Skip to content

PR 423#423

Merged
BigSimmo merged 12 commits into
mainfrom
cursor/july8-closeout-docs-and-checks-e3fb
Jul 9, 2026
Merged

PR 423#423
BigSimmo merged 12 commits into
mainfrom
cursor/july8-closeout-docs-and-checks-e3fb

Conversation

@BigSimmo

@BigSimmo BigSimmo commented Jul 9, 2026

Copy link
Copy Markdown
Owner

Summary

July 8 live-batch closeout: operator runbook, consolidated probes, and hardened R17 enforcement checks.

Latest (a0d34cd) — fail-closed probe cleanup

  • Probe rows tagged with stage: july8-live-batch-probe for mark-and-sweep
  • deleteR17ProbeJobIds() throws on Supabase delete errors (finally block + unexpected-duplicate path)
  • Stranded probe rows swept before each attempt; assertNoStrandedR17ProbeRows() after success

Prior commits on this branch

  • R17 index definition accepts IN (...) and = ANY (ARRAY[...]) pg_get_indexdef forms
  • Document pagination + retry on open-job race
  • Production-only pinning, strict predicate matching, index-specific 23505 detection
  • R17 migration timestamp isolated to 20260708170000

Verification

  • npm run verify:cheap — 1386 tests passed
  • tests/check-july8-live-batch.test.ts — 8 tests
Open in Web Open in Cursor 

- Add docs/operator-apply-july8-batch.md with ordered apply steps for PRs
  #380/#405/#408/#409 (RPC hardening, R17, R5, fail-closed tenancy)
- Add npm run check:july8-live-batch for post-apply live verification
- Extend check-retrieval-owner-migration with fail-closed NULL probe
- Refresh stale docs: process-hardening, tenancy review, ingestion workorder,
  redesign/04-deferred, PR template (36/36 golden eval), migration reconciliation

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
@supabase

supabase Bot commented Jul 9, 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 ↗︎.

@BigSimmo
BigSimmo marked this pull request as ready for review July 9, 2026 04:03
Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
@BigSimmo
BigSimmo enabled auto-merge (squash) July 9, 2026 04:06

@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: 1662a0868e

ℹ️ 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 docs/operator-apply-july8-batch.md Outdated
Comment thread scripts/check-july8-live-batch.ts Outdated
Comment thread scripts/check-july8-live-batch.ts Outdated
@BigSimmo
BigSimmo disabled auto-merge July 9, 2026 04:12
BigSimmo and others added 2 commits July 9, 2026 12:12
…hardening

- Rename R17 migration to 20260708170000 (avoids timestamp collision with
  20260708160000_retrieval_owner_matches_fail_closed and unsafe repair)
- Use transactional CREATE UNIQUE INDEX so db push can apply the full batch;
  document optional CONCURRENTLY path for busy queues
- check:july8-live-batch: requireServerEnv (fail when live keys absent);
  fail R17 probe when schema_drift_snapshot is unavailable
- Refresh operator runbook, schema.sql comment, drift manifest hash

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
@BigSimmo
BigSimmo enabled auto-merge (squash) July 9, 2026 04:18

@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: 3138d2e345

ℹ️ 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/check-july8-live-batch.ts Outdated
Address PR #423 review: schema_drift_snapshot only exposes index names,
so a failed CONCURRENTLY build can pass a name-only probe. Check the
partial-unique definition and reject duplicate open-job inserts.

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
@BigSimmo BigSimmo changed the title docs(ops): July 8 batch closeout runbook and live migration probes PR 423 Jul 9, 2026
cursoragent and others added 3 commits July 9, 2026 04:38
…robes

Importing check-july8-live-batch.ts from unit tests was executing main(),
calling live Supabase RPCs and process.exit(1) in the vitest worker.
Match the repo script convention: only run when invoked directly.

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>

@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: 84ca9b2427

ℹ️ 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/check-july8-live-batch.ts Outdated
Comment thread scripts/check-july8-live-batch.ts Outdated
Comment thread scripts/check-july8-live-batch.ts
- Use randomUUID per enforcement probe; clean legacy fixed probe rows
- Require 23505 violations cite ingestion_jobs_one_open_per_document_uidx
- Reject broader R17 predicates (failed/completed/etc.) in definition check
- Pin check:july8-live-batch to production via checkSupabaseProjectConfig
- Extend unit tests and operator runbook for production-only semantics

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
auto-merge was automatically disabled July 9, 2026 05:06

Head branch was modified

@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds the July 8 ingestion batch migration and live verification tooling, updates the operator runbook and related status docs, revises the tenancy review for fail-closed owner matching, and raises the retrieval eval checklist threshold.

Changes

July 8 batch migration, verification tooling, and documentation

