carlos / platform Public

moves copy: the gate reads the rootfs move refusal as RFS-3-C23

offlineConflict passed its err parameter on to rootfsMoveRefused, which
the moves gate refuses (an error's text forwarded from a mapping helper),
and its if-scoped msg read as the err.Error() msg below it, since the
gate does not scope. It now reads the RootfsMoveError itself and fills
rootfsMoveWords with the host, as rootfsMoveRefused does.

The sentence is RFS-3-C23, an approved, built row of the rootfs deck.
TestMovesStringsAreRecorded takes an emission whose whole pattern is such
a row (recordedElsewhere), as movesExemptionHolds does for a legacy
exemption; never a value the gate could not derive, nor a fragment.
No wording changes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev 4a23d27be758729f841923574bfa4d964b8a60f2 parent 1def2a6
2 files changed, +53 −5
  • approved_moves_copy_test.go +47 −3
  • internal/console/apiinstancemove_offline.go +6 −2
diff --git a/approved_moves_copy_test.go b/approved_moves_copy_test.go
index 6d21aefeb..30215349f 100644
--- a/approved_moves_copy_test.go
+++ b/approved_moves_copy_test.go
@@ -1707,12 +1707,53 @@ func findUnrecorded(ems []movesEmission, rows []copyRow) []movesEmission {
return out
}
+// rootfsApprovedPatterns is the pattern of every approved, built row of the
+// rootfs deck (rootfsBuiltTexts through formatPattern), so a row's %s
+// matches the code's fill-in.
+func rootfsApprovedPatterns(rows []copyRow) map[string]bool {
+ out := map[string]bool{}
+ for text := range rootfsBuiltTexts(rows) {
+ out[formatPattern(text)] = true
+ }
+ return out
+}
+
+// recordedElsewhere reports whether an emission no moves row carries is,
+// whole, the pattern of an approved, built row of another deck: the move
+// doors' refusal of a rootfs instance is RFS-3-C23 (rootfs Plan 3 Task 13),
+// as movesExemptionHolds takes such a row for a legacy exemption. A value
+// the gate could not derive, or a fragment, is never one.
+func recordedElsewhere(e movesEmission, elsewhere map[string]bool) bool {
+ return !e.underived && !e.fragment && elsewhere[e.pattern]
+}
+
+func TestMovesRecordedElsewhere(t *testing.T) {
+ elsewhere := rootfsApprovedPatterns(mustParseRootfsRecord(t))
+ c23 := formatPattern("%s is a rootfs instance, and a rootfs instance does not move. create a new instance where you want it")
+ for _, tc := range []struct {
+ e movesEmission
+ want bool
+ }{
+ {movesEmission{pattern: c23}, true},
+ {movesEmission{pattern: c23, underived: true}, false},
+ {movesEmission{pattern: c23, fragment: true}, false},
+ {movesEmission{pattern: c23 + " now"}, false},
+ {movesEmission{pattern: "a sentence in neither deck"}, false},
+ } {
+ if got := recordedElsewhere(tc.e, elsewhere); got != tc.want {
+ t.Errorf("recordedElsewhere(%s) = %v, want %v", tc.e, got, tc.want)
+ }
+ }
+}
+
// Every sentence the moves code emits to an operator (an HTTP error body, a
-// check's Reason, a phase 1 copy table's text) has a row in the record. A
-// sentence with no row is a finding: add it as a pending row. It is not a
-// reason to loosen this test.
+// check's Reason, a phase 1 copy table's text) has a row in the record, or
+// is the whole of an approved, built row of the rootfs deck
+// (recordedElsewhere). A sentence with no row is a finding: add it as a
+// pending row. It is not a reason to loosen this test.
func TestMovesStringsAreRecorded(t *testing.T) {
rows := mustParseMovesRecord(t)
+ elsewhere := rootfsApprovedPatterns(mustParseRootfsRecord(t))
var all []movesEmission
for _, f := range movesScanFiles {
all = append(all, scanMovesFile(t, f)...)
@@ -1721,6 +1762,9 @@ func TestMovesStringsAreRecorded(t *testing.T) {
t.Fatalf("the scan found only %d emissions; it has stopped reading the code", len(all))
}
for _, e := range findUnrecorded(all, rows) {
+ if recordedElsewhere(e, elsewhere) {
+ continue
+ }
t.Errorf("no row of the record carries %s", e)
}
}
diff --git a/internal/console/apiinstancemove_offline.go b/internal/console/apiinstancemove_offline.go
index 80891d25f..9b8e8434c 100644
--- a/internal/console/apiinstancemove_offline.go
+++ b/internal/console/apiinstancemove_offline.go
@@ -154,8 +154,12 @@ func writeRefusal(w http.ResponseWriter, ref *offlineRefusal) {
// error's own text: phase1Conflict passes only recorded sentences and
// answers a fixed one for anything else.
func offlineConflict(err error) string {
- if msg := rootfsMoveRefused(err); msg != "" {
- return msg
+ // A rootfs record's refusal (RFS-3-C23): rootfsMoveRefused's format,
+ // filled with the host. Written out here, not called, because the moves
+ // copy gate refuses err passed on from this helper.
+ var rootfs *provision.RootfsMoveError
+ if errors.As(err, &rootfs) {
+ return fmt.Sprintf(rootfsMoveWords, rootfs.Host)
}
msg := strings.TrimPrefix(err.Error(), provision.ErrMoveConflict.Error()+": ")
switch {