Skip to content

feat(web-platform): HSTS, wider refusals, request id header, probes, visible hidden characters (L040) - #18

Merged
constantin-jais merged 2 commits into
migrate/recover-codefrom
work/rewrite-l040
Nov 17, 2026
Merged

constantin-jais merged 2 commits into
migrate/recover-codefrom
work/rewrite-l040

Conversation

@constantin-jais

Copy link
Copy Markdown
Contributor

Door: two-way
Origin: proposal

Summary

Lot L040 of the rewrite plan: web-platform : en-têtes, enveloppe d'erreur, sondes, échappement des caractères cachés (TypeScript sur Bun).

Draft pull request. Base: migrate/recover-code.

File Added Removed
packages/web-platform/README.md 43 0
packages/web-platform/fixtures/served-text-preparation-candidate/removed-ranges.copy.json 93 0
packages/web-platform/src/index.ts 3 1
packages/web-platform/src/probes.test.ts 49 0
packages/web-platform/src/probes.ts 22 0
packages/web-platform/src/response.test.ts 40 0
packages/web-platform/src/response.ts 10 1
packages/web-platform/src/server.test.ts 69 0
packages/web-platform/src/server.ts 31 8
packages/web-platform/src/visible-text.test.ts 98 0
packages/web-platform/src/visible-text.ts 62 0

Commits (1, merges excluded):

  • 2b46518 feat(web-platform): HSTS, wider refusals, request id header, probes, visible hidden characters

Evidence

The tests and controls below are local runs on the workstation (Bun 1.4.4), recorded in the commit messages; they were not replayed for this pull request. The CI on this head is authoritative.

Review: read by an independent reviewer (read-only, given the code, the base and the source, never the writer report); low findings only, left uncorrected.

Commit messages, verbatim (sign-off lines omitted):

feat(web-platform): HSTS, wider refusals, request id header, probes, visible hidden characters

secureResponse adds Strict-Transport-Security (max-age=31536000;
includeSubDomains) to the six existing headers, whose values are unchanged.

problem() accepts the closed list PROBLEM_STATUSES (400, 401, 403, 404, 405,
409, 422, 429, 500, 503) and throws web.problem_invalid for any other status,
at run time too. Code pattern, identifier pattern, body and content type are
unchanged.

createRequestHandler sets X-Request-Id, equal to the identifier validated
from the application, on every response it returns (route, static asset, 404,
405, 500, fallback, HEAD included). A client X-Request-Id is never used. A
route receives the identifier as a third argument.

liveRoute() and readyRoute(check) are route factories: 200 ok, 200 ready, and
503 not_ready without any detail when check rejects or throws.

revealHiddenCharacters(text) replaces each hidden code point by [U+XXXX] and
keeps TAB and LF; the result is plain text, not HTML. Its class is the
removedRanges table of the candidate served-text preparation vectors. That
candidate is not merged, so nothing is imported or pinned: the 28 ranges and
55 kept neighbours are copied under fixtures/ and the test compares the
literal table of the module to that copy over the whole code space, printing
its counters. A missing copy fails the test.

Tests, and what turns each red:
- response.test.ts: HSTS header renamed (1 test, plus the liveness test);
  PROBLEM_STATUSES set back to the former four statuses (1 test, plus the
  route refusal test); run-time status check disabled (1 test).
- server.test.ts: X-Request-Id not set (3 tests); a constant passed to the
  route instead of the identifier (1 test).
- probes.test.ts: 503 replaced by 200 (1 test); check not awaited (1 test);
  liveness body changed (1 test).
- visible-text.test.ts: replacement disabled (2 tests); one code point
  dropped from the last range (1 test); copy file absent (1 test).

Would an equivalent refactor turn them red? No: expectations are header
values, statuses and bodies taken from the lot brief, and the class is
checked through the public function against the copied table, not through
the shape of the literal.

Points left to the owner

None named in the commit messages.

Work package

No commit carries a Work-package: or Exempt: trailer. This repository runs no work-package link check; the link to a PRD row, if any, is the owner's to establish.

Blast radius

  • Repository libre-ai/application-development-toolkit only. While draft, nothing moves outside the branch work/rewrite-l040; a merge reaches migrate/recover-code.
  • No workflow file touched.

…visible hidden characters

secureResponse adds Strict-Transport-Security (max-age=31536000;
includeSubDomains) to the six existing headers, whose values are unchanged.

problem() accepts the closed list PROBLEM_STATUSES (400, 401, 403, 404, 405,
409, 422, 429, 500, 503) and throws web.problem_invalid for any other status,
at run time too. Code pattern, identifier pattern, body and content type are
unchanged.

createRequestHandler sets X-Request-Id, equal to the identifier validated
from the application, on every response it returns (route, static asset, 404,
405, 500, fallback, HEAD included). A client X-Request-Id is never used. A
route receives the identifier as a third argument.

liveRoute() and readyRoute(check) are route factories: 200 ok, 200 ready, and
503 not_ready without any detail when check rejects or throws.

revealHiddenCharacters(text) replaces each hidden code point by [U+XXXX] and
keeps TAB and LF; the result is plain text, not HTML. Its class is the
removedRanges table of the candidate served-text preparation vectors. That
candidate is not merged, so nothing is imported or pinned: the 28 ranges and
55 kept neighbours are copied under fixtures/ and the test compares the
literal table of the module to that copy over the whole code space, printing
its counters. A missing copy fails the test.

Tests, and what turns each red:
- response.test.ts: HSTS header renamed (1 test, plus the liveness test);
  PROBLEM_STATUSES set back to the former four statuses (1 test, plus the
  route refusal test); run-time status check disabled (1 test).
- server.test.ts: X-Request-Id not set (3 tests); a constant passed to the
  route instead of the identifier (1 test).
- probes.test.ts: 503 replaced by 200 (1 test); check not awaited (1 test);
  liveness body changed (1 test).
- visible-text.test.ts: replacement disabled (2 tests); one code point
  dropped from the last range (1 test); copy file absent (1 test).

Would an equivalent refactor turn them red? No: expectations are header
values, statuses and bodies taken from the lot brief, and the class is
checked through the public function against the copied table, not through
the shape of the literal.

Signed-off-by: Constantin Jais <74049135+constantin-jais@users.noreply.github.com>
@constantin-jais
constantin-jais marked this pull request as ready for review November 17, 2026 20:58
@constantin-jais
constantin-jais merged commit 2d448de into migrate/recover-code Nov 17, 2026
1 check passed
@constantin-jais
constantin-jais deleted the work/rewrite-l040 branch November 17, 2026 21:26
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