Skip to content

Hand every BIDS run its tag commit; agree on skipped derivatives - #2460

Merged
neuromechanist merged 14 commits into
devfrom
fix/bids-dispatch-source-commit
Nov 27, 2026
Merged

neuromechanist merged 14 commits into
devfrom
fix/bids-dispatch-source-commit

Conversation

@neuromechanist

@neuromechanist neuromechanist commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Two faults found by a local end-to-end run of the ADR 0134 pipeline (nemar-ica on the archive input of on007823), widened in review round 1 by the owner's ruling of 2026-11-27 (ADR 0143, proposed here).

  1. No Worker-dispatched run of the archive could be stored, except a nemar-ica run with a staged serving index.
    nemar-process records the commit it is handed (--source-commit) as extensions.nemar.dataset.source_commit, and ADR 0123 decision 3 keys a BIDS derivative by git: and that commit.
    The dispatcher handed one only with a staged index, so every other run of the archive (every nemar-floor run included) stated none, its stamp had no digest, and the derivative store skipped it for good (no_input_digest). ADR 0121 decision 10 had written that state down.
    Fix (ADR 0143):
    • every Worker-dispatched run of the archive, of every recipe, reads the commit of its version's tag at dispatch (versionTagCommit, one tag lookup, before the claim) and is handed it as --source-commit: after the staged index's file when one was staged (byte-identical to before), alone otherwise;
    • a GitHub fault reading it (github_unreadable, token_mint_failed, no_github_credentials) defers the run: a refused stamp source_commit_deferred, a 503 source_commit_deferred with the fault's word, no end (a run without its commit could never be keyed), and it stops a run over the queue;
    • staging is handed the commit and reads only the index; the serving index's 24-hour deferral now covers index faults only, and a run past it still has its commit;
    • keyStamp keys a BIDS stamp only when its digest is exactly git: and the commit the recorded specification hands; another commit, or two handed, is digest_mismatch (a specification from before that hands none is not checked).
  2. A permanently skipped derivative read differently in the grid, the coverage and the run detail.
    The stored checkpoint was resolved only by the stamp sync, which none of those read-only routes runs, and coverage complete read only the last checkpoint before stored.
    Fix: syncDerivatives ends by resolving the stored rows it decided (resolveDecidedStored, now a static import: the read bounds and the derivative object prefix moved to a leaf module, compute-derivative-constants.ts, so there is no import cycle and no dynamic import), and coverage complete excludes a run whose decided stored row did not keep every recording. An undecided run still counts complete by its last checkpoint.

The tag_absent decision (review round 1, item 4)

A version whose tag the repository does not have is refused (version_tag_absent, 409, nothing written, logged as version_tag_absent dataset=<id> version=<tag>), not run and not deferred.
A version the data plane serves whose tag is gone is an integrity fault an administrator mends by restoring the tag: a retry cannot mend it, so a deferral would only write a stamp on every pass, and a run without its commit could never be keyed, so running it would spend an allocation on a derivative that cannot be stored.
The dataset stays a candidate of the queue, which moves on to the next one (the word does not stop a run over the queue).
The dry run still reads only D1 and the configuration, so it can say would_dispatch for such a version; the live run refuses it.

ADRs

  • ADR 0143 (proposed): every Worker-dispatched run of the archive is handed its tag's commit, or waits for it. It supersedes the last clause of ADR 0121 decision 10 and refines ADR 0141 decisions 3 and 4.
  • ADR 0121 gains a "Partially superseded by ADR 0143" line under its header and a dated pointer under decision 10; ADR 0141 gains a "Refined by ADR 0143" line. The ADR 0141 amendment added earlier on this branch is folded into ADR 0143 (it was never on dev).
  • The index lists ADR 0143 (and a load-bearing line). test/adr-index.unit.test.ts tolerates the 0142 gap that Phase 0: ADR 0142 (license identification, decision card, lineage reliability) #2458 reserves; whichever of the two merges second removes that entry.

