fix: 4 Mythos-hardening fixes (parser spec-conformance + helper footguns)#139
Merged
fix: 4 Mythos-hardening fixes (parser spec-conformance + helper footguns)#139
Conversation
…uns)
All four surfaced by the second Mythos discover pass. The oracle gate
filtered every downstream deployment impact (HIR normalization / analysis
layer each caught the corruption before it reached a decision), so this
PR is scoped as hardening — better diagnostic locality at the parser
layer, and honest docstrings on helpers that would otherwise trap
future contributors.
---
1. **Reject `out in` / `in in` / `out out` feature direction**
`parser/grammar/features.rs:65-82`
AS-5506B §8.1: `feature_direction ::= in | out | in out`. Only the
`in out` combination is legal; the prior code accepted any
`{in,out} {in,out}` pair. HIR `extract_direction()` normalizes the
unknown text to `None` so analyses skipped the feature, but the
diagnostic locality was poor — add an explicit parser error.
2. **Reject non-refined connections without endpoints**
`parser/grammar/connections.rs:22-122`
AS-5506B §9.2: a non-refined connection must have source + arrow +
destination. The prior code guarded the endpoint block on
`IDENT || keyword || SELF_KW`, silently accepting `c1 : port ;`.
The instance-level validator emitted an error later, but locality
was poor. Track whether `refined to` was seen; require endpoints
otherwise.
3. **Extend classifier-rename resolution to `.impl` references**
`hir-def/resolver.rs:359-396`
AS-5506D §4.2: a classifier alias names a type and can be used in
any position a classifier reference can, including `alias.impl_name`.
The prior code gated rename handling on `impl_name.is_none()`, so
`MyAlias.i` returned Unresolved despite a valid rename. Preserve
`impl_name` through the rewrite. Feature-group aliases still only
handle the no-impl case (feature groups have no implementations).
4. **Document `property_eval::eval_numeric` / `numeric_with_unit` as
magnitude-only helpers that strip units**
`hir-def/property_eval.rs:115-168`
Validator found these two functions have zero external callers —
every timing / size analysis in `spar-analysis` routes through
`property_accessors.rs` which has proper unit-factor tables. But
the helper names are misleading: `eval_numeric` silently treats
`5 ms` and `5 ns` as both `5.0`; `numeric_with_unit` drops units
on `BinaryOp`. Add prominent `# Units are silently stripped`
docstring sections + `#[doc(hidden)]` to direct future contributors
at the correct helpers.
---
Workspace: 2,482 tests pass (+6 new regression tests: 3 direction, 2
connection-endpoints, 1 classifier-rename-impl).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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
All four fixes surfaced by the second Mythos discover pass (5 agents on 5 tier-5 files yesterday), then filtered through 4 fresh-session validators (all 4 came back
confirmed-but-no-uca— every bug had a downstream backstop).Since no deployment hazard reaches the controlled process, this PR is scoped as hardening:
Fixes
1. Reject
out in/in in/out outfeature directioncrates/spar-parser/src/grammar/features.rs:65-82AS-5506B §8.1:
feature_direction ::= in | out | in out. Onlyin outis legal. Prior code accepted any{in,out} {in,out}pair. HIRextract_direction()normalized the unknown text toNone(so analyses skipped the feature), but diagnostic locality was poor.2. Reject non-refined connections without endpoints
crates/spar-parser/src/grammar/connections.rs:22-122AS-5506B §9.2: non-refined connections must have source + arrow + destination. Prior code silently accepted
c1 : port ;.compute_semantic_connectionsemitted a "missing endpoint" error later, but diagnostic locality was poor. Trackrefined to; require endpoints otherwise.3. Extend classifier-rename resolution to
.implreferencescrates/spar-hir-def/src/resolver.rs:359-396AS-5506D §4.2: a classifier alias names a type and can be used in any classifier-reference position, including
alias.impl_name. Prior code gated rename handling onimpl_name.is_none(), soMyAlias.ireturnedUnresolveddespite a valid rename. Preserveimpl_namethrough the rewrite. Feature-group aliases still only handle the no-impl case (feature groups have no implementations).4. Document
property_eval::eval_numeric/numeric_with_unitas magnitude-onlycrates/spar-hir-def/src/property_eval.rs:115-168Validator found these functions have zero external callers — every timing/size analysis in
spar-analysisroutes throughproperty_accessors.rswhich carries proper unit-factor tables. But the helper names are misleading:eval_numericsilently treats5 msand5 nsas both5.0;numeric_with_unitdrops units onBinaryOp. Added prominent# Units are silently strippeddocstring sections and#[doc(hidden)]so future contributors are directed atproperty_accessors.rs.Test plan
cargo test --workspace→ 2,482 passed, 0 failed (+6 regression tests: 3 direction, 2 connection-endpoints, 1 classifier-rename-impl).rustup run nightly cargo clippy --workspace --all-targets -- -D warnings→ clean.rustup run nightly cargo fmt --check→ clean.crates/spar-syntax/tests/parser_tests.rs:out_in_feature_direction_is_rejected,in_in_feature_direction_is_rejected,in_out_feature_direction_still_accepted,connection_without_endpoints_is_rejected,refined_connection_may_omit_endpointscrates/spar-hir-def/src/resolver.rs:classifier_renames_resolves_impl_referencePipeline context
Mythos discover + validate now has 5 confirmed findings from 10 files over two days. Today's pass yielded 0 UCAs — a valid outcome. The oracle gate + fresh-session validation doctrine (hallucinations cost more than silence) prevented shipping 4 speculative "urgent" PRs; the actual code changes ended up as hardening because spar's HIR + analysis layer already catches these.
Script templates + first-run ranking: see PR #133 /
scripts/mythos/.🤖 Generated with Claude Code