Skip to content

Describe commit changes by sprite, with saved state kept apart from edits - #80

Merged
Mistium merged 5 commits into
mainfrom
structured-compare
Nov 21, 2026
Merged

Mistium merged 5 commits into
mainfrom
structured-compare

Conversation

@Mistium

@Mistium Mistium commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Commit diffs on MistWarp are hard to read because every save rewrites each sprite's fractch file. Most of what changes is saved runtime state, and much of the rest is older fractch spellings or hidden values. This adds a view that describes a commit by sprite instead of by file:

  • GET /v1/projects/:id/commits/:sha/changes
  • GET /v1/projects/:id/pulls/:index/diff?view=changes (the same shape, in inspection)

Each changed sprite folder (all its region files together) comes back with its sprite name and:

  • scripts: added, removed, changed or moved to another region file, with the hat, text and canvas positions.
  • items: variables, lists, costumes, sounds, extensions and comments that were added, removed, renamed, changed, edited (image or audio changed) or reordered.
  • state: variable and list values, sprite position, size, direction, layer and visibility, stage settings, the current costume, monitors and script canvas positions.

totals counts everything, and totals.stateOnly is true when saved state is all that changed.

These are not reported as edits:

  • moving or reordering scripts;
  • older fractch spellings of the same block (wait_until versus waitUntil), including inside ${...} in template strings;
  • values hidden under a reporter ((reporter ?? value));
  • rotation centres that drift by less than 0.005 on re-save.

Costumes are matched by their asset file, so renames and redraws are named. Existing history gets this straight away and nothing is rewritten. Results go through the existing inspection cache and access checks (canSeeInsideProject, canInspectPull).

Real data

I ran every commit of 5 public production projects (141 commits) through the new view with no failures. Examples:

  • One 2tanium OS commit showed 19 changed scripts; 7 are real edits. The other 12 were fractch writing stop otherScriptsInSprite where it used to write stop other_scripts_in_sprite.
  • Another commit went from 22 changed scripts to 6, mostly because hidden values no longer count.

Limits

This runs on uploaded data, so every pass is linear and bounded:

  • the rename index;
  • pairing scripts with the same hat falls back to order past 10,000 pairs or 2M lines of similarity work;
  • hidden-value stripping skips text nested deeper than 64 brackets;
  • whitespace and folder scans are single pass;
  • the existing 1 MiB per file and 8 MiB per response budgets still apply.

There are timing tests for each case that used to blow up (20,000 renamed costumes, 30,000 scripts with the same hat, 500,000 nested brackets, 80,000 hidden values, a million blank lines, 5,000 sprite folders), plus a fuzz target (1.9M runs, no crashes).

Known gaps

  • Renaming a sprite renames its folder, so it shows as one target removed and another added.
  • Identifiers that differ only by snake_case versus camelCase compare equal. That is what hides the old fractch spellings.
  • pen.setPenColorToColor(...) versus setPenColor is a change of call form, not a rename, so that change still shows.

Size

About 1,900 added lines, most of it the Go parser, comparison and tests. Splitting it would leave unused code in one PR.

Checks

With OSL 6.1.1 (the CI pin aeb83e39):

  • osl test 62 passed;
  • osl lsp check main.osl has no errors, and the warnings were already there;
  • osl compile works;
  • scripts/check_conventions.py passes;
  • scripts/e2e_smoke.py: 333 steps, 0 server errors, including new steps for both views;
  • go test ./... and go vet pass in native/gitinspection;
  • the route dump only adds GET /v1/projects/:id/commits/:sha/changes (and its /api twin).

It had two independent reviews; every must-fix and should-fix finding is fixed on this branch.

Version

1.1.1 → 1.2.0 (new backwards-compatible endpoint).

Screenshots

None: this is API only. The commit and pull request pages start using this view in a follow-up scratch-gui PR.

Docs: MistWarp/docs commit-changes-endpoint.

…dits

GET /v1/projects/:id/commits/:sha/changes and pulls/:index/diff?view=changes
split each sprite's fractch file into scripts, declarations and saved state.
Scripts are matched by content and hat, so moving or reordering them is not an
edit, and hidden values under reporters and older snake_case spellings no
longer count as changes. Variable values, sprite position, size, layer and
visibility, the current costume, monitors and script positions are reported
as state. Costumes are matched by their asset file, so renames and redraws are
named.
Rename matching uses an index, same-hat pairing falls back to order past a
work budget, and hidden-value stripping skips text nested deeper than 64
parentheses, so adversarial files stay linear. Each sprite folder's region
files are compared together, so a script moved between regions is reported as
moved. Statements may end without a semicolon, free comments stay apart from
the next script, costume and sound order changes are reported, redrawn
costumes are named even when the sprite file is unchanged, and totals report
stateOnly instead of codeChanged.
…olders

Hidden-value stripping trims in place instead of copying its output, the
statement reader skips a whitespace run once, and region files are grouped by
folder in one pass. Only a script's own body ends at a closing brace, so object
values keep their id. A comment trailing a statement on the same line stays a
free note instead of joining the next script.
@Mistium
Mistium merged commit cb1126a into main Nov 21, 2026
1 check passed
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