Skip to content

Phase 7f: the advance tick for automatic re-pulls - #1961

Merged
neuromechanist merged 18 commits into
feature/issue-1046-epic-upstream-freshnessfrom
feature/issue-1913-phase7f-gates-tick
Oct 26, 2026
Merged

neuromechanist merged 18 commits into
feature/issue-1046-epic-upstream-freshnessfrom
feature/issue-1913-phase7f-gates-tick

Conversation

@neuromechanist

Copy link
Copy Markdown
Contributor

Summary

Builds the advance tick for automatic re-pulls (ADR 0111, dated 2026-10-25 for this slice). A production-only tick every 30 minutes reads the automatic records from planned to pr_open, holds each one by reason (an observation: it writes the reason and its audit row only when the reason changes, and never bumps the revision), starts the screen and the review for the exact head when every earlier rule holds, writes gates_clear only on a clean verdict from the machine-clean rule (7e), and resumes a stalled automatic record through the dispatch record (7b) once per window and under the cap. Administrator rows are never read. Outside exact production the tick is null and makes no request and no write; the switch AUTO_REPULL_ENABLED must be exactly "1" for any gate work or resume. The tick stops at pr_open and never touches gates_clear, merged or released: those are 7g.

Phase 7f of epic #1046, part of #1913 (which stays open until Phase 7 completes). It builds on 7b (the dispatch record), 7c (the scheduler), 7e (the machine-clean rule and the review admission) and 6e (the screen).

Deviations from the plan (the code wins; each is a safer direction)

  • Rows rotate five per tick by id, keyed to the half hour, not by the plan's ORDER BY updated_at, because holds never touch updated_at and most rows wait on an administrator, so the plan's order would starve the newest rows.
  • The screen is dispatched at most three times per head (counted from its audit rows); a verdict that asks for a person is never re-dispatched.
  • A review whose dispatch failed is retried after 60 minutes; the review starts only while the screen can still clear.
  • While a dispatch for the dataset is live, the tick reads nothing and writes no hold; with the switch off, switch-off is still recorded.
  • The entry point is runRepullAdvanceCron, so the wiring test discovers it as a production-only job (the same rule 7c followed).
  • The measured cost is 152 subrequests when five rows all start their gates and 57 in steady state; the test pins these figures (the plan estimated about 45).

Test plan

  • Typecheck and lint clean; backend/test/upstream-repull-advance.test.ts 86 pass.
  • Full backend suite after the rebase: 9675 pass, 0 fail. The full root run before the rebase had 8 failing files, none touched by this branch: six 5 second timeouts under a machine load of 50 to 120 (each passes alone), one help-text test that failed only in shard order, and the website-parity check against a drifted local checkout.
  • CI on this head (the lead runs the Tests workflow).
  • Only production can check: that the screen and review start on a pull request the App opened, and that the review's check and comment publish there; the real subrequest cost on the 30-minute tick.

Add the advance tick (runRepullAdvanceCron) on the 30-minute
production tick. It reads automatic pr_open rows only, five a tick
in rotation, and records the first machine-clean rule that does not
hold as the row's hold: written once per change of word with one
repull_hold audit row, never over a row whose revision moved, and
without touching revision or updated_at. Null outside exact
production; with the open switch off GitHub is asked nothing and
the row says switch-off; a row a live dispatch works on is left
alone. An edge into another status now clears the hold.

Tested: upstream-repull-advance.test.ts, cron wiring, cron dev
safety and the no-mail scan; each guard mutated and killed.
The advance tick now takes a clean pr_open row to gates_clear, with
gates_sha the head, as the system user, through prepareTransition on
the row as read (the screen, fences and live head are re-checked).
Every other verdict holds. Once every rule before the screen holds
it starts the head's identifier screen (at most three dispatches a
head) and the App's review (absent, or a failed dispatch an hour
old, and only while the screen may still clear).

The GitHub stand-in answers the review's check and comment writes.

Tested: upstream-repull-advance.test.ts (gates, unknown facts,
bounds) plus the facts, screen, route and admission suites; each
new guard mutated and killed.
The advance tick now also reads automatic rows stalled before their
pull request opened (planned to registered). With no live dispatch
and the last one failed, unreported or refused by GitHub, a row that
passes the machine-clean record and dataset rules, has fewer than
three open dispatches, has not moved for an hour and is examined
between 03:00 and 15:59 UTC is resumed through claimOpenDispatch
(the open cap, in the statement that claims) and the scheduler's
send. Otherwise it holds resume-exhausted, resume-refused (a new
word) or cap-exhausted, or waits. A 4xx frees the unit and stops
the tick's sends; a lost answer keeps it. The tick's cost is pinned.

Tested: upstream-repull-advance.test.ts, the dispatch words, the
dispatch and scheduler suites; each guard mutated and killed.
Append the Phase 7f slice: the advance tick (production only, the
switch, automatic rows only, five a tick in rotation and why), holds
as observations, the gates edge on a clean verdict only, when the
screen and the review are started, the resume of a stalled run and
its bounds, the measured cost, and what only production shows. Three
annotations mark what is now built; no earlier line is changed.

Tested: adr-index.unit.test.ts.
One rotation turned by the half hour of the day came back to the
same rows at the same hours: of 240 open automatic rows only 130
were ever read between 03:00 and 15:59 UTC, so the rest could never
be resumed, and a stalled row also waited behind pr_open rows. The
tick now keeps two rotations: pr_open rows turn every half hour, and
stalled rows are read only inside the resume window and turn once
per half hour of it, five of each kind a tick.

Tested: a 60-day simulation over 239, 240, 241, 480 and mixed sets
reads every stalled row inside the window; turning stalled rows by
the half hour of the day, or one rotation for both, fails it.
The review was dispatched on the same tick as the screen, while the
screen could still block or ask for a person, and a screen in error
did not stop it. It now starts only once the head's screen is clear,
so on a later tick. A start the review itself declines is counted by
its reason (pr_review_disabled, github_unreadable, ...) in the result
and the log line, every tick it declines.

Tested: upstream-repull-advance.test.ts (the gate sequence, a screen
in error, the review switched off; the cost figures re-measured);
each change mutated and killed.
A 401, 403 or 429 on a resume's send spent one of the row's three
dispatches although nothing about the row was tried. Only a refusal
of the dispatch itself (404, 422) now counts, as dispatch-refused;
any other 4xx ends the claim as dispatch-deferred (a new dispatch
word), frees its unit, stops the tick's sends and spends nothing.
The bound is renamed AUTOMATIC_OPEN_DISPATCHES_MAX: it counts the
creating dispatch, so a row is resumed twice at most. The send is
its own function, so a payload that cannot be built is tested.

Tested: upstream-repull-advance.test.ts (each refusal status, runs
that never reported, the latest dispatch deciding, the unbuilt
payload) and the dispatch words; each rule mutated and killed.
The open claim compared the row's stored tags with the bare tags it
binds, so a row that records v1.0.0 would be refused as row on every
tick, and the tick waited on it in silence. The claim now matches
the stored tags in either spelling, as the lineage write does, and a
row refusal is the error word repull-mismatch, logged at error level.

Tested: upstream-repull-advance.test.ts (v-prefixed tags, a row that
changes before the claim) with the dispatch, scheduler and route
suites; both changes mutated and killed.
The quiet hour before a resume read only the row's updated_at, which
a run that fails before it writes anything never moves, so a row
could be resumed on consecutive ticks. It now counts from the later
of the row's updated_at and its latest dispatch's report (or send).

Tested: upstream-repull-advance.test.ts (consecutive ticks, a report
exactly 59 and 60 minutes old); each change mutated and killed.
An open cap set to something its reader cannot take was recorded on
the row as cap-exhausted, a full day, though it is a fault in the
configuration. It is now the hold word cap-unreadable (added to the
hold words), on that row and on every later row of the tick, beside
the error word of the same name.

Tested: upstream-repull-advance.test.ts (caps 0, x and 21 over two
stalled rows) and the hold-word tests; both changes mutated and
killed.
A row whose step threw left only its error's class: the tick now
logs the re-pull's id (never its dataset) with the class, and takes
up the next row. last_advance_at was stamped even when the tick
could not list its rows; it is now stamped only for a tick that ran.
The waiting count, which mixed two things, is split into running (a
run is out for the row) and not_due (a resume not due this tick).

Tested: upstream-repull-advance.test.ts (one row's throw, a tick
that cannot list, the counters); each change mutated and killed.
When machine clean found a row clean and the record's transition
refused its gates_clear edge, the refusal was only counted at info
level and the row kept its old hold, so it retried every tick in
silence. It is now held gates-refused (a new hold word) and the log
line is an error, with the refusal's code, every tick it happens.

Tested: upstream-repull-advance.test.ts (a refusal over two ticks);
both changes mutated and killed.
Pin the bounds by their numbers (3 screens a head, 60 minutes before
a failed review dispatch is asked again, 3 open dispatches a row, 60
quiet minutes, 03:00 to 15:59 UTC, 5 rows of each kind), the window's
edges by literal times, a hold that leaves an old updated_at as it
was, a screen that never reported being run again, the screen bound
being per head, a row that moved on between the list and its read,
and the resume's no-github-token, dispatch-unconfigured and
to-tag-malformed words.

Tested: each pinned line mutated (the numbers, the window edges, the
re-check, the head filter, the words) and every mutant killed.
The cron comment now says the tick dispatches screens, starts
reviews, writes gates_clear and resumes, not only that it records
holds. The failure words say what each one is (dispatch-failed is a
screen's failed dispatch or a resume's unbuilt payload; a refused
send is dispatch-refused or dispatch-deferred). Clearing a hold is
said to be a write. The cost adds the App token mint on a cold
isolate. The review start's audit note names who has no user, and
the test header states the stand-in reason instead of citing one.

Tested: typecheck, biome; the advance, cron wiring, cron dev-safety
and review admission suites.
The slice now records the two rotations and the reason (the first
design's rotations left rows unread), the review starting only behind
a clear screen and its refusals said, the gates-refused,
cap-unreadable and resume-refused holds, what spends a resume
(dispatch-deferred does not), the quiet time from the last dispatch,
either spelling of a tag at the claim, the stamp only for a tick that
ran, the limit of the bound when a creating dispatch is unlinked, and
the re-measured cost with the token mint. It no longer cites a source
outside the repository. Two more earlier sentences are annotated, the
7b slice's on the hold columns and the 7c slice's on the resume
bound, and the slice says which five lines are annotated.

Tested: adr-index.unit.test.ts.
@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR1961

Version: 0.10.24-PR1961.59dae08
Commit: 59dae08


🤖 Updated on each push.

A row or dispatch time that does not parse made the row not due on
every tick with nothing said. It is now the error word
time-unreadable, logged at error level, and the row is not resumed.

Tested: upstream-repull-advance.test.ts; reading it as a wait, or
leaving the word out, fails the new test.
A 422 send leaves its dispatch_failed row with no report; the test
pins that the next tick, 30 minutes later, sends nothing, timing it
from the send (COALESCE(reported_at, dispatched_at)).

Tested: replacing the COALESCE with reported_at fails it.
The Phase 7f slice now says that GitHub's 404 for a token that cannot
see a private repository spends a resume, two at most a row, and why
that is accepted, and that an unparsable time is time-unreadable.

Tested: adr-index.unit.test.ts.
@neuromechanist
neuromechanist merged commit cabe498 into feature/issue-1046-epic-upstream-freshness Oct 26, 2026
20 checks passed
@neuromechanist
neuromechanist deleted the feature/issue-1913-phase7f-gates-tick branch October 26, 2026 02:37

This branch was previously deployed

1 inactive deployment
npm — 59dae087 Deployed Oct 26, 2026 by neuromechanist via publish #3994
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