Repository navigation
fix(scaffold): the static and page-vite templates never posted BLOCK_READY (#206) - #208
Conversation
…ADY (#206) A `page` app is not shown by the Civitai host until it posts `BLOCK_READY` — that handler in `PageBlockHost.tsx` is the only transition into `ready`. All three templates declare `page`, but only `page-money` ever sent it, and only because `@civitai/blocks-react`'s `IframeTransport` acks internally. `static` (the `civitai app init` DEFAULT) and `page-vite` are deliberately SDK-free, so they had to say hello themselves and did not. `BLOCK_READY` appeared nowhere in this repo. Measured against the REAL `PageBlockHost` (851f759c20) in Chromium, apps scaffolded from the unfixed CLI and served over HTTP into a sandboxed iframe with the manifest's own `allow-scripts allow-forms`: static never ready -> visible failure card at ~37s page-vite never ready -> visible failure card at ~37s page-money ready in 431-472ms Same at both trust tiers. The ~37s is `MAX_AUTO_RETRIES = 2` with `AUTO_RETRY_BACKOFF_MS = [2000, 5000]`. This was an original omission, not a regression: `git log --follow` shows both template files declared `page` from their first commit. The fix vendors one canonical emitter in `internal/blockproto` and has `scaffold.Render` copy it VERBATIM (no `text/template` pass) into the path `Template.ReadyAckPath()` names — so there is exactly one authority and both templates ship byte-identical bytes. Two hand-maintained copies would drift, and drift here is invisible locally: the app renders fine and dies only inside the real host. Ack on BLOCK_INIT, not on load — and on INIT only. Not because on-load is broken: an on-load poster was MEASURED WORKING in the same harness (ready in 178-265ms). On-INIT is chosen for robustness. The host registers its BLOCK_READY subscriber inside an effect and silently DROPS a message whose type has no subscriber yet, with no retry, while it re-posts BLOCK_INIT every ~400ms until acked — so answering INIT removes the race. It also hands over `event.origin`, so nothing posts to `'*'`; it is late enough not to reveal an empty interactive frame (the host fades its launch overlay and enables pointerEvents on ready); and it is what the SDK's own transport does. Repeats are a no-op, because the host's inbound channel is rate-limited across all types. Also fixes the envelope both templates were teaching. Every block->host message is `{ type, payload }` — the host dispatches `data.payload` — so the demo posts with top-level fields modelled the wrong shape for every message an author adds next. And `RESIZE_IFRAME` is removed outright: `hostHandlerParity.ts` marks it N/A for `PageBlockHost` (a page block fills the surface and does not size to content), so it was inert advice. `static/app.js`'s "the minimal useful thing an app can do is tell the host how tall it is" was simply false for a page app. After the fix, re-scaffolded from this CLI and re-measured in the same harness (2 runs, stable): static ready in 453/459ms, page-vite in 477/434ms, page-money still 489/435ms, and the inert negative control still times out at ~38s. Refs #206
…enough
Guard A (`ready_ack_contract_test.go`, runs in `make ci`) enumerates
`AllTemplates()` and decides subject-hood from EVIDENCE in the rendered output,
never a list in the test: a template is subject to the page-host readiness
contract if its rendered `block.manifest.json` declares `page`, and it is
expected to ship the vendored emitter unless its rendered `package.json`
depends on `@civitai/*` (whose transport acks for it). It then asserts, as
INDEPENDENT sub-tests with distinct messages:
- byte-equality of the rendered emitter with `blockproto.ReadyAckSource()`;
- that the emitter is actually REACHED from the entry point — index.html's
<script src>, or an import in the module index.html loads — checked after
stripping comments, so the HTML comment above the script tag cannot
satisfy it.
Plus a count positive control (>= 2 SDK-free page templates examined, with the
page/SDK split printed) so a guard that stopped observing cannot report a
serene pass, and a shape predicate with a negative corpus: a comment mentioning
BLOCK_READY, the string in a README, `{type:'BLOCK_READY', height:0}`, an
untriggered post, and a correct ack broadcast to `'*'` — each asserted to be
rejected BY THE EXPECTED RULE, not merely rejected.
Guard A cannot prove the ack FIRES. No Go static check can prove JavaScript
executes. Guard B (`ready_ack_runtime_test.go`) therefore loads each shipped
emitter in node under a `window` stub, plays the host's side of the handshake
at it, and reads what came out: exactly one message, only after a real
BLOCK_INIT, `{type:'BLOCK_READY',payload:{height:0}}`, addressed at the host
origin and not `'*'`, with a second BLOCK_INIT producing no second ack. It is
env-gated (CIVITAI_CHECK_SCAFFOLD_RUNTIME=1, mirroring the network guard in
pins_guard_test.go) so `make ci` stays Go-only and offline, and it is wired
into the daily `bump-scaffold-pins` workflow as its own job — an env-gated test
with no scheduled runner is a meaningless green.
Guard B validates its own harness before reading its verdict: two known-bad
fixtures (an inert emitter, and a naive ack with the wrong envelope, a `'*'`
target, no gate and no dedupe) go through the SAME assertions and must be
faulted, and the naive one doubles as the count positive control — it posts on
every message, so the driver's counter is watched moving off zero before any
zero it reports elsewhere is believed.
Mutation results (each failure confirmed to come from THIS guard's own
assertion, with the rest of `go test ./...` clean):
delete the <script> tag from static/index.html -> A wiring FAILS, A
byte-equality PASSES
render an emitter one byte off canonical -> A byte-equality FAILS,
A wiring PASSES
drop "page" from static's manifest -> static skipped AND the
count control FAILS
emitter posts {type,height} with no payload -> A shape + B FAIL
emitter acks on load instead of BLOCK_INIT -> A shape + B FAIL
invert `event.source !== window.parent` -> A passes ENTIRELY, whole
Go module green, B FAILS
That last one is the point of Guard B: the emitter keeps every structural
feature Guard A can see and is completely inert. (The brief predicted the
ack-on-load mutation would play that role; measured, Guard A's shape rules
catch that one too — the inverted source check is the real blind spot.)
Refs #206
The templates now ship `civitai-host.js`, and nothing told anyone what it is or
why it looks like it does nothing locally. Four surfaces:
- `static` / `page-vite` READMEs get a "The host handshake — don't delete it"
section: what BLOCK_READY is for, that the envelope is `{type,payload}`, that
the ack answers BLOCK_INIT rather than announcing, and the no-local-host
caveat only page-money's README carried ("`npm run dev` alone shows a blank
screen — there's no host to send BLOCK_INIT"). Without that caveat the
emitter's silence during local preview reads as a bug and the file reads as
deletable.
- `civitai app init`'s next-steps output says the same thing for the two
templates that ship the emitter. The NeedsHarness branch already covered it;
the static/page-vite branches said "open index.html" / "npm run dev" with no
hint that what you see locally is not what the host does.
- README.md gains a "The host handshake (BLOCK_READY)" section under Templates,
including that RESIZE_IFRAME is not part of a page app's protocol.
- AGENTS.md item 11 records the decision: what it mirrors, why ack-on-INIT
(with the honest note that on-load was MEASURED working — it is a robustness
choice, not a bug fix), why `{type,payload}` even though the host ignores this
particular payload, why `event.origin` and not `'*'`, that RESIZE_IFRAME is
deliberately ABSENT from page templates, and what each of the two guards does
and does not prove. Item 10's "third vendored mirror" is amended — this makes
four (schema/, the slot registry, the dev-embed dotenv mirror, and this).
Refs #206
Two pre-existing claims, unrelated to #206 and wrong on inspection of the templates: - "The `page-money` / `page-vite` templates ship a dev **harness**" — only page-money does. `templates/page-vite/` has no `Harness.tsx.tmpl`, and its package.json declares neither `dev:harness` nor `dev:live`. An author following that sentence runs a script that does not exist. - "the code your app actually imports lives in two published npm packages (the `page-money` / `page-vite` templates wire them for you)" — page-vite's package.json depends on react, react-dom and vite only. Being SDK-free is the point of that template, not an oversight. Also states the reason `npm run dev` shows nothing of the protocol (no host to send BLOCK_INIT) rather than describing it as a blank screen, which is no longer true now that the templates render their own UI.
… nothing Audit round on #206. No 🔴 findings — the shipped emitter is correct and the browser matrix held — but two of the guards were weaker than the PR claimed. **The wiring check matched a BASENAME, not a path.** Two mutants shipped a broken app past the ENTIRE suite, both measured green, both reproducing #206: static/index.html src="./vendor/civitai-host.js" -> ships a 404 page-vite/main.jsx import '../nonexistent/civitai-host.js' -> build fails So the claim that the guard proved the entry point REACHES the emitter was not true. Every reference is now RESOLVED — a <script src> against the document root, an import against the importing module's directory — and compared with where the emitter actually is; a bare specifier or a URL is not a project path at all. On failure it prints every reference with what it resolved to and whether that file exists, so a near-miss names itself. Backed by a 10-case corpus on synthetic trees (wrong subdir, unresolvable relative, bare specifier, HTML comment, commented-out import, orphan module, no script tags, CDN URL that merely ends in the name) — the accept cases are the two real template shapes. **Guard B never ran on a PR.** ci.yml never set CIVITAI_CHECK_SCAFFOLD_RUNTIME, so it skipped on every pull request and ran only on a daily schedule, on the default branch, with no dependent job. The failure the PR advertised it caught — inverting `event.source !== window.parent` — would have merged green and been reported up to 24h later. It is now a `ready-ack-runtime` job in ci.yml; the daily copy stays, relabelled as the drift runner it actually is. Measured, this is not theoretical: FOUR mutations are invisible to the whole offline suite and caught only here (inverted source check, inverted type check, latch-before-post, listener attached inside a setTimeout). **Nothing in CI built page-vite.** Only page-money was ever scaffolded and built (template-page-money, scaffold-currency). Since this PR its entry module has a hard resolution dependency on ./civitai-host.js, so the second mutant above would have shipped a template that cannot `npm run build` at all. New `template-page-vite` job builds it and asserts the ack SURVIVES BUNDLING — Guard A pins the source tree, Vite output is what the platform serves. Control pair measured locally: with the import the bundle carries BLOCK_INIT/BLOCK_READY, with it commented out it carries neither, while the positive control (the app's display name) matches either way, proving the grep reads the bundle. **`acked` latched before a post that can throw.** `postMessage` rejects a targetOrigin it cannot parse as a URL, and `event.origin` is the string "null" when the sender is at an opaque origin — so one throw would silence the emitter forever while the host kept retrying. Measured in Chromium 1228 rather than taken from the spec: `postMessage(msg, 'null')` throws `SyntaxError: Invalid target origin 'null'`. The latch now sets after the post. Not reachable through today's PageBlockHost, and the comment says so rather than claiming a live bug. Pinned by a new `--throw-first-post` mode in the driver, which also models a browser's per-listener exception isolation (previously a throwing emitter would have killed the driver instead of being observed). Also: `app init`'s three handshake lines had no test, unlike every sibling caveat — added, with a control asserting page-money does NOT get them, and proven to fail when the block is deleted. And the provenance path was wrong in two comments: usePostMessage.ts is under src/components/AppBlocks/, never src/hooks/. Full battery re-run, 16 mutations, ZERO survivors — including the classes the first battery missed (inverted condition, swapped operands, wrong bind, commented-out-but-greppable). The battery now also has a positive control that each mutation APPLIED: one regex silently no-op'd on the `}` inside `{{ .Name }}` and read as a surviving mutant until that check existed. Refs #206
Four corrections from the audit round, plus mirror currency.
**The emitter checks the sender WINDOW, not the sender ORIGIN.** It answers
`window.parent` and replies to whatever origin that window sent from — which
establishes "our embedder", not "Civitai". The comment said "only the framing
host" and the README said "the host's real origin"; both overstated it. That is
sound for THIS message (the ack carries `{height:0}` and discloses nothing a
page that chose to frame us doesn't already know) and insufficient for anything
else — and both scaffold READMEs explicitly invite authors to add more messages.
All four surfaces now say what it actually establishes, and carry an explicit
warning that an origin allowlist is required before handling any message that
carries data.
Decision recorded in AGENTS.md rather than left implicit: we deliberately do NOT
vendor an allowlist into the emitter. The real set (production, preview
subdomains, dev-*.civit.ai tunnels) is platform state that moves without notice,
so it would become a FIFTH mirror needing lockstep, and getting it wrong
silently breaks the dev tunnel — while @civitai/blocks-react already maintains
exactly that list from VITE_BLOCK_ALLOWED_PARENT_ORIGINS. Keep the emitter
minimal; make adopting the SDK the documented prerequisite for handling data.
**The upgrade path could wedge the host into a fake-ready state.** "If you later
adopt @civitai/blocks-react, delete it" was the one line reversing the
"don't delete it" instruction repeated in four other places, and it was a
parenthetical. If an author adds the SDK and KEEPS the emitter, whichever
handshake answers the first BLOCK_INIT calls notifyReady() -> stop(), clearing
the retry interval AND the readiness timeout; the SDK's waitForInit then rejects
at its own 10s and the host sits "ready" showing an app that never started, with
no retry and no card. Worse than #206, and silent. Now a callout with the
mechanism, in both template READMEs, the main README, and the emitter header.
**useBlockResize was described as "for the non-page block surfaces"**, but
page-money — a page template — calls it (src/App.tsx.tmpl:140). The accurate
statement is that RESIZE_IFRAME is ignored on a page surface and the hook is
surface-agnostic, so calling it there is a harmless no-op that lets SDK
component code move between surfaces.
**Mirror currency: the reference moved from 851f759c20 to 35a9598dc9.** Two
intervening commits touch this contract. BLOCK_HELLO now EXISTS host-side
(iframeInitController.notifyHello, hostHandlerParity.ts, host browser tests) —
the earlier "zero host references" note was true when measured and is now stale.
Re-verified independently rather than taken on report: notifyHello() leaves the
retry interval and readiness timeout armed by start() untouched, and its own
comment forbids it becoming a precondition for sending init, so a block that
never announces is served by the unchanged retry loop — exactly what this
emitter relies on. Recorded that the emitter deliberately does not send it
(scaffolded apps forgo the fast path, cost: one retry tick of latency) and that
the init-fragment path ships gated off and refuses surface === 'dev-tunnel'.
Emitting BLOCK_HELLO remains out of scope.
Also corrects the provenance path (usePostMessage.ts lives under
src/components/AppBlocks/, never src/hooks/) and documents the three guards,
including why the wiring check must resolve paths and must never go back to a
basename or strings.Contains match.
Refs #206
Audit round — corrections to this PR's body, and what changedAn independent blind audit found no 🔴 findings (the shipped emitter is correct and the browser matrix held up), but it falsified two claims I made in the description above. Correcting them here rather than quietly editing the body, plus the fixes in ❌ Correction 1 — the wiring guard did NOT prove what I said it provedThe body says Guard A asserts "that the entry point actually reaches the file". That was not true as written. It matched a basename, so two mutants shipped a broken app past the entire suite — both measured green, both reproducing #206:
This is the "spelled rather than structural" class: the check could pass while the hazard existed in a different shape. Fixed. Every reference is now resolved — a ❌ Correction 2 — Guard B ran on nothing that could block a mergeThe body presents Guard B as the thing that catches an inverted Fixed. This matters more than it sounds: four of sixteen mutations are invisible to the entire offline suite and are caught only by Guard B — inverted source check, inverted type check, latch-before-post, and a listener attached inside a Gate proven, not assumed — #211 was opened as a temporary draft carrying the inverted source check (a mutation Also fixed in this round
Mirror currency — the reference movedThe platform checkout moved Re-verified independently rather than taken on report: Re-verification (the fix round resets the gate)Full mutant battery re-run — 16 mutations, ZERO survivors, including the classes the first battery missed:
Each offline failure was attributed to the specific test that killed it (four other tests render these same templates, so "something went red" would not be attribution).
Browser matrix re-run (real
Both templates also verified at
Still deferred, unchangedThe 🤖 Generated with Claude Code |
…vacuous Round 3 on #206, from a delta re-audit of 4bc88ad..738ecb6 (which cleared the previous round's ten findings by mutation). **The gating claim was false.** `ready_ack_runtime_test.go` and AGENTS.md said the per-PR ready-ack job BLOCKS the merge. Measured: $ gh api repos/civitai/cli/branches/main/protection --jq .required_status_checks.contexts ["pins-vs-published","scaffold-currency"] $ gh api repos/civitai/cli/rulesets [] `ready-ack-runtime` is not a required context. Neither is `template-page-vite`, and neither is `build-test`. A red run reports and stops nothing — so #211's red job proved the check DETECTS the regression, not that it would have BLOCKED it. Corrected in the wording, not in branch protection: making these contexts required is the honest alternative but it is a repo-policy change affecting every open PR, so it is the maintainer's call and is recorded as the outstanding step instead of taken unilaterally. The measurement is inline at each site so the next reader can re-check rather than trust it. **Every ::error:: in the bundle assertion was unreachable.** `set -euo pipefail` plus `n=$(grep -rlF … | wc -l)`: grep exits 1 on no match, pipefail propagates, `set -e` kills the step AT THE ASSIGNMENT. Reproduced — it exited 1 having printed only the positive-control line, so the log could not distinguish "the harness isn't reading the bundle" from "the ack didn't survive the build", which is the exact ambiguity the positive control exists to remove. It failed CLOSED, so this was diagnosis, not safety. Each grep now carries `|| true`, the loop accumulates rc instead of dying, and the needles are scoped to the JS files actually counted — previously a match in dist/index.html or a public/ passthrough would have satisfied them. Watched in both directions with a decoy planted in dist/index.html: annotations print, the step still fails rc=1, and the decoy does not satisfy the assertions. **The SDK-template control test was vacuous.** Replacing the guard at app_init.go:238 with `if true` survived the ENTIRE suite: page-money's ReadyAckPath() is "", so the line printed with an empty filename (" performs the host handshake — keep it. …") and the "civitai-host.js is absent" assertion was satisfied BY THE BUG it should have caught. An assertion spelled on a value the failure mode erases can only ever pass. Now asserted on the phrase "performs the host handshake", shared as a constant with the positive test, and watched going red on that exact mutation. Checked the conjunct question rather than assuming: NEITHER half should go. They are coextensive across today's three templates but guard different failures — `ReadyAckPath() != ""` stops the empty-filename line, `!NeedsHarness()` stops "there's no host to send BLOCK_INIT" being printed at a template whose dev:harness mounts one. Recorded at the site. **Dead branch removed, three live ones pinned.** The `://` half of the URL guard was unconditionally dead — verified by resolving candidate specifiers with each half toggled, it changes the outcome for no input — so it is gone rather than left as a branch no mutation can reach, and the CDN corpus case now says it is rejected by the fallthrough. The `//` half is NOT dead: without it `//evil.example.com/../civitai-host.js` has its leading slash stripped, filepath.Join cleans the `..`, and it resolves to EXACTLY the emitter's path and is accepted. Pinned, along with the `?`/`#` suffix stripping and the errNoScriptTags early return, via a new optional `wantErr` on the corpus so a rejection must come from the branch the case exists to exercise. Also sweeps two leftover "the real host origin" overclaims from a456c95 that the round-2 sweep missed (contract_test.go:92, runtime_test.go:151). Battery: 20 mutations, ZERO survivors, each attributed to the specific test that killed it, with the apply-verification and null-mutant controls in place. Refs #206
PR #210 (`feat/generate`) adds items 11–16 to this same list while this PR adds item 11, and `git merge-tree --write-tree` exits 1 on AGENTS.md — a real textual conflict. Both PRs also independently corrected the intro's stale "items 5–8 cover `civitai app metrics`" to "5–9" while adding a different clause, so the correct merged sentence is neither side's and a naive take-one-side resolution silently loses the other's range. Nothing about that is discoverable from the file, so whoever resolves the next collision re-derives the rule under time pressure. Writing it down: append-only, numbered by arrival, the PR merging SECOND renumbers its OWN items, never an existing one — because items cross-reference each other by number (item 10 points at item 11, item 9 points at item 6) and so do code comments. Applied the new rule to the file as it stands: all four `item N` / `items N–M` references resolve correctly (items 4 and 8 as non-mirrors, items 5–9 as metrics, item 6 as `notOwned`, item 11 as the ready-ack). The Layout section carries no item references in this branch. No code change; the mutation battery is unaffected. Refs #206
Round 3 — a false claim about gating, an unreachable diagnostic, and a vacuous controlA delta re-audit of ❌ Correction — "a PR check is what makes it a guard" was falseMy last comment and
Fixed by correcting the wording, not by changing branch protection. Making these contexts required is the honest alternative, but it is a repo-policy change affecting every open PR including #210, and that is the maintainer's decision — it has not been given, so I did not take it. 🟡 Every
|
Both are claims this PR itself introduced, in text a future maintainer would read as evidence. `resolveProjectRef` said the removed `strings.Contains(spec, "://")` half "decided nothing for any input". Measured, five inputs disagree — among them `/x://../civitai-host.js` and `./civitai-host.js?u=https://evil.com`, which it rejected and which now resolve to the emitter. None is a URL and the new answer is what a browser gives, so the removal fixes a latent false rejection; but the comment justified deleting a guard on a stronger claim than the measurement supports. It now states the scope it was actually measured at. The numbering note said the Layout section cross-references items by number. It does not — the coupling today is other items, `ci.yml` and a Go test comment. Left as-is it points a maintainer doing a renumber at a section with nothing to fix, while understating where the real references live. Comment-only: 17 changed lines in the Go file, none outside a comment. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Fixes #206.
What was broken
A
pageapp is not shown by the Civitai host until it postsBLOCK_READY—that handler (
PageBlockHost.tsx:864-871) is the only transition intoready. All three templates declarepage, but onlypage-moneyever sentit, and only because
@civitai/blocks-react'sIframeTransportacksinternally (
dist/internal/iframeTransport.js:311).static— thecivitai app initdefault — andpage-viteare deliberately SDK-free, sothey had to say hello themselves and did not.
BLOCK_READYappeared nowhere inthis repo.
Original omission, not a regression:
git log --followshows both templatefiles declared
pagefrom their first commit.Two knock-on problems, fixed in the same commit:
event.data.payloadto its subscribers (usePostMessage.ts:189), so everyblock→host message is
{ type, payload }. Both templates put fields at thetop level. The host ignores the
BLOCK_READYpayload, so this would not havebroken the ack itself — it teaches the wrong shape for every message an
author adds next.
RESIZE_IFRAMEis N/A for a page surface (hostHandlerParity.ts:100-110:the page renders the iframe full-viewport and does not size to content). Both
templates demoed it as "the minimal useful thing an app can do". Removed.
Two corrections to the issue text
The issue is right about the bug and wrong about the symptom, both times in the
direction of making it look milder than it is:
pageBlockHostLogic.ts:476-479is explicit: "a FULL-PAGE surface that collapses is just a blank viewport.
So a failed page renders a message INSIDE the trust frame instead." The user
sees "This app didn't load in time … We already retried 2 times
automatically."
MAX_AUTO_RETRIES = 2withAUTO_RETRY_BACKOFF_MS = [2000, 5000]→ 10+2+10+5+10.Also: the snippet the issue suggests as the fix reproduces the envelope bug
(top-level fields,
payload: undefinedat the host).Measured control matrix
Real
PageBlockHostfromcivitai@851f759c20, real Chromium, apps served overHTTP into an iframe with the manifest's own
allow-scripts allow-formssandbox(no
allow-same-origin⇒ opaquenullorigin). "after" apps re-scaffolded fromthis branch's binary and rebuilt, not hand-edited.
static(default template)page-vitepage-money(regression check)BLOCK_READYposter (positive control)Both templates also verified at
trustTier: 'internal'(pinned origin ratherthan opaque
null): ready in 470–531 ms. After the fix each block frame postsexactly one
BLOCK_READYand zeroRESIZE_IFRAME; before, it postedRESIZE_IFRAME≥1 and noBLOCK_READY— which is what separates "the JS neverran" from "the JS ran and said the wrong thing".
The negative control still failing is what makes the four greens readable.
Why ack on
BLOCK_INIT, not on loadOn-load is not broken. An on-load poster was measured working in the same
harness (ready in 178–265 ms). Ack-on-INIT is a robustness choice, and the
comments in the emitter say so rather than claiming otherwise:
BLOCK_READYsubscriber inside an effectand silently drops a message whose type has no subscriber yet, with no
retry (
usePostMessage.ts:152-153). It re-postsBLOCK_INITevery 400 msuntil acked (
iframeInitController.ts:51), so answering INIT cannot be early.'*'. The init event carriesevent.origin, so the ack is addressedat the host instead of broadcast.
pointerEventson ready, so acking too early reveals an empty interactiveframe.
Repeats are a no-op (mirroring
iframeTransport.js:293-296), which mattersbecause the host's inbound channel is rate-limited to 30 msg/sec across all
types, with the budget consumed after subscriber lookup — re-acking every
retry could starve
BLOCK_ERROR.Structure: one authority, copied verbatim
internal/blockprotoholds the emitter as embedded bytes;scaffold.Rendercopies them with notext/templatepass into the pathTemplate.ReadyAckPath()names (civitai-host.js/src/civitai-host.js).No per-template
.tmplcopy, because two hand-maintained copies drift and drifthere is invisible locally: the app renders fine and dies only inside the real
host.
staticstays no-build (a bare<script src>, no package.json);page-vitestays SDK-free (a side-effectimport).This is the fourth vendored mirror in the CLI, alongside
schema/, the slotregistry, and the dev-embed dotenv mirror. AGENTS.md item 11 records it and
item 10's "third vendored mirror" is amended.
What the two guards prove — and what they don't
Guard A (
ready_ack_contract_test.go, inmake ci) enumeratesAllTemplates()and decides subject-hood from evidence in the renderedoutput, never a list in the test: subject if the rendered manifest declares
page; expected to ship the emitter unless the renderedpackage.jsondependson
@civitai/*. It asserts byte-equality withblockproto.ReadyAckSource()andthat the entry point actually reaches the file (index.html
<script src>,or an import in the module index.html loads) — as independent sub-tests, after
stripping comments. Plus a count positive control (≥2 SDK-free page templates
examined) and a shape predicate with a negative corpus (comment / README prose /
wrong envelope / untriggered post /
'*'target), each required to be rejectedby the expected rule.
Guard A does not prove the ack fires. No Go static check can prove
JavaScript executes.
Guard B (
ready_ack_runtime_test.go) loads each shipped emitter in nodeunder a
windowstub, plays the host's side, and reads the outbound message:exactly one, only after a real
BLOCK_INIT,{type:'BLOCK_READY',payload:{height:0}}, addressed at the host origin and not'*', with a secondBLOCK_INITproducing no second ack. Env-gated(
CIVITAI_CHECK_SCAFFOLD_RUNTIME=1, mirroringpins_guard_test.go) somake cistays Go-only and offline, and wired into the dailybump-scaffold-pinsworkflow as its own job — a gated test with no scheduledrunner is a meaningless green. It validates its own harness first: an inert
fixture and a naive-ack fixture go through the same assertions and must be
faulted, and the naive one doubles as the count positive control (it posts on
every message, so the driver's counter is watched moving off zero).
Guard B does not prove the real host accepts the ack — the stub is this
repo's reading of the contract. The browser matrix above is that evidence.
Mutation results
Each failure confirmed to come from that assertion's own error message, with
go test ./...otherwise clean:<script>tag fromstatic/index.html"page"fromstatic's manifest{type,height}with nopayloadBLOCK_INITevent.source !== window.parentThe last row is the reason Guard B exists: the emitter keeps every structural
feature Guard A can see and is completely inert. (The brief predicted
ack-on-load would play that role; measured, Guard A's shape rules catch that one
too — the inverted source check is the real blind spot. Reported as measured,
not as predicted.)
Verification
make cigreen: 16 packages ok, 1545=== RUN/ 1542--- PASS/ 0--- FAIL/ 3--- SKIP, nopanic: test timed out,gofmt -s -l .silent,
go mod tidya no-op.golangci-lint v2.12.2: 0 issues.actionlintclean on the changed workflow, with a positive control (itrejects
runs-on: ubuntu-lates, so its acceptance is a real green).CIVITAI_CHECK_SCAFFOLD_RUNTIME=1 go test -run TestScaffoldedReadyAckActuallyFiresgreen, controls reported.
Deliberately deferred
internal/antipatternrule for a page manifest with no ready-ack, andcivitai app validatewarning for already-scaffolded apps.Both are the right follow-ups — an author who scaffolded last week still has a
broken app and nothing tells them. They are not in this PR because landing them
now would turn the scaffolds' own self-validation red before the templates that
satisfy them have shipped.
Note for the schema owners (not touched here)
schema/app-block.manifest.schema.jsondescribesiframe.resizableinsize-to-content terms, which is arguably wrong for a
pageapp — the hostrenders those full-viewport and
RESIZE_IFRAMEis marked N/A forPageBlockHost. All three templates still set"resizable": true. That file isa vendored mirror and ask-first per AGENTS.md, so it is left alone; flagging it
rather than fixing it.
🤖 Generated with Claude Code