Skip to content

refactor(cli): single-source the shadow webhooks policy on the setup input - #6221

Open
avallete wants to merge 1 commit into
avallete/shadow-cache-squash-pgadminfrom
avallete/shadow-webhooks-policy-coupling
Open

refactor(cli): single-source the shadow webhooks policy on the setup input#6221
avallete wants to merge 1 commit into
avallete/shadow-cache-squash-pgadminfrom
avallete/shadow-webhooks-policy-coupling

Conversation

@avallete

@avallete avallete commented Aug 16, 2026

Copy link
Copy Markdown
Member

Stacked on #6220 (avallete/shadow-cache-squash-pgadmin).

Summary

The shadow-baseline cache key and the provisioned baseline previously expressed the Webhooks/pg_net policy independently: callers passed LegacyShadowCacheOpts.webhooks for the key, while the use phase picked a provisioner that applied its own policy (legacyMigrateShadowDatabase forced "enabled", legacyMigrateNextShadowDatabase followed config, legacySetupShadowDatabase took caller options). Nothing enforced agreement — three of five call sites had drifted before #6220 re-aligned them by hand, and nothing stopped a sixth call site from drifting again.

This makes that drift class unrepresentable. LegacyShadowDbSetupInput now carries a required webhooks: LegacyShadowWebhooksPolicy field that BOTH the cache-key resolution (shadow-cache.ts) and every baseline provisioner read, so a published snapshot's key can never describe a different baseline than the one actually provisioned.

The old parallel surfaces are deleted outright (no shims):

  • LegacyShadowCacheOpts.webhooks
  • legacyMigrateNextShadowDatabase — one migrate function remains, reading the input's policy
  • the LegacySetupDatabaseOptions params on legacyOpenShadowBaselineSession / legacySetupShadowDatabase
  • legacyPrepareShadowSource's migrate dispatch and the pg-delta-next layer's webhooks-carrying cacheOpts

The per-engine semantics — legacy migra/pg-delta engines force pg_net on (Go parity), pg-delta next follows config — are named exactly once, in legacyShadowSourceWebhooksPolicy(migrationMode), which db diff/db pull use when building their shadow inputs. pgAdmin, migration squash, the catalog exports, and pg-delta next's migrations/declarative shadows state their fixed policies at input construction, each with the rationale in place. The two raw-shadow sites (db pull's legacy declarative export, declarative.orchestrate.ts) pass an explicitly inert "config" — they never run a baseline or touch the cache.

Effective policies, cache keys, and provisioned SQL are unchanged at every call site.

…input

The shadow-baseline cache key and the provisioned baseline previously
expressed the Webhooks/pg_net policy independently: callers passed
LegacyShadowCacheOpts.webhooks for the key while the use phase picked a
provisioner that applied its own policy (legacyMigrateShadowDatabase
forced "enabled", legacyMigrateNextShadowDatabase followed config,
legacySetupShadowDatabase took caller options). Nothing enforced
agreement, and three of five call sites had drifted before the previous
commit re-aligned them by hand.

Make that drift class unrepresentable: LegacyShadowDbSetupInput now
carries a required webhooks policy that BOTH the cache-key resolution
and every baseline provisioner read, so a published snapshot's key can
never describe a different baseline than the one provisioned. The old
parallel surfaces are deleted outright: LegacyShadowCacheOpts.webhooks,
legacyMigrateNextShadowDatabase (one migrate function remains), the
LegacySetupDatabaseOptions params on legacyOpenShadowBaselineSession/
legacySetupShadowDatabase, and legacyPrepareShadowSource's migrate
dispatch. The per-engine semantics — legacy migra/pg-delta force pg_net
on (Go parity), pg-delta next follows config — are named once in
legacyShadowSourceWebhooksPolicy(migrationMode), which db diff/db pull
use when building their shadow inputs; pgadmin, squash, the catalog
exports, and pg-delta next's shadows state their fixed policies at
input construction. Effective policies, cache keys, and provisioned SQL
are unchanged at every call site.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@avallete
avallete requested a review from a team as a code owner August 16, 2026 12:51
@avallete avallete changed the title avallete/shadow webhooks policy coupling refactor(cli): single-source the shadow webhooks policy on the setup input Aug 16, 2026
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.

1 participant