Skip to content

test: add reader visual DOM evidence - #1047

Merged
Sinity merged 1 commit into
masterfrom
feature/test/reader-visual-dom-evidence
May 15, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/test/reader-visual-dom-evidence

Conversation

@Sinity

@Sinity Sinity commented May 15, 2026 •

Copy link
Copy Markdown
Owner

Summary

Adds the first executable #865 visual-evidence lane for the daemon-served local reader. The new tests/visual package boots the real daemon HTTP server against synthetic archives, checks browserless DOM structure and API state, writes evidence envelopes, and covers search/list, conversation/deeplink, query/no-results/facets, empty archive, degraded FTS, and privacy boundaries.

Problem

The reader had endpoint contract tests, but #865 still lacked a dedicated visual/DOM evidence lane. That left /c/{id} shell deep links, evidence-envelope shape, degraded FTS presentation, and private-path safety outside a visual-smoke-oriented test surface. Adding a full browser screenshot gate would require new browser packaging; the fast lane should work first without browser binaries so it can run reliably in the current devshell and standard pytest discovery.

Solution

  • Add tests/visual/ with synthetic archive seeding, daemon server fixtures, minimal DOM parsing, private-path checks, and evidence-manifest helpers.
  • Add DOM/evidence tests for:
    • polylogue.local_reader.search at /;
    • polylogue.local_reader.conversation at /c/reader-c1 plus detail/messages/raw APIs;
    • query search, no-results diagnostics, and scoped facets;
    • empty archive and degraded FTS sanitized error state.
  • Serve the web shell for /c/{id} so conversation deep links are directly verifiable.
  • Normalize daemon reader message_type serialization to stable enum values instead of MessageType.X reprs.
  • Update docs/visual-evidence.md and the MK3 execution log with the new command, coverage, and remaining browser screenshot follow-up.

Ref #865
Ref #848
Ref #859

Verification

  • pytest -q tests/visual → 4 passed
  • pytest -q tests/unit/daemon/test_web_reader.py → 37 passed
  • ruff format --check polylogue/daemon/http.py tests/visual → pass
  • ruff check polylogue/daemon/http.py tests/visual → pass
  • mypy tests/visual polylogue/daemon/http.py → pass
  • devtools verify --quick → exit 0
  • devtools verify --affected --skip-slow → exit 0
  • pre-push devtools verify --quick → exit 0

Follow-up

This PR deliberately does not add Playwright/Chromium screenshots. The new browserless lane records browser_gate_followup in evidence envelopes so a later #865 slice can add the heavier screenshot gate without replacing the fast DOM/contract smoke.

Summary by CodeRabbit

  • New Features

    • Added conversation deeplink support—users can now directly access specific conversations via /c/{conversation-id} paths.
    • Improved message type serialization for enhanced data consistency across the reader.
  • Documentation

    • Updated visual testing and execution planning documentation.

Review Change Stack

Problem: #865 needs executable reader visual evidence that drives the daemon-served shell against synthetic data. Endpoint tests covered contracts, but there was no dedicated evidence lane for DOM structure, deep links, degraded state, or evidence envelopes.

What changed: add tests/visual with synthetic daemon reader fixtures, browserless DOM/evidence assertions, private-path checks, search/detail/no-results/empty/degraded coverage, /c/{id} shell serving, stable message_type serialization, and updated visual-evidence documentation.

Verification: pytest -q tests/visual; pytest -q tests/unit/daemon/test_web_reader.py; ruff format --check polylogue/daemon/http.py tests/visual; ruff check polylogue/daemon/http.py tests/visual; mypy tests/visual polylogue/daemon/http.py; devtools verify --quick; devtools verify --affected --skip-slow.
@coderabbitai

coderabbitai Bot commented May 15, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: e0348db3-fcf6-40ff-b4fb-934dfd89e420

📥 Commits

Reviewing files that changed from the base of the PR and between 49cad6e and 2ec5d3c.

📒 Files selected for processing (6)
  • docs/plans/mk3-execution-log.md
  • docs/visual-evidence.md
  • polylogue/daemon/http.py
  • tests/visual/__init__.py
  • tests/visual/conftest.py
  • tests/visual/test_reader_dom_smoke.py

📝 Walkthrough

Walkthrough

This PR launches Wave 2 of the reader visual DOM evidence test lane. It adds HTTP daemon support for conversation deeplinks (/c/{id}), stabilizes message_type serialization, establishes comprehensive test infrastructure for DOM and API contract validation, and delivers four integrated smoke tests covering shell rendering, deeplinks, search queries, and error states.

