Skip to content

Commit 937c16c

Browse files
authored
Merge pull request #175 from link-foundation/issue-97-2fa46f510db9
2 parents 5b14273 + 911526c commit 937c16c

30 files changed

Lines changed: 10735 additions & 311 deletions

docs/DIAGNOSTICS.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,12 @@ The exit code is `1` whenever any diagnostic is emitted, `0` otherwise.
103103
| `E041` | Domain plugin error. Triggered by a malformed `(domain <name> ...)` block, an unknown domain plugin, or an unsupported request inside a registered domain plugin such as `automatic-sequences`. |
104104
| `E050` | Lean export error. Triggered when `rml export lean` sees forms outside the typed non-probabilistic subset, such as `has probability`, range/valence configuration, operator redefinitions, imports, namespaces, or templates. |
105105
| `E060` | Malformed `(root-construct …)` declaration. Triggered by a missing or non-symbolic name, an unrecognised child clause shape, or a non-symbolic value where a status / kind / dependency name is expected. See [`FOUNDATIONS.md`](./FOUNDATIONS.md). |
106-
| `E061` | Malformed `(foundation …)` declaration. Triggered by a missing name, an unrecognised child clause shape, or a malformed `(defines <op> <aggregator>)` / `(extends …)` / `(numeric-domain …)` / `(truth-domain …)` clause. See [`FOUNDATIONS.md`](./FOUNDATIONS.md). |
106+
| `E061` | Malformed `(foundation …)` declaration. Triggered by a missing name, an unrecognised child clause shape, or a malformed `(defines <op> <aggregator>)` / `(extends …)` / `(numeric-domain …)` / `(truth-domain …)` / `(carrier …)` / `(truth-table …)` clause. See [`FOUNDATIONS.md`](./FOUNDATIONS.md). |
107107
| `E062` | `(with-foundation <name> …)` references a foundation that has not been registered. Evaluation skips the body but continues with the surrounding forms; the active foundation remains the previously-active one. See [`FOUNDATIONS.md`](./FOUNDATIONS.md). |
108+
| `E063` | Carrier violation under `(strict-carrier)`. A probability assignment or query result fell outside the active foundation's declared carrier. See [`FOUNDATIONS.md`](./FOUNDATIONS.md). |
109+
| `E064` | Proof-substrate error. Triggered by malformed proof rules, assumptions, proof objects, `(check-proof …)` forms, premise/rule/conclusion mismatches, unjustified raw premises, or cyclic proof dependencies. See [`FOUNDATIONS.md`](./FOUNDATIONS.md). |
110+
| `E065` | Pure-links strict-mode error. Triggered by malformed `(strict-foundation …)` / `(allow-host-primitive …)` forms or by a query whose transitive dependency path reaches an unallowed `host-primitive` / `host-derived` construct. See [`FOUNDATIONS.md`](./FOUNDATIONS.md). |
111+
| `E066` | MTC/anum encode/decode error. Triggered by non-`Node` encode inputs, characters outside the four-abit alphabet, unbalanced frames, malformed frame tags, or byte-unaligned leaf payloads. See [`FOUNDATIONS.md`](./FOUNDATIONS.md). |
108112

109113
Codes are stable identifiers — they do not change between releases unless we
110114
explicitly note a breaking change in the changelog. The accompanying

docs/FOUNDATIONS.md

Lines changed: 225 additions & 33 deletions
Large diffs are not rendered by default.

docs/case-studies/issue-97/README.md

Lines changed: 208 additions & 26 deletions
Large diffs are not rendered by default.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"baseRefName":"main","body":"## 🤖 AI-Powered Solution Draft\n\nThis pull request is being automatically generated to solve issue #97.\n\n### 📋 Issue Reference\nFixes #97\n\n### 🚧 Status\n**Work in Progress** - The AI assistant is currently analyzing and implementing the solution draft.\n\n### 📝 Implementation Details\n_Details will be added as the solution draft is developed..._\n\n---\n*This PR was created automatically by the AI issue solver*","headRefName":"issue-97-2fa46f510db9","number":175,"state":"OPEN","title":"[WIP] Use similar idea, but everything should be built from links and references","url":"https://github.com/link-foundation/relative-meta-logic/pull/175"}

docs/case-studies/issue-97/evidence/cicd-template-review.md

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,40 @@ remain captured in `docs/case-studies/issue-171/data/recommendations.md`.
200200

201201
The CI workflow already runs `npm test` and `cargo test` on every push
202202
and PR; this can be confirmed by viewing recent runs of the `tests`
203-
workflow on the `issue-97-bbe597194dee` branch. The eight new JS
204-
tests in `foundations.test.mjs` and the eight new Rust tests in
205-
`foundations_tests.rs`, plus the extended self-evaluator coverage,
206-
all execute under the existing `tests` workflow. No additional
207-
workflow changes are needed for issue #97.
203+
workflow on the `issue-97-2fa46f510db9` branch. The extended JS
204+
coverage in `foundations.test.mjs`, `proof-substrate.test.mjs`, and
205+
`pure-links-strict.test.mjs`, plus the mirrored Rust coverage and
206+
self-evaluator checks, all execute under the existing `tests`
207+
workflow. No additional workflow changes are needed for issue #97.
208+
209+
### 8.1 Phase 2–9 follow-up coverage (PR #175)
210+
211+
The subsequent phases that landed on PR #175 add the following test
212+
files to the same suite — no workflow changes required:
213+
214+
| Phase | JS test file | Rust test file |
215+
|-------|--------------|----------------|
216+
| 2 — equality provenance | `js/tests/foundations.test.mjs` (extended) | `rust/tests/foundations_tests.rs` (extended) |
217+
| 3 — proof-object replay | `js/tests/proof-substrate.test.mjs` | `rust/tests/proof_substrate_tests.rs` |
218+
| 4 — links-defined truth tables | `js/tests/foundations.test.mjs` (extended) | `rust/tests/foundations_tests.rs` (extended) |
219+
| 5 — links-defined typed-kernel fragment | `js/tests/typed-kernel-links.test.mjs` | `rust/tests/typed_kernel_links_tests.rs` |
220+
| 6 — pure-links strict mode | `js/tests/pure-links-strict.test.mjs` | `rust/tests/pure_links_strict_tests.rs` |
221+
| 7 — dependency-graph traversal | `js/tests/dependency-graph.test.mjs` | `rust/tests/dependency_graph_tests.rs` |
222+
| 8 — carrier enforcement | `js/tests/foundations.test.mjs` (extended) | `rust/tests/foundations_tests.rs` (extended) |
223+
| 9 — `mtc-anum` experimental profile + MTC theory fragment + serialization invariants | `js/tests/mtc-anum.test.mjs` (extended) | `rust/tests/mtc_anum_tests.rs` (extended) |
224+
225+
All of these are picked up automatically by `npm test` and
226+
`cargo test --all-targets`, which the existing `tests.yml` workflow
227+
already runs on every push and PR.
228+
229+
### 8.2 Re-audit findings (2026-05-16)
230+
231+
A second pass against the four templates (described in this file
232+
plus a fresh independent review documented in this PR) confirms no
233+
new gaps were introduced by the Phase 2–9 work. The reportable
234+
findings remain T-1, T-2, T-3, and the pre-existing CI-debt items
235+
tracked in `docs/case-studies/issue-171/data/recommendations.md`.
236+
The pattern of *path-filtered triggers + safer concurrency
237+
(`!= 'refs/heads/main'`)* this repo has on its `tests.yml` and
238+
`api-docs.yml` is still ahead of all four templates and is worth
239+
contributing upstream once the foundation PR has merged.

docs/case-studies/issue-97/evidence/foundation-surface.md

Lines changed: 81 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ Snapshot-shape tests:
133133
- Rust — `rust/tests/foundations_tests.rs:172-211`
134134
(`builds_a_structured_foundation_report_snapshot`).
135135

136-
## R7 — Structured diagnostics E060 / E061 / E062
136+
## R7 — Structured diagnostics E060 / E061 / E062 and follow-up foundation diagnostics
137137

138138
The codes are emitted at:
139139

@@ -155,55 +155,107 @@ Unknown-foundation tests:
155155
- Rust — `rust/tests/foundations_tests.rs:116-132`
156156
(`reports_unknown_foundation_as_e062_without_aborting`).
157157

158-
The doc surface — `docs/DIAGNOSTICS.md` — lists E060, E061, E062 as
159-
new rows in its error code table.
158+
The doc surface — `docs/DIAGNOSTICS.md` — lists E060 through E066 in
159+
its error code table. E063 covers strict-carrier failures, E064 covers
160+
proof-substrate failures, E065 covers pure-links strict-mode failures,
161+
and E066 covers MTC/anum encode/decode failures.
160162

161163
## R8 — Self-bootstrap encoding
162164

163-
`lib/self/foundations.lino` declares the registry as data
164-
(367 lines total, every section commented). `lib/self/evaluator.lino`
165-
encodes four matching evaluator rules at lines 253-263:
165+
`lib/self/foundations.lino` declares the registry as data and records
166+
the bundled foundations, including the finite truth-table
167+
`boolean-links` profile. `lib/self/evaluator.lino` encodes matching
168+
data-only evaluator rules for the foundation surface, strict mode,
169+
proof substrate, and MTC/anum helpers:
166170

167171
```lino
168172
(rule (eval (root-construct name details))
169-
(register-root-construct name details))
173+
(record-root-construct name details))
170174
171175
(rule (eval (foundation name details))
172-
(register-foundation name details))
176+
(record-foundation name details))
177+
178+
(rule (foundation-clause (carrier values))
179+
(record-foundation-carrier values))
180+
181+
(rule (foundation-clause strict-carrier)
182+
(record-foundation-strict-carrier))
183+
184+
(rule (foundation-clause (truth-table operator rows))
185+
(record-foundation-truth-table operator rows))
186+
187+
(rule (foundation-clause experimental)
188+
(record-foundation-experimental))
189+
190+
(rule (foundation-clause (root symbol))
191+
(record-foundation-root symbol))
192+
193+
(rule (foundation-clause (abit symbol bits))
194+
(record-foundation-abit symbol bits))
173195
174196
(rule (eval (with-foundation name body))
175197
(evaluate-body-under-foundation name body))
176198
177199
(rule (eval (foundation-report))
178-
(query (foundation-report-snapshot)))
200+
(emit-foundation-report))
201+
202+
(rule (eval (strict-foundation pure-links))
203+
(enable-strict-foundation pure-links))
204+
205+
(rule (eval (allow-host-primitive names))
206+
(record-allowed-host-primitives names))
207+
208+
(rule (eval (assumption name (judgement judgement)))
209+
(record-proof-assumption name judgement))
210+
211+
(rule (eval (axiom name (judgement judgement)))
212+
(record-proof-axiom name judgement))
213+
214+
(rule (eval (proof-object name clauses))
215+
(record-proof-object name clauses))
216+
217+
(rule (proof-object-clause (premise-by name))
218+
(record-proof-dependency name))
219+
220+
(rule (proof-object-clause (uses names))
221+
(record-proof-dependencies names))
222+
223+
(rule (eval (check-proof name))
224+
(check-proof-object name))
225+
226+
(rule (eval (encodeAnum node))
227+
(encode-anum node))
228+
229+
(rule (eval (decodeAnum payload))
230+
(decode-anum payload))
179231
```
180232

181-
The Rust self-evaluator parity test requires all four rules to be
233+
The Rust self-evaluator parity test requires these rules to be
182234
present in the data file:
183-
`rust/tests/self_evaluator_tests.rs:11-63` enumerates
184-
`REQUIRED_EVAL_RULES`, including the four `(eval (root-construct …))`
185-
/ `(eval (foundation …))` / `(eval (with-foundation …))` /
186-
`(eval foundation-report)` entries; the assertion is at
187-
`rust/tests/self_evaluator_tests.rs:143-164`. The JS parity test
188-
covers the same forms with the `EncodedEvaluator` class which has
189-
explicit cases for `with-foundation`, `foundation`, and
190-
`root-construct` at
191-
`js/tests/self-evaluator.test.mjs:218-243`.
235+
`rust/tests/self_evaluator_tests.rs` enumerates `REQUIRED_EVAL_RULES`,
236+
including the foundation, strict-mode, proof, and MTC/anum entries, and
237+
`REQUIRED_SURFACE_RULES`, including foundation clauses, proof dependency
238+
clauses, and equality provenance. The JS parity test covers the same
239+
forms with the `EncodedEvaluator` class, including the bundled
240+
`boolean-links` truth-table foundation.
192241

193242
## R9 — Links-defined finite-logic example
194243

195-
Two named alternative foundations ship as data in
244+
Three named alternative foundations ship as data in
196245
`lib/self/foundations.lino`:
197246

198-
- `boolean-classical` at `lib/self/foundations.lino:343-351`
199-
two-valued logic, `and=min`, `or=max`, `both=min`,
200-
`neither=product`, `(extends default-rml)`.
201-
- `kleene-three-valued` at `lib/self/foundations.lino:359-367`
202-
Strong Kleene over the real unit interval, same `and`/`or` shape.
203-
204-
A complete end-to-end example uses both inside one file:
205-
`examples/foundation-boolean-kleene.lino` (46 lines, replayed through
206-
both engines). A minimal sanity-check example is at
247+
- `boolean-links` — strict `{0,1}` Boolean logic with finite
248+
truth-table rows for `and`, `or`, and `not`. Activating this
249+
foundation records those operators as `links-defined`.
250+
- `boolean-classical` — two-valued logic, `and=min`, `or=max`,
251+
`both=min`, `neither=product`, `(extends default-rml)`. These are
252+
host aggregator bindings.
253+
- `kleene-three-valued` — Strong Kleene over the real unit interval,
254+
same `and`/`or` shape. These are also host aggregator bindings.
255+
256+
A complete end-to-end example uses all three profiles inside one file:
257+
`examples/foundation-boolean-kleene.lino` (replayed through both
258+
engines). A minimal sanity-check example is at
207259
`examples/foundation-with-min.lino` (16 lines). Both are picked up
208260
automatically by the shared-example replay
209261
(`rust/tests/shared_examples.rs`, `js/tests/shared-examples.test.mjs`).

0 commit comments

Comments
 (0)