M47 (TASK-83-FREE): Zero-Signup Local Web Viewer (verity view Core SPA & Server)¶
Purpose & Architectural Decisions¶
- Loopback-Hardened Pure-Stdlib Server: Expose
verity viewbindingThreadingHTTPServerstrictly to loopback (127.0.0.1,::1,localhost), rejecting non-loopback--hostat CLI startup, enforcing DNS-rebindingHost/Originvalidation (403 Forbidden), strictContent-Security-Policy(script-src 'self'; object-src 'none'; frame-ancestors 'none'), andX-Verity-View-Tokengating on--allow-live-scan(POST /api/v1/scan) andPOST /api/v1/explain(returns Pro-gated501/403JSON withoutverity-pro). - Artifact Indexer & Live SSE Watch: Index Free artifacts (
verity.scan.v1,verity.test.v1,verity.stream.jsonl) with?offset=&limit=pagination and streamtext/event-streamartifact_added/artifact_updatedevents onGET /api/v1/eventswhen--watchis enabled. - Zero-Build Vanilla ES Module SPA + Plugin Registry: Package static SPA assets (
index.html,style.css,app.js,views/*.js) viaimportlib.resourceswith zero external CDN<script>/<link>tags, plusViewerRegistryextension hooks for optional Pro tab renderers.
Target Files¶
| File | Change |
|---|---|
src/verity/viewer/__init__.py |
ViewerRegistry plugin hook for optional Pro tabs/parsers |
src/verity/viewer/indexer.py |
JSON/JSONL artifact classifier (verity.scan.v1, verity.test.v1, verity.stream.jsonl) |
src/verity/viewer/server.py |
Loopback HTTP + --watch SSE server with CSP & DNS-rebinding guards |
src/verity/viewer/static/ |
Zero-build vanilla ES module SPA (index.html, style.css, app.js, views/*.js) |
src/verity/cli.py |
verity view subcommand (--host, --port, --watch, --allow-live-scan) |
pyproject.toml |
Package data inclusion for verity.viewer static assets |
tests/unit/viewer/test_viewer_server.py |
Loopback, CSP, token-gating, SSE, and asset packaging tests |
ATDD Traceability Matrix¶
| AC ID | Acceptance Criterion | Paired Benign / Negative Control | Verification Tier | Test Target |
|---|---|---|---|---|
AC-47.1 |
verity view binds loopback only and rejects non-loopback --host at startup. |
Default 127.0.0.1 with ephemeral fallback starts cleanly. |
unit |
tests/unit/viewer/test_viewer_server.py::test_loopback_binding |
AC-47.2 |
Server enforces Host/Origin DNS-rebinding checks (403), CSP headers, and X-Verity-View-Token on mutations. |
Valid loopback Host + token succeeds. |
unit |
tests/unit/viewer/test_viewer_server.py::test_security_headers_and_tokens |
AC-47.3 |
Artifact indexer classifies Free JSON/JSONL artifacts, streams --watch SSE events, and gates /api/v1/explain in Free. |
Empty directory returns empty paginated index cleanly. | unit |
tests/unit/viewer/test_viewer_server.py::test_indexer_sse_and_pro_gate |
AC-47.4 |
importlib.resources resolves SPA static files with zero external CDN references; ruff clean. |
All static files load without network egress. | ruff |
uv run ruff check src tests |