carlos / platform Public

The capped REASON shows only for a fleet box of the caller's own fleet and never on an awake row or from a platform box (Task 9 fix round 1)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev 6553646ff29b10d50e48a2526b82d05a54c4f124 parent 6524474
2 files changed, +90 −44
  • internal/console/apiinstances.go +32 −28
  • internal/console/instances_config_refusals_test.go +58 −16

Intent

Human

<task-notification> <task-id>a01da7d8d7c4b02d7</task-id> <tool-use-id>toolu_019d38397jsTYKcsd47FZmwk</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/2d812478-ae68-44f2-8075-b2330abd5939/tasks/a01da7d8d7c4b02d7.output</output-file> <status>completed</status> <summary>Agent "Implement Task 9: refusals on instances list" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>**Status:** DONE_WITH_CONCERNS **Commit:** 65244749. A `packed-refs.lock` error printed, but `git log -1` confirms the commit exists. **Tests:** The new console and CLI tests pass; each failed first, and the mutation made `TestInstanceListNeverShowsAnotherTenantsRefusal` fail. The targeted InstanceList/Rollout/Workers/reasonCell/copy-gate runs also pass. Build, vet, gofmt and the darwin, windows and linux/arm64 builds are clean. **Concerns:** 1. I wrote the code before the tests, so each test's RED was shown by temporarily disabling the call sites, then restoring them. 2. A keyed sibling box can take an instance that a keyless box refuses. The list still shows "config refused" until the keyless box's entry ages out (24 h) or clears. The brief matches by host only, so I left it. 3. Which box a row is "on" for the capped report is a heuristic. A box counts if it is the row's rollout box or appears in `served_by`, or, for an unreported fleet-placed row, if its fleet has a capped box. 4. The config refusal comes first in the REASON cell, ahead of rollout and settings reasons. The brief didn't say. 5. A reason word that isn't `[a-z0-9_]{1,40}` prints as `unknown`, because a fleet box can write anything into its snapshot. 6. The root package's tests needed the sandbox off, because the Go cache path is read-only inside it. The copy rows FSK-C51 to C55 went in byte for byte, and their ids are in `fleetSecretsCopyBuilt`. **Report:** /home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-fleet-secrets-key/.superpowers/sdd/2026-10-29-fleet-secrets-key/task-9-report.md</result> <usage><subagent_tokens>129198</subagent_tokens><tool_uses>37</tool_uses><duration_ms>416645</duration_ms></usage> </task-notification>

Human

<task-notification> <task-id>a4d8bf4eb85d447d0</task-id> <tool-use-id>toolu_017HZ6tiSD4Xw3T8FfZFR2gT</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/2d812478-ae68-44f2-8075-b2330abd5939/tasks/a4d8bf4eb85d447d0.output</output-file> <status>completed</status> <summary>Agent "Review Task 9 (spec + quality)" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>**Spec compliance:** ✅ Compliant. The R-3 host match holds, the join reads fleet boxes only for fleets the caller's account owns, FSK-C51 to C55 match the copy deck byte for byte, and there are no new bucket reads. **Task quality:** Approved. The one Important finding is required by the spec, so it needs your ruling, not a fix round. **Critical:** none. **Important:** - Required by spec §5.7: the "this box refused more instances than it reports" REASON shows on instances that are running. `apiinstances.go:352-358` marks a row whenever its box is capped, even when that box reports the host awake (the test at `instances_config_refusals_test.go:709-719` pins this). On a shared platform box, more than 100 refusals belonging to other accounts would put that REASON, with its journalctl fix, on every healthy row of every customer on the box. Those customers cannot reach that journal. The likely fix is to skip awake rows and drop the capped report for platform boxes, or give platform rows different wording. The ledger's "heuristic, v1 accepted" ruling does not clearly cover either case. Review: /home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-fleet-secrets-key/.superpowers/sdd/2026-10-29-fleet-secrets-key/task-9-review.md</result> <usage><subagent_tokens>81322</subagent_tokens><tool_uses>10</tool_uses><duration_ms>156095</duration_ms></usage> </task-notification>

Attributed to this commit: 26.9 g CO₂e (3,483,059 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on design-fleet-secrets-key, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.

diff --git a/internal/console/apiinstances.go b/internal/console/apiinstances.go
index 4b09f39ce..1d0a97612 100644
--- a/internal/console/apiinstances.go
+++ b/internal/console/apiinstances.go
@@ -219,9 +219,10 @@ type instanceListRecord struct {
// (plan ruling R-3), and never from a box of a fleet the caller does not
// own. Absent when no fresh box reports one.
ConfigRefusal *configRefusalView `json:"config_refusal,omitempty"`
- // RefusalsCapped is true when a box this row is on reported more refused
- // hosts than its snapshot lists and this host is not among those listed:
- // the refusal, if there is one, is out of sight (refusalFor).
+ // RefusalsCapped is true when a box of the caller's own fleet reported
+ // more refused hosts than its snapshot lists, this host is not among
+ // those listed and the box does not have it awake: the refusal, if there
+ // is one, is out of sight (refusalFor). Never set from a platform box.
RefusalsCapped bool `json:"refusals_capped,omitempty"`
// SettingsDefault says the record and the app's policy together ask for
// today's behaviour (provision.EffectiveUpdates(...).Default()), so the
@@ -519,9 +520,10 @@ type boxJoin struct {
rollouts map[string]rolloutView
updates map[string]updatesJoinView
// refusals is each host's config refusal as the freshest box reporting
- // one gave it. capped is the labels of the boxes whose refusal list was
- // shorter than their total (status.BoxMetrics.ConfigRefusalsTotal), and
- // cappedFleets the customer fleets of the account that has such a box.
+ // one gave it. capped is the customer fleet boxes (cappedKey) whose refusal list
+ // was shorter than their total (status.BoxMetrics.ConfigRefusalsTotal),
+ // and cappedFleets the fleets of the account that have such a box.
+ // Platform boxes are never in either.
refusals map[string]status.ConfigRefusal
capped map[string]bool
cappedFleets map[string]bool
@@ -551,46 +553,48 @@ func (j *boxJoin) foldRefusals(b status.Box, fleet string) {
}
j.refusals[r.Host] = r
}
- if m.ConfigRefusalsTotal > len(m.ConfigRefusals) {
+ // Only a customer fleet's box makes a capped report: its owner can read
+ // its journal. A platform box carries many tenants, so its capped list is
+ // mostly other accounts' refusals and says nothing a customer may see.
+ if fleet != "" && m.ConfigRefusalsTotal > len(m.ConfigRefusals) {
if j.capped == nil {
j.capped = map[string]bool{}
j.cappedFleets = map[string]bool{}
}
- j.capped[b.Label] = true
- if fleet != "" {
- j.cappedFleets[fleet] = true
- }
+ j.capped[cappedKey(fleet, b.Label)] = true
+ j.cappedFleets[fleet] = true
}
}
+// cappedKey is the key of a capped fleet box in boxJoin.capped.
+func cappedKey(fleet, label string) string { return fleet + "/" + label }
+
// refusalFor is the join's config refusal for the caller's own row, matched
// by host and by nothing else (R-3): a refusal names only a host, so a host
// the caller has no row for is never shown. When the row has none listed,
-// capped says a box the row is on reported a longer list than it published.
-// A box is the row's when it reports the host (its rollout view, the edges
-// join's boxes), or, for a row nothing reports and placed on a fleet, when
-// that fleet has such a box: a refused instance is the one a box does not
-// report. ro is the row's tenant-checked rollout view.
-func (j boxJoin) refusalFor(rec provision.Record, ro *rolloutView, served []servedBy) (v *configRefusalView, capped bool) {
+// capped says a box of the caller's own fleet reported a longer list than it
+// published and this row may be one of the unlisted (FSK-C55). That needs
+// all of: the box is a customer fleet box of a fleet the caller owns (a
+// platform box never says it); it is the row's box, meaning it reports the
+// host or, for a row no box reports and placed on that fleet, it is a box of
+// the fleet (a refused instance is the one a box does not report); and the
+// box does not have the row awake, since a serving instance is not refused.
+// ro is the row's tenant-checked rollout view.
+func (j boxJoin) refusalFor(rec provision.Record, ro *rolloutView) (v *configRefusalView, capped bool) {
if r, ok := j.refusals[rec.Host]; ok {
return &configRefusalView{Reason: r.Reason, Since: r.Since, Count: r.Count}, false
}
if len(j.capped) == 0 {
return nil, false
}
- if ro != nil && j.capped[ro.Box] {
- return nil, true
- }
- for _, sb := range served {
- if j.capped[sb.Box] {
- return nil, true
- }
- }
- if ro == nil {
- for f := range recordFleets([]provision.Record{rec}) {
+ for f := range recordFleets([]provision.Record{rec}) {
+ switch {
+ case ro == nil:
if j.cappedFleets[f] {
return nil, true
}
+ case !ro.Awake && !ro.refused && j.capped[cappedKey(f, ro.Box)]:
+ return nil, true
}
}
return nil, false
@@ -1180,7 +1184,7 @@ func (s *Server) handleAPIInstanceList(w http.ResponseWriter, r *http.Request) {
continue
}
ro := join.rollout(rec.Host, acct.Sqid, app)
- refusal, refusalsCapped := join.refusalFor(rec, ro, served[rec.Host])
+ refusal, refusalsCapped := join.refusalFor(rec, ro)
matched = append(matched, instanceListRecord{Record: rec,
ConfigRefusal: refusal, RefusalsCapped: refusalsCapped,
StagedVersion: join.versions[rec.Host], Health: h, Upstreams: join.upstreams[rec.Host],
diff --git a/internal/console/instances_config_refusals_test.go b/internal/console/instances_config_refusals_test.go
index 624a7249e..85554673b 100644
--- a/internal/console/instances_config_refusals_test.go
+++ b/internal/console/instances_config_refusals_test.go
@@ -201,31 +201,73 @@ func TestInstanceListShowsCappedReport(t *testing.T) {
}
}
-// The capped report is the row's box's: a capped box that is not the row's
-// (a platform box the row is not on) says nothing about it, and a row a box
-// does report is judged by that box.
-func TestInstanceListCappedReportIsTheRowsBoxs(t *testing.T) {
- fx, token := rootfsReadyFleetApp(t, "code-refusal-capped-box", false)
- createShops(t, fx, token, rootfsShopHost, rootfsSecondHost)
- writeRefusingBox(t, fx, "", "ie-1", []status.ConfigRefusal{refusedAt("n.other.example.net", "no_key", 1)}, 101)
- if got := listedRefusals(t, fx, token)[rootfsShopHost]; got.Capped {
- t.Fatalf("a capped platform box the row is not on marked %s", rootfsShopHost)
- }
- // pi-1 reports shop's host in its rollout and is capped: its row.
+// writeCappedFleetBox writes fleet home's box pi-1 with a capped refusal
+// list (101 refused, 1 listed, none of them the caller's) and a rollout
+// report for hosts.
+func writeCappedFleetBox(t *testing.T, fx *consoleFixture, hosts map[string]status.HostRollout) {
+ t.Helper()
b := status.Box{GeneratedAt: time.Now(), Label: "pi-1", Metrics: &status.BoxMetrics{
ConfigRefusalsTotal: 101, ConfigRefusals: []status.ConfigRefusal{refusedAt("n.other.example.net", "no_key", 1)},
- Rollout: &status.RolloutReport{Hosts: map[string]status.HostRollout{
- rootfsShopHost: {Account: fx.sqid, App: "shop", Installed: "r1", Awake: true}}}}}
+ Rollout: &status.RolloutReport{Hosts: hosts}}}
if err := status.WriteBox(context.Background(), refusalBoxStore(fx, "home"), b); err != nil {
t.Fatal(err)
}
+}
+
+// The capped report is the row's box's, and only a fleet box of the caller's
+// own fleet makes it (its owner can read that box's journal): a row a capped
+// fleet box reports asleep is marked, and so is a row no box reports on a
+// fleet with a capped box (a refused instance is the one a box does not
+// report).
+func TestInstanceListCappedReportIsTheRowsBoxs(t *testing.T) {
+ fx, token := rootfsReadyFleetApp(t, "code-refusal-capped-box", false)
+ createShops(t, fx, token, rootfsShopHost, rootfsSecondHost)
+ writeCappedFleetBox(t, fx, map[string]status.HostRollout{
+ rootfsShopHost: {Account: fx.sqid, App: "shop", Installed: "r1", Good: "r1", Awake: false}})
rows := listedRefusals(t, fx, token)
if !rows[rootfsShopHost].Capped {
- t.Fatalf("%s is reported by the capped box pi-1 and is not marked", rootfsShopHost)
+ t.Fatalf("%s is asleep on the capped box pi-1 and is not marked", rootfsShopHost)
}
- // Unreported by any box, on fleet home, which has a capped box: a refused
- // instance is the one a box does not report, so it is marked too.
if !rows[rootfsSecondHost].Capped {
t.Fatalf("%s is unreported on a fleet with a capped box and is not marked", rootfsSecondHost)
}
}
+
+// A row the capped box has awake is not refused by it: no capped REASON on a
+// healthy row.
+func TestInstanceListCappedReasonSkipsAwakeRows(t *testing.T) {
+ fx, token := rootfsReadyFleetApp(t, "code-refusal-capped-awake", false)
+ createShops(t, fx, token, rootfsShopHost, rootfsSecondHost)
+ writeCappedFleetBox(t, fx, map[string]status.HostRollout{
+ rootfsShopHost: {Account: fx.sqid, App: "shop", Installed: "r1", Serving: "r1", Good: "r1", Awake: true}})
+ rows := listedRefusals(t, fx, token)
+ if got := rows[rootfsShopHost]; got.Capped || got.Refusal != nil {
+ t.Fatalf("%s is awake on the capped box and carries capped=%v %s", rootfsShopHost, got.Capped, got.Raw)
+ }
+ // The control: the unreported row on the same fleet is still marked, so
+ // the awake row is skipped for being awake and not for a dead join.
+ if !rows[rootfsSecondHost].Capped {
+ t.Fatalf("the control %s is not marked: the join did not read the capped box", rootfsSecondHost)
+ }
+}
+
+// A platform box carries many tenants: its capped list is mostly other
+// accounts' refusals, and a customer cannot read its journal. It never puts
+// the capped report on a caller's row, whether the box reports the row
+// asleep or does not report it at all.
+func TestInstanceListCappedReasonNeverOnPlatformBoxes(t *testing.T) {
+ fx, token := rootfsReadyFleetApp(t, "code-refusal-capped-platform", false)
+ createShops(t, fx, token, rootfsShopHost, rootfsSecondHost)
+ b := status.Box{GeneratedAt: time.Now(), Label: "ie-1", Metrics: &status.BoxMetrics{
+ ConfigRefusalsTotal: 101, ConfigRefusals: []status.ConfigRefusal{refusedAt("n.other.example.net", "no_key", 1)},
+ Rollout: &status.RolloutReport{Hosts: map[string]status.HostRollout{
+ rootfsShopHost: {Account: fx.sqid, App: "shop", Installed: "r1", Good: "r1", Awake: false}}}}}
+ if err := status.WriteBox(context.Background(), fx.rel, b); err != nil {
+ t.Fatal(err)
+ }
+ for host, got := range listedRefusals(t, fx, token) {
+ if got.Capped || got.Refusal != nil {
+ t.Fatalf("%s carries capped=%v %s from a capped platform box", host, got.Capped, got.Raw)
+ }
+ }
+}