Skip to content

feat(driver): validate and rename raw Workshop edits through workshop-rs - #454

Merged
Teakowa merged 4 commits into
mainfrom
wright-434-validated-edits
Sep 30, 2026
Merged

Teakowa merged 4 commits into
mainfrom
wright-434-validated-edits

Conversation

@e54-bot

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

Copy link
Copy Markdown
Collaborator

Summary

Implements #434: raw Workshop input now carries the advertised source-edit contract end to end.

  • validateEditTransaction applies the caller's transaction to the supplied current sources and reparses/revalidates the edited project through the session's own workshop-rs path. Malformed or invalid results refuse with the real parse/validation diagnostics and no partial preview; stale identities, unknown sources, overlaps, and invalid ranges keep their structured refusals.
  • semanticRename resolves target either by symbol — a numeric id or declared name, the same addressing references/usage use — or by a source/line/col position inside one identifier occurrence. Global variables, player variables, and subroutines rewrite through the exact identifier spans workshop-rs records (Global.name/Event Player.name prefixes preserved, comments and strings untouched). There is no textual-search fallback: unmapped occurrences refuse rename-unmapped-span, same-namespace collisions rename-name-collision, non-renameable kinds rename-unsupported-kind, and edits that break the reparse refuse with the parse diagnostic or rename-mismatch.
  • wright rename <NAME> <NEW_NAME> [INPUT] exposes the validated rename on the CLI: a -/+ diff preview by default, an atomic sibling-tempfile write with --write that rechecks source identities (edit-stale-source writes nothing).
  • Source languages stay at the provider boundary: OPY input refuses with edit-requires-provider naming providerValidateEdit/providerSemanticRename; unshipped kinds keep source-provider-unavailable.
  • Schema: RenameTarget gains the optional symbol field (integer id or name); the existing position form stays valid. Operation names and response shapes are unchanged.
  • wright-consumer exercises the new path (symbols → semanticRename) on Workshop fixtures.

Docs updated: docs/agent-contract.md, docs/cli/commands.md, docs/architecture/tooling.md.

Closes #434

Test plan

  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo test --workspace --all-targets --all-features — all green
  • git diff --check
  • Acceptance: global var, player var (Event Player.x prefix preserved), subroutine (declaration + Subroutine binding + Call Subroutine); position and name/id addressing; stale-source and stale-write refusals; collision refusal; no partial previews
  • Real fixture: overpy-cake.ws — cakePos → cakePosition produces 18 exact identifier edits, Global.i2 untouched, --write result reparses clean

e54-bot pushed a commit that referenced this pull request Sep 30, 2026
… callees

Review on #454 found two contract violations reachable through the agent surface. Value::Subroutine arguments (Start Rule callees) produced no reference, so a uniquely-named subroutine refused on reparse and a redeclared name could silently retarget a surviving binding; the index now records the call reference and resolves redeclared names to the last declaration, matching workshop-rs name binding. A deserialized EditTransaction also bypassed the constructor's invariants, so empty, overlapping, or unsorted edit lists could produce corrupted ok:true previews; validateTransaction re-normalizes the wire value. Edits that name a source outside the loaded input and renames to the symbol's own name now refuse instead of validating vacuously.

Refs #434
Raw Workshop input now carries the advertised source-edit contract: validateEditTransaction applies the caller's transaction to the supplied current sources and reparses/revalidates the edited project through the session's own workshop-rs path, and semanticRename resolves a symbol (numeric id or declared name, as references/usage address them) or a source/line/col position and rewrites exactly the identifier spans the parsed program records — declarations, the Subroutine event binding, Call Subroutine callees, variable arguments, and Global.name/Event Player.name references. There is no textual-search fallback; unmapped occurrences refuse with rename-unmapped-span, same-namespace collisions with rename-name-collision, and edits that break the reparse with the real Workshop diagnostics.

wright rename <NAME> <NEW_NAME> [INPUT] exposes the same validated rename: a source diff by default, an atomic write with --write that rechecks source identities and refuses edit-stale-source.

Non-Workshop input stays at the provider boundary: the raw operations refuse with edit-requires-provider naming providerValidateEdit/providerSemanticRename, keeping provider-owned paths distinct.

Closes #434
… callees

Review on #454 found two contract violations reachable through the agent surface. Value::Subroutine arguments (Start Rule callees) produced no reference, so a uniquely-named subroutine refused on reparse and a redeclared name could silently retarget a surviving binding; the index now records the call reference and resolves redeclared names to the last declaration, matching workshop-rs name binding. A deserialized EditTransaction also bypassed the constructor's invariants, so empty, overlapping, or unsorted edit lists could produce corrupted ok:true previews; validateTransaction re-normalizes the wire value. Edits that name a source outside the loaded input and renames to the symbol's own name now refuse instead of validating vacuously.

Refs #434
…on in cfg edges

action_subroutine first-matched a CallSubroutine callee name, pointing the CFG edge at a shadowed declaration when two subroutines share a name; workshop-rs resolves redeclared names last-wins, and the semantic index now does too.

Refs #434
main gained a subject parameter on run_configured and a RenderContext parameter on ResultPresentation::render_body in the inspect-presentation rework; pass the rename command no subject and render its body without the context.

Refs #434
@e54-bot
e54-bot force-pushed the wright-434-validated-edits branch from 2c031b2 to 5ed643e Compare September 30, 2026 13:16
@Teakowa
Teakowa enabled auto-merge (squash) September 30, 2026 13:17
@Teakowa
Teakowa merged commit 9dcb427 into main Sep 30, 2026
13 checks passed
@Teakowa
Teakowa deleted the wright-434-validated-edits branch September 30, 2026 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

Validated edits and semantic rename for raw Workshop, through the agent contract and wright rename

2 participants