Add context intelligence: symbol-aware packets, context diff and score#42
Merged
Conversation
Make context an inspectable object, not a hidden prompt (Strategy Gap3 / Phase2). New stdlib-only module continuum/context_intel.py with pure functions and three CLI commands under `continuum context`: - enrich <task_ref>: symbol-aware intel (relevant files, extracted symbols, linked tests, recent commits, prior decisions, blockers). - diff <ref_a> <ref_b>: what context each task received and what differs (files/symbols/tests/decisions only-in-A vs only-in-B, token-size delta) -- answers who got stale context. - score <ref>: estimated_tokens (chars//4), source_count, staleness, deterministic risk_level and a missing_info checklist; non-zero exit only on a real error (unknown task). `context build` gains an optional --intel/--symbols appendix; default packet behavior is unchanged. Symbol extraction is conservative regex across common languages; token estimate reuses core.estimate_tokens. Tests: tests/test_context_intel.py (17 new); full suite 246 green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This was referenced May 31, 2026
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.
Why
Strategy §Gap3 / §Phase2: make the context an agent receives an inspectable
object, not a hidden prompt. This adds three capabilities on top of the
existing
MemoryStoreandcontext buildpacket: smarter (symbol-aware)packets, packet diffing, and packet scoring.
Constraints honored: stdlib + git subprocess only (no tree-sitter, no
ctags, no new deps). Symbol extraction is conservative regex over file text;
token estimate reuses the repo's
chars // 4heuristic (core.estimate_tokens,tied to
CONTEXT_BUDGETS).What
New module
continuum/context_intel.py(pure functions):extract_symbols,relevant_tests,recent_commits,gather_context_intel,diff_intel,score_intelplus renderers. Three CLI commands undercontinuum context:continuum context enrich <task_ref>— relevant files (claimed + changed),extracted symbols, linked tests, recent commits touching those files, prior
decisions (DECISIONS.md + decision events), current blockers. Human +
--json.Accepts
--fileto analyze explicit paths instead of a task's claims.continuum context diff <ref_a> <ref_b>— files/symbols/tests/decisionsonly-in-A vs only-in-B and token-size delta. Answers "who got stale context".
Human +
--json.continuum context score <ref>—estimated_tokens,source_count,staleness(hours/days), deterministicrisk_level(low/med/high fromout-of-scope files, missing tests, stale context, large size) and a
missing_infochecklist. Human +--json. Non-zero exit only on real error(unknown task).
continuum context build --intel/--symbols— appends a compact"Relevant Symbols / Tests / Recent Changes" section. Default packet behavior
is unchanged.
Real smoke output
context enrich T0001(task claimingauth.py):context diff T0001 T0002:context score T0002 --json(task with no linked tests):{ "estimated_tokens": 81, "source_count": 3, "sources": ["files", "symbols", "recent_commits"], "staleness_hours": 0.01, "risk_level": "low", "risk_reasons": ["no linked tests"], "missing_info": ["no tests linked", "no recent decisions"] }Unknown task exits non-zero:
context score T9999->Error: Unknown task: T9999, exit 1.Tests
tests/test_context_intel.pyadds 17 tests (symbol extraction for Python + JSignoring comments/strings; test<->module linking;
recent_commitsin a git repoand
[]in a non-git dir; enrich/diff/score CLI field + JSON shape + exit codes;score flags
missing_infowhen sections are empty). Git-based tests set repoidentity in setUp (CI has no global identity).
CI-mimic
GIT_CONFIG_GLOBAL=/dev/null GIT_CONFIG_SYSTEM=/dev/null python -m unittest discover -s tests: 246 tests pass (229 prior + 17 new).🤖 Generated with Claude Code