Skip to content

Fix op checkpoint JSONB array binding#2288

Open
EagleEyez1 wants to merge 1 commit into
garrytan:masterfrom
EagleEyez1:artie-fix-op-checkpoint-jsonb-20260618
Open

Fix op checkpoint JSONB array binding#2288
EagleEyez1 wants to merge 1 commit into
garrytan:masterfrom
EagleEyez1:artie-fix-op-checkpoint-jsonb-20260618

Conversation

@EagleEyez1

Copy link
Copy Markdown

Summary

Fixes a live Postgres sync failure where recordCompleted() wrote completed_keys as a JSON string instead of a JSON array through a postgres.js unsafe placeholder.

In production this surfaced as:

new row for relation "op_checkpoints" violates check constraint "op_checkpoints_completed_keys_array"

The database constraint was correct; the writer was double-encoding the value by passing JSON.stringify(sorted) to $3::jsonb.

Change

  • Pass the JavaScript string[] directly to the $3::jsonb placeholder.
  • Keep the defensive fallback as an empty JavaScript array.
  • This preserves the v119 completed_keys array-shape guard and lets postgres.js serialize the JSONB value correctly.

Validation

bun test test/op-checkpoint*.test.ts
37 pass
0 fail

Also validated against the production Artie brain after the same fix:

  • gbrain sync --no-pull --no-embed completed successfully after previously aborting before import.
  • gbrain embed --stale restored missing embeddings to 0.
  • Retrieval gate remained healthy.

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