copy gate: a moves exemption holds for an approved, built rootfs row (rootfs Plan 1 Task 12, controller ruling)
TestMovesLegacyExemptionsAreLegacy refused internal/console/apicli.go's
RFS-1-C22 ("invalid kind (want ... or "rootfs")"): the file is exempt
as main's own copy, and main did not say that sentence. By the
controller's ruling an exempt sentence also holds when it equals the
text of an approved row in rootfsCopyBuilt, unescaped as
TestRootfsBuiltCopyIsApplied reads it; the apicli.go exemption is not
narrowed. TestMovesExemptionHolds shows a sentence in neither deck, or
a row that is pending or not built, is still refused.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+57
−2
approved_moves_copy_test.go+57 −2
diff --git a/approved_moves_copy_test.go b/approved_moves_copy_test.go| index 812fb7b02..1d92bc26d 100644 |
| --- a/approved_moves_copy_test.go |
| +++ b/approved_moves_copy_test.go |
| @@ -1890,13 +1890,68 @@ func TestMovesScanFilesCoverTheDiff(t *testing.T) { |
| } |
| } |
| +// movesExemptionHolds reports whether a sentence under a legacy exemption |
| +// may stay exempt: main already had it (inBase), or it is the text of an |
| +// approved, built row of another deck (approvedElsewhere), as the rootfs |
| +// series' rewrite of a sentence in an exempt file is (controller ruling, |
| +// rootfs Plan 1 Task 12). |
| +func movesExemptionHolds(pattern string, inBase, approvedElsewhere map[string]bool) bool { |
| + return inBase[pattern] || approvedElsewhere[pattern] |
| +} |
| + |
| +// rootfsBuiltTexts is the text of every approved row in rootfsCopyBuilt, as |
| +// the code prints it (rootfsAppliedText, as TestRootfsBuiltCopyIsApplied |
| +// reads it). |
| +func rootfsBuiltTexts(rows []copyRow) map[string]bool { |
| + out := map[string]bool{} |
| + for _, r := range builtRows(rows, rootfsCopyBuilt) { |
| + if r.Status == "approved" { |
| + out[rootfsAppliedText(r.Text)] = true |
| + } |
| + } |
| + return out |
| +} |
| + |
| +func TestMovesExemptionHolds(t *testing.T) { |
| + inBase := map[string]bool{"a sentence main had": true} |
| + elsewhere := rootfsBuiltTexts(mustParseRootfsRecord(t)) |
| + rootfs := `invalid kind (want "binary", "static" or "rootfs")` |
| + if !elsewhere[rootfs] { |
| + t.Fatalf("the rootfs deck has no approved, built row %q", rootfs) |
| + } |
| + for _, tc := range []struct { |
| + pattern string |
| + want bool |
| + }{ |
| + {"a sentence main had", true}, |
| + {rootfs, true}, |
| + {"a sentence in neither deck", false}, |
| + {`invalid kind (want "binary" or "static" or "rootfs")`, false}, |
| + } { |
| + if got := movesExemptionHolds(tc.pattern, inBase, elsewhere); got != tc.want { |
| + t.Errorf("movesExemptionHolds(%q) = %v, want %v", tc.pattern, got, tc.want) |
| + } |
| + } |
| + // A row that is not built, or not approved, is not approved copy. |
| + rows := []copyRow{ |
| + {ID: "RFS-1-C22", Text: "built and approved", Status: "approved"}, |
| + {ID: "RFS-1-C23", Text: "built but pending", Status: "pending"}, |
| + {ID: "RFS-9-C01", Text: "approved but not built", Status: "approved"}, |
| + } |
| + got := rootfsBuiltTexts(rows) |
| + if !got["built and approved"] || got["built but pending"] || got["approved but not built"] { |
| + t.Errorf("rootfsBuiltTexts = %v, want only the built, approved row", got) |
| + } |
| +} |
| + |
| // The exemptions in movesLegacyFiles and movesLegacyFuncs are only for |
| -// sentences main already had. Where git can say, every exempt emission's text |
| +// sentences main already had, or approved copy of another deck. Where git can say, every exempt emission's text |
| // is already a string literal of the file at the base commit; a sentence the |
| // series writes into one of these files must get a row, so this fails and |
| // the sentence moves out of the exemption. |
| func TestMovesLegacyExemptionsAreLegacy(t *testing.T) { |
| base := movesScanBaseRef(t) |
| + approvedElsewhere := rootfsBuiltTexts(mustParseRootfsRecord(t)) |
| files := map[string]bool{} |
| for f := range movesLegacyFiles { |
| files[f] = true |
| @@ -1942,7 +1997,7 @@ func TestMovesLegacyExemptionsAreLegacy(t *testing.T) { |
| continue |
| } |
| exempt++ |
| - if !inBase[e.pattern] { |
| + if !movesExemptionHolds(e.pattern, inBase, approvedElsewhere) { |
| t.Errorf("%s is exempt as main's own sentence, but %s at %s did not say it", e, f, base) |
| } |
| } |