Repository navigation
fix(validate): tell existing page apps they never post BLOCK_READY (#206) - #212
Conversation
…206) 4018e2c fixed the `static` and `page-vite` templates, which declared a `page` surface and never acked the host. Every app scaffolded before that commit is still broken and nothing tells its author: it renders perfectly everywhere you can look locally and is replaced by a failure card in the real host after ~37s. This closes that gap in two tiers, deliberately different in strength. 1. `internal/antipattern` gains `resize-iframe-page`. `hostHandlerParity.ts` marks RESIZE_IFRAME N/A for PageBlockHost, so a page app posting it is dead code — and both raw templates demoed it until #206. This is a GATE (it fails scaffold-currency) because it fires on a literal that is present in the file, with no inference. It matches only the '/"-quoted form, never the backtick one: this repo's README and both scaffold READMEs name RESIZE_IFRAME in markdown backticks precisely to say don't post it, and failing the documentation of a rule is a false positive. 2. `civitai app validate` gains a page-without-ack advisory. Unlike the lockfile rule next door — where the platform build provably dies — this infers runtime behaviour from static text and can be wrong, so it is a WARNING and must stay one; --strict already gives anyone who wants a gate one. The dependency is evidence and is checked FIRST: on @civitai/blocks-react the ack comes from IframeTransport and the literal never appears in src/ (measured: zero occurrences in a rendered page-money outside node_modules), so a source-only scan would false-warn at every correct money-path app. It reads source only — never outputDir, node_modules, or markdown — and strips comments, which is load-bearing: both SDK-free templates carry a comment naming BLOCK_READY that survives deleting civitai-host.js. Reading zero source files reports "no finding", because a zero-hit scan over a zero-file tree is indistinguishable from a scanner wired to nothing. It sits in the projectState branch beside lockfileChecks, not in warningChecks, which also runs under ManifestOnly where `app init` self-checks its own template. Measured on a scaffold reconstructed from the templates at 4018e2c^: validate warns and the antipattern gate flags app.js:18. On today's three scaffolds both are silent; deleting civitai-host.js from a fresh static or page-vite scaffold makes the warning fire. Neither check proves the ack FIRES — only the real host can.
…roven A 24-mutant sweep found four guards that no test could distinguish from their absence. Three were real gaps, one was a weak mutant: - `"page": null` — nothing covered it, so declaresPage's `v != nil` half was indistinguishable from a presence-only test. `encoding/json` decodes an explicit null to a PRESENT key holding nil, so the two disagree on exactly one input and no fixture had it. - the comment stripper's string handling — the URL fixture put the URL and the ack on DIFFERENT lines, so deleting the quote case only ate the rest of the URL's own line and the ack below it survived. Same line now. - the outputDir skip — the fixture used `dist`, which is ALSO in the name-based skip list, so an EARLIER check always won and the manifest-driven branch never executed. A non-standard outputDir (`public`) is the only way in; the mutation disabling it survived the entire suite until this case existed. - the walk-error branch — first written off as unreachable by any fixture (chmod is a no-op for root). It is not: a dangling symlink with a scanned extension fails os.ReadFile deterministically for any user. The "expected to survive" was a rationalisation for an untested branch. Re-run: 11/11 attributed kills plus a surviving null mutant, and every mutation verified to have actually changed the tree.
…ges that ack An adversarial audit falsified two headline claims this PR had written into AGENTS.md. Both reproduced live before fixing, both fixed here. 🔴 1. "The dependency is evidence" was false for four of the six published first-party packages. The gate tested the `@civitai/` PREFIX. Measured from fresh npm tarballs: only @civitai/blocks-react@0.39.0 acks (dist/internal/iframeTransport.js:311). @civitai/app-sdk@0.31.0 ships 17 runtime .js files and NONE contains BLOCK_READY — the only hits are a .d.ts type and the README — and it declares no dependencies, so it cannot ack transitively. @civitai/theme, @civitai/components, @civitai/components-react and @civitai/cli contain none at all. theme and components are exactly what a hand-written no-build page app installs, so the scope test went SILENT on a genuinely broken app: verified by adding @civitai/theme to a static scaffold with civitai-host.js deleted, i.e. the literal #206 shape. The predicate is now an exact set in blockproto, with the per-package evidence, used by BOTH validate and the scaffold contract guard — which had the identical hole: a future template depending on @civitai/theme would have been classified SDK-backed and excused from shipping an emitter, a born-broken template passing its own guard. 🔴 2. Three reachable shapes false-warned at a CORRECT project — the outcome this check's own doc names as the worst possible. (a) stripHTMLComments discarded everything after an unterminated `<!--` and ran on .js, so an ordinary `var OPEN = '<!--';` above an emitter deleted it. HTML stripping is now gated to markup extensions AND non-lossy. (b) filepath.WalkDir does not follow symlinks, so a monorepo whose src is a symlink into a shared package had its whole source tree skipped. The scan now follows directory symlinks, with a visited set on resolved paths. (c) outputDir was skipped from the manifest, so "outputDir": "src" skipped the directory holding the emitter (on a manifest with zero validation errors) and "outputDir": "." skipped the entire tree. That skip is gone. For a presence check, scanning extra can only ADD evidence while skipping can only CREATE a false warning, so skipping is a cost decision only — the remaining name-based list is applied to entries, never the root. Also: - The scan is three-valued (found/absent/unobservable); only `absent` warns. A read error, an over-cap file or the file budget is a gap, not an absence. - Caps added: 5000 files, 2 MiB each. validate used to be a manifest-only read; 20,008 files with one 88 MB .js went 0.50 s / 316 MB RSS -> 0.04 s / 21 MB. - app submit now PRINTS warnings (it branched only on res.OK() and dropped them). It is the highest-traffic path and the last point before review. It does not block; that stays the --strict contract. - The antipattern rule is scoped to code extensions: a message NAME is quotable in prose and usable as a JSON key, and unscoped it flagged its own docs. `What` now reads "reference to", not "postMessage of" — the regex matches the quoted token anywhere in code and claiming a call was a claim it cannot make. - Corrected the "first non-REST entry" claim (deprecated-blocks-cli predates it) and both falsified claims in AGENTS.md item 12 and the README.
Found by a surviving mutant, not by reading the code: adding
`if readyAckSkipDirs[filepath.Base(dir)] { return }` to the top of the walk
passed the ENTIRE suite. Every fixture's project root is a random t.TempDir()
name, so nothing exercised the claim that the skip list is applied to entries
only.
A project directory called `build`, `out` or `dist` is perfectly ordinary. Under
that mutant such a project scanned nothing, reported "no files read", and went
silent — the same whole-tree removal that `"outputDir": "."` used to cause and
that the entries-only rule exists to make impossible.
Each case carries its own positive control: the same tree goes silent once the
emitter is added, so "warns" cannot be satisfied by a scan that warns
unconditionally.
…est did not Second surviving mutant from the post-audit battery: deleting the visited set entirely passed the suite, cycle test included. That test was proving the wrong thing — a self-referential symlink terminates anyway, because Linux gives up with ELOOP after ~40 resolutions and the resulting error makes the scan partial. So the OS guarantees termination and the visited set's real job is avoiding DUPLICATE WORK: without it, two links to one directory read every file in it twice, inflating the count toward a budget whose only effect is silencing the check. Counting files is the only thing that can see that, so the new test walks ackScanner directly and asserts three routes to one directory read its files once. The cycle test stays as a backstop, relabelled to say what it does not prove.
#210 (`civitai generate`) landed first and took AGENTS.md items 12–17, so per this file's own convention — the PR merging SECOND renumbers ITS OWN new items — the ready-ack item becomes 18. Both sides had also edited the "which items are which" sentence above the list, which is exactly the collision AGENTS.md warns about ("the correct merged sentence is usually neither one's"). It is rewritten to name both ranges rather than taking either side. Re-grepped every `item N` cross-reference afterwards: all resolve, and item 18's references to items 3, 10 and 11 are unchanged. Merged tree verified rather than assumed: 1896 RUN / 1892 PASS / 0 FAIL / 4 SKIP across 17 packages, gofmt clean over 242 files, and the live scaffold-and-validate matrix re-run on a binary built from the merge.
Correcting two claims this PR made, both falsified by reviewPosting rather than silently editing the body: the original text asserted these, ❌ "The dependency is evidence" — false for four of the six published packagesThe gate tested the
The two CSS packages are exactly what a hand-written no-build page app installs, Fixed by an exact set in The same predicate now backs ❌ "It never false-warns at a correct project" — three reachable shapes didAll three reproduced live before fixing.
The reasoning behind dropping the Also in this round
Mutation battery: 4 rounds, 52 runsNull mutant in every round (all survived); every mutation's diff verified Two real survivors found, both now fixed:
Five further "survivors" were broken scripts, not surviving guards (a missing Verification
Still not provenNeither check proves the ack fires — only the real host can, and there is no 🤖 Generated with Claude Code |
Each is a claim a maintainer would act on, and each is now false. `AGENTS.md` item 11 and the `ready-ack-runtime` note in ci.yml both said no ready-ack check gates a merge, and named adding the required contexts as an outstanding decision. That decision was since taken: `gh api .../branches/main/protection` now returns pins-vs-published, scaffold-currency, build-test, ready-ack-runtime and template-page-vite. Both now state what the API returns, keep the record that an earlier revision claimed "BLOCKS the merge" while it did not, and say the claim is true now only because the contexts were added — not because the job runs. `readyack_test.go` said its dangling-symlink fixture makes os.ReadFile fail. It does not: the walk stops at the os.Stat guard above it. Measured — mutating that ReadFile branch to `continue` fails nothing in the suite, and the same holds for os.ReadDir. Both are reachable only via permissions, and chmod is a no-op for root, so neither can be pinned on a root CI runner. The comment now records the gap instead of implying coverage; shipped behaviour for both was checked by hand and stays silent. `ready_ack_contract_test.go` told a template author it "carries no @civitai/* SDK" — false since the acking set narrowed from the @civitai scope to the packages that actually post BLOCK_READY. A template can carry @civitai/theme and still never ack. `generate.go` cited AGENTS.md items 11-16; the generate items renumbered to 12-17 when this branch took item 18. Comment-only apart from one t.Errorf message string. actionlint clean on the changed workflow, verified against a positive control. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Follow-up to #208 (merged as
4018e2c), closing #206 for apps that already exist.4018e2cfixed thestaticandpage-vitetemplates, which declared apagesurface and never postedBLOCK_READY. Every app scaffolded before thatcommit is still broken, and nothing tells its author — it renders perfectly
everywhere you can look locally and is replaced by a failure card in the real
host after ~37s. This was deliberately deferred out of #208 so it would land
after the templates were fixed; landing it first would have turned the shipped
scaffolds' own self-validation red.
Two pieces, with deliberately different evidentiary strength.
1.
internal/antipattern: theresize-iframe-pagerule (a GATE)hostHandlerParity.tsmarksRESIZE_IFRAMEN/A forPageBlockHost— a pageblock fills the surface and does not size to content — so a page app posting it
is dead code that also models the wrong envelope for every message the author
writes next. Both raw templates demoed it until #206 removed them.
This one is allowed to fail the build (it fails the
scaffold-currencyjob),because it fires on a literal that is present in the file. No inference.
It is the first non-REST entry in that denylist, which until now was strictly
"dead REST route behind a host bridge". Two precision decisions:
'or"pair — deliberately not thebacktick form. This repo's README, both scaffold READMEs and AGENTS.md item 11
all name
`RESIZE_IFRAME`in markdown backticks precisely to tell authorsnot to post it. A gate that fails the documentation of its own rule is a false
positive at a correct project.
Ruleis aper-line regex with no manifest context by construction, and every template
this CLI ships declares
page. A non-page template would need that assumptionrevisited, not the rule deleted — the code says so.
2.
civitai app validate: a page-app-without-ack advisory (a WARNING)🔴
Warnings, neverErrors, and that must stay true. The lockfile checknext door earns hard-error status because the platform provably fails (
npm cidies). This one infers runtime behaviour from static text, and there are
correct projects it cannot read: an ack from a bundled dependency, a framework
wrapper, a code-split chunk, an extension the scan does not open. Hard-failing on
a heuristic is the false-warning-at-a-correct-project failure AGENTS.md item 10
spent four measured corrections avoiding — and
--strictalready gives anyonewho wants a gate one.
The dependency is evidence, and it is checked FIRST. On
@civitai/blocks-reactthe ack comes fromIframeTransportand the literalBLOCK_READYnever appears insrc/— measured on a renderedpage-money:zero occurrences anywhere outside
node_modules. A source-only scan thereforefalse-warns at every correct money-path app on the platform, which is the worst
possible outcome for advisory output.
TestSDKTemplateIsQuietOnlyBecauseOfTheDependencypins that the dep gate is the only reason page-money is accepted, so that
branch cannot rot into a case that passes for an unrelated reason.
Other constraints, each from the #208 audit rounds:
pagesurface, no check. Unreadablepackage.json, no check. Unwalkable tree, no check. And reading ZERO sourcefiles reports "no finding" — a zero-hit scan over a zero-file tree is
indistinguishable from a scanner wired to nothing. That is not defensive
padding: a manifest-only fixture in
warnings_test.gofailed without it.outputDir(not built yet, gitignored), nevernode_modules, never.md.carry a source comment reading "The ONE message a page app must send is
BLOCK_READY" — and it survives deletingcivitai-host.js. Without thestrip the check is inert on the exact population it was written for. Measured
both ways.
warningChecksruns unconditionally including underManifestOnly, whichapp inituses to self-check the template it justwrote. A check that reads
src/lives in theprojectStatebranch besidelockfileChecks, or init's self-validation starts reading files that are notits business.
Measured before / after
Built binary, real scaffolds on disk. The unit tests are not a substitute for
this.
civitai app validate4018e2c^app.js:18 — resize-iframe-pagestatic(today)page-vite(today, + lockfile)page-money(today, + lockfile)static,civitai-host.jsdeleted--strict)page-vite,src/civitai-host.jsdeletedThe pre-fix reconstruction is the real population: it trips both checks, for
two independent reasons (no emitter, and a live
RESIZE_IFRAMEpost).What these checks do NOT prove
event.sourceguard satisfies every assertion here. That is what Guard B(
ready_ack_runtime_test.go) exists for, and there is no runtime guard at allfor an app an author already has. The advisory says this in its own message.
appears in code somewhere", which is weak evidence deliberately treated as
conclusive: being generous costs a missed warning, being strict costs a false
one.
validateis still a best-effort localmirror.
Mutation results
Four rounds, 42 mutant runs. Every mutation was verified to have actually
changed the tree (
git diff --statnon-empty for the expected file) before itsverdict was read, and each round carried a null mutant (comment-only edit)
that had to SURVIVE — it did, every time. Kills are attributed: several
neighbours in this repo render the same templates, so an unattributed "KILLED" is
not evidence about my guard.
Final state — all attributed to a test added in this PR:
TestReadyAckWarning/a_non-page_app_never_warns.../a_non-page_app_never_warnsdeclaresPageaccepts a null page.../an_explicit_"page":_null_does_not_warnTestSDKTemplateIsQuietOnlyBecauseOfTheDependency,TestShippedTemplatesDoNotTripTheReadyAckWarning/page-money,.../page_app_depending_on_@civitai/blocks-react_does_not_warnunknowncaseTestReadyAckCannotObserve/an_unreadable_package.json_….../the_SDK_dep_counts_from_devDependencies_too.../a_package.json_with_no_@civitai_dep_still_warnsunknownTestDeletingTheEmitterMakesTheWarningFire/static.../an_ack_named_only_in_a_comment_warns.../an_ack_named_only_in_an_HTML_comment_warns.../a_URL_literal_does_not_swallow_the_ack_after_it.../an_ack_described_only_in_the_README_warns.../an_ack_present_only_in_a_NON-STANDARD_outputDir_warns.../an_ack_in_node_modules_does_not_countscanned == 0no longer silencesTestReadyAckCannotObserve/a_directory_holding_only_a_manifest_…TestReadyAckCannotObserve/an_unreadable_source_file_…TestReadyAckIsAdvisoryOnlyprojectStateTestReadyAckSkippedByManifestOnlyTestReadyAckWarning/page_app_with_no_ack_at_all_warnsTestScanDir/RESIZE_IFRAME_posted_from_a_page_app_failsTestScanDir/docs_naming_RESIZE_IFRAME_in_backticks_are_not_flagged'onlyTestResizeIframeBoundaryReplacementemptiedTestScanDir/RESIZE_IFRAME_posted_from_a_page_app_failsThe first sweep left four of these unproven, and the second commit here is the
fix. Three were real gaps and one was a weak mutant of mine:
"page": null— nothing covered it, sodeclaresPage'sv != nilhalfwas indistinguishable from a presence-only test.
dist, which is also in thename-based skip list, so an earlier check always won and the
manifest-driven branch never executed. The mutation disabling it survived the
entire suite. A non-standard outputDir (
public) is the only way in.URL and the ack on different lines, so deleting the quote handling only ate
the rest of the URL's own line.
(chmod is a no-op for root). It is not: a dangling symlink with a scanned
extension fails
os.ReadFiledeterministically for any user. The "expected tosurvive" was a rationalisation for an untested branch.
Two further mutants were weak, not surviving guards, and were re-expressed:
one left a variable unused and only broke the build; one replaced a prefix of
Replacementwhile leaving the string non-empty.Verification
make cigreen. Full suite: 1613=== RUN, 1609--- PASS, 0--- FAIL,4
--- SKIP, 16 packagesok, 0FAIL, 0panic: test timed out. All fourskips are pre-existing env-gated tests (
TestScanDirFromEnv,TestSubmissionsCapDriftAgainstLiveAPI,TestScaffoldPinsSatisfyPublished,TestScaffoldedReadyAckActuallyFires).gofmt -s -l .prints nothing, against 213.gofiles found in the tree (thecount is the positive control — a silent
gofmtover zero files looksidentical to a clean one).
ready-ack-runtimeguard run locally withCIVITAI_CHECK_SCAFFOLD_RUNTIME=1: PASS, including its two inert/naivecontrols, on node v26.5.0.
binary built from this branch.
Deliberately not done
app doctorcommand. Out of scope.schema/untouched (vendored, ask-first). Worth flagging though:iframe.resizable's description still reads "Whether the host honoursRESIZE_IFRAME messages", which is arguably wrong for a page app — the host
marks that message N/A on the page surface regardless of the flag. AGENTS.md
item 11 already notes it as a schema-side wording issue; it needs a
server-side decision, not a unilateral edit here.
added in
4018e2c. feat(generate): addcivitai generateandcivitai workflows#210 (feat/generate) is also open and adds items — perthat convention, whichever of us merges second renumbers its own new
items and re-greps the
items N–Mrange clauses.Closes the #206 gap for existing apps.
🤖 Generated with Claude Code