From 95d90ee4532f6cb19e4cbfccf357e51b74ad6c3a Mon Sep 17 00:00:00 2001 From: FredApps <153173854+FredApps@users.noreply.github.com> Date: Sat, 28 Nov 2026 02:21:37 +0100 Subject: [PATCH] Parity: RFC-0052 headless column in the parity report (#888) docs/parity.md gets a headless column computed from the engine registry that texturecraft-cli and the MCP server load: 21 yes, 40 no (window 33, os 5, engine-gap 2), 3 partial, 0 unknown of 64 items, per RFC-0052. --- AGENTS.md | 2 +- crates/ui-egui/src/parity.rs | 130 ++++++++++++++++++++++++++++- docs/parity.md | 154 ++++++++++++++++++----------------- 3 files changed, 207 insertions(+), 79 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index e42b5d53..63517554 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -63,7 +63,7 @@ The key words MUST, MUST NOT, SHOULD, SHOULD NOT and MAY are used as in RFC 2119 ## This repository -TextureCraft is an open-source, native 3D texture painter in Rust: a native egui/eframe app on wgpu, a headless CLI and MCP server, and the same app in the browser (trunk, wasm-bindgen). The project extension is `.tcraft`. Crates are `texturecraft-*`; the product name is written TextureCraft. MaterialCraft's `.mcmat` portable materials are read here through the shared `craft-mcmat` format crate (craft-libs), with the app's own checks in `formats::mcmat`; each app keeps its own models and policy. Start with `docs/architecture.md`, `docs/control-protocol.md`, `ROADMAP.md` and `docs/parity.md`. +TextureCraft is an open-source, native 3D texture painter in Rust: a native egui/eframe app on wgpu, a headless CLI and MCP server, and the same app in the browser (trunk, wasm-bindgen). The project extension is `.tcraft`. Crates are `texturecraft-*`; the product name is written TextureCraft. MaterialCraft's `.mcmat` portable materials are read here through the shared `craft-mcmat` format crate (craft-libs), with the app's own checks in `formats::mcmat`; each app keeps its own models and policy. Start with `docs/architecture.md`, `docs/control-protocol.md`, `ROADMAP.md` and `docs/parity.md`. `docs/parity.md` carries the [RFC-0052](https://github.com/storytold/craft-contrib/blob/main/rfcs/0052-headless-reach.md) Headless column: `yes` only when the id is an engine command (`texturecraft_engine::find`), which `texturecraft-cli` and the MCP server reach. A `ui.*` id is live in the desktop app only and gets a `no`/`partial` mark with a `window`, `os` or `engine-gap` reach in `HEADLESS` (`crates/ui-egui/src/parity.rs`). Never write `yes` there. Regenerate with `TC_UPDATE_PARITY=1 cargo test -p texturecraft-ui-egui parity`. ### Layout ```text diff --git a/crates/ui-egui/src/parity.rs b/crates/ui-egui/src/parity.rs index 50b51a55..23316b2b 100644 --- a/crates/ui-egui/src/parity.rs +++ b/crates/ui-egui/src/parity.rs @@ -6,6 +6,83 @@ use crate::menus::{CATALOG, implemented}; /// Live menu items must never drop below this (raise it when parity rises). pub const FLOOR: usize = 51; +/// RFC-0052 hand marks for catalog ids that aren't engine commands: `(id, headless, reach, why)`. +/// +/// `headless` is `no` or `partial`; `reach` is `window` (needs a desktop window, dialog or pointer), +/// `os` (needs an OS or online service the engine doesn't wrap) or `engine-gap` (could be an engine +/// command, isn't one yet). `yes` is never written here: an item is `yes` only when its id is an +/// engine command (`texturecraft_engine::find`), the registry `texturecraft-cli` and the MCP server +/// load. A `ui.*` id is live in the desktop app only. An unmarked id is `unknown`. +pub const HEADLESS: &[(&str, &str, &str, &str)] = &[ + ("ui.newProject", "partial", "window", "the dialog is desktop-only; `project.new` creates the project"), + ("ui.saveAsTemplate", "partial", "window", "the dialog is desktop-only; `project.template.save` saves it"), + ("ui.export", "partial", "window", "the dialog is desktop-only; `file.exportTextures` exports"), + ("ui.saveReduced", "no", "engine-gap", "a smaller save could be a command"), + ("ui.projectConfig", "no", "engine-gap", "project settings could be set by a command"), + ("ui.recent.clear", "no", "window", "the desktop recent-projects list"), + ("ui.quit", "no", "window", "quits the desktop app"), + ("ui.settings", "no", "window", "the desktop settings window"), + ("ui.mode.bake", "no", "window", "switches the desktop workspace; `bake.run` bakes"), + ("ui.mode.paint", "no", "window", "switches the desktop workspace"), + ("ui.mode.render", "no", "window", "switches the desktop workspace"), + ("ui.layout.save.painting", "no", "window", "desktop window layout"), + ("ui.layout.save.rendering", "no", "window", "desktop window layout"), + ("ui.layout.save.baking", "no", "window", "desktop window layout"), + ("ui.layout.load", "no", "window", "desktop window layout"), + ("ui.hideUi", "no", "window", "desktop window layout"), + ("ui.resetUi", "no", "window", "desktop window layout"), + ("ui.help.releaseNotes", "no", "os", "opens a web page in the browser"), + ("ui.help.docs", "no", "os", "opens a web page in the browser"), + ("ui.help.discord", "no", "os", "opens a web page in the browser"), + ("ui.help.bug", "no", "os", "opens a web page in the browser"), + ("ui.help.checkForUpdates", "no", "os", "an online update check"), + ("ui.help.shortcuts", "no", "window", "a desktop window"), + ("ui.help.showLog", "no", "window", "a desktop window"), + ("ui.help.exportLog", "no", "window", "saves the desktop app's log"), + ("ui.about", "no", "window", "a desktop window"), +]; + +/// Prefixes whose every id opens or arranges a desktop panel (`no`, `window`). +const WINDOW_PREFIXES: [&str; 2] = ["ui.view.", "ui.toolbar."]; + +/// An item's RFC-0052 `(headless, reach, why)`: `yes` for an engine command, else its mark, else +/// `unknown`. +pub fn headless_of(id: &str, in_engine: bool) -> (&'static str, Option<&'static str>, &'static str) { + if in_engine { + return ("yes", None, ""); + } + if let Some(m) = HEADLESS.iter().find(|m| m.0 == id) { + return (m.1, Some(m.2), m.3); + } + if WINDOW_PREFIXES.iter().any(|p| id.starts_with(p)) { + return ("no", Some("window"), "a desktop panel or toolbar"); + } + ("unknown", None, "") +} + +/// Problems with `marks` against `ids` (`(id, is an engine command)`): bad values, repeats, ids +/// not in the catalog, and marks on engine commands (they would hide a `yes`). +pub fn headless_errors(marks: &[(&str, &str, &str, &str)], ids: &[(&str, bool)]) -> Vec { + 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 catalog id")), + Some((_, true)) => errs.push(format!("headless mark `{id}` is stale: it is an engine command, so it is `yes`")), + Some(_) => {} + } + } + errs +} + /// (live, total) over the catalog, separators excluded. pub fn counts() -> (usize, usize) { let items: Vec<_> = CATALOG.iter().filter(|i| i.label != "-").collect(); @@ -20,15 +97,32 @@ pub fn report() -> String { out.push_str("Each row is a menu item of the target menu layout with TextureCraft's command id; "); out.push_str("**live** means the id is implemented. Feature parity beyond menus is tracked in [`ROADMAP.md`](../ROADMAP.md).\n\n"); out.push_str(&format!("**{live} of {total} menu items live ({:.0}%).**\n\n", live as f32 * 100.0 / total.max(1) as f32)); + let values: Vec<_> = CATALOG.iter().filter(|i| i.label != "-").map(|i| headless_of(i.id, texturecraft_engine::find(i.id).is_some())).collect(); + 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(); + out.push_str(&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.** ", + count("yes"), + count("no"), + no("window"), + no("os"), + no("engine-gap"), + count("partial"), + count("unknown") + )); + out.push_str("An item is `headless: yes` when its id is an engine command, so `texturecraft-cli` and the MCP server reach it. "); + out.push_str("A `ui.*` id is live in the desktop app only; its value is the hand mark in `HEADLESS` (`crates/ui-egui/src/parity.rs`).\n\n"); for top in crate::menus::TOP { - out.push_str(&format!("## {top}\n\n| Item | Id | Shortcut | Status |\n|---|---|---|---|\n")); + out.push_str(&format!("## {top}\n\n| Item | Id | Shortcut | Status | Headless |\n|---|---|---|---|---|\n")); for i in CATALOG.iter().filter(|i| i.menu == top && i.label != "-") { let label = match i.sub { Some(s) => format!("{s} ▸ {}", i.label), None => i.label.to_string(), }; let status = if implemented(i.id) { "live" } else { "missing" }; - out.push_str(&format!("| {label} | `{}` | {} | {status} |\n", i.id, i.shortcut.unwrap_or(""))); + let (value, reach, why) = headless_of(i.id, texturecraft_engine::find(i.id).is_some()); + let headless = reach.map_or_else(|| value.to_string(), |r| format!("{value}, reach: {r} ({why})")); + out.push_str(&format!("| {label} | `{}` | {} | {status} | {headless} |\n", i.id, i.shortcut.unwrap_or(""))); } out.push('\n'); } @@ -39,6 +133,38 @@ pub fn report() -> String { mod tests { use super::*; + #[test] + fn headless_marks_are_current() { + let ids: Vec<(&str, bool)> = CATALOG.iter().filter(|i| i.label != "-").map(|i| (i.id, texturecraft_engine::find(i.id).is_some())).collect(); + let errs = headless_errors(HEADLESS, &ids); + assert!(errs.is_empty(), "{errs:?}"); + } + + #[test] + fn a_desktop_only_id_is_live_but_not_headless() { + assert!(implemented("ui.export"), "live in the desktop app"); + assert_eq!(headless_of("ui.export", false).0, "partial"); + assert_eq!(headless_of("ui.view.layers", false), ("no", Some("window"), "a desktop panel or toolbar")); + assert_eq!(headless_of("file.save", true).0, "yes"); + assert_eq!(headless_of("ui.unheardOf", false).0, "unknown"); + let r = report(); + assert!(r.contains("| `file.save` | Ctrl+S | live | yes |"), "{r}"); + let (live, _) = counts(); + let yes = CATALOG.iter().filter(|i| i.label != "-" && texturecraft_engine::find(i.id).is_some()).count(); + assert!(yes < live, "the ui.* ids are live but not headless"); + assert!(r.contains(&format!("{yes} yes,")), "{r}"); + } + + #[test] + fn bad_headless_marks_are_refused() { + 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 catalog id"] { + assert!(errs.iter().any(|e| e.contains(want)), "{want}: {errs:?}"); + } + } + #[test] fn parity_floor_and_report() { let (live, total) = counts(); diff --git a/docs/parity.md b/docs/parity.md index a8bc242d..46707737 100644 --- a/docs/parity.md +++ b/docs/parity.md @@ -4,97 +4,99 @@ Generated by `TC_UPDATE_PARITY=1 cargo test -p texturecraft-ui-egui parity`. Eac **63 of 64 menu items live (98%).** +**Headless ([RFC-0052](https://github.com/storytold/craft-contrib/blob/main/rfcs/0052-headless-reach.md)): 21 yes, 40 no (window 33, os 5, engine-gap 2), 3 partial, 0 unknown.** An item is `headless: yes` when its id is an engine command, so `texturecraft-cli` and the MCP server reach it. A `ui.*` id is live in the desktop app only; its value is the hand mark in `HEADLESS` (`crates/ui-egui/src/parity.rs`). + ## File -| Item | Id | Shortcut | Status | -|---|---|---|---| -| New Project | `ui.newProject` | Ctrl+N | live | -| Open | `file.open` | Ctrl+O | live | -| Recent Projects ▸ Clear | `ui.recent.clear` | | live | -| Open Sample Project | `project.sample` | | live | -| Close | `file.close` | Ctrl+F4 | live | -| Save | `file.save` | Ctrl+S | live | -| Save As | `file.saveAs` | Ctrl+Shift+S | live | -| More Save Options ▸ Save As Template | `ui.saveAsTemplate` | | live | -| More Save Options ▸ Save and Reduce File Size | `ui.saveReduced` | | missing | -| More Save Options ▸ Save As Copy | `file.saveCopy` | | live | -| Remove Unused Resources | `file.removeUnused` | | live | -| Import Resources | `resource.import` | | live | -| Export Textures | `ui.export` | Ctrl+Shift+E | live | -| Export Mesh | `file.exportMesh` | | live | -| Quit | `ui.quit` | Ctrl+Q | live | +| Item | Id | Shortcut | Status | Headless | +|---|---|---|---|---| +| New Project | `ui.newProject` | Ctrl+N | live | partial, reach: window (the dialog is desktop-only; `project.new` creates the project) | +| Open | `file.open` | Ctrl+O | live | yes | +| Recent Projects ▸ Clear | `ui.recent.clear` | | live | no, reach: window (the desktop recent-projects list) | +| Open Sample Project | `project.sample` | | live | yes | +| Close | `file.close` | Ctrl+F4 | live | yes | +| Save | `file.save` | Ctrl+S | live | yes | +| Save As | `file.saveAs` | Ctrl+Shift+S | live | yes | +| More Save Options ▸ Save As Template | `ui.saveAsTemplate` | | live | partial, reach: window (the dialog is desktop-only; `project.template.save` saves it) | +| More Save Options ▸ Save and Reduce File Size | `ui.saveReduced` | | missing | no, reach: engine-gap (a smaller save could be a command) | +| More Save Options ▸ Save As Copy | `file.saveCopy` | | live | yes | +| Remove Unused Resources | `file.removeUnused` | | live | yes | +| Import Resources | `resource.import` | | live | yes | +| Export Textures | `ui.export` | Ctrl+Shift+E | live | partial, reach: window (the dialog is desktop-only; `file.exportTextures` exports) | +| Export Mesh | `file.exportMesh` | | live | yes | +| Quit | `ui.quit` | Ctrl+Q | live | no, reach: window (quits the desktop app) | ## Edit -| Item | Id | Shortcut | Status | -|---|---|---|---| -| Undo | `edit.undo` | Ctrl+Z | live | -| Redo | `edit.redo` | Ctrl+Y | live | -| Project Configuration | `ui.projectConfig` | | live | -| Reimport Mesh | `file.reimportMesh` | Ctrl+Shift+R | live | -| Settings | `ui.settings` | | live | +| Item | Id | Shortcut | Status | Headless | +|---|---|---|---|---| +| Undo | `edit.undo` | Ctrl+Z | live | yes | +| Redo | `edit.redo` | Ctrl+Y | live | yes | +| Project Configuration | `ui.projectConfig` | | live | no, reach: engine-gap (project settings could be set by a command) | +| Reimport Mesh | `file.reimportMesh` | Ctrl+Shift+R | live | yes | +| Settings | `ui.settings` | | live | no, reach: window (the desktop settings window) | ## Mode -| Item | Id | Shortcut | Status | -|---|---|---|---| -| Bake Mesh Maps | `ui.mode.bake` | F8 | live | -| Painting | `ui.mode.paint` | F9 | live | -| Rendering | `ui.mode.render` | F10 | live | +| Item | Id | Shortcut | Status | Headless | +|---|---|---|---|---| +| Bake Mesh Maps | `ui.mode.bake` | F8 | live | no, reach: window (switches the desktop workspace; `bake.run` bakes) | +| Painting | `ui.mode.paint` | F9 | live | no, reach: window (switches the desktop workspace) | +| Rendering | `ui.mode.render` | F10 | live | no, reach: window (switches the desktop workspace) | ## Window -| Item | Id | Shortcut | Status | -|---|---|---|---| -| Views ▸ Assets | `ui.view.assets` | | live | -| Views ▸ Baking Log | `ui.view.bakingLog` | | live | -| Views ▸ Common Settings | `ui.view.bakeSettings` | | live | -| Views ▸ Display Settings | `ui.view.display` | | live | -| Views ▸ Export | `ui.view.export` | | live | -| Views ▸ History | `ui.view.history` | | live | -| Views ▸ Layers | `ui.view.layers` | | live | -| Views ▸ Log | `ui.view.log` | | live | -| Views ▸ Mesh Map Bakers | `ui.view.meshMapBakers` | | live | -| Views ▸ Mesh Map Settings | `ui.view.bakeMaps` | | live | -| Views ▸ Properties | `ui.view.properties` | | live | -| Views ▸ Renderer Settings | `ui.view.renderer` | | live | -| Views ▸ Shader Settings | `ui.view.shader` | | live | -| Views ▸ Texture Set List | `ui.view.textureSetList` | | live | -| Views ▸ Texture Set Settings | `ui.view.textureSetSettings` | | live | -| Toolbars ▸ Docks | `ui.toolbar.docks` | | live | -| Toolbars ▸ Tools | `ui.toolbar.tools` | | live | -| Save UI Layout ▸ Painting Mode | `ui.layout.save.painting` | | live | -| Save UI Layout ▸ Rendering Mode | `ui.layout.save.rendering` | | live | -| Save UI Layout ▸ Baking Mode | `ui.layout.save.baking` | | live | -| Load UI Layout | `ui.layout.load` | | live | -| Hide UI | `ui.hideUi` | Tab | live | -| Reset UI | `ui.resetUi` | | live | +| Item | Id | Shortcut | Status | Headless | +|---|---|---|---|---| +| Views ▸ Assets | `ui.view.assets` | | live | no, reach: window (a desktop panel or toolbar) | +| Views ▸ Baking Log | `ui.view.bakingLog` | | live | no, reach: window (a desktop panel or toolbar) | +| Views ▸ Common Settings | `ui.view.bakeSettings` | | live | no, reach: window (a desktop panel or toolbar) | +| Views ▸ Display Settings | `ui.view.display` | | live | no, reach: window (a desktop panel or toolbar) | +| Views ▸ Export | `ui.view.export` | | live | no, reach: window (a desktop panel or toolbar) | +| Views ▸ History | `ui.view.history` | | live | no, reach: window (a desktop panel or toolbar) | +| Views ▸ Layers | `ui.view.layers` | | live | no, reach: window (a desktop panel or toolbar) | +| Views ▸ Log | `ui.view.log` | | live | no, reach: window (a desktop panel or toolbar) | +| Views ▸ Mesh Map Bakers | `ui.view.meshMapBakers` | | live | no, reach: window (a desktop panel or toolbar) | +| Views ▸ Mesh Map Settings | `ui.view.bakeMaps` | | live | no, reach: window (a desktop panel or toolbar) | +| Views ▸ Properties | `ui.view.properties` | | live | no, reach: window (a desktop panel or toolbar) | +| Views ▸ Renderer Settings | `ui.view.renderer` | | live | no, reach: window (a desktop panel or toolbar) | +| Views ▸ Shader Settings | `ui.view.shader` | | live | no, reach: window (a desktop panel or toolbar) | +| Views ▸ Texture Set List | `ui.view.textureSetList` | | live | no, reach: window (a desktop panel or toolbar) | +| Views ▸ Texture Set Settings | `ui.view.textureSetSettings` | | live | no, reach: window (a desktop panel or toolbar) | +| Toolbars ▸ Docks | `ui.toolbar.docks` | | live | no, reach: window (a desktop panel or toolbar) | +| Toolbars ▸ Tools | `ui.toolbar.tools` | | live | no, reach: window (a desktop panel or toolbar) | +| Save UI Layout ▸ Painting Mode | `ui.layout.save.painting` | | live | no, reach: window (desktop window layout) | +| Save UI Layout ▸ Rendering Mode | `ui.layout.save.rendering` | | live | no, reach: window (desktop window layout) | +| Save UI Layout ▸ Baking Mode | `ui.layout.save.baking` | | live | no, reach: window (desktop window layout) | +| Load UI Layout | `ui.layout.load` | | live | no, reach: window (desktop window layout) | +| Hide UI | `ui.hideUi` | Tab | live | no, reach: window (desktop window layout) | +| Reset UI | `ui.resetUi` | | live | no, reach: window (desktop window layout) | ## Viewport -| Item | Id | Shortcut | Status | -|---|---|---|---| -| Display Material | `viewport.displayMaterial` | M | live | -| Display Next Channel | `viewport.nextChannel` | C | live | -| Display Previous Channel | `viewport.previousChannel` | Shift+C | live | -| Display Next Mesh Map | `viewport.nextMeshMap` | B | live | -| Display Previous Mesh Map | `viewport.previousMeshMap` | Shift+B | live | -| Show Entire Mesh/Path | `viewport.frame` | F | live | -| Enable Quick Mask | `viewport.quickMask` | Y | live | -| Edit Quick Mask | `viewport.quickMask.edit` | U | live | -| Invert Quick Mask | `viewport.quickMask.invert` | Ctrl+Shift+I | live | +| Item | Id | Shortcut | Status | Headless | +|---|---|---|---|---| +| Display Material | `viewport.displayMaterial` | M | live | yes | +| Display Next Channel | `viewport.nextChannel` | C | live | yes | +| Display Previous Channel | `viewport.previousChannel` | Shift+C | live | yes | +| Display Next Mesh Map | `viewport.nextMeshMap` | B | live | yes | +| Display Previous Mesh Map | `viewport.previousMeshMap` | Shift+B | live | yes | +| Show Entire Mesh/Path | `viewport.frame` | F | live | yes | +| Enable Quick Mask | `viewport.quickMask` | Y | live | yes | +| Edit Quick Mask | `viewport.quickMask.edit` | U | live | yes | +| Invert Quick Mask | `viewport.quickMask.invert` | Ctrl+Shift+I | live | yes | ## Help -| Item | Id | Shortcut | Status | -|---|---|---|---| -| Release Notes | `ui.help.releaseNotes` | | live | -| Documentation | `ui.help.docs` | | live | -| Shortcuts List | `ui.help.shortcuts` | | live | -| Discord | `ui.help.discord` | | live | -| Report a Bug | `ui.help.bug` | | live | -| Show Log | `ui.help.showLog` | | live | -| Export Log | `ui.help.exportLog` | | live | -| Check for Updates | `ui.help.checkForUpdates` | | live | -| About TextureCraft | `ui.about` | | live | +| Item | Id | Shortcut | Status | Headless | +|---|---|---|---|---| +| Release Notes | `ui.help.releaseNotes` | | live | no, reach: os (opens a web page in the browser) | +| Documentation | `ui.help.docs` | | live | no, reach: os (opens a web page in the browser) | +| Shortcuts List | `ui.help.shortcuts` | | live | no, reach: window (a desktop window) | +| Discord | `ui.help.discord` | | live | no, reach: os (opens a web page in the browser) | +| Report a Bug | `ui.help.bug` | | live | no, reach: os (opens a web page in the browser) | +| Show Log | `ui.help.showLog` | | live | no, reach: window (a desktop window) | +| Export Log | `ui.help.exportLog` | | live | no, reach: window (saves the desktop app's log) | +| Check for Updates | `ui.help.checkForUpdates` | | live | no, reach: os (an online update check) | +| About TextureCraft | `ui.about` | | live | no, reach: window (a desktop window) |