From ec98ba5f0cfc3c0b011320302ca5622351507b34 Mon Sep 17 00:00:00 2001 From: Andreas Trawoeger Date: Wed, 28 Oct 2026 20:51:51 +0100 Subject: [PATCH] test(skills): the vacuity guard takes the claims it judges MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The control computed the body's usage claims into `claims` and then called `skillDocIsVacuous(body, command)`, which computed them AGAIN — the same claims, read twice, for one decision. The guard now takes the claims, so the control computes them once and hands the same slice to both the guard and the loop below. The rule stays one implementation and the red arm still fires on a body that never invokes its command. This is the non-blocking observation opencharly/plugin-box#70's validator review raised, and it is fixed here rather than filed away. Assisted-by: Claude Code minimax/minimax-m3.1-flash:cloud (fully tested and validated) --- candy/plugin-box/skill_doc_flags_test.go | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/candy/plugin-box/skill_doc_flags_test.go b/candy/plugin-box/skill_doc_flags_test.go index 1dc8ccd..c86de85 100644 --- a/candy/plugin-box/skill_doc_flags_test.go +++ b/candy/plugin-box/skill_doc_flags_test.go @@ -296,12 +296,16 @@ func flagSectionBullets(body []string) []docClaim { return out } -// skillDocIsVacuous reports whether a body makes NO usage claim for the command it documents — -// the state in which the control compares nothing in that body, so every assertion about it -// passes by default. The rule lives in a function so that the guard has its own RED ARM: a -// control that cannot fail is not coverage. -func skillDocIsVacuous(body []string, command string) bool { - return len(usageClaims(body, command)) == 0 +// skillDocIsVacuous reports whether a body's usage claims for the command it documents are +// EMPTY — the state in which the control compares nothing in that body, so every assertion +// about it passes by default. The rule lives in a function so that the guard has its own RED +// ARM: a control that cannot fail is not coverage. +// +// It takes the CLAIMS, not the body: the control needs those claims for the loop below, so +// they are computed ONCE and handed to both the guard and the loop. A body-and-command +// signature would recompute them here — the same claims, read twice, for one decision. +func skillDocIsVacuous(claims []docClaim) bool { + return len(claims) == 0 } // TestSkillBodiesDocumentOnlyRealFlags is the control. Every flag the body offers for its own @@ -330,7 +334,7 @@ func TestSkillBodiesDocumentOnlyRealFlags(t *testing.T) { flags, envs := kongSurface(t, tc.grammar) claims := usageClaims(body, tc.command) - if skillDocIsVacuous(body, tc.command) { + if skillDocIsVacuous(claims) { // A body that never invokes its own command is read by NOTHING here: the usage // claims are what tie a flag in the prose to this command's grammar, and a body // with none of them passes every assertion below without being compared to @@ -446,7 +450,7 @@ func TestSkillDocVacuityIsEffective(t *testing.T) { "charly box other --flag", "```", } - if !skillDocIsVacuous(neverInvokes, "charly box build") { + if !skillDocIsVacuous(usageClaims(neverInvokes, "charly box build")) { t.Fatal("the vacuity guard did not fire on a body that never invokes the command it documents") } @@ -457,7 +461,7 @@ func TestSkillDocVacuityIsEffective(t *testing.T) { "charly box build --flag", "```", } - if skillDocIsVacuous(invokes, "charly box build") { + if skillDocIsVacuous(usageClaims(invokes, "charly box build")) { t.Fatal("the vacuity guard fired on a body that DOES invoke the command it documents") } }