Skip to content

Commit e2ecfe8

Browse files
hyperpolymathclaude
andcommitted
chore(6a2): enrich A2ML checkpoint files + add JTV v2 reversibility design doc
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 6d4ad11 commit e2ecfe8

7 files changed

Lines changed: 339 additions & 144 deletions

File tree

Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
<!-- SPDX-License-Identifier: PMPL-1.0-or-later -->
2+
<!-- Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk> -->
3+
4+
# JTV v2 Reversibility: Canonical Design
5+
6+
Date: 2026-04-12
7+
8+
## Status
9+
10+
Accepted — canonical model for JTV v2 (Gamma). See also the designed fork
11+
with 007's Phase 1 implementation documented at the end of this file.
12+
13+
---
14+
15+
## The Philosophical Commitment
16+
17+
JTV v2's central claim is: **subtraction is not a primitive.** It is the
18+
inverse of addition, accessed via reversal. This is not a convenience — it
19+
is the foundational identity of the Gamma stage of JTV's evolution.
20+
21+
`x - v` in JTV v2 does not exist as a grammar production. Instead:
22+
23+
```
24+
reverse { x += v }
25+
```
26+
27+
This is not approximate. It is not "semantically equivalent in the simple
28+
case." It IS subtraction, because subtraction IS the reversal of addition.
29+
The arithmetic identity is preserved at the operation level, not recovered
30+
by a snapshot.
31+
32+
This commitment places JTV v2 in the tradition of Janus (Lutz & Derby 1982,
33+
Yokoyama & Glück 2007) — per-operation reversal, step-by-step invertibility,
34+
genuine connection to Landauer's principle and Bennett's theorem on reversible
35+
computation.
36+
37+
---
38+
39+
## The Three Constructs
40+
41+
### `reversible { }`
42+
43+
Marks a block whose operations are reversible. Maintains a reversal log:
44+
45+
```
46+
R = [(op₁, inv(op₁)), (op₂, inv(op₂)), ...]
47+
```
48+
49+
Each operation inside records its inverse at execution time. The inverses
50+
are:
51+
52+
| Operation | Inverse |
53+
|-----------|---------|
54+
| `x += v` | `x -= v` (i.e. `reverse { x += v }`) |
55+
| `append(xs, v)` | `remove_last(xs)` |
56+
| `send_local(h, v)` | handle reverts via snapshot of pre-send state |
57+
58+
### `reverse { }`
59+
60+
Applies the reversal log in reverse order. This is step-by-step inversion —
61+
not snapshot restore. The log is walked backwards, each inverse applied in
62+
sequence. The programmer observes intermediate states being undone.
63+
64+
### `irreversible { }`
65+
66+
Explicitly marks operations with no defined inverse: I/O, cross-agent sends,
67+
external API calls. Attempting to `reverse` an `irreversible` block is a
68+
static error.
69+
70+
---
71+
72+
## The Linear Token (Shared with 007)
73+
74+
Both JTV v2 and 007 use the linear `ReversalToken` mechanism for pairing.
75+
Entering `reversible { }` produces a linear value `tok` of type
76+
`ReversalToken<S>`. The token must be consumed by `reverse tok` or
77+
`abandon tok` (explicit commit). Linearity guarantees exactly one
78+
`reverse`/`abandon` per token — no double-reversal, no lost log.
79+
80+
```
81+
reversible {
82+
x += amount
83+
append(log, entry)
84+
} -> tok -- tok : ReversalToken<{ x: Int, log: List<Entry> }>
85+
86+
reverse tok -- replays: remove_last(log), then x -= amount
87+
-- OR
88+
abandon tok -- commits: discards log, operations stand
89+
```
90+
91+
In JTV v2, the token's type parameter `S` records the *types* of captured
92+
variables whose inverses are logged — not their pre-operation values (that
93+
is the snapshot approach; JTV v2 carries the operation log instead).
94+
95+
### Structural sugar
96+
97+
```
98+
reversible { ... } reverse { ... }
99+
-- desugars to: reversible { ... } -> _tok ; reverse _tok
100+
```
101+
102+
---
103+
104+
## Branch Interaction
105+
106+
At `branch` join points, path-sensitive typing applies:
107+
108+
- Token on **all** arms → `ReversalToken<S>` (must consume)
109+
- Token on **some** arms → `Option<ReversalToken<S>>` (auto-promoted; `match` forces handling)
110+
- Token on **no** arms → nothing in scope
111+
112+
The `Option<ReversalToken<S>>` type at asymmetric joins IS the signal.
113+
`match` forces exhaustive `Some`/`None` handling. No separate lint needed.
114+
115+
---
116+
117+
## The ExternalHandle Boundary
118+
119+
`send` inside a `reversible` block targeting an `ExternalHandle` (crossing
120+
an agent boundary) is a **static error** unless inside `irreversible { }`.
121+
122+
This enforces that JTV v2's reversibility is **local reversibility**. True
123+
distributed reversibility (saga patterns, two-phase commit) is implemented
124+
at the agent protocol level, not via `reverse`. This is correct: distributed
125+
reversibility is a distributed systems problem.
126+
127+
---
128+
129+
## What JTV v2 Does NOT Do
130+
131+
JTV v2 does **not** use whole-block snapshot restore as its reversal
132+
mechanism. This is the key distinction from 007's Phase 1 implementation.
133+
134+
- **Snapshot restore** (007 Phase 1): captures pre-block `@state` values,
135+
restores them on `reverse`. Semantically correct at block granularity.
136+
Not per-operation. Not at the Landauer limit.
137+
138+
- **Operation log + replay** (JTV v2): records `(op, inv(op))` pairs as
139+
operations execute, replays inverses in reverse order on `reverse`.
140+
Per-operation. Philosophically aligned with the subtraction-as-inverse claim.
141+
Closer to the Landauer limit (each operation's energy cost can in principle
142+
be recouped).
143+
144+
---
145+
146+
## The Designed Fork with 007
147+
148+
This divergence from 007's Phase 1 is **deliberate and documented** as a
149+
designed experiment. See:
150+
151+
- `007/docs/session-2026-04-12-jtv-v2-reversibility-design.adoc` — 007's
152+
five closed design decisions and Phase 1/Phase 2 distinction
153+
- `nextgen-languages/docs/design/jtv-007-reversibility-fork.adoc` — the
154+
portfolio-level experiment design
155+
156+
### Shared foundations (both approaches)
157+
158+
- Linear `ReversalToken` as pairing mechanism
159+
- `Option<ReversalToken>` at branch joins (path-sensitive typing)
160+
- `ExternalHandle` static error for agent boundary sends
161+
- `irreversible { }` escape hatch
162+
- `reversible { } reverse { }` structural sugar
163+
164+
### What differs
165+
166+
| | JTV v2 | 007 Phase 1 | 007 Phase 2 |
167+
|--|--------|-------------|-------------|
168+
| Token carries | Operation log | `@state` field values (snapshot) | Operation log (ref T) |
169+
| `reverse tok` does | Replay inverse ops in order | Restore snapshot | Replay inverse ops |
170+
| Subtraction model | `reverse { x += v }` = true inverse | State restore predating `+=` | `reverse ref_x += v` = true inverse |
171+
| Landauer proximity | Close | Distant (snapshot has memory cost) | Close |
172+
173+
### Convergence point
174+
175+
007 Phase 2 (`ref T` + fine-grained log) converges toward JTV v2's
176+
per-operation model. At that point the experiment concludes:
177+
178+
- If snapshot proves sufficient for 95% of agent programming use cases,
179+
JTV v2 may consider a two-tier model (snapshot for simple cases, log for
180+
complex ones).
181+
- If per-operation inversion proves essential in 007 Phase 2, the Phase 1
182+
snapshot approach is confirmed as a stepping stone only.
183+
184+
Neither outcome compromises the other. The shared token foundation ensures
185+
findings transfer immediately in either direction.
Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,34 @@
1-
;; SPDX-License-Identifier: PMPL-1.0-or-later
2-
;; AGENTIC.scm - AI agent interaction patterns
1+
# SPDX-License-Identifier: PMPL-1.0-or-later
2+
# Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
3+
#
4+
# AGENTIC.a2ml — AI agent constraints and capabilities
5+
[metadata]
6+
version = "0.1.0"
7+
last-updated = "2026-04-11"
38

