Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
212c41a
Canonicalize direct option ordering
daniele21 Sep 28, 2026
279da02
Version canonical direct scorer contract
daniele21 Sep 28, 2026
09afa5f
Avoid redundant prefix snapshots on cache hits
daniele21 Sep 28, 2026
3c69eb2
Test canonical direct-choice ordering
daniele21 Sep 28, 2026
c2f8282
Test cached prefix snapshot reuse
daniele21 Sep 28, 2026
d6b88c0
Version direct-choice benchmark protocol
daniele21 Sep 28, 2026
b9d58ad
Keep benchmark imports ordered
daniele21 Sep 28, 2026
f04dba5
Document canonical direct-choice ordering
daniele21 Sep 28, 2026
b27009c
Label canonical direct scorer in Snake UI
daniele21 Sep 28, 2026
123b3dd
Align product hypothesis with direct-choice evidence
daniele21 Sep 28, 2026
25d7db6
Record local 2B evidence and direct v2 remediation
daniele21 Sep 28, 2026
34d79db
Document direct v2 benchmark identity
daniele21 Sep 28, 2026
da1ca65
Test direct benchmark protocol identity
daniele21 Sep 28, 2026
09b3f08
Document canonical direct choice and snapshot reuse
daniele21 Sep 28, 2026
5e74df5
Describe canonical one-pass direct choice
daniele21 Sep 28, 2026
cb880aa
Record direct v2 correctness and reuse changes
daniele21 Sep 28, 2026
ac2cd47
Record completed local benchmark evidence
daniele21 Sep 28, 2026
3e479a0
Align repository quality with local 2B evidence
daniele21 Sep 28, 2026
59f55ca
Close semantic evidence lane and focus direct rerun
daniele21 Sep 28, 2026
b008f6c
Render direct options in compiler order
daniele21 Sep 28, 2026
4c3351c
Keep product direction concise
daniele21 Sep 28, 2026
d870a5d
Record repeated-state gate v3 result
daniele21 Sep 28, 2026
061f9b0
Record first pinned 2B direct screening
daniele21 Sep 28, 2026
86e9661
Document DecisionSession candidate ordering
daniele21 Sep 28, 2026
5de9d07
Focus roadmap on stateful direct evidence
daniele21 Sep 28, 2026
cc55b80
Update contribution evidence boundaries
daniele21 Sep 28, 2026
0d7ad51
Update evidence status after local 2B runs
daniele21 Sep 28, 2026
063c667
Align E2E residual gaps with local evidence
daniele21 Sep 28, 2026
f4a3350
Test public session order invariance
daniele21 Sep 28, 2026
bf43503
Document DecisionSession canonical ordering
daniele21 Sep 28, 2026
e39dade
Cover direct ordering in both prompt modes
daniele21 Sep 28, 2026
e33f803
Expose prefix snapshot counts
daniele21 Sep 28, 2026
8e2f09d
Assert cached snapshot count
daniele21 Sep 28, 2026
1e6f185
Compact current state around durable evidence
daniele21 Sep 28, 2026
a27607a
Keep architecture contract context bounded
daniele21 Sep 28, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .engineering/e2e.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@
],
"minimum_automated_fidelity": "host_or_fake",
"residual_gaps": [
"repeated-state gate v3 decides only its frozen scoped semantic-v2 workload",
"the pinned 2B gate is intentionally executed locally and performance evidence remains bound to exact model/runtime/host identity"
"repeated-state gate v3 is a recorded semantic-v2 promotion FAIL while its cache/runtime evidence remains valid only for the frozen workload",
"the pinned 2B evidence is local and remains bound to exact model/runtime/host identity"
],
"real_environment_confirmation": "required",
"automation_gap_reason": null
Expand All @@ -166,8 +166,8 @@
],
"minimum_automated_fidelity": "host_or_fake",
"residual_gaps": [
"representative 2B controller screening is not established by the 0.8B smoke rollout",
"controller quality and holdout evidence remain separate from cache-efficiency proof"
"first representative 2B direct-v1 screening is retained but direct-v2 remediation requires a comparable rerun",
"controller quality and later holdout evidence remain separate from cache-efficiency proof"
],
"real_environment_confirmation": "conditional",
"automation_gap_reason": null
Expand Down
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ milestones rather than every experimental commit.
- local GGUF + llama.cpp reference runtime with exact artifact/runtime provenance;
- reusable single-sequence model-state snapshot/restore with a bounded repeated-state cache;
- stateful direct A/B/C action readout with zero generated answer tokens;
- canonical candidate-ID ordering for direct-choice compiler v2, so caller presentation order does not change the prompt/readout mapping;
- repeated-prefix cache hits reuse the existing captured sequence state instead of serializing the same prefix again;
- comparative semantic v2, semantic v1, direct-letter and generated JSON evidence paths;
- frozen short/fresh and repeated-state benchmark contracts with retained machine-readable evidence;
- constraint-first Snake, support-routing and policy-gate examples;
Expand All @@ -36,8 +38,8 @@ milestones rather than every experimental commit.

- the pinned 2B short/fresh semantic-v2 gate remains **FAIL** on its unchanged criteria;
- 0.8B real-model smoke proves fresh/reused correctness and physical-token reduction directionally;
- repeated-state gate v3 on the pinned 2B CPU identity remains the scoped semantic promotion gate;
- representative 2B Snake controller screening and a later holdout remain pending.
- repeated-state gate v3 on the pinned 2B CPU identity is **FAIL** for semantic-v2 promotion while retaining strong cache-reuse evidence;
- first representative 2B direct screening is retained: stateful/fresh semantics matched, but controller quality/order robustness were insufficient; direct v2 requires rerun before holdout.

### Still planned

Expand Down
5 changes: 1 addition & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,7 @@ The pinned reference identity is Qwen3.5-2B Q4_K_M GGUF through
exact host/runtime identity; PR CI is limited to cheaper 0.8B mechanism smoke. Smaller models and
Metal runs are separate evidence identities.

The general short/fresh semantic-v2 gate is a recorded **FAIL** and must not be reinterpreted.
Repeated-state semantic evidence is governed separately by
`benchmarks/repeated-state-gate-v3.md`. Snake controller quality is governed by
`benchmarks/snake-controller-benchmark-v1.md` and is deliberately separate from cache efficiency.
Both semantic-v2 promotion gates are recorded **FAIL** results and must not be reinterpreted; the repeated-state run still retains strong cache-mechanism evidence. Snake controller quality is governed by `benchmarks/snake-controller-benchmark-v1.md` and remains deliberately separate from cache efficiency. Direct-v1 screening evidence is append-only; direct-v2 reruns use a distinct protocol fingerprint.

Do not edit a frozen fixture silently. A fixture change requires a new explicit dataset/protocol
identity or version decision.
Expand Down
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,11 @@ The first matching decision warms reusable model context; later decisions can re
compiler/runtime rules permit. `fresh=True` evaluates the **same prompt** without shared-prefix
execution and is the supported oracle/debug path.

This API deliberately exposes only the direct A/B/C/... readout in v1. It does not select among
experimental scorers, does not turn normalized option scores into calibrated confidence, and does
not replace deterministic application constraints. Remove impossible candidates before calling
`choose`.
This API deliberately exposes only the direct A/B/C/... readout in v1. Candidate IDs are
canonicalized before lettering, so caller presentation order does not change the compiled choice.
The API does not select among experimental scorers, turn normalized option scores into calibrated
confidence, or replace deterministic application constraints. Remove impossible candidates before
calling `choose`.

## Snake: the idea in one loop

Expand Down Expand Up @@ -280,8 +281,8 @@ reuses only exact/prefix-safe context under explicit compiler/runtime rules.

### 4. Read the decision instead of generating an answer

For a small bounded action set, Decisio can render the valid actions as A/B/C/... and read the
corresponding next-token logits from one model evaluation:
For a small bounded action set, Decisio canonicalizes the valid actions by stable candidate ID,
renders them as A/B/C/..., and reads the corresponding next-token logits from one model evaluation:

```text
A. UP
Expand Down Expand Up @@ -405,8 +406,9 @@ typed action
```

A separate comparative semantic-v2 scorer also exists for experiments. It is **not** the general
default: its frozen short/fresh gate failed the precommitted general-purpose criteria. Repeated-state
experiments remain a scoped evidence lane.
default: both its frozen short/fresh gate and its later repeated-state promotion gate failed their
precommitted criteria. The promoted v1 direction is one-pass direct choice with deterministic
candidate ordering and fresh-equivalent model-state reuse.

## How this differs from SemIf

Expand Down Expand Up @@ -463,7 +465,7 @@ Implemented now:
- local GGUF + llama.cpp execution;
- stable-context model-state reuse with fresh-path correctness checks;
- bounded repeated-state context cache and runtime instrumentation;
- direct A/B/C choice logits with zero generated answer tokens;
- canonical direct A/B/C choice logits with zero generated answer tokens and caller-order invariance;
- deterministic constraints-before-score examples;
- exact model/runtime provenance;
- frozen benchmark/evaluation tooling;
Expand Down
11 changes: 9 additions & 2 deletions benchmarks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,22 @@ The runner prints live progress/ETA. The evaluator includes the cold decision in
group and applies the quality, order, cache/token and >=2x p50/p95 latency criteria frozen in the
methodology document.

The pinned 2B local run **FAILED** the frozen gate: cache reuse/order/zero-generation mechanics passed,
but semantic-v2 scored 32/48 versus generated JSON 39/48 and failed the family/4-candidate quality
guardrails; p50 met the 2x target while p95 narrowly missed it. This closes semantic-v2 promotion for
the repeated-state scope without weakening the runtime/cache evidence.

## Snake controller benchmark v1

[Snake controller benchmark v1](snake-controller-benchmark-v1.md) evaluates the Snake application
at two levels: fixed-state decisions against a bounded dynamic-body planner, and deterministic
seeded episodes. It is the controller-quality benchmark; it is separate from scorer promotion gates
and from the smaller input/cache diagnostic.

The initial matrix compares the same stateful direct prompt under shared versus fresh execution,
compact input, semantic v2/v1 and the adjacent-food application policy. Every run appends a
The matrix compares the same stateful direct prompt under shared versus fresh execution, compact
input, semantic v2/v1 and the adjacent-food application policy. Direct v2 canonicalizes candidate IDs
before A/B/C lettering; its compiler version and ordering rule are part of the protocol fingerprint.
Every run appends a
`run_start` manifest plus terminal configuration results to a JSONL ledger. Evidence binds source
commit, fixture/protocol hashes, exact GGUF/runtime identity, prompt/execution mode, controller
parameters, decision-quality metrics, episode outcomes and runtime/token/cache metrics.
Expand Down
14 changes: 13 additions & 1 deletion benchmarks/repeated-state-gate-v3.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Repeated-state gate v3

Status: frozen before representative execution
Status: executed on pinned 2B reference identity — **FAIL**
Scope: many decisions over one unchanged application state
Reference runtime: Qwen3.5-2B Q4_K_M GGUF + llama.cpp CPU

Expand All @@ -13,6 +13,18 @@ This gate does **not** retry the failed general-purpose scorer-gate v2. A PASS c
repeated-state product scope. Scorer-gate v2 remains the authority for short/fresh general-purpose
use and remains FAIL.

## Representative result

The unchanged pinned 2B local run failed the precommitted gate. Runtime/cache mechanics passed:
8 misses, 40 hits, zero fallbacks, zero semantic order changes and 94,244 physical versus 1,058,852
logical input tokens (~8.9%). Semantic-v2 quality did not: 32/48 correct versus generated JSON
39/48, with failures in evidence entailment, rule application and the four-candidate guardrail.
Group p50 met the 2x latency target (93.34 s versus 187.42 s), while p95 narrowly missed it
(226.43 s versus 438.35 s).

The result does not weaken any threshold and does not invalidate the state-reuse mechanism. It closes
semantic-v2 promotion for this repeated-state scope.

## Why this gate exists

Scorer-gate v2 run `35788235063` showed that semantic v2 was not suitable as a general default:
Expand Down
5 changes: 5 additions & 0 deletions benchmarks/run_snake_controller_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
LlamaCppBackend,
LlamaCppBackendConfig,
)
from decisio.compiler import LETTER_STATEFUL_PROMPT_VERSION
from examples.snake.planner import PLANNER_VERSION, SnakePlanner

from .snake_controller_benchmark import (
Expand Down Expand Up @@ -290,6 +291,10 @@ def run(args: argparse.Namespace) -> dict[str, Any]:
"max_steps": args.episode_max_steps,
"stall_steps": args.stall_steps,
},
"direct_choice": {
"prompt_version": LETTER_STATEFUL_PROMPT_VERSION,
"candidate_order": "candidate_id_lexicographic",
},
}
protocol = {**protocol_payload, "sha256": canonical_sha256(protocol_payload)}
requested_model = _requested_model_identity(args)
Expand Down
32 changes: 27 additions & 5 deletions benchmarks/snake-controller-benchmark-v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,15 @@ The initial matrix isolates controller/readout choices before broad model tuning
| `generated-verbose` | generated JSON baseline | verbose | generated JSON v1 | generated | model (optional) |

The stateful-vs-fresh direct comparison is deliberately controlled: both variants compile the exact
same question-first stateful prompt and therefore the same prompt hash. Only execution changes:
`shared` may restore the reusable prefix; `fresh` evaluates the same compiled prompt without
shared-prefix execution. A prompt-order change is a different experiment and must not be attributed
to caching.
same question-first stateful prompt and therefore the same prompt hash. Direct v2 canonicalizes
candidates lexicographically by stable candidate ID before assigning A/B/C/... readout labels, so
caller presentation order cannot change the direct prompt or candidate-to-token mapping. Only
execution changes: `shared` may restore the reusable prefix; `fresh` evaluates the same compiled
prompt without shared-prefix execution.

The benchmark protocol fingerprint records the direct prompt version and candidate-order strategy.
This keeps direct-v1 screening evidence separate from direct-v2 reruns without changing or
overwriting the append-only ledger.

Do not expand into a model/quantization Cartesian product until this first matrix identifies useful
controller families. Different model artifacts are separate evidence identities.
Expand All @@ -102,7 +107,7 @@ Each row records at least:
- planner version and search/survival bounds;
- configuration ID, scorer, input format, prompt mode, execution mode, effective prefix reuse and controller;
- GGUF filename/SHA/size/quantization, llama.cpp binding/runtime, CPU/context/batch/thread settings;
- selected fixed cases plus episode seeds/board/horizon/stall threshold, hashed as a protocol fingerprint;
- selected fixed cases plus episode seeds/board/horizon/stall threshold and the direct compiler/order contract, hashed as a protocol fingerprint;
- fixed-state metrics, oracle coverage, raw normal/reversed decision readouts and detailed
per-case planner evidence;
- episode metrics and per-seed outcomes;
Expand All @@ -119,6 +124,23 @@ CI uploads the ledger as a retained artifact. Multiple ledger files can be summa
history summarizer groups only comparable
`configuration + model SHA + fixture SHA + protocol SHA` identities.

## First pinned-2B direct screening

Clean `main` commit `263f7ba1274f6f798d7a93a3c0cf4fcfffeae92f` completed the first
representative `direct-stateful-verbose` versus `direct-fresh-verbose` screening on the pinned
Qwen3.5-2B Q4_K_M CPU identity.

Stateful and fresh returned the same choices/scores and identical episode outcomes. Controller
quality was not sufficient for holdout: 5/10 fixed-state optimal-set agreement, 20% catastrophic
misses and 30% order changes. Stateful execution reused 151,808 / 503,070 logical tokens (~30.2%)
with 593 hits, one miss and zero fallbacks. Fixed-state p50 improved from 40.44 s fresh to 5.11 s
stateful, but repeated ~23 MB sequence-state snapshot/restore traffic erased that advantage in long
episodes.

That run remains valid **direct-v1 evidence**. Direct v2 canonicalizes candidate IDs before lettering
and removes redundant snapshots on cache hits, so its rerun receives a different protocol fingerprint
and must not be merged statistically with the v1 screening.

## Run

```bash
Expand Down
23 changes: 11 additions & 12 deletions docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ runtime tolerance. A cache hit is an implementation event, not evidence of corre

## Direct choice readout

For small bounded action sets, Decisio can compile all valid candidates once as A/B/C/... options and
read the corresponding next-token logits from a single model evaluation:
For bounded choices, Decisio sorts stable candidate IDs, assigns A/B/C/... deterministically and
reads those next-token logits from one model evaluation:

```text
state + question + options
Expand All @@ -137,7 +137,8 @@ state + question + options
DecisionResult
```

This is implemented by `LetterTokenScorer` and is the action readout used by the stateful Snake reference. It generates zero answer tokens and avoids one YES/NO evaluation per candidate. Direct logits are an internal primitive, not the product differentiator; option-order sensitivity and uncalibrated probability semantics remain explicit.
`LetterTokenScorer` implements this zero-generation readout. Direct v2's ID sort makes caller order
compile identically; verbalizer sensitivity and uncalibrated score semantics remain explicit.

`LetterTokenScorer(..., reuse_prefix=True)` marks an exact token prefix for model-context reuse.
The generic scorer keeps this explicit; Snake selects it by default and offers `--fresh-prefix` as
Expand Down Expand Up @@ -224,12 +225,10 @@ stable decision context -> reusable model context -> changing state/question ->

Semantic candidate branching remains a second scoped use of the same exact snapshot/restore primitive.

The semantic scorer exposes an optional backend fast path,
`shared_prefix_batch_next_token_logits`. The compiler can also mark a token-safe reusable state
prefix. The llama.cpp backend keeps one canonical sequence, snapshots complete sequence state,
restores candidate branches from that state, and keeps repeated-state checkpoints in an LRU bounded
by both entry count and serialized bytes. Keys are exact token prefixes within one loaded runtime;
unsupported boundaries fall back to ordinary shared-prefix evaluation.
`shared_prefix_batch_next_token_logits` uses compiler-marked safe prefixes on one canonical
sequence. Checkpoints live in an entry/byte-bounded LRU: cold prefixes snapshot once; exact hits
restore the cached snapshot, which also serves as the rollback point for compatible branches.
Unsupported boundaries fall back conservatively.
Candidate branches execute serially on sequence 0, so their count is not limited by
`max_sequences`. Native batch-aligned checkpoint requirements still apply; prompts without
a safe checkpoint fall back to fresh evaluation.
Expand Down Expand Up @@ -348,9 +347,9 @@ These should be answered by evidence rather than preference:

## Current implementation boundary

The canonical path is local GGUF through llama.cpp. The backend snapshots/restores complete
single-sequence model context state and keeps exact compiler-marked checkpoints in a byte-bounded
LRU. This deliberately avoids a KV-only assumption for hybrid/recurrent Qwen3.5 state.
The canonical path is local GGUF through llama.cpp. Cold reusable prefixes snapshot complete
single-sequence state once; exact hits restore the cached checkpoint without re-snapshotting it.
This avoids a KV-only assumption for hybrid/recurrent Qwen3.5 state.

Snake now uses a fixed decision contract as the reusable direct-scoring prefix and sends only current
world state plus deterministic candidate sensors on each model decision. The same prompt can be run
Expand Down
Loading
Loading