Make the B1 survey a command, which immediately falsified B1.
B1 was found with a shell pipeline and published as a finding. The review it
appeared in had already argued that a mechanical check nobody can re-run is an
assertion, and §11's entire claim is mechanical checkability — so asserting B1
unmechanically was that defect committed by the repository reporting it.
tools/survey_layer_declarations.go reads both §11 forms per repository, reports
intra-repository disagreement, and writes a receipt. Run once, it showed the
published B1 was wrong: the estate does not spell layer: three ways across
repositories. The original pipeline took the first ^layer: match per repository
without recording which file it came from, reporting one value where there were
two.
The corrected finding is stronger. Nine of nine repositories carrying both §11
forms declare a different value in each: INTENT.md says Engine/Staff, layer.yaml
says engine/staff. The disagreement is within each repository, between the two
forms §11 permits, and it is universal rather than careless — two generators, two
conventions. Nobody is inconsistent with anybody else.
That relocates the question from casing to precedence: §11 accepts either form
and does not say which governs when both exist and disagree, so a conformance run
reading INTENT.md and one reading layer.yaml reach different answers for nine
repositories while both follow §11. flex-auth is the only declared repository
that cannot exhibit this, and only because it never wrote the second file.
The correction is recorded in the review rather than edited away: a published
review corrected silently is FLEX-DEC-2026-008's defect, and that rule has no
exception for the reviewer.
Four tests cover the disagreement case, the refusal to fold case, a missing
declaration, and the single-form shape that must not read as self-disagreement.
The survey checks only the §3 vocabulary and never applies flex-auth's house
rules to peers.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Assistant: claude-code
Assistant-Model: opus
Assistant-Process: 28468@bnt-lap001
Assistant-Session: c76569b2-6056-4dad-aea4-49cd7a018f5d
2026-09-21 01:24:15 +02:00
|
|
|
package layer_test
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"os"
|
|
|
|
|
"path/filepath"
|
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
"github.com/netkingdom/flex-auth/internal/layer"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func writeRepo(t *testing.T, root, name, intent, declFile string) {
|
|
|
|
|
t.Helper()
|
|
|
|
|
dir := filepath.Join(root, name)
|
|
|
|
|
if err := os.MkdirAll(dir, 0o755); err != nil {
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
}
|
|
|
|
|
if intent != "" {
|
|
|
|
|
body := "---\nlayer: " + intent + "\nrole: PDP\n---\n\n# x\n"
|
|
|
|
|
if err := os.WriteFile(filepath.Join(dir, "INTENT.md"), []byte(body), 0o644); err != nil {
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if declFile != "" {
|
|
|
|
|
if err := os.WriteFile(filepath.Join(dir, "layer.yaml"), []byte("layer: "+declFile+"\n"), 0o644); err != nil {
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The finding FLEX-WP-0030 B1 rests on: §11 accepts either form and does not
|
|
|
|
|
// say which governs when a repository carries both and they disagree.
|
|
|
|
|
func TestSurveyDetectsFormsDisagreeingWithinOneRepo(t *testing.T) {
|
|
|
|
|
root := t.TempDir()
|
|
|
|
|
writeRepo(t, root, "peer", "Engine", "engine")
|
|
|
|
|
|
|
|
|
|
rows, err := layer.SurveyDeclarations(root, []string{"peer"})
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
}
|
|
|
|
|
if len(rows) != 1 {
|
|
|
|
|
t.Fatalf("rows = %d; want 1", len(rows))
|
|
|
|
|
}
|
|
|
|
|
if !rows[0].SelfDisagrees() {
|
|
|
|
|
t.Fatal("Engine vs engine across the two §11 forms was not reported as disagreement")
|
|
|
|
|
}
|
|
|
|
|
if got := len(layer.SelfDisagreeing(rows)); got != 1 {
|
|
|
|
|
t.Fatalf("SelfDisagreeing = %d; want 1", got)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Apply gate-house's section 11 rulings: four-token validator, emission guarantee, resource.system.
GH-DEC-2026-017: the validator admitted {Staff, Engine, Tooling}, built from
section 4's catalog rows, and rejected Taxonomy, which section 3.1 defines.
railiance-master was conforming; the validator was the divergent artifact.
Now four tokens, ASCII case folded, section 4's spelling canonical, INTENT.md
governing while form disagreements are still reported, and every run states
its scope (section 11 binds section 4; volunteers are not non-conformances).
Also fixes the survey silently dropping audit-core's layer.yaml by decoding
peers into flex-auth's own struct.
GH-DEC-2026-018: flex-auth is a section 4 source of evidence. G2 closes as a
question and reopens as a dated gap (review 2026-10-19). cadence.yaml
publishes the per-event-class inventory: deny, redact, not_applicable and
audit_only rare load-bearing (heartbeat and reconciliation, rate forbidden);
allow volume load-bearing (expected-rate and reconciliation). INTENT.md
declares source_of_evidence and names it; tests assert both. Delivery is
FLEX-WP-0031.
FLEX-DEC-2026-015: resource.system follows the runtime, not the repository,
answering ops-warden's WARDEN-IN-0003.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Assistant: claude-code
Assistant-Model: opus
Assistant-Process: 63291@bnt-lap001
Assistant-Session: 8bd77868-ca68-4f49-bb1e-d539ecc0d703
2026-09-21 06:35:30 +02:00
|
|
|
// Case IS folded now. GH-DEC-2026-017 §2 ruled comparison ASCII case-insensitive
|
|
|
|
|
// and requires a run to fold before comparing. This test was the inverse
|
|
|
|
|
// assertion while that was the open question; it is inverted rather than
|
|
|
|
|
// deleted, so the ruling is visible in the place the old behaviour lived.
|
|
|
|
|
func TestSurveyFoldsCaseAfterGHDEC017(t *testing.T) {
|
Make the B1 survey a command, which immediately falsified B1.
B1 was found with a shell pipeline and published as a finding. The review it
appeared in had already argued that a mechanical check nobody can re-run is an
assertion, and §11's entire claim is mechanical checkability — so asserting B1
unmechanically was that defect committed by the repository reporting it.
tools/survey_layer_declarations.go reads both §11 forms per repository, reports
intra-repository disagreement, and writes a receipt. Run once, it showed the
published B1 was wrong: the estate does not spell layer: three ways across
repositories. The original pipeline took the first ^layer: match per repository
without recording which file it came from, reporting one value where there were
two.
The corrected finding is stronger. Nine of nine repositories carrying both §11
forms declare a different value in each: INTENT.md says Engine/Staff, layer.yaml
says engine/staff. The disagreement is within each repository, between the two
forms §11 permits, and it is universal rather than careless — two generators, two
conventions. Nobody is inconsistent with anybody else.
That relocates the question from casing to precedence: §11 accepts either form
and does not say which governs when both exist and disagree, so a conformance run
reading INTENT.md and one reading layer.yaml reach different answers for nine
repositories while both follow §11. flex-auth is the only declared repository
that cannot exhibit this, and only because it never wrote the second file.
The correction is recorded in the review rather than edited away: a published
review corrected silently is FLEX-DEC-2026-008's defect, and that rule has no
exception for the reviewer.
Four tests cover the disagreement case, the refusal to fold case, a missing
declaration, and the single-form shape that must not read as self-disagreement.
The survey checks only the §3 vocabulary and never applies flex-auth's house
rules to peers.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Assistant: claude-code
Assistant-Model: opus
Assistant-Process: 28468@bnt-lap001
Assistant-Session: c76569b2-6056-4dad-aea4-49cd7a018f5d
2026-09-21 01:24:15 +02:00
|
|
|
root := t.TempDir()
|
|
|
|
|
writeRepo(t, root, "peer", "", "engine")
|
|
|
|
|
|
|
|
|
|
rows, _ := layer.SurveyDeclarations(root, []string{"peer"})
|
Apply gate-house's section 11 rulings: four-token validator, emission guarantee, resource.system.
GH-DEC-2026-017: the validator admitted {Staff, Engine, Tooling}, built from
section 4's catalog rows, and rejected Taxonomy, which section 3.1 defines.
railiance-master was conforming; the validator was the divergent artifact.
Now four tokens, ASCII case folded, section 4's spelling canonical, INTENT.md
governing while form disagreements are still reported, and every run states
its scope (section 11 binds section 4; volunteers are not non-conformances).
Also fixes the survey silently dropping audit-core's layer.yaml by decoding
peers into flex-auth's own struct.
GH-DEC-2026-018: flex-auth is a section 4 source of evidence. G2 closes as a
question and reopens as a dated gap (review 2026-10-19). cadence.yaml
publishes the per-event-class inventory: deny, redact, not_applicable and
audit_only rare load-bearing (heartbeat and reconciliation, rate forbidden);
allow volume load-bearing (expected-rate and reconciliation). INTENT.md
declares source_of_evidence and names it; tests assert both. Delivery is
FLEX-WP-0031.
FLEX-DEC-2026-015: resource.system follows the runtime, not the repository,
answering ops-warden's WARDEN-IN-0003.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Assistant: claude-code
Assistant-Model: opus
Assistant-Process: 63291@bnt-lap001
Assistant-Session: 8bd77868-ca68-4f49-bb1e-d539ecc0d703
2026-09-21 06:35:30 +02:00
|
|
|
if !rows[0].File.InVocabulary {
|
|
|
|
|
t.Fatal(`"engine" was rejected; a lowercase declaration is conforming, not tolerated`)
|
|
|
|
|
}
|
|
|
|
|
if rows[0].File.Canonical != "Engine" {
|
|
|
|
|
t.Fatalf("Canonical = %q; want the §4 column spelling Engine", rows[0].File.Canonical)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The two forms disagreeing only in spelling is still reported — precedence
|
|
|
|
|
// says which value is the repository's answer, it does not say the
|
|
|
|
|
// disagreement did not happen (GH-DEC-2026-017 §1) — but it is not a
|
|
|
|
|
// disagreement about a LAYER.
|
|
|
|
|
func TestSpellingDisagreementIsReportedButIsNotALayerDisagreement(t *testing.T) {
|
|
|
|
|
root := t.TempDir()
|
|
|
|
|
writeRepo(t, root, "peer", "Engine", "engine")
|
|
|
|
|
|
|
|
|
|
rows, _ := layer.SurveyDeclarations(root, []string{"peer"})
|
|
|
|
|
if !rows[0].SelfDisagrees() {
|
|
|
|
|
t.Fatal("the form disagreement was not reported; it is a finding in its own right")
|
|
|
|
|
}
|
|
|
|
|
if rows[0].DisagreesOnLayer() {
|
|
|
|
|
t.Fatal("Engine vs engine was reported as a disagreement about a layer; two spellings of Engine do not describe two boundaries")
|
|
|
|
|
}
|
|
|
|
|
if rows[0].Layer() != "Engine" {
|
|
|
|
|
t.Fatal("INTENT.md governs; the repository's answer is its INTENT.md value")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Taxonomy is in the vocabulary, and railiance-master — which declares it and
|
|
|
|
|
// is not a §4 row — is a volunteer, not a non-conformance.
|
|
|
|
|
func TestTaxonomyVolunteerIsInVocabularyAndOutOfScope(t *testing.T) {
|
|
|
|
|
root := t.TempDir()
|
|
|
|
|
writeRepo(t, root, "railiance-master", "Taxonomy", "")
|
|
|
|
|
|
|
|
|
|
rows, _ := layer.SurveyDeclarations(root, []string{"railiance-master"})
|
|
|
|
|
if !rows[0].Intent.InVocabulary {
|
|
|
|
|
t.Fatal("Taxonomy was rejected: §3.1 defines it and §4 catalogues it twice")
|
|
|
|
|
}
|
|
|
|
|
if rows[0].InCatalog {
|
|
|
|
|
t.Fatal("railiance-master was treated as a §4 catalog row")
|
|
|
|
|
}
|
|
|
|
|
if got := layer.VolunteerDeclarations(rows); len(got) != 1 || got[0] != "railiance-master" {
|
|
|
|
|
t.Fatalf("VolunteerDeclarations = %v; want [railiance-master]", got)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// §11 binds §4, and A11 requires a run to state what it ranged over.
|
|
|
|
|
func TestRunStatesItsScope(t *testing.T) {
|
|
|
|
|
repos := []string{"flex-auth", "gate-house", "railiance-master"}
|
|
|
|
|
|
|
|
|
|
catalog := layer.CatalogScope(repos)
|
|
|
|
|
if catalog.Statement == "" {
|
|
|
|
|
t.Fatal("a scope with no statement cannot be acted on")
|
|
|
|
|
}
|
|
|
|
|
if len(catalog.Repos) != 2 {
|
|
|
|
|
t.Fatalf("CatalogScope = %v; want the two §4 rows (flex-auth is the access-engine row)", catalog.Repos)
|
|
|
|
|
}
|
|
|
|
|
if !layer.InCatalog("flex-auth") || !layer.InCatalog("access-engine") {
|
|
|
|
|
t.Fatal("the §4 row resolves under both names until the ruled rename lands")
|
|
|
|
|
}
|
|
|
|
|
if layer.InCatalog("railiance-master") {
|
|
|
|
|
t.Fatal("railiance-master is not a §4 row")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
estate := layer.EstateScope(repos)
|
|
|
|
|
if len(estate.Repos) != 3 || estate.Name == catalog.Name {
|
|
|
|
|
t.Fatal("the estate-wide run and the §4 run must be distinguishable; they answer different questions")
|
Make the B1 survey a command, which immediately falsified B1.
B1 was found with a shell pipeline and published as a finding. The review it
appeared in had already argued that a mechanical check nobody can re-run is an
assertion, and §11's entire claim is mechanical checkability — so asserting B1
unmechanically was that defect committed by the repository reporting it.
tools/survey_layer_declarations.go reads both §11 forms per repository, reports
intra-repository disagreement, and writes a receipt. Run once, it showed the
published B1 was wrong: the estate does not spell layer: three ways across
repositories. The original pipeline took the first ^layer: match per repository
without recording which file it came from, reporting one value where there were
two.
The corrected finding is stronger. Nine of nine repositories carrying both §11
forms declare a different value in each: INTENT.md says Engine/Staff, layer.yaml
says engine/staff. The disagreement is within each repository, between the two
forms §11 permits, and it is universal rather than careless — two generators, two
conventions. Nobody is inconsistent with anybody else.
That relocates the question from casing to precedence: §11 accepts either form
and does not say which governs when both exist and disagree, so a conformance run
reading INTENT.md and one reading layer.yaml reach different answers for nine
repositories while both follow §11. flex-auth is the only declared repository
that cannot exhibit this, and only because it never wrote the second file.
The correction is recorded in the review rather than edited away: a published
review corrected silently is FLEX-DEC-2026-008's defect, and that rule has no
exception for the reviewer.
Four tests cover the disagreement case, the refusal to fold case, a missing
declaration, and the single-form shape that must not read as self-disagreement.
The survey checks only the §3 vocabulary and never applies flex-auth's house
rules to peers.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Assistant: claude-code
Assistant-Model: opus
Assistant-Process: 28468@bnt-lap001
Assistant-Session: c76569b2-6056-4dad-aea4-49cd7a018f5d
2026-09-21 01:24:15 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestSurveyReportsMissingDeclaration(t *testing.T) {
|
|
|
|
|
root := t.TempDir()
|
|
|
|
|
writeRepo(t, root, "silent", "", "")
|
|
|
|
|
|
|
|
|
|
rows, _ := layer.SurveyDeclarations(root, []string{"silent"})
|
|
|
|
|
if rows[0].Declared() {
|
|
|
|
|
t.Fatal("a repository with neither form was reported as declared")
|
|
|
|
|
}
|
|
|
|
|
if got := layer.Undeclared(rows); len(got) != 1 || got[0] != "silent" {
|
|
|
|
|
t.Fatalf("Undeclared = %v; want [silent]", got)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// A single well-formed declaration must not be reported as disagreeing with
|
|
|
|
|
// itself — flex-auth is exactly this shape.
|
|
|
|
|
func TestSurveySingleFormIsNotDisagreement(t *testing.T) {
|
|
|
|
|
root := t.TempDir()
|
|
|
|
|
writeRepo(t, root, "solo", "Engine", "")
|
|
|
|
|
|
|
|
|
|
rows, _ := layer.SurveyDeclarations(root, []string{"solo"})
|
|
|
|
|
if rows[0].SelfDisagrees() {
|
|
|
|
|
t.Fatal("a repository with only INTENT.md was reported as self-disagreeing")
|
|
|
|
|
}
|
|
|
|
|
if !rows[0].Intent.InVocabulary {
|
|
|
|
|
t.Fatal(`"Engine" was rejected from the §3 vocabulary`)
|
|
|
|
|
}
|
|
|
|
|
}
|
Apply gate-house's section 11 rulings: four-token validator, emission guarantee, resource.system.
GH-DEC-2026-017: the validator admitted {Staff, Engine, Tooling}, built from
section 4's catalog rows, and rejected Taxonomy, which section 3.1 defines.
railiance-master was conforming; the validator was the divergent artifact.
Now four tokens, ASCII case folded, section 4's spelling canonical, INTENT.md
governing while form disagreements are still reported, and every run states
its scope (section 11 binds section 4; volunteers are not non-conformances).
Also fixes the survey silently dropping audit-core's layer.yaml by decoding
peers into flex-auth's own struct.
GH-DEC-2026-018: flex-auth is a section 4 source of evidence. G2 closes as a
question and reopens as a dated gap (review 2026-10-19). cadence.yaml
publishes the per-event-class inventory: deny, redact, not_applicable and
audit_only rare load-bearing (heartbeat and reconciliation, rate forbidden);
allow volume load-bearing (expected-rate and reconciliation). INTENT.md
declares source_of_evidence and names it; tests assert both. Delivery is
FLEX-WP-0031.
FLEX-DEC-2026-015: resource.system follows the runtime, not the repository,
answering ops-warden's WARDEN-IN-0003.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Assistant: claude-code
Assistant-Model: opus
Assistant-Process: 63291@bnt-lap001
Assistant-Session: 8bd77868-ca68-4f49-bb1e-d539ecc0d703
2026-09-21 06:35:30 +02:00
|
|
|
|
|
|
|
|
// A peer's declaration is read for layer and role only. A peer carrying a field
|
|
|
|
|
// flex-auth also uses, in a different shape, must not drop out of the survey.
|
|
|
|
|
func TestPeerWithForeignFieldShapesIsStillSurveyed(t *testing.T) {
|
|
|
|
|
root := t.TempDir()
|
|
|
|
|
dir := filepath.Join(root, "audit-core")
|
|
|
|
|
if err := os.MkdirAll(dir, 0o755); err != nil {
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
}
|
|
|
|
|
body := "layer: engine\nrole: evidence\nemission_guarantee:\n - id: chain-head-attestation\n"
|
|
|
|
|
if err := os.WriteFile(filepath.Join(dir, "layer.yaml"), []byte(body), 0o644); err != nil {
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
}
|
|
|
|
|
rows, _ := layer.SurveyDeclarations(root, []string{"audit-core"})
|
|
|
|
|
if !rows[0].File.Found || rows[0].File.Canonical != "Engine" {
|
|
|
|
|
t.Fatalf("audit-core's layer.yaml was dropped: %+v", rows[0].File)
|
|
|
|
|
}
|
|
|
|
|
}
|