Skip to content

feat(capture): learn editable motion, sandbox source canvas code, and promote after live verification - #485

Merged
chubes4 merged 3 commits into
mainfrom
feat/425-generic-behavior-capture
Sep 30, 2026
Merged

chubes4 merged 3 commits into
mainfrom
feat/425-generic-behavior-capture

Conversation

@chubes4

@chubes4 chubes4 commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Refs #425. Companion: Automattic/blocks-engine#2360.

Why

#458 reached LIQUID BONSAI parity only with a hand-authored site recipe. This PR makes plain URL capture learn that behavior from the source itself.

What it does

  1. Observe (screenshot/behavior-capture.ts): two source runs under controlled dates and timezones. Instrumentation installed before source scripts records timestamped text (leaf and mixed content), visibility together with its mechanism, click/pointer listeners, and canvas drawing calls. Sampling is incremental so it does not slow the page it measures. Startup ends when text goes quiet (bounded), and each click probe starts from a settled page.
  2. Learn (learned-motion.ts): infers values in the Blocks Engine marker vocabulary:
    • sequential reveals (cadence, gaps, click replay delays);
    • pending message with cycling dots;
    • elements hidden until a reveal starts;
    • a live clock: roles proved by the two controlled times, startup/replay frames, and the date reveal.
      Anything else goes to unsupported; nothing is substituted. Editorial copy is never embedded.
  3. Promote (learned-motion-promotion.ts): a staged copy with the markers and a portable interpreter (motion-runtime.ts) must match the live source at 390/768/1440 on a contract derived from the evidence. Only then is it written to website/, with a portable-motion.json receipt (origin: learned, residuals listed). Plain compare re-verifies the receipt and fails visibly per residual.
  4. Source canvas reuse (canvas-sandbox.ts): canvas algorithms are not re-derived. The page's own captured, hash-verified scripts that draw on a canvas run behind a DOM membrane: canvas, drawing contexts and listeners are live, reads return real values, and every write to non-canvas content is discarded, so the source cannot overwrite editable text. The sandboxed copy must reproduce the source pointer response, or promotion falls back to learned motion with canvas as a residual.
  5. Comparison fixes: a source with no readiness marker is settled for its learned startup duration before layout is measured, and a click probe waits until the trigger actually receives pointer input (sources that set pointer-events:none while busy).
  6. The portable interpreter is tagged data-blocks-engine-marker-runtime, so Blocks Engine uses its lowered blocks view scripts in WordPress instead.

Supersedes the earlier candidate compilers (text-behavior-runtime.ts, the clock compile step).

LIQUID BONSAI, plain URL, no recipe

  • Learned: 5 sequential reveals, the Synchronizing pending dots, label and status-dot reveals, 4 click triggers, and the 12h clock with its frames and typed date. The source's script.js runs sandboxed for the canvas.
  • Portable: status: translated, no residuals. Plain compare passes at 390/768/1440 plus layout widths.
  • WordPress (SSI dev package + blocks-engine#2360): 0 fallbacks. Text and layout are native paragraph and group blocks, plus editable motion-sequence and live-clock blocks; the sandbox is reported as a preserved_runtime_island. compare --candidate passes against the live source at 390/768/1440 including the canvas pointer probe. Gutenberg audit: all blocks valid, edited text saves, and the front end replays the edited value.
  • Reproduced end to end from a second fresh capture and import.

Tests

  • Neutral real-browser fixture (different names, copy, glyphs and cadence) learns the full program with no unsupported items. It is verified against its live source from the saved DOM, replays edited copy, and reports canvas as untranslated.
  • Neutral sandbox fixture: source code that overwrites copy, restyles, rebuilds markup and draws on pointer and click; the canvas draws and the page DOM is byte-identical afterwards.
  • npm run build, npm run test:package, full npm test: 125 files / 1,444 tests pass. dist/ unchanged.

Remaining

Source canvas code that depends on content it would have created itself cannot run behind the membrane. It stays an explicit residual rather than being approximated.

AI disclosure: GPT-6.1 Sol via OpenCode designed and implemented the observation, learning, canvas sandbox and promotion pipeline and the neutral fixtures, and ran the live LIQUID BONSAI portable and WordPress proofs directly (Chris authorized direct implementation after the Homeboy Cook stalled). Chris Huber directs the goal.

@chubes4 chubes4 changed the title feat(capture): discover source behavior and compile editable text and clock candidates feat(capture): learn editable motion from source behavior and promote it after live verification Sep 30, 2026
@chubes4 chubes4 changed the title feat(capture): learn editable motion from source behavior and promote it after live verification feat(capture): learn editable motion, sandbox source canvas code, and promote after live verification Sep 30, 2026
@chubes4
chubes4 marked this pull request as ready for review September 30, 2026 15:10
@chubes4
chubes4 merged commit 4be527d into main Sep 30, 2026
1 check passed
@chubes4
chubes4 deleted the feat/425-generic-behavior-capture branch September 30, 2026 15:10
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