From cf495954f99aeb0b36345f29d9eb6b6aefbbffc5 Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Sat, 31 Oct 2026 07:36:47 -0500 Subject: [PATCH 1/3] fix(id): guard just-recipes.json against justfile drift (#2729) --- .github/scripts/id-pr-checks.txt | 1 + pkgs/id/flake.nix | 6 ++ pkgs/id/just-recipes.json | 104 +++++++++++++++++++++++++++++-- pkgs/id/justfile | 23 +++++++ 4 files changed, 130 insertions(+), 4 deletions(-) diff --git a/.github/scripts/id-pr-checks.txt b/.github/scripts/id-pr-checks.txt index 63812a0983..be01f8ed59 100644 --- a/.github/scripts/id-pr-checks.txt +++ b/.github/scripts/id-pr-checks.txt @@ -40,4 +40,5 @@ crash-gate-sampled crash-gate-sweep crash-gate-control crash-gate-ingest +just-recipes-drift doc diff --git a/pkgs/id/flake.nix b/pkgs/id/flake.nix index 89edb4b201..fae89c9d4c 100644 --- a/pkgs/id/flake.nix +++ b/pkgs/id/flake.nix @@ -343,6 +343,12 @@ crash-gate-sweep = mkCheck "crash-gate-sweep" "crash-gate-sweep"; crash-gate-control = mkCheck "crash-gate-control" "crash-gate-control"; crash-gate-ingest = mkCheck "crash-gate-ingest" "crash-gate-ingest"; + # Drift guard for the generated just-recipes.json (#2729): fails + # when the checked-in JSON disagrees with the justfile on the + # semantic recipe fields. The recipe projects out generation + # noise (absolute source path, body serialisation), so this is + # green on any correctly regenerated file. + just-recipes-drift = mkCheck "just-recipes-drift" "just-recipes-check"; # Playwright E2E tests (requires building the binary + browser binaries) test-e2e = pkgs.stdenv.mkDerivation { diff --git a/pkgs/id/just-recipes.json b/pkgs/id/just-recipes.json index 43cc1198f0..df991c26f1 100644 --- a/pkgs/id/just-recipes.json +++ b/pkgs/id/just-recipes.json @@ -250,6 +250,65 @@ "namepath": "root::mcpx-stop", "shebang": false }, + "mcpx-test-affected": { + "attributes": [{ "group": "util" }], + "body": [ + ["python3 pkgs/mcpx/scripts/affected-tests.py --base ", [["variable", "base"]], " ", [["variable", "args"]]] + ], + "dependencies": [], + "doc": "agent test tiers from code#1966 (policy: pkgs/mcpx/TESTING.md)", + "name": "mcpx-test-affected", + "parameters": [ + { + "default": "origin/main", + "export": false, + "flag": false, + "help": null, + "kind": "singular", + "long": null, + "max": null, + "min": null, + "multiple": false, + "name": "base", + "pattern": null, + "short": null, + "value": null + }, + { + "default": null, + "export": false, + "flag": false, + "help": null, + "kind": "star", + "long": null, + "max": null, + "min": null, + "multiple": false, + "name": "args", + "pattern": null, + "short": null, + "value": null + } + ], + "priors": 0, + "private": false, + "quiet": false, + "namepath": "root::mcpx-test-affected", + "shebang": false + }, + "rebuild": { + "attributes": [{ "group": "nixos" }], + "body": [["#!/usr/bin/env bash"], ["set -euo pipefail"], ["just update-inputs-all"], ["just switch"]], + "dependencies": [], + "doc": "Update all flake inputs, then rebuild and switch NixOS configuration", + "name": "rebuild", + "parameters": [], + "priors": 0, + "private": false, + "quiet": false, + "namepath": "root::rebuild", + "shebang": true + }, "stage-docs": { "attributes": [{ "group": "docs" }], "body": [["./scripts/stage-docs.sh ", [["variable", "args"]]]], @@ -665,7 +724,7 @@ "windows_shell": null, "working_directory": null }, - "source": "/home/hatch/git/worktrees/queue-1283-551/root.just", + "source": "/home/user/git/fleet/4094-2729-just-recipes-drift/root.just", "unexports": [], "warnings": [] } @@ -750,7 +809,7 @@ }, "bench": { "attributes": [], - "body": [["cargo bench --bench world_bench -- ", ["variable", "args"]]], + "body": [["cargo bench --bench world_bench -- ", [["variable", "args"]]]], "dependencies": [], "doc": "Run the F11.8 benchmark harness (issue #539): journal append+fsync, checkpoint compaction, guest replay, session fan-out", "name": "bench", @@ -1454,7 +1513,7 @@ ["@echo \"✓ Crash gate (sampled + corpus replay) passed\""] ], "dependencies": [], - "doc": "excluded everywhere (they rewrite the checked-in corpus files).", + "doc": "losing all PR coverage.", "name": "crash-gate-sampled", "parameters": [], "priors": 0, @@ -1613,6 +1672,43 @@ "namepath": "just-recipes", "shebang": false }, + "just-recipes-check": { + "attributes": [{ "group": "deps" }], + "body": [ + ["#!/usr/bin/env bash"], + ["set -euo pipefail"], + ["fresh=\"$(mktemp)\""], + ["trap 'rm -f \"$fresh\"' EXIT"], + ["just --dump --dump-format json > \"$fresh\""], + ["# Compare semantic fields only: recipe presence, doc, parameters,"], + ["# dependencies and the private flag, plus alias targets. The top-level"], + ["# `source` is an absolute path from the generating machine and recipe"], + ["# bodies serialise differently between just versions (the `bench`"], + ["# nesting, #2729), so both are projected out — a byte diff would"], + ["# false-positive forever."], + ["project() {"], + [ + " jq -S '{recipes: (.recipes | to_entries | map({key, value: {doc: .value.doc, parameters: [.value.parameters[]? | {name, kind, default}], dependencies: [.value.dependencies[]? | .recipe], private: (.value.private // false)}}) | from_entries), aliases: ((.aliases // {}) | to_entries | map({key, value: .value.target}) | from_entries)}' \"$1\"" + ], + ["}"], + ["if ! diff <(project just-recipes.json) <(project \"$fresh\"); then"], + [ + " echo \"error: just-recipes.json has drifted from the justfile — run 'just lockfiles' and commit the result\" >&2" + ], + [" exit 1"], + ["fi"], + ["echo \"✓ just-recipes.json matches the justfile\""] + ], + "dependencies": [], + "doc": "Fail when just-recipes.json has drifted from this justfile (#2729)", + "name": "just-recipes-check", + "parameters": [], + "priors": 0, + "private": false, + "quiet": false, + "namepath": "just-recipes-check", + "shebang": true + }, "kill": { "attributes": [{ "group": "run" }], "body": [["-pkill -xf \".*/id serve.*\""]], @@ -3096,7 +3192,7 @@ "windows_shell": null, "working_directory": null }, - "source": "/home/hatch/git/worktrees/queue-1283-551/pkgs/id/justfile", + "source": "/home/user/git/fleet/4094-2729-just-recipes-drift/pkgs/id/justfile", "unexports": [], "warnings": [] } diff --git a/pkgs/id/justfile b/pkgs/id/justfile index fa74e2a730..031443d369 100644 --- a/pkgs/id/justfile +++ b/pkgs/id/justfile @@ -202,6 +202,29 @@ just-recipes: just --dump --dump-format json > just-recipes.json biome format --write --config-path . just-recipes.json +# Fail when just-recipes.json has drifted from this justfile (#2729) +[group('deps')] +just-recipes-check: + #!/usr/bin/env bash + set -euo pipefail + fresh="$(mktemp)" + trap 'rm -f "$fresh"' EXIT + just --dump --dump-format json > "$fresh" + # Compare semantic fields only: recipe presence, doc, parameters, + # dependencies and the private flag, plus alias targets. The top-level + # `source` is an absolute path from the generating machine and recipe + # bodies serialise differently between just versions (the `bench` + # nesting, #2729), so both are projected out — a byte diff would + # false-positive forever. + project() { + jq -S '{recipes: (.recipes | to_entries | map({key, value: {doc: .value.doc, parameters: [.value.parameters[]? | {name, kind, default}], dependencies: [.value.dependencies[]? | .recipe], private: (.value.private // false)}}) | from_entries), aliases: ((.aliases // {}) | to_entries | map({key, value: .value.target}) | from_entries)}' "$1" + } + if ! diff <(project just-recipes.json) <(project "$fresh"); then + echo "error: just-recipes.json has drifted from the justfile — run 'just lockfiles' and commit the result" >&2 + exit 1 + fi + echo "✓ just-recipes.json matches the justfile" + # ============================================================================= # Testing # ============================================================================= From beafb497040315b467b3dc6ccfceaaf46b75a5c3 Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Sat, 31 Oct 2026 08:07:01 -0500 Subject: [PATCH 2/3] fix(id): run recipe drift guard inside nix sandbox --- pkgs/id/just-recipes.json | 28 ++------------------------- pkgs/id/justfile | 20 +------------------ pkgs/id/scripts/just-recipes-check.sh | 20 +++++++++++++++++++ 3 files changed, 23 insertions(+), 45 deletions(-) create mode 100644 pkgs/id/scripts/just-recipes-check.sh diff --git a/pkgs/id/just-recipes.json b/pkgs/id/just-recipes.json index df991c26f1..86e545c3b4 100644 --- a/pkgs/id/just-recipes.json +++ b/pkgs/id/just-recipes.json @@ -1674,31 +1674,7 @@ }, "just-recipes-check": { "attributes": [{ "group": "deps" }], - "body": [ - ["#!/usr/bin/env bash"], - ["set -euo pipefail"], - ["fresh=\"$(mktemp)\""], - ["trap 'rm -f \"$fresh\"' EXIT"], - ["just --dump --dump-format json > \"$fresh\""], - ["# Compare semantic fields only: recipe presence, doc, parameters,"], - ["# dependencies and the private flag, plus alias targets. The top-level"], - ["# `source` is an absolute path from the generating machine and recipe"], - ["# bodies serialise differently between just versions (the `bench`"], - ["# nesting, #2729), so both are projected out — a byte diff would"], - ["# false-positive forever."], - ["project() {"], - [ - " jq -S '{recipes: (.recipes | to_entries | map({key, value: {doc: .value.doc, parameters: [.value.parameters[]? | {name, kind, default}], dependencies: [.value.dependencies[]? | .recipe], private: (.value.private // false)}}) | from_entries), aliases: ((.aliases // {}) | to_entries | map({key, value: .value.target}) | from_entries)}' \"$1\"" - ], - ["}"], - ["if ! diff <(project just-recipes.json) <(project \"$fresh\"); then"], - [ - " echo \"error: just-recipes.json has drifted from the justfile — run 'just lockfiles' and commit the result\" >&2" - ], - [" exit 1"], - ["fi"], - ["echo \"✓ just-recipes.json matches the justfile\""] - ], + "body": [["bash scripts/just-recipes-check.sh"]], "dependencies": [], "doc": "Fail when just-recipes.json has drifted from this justfile (#2729)", "name": "just-recipes-check", @@ -1707,7 +1683,7 @@ "private": false, "quiet": false, "namepath": "just-recipes-check", - "shebang": true + "shebang": false }, "kill": { "attributes": [{ "group": "run" }], diff --git a/pkgs/id/justfile b/pkgs/id/justfile index 031443d369..6b86d6efe0 100644 --- a/pkgs/id/justfile +++ b/pkgs/id/justfile @@ -205,25 +205,7 @@ just-recipes: # Fail when just-recipes.json has drifted from this justfile (#2729) [group('deps')] just-recipes-check: - #!/usr/bin/env bash - set -euo pipefail - fresh="$(mktemp)" - trap 'rm -f "$fresh"' EXIT - just --dump --dump-format json > "$fresh" - # Compare semantic fields only: recipe presence, doc, parameters, - # dependencies and the private flag, plus alias targets. The top-level - # `source` is an absolute path from the generating machine and recipe - # bodies serialise differently between just versions (the `bench` - # nesting, #2729), so both are projected out — a byte diff would - # false-positive forever. - project() { - jq -S '{recipes: (.recipes | to_entries | map({key, value: {doc: .value.doc, parameters: [.value.parameters[]? | {name, kind, default}], dependencies: [.value.dependencies[]? | .recipe], private: (.value.private // false)}}) | from_entries), aliases: ((.aliases // {}) | to_entries | map({key, value: .value.target}) | from_entries)}' "$1" - } - if ! diff <(project just-recipes.json) <(project "$fresh"); then - echo "error: just-recipes.json has drifted from the justfile — run 'just lockfiles' and commit the result" >&2 - exit 1 - fi - echo "✓ just-recipes.json matches the justfile" + bash scripts/just-recipes-check.sh # ============================================================================= # Testing diff --git a/pkgs/id/scripts/just-recipes-check.sh b/pkgs/id/scripts/just-recipes-check.sh new file mode 100644 index 0000000000..3870206fff --- /dev/null +++ b/pkgs/id/scripts/just-recipes-check.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +set -euo pipefail +fresh="$(mktemp)" +trap 'rm -f "$fresh"' EXIT +just --dump --dump-format json > "$fresh" +# Compare semantic fields only: recipe presence, doc, parameters, +# dependencies and the private flag, plus alias targets. The top-level +# `source` is an absolute path from the generating machine and recipe +# bodies serialise differently between just versions (the `bench` +# nesting, #2729), so both are projected out — a byte diff would +# false-positive forever. +project() { + jq -S '{recipes: (.recipes | to_entries | map({key, value: {doc: .value.doc, parameters: [.value.parameters[]? | {name, kind, default}], dependencies: [.value.dependencies[]? | .recipe], private: (.value.private // false)}}) | from_entries), aliases: ((.aliases // {}) | to_entries | map({key, value: .value.target}) | from_entries)}' "$1" +} +if ! diff <(project just-recipes.json) <(project "$fresh"); then + echo "error: just-recipes.json has drifted from the justfile — run 'just lockfiles' and commit the result" >&2 + exit 1 +fi +echo "✓ just-recipes.json matches the justfile" + From 1de77d40b98463ed5e1a587e7de3b0968d73c7d8 Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Sat, 31 Oct 2026 08:44:11 -0500 Subject: [PATCH 3/3] Fix just recipe drift projection failures --- pkgs/id/flake.nix | 2 +- pkgs/id/scripts/just-recipes-check-test.sh | 41 ++++++++++++++++++++++ pkgs/id/scripts/just-recipes-check.sh | 15 ++++---- 3 files changed, 51 insertions(+), 7 deletions(-) create mode 100644 pkgs/id/scripts/just-recipes-check-test.sh diff --git a/pkgs/id/flake.nix b/pkgs/id/flake.nix index fae89c9d4c..dc93a74435 100644 --- a/pkgs/id/flake.nix +++ b/pkgs/id/flake.nix @@ -348,7 +348,7 @@ # semantic recipe fields. The recipe projects out generation # noise (absolute source path, body serialisation), so this is # green on any correctly regenerated file. - just-recipes-drift = mkCheck "just-recipes-drift" "just-recipes-check"; + just-recipes-drift = mkCheck "just-recipes-drift" "just-recipes-check && bash scripts/just-recipes-check-test.sh"; # Playwright E2E tests (requires building the binary + browser binaries) test-e2e = pkgs.stdenv.mkDerivation { diff --git a/pkgs/id/scripts/just-recipes-check-test.sh b/pkgs/id/scripts/just-recipes-check-test.sh new file mode 100644 index 0000000000..755eb876c3 --- /dev/null +++ b/pkgs/id/scripts/just-recipes-check-test.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash +set -euo pipefail + +script="$(cd "$(dirname "$0")" && pwd)/just-recipes-check.sh" +tmp="$(mktemp -d)" +trap 'rm -rf "$tmp"' EXIT +mkdir "$tmp/bin" "$tmp/work" +printf '#!%s\n' "$(command -v bash)" > "$tmp/bin/just" +cat >> "$tmp/bin/just" <<'EOF' +cat "$FRESH" +EOF +chmod +x "$tmp/bin/just" +export PATH="$tmp/bin:$PATH" FRESH="$tmp/fresh.json" +cd "$tmp/work" +cat > just-recipes.json <<'EOF' +{"source":"old", "recipes":{"run":{"doc":"run", "private":false, "parameters":[{"name":"arg", "kind":"singular", "default":null, "export":false, "flag":false}], "dependencies":[{"recipe":"dep", "arguments":[["string", "a"]], "star":null}], "body":[["old"]]}}, "aliases":{"r":{"target":"run"}}} +EOF +cp just-recipes.json "$FRESH" +check_pass() { if ! bash "$script" > "$tmp/output" 2>&1; then cat "$tmp/output"; exit 1; fi; } +check_fail() { if bash "$script" > "$tmp/output" 2>&1; then echo "unexpected success: $1" >&2; exit 1; fi; } +change() { jq "$1" just-recipes.json > "$FRESH"; } + +check_pass +change '.source = "new" | .recipes.run.body = [["new"]]' +check_pass +change '.recipes.run.parameters[0].export = true' +check_fail 'parameter export' +change '.recipes.run.parameters[0].flag = true' +check_fail 'parameter flag' +change '.recipes.run.dependencies[0].arguments[0][1] = "b"' +check_fail 'dependency argument' +change '.recipes.run.dependencies[0].star = true' +check_fail 'dependency star' +change '.aliases.r.target = "dep"' +check_fail 'alias target' +printf '{' > "$FRESH" +check_fail 'invalid fresh JSON' +cp just-recipes.json "$FRESH" +printf '{' > just-recipes.json +check_fail 'invalid committed JSON' +echo 'just-recipes-check tests passed' diff --git a/pkgs/id/scripts/just-recipes-check.sh b/pkgs/id/scripts/just-recipes-check.sh index 3870206fff..8345b2b1b2 100644 --- a/pkgs/id/scripts/just-recipes-check.sh +++ b/pkgs/id/scripts/just-recipes-check.sh @@ -1,8 +1,8 @@ #!/usr/bin/env bash set -euo pipefail -fresh="$(mktemp)" -trap 'rm -f "$fresh"' EXIT -just --dump --dump-format json > "$fresh" +tmp="$(mktemp -d)" +trap 'rm -rf "$tmp"' EXIT +just --dump --dump-format json > "$tmp/fresh.json" # Compare semantic fields only: recipe presence, doc, parameters, # dependencies and the private flag, plus alias targets. The top-level # `source` is an absolute path from the generating machine and recipe @@ -10,11 +10,14 @@ just --dump --dump-format json > "$fresh" # nesting, #2729), so both are projected out — a byte diff would # false-positive forever. project() { - jq -S '{recipes: (.recipes | to_entries | map({key, value: {doc: .value.doc, parameters: [.value.parameters[]? | {name, kind, default}], dependencies: [.value.dependencies[]? | .recipe], private: (.value.private // false)}}) | from_entries), aliases: ((.aliases // {}) | to_entries | map({key, value: .value.target}) | from_entries)}' "$1" + jq -S '{recipes: (.recipes | to_entries | map({key, value: {doc: .value.doc, parameters: .value.parameters, dependencies: .value.dependencies, private: (.value.private // false)}}) | from_entries), aliases: ((.aliases // {}) | to_entries | map({key, value: .value.target}) | from_entries)}' "$1" } -if ! diff <(project just-recipes.json) <(project "$fresh"); then +# Project separately: failures inside process substitutions are otherwise hidden +# by diff's exit status and can incorrectly report a match. +project just-recipes.json > "$tmp/committed.json" +project "$tmp/fresh.json" > "$tmp/projected.json" +if ! diff "$tmp/committed.json" "$tmp/projected.json"; then echo "error: just-recipes.json has drifted from the justfile — run 'just lockfiles' and commit the result" >&2 exit 1 fi echo "✓ just-recipes.json matches the justfile" -