Skip to content

docs(agents): require persisting state before publishing handoffs - #584

Merged
mnoah1 merged 2 commits into
mainfrom
preetam/claude-md
Aug 13, 2026
Merged

docs(agents): require persisting state before publishing handoffs#584
mnoah1 merged 2 commits into
mainfrom
preetam/claude-md

Conversation

@behinddwalls

@behinddwalls behinddwalls commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

Why?

A queue message that hands work to a later stage races the write that backs it. Within a service boundary the payload is only the entity ID and the consumer reloads from storage, so a message published before its write lands lets the consumer read an entity that was never recorded — or a version older than the one the message describes — and then act on an assumption that was never true. The other ordering is self-correcting: a failed publish leaves the state durable and the retry re-publishes, where the reverse leaves a message describing a state nothing wrote.

The repo already depends on this ordering but never wrote it down. Two sites deliberately publish first — the recovery nudge in speculate/finalize.go and the status log in buildsignal.go — each with a local comment explaining why. Stated as a blanket rule, it would read as something those two sites violate, and the next reader would "fix" them.

What?

Adds "Persist before you publish" as Key Concept #6, scoped to messages that hand off work. It carves out messages whose consumer depends on nothing the write does — a status log recording a transition, an idempotent nudge whose consumer re-derives from current state — and points at the two sites that document that reasoning in place.

Cross-references the rule from the queue-payload guidance, since reloading from storage is what makes the ordering load-bearing there.

behinddwalls and others added 2 commits August 12, 2026 15:46
## Summary

### Why?

A queue message that hands work to a later stage races the write that backs it. Within a service boundary the payload is only the entity ID and the consumer reloads from storage, so a message published before its write lands lets the consumer read an entity that was never recorded — or a version older than the one the message describes — and then act on an assumption that was never true. The other ordering is self-correcting: a failed publish leaves the state durable and the retry re-publishes, where the reverse leaves a message describing a state nothing wrote.

The repo already depends on this ordering but never wrote it down. Two sites deliberately publish *first* — the recovery nudge in `speculate/finalize.go` and the status log in `buildsignal.go` — each with a local comment explaining why. Stated as a blanket rule, it would read as something those two sites violate, and the next reader would "fix" them.

### What?

Adds "Persist before you publish" as Key Concept #6, scoped to messages that hand off work. It carves out messages whose consumer depends on nothing the write does — a status log recording a transition, an idempotent nudge whose consumer re-derives from current state — and points at the two sites that document that reasoning in place.

Cross-references the rule from the queue-payload guidance, since reloading from storage is what makes the ordering load-bearing there.
@behinddwalls
behinddwalls marked this pull request as ready for review August 12, 2026 22:57
@behinddwalls
behinddwalls requested review from a team and sbalabanov as code owners August 12, 2026 22:57
@mnoah1
mnoah1 added this pull request to the merge queue Aug 13, 2026
Merged via the queue into main with commit 0c10b50 Aug 13, 2026
27 checks passed
@mnoah1
mnoah1 deployed to stack-rebase August 13, 2026 17:07 — with GitHub Actions Active
@behinddwalls
behinddwalls deleted the preetam/claude-md branch August 13, 2026 17:07
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.

2 participants