Repository navigation
#216 fetch credential references: resolve, scope per hop, never echo - #231
Merged
Merged
Conversation
Operator call 1A. The fetch client's jar lived for the worker's lifetime, so one command's Set-Cookie rode every later command to the same host — a credentialed fetch's session would ride an anonymous one. CommandScopeTransport, outermost over the guard, reads the command's scope from a ContextVar the handler sets around _fetch. Cookies live in the scope for one redirect chain; the client's own jar never stores. A hop with no scope is refused (RuntimeError). Each hop goes out on a copy of the request, because httpx builds the next hop from the handed one. The §7 "no server framework" detector named the whole stdlib http package; it now names http.server, so http.cookiejar (the never-storing jar's policy) is allowed. Planted-import tests pin both halves. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Unchanged rules, now public names: HEADER_NAME, HEADER_VALUE, REFUSED_HEADERS, REFUSED_HEADER_PREFIX and the two bounds. The fetch credential table checks a binding's header and value against the same rules the handler applies to `headers`, and the handler will import the table, so the rules can't stay in handler.py without a cycle. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
src/worker/credentials.py, in the alias table's shape: a JSON table at REPLICATOR_FETCH_CREDENTIALS_FILE, read once at boot with every value file it names, frozen behind MappingProxyType. A binding pins its header (call 3), names its hosts in PolicyHost's form (exact, no wildcard), and holds its value in a SecretStr (call 2). An unusable binding is dropped with the rule it broke; neither a value nor an off-rule reference is ever logged. Unset provisions nothing. The setting joins PRODUCTION_ENV, as the credential scrub requires. Loaded at boot; the handler takes the table in a later commit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two content.fetch reason tokens, both terminal with status_code and attempts unset (D6). credential_unknown: no usable binding for the reference. credential_refused: the binding exists, but the header, host, scheme or port is outside it — pre-flight or at the redirect hop. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
D4 steps 1 and 2, both pure and both ahead of the ceiling and the pacer. Step 1, in _request_options: credential_headers' names get the headers guards, folded with headers — a name in both maps (E3) or twice by case (E4) is a duplicate — plus E5's names, the count bound over the union, and E1 (any credential under render="browser"). invalid_request_options. Step 2, _resolve_credentials against the boot table: a reference off fetch-<role> (checked whole, with co-core's validator) or never provisioned is credential_unknown; the wrong header for its binding is credential_refused (call 3); the byte bound over both maps, resolved values counted, is invalid_request_options; a submitted URL outside any binding's scope (https, port 443, the host in every binding) is credential_refused. An off-rule reference is never quoted. The resolved (reference, binding) pairs ride the command scope to the transport; FetchContent never holds a value. The worker passes the boot table to the fetch handler; unset provisions nothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
D3. CommandScopeTransport, outermost, checks every hop against every credential in the command's scope before anything below it runs: https only, port 443 only (call 4), the host — raw_host, canonical — in every binding's hosts. A hop out of scope raises credential_refused and is never sent; out of scope and in a refused range is credential_refused, with no DNS lookup (call 5). A hop in scope carries each credential on the copy it sends; the request httpx holds is never mutated, so a later hop starts without it. This is the only get_secret_value() call site. A Cookie credential is followed by the command's jar cookies in the same field. A forced mid-fetch failure's logged traceback, and the facts, carry no value; both mutations (a leaking error message, an in-place header) fail the tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The charter's §2c, mirroring §2b's alias scan with one deliberate difference: a refusal's detail names the reference, so the issuer knows which binding to provision. So the legal uses of a reference bound by the credential_headers .items() loop are a lookup, the validator, Resolved, or a placeholder in a PermanentFetchError message; a compare, a store or a path built from one fails. The map's values are reachable no other way, the field is read in handler.py alone, and get_secret_value() has one call site: the scope transport. Planted-violation tests for each detector; mutations of the real handler (a startswith on a reference, a second secret read) fail it. The charter gains the credential-reference paragraph, the taxonomy rows, and both enforcement rows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…h path - issuer reference: a credential_headers section (what a reference is, what a binding pins, per-hop scope, the refusal table and tokens, the per-command cookie lifetime), the bounds row pointing at headers.py, and the version-history line; - outcome reference: the two tokens, and their taxonomy rows; - issuer contract: the rule in brief, linking the section; - ENVIRONMENT: REPLICATOR_FETCH_CREDENTIALS_FILE, its format, rules, file posture, boot lines, and rotation-is-a-restart; - ARCHITECTURE, STREAMS: the command scope outside the guard; - seed_fetch.py --credential-header, with COMMANDS.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two seeded commands through the real driver and the scope transport: one redirected within the binding's host stores a blob with the credential on both hops; one redirected off it closes credential_refused, the off-scope host never contacted. No scratch stream, the DLQ included, carries the value. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ty flags Iterator on a @contextmanager as deprecated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A dropped binding logged its value_file whenever it was a string, and an invalid host was quoted twice (the detail and PolicyHost's message). A value pasted into either field reached the journal. value_file is logged only when it is an absolute path; a bad host is named by position. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Path.read_bytes() had no bound, so a value_file at /dev/zero (or a huge file) held the boot forever — a loader that promises to fail closed never returned. It now reads the header bound plus two bytes, and the length check runs before the charset so a truncated read is named for its length. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
It had split the alias table's comment from the call it describes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ENVIRONMENT, STREAMS, the issuer contract and the charter are back under 10,000 tokens; each now states what it owns and links the issuer reference for the rules. The outcome reference stays 75 over: it had 15 tokens of headroom before #216, and its two tokens' one row can't fit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Either branch closed it credential_unknown, so it didn't prove the reference is checked whole. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
Author
|
CR round 1, applied under a blanket
Gate after the fixes: 2227 passed, 2 skipped; |
Exact counts (count_tokens), before -> after: docs/DEPLOYMENT.md 10222 -> 9116 docs/contracts/content-fetch-outcome-reference.md 10072 -> 9935 docs/TESTING.md 10025 -> 9984 docs/INFRASTRUCTURE.md 10011 -> 9981 docs/DEPENDENCIES.md (destination) 4097 -> 5193 Relocated (class B, moved verbatim): - DEPLOYMENT.md "### Dependabot proposes the action and Python bumps (#76, #169)" -> DEPENDENCIES.md "## Dependabot proposes the action and Python bumps": the heading lost its provenance per the #162 seams note (both issues stay in the body); its two links re-aimed (DEPLOYMENT.md#main-takes-pull-requests-208, and #the-build-backends-bound-and-cis-uv same-doc). Pointers repointed: .github/dependabot.yml (2), tests/ci/test_dependabot.py, .skills/doc-sections, .skills/doc-sensitive-paths; DEPENDENCIES.md's scope line names the section. Tightened (class C, every atom kept, claims_dropped 0): - outcome reference, "How the blob TTL clock runs": the window's history ("used to be" a host setting) and the operator-side pairing detail INFRASTRUCTURE.md's lifecycle table carries; - TESTING.md: "Both divergences were found by running against the real server", and "The grant's full shape is broker#2's to state" (broker#2 stays on the line); - INFRASTRUCTURE.md: "It reached 97% on 2026-10-22", "not as a courtesy", and the grants subsection's narrative lead-in. Deleted: nothing. No FALSE facts; links, anchors, orphans, unindexed all empty. Seams: 0 after judging 8 — the #216 heading `credential_headers ... (#216)` renamed (its two anchors updated), six standing provenance headings and one legitimate AGENTS.md back-reference acknowledged in .skills/context-seams-ok. Warrants: .skills/context-loss-ok (3 + 11 + 2 + 4), .skills/context-claims-ok (2). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The tightening said the reap rule was 'on REPLICATOR_BLOB_TTL_SECONDS's horizon', contradicting the next paragraph (nothing keeps the two in step). The rule is daysSinceCustomTime: 8 against the horizon published from the setting. Restores what the boot line shows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Dependabot move left the deploy question without a pointer from the doc an operator reads for it; a row in its when-to-do-what table. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
Author
|
Context curation of the four docs over the 10,000-token budget (
Nothing deleted. No-loss check passes on all four (warrants in CR round 2, applied under
Gate: 2227 passed, 2 skipped; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #216
Builds the approved design (2026-11-23-216-fetch-credential-references-design.md, #230). Replicator now resolves
ContentFetchCommand.credential_headers(co-core 0.51.1, cannobserv#577): a header name mapped to afetch-<role>reference, resolved from a host table, scoped per hop, and never echoed.This PR owes a deploy. With nothing provisioned, the only behaviour change is cookie lifetime (call 1A). Provisioning is the operator's; the commands are on #216.
Commits, in the design's order
fix: a cookie jar per command, not per workerCommandScopeTransport, outermost, reads the command's scope from aContextVarset around_fetch. A hop with no scope is refused. The client jar never stores; cookies live for one redirect chain. Each hop is sent on a copy of the requestrefactor: the request-header rules move to src/worker/headers.pyfeat: the fetch credential tablesrc/worker/credentials.py,REPLICATOR_FETCH_CREDENTIALS_FILE,PRODUCTION_ENV; values inSecretStr, read at bootfeat: credential_unknown and credential_refusedfeat: guard the credential headers and resolve themfeat: scope each credential per hopget_secret_value()calltest: the reference is a key, the value is the transport'sdocs: …seed_fetch.py --credential-headertest: a credentialed frame per hop against a live broker-m integration, end to endGeneratorannotation (ty); the reflection limit in the issuer referenceWhere the build departs from the doc
httppackage, which caughthttp.cookiejar(the never-storing jar's policy). It now nameshttp.server, with planted tests for both halves, and the charter row says so.(reference, binding)pairs (Resolved), so a hop refusal can name the reference without the binding carrying its own key (the alias table's CR managing-skills: the auto-refresh hook is half-installed — vendored skills frozen since 2026-08-05 #39).validate_fetch_credential, notFETCH_CREDENTIAL_RE. The exported pattern ends in$, and the handler's own anchor test (\Zonly) refused it there. The validator usesfullmatch, so the result is the same.detailnames the reference, so "never formatted" can't carry over. The scan allows a reference only as a lookup, validator orResolvedargument, or as a placeholder in aPermanentFetchErrormessage. A comparison, a store or a path built from a reference fails the scan.PolicyHostadmits*.x.com, but a binding matches hosts exactly, so a wildcard would silently match nothing.Gates (worktree, base
c2b9dd5)-m integration(scratch redis-server 7.0.15)-m browser(delegated scope)-m gcstests/citests/deploy+test_deploy.pyhandler.py:169(the_CEILING_FROM_SETTINGSsentinel); nothing newstartswithon a reference, a secondget_secret_value: each fails its testVerification skipped
content.fetch: this identity can'tXADDthere (broker#14). The scratch end-to-end run on the released code follows the deploy (design § Host steps).🤖 Generated with Claude Code