Skip to content

Stage a serving index ahead of its tag by NEMAR's own metadata, as the tag's - #2464

Merged
neuromechanist merged 32 commits into
devfrom
feat/serving-index-metadata-ahead
Nov 27, 2026
Merged

neuromechanist merged 32 commits into
devfrom
feat/serving-index-metadata-ahead

Conversation

@neuromechanist

@neuromechanist neuromechanist commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Builds on #2460, now merged to dev (978a55b); this PR targets dev, and the branch merged dev in (its diff against dev is this change alone).

The owner's ruling of 2026-11-27 on #2461 (ADR 0144, proposed here): the data and events a serving copy was created from are the tag's, and NEMAR's metadata (.nemar/, .github/, .gitattributes) is readiness work that changes without a tag. So a copy built from a commit ahead of the tag by that work is kept as the tag's.

What is admitted

servingIndexAheadOfTag (in zarr-source-check.ts, called by stageServingIndex) handles an index whose commit S is not the tag's commit T:

  • One GitHub compare of T...S, using the Zarr check's request, timeout and bound.
  • The compare must answer ahead, behind_by 0, and fewer than 300 files.
  • Every changed path, and a renamed file's previous path, must be under .nemar/ or .github/, or be a .gitattributes file at any depth.

A .gitattributes edit is admitted only when it cannot change checkout bytes (gitattributesPatchProblem, an allow-list since review round 2). Every attribute of every line the patch adds or removes is checked, macro definitions ([attr]name) included. A line starting +++ or --- is checked like any other, since a compare patch holds hunk lines only.

  • Admitted in any form: annex.*, diff, merge.
  • Admitted only set: text, binary, eol=lf.
  • Admitted only as this value: filter=annex.
  • Refused (index_content_changed): everything else, including eol=crlf, -eol, !eol, -text, !text, text=auto, -binary, other filters, working-tree-encoding, ident, and any unknown name, which could be a macro.
  • CR LF anywhere in the file: any line that can turn CR LF conversion on (eol=crlf, legacy crlf, on a macro definition too) refuses the edit, because that is the one condition under which text, binary and eol=lf change bytes. The patch's own lines are checked first.
  • Every .gitattributes at S, changed or not (81fef998): an admitted binary in one file changes bytes under an eol=crlf in another, so once a delta that changes any .gitattributes is otherwise admitted:
    • One recursive tree listing of S (git/trees/S?recursive=1, 8 MiB bound; GitHub truncates at 7 MB, so any whole answer fits) names every .gitattributes.
    • Each is read whole once (one contents request, 1 MiB bound), including a changed one the listing lacks. No line in any of them may carry eol=crlf or crlf, or the delta is index_content_changed.
    • A truncated listing, one over its bound, or more than 24 files (SERVING_INDEX_MAX_GITATTRIBUTES_FILES) is index_delta_unlisted.
    • A listing or file that cannot be read is github_unreadable and defers the run, like an unread compare.
    • Why 24: each file is one request, and a dataset carries one or two (the root's and .datalad/'s). Across the 396 repositories GitHub's code search indexed on 2026-11-27, none carried more than two. The worst case is the compare, one listing and 24 reads: 26 requests a dataset after the tag's commit.
  • Missing patch: a .gitattributes change whose patch GitHub leaves out is index_delta_unlisted.
  • on007823: its real patch (annex rules and text eol=lf lines going) is still admitted.

Not admitted: .bidsignore, other .datalad/ files, data files, BIDS files, and anything that is not a plain path.

What is refused

  • Refusal words: index_behind_tag, index_diverged, index_content_changed and index_delta_unlisted. The last now also covers a compare body over the bound (previously a fault).
  • After a refusal the run goes ahead at once without the index, with the tag's commit.
  • A compare GitHub cannot answer, or answers in a shape the Worker does not read, is github_unreadable. That defers the run (serving_index_deferred), so a compare that can never be answered costs one 24-hour deferral and then a run without the index.

The run is the tag's; S is provenance

  • What the run is handed: an admitted index goes to the run with the TAG's commit, --serving-index /data/serving-index/index.json --source-commit T. The record states T and the derivative is keyed by git:T plus the staged copy's digest, so ADR 0123 decision 3 and ADR 0143 stand unchanged.
  • What is recorded: the job's specification records the admission as provenance, serving_index: {sha256, size, ahead_of_tag: {tag_commit, index_commit, changed_path_count}}. changed_paths is renamed to changed_path_count.
  • Launch specification: it still carries only {sha256, size}.
  • recipeJobSpec checks: it refuses an admission whose tagCommit is not the commit handed, or whose index commit is the tag's.
  • Field cleanup: StagedServingIndex drops its duplicate sourceCommit. The tag's commit is the one handed; the index's commit is ahead.indexCommit.
  • Keying check: keyStamp keys such a run only when the specification hands exactly the recorded tag_commit; otherwise it is serving_index_unattested. The digest must also be git: + that commit, per ADR 0143 decision 4.

The attestation to the recipe (nemarOrg/nemar-process#108, commit c86eeb99):

  • The vector. After --source-commit T, the arguments add --serving-index-commit S and one --serving-index-delta-path per changed path, a renamed file's old name included, each once and in code-unit order. The recipe uses a row only when its --source-commit is the attested T and the index's source_commit is S.
  • The bound. A job's argument vector is at most 64 strings and such a run uses 16 of them, so at most 24 paths fit (RECIPE_SERVING_INDEX_MAX_DELTA_PATHS; the recipe takes 32). A larger delta is refused as index_delta_unlisted, never cut short. 24 paths of the longest allowed length (512 characters) build a 64-argument specification.
  • Paths. A path with no UTF-8 form (a lone surrogate) is refused.
  • Keying. keyStamp keys such a run only when the arguments hand the recorded tag_commit, attest the recorded index_commit, and carry changed_path_count paths; and only when nothing is attested for an index of the tag's own commit, or when no index was staged.
  • Runtime image. A run handed the attestation needs a runtime image built with Phase 3: Rich metadata enrichment for DataCite DOIs #108; an older image refuses the flags (exit 2). nemar-ica is no longer a placeholder (Lift nemar-ica's placeholder: an administrator can run it #2462, merged into this branch). What gates this is compute being dark plus the release order: Phase 3: Rich metadata enrichment for DataCite DOIs #108 merges before nemar-process's 0.1.2 release image, and COMPUTE_RUNTIME_IMAGE is repinned to that image before compute turns on. This is in ADR 0144's consequences and the CHANGELOG's deploy order.
  • Launch bytes. A comment by RECIPE_SERVING_INDEX_MAX_DELTA_PATHS notes that 24 long non-ASCII paths can exceed LAUNCH_VARIABLE_BYTES_MAX. The spec then does not build, and the dispatch answers invalid_spec before the claim.
  • Drift test. test/compute-recipes-process-drift.unit.test.ts compares recipe versions, engines and steps, not flags, and Phase 3: Rich metadata enrichment for DataCite DOIs #108 changes none of them. It passes against nemar-process dev and against Phase 3: Rich metadata enrichment for DataCite DOIs #108's head (16 each), so no drift test waits for Phase 3: Rich metadata enrichment for DataCite DOIs #108.

Effect on #2461's data

Re-counted with the patch rule, one read-only GitHub compare per dataset, on the same 40 sampled datasets whose index is newer than their tag:

  • 33 admitted. None of the sampled .gitattributes patches touches a byte-changing attribute.
  • 6 changed a path that is not NEMAR's own: content in 4 (on005815, on006817, nm000272, on004067), and .bidsignore alone in 2 (on001787, on006126).
  • 1 listed 300 or more files.

Refs #2461. It does not close it: copies built after a content change still need a rebuild at the tag or a new tag.

Tests

Run on the pushed head:

(backend) serving-index-staging 120, compute-derivatives 105, zarr-source-check, compute-pipeline-input, compute-pipeline,
compute-pipeline-queue, compute-pipeline-routes, compute-pipeline-dispatch, compute-runner-jobs, compute-runner-queue,
compute-fixture-eligibility, compute-local-stack, quality-admin-route, compute-e2e, compute-pipeline-tapis-unconfigured,
compute-progress-reconcile: 843 pass, 0 fail
(root) compute-serving-index-contract, compute-recipes, adr-index, admin-compute-pipeline-cli: 160 pass, 0 fail
(root) compute-recipes-process-drift with NEMAR_PROCESS_DIR at nemar-process dev (9af867a) and at #108 (1f08b149): 16 pass each
bun run typecheck clean; bun run lint clean; biome on every touched file clean

New or changed cases:

  • serving-index-staging.test.ts:
    • on007823's delta, with its real .gitattributes patch, is staged and the spec ends with --source-commit T.
    • Malformed compare answers are faults: status identical, ahead without behind_by, a file entry that is not an object, no filename, a filename or previous filename that is not text.
    • .gitattributes patches that add eol=crlf, remove eol=crlf, add working-tree-encoding, add ident, unset ident, add a filter=lfs, or give a quoted pattern with eol=crlf are refused.
    • An annex-only patch, filter=annex, and a comment naming eol=crlf are admitted. A missing patch is index_delta_unlisted.
    • An over-bound compare body is index_delta_unlisted and the run goes ahead.
    • recipeJobSpec hands T with an admitted index, and refuses an admission compared with another tag commit, or one ahead by nothing.
  • compute-derivatives.test.ts:
    • An admitted run is stored under git:T and the index's digest, with ahead_of_tag naming S.
    • A spec handing another commit than the recorded tag_commit is serving_index_unattested.
  • compute-serving-index-contract.unit.test.ts: the changed_path_count shape.

Every .gitattributes at S (81fef998), in serving-index-staging.test.ts, 145 pass:

  • A root * eol=crlf the delta does not touch, under a nested edit that adds *.tsv binary, refuses; so does a nested unchanged *.tsv eol=crlf under a root edit, found only by a recursive listing.
  • With no CR LF rule anywhere, the same edit is admitted from one listing asked recursive=1, and each file is read once, the changed one too.
  • A truncated listing is index_delta_unlisted, with nothing read.
  • 24 files are read and admitted; 25 are index_delta_unlisted, with nothing read.
  • A listing answered 404, 500, without truncated, without tree, or with a malformed entry is github_unreadable, with nothing read; one over its bound is index_delta_unlisted; through servingIndexForRun a 502 defers the run.
  • A changed .gitattributes the listing lacks is still read (refused on its eol=crlf; github_unreadable when absent).
  • A delta that changes no .gitattributes lists no tree and reads no file.
  • on007823's delta and its real file at S still admit, with a listing modeled on its real tree at bc47f4bc (its one .gitattributes among 1,537 files, not truncated).
  • Other suites: compute-derivatives 105, zarr-source-check 82, compute-pipeline-input 36, compute-pipeline 63, compute-pipeline-dispatch 48, compute-runner-jobs 73, compute-runner-reporting 22, adr-index 11; all pass.

Revert checks for the listing (each restored, verified with cmp):

Mutation Result
Read only the changed files 3 fail
List the top level only (no recursive) 3 fail
Ignore truncated 1 fails
Drop the 24-file bound 1 fails
Read the listing alone (a changed file it lacks unread) 1 fails
Admit on an unread listing 2 fail
Over-bound listing read as unreadable 1 fails

Whole-file read (72888ad4), in serving-index-staging.test.ts, 139 pass at the time:

  • An unchanged * text eol=crlf 40 lines from the hunk refuses, and so do a [attr]m eol=crlf definition and a legacy crlf (one read each, at S).
  • on007823's real file at S (bc47f4bc) admits.
  • A file absent at S, answered 500, answered without base64 content, or over the bound is github_unreadable; through servingIndexForRun the run is deferred.
  • A deleted .gitattributes is not read, and a renamed one is read under its new name only.
  • Revert check: dropping the whole-file read fails those three cases.
  • The cron cost note counts these requests: one listing and at most 24 reads per dataset, only for a delta that changes a .gitattributes and is otherwise admitted, and only for a recipe that keys the serving index, which the dispatcher does not run today.

Review round 2 (23b4330a), all in serving-index-staging.test.ts, 135 pass at the time:

  • Refused: +*.tsv !eol, +*.tsv -eol, +*.tsv -text, +*.tsv m (a macro use), a macro used beside an unchanged [attr]m eol=crlf, +++x eol=crlf, ---y working-tree-encoding=UTF-16, text=auto, the legacy crlf, -binary, a removed -text, and an added text beside an unchanged eol=crlf.
  • Admitted: binary, diff and merge in every form, and a macro defined with annex rules only.

Revert checks for round 2 (each restored):

Mutation Result
The old block-list 7 fail, the four review cases among them
Skip +++/--- lines again 2 fail
Drop the context CR LF check 1 fails

Attestation cases (c86eeb99):

  • The exact vector for an admitted index (base, --serving-index, --source-commit T, --serving-index-commit S, the delta paths), on007823's included.
  • No attestation for an index of the tag's own commit.
  • Paths each once and sorted, a rename's old name included.
  • 24 paths of the longest length fit and 25 are index_delta_unlisted.
  • A lone surrogate is refused.
  • The helper recipeServingIndexAttestationArguments: flags, the bound arithmetic, and a refusal for equal commits, a bad commit, 25 paths, an empty path, or a repeated path.
  • Five new serving_index_unattested keying cases.

Revert checks for the attestation (each restored):

Mutation Result
No attestation arguments 4 fail
No path bound 1 fails
Bound lowered to 23 1 fails
Keying ignores the attestation 3 fail
Keying accepts an attestation without an admission 1 fails
A lone surrogate admitted 1 fails

Earlier revert checks (each restored afterwards; "fail" counts failing tests):

Mutation Result
Hand the index's commit 3 fail
No tag-commit check in recipeJobSpec 1 fails
No ahead-by-nothing check 1 fails
.gitattributes patches not read 7 fail
Removed lines not read 1 fails
Over-bound compare read as unreadable 1 fails
Keying checks the index's commit instead of the tag's 1 fails

Not run: the full bun test (about 80 minutes). It would check every other suite, because the serving index's recorded shape and words changed; only the suites that grep for serving index, staging, stamps or pipeline dispatch were run.

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).
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.
One GitHub compare of the tag's commit and the index's admits an index
whose commit is ahead by .nemar/, .github/ and .gitattributes paths
only; the spec records ahead_of_tag (both commits, changed paths) and
the run is handed the index's commit, the one the recipe accepts.
Behind, diverged, content changes and unlisted deltas are refused
with their own words; an unread compare defers. Keying checks the
handed commit is the admitted one.

