diff --git a/docs/rollouts/2026-09-24-ingest-token-scoping.md b/docs/rollouts/2026-09-24-ingest-token-scoping.md index 408576fe..b35637a4 100644 --- a/docs/rollouts/2026-09-24-ingest-token-scoping.md +++ b/docs/rollouts/2026-09-24-ingest-token-scoping.md @@ -40,7 +40,7 @@ Live producers are the `sourceApp` values the production database received in th | `minimax-code` | Quota collector's MiniMax batch (and on-demand `minimax-usage-collector.mjs`) | `MINIMAX_INGEST_TOKEN` in `~/.secrets/global-api-keys` | Shared | | `deepseek-dsh` | On-demand `deepseek-usage-collector.mjs` | `DEEPSEEK_INGEST_TOKEN` in `~/.secrets/global-api-keys` | Shared | | `antigravity-cli` | `com.jays.antigravity-usage-collector` | `ANTIGRAVITY_INGEST_TOKEN` in `~/.secrets/global-api-keys` | Already scoped | -| `antigravity-statusline` | `com.jays.antigravity-session-collector` | `ANTIGRAVITY_STATUSLINE_INGEST_TOKEN` in `~/.secrets/global-api-keys` (the plist also pins it under the older `ANTIGRAVITY_INGEST_TOKEN` name, which pre-change code reads) | Scoped by board row `078333b0` | +| `antigravity-statusline` | `com.jays.antigravity-session-collector` | `ANTIGRAVITY_STATUSLINE_INGEST_TOKEN` in `~/.secrets/global-api-keys` (the live plist still pins the same value under the older `ANTIGRAVITY_INGEST_TOKEN` name, which current code never reads — the plist entry must be renamed to `ANTIGRAVITY_STATUSLINE_INGEST_TOKEN` before `USAGE_INGEST_REQUIRE_SCOPED_TOKENS=true` is set, or this collector silently loses its token; UM-1508) | Scoped by board row `078333b0` | | `mac-host` | `com.jays.mac-server-watchdog` heartbeat | `MAC_HEARTBEAT_INGEST_TOKEN` in `~/.secrets/global-api-keys` | Shared | | `codecaps` | CodeCaps menu bar app (Mac) | macOS Keychain, entered in the app's settings | Shared (owner must paste) | | `botfleet` | BotFleet harness on the Mac | `~/.botfleet/config.json` `usage.ingestToken` and BotFleet Infisical `USAGE_MONITOR_INGEST_TOKEN` | Shared | @@ -77,6 +77,6 @@ Not done, so `USAGE_INGEST_REQUIRE_SCOPED_TOKENS` stays unset (off): - The Mac LaunchAgents run scripts from `~/Code/Usage-Monitor`, which still has pre-#1533 code. The quota collector and heartbeat watchdog only pick up their scoped names once that checkout reaches `main`. - Running Claude Code sessions keep the old metrics header until they restart; their OTLP exports get `401` until then. -To finish: after the items above, set `USAGE_INGEST_REQUIRE_SCOPED_TOKENS=true` in Usage Monitor Infisical, restart the container, and prove that an unscoped token gets `401` while each producer keeps landing. +To finish: after the items above, rename the `ANTIGRAVITY_INGEST_TOKEN` entry in the live `com.jays.antigravity-session-collector` plist on the Mac to `ANTIGRAVITY_STATUSLINE_INGEST_TOKEN` (the only plist-pinned name the collector reads; UM-1508), then set `USAGE_INGEST_REQUIRE_SCOPED_TOKENS=true` in Usage Monitor Infisical, restart the container, and prove that an unscoped token gets `401` while each producer keeps landing. Side effects of verification: two synthetic production rows were written by probes and left in place for the owner to decide on. One is a heartbeat row `342d8fbe-c18a-4730-ae93-5127d8f3c73e` (superseded by the next real heartbeat). The other is a `scope-probe-other` / `scope-probe` usage row `6785e638-c611-4586-9881-a36418413d1c` (quantity 1, no cost). diff --git a/scripts/__tests__/fleet-usage-collector-tokens.test.mjs b/scripts/__tests__/fleet-usage-collector-tokens.test.mjs index d3d7bc2e..6f2a4007 100644 --- a/scripts/__tests__/fleet-usage-collector-tokens.test.mjs +++ b/scripts/__tests__/fleet-usage-collector-tokens.test.mjs @@ -1,3 +1,5 @@ +import { readFileSync } from "node:fs"; + import { describe, expect, it } from "vitest"; import { STATUSLINE_TOKEN_ENV_NAMES } from "../antigravity-session-collector.mjs"; @@ -41,6 +43,14 @@ describe("fleet collector scoped tokens", () => { expect(new Set(first).size).toBe(producers.length); }); + it("pins the status-line token in the checked-in plist template under the name the collector reads", () => { + const plist = readFileSync(new URL("../com.jays.antigravity-session-collector.plist.example", import.meta.url), "utf8"); + expect(plist).toContain("ANTIGRAVITY_STATUSLINE_INGEST_TOKEN"); + expect(plist).not.toContain("ANTIGRAVITY_INGEST_TOKEN"); + expect(plist).not.toContain("REPLACE_WITH_SCOPED_STATUSLINE_TOKEN"); + expect(plist).toContain(""); + }); + it("never offers the antigravity-cli token to the status-line collector", () => { expect(STATUSLINE_TOKEN_ENV_NAMES).toEqual(["ANTIGRAVITY_STATUSLINE_INGEST_TOKEN", "USAGE_INGEST_TOKEN"]); expect(fleetTokenEnvNames("antigravity-statusline")).not.toContain("ANTIGRAVITY_INGEST_TOKEN"); diff --git a/scripts/com.jays.antigravity-session-collector.plist.example b/scripts/com.jays.antigravity-session-collector.plist.example index 94809117..2ed0213c 100644 --- a/scripts/com.jays.antigravity-session-collector.plist.example +++ b/scripts/com.jays.antigravity-session-collector.plist.example @@ -9,6 +9,11 @@ /opt/homebrew/bin/node /ABSOLUTE/PATH/TO/Usage-Monitor/scripts/antigravity-session-collector.mjs + EnvironmentVariables + + ANTIGRAVITY_STATUSLINE_INGEST_TOKEN + + RunAtLoad StartInterval diff --git a/scripts/vitest.collectors.config.mjs b/scripts/vitest.collectors.config.mjs index 30e79067..c0483c72 100644 --- a/scripts/vitest.collectors.config.mjs +++ b/scripts/vitest.collectors.config.mjs @@ -6,6 +6,7 @@ const config = { "scripts/__tests__/muse-code-usage-collector.test.mjs", "scripts/__tests__/resolve-collector-token.test.mjs", "scripts/__tests__/transfer-muse-code-access-token-to-infisical.test.mjs", + "scripts/__tests__/fleet-usage-collector-tokens.test.mjs", ], }, };