feat(context): CLM-1 LiveContext core — editable session log, total parse, safety reconcile, journal (ADR 125) #555

Open
toasterson wants to merge 9 commits from clm/1-live-context into docs/context-language-model
Owner

Slice CLM-1 of the Context Language Model plan (ADR 125; stacked on #547, base docs/context-language-model).

A pure module, src/agent/context/live/: the editable session log the model will rewrite.

  • Render the editable turns to a mirror with structural headers [[CTX_TURN n role=… id=t<id> [pin]]].
  • Parse any edited text back, totally (never fails), with typed ParseDiagnostics.
  • Reconcile into a new log plus an EditScript and a journal record, enforcing ADR 125 D4:
    • edited or new text is always a model Note, never operator/tool/system content;
    • the protected prefix is re-pinned verbatim;
    • PinnedSafety turns are restored in place if deleted or changed;
    • every removed or rewritten turn is a DroppedSpan with its anchor (DropReason::SelfEdit);
    • EditGate::{Fit,Shrink}; shrinking edits always apply (still_over_budget reported).
  • Backend pairing normalization in to_messages(): orphaned tool results become host-marked assistant blocks, unanswered calls are stripped, notes never split a call group.
  • Reversible marker escaping: header-like lines inside bodies cannot forge headers (injection path closed).
  • Journal trait + in-memory impl with full evicted bodies and blake3 before/after hashes.

Implemented by GPT-6.1 Sol from docs/ai/phases/clm/CLM-1-brief.md; review round 1 (R1–R3) in CLM-1-review.md, all fixed. No loop changes, no I/O, no tools (CLM-2/CLM-3).

Tests: 33 in context::live (seeded property loops), 100 in context:: all passing locally.

Slice **CLM-1** of the Context Language Model plan (ADR 125; stacked on #547, base `docs/context-language-model`). A pure module, `src/agent/context/live/`: the editable session log the model will rewrite. - **Render** the editable turns to a mirror with structural headers `[[CTX_TURN n role=… id=t<id> [pin]]]`. - **Parse** any edited text back, totally (never fails), with typed `ParseDiagnostics`. - **Reconcile** into a new log plus an `EditScript` and a journal record, enforcing ADR 125 D4: - edited or new text is always a model `Note`, never operator/tool/system content; - the protected prefix is re-pinned verbatim; - `PinnedSafety` turns are restored in place if deleted or changed; - every removed or rewritten turn is a `DroppedSpan` with its anchor (`DropReason::SelfEdit`); - `EditGate::{Fit,Shrink}`; shrinking edits always apply (`still_over_budget` reported). - **Backend pairing normalization** in `to_messages()`: orphaned tool results become host-marked assistant blocks, unanswered calls are stripped, notes never split a call group. - **Reversible marker escaping**: header-like lines inside bodies cannot forge headers (injection path closed). - **Journal** trait + in-memory impl with full evicted bodies and blake3 before/after hashes. Implemented by GPT-6.1 Sol from `docs/ai/phases/clm/CLM-1-brief.md`; review round 1 (R1–R3) in `CLM-1-review.md`, all fixed. No loop changes, no I/O, no tools (CLM-2/CLM-3). Tests: 33 in `context::live` (seeded property loops), 100 in `context::` all passing locally.
fix(context): escape structural markers inside mirror bodies (R3)
Some checks failed
CI / check-seshat (pull_request) Successful in 4m50s
CI / check-akh-medu (pull_request) Successful in 8m3s
CI / test-akh-medu (pull_request) Successful in 19m12s
CI / docker-akh-transcripts (pull_request) Successful in 23m18s
CI / publish-chart (pull_request) Successful in 21m53s
CI / test-session-platform (pull_request) Failing after 44m20s
CI / docker-seshd (pull_request) Successful in 42m11s
CI / test-sokar (pull_request) Successful in 59m5s
CI / platform-images-home (pull_request) Has been skipped
CI / platform-images-core (pull_request) Has been skipped
CI / platform-images-daemons (pull_request) Has been skipped
CI / docker-sokard (pull_request) Successful in 1h10m53s
CI / platform-images-fleet (pull_request) Has been skipped
CI / platform-images-collect (pull_request) Has been skipped
3de9046f64
Some checks failed
CI / check-seshat (pull_request) Successful in 4m50s
CI / check-akh-medu (pull_request) Successful in 8m3s
CI / test-akh-medu (pull_request) Successful in 19m12s
CI / docker-akh-transcripts (pull_request) Successful in 23m18s
CI / publish-chart (pull_request) Successful in 21m53s
CI / test-session-platform (pull_request) Failing after 44m20s
CI / docker-seshd (pull_request) Successful in 42m11s
CI / test-sokar (pull_request) Successful in 59m5s
CI / platform-images-home (pull_request) Has been skipped
CI / platform-images-core (pull_request) Has been skipped
CI / platform-images-daemons (pull_request) Has been skipped
CI / docker-sokard (pull_request) Successful in 1h10m53s
CI / platform-images-fleet (pull_request) Has been skipped
CI / platform-images-collect (pull_request) Has been skipped
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin clm/1-live-context:clm/1-live-context
git switch clm/1-live-context

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch docs/context-language-model
git merge --no-ff clm/1-live-context
git switch clm/1-live-context
git rebase docs/context-language-model
git switch docs/context-language-model
git merge --ff-only clm/1-live-context
git switch clm/1-live-context
git rebase docs/context-language-model
git switch docs/context-language-model
git merge --no-ff clm/1-live-context
git switch docs/context-language-model
git merge --squash clm/1-live-context
git switch docs/context-language-model
git merge --ff-only clm/1-live-context
git switch docs/context-language-model
git merge clm/1-live-context
git push origin docs/context-language-model
Sign in to join this conversation.
No reviewers
No labels
follow-up
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
toasterson/akh-medu!555
No description provided.