Skip to content

fix(program): prune provenance spans that do not resolve in attached file source - #410

Merged
Teakowa merged 1 commit into
mainfrom
fix/583-span-prune-on-file-source
Oct 9, 2026
Merged

Teakowa merged 1 commit into
mainfrom
fix/583-span-prune-on-file-source

Conversation

@e54-bot

@e54-bot e54-bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Program::set_file_source retains a member's authored text after a source map rebinds the file table. A provider map can record a span whose extent is not a position in that text — OPY macro expansion attributes expanded tokens by shifting them onto the invocation site, so a recorded end column can run past the authored line (wrightkit/wright#583: bastion's composition/bootstrap.opy rule spans, overwatch-ai-pve's utilities/hero_switch.opy conditions). Once source is retained, Program::validate bounds-checks every provenance span and the stale position fails the whole load with invalid-span.

Attaching text now audits provenance the same way record_identities retires displaced records: a span that does not resolve inside the retained document is cleared, so the node survives with no span rather than a wrong one. Consumers keep every span that is still addressable; lint fix extents derived from surviving spans stay trustworthy.

The underlying opy-rs macro-attribution defect is filed separately.

Test plan

  • file_source_retention_prunes_spans_outside_the_text — attached text shorter than the recorded rule span clears it; spans that fit survive; Program::validate passes
  • wright end-to-end against real OPY projects (bastion, overwatch-ai-pve) with a path dep: compile, lint, analyze all succeed where the 1.12.0 build failed with invalid-span
  • cargo fmt --all -- --check, cargo clippy -p workshop-rs --all-targets -- -D warnings, cargo test -p workshop-rs

…file source

A provider map can record a span whose extent is not a position in the
authored member: OPY macro expansion attributes expanded tokens by
shifting them onto the invocation site, so a recorded end column runs
past the authored line (wrightkit/wright#583, e.g. bastion's
composition/bootstrap.opy rule spans). Once set_file_source retains that
member's text, Program::validate bounds-checks every provenance span
against the document and the stale position fails the whole load with
invalid-span.

Attaching text now audits provenance the same way record_identities
retires displaced records: a span that does not resolve inside the
retained document is cleared so the node survives with no span rather
than a wrong one. Consumers keep every span that is still addressable,
and lint fix extents derived from surviving spans stay trustworthy.
@Teakowa
Teakowa merged commit b0cf645 into main Oct 9, 2026
3 checks passed
@Teakowa
Teakowa deleted the fix/583-span-prune-on-file-source branch October 9, 2026 18:10
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