Repro (local stack, before this change)

  • nemar-ica dispatched on on007823 v1.0.0: the tag is at 4662b76a and the serving index says source_commit bc47f4bc, 6 commits ahead, so staging answered source_commit_differs and the arguments carried no --source-commit.
  • The run finished; pipeline status showed stored 0/1 P and complete 1; derivatives sync answered derivative_unkeyable: { no_input_digest: 1 }.
  • A read-only grid read after that sync still showed stored pending and coverage still complete 1; only after a pipeline status call (which syncs) did the run detail show stored: skipped.
  • The serving index commit mismatch itself is Serving indexes are built after the version tag: nemar-ica stages none for 807 of 812 #2461 (807 of 812 ready indexes are built after their tag); the admission of an index ahead of its tag by metadata only is the stacked PR that follows this one.

Tests

Targeted (from backend/ unless noted), all on the pushed head:

29 backend suites (compute-derivatives, -e2e, -fixture-eligibility, -local-stack, -local-stack-runner, -pipeline-caps,
-pipeline-dispatch, -pipeline-grid, -pipeline-input, -pipeline-queue, -pipeline-routes, -pipeline-tapis-unconfigured,
compute-pipeline, -progress-reconcile, -progress-route, -runner-jobs, -runner-progress, -runner-queue,
-runner-reporting, -source-scan, -tenant-ceiling, oidc-token-allowlist, quality-admin-route, quality-admin-views,
quality-documents, quality-processing-route, quality-route, zarr-source-check, serving-index-staging):
 1059 pass, 0 fail
cron-sweep-wiring, compute-job-callbacks, compute-pipeline-stamps-migration, metadata-json-pipeline-route,
metadata-json-quality, compute-full-path, compute-pipeline-verify, compute-sweep, compute-results-routes:
 all pass, 0 fail
(root) admin-compute-pipeline-cli, admin-compute-derivatives-cli, admin-compute-jobs-cli, compute-recipes,
compute-serving-index-contract, compute-admin-contract, adr-index, admin-route-inventory, api-export-surface:
 all pass, 0 fail
bun run typecheck   clean; bun run lint clean; biome on every touched file: no errors (15 existing `any` warnings)

What the tests pin:

  • serving-index-staging.test.ts: the tag's commit is read first (with or without the tag's v), and nothing is written; an absent tag is tag_absent, refused version_tag_absent (409) with nothing written and logged; a GitHub fault, and a production Worker without the App, are deferred with a source_commit_deferred stamp and still deferred two days on; a live stamp refuses the deferral's claim; through dispatchPipelineJob, a floor run is deferred, then refused, before any job, and dispatched once the tag is there; staging is handed the commit and asks GitHub nothing; index faults alone defer, and a run past 24 hours has its commit; nemar-ica's arguments end with --source-commit <tag commit> for every word, and a spec of a run of the archive without a commit, or with an abbreviated one, throws.
  • compute-derivatives.test.ts: the on007823 shape through sourceCommitForRun, servingIndexForRun, recipeJobSpec, the stamp sync and the store pass (stored, git:<tag commit>, serving_index none); digest_mismatch for a record that states another commit, or a spec that hands two; a record that states the handed commit is keyed by it; the view cases now use a genuinely unkeyable run (digest_mismatch: every recording passed, the record states another commit) and a stored one.
  • zarr-source-check.test.ts: a BIDS recipe asks GitHub only for its tag (one request), reads no index and asks no compare, and its vector is the archive's own and --source-commit. compute-runner-jobs.test.ts: the BIDS spec hands the commit, and one without throws.
  • Suites that dispatch a run of the archive use a GitHub tag stand-in (backend/test/helpers/github-tags.ts, wired into startLifecycleFixture({ githubTags: true })): a real loopback server for the one external request, with the App configuration and a seeded installation token.

Revert checks (each restored afterwards):

  • Round 0: dispatcher change reverted, the derivatives case fails at no_input_digest; the store's stored step removed, both view cases fail; the coverage rule reverted, the skipped case fails.
  • A GitHub fault read as an absent tag (no deferral): 4 source-commit cases fail.
  • An absent tag deferred instead of refused: 2 cases fail.
  • Only a staged index's run handed the commit (the old rule): the BIDS vector cases in zarr-source-check and compute-runner-jobs fail.
  • The BIDS digest check removed: both digest_mismatch cases fail.

Not run: the full bun test (about 80 minutes); it would check the suites no grep for pipeline dispatch, stamps or the changed functions found, because every Worker-dispatched BIDS run now makes a GitHub request that a suite without the stand-in answers no_github_credentials.

Review round 2 (queue starvation)

  1. Only a credential fault stops the queue. source_commit_deferred left STOPS_A_RUN; a run over the queue stops on it only when the reason is no_github_credentials or token_mint_failed (SOURCE_COMMIT_CREDENTIAL_FAULTS), and the daily cron then ends the tick (ENDS_THE_RUN). github_unreadable can be one repository's (a renamed repository under redirect: "manual", an empty one, a 451, a bad sha), so that dataset is deferred and the queue moves on.
  2. Refused heads never fill the room. A run asks pipelineCandidates for PIPELINE_RUN_EXTRA_TRIES (10) candidates beyond its room and stops at the room. I kept ADR 0143 decision 3 as written (refused with nothing written, the dataset stays a candidate and the queue moves on) instead of excluding such datasets in the candidate SQL. The SQL cannot know that a tag exists again without a record of its absence, and writing one would change decision 3. The extra tries bound what one tick spends: at most 40 GitHub requests and about 80 statements, added to the cron's cost note. More than ten refused datasets at once at the head of the order would still hold a run, and each is logged by name.
  3. The serving index's 24-hour clock ignores source_commit_deferred stamps (SERVING_INDEX_DEFERRAL_AGE_SQL).

ADR 0143 decisions 2, 3 and 5, the index line and the changelog say so. The GitHub tag stand-in now answers a tag the same under both spellings (v1.0.0, then 1.0.0 after a 404), which the absent-tag cases need.

