Skip to content

feat(cli): add warehouse replication commands - #7718

Merged
jgoux merged 3 commits into
feat/generated-warehouse-commandsfrom
bnjjj/warehouse-replication-commands
Nov 19, 2026
Merged

jgoux merged 3 commits into
feat/generated-warehouse-commandsfrom
bnjjj/warehouse-replication-commands

Conversation

@bnjjj

@bnjjj bnjjj commented Nov 19, 2026 •

Copy link
Copy Markdown

Adds experimental warehouse replication add, remove and resync commands on top of #7640.

All three use the generated request/runtime path and preserve the immediate API response. All support --dry-run as a local request preview, with no server-side dry-run contract. Resync has no idempotency, revision or wait flags.

The shared generator/runtime gains CLI policy for API impact descriptions in consent. Local previews use the existing shared behavior. No hand-written command handlers are added.

Depends on #7640 and the companion Management API endpoints.

@bnjjj
bnjjj marked this pull request as ready for review November 19, 2026 16:17
@bnjjj
bnjjj requested review from a team and supabase-oss as code owners November 19, 2026 16:17
@bnjjj
bnjjj requested review from Coly010 and removed request for a team November 19, 2026 16:17

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 AI Review

CLI reference prose guidance: snapshot supabase/supabase@4c4112f supplied to reviewers (advisory, not a style pass).

The PR adds experimental Warehouse replication commands. Both reviews identified two resync help errors. The help tells users to omit a required table selector and says there is no preview even though --dry-run previews the request locally. The success test uses responses that omit required fields, and the consent test checks warning text only after the command exits. The remaining findings are seven advisory CLI prose items and one formatting nit. Verification was static.

Findings

Severity Location Category Sources Claim
🟡 MINOR packages/api/scripts/openapi-overrides.json:3888 cli-help claude+codex Resync help and its interactive consent text say there is no preview, even though --dry-run previews the request locally.
🟡 MINOR packages/api/scripts/openapi-overrides.json:3353 cli-help claude+codex Resync's --schema help tells users to omit the required table selector.
🟡 MINOR apps/cli/src/commands/api/api-commands.integration.test.ts:326 test-coverage codex The replication success test uses a response fixture that violates the published result schema for each operation.
🟡 MINOR apps/cli/src/commands/api/api-commands.integration.test.ts:2528 test-coverage codex The resync consent test would still pass if the rebuild warning appeared after the user answered the prompt.
⚪ NIT apps/cli/src/commands/api/api-command-policy.ts:47 docs-style codex The replication group description uses a vague verb where it could name the available actions.
⚪ NIT apps/cli/src/commands/api/generated.ts:412 docs-style codex Replication help uses PostgreSQL in prose where the guide calls for Postgres.
⚪ NIT apps/cli/src/commands/api/generated.ts:393 docs-style codex Each replication command puts selector behavior, operational effects, and response caveats in one long paragraph.
⚪ NIT apps/cli/src/commands/api/generated.ts:452 docs-style codex The remove description obscures what stays unchanged and what restart acceptance establishes.
⚪ NIT apps/cli/src/commands/api/generated.ts:511 docs-style codex The resync description leaves both follow-up command names unformatted.
⚪ NIT apps/cli/src/commands/api/generated.ts:393 docs-style codex The replication descriptions use may for uncertain outcomes.
⚪ NIT apps/cli/src/commands/api/generated.ts:511 docs-style codex The resync description uses a redundant time qualifier for the saved layout.
⚪ NIT apps/cli/src/commands/api/generated.ts:511 docs-style codex The resync description omits the serial comma in its list of what the reset preserves.
⚪ NIT packages/api/scripts/openapi-overrides.json:2549 formatting codex The PR changes how the apostrophe is encoded in two unrelated Warehouse metrics descriptions.

Stats

Claude findings: 2 · Codex findings: 13 · Confirmed: 13 · Refuted: 0 · Uncertain: 0


Models: claude-opus-5-5 + gpt-6.2-sol · Trigger: auto · Workflow run

This review runs once per PR. A maintainer can request another with a /ai-review comment.

"path": "/paths/~1v2~1projects~1{ref}~1warehouse~1replication~1resync",
"value": {
"post": {
"description": "Resets replication for one selected source table using its currently saved layout. Source rows, saved layouts and completed replication state for unrelated tables are preserved. In-progress initial copies of other tables may restart from scratch. The Warehouse copy is deleted and rebuilt when replication resumes; table reads may be unavailable, freshness can lag, and the source incurs additional reads. Stopping and restarting the pipeline interrupts replication for other tables. Duration is unknown. The pipeline must be started and initial sync enabled for the table before the reset. The immediate response retains ETL reset states; it does not establish recopy completion. Inspect warehouse tables get and warehouse status separately. Do not automatically retry an uncertain response: repeating this request may reset the table again. There is no preview, revision check, idempotency key or operation polling.\n\nThis endpoint is currently in its **Alpha** stage.",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 MINOR · cli-help · source: claude+codex

Resync help and its interactive consent text say there is no preview, even though --dry-run previews the request locally.

Evidence: The override at line 3888 and apps/cli/src/commands/api/generated.ts:511 say “There is no preview, revision check, idempotency key or operation polling.” The command enables confirmDescription at generated.ts:513. The runtime prints a local request preview at runtime.ts:226–229 and supplies the description to consent at runtime.ts:231–238. The resync case in api-commands.integration.test.ts:1543–1565 checks the preview and expects zero requests.

Suggested fix: Qualify the OpenAPI description with “There is no server-side preview” and regenerate the CLI artifacts.

"additionalProperties": false,
"properties": {
"schema": {
"description": "Literal source PostgreSQL schema. Omit table to select its current tables.",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 MINOR · cli-help · source: claude+codex

Resync's --schema help tells users to omit the required table selector.

Evidence: The override at line 3353 and apps/cli/src/commands/api/generated.ts:530 say “Omit table to select its current tables.” The override requires both schema and table at line 3363, and generated.ts:536 marks the table field as required.

Suggested fix: Use “Literal name of the source Postgres schema containing the table to resync.” Regenerate the CLI artifacts.

Comment on lines +326 to +339
const attributes =
action === "resync"
? {
pipeline_id: "101",
tables: [{ table_id: 42, new_state: { name: "queued" } }],
application_status: "reset",
}
: {
pipeline_id: "101",
application_status: "restart_requested",
tables: [],
changed: true,
};
const body = { data: { type, id: "101", attributes } };

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 MINOR · test-coverage · source: codex

The replication success test uses a response fixture that violates the published result schema for each operation.

Evidence: The fixtures at lines 326–339 all omit source_data_preserved. The resync schema also requires source_table at apps/cli/src/commands/api/generated.schemas.ts:2738–2744. The add and remove schemas require selected_table_count and unchanged_tables among other fields at generated.schemas.ts:185–199 and :2504–2518. The assertion at line 365 checks that the CLI echoes the fixture.

Suggested fix: Supply a schema-conformant HTTP 202 response for each operation and keep the full JSON equality assertion.

Comment on lines +2528 to +2535
Effect.onExit(() =>
Effect.sync(() => {
if (out.promptConfirmCalls.length > 0) {
expect(out.stderrText).toContain("deleted and rebuilt");
expect(out.stderrText).toContain("interrupts replication for other tables");
}
}),
),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 MINOR · test-coverage · source: codex

The resync consent test would still pass if the rebuild warning appeared after the user answered the prompt.

Evidence: Lines 2528–2535 read accumulated stderr in Effect.onExit. The mock records the prompt and returns its answer at apps/cli/tests/helpers/mocks.ts:429–444. apps/cli/scripts/api-command-reference.ts:154 promises that the description prints before interactive confirmation.

Suggested fix: Capture stderr when the fake confirmation prompt is entered and assert that the rebuild and replication interruption warnings are already present.

description: "Manage the data warehouse for a project",
feature: "warehouse",
groups: {
replication: "Manage Warehouse replication selections and rebuilds",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚪ NIT · docs-style · source: codex

The replication group description uses a vague verb where it could name the available actions.

Evidence: Line 47 says “Manage Warehouse replication selections and rebuilds”. The guide asks writers to name concrete operations in place of broad verbs such as “manage”. https://github.com/supabase/supabase/blob/4c4112fa1fda81ef36a0f32580f7766e2eca2f9c/apps/docs/style-guide/01-voice-and-tone.md#be-specific-and-concrete

Suggested fix: Use “Add tables to Warehouse replication, remove them from replication, or rebuild their Warehouse copies”.

Comment thread apps/cli/src/commands/api/generated.ts Outdated
apiPath: "/v2/projects/{ref}/warehouse/replication/resync",
summary: "Reset and rebuild one Warehouse table",
description:
"Resets replication for one selected source table using its currently saved layout. Source rows, saved layouts and completed replication state for unrelated tables are preserved. In-progress initial copies of other tables may restart from scratch. The Warehouse copy is deleted and rebuilt when replication resumes; table reads may be unavailable, freshness can lag, and the source incurs additional reads. Stopping and restarting the pipeline interrupts replication for other tables. Duration is unknown. The pipeline must be started and initial sync enabled for the table before the reset. The immediate response retains ETL reset states; it does not establish recopy completion. Inspect warehouse tables get and warehouse status separately. Do not automatically retry an uncertain response: repeating this request may reset the table again. There is no preview, revision check, idempotency key or operation polling.",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚪ NIT · docs-style · source: codex

The resync description leaves both follow-up command names unformatted.

Evidence: Line 511 says “Inspect warehouse tables get and warehouse status separately.” The guide calls for code formatting for literal commands. https://github.com/supabase/supabase/blob/4c4112fa1fda81ef36a0f32580f7766e2eca2f9c/apps/docs/style-guide/02-elements.md#use-bold-italics-and-code-for-distinct-purposes

Suggested fix: Use “Inspect warehouse tables get and warehouse status separately.”

apiPath: "/v2/projects/{ref}/warehouse/replication/add",
summary: "Add source tables to Warehouse replication",
description:
"Adds one eligible source table or the currently eligible tables in a schema to an enabled Warehouse. Existing selections and layouts are preserved; already-selected tables are unchanged. Schema selection excludes future tables, except future partitions of selected partition roots. An active pipeline restarts once, interrupting replication for other tables; their in-progress initial copies may restart from scratch. A stopped pipeline remains stopped and requires an explicit start before copying. Initial copy adds source reads; duration is unknown. Unsafe reattachment of retained data is rejected. The response describes configuration and restart acceptance, not completed copy or streaming. Failures may have partial effects; inspect table and pipeline state before retrying.",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚪ NIT · docs-style · source: codex

The replication descriptions use may for uncertain outcomes.

Evidence: Lines 393 and 452 say copies “may restart from scratch” and failures “may have partial effects”. Line 511 also says “table reads may be unavailable” and repeating the request “may reset the table again”. The word list uses might for uncertain outcomes. https://github.com/supabase/supabase/blob/4c4112fa1fda81ef36a0f32580f7766e2eca2f9c/apps/docs/style-guide/WORD_LIST.md#can-may-might-must-and-should

Suggested fix: Use “might restart from scratch”, “might have partial effects”, “table reads might be unavailable”, and “might reset the table again”.

Comment thread apps/cli/src/commands/api/generated.ts Outdated
apiPath: "/v2/projects/{ref}/warehouse/replication/resync",
summary: "Reset and rebuild one Warehouse table",
description:
"Resets replication for one selected source table using its currently saved layout. Source rows, saved layouts and completed replication state for unrelated tables are preserved. In-progress initial copies of other tables may restart from scratch. The Warehouse copy is deleted and rebuilt when replication resumes; table reads may be unavailable, freshness can lag, and the source incurs additional reads. Stopping and restarting the pipeline interrupts replication for other tables. Duration is unknown. The pipeline must be started and initial sync enabled for the table before the reset. The immediate response retains ETL reset states; it does not establish recopy completion. Inspect warehouse tables get and warehouse status separately. Do not automatically retry an uncertain response: repeating this request may reset the table again. There is no preview, revision check, idempotency key or operation polling.",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚪ NIT · docs-style · source: codex

The resync description uses a redundant time qualifier for the saved layout.

Evidence: Line 511 says “using its currently saved layout”. The word list asks writers to state present behavior directly and avoid currently when it adds no meaning. https://github.com/supabase/supabase/blob/4c4112fa1fda81ef36a0f32580f7766e2eca2f9c/apps/docs/style-guide/WORD_LIST.md#currently

Suggested fix: Use “using its saved layout”.

Comment thread apps/cli/src/commands/api/generated.ts Outdated
apiPath: "/v2/projects/{ref}/warehouse/replication/resync",
summary: "Reset and rebuild one Warehouse table",
description:
"Resets replication for one selected source table using its currently saved layout. Source rows, saved layouts and completed replication state for unrelated tables are preserved. In-progress initial copies of other tables may restart from scratch. The Warehouse copy is deleted and rebuilt when replication resumes; table reads may be unavailable, freshness can lag, and the source incurs additional reads. Stopping and restarting the pipeline interrupts replication for other tables. Duration is unknown. The pipeline must be started and initial sync enabled for the table before the reset. The immediate response retains ETL reset states; it does not establish recopy completion. Inspect warehouse tables get and warehouse status separately. Do not automatically retry an uncertain response: repeating this request may reset the table again. There is no preview, revision check, idempotency key or operation polling.",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚪ NIT · docs-style · source: codex

The resync description omits the serial comma in its list of what the reset preserves.

Evidence: Line 511 says “Source rows, saved layouts and completed replication state for unrelated tables are preserved.” The guide uses the Oxford comma in a three-item series. https://github.com/supabase/supabase/blob/4c4112fa1fda81ef36a0f32580f7766e2eca2f9c/apps/docs/style-guide/01-voice-and-tone.md#use-the-oxford-comma

Suggested fix: Use “Source rows, saved layouts, and completed replication state for unrelated tables are preserved.”

"value": {
"get": {
"description": "Returns aggregate workload 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, and full series with dimension labels. 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. Do not average interval percentiles into a whole-range percentile. Executor invocations include metadata/schema work and are not counts of user SQL statements. Timeouts are included in errors; cancellation is separate. Missing and unavailable values remain null. No query history, individual-query attribution, raw queries, or backend selectors are exposed. Each request returns up to eight measurements. A failure of one measurement does not discard the other results.\n\nThis endpoint is currently in its **Alpha** stage.",
"description": "Returns aggregate workload 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, and full series with dimension labels. 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. Do not average interval percentiles into a whole-range percentile. Executor invocations include metadata/schema work and are not counts of user SQL statements. Timeouts are included in errors; cancellation is separate. Missing and unavailable values remain null. No query history, individual-query attribution, raw queries, or backend selectors are exposed. Each request returns up to eight measurements. A failure of one measurement does not discard the other results.\n\nThis endpoint is currently in its **Alpha** stage.",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚪ NIT · formatting · source: codex

The PR changes how the apostrophe is encoded in two unrelated Warehouse metrics descriptions.

Evidence: Lines 2549 and 2941 replace project’s with project\u2019s in the query-stats and capacity descriptions. JSON decoding gives identical strings for each before-and-after pair.

Suggested fix: Restore the literal apostrophe in both descriptions.

Explain each new OpenAPI override in a $comment, cover the add and remove
commands in the hosted-consent matrix and snapshot, and correct the resync
selector and preview help text.
@jgoux

jgoux commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

I pushed b17044a to fix the issues I found in review:

  • Override validation: each of the seven new openapi-overrides.json entries now has a $comment, which parseOpenApiOverrides requires. Before this, loading the overrides failed, and so did the "accepts the committed overrides file" test.
  • Consent coverage: warehouse replication add and warehouse replication remove now have describeHostedConsent matrices, and the consent-defaults snapshot lists all three replication commands as no. Before this, hosted-consent-coverage.unit.test.ts failed.
  • Resync --schema help: the field now has its own description ("Literal source PostgreSQL schema of the table."). It previously told users to omit the table, which resync requires.
  • Resync description: it now says "no server-side preview" rather than "no preview", because the CLI offers --dry-run and the description appears in the confirmation prompt.

I regenerated the files from the current spec and left out unrelated upstream drift, so only these descriptions changed in the generated output.

@jgoux
jgoux merged commit 4e0635a into feat/generated-warehouse-commands Nov 19, 2026
12 checks passed
@jgoux
jgoux deleted the bnjjj/warehouse-replication-commands branch November 19, 2026 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants