test_a_stray_developer_clone_the_parent_tracks_is_first_party

Tests › tests/test_external_provenance.py

passed Passed in the packaged run.

What this test is for

Why it exists

THE NEGATIVE HALF OF gh#352, and the case that forced the predicate split. Both directories here hold a real `.git`; only one is a gitlink in the parent's index. The other is a repository somebody CLONED into a directory whose files this repo tracks and owns.

Verifies REQ-DDB-PIPE-014

Given

  1. db_path, root = _indexed( tmp_path, [*_ours(), *_theirs(), ("evidence/checkout/probe.c", 4)], nested=("vendor/theirs",), )
  2. make_gitlink_free_clone = root / "evidence" / "checkout"
2 more
  1. git_run(make_gitlink_free_clone, "init", "-q", ".")
  2. git_run(root, "add", "-f", "evidence/checkout/probe.c")
→

When

  1. external_roots(root)
  2. stamp_external_provenance(db_path, root)
  3. conn = sqlite3.connect(str(db_path))
  4. try: rows = dict(conn.execute(f"SELECT name, {EXTERNAL_ROOT_COLUMN} FROM path").fetchall()) finally: conn.close()
→

Then

  1. ✓ (make_gitlink_free_clone / ".git").is_dir() holds
  2. ✓ external_roots(root) equals ["vendor/theirs"]
  3. ✓ rows["evidence/checkout/probe.c"] is None
  4. ✓ rows["vendor/theirs/lib_0.c"] equals "vendor/theirs"

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) · 6 of 142 steps

… 2 earlier steps

thread startthread startthread startthread startclew/scope.pyclew/scope.pyclew/scope.pyclew/scope.pyother filesother filesother filesother filestry (line 1003)tryopt (line 845)optloop (line 1239)loopopt (line 847)optloop (line 746)loop_first_build_worker3. whole_repo_scope → _gitignored_paths3_gitignored_paths4. _gitignored_paths → git_argv4git_argv5. git_argv → _no_ext_diff5_no_ext_diff▶ test enters6. git_argv → list6list7. list → link7link8. _gitignored_paths → git_env8git_env9. whole_repo_scope → list9list10. whole_repo_scope → nested_repo_roots10nested_repo_roots11. nested_repo_roots → _nested_repos_under11_nested_repos_under▶ test enters12–14. _nested_repos_under → _warn_unwalkable12_warn_unwalkable +2 more15. nested_repo_roots → _nested_repos_under15_nested_repos_under16. whole_repo_scope → _gitignored_paths16_gitignored_paths

… 126 later steps

4 more

tests/test_external_provenance.py:170 · its file's page

What it checks (4)

  1. assert (make_gitlink_free_clone / ".git").is_dir(), "the fixture must hold a REAL git tree" not attributed
  2. assert external_roots(root) == ["vendor/theirs"], ( "a stray clone in a tracked directory is NOT a declared dependency — reporting it " "makes the tag depend on who built the index rather than on what the repo committed" ) observes external_roots
  3. assert rows["evidence/checkout/probe.c"] is None, "the repo's own tracked file stays ours" not attributed
  4. assert rows["vendor/theirs/lib_0.c"] == "vendor/theirs" not attributed

Where the product reaches it

No product flow reaches this code: no product entry point's flow calls any of the functions this test calls.

Call flow

test_a_stray_developer_clone_the_parent_tracks_is_first_party→_indexed→_ours→_theirs→git_run→external_roots→stamp_external_provenance

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.

test_a_stray_developer_clone_the_parent_tracks_is_first_party · 4 checksexternal_rootsdependency_rootsREQ-DDB-CONFIG-001 · measuredstamp_external_provenanceREQ-DDB-INDEX-005 · measured

Requirements it verifies (1)

requirementlinked byimplementers exercised
REQ-DDB-PIPE-014catalogunknown
Also reaches 2 requirements

Its run touches their code; that is reach, not proof.