Add the RFC-0052 headless column to the parity checklist

This commit is contained in:
FredApps committed 2026-11-28 05:11:15 +07:00
1 parent 3c6df90fe5
commit f9adc25d85
4 files changed
+154 -3

No files matched your search

+1 -1
View File
@@ -67,7 +67,7 @@ FigCraft is an open-source, pure-Rust (egui) design app (Figma-class): interface
### Layout
- `crates/*` by layer, enforced by `cargo xtask layers`: geom and color (L0), doc (L1), layout, text, pathops, plugin, collab (L2), render and format (L3), svg, pdf and vectordrawable (L4), engine (L5), ui-egui, mcp and collab-net (L6), then `apps/`. Nothing below L6 depends on egui, eframe, rfd or winit, so the UI crate is swappable.
- Commands live in `crates/engine/src/cmd/*` (`spec!(id, label, params doc, undoable, run)`). Menus, shortcuts, the Actions palette, CLI, control channel and MCP dispatch the same ids. The menu catalog is `crates/engine/src/catalog.rs` (`cargo xtask parity`). A programmatic call only requests UI (`Session::request_ui`); the control channel drops dialog requests.
- Commands live in `crates/engine/src/cmd/*` (`spec!(id, label, params doc, undoable, run)`). Menus, shortcuts, the Actions palette, CLI, control channel and MCP dispatch the same ids. The menu catalog is `crates/engine/src/catalog.rs` (`cargo xtask parity`). Its headless column ([RFC-0052](https://github.com/storytold/craft-contrib/blob/main/rfcs/0052-headless-reach.md)) is computed: an item is `headless: yes` only when its id is in the engine registry (`find_command`), never through a UI-layer id. A counted item with no engine command gets a `no`/`partial` mark with a `window`, `os` or `engine-gap` reach in `HEADLESS` in the same file, or shows as `unknown`. Never write `yes` there, and drop the mark when the command lands (stale marks fail the tests). A programmatic call only requests UI (`Session::request_ui`); the control channel drops dialog requests.
- Panels read engine state and act through `app.run(id, params)` or `app.set_props(ids, props)`. Colours come from `theme::Tokens`.
- Progress docs: `ROADMAP.md`, `docs/gaps.md` (ranked work list), `docs/target-app-parity.md`, `docs/roadmap.md`, `docs/architecture.md`, the `docs/*-parity.md` files and the generated `docs/parity-checklist.md`. A PR that lands a task updates the rows it touches.
- Releases: `docs/releasing.md`. Control protocol: `docs/control-protocol.md`. MCP: `docs/mcp.md`.
+116
View File
@@ -324,3 +324,119 @@ pub fn parity(extra: &[&str]) -> (usize, usize, Vec<&'static str>) {
pub fn shortcut(id: &str) -> Option<&'static str> {
crate::keymap::primary(id, crate::keymap::Platform::current())
}
/// RFC-0052 hand marks for counted catalog ids that aren't in the engine registry:
/// `(id, headless, reach, why)`.
///
/// `headless` is `no` or `partial`; `reach` is `window` (needs a desktop window, dialog or pointer),
/// `os` (needs an OS service the engine doesn't wrap) or `engine-gap` (could be an engine command,
/// isn't one yet). `yes` is never written here: an id is `yes` only when [`crate::find_command`] has
/// it, the registry `figcraft-cli` and the MCP server load. The UI-layer ids that `cargo xtask parity`
/// passes as `extra` light up a menu item but are not `yes`. An unmarked id is `unknown`.
pub const HEADLESS: &[(&str, &str, &str, &str)] = &[
("edit.copyAsSvg", "partial", "os", "`file.exportSvg` writes the same SVG to a file; the clipboard is the OS's"),
("edit.copyAsPng", "partial", "os", "`file.export` writes the PNG to a file; the clipboard is the OS's"),
("edit.copyAsCss", "no", "engine-gap", "the CSS comes from the engine's codegen, which no command exposes yet"),
("edit.copyAsText", "no", "os", "puts the selected layers' text on the OS clipboard"),
("edit.copyLink", "no", "os", "puts a `figcraft://` link on the OS clipboard"),
];
/// One counted catalog item's RFC-0052 value.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct HeadlessRow {
pub id: &'static str,
pub label: &'static str,
pub value: &'static str,
pub reach: Option<&'static str>,
pub why: &'static str,
}
/// The `headless:` value of `id`: `yes` when `in_engine`, else its mark, else `unknown`.
pub fn headless_of(
id: &str,
in_engine: bool,
marks: &[(&'static str, &'static str, &'static str, &'static str)],
) -> (&'static str, Option<&'static str>, &'static str) {
if in_engine {
return ("yes", None, "");
}
marks.iter().find(|m| m.0 == id).map_or(("unknown", None, ""), |m| (m.1, Some(m.2), m.3))
}
/// Every item [`parity`] counts, with its `headless:` value from the engine registry and [`HEADLESS`].
pub fn headless_rows() -> Vec<HeadlessRow> {
items()
.filter(|m| !m.id.starts_with("collab.") && !OWN.contains(&m.id))
.map(|m| {
let (value, reach, why) = headless_of(m.id, crate::find_command(m.id).is_some(), HEADLESS);
HeadlessRow { id: m.id, label: m.label, value, reach, why }
})
.collect()
}
/// Problems with `marks` against `ids` (`(id, in engine registry)`): bad values, repeats, ids not
/// counted by [`parity`], and marks on registry ids (they would hide a `yes`).
pub fn headless_errors(marks: &[(&str, &str, &str, &str)], ids: &[(&str, bool)]) -> Vec<String> {
let mut errs = Vec::new();
for (i, (id, value, reach, _)) in marks.iter().enumerate() {
if !matches!(*value, "no" | "partial") {
errs.push(format!("headless mark `{id}`: `{value}` is not `no` or `partial` (`yes` comes from the registry)"));
}
if !matches!(*reach, "window" | "os" | "engine-gap") {
errs.push(format!("headless mark `{id}`: reach `{reach}` is not window, os or engine-gap"));
}
if marks[..i].iter().any(|m| m.0 == *id) {
errs.push(format!("headless mark `{id}` is written twice"));
}
match ids.iter().find(|x| x.0 == *id) {
None => errs.push(format!("headless mark `{id}` is not a counted catalog id")),
Some((_, true)) => errs.push(format!("headless mark `{id}` is stale: the engine registry has it, so it is `yes`")),
Some(_) => {}
}
}
errs
}
/// The RFC-0052 summary of `rows`: (yes, no by window/os/engine-gap, partial, unknown).
pub fn headless_counts(rows: &[HeadlessRow]) -> (usize, [usize; 3], usize, usize) {
let count = |v: &str| rows.iter().filter(|r| r.value == v).count();
let no = |r: &str| rows.iter().filter(|x| x.value == "no" && x.reach == Some(r)).count();
(count("yes"), [no("window"), no("os"), no("engine-gap")], count("partial"), count("unknown"))
}
#[cfg(test)]
mod headless_tests {
use super::*;
#[test]
fn checked_in_marks_are_current() {
let ids: Vec<(&str, bool)> = headless_rows().iter().map(|r| (r.id, r.value == "yes")).collect();
let errs = headless_errors(HEADLESS, &ids);
assert!(errs.is_empty(), "{errs:?}");
}
#[test]
fn yes_is_the_engine_registry_not_the_ui_layer() {
let rows = headless_rows();
let (done, total, _) = parity(&[]);
assert_eq!(rows.len(), total, "one row per counted item");
let (yes, no, partial, unknown) = headless_counts(&rows);
assert_eq!(yes, done, "yes is what the engine registry implements, without the UI-layer extras");
assert_eq!(yes + no.iter().sum::<usize>() + partial + unknown, total);
assert!(rows.iter().filter(|r| r.value == "yes").all(|r| crate::find_command(r.id).is_some()));
}
#[test]
fn bad_marks_are_refused_and_live_ids_stay_yes() {
let ids = [("a.b", true), ("c.d", false)];
let marks = [("c.d", "yes", "os", ""), ("c.d", "no", "desk", ""), ("a.b", "no", "os", ""), ("z.z", "no", "os", "")];
let errs = headless_errors(&marks, &ids);
for want in ["is not `no` or `partial`", "reach `desk`", "written twice", "`a.b` is stale", "`z.z` is not a counted"] {
assert!(errs.iter().any(|e| e.contains(want)), "{want}: {errs:?}");
}
let ok = [("c.d", "no", "window", "a dialog")];
assert_eq!(headless_of("a.b", true, &ok).0, "yes");
assert_eq!(headless_of("c.d", false, &ok), ("no", Some("window"), "a dialog"));
assert_eq!(headless_of("q.q", false, &ok).0, "unknown");
}
}
+14 -2
View File
@@ -1,11 +1,23 @@
# Parity checklist
> **Generated:** 2026-11-25 by `cargo xtask parity`. Do not edit by hand.
> **Generated:** 2026-11-28 by `cargo xtask parity`. Do not edit by hand.
FigCraft commands registered for the incumbent's main menu and toolbar (652 commands in the engine).
FigCraft commands registered for the incumbent's main menu and toolbar (667 commands in the engine).
**215 / 215 menu items (100.0%)**
Every catalog item has a command.
## Headless
**Headless ([RFC-0052](https://github.com/storytold/craft-contrib/blob/main/rfcs/0052-headless-reach.md)): 210 yes, 3 no (window 0, os 2, engine-gap 1), 2 partial, 0 unknown.**
An item is `headless: yes` when its id is in the engine registry that `figcraft-cli` and the MCP server load. The UI-layer ids that light up a menu item above don't count. Other values are the hand marks in `HEADLESS` (`crates/engine/src/catalog.rs`), or `unknown`.
- `edit.copyAsText` Copy as text: headless: no, reach: os (puts the selected layers' text on the OS clipboard)
- `edit.copyAsCss` Copy as CSS: headless: no, reach: engine-gap (the CSS comes from the engine's codegen, which no command exposes yet)
- `edit.copyAsSvg` Copy as SVG: headless: partial, reach: os (`file.exportSvg` writes the same SVG to a file; the clipboard is the OS's)
- `edit.copyAsPng` Copy as PNG: headless: partial, reach: os (`file.export` writes the PNG to a file; the clipboard is the OS's)
- `edit.copyLink` Copy link to selection: headless: no, reach: os (puts a `figcraft://` link on the OS clipboard)
Menu coverage measures breadth only; see docs/target-app-parity.md for depth and fidelity.
+23
View File
@@ -256,6 +256,29 @@ fn parity() -> bool {
md.push_str(&format!("- `{m}`\n"));
}
}
let rows = figcraft_engine::catalog::headless_rows();
let ids: Vec<(&str, bool)> = rows.iter().map(|r| (r.id, r.value == "yes")).collect();
let errs = figcraft_engine::catalog::headless_errors(figcraft_engine::catalog::HEADLESS, &ids);
if !errs.is_empty() {
eprintln!("parity: RFC-0052 headless marks in crates/engine/src/catalog.rs:\n {}", errs.join("\n "));
return false;
}
let (yes, no, partial, unknown) = figcraft_engine::catalog::headless_counts(&rows);
md.push_str(&format!(
"\n## Headless\n\n**Headless ([RFC-0052](https://github.com/storytold/craft-contrib/blob/main/rfcs/0052-headless-reach.md)): {yes} yes, {} no (window {}, os {}, engine-gap {}), {partial} partial, {unknown} unknown.**\n\nAn item is `headless: yes` when its id is in the engine registry that `figcraft-cli` and the MCP server load. The UI-layer ids that light up a menu item above don't count. Other values are the hand marks in `HEADLESS` (`crates/engine/src/catalog.rs`), or `unknown`.\n",
no.iter().sum::<usize>(),
no[0],
no[1],
no[2]
));
let other: Vec<_> = rows.iter().filter(|r| r.value != "yes").collect();
if !other.is_empty() {
md.push('\n');
}
for r in other {
let reach = r.reach.map(|x| format!(", reach: {x} ({})", r.why)).unwrap_or_default();
md.push_str(&format!("- `{}` {}: headless: {}{reach}\n", r.id, r.label, r.value));
}
md.push_str("\nMenu coverage measures breadth only; see docs/target-app-parity.md for depth and fidelity.\n");
let path = root().join("docs/parity-checklist.md");
if let Err(e) = std::fs::write(&path, md) {