Repository navigation
feat(playground): tracer v2 records traces in the shared snapshot - #204
Merged
Merged
Conversation
A new module, src/features/playground/tracer/, beside the old tracer and not wired into the app yet (ADR 0004). It rewrites the learner's JavaScript with acorn and astring, runs it on the browser's own engine and returns a trace: steps that each hold a shared snapshot. - every object, array and closure keeps one identity for the whole run - every frame on the stack carries its own slots - functions are traced wherever they are written - the step limit stops the run and keeps the partial trace - a step's focus is derived from what the step changed - tracing the Stack and Heap story's code gives the references its beats assert, for the 9 beats a run can observe 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.
PR 5 of the ADR 0004 build plan. A new module at
src/features/playground/tracer/, added beside the old tracer and not wired into the app; the swap comes with the stack-and-heap lens.What it does
src/shared/snapshot).refId.while(true){}, a loop that catches everything, and afinallythat returns.Evidence
story.test.ts: tracing the Stack ↔ Heap story's code gives the references its beats assert for the 9 beats a run can observe. The 10th is the garbage-collection sweep, which a trace never shows.examples.test.ts: the Playground's JavaScript examples and default template trace without error and print what the untraced code prints.createTracer.toString(); tests run the serialised source standalone, and again after esbuild minification.Known limits
ƒ,class); only closures become heap objects.yield*resumption can miss the outer frame; the scope a class method closes over is not drawn;let/constdeclared directly in aswitchcase are not shown.varand a function declaration of the same name is refused; top-levelawaitis a syntax error; code that declares its own__tfails with a confusing message.examples.test.tslooks for the examples file under both its old and new name while the rename in the Playground basics PR is in flight; tidy once both are merged.🤖 Generated with Claude Code