Repository navigation
Phase 6e: re-pull screen, merge cap, merged and released - #1939
Merged
neuromechanist merged 10 commits intoOct 24, 2026
Merged
neuromechanist merged 10 commits into
neuromechanist merged 10 commits into
Conversation
Migration 0106 adds upstream_repull_screens: one row per screened commit of a re-pull's N.0.0 or N.0.1 pull request, with CHECKs that pin which states carry a report, a nonce or an acknowledgment, one waiting screen per re-pull, and a cascading foreign key. The dataset cascade deletes the screens before the re-pull rows. Tested on bun:sqlite and Miniflare D1 (every CHECK, the unique keys, the waiting index, the foreign key and the cascade).
Move SCREEN_REPORT_DEADLINE_MINUTES and workerErrorReport from identifier-screen.ts, which mails, to identifier-screen-stored.ts, which does not, so a screen that must never mail can read them. identifier-screen.ts re-exports both, so every importer is unchanged. Tested: the identifier screen, sweep, stored-read and gate suites.
The identifier screen is bound to the re-pull row (ADR 0111, decision 7). POST /admin/repulls/:id/screen dispatches run-identifier-screen with ref set to the recorded head, request_id 0 and a callback of its own, /webhooks/identifier-screen-repull-result, whose identifier-repull token binds the dataset, row, pull request, commit and nonce. GET /repulls/:id/screens reads them; POST .../screen/acknowledge records a reason on a screen that asks for one, never on a direct identifier. pr_open -> gates_clear (and the N.0.1 twin), formerly refused as screen-not-built, now opens only for the recorded head with the screen passing, and the claim to merge needs it for the claimed head; both re-check the dataset fences and re-assert the verdict in the statement that writes. A pending screen past the deadline reads unreported; only a screen with no verdict is dispatched again. No mail: the module reads the publication screen's helpers from the mail-free module, and the no-mail scan now covers the screen and its callback. Tested: new screen suite (dispatch, tokens, callback, replay, deadline, acknowledgment, gates, races; Resend capture stays empty), the record suites updated for the fence re-checks, route and export pins.
Every claim to merge a re-pull pull request, N.0.0's and N.0.1's together, now takes one unit of REPULL_DAILY_MERGE_CAP (ADR 0111, decision 6), counted in the UPDATE that writes the claim, in a fixed UTC day on D1's clock, so two claims racing for the last unit cannot both win and a refusal writes nothing (ADR 0099). Absent, the cap is 5; one or two digits up to 20 are read; anything else reads 0 and is refused as merge-cap-unreadable, never the default. A refusal carries the cap in force and today's claims. Tested: cap reader values, cap 1/2/5/0/unreadable, N.0.1 claims counting, yesterday's claims, a race for the last unit, the screen and fences at the claim.
Three routes write what only GitHub and the version row can state, after the Worker reads them with its own credential (ADR 0111, decisions 2, 3, 4 and 6): - POST .../merge-claim/release clears a claim only for a merge not sent or refused, while GitHub says the pull request did not merge; - POST .../merged records gates_clear -> merged (or the N.0.1 twin) with GitHub's merge commit; a merge with no claim, or at another head, is recorded and counted (merged_outside_tool, merged_unscreened_head, counts only the Worker writes); - POST .../released needs the version row with a DOI and a tag on a commit that contains the merge, and in the same batch, guarded on the row as read, writes N.0.0's lineage when the tree was verified and re-arms that dataset's hed, channel-montage, data and availability stamps (path constants added to sweep-stamps.ts). prepareTransition/commitTransition carry the verified writes through the transition's own checks and compare-and-set. The version-DOI scan lists the release check, which reads only that a DOI exists. Tested: GitHub stand-in suite (release, merged, released, races, other datasets untouched), the D1 run of the dispatch, gate, cap and release statements on Miniflare, scans and route pins.
Append the Phase 6e slice of the Phase 6 amendment under its own dated heading, after Phase 4c's: the screen bound to the re-pull row, the merge cap as built, and the verified merge and release (what the dispatch and callback bind, why the screen reads the mail-free helpers, the acknowledgment rule, the gates edges now open, the cap's reading, the claim release, merges recorded outside NEMAR's tools, the tag that must contain the merge, the stamp re-arm, the reconcile decision 2 needs no writer for, and what only stand-ins have checked). No code changed.
Review round 1 of the screen, cap and verified routes: - the gates edge and the claim read the live pull request on GitHub (open, unmerged, main, head at the sha); 502 when unreadable, head-moved otherwise (new upstream-repull-github.ts, shared reads); - the claim's statement also holds anonymous = 0 and no withdrawal; - a claim is released only once five minutes old (claim-too-recent); - merged_outside_tool means only that no claim was held, counted apart from merged_unscreened_head; both show in the list; - compare 404/422 is compare-unresolved; a transport retry time is passed through; the tag is read as application/vnd.github.sha; - an unacknowledged asking verdict may be screened again; an acknowledgment is recorded once (already-acknowledged); - a retried merged or released for the same commit is replayed; - SCREEN_GATED_STATUSES removed (unused). Tested: new and rewritten suites (races staged before the Worker's UPDATE, day edges, fences, replays), shared GitHub stand-in, Miniflare D1, scans and pins; 36 mutations, all killed.
Mark the statements Phase 6e made false as superseded, without rewriting them: the built-decisions notes at the top, the first slice's fences and states as built. Add two Not yet verified items (the workflow posting to the re-pull callback path; GitHub's tag, compare and merge answers, read only through stand-ins), update the README index entry, and bring the Phase 6e slice in line with the review fixes (live head, claim atomicity, claim age, separate merge counts, compare-unresolved, rerun and acknowledgment rules, replays).
📦 Package PreviewYour package is ready to test! bun install -g nemar-cli@PR1939Version: 🤖 Updated on each push. |
Delta review suggestions: the live-head read refuses a draft pull request (pr-draft) at the gates and the claim, so a draft takes no unit of the cap; a merged replay derives its two flags from that pull request's own claim and screened head, not the counts N.0.0 and N.0.1 share; a released replay reports null for lineage_rows and stamps_rearmed (nothing was written; unknown is not zero). Tested: merge suite (draft, N.0.1 replay over N.0.0's counts, replay nulls), touched suites; 5 mutations, all killed.
Add to the Phase 6e slice that the live-head check holds only if Phase 6f's merge call passes the same sha to GitHub's merge API, that a draft is refused, and that an acknowledgment recorded once by an administrator who is absent or demoted leaves only a new head to unblock the pull request. No code changed.
neuromechanist
merged commit Oct 24, 2026
f3d9f1a
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
Binds the identifier screen and the merge cap to the re-pull row (ADR 0111). Migration
0106_upstream_repull_screens.sqladdsupstream_repull_screens(cleaned by the dataset cascade). A re-pull's screen is dispatched for the exact head and commit, reported back through a new callback with a token kind that binds dataset, row, pull request, sha and nonce, and read throughGET /admin/repulls/:id/screens; an acknowledgment counts only for the administrator who recorded it, a report naming another commit is stored as a workflow failure, and the gates-clear edges open only on a clear screen for the current head. The merge claim (the 6a self-edge) now needs the screen, re-checks the dataset fences (mirror, anonymity, withdrawn, import) and takes one unit of a daily cap (REPULL_DAILY_MERGE_CAP, default 5, at most 20; a value that is set but unreadable reads 0 and is refused asmerge-cap-unreadable), in the same statement that writes the claim. New verified routes recordmergedandreleasedafter reading GitHub (the merge, the tag resolving to the reported sha and containing the merge) and release a claim only when GitHub says the pull request did not merge; a merge made outside the tool or at an unscreened head is recorded with Worker-only counts so the one-merge index and the unreconciled check see it. The screen gate is built on the sharedscreenGateso the no-mail import closure holds, and no new route sends mail.Phase 6e of epic #1046, part of #1912 (which stays open until 6g).
executenever merges; nothing creates a record yet.What is in it
backend/src/db/migrations/0106_upstream_repull_screens.sql,deletion.tscascade, the Miniflare migration test.backend/src/services/upstream-repull-screen.ts,identifier-screen-stored.ts(deadline andworkerErrorReportmoved, re-exported), the callbackidentifier-screen-repull.ts, the token kind incallback-tokens.ts, routesPOST /repulls/:id/screen,/screen/acknowledge,GET /repulls/:id/screens.backend/src/services/upstream-repull-verified.ts: merge-claim release,merged,released, the stamp path constants;shared/repull-state.tsedges; route and export pins.Test plan
bun testran once: 19557 pass, 242 skip, 3 fail (website parity against a stale sibling checkout, plus two of the implementer's own that were fixed and rerun); after the rebase 511 tests across 16 touched suites pass (Miniflare migration, no-mail scan, ADR index, pins).migrations:d1-check(wrangler) not run here; the Miniflare suite covers the SQL. GitHub'scommits/tags/<tag>read, the compare status words and the merged-PR fields are verified only against stand-ins.