Skip to content

Commit c9f9b24

Browse files
docs: separate precision suite roles and ForthWall safety (#72)
Corrects stale operational claims, renames the proposed bounded execution layer to ForthWall, and distinguishes DocMatrix conversion infrastructure, Formatrix Docs multi-format viewing/editing, and Blocky Writer fixed-layout PDF placement. It also gates each capability on separate evidence and links the ForthWall safety blocker #70 and optional-suite contract #71. --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent e689f7d commit c9f9b24

20 files changed

Lines changed: 610 additions & 319 deletions

‎Cargo.lock‎

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎README.adoc‎

Lines changed: 60 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,58 @@ This project must declare **MPL-2.0-or-later** for platform/tooling compatibilit
2020

2121
Philosophy: **Palimpsest**. The MPL-2.0 (PMPL) text is provided in `license/MPL-2.0.txt`, and the canonical source is the palimpsest-license repository.
2222

23-
Cross-platform document editor with format tabs (TXT/MD/ADOC/DJOT/ORG/RST/TYP). Gossamer GUI + Ada TUI. Graph visualization, OCR, TTS/STT, Nickel pipelines.
23+
DocMatrix is multi-format document conversion and precision infrastructure for
24+
the wider document suite. The tabbed multi-format viewer/editor is the separate
25+
*Formatrix Docs* project. GUI, TUI, graph, and editor claims in copied or
26+
ecosystem-level documents must not be attributed to DocMatrix itself.
27+
28+
ForthWall is a proposed capability-bounded Forth execution layer for critical
29+
precision operations. It is not currently implemented or proved.
2430

2531
== Features
2632

27-
* *Format Tabs* - View and edit the same document in multiple markup formats
28-
* *Unified AST* - Lossless conversion between formats
29-
* *GUI* - Gossamer with AffineScript frontend
30-
* *TUI* - Ada with AdaCurses for terminal usage
31-
* *Graph Visualization* - ArangoDB for document relationships
32-
* *Accessibility* - OCR, TTS, STT support
33-
* *Pipelines* - Nickel-based import/export transformations
33+
* *Current core* - Parse and render supported formats through a unified AST
34+
* *Current interfaces* - Rust conversion APIs plus a C ABI/FFI surface
35+
* *Suite boundary* - Formatrix Docs owns the tabbed viewer/editor experience
36+
* *Critical-mode proposal* - ForthWall rules bounded to declared inputs,
37+
approved document operations, and independently verified outputs
38+
39+
== Precision document suite
40+
41+
DocMatrix is designed to cooperate with two distinct user-facing tools:
42+
43+
* https://github.com/hyperpolymath/formatrix-docs[Formatrix Docs] — view one
44+
logical document through tabbed TXT, delimiter-selected tabular text,
45+
Markdown, AsciiDoc, Djot, and A2ML representations, with synchronised editing
46+
as the intended progression; and
47+
* https://github.com/hyperpolymath/blocky-writer[Blocky Writer] — fit content
48+
into fixed-layout PDF and application-form boxes, baselines, and
49+
per-character cells that were designed for hand spacing rather than reliable
50+
computer entry.
51+
52+
The responsibilities must remain separate in code and evidence. Conversion
53+
correctness does not prove synchronised editing, and synchronised editing does
54+
not prove page-coordinate placement. A ForthWall operation may coordinate a
55+
bounded critical step only after the relevant component's own semantic,
56+
round-trip, geometry, confinement, and independent-verification gates pass.
57+
The versioned composition contract is tracked in
58+
https://github.com/hyperpolymath/docmatrix/issues/71[issue #71]; it explicitly
59+
forbids making Microsoft Word or another lossy hub format mandatory.
60+
61+
== Conversion delivery gate
62+
63+
DocMatrix conversion claims require independently reproducible tests that
64+
round trips preserve every construct described as lossless, lossy conversions
65+
are reported, input and output formats are identified, and malformed or
66+
ambiguous documents fail without silent rewriting. Viewer/editor behaviours
67+
such as cursor mapping, synchronised tabs, and undo/redo belong to Formatrix
68+
Docs and must be proved there.
69+
70+
Critical-mode automatic editing through the proposed ForthWall layer has an
71+
additional safety gate: bounded capabilities, exact input hashes and evidence
72+
spans, semantic refusal conditions, replay traces, and independent verification
73+
of every applied edit. See
74+
https://github.com/hyperpolymath/docmatrix/issues/70[issue #70].
3475

3576
== Supported Formats
3677

@@ -57,15 +98,22 @@ just deps
5798
# Build all components
5899
just build
59100
60-
# Run GUI
61-
just run-gui
101+
# Exercise the currently evidenced conversion core
102+
just test-core
62103
63-
# Run TUI
64-
just run-tui
104+
# GUI and TUI recipes are ecosystem scaffolding, not DocMatrix capability proof
65105
----
66106

107+
`just test-core` covers core parsing, rendering, format identification, round
108+
trips, and no-panic handling. It is not the complete conversion delivery gate:
109+
the suite does not yet provide dedicated loss-reporting or end-to-end ambiguous
110+
format-identification rejection coverage.
111+
67112
== Architecture
68113

114+
The following tree is ecosystem/Formatrix Docs scaffolding retained in this
115+
checkout; it is not the DocMatrix suite boundary:
116+
69117
[source]
70118
----
71119
crates/

‎crates/formatrix-core/benches/format_bench.rs‎

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
// Copyright (c) Jonathan D.A. Jewell <j.d.a.jewell@open.ac.uk>
33
//! Benchmark tests for format conversion performance
44
5+
use criterion::{black_box, criterion_group, criterion_main, Criterion};
56
use formatrix_core::{
67
ast::{Block, Document, DocumentMeta, Inline, SourceFormat},
7-
traits::{Parser, ParseConfig, RenderConfig, Renderer},
88
formats::PlainTextHandler,
9+
traits::{ParseConfig, Parser, RenderConfig, Renderer},
910
};
10-
use criterion::{black_box, criterion_group, criterion_main, Criterion};
1111

1212
/// Benchmark plaintext parsing of small documents
1313
fn bench_parse_small_plaintext(c: &mut Criterion) {
@@ -26,7 +26,8 @@ fn bench_parse_medium_plaintext(c: &mut Criterion) {
2626
c.bench_function("parse_medium_plaintext_10kb", |b| {
2727
b.iter(|| {
2828
let parser = PlainTextHandler::new();
29-
let input = black_box(&"Lorem ipsum dolor sit amet.\n\n".repeat(500));
29+
let source = "Lorem ipsum dolor sit amet.\n\n".repeat(500);
30+
let input = black_box(source.as_str());
3031
let config = ParseConfig::default();
3132
parser.parse(input, &config)
3233
})
@@ -38,7 +39,8 @@ fn bench_parse_large_plaintext(c: &mut Criterion) {
3839
c.bench_function("parse_large_plaintext_100kb", |b| {
3940
b.iter(|| {
4041
let parser = PlainTextHandler::new();
41-
let input = black_box(&"Lorem ipsum dolor sit amet.\n\n".repeat(5000));
42+
let source = "Lorem ipsum dolor sit amet.\n\n".repeat(5000);
43+
let input = black_box(source.as_str());
4244
let config = ParseConfig::default();
4345
parser.parse(input, &config)
4446
})
@@ -51,14 +53,12 @@ fn bench_render_plaintext(c: &mut Criterion) {
5153
let doc = Document {
5254
source_format: SourceFormat::PlainText,
5355
meta: DocumentMeta::default(),
54-
content: vec![
55-
Block::Paragraph {
56-
content: vec![Inline::Text {
57-
content: "Test paragraph content.".to_string(),
58-
}],
59-
span: None,
60-
},
61-
],
56+
content: vec![Block::Paragraph {
57+
content: vec![Inline::Text {
58+
content: "Test paragraph content.".to_string(),
59+
}],
60+
span: None,
61+
}],
6262
raw_source: None,
6363
};
6464

@@ -93,8 +93,10 @@ fn bench_parse_with_source_preservation(c: &mut Criterion) {
9393
b.iter(|| {
9494
let parser = PlainTextHandler::new();
9595
let input = black_box("Test content with preservation.\n\nAnother paragraph.");
96-
let mut config = ParseConfig::default();
97-
config.preserve_raw_source = true;
96+
let config = ParseConfig {
97+
preserve_raw_source: true,
98+
..Default::default()
99+
};
98100

99101
parser.parse(input, &config)
100102
})
@@ -107,8 +109,10 @@ fn bench_parse_with_span_preservation(c: &mut Criterion) {
107109
b.iter(|| {
108110
let parser = PlainTextHandler::new();
109111
let input = black_box("Test content with spans.\n\nAnother paragraph.");
110-
let mut config = ParseConfig::default();
111-
config.preserve_spans = true;
112+
let config = ParseConfig {
113+
preserve_spans: true,
114+
..Default::default()
115+
};
112116

113117
parser.parse(input, &config)
114118
})
@@ -118,26 +122,22 @@ fn bench_parse_with_span_preservation(c: &mut Criterion) {
118122
/// Benchmark document creation
119123
fn bench_document_creation(c: &mut Criterion) {
120124
c.bench_function("create_document_with_metadata", |b| {
121-
b.iter(|| {
122-
Document {
123-
source_format: SourceFormat::PlainText,
124-
meta: DocumentMeta {
125-
title: Some("Test Title".to_string()),
126-
authors: vec!["Author".to_string()],
127-
date: Some("2026-04-04".to_string()),
128-
language: Some("en".to_string()),
129-
..Default::default()
130-
},
131-
content: vec![
132-
Block::Paragraph {
133-
content: vec![Inline::Text {
134-
content: black_box("Content".to_string()),
135-
}],
136-
span: None,
137-
},
138-
],
139-
raw_source: None,
140-
}
125+
b.iter(|| Document {
126+
source_format: SourceFormat::PlainText,
127+
meta: DocumentMeta {
128+
title: Some("Test Title".to_string()),
129+
authors: vec!["Author".to_string()],
130+
date: Some("2026-04-04".to_string()),
131+
language: Some("en".to_string()),
132+
..Default::default()
133+
},
134+
content: vec![Block::Paragraph {
135+
content: vec![Inline::Text {
136+
content: black_box("Content".to_string()),
137+
}],
138+
span: None,
139+
}],
140+
raw_source: None,
141141
})
142142
});
143143
}
@@ -150,7 +150,8 @@ fn bench_batch_parsing(c: &mut Criterion) {
150150
let config = ParseConfig::default();
151151

152152
for i in 0..10 {
153-
let input = black_box(&format!("Document {}.\n\nContent.", i));
153+
let source = format!("Document {}.\n\nContent.", i);
154+
let input = black_box(source.as_str());
154155
let _ = parser.parse(input, &config);
155156
}
156157
})

‎crates/formatrix-core/src/ast.rs‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -683,16 +683,18 @@ mod proptests {
683683
prop_assert!(format.extension() != format.label() || format.extension() == format.label().to_lowercase());
684684
}
685685

686-
// Property: Document word_count is non-negative
686+
// Property: Document word_count composes from its blocks
687687
#[test]
688-
fn prop_document_word_count_nonnegative(doc in document_strategy()) {
689-
prop_assert!(doc.word_count() >= 0);
688+
fn prop_document_word_count_composes(doc in document_strategy()) {
689+
let expected: usize = doc.content.iter().map(Block::word_count).sum();
690+
prop_assert_eq!(doc.word_count(), expected);
690691
}
691692

692-
// Property: Document char_count is non-negative
693+
// Property: Document char_count composes from its blocks
693694
#[test]
694-
fn prop_document_char_count_nonnegative(doc in document_strategy()) {
695-
prop_assert!(doc.char_count() >= 0);
695+
fn prop_document_char_count_composes(doc in document_strategy()) {
696+
let expected: usize = doc.content.iter().map(Block::char_count).sum();
697+
prop_assert_eq!(doc.char_count(), expected);
696698
}
697699

698700
// Property: Empty document has zero word count
@@ -742,7 +744,7 @@ mod proptests {
742744
span: None,
743745
};
744746
if let Block::Heading { level: l, .. } = block {
745-
prop_assert!(l >= 1 && l <= 6);
747+
prop_assert!((1..=6).contains(&l));
746748
}
747749
}
748750

‎crates/formatrix-core/src/formats/djot.rs‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ fn container_to_block(
280280

281281
Container::Div { class } => {
282282
// Check if it's an admonition
283-
let admonition = match class.as_ref() {
283+
let admonition = match class {
284284
"note" => Some(AdmonitionType::Note),
285285
"tip" => Some(AdmonitionType::Tip),
286286
"warning" => Some(AdmonitionType::Warning),
@@ -537,11 +537,11 @@ fn render_inline(output: &mut String, inline: &Inline) {
537537
}
538538

539539
Inline::Strong { content } => {
540-
output.push_str("*");
540+
output.push('*');
541541
for i in content {
542542
render_inline(output, i);
543543
}
544-
output.push_str("*");
544+
output.push('*');
545545
}
546546

547547
Inline::Strikethrough { content } => {
@@ -602,9 +602,9 @@ fn render_inline(output: &mut String, inline: &Inline) {
602602
}
603603

604604
Inline::RawInline { content, .. } => {
605-
output.push_str("`");
605+
output.push('`');
606606
output.push_str(content);
607-
output.push_str("`");
607+
output.push('`');
608608
}
609609

610610
_ => {}

‎crates/formatrix-core/src/formats/markdown.rs‎

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -159,29 +159,26 @@ fn parse_node<'a>(node: &'a AstNode<'a>) -> Option<Block> {
159159
let columns = Vec::new(); // Would need to extract from table alignments
160160

161161
for child in node.children() {
162-
match child.data.borrow().value {
163-
NodeValue::TableRow(is_header) => {
164-
let cells: Vec<TableCell> = child
165-
.children()
166-
.map(|cell| TableCell {
167-
content: vec![Block::Paragraph {
168-
content: parse_inlines(cell),
169-
span: None,
170-
}],
171-
colspan: 1,
172-
rowspan: 1,
173-
alignment: None,
174-
})
175-
.collect();
176-
177-
let row = TableRow { cells };
178-
if is_header {
179-
header = Some(row);
180-
} else {
181-
body.push(row);
182-
}
162+
if let NodeValue::TableRow(is_header) = child.data.borrow().value {
163+
let cells: Vec<TableCell> = child
164+
.children()
165+
.map(|cell| TableCell {
166+
content: vec![Block::Paragraph {
167+
content: parse_inlines(cell),
168+
span: None,
169+
}],
170+
colspan: 1,
171+
rowspan: 1,
172+
alignment: None,
173+
})
174+
.collect();
175+
176+
let row = TableRow { cells };
177+
if is_header {
178+
header = Some(row);
179+
} else {
180+
body.push(row);
183181
}
184-
_ => {}
185182
}
186183
}
187184

‎crates/formatrix-core/src/formats/orgmode.rs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ where
276276
use orgize::Event;
277277
let mut inlines = Vec::new();
278278

279-
while let Some(event) = events.next() {
279+
for event in events.by_ref() {
280280
match &event {
281281
Event::End(elem) if is_end_element(elem) => break,
282282
Event::Start(Element::Text { value }) | Event::End(Element::Text { value }) => {
@@ -480,7 +480,7 @@ where
480480
I: Iterator<Item = orgize::Event<'a, 'b>>,
481481
{
482482
use orgize::Event;
483-
while let Some(event) = events.next() {
483+
for event in events.by_ref() {
484484
if matches!(event, Event::End(Element::TableRow(_))) {
485485
break;
486486
}
@@ -531,11 +531,11 @@ where
531531
use orgize::Event;
532532
let mut text = String::new();
533533

534-
while let Some(event) = events.next() {
534+
for event in events.by_ref() {
535535
match event {
536536
Event::End(Element::TableCell(_)) => break,
537537
Event::Start(Element::Text { value }) | Event::End(Element::Text { value }) => {
538-
text.push_str(&value);
538+
text.push_str(value);
539539
}
540540
_ => {}
541541
}

0 commit comments

Comments
 (0)