Skip to content

Phase 7e: machine-clean rule and review of the re-pull pull request - #1955

Merged
neuromechanist merged 14 commits into
feature/issue-1046-epic-upstream-freshnessfrom
feature/issue-1913-phase7e-machine-clean
Oct 25, 2026
Merged

neuromechanist merged 14 commits into
feature/issue-1046-epic-upstream-freshnessfrom
feature/issue-1913-phase7e-machine-clean

Conversation

@neuromechanist

Copy link
Copy Markdown
Contributor

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.ts decides 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 of main, the screen clear for the exact head, the review passed for the exact head, the checks of App 3679074 passing on the head, mergeable_state clean, main still at the recorded base, and no enrichment commit since. Unknown is never clean. The fact readers in backend/src/services/upstream-repull-facts.ts read 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's pr-reviews start still answer bot_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.ts and shared/nemar-app.ts (new): the pure rule and the App's constants. backend/src/services/github/branch-protection.ts re-exports the constants, so nothing is defined twice.
  • backend/src/services/upstream-repull-facts.ts (new): the fact readers.
  • backend/src/services/pr-review.ts and pr-review-start.ts: the admission and startRepullPullRequestReview.
  • Tests: 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.
  • ADR 0111 amendment slice for 7e, and one line in ADR 0092 that points to it.

Owner decision (please read)

  • The narrowing: ADR 0092's "not bots" is narrowed for the App's automatic re-pull pull request only, reviewed only when the Worker starts it.
  • Consequences to accept: an edit to that pull request's title or body is not re-reviewed, so a stored pass stands; an administrator cannot re-run its review, --redo included.

Test plan

  • Typecheck and lint clean.
  • Targeted suites: 187 pass, 0 fail. Mutation log: 49 mutants, 47 killed; the two survivors have the same verdict as the original (the merge reading the recorded head, and a 404 read whose body is unreadable anyway).
  • Full bun test on 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.
  • CI on this head (the lead runs the Tests workflow).
  • Only production can check: that GitHub reports the App's pull request author as the login, id and type used here; that the App's token reads mergeable_state as an administrator's does; that check-runs filters work on a mirror; that the review workflow claims and reports on a pull request a bot opened; that main stays at base_sha from pr_open to the merge (an enrichment commit holds the merge with main-moved).

@github-actions

github-actions Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR1955

Version: 0.10.24-PR1955.9e4e91a
Commit: 9e4e91a


🤖 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
neuromechanist force-pushed the feature/issue-1913-phase7e-machine-clean branch from 1f9a9a7 to 9e4e91a Compare October 25, 2026 22:20
@neuromechanist
neuromechanist merged commit b051101 into feature/issue-1046-epic-upstream-freshness Oct 25, 2026
20 checks passed
@neuromechanist
neuromechanist deleted the feature/issue-1913-phase7e-machine-clean branch October 25, 2026 22:42

This branch was previously deployed

1 inactive deployment
npm — 9e4e91a6 Deployed Oct 25, 2026 by neuromechanist via publish #3982
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant