|
| 1 | +# Hide Future Provider Text Deltas Implementation Plan |
| 2 | + |
| 3 | +> **For Claude:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task. |
| 4 | +
|
| 5 | +**Goal:** Stop future CodeAlmanac jobs from persisting token-by-token assistant text deltas in run logs. |
| 6 | + |
| 7 | +**Architecture:** Codex and Claude may continue to emit `TEXT_DELTA` harness events because those are real provider stream events. The operation runner decides which harness events become durable product history. `TEXT_DELTA` is live-only stream material, so the operation runner skips it when recording run events. |
| 8 | + |
| 9 | +**Tech Stack:** Python 3.12, Pydantic models, SQLite run event store, pytest, Ruff. |
| 10 | + |
| 11 | +--- |
| 12 | + |
| 13 | +## Product Decision |
| 14 | + |
| 15 | +`TEXT_DELTA` is not durable product history. |
| 16 | + |
| 17 | +Persist: |
| 18 | + |
| 19 | +- `TEXT` |
| 20 | +- `TOOL_USE` |
| 21 | +- `TOOL_RESULT` |
| 22 | +- `TOOL_SUMMARY` |
| 23 | +- `PROVIDER_SESSION` |
| 24 | +- `CONTEXT_USAGE` |
| 25 | +- `WARNING` |
| 26 | +- `ERROR` |
| 27 | +- `DONE` |
| 28 | +- agent trace events |
| 29 | +- run status events |
| 30 | + |
| 31 | +Do not persist: |
| 32 | + |
| 33 | +- `TEXT_DELTA` |
| 34 | + |
| 35 | +This is provider-neutral. It applies to Codex and Claude. |
| 36 | + |
| 37 | +## Scope |
| 38 | + |
| 39 | +This affects future jobs created by: |
| 40 | + |
| 41 | +- `codealmanac init` |
| 42 | +- `codealmanac ingest` |
| 43 | +- `codealmanac garden` |
| 44 | +- ingest jobs created by `codealmanac sync` |
| 45 | +- scheduled sync ingest jobs |
| 46 | +- scheduled garden jobs |
| 47 | + |
| 48 | +This does not affect: |
| 49 | + |
| 50 | +- old jobs already stored in the database |
| 51 | +- provider transcripts |
| 52 | +- Codex/Claude adapters |
| 53 | +- viewer/server read paths |
| 54 | +- read-only commands such as `search`, `show`, `topics`, `health`, `validate`, |
| 55 | + `serve`, `config`, `automation`, `update`, `doctor`, and `list` |
| 56 | + |
| 57 | +## Out Of Scope |
| 58 | + |
| 59 | +- No old-log filtering. |
| 60 | +- No database migration. |
| 61 | +- No live typing renderer. |
| 62 | +- No `--raw` mode. |
| 63 | +- No delta coalescing. |
| 64 | +- No provider adapter changes. |
| 65 | + |
| 66 | +Old jobs that already persisted `TEXT_DELTA` rows can remain noisy because the |
| 67 | +product is not in public use yet. |
| 68 | + |
| 69 | +## Implementation |
| 70 | + |
| 71 | +### Step 1: Add A Predicate |
| 72 | + |
| 73 | +Modify: |
| 74 | + |
| 75 | +```text |
| 76 | +src/codealmanac/workflows/operations/harness.py |
| 77 | +``` |
| 78 | + |
| 79 | +Add: |
| 80 | + |
| 81 | +```python |
| 82 | +def should_record_harness_event(event: HarnessEvent) -> bool: |
| 83 | + return event.kind != HarnessEventKind.TEXT_DELTA |
| 84 | +``` |
| 85 | + |
| 86 | +This function answers: |
| 87 | + |
| 88 | +```text |
| 89 | +Should this provider event become durable job history? |
| 90 | +``` |
| 91 | + |
| 92 | +### Step 2: Use It At The Operation Boundary |
| 93 | + |
| 94 | +Modify: |
| 95 | + |
| 96 | +```text |
| 97 | +src/codealmanac/workflows/operations/service.py |
| 98 | +``` |
| 99 | + |
| 100 | +Change: |
| 101 | + |
| 102 | +```python |
| 103 | +for event in harness_events(harness): |
| 104 | + self.record(...) |
| 105 | +``` |
| 106 | + |
| 107 | +to: |
| 108 | + |
| 109 | +```python |
| 110 | +for event in harness_events(harness): |
| 111 | + if not should_record_harness_event(event): |
| 112 | + continue |
| 113 | + self.record(...) |
| 114 | +``` |
| 115 | + |
| 116 | +### Step 3: Add Regression Coverage |
| 117 | + |
| 118 | +Modify: |
| 119 | + |
| 120 | +```text |
| 121 | +tests/test_ingest_workflow.py |
| 122 | +``` |
| 123 | + |
| 124 | +Add `TEXT_DELTA` events before the existing completed `TEXT` event in |
| 125 | +`EventfulHarnessAdapter`. |
| 126 | + |
| 127 | +Assert the run log still contains the completed assistant message and no |
| 128 | +`TEXT_DELTA` harness events. |
| 129 | + |
| 130 | +## Verification |
| 131 | + |
| 132 | +Targeted: |
| 133 | + |
| 134 | +```bash |
| 135 | +uv run pytest tests/test_ingest_workflow.py::test_ingest_workflow_records_normalized_harness_events -q |
| 136 | +uv run pytest tests/test_ingest_workflow.py tests/test_codex_app_server_adapter.py tests/test_claude_adapter.py -q |
| 137 | +``` |
| 138 | + |
| 139 | +Full: |
| 140 | + |
| 141 | +```bash |
| 142 | +uv run ruff check . |
| 143 | +uv run pytest -q |
| 144 | +uv run codealmanac validate |
| 145 | +``` |
| 146 | + |
| 147 | +Expected: |
| 148 | + |
| 149 | +- Future runs no longer persist `TEXT_DELTA`. |
| 150 | +- Full assistant `TEXT` messages still persist. |
| 151 | +- Tool/status/error/usage events still persist. |
| 152 | +- Existing noisy jobs remain unchanged. |
0 commit comments