test_a_non_positive_cull_age_leaves_every_current_index_alone¶
Tests › tests/test_registry_hygiene.py
What this test is for
Why it exists
M4, 1.1.0 SECURITY AUDIT. `age > max_age_days` with `max_age_days=0` is true for every database that exists, so one call — from an agent reading "age threshold in days" and passing 0 to mean "no age limit", which is what 0 means in most such knobs — deleted every index on the machine, including repositories this session had never heard of. The blast radius is the whole state root because ONE server answers about every target.
Given
home = tmp_path / "state"kept = []
When
for name in ("alpha", "beta"): repo = tmp_path / name repo.mkdir() target = target_for(repo, home) Path(target.db_path).parent.mkdir(parents=True, exist_ok=True) Path(target.db_path).write_text("", encoding="utf-8") write_build_signature(Path(target.db_path)) TargetRegistry(home).register(repo) ## AGED BY AN HOUR, because `db_status` rounds `age_days` and a database written this ## instant rounds to 0.0 — which is not `> 0` and would make this test pass against the ## defect. An hour-old index is the ordinary case the sweep must not touch. os.utime(target.db_path, (time.time() - 3600, time.time() - 3600)) kept.append(Path(target.db_path))culled = cull(TargetRegistry(home), max_age_days=0, include_stale=False)for db in kept: assert db.exists(), f"{db} was deleted by a zero age threshold"
Then
- ✓ culled equals []
What it exercises
The parts of the system's flows this test ran, measured by per-test coverage: lit steps ran in this test, dimmed ones did not, and ▶ marks where the test called in. Each title opens the whole flow with these steps lit.
thread `clew-first-build-` — `_first_build_worker` (clew/mcp_server/server.py) · 31 of 142 steps
… 32 earlier steps
… 26 steps between
… 42 later steps
5 more
- Build, refresh and check the index · 31 of 153 steps
- `main` (scripts/stage_probe.py) · 30 of 37 steps
- clew — `main` (clew/cli.py) · 1 of 400 steps
- clew-mcp — `main` (clew/mcp_server/server.py) · 1 of 17 steps
- `main` (scripts/incremental_probe.py) · 1 of 3 steps
tests/test_registry_hygiene.py:273 · its file's page
What it checks (2)
assert culled == [], f"a zero age threshold culled current indexes: {culled}"not attributedassert db.exists(), f"{db} was deleted by a zero age threshold"not attributed
Where the product reaches it
main→query_main→_locate→target_for(flow)
Call flow
What it reaches
Each row runs from this test, through the calls it makes, to the code a requirement names. If that code breaks, the test's checks are what should catch it. Reaching is not proving: a check only proves what it observes. No mutation records were given, so these rows say what the test REACHES.
Also reaches 6 requirements
Its run touches their code; that is reach, not proof.
- REQ-DDB-CONFIG-006 measured
- REQ-DDB-CONFIG-007 measured
- REQ-DDB-INDEX-003 measured
- REQ-DDB-MCP-001 measured
- REQ-DDB-MCP-004 measured
- REQ-DDB-PIPE-005 measured