Skip to content

Commit 667a02d

Browse files
committed
fix(development-system): reject dirty checkpoint bootstrap
Require the generation-zero exception to prove empty tracked and untracked snapshots so unreconciled work cannot enter the durable task lineage. Closes: 20260901-xige
1 parent 715574f commit 667a02d

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

plugins/development-system/scripts/write-local-checkpoint.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,10 @@ if ! tail -c +15 "$record_file" | jq -e --argjson generation "$expected_generati
7878
(.gates.fast_gate_receipt | type == "string") and
7979
((.gates.exact_identity_verification_receipt == null and .next_action == "verify-exact-commit") or (.gates.exact_identity_verification_receipt | type == "string"))
8080
elif .state == "pushed-or-delivery-mode-equivalent" and .generation == 0 then
81-
.baseline_oid == .snapshot.head_oid and .test == null and all(.gates[]; . == null) and .delivery != null and
81+
.baseline_oid == .snapshot.head_oid and
82+
.snapshot.tracked_sha256 == "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" and
83+
.snapshot.untracked_sha256 == "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" and
84+
.test == null and all(.gates[]; . == null) and .delivery != null and
8285
(if .delivery.mode == "local-only" then
8386
(.delivery.local_snapshot | type == "string") and (.ci.runs | length) == 0 and .ci.terminal_success_run_id == null
8487
else .delivery.pushed_oid == .snapshot.head_oid end)

scripts/tests/development-discipline-plugin.bats

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ setup() {
9292

9393
repo=$(mktemp -d)
9494
git -C "$repo" init -q
95+
printf '%s\n' baseline >"$repo/tracked.txt"
96+
git -C "$repo" add tracked.txt
9597
git -C "$repo" -c user.name=Test -c user.email=test@example.invalid commit --allow-empty -m baseline -q
9698
records=$(mktemp -d)
9799
first="$records/first.record"
@@ -104,6 +106,7 @@ setup() {
104106
invalid_local_ci="$records/invalid-local-ci.record"
105107
invalid_baseline="$records/invalid-baseline.record"
106108
invalid_committed_test="$records/invalid-committed-test.record"
109+
dirty_bootstrap="$records/dirty-bootstrap.record"
107110
head_oid=$(git -C "$repo" rev-parse HEAD)
108111
empty_sha=e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
109112
printf '%s\n' 'checkpoint-v1 {"generation":0,"predecessor_sha256":null}' >"$invalid"
@@ -164,6 +167,14 @@ setup() {
164167
lock_line=$(grep -n 'flock -x' "$writer" | cut -d: -f1)
165168
snapshot_line=$(grep -n 'current_head=' "$writer" | cut -d: -f1)
166169
[ "$lock_line" -lt "$snapshot_line" ]
170+
171+
printf '%s\n' dirty >"$repo/tracked.txt"
172+
dirty_tracked=$(git -C "$repo" diff --binary --full-index HEAD -- | sha256sum | cut -d ' ' -f 1)
173+
dirty_json=$(jq -cn --arg head "$head_oid" --arg tracked "$dirty_tracked" --arg empty "$empty_sha" '{generation:0,predecessor_sha256:null,baseline_oid:$head,snapshot:{head_oid:$head,tracked_sha256:$tracked,untracked_sha256:$empty},state:"pushed-or-delivery-mode-equivalent",test:null,gates:{lightweight_review_receipt:null,fast_gate_receipt:null,exact_identity_verification_receipt:null},delivery:{mode:"local-only",commit_oid:null,pushed_oid:null,local_snapshot:"snapshot"},ci:{runs:[],terminal_success_run_id:null},next_action:"edit"}')
174+
printf 'checkpoint-v1 %s\n' "$dirty_json" >"$dirty_bootstrap"
175+
run bash -c 'cd "$1" && "$2" dirty-item 0 null "$3"' _ "$repo" "$writer" "$dirty_bootstrap"
176+
[ "$status" -ne 0 ]
177+
[ ! -e "$repo/.git/development-system/checkpoints/dirty-item.latest" ]
167178
}
168179

169180

0 commit comments

Comments
 (0)