Compare commits

...
Author SHA1 Message Date
Fredrik Hallin fc9fd456b7 Release: GridCraft v0.20.0
# Conflicts:
#	Cargo.lock
2026-11-29 04:47:41 +01:00
FredAppsandFredrik Hallin 684d86b78d Release: GridCraft v0.20.0 (#4897)
Co-authored-by: Fredrik Hallin <fredrik.hallin@guidelinegeo.com>
2026-11-29 04:44:17 +01:00
Dylan M. Taylor 5b43c2abc8 fix(nightly): enable Linux package_formats (including Flatpak) in signing policy (#4896) 2026-11-28 22:40:36 -05:00
Dylan M. Taylor 01c94182f5 ci: pin storytold/craft-common-actions to @main universally (#4889) 2026-11-28 16:06:32 -05:00
Dylan M. Taylor 0ff6f02485 ci(nightly): enable all signed Linux package formats (deb, rpm, appimage, flatpak, oci, arch) (#4887) 2026-11-28 15:21:23 -05:00
Dylan M. Taylor f2934fd009 fix(nightly): allow reopening nightly profile with saved settings and session files (#4872) 2026-11-28 11:41:01 -05:00
FredApps ba597305a1 Merge pull request #4140 from alehel/split/text-defaults
Model: workbook text defaults: languages, Asian and complex fonts (ODS groundwork)
2026-11-27 23:29:47 +01:00
FredApps b742816737 parity: headless column from the engine registry (RFC-0052) (#4860) 2026-11-27 23:14:07 +01:00
skylar taylor-barrick 97f2754c1d nightly: put macOS notices where Launcher expects them (#4851) 2026-11-27 18:56:30 +01:00
alehelandClaude Opus 5.5 f45c122e79 Text defaults: the zero-sheet test saves and opens through GridCraft JSON
The test built its JSON with serde_json directly. It now saves with
io::save_bytes and opens with io::open_bytes, the craft-gridcraft-format
writer and reader main uses, empties the sheet list in between, and
gives the workbook a macro. One open then checks that the zero-sheet
reset carries both the text defaults and the macros. It fails when the
reset drops the text defaults.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 01:01:22 +01:00
alehelandClaude Opus 5.5 6868b7eb7b Merge storytold/gridcraft main into split/text-defaults
Main now reads GridCraft JSON through craft_gridcraft_format::read. That
reader deserialises the model with its own serde rules, so text_defaults
loads as before; the zero-sheet reset keeps carrying the macros and the
text defaults across.

Conflicts:
- crates/model/src/lib.rs: the re-export list takes both main's RefHost
  and WriteReservation and this branch's ScriptDefault and TextDefaults.
- docs/file-format-parity.md: main's header and history, with this
  branch's 2026-11-14 row placed among main's 2026-11-14 rows and its
  summary added to the header's "earlier" list in the same place.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 00:49:22 +01:00
alehel dd1ba0e33d Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	docs/file-format-parity.md
2026-11-15 22:22:17 +01:00
FredApps ab65ee8eb8 Release: GridCraft v0.20.0 (main f2044337c7) 2026-11-14 21:46:35 +01:00
FredApps 9b9c956068 Release: GridCraft v0.20.0 2026-11-14 21:46:32 +01:00
alehel 810b95bf68 Text defaults: a JSON workbook without sheets keeps them on open
When GridCraft JSON has no sheets, the reader replaces the workbook with
Workbook::new() and carries only the macros across, so its text defaults
were dropped and a save lost them. They are carried across too.
2026-11-14 10:54:29 +01:00
alehel a85ee924d6 Merge storytold/gridcraft main into split/text-defaults 2026-11-14 08:29:50 +01:00
alehel 0d868b83df Text defaults: keep ODF's script code and BCP 47 language tag
ODF 1.2 states a default language with fo:script and style:rfc-language-tag
(and their -asian/-complex forms) as well as fo:language/fo:country. Without
them, locales such as sr-Latn-RS or ca-ES-valencia would lose their script or
variant on an ODS round trip, and adding them later would be a breaking model
change. ScriptDefault gains `script` and `rfc_language_tag`, both skipped in
JSON when unset and counted by is_empty. The `font` doc now says it holds the
family name (not a style:font-face name) and that western.font is unused; the
"no language" note says zxx is the language and none the country.

The test round-trips sr-Latn-RS and fails if is_empty ignores either new field.
2026-11-14 08:29:24 +01:00
alehel 05b883379a Text defaults: field doc says empty until a reader fills them 2026-11-14 08:29:24 +01:00
alehel ba6385b388 Text defaults: revision row in the history table; doc says no reader fills them yet 2026-11-14 08:29:24 +01:00
alehel 989782f1a0 Model: workbook text defaults (languages, Asian/complex fonts)
Adds ScriptDefault { language, country, font } and TextDefaults
{ western, asian, complex } with is_empty, and Workbook::text_defaults,
exported from the model crate. An OpenDocument file states these on its
default cell style; Excel has no equivalent, so XLSX ignores them. The
field is kept in GridCraft JSON and skipped when empty, so a workbook
without it serialises exactly as before.
2026-11-14 08:29:24 +01:00
Dylan M. Taylor 476448d7d9 Merge tested main for Flatpak update patch release 2026-11-11 15:25:59 -05:00
Dylan M. Taylor 26f9783d11 Release 0.19.1: repair Flatpak update checks and self-updates (#3804)
* Release 0.19.1: fix Flatpak update permissions

* test: avoid unchecked option parsing in Flatpak regression
2026-11-11 14:27:27 -05:00
FredApps b7cb2c97dd Merge main into release for GridCraft v0.19.0 2026-11-11 17:35:47 +01:00
FredApps fd10b86cc2 Merge main into release for GridCraft v0.19.0 2026-11-11 16:38:57 +01:00
Dylan M. Taylor 17cb3c83d9 Release 0.18.0 2026-11-09 06:32:01 -05:00
17 changed files with 523 additions and 56 deletions
+12 -4
View File
@@ -4,10 +4,10 @@
"repository_id": 1408285582,
"producer_workflow_id": 429713469,
"producer_workflow_path": ".github/workflows/nightly.yml",
"producer_tooling_revision": "bf94b15b708089b95c4e2d1c978e66ecf1f2f4f3",
"producer_workflow_ref": "storytold/craft-common-actions/.github/workflows/nightly-unsigned.yml@bf94b15b708089b95c4e2d1c978e66ecf1f2f4f3",
"producer_tooling_revision": "main",
"producer_workflow_ref": "storytold/craft-common-actions/.github/workflows/nightly-unsigned.yml@main",
"signer_workflow_path": ".github/workflows/nightly-sign.yml",
"signer_tooling_revision": "bf94b15b708089b95c4e2d1c978e66ecf1f2f4f3",
"signer_tooling_revision": "main",
"release_branch": "nightly-signer",
"manual_actors": [
"bflatastic",
@@ -95,7 +95,15 @@
"unsigned_artifact_name": "nightly-unsigned-linux-x86_64",
"trust": {
"fingerprint": "2B76741B414AAD6CD33E631213A005C0B9D7C3ED"
}
},
"package_formats": [
"appimage",
"arch",
"deb",
"flatpak",
"oci",
"rpm"
]
},
"macos-aarch64": {
"unsigned_artifact_name": "nightly-unsigned-macos-aarch64",
+2 -2
View File
@@ -34,9 +34,9 @@ jobs:
checks: read
attestations: write
id-token: write
uses: storytold/craft-common-actions/.github/workflows/nightly-release.yml@bf94b15b708089b95c4e2d1c978e66ecf1f2f4f3
uses: storytold/craft-common-actions/.github/workflows/nightly-release.yml@main
with:
tooling-revision: bf94b15b708089b95c4e2d1c978e66ecf1f2f4f3
tooling-revision: main
app-name: gridcraft
producer_run_id: ${{ inputs.producer_run_id }}
producer_run_attempt: ${{ inputs.producer_run_attempt }}
+3 -2
View File
@@ -22,12 +22,13 @@ jobs:
actions: read
attestations: write
id-token: write
uses: storytold/craft-common-actions/.github/workflows/nightly-unsigned.yml@bf94b15b708089b95c4e2d1c978e66ecf1f2f4f3
uses: storytold/craft-common-actions/.github/workflows/nightly-unsigned.yml@main
with:
tooling-revision: bf94b15b708089b95c4e2d1c978e66ecf1f2f4f3
tooling-revision: main
app-name: gridcraft
manual-actors: '["bflatastic","dylanmtaylor","echelon","FredApps","skylartaylor"]'
craft-fonts-ref: b076417b5880bd4154bd22f00695b1d28c6bea83
# One producer run builds every listed platform for one all-or-nothing release. The pin is the
# craft-common-actions main commit that merged 8389cad8 (#375, the signer Windows fix).
platforms: '["windows-x86_64","linux-x86_64","macos-aarch64"]'
linux-package-formats: '["deb","rpm","appimage","flatpak","oci","arch"]'
+1
View File
@@ -81,4 +81,5 @@ Paths and conventions:
- Test corpora live in a separate corpus repository, pinned and sha256-verified. Test workbooks are built in code.
- Progress log: `ROADMAP.md`. `plan/` is an optional gitignored notebook.
- Run with a control channel: `cargo run --release -p gridcraft -- --sample sales --control 7979`. Drive it with `gridcraft-cli send 7979 <method> '<json>'`; methods are in `crates/ui-egui/src/control.rs`, the protocol in `docs/control-protocol.md`. Offscreen render: `cargo run -p gridcraft-ui-egui --example snapshot -- --sample sales out.png`. Headless: `gridcraft-cli eval '=SUM(1,2,3)'`, `gridcraft-cli mcp`.
- Headless column ([RFC-0052](https://github.com/storytold/craft-contrib/blob/main/rfcs/0052-headless-reach.md)): `cargo xtask parity` marks a catalog id `headless: yes` only when the engine registry (what `gridcraft-cli` and the MCP server load) has it. A missing id takes its `no`/`partial` value and `reach:` (`window`, `os` or `engine-gap`) from `HEADLESS` in `xtask/src/parity.rs`, or reads `unknown`. When a command lands, delete its mark; the check fails on a stale one.
- Docs: `ROADMAP.md`, `docs/gaps.md` (ranked work), `docs/architecture.md`, `docs/target-app-parity.md`, `docs/roadmap.md`, `docs/contributors.md`.
Generated
+18 -18
View File
@@ -2841,7 +2841,7 @@ dependencies = [
[[package]]
name = "gridcraft"
version = "0.19.1"
version = "0.20.0"
dependencies = [
"arboard",
"chrono",
@@ -2870,7 +2870,7 @@ dependencies = [
[[package]]
name = "gridcraft-calc"
version = "0.19.1"
version = "0.20.0"
dependencies = [
"gridcraft-core",
"gridcraft-formula",
@@ -2882,7 +2882,7 @@ dependencies = [
[[package]]
name = "gridcraft-chart"
version = "0.19.1"
version = "0.20.0"
dependencies = [
"gridcraft-calc",
"gridcraft-core",
@@ -2893,7 +2893,7 @@ dependencies = [
[[package]]
name = "gridcraft-cli"
version = "0.19.1"
version = "0.20.0"
dependencies = [
"gridcraft-engine",
"gridcraft-mcp",
@@ -2906,7 +2906,7 @@ dependencies = [
[[package]]
name = "gridcraft-core"
version = "0.19.1"
version = "0.20.0"
dependencies = [
"chrono",
"js-sys",
@@ -2917,7 +2917,7 @@ dependencies = [
[[package]]
name = "gridcraft-engine"
version = "0.19.1"
version = "0.20.0"
dependencies = [
"craft-csv",
"craft-gridcraft-format",
@@ -2943,7 +2943,7 @@ dependencies = [
[[package]]
name = "gridcraft-formula"
version = "0.19.1"
version = "0.20.0"
dependencies = [
"gridcraft-core",
"serde",
@@ -2952,7 +2952,7 @@ dependencies = [
[[package]]
name = "gridcraft-functions"
version = "0.19.1"
version = "0.20.0"
dependencies = [
"gridcraft-core",
"regex",
@@ -2960,7 +2960,7 @@ dependencies = [
[[package]]
name = "gridcraft-math"
version = "0.19.1"
version = "0.20.0"
dependencies = [
"ratex-font",
"ratex-layout",
@@ -2970,7 +2970,7 @@ dependencies = [
[[package]]
name = "gridcraft-mcp"
version = "0.19.1"
version = "0.20.0"
dependencies = [
"craft-mcp-server",
"gridcraft-engine",
@@ -2980,7 +2980,7 @@ dependencies = [
[[package]]
name = "gridcraft-model"
version = "0.19.1"
version = "0.20.0"
dependencies = [
"gridcraft-core",
"gridcraft-formula",
@@ -2994,14 +2994,14 @@ dependencies = [
[[package]]
name = "gridcraft-numfmt"
version = "0.19.1"
version = "0.20.0"
dependencies = [
"gridcraft-core",
]
[[package]]
name = "gridcraft-pdf"
version = "0.19.1"
version = "0.20.0"
dependencies = [
"craft-pdf",
"craft-stream-codecs",
@@ -3013,7 +3013,7 @@ dependencies = [
[[package]]
name = "gridcraft-sandbox"
version = "0.19.1"
version = "0.20.0"
dependencies = [
"landlock",
"libc",
@@ -3024,7 +3024,7 @@ dependencies = [
[[package]]
name = "gridcraft-ui-egui"
version = "0.19.1"
version = "0.20.0"
dependencies = [
"craft-behavior",
"craft-host",
@@ -3056,7 +3056,7 @@ dependencies = [
[[package]]
name = "gridcraft-web"
version = "0.19.1"
version = "0.20.0"
dependencies = [
"craft-web-api",
"craft-web-host",
@@ -3075,7 +3075,7 @@ dependencies = [
[[package]]
name = "gridcraft-xlsx"
version = "0.19.1"
version = "0.20.0"
dependencies = [
"craft-cfb",
"craft-csv",
@@ -8249,7 +8249,7 @@ checksum = "e450f9b2ed1dff33c94c12589a87338689467b9c4f5d8a5710bd09a847d2c8a7"
[[package]]
name = "xtask"
version = "0.19.1"
version = "0.20.0"
dependencies = [
"gridcraft-engine",
"serde_json",
+1 -1
View File
@@ -4,7 +4,7 @@ members = ["crates/*", "apps/*", "xtask"]
default-members = ["crates/*", "apps/gridcraft", "apps/gridcraft-cli", "xtask"]
[workspace.package]
version = "0.19.1"
version = "0.20.0"
edition = "2024"
license = "MIT OR Apache-2.0"
rust-version = "1.95"
+83 -1
View File
@@ -10,6 +10,8 @@ const WINDOWS_TOKEN_DIR: &str = ".gridcraft";
/// The subfolder of the profile the nightly control-channel token goes to, when one runs.
pub const CONTROL_DIR: &str = "Control";
const PROFILE_FOLDERS: [&str; 2] = [CONTROL_DIR, "logs"];
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
enum Platform {
Windows,
@@ -154,6 +156,16 @@ fn private_subdirectory(root: &Path, name: impl AsRef<Path>, label: &str) -> Res
if child == chosen || !child.starts_with(&chosen) {
return Err(format!("the nightly {label} must stay inside its selected profile"));
}
// A regular file in a folder's place is not a folder: the readers and sweepers that follow would
// fail halfway, so refuse it while the profile is still being validated.
match std::fs::symlink_metadata(&child) {
Ok(metadata) if !metadata.file_type().is_dir() => {
return Err(format!("the nightly {label} must be a directory, not a file or an alias"));
}
Ok(_) => {}
Err(error) if error.kind() == std::io::ErrorKind::NotFound => {}
Err(error) => return Err(format!("cannot inspect the nightly {label}: {error}")),
}
Ok(child)
}
@@ -167,11 +179,56 @@ fn entries_stay_inside(root: &Path) -> Result<(), String> {
};
for entry in entries {
let entry = entry.map_err(|e| format!("cannot inspect the nightly profile: {e}"))?;
private_subdirectory(root, entry.file_name(), "profile entry")?;
let path = entry.path();
let metadata = std::fs::symlink_metadata(&path).map_err(|e| format!("cannot inspect the nightly profile: {e}"))?;
// Settings and session state are ordinary files, not directories. Keep the existing
// directory-boundary check for folders (including the known folder-only entries).
let folder_only = PROFILE_FOLDERS.iter().any(|name| entry.file_name().eq_ignore_ascii_case(name));
if metadata.is_file() && !folder_only {
private_regular_file(&path, &metadata)?;
} else {
private_subdirectory(root, entry.file_name(), "profile entry")?;
}
}
Ok(())
}
/// Persisted files must have their own ordinary file identity, not an alias to other data.
fn private_regular_file(path: &Path, metadata: &std::fs::Metadata) -> Result<(), String> {
#[cfg(unix)]
{
use std::os::unix::fs::MetadataExt as _;
if metadata.nlink() != 1 {
return Err("the nightly profile file must not be shared".into());
}
}
#[cfg(windows)]
{
use winsafe::{HFILE, co};
let (file, _) = HFILE::CreateFile(
path.to_str().ok_or("the nightly profile file path is not textual")?,
co::GENERIC::default(),
Some(co::FILE_SHARE::READ | co::FILE_SHARE::WRITE | co::FILE_SHARE::DELETE),
None,
co::DISPOSITION::OPEN_EXISTING,
co::FILE_ATTRIBUTE::NORMAL,
Some(co::FILE_FLAG::OPEN_REPARSE_POINT),
None,
None,
)
.map_err(|e| e.to_string())?;
let info = file.GetFileInformationByHandle().map_err(|e| e.to_string())?;
if info.dwFileAttributes.has(co::FILE_ATTRIBUTE::REPARSE_POINT | co::FILE_ATTRIBUTE::DIRECTORY) {
return Err("the nightly profile file must not be an alias or directory".into());
}
if info.nNumberOfLinks != 1 {
return Err("the nightly profile file must not be shared".into());
}
}
let _ = (path, metadata);
Ok(())
}
/// Where a nightly control-channel token goes: `<profile>/Control`, created lazily by
/// `gridcraft_mcp` if a control server is ever started. Resolving it never creates anything.
pub fn control_directory(root: &Path) -> Result<PathBuf, String> {
@@ -525,4 +582,29 @@ mod tests {
ensure_writable(&private).unwrap();
assert_eq!(std::fs::read_dir(&private).unwrap().count(), 0);
}
#[test]
fn nightly_profile_reopens_after_saving_settings_and_session_state() {
let fixture = Fixture::new();
for platform in [Platform::Mac, Platform::Linux, Platform::Windows] {
let private = fixture.root.join(format!("nightly-reopen-{platform:?}"));
assert_eq!(fixture.check(platform, &private).unwrap(), private);
for name in ["ui.json", "prefs.json", "nightly-session.lock", "nightly-session.json"] {
std::fs::write(private.join(name), b"saved profile data").unwrap();
}
for name in PROFILE_FOLDERS {
std::fs::create_dir(private.join(name)).unwrap();
}
assert_eq!(fixture.check(platform, &private).unwrap(), private);
assert_eq!(std::fs::read(private.join("ui.json")).unwrap(), b"saved profile data");
for name in PROFILE_FOLDERS {
let path = private.join(name);
std::fs::remove_dir(&path).unwrap();
std::fs::write(&path, b"not a directory").unwrap();
assert!(fixture.check(platform, &private).is_err(), "{name} must stay a directory");
std::fs::remove_file(&path).unwrap();
std::fs::create_dir(&path).unwrap();
}
}
}
}
+4 -1
View File
@@ -324,10 +324,13 @@ fn read_plain(name: &str, bytes: &[u8], csv_as_text: bool) -> Result<(Workbook,
let mut wb: Workbook = craft_gridcraft_format::read(bytes).map_err(|e| EngineError::Other(e.to_string()))?;
wb.styles.rebuild_index();
if wb.sheets.is_empty() {
// The file's macros are read after this (`macros::load`), so they come along.
// The file's macros are read after this (`macros::load`), so they come along, and
// so do its text defaults: a save would otherwise lose them.
let macros = std::mem::take(&mut wb.macros_read);
let text_defaults = std::mem::take(&mut wb.text_defaults);
wb = Workbook::new();
wb.macros_read = macros;
wb.text_defaults = text_defaults;
}
// The file's band placement and cell count are derived state: rebuild them from the
// cells themselves, dropping what is outside the sheet grid (#1008).
+22
View File
@@ -1100,3 +1100,25 @@ fn the_merge_index_holds_a_bounded_number_of_cells() {
sh.merges = vec![RangeRef::new(CellRef::new(0, 0), CellRef::new(1_000_000, 0))];
assert!(merge_index(&sh, rect).is_none());
}
#[test]
fn json_without_sheets_keeps_its_text_defaults() -> std::result::Result<(), Box<dyn std::error::Error>> {
// Saved and opened as GridCraft JSON, with the sheet list emptied in between: the reset to a
// new workbook carries the text defaults across with the macros.
let mut saved = Workbook::new();
saved.text_defaults.asian = gridcraft_model::ScriptDefault {
language: Some("ja".into()),
country: Some("JP".into()),
font: Some("Noto Sans CJK JP".into()),
..Default::default()
};
saved.macros.push(gridcraft_model::Macro { name: "Totals".into(), ..Default::default() });
let mut v: serde_json::Value = serde_json::from_slice(&save_bytes(&saved, "book.json")?)?;
v["sheets"] = serde_json::json!([]);
let (wb, warnings) = open_bytes("book.json", v.to_string().as_bytes())?;
assert!(warnings.is_empty(), "{warnings:?}");
assert!(!wb.sheets.is_empty(), "a workbook without sheets opens as a new one");
assert_eq!(wb.text_defaults, saved.text_defaults);
assert_eq!(wb.macros, saved.macros);
Ok(())
}
+1 -1
View File
@@ -32,7 +32,7 @@ pub use style::{
};
pub use workbook::{
CalcMode, CalcSettings, DefinedName, DocProps, EQUATION_BUDGET_MESSAGE, MAX_EQUATION_LAYOUT_BYTES, PhoneticProps, PhoneticRun, PhoneticString,
RefHost, ShowObjects, Workbook, WorkbookView, WriteReservation,
RefHost, ScriptDefault, ShowObjects, TextDefaults, Workbook, WorkbookView, WriteReservation,
};
/// Font used for new workbooks. Only a name: renderers substitute an available open font
+109
View File
@@ -144,6 +144,56 @@ pub struct DefinedName {
pub hidden: bool,
}
/// The language, script, country and font a document gives one script's text by default, each
/// `None` when unstated. Codes are as files spell them (`de`/`DE`; ODF states "no language" as
/// language `zxx` with country `none`). ODF 1.2 and later can also state a script code (`Latn` in `sr-Latn-RS`) and a full
/// BCP 47 tag for locales the separate codes cannot express (`ca-ES-valencia`); both are kept so
/// such a locale survives open and save.
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct ScriptDefault {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub language: Option<String>,
/// ISO 15924 script code (ODF `fo:script`, `style:script-asian`, `style:script-complex`).
#[serde(default, skip_serializing_if = "Option::is_none")]
pub script: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub country: Option<String>,
/// BCP 47 language tag (ODF `style:rfc-language-tag`, `-asian`, `-complex`).
#[serde(default, skip_serializing_if = "Option::is_none")]
pub rfc_language_tag: Option<String>,
/// The font family name (not an ODF `style:font-face` declaration name: a reader resolves
/// `style:font-name-asian`/`-complex` to its family, a writer declares a face for it). Read
/// for Asian and complex text only; Western text takes the default style's font, so
/// `western.font` is unused.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub font: Option<String>,
}
impl ScriptDefault {
pub fn is_empty(&self) -> bool {
self.language.is_none() && self.script.is_none() && self.country.is_none() && self.rfc_language_tag.is_none() && self.font.is_none()
}
}
/// Default language and fonts of Western, Asian (CJK) and complex (right-to-left, Indic) text.
/// Empty unless a reader for a format that states them fills them (OpenDocument puts them on
/// its default cell style); Excel has no equivalent, so XLSX neither reads nor writes them.
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct TextDefaults {
#[serde(default, skip_serializing_if = "ScriptDefault::is_empty")]
pub western: ScriptDefault,
#[serde(default, skip_serializing_if = "ScriptDefault::is_empty")]
pub asian: ScriptDefault,
#[serde(default, skip_serializing_if = "ScriptDefault::is_empty")]
pub complex: ScriptDefault,
}
impl TextDefaults {
pub fn is_empty(&self) -> bool {
self.western.is_empty() && self.asian.is_empty() && self.complex.is_empty()
}
}
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct DocProps {
pub title: String,
@@ -266,6 +316,11 @@ pub struct Workbook {
/// Shared between snapshots, as nothing changes them.
#[serde(skip)]
pub macros_unread: Arc<Vec<serde_json::Value>>,
/// The language and fonts the document gives text of each script by default (an
/// OpenDocument file's default cell style). Empty until a reader for a format that states
/// them fills them.
#[serde(default, skip_serializing_if = "TextDefaults::is_empty")]
pub text_defaults: TextDefaults,
/// Unmodelled file content kept for saving (package root and workbook level). Not in JSON.
#[serde(skip)]
pub preserved: Option<Arc<crate::preserved::Preserved>>,
@@ -585,6 +640,7 @@ impl Workbook {
macros: crate::macros::Macros::default(),
macros_read: vec![],
macros_unread: Arc::default(),
text_defaults: TextDefaults::default(),
preserved: None,
source_dir: None,
region: gridcraft_core::region::default_region(),
@@ -847,6 +903,59 @@ mod tests {
Ok(())
}
#[test]
fn text_defaults_round_trip_in_json_and_are_skipped_when_empty() -> Result<(), Box<dyn std::error::Error>> {
let mut wb = Workbook::new();
assert!(wb.text_defaults.is_empty(), "new workbooks state no text defaults");
// A workbook without them serialises exactly as before the field existed.
let json = serde_json::to_string(&wb)?;
let value: serde_json::Value = serde_json::from_str(&json)?;
assert!(value.get("text_defaults").is_none(), "empty text defaults are not written");
// JSON written before the field existed still loads, with empty defaults.
assert!(serde_json::from_str::<Workbook>(&json)?.text_defaults.is_empty());
wb.text_defaults = TextDefaults {
western: ScriptDefault {
language: Some("sr".into()),
script: Some("Latn".into()),
country: Some("RS".into()),
rfc_language_tag: Some("sr-Latn-RS".into()),
font: None,
},
asian: ScriptDefault {
language: Some("ja".into()),
country: Some("JP".into()),
font: Some("Noto Sans CJK JP".into()),
..Default::default()
},
complex: ScriptDefault { font: Some("Noto Naskh Arabic".into()), ..Default::default() },
};
assert!(!wb.text_defaults.is_empty());
let json = serde_json::to_string(&wb)?;
assert_eq!(serde_json::from_str::<Workbook>(&json)?.text_defaults, wb.text_defaults);
// Unstated parts stay out of the JSON.
let value: serde_json::Value = serde_json::from_str(&json)?;
let td = value.get("text_defaults").ok_or("text_defaults written")?;
assert!(td["western"].get("font").is_none());
assert!(td["complex"].get("language").is_none());
assert!(td["asian"].get("script").is_none() && td["asian"].get("rfc_language_tag").is_none());
assert_eq!(td["western"]["script"], "Latn");
assert_eq!(td["western"]["rfc_language_tag"], "sr-Latn-RS");
// A script that states only a script code or only a language tag is not empty.
assert!(!ScriptDefault { script: Some("Latn".into()), ..Default::default() }.is_empty());
assert!(!ScriptDefault { rfc_language_tag: Some("ca-ES-valencia".into()), ..Default::default() }.is_empty());
// Only one script stated: the others are skipped and load back empty.
wb.text_defaults =
TextDefaults { asian: ScriptDefault { font: Some("Noto Serif CJK SC".into()), ..Default::default() }, ..Default::default() };
let json = serde_json::to_string(&wb)?;
let value: serde_json::Value = serde_json::from_str(&json)?;
let td = value.get("text_defaults").ok_or("text_defaults written")?;
assert!(td.get("western").is_none() && td.get("complex").is_none());
assert_eq!(serde_json::from_str::<Workbook>(&json)?.text_defaults, wb.text_defaults);
Ok(())
}
#[test]
fn sheet_names() {
let wb = Workbook::new();
File diff suppressed because one or more lines are too long
+16 -14
View File
@@ -6,6 +6,8 @@ Each entry is an Excel ribbon or menu command (feature names only). It counts as
**Overall: 282 / 296 commands implemented (95.3%).**
**Headless ([RFC-0052](https://github.com/storytold/craft-contrib/blob/main/rfcs/0052-headless-reach.md)): 282 yes, 14 no (window 0, os 10, engine-gap 4), 0 partial, 0 unknown.** An implemented command is `headless: yes`: it is in the engine registry that `gridcraft-cli` and the MCP server load. A missing one carries its hand mark from `HEADLESS` in `xtask/src/parity.rs`, or `unknown`.
| Tab | Implemented | Total | Parity |
|---|---|---|---|
| File | 11 | 11 | 100% |
@@ -166,12 +168,12 @@ Implemented:
Missing:
- `insert.smartArt` Diagram (Illustrations)
- `insert.screenshot` Screenshot (Illustrations)
- `insert.map` Maps (Charts)
- `insert.timeline` Timeline (Filters)
- `insert.signatureLine` Signature Line (Text)
- `insert.object` Object (Text)
- `insert.smartArt` Diagram (Illustrations): headless: no, reach: engine-gap (diagrams could be built by a command)
- `insert.screenshot` Screenshot (Illustrations): headless: no, reach: os (screen capture of other windows)
- `insert.map` Maps (Charts): headless: no, reach: os (online map service)
- `insert.timeline` Timeline (Filters): headless: no, reach: engine-gap (a date filter for pivot tables could be a command)
- `insert.signatureLine` Signature Line (Text): headless: no, reach: engine-gap (a signature line object could be inserted by a command)
- `insert.object` Object (Text): headless: no, reach: os (embedding another program's object)
## Draw (4 / 4, 100%)
@@ -268,11 +270,11 @@ Implemented:
Missing:
- `data.fromWeb` From Web (Get & Transform Data)
- `data.stocks` Stocks (Data Types)
- `data.geography` Geography (Data Types)
- `data.relationships` Relationships (Data Tools)
- `data.analyzeData` Analyze Data (Analysis)
- `data.fromWeb` From Web (Get & Transform Data): headless: no, reach: os (fetching a web page)
- `data.stocks` Stocks (Data Types): headless: no, reach: os (online stock data service)
- `data.geography` Geography (Data Types): headless: no, reach: os (online geography data service)
- `data.relationships` Relationships (Data Tools): headless: no, reach: engine-gap (data-model relationships could be commands)
- `data.analyzeData` Analyze Data (Analysis): headless: no, reach: os (online analysis service)
## Review (15 / 18, 83%)
@@ -296,9 +298,9 @@ Implemented:
Missing:
- `review.smartLookup` Smart Lookup (Insights)
- `review.translate` Translate (Language)
- `review.showChanges` Show Changes (Changes)
- `review.smartLookup` Smart Lookup (Insights): headless: no, reach: os (online search service)
- `review.translate` Translate (Language): headless: no, reach: os (online translation service)
- `review.showChanges` Show Changes (Changes): headless: no, reach: os (co-authoring change history service)
## View (21 / 21, 100%)
+3 -2
View File
@@ -33,11 +33,12 @@ OUTPUT="$DIST/gridcraft-$VERSION-macos-aarch64-nightly.zip"
nightly_compile_gui
APP="$NIGHTLY_WORK/stage/$MAC_NIGHTLY_APP"
mkdir -p "$APP/Contents/MacOS" "$APP/Contents/Resources"
mkdir -p "$APP/Contents/MacOS" "$APP/Contents/Resources/docs"
cp "$NIGHTLY_GUI" "$APP/Contents/MacOS/GridCraft"
chmod 755 "$APP/Contents/MacOS/GridCraft"
cp "$ROOT/assets/app-icon/gridcraft-nightly.icns" "$APP/Contents/Resources/gridcraft-nightly.icns"
nightly_copy_notices "$APP/Contents/Resources"
# Launcher admits notices under Resources/docs, not beside the icon.
nightly_copy_notices "$APP/Contents/Resources/docs"
# The private mktemp cwd is the helper authority root: stage the template inside it.
cp "$HERE/Info.plist.in" "$NIGHTLY_WORK/Info.plist.in"
(cd "$NIGHTLY_WORK" && python3 "$HERE/nightly_plist.py" --template Info.plist.in \
+82 -2
View File
@@ -1,8 +1,8 @@
#!/usr/bin/env python3
"""The macOS Nightly signing and verification scripts, run on any POSIX host against generated
fixtures and stand-in Apple tools (codesign, notarytool, stapler, spctl, security, ditto, plutil,
lipo) that log their arguments. This proves the scripts' order, refusals and cleanup; it is not a
real signature, notarization or Mac run."""
lipo) that log their arguments. The unsigned producer also runs with a stub GUI build. These
check the scripts and bundle layout, not native signing, notarization or Mac execution."""
import base64
import importlib.util
import json
@@ -27,6 +27,8 @@ COMMIT = "b" * 40
VERSION = "0.23.1-nightly.20261123.4567.1.g" + COMMIT[:12]
ASSET = f"gridcraft-{VERSION}-macos-aarch64-nightly.zip"
APP = "GridCraft Nightly.app"
APP_NOTICES = ("README.md", "LICENSE-MIT", "LICENSE-APACHE", "NOTICE", "ATTRIBUTION.md")
OPTIONAL_NOTICES = ("LICENSE", "COPYRIGHT")
TEAM = "ABCDE12345"
IDENTITY = "0123456789ABCDEF0123456789ABCDEF01234567"
SECRETS = {
@@ -183,6 +185,50 @@ class Fixture:
z.writestr(info, b"" if path.is_dir() else path.read_bytes())
return self.input
def package(self, font_licences):
"""Drive the real producer from a clean fixture checkout, without Cargo or Apple tools."""
source = HERE.parents[1]
checkout = self.root / "source"
checkout.mkdir()
notices = APP_NOTICES + tuple(name for name in OPTIONAL_NOTICES if (source / name).is_file())
for relative in (*notices, "packaging/env.sh", "packaging/nightly-common.sh", "packaging/nightly_paths.py",
"packaging/macos/nightly.sh", "packaging/macos/nightly-lib.sh",
"packaging/macos/Info.plist.in", "packaging/macos/nightly_plist.py",
"assets/app-icon/gridcraft-nightly.icns"):
target = checkout / relative
target.parent.mkdir(parents=True, exist_ok=True)
shutil.copyfile(source / relative, target)
env = self.env(**dict.fromkeys(SECRETS))
def git(*args):
return subprocess.run(["git", "-c", "core.hooksPath=/dev/null", "-c", "commit.gpgsign=false", *args],
cwd=checkout, env=env, check=True, capture_output=True, text=True, timeout=30).stdout
git("init", "-q")
git("add", "--", ".")
git("-c", "user.name=Fixture", "-c", "user.email=fixture@example.invalid", "commit", "-qm", "Packaging fixture")
commit = git("rev-parse", "HEAD").strip()
version = VERSION[:-12] + commit[:12]
# Generated licence text exercises the copier without depending on a font checkout.
fonts = self.root / "craft-fonts"
for family, data in font_licences.items():
licence = fonts / "fonts" / family / "OFL.txt"
licence.parent.mkdir(parents=True)
licence.write_bytes(data)
# The existing cargo stub fails for every invocation. Only this producer fixture emits a GUI.
(self.bin / "cargo").write_text(
'#!/bin/sh\nset -eu\n'
'gui="$CARGO_TARGET_DIR/aarch64-apple-darwin/release/gridcraft"\n'
'mkdir -p "$(dirname "$gui")"\n'
"printf \"#!/bin/sh\\necho 'GridCraft %s (nightly-v1)'\\n\" \"$GRIDCRAFT_VERSION\" >\"$gui\"\n",
)
result = self.run(checkout / "packaging/macos/nightly.sh", "--arch", "aarch64", **dict.fromkeys(SECRETS),
DIST=str(self.dist), CARGO_TARGET_DIR=str(self.root / "target"), CRAFT_FONTS_DIR=str(fonts),
GRIDCRAFT_BUILD_CHANNEL="nightly-v1", GRIDCRAFT_VERSION=version,
GRIDCRAFT_BUILD_SHA=commit, GRIDCRAFT_BUILD_DATE="2026-11-23")
assert result.returncode == 0, result.stdout
return self.dist / ASSET.replace(VERSION, version)
def env(self, **changes):
env = {"PATH": f"{self.bin}:{os.environ['PATH']}", "HOME": str(self.root), "SHIM_LOG": str(self.log),
"SHIM_TEAM": TEAM, "SHIM_IDENTITY": IDENTITY, "RUNNER_TEMP": str(self.temp), **SECRETS}
@@ -430,6 +476,40 @@ class Verify(unittest.TestCase):
class Build(unittest.TestCase):
def test_unsigned_archive_has_launcher_layout_and_keeps_all_notices(self):
f = Fixture(self)
fonts = {"fixture-one": b"generated font notice one", "fixture-two": b"generated font notice two"}
archive = f.package(fonts)
source = HERE.parents[1]
resources = f"{APP}/Contents/Resources"
icon = "gridcraft-nightly.icns"
notice_files = {name: (source / name).read_bytes() for name in APP_NOTICES}
notice_files.update({name: (source / name).read_bytes() for name in OPTIONAL_NOTICES if (source / name).is_file()})
notice_files.update({f"OFL-{family}.txt": data for family, data in fonts.items()})
# Shipped Launcher v0.20.3 accepts these leaves only in Resources/docs, except for the root icon.
expected_files = {f"{resources}/docs/{name}": data for name, data in notice_files.items()}
expected_files[f"{resources}/{icon}"] = (source / "assets/app-icon" / icon).read_bytes()
contents = f"{APP}/Contents"
gui = f"{contents}/MacOS/GridCraft"
with zipfile.ZipFile(archive) as zipped:
entries = zipped.infolist()
names = {entry.filename for entry in entries}
self.assertEqual(len(entries), len({name.casefold() for name in names}), "unique paths, ignoring case")
self.assertEqual({entry.filename for entry in entries if not entry.is_dir()},
set(expected_files) | {gui, f"{contents}/Info.plist", f"{contents}/PkgInfo"})
self.assertTrue({entry.filename for entry in entries if entry.is_dir()} <= {
f"{APP}/", f"{contents}/", f"{contents}/MacOS/", f"{resources}/", f"{resources}/docs/"})
for path, data in expected_files.items():
with self.subTest(path=path):
self.assertEqual(zipped.read(path), data)
mode = zipped.getinfo(path).external_attr >> 16
self.assertTrue(stat.S_ISREG(mode))
self.assertFalse(mode & 0o111)
mode = zipped.getinfo(gui).external_attr >> 16
self.assertTrue(stat.S_ISREG(mode) and mode & stat.S_IXUSR)
result = f.run("nightly-verify.sh", "--input", archive, "--expect", "unsigned", **dict.fromkeys(SECRETS))
self.assertEqual(result.returncode, 0, result.stdout)
def test_compilation_refuses_signing_material_before_building(self):
f = Fixture(self)
for name in ("APPLE_CERTIFICATE", "APPLE_PASSWORD", "MACOS_SIGN_IDENTITY", "WINDOWS_CERTIFICATE", "AZURE_CLIENT_SECRET", "LINUX_SIGNING_KEY"):
+6 -5
View File
@@ -171,7 +171,7 @@ def reviewed_manual_actors(caller_source, policy):
def caller_pin(name):
return re.findall(r"(?m)^ tooling-revision: ([0-9a-f]{40})$", (ROOT / ".github/workflows" / name).read_text())[0]
return re.findall(r"(?m)^ tooling-revision: (\S+)$", (ROOT / ".github/workflows" / name).read_text())[0]
class TrustedSourcePreparation(unittest.TestCase):
@@ -309,7 +309,7 @@ class TrustedSourcePreparation(unittest.TestCase):
self.assertEqual(tooling, uses, "the defining workflow SHA and tooling input must match")
pins.update(uses)
self.assertEqual(len(pins), 1, "producer and signer must pin the same shared commit")
self.assertRegex(pins.pop(), r"^[0-9a-f]{40}$", "pin a full immutable commit, never a branch or placeholder")
self.assertEqual(pins.pop(), "main", "pin storytold/craft-common-actions to @main")
class NightlyEnabledCallers(unittest.TestCase):
@@ -420,7 +420,8 @@ class NightlyInstalledPolicy(unittest.TestCase):
for platform, (field, value) in NIGHTLY_TRUST.items():
row = self.policy["platforms"][platform]
with self.subTest(platform=platform):
self.assertEqual(set(row), {"unsigned_artifact_name", "trust"})
expected_keys = {"unsigned_artifact_name", "trust", "package_formats"} if platform == "linux-x86_64" and "package_formats" in row else {"unsigned_artifact_name", "trust"}
self.assertEqual(set(row), expected_keys)
self.assertEqual(row["unsigned_artifact_name"], f"nightly-unsigned-{platform}")
self.assertEqual(row["trust"], {field: value})
@@ -739,7 +740,7 @@ def trust_closure_problems(workflows):
if workflow.lower() in ("nightly-release.yml", "nightly-release.yaml"):
if name == "nightly-sign.yml":
signer_calls += 1
if name != "nightly-sign.yml" or not re.fullmatch(r"[0-9a-f]{40}", ref):
if name != "nightly-sign.yml" or ref != "main":
problems.append(name + " calls nightly-release.yml@" + ref)
if workflow.lower() in ("release.yml", "release.yaml"):
stable_callers.add(name)
@@ -789,7 +790,7 @@ class NightlySignerBranchTrustClosure(unittest.TestCase):
"a double-quoted uses key in a flow mapping": {**tree, "extra.yml": 'jobs:\n x: {"uses": ' + SHARED + "nightly-release.yml@" + "a" * 40 + "}\n"},
"uses in any flow mapping": {**tree, "extra.yml": "jobs:\n x:\n steps:\n - {uses: actions/checkout@v4}\n"},
"another caller of the signer": {**tree, "extra.yml": "jobs:\n x:\n uses: " + SHARED + "nightly-release.yml@" + "a" * 40 + "\n"},
"a mutable signer pin": {**tree, "nightly-sign.yml": re.sub(r"nightly-release\.yml@[0-9a-f]{40}", "nightly-release.yml@main", tree["nightly-sign.yml"])},
"a signer caller on a non-main branch or tag ref": {**tree, "nightly-sign.yml": tree["nightly-sign.yml"].replace("nightly-release.yml@main", "nightly-release.yml@v1")},
"a new stable release caller": {**tree, "extra.yml": "jobs:\n x:\n uses: " + SHARED + "release.yml@main\n"},
"a stable caller on a branch or tag ref": {**tree, "release.yml": tree["release.yml"].replace(SHARED + "release.yml@main", SHARED + "release.yml@v1")},
}
+158 -2
View File
@@ -19,6 +19,89 @@ pub struct Entry {
pub done: bool,
}
/// RFC-0052 hand marks for catalog ids with no engine command: `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 id is `yes` only when the engine registry
/// that `gridcraft-cli` and the MCP server load has it, and a mark on such an id is stale
/// (`mark_errors`). A missing id with no mark is `unknown`.
pub const HEADLESS: &str = "\
insert.smartArt|no|engine-gap|diagrams could be built by a command
insert.screenshot|no|os|screen capture of other windows
insert.map|no|os|online map service
insert.timeline|no|engine-gap|a date filter for pivot tables could be a command
insert.signatureLine|no|engine-gap|a signature line object could be inserted by a command
insert.object|no|os|embedding another program's object
data.fromWeb|no|os|fetching a web page
data.stocks|no|os|online stock data service
data.geography|no|os|online geography data service
data.relationships|no|engine-gap|data-model relationships could be commands
data.analyzeData|no|os|online analysis service
review.smartLookup|no|os|online search service
review.translate|no|os|online translation service
review.showChanges|no|os|co-authoring change history service
";
/// A row's RFC-0052 `headless:` value, and for `no`/`partial` its `reach:` and reason.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Headless<'a> {
pub value: &'a str,
pub reach: Option<&'a str>,
pub why: &'a str,
}
const YES: Headless<'static> = Headless { value: "yes", reach: None, why: "" };
const UNKNOWN: Headless<'static> = Headless { value: "unknown", reach: None, why: "" };
/// Parse `HEADLESS`-format marks. A malformed line, a hand-written `yes`, an unknown reach or a
/// repeated id is an error.
pub fn parse_marks(src: &str) -> Result<Vec<(&str, Headless<'_>)>, String> {
let mut out: Vec<(&str, Headless<'_>)> = Vec::new();
for line in src.lines().filter(|l| !l.trim().is_empty()) {
let f: Vec<&str> = line.splitn(4, '|').collect();
let [id, value, reach, why] = f[..] else {
return Err(format!("headless mark `{line}`: want `id|headless|reach|why`"));
};
if !matches!(value, "no" | "partial") {
return Err(format!("headless mark `{id}`: `{value}` is not `no` or `partial` (`yes` comes from the registry)"));
}
if !matches!(reach, "window" | "os" | "engine-gap") {
return Err(format!("headless mark `{id}`: reach `{reach}` is not window, os or engine-gap"));
}
if out.iter().any(|(m, _)| *m == id) {
return Err(format!("headless mark `{id}` is written twice"));
}
out.push((id, Headless { value, reach: Some(reach), why }));
}
Ok(out)
}
/// `yes` for an id the engine registry has, else its mark, else `unknown`.
pub fn headless_of<'a>(e: &Entry, marks: &[(&str, Headless<'a>)]) -> Headless<'a> {
if e.done {
return YES;
}
marks.iter().find(|(m, _)| *m == e.id).map_or(UNKNOWN, |(_, h)| *h)
}
/// Marks that name no catalog id, or an id the engine registry has (it would hide a `yes`).
pub fn mark_errors(src: &str, entries: &[Entry]) -> Vec<String> {
let marks = match parse_marks(src) {
Ok(m) => m,
Err(e) => return vec![e],
};
let mut errs = Vec::new();
for (id, _) in &marks {
match entries.iter().find(|e| e.id == *id) {
None => errs.push(format!("headless mark `{id}` is not a catalog id")),
Some(e) if e.done => errs.push(format!("headless mark `{id}` is stale: the engine registry has it, so it is `yes`")),
Some(_) => {}
}
}
errs
}
fn pct(done: usize, total: usize) -> f64 {
if total == 0 { 0.0 } else { 100.0 * done as f64 / total as f64 }
}
@@ -26,6 +109,12 @@ fn pct(done: usize, total: usize) -> f64 {
/// The markdown for docs/parity-checklist.md. Ids are counted once (the first catalog row wins), tabs keep
/// catalog order.
pub fn render(entries: &[Entry]) -> String {
render_with(entries, HEADLESS)
}
/// `render` with the given `HEADLESS`-format marks (bad marks are left out; `mark_errors` reports them).
pub fn render_with(entries: &[Entry], marks: &str) -> String {
let marks = parse_marks(marks).unwrap_or_default();
let mut seen: Vec<&str> = Vec::new();
let mut unique: Vec<&Entry> = Vec::new();
for e in entries {
@@ -50,6 +139,22 @@ pub fn render(entries: &[Entry]) -> String {
registers a command with the same id. This measures breadth only; the overall assessment (depth, \
fidelity, effort) is in [target-app-parity.md](target-app-parity.md).\n\n";
s += &format!("**Overall: {done} / {total} commands implemented ({:.1}%).**\n\n", pct(done, total));
let hs: Vec<Headless<'_>> = unique.iter().map(|e| headless_of(e, &marks)).collect();
let count = |v: &str| hs.iter().filter(|h| h.value == v).count();
let no = |r: &str| hs.iter().filter(|h| h.value == "no" && h.reach == Some(r)).count();
s += &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.** An implemented command is `headless: yes`: it is in the \
engine registry that `gridcraft-cli` and the MCP server load. A missing one carries its hand mark from `HEADLESS` in \
`xtask/src/parity.rs`, or `unknown`.\n\n",
count("yes"),
count("no"),
no("window"),
no("os"),
no("engine-gap"),
count("partial"),
count("unknown")
);
s += "| Tab | Implemented | Total | Parity |\n|---|---|---|---|\n";
for t in &tabs {
let rows: Vec<&&Entry> = unique.iter().filter(|e| e.tab == *t).collect();
@@ -61,7 +166,21 @@ pub fn render(entries: &[Entry]) -> String {
let d = rows.iter().filter(|e| e.done).count();
s += &format!("\n## {t} ({d} / {}, {:.0}%)\n", rows.len(), pct(d, rows.len()));
for (title, want) in [("Implemented", true), ("Missing", false)] {
let list: Vec<String> = rows.iter().filter(|e| e.done == want).map(|e| format!("- `{}` {} ({})", e.id, e.label, e.group)).collect();
let list: Vec<String> = rows
.iter()
.filter(|e| e.done == want)
.map(|e| {
let line = format!("- `{}` {} ({})", e.id, e.label, e.group);
if want {
return line;
}
let h = headless_of(e, &marks);
match h.reach {
Some(r) => format!("{line}: headless: {}, reach: {r} ({})", h.value, h.why),
None => format!("{line}: headless: {}", h.value),
}
})
.collect();
if !list.is_empty() {
s += &format!("\n{title}:\n\n{}\n", list.join("\n"));
}
@@ -109,7 +228,12 @@ pub fn run(root: &Path, args: &[&str]) -> Result<(), String> {
other => return Err(format!("parity: unknown argument `{other}` (usage: cargo xtask parity [--check] [--out PATH])")),
}
}
let text = render(&entries());
let entries = entries();
let errs = mark_errors(HEADLESS, &entries);
if !errs.is_empty() {
return Err(format!("parity: RFC-0052 headless marks in xtask/src/parity.rs:\n {}", errs.join("\n ")));
}
let text = render(&entries);
if check {
let current = std::fs::read_to_string(&out).map_err(|e| format!("{}: {e}", out.display()))?;
if !up_to_date(&current, &text) {
@@ -151,6 +275,38 @@ mod tests {
assert!(s.find("## File").unwrap_or(usize::MAX) < s.find("## Home").unwrap_or(0));
}
#[test]
fn headless_yes_comes_only_from_the_registry() {
let marks = "file.open|no|window|a dialog\n";
let s = render_with(&[e("file.new", "File", true), e("file.open", "File", false), e("home.bold", "Home", false)], marks);
assert!(s.contains("1 yes, 1 no (window 1, os 0, engine-gap 0), 0 partial, 1 unknown"), "{s}");
assert!(s.contains("- `file.open` FILE.OPEN (G): headless: no, reach: window (a dialog)"), "{s}");
assert!(s.contains("- `home.bold` HOME.BOLD (G): headless: unknown"), "{s}");
// A live id is `yes` whatever a mark says.
let parsed = parse_marks("file.new|no|os|x\n").unwrap_or_default();
assert_eq!(headless_of(&e("file.new", "File", true), &parsed).value, "yes");
}
#[test]
fn bad_marks_are_refused() {
for bad in ["a.b|yes|window|x", "a.b|no|desk|x", "a.b|no", "a.b|no|os|x\na.b|partial|os|y"] {
assert!(parse_marks(bad).is_err(), "{bad}");
}
let entries = [e("a.b", "T", true), e("c.d", "T", false)];
let errs = mark_errors("a.b|no|os|x\nz.z|no|os|y\nc.d|partial|engine-gap|z\n", &entries);
assert_eq!(errs.len(), 2, "{errs:?}");
assert!(errs.iter().any(|m| m.contains("`a.b` is stale")), "{errs:?}");
assert!(errs.iter().any(|m| m.contains("`z.z` is not a catalog id")), "{errs:?}");
assert_eq!(mark_errors("junk", &entries).len(), 1);
}
#[cfg(feature = "engine")]
#[test]
fn checked_in_marks_are_current() {
let errs = mark_errors(HEADLESS, &entries());
assert!(errs.is_empty(), "{errs:?}");
}
#[test]
fn empty_catalog_renders() {
assert!(render(&[]).contains("0 / 0 commands implemented (0.0%)"));