Skip to content

fix(tracker): sync the replica before the bulk import's parity check - #1359

Open
joeharris76 wants to merge 2 commits into
developfrom
fix/findings-import-parity-replica-sync
Open

fix(tracker): sync the replica before the bulk import's parity check#1359
joeharris76 wants to merge 2 commits into
developfrom
fix/findings-import-parity-replica-sync

Conversation

@joeharris76

Copy link
Copy Markdown
Owner

The bulk transfer writes straight to the primary, while the command's connection reads through a local embedded replica opened before it. Parity was computed against that stale replica, so a CORRECT import reported every record absent: the first production run printed 'PARITY FAILED' immediately after transferring all 432 rows successfully, and a fresh connection then confirmed parity OK 64/64 with zero diffs.

It fails safe -- staleness can only under-report presence, never invent it -- but it makes the exit code untrustworthy, which defeats the point of a self-asserting rung. Sync before comparing, with a regression test asserting parity is never computed against an unsynced replica.

The bulk transfer writes straight to the primary, while the command's connection reads through a local embedded replica opened before it. Parity was computed against that stale replica, so a CORRECT import reported every record absent: the first production run printed 'PARITY FAILED' immediately after transferring all 432 rows successfully, and a fresh connection then confirmed parity OK 64/64 with zero diffs.

It fails safe -- staleness can only under-report presence, never invent it -- but it makes the exit code untrustworthy, which defeats the point of a self-asserting rung. Sync before comparing, with a regression test asserting parity is never computed against an unsynced replica.
@joeharris76
joeharris76 enabled auto-merge (squash) July 30, 2026 19:06
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

…tracker

Phase 5's import is complete: all 65 records are in the tracker's findings tables at SCHEMA_VERSION 4, with verified field-level parity (every frontmatter key, every body section byte-for-byte, each triage-log line as one imported_triage_log event) and a byte-identical finding_events restore proof.

Announce the freeze at the top of the directory README, point capture and triage at the todo finding subcommands, and state plainly that the freeze IS the rollback window: these files stay until phase 6 so a parity problem still has a fallback. Git history is untouched either way.

Copy link
Copy Markdown
Owner Author

@codex review

@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: 9d2d237a21

ℹ️ 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 on lines +1714 to +1716
replica_sync = getattr(conn, "sync", None)
if callable(replica_sync):
replica_sync()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Serialize the post-transfer replica sync

When another tracker process starts in the same worktree during this bulk import, this call can sync the shared replica concurrently because the connection-time _replica_setup_lock has already been released. _project/scripts/todo_db.py explicitly identifies concurrent multi-process sync as a corruption hazard and serializes every existing open-and-sync operation, so this additional sync should use the same lock or a synchronized connection helper.

Useful? React with 👍 / 👎.

Comment on lines +1714 to +1716
replica_sync = getattr(conn, "sync", None)
if callable(replica_sync):
replica_sync()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Convert post-transfer sync failures into tracker errors

When the transfer succeeds but the subsequent replica refresh fails because of a network, authentication, or local-replica error, _HostedConnection.sync() forwards the raw libsql exception while todo_db.main() only catches TodoError and sqlite3.Error around dispatch. Such a failure therefore produces a traceback after the data has already landed instead of the tracker's clean, redacted exit-2 error; wrap or map the sync exception before it escapes.

Useful? React with 👍 / 👎.

Comment on lines +5 to +6
> All 65 records now live in the shared tracker's findings tables
> (`SCHEMA_VERSION` 4), imported with verified field-level parity: every

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Correct the frozen corpus record count

The directory contains 65 Markdown files only when README.md is counted; the importer and parity_report() explicitly exclude that file, leaving 64 actual records, consistent with the reported 64/64 parity run. Claiming that all 65 records were imported overstates the migration proof used to justify the phase-6 demolition, so this should say 64 or explicitly identify a separate 65th database record.

Useful? React with 👍 / 👎.

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