Skip to content

Commit 10e937c

Browse files
feat(types): Echo types (structured loss) across the pipeline (#17)
Adds Echo<A,B> / EchoR<A,B> as Error-Lang's first-class visible structured-loss shape, porting the echo-types (Agda) / EchoTypes.jl (Julia) lineage. Governing invariant: decomposition must be visible — echo_to_residue is never a silent cast, EchoR never unifies with Echo, and the stability debit is never hidden. Compiler: TyEcho/TyEchoR in type checker, VEcho/VResidue in VM/Bytecode, dedicated opcodes in Codegen, echoEraseCost=15.0 [Stab-Erase] debit. Five builtins mirror EchoTypes.jl: echo, echo_to_residue, echo_input, echo_output, residue_strictly_loses. Tests: three decomposition planes (syntactic, semantic/runtime, type-checking). Docs: spec/type-system.md §7, docs/Echo-Decomposition.adoc, Curriculum Lesson 11, EXPLAINME.adoc, contractiles/ (Mustfile, Dustfile, Trustfile.hs, Intentfile), manifests (STATE, META ADR-0001, NEUROSYM rules, ECOSYSTEM, AGENTIC constraint).
1 parent 35c93b6 commit 10e937c

24 files changed

Lines changed: 1513 additions & 116 deletions

.machine_readable/6a2/AGENTIC.a2ml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ can-create-files = true
2020
# - Never use banned languages (TypeScript, Python, Go, etc.)
2121
# - Never place state files in repository root (must be in .machine_readable/)
2222
# - Never use AGPL license (use MPL-2.0)
23+
# - Never break VISIBLE DECOMPOSITION for Echo types:
24+
# * do not make echo_to_residue a silent cast
25+
# * do not let EchoR<A,B> behave like / coerce to Echo<A,B>
26+
# * do not hide the erasure stability debit ([Stab-Erase])
27+
# (see docs/Echo-Decomposition.adoc, spec/type-system.md §7)
2328

2429
[maintenance-integrity]
2530
fail-closed = true

.machine_readable/6a2/ECOSYSTEM.a2ml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,17 @@ last-updated = "2026-04-11"
88

99
[project]
1010
name = "Error Lang"
11-
purpose = ""
12-
role = ""
11+
purpose = "A dissembling/decompositional educational language that makes the decay and structured loss of programs, semantics, and types VISIBLE."
12+
role = "Operational, stability-aware embedding of the Echo (structured-loss) lineage; the decomposition-visible member of the Echo family."
1313

1414
[position-in-ecosystem]
15-
category = ""
15+
category = "educational-programming-language"
1616

1717
[related-projects]
1818
projects = [
19-
# No related projects recorded
19+
# The Echo (structured-loss) lineage that Error-Lang's Echo<A,B>/EchoR<A,B> embed.
20+
# Error-Lang stays Error-Lang-specific (visible decomposition); it does not
21+
# re-export these repos' exposition.
22+
{ name = "echo-types", owner = "hyperpolymath", role = "source of mechanized truth (Agda): Echo f y := Σ(x:A), (f x ≡ y)" },
23+
{ name = "EchoTypes.jl", owner = "hyperpolymath", role = "finite-domain executable model (Julia) — a model, not a proof" },
2024
]

.machine_readable/6a2/META.a2ml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,15 @@ author = "Jonathan D.A. Jewell (hyperpolymath)"
1212

1313
[architecture-decisions]
1414
decisions = [
15-
# No ADRs recorded
15+
# ADR-0001: Echo types model structured loss as first-class, VISIBLE decomposition.
16+
# Echo<A,B> = retained witness + visible output; EchoR<A,B> = residue after
17+
# irreversible erasure; echo_to_residue is an explicit decomposition step that
18+
# debits stability ([Stab-Erase]). Invariant: decomposition must be visible —
19+
# no silent cast, EchoR is not Echo-with-a-missing-field, debit not hidden.
20+
# Runtime is single-witness (VEcho{input,output} / VResidue{output}); whole-fibre
21+
# waits for first-class functions. Builtin names mirror EchoTypes.jl.
22+
# Refs: docs/Echo-Decomposition.adoc, spec/type-system.md §7.
23+
{ id = "ADR-0001", title = "Echo types as visible structured-loss decomposition", status = "accepted" },
1624
]
1725

1826
[development-practices]

.machine_readable/6a2/NEUROSYM.a2ml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@ report-format = "logtalk"
1414
[symbolic-rules]
1515
# Custom symbolic rules for this project
1616
# - { name = "no-unsafe-ffi", pattern = "believe_me|unsafeCoerce", severity = "critical" }
17+
#
18+
# Echo decomposition must remain VISIBLE (see docs/Echo-Decomposition.adoc):
19+
# - echo_to_residue must debit stability — it is never a silent cast
20+
# - EchoR<A,B> must not unify with / be coerced to Echo<A,B>
21+
# - echo_input must be rejected on a residue (the witness is gone)
22+
rules = [
23+
{ name = "echo-erasure-must-cost", concern = "echo_to_residue must apply the [Stab-Erase] stability debit", severity = "high" },
24+
{ name = "echo-residue-no-coercion", concern = "no implicit Echo->EchoR or Echo->B coercion; EchoR does not unify back into Echo", severity = "high" },
25+
{ name = "echo-input-not-on-residue", concern = "echo_input is illegal on EchoR (non-recoverable residue)", severity = "high" },
26+
]
1727

1828
[neural-config]
1929
# Neural pattern detection settings

.machine_readable/6a2/STATE.a2ml

Lines changed: 56 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,41 +4,79 @@
44
# STATE.a2ml — Error Lang project state
55
[metadata]
66
project = "error-lang"
7-
version = "0.4.0"
8-
last-updated = "2026-02-07"
7+
version = "0.5.0"
8+
last-updated = "2026-06-02"
99
status = "active"
10-
session = "converted from scheme — 2026-04-11"
10+
session = "Echo types (structured loss) — 2026-06-02"
1111

1212
[project-context]
1313
name = "Error Lang"
14-
purpose = """Merge error-lang-playground into main repo"""
14+
purpose = """
15+
Add Echo types (Echo<A,B> / EchoR<A,B>) as Error-Lang's first-class, visible
16+
form of structured loss. Port the echo-types (Agda) / EchoTypes.jl (Julia)
17+
lineage into the compiler pipeline, type checker, VM, and documentation.
18+
Governing invariant: decomposition must be visible.
19+
"""
1520
completion-percentage = 100
1621

1722
[position]
1823
phase = "production-ready" # design | implementation | testing | maintenance | archived
19-
maturity = "experimental" # experimental | alpha | beta | production | lts
24+
maturity = "experimental" # experimental | alpha | beta | production | lts
2025

21-
[route-to-mvp]
22-
milestones = [
23-
# No milestones recorded
26+
[what-was-done]
27+
# Session 2026-06-02 — Echo types (structured loss)
28+
additions = [
29+
"Echo<A,B> and EchoR<A,B> types added to: lexer (keywords), parser (type annotations), type checker (TyEcho/TyEchoR, unification, builtins), codegen (dedicated opcodes), VM (VEcho/VResidue, stability debit)",
30+
"Five builtins mirroring EchoTypes.jl: echo, echo_to_residue, echo_input, echo_output, residue_strictly_loses",
31+
"Stability debit: echoEraseCost = 15.0 charged by OpEchoToResidue, never on projection",
32+
"Irreversibility: TyEcho never unifies with TyEchoR; echo_input is type+runtime error on EchoR",
33+
"Tests: type-checker (10), parser (1 comprehensive), lexer (2), runtime (5) across three decomposition planes",
34+
"New docs: docs/Echo-Decomposition.adoc (authoritative), spec/type-system.md §7, docs/Design-Philosophy.adoc section, docs/Error-Lang.adoc section, docs/Curriculum.adoc Lesson 11, docs/Educational-Framework.adoc, docs/Error-Categories.adoc echo-erasure row",
35+
"New example: examples/11-echo-decomposition.err (narrated, with gutter zone)",
36+
"Updated manifests: 0-AI-MANIFEST.a2ml (core narrative + invariants), META.a2ml (ADR-0001), NEUROSYM.a2ml (3 symbolic rules), ECOSYSTEM.a2ml (lineage), AGENTIC.a2ml (constraint)",
37+
"README.adoc decompositional framing and Echo introduction",
38+
"EXPLAINME.adoc created (human/agent orientation document)",
39+
"contractiles/ updated: Mustfile (Error-Lang invariants), Dustfile (recovery handlers), trust/Trustfile.hs (verification), lust/Intentfile (roadmap)",
40+
"CI hardening: casket-pages.yml, codeql.yml, hypatia-scan.yml get timeout-minutes (separate PR #18)",
2441
]
2542

43+
[current-ci-status]
44+
# As of 2026-06-02, PR #17 (Echo types) check status:
45+
passing = [
46+
"Hypatia Neurosymbolic Analysis",
47+
"CodeQL Analysis (javascript-typescript)",
48+
"governance / Licence consistency",
49+
"governance / Guix primary / Nix fallback policy",
50+
"governance / Well-Known (RFC 9116 + RSR)",
51+
"governance / Workflow security linter",
52+
"governance / Trusted-base reduction policy",
53+
"governance / Validate Hypatia baseline",
54+
"governance / Code quality + docs",
55+
"governance / Security policy checks",
56+
]
57+
failing = [
58+
"governance / Language / package anti-pattern policy",
59+
]
60+
failing-reason = """
61+
The anti-pattern policy bans ReScript (.res files) estate-wide. This failure
62+
is PRE-EXISTING on main — it fails identically there. It is NOT caused by
63+
Echo types or any recent work. Resolution: AffineScript re-target (INTENT-001,
64+
ADR-pending). Do NOT attempt to fix by removing .res files.
65+
"""
66+
2667
[blockers-and-issues]
2768
issues = [
28-
"Backend architecture decision: bytecode VM vs transpile to JS",
69+
"governance / Language / package anti-pattern policy — permanent pre-existing failure (ReScript ban); resolves only with AffineScript re-target",
2970
]
3071

3172
[critical-next-actions]
3273
actions = [
33-
"Decide on backend strategy (bytecode vs transpile)",
34-
"Complete Zig FFI bindings",
35-
"Start LSP server skeleton",
36-
"Design computational haptics visualization protocol",
37-
"Complete backend/codegen",
38-
"Complete LSP server",
39-
"Create VS Code extension prototype",
74+
"AffineScript re-target: migrate compiler/src/*.res to standard dialect (INTENT-001)",
75+
"First-class functions in VM: enable whole-fibre Echo (INTENT-002)",
76+
"LSP hover for Echo decomposition tracking (INTENT-005)",
4077
]
4178

4279
[maintenance-status]
43-
last-run-utc = "2026-02-07T00:00:00Z"
44-
last-result = "unknown" # unknown | pass | warn | fail
80+
last-run-utc = "2026-06-02T00:00:00Z"
81+
last-result = "pass" # unknown | pass | warn | fail
82+
notes = "All checks pass except the pre-existing governance ReScript ban."

0-AI-MANIFEST.a2ml

Lines changed: 103 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,137 @@
11
# SPDX-License-Identifier: MPL-2.0
22
# 0-AI-MANIFEST.a2ml — error-lang
33
# Universal AI Agent Gateway — Read This First
4-
# Generated: 2026-03-14
4+
# Last updated: 2026-06-02
55

66
## Identity
77

88
project: error-lang
99
type: programming-language
1010
owner: hyperpolymath
1111
description: >
12-
Error-first programming language with graduated error levels and ReScript playground compiler.
12+
A dissembling / decompositional educational programming language. Programs,
13+
syntax, semantics, and types can decay, decompose, and destabilise over time,
14+
and the language EXPOSES that decomposition (consequence amplification +
15+
stability scoring) rather than hiding it. Echo types give structured loss a
16+
first-class shape. Error-first with graduated error levels.
1317
license: MPL-2.0
1418

19+
## Core Narrative (read before reasoning about features)
20+
21+
Error-Lang is not merely "a language with errors." It is decompositional:
22+
the distinctive claim is that decomposition is itself something the language
23+
exposes and reasons about. Echo types make STRUCTURED LOSS first-class:
24+
- Echo<A, B> retained witness + visible output (a fibre witness)
25+
- EchoR<A, B> residue after irreversible erasure (witness gone)
26+
- echo_to_residue explicit decomposition step; debits stability ([Stab-Erase])
27+
Governing invariant: DECOMPOSITION MUST BE VISIBLE — echo_to_residue is never a
28+
silent cast, EchoR is never an Echo with a missing field, and the stability
29+
debit is never hidden. See docs/Echo-Decomposition.adoc and spec/type-system.md §7.
30+
1531
## Critical Invariants
1632

33+
- Decomposition must be visible: never make echo_to_residue a silent cast,
34+
never let EchoR behave like Echo, never hide the erasure stability debit
1735
- SCM files ONLY in `.machine_readable/` (root copies are symlinks)
18-
- NEVER delete spec files: grammar, SPEC.core.scm
36+
- NEVER delete spec files: spec/grammar.ebnf, spec/SPEC.core.scm
1937
- NEVER use banned languages: TypeScript, Node.js, npm, Go, Python
2038
- All GitHub Actions must be SHA-pinned
21-
- All source files must have SPDX headers
39+
- All source files must have SPDX-License-Identifier: MPL-2.0 headers
2240
- Root symlinks MUST be maintained when moving files
41+
- NEVER use the AGPL license (use MPL-2.0)
42+
- DO NOT remove compiler/*.res files — they are a legacy reference frontend
43+
pending AffineScript re-target. The governance CI failure is pre-existing.
44+
45+
## Known Pre-existing CI Failure
46+
47+
governance / Language / package anti-pattern policy FAILS on every PR and on
48+
main because compiler/src/*.res files exist. This is intentional/legacy — the
49+
compiler is a reference frontend in a non-standard early ReScript dialect. The
50+
runnable implementation is in cli/. Resolution: AffineScript re-target
51+
(contractiles/lust/Intentfile INTENT-001). Do NOT work around it by removing
52+
.res files or patching governance.yml.
2353

2454
## Canonical File Locations
2555

26-
### Machine-Readable Metadata (.machine_readable/)
27-
- `.machine_readable/AGENTIC.scm`
28-
- `.machine_readable/ECOSYSTEM.scm`
29-
- `.machine_readable/META.scm`
30-
- `.machine_readable/NEUROSYM.scm`
31-
- `.machine_readable/PLAYBOOK.scm`
32-
- `.machine_readable/STATE.scm`
56+
### Human Orientation
57+
- `EXPLAINME.adoc` — Comprehensive human/agent orientation (read this too)
58+
- `README.adoc` — GitHub landing page overview
59+
60+
### Machine-Readable Metadata (.machine_readable/6a2/)
61+
- `.machine_readable/6a2/STATE.a2ml` — Current project state and session history
62+
- `.machine_readable/6a2/META.a2ml` — Architecture decisions (ADR-0001: Echo types)
63+
- `.machine_readable/6a2/AGENTIC.a2ml` — Agent permissions and constraints
64+
- `.machine_readable/6a2/ECOSYSTEM.a2ml` — Ecosystem position and related projects
65+
- `.machine_readable/6a2/NEUROSYM.a2ml` — Hypatia symbolic rules for Echo invariants
66+
- `.machine_readable/6a2/PLAYBOOK.a2ml` — Operational playbook
3367

68+
### Operational Framework (contractiles/)
69+
- `contractiles/must/Mustfile` — Required invariants and validation checks
70+
- `contractiles/dust/Dustfile` — Recovery and rollback handlers
71+
- `contractiles/trust/Trustfile.hs` — Trust model and verification steps
72+
- `contractiles/lust/Intentfile` — Roadmap and intent (INTENT-001 through 005)
3473

3574
### Specification (spec/)
36-
- `spec/grammar.ebnf` — Canonical EBNF grammar (@taxonomy: spec/grammar)
75+
- `spec/grammar.ebnf` — Canonical EBNF grammar (@taxonomy: spec/grammar)
76+
- `spec/type-system.md` — Type system spec including §7 Echo Types
77+
- `spec/README.adoc` — Specification index
3778

38-
- `spec/README.adoc` — Specification index
79+
### Key Documentation (docs/)
80+
- `docs/Echo-Decomposition.adoc` — Echo types authoritative narrative
81+
- `docs/Design-Philosophy.adoc` — Why the language is designed this way
82+
- `docs/Error-Lang.adoc` — Full language reference
83+
- `docs/Error-Categories.adoc` — Nine error categories + stability debits
84+
- `docs/Curriculum.adoc` — Lesson sequence (Lessons 1–11)
3985

4086
### Verification (verification/)
41-
- `verification/proofs/` — Formal proofs
42-
- `verification/tests/` — Test suite ../compiler/test
43-
(symlink)
44-
- `verification/conformance/` — Conformance tests ../conformance
45-
(symlink)
46-
- `verification/benchmarks/` — Performance benchmarks ../bench
47-
(symlink)
48-
- `verification/fuzzing/` — Fuzz targets ../compiler/fuzz
49-
(symlink)
50-
- `verification/README.adoc` — Verification index
87+
- `verification/proofs/` — Formal proofs
88+
- `verification/tests/` — Test suite (symlink → ../compiler/test)
89+
- `verification/conformance/` — Conformance tests (symlink → ../conformance)
90+
- `verification/benchmarks/` — Performance benchmarks (symlink → ../bench)
91+
- `verification/fuzzing/` — Fuzz targets (symlink → ../compiler/fuzz)
5192

52-
## Taxonomy Index
93+
### Compiler (reference frontend — non-standard ReScript dialect)
94+
- `compiler/src/Types.res` — Token + type AST (TyEcho, TyEchoResidue)
95+
- `compiler/src/Lexer.res` — Tokenizer (Echo, EchoR keywords)
96+
- `compiler/src/Parser.res` — AST builder (type expression parser)
97+
- `compiler/src/TypeChecker.res` — Type inference + unification (Echo rules)
98+
- `compiler/src/Bytecode.res` — VEcho/VResidue values + Echo opcodes
99+
- `compiler/src/VM.res` — Stack VM (echoEraseCost = 15.0)
100+
- `compiler/src/Codegen.res` — AST → bytecode
53101

54-
- `spec/grammar.ebnf` — @taxonomy: spec/grammar
102+
### CLI (runnable implementation)
103+
- `cli/runtime.js` — Main runtime (Deno)
104+
- `cli/analyze.js` — Stability analysis
105+
- `cli/five-whys.js` — Root cause tracing
106+
- `cli/layer-navigator.js` — Five-layer view
55107

56-
- `spec/README.adoc` — @taxonomy: spec/index
57-
- `verification/README.adoc` — @taxonomy: verification/index
58-
- `playground/compiler/src/lexer/Lexer.res` — @taxonomy: compiler/lexer
59-
- `playground/compiler/src/parser/Parser.res` — @taxonomy: compiler/parser
60-
- `editors/error-lang.tmLanguage.json` — @taxonomy: editors/textmate-grammar
108+
### Examples
109+
- `examples/01-hello-world.err` — Baseline
110+
- `examples/11-echo-decomposition.err` — Echo types (full demo with gutter zone)
111+
112+
## Taxonomy Index
113+
114+
- `spec/grammar.ebnf` — @taxonomy: spec/grammar
115+
- `spec/type-system.md` — @taxonomy: spec/type-system
116+
- `spec/README.adoc` — @taxonomy: spec/index
117+
- `docs/Echo-Decomposition.adoc` — @taxonomy: docs/echo-decomposition
118+
- `verification/README.adoc` — @taxonomy: verification/index
119+
- `compiler/src/Lexer.res` — @taxonomy: compiler/lexer
120+
- `compiler/src/Parser.res` — @taxonomy: compiler/parser
121+
- `compiler/src/TypeChecker.res` — @taxonomy: compiler/typechecker
122+
- `compiler/src/VM.res` — @taxonomy: compiler/vm
61123

62124
## Session Startup Sequence
63125

64126
1. Read this manifest (0-AI-MANIFEST.a2ml)
65-
2. Read `.machine_readable/STATE.scm` for current progress
66-
3. Read `.machine_readable/META.scm` for architecture decisions
67-
4. Read `.machine_readable/ECOSYSTEM.scm` for ecosystem context
127+
2. Read `EXPLAINME.adoc` for comprehensive orientation
128+
3. Read `.machine_readable/6a2/STATE.a2ml` for current project state
129+
4. Read `.machine_readable/6a2/META.a2ml` for architecture decisions
130+
5. Read `.machine_readable/6a2/AGENTIC.a2ml` for agent constraints
131+
6. Read `.machine_readable/6a2/ECOSYSTEM.a2ml` for ecosystem context
132+
133+
## Session Exit Sequence
134+
135+
1. Update `.machine_readable/6a2/STATE.a2ml` with session outcomes
136+
2. Ensure all new files have SPDX-License-Identifier: MPL-2.0 headers
137+
3. Ensure Echo decomposition invariants are intact (run contractiles/must/Mustfile checks)

0 commit comments

Comments
 (0)