throughline 0.4.9 → 0.4.11

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.
@@ -26,13 +26,13 @@
26
26
  - 現行 Claude path は、Claude hooks、slash command、handoff baton、DB、resume context、L1 / L2 / L3 persistence で成立している。
27
27
  - 外部モデル的に呼ぶ主要箇所は L2 -> L1 要約。
28
28
  - Claude-primary の現行 L2 -> L1 要約は `codex-sidecar` が configured の場合に sidecar を優先し、使えない場合は Claude Haiku 経路に戻る。Codex-primary は Codex CLI backend 失敗を明示 error にし、Claude Haiku / raw L2 へ fallback しない。
29
- - Codex guarded trim は、Codex app-server の `thread/read` / `thread/resume` / `thread/rollback` / `thread/inject_items` を使う。明示 thread identityrollout/app-server turn count guard、injectable memory がない場合は mutation 前に拒否する。
29
+ - Codex guarded trim は、Codex app-server の `thread/read` / `thread/resume` / `thread/rollback` / `thread/inject_items` を使う。明示 thread identity と injectable memory がない場合は mutation 前に拒否する。rollout/app-server turn count mismatch は診断に残し、`thread/read` / `thread/resume` が同じ count を返す場合は app-server 側の差分で rollback `numTurns` を補正する。
30
30
  - Claude `/rewind` 自動化はまだ有効化しない。
