Skip to documentation

PhET simulation pilot

PhET simulations use ordinary lesson ZIP packages containing TDF/stimulus JSON, compiled simulation HTML, a monitoring catalog, corresponding source and notices. Upload uses the standard content pipeline without per-lesson server configuration. The pilot targets three pinned builds from public source with a shared collector: Density 1.2.9, Pendulum Lab 1.0.34, and Circuit Construction Kit: DC 1.5.1.

Author a simulation node

The SPARC authoring catalog includes an atomic simulation node. It requires an accessible label and a simulation object containing a packaged buildId, asset references with SHA-256 hashes, and one to 32 declarative bindings:

In the visual editor, select Simulation from the palette, enter its label, enter its packaged build ID, edit Simulation package assets (JSON), and edit Observation bindings (JSON). Changes apply when the field loses focus; invalid changes show an inline error and are not applied. The starter address is an explicit placeholder and must be replaced with a validated catalog address before launch. Authoring preview displays the label without starting a simulation or collecting telemetry.

{
  "id": "simulation",
  "nodeType": "atomic",
  "atomType": "simulation",
  "label": "Density: mass and volume",
  "simulation": {
    "buildId": "replace-with-the-validated-pinned-build-id",
    "asset": {
      "url": "simulation.html",
      "sha256": "<SHA-256 of packaged HTML>",
      "catalog": { "url": "simulation.catalog.json", "sha256": "<SHA-256 of packaged catalog>" }
    },
    "bindings": [
      {
        "name": "mass",
        "label": "Block mass",
        "unit": "kg",
        "address": { "path": "screens.1.model.blockA.massProperty" },
        "projection": "value"
      }
    ]
  }
}

Use a build ID of 1 to 160 lowercase letters, digits, periods, or hyphens. Give each binding a unique name of 1 to 64 letters, digits, or underscores starting with a letter. The previous_ prefix and system-supplied event slot names are reserved.

Choose either a structural path or a tandem name, up to 1,000 characters. Validate it against the pinned build's catalog. Structural paths describe the first discovery location. Dynamic components use session-local object IDs. Required values need observed notification coverage. Missing, ambiguous, unsupported, or incomplete required evidence stops the attempt.

The supported projections are value for scalar properties, count for collection size, and any-nonzero for an explicitly named numeric memberProperty of collection members. any-nonzero uses an absolute numerical tolerance of 1e-8. The circuit activity uses currentProperty. These are declarative projections over the common catalog and snapshots; there is no circuit-specific collector.

Bindings become slots in an interface-event fact with eventType: "simulation-observation". Author conditions and effects in the existing productionRules DSL. The host evaluates settled frame checkpoints in order after ordered browser receipt, independently of research storage. It does not turn observations into answer submissions or KC/model updates. Those require explicitly authored effects. This pilot uses static authored rules and does not support an AutoTutor/LLM-driven simulation policy.

Guard completed tasks with persistent SPARC state. The example activities set simulation.completed and require it before the learner selects Done. Repeated observations cannot repeatedly award task completion. Completed work and prior instructional history survive reload; the physical simulation state does not.

Record selected activity

Bind the observed values and use one history-event effect per rule to record a meaningful action. Its selection and action are expressions. Its input can be an expression or a text template with single-brace variable names. Optional expressions supply outcome (default unknown) and values. Use endsAttempt: true for a rule that ends the attempt.

{
  "type": "history-event",
  "selection": { "type": "literal", "value": "Wood block" },
  "action": { "type": "literal", "value": "Adjust volume" },
  "input": "Volume {previous_volume} → {volume} m³"
}

Bind previous_volume and volume before using this effect. Binding label and unit values may each be at most 120 characters and follow selected values into the export. Use the model's units. Density represents volume in m³ even when the slider shows liters.

An observation fact includes assigned binding names, previous_<name>, simulationEvent, interactionBinding, and changeCount. Event names are observation, interaction-completed, interaction-cancelled, reset, collection-added, and collection-removed. Collection events preserve member identities and transition counts. Reset emits its own activity and suppresses reset-induced removals. Shared framework property links supply the provenance for completed control interactions. A property or topology change alone remains an observation. Older Reset All callbacks without input provenance also remain observations.

After reload, an action can refer to evidence labeled last-recorded-state-after-reload. The learner starts a new simulation instance explicitly. If a page contains multiple simulation nodes, associate actions explicitly with the intended simulation. The host can infer an association only for an unambiguous single simulation. Simulation exports and research traces

Builds and ordinary ZIP upload

The application repository owns packages/phet-monitor/ and tools/phet-pilot/. releases.json pins the original dependency manifests and supplemental locale metadata. Acquisition and builds reject unexpected source edits. Density and CCK include adapted-from-phet in their supportedBrands metadata; Pendulum uses its pinned baseline metadata. Shared changes are confined to Axon, Joist, Scenery, Tandem, and the Chipper preload list.

After building all three monitored artifacts with the current shared sources:

node tools/phet-pilot/generate-catalogs.mjs
node tools/phet-pilot/create-activities.mjs 'C:/dev/mofacts_config/SPARC PhET Pilot'
node tools/phet-pilot/verify-activities.cjs 'C:/dev/mofacts_config/SPARC PhET Pilot'

The canonical directory C:/dev/mofacts_config/SPARC PhET Pilot/ contains the editable lesson JSON and each simulation HTML, catalog, source archive and notices. Three individual upload ZIPs are written at the config repository root: SPARC PhET density.zip, SPARC PhET pendulum-lab.zip, and SPARC PhET circuit-construction-kit-dc.zip. The combined SPARC PhET Pilot.zip contains all three. These are normal lesson packages.

The uploader recognizes JSON attachments separately from TDF and stimulus JSON. Before content persistence, it checks the referenced file hashes, catalog identity, and observation coverage. Per-file limits are 64 MiB for simulation HTML, 8 MiB for the catalog, and 512 MiB for any other declared simulation dependency, within the applicable package limits. The uploader resolves names within the uploaded lesson's stimulus set and stores application-relative immutable asset IDs with the launch query intact. Telemetry authorization checks the page, node, and build in the authorized lesson. The package runs through the ordinary MoFaCTS installation.

The existing asset route serves simulation HTML with HTTP CSP sandbox allow-scripts, a restricted resource policy and frame-ancestors self; the iframe also grants scripts only. Its effective browser origin is unique and opaque even though bytes come from ordinary application storage. It cannot access the parent DOM, application local storage or authenticated APIs. Both filesystem and S3 asset delivery apply this policy; ordinary assets retain their delivery behavior. The host validates exact source window, origin null, protocol, build and unpredictable attempt identity. Sending to an opaque iframe requires target origin *; the window/attempt checks remain mandatory. The child accepts initialization only from its actual parent and the embedding origin derived from browser-provided origin-only referrer metadata. This removes hard-coded deployment origins without exposing learner identity.

Upload the ZIP under the intended owner account, then launch the new activities from Practice.

Activity Instructional condition
Density Increase wood volume above 5 L while mass/volume remains 400 kg/m³
Pendulum Lab Change length to at least 0.75 m, then observe left–right–left motion
Circuit Construction Kit: DC Create and remove components, then form a circuit with nonzero current

The Pendulum Lab task detects angular crossings from observed property changes at settled checkpoints; it does not estimate an exact pendulum period. Launch it with the documented ?accessibility flag for keyboard operation. In Circuit Construction Kit: DC, use the native focusable wire control for keyboard deletion.

Simulation data

Ordinary history records selected learner actions. The separate research trace preserves the ordered model observations and attempt status. Simulation activity and trace access

Monitor and deployment reference

The shared collector uses object-level events after one initial model discovery. Property notifications, emitter events, and Axon observable-array API mutations are observed directly. Frame callbacks settle already-captured records and affected cached identity edges; they do not inspect model values. No model-step hook, polling mode, full-model rescan, or full-frame reference collector remains.

Plain fields, ordinary arrays/maps/sets, typed-array physics buffers, and vector/matrix direct writes are initial-only, unsupported for continuous observation. Objects explicitly carried by events may receive labeled event-point snapshots. Getters, closures, and rendering/browser objects remain unsupported. Direct backing-array or defineProperty writes bypassing Axon are unsupported. The trace contains object and field-level coverage inventories; required bindings cannot use initial-only data.

Startup capture begins before the first model factory. Early primitive notification values and order are retained until ownership is known; pre-discovery mutable references resolve later and cannot establish their earlier field values. Earlier module-loading activity is outside coverage. Dynamic identity uses IDs and collection references, while structural paths describe first discovery. Event-driven trial deletion releases affected disposed/detached subgraphs without model rescans. Silent ordinary-array membership changes cannot establish detachment.

Research-only coalescing starts a 100 ms window for each pending storage group. Contiguous receipts are combined into bounded storage batches without changing record sequences. Further writes follow completion of the preceding write and receive their own coalescing window, limiting sustained requests to at most ten per second. No timer runs on an idle queue. This storage scheduling never gates SPARC observation delivery.

