Skip to content

fix: Reverse engineer items from #34 - #51

Open
Jozkah wants to merge 7 commits into
CNCKitchen:mainfrom
Jozkah:fix/reverse-review
Open

Jozkah wants to merge 7 commits into
CNCKitchen:mainfrom
Jozkah:fix/reverse-review

Conversation

@Jozkah

@Jozkah Jozkah commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

The Reverse engineer items from #34, rebased on 0.9.3. The notes fix is left out because you shipped it in 0.9.3. One commit per item, each with a regression test that fails without it:

  • A project with an Import STEP feature never read as saved. Each capture encoded the STEP texts into new bytes, so the snapshot signature never matched. The leave-page warning always fired, project.unsaved was always true, and recovery rewrote every member every 2 s. The bytes are now reused while the texts are the same.
  • Duplicate feature ids from a project file. nextFeatureId / nextParameterId were only checked to be finite, so a file could set them at or below an id in use, and removeFeature then deleted both. They're moved past the largest id on load, and a non-integer nextOfKind is refused.
  • STEP file lookup by inherited keys. An Import keyed constructor or __proto__ found an Object member. Lookups now use Object.hasOwn.
  • The kernel kept the pre-edit scan. After a Mesh Tools copy was adopted, or undo crossed it, the file name and triangle count didn't change, so syncScan didn't send the new scan, and splits and compares ran on the old one. A scan-change counter now takes part.
  • Build counters drifting. A throw in finishBuild counted a build off twice, and readRegionsAgain had no catch. Each build is now counted off once.
  • A failed helper kernel load was cached. The helper now tries again on the next request.
  • Deep expressions and long parameter chains overflowed the stack. The parser has a depth limit, and expressions over 4000 characters are refused. Parameters are read in dependency order, and an overflow becomes an expression error.

Build: npm run build passes. npm test (3104), npm --prefix mcp test, the plugin boundary and units checks, and npm run e2e:ci all pass.

The project snapshot tells members apart by the identity of their bytes, and the Reverse part encoded its STEP texts afresh on every capture, so a project with an Import never read as saved and every checkpoint rewrote its members. The bytes are now kept by their text and reused while it is unchanged.
A project file's nextFeatureId and nextParameterId were only checked to be numbers, so a counter at or below an existing id handed that id out again and one removal took two features. Loading now moves each counter past the largest id taken, and a name counter must be a whole number.
The STEP texts are held in a plain object, so an Import whose key a project file gave as constructor or toString found a function on the prototype, failed its build with a clone error and saved an empty member. Lookups now take own keys only, and such an Import reads as having no file.
The session told whether the kernel had the scan by its file name, triangle count and alignment, and a smoothed or offset copy keeps all three, so splits, trims, networks and the live map went on reading the scan from before the edit. Every load or swap of the scan is now counted, and the count is part of what the session compares.
A throw while a build's answer was written into the store reached the build's catch, which took it off the running count a second time, and a region read that threw was never taken off at all. Each build is now counted off once, and the region read is counted off whatever happens, failing the build with what went wrong.
The helper kept the promise of its first kernel load, so one load that failed failed every request after it, and the helper's share of the parallel build was lost until the page was reloaded. A failed load is now forgotten and the next request tries again.
The expression parser and the parameter table both recursed as deep as their input, so a project file with deeply nested parentheses or a long chain of parameters failed to open with a raw stack overflow. Expressions now have a nesting and length limit, a stack overflow while evaluating becomes an error of the expression, and the table reads a parameter once the ones it reads are done, so a long chain is read one link at a time.

This branch has not been deployed

No deployments
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