You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(L10): phase 2 — echo residue as a linear undo-capability (#41)
## What
Phase 2 of the Layer-10 echo-residue work (phase 1 = #34). Makes the
reversal residue a first-class **linear** value. The checker's residue
stack now carries `Linear<Echo<T>>` (was a bare `Echo<T>`):
`push_echo_residue`
wraps the residue in `Type::Linear`, so the consumed-once discipline is
explicit in the carried type, and the single linear use is discharged by
the matching `take_echo_residue` pop in a later `reverse`.
The only non-comment code change is that one-line wrap; the rest is the
Idris proof, tests, spec, and docs.
## The design decision (worth a look)
A reversal log is an **affine capability consumed linearly**:
- **Linear consumption** — when you *do* reverse, you consume one
specific
residue exactly once (`reverseLinear`'s `(1 e : Echo f y)`). Replaying
the
*same* log twice is rejected: the residue has already been popped, so
the
second `reverse` is `ReverseWithoutResidue`.
- **Affine retention** — a `reversible` block need **not** be paired
with a
`reverse`. An undo capability that is never exercised is dropped at the
body boundary, *not* flagged. Reversibility is a capability, usually
unused.
The opposite — strict "must-reverse" linearity, where an un-reversed
residue
is a `LinearNotConsumed` error — is deliberately **rejected**: it
conflates
*having* an inverse with *applying* it, and is poor agent ergonomics.
Three
new tests lock the affine drop in so a future change cannot silently
tighten
it.
## Formal model
`proofs/idris2/EchoResidueLinear.idr` (`%default total`, zero
`believe_me`,
`idris2 --check` clean):
- `reverseLinear` consumes `(1 e : Echo f y)` — Idris2's quantity `1`
*is*
the "consumed exactly once" proof, mirroring 007's planned
`Linear<Echo<T>>`;
- `reverseLinearCorrect` — recovered input maps back to `y` (intrinsic);
- `ResidueCell` (`Holding`/`Spent`) — the residue carried as **agent
state**
between handler invocations;
- `takeForReverse` — a later handler consumes the cell linearly (`Spent
→
Nothing`);
- `holdingReverses` / `spentDoesNotReverse` — cross-handler reversal
succeeds
iff a residue was retained;
- `cellMode` — bridges a cell back to the phase-1 `Reversibility` mode.
## Verified locally
- `idris2 --check EchoResidueLinear.idr` → exit 0 (and dependency
`EchoResidue.idr`)
- `cargo test -p oo7-core` → **883** lib tests pass (incl. 3 new L10
phase-2 tests), 0 fail
- `cargo fmt -- --check` → 0 diffs
- `cargo clippy -- -D warnings` (CI-equivalent, no `--all-targets`) →
exit 0
- A2ML validator on `.machine_readable/6a2/` → 0 errors
## Still open (its own rung)
Cross-handler **named** residues need residue-binding surface syntax
(`let undo = reversible {…}` … later `reverse undo`). The formal model
(`ResidueCell`) is already in place; only the grammar change is missing,
and
because the grammar is Harvard-guarded that is kept as a separate,
carefully-
scoped rung. Until then cross-handler reversal is conservatively
rejected by
per-body isolation (sound, if incomplete).
## Docs updated in lockstep
`spec/TYPE-SYSTEM-SPEC.adoc` §11b.4, `spec/OPERATIONAL-SEMANTICS.adoc`
§11.4
(planned → landed), `CHANGELOG.md`, `docs/echo-residue-integration.adoc`
(phase-2 section + design-decision subsection + still-open rung), and
6a2
`STATE.a2ml`.
> Note: repo CI may still be gated by the GitHub Actions
billing/spending-limit
> rejection documented in the session log (account-owner action). All
gates
> above were therefore verified locally.
https://claude.ai/code/session_018CaSgNjNURC7ocsyjYh9We
---
_Generated by [Claude
Code](https://claude.ai/code/session_018CaSgNjNURC7ocsyjYh9We)_
Co-authored-by: Claude <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: .machine_readable/6a2/STATE.a2ml
+3-6Lines changed: 3 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -6,9 +6,9 @@
6
6
7
7
@state(version="2.0"):
8
8
phase: "implementation"
9
-
next_action: "Phase-2 echo-residue (Linear<Echo<T>> undo-capability + cross-handler reversal); reconcile estate-standardization-20260607 into main; continue parser gap fill (types, imports, locales, choreographies)"
10
-
last_action: "echo-types integrated as Kategoria Layer 10 reversibility — Echo residue makes reverse/irreversible type-safe (spec §11.3 now ENFORCED), Idris2 EchoResidue.idr proof, agent-facing L10_REVERSE_WITHOUT_RESIDUE (PR #34 merged); test/E2E/clippy/fmt CI gates greened (PR #38 merged); CI reconciled at root: hypatia ssh→https, A2ML 40→0, K9 7→0, grammar-guard, eclexiaiser merge-conflict, stapeln"
11
-
updated: 2026-06-13T07:40:00Z
9
+
next_action: "Layer-10 cross-handler named residues: residue-binding grammar syntax (let undo = reversible {…}; reverse undo) carried through agent state — Harvard-guarded grammar change, own rung; then continue parser gap fill (types, imports, locales, choreographies)"
10
+
last_action: "Phase-2 echo-residue landed: residue is now Linear<Echo<T>> (affine capability, linear consumption — double-reverse rejected, un-reversed residue not an error); Idris2 EchoResidueLinear.idr (reverseLinear (1 e), ResidueCell Holding/Spent, idris2 --check clean, zero believe_me); 3 new typechecker tests (883 oo7-core passing); spec §11b.4/§11.4 + CHANGELOG + integration doc updated in lockstep. estate-standardization-20260607 reconciled into main (PR #40 merged). Prior: Layer 10 phase-1 (PR #34), CI gates greened (PR #38), 6a2/ecosystem refresh (PR #39)"
11
+
updated: 2026-06-14T02:00:00Z
12
12
13
13
@blockers:
14
14
- id: proof-debt
@@ -17,9 +17,6 @@ updated: 2026-06-13T07:40:00Z
17
17
- id: ci-billing
18
18
description: "GitHub Actions billing/spending-limit rejection — every job fails in 2-3s with no logs; blocks CI validation of all pushes (account-owner action: Settings → Billing & plans)"
19
19
since: 2026-06-13
20
-
- id: estate-standardization-unmerged
21
-
description: "estate-standardization-20260607 (estate-standards catch-up: contractiles, bot_directives, svc/k9→self-validating rename, 24 CI workflows) diverged from main AND conflicts with PR #34/#38 (ci.yml + K9 guards renamed from PRE-#38 content, so the K9! magic/pedigree fixes must be re-applied during reconciliation)"
Copy file name to clipboardExpand all lines: .machine_readable/session-log.txt
+2Lines changed: 2 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -27,3 +27,5 @@
27
27
[2026-06-13 12:06:00] UPDATE: PR #38 MERGED to origin/main. BOTH this session's PRs are now in main (#34 echo-types Layer 10 + CI root-fixes; #38 test/E2E gates + session-log checkpoint). main is the single reconciled line. Branch-reconciliation now reduces to: both feature branches (claude/inspiring-meitner-QHuNU, claude/ci-cleanup-fmt-clippy-examples) are MERGED → safe to delete. Remaining next-actions unchanged: (ii) delete the two merged branches + enumerate any OTHER remote branches; (iii) doc-currency sweep (6a2, ANCHOR realignment, contractiles incl. Bust/Dust, svc/k9, CREATE bot_directives/, README/EXPLAINME, wiki bleeding-edge); (iv) standards/rsr-template drift check (flag divergence immediately); (v) recency-gate nextgen-languages/nextgen-typing/echo-types; (vi) resume main work. NOTE: GitHub Actions billing rejection may still be active — verify before relying on CI.
28
28
[2026-06-13 12:25:00] BRANCH DECISION (item 3): chore/hypatia-scan-reusable-wrapper assessed → DROP (superseded, do not re-create). Evidence: (1) main already DELETED its inline hypatia-scan.yml; (2) main's codeql.yml already uses the `actions` extractor (the branch's "codeql actions matrix" commit is redundant); (3) estate-standardization-20260607 redoes BOTH codeql.yml + hypatia-scan.yml, and its hypatia-scan.yml is the same thin standards reusable-wrapper but pinned to a NEWER standards SHA (6cd3772) vs the branch's stale 97df762. The branch (3 wks old, 24 commits behind main, 3 commits ahead) adds nothing not better-done by main + estate-standardization. DELETION BLOCKED from this remote-exec env: the local git proxy rejects push-deletes ("remote end hung up") and the GitHub MCP has no delete-branch/ref tool. ACTION (account owner): delete chore/hypatia-scan-reusable-wrapper, OR it retires naturally when estate-standardization-20260607 lands. Remaining open branch decision: estate-standardization-20260607 (the standards catch-up; conflicts with #34/#38; needs maintainer-driven reconcile — re-apply the K9!/grammar fixes into the renamed self-validating/ guards).
29
29
30
+
31
+
[2026-06-14 01:25:37] Session ended (continuation): item-2 estate-standardization reconcile MERGED (PR #40) → main is one reconciled line. Then resumed ORIGINAL WORK = Layer-10 PHASE 2 (residue as a linear undo-capability). (a) Idris2: proofs/idris2/EchoResidueLinear.idr (NEW, %default total, zero believe_me, idris2 --check clean) — reverseLinear consumes (1 e : Echo f y) (Idris2 quantity 1 = "consumed exactly once" proof, mirroring 007's planned Linear<Echo<T>>); reverseLinearCorrect (recovered input maps back to y, intrinsic via the dependent pair); ResidueCell Holding/Spent = the residue carried as agent STATE between handlers; takeForReverse (later handler consumes the cell; Spent→Nothing); holdingReverses/spentDoesNotReverse (cross-handler reversal succeeds iff a residue was retained); cellMode bridges a cell back to the phase-1 Reversibility mode. (b) Rust typechecker.rs: residue stack now carries Linear<Echo<T>> (push_echo_residue wraps Type::Echo in Type::Linear) — the consumed-once discipline is explicit in the carried type; the single linear use is the take_echo_residue pop in a later reverse. +3 typechecker_tests (l10_phase2_residue_type_is_linear_echo / _double_reverse_of_single_residue_is_error / _retained_residue_is_not_an_error) → 883 oo7-core lib tests passing. CI gates verified LOCALLY: cargo check --offline 0, full oo7-core test suite 922 ok 0 fail, fmt --check 0, clippy (CI-equivalent, no --all-targets) -D warnings exit 0. (c) DESIGN DECISION flagged to user (a plus/interesting): the residue is an AFFINE capability consumed LINEARLY — replaying one log twice is rejected (linear use; structural in the stack), but a reversible block need NOT be paired with a reverse (un-reversed residue is NOT an error; reversibility is a capability, usually unused). The opposite (strict must-reverse / LinearNotConsumed) was deliberately REJECTED as semantically wrong + poor agent ergonomics; the 3 tests lock the affine-drop in so it can't be silently tightened. (d) Docs in lockstep: TYPE-SYSTEM-SPEC §11b.4 + OPERATIONAL-SEMANTICS §11.4 (planned→landed), CHANGELOG phase-2 bullet, docs/echo-residue-integration.adoc (phase-2 section + design-decision subsection + "still open" cross-handler rung), 6a2 STATE.a2ml last/next_action + cleared estate-standardization-unmerged blocker. (e) NOTE — canonical-proof-suite MANIFEST.a2ml NOT touched: phase-1 EchoResidue.idr is not a manifest entry either, so EchoResidueLinear.idr stays alongside it (checked by idris2 --check, not the curated S/E/M suite); the proof-suite workflow ignores unlisted .idr files (no CI risk). STILL OPEN (next rung): cross-handler NAMED residues need residue-binding grammar syntax (let undo = reversible {…}; reverse undo) — Harvard-guarded grammar change, kept as its own rung; formal model (ResidueCell) already in place, only surface syntax missing. Phase-2 work pushed to branch claude/echo-residue-phase2-linear → draft PR. Billing blocker may still gate CI (account-owner action).
Copy file name to clipboardExpand all lines: CHANGELOG.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,8 @@ All notable changes to this project will be documented in this file.
6
6
## [Unreleased] — 2026-04-10 consolidation pass
7
7
8
8
### Added
9
-
-**Layer 10 — Reversibility (Echo residue): echo-types integrated into the type system.**`reversible`/`irreversible`/`reverse` are no longer checked identically: `Type::Echo<T>` residues are tracked per body (`reversible` retains one, `irreversible` discards it, `reverse` consumes one), and a `reverse` with no residue is `ReverseWithoutResidue` — enforcing OPERATIONAL-SEMANTICS §11.3, previously unenforced. Grounded in echo-types' keystone `A ≃ Σ B (Echo f)` and mechanised in `proofs/idris2/EchoResidue.idr` (`encodeDecode`, `reverseAfterIrreversibleIllTyped`, `collapseHasNoSection`; `%default total`, zero `believe_me`). Surfaced to agents via `agent_api` code `L10_REVERSE_WITHOUT_RESIDUE` (+`mark_reversible`/`retain_echo` remediations). 4 new typechecker tests (880 `oo7-core` lib tests passing). Spec: TYPE-SYSTEM-SPEC §"Layer 10", OPERATIONAL-SEMANTICS §11.4; design note `docs/echo-residue-integration.adoc` (incl. the phase-2 linear-undo-capability rung).
9
+
-**Layer 10 — Reversibility (Echo residue): echo-types integrated into the type system.**`reversible`/`irreversible`/`reverse` are no longer checked identically: `Type::Echo<T>` residues are tracked per body (`reversible` retains one, `irreversible` discards it, `reverse` consumes one), and a `reverse` with no residue is `ReverseWithoutResidue` — enforcing OPERATIONAL-SEMANTICS §11.3, previously unenforced. Grounded in echo-types' keystone `A ≃ Σ B (Echo f)` and mechanised in `proofs/idris2/EchoResidue.idr` (`encodeDecode`, `reverseAfterIrreversibleIllTyped`, `collapseHasNoSection`; `%default total`, zero `believe_me`). Surfaced to agents via `agent_api` code `L10_REVERSE_WITHOUT_RESIDUE` (+`mark_reversible`/`retain_echo` remediations). 4 new typechecker tests. Spec: TYPE-SYSTEM-SPEC §"Layer 10", OPERATIONAL-SEMANTICS §11.4; design note `docs/echo-residue-integration.adoc`.
10
+
-**Layer 10 phase 2 — the residue is a linear undo-capability.** The checker's residue stack now carries `Linear<Echo<T>>` (was a bare `Echo<T>`), making the consumed-once discipline explicit in the type. Discipline: *affine capability, linear consumption* — a given reversal log is consumed at most once (a double `reverse` of one residue is rejected) yet a `reversible` block need not be paired with a `reverse` (an un-reversed residue is **not** an error; reversibility is a capability, usually unused). Mechanised in `proofs/idris2/EchoResidueLinear.idr` (`reverseLinear` consumes `(1 e : Echo f y)`; `ResidueCell` Holding/Spent = the residue as agent state; `holdingReverses`/`spentDoesNotReverse`; `%default total`, zero `believe_me`, `idris2 --check` clean). 3 new typechecker tests (883 `oo7-core` lib tests passing). Remaining rung: cross-handler *named* residues (residue-binding grammar syntax, Harvard-guarded — kept separate). Spec/docs updated in lockstep.
10
11
-**752 tests** (up from 207 at 0.5.0). CRG-C achieved 2026-04-04 for `oo7-core`.
11
12
-**31 multi-language backends** via `mk2_bridge::create_backend_registry()`. Real dispatch to `elixir`, `idris2`, `gleam`, `rescript`, `nickel`, `guile`, `psql`, etc. Tier-5 coprocessor backends (CUDA/Vulkan/Metal/OpenCL/FPGA/TPU/DSP) do phase-1 device discovery with documented "kernel launch is future work" status.
0 commit comments