All gates verified. Final report: **Phase 163 — final verification pass (all 5 tasks already complete; verification-only run)** - Verified D1–D4 in code: `page_strip_mode` column + migration 0027, `DocContent` absent-never-null rule keyed off `page_count`; `_persist_pdf_pages` render → atomic tmp+`os.replace` writes → stale-tail-last + `strip_class` stamp; `_regate_pdf_strip` on both unchanged paths (mirror gate, heal, repair, fail-soft, one INFO line only when acting); viewer mode branch + Text/Pages toggle (Text default, `aria-pressed`, no innerHTML, lazy imgs). - `uv run pytest --cov=app --cov-report=term-missing` → **3796 tests, exit 0, coverage 99%** (>90%) - `uv run pytest tests/e2e/test_pdf_strip_additive_selfheal.py -v --no-cov` → **5 passed** in isolation - `test_pdf_pages_in_sources + test_pictorial_pdf + test_garbage_pdf` → 10 passed; `test_document_viewer(_context) + test_image_documents` → 20 passed - `uv run ruff check .` clean; `uv run pyright` → 0 errors; alembic **0027 downgrade→upgrade CLI round-trip clean** (+ integration pins) - Completion criteria: additive view w/ toggle ✅ · primary DOM byte-identity ✅ · write-first order/mid-write-failure/atomic pins ✅ · heal + repair E2E ✅ · zero vision/LLM on fast path (mock-captured) ✅ · non-qualifying payload byte-identity ✅ · docs pass ✅ - **Documentation**: README.md + AGENTS.md reviewed in full — the phase's updates are accurate; all config-table defaults cross-checked against `app/config.py` (no drift), every page route, script, and E2E command referenced exists, every `.env.example` var documented — **verified consistent, no changes needed**. - Notable: live `Letumdei` repair is owner-runtime post-deploy per D5 (next production Sync self-heals; no live changes made); the modified `.agents/screenshots/doc_modal_scrollbar_1280.png` is an E2E-regenerated artifact left for the pipeline commit. - **Next pending phase:** `164_chat_error_honesty`
69 lines
2.8 KiB
Python
69 lines
2.8 KiB
Python
"""documents.page_strip_mode: the strip CLASS behind page_count (phase 163, task 01)
|
|
|
|
Revision ID: 0027
|
|
Revises: 0026
|
|
Create Date: 2026-10-08
|
|
|
|
Phase 163 (the PDF page strip is ADDITIVE for a text-bearing book —
|
|
task 01, storage only):
|
|
|
|
* ``documents.page_strip_mode`` — VARCHAR(16) NULLABLE, NO server
|
|
default, NO index: the CLASS of the page strip a non-NULL
|
|
``page_count`` describes, so the viewer knows whether the strip
|
|
REPLACES the text or sits one toggle behind it.
|
|
|
|
``"primary"`` — the phase-133 FALLBACK class (an unusable text layer:
|
|
the screenshots ARE the content), i.e. exactly the pre-phase view: the
|
|
strip is the document's view and no text is shown. ``"additive"`` —
|
|
the phase-140 PICTORIAL class (a usable text layer with ≥1 sparse page
|
|
described): the document keeps its text view and its Summary panel,
|
|
and the strip is one Text/Pages toggle away.
|
|
|
|
NULL means NO strip (every non-qualifying document — text documents,
|
|
images, text-heavy PDFs — and every qualifying PDF whose render/write
|
|
failed). A row written before this phase keeps NULL while its
|
|
``page_count`` stands; the wire omits the key in that case and the
|
|
viewer treats an absent mode as ``"primary"`` (today's DOM), so
|
|
existing rows render exactly as before until the fast-path re-gate
|
|
(task 03) stamps them. Stamped and cleared EXACTLY with
|
|
``page_count`` — the importer's persist (task 02) and the unchanged-
|
|
path re-gate (task 03) are the only writers.
|
|
|
|
A display fact, never a query surface, like the 0026 column it
|
|
accompanies: the content endpoint reads it from the ROW after the
|
|
``(source, path)`` lookup, so it carries no index of its own (the
|
|
``file_hash`` convention, 0025).
|
|
|
|
One additive, fully reversible migration (A13); no other schema change.
|
|
The ordering of the copies on disk (task 02) and the re-gate itself
|
|
(task 03) are importer code — this revision only carries the column.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
import sqlalchemy as sa
|
|
|
|
from alembic import op
|
|
|
|
revision = "0027"
|
|
down_revision = "0026"
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
# No index (a display fact, never a query surface — the content
|
|
# endpoint reads it from the row) and no server default (NULL is the
|
|
# meaningful state for every non-qualifying document, every fail-soft
|
|
# miss, and every pre-phase row).
|
|
op.add_column(
|
|
"documents", sa.Column("page_strip_mode", sa.String(length=16), nullable=True)
|
|
)
|
|
|
|
|
|
def downgrade() -> None:
|
|
# The page_strip_mode column is the only 0027 artefact — dropping it
|
|
# leaves 0026's schema byte-identical (A13, fully reversible). The
|
|
# class is re-derivable from the source file on the next sync (the
|
|
# deterministic re-gate of task 03), so no data is lost by the drop.
|
|
op.drop_column("documents", "page_strip_mode")
|