Skip to content

feat: carry identifier and nested-value provenance in mapped text - #329

Merged
Teakowa merged 1 commit into
mainfrom
feat/mapped-text-provenance-328
Sep 29, 2026
Merged

Teakowa merged 1 commit into
mainfrom
feat/mapped-text-provenance-328

Conversation

@e54-bot

@e54-bot e54-bot commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements #328: the canonical workshop-rs/mapped-text-v1 artifact now carries the provenance surface introduced by the v1.1.0 public API (#326), so provider-generated mapped Workshop programs preserve exact identifier and nested-value source provenance across the provider boundary.

Format extension (all additive, optional members — format ID unchanged):

  • rule entries: name_span, event_name_span
  • action entries: identifier_span (covers Set/Modify * Variable* targets, For * Variable* targets, Assign Member, Call Subroutine callees)
  • condition and action_argument entries: identifier_span plus recursive children ({span?, identifier_span?, children} aligned positionally with the public Value tree: array indices, call arguments, vector x/y/z, player-variable player child)
  • All four entry kinds now accept entries without a coarse span — identifier-only provenance is real (e.g. (expr).member records an identifier span but no value span)

SourceMap::extract emits these members when recorded; SourceMap::apply validates every span and restores them onto the parsed Program. Nested children are positional: entries beyond the reparsed Value tree are dropped (emission can canonicalize value forms), missing positions stay unmapped rather than being guessed — matching Wright's rule that absent exact provenance reports unmapped.

Compatibility: old artifacts without the new members decode and apply unchanged; unknown JSON members are ignored as before. Only span-less entries require a consumer built for the extended contract — which is precisely the consumer that needs identifier provenance.

docs/source-preservation.md documents the extended members and the tolerance/compatibility semantics. ADR-0013 needs no change (it records the decision, not field-level detail).

Test plan

  • cargo test -p workshop-rs --lib tests::source_map — 13/13, including authored-JSON attach, identifier-only round trips, nested-child validation, atomic rejection, backward compatibility
  • cargo test --workspace --all-targets — 235 + 9 + 107 + 15 + 15, all passing; corpus extract → emit → parse → apply covers every mapped position incl. nested paths on real projects
  • cargo fmt --all --check
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo run -p workshop-rs --bin workshop-catalog-gen -- check — DIFF-CHECK-OK
  • git diff --check

Generated with Devin

Providers can now attach rule name/event-name spans, action identifier
spans, and recursive value provenance (identifier spans plus positional
children) through additive optional members on the existing
workshop-rs/mapped-text-v1 entries. Consumers built for the extended
contract recover exact identifier locations that previously reported as
unmapped; older decoders ignore the new members and keep the previous
behavior.

Closes #328

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@Teakowa
Teakowa merged commit b07f08a into main Sep 29, 2026
5 checks passed
@Teakowa
Teakowa deleted the feat/mapped-text-provenance-328 branch September 29, 2026 20:41
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