# Symgliph Adaptive Context Compilation 0.2

Status: **Experimental profile**  
Short name: **SACP-0.2**  
Specification identifier: `urn:symgliph:spec:adaptive-context:0.2`  
Last updated: 2026-08-03

## 1. Abstract

SACP-0.2 defines a deterministic procedure for expanding a source-verifiable
context packet along an ascending token and semantic-node ladder. Expansion
stops when a declared evidence-sufficiency estimator passes, all candidates are
exhausted, or hard limits are reached.

The estimator is a routing heuristic. Passing it does not establish retrieval
recall, answer correctness, or quality parity with full context. Those claims
require an external evaluation such as ECEB with pinned tasks, repeated model
runs, provenance labels, and a declared quality margin.

## 2. Conformance language

The key words **MUST**, **MUST NOT**, **REQUIRED**, **SHOULD**, **SHOULD NOT**,
and **MAY** are to be interpreted as described by RFC 2119 and RFC 8174.

## 3. Inputs

An adaptive request MUST declare:

- a non-empty query containing at least one searchable term;
- positive minimum and maximum token ceilings;
- a positive token step;
- positive minimum and maximum semantic-node ceilings;
- a positive node step;
- a query-term coverage threshold from 0 through 10,000 basis points;
- a positive minimum evidence count; and
- whether shortened evidence excerpts are permitted at the stopping point.

Minimum ceilings MUST NOT exceed their corresponding maximum ceilings. The
minimum evidence count MUST NOT exceed the maximum node ceiling.

Candidate path seeds MAY be supplied by an upstream lexical, embedding, or
policy-aware retriever. A path seed is a ranking hint only. It MUST NOT bypass
manifest membership, source-range validation, or digest verification.

## 4. Expansion procedure

Let the request define token ladder `T` and node ladder `N`:

```text
T_0 = max(min_tokens, minimum_context_kernel_tokens)
N_0 = min_nodes

T_(i+1) = min(T_i + token_step, max_tokens)
N_(i+1) = min(N_i + node_step, max_nodes)
```

For each round `i`, an implementation MUST:

1. retrieve and graph-expand candidates using the same pinned corpus and
   semantic roots;
2. pack ordinary text using ceilings `T_i` and `N_i`;
3. verify every emitted source range and file digest;
4. calculate the exact prompt token count and context BLAKE3 digest;
5. calculate the declared evidence-sufficiency estimate;
6. append the round to the trace; and
7. either stop under Section 6 or advance both ladders.

If the minimum context kernel exceeds `max_tokens`, compilation MUST fail with
a token-budget error. Raising the effective first rung to the kernel minimum is
recorded in the first round and does not permit the hard maximum to be crossed.

The first round is numbered one. Ceilings MUST be non-decreasing, and at least
one ceiling MUST strictly increase between adjacent rounds.

## 5. Built-in evidence estimator

The v1 estimator derives case-insensitive alphanumeric query terms after
removing the profile's fixed stop-word list. It measures those terms only
against selected evidence blocks, excluding the packet header containing the
query itself.

```text
term_coverage_bps = floor(
  10,000 * matched_unique_query_terms / unique_query_terms
)
```

The estimate passes only when:

```text
term_coverage_bps >= min_query_term_coverage_bps
evidence_count >= min_evidence
require_untruncated_evidence implies truncated_evidence_count == 0
```

The result MUST use the field name `estimated_sufficient`. Implementations MUST
NOT label this value `verified_quality`, `complete`, or an equivalent claim.

## 6. Stop reasons

Exactly one stop reason MUST be recorded:

`estimated_sufficient`
: The estimator passed. The first passing round MUST be selected.

`candidate_exhausted`
: The estimator failed and the ordinary packet reported that no candidates or
  excerpt bytes remained omitted.

`hard_limit_reached`
: The estimator failed, omitted material remained, and both maximum ceilings
  were reached.

The selected packet MUST be the packet from the final recorded round. A failed
estimate still produces a valid source-verifiable packet unless the caller
chooses fail-closed enforcement.

## 7. Result artifact

The registered schema is
[`symgliph.adaptive-context/v1`](schema/adaptive-context-v1.schema.json). A
result records:

- the exact request and estimator thresholds;
- the stop reason and selected round;
- every attempted token/node ceiling;
- prompt tokens, evidence counts, newly discovered evidence, and deduplicated
  evidence paths per round;
- every exact-context BLAKE3 digest;
- matched and missing query terms and failed estimator conditions; and
- the final SCGP context packet.

The final packet remains governed by the SCGP Context capability. Adaptive
compilation does not weaken its source-verification or hard-budget invariants.

## 8. Model and agent integration

The reference JSON-RPC method is `context.adaptive`. Models receive only the
final packet's ordinary `prompt` text. The expansion trace is control-plane
evidence for the caller, evaluator, or audit log; it need not be inserted into
model context.

A caller that treats a failed estimate as an error SHOULD enable fail-closed
behavior. The reference CLI provides `adaptive-pack --require-sufficient`,
which exits with status 2 when the estimator does not pass.

## 9. Evaluation profile

An empirical claim that adaptive compilation preserves quality SHOULD compare,
on the same pinned tasks and model settings:

- full permitted context;
- a strong lexical baseline;
- fixed-budget compiled context; and
- adaptive compiled context.

At minimum, the report SHOULD retain task success, evidence and fix-path recall,
prompt and output tokens, total provider cost, latency, stop-reason frequency,
selected-round distribution, and repeated-run variance. The quality threshold
and permitted regression from full context MUST be declared before evaluation.

## 10. Security and claim boundary

All SCGP prompt-injection, stale-source, path portability, and provenance
requirements continue to apply. An estimator can be satisfied by irrelevant or
adversarial text containing the query vocabulary. Therefore:

- estimator success MUST NOT authorize data access;
- estimator success MUST NOT override policy classification;
- estimator success MUST NOT be reported as answer correctness; and
- external quality evaluation MUST remain independent of the stopping rule.
