fix(session): prevent saves failing for long session IDs - #476
fix(session): prevent saves failing for long session IDs#476henkterharmsel wants to merge 1 commit into
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 27, 2026, 2:48 PM ET / 18:48 UTC. ClawSweeper reviewWhat this changesThe PR changes atomic session-write temporary paths to use a short unique sibling basename and adds regression coverage for long valid session filenames. Merge readinessThis PR remains necessary: current Priority: P2 Review scores
Verification
How this fits togetherACPX persists agent session records through a local file session store. A save writes JSON to a unique temporary file beside the destination and atomically renames it into the persistent session record. flowchart LR
Session[Agent session update] --> Store[File session store]
Store --> Destination[Session JSON destination]
Destination --> Temp[Unique sibling temp file]
Temp --> Rename[Atomic rename]
Rename --> Record[Persisted session record]
Before merge
Agent review detailsSecurityNone. Review metrics
Technical reviewBest possible solution: Merge the bounded same-directory temporary-name approach once the remaining required checks complete, keeping the UUID uniqueness and existing atomic-rename boundary unchanged. Do we have a high-confidence way to reproduce the issue? Yes from source inspection: current Is this the best way to solve the issue? Yes. A short hidden sibling basename preserves the same-filesystem atomic rename boundary, PID/timestamp diagnostics, and UUID uniqueness without imposing a new session-ID limit or changing persisted destination names. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 504040facb19. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
68ca211 to
dc67122
Compare
Related: #447
What Problem This Solves
Fixes an issue where users with long but valid ACPX session identifiers could see session persistence fail with
ENAMETOOLONGafter the collision fix in #447. Appending PID, timestamp, and UUID to the full destination basename can exceed the common 255-byte filesystem component limit even when the destination itself is valid.Why This Change Was Made
Atomic writes now create a bounded sibling temporary basename in the destination directory. This preserves same-filesystem atomic rename behavior, PID/timestamp diagnostics, and per-write UUID uniqueness without extending the destination basename.
User Impact
Long valid session identifiers remain persistable while concurrent writes continue to use collision-resistant temporary paths.
Evidence
TMPDIR=/var/tmp PATH=/tmp/codex-corepack-bin:$PATH corepack pnpm run checkpasses:codex review --base upstream/mainreported no findings.Real behavior proof
Behavior or issue addressed: A valid 220-byte session identifier must remain writable through the real file session store while concurrent writes use distinct temporary files.
Real environment tested: Linux x86_64 checkout of this branch using Node 24.18.0 and pnpm 10.34.5. The probe imported the built production
createFileSessionStoreimplementation directly; it did not use mocks or snapshots.Exact steps or command run after this patch:
corepack pnpm run build.Date.now()so all writes shared one millisecond.acpxRecordId.store.save(record)calls..tmpfiles.Evidence after fix:
Observed result after fix: All 400 writes completed without an exception. The long-ID session remained readable, exactly one JSON destination remained, and no temporary files leaked.
What was not tested: Windows and macOS were not tested locally. The same-directory and basename-length behavior is covered through Node's platform path API and CI can provide cross-platform validation.
AI-assisted disclosure
This PR is AI-assisted. I reviewed the implementation and understand that only the private temporary basename changes; the destination path, atomic rename boundary, and UUID uniqueness remain unchanged.