Skip to content

test: add golden rendering checks and broaden archive health - #58

Closed
Sinity wants to merge 5 commits into
masterfrom
feature/testing/golden-tests-health-checks-hooks
Closed

Sinity wants to merge 5 commits into
masterfrom
feature/testing/golden-tests-health-checks-hooks

Conversation

@Sinity

@Sinity Sinity commented Apr 7, 2026 •

Copy link
Copy Markdown
Owner

Summary

I used this branch to turn a loosely covered archive surface into something that produces sharper regressions. The work lands in four layers: optional git hooks for local workflow hygiene, expanded polylogue check coverage for empty conversations and FTS drift, a proper golden-test framework for rendering, and much broader semantic/provider test coverage. Hardened the SQLite setup and a few parser edges that were making concurrent and corpus-backed tests noisier than they needed to be. The common theme is not "more tests" in the abstract; it is making the failures that matter show up earlier and in a more legible form. That is especially important after the previous architectural refactors, because rendering and parser behavior now spans more seams and needed stronger contracts.

Motivation

There were two related gaps in the test story.

First, rendering and semantic behavior were mostly verified through small assertions embedded in broader tests. That made regressions hard to diagnose. If markdown ordering changed, or Unicode started being mangled, or a tool-use block rendered differently, the failure usually appeared as a surprising string mismatch somewhere downstream rather than as a snapshot diff that told me exactly what changed.

Second, the health/check surface was too optimistic. I could create empty conversations while debugging, or blow away the FTS table during index work, and polylogue check still lacked a targeted opinion about those states. For a tool that relies heavily on FTS-backed queries, not noticing index drift is a real blind spot.

The branch also inherited some fragility from earlier refactors: import paths had shifted, concurrent tests occasionally tripped SQLite lock errors, and parser failures could disappear into swallowed JSON exceptions. Fixing those was part of making the new tests trustworthy.

Changes by concern

Optional workflow hooks

I added local git workflow aids rather than repository-enforced policy:

  • .gitconfig now includes a handful of history/review aliases and better diff/conflict defaults
  • .githooks/commit-msg warns on non-conventional commit subjects but does not reject the commit
  • .githooks/pre-push warns on WIP/messy subjects and asks for confirmation before pushing

The important implementation choice is that these are soft checks. They are meant to catch avoidable mistakes in local development, not to become a second CI system or a source of surprise failures. .githooks/README.md documents installation and bypass so contributors can opt in explicitly.

Health surface checks the states we actually debug

polylogue/health.py gains two checks that were missing in practice:

  • empty_conversations: conversations that exist without any messages
  • fts_sync: missing messages_fts table or message/FTS row-count drift

That makes polylogue check substantially more useful during storage/index work. A healthy database is not just "foreign keys and duplicates look fine"; it is also "the content the query layer depends on is present and in sync."

Made the supporting plumbing a little sturdier:

  • storage/backends/sqlite.py creates parent directories before connect and sets PRAGMA busy_timeout = 30000
  • storage/search_providers/fts5.py stops calling connection_context() with the stale signature
  • ingestion/source.py no longer swallows JSONDecodeError in the final fallback path

That last change is subtle but important: if a source file is invalid, the system should count and report it, not quietly limp past it.

Golden tests and semantic API coverage

The new golden framework is intentionally simple:

tests/golden/<case>/
  input/
  expected/
  metadata.yaml

tests/test_golden_outputs.py exercises the renderer against cases that matter to humans reading archive output: simple ChatGPT dialogue, Claude thinking blocks, JSON tool-use formatting, empty-message elision, Unicode preservation, attachment formatting, and timestamp ordering. tests/scripts/update_golden.py provides the update path when rendering intentionally changes.

Added tests/test_semantic_api_comprehensive.py, which is effectively the contract test suite for the semantic/domain layer. It covers things like:

  • DialoguePair validation
  • message metadata extraction (cost_usd, duration_ms)
  • conversation aggregates (total_cost, tags, display title)
  • iteration helpers (pairs, thinking, substantive, dialogue)
  • string/render helpers (to_text, to_clean_text)

That suite is valuable because it verifies archive semantics independently of the CLI and independently of raw provider parsing.

Real-data parser tests and manual verification

tests/test_providers_real_data.py adds skip-gated parser tests for ChatGPT and Claude production exports. These are not always available in every environment, so they are gated rather than mandatory, but they are still worth keeping in-tree because they let us validate real export shapes when the corpus is present.

Added tests/manual/verify_database.sh, verify_attachments.sh, and verify_filesystem.sh for targeted local spot checks. These are not meant to replace automated tests; they exist because archive tooling sometimes benefits from a quick "inspect the actual on-disk outcome" loop.

Test-suite cleanup and concurrency stability

The first commit in the branch unblocked a very large set of tests after import-path fallout. From there I cleaned up some patterns that were creating avoidable noise:

  • import updates to polylogue.storage.backends.sqlite
  • removal of nested connection-depth assertions that no longer matched the backend behavior
  • explicit conn.commit() calls and early WAL setup in a few concurrent tests
  • replacement of some caplog assertions with stdout/stderr capture where structlog formatting had made log-text checks brittle
  • addition of pytest-xdist so the suite can scale better locally

Testing

The work is directly exercised by:

  • tests/test_golden_outputs.py
  • tests/test_semantic_api_comprehensive.py
  • tests/test_providers_real_data.py
  • updated tests/test_health.py, tests/test_check.py, tests/test_db.py, and tests/test_pipeline_concurrent.py
  • manual verification scripts under tests/manual/

Notes

The real-data tests are intentionally skip-gated. They provide value when the production-shaped fixtures are available, but I did not want this branch to make the open-source/dev test path depend on private corpora.

For reviewers, the most important question is whether the new golden cases capture the renderer semantics we actually care about. If they do, future output changes should become much easier to review and much harder to miss.

Sinity and others added 5 commits January 30, 2026 04:30
Phase 1 of comprehensive testing plan - fixes blocking import errors
that prevented test suite execution.

Changes:
- Updated all test imports: polylogue.storage.db → polylogue.storage.backends.sqlite
- Fixed 24 test files with collection errors
- Added WAL mode initialization in concurrent tests to prevent database locks
- Updated .gitignore for test artifacts
- Consolidated test_db.py and test_db_store.py (removed duplication)

Test Results: All previously blocked tests now executable

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Phase 3: Added 53 new tests covering semantic API gaps including
DialoguePair validation, message metadata extraction, conversation
metadata, and iteration helpers.

Coverage added:
- DialoguePair validation (10 tests)
- Message metadata (cost_usd, duration_ms) (8 tests)
- Conversation metadata (user_title, display_title, tags) (12 tests)
- Iteration helpers (iter_pairs, iter_thinking, iter_substantive) (15 tests)
- Conversation rendering (to_text, to_clean_text) (8 tests)

Test Results: +53 tests, all passing

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Phase 4: Created tests using actual ChatGPT and Claude export files
to validate ZIP parsing, conversation structure, and metadata extraction.

Tests added:
- ChatGPT ZIP parsing and conversation extraction (6 tests)
- Claude ZIP parsing and conversation extraction (6 tests)
- Real export data validation (branching, attachments, metadata)

Uses real exports from: /realm/data/exports/chatlog/raw/

Test Results: +12 tests, all passing

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Phase 5: Created comprehensive golden test infrastructure with 12 tests
that verify rendered output matches expected behavior. Documents current
rendering logic and catches regressions.

Infrastructure created:
- tests/test_golden_outputs.py (12 tests across 3 categories)
- tests/golden/README.md (documentation)
- tests/scripts/update_golden.py (regeneration utility)

Tests cover:
- Markdown rendering (8 tests)
- File structure (2 tests)
- Edge cases (2 tests)

Key findings documented:
- Thinking blocks (<thinking>...</thinking>) preserved as-is ✓
- JSON auto-formatted in code blocks ✓
- Unicode fully preserved ✓
- Long text not truncated (30KB+ tested) ✓
- Markdown special chars not escaped ✓

Test Results: +12 tests, 1375 total passing

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Phase 6 (partial): Created manual testing protocol and verification scripts.
Manual execution against real data still pending.

Infrastructure created:
- MANUAL_TESTING_PROTOCOL.md (7-layer testing protocol)
- tests/manual/setup_test_data.sh (test data preparation)
- tests/manual/verify_database.sh (SQL integrity checks)
- tests/manual/verify_filesystem.sh (output structure validation)
- tests/manual/verify_attachments.sh (attachment reference validation)

Next: Execute protocol against real exports (especially Gemini with auth)

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Copilot AI review requested due to automatic review settings April 7, 2026 13:12
@coderabbitai

coderabbitai Bot commented Apr 7, 2026 •

Copy link
Copy Markdown

Warning

Rate limit exceeded

@Sinity has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 13 minutes and 3 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 13 minutes and 3 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 5dec633b-409b-4cf3-952c-0bcf4b01161b

📥 Commits

Reviewing files that changed from the base of the PR and between 9195ef4 and 4938357.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock, !**/*.lock
📒 Files selected for processing (44)
  • .gitignore
  • polylogue/health.py
  • polylogue/ingestion/source.py
  • polylogue/storage/backends/sqlite.py
  • polylogue/storage/search_providers/fts5.py
  • pyproject.toml
  • tests/factories.py
  • tests/golden/README.md
  • tests/manual/setup_test_data.sh
  • tests/manual/verify_attachments.sh
  • tests/manual/verify_database.sh
  • tests/manual/verify_filesystem.sh
  • tests/scripts/update_golden.py
  • tests/test_check.py
  • tests/test_cli.py
  • tests/test_cli_sync.py
  • tests/test_db.py
  • tests/test_db_store.py
  • tests/test_facade.py
  • tests/test_filters.py
  • tests/test_golden_outputs.py
  • tests/test_health.py
  • tests/test_indexing_service.py
  • tests/test_ingest_render.py
  • tests/test_lib.py
  • tests/test_pipeline.py
  • tests/test_pipeline_concurrent.py
  • tests/test_pipeline_runner.py
  • tests/test_pipeline_services.py
  • tests/test_providers_real_data.py
  • tests/test_prune_performance.py
  • tests/test_renderers.py
  • tests/test_rendering_core.py
  • tests/test_repository_render.py
  • tests/test_run.py
  • tests/test_search.py
  • tests/test_search_health.py
  • tests/test_search_index.py
  • tests/test_search_providers.py
  • tests/test_semantic_api_comprehensive.py
  • tests/test_server.py
  • tests/test_simple_coverage.py
  • tests/test_source_ingest.py
  • tests/test_store.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/testing/golden-tests-health-checks-hooks

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

@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: 493835705c

ℹ️ 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".

Comment thread polylogue/health.py Resolved
Sinity added a commit that referenced this pull request Apr 7, 2026
…ns (#58)

Wire developer-workflow tooling, expand the health-check surface, harden
SQLite connection setup, and backfill test coverage across rendering,
semantic API, and provider parsing.

Git hooks and developer config:
- .gitconfig with merge-commit workflow aliases (lg, review, incoming,
  cleanup) and histogram diff, zdiff3 conflict markers
- commit-msg hook: soft conventional-commit format validation with
  color-coded reminder — commits always proceed
- pre-push hook: detects WIP/messy commit subjects and prompts before
  push; also warns on non-conventional format
- .githooks/README.md documents installation and bypass

Health checks (polylogue/health.py):
- empty_conversations check: flags conversations with zero messages
- fts_sync check: compares messages table count against messages_fts,
  reports missing FTS index or row-count drift

Storage hardening:
- sqlite.py: mkdir parents before connect, add PRAGMA busy_timeout
  30000 to reduce lock-contention failures in concurrent workflows
- fts5.py: fix connection_context() call that passed spurious None
  first argument after the signature changed
- source.py: remove swallowed JSONDecodeError in _iter_json_stream
  fallback path — errors now propagate so cursor_state tracks failures

Golden test framework:
- tests/golden/README.md defines the case structure (input/expected/
  metadata.yaml) and update workflow
- tests/scripts/update_golden.py regenerates expected/ from current
  rendering code for chatgpt-simple and claude-thinking cases
- tests/test_golden_outputs.py: snapshot tests covering markdown
  rendering of ChatGPT, Claude thinking blocks, JSON tool use, empty
  messages, Unicode preservation, attachments, and timestamp ordering

Semantic API test suite (tests/test_semantic_api_comprehensive.py):
- 53 tests covering DialoguePair validation, Message metadata
  extraction (cost_usd, duration_ms), Conversation aggregation
  (total_cost, tags, display_title), iteration helpers (pairs,
  thinking, substantive, dialogue), and rendering (to_text,
  to_clean_text)

Provider real-data tests (tests/test_providers_real_data.py):
- pytest.skip-gated tests exercising ChatGPT and Claude ZIP parsers
  against production exports on /realm/data, plus provider detection
  and end-to-end import cycle verification

Test modernization across ~20 files:
- Consolidate imports: polylogue.storage.db → .backends.sqlite,
  polylogue.pipeline.models → .storage.store
- Remove tests for deprecated nested-connection depth tracking
- Replace caplog assertions with capsys for structlog compatibility
- Pre-initialize WAL mode and add explicit conn.commit() in
  concurrent tests to reduce SQLite lock contention
- Add pytest-xdist (parallel execution) to dev dependencies

Scaffolding:
- CLAUDE.md symlink → AGENTS.md
- scripts/generate_screenshots.py for README asset generation
- tests/manual/ verification scripts for database, attachments,
  and filesystem spot-checks
- .gitignore entries for test datasets

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.

Pull request overview

This PR strengthens Polylogue’s regression signals by expanding health/check coverage, hardening SQLite connection behavior for concurrent tests, and adding broader test suites (including a new “golden” rendering test scaffold and comprehensive semantic API tests).

Changes:

  • Add new health checks for empty conversations and FTS index/table sync issues; improve SQLite connection setup (parent dir creation, busy timeout).
  • Add new test suites for renderer output (“golden” scaffold), semantic/domain model contracts, and skip-gated real-data provider parsing.
  • Update many tests to new SQLite backend import paths and add local/manual verification scripts; add pytest-xdist to dev deps.

Reviewed changes

Copilot reviewed 43 out of 45 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
uv.lock Adds pytest-xdist (and execnet) to the locked dev dependency set.
pyproject.toml Adds pytest-xdist to dev extras.
.gitignore Ignores local/real test datasets under tests/datasets/ and tests/test-datasets/*.
polylogue/storage/search_providers/fts5.py Updates connection_context usage to match the new signature.
polylogue/storage/backends/sqlite.py Ensures DB parent dirs exist and sets PRAGMA busy_timeout to reduce lock flakiness.
polylogue/ingestion/source.py Stops swallowing JSONDecodeError in the final JSON-load fallback so failures can be tracked.
polylogue/health.py Adds empty_conversations and fts_sync checks; health report is a dataclass-based API.
tests/factories.py Ensures test DB parent directory exists; updates open_connection import path.
tests/golden/README.md Documents intended golden test directory structure and update workflow.
tests/test_golden_outputs.py Introduces “golden” rendering tests scaffold and renderer/file-structure assertions.
tests/scripts/update_golden.py Adds a script intended to regenerate golden expected files.
tests/manual/verify_filesystem.sh Adds manual script to inspect rendered filesystem output.
tests/manual/verify_database.sh Adds manual script to inspect DB integrity/content via sqlite3.
tests/manual/verify_attachments.sh Adds manual script to inspect attachment tables/refs via sqlite3.
tests/manual/setup_test_data.sh Adds manual helper to copy sample exports into a local test inbox.
tests/test_semantic_api_comprehensive.py Adds a comprehensive semantic API contract test suite for polylogue.lib.models.
tests/test_providers_real_data.py Adds skip-gated tests against real export paths and a local Cody JSON fixture.
tests/test_health.py Updates health-cache tests to capture structlog output via capsys; removes timing sleeps.
tests/test_source_ingest.py Updates invalid JSON ingestion expectations to require failure tracking (comment cleanup).
tests/test_store.py Updates SQLite connection imports to polylogue.storage.backends.sqlite.
tests/test_search.py Updates SQLite connection imports to polylogue.storage.backends.sqlite.
tests/test_search_providers.py Updates SQLite connection imports to polylogue.storage.backends.sqlite.
tests/test_search_index.py Updates SQLite connection imports to polylogue.storage.backends.sqlite.
tests/test_search_health.py Updates health result access to dataclass properties; updates DB module monkeypatch import.
tests/test_run.py Updates SQLite connection imports; adjusts rerender test to rely on content hashing rather than mtime sleep.
tests/test_repository_render.py Consolidates SQLite backend/open_connection imports from polylogue.storage.backends.sqlite.
tests/test_rendering_core.py Updates SQLite connection imports to polylogue.storage.backends.sqlite.
tests/test_renderers.py Updates SQLite connection imports to polylogue.storage.backends.sqlite.
tests/test_prune_performance.py Updates SQLite connection imports to polylogue.storage.backends.sqlite.
tests/test_pipeline.py Updates SQLite connection imports to polylogue.storage.backends.sqlite.
tests/test_pipeline_services.py Updates connection_context import to polylogue.storage.backends.sqlite.
tests/test_pipeline_runner.py Updates PlanResult/RunResult imports and SQLite connection imports.
tests/test_pipeline_concurrent.py Updates SQLite connection imports to polylogue.storage.backends.sqlite.
tests/test_lib.py Updates SQLite connection imports to polylogue.storage.backends.sqlite.
tests/test_ingest_render.py Updates SQLite connection imports to polylogue.storage.backends.sqlite.
tests/test_indexing_service.py Updates SQLite connection imports to polylogue.storage.backends.sqlite.
tests/test_db.py Removes tests relying on old connection nesting semantics; adds WAL pre-init for thread isolation tests; updates migration patching.
tests/test_db_store.py Aligns with new connection semantics (manual commits / reduced concurrency); updates imports.
tests/test_simple_coverage.py Updates VerifyStatus import to polylogue.health.
tests/test_server.py Updates reload logic for polylogue.storage.backends.sqlite identity concerns; removes old db module reload.
tests/test_facade.py Pre-initializes WAL mode before concurrent ingestion to reduce lock contention.
tests/test_filters.py Updates SQLite connection imports to polylogue.storage.backends.sqlite.
tests/test_cli.py Removes sleep and uses touch() for deterministic mtime update in a race-condition test.
tests/test_cli_sync.py Updates PlanResult/RunResult imports.
tests/test_check.py Updates SQLite connection imports and adds explicit commits to ensure check fixtures persist.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread polylogue/health.py
Comment on lines +196 to +200
if fts_exists:
# Count messages in both tables
msg_count = conn.execute("SELECT COUNT(*) FROM messages").fetchone()[0]
fts_count = conn.execute("SELECT COUNT(*) FROM messages_fts").fetchone()[0]

Copilot AI Apr 7, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FTS sync check compares total messages vs total FTS rows, but the FTS index is built only from messages with non-null text (see storage.index/rebuild_index WHERE messages.text IS NOT NULL). This will produce false WARNINGs when there are attachment-only or null-text messages. Consider comparing against COUNT(*) FROM messages WHERE text IS NOT NULL (and possibly text != '') instead of all messages.

Copilot uses AI. Check for mistakes.
Comment thread tests/test_db.py
_ensure_schema,
_run_migrations,
connection_context,
default_db_path,

Copilot AI Apr 7, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default_db_path is imported but no longer referenced in this test module. With ruff's default F/pyflakes rules enabled, this will fail CI as an unused import (F401). Remove the import or add a test that uses it.

Suggested change
default_db_path,

Copilot uses AI. Check for mistakes.
Comment on lines +13 to +16
import pytest

from polylogue.lib.models import Attachment, Conversation, DialoguePair, Message, Role

Copilot AI Apr 7, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Role is imported but never used. Ruff will flag this as an unused import (F401). Please remove it or use it in assertions/types to keep the suite lint-clean.

Copilot uses AI. Check for mistakes.
Comment on lines +298 to +305
def test_message_metadata_immutability():
"""Message provider_meta should not be modifiable after creation."""
msg = Message(id="1", role="user", text="Hello", provider_meta={"key": "value"})
# Accessing provider_meta should work
assert msg.provider_meta["key"] == "value"
# But mutation of the dict affects the message
msg.provider_meta["new_key"] = "new_value"
assert msg.provider_meta["new_key"] == "new_value"

Copilot AI Apr 7, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docstring says provider_meta "should not be modifiable after creation", but the test then mutates msg.provider_meta and asserts the mutation is visible. This is misleading about the semantic API contract; either change the behavior being asserted (e.g., verify immutability via defensive copy) or update the docstring/test name to match that provider_meta is intentionally mutable.

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +8
"""Golden/snapshot tests for rendered output.

These tests verify that polylogue's rendered output (markdown files, HTML, etc.)
matches expected "golden" reference files. This catches regressions in rendering
logic and documents expected output format.

Golden files are stored in tests/golden/<test-case>/expected/
"""

Copilot AI Apr 7, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests are described as golden/snapshot tests, but they don't read/compare any files under tests/golden/<case>/expected/ (and GOLDEN_DIR is unused). As written, this is just a set of substring assertions and won't catch small formatting regressions with a diffable snapshot. Consider loading the expected golden markdown and doing a normalized full-text comparison so failures show an actual snapshot diff.

Copilot uses AI. Check for mistakes.
import pytest

from polylogue.config import Source
from polylogue.ingestion import drive

Copilot AI Apr 7, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

drive is imported but never used. Ruff will flag this as an unused import (F401), which will fail linting in CI. Remove it or add assertions that use it.

Suggested change
from polylogue.ingestion import drive

Copilot uses AI. Check for mistakes.
Comment thread tests/test_server.py
Comment on lines 68 to 76
# Reload modules to ensure consistent DatabaseError class identity
# This is needed when other tests in the suite reload polylogue.storage.db
# This is needed when other tests in the suite reload polylogue.storage.backends.sqlite
# Order: db first (defines DatabaseError), then backends, then api
import importlib

import polylogue.server.api
import polylogue.storage.backends.sqlite
import polylogue.storage.db
importlib.reload(polylogue.storage.db)
importlib.reload(polylogue.storage.backends.sqlite)
importlib.reload(polylogue.server.api)

Copilot AI Apr 7, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reload-order comment is now inaccurate: DatabaseError is defined in polylogue.storage.backends.sqlite, but the comment still says "db first" even though polylogue.storage.db is no longer reloaded here. Please update/remove the comment to reflect the actual reload order being used so future test debugging isn't misled.

Copilot uses AI. Check for mistakes.
Comment thread tests/test_db_store.py

from __future__ import annotations

import pytest

Copilot AI Apr 7, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pytest is imported but unused in this module. With ruff's F (pyflakes) checks enabled, this will fail CI as an unused import (F401). Remove the import or use pytest features (e.g., pytest.raises, marks, fixtures) in this file.

Suggested change
import pytest

Copilot uses AI. Check for mistakes.
Comment thread tests/test_health.py
Comment on lines +11 to 13
import pytest


Copilot AI Apr 7, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pytest is imported but not used anywhere in this file. With ruff's pyflakes rules enabled, this will fail linting (F401). Remove the import or use pytest (e.g., pytest.raises, pytest.mark).

Suggested change
import pytest

Copilot uses AI. Check for mistakes.
Comment on lines 3 to +7
import json
import zipfile

import pytest

Copilot AI Apr 7, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pytest is imported but not used in this test module. Ruff will flag this as an unused import (F401) and fail CI. Please remove it or use pytest helpers in assertions.

Copilot uses AI. Check for mistakes.
@Sinity

Sinity commented Apr 8, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Apr 8, 2026

Copy link
Copy Markdown
✅ Actions performed

Full review triggered.

@Sinity Sinity closed this Apr 9, 2026
@Sinity Sinity added the faux-pull-request PR created as part of a history rewrite process label Apr 9, 2026
@Sinity
Sinity deleted the feature/testing/golden-tests-health-checks-hooks branch April 9, 2026 23:02
Sinity added a commit that referenced this pull request Apr 22, 2026
…ns (#58)

Wire developer-workflow tooling, expand the health-check surface, harden
SQLite connection setup, and backfill test coverage across rendering,
semantic API, and provider parsing.

Git hooks and developer config:
- .gitconfig with merge-commit workflow aliases (lg, review, incoming,
  cleanup) and histogram diff, zdiff3 conflict markers
- commit-msg hook: soft conventional-commit format validation with
  color-coded reminder — commits always proceed
- pre-push hook: detects WIP/messy commit subjects and prompts before
  push; also warns on non-conventional format
- .githooks/README.md documents installation and bypass

Health checks (polylogue/health.py):
- empty_conversations check: flags conversations with zero messages
- fts_sync check: compares messages table count against messages_fts,
  reports missing FTS index or row-count drift

Storage hardening:
- sqlite.py: mkdir parents before connect, add PRAGMA busy_timeout
  30000 to reduce lock-contention failures in concurrent workflows
- fts5.py: fix connection_context() call that passed spurious None
  first argument after the signature changed
- source.py: remove swallowed JSONDecodeError in _iter_json_stream
  fallback path — errors now propagate so cursor_state tracks failures

Golden test framework:
- tests/golden/README.md defines the case structure (input/expected/
  metadata.yaml) and update workflow
- tests/scripts/update_golden.py regenerates expected/ from current
  rendering code for chatgpt-simple and claude-thinking cases
- tests/test_golden_outputs.py: snapshot tests covering markdown
  rendering of ChatGPT, Claude thinking blocks, JSON tool use, empty
  messages, Unicode preservation, attachments, and timestamp ordering

Semantic API test suite (tests/test_semantic_api_comprehensive.py):
- 53 tests covering DialoguePair validation, Message metadata
  extraction (cost_usd, duration_ms), Conversation aggregation
  (total_cost, tags, display_title), iteration helpers (pairs,
  thinking, substantive, dialogue), and rendering (to_text,
  to_clean_text)

Provider real-data tests (tests/test_providers_real_data.py):
- pytest.skip-gated tests exercising ChatGPT and Claude ZIP parsers
  against production exports on /realm/data, plus provider detection
  and end-to-end import cycle verification

Test modernization across ~20 files:
- Consolidate imports: polylogue.storage.db → .backends.sqlite,
  polylogue.pipeline.models → .storage.store
- Remove tests for deprecated nested-connection depth tracking
- Replace caplog assertions with capsys for structlog compatibility
- Pre-initialize WAL mode and add explicit conn.commit() in
  concurrent tests to reduce SQLite lock contention
- Add pytest-xdist (parallel execution) to dev dependencies

Scaffolding:
- CLAUDE.md symlink → AGENTS.md
- scripts/generate_screenshots.py for README asset generation
- tests/manual/ verification scripts for database, attachments,
  and filesystem spot-checks
- .gitignore entries for test datasets
@Sinity

Sinity commented Apr 28, 2026

Copy link
Copy Markdown
Owner Author

🤖 Post-hoc audit note: this PR received bot review feedback verified against current HEAD as part of #544. 3 finding(s) confirmed still present → tracked in #550.

@Sinity

Sinity commented Sep 30, 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.

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

area:cli CLI area:qa QA area:storage Storage faux-pull-request PR created as part of a history rewrite process type:feat New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants