Skip to content

refactor(audit-engine): cloud-fetcher waiter state is one union, not three booleans - #1704

Closed
nc9 wants to merge 1 commit into
mainfrom
refactor/cloud-fetcher-waiter-state-1664
Closed

nc9 wants to merge 1 commit into
mainfrom
refactor/cloud-fetcher-waiter-state-1664

Conversation

@nc9

@nc9 nc9 commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Part of #1664 (the waiter half; the report render block is a separate PR because it changes the JSON schema).

cloud-fetcher.ts kept a waiter's state in three booleans, settled, dispatched and racing, whose legal combinations lived only in comments. They are one union now:

type WaiterState = "queued" | "dispatched" | "racing" | "settled"
queued -> dispatched | racing -> settled, and queued -> settled (an abort or a render item)

The issue names three states; the code has a fourth that was always legal and could not be dropped: dispatched (terminal handling committed, the one-and-only fallback fetch started and has not settled the waiter yet; a fallback settles asynchronously). Merging it into queued or settled would let a re-sent completed item (#992) or an overlapping fallback sweep double-fetch. The illegal combinations (racing without dispatched, racing with settled) can no longer be written.

No behaviour change: claim moves queued to dispatched and refuses any other state, the headroom timer moves dispatched to racing, resolveWaiter and rejectWaiter end in settled, the demux and the retire checks read the same four states the boolean tests encoded. No user-facing change, so no CHANGELOG bullet.

Acceptance criteria (#1664, waiter AC)

  • Waiter state is one union, not three booleans; existing cloud-fetcher tests pass: cloud-fetcher (13), cloud-fetch-headroom (10, the racing and claim paths), cloud-fetcher-redirect-hops (9), rendered-fetch (6)
  • A source guard (cloud-fetcher-waiter-state-1664.test.ts) pins the union and fails if the booleans return

Checks

tsgo (audit-engine), root lint. Temp HOME. Goldens not run locally (CI runs them).

Agent skill and docs

  • squirrelscan agent skill (squirrelscan/skills): No change. An internal refactor of the cloud fetcher's waiter state; no behaviour an agent can see.
  • Docs: No docs page applies: nothing user-facing changes (no CHANGELOG bullet for the same reason).

@nc9

nc9 commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

All commits of this draft are on main (landed in the v0.0.175 bundle). Closing the draft.

@nc9 nc9 closed this Nov 11, 2026
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