Tests and revert checks:

  • compute-pipeline-queue.test.ts: a credential fault (a production Worker without the App) stops the queue at the first of three datasets with one deferral stamp (fails with "never stop on source_commit_deferred"); a 502 for the first repository defers it and the second dispatches (fails with "stop on every source_commit_deferred" and with "only the room's worth of candidates"); ten heads refused version_tag_absent and the eleventh dispatches, with only its stamp written (fails with "only the room's worth of candidates").
  • serving-index-staging.test.ts: an index deferral 25 hours ago and a commit deferral an hour ago, then an index fault, runs without the index (fails when the commit's deferral counts as another kind).
  • Suites opted into the tag stand-in, and their neighbors, all on this head: compute-e2e 3, compute-pipeline-caps 13, compute-pipeline-dispatch 48, compute-pipeline-grid 26, compute-pipeline-queue 33, compute-pipeline-routes 36, compute-pipeline-tapis-unconfigured 29, compute-pipeline 63, compute-progress-reconcile 31, compute-progress-route 12, compute-tenant-ceiling 51, compute-runner-jobs 73, compute-runner-reporting 22, zarr-source-check 82, serving-index-staging 79, compute-derivatives 98, compute-pipeline-input 34, compute-local-stack 33, compute-local-stack-runner 6; root admin-compute-pipeline-cli, adr-index and compute-serving-index-contract 93. All pass, 0 fail; typecheck and lint clean.

Merging with the other open PRs

Agentic AI tools were used. Workflows follow the Research Skills (doi:10.5281/zenodo.20696515). The author assumes full responsibility for this content and associated changes.

A nemar-ica run of the archive with no serving index staged got no
--source-commit, so its record stated no commit, its stamp had no input
digest and its derivative was skipped for good (no_input_digest). The
staging answer now carries the tag's commit whenever it was read, and
the job spec hands it as --source-commit with or without an index.

Tested: serving-index-staging, compute-derivatives (nemar-ica cases),
compute-serving-index-contract; each new case fails with the fix
reverted.
Names the mechanism decision 6 always implied: a run staged without a
serving index is handed --source-commit and the tag's commit whenever it
was read, so its derivative is keyed none and stored.

Tested: adr-index unit test.
The grid and a run's detail read the stored checkpoint from a progress
row that only the stamp sync resolved, so after the derivative store
skipped a run they showed it pending until the next sync, and coverage
counted it complete. The store's pass now resolves the stored rows it
decided, and coverage complete excludes a run whose decided stored row
did not keep every recording.

Tested: compute-derivatives (new view cases), compute-progress-reconcile,
compute-pipeline-grid, quality-admin-route; both parts revert-checked.
Not tested: changelog text only.
Keeps the new case apart from the nemar-ica placeholder case, which a
parallel change edits.

Tested: compute-serving-index-contract unit test (13 pass).
@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR2460

Version: 0.10.49-PR2460.16a81bf
Commit: 16a81bf


🤖 Updated on each push.

The read bounds and the derivative object prefix move to a leaf module
the progress and quality modules read, so the store imports
resolveDecidedStored at the top with no cycle; the dynamic import and
its catch, which only guarded the module load, are gone.

Tested: compute-derivatives, compute-progress-reconcile, quality suites
(252 pass).
keyStamp trusted the record's git: digest. When the recorded spec hands
--source-commit, the stamp's digest must be exactly git:<that commit>;
another commit, or two handed, is digest_mismatch.

Tested: compute-derivatives (98 pass); the two mismatch cases fail
with the check removed.
Every Worker-dispatched run of the archive, nemar-floor included, now
reads its version's tag commit at dispatch and gets --source-commit. A
GitHub fault defers the run (source_commit_deferred, a refused stamp,
no end; it stops the queue); an absent tag refuses it
(version_tag_absent, nothing written). Staging is handed the commit and
reads only the index. Suites that dispatch a BIDS run use a GitHub tag
stand-in (helpers/github-tags.ts). The coverage case now uses a
genuinely unkeyable run (digest_mismatch), as does the CLI help.

Tested: 29 backend compute and quality suites (1059 pass) plus the
callback, cron, sweep, metadata and CLI suites; revert-checked.
Supersedes the last clause of ADR 0121 decision 10 and refines ADR
0141 decisions 3 and 4 (pointers in both); the 0141 amendment added
earlier on this branch is folded into it. Tolerates the 0142 gap that
PR #2458 reserves.

Tested: adr-index unit test.
Not tested: changelog text only.
@neuromechanist neuromechanist changed the title Store unstaged nemar-ica BIDS runs; agree on skipped derivatives Hand every BIDS run its tag commit; agree on skipped derivatives Nov 27, 2026
Only a GitHub credential fault (no_github_credentials, token_mint_
failed) stops a run over the queue, and it ends the daily tick; a
github_unreadable deferral is one repository's and is passed over. A
run asks for PIPELINE_RUN_EXTRA_TRIES (10) candidates beyond its room,
so datasets refused for a missing tag or deferred never fill it. The
tag stand-in now answers both tag spellings.

Tested: compute-pipeline-queue (33 pass); each new case fails with its
mutation.
A source_commit_deferred stamp no longer counts as another kind in
SERVING_INDEX_DEFERRAL_AGE_SQL, so it does not restart the 24 hours.

Tested: serving-index-staging (79 pass); the new case fails when the
word is counted as another kind.
Narrows decision 2, adds the extra tries to decision 3 and the clock
to decision 5; index line and changelog follow.

Tested: adr-index unit test.
@neuromechanist
neuromechanist merged commit 978a55b into dev Nov 27, 2026
27 checks passed
@neuromechanist
neuromechanist deleted the fix/bids-dispatch-source-commit branch November 27, 2026 11:44

This branch was previously deployed

1 inactive deployment
npm — 16a81bfb Deployed Nov 27, 2026 by neuromechanist via publish #5121
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant