Skip to content

Slice 023: Context compaction + session lineage - #32

Merged
HackTuah merged 6 commits into
mainfrom
slice/023-context-compaction
Sep 20, 2026
Merged

HackTuah merged 6 commits into
mainfrom
slice/023-context-compaction

Conversation

@HackTuah

Copy link
Copy Markdown
Member

Slice 023 per slices/023-context-compaction/SLICE.md. Evidence in its PROOF.md; the measured facts, findings and follow-ups in its NOTES.md.

  • Trinity.Memory (Tokens, Compactor): an estimate before every model call, compaction into a row that points at what it summarised (nothing edited or deleted), the newest compaction folded into the system prompt, the fork past the hard threshold into a child with parent_id.
  • Two new event shapes (compaction, forked); the provider treats a missing object as transient; the compactor falls back to plain text.
  • The eval harness (mix test --only eval): 17 of 18 facts survived on nvidia:nemotron (0.944).
  • Gate exit 0, 264 tests, coverage 75.39%. Manual queue: AC4 (the owner's own eval run), AC5 (screenshots already in proof/).

… slice opens

ROADMAP row 023 to in_progress. NOTES.md records that req_llm exposes no
tokenizer and no context window for the owner's models (an estimate and
a configured window with a documented floor), that the fake's object
generation answers "fake", then the eight-line build plan, the two-item
manual queue, and three deviations stated before any code. plan_check:
PASS.

Signed-off-by: Ayla Croft <aylacroft@proton.me>
… state and the fork, the UI and the eval harness

Lines 1 to 7 of the G1 plan. Trinity.Memory (the context's boundary:
Trinity and LLM, never Sessions) with Tokens (bytes over three plus four
per message, calibrated high against the provider's own count; the
window from the registry entry's context_tokens, 32,768 when absent;
soft 70 % and hard 90 %) and Compactor (plan/2 pure over the history,
compact/3 through generate_object with a plain-text fallback when the
provider answers no object or an empty one, the row's attributes
returned for the Session to write: range, digests, the four fields, the
maximum taint of the inputs). The Session estimates the request before
every model call: over soft it enters compacting (012's empty state),
writes the row and broadcasts {:compaction, row}; over hard afterwards
it forks: a child session with parent_id, the compaction first, the
user's message second, the child's turn started, the parent closed with
a row naming the child and {:forked, id} broadcast (the eighth and ninth
event shapes). Prompt folds the newest compaction into the system prompt
(inside <untrusted> when tainted) and drops the rows it covers. The
provider turns a response with no object into a transient error the
retry covers. The chat: the context indicator, the compaction card with
a link to the first covered row, the redirect on a fork. The eval
harness under test/evals (tag :eval, excluded by default): three
scripted conversations, fact survival, a table written to proof/,
TRINITY_EVAL_MODEL to pick the model. The fake's object/1 and
object_delay/1. DataCase takes an ownership_timeout tag.

Tests: Tokens, plan/2, the prompt's folding, AC1 (200 turns: naive 9,283
tokens, 2,101 after compaction, soft 4,200, three compactions), AC2 (the
rows remain, seqs gapless, the range on the row), AC3 (killed in
compacting: nothing written, the retry compacts once, no shared range),
AC6 (the fork: parent_id, the compaction first, the message second, the
child answers), the indicator, the card, the redirect. The live eval on
nvidia:nemotron: 17 of 18 facts, 0.944 (proof/eval-2026-09-20.md);
openrouter:ling's free tier ran out of daily requests mid-measurement.
Gate exit 0, 264 tests; credo --strict --all clean.

Signed-off-by: Ayla Croft <aylacroft@proton.me>
PROOF.md with every criterion's evidence: AC1 with its numbers (9,283
naive, 2,101 after compaction, soft 4,200), AC2, AC3 and AC6 from the
tests, AC4 from the live eval on nvidia:nemotron (17 of 18, 0.944, the
table in proof/), AC5 from the tests and two screenshots. NOTES.md
carries the nine findings and the follow-ups. coverage.tsv: 023 at
75.39% from 74.85%. ROADMAP row 023 to done. Gate exit 0, 264 tests.

Signed-off-by: Ayla Croft <aylacroft@proton.me>
Signed-off-by: Ayla Croft <aylacroft@proton.me>
…nit's idle

The postgres job (run 35534378835) read the init's idle and rendered
before the turn ("both sides are exactly equal"); the same race as
NOTES finding 9, on a slower pool. NOTES finding 10.

Signed-off-by: Ayla Croft <aylacroft@proton.me>
…he previous commit described)

Signed-off-by: Ayla Croft <aylacroft@proton.me>
@HackTuah
HackTuah merged commit a54fe4d into main Sep 20, 2026
4 checks passed
@HackTuah
HackTuah deleted the slice/023-context-compaction branch September 20, 2026 20:20
@HackTuah HackTuah mentioned this pull request Sep 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant