Files
amethyst/quartz/src
Claude f52b07865e fix(cordn): six audit findings — retirement, capabilities, idle clock
An audit of this branch turned up ten findings. These are the six that
are small and unambiguous; the other four are design-level and are
written up separately rather than fixed in passing.

- The fixture coordinator's `join_request_store` stored `at = clock++`
  and returned `clock`, so the value a caller acked with was always one
  past the value stored. Nothing could ever be retired.
- `join_request_take_many` ignored `consumed` outright, which made
  retirement a no-op in every fixture-backed test: an answered request
  came back forever and no test could notice. It now retires exactly as
  `welcome_take` beside it does.
- `pendingWelcomes` passed `drainRetirements()` inline, emptying the
  queue before the call it rode on. A failing `takeWelcomes` dropped
  those acks permanently and the coordinator kept re-serving consumed
  Welcomes. The join-request path already re-queued on failure; this
  matches it.
- A cordn last-resort KeyPackage carries its marker inside
  `app_data_dictionary` (0x0006) but advertised leaf capabilities that
  did not include it. `CordnGroupPolicy.lastResortLeafCapabilities()`
  existed for precisely this and was called from nowhere.
- `OpenStreamReceiver.lastActivityMs` started at 0, so against a real
  clock `needsProbe()` was true from construction — thirty-odd years
  idle before the first frame. Only a test calls it today, which is why
  it went unnoticed.
- `KeyStoreCordnBlobCipher` serialised every cordn KeyStore encrypt and
  decrypt behind a lock whose justification no longer holds:
  `KeyStoreEncryption` keeps its `Cipher` in a `ThreadLocal` now, so the
  init/doFinal pair cannot interleave and the lock only cost
  concurrency. The KDoc explaining the old hazard is replaced by one
  explaining why there is no longer a lock.

Incidental, from the merge: `EXTERNAL_SENDERS_EXTENSION_TYPE` was 0x0004,
the same value as `EXTERNAL_PUB_EXTENSION_TYPE`. RFC 9420 §13.3 assigns
it 0x0005.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012BfD4txdnsaPRXmNXbup9n
2026-09-23 23:28:46 +00:00
..