carlos / platform Public

Sidecar isolation Task 9 (2/5): status carries the flat-exec report and the workers word (D14)

Additive, private Metrics fields: FlatExec (mode, allowlist, dropped
entries, effective intent, per-host spawn record, inventory or its unknown
reason, flat worker count, D15's closure check) and Layout.Workers with its
reason. The contract allowlist pins each to the field level and the fixture
exercises every one; BuildFleet never names Metrics, so none reaches
fleet.json.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev f7efe00e02867cc910b1119b1a2bb51431c88d48 parent 0bdbe78
2 files changed, +118 −5
  • internal/status/contract_test.go +39 −4
  • internal/status/snapshot.go +79 −1
diff --git a/internal/status/contract_test.go b/internal/status/contract_test.go
index 011e17935..3b76d8cf0 100644
--- a/internal/status/contract_test.go
+++ b/internal/status/contract_test.go
@@ -82,13 +82,24 @@ var allowedBoxKeys = map[string][]string{
"": {"generated_at", "label", "region", "routes", "load", "capacity", "replication", "adoption_running", "config_path_running", "restart_path_running", "expired_canaries", "metrics"},
"routes": {"static", "resident", "hibernating", "awake", "asleep"},
"replication": {"healthy", "lag_seconds"},
- "metrics": {"mem_total_bytes", "mem_avail_bytes", "load1", "disk_free_bytes", "release", "tunnel", "route_versions", "upstreams", "layout", "config_refusals", "config_refusals_total", "release_refusals", "proof_waits", "config_guard", "build_states", "build_states_err", "update_settings", "updates"},
+ "metrics": {"mem_total_bytes", "mem_avail_bytes", "load1", "disk_free_bytes", "release", "tunnel", "route_versions", "upstreams", "layout", "flat_exec", "config_refusals", "config_refusals_total", "release_refusals", "proof_waits", "config_guard", "build_states", "build_states_err", "update_settings", "updates"},
"metrics.route_versions": {wildcardAnyKey},
"metrics.upstreams": {wildcardAnyKey},
"metrics.upstreams.*[]": {"addr", "up", "since", "fails", "last_error"},
- "metrics.layout": {"mode", "rows", "default", "default_blocked"},
- "metrics.layout.rows": {wildcardAnyKey},
- "metrics.layout.rows.*": {"layout", "reason", "note"},
+ // workers and workers_reason (sidecar isolation D11, D14) are the box's
+ // workers readiness word and its private diagnostic.
+ "metrics.layout": {"mode", "rows", "default", "default_blocked", "workers", "workers_reason"},
+ "metrics.layout.rows": {wildcardAnyKey},
+ "metrics.layout.rows.*": {"layout", "reason", "note"},
+ // flat_exec (sidecar isolation D12 to D15) is the box's flat-exec
+ // policy, its per-host spawn record and the inventory of what refuse
+ // would stop. Hostname-bearing, in the private block only, on the same
+ // structural ground as layout above; pinned to the field level so a
+ // future field on a refusal or an inventory row is a publication
+ // decision too.
+ "metrics.flat_exec": {"mode", "allow", "dropped", "intent", "refusals", "inventory", "inventory_unknown", "flat_workers", "closed"},
+ "metrics.flat_exec.refusals[]": {"host", "reason", "since", "last", "count"},
+ "metrics.flat_exec.inventory[]": {"host", "layout", "worker"},
// config_refusals (amadan #213) names hosts and a closed reason word, in
// the private block only. Pinned to the field level so a future field on
// the refusal is a publication decision too.
@@ -332,6 +343,29 @@ func fixtureProbes() status.Probes {
"contract-foreign.internal": {Layout: "foreign",
Reason: `db "x" socket "y" are neither the flat nor the nested defaults`},
},
+ // The workers readiness word and its reason, so both new layout
+ // fields are exercised by the allowlist walk.
+ Workers: "blocked",
+ WorkersReason: "layout intent is flat",
+ }
+
+ // One refusal and one inventory row, with every field set, so the
+ // whole flat_exec block is exercised by the allowlist walk and not
+ // merely permitted by it.
+ flatExec := &status.FlatExecReport{
+ Mode: "refuse",
+ Allow: []string{"contract-allowed.internal"},
+ Dropped: []string{"*.contract.internal"},
+ Intent: "nested",
+ Refusals: []status.FlatExecRefusal{
+ {Host: "contract-flat-refused.internal", Reason: "flat_refused", Since: time.Now().Add(-time.Hour), Last: time.Now(), Count: 3},
+ },
+ Inventory: []status.FlatExecRow{
+ {Host: "contract-flat-refused.internal", Layout: "flat", Worker: true},
+ },
+ InventoryUnknown: "no layout pass is armed on this box",
+ FlatWorkers: 1,
+ Closed: false,
}
return status.Probes{
@@ -339,6 +373,7 @@ func fixtureProbes() status.Probes {
Region: "us-west-1",
Upstreams: upstreams,
Layout: layoutReport,
+ FlatExec: flatExec,
// One refusal so metrics.config_refusals is exercised by the
// allowlist walk and not merely permitted by it.
ConfigRefusals: []status.ConfigRefusal{
diff --git a/internal/status/snapshot.go b/internal/status/snapshot.go
index 4dd9ef44a..089d7f78d 100644
--- a/internal/status/snapshot.go
+++ b/internal/status/snapshot.go
@@ -159,6 +159,13 @@ type Probes struct {
// than guess at a mode. Hostname-keyed, like Aliases and RouteVersions
// above, which is why it lands in Box.Metrics and nowhere else.
Layout *LayoutReport
+ // FlatExec is the box's flat-exec policy report (sidecar isolation D12
+ // to D15): the policy in force, its spawn record and the inventory of
+ // what refuse would stop, built by the caller from the same routes it
+ // listed for Layout. nil means no policy is armed (no agent on this
+ // box), carried through as nothing to report. Hostname-bearing, so it
+ // lands in Box.Metrics and nowhere else.
+ FlatExec *FlatExecReport
// ConfigRefusals is the instances this box is CURRENTLY refusing to take
// because it cannot provide their config (amadan #213), as the host's
// config guard reports them; nil when it refuses nothing. They land in
@@ -251,6 +258,69 @@ type LayoutReport struct {
// box whose Mode is none. Both additive; an old reader ignores them.
Default bool `json:"default,omitempty"`
DefaultBlocked string `json:"default_blocked,omitempty"`
+ // Workers is the box's workers readiness (sidecar isolation D11, D14),
+ // one of the closed words nested, off, waiting_for_prev, blocked:
+ // whether this agent mints and moves worker rows nested. "nested" only
+ // when the start-time readiness holds, the effective intent is nested,
+ // the nested gate answers and claim mode is off; "blocked" is the
+ // readiness holding while one of the other three does not, with
+ // WorkersReason saying which (a private diagnostic, never member
+ // text). Both additive and omitted by a box that predates them.
+ Workers string `json:"workers,omitempty"`
+ WorkersReason string `json:"workers_reason,omitempty"`
+}
+
+// FlatExecReport is the box's flat-exec policy and what it has done or
+// would do (sidecar isolation D12 to D15). PRIVATE, like everything under
+// Box.Metrics: Refusals and Inventory name real hosts.
+//
+// Mode is the policy in force, refuse or report, and Allow the exact hosts
+// CARLOS_FLAT_EXEC_ALLOW names; Dropped is the entries it named that were
+// not valid host shapes, so an operator sees a typo. Intent is the box's
+// effective layout intent with its source, one of the closed words
+// nested, flat_choice, flat_fallback, unknown. Refusals is the spawn
+// record: per host, the last refusal or would-be refusal. Inventory is
+// what refuse would stop, read from the registry at this snapshot (R4-3):
+// every row the agent could spawn through a seam that classifies flat or
+// foreign and is not allowlisted, awake or asleep; InventoryUnknown says
+// why it could not be computed, and an unknown inventory is never empty
+// and never closed. FlatWorkers counts the worker rows classifying flat.
+// Closed is D15's closure check: refuse in force, an empty allowlist, the
+// inventory known, and no worker row flat or foreign.
+type FlatExecReport struct {
+ Mode string `json:"mode"`
+ Allow []string `json:"allow,omitempty"`
+ Dropped []string `json:"dropped,omitempty"`
+ Intent string `json:"intent"`
+ Refusals []FlatExecRefusal `json:"refusals,omitempty"`
+ Inventory []FlatExecRow `json:"inventory,omitempty"`
+ InventoryUnknown string `json:"inventory_unknown,omitempty"`
+ FlatWorkers int `json:"flat_workers"`
+ Closed bool `json:"closed"`
+}
+
+// FlatExecRefusal is one host's last refusal or would-be refusal under the
+// flat-exec policy (D14), the shape ConfigRefusal has: Reason is a closed
+// word (flat_refused, foreign_refused, flat_reported, foreign_reported),
+// never error text; Since is the first record in this stretch, Last the
+// most recent, Count how many spawns were refused or reported. PRIVATE:
+// Host is a real route name.
+type FlatExecRefusal struct {
+ Host string `json:"host"`
+ Reason string `json:"reason"`
+ Since time.Time `json:"since"`
+ Last time.Time `json:"last"`
+ Count int `json:"count"`
+}
+
+// FlatExecRow is one row of the flat-exec inventory (D14): a host the
+// policy would refuse, its layout word (flat or foreign), and whether it
+// is a worker row, which the closure check counts. PRIVATE: Host is a
+// real route name.
+type FlatExecRow struct {
+ Host string `json:"host"`
+ Layout string `json:"layout"`
+ Worker bool `json:"worker,omitempty"`
}
// ConfigRefusal is one host this box is refusing to take because it cannot
@@ -598,6 +668,13 @@ type BoxMetrics struct {
// never reach the public fleet.json. nil (the field absent) means the
// box has no layout pass armed, not "every route reports flat".
Layout *LayoutReport `json:"layout,omitempty"`
+ // FlatExec is Probes.FlatExec carried straight through: the box's
+ // flat-exec policy, spawn record and inventory (sidecar isolation D14),
+ // hostname-bearing and private for the identical reason Layout is.
+ // nil (absent) means no policy is armed on the box, which no agent at
+ // or above this release leaves it, so an old box is told apart from a
+ // box under report.
+ FlatExec *FlatExecReport `json:"flat_exec,omitempty"`
// ConfigRefusals is the hosts this box is refusing to take because it
// cannot provide their config (amadan #213). It is how an operator sees
// that a box is keyless, or holds the wrong key, without reading its
@@ -1043,7 +1120,7 @@ func CollectBox(routes []registry.Route, p Probes, now time.Time) Box {
p.DiskFreeBytes != nil || p.Release != "" || p.Tunnel != "" ||
p.InstanceID != "" || p.Platform != "" || p.SystemChannel != "" || p.System != nil ||
len(routeVersions) > 0 || len(routeServing) > 0 || len(aliasReadings) > 0 || len(p.Upstreams) > 0 ||
- len(routeDBBytes) > 0 || p.Layout != nil || len(p.ConfigRefusals) > 0 || len(p.ReleaseRefusals) > 0 || len(p.ProofWaits) > 0 || p.Rollout != nil || p.ConfigGuard != "" ||
+ len(routeDBBytes) > 0 || p.Layout != nil || p.FlatExec != nil || len(p.ConfigRefusals) > 0 || len(p.ReleaseRefusals) > 0 || len(p.ProofWaits) > 0 || p.Rollout != nil || p.ConfigGuard != "" ||
p.Alerts != nil || p.GeoIP != nil || len(p.BuildStates) > 0 || p.BuildStatesErr != "" ||
p.UpdateSettings != 0 || len(p.Updates) > 0 {
box.Metrics = &BoxMetrics{
@@ -1076,6 +1153,7 @@ func CollectBox(routes []registry.Route, p Probes, now time.Time) Box {
Upstreams: p.Upstreams,
RouteDBBytes: routeDBBytes,
Layout: p.Layout,
+ FlatExec: p.FlatExec,
// A fresh copy: the guard's own slice is its to mutate.
ConfigRefusals: append([]ConfigRefusal(nil), p.ConfigRefusals...),
ConfigRefusalsTotal: p.ConfigRefusalsTotal,