From ee27b229313c960023a26cc0352ad365fb85899d Mon Sep 17 00:00:00 2001 From: Muse Sweep Date: Fri, 23 Oct 2026 21:18:44 -0500 Subject: [PATCH] fix(id): make the seven formatter/lint flake checks actually fail (#702) Remove the '|| true' that made treefmt/rustfmt/statix/shfmt/ shellcheck/taplo/prettier checks in pkgs/id/flake.nix always succeed, after a per-tool violation census on main f7dfea35: - rustfmt (240 files), shfmt (13), taplo check (10), prettier (26): zero violations - enforce as-is. - statix: zero violations under the project config, but the sandbox source copy cannot see the repo-root statix.toml that disables repeated_keys, so W20 fired on the NixOS test files' dotted nodes. paths. Add pkgs/id/statix.toml mirroring the root config, and restructure the per-file loop to collect failures (process substitution - a piped while loses the flag). - shellcheck: enforced at --severity=warning. Under sandbox conditions (no .shellcheckrc) shellcheck reports only four info findings (SC2012 in the examples' build.sh files) and no warning-or-above findings. - treefmt: only three files changed, all taplo formatting of Cargo.toml files. Format pkgs/id/Cargo.toml and exclude vendor/** in treefmt.toml (vendored upstream crates are not ours to reformat). - prettier/treefmt in the sandbox also missed the repo-root .editorconfig ([*.md] max_line_length=off drives prettier's markdown print width); add pkgs/id/.editorconfig mirroring the root rules so the standalone flake formats identically in the sandbox and in a working tree. Verified: nix build of rustfmt/shfmt/shellcheck/taplo/prettier/ statix checks all pass on the fixed tree; treefmt --ci passes (0 changed) with the flake's formatter set - its nix build is blocked locally only by the sandbox symlinked-store purity failure in the bun2nix dependency, which does not occur on CI runners. Negative tests: a deliberately mis-formatted .rs/.sh/.toml/.md and a statix-flagged .nix each make the corresponding check fail. --- pkgs/id/.editorconfig | 44 +++++++++++++++++++++++++++++++++++++++++++ pkgs/id/Cargo.toml | 8 ++++++-- pkgs/id/flake.nix | 37 ++++++++++++++++++++++-------------- pkgs/id/statix.toml | 9 +++++++++ pkgs/id/treefmt.toml | 2 ++ 5 files changed, 84 insertions(+), 16 deletions(-) create mode 100644 pkgs/id/.editorconfig create mode 100644 pkgs/id/statix.toml diff --git a/pkgs/id/.editorconfig b/pkgs/id/.editorconfig new file mode 100644 index 0000000000..13f8c273bf --- /dev/null +++ b/pkgs/id/.editorconfig @@ -0,0 +1,44 @@ +# pkgs/id is a standalone flake: its checks build from a source copy of +# this directory alone, so the repository-root .editorconfig is not +# visible inside the Nix sandbox. Tools that read editorconfig +# (prettier, shfmt) therefore formatted differently in CI than in a +# working tree — e.g. prettier's markdown print width comes from the +# [*.md] max_line_length rule below (#702). Keep this file in sync +# with the root .editorconfig rules that cover files under pkgs/id. +root = true + +[*] +charset=utf-8 +end_of_line=lf +indent_size=2 +indent_style=space +insert_final_newline=true +trim_trailing_whitespace=true + +[*.{bzl, py}] +indent_size = 4 + +[*.{nix}] +indent_size = 2 + +[*.md] +max_line_length=off +trim_trailing_whitespace=false + +[doc/**/transcript.txt] +trim_trailing_whitespace = false +insert_final_newline = false +end_of_line = unset + +[*.{diff,patch}] +end_of_line=unset +indent_size=unset +insert_final_newline=unset +trim_trailing_whitespace=unset + +[{LICENSES/**,LICENSE*}] +charset=unset +end_of_line=unset +indent_size=unset +insert_final_newline=unset +trim_trailing_whitespace=unset diff --git a/pkgs/id/Cargo.toml b/pkgs/id/Cargo.toml index b9819957fd..fa5bfae38d 100644 --- a/pkgs/id/Cargo.toml +++ b/pkgs/id/Cargo.toml @@ -64,10 +64,14 @@ p2panda-sync = { path = "vendor/p2panda-sync" } # Group membership and the auth DAG (P2.1). The `serde` feature (P2.3) serializes group actions, # which the event store keeps with each group operation. `test_utils` is not enabled: it turns on # test-only behaviour in p2panda-core, so the test types come from our own tests. -p2panda-auth = { git = "https://github.com/p2panda/p2panda", rev = "3e84cac48bba05c6857cce2ec433862b97f8d53c", features = ["serde"] } +p2panda-auth = { git = "https://github.com/p2panda/p2panda", rev = "3e84cac48bba05c6857cce2ec433862b97f8d53c", features = [ + "serde", +] } # DataScheme group encryption (P4.1, src/encryption/). `data_scheme` is on because the adapter is the # scheme. `test_utils` and `message_scheme` stay off: the adapter brings its own orderer and membership. -p2panda-encryption = { path = "vendor/p2panda-encryption", default-features = false, features = ["data_scheme"] } +p2panda-encryption = { path = "vendor/p2panda-encryption", default-features = false, features = [ + "data_scheme", +] } postcard = { version = "1", features = ["alloc"] } rand = "0.10" redb = "=4.3.0" diff --git a/pkgs/id/flake.nix b/pkgs/id/flake.nix index 39353a3a95..176808a2de 100644 --- a/pkgs/id/flake.nix +++ b/pkgs/id/flake.nix @@ -410,7 +410,7 @@ src = ./.; nativeBuildInputs = fmtBins; buildPhase = '' - treefmt --config-file ./treefmt.toml --tree-root "$(pwd)" --ci 2>&1 || true + treefmt --config-file ./treefmt.toml --tree-root "$(pwd)" --ci 2>&1 ''; installPhase = '' mkdir -p $out @@ -442,8 +442,7 @@ nativeBuildInputs = [ rustToolchain ]; buildPhase = '' find . -name '*.rs' -not -path '*/target/*' \ - -exec rustfmt --check --edition 2024 {} + \ - || true + -exec rustfmt --check --edition 2024 {} + ''; installPhase = '' mkdir -p $out @@ -455,9 +454,17 @@ src = ./.; nativeBuildInputs = [ pkgs.statix ]; buildPhase = '' - find . -name '*.nix' -print0 | while IFS= read -r -d "" f; do - statix check -- "$f" || true - done + # Collect failures across files instead of swallowing each + # one: a pipe into `while` would run the loop in a subshell + # and lose the flag, so feed it via process substitution. + fail=0 + while IFS= read -r -d "" f; do + statix check -- "$f" || fail=1 + done < <(find . -name '*.nix' -print0) + if [ "$fail" -ne 0 ]; then + echo "statix-check: statix reported problems above" >&2 + false + fi ''; installPhase = '' mkdir -p $out @@ -470,8 +477,7 @@ nativeBuildInputs = [ pkgs.shfmt ]; buildPhase = '' find . -name '*.sh' -not -path '*/node_modules/*' \ - -exec shfmt -d -i 2 -s {} + \ - || true + -exec shfmt -d -i 2 -s {} + ''; installPhase = '' mkdir -p $out @@ -483,9 +489,14 @@ src = ./.; nativeBuildInputs = [ pkgs.shellcheck ]; buildPhase = '' + # Enforced at warning severity (#702): under sandbox + # conditions shellcheck reports only four info findings + # (SC2012, `ls` glob picks in the examples' build.sh + # files) and no warning-or-above findings, so warnings + # and errors fail the gate while those info findings + # are worked down separately. find . -name '*.sh' -not -path '*/node_modules/*' \ - -exec shellcheck {} + \ - || true + -exec shellcheck --severity=warning {} + ''; installPhase = '' mkdir -p $out @@ -498,8 +509,7 @@ nativeBuildInputs = [ pkgs.taplo ]; buildPhase = '' find . -name '*.toml' -not -path '*/target/*' \ - -exec taplo check {} + \ - || true + -exec taplo check {} + ''; installPhase = '' mkdir -p $out @@ -515,8 +525,7 @@ -o -name '*.scss' -o -name '*.yaml' \) \ -not -path '*/node_modules/*' -not -path '*/target/*' \ -not -path '*/dist/*' \ - -exec prettier --check {} + \ - || true + -exec prettier --check {} + ''; installPhase = '' mkdir -p $out diff --git a/pkgs/id/statix.toml b/pkgs/id/statix.toml new file mode 100644 index 0000000000..98774f4ed7 --- /dev/null +++ b/pkgs/id/statix.toml @@ -0,0 +1,9 @@ +# pkgs/id is a standalone flake: its checks build from a source copy of +# this directory alone, so the repository-root statix.toml is not +# visible inside the Nix sandbox. Without this file the sandbox run +# enables lints the project deliberately turned off — repeated_keys +# (W20) fires on the idiomatic dotted `nodes.` paths in the +# NixOS VM test files (#702). Keep in sync with the root statix.toml. +disabled = ["repeated_keys"] +nix_version = '2.23' +ignore = ['.direnv'] diff --git a/pkgs/id/treefmt.toml b/pkgs/id/treefmt.toml index 4a01ceaea7..ce4effb171 100644 --- a/pkgs/id/treefmt.toml +++ b/pkgs/id/treefmt.toml @@ -21,6 +21,8 @@ excludes = [ "web/bun.nix", "e2e/bun.nix", "flake.lock", + # Vendored upstream crates: do not reformat code we do not own (#702). + "vendor/**", ] [formatter.rustfmt]