Skip to content

test(Conformance): pin the rewriting-client redirect paths; build preprocess once (#359) - #369

Merged
thomasfosterau merged 1 commit into
trunkfrom
issue-359-redirect-followups
Oct 15, 2026
Merged

thomasfosterau merged 1 commit into
trunkfrom
issue-359-redirect-followups

Conversation

@thomasfosterau

Copy link
Copy Markdown
Owner

Summary

Refs #359 — follow-up to #360, from its post-merge review. Refs #352 — three nits from #368's post-merge review, listed separately below. Re-located against trunk at d182132 (after #366's step/send split and per-hop requestTimeout, and #368's refusal rules).

#360 follow-ups (src/internal/conformance/core.ts, src/Conformance.test.ts, docs/conformance.md)

Should-fix — test gaps:

  1. Per-attempt reset. New test: retry(rewrite(mapRequestEffect(refusing, f))) where attempt 1 prepares and the transport refuses it, and attempt 2's preparation fails. spec/target/reachable's note names the preparation failure and does not say the transport "followed itself" a redirect.
  2. Early-return branch. New test: mapRequestEffect(rewrite(canned), fail), the rewrite before the failing preparation. The note is the preparation failure, not a transport-followed redirect.
  3. Origin, not hostname. New tests: behind a client rewriting onto http://127.0.0.1:4010, a 308 to http://127.0.0.1:4011/live/… and to https://127.0.0.1:4010/live/… are both refused (nothing under /live is requested; spec/target/reachable names the Location).
  4. Path-prefix caveat. One sentence in docs/conformance.md §1.2 and on resolvedLocation: a client that rewrites the path too (adds a prefix) adds it again to a followed hop's path, as it does to a relative Location's.

Nits — behaviour:

  1. preprocess built once. client.preprocess(request) is now built once per request, outside the Effect.suspend, with the per-attempt reset of the capture still inside it. A HttpClient.mapRequestInput function now runs once per request, as under execute, not once per retry attempt. Under feat(Conformance): skip and requestTimeout options (#302) #366 each hop is its own step, so each hop still builds its own (one request, one build); the existing retry-under-requestTimeout test still passes. New test pins sent === 2 × mapped under retry({ times: 1 }).
  2. Null-origin guard. resolvedLocation no longer matches a rewritten origin of "null", so a data:/mailto:/custom-scheme Location is not read as a path on the kit's origin. New test with a client rewriting onto x-local://127.0.0.1:4010.
  3. Refused-hop naming. A refused hop is now named by the Location the server sent (resolved against the kit's URL as before), not the kit-origin URL it was translated to. New test: a rewriting client whose server redirects every request to itself on http://127.0.0.1:4010 is named by that URL at the hop cap.

#368 follow-ups (Refs #352; no behaviour change)

  1. docs/conformance.md §9 no longer says spec/query/include-unsupported-endpoint could fail with "got no response"; unknown-query-parameter and delete-response, which are not refusal rules, keep it.
  2. New test: a refusal probe answered by a 3xx the kit reads as the answer itself (a 302 with no Location, a 304) still fails both feat(Conformance): probe include / sort on an endpoint that does not declare them (#261) #278 rules with "was not rejected".
  3. Test renamed: "says a probe that got no response got none, not that it was not rejected" → "does not decide either on a probe that got no response".

The duplicated redirect note (spec.ts ~1454–1460 and core.ts undecidedByRedirects) is left as it is, as asked.

Mutation checks

Each mutant was applied alone and the whole of src/Conformance.test.ts run; each was killed, and only by the test(s) aimed at it:

Mutant Killed by
drop prepared = Option.none() per attempt per-attempt reset test
drop the "nothing captured and a failure" early return early-return test
compare hostname instead of origin in resolvedLocation both port and https cases
build preprocess inside the suspend again build-once test
drop the "null" origin guard custom-scheme test
name a refused hop by the translated URL refused-hop naming test
count an answered 3xx as "says nothing" in saysNothingOfRefusal both 302/304 cases

Verification

  • pnpm install --frozen-lockfile — pass
  • vp run build — pass
  • vp check — pass (0 errors; no new warnings on changed lines)
  • vp run check (sources, type-level tests, examples, emitted declarations) — pass
  • vp run -r test:unit — pass (3426 + 45 + 43 + 55)
  • vp run docgen — pass
  • fallow audit --base origin/trunk — pass ("No issues in 4 changed files"; 3 inherited complexity findings excluded by the gate). fallow audit --format json --quiet --explain --gate-marker agent — verdict pass.

Changeset

Notes

  • Spec-compliance behaviour: only the redirect runner for clients that rewrite with HttpClient.mapRequest/mapRequestInput; a client that rewrites nothing is unaffected.
  • Nit 7 changes only the URL a note quotes for a refused hop on a rewritten origin; for a relative Location, or one not on the rewritten origin, the quoted URL is unchanged.

🤖 Generated with Claude Code


Generated by Claude Code

…process once (#359)

Follow-up to #360's post-merge review:

- Tests pin the per-attempt reset of the prepared request under a client's
  own `retry`, the early return for a preparation that fails after the
  client's rewrite, and the refusal of a `Location` on the rewritten host
  over another port or over `https`.
- The client's `preprocess` is built once per request, as `execute` builds
  it, so a `mapRequestInput` function runs once rather than once per attempt.
- A rewritten URL with no origin (`"null"`) never makes a `Location` with no
  origin a path on the kit's origin.
- A refused hop is named by the `Location` the server sent, not the
  kit-origin URL it was translated to.
- The path-prefix caveat is documented in `docs/conformance.md` §1.2 and on
  `resolvedLocation`.

Follow-ups to #368's review (#352): a test pins that a refusal probe
answered by a 3xx the kit reads as the answer itself still fails; a test is
renamed to match the skip it asserts; §9 no longer says
`include-unsupported-endpoint` could fail with "got no response".

Claude-Session: https://claude.ai/code/session_0187g2QpzaHqEzX8GJxiJBVc
Co-Authored-By: Claude <noreply@anthropic.com>
@thomasfosterau
thomasfosterau merged commit 1de3515 into trunk Oct 15, 2026
1 check passed
@thomasfosterau
thomasfosterau deleted the issue-359-redirect-followups branch October 15, 2026 09:10
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.

2 participants