Repository navigation
Description
From the CannObserv/cannobserv#594 burn-down coordinator, relayed with the operator's consent. Source: https://github.com/CannObserv/cannobserv/issues/577#issuecomment-7068700156. Released in cannobserv v0.51.1 (2026-11-22, tag facdaebf).
cannobserv v0.51.1 (PATCH) adds fetch credential references to content.fetch (CannObserv/cannobserv#577). You go first; Watcher won't send one until you announce support.
What's on the wire.
ContentFetchCommand.credential_headers: dict[str, str] | Nonemaps a header name to a reference namedfetch-<role>, for example{"X-Api-Key": "fetch-wa-leg-api"}.- The value is never on the frame; you resolve it from host state.
- The map is disjoint from
headers(the issuer's Emit refuses an overlap).Noneand{}both mean no credential. - The canonical class decodes any map, so a malformed one reaches you to close.
What you owe (please carry these into docs/contracts/content-fetch-issuer-reference.md):
-
C1. Resolve on the host, and never echo the value. Keep it out of logs, facts,
detailand crash dumps;detailnames the header and the reference. YourAliasTableshape fits: a table frozen at boot, with a binding that points at host state (a file path), not key material. -
C2. Scope the value per hop: only to hosts the binding names, only over
https, on every hop including the first. Don't put the resolved value inFetchContent.headers. Measured on httpx 0.28.1 (AsyncFetchDriver,follow_redirects=True):X-Api-Keyis carried to a cross-origin redirect target.Authorizationsurvives an http→https upgrade.Cookieis dropped on every hop, same-origin included.
A transport beside
egress.py's destination guard sees every hop. It can attach the credential where the hop is in scope, which also restores a dropped cookie. The design recommends that a binding list exact hostnames inPolicyHost's canonical form. -
C3. Refuse, don't strip. A URL or redirect hop outside the binding's hosts, or not
https, closes the command before that hop is sent. -
C4. Guard the union. Your request-option guards (hop-by-hop,
Host/Content-Length, CRLF, count and size) cover the names in both maps, and the size bound covers the resolved values. A failure isinvalid_request_options, as today.
Two new FetchFailedEvent.reason tokens. Both are yours, since the vocabulary is producer-owned. cannobserv documents them in its registry; please add them to content-fetch-outcome-reference.md. Both are terminal=True, with status_code and attempts unset:
credential_unknown: no usable binding on this host for the reference. That covers one never provisioned, one dropped at load, or one off the rule.credential_refused: the binding exists, but the URL or a redirect hop is out of scope (C3). This isdestination_refused's shape.
Adoption. Your pin is co-core>=0.50.0,<0.51, so this crosses the 0.51.0 MINOR. CREDENTIALS_ALIAS_PATTERN keeps its exact text, so your ALIAS_NAME_PATTERN pin still holds. FETCH_CREDENTIAL_PATTERN and validate_fetch_credential are available for a credential table's load-time check.
Please announce support on CannObserv/cannobserv#577 and in your contract doc once a deployed worker resolves references. Watcher waits for that announcement, as it did for render (#63). Until then, a credentialed frame on an older worker is fetched without its credential, silently. That leaks nothing, but it has no effect.
Activity
gregoryfoster commentedon Nov 23, 2026
Pre-flight brief (coordinator, epic #154, 2026-11-23)
This is the next child. Watcher waits on our announcement before it sends a single
credential_headersframe, and Archiver#376 waits behind Watcher. The issue body is the upstream ask; this comment is the brief. Measured againstorigin/mainatc08b818(live, deployed 2026-11-22 21:32Z) unless marked.It's a contract change, so a design doc comes first:
docs/plans/2026-11-2X-216-fetch-credential-references-design.md, committed as#216 docs: add design doc for fetch credential references. Pause for the operator's approval before building. Upstream's design is cannobservdocs/plans/2026-11-21-577-fetch-credential-references-design.md(approved 2026-11-21; read it withGH_TOKEN_CANNOBSERV). Its §2 D3 and D4 are what we owe. Its §7 says it did not read our contract docs, so check its claims about them.Step 0: the co-core pin move rides here, as its own PR
The operator's 2026-11-22 order had the pin move as a separate child before this one. Folding it in as #216's first PR is my call: the move is additive over our closure, and it's the first thing #216 needs.
co-core,co-core-aio,co-core-syncto>=0.51.1,<0.52. Lock withbash scripts/co-pypi.sh uv lock. The index's newest is 0.51.1 for all three [measured 2026-11-23, probed unbounded].scripts/co_core_closure_diff.py, rootssrcandscripts) [measured]. 58 files each side, 8 not identical:version-only: the three__init__.py.docstrings-only:pure/extract/__init__.py.pure/models/changes.py: additive.ContentFetchCommand.credential_headers: dict[str, str] | None = None, the Emit's E1–E5 refusals,hide_input_in_errorson the Emit, and two registry docstring entries.pure/util/aliases.py: additive.CREDENTIALS_ALIAS_PATTERNkeeps its text, soALIAS_NAME_PATTERN's pin (src/worker/aliases.py:74) still holds.pure/extract/errors.py,extraction_defaults.py:include_description(#559). Nothing insrc/orscripts/calls intoco_core.pure.extract[traced, grep], so the new required keyword can't bite.co-core-aioandco-core-syncnow requireco-core>=0.51.1,<0.52.extra="ignore". It may deploy before the design is approved. A runtime dependency moved, so deploy it (docs/DEPLOYMENT.md'srelease_setdiff will show the three co-core packages).What the design has to decide
These are recommendations, not decisions; the operator approves the doc.
AliasTable's shape (src/worker/aliases.py:85-136):REPLICATOR_FETCH_CREDENTIALS_FILEnames a JSON table, unset means nothing is provisioned, it's read once at boot, frozen behindMappingProxyType, and a bad entry is dropped and logged, never raised. An entry isfetch-<role>→{"hosts": [...], "value_file": "/etc/replicator/..."}.hostsare exact names in co-core'sPolicyHostform (changes.py_canonical_host: lower case, no trailing dot, punycode); reuse the function, don't copy it.value_fileis a path, never the value, and_why_unusable's absolute-path rule applies. Load names withvalidate_fetch_credential. Decide whether the value is read at boot (rotation needs a restart) or at use.reprandstrnever show it (pydantic'sSecretStror a slots class), so a traceback, alogger.exceptionor a crash dump can't print it (C1).httpx.AsyncClientserves every command (src/worker/main.py:87-129,GuardedTransport(BodyCeilingTransport(...))). The per-command credential therefore has to reach the transport some other way than a constructor: aContextVarset aroundfetcher.executeholds for every hop, since httpx follows redirects in the same task. co-core'sAsyncFetchDriverbuilds the request itself, so request extensions aren't ours to set. Decide where the credential transport sits relative to the destination guard, and which refusal wins on a hop that is both out of scope and in a refused range.render="browser"with credentials. The canonical class decodes it (E1 is Emit-only). I recommendinvalid_request_options, extending the existing "no header butuser-agentunderbrowser" rule (src/worker/handler.py:107-110,:542). It's the C4 union applied to the browser.CREDENTIAL_UNKNOWNandCREDENTIAL_REFUSEDtoFailureReason(src/core/errors.py:63). Both are terminal, withstatus_codeandattemptsunset, anddetailnames the header and the reference only.replicator-boundaries.md's three tests on the capability. Then mirrortests/test_boundaries.py§2b (:680-800, "the alias is a key, never a value") forcredential_headers: the reference is a lookup key, and no payload field feeds a credential-shaped parameter. Change the charter and its tests together.Hazards [measured 2026-11-23, httpx 0.28.1,
httpx.MockTransport]request.headersin place._build_redirect_requestcopies the previous request's headers (Headers(request.headers)) into the next hop. A transport that setsX-Api-Keyon the request it was handed sent it to a cross-origin redirect target in the probe:https://other.example/landreceived it. Hand the inner transport a copy, and test a cross-origin redirect with an in-scope first hop.Set-Cookiefrom one request was sent on a later, separate request to the same host. Today that means one command's fetch can change another's response, and the jar grows for the worker's whole life. With credentials, a session minted by a credentialed fetch would be replayed on later commands that carry no credential, outside C2's scope. The design must close this, for example with a jar that never stores. That also changes today's anonymous behaviour, so it's its own commit with its own test, and the doc says so. If you find something relies on today's jar, stop and say so on this issue.MAX_REQUEST_HEADERSandMAX_REQUEST_HEADER_BYTES(handler.py:128-129) apply to both maps, with the bytes measured over the resolved values.MAX_HEADER_VALUE_LENGTHis about response headers and doesn't apply. A value that fails the bound isinvalid_request_options, and itsdetailmust not quote it./etc/replicator(groupreplicatorsince Run replicator.service as a dedicated user, not exedev (#151 follow-up) #202), and the operator does it. Write the exact commands on this issue. A deploy with nothing provisioned is the safe state: every credentialed frame closescredential_unknown.Docs
docs/contracts/content-fetch-issuer-reference.md: C1–C4 under "Request options" (:30), and the announcement line once a deployed worker resolves references.docs/contracts/content-fetch-outcome-reference.md: the two tokens.docs/ENVIRONMENT.md: the new variable, next toREPLICATOR_REPLICATION_ALIASES_FILE(:69). Alsodocs/STREAMS.mdanddocs/ARCHITECTURE.mdwhere the fetch path is described.How it ships (pr mode, since #208)
Refs #216, merged on GitHub with a merge commit: the pin move, the design doc, then the build. Every code PR here owes a deploy.Done when
c08b818, plus the new tests), ruff is clean, and CI is green by job on the final SHA and onmain.httpshost carries the header on every hop. An out-of-scope redirect closescredential_refusedbefore that hop goes out. An unknown reference closescredential_unknown. No value appears in the journal (journalctl -u replicator.servicegrep for the test value: 0 hits).gregoryfoster commentedon Nov 23, 2026
Pickup: the brief checked against
origin/mainc08b818(2026-11-23)Most of the brief holds. Below: what I verified, the corrections, and what the brief leaves out. The design doc takes these as inputs.
Verified as briefed
<1].co_core_closure_diff.py 0.50.0 0.51.1reports 58/58 files with 8 not identical, matching the brief file for file. Per-step diffs place the changes:changes.pyandaliases.pyare 0.51.1's,extract/*is 0.51.0's (#559).CREDENTIALS_ALIAS_PATTERN == ALIAS_NAME_PATTERN[measured]. Nothing insrc/,scripts/ortests/calls intoco_core.pure.extract[grep]. The closure is the same withtests/as a root. → #216 chore: move co-core 0.50 → 0.51 (0.51.1) #229 is open, CI is green on all four jobs, and it's waiting for the operator's merge.aliases.py:85-136,main.py:87-129,handler.py:107-112/128-129/542,errors.py:63,content-fetch-issuer-reference.md:30andENVIRONMENT.md:69all hold. §2b oftest_boundaries.pyruns 681-895, not 680-800.MockTransport]:X-Api-Keyon the request it was handed sends it to a cross-origin redirect target.Set-Cookiefrom one command on a later command to the same host.Corrections
Set-Cookieon a 302 is sent back on the next hop of the same fetch [measured:/bouncesetssid=abc, and/landreceives it]. Sites that do a cookie check, or hand out a session on redirect, depend on that, so a never-store jar can make a working fetch loop untilTooManyRedirects, or land on an error page. What fits is a per-command jar: cookies live for one command's redirect chain and are then discarded. That closes the cross-command leak and the replay of a credentialed session while keeping the bounce. I found nothing that relies on the cross-command jar:src/never touches cookies [grep]. Production's corpus can't be measured from here, so the design names that as the residual.ContextVar.AsyncFetchDriver(client=...)per command, over a per-commandhttpx.AsyncClientthat wraps the shared transport (the pool lives inAsyncHTTPTransport, not the client), gives a per-command jar (item 1) and lets the credential reach the transport through a constructor. The design compares the two._canonical_hostis private. The public route isTypeAdapter(PolicyHost)(changes.py:1898). And a hop's host must come fromrequest.url.raw_host, not.host..hostis IDNA-decoded ('bücher.example.'), so it never equals a binding's punycode. Both keep the trailing dot [measured]. So the comparison isPolicyHost(raw_host.decode("ascii"))against the binding's canonical names.{"User-Agent": "fetch-x"}, and today's guards admituser-agentand the validators inheaders, so guarding the union doesn't refuse them. Replicator has to refuseuser-agent,if-none-matchandif-modified-sinceas credential names explicitly (invalid_request_options). E3 (overlap withheaders) and E4 (case duplicates) are caught by folding the union, as the brief says.What the brief leaves out
PolicyHosthas no port, so a host-only binding admitshttpson any port. The design has to decide this.REPLICATOR_FETCH_CREDENTIALS_FILEtripstest_every_credential_setting_is_scrubbed(its name matchescredential). It joinsPRODUCTION_ENVintests/conftest.py. That's expected, not a blocker.replicatorand can read anything group-readable under/etc/replicator, the same as today's writer keys. The renderer sandbox stays on. The value files get the keys' posture.Next: the design doc PR, and then a pause for the operator's approval.
gregoryfoster commentedon Nov 23, 2026
Step 0 shipped. #229 merged as
012512a. Its push CI was green, andscripts/deploy.shdeployed it: live is012512a4493a, andworker readylogged on that build. The release's package diff againstc08b81882bdcis the three co-core packages, 0.50.0 → 0.51.1, and nothing else. The journal since the restart has no warning or error lines. Behaviour is unchanged:credential_headersdecodes and nothing reads it. Next: the design doc (#230), which waits for the operator's approval.#216 docs: mark the fetch credential design accepted
gregoryfoster commentedon Nov 23, 2026
Step 1 done: the operator approved the design (#230) with all five recommendations as written — per-command cookie jar, values read at boot, a binding pins its header, port 443 only,
credential_refusedbeforedestination_refused. Merged as c2b9dd5 (docs only; no deploy — the build's deploy brings live up to main).Next: the build on
216-fetch-credentials, in the commit order the doc lists.gregoryfoster commentedon Nov 23, 2026
Step 2, the build, is up as #231, and it owes a deploy. With nothing provisioned, the only change after deploying is cookie lifetime: cookies now last for one command's redirect chain. The commands below are for you to run after the deploy. Nothing here needs them to land first: an env variable the running code doesn't know is ignored.
Provisioning a fetch credential on co-replicator (operator)
Set the three names first. The example is cannobserv#577's; use the real binding Archiver will reference.
1. The value directory, and one value file per binding.
read -skeeps the value off the command line, out of shell history and off the screen.umask 027makes the file0640from the moment it exists.2. The table. Paths only, never a value.
3. Point the service at it, and restart. Values are read at boot, so rotating a value later is also just a restart.
4. Check it. The boot line names the reference, header, hosts and path. The last grep counts journal lines containing the value; it reads the value from its file, so you never type it. It should print
0.A binding with a broken rule logs
ignoring an unusable fetch credential bindingwith the rule, never the value; fix it and restart. Unset, or no file at that path, logsno fetch credential table on this host — fetch credentials are not provisioned.5. The optional live frame (design § Host steps) is yours, under Watcher's identity:
seed_fetch.py --production --credential-header "$HEADER: $REF" --info-source-id <real id> <https://$HOST/...>. Then repeat thegrep -cin step 4.#216 fix: CR 1 — never quote a pasted value from value_file or hosts
#216 fix: CR 2 — bound the value-file read
#216 refactor: CR 3 — load the credential table above the alias block
#216 docs: CR 4 — tighten the credential additions to each doc's budget
#216 test: CR 5 — the trailing-newline test asserts the off-rule branch
#216 test: CR 6 — pass the root to _secret_reads, not a swapped global
#216 docs: curate the four docs over the 10,000-token budget
#216 chore: curation telemetry for the four over-budget docs
#216 docs: CR 7 — the lifecycle rule isn't on the TTL setting
#216 docs: CR 8 — DEPLOYMENT points at whether a bot PR owes a deploy
#216 docs: CR 9 — rewrap DEPENDENCIES.md's scope paragraph
#216 chore: amend the curation rows for CR 7 and CR 8's late fixes
gregoryfoster commentedon Nov 23, 2026
Step 3 shipped: #231 merged as 6718cc9 (merge commit, push CI green on all 4 jobs) and deployed. Live moved
012512a4493a→6718cc94bade, andworker readylogged on it. The release's package set is identical, so only Replicator's own code changed. The boot logsno fetch credential table on this host — fetch credentials are not provisionedat INFO, with no warnings or errors.With nothing provisioned, the only live change is cookie lifetime: cookies now last for one command's redirect chain. Provisioning is yours, using the commands above.
Next: the scratch end-to-end run on the released code (design § Host steps), then the cannobserv#577 announcement draft here.
gregoryfoster commentedon Nov 23, 2026
Scratch end-to-end run on the released code: passed
The design's verification step (§ Host steps). The released code (
/srv/replicator/live,6718cc94bade) ran as a scratch worker against a scratchredis-server, with a clean environment (env -i). The binding was a scratch one:fetch-e2e→X-Api-Key,hosts: ["httpbin.org"], with a dummy, non-secret value. Commands were seeded with the release's ownseed_fetch.py --credential-header … --watch./redirect-to→/headers)blob_available. The echoed second hop carriesX-Api-Key, so the transport re-attached it on a hop httpx built from the original requestexample.comcredential_refused, terminal:https://example.com/ is outside x-api-key (fetch-e2e)'s scope: example.com is not one of httpbin.org. Refused before the hop was sentfetch-nopecredential_unknown:… names fetch-nope, which this host has not provisionedReferer: fetch-e2e(not the binding's header)credential_refused:… bound to the 'x-api-key' header onlyhttp://first hopcredential_refused:… is http, not https/headers(control)blob_available, noX-Api-Key/cookies/set?e2e=1), then a second command to/cookies{"e2e": "1"}(kept across the redirect chain), second{}(not carried to the next command)Where the value appears: 0 times in the worker's log,
content.blobs,content.fetchand the DLQ. It is in one stored blob, case A's, because httpbin echoes request headers. That is the reflection limit the issuer reference names, and the reason a binding should name only trusted hosts. The worker logged no errors. Its five warnings were the four refusals' dead-letter lines and the scratch blob directory's traversability notice. The scratch worker, keys, Redis and files are removed.Live production since the deploy: Watcher's first command on
6718cc94badestored a blob, with nothing refused and no warnings.DRAFT, not posted: support announcement for cannobserv#577
For the cohort's issuers (Watcher, Archiver) and the #594 coordinator. Not posted. It waits for the operator's consent. #577 is closed, so it goes on as a comment there. watcher#457 also waits on this announcement.
gregoryfoster commentedon Nov 23, 2026
Done. Support is announced on cannobserv#577: https://github.com/CannObserv/cannobserv/issues/577#issuecomment-7112900946 (posted with the operator's consent). That unblocks CannObserv/watcher#457.
012512a4493a6718cc94badeStill the operator's: provisioning a real binding, with the commands in this comment. Until then every credentialed command closes
credential_unknown.Verification debt:
content.fetch(this identity can'tXADDthere, broker#14). It comes when Watcher sends the first one against a provisioned binding;Notes for later issues:
FETCH_CREDENTIAL_PATTERNends in$, sore.matchor a JSON-schemapatternaccepts"fetch-x\n". Archiver's save-time check (Fetch headers: per-host (Domain) and per-source policy, carried to content.fetch archiver#376) should callvalidate_fetch_credential, which usesfullmatch.(#138), INFRASTRUCTURE(#148)) are still acknowledged rather than renamed.gregoryfoster commentedon Nov 23, 2026
The cannobserv note from the closing comment is now filed: CannObserv/cannobserv#763 (all three exported
*_PATTERNconstants end in$; measured to accept a trailing newline underre.match,re.searchand jsonschema 4.26.0, while co-core's functions and pydantic'spattern=refuse it).Same shape here, measured:
src/worker/aliases.py:298checks alias names with_ALIAS_NAME.match, which acceptsgcs-x\n. It isn't reachable in practice: the name rule then requires the bucket to be exactlyco-gcs-x\n, so it needs an operator to write a newline into both fields of the host table. Bus commands can't reach it. It's worth afullmatchwhen cannobserv#763 settles the pattern text, since the pin attests/worker/test_aliases.py:409moves with it.