Repository navigation
Conversation
Move the connection-bound schema and index helpers of HistoryStore into the new module history_service/store_schema.py. HistoryStore keeps a method under every moved name, with the same signature and the same staticmethod or instance kind, that passes the store module (and the store, for instance helpers) to the moved code. The moved code looks every store-module name up on that module at call time, so a replacement made on the store module or class still takes effect. The new module imports nothing first-party and does not import the store module. HistoryStore keeps the connection, the migration lock and every commit and rollback: _initialize_schema, _backfill_disk_identity_keys, _index_build_lower_bound_bytes, build_chronological_index and _release_failed_index_build stay where they are. No behaviour, error text, log line or migration policy changes. Refs #1328
The move dedented the interior lines of the multi-line SQL literals along with the code, so a fresh database stored its two identity index statements with four fewer spaces than before. Restore the original indentation inside every non-docstring literal of the moved helpers, and pin the stored index SQL in a test. Refs #1328
|
@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
🛡️ Codex Security Review · Automatically triggeredSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
What moved
The connection-bound schema and index helpers of
HistoryStoremove fromhistory_service/store.pyinto the new modulehistory_service/store_schema.py. There are 22 of them, in their original order:_synchronize_table_counts,_rowid_span,_has_table,_recount_implausible_table_counts,_recount_table,_recount_restored_table_counts,_backfill_disk_identity_keys_once,_ensure_slot_state_columns,_ensure_slot_event_columns,_ensure_metric_sample_columns,_backfill_disk_identity_batch,_ensure_identity_indexes,_missing_chronological_indexes,_ensure_chronological_indexes,_apply_bulk_maintenance_profile,_filesystem_key,_index_key_columns,_index_build_disk_needsand_ensure_columns._describe_free_space,_require_index_build_spaceand_describe_startup_space_failure.HistoryStorekeeps the connection, the migration lock and every commit and rollback. These stay instore.pyunchanged:_initialize_schema,_backfill_disk_identity_keys(it commits each batch),_index_build_lower_bound_bytes(it commits a corrected counter),build_chronological_index,_release_failed_index_build(it rolls back),pending_chronological_indexes,index_maintenance,exact_count_scan,_wait_for_exact_count_scansandsqlite_temporary_directory. The schema text and every constant also stay instore.py.Behaviour is unchanged
HistoryStorekeeps a method under every moved name. Each one keeps the original signature (including theHISTORY_COUNTED_TABLESdefault) and the originalstaticmethodor instance kind, soinspect.getattr_staticstill finds astaticmethodfor each kill phase. Each one calls the moved function and passes the store module (and the store, for instance helpers).store.pyglobals through that module at call time:HistoryStore, the constants,logger,host_repair_path,HistoryIndexBuildSpaceError,osandshutil. A replacement on the store module or class therefore still takes effect. Examples arestore_module.CHRONOLOGICAL_INDEX_INLINE_MAX_ROWS,store_module.DISK_IDENTITY_BACKFILL_BATCH_SIZEandsetattr(HistoryStore, "_backfill_disk_identity_batch", ...). Log records still come from thehistory_service.storelogger.store_schemaimports nothing first-party and does not importstore, so there is no cycle and no new cross-package import.store.pykeepshost_repair_pathimported (withnoqa: F401) because the moved code reads it there.sqlite_master) is byte-for-byte what it was; a script compared all 59 string literals of the 22 moved functions withmainand found no difference. A bare store global becamestore_module.NAME,selfbecamestore, and each signature gained thestore_moduleparameter (plusstorefor instance helpers). No statement was reordered, reworded or fixed. Migration policy and the v1 and v2 contracts are unchanged.Tests
Seven new tests are in
tests/test_history_deferred_indexes.py(StoreSchemaModuleTests):history_service.store, and it has no first-party import.HistoryStore, with the same kind, parameters and return annotation as the moved function.HistoryStoremethod (_ensure_columns);SLOT_EVENT_OPTIONAL_COLUMNS,CHRONOLOGICAL_INDEX_INLINE_MAX_ROWS,logger);_filesystem_key,sqlite_temporary_directory,host_repair_path).Before the move, the first six failed because
history_service.store_schemadid not exist (Ran 6 tests ... FAILED (failures=1, errors=5)). No existing test line changed. The one other test-file edit is thehistory_service/store.pyceiling intests/test_source_shape.py, lowered from 6000 to 5500 as that check asks.store.pywent from 5507 to 5231 lines, andstore_schema.pyis 415 lines.Local runs used
python -m unittest(SQLite 3.50.4; this change relies on nothing that differs from 3.45.1). All passed with 0 skipped:tests.test_history_service: 340 tests.tests.test_history_deferred_indexes,tests.test_history_released_schema_upgrades,tests.test_image_upgrade_contract,tests.test_dev_checkandtests.test_ci_contract: 279 tests.tests.test_source_shape,tests.test_unittest_shards,tests.test_unittest_identitiesandtests.test_changelog_fragmentswithStoreSchemaModuleTests: 139 tests.ruff check --select E4,E7,E9,Fandgit diff --checkare clean.Left out
The plan expected 500 to 750 lines. This move is 363 method lines. The helpers that commit or roll back (
_backfill_disk_identity_keys,_index_build_lower_bound_bytes,_release_failed_index_build) stay onHistoryStore, so that it keeps every transaction.Refs #1328