phase: 187_sync_peak_memory_line
**Phase 187 — final verification pass: all criteria met, repo 100% green.**
Verified (all four tasks already in `complete/`)
- `app/core/memory.py`: `rss_mb` / `rss_peak_mb` / `cgroup_peak_mb` / `fmt_mb`, pure stdlib, never-raise, **100%** coverage, 24 branch tests.
- Lifecycle lines append-only: `sync: started … rss_mb=`, all three terminals `… rss_mb= rss_peak_mb=` (failed = sanitized one-liner beside the surviving `logger.exception`), `import: summary … rss_mb=`; prefixes byte-identical.
- `GET /api/sync/status`: additive `rss_mb`/`rss_peak_mb` (`int|null`), keyed off the ONE `_sample_rss` (run start, phase transitions, forced terminals, 5 s-throttled hook), `peak >= current` invariant, anonymous 403.
- `sources.js` `fmtSyncPeakClause`: ` · peak <N> MB` trailing the counts line / "Sync cancelled", nothing when null, no new control/live region.
Gates (exact commands)
- `uv run pytest --cov=app --cov-report=term-missing` → **4570 passed**, TOTAL **99%**, `app/api/sync.py` **100%**, `app/core/memory.py` **100%**
- `uv run ruff check .` → clean · `uv run pyright` → **0 errors**
- `uv run pytest tests/e2e/test_sync_peak_memory_visible.py -v --no-cov` → **5 passed in isolation** (ran twice)
- All 27 touched E2E families re-run **in isolation**, all green (progress_box 8, cancel 3, status_freshness 4, summary_visibility 3, sync_button 3, session_reset 4, git_freeze 2, git_log_stream_dates 5, PDF/image suites, …)
Completion criteria: every checkbox ✅ except the commit + phase-dir move, which belong to the harness.
Documentation
- README reviewed in full (pages, commands, config tables cross-checked against `app/config.py` — 85 env rows, all defaults match; phase-187 ops section, greps, process-vs-cgroup caveat): consistent, no changes needed.
- `AGENTS.md`: **fixed one pre-existing inconsistency** — rule 6 claimed the no-CDN test covers "the index page"; it actually parametrizes 10 pages (all but `/doc-edit.html`).
Notable
- Two failures early in the pass were self-inflicted by running the E2E module concurrently with the full suite on the shared Postgres (TRUNCATE deadlock + one order-dependent `test_overview` flake); both vanish under the documented serial isolation — no code defect, no change made.
- **PLAN §9 still needs the owner's reconciliation** (phase 187 adds the sync memory fields + two status keys; PLAN is never agent-edited — AGENTS rule 10 carries the spec). `TODO.md` holds an unrelated owner note, left untouched.
Next pending phase: `188_chunks_hnsw_index`.
This commit is contained in:
@@ -18,6 +18,7 @@ import base64
|
||||
import hashlib
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import textwrap
|
||||
from collections.abc import Callable, Sequence
|
||||
from datetime import UTC, datetime
|
||||
@@ -54,6 +55,11 @@ from tests.fakes import FakeEmbedder
|
||||
#: (``Settings().import_extension_set`` — now seventeen formats).
|
||||
DEFAULT_EXTS = frozenset({".md", ".markdown", ".txt", ".yaml", ".yml", ".json", ".py"})
|
||||
|
||||
#: Phase 187 (task 02): the ONE rendering :func:`app.core.memory.fmt_mb`
|
||||
#: allows for an MB field — ``?`` when the platform cannot know, else a
|
||||
#: positive integer (never ``None``, never a float or a negative).
|
||||
MB = r"(?:\?|[1-9][0-9]*)"
|
||||
|
||||
|
||||
class _PoisonEmbedder(FakeEmbedder):
|
||||
"""Fails (like a real endpoint) on any text containing 'poison'."""
|
||||
@@ -1001,7 +1007,10 @@ def test_import_summary_log_line_includes_summary_counters(
|
||||
and the phase-151 ``pdf_images_deduped`` / ``pdf_images_blank_skipped``
|
||||
counters (the parser's per-PDF drop counts, next to
|
||||
``pdf_pictorial_pages``) sit after ``dates_updated``, before
|
||||
``formats``."""
|
||||
``formats``. Phase 187 (task 02) APPENDS a trailing ``rss_mb=``
|
||||
(LOCKED A2 — the memory the run sits at, ``?`` when unknowable); the
|
||||
pre-phase text up to and including ``formats=…`` is byte-identical.
|
||||
"""
|
||||
s = ImportSummary()
|
||||
s.files, s.added, s.chunks, s.embed_batches = 3, 3, 5, 4
|
||||
s.summaries, s.summary_errors = 2, 1
|
||||
@@ -1019,7 +1028,7 @@ def test_import_summary_log_line_includes_summary_counters(
|
||||
with caplog.at_level(logging.INFO, logger="app.importer"):
|
||||
s.log()
|
||||
line = caplog.records[-1].getMessage()
|
||||
assert line == (
|
||||
assert line.startswith(
|
||||
"import: summary files=3 added=3 updated=0 unchanged=0 pruned=0 errors=0 "
|
||||
"chunks=5 embed_batches=4 summaries=2 summary_errors=1 summary_backfilled=1 "
|
||||
"dates_updated=0 images_failed=0 svg_indexed=4 image_context_backfilled=2 "
|
||||
@@ -1027,6 +1036,9 @@ def test_import_summary_log_line_includes_summary_counters(
|
||||
"pdf_images_deduped=3 pdf_images_blank_skipped=1 "
|
||||
"formats=yaml:2,md:1"
|
||||
)
|
||||
# Phase 187 (task 02): the ONE appended field, `?` (unknowable) or a
|
||||
# positive integer MB — never `None`, never a negative or a float.
|
||||
assert re.fullmatch(rf".* rss_mb={MB}", line), line
|
||||
|
||||
|
||||
def test_prune_removes_files_now_excluded_by_format_filter(db, tmp_path: Path) -> None:
|
||||
@@ -1082,7 +1094,10 @@ def test_formats_counter_counts_extensionless_name_token(
|
||||
for r in caplog.records
|
||||
if "import: summary files=" in r.getMessage()
|
||||
)
|
||||
assert line.endswith("formats=dockerfile:1,md:1")
|
||||
# Phase 187 (task 02): ``formats=`` is no longer the LAST field
|
||||
# (`` rss_mb=…`` follows), but its position and value are intact.
|
||||
assert " formats=dockerfile:1,md:1" in line
|
||||
assert re.search(rf"formats=dockerfile:1,md:1 rss_mb={MB}$", line), line
|
||||
assert "unknown" not in line
|
||||
finally:
|
||||
_cleanup_source(db, root.name)
|
||||
|
||||
Reference in New Issue
Block a user