Repository navigation
Description
Goal and dependencies
Parent: #273. Priority: P1 — durable recovery. Blocked by: #274 (versioned identity/projection) and #276 (human-request lifecycle). Do not invent a parallel event schema or re-execute tool events.
After reload, sleep, reconnect or restart, recover the same typed transcript and truthful request/outcome state without duplicate actions or lost drafts.
Existing behavior to preserve
The journal guide already documents SQLite/WAL, MODEX_EVENT_JOURNAL=1, journal identity/cursors, batched absolute updates, paired desktop SSE resume, phone delta snapshots and retention. State files remain authoritative. Journal disable/failure falls back to existing reload behavior. This is an extension/migration issue, not a missing-journal implementation.
Preserve defaults unless separately approved: opt-in flag; 250 ms batching; 7-day / 250,000-row retention; 10,000-event replay limit; existing 4 MB replay and 8 MB slow-stream fallbacks. These are the documented baseline values, not new service-level guarantees.
Integration points
Locate the current EventJournal implementation with rg -n 'class EventJournal|replayItems' apps/desktop/src; use that implementation. Existing consumers include apps/desktop/src/main/engine/{store,runner,desktop-host,desktop-client,companion}.ts, apps/desktop/src/renderer/transcript.ts, apps/store-desktop/, and apps/ios/ModexCompanion/.
Extend apps/desktop/test/{event-journal,journal-resume}.test.ts and apps/desktop/e2e/event-journal.spec.ts; add apps/desktop/test/conversation-migration.test.ts. Update docs/event-journal.md and docs/conversation-events.md from #274.
Implementation steps
- Inventory actual snapshot/journal/client schema versions and create saved legacy/current fixtures. Add richer identity, phase, part, outcome and request-state metadata without promoting the journal to authoritative execution state.
- Define a consistent snapshot + high-water cursor boundary. Keep coalescing safe for typed fields: do not merge across item/part/attempt/runtime identities, overwrite a terminal state with an old running update, or discard durable request withdrawal. Replay uses idempotent projections, not callbacks that run tools.
- Extend serializers/validators and the existing desktop/phone merge paths. Negotiate schema capability; unknown future actionable items become non-actionable fallbacks. Preserve historical text and old-client compatible records. Invalid, foreign, expired, ahead-of-log or oversized cursors explicitly reload rather than silently skipping events.
- Reconcile restart with authoritative native state when available. Pending requests from a dead runtime are expired/unavailable, not active approvals. Unknown execution stays unknown. Never automatically resend a user prompt, command, question answer or approval after an uncertain outcome; explicit user retry creates a new attempt with visible consequences.
- Keep disk/journal failure behavior safe: existing state/drafts survive, paired streams reset to snapshot mode, and failure of a projection journal does not claim an action was durably audited. Redact sensitive request/credential content before persistence, rather than relying on renderer masking.
- Exercise migration, batching, wake and paired races with real journal/TLS fixtures, then verify native UI behavior. Record rollback/read compatibility and docs/status.md updates in a signed PR. Default-on journaling is out of scope.
Acceptance criteria
- Direct projection, snapshot + replay and supported client catch-up converge on identical item identity, text, phase and outcome.
- Duplicate identified frames are harmless; legitimately repeated deltas remain represented; old-attempt updates do not mutate new attempts.
- Request withdrawal and resolution survive batching/replay; reconnect never revives a dead card or emits a second native decision.
- Cursor reset, pruning, journal replacement, out-of-range cursor, replay/stream size limits and journal-off fallback all request the correct reload path.
- Crash between persistence/broadcast/native send yields truthful unknown/expired state with zero implicit re-execution; old snapshots migrate without text/draft loss.
- Desktop/Store/iPhone capability mismatches retain readable safe fallback. A legacy binary client cannot approve an unsupported structured question.
- Existing privacy/retention limits are retained and documented; no raw credentials or sensitive question bodies enter the journal.
Verification: RED → GREEN fixtures, pnpm build, pnpm typecheck, pnpm test, pnpm test:e2e, plus the documented paired journal-resume and supported native iPhone tests. Record exact SHAs, environments and skips rather than claiming all-platform acceptance from one OS.
Long-running goal prompt — implement
Implement CF-6 in TypeSafeAI/modex under #273 using the landed #274/#276 contracts. Read current AGENTS.md, docs/event-journal.md, actual journal/snapshot/client implementations and existing paired tests. Work in an owned worktree with pinned pnpm and Superpowers TDD. Extend the SQLite journal and authoritative state files already present; do not build a new event store, change its default flag or replace the native runtime.
Preserve typed item/part/attempt/generation identity, phases, outcomes and human-request withdrawal across batching, snapshots and desktop/iPhone catch-up. Make snapshot/cursor boundaries coherent and updates idempotent. Treat replay as presentation only. A restart or uncertain native send must not resend prompts, commands or answers; dead requests become unavailable and unknown outcomes remain unknown. Maintain legacy readable fallback, existing retention/size limits, draft ownership and journal-failure recovery. Add hostile migration/cursor/batching/reconnect tests before fixes and count native execution calls to prove no duplicate side effects. Run applicable full and paired suites, update compatibility/rollback docs and status, then prepare a signed linked PR. Leave exact SHAs, commands/results, skips, supported environments and next steps in the checkpoint. Do not enable journaling globally, merge or release.
Follow-up long-running goal prompt — verify and finish
Resume CF-6 from the actual PR/head and checkpoints after verifying worktree ownership. Compare journal-off, direct live projection, snapshot-plus-replay and paired-client catch-up on the same mixed transcript. Inject duplicate frames, an old-attempt update, a cursor from a deleted journal, pruning, future/expired cursors, oversized replay, journal write failure and a crash immediately after an approval write.
Check that request withdrawal survives coalescing, terminal outcomes cannot regress, all sensitive data is filtered before storage, and no executor or native response is called by replay. Load old snapshots and unsupported-client fixtures while preserving drafts. Reproduce defects with failing tests, narrowly repair the existing implementation, and rerun build/typecheck/unit/E2E and paired/native checks. Do not expand into an authoritative event store or switch the feature default. Update docs and the issue receipt with exact schemas, SHAs, results, skips and remaining native gates. Leave incomplete acceptance open; no merge or release without separate authorization.
Activity
BunsDev commentedon Oct 18, 2026
Input for CF-6 from the #273 tracker session, after #282 (CF-1) merged as
7780093.Older paired desktops can read unresolved tools as success. CF-1 leaves
okunset on a tool whose outcome isunknownorinterrupted(okForinshared/conversation-events.ts, asdocs/conversation-events.mddocuments). Before7780093, the runner setok: falseon a tool still open when the turn ended.A renderer built before
7780093reads onlyok. It showsok: undefinedas Done, and its fold rule (item.ok !== false) folds the tool away with completed work. A Store client or paired desktop on an older build, connected to a newer host, therefore shows an interrupted or unknown tool as quietly successful. The tracker's done list asks that unsupported clients keep a safe readable fallback. Two options:ok: falsewith those outcomes as the legacy fallback. Current renderers readoutcome, so their labels don't change.I raised this in review on #282 before it merged (review). The contract chose
undefineddeliberately, so I've left the decision to this issue rather than change the contract myself.The iPhone ignores
okandoutcomeentirely.CompanionViews.swiftshows a checkmark for every finished tool (item.status == "running" ? "gearshape.2" : "checkmark.circle"), andcompanion.ts'smobileItemforwards onlystatusandok. So failed, denied, interrupted and unknown tools all look done on the phone. This predates CF-1. It's the companion's half of "supported paired-client recovery converge with safe non-actionable fallbacks".BunsDev commentedon Oct 18, 2026
CF-6 claim: the half that depends only on #274, 2026-10-18, from the session that did CF-1 (#282) and the CF-4 typed-turn slice (#284)
#276 (CF-3) has not landed;
cf3-human-requestsis still at89c98f2. Val asked this session to take only the CF-1-dependent part of this issue now:test/conversation-migration.test.ts. Unsupported clients keep a readable fallback.docs/event-journal.mdanddocs/conversation-events.mdget updated.Left for after #276 lands: request withdrawal and resolution through batching and replay, dead-card revival, the second native decision, and any structured-question capability negotiation.
.worktrees/cf6-typed-replay, branchcf6-typed-replay, frommainat7780093.event-journal.ts,companion.ts(the phone's item projection),desktop-host.ts/desktop-client.tsonly if replay needs it, the journal tests, and the docs.Share the captured-stream test helpers between test files
Replay journal items as upserts and give the phone typed items
Settle work a dead process left running in the snapshot and the journal
Document typed conversation state in the event journal
Carry typed conversation state through the journal, snapshots and the…
BunsDev commentedon Oct 18, 2026
CF-6 checkpoint, first half (the part resting on #274): merged in #285 as
fb76aacon 2026-10-18. Base8e26534after a signed rebase over CF-4; PR head13a8b33. All 11 checks green, includingunit + e2e (macOS)and iPhone companion.Done
replayItemsnow upserts by id, where before it appended a stale copy. Repeated deltas stay represented, and a retry reusing a native id never merges into the first attempt.unknownin the saved snapshot, the journal and every client, not only in one window, and nothing runs again. Before, clients resuming from the journal kept a spinner forever.test/conversation-migration.test.ts).Checks at
01a395b, before the rebasepnpm test: the first stage ran 1,520 tests, with 1,504 passed, 0 failed and 16 skipped. The second stage passed 21 of 21.event-journal,companion,store-desktop,store-demo,desktop-host-launch,app,sourcesandagents.Still open, after #276 (CF-3) lands
Settle a thread on first load without resending items that did not ch…
Capture fidelity states in every theme, measure a long transcript, an…
Record who answered each request and whether the answer reached the CLI
Say on a card when the phone answered or delivery is uncertain
Document the request lifecycle across replay and reconnect
Let the phone act on threads started on the Mac
37 remaining items
Exercise CR2 reads through production Electron IPC (#361)
mariscate commentedon Oct 22, 2026
Refreshed goal prompts — 2026-10-22 (
mainat0e674e7)On
main: every CF-6 review finding (3, 4, 6, 7, 9, 10, 11). Finding 10 (#336) came after the v0.3.0 tag and is unreleased. The journal mechanics (#309) and the request half of replay are documented indocs/event-journal.mdanddocs/human-requests.md.Still open:
None of the repairs has run against a live provider, Store 0.0.8 or a physical iPhone, so the acceptance boxes stay unticked.
Long-running goal prompt
Follow-up / resume prompt
BunsDev commentedon Oct 22, 2026
Coordination with #276 (phone answers to questions). The #276 session is taking the companion change on worktree/branch
cf3-phone-answers, cut frommainat0e674e7. That coverscompanion.tsandmobile-commands.tsrouting phone answers through the runner'sanswerQuestionbroker with the same refusals, a 409 when another client won, secrets kept out of logs and state, desktop/phone race tests, and the native iPhone question card. To avoid duplication, #279 should not land a second companion path. It can add its replay/reconnect tests for an answered or withdrawn question seen by the phone on top of that PR, which I'll link here once it's open.BunsDev commentedon Oct 22, 2026
The companion change for phone answers to questions is #373 (branch
cf3-phone-answers, frommain0e674e7). It routesPOST /v1/threads/:id/answer-questionthrough the runner'sanswerQuestionbroker withby: "phone": same refusals, 409 for the loser, secrets never logged or saved. It sends the native question card only to phones that namequestioninx-modex-item-kinds; older phones keep the notice. #373 already includes desktop/phone race tests in both orders, a phone-answered secret, and Stop. For #279, build on #373 rather than a second path: add the replay and reconnect tests for an answered or withdrawn question seen by the phone (journal delta, expired cursor, reconnect after the decision).BunsDev commentedon Oct 23, 2026
Checkpoint — 2026-10-23 (PR #388)
Worktree and branch:
cf6-acceptance, frommainatec7be57. Head isdbd2e81; the tests ran at8bf909f.What #388 adds. It builds on #373's broker path and adds no second companion path:
Each phone test counts Codex's replies (always one) and checks the secret is in no file, journal row, poll or snapshot. The phone tests passed on their first run, because the behaviour already existed. Mutations to the built code show each test can fail.
Findings, corrected in
event-journal.md:Checks (local,
8bf909fplus docs):pnpm build: passed.pnpm test: desktop 1,816 passed, 16 skipped, 0 failed.pnpm test:e2e: 389 passed, 6 skipped; site 7 passed.Open: G1's live approval, G2, G3, the G4 apps and a real power cut for G6. Acceptance boxes stay unticked until they have evidence, or until Val defers them in writing.
Next action: after 2026-10-25 9:35 AM, run G2 step 1 (
MODEX_EVENT_JOURNAL=1 MODEX_LIVE_SMOKE=1 MODEX_LIVE_BACKENDS=codex npx playwright test e2e/live-smoke.spec.ts) fromcf6-acceptance.BunsDev commentedon Oct 23, 2026
CF-6 checkpoint: questions across replay and reconnect (2026-10-22)
PR: #389, branch and worktree
cf6-replay.mainat2eba641(Run Plan mode on Codex in Codex's native plan collaboration mode (CF-3) #385). It was first cut fromec7be57(CF-3: answer an agent's questions from the iPhone, through the Mac's broker #373).8c36029, 8 signed commits.#385 landed as
2eba641. A Codex Plan turn now runs in Codex's plan mode, which sends its plan as aplanmessage (nativePhase: "plan").Acceptance criteria after #389
nativePhasesendingat a crash reads as uncertain on both kinds of phone. v0.3.0 questions and plan load closed, with the draft byte-identicalinvalid(now a committed test)Native iPhone tests:
QuestionCardTestsadds 4 cases: a delta closes one card and keeps another card's draft; a withdrawn card sends nothing; a reload replaces the transcript; an uncertain answer stays closed.Commands and results
Environment: macOS, Node v24.22.0, pnpm 10.34.5, the iOS 27.0 simulator (dedicated iPhone 18 Pro).
b77fecd, before the rebase:pnpm build && pnpm typecheck && pnpm testpassed. Desktop unit: 1,821 passed, 16 skipped, 0 failed; the other suites all passed.pnpm test:e2e: 388 passed, 6 skipped, site 7/7.8f55ad4: iOStest-e2e.sh(MODEX_UI_TIMEOUT_SCALE=2): 43/43.8c36029, after the rebase onto2eba641:codex-native-plan,human-requests,event-journal,companion,store-desktop: 16/16;ModexCompanionTests: 60/60.backend-health.test.jshung idle for about two hours under load and passed 5/5 alone. Questions across replay and reconnect on the phone and paired desktops (CF-6) #389 doesn't touch it.Still open (native and human gates)
The TestFlight upload of a Companion build with the card is Val's. The acceptance boxes stay unticked until those gates run or Val defers them in writing.
Next step: Val reviews #389 and decides on merging. After that, a gate plan in
docs/reviewsfor the gates above. The steps for a native question are already in #281.BunsDev commentedon Oct 23, 2026
Update (
64c4515, #388). G1 is now passed in full. A live Chat-mode Claude Code 2.1.309 (Haiku) turn asked to run one command, and it was approved in the window. After a clean quit, the journal's 13 rows replay exactly to the saved transcript. The card readsanswer: yes,answeredBy: desktop,delivery: sent, and the command ran once.Still open, with owners:
Next action: G2 step 1 after the reset.
BunsDev commentedon Oct 23, 2026
CF-6 checkpoint: final head of #389 (2026-10-22)
#389 is at
fa4b7cbonmain2eba641, with 10 signed commits. It waits for Val's go-ahead to merge.Added since the earlier checkpoint
resumed: false, nothing replayed) to the answered card.final/plan.live-codex-journal.json, sha25655ab91f8…dda9a.touch probe-file.txt, its late deny got a 409, and every view agreed.acceptEdits) ran the same command without asking, so there was nothing to answer from the phone.live-claude-journal.json, sha256c43a4f4e…2e74.Full gate on the final head
fa4b7cbpnpm build && pnpm typecheck && pnpm test: passed.pnpm test:e2e: 389 passed, 6 skipped, 0 failed; site 7/7.ModexCompanionTests: 60/60.test-e2e.sh,MODEX_UI_TIMEOUT_SCALE=2): 43/43.Gate table
Next: Val reviews #389 and decides on merging. Then the physical-iPhone gate, run after a Companion build reaches TestFlight.
BunsDev commentedon Oct 23, 2026
Val's decisions (2026-10-23), recorded in the gate plan on #388:
#388 goes to the merge queue once CI is green. Before this issue can close: G2 (next session) and G3 (Val).
BunsDev commentedon Oct 23, 2026
Coordination between #388 (
cf6-acceptance) and #389 (cf6-replay). The two were opened 25 minutes apart from the same base and overlap. #388 has auto-merge on and owns the gate plan with Val's decisions, so #389 will rebase onto it once it lands. When it does, #389 will:Drop its duplicates:
docs/reviews/2026-10-22-cf6-gates.md, which conflicts with Windows and Linux journal CI, an in-app live journal check and a mid-reply kill, on top of #389 (CF-6) #388's;slow-stream.test.ts(G5) already covers.Keep what Windows and Linux journal CI, an in-app live journal check and a mid-reply kill, on top of #389 (CF-6) #388 doesn't have:
companion.tsfixes, each red first. An older phone was told a question answered on the phone was "Answered on your Mac". The phone didn't receivenativePhase, so Codex's plan wasn't marked.sendingreading as uncertain on both kinds of phone; an older paired desktop's approve or deny on a question refused.QuestionCardTestsreplay cases, and the paired fixture running with the journal on, plus a UI flow closing two cards on the Mac.Add to Windows and Linux journal CI, an in-app live journal check and a mid-reply kill, on top of #389 (CF-6) #388's G2 section, as partial evidence, a live Codex run tonight that worked although the plan says the account is out of credits:
MODEX_EVENT_JOURNAL-equivalent wiring. That means the realEventJournal,CompanionServerand a phone over HTTPS namingquestion.grep -r ~/.modex.~/.claude/task-evidence/cf6-2026-10-22/live-codex-journal.json, sha25655ab91f88991d849062897fb85a5a0a0259d2361cb9f3eb33c2d13af955dda9a.Since Codex answered tonight, G2 may not need to wait for the 25th. That's for the Windows and Linux journal CI, an in-app live journal check and a mid-reply kill, on top of #389 (CF-6) #388 owner or Val to decide.
#389 stays unmerged until Val's go-ahead.
BunsDev commentedon Oct 23, 2026
Checkpoint, 2026-10-23 (
main2eba641)Two CF-6 PRs, reconciled at Val's choice. #389 (
cf6-replay,fa4b7cb) is the base and is in the merge queue. #388 (cf6-acceptance,9f8ae8f) is rebased onto it and keeps only what #389 lacks:event-journal.mdcorrections.#388's duplicate phone tests and 8 MB test were dropped. GitHub retargets #388 to
mainwhen #389 merges.Correction: my earlier checkpoints said live Codex had to wait for the 2026-10-25 reset. #389 ran it live on 2026-10-22, so it wasn't blocked. I didn't check.
Checks on
fa4b7cb+ #388:pnpm build: passed.pnpm test: 1,828 passed, 16 skipped, 0 failed, 1 cancelled. The cancelled test is theclaude-lifecycleworktree-stop test, which hit its 6 s timeout under full-suite load; on its own it passed 5/5.pnpm test:e2e: 390 passed, 7 skipped; site 7/7.Open: the physical iPhone gate (Val). This issue can close once that has evidence or Val defers it in writing.
Next action: after #389 lands and #388's CI is green, merge #388 with Val's go-ahead. Val's earlier go-ahead covered #388 before the rebase.
BunsDev commentedon Oct 23, 2026
Checkpoint, 2026-10-23: both CF-6 PRs are on
main4f44304.e123ccc, rebased onto Questions across replay and reconnect on the phone and paired desktops (CF-6) #389 and keeping only what Questions across replay and reconnect on the phone and paired desktops (CF-6) #389 lacked.Windows and Linux CI on #388's final head
8551a9cran the journal, replay and request suites,question-replayincluded. Both passed 56/56 (run 39905321101).Still open: the physical iPhone gate, owned by Val, with steps in the gate review. It needs a Companion build cut after #373 on TestFlight.
Next action: Val uploads that build, runs the gate, and posts the results here. This issue closes on that evidence, or on Val's written deferral.
BunsDev commentedon Oct 23, 2026
Clean re-run on
maine123ccc(both CF-6 PRs merged):pnpm build: passed.pnpm test: exit 0. Desktop 1,831 passed, 16 skipped, 0 failed, 0 cancelled. Every other suite passed.The
claude-lifecycletimeout cancelled in the earlier run did not recur. The only open CF-6 gate is the physical iPhone (Val).BunsDev commentedon Oct 23, 2026
Val deferred the physical iPhone gate in writing (2026-10-23), through the session's question prompt: "Defer it, close #279". The evidence that stands for it:
CompanionModelTestsandCompanionFlowTestsagainst a fixture that keeps a journal);question-replay.test.ts).The gate review keeps its steps, in case it is run later.
Every CF-6 gate now has evidence or a written deferral:
Code is on
mainin #389 (4f44304) and #388 (e123ccc). A cleanpnpm testran one123ccc. Closing.