Repository navigation
refactor: current split-file archive as the sole storage architecture - #1787
Conversation
Replace the old archive storage branch with the current file-set runtime as the only archive path. The implementation routes surfaces through source.db, index.db, embeddings.db, user.db, and ops.db, removes in-place upgrade-chain code, and updates generated docs/tests around session/origin/archive terminology. Old polylogue.db files are not a runtime mode or readiness blocker. Operators move out-of-band state aside, initialize the current archive files, and re-acquire from source. Ref #1743 Verification: POLYLOGUE_PYTEST_WORKERS=4 devtools verify --seed-testmon --skip-slow; POLYLOGUE_PYTEST_WORKERS=4 devtools verify.
|
Important Review skippedToo many files! This PR contains 300 files, which is 150 over the limit of 150. To get a review, narrow the scope: ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (300)
You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ 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. Comment |
The browser-extension package-lock.json is gitignored, but setup-node was configured to require it for npm cache setup. Remove the cache configuration so the existing npm install fallback can run in CI. Verification: devtools verify-ci-workflows; devtools verify --quick.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: af271cb72e
ℹ️ 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".
|
Addressed the two Codex inline findings on
Added regression coverage:
Verification run locally:
Dogfood notes before deploy:
|
Problem: old archive filenames were still surfaced as a compatibility condition through paths output and connection-open helpers, which kept implying a handled legacy archive mode. What changed: removed the archive.db/polylogue.db symlink helper, stopped paths from reporting unrelated archive-root files, made fresh count/stats/list reads return empty results before archive files exist, and renamed test/runtime vocabulary that implied legacy routing. Backup directories now use an unnumbered archive prefix. Verification: devtools test tests/unit/cli/test_paths.py tests/unit/cli/test_plain_output_contract.py tests/unit/daemon/test_backup.py tests/unit/daemon/test_daemon_cli.py tests/unit/daemon/test_daemon_status.py tests/unit/daemon/test_embedding_readiness.py tests/unit/cli/test_embed_status_fast.py tests/unit/daemon/test_convergence_stages.py tests/unit/daemon/test_raw_failure_sample.py tests/unit/storage/test_user_state_contracts.py tests/unit/storage/test_archive_tiers_write.py tests/unit/storage/test_archive_tiers_source_write.py; uv run devtools verify-distribution-surface --work-dir /tmp/polylogue-dist-check-fresh --keep-work-dir; devtools lab-scenario verify-baselines; devtools verify --quick
Problem: render-pages --check compared the ignored .cache/site output against a fresh render, so CI failed from a clean checkout even when the pages renderer was valid. What changed: treat an absent output directory as a successful renderability check after building the temporary site. Existing output directories are still hash-compared so stale local caches remain detectable. Verification: devtools render-pages --check --output /tmp/polylogue-missing-site-check; devtools render-all --check --skip agents; devtools test tests/unit/site/test_renderer_behavior.py tests/unit/devtools/test_render_all.py; devtools verify --quick
Problem: current archive code and tests still treated the retired single-file archive name as a meaningful product state. That kept stale routing, fixture names, and generated docs tied to a file that should not be special-cased by the current runtime. What changed: default database resolution now points at index.db, live cursor and reset paths no longer rewrite or derive from the retired filename, session-insight repair uses the archive tier facade, and fixtures/docs now describe the archive by its current tier files or by neutral stray SQLite files. Verification: devtools verify (exit_code=0; ruff, mypy, render-all, static gates, and pytest-testmon all passed). Forbidden-term audit: rg over polylogue/docs/devtools/tests/CLAUDE.md/AGENTS.md for retired archive/schema-v1 phrasing returned no matches.
|
Correction to the storage/runtime framing after review:
Verification on
|
Lands the remaining #1743 migration surface and conforms the Python runtime to the already-migrated split-file archive schema (source/index/embeddings/user/ops .db) with origin/native_id vocabulary. What changed: - Remove obsolete storage surfaces entirely: action_event / action_events packages, provider/events.py, insights/storage.py, the legacy ingest-batch append helpers, and the provider_meta classification policy (devtools/verify_provider_meta_policy.py, docs/plans/provider-meta-policy.yaml). - Remove the dead legacy user-state half of sessions_identity.py (add_mark/save_annotation/repoint_user_state_by_identity/save_workspace/... against nonexistent user_marks/user_annotations/reader_workspaces). The repository write/read path goes through archive_tiers/user_write.py upsert_* against the new (target_type,target_id) tables. The identity repoint pass is obsolete: session_id = origin:native_id is deterministic across reset+reimport, so marks rebind with no repoint. - Delete the single-DB fallback in hook_paste_enrichment.py that read a removed sessions.provider_meta column; the archive (index.db) path is the only supported path. - Reconcile user_state_targets registry with the marks/annotations target_type CHECK list (drop duplicate 'session', add missing 'phase'). - Fix production type conformance against the migrated domain models: renderer reads typed attachment display_name instead of the removed provider_meta dict; hydrator builds Message(provider=...); add None guards and fix variance/redundant-expr findings surfaced by mypy --strict. Verification: - mypy polylogue/ : Success, no issues found in 844 source files - ruff check . : All checks passed - ruff format --check . : 1626 files already formatted Ref #1743
The test layer still constructed/read the old provider-era model shapes (source_name, provider_session_id, provider_meta, TransformResult.bundle, removed columns), which mypy --strict flagged across 34 files. What changed: - SessionRecord/SessionEvent: source_name/provider_session_id → origin/native_id; origin args now pass Origin (Origin.from_string / origin_from_provider) not str/Provider. - Drop the removed provider_meta kwarg/attribute from Session, Attachment, SessionSummary, AttachmentRecord, classify_state, and SessionBuilder.add_attachment; map display info to the typed display_name / name / source_url / metadata fields. - TransformResult.bundle is gone: read result.session (ParsedSession) and flatten content blocks from its messages; rewrite tests/infra save_transform_and_hydrate to write via write_parsed_session_to_archive and hydrate through session_from_records. - Rewrite the removed-_transform_to_tuples tests against the current persistence seam (write_parsed_session_to_archive + the actions view). - Fix stale infra SELECTs that referenced removed columns (blocks.metadata, attachments.provider_meta) and crashed at runtime with OperationalError. - ParsedMessage role args pass Role; ParsedContentBlock list items are typed objects; ArchiveEmbeddingMeta uses its current fields; ArchiveTier imports from archive_tiers.types. - Regenerate docs/devtools.md (drop deleted verify-provider-meta-policy) and the topology projection (844 realized == 844 declared). Verification: - mypy : Success, no issues found in 1623 source files - ruff check . : All checks passed; ruff format --check . : clean - devtools verify-doc-commands / verify-topology / verify-test-infra-currency : green Ref #1743
…ry_state column
rebuild.py SESSION insight template had a literal '{}' (empty-JSON metadata)
inside a str.format() call, raising IndexError on every insight load batch.
Escaped to '{{}}'. hook_paste_enrichment inserted paste_spans.boundary, but
the column is boundary_state.
Ref #1743
… reads The split-file migration left the async backend's read paths querying source-tier tables (raw_sessions, raw_artifacts, blob_refs) on the index.db connection, which only sees index tables -> 'no such table: raw_sessions' across raw reads, parse-tracking, sampling, and probes. Attach source.db/user.db/embeddings.db/ops.db to index.db connections (idempotent, guarded against the existing per-site ATTACH calls) so unqualified table names resolve across tiers and cross-tier joins (sessions.raw_id -> raw_sessions.raw_id) work in one query. SQLite resolves unqualified names to main first, so index-tier tables are unaffected; only sibling-only tables resolve to their attached tier. Per-tier write connections are unchanged. Ref #1743
Mirror the async cross-tier ATTACH on the sync connection path so sync readers (schema sampling, devtools probes, retention) resolve source/user/embeddings/ops tier tables by unqualified name. Ref #1743
The user-state resolver queried a nonexistent threads.root_session_id; in the current schema thread_id IS the root session id. Resolve thread targets by thread_id existence. Drop the redundant duplicate 'session' entry from the target-kind registry (set semantics already deduped it). Ref #1743
The migration shifted audited interpolation sites and added safe ones (cross-tier ATTACH schema name from a closed tuple; record-projection SELECT constants; native-id placeholder strings; bound correction clauses). Update _TRUSTED_IDENTIFIER_NAMES and the chunked-IN audited line. All interpolated values remain trusted compile-time identifiers or bound-param placeholder strings; no user input reaches a query string. Ref #1743
Migrate the runtime read/write surfaces still on pre-#1743 column and table names to the current split-file archive schema. - raw query layer (raw_state.py, raw_reads.py, raw_writes.py, mappers_archive.py, async_sqlite_raw.py, sessions_reads.py): map raw_sessions onto origin + INTEGER-ms columns (parsed_at_ms, validated_at_ms, acquired_at_ms, file_mtime_ms, detection_warnings_json), collapse source_name/payload_provider onto origin, derive blob_hash, and fix a stray un-migrated list_sessions_by_parent projection. - cursor.py: the file-stat cursor now reads/writes the unified ops-tier ingest_cursor (stat_size, updated_at_ms) instead of the removed source_file_cursor table. - schemas/sampling_db.py: read raw_sessions from the source tier with origin + ms columns, resolve blobs by blob_hash; group by c.origin. - ops tier (ops.py): add otlp_spans and otlp_telemetry tables the OTLP receiver and span writer target; daemon_workload_probe boundary table ingest_attempt -> live_ingest_attempt. - devtools/pipeline_probe/engine.py: drop the removed EFFECTIVE_RAW_PROVIDER_SQL import and the dead single-file raw fallback. Tests across raw, parse-tracking, sampling, schema-generation, analytics, indexing, prepare, branching, ingest-batch, otlp, fts-global-repair, and benchmarks updated to seed via typed fields and the generated id scheme. Verification: mypy --strict clean (1623 files); ruff clean. Ref #1743
…ubsystem Wave-2 conformance across filters, semantics, hybrid, storage tiers, cli/ui/sources, snapshots, and pricing, plus the artifact-observation subsystem migration. Production: - Migrate the artifact-observation writers/readers (storage/artifacts/*, storage/sqlite/queries/artifacts.py) off the removed artifact_observations table onto raw_artifacts (origin + INTEGER-ms columns; drop wire_format, bundle_scope, resolution fields). Unblocks acquisition-time artifact storage. - hybrid_sessions.py scope filter sessions.source_name -> sessions.origin. - hook_paste_enrichment paste_spans insert now includes the NOT NULL position column (hook-derived spans were silently dropped by OR IGNORE). Tests: seed via typed fields (working_directories/git_branch/content_blocks) instead of the dropped provider_meta escape hatch; assert origin vocabulary and generated origin:native_id ids; regenerate stale syrupy snapshots; rewrite session-reported-cost tests onto the typed per-message cost contract (the metadata cost seam is removed per #803/#1139); content-addressed attachment expectations. Verification: mypy --strict clean (1623 files); ruff clean. Ref #1743
- cwd filter SQL now uses the session_working_dirs table + cwd.path (not json_each/working_directories); seed via working_directories_json; origin token + generated origin:native_id session ids. - fts5 since-filter parametrize: message_id is session_id:native_id, drop the doubled session segment from expected ids. - _row_to_raw_session test row uses the origin column + INTEGER-ms columns; source_name/payload_provider project from origin. Ref #1743
|
Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.
Only the rows listed above are dispositioned. Held findings remain open. |
|
Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.
Only the rows listed above are dispositioned. Held findings remain open. |
Summary
Makes the split-file archive (
source.db/index.db/embeddings.db/user.db/ops.db) the only supported Polylogue storage runtime, per #1743.Removes the old single-file archive paths and compatibility framing, migrates
storage/query/runtime/test/doc surfaces to the current schema and
origin/native_id/session_events/actionsvocabulary, and lands the full #1743scope — including the parity/structural tail that was briefly tracked as
separate
post-#1743issues and has since been folded back into #1743'sPulled-In Scope section.
Closes #1743.
Problem
The current-archive runtime had landed at the DDL level, but large parts of the
Python runtime, query layer, and test suite still spoke the pre-split schema:
old physical table/column names (
source_name,provider_meta,parsed_at,acquired_at,source_file_cursor,artifact_observations, old-shapepending_blob_refs), single-DB read/write paths, and dead legacy modules. mypy--strictflagged 112 inconsistencies and the suite had 183 runtime failures —many from production code reading the wrong tier or stale columns, not just test
drift. Beyond that initial conformance pass, a tail of completion work remained:
two parallel insight-rebuild stacks, native read-surface features the old
runtime had (auto→hybrid elevation, readiness degraded/legacy taxonomy), and a
provider_metaescape hatch still on the parser-output models.Solution
sessions_identity.py(therepoint_user_state_by_identitymachinery isobsolete now that
session_id = origin:native_idis deterministic), thesingle-DB
hook_paste_enrichmentfallback,action_event*/provider/eventspackages, the provider-meta-policy verifier, and the dead
RepositoryWriteMixinuser-state stack (the live path routes through
ArchiveStore).open_connectionnow ATTACH the sibling tiers toindex.dbconnections, sounqualified cross-tier names (
raw_sessions,blob_refs,pending_blob_refs)resolve (SQLite main-wins keeps index tables unaffected). This was the
keystone fix for ~50 "no such table: raw_sessions" failures.
origin+ INTEGER-ms columns,blob_hash),cursor.py→ingest_cursor,sampling_db.pysource-tierreads, blob-GC lease management (
pending_blob_refsBLOB hash +ref_type/ref_id/acquired_at_ms), the artifact-observation subsystem →raw_artifacts, OTLP tables added to the ops tier, FTS-template brace bug,paste_spans.boundary_state,hybrid_sessionsorigin column, and theuser-state thread resolver.
populated are now wired through —
instructions_text,title_source(closedorigin/heuristic/unknown enum),
session_agent_policies, token/costaggregation, and batch
[Pasted text #N]paste detection.provider_metafrom all threeParsed*models (the one live consumer became the typed
ParsedAttachment.attachment_kind;two half-wired features were realized into typed sinks instead of deleted) and
merged
ContentBlockTypeinto the single canonicalBlockTypeenum.provider_metaescape hatch; assertoriginvocabulary and generatedorigin:native_idids; regenerate snapshots; rewrite session-cost tests ontothe typed per-message contract.
Completion scope (folded into #1743)
The parity/structural tail listed in #1743's "Pulled-In Scope" section all
lands here:
the single canonical
rebuild_session_insights_sync;_rebuild_archive_session_insightsis now a thin wrapper. Split the
threadstable ownership by column (topologyowns the spine +
thread_sessionsvia upsert; insights upsert analyticscolumns only, no destructive DELETE+INSERT that zeroed
created_at_msandcascade-wiped membership). Removed the
session_profilesnative-column /inference_payload_jsonduality on the write side.native path; readiness degraded/legacy taxonomy (fallback-reason counts from
the
inference_payload_json/enrichment_payload_jsoncolumns,incompatibleverdict from materializer version);
run_archive_readinessprobes the activeindex.db; the semantic/hybrid graceful-degradation contract is documented andtested (empty leg, not an error, when embeddings are unready).
repurposed
origincolumn to asource_pathprefix; blob-GC generationtracking migrated to the current
gc_generations(generation_id, *_at_ms, reclaimed_*)shape; the temporalinput_high_water_mark_sourcetaxonomy ispersisted on
insight_materialization.were over-filling every optional message field, which broke render (gemini) and
pushed the discriminating key past the 8 KB acquire detection prefix
(claude-ai → 0 sessions). Reset to realistic compact shapes; all five
per-provider workflow tests pass un-xfailed. Real-export detection is
unaffected.
Re-ingest plan (schema change)
This is a deletes-then-defines schema change, not an in-place upgrade. The
index tier bumps to
INDEX_SCHEMA_VERSION = 3(theinput_high_water_mark_sourcecolumn), so an existing on-disk archive isrejected on version mismatch and rebuilt from source. The operator transition is
external to the runtime:
preserved at the moved-to path, not deleted).
polylogue maintenance archive-init --yesto create the current file set.polylogued run(or acquisition/ingest) re-acquires from source artifacts andrebuilds
source.db+index.db.embeddings.dbis rebuilt only if embeddingis enabled.
user.db(marks, annotations, corrections, user tags, saved views, recallpacks) is the durable human-authored tier; the move-aside preserves every tier,
so it survives the rebuild. Expected impact: a full rebuild re-parses the source
corpus (tens of minutes on a large archive); FTS and derived insights are
rebuilt automatically.
Verification
mypy(strict, all ofpolylogue/tests/devtools): Success, 1604 source files.ruff check ./ruff format --check .: clean.devtools verify --quick):render-all --check,verify-doc-commands,verify-topology,verify-layering,verify-test-infra-currency,verify-test-clock-hygieneall green.devtools verify --all, 16 workers): 10,250 passed, 2 xfailed,1 failed. The single failure is
test_messages_fts_trigger_growth_is_subquadratic,a wall-clock perf benchmark that passes in isolation (
-n 0) and only failsunder 16-worker CPU contention — the known xdist-load instability tracked in
Stabilize devtools verify --all under xdist load #1775, unrelated to this PR (nothing here touches the messages FTS triggers).
session_ids=None),continuation-member sessions carry a
'thread'insight_materialization marker,thread_sessionsis repopulated,threads.created_at_msis not zeroed, andassess_session_insight_repairs(...).row_debt == 0.Follow-ups (tracked, non-blocking)
content_blocks→blocksin the in-memory models/tests(functionally correct today; a large low-risk naming sweep, deliberately
deferred to keep this PR reviewable).
merge-enabling level during the split-file migration; this PR raises it back
toward target as the suite regreens).
🤖 Generated with Claude Code