feat(experiments): hfir, an assembly-like IR agents write instead of HTML - #3321
Closed
miguel-heygen wants to merge 1 commit into
Closed
feat(experiments): hfir, an assembly-like IR agents write instead of HTML#3321miguel-heygen wants to merge 1 commit into
miguel-heygen wants to merge 1 commit into
Conversation
…HTML Not shipped and not proposed for shipping. Lives under experiments/ and answers one question with a runnable prototype instead of an argument. The question: every code-to-video framework is designed to read well to a human, but increasingly no human reads the source. Agents want the opposite of what humans want, explicitness over convention. So what if an agent never wrote HTML at all? hfir is a flat table of (op, frame, element, property, value). Two opcodes, and the difference between them is the whole idea: SET is a hard step that holds, RAMP interpolates linearly into the stated value. Interpolation is declared per property per segment, so there is no implicit tween and no easing name to misread. Nothing is inferred. It compiles to WAAPI keyframes rather than CSS, because seeking by currentTime is the path the render engine treats as authoritative and it is a Baseline web standard rather than a Chromium internal. The useful consequence is that the IR inherits browser text shaping, compositing and colour for free while the agent never touches the cascade or the box model. That is also the honest answer to "should we go native": the explicitness people want from native turns out to be a compiler problem rather than an engine one, and doing it this way keeps the installed renderer and the HTML/CSS fluency every model already has. Verified rather than asserted. The example scene renders 60 frames of 720p in about 2.5s, and frames 0, 29, 30 and 45 were checked against the table by eye: opacity 0 is genuinely absent, the SET at frame 30 steps with nothing between 29 and 30, and the two RAMPs land the box at x=960 interpolated red to green. Limits are in the README, including the one real leak: WAAPI cannot animate text content, so text runs off a discrete per-frame table. The prototype only shows this is possible, not that it is better. The test that would settle it is a cold first-valid-render comparison against HTML, which nobody in the category publishes for any format.
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.
What
An experiment under
experiments/hfir/: a flat, assembly-flavoured IR that an agent writes instead of HTML, which compiles to a normal HyperFrames composition.Not shipped, not proposed for shipping, not wired into anything. It exists to answer a question with a runnable prototype instead of an argument.
Why
The provocation, roughly: code no longer needs to be intuitive to us, because increasingly no human reads it. It needs to be intuitive to agents, and agents want the opposite of what humans want, explicitness and dials rather than terseness and convention. "Assembly for programmatic video rather than Ruby on Rails."
So: what if an agent never wrote HTML at all?
What it looks like
A complete scene, with no HTML and no CSS anywhere in it:
The one design decision that matters:
SETandRAMPare different opcodes.SETis a hard step that holds;RAMPinterpolates linearly into the stated value. Interpolation is declared per property, per segment. There is no implicit tween and no easing name to misinterpret.How it runs
Chrome never sees the IR. It is compiled ahead of time in Node:
The output is an ordinary composition, so
lint,check,render,previewand Studio all work on it unchanged. No new runtime, no interpreter to ship.It targets WAAPI rather than CSS keyframes because seeking by
currentTimeis the path the engine treats as authoritative, and it is a Baseline web standard rather than a Chromium internal. The useful consequence is that the IR inherits browser text shaping, compositing and colour for free while the agent never touches the cascade or the box model.Verified, not asserted
Rendered, and frames checked against the table by eye:
box opacity 0SETis a stepRAMPs60 frames of 720p in ~2.5s.
Test plan
6 tests covering keyframe placement on exact frames,
SETvsRAMPeasing, and the three parse errors (undeclared element, unmapped property, op past the end). Plus the render above.What it is not
Being blunt so nobody over-reads this:
The bit I would actually like a second opinion on
This is also the honest answer to "should we build a native renderer": the explicitness people want from native turns out to be a compiler problem rather than an engine problem. Solving it this way keeps the installed renderer, the standards floor, and the enormous amount of HTML/CSS in every model's training data.
If that reasoning is wrong, this is a cheap place to find out.
The follow-up worth running either way: give an agent the IR spec and the HTML spec cold, same prompts, and measure first-valid-render rate and repair loops. Nobody in the category publishes that number for any format.