- postgres/: mod.rs (module doc + shared structs + re-exports), pool.rs (constructor family + pin-TTL consts), schema.rs (bootstrap/GC DDL + catalog probe), cas.rs (the Backend row body + cursor pair + delete_batch), pins.rs (the whole EngineFleetState impl — the associated-type-bearing trait impl cannot split across files, recorded adjustment), windows.rs (the window family), joint.rs (PgJointTx + sweep_lock_key + the joint/sweep tests), testing.rs (the schema-per-test fixtures); tests ride their subjects - pg_lo/: mod.rs (doc + PgLoBackend/PgLoStaging), staging.rs (the held-tx staging cursor incl. its Drop body, the fleet joint form, the LO primitives), windows.rs (lo_get windows + the streaming cursor + the Backend companion-row body + the window-family clauses), reap.rs (the orphan-recovery sweep — wave 9's F-4 anchor), testing.rs (the per-test dedicated-database fixtures); tests ride their subjects - the blanket #![allow(dead_code)] removed from both engines; the genuinely not-yet-consumed items carry scoped, consumer-named allowances (delete_batch, both system_identifiers, the reaper, the pg-lo joint failure knob); nanos_to_time/new_schemaless moved into the cfg(test) fixture modules - doc touch-ups as audit exceptions: the two pre-split allow paragraphs reworded to the scoped-allowance/split-layout state; stale src/postgres.rs / src/pg_lo.rs prose refs -> directory forms Verification: slice-based pure moves (anchor-asserted) + a line-diff audit showing only the expected edit classes; lib.rs byte-unchanged; test lists diff 1:1 vs pre-split (path relocations only, counts exact): live harness --features postgres 186+87, --features pg-lo 155+71, --all-features 271+125, all green; server-less default/all-features green with clean skips; clippy (-D warnings) default/postgres/pg-lo/ all-features; fmt; cargo doc zero warnings Tasks: split-postgres-pg-lo (status: completed)
8.4 KiB
id, name, status, depends_on, scope, risk, impact, level, tags
| id | name | status | depends_on | scope | risk | impact | level | tags | |||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| split-postgres-pg-lo | postgres.rs → postgres/, pg_lo.rs → pg_lo/ — the engine giants split; re-exports unchanged | completed |
|
moderate | medium | component | implementation |
|
Description
Review-001 D-1's other two god files: src/postgres.rs (2,936) and
src/pg_lo.rs (3,089) — the two SQL-tier engines. Same method as the
sibling splits: pure moves, no behavior change, lib.rs re-exports
unchanged, #[cfg(feature)] gates moving with the module. The file
boundaries between the engines are already clean (the wave-4/5 seam
pattern); the splits are within-engine.
postgres.rs (feature postgres) — proposed shape, the task's to
adjust with a recorded note:
postgres/mod.rs— module doc + intra-re-exports.postgres/schema.rs— bootstrap/ensure, the session options, thebusy_timeout-analogue posture text.postgres/pool.rs— the pool setup and the per-connection prepared-statement discipline (PgOptsitself is not here — it lives inpg_common.rs, which stays as it is).postgres/cas.rs— the CAS rows, the stable-cursor list, batch-delete,synchronous_commitparity.postgres/pins.rs— the pin clause family (pin_commit/pin_renew/pin_check/arbitrate's SQL half).postgres/windows.rs— the window family +reap_orphans' kv-side neighbors.postgres/joint.rs—PgJointTxand the sweep lock (sweep_lock_acquire/release).- tests ride their subject modules.
pg_lo.rs (feature pg-lo) — proposed shape:
pg_lo/mod.rs— module doc + intra-re-exports.pg_lo/staging.rs—PgLoStaging(the staged chunkedlowritetx, its Drop body).pg_lo/windows.rs— descriptorlesslo_getwindows + the companion rows + the size probes.pg_lo/reap.rs—reap_orphans/reap_orphans_tx(wave 9's F-4 work concentrates here — that is why it gets its own file).- tests ride their subject modules.
pg_common.rs (321 lines) stays as it is — it is not a god file and
its shared clauses are already the extracted shape. The blanket
dead-code allows follow the sibling splits' discipline. No fixing:
F-2/F-4 are wave 9's; the D-2 coverage work is wave 9's too.
Acceptance Criteria
- both files are directory modules;
lib.rs's re-export set byte-identical (audited) - every moved region is a move, not a rewrite (move detection on the diff; spot-reads against the old blobs)
- the feature gates intact:
pg-lowithoutpostgresstill compiles (ADR-010 §1's consequence), the pg-pure builds check clean - the
pg_lostaging/joint-tx Drop bodies land unmodified in their new homes (F-2's wave-9 anchor points preserved) - the full suite green (default,
--all-featuresserver-less; the live-pg acceptance runs at the wave gate) - gates green:
cargo test,cargo test --all-featuresserver-less, clippy across variants (incl. the pg-pure), fmt, doc
References
- docs/reviews/001-storage-surface-general-review.md (D-1; F-2/F-4 as the wave-9 anchors this split prepares)
- docs/plans/implementation.md (§Wave 8; §Review gates — the split gate)
- src/postgres.rs, src/pg_lo.rs (the files this task splits)
- docs/architecture/decisions/007-two-kv-engines-sqlite-and-postgres.md, 009-pg-lo-large-tier-engine.md, 010-backend-io-seams-and-fleet-state-home.md (the engines' contracts — the module docs the splits inherit)
- tasks/split-store.md, tasks/split-ops.md (the sibling splits; the same method and audit)
Summary
Completed 2026-10-16. Both god files became directory modules as pure moves — every moved region is a byte-identical slice of the old blob (slice-based assembly with anchor assertions, then a line-diff audit showing only the expected edit classes: module-doc headers, import headers, visibility widenings, scoped allow lines, test-mod wrappers).
lib.rsis byte-unchanged (thepub moddeclarations resolve to the directories as-is) andstore.rs's imports (crate::postgres::{PgJointTx, PostgresBackend, PostgresCursor},crate::pg_lo::{PgLoBackend, PgLoCursor, PgLoStaging},crate::postgres::DEFAULT_PIN_TTL_SECS,crate::pg_lo::LOWRITE_CHUNK) all hold their paths via the intra-module re-exports.Design-point adjustments (recorded per the task charter):
- The
impl EngineFleetStateis one trait impl and cannot split (it carries theJointTxassociated type) — so it lives whole inpins.rs:begin_joint_tx/joint_putjoined the pin clauses (pin_commit/pin_renew/pin_check/pin_reap/arbitrate) and the sweep lease.joint.rsstill gets its task shape: thePgJointTximpl, thesweep_lock_keyhelper (pub(super), the lock-key namespace), and the joint-tx + sweep-lease tests. The window-family trait impl stayed whole inwindows.rs; theBackendimpls stayed whole incas.rs/windows.rs.- The shared structs stay on the module roots —
PostgresBackend
PgJointTxinpostgres/mod.rs,PgLoBackend+PgLoStaginginpg_lo/mod.rs— so the sibling impl blocks keep their field access without visibility edits per field;PgLoCursoris wholly inpg_lo/windows.rs(constructed and read only there). DDL helpers live inschema.rs/pg_lo's mod root (pub(super)); the LO statement primitives (lo_create/lo_open/lowrite_all) live inpg_lo/staging.rs, the window machinery (lo_get_window/read_windows) inpg_lo/windows.rs.- The blanket
#![allow(dead_code)]is gone from both engines (the sibling splits' discipline). The truly not-yet-consumed items carry scoped allowances with the consumer named:PostgresBackend::delete_batch(the sweep-batch shape; the store core's delete paths arbitrate and delete per key),PostgresBackend::system_identifierandPgLoBackend::system_identifier(the pg-lo fleet constructor, featurepg-lo/all(postgres, pg-lo)), thepg_loreaper impl (reap_orphans/reap_orphans_tx— wave 9's F-4 anchor, whose consumer is the embedder's operator runbook), and the pg-lo test-only mid-driver failure-injection knob (its store-core consolidation driver is theall(postgres, pg-lo)build's consumer).nanos_to_timemoved into thecfg(test)fixture modules (its only consumers),new_schemalesswith it.pg_lo/testing.rs(cfg test): the per-test dedicated-database harness, the DSN plumbing, the read-seam/staged helpers, and the catalog probes for the zero-residue gates.postgres/testing.rsthe schema-per-test harness twin. The pg-loHarness.dsnfield is the joint-form tests' second-engine handle.- Shared test fixtures (
pg_common.rs'stest_support) untouched; thecrate::postgres::test_supportre-export preserved.Verification (live pg harness, the dockerized
pglo-pocpostgres:16-alpineon :15432 — thanks to the session's flag): withALKBLOBS_PG_*set,cargo test --features postgres(186 lib
- 87 conformance),
--features pg-lo(155 + 71), and--all-features(271 + 125) ran for real, all green — and the lib test lists diff 1:1 against pre-split (only path relocationspostgres::tests::X→postgres/<file>::tests::X, counts exact). Server-less variants (cargo test,cargo test --all-featureswithout env) skip the pg columns cleanly and are green. Gates:cargo clippyacross default/postgres/pg-lo/--all-features(-D warnings),cargo fmt --check,cargo doc --no-deps(zero warnings). Audit exceptions (doc touches, not code): the two module-doc allow paragraphs rewritten to describe the scoped allowances + the split layout; stale file references (src/postgres.rs/src/pg_lo.rsprose in the pg_lo module doc andpg_common.rs's shared-helper doc) updated to the directory forms. One pre-existing, unreproduced flake observed during the runs:ops::harness::the_paused_fleet_token_expires_reaps_and_the_reput_ backstop_never_loses_silently(ops.rs — untouched by this split) failed once in two live full-suite runs and passed everywhere else, including three consecutive live runs after; watch it at the wave gate. The pristine-baselinecargo clippy --no-default-features --all-targetsfailure (empty engine-enum exhaustiveness in store.rs) is pre-existing and outside this task's gate list.