Skip to content

Cleanup foundations: dead code and cold-path performance - #249

Merged
oddharsh merged 5 commits into
mainfrom
codex/site-cleanup-foundations
Aug 7, 2026
Merged

oddharsh merged 5 commits into
mainfrom
codex/site-cleanup-foundations

Conversation

@oddharsh

@oddharsh oddharsh commented Aug 7, 2026

Copy link
Copy Markdown
Owner

Summary

  • remove the sole orphaned Worker export found by the repository-wide symbol sweep
  • cap optional /whoareyou RDAP enrichment at 250 ms and finish cold reads in waitUntil
  • omit upgrade-insecure-requests from the report-only CSP twin while preserving it in enforcement
  • lazy-load Horizon's deep-page uptime iframe so its perpetual timer does not start during initial load
  • add focused regression coverage for all three behavioral changes

Audit scope

Reviewed the current origin/main checkout across 1,164 tracked files, 59 registered public surfaces, all Worker modules, generated/static page boundaries, route/config parity, dependencies, exports, duplicate code, photo artifacts, auxiliary Workers, and every public subpage in a live browser sweep.

Notable restraint:

  • exact-clone scan found 0.13% duplication, so no abstraction rewrite was justified
  • the Service Worker unregister stub and legacy URL redirects remain active compatibility contracts and were intentionally preserved
  • the old chore/dead-code-sweep branch was not replayed because its structural cleanups are already present on current main

Validation

  • npm test: 158/158
  • cal npm test: 47/47 (the two documented Miniflare WorkflowTimeoutError lines remain cosmetic)
  • npm run build
  • npm run perf-budget: hard checks green; 254.67 KiB gzip, 11.6 ms startup CPU
  • npm run routes:check: 118 routes, 0 failures
  • npm run check-wrangler
  • npm run photos:check: 158 photos / 474 hashed tiers
  • npm run pages:check
  • npm run infra:check -- --offline
  • remote D1 checkpoint comparison: 109 releases, through v173
  • root, cf-garage, and lwe-ask Wrangler deploy --dry-run
  • shell syntax, Python AST parse, Rust cargo test
  • git diff --check

No deployment performed.

@oddharsh
oddharsh force-pushed the codex/site-cleanup-foundations branch from 554cbb0 to 2d5d1bc Compare August 7, 2026 16:06
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 7, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
aadhar-sh 3b6fe4a Aug 07 2026, 07:57 PM

@oddharsh
oddharsh marked this pull request as ready for review August 7, 2026 19:56
@oddharsh
oddharsh enabled auto-merge (squash) August 7, 2026 19:56
@oddharsh
oddharsh merged commit 9641837 into main Aug 7, 2026
5 of 6 checks passed
@oddharsh
oddharsh deleted the codex/site-cleanup-foundations branch August 7, 2026 19:57
oddharsh added a commit that referenced this pull request Aug 7, 2026
#249 landed the behavioural fix for this while this branch was open: the
report-only twin no longer carries `upgrade-insecure-requests`, which a browser
ignores there and files a security issue about on every page load. So this is no
longer the fix. What is left is the trap in how that fix is derived, plus the
half of the assertion the test cannot currently make.

CSP_REPORT_ONLY_TAIL was `CSP_TAIL.replace(/; upgrade-insecure-requests$/, "")`,
anchored to the end of the string. Append one more directive after
upgrade-insecure-requests and the replace matches nothing, the twin silently gets
the directive back, and no test fails. Invert it: CSP_TAIL_REPORTABLE is the
short tail, CSP_TAIL composes the long one from it. There is no pattern to miss,
so the failure mode does not exist rather than being guarded against.

The test asserted only that the twin OMITS the directive, which passes just as
happily if it falls out of both policies. Added the enforcing half, and an
equality that pins the two tails to one policy minus one inert directive rather
than two policies free to drift.

