Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/rollouts/2026-09-24-ingest-token-scoping.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down Expand Up @@ -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).
10 changes: 10 additions & 0 deletions scripts/__tests__/fleet-usage-collector-tokens.test.mjs
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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("<key>ANTIGRAVITY_STATUSLINE_INGEST_TOKEN</key>");
expect(plist).not.toContain("<key>ANTIGRAVITY_INGEST_TOKEN</key>");
expect(plist).not.toContain("REPLACE_WITH_SCOPED_STATUSLINE_TOKEN");
expect(plist).toContain("<string></string>");
});
Comment thread
swu-rob[bot] marked this conversation as resolved.
Resolved
Comment thread
swu-rob[bot] marked this conversation as resolved.
Resolved

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");
Expand Down
5 changes: 5 additions & 0 deletions scripts/com.jays.antigravity-session-collector.plist.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
<string>/opt/homebrew/bin/node</string>
<string>/ABSOLUTE/PATH/TO/Usage-Monitor/scripts/antigravity-session-collector.mjs</string>
</array>
<key>EnvironmentVariables</key>
<dict>
<key>ANTIGRAVITY_STATUSLINE_INGEST_TOKEN</key>
<string></string>
</dict>
<key>RunAtLoad</key>
<true/>
<key>StartInterval</key>
Expand Down
1 change: 1 addition & 0 deletions scripts/vitest.collectors.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],
},
};
Expand Down
Loading