The shared monitor uses an explicit version-1 registration contract for properties, emitters and observable collections. Shared framework constructors supply kind, exact notification source, public value reader and collection child handles. Rendering/instrumentation exclusions use registered constructor identities. Private-field lookalikes never gain observed coverage. The declaration in packages/phet-monitor/registration-contract.d.ts is identical across the three adapted builds; release manifests record its hash. Framework adapters preserve startup capture, collection identity, disposal and the independent reactive SPARC/research paths. No simulation model is patched and no polling mode is introduced.

The server streams ZIP entries into a temporary directory and hashes each entry during extraction. Parsed TDF and stimulus objects remain in memory for validation. See the shared ZIP validation limits. Upload and repair clear staging after preflight, success or failure. Saved packages retain the source archives and notices.

Each simulation dependency is uploaded only to the stimulus-set scopes that declare it. A shared dependency accumulates its declaring scopes. The combined three-simulation package has four dependencies per simulation—HTML, catalog, source archive and notices—for 12 extracted media records. These upload rules do not rewrite assets in already saved lessons.

Package SHA-256 checks read streams. FilesCollection's public addFile API registers durable filesystem copies. Exports lazily open one asset stream at a time, generate the ZIP into owned temporary storage and register that file. S3 writes receive streams with ContentLength; S3 downloads stream with backpressure and close on disconnect. Buffered storage reads remain explicit for bounded consumers such as readiness checks. Independent server-side telemetry validation produces the serialization used for both byte limits and the batch digest; sequence, ownership and transaction checks govern acceptance.

Plan temporary disk space for expanded assets, durable copies, and exports.

Use verify-host.mjs <fresh-fixture-ids.json> --hold-research for live feedback/persistence/reload checks, then verify-history.mjs <fixture-ids.json> for actual Download UI checks across own-history, owned-data and individual-lesson scopes. Verification uses synthetic fixtures and the canonical ignored test credentials; update user-facing demos in place under their original admin owner. Do not clear learner history to repeat a test. The uploader, host/history verifiers and ingestion benchmark share tools/phet-pilot/local-app.mjs for full headless Chromium, exact localhost origin validation and canonical ignored test credentials. Run its three isolated tests with node --test tools/phet-pilot/local-app.test.mjs; they never read real credentials. User-facing trials use Chrome. measure-ingestion.mjs <fixture-ids.json> records synthetic attempt/lifecycle rows with canonical session/unit context, without task credit; use test fixtures only. Build/reproduction and probe commands are maintained in the application tools/phet-pilot/README.md.

Evaluate a simulation package

Qualify the exact application revision and simulation artifact together. Uploading a package does not deploy application code, and results for one protocol or build do not qualify another. The pilot covers its three pinned builds; other PhET simulations need their own catalog, coverage and compatibility review.

Exercise representative native pointer and keyboard controls, Reset All, screen changes, and dynamic component creation/disposal. Check supported-state reconstruction and startup ordering, then confirm that idle frame callbacks inspect no model objects. A disposal probe can test selected object references after repeated create/reset cycles, but it does not establish a complete heap audit. Verify course-assigned launches separately from ordinary owned-lesson launches.

For performance comparisons, run the baseline and monitored build for ten minutes each with the same machine, viewport, launch flags and scripted action policy. Report the p95 frame interval and its change against the pilot's 10% target, along with maximum gaps, action counts, visibility, elapsed duration, errors and trace completeness. Frame intervals include rendering and action work; they are not direct CPU-cost measurements. A passing p95 result does not establish worst-case responsiveness. Keep frame-ended inventory samples distinct from settled object counts.

Use held research writes to confirm that instructional feedback can arrive before research storage completes, then release storage and verify the supporting observations. Test explicit restart after reload, retained task completion, ordinary Download across all authorized scopes, and package re-export with portable filenames, query parameters, hashes, source and notices intact. Check temporary staging cleanup after upload/export. Complete accessibility, physical-state replay and distribution-license clearance require their own review.

Keep build logs, source/license inventories, artifact hashes, traces, coverage inventories, screenshots and measurements with the build's development evidence. The application repository's tools/phet-pilot/README.md owns reproduction commands. License Guidance explains the separate project and third-party obligations.

Production response-policy ownership

The production Apache virtual host preserves a Content-Security-Policy supplied by the application and applies its normal site policy only when the response has none. Uploaded simulation HTML therefore retains the shared asset route sandbox policy, including same-site frame ancestors, no same-origin sandbox capability, and restricted network access. Main application pages retain frame-ancestors none. Other assets without an application policy still receive the normal site policy. No build-specific or lesson-specific proxy configuration is required.

The deployment procedure requires exactly one enforced site default, compares the live main-page policy, and preserves its authenticated readiness and participant acceptance gate. Verify an uploaded simulation response as well as the main page when changing proxy headers.