Skip to content

fix(operad): skip WF-level type check when LINK matches additional_port_pair#35

Merged
MSD21091969 merged 1 commit intomasterfrom
guido/r16-loader-additional-pair-typing
May 4, 2026
Merged

fix(operad): skip WF-level type check when LINK matches additional_port_pair#35
MSD21091969 merged 1 commit intomasterfrom
guido/r16-loader-additional-pair-typing

Conversation

@MSD21091969
Copy link
Copy Markdown
Collaborator

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

  • CI green
  • Verify on z440 federation kernels: deploy new binary; existing primary-pair LINKs still validate; pins-urn / has-occupant / mounts-tool / filtered-by additional pairs now admit their declared wildcard or narrowed types

🤖 Generated with Claude Code

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>
Copilot AI review requested due to automatic review settings May 4, 2026 08:20
@MSD21091969 MSD21091969 merged commit fc0a848 into master May 4, 2026
2 checks passed
@MSD21091969 MSD21091969 deleted the guido/r16-loader-additional-pair-typing branch May 4, 2026 08:21
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ValidateStrataLink type 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants