Skip to content

fix(classifier-match): allow same-direction delegation bus access connections (AADL v2.3 §9.4)#216

Open
avrabe wants to merge 3 commits into
mainfrom
fix/v0.9.x-classifier-match-delegation
Open

fix(classifier-match): allow same-direction delegation bus access connections (AADL v2.3 §9.4)#216
avrabe wants to merge 3 commits into
mainfrom
fix/v0.9.x-classifier-match-delegation

Conversation

@avrabe
Copy link
Copy Markdown
Contributor

@avrabe avrabe commented May 12, 2026

Reproducer

package Repro
public
  with Buses;

  device InnerDevice
  features
    eth : provides bus access Buses::Ethernet;
  end InnerDevice;

  system Outer
  features
    eth_ext : provides bus access Buses::Ethernet;
  end Outer;

  system implementation Outer.impl
    subcomponents
      inner : device InnerDevice;
    connections
      -- Delegation: both 'provides' — valid per AADL v2.3 §9.4
      c_eth : bus access eth_ext <-> inner.eth;
  end Outer.impl;
end Repro;

Expected: no error. Actual on v0.9.3: classifier_match: connection 'c_eth': both source 'eth_ext' and destination 'eth' are 'provides' — access connections require provides ↔ requires pairing. User reports 32 occurrences in their real OEM SIP-internal wiring model on x86_64-linux.

Summary

  • Bug: spar applied the peer-connection rule (providesrequires) uniformly to every access connection, falsely flagging valid delegation connections where both ends are provides (or both requires).
  • Root cause: check_access_match in classifier_match.rs didn't distinguish peer from delegation; it only checked src_ak == dst_ak.
  • Fix: detect delegation as "exactly one endpoint's ConnectionEnd.subcomponent is None" (i.e. that end references the enclosing component's own feature, not a subcomponent's). For delegation, directions must MATCH; for peer, they must oppose. Existing peer-error wording is preserved verbatim (golden-test stable); delegation mismatches use fresh wording.
  • Spec: AADL v2.3 / AS5506D §9.4. Same rule applies to data-access and subprogram-access connections, which share the code path and benefit uniformly.

Test plan

  • bus_access_delegation_both_provides_ok — exact user MWE; no diagnostic.
  • bus_access_delegation_both_requires_ok — same shape, both requires; no diagnostic.
  • bus_access_peer_provides_to_requires_ok — peer regression (Provides ↔ Requires) still clean.
  • bus_access_peer_both_provides_errors — peer regression: both-provides still errors with original wording.
  • bus_access_peer_both_requires_errors — peer regression: both-requires still errors with original wording.
  • bus_access_delegation_directions_mismatch_errors — delegation provides/requires mismatch errors with new wording.

All 38 classifier_match tests pass; cargo clippy --workspace --all-targets -- -D warnings clean; cargo fmt clean.

🤖 Generated with Claude Code

…nections (AADL v2.3 §9.4)

Per AADL v2.3 §9.4 access connections come in two kinds: peer
(subcomponent ↔ subcomponent) where directions must oppose, and
delegation (enclosing-feature ↔ subcomponent-feature) where the
enclosing feature delegates its role inward and directions must
MATCH. spar previously applied the peer rule uniformly, causing
false-positive errors on valid delegation connections like
`bus access eth_ext <-> inner.eth` where both ends are `provides`.

Detection: a connection is a delegation iff exactly one
`ConnectionEnd.subcomponent` is `None` (the side referencing the
enclosing component's own feature). For delegation, mismatched
directions now error with fresh wording; for peer connections,
same-direction continues to error with the existing wording.

User-reported on v0.9.3 with 32 occurrences in real OEM SIP-internal
wiring.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@avrabe avrabe enabled auto-merge (squash) May 12, 2026 16:00
@codecov
Copy link
Copy Markdown

codecov Bot commented May 12, 2026

Codecov Report

❌ Patch coverage is 99.59677% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/spar-analysis/src/classifier_match.rs 99.59% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

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.

1 participant