Skip to content

fix(store): deterministic operator-audit lease; package budgets as measurement plus margin (#971) - #975

Merged
jimhoyd merged 1 commit into
mainfrom
claude/flake-and-budgets
Sep 29, 2026
Merged

jimhoyd merged 1 commit into
mainfrom
claude/flake-and-budgets

Conversation

@jimhoyd

@jimhoyd jimhoyd commented Sep 29, 2026

Copy link
Copy Markdown
Collaborator

Fixes #971

Flaky store test

packages/store/test/operator-audit.test.ts ran DELETE FROM store_servers while the serving store was still open. Its heartbeat (joinHostLease, every 5 s) upserts its own lease, so a beat landing between the DELETE and deleteOwnerless's fence re-inserted the lease and the command was refused. The test now calls store.close(), which stops the heartbeat and deletes the lease, before the final command.

  • No other store/auth/audit test deletes or expires a *_servers lease under a running server (the other matches insert synthetic expired/peer rows).
  • Product code: no real race. Only close() removes a process's own lease, and it clears the heartbeat first. A beat re-inserting a lease that a peer purged after it expired (e.g. a suspended process) is intended: the process is still serving.
  • Evidence: the store workspace suite passed 5 consecutive runs (206/206 each) locally on Node 26.

Package budget policy

Every PR used to bump the core budget by a few KiB and append a history comment, so concurrent PRs conflicted on the same lines. scripts/package-audit.ts now carries one policy comment: each limit is a Node 26 measurement (after npm run build, npm pack --dry-run --json --ignore-scripts) plus a fixed margin:

  • core: +24 KiB packed (~2%), +2% unpacked, +2% entries
  • add-ons: packed + max(10%, 6 KiB), unpacked + max(10%, 24 KiB), entries + 2

The margins absorb CI's Node 24 (~800 bytes larger packed). When intended growth reaches a limit, re-measure every package and reset the whole table by the policy instead of raising one by the overshoot. The per-PR history comments are gone; the commit history keeps them. Entries limits were tightened to measurement + margin (e.g. mcp 31 -> 14, store-schema 12 -> 9). docs/DEVELOPMENT-PIPELINE.md describes the policy.

Package Measured packed / unpacked / entries Budget
core 1047859 / 4132700 / 531 1048 KiB / 4116 KiB / 542
audit 27418 / 89089 / 26 33 / 111 KiB / 28
auth 20313 / 63962 / 14 26 / 87 KiB / 16
store 144031 / 560117 / 34 155 / 602 KiB / 36
mcp 33066 / 136737 / 12 39 / 158 KiB / 14
store-schema 11896 / 45543 / 7 18 / 69 KiB / 9

npm run verify and npm run test:package pass locally (Node 26).

🤖 Generated with Claude Code

…mand; budgets as measurement plus margin (#971)

The test deleted the store_servers lease while the serving store's heartbeat
kept renewing it, so a beat between the DELETE and the operator fence re-inserted
the lease and refused deleteOwnerless. Closing the store stops the heartbeat and
removes its lease deterministically.

Package budgets are now each package's measurement plus a fixed margin (core
24 KiB packed, 2% unpacked and entries; add-ons the larger of 10% and
6/24 KiB, plus two entries), with one policy comment replacing the per-PR
history, so routine growth no longer edits the same lines in every PR.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@jimhoyd
jimhoyd enabled auto-merge (squash) September 29, 2026 21:55
@jimhoyd
jimhoyd merged commit fc345d7 into main Sep 29, 2026
26 checks passed
@jimhoyd
jimhoyd deleted the claude/flake-and-budgets branch September 29, 2026 22:03
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.

Flaky store test: operator-audit's final deleteOwnerless races the server lease heartbeat

1 participant