Changes

Wave 2 reader visual DOM evidence launch

Layer / File(s) Summary
Planning and documentation
docs/plans/mk3-execution-log.md, docs/visual-evidence.md
Execution log entry documenting Wave 2 scope (visual DOM evidence lane, /c/{id} deeplinks, message_type serialization). Updated visual-evidence.md describes a two-lane fast-path approach (unit/daemon HTTP contract plus DOM/evidence assertions), expands route coverage to include raw endpoints and auth boundaries, and defers pixel-diff screenshot testing to issue #865.
HTTP daemon: deeplink routing and message serialization
polylogue/daemon/http.py
Adds _message_type_value helper normalizing message_type field for both raw values and enum-like objects. Expands unauthenticated web-shell GET dispatcher to serve /c/{id} conversation deeplinks alongside root path. Updates get_conversation and get_messages endpoints to use the new serialization helper.
Visual test infrastructure: workspace, DOM parsing, and server fixtures
tests/visual/__init__.py, tests/visual/conftest.py
Establishes ReaderWorkspace temp directory structure with environment setup. Adds lightweight DOMSummary HTML parser for counting scripts/styles and collecting element metadata. Provides evidence manifest JSON writing with on-disk validation. Creates SQLite archive database helpers with synthetic conversation/message seeding. Implements running_reader_server context manager starting DaemonAPIHTTPServer on ephemeral localhost port in daemon thread with disabled auth. Includes HTTP client helpers (get_json with assertions, get_text with error response handling).
Visual DOM and API contract smoke tests
tests/visual/test_reader_dom_smoke.py
Four integrated smoke test functions exercising reader routes: root shell DOM test validates HTML structure and required element IDs; deeplink and detail test verifies /c/{id} conversation access and serialization of conversation/messages/raw JSON; search query test asserts hit counts, identity-key relationships, and "no results" diagnostics; empty and degraded test verifies graceful handling when conversations are disabled and when message FTS is unavailable (503 with sanitized error). All tests collect evidence manifests with checksums and metadata.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A deeplink dawns where chats convene,
The reader shell, a DOM machine!
With manifests that mark the way,
Synthetic tales have much to say.
Fast lanes test without a screen—
The finest evidence you've seen! 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 8.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'test: add reader visual DOM evidence' accurately and concisely describes the main change: adding new visual DOM evidence tests for the reader.
Description check ✅ Passed The pull request description follows the template with all major sections completed: Summary, Problem, Solution, Verification, and Follow-ups. Each section provides clear, specific information about the changes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/test/reader-visual-dom-evidence

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.

@Sinity
Sinity merged commit 7b850cf into master May 15, 2026
4 checks passed
@Sinity
Sinity deleted the feature/test/reader-visual-dom-evidence branch May 15, 2026 13:19
Sinity added a commit that referenced this pull request May 15, 2026
Summary

Route the reader visual/DOM smoke lane through the verification-lab operator surface so agents and operators can invoke it as a named scenario instead of remembering the raw pytest path.

Problem

#1047 added fast reader DOM evidence, but the durable operator command was still `pytest -q tests/visual`. That left the lane outside `devtools lab-scenario list`, outside JSON report output, and easy to miss when following the MK3 execution plan.

Solution

- Add `reader-visual-smoke` to `devtools lab-scenario` discovery.
- Dispatch `devtools lab-scenario run reader-visual-smoke` to `pytest -q tests/visual`.
- Emit JSON and optional report-file output for the lane.
- Cover scenario discovery and dispatch in devtools unit tests.
- Document the operator-facing command in the visual evidence docs and execution log.

Ref #865

Verification

- `ruff format --check devtools/lab_scenario.py tests/unit/devtools/test_lab_list_subcommands.py tests/unit/devtools/test_lab_surface.py` -> 3 files already formatted
- `ruff check devtools/lab_scenario.py tests/unit/devtools/test_lab_list_subcommands.py tests/unit/devtools/test_lab_surface.py` -> All checks passed
- `mypy devtools/lab_scenario.py tests/unit/devtools/test_lab_list_subcommands.py tests/unit/devtools/test_lab_surface.py` -> Success
- `pytest -q tests/unit/devtools/test_lab_list_subcommands.py tests/unit/devtools/test_lab_surface.py -k lab_scenario` -> 6 passed
- `devtools lab-scenario run reader-visual-smoke --json` -> 4 passed
- `devtools verify --quick` -> exit_code 0
- `devtools verify --affected --skip-slow` -> exit_code 0
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.

1 participant