Repository navigation
fleet gh: four-tier fallback chain with bounded mints (code#16826) - #16833
Merged
Merged
Conversation
Implements code#16826 (gh-daemon resilience programme, 2026-11-29): the token-resolution walk is now T1 local daemon -> T2 laptop daemon -> T3 Cloudflare token endpoint (HTTPS, [gh] cache_cf_url + cache_cf_token_name broker name) -> T4 in-process direct, failing over immediately under the design budget (connect 2s, daemon request 5s, CF request 8s, mint upstream 15s, single-flight wait 10s, broker already bounded at 10s in fleet-secrets). Daemon-side (gh_cache): bounded single-flight wait via Condvar wait_timeout with the cached-failure answer while the mint continues on its own thread; mint/resolution failures cached 30s; client daemon request timeout cut from 60s to 5s. Client-side (gh + gh/chain + gh/cache_serve): unified CacheTier list (https:// entry kind, http:// hard error, list position = chain position), in-walk failure memo, cross-invocation negative-cache stamp file (~/.cache/fleet/gh-tier-failures.json; connect 60s, other classes 30s; tier ids/classes/timestamps only), ALL-DOWN error naming every tier and failure class, cache-status extended with the CF line (UP/DOWN/NOT-CONFIGURED, counts-only, exit 3 only when no tier answered). Config (fleet-config): [gh] cache_cf_url + cache_cf_token_name (name only, never a value), FLEET_GH_CACHE_CF_URL / FLEET_GH_CACHE_CF_TOKEN_NAME env overrides, URL entries pass through gh_cache_addrs unmangled. Docs: design landed at pkgs/fleet/docs/fleet-gh-fallback-chain-design.md with an implementation-status note, agent last-resort runbook at pkgs/fleet/docs/runbook-agent-last-resort.md, cross-linked from fleet-gh-credentials.md. Tests: tier entry parsing, config precedence + CF keys, chain construction order, CF client contract over loopback (bearer asserted server-side), CF body/skew contract, negative-cache TTLs + corrupt file, walk failover dead->live daemon, daemon-error continuation + loud ALL-DOWN, hanging-daemon walk reaching tier 4 within budget, bounded single-flight wait with detached mint landing, daemon failure caching, hanging-daemon client fetch bound, cache-status exit codes.
|
Important Review skippedBot user detected. To trigger a single review, invoke the
|
6 tasks
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.
Part of #16826 — the
pkgs/fleetclient + daemon half of the gh-daemon resilience programme (Drew's order, 2026-11-29). Design:pkgs/fleet/docs/fleet-gh-fallback-chain-design.md(landed in this PR); agent last-resort runbook:pkgs/fleet/docs/runbook-agent-last-resort.md.What changed
The chain (T1→T2→T3→T4, immediate failover, bounded per tier)
gh/chain.rs):--cache-addr/FLEET_GH_CACHE/ config entries parse intoCacheTier::{Tcp, Https}; anhttps://entry is the tier-3 Cloudflare endpoint,http://is a hard parse error, list position is chain position. Config/defaults append[gh] cache_cf_urlas the last tier.FleetTokenProvider::viawalks tiers per rotation candidate: TCP daemon (connect 2s, whole request 5s — was 60s) → CFGET /token(8s, bearer resolved by broker NAME from[gh] cache_cf_token_name, fleet-App candidates pass?owner=) → in-process tier 4. A daemon error answer no longer ends the walk. Tier 3 is consumed once per invocation (later candidates skip it rather than re-runghunder the identical token).~/.cache/fleet/gh-tier-failures.json(tier id + class + timestamp only; connect 60s, timeout/http-status/bad-body 30s; a hit clears the entry; corrupt file = empty cache). ALL-DOWN errors name every tier and its failure class.cache-status: one line per tier incl. the CF line (UP http=200 token_ttl=… latency=…/DOWN http=…/NOT-CONFIGURED); exit 3 only when no tier answered.Daemon side (
gh_cache)wait_timeout): the waiter gets the cached-failure answer while the mint continues on its own thread and populates the cache.RawMinterureq agent goes 60s/10s → 15s total / 5s connect, covering both the daemon mint and tier-4 in-process mint.Config (
fleet-config):[gh] cache_cf_url+cache_cf_token_name(broker NAME only), env overridesFLEET_GH_CACHE_CF_URL/FLEET_GH_CACHE_CF_TOKEN_NAME, blank-field load errors, URL entries pass throughgh_cache_addrsunmangled.Deviations from the patch plan (recorded on #16826)
wait_timeout, not tokio timeouts.BROKER_ATTEMPT_TIMEOUT= 10s); kept per design §5's allowance (design suggested 5s for a new bound).pkgs/fleet/docs/instead ofdoc/agents/: the working checkout is sparse (pkgs/fleet only) and three bounded attempts to expand it todoc/failed on the day's flaky egress.pkgs/fleet/docs/is the fleet docs home offleet-gh-credentials.md, which now cross-links both documents.Tests
New unit tests (oracle-named per house doctrine): tier entry parsing; CF config precedence/blank rules; chain construction order + precedence; CF client contract over loopback (Authorization asserted server-side; 200 HIT, 503 → http-status, hang → timeout within budget); CF body/skew-guard contract; negative-cache TTLs + corrupt stamp; walk failover dead→live daemon; daemon-error continuation + loud ALL-DOWN; hanging-daemon walk reaching tier 4 within the 5s budget; bounded single-flight wait with the mint landing detached; daemon failure caching; hanging-daemon client fetch bound; cache-status exit codes.
Verification evidence (CI / Actions exec results and e2e timings) will be recorded on #16826 as it lands.
{ "direct_parent": null, "links": [], "lineage": { "design": null, "roadmap_item": null, "priority": null }, "pm_meta": 1, "provenance": { "queue_id": null, "scheduled_start": null, "picked_up_at": null, "work_started_at": null, "created_at": "2026-11-29T15:09:30Z", "session_id": null, "lane": null, "host": "htch-runtime", "worktree": null, "model": null, "lane_start_issues": [], "workspace_ref": null, "auth_subject": "archer", "stamped_by": "fleet 0.1.0 (native)" } }Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.