Repository navigation
refactor(sessions): retire runtime transcript sidecars - #117380
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 1, 2026, 9:02 AM ET / 13:02 UTC. ClawSweeper reviewWhat this changesThe branch moves runtime transcript-write coordination to SQLite leases, confines retired JSONL sidecar inspection to Doctor, and preserves file-lock behavior through the existing Plugin SDK runtime entrypoint. Merge readinessThis PR is still necessary: current Priority: P2 Review scores
Verification
How this fits togetherAgent turns and compaction need an exclusive coordinator before they update a session transcript, while gateway startup marks interrupted main sessions for recovery. The branch makes the SQLite state lease the runtime coordinator, leaving legacy JSONL lock files only for Doctor repair and Plugin SDK file-artifact compatibility. flowchart LR
A[Agent turn or compaction] --> B[Session write coordinator]
B --> C[SQLite state lease]
C --> D[Transcript database write]
E[Gateway startup] --> F[SQLite orphan recovery]
G[Legacy JSONL lock file] --> H[Doctor inspection and repair]
I[Plugin SDK file caller] --> J[File-lock compatibility adapter]
Decision needed
Why: The branch changes both persisted session coordination and a shipped plugin-facing runtime contract. The implementation direction is coherent, but choosing and validating that enduring boundary requires maintainer intent plus the repository-mandated dependency/Codex inspection. Before merge
Agent review detailsSecurityNone. PR surfaceSource -691, Tests -1533, Generated 0, Other -2. Total -2226 across 27 files. View PR surface stats
Review metricsNone. Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep one canonical SQLite lease flow for runtime transcript writes, retain the public SDK file-artifact contract only at its explicit compatibility boundary, and obtain the required direct Codex and fs-safe contract checks before maintainer acceptance. Do we have a high-confidence way to reproduce the issue? Yes for the source-level behavior: current main still acquires JSONL sidecar locks and gateway startup consumes sidecar cleanup for restart marking, while the branch removes those paths. A live upgrade run was not repeated in this read-only review. Is this the best way to solve the issue? Unclear pending maintainer acceptance and direct contract inspection. Reusing the existing SQLite lease primitive and isolating legacy artifacts behind Doctor is the cleaner owner boundary, but the SDK and lifecycle compatibility claims need the required source proof. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against f5989ea1f64c. 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 (1 earlier review cycle)
|
|
Merged via squash.
|
Summary
.jsonl.lockinspection and repair behind doctor onlyRepair
Root cause: core had two ownership systems for one transcript: canonical SQLite state plus JSONL sidecar locks. Startup then rediscovered the sidecars, reclaimed them, and inferred restart recovery state from the cleanup result. This duplicated lifecycle policy and allowed lock files to become an indirect source of session truth.
Architectural owner:
src/agents/session-write-lock.tsnow owns logical session writes through the existing state-lease table.src/commands/doctor-session-lock-files.tsowns legacy sidecar diagnosis/migration.src/plugin-sdk/session-write-lock-runtime.tsis the compatibility boundary for shipped external file-artifact callers.Canonical fix: runtime callers use one SQLite lease keyed by the typed transcript target. Gateway startup records orphan recovery directly from authoritative SQLite rows before channels start. Doctor can still inspect and identity-fence old
.jsonl.lockremoval. The SDK adapter preserves file locking, reentrancy, symlink canonicalization, stale recovery, abort admission, max-hold watchdog, and synchronous signal cleanup.Removed paths:
sidecars.session-locksstartup sweepsrc/agents/sessions/storage-lock.tsCompatibility and contracts
agent-harness-runtimesignature remains the public seam.jsonl.lockrepair remains available through doctor, and doctor intentionally ignores retired holdermaxHoldMs@openclaw/fs-safe0.5.0 file-lock, sync-lock, and sidecar-lock sources for payload factories, reentrancy, snapshot-fenced removal, and exit cleanup../codex/codex-rs/app-server/src/request_processors/turn_processor.rs:477-617and compaction submission at../codex/codex-rs/app-server/src/request_processors/thread_processor.rs:1868-1878; the lease continues to surround the existing turn/compaction lifecycle rather than changing that protocolLOC
Handwritten production: 862 added / 1,515 removed = net -653 LOC. Tests and generated manifests are counted separately.
Proof
pnpm check:changedpassed, including core/extension types, SDK contracts, dead exports, database-first guard, import cycles, and lintpnpm buildpassedCurrent-main integration and review disposition
ClawSweeper's two rank-up moves are satisfied as follows:
f92449f6fba63c3ec54d1dda6d187510ee9a8182with main checkpoint142ad75c433692d8ffaf80585d6bb66a553c9cd2was conflict-free and produced exact tree692009100cbdaac5dedba1c4a0b00c2d39cc2058. That tree preserved both sides of the only overlapping production file (doctor-auth-migration-receipts.ts) and all four expected SDK baseline entries. On the exact combined tree, 297 focused tests,pnpm plugin-sdk:surface:check, and the fullpnpm check:changedgate passed: Blacksmith Testbox run (tbx_01kyymm0yq1xhev0xzad6z7wsv). Main subsequently advanced tob5a59e0a7d948a8b9021b97ab5c66248f12303d2, with zero overlap across the 27 paths touched by this PR. No rebase or code-resolution commit is needed: the only relevant moving-main integration was already tested as an exact merge tree, and later drift is disjoint.@openclaw/fs-safe0.5.0 preserves per-attempt payload creation, explicit-owner reentrancy, realpath canonicalization,O_EXCLacquisition, fsync, identity/snapshot-fenced release and stale reclaim, manager drain/reset, and synchronous exit cleanup. Sibling Codex routes both turns and compaction into the same session submission loop:codex-rs/app-server/src/request_processors/turn_processor.rs:339-355,476-619,codex-rs/app-server/src/request_processors/thread_processor.rs:1875-1886,codex-rs/core/src/codex_thread.rs:226-228,274-330,470-474, andcodex-rs/core/src/session/mod.rs:766-837. This PR keeps the lease around that existing lifecycle; it does not alter Codex protocol/runtime behavior.The merged-result proof specifically retained the PR's synchronous lock helper at the migrated doctor receipt call sites plus current main's
recordLegacyMigrationRun/recordLegacyMigrationSourcebehavior. It also retained the expectedagent-harness-runtime,channel-status,discord, andstatus-helpersSDK hashes.Independent adversarial review additionally exercised separate real Node processes: a holder acquired the lock, a contender returned stable
OPENCLAW_SESSION_WRITE_LOCK_TIMEOUT, the holder was killed withSIGKILL, and a fresh writer reacquired and released the UUID lease with zero.jsonl.lockfiles left behind. Hosted CI independently covers the state lease's spawned-child cross-process path.