Repository navigation
feat(context-engine): D3 P0-B — self-describing citation instruction in the injected cold block - #46
Merged
Conversation
…in the injected cold block The D3 attribution design (scheme A, explicit citation) needs the ACTING agent to know the protocol: when it acts on an injected cold item, cite it via a `Context-Used: <slug>` git trailer on that commit. Rather than changing every consumer's prompt, the protocol travels with the data — the injected cold block itself now closes with one instruction line. - route.py `build_context`: append `COLD_CITATION_NOTE` as the last line of the cold section, ONLY when at least one real slug-bearing cold line is surfaced (gated on `cold_slugs` — never on warm-only injections, never on an empty block). - Rendered-only: the line is appended to the block string after telemetry assembly, so `cold_surfaced` and `cold_slugs` are unchanged; it does not start with `[`, so `_cold_slug_from_line` returns None for it. - cold.py `surface_cold` stays pure (no change). - Tests: instruction present as the last line iff a real cold item surfaced, absent on warm-only injection, not parseable as a slug line, telemetry count/slugs unaffected. Full suite 434 pass; ruff clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The injected cold block is now SELF-DESCRIBING: when at least one real cold item line is surfaced,
build_contextcloses the cold section with one instruction line teaching the reading agent the D3 citation protocol:Why
D3 attribution scheme A (explicit citation) needs the ACTING agent to know the protocol. Rather than changing every consumer's prompt, the protocol travels with the data — any consumer that receives the injected block automatically receives the instruction. Builds directly on #44 (slug tokens +
cold_slugstelemetry).Design constraints honoured
cold_slugs(at least one real slug-bearing line — never on warm-only injections, never appended to a note-only block, never when the block is empty).cold_surfacedandcold_slugsare byte-identical to before.[, so_cold_slug_from_linereturnsNonefor it.cold.pysurface_coldstays pure — the change lives where the block is assembled (route.py).Tests
test_cold_block_is_self_describing: instruction present exactly once, names theContext-Used:trailer key, is the LAST line of the block;_cold_slug_from_line(COLD_CITATION_NOTE) is None;cold_surfaced/cold_slugstelemetry unchanged.test_no_citation_instruction_without_cold_items: warm-only injection carries no instruction.Full suite: 434 passed (was 432).
ruff check .clean.🤖 Generated with Claude Code