|
1 | | -// SPDX-License-Identifier: PMPL-1.0-or-later |
| 1 | +// SPDX-License-Identifier: MPL-2.0 |
2 | 2 | = a2ml_ex — Show Me The Receipts |
3 | 3 | :toc: |
4 | 4 | :icons: font |
5 | 5 |
|
6 | 6 | The README makes claims. This file backs them up. |
7 | 7 |
|
8 | | -[quote, README] |
9 | | -____ |
10 | | -A2ML is a structured markup language with built-in attestation provenance, directive metadata, and trust-level tracking. This library provides a complete parser and renderer for A2ML documents in pure Elixir. |
11 | | -____ |
| 8 | +== Real Claims From The README |
| 9 | + |
| 10 | +**Claim 1: "Parse A2ML documents from strings or files… Render AST back to A2ML surface syntax (round-trip support)"** (README, Features section) |
| 11 | + |
| 12 | +The parser in `lib/a2ml/parser.ex` reads A2ML-formatted text and emits a typed AST via `A2ML.Parser.parse/1`, which returns `{:ok, Document.t()}` or `{:error, reason}`. The parser extracts: |
| 13 | + |
| 14 | +* Title from H1 heading (`# Title`) |
| 15 | +* Blocks (paragraphs, headings, code blocks, directives, attestations) |
| 16 | +* Directives starting with `@` (e.g., `@include(file="chapter1.a2ml")`) |
| 17 | +* Attestation provenances blocks starting with `!attest` |
| 18 | + |
| 19 | +The renderer in `lib/a2ml/renderer.ex` reconstructs the surface syntax from the AST via `A2ML.Renderer.render/1`, returning `{:ok, rendered_string}`. This enables round-trip: parse → modify AST → render produces valid A2ML again. |
| 20 | + |
| 21 | +*How it works:* The parser splits input by newlines, identifies block boundaries, and classifies each line. The `Attestation` struct stores identity, role, trust level, and timestamp. Directives are key-value pairs in `@name(key=val): value` syntax. The renderer walks the AST and reconstructs each element. Caveat: Whitespace normalization and comment stripping mean the rendered output may not be byte-for-byte identical to the input, though semantic content is preserved. |
| 22 | + |
| 23 | +**Claim 2: "Trust-level hierarchy: :unverified, :automated, :reviewed, :verified"** (README, Trust Levels section) |
| 24 | + |
| 25 | +The `A2ML.Types.TrustLevel` enum in `lib/a2ml/types.ex` defines a four-tier hierarchy. The parser extracts trust level from attestation blocks (`trust-level: verified`) and stores it on the `Attestation` struct. The types module enforces the hierarchy: `:unverified` < `:automated` < `:reviewed` < `:verified`. Document-wide trust is derived from the minimum trust level of all attestations. |
| 26 | + |
| 27 | +*How it works:* Attestation blocks declare `trust-level: <level>`. When rendering, the renderer includes the trust level in the output. Clients can filter documents by minimum trust requirement. Caveat: Trust levels are advisory metadata—the library does not cryptographically verify signatures. Signature verification (mentioned in the README's example) is a future feature; currently `signature:` field is stored as a string literal without validation. |
| 28 | + |
| 29 | +== Dogfooted Across The Account |
| 30 | + |
| 31 | +a2ml_ex is part of the A2ML ecosystem, which includes: |
| 32 | + |
| 33 | +* link:https://github.com/hyperpolymath/a2ml-deno[a2ml-deno] — Deno/ReScript implementation (primary) |
| 34 | +* link:https://github.com/hyperpolymath/tree-sitter-a2ml[tree-sitter-a2ml] — Tree-sitter grammar for syntax highlighting |
| 35 | +* link:https://github.com/hyperpolymath/a2ml-haskell[a2ml-haskell] — Haskell implementation |
| 36 | +* link:https://github.com/hyperpolymath/standards[standards] — A2ML spec (K9 service specification) |
| 37 | + |
| 38 | +The Elixir implementation enables A2ML parsing in BEAM-based systems (Elixir, Erlang). It follows the same type structure as the Deno version. |
12 | 39 |
|
13 | 40 | == Technology Choices |
14 | 41 |
|
15 | | -[cols="1,2"] |
| 42 | +[cols="1,2,3"] |
16 | 43 | |=== |
17 | | -| Technology | Learn More |
| 44 | +| Technology | Learn More | Why |
18 | 45 |
|
19 | | -| **Elixir** | https://elixir-lang.org |
| 46 | +| **Elixir** | https://elixir-lang.org | BEAM runtime, immutable data structures, pattern matching for AST |
| 47 | +| **ExUnit** | https://hexdocs.pm/ex_unit | Testing framework (no external test dependency) |
| 48 | +| **Hex.pm** | https://hex.pm | Package distribution (MPL-2.0 requirement for Hex ecosystem) |
20 | 49 | |=== |
21 | 50 |
|
22 | 51 | == File Map |
23 | 52 |
|
24 | | -[cols="1,2"] |
| 53 | +[cols="1,2,3"] |
25 | 54 | |=== |
26 | | -| Path | What's There |
| 55 | +| Path | What's There | Key Details |
27 | 56 |
|
28 | | -| `lib/` | Library code |
29 | | -| `test(s)/` | Test suite |
| 57 | +| `lib/a2ml/parser.ex` | A2ML text parser | Reads lines, extracts title, parses blocks, directives, attestations |
| 58 | +| `lib/a2ml/renderer.ex` | AST-to-text renderer | Reconstructs A2ML surface syntax from `Document` struct |
| 59 | +| `lib/a2ml/types.ex` | Type definitions | `Document`, `Block`, `Inline`, `Directive`, `Attestation`, `TrustLevel` structs |
| 60 | +| `lib/a2_ml.ex` | Public API | Re-exports parser and renderer functions |
| 61 | +| `test/a2ml_test.exs` | Parser tests | Round-trip tests, edge cases, error handling |
| 62 | +| `mix.exs` | Build configuration | Elixir version, Hex metadata, dependencies |
30 | 63 | |=== |
31 | 64 |
|
32 | 65 | == Questions? |
|
0 commit comments