feat: [ENG-2065] dream state + log services#378
Conversation
Add dream infrastructure persistence layer: - dream-state-schema.ts: DreamStateSchema, PendingMergeSchema, EMPTY_DREAM_STATE - dream-log-schema.ts: DreamOperationSchema (CONSOLIDATE/SYNTHESIZE/PRUNE), DreamLogEntrySchema (completed/partial/error/processing/undone) - dream-state-service.ts: fail-open read, atomic write, incrementCurationCount - dream-lock-service.ts: PID-based lock with stale detection and write-then-verify - dream-log-store.ts: atomic save, Zod validation, monotonic IDs, stale processing resolution, pruning beyond maxEntries 79 tests passing, 0 type errors.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6ebf4ff97c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
- DreamStateService.read(): spread pendingMerges as new array to avoid mutating EMPTY_DREAM_STATE module constant - DreamLockService.tryAcquire(): add mkdir guard before writeFile to handle fresh projects where baseDir doesn't exist yet
|
Claude finished @RyanNg1403's task in 4m 15s —— View job PR Review: feat: [ENG-2065] dream state + log servicesTasks
Overall: 4/5Well-scoped persistence layer — clean atomic writes, solid fail-open semantics, good path-traversal prevention, and the two correctness bugs from the first review pass ( What's still open
What's good
Minor observations (no action required)
|
- isProcessAlive: treat EPERM as alive (process exists, lacking permission) - SynthesizeOperationSchema: constrain confidence to [0, 1]
|
Claude finished @RyanNg1403's task in 2m 41s —— View job PR Review: feat: [ENG-2065] dream state + log servicesTasks
Overall: 4.5/5The two must-fix issues from the prior review round have both landed cleanly in What was fixed since last review
Still open (nitpicks / suggestions only)
None of the above block merge. All are carryovers from the prior review; none are regressions introduced by the fixup commits. What's solid
|

Summary
src/server/infra/dream/— Zod schemas for state and log entries, a fail-open state service, a PID-based lock service, and a file-based log store. AddedDREAM_LOG_DIRandDREAM_LOG_ID_PREFIXtosrc/server/constants.ts.Type of change
Scope (select all touched areas)
Linked issues
Root cause (bug fixes only, otherwise write
N/A)N/A
Test plan
test/unit/infra/dream/dream-state-schema.test.tstest/unit/infra/dream/dream-log-schema.test.tstest/unit/infra/dream/dream-state-service.test.tstest/unit/infra/dream/dream-lock-service.test.tstest/unit/infra/dream/dream-log-store.test.tsUser-visible changes
None
Evidence
79 tests passing, 0 type errors, lint clean.
Checklist
npm test)npm run lint)npm run typecheck)npm run build)mainRisks and mitigations
DreamLockService.tryAcquire()has a TOCTOU race window in the write-then-verify pattern.DreamStateService.incrementCurationCount()is not atomic under concurrent writers.