throughline 0.4.12 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/.codex-sidecar.yml +5 -0
  2. package/CHANGELOG.md +106 -0
  3. package/README.ja.md +37 -21
  4. package/README.md +47 -26
  5. package/docs/00_overview.md +34 -0
  6. package/docs/{L1_L2_L3_REDESIGN.md → 01_l1_l2_l3_redesign.md} +3 -3
  7. package/docs/{THROUGHLINE_CLEAR_AUTO_HANDOFF_PLAN.md → 02_clear_auto_handoff_plan.md} +6 -6
  8. package/docs/{INHERITANCE_ON_CLEAR_ONLY.md → 03_inheritance_on_clear_only.md} +3 -3
  9. package/docs/{PUBLIC_RELEASE_PLAN.md → 04_public_release_plan.md} +3 -3
  10. package/docs/{THROUGHLINE_CODEX_FIRST_ROADMAP.md → 05_codex_first_roadmap.md} +9 -9
  11. package/docs/{THROUGHLINE_CODEX_TRIM_ROLLBACK_FIX_PLAN.md → 06_codex_trim_rollback_fix_plan.md} +6 -6
  12. package/docs/{THROUGHLINE_CODEX_TRIM_IMPLEMENTATION_PLAN.md → 07_codex_trim_implementation_plan.md} +10 -10
  13. package/docs/{THROUGHLINE_CODEX_DUAL_SUPPORT.md → 08_codex_dual_support.md} +8 -8
  14. package/docs/{throughline-rollback-context-trim-insight.md → 09_rollback_context_trim_insight.md} +5 -5
  15. package/docs/10_transcript_injection_plan.md +446 -0
  16. package/docs/{THROUGHLINE_CODEX_MONITOR_IMPLEMENTATION_PLAN.md → 11_codex_monitor_implementation_plan.md} +1 -1
  17. package/docs/12_desktop_clear_handoff_plan.md +215 -0
  18. package/docs/adr/0001-claude-primary-codex-adapter.md +22 -0
  19. package/docs/archive/README.md +3 -3
  20. package/docs/archive/THROUGHLINE_NEXT_STEPS.md +3 -3
  21. package/package.json +2 -1
  22. package/rag/01-hooks/raw/hooks-reference-extract.md +250 -0
  23. package/rag/01-hooks/raw/session-end-reasons.md +21 -0
  24. package/rag/02-messages-api/raw/messages-api-extract.md +126 -0
  25. package/rag/03-settings/raw/sessions-extract.md +64 -0
  26. package/rag/04-skills/raw/initialUserMessage-investigation.md +101 -0
  27. package/rag/INDEX.md +164 -0
  28. package/src/baton.mjs +2 -2
  29. package/src/db.mjs +2 -2
  30. package/src/hook-entrypoints.test.mjs +390 -0
  31. package/src/package-files.test.mjs +1 -0
  32. package/src/prompt-submit.mjs +132 -5
  33. package/src/resume-context.mjs +23 -6
  34. package/src/resume-context.test.mjs +21 -5
  35. package/src/session-merger.mjs +1 -1
  36. package/src/session-start.mjs +155 -14
  37. package/src/spike-transcript-writer.mjs +196 -0
  38. package/src/spike-transcript-writer.test.mjs +298 -0
  39. package/src/state-file.mjs +1 -1
  40. package/src/token-monitor.mjs +1 -1
  41. package/src/transcript-reader.mjs +71 -0
  42. package/src/turn-backfill.mjs +131 -0
  43. package/src/turn-backfill.test.mjs +213 -0
  44. package/src/turn-processor.mjs +28 -40
  45. /package/docs/{throughline-codex-trim-rollback-incident-report.md → audit-2026-05/codex-trim-rollback-incident-report.md} +0 -0
@@ -19,6 +19,7 @@ allowed_paths:
19
19
  - bin/
20
20
  - docs/
21
21
  - package.json
22
+ - spike/
22
23
  - src/
23
24
 
24
25
  deny_paths:
@@ -35,6 +36,10 @@ deny_paths:
35
36
  - .codex-sidecar/logs/
36
37
 
37
38
  presets:
39
+ work:
40
+ workflow: work
41
+ readonly: false
42
+ prompt: "Implement the requested scoped change in the isolated worktree, run the listed verification commands, and report results."
38
43
  review:
39
44
  workflow: review
40
45
  readonly: true
package/CHANGELOG.md CHANGED
@@ -10,6 +10,112 @@ shipped to npm but were not individually tagged on GitHub.
10
10
 
11
11
  ## [Unreleased]
12
12
 
13
+ ## [0.6.0] — 2026-07-12
14
+
15
+ L2 capture is rebuilt from "save only the last pair each Stop" to a
16
+ full-transcript backfill, closing the permanent holes that left `/clear`
17
+ handoffs with empty or partial memory. Also documents that Claude Code
18
+ Desktop `/clear` cannot be auto-detected by hooks (upstream client bug).
19
+
20
+ ### Fixed
21
+
22
+ - **L2 capture completeness (backfill).** The Stop hook previously stored
23
+ only the last user/assistant pair, so any Stop that fired before the
24
+ transcript flushed — or did not fire at all — became a permanent gap in
25
+ `bodies`. Measured omission of completed logical turns was 27% (Desktop) /
26
+ 41% (VS Code). `turn-processor` now scans the whole transcript into logical
27
+ turn groups and backfills every uncaptured turn (`src/turn-backfill.mjs`
28
+ `backfillBodies`). On a `/clear` merge, `session-start` also backfills the
29
+ predecessor's transcript **before** rendering the resume context, so the
30
+ turn immediately preceding `/clear` is recovered. Verified end-to-end on a
31
+ real Desktop `/tl` → `/clear` handoff (successor inherits the full
32
+ predecessor conversation).
33
+ - Group-level dedup: a logical turn group whose fragments are already in
34
+ `bodies` is skipped whole, preventing duplicate pairs when a turn spans
35
+ multiple Stops (interrupts, plan rejections, AskUserQuestion replies).
36
+ - Representative fragment = the last non-junk assistant fragment; API
37
+ notices (e.g. session-limit messages) no longer overwrite the real reply.
38
+ - `created_at` uses the transcript entry timestamp so bulk-recovered rows
39
+ preserve conversation order for the L2 window / current anchor.
40
+ - Predecessor transcript path is derived deterministically from the project
41
+ path (`deriveTranscriptPath`); the state file is only a fallback, because
42
+ a predecessor whose Stop never fired has no state file.
43
+ - `readTranscript` now excludes `isSidechain` entries.
44
+
45
+ ### Known limitations
46
+
47
+ - **Claude Code Desktop `/clear` is undetectable by hooks.** Desktop sends
48
+ SessionStart `source:"startup"` (not `"clear"`) and SessionEnd
49
+ `reason:"other"` (indistinguishable from session deletion), so the auto
50
+ handoff path never fires there. Reported upstream
51
+ ([anthropics/claude-code#76704](https://github.com/anthropics/claude-code/issues/76704)).
52
+ Workaround: run `/tl` before `/clear` on Desktop.
53
+ - **Desktop can drop assistant text from the transcript entirely.** In long
54
+ tool-heavy turns, intermediate assistant text blocks are sometimes never
55
+ written to the session JSONL (permanent, no local recovery path). Reported
56
+ upstream ([anthropics/claude-code#76706](https://github.com/anthropics/claude-code/issues/76706)).
57
+
58
+ ## [0.5.0] — 2026-05-24
59
+
60
+ This release closes out the v0.5 transcript-injection investigation and
61
+ locks in **path C** (`resume-context.mjs` v2.1 header + 現在地 anchor) as
62
+ the plugin-scope completion form for Throughline.
63
+
64
+ ### Changed
65
+
66
+ - Strengthened the Claude `/clear` resume context header with two new
67
+ short-message handling rules so the cleared-me side stops misreading
68
+ follow-up shorts as fresh requests:
69
+ - **短文/相槌の判定**: any user message that is ≤50 chars or built solely
70
+ out of acknowledgment / agreement / prompt words (はい / うん / 了解 /
71
+ OK / やって / 進めて / 続き / 次) must be treated as a GO sign on the
72
+ previous assistant's proposed next move, not a new request, and the
73
+ cleared-me must not ask back, re-list options, or pivot to other work.
74
+ - **古い番号リストの再実行禁止**: when the latest user references an
75
+ older numbered list (e.g. `2 をやれ`) but the most recent assistant turn
76
+ already executed that item, the cleared-me must respond with a result
77
+ confirmation / next move, not by re-executing the already-done item.
78
+ The latest assistant utterance outranks any older numbered list
79
+ referenced from it.
80
+
81
+ ### Research (no shipped behavior change)
82
+
83
+ Two alternative injection routes were spiked end-to-end against real
84
+ Claude Code (v2.1.145) and both confirmed dead, locking path C as the
85
+ plugin-scope ceiling.
86
+
87
+ - **D route — transcript JSONL append** (Phase 0-2 / Phase 0-5): four
88
+ real-machine runs across `SessionStart` (chain `null` orphan) and
89
+ `UserPromptSubmit` (chain `b` reachable-from-attachment) timings, with
90
+ both synthetic and real Claude model names. All four runs produced
91
+ 「ない」when the cleared-me was asked to quote the spike tracer. Root
92
+ cause: Claude Code decides each new turn's `parentUuid` from its
93
+ in-process memory state and never re-reads the JSONL, so any text a
94
+ hook writes to `transcript_path` lives on a parallel chain that the
95
+ next prompt's parent-walk never reaches.
96
+ - **`hookSpecificOutput.initialUserMessage` route** (Phase 0-6): real
97
+ Claude Code interactive run on 2026-05-24 13:33 (tracer `9220a79c`,
98
+ session `0979ad20-…`) returned 「ない」, empirically confirming the
99
+ openclaude source comment that `initialUserMessage` is consumed only
100
+ for headless orchestrator sessions, not for the interactive `/clear`
101
+ scenario this project needs.
102
+
103
+ Both routes are kept in-tree behind marker files
104
+ (`~/.throughline/spike-inject.flag`,
105
+ `~/.throughline/spike-prompt.flag`,
106
+ `~/.throughline/initial-user-message-test.flag`) as research
107
+ infrastructure for future re-evaluation; they are no-op when the flags
108
+ are absent and have no effect on the shipped path.
109
+
110
+ ### Added
111
+
112
+ - `docs/10_transcript_injection_plan.md`: full Phase 0 plan and
113
+ result log for the D / `initialUserMessage` investigation.
114
+ - `rag/`: third-party spec knowledge base (Claude Code hooks
115
+ reference, Anthropic Messages API, sessions docs, openclaude
116
+ `initialUserMessage` source extract) used as the grounding for the
117
+ no-go calls above.
118
+
13
119
  ## [0.4.12] — 2026-05-17
14
120
 
15
121
  ### Changed
package/README.ja.md CHANGED
@@ -38,14 +38,18 @@ skill も登録する。75% 自動発火は token-monitor 依存ではなく、
38
38
 
39
39
  ## 他の手段との比較
40
40
 
41
- | | Throughline | MemGPT / SummaryBufferMemory | 素の Claude Code |
42
- |---|---|---|---|
43
- | **圧縮の軸** | コンテンツの **種類** (テキスト vs ツール I/O) | **新旧** (古い 要約) | 無し |
44
- | **コーディング用途への適合** | ツール I/O こそ重い 80% | 残したい部分まで圧縮される | |
45
- | **`/clear` 後の生存** | ✅ SQLite + typed `/clear` / `/tl` バトン | ホスト依存 | |
46
- | **誤継承リスク** | (typed `/clear` / `/tl` が前任を指名) | | |
47
- | **ランタイム依存** | **ゼロ** (Node 22.5+ 同梱の `node:sqlite`) | 多数 | — |
48
- | **マルチセッション トークン監視** | Claude 実測 `message.usage`、Codex rollout `token_count` | | |
41
+ | | **Throughline** | `/clear` (組み込み) | `/compact` (組み込み) | MemGPT / SummaryBufferMemory |
42
+ |---|---|---|---|---|
43
+ | **何をする** | ツール I/O を SQLite に退避、本文は残す | ウィンドウを全消去 | ウィンドウ全体を LLM 要約 | 新旧で要約 |
44
+ | **圧縮の軸** | コンテンツの **種類** (テキスト vs ツール I/O) | 無し全消去 | **新旧** (一律) | **新旧** (一律) |
45
+ | **境界後に残る記憶** | ✅ 直近 20 ターン本文 + それ以前 L1 + L3 オンデマンド | ゼロ | 一個の要約 (情報欠落) | △ 要約 (情報欠落) |
46
+ | **ツール I/O の扱い** | L3 に退避、`/sc-detail HH:MM:SS` で取り戻せる | 消える | 要約に溶けて読めない | 要約に溶ける |
47
+ | **コーディング用途への適合** | ツール I/O こそ重い 80% | — 文脈が切れる | ただし不可逆 | 中 |
48
+ | **誤継承リスク** | (typed `/clear` / `/tl` が前任を指名) | n/a | n/a | 高 |
49
+ | **ランタイム依存** | **ゼロ** (Node 22.5+ 同梱の `node:sqlite`) | n/a | n/a | 多数 |
50
+ | **マルチセッション トークン監視** | ✅ 実測 `message.usage` / Codex rollout `token_count` | — | — | — |
51
+
52
+ **ひとことで**: `/clear` は全部捨てる、`/compact` は全部混ぜる、Throughline は **書いた本文はそのまま残し、ツール出力 (= 80% の重量物) だけ退避** する。
49
53
 
50
54
  <details>
51
55
  <summary><b>なぜこれが効くのか — 80% ツール I/O 問題</b></summary>
@@ -54,18 +58,25 @@ skill も登録する。75% 自動発火は token-monitor 依存ではなく、
54
58
  ファイル読み込み、Bash 出力、grep 結果。これらは Claude が即座に消費するデータですが、
55
59
  コンテキスト上には永久に残り、ウィンドウ上限に向かって押し出されていきます。
56
60
 
57
- Throughline はこの問題を、会話を **時間ではなく種類** で分離することで解決します:
61
+ ```mermaid
62
+ xychart-beta
63
+ title "コーディング 50 ターン後のコンテキスト (典型例)"
64
+ x-axis ["Throughline 無し", "/clear + Throughline 再開後"]
65
+ y-axis "コンテキスト内トークン数" 0 --> 140000
66
+ bar [125000, 13000]
67
+ ```
58
68
 
59
69
  ```
60
70
  Throughline 無し (50 ターン、/clear なし):
61
- コンテキスト = ユーザー文 + アシスタント文 + ツール I/O + システムメッセージ
62
- 125,000 トークン (うち 80% は二度と読み返さないツール I/O)
71
+ ユーザー / アシスタント本文 ~25,000 tok ████
72
+ ツール I/O (80%) ~100,000 tok ████████████████
73
+ ≈ 125,000 tok 合計
63
74
 
64
75
  Throughline 有り (50 ターン → /clear → 再開):
65
- コンテキスト = 直近 20 ターンの会話本文 (L2)
66
- + それ以前 30 ターンの一行要約 (L1)
67
- + ツール I/O ゼロ (L3 — SQLite に退避、必要時にだけ取得)
68
- ≈ 13,000 トークン同じ判断、同じ文脈、90% 軽量
76
+ 直近 20 ターン L2 ~10,000 tok ██
77
+ それ以前 30 ターン L1 ~3,000 tok ▌
78
+ ツール I/O 0 tok (SQLite 退避、オンデマンド取得)
79
+ ≈ 13,000 tok — 90% 軽量
69
80
  ```
70
81
 
71
82
  MemGPT や LangChain の SummaryBufferMemory が **新旧** で圧縮するのに対し、
@@ -210,6 +221,9 @@ S1 (4 ターン) --/clear--> S2 (S1 を auto-merge + 3 ターン追加) --/clear
210
221
 
211
222
  ---
212
223
 
224
+ <details>
225
+ <summary><b>Codex sidecar と Codex trim</b> — operator 向け adapter 詳細 (クリックで展開)</summary>
226
+
213
227
  ## Codex sidecar と Codex trim
214
228
 
215
229
  Throughline の主軸は引き続き **Claude Code** です。Codex 対応は、Claude hooks /
@@ -227,6 +241,8 @@ memory inject を直接実行します。Claude 側は `/clear` での auto path
227
241
  SessionStart 注入の Reading Contract / Continuation Instruction で同じ意図を
228
242
  継承しています。
229
243
 
244
+ </details>
245
+
230
246
  ---
231
247
 
232
248
  ## マルチセッション トークン監視
@@ -306,12 +322,12 @@ Throughline state をまだ書いていない現在セッションも表示で
306
322
 
307
323
  ## 設計ドキュメント
308
324
 
309
- - [`docs/L1_L2_L3_REDESIGN.md`](docs/L1_L2_L3_REDESIGN.md) — L1/L2/L3 差分階層モデルの **設計仕様書** (schema v4 ベース + v5 L3 分類拡張)。記憶階層化ルールの正典
310
- - [`docs/INHERITANCE_ON_CLEAR_ONLY.md`](docs/INHERITANCE_ON_CLEAR_ONLY.md) — `/tl` バトン引き継ぎ方式の設計判断記録 (schema v6–v7)
311
- - [`docs/THROUGHLINE_CODEX_DUAL_SUPPORT.md`](docs/THROUGHLINE_CODEX_DUAL_SUPPORT.md) — Claude 主軸を維持したまま Codex 対応を足すための architecture brief
312
- - [`docs/throughline-rollback-context-trim-insight.md`](docs/throughline-rollback-context-trim-insight.md) — rollback / trim 設計 insight。復元 memory を current work として読ませる制約も記録
313
- - [`docs/THROUGHLINE_CODEX_TRIM_IMPLEMENTATION_PLAN.md`](docs/THROUGHLINE_CODEX_TRIM_IMPLEMENTATION_PLAN.md) — Claude/Codex 両対応と rollback trim の統合 TODO 計画
314
- - [`docs/PUBLIC_RELEASE_PLAN.md`](docs/PUBLIC_RELEASE_PLAN.md) — 公開配布化プラン、§ 0 フォールバック禁止ルール、バージョン別実装ステータス
325
+ - [`docs/01_l1_l2_l3_redesign.md`](docs/01_l1_l2_l3_redesign.md) — L1/L2/L3 差分階層モデルの **設計仕様書** (schema v4 ベース + v5 L3 分類拡張)。記憶階層化ルールの正典
326
+ - [`docs/03_inheritance_on_clear_only.md`](docs/03_inheritance_on_clear_only.md) — `/tl` バトン引き継ぎ方式の設計判断記録 (schema v6–v7)
327
+ - [`docs/08_codex_dual_support.md`](docs/08_codex_dual_support.md) — Claude 主軸を維持したまま Codex 対応を足すための architecture brief
328
+ - [`docs/09_rollback_context_trim_insight.md`](docs/09_rollback_context_trim_insight.md) — rollback / trim 設計 insight。復元 memory を current work として読ませる制約も記録
329
+ - [`docs/07_codex_trim_implementation_plan.md`](docs/07_codex_trim_implementation_plan.md) — Claude/Codex 両対応と rollback trim の統合 TODO 計画
330
+ - [`docs/04_public_release_plan.md`](docs/04_public_release_plan.md) — 公開配布化プラン、§ 0 フォールバック禁止ルール、バージョン別実装ステータス
315
331
  - [`CHANGELOG.md`](CHANGELOG.md) — リリース履歴
316
332
  - [`docs/archive/`](docs/archive/) — 破棄済み旧設計 (CONCEPT 初期案、session-linking 実験記録など)
317
333
 
package/README.md CHANGED
@@ -50,14 +50,18 @@ guarded `trim --execute --host codex` surface.
50
50
 
51
51
  ## How it compares
52
52
 
53
- | | Throughline | MemGPT / SummaryBufferMemory | Plain Claude Code |
54
- |---|---|---|---|
55
- | **Compression axis** | content **type** (text vs tool I/O) | **recency** (old summarized) | none |
56
- | **Coding-assistant fit** | high tool I/O is the heavy 80% | mediumalso compresses what you want to keep | |
57
- | **`/clear` survival** | ✅ via SQLite + typed `/clear` / `/tl` baton | depends on host | ❌ |
58
- | **Auto-inheritance risk** | low (typed `/clear` or `/tl` names the predecessor) | high | |
59
- | **Runtime deps** | **zero** (Node 22.5+ built-in `node:sqlite`) | many | — |
60
- | **Multi-session token monitor** | Claude real `message.usage`; Codex rollout `token_count` when available | | |
53
+ | | **Throughline** | `/clear` (built-in) | `/compact` (built-in) | MemGPT / SummaryBufferMemory |
54
+ |---|---|---|---|---|
55
+ | **What it does** | retire tool I/O to SQLite, keep text in-context | wipe the whole window | LLM-summarize the whole window | recency-based summarize |
56
+ | **Compression axis** | content **type** (text vs tool I/O) | nonefull wipe | **recency** (uniform) | **recency** (uniform) |
57
+ | **Memory after the boundary** | ✅ recent 20 turns verbatim + older as L1 + L3 on demand | ❌ zero | △ lossy single summary | △ lossy summary |
58
+ | **Tool I/O handling** | retired to L3, retrievable by `/sc-detail HH:MM:SS` | gone | folded into summary, unreadable | folded into summary |
59
+ | **Coding-assistant fit** | high tool I/O is the heavy 80% | low — you lose the thread | medium but irreversible | medium |
60
+ | **Auto-inheritance risk** | low (typed `/clear` / `/tl` names the predecessor) | n/a | n/a | high |
61
+ | **Runtime deps** | **zero** (Node 22.5+ built-in `node:sqlite`) | n/a | n/a | many |
62
+ | **Multi-session token monitor** | ✅ real `message.usage` / Codex rollout `token_count` | — | — | — |
63
+
64
+ **Short version**: `/clear` throws everything away, `/compact` blurs everything together, Throughline keeps the *text* you wrote verbatim and only retires the *tool output* — which is where 80% of the bloat lives.
61
65
 
62
66
  <details>
63
67
  <summary><b>Why this matters — the 80% tool-I/O problem</b></summary>
@@ -67,24 +71,32 @@ file reads, Bash output, grep results. This data is consumed the moment Claude
67
71
  acts on it, but it stays in the context forever, pushing you toward the window
68
72
  limit.
69
73
 
70
- Throughline fixes this by separating conversation content by **type, not time**:
74
+ ```mermaid
75
+ xychart-beta
76
+ title "Context after 50 turns of coding work (typical session)"
77
+ x-axis ["Without Throughline", "After /clear + Throughline resume"]
78
+ y-axis "Tokens in context" 0 --> 140000
79
+ bar [125000, 13000]
80
+ ```
71
81
 
72
82
  ```
73
83
  Without Throughline (50 turns, no /clear):
74
- Context = user text + assistant text + tool I/O + system messages
75
- ≈ 125,000 tokens (80% is tool I/O you'll never re-read)
84
+ user/assistant text ~25,000 tok ████
85
+ tool I/O (80%) ~100,000 tok ████████████████
86
+ ≈ 125,000 tok total
76
87
 
77
88
  With Throughline (50 turns → /clear → resume):
78
- Context = recent 20 turns of conversation text (L2)
79
- + older 30 turns as one-line summaries (L1)
80
- + zero tool I/O (L3 — retired to SQLite, on-demand)
81
- ≈ 13,000 tokenssame decisions, same context, 90% lighter
89
+ recent 20 turns L2 ~10,000 tok ██
90
+ older 30 turns L1 ~3,000 tok ▌
91
+ tool I/O 0 tok (retired to SQLite, on-demand)
92
+ ≈ 13,000 tok total — 90% lighter
82
93
  ```
83
94
 
95
+ Throughline separates conversation content by **type, not time**: human-readable
96
+ conversation stays in-context, machine-generated tool output retires to L3.
84
97
  Unlike MemGPT or LangChain's SummaryBufferMemory which compress by **recency**
85
- (old = summarized), Throughline separates by **content type**: human-readable
86
- conversation stays, machine-generated tool output retires. This is purpose-built
87
- for coding assistants where tool I/O is heavy but transient.
98
+ (old = summarized), this is purpose-built for coding assistants where tool I/O
99
+ is heavy but transient.
88
100
 
89
101
  The retired L3 data isn't lost — Claude can pull it back on demand via
90
102
  `throughline detail <time>` when a past turn's tool output becomes relevant
@@ -242,6 +254,9 @@ S1 (4 turns) --/clear--> S2 (auto-merges S1, adds 3 turns) --/clear--> S3 (auto-
242
254
 
243
255
  ---
244
256
 
257
+ <details>
258
+ <summary><b>Codex sidecar and Codex trim</b> — operator-level adapter details (click to expand)</summary>
259
+
245
260
  ## Codex sidecar and Codex trim
246
261
 
247
262
  Throughline is still **Claude Code first**. Codex support is an adapter layer:
@@ -535,6 +550,8 @@ the full text remains in `--json` as `memoryPreview.text`, and for Codex the
535
550
  fresh-thread continuation can be guided with `codex-handoff-start` or rendered
536
551
  directly with the `codex-resume` command shown in the fresh-thread continuation path.
537
552
 
553
+ </details>
554
+
538
555
  ---
539
556
 
540
557
  ## Multi-session token monitor
@@ -827,7 +844,7 @@ The only tolerated silent paths are:
827
844
  - JSONL per-line parse tolerance (tail partial writes are part of the format spec)
828
845
  - State-file corruption recovery (files are idempotently regenerated next turn)
829
846
 
830
- See [`docs/PUBLIC_RELEASE_PLAN.md §0`](docs/PUBLIC_RELEASE_PLAN.md) for the full
847
+ See [`docs/04_public_release_plan.md §0`](docs/04_public_release_plan.md) for the full
831
848
  rule.
832
849
 
833
850
  ---
@@ -852,6 +869,10 @@ See [`src/haiku-summarizer.mjs`](src/haiku-summarizer.mjs) for the implementatio
852
869
 
853
870
  ## Troubleshooting
854
871
 
872
+ ### Claude Code Desktop `/clear`
873
+
874
+ Automatic inheritance (the auto path) does not fire for `/clear` in Claude Code Desktop: the client does not send `source="clear"` and also mislabels the SessionEnd `reason` as `"other"`. This is reported upstream in [anthropics/claude-code#76704](https://github.com/anthropics/claude-code/issues/76704). On Desktop, run `/tl` before `/clear` (the baton lasts one hour). The 0.6.0 backfill work means this `/tl` handoff carries complete L2 through the immediately preceding turn. The VS Code extension's `/clear` auto-handoff works normally.
875
+
855
876
  **Monitor says `待機中 — アクティブなセッションがありません`**
856
877
  No session has touched its state file in the last 15 minutes. Send a message in
857
878
  Claude Code and the monitor should pick it up within 1 second. If it still does
@@ -992,25 +1013,25 @@ the first generation to pick up the auto-start task.
992
1013
 
993
1014
  ## Design docs
994
1015
 
995
- - [`docs/L1_L2_L3_REDESIGN.md`](docs/L1_L2_L3_REDESIGN.md) — **core design
1016
+ - [`docs/01_l1_l2_l3_redesign.md`](docs/01_l1_l2_l3_redesign.md) — **core design
996
1017
  spec** for the L1/L2/L3 differential layer model (schema v4 base + v5 L3
997
1018
  classification extension). Authoritative for the memory layering rules.
998
- - [`docs/INHERITANCE_ON_CLEAR_ONLY.md`](docs/INHERITANCE_ON_CLEAR_ONLY.md) —
1019
+ - [`docs/03_inheritance_on_clear_only.md`](docs/03_inheritance_on_clear_only.md) —
999
1020
  design record for the `/tl` baton handoff system (schema v6–v7). Explains
1000
1021
  why the current inheritance is opt-in rather than heuristic.
1001
- - [`docs/THROUGHLINE_CODEX_DUAL_SUPPORT.md`](docs/THROUGHLINE_CODEX_DUAL_SUPPORT.md) —
1022
+ - [`docs/08_codex_dual_support.md`](docs/08_codex_dual_support.md) —
1002
1023
  architecture brief for adding Codex support without replacing the Claude
1003
1024
  Code hook/slash-command path.
1004
- - [`docs/throughline-rollback-context-trim-insight.md`](docs/throughline-rollback-context-trim-insight.md) —
1025
+ - [`docs/09_rollback_context_trim_insight.md`](docs/09_rollback_context_trim_insight.md) —
1005
1026
  design insight for context rollback/trim, including why restored memory must
1006
1027
  be framed as current work rather than passive history.
1007
- - [`docs/THROUGHLINE_CODEX_FIRST_ROADMAP.md`](docs/THROUGHLINE_CODEX_FIRST_ROADMAP.md) —
1028
+ - [`docs/05_codex_first_roadmap.md`](docs/05_codex_first_roadmap.md) —
1008
1029
  current next-phase TODO plan: Codex primary first, Codex rewind-compatible
1009
1030
  trim next, Claude rewind finalization after that.
1010
- - [`docs/THROUGHLINE_CODEX_TRIM_IMPLEMENTATION_PLAN.md`](docs/THROUGHLINE_CODEX_TRIM_IMPLEMENTATION_PLAN.md) —
1031
+ - [`docs/07_codex_trim_implementation_plan.md`](docs/07_codex_trim_implementation_plan.md) —
1011
1032
  historical integrated TODO plan and implementation record for Claude/Codex
1012
1033
  dual support and rollback trim.
1013
- - [`docs/PUBLIC_RELEASE_PLAN.md`](docs/PUBLIC_RELEASE_PLAN.md) — public
1034
+ - [`docs/04_public_release_plan.md`](docs/04_public_release_plan.md) — public
1014
1035
  release plan, implementation status by version, § 0 fallback rule, and
1015
1036
  remaining tasks.
1016
1037
  - [`docs/archive/`](docs/archive/) — superseded design documents kept for
@@ -0,0 +1,34 @@
1
+ # Throughline Documentation Overview
2
+
3
+ このディレクトリは Throughline の設計・計画・監査記録の入口です。実装判断は常に source を正とし、文書は現行実装へ追従させます。
4
+
5
+ ## Canonical Docs
6
+
7
+ | 文書 | 役割 |
8
+ |---|---|
9
+ | [01_l1_l2_l3_redesign.md](01_l1_l2_l3_redesign.md) | L1/L2/L3 記憶レイヤーの設計記録 |
10
+ | [02_clear_auto_handoff_plan.md](02_clear_auto_handoff_plan.md) | `/clear` / `/tl` handoff の現行仕様と計画 |
11
+ | [03_inheritance_on_clear_only.md](03_inheritance_on_clear_only.md) | 2026-04 段階の継承方式検証履歴 |
12
+ | [04_public_release_plan.md](04_public_release_plan.md) | 公開配布化、フォールバック禁止、リリース状態 |
13
+ | [05_codex_first_roadmap.md](05_codex_first_roadmap.md) | Codex primary / trim / Claude finalization の実装順 |
14
+ | [06_codex_trim_rollback_fix_plan.md](06_codex_trim_rollback_fix_plan.md) | Codex rollback / inject incident 後の修正計画 |
15
+ | [07_codex_trim_implementation_plan.md](07_codex_trim_implementation_plan.md) | Codex 両対応 + rollback trim の旧統合計画と実装履歴 |
16
+ | [08_codex_dual_support.md](08_codex_dual_support.md) | Claude primary を維持した Codex adapter 方針 |
17
+ | [09_rollback_context_trim_insight.md](09_rollback_context_trim_insight.md) | rollback を context delete primitive と見る設計メモ |
18
+ | [10_transcript_injection_plan.md](10_transcript_injection_plan.md) | transcript injection 検証計画と v0.5 実機結果 |
19
+ | [11_codex_monitor_implementation_plan.md](11_codex_monitor_implementation_plan.md) | Codex monitor 対応の実装記録 |
20
+
21
+ ## Supporting Records
22
+
23
+ | 場所 | 役割 |
24
+ |---|---|
25
+ | [adr/](adr/) | 根幹の設計判断 |
26
+ | [audit-2026-05/](audit-2026-05/) | 2026-05 の監査・インシデント記録 |
27
+ | [archive/](archive/) | 破棄または履歴扱いの旧設計 |
28
+ | [../rag/INDEX.md](../rag/INDEX.md) | 外部仕様・調査の再利用棚 |
29
+
30
+ ## Entrypoints
31
+
32
+ - [../CLAUDE.md](../CLAUDE.md): AI 作業者向けの正本。
33
+ - [../README.md](../README.md): ユーザー向けの入口。
34
+ - [../AGENTS.md](../AGENTS.md): Codex など Claude Code 以外のエージェント向け入口。
@@ -1,6 +1,6 @@
1
1
  # 新 L1/L2/L3 設計(再定義)
2
2
 
3
- > **Status**: 実装完了(2026-04-16 時点)。この文書は **L1/L2/L3 再定義の設計記録**であり、schema v4-v5 相当の変更までを扱う。以後の `handoff_batons` (v6)・`memo_text` (v7)・state.usage スナップショット・VSCode 自動起動・monitor 診断機能は本仕様と独立で、[CLAUDE.md](../CLAUDE.md) と [PUBLIC_RELEASE_PLAN.md](PUBLIC_RELEASE_PLAN.md) に索引あり。
3
+ > **Status**: 実装完了(2026-04-16 時点)。この文書は **L1/L2/L3 再定義の設計記録**であり、schema v4-v5 相当の変更までを扱う。以後の `handoff_batons` (v6)・`memo_text` (v7)・state.usage スナップショット・VSCode 自動起動・monitor 診断機能は本仕様と独立で、[CLAUDE.md](../CLAUDE.md) と [04_public_release_plan.md](04_public_release_plan.md) に索引あり。
4
4
  > 全ステップ (1〜8) 実装済み。L1/L2/L3 すべて書き込みパスが稼働。schema v5 で details に `kind` / `source_id` 列追加済み。
5
5
  > 進捗の詳細は「実装順序」セクション末尾の進捗表を参照。
6
6
 
@@ -240,7 +240,7 @@ N=20 は中央値の約 1.5 倍、p75 の少し下。典型的なセッション
240
240
  - [src/session-merger.mjs](../src/session-merger.mjs) — **bodies テーブルも merge 追従対象に追加**、judgments 張り替えロジックは削除(skeletons/details/bodies の 3 テーブルで session_id 張り替え)
241
241
  - `src/detail-capture.mjs` — **削除**(Stop フックに統合)
242
242
  - `.claude-plugin/hooks.json` — detail-capture の PostToolUse 登録を削除
243
- - [.claude/settings.json](../.claude/settings.json) — classifier / detail-capture 関連 hook があれば削除
243
+ - `.claude/settings.json` / `.claude/settings.local.json` — classifier / detail-capture 関連 hook がローカル設定にあれば削除
244
244
  - [docs/archive/CONCEPT.md](archive/CONCEPT.md) — 再定義の反映
245
245
  - **新規**: `commands/sc-detail.md` — L3 オンデマンド参照コマンド。bodies 設計と同時実装必須
246
246
 
@@ -279,7 +279,7 @@ N=20 は中央値の約 1.5 倍、p75 の少し下。典型的なセッション
279
279
  - ~~src/context-injector.mjs~~ から judgments 読み出しを削除(ファイル自体が廃止済み)
280
280
  - [src/session-merger.mjs](../src/session-merger.mjs) から judgments の UPDATE を削除
281
281
  - `src/classifier.mjs` 削除
282
- - [.claude/settings.json](../.claude/settings.json) / `.claude-plugin/hooks.json` から classifier 関連 hook があれば削除
282
+ - `.claude/settings.json` / `.claude/settings.local.json` / `.claude-plugin/hooks.json` から classifier 関連 hook があれば削除
283
283
  - この段階では judgments テーブルは DB に残したまま。参照が消えただけ
284
284
 
285
285
  2. **schema v4 migration** — [src/db.mjs](../src/db.mjs)
@@ -4,7 +4,7 @@
4
4
  2026-05-08 セッションの議論と実機検証、外部仕様調査に基づく。
5
5
  A 案 (= /clear で自動引継ぎ + /tl は逃げ道として残す + /tl-trim 廃止) **採択確定**。
6
6
 
7
- > 過去の経緯 (なぜ `/tl` バトンを採用したか) は [INHERITANCE_ON_CLEAR_ONLY.md](INHERITANCE_ON_CLEAR_ONLY.md) を参照。
7
+ > 過去の経緯 (なぜ `/tl` バトンを採用したか) は [03_inheritance_on_clear_only.md](03_inheritance_on_clear_only.md) を参照。
8
8
  > 本書は **2026-05-08 時点の現状検証 + 新理想設計** を扱う。
9
9
 
10
10
  > **2026-05-09 (v0.4.1) update**: 2 経路の優先順位を **入れ替えた**。
@@ -136,7 +136,7 @@ on SessionStart(source, session_id, project_path):
136
136
  - 元機能: memo 入力 + dry-run preview 表示
137
137
  - 新仕様で memo 廃止 + 軽量化方針 → 役割なし
138
138
  - 削除対象:
139
- - [.claude/commands/tl-trim.md](../.claude/commands/tl-trim.md) (slash command)
139
+ - `.claude/commands/tl-trim.md` (deleted slash command)
140
140
  - [src/cli/trim.mjs](../src/cli/trim.mjs) の **Claude path 部分のみ** 削除 (`describeTrimHost('claude')` ブランチ、Claude 用 memory preview 経路など)
141
141
  - 関連 test
142
142
  - **維持** (Codex 側を壊さないため):
@@ -218,7 +218,7 @@ auto-compaction は Claude Code 内部の context 圧縮で、conversation 連
218
218
  - [ ] **`src/prompt-submit.mjs`**: 維持 (baton 書き込み + ensureMonitorTaskFile)
219
219
  - [ ] **[.claude/commands/tl.md](../.claude/commands/tl.md)**: memo 4 項目入力要求を削除、純粋に「baton 立てるだけ」の最小実装に書き換え
220
220
  - [x] **`/tl-trim` 関連削除**:
221
- - [.claude/commands/tl-trim.md](../.claude/commands/tl-trim.md) ファイル削除
221
+ - `.claude/commands/tl-trim.md` ファイル削除
222
222
  - **`src/cli/trim.mjs` 自体は維持**: Codex 経路 (`--host codex`, `--preflight`, `--execute`, `--codex-app-server-bin` 等) と doctor `--trim --host claude` で使う `describeTrimHost('claude')` の dry-run 表示が依存しているため、コード削除はしない (= ユーザーが直接 `throughline trim --host claude --dry-run` を打つ余地は残す。実用は SessionStart 自動経路に置き換わる)
223
223
  - [ ] **[src/cli/install.mjs](../src/cli/install.mjs)**: Throughline 管理 slash commands の copy 対象リストから `tl-trim.md` を除外。`tl.md` は維持。`src/cli/install.test.mjs` の関連 test も update
224
224
  - [ ] **[bin/throughline.mjs](../bin/throughline.mjs) の `showHelp()` 文言 update**:
@@ -246,8 +246,8 @@ auto-compaction は Claude Code 内部の context 圧縮で、conversation 連
246
246
  - `THROUGHLINE_DISABLE_AUTO_HANDOFF` env var 紹介を新規追加
247
247
  - 既存 `inflight-memo.log` ファイルは新版で書き込み停止することを README で告知 (= 手動削除提案)
248
248
  - [CHANGELOG.md](../CHANGELOG.md): breaking change を明示 (memo 廃止、save-inflight 削除、/tl-trim 削除、`updateBatonMemo` 削除、baton_has_memo フィールド削除)
249
- - [INHERITANCE_ON_CLEAR_ONLY.md](INHERITANCE_ON_CLEAR_ONLY.md): 「2026-04 段階の検証 → 2026-05 でバグ修正により案 A 成立、本書は履歴扱い」note 追加
250
- - [PUBLIC_RELEASE_PLAN.md](PUBLIC_RELEASE_PLAN.md): version bump + breaking change 反映
249
+ - [03_inheritance_on_clear_only.md](03_inheritance_on_clear_only.md): 「2026-04 段階の検証 → 2026-05 でバグ修正により案 A 成立、本書は履歴扱い」note 追加
250
+ - [04_public_release_plan.md](04_public_release_plan.md): version bump + breaking change 反映
251
251
  - [ ] **package.json**: **0.4.0** に bump (semver minor、pre-1.0 の breaking)
252
252
  - [ ] **caveat 記録**: 「`/clear` SessionStart `source` は 2.1.128 で reliable、過去 #49937 は fix 済み」を public で記録
253
253
 
@@ -258,7 +258,7 @@ auto-compaction は Claude Code 内部の context 圧縮で、conversation 連
258
258
  廃止対象:
259
259
  - `src/cli/save-inflight.mjs` (~80 行) → 削除
260
260
  - `src/cli/trim.mjs` の Claude path 部分 (~30 行) → 削除 (Codex path は維持)
261
- - [.claude/commands/tl-trim.md](../.claude/commands/tl-trim.md) (~40 行) → 削除
261
+ - `.claude/commands/tl-trim.md` (~40 行) → 削除
262
262
  - `src/baton.mjs` の `updateBatonMemo` 関数 (~10 行) → 削除
263
263
  - `handoff_batons.memo_text` 列 (schema migration、コードへの影響は consumeBaton 戻り値変更のみ)
264
264
  - `src/hook-entrypoints.test.mjs` 内 save-inflight test ケース (~30 行) → 削除
@@ -13,7 +13,7 @@
13
13
  > メニュー由来 `/clear` のように UserPromptSubmit に届かない経路のための
14
14
  > fallback で、`THROUGHLINE_DISABLE_AUTO_HANDOFF=1` で OFF にできる (typed
15
15
  > `/clear` / `/tl` は env と無関係に引き続き発火する)。詳細は
16
- > [THROUGHLINE_CLEAR_AUTO_HANDOFF_PLAN.md](THROUGHLINE_CLEAR_AUTO_HANDOFF_PLAN.md)。
16
+ > [02_clear_auto_handoff_plan.md](02_clear_auto_handoff_plan.md)。
17
17
  >
18
18
  > 本書は当時のバトン採用判断を残す履歴ドキュメント。「結局 baton primary に
19
19
  > 戻った」という結末は皮肉だが、当時の判断は VSCode 拡張側 source バグへの
@@ -129,7 +129,7 @@ Throughline の SessionStart フックは現在 **同一 project_path の未合
129
129
  - 注入は session-start.mjs 側の `mergeResult.merged` 分岐で既に制御されているので修正不要
130
130
  - ただし「同一 session 継続(source='resume')での注入」が必要か要検討。現状の resume フックは本計画のスコープ外として deferred(別タスクで検討)
131
131
 
132
- 4. **[docs/L1_L2_L3_REDESIGN.md](L1_L2_L3_REDESIGN.md) / [CLAUDE.md](../CLAUDE.md) / [README.md](../README.md) の更新**
132
+ 4. **[docs/01_l1_l2_l3_redesign.md](01_l1_l2_l3_redesign.md) / [CLAUDE.md](../CLAUDE.md) / [README.md](../README.md) の更新**
133
133
  - 「記憶張り替えの発火条件は SessionStart source='clear' のみ」を明記
134
134
  - CLAUDE.md 冒頭「設計の核」の「`/clear` 後も SQLite はそのまま残る。`SessionStart` フックで前任セッションの全レコードを新 session_id に張り替える」の直後に引き継ぎ条件を追記
135
135
 
@@ -158,7 +158,7 @@ Throughline の SessionStart フックは現在 **同一 project_path の未合
158
158
  - [src/session-merger.mjs](../src/session-merger.mjs) — 参照のみ(現状維持)
159
159
  - [src/session-merger.test.mjs](../src/session-merger.test.mjs) — テスト追加
160
160
  - [src/resume-context.mjs](../src/resume-context.mjs) — 参照のみ
161
- - [CLAUDE.md](../CLAUDE.md) / [docs/L1_L2_L3_REDESIGN.md](L1_L2_L3_REDESIGN.md) / [README.md](../README.md) — ドキュメント更新
161
+ - [CLAUDE.md](../CLAUDE.md) / [docs/01_l1_l2_l3_redesign.md](01_l1_l2_l3_redesign.md) / [README.md](../README.md) — ドキュメント更新
162
162
 
163
163
  ## Non-Goals (本計画では扱わない)
164
164
 
@@ -79,7 +79,7 @@ schema v4 で PostToolUse (`capture-tool`) は廃止、L2/L3 は Stop 内で一
79
79
  | schema v5 migration(details に kind / source_id 追加、L3 分離書き込み対応) | [src/db.mjs](../src/db.mjs) |
80
80
  | schema v6 migration(handoff_batons テーブル追加、`/tl` バトン引き継ぎ方式) | [src/db.mjs](../src/db.mjs), [src/baton.mjs](../src/baton.mjs) |
81
81
  | schema v7 migration(`handoff_batons.memo_text` カラム追加、in-flight メモ保存) | (v8 で memo_text drop、save-inflight 削除済み) |
82
- | schema v8 migration(`handoff_batons.memo_text` drop、`/clear` auto path 化、`save-inflight` / `/tl-trim` / `updateBatonMemo` 削除、注入を L1+L2+L3 refs のみに簡素化) | [src/db.mjs](../src/db.mjs), [src/session-start.mjs](../src/session-start.mjs), [src/resume-context.mjs](../src/resume-context.mjs), [docs/THROUGHLINE_CLEAR_AUTO_HANDOFF_PLAN.md](THROUGHLINE_CLEAR_AUTO_HANDOFF_PLAN.md) |
82
+ | schema v8 migration(`handoff_batons.memo_text` drop、`/clear` auto path 化、`save-inflight` / `/tl-trim` / `updateBatonMemo` 削除、注入を L1+L2+L3 refs のみに簡素化) | [src/db.mjs](../src/db.mjs), [src/session-start.mjs](../src/session-start.mjs), [src/resume-context.mjs](../src/resume-context.mjs), [docs/02_clear_auto_handoff_plan.md](02_clear_auto_handoff_plan.md) |
83
83
  | VSCode `.vscode/tasks.json` の自動プロビジョニング(token-monitor の folderOpen 自動起動) | [src/vscode-task.mjs](../src/vscode-task.mjs) |
84
84
  | Stop フック時の state.usage スナップショット(monitor の「止まって見える」問題の切り分け用) | [src/state-file.mjs](../src/state-file.mjs), [src/turn-processor.mjs](../src/turn-processor.mjs) |
85
85
  | `throughline doctor --session <id-prefix>` セッション診断(state/transcript ズレ検出) | [src/cli/doctor.mjs](../src/cli/doctor.mjs) |
@@ -132,9 +132,9 @@ schema v4 で PostToolUse (`capture-tool`) は廃止、L2/L3 は Stop 内で一
132
132
  | **npm 公開 (v0.3.25): Codex VS Code rollback smoke verifier** | `throughline codex-vscode-rollback-smoke --verify --codex-thread-id <id>` を追加。rollout を read-only で読み、rollback event、rollback 済み user text、rollback 後 user turn、`restoreSafety.status = ok` を必須条件にする。`--after-vscode-restart` がある場合だけ `restartSafe: true` を返す。実 incident-shaped live rollback run では `thread_rolled_back` と injected memory は記録されたが、rollback 対象 user text が `compacted.replacement_history` に残り、後続 verifier では rollback 済み user text の再出現も観測した。後続分類で app-server response 上の retained text は `aggregatedOutput` に限定され、controlled rollback model-visible smoke は再現しなかったため、これは現在は diagnostic evidence として扱う |
133
133
  | **npm 公開 (v0.3.25): Codex primary doctor** | `throughline doctor --codex` を追加。現在 project の Codex thread env identity、rollout candidates、captured `codex:<thread_id>` DB sessions、context-refresh memory contract、new-thread handoff readiness、safe continuation status、host primitive audit status、次に使う capture / handoff / resume / audit command を表示する。doctor 自体は read-only で、Codex thread / DB / Claude settings を変更しない。`doctor --trim --host codex` も host primitive audit status を表示する |
134
134
  | **npm 公開 (v0.3.25): Codex global Stop hook / skill install** | `throughline install` が Claude hooks / slash commands に加えて `~/.codex/hooks.json` に絶対 node + installed `bin/throughline.mjs codex-hook stop` を `async: false` で登録し、`~/.codex/config.toml` の `[features].codex_hooks = true` を有効化し、`~/.codex/skills/throughline` に `$throughline` skill を配置する。Codex App Server / VSCode host の PATH 差分で bare `throughline` が見えない可能性があるため、hook は Caveat と同じ絶対パス型に寄せる。既存 Caveat / Spotter などの Codex hooks は保持し、`throughline uninstall` は Throughline 管理の Codex hook / skill だけを削除する。既に bare command または `async: true` で登録済みの Throughline Codex Stop hook は次回 install で更新する。実環境では `codex exec --json` child thread `019dfd4f-93ff-7522-8f89-bd1e1996c8d7` が Stop hook で自然 capture され、`doctor --codex` の latest DB session が `codex:019dfd4f-93ff-7522-8f89-bd1e1996c8d7` に進むことを確認した。さらに絶対パス型へ更新後、child thread `019dfd5e-1248-7c11-8ddc-97e1b0701e10` でも latest DB session が `codex:019dfd5e-1248-7c11-8ddc-97e1b0701e10` に進むことを確認した。hook shape 変更後に新規開始した VSCode-origin thread `019dfd62-9a9d-7211-bf91-89d8e3fc908e` でも `doctor --codex` の current thread と latest DB session が一致し、自然 Stop hook capture を確認済み。hook shape 変更前から開いていた VSCode-origin parent thread は、変更後の自然 Stop smoke としては扱わない。Caveat 側にも `async: false` Stop hook が動く実測があるため、Codex 側は Caveat と同じ同期 hook 方針に寄せる。`codex-capture` / `codex-summarize` / `codex-resume --memo-stdin` は診断・明示操作 surface として維持し、model-visible smoke は明示 opt-in。2026-05-08 以降、Stop hook auto-refresh は verified usage 75% 以上で guarded rollback / inject を試行し、estimate usage では mutation しない。2026-05-09 以降は Codex native auto-compact より先に Throughline refresh を走らせつつ、70% warning よりは mutation を遅らせる |
135
- | **npm 公開 (v0.3.25): Codex-first roadmap** | [THROUGHLINE_CODEX_FIRST_ROADMAP.md](THROUGHLINE_CODEX_FIRST_ROADMAP.md) を追加。次フェーズは Codex primary 実用化、Codex Rewind 互換、Claude 側 finalization の順で進める。Codex primary の L2→L1 backend は Codex CLI を本線とし、`codex-sidecar` は Claude primary からの review / risk-check / second opinion / 互換 L2→L1 経路として整理する |
135
+ | **npm 公開 (v0.3.25): Codex-first roadmap** | [05_codex_first_roadmap.md](05_codex_first_roadmap.md) を追加。次フェーズは Codex primary 実用化、Codex Rewind 互換、Claude 側 finalization の順で進める。Codex primary の L2→L1 backend は Codex CLI を本線とし、`codex-sidecar` は Claude primary からの review / risk-check / second opinion / 互換 L2→L1 経路として整理する |
136
136
  | **npm 公開 (v0.3.25): npm docs packaging** | README から参照する `docs/` と `CHANGELOG.md` を npm `files` に追加。`docs/throughline-handoff-context.example.json` を含め、README の sidecar dry-run 例が tarball 内でも成立するようにする |
137
- | **npm 公開 (v0.4.0): /clear auto-handoff + memo / save-inflight / /tl-trim retire** | 2026-05-08 Claude Code 2.1.128 で `source='clear'` が reliable になったため、`/clear` で自動引継ぎがデフォルト ON になる auto path を追加。`THROUGHLINE_DISABLE_AUTO_HANDOFF=1` で OFF にできる。`/tl` slash command は明示意思マーカーへ簡素化 (memo 4 項目入力廃止、`save-inflight` CLI 削除、`/tl-trim` slash command 廃止、`updateBatonMemo` 関数削除、`handoff_batons.memo_text` を schema v8 で drop)。注入は L1 + L2 + L3 references のみに簡素化し、memo / 中断直前 thinking セクションを削除。Codex 側 trim path は維持。詳細は [CHANGELOG.md](../CHANGELOG.md) と [THROUGHLINE_CLEAR_AUTO_HANDOFF_PLAN.md](THROUGHLINE_CLEAR_AUTO_HANDOFF_PLAN.md) |
137
+ | **npm 公開 (v0.4.0): /clear auto-handoff + memo / save-inflight / /tl-trim retire** | 2026-05-08 Claude Code 2.1.128 で `source='clear'` が reliable になったため、`/clear` で自動引継ぎがデフォルト ON になる auto path を追加。`THROUGHLINE_DISABLE_AUTO_HANDOFF=1` で OFF にできる。`/tl` slash command は明示意思マーカーへ簡素化 (memo 4 項目入力廃止、`save-inflight` CLI 削除、`/tl-trim` slash command 廃止、`updateBatonMemo` 関数削除、`handoff_batons.memo_text` を schema v8 で drop)。注入は L1 + L2 + L3 references のみに簡素化し、memo / 中断直前 thinking セクションを削除。Codex 側 trim path は維持。詳細は [CHANGELOG.md](../CHANGELOG.md) と [02_clear_auto_handoff_plan.md](02_clear_auto_handoff_plan.md) |
138
138
  | **npm 公開 (v0.4.1): typed `/clear` も baton を書く + 2 経路の優先順位入れ替え** | 2026-05-09 `/clear` を UserPromptSubmit hook で検出した時点で当該セッションの `session_id` を `handoff_batons` に書き込み、次 SessionStart が確定的にそのセッションを引き継ぐ。これで multi-window で「最新更新セッション ≠ /clear したセッション」になるシナリオで `findLatestClaudePredecessor` heuristic が誤った前任を選ぶ問題を解消。2 経路の優先順位を **baton path = primary、auto path = fallback** に変更 (auto path は VSCode 拡張メニュー由来など UserPromptSubmit に届かない経路のフォールバック)。`THROUGHLINE_DISABLE_AUTO_HANDOFF=1` は fallback path のみに作用するようになった (typed `/clear` / `/tl` は env と無関係に発火する)。あわせて `.vscode/tasks.json` を git 追跡から外し (gitignore)、`ensureMonitorTaskFile` が hook 発火ごとに絶対パスを書き換える挙動による別環境での dirty diff を解消。`src/prompt-submit.test.mjs` を新設し、`isClearCommand` / `isBatonCommand` 判定 14 件と subprocess+DB 実体テスト 3 件を追加。詳細は [CHANGELOG.md](../CHANGELOG.md) |
139
139
  | **npm 公開 (v0.4.7): Codex monitor direct discovery + 80% auto-refresh** | 2026-05-09 Codex Stop hook auto-refresh の verified usage threshold を 90% から 80% に変更し、Codex native auto-compact より先に Throughline DB memory refresh を試行する。estimate usage / estimated context window では mutation しない。`throughline monitor` は `~/.throughline/state` に加えて `~/.codex/sessions/**/rollout-*.jsonl` を直接 discovery し、Throughline state が未生成の現在 Codex thread も表示する。既存 state がある場合は state の usage snapshot を保持しつつ discovered rollout path / mtime を合流する。Codex 表示 ID は `codex:01` ではなく raw thread id 先頭 8 桁 (`019e085c`) にした。Codex open turn の transient `output_tokens` は token count に overlay するが、モデル欄の `live+<tokens>` marker は表示しない |
140
140
  | **未リリース: Codex current-session 75% trigger** | Codex 自動発火を token-monitor に依存させず、global install が Codex `UserPromptSubmit` / `PostToolUse` hooks も登録する。hook は当該 Codex session の rollout `token_count` を直接読み、verified 75% 以上なら同じ user turn または tool loop 継続前に `$throughline` workflow 実行指示を `additionalContext` で注入する。Stop hook の guarded auto-refresh は残す。`~/.codex/config.toml` は旧 `codex_hooks = true` に加えて現行 `hooks = true` も有効化する |
@@ -10,14 +10,14 @@
10
10
 
11
11
  | 文書 | 扱い |
12
12
  |---|---|
13
- | [THROUGHLINE_CODEX_TRIM_IMPLEMENTATION_PLAN.md](THROUGHLINE_CODEX_TRIM_IMPLEMENTATION_PLAN.md) | これまでの統合計画と実装履歴。完了済み成果と根拠は維持するが、今後の実装順はこの文書を優先する |
14
- | [THROUGHLINE_CODEX_TRIM_ROLLBACK_FIX_PLAN.md](THROUGHLINE_CODEX_TRIM_ROLLBACK_FIX_PLAN.md) | 2026-05-06 incident 後の修正計画。controlled smoke で rollback marker の model-visible 復活は未再現となり、overbroad blocker は解除済み |
15
- | [THROUGHLINE_CODEX_DUAL_SUPPORT.md](THROUGHLINE_CODEX_DUAL_SUPPORT.md) | Claude / Codex 両対応の architecture brief。adapter 境界の基本方針として維持する |
16
- | [throughline-rollback-context-trim-insight.md](throughline-rollback-context-trim-insight.md) | rollback / rewind を context delete primitive と見る設計メモ |
17
- | [PUBLIC_RELEASE_PLAN.md](PUBLIC_RELEASE_PLAN.md) | 公開配布の状態表。実装済み behavior だけを公開説明に出す |
13
+ | [07_codex_trim_implementation_plan.md](07_codex_trim_implementation_plan.md) | これまでの統合計画と実装履歴。完了済み成果と根拠は維持するが、今後の実装順はこの文書を優先する |
14
+ | [06_codex_trim_rollback_fix_plan.md](06_codex_trim_rollback_fix_plan.md) | 2026-05-06 incident 後の修正計画。controlled smoke で rollback marker の model-visible 復活は未再現となり、overbroad blocker は解除済み |
15
+ | [08_codex_dual_support.md](08_codex_dual_support.md) | Claude / Codex 両対応の architecture brief。adapter 境界の基本方針として維持する |
16
+ | [09_rollback_context_trim_insight.md](09_rollback_context_trim_insight.md) | rollback / rewind を context delete primitive と見る設計メモ |
17
+ | [04_public_release_plan.md](04_public_release_plan.md) | 公開配布の状態表。実装済み behavior だけを公開説明に出す |
18
18
  | [../CLAUDE.md](../CLAUDE.md) / [../AGENTS.md](../AGENTS.md) | 作業者向け入口。Claude 正本を守りつつ、この文書を次フェーズ計画として参照する |
19
19
 
20
- この文書は、以後の実装順について [THROUGHLINE_CODEX_TRIM_IMPLEMENTATION_PLAN.md](THROUGHLINE_CODEX_TRIM_IMPLEMENTATION_PLAN.md) を上書きする。
20
+ この文書は、以後の実装順について [07_codex_trim_implementation_plan.md](07_codex_trim_implementation_plan.md) を上書きする。
21
21
  ただし、Claude primary を壊さない、Claude hooks / `/tl` / baton / DB / resume context を Codex 用に置き換えない、という既存の絶対条件は維持する。
22
22
 
23
23
  ## 現状認識
@@ -32,7 +32,7 @@
32
32
 
33
33
  ## 新セッション引き継ぎ
34
34
 
35
- 2026-05-08 時点では、Codex primary の capture / summarize / resume は実装・実測済み。Codex trim execute / auto-refresh は、controlled rollback model-visible smoke の clean result を受けて blocker を解除した。[THROUGHLINE_CODEX_TRIM_ROLLBACK_FIX_PLAN.md](THROUGHLINE_CODEX_TRIM_ROLLBACK_FIX_PLAN.md) の Phase 0-3 は実装済み。Phase 4 では Codex app-server の protocol / local store 調査、read-only app-server process restart smoke、local restore source audit、manual VS Code restart smoke protocol、実 VS Code reload / reconnect 後の hidden developer memory marker proof、rollback 非復活 verifier、controlled rollback model-visible smoke surface まで進んだ。incident-shaped live rollback run では `compacted.replacement_history` retention を診断したが、後続の risky restore inspection では app-server response 上の retained text は `aggregatedOutput` など quoted/tool-output field に限定され、direct user message / `replacement_history` の復活とは分離された。2026-05-10 の live token_count 実験では同一 thread refresh が持続削減にならない可能性が濃くなったため、auto-refresh は disabled、通常 `$throughline` は新スレッド handoff とする。`throughline codex-host-primitive-audit` は diagnostic-only として残す。
35
+ 2026-05-08 時点では、Codex primary の capture / summarize / resume は実装・実測済み。Codex trim execute / auto-refresh は、controlled rollback model-visible smoke の clean result を受けて blocker を解除した。[06_codex_trim_rollback_fix_plan.md](06_codex_trim_rollback_fix_plan.md) の Phase 0-3 は実装済み。Phase 4 では Codex app-server の protocol / local store 調査、read-only app-server process restart smoke、local restore source audit、manual VS Code restart smoke protocol、実 VS Code reload / reconnect 後の hidden developer memory marker proof、rollback 非復活 verifier、controlled rollback model-visible smoke surface まで進んだ。incident-shaped live rollback run では `compacted.replacement_history` retention を診断したが、後続の risky restore inspection では app-server response 上の retained text は `aggregatedOutput` など quoted/tool-output field に限定され、direct user message / `replacement_history` の復活とは分離された。2026-05-10 の live token_count 実験では同一 thread refresh が持続削減にならない可能性が濃くなったため、auto-refresh は disabled、通常 `$throughline` は新スレッド handoff とする。`throughline codex-host-primitive-audit` は diagnostic-only として残す。
36
36
 
37
37
  Codex 側で実装済み / 診断可能なもの:
38
38
 
@@ -71,7 +71,7 @@ Codex 側で再実装しないこと:
71
71
  1. この `新セッション引き継ぎ` を読む。
72
72
  2. Codex 側をやり直さず、Claude `/rewind conversation only` の手動 UX 確認へ進む。
73
73
  3. Claude 側に触る前に [../CLAUDE.md](../CLAUDE.md) を読む。
74
- 4. Codex rollback incident の追加診断が必要な場合だけ、[THROUGHLINE_CODEX_TRIM_ROLLBACK_FIX_PLAN.md](THROUGHLINE_CODEX_TRIM_ROLLBACK_FIX_PLAN.md) の Phase 4 を参照する。
74
+ 4. Codex rollback incident の追加診断が必要な場合だけ、[06_codex_trim_rollback_fix_plan.md](06_codex_trim_rollback_fix_plan.md) の Phase 4 を参照する。
75
75
  5. `.claude/settings.json` はユーザー環境差分を含み得るため、明示依頼なしに整理・置換しない。
76
76
 
77
77
  ## 新しい実装順
@@ -515,7 +515,7 @@ TODO:
515
515
 
516
516
  ## 次の作業
517
517
 
518
- Codex primary の capture / summarize / resume は完了扱い。Codex trim execute は明示診断用 current-thread path として残すが、auto-refresh は 2026-05-10 の live token_count 実験後に無効化済み。[THROUGHLINE_CODEX_TRIM_ROLLBACK_FIX_PLAN.md](THROUGHLINE_CODEX_TRIM_ROLLBACK_FIX_PLAN.md) の Phase 0-4、read-only app-server process restart smoke、local restore source audit、host primitive audit、manual VS Code restore smoke protocol、実 VS Code reload / reconnect marker proof、rollback 非復活 verifier、controlled rollback model-visible smoke surface は実装済み。incident-shaped live rollback run は `restoreSafety.status = risk` で、`compacted.replacement_history` retention と rollback 済み text match を診断上は観測した。後続の app-server response 分類では retained text が `aggregatedOutput` の引用に限定され、direct user message / model-visible reproduction とは分けて扱う。host primitive audit でも current-thread rollback non-resurrection primitive は見つかっていない。通常 `$throughline` は新スレッド handoff prompt とし、current-thread rollback / inject は自動化しない。
518
+ Codex primary の capture / summarize / resume は完了扱い。Codex trim execute は明示診断用 current-thread path として残すが、auto-refresh は 2026-05-10 の live token_count 実験後に無効化済み。[06_codex_trim_rollback_fix_plan.md](06_codex_trim_rollback_fix_plan.md) の Phase 0-4、read-only app-server process restart smoke、local restore source audit、host primitive audit、manual VS Code restore smoke protocol、実 VS Code reload / reconnect marker proof、rollback 非復活 verifier、controlled rollback model-visible smoke surface は実装済み。incident-shaped live rollback run は `restoreSafety.status = risk` で、`compacted.replacement_history` retention と rollback 済み text match を診断上は観測した。後続の app-server response 分類では retained text が `aggregatedOutput` の引用に限定され、direct user message / model-visible reproduction とは分けて扱う。host primitive audit でも current-thread rollback non-resurrection primitive は見つかっていない。通常 `$throughline` は新スレッド handoff prompt とし、current-thread rollback / inject は自動化しない。
519
519
 
520
520
  再開時は次を実施する:
521
521