diff --git a/docs/2-handbook/external-accounts/github.md b/docs/2-handbook/external-accounts/github.md index 4a9d39475..63c8d1dbd 100644 --- a/docs/2-handbook/external-accounts/github.md +++ b/docs/2-handbook/external-accounts/github.md @@ -32,7 +32,7 @@ or the token fetch. swarm-wide switch is the intended control.) github.com only. The token **value** never touches nix — the agent writes it -to `/github-token` at runtime (see [Provisioning](#provisioning)). +to a file under `/run` at runtime (see [Provisioning](#provisioning)). ## Provisioning @@ -44,13 +44,19 @@ no hive writes it. One token per agent: swarm-controller refuses to link another until you delete the stored one, and no route hands it back. The agent's `hive-agent-github-token` unit reads that path under the -agent's own store certificate and writes `/github-token` (`0600`, -owned by the agent), on boot and every two minutes, replacing the file only -when the token changed. It needs a store identity +agent's own store certificate and writes `/run/hive-agent-github-token/token` +(`0400`, owned by the agent), on every start and every two minutes, replacing +the file only when the token changed. It needs a store identity (`services.hyperhive.agent.bao.addr`); an agent without one gets no token. -The unit never deletes the file: a `github-token` already in place stays -when the store holds none or doesn't answer. Where the token lives and who -reads it: [credentials-reference.md](../../4-implementation/swarm/credentials-reference.md). + +`/run` starts empty on every start, so the unit fetches the token anew each +time: an agent whose token you removed from the store has none after its next +start. When the +store doesn't answer at start, the agent boots and runs without a GitHub +token (`gh` and `git push` run unauthenticated, the unit logs one warning), +and the unit asks again until the store answers. Nothing reads the +`/github-token` file an earlier version kept, and nothing deletes it; +it stays on disk, unused. Where the token lives and who reads it: [credentials-reference.md](../../4-implementation/swarm/credentials-reference.md). ## Security diff --git a/docs/4-implementation/agent-tools/github.md b/docs/4-implementation/agent-tools/github.md index 022e8cfb7..0a70c1c7f 100644 --- a/docs/4-implementation/agent-tools/github.md +++ b/docs/4-implementation/agent-tools/github.md @@ -17,9 +17,10 @@ When enabled, the container gets: Host-scoped, so it never touches the forge (`localhost:3000`) or any other remote. -Both scripts read the token from `/github-token` **at invocation -time**, so a PAT written (or rotated) mid-session takes effect immediately -— no container rebuild or restart. Until the file exists, `gh` / `git push` +Both scripts read the token from `/run/hive-agent-github-token/token` +(`services.hyperhive.agent.github.tokenFile`) **at invocation +time**, so a PAT fetched (or rotated) mid-session takes effect immediately +— no container rebuild or restart. They never read the state dir. Until the file exists, `gh` / `git push` fail unauthenticated. The build bakes the token path into the scripts (rather than reading it from an env var), because claude's Bash tool runs in a minimal environment that wouldn't carry one. @@ -42,12 +43,13 @@ rather than merely switched off. it's also why this isn't a cargo feature — a feature would unify across the workspace and cost every crate its build cache. -At runtime the poller needs the PAT above. No PAT, no polling: the unit +At runtime the poller needs the PAT above, at the path in +`HIVE_GITHUB_TOKEN_FILE` (the same `/run` file). No PAT, no polling: the unit logs why and exits 0, which is why it's `Restart = on-failure` and never `always` — a clean exit on a PAT-less agent must not become a restart loop. The poller waits about ten minutes for the PAT to appear before it gives up. A path unit (`hive-github-notify.path`) starts the poller -again when `/github-token` changes, so a PAT that lands later still +again when the token file changes, so a PAT that lands later still enables polling. Once polling, it re-reads the file on every tick, so it picks up a rotated PAT on the next tick without a restart. diff --git a/docs/4-implementation/swarm/credentials-reference.md b/docs/4-implementation/swarm/credentials-reference.md index f061878a7..5e90cdcf0 100644 --- a/docs/4-implementation/swarm/credentials-reference.md +++ b/docs/4-implementation/swarm/credentials-reference.md @@ -33,7 +33,7 @@ the rest of the cell says how. | `swarm/agents//forge-token` | `swarm-controller`, at agent creation and every 5 minutes | the agent | ✅ when missing or no longer matching the forge | ✅ every 10 minutes | | `swarm/agents//forge/