Skip to content

AMP v0.1.0 (draft): Algorithm Memento Protocol — substrate self-hosts its own production mechanism#544

Merged
TSavo merged 3 commits into
mainfrom
ts-amp-spec-draft
May 10, 2026
Merged

AMP v0.1.0 (draft): Algorithm Memento Protocol — substrate self-hosts its own production mechanism#544
TSavo merged 3 commits into
mainfrom
ts-amp-spec-draft

Conversation

@TSavo
Copy link
Copy Markdown
Owner

@TSavo TSavo commented May 10, 2026

Above all, correctness. The substrate's lifters have been the largest violation of the first axiom — same algorithm implemented independently across 5 language ports, no canonical reference. AMP makes algorithms content-addressed mementos and bindings verifiable refinement-claims. The substrate hosts its own production. See spec for the full design including formalized refinement relation, minting/discharge protocols, federation rule, worked example, relation to PPP/CCP/FRP/PEP. Design only — implementation comes after review. T Savo

Summary by CodeRabbit

  • Documentation
    • Added research paper explaining how ProofIR represents multiple programming languages through content-addressed algorithm representations and verifiable language bindings.
    • Added Algorithm Memento Protocol (AMP) v0.1.0 specification detailing algorithm representation, binding verification, and cross-language federation mechanisms.

Review Change Stack

The substrate's first axiom is Supra omnia, rectum. Until today, the
substrate's own lifters violated that axiom — the same algorithm
implemented independently in 5 language ports, no canonical reference,
no content-addressed identity, no mechanically-detectable drift.

AMP closes the gap. Algorithms become content-addressed mementos.
Language bindings become verifiable refinement-claims. Discharge
produces receipts. The substrate hosts its own production mechanism
under the same first axiom that governs its outputs.

This draft (v0.1.0) defines:
- Algorithm memento shape (FunctionContractMemento with conventions)
- Binding-claim memento shape (refines an algorithm via input_cids)
- Refinement relation (formalized in §2)
- Minting protocol (§3, §4)
- Discharge protocol (§5)
- Projection mementos per language (§6)
- Federation rule (§7) — same algorithm CID = same algorithm
- Lifecycle (§8) — refine / deprecate / version through PEP
- Worked example: TWO_ARMED_CONDITIONAL (§9)
- Relation to PPP, CCP, FRP, PEP (§10)
- Open questions deferred to future versions (§11)
- Out of scope (§12) — implementation, migration, ProofIR effect extensions

After AMP lands and is implemented, every contract emitted by every
lifter carries provenance to a content-addressed algorithm + binding +
discharge receipt. Drift detectable. Federation mechanical. The
substrate finally applies its first axiom to itself.

T Savo
Copilot AI review requested due to automatic review settings May 10, 2026 02:20
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 10, 2026

Warning

Rate limit exceeded

@TSavo has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 43 minutes and 36 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e3a6495a-5c9b-4de3-871e-52848b805c02

📥 Commits

Reviewing files that changed from the base of the PR and between da12673 and c68d789.

📒 Files selected for processing (3)
  • docs/papers/13-after-grammars-programming-languages-as-content-addressed-algebras.md
  • docs/papers/README.md
  • protocol/specs/2026-05-09-language-signature-protocol.md

Walkthrough

This pull request introduces the Algorithm Memento Protocol (AMP) v0.1.0 specification and a supporting theoretical paper establishing the correctness and design rationale for substrate self-application. The changes add two new foundational documents and update the paper index without modifying any code or public APIs.

Changes

Algorithm Memento Protocol and Self-Hosted Verification

Layer / File(s) Summary
Protocol Problem Statement
protocol/specs/2026-05-09-algorithm-memento-protocol.md
AMP problem statement: independent lifter implementations across languages lack canonical content-addressed identity and mechanical drift detection. Core concepts introduced: algorithm mementos, binding-claim mementos, refinement relations, discharge protocols, and federation rules.
Core Data Structures
protocol/specs/2026-05-09-algorithm-memento-protocol.md
Algorithm shape and memento as FunctionContractMemento with CID-derived identity; binding-claim memento structure; refinement criteria (pre coverage, post equality, effect compatibility); projection function role; algorithm catalog organization. Refinement obligation formalized using quantified logic.
Minting and Discharge Workflows
protocol/specs/2026-05-09-algorithm-memento-protocol.md
Minting procedures for algorithm and binding-claim mementos (CID computation, signing, catalog placement); discharge protocol via proof lowering and prove portfolio, producing proof-relevant signed receipts. Unattested bindings marked UNATTESTED as consumed-at-risk.
Projections, Federation, and Lifecycle
protocol/specs/2026-05-09-algorithm-memento-protocol.md
Per-language AST projection mementos and refinement role; federation rule for treating bindings sharing same algorithm CID as semantically equivalent when discharged; algorithm lifecycle (refinement chains, deprecation mementos, versioning under PEP).
Worked Example and Protocol Integration
protocol/specs/2026-05-09-algorithm-memento-protocol.md
Worked example for TWO_ARMED_CONDITIONAL showing algorithm memento structure, walk-c binding-claim with CID references, and multi-language federation. AMP relationship to PPP, CCP, FRP, and PEP defined.
Specification Boundaries
protocol/specs/2026-05-09-algorithm-memento-protocol.md
Explicit v0.1.0 unspecified items (canonical executable form, projection details, IR constructors, signing hierarchy, discharge automation) and out-of-scope areas (implementation, lifter migration, algebraic-effects extension).
Paper Problem Statement and Context
docs/papers/12-after-languages-how-proofir-represents-every-language.md
Paper thesis: substrate axiom Supra omnia, rectum must apply to its own production mechanism. Problem: independent per-language lifters lack canonical identity. Context within After-X prior work and PEP evolution. High-level mechanism overview of algorithm mementos, binding-claim mementos, and federation.
Theoretical Justification
docs/papers/12-after-languages-how-proofir-represents-every-language.md
Nine lemmas establishing: federation by CID, soundness preservation, drift detection, CID-vs-behavior distinction, lifter compositionality, language closure via projections, Cousot-equivalence lattice structure, algebraic-effects embedding, and substrate self-hosting with mechanically checkable receipts.
Counterargument Responses
docs/papers/12-after-languages-how-proofir-represents-every-language.md
Addresses counterarguments A–F: undecidable behavioral equivalence, discharge/prove-portfolio circularity, overhead replacement, verifier-verification concerns, catalog size, and language-addition friction.
Enabled Capabilities and Limitations
docs/papers/12-after-languages-how-proofir-represents-every-language.md
Outcomes: mechanical cross-language verification, single-point algorithm attestation, simultaneous rollout across ports, lifter provenance auditability. Limitations: canonical executable representation, algebraic-effects implementation, lifter migration strategy, signing hierarchies, hyperproperties.
Conclusion
docs/papers/12-after-languages-how-proofir-represents-every-language.md
Closing principle restates substrate self-application via content-addressed algorithm/binding-claim/discharge artifacts.
Documentation Index Update
docs/papers/README.md
Paper entry 12 added to index with thesis description and AMP v0.1.0 spec reference.

Poem

🐰 In substrate's heart, a truth took form—
Algorithms clad in CID as norm,
Each lifter's claim a signed receipt,
Federation makes the proof complete!
Self-hosted now, from axiom down,
Where rectum reigns—the substrate's crown. ✨


