Skip to content

feat(L10): rung-3b runtime — per-variable delta residue replay#55

Merged
hyperpolymath merged 1 commit into
mainfrom
claude/l10-residue-delta
Jun 20, 2026
Merged

feat(L10): rung-3b runtime — per-variable delta residue replay#55
hyperpolymath merged 1 commit into
mainfrom
claude/l10-residue-delta

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

What

Refines the L10 rung-3b runtime residue (landed in #54) from a whole-state checkpoint to a per-variable delta. reverse <name> now restores only the state fields its matching reversible as <name> body actually mutated, leaving everything else intact.

Why

The #54 checkpoint cut snapshotted/restored the entire AgentInstance.state map. That has a real clobber bug: if a handler firing between the reversible as and the reverse changed some unrelated field, reverse would silently revert it too. Per-variable delta is the correct "undo just this block's effect" semantics.

How

  • collect_set_fields (eval.rs): a static scan of the reversible body for set <field> targets, descending through every nested control construct (mirrors the type checker's collect_reversible_as_bindings recursion shape).
  • ReversibleAs captures a before-image delta — the prior values of exactly those fields — as Holding(delta) before running the body.
  • ReverseNamed writes those captured fields back (for (k,v) in delta { state.insert(k,v) }), rather than replacing the whole map; then marks the cell Spent.
  • Over-approximation is harmless: a field set only on an untaken branch is captured at its current value, so writing it back is a no-op.

Test

New residue_reverse_is_per_field_delta_not_whole_checkpoint: debit arms undo touching only balance; a separate annotate handler changes the unrelated field note; reverse undo restores balance to its pre-debit value but preserves note — which a whole-checkpoint restore would have clobbered.

Verification

  • 914 oo7-core lib tests pass (was 913 + this one)
  • cargo fmt --check clean, clippy -D warnings exit 0
  • examples/transactional_rollback.007 parse + check + run green
  • just run-examples exit 0; error-line count identical to origin/main (98 — all in unrelated pre-existing examples, no regression)

Docs

Spec §11b.8, the example header, and docs/echo-residue-integration.adoc all updated from "checkpoint / whole state map" to "per-variable delta" wording. New CHANGELOG entry (the #54 historical entry is left intact).

Note: CI on this repo currently fails every job in ~2-3s with no logs — an org-level billing/runner-rejection block unrelated to the diff. Verification above is local.

🤖 Generated with Claude Code

https://claude.ai/code/session_018CaSgNjNURC7ocsyjYh9We


Generated by Claude Code

Refine `reverse <name>` to restore only the state fields its
`reversible as <name>` body mutated (a before-image delta), not the
whole agent state map. Fixes a real clobber: under the whole-checkpoint
cut a reverse would silently revert an unrelated field that an
intervening handler had changed.

- eval: `collect_set_fields` statically scans the body (descending
  nested control) for `set` targets; `ReversibleAs` captures the
  before-image of just those fields as `Holding(delta)`; `ReverseNamed`
  writes them back rather than replacing the whole `AgentInstance.state`.
  Over-approximation is harmless (a field set only on an untaken branch
  is captured at its current value, so write-back is a no-op).
- test: residue_reverse_is_per_field_delta_not_whole_checkpoint — a
  reverse restores `balance` but preserves a `note` an intervening
  handler changed.
- spec §11b.8 / example / design-note: "checkpoint" -> "per-variable
  delta" in lockstep.

914 oo7-core lib tests pass; fmt + clippy clean; example + e2e green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018CaSgNjNURC7ocsyjYh9We
@hyperpolymath
hyperpolymath marked this pull request as ready for review June 20, 2026 19:21
@hyperpolymath
hyperpolymath merged commit c3cd2b3 into main Jun 20, 2026
1 of 24 checks passed
@hyperpolymath
hyperpolymath deleted the claude/l10-residue-delta branch June 20, 2026 19:21
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.

2 participants