agent v0.86.0: DR-tier-by-default — capability inactive state (GatedBy/GateActive, pbsdr gate via DRConfigured) + F-3 root-run provision parent ownership
Claude-Session: https://claude.ai/code/session_01NptTCFtu7dz2Ru89qHRagN
This commit is contained in:
@@ -115,3 +115,82 @@ func TestProbe_NilRunnerNoPanic(t *testing.T) {
|
||||
t.Fatalf("nil-runner probe returned %d statuses, want %d", got, len(Manifest()))
|
||||
}
|
||||
}
|
||||
|
||||
// ── DR-tier gate (v0.86.0) ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
// Gate OFF + healthy plumbing → the gated pbsdr-* capabilities report INACTIVE (the neutral
|
||||
// "disabled by configuration" state), NOT ok and NOT degraded — Scenario B of the DR-by-default
|
||||
// spec. Ungated siblings are untouched. Red-proof partner: collapse inactive into ok (drop the
|
||||
// gate branch in Probe) → this fails while TestProbe_GateOffBinaryMissingStaysDegraded passes.
|
||||
func TestProbe_GateOffHealthyIsInactive(t *testing.T) {
|
||||
r := &fakeRunner{denyBinary: map[string]bool{}}
|
||||
p := Prober{
|
||||
Runner: r,
|
||||
Exists: func(string) bool { return true },
|
||||
GateActive: func(gate string) bool { return gate != GatePBSDR }, // DR tier OFF
|
||||
}
|
||||
statuses := p.Probe(context.Background())
|
||||
for _, name := range []string{"pbsdr-create", "pbsdr-reconcile", "pbsdr-grant"} {
|
||||
s := find(statuses, name)
|
||||
if s.Status != StatusInactive || s.Reason != ReasonInactive {
|
||||
t.Fatalf("%s = %+v, want inactive/%q", name, s, ReasonInactive)
|
||||
}
|
||||
}
|
||||
// An ungated sibling stays plain ok.
|
||||
if s := find(statuses, "drive-bind"); s.Status != StatusOK {
|
||||
t.Fatalf("drive-bind = %+v, want ok (ungated)", s)
|
||||
}
|
||||
// Summarize must NOT count inactive as degraded (it is not error-log-worthy).
|
||||
ok, total, degraded := Summarize(statuses)
|
||||
if len(degraded) != 0 {
|
||||
t.Fatalf("inactive leaked into degraded: %+v", degraded)
|
||||
}
|
||||
if ok != total-3 {
|
||||
t.Fatalf("ok=%d total=%d, want exactly the 3 gated ones non-ok", ok, total)
|
||||
}
|
||||
}
|
||||
|
||||
// Gate OFF + BROKEN plumbing (binary missing) → DEGRADED stays degraded. An un-migrated
|
||||
// pre-v1.15.0 box must never masquerade as deliberately disabled ("never silently pretend").
|
||||
func TestProbe_GateOffBinaryMissingStaysDegraded(t *testing.T) {
|
||||
r := &fakeRunner{denyBinary: map[string]bool{}}
|
||||
p := Prober{
|
||||
Runner: r,
|
||||
Exists: func(path string) bool { return path != "/usr/local/sbin/felhom-pbs-apply" },
|
||||
GateActive: func(gate string) bool { return gate != GatePBSDR }, // DR tier OFF
|
||||
}
|
||||
statuses := p.Probe(context.Background())
|
||||
for _, name := range []string{"pbsdr-create", "pbsdr-reconcile", "pbsdr-grant"} {
|
||||
s := find(statuses, name)
|
||||
if s.Status != StatusDegraded || s.Reason != "binary not found" {
|
||||
t.Fatalf("%s = %+v, want degraded/binary not found even with the gate off", name, s)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Gate ON (DR configured) + healthy plumbing → plain ok, exactly the pre-v0.86.0 behavior.
|
||||
// A nil GateActive must behave the same (fails ACTIVE).
|
||||
func TestProbe_GateOnOrNilIsOK(t *testing.T) {
|
||||
for _, gate := range []func(string) bool{nil, func(string) bool { return true }} {
|
||||
r := &fakeRunner{denyBinary: map[string]bool{}}
|
||||
p := Prober{Runner: r, Exists: func(string) bool { return true }, GateActive: gate}
|
||||
statuses := p.Probe(context.Background())
|
||||
if s := find(statuses, "pbsdr-create"); s.Status != StatusOK {
|
||||
t.Fatalf("pbsdr-create = %+v, want ok (gate active/nil)", s)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The gate rides the pbsdr- name prefix: exactly the pbsdr-* manifest entries are gated, nothing
|
||||
// else (a regression here would silently un-gate the tier or gate an unrelated capability).
|
||||
func TestManifest_ExactlyPBSDRGated(t *testing.T) {
|
||||
for _, c := range Manifest() {
|
||||
wantGated := strings.HasPrefix(c.Name, "pbsdr-")
|
||||
if gated := c.GatedBy == GatePBSDR; gated != wantGated {
|
||||
t.Fatalf("%s: GatedBy=%q, want gated=%v", c.Name, c.GatedBy, wantGated)
|
||||
}
|
||||
if c.GatedBy != "" && c.GatedBy != GatePBSDR {
|
||||
t.Fatalf("%s: unknown gate id %q", c.Name, c.GatedBy)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user