Tested: serving-index-staging (96), compute-derivatives (100), the
contract unit tests and the compute suites (1127 pass); revert-checked.
Supersedes ADR 0141 decision 2 in part, refines ADR 0143 decision 1
and ADR 0123 decision 3 for such a run; pointers in 0141 and 0143.

Tested: adr-index unit test.
Not tested: changelog text only.
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.
… into feat/serving-index-metadata-ahead

# Conflicts:
#	.context/decisions/README.md
Owner ruling: the run is the tag's. An index admitted ahead of its tag
is handed with the tag's commit (--source-commit T) and keyed git:T;
its own commit is provenance in ahead_of_tag (tag_commit,
index_commit, changed_path_count, renamed from changed_paths).
recipeJobSpec refuses an admission compared with another tag commit,
or one ahead by nothing; StagedServingIndex drops its duplicate
sourceCommit; keyStamp checks the handed commit is the recorded
tag_commit. A .gitattributes edit is admitted only when its patch adds
or removes no eol=crlf, working-tree-encoding, ident or non-annex
filter, and refused unlisted without a patch. An over-bound compare is
index_delta_unlisted, not a fault. The nemar-process arguments that
let the recipe use an admitted index come in a later commit.

Tested: serving-index-staging (116), compute-derivatives (100) and 14
more compute suites (834 pass in all), root contract, recipe, adr and
CLI tests (146); seven revert checks.
Hand T, keep S as provenance, state the owner's invariant, correct the
claim that .gitattributes never changes bytes, say why the rule
differs from ZARR_SOURCE_DELTA_ROOTS, and note that an unanswerable
compare costs one 24-hour deferral. Renamed for the new title.

Tested: adr-index unit test.
@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@PR2464

Version: 0.10.50-PR2464.4e51bf6
Commit: 4e51bf6


🤖 Updated on each push.

@neuromechanist neuromechanist changed the title Stage a serving index ahead of its tag by NEMAR's own metadata Stage a serving index ahead of its tag by NEMAR's own metadata, as the tag's Nov 27, 2026
Base automatically changed from fix/bids-dispatch-source-commit to dev November 27, 2026 11:44
…adata-ahead

# Conflicts:
#	.context/decisions/0141-the-dispatcher-stages-the-serving-index-and-the-launch-specification-is-version-2.md
#	.context/decisions/README.md
#	CHANGELOG.md
#	backend/src/services/compute-pipeline.ts
#	backend/src/services/serving-index-staging.ts
#	backend/test/compute-derivatives.test.ts
#	backend/test/serving-index-staging.test.ts
The plumbing for nemarOrg/nemar-process#108: a run handed an index
ahead of its tag keeps --source-commit T and adds --serving-index-
commit S and one --serving-index-delta-path per changed path (old
names of renamed files included, each once, code-unit order). A job's
64 arguments fit 24 paths, so admission refuses a larger delta as
index_delta_unlisted instead of cutting it; a path with no UTF-8 form
is refused. keyStamp keys such a run only when the arguments attest
the recorded index commit and path count, and attest nothing when no
index ahead of its tag was staged. The marker is gone.

