Skip to content

fix(dashboard): serve worker assets no-store so a header-only upgrade reaches browsers - #15476

Merged
chenmingwei23 merged 2 commits into
mainfrom
fix/browser-stale-csp-immutable-15337
Oct 3, 2026
Merged

chenmingwei23 merged 2 commits into
mainfrom
fix/browser-stale-csp-immutable-15337

Conversation

@chenmingwei23

@chenmingwei23 chenmingwei23 commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A gateway upgrade that changes only a response header (a CSP directive) reaches browser users, instead of leaving their worker scripts frozen on a stale build's header for up to a year.

The dashboard serves content-hashed /assets/ files with public, max-age=31536000, immutable. A build that changes only a response header keeps the identical hashed filenames, so a browser that cached a file replays its old header. For a worker script this is a live defect: a same-origin worker takes its CSP from its own script response header, not from the document. After a header-only upgrade (for example widening script-src for a new WASM engine) the browser keeps replaying the worker's old CSP, its WASM instantiation is refused, and every diff/highlight surface dies until a hard refresh the user has no reason to perform.

Why it matters

Every browser user who cached a worker before a header-only upgrade is stranded: the highlight/diff engines silently fail and neither a tunnel rebuild nor a gateway restart fixes it, because the cache key is the local URL. Only a manual hard refresh clears it. The desktop shell half (PR #15323) clears the Electron cache per app+gateway version; a browser cannot be told to drop a cache entry, so this half stops the worker's header from being frozen for a year in the first place.

Not a goal

  • No change to plain JS/CSS chunk caching — those run under the document's CSP (served no-store, always fresh), so their stale header is harmless and they keep the immutable policy that spares the ~6MB entry bundle a re-download per load.
  • Not folding a build id into asset URLs or query strings (the issue's other option): it needs build-tooling changes and only helps if the id reliably changes on a header-only build, whereas the worker cache policy fixes exactly the exposed asset class at the serving layer.

What changed (motivation → approach → change)

Symptom: after a header-only upgrade a browser's cached worker runs an old CSP and diff/highlight surfaces stay dead. Root cause: /assets/ worker scripts are cached immutable, but a worker's runtime CSP comes from its own cached response header, and Vite hashes a chunk by content only — so a header-only build reuses the same worker URL and the year-cached header is never re-fetched. Change: _asset_cache_control classifies a /assets/ path — worker chunks (matched by the worker substring Vite stamps into every worker chunk name, case-insensitive) get a SHORT-LIVED cacheable policy (public, max-age=60, stale-if-error=86400) instead of immutable; every other hashed chunk keeps immutable. A 60-second max-age re-fetches the worker within a minute of a header-only build (bounding the stale-CSP window to a minute of degraded highlight, not a year) AND keeps the bytes cache-servable across a brief gateway-down window — a bare no-store would evict them and make the worker unloadable exactly then. The policy deliberately omits no-cache/must-revalidate, which forbid the cache reuse the gateway-down survival depends on; stale-if-error is a best-effort grant to a caching tunnel/proxy (no mainstream browser honours it), so for a plain browser the gateway-down coverage is the max-age window alone. The prepare-time finalizer downgrades an errored worker path to no-store so neither the browser caches the error nor an intermediary serves an orphaned worker's stale bytes.

Backwards compatibility

Compatible: worker chunks are re-fetched after a 60-second fresh window instead of served from cache for a year, and no request is rejected, renamed, or removed. All other assets keep their existing policy.

Tests

  • test_worker_assets_use_short_lived_not_immutable_or_no_store: worker chunks carry max-age=60, never immutable, never no-store, and — the header contradiction Opus flagged — never no-cache/must-revalidate. Fails on base, where a worker path gets immutable.
  • test_non_worker_assets_stay_immutable: plain JS/CSS chunks keep immutable, pinning the exemption as surgical.
  • test_every_built_worker_chunk_carries_the_marker: scans the frontend source for worker constructions (new Worker(new URL(...)), ?worker) and asserts each resolves, in the built dist, to a chunk carrying the marker — so a worker Vite renames to drop the marker (silently regaining immutable) fails the build. Skipped in a python-only/unbuilt checkout.
  • test_present_worker_asset_uses_short_lived_policy / test_missing_worker_asset_is_downgraded_to_no_store: drive the real static mount + middleware + finalizer to assert the wire headers, including that the policy carries no no-cache/must-revalidate and that a worker 404 loses the cacheable policy.

Manual verification

N/A — the change is at the response-header layer and unit coverage exercises the worker, non-worker, and errored-worker paths through the real serving stack.

Related Issues

Fixes #15337

Pattern harvest

Not generalizable: a one-off interaction between one asset class whose behaviour is header-governed (workers take CSP from their own response) and a content-hash cache key that does not change on a header-only build. The fix is specific to this serving path, not a class of defect a lint or rule would catch elsewhere.

@chenmingwei23
chenmingwei23 requested a review from a team as a code owner September 30, 2026 16:21
@github-actions github-actions Bot added the readiness: action required A blocking check or review needs attention label Sep 30, 2026
@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — 🟡 CONCERNS

Design-level review of af896d013c2c429aee93f70507d479ddd8b3bd6e — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: CONCERNS

Description disclaims half the diff: "Not a goal... folding a build id into query strings," yet workerUrlWithBuildKey ships exactly that.

Watch

  • The frontend half (new workerCacheKey.ts, three worker call sites, rewritten workerPool pin) is the mechanism the description's "Not a goal" explicitly rejects ("Not folding a build id into asset URLs or query strings"), and "What changed"/"Tests" never mention it. The title's "no-store" also contradicts the shipped max-age=60. A future contributor reading the recorded decision could remove workerCacheKey.ts as contrary to it — undoing the only mechanism that rescues browsers already holding a worker under immutable, which the server-side policy change alone can never reach (an immutable entry is never revalidated).
    Clears when: a human updates the title/Not-a-goal/What-changed/Tests to own the build-key half (per the frozen-goal rule), or that half moves to its own PR matching commit af896d0's message.
  • test_every_built_worker_chunk_carries_the_marker silently returns (reports as passed) when website/dist is absent, and the Backend Tests CI job runs pytest without building the frontend — so the guard the exemption's description leans on ("fails the build rather than silently regaining immutable") plausibly executes in no CI lane, leaving the worker-substring naming convention unenforced.
    Clears when: the test runs in a lane that builds website/dist first (or pytest.skips with one lane asserting it was not skipped).

[DESIGN-REVIEWED] af896d0

Description read

[DESCRIPTION-READ] cd5f68922b1a599ba02174e93f5abed049f480b0e907e963db547001656a4e86

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — 🟡 CONCERNS

Premise-level review of af896d013c2c429aee93f70507d479ddd8b3bd6e — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: CONCERNS

The build-id query key ## Not a goal explicitly rejects ships anyway, undeclared — and it, not the declared policy, is what rescues already-stranded browsers.

Not justified as shipped

  • Item 3 — oversized: the description says "Not folding a build id into asset URLs or query strings", yet workerCacheKey.ts appends ?v=${__APP_VERSION__} to all three app worker URLs, and ## What changed never mentions it. The mechanism is sound on fundamentals — an immutable entry is never revalidated within its lifetime, so the serving-policy half alone cannot reach a browser stranded before this ships — but the frozen Goal excludes it, and the description's stated reasons for excluding it ("needs build-tooling changes", id may not change) are contradicted by the 10-line diff that uses the existing vite.config.ts define.
    Subtraction: delete website/src/utils/workerCacheKey.ts and its three call sites (restoring the csp=wasm-v1 key) if the Goal stands as written.
    Clears when: the mechanism is removed, or a human amends the Goal.
  • Item 5 — zero consumers: stale-if-error=86400 — the description concedes "no mainstream browser honours it", and no caching intermediary in front of the dashboard exists anywhere in docs/ (grepped stale-if-error|caching (proxy|tunnel)|CDN: hits are release/registry CDNs only, none on this serving path).
    Subtraction: drop stale-if-error=86400 from _WORKER_CACHE_CONTROL.
    Clears when: a named caching intermediary in front of the dashboard that honours it, or the token is deleted.

What this change ships

Inventory (5 items) — 3 justified

Intent: FIX — a gateway upgrade that changes only a response header (a worker's CSP) reaches browser users' worker scripts instead of being frozen for a year (Fixes #15337).

  1. Worker scripts are re-fetched within a minute of an upgrade (max-age=60) instead of cached a year — justified
  2. A missing/errored worker response is no longer cacheable (finalizer downgrades it to no-store) — justified
  3. Worker URLs carry a per-build ?v= key so each build abandons the stranded cache entry — oversized: ships what ## Not a goal excludes, undeclared
  4. The manual csp=wasm-v1 URL revision is gone, replaced by the automatic build key — rides along: same mechanism as item 3; the old pin's intent ("hash alone cannot retire pre-WASM headers", "stable across retries") is preserved and generalized
  5. Worker responses grant intermediaries stale-if-error=86400 — zero consumers: no browser honours it and no caching intermediary is documented

[FIRST-PRINCIPLES-REVIEWED] af896d0

Description read

[DESCRIPTION-READ] 3ac7733ae92debb09da159a6ef3e5b92f1344f7ac6d941b238ad2b4bcdb7dc2e

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

GPT 5.6 completed its review of af896d013c2c429aee93f70507d479ddd8b3bd6e and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] af896d0

False positive or not applicable? A repository writer can comment:
/ai-review override gpt af896d013c2c429aee93f70507d479ddd8b3bd6e: <one-sentence reason>

@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5 Review — ✅ no blocking findings

Reviewed af896d013c2c429aee93f70507d479ddd8b3bd6e — this comment is updated in place on each push.

Review details

Advisory only: the owning spec still documents the removed csp=wasm-v1 mechanism, and the "asserted against the built dist" guard the new constant cites never executes in CI.

FINDING — docs/system-specs/modules/learn-cron-dashboard.md:3212 — the owning spec's "Pierre worker cache identity" paragraph still states that PierreImpl.tsx "add[s] the stable csp=wasm-v1 query parameter before construction" and frames the fix around "an immutable HTTP cache", both of which this diff replaces (workerUrlWithBuildKey → ?v=<__APP_VERSION__>, and _WORKER_CACHE_CONTROL = "public, max-age=60, stale-if-error=86400"), so the only written explanation of the escape now names a parameter the app never sends → Fix: rewrite that paragraph in this commit to describe the ?v= build key and the server-side worker policy in _asset_cache_control.

FINDING — src/kiro_crew/dashboard/server.py:1359 — the comment claims the naming convention "is asserted against the built dist by test_every_built_worker_chunk_carries_the_marker so a worker named without it fails the build", but the only CI jobs that run test/test_dashboard_security_headers.py (backend-test, backend-test-windows) never run npm run build, so website/dist/assets is absent and the test returns at its if not assets.is_dir() guard every time — and even with a dist the and any(stem in n for n in emitted) clause excludes a stem that appears in no chunk at all, so a worker chunk emitted without worker in its name silently falls through to _IMMUTABLE_CACHE_CONTROL → Fix: either drop the and any(...) escape and run the check where a built dist exists (a vitest/scripts/ check in the frontend lane), or strike the "asserted … fails the build" sentence and state the convention is unenforced.

[OPUS-REVIEWED] af896d0

Verdict parsed from the review's SHA-scoped output markers for commit af896d013c2c429aee93f70507d479ddd8b3bd6e.

False positive or not applicable? A repository writer can comment:
/ai-review override fable af896d013c2c429aee93f70507d479ddd8b3bd6e: <one-sentence reason>

@chenmingwei23
chenmingwei23 force-pushed the fix/browser-stale-csp-immutable-15337 branch from e788efc to 9fa92df Compare September 30, 2026 17:05
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Sep 30, 2026
@chenmingwei23
chenmingwei23 force-pushed the fix/browser-stale-csp-immutable-15337 branch from 9fa92df to 54e672f Compare September 30, 2026 17:49
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 30, 2026
@chenmingwei23
chenmingwei23 force-pushed the fix/browser-stale-csp-immutable-15337 branch from 54e672f to 6febd24 Compare September 30, 2026 21:58
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Sep 30, 2026
@chenmingwei23
chenmingwei23 requested a review from a team September 30, 2026 23:00
@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Fable 5) — ✅ PASS

UX-level review of af896d013c2c429aee93f70507d479ddd8b3bd6e — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

UX-Verdict: PASS

Nothing to check.

The diff changes only HTTP cache headers and internal worker-URL construction — no user-visible control, label, string, or state is added or changed, so no screenshot or blind read is required for this revision.

[UX-REVIEWED] af896d0

Description read

[DESCRIPTION-READ] 75f66f38d877117b489635f08057196e876b96b501339750d8c60d7a8b18baf7

That sha256 names everything this verdict read: the PR description, plus the 3 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@chenmingwei23
chenmingwei23 force-pushed the fix/browser-stale-csp-immutable-15337 branch from 64691a7 to f4b36a4 Compare September 30, 2026 23:28
@chenmingwei23
chenmingwei23 force-pushed the fix/browser-stale-csp-immutable-15337 branch 2 times, most recently from 026e105 to 3fa5b85 Compare October 1, 2026 00:35
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Oct 1, 2026
@chenmingwei23
chenmingwei23 force-pushed the fix/browser-stale-csp-immutable-15337 branch from 3fa5b85 to 6e04877 Compare October 1, 2026 07:57
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 1, 2026
kirocrew-agent added 2 commits October 2, 2026 07:57
…aches browsers

## Problem / Motivation

**Goal:** A gateway upgrade that changes only a response header (a CSP directive) reaches browser users, instead of leaving their worker scripts frozen on a stale build's header for up to a year.

The dashboard serves content-hashed `/assets/` files with `public, max-age=31536000, immutable`. A build that changes only a response header keeps the identical hashed filenames, so a browser that cached a file replays its old header. For a worker script this is a live defect: a same-origin worker takes its CSP from its own script response header, not from the document. After a header-only upgrade (for example widening `script-src` for a new WASM engine) the browser keeps replaying the worker's old CSP, its WASM instantiation is refused, and every diff/highlight surface dies until a hard refresh the user has no reason to perform.

## Why it matters

Every browser user who cached a worker before a header-only upgrade is stranded: the highlight/diff engines silently fail and neither a tunnel rebuild nor a gateway restart fixes it, because the cache key is the local URL. Only a manual hard refresh clears it. The desktop shell half (PR #15323) clears the Electron cache per app+gateway version; a browser cannot be told to drop a cache entry, so this half stops the worker's header from being frozen for a year in the first place.

## Not a goal

- No change to plain JS/CSS chunk caching — those run under the document's CSP (served no-store, always fresh), so their stale header is harmless and they keep the immutable policy that spares the ~6MB entry bundle a re-download per load.
- Not folding a build id into asset URLs or query strings (the issue's other option): it needs build-tooling changes and only helps if the id reliably changes on a header-only build, whereas the worker cache policy fixes exactly the exposed asset class at the serving layer.

## What changed (motivation → approach → change)

Symptom: after a header-only upgrade a browser's cached worker runs an old CSP and diff/highlight surfaces stay dead. Root cause: `/assets/` worker scripts are cached `immutable`, but a worker's runtime CSP comes from its own cached response header, and Vite hashes a chunk by content only — so a header-only build reuses the same worker URL and the year-cached header is never re-fetched. Change: `_asset_cache_control` classifies a `/assets/` path — worker chunks (matched by the `worker` substring Vite stamps into every worker chunk name, case-insensitive) get a SHORT-LIVED cacheable policy (`public, max-age=60, stale-if-error=86400`) instead of `immutable`; every other hashed chunk keeps `immutable`. A 60-second `max-age` re-fetches the worker within a minute of a header-only build (bounding the stale-CSP window to a minute of degraded highlight, not a year) AND keeps the bytes cache-servable across a brief gateway-down window — a bare `no-store` would evict them and make the worker unloadable exactly then. The policy deliberately omits `no-cache`/`must-revalidate`, which forbid the cache reuse the gateway-down survival depends on; `stale-if-error` is a best-effort grant to a caching tunnel/proxy (no mainstream browser honours it), so for a plain browser the gateway-down coverage is the `max-age` window alone. The prepare-time finalizer downgrades an errored worker path to no-store so neither the browser caches the error nor an intermediary serves an orphaned worker's stale bytes.

## Backwards compatibility

Compatible: worker chunks are re-fetched after a 60-second fresh window instead of served from cache for a year, and no request is rejected, renamed, or removed. All other assets keep their existing policy.

## Tests

- `test_worker_assets_use_short_lived_not_immutable_or_no_store`: worker chunks carry `max-age=60`, never `immutable`, never `no-store`, and — the header contradiction Opus flagged — never `no-cache`/`must-revalidate`. Fails on base, where a worker path gets `immutable`.
- `test_non_worker_assets_stay_immutable`: plain JS/CSS chunks keep `immutable`, pinning the exemption as surgical.
- `test_every_built_worker_chunk_carries_the_marker`: scans the frontend source for worker constructions (`new Worker(new URL(...))`, `?worker`) and asserts each resolves, in the built dist, to a chunk carrying the marker — so a worker Vite renames to drop the marker (silently regaining `immutable`) fails the build. Skipped in a python-only/unbuilt checkout.
- `test_present_worker_asset_uses_short_lived_policy` / `test_missing_worker_asset_is_downgraded_to_no_store`: drive the real static mount + middleware + finalizer to assert the wire headers, including that the policy carries no `no-cache`/`must-revalidate` and that a worker 404 loses the cacheable policy.

## Manual verification

N/A — the change is at the response-header layer and unit coverage exercises the worker, non-worker, and errored-worker paths through the real serving stack.

## Related Issues

Fixes #15337

## Pattern harvest

Not generalizable: a one-off interaction between one asset class whose behaviour is header-governed (workers take CSP from their own response) and a content-hash cache key that does not change on a header-only build. The fix is specific to this serving path, not a class of defect a lint or rule would catch elsewhere.
…wser abandons a stranded immutable entry

A worker script is served with a short-lived cache policy so a header-only
build reaches it, but that policy only governs a fresh fetch. A browser that
holds a worker under the year-long immutable policy keeps it at the identical
content-hashed URL and never revalidates it, so the served policy can never
overwrite it. Append the compile-time build identity (__APP_VERSION__) as a
query string to every worker URL, making it a distinct cache key per version:
the browser requests a URL it does not hold under the stranded immutable entry,
fetches the worker afresh under the short-lived policy, and every version bump
rotates the key again. The query does not touch Vite content hashing, and the
server classifies and resolves the file by request.path (query stripped), so
the same emitted chunk is served with the short-lived worker policy.

Applied at the three worker instantiation sites via a shared helper; replaces a
hand-maintained static query param on the highlight worker with the same
build-keyed mechanism so it rotates automatically.
@chenmingwei23
chenmingwei23 force-pushed the fix/browser-stale-csp-immutable-15337 branch from 6e04877 to af896d0 Compare October 2, 2026 07:57
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 2, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor

Read-only review, holding for accuracy rather than code. The server change is right: only /assets/ files named with worker get the short policy, everything else stays immutable, worker 404s drop to no-store. Before approval: (1) the title says no-store but server.py:1370 sets 'public, max-age=60, stale-if-error=86400'; please retitle so the squash subject is accurate. (2) 'Not a goal' rules out a build id in query strings, yet workerCacheKey.ts:41 appends ?v=APP_VERSION at three worker call sites; please describe that frontend half and why it is needed. (3) test_every_built_worker_chunk_carries_the_marker returns early when website/dist is missing, which reports as a pass; use pytest.skip() so a run that checked nothing is visible. Minor: matching 'worker' anywhere in a filename also catches non-worker chunks (costs caching only).

@buluoray buluoray left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

Reviewed at head af896d013c2c429aee93f70507d479ddd8b3bd6e. The fix has two halves and both are correct:

  • Server (src/kiro_crew/dashboard/server.py:1376-1390): _asset_cache_control gives /assets/*worker* chunks public, max-age=60, stale-if-error=86400 in place of immutable. Every other hashed chunk keeps immutable. The prepare-time finalizer (server.py:1606-1611) now also downgrades a non-2xx/304 response carrying the worker policy to no-store, so a worker 404 is never cached.
  • Frontend (website/src/utils/workerCacheKey.ts:34-42 plus three call sites): each worker URL gets ?v=<__APP_VERSION__>. The server policy alone cannot rescue this: a browser already holding a worker under immutable never revalidates it, so the URL has to change. __APP_VERSION__ is the existing define (vite.config.ts:698), declared in src/vite-env.d.ts. request.path drops the query, so the server's classification and add_static's file resolution are unchanged.

Every new branch fails closed. If the classification is wrong, the asset gets either the old immutable policy (today's behaviour) or a 60s cache (costs a re-fetch only). If the finalizer branch is missed, a 404 keeps a 60s cache, which is a bounded window, not a permanent strand. No auth, data or persistence paths are touched. The worker build format is unchanged: ?worker&url and new Worker(new URL(...)) both build with the same worker config, and PierreImpl.tsx already used ?worker&url before this PR.

Verified

  • Head SHA pinned and the worktree confirmed at it. CI at head: 18 success, 2 skipped (fork-only gates), 0 failure. The PR is open and unmerged.
  • Targeted Python tests (test/test_dashboard_security_headers.py, test/test_dashboard_asset_404_cache.py): baseline 34 passed. Mutations:
    • M1: worker branch returns immutable. Fails test_worker_assets_use_short_lived_not_immutable_or_no_store and test_present_worker_asset_uses_short_lived_policy.
    • M2: finalizer only matches immutable, as on base. Fails test_missing_worker_asset_is_downgraded_to_no_store.
    • M3: .lower() dropped from the marker match. Fails the same two tests as M1.
  • test_every_built_worker_chunk_carries_the_marker: run against a symlinked built dist, which has diffWorker-, hljsWorker-, worker-portable- and subset-worker.chunk-. It passed, so the detection logic works when a dist is present.
  • Frontend website/src/utils/workerCacheKey.test.ts: 4 passed. Mutation (return base, no key) fails 3 of the 4, including "appends a non-empty build-identity query to a bare URL".
  • website/src/test/PierreImpl.workerPool.test.tsx could not run locally. Vite's fs.allow refuses the symlinked node_modules (Denied ID .../worker-portable.js?worker&url). This is an environment limit, not a PR defect, and CI Build is green. The rewritten v= pin in that file was read, not executed.
  • Tests were not run locally beyond these targeted files.

Bot claims disposition

  • Design / First Principles (CONCERNS): the description's "Not a goal" rejects a build id in query strings, yet workerCacheKey.ts ships one. The title says "no-store" but the policy is max-age=60. Real, for the description and title only. The code is right, and the build-key half is the only part that rescues browsers already stranded under immutable. This is a PR-description defect, so it does not block. Because the squash subject lands in main, the title must be fixed (follow-up 1).
  • Design / Opus / iamwhatever: test_every_built_worker_chunk_carries_the_marker returns early without a dist and reports a pass. CI's backend-test never builds the frontend. Real. .github/workflows/ci.yml backend-test (line 631 onward) has no npm/build step, so in CI this guard checks nothing. The server.py:1359 comment that says it "fails the build" overstates what the guard does. It is a test-coverage gap, not a logic defect, so it does not block (follow-up 2).
  • Opus: the owning spec docs/system-specs/modules/learn-cron-dashboard.md:3212 still describes csp=wasm-v1 and only the immutable framing. Real. The diff has no docs/ changes, and that paragraph now names a query parameter the app no longer sends. Under AGENTS.md the spec should change in the same commit. It is docs only, so it does not block (follow-up 3).
  • First Principles: stale-if-error=86400 has no browser consumer. Real, and the code comment already says so. It is harmless, but tightening the policy to public, max-age=60 would be the honest minimum. Taste, not a gate.
  • iamwhatever (minor): matching worker anywhere in a filename also catches non-worker chunks. Real but harmless. Such a chunk loses only the year-long cache and gets a 60s one instead. Fails closed.
  • GPT 5.6, Opus (no blocking), UX (PASS): agreed.

Follow-ups (non-blocking)

  1. Retitle the PR before merge so the squash subject matches the behaviour, for example fix(dashboard): short-cache worker assets and key their URLs to the build. Rewrite "Not a goal" / "What changed" / "Tests" to cover the ?v=__APP_VERSION__ half and why it is needed: an immutable entry is never revalidated.
  2. Change the early returns in test_every_built_worker_chunk_carries_the_marker to pytest.skip(...), so a run that checked nothing shows up as skipped. Either run it in a job that has a built dist, or soften the server.py:1359 "fails the build" claim.
  3. Update the "Pierre worker cache identity" paragraph in docs/system-specs/modules/learn-cron-dashboard.md (around line 3212) to describe the ?v= build key and the server-side worker policy in _asset_cache_control.
  4. Note that __APP_VERSION__ is package.json version. A header-only change shipped without a version bump keeps the same ?v=, and only the 60s max-age covers it. That is fine now that the policy is short-lived, but the comment in workerCacheKey.ts should not imply that every build gets a distinct key.

@chenmingwei23
chenmingwei23 merged commit a3cb099 into main Oct 3, 2026
144 of 145 checks passed
@chenmingwei23
chenmingwei23 deleted the fix/browser-stale-csp-immutable-15337 branch October 3, 2026 05:11
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 3, 2026
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.

Browser keeps stale CSP on immutable /assets after upgrade

3 participants