Skip to content

fix: reconcile live deep-memory commit function#569

Merged
BigSimmo merged 1 commit into
mainfrom
codex/deep-memory-live-reconcile
Jul 13, 2026
Merged

fix: reconcile live deep-memory commit function#569
BigSimmo merged 1 commit into
mainfrom
codex/deep-memory-live-reconcile

Conversation

@BigSimmo

Copy link
Copy Markdown
Owner

Summary

  • add a function-only forward migration for commit_document_deep_memory_generation
  • source the definition directly from the canonical supabase/schema.sql
  • add a replay guard for the transaction-time producer checks and staged metadata constraints

Why

After PR #568 was applied, live drift fell from two function mismatches to one. The enrichment function reconciled, but the deep-memory function remained unchanged because the first forward migration repeated the older migration body rather than the canonical schema body. This migration applies the exact manifest-backed definition.

Verification

  • focused schema/drift Vitest: 57/57 passed
  • npx supabase db push --linked --dry-run: only 20260713090500_reconcile_deep_memory_commit.sql would apply
  • focused Prettier and git diff --check: passed
  • current live drift: exactly one mismatch, the function this migration replaces

Safety

Function-only CREATE OR REPLACE plus service-role ACL reassertion. No table DDL, row mutation, backfill, or raw SQL apply.

@BigSimmo
BigSimmo enabled auto-merge (squash) July 13, 2026 09:07
@supabase

supabase Bot commented Jul 13, 2026

Copy link
Copy Markdown

Updates to Preview Branch (codex/deep-memory-live-reconcile) ↗︎

Deployments Status Updated
Database Mon, 13 Jul 2026 09:07:51 UTC
Services Mon, 13 Jul 2026 09:07:51 UTC
APIs Mon, 13 Jul 2026 09:07:51 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 Mon, 13 Jul 2026 09:07:58 UTC
Migrations Mon, 13 Jul 2026 09:09:06 UTC
Seeding Mon, 13 Jul 2026 09:09:09 UTC
Edge Functions Mon, 13 Jul 2026 09:09:10 UTC

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

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a86a0d98-bb44-420e-ae91-f074bad20ab8

📥 Commits

Reviewing files that changed from the base of the PR and between c9c3d2b and 59a976b.

📒 Files selected for processing (2)
  • supabase/migrations/20260713090500_reconcile_deep_memory_commit.sql
  • tests/supabase-schema.test.ts

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes

    • Improved reliability when committing document processing results by validating producer, artifact, generation, and count information.
    • Prevented inconsistent or ambiguous staged data from being committed.
    • Added safeguards against invalid references and outdated processing artifacts.
    • Ensured committed records retain accurate processing metadata.
  • Security

    • Restricted document-generation commit operations to authorized service processes.

Walkthrough

The migration replaces the deep-memory commit function with input, producer, count, generation, and referential-integrity validation; reconciles staged rows and metadata; returns commit details; and limits execution to service_role. Schema tests verify the migration and key safeguards.

Changes

Deep memory reconciliation

Layer / File(s) Summary
Commit contract and staged-data validation
supabase/migrations/20260713090500_reconcile_deep_memory_commit.sql
Defines the secured function and validates inputs, document generations, producer evidence, staged counts, and referential integrity.
Commit mutation, metadata, and access control
supabase/migrations/20260713090500_reconcile_deep_memory_commit.sql, tests/supabase-schema.test.ts
Commits matching staged rows, removes stale rows, applies document metadata, returns a JSONB summary, restricts execution to service_role, and adds migration assertions.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant CommitFunction
  participant StagedRows
  participant MetadataPatch
  Caller->>CommitFunction: submit deep-memory commit
  CommitFunction->>StagedRows: validate and lock staged data
  StagedRows-->>CommitFunction: validation results
  CommitFunction->>StagedRows: reconcile committed and stale rows
  CommitFunction->>MetadataPatch: apply document metadata patch
  MetadataPatch-->>CommitFunction: metadata update result
  CommitFunction-->>Caller: return commit summary
Loading
🚥 Pre-merge checks | ✅ 5 | ❌ 6

❌ Failed checks (6 inconclusive)

Check name Status Explanation Resolution
Generated And Sensitive Files ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
Verification Claims ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
Risky Git Or Deployment Actions ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
Supabase Project And Schema Safety ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
Runtime And Package Manager Integrity ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
Api Route Failure Handling ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change: reconciling the live deep-memory commit function.
Description check ✅ Passed The description is mostly complete and covers summary, rationale, verification, and safety for the migration.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ 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 codex/deep-memory-live-reconcile
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch codex/deep-memory-live-reconcile

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


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

@BigSimmo
BigSimmo merged commit 5e2e90f into main Jul 13, 2026
15 checks passed
@BigSimmo
BigSimmo deleted the codex/deep-memory-live-reconcile branch July 13, 2026 16:33
BigSimmo pushed a commit that referenced this pull request Jul 17, 2026
…eak-OR footgun

Follow-through on the memory/task review. Cross-checked every tracked
ongoing/recommended task against the current tree and updated the ledgers to
match reality:

- ingestion-concurrency-fix-workorder: mark deep-memory delete-scoping RESOLVED
  (producer-scoped model — migration 20260713030000 + #569 + deep-memory.ts
  cleanupStagedArtifacts). This doc now has no open repository items.
- operator-backlog: close the drift-codify forward-migration row (step 1h) — the
  forward-codify work-order is complete (applied 2026-07-13). Add a new "apply
  repo-ahead migrations to live" verify row for the three committed-but-unapplied
  migrations (20260713201542, 20260714110000, 20260717120000).
- audit-remediation-plan-2026-07-14: add a dated reconciliation block recording
  which findings are now DONE in code, which remain open (OWNER:CODE), which are
  in flight (PRs #708/#710), and which are operator-pending.

Also fix a config footgun the review surfaced (audit finding F5): .env.example
advertised RAG_TEXT_WEAK_OR_RELAXATION=true, but src/lib/env.ts defaults it to
false because it is a known-regressive opt-in experiment (buries some correct
docs after re-ranking). Align the example with the safe code default.

Docs + one config default only; no runtime code or schema changed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011Zbpyexer9cLgxhrB61RCU
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