Skip to content

chore(api): drop deprecated patch_policies.sources column (#3151) - #3154

Draft
ToddHebebrand wants to merge 15 commits into
mainfrom
chore/3151-drop-patch-policies-sources
Draft

chore(api): drop deprecated patch_policies.sources column (#3151)#3154
ToddHebebrand wants to merge 15 commits into
mainfrom
chore/3151-drop-patch-policies-sources

Conversation

@ToddHebebrand

Copy link
Copy Markdown
Collaborator

Summary

Contract phase of the third-party update ring auto-approve expand/contract plan (docs/superpowers/specs/vuln-patch/2026-08-04-third-party-update-ring-auto-approve-design.md). The expand phase (#3150) removed every reader and writer of patch_policies.sources; this PR drops the column itself.

  • Migration 2026-08-14-drop-patch-policies-sources.sql: ALTER TABLE patch_policies DROP COLUMN IF EXISTS sources; — idempotent, no inner transaction. Named -14- (not today's date) so it sorts after the existing 2026-08-13 ring backfill migration from feat(patching): third-party auto-approval as a first-class Update Ring control #3150.
  • Schema: removed the deprecated sources column definition + deprecation comment from apps/api/src/db/schema/patches.ts (patchSourceEnum itself stays — still used by patches.source).
  • Dead strips removed: with the column gone from the schema, a full-row select can no longer return a sources key, so the defensive const { sources: _sources, ...rest } strips in routes/updateRings.ts (detail endpoint) and services/aiToolsPolicyPrereqs.ts (manage_update_rings get) are removed. Tests updated accordingly; the not.toHaveProperty('sources') response assertions are kept as regression guards.
  • No cascade/export-registry changes needed: patch_policies is partner-owned (no org_id, no device_id), so it appears in none of the cascade or export-policy lists.

⚠️ MERGE GATE — do not merge yet

Verification

  • pnpm db:check-drift: clean for this change (my migration applies and schema matches; the only remaining local drift entries are sibling-branch migrations in the shared local DB ledger, pre-existing).
  • Column confirmed dropped in local Postgres after pnpm db:migrate.
  • tsc --noEmit clean in apps/api.
  • Affected tests green single-worker (120 passed): updateRings_detail_update_delete, updateRings_list_create, updateRings_patches_compliance_scope, db/autoMigrate, services/aiToolsPolicyPrereqs.
  • Repo-wide grep: no remaining readers/writers of patchPolicies.sources / patch_policies.sources.

Closes #3151

🤖 Generated with Claude Code

Todd Hebebrand and others added 15 commits August 4, 2026 14:22
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…DeferralDays

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…losed deferral/severity parsing

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…d drop the third_party_app virtual category

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…es the severity exemption

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ing, reject third_party_app rules

Ring create/update routes now flow autoApprove.thirdPartyApps and
thirdPartyDeferralDays through to the DB (ringAutoApproveSchema already
validates them). Removes the dead createRingSchema/updateRingSchema
sources field, the list-select and insert/update sources plumbing on
patch_policies (expand/contract: DROP COLUMN ships a release later),
and rejects third_party_app category rules at the write boundary in
favor of the ring-level toggle.

patchPolicies.sources still has one other reader, aiToolsPolicyPrereqs.ts
(Task 7's job to remove) — tsc --noEmit does not flag it since selecting
a still-existing column isn't a type error.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Code review on Task 5 caught that GET /update-rings/:id still leaked
patchPolicies.sources — its full-row select spreads the raw DB row
into the JSON response, unlike the list endpoint's explicit column
projection. Destructure `sources` out before the response spread
instead of hand-projecting all ~20 remaining columns (that select
also feeds the partnerId access check and every other detail field).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…pp category rules

Fixes over the initial version per review: statement 2 no longer
overwrites an explicit thirdPartyApps key set via the new UI (a stale
legacy third_party_app rule now falls through to statement 3, which
strips it without touching auto_approve); statement 1 only stamps
thirdPartyDeferralDays when absent; statement 2's deferralDaysOverride
parse is bounded to 0-365 to match the evaluator's read-time bound and
avoid an integer-overflow abort on a huge digit string.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…urces

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
… trip

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Adds an "Auto-approve" column to the Update Rings table summarizing each
ring's gate as badges (OS severities, 3rd-party apps, or Manual), and a
hint under the PatchTab third-party sources toggle pointing techs at the
linked Update Ring for auto-approval rules.

Bumps the de-DE/es-419/pt-BR patches.json exact-English duplicate
baselines by one each: "Manual" and "OS: {{severities}}" are legitimately
identical in those locales.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…pp category rules

Fixes over the initial version per review: statement 2 no longer
overwrites an explicit thirdPartyApps key set via the new UI (a stale
legacy third_party_app rule now falls through to statement 3, which
strips it without touching auto_approve); statement 1 only stamps
thirdPartyDeferralDays when absent; statement 2's deferralDaysOverride
parse is bounded to 0-365 to match the evaluator's read-time bound and
avoid an integer-overflow abort on a huge digit string.

Second review pass: statement 2 was flipping enabled:true on a ring
whose OS auto-approve was previously off, silently carrying forward
its stored severities as if OS auto-approve had been on all along —
now clears severities to [] whenever the pre-image wasn't already
boolean-true enabled, so a disabled OS state survives the ring-level
enable. Added a comment documenting the accepted narrowing where an
already-enabled ring with empty severities loses rule-based 3P intent
(fail-closed, 0 known rows), and a comment in
migrateToConfigPolicies.ts flagging that its hardcoded sources:['os']
is safe only because the script is a retained one-shot, not a
repeatable sync.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contract phase of the third-party update ring auto-approve expand/contract
plan (spec 2026-08-04). The expand phase (#3150) removed every reader and
writer of patch_policies.sources; this drops the column itself, removes the
deprecated schema definition, and deletes the now-dead response strips in
the ring detail route and the manage_update_rings AI tool (a full-row
select can no longer return a sources key).

Must not merge until the release containing #3150 has shipped to both prod
regions, so rolling deploys never run an older API against the dropped
column.

Closes #3151

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 5, 2026

Copy link
Copy Markdown

Deploying breeze with  Cloudflare Pages  Cloudflare Pages

Latest commit: b72c9e4
Status: ✅  Deploy successful!
Preview URL: https://bf43b87f.breeze-9te.pages.dev
Branch Preview URL: https://chore-3151-drop-patch-polici.breeze-9te.pages.dev

View logs

@ToddHebebrand

Copy link
Copy Markdown
Collaborator Author

Heads-up from the base branch: 10fb309 on ToddHebebrand/3rd-party-patch-update-rings restored the primary.sources read in apps/api/src/scripts/migrateToConfigPolicies.ts (the hardcoded ['os'] silently dropped a not-yet-migrated partner's third-party opt-in on first run). That means this PR's schema-column removal now breaks that script at compile time — it needs to be handled here in the same change (snapshot-read via raw SQL, drop the read behind a column-existence check, or delete the script). Issue #3151's checklist has been updated accordingly.

🤖 Generated with Claude Code

Base automatically changed from ToddHebebrand/3rd-party-patch-update-rings to main August 5, 2026 21:43
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