Explorer

definy.read-snapshot-check-input

description
What definy.check-snapshot checks for a project snapshot (docs/service.md): the parts with their definitions and the latest snapshots of the main branches as the type environment. none if it is not a project snapshot (definy.submit-verified-event checks that the contents are in the CAS first). The decoded snapshot is also passed to then, so the caller can put it in the snapshot cache once it is stored instead of decoding it again on the next submit
type
Fn(
  signed_event_bytes: String,
  then: Fn(
    input: Union{#none, #some(@definy.snapshot-check-source)},
    commit: Union{#none, #some(@definy.stored-snapshot)}
  ) -> @definy.service-io
) -> @definy.service-io
expression
fn(signed_event_bytes$0, then$1) =>
  match @definy.decode-stored-snapshot(signed_event_bytes: $0) {
    #none(_) =>
      $1(input: #none, commit: #none),
    #some(commit$2) =>
      let parts$3 = @definy.snapshot-parts(modules: $2.modules, index: 0);
      let hashes$4 = @core.list-map(
          T: @definy.stored-snapshot-part,
          U: String,
          f: fn(item$5) =>
            $5.content_hash,
          xs: $3
        );
      @definy.read-snapshots(
        then: fn(commits$6) =>
          let latest$7 = @definy.latest-main-snapshots(commits: $6);
          @definy.read-resolutions(
            content_hashes: $4,
            then: fn(resolutions$8) =>
              @definy.read-definitions(
                content_hashes: @definy.unresolved-hashes(hashes: $4, resolutions: $8),
                then: fn(definitions$9) =>
                  match @definy.closure-references(parts: $3, resolutions: $8, definitions: $9, types_only: false) {
                    #fallback(_) =>
                      @definy.read-snapshot-check-input-full(
                        commit: $2,
                        parts: $3,
                        latest: $7,
                        then: fn(input$10, commit$11) =>
                          $1(input: $10, commit: $11)
                      ),
                    #refs(refs$12) =>
                      let candidates$13 = @definy.closure-candidates(commits: $7, index: 0);
                      let project_module_ids$14 = @definy.project-module-ids(commits: $7, project_name: $2.project_name, index: 0);
                      @definy.latest-closure(
                        candidates: @definy.closure-candidate-index(candidates: $13),
                        frontier: @core.list-concat(
                          left: @core.list-concat(left: @definy.closure-implicit-roots, right: $12),
                          right: @definy.closure-module-part-ids(
                            candidates: $13,
                            module_ids: @core.list-concat(
                              left: @core.list-map(
                                T: @definy.stored-snapshot-module,
                                U: String,
                                f: fn(item$15) =>
                                  $15.id,
                                xs: $2.modules
                              ),
                              right: $14
                            ),
                            index: 0,
                            result: []
                          )
                        ),
                        selected: [],
                        found: [],
                        resolutions: [],
                        definitions: [],
                        then: fn(closure$16) =>
                          match $16 {
                            #none(_) =>
                              @definy.read-snapshot-check-input-full(
                                commit: $2,
                                parts: $3,
                                latest: $7,
                                then: fn(input$17, commit$18) =>
                                  $1(input: $17, commit: $18)
                              ),
                            #some(closure$19) =>
                              $1(
                                input: #some({
                                  project_name: $2.project_name,
                                  parts: @core.list-map(
                                    T: @definy.stored-snapshot-part,
                                    U: @definy.snapshot-check-source-part,
                                    f: fn(item$20) =>
                                      @definy.source-part-of(part: $20, definitions: $9),
                                    xs: $3
                                  ),
                                  latest_commits: @core.list-map(
                                    T: @definy.closure-candidate,
                                    U: @definy.latest-snapshot-source,
                                    f: fn(item$21) =>
                                      {
                                        project_name: $21.project_name,
                                        parts: [@definy.source-part-of(part: $21.part, definitions: $19.definitions)]
                                      },
                                    xs: $19.parts
                                  ),
                                  project_module_ids: $14,
                                  resolutions: @core.list-concat(left: $8, right: $19.resolutions)
                                }),
                                commit: #some($2)
                              )
                          }
                      )
                  }
              )
          )
      )
  }
visibility
public
definy.read-snapshot-check-input (project definy, branch main, snapshot l0VFjJZP174d8CbZWFoujAGTYjgsQu4uTq5uWCZaXgo)
id: ZOIULgVySaxoWjlZgj1xVUrZlQ3GD_Oj7ZA4W-ve_X4
content hash: 0I3VuLB8Hu__921dpVmN1EblIaZ7OKnUcOaFTNXnSDI