Skip to content

fix(ingestion): R24e — drop ingestion_job_stages.job_id FK (resolve drift #8) - #386

Closed
BigSimmo wants to merge 1 commit into
mainfrom
claude/ingestion-r24e-stage-fk
Closed

fix(ingestion): R24e — drop ingestion_job_stages.job_id FK (resolve drift #8)#386
BigSimmo wants to merge 1 commit into
mainfrom
claude/ingestion-r24e-stage-fk

Conversation

@BigSimmo

Copy link
Copy Markdown
Owner

Resolves drift-reconciliation backlog item #8 in the direction the live evidence supports — the opposite of the earlier "add the FK to live" plan. Follow-up to the RPC hardening merged in #380; both are phase-3 concurrency work off docs/ingestion-state-machine.md (R24e).

Evidence (read-only live catalog, project sjrfecxgysukkwxsowpy):

  • Live never had this FK — it exists only in schema.sql + the migration chain, so fresh/preview databases diverge from live.
  • The edge agent's stageStart writes an indexing_v3_agent_jobs id into job_id (never an ingestion_jobs id), so on any DB where the FK exists the agent's artifact-repair path dies at its first stage insert (FK 23503).
  • Live carries 253 orphan stage rows whose job_id has no ingestion_jobs match — NOT VALID + VALIDATE would fail against them.

Change:

  • schema.sql: ingestion_job_stages.job_id is a plain not null column (documented as an intentional non-FK correlation id).
  • Migration 20260708140000: drop constraint if exists — no-op on live, removes it on the branch/preview migration chain.
  • drift-allowlist.json: remove the now-obsolete FK entry (schema.sql matches live).
  • database-drift-detection.md: backlog item Bump gitleaks/gitleaks-action from 2 to 3 #8 marked resolved.
  • supabase-schema.test.ts: assert the FK is absent; drift manifest regenerated.

Verified: vitest drift-detection + supabase-schema (52) + ingestion ✅, eslint ✅, drift manifest regenerated ✅. Migration apply to live is an operator step (linked supabase CLI workflow).

Refs #380#377#342
🤖 Generated with Claude Code

…rift #8)
Live evidence, not the backlog's add-the-FK plan: live never had this FK, the
edge agent writes an indexing_v3_agent_jobs id into job_id (never satisfies a FK
to ingestion_jobs), and live carries 253 orphan stage rows that would fail
VALIDATE. Removing the FK makes fresh/preview databases match live and unbreaks
the agent's artifact-repair path there.
- schema.sql: ingestion_job_stages.job_id is a plain not-null column (documented)
- migration 20260708140000: drop constraint if exists (no-op on live; removes it
on the branch/preview migration chain)
- drift-allowlist: remove the now-obsolete FK entry (schema.sql matches live)
- database-drift-detection.md: mark backlog item #8 resolved with rationale
- supabase-schema.test: assert the FK is absent from schema.sql
- drift manifest regenerated (clean scratch replay)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@supabase

supabaseBot commented Jul 8, 2026

Copy link
Copy Markdown

Updates to Preview Branch (claude/ingestion-r24e-stage-fk) ↗︎

DeploymentsStatusUpdated
DatabaseWed, 08 Jul 2026 07:25:30 UTC
ServicesWed, 08 Jul 2026 07:25:30 UTC
APIsWed, 08 Jul 2026 07:25:30 UTC

Tasks are run on every commit but only new migration files are pushed.
Close and reopen this PR if you want to apply changes from existing seed or migration files.

TasksStatusUpdated
ConfigurationsWed, 08 Jul 2026 07:25:38 UTC
MigrationsWed, 08 Jul 2026 07:26:28 UTC
SeedingWed, 08 Jul 2026 07:26:32 UTC
Edge FunctionsWed, 08 Jul 2026 07:26:33 UTC

View logs for this Workflow Run ↗︎.
Learn more about Supabase for Git ↗︎.

@chatgpt-codex-connectorchatgpt-codex-connectorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit:34740f6dce

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment threadsupabase/schema.sql
@BigSimmo
BigSimmo enabled auto-merge (squash) July 8, 2026 08:05
@BigSimmoClaude

Copy link
Copy Markdown
OwnerAuthor

Superseded by #389 — same R24e fix (drop the phantom ingestion_job_stages.job_id FK), rebased on latest main (this branch was 8 commits behind and used a different migration filename at the same 20260708140000 timestamp, which would collide). Closing as a duplicate; no content is lost. See #389 for the canonical version.


Generated by Claude Code

@BigSimmo

Copy link
Copy Markdown
OwnerAuthor

Closed after #389 merged the overlapping R24e FK drop. The Codex retry-target fix that landed on this branch was re-opened as #395.

Sign up for freeto 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

@BigSimmo