Skip to content

feat(jobs): continue scheduled work only on a live artifact - #976

Merged
HugoXK merged 1 commit into
mainfrom
dev1/789-live-artifact-gate
Nov 18, 2026
Merged

HugoXK merged 1 commit into
mainfrom
dev1/789-live-artifact-gate

Conversation

@HugoXK

@HugoXK HugoXK commented Nov 17, 2026

Copy link
Copy Markdown
Owner

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, else issue_url): closed/merged produce the new decision { kind: 'iterate', staleWorkItemId, artifactState }, and tick() enqueues enqueue(repo, 'schedule', undefined, 'iterate') — the original goal, no work_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, tree 96de106fcecdbe69476bd83bb84c1c39de57ccac, parent c3d16bbc51bc04e0fc405f1f4e6c0e7bc1868439 (read from the API at Date: Tue, 17 Nov 2026 06:31:37 GMT). 6 files, +230/−32.

Ran:

  • npm ci && npm run check at the tip — exit 0, 2617/2617 tests pass, lint/typecheck/build clean
  • red at base 4cfe2986 — 7 new tests, 7 fail
  • node scripts/risk-gate.mjs --base c3d16bb — T3, basis src/jobs/continuity.ts

Not 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-iterate kinds and the work-item row keeps its prior state.
Docs: docs/architecture.md updated in this PR.
Changelog: changelog.d/789-live-artifact-decision.changed.md.

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.

@HugoXK-bot HugoXK-bot left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 — decideNextJob is async and takes the same CarryOverReader, so the scheduler can consult GitHub before choosing.
  • src/jobs/continuity.ts:400-413 — the read is after due-ness, uses pr_url then issue_url, and only a closed/merged answer returns { kind: 'iterate', staleWorkItemId, artifactState }; a thrown read is unverified and keeps the item.
  • src/jobs/continuity.ts:414-421 — open, a failed read and an item with no link keep the previous review/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-4511 passes it to the decision inside the tick, after the active-job and budget gates.
  • src/jobs/service.ts:4539-4544 — the fresh run is enqueue(repo, 'schedule', undefined, 'iterate'): no goal override, no work_item_id, so the goal is repo.goal and the run is nobody's continuation.
  • src/jobs/service.ts:4549-4552 — the stale row is marked only inside if (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-1459 and changelog.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 is review-gate waiting for this PASS; ci-ok and pr-lint success.

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 0
  • npx tsx --test test/jobs.test.ts test/automationHealth.test.ts — 129/129 pass
  • npx tsx tmp-probe-verdict976.ts — with a due schedule row: merged PR → job iterate/trigger schedule/work_item_id null/goal = repo.goal, row merged, occurrence settled dispatched with the job id, open work empty; a read that throws → followup with the item in_progress; no link → followup with no read; after the mark, the next decision picks the next open item
  • copied src/jobs/continuity.ts and src/jobs/service.ts from base c3d16bbc into this tree and re-ran the same two files — not ok 88, 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.ts
  • node 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

@HugoXK
HugoXK merged commit 2cd064b into main Nov 18, 2026
34 of 35 checks passed
@HugoXK
HugoXK deleted the dev1/789-live-artifact-gate branch November 18, 2026 01:00
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.

feat: continue scheduled work only when a live artifact supports it

2 participants