Repository navigation
fix(storage): block schema version mismatch - #709
Conversation
Problem: the schema-version mismatch path claimed to recreate or upgrade an old archive, but it only reran additive CREATE IF NOT EXISTS DDL. That could leave incompatible old table shapes in place while advancing PRAGMA user_version. Read-only opens also skipped compatibility checks and could fail later with confusing SQL errors. What changed: reject mismatched schema versions for sync and async setup with the existing reset/re-import diagnostic, wire read-only connections through a non-mutating compatibility check, and remove the unused metadata export/import path that belonged to the misleading in-place recreate story. Update docs and assurance wording to say mismatch blocks instead of wiping or migrating. Verification: ruff check polylogue/storage/backends/schema.py polylogue/storage/backends/schema_bootstrap.py polylogue/storage/backends/connection.py tests/unit/storage/test_backend.py; ruff format --check polylogue/storage/backends/schema.py polylogue/storage/backends/schema_bootstrap.py polylogue/storage/backends/connection.py tests/unit/storage/test_backend.py; pytest -q tests/unit/storage/test_backend.py; devtools verify-manifests Ref #618
Problem: another agent started replacing local ISO parsing in materialization sort-key handling with the shared timestamp parser, but the worktree edit left duplicated imports and dead fallback code. What changed: finish the change by routing non-numeric sort-key parsing through polylogue.core.timestamps.parse_timestamp and add focused coverage for ISO datetimes and millisecond epoch normalization. Verification: ruff check polylogue/pipeline/materialization_runtime.py tests/unit/pipeline/test_materialization_runtime.py; ruff format --check polylogue/pipeline/materialization_runtime.py tests/unit/pipeline/test_materialization_runtime.py; pytest -q tests/unit/pipeline/test_materialization_runtime.py
|
Warning Rate limit exceeded
To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (10)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 0/1 reviews remaining, refill in 19 minutes and 33 seconds.Comment |
Polylogue Proof PackRefs: Affected Domains
Additional routed domains with zero affected claims
Focused Gates
Required PR Gates
Optional Confidence Gates
Known Gaps
Additional gaps in zero-claim routed domains
Oracle / Cost
|
Problem: another agent left a ChatGPT parser change that began teaching _coerce_float about ISO timestamp strings, but it was uncommitted and lacked parser-level coverage. What changed: finish the ChatGPT timestamp coercion fix and add coverage that ISO create_time values sort extracted messages chronologically. Verification: ruff check polylogue/sources/parsers/chatgpt.py tests/unit/sources/test_parsers_chatgpt.py; ruff format --check polylogue/sources/parsers/chatgpt.py tests/unit/sources/test_parsers_chatgpt.py; pytest -q tests/unit/sources/test_parsers_chatgpt.py tests/unit/pipeline/test_materialization_runtime.py
There was a problem hiding this comment.
Pull request overview
This PR tightens SQLite archive schema handling by making schema-version mismatches fail explicitly (including for read-only opens) rather than attempting partial “upgrade” behavior, and completes a materialization timestamp parsing fix by routing ISO timestamps through the shared timestamp parser.
Changes:
- Reject schema-version mismatches in sync and async schema initialization with a clear reset/re-import diagnostic.
- Add a read-only layout/version compatibility check for
open_read_connection()to fail early on incompatible archives. - Fix materialization timestamp sort-key parsing by using
parse_timestamp()and add unit coverage for ISO and millisecond-epoch inputs.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
polylogue/storage/backends/schema.py |
Raises DatabaseError on version mismatch; adds assert_readable_archive_layout() for read-only compatibility checks. |
polylogue/storage/backends/connection.py |
Invokes read-only compatibility checks during open_read_connection(). |
polylogue/storage/backends/schema_bootstrap.py |
Updates version-mismatch diagnostic message and removes unused metadata export/import helpers. |
polylogue/pipeline/materialization_runtime.py |
Uses shared parse_timestamp() for non-numeric timestamp sort keys. |
tests/unit/storage/test_backend.py |
Updates schema-mismatch expectations and adds coverage for read-only mismatch behavior. |
tests/unit/pipeline/test_materialization_runtime.py |
Adds tests for ISO datetime and millisecond epoch sort-key normalization. |
docs/plans/assurance-domains.yaml |
Updates assurance notes to reflect “block on mismatch” behavior. |
docs/architecture.md |
Updates architecture docs to reflect mismatch rejection behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if decision.action == "version_mismatch": | ||
| _handle_version_mismatch(conn, decision.current_version or 0) | ||
| raise DatabaseError(schema_version_mismatch_message(decision.current_version or 0)) | ||
| return |
| raise DatabaseError(schema_version_mismatch_message(decision.current_version or 0)) | ||
| return |
| raise DatabaseError(schema_version_mismatch_message(decision.current_version or 0)) | ||
| return |
Summary: Make mismatched archive schema versions fail explicitly instead of pretending to recreate or migrate legacy layouts, and incorporate timestamp parsing fixes left in the worktree by another agent. Problem: #618 identified that the version-mismatch path claimed to preserve metadata and recreate the database, but the implementation only reran additive CREATE IF NOT EXISTS DDL. That could leave old table shapes in place while setting PRAGMA user_version to the current schema. Read-only opens also skipped compatibility checks, so old databases could fail later with unclear SQL errors. Separately, another agent had started replacing local timestamp parsing in materialization and ChatGPT ordering with the shared timestamp parser; those edits were present in the worktree but needed cleanup and coverage. Solution: Reject schema-version mismatches in sync and async schema setup with the reset/re-import diagnostic. Add a non-mutating read-only compatibility check so open_read_connection() fails clearly on mismatched versions or known legacy inline raw layouts. Remove the unused metadata export/import recreate path tied to the misleading in-place upgrade story. Update architecture and assurance text to say mismatches block rather than wipe or migrate. Finish the materialization and ChatGPT timestamp fixes by routing non-numeric timestamp parsing through parse_timestamp() and adding focused coverage. Verification: ruff check polylogue/storage/backends/schema.py polylogue/storage/backends/schema_bootstrap.py polylogue/storage/backends/connection.py polylogue/pipeline/materialization_runtime.py tests/unit/storage/test_backend.py tests/unit/pipeline/test_materialization_runtime.py; ruff format --check polylogue/storage/backends/schema.py polylogue/storage/backends/schema_bootstrap.py polylogue/storage/backends/connection.py polylogue/pipeline/materialization_runtime.py tests/unit/storage/test_backend.py tests/unit/pipeline/test_materialization_runtime.py; pytest -q tests/unit/storage/test_backend.py tests/unit/pipeline/test_materialization_runtime.py; ruff check polylogue/sources/parsers/chatgpt.py tests/unit/sources/test_parsers_chatgpt.py; ruff format --check polylogue/sources/parsers/chatgpt.py tests/unit/sources/test_parsers_chatgpt.py; pytest -q tests/unit/sources/test_parsers_chatgpt.py tests/unit/pipeline/test_materialization_runtime.py; devtools verify-manifests; devtools render-all --check; git push pre-push hook ran devtools verify --quick and passed. Ref #618
Summary
Make mismatched archive schema versions fail explicitly instead of pretending to recreate or migrate legacy layouts, and incorporate timestamp parsing fixes left in the worktree by another agent.
Problem
#618 identified that the version-mismatch path claimed to preserve metadata and recreate the database, but the implementation only reran additive
CREATE ... IF NOT EXISTSDDL. That could leave old table shapes in place while settingPRAGMA user_versionto the current schema. Read-only opens also skipped compatibility checks, so old databases could fail later with unclear SQL errors.Separately, another agent had started replacing local timestamp parsing in materialization and ChatGPT ordering with the shared timestamp parser. Those edits were present in the worktree but needed cleanup and coverage.
Solution
open_read_connection()fails clearly on mismatched versions or known legacy inline raw layouts.parse_timestamp()and covering ISO datetime plus millisecond epoch behavior.create_timevalues participate in message ordering, with parser-level coverage.Verification
ruff check polylogue/storage/backends/schema.py polylogue/storage/backends/schema_bootstrap.py polylogue/storage/backends/connection.py polylogue/pipeline/materialization_runtime.py tests/unit/storage/test_backend.py tests/unit/pipeline/test_materialization_runtime.pyruff format --check polylogue/storage/backends/schema.py polylogue/storage/backends/schema_bootstrap.py polylogue/storage/backends/connection.py polylogue/pipeline/materialization_runtime.py tests/unit/storage/test_backend.py tests/unit/pipeline/test_materialization_runtime.pypytest -q tests/unit/storage/test_backend.py tests/unit/pipeline/test_materialization_runtime.pyruff check polylogue/sources/parsers/chatgpt.py tests/unit/sources/test_parsers_chatgpt.pyruff format --check polylogue/sources/parsers/chatgpt.py tests/unit/sources/test_parsers_chatgpt.pypytest -q tests/unit/sources/test_parsers_chatgpt.py tests/unit/pipeline/test_materialization_runtime.pydevtools verify-manifestsdevtools render-all --checkgit pushpre-push hook:devtools verify --quickpassedRef #618