diff --git a/.env.example b/.env.example index f51f3f2..ca5be35 100644 --- a/.env.example +++ b/.env.example @@ -22,6 +22,11 @@ EVOSCIENTIST_WORKSPACE_DIR= # when the backend was started manually (no deploy sidecar); otherwise the # sidecar value wins. Defaults to a uuid derived from the workspace root. EVOSCIENTIST_DEPLOYMENT_ID= +# Usage-attribution deployment id, matching the backend's +# EVOSCIENTIST_USAGE_DEPLOYMENT_ID (stored in /deployment-id). This is +# intentionally separate from the scope deployment id above so the usage +# identity cannot repartition workspace scopes. +EVOSCIENTIST_USAGE_DEPLOYMENT_ID= # Optional for local processes running as the same OS user: both sides share # ~/.config/evoscientist/provider-admin-token automatically. Set this explicitly # when the WebUI and backend run on different hosts, users, or containers. diff --git a/src/app/api/usage/routes.test.ts b/src/app/api/usage/routes.test.ts index 860fdfd..28797fc 100644 --- a/src/app/api/usage/routes.test.ts +++ b/src/app/api/usage/routes.test.ts @@ -8,7 +8,7 @@ vi.mock("server-only", () => ({})); const dataDir = fs.mkdtempSync(path.join(os.tmpdir(), "evosci-usage-routes-")); process.env.EVOSCIENTIST_DATA_DIR = dataDir; process.env.EVOSCIENTIST_USAGE_SINK_TOKEN = "route-test-token"; -process.env.EVOSCIENTIST_DEPLOYMENT_ID = "11111111-1111-4111-8111-111111111111"; +process.env.EVOSCIENTIST_USAGE_DEPLOYMENT_ID = "11111111-1111-4111-8111-111111111111"; process.env.EVOSCIENTIST_WORKSPACE_ID = "ws1_fixture"; const capabilities = await import("./capabilities/route"); diff --git a/src/lib/server/usageStore.test.ts b/src/lib/server/usageStore.test.ts index eb92ede..388da1e 100644 --- a/src/lib/server/usageStore.test.ts +++ b/src/lib/server/usageStore.test.ts @@ -8,7 +8,7 @@ vi.mock("server-only", () => ({})); const dataDir = fs.mkdtempSync(path.join(os.tmpdir(), "evosci-usage-store-")); process.env.EVOSCIENTIST_DATA_DIR = dataDir; -process.env.EVOSCIENTIST_DEPLOYMENT_ID = "11111111-1111-4111-8111-111111111111"; +process.env.EVOSCIENTIST_USAGE_DEPLOYMENT_ID = "11111111-1111-4111-8111-111111111111"; process.env.EVOSCIENTIST_WORKSPACE_ID = "ws1_fixture"; const store = await import("./usageStore"); diff --git a/src/lib/server/usageStore.ts b/src/lib/server/usageStore.ts index 84fda0f..308e94d 100644 --- a/src/lib/server/usageStore.ts +++ b/src/lib/server/usageStore.ts @@ -574,7 +574,7 @@ export function usageStatus(filters: URLSearchParams): UsageStatusResult { const db = usageDb(); const statusFilters = new URLSearchParams(); for (const [key, environment] of [ - ["deployment_id", "EVOSCIENTIST_DEPLOYMENT_ID"], + ["deployment_id", "EVOSCIENTIST_USAGE_DEPLOYMENT_ID"], ["workspace_id", "EVOSCIENTIST_WORKSPACE_ID"], ] as const) { const value = filters.get(key) ?? process.env[environment]?.trim();