🎯 3 (Moderate) | ⏱️ ~22 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and clearly summarizes the main change: introducing the Algorithm Memento Protocol (AMP) v0.1.0 to enable the substrate to self-host its own production mechanism, which is the core objective of this PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ts-amp-spec-draft

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3fc4e8827b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +123 to +127
∀ (i : LangAST). B.pre(i) →
∃ (a : ASTPattern). P_lang.project(i) = Some(a)
∧ A.pre(a)
∧ B.post(i, ctx) = A.post(a, ctx)
```
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Quantify context in the refinement obligation

The formal refinement claim uses ctx without binding it (B.post(i, ctx) = A.post(a, ctx)), which makes the obligation an open formula rather than a closed theorem. Open formulas are not directly dischargeable as stated and can be interpreted inconsistently across backends, so implementations will either fail lowering/proving or silently assume an implicit scope that is not specified.

Useful? React with 👍 / 👎.

To mint a binding-claim `B` for algorithm `A` in language `L`:

1. Identify the binding code (the lifter's source files).
2. Compute `B.body_cid` as `BLAKE3-512` of the binding source code bytes (concatenated with file separators per a normalization rule TBD).
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Define deterministic body_cid normalization now

Step 2 makes B.body_cid mandatory for minting but leaves byte normalization as TBD, so different producers can hash different byte streams for identical binding code (file ordering, separators, newline normalization, path encoding). That breaks cross-port reproducibility and can invalidate attestation/federation because the same logical binding may receive different CIDs.

Useful? React with 👍 / 👎.

The substrate's first axiom Supra omnia, rectum binds the substrate's
outputs but has not until now bound the substrate's own production
mechanism. The lifter family is five-language reimplementations of
the same algorithms with no canonical reference, no content-addressed
identity for the algorithm itself, no mechanically-detectable drift.

This paper extends the After-X arc one level inward: the substrate
applies its first axiom to itself. Algorithms become content-addressed
mementos. Language ports become verifiable refinement-claims. Discharge
produces signed receipts. Federation across languages is by algorithm
CID, mechanically.

Contains nine lemmas with constructive proofs or proof sketches:
  L1 Federation by CID
  L2 Soundness Preservation
  L3 Drift Detection
  L4 Algorithm Identity is Syntactic, not Behavioral
  L5 Compositional Lifters
  L6 Language Closure
  L7 Cousot Equivalence (catalog = reduced product of abstract domains)
  L8 Algebraic Effects Embedding
  L9 Substrate Self-Hosting

Engages six counterarguments (decidability, circularity, port resistance,
foundational regress, catalog explosion, projection-memento friction).

Companion to AMP v0.1.0 spec (PR #544).

T Savo
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/papers/12-after-languages-how-proofir-represents-every-language.md`:
- Line 11: The phrase "five Python ports, five Rust ports, five C ports" in the
opening paragraph is inconsistent with the rest of the paper which asserts five
total language ports; replace that sequence with wording that matches the
intended meaning (e.g., "five language ports" or list the five languages once).
Locate the sentence beginning "**What this paper argues.**" and update the
fragment "five Python ports, five Rust ports, five C ports of the same
algorithm" to a corrected form such as "five language ports of the same
algorithm" (or an explicit single list of the five languages) so the port-count
matches the paper's narrative and removes the copy error.

In `@protocol/specs/2026-05-09-algorithm-memento-protocol.md`:
- Around line 84-85: The spec currently has two conflicting normative
requirements: "input_cids must include the algorithm being bound" and a separate
mandatory requirement for P_lang.cid during minting; unify these into one rule
by making "input_cids MUST include the algorithm CID" the single normative
requirement and update the minting rules to derive/validate P_lang.cid from
input_cids (or mark P_lang.cid optional/derived), ensuring both references
(input_cids and P_lang.cid in minting) state the same requirement and include a
brief sentence describing how emitters should validate the algorithm CID against
input_cids to avoid incompatible emitters.
- Around line 33-35: Update the markdown fenced code blocks to include
appropriate language identifiers (e.g., ```text or ```json) to satisfy MD040;
specifically add language tags to the blocks containing "A : ASTPattern ×
Context → IrFormula", the AlgorithmMemento and BindingClaimMemento sections
(AlgorithmMemento ⊆ FunctionContractMemento and BindingClaimMemento ⊆
FunctionContractMemento), the AlgorithmCatalog JSON block, the formal/assertion
blocks referencing "∀ (i : LangAST). B.pre(i) →" and "B.post = forall
i:LangAST.", and the ASTProjectionMemento block so each fenced block has the
correct language hint (use ```text for math/notation and ```json for
AlgorithmCatalog).
- Around line 123-127: The formula uses ctx without binding; fix by quantifying
ctx and making the postcondition a forall over contexts (e.g. add "∀ (ctx :
CtxType)." so the clause becomes ∀ (i : LangAST). B.pre(i) → ∃ (a : ASTPattern).
P_lang.project(i) = Some(a) ∧ A.pre(a) ∧ ∀ (ctx : CtxType). B.post(i, ctx) =
A.post(a, ctx); apply the same change to the analogous formula at lines 132-137
and ensure the same CtxType (or explicit context sort) is used consistently for
B.post and A.post.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d3c9aec4-eefc-439f-81c8-90389e2d7a18

📥 Commits

Reviewing files that changed from the base of the PR and between f2960eb and da12673.

📒 Files selected for processing (3)
  • docs/papers/12-after-languages-how-proofir-represents-every-language.md
  • docs/papers/README.md
  • protocol/specs/2026-05-09-algorithm-memento-protocol.md

>
> **Premise the earlier papers established.** A content-addressed federated substrate of canonical predicates, with signed implication edges, witnesses from a portfolio of solvers, droppers that close the loop with lifters, and a federation that asymptotically reduces verification cost to cache lookup. After Verification argued that this substrate makes leaf-discharge bug classes structurally impossible. After Types argued that invariants replace logging as the primary epistemic instrument.
>
> **What this paper argues.** That the substrate's first axiom — *Supra omnia, rectum*, above all correctness — has been load-bearing for substrate output but has not yet been applied to the substrate's own production mechanism. The lifters that emit substrate output have themselves been per-language reimplementations: five Python ports, five Rust ports, five C ports of the same algorithm, no canonical reference, no content-addressed identity for the algorithm itself, no mechanically-detectable drift. We close the gap. Algorithms become content-addressed mementos; language-specific lifters become verifiable refinement-claims; the substrate hosts its own production. We prove federation, drift detection, soundness preservation, and Cousot equivalence as nine lemmas. The substrate finally applies its first axiom to itself.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Port-count wording appears incorrect/inconsistent.

“five Python ports, five Rust ports, five C ports” conflicts with the rest of the paper/spec narrative (five total language ports). This reads like a copy error and should be corrected for clarity.

Proposed text fix
-... per-language reimplementations: five Python ports, five Rust ports, five C ports of the same algorithm ...
+... per-language reimplementations: one Python port, one Rust port, one C port, one Java port, and one Zig port of the same algorithm ...
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
> **What this paper argues.** That the substrate's first axiom — *Supra omnia, rectum*, above all correctness — has been load-bearing for substrate output but has not yet been applied to the substrate's own production mechanism. The lifters that emit substrate output have themselves been per-language reimplementations: five Python ports, five Rust ports, five C ports of the same algorithm, no canonical reference, no content-addressed identity for the algorithm itself, no mechanically-detectable drift. We close the gap. Algorithms become content-addressed mementos; language-specific lifters become verifiable refinement-claims; the substrate hosts its own production. We prove federation, drift detection, soundness preservation, and Cousot equivalence as nine lemmas. The substrate finally applies its first axiom to itself.
> **What this paper argues.** That the substrate's first axiom — *Supra omnia, rectum*, above all correctness — has been load-bearing for substrate output but has not yet been applied to the substrate's own production mechanism. The lifters that emit substrate output have themselves been per-language reimplementations: one Python port, one Rust port, one C port, one Java port, and one Zig port of the same algorithm, no canonical reference, no content-addressed identity for the algorithm itself, no mechanically-detectable drift. We close the gap. Algorithms become content-addressed mementos; language-specific lifters become verifiable refinement-claims; the substrate hosts its own production. We prove federation, drift detection, soundness preservation, and Cousot equivalence as nine lemmas. The substrate finally applies its first axiom to itself.
🧰 Tools
🪛 LanguageTool

[style] ~11-~11: To make your text as clear as possible to all readers, do not use this foreign term. Possible alternatives are “above”, “above-mentioned”, “aforementioned”, or “as previously mentioned” (in the document).
Context: ....** That the substrate's first axiom — Supra omnia, rectum, above all correctness —...

