CSE Machine Plugin#28
Conversation
…ages Local checkpoint (plugins remote is upstream; fork/push when opening the PR). - common/cse-machine: language-agnostic CSE machine protocol — channel/plugin/ directory ids, the snapshot-message type, and the consolidated CseSnapshot schema (superset of the previously-duplicated copies in py-slang, js-slang and the frontend: includes heapObjects, isOnCallStack, isConst, currentLine) - runner/cse-machine: abstract CseMachinePlugin that forwards a run's CseSnapshots over the __cse channel; per-language serialization stays in the evaluators - both build (rollup -> cjs/mjs/d.ts) and pass jest Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Local checkpoint. - web/cse-machine: CseMachineHostPlugin subscribes to the __cse channel and hands each received CseSnapshot batch to the host via receiveSnapshots. Transport only, no UI deps — the adapter + Konva visualizer stay in the frontend for now (deferred extraction), so this plugin is small and language-agnostic. - re-exports the common-cse-machine protocol types for host convenience. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Mirrors the Jest → Vitest migration done in main (PR #27): - Remove jest, ts-jest, @types/jest from all three packages - Add vitest (+ @vitest/coverage-istanbul for test packages) - Update test/test-coverage scripts to use vitest run - Delete jest.config.cjs from common and runner packages - Remove "types": ["jest"] from tsconfigs - Add explicit vitest imports to test files Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
There was a problem hiding this comment.
Code Review
This pull request introduces three new packages to support a language-agnostic CSE (Control-Stash-Environment) machine plugin pair: @sourceacademy/common-cse-machine for shared protocol types, @sourceacademy/runner-cse-machine for sending snapshots, and @sourceacademy/web-cse-machine for receiving snapshots. The feedback identifies potential runtime crashes in both the runner and web plugins if the cseChannel array is empty during initialization, and suggests adding defensive checks to handle this safely.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@coderabbitai, any comments? |
This comment was marked as resolved.
This comment was marked as resolved.
AaravMalani
left a comment
There was a problem hiding this comment.
Mostly LGTM, just want a couple of issues addressed before I approve
AaravMalani
left a comment
There was a problem hiding this comment.
LGTM! Maybe add a README in this or a future PR?
Shall I add one based on the wiki in this very same PR? |
Depends on Conductor PR by @Shrey5132.
Depends on #25
Summary
Adds three new installable packages that implement the language-agnostic CSE (Control–Stash–Environment) machine plugin pair for the Conductor framework.
Packages
@sourceacademy/common-cse-machineShared protocol — channel ID, plugin IDs, and the
CseSnapshot/CseSerializedEnvFrame/CseSerializedValuetype hierarchy. Everything that crosses the__csechannel must be structured-clone-able JSON; all language evaluators serialise into these shared shapes.@sourceacademy/runner-cse-machineWorker-side plugin. Exposes
CseMachinePlugin.sendSnapshots(snapshots)which a language evaluator calls after collecting its steps. Sends a singleCseSnapshotMessageover the__csechannel.@sourceacademy/web-cse-machineHost-side plugin. Subscribes to the
__csechannel and delivers received snapshots to the host app via areceiveSnapshotscallback. The host app wires this to its own rendering layer.TODO : In the future, we should be moving the entire Frontend and the Konva visualisation layer into this host plugin and aim to make it external!
Design notes
installableplugins — the runner and web sidlementations live in each language evaluator repo and thefrontend respectively. (The host should be made EXTERNAL soon)portal:lo published npm versions once this PR merges.