31
- - Codex automatic refresh mutation は再有効化済み。`75%` verified usage threshold rollback / Throughline DB memory inject を試行し、estimate usage では実行しない。Codex native auto-compact より先に Throughline refresh を走らせつつ、70% warning よりは mutation を遅らせる。
31
+ - 2026-05-10 update: Codex automatic current-thread refresh mutation は無効化する。live rollback / injecttoken_count が一時的に落ちても同一 thread で戻る実測があるため、`UserPromptSubmit` / `PostToolUse` / `Stop` hooks capture / monitor state write のみ行い、`codex_auto_refresh_disabled` で quiet にする。bare `$throughline` は `codex-handoff-start --execute` による app-server 新スレッド handoff とし、明示 `trim --execute --host codex` だけを診断用 current-thread rollback / inject path として残す。
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` の復活とは分離された。`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 を解除した。[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 として残す。
36
36
 
37
37
  Codex 側で実装済み / 診断可能なもの:
38
38
 
@@ -40,8 +40,8 @@ Codex 側で実装済み / 診断可能なもの:
40
40
  - `codex-summarize`: Codex CLI backend で L2 -> L1 を書ける。Claude Haiku / raw L2 へ fallback しない。
41
41
  - `codex-resume`: L1 summary と active L2 context を Codex active-work context / fresh-thread handoff / developer message item として描画できる。
42
42
  - `trim --dry-run --host codex` / `doctor --trim --host codex`: rollback / inject plan、memory contract、context reduction estimate、diagnostics を表示する。fresh-thread handoff は代替継続 surface として残すが、current thread trim の代替ではない。
43
- - `trim --preflight --host codex`: rollout / app-server turn count guard を確認する。restore-safety diagnostics と planned rollback risk は報告するが、拒否条件ではない。
44
- - `trim --execute --host codex`: live app-server へ guarded rollback + Throughline DB memory inject を送る。env gate や host primitive audit gate は不要。DB memory が無い場合、または rollout/app-server turn count がずれる場合は mutation 前に拒否する。
43
+ - `trim --preflight --host codex`: rollout / app-server turn count を診断し、必要なら app-server count 由来の rollback 数補正 preview を表示する。restore-safety diagnostics と planned rollback risk は報告するが、拒否条件ではない。
44
+ - `trim --execute --host codex`: explicit diagnostic current-thread path として、live app-server へ guarded rollback + Throughline DB memory inject を送る。env gate や host primitive audit gate は不要。DB memory が無い場合は mutation 前に拒否する。rollout/app-server turn count がずれる場合は、`thread/read` / `thread/resume` が一致していれば app-server count を正として rollback `numTurns` を補正する。bare `$throughline` と hooks からは呼ばない。
45
45
  - `codex-visibility-smoke`: injected active-work memory が次 model turn で model-visible になることを確認済み。
46
46
  - `codex-rollback-model-visible-smoke`: controlled two-phase smoke。`--prepare` は unique marker を含む user turn を開始して 1 turn rollback し、`--verify` は full marker を含まない prefix-only prompt で rollback 済み marker が model-visible かを測る。これは実 current thread を mutate するため明示 env 必須。live run では `--marker-file` を使い、full marker を同一 thread の chat/tool output に出さない。
47
47
  - `codex-restore-smoke`: fresh app-server process を複数回起動し、`thread/read` / `thread/resume` / paginated `thread/turns/list` turn count が rollout active turn count と一致し続けるかを read-only で確認できる。ただし proof scope は `app_server_process_restart_only` で、VS Code restart-safe 証明ではない。
@@ -271,7 +271,7 @@ Phase 3 implementation result (2026-05-06):
271
271
  - [x] `throughline codex-resume --format handoff` は current thread を mutate せず、新規 Codex thread に貼る短い handoff prompt を返す。handoff view は L2 件数 / 本文長 / detail refs を cap し、full active-work context は通常 text renderer に残す。
272
272
  - [x] `throughline codex-handoff-smoke --session codex:<thread_id>` は新規 thread handoff prompt を read-only に検査し、prompt size / required sections / mutation boundary / detail command dedupe を固定する。
273
273
  - [x] `throughline codex-handoff-model-smoke --session codex:<thread_id>` は明示 opt-in 時だけ `codex exec --ephemeral --ignore-user-config --ignore-rules --sandbox read-only` で handoff prompt の marker model smoke を行う。`--dry-run` は env なしで readiness / command boundary を監査し、`--print-prompt` で結合 prompt を出せる。`--memo-stdin` で Codex-primary current-work memo も同じ prompt に含める。structural handoff smoke が ready でなければ拒否し、current thread は mutate しない。
274
- - [x] `throughline codex-handoff-start --session codex:<thread_id>` は safe continuation の guided entrypoint として、structural smoke / model smoke dry-run / handoff render / optional live smoke / `--print-prompt` read-only にまとめて表示する。`--memo-stdin` 時は replay 用コマンドにも `--memo-stdin` を伝播し、same memo を pipe する注意を出す。
274
+ - [x] `throughline codex-handoff-start --session codex:<thread_id>` は safe continuation の guided entrypoint として、structural smoke / model smoke dry-run / handoff render / optional live smoke / `--print-prompt` をまとめて表示する。`--execute` では app-server `thread/start` + `thread/inject_items` で新 thread に developer memory を注入し、`--open-host auto|vscode|cli|none` で表示を開く。`--memo-stdin` 時は replay 用コマンドにも `--memo-stdin` を伝播し、same memo を pipe する注意を出す。
275
275
  - [x] `throughline codex-resume --format item-json` は Codex developer message item JSON を返す。
276
276
  - [x] `codex-resume` は explicit session を受け取れる。省略時は cwd の最新 `codex:%` session だけを対象にし、Claude session を混ぜない。
277
277
  - [x] `src/codex-handoff.test.mjs` / `src/codex-resume.test.mjs` で renderer と CLI shape を固定した。
@@ -318,7 +318,7 @@ TODO:
318
318
  - post-inject visibility check
319
319
  - [x] execute env gate を外せる条件を再検討した。
320
320
  - 2026-05-07 correction: live app-server smoke / post-inject visibility / worktree 非破壊性だけでは不十分だったため、一時的に `THROUGHLINE_EXPERIMENTAL_CODEX_TRIM_EXECUTE=1` gate を戻した。
321
- - 2026-05-08 unblock: controlled rollback model-visible smoke が app-server restart 境界と VS Code reload/reconnect 境界の両方で `not-reproduced` だったため、env gate / host primitive audit gate / restore-safety-only blocker を解除した。現行 blocker は thread identity、Throughline DB injectable memory、rollout/app-server turn-count mismatch
321
+ - 2026-05-08 unblock: controlled rollback model-visible smoke が app-server restart 境界と VS Code reload/reconnect 境界の両方で `not-reproduced` だったため、env gate / host primitive audit gate / restore-safety-only blocker を解除した。2026-05-09 update: rollout/app-server turn-count mismatch も blocker から外し、app-server `thread/read` / `thread/resume` が一致する場合は差分補正で rollback `numTurns` を決める。
322
322
  - [x] partial rollback の multi-turn harness を作る。
323
323
  - [x] rollback marker / injected memory が live `thread/resume` 後も効くか確認する。
324
324
  - [x] ローカルファイル変更が戻らないことを、実ファイル付き smoke で確認する。
@@ -328,7 +328,7 @@ TODO:
328
328
  - `throughline codex-restore-smoke --codex-thread-id <id>` は fresh app-server process を複数回起動し、rollout active turn count と `thread/read` / `thread/resume` / paginated `thread/turns/list` の一致を確認する。
329
329
  - proof scope は `app_server_process_restart_only`。VS Code restart / reconnect 越しの rollback / inject durability はまだ証明しない。
330
330
  - [x] failure mode を固定する。
331
- - turn count mismatch
331
+ - turn count mismatch diagnostic / app-server-count rollback adjustment
332
332
  - inject visibility timeout
333
333
  - app-server unavailable
334
334
  - thread not found
@@ -344,10 +344,10 @@ TODO:
344
344
  Phase 4 implementation status (2026-05-07):
345
345
 
346
346
  - [x] `throughline trim --preflight --host codex --codex-thread-id <id>` は `thread/read` / `thread/resume` まで実行し、rollback / inject は送らない。
347
- - [x] historical: `throughline trim --execute --host codex --codex-thread-id <id>` は guarded execute を行う実装だった。2026-05-07 correction では env gate と host primitive audit gate を戻して一時 blocked にした。2026-05-08 unblock では controlled rollback model-visible smoke が再現しなかったため、env gate / host primitive audit gate / restore-safety-only blocker を外し、DB memory と rollout/app-server turn-count guard を残した。
348
- - [x] rollout source を使う場合、rollback 前に rollout active turn count と app-server `thread/read` / `thread/resume` turn count を照合する。不一致なら rollback / inject を送らず refuse する。
347
+ - [x] historical: `throughline trim --execute --host codex --codex-thread-id <id>` は guarded execute を行う実装だった。2026-05-07 correction では env gate と host primitive audit gate を戻して一時 blocked にした。2026-05-08 unblock では controlled rollback model-visible smoke が再現しなかったため、env gate / host primitive audit gate / restore-safety-only blocker を外し、DB memory と rollout/app-server turn-count diagnostics を残した。
348
+ - [x] rollout source を使う場合、rollback 前に rollout active turn count と app-server `thread/read` / `thread/resume` turn count を照合する。不一致でも refuse せず診断に残す。`readTurns === resumedTurns` なら planned rollback turns `readTurns - expectedTurns` を足して `thread/rollback.numTurns` を送る。
349
349
  - [x] guarded execute は `thread/rollback` -> `thread/inject_items` -> post-inject `thread/read` polling の順に進む。`turn/start` は呼ばない。
350
- - [x] fake app-server harness で partial rollback、delayed inject visibility、mismatch refusal、mutation not sent preflight を固定した。
350
+ - [x] fake app-server harness で partial rollback、delayed inject visibility、mismatch adjustment、mutation not sent preflight を固定した。
351
351
  - [x] `thread/resume` 後に injected memory が維持されることを、実 Codex host smoke として確認済み。
352
352
  - [x] 実 Codex host での next model turn visibility smoke は Phase 3 の `codex-visibility-smoke` で確認済み。active-work developer message が次の model turn の agent delta に反映された。
353
353
  - [x] 実 Codex host で `trim --preflight --host codex --codex-thread-id 019dfa40-1cc8-7d13-a110-16b09364fa6a --json` を実行し、guard が mutation 前に read / resume count を照合することを確認した。
@@ -419,7 +419,7 @@ TODO:
419
419
  - [x] Codex trim / setup まで含む command surface を決める。
420
420
  - `throughline trim --host codex`
421
421
  - `throughline trim --preflight --host codex --codex-thread-id <id>`
422
- - `throughline trim --execute --host codex --codex-thread-id <id>` (DB memory rollout/app-server turn-count guard がそろう場合に current-thread rollback / inject を実行)
422
+ - `throughline trim --execute --host codex --codex-thread-id <id>` (DB memory がある場合に current-thread rollback / inject を実行し、rollout/app-server turn-count mismatch は診断と `numTurns` 補正に使う)
423
423
  - `doctor --codex` / `codex-capture` / `codex-summarize` / `codex-resume --memo-stdin` / `codex-visibility-smoke`
424
424
  - [x] Codex primary の doctor を追加または拡張する。
425
425
  - [x] Codex primary の setup / install 手順を追加する。
@@ -440,7 +440,7 @@ Phase 5 implementation status (2026-05-06):
440
440
  - [x] `doctor --codex` は Claude settings を変更しない。Codex primary entrypoint の診断に限定する。
441
441
  - [x] 実セッションで `doctor --codex` -> `codex-capture` -> `codex-resume --format item-json` -> `doctor --codex` の local smoke を実施した。`codex-resume` は developer message item JSON を描画し、再診断で captured DB session が 1 件として表示された。
442
442
  - [x] 実セッションで `codex-visibility-smoke` を実施した。`THROUGHLINE_EXPERIMENTAL_CODEX_MODEL_VISIBLE_SMOKE=1` を必須にし、長い model turn に備えて `--request-timeout-ms 150000` / `--timeout-ms 180000` を使えるようにした。
443
- - [x] Codex primary の setup / install 手順は README に記録した。global install は Codex Stop hook と `$throughline` skill を自動登録する。2026-05-09 以降、bare `$throughline` は AI による診断 flow ではなく `trim --execute --host codex --all --json` を直接走らせる scripted current-thread refresh とする。diagnostics / dry-run / preflight / fresh-thread handoff は明示要求時だけ使う。
443
+ - [x] Codex primary の setup / install 手順は README に記録した。global install は Codex hooks と `$throughline` skill を自動登録する。2026-05-10 以降、bare `$throughline` は `throughline codex-handoff-start --execute` による app-server 新スレッド handoff とする。hooks capture / monitor state write だけを行い、current-thread rollback / inject は明示 `trim --execute --host codex` を要求された時だけ使う。
444
444
  - [x] `codex-summarize` を明示診断・運用 flow に追加した。Codex CLI backend を使い、Claude Haiku へ fallback しない。
445
445
  - [x] Codex primary の summarize / guarded execute まで含む end-to-end smoke を実施した。2026-05-07 correction では guarded execute を live app-server smoke としてのみ扱った。2026-05-08 unblock 後は、controlled rollback model-visible smoke の `not-reproduced` と current-thread live run の `execute-durable-verified` を合わせて、Codex current-thread trim 完了条件に含める。
446
446
  - `codex-capture`: `capturedTurns = 41`, `capturedRows = 75`, `capturedDetails = 2424`
@@ -460,16 +460,16 @@ Phase 5 implementation status (2026-05-06):
460
460
  - 追加確認: current VSCode-origin parent thread `019dfd38-c530-71c3-b7b8-180bdd3054bc` は hook shape 変更前に開始していたため、変更後の自然 Stop smoke としては不適格。assistant final 後に rollout は `task_complete` まで進んだが latest DB session は exec child のままだった。次に VSCode-origin を見る場合は、hook shape 変更後に新しく開始した Codex session で確認する。
461
461
  - 最終確認: hook shape 変更後に新しく開始した VSCode-origin Codex session で 1 turn 完了後、`throughline doctor --codex` を実行した。`current Codex thread` は `019dfd62-9a9d-7211-bf91-89d8e3fc908e`、`latest DB session` は `codex:019dfd62-9a9d-7211-bf91-89d8e3fc908e` で一致し、`Codex hooks feature: enabled`、`Codex Stop hook: registered`、command は `/usr/bin/node /home/kite/projects/Throughline/bin/throughline.mjs codex-hook stop`、`async: false`、`timeoutSec: 300` だった。VSCode-origin の自然 Stop hook による DB capture も解決済みとして扱う。
462
462
  - historical 2026-05-07 correction: 以下の Codex trim smoke は live app-server primitive の履歴として残す。ただし 2026-05-06 incident 後、restart / reconnect 越しの durable context trim 成功とは一時的に扱わず、`$throughline` / Codex Stop hook の automatic mutation を止めていた。
463
- - 2026-05-09 UX 修正: bare `$throughline` は `doctor --codex` / `trim --dry-run --all` / `trim --preflight --all` を AI に順番実行させる説明 surface ではなく、`throughline trim --execute --host codex --all --json` を直接実行する scripted current-thread refresh に戻す。注入 memory L2 最新 20 full bodies + L1 older summaries + L3 references only。diagnostics / dry-run / preflight / fresh-thread handoff は明示要求時だけ使う。
464
- - memory contract 修正: Codex guarded trim でも注入 memory は元の `/tl` 思想を正とする。古い turn は L1 summaries、直近 20 turn は L2 full bodies、L3 は reference only で、L3 bodies / tool payloads は注入しない。rollout source は rollback candidate / app-server turn count guard の根拠であり、Throughline DB memory がある場合に rollout active work preview を注入 memory として使わない。DB memory が無い execute は rollout preview を注入せず、mutation 前に拒否する。
463
+ - 2026-05-10 UX 修正: bare `$throughline` は `doctor --codex` / `trim --dry-run --all` / `trim --preflight --all` を AI に順番実行させる説明 surface でも、`trim --execute --host codex --all` を直接実行する current-thread refresh でもなく、`throughline codex-handoff-start --execute` による app-server 新スレッド handoff とする。current-thread rollback / inject は明示要求時だけ使う。
464
+ - memory contract 修正: Codex guarded trim でも注入 memory は元の `/tl` 思想を正とする。古い turn は L1 summaries、直近 20 turn は L2 full bodies、L3 は reference only で、L3 bodies / tool payloads は注入しない。rollout source は rollback candidate app-server turn-count 補正の根拠であり、Throughline DB memory がある場合に rollout active work preview を注入 memory として使わない。DB memory が無い execute は rollout preview を注入せず、mutation 前に拒否する。
465
465
  - doctor visibility 修正: `doctor --codex` は旧 context refresh readiness として rollback source、inject memory source、memory contract、L1 summaries / recent L2 bodies / L3 references-only count、heuristic reduction estimate を表示していた。実 thread `019dfd62-9a9d-7211-bf91-89d8e3fc908e` では live readiness として `context refresh: ready`、`rollback source: codex-rollout`、`inject memory source: throughline-db`、`memory contract: older L1 + latest 20 L2 full bodies + L3 references only` を確認した。ただし incident 後は restart-safe readiness ではない。
466
466
  - 削減量の記録: `trim --dry-run --host codex` は rollout text がある場合に `contextReductionEstimate` を返す。2026-05-06 の現在 thread `019dfd62-9a9d-7211-bf91-89d8e3fc908e` では通常 keep-recent preview だと `capturedTurns = 14` / `keepRecent = 20` のため `rollbackTurns = 0`、推定削減量も 0 だった。旧 bare `$throughline` context refresh は `--all` を使っていたため、この keep-recent preview の 0 は「Codex で削減できない」という意味ではない。
467
467
  - historical live-only `$throughline` context refresh smoke: 同じ VSCode-origin thread `019dfd62-9a9d-7211-bf91-89d8e3fc908e` で `trim --dry-run --host codex --all --json` -> `trim --preflight --host codex --all --json` -> `trim --execute --host codex --all` を実行した。preflight は rollout/app-server turn count `20 / 20` match、execute は `rollbackSent = true`、`injectSent = true`、`injectedItems = 1`、`rollback candidate turns = 20`。直前見積もりは `rollbackEstimatedTokens = 179780`、`injectedMemoryEstimatedTokens = 2009`、`netEstimatedTokens = 177771`、`reductionPct = 99` (`chars / 4` heuristic)。これは live app-server smoke であり、restart-safe durability の証明ではない。
468
468
  - post-refresh confirmation: execute 後の次 user turn で `doctor --codex` は current thread と latest DB session の一致を維持し、latest DB session は `2026-05-06 22:41:10` へ更新された。`trim --dry-run --host codex --all --json` は `activeTurns = 2`、`rollbackEvents = 1`、`rolledBackTurns = 20` を返し、`codex-resume` は rollback 後の短い active work context を L2 として描画した。
469
469
  - monitor adapter 修正: `throughline monitor` は Claude / Codex host-aware state を読む。Codex Stop hook は `codex:<thread_id>` monitor state を書き、Codex rollout path は Claude transcript 用 `transcriptPath` ではなく `rolloutPath` に保存する。2026-05-09 以降、monitor は `~/.throughline/state` だけでなく `~/.codex/sessions/**/rollout-*.jsonl` も直接 discovery するため、state 未生成の現在 Codex thread も表示できる。既存 state がある場合は usage snapshot を保持しつつ discovered rollout path / mtime を合流する。rollout に `event_msg` / `token_count` がある場合は verified usage として表示し、無い場合だけ `estimated: true` / `source = codex-rollout-chars-div-4` の明示 estimate を使う。state filename は URL encode し、`codex:` session id を Windows でも保存可能にした。表示 ID は `codex:` prefix を外した raw thread id 先頭 8 桁。
470
470
  - monitor doctor 修正: Codex Stop hook stdout は VSCode chat に必ず見えるとは限らないため、`doctor --codex` に `.vscode/tasks.json` の Throughline Monitor task 診断を追加した。登録済み / 未登録 / JSONC / parse error / broken absolute path と `runOn`、および初回作成後は `Developer: Reload Window` が必要という note を read-only で表示する。
471
- - historical automatic refresh 実装: Codex Stop hook は capture / L1 summarize / monitor state 書き込み後、verified usage が verified context window の `90%` 以上なら automatic refresh を試行する経路を持っていた。2026-05-06 incident 後、この経路は blocker として扱い、monitor state / warning / diagnostics は残しても rollback + inject は送らない状態にした。2026-05-08 unblock 後は guarded rollback / inject を再有効化し、2026-05-09 以降は Codex native auto-compact より先に Throughline refresh を走らせるため verified usage `75%` 以上を既定閾値にする。
472
- - current-session trigger 修正: Codex auto-refresh を token-monitor の描画ループに置かず、Codex `UserPromptSubmit` / `PostToolUse` hooks が当該 session の rollout `token_count` を直接読んで verified 75% 以上なら `$throughline` workflow 実行指示を同じ user turn または tool loop 継続前の `additionalContext` として注入する。monitor は表示専用で、自動発火の判定元にしない。
471
+ - historical automatic refresh 実装: Codex Stop hook は capture / L1 summarize / monitor state 書き込み後、verified usage が verified context window の `90%` 以上なら automatic refresh を試行する経路を持っていた。2026-05-06 incident 後、この経路は blocker として扱い、monitor state / warning / diagnostics は残しても rollback + inject は送らない状態にした。2026-05-08 unblock 後は guarded rollback / inject を再有効化し、2026-05-09 以降は verified usage `75%` 以上を既定閾値にした。2026-05-10 live token_count 実験後は、automatic refresh mutation を再び無効化する。
472
+ - current-session trigger 修正: Codex `UserPromptSubmit` / `PostToolUse` hooks は当該 session の rollout capture / monitor state write だけを行う。verified 75% 以上でも `$throughline` workflow 実行指示を `additionalContext` として注入しない。monitor は表示専用で、自動発火の判定元にしない。
473
473
 
474
474
  ## Phase 6: Claude Side Finalization
475
475
 
@@ -515,11 +515,11 @@ TODO:
515
515
 
516
516
  ## 次の作業
517
517
 
518
- Codex primary の capture / summarize / resume は完了扱い。Codex trim execute / auto-refresh 2026-05-08controlled rollback model-visible smoke 後に再有効化済み。[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 は見つかっていないが、これは diagnostic-only で、DB memory rollout/app-server turn-count guard がそろう `trim --execute` を塞がない。
518
+ Codex primary の capture / summarize / resume は完了扱い。Codex trim execute は明示診断用 current-thread path として残すが、auto-refresh 2026-05-10live 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 は自動化しない。
519
519
 
520
520
  再開時は次を実施する:
521
521
 
522
- 1. Codex trim execute / Stop hook auto-refresh の実運用 telemetry を見て、`execute-sent-live-only` / `execute-unverified` / `execute-durable-verified` の分類が期待どおりか確認する。
522
+ 1. Codex 新スレッド handoff UX を通常 `$throughline` surface として磨き、必要な場合だけ明示 `trim --execute --host codex` telemetry を見る。
523
523
  2. VS Code restore path の追加実測を行い、`compacted.replacement_history` が rollback 済み user text の復元元として残る経路をさらに特定する。
524
524
  3. restore-safety / host primitive audit を blocker として再導入する場合は、controlled smoke で再現した具体的 evidence を先に記録する。
525
525
  4. その後に Claude `/rewind conversation only` の手動 UX 確認へ戻る。
@@ -45,7 +45,7 @@ rollback trim は最終的な理想に近いが、host primitive の実測が必
45
45
  - Claude hooks、slash command、transcript parsing、handoff baton、SessionStart resume behavior を Codex 用に置き換えない。
46
46
  - Claude-facing field / command / DB semantics を rename しない。
47
47
  - Codex 対応は adapter / projection として足す。
48
- - `thread/rollback` / `thread/inject_items` は live host primitive として実測済み。2026-05-06 incident 後に Codex guarded execute / auto-refresh は一時停止したが、2026-05-08 の controlled rollback model-visible smoke が再現しなかったため、過剰 blocker は解除済み。現在は [THROUGHLINE_CODEX_TRIM_ROLLBACK_FIX_PLAN.md](THROUGHLINE_CODEX_TRIM_ROLLBACK_FIX_PLAN.md) を優先し、DB memory rollout/app-server turn-count guard を必須にする。Claude `/rewind` 自動化はまだ有効化しない。
48
+ - `thread/rollback` / `thread/inject_items` は live host primitive として実測済み。2026-05-06 incident 後に Codex guarded execute / auto-refresh は一時停止したが、2026-05-08 の controlled rollback model-visible smoke が再現しなかったため、過剰 blocker は解除済み。現在は [THROUGHLINE_CODEX_TRIM_ROLLBACK_FIX_PLAN.md](THROUGHLINE_CODEX_TRIM_ROLLBACK_FIX_PLAN.md) を優先し、DB memory を必須にする。rollout/app-server turn-count mismatch は診断と app-server count 由来の rollback `numTurns` 補正に使う。Claude `/rewind` 自動化はまだ有効化しない。
49
49
  - fallback や silent recovery で失敗を隠さない。互換モードは条件と理由を明示する。
50
50
 
51
51
  ## 運用ルール
@@ -372,7 +372,7 @@ Phase 6 result (2026-05-06):
372
372
  - `thread/inject_items` に raw Responses API item `{ type: "message", role: "developer", content: [{ type: "input_text", text: "..." }] }` を渡し、次の `turn/start` で injected memory が model-visible になることを確認した。marker `TL_PHASE6_INJECT_OK` を正しく返した。
373
373
  - その後の Codex primary 実装で、`codex-resume` が描画する active-work developer message も実 Codex host で model-visible になることを確認した。marker `TL_CODEX_VISIBLE_REAL_20260506_C` が `item/agentMessage/delta` に出た。詳細な実測値は [THROUGHLINE_CODEX_FIRST_ROADMAP.md](THROUGHLINE_CODEX_FIRST_ROADMAP.md) の Phase 3 result を正とする。
374
374
  - さらに `thread/inject_items` 後にもう一度 `thread/resume` してから `turn/start` を呼ぶ smoke も追加し、実 Codex host で marker `TL_CODEX_RESUME_AFTER_INJECT_REAL_20260506` が `item/agentMessage/delta` に出ることを確認した。
375
- - Codex host primitive は live app-server 上では実測済み。ただし restart-safe durability は未証明。現在は明示 `--codex-thread-id` または env thread identity と rollout/app-server turn count guard live mutation の最低条件であり、durable success は別分類で扱う。2026-05-06 incident 後はいったん Codex Stop hook 後の automatic refresh mutation を blocked としたが、2026-05-08 unblock 後は guarded rollback / inject を試行する。2026-05-09 以降は Codex native auto-compact より先に Throughline refresh を走らせるため、verified usage 75% 以上を既定閾値にする。
375
+ - Codex host primitive は live app-server 上では実測済み。ただし restart-safe durability は未証明。現在は明示 `--codex-thread-id` または env thread identity と Throughline DB memory が live mutation の最低条件であり、rollout/app-server turn-count mismatch は診断と rollback `numTurns` 補正に使う。durable success は別分類で扱う。2026-05-06 incident 後はいったん Codex Stop hook 後の automatic refresh mutation を blocked としたが、2026-05-08 unblock 後は guarded rollback / inject を試行する。2026-05-09 以降は Codex native auto-compact より先に Throughline refresh を走らせるため、verified usage 75% 以上を既定閾値にする。
376
376
  - Claude `/rewind conversation only` は手動 UX として扱う。外部ツールからの自動化 surface は未確認。Claude host の automatic rollback / inject は `manual-only`。
377
377
  - Phase 8 では dry-run / preflight を本線にしつつ、Codex だけ guarded execute を追加した。Claude は manual-only のまま扱う。
378
378
 
@@ -386,7 +386,7 @@ Phase 6 result (2026-05-06):
386
386
 
387
387
  TODO:
388
388
 
389
- - [x] host identity model を整理する。Claude `session_id`、Codex `thread_id`、`project_path`、origin session / thread references の対応表を作る。Codex は `thread_id` と rollout JSONL を app-server で扱い、明示 identity と turn count guard がある場合だけ guarded execute へ進む。
389
+ - [x] host identity model を整理する。Claude `session_id`、Codex `thread_id`、`project_path`、origin session / thread references の対応表を作る。Codex は `thread_id` と rollout JSONL を app-server で扱い、明示 identity と Throughline DB memory がある場合に guarded execute へ進む。turn count mismatch は診断と app-server count 由来の rollback `numTurns` 補正に使う。
390
390
  - [x] current session / thread の captured turn count を記録または導出する方法を決める。
391
391
  - [x] rollback 可能な最大 turn 数を計算する。
392
392
  - [x] keep-recent の既定値を決める。
@@ -428,7 +428,7 @@ TODO:
428
428
  - [x] 実行前に captured turns / keep turns / injected memory summary を表示する。
429
429
  - [x] Codex dry-run では `--codex-thread-id` を受け取り、Claude / Throughline の `session_id` と Codex `thread_id` を混同しない形で plan に残す。
430
430
  - [x] Codex non-dry-run の最初の統合として `--preflight` を追加する。これは app-server の initialize / read / resume だけを実行し、rollback / inject は送らない。
431
- - [x] Codex の guarded execution として `--execute` を追加する。ただし `--host codex`、明示または env の Codex thread identity、rollout/app-server turn count guard を必須にし、実行後に model turn は開始しない。
431
+ - [x] Codex の guarded execution として `--execute` を追加する。ただし `--host codex`、明示または env の Codex thread identity、Throughline DB memory を必須にし、実行後に model turn は開始しない。rollout/app-server turn-count mismatch は診断と rollback `numTurns` 補正に使う。
432
432
  - [ ] 自動 rollback 対応 host では、実行後に resume / injected memory が restart / reconnect 後も有効か検証する。Codex は Phase 6 spike、2026-05-06 guarded execute smoke、post-inject resume visibility smoke で live app-server 上の rollback/inject と injected memory visibility だけを確認した。2026-05-06 incident 後、これは restart-safe durability の完了条件を満たさない。
433
433
  - [x] `doctor` に trim 関連診断を追加する。
434
434
 
@@ -436,11 +436,11 @@ Phase 8 partial implementation result (2026-05-06):
436
436
 
437
437
  - `throughline trim --dry-run [--host claude|codex|unknown] [--keep-recent N] [--all] [--session <id>] [--codex-thread-id <id>] [--json]` を追加。
438
438
  - `throughline trim --dry-run --memo-stdin` を追加。`/tl` が解決した「L1/L2 はあるが今やっている作業として認識されない」問題を `/tl-trim` でも再発させないため、current-work memo を curated memory preview の先頭に入れる。
439
- - non-dry-run `throughline trim` は Claude / unknown host では automatic rollback / inject 未対応として exit 1 で明示拒否する。Codex host には `--execute` 経路が実装済み。2026-05-06 incident 後はいったん拒否したが、2026-05-08 unblock 後は明示 `--execute`、Codex thread identity、Throughline DB memoryrollout/app-server turn-count guard がそろえば mutation へ進む。
439
+ - non-dry-run `throughline trim` は Claude / unknown host では automatic rollback / inject 未対応として exit 1 で明示拒否する。Codex host には `--execute` 経路が実装済み。2026-05-06 incident 後はいったん拒否したが、2026-05-08 unblock 後は明示 `--execute`、Codex thread identity、Throughline DB memory がそろえば mutation へ進む。2026-05-09 以降は rollout/app-server turn-count mismatch refuse せず、app-server count 由来で rollback `numTurns` を補正する。
440
440
  - `src/codex-app-server.mjs` を追加し、newline JSON framing、initialize / read / resume / rollback / inject / turn-start request builder、server line parser をテストで固定した。Codex guarded execute はこの helper を通り、model turn は開始しない。
441
441
  - `--codex-thread-id` の明示入力を最優先で信頼する。明示入力が無い場合のみ、`THROUGHLINE_CODEX_THREAD_ID` / `CODEX_THREAD_ID` を current-thread identity signal として使う。最新 rollout 推測による automatic trim は行わない。
442
442
  - `throughline trim --preflight --host codex --codex-thread-id <id> [--json]` を追加した。これは `thread/read` と `thread/resume` が対象 thread に届くことを確認し、`rollbackRequestPreview` を返すが、`thread/rollback` / `thread/inject_items` は送らない。
443
- - `codex-rollout` source の場合、preflight は rollout 側 active turn count と app-server `thread/read` / `thread/resume` の turn count を突き合わせる。不一致または app-server count 不明なら `preflight-refused` として止まり、rollback / inject は送らない。
443
+ - `codex-rollout` source の場合、preflight は rollout 側 active turn count と app-server `thread/read` / `thread/resume` の turn count を突き合わせる。不一致でも `preflight-refused` にはせず、`readTurns === resumedTurns` なら app-server count 由来の rollback `numTurns` 補正 preview を返す。preflight なので rollback / inject は送らない。
444
444
  - 同日、検証 thread `019dfaba-f87e-7f41-a144-d5ca7c6dd7f9` に実 app-server preflight を当て、`readTurns: 1` / `resumedTurns: 1` / `rollbackSent: false` / `injectSent: false` を確認した。
445
445
  - `throughline trim --execute --host codex --codex-thread-id <id> [--json]` を追加した。2026-05-06 incident 後は既定で拒否し、2026-05-07 追加修正では host primitive audit gate も置いた。2026-05-08 unblock 後はこの env gate / host primitive audit gate を外し、app-server の `thread/read`、`thread/resume`、`thread/rollback`、`thread/inject_items`、確認用 `thread/read` へ進む。host primitive audit と restore-safety は diagnostic-only。
446
446
  - 実 app-server smoke では `thread/inject_items` の直後に返る turn 配列が、注入 item の可視化より早い場合があると分かった。その後の current-thread live run で、現行 Codex host の developer memory injection は item-level で、即時 `thread/read` の turn count を増やさない場合があることも確認した。そのため `--execute` は `thread/inject_items` の応答に turn list があればその turn count を期待値とし、応答に turn list がなければ rollback 後 turn count を期待値として post-inject `thread/read` を短く poll する。`postInjectVisibilityCheck` は `match` / `timeout` / `unchecked` を記録する。CLI 外側の status は `executed` ではなく、live mutation だけなら `execute-sent-live-only`、timeout や durable evidence 不足なら `execute-unverified`、rollout に新 rollback marker と active-work memory injection が観測された場合は `execute-durable-verified` とする。restore-safety は durable mutation evidence とは別の diagnostic として表示する。exit 0 は `execute-durable-verified` に限る。
@@ -18,8 +18,15 @@ quoted/tool-output field に残り得ることは確認済みですが、それ
18
18
  model-visible input に入ることは controlled smoke で再現していません。incident-shaped
19
19
  run の retained text は risk evidence として残す一方、単独では mutation 前 blocker にしません。
20
20
  Codex current-thread trim は、明示 `--execute`、Throughline DB injectable memory、
21
- Codex thread identityrollout/app-server turn-count guard を条件に実行します。Codex Stop hook
22
- auto-refresh verified usage 75% 以上で同じ guarded path を試行し、estimate usage では実行しません。
21
+ Codex thread identity を条件にした診断用 path として残します。rollout/app-server
22
+ turn-count mismatch は診断に残し、app-server `thread/read` / `thread/resume` が同じ
23
+ count を返す場合は、その差分で rollback `numTurns` を補正します。
24
+ 2026-05-10 update: live token_count 実験で、rollback / inject 後に token count が
25
+ 一時的に下がっても同一 thread で戻る挙動を確認したため、Codex automatic
26
+ current-thread refresh は無効化します。`UserPromptSubmit` / `PostToolUse` / `Stop`
27
+ hooks は capture / monitor state write のみ行い、`codex_auto_refresh_disabled` で
28
+ quiet にします。bare `$throughline` は `codex-handoff-start --execute` による
29
+ app-server 新スレッド handoff とします。
23
30
 
24
31
  最初のインシデント仮説に対する重要な訂正:
25
32
 
@@ -293,7 +300,8 @@ TODO:
293
300
  repair contract が blocked の場合は拒否していた。
294
301
  - 2026-05-08 unblock: host primitive audit は diagnostic-only に変更した。
295
302
  現行 Codex CLI に same-thread repair primitive が無い事実は表示するが、
296
- DB memory rollout/app-server turn-count guard がそろう execute を塞がない。
303
+ DB memory がある execute を塞がない。rollout/app-server turn-count mismatch
304
+ 診断と app-server count 由来の rollback `numTurns` 補正に使う。
297
305
  - `~/.codex/state_5.sqlite` の `threads` table は rollout path / metadata を持つが、
298
306
  turn bodies は持たない。turn body の主根拠は rollout JSONL 側である可能性が
299
307
  高いが、VS Code extension restore source は別途未確定。
@@ -624,8 +632,9 @@ TODO:
624
632
  mutation 前 blocker にはしない。
625
633
  - [x] 明示 `trim --execute --host codex` の製品判断を固定する。
626
634
  - 判断: 明示 `--execute` で実行する。env opt-in と host primitive audit gate は外す。
627
- DB memory が無い場合、または rollout/app-server turn count guard が合わない場合は
628
- mutation 前に拒否する。実行後は `execute-sent-live-only` /
635
+ DB memory が無い場合は mutation 前に拒否する。rollout/app-server turn count がずれる場合は
636
+ refusal ではなく診断に残し、app-server count を正として rollback `numTurns` を補正する。
637
+ 実行後は `execute-sent-live-only` /
629
638
  `execute-unverified` / `execute-durable-verified` で結果を分ける。
630
639
 
631
640
  受け入れ条件:
@@ -644,13 +653,11 @@ TODO:
644
653
  という記述を訂正する。
645
654
  - [x] hypothesis を compacted replacement-history restore に言及する形へ更新する。
646
655
  - [x] Codex Rewind-equivalent trim が complete だという roadmap claim を格下げする。
647
- - [x] Codex auto-refresh verified usage 75% 以上で guarded rollback / inject を
648
- 実行する。estimate usage では実行しない。
649
- - [x] Codex 75% trigger は token-monitor 依存にしない。Codex `UserPromptSubmit`
650
- / `PostToolUse` hooks が当該 session rollout `token_count` を直接読み、
651
- verified 75% 以上なら current session へ `$throughline` workflow 実行指示を
652
- 注入する。`PostToolUse` により、tool loop 中に閾値を超えた場合も次の継続前に
653
- 同じ判定を走らせる。
656
+ - [x] Codex auto-refresh は無効化する。明示 `trim --execute --host codex`
657
+ diagnostic current-thread rollback / inject として残す。
658
+ - [x] Codex `UserPromptSubmit` / `PostToolUse` hooks は token-monitor 依存にせず
659
+ rollout capture / monitor state write だけを行う。verified 75% 以上でも current
660
+ session へ `$throughline` workflow 実行指示を注入しない。
654
661
  - [x] 新セッションが古い「Codex side complete」claim ではなく、この fix plan から
655
662
  再開できるように `CLAUDE.md` を更新する。
656
663
 
@@ -670,8 +677,12 @@ TODO:
670
677
  5. フェーズ 4: durable host behavior を調査し、製品仕様を決める。
671
678
  6. フェーズ 5: 挙動修正後に広範な docs を更新する。
672
679
 
673
- 作業量や複雑さを理由に目標を下げない。2026-05-08 時点の製品仕様は、
674
- 同一 Codex thread guarded rollback + Throughline DB memory inject を実行し、
675
- rollout 上の新 rollback event injected active-work memory で durable evidence を確認すること。
676
- restore-safety / host primitive audit は diagnostics として残すが、単独では execute / auto-refresh の blocker にしない。
677
- mutation 前 refusal は thread identity、Throughline DB injectable memory、rollout/app-server turn-count mismatch に限定する。
680
+ 作業量や複雑さを理由に目標を下げない。2026-05-10 時点の製品仕様は、
681
+ 通常 `$throughline` を新スレッド handoff prompt とし、Codex hooks automatic
682
+ current-thread mutation を行わないこと。明示 `trim --execute --host codex` は診断用
683
+ current-thread rollback / inject として残す。restore-safety / host primitive audit /
684
+ rollout-app-server turn-count mismatch は diagnostics として残す。
685
+ 2026-05-09 update: rollout/app-server turn-count mismatch は mutation 前 refusal から外した。
686
+ app-server `thread/read` / `thread/resume` が同じ count を返す場合、planned rollback turns に
687
+ `readTurns - expectedTurns` を足して `thread/rollback.numTurns` を送る。例:
688
+ `expectedTurns = 6` / `readTurns = resumedTurns = 7` / `--all` なら `numTurns = 7`。
@@ -9,19 +9,23 @@
9
9
  | 文書 | 役割 |
10
10
  |---|---|
11
11
  | [THROUGHLINE_CODEX_FIRST_ROADMAP.md](THROUGHLINE_CODEX_FIRST_ROADMAP.md) | 2026-05-06 以降の次フェーズ計画。Codex primary と Codex Rewind 互換を先行する |
12
- | [THROUGHLINE_CODEX_TRIM_ROLLBACK_FIX_PLAN.md](THROUGHLINE_CODEX_TRIM_ROLLBACK_FIX_PLAN.md) | 2026-05-06 incident 後の修正計画。2026-05-08controlled smoke 後、automatic mutation は再有効化し、restore-safety / host primitive audit diagnostics として残す |
12
+ | [THROUGHLINE_CODEX_TRIM_ROLLBACK_FIX_PLAN.md](THROUGHLINE_CODEX_TRIM_ROLLBACK_FIX_PLAN.md) | 2026-05-06 incident 後の修正計画。2026-05-10live token_count 実験後、Codex automatic current-thread mutation は無効化し、通常 `$throughline` は新スレッド handoff に戻す |
13
13
  | [THROUGHLINE_CODEX_TRIM_IMPLEMENTATION_PLAN.md](THROUGHLINE_CODEX_TRIM_IMPLEMENTATION_PLAN.md) | この気づきと Claude / Codex 両対応計画を統合した旧計画と実装履歴。完了済み根拠として参照する |
14
14
  | [THROUGHLINE_CODEX_DUAL_SUPPORT.md](THROUGHLINE_CODEX_DUAL_SUPPORT.md) | Throughline を Claude primary のまま Codex adapter / sidecar に対応させる architecture brief |
15
15
 
16
16
  この文書は「rollback は欠けていた delete primitive かもしれない」という洞察を残すもの。実装時は、未検証の host primitive を本線仕様にせず、次フェーズ計画 [THROUGHLINE_CODEX_FIRST_ROADMAP.md](THROUGHLINE_CODEX_FIRST_ROADMAP.md) の Codex Rewind 互換 Phase で実測してから本線 UX に進む。
17
17
 
18
- 2026-05-06 update: Codex app-server の `thread/rollback` / `thread/inject_items` は live host primitive として実測済み。Throughline CLI には明示 `--codex-thread-id` または `THROUGHLINE_CODEX_THREAD_ID` / `CODEX_THREAD_ID` による current-thread identity、rollout/app-server turn count guard、guarded execute が入った。
18
+ 2026-05-06 update: Codex app-server の `thread/rollback` / `thread/inject_items` は live host primitive として実測済み。Throughline CLI には明示 `--codex-thread-id` または `THROUGHLINE_CODEX_THREAD_ID` / `CODEX_THREAD_ID` による current-thread identity、rollout/app-server turn count diagnostics、guarded execute が入った。
19
19
 
20
20
  2026-05-07 correction: VS Code restart / reconnect 後に rollback 済み user prompt が復活したように見える incident が起きたため、Codex rollback / inject は restart-safe な context trim primitive としていったん未証明へ戻した。特に `compacted.replacement_history` など、live app-server read/resume 以外の restore source を検証するまで、`$throughline` と Codex Stop hook auto-refresh は mutation を自動実行しない方針にした。Claude `/rewind` 自動化はまだ有効化しない。
21
21
 
22
- 2026-05-08 unblock: その後の切り分けで、incident thread の retained text は app-server response 上では `aggregatedOutput` など quoted/tool-output field に分類され、controlled rollback model-visible smoke は app-server restart 境界と VS Code reload/reconnect 境界の両方で `not-reproduced` だった。これを受け、Codex `trim --execute --host codex` と Stop hook auto-refresh の過剰 blocker は解除する。`compacted.replacement_history` retention、restore-safety risk、host primitive audit は引き続き diagnostics だが、単独では mutation 前 refusal にしない。DB memory 不在と rollout/app-server turn-count 不一致は引き続き mutation 前 blocker。
22
+ 2026-05-08 unblock: その後の切り分けで、incident thread の retained text は app-server response 上では `aggregatedOutput` など quoted/tool-output field に分類され、controlled rollback model-visible smoke は app-server restart 境界と VS Code reload/reconnect 境界の両方で `not-reproduced` だった。これを受け、Codex `trim --execute --host codex` と Stop hook auto-refresh の過剰 blocker は解除する。`compacted.replacement_history` retention、restore-safety risk、host primitive audit は引き続き diagnostics だが、単独では mutation 前 refusal にしない。DB memory 不在は引き続き mutation 前 blocker。
23
23
 
24
- 2026-05-09 skill UX: bare `$throughline` は diagnostics / dry-run / preflight AI に順番実行させる surface ではなく、`throughline trim --execute --host codex --all --json` を直接走らせる scripted current-thread refresh とする。目的は rollback と、Throughline DB L2 最新 20 full bodies + older L1 summaries + L3 references-only memory injection のみ。doctor / dry-run / preflight / fresh-thread handoff / restore-safety / host primitive audit は明示診断用であり、通常 `$throughline` の前段にはしない。
24
+ 2026-05-09 update: rollout/app-server turn-count 不一致も mutation blocker から外した。app-server `thread/read` / `thread/resume` が同じ count を返す場合、planned rollback turns `readTurns - expectedTurns` を足して `thread/rollback.numTurns` を送る。`expectedTurns = 6` / `readTurns = resumedTurns = 7` / `--all` なら `numTurns = 7`。
25
+
26
+ 2026-05-09 skill UX: bare `$throughline` は diagnostics / dry-run / preflight を AI に順番実行させる surface ではなく、`throughline trim --execute --host codex --all` を直接走らせる scripted current-thread refresh としていた。目的は rollback と、Throughline DB の L2 最新 20 full bodies + older L1 summaries + L3 references-only memory injection のみだった。2026-05-10 以降は `--json` の full plan / memory preview が tool output として context を再膨張させるため、通常 path では付けないようにした。
27
+
28
+ 2026-05-10 rollback UX correction: 追加 live 実験で、current-thread rollback / inject 後に token_count が一時的に下がっても同一 thread で戻る挙動を確認した。これを受け、Codex automatic current-thread refresh は無効化し、`UserPromptSubmit` / `PostToolUse` / `Stop` hooks は capture / monitor state write のみ行う。bare `$throughline` は `throughline codex-handoff-start --execute` による app-server 新スレッド handoff とし、明示 `trim --execute --host codex` は診断用 current-thread path として残す。
25
29
 
26
30
  2026-05-07 host primitive audit: `throughline codex-host-primitive-audit` で installed Codex app-server schema を機械監査した。`thread/rollback` / `thread/inject_items` / `thread/compact/start` / `thread/start` / `thread/fork` / `thread/resume` は存在するが、rollback 済み user text を current-thread の model-visible input へ復活させない deletion / isolation / projection primitive は見つからなかった。`thread/resume(history)` は schema 上 `[UNSTABLE] FOR CODEX CLOUD - DO NOT USE` で、`thread_id` も ignored になるため、Throughline の current-thread repair primitive には採用しない。
27
31
 
@@ -263,11 +267,13 @@ Codex で考えられる流れ:
263
267
  9. ユーザーは同じ Codex thread で続行する。
264
268
  ```
265
269
 
266
- 現行実装では、Codex Stop hook 後の 75% automatic refresh guarded rollback / inject
267
- mutation を試行する。明示 CLI の `throughline trim --execute --host codex --codex-thread-id <id>`
268
- env gate なしで実行する。明示 Codex thread identity、injectable Throughline DB memory、
269
- rollout/app-server turn count guard は live mutation の最低条件であり、durable success は
270
- post-execute rollout evidence `execute-durable-verified` として別判定する。
270
+ 現行実装では、Codex hooks からの 75% automatic refresh は無効化している。明示 CLI
271
+ `throughline trim --execute --host codex --codex-thread-id <id>` は診断用 current-thread
272
+ path として env gate なしで実行できる。明示 Codex thread identity injectable
273
+ Throughline DB memory は live mutation の最低条件であり、rollout/app-server
274
+ turn-count mismatch は診断と app-server count 由来の rollback `numTurns` 補正に使う。
275
+ durable success は post-execute rollout evidence で `execute-durable-verified` として
276
+ 別判定する。
271
277
 
272
278
  重要な考え:
273
279
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "throughline",
3
- "version": "0.4.9",
3
+ "version": "0.4.11",
4
4
  "type": "module",
5
5
  "description": "Claude Code hooks plugin for structured context compression (/clear-safe persistent memory)",
6
6
  "keywords": [
@@ -30,7 +30,7 @@
30
30
  "LICENSE"
31
31
  ],
32
32
  "scripts": {
33
- "test": "node --test src/*.test.mjs src/cli/*.test.mjs"
33
+ "test": "node --import ./src/test-env.mjs --test src/*.test.mjs src/cli/*.test.mjs"
34
34
  },
35
35
  "engines": {
36
36
  "node": ">=22.5"
@@ -10,6 +10,7 @@ import {
10
10
  DEFAULT_CODEX_HANDOFF_MODEL_SMOKE_TIMEOUT_MS,
11
11
  runCodexHandoffModelSmoke,
12
12
  } from '../codex-handoff-model-smoke.mjs';
13
+ import { sameProjectPath } from '../project-path.mjs';
13
14
 
14
15
  async function readStdin() {
15
16
  let raw = '';
@@ -104,16 +105,15 @@ function parseArgs(args) {
104
105
  }
105
106
 
106
107
  function findLatestCodexSessionId(db, projectPath) {
107
- const row = db
108
+ const rows = db
108
109
  .prepare(
109
- `SELECT session_id
110
+ `SELECT session_id, project_path
110
111
  FROM sessions
111
- WHERE lower(project_path) = lower(?)
112
- AND session_id LIKE 'codex:%'
113
- ORDER BY updated_at DESC
114
- LIMIT 1`,
112
+ WHERE session_id LIKE 'codex:%'
113
+ ORDER BY updated_at DESC`,
115
114
  )
116
- .get(projectPath);
115
+ .all();
116
+ const row = rows.find((candidate) => sameProjectPath(candidate.project_path, projectPath));
117
117
  return row?.session_id ?? null;
118
118
  }
119
119
 
@@ -1,6 +1,7 @@
1
1
  import { getDb } from '../db.mjs';
2
2
  import { buildHandoffRecord } from '../handoff-record.mjs';
3
3
  import { buildCodexHandoffSmoke } from '../codex-handoff-smoke.mjs';
4
+ import { sameProjectPath } from '../project-path.mjs';
4
5
 
5
6
  async function readStdin() {
6
7
  let raw = '';
@@ -75,16 +76,15 @@ function parseArgs(args) {
75
76
  }
76
77
 
77
78
  function findLatestCodexSessionId(db, projectPath) {
78
- const row = db
79
+ const rows = db
79
80
  .prepare(
80
- `SELECT session_id
81
+ `SELECT session_id, project_path
81
82
  FROM sessions
82
- WHERE lower(project_path) = lower(?)
83
- AND session_id LIKE 'codex:%'
84
- ORDER BY updated_at DESC
85
- LIMIT 1`,
83
+ WHERE session_id LIKE 'codex:%'
84
+ ORDER BY updated_at DESC`,
86
85
  )
87
- .get(projectPath);
86
+ .all();
87
+ const row = rows.find((candidate) => sameProjectPath(candidate.project_path, projectPath));
88
88
  return row?.session_id ?? null;
89
89
  }
90
90