Contract v4 field rules (council-reviewed draft 2.4) — FLT-389 / FLT-399 I3a¶
Draft 2.4 changes (2026-11-07, after the draft 2.3 delta round: CedricFocus 2 new Highs in reconciliation, Gronktayvius red team C4/C6/ACL/HTTP-stack open + 8 new Highs): (a) RECONCILIATION is now a TIME FENCE, not a state match: an UnknownOutcome stays UNRESOLVED until the lease expiry plus 5 s has passed (R20 guarantees nothing in flight can commit after that), and a matching state is reported as EQUIVALENT STATE REACHED, never as proof that this request committed; (b) a 500 on a dispatched mutation is ALWAYS UnknownOutcome (the validate-before-commit exception is deleted); (c) the handoff 200 now carries expiresAt; the Theia 202 is exempt from the wt echo; (d) R13 adds link-count 1, owner equals caller, POSIX ACL entries, exclusive non-following create, NT-prefix path spellings and equal-credential refusal; (e) the network-sink ban is by sink, not by name list; Stryker.NET named; (f) NEW PART B, server obligations R22 to R27 (one current lease id per worktree, stale version compare on every mutate, fixed-time credential compare and a single Authorization header, loopback-only listen socket, Theia trusted-binary launch, refuse to start when read equals mutate credential), which the gateway session enforces and which the client does NOT implement.
Draft 2.3 changes (2026-11-07, after the draft 2.2 delta round: CedricFocus 5 remaining issues, Gronktayvius red team 5 open + 7 new Highs): D1 the GET snapshot no longer carries leaseId (R11): a lease id is a mutate-only capability returned only by lease and handoff; R19 success bodies echo wt; R19 route-to-credential binding (read token cannot mutate); server rejects expired leases on every mutate route and bounds issuance (R20); R20 worktreePath lexical + registered-root rule; R14 exact base-URI and peer equality (127.0.0.2, ::ffff:127.0.0.1, port); R16 retry-before-terminal ordering, explicit reconciliation PREDICATES per operation, replay success needs a confirming GET, S16.1 narrowed; DELETE 204 empty body exempt; header vectors for ETag, If-Match, X-Forge-Lease; wire vectors that only become dangerous after unicode-escape decoding; R13 creator/reader ACL rule; consumer conformance manifest (R18); architecture test bans the whole HTTP/socket stack by namespace.
Draft 2.2 changes (2026-11-07, after the CedricFocus delta round, the gateway server review and the orchestrator's conditions): R9c request panel complete-only; R11 always five members, panel {} or complete; R12 stale create is 412; R13 non-following open protocol; R15 duplicates detected on DECODED names too; R16 protocol validity separated from commit certainty (invalid or lost mutation response = UnknownOutcome, reconcile by GET), handoff retry bounds, new kind IdempotencyConflict; R17 cache saturation policy; R19 endpoint matrix; section 4 scenarios for the choke point, lease generation and independent pinning.
Status: DRAFT 2 (superseded by 2.2 above), 2026-11-07. Author lane A (WT-1d5b). Reviewed by Gronktayvius red team (11 findings F1 to F11) and CedricFocus (5 P1, 3 P2), and aligned with the real server at I3a f0be726 (answers from the gateway session). The gateway session cuts the v4 contract file and folds this table in; both repos pin the v4 LF hash and the shared vectors file WT-1d5b-contract-v4-field-vectors.json (LF + final newline). Normalisation rule for hashes is unchanged: strip one leading UTF-8 BOM, CRLF to LF, nothing else.
Principles: (1) parse, do not validate: every wire value becomes a typed value or is rejected. (2) One table, two enforcers (client choke point, server), same vectors. (3) Fail closed: a violation means the request is not sent / the response is rejected, with a typed error carrying kind and status only, never the offending value, and a violation is NEVER retried and NEVER treated as an empty or bootstrap state. (4) ASCII-only identifiers.
1. JSON scanner (R15, normative, applies to every request body and every response body, both sides)¶
Bodies are UTF-8 without BOM, a single JSON object (the one exception: a successful DELETE answers 204 with an EMPTY body, and a 204 with any body is invalid; an empty body is valid only for 204), max nesting depth 8, no comments, no trailing commas, no NaN/Infinity. Member names are compared ordinally and case-sensitively (version and Version are different members, and an unknown member is rejected, so Version is rejected as unknown). Duplicate member names at ANY depth are rejected, detected on BOTH the raw spelling and the DECODED name ({"version":4,"version":5} has two raw spellings of one decoded name and is rejected) before any decode-to-map. Numbers: raw token must match 0|[1-9][0-9]* (no sign, no fraction, no exponent, no -0, no leading zero, never a JSON string where an integer is required). Strings are validated only AFTER JSON decoding (so \u002e\u002e is seen as ..). Required members must be present with the exact JSON type; null is allowed only where a rule says so. Do not port the \A ... \z anchors by hand into another language: JavaScript $ matches before a trailing newline; use an explicit end-of-string check.
2. Rule table¶
| # | Field | Rule |
|---|---|---|
| R1 | wt |
\AWT-[0-9a-z]{4}\z |
| R2 | owner, toOwner, currentOwner |
1 to 64 ASCII characters: first character [A-Za-z0-9]; the rest [A-Za-z0-9._-] (letters, digits, dot, underscore, hyphen); the last character must not be .. Regex: \A[A-Za-z0-9](?:[A-Za-z0-9._-]{0,62}[A-Za-z0-9_-])?\z. No colon. Owners never go into URLs, paths, sockets or header names. Examples: dsh, theia, WT-98c2, greatroom, local_7e048aeb-9ce8-47ee-ab98-08317d098e8c |
| R3 | leaseId, launchId |
\A[0-9a-f]{32}\z. leaseId is a capability: issued from at least 128 bits of CSPRNG output, compared in constant time, never logged, never in an error text |
| R4 | idempotencyKey |
canonical lower-case hyphenated UUID \A[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\z, not the nil UUID |
| R5 | ttlSeconds |
JSON integer 30 to 600 inclusive |
| R6 | expectedVersion (request) |
JSON integer 0 to 9007199254740991 |
| R7 | version (response) |
JSON integer 1 to 9007199254740991; 0 appears only in the bootstrap 404 (R12) |
| R8 | every timestamp (expiresAt, updatedAt) |
ONE canonical form yyyy-MM-ddTHH:mm:ssZ (regex \A[0-9]{4}-(0[1-9]\|1[0-2])-(0[1-9]\|[12][0-9]\|3[01])T([01][0-9]\|2[0-3]):[0-5][0-9]:[0-5][0-9]Z\z), year 2000 to 2100, calendar-valid (no 31 February), seconds precision, no fraction, no offset other than the literal Z. Grant USE window: when a client uses a lease grant, now - 5 s < expiresAt <= now + requestedTtl + 5 s, evaluated with an injectable clock. Display-only values (updatedAt, expiresAt in a GET snapshot) are NOT checked against the clock |
| R9 | ticketPanel.ticketKey |
\A[A-Z]{2,10}-[0-9]{1,6}\z |
| R9a | ticketPanel.status |
exactly one of todo, in_progress, review, blocked, done |
| R9c | ticketPanel as a whole |
a REQUEST (PUT body {"ticketPanel":{...}}) carries ALL FIVE members: ticketKey, status, checklist, activeFile, updatedAt (complete-only, no merge, no partial). A RESPONSE panel is exactly {} (never set) or the complete five-member object; a partial panel in a response is a protocol violation |
| R9b | ticketPanel.checklist |
array of at most 50 {id, done}; id \A[a-z0-9-]{1,40}\z, unique in the list; done boolean |
| R10 | ticketPanel.activeFile |
see section 3 |
| R11 | GET 200 snapshot | members wt, owner, version, lease, ticketPanel all required; wt equals the requested wt; version per R7; owner is null if and only if lease is null; when present lease.owner equals owner; lease is exactly {owner, expiresAt} per R2, R8 (D1: the snapshot NEVER carries leaseId; a lease id is a mutate-only capability returned only by lease acquire and handoff, so a read-token holder never learns it); ticketPanel exactly {} or the complete five-member object per R9c, validated by R9 to R10; the server renders ALL FIVE members always (never omits them): never leased gives owner: null, lease: null, ticketPanel: {}; unknown members rejected at every depth. An EXPIRED lease is never rendered: the server renders lease: null and owner: null |
| R12 | bootstrap | ONLY an HTTP 404 whose body is exactly the two members wt (equals the requested wt) and version (the integer 0). Anything else on a 404, and ANY validation failure on any status, is not a bootstrap and never leads to an expectedVersion: 0 write. Server side: expectedVersion: 0 on lease acquire is an atomic create-if-absent and returns 412 {version} (stale version) when the record already exists. 401 and 403 are authentication failures, never an empty state |
| R13 | credential file | \A[0-9a-f]{64}(\r?\n)?\z over the raw bytes: exactly 64 lower-case hex characters, then at most ONE line ending, then end of file; file size at most 66 bytes. OPEN PROTOCOL (fail closed on any error): the path comes from configuration, must be absolute and local (no UNC, no \\?\ device paths); open the trusted parent directory first, then open the file RELATIVE to that directory handle with non-following semantics (reparse points and symlinks are never followed; any reparse point on any component, including the parent chain, is a rejection); classify the object type from the opened handle BEFORE any read (must be a regular disk file: named pipes, devices, directories are rejected without reading, so nothing can block); require an owner-only ACL (Windows: the DACL grants access only to the file owner, SYSTEM and Administrators; POSIX: mode 0600 AND no extended ACL entry for anyone but the owner) and REJECT the file otherwise, returning no token; additionally require link count 1 (a hardlink is rejected) and that the file owner (Windows SID, POSIX uid) equals the calling user; the two credentials (read, mutate) must differ under a fixed-time compare, otherwise BOTH are refused and no token is returned; before any native open the path is canonicalised with the documented Win32 API and refused unless it is a drive-letter path: \\??\, \\.\ (including \\.\pipe\), \\?\, \\?\UNC\, \??\UNC\ and every UNC form are rejected without an open attempt; the WRITER (onboarder) must create the file exclusively and non-following (CREATE_NEW with FILE_FLAG_OPEN_REPARSE_POINT, or O_CREAT|O_EXCL|O_NOFOLLOW) atomically with that owner-only ACL, failing if the name exists, in a parent directory that is itself owner-only and not a reparse point; read from that same handle with a hard 67-byte cap, cancellable (cancellation returns no token). No Trim |
| R14 | transport and size caps | base address is the constant http://127.0.0.1:4319 or http://[::1]:4319 (IP literal, never a name; no userinfo, no path, no query; scheme http only; port exactly 4319; 127.0.0.2, any other 127.x address, ::ffff:127.0.0.1, localhost, https, other ports are rejected at construction; tests that need another port pass it through one explicit test-only factory argument, never through a general predicate such as IPAddress.IsLoopback); the CONNECTED peer address must byte-equal the chosen constant (127.0.0.1 or ::1) and port 4319, checked at connect time; proxies disabled; redirects disabled and every 3xx is a failure; connected peer checked to be that loopback literal; request Content-Type: application/json and responses accepted only as application/json (optional charset=utf-8) with no Content-Encoding; request body at most 64 KiB; response body at most 1 MiB enforced on the bytes actually read, with a read timeout; every string member at most the length its rule allows; error bodies are never echoed and error kinds come from an allowlist |
| R16 | errors and retries (matrix) | PROTOCOL VALIDITY and COMMIT CERTAINTY are separate dimensions. (1) A rule violation in the client's own INPUT: BadRequest, no request sent. (2) A violation in a GET response (or any non-mutation): ProtocolViolation, never retried, never a bootstrap. (3) ANY mutation (lease acquire, PUT, handoff, DELETE) that was dispatched and then ends in a timeout, connection loss, 408, 429, 500, 502, 503, 504, a missing, truncated, oversized or invalid response body, or an unexpected status is UnknownOutcome (the cause is recorded, the commit is unknown). UnknownOutcome blocks all further mutations and any report of success until a validated GET (R11) resolves what happened; an inconclusive GET leaves the operation reported as UNRESOLVED. ORDER: the bounded exact-idempotent retries of (5) happen BEFORE the terminal UnknownOutcome transition; the block is entered only when the retries are exhausted or the failure is not retry-eligible (a sequence 503, 503, 200-replay is a success with no block; 503 three times is UnknownOutcome). RECONCILIATION = TIME FENCE THEN COMPARE. A GET cannot prove that a dispatched mutation will never commit (it may still be queued on the server) and cannot prove WHICH client's request produced a state. So: (i) after UnknownOutcome the client does nothing further on that worktree until the FENCE time has passed: fence = the expiry of the lease the mutation was gated by (the grant's expiresAt), or for a lease acquire dispatch time + requested ttlSeconds, plus 5 s; R20 guarantees the server rejects every mutation gated by an expired lease, so nothing in flight can commit after the fence. Exception: a handoff may be resolved EARLIER and exactly by replaying the SAME idempotencyKey (R17). (ii) After the fence, one validated GET (R11) is compared with the pre-image taken before the call: version equal to the pre-image version = the mutation did not commit (conclusive only after the fence); version equal to pre-image + 1 AND the state equal to the intended post-image (PUT: ticketPanel equal to the sent panel; handoff: owner equal to toOwner; DELETE: lease null; acquire: owner equal to the requested owner) = EQUIVALENT STATE REACHED, reported as such and never as proof that this request was the one that committed (another writer could reach the same state); every other combination, including a DIFFERENT owner after a DELETE, a version more than pre + 1, or a later hand-back to the same owner string, is UNRESOLVED and is reported to the caller, who must not retry blindly. A lost ACQUIRE never yields a usable lease id (the id was in the lost response): the client must not use or release it and simply waits out the TTL. (iii) "Any 200 GET counts as resolved" is forbidden. REPLAY: a 200 that is a replay of a stored handoff response is HISTORICAL; before it is treated as current authority the client must GET and require post.owner equals toOwner and post.version equals the stored response version; otherwise the result is UNRESOLVED (the world moved on) and the stored lease id is never used. LOST-RESPONSE SEQUENCE (single, consistent): handoff with a lost response: at most 3 exact idempotent replays (same key, byte-identical body, 200 ms then 400 ms backoff, 10 s overall); if none yields a response, UnknownOutcome, then the fence, then the validated GET; acquire and PUT are never replayed. Narrowed no-further-request rule: after a rule violation in the client's own input or in a GET response NO further request is made; after an invalid mutation response the ONLY permitted further request is the reconciliation GET. (4) Definite non-commit only for these server answers: 400, 401, 403, 404, 405, 409, 412, 415 with a valid R19 error body. (5) Retries: GET connection failure or 503 only; handoff 503 or connection failure only with the SAME idempotencyKey and the byte-identical body; both at most 3 attempts, 200 ms then 400 ms backoff, 10 s overall deadline. Acquire and PUT are never auto-retried. (6) 415 is BadRequest; 409 idempotency_conflict is kind IdempotencyConflict (never retried, never success); 409 held is LeaseConflict; 412 is VersionConflict; 401 and 403 are authentication failures; a 500 (including protocol_violation and sessions_corrupt) on any dispatched mutation is ALWAYS UnknownOutcome (there is no validate-before-commit exception: a server that commits and then dies also answers 500, and re-sending with a new key would apply the mutation twice). New error kinds (additive): ProtocolViolation, UnknownOutcome, IdempotencyConflict. Every classifier treats an unknown or out-of-range kind as non-retryable and failing closed |
| R17 | idempotency (server contract) | key scope is the worktree record; the stored entry binds a request fingerprint, SHA-256 over canonical {toOwner, leaseId, expectedVersion}; same key + same fingerprint within 10 minutes replays the stored response byte for byte (a historical success, not re-validated against the clock); same key + different fingerprint is 409 idempotency_conflict; the entry is committed atomically with the mutation (same locked write); entries older than 10 minutes are pruned on every write and each record keeps at most 256; an UNEXPIRED entry is never evicted: when 256 unexpired entries exist a new key is refused with 429 {"error":{"type":"idempotency_capacity"}} (not retryable until older entries age out), so replay protection is never silently lost |
| R19 | endpoint matrix (all members required and exact; no other members; null only where stated) |
POST /v1/sessions/{wt}/lease request {owner, ttlSeconds, expectedVersion} (R2, R5, R6) -> 200 {wt, leaseId, version, expiresAt} (R1 equals the requested wt, R3, R7, R8). PUT /v1/sessions/{wt} request headers If-Match (exactly one strong quoted integer, never *, never W/) and X-Forge-Lease (R3), body {"ticketPanel": <complete R9c panel>} -> 200 {wt, version} and ETag: "<version>" equal to the body version. POST /v1/sessions/{wt}/handoff request {toOwner, leaseId, expectedVersion, idempotencyKey} -> 200 {wt, leaseId, version, expiresAt, elapsedMs} with expiresAt per R8 (the new owner's lease expiry; the client validates the use window now - 5 s < expiresAt <= now + 600 s + 5 s because a handoff request carries no TTL) and elapsedMs an integer 0 to 3600000. DELETE /v1/sessions/{wt}/lease headers If-Match, X-Forge-Lease -> 204 with an EMPTY body. GET /v1/sessions/{wt} -> 200 per R11 with ETag: "<version>" equal to the body version; 404 per R12. Errors: 409 held {currentOwner, version, expiresAt} (R2, R7, R8); 412 {version} (R7); 409 {"error":{"type":"idempotency_conflict"}}; 400 {"error":"bad_wt"}, {"error":"bad_request"}, {"error":"path_refused"}; 401 {"error":"unauthorized"}; 403 {"error":{"type":"route_disabled","ticket":"FLT-399 I3"}}; 405 {"error":{"type":"method_not_allowed","use":"/v1/sessions/{wt}"}} (use exactly that string); 415 {"error":{"type":"unsupported_media_type"}}; 429 {"error":{"type":"idempotency_capacity"}}; 500 {"error":{"type":"sessions_corrupt"}} or {"error":{"type":"protocol_violation"}}; 502 {"error":{"type":"launch_failed"}}; 503 {"error":{"type":"busy"}}. Theia: POST /v1/theia/open request {worktreePath} (absolute local path, server canonicalises by final handle path) -> 202 {launchId} (R3 form). GET /v1/sessions (the list) is OUT OF SCOPE: legacy opaque schema, clients must not parse or depend on it. Every success body of the session routes echoes wt and the client rejects a body whose wt differs from the request's (the Theia 202 {launchId} is the one exempt body: it has no worktree identity). HEADER GRAMMAR: ETag and If-Match values are exactly one strong quoted canonical integer "<n>" (\A"(0\|[1-9][0-9]*)"\z): *, W/"3", a list "3", "4", an unquoted 3, "03", "", a duplicated header and leading or trailing whitespace are all rejected (server: 400; client: ProtocolViolation); the response ETag must equal the body version. X-Forge-Lease is exactly one value in the R3 form, never duplicated. ROUTE-TO-CREDENTIAL BINDING: GET /v1/sessions/{wt} takes the READ token; lease, PUT, handoff, DELETE and /v1/theia/open take the MUTATE token; the read token on any mutate route is rejected (403) with the body unchanged; a request with both tokens or a mismatching one is rejected |
| R20 | lease lifetime enforcement (server) | the server rejects an expired lease (expiresAt not later than now) on EVERY mutate route (PUT, handoff, DELETE; 409, body unchanged) and issues expiresAt inside [now + ttlSeconds - 5 s, now + ttlSeconds + 5 s]; a lease id is resolved only inside its own worktree record. Frozen-clock scenario: one second past expiresAt a PUT with the old lease id is rejected |
| R21 | Theia worktreePath |
lexical: \A[A-Za-z]:\\(?:[A-Za-z0-9._@+ -]{1,100}\\)*[A-Za-z0-9._@+ -]{1,100}\z, at most 260 characters, no .. or . segment, no trailing backslash, no quotes, no UNC, no \\?\; semantic: the value must resolve, via the section-3 handle protocol, to EXACTLY a registered worktree root (the final handle path equals that root; a subdirectory, a junction, or a sibling prefix is refused); launch with an argument vector only, never a command string |
| R18 | activeFile consumers |
activeFile may be opened ONLY by a consumer that passes the section-3 conformance fixtures. Until the Theia launcher and the panel pass them, opening activeFile is disabled in that consumer. This is a release prerequisite, not a follow-up. ENFORCED BY A MANIFEST: a consumer opens activeFile only if it carries a conformance manifest, the SHA-256 of the passing section-3 fixture-run result its own CI produced for the CURRENT vectors hash; without the manifest, or with a manifest for another vectors hash, the consumer refuses to open (scenario S18.1: a consumer built without the manifest still refuses, and a consumer that opens anyway fails the build) |
(R15 is section 1; numbering kept stable for the vectors.)
3. activeFile policy (R10)¶
A value is valid only if ALL of these hold, checked on the decoded string:
1. Length 1 to 260; split on / into segments; no leading /, no trailing /, no empty segment.
2. Every segment matches \A[A-Za-z0-9._@+ -]{1,100}\z, does not start or end with a space, does not end with ., and does not start with -. (ASCII only: no %, \, :, $, ~, *, ?, <, >, |, ", control characters, bidi or other format characters.)
3. No segment is . or ...
4. No segment equals .git case-insensitively; no segment matches \Agit~[0-9]+\z case-insensitively.
5. No segment whose part before the first . equals, case-insensitively, a Windows reserved device name: CON, PRN, AUX, NUL, COM1 to COM9, LPT1 to LPT9.
6. No segment ends (case-insensitively) with a launchable-shortcut extension: .lnk, .url, .settingcontent-ms, .desktop, .scf, .library-ms, .appref-ms.
Consumer rules (R18): open with an argument vector and a non-shell, non-creating file API (never ShellExecute, start, cmd /c or xdg-open; never create a missing file; never invoke git); do not treat opening a workspace as running its tasks (.vscode/tasks.json, .devcontainer), which is an editor trust decision outside this contract. REAL-PATH PROTOCOL (every consumer, fail closed on any error): open the registered worktree root as a directory handle; walk the segments with relative opens that do not follow reparse points or symlinks, rejecting any reparse point on any segment; the final object must be a regular file on the same volume as the root with a link count of 1; read the final path from the opened handle and require it to be under the root with a separator boundary (so C:\wt-evil is not inside C:\wt, and compare in the same \\?\ form, ordinal and case-insensitive on Windows); then use that handle, or repeat the walk at open. If a consumer must reopen by name, the residual same-user race is documented and accepted only for a same-user attacker. Required conformance fixtures: junction escape, symlink to .git/hooks/pre-commit, hardlink to a token file, root versus root-evil, 8.3 short names, foo -p as a single argument.
3b. PART B: server obligations (enforced by the gateway; the client does NOT implement these)¶
| # | Obligation |
|---|---|
| R22 | ONE current lease id per worktree. A lease id is looked up by the pair (wt, leaseId); handoff and DELETE drop the previous id in the SAME locked write; any other id, including an unexpired superseded one and an id issued for another worktree, is 409 with the stored state byte-identical |
| R23 | EVERY mutate compares If-Match (PUT, DELETE) or expectedVersion (acquire, handoff) with the stored version and answers 412 {version} with the state unchanged on mismatch, one scenario per route |
| R24 | Credentials and lease ids are compared with a fixed-time compare. Authentication is exactly one Authorization: Bearer <token> header; the token is never accepted from a query string, body or cookie; duplicate or malformed Authorization headers are rejected |
| R25 | The listening socket binds 127.0.0.1 and ::1 only, with exclusive address use and dual-stack OFF; a connection whose local address is not that literal is dropped before any header is read |
| R26 | Theia launch: absolute path of a trusted binary OUTSIDE any worktree; the child's working directory is that binary's own directory and NO worktree path is on the child's DLL search path (the gateway process itself keeps its default DLL search; a restriction that would also restrict the gateway is not required); the worktree path is exactly one argv element; a theia.exe or DLL planted in the worktree is never loaded |
| R27 | The server refuses to start (and the onboarder refuses to write) when the read and mutate credentials are equal under a fixed-time compare; check order on a request is: read token only on GET routes, mutate token only on mutate routes |
4. Client design requirements (summary; the code follows after the vectors are red)¶
Private constructors; classes or structs with an IsInitialized check (default is invalid); parse returns a result that the caller must handle (analyzer bans an ignored TryParse); all HTTP types internal, one registered handler, tokens unreachable from ToString, logs and exceptions; banned-API rule for HttpClient, HttpRequestMessage and raw JSON serialisation outside the gate class (name: BoundaryGate); serialise-time revalidation so a reflected instance still cannot reach the wire; strict bounded reader with the section-1 scanner; one CredentialFile.ReadExact. The panel and Theia consumer must use the same scanner (a duplicate-member-rejecting parser before any JSON.parse).
Additions required by the orchestrator (draft 2.1):
- Error kinds fail closed: every switch or classifier over the client's error kind treats an unknown, new or out-of-range kind as NON-retryable and as a failure, with no state change. A test casts an out-of-range integer to the enum, feeds it to each classifier, and asserts no retry and no state change.
- UnknownOutcome never lets the client assume the write succeeded. After an UnknownOutcome the client reconciles by a GET (validated per R11) before any further mutation or any report of success; if the GET cannot resolve the outcome the operation is reported as unresolved.
- F5 by construction: all transport (HttpClient, HttpMessageHandler, HttpRequestMessage, the JSON deserializer used for wire DTOs, token and credential reading) is internal to the gate class and its helpers (BoundaryGate). An architecture test (reflection over the assembly, plus a source scan of the project) fails if any type outside the gate namespace references those types. The test must be proven able to fail with a deliberate violation (a throwaway type in the test assembly that references HttpClient, expected to be reported).
Draft 2.2 test obligations (each is a scenario in the vectors file, and each must be shown failing against a deliberate mutant):
- Choke point bypasses: a default value object is rejected at serialise time; an ignored parse result is a compile or analyzer error; a reflected (constructor-skipped) instance cannot reach the wire; a second HttpClient use outside the gate fails the architecture test; the architecture test bans outbound network access BY SINK, not by a name list, outside the gate: any reference to a type in a namespace starting with System.Net; any DllImport of winhttp, wininet, ws2_32 or mswsock; any Process.Start or ProcessStartInfo; any Type.GetType, Assembly.GetType or Activator.CreateInstance whose string argument contains System.Net, WebRequest, HttpClient or Socket; it keeps one deliberate failing fixture per sink (including WebRequest.Create, pwsh.exe, curl.exe, a DllImport of winhttp, and Activator.CreateInstance(Type.GetType("System.Net.Http.HttpClient"))). A scan test also fails the build on ==, Equals or SequenceEqual applied to credential or lease-id bytes (fixed-time compare only). Stryker.NET runs on the gate and on the classifiers and a surviving mutant fails the build; Semgrep rules for the sinks above also fail the build.
- Lease generation: a scan test bans System.Random, Guid.NewGuid and any non-CSPRNG source in the code that mints leaseId; a statistical smoke (many ids, all distinct, 128 bits) runs in the server tests.
- Independent pinning: the contract hash and the vectors hash are pinned separately in BOTH repos; neither repo's CI may update the other's pin; any change to the contract, the vectors or either pin requires a logged entry in the shared notes and an acknowledgement from the other session. Rewriting a rule, its vector and one repo's pin alone fails the other repo's CI.
- Mutation-proof boundaries: vectors at exact min and max for every numeric and length rule; the test suite includes mutants that shift each boundary by one.
5. Vectors¶
WT-1d5b-contract-v4-field-vectors.json: per rule, good and bad entries with exact min/max boundaries, values carried as base64 UTF-8 or raw wire bytes (so control characters, bidi marks, duplicate members and -0 survive git and editors), plus context where a rule depends on it (requested wt, fixed clock for R8). Filesystem, concurrency, redirect and server-obligation rules (R10 conformance, R13 handle checks, R14, R16, R17, R22 to R27) are covered by scenario tests listed in the vectors file under scenarios, not by string vectors. Both repos assert every entry in build-blocking CI; weakening a rule requires a new contract file and a new hash. Mutants: boundary changes (>= 30 to > 30), each rule deleted, redirects followed, BadRequest mapped to retryable, the real-path check removed.
6. Out of scope¶
Smoke tool and panel (card FLT-444). TLS and token rotation. Same-user processes reading the token files (accepted limit).