4-
(define agentic-config
5-
`((version . "1.0.0")
6-
(project . "jtv-playground")
7-
(claude-code
8-
((model . "claude-opus-4-5-20251101")
9-
(tools . ("read" "edit" "bash" "grep" "glob"))
10-
(permissions . "read-all")))
11-
(patterns
12-
((code-review . "thorough")
13-
(refactoring . "liberal")
14-
(testing . "comprehensive")
15-
(experimentation . "encouraged")))
16-
(constraints
17-
((languages . ("rescript" "rust" "gleam" "scheme"))
18-
(banned . ("typescript" "go" "python" "makefile"))))
19-
(project-specific
20-
((experiments . "document-learnings")
21-
(multi-tech . "compare-approaches")))))
9+
[agent-permissions]
10+
can-edit-source = true
11+
can-edit-tests = true
12+
can-edit-docs = true
13+
can-edit-config = true
14+
can-create-files = true
15+
16+
[agent-constraints]
17+
# What AI agents must NOT do:
18+
# - Never use banned language patterns (believe_me, unsafeCoerce, etc.)
19+
# - Never commit secrets or credentials
20+
# - Never use banned languages (TypeScript, Python, Go, etc.)
21+
# - Never place state files in repository root (must be in .machine_readable/)
22+
# - Never use AGPL license (use PMPL-1.0-or-later)
23+
24+
[maintenance-integrity]
25+
fail-closed = true
26+
require-evidence-per-step = true
27+
allow-silent-skip = false
28+
require-rerun-after-fix = true
29+
release-claim-requires-hard-pass = true
30+
31+
[automation-hooks]
32+
# on-enter: Read 0-AI-MANIFEST.a2ml, then STATE.a2ml
33+
# on-exit: Update STATE.a2ml with session outcomes
34+
# on-commit: Run just validate-rsr
Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,20 @@
1-
;; SPDX-License-Identifier: PMPL-1.0-or-later
2-
;; ECOSYSTEM.scm - Ecosystem positioning
1+
# SPDX-License-Identifier: PMPL-1.0-or-later
2+
# Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
3+
#
4+
# ECOSYSTEM.a2ml — Playground ecosystem position
5+
[metadata]
6+
version = "1.0.0"
7+
last-updated = "2026-04-11"
38

4-
(ecosystem
5-
(version . "1.0.0")
6-
(name . "jtv-playground")
7-
(type . "language-playground")
8-
(purpose . "Comprehensive development experimentation sandbox")
9+
[project]
10+
name = "Playground"
11+
purpose = "Comprehensive development experimentation sandbox"
12+
role = "language-playground"
913

10-
(position-in-ecosystem
11-
((parent . "language-playgrounds")
12-
(grandparent . "nextgen-languages")
13-
(category . "general-experimentation")))
14+
[position-in-ecosystem]
15+
category = "general-experimentation"
1416

15-
(related-projects
16-
((julia-the-viper
17-
((relationship . "origin")
18-
(description . "Harvard Architecture systems programming")))
19-
(all-playgrounds
20-
((relationship . "sibling")
21-
(description . "Part of language-playgrounds family")))))
22-
23-
(what-this-is
24-
("Multi-technology playground"
25-
"API and frontend demos"
26-
"Testing and infrastructure experiments"))
27-
28-
(what-this-is-not
29-
("Production codebase"
30-
"Single-technology focus"
31-
"Stable API")))
17+
[related-projects]
18+
projects = [
19+
{ name = "jtv-playground", relationship = "origin" },
20+
]
Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,27 @@
1-
;; SPDX-License-Identifier: PMPL-1.0-or-later
2-
;; META.scm - Project metadata and architecture decisions
1+
# SPDX-License-Identifier: PMPL-1.0-or-later
2+
# Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
3+
#
4+
# META.a2ml — Playground meta-level information
5+
[metadata]
6+
version = "1.0.0"
7+
last-updated = "2026-04-11"
38

4-
(define project-meta
5-
`((version . "1.0.0")
6-
(name . "jtv-playground")
7-
(architecture-decisions
8-
((adr-001
9-
((status . "accepted")
10-
(date . "2025-12-30")
11-
(context . "Need comprehensive development playground")
12-
(decision . "Create multi-technology experimentation sandbox")
13-
(consequences . "Learn and prototype across different stacks")))))
14-
(development-practices
15-
((code-style . "per-technology")
16-
(security . "openssf-scorecard")
17-
(testing . "per-experiment")
18-
(versioning . "semver")
19-
(documentation . "asciidoc")
20-
(branching . "trunk-based")))
21-
(design-rationale
22-
((why-playground . "Safe space for experimentation")
23-
(why-multi-tech . "Learn different approaches")
24-
(why-organized . "Structured experiment tracking")))))
9+
[project-info]
10+
license = "PMPL-1.0-or-later"
11+
author = "Jonathan D.A. Jewell (hyperpolymath)"
12+
13+
[architecture-decisions]
14+
decisions = [
15+
# No ADRs recorded
16+
]
17+
18+
[development-practices]
19+
versioning = "SemVer"
20+
documentation = "AsciiDoc"
21+
build-tool = "just"
22+
23+
[maintenance-axes]
24+
scoping-first = true
25+
axis-1 = "must > intend > like"
26+
axis-2 = "corrective > adaptive > perfective"
27+
axis-3 = "systems > compliance > effects"
Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
;; SPDX-License-Identifier: PMPL-1.0-or-later
2-
;; NEUROSYM.scm - Neurosymbolic integration config
1+
# SPDX-License-Identifier: PMPL-1.0-or-later
2+
# Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
3+
#
4+
# NEUROSYM.a2ml — Neurosymbolic integration metadata
5+
[metadata]
6+
version = "0.1.0"
7+
last-updated = "2026-04-11"
38

4-
(define neurosym-config
5-
`((version . "1.0.0")
6-
(project . "jtv-playground")
7-
(symbolic-layer
8-
((type . "scheme")
9-
(reasoning . "deductive")
10-
(verification . "per-experiment")
11-
(language-specific
12-
((multi-tech . #t)
13-
(patterns . "design-patterns")
14-
(semantics . "varies")))))
15-
(neural-layer
16-
((embeddings . #f)
17-
(fine-tuning . #f)
18-
(inference . #f)))
19-
(integration
20-
((ai-assisted-development . "duet-style")
21-
(experiment-suggestions . #t)))))
9+
[hypatia-config]
10+
scan-enabled = true
11+
scan-depth = "standard" # quick | standard | deep
12+
report-format = "logtalk"
13+
14+
[symbolic-rules]
15+
# Custom symbolic rules for this project
16+
# - { name = "no-unsafe-ffi", pattern = "believe_me|unsafeCoerce", severity = "critical" }
17+
18+
[neural-config]
19+
# Neural pattern detection settings
20+
# confidence-threshold = 0.85
21+
# model = "hypatia-v2"

0 commit comments

Comments
 (0)