Skip to content

[NO-JIRA] devbox: cf-route-monitor timer for the api.anthropic.com route - #1077

Merged
johnnymo87 merged 2 commits into
mainfrom
cf-route-monitor
Dec 2, 2026
Merged

johnnymo87 merged 2 commits into
mainfrom
cf-route-monitor

Conversation

@johnnymo87

Copy link
Copy Markdown
Owner

Description

  • Adds cf-route-monitor, a devbox-only user timer that runs every 30 s and probes https://api.anthropic.com/cdn-cgi/trace. Each probe appends one line to ~/.local/state/cf-route-monitor/log.jsonl with: TCP connect time (DNS excluded), the Cloudflare site that served it (colo), HTTP status and curl exit code.
  • It probes over IPv4, and over IPv6 only when an IPv6 route to Anthropic exists. Probes always bypass any proxy.
  • It sends a pigeon alert (warning) after 2 failed probes in a row, and an info alert after 10 OKs in a row, with the outage's duration and the sites seen. An undelivered alert is retried; if the alert request times out, the retry waits 5 minutes, because pigeon may still deliver it.
  • Why: on 2026-12-02, devbox's route to api.anthropic.com (served by Cloudflare) repeatedly went dark for 20–70 s while Cloudflare served it from Moscow (DME). Every TeamClaude turn in flight failed. This monitor records future episodes and triggers the manual fallback proxy stopgap.
  • It is detection only: about 2 requests a minute, no credentials. It deploys with the devbox home-manager switch and only adds this timer and its service; no other unit restarts (from comparing the build derivations against main).
  • Tests: checks.cf-route-monitor-tests, 93 hermetic assertions.

References

  • Bead workstation-dkts.2 (parent workstation-dkts)

…(workstation-dkts.2)

Detection only: 30 s user timer probes /cdn-cgi/trace over v4 (v6 when routable),
logs JSONL, alerts via pigeon on 2 consecutive failures and on recovery.
…ty, stale counters, TERM cleanup, --noproxy)

- Alert POST -m 12 (above pigeon's 10 s /alert budget, whose first leg is a
  Cloudflare Worker that stalls in exactly this outage); a curl timeout is
  'outcome unknown' and backs off 5 min instead of re-posting every run.
  TimeoutStartSec 40s (runs cannot overlap).
- severity 'warning' (pigeon accepts info|warning|error only).
- Counters older than 5 min do not carry over a gap (reboot).
- Temp files cleaned on SIGTERM.
- Probes use --noproxy '*' so they always measure the direct route.

Bead workstation-dkts.2.
@johnnymo87
johnnymo87 enabled auto-merge (squash) December 2, 2026 22:47
@johnnymo87
johnnymo87 merged commit 5cd0fa3 into main Dec 2, 2026
2 checks passed
@johnnymo87
johnnymo87 deleted the cf-route-monitor branch December 2, 2026 23:10
johnnymo87 added a commit that referenced this pull request Dec 2, 2026
…1078)

#### Description

- Adds `hosts/gamebox/tc-fallback-proxy.nix`: a tinyproxy on gamebox
that devbox's TeamClaude can use as its `upstreamProxy` while devbox's
own route to Cloudflare-fronted `api.anthropic.com` is broken. On
2026-12-02, devbox's traffic landed on Cloudflare's Moscow site and went
dark in 20–70 s clusters for about two hours.
- Locked down: it serves only devbox's tailnet IP, only CONNECT, only
`api.anthropic.com:443` and `platform.claude.com:443` (URL-mode anchored
filter, default deny). It is reachable only over `tailscale0`, because
the port is not opened on any other interface. TLS runs end to end, so
gamebox never sees tokens or prompts.
- Verified: the generated config was built and run on gamebox. An
identical transient instance carried live TeamClaude traffic: all 5
accounts probed ok, 33 live requests went through, and there were 0
errors. Off-allowlist hosts, plain HTTP and other ports are refused.
- **Deploy note:** this takes effect only at the next gamebox system
switch. main's lock moves gamebox's nixpkgs (0dc498b → 9aa1957), so that
switch is a broad one, and it must avoid a CI job in progress. Before
switching, stop the transient stopgap that holds port 8888: `systemctl
--user stop tc-fallback-proxy` on gamebox. If you forget, the system
unit retries every 5 s until the port is free.

#### References

- Bead workstation-dkts.3 (the stopgap runbook is in its comments)
- #1077 (devbox connect monitor), #1074 (DNS resolver diversity)
johnnymo87 added a commit that referenced this pull request Dec 2, 2026
…timeout, keep-old on switch (#1081)

#### Description

- Bumps the TeamClaude fork to johnnymo87/teamclaude#11, which adds an
optional **automatic egress fallback**. While devbox's direct connect to
api.anthropic.com fails, requests go through gamebox's tinyproxy
(#1078), with one same-account retry. It returns to direct after 15
minutes and 6 clean probes. It is inert until `fallbackProxy` is set in
`~/.config/teamclaude.json`.
- devbox unit:
`NODE_OPTIONS=--network-family-autoselection-attempt-timeout=3000`.
Node's default of 250 ms per address family declared a slow-but-working
route (~540 ms RTT) dead.
- devbox unit: **`X-SwitchMethod = keep-old`**. Without it, the
unattended pull-workstation home-manager switch would restart
TeamClaude, cutting every live agent turn, at whatever hour it ran.
switch-impact on this tree reports `Keeping old units:
teamclaude.service`. The new build and the env var take effect only at
an explicit restart, which will be scheduled at a quiet time and
announced.
- Mac: `home.darwin.nix` uses the same package, so the Mac's next
`home-switch` picks up the new TeamClaude. Its config has no
`fallbackProxy`, so nothing changes in behaviour there.

#### References

- Beads workstation-dkts.4 and .5; #1077 (monitor), #1078 (gamebox
proxy)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant