Plan · ox CLI · fixes ox#1093 · ox#1019 · ox#1095 · refs ox#1077 · verified on main @ 75d57962
Held sessions stay local
Promise: a session I hold (session_publishing: manual) stays on my machine. It is not summarized, not uploaded and not deleted until I run ox session upload <name>.
today: 10 paths ignore the hold worst case: held session deleted (seen 28 Sep) fix: 1 marker, checked everywhere reviewer: Ryan
TL;DR
Problem
Manual publishing is only checked inside session stop. Everything that runs afterward ignores it: the daemon, the exit hooks, ox doctor, recover, regenerate and push-summary. So a held session gets summarized, then uploaded to the shared Ledger or deleted.
Approach
Write a .held marker into the session's cache folder at stop, or at crash recovery from the mode recorded at start. Every path that summarizes, uploads or deletes checks it first, next to #1065's quarantine checks. Publishing becomes one explicit, synchronous command.
Decision needed
Approve the approach and the scope cut: the auto-mode "local-only → uploaded next cycle" leak goes to its own issue. Biggest risk: missing a path. The audit on current main found 10, including a same-minute /clear that truncates a held transcript.
Why the marker lives on the session
The daemon is a separate process. It can't see the OX_SESSION_PUBLISHING override that the stop command ran with. The existing .downloaded marker is the precedent for "daemon, skip this folder".
Fails closed
The CLI decides, using the normal precedence (env, then user, project and team config). The daemon reads only the session, never config. An unreadable marker still counts as held.
| Issue | What this PR does | PR keyword |
|---|---|---|
| ox#1093 held session summarized, uploaded or deleted | .held marker, plus one skip check on every automatic path | Fixes |
ox#1019 session upload can't find held sessions | Upload searches the cache locations and publishes synchronously | Fixes |
| ox#1095 doctor doesn't show held sessions | ox doctor, agent doctor and ox status list held sessions with the publish command. Info only, never auto-publish. | Fixes |
| ox#1077 a second recording orphans the first | Verified on main: the daemon already reclaims the orphan once its agent process exits. The #1077 orphan was finalized Sep 26 with stop_reason: recovered. This PR adds visibility while it waits, lets upload publish it early (same code path as #1019). Why the second recording starts at all needs its own investigation. | Refs |
Before and after
Before → After
Before · todayAfter · this plan Trace a pathsession stopside effectsexit hooksdaemon scanpush-summarydoctor · recover · pruneox session upload
Red ends lose data or leak it. Gold is "the team can read it". Sage is "stays on this machine". Before: five paths reach upload or delete. After: each path stops at one shared held? check, and only an explicit upload publishes.
| Event | Before · today | After · this plan |
|---|---|---|
session stop (manual) | Prints "saved locally", but nothing on disk records the hold. | heldWrites .held first and prints the publish command. |
| Stop side effects | leakSummary snippet goes to team memory, and stop prints a push-summary prompt that publishes. | heldNo observation, no publish prompt. The summary is made when you publish. |
AI coworker exits / runs /clear | uploadThe hook asks the daemon to finalize it now, skipping the scan. | heldThe hook writes .held and sends nothing. |
/clear within the first minute | wipeSame folder name is reused, and the held transcript is truncated. | heldRefuses to restart into a held folder. |
Agent crashes, then doctor, recover or daemon recovery | uploadRecovered and uploaded. | heldRecovered and held, from the mode recorded at start. |
| Daemon scan, ~10 min later | uploaddeleteAn AI summarizes it, then it's uploaded or deleted. | heldSkipped. The log counts held=N. |
AI coworker runs push-summary | deleteOn a low score the folder is removed. | heldRefused: "session is held". In manual mode, stop no longer prompts for it. |
ox doctor · regenerate · sweeps · prune | uploaddeleteDoctor and regenerate upload it. The orphan sweep and prune delete it. | heldAll skip it. It can be removed only by name. |
ox doctor · ox status report (#1095) | silent"Nothing to do". Held sessions show up nowhere. | infoLists each held session with its ox session upload command. Never auto-publishes. |
ox session upload <name> | broken"session not found". | publishPublishes now and removes .held only after the commit lands. The daemon then summarizes it. |
| Orphaned first recording, cache only (#1077) | invisibleHidden until the daemon reclaims it, after its agent exits (about a day later in #1077). Upload says "no content files found". | infoDoctor shows it as waiting for recovery, and upload can publish it now. |
What the coworker sees
The same held session in the terminal. The "After" wording is proposed.
Before · 28 Sep, as reported in ox#1093 zsh · ox 0.18.0
$ OX_SESSION_PUBLISHING=manual ox agent OxaSGr session stop
✓ Session saved locally (publishing mode: manual).
Use 'ox session upload' to publish.
# ~1 hour later, daemon log:
INFO starting agent work type=session-finalize
INFO session below discard threshold, removing
session=2026-09-28T16-42-faridun-OxaSGr
$ ox session upload OxaSGr
✗ session not found
After · proposed output zsh · ox (this plan)
$ ox agent Ox7f3a session stop
● Held on this machine. Not summarized, not uploaded.
Publish when ready:
ox session upload 2026-10-04T22-02-faridun-Ox7f3a
$ ox session list
2026-10-04T22-02-faridun-Ox7f3a held · local 66 entries
$ ox doctor
ℹ 1 session held on this machine (manual publishing)
publish: ox session upload 2026-10-04T22-02-faridun-Ox7f3a
# daemon log, every cycle:
INFO session finalize detect complete held=1 queued=0
$ ox session upload Ox7f3a
✓ Published to the Ledger · hold released
Decisions
Where the hold lives
A .held file in the session's cache folder only. It holds JSON (held_at, reason, source) and is written atomically. It is never written inside the shared sessions/ tree.
The daemon commits whole session folders, so a .held there would hold the session on every teammate's machine. Keeping it in the cache avoids editing the sessions/.gitignore that older ox versions rewrite.
Who decides "held"
The CLI, with the usual precedence (env, user, project, team). It records the mode at start for crash recovery and writes .held at stop. The daemon reads the session, never config.
Rejected: a daemon config fallback. The daemon can't see the CLI's env, so it would hold sessions the CLI meant to publish (D13). Older unmarked sessions get marked by the CLI at prime or doctor.
Relation to #1065 quarantine
A separate marker, with the hold check placed next to every quarantine check. Quarantine is a flag in .recording.json, which stop deletes, so it can't carry a hold. Quarantine is checked first. Two #1065 identifiers that say "held" get renamed to "quarantined".
How publishing works
ox session upload publishes synchronously and removes .held last. The daemon summarizes afterward, and respects agent.summarizer=off.
Rejected: "release the hold and let the daemon finalize". The quality gate could re-hold or delete it, or nothing happens if the daemon is down.
Summary for a held session
None until you publish. Manual stop no longer prints the push-summary prompt, because push-summary publishes.
Cost: a daemon summary is about 10× an inline one (ADR-016), only for sessions you choose to publish. The plan comment on #1019 gets updated to match.
prune
Never deletes a held session. Removal is by name only (abort/remove). No new flag, per the reduce-bloat directive.
Unchanged and out of scope
Unchanged on purpose: the quality-gate discard of low-score sessions in auto mode (PR #238). ox#1080 is closed.
Out of scope: retracting a draft published before switching to manual, which would be a Ledger write in manual mode (ox-6p5y.15 requires zero). Counting summary.json alone as a summary, since the daemon still requires summary.md. The auto-mode "local-only → uploaded next cycle" leak, filed separately. #1077's root cause (cf. #541).
Plan, tests and risks
Plan
- Marker helpers. One small file next to the existing summary marker: write (atomic), check (an unreadable marker = held), release, and a name-wide check across every cache location. Refuses to write inside the shared
sessions/tree. - Record the mode at start on the recording state, at every start site.
- Stop and hooks. Write
.heldin both manual branches before the recording state is cleared. No.needs-summary, no summary prompt, no observation, and a clear message. Hooks write.heldand send no IPC. A new recording refuses to start in a held folder (same-minute/clear). - Every crash-recovery path holds. Daemon scan recovery, orphan detection,
ox doctor --fix, the doctor upload-retry reclaim,session recoverand--release-quarantineall write.heldfrom the recorded mode before clearing state. - Daemon checks next to the quarantine checks: scan, the start of prompt-building and result-processing, and the IPC handler (by name). Staging skips dotfiles, and the orphan-stub sweep skips held folders.
- Publish-side guards, matched by session name: the shared LFS upload path (
regenerate,migrate-lfs),push-summary, doctor upload-retry,prune. - Publish (#1019, #1077).
ox session uploadfinds cached sessions and publishes them synchronously, then removes the hold. The daemon summarizes afterward. - Visibility (#1095, #1077). A
heldstatus in list, abort and prune.ox doctor, agent doctor andox statuslist held sessions and cache-only orphans as info, each with its upload command. The CLI marks older unmarked manual sessions here. - Docs. README wording, upload
--help, plus aRule:in the existing manual-publishing.feature.
Proof: fails before the fix, passes after
End-to-end, real commands, real bare remote
Set manual in user config, then do a real start, record 3 entries and stop. Run a finalize pass at score 0.8, then at 0, plus a SessionEnd-shaped IPC and ox doctor.
The first assertion fails today: 0 AI runs, 0 items queued. Then: files and transcript hash unchanged, no summary, no .held anywhere in the shared tree, remote HEAD unchanged, no team observation, no summary prompt, and the list shows held. Then ox session upload publishes it, removes the hold, and the next pass queues exactly one summary.
Every path the audit found
Each of the five crash-recovery paths ends held, never uploaded. A same-minute /clear leaves the transcript byte-identical. regenerate --all and migrate-lfs don't upload it, the orphan sweep keeps it, push-summary refuses, prune skips, and abort still works. Env auto with config manual means not held (D13). Plus race tests at the two daemon entry points, and visibility in doctor, agent doctor JSON and ox status. Finally, deliberately break the scan check and record the red failure text.
Risks & coordination
#1065 merged
The branch is rebased onto it. Its quarantine check sites are the pattern for every hold check. #959 (lpavel, idle) still overlaps.
Review
Ryan owns nearly every file touched. The PR gives the user-facing changes (list status, upload, doctor and status lines) their own section. Run /security-review before merge.
Contract change
The JSON status field gains held. Check any consumer that matches on local. Older env-only holds are marked best-effort at the next prime or doctor.
Implementation notes
- Verified on
main@75d57962(2026-10-05). Mode resolution:internal/config/session_recording.go:229-304(D13 precedence). - Stop: manual branches
cmd/ox/agent_session.go:1257,agent_session_incremental.go:331. The summary prompt and.needs-summaryare written before them (agent_session.go:1213-1223, incremental:299-302).ClearRecordingStateAtis at:585.recoverViaNormalStop(agent_session_recover.go:206-234) shares the manual branch. - Start sites:
internal/session/recording.go:1335-1349(StartRecording, next toErrQuarantinedSessionPath),agent_session.go:263,agent_prime.go:1482,agent_hook.go:874. Drop-file cleanup isagent_session.go:194-209; the raw header truncate isagent_session_incremental.go:81. - Hooks:
cmd/ox/agent_hook.go:358-370(/clear),:436-449(SessionEnd). - Daemon
session_finalize.go: detect quarantine skip 606-615; stale recovery lock ~633 (write.heldbeforeos.Remove); git-tracked recovery 639/1025 (never write.heldthere);DetectOrphanedForAgent~945;BuildPromptquarantine 1084-1088;ProcessResultquarantine 1226-1234, with the hold check beforecheckLedgerResolved1241; staging 2080-2093; commit 2367. IPCinternal/daemon/daemon.go:~1870(match by name). - Doctor: upload-retry
doctor_session_upload_retry.go(loop top before :142, stale reclaim 161-195, quarantine skip 154-159); orphaned recordingsinternal/doctor/session.go:670-676; quarantine warning pattern 746-793. - Recover:
withCachedRecordingForRecoveryagent_session_recover.go:266(next tolatest.SourceRejected),publishCachedRecording:452. - Upload chokepoint
cmd/ox/session_upload.go:134(next to #1065's check);regeneratesession_regenerate.go:124/238-243. Push-summarysession_push_summary.go:270and:426-449. Orphan-stub sweepinternal/session/recording.go:1114-1173. - Publish:
cmd/ox/session_upload_cmd.go:25-57; reuseretrySessionUploadWithEffects; cache search pattern fromagent_session_abort.go:302;PreserveSessionCacheinternal/session/store.go:731. - Visibility: agent doctor
cmd/ox/agent_doctor.go:124; doctor session checkscmd/ox/doctor_session.go:12;ox statuscmd/ox/status.go;internal/session/classify.goorder: canceled → uploaded → held → draft. - Tests: E2E on
newDownloadLedgerFixture(:50) +runFinalizePass(:169) incmd/ox/session_download_finalize_test.go; manual start/stopcmd/ox/agent_session_manual_publish_test.go:113; crash harnesscmd/ox/agent_session_quarantine_test.go; race templatesession_finalize_download_test.go:225. BDD:tests/acceptance/features/session-recording/manual-publishing.feature.
Planned in SageOx session ses_01a108f0. Issues: ox#1093 · ox#1019 · ox#1095 · ox#1077 (in part). enriched by

