Repository navigation
Description
Context
Found while auditing ui-server for #4169. It is the same bug class as #4169 and the second review finding on #4168: an authority check inside a write-worker procedure compares a login's expiry against a time the caller stamped before it waited for the writer. Any time spent queued behind other writes falls outside the check, so a login that expires while the request waits still passes. Revocation is unaffected in each case, because it is read from the row inside the transaction.
Three sites, observed from the code only (no reproduction run yet):
- Session worker-profile writes.
saveandbindstampDate.now()on the app side and submit it to the writer (submit("save", …),packages/ui-server/src/ws/session-profiles.ts:93;write(sessionId, { bind: … }, "bind", …),packages/ui-server/src/ws/session-profiles.ts:111). Inside the transaction,saveProfileandbindDraftProfilecallauthorizeProfile(db, principalId, now)with that stamp (bindDraftProfile,packages/ui-server/src/ws/session-profile-writes.ts:32-34;saveProfile,packages/ui-server/src/ws/session-profile-writes.ts:56-59). - Push subscription binding.
subscribestampsDate.now()(subscribe,packages/ui-server/src/activity/push-sender.ts:213) and the worker'sINSERT … SELECT … WHERE expires_at > ?checks the target login against it (subscribe,packages/ui-server/src/activity/push-writes.ts:21-28). A login that expired while queued can still bind a device. - Storage notice dispatch.
deliverStoragecallsnotices.begin(sub.endpoint, at ?? Date.now())(deliverStorage,packages/ui-server/src/activity/push-sender.ts:307-316), and the worker'sbegindecides the recipient withowner(sub.principal_id, now)against that stamp (begin,packages/ui-server/src/storage/notify-writes.ts:41-58).
#4169 fixed the reference-grant case by reading the clock at the check inside the writer transaction and keeping the stamp for recorded timestamps and retention.
Scope
At each of the three sites, check principal usability against the clock read at the check inside the writer transaction. Keep the stamped time wherever it records a timestamp (updated_at, created_at, receipt times), drives retention or cleanup, or orders time (the storage notifier's reversed-clock guard and its eligibility windows).
Out of scope
Reference grants (#4169), chat deletion (#4168), safety reviews (they already read the clock inside their transaction), checks run synchronously before any await (route guards, authGuard), and any change to profile, push or storage-notice semantics.
Acceptance criteria
- At each of the three sites, a login that is usable when the request is stamped but expires before the writer runs is refused (profile writes:
SessionProfileError401; subscribe: returns false and binds nothing; storage notice:beginreturns null and records no attempt). Each is proven by a real-SQLite test that holds the writer and fails before the change. - Recorded timestamps and retention still use the stamped time, proven by the same tests or by existing ones.
Verification
Run each failing-first held-writer test. A mutation back to the stamp must fail it. packages/ui-server/tests/reference-grants.test.ts ("reference grant creation behind a held writer") shows the held-writer pattern.
Contract impact
None: no shape changes. A request that previously succeeded on an expired login is now refused.
Activity
schlessera commentedon Nov 17, 2026
Decision (maintainer, 2026-11-17):
priority: p2, in 0.45.0.schlessera commentedon Nov 17, 2026
Claimed for implementation. Claim token:
claim-7bdbda1a. Branch:fix/4176-writer-clock-expiry.collisions: closure-only overlaps with open ui-server PRs (incl. #4177, same bug class); no path collisions
fix(ui-server): check login expiry against the clock inside the write…
schlessera commentedon Nov 17, 2026
Merged in #4181 as
1cd5fd474through the integration lease (orchestrator merge queue for 0.45.0). Candidate confirmation passed on the exact head; the squash's own main run carries the post-merge heavy categories.