Skip to content

chore(core): retire dead context/inject.ts twin (T-605/T-606, ADR-049)#61

Merged
matze4u merged 2 commits into
mainfrom
feat/v1-0-retire-dead-context-inject
Jun 2, 2026
Merged

chore(core): retire dead context/inject.ts twin (T-605/T-606, ADR-049)#61
matze4u merged 2 commits into
mainfrom
feat/v1-0-retire-dead-context-inject

Conversation

@matze4u

@matze4u matze4u commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

What

Retire the dead context-injection twin packages/core/src/context/inject.ts (+ its test), superseded by the live buildContextInjection.

context/inject.ts (buildContextBlock / injectContext, user-message placement) was the recorded implementation of T-605 (context-block injection) + T-606 (cache-friendly placement), but had zero live callers — referenced only by its own inject.test.ts. The live path is chat/context-injection.ts::buildContextInjection (T-MR13, ADR-025), which folds the snippets into a bounded <workspace-context> system-prompt block, used in both chat/handler.ts:356 and agent/turn-handler.ts:312. The system-prompt placement won; the user-message twin is the dead loser.

Same retire shape as PR #51 (dead tracking/audit-log.ts, T-413, ADR-039) and exactly the cleanup ADR-048 named when it flagged context/inject.ts as the one genuinely dead twin.

Why it is safe

  • Grep across packages/core/src + clients/ (excluding its own test and /dist/): zero callers. No barrel/index re-exports.
  • Deleting it does not orphan context/snippet.tsSnippet is still imported by annotations.ts, indexer.ts, chunk-tree.ts, engine.ts.
  • No protocol/codegen change; no runtime behavior change.

Both impls preserve the same cache goal

Keep the cached static prefix byte-identical, let the per-turn context ride where cache misses are expected — inject.ts via the user message, buildContextInjection via the system-prompt suffix after the cache_control'd guidelines/rules prefix. No insight lost; the live placement additionally gives better instruction-following steering.

AI council

codex-cli 0.134.0 + gemini-cli 0.41.2 (2026-06-02) — UNANIMOUS:

  • Q0=A retire the zero-caller competing contract
  • Q1=A dedicated ADR-049 (mirrors the ADR-039 retire precedent)
  • Q2=A T-605/T-606 stay [x], done-comments updated to cite the live impl
  • Q3=A nothing to port (the fixed 8000-char cap supersedes the dynamic 20%-window budget; safer against system-prompt cache-block overflow)
  • Q4 no trap

Changes

  • chore(core): delete context/inject.ts + context/inject.test.ts.
  • docs: ADR-049; index.md row; road-to-v1-0.md T-605/T-606 done-comments updated (stay [x] — the capability is live via the system-prompt placement).

Verification

task ci deterministic phases (lint, build, typecheck, format) green every run. Core test suite 3/4 full runs green (1120 passed / 1 skip; -6 = the removed inject.test.ts).

The 1/4 failure is a pre-existing, intermittent flake unrelated to this diff: chat/handler-list.test.ts (conversationList newest-first order, PR #58 / ADR-046) trips on a same-millisecond timestamp tie under full-suite load — it passes 3/3 in isolation, and sessions/watcher.test.ts (chokidar debounce) rotated into the same slot on one run (passes 2/2 in isolation). This diff touches none of those modules. Remote CI (6-node matrix) is the authoritative gate.

No checkbox flip — T-605/T-606 stay [x].

matze4u added 2 commits June 2, 2026 12:22
context/inject.ts (buildContextBlock/injectContext, user-message context
placement) was the recorded T-605/T-606 implementation but had ZERO live
callers — referenced only by its own test. The live context-injection path
is chat/context-injection.ts::buildContextInjection (T-MR13, ADR-025), a
<workspace-context> system-prompt block used in both chat/handler.ts and
agent/turn-handler.ts. The system-prompt placement won; the user-message
twin is the dead loser. Delete it + its 6-test file. Deleting does not
orphan context/snippet.ts (still imported by annotations/indexer/chunk-tree/
engine). No protocol/codegen change; no behavior change (zero live callers).
- ADR-049: documents the T-605/T-606 (user-message) -> T-MR13 (system-prompt
  buildContextInjection) supersession and the retire, mirroring the ADR-039
  dead-twin retire precedent. AI council (codex-cli 0.134.0 + gemini-cli
  0.41.2) UNANIMOUS Q0-Q4=A.
- docs/adr/index.md: add the ADR-049 row.
- road-to-v1-0.md: T-605/T-606 stay [x]; done-comments updated to cite the
  live buildContextInjection (capability is live via the system-prompt
  placement, only the losing implementation file was removed).
@matze4u matze4u merged commit 5d1ad10 into main Jun 2, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant