fix(operad): skip WF-level type check when LINK matches additional_port_pair#35
Merged
MSD21091969 merged 1 commit intomasterfrom May 4, 2026
Merged
Conversation
ValidateStrataLink rule 2 (WF-level src_types/tgt_types) ran before rule 3 (pair-level types), so an additional_port_pair declaring tgt_types=["*"] could not admit a tgt type that fell outside the WF-level list. Concretely this rejected `session --pins-urn--> purpose` even though WF19's pins-urn pair declares wildcard tgt_types — because "purpose" is not in WF19's primary tgt_types [kernel, session, agent_session, user, agent]. Fix: when the envelope's (src_port, tgt_port) matches a declared AdditionalPortPair, the pair's own SrcTypes/TgtTypes (rule 3) govern type allowance entirely. Rule 2 still applies to primary-pair LINKs. The ontology's intent — additional pairs may admit tgt types narrower OR wider than the WF-level — is now honored. New test TestValidateStrataLink_AdditionalPair_WildcardOverridesNarrowWF locks the behavior with a fixture whose WF-level TgtTypes does NOT include "program", proving the wildcard pair admits it via rule 3 alone. All existing tests pass (operad + fold + graph + hdc + kernel + reactive + tday + transport). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR adjusts operad.Registry.ValidateStrataLink so that LINK validation for additional WF port-pairs can use the additional pair’s own SrcTypes/TgtTypes rules (including tgt_types=["*"]), fixing a loader/validation gap that previously rejected WF19.pins-urn links when the WF-level tgt_types list was narrower than the pair-level rule.
Changes:
- Reorders/rewrites
ValidateStrataLinktype checks to treat additional-port-pair LINKs differently from primary-pair LINKs. - Adds a regression test ensuring an additional pair with
tgt_types=["*"]can admit a target type excluded from the WF-level list.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| internal/operad/validate.go | Changes how WF-level vs additional-pair-level src_types/tgt_types constraints are applied during strata LINK validation. |
| internal/operad/validate_link_pair_test.go | Adds a regression test for wildcard additional-pair behavior when WF-level tgt_types is narrow. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+362
to
+372
| // Rule 3: pair-level src_types/tgt_types enforcement (additional-pair LINKs). | ||
| // A tgt_types entry of "*" is a wildcard per the ontology convention (see | ||
| // WF19.pins-urn in ontology.json v3.12): any tgt type passes. | ||
| if len(pair.SrcTypes) > 0 && !containsTypeID(pair.SrcTypes, srcNode.TypeID) { | ||
| return fmt.Errorf("operad: src type %q not allowed on pair (%s, %s) of %s: %v", | ||
| srcNode.TypeID, env.SrcPort, env.TgtPort, env.RewriteCategory, pair.SrcTypes) | ||
| } | ||
| if len(pair.TgtTypes) > 0 && !containsTypeID(pair.TgtTypes, "*") && | ||
| !containsTypeID(pair.TgtTypes, tgtNode.TypeID) { | ||
| return fmt.Errorf("operad: tgt type %q not allowed on pair (%s, %s) of %s: %v", | ||
| tgtNode.TypeID, env.SrcPort, env.TgtPort, env.RewriteCategory, pair.TgtTypes) |
| // declares tgt_types=[kernel, session, agent_session, user, agent], but the | ||
| // pins-urn additional pair declares tgt_types=["*"]. Pre-fix, ValidateStrataLink | ||
| // ran the WF-level check (rule 2) before the pair-level check (rule 3), which | ||
| // rejected `session --pins-urn--> purpose` because "purpose" is not in the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the kernel loader-gap that blocked `session --pins-urn--> ` LINKs in T=183 sprint. `ValidateStrataLink` rule 2 (WF-level `src_types`/`tgt_types`) ran before rule 3 (pair-level types), so an `additional_port_pair` declaring `tgt_types=[""]` couldn't admit a tgt type that fell outside the WF-level list. Concretely `session --pins-urn--> purpose` was rejected even though WF19's pins-urn pair declares wildcard `tgt_types` — because `purpose` isn't in WF19's primary `tgt_types [kernel, session, agent_session, user, agent]`.
Fix
When the envelope's `(src_port, tgt_port)` matches a declared `AdditionalPortPair`, the pair's own `SrcTypes/TgtTypes` (rule 3) govern type allowance entirely. Rule 2 still applies to primary-pair LINKs. The ontology's intent — additional pairs may admit tgt types narrower OR wider than the WF-level — is now honored.
Test
New `TestValidateStrataLink_AdditionalPair_WildcardOverridesNarrowWF` locks the behavior with a fixture whose WF-level `TgtTypes` does NOT include `program`, proving the wildcard pair admits it via rule 3 alone.
All existing tests pass:
```
ok moos/kernel/internal/fold 2.709s
ok moos/kernel/internal/graph 2.649s
ok moos/kernel/internal/hdc 2.483s
ok moos/kernel/internal/kernel 1.991s
ok moos/kernel/internal/operad 5.219s
ok moos/kernel/internal/reactive 1.419s
ok moos/kernel/internal/tday 1.394s
ok moos/kernel/internal/transport 2.449s
```
Verified live
After deploying the new binary on hp-laptop `:8000`, fired 13 pins-urn LINKs (`session:sam.t187-mvp` pinning its full scope: 1 purpose + 8 programs + 3 derivations + 1 grammar_fragment). All accepted.
Test plan
🤖 Generated with Claude Code