Public: anyone can read this; the crew can change it.

One person reloading app pages cannot evict other people's panel proofs #15203

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

One signed-in person reloading app pages can no longer push other people's panel proofs out of memory. Until now that would get those people's notes filed as visitor notes. Proofs are now capped per bind (one grant cookie on one host), so minting past the cap evicts only that bind's own oldest proofs.

Notes

shipped production is serving it deploy cfe12e4

opened this

One signed-in person reloading app pages can no longer push other people's panel proofs out of memory. Until now that would get those people's notes filed as visitor notes. Proofs are now capped per bind (one grant cookie on one host), so minting past the cap evicts only that bind's own oldest proofs.

What changed in src/apps/feedback.ts:

  • Per-bind cap: each bind keeps at most its newest 32 proofs (PROOF_PER_BIND), tracked in a new list per bind.
  • Expired first: every proof has the same 24-hour lifetime, so the oldest ones in the map expire first. Each mint clears the expired ones from the front before any live proof is evicted. This costs only as many steps as there are expired proofs.
  • Global cap kept: PROOF_MAX (20,000) is still enforced last, so memory stays bounded. One person would now need about 625 separate grant cookies to reach it.
  • spendProof, PROOF_MAX, PROOF_PER_BIND and a small proofsHeld() count are exported so the tests can reach them.

What to look at: whether 32 is a good number of open tabs to cover per bind. A tab opened before its bind's 32 newest proofs falls back to visitor on its next note.

test/feedback-proof.test.ts (new) covers:

  • one bind minting past the global cap while another bind's proof still spends;
  • a bind keeping only its newest proofs;
  • the same grant on another host counting as a separate bind;
  • expired proofs being swept on the next mint;
  • the global cap holding across many binds.

Against main's feedback.ts, the first two tests fail, as the issue asks. The other three pass there too, since main also bounds memory and, in that test, evicts the expired proof as the oldest.

How to try it: bun test test/feedback-proof.test.ts test/toolbar-where.test.ts test/apps-feedback.test.ts — all 49 tests pass. bun scripts/gate.ts --fix and bun x tsc --noEmit both report nothing. I didn't update the issue's plan with keep_plan, because that tool isn't available in this session.

🤖 Generated with Claude Code

Closes #15201

commented

One signed-in person reloading app pages can no longer push other people's panel proofs out of memory. Until now that would get those people's notes filed as visitor notes. Proofs are now capped per bind (one grant cookie on one host), so minting past the cap evicts only that bind's own oldest proofs.

What changed in src/apps/feedback.ts:

  • Per-bind cap: each bind keeps at most its newest 32 proofs (PROOF_PER_BIND), tracked in a new list per bind.
  • Expired first: every proof has the same 24-hour lifetime, so the oldest ones in the map expire first. Each mint clears the expired ones from the front before any live proof is evicted. This costs only as many steps as there are expired proofs.
  • Global cap kept: PROOF_MAX (20,000) is still enforced last, so memory stays bounded. One person would now need about 625 separate grant cookies to reach it.
  • spendProof, PROOF_MAX, PROOF_PER_BIND and a small proofsHeld() count are exported so the tests can reach them.

What to look at: whether 32 is a good number of open tabs to cover per bind. A tab opened before its bind's 32 newest proofs falls back to visitor on its next note.

test/feedback-proof.test.ts (new) covers:

  • one bind minting past the global cap while another bind's proof still spends;
  • a bind keeping only its newest proofs;
  • the same grant on another host counting as a separate bind;
  • expired proofs being swept on the next mint;
  • the global cap holding across many binds.

Against main's feedback.ts, the first two tests fail, as the issue asks. The other three pass there too, since main also bounds memory and, in that test, evicts the expired proof as the oldest.

How to try it: bun test test/feedback-proof.test.ts test/toolbar-where.test.ts test/apps-feedback.test.ts — all 49 tests pass. bun scripts/gate.ts --fix and bun x tsc --noEmit both report nothing. I didn't update the issue's plan with keep_plan, because that tool isn't available in this session.

🤖 Generated with Claude Code

commented

Panel proofs are now capped per bind (one grant cookie on one host). One person reloading evicts only their own oldest proofs, and other people's notes keep their names instead of being filed as visitor notes.

What changed in src/apps/feedback.ts:

  • One map, keyed by bind. The existing proofs map (already in the module-state baseline) now holds each bind's proofs, oldest first, with a held counter for the total. The extra module-level map and the test-only export from the first push are gone; those were the two red tests.
  • Per-bind cap. Each bind keeps its newest 32 proofs (PROOF_PER_BIND). On each mint, that bind's own expired and oldest proofs are dropped first.
  • Global cap. PROOF_MAX (20,000) still bounds memory. When it is full, expired proofs across all binds are swept first. Only then does the bind that minted least recently give up its oldest proof.
  • Cheap at the cap. The full sweep only runs once the soonest expiry has passed. Without that limit, filling to the cap took about 10 s in the test.
  • Behaviour change: spendProof looks the token up under the caller's bind. A token presented with the wrong cookie or host is refused as before, but it is no longer used up for its real owner.

test/feedback-proof.test.ts (new) checks that:

  • one bind minting past the global cap leaves another bind's proof spendable;
  • a bind keeps only its newest proofs;
  • a proof spends once, and only for its own grant and host;
  • the same grant on another host counts as another bind;
  • the global cap evicts from the least recent bind;
  • an expired proof is swept before a live one is evicted.

Against main's code, the first two tests fail (I ran them there). I expect the sweep test to fail there too, but I haven't run it.

To try it: bun test test/feedback-proof.test.ts test/module-state.test.ts test/unused-exports.test.ts test/toolbar-where.test.ts test/apps-feedback.test.ts — all 56 pass. bun scripts/gate.ts --fix and bun x tsc --noEmit report nothing.

🤖 Generated with Claude Code

Approved

Approved. Proofs are now held per bind (grant cookie + host), newest 32 kept; a mint past the cap drops only that bind's own expired and oldest proofs. At the global cap, expired proofs are swept (gated by a soonest-expiry lower bound so it is not O(n) per mint) before the least-recently-minted bind gives up its oldest. The preview answers 200; the change is server-internal with no page or terminal surface, so no TUI screen or docs/features page is owed, and README is untouched. Identity and cookie handling are unchanged; a wrong-bind spend is refused and no longer burns the real owner's token.

Two things I would do next: (1) spendProof and PROOF_MAX/PROOF_PER_BIND are exported only for the test; consider a narrower test seam or confirm the unused-exports check is happy long term. (2) Eviction at the global cap takes the least recent bind's oldest live proof, so a flood of many distinct grant cookies can still evict others; rate-limiting panel loads by socket address would close that.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs