Skip to content

refactor: current split-file archive as the sole storage architecture - #1787

Merged
Sinity merged 71 commits into
masterfrom
feature/refactor/current-archive-runtime
Jun 9, 2026
Merged

Sinity merged 71 commits into
masterfrom
feature/refactor/current-archive-runtime

Conversation

@Sinity

@Sinity Sinity commented Jun 6, 2026 •

Copy link
Copy Markdown
Owner

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 / actions vocabulary, and lands the full #1743
scope — including the parity/structural tail that was briefly tracked as
separate post-#1743 issues and has since been folded back into #1743's
Pulled-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-shape
pending_blob_refs), single-DB read/write paths, and dead legacy modules. mypy
--strict flagged 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_meta escape hatch still on the parser-output models.

Solution

  • Remove obsolete surfaces: the dead legacy user-state half of
    sessions_identity.py (the repoint_user_state_by_identity machinery is
    obsolete now that session_id = origin:native_id is deterministic), the
    single-DB hook_paste_enrichment fallback, action_event*/provider/events
    packages, the provider-meta-policy verifier, and the dead RepositoryWriteMixin
    user-state stack (the live path routes through ArchiveStore).
  • Cross-tier reads: both the async cached path and the one-shot sync
    open_connection now ATTACH the sibling tiers to index.db connections, so
    unqualified 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.
  • Column/tier migrations: raw query layer (origin + INTEGER-ms columns,
    blob_hash), cursor.py → ingest_cursor, sampling_db.py source-tier
    reads, blob-GC lease management (pending_blob_refs BLOB 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_sessions origin column, and the
    user-state thread resolver.
  • Schema-column realization: parser/DDL fields that were declared but never
    populated are now wired through — instructions_text, title_source (closed
    origin/heuristic/unknown enum), session_agent_policies, token/cost
    aggregation, and batch [Pasted text #N] paste detection.
  • Parser-contract cleanup: removed provider_meta from all three Parsed*
    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 ContentBlockType into the single canonical BlockType enum.
  • Test conformance: seed via typed fields instead of the dropped
    provider_meta escape hatch; assert origin vocabulary and generated
    origin:native_id ids; regenerate snapshots; rewrite session-cost tests onto
    the typed per-message contract.

Completion scope (folded into #1743)

The parity/structural tail listed in #1743's "Pulled-In Scope" section all
lands here:

  • No parallel stacks: converged the two insight-rebuild implementations onto
    the single canonical rebuild_session_insights_sync; _rebuild_archive_session_insights
    is now a thin wrapper. Split the threads table ownership by column (topology
    owns the spine + thread_sessions via upsert; insights upsert analytics
    columns only, no destructive DELETE+INSERT that zeroed created_at_ms and
    cascade-wiped membership). Removed the session_profiles native-column /
    inference_payload_json duality on the write side.
  • Native read-surface parity: auto→hybrid retrieval elevation restored on the
    native path; readiness degraded/legacy taxonomy (fallback-reason counts from
    the inference_payload_json/enrichment_payload_json columns, incompatible
    verdict from materializer version); run_archive_readiness probes the active
    index.db; the semantic/hybrid graceful-degradation contract is documented and
    tested (empty leg, not an error, when embeddings are unready).
  • Ingest/maintenance correctness: source-scoped planning rescoped from the
    repurposed origin column to a source_path prefix; blob-GC generation
    tracking migrated to the current gc_generations(generation_id, *_at_ms, reclaimed_*) shape; the temporal input_high_water_mark_source taxonomy is
    persisted on insight_materialization.
  • Synthetic-corpus fidelity: the gemini and claude-ai synthetic generators
    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 (the
input_high_water_mark_source column), so an existing on-disk archive is
rejected on version mismatch and rebuilt from source. The operator transition is
external to the runtime:

  1. Move the existing archive files aside (a reversible move — the old files are
    preserved at the moved-to path, not deleted).
  2. polylogue maintenance archive-init --yes to create the current file set.
  3. polylogued run (or acquisition/ingest) re-acquires from source artifacts and
    rebuilds source.db + index.db. embeddings.db is rebuilt only if embedding
    is enabled.

user.db (marks, annotations, corrections, user tags, saved views, recall
packs) 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 of polylogue/tests/devtools): Success, 1604 source files.
  • ruff check . / ruff format --check .: clean.
  • Static gates (devtools verify --quick): render-all --check,
    verify-doc-commands, verify-topology, verify-layering,
    verify-test-infra-currency, verify-test-clock-hygiene all green.
  • Full suite (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 fails
    under 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).
  • Convergence adversarial check: after a full rebuild (session_ids=None),
    continuation-member sessions carry a 'thread' insight_materialization marker,
    thread_sessions is repopulated, threads.created_at_ms is not zeroed, and
    assess_session_insight_repairs(...).row_debt == 0.

Follow-ups (tracked, non-blocking)

🤖 Generated with Claude Code

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.
Copilot AI review requested due to automatic review settings June 6, 2026 10:59
@coderabbitai

coderabbitai Bot commented Jun 6, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Too many files!

This PR contains 300 files, which is 150 over the limit of 150.

To get a review, narrow the scope:
• coderabbit review --type committed # exclude uncommitted changes
• coderabbit review --dir # limit to a subdirectory
• coderabbit review --base # compare against a closer base

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 5f152b1a-ba95-4249-9d2e-f8990a215736

📥 Commits

Reviewing files that changed from the base of the PR and between 15af28c and cdfe703.

📒 Files selected for processing (300)
  • .github/workflows/extension-release.yml
  • .github/workflows/release.yml
  • AGENTS.md
  • CLAUDE.md
  • CONTRIBUTING.md
  • Containerfile
  • README.md
  • TESTING.md
  • browser-extension/src/common.js
  • browser-extension/tests/common.test.js
  • devtools/archive_space_report.py
  • devtools/benchmark_campaigns.py
  • devtools/benchmark_scenario_catalog.py
  • devtools/build_topology_projection.py
  • devtools/command_catalog.py
  • devtools/daemon_workload_probe.py
  • devtools/evidence_dashboard.py
  • devtools/inject_semantic_annotations.py
  • devtools/large_archive_generator.py
  • devtools/mutation_scenario_catalog.py
  • devtools/pages_builder.py
  • devtools/pipeline_probe/engine.py
  • devtools/pipeline_probe/request.py
  • devtools/pipeline_probe/result.py
  • devtools/render_cli_output_schemas.py
  • devtools/render_openapi.py
  • devtools/render_pages.py
  • devtools/render_quality_reference.py
  • devtools/self_verify.py
  • devtools/synthetic_benchmark_catalog.py
  • devtools/synthetic_benchmark_runtime.py
  • devtools/validation_lane_catalog_contracts.py
  • devtools/verify.py
  • devtools/verify_provider_meta_policy.py
  • devtools/verify_schema_upgrade_lane.py
  • devtools/verify_test_coverage_contracts.py
  • devtools/verify_test_infra_currency.py
  • docs/architecture-spine.md
  • docs/architecture.md
  • docs/audits/2026-05-19-closed-issue-workload-audit.md
  • docs/audits/2026-05-20-cross-surface-coherence-audit.md
  • docs/cli-audit.md
  • docs/cli-reference.md
  • docs/configuration.md
  • docs/cost-model.md
  • docs/daemon-threat-model.md
  • docs/daemon.md
  • docs/data-model.md
  • docs/design/agent-first-mcp.md
  • docs/design/archive-storytelling.md
  • docs/design/mk2/coding-agent-pack/01-github-issue-feat-surfaces.md
  • docs/design/mk2/coding-agent-pack/02-coding-agent-prompt.md
  • docs/design/mk2/coding-agent-pack/04-cli-enhancement-spec.md
  • docs/design/mk2/coding-agent-pack/05-daemon-api-contract.json
  • docs/design/mk2/coding-agent-pack/07-verification-and-visual-evidence.md
  • docs/design/mk2/design-canvas/artboard-dataflow.jsx
  • docs/design/mk2/design-canvas/artboard-handoff.jsx
  • docs/design/mk2/design-canvas/artboard-states.jsx
  • docs/design/mk2/design-canvas/artboard-tui.jsx
  • docs/design/mk3/docs/02-view-inventory.md
  • docs/design/project-memory.md
  • docs/design/second-brain.md
  • docs/design/time-machine.md
  • docs/design/whole-product.md
  • docs/devtools.md
  • docs/execution-plan.md
  • docs/export.md
  • docs/generate.md
  • docs/getting-started.md
  • docs/insights-rigor-matrix.md
  • docs/insights.md
  • docs/internals.md
  • docs/library-api.md
  • docs/maintenance.md
  • docs/mcp-integration.md
  • docs/mcp-reference.md
  • docs/onboarding.md
  • docs/openapi/search.yaml
  • docs/plans/api-parity.yaml
  • docs/plans/archive-file-set-status.md
  • docs/plans/assurance-domains.yaml
  • docs/plans/campaign-coverage.yaml
  • docs/plans/decisions/001-provider-source-column-consolidation.md
  • docs/plans/mk3-execution-log.md
  • docs/plans/oracle-quality.yaml
  • docs/plans/provider-meta-policy.yaml
  • docs/plans/scenario-coverage.yaml
  • docs/plans/schema-inventory.md
  • docs/plans/security-privacy-coverage.yaml
  • docs/plans/slo-catalog.yaml
  • docs/plans/test-clock-allowlist.yaml
  • docs/plans/test-closure-matrix.yaml
  • docs/plans/test-coverage-domains.yaml
  • docs/plans/test-coverage-exemptions.yaml
  • docs/plans/topology-target.yaml
  • docs/providers/README.md
  • docs/providers/chatgpt.md
  • docs/providers/claude-ai.md
  • docs/providers/claude-code.md
  • docs/providers/index.md
  • docs/providers/openai-codex.md
  • docs/release.md
  • docs/schema-annotations.md
  • docs/schema.md
  • docs/schemas/cli-output/README.md
  • docs/schemas/cli-output/search-envelope.schema.json
  • docs/schemas/cli-output/session-list-row.schema.json
  • docs/schemas/cli-output/session-neighbor-candidate.schema.json
  • docs/schemas/cli-output/session-search-hit.schema.json
  • docs/schemas/cli-output/session-summary.schema.json
  • docs/search.md
  • docs/security.md
  • docs/test-quality-workflows.md
  • docs/topology-status.md
  • docs/visual-evidence.md
  • flake.nix
  • nix/hm-module.nix
  • nix/homebrew-tap-template/Formula/polylogue.rb
  • nix/module.nix
  • polylogue/__init__.py
  • polylogue/api/__init__.py
  • polylogue/api/archive.py
  • polylogue/api/contracts/__init__.py
  • polylogue/api/contracts/api_write_surface.py
  • polylogue/api/contracts/assertions.py
  • polylogue/api/contracts/cli_write_surface.py
  • polylogue/api/contracts/mcp_write_surface.py
  • polylogue/api/contracts/read_surface.py
  • polylogue/api/contracts/tui_surface.py
  • polylogue/api/contracts/write_surface.py
  • polylogue/api/embeddings.py
  • polylogue/api/ingest.py
  • polylogue/api/insights.py
  • polylogue/api/search_envelope_builder.py
  • polylogue/api/sync/__init__.py
  • polylogue/api/sync/bridge.py
  • polylogue/api/sync/insights.py
  • polylogue/api/sync/sessions.py
  • polylogue/api/sync/view_loader.py
  • polylogue/api/user_state_resolver.py
  • polylogue/archive/actions/__init__.py
  • polylogue/archive/actions/actions.py
  • polylogue/archive/actions/fields.py
  • polylogue/archive/actions/parsing.py
  • polylogue/archive/artifact_taxonomy/__init__.py
  • polylogue/archive/artifact_taxonomy/models.py
  • polylogue/archive/artifact_taxonomy/runtime.py
  • polylogue/archive/artifact_taxonomy/support.py
  • polylogue/archive/attachment/models.py
  • polylogue/archive/conversation/__init__.py
  • polylogue/archive/conversation/branch_type.py
  • polylogue/archive/conversation/models.py
  • polylogue/archive/coverage.py
  • polylogue/archive/filter/builder.py
  • polylogue/archive/filter/filters.py
  • polylogue/archive/message/messages.py
  • polylogue/archive/message/model_runtime.py
  • polylogue/archive/message/models.py
  • polylogue/archive/message/roles.py
  • polylogue/archive/message/types.py
  • polylogue/archive/models.py
  • polylogue/archive/phase/extraction.py
  • polylogue/archive/projection/filter_mixin.py
  • polylogue/archive/projection/projections.py
  • polylogue/archive/projection/terminal_mixin.py
  • polylogue/archive/projection/transform_mixin.py
  • polylogue/archive/provider/__init__.py
  • polylogue/archive/provider/capabilities.py
  • polylogue/archive/query/archive_execution.py
  • polylogue/archive/query/facets.py
  • polylogue/archive/query/fields.py
  • polylogue/archive/query/miss_diagnostics.py
  • polylogue/archive/query/plan.py
  • polylogue/archive/query/plan_description.py
  • polylogue/archive/query/plan_execution.py
  • polylogue/archive/query/retrieval.py
  • polylogue/archive/query/retrieval_candidates.py
  • polylogue/archive/query/retrieval_search.py
  • polylogue/archive/query/runtime.py
  • polylogue/archive/query/runtime_filters.py
  • polylogue/archive/query/runtime_matching.py
  • polylogue/archive/query/runtime_plan.py
  • polylogue/archive/query/search_hits.py
  • polylogue/archive/query/sorting.py
  • polylogue/archive/query/spec.py
  • polylogue/archive/query/support.py
  • polylogue/archive/semantic/__init__.py
  • polylogue/archive/semantic/content_projection.py
  • polylogue/archive/semantic/cost_compute.py
  • polylogue/archive/semantic/facts.py
  • polylogue/archive/semantic/models.py
  • polylogue/archive/semantic/outlook.py
  • polylogue/archive/semantic/pricing.py
  • polylogue/archive/semantic/support.py
  • polylogue/archive/semantic/timing.py
  • polylogue/archive/session/attribution.py
  • polylogue/archive/session/branch_type.py
  • polylogue/archive/session/documents.py
  • polylogue/archive/session/domain_models.py
  • polylogue/archive/session/domain_runtime.py
  • polylogue/archive/session/events.py
  • polylogue/archive/session/extraction.py
  • polylogue/archive/session/models.py
  • polylogue/archive/session/neighbor_candidates.py
  • polylogue/archive/session/repo_identity.py
  • polylogue/archive/session/runtime.py
  • polylogue/archive/session/session_summaries.py
  • polylogue/archive/session/summary_runtime.py
  • polylogue/archive/session/threads.py
  • polylogue/archive/stats.py
  • polylogue/archive/topology/__init__.py
  • polylogue/archive/topology/edge.py
  • polylogue/archive/write_effects.py
  • polylogue/artifacts/runtime.py
  • polylogue/cli/archive_query.py
  • polylogue/cli/bulk_export.py
  • polylogue/cli/click_app.py
  • polylogue/cli/click_command_registration.py
  • polylogue/cli/click_option_groups.py
  • polylogue/cli/commands/backup.py
  • polylogue/cli/commands/blackboard.py
  • polylogue/cli/commands/completions.py
  • polylogue/cli/commands/context.py
  • polylogue/cli/commands/context_pack.py
  • polylogue/cli/commands/correlate.py
  • polylogue/cli/commands/cost.py
  • polylogue/cli/commands/dashboard.py
  • polylogue/cli/commands/diagnostics.py
  • polylogue/cli/commands/embed.py
  • polylogue/cli/commands/export.py
  • polylogue/cli/commands/facets.py
  • polylogue/cli/commands/feedback.py
  • polylogue/cli/commands/insights.py
  • polylogue/cli/commands/maintenance.py
  • polylogue/cli/commands/neighbors.py
  • polylogue/cli/commands/paths.py
  • polylogue/cli/commands/reset.py
  • polylogue/cli/commands/resume.py
  • polylogue/cli/commands/resume_candidates.py
  • polylogue/cli/commands/status.py
  • polylogue/cli/commands/status_diagnostics.py
  • polylogue/cli/commands/tags.py
  • polylogue/cli/commands/tutorial.py
  • polylogue/cli/commands/user_state.py
  • polylogue/cli/messages.py
  • polylogue/cli/output_assurance.py
  • polylogue/cli/parser_diagnostics.py
  • polylogue/cli/query.py
  • polylogue/cli/query_actions.py
  • polylogue/cli/query_contracts.py
  • polylogue/cli/query_feedback.py
  • polylogue/cli/query_output.py
  • polylogue/cli/query_output_contracts.py
  • polylogue/cli/query_progress.py
  • polylogue/cli/query_semantic.py
  • polylogue/cli/query_stats.py
  • polylogue/cli/query_verbs.py
  • polylogue/cli/root_request.py
  • polylogue/cli/select.py
  • polylogue/cli/shared/check_support.py
  • polylogue/cli/shared/embed_runtime.py
  • polylogue/cli/shared/embed_stats.py
  • polylogue/cli/shared/formatting.py
  • polylogue/cli/shared/helper_summary.py
  • polylogue/cli/shared/helpers.py
  • polylogue/cli/shared/insight_command_contracts.py
  • polylogue/cli/shared/latest_resolver.py
  • polylogue/cli/shared/machine_errors.py
  • polylogue/cli/shared/resume_rendering.py
  • polylogue/cli/shared/types.py
  • polylogue/cli/shell_completion_values.py
  • polylogue/config.py
  • polylogue/core/common.py
  • polylogue/core/degraded.py
  • polylogue/core/enums.py
  • polylogue/core/identity_law.py
  • polylogue/core/provider_identity.py
  • polylogue/core/sources.py
  • polylogue/core/timestamps.py
  • polylogue/core/user_state_targets.py
  • polylogue/daemon/backup.py
  • polylogue/daemon/catchup_status.py
  • polylogue/daemon/cli.py
  • polylogue/daemon/compare.py
  • polylogue/daemon/convergence.py
  • polylogue/daemon/convergence_debt_alert.py
  • polylogue/daemon/convergence_debt_status.py
  • polylogue/daemon/convergence_stages.py
  • polylogue/daemon/cursor_lag_baseline.py
  • polylogue/daemon/cursor_lag_status.py
  • polylogue/daemon/embedding_backlog.py
  • polylogue/daemon/embedding_readiness.py
  • polylogue/daemon/events.py
  • polylogue/daemon/events_http.py
  • polylogue/daemon/fts_startup.py
  • polylogue/daemon/fts_status.py
  • polylogue/daemon/health.py
  • polylogue/daemon/healthz.py
  • polylogue/daemon/http.py
  • polylogue/daemon/live_ingest_attempt_models.py

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/refactor/current-archive-runtime

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI 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.

Copilot wasn't able to review this pull request because it exceeds the maximum number of files (300). Try reducing the number of changed files and requesting a review from Copilot again.

github-actions Bot pushed a commit that referenced this pull request Jun 6, 2026
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.

@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: 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".

github-actions Bot pushed a commit that referenced this pull request Jun 6, 2026
@Sinity

Sinity commented Jun 6, 2026

Copy link
Copy Markdown
Owner Author

Addressed the two Codex inline findings on 12b47b17:

  • write_parsed_session_to_archive(..., merge_append=False) now clears writer-owned per-session projection rows before replacing the parsed snapshot: attachment refs, session events, outbound session links, working dirs, session repos, and session commits. Git columns on sessions now follow the replacement snapshot instead of preserving stale values.
  • Raw hook events now upsert by hook_event_id, so replaying the same acquired source refreshes the row instead of failing on the primary key.

Added regression coverage:

  • tests/unit/storage/test_archive_tiers_write.py::test_archive_tiers_writer_replacement_clears_old_projection_rows
  • tests/unit/storage/test_archive_tiers_source_write.py::test_archive_tiers_source_writer_replays_hook_events_idempotently

Verification run locally:

  • devtools test tests/unit/storage/test_archive_tiers_write.py tests/unit/storage/test_archive_tiers_source_write.py -> 19 passed.
  • devtools verify --quick -> exit_code 0 on 12b47b17.
  • Push pre-push quick gate -> exit_code 0 on 12b47b17.

Dogfood notes before deploy:

  • polylogue --plain paths --format json reports active archive root /home/sinity/.local/share/polylogue, active database /home/sinity/.local/share/polylogue/index.db, complete archive file set, and polylogue.db only under non_canonical_files.
  • POLYLOGUE_DAEMON_URL=http://127.0.0.1:1 polylogue --plain status --format json reports direct fallback active_db_path=/home/sinity/.local/share/polylogue/index.db.
  • The currently running daemon still serves db_path=/home/sinity/.local/share/polylogue/polylogue.db; that is the already-installed daemon binary and should be rechecked after deploying this PR.

Sinity added 4 commits June 6, 2026 13:09
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.
@Sinity

Sinity commented Jun 6, 2026

Copy link
Copy Markdown
Owner Author

Correction to the storage/runtime framing after review:

  • The retired single-file archive name is no longer treated as a meaningful product state. It is not routed, classified, upgraded, or specially reported by the current runtime.
  • polylogue.paths.db_path() now resolves to the current index.db path.
  • Live cursor selection no longer rewrites a retired archive filename to ops.db.
  • Reset and repair now operate from archive_root / the archive tier facade directly.
  • Tests and generated docs were scrubbed so ordinary fixtures use index.db, source.db, user.db, embeddings.db, and ops.db; unrelated SQLite files are named neutrally.

Verification on 85371e18:

  • devtools verify passed.
  • Push hook devtools verify --quick passed.
  • A targeted wording audit over polylogue, docs, devtools, tests, CLAUDE.md, and generated AGENTS.md returned no matches for the retired archive/schema-v1 framing terms.

github-actions Bot pushed a commit that referenced this pull request Jun 6, 2026
Sinity added 13 commits June 7, 2026 13:05
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
@Sinity

Sinity commented Oct 1, 2026

Copy link
Copy Markdown
Owner Author

Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.

  • 74.F093 / P1: fixed-already at the checked revision: Full replacement now clears all parser-owned child projections through _clear_session_projection_rows at polylogue/storage/sqlite/archive_tiers/write.py:3116. Its deletion set includes attachment_refs, usage events, working directories and repository edges at :3131-3137, and :3145 removes parser-owned session events while preserving the separately acquired capture-gap evidence.

Only the rows listed above are dispositioned. Held findings remain open.

@Sinity

Sinity commented Oct 1, 2026

Copy link
Copy Markdown
Owner Author

Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.

  • 75.F096 / P2: fixed-already at the checked revision: The hook writer checks the existing hook_event_id before insertion and returns on an exact semantic retry at polylogue/storage/sqlite/archive_tiers/source_write.py:1684-1688. A changed immutable event raises HookEventConflictError rather than an accidental UNIQUE failure, and identical re-ingestion never reaches the INSERT.

Only the rows listed above are dispositioned. Held findings remain open.

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.

Archive storage: clean-sheet current archive implementation

2 participants