Skip to main content

Module context_graft

Module context_graft 

Source
Expand description

Session-scoped context graft layer (ADR-058 Phase 3).

The agent loop never gets a parallel store; it gets a query/graft layer over ExoChain’s ECC indexes, scoped to one conversation. This module is the kernel side of that layer:

  • 3.1 SessionView — a session-scoped, ephemeral semantic index (a per-session HNSW). Because the index holds only this conversation’s chunks, scoping is structural: a query can only return this session’s chunks. The view is disposable and rebuildable from the chain (re-embed this session’s events), so killing/rebuilding a loop costs only time — ExoChain remains the source of truth.
  • 3.2 graft API — query → candidate branches → COW-reference graft, keyed by chain sequence, large payloads as content-addressed blobs.
  • 3.3 index population — embed agent.chat.turn / tool-output events with the ADR-059 embedder, store f32 vectors keyed by chain sequence.

§This IS the ECC causal model

Graft / prune / promote map onto the node lifecycle (NodeState): Speculative → Frontier → Committed (collapse to trunk) or → Stale → Pruned (evicted off main_line). v1 is single semantic index per conversation (ADR-058 phasing); fusion (causal + temporal + BVH) is v2 and additive — every chunk is already keyed by chain sequence.

The session view is deliberately separate from the durable global CausalGraph: it is the L2 “warm, this-run” tier. L2→L3 promotion onto the durable trunk is Phase 4.

Structs§

ChunkMeta
Metadata for one chunk indexed in a SessionView.
GraftedItem
One item grafted into the working set (ADR-058 Phase 3.2).
ScopedHit
A hit from a scoped query: the matched chunk plus its similarity score.
SessionView
A session-scoped, ephemeral semantic view over this conversation’s chain chunks (ADR-058 Phase 3.1).

Enums§

GraftContent
How a grafted item’s content is carried into the working set.
NodeState
Node lifecycle state on the causal model (ADR-058 / ADR-056).

Functions§

content_hash
Compute the content-addressed identity of a chunk’s text.
mirror_state
Mirror a per-turn node-state transition across both substrates (ADR-062 P0.2): the authoritative L2 SessionView chunk and the durable CausalNode metadata.state.