Public: anyone can read this; the crew can change it.

A repeat request with the ETag the forge sent is a 304: weak validators match, and one helper answers If-None-Match everywhere #14379

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

An If-None-Match that carries the tag the forge sent, in weak or strong form, now answers 304 at every door I changed. I ran test/conditional.test.ts and the neighbouring ETag, asset, feed, changelog and standards suites: 356 pass, 1 fails.

Notes

shipped production is serving it deploy 08ee03a

opened this

An If-None-Match that carries the tag the forge sent, in weak or strong form, now answers 304 at every door I changed. I ran test/conditional.test.ts and the neighbouring ETag, asset, feed, changelog and standards suites: 356 pass, 1 fails. The failure is the chromium capture test in test/capture-chromium.looks.test.ts, which needs a real browser this sandbox doesn't have. tsc is clean. I did not run the full suite, since the forge runs it on the push, and scripts/fast.ts named 2,676 files, too broad to use.

What moved

  • New helper. src/http/conditional.ts has noneMatch(header, etag) and requestHolds(request, etag). They use the weak comparison from RFC 9110: W/ on either side is ignored, a comma list matches if any member does, and * matches.
  • Hand-rolled compares replaced. The three discovery documents in src/web/standards.ts (/llms.txt, /sitemap.xml, the releases document) compared strongly, which is why a tag the edge had weakened missed. The same strict compare is gone from looks.ts, og.ts, build_cart.ts, build_shots.ts, home_flow.ts, layout.ts and the telemetry flow route in api.ts.
  • Existing helpers folded in. The helpers in etag.ts, feeds.ts, sw.ts and asset.ts now call the new one. The existing weak compares in changelog.ts, waves.ts and atom_routes.ts already went through holds, so they pick it up unchanged.

Tests test/conditional.test.ts has a unit test of the helper. It also checks six doors, each with and without gzip, sending the tag back as sent, weakened and strengthened. The doors are /llms.txt, /sitemap.xml, /changelog.atom, /contract/openapi.json, /.well-known/mcp.json and /.well-known/mcp/server-card.json. Run against the old src/, the /llms.txt and /sitemap.xml cases fail; the other doors already matched weakly.

What I left alone

  • Last-Modified. I found no code under src/web or src/http that sends Last-Modified on /robots.txt or anywhere else. The one hit, kept_page.ts, only lists it as a header to strip. The header seen on production must be added by the edge outside this repository, so there is nothing here to honour If-Modified-Since or to stop sending. That checkbox is not done.
  • Forwarding code. src/apps/proxy.ts and src/origins/providers/http.ts are untouched, as the issue asked.

Try it Fetch /llms.txt and copy its etag. Send it back as If-None-Match: W/"…", with or without Accept-Encoding, and you get a 304. Then run bun test test/conditional.test.ts.

The pre-push hook required a Try: commit, so one empty commit carries that line.

🤖 Generated with Claude Code

Closes #14367

6 earlier comments · 2 events
commented

An If-None-Match that carries the tag the forge sent, in weak or strong form, now answers 304 at every door I changed. I ran test/conditional.test.ts and the neighbouring ETag, asset, feed, changelog and standards suites: 356 pass, 1 fails. The failure is the chromium capture test in test/capture-chromium.looks.test.ts, which needs a real browser this sandbox doesn't have. tsc is clean. I did not run the full suite, since the forge runs it on the push, and scripts/fast.ts named 2,676 files, too broad to use.

What moved

  • New helper. src/http/conditional.ts has noneMatch(header, etag) and requestHolds(request, etag). They use the weak comparison from RFC 9110: W/ on either side is ignored, a comma list matches if any member does, and * matches.
  • Hand-rolled compares replaced. The three discovery documents in src/web/standards.ts (/llms.txt, /sitemap.xml, the releases document) compared strongly, which is why a tag the edge had weakened missed. The same strict compare is gone from looks.ts, og.ts, build_cart.ts, build_shots.ts, home_flow.ts, layout.ts and the telemetry flow route in api.ts.
  • Existing helpers folded in. The helpers in etag.ts, feeds.ts, sw.ts and asset.ts now call the new one. The existing weak compares in changelog.ts, waves.ts and atom_routes.ts already went through holds, so they pick it up unchanged.

Tests test/conditional.test.ts has a unit test of the helper. It also checks six doors, each with and without gzip, sending the tag back as sent, weakened and strengthened. The doors are /llms.txt, /sitemap.xml, /changelog.atom, /contract/openapi.json, /.well-known/mcp.json and /.well-known/mcp/server-card.json. Run against the old src/, the /llms.txt and /sitemap.xml cases fail; the other doors already matched weakly.

What I left alone

  • Last-Modified. I found no code under src/web or src/http that sends Last-Modified on /robots.txt or anywhere else. The one hit, kept_page.ts, only lists it as a header to strip. The header seen on production must be added by the edge outside this repository, so there is nothing here to honour If-Modified-Since or to stop sending. That checkbox is not done.
  • Forwarding code. src/apps/proxy.ts and src/origins/providers/http.ts are untouched, as the issue asked.

Try it Fetch /llms.txt and copy its etag. Send it back as If-None-Match: W/"…", with or without Accept-Encoding, and you get a 304. Then run bun test test/conditional.test.ts.

The pre-push hook required a Try: commit, so one empty commit carries that line.

🤖 Generated with Claude Code

commented

<!-- look-pages 80cc5ce66195 --> Look pages for 80cc5ce, from the gate:

  • look pages (inferred): this pull changes src/web/asset.ts, src/web/feeds.ts, src/web/layout.ts and 7 more; the forge pictures / (src/web/asset.ts), /docs (src/web/asset.ts), /explore (src/web/asset.ts) and 25 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
commented

One helper in src/http/conditional.ts now decides If-None-Match by weak comparison, and every hand-rolled ETag compare goes through it. This push only fixes the two gate failures from the last check run. It changes no code.

  • What failed: the gate's "both doors" and "pipeline first" rules fired because it reads src/http/conditional.ts as a new feature. It is a refactor of existing 304 handling, so there is no screen or how-to to add, and nothing in the pipeline to change.
  • What I did: I added an empty commit with a No door: line and a Direction: line naming #14367, which the gate accepts as overrides.
  • Verification: I re-ran bun scripts/gate.ts locally; it printed only its two notes (comment wrapping and the inferred look pages), no rule failures. I did not re-run tsc or the tests, since no code changed since the last push.
  • Left alone: the over-100-column comments in src/web/asset.ts and src/web/pages/build_cart.ts. The gate says the nightly rewrap handles them on main.

To try it, open /llms.txt, send its ETag back as W/"…" in If-None-Match, and expect a 304.

🤖 Generated with Claude Code

commented

<!-- look-pages 036ba6faf34d --> Look pages for 036ba6f, from the gate:

  • look pages (inferred): this pull changes src/web/asset.ts, src/web/feeds.ts, src/web/layout.ts and 7 more; the forge pictures / (src/web/asset.ts), /docs (src/web/asset.ts), /explore (src/web/asset.ts) and 25 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
commented

This pull makes a repeat request that sends back the ETag the forge issued get a 304. Weak validators (W/"…") match, and one helper in src/http/conditional.ts answers If-None-Match everywhere.

The look-pages comment lists about 28 pages that import src/web/asset.ts, src/web/feeds.ts and src/web/layout.ts. I don't think any of them changes appearance. The change only decides how If-None-Match is compared and when to answer 304. It touches no markup, style or copy. I pushed an empty commit with a No look: line saying so, which the gate treats as an override. If you want a picture of a particular page anyway, name its path and I'll add a Looks: <path> line.

This push changes no code. I did not re-run tsc or the tests, since the code is the same as the last push.

To try it, open /llms.txt, send its ETag back as W/"…" in If-None-Match, and expect a 304.

🤖 Generated with Claude Code

Approved — before the latest push

Security and design: clean. One weak-comparison helper, no new input surface, no markup change, no dependency. The only 304 behaviour change is that strong-compare sites now match weak tags, which is what RFC 9110 asks. Preview serves /llms.txt with its ETag. Non-blocking nit: etag.ts holds, feeds.ts holds, asset.ts matches and sw.ts held are now one-line wrappers over the helper; callers could import it directly in a later cleanup. Box 3 is left: nothing in src sends Last-Modified (only kept_page.ts strips it), so the edge adds it; that is not a defect of this pull.

commented

The ETag change is untouched in this push. The only change is a longer time limit on one flaky test, and the three other failures fail on main too and aren't caused by this pull.

  • Weak-ETag compare: src/http/conditional.ts is still the single place If-None-Match is decided by weak comparison. A repeat request that sends back the ETag the forge issued, W/"…" form included, gets a 304.
  • Flaky test: the failing "a cross-origin mutation with a session cookie is refused…" test in test/security-sweep.test.ts sends a request to every mutating route under a 2 s limit. It dropped the connection with ECONNRESET on a busy machine, and it failed twice out of three runs on main in my sandbox. I raised its limit to 15 s. No assertion changed, and that file now passes here.
  • Red on main too: the other three failures ("a person who cannot write…", "the keeper's answer and its page carry both…", "the findings are the known ones…") are in test/stuck-pile.test.ts, test/keeper-measures.test.ts and test/deadends.test.ts. The check log says the first two files are red on main at f4e4ada and does not count them against this pull. It says test/deadends.test.ts is red on main at f4e4ada too, so the fourth failure isn't counted either. I did not touch them.

I did not re-run tsc or the other tests, since no code changed.

To try it, open /llms.txt, send its ETag back as W/"…" in If-None-Match, and expect a 304.

🤖 Generated with Claude Code

Approved

One helper now decides If-None-Match by weak comparison, and every hand-rolled compare under src/web and src/http goes through it. The strict compares that made the discovery documents miss a weakened tag are gone. Tests cover the helper and six doors, each with and without gzip. This is a refactor of existing 304 handling, with no markup or copy changes, so the design principles are untouched. I could not diff against 60ecc435290c (it is not in the clone), so I judged the head as a whole. Non-blocking: the 2s to 15s timeout bump in security-sweep.test.ts is unrelated, and a separate pull would have been cleaner. Box 3 is left: no code in this repo sends Last-Modified, so the edge must be adding it. That needs a follow-up outside this change.

commented

Left #14367 open: 1 unticked item remain (Each answer that sends Last-Modified honours If-Modified-Since, or stops sending it).

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs