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.

tests/test_derived_axis.py:55

Checks

  • assert "NOT DEFINITIVE" in payload["note"]
  • assert "definitive empty result" not in payload["note"]

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-006catalog
REQ-DDB-MCP-004measuredtest_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
lines 63–65payload = { "note": "No callers. This is a definitive empty result from the database. Do not retry.", }lines 66–66staleness = freshness.notices({"fast": _FAST}, code={})lines 67–67_withdraw_definitive(payload, staleness)lines 68–68assert "NOT DEFINITIVE" in payload["note"]lines 69–69assert "definitive empty result" not in payload["note"]

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.

tests/test_derived_axis.py:31

Show on the map →

Called by none

Calls notices

Checks

  • assert len(derived) == 1
  • assert "src/a.c" in message and "reachability" in message and "threads" in message

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-006catalog
REQ-DDB-MCP-004measuredtest_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
lines 36–36found = freshness.notices({"fast": _FAST}, code={})lines 37–37derived = [n for n in found if n["axis"] == freshness.AXIS_DERIVED]lines 38–38assert len(derived) == 1lines 39–39message = derived[0]["message"]lines 40–40assert "src/a.c" in message and "reachability" in message and "threads" in message

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`.

tests/test_derived_axis.py:72

Checks

  • assert status["fast"]["pending"] == "1"
  • assert status["stale"] is True
  • assert any(n["axis"] == "derived" for n in status.get("staleness", []))

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-006measuredtest_db_status_reports_the_fast_section_and_counts_it_as_stale → db_status
REQ-DDB-CONFIG-007measuredtest_db_status_reports_the_fast_section_and_counts_it_as_stale → db_status
REQ-DDB-INDEX-003measuredtest_db_status_reports_the_fast_section_and_counts_it_as_stale → db_status → _coverage_meta
REQ-DDB-INDEX-006catalog
REQ-DDB-MCP-001measuredtest_db_status_reports_the_fast_section_and_counts_it_as_stale → db_status
REQ-DDB-MCP-004measuredtest_db_status_reports_the_fast_section_and_counts_it_as_stale → db_status
REQ-DDB-PIPE-005measuredtest_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
lines 80–80from clew.mcp_server.state import Target, db_statuslines 81–81from clew.signature import write_build_signaturelines 83–83db = tmp_path / "clew.db"lines 84–84sqlite3.connect(db).close()lines 85–85write_build_signature(db)lines 86–86with sqlite3.connect(db) as connlines 87–90conn.executemany( "INSERT INTO build_meta (key, value) VALUES (?, ?)", [(f"fast.{k}", v) for k, v in _FAST.items()], )lines 91–91status = db_status(Target(repo_path=str(tmp_path), slug="t", db_path=str(db)))lines 92–92assert status["fast"]["pending"] == "1"lines 93–93assert status["stale"] is Truelines 94–94assert any(n["axis"] == "derived" for n in status.get("staleness", []))

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.

tests/test_derived_axis.py:43

Show on the map →

Called by none

Calls notices

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

requirementlinkedpath to the implementer
REQ-DDB-INDEX-006catalog
REQ-DDB-MCP-004measuredtest_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"]

Activity · 3 steps
lines 50–50assert not [n for n in freshness.notices({}, code={}) if n["axis"] == "derived"]lines 51–51cleared = {"fast": {**_FAST, "pending": "0"}}lines 52–52assert not [n for n in freshness.notices(cleared, code={}) if n["axis"] == "derived"]