Verified both new assertions bite: putting the directive back in the twin fails
1 test, dropping it from the enforcing policy fails 2. 161 tests pass.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
oddharsh added a commit that referenced this pull request Aug 7, 2026
…#257)

#249 landed the behavioural fix for this while this branch was open: the
report-only twin no longer carries `upgrade-insecure-requests`, which a browser
ignores there and files a security issue about on every page load. So this is no
longer the fix. What is left is the trap in how that fix is derived, plus the
half of the assertion the test cannot currently make.

CSP_REPORT_ONLY_TAIL was `CSP_TAIL.replace(/; upgrade-insecure-requests$/, "")`,
anchored to the end of the string. Append one more directive after
upgrade-insecure-requests and the replace matches nothing, the twin silently gets
the directive back, and no test fails. Invert it: CSP_TAIL_REPORTABLE is the
short tail, CSP_TAIL composes the long one from it. There is no pattern to miss,
so the failure mode does not exist rather than being guarded against.

The test asserted only that the twin OMITS the directive, which passes just as
happily if it falls out of both policies. Added the enforcing half, and an
equality that pins the two tails to one policy minus one inert directive rather
than two policies free to drift.

Verified both new assertions bite: putting the directive back in the twin fails
1 test, dropping it from the enforcing policy fails 2. 161 tests pass.

Co-authored-by: Aadharsh Pannirselvam <19518661+oddharsh@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
oddharsh added a commit that referenced this pull request Aug 24, 2026
…uarded

ENFORCE_PAGE_HASHES was pinned true on 2026-08-16 and nothing has flipped it in
either direction since, so its false arm has been dead code for a week. It was
not one line: it cost a second header name, a second tail constant, a `tail`
parameter threaded through both policy builders to feed that constant, an
entries loop in withSecurityHeaders whose only job was carrying a second header
past a bail, and two branches apiece in the contract test and the twin-fact
tripwire.

The emitted policy is byte-identical, checked both ways. CSP_TAIL now holds the
string CSP_TAIL_REPORTABLE plus "; upgrade-insecure-requests" used to compose,
and a build of each side produces the same _headers line.

cspHeadersFor returns exactly ONE header now. The contract test counts the keys
rather than probing one name, since a twin under any other spelling is the same
regression, and the upgrade-insecure-requests assertion inverts with the change:
it used to check the twin OMITTED the directive, and with one policy left the
only way to get it wrong is to lose it, so it now checks presence on both arms.

gen-md-twins no longer reads the flag. It reads the header set cspHeadersFor
actually emits, which is the better check for the reason the flag era proved:
a flag states an intention, and #249's bug was the enforcing half never being
applied to a single document while the flag said it was. /security claims
'unsafe-inline' left script-src, and that claim goes false the moment a
report-only twin returns, so the deploy fails until one of the two is put right.

Controls, both run: reintroducing a report-only twin fails the contract test by
name (it reports the two keys it found) and fails the twin-fact tripwire by name.
Reverting makes both green again.

The rollout story stays. What the DevTools sweep found on /garage/horizon, and
why the enforcing half had never been applied, are gotcha 17 in CLAUDE.md, which
is where it belongs now that the mechanism is gone. Rolling back is `git revert`
rather than a flag, and `bun run csp:sweep` is the signal that would call for
one; its header says so instead of describing a flip that already happened.

353 tests, typecheck, lint, build, pages, photos and the 142-route oracle green.
The build's taste warnings on this branch are the ones #525 fixes, not new.
oddharsh added a commit that referenced this pull request Aug 24, 2026
…uarded

ENFORCE_PAGE_HASHES was pinned true on 2026-08-16 and nothing has flipped it in
either direction since, so its false arm has been dead code for a week. It was
not one line: it cost a second header name, a second tail constant, a `tail`
parameter threaded through both policy builders to feed that constant, an
entries loop in withSecurityHeaders whose only job was carrying a second header
past a bail, and two branches apiece in the contract test and the twin-fact
tripwire.

The emitted policy is byte-identical, checked both ways. CSP_TAIL now holds the
string CSP_TAIL_REPORTABLE plus "; upgrade-insecure-requests" used to compose,
and a build of each side produces the same _headers line.

cspHeadersFor returns exactly ONE header now. The contract test counts the keys
rather than probing one name, since a twin under any other spelling is the same
regression, and the upgrade-insecure-requests assertion inverts with the change:
it used to check the twin OMITTED the directive, and with one policy left the
only way to get it wrong is to lose it, so it now checks presence on both arms.

gen-md-twins no longer reads the flag. It reads the header set cspHeadersFor
actually emits, which is the better check for the reason the flag era proved:
a flag states an intention, and #249's bug was the enforcing half never being
applied to a single document while the flag said it was. /security claims
'unsafe-inline' left script-src, and that claim goes false the moment a
report-only twin returns, so the deploy fails until one of the two is put right.

Controls, both run: reintroducing a report-only twin fails the contract test by
name (it reports the two keys it found) and fails the twin-fact tripwire by name.
Reverting makes both green again.

The rollout story stays. What the DevTools sweep found on /garage/horizon, and
why the enforcing half had never been applied, are gotcha 17 in CLAUDE.md, which
is where it belongs now that the mechanism is gone. Rolling back is `git revert`
rather than a flag, and `bun run csp:sweep` is the signal that would call for
one; its header says so instead of describing a flip that already happened.

353 tests, typecheck, lint, build, pages, photos and the 142-route oracle green.
The build's taste warnings on this branch are the ones #525 fixes, not new.
oddharsh added a commit that referenced this pull request Aug 24, 2026
…uarded (#527)

ENFORCE_PAGE_HASHES was pinned true on 2026-08-16 and nothing has flipped it in
either direction since, so its false arm has been dead code for a week. It was
not one line: it cost a second header name, a second tail constant, a `tail`
parameter threaded through both policy builders to feed that constant, an
entries loop in withSecurityHeaders whose only job was carrying a second header
past a bail, and two branches apiece in the contract test and the twin-fact
tripwire.

The emitted policy is byte-identical, checked both ways. CSP_TAIL now holds the
string CSP_TAIL_REPORTABLE plus "; upgrade-insecure-requests" used to compose,
and a build of each side produces the same _headers line.

cspHeadersFor returns exactly ONE header now. The contract test counts the keys
rather than probing one name, since a twin under any other spelling is the same
regression, and the upgrade-insecure-requests assertion inverts with the change:
it used to check the twin OMITTED the directive, and with one policy left the
only way to get it wrong is to lose it, so it now checks presence on both arms.

gen-md-twins no longer reads the flag. It reads the header set cspHeadersFor
actually emits, which is the better check for the reason the flag era proved:
a flag states an intention, and #249's bug was the enforcing half never being
applied to a single document while the flag said it was. /security claims
'unsafe-inline' left script-src, and that claim goes false the moment a
report-only twin returns, so the deploy fails until one of the two is put right.

Controls, both run: reintroducing a report-only twin fails the contract test by
name (it reports the two keys it found) and fails the twin-fact tripwire by name.
Reverting makes both green again.

The rollout story stays. What the DevTools sweep found on /garage/horizon, and
why the enforcing half had never been applied, are gotcha 17 in CLAUDE.md, which
is where it belongs now that the mechanism is gone. Rolling back is `git revert`
rather than a flag, and `bun run csp:sweep` is the signal that would call for
one; its header says so instead of describing a flip that already happened.

353 tests, typecheck, lint, build, pages, photos and the 142-route oracle green.
The build's taste warnings on this branch are the ones #525 fixes, not new.

Co-authored-by: Aadharsh Pannirselvam <19518661+oddharsh@users.noreply.github.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.

1 participant