Repository navigation
feat: re-pull newer upstream snapshots as versions (#1046) - #1983
Merged
Merged
Conversation
Mechanism, version policy, state model and gates for re-pulling a newer OpenNeuro snapshot as a major version. Docs only, not tested.
ADR 0111 and append-only amendments to ADRs 0006, 0060, 0089, 0091 and 0093; AGENTS.md entry. Tested: adr-index test, lint, typecheck. Closes #1907
* Add dataset_versions source_version columns Migration 0100 adds source_version and source_version_basis with a CHECK that keeps never-examined, unknown and known-tag apart. Tested on real SQLite, including the NULL-safe CHECK terms; datasets is untouched (budget test still 84). * Add source snapshot parser and tag helpers shared/source-snapshot.ts: sourceSnapshotOf, isOwnSourceEntry, openNeuroSourceId, compareSourceTags, mirroredTagOf. Reads only the dataset's own SourceDatasets entry; any disagreement is unknown. Unit tested (36 cases); each rule mutated and caught. * Record source snapshot at version insert One INSERT_DATASET_VERSION_SQL for all five dataset_versions insert sites. The manifest-ready callback and admin manifest regeneration read the tagged dataset_description.json (bounded, never throws); the inline sites use the description they hold. An absent file or failed read stays NULL/NULL. Tested through the real worker and admin route plus a source scan; mutations caught. * Add upstream-backfill admin route POST /admin/datasets/upstream-backfill examines never-examined on###### version rows in keyset pages (default 25, max 50), dry run by default. A fetch error writes nothing, a 404 is unknown only past one hour, an all-absent batch is a suspect credential, and the write never overwrites. 23 route tests on real SQLite; mutations caught. Route inventory pin updated. * Add nemar admin upstream-backfill Loops POST /admin/datasets/upstream-backfill over next_cursor (250 ms pause, --max-batches), dry run unless --execute, reads the 502 body so the resume cursor is printed, exits 1 on any error or unfinished pass. Tested through the real CLI against a local server; mutations caught. API export pin updated. * Expose source_version on version rows GET /datasets/:id/versions rows gain source_version and source_version_basis (always present; nulls mean never examined). The route is outside the OpenAPI document by design, so the CLI VersionInfo type is the contract. Tested through the real route; mutation caught. * Record Phase 2 in ADR 0111 and design notes Dated append-only amendment to ADR 0111: the insert-site table (A and B live, C and D dev-only, E unreachable) corrects the callback-already-reads claim; the entry-level Version reading, the meaning of doi, and the insert-versus-backfill rule for an absent file. Design note section 4 updated to match. Docs only; the ADR index test passes. * Renumber source_version migration to 0101 The email epic (#1893) holds 0100_broadcast_queue on its pushed branch; this takes 0101 so the two never share a number. Renames the file and updates the references in code, tests and docs; the migration test, column budget test and route tests pass. * Scope the 0098 column test to 0098 The test compared the schema after ALL migrations with the schema before 0098, so any later column on dataset_versions (0101 adds two) failed it. It now builds the after-schema through 0098 only. Test passes (30). * Make a refused version row raise, not vanish INSERT_DATASET_VERSION_SQL uses ON CONFLICT (dataset_id, version) DO NOTHING instead of INSERT OR IGNORE, so a snapshot pair the CHECK refuses fails the insert (callback 500, job stays dispatched) while a replayed version stays a silent no-op. Tested on real SQLite and through the callback; reverting to OR IGNORE fails both new tests. * Harden the tagged description read Normalize the ref with toVersionTag (no vv1.0.0), cap the body at 1 MiB (over-cap is a read error), strip a byte order mark, warn when an insert-time read is absent, and document the 5 s worst-case latency. Removes the unused readMirroredTag and readSourceVersionRows. New tests: stalled App token mint is cut off at the deadline, the legacy handler (site D) through its route, cap boundary with and without a declared length. Mutations caught: ref, deadline race, cap (stream and exact), BOM, site D bind, absent warning. * Record a 404 as unknown only after a control read An absent description becomes unknown (final) only when a control read of the same repository at main succeeds with the same credential; otherwise the row is not_examined and retried. The suspect-credential guard no longer depends on batch size or on other errors. Only N.N.N versions are candidates. A write result without a change count is an error, and execute= is parsed strictly (400). Tests: lone and mixed batches, shared control read, keyset tie-break inside one dataset, v-prefixed and non-semver rows; 9 mutations caught. * Tell the operator unknown is final and when to rerun nemar admin upstream-backfill says a recorded unknown is final, and a finished pass with rows not examined prints one line to rerun without --after (an unfinished pass prints the resume cursor instead). Tested through the real CLI; three mutations caught. * Correct the Phase 2 comments and ADR amendment Migration comments: TRUE-or-FALSE-never-NULL wording, the full unknown definition, and the cross-column CHECK marked unverified on D1. ADR 0111 amendment: one correction and three readings, names the decision 4 sentence it corrects, control read and N.N.N rules, ON CONFLICT insert; README entry notes decision 4 is built. Design note: dated migration wording. * Reset process-wide GitHub state in the insert tests In the full Bun process an earlier file leaves the GitHub rate-limit bucket drained, which made the legacy-handler description read fail fast and the site D tests see NULL/NULL. The tests now reset the rate-limit state and the installation-token cache before each test; the file passes alone (38) and the full-suite check follows. * Run the legacy-handler tests in a process of their own In a full Bun process an earlier file installs a permanent mock.module of services/github whose getTreeAtRef returns an empty tree, so the legacy version-DOI handler (site D) read NULL/NULL and the tests failed in the full run only. The four assertions now live in source-snapshot-legacy-handler.test.ts and run in a child process via a wrapper test; the stand-in is shared through helpers/source-snapshot-standin.ts. Mutating the site D bind fails the wrapper. * Renumber source_version migration to 0104 origin/dev holds 0100 and 0101 (email epic) and its branches reach 0103. Renames the file and updates the references in code, tests, the ADR 0111 amendment and the design note. Migration, column budget and route tests pass; no duplicate migration prefixes. * Tell transient backfill rows from ones needing an admin errors[] carries kind: transient (a rerun fixes it) or needs_admin (absent at the tag and at main, which a rerun never fixes). The CLI states the two causes separately and marks needs-admin rows; the ADR amendment says the same. Also rewraps the route header comment. Route and CLI tests pass; the cause mutation is caught.
* refactor: move concept-DOI edit to shared/ applyConceptDoiToDescription moves unchanged to shared/standard-edits/description.ts so the re-pull planner (ADR 0111, #1911) can recognize the edit publish makes. services/doi.ts re-exports it; the orchestrator and the #1386 repair keep their imports. Tested: concept-doi-description, repair-doi-metadata and doi-provider suites pass unedited; a new suite proves the two paths are one function and pins the non-array SourceDatasets cases; three one-line mutations of the shared body fail the old-path suite. * refactor: move README edits to shared/ shared/standard-edits/readme.ts now holds buildDoiBadge and planReadmeBadgeCommit (moved unchanged; services/doi.ts re-exports them), decideReadme and readmeProvenanceStub (ensureReadmeMd's #642 rule, which ensureReadmeMd now applies), and selectPublishReadmes (the update_readme step's content-source and deletion rule), for the re-pull planner (ADR 0111, #1911). Tested: readme-badge-plan, import-openneuro and repair-doi-metadata pass unedited; a new suite proves the badge pair is the same functions, pins the stub's bytes, and checks ensureReadmeMd against decideReadme on nine real directory layouts; seven one-line mutations each fail a suite. * refactor: publish README step uses shared rule The orchestrator's update_readme step takes its content source and the files it deletes from selectPublishReadmes instead of an inline copy of the same loop, so the re-pull planner models the rule publish actually follows. Same order, same entries, same deletions. Tested: a source check pins the call and the absence of a README list in the orchestrator (no test drives the step itself, it reads GitHub); mutating the delete loop to readmes.found fails it; the orchestrator source-scan suites still pass. * feat: add shared .bidsignore edit withBidsignoreEntry in shared/standard-edits/bidsignore.ts is the .nemar/ line rule the backend's enrichment commit and the upload's metadata step each carry a copy of, for the re-pull planner (ADR 0111, #1911). Both callers are left unchanged. Tested: a parity suite runs the real writeNemarMetadata for eleven starting files (absent, empty, CRLF, trailing blanks, already present, non-ASCII) and compares bytes; mutating the shared rule or the upload's copy fails it. * refactor: import header patch returns a result importHeaderPatch(before, dates) in shared/identifier-scrub.ts is the importer's scrub-then-dates patch with both proofs, returning ok/not-edf/scrub-unverified instead of throwing, for the re-pull planner (ADR 0111, #1911). patchHeader in import-scrub.ts is now a thin wrapper: not-edf is null and scrub-unverified throws the same ImportScrubRefused as before. Tested: import-scrub, import-normalize, identifier-scrub and identifier-dates pass unedited; a new unit suite pins the result shapes; a new end-to-end case (no existing one reads a non-EDF header) drives prepareImportedTreeForCopy over two non-EDF recordings. Mutations of the shared body and of the wrapper each fail a suite. * refactor: export the scrub's path rules RECORDING, JSON_FILE and SCANS_TABLE in import-scrub.ts become exported RECORDING_PATH, JSON_PATH and SCANS_TABLE_PATH, unchanged, so the re-pull planner (ADR 0111, #1911) forecasts the scrub over the same paths it runs on. Tested: import-scrub passes unedited (50/50); a new unit suite pins what each matches and that none is stateful; three one-line mutations of the patterns fail it, and dropping .bdf also fails the not-EDF end-to-end case. * feat: plain-git location log read at a ref git-lib.ts exports presentIn and adds readLocationLogsAt(repo, ref, keys): the location logs at one resolved commit of a git-annex branch, read with rev-parse and cat-file only, so the re-pull planner (ADR 0111, #1911) can read dead marks and nemar-s3 presence from a bare clone. It applies git-annex's keyFile escaping (& % : /), refuses a ref that does not resolve instead of answering no log, and refuses a ref or key that would break the batch read. Tested against real git-annex (add, copy to a directory remote, drop, dead, registerurl, bare clone): logs match git-annex's own, presence matches whereis, a URL key is found under its escaped name. Six one-line mutations each fail it; annex-registry still passes. * test: not-EDF case fails without git-annex in CI The suite's git-annex probe goes through toolOrFail, so NEMAR_REQUIRE_SCRUB_TOOLS=1 fails it instead of skipping, and the header says it drives the git-held header read, not the upstream ranged read (review round 1, #1925). Tested: passes with git-annex; skips without it; fails with the requirement set and no git-annex on PATH. * test: pin the reachable scrub-unverified header Review round 1 (#1925) found a header the scrub rewrites but cannot prove: a recording field leading with Startdate 99-ZZZ-9999. import-header-patch pins importHeaderPatch's scrub-unverified result for it with dates on and off and corrects the comment that called the branch unreachable (datesUnproven stays documented as unreached: 400,000 fuzzed patches found none). The not-EDF end-to-end file becomes import-scrub-header-outcomes and adds the same header through prepareImportedTreeForCopy: it refuses with scrub-unverified in patchHeader, before any write or commit. Tested: both files pass; flipping patchHeader's not-edf test fails both end-to-end cases, and dropping importHeaderPatch's verifyScrub guard fails the unit and end-to-end cases. * docs: point DOI edit comments at shared/ The orchestrator's update_metadata comment and repair-doi-metadata's header named services/doi.ts as where the rules live; they now name shared/standard-edits/, which doi.ts re-exports, so nobody adds a copy back in doi.ts. The readme.ts header also says doi.ts re-exports applyConceptDoiToDescription (review round 1, #1925). Comments only. Tested: the orchestrator source-scan suites, standard-edits-readme and repair-doi-metadata pass. * test: pin update_readme wiring on the syntax tree The orchestrator wiring check now parses publication-orchestrator.ts with the TypeScript compiler and compares comment-free code: the selectPublishReadmes import, readmes = selectPublishReadmes(tree) over main's tree, getBlobContent of contentSource.sha, contentSourcePath: contentSource?.path, and one deleteRepoFile inside the loop over readmes.remove. Any string literal in the file that spells a README name in any case, other than the README.md it writes, fails (review round 1, #1925). Tested: re-inlining a list (readme.md, Readme.md, README.rst), filtering the tree by an inline list, hard-coding contentSourcePath, deleting readmes.found and reading tree[0] each fail it; the expected text written only in a comment does not satisfy it. * fix: refuse unreadable location logs readLocationLogsAt no longer reads "no log" for a reason other than the branch having none (review round 1, #1925). A ref whose tree has no uuid.log (HEAD, main, any non-git-annex branch) refuses with annex-ref-not-git-annex, and a log the tree names that this clone lacks (a partial or blobless clone), or a log path that is a directory, refuses with annex-log-unreadable. Paths are looked up with ls-tree and read by object id; a key named twice gets the same answer twice. A valid git-annex ref reads exactly as before. Tested against real git-annex plus branches built with git mktree --missing: HEAD, main and a branch without uuid.log refuse, the missing object and the directory refuse, absent logs stay empty, duplicates agree. Removing each guard, or returning one answer per unique path, fails a test; annex-registry and fresh-clone still pass. * test: hold the backend .bidsignore copy to shared The bidsignore parity suite now also runs the backend's own rule: the loop over bidsignoreEntriesToIgnore in commitEnrichmentWithBidsignore is taken from the parsed contents.ts without comments, compiled and run over the same eleven starting files, with one entry and with the admin route's two, and compared with withBidsignoreEntry byte for byte. It also reads the .nemar/ entry the enrichment pipeline and the admin route's v2 branch pass. The backend copy is unchanged; #1918 owns folding it in (review round 1, #1925). Tested: dropping trimEnd, matching by endsWith, never setting the updated flag in contents.ts, and changing either caller's entry each fail it. * docs: note the ensureReadmeMd from quirk The ensureReadmeMd parity block is retitled to say it proves the file I/O (decideReadme's own tests pin the rules), the lowercase bare readme case says from: "README" is the preserved legacy outcome, and ReadmeOutcome's doc says so too, with its consequence: on a case-sensitive filesystem the caller's git add README names an untracked path and the import fails at staging (checked: fatal, exit 128). No code changes (review round 1, #1925). Tested: standard-edits-readme and import-openneuro pass. * Halve the ls-tree batch for argv margin Tested: location-logs-at suite passes.
* feat: define the tag-pin markers in shared/ Three refusal markers for epic #1046 Phase 3 (mirror lag, upstream moved, annex-uuid conflict), defined once in shared/ so the CLI and the Worker import the same literal. The CLI re-exports them from src/lib/import-markers.ts. Typecheck passes; no behavior yet. * feat: classify mirror lag and upstream moved Adds the mirror_lag and upstream_moved causes (labels mirror-lag, upstream-moved) and lets annex_uuid_conflict match the #1320 preflight's marker as well as git-annex's own wording. The summary for annex_uuid_conflict now names both recoveries. Tested with import-failure-cause.test.ts; each new rule mutated and caught. * feat: keep a mirror lag retryable, then park it A refusal for a tag not yet on OpenNeuro's GitHub mirror is quarantined as mirror_lag instead of not_found_dataset, stays a retry candidate, and is parked as mirror_lag once the 14-day window has passed. It sends no quarantine mail and files no issue on failure; the retry engine files its one admin issue when it parks it. The plan's effects move into applyRetryPlan so they run in tests on real SQLite. Tested: import-retry, import-mirror-lag-recovery and the issue and error suites; each rule mutated and caught. * feat: park upstream-moved and annex conflicts The retry engine parks a released mirror whose upstream moved (a re-pull's job, ADR 0111) and an annex-uuid conflict (#1320) at once instead of re-dispatching an import that refuses the same way every time. Both are read through the classifier so the park reason and the issue label agree. Tested in import-retry.test.ts; each rule mutated and caught. * feat: dispatch the auto-import at its tag The auto-import puts the tag discovery found in the onboard dispatch (client_payload.openneuro_tag) and in its audit row; the retry engine sends none, so a retry is prepared at whatever OpenNeuro names then. A malformed tag is left out. shared/openneuro-tag.ts defines the tag shape once. Tested: auto-import unit tests, the retry dispatch through a local GitHub stand-in, and autoImportTick against the real GraphQL in the integration tier; each mutated and caught. * feat: clone an OpenNeuro import at its tag prepare clones the OpenNeuro mirror at the upstream tag it imports (the --tag it is given, else OpenNeuro's latest from GraphQL), never the default HEAD (ADR 0111 decision 10). A tag that cannot be resolved or is not on the mirror yet refuses with [openneuro-mirror-lag] before the dataset record is created. Every refusal ends in refuseImport: it clears stale staging so copy and finalize cannot act on an earlier manifest, then prints the marker as the last failure line. Tested: import-tag-pin (real git-annex upstream with two tags and a HEAD past both; S3 stand-in with the real aws CLI), the reporter fed a real refusal, and against real OpenNeuro in the integration tier; each rule mutated and caught. * feat: add --tag to admin import-openneuro Imports one dataset at a named upstream snapshot tag, passed to prepare (--phase prepare), the --local driver, and the workflow dispatch as openneuro_tag only when given, so a dispatch without it keeps the shape an older workflow accepts. Refused with a batch, with copy or finalize, and for a value that is not a snapshot tag. Tested: the argument rules and dispatch fields, the help text the workflow greps, and the real CLI refusing an absent tag (integration tier); each mutated and caught. * feat: read the upstream tag a description records recordedUpstreamTag reads the SourceDatasets entries naming the dataset's own ds (their Version, then a 10.18112/openneuro DOI, then the URL), never NEMAR's top-level Version, and answers null when they disagree. A stand-in for Phase 2's sourceSnapshotOf until both merge. Tested against the live on003645 and on004362 shapes and every disagreement case; each rule mutated and caught. * feat: guard Step 4c against a moved upstream Step 4c reads the upstream tag origin/main records. Unrecorded or equal: the same-version hard reset, as before. Different: a released dataset refuses with [openneuro-upstream-moved] before any reset, S3 setup or push (a re-pull's job, ADR 0111); an unreleased one is retargeted with git reset --soft origin/main, so the new tag's tree lands as a fast-forward. Release state comes from hasReleasedVersion, asked only on a move; not knowing is a plain failure. decideReimportBase replaces decideReimportMainReset, and git-annex-remote.test.ts now drives baseOnOriginMain instead of a hand copy. The API surface pin gains hasReleasedVersion. Tested with real git-annex repos for every recorded form, and the released-version answers through a local backend (integration tier); each rule mutated and caught. * feat: preflight the bucket annex-uuid (#1320) Before prepare configures nemar-s3 it compares the annex-uuid at the bucket prefix with the nemar-s3 uuids the git-annex branch records (after Step 4b's merge). It proceeds when the bucket has none or exactly one branch uuid matches; otherwise it refuses with [nemar-annex-uuid-conflict], both uuids, and the recovery that fits: remove a marker no branch records, or reconcile and delete nothing. A bucket it cannot ask is warned about and the remote set up as before. The git-annex export pin gains preflightBucketAnnexUuid and the test-only uuidsNamedInRemoteLog. Tested with real git-annex remote.log files and the S3 stand-in through the real aws CLI; each rule mutated and caught. * docs: record the tag pin and its rulings CHANGELOG Unreleased entry for Phase 3 (behavior, production changes, deploy coupling and version skew), and a dated ADR 0111 amendment recording decision 10 as built and the lead's rulings on retarget, the mirror-lag cap and parking annex conflicts. adr-index test passes. * feat: record the mirrored snapshot at import A first import or a retarget appends {DOI, URL, Version} for the pinned tag to SourceDatasets, from the tag alone and kept in git; never after a hard reset, or when an entry already names the ds. applyConceptDoiToDescription (shared/standard-edits/description.ts, which doi.ts re-exports) now compares DOIs normalized and adds no second entry for a dataset an entry already names, so the recorded tag stays known. CHANGELOG and the ADR 0111 amendment describe both. Tested: import-tag-pin (entry shape, round trip through the reader, git blob under an annex-everything policy), the guard reading the entry the import writes, concept-doi-description; mutated and caught. * test: remove the refusal test's scratch dir The capture test that runs refuseImport in a child process left its temp directory behind on every run. It is removed in a finally now. import-capture-workflow.test.ts passes. * refactor: type refusal markers, correct docs ImportRefused.marker is now the ImportRefusalMarker union exported from shared/import-markers.ts. Corrects three comments: the tag pattern's bash pin belongs to the workflow PR, PinnedClone.latestTag is null only for an explicit tag whose lookup failed, and the upstream marker's backend copy predates shared/. Typecheck passes. * fix: read only OpenNeuro URLs as its snapshots recordedUpstreamTag counts a URL only on openneuro.org's dataset pages or the OpenNeuroDatasets GitHub mirror (tree, releases, .git); any other host names no OpenNeuro dataset. The DOI and URL parsers move to shared/openneuro-tag.ts, readRecordedUpstreamTag says why nothing is recorded (none or disagree), entries may be null, and the header lists the three behaviors that differ from Phase 2's parser. Tested in import-upstream-tag.test.ts; each rule mutated and caught. * fix: complete an untagged entry, never skip it appendSourceDatasetEntry skipped whenever any entry named the dataset, so an untagged one (a concept DOI, a dataset page) left the recorded tag unknown and the upstream-moved guard blind. It now skips only when a tag is already recorded, completes an untagged entry that names this dataset alone in place (Version, and DOI or URL if missing), and appends beside an entry naming two datasets. Null entries are kept. Tested in import-tag-pin.test.ts, DOI-only and URL-only shapes included; each rule mutated and caught. * fix: tolerate null sources in the DOI de-dup applyConceptDoiToDescription threw on SourceDatasets: [null] in the predicate Phase 3 rewrote; it now skips anything but an object, and an entry naming the dataset by its OpenNeuro page also stands for it. The comment says upstream's own DatasetDOI is dropped when an entry for the same ds exists at another tag. New tests: an upstream DOI newer than the entry, the live on004362 DOI-only shape, a page-only entry and a null entry, the last also at the shared module directly (shared/standard-edits/description.ts); mutated and caught. * fix: one IsDerivedFrom per imported snapshot bidsToDataCite turned the importer's SourceDatasets entry into two IsDerivedFrom relations, its DOI and its OpenNeuro page. The page is skipped when it names the same OpenNeuro dataset as the entry's DOI; any other URL is kept. Tested in datacite.test.ts; mutated both ways and caught. * fix: an incomplete preflight is unchecked The #1320 preflight could call a conflict (and advise removing the bucket marker) on evidence it did not have. It now answers unchecked when Step 4b's fetch or merge failed (fetchOriginAnnexBranch tells a missing origin branch from a failure), when git cannot read the branch's remote.log, or when origin has a git-annex branch that records no nemar-s3; a missing aws binary is unchecked too. The removal advice appears only for the complete case, conditioned on no clone recording the uuid. annexUuidPreflightAction is the choice prepare acts on. The git-annex export pin gains the two helpers. Tested with real repos and the S3 stand-in; each rule mutated and caught. * fix: fail closed when Step 4c cannot ask origin A failed git fetch origin main read as a first import, so the guard never ran; only git's "couldn't find remote ref main" is a first import now, and any other failure stops prepare before anything is reset or pushed. decideReimportBase reads the recorded tag before it looks at the branch, so a detached HEAD or an adjusted branch cannot skip the guard, and an unreleased import off main is refused rather than retargeted. Tested with real repos; each rule mutated and caught. * fix: say when the upstream-moved guard is inert When origin/main has no readable recorded tag (no description, one git cannot read, one that is not JSON, no tagged entry, or entries that disagree) the guard cannot fire, as ADR 0111 requires. Step 4c now prints a warning naming the reason and returns it as unrecorded, instead of swallowing it in a bare catch. Not a refusal. Tested with real repos for each reason; each mutated and caught. * fix: refuse a retarget that would drop corrections A retarget takes the new tag's tree whole, so origin's .nemar/corrections.jsonl would go with the old one. Step 4c now refuses, before any reset, when that ledger holds any line other than the importer's own import-scrubbed one, or a line it cannot parse, naming the count (ADR 0085). Tested with real repos; each rule mutated and caught. * fix: name the repair command for a moved mirror The upstream-moved refusal ends with the command that repairs the released version at the tag it mirrors, nemar admin import-openneuro <ds> --tag <recorded tag>, which passes the guard; the classifier's summary says so too, and that the retry engine never runs it. The annex-uuid summary says an operator restarts a parked import by hand after fixing the marker. Tested in the guard and classifier tests; mutated and caught. * fix: one short lookup when a tag is explicit With --tag the latest-tag lookup only decides a warning, so it now makes one attempt with at most a 10-second timeout instead of three retried ones. Tested: a failing GraphQL is asked once and the clone goes ahead; mutated and caught. * fix: remove the work dir a refused prepare made A refusal, and a failure of the clone at the tag or of the guard, removes the work directory this run created (read-only annex directories included) and keeps one the caller named with --dir. Those two failures now end in prepareImport like refusals do. The refuseImport and ImportRefused comments now say staging is cleared only when the run persists it, that copy and finalize then fail at once on the missing manifest, and what the cleanup catch is for. Tested in a child process; mutated and caught. * test: drive prepareImport and the retry tick test/import-prepare-pin.test.ts runs prepareImport in a child against local repos (git url insteadOf rewrites of the two GitHub URLs) and a local backend: released and moved refuses with nothing pushed and its work dir removed; unreleased and moved retargets and records the new tag (and warns that it is not OpenNeuro's latest); same tag and unrecorded tag take the hard reset, the latter recording nothing. shouldRecordSourceEntry is the extracted entry decision; ImportOptions gains openNeuroLookup for the GraphQL endpoint. The sweep's tick after its S3 reads is retryCandidateInput plus runRetryTick, run on real SQLite from the stored datetime. The importTag, released and sourceId wiring, the entry condition and the window read were each mutated and caught. * docs: correct the park and override comments decideRetryAction's numbered rules are in the order they apply, and the note on parking upstream_moved and annex_uuid_conflict now says it is a backstop: classifyRecovery has no rule for either marker and a failure usually quarantines the row by dataset state first. classifyRecovery says why the mirror-lag override also bypasses has_doi, made_public and has_version. Tests reset the GraphQL fixture before each test, and in CI a missing aws CLI fails instead of skipping the S3 tests. Suites pass. * docs: bring the ADR and CHANGELOG up to date ADR 0111: annotates the not-yet-built statements and decision 10's "retried, not parked" bullet (decisions 4 and 10 are built; mirror lag parks after 14 days), dates the amendment 2026-10-24, rewords the park of upstream_moved and annex_uuid_conflict as the backstop it is, and records the round's changes and the window's anchoring limit. CHANGELOG: the #993 line names the unrecorded case, staging is cleared only when the run persists it, and the workflow pair lands first; the --tag help says dispatch needs the updated workflow. adr-index and tag-option tests pass. * test: time out git-backed import tests at 60 s Under the full unit-pure run (no --timeout, so bun's 5 s default) the four Step 4c tests in git-annex-remote.test.ts timed out at 5,001 ms; they and the tag-pin tests that clone real repositories now carry an explicit 60 s timeout, as the other git-backed suites do. Both files pass. * fix: keep the ADR 0089 hold through a retarget An import-scrubbed ledger line whose scrub blanked a JSON value or scrubbed a git-held recording means origin's history still holds the originals; a retarget would drop the line, skip earlierHistoryHold and report no hold. Such a line now refuses the retarget like a recorded correction. The comment and the ADR amendment no longer say Step 5b's scrub re-applies the old line. Tested with nonzero counts (and a zero-count line that still retargets); mutated and caught. * fix: read git statuses, not localized messages Step 4c and Step 4b told a missing ref by git's English "couldn't find remote ref", and the guard told a missing file by "does not exist in"; git localizes both ("Konnte Remote-Referenz main nicht finden"), and init.ts already forbids matching them. Missing refs now come from git ls-remote --exit-code (status 2) and missing paths from git ls-tree's listing. Tested under LC_ALL=de_DE.UTF-8 (German messages on this machine): first import, missing description, missing ledger and an absent git-annex branch; each reverted to a message match and caught. * fix: never deepen or overwrite a source entry appendSourceDatasetEntry returns disagree, with a warning, when entries already record different tags for the dataset, instead of adding a third. The in-place completion leaves an untagged entry alone (and appends beside it, with a warning) when it already carries a Version that is not a tag or a DOI or URL that is not text, so it no longer overwrites them. Tested in import-tag-pin.test.ts; mutated and caught. * docs: make the ADR 0111 header truthful The header said nothing in the Decision section was built, with the same annotation under it as under the section; it now says decisions 4 and 10 are built per their amendments, and the one annotation stays under the section. adr-index passes. * test: catch a local-time misread on UTC The 14-day window test now runs in America/Los_Angeles and restores TZ with Reflect.deleteProperty in a finally, so reading the zoneless SQLite datetime as local time fails on a UTC runner too. Mutation-proven: the old test survived the misread under TZ=UTC; the new one catches it. Tested with bun test, TZ=UTC and default zone. * refactor: read the recorded tag with Phase 2's parser The upstream-moved guard and the SourceDatasets record now read the tag with sourceSnapshotOf (shared/source-snapshot.ts); the Phase 3 reader src/lib/import-upstream-tag.ts is gone, and hasSourceEntryFor uses isOwnSourceEntry. Where the two differed the parser wins: a tag is numeric and dotted, an entry naming two datasets gives no tag, and the mirror's .git URL names no dataset. The record is written only when the parser then reads it as the tag ("unreadable" otherwise, with a warning), which replaces the "disagree" outcome and the old append beside a two-dataset entry. sameUpstreamTag stays the guard's equality. Tests moved to the parser, with the three changed cases named; ADR 0111 and CHANGELOG updated. Tested: Phase 3 suites, source-snapshot; five mutations caught. * fix: judge the DOI de-dup by isOwnSourceEntry applyConceptDoiToDescription drops upstream's DatasetDOI when an entry for the same dataset exists; "for the same dataset" is now the shared parser's isOwnSourceEntry, so publication and every reader of the tag agree. The mirror's .git clone URL, which no reader counts as the dataset's, no longer stands in for upstream's DOI. Tested with standard-edits-description (tree URL dropped, .git URL kept beside) and concept-doi-description; the wider match mutated back and caught. * test: give Phase 3 clone tests a git identity git annex init commits, and the CI runners have no git identity, so every Phase 3 test that clones through cloneOpenNeuroAtTag failed there (unit-pure and integration-dev) while passing on a machine with a global one. A new helper, test/helpers/git-identity.ts, sets GIT_AUTHOR_* and GIT_COMMITTER_* in process.env for the file and restores them after; no global git config. The live test also clones into a fresh directory per attempt, so a --retry is not failed by the directory an earlier attempt left. Tested with HOME empty, GIT_CONFIG_SYSTEM=/dev/null and a global config holding only user.useConfigOnly: 36 failures before, none after.
* feat: add the upstream staleness classifier Pure classifyMirror and diffStaleMirrors in shared/upstream-staleness.ts: eleven states, eight anomaly kinds, verdict by upstream creation order (not tag number), plus isSourceTag. Recorded OpenNeuro fixtures included. Tested with the recorded responses. * feat: read OpenNeuro snapshots in batches Batched GraphQL reader for the staleness report: 50 datasets per request, ids only as variables, per-alias deleted/absent, any failure an error read (never a verdict). Exports OPENNEURO_GRAPHQL_URL and adds an override binding. Tested against a stand-in serving the recorded response. * feat: add GET /admin/upstream-status Read-only, keyset-paged report of OpenNeuro mirrors behind upstream: batched snapshot read, GitHub mirror probe with a HEAD control read (rawContentUrl gains an org parameter), pinned in the route inventory. Tested on real SQLite, a recorded-response OpenNeuro stand-in, and Miniflare D1. * docs: record Phase 4a in ADR 0111 Dated amendment: population, state precedence, creation order over tag number, the control-read proof of mirror lag, no cron. Points the design note's staleness predicate at it. Docs only, not tested. * fix: harden the upstream status report Reader: a partial response, a null latest beside a non-empty list and a foreign 'does not exist' are error reads. Classifier: a latest older than a list entry is an anomaly; unknown rows name the OpenNeuro failure. Service: 502 only when rows needing a verdict ended unchecked, excluded unmanaged on rows counted, probe 200 needs a JSON object body, no claimed probes when the token cannot be minted. Route: strict limit, dataset with after is 400, D1 failures labeled apart from defects. Tested with mutations on real SQLite, recorded responses and Miniflare D1. * docs: Phase 4a review fixes in ADR 0111 Amendment now states the status codes, per-page counts, unmanaged rows, the latest-versus-list anomaly, the same-tag re-creation limit, the CDN 404 cache, the HEAD control read, and what the next part will do. The token caveat moves to Not yet verified. Fixes the design note predicate and the raw-read comments. Docs only, not tested. * fix: unreadable latest date is an anomaly, not current An unparsable (not null) latest date skipped the list check and let a recorded==latest row read current beside a later snapshot. The list entry's date is tried next; if neither reads the row is upstream_dates_unreadable. ADR wording for upstream_older and the unknown-row note, probe doc block moved back. Tested with mutations.
* refactor: scope the import scrub to given paths scrubImportedTree takes an optional scope (the paths it may read and change) and an optional sourceOf (a source, held, or none per key, in place of the whereis map), so an upstream re-pull can scrub its delta paths only. A provenance file outside the scope is counted as not annotated. The manifest's closing check is exported as assertCopiedRecordingsRead. The importer passes neither option and its suites pass unedited. Tested: new scope, source and closing-check tests in test/import-scrub.test.ts, each killed by a one-line mutation; the import-scrub suites pass. * feat: read upstream objects at a pinned version UpstreamSource gains a pinned kind (bucket, object, versionId, region), read by httpUpstreamReader at pinnedObjectUrl: the path-style URL with every segment encoded and ?versionId= kept, so an upstream re-pull's scrub reads the version its copy will copy (ADR 0111, decision 8). The size and hash rules apply unchanged. Tested: the URL's encoding, and a scrub against the S3 stand-in with a newer object current at the path, where both the ranged header read and the download name the version; each killed by a one-line mutation. * refactor: extract the finalize tree gate The verify, tree gate and register steps of finalizeImport move, with their messages unchanged, to src/lib/import-finalize-gate.ts as verifyManifestObjects, treeGate and registerTreeKeys, so an upstream re-pull's register step runs the same three. DATA_AVAILABILITY_MARKER moves with the gate and import-openneuro.ts re-exports it. finalizeImport keeps its exits. Tested: test/import-finalize-gate.test.ts on a real git-annex repository with a listing from the S3 stand-in through the real aws, texts pinned word for word; each function killed by a one-line mutation. The finalize suites pass unedited. * feat: plan the generated participants.tsv The enrichment's placeholder participants.tsv moves to shared/standard-edits/participants.ts (the backend module re-exports it), and the re-pull planner treats it as a standard edit: where upstream ships none, NEMAR's file is explained when it is the placeholder of an upstream tree's subjects, it changed upstream when the subjects did, and N.0.0 gets the placeholder of tag B's subjects. A placeholder edited afterwards stays NEMAR's correction. The body's planner is now PLANNER_VERSION, 2. Tested: three fixture plans (tag B adds a subject, the same subjects, an edited placeholder) and the shared-path identity; each changed line killed by a one-line mutation. The planner and participants suites pass. * feat: add the repull-scrubbed ledger action The ledger takes a repull-scrubbed action: an upstream re-pull's delta scrub writes it (ledgerAction) before its one commit, so it holds no history. The planner counts neither scrub action as a recorded correction; the re-import hold still reads import-scrubbed lines only; the ADR 0085 proof tolerates a re-pull's commit as it does the importer's; a retarget still refuses any line but the importer's own. Tested: the scrub writes the word, a repull-scrubbed line holds nothing on a re-import while the importer's does, a plan with one beside unexplained paths is not refused, the fresh-clone proof tolerates the commit, and a retarget refuses it; each killed by a one-line mutation. * fix: point the upstream-moved refusal at repull The [openneuro-upstream-moved] refusal of a released mirror now names the re-pull to the new tag, nemar admin repull plan <id> --to-tag <tag>, quoted so the tag is not read with the full stop, before the repair at the recorded tag, which stays last. Tested: the guard suite, with a new test of the sentence; naming the recorded tag instead is killed. * fix: order to-tag by OpenNeuro creation The re-pull plan's to-tag check no longer compares tags numerically. It reads OpenNeuro's latest and its snapshot list with creation times in one answer (fetchOpenNeuroSnapshots, the staleness report's query and parser, moved to shared/openneuro-snapshots.ts) and orders them through upstreamSnapshotOrder, now the one helper the staleness verdict uses too. Only OpenNeuro's latest created after from_tag is ok; an order the answer cannot establish, or no from_tag, is unchecked, so the plan is not executable. A mirror recorded at legacy 00006 is no longer held behind 1.0.0 by its number. Phase 5's to-tag unit tests move to the creation-order rule. Tested: unit tests of the helper and the check, the fetch's retry and error paths against a loopback stand-in, and plans over the fixture (legacy tag, same creation time); each changed rule killed by a one-line mutation. The Phase 4 suites pass unedited. * test: set the fixture's tag B participants plainly The re-pull fixture adds tag B's participants.tsv by assignment instead of a conditional spread, which typed the edits as possibly undefined. No behavior change. Tested: test/repull-plan.test.ts. * docs: record Phase 6b in ADR 0111 Append-only amendment dated 2026-10-24: the scrub's scope, sources and pinned reads; repull-scrubbed and the corrected ledger rule; the generated participants.tsv as a standard edit (closing the Phase 5 open item); planner 2; to_tag ordered by OpenNeuro's creation order (correcting the Phase 5 reading); the refusal's re-pull pointer; the finalize gate as functions. Docs only. * fix: refuse what a scoped scrub would miss A scoped scrub refuses scope-incomplete when a path changed since HEAD is outside its scope, and provenance-out-of-scope, before any download, when a header will change and a provenance file lies outside it (the lead's ruling: refused, not counted). A provenance file that is not a JSON object is counted as provenance_malformed, apart from one that is not a regular file; the importer warns on both as before. The held-key doc names its real basis. Tested: test/import-scrub.test.ts adds the two refusals, provenance annotated in scope, a malformed one, the read keys of the scope and no-source scrubs, a held key refused by the closing check, and a pinned version gone answering http-404 with no unpinned read; each guard killed by a one-line mutation. * fix: an undated snapshot never orders tags upstreamSnapshotOrder answers list_undated when another snapshot in upstream's list has an unreadable date, since it could be the newest: the plan's to-tag check is then unchecked, and the staleness verdict reads upstream_dates_unreadable instead of stale or upstream_older (a mirror at the stated latest stays current). The check's messages name an unknown from_tag as the mirrored tag (unknown) rather than printing null, and its no-from_tag detail is pinned. Tested: the helper, the check with [1.0.0 2020, 1.1.0 2021 latest, 1.2.0 undated] from 1.0.0, and the classifier; each change killed by a one-line mutation; the Phase 4 suites pass. * fix: keep the scrub words to the scrubs SCRUB_ACTIONS in scripts/scrub/ledger.ts names import-scrubbed and repull-scrubbed once: ledger-cli append refuses both (the importer writes through appendLedger, not the CLI), and the planner reads the set. The proof's exemption, now isScrubLedgerCommit, accepts repull-scrubbed lines beside other files only when the commit carries the Upstream-Snapshot: and Repull-Plan: trailers. The runbook, the design record and the retarget comments say so. Tested: the CLI refuses both words and appends nothing; fresh-clone twins without trailers, with one trailer, with another action and with an edited earlier line each fail, with cleanup in a finally; each rule killed by a one-line mutation. * fix: word the refusal for a newer snapshot The [openneuro-upstream-moved] refusal names nemar admin repull plan <id>, to OpenNeuro's latest snapshot by default, with --to-tag naming the imported tag, which need not be the newer one; the repair at the recorded tag stays last. Tested: the guard suite, with the sentence pinned; naming the recorded tag instead is killed. * test: prove finalize stops at the tree gate finalizeImport runs in a child process over a local origin (GIT_CONFIG_GLOBAL rewrites the GitHub URL, a dummy token, no system config), the S3 stand-in through the real aws, and a closed API port: a tree key with no object exits 1 with the [nemar-data-unavailable] line, registers nothing and pushes no git-annex branch. Tested: replacing the gate's condition in finalizeImport with false fails it. * test: drop the planner version detector The plan test keeps body.planner equal to PLANNER_VERSION and no longer pins the constant's value, which only detected a change. Tested: test/repull-plan.test.ts. * docs: settle the 6b ADR slice's rulings The Phase 6b amendment records the lead's rulings: a scoped scrub refuses an incomplete scope and a provenance file outside it (closing the open item), the malformed count, the re-pull commit's trailers for the proof and the CLI's refusal of the scrub words, an undated snapshot never ordering tags, the no-answer case with and without --to-tag, and the refusal's new wording. digest.ts says execution will refuse an older planner's plan in a later slice. Docs only. * fix: count untracked paths in the scope check The scoped scrub's completeness check reads untracked paths .gitignore does not exclude (git ls-files --others --exclude-standard) beside git diff HEAD, so an untracked path outside the scope also refuses scope-incomplete. The scope docstring says a re-pull's scope must hold every written and deleted delta path and every .gitattributes the annex policy edited (ADR 0060). Tested: an untracked path outside the scope refuses and inside it is read; dropping the untracked listing is killed. * test: date-only changes refuse out of scope The provenance-out-of-scope rule counts a planned header change, a date-only one included, since ADR 0091's sentence goes in the same file. The comment says the refusal comes after the ranged header reads and before any recording is downloaded, and that a date-only download that later fails was refused already, the safe side. Tested: a date-only recording with the provenance pair outside the scope refuses with no download; narrowing the rule to scrubs is killed. * test: refuse the squash merge without trailers The fresh-clone proof is driven with GitHub's squash shape: the pull request's commits as bullets, the re-pull commit's trailers mid-message and an enrichment bullet last. git reads no trailers there, and the proof refuses with ledger-commit-not-alone count=1; the same squash ending with both trailers passes. Tested: reading the whole message instead of git's trailers is killed. * docs: align ADR 0111 with the 6b review The Phase 6b slice says the provenance refusal comes after the ranged header reads and before any recording is downloaded and counts a date-only change, the scope holds untracked, deleted and .gitattributes delta paths, and a squash merge without trailers fails the proof with ledger-commit-not-alone until Phase 6f writes the message. Phase 4a's rule 13 gains an annotation for list_undated, and the classifier's step comments name it. Docs and comments only. * test: keep the gate test's origin annex-initialised Old git-annex initialises an un-inited local origin on clone, moving its git-annex ref and failing the before/after check on CI. Also use a fresh work dir per attempt so retries do not hide the first failure. Tested: finalize gate test 3x, PR tests, typecheck, lint. * test: American spelling in the gate test The finalize gate test's origin comment says initialize and artifact. Comment only. Tested: test/import-finalize-gate.test.ts.
Absorbs dev (mail and support tickets, pr-reviews --redo and --concurrency, fork shims on pull_request_target, the ADR 0020 amendment, and the Phase 3 onboard workflow #1933). Conflicts resolved keeping both sides: ADR 0093 amendments in date order, ADR index and AGENTS.md lines for 0110 to 0112, mail and re-pull admin routes and commands, export-surface pins, and the admin route total recomputed to 189. The 0098 migration test keeps the through-0098 comparison, which excludes every later migration. Tested: typecheck, lint, targeted suites and the full suite (one environmental failure: website account-copy parity against a stale local website checkout).
* refactor: share the plan's catalog read Move the two NEMAR API reads the plan starts from (the dataset row and its version rows) out of the plan command into src/lib/repull/execute/catalog.ts, so execution can re-read them before it re-plans. No behavior change; test/repull-plan-cli.test.ts passes (23 tests). * feat: verify a re-pull plan against live sources Execution reads the reviewed plan file, proves its body hashes to the stated digest, refuses a plan made by another planner, against another API or from other remotes, refuses an anonymous dataset, and plans again from live sources: the live preflight and executable decide, never the file's. A main moved only by .nemar/** other than the privacy ledger rebases; anything else, a moved git-annex branch included, is plan-stale. A recording whose key NEMAR marks dead refuses, since the plan pins no version to scrub it from. The planner gains collect: the bytes of every computed target recorded by blob id, so execution never rebuilds a standard edit; the digest does not move. nemar-s3's remote.log reading is exported for execution's upload. Tested: repull-compare-plans.unit.test.ts (new) and repull-plan.test.ts (a collect test added), 61 pass. * feat: materialize a re-pull delta A working clone of NEMAR's main at depth 2 at the base, git-annex initialized with no special remote enabled and no background gc. Every path the plan writes or deletes is written from where the plan says (upstream's blob, fetched by id when missing; bytes the planner computed; a pinned object read at its version and proved by its key; the merged description) and staged by its exact id, never through git add; .nemar/metadata.json's IsIdenticalTo names the new snapshot. The materialized index is then committed locally, after a check that nothing outside the scrub's scope changed; that commit is never pushed. Tested with the integration suite added in the run commit (repull-execute-prepare.test.ts). * feat: scrub a re-pull delta before any copy The importer's own scrub on the delta paths and the provenance files only: annexed recordings read at the version the plan pinned (a key NEMAR holds is not read again), dates set, a repull-scrubbed ledger line at the record's time under a fixed actor. Upstream's location log is recorded first for each copied recording NEMAR's branch never knew, so a key the scrub re-keys can be retired and marked dead. Git-held data the policy annexes is then annexed and uploaded with the same upload, and the import's closing check runs over the copy keys. Tested with the integration suite added in the run commit (repull-execute-prepare.test.ts). * feat: synthesize the re-pull commit git commit-tree of the prepared index onto the base: one parent, the fixed identity, the record's created_at as both dates, a body of counts and the Upstream-Snapshot and Repull-Plan trailers last. Before it is accepted the tree must be the plan's targets with the scrub's changes only, no replaced key named, every named key held, copied or uploaded here, and the copy manifest a subset of the plan's copy keys; after it, no scrubbed original is reachable. The work branch and the local git-annex branch are saved as a 0600 bundle with the base as prerequisite, and restored only when it delivers the recorded commit. Tested: repull-synthesize.unit.test.ts (new, 12 pass); the rest with the run commit's suite. * feat: prepare a re-pull through prepared executeRepull, the library entry the execute command will call: prove and re-plan the reviewed plan, POST /admin/repulls (or find the open record of the same plan), then prepare and move planned to prepared with the commit, its tree, the copy manifest's digest and counts. A prepared record is left as it is when its working clone holds its commit, restored from the checkpoint otherwise, or prepared again and required to reproduce the recorded tree and commit; a base moved by .nemar/** only is prepared again there. A failure records why on the record. Adds the /admin/repulls API client and pins its exports; makeRepullApp mounts the real /admin/repulls routes; the fixture gains an xx id, an S3 stand-in holding upstream's pinned versions under newer ones, a flagged added EDF, an identifier sidecar and a CRLF sidecar. Tested: repull-execute-prepare.test.ts (new, 30 pass), api-export-surface, repull-plan-cli; full bun test 19745 pass, 2 fail unrelated (website parity against the sibling checkout; a users-search test that passes alone). * docs: record Phase 6c in ADR 0111 Append the Phase 6c slice, dated 2026-10-24: execution on the administrator's machine, the plan proved by its digest and its preflight recomputed, the narrow reading of the .nemar/** rule, the dead-recording refusal, the preparation (exact-id staging, the local materialization commit, the scope with the provenance files, upstream's location log adopted for copied recordings), the synthesized commit and its checks, deterministic re-preparation and the checkpoint, and what only stand-ins answered. Docs only. * fix: check NEMAR-owned paths and modes The synthesis no longer exempts .nemar/** and .github/**: every path there must be NEMAR's side as it was, .nemar/metadata.json what the NEMAR-owned edit wrote, and the privacy ledger the base's text plus exactly one repull-scrubbed line when the scrub changed something (none otherwise; an edited line, a removal or a second line refuses). Modes are checked too: a path kept is kept with its mode, an in-place scrub change keeps the mode, and every annexed entry the re-pull writes is a symlink. The reachability comment now says it holds within the clone's depth. Tested: repull-synthesize.unit.test.ts, 17 pass (6 new), each rule mutated and caught. * feat: refuse unpinned dead recordings in plans A dead key N.0.0 would name at a recording path must be re-keyed by the scrub from upstream's bytes, and the plan pins only the keys it copies, so the plan itself now refuses it (dead-recording-unpinned) and a reviewer sees it; execution's late refusal of the same is removed, as the live plan is then not executable. The fixture gains movedScrubbedEdf (only a recording is dead), and the options the execution suite uses (bomNemarMetadata, symlinkB, nestedGitattributesB). Tested: repull-plan.test.ts -t dead, 3 pass (1 new); the refusal mutated off and caught. * fix: clear a stale error on a restated stage A prepared self-edge sent with no error now clears the stored error, as an edge into another open status does: it records the whole stage again, so the step it repeats succeeded (CLEARING_SELF_EDGES in shared/repull-state.ts). Every other repeat, and an edge into a terminal status, keeps the error, and an error sent on the self-edge still goes through ADR 0051's rule. Execution uses it when a prepared row is shown to hold its facts again. Tested: upstream-repulls-route.test.ts, 108 pass (two 6a tests moved to a pr_open repeat, one new); both directions mutated and caught. * fix: report NEMAR-owned edits a run leaves materializeDelta returns each NEMAR-owned edit it left, by its status, so the run can say and count them rather than leave them silently; .nemar/metadata.json is read as the planner reads it, a byte-order mark set aside and kept. Tested with the execution suite (a BOM-prefixed file and an unparseable one), in the test commit below. * fix: keep retryable scrub refusals ImportScrubRefused keeps whether upstream stopped serving its bytes (upstreamInaccessible, now a readonly field), and execution's ExecuteRefused carries it as retryable through the conversion. The scrub-delta comment states the provenance rule by content and that an in-scope scans table has every dated row set; the remote name is the one S3_REMOTE_NAME constant. Tested with the execution suite (a pinned version upstream dropped), in the test commit below; the pass-through mutated off and caught. * fix: refuse a dataset of unknown anonymity Execution goes on only when the dataset row says anonymous is exactly 0: 1 is anonymous-dataset as before, and an absent or unreadable field is anonymity-unknown, since unknown is never clean. Tested with the execution suite (a catalog row without the field), in the test commit below; the check mutated to === 1 and caught. * fix: lock, isolate and pin a re-pull run Every git and git-annex call of an execution, the planner's included, runs with GIT_CONFIG_GLOBAL=/dev/null and GIT_CONFIG_NOSYSTEM=1, and the work clone is made with annex.addunlocked=false, core.autocrlf=false, core.hooksPath, core.attributesFile and core.excludesFile set to /dev/null and no background gc. The clone refuses a git-annex branch that is not the plan's (plan-stale). One execution per plan holds a pid lock beside its directory (execution-locked; a dead holder's lock is taken over). A prepared row shown to hold its facts again sends the prepared self-edge, which clears a stale error; the clone and checkpoint say in fixed words why they were not used; a failure that cannot be recorded is said; NEMAR-owned edits left are said and counted; the row keeps the scrub's unread and unproven counts (new count keys); the final cleanup never replaces the real refusal, and a refusal in S0 leaves no empty directory. Comments: only a prepared row resumes from disk; S0 writes nothing to the API, pushes or uploads; the execute command is not built yet. Tested with the execution suite, in the test commit below. * test: cover the preparation's new refusals The execution suite now asserts: the commit changes exactly the plan's paths, the NEMAR-owned edit and, after a scrub, the ledger and provenance files; origin refs equal before and after; private modes up to repull/; the scrub's unread counts and the owned-edit counts; a rerun uploads and writes nothing; a stale error cleared; a manifest digest not reproduced; a prepared row rebased onto a moved main; a hostile global git config and XDG attributes giving the identical commit; the plan lock both ways; the git-annex pin; the closing header check's wiring; a pinned version upstream dropped (retryable, recorded, and said when the record cannot be written); a wrong destination prefix; until-not-built; anonymity unknown; a BOM and an unparseable metadata file; a dead recording; the CRLF, 100755, symlink and nested .gitattributes targets. repull-materialize.unit.test.ts pins isWritablePath. Tested: 47 + 2 pass; the repull set, the scrub suite and the export pin 591 pass. * docs: revise the Phase 6c slice in ADR 0111 The Phase 6c slice, still last and dated 2026-10-24, now records: only a prepared row resumes from disk; the plan lock and the config isolation; the refusal order as built; anonymity exactly 0; a moved main with no differing path is plan-stale, and the clone pins the git-annex branch; the dead-recording refusal now in the plan; the pre-scrub commit's unscrubbed blobs kept in the private clone until the pull request opens; scans tables in scope fully dated; the adopted upstream holders the pushing slice must handle; the NEMAR-owned, ledger and mode rules of the synthesis; reachability within the clone's depth; the stale-error clearing and the meaning of delta_paths. Two sentences of the first Phase 6 slice carry dated annotations for the prepared self-edge. Docs only. * fix: take the plan lock atomically The pid file is written in a private sibling directory that is then renamed onto the lock's path, which fails while a lock is there, so no lock is seen without its pid; a lock whose pid cannot be read is taken for a live one. A crashed holder's lock is moved aside and taken over only if what was moved is still that holder's; the release removes only this process's own lock. The refusal names the lock's path and says to remove it when no execution runs (pid reuse after a crash). Tested in the test commit below: an empty pid in a fresh lock is never taken over, a live and a dead holder, the release guard. * fix: restate only a preparation's own error Every error the preparation records now begins [prepare:<code>], and a prepared row shown to hold its facts again sends the clearing self-edge only when its stored error begins so; an error a later step recorded is left as it is. The CLEARING_SELF_EDGES comment says the same. Tested in the test commit below, both directions. * fix: count overlapping git isolation withIsolatedGit keeps a depth: the outermost call saves the user's GIT_CONFIG_GLOBAL and GIT_CONFIG_NOSYSTEM and only the last to finish restores them, so overlapping executions in one process cannot leave the isolated values behind. Tested in the test commit below (repull-workdir.unit.test.ts). * fix: carry the upstream marker, not a field ExecuteRefused.retryable had no reader: dropped, with the readonly the importer's ImportScrubRefused gained for it. A scrub refusal keeps the scrub's message as it is, which begins with the [openneuro-upstream-inaccessible] marker when upstream stopped serving a pinned object; that text is what the Worker matches. Tested in the test commit below (the message begins with the marker). * fix: name a missing dataset row A plan whose dataset has no row is refused as dataset-missing, before the anonymity check, which would otherwise call it anonymity-unknown. Tested in the test commit below. * test: cover the lock, restate and isolation repull-execute-prepare.test.ts: a lock with an empty pid in a fresh directory is refused and left as it was, the refusal naming the lock's path; an error a later step recorded is not cleared by a preparation that holds; a dropped pinned version's refusal begins with the upstream marker; a missing dataset row is dataset-missing. repull-workdir.unit.test.ts (new): overlapping isolations restore only at the last, a throwing call restores, the lock's release removes only its own lock. Tested: the 6c suites and the repull route suites, 377 pass before the two lock unit tests; each fix mutated and caught. * docs: record the lock, restate and marker rules The Phase 6c slice of ADR 0111 now says how the lock is made atomically and what its refusal names, that a missing dataset row is dataset-missing, that a scrub refusal's [openneuro-upstream-inaccessible] marker text is the contract for a failure that may pass later, and that execution clears only an error that begins [prepare:; the dated annotation on the first slice's last_error sentence says the same. Docs only.
* feat: declare the automatic re-pull switches
Add repull-switches.ts: exact-production test, the open and merge switches (exact "1"; merge needs open), and the one cap reader. The merge cap and the create fence now read through it, unchanged in behavior. The three variables stay absent from every wrangler vars block, pinned by a flag test. Tested: unit cross product, flag test, merge-claim suite.
* feat: report the re-pull switches
Add GET /admin/repulls/switches, registered before /repulls/:id, answering what the Worker reads: production, both switches and the open cap. No raw binding value. Pinned in the route inventory (entry and order). Tested: route suite and inventory.
* feat: name the App's bot user
Add NEMAR_APP_BOT_LOGIN and NEMAR_APP_BOT_USER_ID beside NEMAR_APP_ID, measured 2026-10-24. Constants only; later phases read them. Tested: typecheck.
* docs: record Phase 7a in ADR 0111
Append the 7a amendment: the switch and cap rules, the measured ruleset and review facts, and the split of the ruleset check (installation permissions read; organization rulesets need an admin:org token and stay an owner step before the Worker's merge). Documentation only.
* test: pin the cap's two-digit bound
A three-digit binding with leading zeros ('005') must read unreadable; the max check alone did not catch a widened digit rule. Tested: unit suite, mutation killed.
* feat: report the merge cap and tighten tests
Move the merge cap reader into repull-switches.ts and report both caps. Tests: newline and tab cap values, every switch mix in the report, an ENVIRONMENT that is truly unset in the route suite. Mutants killed.
* test: guard all four names in every table
The flag test walks the whole parsed wrangler file for the two switches and both caps, and a new test pins the App's bot login and user id. The redundant read-every-block test is removed; the unit suite covers the readers. Mutants killed.
* docs: correct the re-pull switch comments
Four variables, one sentence for when the owner adds them, the dashboard remark on the pacing macro, switch wording in bindings, and the ADR's administrator attribution and merge cap line. Documentation only.
* feat: add the re-pull dispatch record Migration 0109: upstream_repull_dispatches (one row per dispatch of the automatic re-pull, on datasets only, a nonce held exactly while live, one live dispatch per dataset), the scheduler's one row, and hold_reason/hold_since on upstream_repulls (automatic rows only, set together). The shared words for kinds, states, codes, hold reasons, the planner pin and the copy bound. The dataset cascade deletes the dispatches before the re-pull rows. Tested: every CHECK and index on bun:sqlite and Miniflare D1; the cascade against a loopback GitHub stand-in. * feat: sign re-pull dispatch tokens A callback token kind of its own for the automatic re-pull's run: HMAC-SHA256 with the shared callback secret over a domain line, the dispatch id, its dataset and its one-shot nonce; a field with a line break is refused by the signer and fails the verifier. Re-exported from the services/github barrel; the surface pin gains the three names. Tested: round trip, every field bound, and domain separation in both directions against all eight other token kinds. * feat: accept re-pull run reports The dispatch service: claimOpenDispatch (exact production and the open switch; one unit of REPULL_DAILY_OPEN_CAP counted in the claim's own statement; a first dispatch needs no open re-pull, a resume an automatic row that stalled before pr_open), claimFinishDispatch (exact production only, no cap), markDispatchSendFailed, the check an automatic create makes of its dispatch, and the watchdog that ends a dispatch silent for 8 hours as unreported. POST /webhooks/repull-state stores a run's report: started once, then opened, finished, refused or failed, a compare-and-set on the nonce, one answer for every token refusal, codes from the closed list. No mail; the no-mail scan gains both roots. Tested: real SQLite through the webhooks router, the statements on Miniflare D1, the Resend capture empty, each guard mutated. * feat: bind automatic re-pulls to a dispatch POST /admin/repulls takes dispatch_id and dispatch_token, both or neither; origin is in no request. A create with a live dispatch whose token the Worker signed records origin automatic, after exact production, the open switch and an on dataset; the dispatch must name the dataset, ds and both tags; the plan must be planner 2 with unexplained, conflicts and corrections stated and 0, and a stated copy of at most 1 TiB. The insert links the dispatch by the row's key. An open record is returned only to a caller of its own origin, and a dispatch that names its record takes only that one. Tested: the route with real SQLite, each refusal with nothing written; a scan that every literal refusal word is a dispatch code. * docs: record Phase 7b in ADR 0111 The 7b slice of the Phase 7 amendment: the dispatch record and its states, production only, the open cap counted at the claim, the dispatch token and the report callback with its closed code list, the watchdog, origin automatic only through a Worker-signed dispatch with the planner pin and the zero-unexplained check, and the same-origin reading of "the same plan is the same record". Not tested (prose). * fix: one token answer and guarded dispatch link The automatic create checks the token before it says anything about a dispatch, so an unknown, ended or wrong-token dispatch is one 401. The link is guarded by liveness and rolls the create back. A claim that cannot be handed out is ended, an odd tag and an unreadable cap are their own refusals, the claim audit is built in SQL, and the watchdog throws on an absent count. Comments match the code. Tested with the backend dispatch, route and D1 suites. * test: pin the dispatch record's guards Covers the token oracle, the callback without switches, the unconfigured refusals, the stale-dispatch race, resume tags, closed rows after pr_open, the stranded claim, the link guard, the watchdog bound and count, the cap's kept units, run URLs and the Miniflare D1 cap and live races. * docs: amend ADR 0111 slice 7b after review States the single token answer, token masking, the cap's scope and deletion, the guarded link and the stranded-claim end. * feat: drive the dispatch watchdog from the cron The watchdog is called from the production-only daily block, is declared prod-only in the sweep wiring test, and ADR 0111 records that its wiring lands in 7b. Tested with the cron wiring suites. * fix: end a stranded claim by nonce, log both errors When the claim insert reports no id the dispatch is ended by its nonce, a failed cleanup logs both errors and throws the original, and the ADR says a racing create's loser gets the token 401. Tested with fault injection on the real engine.
* feat: guard a re-pull's pushes and S3 writes Every push and aws s3api call execution makes after prepared is checked against a closed list of forms: origin only, release branches and git-annex by commit id, copies only from upstream's bucket at a version id. Unit-tested. * feat: copy re-pull objects pinned by version copyPinned heads each upstream object at its pinned version, copies it server side with ?versionId= and the version's ETag as condition (multipart above 5 GiB, aborted on failure), and heads the destination. The S3 stand-in gains cross-bucket CopyObject and a hold. Tested with the real aws CLI against the stand-in; five mutations killed. * feat: register and push a re-pull branch registerCopied gates the N.0.0 tree against a fresh bucket listing and pushes one git-annex commit written from facts: nemar-s3 present for every tree key, dead marks for replaced keys, never the working clone's adopted holders or its own uuid. head.ts accepts only enrichment-shaped commits on a moved head; push.ts pushes through the write guard. copied and registered gain error-only self-edges. Unit and route tests pass. * feat: open the re-pull pull request pushRelease checks main (enrichment-shaped moves only) and pushes or reuses release/vN.0.0; openRelease finds the open pull request by its head before opening one with the administrator's token, refuses another open release pull request, and writes a body of counts, the digest and the trailer guidance. The GitHub stand-in now opens pull requests on branches it reads from the bare origin. * feat: add nemar admin repull execute executeRepull now walks prepared to copied, registered and pr_open (advance.ts) and stops there: it never merges. A record past prepared is taken up from the working clone or its checkpoint without planning again; every run refuses an anonymous dataset first. Step failures are recorded with [copy:, [register: or [pr: and exit 3. Tested end to end through the real binary: 17 cases, including resume at each --until, SIGKILL mid-copy, lost and failed pull request answers, foreign and enrichment heads, a moved main and tag, and a missing held key. * feat: add the re-pull S3 canary nemar admin repull canary copies a small and a multipart upstream object into a scratch prefix by version id through the write guard, checks sizes, the single copy's ETag and the source version S3 names, writes and deletes a staging-shaped key, deletes the copies by version and lists the prefix empty. Dry run by default; never locks or bypasses. Tested against the stand-in, including endpoints that ignore the version id or the copy condition and a locked copy. * docs: record Phase 6d in ADR 0111 Appends the Phase 6d slice: the command and its resume past prepared, the pinned copy, the write guard, the registration that publishes no holder NEMAR does not control (deciding the Phase 6c open point), the release branch and pull request with the trailer guidance, the canary, and what only the canary and production runs can check. Annotates the header and three earlier sentences it decides or corrects. * fix: say the copy count is an upper bound * fix: check the version S3 copied from * fix: narrow the canary and clean up after it * fix: tell push and head outcomes apart * fix: remove the clone on a later run at pr_open * docs: update the 6d slice of ADR 0111 * test: cover branch-unreadable on a real clone * test: lock the wrong-copy delete to its own key * fix: list the 6d refusal words in DISPATCH_CODES * test: state the canary suite's unit-pure tier * test: assert whereis preconditions and output * test: give the whereis clone a git identity
* refactor: renumber the dispatch migration to 0111 origin/dev took 0109 and 0110 for the ticket work, so the Phase 7b migration moves to 0111. Nothing is deployed. Renamed backend/src/db/migrations/0109_upstream_repull_automatic.sql. Updated references in backend/test/upstream-repull-dispatches-migration.test.ts, backend/src/services/deletion.ts, backend/src/services/upstream-repull-dispatch.ts and shared/repull-state.ts. Tested: typecheck, lint, the dispatch, re-pull, screens and source-version migration tests, and test/adr-index.unit.test.ts. * docs: annotate the dispatch migration number Notes on the ADR 0111 Phase 7b record that the migration is numbered 0111; the dated text is unchanged. Tested: adr-index test.
* feat: dispatch the re-pull workflow Add buildUpstreamRepullPayload, which checks every field (a release CLI version only, the signed token's shape, a finish names its re-pull) and throws before anything is sent, and triggerUpstreamRepullRun, which answers sent, refused (a 4xx) or unknown (a 5xx, a lost connection or the timeout) and never forwards GitHub's body. Tested: backend/test/upstream-repull-payload.test.ts against a loopback GitHub stand-in. * refactor: share OpenNeuro's endpoint via a leaf Move OPENNEURO_GRAPHQL_URL to services/openneuro-endpoint.ts, which imports nothing, so the staleness report's snapshot reader no longer loads discovery (discovery re-exports the constant unchanged). Pin the separation both ways with an import-closure scan that fires on a planted import. Tested: repull-discovery-separation, upstream-status-route and auto-import suites. * feat: select and dispatch re-pull candidates Add runRepullSchedulerCron: in exact production with the open switch on, it walks up to three pages of the staleness report from a stored cursor, takes stale_ready mirrors only, skips anonymous, unreconciled, open, live, content-refused and recently pulled ones, re-reads the dataset fences, and claims each dispatch through the dispatch record's capped claim. It waits for a completed administrator re-pull, refuses a non-release build, stops before a stale row the probes did not reach, and is blind (sends nothing, keeps the cursor) when OpenNeuro or the probe credential fails. The scheduler's outcome words are shared and shape-checked. Tested: upstream-repull-scheduler (SQLite, loopback OpenNeuro, raw mirror and GitHub stand-ins), its Miniflare D1 twin, and the no-mail and discovery-separation scans. * feat: schedule automatic re-pulls in production Call runRepullSchedulerCron from the production-only daily block, with one log line per tick (error level when it could not see or could not send). DEV_CRON_ALLOWLIST is unchanged. The wiring test declares the scheduler prod-only and now also pins every prod-only job out of the allowlist; the dev-safety test shows the scheduler and the dispatch watchdog return null with D1 untouched for any ENVIRONMENT but exactly production. Tested: cron-sweep-wiring and cron-dev-safety suites. * feat: count unchecked mirrors in the re-pull tick A mirror the staleness report could not compare is passed by, so one that always fails cannot hold the cursor; the tick now counts those and logs at error level when it passed any, so partial blindness is seen. Tested: upstream-repull-scheduler suite (a per-dataset OpenNeuro read that is no verdict). * docs: record Phase 7c in ADR 0111 Append the 7c slice: candidates from stale_ready only and the exclusions, the 30-day reading, the open cap claimed at dispatch (a 4xx frees the unit, a 5xx or a lost answer keeps it), production only with DEV_CRON_ALLOWLIST unchanged, gate G4 and the release-build rule in code, the rotation and the probe-budget stop, what the dispatch carries, discovery untouched, and what only production can show. Tested: adr-index suite. * fix: log an unanswered dispatch by class only triggerUpstreamRepullRun now logs a send that got no answer by its error's class (errorClassName: a plain identifier, else Error), never its message, so a failure on this side can be told from a timeout without echoing a URL, a path or the token. Tested: upstream-repull-payload suite (a TypeError whose message holds the token, and a timeout). * fix: require both G4 re-pulls before scheduling The scheduler opened after any one administrator re-pull of any on mirror. It now waits until both re-pulls the design record's gate G4 names (on003645 and on004362, REPULL_G4_DATASETS) were run by an administrator to complete with their tags; one of them alone, two runs of one, an automatic or unfinished run, or another mirror's do not count. Tested: upstream-repull-scheduler and its D1 suite. * fix: hold the re-pull tick only on real trouble - blind only when OpenNeuro fails a batch; a page whose rows are all unchecked is passed by, so one mirror cannot wedge the rotation - every probe unverified is blind and holds the cursor, two ticks at most per place in 30 days (a mirror whose OpenNeuro repository is gone) - a 401, 403, 404, 429 or second 4xx in one tick stops before the mirror and stores the new outcome send-refused - a candidate whose reads throw holds the tick twice (audit rows), then is passed by as candidate-error - the result and log line carry probe, candidate and refusal counts and fixed error words, never a message; the dispatch uses the probes' credential directly Tested: scheduler suite (67) and its D1 suite, including the claim's own stop words at tick level, the probe budget across pages and a measured 79-call tick. * fix: skip a mirror whose dispatches go unreported A workflow that answers 204 and never runs leaves each dispatch unreported, so the scheduler would send the same mirror again on every rotation. A dataset whose last three dispatches all ended unreported is now skipped as unreported-streak. Tested: scheduler suite (the streak, two in a row, a streak broken by a later report) and its D1 suite. * docs: list the callers that end a dispatch unsent markDispatchSendFailed's doc said only a refusal ends a dispatch this way; issued() and the scheduler's payload-build guard call it too. The doc now names all three and says a lost answer never ends here. Tested: comment only (typecheck). * docs: state gate G4 by its content in the code The proof's doc and REPULL_G4_DATASETS now say what the design record's G4 is (two re-pulls by hand, the DOI with IsDerivedFrom, the previous version serving) and which half the database shows. Tested: comment only (typecheck). * docs: record Phase 7c as a slice of Phase 7 Move the 7c record under the Phase 7 amendment as its own slice, beside 7a and 7b, and annotate the header. It now records gate G4 as both named re-pulls, defines a refused dispatch as a 4xx (the 7b slice only said a refused dispatch frees its unit), and adds send-refused, the three blind cases, the bounded holds, the unreported streak, the measured tick cost and the accepted CLI-version window between deploy and npm publish. Tested: adr-index suite. * fix: hold the cursor before writing a probe hold The probe hold read its count and wrote its audit row after the scan had moved the cursor, so a failed write stamped the moved cursor and passed the unverified mirrors by. The cursor is now held first and restored only when the hold passes on. A mirror skipped for unreported-streak raises the tick's log line to warn, and the streak's doc says nothing clears it. Tested: scheduler suite (the audit insert failing holds the cursor; the warn level) and the D1 suite (a probe hold counted at its cursor only). * docs: say nothing clears an unreported streak The 7c slice now says the streak is never cleared, the mirror stays on the administrator's path (re-pulled by hand with repull plan and execute), and the skip raises the tick's log line to warn. Tested: adr-index suite.
…1955) * feat: define a machine-clean re-pull Add shared/repull-machine-clean.ts, the pure machine-clean rule of ADR 0111 decision 7 in a fixed order, first failing rule as a hold word, unknown never clean. Name the App and its bot user once in shared/nemar-app.ts (re-exported by branch-protection.ts) so the pure rule can read them. Add the hold words pr-draft, screen-exempt and dataset-not-mirror. Tested: test/repull-machine-clean.unit.test.ts (every word by one flip, every pair ordered, unknown values hold), nemar-app-bot and repull-dispatch-words unit tests; typecheck clean. * feat: read the facts a re-pull merge needs Add upstream-repull-facts.ts: the pull request, main, the App-pinned BIDS and version-check runs (by name, app_id, latest, filtered again on the answer), the screen of the head (an acknowledgment never passes), the review read as the stricter of its two verdicts, and the dataset fences; gatherMachineCleanFacts reads them per stage and asks GitHub nothing when the switches, the record or the dataset already decide. Any non-200, timeout or odd shape is unreadable. Tested: backend/test/upstream-repull-facts.test.ts against the GitHub stand-in (each fact flipped at its source, 404/500/timeout, re-runs, other Apps), no-mail scan, the existing repull suites. * feat: review the automatic re-pull pull request The review intake skipped every bot, so no review could exist for the App's re-pull pull request and none could be machine clean. Add startRepullPullRequestReview: exact production and the open switch, an automatic on record at pr_open, GitHub's record of the pull request by the App (login, id, type) at the recorded head; the intake then admits it only from the recorded release branch in the dataset's own repository. Webhook deliveries and an administrator's start of the App's pull request still answer bot_author. Tested: backend/test/pr-review-repull-admission.test.ts (start, refusals, webhook and admin start unchanged, never exempt, a block holds, no mail), the existing pr-review suites, no-mail scan. * docs: record Phase 7e in ADR 0111 Append the dated 7e slice: machine clean as built (order, fact sources, App-pinned checks with the 2026-10-25 measurement, the strict screen and review readings), the correction of 'The App is not exempt, so the review runs', and the narrowing of ADR 0092's 'not bots' for the App's automatic re-pull pull request only, with its consequences. Annotate the corrected sentence and add the narrowing line to ADR 0092's header. Tested: adr-index and docs-links unit tests. * test: order the facts test's imports Biome's organizeImports wanted the upstream-repull-github import after the upstream-repull-facts one; CI lint failed on it. Tested: bunx biome check on the file is clean. * fix: hold a re-pull on any unsettled import Machine clean read an import as in flight only while it was preparing, copying or finalizing, so incomplete (being repaired by the retry engine) or an undeclared status read as settled. Hold on every status but complete, failed, quarantined and rolled_back; the record's own create fence is unchanged. Tested: upstream-repull-facts (incomplete, an unknown status, each settled status, and a pin against IMPORT_STATUSES), no-mail scan, the repull route suite. * test: hold on records the facts cannot read A dropped screen or review table, a dataset read that throws, and a screen or review row in a state outside the vocabulary (written with CHECKs ignored) each hold: screen-unreadable, review-unreadable, and anonymity unknown with GitHub not asked. Tested: upstream-repull-facts; each catch and the unknown-state arms mutated to a clean answer fail a test. * refactor: drop the screen fact nothing reads readScreenFact never answers rerun: a head with no screen is absent, which holds as screen-rerun. Remove the member so the table maps only facts a reader can produce. Tested: repull-machine-clean unit test, typecheck. * fix: ask ownership first in the re-pull review The start's ownership check came after the on-dataset check, which already implied it, so it could never fail. Ask it right after the switches, document every gate and its answer, say nothing calls the start yet, and say a failed audit row is logged by design. Tested: pr-review-repull-admission (login with the wrong type, the App's id under another login, nm and xx records, a dev-owned id), each guard mutated in turn fails a test. * test: pin how the intake tells a bot A Bot-typed author without the [bot] suffix and a [bot] login typed as a user are each a bot's pull request, and a person's malformed login is refused. Tested: pr-review-repull-admission; the type check, the suffix check and the login-shape check each mutated away fail a test. * fix: name the App in the review queue detail The detail view showed the App's pull request author as (unknown) from GitHub and as nemar-publish-bot?bot? from the stored review, because both readers reduce a login to a person's shape. Show the App's bot name, brackets included, when GitHub's login and id both match, and for the stored row and the standing; every other login is reduced as before. Tested: pr-review-repull-admission (the detail names the App; a bot borrowing the login with another id stays unknown), the queue suite and the admin pr-reviews CLI suite. * docs: correct the machine-clean comments Say a pass is never carried between stages and that --redo cannot touch the App's class; cite decisions 6 and 7 for the zero counts; say the hold words follow the rules' order rather than being defined there; and record that the App posts version-check on central-flow repositories while the rulesets leave it unpinned. Tested: typecheck and biome; comments only. * docs: match the Phase 7e slice to the code Drop the --redo rationale for this class, state the settled-import rule beside the unchanged create fence, list the start's gates with their answers and say nothing calls it yet, say a failed audit row is logged by design, make the review-not-pass hold after a review that ended without a verdict explicit, and record the queue label. Tested: adr-index and docs-links unit tests. * docs: say which start restarts the App's review The Worker's own start restarts a review whose dispatch failed on the same head; an errored, declined or unreported review holds until a new head, and --redo cannot touch it. Word both sentences of the 7e slice that way. Tested: adr-index and docs-links unit tests; biome clean on every touched file.
* feat: Worker routes for resume, merge and lock
The verified merge route records a pull request found merged while
the row is pr_open (outside the tools, at an unscreened head); merged
repeats to record why the release is not recorded yet; every step past
prepared that keeps a record open re-reads the dataset fences; a
released N.0.0 must record its locked objects before complete or N.0.1
(lock-unrecorded), and the released self-edge carries the count or the
lock's error; a stuck claim expires (outcome expired) once 30 minutes
old and GitHub says it did not merge.
Tested: backend/test/upstream-repull* and the state unit test pass;
seven mutants of the new guards each fail a test.
* feat: add nemar admin repull status and resume
resume takes an open re-pull past its pull request: a merge found on
GitHub is recorded through the verified route, a closed one ends the
record abandoned, a head moved by enrichment is recorded and any other
is head-foreign, main must be the base or moved by enrichment only
(re-synthesized onto it with a lease when GitHub says dirty or behind),
the identifier screen is dispatched and acknowledged when asked, and
gates_clear is recorded once it passes and GitHub says clean. A held
claim is resolved from GitHub and expires once old enough. status shows
the record, its screens and the next command. Never merges.
Tested: test/repull-gates-cli.test.ts (14 pass) against a re-pull
executed to pr_open by the real execute; pr-review-approve tests pass.
* feat: merge a re-pull pull request through one gate
nemar admin repull merge <id> merges a gates_clear re-pull only after
reading, before anything is written: the open pull request at the
screened head, main moved by enrichment only, the automated review of
that head (failed, running or unread needs --force), the identifier
screen, GitHub clean, and a squash message whose last paragraph is the
commit's two trailers as git reads them. Then it confirms (one DOI),
claims a unit of the daily cap, squash-merges at the screened sha, and
records the merge; a held claim is reused, a lost answer keeps it. The
pull request body and the execute help now name resume and merge.
Tested: test/repull-merge-cli.test.ts (10 pass), the trailers unit
test, the command-text test and the execute CLI suite.
* feat: route pr-reviews merges of re-pulls
approve --merge and y in next ask, for a release/* pull request,
whether a re-pull record names it; a re-pull's pull request runs the
re-pull gate's checks before the approval is written (a refusal writes
nothing), is squash-merged by the gate after it (claim, sha, trailers,
record), and an explicit --method other than squash is refused. A NEMAR
API that cannot say refuses the merge; an ordinary release pull request
is merged as before.
Tested: test/admin-pr-reviews-repull.test.ts (6 pass) and the existing
admin-pr-reviews CLI suite.
* feat: record the re-pull release
From merged, resume waits (bounded) for the v<N.0.0> tag on origin and
the version row, verifies the tagged tree against the synthesized one
outside .nemar/ and .github/, and records the release through the
Worker's verified route (lineage only when verified; the sweep stamps
are re-armed there). Then it locks the dataset's objects through the
existing s3-lock route, records the count only when every object was
locked (else the error, and the row stays released for the next run),
and completes a record with no corrections. The object lock batch
honors the test-only S3 endpoint override; the S3 stand-in answers
PutObjectRetention.
Tested: test/repull-release-cli.test.ts (5 pass) through the real
s3-lock route against the S3 stand-in.
* docs: record Phase 6f in ADR 0111
Append the Phase 6f slice: resume past the pull request, the
re-synthesis onto a moved main, the merge gate shared by repull merge
and pr-reviews, a stuck claim's expiry, the fences on every step past
prepared, the release and the lock, and what only stand-ins answered;
annotate the earlier sentences it builds. AGENTS.md's ADR 0093 line
names the re-pull's one gate, as decision 7 asks.
Tested: the ADR index and docs link tests pass.
* fix: keep merge and resume scratch apart
The scratch repository that reads origin is now per purpose and per
process (repull/<id>/{resume,merge}/<digest8>-<pid>), so a merge from
pr-reviews and a resume of one record never remove each other's; and a
pull request that moves while resume reads its state waits a turn
instead of reading again at once.
Tested: the four Phase 6f CLI suites pass (126 with the unit tests).
* test: route the re-pull suites, pin the new API
The four CLI suites name TEST_API_URL in their headers, so the
workflow routes them to the integration tier their headers claim; the
trailers test claims unit-pure; the API export surface pins the six
new /admin/repulls client functions.
Tested: ci-tier-routing and api-export-surface pass.
* docs: name the re-pull scratch paths in ADR 0111
The Phase 6f slice now names the per-purpose, per-process scratch repository resume and the merge gate read origin through. Not tested (text only).
* Confirm repull locks by read-back and count
The s3-lock route reads retention back before it counts a 403 as locked, and locks an explicit list of annex keys at their current versions. The Worker refuses a released count below the record's copied, skipped and local uploads. Shared dispatch codes and lock docs updated. Tested: backend upstream-repull suites.
* Check a held merge claim before it is reused
POST /admin/repulls/:id/merge-claim/check re-reads what the claim's statement read (dataset fences, the screen for this administrator, the live head) and refuses a claim 25 minutes old or more. It writes nothing. Route inventory pinned. Tested: backend upstream-repull suites.
* Merge a repull under a checked claim and lock
The merge gate holds the record's plan lock from claim to record, checks a held claim with the Worker before sending under it, treats a lost claim answer as a claim that may be held, keeps its claim when GitHub did not merge, and refuses a head branch GitHub does not name. An unrecorded merge exits 3. Help and token wording match the code. Tested: repull-merge-cli and admin-pr-reviews-repull suites.
* Lock only N.0.0's objects; read trailers back
The release reads the staging manifest the copy wrote (digest checked against the record), locks those keys by name through the s3-lock route, and records the count only when every key is confirmed. Before the tag it reads the squash commit on main and refuses one whose last paragraph lacks both trailers (merge-trailers). Export pins updated. Tested: repull-release-cli and api-export-surface suites.
* Keep enrichment when re-synthesizing a repull
The re-synthesized commit applies what enrichment did on main (the .bidsignore line on the recorded file, a participants placeholder when N.0.0 has none) instead of undoing it. A re-synthesis pushed and not recorded is recognized from the head and recorded by the next resume. Tested: repull-resynthesize and repull-gates-cli suites.
* docs: align repull help, AGENTS and ADR 0111
Resume help and headers name what it does and does not do; the trailers docblock and AGENTS.md's ADR 0093 summary name the merge paths. ADR 0111 gains dated annotations where Phase 6f built, changed or did not build what earlier text promised, and its Phase 6f slice is rewritten to match the code. Tested: adr-index and repull-command-text suites.
* test: plain string in the resynthesize suite
Biome's noUnusedTemplateLiteral. Tested: repull-resynthesize suite.
* Say when a pr-reviews repull merge is unrecorded
approve --merge exits 3 and next stops, counting it unknown, when GitHub merged a re-pull pull request and the record write failed; both name nemar admin repull resume. Neither prints a green Merged. Tested: admin-pr-reviews-repull suite, both checks mutated and killed.
* feat: hold automatic re-pulls by reason Add the advance tick (runRepullAdvanceCron) on the 30-minute production tick. It reads automatic pr_open rows only, five a tick in rotation, and records the first machine-clean rule that does not hold as the row's hold: written once per change of word with one repull_hold audit row, never over a row whose revision moved, and without touching revision or updated_at. Null outside exact production; with the open switch off GitHub is asked nothing and the row says switch-off; a row a live dispatch works on is left alone. An edge into another status now clears the hold. Tested: upstream-repull-advance.test.ts, cron wiring, cron dev safety and the no-mail scan; each guard mutated and killed. * feat: clear the gates of an automatic re-pull The advance tick now takes a clean pr_open row to gates_clear, with gates_sha the head, as the system user, through prepareTransition on the row as read (the screen, fences and live head are re-checked). Every other verdict holds. Once every rule before the screen holds it starts the head's identifier screen (at most three dispatches a head) and the App's review (absent, or a failed dispatch an hour old, and only while the screen may still clear). The GitHub stand-in answers the review's check and comment writes. Tested: upstream-repull-advance.test.ts (gates, unknown facts, bounds) plus the facts, screen, route and admission suites; each new guard mutated and killed. * feat: resume a stalled automatic re-pull The advance tick now also reads automatic rows stalled before their pull request opened (planned to registered). With no live dispatch and the last one failed, unreported or refused by GitHub, a row that passes the machine-clean record and dataset rules, has fewer than three open dispatches, has not moved for an hour and is examined between 03:00 and 15:59 UTC is resumed through claimOpenDispatch (the open cap, in the statement that claims) and the scheduler's send. Otherwise it holds resume-exhausted, resume-refused (a new word) or cap-exhausted, or waits. A 4xx frees the unit and stops the tick's sends; a lost answer keeps it. The tick's cost is pinned. Tested: upstream-repull-advance.test.ts, the dispatch words, the dispatch and scheduler suites; each guard mutated and killed. * docs: record Phase 7f in ADR 0111 Append the Phase 7f slice: the advance tick (production only, the switch, automatic rows only, five a tick in rotation and why), holds as observations, the gates edge on a clean verdict only, when the screen and the review are started, the resume of a stalled run and its bounds, the measured cost, and what only production shows. Three annotations mark what is now built; no earlier line is changed. Tested: adr-index.unit.test.ts. * fix: read every stalled row inside the window One rotation turned by the half hour of the day came back to the same rows at the same hours: of 240 open automatic rows only 130 were ever read between 03:00 and 15:59 UTC, so the rest could never be resumed, and a stalled row also waited behind pr_open rows. The tick now keeps two rotations: pr_open rows turn every half hour, and stalled rows are read only inside the resume window and turn once per half hour of it, five of each kind a tick. Tested: a 60-day simulation over 239, 240, 241, 480 and mixed sets reads every stalled row inside the window; turning stalled rows by the half hour of the day, or one rotation for both, fails it. * fix: start the review only behind a clear screen The review was dispatched on the same tick as the screen, while the screen could still block or ask for a person, and a screen in error did not stop it. It now starts only once the head's screen is clear, so on a later tick. A start the review itself declines is counted by its reason (pr_review_disabled, github_unreadable, ...) in the result and the log line, every tick it declines. Tested: upstream-repull-advance.test.ts (the gate sequence, a screen in error, the review switched off; the cost figures re-measured); each change mutated and killed. * fix: spend a resume only on a dispatch's own fault A 401, 403 or 429 on a resume's send spent one of the row's three dispatches although nothing about the row was tried. Only a refusal of the dispatch itself (404, 422) now counts, as dispatch-refused; any other 4xx ends the claim as dispatch-deferred (a new dispatch word), frees its unit, stops the tick's sends and spends nothing. The bound is renamed AUTOMATIC_OPEN_DISPATCHES_MAX: it counts the creating dispatch, so a row is resumed twice at most. The send is its own function, so a payload that cannot be built is tested. Tested: upstream-repull-advance.test.ts (each refusal status, runs that never reported, the latest dispatch deciding, the unbuilt payload) and the dispatch words; each rule mutated and killed. * fix: claim a resume on either spelling of a tag The open claim compared the row's stored tags with the bare tags it binds, so a row that records v1.0.0 would be refused as row on every tick, and the tick waited on it in silence. The claim now matches the stored tags in either spelling, as the lineage write does, and a row refusal is the error word repull-mismatch, logged at error level. Tested: upstream-repull-advance.test.ts (v-prefixed tags, a row that changes before the claim) with the dispatch, scheduler and route suites; both changes mutated and killed. * fix: time a resume from the row's last dispatch The quiet hour before a resume read only the row's updated_at, which a run that fails before it writes anything never moves, so a row could be resumed on consecutive ticks. It now counts from the later of the row's updated_at and its latest dispatch's report (or send). Tested: upstream-repull-advance.test.ts (consecutive ticks, a report exactly 59 and 60 minutes old); each change mutated and killed. * fix: hold an unreadable open cap as such An open cap set to something its reader cannot take was recorded on the row as cap-exhausted, a full day, though it is a fault in the configuration. It is now the hold word cap-unreadable (added to the hold words), on that row and on every later row of the tick, beside the error word of the same name. Tested: upstream-repull-advance.test.ts (caps 0, x and 21 over two stalled rows) and the hold-word tests; both changes mutated and killed. * fix: name a failed row and stamp only a run A row whose step threw left only its error's class: the tick now logs the re-pull's id (never its dataset) with the class, and takes up the next row. last_advance_at was stamped even when the tick could not list its rows; it is now stamped only for a tick that ran. The waiting count, which mixed two things, is split into running (a run is out for the row) and not_due (a resume not due this tick). Tested: upstream-repull-advance.test.ts (one row's throw, a tick that cannot list, the counters); each change mutated and killed. * fix: hold a clean row whose gates edge is refused When machine clean found a row clean and the record's transition refused its gates_clear edge, the refusal was only counted at info level and the row kept its old hold, so it retried every tick in silence. It is now held gates-refused (a new hold word) and the log line is an error, with the refusal's code, every tick it happens. Tested: upstream-repull-advance.test.ts (a refusal over two ticks); both changes mutated and killed. * test: pin the advance tick's bounds and edges Pin the bounds by their numbers (3 screens a head, 60 minutes before a failed review dispatch is asked again, 3 open dispatches a row, 60 quiet minutes, 03:00 to 15:59 UTC, 5 rows of each kind), the window's edges by literal times, a hold that leaves an old updated_at as it was, a screen that never reported being run again, the screen bound being per head, a row that moved on between the list and its read, and the resume's no-github-token, dispatch-unconfigured and to-tag-malformed words. Tested: each pinned line mutated (the numbers, the window edges, the re-check, the head filter, the words) and every mutant killed. * docs: make the advance tick's comments match it The cron comment now says the tick dispatches screens, starts reviews, writes gates_clear and resumes, not only that it records holds. The failure words say what each one is (dispatch-failed is a screen's failed dispatch or a resume's unbuilt payload; a refused send is dispatch-refused or dispatch-deferred). Clearing a hold is said to be a write. The cost adds the App token mint on a cold isolate. The review start's audit note names who has no user, and the test header states the stand-in reason instead of citing one. Tested: typecheck, biome; the advance, cron wiring, cron dev-safety and review admission suites. * docs: correct the Phase 7f slice of ADR 0111 The slice now records the two rotations and the reason (the first design's rotations left rows unread), the review starting only behind a clear screen and its refusals said, the gates-refused, cap-unreadable and resume-refused holds, what spends a resume (dispatch-deferred does not), the quiet time from the last dispatch, either spelling of a tag at the claim, the stamp only for a tick that ran, the limit of the bound when a creating dispatch is unlinked, and the re-measured cost with the token mint. It no longer cites a source outside the repository. Two more earlier sentences are annotated, the 7b slice's on the hold columns and the 7c slice's on the resume bound, and the slice says which five lines are annotated. Tested: adr-index.unit.test.ts. * fix: say when a resume's time does not parse A row or dispatch time that does not parse made the row not due on every tick with nothing said. It is now the error word time-unreadable, logged at error level, and the row is not resumed. Tested: upstream-repull-advance.test.ts; reading it as a wait, or leaving the word out, fails the new test. * test: time a refused resume send from its send A 422 send leaves its dispatch_failed row with no report; the test pins that the next tick, 30 minutes later, sends nothing, timing it from the send (COALESCE(reported_at, dispatched_at)). Tested: replacing the COALESCE with reported_at fails it. * docs: record the 404 trade-off in ADR 0111 The Phase 7f slice now says that GitHub's 404 for a token that cannot see a private repository spends a resume, two at most a row, and why that is accepted, and that an unparsable time is time-unreadable. Tested: adr-index.unit.test.ts.
…ow (#1963) * feat: run a re-pull unattended from a dispatch plan, execute and resume take --automatic-dispatch <id>: the dispatch is read from the event file (exactly the Worker's nine keys), the CLI must be the release it names, GH_TOKEN is the App token, a token on the command line is refused, and only fixed repull-auto lines are printed. plan reports started and refuses a plan the automatic path does not take; execute checks the live plan, presents the dispatch at the create, never takes up an administrator's record, and reports opened; resume finishes only a merged automatic re-pull. New run words are on the closed list. Tested: repull-automatic unit and CLI suites (real binary, real routes and callback, GitHub and S3 stand-ins), dispatch-words scan, typecheck, lint. * feat: settle the release head before reporting At pr_open a dispatched execute reads the release branch with git, holding the run's lock, until enrichment has not moved it for five minutes or --settle-minutes passes (default 30). Each move is judged by the head rule execute and resume share and recorded as the pr_open self-edge; any other commit is head-foreign, recorded on the row as [auto:head-foreign], and the run reports failed. A read that cannot be made is counted and retried, never taken as a move. Tested: repull-automatic CLI suite (enrichment move recorded, README commit refused, quiet period and bound timed against a real origin), typecheck, lint. * feat: add the run-upstream-repull workflow The authoring copy of the central workflow the Worker's dispatch starts, for nemarDatasets/.github; deployed only with the epic release. Masks the dispatch token from the event file first, checks the nine keys, gates on disk, mints an App token for the one dataset repository, installs exactly the release named (no dev build), signs in with the key in env, exchanges the import's AWS pair for a session, runs plan and execute (open) or resume (finish) unattended, and reports a run that did not report. No run line interpolates an expression; nothing is uploaded. Tested: actionlint with shellcheck; pinned by the next commit's test. * test: pin the re-pull workflow Parses the authoring copy and pins its triggers, scopes, concurrency, bound and timing, the token's mask and absence from every env, the nine keys against the Worker's builder, every option against the CLI, the App token's scope, and the callback word list. Runs the guard scripts under bash: validation, mask, the release-only install (bun and nemar stand-ins) and the backstop (curl stand-in). Parity with the deployed copy via NEMAR_REPULL_WORKFLOW_LIVE, skipping visibly. Tested: 31 pass, 3 parity skips; each guard mutated and caught. * docs: record Phase 7d in ADR 0111 Appends the dated 7d slice: where the run executes, the public-log rule, the dispatch and its token, production only, the live-plan check, the settle rule, the reports and backstop, the resume limit the next slice inherits, and what only production can check. Not tested (prose). * fix: end an automatic run's crash in its fixed line Bun prints an uncaught exception and an unhandled rejection itself, with the message and a source excerpt, which can name a path or a key in the public log. The quiet guard now takes both: the run ends with result phase=failed code=runner-failed and exits 1, a run that had said it succeeded says it failed, and one that had said why it failed keeps its word. Tested: a throwing timer and an unhandled rejection in a real process leave only repull-auto lines; each handler mutated and caught. * fix: send an automatic run's token only to NEMAR An automatic run refuses a TEST_API_URL or stored apiUrl other than the production API or a loopback one (auto-api-not-production) before anything is sent, and does not report it; the notices request, which carries the NEMAR key, is skipped in automatic mode. The token on argv is checked before the plan file is read, a missing event file is runner-failed, and one id bound (15 digits) is shared by the Worker's builder and the CLI. Tested: unit and payload suites; each guard mutated and caught. * fix: keep an automatic copy inside the token's hour The App token the workflow mints lasts an hour. A plan whose copy and uploads would take more than 20 minutes by estimate (30 MiB/s, the server-side rate ADR 0064 records, and a second an object, with no credit for concurrency) is refused auto-copy-too-long at plan and from the live plan at execute, before the copy, and the word ends the automatic path for that tag. A run that fails while GitHub answers its token 401 is reported token-expired, whatever its step called it. Tested: unit (budget edges, the override only shortens, the probe) and CLI (refused at plan; a refused registration push with an expired token reported token-expired); each guard mutated and caught. * fix: settle the release head only on what was read The branch is quiet only over successful reads: the settle ends when reads have seen the recorded head unchanged for the quiet period, or at its bound, and it is settled only if a read succeeded in the last quiet period. Otherwise the run records [auto:head-unreadable] with the last read's cause in fixed words and reports failed head-unreadable (resumable at pr_open). The stored head-foreign text no longer speaks of a command that is not built. Tested: settle on a virtual clock (quiet, a move, the bound, always unreadable, reads that stop), and through the CLI with an unreadable origin; each guard mutated and caught. * fix: harden the re-pull workflow's public log The two sts calls send their error to /dev/null (an explicit deny names the IAM user and the account); the App token and Bun actions are pinned to the commits run-publication-review.yml pins; the header names the workflows that already use each secret and says the App token lasts an hour. The test now checks that curl reads its configuration from stdin, the pins, the one id pattern, and that the stalled-run slice's resume window still opens its pull requests the same UTC day. Tested: actionlint with shellcheck; workflow suite 33 pass, 3 parity skips; each guard mutated and caught. * test: cover the automatic run's checks end to end Through the real binary: an API that is not production's, the token on argv before a bad plan file, an unknown option and a missing event file (failed result line, nothing reported), a finish fed to plan, another dataset and other tags (dispatch-mismatch), a rerun tolerating already-started, a create answered with an administrator's or another record, a taken-up record whose plan has a correction, and a finish of another record, an administrator's, a completed one or none. Tested: CLI suite 31 pass; each covered guard mutated and caught. * docs: align the 7d slice and comments with the run The 7d slice now states the App token's hour and the copy budget with its reason, token-expired, the settle rule as built, the API check, the crash handling, the hidden sts error, the pinned actions, the one id bound, what a tenth key does (the CLI reports nothing; the backstop reports a shape-valid one, which the Worker stores only for its own token), that a refused plan writes no record but leaves its file on the runner, what REPULL_JOB_TIMEOUT_MINUTES binds, the finish's --wait-minutes 30, the resume window now checked here, and what 7f's resume of a copied record meets. Header annotations name 7d. The automatic module's comments match the code. Tested: adr-index and the decision tests; lint. * Keep automatic runs inside the App token hour The workflow notes the mint time (NEMAR_REPULL_TOKEN_SINCE) just before minting; the CLI plans for 55 minutes of the token. The copy budget is now derived: 55 minus the settle's six-minute reserve and 29 minutes for the other steps, so it stays 20 minutes but the settle is inside the hour. The plan, the execute before its record, and the copy, registration and pull-request steps refuse auto-token-hour when what is left would not fit; a missing or future mint time refuses auto-token-clock. The settle is cut at the end of the usable hour and a cut settle is head-unreadable (cause token-hour). The stored head-unreadable message and comments no longer promise a later run: an administrator's resume is the only way to settle it again. The quiet line now logs token_age_s and per-step seconds. Tested: unit, workflow and automatic CLI suites (injected clock and mint times in the past), typecheck and biome. * End a crashed run with its stored report The sink records a terminal report the Worker stored. A crash, or an exit without a result line, after that prints the quiet line, a report-stands line and the stored result, instead of a failed line the dispatch's record contradicts. The crash handler's body is in try/finally so it exits 1 whatever happens while writing, and the closing lines mark the run ended before writing, so a log that cannot be written is not tried again on the way out. Tested: unit suite, including a crash after a stored opened and failed report, an exit after a stored finish, and a crash whose stdout throws (exit 1, nothing on stderr). * Make token-expired final; skip needless probes The App-token probe no longer runs for words that already say why the run stopped: auto-token-on-argv (reported first and as itself), auto-token-hour, auto-token-clock, head-unreadable and head-foreign. token-expired is reported refused once an open run left its record, and is in DISPATCH_FINAL_CODES, so the scheduler sends no new dispatch for the tag; before the record it stays failed. The report and the probe fetch with redirect "error", so neither token follows a redirect. Tested: unit suite (real loopback 307 redirect servers), automatic CLI suite (expired token with the token on argv, at the settle and at the registration; final_refusals counted by CANDIDATE_BLOCKERS_SQL). * Hide the workflow login's stderr too The sign-in step sends both streams to /dev/null, since either can name the account. The workflow test pins the line and runs the step with a stand-in nemar that prints on both streams and exits 0 or 1. Tested: workflow suite, actionlint with shellcheck. * ADR 0111: record the 7d token hour and limits The 7d slice now says how the token's 55 usable minutes are shared (settle reserve, other steps, the derived copy budget), the elapsed checks and auto-token-hour/auto-token-clock, the settle cut, the probe's skip list, token-expired reported refused and final once a record exists, redirects refused, crash lines after a stored report, the logged durations, and that an administrator's resume is the only way to settle a head-unreadable pull request. The stalled-run limit names where a resume still works: planned, and prepared before any object is copied; a CLI test shows the latter replans to the record's digest and opens its pull request. Tested: adr-index suite; the new CLI test. * Keep the automatic unit suite in unit-pure The redirect test of the report set the CLI's API address through the environment variable the CI routing reads as a live-tier marker, which moved the file out of unit-pure while its header claimed it. The report now takes the API address as a tests-only option (the CLI's own by default), and the test passes the loopback server's address there instead. The header says it starts two loopback servers. Tested: ci-tier-routing and the automatic unit suite (109 pass); the redirect mutant is still killed; the CLI happy path still reports.
…and the mirror rehearsal (#1962) * feat: replay re-pull corrections as N.0.1 After N.0.0 is merged, tagged, minted and its objects locked, resume makes N.0.1 from the reviewed plan: NEMAR's side of each correction (and of each conflict resolved with --take-ours) replayed onto the new main byte for byte, the README family as a unit, the description keys set and Version N.0.1; no scrub, no copy; replayed annexed keys must be in the bucket and at nemar-s3. Conflicts wait for a decision (--take-ours or --keep-upstream) before anything is made. N.0.1 then takes the same screen, gates, merge gate (claiming the cap as n1), pr-reviews delegation and release as N.0.0, ending complete. Tested: repull-patch (real git) and repull-patch-cli (real CLI and Worker routes, GitHub and S3 stand-ins); release and pr-reviews suites updated for N.0.1 being built. * feat: abandon and supersede a re-pull nemar admin repull abandon <id> ends an open record: before N.0.0's merge it closes the pull request, deletes the release branch (only when its head is the record's commit or enrichment's), reports the orphans the staging manifest names (objects and bytes, nothing deleted) and ends it abandoned; between merge and release it refuses (wait-for-release); after the release it declines N.0.1 (patch_declined). Every pull request of the branch is read first, and a merged one, or a held claim, refuses before anything is written. execute --supersede ends the administrator's open record of another tag, from the same from_tag and before its merge, as superseded, after the new plan is proved and made again from live sources (the old record's own release branch and pull request tolerated in its preflight). Without the flag, another open record is repull-in-flight. An automatic record is never superseded. Tested: repull-abandon-cli and repull-supersede-cli (real CLI and Worker routes, GitHub and S3 stand-ins). * feat: refuse a manual major on a mirror On an on dataset, or a row recorded as an OpenNeuro import, a higher major in nemar dataset release (--type major, --version, the prompt's major or custom version) or nemar dataset update --bump major is refused before anything is cloned or changed: a mirror's major is an upstream re-pull. The CLI's rule only; the dataset repositories' version-check workflow is not changed. Tested: dataset-release-mirror-major (the rule, and the real CLI against a loopback stand-in with git and gh shims). * feat: add a mirror rehearsal exemplar nemar admin exemplar create <xx> --source <on> --mirror <ds> makes a staging exemplar whose row says source openneuro and source_id <ds>, so an upstream re-pull can be rehearsed on an xx id. Its dev-bucket remote takes the name nemar-s3 (the one a re-pull reads) after the inherited production remote is renamed out of its way. The route stays staging-only, refuses an anonymous exemplar, and refuses a pair that is not an on dataset and the ds it mirrors. Tested: exemplar-endpoint (the route's refusals and the recorded source) and exemplar-clone (the rename on real git-annex). * test: cover a kept branch and another release PR Abandon keeps (and says it keeps) a release branch whose head is not the re-pull's; a supersede whose new plan finds another release pull request beside the old record's stays not executable. Tested: both suites pass. * fix: keep N.0.0's lock when declining N.0.1 Abandon refuses to decline N.0.1 of a released record whose lock is not recorded (lock-unrecorded), so a released version's objects are never left unlocked by giving up. The conflict wait points at the reviewed plan file, and resume says when --take-ours or --keep-upstream come after N.0.1 is made. Tested: repull-patch-cli (7 pass), with a mutant of the guard killed. * docs: record Phase 6g in ADR 0111 The Phase 6g slice (N.0.1 and its resolutions, abandon and supersede with what each can and cannot end, the manual-major refusal and its CLI-only limit, the mirror rehearsal fixture, what only stand-ins checked), twelve annotations on the sentences it builds, and the README index entry for ADR 0111. Tested: adr-index passes. * fix: read the patch count only for N.0.1's squash squashMessage read the record's corrections count for N.0.0 too, which a caller with a partial row does not hold. Tested: repull-trailers passes. * test: pin the repull texts after Phase 6g The command list and help now name abandon, --supersede, --take-ours and --keep-upstream and no unbuilt step; N.0.1's pull request body names its commands and trailers and counts only; repull-patch claims the unit-pure tier it is routed to. Tested: repull-command-text and ci-tier-routing pass. * fix: judge abandon and supersede on whole reads One reader of a dataset's pull request list (pulls.ts) for the plan's release-pr check, the open of the release pull request, abandon and supersede: a list is answered only whole, never short. The release-pr check always reads it and hands what it read to a supersede, which judges the old record's own release from that read (no second read): another release branch or pull request, a second pull request of its branch, a pre-push status or a list not read whole refuses, and says why. A held merge claim refuses the supersede before anything is planned. Abandon reads the recorded pull request by its number whatever the list says, deletes a release branch only with a lease on the head it judged (the write guard refuses a delete without one, delete-without-lease), and refuses with exit 1 before writes and exit 3 after. Tested: repull-supersede-cli (18), repull-abandon-cli (9), repull-write-guard, repull-plan, repull-plan-cli, repull-execute-cli, repull-execute-prepare pass; mutants killed. * fix: harden N.0.1's replay and release N.0.1 refuses a replayed path enrichment wrote after the merge (patch-main-moved), a description value that does not parse or a __proto__ key (patch-description-unreadable), and waits while a conflict is neither named nor left by --keep-upstream, saying how many it resolved and left. Its tagged tree must be its gated head outside .nemar/ and .github/ (patch-tree-mismatch leaves patch_merged), and its merge gate refuses a record that does not state its corrections. Re-reads use the moved-ref fetch depth, and a recognized re-synthesis records its real tree. A fixture option replaces a recording with NEMAR's own annexed content. Tested: repull-patch (19), repull-patch-cli (20), repull-patch-resolutions-cli (6), repull-release-cli, repull-gates-cli, repull-merge-cli, admin-pr-reviews-repull pass; mutants killed. * fix: refuse an unreadable mirror version On a mirror, a current or next version the rule cannot read (empty, none, 1.0, a prerelease) is refused: whether it is a major is then not known. A dataset that is not a mirror is not this rule's to judge. Tested: dataset-release-mirror-major passes; mutant killed. * fix: refuse an unread remote.log in exemplars The inherited remote's rename refuses when the git-annex branch cannot be read, instead of reading it as naming nothing. Steps 5 and 6 of prepare are one seam (prepareDevRemote: rename, ignore, configure, uuid) tested with real git-annex over directory remotes; the s3-remote imports are merged and nemarS3DevUuid is documented. Tested: exemplar-clone (40) passes; mutants killed. * test: what an exemplar row records The exemplar route's success path, against a GitHub stand-in: a mirror fixture records source openneuro and the ds, an ordinary one nemar-exemplar and its clone source, and the audit row keeps the source it was cloned from. Tested: exemplar-endpoint (20) passes; mutant killed. * docs: help texts and ADR 0111 after review Abandon's help says main's current tree and that exit 3 is resumable; resume's says a conflict not named stays upstream's only with --keep-upstream and that a record without counts exits 0 at released. The Phase 6g slice records the whole reads, the leased delete, the early claim check, the N.0.1 refusals, the unreadable mirror version and the fixture's source_id overlap; two stale decision 3 lines are annotated, and the index names the 7f slice. Tested: adr-index and repull-command-text pass. * fix: close the enrichment window at the merge Enrichment can move main after a pull request's gates on two paths outside .nemar/ and .github/ (the .bidsignore line, a placeholder participants.tsv); the squash then tags a tree the gates did not clear, and N.0.1's release refused it after the DOI, wedging the record. The merge gate now refuses such a main before any claim (merge-main-moved), for N.0.0 and N.0.1; resume takes the record back to its open status and makes the commit again on the new main, even when GitHub reports it clean. A tag that still differs is released only with resume --accept-tag-tree "<reason>", which its refusal names. A fixture option leaves participants.tsv absent on both sides. Tested: repull-patch-resolutions-cli (8), repull-patch-cli (20), repull-gates-cli, repull-merge-cli, repull-release-cli, admin-pr-reviews-repull pass; mutants killed. * fix: name what a supersede or abandon refuses A supersede refused for another release branch names it, so the stale one can be deleted by hand. With no pull request recorded (registered), exactly one open pull request of the old record's branch from the dataset's own repository is its own; a fork's, or a second one, refuses. Abandon names a merged pull request of the branch that is not the record's (foreign-pull-request-merged) instead of sending the administrator to resume. The GitHub stand-in can answer a fork's head repository. Tested: repull-supersede-cli (21), repull-abandon-cli (10) pass; mutants killed. * fix: say the form a mirror version needs The refusal of an unreadable version on a mirror now says a version is of the form X.Y.Z and how to give one. Tested: dataset-release-mirror-major passes; mutant killed. * fix: exemplar annex hint and test git identity An unreadable git-annex branch in the exemplar's rename says to run git annex init (the clone step does). The mirror fixture tests take their git identity from test/helpers/git-identity.ts, since git-annex commits to its branch and a CI runner has no global identity; they asserted nothing about the inits they rely on before, and now do. Tested: exemplar-clone (40) passes, also with GIT_CONFIG_GLOBAL=/dev/null and user.useConfigOnly=true, where it failed 5 tests before; mutant killed. * docs: record the enrichment window in ADR 0111 The Phase 6g slice states the merge gate's rule for a main enrichment moved outside .nemar/ and .github/ (merge-main-moved), the case it closes, the recovery through resume, and the named path for a tag that still differs (resume --accept-tag-tree), with its reason printed and not stored; also the supersede's fork and unrecorded pull request rule, abandon's foreign merged pull request, and the two refusal remedies. Tested: adr-index passes. * style: sort the repull command imports The abandon import landed beside Phase 7d's automatic import in the rebase; Biome orders them. Tested: bun run lint passes. * docs: align ADR 0111's 6g lines with Phase 7d With Phase 7d's unattended run built, the abandon paragraph no longer says the run is not built: abandon touches no dispatch and no workflow run and ends the record only. The index entry names the unattended run and the 7d slice; the Worker's merge is still not built. Tested: adr-index passes. * test: start repull cases from saved world points The re-pull world can save a point (refs, bucket, database, pulls) and restore to it. repull-patch-cli, repull-patch-resolutions-cli, repull-release-cli and repull-supersede-cli reach their shared starting points (N.0.0 merged, released and locked, N.0.1 opened and gated, tag C planned) once in beforeAll, with the same assertions, instead of driving every case through the same CLI runs again. No wait or sleep was in them. Tested: the four suites pass (patch-cli 55s to 32s, release-cli 30s to 25s, supersede-cli 36s to 27s locally; resolutions-cli unchanged at about 48s, its three world builds dominate). The whole live tier passes locally against stand-ins: 1925 pass, 138 skip, 0 fail in 1178s. * ci: raise the live integration cap to 35 minutes The integration-dev job's tests project to about 30 minutes on current runners with the re-pull world suites of Phases 6g and 7d; the owner chose a 35 minute cap. Only the job's timeout-minutes changes. * ci: say why the live integration cap is 35 The comment above integration-dev's timeout now gives the measured time (about 16 minutes before Phases 6g and 7d, about 30 projected with them) and the 35 minute cap the owner chose.
* feat: merge a machine-clean automatic re-pull
The advance tick now takes an automatic record at gates_clear to its
merge (upstream-repull-merge.ts): both switches, a bound of three merges
per record, fresh machine-clean facts at the merge stage, the record's
own claim (which counts the daily merge cap), an audit row written in
the statement that decides the send, then one squash PUT at the
screened sha with the gate's trailer message, recorded through the
verified route. A 4xx keeps the claim and holds merge-refused; a 5xx,
a timeout or a 2xx without merged keeps it and holds claim-held. The
squash message moves to shared/repull-squash.ts so the gate and the
Worker send one message. New hold words: merge-exhausted,
merge-message, claim-refused.
Tested: upstream-repull-worker-merge.test.ts (55), the advance suite
updated for gates_clear rows and the log line, the trailer unit test
against git, the no-mail scan, repull-merge-cli.test.ts (23).
* feat: reconcile an unanswered Worker merge
A gates_clear record holding a claim is now resolved from GitHub on a
later tick (reconcileWorkerClaim), whatever the switches say: a merge
GitHub made at the claimed head is recorded; a merge whose answer was
lost, or none sent, is sent again only under the same claim, while it
is younger than 25 minutes, the switches are on, the facts are clean
and fewer than three merges were sent; a refused merge's claim is
released through the record's writer once five minutes old, and the
record holds merge-refused; a closed pull request frees the claim by
the age its answer allows. An administrator's claim is never sent
under or released.
Tested: upstream-repull-worker-merge.test.ts (66), the advance suite,
the no-mail scan, the dispatch word list.
* feat: finish an automatic re-pull after its merge
The advance tick's third rotation now also reads automatic records at
merged and released (finishAfterMerge): once the merge's version row
has its DOI (either spelling), it claims a finish dispatch through the
dispatch record (no open cap, one live per dataset) and sends the
central workflow's finish mode, at most three times a record, then
holds finish-exhausted. It reads no switch, in exact production only,
so turning the switches off never strands a minted DOI's lineage, lock
and complete. GitHub's 404 or 422 spends an attempt, any other 4xx is
dispatch-deferred and does not; a development build sends nothing.
The cron and wiring comments now say what the tick does past the gates.
Tested: upstream-repull-worker-merge.test.ts (75, the finish payload,
the token, the bound, both switches off, the tick's cost), the advance,
cron wiring and dev-safety suites, the no-mail scan.
* feat: merge a re-pull over a BIDS failure
nemar admin repull merge <id> --bids-failure-reason "<text>" (10 to
500 characters) merges a re-pull an administrator opened over a failed
BIDS validation. The gate needs GitHub's unstable instead of clean and
refuses blocked (a rule requires the check: a bypass) and clean before
anything is written, never reuses a held claim, and sends the squash
only while GitHub still says unstable. The claim carries the override;
the Worker reads at the claimed head that BIDS validation completed
with failure, version-check with success and the state is unstable,
on an administrator's record, and writes the reason in its own
repull_bids_override audit row in the claim's batch. A claim naming it
with no reader is refused. Six new refusal words are listed.
Tested: repull-merge-bids-override-cli.test.ts (11),
upstream-repull-bids-override.test.ts (17), repull-merge-cli,
admin-pr-reviews-repull, the merge-claim, route and resume suites,
pr-review-approve, the dispatch word list.
* docs: narrow ADR 0093's merge in AGENTS.md
The ADR 0093 entry now says an administrator merges by three paths
only (pr-reviews approve --merge and y in next, which read GitHub's
state and need clean, and repull merge, whose gate all three share for
a re-pull and which reads the record, main, the review, the screen and
clean, or unstable over a failed BIDS validation with a reason, never
blocked), and that ADR 0111 narrows the merge for one class: a
machine-clean automatic re-pull pull request, which the Worker merges
when AUTO_REPULL_MERGE_ENABLED is on and approves nothing.
Tested: the ADR index and docs-links unit tests.
* docs: record Phase 7g in ADR 0111
Appends the Phase 7g amendment: the ruleset check the owner ran on
2026-10-26 (installation 131475246 of App 3679074 with contents and
pull_requests write among the rest, repository selection all, and an
empty organization ruleset list), the Worker's merge and its outcomes,
the reconcile of a held claim, the finish run, the administrator's
merge over a failed BIDS validation, the kill switch, the new words,
the measured cost and what only production can check. Eleven
annotations mark the earlier text this builds; ADR 0093's header names
the narrowing and its 2026-10-23 amendment is annotated as built; the
index entry no longer says the merge is unbuilt.
Tested: the ADR index and docs-links unit tests.
* docs: mark re-pull execution built in AGENTS.md
The ADR 0111 entry said execution was not yet built; manual execution (6b to 6g) and the automatic path (Phase 7) are now in code. Doc only; no test covers this line.
* fix: refuse a fork head at every re-pull merge
The administrator's merge gate (checkRepullMerge, through repull merge
and pr-reviews alike) and the Worker's reader of a merge over a failed
BIDS validation now refuse a pull request whose head or base is not
nemarDatasets/<dataset> itself, compared without case as the release
pull request's own check does; a deleted fork, whose head names no
repository, fails closed. fetchPullRequest reads both repositories.
The Worker answers the existing pull-request-mismatch.
Tested: a fork's and a deleted fork's head refused before any write or
PUT through the ordinary gate (repull-merge-cli), the CLI override and
the Worker's override, a base of another repository refused, and the
same repository named in another case accepted; deleting either
comparison fails its tests.
* fix: treat only 405, 409, 422 as merge refusals
GitHub's answer to the Worker's merge is a refusal only for 405, 409
and 422 (MERGE_REFUSED_STATUSES). Every other answer that is not a 2xx
saying merged: true, a 401, a 403 or a 429 among them, leaves the
merge unknown: the claim is kept and the record holds claim-held. The
module comment and the Phase 7g slice of ADR 0111 say so.
Tested: 401, 403 and 429 keep the claim, write no merge-refused and
are not released five minutes on; 405, 409 and 422 refuse, and five
minutes on are released as refused with merge-refused. Widening the
set to every 4xx fails the 401, 403 and 429 tests.
* fix: bind re-pull audit ids as text
The Worker's merge rows, its answer rows, the claim owner's edge and the
screen's dispatch count compared resource_id with CAST(? AS TEXT) over a
bound number. They now bind String(id), as resource_id is written, so the
comparison is text against text and the statement is independent of D1's
binding type: a number D1 delivered as REAL would have cast to 5.0 and
matched nothing. The record's own id = ? keeps its integer bind, and the
merge's audit insert takes the text id as a separate parameter.
Tested: the 7g merge, BIDS override and advance suites pass (222).
* refactor: declare the dispatch refusal set once
The open resume and the finish of a merged record each kept their own
copy of the statuses that say GitHub refused a dispatch itself (404 and
422, `dispatch-refused`). The dispatch module now exports the one set and
both import it, so the two cannot drift apart.
Tested: the merge, advance and dispatch suites pass (323).
* docs: say a merged row also counts as not due
The advance tick's notDue counter described only stalled rows, but the
finish of a merged row increments it too: when the version is not minted
yet, and when the tick's sends stopped after a refusal. The comment now
names both.
Tested: comment only; typecheck passes.
* fix: log a refused Worker merge at error level
A merge GitHub refused (405, 409 or 422) was counted nowhere and only
moved the row's hold to merge-refused, so the tick logged it at info
level. The tick now counts it (mergeRefused, merge_refused= on the log
line) and a tick with one is logged at error level, as a lost answer is.
ADR 0111's Phase 7g slice says so, and the 7f log line pin carries the
new field.
Tested: the merge and advance suites pass (201); a mutant that drops the
error level and one that drops the count are each killed by the 405, 409
and 422 tests.
* docs: name every outcome of the Worker's claim
The merge module's step 6 and ADR 0111's Phase 7g slice named only
cap-exhausted, cap-unreadable and claim-refused for the record's answer
to the Worker's claim. Two more exist: a live head GitHub could not
answer (the record's github-unreadable, a 502) holds pr-unreadable, and
a record that moved while it was read (stale-status) is skipped for the
next tick. Both now say so.
Tested: comment and ADR only; the mapping's test comes with the merge
tests that follow.
* docs: say which sites hand-write the trailers
trailers.ts said the two trailer lines had one definition, shared with
the Worker's merge. One formatter exists, repullTrailerLines, which the
squash message, the trailer check and the N.0.1 patch commit use, but
three sites still write the lines by hand: the re-pull commit's own
message and the N.0.0 and N.0.1 pull request bodies. The comment now
names them.
Tested: comment only; typecheck passes.
* test: pin the Worker merge's fences and bounds
Adds what the round-1 test review found unpinned in the Worker's merge:
a record that moves before the merge's audit row sends nothing; a lost
answer is not sent again once main, the review, BIDS validation or the
screen is no longer clean; a GitHub that cannot answer for the live
head at the claim holds pr-unreadable; a pull request GitHub cannot
read keeps a held claim even when the release's own read would
succeed; a held claim and a finish are skipped outside exact production
and for an administrator's record, the finish before one statement;
the finish bound holds at merged; the two bounds are pinned at three;
and the rows past their gates rotate five a tick, a merged row with a
higher id reached behind six held ones. The GitHub stand-in gains
pullReadFailures, a number of pull request reads to fail before it
answers again. The file's header no longer claims more than it shows.
Tested: the worker-merge suite passes (97). Each of 13 mutants of the
merge and the tick is killed by a test added here.
* test: refuse six more override check states
The merge over a failed BIDS validation was tested against a running,
a passed and another App's validation and a failed version-check. It
now also refuses, at the Worker's claim and through the CLI, a BIDS
validation that timed out, was cancelled or was skipped, and a
version-check still running, skipped or cancelled: only a validation
completed with failure beside a version-check completed with success
is taken. Both files' headers now say what they test, a fork's head
included, and no longer claim more.
Tested: the Worker suite (27) and the CLI suite (18) pass. A mutant that
takes any unsuccessful validation as failed, and one that takes any
unfailed version-check as passed, are each killed in both suites.
* test: scan the Worker for one merge, no approval
A source scan on the syntax tree, modeled on the re-pull's no-mail
scan, over every file of the Worker and the import closure of the
re-pull services: GitHub's merge endpoint appears once, as the URL of a
PUT in sendSquashMerge; GraphQL's merge mutations appear nowhere; and
neither the review endpoint, the APPROVE event nor GraphQL's review
mutations appear at all, so no Worker code path approves (ADR 0093).
Strings are folded from literals, templates and concatenations.
Tested: 9 pass. Each rule is proven to fire on a planted violation: a
second merge in another re-pull service, one elsewhere in the Worker
built from pieces, the one merge made a POST or moved out of its
function, GraphQL's merge, a review with APPROVE split in two, GraphQL's
review, an approval outside the re-pull's code, and a new re-pull
service picked up without being named.
* fix: name the base in the gate's fork refusal
The merge gate refuses a pull request whose head or base is not the
dataset's own repository, but its message named only the head, so a
pull request into another repository was refused with its own head
named as the reason. The message now names both.
Tested: repull-merge-cli passes (26), its new base test included.
* test: refuse a pull request into another repo
The merge gate's fork check compares the head and the base, but only a
fork's head and a deleted fork's were tested, so dropping the base
comparison passed. The CLI's GitHub stand-in can now name another base
repository, and the ordinary gate is tested to refuse a pull request
into one before any claim or merge.
Tested: repull-merge-cli passes (26). Dropping the head comparison
fails the fork tests of the gate and of the override; dropping the base
comparison fails the new test.
* fix: refuse a fork head at the claim
readRecordedPullRequest checked the head and base refs of the record's
pull request but not their repositories, so a fork's branch of the
recorded name passed the claim's live read, and only the client's gate
refused it. It now reads head.repo and base.repo and refuses unless
both are nemarDatasets/<dataset>, compared without case, with the
existing pull-request-mismatch; a deleted fork's head fails closed. The
claim and the gates read it through liveHeadRefusal, which answers
every mismatch other than an unread GitHub as head-moved, so a fork
there is head-moved with a message naming both repositories; the
verified routes and the Worker's reconcile see pull-request-mismatch,
and a fork there keeps the record and its claim. No word list changes.
The backend GitHub stand-in now names the dataset's own repository for
head and base when a test does not, as GitHub always names both, so no
test's fixture changes.
Tested: backend re-pull suites pass (955), CLI claim and gate suites
pass (461). A fork's, a deleted fork's and another base refuse the
claim and the gates with nothing written and no PUT; a fork after the
Worker's facts holds claim-refused with no PUT; a held claim reading a
fork is kept. Dropping the comparison, either half of it, or its case
folding each fails a new test.
* refactor: share one own-repository predicate
The rule that a re-pull pull request's head and base are the dataset's
own repository was kept by hand in five places: the machine-clean rule,
the Worker's read of the recorded pull request, the BIDS override's
reader, the CLI merge gate and the CLI's search for the open release
pull request. isOwnDatasetRepo in shared/nemar-app.ts now holds it,
exact against nemarDatasets/<dataset_id> and compared without case, and
all five call it. Behavior is unchanged.
Tested: the backend re-pull suites pass (955) and the machine-clean unit
suite (57) with a new test of the predicate. A case-sensitive, a prefix
and an always-own mutant of the predicate are each killed: in the unit
suite, the claim and override suites, the CLI merge gate and the release
pull request search.
* fix: refuse a fork at the gates turn
The CLI's gates turn (gatesTurn in resume) checked the pull request's
branches but not its repositories. A fork's pull request of the recorded
branch then reached the Worker's gates edge, which refuses it as a moved
head, so resume read it again on every turn until resume-looped, about
20 turns and 43 reads, without naming the fork. The turn now refuses at
its first read, with the existing pr-foreign word recorded as the step's
error and a message naming both repositories, through the shared
own-repository predicate.
Tested: in repull-gates-cli a fork's pull request at pr_open, its screen
passed, is pr-foreign after at most two reads of the pull request, and
the dataset's own repository spelled in another case reaches
gates_clear. Dropping the check fails the fork test.
* docs: name the repository rule in the gate lists
The lists of what a re-pull merge checks were kept by hand and none
named the repository rule: AGENTS.md's summary of the gate under ADR
0093, nemar admin repull merge's help, and the property lists of the
CLI merge suite and of the claim suite. Each now says the pull request
must be from and into nemarDatasets/<dataset_id>, compared without
case. ADR 0111's Phase 7g slice gains one sentence saying every merge
gate and the claim refuse another head or base repository, and that the
earlier amendments' lists do not repeat it; those lists are not edited.
Tested: text only; typecheck and Biome pass on the touched files.
* docs: name an unknown answer in lost-answer text
The merge module's comment on a claim the Worker holds, and the same
branch in ADR 0111's Phase 7g slice, spoke of a merge whose answer was
lost. Since only 405, 409 and 422 are refusals, a 401, 403 or 429 takes
that branch too, so both now say "lost or did not say what became of
it", where the claim is sent again, kept, or expired at 30 minutes. Only
the Phase 7g slice of the ADR is edited.
Tested: comment and ADR only; typecheck passes.
* docs: spell canceled in prose
The two BIDS override suites spelled the word "cancelled" in their
headers and test titles. Prose now says "canceled", in American English;
GitHub's own conclusion value, "cancelled", stays in the code that
builds each check run.
Tested: the Worker override suite passes (27); titles and comments only.
* test: pin the stale-status skip
The Worker's merge returns skipped, not claim-refused, when the record
moves between the claim's read and its commit (stale-status), so the
next tick reads it as it is; replacing that branch with if (false) left
every test green. A revision bump just before the claim commits now
shows the tick holds nothing, refuses nothing, writes no log line and
sends nothing, and the next tick merges the record.
Tested: worker-merge suite passes (100); the if (false) mutant of the
stale-status branch fails the new test.
* test: pin the audit id bind types
The statements that compare an audit row's resource_id bind the
re-pull's id as text, so D1 never compares a REAL 5.0 with "5"; but
SQLite under Bun coerces a bound number to the column's text, so
reverting any of those binds to the number passed every test. Two
guards now read the binds through interceptingD1: in the Worker's merge,
every statement with resource_id = ?n is bound a string there, across a
lost answer and the held claim's next tick (the merge's audit row, its
merges and the claim's owner); in the advance tick, the screen's
dispatch count is bound String(id).
Tested: the worker-merge (101) and advance (122) suites pass. Reverting
each of the four binds to a number fails its guard.
* test: refuse an unreadable repository
The Worker's read of the recorded pull request treats a head or base
repository GitHub does not name, or names in another shape, as an
unreadable answer, but no test covered it; without the base check a
missing base.repo threw a TypeError instead of answering 502. Four
answers (each repository missing, and malformed) now each refuse the
claim and the gates with github-unreadable (502), one test per answer;
the record of a merge refuses the same four; and in the tick each holds
pr-unreadable before anything is claimed or sent.
Tested: the claim (48) and worker-merge (105) suites pass. Deleting the
head repository's shape check fails both head rows; deleting the base
repository's fails both base rows.
* test: refuse a merged fork pull request
The test of a held claim whose pull request turned into a fork's used
an unmerged pull request, so it reached only the release half of its
title. A pull request GitHub reports merged at the claimed head and
branch, but from a fork, is now shown to keep the claim held: the
Worker never records a fork's merge as the re-pull's.
Tested: worker-merge suite passes (106). Dropping the head comparison
of the claim's read fails the new test on its own.
* test: assert the exact refusals
Three assertions could not fail. The claim suite's fork test and the
override suite's refusals asserted that GitHub was sent no merge, but
the claim route never sends one: the fork test now asserts the words
its refusal names each repository by, for the claim and the gates, and
the override's refusals that no claim edge was written. The Worker's
merge test asserted refused: {} through toMatchObject, which in Bun
matches any object; it now asserts the maps with toEqual. The advance
suite's five matchers of the same kind (held, refused and reviewRefused
as {}) are made exact the same way, and all hold.
Tested: the claim (48), override (27), worker-merge (106) and advance
(122) suites pass.
* docs: say which rows notDue counts
The advance tick's notDue comment named merged rows only, but a
released row counts too when the tick's sends stopped after a refusal;
only a merged row waits for its version's DOI. The comment now names
both statuses and which reason each can have.
Tested: comment only; typecheck passes.
* feat: count re-pulls in the weekly report
The weekly import report gains an "Upstream re-pulls" section after the
upstream freshness one. It arrives every week, quiet or not (ADR 0054),
and counts the week's dispatches by kind, state and word, the open
automatic re-pulls by hold word, claims to merge held over an hour,
re-pulls that ended failed, and merges by who held the claim (the Worker,
an administrator's tool, none). It shows the switches and caps in force
and the scheduler's last ticks, names no dataset, and prints a word only
when it is on its closed list and does not name anonymity.
Attention follows ADR 0053 exactly: a switch on with the scheduler silent
for 26 hours, an unreported or refused dispatch, a claim held over an
hour, a failed re-pull, a bound reached, an unreadable cap. A switch that
is off, a hold waiting on a gate and a run's refusal are quiet. A read
that fails leaves the facts null and lists a failed part (ADR 0054). The
shared attention rule adds the reasons, so the headline and
`nemar admin import-weekly` cannot disagree; the command prints the same
counts, and the log line gains repull_dispatched, repull_merged_worker
and repull_unreported.
Tested: a new suite through the report's entry point on real SQLite with
the production writers' audit rows, the same statements on Miniflare's
D1, the CLI against a canned report, and the no-mail scan with the new
service as a root. Mutation checks recorded in the PR.
* feat: list re-pull dispatches for admins
`GET /admin/repulls/dispatches?dataset=&status=&after=&limit=` lists the
automatic path's dispatches newest first, as a keyset page of at most 50
rows (25 by default), registered before `/repulls/:id`. It selects its
columns by name, so a live dispatch's one-shot nonce never leaves the
Worker, and it names the dataset, which the weekly report never does.
`GET /admin/repulls/switches` now also returns the scheduler's three
stamps (never its cursor, a dataset id), null when the row is absent and
a 500 naming migration 0111 when the table is.
Tested: a new route suite on real SQLite (order, the cursor, the page
bound at the route and in the service, the filters, malformed queries,
the nonce, roles, no mail), the switches route suite, the route
inventory, and the list and the scheduler's row on Miniflare's D1.
Mutation checks recorded in the PR.
* feat: add nemar admin repull auto
`nemar admin repull auto [--json]` shows the automatic re-pull as the
Worker reads and records it: the switches and both daily caps (an
unreadable cap says so and reads 0), the scheduler's two stamps, the
open automatic re-pulls with the word each is held for and any claim to
merge still held, and the 20 newest dispatches. It names datasets and
ids, which the weekly report never does. It reads every page of open
re-pulls and says when the list stopped before its end, shows an absent
scheduler row as unknown rather than never recorded, makes only GET
requests, and prints nothing when a read fails. The API client gains
getRepullSwitches and listRepullDispatches.
Tested: a new CLI suite through the real entry point against the real
admin routes over real SQLite (text and --json, paging, truncation,
unknown, a member's refusal, a failed read, GETs only), the command
list and help text, and the API export surface. Mutation checks
recorded in the PR.
* docs: record Phase 7 in ADR 0111
Appends the Phase 7h slice, dated 2026-10-26: the weekly report's
re-pull section (what it counts, how a merge is attributed by its claim,
the words it prints, unknown never zero), what asks for attention under
ADR 0053 and what does not, the administrator's list and command, the
kill switch as the runbook will state it, and the closing sentence that
the slices of Phase 7 are complete. Adds the header and Decision
annotations and a new last item under Not yet verified, and updates the
README index entry to name the 7a to 7h slices.
Documentation only; the ADR index test passes.
* refactor: share one dispatch seeder in tests
Five suites each carried their own copy of the insert that seeds a row
of upstream_repull_dispatches. They now share one in
backend/test/helpers/repull-rows.ts: the statement, its binds for any
driver, and a bun:sqlite seeder. The two Miniflare suites bind the same
values, and a live dispatch's nonce carries one recognizable mark, so
each suite that proves the nonce never leaves the Worker asserts on it.
Tested: the five suites pass unchanged (71 tests), and the nonce
assertions still fail when the list selects the whole row.
* fix: count only real merge edges
The merge count read every audit row of an edge into merged or
patch_merged. The release's step errors (a tag or a version row not
there yet) write an edge from merged to merged, through the same writer,
so one Worker merge plus two release errors reported worker=3, and one
merge outside NEMAR's tools plus one error reported unattributed=1, in a
public report. The statement now counts an edge only when it starts
somewhere other than where it ends, and its comment and the 7h slice of
ADR 0111 say so.
Tested: three regression tests drive the production writers
(transitionRepull and recordRepullMerged): one merge with two release
errors counts once, an outside merge with an error is not unattributed,
and N.0.1's error adds nothing. Each fails on the old statement with the
counts above.
* test: pin merge claimants and window edges
The merge tests now go through the production writers
(transitionRepull, recordRepullMerged, releaseMergeClaim) instead of
hand-built audit rows.
They pin the four counts with distinct numbers, so a swapped predicate
moves a count; that whoever records a merge does not decide its
claimant; a claim taken over; N.0.0 and N.0.1 on one record taking
each its own latest earlier claim; and the inclusive start and
exclusive end of both the merge and the failed windows.
Tested: the section suite passes; 11 mutants (ORDER BY ASC, dropped
earlier-claim bound, claimant from the recorder, three predicate swaps,
the outside flag, four window edges) each fail it.
* fix: treat a partial D1 batch as unknown
The weekly re-pull read sends five statements as one batch and took
whatever answers came back.
A batch with more or fewer answers than statements, or with an answer
that did not report success, is now a read that failed, so the section
is unknown with a failed part and never the counts that did arrive.
A missing rows array already threw and now has a test of its own.
The tests alter the batch answers of a real D1 (failure injection, no
canned rows) and fail the batch at the batch step as well as at the
prepare step, where only the prepare step was failed before.
Tested: the section suite and the six suites that call the gather pass;
7 mutants (rows guard to an empty list, length clause dropped, success
clause dropped, success tolerated when absent, a swallowed batch
rejection, an unchecked batch, a one-sided length test) each fail it.
ADR 0111's Phase 7h slice states the rule.
* test: pin that fault holds raise no attention
merge-refused, gates-refused and claim-refused are counted in the
table of holds and ask for nothing, with both switches on and a fresh
scheduler; one test each.
A broader test seeds every hold word but the two bounds
(resume-exhausted, finish-exhausted) and expects no reason, so a word
added to the list later cannot start asking unnoticed.
ADR 0111's Phase 7h slice now says so beside the gate holds.
Tested: the section suite passes; 6 mutants (merge-refused,
gates-refused, claim-refused, merge-exhausted and resume-refused each
asking, and any hold beyond the two bounds asking) each fail it.
* fix: name the resume and finish bounds
The weekly section's footer, the shared attention rule's comment and
ADR 0111's Phase 7h slice said that "a bound reached" asks for
attention.
Only two bounds do (resume-exhausted and finish-exhausted); the merge
bound, merge-exhausted, is a hold that is counted and does not ask.
All three now name the two, and the footer adds that every other hold
is counted in its table and does not ask.
Tested: the section suite passes with a new pin on the footer's text;
2 mutants (the old wording back, the new clause dropped) fail it.
* fix: print every merge count in import-weekly
The second re-pulls line of nemar admin import-weekly printed three of
the four merge counts and left out the merges whose claim is not in
the audit log, so the line did not add up to the merges.
It now prints merged_unattributed as well.
The CLI fixtures now hold a different non-zero number for every count
the two lines print (a routine week for the ones that do not ask, and
a busy week with all fourteen), so a label moved onto another count is
a different line.
Tested: test/import-weekly-cli.test.ts passes; 7 mutants (the count
dropped, and six labels moved onto another count) each fail it.
* refactor: take the switch types from shared
repull-switches.ts declared CapReading and RepullSwitchesReport, and
shared/repull-observability.ts declared the same two shapes as
RepullCapReading and RepullSwitchesReport for the wire.
The service copies are deleted and the three importers
(upstream-repull, upstream-repull-dispatch and the readers in
repull-switches itself) take the shared names, so the Worker and the
CLI read one declaration.
No behavior change.
Tested: bun run typecheck exit 0; Biome clean; the switch, dispatch,
merge and no-mail suites pass.
* test: pin an absent field and the N.0.1 hour
Three gaps the review found in the weekly section's tests.
An unreadable cap must read "unreadable, so it reads 0" and never "0
(the default)".
A report whose re-pull field is absent (an older backend) must render
unknown in the body and in each of the three log counts without
throwing, and must raise the could-not-be-determined reason.
A claim to merge on N.0.1's pull request is held to the same hour as
N.0.0's: exactly an hour is not older, a second more is.
Tested: the section suite passes; 7 mutants (the cap rendered as the
default, the absent field treated as a value in the body and in each
log count, the N.0.1 bound made inclusive, the N.0.1 half of the claims
dropped) each fail it.
* fix: correct the auto help on a failed read
The help for nemar admin repull auto, and ADR 0111's Phase 7h slice,
said that nothing is printed when a read fails.
The command prints the failure line and no table, which its own test
already pins, so the help now says "Only the failure is printed then,
never a table" and the ADR says it prints the failure and no table.
The help test pins the new wording and rejects the old.
Tested: the command-text suite and the ADR index test pass; 2 mutants
(the old wording back, a table said to follow) fail the pin.
* fix: print only fixed words in the weekly tables
The closed-list rule for a word (on its list, and not naming
anonymity, else other) ran only in the gather, so a table rendered
from facts that held an id where a word should be would print it, and
the test that claimed otherwise rendered a fixture with no id in it.
The rule moves to shared/repull-observability.ts as publicWord; the
gather uses it, and the renderer now folds every word of every table
and the scheduler's outcome through it and adds the counts that come
to the same word, so the report on a public repository holds no
identifier by either road.
The id test now renders facts with ids of every shape in each place a
word is printed, beside listed words and one that names anonymity, and
pins the exact tables.
publicWord has unit tests of its own, including that a digit does not
withhold the four codes that hold one.
Tested: typecheck exit 0; the section suite, the dispatch words suite
and the ADR index test pass; 15 mutants (the renderer raw, unsummed,
raw outcome and on the wrong list; publicWord without its list, without
the anonymity rule, with a digit rule and with swapped lists; the gather
on the wrong list) each fail them. ADR 0111 states the rule.
* test: compare real output in the weekly tests
Two tests could not fail.
The headline test compared weeklyHeadline(f).attention with
weeklyAttention(f).attention, which is one value read twice.
It now asserts the literal text: the Worker's reasons in the headline
word for word and in their order, a quiet week adding none, and a week
that is null or absent asking in words.
The statement test matched dataset_id in the SQL text, which
"dataset_id AS d" evades.
It now runs each of the five statements over seeded rows and requires
exactly the columns the gather reads.
Tested: the section suite passes; 10 mutants (one reason, reversed
reasons, null or absent not a reason, a headline of the first problem,
and a dataset_id column added to each of the five statements) each fail
it.
* docs: correct test headers and a spelling
The headers of the weekly section test, the dispatch route test and
the auto command test said each property has "a test that fails when
its line is changed", which no header can promise; they now say "a
test of its own".
The section test's header also names what the suite now covers (facts
that hold an id, a partial batch, the holds that do not ask).
"Modelled" is "modeled" in the route test.
Comments only. Tested: Biome clean; the three files are unchanged in
behavior and the section suite still passes.
* test: pin the dispatch list client filters
listRepullDispatches sends four filters (dataset, status, after,
limit) and the command used only limit, so a client that dropped or
misnamed any of the others passed every test.
The client is now called in-process against the real routes over real
SQLite, with six dispatches over two datasets and three states: one
test each for dataset, status, after (strictly below the named id) and
limit (with the cursor it returns continuing the page), one for the
filters together, and one for none.
The route and the client have no kind filter, so none is tested.
Tested: test/admin-repull-auto-cli.test.ts passes; 6 mutants (each of
the four filters removed from the client, the dataset sent under the
wrong name, after sent as limit) each fail it.
* test: pin that auto prints no API key
Nothing checked that nemar admin repull auto keeps a key out of its
output, though the brief requires it.
The test stores an admin key, sets NEMAR_API_KEY, GH_TOKEN,
GITHUB_TOKEN and AWS credentials in the CLI's environment, and puts
secret-named sentinels in the Worker's bindings (the GitHub PAT, the
Resend and callback keys, the encryption key), then runs the command
as text and as --json and requires that neither stream holds any of
them, the stored key's eight-character prefix, or a Bearer header.
It also requires that something was printed, so an empty output is not
a pass.
Tested: test/admin-repull-auto-cli.test.ts passes; 5 mutants (GH_TOKEN
printed after the table, NEMAR_API_KEY and AWS_SESSION_TOKEN in the
JSON, the client logging its Authorization header to stderr, the
Worker's bindings spread into the switches report) each fail it.
* test: pin exclusive merge counts
A merge recorded as made outside NEMAR's tools has a claim edge in the
log when the claim was released and the merge was then made by hand.
Without the guard in the worker and administrator counts, the same
merge was also the claimant's.
Two tests (the Worker's released claim, an administrator's) record such
a merge through the production writers and require one merge outside
the tools and none under the claimant.
The lost-claim test now rewrites the claim edge as an entry edge from
pr_open instead of deleting it, so a claim edge that is not a
self-edge is seen not to be a claim.
Tested: the section suite passes; 3 mutants (the outside guard dropped
from the worker count and from the administrator count, and the
self-edge guard dropped from the claim edge) each fail it.
* fix: tie the claimant to the merged pull request
The weekly merges statement took the latest claim edge of either pull
request before a merge, so an N.0.1 merge whose own claim edge was
lost (an audit row that never landed) was counted as N.0.0's
claimant's, and the merge count named a claim that was not its own.
It now takes the claim edge of the pull request that merged: the
gates_clear self-edge for a merge into merged, the patch_gates_clear
one for a merge into patch_merged.
An N.0.1 merge with no claim edge of its own is unattributed.
The doc comment on the statement and ADR 0111's attribution sentence
say the claim of the pull request that merged.
Two tests (N.0.0 claimed by an administrator and by the Worker) lose
N.0.1's claim edge and require unattributed; the D1 path gets the same
rows, so Miniflare's D1 runs the CASE as well.
Tested: the section and D1 suites pass; 2 mutants (the either-pull-
request predicate back, and the CASE inverted) fail them.
* test: run the merge self-edge clause on D1
The D1 path had no row for the release step's error on a merged
record, so the from-is-not-to clause of the merges statement ran there
over nothing it could exclude.
The Miniflare test now holds a merged-to-merged edge on N.0.0's record
and a patch_merged-to-patch_merged edge on N.0.1's, and still expects
the same counts: neither is a merge.
Tested: the D1 suite passes; 2 mutants (the clause dropped, and
inverted so only self-edges count) each fail it.
* fix: print a scheduler stamp only as a time
The scheduler's last_tick_at and last_advance_at are text columns that
check nothing about their content, and the report printed them as
they were stored.
A forged value (a dataset id, say) would have reached the public
repository.
A stamp is now printed only when it has the form SQLite's datetime()
writes; any other value is said to be "a recorded run that could not
be read", and with a switch on that is the existing reason that the
scheduler's last run could not be read.
The test stores six forged values (an id, an id with a time before or
after it or on a second line, an ISO form) in both stamps, requires
that neither appears in the report and that the sentence says so, and
requires that a real stamp is still printed.
ADR 0111's slice states the rule.
Tested: the section suite passes; 4 mutants (printed raw, each anchor
of the shape check dropped, the check inverted) each fail it.
* fix: name a dispatch GitHub did not accept
The weekly section's footer, which says what asks for attention, left
out a dispatch that GitHub did not accept (dispatch_failed), which the
rule raises a reason for.
The footer now says "a dispatch nobody answered or that GitHub did not
accept"; the shared attention rule's comment, the weekly service's
header and ADR 0111's attention list say the same, in the words of the
reason itself ("not accepted by GitHub") rather than "refused", which
is also the word for a run's refusal, a state that does not ask.
Each case of the one-reason-at-a-time test now carries the footer's
words for its reason and requires the section to hold them, so a
reason the rule raises that the footer does not name fails its case.
Tested: the section suite passes; 5 mutants (the footer without the
dispatch clause, without the held claim, the failed re-pull, the
unreadable cap, and the scheduler) each fail it.
* docs: say what makes a batch answer unreadable
ADR 0111's Phase 7h slice said an answer "that holds no rows" is a
failed read.
The code throws on an answer with no rows array, and treats an empty
array differently by read: on a grouped read (the dispatches, the
holds) it is a true zero, and on a count, which always returns one
row, it is a failed read.
The ADR and the gather's comment now say that.
The empty counts had no test, so the claim is backed: the claims, the
merges and the failed counts each come back with an empty rows array
and the section is unknown with the aggregate's own message.
Tested: the section suite and the ADR index test pass; 2 mutants (the
aggregate check removed, an empty merges answer read as zeros) fail
it.
* refactor: renumber the dispatch migration to 0112 origin/dev took 0111 for the mail screening, so the automatic re-pull migration moves to 0112. Nothing is deployed. Every reference to the migration number moves with it (the route's hint, the auto view's line, the tests that pin both, comments); ADR 0111 gets a dated note. Tested: migrations:d1-check, the dispatch migration, re-pull route, dispatch route, auto view, weekly section and ADR index suites. * refactor: move the repull canary to scripts The S3 canary is the owner's one-off real-bucket check, so it leaves the shipped CLI: `nemar admin repull canary` is gone and the same implementation runs as `bun run scripts/repull-canary.ts` with the same arguments, fences, dry-run default and --execute. The write guard stays in src. The test moves with it and runs the script; the help pin moves from the command-text test to it. ADR 0111 gets a dated note. Tested: test/repull-canary.test.ts (real aws CLI on the S3 stand-in) and test/repull-command-text.unit.test.ts; typecheck; biome. * feat: filter re-pulls by origin on the admin list GET /admin/repulls takes `origin` (automatic or administrator; any other value is 400 invalid-query), and `nemar admin repull auto` asks for the automatic ones instead of paging every origin and filtering on the client. The two origins are declared once in shared state. Tested: a route test that the filter returns only that origin and refuses any other; the auto view's paging test now pins two pages and the origin it asks for. Mutants killed: the SQL filter dropped, the route's check removed, the view not asking for the origin. * test: keep one layer per machine-clean rule Each machine-clean rule is pinned once, where its fact is read (upstream-repull-facts.test.ts, beside the pure table). The advance tick and the Worker's merge each keep one case that shows the stage applies the rule (the last rule, GitHub's unknown mergeable state), and the tick keeps one case that a hold before the screen starts no gate work. Four repository-shape cases only the merge suite had move to the facts suite. The two GitHub stand-ins stay separate. Tested: the four suites (advance 105, merge 81, facts 98, unit 57, all pass). Each rule mutated in shared/repull-machine-clean.ts is killed by the facts or unit suite; one mutant is equivalent. * refactor: share the GitHub pull request parser pullRequestFacts in upstream-repull-github.ts is the one parser of GitHub's pull request. The machine-clean reader (pullRequestFactOf) now builds on it and reads only the fields the other path does not: the author, the number, draft as sent and mergeable_state. The accepted shapes and every hold word are unchanged. Tested: every backend/test/upstream-repull* suite passes unchanged (873). One facts case is added: a head that is not a commit id is pr-unreadable; no suite pinned that check in either parser before (mutant survived on the old code, killed now). * refactor: share the automatic plan rule automaticPlanRefusal in shared/repull-state.ts is the one rule the automatic path holds a plan to: this planner's, unexplained, conflicts and corrections stated as 0, and a stated copy size within AUTO_MAX_COPY_BYTES. The Worker's automatic create and the CLI's assertAutomaticCounts both call it; the CLI then checks what only a run can (every key's size known, the copy within the token's hour). Codes and order are unchanged. The words test's scan of the Worker proves itself on auto-repull-off now: auto-not-clean-plan's literal moved to shared. Tested: test/repull-automatic.unit.test.ts and backend/test/upstream-repulls-route.test.ts (181 pass), test/repull-dispatch-words.unit.test.ts (11 pass). Mutants killed on both sides: corrections dropped from the rule, the bound widened by one byte; the CLI's known-size check removed is killed by the unit suite. * refactor: pass the tick's reads to its gates The advance tick's gates edge and the Worker's claim now check the dataset fences, the screen and the pull request on the tick's own reads of them (readMachineCleanFacts), instead of reading each again. The statements still re-assert the screen and, for the claim, the cap and the dataset's anonymity and withdrawal. Five clean rows at the gates take 20 GitHub reads and 42 D1 statements (were 25 and 52); five merges 30 and 72 (were 35 and 82). ADR 0111 gets dated notes. Tested: every backend/test/upstream-repull* suite (874 pass). The tests that pinned the second reads now pin one read per pull request, the claim made on the tick's read, its own check of a fork's read, and a screen stored again after the read refusing the gates edge. Mutants killed: the screen guard dropped, GitHub read again, the passed pull request's repository unchecked. * refactor: plan once in the unattended run The automatic `plan` keeps its scratch clones and the bytes it computed beside the plan file (keepPlanHandoff), and the automatic `execute` takes that plan, proved by its digest and checked as before (the automatic plan rule, the token's hour), and prepares from those clones without planning again; with no handoff it refuses not-planned before the record. An administrator's execute still plans again. The quiet line loses replan_s. ADR 0111 gets a dated note. Tested: test/repull-automatic-cli.test.ts (42 pass, two new: execute opens with OpenNeuro unanswered and asks it nothing; execute without the handoff is not-planned), test/repull-automatic.unit.test.ts and test/repull-workflow.test.ts. Mutants killed: execute planning again, a handoff taken without its clones. * refactor: cut the dispatch word list DISPATCH_CODES goes from 248 words to 57: the Worker's own and its answers to a report, the run's own, the final codes and nine step classes. A run reports a refusal whose word the list does not hold as the class of the step that met it (ExecuteRefused.step, named at each stage: plan, record, prepare, copy, register, pr, settle, finish; a scrub refusal is scrub-failed), no-code only with no step. The exact word stays in last_error. The workflow's five words and the migration's CHECKs (shape only) need no change. no-github-token and to-tag-malformed are the advance tick's own words. ADR 0111 gets a dated note. Tested: dispatch-words (pins the list; every scanned refusal word of the CLI, the scrub and the Worker reaches a report as a listed word), automatic unit, workflow, admin auto view, every backend re-pull and weekly suite, and the automatic CLI suite (43 pass; a copy step's pin-changed reports copy-failed). Mutants killed: copy-failed off the list, unlisted words reported as they are, the scrub's class, the step wrapper and the record step not naming themselves. * revert: keep the tick's own reads Reverts bf51e92. The read pass-through added 116 net lines to save GitHub reads that the tick does not need: its reads and subrequests stay inside the pinned budgets. The tick's decisions and tests are as before. * test: drop a pin on a removed word The withdrawn refusal is the tick's own code, no longer a dispatch word after the word cut; the revert restored an older pin on it. The test's other assertions are unchanged. * fix: write the planner handoff atomically keepPlanHandoff writes the computed bytes inside the planner's directory first and renames the whole into place last, so a handoff is complete or absent; readPlanHandoff refuses not-planned unless both the clones and computed/ are there. Before, a handoff missing its computed bytes let execute write its record and fail at the preparation. Tested: a new automatic CLI case (computed/ deleted after the plan: not-planned, no record, no writes) and the handoff cases (3 pass). Mutant killed: the computed check dropped with a tolerant read. * fix: clean up the planner handoff everywhere The automatic execute command now removes its plan step's handoff however it ends (a cleanup the run wrapper calls in a finally), so a record taken up past prepared, a refusal before the preparation and a plan file that does not prove all leave none behind. Execute itself removes only an administrator's planner clones, as before item 8. Tested: four automatic CLI cases (the token-hour refusal and a record taken up past prepared leave no handoff; a taken and a refused plan leave no planning scratch). Mutants killed: the execute's cleanup deleted (3 tests), the plan's scratch removal deleted (2 tests). * fix: take the executable flag from verified data The automatic execute no longer reads the plan file's executable, which sits outside the digest. The plan step's handoff now names the digest of the plan it took (keepPlanHandoff), and execute requires a handoff for the digest its proved body hashes to: that handoff, left only for an executable plan the automatic path takes, stands for the flag. Execute checks the counts and the token's hour as before. ADR 0111's note says so. Tested: five new automatic CLI cases: the flag flipped on disk changes nothing; a body byte edited is refused (plan-refused) and one edited and digested again is not-planned, both writing nothing; another API and other remotes are refused, writing nothing. Mutants killed: the raw flag read, the digest skipped, the handoff's digest unchecked, the environment and the sources unchecked. * docs: say what a refusal keeps The word list's comment and ADR 0111's word-cut note say plainly that a refusal before the record exists keeps only its listed word; once the record exists, the exact word is in last_error. The automatic plan rule, the copy budget and the plan checks say what happens at execute (the plan's proved body, the handoff for the flag) instead of a live plan. FIXED_WORD_RE's comment says migration 0112 checks the word's shape only; z.enum(DISPATCH_CODES) and isDispatchCode hold the list. The new ADR notes put one sentence on each line. Tested: dispatch-words, automatic unit and ADR index suites (65 pass). * test: restore the check-still-running hold The advance suite again has the case of a version check still queued (version-check-pending): no screen, no review is started. The cut to one case per stage had dropped it, and with it the only test that failed when gate work started one rule early. GATE_WORK_HOLDS is also pinned to its 15 words. Tested: backend/test/upstream-repull-advance.test.ts (107 pass). Mutants killed: gate work from version-check-pending (both tests), from version-check-failed (the pin). * test: pin each step class end to end Four automatic CLI cases report a word the list does not hold as the class of the step that met it: the record refusing the prepared edge (field-invalid) is prepare-failed; GitHub giving no answer to the pull request (pr-create-unknown) is pr-failed; the record refusing the settle's move (stale-status) is settle-failed; a finish whose dataset the catalog no longer has (dataset-missing) is finish-failed. Tested: the four cases pass. Mutants killed: the preparation tagged as the copy, the settle as the pull request, the step wrapper naming one fixed step, the finish as the plan. * test: refuse an absent draft The facts suite now has a pull request answer with no draft, which is pr-unreadable: the rule's reader is the only guard that keeps an absent draft from reading as not a draft. Tested: backend/test/upstream-repull-facts.test.ts (100 pass). Mutant killed: the draft guard dropped. * fix: tag another plan's open record as record An automatic execute that meets an open record of another plan refuses repull-in-flight before anything is planned; that refusal now names the record step, as the other record refusals do, so it is reported record-refused instead of plan-refused. Tested: a new automatic CLI case (an administrator's record of another plan at planned: refused, record-refused, the record untouched). Mutant killed: the record step left off that refusal. * docs: name the steps that keep their word The word list's comment and ADR 0111's word-cut note claimed that once the record exists its last_error keeps the exact word. Only the preparation, the copy, the registration and the pull request write it (`[<step>:<word>]`) when they fail on their own; a refused edge, the settle and the finish keep only the listed word, as the suites show. Both sentences now say so. Tested: ADR index and dispatch-words suites. * test: pin the plan step's executable gate Execute takes the plan step's handoff for the executable flag, so the plan step is the only gate on it, and no case had a plan that is not executable. A release branch of the target version already on origin now makes plan refuse: exit 3, plan-refused, no handoff, no planning scratch, nothing written. Tested: the new automatic CLI case passes. Mutant killed: the plan step's executable gate removed (the counts still checked). * test: pin the handoff's clones check The clones check in readPlanHandoff lost its only pin when the atomic handoff widened the checks: the case with no handoff trips another check first. A handoff whose upstream.git is gone now refuses not-planned with no record and nothing written, and a plan refused for the token's hour is shown to leave no handoff. Tested: both automatic CLI cases pass. Mutants killed: the clones check dropped; the handoff kept before the token-hour refusal. * fix: keep the handoff for a live lock holder The execute command's cleanup removed the plan step's handoff however the run ended, including when execute was refused at the plan's lock (execution-locked), which deleted the clones the execution holding the lock reads. The cleanup is now given the word the run was refused or failed with, and keeps the handoff on that refusal; Spec.cleanup says so. Tested: a new automatic CLI case (the plan's lock held by a live process: refused, the handoff kept, no record) and the refused-execute cleanup case. Mutant killed: the removal restored on that refusal. * refactor: bind the live plan as livePlan readExecutablePlan names the re-made plan livePlan instead of outcome.file, so the live: field it returns no longer reads as the live sources parameter. The module doc says the live decision is an administrator's run's; a dispatched run decides nothing live. No behavior change; typecheck and Biome pass. * docs: execute asks the automatic counts again assertAutomaticPlan's doc said execute reads neither the flag nor the counts from the file. takeAutomaticPlan asks assertAutomaticCounts of the proved body; only the executable flag is left to the handoff. Comment only.
Merge origin/dev (81e953d, 34 commits: 0.10.24 and 0.10.25, the Cloudflare mail move, inbound screening, the App rename) into the epic. Four conflicts, resolved by keeping both sides: - CHANGELOG.md: the epic's Unreleased section first, then dev's 0.10.25 and 0.10.24 sections, newest first; no entry dropped. - backend/src/services/github/branch-protection.ts: the epic's comment and re-export from shared/nemar-app.ts, with dev's rename of the App to nemar-bot applied to the comment's first line. - test/admin-route-inventory.unit.test.ts: dev's mail entries and the epic's repull entries auto-merged; the pin is the union, 198 (170 at the base, plus 23 from the epic and 5 from dev). - test/api-export-surface.unit.test.ts: both POST_SPLIT_ADDITIONS additions, dev's mail functions then the epic's repull ones. Migrations stay unique: dev adds 0109 to 0111, the epic 0104 to 0106 and 0112. Tested: typecheck passes; both inventory test files pass.
GitHub now names the App's bot user nemar-bot[bot]; the old login answers 404, and the user id (283755542) and the App id (3679074) are unchanged (gh api, 2026-10-26). - shared/nemar-app.ts: NEMAR_APP_BOT_LOGIN is nemar-bot[bot]; the comment keeps the 2026-10-24 measurement and records the new one. - pr-review-queue.ts: loginLabel shows the App's name only beside the App's numeric id, as restAuthorLabel already did; the machine-clean rule, the review start and the intake already compared login, id and type. - Tests: the identity pin, the lookalike logins (nemar-bot2[bot], nemar-bot) and two comments follow the rename; two new detail-view tests store a review under the App's login with another id, and under the App's id with another login, and neither is shown as the App's. Tested: typecheck; Biome on the changed files; the four affected suites pass (191). Mutations of loginLabel (login only, either half, id only) each fail a new test, and the old login fails the pin.
The Unreleased deploy-coupling bullet said the onboard workflow change lands first; it shipped in 0.10.24 (#1933). Doc only; no test reads this bullet.
A pull request from a bot with the App's numeric id under another login (nemar-bot2[bot]) shows (unknown) in the detail view. Tested: the admission suite passes (32); with the login half of restAuthorLabel dropped, the new case fails.
A dated amendment at the end: the App is now nemar-bot, the bot user nemar-bot[bot] with id 283755542 and the App id 3679074 unchanged, the old login 404. The earlier lines stay as dated history; the production-only check in the Phase 7e amendment now names nemar-bot[bot]. Doc only.
The enrichment run commits as nemar-bot (formerly nemar-publish-bot) since the App was renamed on 2026-10-26. Doc only.
The ADR 0113 entry sat after the Backfill note; it now follows ADR 0112 in the index list. Line content unchanged. Tested: the ADR index test passes.
Sync the epic with dev and follow the App rename
* ci: check out the repull workflow in tests Adds run-upstream-repull.yml to the sparse checkout of the deployed dataset workflows and updates the comment's count to four. Nothing reads the file yet; the next commit names it for the parity test. YAML parsed; not run in CI. * ci: set the repull workflow live flag in tests Names the checked-out copy in NEMAR_REPULL_WORKFLOW_LIVE so test/repull-workflow.test.ts compares it byte for byte; a declared path that is missing fails. The unit-pure job stays red until the twin pull request lands in nemarDatasets/.github, so this is held with it. YAML parsed; not run in CI. * test: say repull header names the deployed copy Comment only. The header said the unit-pure-shard job will, once the deploy lands, name the deployed copy. It now says the job does so, stays red until the deploy pull request is merged, and fails on any drift after. bun test test/repull-workflow.test.ts: 34 pass, 3 skip, 0 fail with the variable unset. * ci: harden the repull token and mask checks The validation step now checks the token and repull_id in the jq gate, on the event file, where a token with a trailing newline and an empty repull_id can no longer pass as they did through a shell variable. The mask step splits the token at carriage returns as well as line feeds. Comment fixes: the second step reads the token, canceled, and the script, not the runner header, never echoes a value. Checked with a hostile-event harness (each guard mutated and caught), actionlint, and test/repull-workflow.test.ts: 34 pass, 3 skip. The org copy follows in nemarDatasets/.github#148. * ci: refuse control characters in the payload The validation gate now refuses a control character in any payload field, read from the event file. An environment variable ends at a NUL, so the checks on the variables saw only what preceded it and step 2 passed a payload the CLI refused later. The test also covers the final newline that a regex dollar lets through, so the separate final-newline guard on the token and repull_id is gone. Checked with the review harness on jq 1.8.2, Apple jq 1.7.1 and Ubuntu 24.04's jq 1.7.1 (identical results), actionlint clean, and the existing tests: 34 pass, 3 skip. The org copy follows in nemarDatasets/.github#148. * test: pin the repull hardening and control check Adds cases to the mask test and the refusal test, each caught by its own mutant: a carriage return in the token is masked per line; a token with a final newline, an empty repull_id and a repull_id of 1 plus a newline are refused; a NUL in any field is refused, with the job environment cut at the NUL as a C string is. The refusal cases are collected, so a weakened check shows every case it lets through. 34 pass, 3 skip (37 pass against the org copy).
Brings dev's authenticated data host read (#1978, ADR 0114) and the 0.10.26-dev2 bump. The ADR index keeps 0113 in its list position and adds 0114 after it. src/index.ts keeps both early returns: automatic re-pull runs and the git credential helper print no notices. Tested: typecheck, Biome on src, the D1 migration check, the ADR index and 278 targeted tests pass. The full root run has two failures: the website parity test reads a stale local website checkout (9 of 9 pass against GitHub's main copy), and the --json test in admin-publish-list-skew-cli passes alone (18 of 18) and fails only under full-suite load.
chore: sync dev into the epic
* docs: finish the AGENTS.md pointers for re-pulls Replace the ADR 0111 entry with its final state. Add the hard rule that the four re-pull switches and caps are the owner's and that the CLI refuses a manual major on a mirror. Add the public row (mirror versions and the mirror flag) and the gated row (upstream freshness and the re-pull runbooks). The ADR 0093 entry already names the Worker's merge of an automatic re-pull, so it is unchanged. Docs only; test/docs-links.unit.test.ts passes against a fresh docs checkout. * docs: link the upstream design from the index The design-upstream-repull.md row in .context/README.md now says it is analysis, names ADR 0111 as the verdict and points at the three gated runbooks; its destination stays public. In the design record, a tag missing from the GitHub mirror is no longer described as retried without end: it is parked after 14 days, as ADR 0111's amendment of 2026-10-24 says and the retry engine does. Docs only; test/docs-links.unit.test.ts passes against a fresh docs checkout. * docs: record Phase 8 in ADR 0111 Append Amendment 2026-10-27 (#1914): the page paths, the mirror field contract, the order docs, website and backfill reach production, the workflow pairs, the finding that a re-pull's DOI may carry IsIdenticalTo as well as IsDerivedFrom (the public page says only "related identifier" until the first real record), what is still not verified, and the two items left open for the owner. Add a dated annotation to the header, the Decision section and decision 5, and rewrite the ADR 0111 index line to the built state. No decision text is changed. Docs only; test/adr-index.unit.test.ts passes. * docs: consolidate the re-pull changelog Turn the Unreleased block, which held only Phase 3's bullets, into one entry for the epic: Changed per phase (2 to 8), Production behavior changes, Deploy coupling, Owner steps after release and Known limits. Every earlier bullet's fact is kept, shorter; the Phase 3 bullet about a non-latest explicit tag no longer says the pinned copy is unbuilt. Docs only; test/changelog-format.unit.test.ts passes. * feat: type the mirror flag in the contract dataPlaneVersionListingSchema now declares the entry's mirror as an optional boolean that may be null, and still passes every other key through. A listing whose mirror is anything else fails the CLI's read of it with the existing "did not match the expected shape" sentence, and a backend that predates the flag (no key) still parses. test/data-plane-mirror-contract.test.ts serves the real landing route over real SQLite and reads it with the CLI's reader; a second loopback server serves the real payload with one value changed for the failing cases. Eight one-line mutations of the schema and of mirrorFlagOf each fail at least one test. Tested: the new file (8 pass), that file with http-download and the two backend mirror-flag suites (50 pass), typecheck, lint. * docs: fix the re-created tag claim The changelog and ADR 0111 said the dry-run plan compares trees and so sees a tag re-created upstream under the same name. It does not: a plan to a tag equal to the mirrored tag is refused as nothing-to-pull before any tree is compared (src/lib/repull/preflight.ts, lines 157 and 158). The changelog now says nothing detects it, and the ADR gets a dated annotation. The amendment's note on annotations no longer counts them. Docs only; the changelog and ADR index tests pass. * docs: complete the not-yet-verified list The amendment's list held only some of what the earlier amendments say only the canary or a production run can check. It now holds all of it, grouped by what shows it: the canary and the first copy, the first two re-pulls, the first unattended run, the first Worker merge, and the release with its first weeks. That adds the App's login, id and type, the leased push and the lock calls, the 204 and the runner's masking, the second release pull request and the N.0.1 tag, and the BIDS unstable state. The ADR index line and the changelog now describe the same scope. Every item was read in the amendment that records it. Docs only; the changelog and ADR index tests pass. * docs: correct the amendment's citations The amendment cited two backend tests for "metadata.json is unchanged", but neither reads that file. It now cites the mapping in backend/src/services/data-router.ts and test/data-route.unit.test.ts, which pins the four keys of each extensions.nemar.versions entry, and says the recorded payload fixtures are in the website repository. Decision 5's annotation says the chip is on the website's staging branch only. The sentence about the two docs pull requests keeps the dated fact and drops the status and the health-check procedure; the changelog gains one deploy-coupling line for the same fact. Docs only; the changelog and ADR index tests pass. * docs: correct two overstated claims The changelog said the plan command prints counts and never a path, but it also prints "Plan file: <path>" (src/lib/repull/render.ts, line 106); it now says it prints that file's location and nothing of the dataset. The changelog and the ADR index said the four switches are absent from the Worker's configuration. The test pins the wrangler configuration file and not Worker secrets, so both now say "wrangler configuration", and the changelog adds that a secret of the same name would turn the path on and that /admin/repulls/switches reports it. Docs only; the changelog and ADR index tests pass. * docs: restore dropped changelog facts The Phase 3 bullets were condensed past what the pull request body said was kept. This restores the audit row the dispatch writes, the reset of the clone to the tag, the lag on a latest tag OpenNeuro cannot name, that git reset --soft drops .github/ until finalize deploys it again, the warning when the guard cannot fire, what the preflight does when its comparison is incomplete, the manual restart of a parked annex conflict, the staging clean-up details, and how the snapshot entry is read and written. It also names the epic cleanup (#1976) where the text describes its effects (the canary script, the plan handoff, the origin filter, the migration number) and adds one bullet for what the two dev syncs (#1979, #1981) carry: the App rename and the authenticated data host. Docs only; the changelog format test passes. * docs: point the DOI relation at the amendment Decision 2, the Phase 7c gate G4 and the design record (the release path and gate G4) state that a re-pull's DOI carries IsDerivedFrom, as a fact or as the gate's pass criterion. The Phase 8 amendment records that a second source names the same DOI as IsIdenticalTo, so which relation the first record carries is not known until G4 runs. Each of the four places gets one dated annotation pointing at that section; no other text changes. Docs only; the ADR index test passes. * fix: say only a re-pull pins the copy The import's warning for an explicit tag that is not OpenNeuro's latest, and the doc comment above it, said ADR 0111 decision 8 is not built. It is built for a re-pull's copy, which pins the S3 version; the import's copy still takes the object currently at each upstream path (its manifest items carry a bucket and a key and no version, as parseS3Url returns them). Both now say only a re-pull's copy pins the object version. The ADR gets a dated annotation on the Phase 3 amendment's sentence. test/import-prepare-pin.test.ts asserts the new wording; with the old string restored it fails. Tested: the 16 test files that import src/lib/import-openneuro.ts and the tag-option test (386 pass), typecheck and lint. * docs: fix the data plane contract comments The comment on the version listing said null is for an N.0.0 whose tag is unknown, which read as any dataset's N.0.0. mirrorFlagOf sends null only for an N.0.0 of an OpenNeuro dataset and false for every other version, a NEMAR dataset's N.0.0 included (shared/source-snapshot.ts, line 267 and the lines after it). The file header said passthrough on the entry is deliberate with no exception; it now names the version listing's mirror field as the one typed exception. Comments only; typecheck passes and the contract test passes (8). * docs: spell out abbreviations on first use The ADR 0111 amendment and the changelog's Unreleased block used DOI, API, S3, BIDS, CLI, ADR and UTC without defining them. Each is now spelled out once, at its first use in that text (the changelog's older entries come later in the file, and the ADR never spells any of them out). The amendment's DOI section heading carries the full name, so the four annotations that quote it now quote the new heading, and the amendment no longer quotes a code comment that held BIDS. Docs only; the ADR index, changelog format and docs links tests pass. * fix: correct the copy-pinning claim Recovery also copies a recorded version (pinned sources from .log.rmet, copySourceArgument in src/lib/content-recovery.ts), so 'only a re-pull's copy pins' was false. The import warning and its CHANGELOG line now say a re-pull's copy pins the object version. Tested: typecheck, Biome, changelog-format and adr-index tests pass. * fix: finish dropping 'only' from the pin claim The import's doc comment and its test still said only a re-pull's copy pins the object version. The test now asserts the new wording, and that the old phrase and 'is not built' are absent. Tested: typecheck, Biome, the 28 import-related test files, the ADR index and CHANGELOG format tests: 789 pass, 1 skip, 0 fail. * docs: scope the re-created tag claim The previous fix said nothing detects a tag re-created upstream under the same name. Two checks do part of it. A plan to the mirrored tag is refused as nothing-to-pull before any tree of upstream is cloned or compared (preflight.ts lines 157 and 158, plan.ts lines 278 to 294), so a mirror's recorded tag that upstream re-creates is not detected. A target tag re-created after a plan has read it is caught: execute refuses with upstream-tag-moved before the copy, the registration and the pull request (advance.ts lines 146 to 176). The ADR annotation and the changelog limit now say exactly that. Docs only; the ADR index and changelog format tests pass. * docs: add the G4 and plan handoff checks The amendment's list of what only a first run can show lacked two items. Gate G4's reading, that the new major's DOI resolves and the previous version still serves, is in the first-two-re-pulls group (ADR 0111, Phase 7c amendment: the owner reads both before turning a switch on). The epic cleanup's own test plan (#1976) leaves the first automatic run through the plan handoff and the 57-word dispatch list for production; it is in the first-unattended-run group, with the two annotations of 2026-10-26 that describe the change. The ADR index line and the changelog name groups, not items, so their scope sentences still match the list. Docs only; tests pass. * docs: spell out more abbreviations The amendment and the changelog's Unreleased block now spell out CI, AWS and JSON (amendment) and CDN, URL and JSON (changelog) at their first use; the ADR never defines them and the changelog's older entries come after the block. The changelog's "screened SHA" now says "screened commit", so no SHA remains to define. Docs only; the ADR index and changelog format tests pass. * docs: say null is for an on dataset The changelog and the ADR index line said the mirror flag is null for an N.0.0 whose tag is unknown, which reads as any dataset's N.0.0. mirrorFlagOf sends null only for an N.0.0 of an on dataset and false for every other version (shared/source-snapshot.ts, line 267 and the lines after it). Both now say so, as the contract comment and the ADR amendment already do. Docs only; the ADR index and changelog format tests pass.
neuromechanist
added a commit
that referenced
this pull request
Oct 27, 2026
ADR 0111's Phase 2 amendment still said only a version of the form N.N.N is a candidate. A dated annotation under it says a row spelled vN.N.N is a candidate too. The #1983 review amendment said earlier text is unchanged; it now says the decision text is unchanged and earlier text is annotated where the amendment corrects it. Append only, bar that one sentence. Tested: test/adr-index.unit.test.ts.
* docs: fix the s3_lock 403 comments A 403 on PutObjectRetention counts as locked only when the retention read-back shows the lock this route sets. Comment text only; tested: not applicable. * docs: say a secret turns the switches on The auto re-pull switches are read from the Worker environment, so a secret of the same name enables them too. Comment text only; tested: not applicable. * feat: ask when the scheduler waits on gate G4 With the open switch on and the scheduler's last tick concluded waiting-for-manual-run, the weekly report now asks for attention: a switch turned on early otherwise changes nothing and says nothing. Quiet with the switch off. Tested: import-weekly-repull-section (81 pass); both the removal and the unconditional form of the check fail the new tests. * fix: ignore the OpenNeuro URL override in prod snapshotGraphqlUrl returns OpenNeuro's own endpoint in production and in an unknown environment (fail-closed), and honors OPENNEURO_GRAPHQL_URL elsewhere. A loopback http address is honored everywhere, as githubApiBase does in the CLI, so the suites that run the production-only scheduler against a local stand-in stay hermetic. Tested: openneuro-snapshots (34 pass) with a routed fetch that never reaches a network; four mutations each fail the new tests; 337 pass across the nine dependent files. * fix: mirroredTagOf reads vN.N.N rows too D1 stores a version as 1.0.0 or v1.0.0, and mirroredTagOf matched only the bare spelling, so a mirror whose rows carry the v read as unpublished and was never compared or dispatched. It now accepts one leading v, orders by number across both spellings, reads the rows of one version together (a disagreement is unknown, never one picked) and returns the version bare. The staleness report dates a version by its earliest row in either spelling, and the plan's from-tag no longer strips the v itself. Tested: source-snapshot and upstream-staleness unit tests, every consumer's suite (12 files, 462 pass) and the plan, supersede and upstream-status CLI suites (86 pass); the v-only test fails with the old regex. * refactor: drop the unused SOURCE_VERSION_BASES Nothing in src, shared, backend or the tests read it or its type (git grep finds only the definition); migration 0104's CHECK is the list of the three words, and the parser's types name them directly. Tested: source-snapshot unit tests (48 pass); typecheck in the hook. * ci: install and name the test tools unit-pure-shard, deploy-backend's test-gate and the nightly run set up Python 3.12 and uv, as scrub-tools-shard does: without uv the EDF reader cases in identifier-scrub and identifier-dates skipped in unit-pure (3 skips in shard 4 of run 40537526547) and reported green. Each of those jobs, and integration-dev, gets a "Tool versions" step that names git, git-annex, uv (where needed) and the aws CLI, which the runner image provides and no step installs, so a missing tool fails that step by name. Tested: ci-tier-routing, workflow-yaml and the other suites that read these workflows pass; the three files parse. * test: fail on a missing tool when CI is set toolOrFail threw only under NEMAR_REQUIRE_SCRUB_TOOLS=1, which only the scrub-tools job sets, so in unit-pure, integration-dev, the deploy gate and the nightly run a missing aws, uv or git-annex skipped about 45 describe blocks across 18 files and reported green. It now also throws wherever CI is set, read by gitAnnexGate's rule (exported as ciIsSet), and the error says which of the two made the tool required. Tested: test/scrub/require-tools.test.ts passes (8 tests) with new cases for CI=true and for CI set to false, 0 or empty; with the CI clause removed the CI=true case fails. * docs: say why the two version patterns differ NEMAR_VERSION_RE (repull-state) and the stored-row pattern in source-snapshot now accept different spellings, so they stay two constants. Each says why: a re-pull record and its requests carry a bare N.N.N, which the record's statements prefix with the v themselves to find a row in either spelling, while dataset_versions rows may carry the v. Comments only. Tested: Biome; typecheck in the hook. * docs: qualify plan as read-only plan --automatic-dispatch reports started (and refused or failed) to the Worker, which stores it. Help text, the plan command description, the CHANGELOG bullet and an ADR 0111 annotation say so. Tested: repull-command-text (13 pass). * refactor: write the trailers from one builder The re-pull commit (synthesize), N.0.0's pull request body, N.0.1's body and its commit message now take their trailer lines from repullTrailerLines and the new repullPatchTrailerLine in shared/repull-squash.ts instead of their own templates (#1972). Bytes are unchanged. Tests pin each writer's lines to the builder's output; mutating any one writer fails them. Tested: repull-trailers.unit (13), command-text, patch, patch-cli, resynthesize, admin-pr-reviews-repull, worker-merge (160 pass), execute-prepare and execute-cli (74 pass). * fix: approve --merge exits 3 on a held claim A claim to merge that is held (a lost answer, GitHub did not merge) now exits with the waiting code, as repull merge does, instead of 1. A refusal with no claim held still exits 1. Tested: admin-pr-reviews-repull (14 pass); removing the branch fails the two exit-3 tests and exiting 3 always fails the exit-1 control. * test: run the merge-gate CLI suites in unit-pure Nine suites reached integration-dev only because a header comment named the API address variable that scripts/ci/unit-pure-files.sh greps for: repull-merge, -gates, -patch, -patch-resolutions, -release, -abandon, -supersede, -merge-bids-override and admin-pr-reviews-repull. Only the header comment changes: it no longer names the variable, and its CI TIER claim says unit-pure, which test/ci-tier-routing.unit.test.ts holds against the classifier. Tested: the nine suites pass with no TEST_API_URL in the environment, no --timeout and no retry (147 pass, 0 fail, 278 s), with every proxy variable pointed at a local egress spy that logged no request; the same spy logged bun fetch, the aws CLI and git reaching outside hosts. ci-tier-routing passes (73 tests); the classifier lists 760 files. * fix: name abandon for a record without counts A record that does not say how many corrections and conflicts its plan has stays released and blocks the dataset's next re-pull; resume's message and help now name nemar admin repull abandon as the way out. Tested: repull-patch-cli (21 pass); the old message fails the new test, which also runs abandon and sees patch_declined. * test: bound workerd hooks and spawn loops Four Miniflare suites booted workerd and applied every migration in a beforeAll under the default five seconds: their beforeAll now has 60 s and their afterAll 30 s, the bounds site-binding-identity, private-site-rpc-entry and email-send-binding give the same hooks. dataset-release-mirror-major runs the CLI from source up to four times a test, each run bounded at 30 s by its own timeout; the file now has 60 s, git-credential's bound for the same spawn. repull-workflow's seven tests that run step scripts in a loop (up to 31 bash runs) get 20 s, the bound publication-review-workflow gives its loops. Tested: the four Miniflare suites (10 pass) and the two test/ suites (40 pass, 3 skips: the deployed copy, accepted) pass. * test: end the held copy on release, not a timer "killed while a copy hangs" held the killed run's CopyObject for a fixed 8 s. The CLI's aws child outlives the SIGKILL and keeps its connection open, so the hold never saw its client go and always ran out its timer; the test then sat out the rest of it (4.6 s locally). The S3 stand-in's hold now also ends on releaseHolds(), and the test holds with a 120 s backstop, ends the hold after the next run has completed (in a finally, so a failure cannot leave it held), and polls for its observable end with the existing 15 s deadline. Tested: the test passes in 15.0 s of run time against 19.2 to 20.0 s before; with releaseHolds() made a no-op it fails at the settle check. * docs: mark the re-pull ADR amendments as built ADRs 0006, 0060, 0089 and 0091 each carried an amendment saying the re-pull was designed in ADR 0111 and not yet built. Each gets a dated annotation saying epic #1046 built it, and which ADR 0111 amendment records how. Append-only; no decision text changed. Tested: test/adr-index.unit.test.ts. * docs: annotate stale ADR 0111 statements Seven earlier statements of ADR 0111 still said the workflow pair was held or not deployed, a route was owner-or-admin only, or an item was open that the Phase 2 amendment closed. Each gets a dated annotation under it, as the record's own rule requires. Append-only; the end of the file is untouched. Tested: test/adr-index.unit.test.ts. * test: run mirror-major against the real routes The spawned cases of dataset-release-mirror-major ran the CLI against a Bun.serve() that answered GET /datasets/:id and /versions with rows written in the test, so the source and version the refusal reads were a copy of the Worker's answer, not the answer. They now run against the real datasets router over bun:sqlite with every migration applied, behind its real auth (makeRepullApp, as repull-plan-cli does), with the rows seeded in SQLite and GitHub, which the versions route reads the description from, as the github-standin. /notices is answered as the re-pull suites answer it. Tested: 6 pass. With the detail route's `source` removed from its answer (a scratch mutation) the two xx cases fail, which the canned answer could not show. Under an egress spy that logs any request to an outside host, nothing reached one. * test: refuse remote git calls in a CLI shim dataset-release-mirror-major's git shim refused only `clone`, and the update case's working tree has `https://github.com/nemarDatasets/<id>` as its origin. A mutation that let the CLI past the mirror refusal made the test create a branch, commit and run a real `git push` to GitHub with the machine's credential helper; it failed only because nemarDatasets/xx090123 does not exist today. The shim now refuses clone, fetch, pull, push and ls-remote, and still records each call. Tested: 6 pass; under the same mutation the push is refused by the shim ("Failed to push branch") and nothing reaches GitHub. * test: run prepareImport against the real routes import-prepare-pin's backend was a Bun.serve() that answered the import create with a hand-written 409 and the version list with a hand-written array, so the release state the upstream-moved guard reads never came from the Worker. It is now the real admin and datasets routers over bun:sqlite with every migration applied, behind their real auth (makeRepullFullApp): the import create answers 409 because the database holds on999990, and each case sets its release state with a version row. GitHub, which the version list reads the description from, is the github-standin. Tested: 5 pass. Scratch mutations of the real routes are caught: a version list that drops its rows fails the released case, and an import create that does not refuse an existing dataset fails all four prepare cases. No request reached an outside host under an egress spy. * docs: correct the re-pull merge rules AGENTS.md said an administrator merges by three paths only; it is NEMAR's tools that do, and the GitHub merge button is not bound. AGENTS.md and ADR 0093 (dated annotations) said the Worker merges while AUTO_REPULL_MERGE_ENABLED is on; it merges only in production with AUTO_REPULL_ENABLED and AUTO_REPULL_MERGE_ENABLED both exactly 1 (autoRepullMergeEnabled). Tested: test/adr-index.unit.test.ts. * docs: say the re-pull workflow copy is merged The header of repull-workflow.test.ts still said the org copy was held until the epic ships. It merged as nemarDatasets/.github#148. Comment text only; the authoring copy is not changed. Tested: repull-workflow (34 pass, 3 skip). * test: restore the exemplar test's no-mocks note This epic replaced exemplar-endpoint's header sentence that tied the happy path to the no-mocks policy. The GitHub stand-in it added is a loopback server the route's own GitHub client calls (createRepository is the happy path's only GitHub request), in the style of repull-github-standin, so it stays; the header says so again and names the policy. Tested: backend/test/exemplar-endpoint.test.ts passes (20 tests). * test: pin the Worker merge's status and order Nothing ran workerMergeRepull on an automatic record that is not at gates_clear (patch_* included), reconcileWorkerClaim on a claim held on such a record, or the credential read that comes before the claim. New tests, in the worker-merge suite's harness (bun:sqlite with every migration behind realD1, the repull GitHub stand-in): - every status but gates_clear, a machine-clean world otherwise: workerMergeRepull skips, reads nothing from GitHub, and writes no claim and no row (16 tests); - the same statuses holding a claim: reconcileWorkerClaim skips and reads nothing (16 tests; pr_open is the case only the status term refuses, the others also lack a merge commit); - the credential goes away after the facts' reads and comes back for the claim's own read: held pr-unreadable, no claim, no audit row, nothing sent. Tested: the suite passes (114 tests). Scratch mutations, one at a time: the status term dropped from workerMergeRepull fails 16 tests, from reconcileWorkerClaim 8; the credential read moved after the claim fails the order test, and so does a catch that carries on. * refactor: name the dataset checks in shared The BIDS validation and version-check names, and the four legacy inline repositories, move to shared/dataset-checks.ts so the CLI's re-pull gates can read the check the ruleset requires; deriveContexts reads them there and branch-protection re-exports the legacy set. Outputs are unchanged. Tested: branch-ruleset and the other GitHub module suites (part of the 28-file hermetic run, 1259 pass); typecheck in the hook. * refactor: share the BIDS override rule shared/repull-bids-override.ts holds the rule an administrator's merge over a failed BIDS validation rests on: checkFactOf reads the App's latest run of a check (moved from the Worker's reader of the two checks), bidsOverrideFault decides the facts (an administrator's record, unstable and not blocked, BIDS failed, version-check passed), and othersNotPassing and bidsOnlyFault add that no other check run or commit status fails. The Worker's claim now asks bidsOverrideFault, with its refusal codes and words unchanged. Tested: new unit test of the rule (13 pass); the Worker's override, facts, merge-claim and scan suites (part of the 28-file hermetic run, 1259 pass); typecheck in the hook. * fix: resume gates a head failing BIDS alone A failed BIDS validation that no rule requires makes GitHub report unstable, and resume recorded the gates only on clean, so merge --bids-failure-reason, taken only from gates_clear, could not be reached. On a record an administrator opened, resume now also records the gates when GitHub reports unstable and BIDS validation is the one check that fails (bidsOnlyFault over every check run and commit status of the head, read with the administrator's token); the result and the ready line say to merge with the reason. The merge gate refuses an override where another check or status does not pass, before anything is written; the Worker's claim still reads the BIDS and version-check facts itself. An automatic record, a merge without the reason and pr-reviews still require clean. The GitHub stand-in answers a commit's combined status. Tested: BIDS override CLI suite (28 pass, 10 new: BIDS-only unstable reaches gates_clear and merges with the reason; another check, a status, a running check, a failed version-check or a passed BIDS run are not gated; clean is unchanged; an automatic record is not gated; the merge without the reason and the merge over another failing check refuse); machine-clean unit test (58 pass); 13 other CLI suites (512 pass). The BIDS-only test fails with the resume change reverted. * docs: amend ADR 0111 for the #1983 review A dated amendment at the end of the record, nothing above it changed: the BIDS override is reached through resume (what was wrong, the rule in shared/repull-bids-override.ts, the merge gate's half, what still requires clean, what only GitHub can show), and the mirrored tag reads both spellings of a version (the rows of one version read together, a disagreement unknown; the backfill's bare-only rows left open). Tested: documentation only. * style: American spelling in a BIDS-only message The state word shown when GitHub's mergeable state cannot be printed reads "unrecognized". Tested: Biome and typecheck in the hook. * ci: install the German locale for the git cases Two pure suites run git in German to show that an outcome is read from a status and not from git's message. The runner has no de_DE.UTF-8 locale, so git spoke English there and those cases asserted nothing. unit-pure-shard, deploy-backend's test-gate and the nightly run now install language-pack-de-base after git-annex, and "Tool versions" fails by name when de_DE.utf8 is not listed. Tested in an ubuntu:24.04 container with git 2.56.0 from the git-core PPA (the runner's git): before the pack git answered an unknown command in English under LC_ALL=de_DE.UTF-8; after it (8 s to install) in German. The archive's git 2.43 ships no catalog of its own and speaks German only with the pack. * test: fail German cases where git is English The German cases in import-annex-uuid-preflight and import-upstream-moved-guard set LC_ALL=de_DE.UTF-8 and asserted on the outcome, which passes on English where the locale or git's German catalog is missing. Their two copies of inGerman become one helper (test/helpers/in-german.ts) that first asks git something whose answer differs from the C locale's: where git is not German it throws with CI set, and elsewhere runs the case in English after a warning, as a missing tool skips. Tested: both suites pass (34 pass, 1 skip: the root-only case); git speaks German here. With the locale replaced by one that does not exist (a scratch mutation) the two German cases fail with CI=true and pass with a warning without it. * fix: check the shapes a re-pull reads and trusts The bucket and region remote.log names, and the dataset ids, tags and versions a plan states, become a host, a ref, a branch name and the write guard's one destination. Each is now checked where it is read (new src/lib/repull/shapes.ts): the planner refuses a malformed bucket or region, execute and the release refuse it as nemar-s3-invalid, the annex-uuid read and the bucket listing build no host from one, and planFacts refuses a malformed scalar as plan-schema. The words name the field and the shape, never the value. Tested: repull-shapes.unit (18), the planner and release entry points, 13 mutations each fail a test; the whole re-pull family, 676 pass in 36 files. * test: pin the production override fence Production ignores a non-loopback OPENNEURO_GRAPHQL_URL of any protocol and honors only an http loopback one. A matrix of six protocols against loopback and other hosts pins snapshotGraphqlUrl, https on a loopback host is refused, and the reader posts to openneuro.org (routed fetch, nothing sent) for https, ws and ftp on the stand-in's port and for http on a host that is not loopback. Tested: openneuro-snapshots (37 pass); removing the protocol check, allowing https and dropping the host check each fail the new tests. * fix: backfill examines vN.N.N rows The backfill took only rows spelled N.N.N, so a v-spelled row from before migration 0104 stayed never examined, and the staleness report, which now reads both spellings, sent it to a pass that could not reach it. A candidate is now read as mirroredTagOf reads it: one lowercase v stripped (bareNemarVersion, and the same in SQL), then N.N.N. The ref is the canonical tag, the rows of one version in both spellings are read once and each recorded from that read, the write stays on the row's own spelling, and the cursor carries it (CURSOR_RE takes the v). vv1.0.0, V1.0.0 and other shapes are still never candidates. Tested: new Miniflare D1 test (4 pass: a v-only row examined and its source_version written; both spellings read once; the v cursor pages to the end; odd spellings skipped); route test (35 pass, the v test replaced by its new rule); backfill, status and snapshot suites (13 files, 395 pass, 6 skipped by design, 0 fail). * fix: shape-check the commit ids of a plan planFacts now refuses an upstream, main or git-annex commit in a plan that is not a full 40-digit lowercase hex id (plan-schema, naming the field and never the value). A commit id ends up as an argument of git fetch, checkout, commit-tree and ls-remote. New isCommitId in shapes.ts uses the Worker's SHA_RE. Tested: repull-shapes.unit (22 pass); six mutations each fail a test; 182 pass across the 12 re-pull unit files. * docs: ADR 0111 notes the backfill reads v rows The review amendment at the end of the record said the backfill still took only N.N.N rows and left that open; the backfill now examines both spellings, so the bullet says so, and that the Phase 2 amendment's "Only a version of the form N.N.N is a candidate" no longer holds. Only the amendment's own last bullets change. Tested: documentation only. * test: keep the day-cap suites in one UTC day The merge cap and the open cap count a fixed UTC day with date('now') inside their statements, and no function that claims takes a clock: workerMergeRepull(env, row), claimOpenDispatch(env, candidate) and the claim route read D1's own. So a test that makes several claims and expects one day (merge-claim's "the day is the UTC day", dispatch's "yesterday's dispatches do not count", worker-merge's "a cap of 1 and two clean rows") fails when it runs across 00:00 UTC. With no clock to fix, each of the three suites' beforeEach now awaits insideOneUtcDay(db): when less than 2 s is left of the UTC day on the database's clock, it polls until the day turns, with a deadline of a second past the turn. Every test in them takes well under a second. Tested: the three suites pass (222 tests); the guard returns at once away from midnight, and SQLite's now agreed with Date.now() to the ms. * test: pin the nemar-s3-invalid guards advance.ts: a working clone whose remote.log names the bucket as a path is refused by the real executeRepull before the copy, with nothing uploaded, pushed or opened and the record prepared with [copy:nemar-s3-invalid]. run.ts: a plan forged onto a git-annex commit with such a remote.log, digested again with its handoff, is refused at prepare by the automatic execute (record planned, [prepare:nemar-s3-invalid], dispatch prepare-failed, no S3 or GitHub write). Tested: removing either guard fails its test; both pass with the guards in place. * test: name the IAM collaborator precondition Three iam-removal cases need test-user to be a collaborator of nm099999 (its dataset_collaborators row and its user_s3_permissions row, seeded by scripts/seed-dev-db.sql). The reset of nm099999 deletes both and restores neither, so after any reset the cases failed with the route's 403, which reads as an authorization bug. The only routes that write the row, invite and access-request approve, go through grantCollaborator, which first adds test-user's GitHub login as a collaborator on GitHub, so no test may call them. Each of the three cases now reads GET /datasets/nm099999/collaborators as test-admin first and fails with "Missing precondition: test-user is not a collaborator of nm099999 ..." and how to re-seed it; an answer that is not 200 fails as unread and is asked again by the next case. Tested against the dev backend, whose nm099999 has no collaborator row: the three cases fail with that message; with the check removed they fail as before, 403 where 200 was expected. * docs: list the review fixes in the CHANGELOG Four bullets under Production behavior changes, each on its own lines: the G4 attention reason in the Monday report, production ignoring OPENNEURO_GRAPHQL_URL unless it is a loopback http URL, approve --merge exiting 3 on a held claim, and the shape refusals for a bucket, region, dataset id, tag, version and commit id. Docs only. * docs: record the live GitHub check in ADR 0111 The review amendment's stand-in bullet becomes what was read on 2026-10-27, read-only, on nemarDatasets/on004362 pull request #1 at c06fa1cf: main has no branch protection (404) and only the tag ruleset; the pull request reads unstable with "NEMAR PR Review", not required, as its one failing check; the check names and the fields of the check-runs and combined-status answers are the ones the rule reads, and the rule run on those answers names the review as what fails. Still unverified: a live failed BIDS run on an unprotected repository reading unstable. Tested: documentation only; the rule was run on the saved live answers. * ci: refresh the unit-pure shard timings Regenerated as test.yml's note above unit-pure-shard says: the unit-pure-shard-* artifacts of the two green runs at b78f11c (push 40537526547 and pull_request 40537849610), merged per run with the documented jq, then averaged per file across the two runs, as the note asks. The committed file timed 644 of the 751 pure files; this one times all 751 (1,495 s of test time in all). The nine merge-gate suites that now route to unit-pure ran in integration-dev in those runs, so they are not timed yet and bun puts most of them on the last shard. A dry run of bun's partition (--shard i/6 -t '^never$') with each file's measured time, the nine at their integration-dev times, projects the slowest shard at 472 s with this file and 737 s with the old one. The next refresh, from the first green run of the fix pull request, times the nine. Tested: the file parses as version 1 with 751 numeric entries, and bun partitions the 760 listed files with it. * test: name the git calls the shim refuses * fix: re-read other checks before the claim The gate read that nothing but BIDS validation fails once, before the review was read again, the confirmation and the claim, and the merge's last look re-checks only that GitHub still says unstable, so a check that started failing in between was merged over. sendUnderLock now reads it again, under the lock and before the claim, through the same helper step 7 uses, and a refusal claims nothing. The ordinary merge reads no check, as before. Tested: BIDS override CLI suite (a check that starts failing after the gate's read is refused with nothing claimed; the ordinary merge of a clean head reads no check); the test fails with the re-check removed. * fix: approve --merge marks its exit 3 reported approve --merge exits 3 while a claim to merge is held and when GitHub merged the pull request and the record does not hold it yet, without markReportedExit, so the exit hook asked for a debug log under a correct answer. Both paths mark the exit reported, as repull merge does; a refusal that exits 1 is unchanged. Tested: pr-reviews re-pull CLI suite (the three exit-3 cases print no request for a debug log). * fix: resume at the gates names the BIDS override A second resume on a record gated over a failed BIDS validation returned a plain ready, so it printed the ordinary merge command, which the gate refuses while GitHub reports unstable. At gates_clear, on a record an administrator opened, resume now reads GitHub's state and, while it is unstable for BIDS validation alone (the rule its gates were recorded by), its ready line names --bids-failure-reason. resume --json carries the flag as bids_failure, true or false. Tested: BIDS override CLI suite (the second resume's line and JSON name the override while the validation fails, and the ordinary merge once GitHub reports clean); the gates CLI suite. * docs: annotate the v-row candidate sentence ADR 0111's Phase 2 amendment still said only a version of the form N.N.N is a candidate. A dated annotation under it says a row spelled vN.N.N is a candidate too. The #1983 review amendment said earlier text is unchanged; it now says the decision text is unchanged and earlier text is annotated where the amendment corrects it. Append only, bar that one sentence. Tested: test/adr-index.unit.test.ts. * docs: make the AGENTS.md merge rules agree The paragraph on ADR 0093 said NEMAR's tools merge by three paths only, then said the Worker merges a machine-clean automatic re-pull. It now says an administrator merges through NEMAR's tools by three paths only, the Worker makes the one other merge, and the GitHub merge button is bound by none of it. Docs only. * docs: say plan may report its dispatch The header comment of admin-repull.ts said plan writes nothing to D1 or the API, and its help said a dry run, always. Both now carry the exception the help already named further down: plan --automatic-dispatch reports its dispatch to the Worker. Comment and help text only. Tested: repull-command-text (13 pass). * docs: fix the BIDS override help sentence The merge help said no check but BIDS validation fails or is still running, and that resume records the gates of such a head. resume and the Worker's claim need BIDS validation to have completed with failure and every other check to pass, and resume waits while a check runs. The sentence now says so. Comment text in the help only; no code changed. Tested: repull-command-text (13 pass). * docs: note staleness reads v-spelled rows A CHANGELOG bullet under the Unreleased production behavior changes: the staleness report and the backfill now read version rows spelled vN.N.N, which the report used to ignore, so upstream-backfill --execute writes more rows. On its own lines. Docs only. * ci: require test tools by variable, not CI toolOrFail and inGerman threw wherever CI was set. nightly-tests.yml and bump-validator.yml run dev's tests with their files on main, which install neither uv nor the German locale, so the nightly would have gone red and filed an issue once this reached dev. Both now fail only under NEMAR_REQUIRE_SCRUB_TOOLS=1, set at job level where every tool is installed or named: test.yml's unit-pure-shard (git-annex, the German locale, Python and uv, the runner's aws), integration-dev (git-annex and aws; its suites need nothing else) and scrub-tools-shard (moved from its test step), and deploy-backend's test-gate (as unit-pure-shard). nightly and bump-validator do not set it. gitAnnexGate is back to its own CI rule, unexported. Tested: require-tools.test.ts passes (8), now pinning that CI=true alone is a clean skip; with CI keyed back in, those two cases fail. With the locale replaced by one that does not exist, the German cases fail under the variable and pass with a warning under CI=true alone. * ci: give the validator bump git-annex bump-validator.yml's bump path runs a bare `bun test` over the whole tree with neither git-annex nor the backend's dependencies. Since #1978 the data-host suites refuse to skip a missing git-annex on a CI runner, so the path has been red; and without backend/node_modules no backend suite can import hono. It now installs git-annex (with the 10-minute limit test.yml's jobs use) and the backend's dependencies from their lockfile, both behind the skip guard every later step has. The variable that requires uv and the German locale is not set here: this job runs from the copy of the file on main. Tested: bump-validator-workflow.test.ts and workflow-yaml.test.ts pass (34). With git-annex off PATH and CI=true, data-host-cli and data-host-e2e fail ("refusing to skip"); with it, they pass (27). * test: shim refuses every remote git call dataset-release-mirror-major's git shim matched the command in $1 only, so `git -c k=v push`, `git -C dir push`, `git --git-dir=x fetch`, `git annex sync` and `git remote update` reached the real git, and cli() handed the CLI the test process's GH_TOKEN and GITHUB_TOKEN. The shim (gitShim) now finds the command past git's own options, the ones that take a value skipping it too, and refuses with exit 128, before the real git runs: clone, fetch, pull, push, ls-remote, archive, request-pull, send-pack, fetch-pack, http-fetch, http-push, svn, p4 and every submodule command; remote update, prune, show and set-head; every annex command but annex version. cli() drops GH_TOKEN and GITHUB_TOKEN. The header says exactly that, and a test holds it to the two lists. New tests, with a recorder in place of the real git: 18 such calls are refused and never reach it; the six calls the CLI makes here are still handed on; a token in the test process does not reach the CLI. Tested: 27 pass. With the old $1 matching back, 13 of the 18 reach the recorder and fail; with the two tokens no longer dropped, the token test fails. * test: refuse the override on a failed check read Nothing failed the two reads the BIDS-only override rests on (src/lib/repull/bids-only.ts: every check run of the head, and its combined status), the merge gate's unreadable branch, or fetchDatasetRepoJson itself. The GitHub stand-in gains readFaults, an error-path fixture that answers one check-runs or status read with an HTTP status. Through the real CLI against the re-pull world, each read answering 500 now refuses `merge --bids-failure-reason` with the github stop and the read's own words, before anything is written, and keeps resume from recording the gates of a BIDS-only head (4 tests). fetchDatasetRepoJson is pinned on an HTTP error with and without a message, a 200 that is not JSON, and no answer at all (5 tests). Tested: the three suites pass (126). Scratch mutations, one at a time: a failed check-runs read taken as no runs fails its 2 tests; a failed status read taken as all success merges and gates, and fails its 2; the merge gate taking unreadable as BIDS-only merges, and fails 2; fetchDatasetRepoJson keeping an error's body fails 2. * test: keep the open-cap suites in one UTC day upstream-repull-advance (usedToday, the resume dispatches that count against the open cap) and upstream-repull-scheduler ("a second tick the same day is cap-reached") count the same UTC day on the database's clock as the three suites already guarded. The advance tick takes a `now`, but it decides the tick's windows; the cap's day is date('now') inside the statement. Both suites' beforeEach now await insideOneUtcDay(db), and the helper names its five users. Tested: both suites pass (175). With the guard made to throw, all 175 fail, so it runs before every test of both. * test: read the annex-uuid host through a spy repull-shapes' happy path replaced fetch and served a canned 200, so the read's success never met a real request. The read's URL is the real S3 host by design (no endpoint override), so the code cannot be pointed at a stand-in; a proxy is what it really calls instead. The happy path and the no-request cases now run the real fetch with the egress spy (test/helpers/egress-spy.ts) as the process's proxy: a valid pair sends one CONNECT to nemar.s3.us-east-2.amazonaws.com:443 and, refused, reads as an error; a bucket or region that could name another host sends nothing. The exact object URL is pinned on a 404 (absent) and a 403 (forbidden) answered by the remaining fetch fixture, error paths only. No test serves a canned success. Tested: 23 pass. Scratch mutations: without the bucket and region guard the no-request test fails; a path-style URL fails the host and URL tests; dropping the prefix fails the URL test. * test: name each missing IAM fixture row The precondition read only test-user's dataset_collaborators row, but the two upload routes also need its user_s3_permissions row for nm099999, which the reset deletes too. Each collaborator case now checks the rows its route needs and names the one that is missing: the collaborator row from the collaborator list, as test-admin, for all three; the permission row, which no route but the upload routes reads, from upload-urls as test-user, for the two upload cases. That route checks the rows in turn and writes nothing (it signs URLs locally), so a missing collaborator row says the permission row cannot be read yet. Nothing is written. Tested against dev, whose nm099999 has neither row: the three cases fail naming the collaborator row. Against a local server running the real datasets routes over bun:sqlite: with the permission row left out, the two upload cases name it; with both rows, the presigned URL case passes. With the permission check removed, the two upload cases fail with the route's bare 403 instead. * test: name the finish dispatch in the workflow header * docs: match the workflow header to nemarDatasets
📦 Package PreviewYour package is ready to test! bun install -g nemar-cli@PR1983Version: 🤖 Updated on each push. |
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.
Summary
This PR merges the upstream freshness epic (#1046) into dev. A NEMAR dataset that mirrors an OpenNeuro dataset can now be re-pulled to a newer upstream snapshot: the snapshot is built as a reviewed delta on a release branch, lands through one pull request, and is released as a new major version. ADR 0111 is the verdict.
The automatic path (a scheduled re-pull, and the Worker's merge of a machine-clean pull request) is built and off by default. Its switches are absent from the deployed wrangler configuration, so merging and releasing this PR does not turn it on.
Phases
Each phase has its own sub-issue (#1907 to #1914). Its amendments are dated in ADR 0111.
nemar admin upstream-status) and the derived mirror flag, which is never stored.nemar admin repull plan).What changes for production
mirrorflag. Before the owner's backfill, a known mirror readsnull.nemar dataset release --type majoron anondataset is refused and points tonemar admin repull plan.AUTO_REPULL_ENABLEDandAUTO_REPULL_MERGE_ENABLED, with daily capsREPULL_DAILY_OPEN_CAP(default 2) andREPULL_DAILY_MERGE_CAP(default 5).Release order (plan section 3)
api.nemar.org/healthfor the new version, and a known dataset's listing ondata.nemar.orgfor amirrorkey on every version.nemar admin upstream-backfill(a dry run, then--execute),nemar admin upstream-status, then the canary and the G3 and G4 checks.Open items and known limits
run-upstream-repull.ymlstill say "held" in their header. The two copies must change together, and the org change needs the owner's go.--tag, which this release ships.Verification
The gate for an epic PR into dev is CI on this PR, per the owner's direction.
Local evidence from full root runs of the epic:
--jsontest in admin-publish-list-skew-cli is load-sensitive and passes alone.Later phase PRs were checked on their own gates, recorded in each PR body.
The review of this PR is posted as a comment, with its rounds.