test_incremental_pipeline.py

tests/integration/test_incremental_pipeline.py

An incrementally refreshed index must equal a full rebuild — THROUGH THE REAL PIPELINE.

test_an_incremental_refresh_equals_a_full_rebuild

None test_incremental_pipeline.test_an_incremental_refresh_equals_a_full_rebuild(Path tmp_path)

A pipeline-driven incremental refresh must equal a pipeline-driven full rebuild.

tests/integration/test_incremental_pipeline.py:181

Show on the map →

Called by none

Calls _edit, _seed, _snapshot, captured_output

Checks

  • assert row is not None and int(row[0]) > 0, (f"the second build did NOT take the incremental branch (splice_generation={row}), so " f"this test compares two full rebuilds and proves nothing about the splice" )
  • assert ("pipeline_probe", "sound_play_findme", "doxygen_sqlite") in want["edges"] or any(a == "pipeline_probe" and b == "sound_play_findme" for a, b, _ in want["edges"] ), "the rebuild has no pipeline_probe -> sound_play_findme edge; the second pass is untested"
  • assert not any("vendor" in f for f in want["indexed"]), ("the rebuild indexed the excluded vendor/ tree, so EXCLUDE_PATTERNS is not in force " "and the scope filter is untested here" )
  • assert any("Extra" in a or "Extra" in b for a, b in want["reimplements"]), ("the rebuild has no Extra override, so the inheritance tables are untested here" )
  • assert want["params"], ("the rebuild produced no memberdef_param rows, so comparing that table is vacuous" )
  • assert not missing and not extra, (f"{layer}: the incrementally refreshed index disagrees with a full rebuild.\n" f" missing from incremental ({len(missing)}): {sorted(missing)[:8]}\n" f" only in incremental ({len(extra)}): {sorted(extra)[:8]}" )

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CLI-001measured
REQ-DDB-CONFIG-001measured
REQ-DDB-CONFIG-003measured
REQ-DDB-CONFIG-004measured
REQ-DDB-CONFIG-005measured
REQ-DDB-CONFIG-006measured
REQ-DDB-CONFIG-007measured
REQ-DDB-CONFIG-009measured
REQ-DDB-GUARD-012measured
REQ-DDB-GUARD-024measured
REQ-DDB-INDEX-001measured
REQ-DDB-INDEX-002measured
REQ-DDB-INDEX-003measured
REQ-DDB-INDEX-004measured
REQ-DDB-INDEX-005measured
REQ-DDB-INDEX-006measured
REQ-DDB-INDEX-007measured
REQ-DDB-INDEX-008measured
REQ-DDB-INDEX-009measured
REQ-DDB-INDEX-010measured
REQ-DDB-INDEX-011measured
REQ-DDB-MCP-001measured
REQ-DDB-MCP-004measured
REQ-DDB-PIPE-001measured
REQ-DDB-PIPE-003measured
REQ-DDB-PIPE-004measured
REQ-DDB-PIPE-005measured
REQ-DDB-PIPE-006measured
REQ-DDB-PIPE-007measured
REQ-DDB-PIPE-008measured
REQ-DDB-PIPE-009measured
REQ-DDB-PIPE-010measured
REQ-DDB-PIPE-011measured
REQ-DDB-PIPE-012measured
REQ-DDB-PIPE-013measured
REQ-DDB-PIPE-014measured
REQ-DDB-PIPE-015measured
REQ-DDB-QUERY-003measured
REQ-DDB-QUERY-011measured
REQ-DDB-SCHEMA-001measured
REQ-DDB-SCHEMA-002measured
REQ-DDB-SCHEMA-003measured
REQ-DDB-SCHEMA-004measured
REQ-DDB-SCHEMA-005measured
REQ-DDB-SCHEMA-006measured
REQ-DDB-SCHEMA-007measured
REQ-DDB-SCHEMA-009measured
REQ-DDB-SCHEMA-011measured
REQ-DDB-SCHEMA-012measured
REQ-DDB-SCHEMA-013measured
REQ-DDB-SCHEMA-014measured
REQ-DDB-SCHEMA-015measured
Source · 71 lines
def test_an_incremental_refresh_equals_a_full_rebuild(tmp_path: Path) -> None:
    """THE WIRING IS THE SUBJECT. Every call goes through `build_index`, so removing any step
    from `_incremental_plan` or `_incremental_doxygen` changes this test's answer.

    The incremental build reuses ONE output path across two invocations, which is what makes
    the second one incremental: the sidecar beside that path holds the previous doxygen output
    and the scan state. The full rebuild goes to a FRESH path, so it has no sidecar and cannot
    take the splice branch at all.

    @brief Incremental and full builds of one tree agree.
    @return None.
    @version 1
    """
    root = tmp_path / "repo"
    _seed(root)
    incremental = tmp_path / "incremental.db"

    with captured_output():
        build_index(output=incremental, repo_root=root, doxyfile=root / "Doxyfile")
    _edit(root)
    with captured_output():
        build_index(output=incremental, repo_root=root, doxyfile=root / "Doxyfile")

    ## THE NON-VACUITY GATE FOR THIS WHOLE FILE. If the second build fell back to a full run
    ## — no previous output, a config_sha mismatch, an exception swallowed by the fallback —
    ## then every comparison below passes while testing NOTHING about the splice. The sidecar's
    ## generation counter is the structural witness: `record_splice(reset=...)` zeroes it after
    ## a full build and increments it after a splice, so a positive value can only mean the
    ## incremental branch ran.
    sidecar = sqlite3.connect(str(incremental) + ".idxcache")
    try:
        row = sidecar.execute(
            "SELECT value FROM cache_meta WHERE key = 'splice_generation'"
        ).fetchone()
    finally:
        sidecar.close()
    assert row is not None and int(row[0]) > 0, (
        f"the second build did NOT take the incremental branch (splice_generation={row}), so "
        f"this test compares two full rebuilds and proves nothing about the splice"
    )

    full = tmp_path / "full.db"
    with captured_output():
        build_index(output=full, repo_root=root, doxyfile=root / "Doxyfile")

    got, want = _snapshot(incremental), _snapshot(full)

    ## NON-VACUITY, per mechanism. Each of these is a thing the pipeline had to do correctly to
    ## get here; if the rebuild lacks it, the comparison below cannot see that mechanism at all.
    assert ("pipeline_probe", "sound_play_findme", "doxygen_sqlite") in want["edges"] or any(
        a == "pipeline_probe" and b == "sound_play_findme" for a, b, _ in want["edges"]
    ), "the rebuild has no pipeline_probe -> sound_play_findme edge; the second pass is untested"
    assert not any("vendor" in f for f in want["indexed"]), (
        "the rebuild indexed the excluded vendor/ tree, so EXCLUDE_PATTERNS is not in force "
        "and the scope filter is untested here"
    )
    assert any("Extra" in a or "Extra" in b for a, b in want["reimplements"]), (
        "the rebuild has no Extra override, so the inheritance tables are untested here"
    )
    assert want["params"], (
        "the rebuild produced no memberdef_param rows, so comparing that table is vacuous"
    )

    for layer in ("members", "edges", "indexed", "reimplements", "params"):
        missing = want[layer] - got[layer]
        extra = got[layer] - want[layer]
        assert not missing and not extra, (
            f"{layer}: the incrementally refreshed index disagrees with a full rebuild.\n"
            f"  missing from incremental ({len(missing)}): {sorted(missing)[:8]}\n"
            f"  only in incremental ({len(extra)}): {sorted(extra)[:8]}"
        )

1 more lines, not shown

Activity · 24 steps
lines 194–194root = tmp_path / "repo"lines 195–195_seed(root)lines 196–196incremental = tmp_path / "incremental.db"lines 198–198with captured_output()lines 199–199build_index(output=incremental, repo_root=root, doxyfile=root / "Doxyfile")lines 200–200_edit(root)lines 201–201with captured_output()lines 202–202build_index(output=incremental, repo_root=root, doxyfile=root / "Doxyfile")lines 210–210sidecar = sqlite3.connect(str(incremental) + ".idxcache")lines 211–211trylines 212–214row = sidecar.execute( "SELECT value FROM cache_meta WHERE key = 'splice_generation'" ).fetchone()lines 217–220assert row is not None and int(row[0]) > 0, ( f"the second build did NOT take the incremental branch (splice_generation={row}), so " f"this test compares two full rebuilds and proves nothing about the splice" )lines 222–222full = tmp_path / "full.db"lines 223–223with captured_output()lines 224–224build_index(output=full, repo_root=root, doxyfile=root / "Doxyfile")lines 226–226got, want = _snapshot(incremental), _snapshot(full)lines 230–232assert ("pipeline_probe", "sound_play_findme", "doxygen_sqlite") in want["edges"] or any( a == "pipeline_probe" and b == "sound_play_findme" for a, b, _ in want["edges"] ), "the rebuild has no pipeline_probe -> sound_play_findme edge; the second pass is untested"lines 233–236assert not any("vendor" in f for f in want["indexed"]), ( "the rebuild indexed the excluded vendor/ tree, so EXCLUDE_PATTERNS is not in force " "and the scope filter is untested here" )lines 237–239assert any("Extra" in a or "Extra" in b for a, b in want["reimplements"]), ( "the rebuild has no Extra override, so the inheritance tables are untested here" )lines 240–242assert want["params"], ( "the rebuild produced no memberdef_param rows, so comparing that table is vacuous" )lines 244–244◇ for layer in ("members", "edges", "indexed", "reimplements", "params")lines 245–245missing = want[layer] - got[layer]lines 246–246extra = got[layer] - want[layer]lines 247–251assert not missing and not extra, ( f"{layer}: the incrementally refreshed index disagrees with a full rebuild.\n" f" missing from incremental ({len(missing)}): {sorted(missing)[:8]}\n" f" only in incremental ({len(extra)}): {sorted(extra)[:8]}" )