Skip to content

fix(validate): the ready-ack advisory passed an emitter nothing loads - #219

Merged
ZacxDev merged 7 commits into
mainfrom
fix/ack-wiring-check
Aug 6, 2026
Merged

ZacxDev merged 7 commits into
mainfrom
fix/ack-wiring-check

Conversation

@ZacxDev

@ZacxDev ZacxDev commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

civitai app validate's page-without-ack advisory (#206) told authors to do
two things — copy civitai-host.js in, and load it from index.html or
the entry module — and verified only the first. A blind dogfood run of the
shipped CLI found the false pass; I reproduced it independently.

Measured on a genuinely pre-fix scaffold (app init from the CLI at 0ce0025),
emitter copied in and never referenced:

$ grep -c 'civitai-host' index.html
0
$ civitai app validate <dir> --strict
✓ <dir> is valid          # rc=0

The browser never loads the file, so the app is exactly as broken as before —
and the author is told they are fine while obeying our own advice. That is
worse than the silence it replaced. An orphan file containing the literal
anywhere in the tree passed identically.

What changed

The check now resolves the entry graph — index.html, its <script src>
tags and inline modules, and the imports below them — and asks whether a file
the browser loads mentions the message.

That resolution already existed in this repo, as test-only code behind scaffold
Guard A (internal/scaffold/ready_ack_contract_test.go). It moves to
internal/blockproto (entrygraph.go + wiring.go), so one predicate answers
the question for both a template and an author's project — the precedent is
exact: PackageAcksReady was consolidated there for the same reason, and the
second copy was wrong. The three copies of the comment stripper collapse into
blockproto/comments.go alongside it. Guard A's control corpus moved with the
predicate; Guard A's strength is unchanged.

Two tiers, and the message names which one ran:

tier when what it says
reachability (strong) the entry graph resolves completely nothing index.html loads reaches it (orphan emitter) or nothing index.html loads posts it either
presence only (weak) the graph is incomplete the old whole-tree scan — and the message states it did NOT check that the file is loaded

Still a Warning, never an Error, for every reason already recorded in
AGENTS.md item 18.

The decidability boundary, and why

The obvious boundary is "static shape ⇒ decidable, bundler ⇒ not". I did not
use it
, and the first draft that did was wrong in both directions: an ordinary
Vite project resolves perfectly (index.html is Vite's entry, which is how
Guard A has checked page-vite all along), while a no-build project can still
carry a specifier we cannot follow. Drawing the line at project type would have
left the whole page-vite population — half the pre-fix apps — on the broken
tier.

So the boundary is completeness of the resolution itself. ResolveEntryGraph
reports Complete, and any reference it cannot account for clears it:

  • a bundler alias, or any bare specifier that is not a declared npm dependency
    (import '@/civitai-host.js');
  • an off-project or protocol-relative URL, or a path escaping the project root;
  • a reference resolving to a file that is not there;
  • a file it could not read, or an exhausted budget;
  • no index.html at the project root at all.

A bare specifier naming a declared dependency is accounted for — it is a
package, not a file in this project — which is the only reason a React app
resolves at all. packageDeps therefore returns the dependency names alongside
the ack verdict, from one read of package.json.

🔴 A reference to a file that is not there is a GAP, not a decided absence.
Tempting to read it as "the browser 404s that, so it cannot be the ack" — but a
project that presumably builds having an unresolvable reference means our model
is wrong
, and a confident finding on a wrong model is the failure this PR is
about. It also keeps two documented trades alive unchanged: deleting the emitter
from a current scaffold (leaving a dangling <script src>) drops to the presence
tier, and item 18's public/-holds-a-stale-ack false negative stays a false
negative instead of silently becoming a warning.

"Cannot observe" does not become "everything passes." An incomplete graph
never produces a wiring finding (item 10's doctrine), but the presence finding
still fires when nothing in the tree mentions the message at all, and its text
discloses its own weakness. The residual is stated rather than hidden: an
unresolvable graph plus the literal somewhere is silence — a false negative,
the cheap direction. An unobservable tree scan (unreadable file, size cap, file
budget) still gates both tiers.

Measured before/after

before = e800129 (current main, the shipped defect). after = this branch.
Projects scaffolded with the CLI at 0ce0025, so they are genuinely pre-#206.

FIXTURE                BEFORE (e800129)               AFTER (this branch)
control-noemitter      WARN         rc=0 strict=1     WARN/missing   rc=0 strict=1
static-unwired         silent       rc=0 strict=0     WARN/unwired   rc=0 strict=1
static-orphan          silent       rc=0 strict=0     WARN/unwired   rc=0 strict=1
vite-unwired           silent       rc=0 strict=0     WARN/unwired   rc=0 strict=1
static-wired           silent       rc=0 strict=0     silent         rc=0 strict=0
vite-wired             silent       rc=0 strict=0     silent         rc=0 strict=0
fresh-static           silent       rc=0 strict=0     silent         rc=0 strict=0
fresh-page-vite        silent       rc=0 strict=0     silent         rc=0 strict=0
fresh-page-money       silent       rc=0 strict=0     silent         rc=0 strict=0

control-noemitter is the harness positive control: a pre-fix project with
no emitter anywhere, which must warn on both binaries. Without it, an
all-silent BEFORE column is indistinguishable from a probe wired to nothing.
--strict moves the exit code to 1 on exactly the warning rows and nowhere else.

What the check now proves, and what it still cannot

Proves, on the strong tier: a file your index.html actually loads mentions
BLOCK_READY outside a comment
— resolved, not grepped, and not basename-
matched.

Still cannot prove:

  • that the ack fires. No static check can; an inverted event.source guard
    passes everything here. That is Guard B's job for templates, and there is no
    equivalent for an app the author already has.
  • wiring behind a bundler alias, a computed import(expr), a plugin-injected
    entry, or a framework-owned entry with no root index.html.
    These land on
    the presence tier, which says so in its own text.
  • anything about a project whose tree it could not fully read. Silence, as
    before.

Mutation results

20 mutants, restore by file-copy snapshot with a sha256 check both directions
(the first attempt restored with git checkout and silently left every untracked
file mutated — noted so nobody rebuilds that harness). Every mutant was confirmed
to change the file before the run; each kill is attributed to the test and the
assertion message.

mutant verdict killed by
M0 null (comment-only) SURVIVED ✓ — (must survive)
M1 restore the defect (presence only) KILLED TestEmitterPresentButNotLoadedWarns — tier = "", want "unwired"
M2 old precedence (a literal anywhere wins) KILLED same
M3 every bare specifier is a package KILLED TestReadyAckDecidabilityBoundary/a_bundler_alias…
M4 dependency match == → prefix KILLED same
M5 // guard → /// KILLED TestReadyAckWiringPredicate/reject: protocol-relative URL…
M6 drop root containment KILLED …/reject: an import that escapes the project root
M7 missing file is not a gap KILLED TestReadyAckWarning/a_non-conventional_outputDir… + boundary test
M8 stop reading inline <script> imports KILLED …/accept: an inline module in index.html imports it
M9 drop extensionless resolution KILLED …/accept: an extensionless import…
M10 file budget is not a gap KILLED TestEntryGraphBudgetsAreGaps/the_file_budget_is_a_gap
M11 drop the graph's source-extension gate KILLED …/a_stylesheet_in_the_graph_is_not_ack_evidence
M12 delete the presence tier's disclosure KILLED TestReadyAckAdvisoriesStateTheirOwnStrength
M13 unterminated <!-- becomes lossy again KILLED TestReadyAckWarning/an_unterminated_<!--_in_.html…
M14 stop respecting JS string literals KILLED …/a_URL_literal_does_not_swallow_the_ack_after_it
M15 HTML-strip every extension KILLED …/a_matched_<!--_-->_pair_in_.js_strings…
M16 drop the unobservable-tree gate KILLED TestReadyAckCannotObserve/a_directory_holding_only_a_manifest…
M17 missing index.html is not a gap KILLED …/an_ack_in_a_.vue_single-file_component_does_not_warn
M18 make ErrNoScriptTags unreachable KILLED …/reject: no script tags at all
M19 Guard A depth 2 → 99 survived, then fixed now …/reject: the emitter is two import levels below the entry

M19 is the finding worth reading: nothing in the suite held Guard A's documented
"one level of imports on purpose" contract. The corpus case that pins it is in
this PR, and re-running M19 kills it.

Tests

New fixtures are rendered templates, mutated — a hand-written string fixture
carries none of the template's comments, import graph or near-miss shapes. The
mutation helper fails if its replacement is a no-op, so a template rename
cannot silently turn a test into "the project was never broken".

  • emitter present and wired (<script src>, and moved to vendor/ with the tag
    followed) → silent
  • emitter present, not wired, on static and page-vite → warns
    (unwired)
  • emitter wired via an entry-module import → silent
  • orphan file containing BLOCK_READY → warns
  • @civitai/blocks-react project → silent, asserted to be silent because of the
    dependency
    (scanForReadyAck = ackAbsent on that tree)
  • undecidable shapes asserted explicitly: bundler alias with the emitter present
    → silent (documented residual), same alias with it deleted →
    presence-only, no root index.html → presence-only, dangling reference →
    presence-only, genuinely pre-fix project → missing (reachability)
  • TestShippedSDKFreeTemplatesResolveCompletely — a seam guard so the strong
    tier cannot go quietly dead: if a template edit made the shipped scaffolds
    unresolvable, every real project would silently fall to the presence tier while
    every "no warning" assertion stayed green.

make ci

Green. Counts from go test ./... -v -count=1, not an exit code:
=== RUN 2024, --- PASS 2020, --- FAIL 0, --- SKIP 4, 0 timeout panics,
18/18 packages ok, gofmt -s -l . silent. The 4 skips are the pre-existing
env-gated ones (TestScanDirFromEnv, TestSubmissionsCapDriftAgainstLiveAPI,
TestScaffoldPinsSatisfyPublished, TestScaffoldedReadyAckActuallyFires);
Guard B was additionally run locally with CIVITAI_CHECK_SCAFFOLD_RUNTIME=1 and
passes, including both of its own controls.

Docs

AGENTS.md gains item 20 (append-only numbering, next free number) for the
tier split, the boundary and its rejected alternative, and the measured matrix.
Items 11 and 18 are corrected in place: 11 records the resolver's move
into blockproto and the newly-pinned depth bound; 18's "mentioned in code"
claim becomes "code the browser loads" and points at 20. README documents both
tiers plus the thing an author actually needs — that copying the emitter in is
half the fix, with the exact reference each template uses.

Refs #206, #212. No changes to schema/, the emitter, or any template.

🤖 Generated with Claude Code

ZacxDev and others added 3 commits August 5, 2026 23:43
`civitai app validate`'s page-without-ack advisory told authors to do two
things — copy `civitai-host.js` in, and LOAD it from index.html or the entry
module — and verified only the first. Measured on a genuinely pre-fix scaffold
(built from the CLI at 0ce0025): with the emitter copied in and never
referenced, `civitai app validate --strict` printed `✓ … is valid` and exited
0 for an app that was still exactly as broken as before #206. An orphan file
containing the literal anywhere in the tree passed identically.

The check now resolves the ENTRY GRAPH — index.html, its `<script src>` tags
and inline modules, and the imports below them — and asks whether a file the
BROWSER LOADS mentions the message. The resolution was already in this repo as
test-only code behind scaffold Guard A; it moves to `internal/blockproto`
(entrygraph.go + wiring.go) so one predicate answers the question for both a
template and an author's project, exactly as `PackageAcksReady` was
consolidated there. The three copies of the comment stripper collapse into
`blockproto/comments.go` with them.

Two tiers, and the message names which one ran:

  - REACHABILITY (strong) when the graph resolves COMPLETELY. Then an emitter
    nothing loads is reported as the orphan it is.
  - PRESENCE ONLY (weak) when the graph is incomplete — no root index.html, a
    bundler alias, a reference to a file that is not there, a budget
    exhausted. Its message discloses, in the same breath as the remedy, that
    it did not check that the file is loaded.

An incomplete graph never produces a wiring finding (AGENTS.md item 10: a
check that cannot observe returns no finding), but "cannot observe" does not
become "everything passes" — the presence finding still fires when nothing in
the tree mentions the message. The residual is stated rather than hidden: an
unresolvable graph plus a literal somewhere is silence, a false negative.

Still a Warning, never an Error (item 18): it infers runtime behaviour from
static text, and `--strict` already gives anyone who wants a gate one.

Measured, pre-fix static + page-vite projects, before (e800129) -> after:
  emitter copied, not wired   silent rc=0 strict 0 -> WARN rc=0 strict 1
  orphan BLOCK_READY file     silent rc=0 strict 0 -> WARN rc=0 strict 1
  same, properly wired        silent               -> silent
  fresh static/page-vite/page-money scaffolds      -> all silent
Harness positive control: a pre-fix project with no emitter warns on BOTH
binaries, so the silent cells above are real false passes.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…ys which ran

AGENTS.md gets item 20 (append-only numbering) for the reachability/presence
split, the decidability boundary and why it is COMPLETENESS rather than
"does the manifest declare a buildCommand", the reference-to-a-missing-file =
gap rule, and the measured before/after matrix with its positive control.
Items 11 and 18 are corrected in place: 11 records that the entry-graph
resolver moved out of Guard A into internal/blockproto (its control corpus
with it) and that the depth bound is now pinned; 18's "mentioned in code" claim
is amended to "code the browser loads", with a pointer to 20.

README documents the two tiers, and — the part an author actually needs — that
copying `civitai-host.js` in is half the fix, with the exact reference each
template uses.

Also adds the corpus case that pins readyAckWiringDepth. Widening it from 2 to
99 was a SURVIVING mutant: the "one level of imports on purpose" contract was
documented and unheld.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Audit of #219 found three 🔴 sharing one root cause: `<script src>` was being
parsed and resolved with JavaScript module-specifier rules. All three
reproduced, each on a project one character from a shipped template.

1. `<script src="app.js">` — no `./`, entirely ordinary HTML — was read as a
   BARE specifier, resolved to nothing, made the graph incomplete, and dropped
   to the presence tier: THE HEADLINE DEFECT, INTACT. The fix did not cover the
   projects it was written for.
     src="./app.js"  -> strict_rc=1 (warns)   src="app.js" -> strict_rc=0 (silent)

2. An unquoted `src=./civitai-host.js`, also legal HTML, was dropped by a
   quotes-only regex and then re-classified as an INLINE script with an empty
   body. The reference vanished with `Complete` still TRUE, so a CORRECT static
   scaffold got the strong tier's warning and --strict rc=1 — a false warning
   at a correct project, the class item 10 records four corrections to avoid.

3. `MaxDepth` truncated the walk without clearing `Complete`, so the STRONG
   tier fired on a partial graph: a correct project whose ack sits ten imports
   below index.html warned with rc=1. Three comments (entrygraph.go, the PR
   body, AGENTS item 20) claimed an exhausted budget made the graph incomplete;
   none was true of this budget.

Root fix: `refSyntax` splits URL from module resolution. Under URL syntax a
specifier that is not scheme-qualified or protocol-relative is
DOCUMENT-RELATIVE, there are no bare specifiers, and there is no extension or
directory-index guessing — which also reverts the accidental acceptance of
`src="./civitai-host"`, a 404 on a no-build template and the exact "ships a
404" shape wiring.go claims to reject. Under module syntax a bare specifier is
a package and a bundler's extension resolution applies. The scheme regex is
anchored: the scheme check runs before the ?/# strip, so an unanchored pattern
throws away `./x.js?from=https://cdn`.

Also fixed, same round:
  - 410 MB -> 39.5 MB peak RSS on a 200-module graph INSIDE the file/size
    budgets (pre-graph baseline on that fixture: 39.5 MB). EntryFile no longer
    retains `Code`; contents go to `Inspect` while in hand, so the walk holds
    one file at a time like the tree scan. `app submit` paid this too.
  - The strength guard was half vacuous: it asserted "index.html loads", a
    phrase from the SHARED remedy fragment every advisory carries, so replacing
    the unwired headline with vague prose passed. Each tier's literals are now
    pinned with inverse controls that no other tier may carry.
  - StripJSComments swallowed the tail of an unterminated `/*` while
    StripHTMLComments deliberately keeps it. Same rule now, same reason.
  - Caps are pinned by value, so a raised cap fails instead of allocating (a
    1<<40 mutant hung the suite twice rather than going red).

Newly pinned branches, each found unpinned by the audit's sweep: unquoted and
single-quoted src, no-leading-./, root-relative, extensionless src vs
extensionless import, URL scheme (anchored), `../` imports, dynamic import(),
declaresPackage's separator boundary, entryModuleExts widening, the `-->`
terminator, backtick strings and backslash escapes, depth truncation in both
directions, and Inspect's own positive control.

Guard A's REJECTION set is unchanged; its ACCEPTANCE set moved twice and both
are now stated in AGENTS item 11 — inline-module imports (a real load it
missed) and the HTML spellings a browser resolves identically.

Battery: 42 mutants, 40 killed with attributed failures, 2 null mutants
survived as required, 0 broken. Every mutant the audit reported surviving
(V11, V20, the fine-grained dependency prefix, the unquoted-src widening, the
Guard A depth bound) now dies against a test added here.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@ZacxDev

ZacxDev commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

Audit round 1 — three 🔴 confirmed, one root cause, fixed in 518e514

I reproduced all three before touching anything, plus the 🟡s. The audit is right and my PR body was wrong. Corrections first, since the falsified claims are the important part.

Claims this PR made that were false

claim where reality
"the headline defect is fixed" PR body, title False for any index.html that omits ./. <script src="app.js"> was read as a bare module specifier → gap → presence tier → silent. Measured: src="./app.js" → strict_rc=1; src="app.js" → strict_rc=0, the shipped defect intact.
"an exhausted budget" makes the graph incomplete entrygraph.go:43-45, PR body, AGENTS item 20 Not true of the depth budget. MaxDepth truncated the walk and left Complete true, so the strong tier fired on a partial graph. A correct project with its ack ten imports below index.html warned with --strict rc=1.
the incomplete bucket is "a bundler alias or other bare specifier that is not a declared dependency" PR body, AGENTS item 20 Under-described to the point of being misleading — nobody maps that phrase to ordinary HTML.
"Guard A's strength is unchanged" PR body Its rejection set was unchanged; its acceptance set moved twice. One was a genuine improvement (inline <script type="module"> imports), one was a bug (extensionless src). Both are now stated in AGENTS item 11.
TestEntryGraphBudgetsAreGaps / "the depth bound is a gap only when there is more to see" test name The test asserted nothing about gaps. The name claimed a property the code lacked.

The root cause

<script src> was parsed and resolved with JavaScript module-specifier rules. That single conflation produced all three 🔴 — two of them opposites, which is why they read as unrelated:

src="app.js"            bare specifier -> gap -> SILENT at a broken app
src=./civitai-host.js   unquoted, regex required quotes -> tag re-read as an
                        INLINE script with an empty body -> reference vanished
                        with Complete still TRUE -> WARNED at a correct app
src="./civitai-host"    extension-guessed to .js -> ACCEPTED, on a no-build
                        template where the browser 404s that URL

refSyntax now splits them. Under URL syntax: not scheme-qualified and not protocol-relative ⇒ document-relative; no bare specifiers; no extension or directory-index guessing. Under module syntax: bare ⇒ package, bundler extension resolution applies. The scheme regex is anchored — the scheme check runs before the ?/# strip, so an unanchored pattern discards ./x.js?from=https://cdn (that mutant survived the first sweep; it now dies).

Depth truncation now records a gap, but only for imports that are not declared packages — counting import 'react' at the bound would make every project as deep as the bound unobservable.

Live matrix (before = e800129, after = 518e514)

(Note: my original matrix already used e800129 as "before". 0ce0025 was used only to scaffold genuinely pre-#206 projects, never as a comparison binary — the audit's read of that was the one place I'd push back.)

FIXTURE                        BEFORE (e800129)              AFTER
control-noemitter              WARN         rc=0 strict=1    WARN/missing   rc=0 strict=1
static-unwired                 silent       rc=0 strict=0    WARN/unwired   rc=0 strict=1
static-unwired-nodotslash  🔴1  silent       rc=0 strict=0    WARN/unwired   rc=0 strict=1
correct-unquoted-src       🔴2  silent       rc=0 strict=0    silent         rc=0 strict=0
correct-nodotslash              silent       rc=0 strict=0    silent         rc=0 strict=0
correct-deep               🔴3  silent       rc=0 strict=0    silent         rc=0 strict=0
static-orphan                   silent       rc=0 strict=0    WARN/unwired   rc=0 strict=1
vite-unwired                    silent       rc=0 strict=0    WARN/unwired   rc=0 strict=1
static-wired / vite-wired       silent                        silent
fresh static / page-vite / page-money   silent                silent

correct-unquoted-src and correct-deep warned with --strict rc=1 on the previous head of this branch; both are silent now. control-noemitter is the harness positive control (must warn on both binaries).

Memory (🟡 6)

Same 200-module fan-out fixture, every file inside maxAckGraphFiles/maxAckFileBytes:

peak RSS wall
e800129 (no graph) 39.5 MB 1.26 s
this PR, before the fix 410 MB 1.87 s
this PR, after 39.5 MB 2.67 s

Back to the pre-graph baseline exactly. EntryFile no longer carries Code; contents go to EntryGraphOptions.Inspect while in hand, so the walk holds one file at a time like the tree scan. The residual ~1.4 s is the entry walk itself on a 400 MB tree. TestEntryGraphRetainsNoContents pins it structurally rather than by benchmark, since a benchmark would drift.

Mutation battery — 42 mutants

40 killed with attributed failures, 2 null mutants survived as required, 0 broken. Restore is by file-copy snapshot with sha256 verified in both directions, each run timeout-bounded so a hanging mutant is reported rather than wedging the battery.

Every mutant the audit reported surviving now dies:

audit mutant now
E11 unquoted-src widening B1-quotes-required KILLED — TestHTMLSrcIsAURLNotAModuleSpecifier/silent:_unquoted_src
V11 unwired headline → "something is off" F1-unwired-headline KILLED — …StateTheirOwnStrength: the unwired advisory no longer says "DOES contain"
V20 delete the operative disclosure F2-drop-operative-disclosure KILLED — no longer says "will silence this warning"
fine-grained dependency prefix scan G1-deps-prefix-fine KILLED — …/a_bare_specifier_that_merely_starts_like_a_dependency
Guard A depth 2→99 H14-depth-unbounded KILLED — …/reject: the emitter is two import levels below the entry
cap raised to 1<<40 (hung the suite twice) G9-cap-raised KILLED — TestReadyAckCapValues, fails in <1 s

New kills for the root cause and the branches the sweep found unpinned: A1-src-as-bare-specifier, A2-no-url-scheme-check, A3-scheme-boundary (survived the first sweep, now pinned by a query-string-containing-a-URL fixture), B2-src-first-group-only, C1-depth-not-a-gap, C2-depth-gap-always, D1-guess-ext-for-urls, D2-no-ext-resolution-at-all, E1-retain-contents, E2-inspect-index-only, F3/F4/F5 message content per tier, G2-parent-dir-arm, G3-html-terminator (-->→->), G4-backtick, G5-escape, G6-block-comment-lossy, G7-dynamic-import, G8-module-exts-css.

Three mutants came back BROKEN-MUTANT on the first pass — regex needles mangled by re-escaping a Go raw string inside a Python literal. That is a false survivor generator, so they were re-run through a line-anchored harness that takes the needle out of the file itself; all three then killed.

🟡/🟢 also done

7 strength guard rewritten (literals unique to one tier + inverse controls). 8 branches pinned as listed. 9 StripJSComments no longer swallows the tail of an unterminated /* — same rule and same reason as the HTML half, which is what the asymmetry should have been all along. 12 the v0.1.90 citation is gone. 13 caps pinned by value, plus a bound in the cap fixtures so an absurd constant fails fast instead of allocating.

Not done / disagreements

  • Windows path-case — out of scope per the audit, pre-existing.
  • 0ce0025 as a "before" binary — I never used it as one; it only scaffolded pre-Scaffolded 'static' (default) and 'page-vite' apps never send BLOCK_READY — the host times out and collapses them #206 projects. Flagging in case that assumption propagated elsewhere.
  • The extensionless-src project now gets silence, not a warning. After the fix that reference resolves to nothing, which is a gap → presence tier → the tree holds the literal → quiet. Honest (we stopped modelling) rather than the previous false claim that the emitter was wired, but it is still a false negative. Asserted explicitly in TestHTMLSrcIsAURLNotAModuleSpecifier including the Complete == false check, so nobody reads the silence as approval.
  • MaxDepth/MaxFiles left at 8/200. Now that truncation is a gap, a genuinely large app falls to the presence tier more often than before. That is the correct direction (quiet, disclosed) and the Scaffolded 'static' (default) and 'page-vite' apps never send BLOCK_READY — the host times out and collapses them #206 population is small apps, but it does mean the strong tier covers less than the numbers suggest. Raising them is a separate, measurable change.

Gate

make ci green. go test ./... -v -count=1: === RUN 2065, --- PASS 2061, --- FAIL 0, --- SKIP 4 (the pre-existing env-gated ones), 0 timeout panics, 18/18 packages ok, gofmt -s -l . silent. Guard B run locally with CIVITAI_CHECK_SCAFFOLD_RUNTIME=1 — passes with both its own controls. git status --porcelain empty; every mutation reverted and checksum-verified.

🤖 Generated with Claude Code

…r half of the memory fix

Round-2 delta audit found two REGRESSIONS from the previously-audited tip and
one claim I had marked fixed that was only half fixed. All reproduced locally
before any change.

N2 — `\b` is not an HTML attribute-name boundary. It matches between `-` and
`s`, so `\bsrc\s*=` read `data-src=`/`x-src=` as `src=`, and `<script\b` read
`<script-loader>` as a script. Measured on a CORRECT static scaffold with
`<script data-src="./app.js" src="./civitai-host.js">` — a real consent-manager
/ lazy-load pattern — the wrong reference resolved, `Complete` stayed true, and
the STRONG tier warned with --strict rc=1. That is the same false-warning class
the unquoted-src fix had just closed, reintroduced by that fix. RE2 has no
lookahead, so the boundaries are now `(?:^|[\s/])src\s*=` and a required
`[\s/>]` after `<script`.

N3 — the truncation gap over-fired and silenced the defect this PR exists to
catch. At the depth bound it gapped for any non-package specifier WITHOUT the
dedupe the normal path does, so a DIAMOND — the normal shape of any real module
graph — whose deepest module re-imports an already-walked file produced a gap
whose message was literally false about a file sitting in g.Files, dropped the
project to the presence tier, and let an orphaned emitter pass with rc=0.
Measured; a self-cycle did the same. `truncatedBelow` now answers "no" for a
declared package AND for a target already in the graph.

N1 — the memory fix was half a fix, and three 🔴 comments asserted a property
the binary lacked. A Go substring shares its parent's backing array, so an
un-cloned import specifier pins its whole file, held in both the BFS queue and
EntryFile.Spec. Re-measured on a fixture that genuinely reaches 200 files
inside both caps, every module ~2 MiB of REAL code AND carrying an import:

  e800129, before the graph existed   26.4 - 27.8 MB
  retaining EntryFile.Code             421 - 439 MB
  Code dropped, specifiers aliased     558 - 628 MB
  both fixed (strings.Clone)          31.4 - 33.3 MB

My earlier "39.5 MB, one file at a time" came from a fixture the depth bound
truncated to ten files, padded with COMMENTS so almost nothing survived
stripping. The fixture shape IS the measurement; the comments now carry the
table and name the shape. TestEntryGraphRetainsNoContents states in its own
body that it CANNOT see the aliasing half — strings.Contains reads the logical
string, not the backing array — so nobody cites it as proof again.

N4 — the strength guard was still half vacuous on the third tier: all three of
the presence tier's asserted literals lived in its trailing disclosure, so
replacing its OPENING diagnosis survived. The shared "nothing in this project's
source posts" sentence is now asserted as set membership across exactly the two
tiers that report an absence.

N5/N6 — pinned: the `rel == ".."` containment arm (reachable via directory-index
resolution), srcAttrValue's empty-src verdict, single-letter and uppercase URL
schemes, and the JS `*/` terminator. Corrected: the scheme-check/?#-strip ORDER
is NOT load-bearing (two sweeps swapped it with nothing failing) — only the `^`
anchor is; AGENTS.md and the test comment both said otherwise.

Battery: 52 mutants, 49 killed with attributed failures, 2 null mutants
survived as required. One documented survivor: dropping strings.Clone, which no
unit test can observe — the guard is the live RSS measurement above, and the
test says so rather than implying coverage it does not have.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@ZacxDev

ZacxDev commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

Audit round 2 — two regressions and a half-fix, corrected in 6288c88

All six findings reproduced locally before I changed anything. Two were regressions I introduced in 518e514, one in the exact class that commit had just closed. Corrections first.

Claims from 518e514 that were false

claim where reality
the graph "holds ONE file at a time exactly like the tree scan" entrygraph.go:110-116, readyack.go:224-231, AGENTS.md:1030-1041 False. Dropping EntryFile.Code was half the fix. A Go substring shares its parent's backing array, so an un-cloned import specifier pinned its whole 2 MiB file — held in the BFS queue and EntryFile.Spec. Measured 558–628 MB.
"39.5 MB, matching the pre-graph baseline" AGENTS.md:1041 Measured on the wrong fixture — a chain the depth bound truncated to 10 files, padded with comments so nothing survived stripping. Neither hazard was exercised.
pre-graph baseline "~40 MB" vs "~17 MB" AGENTS vs the source comments Inconsistent, and both were guesses at a number I had not measured on a comparable fixture. My measurement: 26.4–27.8 MB at e800129 on the 200-module fixture.
the scheme-check / ?#-strip order is load-bearing AGENTS.md, entrygraph_test.go:267 False, as both your sweeps found. A scheme-qualified specifier stays scheme-qualified once its query is removed. Only the ^ anchor matters. Corrected in both places.
"an exhausted budget makes the graph incomplete" (depth) fixed in 518e514 Now true — but the fix over-fired, see N3.

N2 — \b is not an HTML name boundary (reproduced; I'd call this 🔴 too)

\b matches between - and s. Measured on a correct static scaffold:

ctlgood      (untouched)                  strict_rc=0  findings=0
datasrc      data-src added before src    strict_rc=1  findings=1   FALSE WARNING, strong tier
xsrc         x-src added before src       strict_rc=1  findings=1   FALSE WARNING
brokenctl    emitter removed              strict_rc=1  findings=1   positive control

RE2 has no lookahead, so: (?:^|[\s/])src\s*= for the attribute, and a required [\s/>] after <script for the tag. After the fix all three correct projects are silent and brokenctl still warns. The inverse control is pinned too — a data-src carrying the only reference to the emitter must still warn (TestAttributeNameBoundary/warns:_the_emitter_is_referenced_only_by_data-src), or "ignore data-src" would be indistinguishable from "ignore every src".

N3 — the truncation gap over-fired and silenced the headline defect

Confirmed exactly as reported. At the bound I gapped for any non-package specifier without the g.FileAt(file) >= 0 dedupe the normal path does:

                    HEAD@518e514        after 6288c88
diamond             silent  rc=0        UNWIRED  rc=1
selfcycle           silent  rc=0        UNWIRED  rc=1
control (nothing below the bound)   UNWIRED rc=1  (both)

The gap message was literally false — it named a file sitting in g.Files. truncatedBelow now answers "no" for a declared package and for an already-walked target. A gap that over-fires is not conservative; it is the false pass wearing a different hat. A negative control pins the other direction: a genuinely unwalked module below the bound must still gap, or the dedupe has simply disabled the guard.

N1 — memory, re-measured on a fixture that actually reaches 200 files

Every module ~2 MiB of real (non-comment) code and carrying an import — the shape both hazards need. Graph reach verified at 200/200 before measuring; 3 runs each:

build peak RSS
e800129, before the graph existed 26.4 – 27.8 MB
retaining EntryFile.Code 421 – 439 MB (your figure)
Code dropped, specifiers aliased (518e514) 558 – 628 MB
both fixed (strings.Clone) 31.4 – 33.3 MB

The residual ~5 MB over the tree scan is the graph reading its files at all; the property that matters is O(one file), not O(graph). The fixture shape is now stated beside every number, in the source and in AGENTS.md, because that is what went wrong the first time.

TestEntryGraphRetainsNoContents now says in its own body that it cannot see the aliasing half — strings.Contains reads the logical string, not the backing array — so it can't be cited as coverage again. I could not make that half structural; the guard is the live measurement, and the test says so.

N4 — the third tier's opening diagnosis

Reproduced: all three of the presence tier's asserted literals lived in its trailing disclosure, so replacing its opening survived. The shared "nothing in this project's source posts" sentence is now asserted as set membership — present in exactly the two tiers that report an absence, absent from the one that fires because the message is present. N4a-presence-headline now dies.

N5 / N6

Pinned: the rel == ".." containment arm (reachable via directory-index resolution — import '../..' with an index.js in the parent), srcAttrValue's empty-src verdict (a tag with a src is external, so its body must not execute), single-letter and uppercase URL schemes, and the JS */ terminator (the HTML half had a dedicated case, the JS half didn't). Doc claims corrected as tabled above.

Battery — 52 mutants

49 killed with attributed failures, 2 null mutants survived as required, 1 documented survivor.

Regressions and previously-unpinned branches, each attributed to a test added here:

mutant killed by
N2a-attr-boundary-b (\b back on the attribute) TestAttributeNameBoundary/silent:_data-src_before_src
N2b-tag-boundary-b (\b back on the tag) …/reject: a <script-loader> custom element is not a script tag
N3a-truncation-no-dedupe TestDiamondAtTheDepthBoundStillWarns/diamond:…
N3b-truncation-never …/negative control: a real truncation still gaps
N4a-presence-headline …StateTheirOwnStrength: no longer opens by saying WHAT WAS FOUND
N5a-containment-dotdot-arm TestEntryGraphRootContainment
N5b-empty-src-inline …/reject: a body import inside a tag that has an (empty) src
N5c-js-terminator TestStripJSComments/a_star_inside_a_block_comment…
N5d-scheme-class-narrow …/reject: a single-letter scheme is still a URL
A3-scheme-boundary (survived round 2) …/accept: a local src whose query string contains a URL

The documented survivor: N1a-no-clone. Dropping strings.Clone passes the entire unit suite, and no unit test can see it — a backing array is invisible to every assertion Go gives you here. Reported as a survivor rather than papered over; the guard is the RSS table above.

Five needles came back BROKEN-MUTANT because the code they targeted moved in this round — C1/C2 are superseded by N3a/N3b (same branch, new implementation), and B1/F2/G7 were re-run through the line-anchored harness and all three killed. Every mutation is checksum-verified as applied and as reverted; git status --porcelain is empty.

Live matrix (before = e800129)

Re-run in full. Every fresh scaffold stays silent:

control-noemitter          WARN rc=0 strict=1  →  WARN/missing  rc=0 strict=1
static-unwired             silent            →  WARN/unwired  rc=0 strict=1
static-unwired-nodotslash  silent            →  WARN/unwired  rc=0 strict=1
static-orphan              silent            →  WARN/unwired  rc=0 strict=1
vite-unwired               silent            →  WARN/unwired  rc=0 strict=1
correct-unquoted-src       silent            →  silent
correct-nodotslash         silent            →  silent
correct-deep               silent            →  silent
static-wired / vite-wired  silent            →  silent
fresh static / page-vite / page-money        →  silent

Every probe ran behind a fixture-existence control (8/8 index.html present, emitter counts asserted per fixture) — your wiped-directory incident is exactly the shape where a grep -c of 0 reads as "no warnings".

⚠️ No remote CI signal

GitHub Actions is stalled repo-wide — checks on this branch have sat queued with 0 s elapsed for hours, and runs on main are queued too; no runner has picked anything up. I have not seen a green check for this branch and am not claiming one. Local only:

make ci green. go test ./... -v -count=1: === RUN 2086, --- PASS 2082, --- FAIL 0, --- SKIP 4 (the pre-existing env-gated ones), 0 timeout panics, 18/18 packages ok, gofmt -s -l . silent. Guard B run locally with CIVITAI_CHECK_SCAFFOLD_RUNTIME=1 — passes with both its own controls. A missing check is not a passing check; these all need re-running once runners return.

🤖 Generated with Claude Code

…d not answer yet

Round-3 audit: the truncation dedupe consulted `g.Files`, but files enter there
when POPPED, not when QUEUED. A target already enqueued therefore looked absent,
so two modules at exactly MaxDepth where the first-enqueued imports the second
gapped — or did not — according to THE TEXTUAL ORDER OF TWO IMPORT STATEMENTS.
In the losing order an orphaned emitter shipped silently. Reproduced on real
scaffolds, flat and nested:

                     518e514   6288c88   HEAD
  deepest imports nothing   warns    warns     warns
  diamond                   silent   warns     warns
  deepest imports its
    not-yet-walked sibling   silent   SILENT    warns
  same graph, imports
    textually swapped        silent   warns     warns

The check is now DEFERRED to the end of the walk: once the queue drains,
`g.Files` is final and the answer cannot depend on ordering. Pinned by two
copies of one graph with the imports swapped, plus a nested variant — the base
directory argument was only ever proven where root and module dir coincide.

Also pinned (all survived the previous sweep):
  - both reScriptBlock changes from the last commit: `</script >` must close an
    inline module, `</scriptx>` must not, and a <script-loader> body is not a
    script. My first draft of the `</scriptx>` case asserted the opposite and
    was wrong about HTML — a browser keeps parsing past a bogus close tag, so
    it is an ACCEPT, and the accept is what discriminates the widening.
  - truncatedBelow's refUnresolved and resolveRefPath-error arms: a bundler
    alias or a dangling import at the bound must still gap, or the STRONG tier
    fires at a correct project.

Dropped the unreachable `^` alternative in reSrcAttr rather than leaving a
branch no mutation can exercise: reScriptOpen's capture is `([\s/][^>]*)?`, so
an attribute list is either empty or starts with whitespace or `/`.

AGENTS.md: every memory row now names its fixture (the `e800129` row is the
whole-tree grep, so it moves with the tree — an independent measurement on a
smaller tree put it at 17.6-17.8 MB; both are right about their own fixture,
and the durable fact is the ~18x ratio). Adds an explicit RESIDUALS list: the
extensionless-src false negative, large graphs falling to the presence tier
more often than the caps suggest, the aliasing property guarded by a
measurement rather than a test, the pre-existing ` src=`-inside-an-attribute-
value hijack, and computed import(expr) being unmatched.

Battery: 57 mutants, 54 killed with attributed failures, 2 null survived as
required, 1 declared survivor (strings.Clone, unobservable to any unit test).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@ZacxDev

ZacxDev commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

Audit round 3 (final) — F1 fixed in fd8cf9b, residuals now written down

F1 reproduced exactly as reported, and the fix is a shape change rather than another condition.

F1 — the dedupe asked g.Files a question it could not answer yet

Files enter g.Files when popped, not when queued, so a target already enqueued looked absent. Measured on real scaffolded static projects with an orphaned emitter, all identical but one import line:

project 518e514 6288c88 fd8cf9b
deepest module imports nothing (control) warns warns warns
diamond silent warns warns
deepest imports its not-yet-walked sibling silent SILENT ❌ warns ✅
same graph, imports textually swapped silent warns warns

The import-order pair, both orders, flat and nested — all four now identical:

flat-ab     before(e800129) rc=0  |  HEAD rc=1  UNWIRED
flat-ba     before(e800129) rc=0  |  HEAD rc=1  UNWIRED
nested-ab   before(e800129) rc=0  |  HEAD rc=1  UNWIRED
nested-ba   before(e800129) rc=0  |  HEAD rc=1  UNWIRED

(Fixture control reported alongside: 4/4 carry the orphaned emitter.)

The fix defers the truncation check to after the walk drains, when g.Files is final — so the answer cannot depend on ordering at all, rather than depending on it correctly. Consulting the queue as well would have worked; deferring removes the class instead of the instance.

F2 / F3 / F4 — pinned

  • F2: </script > must close an inline module (M9), </scriptx> must not end one early (M10), and a <script-loader> body is not a script (M8). ⚠️ My first draft of the </scriptx> case asserted the opposite and was wrong about HTML — a browser keeps parsing past a bogus close tag, so it is an accept, and the accept is what discriminates the widening. Corrected before commit.
  • F3: refUnresolved (M16) and resolveRefPath-error (M17) arms both pinned — a bundler alias or dangling import at the bound must still gap, or the strong tier fires at a correct project. M29 pinned by a nested fixture (src/deep/); every previous fixture was root-flat, where root and module dir coincide.
  • F4: dropped the ^ alternative rather than documenting an unreachable branch. reScriptOpen's capture is ([\s/][^>]*)?, so an attribute list is either empty or starts with [\s/].
  • F5: every memory row now names its fixture. The e800129 row is the whole-tree grep, so it scales with the tree, not the graph — your 17.6–17.8 MB and my 26.4–27.8 MB are both right about their own fixture. The durable fact is the ratio, and the ~18× figure is now in the N1a disclosure as you asked.

Residuals, now recorded in AGENTS.md item 20

Written down because every one was found by an audit rather than by me, and a residual nobody records is indistinguishable from a bug nobody noticed:

  1. Extensionless src → gap → presence tier → quiet. Correct, but a false negative, not approval.
  2. Large graphs fall to the presence tier more often than the caps suggest — with truncation a gap, anything deeper than MaxDepth or wider than MaxFiles is presence-only. The strong tier covers small and pre-fix apps, which is the Scaffolded 'static' (default) and 'page-vite' apps never send BLOCK_READY — the host times out and collapses them #206 population, not big ones.
  3. The strings.Clone property is guarded by a measurement, not a test — dropping it passes the entire suite at ~18× peak RSS. Declared survivor; the test says in its own body that it cannot see that half.
  4. src= inside an attribute value hijacks the reference (<script data-x="foo src=./nope.js" src="./x.js">). Pre-existing and byte-identical before/after this work — fixing it needs a real attribute parser, which is a bigger change than this check earns.
  5. Computed import(expr) is unmatched — the one residual that makes the graph smaller without setting a gap.

Battery — 57 mutants

54 killed with attributed failures, 2 null mutants survived as required, 1 declared survivor.

mutant killed by
F1a-truncation-inline-again …/the bound is order-independent (import A then B)
F2a-close-tag-strict …/accept: an inline module closed by </script >``
F2b-close-tag-wide …/accept: an inline module continues past a bogus ``
F2c-inline-tag-boundary …/reject: an import inside a <script-loader> body is not a load
F3a-unresolved-not-truncation …/a bundler alias at the depth bound is a gap
F3b-danglingref-not-truncation …/a dangling import at the depth bound is a gap
F3c-truncation-wrong-basedir …/the bound resolves against the importing module's directory
N3a / N3b (re-pointed at the deferred shape) TestDiamondAtTheDepthBoundStillWarns + its negative control

N1a-no-clone remains the sole declared survivor. Four needles moved when reSrcAttr changed for F4 and were re-run line-anchored (B1, N2a, F2, G7) — all four killed. Every mutation checksum-verified as applied and as reverted; git status --porcelain empty.

Live matrix (before = e800129) — every fresh scaffold silent

control-noemitter          WARN rc=0 strict=1  →  WARN/missing  rc=0 strict=1
static-unwired             silent  →  WARN/unwired  rc=0 strict=1
static-unwired-nodotslash  silent  →  WARN/unwired  rc=0 strict=1
static-orphan              silent  →  WARN/unwired  rc=0 strict=1
vite-unwired               silent  →  WARN/unwired  rc=0 strict=1
correct-unquoted-src / correct-nodotslash / correct-deep   silent → silent
static-wired / vite-wired                                  silent → silent
fresh static / page-vite / page-money                      silent → silent

Source-fixture existence control reported beside it: 5/5 present. Memory re-checked on mem200b: HEAD 31.8–33.1 MB vs e800129 26.9–32.7 MB.

⚠️ Local-only gate

Remote CI is still stalled repo-wide — no runner has picked up this branch or main. I have not seen a green check and am not claiming one.

make ci green locally. go test ./... -v -count=1: === RUN 2094, --- PASS 2090, --- FAIL 0, --- SKIP 4 (pre-existing env-gated), 0 timeout panics, 18/18 packages, gofmt -s -l . silent. Guard B passes locally with CIVITAI_CHECK_SCAFFOLD_RUNTIME=1. All five required contexts still need a real run.

🤖 Generated with Claude Code

ZacxDev and others added 2 commits August 6, 2026 17:56
The CI workflow run for 6288c88 and fd8cf9b was never created — GitHub
dropped the workflow_run during a repo-wide Actions outage (CodeQL runs for
the same commits were created and executed, so the pull_request event itself
arrived). No workflow_dispatch trigger on ci.yml, so an empty commit is the
way to fire a fresh synchronize. Squash-merge collapses this.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@ZacxDev ZacxDev closed this Aug 6, 2026
@ZacxDev ZacxDev reopened this Aug 6, 2026
@ZacxDev
ZacxDev merged commit 3ffd735 into main Aug 6, 2026
12 checks passed
ZacxDev added a commit that referenced this pull request Aug 6, 2026
On 2026-08-06 a GitHub Actions incident throttled webhook triggers. Push and
pull_request events stopped creating workflow runs entirely — for ~3.5 hours
no ci.yml run was created anywhere in the repo. Events were still arriving:
GitHub-managed workflows (CodeQL) fired and completed on the same commits,
so only user workflow runs went missing.

PR #219 sat unmergeable with no recovery path. Every remedy depends on the
trigger that was broken:

  - `gh run rerun` needs an existing run for the head sha; none was created
  - an empty commit fires `synchronize` — throttled
  - close + reopen fires `reopened` — throttled
  - `workflow_dispatch` — not declared

workflow_dispatch is the only trigger that does not ride a webhook. It cannot
be applied retroactively, because a dispatchable workflow must already exist
on the default branch — so it only helps if it lands before the next
incident, which is the whole argument for adding it now.

No job, permission or step changes: the diff is 15 added lines, 14 of them
comment. actionlint clean, verified against a positive control (it reports 16
findings on a deliberately-bad runner label, so its silence here is
meaningful).

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.

2 participants