Parity checklist: headless counts (RFC-0052) (#3291)

* parity: headless counts in the summary (RFC-0052)

* Add the Headless header cell to the parity rows table
This commit is contained in:
FredApps authored and GitHub committed 2026-11-27 23:32:05 +01:00
1 parent cc0dd6625e
commit d3fcb375c1
3 files changed
+76 -6

No files matched your search

+1
View File
@@ -80,4 +80,5 @@ Paths and conventions:
- Test corpora: `storytold/photocraft-corpus`, fetched pinned and sha256-verified.
- Progress log: `ROADMAP.md`. `plan/` is an optional gitignored notebook.
- Run with a control channel: `cargo run --release -p designcraft -- --sample --control 7979`. Methods are in `crates/ui-egui/src/control.rs`, the protocol in `docs/control-protocol.md`. Headless: `designcraft-cli run --sample --cmd 'frame.create={"rect":[0,0,100,100]}' --export out.png`; `--all-pages DIR` renders every page.
- Headless column ([RFC-0052](https://github.com/storytold/craft-contrib/blob/main/rfcs/0052-headless-reach.md)): `docs/parity-checklist.md` rows may carry a fifth `Headless` cell, `no (<reach>)` or `partial (<reach>)` with a reach of `window`, `os` or `engine-gap`; without one a row is `unknown`, and `cargo xtask parity` counts them in the summary. The rows name no command ids yet, so the check refuses `yes`: adding the engine command id a row needs comes first (LightCraft's `cmd:<id>` is the model).
- Docs: `ROADMAP.md`, `docs/gaps.md` (ranked work), `docs/target-app-parity.md`, `docs/roadmap.md`, `docs/agents.md`, `docs/contributors.md`.
+4 -2
View File
@@ -48,10 +48,12 @@ bound.
Open P0 items: Vector/page formats (PDF/AI/SVG/EPS place), Export to PDF (print).
**Headless ([RFC-0052](https://github.com/storytold/craft-contrib/blob/main/rfcs/0052-headless-reach.md)): 0 yes, 0 no (window 0, os 0, engine-gap 0), 0 partial, 277 unknown.** The rows name no command ids yet, so none can be `yes`. A row may add a fifth `Headless` cell, `no (<reach>)` or `partial (<reach>)` with a reach of `window`, `os` or `engine-gap`; a row without one is `unknown`.
## Rows
| Area | Feature | Priority | Status |
|---|---|---|---|
| Area | Feature | Priority | Status | Headless |
|---|---|---|---|---|
| Application shell & workspace | Start/Home screen | P0 | D |
| Application shell & workspace | Multiple documents in tabs | P0 | D |
| Application shell & workspace | New Window for same document | P1 | D |
+71 -4
View File
@@ -6,14 +6,21 @@ use std::path::Path;
const START: &str = "<!-- SUMMARY -->";
const ROWS: &str = "\n## Rows";
/// The cells of a table line that is a scored row: `Area | Feature | Priority | Status`, with an
/// optional fifth `Headless` cell (RFC-0052).
fn row_cells(l: &str) -> Option<Vec<&str>> {
let cells: Vec<&str> = l.trim().trim_matches('|').split('|').map(str::trim).collect();
let scored = matches!(cells.len(), 4 | 5) && matches!(cells[2], "P0" | "P1" | "P2") && matches!(cells[3], "D" | "P" | "M");
scored.then_some(cells)
}
/// (area, feature, priority 0–2, value 0 / 0.5 / 1) for each table row.
pub fn rows(text: &str) -> Vec<(String, String, u8, f64)> {
let mut out = Vec::new();
for l in text.lines() {
let cells: Vec<&str> = l.trim().trim_matches('|').split('|').map(str::trim).collect();
if cells.len() != 4 {
let Some(cells) = row_cells(l) else {
continue;
}
};
let pri = match cells[2] {
"P0" => 0,
"P1" => 1,
@@ -31,6 +38,53 @@ pub fn rows(text: &str) -> Vec<(String, String, u8, f64)> {
out
}
/// A row's RFC-0052 `headless:` cell: empty or `unknown`, `no (<reach>)` or `partial (<reach>)` with
/// a reach of `window`, `os` or `engine-gap`. The rows name no command ids, so nothing can check a
/// `yes`: it is refused until a row cites the engine command that does the feature.
pub fn headless_cell(cell: Option<&str>) -> Result<(&'static str, Option<&'static str>), String> {
let c = cell.unwrap_or("").trim();
if c.is_empty() || c == "unknown" {
return Ok(("unknown", None));
}
let (value, rest) = c.split_once(' ').unwrap_or((c, ""));
let value = match value {
"no" => "no",
"partial" => "partial",
"yes" => return Err(format!("headless `{c}`: a row is `yes` only once it names the engine command id that does it (RFC-0052)")),
_ => return Err(format!("headless `{c}` is not unknown, `no (<reach>)` or `partial (<reach>)`")),
};
let reach = match rest.trim().trim_start_matches('(').trim_end_matches(')') {
"window" => "window",
"os" => "os",
"engine-gap" => "engine-gap",
r => return Err(format!("headless `{c}`: reach `{r}` is not window, os or engine-gap")),
};
Ok((value, Some(reach)))
}
/// Every row's RFC-0052 value, or the first bad cell.
pub fn headless(text: &str) -> Result<Vec<(&'static str, Option<&'static str>)>, String> {
text.lines().filter_map(row_cells).map(|c| headless_cell(c.get(4).copied()).map_err(|e| format!("{}: {e}", c[1]))).collect()
}
/// The RFC-0052 summary line.
pub fn headless_line(values: &[(&str, Option<&str>)]) -> String {
let count = |v: &str| values.iter().filter(|h| h.0 == v).count();
let no = |r: &str| values.iter().filter(|h| h.0 == "no" && h.1 == Some(r)).count();
format!(
"**Headless ([RFC-0052](https://github.com/storytold/craft-contrib/blob/main/rfcs/0052-headless-reach.md)): {} yes, {} no (window {}, os {}, engine-gap {}), {} partial, {} unknown.** \
The rows name no command ids yet, so none can be `yes`. A row may add a fifth `Headless` cell, `no (<reach>)` or \
`partial (<reach>)` with a reach of `window`, `os` or `engine-gap`; a row without one is `unknown`.\n",
count("yes"),
count("no"),
no("window"),
no("os"),
no("engine-gap"),
count("partial"),
count("unknown")
)
}
fn weight(p: u8) -> f64 {
[3.0, 2.0, 1.0][p as usize]
}
@@ -75,7 +129,7 @@ pub fn run(root: &Path) -> Result<(), String> {
return Err("docs/parity-checklist.md needs a `<!-- SUMMARY -->` marker before `## Rows`".into());
};
let rows = rows(&text[b..]);
let s = summary(&rows);
let s = format!("{}\n{}", summary(&rows), headless_line(&headless(&text[b..])?));
let new = format!("{}{START}\n{s}{}", &text[..a], &text[b..]);
std::fs::write(&path, new).map_err(|e| e.to_string())?;
print!("{s}");
@@ -96,4 +150,17 @@ mod tests {
assert!(s.contains("**Weighted breadth parity: 67%**"), "{s}");
assert!(s.contains("Open P0 items: ."));
}
#[test]
fn headless_cells_default_to_unknown_and_refuse_yes() {
let t = "| A | x | P0 | D |\n| A | y | P1 | M | no (window) |\n| B | z | P2 | P | partial (engine-gap) |\n| B | w | P2 | D | unknown |\n";
let v = headless(t).unwrap_or_default();
assert_eq!(v, [("unknown", None), ("no", Some("window")), ("partial", Some("engine-gap")), ("unknown", None)]);
assert_eq!(rows(t).len(), 4, "a fifth cell keeps the row scored");
let line = headless_line(&v);
assert!(line.contains("0 yes, 1 no (window 1, os 0, engine-gap 0), 1 partial, 2 unknown"), "{line}");
for bad in ["yes", "yes (cmd:a.b)", "no", "no (desk)", "maybe (os)"] {
assert!(headless(&format!("| A | x | P0 | D | {bad} |\n")).is_err(), "{bad}");
}
}
}