fix(file-search): store workspace file revisions at millisecond precision - #7941
Conversation
…sion The content revision round-trips through JavaScript Date and JSON, both of which truncate to milliseconds, while now() stores microseconds. A sub-millisecond revision stops comparing equal to its own round-trip, so every SQL equality keyed on it matches zero rows and the file is never claimed, indexed, or cleaned up. Truncate at the column default and enforce it with a BEFORE trigger for the writers a default cannot reach, then retire the rows minted before the invariant existed in a batched script migration.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
There was a problem hiding this comment.
All reported issues were addressed across 8 files
Tip: cubic can generate docs of your entire codebase and keep them up to date. Try it here.
Fix all with cubic | Re-trigger cubic
A chat upload is materialized into a workspace file by setting context alone, so the revision is never written and the search-index trigger would key the promoted file to a value nothing can claim. Fire the normalizer on every update; `UPDATE OF` is evaluated against the statement's target columns, so this does not demote provenance on a metadata write. Accept the shared integration database in the repair suite the way the sibling suites do, and record the new script migration in the registry order assertions.
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
No issues found across 10 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Tip: cubic can generate docs of your entire codebase and keep them up to date. Try it here.
Re-trigger cubic
Staging took 0357 for the outbox autovacuum migration. The SQL is byte for byte the previously reviewed file; only the number and the references to it changed.
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
No issues found across 10 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Tip: cubic can generate docs of your entire codebase and keep them up to date. Try it here.
Re-trigger cubic
Summary
workspace_files.content_updated_atis a revision identity that round-trips through JavaScriptDateand JSON (both millisecond), whilenow()stores microseconds. A sub-millisecond revision stops comparing equal to its own round-trip, so every SQL equality keyed on it matches zero rows — the file is never claimed, never indexed, and never cleaned up, because the only cleanup path (markTerminal) is itself gated behind being dispatched.0357truncates the column default and adds aBEFORE INSERT OR UPDATEtrigger for the writers a default cannot reach: explicitCURRENT_TIMESTAMPexpressions, raw SQL inserts, and any UPDATE. It is DDL-only, so it stays idempotent under the autocommit path a fresh install takes after0355's embeddedCOMMIT, and holds its lock for DDL rather than for a data rewrite.0018retires the rows minted before the invariant existed, keyset-paginated and batched. Each batch is one transaction so thesecret_provenance_versionthatworkspace_files_secret_provenance_demotenulls is restored with its sidecar, instead of being lost if a run dies midway.context = 'workspace', live and soft-deleted: those are the rows the search index keys on, and a soft-deleted row is restored by paths that do not rewrite the column. Other contexts are never search-indexed and only compare this column in JavaScript, where both sides are already millisecond; the trigger normalizes them on their next content write.workspace_files_secret_provenance_demote, so that trigger'sWHENclause compares the normalized value and a write that does not change the millisecond revision no longer demotes provenance. There is a test for both directions.Type of Change
Testing
CURRENT_TIMESTAMPrestore write, trigger ordering vs provenance demotion in both directions) and the repair (scoping, sidecar realignment, orphaned index/segment rows, replay no-op, keyset progress). Wired into the existingpackages/dbCI step.workspace_files: 94,196 rows repaired in 2.4s, replay a 0.5s no-op, other contexts untouched, tracked provenance versions and sidecars preserved.0357applies and replays cleanly both in autocommit and inside a transaction.bun run lint, all 46 audits,docs-manifest:check,check:migrations origin/staging, andtype-checkpass.Checklist