Layer / File(s) Summary
R17 unique index migration and schema doc update
supabase/migrations/20260708170000_ingestion_jobs_one_open_per_document.sql, supabase/schema.sql, supabase/drift-manifest.json
Adds the transactional partial unique index for one open ingestion job per document and updates the schema comment and drift hash to match it.
Verification script and probes
package.json, scripts/check-july8-live-batch.ts, scripts/check-retrieval-owner-migration.ts, tests/check-july8-live-batch.test.ts
Adds the live-batch checker, the production-only retrieval-owner NULL probe, the npm script entry, and unit tests for the R17 index and unique-violation helpers.
Operator apply runbook for July 8 batch
docs/operator-apply-july8-batch.md
Adds the operator runbook covering pre-flight checks, apply order, optional busy-queue handling, post-apply verification, and expected probe outcomes.
Process and reconciliation status updates
docs/process-hardening.md, docs/ingestion-concurrency-fix-workorder.md, docs/supabase-migration-reconciliation.md
Updates process notes and workorder status to reflect the July 8 batch, merged-vs-pending live-apply state, and the new runbook reference.
Tenancy defense-in-depth review updates
docs/tenancy-defense-in-depth-review.md
Documents retrieval-owner matching as fail-closed on NULL, marks recommendation item 1 done, and updates the review status text.
Eval gate and deferred-item status updates
.github/pull_request_template.md, docs/process-hardening.md, docs/redesign/04-deferred.md
Raises the retrieval eval threshold to 36/36 and updates several deferred-item entries to resolved or done.

Estimated code review effort: 3 (Moderate) | ~25 minutes


Caution

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

  • Ignore

❌ Failed checks (1 error, 2 warnings, 1 inconclusive)

Check name Status Explanation Resolution
Verification Claims ❌ Error PR description’s Verification section includes npm run format:check without an explicit result; the check requires command + outcome (passed/not run). Rewrite every verification claim as Ran <command>: passed or Not run: <reason>; add an outcome to npm run format:check.
Description check ⚠️ Warning The summary and verification are present, but the template-required Clinical Governance Preflight and full checklist structure are missing. Add the missing Clinical Governance Preflight section and complete the template’s verification checklist with the relevant checked items.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 70.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title is too generic to describe the change and doesn’t indicate the R17 probe and live-batch hardening work. Use a concise, specific title such as one referencing R17 probe cleanup, production pinning, and July 8 live-batch hardening.
✅ Passed checks (7 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Generated And Sensitive Files ✅ Passed No secrets or disallowed artifacts found; diff only touches docs/scripts/tests/migrations plus a tracked schema-manifest hash update.
Risky Git Or Deployment Actions ✅ Passed No force-push/reset/branch-deletion steps found; live apply docs require production targeting and explicit operator approval, and the probe script gates on production with cleanup.
Supabase Project And Schema Safety ✅ Passed No stale Supabase refs introduced; DB changes are additive and paired with explicit preflight, apply-order, cleanup, and post-apply verification docs.
Runtime And Package Manager Integrity ✅ Passed No package-manager, lockfile, or engine changes; Node 24/npm 11 and engine-strict remain intact.
Api Route Failure Handling ✅ Passed PASS: The only integration scripts added fail closed on missing envs/RPC errors, retry races, and exit 1 on any probe failure; no API routes or server actions changed.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor/july8-closeout-docs-and-checks-e3fb
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch cursor/july8-closeout-docs-and-checks-e3fb

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
tests/check-july8-live-batch.test.ts (1)

6-14: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add a test case using the real Postgres-reconstructed predicate form.

All cases here use literal WHERE status IN (...) strings. If isExpectedR17IndexDef's matcher needs to also accept status = ANY (ARRAY[...]) (see companion comment on scripts/check-july8-live-batch.ts), add a test asserting that form is accepted too, since that's closer to what pg_get_indexdef/schema_drift_snapshot will actually return.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/check-july8-live-batch.test.ts` around lines 6 - 14, Add a test in
isExpectedR17IndexDef’s spec that uses the real Postgres-reconstructed predicate
form with status = ANY (ARRAY[...]) instead of only the literal IN clause.
Update the test in tests/check-july8-live-batch.test.ts alongside the existing
canonical partial unique index case, and assert that isExpectedR17IndexDef
accepts the ARRAY form while normalizeIndexDef still normalizes it as expected.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scripts/check-july8-live-batch.ts`:
- Around line 28-51: The R17 index matcher in isExpectedR17IndexDef only
recognizes status IN (...) and will reject a valid partial index rendered by
pg_get_indexdef as status = ANY (ARRAY[...]). Update the parsing in that helper
to accept both IN and ANY(array) forms while still requiring the same
pending/processing pair and excluding broader predicates, and add tests around
schema_drift_snapshot() output to cover the ANY rendering.
- Around line 148-229: findR17ProbeDocument currently stops after a single
200-row fetch, so it can miss a usable document and still race with ingestion
activity; update the R17 probe flow to keep scanning through pages until a
document without open jobs is found. Use the existing findR17ProbeDocument and
checkR17IndexEnforcement helpers, and make the insert path retry or re-select a
new document when a unique-violation/open-job race occurs instead of failing
immediately. Ensure cleanupLegacyR17ProbeRows still runs before each attempt so
stale probe rows do not bias the scan.

---

Nitpick comments:
In `@tests/check-july8-live-batch.test.ts`:
- Around line 6-14: Add a test in isExpectedR17IndexDef’s spec that uses the
real Postgres-reconstructed predicate form with status = ANY (ARRAY[...])
instead of only the literal IN clause. Update the test in
tests/check-july8-live-batch.test.ts alongside the existing canonical partial
unique index case, and assert that isExpectedR17IndexDef accepts the ARRAY form
while normalizeIndexDef still normalizes it as expected.
🪄 Autofix (Beta)

❌ Autofix failed (check again to retry)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: b434e46f-9b22-48de-a387-e1bb006ba712

📥 Commits

Reviewing files that changed from the base of the PR and between 8163549 and a4e56df.

📒 Files selected for processing (15)
  • .github/pull_request_template.md
  • docs/ingestion-concurrency-fix-workorder.md
  • docs/operator-apply-july8-batch.md
  • docs/process-hardening.md
  • docs/redesign/04-deferred.md
  • docs/supabase-migration-reconciliation.md
  • docs/tenancy-defense-in-depth-review.md
  • package.json
  • scripts/check-july8-live-batch.ts
  • scripts/check-retrieval-owner-migration.ts
  • supabase/drift-manifest.json
  • supabase/migrations/20260708160000_ingestion_jobs_one_open_per_document.sql
  • supabase/migrations/20260708170000_ingestion_jobs_one_open_per_document.sql
  • supabase/schema.sql
  • tests/check-july8-live-batch.test.ts
💤 Files with no reviewable changes (1)
  • supabase/migrations/20260708160000_ingestion_jobs_one_open_per_document.sql

Comment thread scripts/check-july8-live-batch.ts
Comment thread scripts/check-july8-live-batch.ts

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

ℹ️ 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/check-july8-live-batch.ts Outdated
@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

Autofix skipped. No unresolved CodeRabbit review comments with fix instructions found.

@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

Autofix skipped. No unresolved CodeRabbit review comments with fix instructions found.

@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

Autofix skipped. No unresolved CodeRabbit review comments with fix instructions found.

- Tag probe rows with stage july8-live-batch-probe for mark-and-sweep
- Check delete errors in finally and unexpected-duplicate paths
- Sweep stranded probe rows before each attempt and verify none remain
- Document probe cleanup semantics in operator runbook

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
scripts/check-july8-live-batch.ts (1)

44-67: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Reject extra boolean predicates in the R17 matcher.

The matcher still accepts broader predicates that contain the expected status list plus another clause, e.g. status IN ('pending','processing') OR status IS NOT NULL. That violates the “exact pending + processing only” contract.

Proposed guard
   const whereClause = normalized.slice(whereIdx + " where ".length);
+  if (/\b(?:and|or)\b/.test(whereClause)) return false;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/check-july8-live-batch.ts` around lines 44 - 67, The R17 status
matcher is too permissive because it only extracts the status list from
`whereClause` and ignores any extra predicates. Update the parsing in the
status-matching logic to require the whole clause to be exactly a `status IN
(...)` or `status = ANY(...)` expression with only `pending` and `processing`,
and reject cases where additional boolean conditions are present. Use the
existing matcher logic around `whereClause`, `inMatch`, and `anyMatch` to add a
strict guard before returning true.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@scripts/check-july8-live-batch.ts`:
- Around line 44-67: The R17 status matcher is too permissive because it only
extracts the status list from `whereClause` and ignores any extra predicates.
Update the parsing in the status-matching logic to require the whole clause to
be exactly a `status IN (...)` or `status = ANY(...)` expression with only
`pending` and `processing`, and reject cases where additional boolean conditions
are present. Use the existing matcher logic around `whereClause`, `inMatch`, and
`anyMatch` to add a strict guard before returning true.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 680763d2-cfa3-41d4-8964-558787ced9f4

📥 Commits

Reviewing files that changed from the base of the PR and between b10689c and a0d34cd.

📒 Files selected for processing (3)
  • docs/operator-apply-july8-batch.md
  • scripts/check-july8-live-batch.ts
  • tests/check-july8-live-batch.test.ts
✅ Files skipped from review due to trivial changes (1)
  • docs/operator-apply-july8-batch.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/check-july8-live-batch.test.ts

@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

Autofix skipped. No unresolved CodeRabbit review comments with fix instructions found.

@BigSimmo
BigSimmo enabled auto-merge (squash) July 9, 2026 07:23

@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: 8f0184510e

ℹ️ 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/check-july8-live-batch.ts
@BigSimmo
BigSimmo merged commit 1665b50 into main Jul 9, 2026
10 checks passed
@BigSimmo
BigSimmo deleted the cursor/july8-closeout-docs-and-checks-e3fb branch July 9, 2026 12:35
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.

2 participants