Repository navigation
Epic cleanup: approved simplifications - #1976
Merged
neuromechanist merged 25 commits intoOct 27, 2026
Merged
neuromechanist merged 25 commits into
neuromechanist merged 25 commits into
Conversation
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.
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.
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.
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.
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).
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.
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.
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.
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.
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.
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.
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.
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).
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.
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).
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).
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.
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.
📦 Package PreviewYour package is ready to test! bun install -g nemar-cli@PR1976Version: 🤖 Updated on each push. |
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.
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.
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).
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.
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.
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.
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.
neuromechanist
merged commit Oct 27, 2026
acfeeaa
into
feature/issue-1046-epic-upstream-freshness
24 checks passed
neuromechanist
added a commit
that referenced
this pull request
Oct 27, 2026
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.
neuromechanist
added a commit
that referenced
this pull request
Oct 27, 2026
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.
neuromechanist
added a commit
that referenced
this pull request
Oct 27, 2026
* 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.
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
The approved cleanup from the whole-epic simplification review, as one PR into the epic. Behavior is unchanged except the dispatch word list cut, which the owner approved. Review fixes added code (the digest-checked planner handoff and its pins), so the net change is +213 lines, not the -199 of the first pass.
Changes:
0111_mail_screening.sql.scripts/, with the same fences, the dry-run default and--execute.GET /repullsfilters by origin;nemar admin repull autoasks for automatic re-pulls only.executeuses the plan the run'splanstep wrote, with a digest-checked handoff beside it; an administrator'sexecutestill plans.Decisions and known effects
Review outcomes
record-refused; each step class is pinned end to end; the check-still-running hold is pinned; an absentdraftis tested.Test plan
bun run migrations:d1-check: exit 0.website parityagainst the local sibling checkout; it passes against GitHub's copy.