Repository navigation
fix: keep device identity reads lock-free - #124745
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
* refactor(imports): dedupe and hoist imports * feat(lint): enforce import/no-duplicates and import/first
…n session (#124708) * feat(voice-call): add sessionScope "main" for main-session call routing Inbound and outbound calls can now share the configured agent's main session instead of a dedicated voice session. The new scope resolves through the existing explicit-key canonicalization path, honoring core session.mainKey and global-scope aliasing. The inbound webhook path now forwards coreSession like every other resolver call site. * style: format events.test.ts * test(voice-call): split events.test.ts under the max-lines cap
|
Codex review: needs maintainer review before merge. Reviewed August 17, 2026, 2:11 AM ET / 06:11 UTC. ClawSweeper reviewWhat this changesThis PR changes persisted device-identity reads so read-only consumers do not create coordinator locks and can treat a genuinely empty concurrent SQLite bootstrap as temporarily identity-less. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readinessKeep open for maintainer review. Current main proves the lock-creating read path, but the exact PR head and merge result could not be inspected because its promised Git objects are absent locally and GitHub DNS was unavailable; the protected Likely related people
Priority: P2 Review scores
Verification
How this fits togetherDevice identity lets CLI, Doctor, Gateway probes, and node tooling authenticate or inspect pairing state. These consumers read the shared SQLite state database and then either attach an existing identity or report that none is available. flowchart LR
Consumer[CLI, Doctor, or Gateway probe] --> Lookup[Device identity lookup]
Lookup --> ReadOnly[Read-only state database access]
ReadOnly --> Check{Identity table available?}
Check -->|identity row| Identity[Return validated identity]
Check -->|empty bootstrap| Miss[Return temporary absence]
Check -->|partial or corrupt state| Fail[Fail closed]
Identity --> Client[Authentication or diagnostics]
Miss --> Client
Decision needed
Why: The available metadata conflicts sharply on scope, and read-only SQLite behavior affects authentication-adjacent consumers; automated review cannot establish the actual merge surface without the unavailable PR head. Before merge
Findings
Agent review detailsSecurityNeeds attention: The dependency guard reports package-manifest and lockfile changes outside the stated repair, and the unavailable exact merge result prevents a supply-chain clearance. Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Produce a current merge-result diff containing only the intended identity/read-only-storage repair, keep empty-bootstrap classification in the shared read-only SQLite boundary, and prove exact-head behavior for missing, concurrent-empty, valid, and corrupt database states. Do we have a high-confidence way to reproduce the issue? Yes, from source: Is this the best way to solve the issue? Unclear: moving this behavior to the shared artifact-preserving read-only SQLite boundary is the right architectural direction, but the exact PR implementation and its one-snapshot bootstrap classification could not be inspected. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against b097d64574be. LabelsLabel justifications:
EvidenceSecurity concerns:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (4 earlier review cycles)
|
Co-authored-by: Amp <[email protected]>
* feat(codex): register additional session homes * fix(codex): preserve automatic session homes * docs(codex): explain automatic home discovery around sessionCatalog.homes --------- Co-authored-by: IWhatsskill <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
#124724) * fix(ui): keep Control UI device identity working on plain-HTTP origins @noble/ed25519 defaults its SHA-512 provider to crypto.subtle, which browsers gate to secure contexts, so device identity silently vanished on http:// LAN dashboards and connects fell back to shared-credential auth with no pairing. Wire a lazy pure-JS @noble/hashes fallback for SHA-512 and the fingerprint SHA-256, and drop the isSecureContext gate in the connect path. Secure contexts keep the platform digests and pay no startup bytes: the fallback loads as its own lazy chunk, kept out of the gateway-runtime startup chunk on purpose. * test(ui): cover device identity minting and signing without crypto.subtle New jsdom regression suite fails on pre-fix code (subtle-less crypto stub with getRandomValues, which real insecure contexts keep). Rewrites the gateway connect tests that previously asserted the device-less insecure fallback: an insecure context now attaches a device identity. * docs(web): plain-HTTP dashboards now pair with a device identity The signing key never crosses the wire, so HTTP+pairing is strictly stronger than the old HTTP token-only fallback; HTTPS (Tailscale Serve) stays the recommendation for transport privacy. * fix(ui): drop unnecessary boolean literal compare in secure-context timing meta * test(ui): declare device.id on the connect-frame test shape * test(ui): split the subtle-less scope-upgrade e2e into the two real invariants Without crypto.subtle the browser can now sign, so the banner offers the explicit admin upgrade; manual-only guidance is reserved for browsers that cannot mint an identity at all (no WebCrypto RNG). Also corrects the connect-path comment: blocked storage yields an ephemeral identity, only a failed mint degrades device-less. * fix(ui): address review findings on the HTTP device-identity path - Storage-blocked pages keep one stable in-memory identity per page lifetime instead of minting a fresh unpaired key on every reconnect, and a write-rejecting store no longer fails the mint (regression tests bite pre-fix). - Connect timing now reports the real browser secure-context fact via a shared browserSecureContext() helper instead of inferring it from device-identity presence. - Docs state the accepted trusted-proxy contract: browsers attach a device identity on every origin, so first connects follow the standard pairing flow (deviceAutoApprove or a one-time approval); device-less admission remains only for browsers that cannot mint an identity. * refactor(ui): trim the connect-path additions under the max-lines cap
…24464) A LINE push made exactly one attempt, so a transient provider or transport failure dropped the reply even though retrying was safe to do. Retrying alone would have duplicated a send LINE already accepted, so every push now carries an X-Line-Retry-Key and reuses it across attempts: LINE answers a replayed key with 409 and the accepted request's sent messages, which resolves to the original delivery instead of a second message. Retries follow LINE's documented policy - server errors and transport failures only, never 2xx, 409 or any 4xx - and run through the shared channel API retry runner in strict mode. Replies stay single-attempt because LINE offers no retry key for them.
… abort (#124756) * fix(outbound): record queue-write loss and fail every payload on prep abort Two silent-observer gaps in the outbound queue admission path: 1. Best-effort staging/queue-write failures were swallowed with a bare 'return null'. The send proceeded live-only, so a crash mid-send lost the message with zero forensic trace of why the write-ahead row was missing. Every sibling degradation on this boundary logs (persistQueuedPreSendState, the dispatch-refresh fallback); this one now warns with channel/target and the error. 2. Batch preparation failure emitted message_sent for only the first payload while audit emitted per-payload terminals, so plugins with message_sent hooks saw 1 failure for an N-payload batch. The failure path now emits one hook failure per logical payload, matching the audit terminals and the recovery sibling's queuedTerminalFailureEvents. The unused error.payload pick and its OutboundPayloadPreparationError import went with it. Regressions: queue-write warn asserted in the existing best-effort fallback test; new multi-payload prep-failure test asserts 2 hook failures. Both fail pre-fix. * chore(outbound): keep OutboundPayloadPreparationError module-local Last external consumer went away with the per-payload emit; the deadcode:exports gate rejects unused exports.
…4754) * refactor(gateway): drop dead session-subscriber registry surface getForConnection and both registry clear() methods had no production callers — only server-chat-state.test.ts consumed them (verified by repo-wide grep incl. plugin-sdk). The recency-sorted connToSessionKeys index existed solely so getForConnection returned keys in subscription order, an ordering nothing read, rebuilt via toSorted() on every subscribe/unsubscribe/settle — including the provisional-replay settle path. unsubscribeAll now reads the reverse index directly from connToSessionRecency's keys (same contents, no ordering), removing the per-call O(k log k) rebuild and the duplicate map. Tests assert through get()/getApprovals(), the production read paths, per test-audit norms. Behavior-neutral: subscription state transitions and event-visible delivery unchanged; chat-state, broadcast, node-subscription, instance-runtime, agent-events, session-events suites pass. * test(gateway): fix ETXTBSY flake in workspace-sync candidate bounding The test rewrote its mock git script between two createGitTransferList calls. On Linux CI the second spawn can race a lingering fork of the first child still holding the script's write fd, failing exec with ETXTBSY. Write the script once; vary the entry count through a data file the script reads instead.
* fix(openai): centralize setup auth metadata * refactor(openai): overlay auth hooks in place
|
Merged via squash.
|
What Problem This Solves
Fixes an issue where read-only device identity checks could create coordinator lock state and serialize behind identity writers. A concurrent first-time database creator could also expose an empty SQLite bootstrap snapshot that made the read fail before schema creation committed.
Why This Change Was Made
Read-only identity lookup now opens the state database without taking the identity coordinator. It treats only a truly empty bootstrap database with a missing
device_identitiestable as a temporary miss; partial or corrupt schemas still fail closed. Identity creation and migration remain coordinator-owned, and no SQLite schema or version changes are included.AI-assisted: yes.
User Impact
Doctor and other read-only device identity consumers no longer create lock files or wait behind identity creation. Concurrent first-start reads safely return no identity until the creator commits, then observe the authoritative identity.
Evidence
Node 24.15.0 focused validation:
src/infra/device-identity.test.ts: 23 passed, including no-write, bootstrap concurrency, authoritative winner, and corrupt-row behavior.src/infra/state-migrations.device-identity.test.ts: 26 passed.src/infra/startup-migration-checkpoint.test.ts: 17 passed.src/node-host/startup-state-migrations.test.ts: 6 passed.src/commands/doctor-device-pairing.test.ts: 9 passed.git diff --checkpassed.check:changedclassification was attempted but its delegated Crabbox binary failed local sanity checks; the focused Node 24 tests and direct format/lint gates above were run instead. Codex autoreview was unavailable; a final diff review found no P0-P2 findings.