Home / Projects / Orchestrata Ultimate / Decisions / ADR index / ADR-0086

ADR-0086: Claude sessions get a project-scoped SPEC-106 context pack at SessionStart

field value
Status Proposed
Date 2026-10-11
Register factory (docs/adr, 4-digit ids)
Source docs/adr/0086-session-graph-context-injection.md — recorded on branch feat/session-ctx-inject at 030a4ff64, not yet on master
Wiki register entry ADR-0086 (wiki status: Proposed)

← ADR-0085 · ADR-0087 →

The record

Status: Proposed · Date: 2026-10-11

Context

Claude Code sessions start with flat dumps (session_resume_context.py prints the whole task list — "156 pending work items … and 151 more"). The selective, graph-backed injection the field calls context injection (inject only the slice relevant to the current work) already exists in this repo for volks — knowledge_graph/context_injector.py ContextInjector.inject_for_task over the SPEC-106 pipeline analyze_request → select → pack → render — but nothing feeds it to Claude sessions, and the earlier attempt (claude/hooks/context_graph, Ctx* labels) has no writer, reads a Neo4j that no longer exists, and its only caller (claude/hooks/session_context_hook.py) is registered nowhere live.

The SPEC-106 pipeline is also unusable at repo scale today. Measured 2026-10-11 on the test fleet orchkg (10.53.2.10, 725,636 nodes):

Defect Measurement
D-1 selector.select hop-0 / root match is (n:A OR n:B …) AND (n.id = rid OR n.alias = rid) — no index can serve it ~5.7 s per id; a 3-entity request linked 90 ambiguous ids → ~8.5 min; scripts/context_pack.py did not finish in 120 s on any run. Per-label indexed MATCH (n:L {key: rid}) UNION form: 0.03 s for 5 ids; full 2-hop BUILD expansion 0.078 s
D-2 frame._fetch_candidate_names downloads every linkable name per call 14.6 s unscoped (Function 10.4 s / 160,840 rows); 8.4 s even project-scoped
D-3 the shared orchkg holds one full code copy per worktree, id-prefixed <project>: Class nodes: wt-GD-CONVERSATION 6573, wt-GD-GATEWAY 6573, wt-AST-ROOTS 6568, orchestrata-ultimate 6286, orchestrata-ultimate-architecture 1668 …; n.project_id unpopulated → every name links ambiguously

Design contract: plans/contracts/session-graph-context.{mmd,contract.json} (validate_mermaid: valid classDiagram, 106 lines).

Decision (proposed)

  1. Fix D-1/D-2/D-3 inside SPEC-106 (indexed per-label root lookups; token-driven indexed candidate lookup with _fold re-check; project-scoped linking via an indexed id range >= "<p>:" AND < "<p>;").
  2. Add a SessionStart hook (orchestrata_ultimate.context.session_graph_context, shim .claude/hooks/session-graph-context.sh, registered in .claude/settings.json and mirrored by gen_plugin.py) that builds the request from the session goal + current step, handoff alerts/files, branch, and files changed vs origin/master, and emits a 1500-token pack via hookSpecificOutput.additionalContext under a 5 s wall clock; every failure path prints one line and exits 0.

Four points need Mohamed's ruling:

Forks found while amending the contract for R1/R3 (2026-10-11, contract specGap), open for Mohamed:

Found and designed out (no ruling needed, fixed in the build): D-7 — claude/hooks/ast_sync_hook.py falls back to <repo>/.env for the graph endpoint, which names prod, so an edit in a shell without direnv can sync a worktree into prod orchkg; the launcher resolves the endpoint from the process env, then ~/.config/ast-sync/env, nothing else.

Alternatives rejected

Consequences

Provenance

No other ADR is named in this record.

Rulings cited

Specs cited