Repository navigation
fix(identity): prevent cross-runtime device identity races - #120643
Conversation
eb6345e to
5c592d2
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
|
Codex review: needs maintainer review before merge. Reviewed August 8, 2026, 4:48 PM ET / 20:48 UTC. ClawSweeper reviewWhat this changesThe PR makes Node and Swift acquire the same ordered temporary and selected-state SQLite coordinator locks before creating or migrating a shared device identity. Merge readinessKeep open for protected maintainer review. The PR remains necessary: current main still lets Node and Swift coordinate the same identity database through different lock locations, while the proposed ordered bridge unifies that boundary without a schema or config change. Priority: P2 Review scores
Verification
How this fits togetherNode and OpenClawKit can use one selected state tree containing the device identity database. Coordinator locks serialize initialization and migration so both runtimes preserve one stable device identity. flowchart LR
A[Node runtime] --> C[Ordered coordinator locks]
B[Swift runtime] --> C
C --> D[Selected state tree]
D --> E[Device identity database]
E --> F[Stable device identity]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +59, Tests +199, Other +129. Total +387 across 15 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep one canonical ordered coordinator contract in both runtimes, retain the temporary lock only as the bounded rolling-upgrade bridge, and land after current-base cross-runtime coverage is green. Do we have a high-confidence way to reproduce the issue? Yes, from source: current Node and Swift select different coordinator locations for the same identity database, and the focused tests exercise the dual-lock bridge and its cleanup path. Is this the best way to solve the issue? Yes. A single ordered cross-runtime coordinator with a temporary compatibility bridge fixes the owner boundary; dropping either lock immediately would leave either older binaries or alternate state trees unprotected. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 51960f65794e. LabelsLabel justifications:
EvidenceWhat 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 (3 earlier review cycles) |
add86a3 to
b3e1829
Compare
b3e1829 to
abf6668
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Merged via squash.
|
…120643) * fix(identity): coordinate SQLite ownership across runtimes * fix(ci): route changed-scope fixture tests
What Problem This Solves
Fixes an issue where users running the TypeScript and Swift runtimes against the same selected state tree could have each runtime coordinate device identity SQLite ownership through a different lock database. During mixed-version upgrades or alternate state-directory use, that split ownership could allow overlapping initialization and produce mismatched device identities.
Why This Change Was Made
The selected state tree now owns the canonical coordinator under
tmp/openclaw-<uid>. For rolling upgrades, both runtimes first acquire the shipped process-temporary coordinator and then the state-local coordinator, release them in reverse order, and unwind every acquired coordinator if a later acquisition fails. A shared ordered JSON fixture pins the full cross-language path and hash contract, and CI routes fixture-only changes through both Node and OpenClawKit coverage. The bridge preserves interoperability with the shipped process-temporary owner without migrating or deleting coordinator files, and it does not change the SQLite schema or schema version. This change was AI-assisted and reviewed before publication.User Impact
Users can run mixed TypeScript/Swift deployments and rolling upgrades without the two runtimes independently claiming the same device identity database. Existing installations require no configuration change or migration, and the device identity remains stable across the upgrade boundary.
Evidence
node scripts/run-vitest.mjs src/infra/device-identity-coordinator.contract.test.ts src/infra/device-identity.test.ts src/infra/device-identity.state-dir.test.ts src/infra/state-migrations.device-identity.test.ts src/infra/gateway-lock.state-dir.test.ts src/scripts/ci-changed-scope.test.ts src/scripts/ci-changed-scope.contract-fixtures.test.ts— 55 infrastructure tests and 38 tooling tests passed.node scripts/run-vitest.mjs test/scripts/test-projects.test.ts --testNamePattern 'keeps CI, dependency, and docs tooling edits on owner tests'— the exact CI routing assertion passed after registering the new fixture suite with its tooling owner.DEVELOPER_DIR=/Applications/Xcode-beta.app/Contents/Developer swift test --package-path apps/shared/OpenClawKit --filter DeviceIdentityCoordinatorContractTests— 1 test passed.DEVELOPER_DIR=/Applications/Xcode-beta.app/Contents/Developer swift test --package-path apps/shared/OpenClawKit --filter DeviceIdentityStoreTests— 37 tests passed.pnpm tsgo:core,pnpm tsgo:core:test,pnpm tsgo:scripts, targeted Oxlint/oxfmt, SwiftFormat, andgit diff --checkpassed.checks-node-compact-small-2; commitadd86a3e6de8623fed90060fa7c83570c7c20871fixes that deterministic PR-owned failure. A new exact-head hosted run is required before landing.node scripts/check-changed.mjsdelegation could not acquire a Crabbox/Testbox provider; its prescribed trusted-source local fallback passed.