fix(isolation): scope the legacy code fallback and sketch writes to the identity - #161
Merged
Merged
Conversation
…he identity A code-less start_simulation ran whatever any user compiled last, and any user could overwrite or delete the shared start sketch. Both now hold per subject; the REST and WebSocket contracts keep their shape and status codes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
R2 of the refactoring series (
docs/UNOSIM_REFACTORING_OPL.md), audit findings S2 and S3.start_simulationwithoutcoderan the code that any user compiled last (lastCompiledCodewas one global variable).POST/PUT/DELETE /api/sketchesacted on one global store; the client openssketches[0]as everyone's start sketch, so any user could replace or delete it.Why "secure" instead of "remove"
docs/ARCHITECTURE.mdrequires a new major version for incompatible REST changes. A routes test calls the sketch CRUD the public API.Change
LastCompiledCodeStore(bounded LRU,config.compilation.lastCompiledCodeMaxSubjects = 1000):/api/compilerecords per subject;start_simulationwithout code falls back only to the same subject's code, otherwise the existing "No compiled code available" path.OwnedSketchStoreoverMemStorage: created sketches belong to their subject; the seeded default sketch stays visible to all and read-only; foreign and unknown ids both answer 404. The routes moved unchanged intoserver/routes/sketches.routes.ts.Tests
simulation-last-compiled-code.test.ts(another subject's code is never run; the same subject keeps the fallback),last-compiled-code-store.test.ts,sketches.routes.test.ts(seed read-only; foreign GET/PUT/DELETE 404; own CRUD works).compiler.routes.test.ts:setLastCompiledCodenow receives the fixture subject ("student-a") with the code.routes-core.test.ts: the CRUD sequence reuses the local session cookie of its creating request, as a browser does. Before, every request implicitly got a new local identity.unit-node-httpgroup.npm run check,check:docs, ESLint, unit 2703 passed, pre-push incl. Sonar quality gate PASSED.🤖 Generated with Claude Code