carlos / platform Public

host: named-units skips only a fleet box whose identity resolves

A box with CARLOS_FLEET set but invalid now reads its parameter as usual,
so the misconfiguration shows in the record instead of behind a false
"managed-fleet box" skip (Task 4 review, plan wording). Adds a table test
over namedUnitsSkipReason.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 7a6ed46ecdf865bee1e9281939ff4398a52a2758 parent 7ca8abd
2 files changed, +34 −3
  • internal/host/namedunitsfetch.go +4 −3
  • internal/host/namedunitsfetch_test.go +30 −0

CI failed — run details

diff --git a/internal/host/namedunitsfetch.go b/internal/host/namedunitsfetch.go
index 560968363..d6fa41782 100644
--- a/internal/host/namedunitsfetch.go
+++ b/internal/host/namedunitsfetch.go
@@ -244,13 +244,14 @@ func productionNamedUnitsFetch() namedUnitsFetch {
// namedUnitsSkipReason: boxes that can't take a per-box declaration skip
// the step without a network call, rather than fail every pass with
// AccessDenied. A group-launched box has /etc/carlos/group.json; a managed
-// fleet box has CARLOS_FLEET set (resolved or not: a misconfigured fleet
-// box is still not a fixed box).
+// fleet box's identity resolves. A box whose CARLOS_FLEET is set but
+// invalid is not skipped: it reads as usual, and what the read meets shows
+// in the record rather than a skip that hides the misconfiguration.
func namedUnitsSkipReason(etc string, getenv func(string) string) string {
if groupMarkerPresent(etc) {
return "a group-launched box takes no per-box declaration"
}
- if _, err := resolveFleetIdentity(getenv); !errors.Is(err, errNotFleetBox) {
+ if _, err := resolveFleetIdentity(getenv); err == nil {
return "a managed-fleet box takes no per-box declaration"
}
return ""
diff --git a/internal/host/namedunitsfetch_test.go b/internal/host/namedunitsfetch_test.go
index 4cf2219b2..d6d4f59e8 100644
--- a/internal/host/namedunitsfetch_test.go
+++ b/internal/host/namedunitsfetch_test.go
@@ -523,3 +523,33 @@ func TestProductionNamedUnitsFetchIsWired(t *testing.T) {
t.Fatal("adoptNamedUnitsStep is nil")
}
}
+
+func TestNamedUnitsSkipReason(t *testing.T) {
+ for _, c := range []struct {
+ name string
+ group bool
+ env map[string]string
+ skip bool
+ }{
+ {name: "group marker present", group: true, skip: true},
+ {name: "valid fleet identity", env: map[string]string{"CARLOS_FLEET": "pi", "CARLOS_FLEET_BOX": "box-1"}, skip: true},
+ {name: "CARLOS_FLEET set but invalid", env: map[string]string{"CARLOS_FLEET": "pi", "CARLOS_TUNNEL_NAME": "pi-box"}, skip: false},
+ {name: "neither", skip: false},
+ } {
+ t.Run(c.name, func(t *testing.T) {
+ etc := t.TempDir()
+ if c.group {
+ if err := os.MkdirAll(filepath.Join(etc, "carlos"), 0o755); err != nil {
+ t.Fatal(err)
+ }
+ if err := os.WriteFile(filepath.Join(etc, "carlos", "group.json"), []byte("{}"), 0o644); err != nil {
+ t.Fatal(err)
+ }
+ }
+ reason := namedUnitsSkipReason(etc, func(k string) string { return c.env[k] })
+ if (reason != "") != c.skip {
+ t.Fatalf("skip reason %q, want skip=%v", reason, c.skip)
+ }
+ })
+ }
+}