From c261d65a7f6856d904f2f1484d05ab48de97ecf7 Mon Sep 17 00:00:00 2001 From: Benjamin <5719034+bnjjj@users.noreply.github.com> Date: Thu, 19 Nov 2026 11:19:18 +0100 Subject: [PATCH 1/2] feat(cli): add warehouse inspect capacity --- .../command-surface.integration.test.ts | 25 +- .../src/commands/api/api-command-policy.ts | 1 + .../src/commands/api/api-commands.e2e.test.ts | 67 +-- .../api/api-commands.integration.test.ts | 87 ++++ apps/cli/src/commands/api/generated.md | 20 + .../cli/src/commands/api/generated.schemas.ts | 237 ++++++++++ apps/cli/src/commands/api/generated.ts | 96 ++++ packages/api/scripts/openapi-overrides.json | 427 ++++++++++++++++++ packages/api/src/generated/contracts.ts | 206 +++++++++ packages/api/src/generated/effect-client.ts | 16 + packages/api/src/generated/openapi.json | 418 +++++++++++++++++ packages/api/src/generated/permissions.ts | 1 + 12 files changed, 1560 insertions(+), 41 deletions(-) diff --git a/apps/cli/src/cli/command-surface/command-surface.integration.test.ts b/apps/cli/src/cli/command-surface/command-surface.integration.test.ts index ace075fa52..0fa0dfb89c 100644 --- a/apps/cli/src/cli/command-surface/command-surface.integration.test.ts +++ b/apps/cli/src/cli/command-surface/command-surface.integration.test.ts @@ -58,6 +58,7 @@ describe("command surface", () => { "warehouse disable", "warehouse enable", "warehouse inspect", + "warehouse inspect capacity", "warehouse inspect query-stats", "warehouse status", "warehouse tables", @@ -83,7 +84,7 @@ describe("command surface", () => { ); it.effect( - "mounts workload inspection under Warehouse and preserves standalone inspect commands", + "mounts metrics inspection under Warehouse and preserves standalone inspect commands", () => Effect.gen(function* () { const { commands } = yield* Effect.promise(() => surface); @@ -95,16 +96,18 @@ describe("command surface", () => { expect(enabled[path]).toEqual(commands[path]); } expect(enabled).not.toHaveProperty("inspect warehouse"); - const stats = enabled["warehouse inspect query-stats"]; - expect(stats).toMatchObject({ - stage: { status: "experimental", feature: "warehouse" }, - target: { group: "hosted", consent: "none" }, - api: { operationId: "v2-get-warehouse-query-stats" }, - }); - expect(Object.keys(stats?.flags ?? {})).toEqual( - expect.arrayContaining(["since", "from", "to", "attributes", "interval", "remote"]), - ); - expect(stats?.flags).not.toHaveProperty("wait"); + for (const command of ["capacity", "query-stats"]) { + const entry = enabled[`warehouse inspect ${command}`]; + expect(entry).toMatchObject({ + stage: { status: "experimental", feature: "warehouse" }, + target: { group: "hosted", consent: "none" }, + api: { operationId: `v2-get-warehouse-${command}` }, + }); + expect(Object.keys(entry?.flags ?? {})).toEqual( + expect.arrayContaining(["since", "from", "to", "attributes", "interval", "remote"]), + ); + expect(entry?.flags).not.toHaveProperty("wait"); + } }), ); diff --git a/apps/cli/src/commands/api/api-command-policy.ts b/apps/cli/src/commands/api/api-command-policy.ts index 44421ab146..b1a7925060 100644 --- a/apps/cli/src/commands/api/api-command-policy.ts +++ b/apps/cli/src/commands/api/api-command-policy.ts @@ -25,6 +25,7 @@ export const generatedOperations: ReadonlyArray = [ "v2-get-warehouse-table-layout", "v2-update-warehouse-table-layout", "v2-get-warehouse-query-stats", + "v2-get-warehouse-capacity", ]; export const nouns = { diff --git a/apps/cli/src/commands/api/api-commands.e2e.test.ts b/apps/cli/src/commands/api/api-commands.e2e.test.ts index ad934d25e2..b3b26d860f 100644 --- a/apps/cli/src/commands/api/api-commands.e2e.test.ts +++ b/apps/cli/src/commands/api/api-commands.e2e.test.ts @@ -107,38 +107,45 @@ const runWarehouse = ( return { result, requests, bodies }; }).pipe(Effect.scoped); -it.live("warehouse inspect query-stats reaches the public route through the compiled CLI", () => - Effect.gen(function* () { - const response = json(200, { - data: [ - { - type: "warehouse_metric", - id: "query_rate", - attributes: { - project_ref: REF, - metric: "query_rate", - unit: "per_second", - aggregation: "rate", - definition: "Query invocations per second.", - requested: { metric: "query_rate", start: 1795000000, end: 1795001800 }, - effective: { start: 1795000000, end: 1795001800, step: 60, rate_window_seconds: 300 }, - scrape_interval_seconds: 60, - last_sample_at: null, - availability: "unavailable", - series: [], +it.live.each([ + { command: "query-stats", metric: "query_rate", unit: "per_second", aggregation: "rate" }, + { command: "capacity", metric: "query_in_flight", unit: "queries", aggregation: "sum" }, +] as const)( + "warehouse inspect $command reaches the public route through the compiled CLI", + ({ command, metric, unit, aggregation }) => + Effect.gen(function* () { + const response = json(200, { + data: [ + { + type: "warehouse_metric", + id: metric, + attributes: { + project_ref: REF, + metric, + unit, + aggregation, + definition: "Executor query invocations.", + requested: { metric, start: 1795000000, end: 1795001800 }, + effective: { start: 1795000000, end: 1795001800, step: 60, rate_window_seconds: 300 }, + scrape_interval_seconds: 60, + last_sample_at: null, + availability: "unavailable", + series: [], + }, }, - }, - ], - } satisfies OperationOutput<"v2GetWarehouseQueryStats">); - const { result, requests } = yield* runWarehouse( - ["inspect", "query-stats", "--since", "30m"], - () => response, - ); + ], + } satisfies + | OperationOutput<"v2GetWarehouseQueryStats"> + | OperationOutput<"v2GetWarehouseCapacity">); + const { result, requests } = yield* runWarehouse( + ["inspect", command, "--since", "30m"], + () => response, + ); - requireCliSuccess(result, "warehouse inspect query-stats"); - expect(result.stdout, result.stderr).toBe(response.body); - expect(requests).toEqual([`GET /v2/projects/${REF}/warehouse/query-stats`]); - }).pipe(Effect.provide(BunServices.layer)), + requireCliSuccess(result, `warehouse inspect ${command}`); + expect(result.stdout, result.stderr).toBe(response.body); + expect(requests).toEqual([`GET /v2/projects/${REF}/warehouse/${command}`]); + }).pipe(Effect.provide(BunServices.layer)), ); it.live("warehouse status reports a 409 as a conflict failure document on stderr", () => diff --git a/apps/cli/src/commands/api/api-commands.integration.test.ts b/apps/cli/src/commands/api/api-commands.integration.test.ts index 30d025ad29..2ee5031615 100644 --- a/apps/cli/src/commands/api/api-commands.integration.test.ts +++ b/apps/cli/src/commands/api/api-commands.integration.test.ts @@ -645,6 +645,88 @@ describe("generated warehouse commands", () => { }); }); }); + describe("warehouse inspect capacity", () => { + const argv = ["warehouse", "inspect", "capacity"]; + const attributes = { + project_ref: VALID_REF, + metric: "activation_duration_p95", + unit: "seconds", + aggregation: "p95", + definition: "Activation duration by kind and result.", + requested: { metric: "activation_duration_p95", start: 1795000000, end: 1795001800 }, + effective: { start: 1795000000, end: 1795001800, step: 60, rate_window_seconds: 300 }, + scrape_interval_seconds: 60, + last_sample_at: 1795001740, + availability: "partial", + series: [ + { + labels: { kind: "cold", result: "success" }, + points: [ + { timestamp: 1795001740, value: 0.2 }, + { timestamp: 1795001800, value: null }, + ], + coverage: { returned_points: 1, expected_points: 2 }, + }, + { + labels: { kind: "warm", result: "success" }, + points: [{ timestamp: 1795001800, value: 0.01 }], + coverage: { returned_points: 1, expected_points: 2 }, + }, + ], + } satisfies OperationOutput<"v2GetWarehouseCapacity">["data"][number]["attributes"]; + const response = { + data: [ + { + type: "warehouse_metric", + id: "activation_duration_p95", + attributes: { ...attributes, future_observation: { reason: null } }, + }, + ], + }; + + it.effect("leaves default selection to the API and preserves all JSON bytes when piped", () => { + const { sent, out, run } = setup([...argv, "--since", "30m", "--interval", "5m"], { + route: ok(response), + }); + return Effect.gen(function* () { + yield* run; + expect(sent).toHaveLength(1); + expect(sent[0]).toMatchObject({ + method: "GET", + path: `/v2/projects/${VALID_REF}/warehouse/capacity`, + body: undefined, + }); + expect(Object.fromEntries(new URLSearchParams(sent[0]?.search))).toEqual({ + since: "30m", + interval: "5m", + }); + expect(out.stdoutText).toBe(encodeJson(response)); + }); + }); + + it.effect( + "forwards fixed timestamps and metric selection and keeps all dimensions in YAML", + () => { + const from = "2026-11-18T09:30:00+01:00"; + const to = "2026-11-18T10:00:00+01:00"; + const selection = "activation_duration_p95,worker_admission_occupied"; + const { sent, out, run } = setup( + [...argv, "--from", from, "--to", to, "--attributes", selection, "-o", "yaml"], + { route: ok(response), stdoutIsTty: true }, + ); + return Effect.gen(function* () { + yield* run; + expect(sent).toHaveLength(1); + expect(Object.fromEntries(new URLSearchParams(sent[0]?.search))).toEqual({ + from, + to, + attributes: selection, + }); + expect(parseYaml(out.stdoutText)).toEqual(response); + }); + }, + ); + }); describe("warehouse tables get", () => { const tablePath = `/v2/projects/${VALID_REF}/warehouse/tables/16385`; const body = { @@ -2067,6 +2149,11 @@ describe("generated warehouse commands", () => { args: ["warehouse", "inspect", "query-stats"], features: ["warehouse"], }, + { + name: "Warehouse capacity inspection", + args: ["warehouse", "inspect", "capacity"], + features: ["warehouse"], + }, { name: "database inspection", args: ["inspect", "db", "table-stats"], features: [] }, { name: "inspection report", args: ["inspect", "report"], features: [] }, { diff --git a/apps/cli/src/commands/api/generated.md b/apps/cli/src/commands/api/generated.md index 3e21bb3db0..f1942bdf57 100644 --- a/apps/cli/src/commands/api/generated.md +++ b/apps/cli/src/commands/api/generated.md @@ -67,6 +67,26 @@ Enables replication for the currently eligible tables in a schema, or the named - Failure message from `/data/attributes/status_error`. - Failure hint names `supabase warehouse status --remote=`. +## `supabase warehouse inspect capacity` + +Inspect Warehouse capacity diagnostics + +Returns capacity, admission, assignment-wait, and activation measurements over a bounded time range, using the project’s stored Warehouse placement. Use since or both from and to; the default is the last 30 minutes. Each measurement includes its definition, unit, aggregation, requested and effective ranges, rate_window_seconds, source-sample freshness, availability, coverage, and full series with dimension labels such as reason, kind, and result. Executor invocations in flight are distinct from worker admission grants. Occupied admission includes active plus pending grants. The configured admission limit does not imply an open gate or spare capacity. Missing, stale, and insufficient observations remain unavailable or null; they do not establish healthy or idle capacity. Point timestamps are evaluation times; last_sample_at is the original source-sample time. Rates and latency quantiles describe the effective rate window at each point, not the entire requested range. Each request returns up to eight measurements, and a failure of one measurement does not discard the other results. No raw queries or backend selectors are accepted. + +- Access: read-only, no consent. +- Feature: `warehouse`. +- Request: `GET /v2/projects/{ref}/warehouse/capacity` (`v2-get-warehouse-capacity`), success 200 json. + +### Flags + +| Flag | Type | Required | Repeatable | Binds to | +| --------------------------- | --------------------------------------------- | -------- | ---------- | ------------------ | +| `--attributes ` | string | no | no | query `attributes` | +| `--from ` | string | no | no | query `from` | +| `--interval ` | string (`10m`, `1d`, `1h`, `1m`, `30m`, `5m`) | no | no | query `interval` | +| `--since ` | string | no | no | query `since` | +| `--to ` | string | no | no | query `to` | + ## `supabase warehouse inspect query-stats` Inspect Warehouse workload query statistics diff --git a/apps/cli/src/commands/api/generated.schemas.ts b/apps/cli/src/commands/api/generated.schemas.ts index 259740bc14..70943c23ea 100644 --- a/apps/cli/src/commands/api/generated.schemas.ts +++ b/apps/cli/src/commands/api/generated.schemas.ts @@ -246,6 +246,243 @@ export const apiCommandSchemas = { required: ["data"], }, }, + "v2-get-warehouse-capacity": { + result: { + $schema: "https://json-schema.org/draft/2020-12/schema", + properties: { + data: { + items: { + properties: { + attributes: { + properties: { + aggregation: { + enum: ["mean", "occupied", "p50", "p95", "p99", "rate", "sum"], + type: "string", + }, + availability: { + enum: [ + "disabled", + "insufficient_data", + "no_data", + "not_provisioned", + "ok", + "partial", + "stale", + "unavailable", + ], + type: "string", + }, + definition: { + type: "string", + }, + effective: { + properties: { + end: { + type: "number", + }, + rate_window_seconds: { + type: "number", + }, + start: { + type: "number", + }, + step: { + type: "number", + }, + }, + required: ["end", "rate_window_seconds", "start", "step"], + type: "object", + }, + last_sample_at: { + description: + "Latest observed source sample timestamp in Unix seconds; not the query evaluation timestamp.", + type: ["number", "null"], + }, + metric: { + enum: [ + "activation_duration_mean", + "activation_duration_p95", + "activation_rate", + "admission_rejection_rate", + "assignment_wait_mean", + "assignment_wait_p95", + "duckdb_duration_mean", + "query_canceled_rate", + "query_duration_mean", + "query_duration_p50", + "query_duration_p95", + "query_duration_p99", + "query_error_rate", + "query_in_flight", + "query_rate", + "query_timeout_rate", + "rpc_duration_mean", + "rpc_duration_p95", + "rpc_rate", + "worker_admission_active", + "worker_admission_limit", + "worker_admission_occupied", + "worker_admission_pending", + ], + type: "string", + }, + project_ref: { + type: "string", + }, + requested: { + properties: { + end: { + type: "number", + }, + metric: { + enum: [ + "activation_duration_mean", + "activation_duration_p95", + "activation_rate", + "admission_rejection_rate", + "assignment_wait_mean", + "assignment_wait_p95", + "duckdb_duration_mean", + "query_canceled_rate", + "query_duration_mean", + "query_duration_p50", + "query_duration_p95", + "query_duration_p99", + "query_error_rate", + "query_in_flight", + "query_rate", + "query_timeout_rate", + "rpc_duration_mean", + "rpc_duration_p95", + "rpc_rate", + "worker_admission_active", + "worker_admission_limit", + "worker_admission_occupied", + "worker_admission_pending", + ], + type: "string", + }, + start: { + type: "number", + }, + step: { + type: "number", + }, + }, + required: ["end", "metric", "start"], + type: "object", + }, + scrape_interval_seconds: { + type: "number", + }, + series: { + items: { + properties: { + coverage: { + description: + "Grid point coverage, not proof that every worker was scraped.", + properties: { + expected_points: { + type: "number", + }, + returned_points: { + type: "number", + }, + }, + required: ["expected_points", "returned_points"], + type: "object", + }, + labels: { + additionalProperties: { + type: "string", + }, + type: "object", + }, + points: { + items: { + properties: { + timestamp: { + type: "number", + }, + value: { + type: ["number", "null"], + }, + }, + required: ["timestamp", "value"], + type: "object", + }, + type: "array", + }, + }, + required: ["coverage", "labels", "points"], + type: "object", + }, + type: "array", + }, + unit: { + enum: ["grants", "per_second", "queries", "seconds"], + type: "string", + }, + }, + required: [ + "aggregation", + "availability", + "definition", + "effective", + "last_sample_at", + "metric", + "project_ref", + "requested", + "scrape_interval_seconds", + "series", + "unit", + ], + type: "object", + }, + id: { + enum: [ + "activation_duration_mean", + "activation_duration_p95", + "activation_rate", + "admission_rejection_rate", + "assignment_wait_mean", + "assignment_wait_p95", + "duckdb_duration_mean", + "query_canceled_rate", + "query_duration_mean", + "query_duration_p50", + "query_duration_p95", + "query_duration_p99", + "query_error_rate", + "query_in_flight", + "query_rate", + "query_timeout_rate", + "rpc_duration_mean", + "rpc_duration_p95", + "rpc_rate", + "worker_admission_active", + "worker_admission_limit", + "worker_admission_occupied", + "worker_admission_pending", + ], + type: "string", + }, + type: { + description: "Resource type.", + enum: ["warehouse_metric"], + type: "string", + }, + }, + required: ["attributes", "id", "type"], + type: "object", + }, + type: "array", + }, + }, + required: ["data"], + type: "object", + }, + }, "v2-get-warehouse-connection": { result: { $schema: "https://json-schema.org/draft/2020-12/schema", diff --git a/apps/cli/src/commands/api/generated.ts b/apps/cli/src/commands/api/generated.ts index 0a5793dae4..37318feb08 100644 --- a/apps/cli/src/commands/api/generated.ts +++ b/apps/cli/src/commands/api/generated.ts @@ -190,6 +190,102 @@ export const apiCommands = [ error: "/data/attributes/status_error", }, }, + { + command: ["warehouse", "inspect", "capacity"], + operationId: "v2-get-warehouse-capacity", + definition: "v2GetWarehouseCapacity", + method: "GET", + apiPath: "/v2/projects/{ref}/warehouse/capacity", + summary: "Inspect Warehouse capacity diagnostics", + description: + "Returns capacity, admission, assignment-wait, and activation measurements over a bounded time range, using the project’s stored Warehouse placement. Use since or both from and to; the default is the last 30 minutes. Each measurement includes its definition, unit, aggregation, requested and effective ranges, rate_window_seconds, source-sample freshness, availability, coverage, and full series with dimension labels such as reason, kind, and result. Executor invocations in flight are distinct from worker admission grants. Occupied admission includes active plus pending grants. The configured admission limit does not imply an open gate or spare capacity. Missing, stale, and insufficient observations remain unavailable or null; they do not establish healthy or idle capacity. Point timestamps are evaluation times; last_sample_at is the original source-sample time. Rates and latency quantiles describe the effective rate window at each point, not the entire requested range. Each request returns up to eight measurements, and a failure of one measurement does not discard the other results. No raw queries or backend selectors are accepted.", + readOnly: true, + feature: "warehouse", + response: { + status: 200, + kind: "json", + }, + flags: [ + { + name: "attributes", + type: "string", + repeatable: false, + required: false, + description: + "Up to eight distinct measurements. Defaults to query_in_flight, worker_admission_limit, worker_admission_active, worker_admission_pending, worker_admission_occupied, admission_rejection_rate, assignment_wait_p95, activation_duration_p95. Supply a comma-separated list. Allowed measurements: query_in_flight, worker_admission_limit, worker_admission_active, worker_admission_pending, worker_admission_occupied, admission_rejection_rate, assignment_wait_mean, assignment_wait_p95, activation_rate, activation_duration_mean, activation_duration_p95.", + }, + { + name: "from", + type: "string", + repeatable: false, + required: false, + description: + "Range start as an ISO timestamp, within the last 30 days. Requires to; cannot be combined with since.", + }, + { + name: "interval", + type: "string", + choices: ["10m", "1d", "1h", "1m", "30m", "5m"], + repeatable: false, + required: false, + description: + "Defaults to 1m. The effective step increases to stay within 1441 points per series. Rate and latency windows are at least 5m.", + }, + { + name: "since", + type: "string", + repeatable: false, + required: false, + description: + "Look back from server time, for example 30m, 2h, or 1d. Defaults to 30m when from/to are omitted. Maximum 30d. Cannot be combined with from/to.", + }, + { + name: "to", + type: "string", + repeatable: false, + required: false, + description: + "Range end as an ISO timestamp, no later than server time. Requires from; cannot be combined with since. The service tolerates up to 60 seconds of request delay or clock skew.", + }, + ], + bindings: [ + { + location: "path", + name: "ref", + source: "target", + }, + { + location: "query", + name: "attributes", + source: "flag", + flag: "attributes", + }, + { + location: "query", + name: "from", + source: "flag", + flag: "from", + }, + { + location: "query", + name: "interval", + source: "flag", + flag: "interval", + }, + { + location: "query", + name: "since", + source: "flag", + flag: "since", + }, + { + location: "query", + name: "to", + source: "flag", + flag: "to", + }, + ], + }, { command: ["warehouse", "inspect", "query-stats"], operationId: "v2-get-warehouse-query-stats", diff --git a/packages/api/scripts/openapi-overrides.json b/packages/api/scripts/openapi-overrides.json index 5c022cc142..19a84664e2 100644 --- a/packages/api/scripts/openapi-overrides.json +++ b/packages/api/scripts/openapi-overrides.json @@ -2956,5 +2956,432 @@ } }, "$comment": "Public Warehouse workload metrics generate warehouse inspect query-stats." + }, + { + "op": "add", + "path": "/components/schemas/V2WarehouseCapacityResponse_Output", + "value": { + "properties": { + "data": { + "items": { + "properties": { + "attributes": { + "properties": { + "aggregation": { + "enum": ["mean", "occupied", "p50", "p95", "p99", "rate", "sum"], + "type": "string" + }, + "availability": { + "enum": [ + "disabled", + "insufficient_data", + "no_data", + "not_provisioned", + "ok", + "partial", + "stale", + "unavailable" + ], + "type": "string" + }, + "definition": { + "type": "string" + }, + "effective": { + "properties": { + "end": { + "type": "number" + }, + "rate_window_seconds": { + "type": "number" + }, + "start": { + "type": "number" + }, + "step": { + "type": "number" + } + }, + "required": ["end", "rate_window_seconds", "start", "step"], + "type": "object" + }, + "last_sample_at": { + "description": "Latest observed source sample timestamp in Unix seconds; not the query evaluation timestamp.", + "nullable": true, + "type": "number" + }, + "metric": { + "enum": [ + "activation_duration_mean", + "activation_duration_p95", + "activation_rate", + "admission_rejection_rate", + "assignment_wait_mean", + "assignment_wait_p95", + "duckdb_duration_mean", + "query_canceled_rate", + "query_duration_mean", + "query_duration_p50", + "query_duration_p95", + "query_duration_p99", + "query_error_rate", + "query_in_flight", + "query_rate", + "query_timeout_rate", + "rpc_duration_mean", + "rpc_duration_p95", + "rpc_rate", + "worker_admission_active", + "worker_admission_limit", + "worker_admission_occupied", + "worker_admission_pending" + ], + "type": "string" + }, + "project_ref": { + "type": "string" + }, + "requested": { + "properties": { + "end": { + "type": "number" + }, + "metric": { + "enum": [ + "activation_duration_mean", + "activation_duration_p95", + "activation_rate", + "admission_rejection_rate", + "assignment_wait_mean", + "assignment_wait_p95", + "duckdb_duration_mean", + "query_canceled_rate", + "query_duration_mean", + "query_duration_p50", + "query_duration_p95", + "query_duration_p99", + "query_error_rate", + "query_in_flight", + "query_rate", + "query_timeout_rate", + "rpc_duration_mean", + "rpc_duration_p95", + "rpc_rate", + "worker_admission_active", + "worker_admission_limit", + "worker_admission_occupied", + "worker_admission_pending" + ], + "type": "string" + }, + "start": { + "type": "number" + }, + "step": { + "type": "number" + } + }, + "required": ["end", "metric", "start"], + "type": "object" + }, + "scrape_interval_seconds": { + "type": "number" + }, + "series": { + "items": { + "properties": { + "coverage": { + "description": "Grid point coverage, not proof that every worker was scraped.", + "properties": { + "expected_points": { + "type": "number" + }, + "returned_points": { + "type": "number" + } + }, + "required": ["expected_points", "returned_points"], + "type": "object" + }, + "labels": { + "additionalProperties": { + "type": "string" + }, + "type": "object" + }, + "points": { + "items": { + "properties": { + "timestamp": { + "type": "number" + }, + "value": { + "nullable": true, + "type": "number" + } + }, + "required": ["timestamp", "value"], + "type": "object" + }, + "type": "array" + } + }, + "required": ["coverage", "labels", "points"], + "type": "object" + }, + "type": "array" + }, + "unit": { + "enum": ["grants", "per_second", "queries", "seconds"], + "type": "string" + } + }, + "required": [ + "aggregation", + "availability", + "definition", + "effective", + "last_sample_at", + "metric", + "project_ref", + "requested", + "scrape_interval_seconds", + "series", + "unit" + ], + "type": "object" + }, + "id": { + "enum": [ + "activation_duration_mean", + "activation_duration_p95", + "activation_rate", + "admission_rejection_rate", + "assignment_wait_mean", + "assignment_wait_p95", + "duckdb_duration_mean", + "query_canceled_rate", + "query_duration_mean", + "query_duration_p50", + "query_duration_p95", + "query_duration_p99", + "query_error_rate", + "query_in_flight", + "query_rate", + "query_timeout_rate", + "rpc_duration_mean", + "rpc_duration_p95", + "rpc_rate", + "worker_admission_active", + "worker_admission_limit", + "worker_admission_occupied", + "worker_admission_pending" + ], + "type": "string" + }, + "type": { + "description": "Resource type.", + "enum": ["warehouse_metric"], + "type": "string" + } + }, + "required": ["attributes", "id", "type"], + "type": "object" + }, + "type": "array" + } + }, + "required": ["data"], + "type": "object" + } + }, + { + "op": "add", + "path": "/paths/~1v2~1projects~1{ref}~1warehouse~1capacity", + "value": { + "get": { + "description": "Returns capacity, admission, assignment-wait, and activation measurements over a bounded time range, using the project\u2019s stored Warehouse placement. Use since or both from and to; the default is the last 30 minutes. Each measurement includes its definition, unit, aggregation, requested and effective ranges, rate_window_seconds, source-sample freshness, availability, coverage, and full series with dimension labels such as reason, kind, and result. Executor invocations in flight are distinct from worker admission grants. Occupied admission includes active plus pending grants. The configured admission limit does not imply an open gate or spare capacity. Missing, stale, and insufficient observations remain unavailable or null; they do not establish healthy or idle capacity. Point timestamps are evaluation times; last_sample_at is the original source-sample time. Rates and latency quantiles describe the effective rate window at each point, not the entire requested range. Each request returns up to eight measurements, and a failure of one measurement does not discard the other results. No raw queries or backend selectors are accepted.\n\nThis endpoint is currently in its **Alpha** stage.", + "operationId": "v2-get-warehouse-capacity", + "parameters": [ + { + "description": "Up to eight distinct measurements. Defaults to query_in_flight, worker_admission_limit, worker_admission_active, worker_admission_pending, worker_admission_occupied, admission_rejection_rate, assignment_wait_p95, activation_duration_p95. Supply a comma-separated list. Allowed measurements: query_in_flight, worker_admission_limit, worker_admission_active, worker_admission_pending, worker_admission_occupied, admission_rejection_rate, assignment_wait_mean, assignment_wait_p95, activation_rate, activation_duration_mean, activation_duration_p95.", + "in": "query", + "name": "attributes", + "required": false, + "schema": { + "type": "string" + } + }, + { + "description": "Range start as an ISO timestamp, within the last 30 days. Requires to; cannot be combined with since.", + "in": "query", + "name": "from", + "required": false, + "schema": { + "format": "date-time", + "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$", + "type": "string" + } + }, + { + "description": "Defaults to 1m. The effective step increases to stay within 1441 points per series. Rate and latency windows are at least 5m.", + "in": "query", + "name": "interval", + "required": false, + "schema": { + "enum": ["10m", "1d", "1h", "1m", "30m", "5m"], + "type": "string" + } + }, + { + "description": "Project ref", + "in": "path", + "name": "ref", + "required": true, + "schema": { + "example": "abcdefghijklmnopqrst", + "maxLength": 20, + "minLength": 20, + "pattern": "^[a-z]+$", + "type": "string" + } + }, + { + "description": "Look back from server time, for example 30m, 2h, or 1d. Defaults to 30m when from/to are omitted. Maximum 30d. Cannot be combined with from/to.", + "in": "query", + "name": "since", + "required": false, + "schema": { + "pattern": "^[1-9]\\d*(s|m|h|d)$", + "type": "string" + } + }, + { + "description": "Range end as an ISO timestamp, no later than server time. Requires from; cannot be combined with since. The service tolerates up to 60 seconds of request delay or clock skew.", + "in": "query", + "name": "to", + "required": false, + "schema": { + "format": "date-time", + "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$", + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/V2WarehouseCapacityResponse_Output" + } + } + }, + "description": "" + }, + "400": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponseBody" + } + } + }, + "description": "validation_failed: Invalid measurement selection, range, interval, or query parameter" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponseBody" + } + } + }, + "description": "Unauthorized" + }, + "402": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponseBody" + } + } + }, + "description": "This feature requires the Pro, Team, or Enterprise organization plan." + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponseBody" + } + } + }, + "description": "Forbidden action" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponseBody" + } + } + }, + "description": "Project not found" + }, + "429": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponseBody" + } + } + }, + "description": "Rate limit exceeded" + }, + "503": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponseBody" + } + } + }, + "description": "warehouse_metrics_unavailable: Metrics query capacity is temporarily unavailable; retry after a short delay. warehouse_setup_unavailable: Warehouse feature or project metadata unavailable." + } + }, + "security": [ + { + "bearer": [] + } + ], + "summary": "Inspect Warehouse capacity diagnostics", + "tags": ["Projects Warehouse"], + "x-allowed-plans": ["Enterprise", "Pro", "Team"], + "x-badges": [ + { + "name": "OAuth scope: database:read", + "position": "after" + }, + { + "name": "Only available on Pro, Team, Enterprise", + "position": "before" + }, + { + "name": "Alpha", + "position": "before" + } + ], + "x-endpoint-owners": ["pipelines"], + "x-fga-permissions": [["database_read"]], + "x-oauth-scope": "database:read", + "x-operation": { + "group": "warehouse.inspect", + "method": "capacity" + }, + "x-scalar-stability": "experimental" + } + }, + "$comment": "Public Warehouse capacity metrics generate warehouse inspect capacity." } ] diff --git a/packages/api/src/generated/contracts.ts b/packages/api/src/generated/contracts.ts index 169abe1535..12171cd818 100644 --- a/packages/api/src/generated/contracts.ts +++ b/packages/api/src/generated/contracts.ts @@ -14320,6 +14320,197 @@ export const V2GetProjectConfigOutput = Schema.Struct({ }), }), }); +export const V2GetWarehouseCapacityInput = Schema.Struct({ + attributes: Schema.optionalKey(Schema.String), + from: Schema.optionalKey(Schema.String.annotate({ format: "date-time" })), + interval: Schema.optionalKey(Schema.Literals(["10m", "1d", "1h", "1m", "30m", "5m"])), + ref: Schema.String.check( + Schema.isMinCodePoints(20).annotate({ expected: "a string with at least 20 code points" }), + ) + .check( + Schema.isMaxCodePoints(20).annotate({ expected: "a string with at most 20 code points" }), + ) + .check( + Schema.isPattern(new RegExp("^[a-z]+$", "u")).annotate({ + expected: "a string matching the RegExp ^[a-z]+$", + }), + ), + since: Schema.optionalKey( + Schema.String.check( + Schema.isPattern(new RegExp("^[1-9]\\d*(s|m|h|d)$", "u")).annotate({ + expected: "a string matching the RegExp ^[1-9]\\d*(s|m|h|d)$", + }), + ), + ), + to: Schema.optionalKey(Schema.String.annotate({ format: "date-time" })), +}); +export const V2GetWarehouseCapacityOutput = Schema.Struct({ + data: Schema.Array( + Schema.Struct({ + attributes: Schema.Struct({ + aggregation: Schema.Union([ + Schema.Literals(["mean", "occupied", "p50", "p95", "p99", "rate", "sum"]), + OpenString, + ]), + availability: Schema.Union([ + Schema.Literals([ + "disabled", + "insufficient_data", + "no_data", + "not_provisioned", + "ok", + "partial", + "stale", + "unavailable", + ]), + OpenString, + ]), + definition: Schema.String, + effective: Schema.Struct({ + end: Schema.Number.check(Schema.isFinite().annotate({ expected: "a finite number" })), + rate_window_seconds: Schema.Number.check( + Schema.isFinite().annotate({ expected: "a finite number" }), + ), + start: Schema.Number.check(Schema.isFinite().annotate({ expected: "a finite number" })), + step: Schema.Number.check(Schema.isFinite().annotate({ expected: "a finite number" })), + }), + last_sample_at: Schema.Union([ + Schema.Number.annotate({ + description: + "Latest observed source sample timestamp in Unix seconds; not the query evaluation timestamp.", + }).check(Schema.isFinite().annotate({ expected: "a finite number" })), + Schema.Null, + ]), + metric: Schema.Union([ + Schema.Literals([ + "activation_duration_mean", + "activation_duration_p95", + "activation_rate", + "admission_rejection_rate", + "assignment_wait_mean", + "assignment_wait_p95", + "duckdb_duration_mean", + "query_canceled_rate", + "query_duration_mean", + "query_duration_p50", + "query_duration_p95", + "query_duration_p99", + "query_error_rate", + "query_in_flight", + "query_rate", + "query_timeout_rate", + "rpc_duration_mean", + "rpc_duration_p95", + "rpc_rate", + "worker_admission_active", + "worker_admission_limit", + "worker_admission_occupied", + "worker_admission_pending", + ]), + OpenString, + ]), + project_ref: Schema.String, + requested: Schema.Struct({ + end: Schema.Number.check(Schema.isFinite().annotate({ expected: "a finite number" })), + metric: Schema.Union([ + Schema.Literals([ + "activation_duration_mean", + "activation_duration_p95", + "activation_rate", + "admission_rejection_rate", + "assignment_wait_mean", + "assignment_wait_p95", + "duckdb_duration_mean", + "query_canceled_rate", + "query_duration_mean", + "query_duration_p50", + "query_duration_p95", + "query_duration_p99", + "query_error_rate", + "query_in_flight", + "query_rate", + "query_timeout_rate", + "rpc_duration_mean", + "rpc_duration_p95", + "rpc_rate", + "worker_admission_active", + "worker_admission_limit", + "worker_admission_occupied", + "worker_admission_pending", + ]), + OpenString, + ]), + start: Schema.Number.check(Schema.isFinite().annotate({ expected: "a finite number" })), + step: Schema.optionalKey( + Schema.Number.check(Schema.isFinite().annotate({ expected: "a finite number" })), + ), + }), + scrape_interval_seconds: Schema.Number.check( + Schema.isFinite().annotate({ expected: "a finite number" }), + ), + series: Schema.Array( + Schema.Struct({ + coverage: Schema.Struct({ + expected_points: Schema.Number.check( + Schema.isFinite().annotate({ expected: "a finite number" }), + ), + returned_points: Schema.Number.check( + Schema.isFinite().annotate({ expected: "a finite number" }), + ), + }).annotate({ + description: "Grid point coverage, not proof that every worker was scraped.", + }), + labels: Schema.Record(Schema.String, Schema.String), + points: Schema.Array( + Schema.Struct({ + timestamp: Schema.Number.check( + Schema.isFinite().annotate({ expected: "a finite number" }), + ), + value: Schema.Union([ + Schema.Number.check(Schema.isFinite().annotate({ expected: "a finite number" })), + Schema.Null, + ]), + }), + ), + }), + ), + unit: Schema.Union([ + Schema.Literals(["grants", "per_second", "queries", "seconds"]), + OpenString, + ]), + }), + id: Schema.Union([ + Schema.Literals([ + "activation_duration_mean", + "activation_duration_p95", + "activation_rate", + "admission_rejection_rate", + "assignment_wait_mean", + "assignment_wait_p95", + "duckdb_duration_mean", + "query_canceled_rate", + "query_duration_mean", + "query_duration_p50", + "query_duration_p95", + "query_duration_p99", + "query_error_rate", + "query_in_flight", + "query_rate", + "query_timeout_rate", + "rpc_duration_mean", + "rpc_duration_p95", + "rpc_rate", + "worker_admission_active", + "worker_admission_limit", + "worker_admission_occupied", + "worker_admission_pending", + ]), + OpenString, + ]), + type: Schema.Literal("warehouse_metric").annotate({ description: "Resource type." }), + }), + ), +}); export const V2GetWarehouseConnectionInput = Schema.Struct({ ref: Schema.String.check( Schema.isMinCodePoints(20).annotate({ expected: "a string with at least 20 code points" }), @@ -20971,6 +21162,7 @@ export const openApiOperationIdMap = { "v2-get-a-compute-instance": "v2GetAComputeInstance", "v2-get-notebook": "v2GetNotebook", "v2-get-project-config": "v2GetProjectConfig", + "v2-get-warehouse-capacity": "v2GetWarehouseCapacity", "v2-get-warehouse-connection": "v2GetWarehouseConnection", "v2-get-warehouse-query-stats": "v2GetWarehouseQueryStats", "v2-get-warehouse-setup": "v2GetWarehouseSetup", @@ -24152,6 +24344,20 @@ export const operationDefinitions = { inputSchema: V2GetProjectConfigInput, outputSchema: V2GetProjectConfigOutput, }, + v2GetWarehouseCapacity: { + id: "v2GetWarehouseCapacity", + description: + "Returns capacity, admission, assignment-wait, and activation measurements over a bounded time range, using the project’s stored Warehouse placement. Use since or both from and to; the default is the last 30 minutes. Each measurement includes its definition, unit, aggregation, requested and effective ranges, rate_window_seconds, source-sample freshness, availability, coverage, and full series with dimension labels such as reason, kind, and result. Executor invocations in flight are distinct from worker admission grants. Occupied admission includes active plus pending grants. The configured admission limit does not imply an open gate or spare capacity. Missing, stale, and insufficient observations remain unavailable or null; they do not establish healthy or idle capacity. Point timestamps are evaluation times; last_sample_at is the original source-sample time. Rates and latency quantiles describe the effective rate window at each point, not the entire requested range. Each request returns up to eight measurements, and a failure of one measurement does not discard the other results. No raw queries or backend selectors are accepted.\n\nThis endpoint is currently in its **Alpha** stage.", + method: "GET", + path: "/v2/projects/{ref}/warehouse/capacity", + pathParams: ["ref"], + queryParams: ["attributes", "from", "interval", "since", "to"], + headerParams: [], + requestBody: { kind: "none" }, + response: { kind: "json" }, + inputSchema: V2GetWarehouseCapacityInput, + outputSchema: V2GetWarehouseCapacityOutput, + }, v2GetWarehouseConnection: { id: "v2GetWarehouseConnection", description: diff --git a/packages/api/src/generated/effect-client.ts b/packages/api/src/generated/effect-client.ts index c014161cb9..b1a8cd3e65 100644 --- a/packages/api/src/generated/effect-client.ts +++ b/packages/api/src/generated/effect-client.ts @@ -3092,6 +3092,22 @@ export const versionedEffectOperations = { options, ); }), + getWarehouseCapacity: ( + input: typeof operationDefinitions.v2GetWarehouseCapacity.inputSchema.Type, + options?: SupabaseApiRequestOptions, + ): Effect.Effect< + typeof operationDefinitions.v2GetWarehouseCapacity.outputSchema.Type, + SupabaseApiError, + SupabaseApiClient + > => + Effect.gen(function* () { + const client = yield* SupabaseApiClient; + return yield* client.execute<"v2GetWarehouseCapacity">( + operationDefinitions.v2GetWarehouseCapacity, + input, + options, + ); + }), getWarehouseConnection: ( input: typeof operationDefinitions.v2GetWarehouseConnection.inputSchema.Type, options?: SupabaseApiRequestOptions, diff --git a/packages/api/src/generated/openapi.json b/packages/api/src/generated/openapi.json index 4fea2b2f5e..cf92d0d02a 100644 --- a/packages/api/src/generated/openapi.json +++ b/packages/api/src/generated/openapi.json @@ -33553,6 +33553,190 @@ }, "x-scalar-stability": "experimental" } + }, + "/v2/projects/{ref}/warehouse/capacity": { + "get": { + "description": "Returns capacity, admission, assignment-wait, and activation measurements over a bounded time range, using the project’s stored Warehouse placement. Use since or both from and to; the default is the last 30 minutes. Each measurement includes its definition, unit, aggregation, requested and effective ranges, rate_window_seconds, source-sample freshness, availability, coverage, and full series with dimension labels such as reason, kind, and result. Executor invocations in flight are distinct from worker admission grants. Occupied admission includes active plus pending grants. The configured admission limit does not imply an open gate or spare capacity. Missing, stale, and insufficient observations remain unavailable or null; they do not establish healthy or idle capacity. Point timestamps are evaluation times; last_sample_at is the original source-sample time. Rates and latency quantiles describe the effective rate window at each point, not the entire requested range. Each request returns up to eight measurements, and a failure of one measurement does not discard the other results. No raw queries or backend selectors are accepted.\n\nThis endpoint is currently in its **Alpha** stage.", + "operationId": "v2-get-warehouse-capacity", + "parameters": [ + { + "description": "Up to eight distinct measurements. Defaults to query_in_flight, worker_admission_limit, worker_admission_active, worker_admission_pending, worker_admission_occupied, admission_rejection_rate, assignment_wait_p95, activation_duration_p95. Supply a comma-separated list. Allowed measurements: query_in_flight, worker_admission_limit, worker_admission_active, worker_admission_pending, worker_admission_occupied, admission_rejection_rate, assignment_wait_mean, assignment_wait_p95, activation_rate, activation_duration_mean, activation_duration_p95.", + "in": "query", + "name": "attributes", + "required": false, + "schema": { + "type": "string" + } + }, + { + "description": "Range start as an ISO timestamp, within the last 30 days. Requires to; cannot be combined with since.", + "in": "query", + "name": "from", + "required": false, + "schema": { + "format": "date-time", + "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$", + "type": "string" + } + }, + { + "description": "Defaults to 1m. The effective step increases to stay within 1441 points per series. Rate and latency windows are at least 5m.", + "in": "query", + "name": "interval", + "required": false, + "schema": { + "enum": ["10m", "1d", "1h", "1m", "30m", "5m"], + "type": "string" + } + }, + { + "description": "Project ref", + "in": "path", + "name": "ref", + "required": true, + "schema": { + "example": "abcdefghijklmnopqrst", + "maxLength": 20, + "minLength": 20, + "pattern": "^[a-z]+$", + "type": "string" + } + }, + { + "description": "Look back from server time, for example 30m, 2h, or 1d. Defaults to 30m when from/to are omitted. Maximum 30d. Cannot be combined with from/to.", + "in": "query", + "name": "since", + "required": false, + "schema": { + "pattern": "^[1-9]\\d*(s|m|h|d)$", + "type": "string" + } + }, + { + "description": "Range end as an ISO timestamp, no later than server time. Requires from; cannot be combined with since. The service tolerates up to 60 seconds of request delay or clock skew.", + "in": "query", + "name": "to", + "required": false, + "schema": { + "format": "date-time", + "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$", + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/V2WarehouseCapacityResponse_Output" + } + } + }, + "description": "" + }, + "400": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponseBody" + } + } + }, + "description": "validation_failed: Invalid measurement selection, range, interval, or query parameter" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponseBody" + } + } + }, + "description": "Unauthorized" + }, + "402": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponseBody" + } + } + }, + "description": "This feature requires the Pro, Team, or Enterprise organization plan." + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponseBody" + } + } + }, + "description": "Forbidden action" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponseBody" + } + } + }, + "description": "Project not found" + }, + "429": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponseBody" + } + } + }, + "description": "Rate limit exceeded" + }, + "503": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponseBody" + } + } + }, + "description": "warehouse_metrics_unavailable: Metrics query capacity is temporarily unavailable; retry after a short delay. warehouse_setup_unavailable: Warehouse feature or project metadata unavailable." + } + }, + "security": [ + { + "bearer": [] + } + ], + "summary": "Inspect Warehouse capacity diagnostics", + "tags": ["Projects Warehouse"], + "x-allowed-plans": ["Enterprise", "Pro", "Team"], + "x-badges": [ + { + "name": "OAuth scope: database:read", + "position": "after" + }, + { + "name": "Only available on Pro, Team, Enterprise", + "position": "before" + }, + { + "name": "Alpha", + "position": "before" + } + ], + "x-endpoint-owners": ["pipelines"], + "x-fga-permissions": [["database_read"]], + "x-oauth-scope": "database:read", + "x-operation": { + "group": "warehouse.inspect", + "method": "capacity" + }, + "x-scalar-stability": "experimental" + } } }, "components": { @@ -50710,6 +50894,240 @@ }, "required": ["data"], "type": "object" + }, + "V2WarehouseCapacityResponse_Output": { + "properties": { + "data": { + "items": { + "properties": { + "attributes": { + "properties": { + "aggregation": { + "enum": ["mean", "occupied", "p50", "p95", "p99", "rate", "sum"], + "type": "string" + }, + "availability": { + "enum": [ + "disabled", + "insufficient_data", + "no_data", + "not_provisioned", + "ok", + "partial", + "stale", + "unavailable" + ], + "type": "string" + }, + "definition": { + "type": "string" + }, + "effective": { + "properties": { + "end": { + "type": "number" + }, + "rate_window_seconds": { + "type": "number" + }, + "start": { + "type": "number" + }, + "step": { + "type": "number" + } + }, + "required": ["end", "rate_window_seconds", "start", "step"], + "type": "object" + }, + "last_sample_at": { + "description": "Latest observed source sample timestamp in Unix seconds; not the query evaluation timestamp.", + "nullable": true, + "type": "number" + }, + "metric": { + "enum": [ + "activation_duration_mean", + "activation_duration_p95", + "activation_rate", + "admission_rejection_rate", + "assignment_wait_mean", + "assignment_wait_p95", + "duckdb_duration_mean", + "query_canceled_rate", + "query_duration_mean", + "query_duration_p50", + "query_duration_p95", + "query_duration_p99", + "query_error_rate", + "query_in_flight", + "query_rate", + "query_timeout_rate", + "rpc_duration_mean", + "rpc_duration_p95", + "rpc_rate", + "worker_admission_active", + "worker_admission_limit", + "worker_admission_occupied", + "worker_admission_pending" + ], + "type": "string" + }, + "project_ref": { + "type": "string" + }, + "requested": { + "properties": { + "end": { + "type": "number" + }, + "metric": { + "enum": [ + "activation_duration_mean", + "activation_duration_p95", + "activation_rate", + "admission_rejection_rate", + "assignment_wait_mean", + "assignment_wait_p95", + "duckdb_duration_mean", + "query_canceled_rate", + "query_duration_mean", + "query_duration_p50", + "query_duration_p95", + "query_duration_p99", + "query_error_rate", + "query_in_flight", + "query_rate", + "query_timeout_rate", + "rpc_duration_mean", + "rpc_duration_p95", + "rpc_rate", + "worker_admission_active", + "worker_admission_limit", + "worker_admission_occupied", + "worker_admission_pending" + ], + "type": "string" + }, + "start": { + "type": "number" + }, + "step": { + "type": "number" + } + }, + "required": ["end", "metric", "start"], + "type": "object" + }, + "scrape_interval_seconds": { + "type": "number" + }, + "series": { + "items": { + "properties": { + "coverage": { + "description": "Grid point coverage, not proof that every worker was scraped.", + "properties": { + "expected_points": { + "type": "number" + }, + "returned_points": { + "type": "number" + } + }, + "required": ["expected_points", "returned_points"], + "type": "object" + }, + "labels": { + "additionalProperties": { + "type": "string" + }, + "type": "object" + }, + "points": { + "items": { + "properties": { + "timestamp": { + "type": "number" + }, + "value": { + "nullable": true, + "type": "number" + } + }, + "required": ["timestamp", "value"], + "type": "object" + }, + "type": "array" + } + }, + "required": ["coverage", "labels", "points"], + "type": "object" + }, + "type": "array" + }, + "unit": { + "enum": ["grants", "per_second", "queries", "seconds"], + "type": "string" + } + }, + "required": [ + "aggregation", + "availability", + "definition", + "effective", + "last_sample_at", + "metric", + "project_ref", + "requested", + "scrape_interval_seconds", + "series", + "unit" + ], + "type": "object" + }, + "id": { + "enum": [ + "activation_duration_mean", + "activation_duration_p95", + "activation_rate", + "admission_rejection_rate", + "assignment_wait_mean", + "assignment_wait_p95", + "duckdb_duration_mean", + "query_canceled_rate", + "query_duration_mean", + "query_duration_p50", + "query_duration_p95", + "query_duration_p99", + "query_error_rate", + "query_in_flight", + "query_rate", + "query_timeout_rate", + "rpc_duration_mean", + "rpc_duration_p95", + "rpc_rate", + "worker_admission_active", + "worker_admission_limit", + "worker_admission_occupied", + "worker_admission_pending" + ], + "type": "string" + }, + "type": { + "description": "Resource type.", + "enum": ["warehouse_metric"], + "type": "string" + } + }, + "required": ["attributes", "id", "type"], + "type": "object" + }, + "type": "array" + } + }, + "required": ["data"], + "type": "object" } } } diff --git a/packages/api/src/generated/permissions.ts b/packages/api/src/generated/permissions.ts index fc787e4a6e..59ffaf69a7 100644 --- a/packages/api/src/generated/permissions.ts +++ b/packages/api/src/generated/permissions.ts @@ -458,4 +458,5 @@ export const operationPermissions: Readonly oauthScope: "database:write", }, "v2-get-warehouse-query-stats": { fga: [["database_read"]], oauthScope: "database:read" }, + "v2-get-warehouse-capacity": { fga: [["database_read"]], oauthScope: "database:read" }, }; From c4f362efffb5510c6620e15f254372097410f74f Mon Sep 17 00:00:00 2001 From: Benjamin <5719034+bnjjj@users.noreply.github.com> Date: Thu, 19 Nov 2026 11:52:24 +0100 Subject: [PATCH 2/2] fix(cli): refine capacity contract and generated help --- .../api/api-commands.integration.test.ts | 22 ++++++++- apps/cli/src/commands/api/generated.md | 10 +++- .../cli/src/commands/api/generated.schemas.ts | 36 -------------- apps/cli/src/commands/api/generated.ts | 12 ++--- packages/api/scripts/openapi-overrides.json | 48 +++---------------- packages/api/src/generated/contracts.ts | 38 +-------------- packages/api/src/generated/openapi.json | 48 +++---------------- 7 files changed, 48 insertions(+), 166 deletions(-) diff --git a/apps/cli/src/commands/api/api-commands.integration.test.ts b/apps/cli/src/commands/api/api-commands.integration.test.ts index 2ee5031615..0ca827c87f 100644 --- a/apps/cli/src/commands/api/api-commands.integration.test.ts +++ b/apps/cli/src/commands/api/api-commands.integration.test.ts @@ -685,8 +685,9 @@ describe("generated warehouse commands", () => { }; it.effect("leaves default selection to the API and preserves all JSON bytes when piped", () => { + const rawResponse = `\n${encodeJson(response).replace('"value":0.2', '"value":0.20')}\n`; const { sent, out, run } = setup([...argv, "--since", "30m", "--interval", "5m"], { - route: ok(response), + route: ok(rawResponse), }); return Effect.gen(function* () { yield* run; @@ -700,10 +701,27 @@ describe("generated warehouse commands", () => { since: "30m", interval: "5m", }); - expect(out.stdoutText).toBe(encodeJson(response)); + expect(out.stdoutText).toBe(rawResponse); }); }); + it.effect( + "renders both capacity series, their dimensions, unit, availability, and null sample", + () => { + const { out, run } = setup(argv, { route: ok(response), stdoutIsTty: true }); + return Effect.gen(function* () { + yield* run; + expect(out.stdoutText).toMatch(/Kind\s+cold/); + expect(out.stdoutText).toMatch(/Kind\s+warm/); + expect(out.stdoutText.match(/Result\s+success/g)).toHaveLength(2); + expect(out.stdoutText).toMatch(/\bUNIT\b[\s\S]*\bseconds\b/); + expect(out.stdoutText).toMatch(/\bAVAILABILITY\b[\s\S]*\bpartial\b/); + expect(out.stdoutText).toMatch(/1795001800\s*[|│]?\s*-/); + expect(out.stdoutText).toMatch(/1795001800\s*[|│]?\s*0\.01/); + }); + }, + ); + it.effect( "forwards fixed timestamps and metric selection and keeps all dimensions in YAML", () => { diff --git a/apps/cli/src/commands/api/generated.md b/apps/cli/src/commands/api/generated.md index f1942bdf57..ff1837604a 100644 --- a/apps/cli/src/commands/api/generated.md +++ b/apps/cli/src/commands/api/generated.md @@ -71,7 +71,15 @@ Enables replication for the currently eligible tables in a schema, or the named Inspect Warehouse capacity diagnostics -Returns capacity, admission, assignment-wait, and activation measurements over a bounded time range, using the project’s stored Warehouse placement. Use since or both from and to; the default is the last 30 minutes. Each measurement includes its definition, unit, aggregation, requested and effective ranges, rate_window_seconds, source-sample freshness, availability, coverage, and full series with dimension labels such as reason, kind, and result. Executor invocations in flight are distinct from worker admission grants. Occupied admission includes active plus pending grants. The configured admission limit does not imply an open gate or spare capacity. Missing, stale, and insufficient observations remain unavailable or null; they do not establish healthy or idle capacity. Point timestamps are evaluation times; last_sample_at is the original source-sample time. Rates and latency quantiles describe the effective rate window at each point, not the entire requested range. Each request returns up to eight measurements, and a failure of one measurement does not discard the other results. No raw queries or backend selectors are accepted. +Returns capacity, admission, assignment-wait, and activation measurements over a bounded time range, using the project’s stored Warehouse placement. Use `--since` or specify both `--from` and `--to`; the default is the last 30 minutes. + +Each measurement includes its definition, unit, aggregation, requested and effective ranges, `rate_window_seconds`, source-sample freshness, availability, coverage, and full series with dimension labels such as `reason`, `kind`, and `result`. + +Executor invocations in flight are distinct from worker admission grants. Occupied admission includes active plus pending grants. The configured admission limit does not imply an open gate or spare capacity. Missing, stale, and insufficient observations remain unavailable or `null`; they do not establish healthy or idle capacity. + +Point timestamps are evaluation times; `last_sample_at` is the original source-sample time. Rates and latency quantiles describe the effective rate window at each point, not the entire requested range. + +Each request returns up to eight measurements, and a failure of one measurement does not discard the other results. No raw queries or backend selectors are accepted. - Access: read-only, no consent. - Feature: `warehouse`. diff --git a/apps/cli/src/commands/api/generated.schemas.ts b/apps/cli/src/commands/api/generated.schemas.ts index 70943c23ea..7503a81041 100644 --- a/apps/cli/src/commands/api/generated.schemas.ts +++ b/apps/cli/src/commands/api/generated.schemas.ts @@ -306,19 +306,7 @@ export const apiCommandSchemas = { "admission_rejection_rate", "assignment_wait_mean", "assignment_wait_p95", - "duckdb_duration_mean", - "query_canceled_rate", - "query_duration_mean", - "query_duration_p50", - "query_duration_p95", - "query_duration_p99", - "query_error_rate", "query_in_flight", - "query_rate", - "query_timeout_rate", - "rpc_duration_mean", - "rpc_duration_p95", - "rpc_rate", "worker_admission_active", "worker_admission_limit", "worker_admission_occupied", @@ -342,19 +330,7 @@ export const apiCommandSchemas = { "admission_rejection_rate", "assignment_wait_mean", "assignment_wait_p95", - "duckdb_duration_mean", - "query_canceled_rate", - "query_duration_mean", - "query_duration_p50", - "query_duration_p95", - "query_duration_p99", - "query_error_rate", "query_in_flight", - "query_rate", - "query_timeout_rate", - "rpc_duration_mean", - "rpc_duration_p95", - "rpc_rate", "worker_admission_active", "worker_admission_limit", "worker_admission_occupied", @@ -447,19 +423,7 @@ export const apiCommandSchemas = { "admission_rejection_rate", "assignment_wait_mean", "assignment_wait_p95", - "duckdb_duration_mean", - "query_canceled_rate", - "query_duration_mean", - "query_duration_p50", - "query_duration_p95", - "query_duration_p99", - "query_error_rate", "query_in_flight", - "query_rate", - "query_timeout_rate", - "rpc_duration_mean", - "rpc_duration_p95", - "rpc_rate", "worker_admission_active", "worker_admission_limit", "worker_admission_occupied", diff --git a/apps/cli/src/commands/api/generated.ts b/apps/cli/src/commands/api/generated.ts index 37318feb08..30ff3dc771 100644 --- a/apps/cli/src/commands/api/generated.ts +++ b/apps/cli/src/commands/api/generated.ts @@ -198,7 +198,7 @@ export const apiCommands = [ apiPath: "/v2/projects/{ref}/warehouse/capacity", summary: "Inspect Warehouse capacity diagnostics", description: - "Returns capacity, admission, assignment-wait, and activation measurements over a bounded time range, using the project’s stored Warehouse placement. Use since or both from and to; the default is the last 30 minutes. Each measurement includes its definition, unit, aggregation, requested and effective ranges, rate_window_seconds, source-sample freshness, availability, coverage, and full series with dimension labels such as reason, kind, and result. Executor invocations in flight are distinct from worker admission grants. Occupied admission includes active plus pending grants. The configured admission limit does not imply an open gate or spare capacity. Missing, stale, and insufficient observations remain unavailable or null; they do not establish healthy or idle capacity. Point timestamps are evaluation times; last_sample_at is the original source-sample time. Rates and latency quantiles describe the effective rate window at each point, not the entire requested range. Each request returns up to eight measurements, and a failure of one measurement does not discard the other results. No raw queries or backend selectors are accepted.", + "Returns capacity, admission, assignment-wait, and activation measurements over a bounded time range, using the project’s stored Warehouse placement. Use `--since` or specify both `--from` and `--to`; the default is the last 30 minutes.\n\nEach measurement includes its definition, unit, aggregation, requested and effective ranges, `rate_window_seconds`, source-sample freshness, availability, coverage, and full series with dimension labels such as `reason`, `kind`, and `result`.\n\nExecutor invocations in flight are distinct from worker admission grants. Occupied admission includes active plus pending grants. The configured admission limit does not imply an open gate or spare capacity. Missing, stale, and insufficient observations remain unavailable or `null`; they do not establish healthy or idle capacity.\n\nPoint timestamps are evaluation times; `last_sample_at` is the original source-sample time. Rates and latency quantiles describe the effective rate window at each point, not the entire requested range.\n\nEach request returns up to eight measurements, and a failure of one measurement does not discard the other results. No raw queries or backend selectors are accepted.", readOnly: true, feature: "warehouse", response: { @@ -212,7 +212,7 @@ export const apiCommands = [ repeatable: false, required: false, description: - "Up to eight distinct measurements. Defaults to query_in_flight, worker_admission_limit, worker_admission_active, worker_admission_pending, worker_admission_occupied, admission_rejection_rate, assignment_wait_p95, activation_duration_p95. Supply a comma-separated list. Allowed measurements: query_in_flight, worker_admission_limit, worker_admission_active, worker_admission_pending, worker_admission_occupied, admission_rejection_rate, assignment_wait_mean, assignment_wait_p95, activation_rate, activation_duration_mean, activation_duration_p95.", + "Up to eight distinct measurements. Defaults to `query_in_flight`, `worker_admission_limit`, `worker_admission_active`, `worker_admission_pending`, `worker_admission_occupied`, `admission_rejection_rate`, `assignment_wait_p95`, `activation_duration_p95`. Supply a comma-separated list. Allowed measurements: `query_in_flight`, `worker_admission_limit`, `worker_admission_active`, `worker_admission_pending`, `worker_admission_occupied`, `admission_rejection_rate`, `assignment_wait_mean`, `assignment_wait_p95`, `activation_rate`, `activation_duration_mean`, `activation_duration_p95`.", }, { name: "from", @@ -220,7 +220,7 @@ export const apiCommands = [ repeatable: false, required: false, description: - "Range start as an ISO timestamp, within the last 30 days. Requires to; cannot be combined with since.", + "Range start as an ISO 8601 timestamp with seconds and a time zone, for example `2026-11-18T09:30:00Z`, within the last 30 days. Requires `--to`; cannot be combined with `--since`.", }, { name: "interval", @@ -229,7 +229,7 @@ export const apiCommands = [ repeatable: false, required: false, description: - "Defaults to 1m. The effective step increases to stay within 1441 points per series. Rate and latency windows are at least 5m.", + "Defaults to `1m`. The effective step increases to stay within 1,441 points per series. Rate and latency windows are at least `5m`.", }, { name: "since", @@ -237,7 +237,7 @@ export const apiCommands = [ repeatable: false, required: false, description: - "Look back from server time, for example 30m, 2h, or 1d. Defaults to 30m when from/to are omitted. Maximum 30d. Cannot be combined with from/to.", + "Look back from server time, for example `30m`, `2h`, or `1d`. Defaults to `30m` when `--from`/`--to` are omitted. Maximum `30d`. Cannot be combined with `--from`/`--to`.", }, { name: "to", @@ -245,7 +245,7 @@ export const apiCommands = [ repeatable: false, required: false, description: - "Range end as an ISO timestamp, no later than server time. Requires from; cannot be combined with since. The service tolerates up to 60 seconds of request delay or clock skew.", + "Range end as an ISO 8601 timestamp with seconds and a time zone, for example `2026-11-18T09:30:00Z`, no later than server time. Requires `--from`; cannot be combined with `--since`. The service tolerates up to 60 seconds of request delay or clock skew.", }, ], bindings: [ diff --git a/packages/api/scripts/openapi-overrides.json b/packages/api/scripts/openapi-overrides.json index 19a84664e2..e5cd825c21 100644 --- a/packages/api/scripts/openapi-overrides.json +++ b/packages/api/scripts/openapi-overrides.json @@ -3018,19 +3018,7 @@ "admission_rejection_rate", "assignment_wait_mean", "assignment_wait_p95", - "duckdb_duration_mean", - "query_canceled_rate", - "query_duration_mean", - "query_duration_p50", - "query_duration_p95", - "query_duration_p99", - "query_error_rate", "query_in_flight", - "query_rate", - "query_timeout_rate", - "rpc_duration_mean", - "rpc_duration_p95", - "rpc_rate", "worker_admission_active", "worker_admission_limit", "worker_admission_occupied", @@ -3054,19 +3042,7 @@ "admission_rejection_rate", "assignment_wait_mean", "assignment_wait_p95", - "duckdb_duration_mean", - "query_canceled_rate", - "query_duration_mean", - "query_duration_p50", - "query_duration_p95", - "query_duration_p99", - "query_error_rate", "query_in_flight", - "query_rate", - "query_timeout_rate", - "rpc_duration_mean", - "rpc_duration_p95", - "rpc_rate", "worker_admission_active", "worker_admission_limit", "worker_admission_occupied", @@ -3159,19 +3135,7 @@ "admission_rejection_rate", "assignment_wait_mean", "assignment_wait_p95", - "duckdb_duration_mean", - "query_canceled_rate", - "query_duration_mean", - "query_duration_p50", - "query_duration_p95", - "query_duration_p99", - "query_error_rate", "query_in_flight", - "query_rate", - "query_timeout_rate", - "rpc_duration_mean", - "rpc_duration_p95", - "rpc_rate", "worker_admission_active", "worker_admission_limit", "worker_admission_occupied", @@ -3200,11 +3164,11 @@ "path": "/paths/~1v2~1projects~1{ref}~1warehouse~1capacity", "value": { "get": { - "description": "Returns capacity, admission, assignment-wait, and activation measurements over a bounded time range, using the project\u2019s stored Warehouse placement. Use since or both from and to; the default is the last 30 minutes. Each measurement includes its definition, unit, aggregation, requested and effective ranges, rate_window_seconds, source-sample freshness, availability, coverage, and full series with dimension labels such as reason, kind, and result. Executor invocations in flight are distinct from worker admission grants. Occupied admission includes active plus pending grants. The configured admission limit does not imply an open gate or spare capacity. Missing, stale, and insufficient observations remain unavailable or null; they do not establish healthy or idle capacity. Point timestamps are evaluation times; last_sample_at is the original source-sample time. Rates and latency quantiles describe the effective rate window at each point, not the entire requested range. Each request returns up to eight measurements, and a failure of one measurement does not discard the other results. No raw queries or backend selectors are accepted.\n\nThis endpoint is currently in its **Alpha** stage.", + "description": "Returns capacity, admission, assignment-wait, and activation measurements over a bounded time range, using the project\u2019s stored Warehouse placement. Use `--since` or specify both `--from` and `--to`; the default is the last 30 minutes.\n\nEach measurement includes its definition, unit, aggregation, requested and effective ranges, `rate_window_seconds`, source-sample freshness, availability, coverage, and full series with dimension labels such as `reason`, `kind`, and `result`.\n\nExecutor invocations in flight are distinct from worker admission grants. Occupied admission includes active plus pending grants. The configured admission limit does not imply an open gate or spare capacity. Missing, stale, and insufficient observations remain unavailable or `null`; they do not establish healthy or idle capacity.\n\nPoint timestamps are evaluation times; `last_sample_at` is the original source-sample time. Rates and latency quantiles describe the effective rate window at each point, not the entire requested range.\n\nEach request returns up to eight measurements, and a failure of one measurement does not discard the other results. No raw queries or backend selectors are accepted.\n\nThis endpoint is currently in its **Alpha** stage.", "operationId": "v2-get-warehouse-capacity", "parameters": [ { - "description": "Up to eight distinct measurements. Defaults to query_in_flight, worker_admission_limit, worker_admission_active, worker_admission_pending, worker_admission_occupied, admission_rejection_rate, assignment_wait_p95, activation_duration_p95. Supply a comma-separated list. Allowed measurements: query_in_flight, worker_admission_limit, worker_admission_active, worker_admission_pending, worker_admission_occupied, admission_rejection_rate, assignment_wait_mean, assignment_wait_p95, activation_rate, activation_duration_mean, activation_duration_p95.", + "description": "Up to eight distinct measurements. Defaults to `query_in_flight`, `worker_admission_limit`, `worker_admission_active`, `worker_admission_pending`, `worker_admission_occupied`, `admission_rejection_rate`, `assignment_wait_p95`, `activation_duration_p95`. Supply a comma-separated list. Allowed measurements: `query_in_flight`, `worker_admission_limit`, `worker_admission_active`, `worker_admission_pending`, `worker_admission_occupied`, `admission_rejection_rate`, `assignment_wait_mean`, `assignment_wait_p95`, `activation_rate`, `activation_duration_mean`, `activation_duration_p95`.", "in": "query", "name": "attributes", "required": false, @@ -3213,7 +3177,7 @@ } }, { - "description": "Range start as an ISO timestamp, within the last 30 days. Requires to; cannot be combined with since.", + "description": "Range start as an ISO 8601 timestamp with seconds and a time zone, for example `2026-11-18T09:30:00Z`, within the last 30 days. Requires `--to`; cannot be combined with `--since`.", "in": "query", "name": "from", "required": false, @@ -3224,7 +3188,7 @@ } }, { - "description": "Defaults to 1m. The effective step increases to stay within 1441 points per series. Rate and latency windows are at least 5m.", + "description": "Defaults to `1m`. The effective step increases to stay within 1,441 points per series. Rate and latency windows are at least `5m`.", "in": "query", "name": "interval", "required": false, @@ -3247,7 +3211,7 @@ } }, { - "description": "Look back from server time, for example 30m, 2h, or 1d. Defaults to 30m when from/to are omitted. Maximum 30d. Cannot be combined with from/to.", + "description": "Look back from server time, for example `30m`, `2h`, or `1d`. Defaults to `30m` when `--from`/`--to` are omitted. Maximum `30d`. Cannot be combined with `--from`/`--to`.", "in": "query", "name": "since", "required": false, @@ -3257,7 +3221,7 @@ } }, { - "description": "Range end as an ISO timestamp, no later than server time. Requires from; cannot be combined with since. The service tolerates up to 60 seconds of request delay or clock skew.", + "description": "Range end as an ISO 8601 timestamp with seconds and a time zone, for example `2026-11-18T09:30:00Z`, no later than server time. Requires `--from`; cannot be combined with `--since`. The service tolerates up to 60 seconds of request delay or clock skew.", "in": "query", "name": "to", "required": false, diff --git a/packages/api/src/generated/contracts.ts b/packages/api/src/generated/contracts.ts index 12171cd818..cc2bbca132 100644 --- a/packages/api/src/generated/contracts.ts +++ b/packages/api/src/generated/contracts.ts @@ -14389,19 +14389,7 @@ export const V2GetWarehouseCapacityOutput = Schema.Struct({ "admission_rejection_rate", "assignment_wait_mean", "assignment_wait_p95", - "duckdb_duration_mean", - "query_canceled_rate", - "query_duration_mean", - "query_duration_p50", - "query_duration_p95", - "query_duration_p99", - "query_error_rate", "query_in_flight", - "query_rate", - "query_timeout_rate", - "rpc_duration_mean", - "rpc_duration_p95", - "rpc_rate", "worker_admission_active", "worker_admission_limit", "worker_admission_occupied", @@ -14420,19 +14408,7 @@ export const V2GetWarehouseCapacityOutput = Schema.Struct({ "admission_rejection_rate", "assignment_wait_mean", "assignment_wait_p95", - "duckdb_duration_mean", - "query_canceled_rate", - "query_duration_mean", - "query_duration_p50", - "query_duration_p95", - "query_duration_p99", - "query_error_rate", "query_in_flight", - "query_rate", - "query_timeout_rate", - "rpc_duration_mean", - "rpc_duration_p95", - "rpc_rate", "worker_admission_active", "worker_admission_limit", "worker_admission_occupied", @@ -14487,19 +14463,7 @@ export const V2GetWarehouseCapacityOutput = Schema.Struct({ "admission_rejection_rate", "assignment_wait_mean", "assignment_wait_p95", - "duckdb_duration_mean", - "query_canceled_rate", - "query_duration_mean", - "query_duration_p50", - "query_duration_p95", - "query_duration_p99", - "query_error_rate", "query_in_flight", - "query_rate", - "query_timeout_rate", - "rpc_duration_mean", - "rpc_duration_p95", - "rpc_rate", "worker_admission_active", "worker_admission_limit", "worker_admission_occupied", @@ -24347,7 +24311,7 @@ export const operationDefinitions = { v2GetWarehouseCapacity: { id: "v2GetWarehouseCapacity", description: - "Returns capacity, admission, assignment-wait, and activation measurements over a bounded time range, using the project’s stored Warehouse placement. Use since or both from and to; the default is the last 30 minutes. Each measurement includes its definition, unit, aggregation, requested and effective ranges, rate_window_seconds, source-sample freshness, availability, coverage, and full series with dimension labels such as reason, kind, and result. Executor invocations in flight are distinct from worker admission grants. Occupied admission includes active plus pending grants. The configured admission limit does not imply an open gate or spare capacity. Missing, stale, and insufficient observations remain unavailable or null; they do not establish healthy or idle capacity. Point timestamps are evaluation times; last_sample_at is the original source-sample time. Rates and latency quantiles describe the effective rate window at each point, not the entire requested range. Each request returns up to eight measurements, and a failure of one measurement does not discard the other results. No raw queries or backend selectors are accepted.\n\nThis endpoint is currently in its **Alpha** stage.", + "Returns capacity, admission, assignment-wait, and activation measurements over a bounded time range, using the project’s stored Warehouse placement. Use `--since` or specify both `--from` and `--to`; the default is the last 30 minutes.\n\nEach measurement includes its definition, unit, aggregation, requested and effective ranges, `rate_window_seconds`, source-sample freshness, availability, coverage, and full series with dimension labels such as `reason`, `kind`, and `result`.\n\nExecutor invocations in flight are distinct from worker admission grants. Occupied admission includes active plus pending grants. The configured admission limit does not imply an open gate or spare capacity. Missing, stale, and insufficient observations remain unavailable or `null`; they do not establish healthy or idle capacity.\n\nPoint timestamps are evaluation times; `last_sample_at` is the original source-sample time. Rates and latency quantiles describe the effective rate window at each point, not the entire requested range.\n\nEach request returns up to eight measurements, and a failure of one measurement does not discard the other results. No raw queries or backend selectors are accepted.\n\nThis endpoint is currently in its **Alpha** stage.", method: "GET", path: "/v2/projects/{ref}/warehouse/capacity", pathParams: ["ref"], diff --git a/packages/api/src/generated/openapi.json b/packages/api/src/generated/openapi.json index cf92d0d02a..11dab8f078 100644 --- a/packages/api/src/generated/openapi.json +++ b/packages/api/src/generated/openapi.json @@ -33556,11 +33556,11 @@ }, "/v2/projects/{ref}/warehouse/capacity": { "get": { - "description": "Returns capacity, admission, assignment-wait, and activation measurements over a bounded time range, using the project’s stored Warehouse placement. Use since or both from and to; the default is the last 30 minutes. Each measurement includes its definition, unit, aggregation, requested and effective ranges, rate_window_seconds, source-sample freshness, availability, coverage, and full series with dimension labels such as reason, kind, and result. Executor invocations in flight are distinct from worker admission grants. Occupied admission includes active plus pending grants. The configured admission limit does not imply an open gate or spare capacity. Missing, stale, and insufficient observations remain unavailable or null; they do not establish healthy or idle capacity. Point timestamps are evaluation times; last_sample_at is the original source-sample time. Rates and latency quantiles describe the effective rate window at each point, not the entire requested range. Each request returns up to eight measurements, and a failure of one measurement does not discard the other results. No raw queries or backend selectors are accepted.\n\nThis endpoint is currently in its **Alpha** stage.", + "description": "Returns capacity, admission, assignment-wait, and activation measurements over a bounded time range, using the project’s stored Warehouse placement. Use `--since` or specify both `--from` and `--to`; the default is the last 30 minutes.\n\nEach measurement includes its definition, unit, aggregation, requested and effective ranges, `rate_window_seconds`, source-sample freshness, availability, coverage, and full series with dimension labels such as `reason`, `kind`, and `result`.\n\nExecutor invocations in flight are distinct from worker admission grants. Occupied admission includes active plus pending grants. The configured admission limit does not imply an open gate or spare capacity. Missing, stale, and insufficient observations remain unavailable or `null`; they do not establish healthy or idle capacity.\n\nPoint timestamps are evaluation times; `last_sample_at` is the original source-sample time. Rates and latency quantiles describe the effective rate window at each point, not the entire requested range.\n\nEach request returns up to eight measurements, and a failure of one measurement does not discard the other results. No raw queries or backend selectors are accepted.\n\nThis endpoint is currently in its **Alpha** stage.", "operationId": "v2-get-warehouse-capacity", "parameters": [ { - "description": "Up to eight distinct measurements. Defaults to query_in_flight, worker_admission_limit, worker_admission_active, worker_admission_pending, worker_admission_occupied, admission_rejection_rate, assignment_wait_p95, activation_duration_p95. Supply a comma-separated list. Allowed measurements: query_in_flight, worker_admission_limit, worker_admission_active, worker_admission_pending, worker_admission_occupied, admission_rejection_rate, assignment_wait_mean, assignment_wait_p95, activation_rate, activation_duration_mean, activation_duration_p95.", + "description": "Up to eight distinct measurements. Defaults to `query_in_flight`, `worker_admission_limit`, `worker_admission_active`, `worker_admission_pending`, `worker_admission_occupied`, `admission_rejection_rate`, `assignment_wait_p95`, `activation_duration_p95`. Supply a comma-separated list. Allowed measurements: `query_in_flight`, `worker_admission_limit`, `worker_admission_active`, `worker_admission_pending`, `worker_admission_occupied`, `admission_rejection_rate`, `assignment_wait_mean`, `assignment_wait_p95`, `activation_rate`, `activation_duration_mean`, `activation_duration_p95`.", "in": "query", "name": "attributes", "required": false, @@ -33569,7 +33569,7 @@ } }, { - "description": "Range start as an ISO timestamp, within the last 30 days. Requires to; cannot be combined with since.", + "description": "Range start as an ISO 8601 timestamp with seconds and a time zone, for example `2026-11-18T09:30:00Z`, within the last 30 days. Requires `--to`; cannot be combined with `--since`.", "in": "query", "name": "from", "required": false, @@ -33580,7 +33580,7 @@ } }, { - "description": "Defaults to 1m. The effective step increases to stay within 1441 points per series. Rate and latency windows are at least 5m.", + "description": "Defaults to `1m`. The effective step increases to stay within 1,441 points per series. Rate and latency windows are at least `5m`.", "in": "query", "name": "interval", "required": false, @@ -33603,7 +33603,7 @@ } }, { - "description": "Look back from server time, for example 30m, 2h, or 1d. Defaults to 30m when from/to are omitted. Maximum 30d. Cannot be combined with from/to.", + "description": "Look back from server time, for example `30m`, `2h`, or `1d`. Defaults to `30m` when `--from`/`--to` are omitted. Maximum `30d`. Cannot be combined with `--from`/`--to`.", "in": "query", "name": "since", "required": false, @@ -33613,7 +33613,7 @@ } }, { - "description": "Range end as an ISO timestamp, no later than server time. Requires from; cannot be combined with since. The service tolerates up to 60 seconds of request delay or clock skew.", + "description": "Range end as an ISO 8601 timestamp with seconds and a time zone, for example `2026-11-18T09:30:00Z`, no later than server time. Requires `--from`; cannot be combined with `--since`. The service tolerates up to 60 seconds of request delay or clock skew.", "in": "query", "name": "to", "required": false, @@ -50953,19 +50953,7 @@ "admission_rejection_rate", "assignment_wait_mean", "assignment_wait_p95", - "duckdb_duration_mean", - "query_canceled_rate", - "query_duration_mean", - "query_duration_p50", - "query_duration_p95", - "query_duration_p99", - "query_error_rate", "query_in_flight", - "query_rate", - "query_timeout_rate", - "rpc_duration_mean", - "rpc_duration_p95", - "rpc_rate", "worker_admission_active", "worker_admission_limit", "worker_admission_occupied", @@ -50989,19 +50977,7 @@ "admission_rejection_rate", "assignment_wait_mean", "assignment_wait_p95", - "duckdb_duration_mean", - "query_canceled_rate", - "query_duration_mean", - "query_duration_p50", - "query_duration_p95", - "query_duration_p99", - "query_error_rate", "query_in_flight", - "query_rate", - "query_timeout_rate", - "rpc_duration_mean", - "rpc_duration_p95", - "rpc_rate", "worker_admission_active", "worker_admission_limit", "worker_admission_occupied", @@ -51094,19 +51070,7 @@ "admission_rejection_rate", "assignment_wait_mean", "assignment_wait_p95", - "duckdb_duration_mean", - "query_canceled_rate", - "query_duration_mean", - "query_duration_p50", - "query_duration_p95", - "query_duration_p99", - "query_error_rate", "query_in_flight", - "query_rate", - "query_timeout_rate", - "rpc_duration_mean", - "rpc_duration_p95", - "rpc_rate", "worker_admission_active", "worker_admission_limit", "worker_admission_occupied",