Skip to content

MVP kernel: L2 grade algebras + L1 graded checker + anytype-specific seam (Phases 2-4)#12

Merged
hyperpolymath merged 6 commits into
mainfrom
feat/mvp-kernel-phases-2-4
Jul 21, 2026
Merged

MVP kernel: L2 grade algebras + L1 graded checker + anytype-specific seam (Phases 2-4)#12
hyperpolymath merged 6 commits into
mainfrom
feat/mvp-kernel-phases-2-4

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

What

Implements route-to-mvp Phases 2, 3 and 4 from STATE.a2ml — the repo's first actual kernel code — plus the honesty pass that keeps every doc inside what is built.

  • L2 (Phase 2): Anytype.Grade.Algebra — a GradeAlgebra record whose ordered-semiring laws are proof fields, so an unlawful algebra is unrepresentable. Instances: affine {0,1,ω} (mirrors AffineScript lib/quantity.ml cell-for-cell, incl. the ω·1=ω BUG-001 rule) and exact-usage .
  • L1 (Phase 3): usage-counting bidirectional checker for a simply-graded λ-calculus; the type-index language has no recursion constructor, so type-level computation is total by construction (syntactic totality gate, %default total, no believe_me/holes anywhere); conversion = normalise-and-compare at one site.
  • Seam (Phase 4, both halves): Abi.{Types,Layout,Foreign} rewritten from template demos to anytype's wire contract (codes proven injective; request/response layouts proven CABICompliant); anytype-check CLI with a total fuel-bounded S-expression reader; Zig 0.16 anytype_check export with comptime layout asserts. MVP transport: spawned process (stated in the ffi README).
  • Gates: just test (kernel build + 19-case golden matrix + 8 seam tests + zig build test), scripts/check-idris2-proofs.sh (manifest over every .idr; missing prover = FAIL; the 5 never-compiling template proof modules are quarantined and must keep failing), and .github/workflows/idris2-proof.yml — the first CI in this repo that checks any Idris2. The fake exit-0 build/just/proofs.just recipes are deleted.
  • Truth pass: README status table + WARNING, EXPLAINME, AFFIRMATION (still an unsigned draft), STATE.a2ml (10→40%, Phases 2-4 → 100), ANCHOR.a2ml systemet pin discharged with commit ba5930dc, PROOF-STATUS/ROADMAP de-templated, .tool-versions idris2 0.7.0 + zig 0.16.0, mise.toml purged of template runtime residue.

The headline demonstration

The same rules under two algebras (golden matrix + CLI tests):

echo '(lam 1 bool tt)' | anytype-check --discipline affine   # ACCEPT (drop ok: 0 <= 1)
echo '(lam 1 bool tt)' | anytype-check --discipline exact    # REJECT (0 /= 1)

Pick the algebra, get the discipline — now code, not prose.

Verification

  • just test: 19/19 golden cases + 8/8 seam cases + 4/4 zig tests — green locally (Idris2 0.7.0, Zig 0.16.0).
  • just proof-check-idris2: 16 gated modules pass, 5 quarantined still fail as recorded, all 21 .idr files accounted for.
  • Every gate was watched failing (prover off PATH, sabotaged law proof, flipped golden expectation, kernel binary removed) before being made green.

Out of scope (recorded in ROADMAP/STATE)

Branching (needs a grade join beyond systemet's stated laws), L3 recursion, L0 lowering, L4/TEA (open in systemet), in-process RefC linkage, checker soundness proof.

🤖 Generated with Claude Code

hyperpolymath and others added 6 commits July 21, 2026 07:04
The build/ tree held template guix/just scaffolding whose proof-check
recipes exit 0 when the prover is absent (the estate-wide fake-green
gate flaw). Real, hard-failing test and proof-check recipes land
directly in the Justfile and scripts/ in the following commits.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…1 graded checker

Phases 2-3 of route-to-mvp, no longer scaffolding:

- Anytype.Grade.Algebra: GradeAlgebra record whose semiring and order
  laws are proof fields -- an unlawful algebra is unrepresentable.
- Anytype.Grade.Affine: {0,1,omega} mirroring affinescript
  lib/quantity.ml cell-for-cell (1+1=omega saturation, omega*1=omega);
  all laws discharged by exhaustive enumeration, %default total,
  no believe_me/assert_total/holes anywhere.
- Anytype.Grade.Exact: exact-usage Nat instance (order = equality),
  the same-rules-distinct-disciplines demonstration systemet requires.
- Anytype.Core.*: bidirectional simply-graded lambda calculus with
  usage counting; TNat index language total by construction (the MVP
  L1 totality gate); conversion = normalise-and-compare at a single
  mode-switch site.
- Golden matrix (19 cases): affine accepts drop where exact rejects it;
  omega-arrow scaling rejection; TBits conversion accept/reject.
- scripts/check-idris2-proofs.sh: manifest-driven hard-fail proof gate
  (missing toolchain = FAIL; unlisted .idr = FAIL; quarantined template
  modules must keep failing). Adapted from ideas-to-alphas.
- Justfile: test / test-smoke / proof-check-idris2 are real commands,
  replacing the template echo placeholders.

All gates watched failing (toolchain absent, sabotaged proof, flipped
golden expectation) before being made green.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…pe-check CLI

Phase 4 (Idris half): replaces the RSR template's generic librsr demo
with anytype's actual seam:

- Abi.Types: Discipline/Verdict wire types; codes proven injective,
  decode proven inverse of encode.
- Abi.Layout: template's Divides/StructLayout machinery re-scoped to
  the real anytype_request_t / anytype_response_t layouts (16 bytes,
  align 8), both proven CABICompliant. abi.ipkg renamed anytype-abi.
- Abi.Foreign: seam contract for the Zig-exported anytype_check symbol;
  MVP transport is a spawned process (Zig binding pending).
- Anytype.Sexp (total S-expression reader, fuel-bounded, scope-checked
  de Bruijn) + Anytype.Main: the anytype-check executable. Exit codes
  are verdictCode values: 0 accept, 1 reject, 2 ill-formed.
- scripts/check-cli.sh: 8 seam golden tests (verdict line + exit code);
  wired into just test and CI alongside the proof sweep.
- Proof MANIFEST extended to the CLI modules (coverage rule caught them
  first, as designed).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…rts, round-trip tests

Replaces the un-instantiated {{project}} template. checkWith spawns the
anytype-check kernel binary and maps its exit code (= verdictCode) back
to the C return value; wire structs are comptime-asserted against the
layouts proven in Abi.Layout, so a drift on either side breaks a gate.
zig build test wired into just test and CI (toolchain checksum-pinned;
missing zig or missing kernel binary FAILS, never skips).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
… built kernel

- README: L1/L2 rows design->built (MVP); honesty WARNING rewritten to
  enumerate what is and is not built.
- EXPLAINME: current-state section describes the real kernel, gates and
  seam; per-section caveats updated from 'intended' to 'built (MVP)'.
- AFFIRMATION: what-we-do-NOT-claim updated (still an unsigned draft --
  signing requires the anchor checklist).
- STATE.a2ml: completion 10->40, phase design->implementation, Phases
  2/3/4 -> 100, new critical-next-actions (branching join, L3/L0,
  in-process seam, quarantined template proofs).
- ANCHOR.a2ml: systemet pin discharged with a concrete commit
  (ba5930dc478c80b1f968eea4ca28acd0f9d67966, 2026-07-18).
- PROOF-STATUS/ROADMAP: de-templated; MANIFEST is the source of truth.
- .tool-versions: idris2 0.7.0 + zig 0.16.0 active; mise.toml purged of
  template runtime residue (node/python/go/bun/npm etc).
- ffi README: seam contract + process-boundary transport stated.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The !/build/ negations existed for the old tracked build/ config
directory; after its removal they were re-including Idris2's compiled
artifacts (.so/.ss executables), which landed in the previous commits.
build/ is generated output only now.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
C Security Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

💡 Need a hand with PR review? Try Gitar by Sonar!

hyperpolymath added a commit to hyperpolymath/affinescript that referenced this pull request Jul 21, 2026
)

Resolves the long-standing `// TODO: link the SystemET / Anytype design
notes once they have stable locations.` at README.adoc:115.

Both locations are now stable — and as of hyperpolymath/anytype#12 the
kernel is real code, not prose: AffineScript's `{0,1,ω}` quantity
semiring (`lib/quantity.ml`) is one instantiation of anytype's L2
grade-algebra interface (its affine instance mirrors
`q_add`/`q_mul`/`q_le` cell-for-cell, verified by anytype's golden
matrix).

Docs-only change.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
@hyperpolymath
hyperpolymath marked this pull request as ready for review July 21, 2026 06:48
@hyperpolymath
hyperpolymath merged commit e32ae12 into main Jul 21, 2026
14 of 30 checks passed
@hyperpolymath
hyperpolymath deleted the feat/mvp-kernel-phases-2-4 branch July 21, 2026 06:48
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.

1 participant