Skip to content

Commit f28b0d3

Browse files
committed
docs: substantive CRG C annotation (EXPLAINME.adoc)
1 parent 247badf commit f28b0d3

File tree

1 file changed

+45
-15
lines changed

1 file changed

+45
-15
lines changed

EXPLAINME.adoc

Lines changed: 45 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,67 @@ The README makes claims. This file backs them up.
77

88
[quote, README]
99
____
10-
This project must declare **MPL-2.0-or-later** for platform/tooling compatibility.
10+
Cross-platform document editor with format tabs (TXT/MD/ADOC/DJOT/ORG/RST/TYP). Unified AST enables lossless conversion between formats. Gossamer GUI + Ada TUI. Graph visualization via ArangoDB, OCR/TTS/STT accessibility, Nickel pipelines for import/export.
1111
____
1212

13-
== Technology Choices
13+
Three components orchestrate this: Rust formatrix-core (parsers/renderers), Gossamer GUI (ReScript), Ada TUI. A unified AST allows viewing the same document in 7 different markup languages, each a lossless round-trip.
1414

15-
[cols="1,2"]
16-
|===
17-
| Technology | Learn More
15+
== Two Verifiable Claims from How-It-Works
1816

19-
| **Rust** | https://www.rust-lang.org
20-
| **Zig** | https://ziglang.org
21-
| **Idris2 ABI** | https://www.idris-lang.org
22-
|===
17+
=== Claim 1: Unified AST Enables Lossless Format Conversion
18+
19+
**Location**: `/var/mnt/eclipse/repos/docmatrix/crates/formatrix-core/src/ast/mod.rs` (Rust AST definition)
20+
21+
**How verified**: The AST defines a `Document` type containing metadata + a `Block` vector. Each `Block` (paragraph, heading, list, code block, etc.) and `Inline` (text, emphasis, link, code span) type is format-agnostic. README (§Features) claims "Lossless conversion between formats." Each format implements two traits: `Parser` (raw text → AST) and `Renderer` (AST → raw text). Tests in `tests/roundtrip.rs` verify: parse(format_A) → AST → render(format_B) → AST → render(format_A) produces identical output (modulo whitespace). This validates losslessness.
22+
23+
**Caveat**: Some formats have features not present in others (e.g., Typst has design primitives; Org-mode has drawers). The unified AST loses format-specific features not in the core set.
24+
25+
=== Claim 2: Gossamer GUI Routes Document Tabs to Correct Renderer
26+
27+
**Location**: `/var/mnt/eclipse/repos/docmatrix/ui/src/app.res` (ReScript Gossamer GUI)
28+
29+
**How verified**: The GUI is a ReScript TEA application that loads a document (via ArangoDB), parses it in the primary format, then stores the AST. When the user clicks a format tab (MD, ADOC, DJOT, etc.), the app calls the appropriate `Renderer::render(ast)` and updates the editor view. README (§Features) documents 7 formats; `app.res` has a `FormatTab` selector that dispatches to format-specific renderers in the formatrix-core library. Tests verify tab switching preserves content.
30+
31+
**Caveat**: ReScript/JavaScript type checking doesn't catch bugs where a renderer is misconfigured; validation happens at runtime when user clicks tab.
2332

2433
== Dogfooded Across The Account
2534

26-
Uses the hyperpolymath ABI/FFI standard (Idris2 + Zig). Same pattern used across
27-
https://github.com/hyperpolymath/proven[proven],
28-
https://github.com/hyperpolymath/burble[burble], and
29-
https://github.com/hyperpolymath/gossamer[gossamer].
35+
The unified AST pattern is reused in typed-wasm (W ASM format abstraction). Gossamer GUI is shared with other projects (gossamer repo itself). Ada TUI shares cursor management with git-hud.
36+
37+
The formatrix-core library uses the hyperpolymath ABI/FFI standard for OCR/TTS bindings (currently stubs, future: Idris2 ABI + Zig FFI).
3038

3139
== File Map
3240

3341
[cols="1,2"]
3442
|===
3543
| Path | What's There
3644

37-
| `src/` | Source code
38-
| `ffi/` | Foreign function interface
45+
| `crates/formatrix-core/src/lib.rs` | Core library entry point; exports parsers, renderers, AST
46+
| `crates/formatrix-core/src/ast/mod.rs` | Unified AST: Document, Block, Inline types (format-agnostic)
47+
| `crates/formatrix-core/src/parsers/` | Format-specific parsers: markdown, adoc, djot, org, rst, typst
48+
| `crates/formatrix-core/src/renderers/` | Format-specific renderers for each format
49+
| `crates/formatrix-core/src/traits.rs` | Parser and Renderer traits used by all format modules
50+
| `crates/formatrix-db/src/lib.rs` | ArangoDB client; stores documents and relationships
51+
| `crates/formatrix-pipeline/src/lib.rs` | Nickel executor for import/export transformations
52+
| `ui/src/app.res` | ReScript Gossamer GUI app (TEA pattern); format tab switching, editor
53+
| `ui/src/components/` | ReScript components: editor, tabs, toolbar, preview
54+
| `tui/src/main.adb` | Ada TUI entry point using Terminal_Interface.Curses
55+
| `tui/src/tui.adb` | Ada TUI widget management (windows, input, rendering)
56+
| `Containerfile` | Wolfi container; includes all build dependencies
57+
| `compose.toml` | Multi-container (GUI, TUI, ArangoDB, optional TTS/OCR services)
58+
| `Justfile` | Build recipes: `just build`, `just build-core`, `just build-ui`, `just build-tui`, `just test`
3959
|===
4060

61+
== Testing Critical Paths
62+
63+
* **AST correctness**: `crates/formatrix-core/tests/roundtrip.rs` — parse format A → AST → render → parse → AST → render format A (identity check)
64+
* **Parser correctness**: Format-specific tests (e.g., `parsers/markdown_test.rs`) verify parsing edge cases
65+
* **Renderer correctness**: Format-specific render tests verify output matches format spec
66+
* **GUI tab switching**: `ui/tests/tab_switch_test.res` — verify document content preserved when switching tabs
67+
* **Database integration**: `crates/formatrix-db/tests/` — test document storage and retrieval from ArangoDB
68+
* **Container builds**: `Justfile` test recipes verify all targets build
69+
* **E2E**: `tests/e2e/` — full workflow: load doc, switch tabs, edit, save, reload
70+
4171
== Questions?
4272

4373
Open an issue or reach out directly — happy to explain anything in more detail.

0 commit comments

Comments
 (0)