(SUPRA)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/papers/12-after-languages-how-proofir-represents-every-language.md` at
line 11, The phrase "five Python ports, five Rust ports, five C ports" in the
opening paragraph is inconsistent with the rest of the paper which asserts five
total language ports; replace that sequence with wording that matches the
intended meaning (e.g., "five language ports" or list the five languages once).
Locate the sentence beginning "**What this paper argues.**" and update the
fragment "five Python ports, five Rust ports, five C ports of the same
algorithm" to a corrected form such as "five language ports of the same
algorithm" (or an explicit single list of the five languages) so the port-count
matches the paper's narrative and removes the copy error.

Comment on lines +33 to +35
```
A : ASTPattern × Context → IrFormula
```
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Add language identifiers to fenced code blocks (MD040).

Several fenced blocks are missing a language tag, which is triggering markdownlint and reduces render/tooling quality.

Proposed spec fix
-```
+```text
 A : ASTPattern × Context → IrFormula

- +text
AlgorithmMemento ⊆ FunctionContractMemento where:
...


-```
+```text
BindingClaimMemento ⊆ FunctionContractMemento where:
...

- +json
AlgorithmCatalog := {
...
}


-```
+```text
∀ (i : LangAST). B.pre(i) →
...

- +text
B.post = forall i:LangAST.
...


-```
+```text
ASTProjectionMemento {
...
}

Also applies to: 51-63, 71-85, 103-109, 122-127, 131-137, 183-191

🧰 Tools
🪛 markdownlint-cli2 (0.22.1)

[warning] 33-33: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@protocol/specs/2026-05-09-algorithm-memento-protocol.md` around lines 33 -
35, Update the markdown fenced code blocks to include appropriate language
identifiers (e.g., ```text or ```json) to satisfy MD040; specifically add
language tags to the blocks containing "A : ASTPattern × Context → IrFormula",
the AlgorithmMemento and BindingClaimMemento sections (AlgorithmMemento ⊆
FunctionContractMemento and BindingClaimMemento ⊆ FunctionContractMemento), the
AlgorithmCatalog JSON block, the formal/assertion blocks referencing "∀ (i :
LangAST). B.pre(i) →" and "B.post = forall i:LangAST.", and the
ASTProjectionMemento block so each fenced block has the correct language hint
(use ```text for math/notation and ```json for AlgorithmCatalog).

Comment on lines +84 to +85
- input_cids : [<algorithm_cid>] — must include the algorithm being bound
```
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

input_cids requirements are internally inconsistent.

Line 84-85 says input_cids “must include the algorithm being bound,” while Line 163-164 makes P_lang.cid mandatory in minting. This should be one normative rule to avoid incompatible emitters.

Proposed spec fix
-  - input_cids        : [<algorithm_cid>] — must include the algorithm being bound
+  - input_cids        : [<algorithm_cid>, <projection_memento_cid>] — must include both the bound algorithm CID and the language projection CID

Also applies to: 163-164

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@protocol/specs/2026-05-09-algorithm-memento-protocol.md` around lines 84 -
85, The spec currently has two conflicting normative requirements: "input_cids
must include the algorithm being bound" and a separate mandatory requirement for
P_lang.cid during minting; unify these into one rule by making "input_cids MUST
include the algorithm CID" the single normative requirement and update the
minting rules to derive/validate P_lang.cid from input_cids (or mark P_lang.cid
optional/derived), ensuring both references (input_cids and P_lang.cid in
minting) state the same requirement and include a brief sentence describing how
emitters should validate the algorithm CID against input_cids to avoid
incompatible emitters.

