# Phase 165.4-03 Summary

Status: implemented in working tree

## Goal

Open `165.4 / 999.74` by adding deterministic theory-context injection for
theorem-facing work.

The runtime should materialize path-scoped context fragments for theory
artifacts, and session-start should inject them once per session window instead
of repeating the same notation/prerequisite/reusable-route context every turn.

## What Landed

- new theory-context module:
  - `knowledge_hub/theory_context_injection.py`
- runtime bundle generation now materializes a top-level
  `theory_context_injection` surface with:
  - path-scoped target paths for theorem-facing artifacts
  - compact fragment notes/json for:
    - `notation_bindings`
    - `prerequisite_closure`
    - `relevant_l2_units`
  - session TTL metadata (`3600` seconds)
- fragment truth sources stay mechanical and reuse existing artifacts instead of
  re-inferring context:
  - `notation_table.json`
  - `prerequisite_closure_review.json`
  - `formal_theory_review.json`
  - `topic_skill_projection.active.json|md`
- `runtime_protocol.generated.md` now renders a dedicated
  `Theory context injection` section
- `session_start.contract.json|md` now applies file-based session dedup:
  - first delivery in the TTL window: fragment note paths are injected into the
    startup read list
  - repeated delivery inside the TTL window: suppressed mechanically
  - once TTL expires: injection becomes eligible again
- `aitp_codex.build_codex_prompt()` now includes freshly injected theory-context
  fragment paths and summaries in the startup prompt so Codex actually receives
  the bounded theorem-facing context
- runtime bundle schema now explicitly requires `theory_context_injection`

## Verification

- `python -m pytest research/knowledge-hub/tests/test_runtime_profiles_and_projections.py -q`
- `python -m pytest research/knowledge-hub/tests/test_aitp_service.py -q`
- `python -m pytest research/knowledge-hub/tests/test_aitp_codex.py -q`
- `python -m pytest research/knowledge-hub/tests -q`

## Outcome

`165.4` now has a real context-injection slice:

- theorem-facing agent sessions receive concise notation / prerequisite /
  reusable-route context through deterministic fragment files
- repeated session-starts in the same TTL window do not keep re-injecting the
  same context
- the injection boundary is durable, path-scoped, schema-backed, and tested

## Remaining Open Work Inside 165.4

- `999.76` JSONL metrics for self-evolution
- `999.77` derivation loop detection
- `999.78` manifest-as-truth-source
