Repository navigation
Phase B2b: stage the serving index (#2324) - #2388
Merged
neuromechanist merged 14 commits intoNov 26, 2026
Merged
neuromechanist merged 14 commits into
neuromechanist merged 14 commits into
Conversation
Adds serving_index to nemar.launch-spec.v2 and to a recipe job's spec, the serving index response, the container path and serving_index_mismatch. Tested: contract unit tests.
nemar-ica's archive job is handed the index only when its source_commit is the tag's; the copy is kept by digest before the job exists. Tested later with the route.
POST /compute/jobs/:id/serving-index signs the copy the recorded spec names. Tested: serving-index-staging, route inventory.
Tested: compute-derivatives.
Tested: adr-index.
Not tested: prose only.
10 tasks done
Tested: compute-state (59 pass).
index_unusable for an index the recipe would refuse (readIJson plus validate_document's shape); copy_conflict and copy_put_failed lines; a 403 from S3 is a fault. Tested: serving-index-staging.
A fault leaves a refused serving_index_deferred stamp and answers zarr_source_unverifiable; after 24 hours the run goes without the index. Tested: serving-index-staging (66 pass).
Tested: adr-index.
📦 Package PreviewYour package is ready to test! bun install -g nemar-cli@PR2388Version: 🤖 Updated on each push. |
…-progress' into feature/issue-2324-b2b-serving-index # Conflicts: # CHANGELOG.md
A 403 is an absent index unless the row's copy is ready with stores; a deferral answers serving_index_deferred (503) with runs_without_index_after; the age is whole minutes, the call site narrows by type. Tested: serving-index-staging (74), backend targeted (966).
Not tested: prose only.
Over 50,000 documents judged twice exceed bun's 5 s default on a loaded runner; the corpus keeps its size. Tested: schema-check-contract.
neuromechanist
merged commit Nov 26, 2026
39e2ee3
into
feature/issue-2324-epic-pipeline-progress
25 of 27 checks passed
This was referenced Nov 26, 2026
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase B2b of #2324: the dispatcher stages the serving index for nemar-ica's archive runs, through the launch specification. The launcher side is nemarOrg/nemar-process#96 (into
feature/issue-65-epic-pipeline-progress, nemarOrg/nemar-process#65).Versioning:
nemar.launch-spec.v2(ADR 0141)additionalProperties: false), and the launcher validates against its schema copy and refuses an unknown member asinvalid_spec(launcher/nemar_launch/spec.py). A launcher that reads version 1 would refuse a specification carryingserving_index, so the field is a new version, not a v1 addition.serving_index: {sha256, size}(size at most 64 MiB, the recipe's own bound), and an openserving_index_responsein$defs. Every version 1 document is a version 2 document with the same bytes: the golden vectors and the wire cases are unchanged.RECIPES_KEYING_SERVING_INDEXon the archive input, which runs on Tapis only; no launcher was ever registered with a tenant (nemar-processdeploy/tapis/released-versions.jsonis empty), and a runner is never handed the member.What changed
shared/contract/compute-launch.ts,compute-launch.schema.json,compute.ts,compute-state.ts,compute-recipes.ts): the launch member,ServingIndexResponseSchema,SERVING_INDEX_CONTAINER_PATH(/data/serving-index/index.json), a recipe job'sserving_index({sha256, size}or{reason}, refused on a job without a recipe),SERVING_INDEX_ABSENT_REASONS,recipeServingIndexArguments, and the launcher detailserving_index_mismatchunderdataset_fetch_failed(the platform's).backend/src/services/serving-index-staging.ts,compute-pipeline.ts): for nemar-ica onbids, before the claim, the Worker reads<id>/zarr/index.json(S3 in production, theNEMAR_ZARR_INDEX_BASEseam outside it) and the tag's commit (tagCommit, the Zarr check's own lookup). It stages the index only whensource_commitis exactly the tag's commit; no compare is ever requested, sometadata_onlynever applies. The exact bytes are kept underserving-index/<sha256>.jsonin the records bucket (create-only, a key holding other bytes is never overwritten) before the job exists. Every failure is a word recorded in the spec, and the job is dispatched without the index.--serving-index /data/serving-index/index.json --source-commit <tag commit>after the archive's own arguments, which already name--dataset-id.buildLaunch): the recorded{sha256, size}goes into the launch specification; a recorded word does not.POST /compute/jobs/:id/serving-index: the bundle route's door (job token, lease for a runner, terminal refused), then a ten-minute presigned GET of the copy the RECORDED specification names (read back by its digest), after a head that checks the size. Every other job gets the door's one refusal.keyStamp): a recorded{sha256, size}is keyedsha256:<hex>, and the arguments must hand that copy (the flag once, at the contract path). A recorded word or no record is keyednone, and the arguments must name no index. Anything else isserving_index_unattested.placeholder: true; no path dispatches it.compute-pipeline.tsunderroutes/admin/is not touched (B3 has it).Gates
bun run typecheck: clean.bun run lintand Biome over every changed file: clean.test/compute-serving-index-contract.unit.test.ts,test/compute-contract.unit.test.ts,test/compute-local-launch-contract.unit.test.ts,test/compute-recipes.unit.test.ts,test/contract-schemas.test.ts,test/adr-index.unit.test.ts: 632 pass.serving-index-staging(26, new),compute-derivatives,compute-route-inventory,compute-job-callbacks,zarr-source-check,compute-pipeline,compute-pipeline-input,compute-pipeline-verify,compute-runner-jobs,compute-fixture-eligibility,compute-lifecycle-submit,compute-records,tapis-client: 752 pass.migrations:d1-check.bun test(epic todevonly).Mutation testing
Each mutation applied alone, the targeted tests run, the file restored (script kept in the session scratchpad).
Deviations from the design
getZarrIndexreads it there), so the Worker reads it from S3, through a newgetZarrIndexResponsethat returns the exact bytes.serving-index/<sha256>.json) in the records bucket rather than under the job's ownrecords/<id>/prefix: the job id exists only insidecreateJob, and writing first means no specification ever names bytes that are not kept. Per-job retention does not delete these copies (see the question below).Questions for the owner
Review fixes (round 1)
test/compute-state.unit.test.ts:serving_index_mismatchis underdataset_fetch_failed.platforminTABLE.readIJson: UTF-8, no byte order mark, no repeated member name) andzarr_input.validate_document's shape (stores,store_count, each store'spath,zarrandgroups, each group'sname,modality,rate,n_channels,n_samples, with the recipe's bounds). One that fails isindex_unusableand the run goes ahead at once without it. The recipe side is in B2b: fetch and bind the staged serving index (#65) nemar-process#96: an index it cannot use skips the views of the serving copy withserving_index_unusableinstead of exiting 2, soserving_index_unusablejoinsVIEWS_SKIPPED_NEMAR_PROCESS_WORDS. Residual: a whole number written as3.0is a JSON float in Python and an integer in JavaScript, so the Worker accepts it where the recipe would not; the recipe then skips with its own word.[serving-index] copy_conflict sha256=<hex>for foreign bytes at the content address, and[serving-index] copy_put_failed error=<class>for a store throw; neither shares the genericstage_threwline.github_unreadable,index_unreadable(an S3 throw included),token_mint_failed,no_github_credentialsorindex_not_stored, the run is not dispatched.servingIndexForRunwrites arefusedstamp withserving_index_deferred, the stamp states that already exist (a refused stamp holds no slot, never counts toward the cooldown or the cap, and is left out of the grid), and the dispatch answerszarr_source_unverifiable(503) with the fault's word and the stamp (superseded in round 2 by its own word,serving_index_deferred). No migration.no_index,source_commit_differs,tag_absent,index_too_large,index_unusableandindex_commit_unusablerun at once without the index.getZarrIndex's sweep relies on 403 meaning absent, so that is left alone; the staging readergetZarrIndexResponseis its own, and there a 403 now throws and isindex_unreadable, a fault.zarr_source_unverifiablerather than a new one, soshared/contract/compute-admin.ts(which B3 changes) is untouched.serving-index/is outside the records' lock and retention rules (no sweep; a future sweep must never remove a copy a live job names) and thatprovenance.jsonbinds the index indirectly throughlaunch_spec_digest.Before nemar-ica's placeholder is lifted
nm099999is required: nemar-ica is a placeholder, so no test reachesdispatchPipelineJobpast the placeholder gate. The deferral's mapping is tested throughservingIndexRefusal, but the one call-site line (if (refusal !== null) return refusal;) survives mutation until that test exists (CLI-37 below).nemar.launch-spec.v2.Gates after the fixes
bun run typecheck,bun run lint, Biome over every changed file: clean.test/compute-state.unit.test.tsandtest/quality-documents-contract.unit.test.ts): 804 pass across 8 files.compute-pipeline-grid,compute-pipeline-queue,compute-pipeline-dispatch): 896 pass across 16 files;serving-index-stagingis 66.bun test.Mutations of the new checks
Review fixes (round 2)
The epic base is merged in (a merge, not a rebase), with B3's and B3b's
shared/contract/compute-admin.ts; onlyCHANGELOG.mdconflicted.s3:ListBucket, so a missing object answers 403.getZarrIndexResponsenow hands a 403 back as"forbidden", and staging reads the dataset row withZARR_COPY_SQL(moved beside the rule): a copy that is notready, or has no store, isno_indexand runs at once; areadycopy with stores is a fault (index_unreadable) and defers. The index seam applies the same rule. Tested both ways through a stand-in that answers 403, for four row states.s3:ListBucketon the Zarr prefix; S3 then answers 404 for a missing object, and the row is no longer needed to tell the two apart. Not done here: it is an infrastructure change.if (decided.kind !== "run") return servingIndexRefusal(decided, datasetId, tag);, thendecided.servingIndex.servingIndexRefusaltakes only the two non-run decisions. Dropping the line, or only itsreturn, is abun run typecheckerror (Property 'servingIndex' does not exist on type 'ServingIndexDecision'), checked by hand: CLI-37 is killed by the compiler.serving_index_deferred(503) is its own word: inPipelineRefusal,COMPUTE_PIPELINE_ONLY_REFUSAL_STATUSand the route's sentences. The sentence says the serving index could not be staged because of a temporary fault, that the run is deferred, not failed, that its stamp records the deferral, and that 24 hours after the first deferral the run goes ahead without the index; the answer carriesruns_without_index_after(ISO 8601), the time it goes ahead.PIPELINE_RUN_STATUS_SQLis unchanged (a refused stamp still readsfailedthere); the sentence states that the stamp is a deferral. B3's admin quality route answers a deferred stamprun_not_succeeded.serving_index_deferredand the fieldruns_without_index_after; the website drift tests pin these word lists.servingIndexShapeOk's docstring names the one difference from the recipe: an integer-valued float such as3.0is accepted by the Worker and refused by the recipe, which then skips the views. ADR 0141 no longer calls the provenance binding complete:launch_spec_digestbinds the digest the launcher was handed, not proof that the file was checked. It also records the 403 rule and the word.strftime('%s')), so the boundary is exact; withjuliandayit was a fraction past 1,440 and R2-04 survived.Gates after round 2
bun run typecheck,bun run lint, Biome over every changed file: clean.compute-admin-contract,admin-compute-pipeline-cli,admin-route-inventory,api-export-surface): 953 pass across 12 files.compute-pipeline-routes,quality-admin-route): 966 pass across 18 files;serving-index-stagingis 74.bun test.Mutations, round 2
zarr_source_unverifiableruns_without_index_afteralways 24 hours from nowreturnbun run typecheckCLI-21 to CLI-35 were run again on the new code and all are killed (CLI-24 against the new age SQL); CLI-27, CLI-36 and CLI-37 are superseded by R2-01, R2-02, R2-05 and R2-07.
Agentic AI tools were used.