Repository navigation
Phase 6a: upstream re-pull record and state machine - #1936
Merged
neuromechanist merged 8 commits intoOct 24, 2026
Merged
neuromechanist merged 8 commits into
neuromechanist merged 8 commits into
Conversation
📦 Package PreviewYour package is ready to test! bun install -g nemar-cli@PR1936Version: 🤖 Updated on each push. |
Migration 0105 records one row per re-pull attempt, with stage invariants as CHECKs and a partial unique index for one open row per dataset. shared/repull-state.ts holds the states, the only allowed edges and the columns each edge may write. Tested on bun:sqlite and Miniflare D1; every edge pair asserted.
Adds the /admin/repulls routes (create, list, get, transition) and the service behind them: environment fence (exactly production lifts it), anonymity, withdrawn and import-in-flight refusals, version facts from D1, one open record per dataset, attempts, lineage at create through the one writer of that word, and compare-and-set transitions that take only the allowed edge and the columns it names. The delete cascade removes the records. No route sends mail. Tested on bun:sqlite and Miniflare D1; a source scan pins the lineage writer.
The staleness report left a mirror being re-pulled unclassified beyond its import state. A non-terminal upstream_repulls row now makes the mirror in_progress and keeps it out of the OpenNeuro comparison. Tested on the route (SQLite and Miniflare D1) and the pure classifier.
Migration 0105 (unreleased) gains revision, a unique index on (dataset_id, to_tag) for rows holding a merge sha, and the patch_released tag CHECK. The state module gains the self-edges that record a claim to merge, the locked count and a planned error. Tested on SQLite and Miniflare D1.
Transitions compare-and-set on status and revision. A merge claim is recordable and blocks head moves and closes. Any unreconciled merge blocks the dataset (merge-unreconciled). The lineage write matches v spellings and reports lineage_rows. Blank errors are refused, forward edges clear last_error, refusals carry a code, the create race is retried once, and a source scan pins that no mail is imported. Tested; mutations killed.
The Worker stamps the claim time; a request cannot carry it. The two claim columns are paired by a CHECK. A failed row that was merged and tagged no longer blocks the dataset. Dead gates-not-set branch removed, a deleted row answers 404, test names corrected. Tested.
neuromechanist
force-pushed
the
feature/issue-1912-phase6a-repull-record
branch
from
October 24, 2026 15:43
ac8f49e to
5d18f74
Compare
neuromechanist
merged commit Oct 24, 2026
07752a4
into
feature/issue-1046-epic-upstream-freshness
14 checks passed
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
Adds the durable record of an upstream re-pull (ADR 0111): migration
0105_upstream_repulls.sql, the pure state machine inshared/repull-state.ts,backend/src/services/upstream-repull.tsand the admin routes under/admin/repulls. A re-pull is one row per dataset, tag and attempt, with a partial unique index that allows one non-terminal row per dataset and CHECKs that make impossible states unwritable (gates_clear,complete,terminal_at). Transitions are compare-and-set on the previous status, refuse a stalefrom, keep the branch, PR number and patch identity once set, and refuseabandoned,supersededandpatch_declinedwhile a merge claim is held. Creating a record writes lineage (source_version, basis) on a NULL/NULL row only whenlineage_recordableis true, counts a held merge claim as blocking a new attempt, refuses anonymous datasets, and refuses every non-xxwrite unless the environment is exactlyproduction. The staleness report now shows an open re-pull as in progress ahead of a parked import. No mail is sent from any new route.Phase 6a of epic #1046, part of #1912 (which stays open until 6g). No behavior changes for existing flows; nothing creates a record yet.
What is in it
backend/src/db/migrations/0105_upstream_repulls.sql,shared/repull-state.ts,test/repull-state.unit.test.ts;publication-review-migration.test.tsbounded so a later table cannot break its "0098 objects" check.backend/src/services/upstream-repull.ts,backend/src/routes/admin/upstream-repulls.ts, registration inroutes/admin/index.ts, the cascade delete indeletion.ts, the route inventory pin (total 162).backend/src/services/upstream-status.tsandshared/upstream-staleness.ts: the in-progress hook.UNIQUE(dataset_id, to_tag)as per attempt so an abandoned tag can be retried.Test plan
bun testran before the last edits with only the website parity failure (stale sibling checkout) and two failures fixed afterward.bun run typecheckandbun run lintclean; migration 0105 exercised on Miniflare D1 in process (CHECKs, partial index,json_patch, create, lineage write, audit and transitions).migrations:d1-check(wrangler) was not run;meta.last_row_idandchanges()inside D1 batches have no production check.