Skip to content

Align schema claim gating with migration by joining documents before v3 job claim - #163

Merged
BigSimmo merged 2 commits into
mainfrom
copilot/join-documents-before-claiming-jobs
Jul 2, 2026
Merged

Align schema claim gating with migration by joining documents before v3 job claim#163
BigSimmo merged 2 commits into
mainfrom
copilot/join-documents-before-claiming-jobs

Conversation

CopilotAI commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Canonical supabase/schema.sql could claim indexing_v3_agent_jobs rows for documents no longer indexed, increment attempts, then drop them in patched_documents, effectively consuming jobs without returning work.

  • This updates schema claim eligibility to match migration behavior by enforcing document-state gating before claim/update.

  • Schema claim path

    • Added a pre-claim join from indexing_v3_agent_jobs to documents in eligible_jobs.
    • Enforced d.status = 'indexed' at eligibility time (not only during patched_documents update).
  • Snapshot guardrail

    • Extended tests/supabase-schema.test.ts assertions to require the schema claim function to include:
      • join public.documents d
      • and d.status = 'indexed'
with eligible_jobs as (
selectj.id, j.document_id, j.attempt_count, j.max_attemptsfrompublic.indexing_v3_agent_jobs j
joinpublic.documents d
ond.id=j.document_idandd.status='indexed'
...
)

Verification

  • npm run verify:cheap
  • npm run verify:ui when UI, routing, styling, browser behavior, reduced-motion, or forced-colors behavior changed
  • npm run verify:release before release or handoff confidence claims
  • npm run format:check
  • npm run check:production-readiness when clinical workflow, privacy, environment, Supabase, source governance, or deployment behavior changed
  • npm run check:deployment-readiness when deployment startup, hosting, or rollout behavior changed

Clinical Governance Preflight

Complete this section when the change touches ingestion, answer generation, search/ranking, source rendering, document access, privacy, production env, or clinical output.

  • 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

  • Change is intentionally surgical: one eligibility join/filter update in supabase/schema.sql plus matching schema snapshot assertions.

CopilotAI changed the title [WIP] Join documents before claiming schema jobsAlign schema claim gating with migration by joining documents before v3 job claimJul 2, 2026
CopilotAI requested a review from BigSimmoJuly 2, 2026 10:15
@BigSimmo
BigSimmo marked this pull request as ready for review July 2, 2026 10:27
@BigSimmo
BigSimmo enabled auto-merge July 2, 2026 10:27
@BigSimmo
BigSimmo merged commit df90d35 into mainJul 2, 2026
4 checks passed
@BigSimmo
BigSimmo deleted the copilot/join-documents-before-claiming-jobs branch July 2, 2026 16:31
BigSimmo pushed a commit that referenced this pull request Aug 15, 2026
Travels with the owning PR rather than a ledger-only branch, per AGENTS.md
"PR bundling" — these are independent immutable files, so they carry no
conflict risk against a concurrent reconcile.
- Branch review record for f939131.
- issues:done for #163, recording the split explicitly: what was already on
main before this PR versus what this PR delivered, and the one part left
deliberately undone (the shared band's count/query weighting).
- issues:add for the comps-vs-contract divergence that left behind, so the
next implementer finds a decision to make rather than a silent gap.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XYphQZmsBBeqnidpSnAtjE
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.

**<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Join documents before claiming schema jobs**

2 participants

@BigSimmo