Orchestrata Ultimate › Plans › context-injection-tracked-plan

Context-Injection Tracked Plan

Source: plans/context-injection-tracked-plan.md at 8a2cb42ad · last changed 2026-07-27 · first committed 2026-07-13 · 75 lines.

Prose pending.

Plan text

Context-Injection Tracked Plan

Continuation of plans/context-injection-evolution-plan.md and docs/context-injection.md.

Status key: [ ] pending [~] in progress [x] done

Phase 0 — Foundations

# Task Status Commit Notes
0.1 ContextBudget dataclass [x] pre-T1 context/budget.py
0.2 UnifiedContextAssembler skeleton [x] pre-T1 context/assembler.py
0.3 Store-agnostic artifact digest provider [x] pre-T1 context/providers/artifact_digest.py
0.4 Mission context provider [x] pre-T1 context/providers/mission_context.py
0.5 Wire assembler into both runners [x] pre-T1 kernel/pipeline_kg.py, orchestrator/pipeline_runner.py
0.6 Feed session/goal ContextData into assembler [x] current kernel/pipeline_kg.py now reads from _session_ctrl or session
0.7 Populate plan-window layer [x] current context/providers/plan_context.py renders current/recent/upcoming goal tasks
0.8 Context-usage telemetry [x] 200a80b0 Per-layer token spend logged in context/assembler.py; 50% budget alerts added
0.9 Mandatory citations + validator enforcement [x] current persona preamble mandates Entities used; GraphContextValidator now extracts/enforces REQ and DEC ids

Phase 1 — AST-driven context

# Task Status Commit Notes
1.1 AST API client [x] current context_providers/ast_context.py wraps scripts/serialize_codebase_ast.py
1.2 Branch context provider [x] current rendered in ast_context "## Branch points"
1.3 Complexity hotspot provider [x] current rendered in ast_context "## Complexity hotspots"
1.4 Call-graph neighborhood provider [x] current rendered in ast_context "## Call-graph neighborhood"
1.5 Trace-lint preflight provider [x] current rendered in ast_context "## Missing @traces"
1.6 Prolog relevance refinement by default [x] current PipelineKGMixin._init_context_injector wires KgRelevanceRetriever when Prolog + Neo4j are healthy
1.7 AST-to-KG bridge [x] current serialize_codebase_ast.py ast-to-kg writes complexity/branch_count/CALLS edges; KGCodeContext exposes get_complexity_hotspots and get_call_graph_neighborhood

Phase 2 — KG enhancements

# Task Status Commit Notes
2.1 Canonical File.id lookups in ContextInjector [x] current _query_exact_files resolves by {project_id}:{path} id, exact path fallback kept, basename heuristic removed
2.2 Recent-changes section [x] current GraphContext.recent_changes populated from Change nodes / NEXT_VERSION / file timestamps; project-scoped; tests in tests/knowledge_graph/test_context_injector_coverage.py
2.3 Similar-patterns section [x] current GraphContext.similar_patterns populated from base_classes and INHERITS/IMPLEMENTS edges; project-scoped; tests in tests/knowledge_graph/test_context_injector_coverage.py
2.4 Requirement closure [x] current closure_requirement_chain walks HAS_ITEM parents and REQUIRES dependencies up to depth 2; ContextInjector renders distances and caps at 20; tests added to tests/knowledge_graph/test_requirement_resolution.py
2.5 Semantic-search bridge [x] current New knowledge_graph/semantic_bridge.py with search_semantic_roots; semantic_context.py refactored to use it; ContextInjector optionally injects ## Semantically related files via semantic_config; tests in tests/knowledge_graph/test_semantic_bridge.py
2.6 Validator feedback loop [x] current ValidatorLoop re-injects expanded context on missing citations; ContextExpansion added to ContextInjector.inject; BaseAgent activates loop when payload kwarg + injector are wired; tests in tests/knowledge_graph/test_context_validator_loop.py
2.7 Runtime Tier-H ingestion [x] current PipelineKGMixin emits runtime Decision signals; orchestrator + kernel dispatch write :Message nodes; BaseAgent writes :ToolCall nodes; tests in tests/knowledge_graph/test_runtime_signals.py
2.8 Unify Requirement/RequirementItem [x] current New knowledge_graph/requirement_resolution.py with RequirementChain + resolve_requirement_chain; adopted by ContextInjector and tools/context_tools.py; tests in tests/knowledge_graph/test_requirement_resolution.py
2.9 Project-scoped context [x] current project_resolver.resolve_project_id centralizes KG-first project lookup; ContextInjector semantic layer filters by project_id; assembler threads project_id into AST context

Phase 3 — Session, memory, plan window

# Task Status Commit Notes
3.1 Memory summarization [x] pre-T1 memory/memory_context.py
3.2 Universal memory binding [x] pre-T1 both runners register per thread
3.3 Plan parser [x] eab26699 parse plans/execution-plan.md into PlanStep tuples; tests in tests/planning/test_plan_parser.py
3.4 Plan-window provider [x] current renders from Goal.tasks instead of parsing execution-plan.md
3.5 Current-step tracking [x] 49c0d45c Goal.current_step, advance_goal_step(), set_goal_step(), CLI goal advance/goal step, plan_context honors current step
3.6 End-to-end long-session test [x] 6ed32828 20-turn budget test in tests/session/test_context_window.py

Phase 4 — Optimization / tools

# Task Status Commit Notes
4.1 Context pack caching [x] f1f620f7 per-instance cache keyed by snapshot/volk/subject/task/payload-fingerprint; exposes pack_cache_hits/misses
4.6 Adaptive layer trimming [x] current trim_to_budget trims at paragraph/sentence/word/byte boundaries; assembler applies it to all non-protected layers
4.2 Incremental KG sync [x] current FileSynchronizer persists _file_hashes to .orchestrata/kg_sync_state.json; ensure_fresh/sync_project load/save state
4.3 Query cache invalidation [x] current key includes synced_at
4.4 On-demand context tools [x] current get_code, get_tests, get_requirements, search_code registered as native tools
4.5 Context dashboard / report script [x] 27fdf822 context_usage_log.py JSONL sink + scripts/context_usage_report.py table/json aggregation

Phase 5 — Cleanup

# Task Status Commit Notes
5.1 Canonicalize ArtifactStore implementations [x] current Single canonical implementation in core.artifact_store; kernel/orchestrator modules re-export. Both stage/type and stage_alias/artifact_type APIs preserved; JSONL writes both key sets for cross-store replay.
5.2 Remove basename heuristic [x] current removed from _query_context; tests updated to use exact paths
5.3 Consolidate context provider package [x] current Moved context_budget.py, context_assembler.py, context_usage_log.py, and context_providers/ from knowledge_graph/ to top-level context/; updated all imports, tests, docs, and architecture_checker.py layer map