test_derived_axis.py¶
tests/test_derived_axis.py
A fast in-place refresh leaves whole-index layers behind, and every reply must say so.
test_a_definitive_negative_is_withdrawn_while_layers_are_derived_stale
None test_derived_axis.test_a_definitive_negative_is_withdrawn_while_layers_are_derived_stale()
The derived axis replaces a definitive-negative note.
Checks
assert "NOT DEFINITIVE" in payload["note"]assert "definitive empty result" not in payload["note"]
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-INDEX-006 | catalog | |
| REQ-DDB-MCP-004 | measured | test_a_definitive_negative_is_withdrawn_while_layers_are_derived_stale → notices |
Source · 17 lines
def test_a_definitive_negative_is_withdrawn_while_layers_are_derived_stale() -> None:
""" "No callers" from a call graph that has not seen the edit is not a measurement of the
edited code. The derived axis withdraws the definitive wording like `schema` does.
@brief The derived axis replaces a definitive-negative note.
@return None.
@version 1
"""
payload = {
"note": "No callers. This is a definitive empty result from the database. Do not retry.",
}
staleness = freshness.notices({"fast": _FAST}, code={})
_withdraw_definitive(payload, staleness)
assert "NOT DEFINITIVE" in payload["note"]
assert "definitive empty result" not in payload["note"]
Activity · 5 steps
test_a_pending_fast_refresh_raises_the_derived_axis
None test_derived_axis.test_a_pending_fast_refresh_raises_the_derived_axis()
notices() names the derived axis, the files and the stale layers.
Checks
assert len(derived) == 1assert "src/a.c" in message and "reachability" in message and "threads" in message
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-INDEX-006 | catalog | |
| REQ-DDB-MCP-004 | measured | test_a_pending_fast_refresh_raises_the_derived_axis → notices |
Source · 12 lines
def test_a_pending_fast_refresh_raises_the_derived_axis() -> None:
"""@brief notices() names the derived axis, the files and the stale layers.
@return None.
@version 1
"""
found = freshness.notices({"fast": _FAST}, code={})
derived = [n for n in found if n["axis"] == freshness.AXIS_DERIVED]
assert len(derived) == 1
message = derived[0]["message"]
assert "src/a.c" in message and "reachability" in message and "threads" in message
Activity · 5 steps
test_db_status_reports_the_fast_section_and_counts_it_as_stale
None test_derived_axis.test_db_status_reports_the_fast_section_and_counts_it_as_stale(Path tmp_path)
db_status carries `fast` and sets `stale`.
Checks
assert status["fast"]["pending"] == "1"assert status["stale"] is Trueassert any(n["axis"] == "derived" for n in status.get("staleness", []))
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-006 | measured | test_db_status_reports_the_fast_section_and_counts_it_as_stale → db_status |
| REQ-DDB-CONFIG-007 | measured | test_db_status_reports_the_fast_section_and_counts_it_as_stale → db_status |
| REQ-DDB-INDEX-003 | measured | test_db_status_reports_the_fast_section_and_counts_it_as_stale → db_status → _coverage_meta |
| REQ-DDB-INDEX-006 | catalog | |
| REQ-DDB-MCP-001 | measured | test_db_status_reports_the_fast_section_and_counts_it_as_stale → db_status |
| REQ-DDB-MCP-004 | measured | test_db_status_reports_the_fast_section_and_counts_it_as_stale → db_status |
| REQ-DDB-PIPE-005 | measured | test_db_status_reports_the_fast_section_and_counts_it_as_stale → write_build_signature |
Source · 23 lines
def test_db_status_reports_the_fast_section_and_counts_it_as_stale(tmp_path: Path) -> None:
"""`stale` MUST INCLUDE IT: the server's follow-up full build is skipped when an index reads
as fresh, and an in-place write makes it read fresh on every other axis.
@brief db_status carries `fast` and sets `stale`.
@return None.
@version 1
"""
from clew.mcp_server.state import Target, db_status
from clew.signature import write_build_signature
db = tmp_path / "clew.db"
sqlite3.connect(db).close()
write_build_signature(db)
with sqlite3.connect(db) as conn:
conn.executemany(
"INSERT INTO build_meta (key, value) VALUES (?, ?)",
[(f"fast.{k}", v) for k, v in _FAST.items()],
)
status = db_status(Target(repo_path=str(tmp_path), slug="t", db_path=str(db)))
assert status["fast"]["pending"] == "1"
assert status["stale"] is True
assert any(n["axis"] == "derived" for n in status.get("staleness", []))1 more lines, not shown
Activity · 11 steps
test_no_fast_record_means_no_derived_axis
None test_derived_axis.test_no_fast_record_means_no_derived_axis()
No fast section, or a cleared one, adds no notice.
Checks
assert not [n for n in freshness.notices({}, code={}) if n["axis"] == "derived"]assert not [n for n in freshness.notices(cleared, code={}) if n["axis"] == "derived"]
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-INDEX-006 | catalog | |
| REQ-DDB-MCP-004 | measured | test_no_fast_record_means_no_derived_axis → notices |
Source · 12 lines
def test_no_fast_record_means_no_derived_axis() -> None:
"""A WARNING THAT ALWAYS FIRES IS ONE NOBODY READS: a current index gets nothing.
@brief No fast section, or a cleared one, adds no notice.
@return None.
@version 1
"""
assert not [n for n in freshness.notices({}, code={}) if n["axis"] == "derived"]
cleared = {"fast": {**_FAST, "pending": "0"}}
assert not [n for n in freshness.notices(cleared, code={}) if n["axis"] == "derived"]