Comment on lines +123 to +127
∀ (i : LangAST). B.pre(i) →
∃ (a : ASTPattern). P_lang.project(i) = Some(a)
∧ A.pre(a)
∧ B.post(i, ctx) = A.post(a, ctx)
```
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

ctx is free/unbound in the formal refinement formula.

The obligation quantifies i and a, but ctx is used without binding, making the formula formally ill-typed/ambiguous for implementation.

Proposed spec fix
-∀ (i : LangAST). B.pre(i) →
-  ∃ (a : ASTPattern). P_lang.project(i) = Some(a)
-                    ∧ A.pre(a)
-                    ∧ B.post(i, ctx) = A.post(a, ctx)
+∀ (i : LangAST, ctx : Context). B.pre(i) →
+  ∃ (a : ASTPattern). P_lang.project(i) = Some(a)
+                    ∧ A.pre(a)
+                    ∧ B.post(i, ctx) = A.post(a, ctx)
-B.post = forall i:LangAST.
+B.post = forall i:LangAST, ctx:Context.
            B.pre(i) → ∃ a:ASTPattern.
              P_lang.project(i) = Some(a)
              ∧ A.pre(a)
              ∧ B(i, ctx) = A(a, ctx)

Also applies to: 132-137

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@protocol/specs/2026-05-09-algorithm-memento-protocol.md` around lines 123 -
127, The formula uses ctx without binding; fix by quantifying ctx and making the
postcondition a forall over contexts (e.g. add "∀ (ctx : CtxType)." so the
clause becomes ∀ (i : LangAST). B.pre(i) → ∃ (a : ASTPattern). P_lang.project(i)
= Some(a) ∧ A.pre(a) ∧ ∀ (ctx : CtxType). B.post(i, ctx) = A.post(a, ctx); apply
the same change to the analogous formula at lines 132-137 and ensure the same
CtxType (or explicit context sort) is used consistently for B.post and A.post.

Paper 13: After Grammars: Programming Languages as Content-Addressed
Algebras. Extends paper 12 one level inward — not just algorithms
become content-addressed mementos, but the LANGUAGES themselves do.
Universal algebra and category theory established the math; this
paper makes the algebras content-addressed and federated.

Nine lemmas:
  L1 Signature CID Identity
  L2 Morphism Composition
  L3 Initial-Algebra Universality
  L4 Cross-Language Soundness via Homomorphism
  L5 Compilation Correctness as Homomorphism Discharge
  L6 Effect Signatures as Embedded Lawvere Theories
  L7 Equational Reasoning via Catalog Equations
  L8 Substrate Completeness for Algebraic Languages
  L9 Language Design as Algebra Construction

Six counterarguments engaged.

Companion spec LSP v0.1.0 (Language Signature Protocol):
- SortMemento, EquationMemento, LanguageSignatureMemento,
  LanguageMorphismMemento wire shapes
- Homomorphism obligation formalized
- Catalog placement at protocol/language-catalog/
- Bootstrap path through v0.5.0 to mint signatures + morphisms
  for the existing ProvekIt language family

After LSP lands, the substrate becomes the federation of programming
language theory. Cross-language verification = morphism composition.
Compiler correctness = morphism discharge receipt. Polyglot reasoning
= graph traversal over the content-addressed catalog.

The substrate's first axiom finally applies to the LANGUAGES it
reasons about, not just to the contracts written in them.

T Savo
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@TSavo TSavo merged commit 8f77563 into main May 10, 2026
8 of 9 checks passed
TSavo added a commit that referenced this pull request May 10, 2026
…ix input_cids, MD040, paper-12 port count

Applies the still-valid AMP/LSP spec review nits from PR #544:
- Bind `ctx` in the §2 refinement obligation (both the prose form and the
  IrFormula encoding): the formula now quantifies `(i : LangAST) (ctx :
  Context)` so it is a closed theorem, not an open formula that backends
  interpret inconsistently.
- Define a deterministic `B.body_cid` normalization rule in §4 (was TBD):
  BLAKE3-512(JCS({ "files": <sorted-by-path array of { path: repo-relative
  POSIX path NFC-normalized, content_cid: BLAKE3-512 of the file bytes } }))
  -- order-independent, separator-free, byte-reproducible across producers.
  §1.3's body_cid field now points at the §4 rule.
- Make the `input_cids` rule consistent: §1.3 now matches §4 step 5 --
  [<algorithm_cid>, <projection_memento_cid>], must include both the bound
  algorithm CID and the language projection (P_lang) CID.
- Tag the bare fenced code blocks in the AMP spec with a language id
  (markdownlint MD040).
- Paper 12: fix the copy-error port count ("five Python ports, five Rust
  ports, five C ports") to "one Python port, one Rust port, one C port, one
  Java port, and one Zig port" (five total ports, one per language).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
TSavo added a commit that referenced this pull request May 10, 2026
spec(amp): address #544 review nits - bind ctx, normalize body_cid, fix input_cids, MD040, paper-12 port count
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.

2 participants