Skip to content

feat(daemon): lease completion finality guard + LL law tests (coupling-core E2)#469

Merged
proboscis merged 2 commits into
mainfrom
feat/coupling-core-lease-laws
Jun 12, 2026
Merged

feat(daemon): lease completion finality guard + LL law tests (coupling-core E2)#469
proboscis merged 2 commits into
mainfrom
feat/coupling-core-lease-laws

Conversation

@proboscis

Copy link
Copy Markdown
Owner

Stacked on #468. Phase E2 of the coupling-core roadmap: the worker-lease draft laws (LL1–LL5, docs/design/worker-lease.md in #465) become executable, and the one law the code violated gets its fix.

The LL3 bug

before                                        after
──────                                        ─────
ack #1: success, result A  → committed        ack #1: success, result A → committed
ack #2 (late/duplicate):                      ack #2: idempotent no-op —
  Success/Error/ResultJSON                      first verdict wins
  OVERWRITTEN unconditionally

A re-dispatched executor finishing after its successor, or an at-least-once RPC retry, could rewrite a verdict the master had already acted on.

Law test coverage

Law Test
LL1 liveness fail-fast existing TestWaitForWorkerLeaseCompletionFailsFastWhenWorkerLost
LL2 dispatch exclusivity + monotone DispatchCount TestLeaseLawDispatchExclusiveUntilExpiry, TestLeaseLawNoDispatchAfterCompletion
LL3 completion finality TestLeaseLawCompletionFinality
LL4 restart amnesia is safe TestLeaseLawRestartAmnesiaFailsFast
LL5 snapshot sufficiency existing executeLeaseEffect snapshot tests
all interleavings TestLeaseLawRandomWalkInvariants (seeded random walk)

Verification

🤖 Generated with Claude Code

proboscis and others added 2 commits June 12, 2026 16:43
…g-core E2)

Promotes the worker-lease draft laws (LL1-LL5, docs/design/worker-lease.md)
to executable tests, and fixes the one law the code did not yet uphold:

- LL3 completion finality: acknowledgeWorkerLease previously overwrote a
  committed verdict unconditionally, so a late or duplicate ack (an
  at-least-once RPC retry, or a re-dispatched executor finishing after its
  successor) could flip Success/Error/ResultJSON after the master had
  already acted on the first verdict. The first verdict now wins; acking a
  completed lease is an idempotent no-op.
- New law tests: completion finality, dispatch exclusivity until the
  dispatch TTL (with monotone DispatchCount), no dispatch after
  completion, restart amnesia fails fast (lease not found immediately,
  never a timeout hang), and a seeded random walk over
  dispatch/expire/ack interleavings asserting all of the above for any
  operation order. LL1 was already covered by the fail-fast worker-lost
  test; LL5 by the snapshot tests.

Verified: go test ./internal/daemon (full suite + new law tests pass).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@proboscis proboscis changed the base branch from feat/coupling-core-lease-guard to main June 12, 2026 07:58
@proboscis proboscis merged commit c2af97a into main Jun 12, 2026
@proboscis proboscis deleted the feat/coupling-core-lease-laws branch June 12, 2026 07:59
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