Skip to content

feat: one archive for Claude Code and Codex — codex-sync, shared-mcp, reconcile capture - #84

Merged
Wynelson94 merged 2 commits into
mainfrom
codex/shared-memory
Sep 7, 2026
Merged

feat: one archive for Claude Code and Codex — codex-sync, shared-mcp, reconcile capture#84
Wynelson94 merged 2 commits into
mainfrom
codex/shared-memory

Conversation

@Wynelson94

Copy link
Copy Markdown
Owner

Longhand now keeps one archive for Claude Code and Codex. Codex Desktop / CLI threads (the rollouts under ~/.codex/sessions) are captured into the same ~/.longhand archive the Claude Code hooks write, and the second client is held to the same rules as the first: exact records, stable IDs, nothing stored twice, drift never silent.

What's in it

  • longhand codex-sync — bounded, exact-record capture by default (no vector model loaded); --semantic runs the full pipeline so recall and semantic search see the sessions. Defaults: 50 sessions / 16 MiB / 20,000 events per run; --dry-run, --watch, --include-subagents.
  • reconcile --fix captures Codex too, so an installed reconciler keeps both clients current with no extra setup. Report + MCP tool gained codex_* fields.
  • longhand shared-mcp — four read-only keyword tools (list_sessions with source/project filters, search, get_session_timeline, get_event_text) over the SQLite archive, no Chroma. The server Codex talks to, and how Claude searches Codex history by phrase.
  • Codex adapter (longhand/codex.py): skip sets for Codex's UI mirrors and bookkeeping (same rule as KNOWN_SKIP_ENTRY_TYPES), encrypted-only reasoning skipped, subagent ("guardian") threads skipped by default, git ops + error detection on the archive path — including the cmd: literals inside Codex exec scripts — so commits made from Codex reach find_commits.
  • Shapes gate: tests/fixtures/codex_shapes/ (every record shape seen in the wild, both Codex CLI generations) + tests/test_codex_shapes.py. Unknown shapes are preserved as unknown events; doctor names Codex drift by nested kind.
  • doctor: "Codex capture" row (only when a Codex home exists); archived Codex sessions split out of "needing analysis" with the remedy that works (codex-sync --semanticanalyze never embeds events).
  • Fixed: CoreML ONNX ingest failures on macOS (one shared CPU-pinned ONNXMiniLM_L6_V2); frame-link (the Artifact publish link) triaged like pr-link; mcp>=1.2.0 floor (FastMCP first shipped there).
  • Docs: docs/codex.md, README "Works with Codex", CLAUDE.md note, scripts/com.longhand.codex-sync.plist.template.

Verification

  • ruff check, ruff format --check, mypy longhand, pytest580 passed (was 558).
  • Live-archive dogfood on 7 real rollouts (two Codex CLI generations): 5 primary threads captured, 2 guardian threads skipped, 719 events (was 2,046 with 1,194 blank rows), 33 git operations, doctor green.
  • Fresh-venv smoke from the built wheel: dry-run, capture, shared-mcp stdio handshake (4 tools, search hit), --semantic upgrade + CLI semantic search hit, reconcile --fix capturing a new rollout, doctor rows.

Notes for review

  • Retention decisions (skip UI mirrors; skip subagent threads by default; fold capture into reconcile) were made deliberately — see the CHANGELOG "Changed" section.
  • The suite now pins CODEX_HOME to a nonexistent path in the autouse fixture so no test can discover a developer's real ~/.codex.
  • Version stays 1.0.1 here; 1.1.0 follows via the release PR.

Originally drafted in Codex; reviewed and hardened for CI here.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LzrMzN4dfuJJKc4UZP6SFb

Wynelson94 and others added 2 commits September 7, 2026 16:09
… reconcile capture

Longhand now captures Codex Desktop / CLI threads (the rollouts under
~/.codex/sessions) into the same ~/.longhand archive the Claude Code hooks
write, and holds the second client to the same rules as the first: exact
records, stable IDs, nothing stored twice, drift never silent.

- `longhand codex-sync`: bounded, exact-record capture by default (no vector
  model); `--semantic` runs the full pipeline. Defaults 50 sessions / 16 MiB /
  20k events; `--dry-run`, `--watch`, `--include-subagents`.
- `reconcile --fix` captures Codex too, so the scheduled reconciler keeps both
  clients current with no extra setup.
- `longhand shared-mcp`: four read-only keyword tools over the SQLite archive
  (no Chroma) — the server Codex talks to, and the way Claude searches Codex
  history by phrase.
- Codex adapter with skip sets for UI mirrors / bookkeeping (Claude-parser
  precedent), subagent (guardian) threads skipped by default, git ops and
  error detection on the archive path — including `cmd:` literals inside
  Codex `exec` scripts — and a regression-gated shapes fixture.
- doctor: "Codex capture" row, archived-session remedy (`codex-sync
  --semantic`; `analyze` never embeds events), Codex drift named by kind.
- Fixed: CoreML ONNX ingest failures on macOS (shared CPU-pinned model);
  `frame-link` (Artifact publish link) triaged; `mcp>=1.2.0` floor (FastMCP).

Originally drafted in Codex; reviewed, hardened for CI (mypy, ruff format),
dogfooded on a live archive and a fresh-venv wheel install.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LzrMzN4dfuJJKc4UZP6SFb
Rich wraps and hyphenates long option names at the 80-column width CI
runs with, so `--include-subagents` was not findable in the rendered
text there (all five Linux legs, 578/579 otherwise green). Check the
registered command's declared defaults and flags instead; keep the
`--help` exit-code checks.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LzrMzN4dfuJJKc4UZP6SFb
@Wynelson94
Wynelson94 merged commit c95bce6 into main Sep 7, 2026
12 checks passed
Wynelson94 added a commit that referenced this pull request Sep 7, 2026
Longhand now captures Codex Desktop / CLI threads into the same archive
the Claude Code hooks write, and holds the second client to the same
rules as the first: exact records, stable IDs, nothing stored twice,
drift never silent. Version bump + sibling manifests + CHANGELOG heading;
the feature itself landed in #84.

Also re-pins fieldnote 0002 (project-inference-cwd-mode) to parser.py:
#84 changed the file (Codex adapter dispatch, frame-link triage) but not
build_session's cwd-mode attribution the note documents, so the prose
still holds and only the pin was stale.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LzrMzN4dfuJJKc4UZP6SFb
Wynelson94 added a commit that referenced this pull request Sep 7, 2026
The claim (cwd-mode project attribution in build_session) was re-read
against the post-#84 parser and still holds.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LzrMzN4dfuJJKc4UZP6SFb
Wynelson94 added a commit that referenced this pull request Sep 7, 2026
* v1.1.0: one archive for Claude Code and Codex

Longhand now captures Codex Desktop / CLI threads into the same archive
the Claude Code hooks write, and holds the second client to the same
rules as the first: exact records, stable IDs, nothing stored twice,
drift never silent. Version bump + sibling manifests + CHANGELOG heading;
the feature itself landed in #84.

Also re-pins fieldnote 0002 (project-inference-cwd-mode) to parser.py:
#84 changed the file (Codex adapter dispatch, frame-link triage) but not
build_session's cwd-mode attribution the note documents, so the prose
still holds and only the pin was stale.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LzrMzN4dfuJJKc4UZP6SFb

* chore: record fieldnote 0002 re-verification after #84

The claim (cwd-mode project attribution in build_session) was re-read
against the post-#84 parser and still holds.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LzrMzN4dfuJJKc4UZP6SFb

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant