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

@BigSimmo BigSimmo commented Jul 8, 2026

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

supabase Bot commented Jul 8, 2026

Copy link
Copy Markdown

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

Deployments Status Updated
Database Wed, 08 Jul 2026 07:25:30 UTC
Services Wed, 08 Jul 2026 07:25:30 UTC
APIs Wed, 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.

Tasks Status Updated
Configurations Wed, 08 Jul 2026 07:25:38 UTC
Migrations Wed, 08 Jul 2026 07:26:28 UTC
Seeding Wed, 08 Jul 2026 07:26:32 UTC
Edge Functions Wed, 08 Jul 2026 07:26:33 UTC

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

@chatgpt-codex-connector chatgpt-codex-connector Bot 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 thread supabase/schema.sql
@BigSimmo
BigSimmo enabled auto-merge (squash) July 8, 2026 08:05

BigSimmo commented Jul 8, 2026

Copy link
Copy Markdown
Owner Author

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

BigSimmo commented Jul 8, 2026

Copy link
Copy Markdown
Owner Author

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 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