Implements CARD-14 (core #113) under decisions D10 (secure: true by default) and D11 (string | string[] for every response header). First card of the HTTP lane: CARD-15 and CARD-16 stack on this branch.
What changed and why
Read:@cookie('name') / @cookies() are a new 'cookies' arg source next to @header/@headers, with the same forms: none, key, key list, schema. The Cookie header is parsed on first use per request and cached on the context, so a route with no cookie argument never parses it. Parsing follows RFC 6265: the first value wins, %-sequences are decoded, malformed pairs are skipped (never a 400), and an undecodable value is kept raw. Several cookie lines are joined with ; . The map has no prototype, so __proto__=x is just a key. Works on HTTP and WS routes. 'cookies' joins the seed-key allow-list, and @needs('cookies') resolves the same map.
Write:setCookie(name, value, options?) (src/cookies.ts, no dependency) defaults to Path=/; Secure; HttpOnly; SameSite=Lax. It throws, naming the field, on a non-token name; on a value with CR/LF, ;, ,, whitespace or a control character; on an attribute with CR/LF; and on sameSite: 'none' or partitioned without secure.
Many cookies:TransformerFn, ErrorResponse.headers, HttpError/HttpErrorLike.headers, ResponseShape.headers and NeutralOutcome widen to Record<string, string | string[]>.
Node: joinListHeaders runs inside the existing writeHead patch, so every Node write path is covered. It keeps set-cookie arrays (Node writes one line per element) and joins every other array with , .
Fetch adapters (Deno, Bun, edge, app.fetch): toWebHeaders builds a Headers and appends each set-cookie element. The buffered/stream, shed-503 and preflight paths all use it.
mergeInjectedHeaders: injected headers still win. A handler vary array is joined before being merged with the injected value.
OpenAPI: a cookie argument becomes an in: 'cookie' parameter.
Plugins checked: metrics/src/prometheus.ts and rate-limit/src/errors.ts only produce headers, so they are unaffected.
Things I was unsure about / deviations
Stricter attribute check than the card.path/domain also refuse ; and other control characters, not only CR/LF: a ; in Path would add an attribute without breaking the header. I chose the conservative option; flag it if you want CR/LF only.
Card note not followed: cookies are parsed lazily instead of seeded. The card says to seed cookies into the context. In this codebase steps can only needreq/params (topoSort seed keys), so seeding would only serve handlers. Lazy parsing in resolveArgs gives "parsed once, only when declared" without a per-request flag.
Quoted values are not unquoted.a="x" reads as "x"; RFC 6265 §5.2 doesn't unquote.
setCookie writes the value as given and does not encode it (T4 expects s=v). JSDoc tells callers to encodeURIComponent the value themselves.
Test evidence
New: test/cookies.test.ts (T1–T9, T11, WS route, OpenAPI, injected-header authority; raw socket rawHeaders on Node plus app.fetch), test/http-headers.test.ts (array merge, joinListHeaders, toWebHeaders), test/mesh/integration.test.ts (T10: teapot route with two cookies reaches the teacup client as two lines), test/deno/cookies.test.ts, test/bun/cookies.test.ts (real Deno.serve/Bun.serve), test/edge/run.ts + worker.ts (workerd).
== npm run lint
exit 0
✖ 50 problems (0 errors, 50 warnings)
== npm run format:check
exit 0
All matched files use Prettier code style!
== npm run typecheck
exit 0
== npm run test
exit 0
Test Files 93 passed (93)
Tests 941 passed (941)
== npm run build
exit 0
CJS ⚡️ Build success in 27ms
ESM ⚡️ Build success in 28ms
DTS ⚡️ Build success in 1145ms
== npm run complexity:check
exit 0
✓ cognitive complexity: every function ≤ 25
== npm run test:deno
exit 0
T3 serveDeno: an IPv6 peer is passed through as Deno reports it ... ok (822µs)
ok | 37 passed | 0 failed (4s)
== npm run test:bun
exit 0
27 pass
0 fail
== npm run test:edge
exit 0
edge (workerd via miniflare): HTTP 200 + cookies + body limits 413/413/200/413 + WS echo:hi + ws limits — PASS
edge (workerd): router parity — 1158 matcher cases + 55 app.fetch cases — PASS
Lint warnings (50) are the pre-existing no-explicit-any baseline; this branch adds none. Frozen router-parity captures are untouched. npm audit --audit-level=moderate: 0 vulnerabilities after rebasing on develop (#134 merged).
Docs follow-up (CARD-12)
guides/arguments.md: @cookie/@cookies, parsing rules, @needs('cookies'); setCookie with options and defaults; several cookies via a set-cookie array; the secure: !isDev recipe for Safari, LAN IPs and plain-HTTP dev hosts (D10).
reference/decorators.md: the two decorators.
Migration note for the string | string[] header widening (D11), and how other arrays are joined.
Implements **CARD-14** (core #113) under decisions **D10** (`secure: true` by default) and **D11** (`string | string[]` for every response header). First card of the HTTP lane: CARD-15 and CARD-16 stack on this branch.
## What changed and why
- **Read:** `@cookie('name')` / `@cookies()` are a new `'cookies'` arg source next to `@header`/`@headers`, with the same forms: none, key, key list, schema. The `Cookie` header is parsed on first use per request and cached on the context, so a route with no cookie argument never parses it. Parsing follows RFC 6265: the first value wins, `%`-sequences are decoded, malformed pairs are skipped (never a 400), and an undecodable value is kept raw. Several `cookie` lines are joined with `; `. The map has no prototype, so `__proto__=x` is just a key. Works on HTTP and WS routes. `'cookies'` joins the seed-key allow-list, and `@needs('cookies')` resolves the same map.
- **Write:** `setCookie(name, value, options?)` (`src/cookies.ts`, no dependency) defaults to `Path=/; Secure; HttpOnly; SameSite=Lax`. It throws, naming the field, on a non-token name; on a value with CR/LF, `;`, `,`, whitespace or a control character; on an attribute with CR/LF; and on `sameSite: 'none'` or `partitioned` without `secure`.
- **Many cookies:** `TransformerFn`, `ErrorResponse.headers`, `HttpError`/`HttpErrorLike.headers`, `ResponseShape.headers` and `NeutralOutcome` widen to `Record<string, string | string[]>`.
- Node: `joinListHeaders` runs inside the existing `writeHead` patch, so every Node write path is covered. It keeps `set-cookie` arrays (Node writes one line per element) and joins every other array with `, `.
- Fetch adapters (Deno, Bun, edge, `app.fetch`): `toWebHeaders` builds a `Headers` and appends each `set-cookie` element. The buffered/stream, shed-503 and preflight paths all use it.
- `mergeInjectedHeaders`: injected headers still win. A handler `vary` array is joined before being merged with the injected value.
- **OpenAPI:** a cookie argument becomes an `in: 'cookie'` parameter.
- Plugins checked: `metrics/src/prometheus.ts` and `rate-limit/src/errors.ts` only *produce* headers, so they are unaffected.
## Things I was unsure about / deviations
- **Stricter attribute check than the card.** `path`/`domain` also refuse `;` and other control characters, not only CR/LF: a `;` in `Path` would add an attribute without breaking the header. I chose the conservative option; flag it if you want CR/LF only.
- **Card note not followed: cookies are parsed lazily instead of seeded.** The card says to seed `cookies` into the context. In this codebase steps can only `need` `req`/`params` (`topoSort` seed keys), so seeding would only serve handlers. Lazy parsing in `resolveArgs` gives "parsed once, only when declared" without a per-request flag.
- **Quoted values are not unquoted.** `a="x"` reads as `"x"`; RFC 6265 §5.2 doesn't unquote.
- `setCookie` writes the value as given and does not encode it (T4 expects `s=v`). JSDoc tells callers to `encodeURIComponent` the value themselves.
## Test evidence
New: `test/cookies.test.ts` (T1–T9, T11, WS route, OpenAPI, injected-header authority; raw socket `rawHeaders` on Node plus `app.fetch`), `test/http-headers.test.ts` (array merge, `joinListHeaders`, `toWebHeaders`), `test/mesh/integration.test.ts` (T10: teapot route with two cookies reaches the teacup client as two lines), `test/deno/cookies.test.ts`, `test/bun/cookies.test.ts` (real `Deno.serve`/`Bun.serve`), `test/edge/run.ts` + `worker.ts` (workerd).
```
== npm run lint
exit 0
✖ 50 problems (0 errors, 50 warnings)
== npm run format:check
exit 0
All matched files use Prettier code style!
== npm run typecheck
exit 0
== npm run test
exit 0
Test Files 93 passed (93)
Tests 941 passed (941)
== npm run build
exit 0
CJS ⚡️ Build success in 27ms
ESM ⚡️ Build success in 28ms
DTS ⚡️ Build success in 1145ms
== npm run complexity:check
exit 0
✓ cognitive complexity: every function ≤ 25
== npm run test:deno
exit 0
T3 serveDeno: an IPv6 peer is passed through as Deno reports it ... ok (822µs)
ok | 37 passed | 0 failed (4s)
== npm run test:bun
exit 0
27 pass
0 fail
== npm run test:edge
exit 0
edge (workerd via miniflare): HTTP 200 + cookies + body limits 413/413/200/413 + WS echo:hi + ws limits — PASS
edge (workerd): router parity — 1158 matcher cases + 55 app.fetch cases — PASS
```
Lint warnings (50) are the pre-existing `no-explicit-any` baseline; this branch adds none. Frozen router-parity captures are untouched. `npm audit --audit-level=moderate`: 0 vulnerabilities after rebasing on develop (#134 merged).
## Docs follow-up (CARD-12)
- `guides/arguments.md`: `@cookie`/`@cookies`, parsing rules, `@needs('cookies')`; `setCookie` with options and defaults; several cookies via a `set-cookie` array; the `secure: !isDev` recipe for Safari, LAN IPs and plain-HTTP dev hosts (D10).
- `reference/decorators.md`: the two decorators.
- Migration note for the `string | string[]` header widening (D11), and how other arrays are joined.
Owner decisions (2026-10-23): lazy cookie parsing and the stricter path/domain validation are accepted. Unquoting and value encoding are out of 1c. Not merging yet: implementation review first.
Owner decisions (2026-10-23): lazy cookie parsing and the stricter `path`/`domain` validation are accepted. Unquoting and value encoding are out of 1c. Not merging yet: implementation review first.
Implementation review done on 2026-10-23: a Codex review of all 12 sprint PRs, with each finding verified. The P1s in #142 and the P3 in #149 are fixed. The owner (Chrnx) authorized merging in order, each one rebased on develop with CI green. This supersedes the earlier "not merging yet" note.
Implementation review done on 2026-10-23: a Codex review of all 12 sprint PRs, with each finding verified. The P1s in #142 and the P3 in #149 are fixed. The owner (Chrnx) authorized merging in order, each one rebased on develop with CI green. This supersedes the earlier "not merging yet" note.
Reading a cookie meant parsing the Cookie header by hand, and a response
could not carry more than one Set-Cookie: response header values were
Record<string, string>, and the fetch adapters would have stringified an
array into one broken "a,b" cookie anyway.
- @cookie('name') / @cookies() sit next to @header/@headers as a new
'cookies' arg source. The header is parsed on first use per request and
cached on the context, so a route without a cookie argument never parses
it. RFC 6265: first value wins, %-sequences decoded, malformed pairs
skipped (never a 400), undecodable values kept raw. Several cookie lines
are joined with "; ". The map has no prototype. @needs('cookies') reads
the same map, and 'cookies' joins the seed-key allow-list.
- setCookie(name, value, options) serialises one Set-Cookie value with
HttpOnly, SameSite=Lax, Path=/ and Secure by default (D10), and throws,
naming the field, on anything that could inject a header or that browsers
reject (sameSite none / partitioned without secure).
- Response header values widen to string | string[] (D11) across
TransformerFn, ErrorResponse, HttpError(Like).headers, ResponseShape and
the neutral outcome. Node writes a set-cookie array as one line per
element and joins every other array with ", " before writeHead; the
fetch adapters build a Headers and append each set-cookie element.
mergeInjectedHeaders keeps arrays by reference and joins a vary array
before merging it.
- OpenAPI maps a cookie argument to an in: cookie parameter.
BREAKING CHANGE: code that reads a header value from TransformerFn,
ErrorResponse, HttpError or ResponseShape as a string must handle string[].
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Implements CARD-14 (core #113) under decisions D10 (
secure: trueby default) and D11 (string | string[]for every response header). First card of the HTTP lane: CARD-15 and CARD-16 stack on this branch.What changed and why
@cookie('name')/@cookies()are a new'cookies'arg source next to@header/@headers, with the same forms: none, key, key list, schema. TheCookieheader is parsed on first use per request and cached on the context, so a route with no cookie argument never parses it. Parsing follows RFC 6265: the first value wins,%-sequences are decoded, malformed pairs are skipped (never a 400), and an undecodable value is kept raw. Severalcookielines are joined with;. The map has no prototype, so__proto__=xis just a key. Works on HTTP and WS routes.'cookies'joins the seed-key allow-list, and@needs('cookies')resolves the same map.setCookie(name, value, options?)(src/cookies.ts, no dependency) defaults toPath=/; Secure; HttpOnly; SameSite=Lax. It throws, naming the field, on a non-token name; on a value with CR/LF,;,,, whitespace or a control character; on an attribute with CR/LF; and onsameSite: 'none'orpartitionedwithoutsecure.TransformerFn,ErrorResponse.headers,HttpError/HttpErrorLike.headers,ResponseShape.headersandNeutralOutcomewiden toRecord<string, string | string[]>.joinListHeadersruns inside the existingwriteHeadpatch, so every Node write path is covered. It keepsset-cookiearrays (Node writes one line per element) and joins every other array with,.app.fetch):toWebHeadersbuilds aHeadersand appends eachset-cookieelement. The buffered/stream, shed-503 and preflight paths all use it.mergeInjectedHeaders: injected headers still win. A handlervaryarray is joined before being merged with the injected value.in: 'cookie'parameter.metrics/src/prometheus.tsandrate-limit/src/errors.tsonly produce headers, so they are unaffected.Things I was unsure about / deviations
path/domainalso refuse;and other control characters, not only CR/LF: a;inPathwould add an attribute without breaking the header. I chose the conservative option; flag it if you want CR/LF only.cookiesinto the context. In this codebase steps can onlyneedreq/params(topoSortseed keys), so seeding would only serve handlers. Lazy parsing inresolveArgsgives "parsed once, only when declared" without a per-request flag.a="x"reads as"x"; RFC 6265 §5.2 doesn't unquote.setCookiewrites the value as given and does not encode it (T4 expectss=v). JSDoc tells callers toencodeURIComponentthe value themselves.Test evidence
New:
test/cookies.test.ts(T1–T9, T11, WS route, OpenAPI, injected-header authority; raw socketrawHeaderson Node plusapp.fetch),test/http-headers.test.ts(array merge,joinListHeaders,toWebHeaders),test/mesh/integration.test.ts(T10: teapot route with two cookies reaches the teacup client as two lines),test/deno/cookies.test.ts,test/bun/cookies.test.ts(realDeno.serve/Bun.serve),test/edge/run.ts+worker.ts(workerd).Lint warnings (50) are the pre-existing
no-explicit-anybaseline; this branch adds none. Frozen router-parity captures are untouched.npm audit --audit-level=moderate: 0 vulnerabilities after rebasing on develop (#134 merged).Docs follow-up (CARD-12)
guides/arguments.md:@cookie/@cookies, parsing rules,@needs('cookies');setCookiewith options and defaults; several cookies via aset-cookiearray; thesecure: !isDevrecipe for Safari, LAN IPs and plain-HTTP dev hosts (D10).reference/decorators.md: the two decorators.string | string[]header widening (D11), and how other arrays are joined.82767eabd2to47743fdf1fOwner decisions (2026-10-23): lazy cookie parsing and the stricter
path/domainvalidation are accepted. Unquoting and value encoding are out of 1c. Not merging yet: implementation review first.Implementation review done on 2026-10-23: a Codex review of all 12 sprint PRs, with each finding verified. The P1s in #142 and the P3 in #149 are fixed. The owner (Chrnx) authorized merging in order, each one rebased on develop with CI green. This supersedes the earlier "not merging yet" note.
47743fdf1fto88945b0b1fReading a cookie meant parsing the Cookie header by hand, and a response could not carry more than one Set-Cookie: response header values were Record<string, string>, and the fetch adapters would have stringified an array into one broken "a,b" cookie anyway. - @cookie('name') / @cookies() sit next to @header/@headers as a new 'cookies' arg source. The header is parsed on first use per request and cached on the context, so a route without a cookie argument never parses it. RFC 6265: first value wins, %-sequences decoded, malformed pairs skipped (never a 400), undecodable values kept raw. Several cookie lines are joined with "; ". The map has no prototype. @needs('cookies') reads the same map, and 'cookies' joins the seed-key allow-list. - setCookie(name, value, options) serialises one Set-Cookie value with HttpOnly, SameSite=Lax, Path=/ and Secure by default (D10), and throws, naming the field, on anything that could inject a header or that browsers reject (sameSite none / partitioned without secure). - Response header values widen to string | string[] (D11) across TransformerFn, ErrorResponse, HttpError(Like).headers, ResponseShape and the neutral outcome. Node writes a set-cookie array as one line per element and joins every other array with ", " before writeHead; the fetch adapters build a Headers and append each set-cookie element. mergeInjectedHeaders keeps arrays by reference and joins a vary array before merging it. - OpenAPI maps a cookie argument to an in: cookie parameter. BREAKING CHANGE: code that reads a header value from TransformerFn, ErrorResponse, HttpError or ResponseShape as a string must handle string[]. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>88945b0b1fto7f9a0eef0f