Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/scripts/id-pr-checks.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ crash-gate-sampled
crash-gate-sweep
crash-gate-control
crash-gate-ingest
just-recipes-drift
doc
6 changes: 6 additions & 0 deletions pkgs/id/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 && bash scripts/just-recipes-check-test.sh";

# Playwright E2E tests (requires building the binary + browser binaries)
test-e2e = pkgs.stdenv.mkDerivation {
Expand Down
80 changes: 76 additions & 4 deletions pkgs/id/just-recipes.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"]]]],
Expand Down Expand Up @@ -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": []
}
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -1613,6 +1672,19 @@
"namepath": "just-recipes",
"shebang": false
},
"just-recipes-check": {
"attributes": [{ "group": "deps" }],
"body": [["bash scripts/just-recipes-check.sh"]],
"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": false
},
"kill": {
"attributes": [{ "group": "run" }],
"body": [["-pkill -xf \".*/id serve.*\""]],
Expand Down Expand Up @@ -3096,7 +3168,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": []
}
5 changes: 5 additions & 0 deletions pkgs/id/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,11 @@ 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:
bash scripts/just-recipes-check.sh

# =============================================================================
# Testing
# =============================================================================
Expand Down
41 changes: 41 additions & 0 deletions pkgs/id/scripts/just-recipes-check-test.sh
Original file line number Diff line number Diff line change
@@ -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'
23 changes: 23 additions & 0 deletions pkgs/id/scripts/just-recipes-check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash
set -euo pipefail
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
# 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, dependencies: .value.dependencies, private: (.value.private // false)}}) | from_entries), aliases: ((.aliases // {}) | to_entries | map({key, value: .value.target}) | from_entries)}' "$1"
}
# 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"
Loading