Repository navigation
Phase 7e: machine-clean rule and review of the re-pull pull request - #1955
Merged
neuromechanist merged 14 commits intoOct 25, 2026
Conversation
📦 Package PreviewYour package is ready to test! bun install -g nemar-cli@PR1955Version: 🤖 Updated on each push. |
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
neuromechanist
force-pushed
the
feature/issue-1913-phase7e-machine-clean
branch
from
October 25, 2026 22:20
1f9a9a7 to
9e4e91a
Compare
neuromechanist
merged commit Oct 25, 2026
b051101
into
feature/issue-1046-epic-upstream-freshness
20 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
Defines when an automatic re-pull pull request is machine-clean and reviews it (ADR 0111, dated 2026-10-25 for this slice). A pure rule in
shared/repull-machine-clean.tsdecides from facts only: the pull request is open, not a draft, from the App (login, id and type), with a head repository that is ours, a base ofmain, the screen clear for the exact head, the review passed for the exact head, the checks of App 3679074 passing on the head,mergeable_stateclean,mainstill at the recorded base, and no enrichment commit since. Unknown is never clean. The fact readers inbackend/src/services/upstream-repull-facts.tsread each fact from GitHub or the record. The review intake now admits exactly the App's automatic re-pull class, and only when the Worker starts the review; GitHub webhook deliveries and an administrator'spr-reviews startstill answerbot_author.This narrows ADR 0092's "not bots" for that one class, and the amendment says so. Nothing merges here: the merge is Phase 7g, behind the switches. No mail from any new route.
Phase 7e of epic #1046, part of #1913 (which stays open until Phase 7 completes). It builds on 6e (the screen and the cap) and 7b (the dispatch record).
What is in it
shared/repull-machine-clean.tsandshared/nemar-app.ts(new): the pure rule and the App's constants.backend/src/services/github/branch-protection.tsre-exports the constants, so nothing is defined twice.backend/src/services/upstream-repull-facts.ts(new): the fact readers.backend/src/services/pr-review.tsandpr-review-start.ts: the admission andstartRepullPullRequestReview.test/repull-machine-clean.unit.test.ts,backend/test/nemar-app-bot.unit.test.ts,backend/test/upstream-repull-facts.test.ts,backend/test/pr-review-repull-admission.test.ts, and the no-mail scan roots.Owner decision (please read)
--redoincluded.Test plan
bun teston the implementer's run: 20752 pass, 242 skip, 2 fail. Neither is from this branch: website parity against a drifted sibling checkout, and a 5 second timeout under load that passes alone.mergeable_stateas an administrator's does; thatcheck-runsfilters work on a mirror; that the review workflow claims and reports on a pull request a bot opened; thatmainstays atbase_shafrompr_opento the merge (an enrichment commit holds the merge withmain-moved).