Skip to content

fix: surface and recover stranded uploads#1152

Merged
BigSimmo merged 3 commits into
mainfrom
codex/stranded-upload-recovery
Jul 24, 2026
Merged

fix: surface and recover stranded uploads#1152
BigSimmo merged 3 commits into
mainfrom
codex/stranded-upload-recovery

Conversation

@BigSimmo

Copy link
Copy Markdown
Owner

Summary

  • detect aged owner-scoped queued documents with no pending/processing ingestion job in reindex:health
  • make the six-hour ingestion autopilot open/update a durable alert when recoverable work is detected, while remaining read-only by default
  • include stranded rows in the existing guarded manual recovery path
  • enqueue approved recovery through PR fix: serialize reindex with active enrichment #1143's transactional owner-scoped RPC instead of the older multi-call helper

RAG impact: no retrieval behaviour change — this affects ingestion health detection and queue recovery only; retrieval, ranking, generation and source rendering are unchanged.

Verification

  • red proof: 4 focused failures before implementation (atomic RPC, ownerless fail-closed, stranded health assessment, scheduled alert wiring)
  • npx vitest run tests/stranded-queued-recovery.test.ts tests/ingestion-autopilot.test.ts tests/ingestion-recovery.test.ts tests/supabase-schema.test.ts --maxWorkers=1 — 98/98 passed
  • npm run typecheck
  • scoped ESLint and Prettier
  • npm run check:github-actions
  • npm run check:ci-scope
  • production-readiness script — READY for Clinical KB Database (sjrfecxgysukkwxsowpy); configuration-only, no API request
  • exact-head hosted required checks — pending

verify:pr-local dry-run selected runtime, format, lint, typecheck, full unit, build and offline RAG fixtures. The smallest affected tests and static gates were run locally; exact-head hosted CI remains the broad landing gate.

UI verification not run: no UI, routing, styling or browser behavior changed. No live Supabase query/mutation, OpenAI/Railway call, RAG evaluation or deployment was run.

Risk and rollout

  • Risk: low-to-medium. Scheduled behavior adds read-only queries and an issue alert when recoverable work exists; production queue mutation remains behind the existing repository variable plus manual apply=true dispatch.
  • Rollback: revert this commit. Existing manual recovery remains available; no schema or data rollback is required.
  • Provider or production effects: after merge, the scheduled workflow performs bounded read-only detection and may create/update the existing ingestion-autopilot GitHub issue. It does not mutate Supabase automatically.

Clinical Governance Preflight

  • Source-backed claims still require linked source verification before clinical use
  • No patient-identifiable document workflow was introduced or expanded without explicit governance approval
  • Supabase target remains Clinical KB Database (sjrfecxgysukkwxsowpy)
  • Service-role keys and private document access remain server-only
  • Demo/synthetic content remains clearly separated from real clinical sources
  • Source metadata, review status, and outdated/unknown-source behavior remain conservative
  • Deployment classification/TGA SaMD impact was checked when clinical decision-support behavior changed

Notes

The detector is capped at 20 returned candidates and scans at most 200 aged queued rows per run. Rows without an owner are excluded from discovery and fail closed if passed directly. The transactional RPC and unique open-job index guarantee idempotent enqueue under concurrent recovery.

Detect aged owner-scoped queued documents without open jobs in the scheduled health probe, alert operators without automatic production mutation, and recover approved candidates through the transactional reindex RPC.
@supabase

supabase Bot commented Jul 24, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project sjrfecxgysukkwxsowpy because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@BigSimmo, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 29 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 07d79337-f6bb-4419-96fb-ada4c277a618

📥 Commits

Reviewing files that changed from the base of the PR and between e90d906 and ff3cc60.

📒 Files selected for processing (9)
  • .github/workflows/ingestion-autopilot.yml
  • docs/outstanding-issues.md
  • docs/reindex-runbook.md
  • docs/webhooks.md
  • scripts/ingestion-autopilot.ts
  • scripts/reindex-health.ts
  • src/lib/stranded-queued-recovery.ts
  • tests/ingestion-autopilot.test.ts
  • tests/stranded-queued-recovery.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/stranded-upload-recovery

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@BigSimmo
BigSimmo enabled auto-merge (squash) July 24, 2026 07:15

@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: eb446cdd42

ℹ️ 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 scripts/ingestion-autopilot.ts
@BigSimmo

Copy link
Copy Markdown
Owner Author

@codex resolve actionable Codex review findings for this pull request and current head using the repository instructions. This is the pull request's single automatic repair pass: do not perform a fresh review, create new standalone findings, or request another review. Work only the existing unresolved Codex threads on the current head. Always fix P0 and P1 findings. For P2 and lower findings, fix only clear, scoped, low-risk issues; otherwise disposition them with a concise reason. After fixing or dispositioning a thread, reply in that thread with as the first line, followed by a concise summary; that marker authorizes the workflow to close that exact thread. If human input or new authorization is required, do not use the marker and leave the thread open with the blocker. Finish only after every actionable thread is fixed or dispositioned and closed, or explicitly left open for a human decision. Do not update the branch from main, address unrelated reviews, broaden scope, or create more than one scoped fix commit. Do not use external APIs, paid services, credentials, dependency changes, or broad refactors unless explicitly authorized. Add targeted tests where behavior changes and run the narrowest relevant validation.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

Unknown error
ℹ️ 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".

Exclude queued documents with failed ingestion jobs from the stranded sweep so ordinary failed-job recovery retains the single action limit.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

1 similar comment
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 094f6a3dca

ℹ️ 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".

@BigSimmo
BigSimmo merged commit 1c30a9d into main Jul 24, 2026
25 checks passed
@BigSimmo
BigSimmo deleted the codex/stranded-upload-recovery branch July 24, 2026 07:25
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