Skip to content

chore(issues): ledger doc hygiene + canonical reference cleanup (#142 #154 #156 #186 #187 #232) - #1835

Merged
BigSimmo merged 6 commits into
mainfrom
codex/clean-up-ledger-documentation-and-references
Aug 12, 2026
Merged

chore(issues): ledger doc hygiene + canonical reference cleanup (#142 #154 #156 #186 #187 #232)#1835
BigSimmo merged 6 commits into
mainfrom
codex/clean-up-ledger-documentation-and-references

Conversation

@BigSimmo

@BigSimmo BigSimmo commented Aug 12, 2026

Copy link
Copy Markdown
Owner

Summary

  • File dated point-in-time reviews under their canonical docs/audit/ and docs/archive/ locations and repair every affected repository reference.
  • Archive completed ledger work through the guarded writers, preserve the append-only review history, and correct #101 so it no longer proposes the metadata and memory hydration already shipped by PR perf(rag): parallelise independent retrieval hydration #1474.
  • Keep the existing performance-only PostgreSQL plan hint while updating migration references and the generated drift manifest.

Verification

  • npm run drift:manifest — passed; scratch PostgreSQL replay completed and regenerated supabase/drift-manifest.json for the changed schema source.
  • npm run verify:pr-local — partial: runtime, installed-lock parity, changed-file formatting, sitemap/docs checks, ledger guards, workflow/policy guards, lint, and typecheck passed. The full unit stage failed in unrelated Windows/baseline areas (bundle-budget, pr-handoff-stop, worker-observability timing, and document-viewer virtualization timing), so build and offline RAG evaluation were not reached.
  • npm run check:outstanding-issues, npm run check:branch-review-ledger, npm run docs:check-links, npm run docs:check-inventory, npm run docs:check-index, npm run check:migration-role, and npm run format — passed.
  • npm run test -- tests/drift-detection.test.ts — 12/12 passed.

UI verification not run: this PR does not change UI, routing, styling, browser behavior, reduced motion, or forced-colors behavior.

RAG impact: no retrieval, ranking, candidate-selection, source-rendering, or answer-contract behavior changes. The ledger text only records that PR #1474 already shipped metadata and memory hydration parallelisation; the remaining candidates stay behind their existing RAG flag and canary requirements.

Risk and rollout

  • Risk: Low. Most changes are documentation/reference moves. The only executable database delta is the existing force_custom_plan performance hint; it does not change result sets, RLS, schema shape, or clinical logic.
  • Rollback: Revert this PR. No data migration or destructive operation is required.
  • Provider or production effects: None. Drift-manifest generation used a worktree-owned local scratch PostgreSQL container only.

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; no clinical decision-support behavior changes

Notes

  • Historical capacity and scale reviews are rename-only snapshots. Their point-in-time wording is intentionally preserved under docs/audit/; current repository policy says historical audit records are superseded rather than rewritten.

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 59 minutes

Your organization has reached its usage spending cap. Adjust your spending cap in the billing tab.

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

Run ID: 5241bbf0-ab41-4eec-9339-61b44da1bfbc

📥 Commits

Reviewing files that changed from the base of the PR and between fe46e5a and 03e5566.

📒 Files selected for processing (8)
  • AGENTS.md
  • PR_POLICY_BODY.md
  • docs/archive/operator-apply-july8-batch.md
  • docs/audit/tenancy-defense-in-depth-review.md
  • docs/branch-review-ledger.md
  • docs/outstanding-issues.md
  • docs/privacy-impact-assessment.md
  • supabase/drift-manifest.json
📝 Walkthrough

Walkthrough

The PR adds capacity and scale-readiness audit documents, updates references to relocated audit and archive documents, strengthens CI and issue-tracking safeguards, and records review-policy and ledger updates.

Changes

Audit and governance updates

Layer / File(s) Summary
Capacity and scale-readiness audit content
docs/audit/capacity-review.md, docs/audit/scale-readiness-review.md
Adds concurrency analysis, staging soak-test procedures, scale-readiness findings, measured constraints, and ranked remediation plans.
Audit and archive reference migration
SECURITY.md, docs/..., scripts/..., src/lib/..., supabase/..., tests/...
Updates references to use the docs/audit/ and docs/archive/ locations.
Review safeguards and records
AGENTS.md, PR_POLICY_BODY.md, docs/branch-review-ledger.md
Adds CI and issue-tracking safeguards, documents PR policy requirements, and records the superseding review result.

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

Possibly related PRs

Suggested reviewers: cursoragent

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 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.
Title check ✅ Passed The title clearly summarizes the primary ledger documentation and canonical reference cleanup changes.
Description check ✅ Passed The description covers the required summary, verification, risk and rollout, clinical governance, and notes sections with specific results and exceptions.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/clean-up-ledger-documentation-and-references

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

@supabase

supabase Bot commented Aug 12, 2026

Copy link
Copy Markdown

Updates to Preview Branch (codex/clean-up-ledger-documentation-and-references) ↗︎

Deployments Status Updated
Database Wed, 12 Aug 2026 13:01:22 UTC
Services Wed, 12 Aug 2026 13:01:22 UTC
APIs Wed, 12 Aug 2026 13:01:22 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, 12 Aug 2026 13:01:24 UTC
Migrations Wed, 12 Aug 2026 13:01:26 UTC
Seeding Wed, 12 Aug 2026 13:01:27 UTC
Edge Functions Wed, 12 Aug 2026 13:01:29 UTC

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

@github-actions

Copy link
Copy Markdown
Contributor

CI triage

CI failed on this PR. Automated classification of the 2 failed job(s):

  • Unit coverageneeds investigation: inspect the failing step and uploaded diagnostics; rerun only after classifying the cause.
  • PR requiredneeds investigation: inspect the failing step and uploaded diagnostics; rerun only after classifying the cause.

Compared with main CI run #9803 (failure).

Classification is evidence routing, not permission to ignore a failure. Exact quarantined Playwright identities remain governed by the flake ledger.

@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

[`docs/supabase-migration-reconciliation.md`](supabase-migration-reconciliation.md)
and [`docs/ingestion-concurrency-fix-workorder.md`](ingestion-concurrency-fix-workorder.md).

P2 Badge Rebase companion links after archiving the runbook

After this file moves from docs/ to docs/archive/, these targets resolve to nonexistent files under docs/archive/, so both companion links return 404 instead of opening the maintained reconciliation and workorder documents. npm run docs:check-links -- --all reports both paths as missing; prefix the targets with ../ to preserve the links.


[`scripts/check-owner-scope-api.mjs`](../scripts/check-owner-scope-api.mjs) fails when a

P2 Badge Rebase proof links after moving the tenancy audit

Once the audit lives under docs/audit/, ../scripts/check-owner-scope-api.mjs resolves to the nonexistent docs/scripts/ directory; the test link on line 286 similarly resolves under docs/tests/. The all-doc link check reports both failures, so these proof links need ../../scripts/... and ../../tests/... paths.

ℹ️ 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/outstanding-issues.md Outdated
Comment thread docs/outstanding-issues.md Outdated
@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. The only repository destination is BigSimmo/Database, and the only branch destination is the pull request head branch codex/clean-up-ledger-documentation-and-references at starting commit a2258eb; never publish fixes to a detached or synthetic work branch and never create a stacked pull request. Use the authenticated GitHub connector to commit each approved fix to BigSimmo/Database:codex/clean-up-ledger-documentation-and-references, then verify that the pull request head contains the published commit before reporting success. 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. For a fixed thread, reply with as the first line and as the second line. For a no-code disposition, use followed by . These result markers authorize the workflow to close that exact thread only after it verifies a fixed commit is the pull request head; a local-only commit is not a fix. If publication or verification fails, do not use either result marker, do not claim success, and leave the thread open with the blocker. If human input or new authorization is required, do the same. 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 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

[`docs/supabase-migration-reconciliation.md`](supabase-migration-reconciliation.md)
and [`docs/ingestion-concurrency-fix-workorder.md`](ingestion-concurrency-fix-workorder.md).

P2 Badge Preserve companion links after archiving the runbook

After this file moves from docs/ to docs/archive/, these relative targets resolve to nonexistent files under docs/archive/, so readers following the runbook's two companion links receive 404s. Update both targets to traverse back to docs/ (for example, ../supabase-migration-reconciliation.md); the default docs link check excludes archived files, so this regression is not caught unless the historical sweep is run.

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

Copilot AI 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.

Pull request overview

Reorganizes historical documentation into canonical audit/archive locations and updates ledger guidance and records.

Changes:

  • Moves dated reviews/runbooks and updates references.
  • Archives completed issue-ledger entries and adds superseding review evidence.
  • Adds durable CI fallback and ledger-verification guidance.

Reviewed changes

Copilot reviewed 37 out of 40 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
.claude/agents/clinical-governance-reviewer.md Updates tenancy-review path.
AGENTS.md Adds CI and ledger safeguards.
SECURITY.md Updates tenancy-review link.
docs/README.md Indexes relocated documents.
docs/archive/operator-apply-july8-batch.md Updates capacity-review reference.
docs/audit/audit-handover-2026-07-14.md Updates tenancy-review references.
docs/audit/audit-remediation-plan-2026-07-14.md Updates remediation file path.
docs/audit/capacity-review.md Relocates capacity audit.
docs/audit/latency-audit-2026-07-28.md Updates capacity references.
docs/audit/scale-readiness-review.md Relocates scale audit.
docs/audit/tenancy-defense-in-depth-review.md Relocates tenancy audit and runbook links.
docs/auth-connection-cap-runbook.md Updates capacity references.
docs/branch-review-ledger.md Appends superseding PR-J record.
docs/codebase-index.md Updates documentation map.
docs/deploy-corrector-public-titles.md Updates related-document paths.
docs/deployment-architecture.md Updates capacity references.
docs/ingestion-concurrency-fix-workorder.md Updates audit and archive paths.
docs/ingestion-state-machine.md Updates scale-review path.
docs/launch-operator-runbook.md Updates operator and capacity links.
docs/operator-backlog.md Updates runbook links.
docs/outstanding-issues.md Revises and archives ledger entries.
docs/privacy-impact-assessment.md Updates tenancy-review link.
docs/process-hardening.md Updates archived runbook link.
docs/prompts/codex-data-database-safety-ultra-review.md Updates review input path.
docs/prompts/codex-performance-reliability-ultra-review.md Updates audit input paths.
docs/staging-setup.md Updates capacity references.
docs/supabase-migration-reconciliation.md Updates archived runbook link.
docs/worker-deploy-runbook.md Updates archived runbook link.
scripts/archive/check-july8-live-batch.ts Updates failure guidance path.
scripts/check-owner-scope-api.mjs Updates tenancy-review references.
scripts/check-retrieval-owner-migration.ts Updates remediation path.
scripts/soak-test.ts Updates capacity-review references.
src/lib/owner-scope.ts Updates tenancy-review comment.
supabase/migrations/20260708160000_ingestion_jobs_one_open_per_document.sql Updates archived runbook comment.
supabase/migrations/20260708160001_retrieval_owner_matches_fail_closed.sql Updates tenancy-review comment.
supabase/migrations/20260708170000_ingestion_jobs_one_open_per_document.sql Updates archived runbook comment.
supabase/migrations/20260717120000_corrector_public_titles_only.sql Updates tenancy-review comment.
supabase/migrations/20260724120000_table_facts_plpgsql_execute.sql Updates scale-review comment.
supabase/schema.sql Updates archived runbook comment.
tests/owner-scope-guard.test.ts Reads the relocated tenancy review.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread supabase/migrations/20260724120000_table_facts_plpgsql_execute.sql
Comment thread docs/outstanding-issues.md Outdated
Comment thread docs/outstanding-issues.md Outdated
@BigSimmo

Copy link
Copy Markdown
Owner Author

@copilot Fix the code for all comments in this review thread.

When a review comment includes a suggested change, apply the suggestion exactly.

Do not make changes beyond what is described in the linked review thread.

fix #186 archive

- Restore #156 (read-modify-write race + Update-branch corruption) from
  archive back to the open issues section with its original full text; the
  underlying allocation race is not resolved by the conservative architecture
  decision described in the previous commit.
- Re-add #156 to the recommendations priority table as row 51 (between #101
  and #172, consistent with its original ordering).
- Correct #101 to credit only metadata and memory parallelisation
  (hydrateCandidatesWithMetadataAndMemory) from PR #1474; visual hydration
  (attachPageVisualEvidence) is still called serially after hydration on all
  six call sites and is explicitly listed as a remaining candidate.
- Update #186 archive text to reflect that only metadata+memory were updated
  in #101, not visual hydration.

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

Copilot AI commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

@copilot Fix the code for all comments in this review thread.

When a review comment includes a suggested change, apply t...

Fixed in commit fix(issues): restore #156 as open, correct #101 visual hydration claim, fix #186 archive:

  1. #156 — removed from archive, restored to the open issues section with its original full text and re-added to the recommendations table at row 51. The underlying read-modify-write allocation race is unresolved.

  2. #101 — corrected to credit only metadata and memory parallelisation (hydrateCandidatesWithMetadataAndMemory) from PR perf(rag): parallelise independent retrieval hydration #1474. Visual hydration (attachPageVisualEvidence) is still called serially after hydration on all six call sites (rag.ts:1442,1811,1857,1959,2194,2281) and is now listed explicitly as a remaining canary-gated candidate.

  3. #186 archive — updated to reflect that only metadata+memory were updated in #101, and that visual hydration remains a candidate.

Regarding the Clinical Governance Preflight finding: the migration file in this PR is a performance-only change (switching from a generic cached plan to force_custom_plan — no change to result rows, ordering predicates, RLS, or schema). The PR body should be updated to include a ## Clinical Governance Preflight section before merge to satisfy pr-policy.mjs. That is a PR description edit rather than a code change.

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

🤖 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 `@docs/audit/capacity-review.md`:
- Around line 153-154: Align the non-429 error-rate gate with the documented
acceptance threshold: require less than 1% and fail runs at or above 1%,
updating both the executable check and acceptance table consistently.
- Around line 129-163: The soak-test documentation currently claims broader
capacity coverage than the driver provides and uses a 5% failure threshold
instead of the documented <1% criterion. Either update scripts/soak-test.ts to
model authentication bursts, two searches and one document open per answer, and
enforce a non-429 error rate below 1%, or explicitly scope this documentation to
search-and-answer traffic and revise its success criteria accordingly.

In `@docs/audit/scale-readiness-review.md`:
- Around line 55-62: Update the RPC fan-out statement in the scale-readiness
review to distinguish the base cold-request range from the higher retry-expanded
maximum, explicitly accounting for OR-relaxation and trigram-correction retries.
Revise the F6 connection and throughput planning reference to use the
retry-expanded peak rather than the 10–14 base range alone.

In `@docs/ingestion-concurrency-fix-workorder.md`:
- Line 25: Correct the Markdown link paths relative to their containing files:
in docs/ingestion-concurrency-fix-workorder.md:25,
docs/ingestion-state-machine.md:21, and docs/privacy-impact-assessment.md:494
use audit/scale-readiness-review.md or audit/tenancy-defense-in-depth-review.md
as appropriate; in docs/prompts/codex-data-database-safety-ultra-review.md:67
use ../audit/tenancy-defense-in-depth-review.md.
🪄 Autofix

❌ 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 9ba165c7-3315-4f92-8d44-33d6effdea5c

📥 Commits

Reviewing files that changed from the base of the PR and between 3b6cab0 and fb69cdb.

📒 Files selected for processing (40)
  • .claude/agents/clinical-governance-reviewer.md
  • AGENTS.md
  • SECURITY.md
  • docs/README.md
  • docs/archive/operator-apply-july8-batch.md
  • docs/audit/audit-handover-2026-07-14.md
  • docs/audit/audit-remediation-plan-2026-07-14.md
  • docs/audit/capacity-review.md
  • docs/audit/latency-audit-2026-07-28.md
  • docs/audit/scale-readiness-review.md
  • docs/audit/tenancy-defense-in-depth-review.md
  • docs/auth-connection-cap-runbook.md
  • docs/branch-review-ledger.md
  • docs/codebase-index.md
  • docs/deploy-corrector-public-titles.md
  • docs/deployment-architecture.md
  • docs/ingestion-concurrency-fix-workorder.md
  • docs/ingestion-state-machine.md
  • docs/launch-operator-runbook.md
  • docs/operator-backlog.md
  • docs/outstanding-issues.md
  • docs/privacy-impact-assessment.md
  • docs/process-hardening.md
  • docs/prompts/codex-data-database-safety-ultra-review.md
  • docs/prompts/codex-performance-reliability-ultra-review.md
  • docs/staging-setup.md
  • docs/supabase-migration-reconciliation.md
  • docs/worker-deploy-runbook.md
  • scripts/archive/check-july8-live-batch.ts
  • scripts/check-owner-scope-api.mjs
  • scripts/check-retrieval-owner-migration.ts
  • scripts/soak-test.ts
  • src/lib/owner-scope.ts
  • supabase/migrations/20260708160000_ingestion_jobs_one_open_per_document.sql
  • supabase/migrations/20260708160001_retrieval_owner_matches_fail_closed.sql
  • supabase/migrations/20260708170000_ingestion_jobs_one_open_per_document.sql
  • supabase/migrations/20260717120000_corrector_public_titles_only.sql
  • supabase/migrations/20260724120000_table_facts_plpgsql_execute.sql
  • supabase/schema.sql
  • tests/owner-scope-guard.test.ts

Comment thread docs/ingestion-concurrency-fix-workorder.md

@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

Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 4

🤖 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 `@docs/audit/capacity-review.md`:
- Around line 153-154: Align the non-429 error-rate gate with the documented
acceptance threshold: require less than 1% and fail runs at or above 1%,
updating both the executable check and acceptance table consistently.
- Around line 129-163: The soak-test documentation currently claims broader
capacity coverage than the driver provides and uses a 5% failure threshold
instead of the documented <1% criterion. Either update scripts/soak-test.ts to
model authentication bursts, two searches and one document open per answer, and
enforce a non-429 error rate below 1%, or explicitly scope this documentation to
search-and-answer traffic and revise its success criteria accordingly.

In `@docs/audit/scale-readiness-review.md`:
- Around line 55-62: Update the RPC fan-out statement in the scale-readiness
review to distinguish the base cold-request range from the higher retry-expanded
maximum, explicitly accounting for OR-relaxation and trigram-correction retries.
Revise the F6 connection and throughput planning reference to use the
retry-expanded peak rather than the 10–14 base range alone.

In `@docs/ingestion-concurrency-fix-workorder.md`:
- Line 25: Correct the Markdown link paths relative to their containing files:
in docs/ingestion-concurrency-fix-workorder.md:25,
docs/ingestion-state-machine.md:21, and docs/privacy-impact-assessment.md:494
use audit/scale-readiness-review.md or audit/tenancy-defense-in-depth-review.md
as appropriate; in docs/prompts/codex-data-database-safety-ultra-review.md:67
use ../audit/tenancy-defense-in-depth-review.md.
🪄 Autofix

❌ 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 9ba165c7-3315-4f92-8d44-33d6effdea5c

📥 Commits

Reviewing files that changed from the base of the PR and between 3b6cab0 and fb69cdb.

📒 Files selected for processing (40)
  • .claude/agents/clinical-governance-reviewer.md
  • AGENTS.md
  • SECURITY.md
  • docs/README.md
  • docs/archive/operator-apply-july8-batch.md
  • docs/audit/audit-handover-2026-07-14.md
  • docs/audit/audit-remediation-plan-2026-07-14.md
  • docs/audit/capacity-review.md
  • docs/audit/latency-audit-2026-07-28.md
  • docs/audit/scale-readiness-review.md
  • docs/audit/tenancy-defense-in-depth-review.md
  • docs/auth-connection-cap-runbook.md
  • docs/branch-review-ledger.md
  • docs/codebase-index.md
  • docs/deploy-corrector-public-titles.md
  • docs/deployment-architecture.md
  • docs/ingestion-concurrency-fix-workorder.md
  • docs/ingestion-state-machine.md
  • docs/launch-operator-runbook.md
  • docs/operator-backlog.md
  • docs/outstanding-issues.md
  • docs/privacy-impact-assessment.md
  • docs/process-hardening.md
  • docs/prompts/codex-data-database-safety-ultra-review.md
  • docs/prompts/codex-performance-reliability-ultra-review.md
  • docs/staging-setup.md
  • docs/supabase-migration-reconciliation.md
  • docs/worker-deploy-runbook.md
  • scripts/archive/check-july8-live-batch.ts
  • scripts/check-owner-scope-api.mjs
  • scripts/check-retrieval-owner-migration.ts
  • scripts/soak-test.ts
  • src/lib/owner-scope.ts
  • supabase/migrations/20260708160000_ingestion_jobs_one_open_per_document.sql
  • supabase/migrations/20260708160001_retrieval_owner_matches_fail_closed.sql
  • supabase/migrations/20260708170000_ingestion_jobs_one_open_per_document.sql
  • supabase/migrations/20260717120000_corrector_public_titles_only.sql
  • supabase/migrations/20260724120000_table_facts_plpgsql_execute.sql
  • supabase/schema.sql
  • tests/owner-scope-guard.test.ts
🛑 Comments failed to post (3)
docs/audit/capacity-review.md (2)

129-163: 🚀 Performance & Scalability | 🟠 Major | 🏗️ Heavy lift

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n -C 4 -- 'search|answer|document|auth|bearer|think|error|429' scripts/soak-test.ts

Repository: BigSimmo/Database

Length of output: 8326


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- applicable guidance ---'
find .. -name AGENTS.md -print

printf '%s\n' '--- capacity model and criteria ---'
sed -n '1,190p' docs/audit/capacity-review.md

printf '%s\n' '--- soak-test structure ---'
sed -n '1,285p' scripts/soak-test.ts

Repository: BigSimmo/Database

Length of output: 20006


🏁 Script executed:

#!/bin/bash
set -euo pipefail

cat AGENTS.md

python3 - <<'PY'
from pathlib import Path
import re

script = Path("scripts/soak-test.ts").read_text()
doc = Path("docs/audit/capacity-review.md").read_text()

endpoints = sorted(set(re.findall(r'endpoint:\s*"([^"]+)"', script)))
request_paths = sorted(set(re.findall(r'`/api/\$\{endpoint\}`', script)))
has_bearer = "authorization: `Bearer ${args.bearer}`" in script
has_auth_endpoint = bool(re.search(r'/api/(auth|sign[-_]?in|login)', script, re.I))
has_document_endpoint = bool(re.search(r'/api/[^`"]*(document|doc)', script, re.I))
gate_lines = [line.strip() for line in doc.splitlines() if "Non-429 error rate" in line or "gate:" in line or "FAIL: non-429" in script]

print("script endpoint union:", endpoints)
print("script constructs only parameterized /api/{endpoint} requests:", bool(request_paths))
print("bearer header present:", has_bearer)
print("authentication endpoint present:", has_auth_endpoint)
print("document endpoint present:", has_document_endpoint)
print("success/gate lines:")
for line in gate_lines:
    print("  " + line)
PY

Repository: BigSimmo/Database

Length of output: 50374


Align the soak test with the capacity model and success criteria.

The model includes authentication bursts, two searches per answer, and one document open per answer. The driver sends only /api/search and /api/answer requests, and --bearer reuses an existing session. It cannot measure authentication or document-read capacity. Its 5% non-429 failure gate also conflicts with the documented <1% success criterion. Add the missing phases and enforce the <1% gate, or scope the documentation to search and answer traffic.

🤖 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 `@docs/audit/capacity-review.md` around lines 129 - 163, The soak-test
documentation currently claims broader capacity coverage than the driver
provides and uses a 5% failure threshold instead of the documented <1%
criterion. Either update scripts/soak-test.ts to model authentication bursts,
two searches and one document open per answer, and enforce a non-429 error rate
below 1%, or explicitly scope this documentation to search-and-answer traffic
and revise its success criteria accordingly.

153-154: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Make the executable error gate match the acceptance threshold.

Line 153 allows a non-429 error rate below 5%, while Line 171 requires less than 1%. A run with a 4% error rate can exit successfully and still fail the documented success criteria. Align the script and the acceptance table. If <1% is the gate, fail at >=1%.

Proposed documentation correction
- Exits non-zero if the non-429 error rate exceeds 5 %.
+ Exits non-zero if the non-429 error rate reaches 1 % or more.
🤖 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 `@docs/audit/capacity-review.md` around lines 153 - 154, Align the non-429
error-rate gate with the documented acceptance threshold: require less than 1%
and fail runs at or above 1%, updating both the executable check and acceptance
table consistently.
docs/audit/scale-readiness-review.md (1)

55-62: 🚀 Performance & Scalability | 🟠 Major | 🏗️ Heavy lift

Include retry fan-out in the RPC capacity budget.

The calculation reaches 14 RPCs before the OR-relaxation and trigram-correction retries described on Lines 59-60. A retrying request can therefore exceed the stated 10–14 RPC range. F6 reuses that range for connection and throughput planning, which underestimates peak pool occupancy. Report the base fan-out and the retry-expanded maximum separately.

Proposed wording correction
- A single cold request can issue 10–14 RPCs, of which the table-facts trio alone is ~3 × 6.75 s of parallel DB CPU.
+ A single cold request issues 10–14 base RPCs. OR-relaxation and trigram-correction retries add further RPCs; budget their maximum separately.
🤖 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 `@docs/audit/scale-readiness-review.md` around lines 55 - 62, Update the RPC
fan-out statement in the scale-readiness review to distinguish the base
cold-request range from the higher retry-expanded maximum, explicitly accounting
for OR-relaxation and trigram-correction retries. Revise the F6 connection and
throughput planning reference to use the retry-expanded peak rather than the
10–14 base range alone.

@BigSimmo
BigSimmo enabled auto-merge August 12, 2026 09:41
BigSimmo pushed a commit that referenced this pull request Aug 12, 2026
Checked all 12 open PRs and mapped them to ledger rows. Twenty-four open rows
are actively being fixed right now — #1835 (7 rows), #1840 (4), #1842 (6),
#1841 (4), #1836 (2), #1837 (1), #1839 (1) — and none of those rows said so.

This is the #292 failure mode with the safety off: a queued row that reads as
unclaimed while a PR is open against it is how the same conversion shipped
twice on 2026-08-09. Each row now names its PR and says not to start until
that PR merges.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017paT42ZVMf8jaLtkjFxdy5
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

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

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Cannot run autofix: This PR has merge conflicts.

Please resolve the conflicts with the base branch and try again.

Alternatively, use @coderabbitai resolve merge conflict to automatically resolve the conflicts.

@BigSimmo

Copy link
Copy Markdown
Owner Author

@copilot please resolve all issues for me including the merge failure and then have it ready to merge and babysit this PR

auto-merge was automatically disabled August 12, 2026 11:02

Head branch was pushed to by a user without write access

@BigSimmo
BigSimmo enabled auto-merge August 12, 2026 11:04
auto-merge was automatically disabled August 12, 2026 11:05

Head branch was pushed to by a user without write access

Copilot AI commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

@copilot please resolve all issues for me including the merge failure and then have it ready to merge and babysit this PR

Done. Here's what was resolved:

  1. Merge conflicts (merge: resolve ledger conflicts with origin/main, 42c2718a): Both docs/outstanding-issues.md and docs/branch-review-ledger.md had real content conflicts with origin/main. Resolved by keeping all rows from both sides — removed resolved items (fix(rag): exempt deterministic document-list/table answers from prose sanitizer #207, style(mockups): keep tool-card titles on their own line #226, Role-pure categorical tone scale for service pathway pills #230) that main had already archived from the priority table, kept Parse nested JSONB job-status RPC result before completion gate checks #156 as open (per the original review finding), and included the newly-archived rows from both branches in the archive section. Both npm run check:outstanding-issues (305 rows, 137 open, 168 archived) and npm run check:branch-review-ledger passed after resolution.

  2. Clinical Governance Preflight (chore: add PR_POLICY_BODY.md for clinical governance preflight sync, fe46e5ad): Added PR_POLICY_BODY.md to the branch so the CI sync-pr-policy-body job will auto-update the PR description with a complete ## Clinical Governance Preflight section (all 7 items checked) when CI runs. The migration is performance-only — no result-set, RLS, schema, or clinical-logic changes. evaluatePullRequestPolicy confirms no blocking errors with the new body.

The branch is now pushed and CI should be running. Once CI completes green, the PR will be ready to merge. Note: per AGENTS.md "Stop when the pull request is open" policy, I'm stopping here — the CI results and merge decision are yours.

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

🤖 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 `@PR_POLICY_BODY.md`:
- Around line 17-19: Update the verification entries in PR_POLICY_BODY.md to
include the decisive success-output line for every listed command, including
formatting, issue, ledger, documentation, design-system, migration-role, and
diff checks. Replace unsupported “passed” or exit-code-only claims with the
exact gate output while preserving the existing command coverage.
🪄 Autofix

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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 5fc38748-d374-461d-8453-297e3f6f990c

📥 Commits

Reviewing files that changed from the base of the PR and between fb69cdb and fe46e5a.

📒 Files selected for processing (4)
  • PR_POLICY_BODY.md
  • docs/branch-review-ledger.md
  • docs/codebase-index.md
  • docs/outstanding-issues.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • docs/codebase-index.md
  • docs/branch-review-ledger.md

Comment thread PR_POLICY_BODY.md Outdated
@BigSimmo
BigSimmo enabled auto-merge August 12, 2026 11:13
@BigSimmo
BigSimmo merged commit bbcbe67 into main Aug 12, 2026
96 checks passed
@BigSimmo
BigSimmo deleted the codex/clean-up-ledger-documentation-and-references branch August 12, 2026 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants