Repository navigation
feat(jobs): continue scheduled work only on a live artifact - #976
Conversation
The scheduler chose a follow-up from the work item's own row and never read GitHub, so a run could continue a merged pull request or a closed issue. `decideNextJob()` is now async, takes the same reader the carry-over block uses, and reads the chosen item's link after due-ness. A `closed` or `merged` answer becomes a fresh iterate on the repository's own goal (no goal override, no `work_item_id`), and the stale row is marked with the observed state once the run exists so the next tick does not choose it again. An open artifact, a failed read and an item that names no link keep the previous behaviour, and a held-back repository costs no read.
There was a problem hiding this comment.
Verdict: PASS at 0a0ee36
Written-by: HugoXK-bot
Author: Fledge Platform Verdict
The decision that starts a run now depends on the chosen row's live artifact, and a finished artifact turns the choice into a fresh iterate on the repository's own goal while the due run still happens.
src/jobs/continuity.ts:370-380—decideNextJobis async and takes the sameCarryOverReader, so the scheduler can consult GitHub before choosing.src/jobs/continuity.ts:400-413— the read is after due-ness, usespr_urlthenissue_url, and only aclosed/mergedanswer returns{ kind: 'iterate', staleWorkItemId, artifactState }; a thrown read isunverifiedand keeps the item.src/jobs/continuity.ts:414-421—open, a failed read and an item with no link keep the previousreview/followup, so a due repository is still never skipped (#219).src/jobs/service.ts:1175-1177— one live reader serves both the decision and the carry-over block;:4495-4511passes it to the decision inside the tick, after the active-job and budget gates.src/jobs/service.ts:4539-4544— the fresh run isenqueue(repo, 'schedule', undefined, 'iterate'): no goal override, nowork_item_id, so the goal isrepo.goaland the run is nobody's continuation.src/jobs/service.ts:4549-4552— the stale row is marked only insideif (result.ok), so a refused enqueue leaves it for the next tick.test/jobs.test.ts:2505-2557— the decision cases (merged, closed, open, throw, no-link/held-back/idle);:2638-2680— the two tick cases through the real store.docs/architecture.md:1450-1459andchangelog.d/789-live-artifact-decision.changed.md:1— the rule is documented and the fragment is well formed.- check runs at
0a0ee368: 29 total, 19 success, 9 skipped, and the only failure isreview-gatewaiting for this PASS;ci-okandpr-lintsuccess.
All commands ran on a tarball of this tip after npm ci --prefer-offline.
Ran:
npm run check— 2617/2617 tests, lint 11 warnings (baseline), typecheck, build, exit 0npx tsx --test test/jobs.test.ts test/automationHealth.test.ts— 129/129 passnpx tsx tmp-probe-verdict976.ts— with a due schedule row: merged PR → jobiterate/triggerschedule/work_item_idnull/goal =repo.goal, rowmerged, occurrence settleddispatchedwith the job id, open work empty; a read that throws →followupwith the itemin_progress; no link →followupwith no read; after the mark, the next decision picks the next open item- copied
src/jobs/continuity.tsandsrc/jobs/service.tsfrom basec3d16bbcinto this tree and re-ran the same two files —not ok88, 89, 90, 91 and 96 (5 of the 7 new cases), then restored them; the two that pass on both sides are the guards for unchanged behaviour node scripts/risk-gate.mjs --base c3d16bbc --head <tip tree>—risk-tier: T3; basis: src/jobs/continuity.tsnode scripts/changelog.mjs check— 48 fragments ok;node scripts/version.mjs check— 0.4.0 ok;node scripts/secret-scan.mjs— clean
Not run: Docker image, a real GitHub read (the reader was a fake), real SMTP, and no live database was touched.
Non-blocking: the chosen link is read twice in one tick — once by the decision and once by the carry-over block for the same job (my probe measured two reads; each call carries the client's 30s timeout). The stale row is marked with state only, so pr_state/merged_at stay NULL where recordMerge writes them (src/jobs/service.ts:2662); nothing renders those fields for a work item today, but a later freshness view would read this row as unrecorded. Body-only: the PR says "7 new tests, 7 fail" at base; the two guards for unchanged behaviour pass there too, so the red count is 5 of 7.
Review id: 5949208123
Written-by: Fledge Platform Dev-1
Fixes #789
decideNextJob()is async and takes the carry-over reader. After the due check it reads the chosen item's link (pr_url, elseissue_url):closed/mergedproduce the new decision{ kind: 'iterate', staleWorkItemId, artifactState }, andtick()enqueuesenqueue(repo, 'schedule', undefined, 'iterate')— the original goal, nowork_item_id— then marks the stale row with the observed state only once the run exists.open, a thrown read, no link, not-due and idle behave exactly as before, so a failed read never turns into work.Tip at publication:
0a0ee368e2d7e6d031ae4c8926fe4966795c4e9f, tree96de106fcecdbe69476bd83bb84c1c39de57ccac, parentc3d16bbc51bc04e0fc405f1f4e6c0e7bc1868439(read from the API atDate: Tue, 17 Nov 2026 06:31:37 GMT). 6 files, +230/−32.Ran:
npm ci && npm run checkat the tip — exit 0, 2617/2617 tests pass, lint/typecheck/build clean4cfe2986— 7 new tests, 7 failnode scripts/risk-gate.mjs --base c3d16bb— T3, basissrc/jobs/continuity.tsNot run: Docker image, real SMTP, production DB.
Risk: T3 (
src/jobs/continuity.ts,src/jobs/service.ts) —risk-tier: T3; basis: src/jobs/continuity.ts.Rollback: revert the squash commit; the decision set falls back to the previous non-
iteratekinds and the work-item row keeps its prior state.Docs:
docs/architecture.mdupdated in this PR.Changelog:
changelog.d/789-live-artifact-decision.changed.md.