phase: 97_kb_tree_catalog
All completion criteria verified — everything is green, no defects found. Final report: ## Phase 97 final verification pass — ALL GREEN **Verified (no code changes needed):** - `GET /api/docs/tree` (admin), `build_kb_tree` pure builder, `PATCH /api/folders/summary`, migration 0018 (`manually_edited`, head confirmed), generator skip/keep + `kept_manual` stat, RAG tree UI + edit affordance in `sources.js`/`index.html`/`styles.css` - `tests/e2e/test_kb_tree.py`: 8 passed — top level, drill source/folder, edit round-trip, clear, manual-desc-survives-sync, reload fallback, anonymous gate - Integration: tree shape/order/403/empty/indexed-only + PATCH update/create/root/clear/404/403/no-LLM + stat-walk equivalence (in `test_docs_api.py`); 3-field `folder_summaries=` import token preserved **Gates (exact commands):** - `uv run pytest --cov=app --cov-report=term-missing` → **2053 passed**, TOTAL coverage **99%** (>90% ✓) - `uv run ruff check . && uv run pyright` → **All checks passed / 0 errors** - `uv run pytest tests/e2e/test_kb_tree.py -v --no-cov` → **8 passed** in isolation - 30 story/RAG-view E2E suites run **one per process**: all passed, incl. `test_ls_tree_drilldown` (agent `ls` byte-identical ✓), `test_import_documents`, `test_edit_summaries`, `test_admin_auth`, `test_kb_overview` **Completion criteria:** tree view ✓ · edit round-trip + clear ✓ · manual persists/clear resets ✓ · `ls` unchanged ✓ · pytest/coverage/lint ✓ · E2E isolation ✓ · commit — left to harness per protocol (working tree untouched, `git add/commit` not run) **Deviations:** none. **Next pending phase:** none — `todo/` contains only 97 (96 already committed).
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
"""folder_summaries.manually_edited: owner-edited descriptions (phase 97, task 01)
|
||||
|
||||
Revision ID: 0018
|
||||
Revises: 0017
|
||||
Create Date: 2026-09-11
|
||||
|
||||
Phase 97 (the RAG view shows the catalog as the drill-down tree the
|
||||
agent sees, with editable folder descriptions): the owner can edit —
|
||||
or clear — any directory's description, just like a file's summary
|
||||
(phase 57's affordance). The owner's words are OWNER CONTENT: the
|
||||
sync-time generator must never silently rewrite them. This migration
|
||||
adds the one flag that makes that enforceable — a single additive,
|
||||
fully reversible column (A13), no other schema change:
|
||||
|
||||
* ``folder_summaries.manually_edited`` — BOOLEAN NOT NULL, server
|
||||
default ``false``: ``true`` only while the row's description was
|
||||
written by the owner (``PATCH /api/folders/summary`` — phase 97,
|
||||
task 03 — the ONLY writer; the generator never sets it). The
|
||||
generator's two rules for a manual row (``app.rag.folder_summaries``):
|
||||
SKIPPED on regeneration (no ``lite`` burn on owner text — counted
|
||||
``kept_manual`` in the stats) and NEVER pruned (owner content
|
||||
persists until the owner clears it — even a manual row for a folder
|
||||
that dropped below 2 documents). Pre-0018 rows backfill ``false``:
|
||||
an AI-written row stays an AI row. Clearing the description DELETES
|
||||
the row — the next KB-changing sync regenerates an AI description
|
||||
(the reset path; no separate regenerate button in v1).
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import sqlalchemy as sa
|
||||
|
||||
from alembic import op
|
||||
|
||||
revision = "0018"
|
||||
down_revision = "0017"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
op.add_column(
|
||||
"folder_summaries",
|
||||
sa.Column(
|
||||
"manually_edited",
|
||||
sa.Boolean(),
|
||||
server_default=sa.text("false"),
|
||||
nullable=False,
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# The column is the only 0018 artefact — dropping it (the rows and
|
||||
# their summaries survive) leaves 0017's schema byte-identical
|
||||
# (A13, fully reversible).
|
||||
op.drop_column("folder_summaries", "manually_edited")
|
||||
Reference in New Issue
Block a user