test(operad): regression coverage for the 4.0.4 member-of pair + port_color_map first use - #65
Conversation
…_color_map first use (#64) No behavior change — pins the enforcement ffs0#172 (ontology 4.0.4) now depends on so a regression fails loudly instead of silently weakening the fail-closed color gate. One new test file, all four #64 asks: 1. WF02 member-of/has-member additional pair is captured by the loader, and ValidateLINK accepts member-of AND delegates-to (both 4.0.x WF02 pairs) while rejecting an undeclared variant with the declared set named. 2. port_color_map first-use coverage: the override merges onto DefaultPortColors (member-of/has-member are absent from the built-ins, so the override is what makes the pair loadable), an ontology color wins over a default, and an unknown color name or JSON null is a LOAD ERROR — a typo or a None-emitting script must not alias onto the exempt "" color. Empty string stays a documented exemption. 3. MOOS_INTEGRATION readback as a test: against the real sibling ontology, every port of every declared pair (primary + additional, all WFs) carries a color, and member-of is present + auth. The loader only WARNS on uncovered ports; this makes it a hard failure for the shipped ontology. 4. the interim manual Doctor-time check recorded in the file header until (3) runs in CI. Verified: `go test ./internal/operad/` green; `MOOS_INTEGRATION=1 go test -run DeclaredPairsAllColored` PASS against ffs0 4.0.4; go vet clean; go build ./... ok. Reuses the shared writeOntology helper from loader_test.go. Closes #64. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds regression tests to the internal/operad ontology loader/validator surface to pin behavior required by the ffs0 ontology 4.0.4 upgrade (notably WF02’s member-of/has-member additional port pair and reliance on port_color_compatibility.port_color_map).
Changes:
- Adds a hermetic ontology fixture test ensuring WF02’s
member-ofadditional pair is loaded intoAdditionalPortPairs. - Adds
ValidateLINKcoverage ensuring WF02 acceptsmember-of/has-member,delegates-to/delegated-by, and the primarygovernspair, while rejecting an undeclared variant with a helpful error. - Adds tests around
port_color_mapbehavior (merge-over-defaults, override wins, unknown/null errors, empty-string exemption) plus aMOOS_INTEGRATION=1check against the sibling real ontology.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // TestLoadRegistry_PortColorMap_OverrideMergesOntoDefaults — the override adds | ||
| // member-of/has-member (absent from DefaultPortColors) WITHOUT dropping the | ||
| // built-in defaults. Merge, not replace. | ||
| func TestLoadRegistry_PortColorMap_OverrideMergesOntoDefaults(t *testing.T) { | ||
| reg, err := LoadRegistry(writeOntology(t, wf02Ontology)) |
There was a problem hiding this comment.
Agreed — removed the duplicated port_color_map unit tests. loader_test.go already covers override-wins / new-port / "" exemption / unknown / null (with synthetic ports). Kept only what was actually missing: the WF02 member-of + delegates-to pair (load + validate) and the real-ontology declared-vs-loaded readback that pins member-of's color specifically. File renamed to member_of_pair_test.go.
…coverage (Copilot #65) loader_test.go already covers the port_color_map merge/unknown/null/exemption surface (with synthetic ports). Removed the redundant unit tests; kept what was genuinely missing: the WF02 member-of/delegates-to pair (load + validate) and the real-ontology declared-vs-loaded readback that pins member-of + every declared pair's color. Renamed the file to match (member_of_pair_test.go). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Closes #64. No behavior change — regression coverage only, pinning the enforcement that ffs0#172 (ontology 4.0.4) now depends on.
Why
member-of/has-memberare absent fromDefaultPortColors, so their color comes only from theport_color_mapoverride — the first load-bearing use of that path. If the override merge, the WF02 pair loading, or the fail-closed color gate regresses, the 4.0.4member-ofLINKs would be silently rejected (or worse, silently weakened). Nothing tested that until now.What (all four #64 asks, one new test file)
member-of/has-member(v4.0.4) alongsidedelegates-to(v3.13);ValidateLINKaccepts both WF02 additional pairs and the primarygoverns, and rejects an undeclared variant with the declared set named.port_color_mapfirst use — the override merges ontoDefaultPortColors(defaults survive), an ontology color wins over a built-in default, and an unknown color name or JSON null is a load error (a typo orNone-emitting script must not alias onto the exempt""). Empty string stays a documented exemption.MOOS_INTEGRATIONreadback as a test — against the real sibling ontology, every port of every declared pair (primary + additional, all WFs) carries a color, andmember-ofis present +auth. The loader only warns on uncovered ports; this makes it a hard failure for the shipped ontology./operad/rewrite-categories+/operad/port-colorsvsontology.jsonat Doctor time) until (3) runs in CI.Verification
go test ./internal/operad/— green (full hermetic suite)MOOS_INTEGRATION=1 go test ./internal/operad/ -run DeclaredPairsAllColored— PASS against ffs0 4.0.4go vet ./internal/operad/clean ·go build ./...okReuses the shared
writeOntologyhelper fromloader_test.go(no duplicate).🤖 Generated with Claude Code