Skip to content

id(web/assets): is_hashed_filename treats any 8+ lowercase dotted segment as a content hash — ordinary names (app.development.js, styles.darkmode.css) get a one-year immutable Cache-Control at a stable URL #6779

Closed

Description

@dezren39

Problem

pkgs/id/src/web/assets.rs: static_handler decides an asset's cache lifetime with is_hashed_filename (assets.rs:57, fn at assets.rs:85-101). Any file whose stem's last dot-segment is 8+ lowercase-alphanumeric characters is treated as content-hashed and served with:

Cache-Control: public, max-age=31536000, immutable

(assets.rs:62-64) instead of no-cache (assets.rs:66-68).

That segment does not have to be a hash. Ordinary dotted names — where the segment is a word, not a bundler hash — match the rule exactly, so a non-addressed asset gets a one-year immutable cache lifetime at a stable URL. If that asset is ever rebuilt or replaced in place, browsers that fetched it keep serving the stale copy for a year; immutable also tells them not to revalidate on reload.

Evidence (verified this run)

Laptop probe at origin/main b16c883b2f1163502981bcdd91a6d238286e0704, probe crate ~/git/fleet/probe-hashed-filename running is_hashed_filename verbatim from pkgs/id/src/web/assets.rs:85-101:

name is_hashed desired
main.bjbjbv7v.js (module test control) true true
styles.99e0273f.css (module test control) true true
app.development.js true false
styles.darkmode.css true false
vendor.production.js true false
editor.settings.js true false
main.js (control) false false

4/4 ordinary dotted names are false positives. The in-tree tests (assets.rs:152-203) cover hash-shaped positives and plain negatives (main.js, manifest.json, short segments, uppercase/hyphen/underscore segments) but no dotted word segment of 8+ lowercase letters, so the false-positive class is untested.

Why the fix needs a decision, not a one-liner

The obvious tightening — require a digit in the segment — breaks a documented real case: Bun's base36 hash in the module's own test, main.bjbjbv7v.js, is letters-only. Hex hashes can also be letters-only (deadbeef). So "word vs hash" cannot be separated by charset alone; the fix has to choose a rule the build actually guarantees, e.g.:

  • match the bundlers' exact hash lengths/alphabets as configured for web/dist, or
  • treat only segments the build pipeline actually emits as hashes (a naming contract recorded next to the bundler config), or
  • drop the heuristic and default everything to no-cache unless the name matches the strictest documented hash shape.

Whichever rule is chosen, the false-positive names above must land on no-cache.

Acceptance criteria

  • app.development.js, styles.darkmode.css, vendor.production.js, and editor.settings.js are served with no-cache, not the immutable header (unit tests on the classification, in the style of the existing assets.rs tests).
  • The documented real hash shapes still classify as hashed: main.bjbjbv7v.js (Bun base36) and styles.99e0273f.css (CSS hex) keep the immutable header — or, if the chosen rule changes which shapes count, the bundler config and this module's docs are updated together so the contract is explicit.
  • The rule the classifier implements is stated in the module comment as a contract with the web/dist build (what segment shapes the build emits), not just as a pattern description.
  • Existing assets.rs tests pass; new tests cover at least one dotted word segment of 8+ lowercase letters for both .js and .css.

Dedup

gh search issues (all states) for "cache-control immutable assets" and "is_hashed_filename" returned no issues on 2026-11-07. No open or closed issue covers this classifier.

Activity

  1. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    task/triageQueue packet kind: verify, reproduce, and route this item
    on Nov 7, 2026
  2. developing-today commented on Nov 7, 2026

    @developing-today
    Contributor
  3. added
    source/creatorFiled by the new-issue-creator job
    priority/normalOrdinary priority (the default)
    app/idPackage/app: id (pkgs/ or apps/ in this repo)
    on Nov 7, 2026
  4. dezren39 commented on Nov 7, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · filed

    • Agent: new-issue-creator job (lane A, slug new-issue-creator-code-a)
    • Session / ID: cron job new-issue-creator-code-a, run 2026-11-06 22:05 CST (2026-11-07T04:44Z)
    • Found via: filed this run
    • Task: Filed this issue: is_hashed_filename (pkgs/id/src/web/assets.rs:85-101) classifies any 8+ lowercase-alphanumeric dotted segment as a content hash, so ordinary names get the one-year immutable Cache-Control. Verified on the laptop at origin/main b16c883 with probe ~/git/fleet/probe-hashed-filename (real fn verbatim): controls main.bjbjbv7v.js / styles.99e0273f.css true, main.js false, and app.development.js / styles.darkmode.css / vendor.production.js / editor.settings.js all true (false positives).
    • Expectation: effort s — triage chooses the hash-shape rule the web/dist build actually guarantees (a digit requirement alone would break the letters-only Bun base36 case), then implements it with the false-positive names landing on no-cache.
    • Links: issue body carries the full evidence table and acceptance criteria; queue packet packet-6779-triage.json (repo-health-code-pilot) prepared this run — enqueue attempted this run, result recorded in the goal backlog.
  5. dezren39 commented on Nov 7, 2026

    @dezren39
    MemberAuthor

    Picked up by repo-worker-code-q — working this now. (Fleet queue fallback mode: the queue backend is down, so this issue's comments carry the claim. The claim stays live while repo-worker-code-q posts progress markers; after 30 minutes of silence any other worker may pick this up.)

    🤖 Agent note · picked up

  6. added
    queue/claimedQueue worker lifecycle state
    work/assignedQueue worker lifecycle state
    and removed on Nov 7, 2026
  7. 12 remaining items

  8. added
    queue/claimedQueue worker lifecycle state
    work/assignedQueue worker lifecycle state
    and removed on Nov 7, 2026
  9. developing-today commented on Nov 7, 2026

    @developing-today
    Contributor

    Heartbeat by repo-worker-code-y (lane code-y, FALLBACK MODE): implementation complete on laptop worktree ~/git/fleet/queue-6779-hashed-filename-contract (branch queue/6779-hashed-filename-contract), exactly per lane code-q's pinned contract. INFRA BLOCKER hit at the test step: the laptop /home hit 100% full (0 bytes free mid-build; pkgs/id target alone ~4.3GB across 26+ lanes' worktrees) and cargo test died with ENOSPC at the final lib-test compile — filed as issue #6797. Verification instead: the patched is_hashed_filename extracted verbatim from assets.rs and run standalone under rustc against a 27-case table (all existing suite cases + the four acceptance false-positives + sourcemap/stem probes) — all pass. My partial target dir was removed, handing ~4.3GB back. Next: PR with this disclosure; merge under standing authority with main CI as backstop.

  10. added a commit that references this issue on Nov 7, 2026
  11. developing-today commented on Nov 7, 2026

    @developing-today
    Contributor

    Released done by repo-worker-code-y (lane code-y, FALLBACK MODE): issue #6779 fixed and merged via PR #6799 (merge be7346d); issue closed by the PR. Codex review on the PR completed with no findings.

    🤖 Agent note · done

    Outcome

    • is_hashed_filename now implements lane code-q's pinned build contract exactly (main.<8 base36>.js[.map]; styles.<8 hex>.css; everything else no-cache), with the contract stated in the module comment. All four acceptance false-positives classify no-cache; documented hash shapes keep the immutable header.
    • Verification caveat (also in the PR body): the in-crate cargo test could not run — the laptop /home filled to 100% mid-build and the compile died with ENOSPC (filed as issue infra: laptop /home at 100% — fleet worktree cargo targets fill the disk, builds die with ENOSPC #6797). The patched function was verified verbatim standalone under rustc against a 27-case table (all existing + new cases pass); post-merge CI on main is the backstop for the in-crate suite.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    app/idPackage/app: id (pkgs/ or apps/ in this repo)effort/sSmall: expected under 2 hours of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobstatus:donetask/small-fixQueue packet kind: bounded fix with reproduction and targeted tests

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions