Plan · ox CLI · fixes ox#1093 · ox#1080 · ox#1019 · ox#1095 · refs ox#1077
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: 8 paths ignore the hold worst case: only copy 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 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 own folder at stop. Every path that summarizes, uploads or deletes checks it first. Publishing becomes one explicit, synchronous command. And no session is deleted unless it's provably on the remote.
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: a collision with #1065 (arrsingh, active), which touches the same finalize code.
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
A session counts as held if the marker exists, or if config says manual and the session isn't published yet. Env can add a hold, never remove one. 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#1080 discard deletes the only copy | Deletes only with upstream proof; otherwise keeps it as kept_local | 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 | Upload publishes the orphan and replaces its draft meta.json. Doctor reports cache-only sessions and stops flagging uploaded sessions whose transcript is an LFS stub. 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 uploadlow score, never uploaded
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. An earlier draft stays in the Ledger. | heldNo observation is written, and the draft is retracted. |
AI coworker exits / runs /clear | uploadThe hook asks the daemon to finalize it now, skipping the scan. | heldThe hook writes .held and sends nothing. |
| 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 · recover · prune | uploaddeleteDoctor and recover upload it. Prune deletes it as "local only". | heldAll three 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. |
| Orphaned first recording, cache only (#1077) | stuckUpload says "no content files found". Agent doctor misses it, and flags published sessions as missing a summary instead. | publishDoctor warns with the upload command. Upload publishes it and replaces the draft meta.json. |
| Any session scores low, never uploaded | deleteOnly copy deleted (#1080). | keptDeleted only if it's provably on the remote. Otherwise kept as .held(kept_local). |
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 own folder. It holds JSON (held_at, reason, source), is written atomically, and is never staged or committed.
Rejected: .recording.json (deleted at stop), meta.json (means "draft" in the Ledger), the transcript footer (gets uploaded).
Who decides "held"
The marker, or config set to manual while the session is unpublished. The daemon also reads user, project and team config, so sessions held before this ships are covered too.
Env can only add a hold. Sessions held only through the env var before the upgrade are best effort, which goes in the release note.
How publishing works
ox session upload publishes synchronously, reusing the doctor upload-retry path, and removes .held last.
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.
Proof before any delete
Non-draft meta.json on the upstream branch, with a matching transcript hash. Otherwise the session is kept.
A local commit that was never pushed isn't proof. Uploads that excised a paused span won't match, so they're kept, which is the safe direction.
prune
Never deletes a held session. Removal is by name only (abort/remove). No new flag, per the reduce-bloat directive.
Out of scope → its own issue
The "local-only" disposition auto-uploads on the next cycle for every auto-mode user. It's a real bug, but fixing it changes behavior for teams that never chose manual.
Also #1077's root cause: why a new recording starts without finalizing the open one (cf. #541). This PR makes the orphan visible and publishable, and the trigger needs its own reproduction.
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.
- Record the mode at start on the recording state, plus a config-based "held by config" check the daemon can call.
- Daemon. One shared hold check at the scan, both crash-recovery blocks, the start of prompt-building and result-processing, and the IPC handler. Staging skips dotfiles.
- Discard guard (#1080). Delete only with upstream proof; otherwise keep the session and mark it
kept_local. - Stop and hooks. Write
.heldbefore anything the daemon reacts to. Also: no summary prompt, no observation, retract the draft, and a clear message. - Other entry points.
recover, doctor upload-retry andpush-summaryskip held sessions. - Publish (#1019, #1077).
ox session uploadfinds cached sessions, including orphans that were never held, and publishes them synchronously. It replaces a leftover draftmeta.json. - Visibility (#1095, #1077). A
heldstatus in list, abort and prune.ox doctor, agent doctor andox statuslist held sessions (info) and cache-only orphans (warning), each with its upload command. Agent doctor stops flagging uploaded sessions whose transcript is an LFS stub. The draft reaper handles drafts orphaned by a held session. - Docs. README wording, plus a
Rule: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, remote HEAD unchanged, no team observation, and the list shows held. Then ox session upload publishes it and removes the hold.
Unit + guard tests
Discard keeps sessions that are unproven, unpushed or committed but never pushed, and deletes ones proven on upstream. Also covered: race tests at the two daemon entry points, crash-recovery hold, the config fallback, the name-wide hold and the IPC skip. Three existing tests that expect deletion get flipped. Finally, deliberately break the scan check and record the red failure text.
Visibility: doctor, agent doctor JSON and ox status list a held session (info) and a cache-only orphan (warning) without uploading either. An uploaded session whose transcript is an LFS stub reports nothing missing. Upload publishes an orphan whose Ledger folder holds only a draft meta.json.
Risks & coordination
Collision
#1065 (arrsingh, active today) and #959 (lpavel, idle) touch the same finalize, stop, hook and recording code. Keep edits to one additive check per site, murmur arrsingh first, and rebase onto whichever lands first.
Review
Ryan owns nearly every file touched. Run /security-review before merge, since it touches internal/session/.
Contract change
The JSON status field gains held. Check any consumer that matches on local.
Implementation notes
- Mode resolution:
internal/config/session_recording.go:251-324(ResolveSessionPublishing,GetSessionPublishing). - Stop: incremental
cmd/ox/agent_session_incremental.go:97(.needs-summary:265, manual return :293). Legacycmd/ox/agent_session.go:1088-1307(.needs-summary:1266, manual return :1300).ClearRecordingStateAt:586.recordSessionObservation:613/:789. Recording start sitesagent_session.go:252,agent_prime.go:1416. - Marker precedent:
internal/lfs/download_marker.go. New file:internal/session/hold_marker.go, besidesummary_marker.go. Atomic writes viafileutil.AtomicWriteJSON. - Daemon
internal/daemon/agentwork/session_finalize.go:Detect:366 (first copy wins :371),detectInDir:460 (put the check after stale recovery:617, next to the:1000). IPC.downloadedskip :659),BuildPrompt:1064 (before the upload-only return :1070),ProcessResult:1200 (beforecheckLedgerResolved/upload-only :1210-1215), discard :1467-1497, staging :2050-2063 (skip dotfiles),DetectOrphanedForAgent:853 (internal/daemon/daemon.go:1867-1938(XDG path rewrite :1907). - Hooks:
cmd/ox/agent_hook.go:361 (/clear), :442 (SessionEnd). Write.heldbefore clearing state, and send no IPC. - Data-loss paths:
cmd/ox/session_push_summary.go:426-447; doctorcmd/ox/doctor_session_upload_retry.go(reuseretrySessionUploadWithEffects:366); recovercmd/ox/agent_session_recover.go:330. - Publish:
cmd/ox/session_upload_cmd.go:48-60. Cache search pattern fromagent_session_abort.go:302. Abort status switch :162-190.PreserveSessionCacheinternal/session/store.go:731. - Visibility (#1095, #1077): agent doctor
findIncompleteSessionscmd/ox/agent_doctor.go:124only scans<ledger>/sessions.checkSessionCompleteness:166 stats the summary files, so the fix is to treat a non-draftmeta.jsonthat lists the summary as complete. Doctor session checks are incmd/ox/doctor_session.go:12;ox statusiscmd/ox/status.go(renderGitReposSection:477). - Status:
internal/session/classify.goorder: canceled → uploaded → held → draft. Rendering incmd/ox/session_list.goprintSessionRow. - Upstream proof: pattern
sync.go:1939; OID comparesession_finalize.go:1947-1957. Draft reaperdraft_orphan.go:106. Retraction commits go throughgitutil.CommitLedgerSnapshot(ADR-030). - Leave
EnsureSessionsGitignore(internal/lfs/session_upload.go:224) unchanged. It rewrites a committed file whenever it differs, so ox versions on one team would keep reverting each other's edits. - 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; race templatesession_finalize_download_test.go:225; flipsession_finalize_empty_test.go:290,session_finalize_summary_test.go:515,:715. BDD:tests/acceptance/features/session-recording/manual-publishing.feature.
Planned in SageOx session ses_01a108f0. Issues: ox#1093 · ox#1080 · ox#1019 · ox#1095 · ox#1077 (in part). enriched by