Tested: serving-index-staging (120), compute-derivatives (105), 14
more compute suites (843 pass), contract/recipes/adr/CLI unit (160),
the drift test against nemar-process dev and #108 (16 each); six
revert checks.
A block-list admitted !eol, -eol, -text and macro uses that change
checkout bytes when CR LF conversion is in effect. Every attribute of
every added or removed line, macro definitions included, must now be
annex.* or diff/merge (any form), filter=annex, or text, binary,
eol=lf set; any patch line, context included, that can turn CR LF
on (eol=crlf, legacy crlf) refuses the edit. Lines starting +++ or
--- are no longer skipped: a compare patch has hunk lines only.

Tested: serving-index-staging (135 pass); the old block-list fails 7
cases, skipping +++/--- fails 2, dropping the context check fails 1.
Tested: adr-index unit test.
The patch shows only touched lines and a little context, so an
unchanged eol=crlf line elsewhere in the file went unseen. Each changed
.gitattributes the edit leaves at the index's commit is now read whole
(GitHub contents at S, 1 MiB bound; a deleted file is skipped, a
renamed one read under its new name) and any line, macro definitions
too, that turns CR LF on refuses the index. A file that cannot be read
whole is github_unreadable and defers. The stand-in answers contents.

Tested: serving-index-staging (139), compute-derivatives (105) and six
more compute suites; dropping the read fails 3 cases.
@neuromechanist
neuromechanist merged commit 01038b2 into dev Nov 27, 2026
27 checks passed
@neuromechanist
neuromechanist deleted the feat/serving-index-metadata-ahead branch November 27, 2026 12:32

This branch was previously deployed

1 inactive deployment
npm — 4e51bf6c Deployed Nov 27, 2026 by neuromechanist via publish #5136
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