test_scope.py¶
tests/test_scope.py
Tests for declaration-driven index scope derivation (`clew.scope`).
test_a_declared_exclude_outside_the_repository_is_dropped
None test_scope.test_a_declared_exclude_outside_the_repository_is_dropped(Path tmp_path)
An escaping declared exclude is dropped too, rather than silently matching nothing.
Checks
assert derived.source == sc.SOURCE_DECLAREDassert derived.excludes == (), (f"an exclude outside the repository must be dropped, not resolved; got {derived.excludes}" )
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_a_declared_exclude_outside_the_repository_is_dropped → derive_scope |
| REQ-DDB-GUARD-012 | inferred | test_a_declared_exclude_outside_the_repository_is_dropped → derive_scope → _declared_index_scope → load_declaration_located → _checked_sections → _checked_section → _checked_requirements → _validate_node |
| REQ-DDB-PIPE-014 | catalog | |
| REQ-DDB-WIKI-054 | inferred | test_a_declared_exclude_outside_the_repository_is_dropped → derive_scope → _declared_index_scope → load_declaration_located → _checked_sections → _checked_section → _checked_list_section → all |
Source · 24 lines
def test_a_declared_exclude_outside_the_repository_is_dropped(tmp_path: Path) -> None:
"""The same resolution bug on the quieter half. An exclude cannot leak a tree, but one
pointing outside the repo silently excludes NOTHING while reading as honoured — the
accepted-but-unread failure this module fixes everywhere else.
@brief An escaping exclude does not reach the derived scope.
@return None.
@version 1
"""
root = tmp_path / "repo"
(root / "src").mkdir(parents=True)
(tmp_path / "outside").mkdir()
(root / ".clew.yaml").write_text(
"index_scope:\n roots: [src]\n excludes:\n - ../outside\n", encoding="utf-8"
)
derived = sc.derive_scope(root)
assert derived.source == sc.SOURCE_DECLARED
assert derived.excludes == (), (
f"an exclude outside the repository must be dropped, not resolved; got {derived.excludes}"
)
Activity · 7 steps
test_a_declared_root_outside_the_repository_is_refused
None test_scope.test_a_declared_root_outside_the_repository_is_refused(Path tmp_path)
A declared root that escapes the repository is dropped, not indexed.
Checks
assert rejection is not None, f"{entry!r} escapes the repository and must be rejected"assert all(sc._is_within(got, root.resolve()) for got in derived.roots), (f"{entry!r} put {derived.roots} outside {root} — the index would carry a tree " f"this repository never offered" )assert sc.declared_scope_rejection(root, stated) is not None, (f"a STATED root of {entry!r} must be rejected exactly as a declared one is" )
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_a_declared_root_outside_the_repository_is_refused → declared_scope_rejection |
| REQ-DDB-CONFIG-005 | measured | |
| REQ-DDB-GUARD-012 | inferred | test_a_declared_root_outside_the_repository_is_refused → declared_scope_rejection → _declared_index_scope → load_declaration_located → _checked_sections → _checked_section → _checked_requirements → _validate_node |
| REQ-DDB-PIPE-007 | catalog | |
| REQ-DDB-PIPE-014 | measured | |
| REQ-DDB-QUERY-006 | catalog | |
| REQ-DDB-WIKI-054 | inferred | test_a_declared_root_outside_the_repository_is_refused → all |
Source · 45 lines
def test_a_declared_root_outside_the_repository_is_refused(tmp_path: Path) -> None:
"""H5, 1.1.0 SECURITY AUDIT. `roots:` is repo-relative by contract, but the derivation
resolved each entry with `(root / entry).resolve()` and asked only whether it EXISTS. An
absolute entry discards `root` entirely (`Path('/a') / '/etc'` is `/etc`), and `../` walks
out, so a repository — or an MCP caller stating a scope for a repository it merely names —
chose any readable directory on the machine as the indexed tree. The index is then served
as that repository's content, with the paths of a tree the owner never offered.
Dropped-and-reported rather than raised: `_existing_paths` already drops a root that does
not exist, and an empty `roots` is the rejection the caller above already handles.
@brief An absolute or parent-escaping declared root never reaches the scope.
@return None.
@version 1
"""
root = tmp_path / "repo"
(root / "src").mkdir(parents=True)
outside = tmp_path / "outside"
(outside / "secrets").mkdir(parents=True)
for entry in (str(outside), "../outside", "src/../../outside"):
(root / ".clew.yaml").write_text(
f"index_scope:\n roots:\n - {entry}\n", encoding="utf-8"
)
rejection = sc.declared_scope_rejection(root)
derived = sc.derive_scope(root)
assert rejection is not None, f"{entry!r} escapes the repository and must be rejected"
assert all(sc._is_within(got, root.resolve()) for got in derived.roots), (
f"{entry!r} put {derived.roots} outside {root} — the index would carry a tree "
f"this repository never offered"
)
## AND THE TIER-1 STATED FORM, which is the reachable half: an MCP caller states a
## scope for a repository it merely NAMES, so this entry never passed an owner's hands
## at all. Both tiers go through one derivation, which is why one fix covers both —
## asserted rather than assumed, since the replay path (`_replay_manifest_statements`)
## re-enters the same function on every later build.
stated = {"roots": [entry]}
assert sc.declared_scope_rejection(root, stated) is not None, (
f"a STATED root of {entry!r} must be rejected exactly as a declared one is"
)
Activity · 12 steps
test_a_gate_pattern_alone_derives_no_index_scope
None test_scope.test_a_gate_pattern_alone_derives_no_index_scope(Path tmp_path)
The gate's files: pattern must NOT supply index roots.
Checks
assert derived.source == sc.SOURCE_WHOLE_REPOassert not derived.is_derived(), "the gate is not a declaration"assert derived.roots == (root.resolve(),), "the gate's boundary is not an index boundary"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_a_gate_pattern_alone_derives_no_index_scope → derive_scope |
| REQ-DDB-GUARD-012 | inferred | test_a_gate_pattern_alone_derives_no_index_scope → derive_scope → _declared_index_scope → load_declaration_located → _checked_sections → _checked_section → _checked_requirements → _validate_node |
| REQ-DDB-PIPE-014 | catalog | |
| REQ-DDB-WIKI-054 | inferred | test_a_gate_pattern_alone_derives_no_index_scope → derive_scope → _declared_index_scope → load_declaration_located → _checked_sections → _checked_section → _checked_list_section → all |
Source · 29 lines
def test_a_gate_pattern_alone_derives_no_index_scope(tmp_path: Path) -> None:
"""THE POINT OF THE THREE-TIER CHAIN. A `files:` regex answers what must be
DOCUMENTED. Standing in for the index decision it narrowed the index to the
quality bar — and, sitting above the whole-repo tier, it shadowed the fallback
that would have covered the rest.
So a repo whose only declaration is the gate derives NOTHING, and the resolution
drops to the whole repository (gh#333 removed the Doxyfile tier in between). The
`.c` file the gate exempts is the measurable consequence: it is out of the
mandate and squarely inside the repo, so it must be inside the scope.
`is_derived()` stays FALSE, and that is not a contradiction with the whole-repo
tier having roots: it asks whether the repo DECLARED a boundary, which is what
the callers gating on it (`propose`, `init`) actually want to know.
@brief A doxygen-guard hook contributes no index roots.
@version 2
"""
root = _repo(tmp_path / "repo", _SIMPLE_CONFIG)
_write(root / "src" / "a.c")
_write(root / "vendor" / "huge" / "d.c")
derived = sc.derive_scope(root)
assert derived.source == sc.SOURCE_WHOLE_REPO
assert not derived.is_derived(), "the gate is not a declaration"
assert derived.roots == (root.resolve(),), "the gate's boundary is not an index boundary"
Activity · 7 steps
test_a_repo_declaring_nothing_still_reports_absence
None test_scope.test_a_repo_declaring_nothing_still_reports_absence(Path tmp_path)
A genuinely absent declaration keeps its original wording.
Checks
assert derived.source == sc.SOURCE_WHOLE_REPOassert "no index_scope is declared" in derived.reason, (f"a repo that declares nothing must still report absence; got: {derived.reason}" )
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_a_repo_declaring_nothing_still_reports_absence → derive_scope |
| REQ-DDB-GUARD-012 | inferred | test_a_repo_declaring_nothing_still_reports_absence → derive_scope → _declared_index_scope → load_declaration_located → _checked_sections → _checked_section → _checked_requirements → _validate_node |
| REQ-DDB-PIPE-014 | catalog | |
| REQ-DDB-WIKI-054 | inferred | test_a_repo_declaring_nothing_still_reports_absence → derive_scope → _declared_index_scope → load_declaration_located → _checked_sections → _checked_section → _checked_list_section → all |
Source · 21 lines
def test_a_repo_declaring_nothing_still_reports_absence(tmp_path: Path) -> None:
"""THE CONTROL. Every message above is a REPLACEMENT for the absence clause, so a check that
only looked for the new wording would pass a version that had deleted the old one — and a
repo that declares nothing genuinely has no index_scope, which is the common case and must
keep saying so.
@brief With no declaration at all, the reason still says none is declared.
@return None.
@version 1
"""
root = tmp_path / "repo"
(root / "src").mkdir(parents=True)
derived = sc.derive_scope(root)
assert derived.source == sc.SOURCE_WHOLE_REPO
assert "no index_scope is declared" in derived.reason, (
f"a repo that declares nothing must still report absence; got: {derived.reason}"
)
Activity · 5 steps
test_a_scope_that_could_not_ask_git_does_not_claim_it_excluded_ignores
None test_scope.test_a_scope_that_could_not_ask_git_does_not_claim_it_excluded_ignores(Path tmp_path)
A scope that could not ask git must not claim it excluded what git ignores.
Checks
assert "less the paths git ignores" not in scope.reason, (f"claims an exclusion that never happened: {scope.reason}" )assert "not a git repository" in lowered or "could not" in lowered, (f"the reason must say the ignore list was unobtainable: {scope.reason}" )
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_a_scope_that_could_not_ask_git_does_not_claim_it_excluded_ignores → whole_repo_scope |
| REQ-DDB-PIPE-014 | catalog |
Source · 43 lines
def test_a_scope_that_could_not_ask_git_does_not_claim_it_excluded_ignores(
tmp_path: Path,
) -> None:
"""`_gitignored_paths` returns `[]` on BOTH "git said nothing is ignored" and "git could not
be asked at all" — a missing binary, or a tree that is not a repository. The second case
excludes nothing, and the only signal is a WARNING nobody reads after a build reports
success.
MEANWHILE `DerivedScope.reason` STATES THE OPPOSITE. It is built unconditionally and says
the scope is the whole repository "less the paths git ignores and the dot/cache
directories". When git was never successfully asked, that sentence is FALSE: nothing
ignored was excluded, and the build log asserts that something was.
This is the module's own rule turned on itself. `_gitignored_paths`'s docstring already
concedes "a silently wider index is the outcome this project keeps paying for" — so the
author knew, and the reason string still claims the exclusion happened.
AN EMPTY IGNORE LIST AND AN UNASKABLE ONE ARE DIFFERENT FACTS. A reporter whose index is
mysteriously wide needs to know which one they have, and the reason string is where they
will look.
@brief An unaskable ignore list is disclosed, not asserted away.
@return None.
@version 1
"""
## A DIRECTORY THAT IS NOT A GIT REPOSITORY, which is the reachable half of the fallback:
## `git ls-files` exits non-zero and the function returns `[]`. The missing-binary half
## takes the same branch and needs no second fixture.
root = tmp_path / "notarepo"
(root / "src").mkdir(parents=True)
(root / "src" / "a.c").write_text("int main(void){return 0;}\n", encoding="utf-8")
scope = sc.whole_repo_scope(root)
assert "less the paths git ignores" not in scope.reason, (
f"claims an exclusion that never happened: {scope.reason}"
)
lowered = scope.reason.lower()
assert "not a git repository" in lowered or "could not" in lowered, (
f"the reason must say the ignore list was unobtainable: {scope.reason}"
)
Activity · 7 steps
test_an_index_scope_declaration_is_what_yields_roots
None test_scope.test_an_index_scope_declaration_is_what_yields_roots(Path tmp_path)
A declaration is the only tier that yields index roots.
Checks
assert sc.derive_scope(root).roots == (root.resolve(),), "the gate declares no boundary"assert declared.source == sc.SOURCE_DECLAREDassert sorted(p.name for p in declared.roots) == ["src", "tests", "vendor"]assert declared.is_derived() is True, "a declared scope is the only tier that narrows"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_an_index_scope_declaration_is_what_yields_roots → derive_scope |
| REQ-DDB-GUARD-012 | inferred | test_an_index_scope_declaration_is_what_yields_roots → derive_scope → _declared_index_scope → load_declaration_located → _checked_sections → _checked_section → _checked_requirements → _validate_node |
| REQ-DDB-PIPE-014 | catalog | |
| REQ-DDB-WIKI-054 | inferred | test_an_index_scope_declaration_is_what_yields_roots → derive_scope → _declared_index_scope → load_declaration_located → _checked_sections → _checked_section → _checked_list_section → all |
Source · 27 lines
def test_an_index_scope_declaration_is_what_yields_roots(tmp_path: Path) -> None:
"""#57: index scope used to be identical to GATE scope, but they answer different
questions — the gate says what MUST be documented, the index says what should be
reasonable-about. Coupling them forced a repo to loosen its quality bar to widen
its graph. Here the gate covers `src/` alone while `vendor/` and `tests/` are the
trees a reader wants; the declaration is what lets them differ.
@brief Declared roots override, and the gate alone yields none.
@version 2
"""
root = tmp_path / "repo"
root.mkdir()
_repo_gating_only_src(root)
## The gate alone yields the WHOLE REPO (gh#333), not nothing — so the thing that
## distinguishes a declaration is that it NARROWS, which is the assertion below.
assert sc.derive_scope(root).roots == (root.resolve(),), "the gate declares no boundary"
(root / ".clew.yaml").write_text(
"index_scope:\n roots: [src, vendor, tests]\n", encoding="utf-8"
)
declared = sc.derive_scope(root)
assert declared.source == sc.SOURCE_DECLARED
assert sorted(p.name for p in declared.roots) == ["src", "tests", "vendor"]
assert declared.is_derived() is True, "a declared scope is the only tier that narrows"
Activity · 9 steps
test_an_index_scope_with_no_roots_says_so_rather_than_claiming_none_is_declared
None test_scope.test_an_index_scope_with_no_roots_says_so_rather_than_claiming_none_is_declared(Path tmp_path)
A present-but-unusable index_scope must not report as an ABSENT one.
Checks
assert derived.source == sc.SOURCE_WHOLE_REPO, "a rootless scope must still fall back"assert "no index_scope is declared" not in derived.reason, (f"the reason still claims the declaration is ABSENT while the loader logged that it was " f"read — that is the contradiction this test exists for. Got: {derived.reason}" )assert "roots" in derived.reason and "REPLACES" in derived.reason, (f"the reason must say WHY it was unusable and that `roots` replaces the scope, which is " f"the sharp edge; got: {derived.reason}" )
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_an_index_scope_with_no_roots_says_so_rather_than_claiming_none_is_declared → derive_scope |
| REQ-DDB-GUARD-012 | inferred | test_an_index_scope_with_no_roots_says_so_rather_than_claiming_none_is_declared → derive_scope → _declared_index_scope → load_declaration_located → _checked_sections → _checked_section → _checked_requirements → _validate_node |
| REQ-DDB-PIPE-014 | catalog | |
| REQ-DDB-WIKI-054 | inferred | test_an_index_scope_with_no_roots_says_so_rather_than_claiming_none_is_declared → derive_scope → _declared_index_scope → load_declaration_located → _checked_sections → _checked_section → _checked_list_section → all |
Source · 39 lines
def test_an_index_scope_with_no_roots_says_so_rather_than_claiming_none_is_declared(
tmp_path: Path,
) -> None:
"""gh#5, AND THE DEFECT IS A CONTRADICTION RATHER THAN A WRONG SCOPE. The reporter wrote an
`index_scope:` block, and one build told them both things at once:
INFO declaration: <file> declares index_scope
WARNING scope: indexing the WHOLE repository — no index_scope is declared for this repo
The behaviour was right — `roots` REPLACES the scope and is required, so a block carrying
only exclusions is not a usable scope — but nothing distinguished found-but-rejected from
absent. They spent a round trip deciding whether to fix their YAML or file a bug, and only
`propose_declaration` settled it: a tool nobody reaches for after a build reports success.
ASSERTS THE ABSENCE CLAUSE IS GONE, not merely that a reason exists. Appending the real cause
while still saying "no index_scope is declared" would leave the contradiction in place, which
is why `rejected` REPLACES that clause instead of adding to it.
@brief A rootless index_scope is reported as rejected, not as absent.
@return None.
@version 1
"""
root = tmp_path / "repo"
(root / "src").mkdir(parents=True)
(root / ".clew.yaml").write_text("index_scope:\n excludes:\n - src\n", encoding="utf-8")
derived = sc.derive_scope(root)
assert derived.source == sc.SOURCE_WHOLE_REPO, "a rootless scope must still fall back"
assert "no index_scope is declared" not in derived.reason, (
f"the reason still claims the declaration is ABSENT while the loader logged that it was "
f"read — that is the contradiction this test exists for. Got: {derived.reason}"
)
assert "roots" in derived.reason and "REPLACES" in derived.reason, (
f"the reason must say WHY it was unusable and that `roots` replaces the scope, which is "
f"the sharp edge; got: {derived.reason}"
)
Activity · 7 steps
test_an_indexed_tree_that_looks_vendored_is_named_with_the_remedy
None test_scope.test_an_indexed_tree_that_looks_vendored_is_named_with_the_remedy(Path tmp_path)
A tree that looks vendored and IS indexed is named, with the remedy.
Checks
assert "third_party" in reason, f"the vendored-looking tree is not named: {reason}"assert "index_scope" in reason, f"no remedy is given: {reason}"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_an_indexed_tree_that_looks_vendored_is_named_with_the_remedy → whole_repo_scope |
| REQ-DDB-PIPE-014 | catalog |
Source · 26 lines
def test_an_indexed_tree_that_looks_vendored_is_named_with_the_remedy(tmp_path: Path) -> None:
"""A COMMITTED DEPENDENCY TREE IS EXCLUDED BY NO IGNORE RULE. `_gitignored_paths` asks git
for `--others`, i.e. UNTRACKED files only, so a vendored library someone checked in is
indexed in full and nothing says so — the index is silently dominated by somebody else's
code.
DISCLOSED, NOT EXCLUDED, by owner ruling. clew cannot tell a vendored tree from
first-party code sharing a conventional name, and excluding by name would silently remove
real source — absence reported as emptiness, the failure this whole patch addresses. The
repository can already narrow its own scope with `index_scope`; what was missing is being
TOLD to.
@brief A vendored-looking indexed tree is named and the fix is given.
@return None.
@version 1
"""
root = tmp_path / "repo"
_src(root, "src/main.c")
_src(root, "third_party/zlib/inflate.c")
reason = sc.whole_repo_scope(root).reason
assert "third_party" in reason, f"the vendored-looking tree is not named: {reason}"
assert "index_scope" in reason, f"no remedy is given: {reason}"
Activity · 6 steps
test_an_unknown_key_inside_index_scope_refuses_by_name
None test_scope.test_an_unknown_key_inside_index_scope_refuses_by_name(Path tmp_path)
A misspelled key INSIDE index_scope must refuse by name, not be silently ignored.
Checks
assert derived.source == sc.SOURCE_WHOLE_REPO, ("a declaration carrying an unread key must NOT be applied as though it were understood — " "silently honouring `roots` while dropping `exclude` is the half-applied scope change " "that reads as success" )assert "exclude" in derived.reason, "the reason must name the offending key"assert "excludes" in derived.reason, "and the accepted spelling, so the fix is one edit"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_an_unknown_key_inside_index_scope_refuses_by_name → derive_scope |
| REQ-DDB-GUARD-012 | inferred | test_an_unknown_key_inside_index_scope_refuses_by_name → derive_scope → _declared_index_scope → load_declaration_located → _checked_sections → _checked_section → _checked_requirements → _validate_node |
| REQ-DDB-PIPE-014 | catalog | |
| REQ-DDB-WIKI-054 | inferred | test_an_unknown_key_inside_index_scope_refuses_by_name → derive_scope → _declared_index_scope → load_declaration_located → _checked_sections → _checked_section → _checked_list_section → all |
Source · 32 lines
def test_an_unknown_key_inside_index_scope_refuses_by_name(tmp_path: Path) -> None:
"""FOUND WHILE FIXING gh#5 AND IT IS THE WORSE HALF. Section NAMES were validated against
KNOWN_SECTIONS; the keys inside a section were not. So `exclude:` for `excludes:` parsed to a
valid mapping that no consumer ever read — the reporter's own YAML used the singular, and
even with `roots` supplied it would have excluded nothing while reporting success.
That is precisely the shape this project has shipped most often: an accepted-but-unread key.
`key_arg_idx` for `key_arg_index` silently keyed dataflow off argument 0; a `--declare`'d
`preprocessor:` section validated, logged as applied, and resolved as though nobody had
stated it. Fail closed at the ENTRY level, and name the accepted keys so the fix is one edit.
@brief An unknown inner key is refused and both it and the accepted set are named.
@return None.
@version 1
"""
root = tmp_path / "repo"
(root / "src").mkdir(parents=True)
(root / ".clew.yaml").write_text(
"index_scope:\n roots:\n - src\n exclude:\n - src/gen\n", encoding="utf-8"
)
derived = sc.derive_scope(root)
assert derived.source == sc.SOURCE_WHOLE_REPO, (
"a declaration carrying an unread key must NOT be applied as though it were understood — "
"silently honouring `roots` while dropping `exclude` is the half-applied scope change "
"that reads as success"
)
assert "exclude" in derived.reason, "the reason must name the offending key"
assert "excludes" in derived.reason, "and the accepted spelling, so the fix is one edit"
Activity · 7 steps
test_cli_apply_scope_default_replaces_the_doxyfile_input
None test_scope.test_cli_apply_scope_default_replaces_the_doxyfile_input(Path tmp_path)
The parser default is from-guard, so a bare invocation indexes the whole repo.
Checks
assert args.scope == sc.SCOPE_FROM_GUARD, ("gh#333 flipped the default, and the 22->6 collapse must not have moved it: the " "parser default is the ONLY declaration of it left in the tool" )assert args.replace_input is Trueassert args.extra_input == [str(root.resolve())]
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_cli_apply_scope_default_replaces_the_doxyfile_input → _apply_scope → declared_scope_rejection |
| REQ-DDB-GUARD-012 | inferred | test_cli_apply_scope_default_replaces_the_doxyfile_input → _apply_scope → declared_scope_rejection → _declared_index_scope → load_declaration_located → _checked_sections → _checked_section → _checked_requirements → _validate_node |
| REQ-DDB-PIPE-014 | catalog | |
| REQ-DDB-WIKI-054 | inferred | test_cli_apply_scope_default_replaces_the_doxyfile_input → _apply_scope → declared_scope_rejection → _declared_index_scope → load_declaration_located → _checked_sections → _checked_section → _checked_list_section → all |
Source · 29 lines
def test_cli_apply_scope_default_replaces_the_doxyfile_input(tmp_path: Path) -> None:
"""THE INVERSION gh#333 FIXES, asserted from the CLI surface. A repo that ships a
Doxyfile and declares no index scope used to keep the Doxyfile's INPUT — its
published-API subset — while an otherwise identical repo WITHOUT a Doxyfile got
its whole tree. The default now replaces INPUT in both cases.
`replace_input` is the load-bearing assertion, not `extra_input`: it is what
tells the Doxyfile writer to discard the target's own INPUT rather than prepend
to it, so a test that checked only the root list would pass against a build that
indexed the union of both.
@brief The default scope replaces a shipped Doxyfile's INPUT with the repo root.
@version 1
"""
from clew.cli import _apply_scope
root = _repo(tmp_path / "repo", _SIMPLE_CONFIG)
_write(root / "src" / "a.c")
args = _args(tmp_path / "clew.db", doxyfile=str(root / "Doxyfile"))
_apply_scope(args, root)
assert args.scope == sc.SCOPE_FROM_GUARD, (
"gh#333 flipped the default, and the 22->6 collapse must not have moved it: the "
"parser default is the ONLY declaration of it left in the tool"
)
assert args.replace_input is True
assert args.extra_input == [str(root.resolve())]
Activity · 8 steps
test_cli_apply_scope_doxyfile_is_inert
None test_scope.test_cli_apply_scope_doxyfile_is_inert(Path tmp_path)
A stated doxyfile scope is an EXPLICIT opt-out and leaves the build args untouched.
Checks
assert args.scope == sc.SCOPE_DOXYFILEassert args.replace_input is Falseassert args.extra_input is None
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | inferred | test_cli_apply_scope_doxyfile_is_inert → _apply_scope → declared_scope_rejection |
| REQ-DDB-GUARD-012 | inferred | test_cli_apply_scope_doxyfile_is_inert → _apply_scope → declared_scope_rejection → _declared_index_scope → load_declaration_located → _checked_sections → _checked_section → _checked_requirements → _validate_node |
| REQ-DDB-PIPE-014 | catalog | |
| REQ-DDB-WIKI-054 | inferred | test_cli_apply_scope_doxyfile_is_inert → _apply_scope → declared_scope_rejection → _declared_index_scope → load_declaration_located → _checked_sections → _checked_section → _checked_list_section → all |
Source · 34 lines
def test_cli_apply_scope_doxyfile_is_inert(tmp_path: Path) -> None:
"""gh#333 flipped the DEFAULT to `from-guard`, and this is the surviving narrow
path: an operator who passes `--scope doxyfile` gets the Doxyfile's own INPUT and
no derivation at all.
Stated EXPLICITLY here rather than relying on the parser default, which is the
whole point of the flip — a test that took the default would have silently
started asserting the new behaviour under the old name.
THE FLAG IS GONE AND THE VALUE IS NOT (22->6 collapse). `doxyfile` scope is build
MECHANICS, not a declaration, so it has no section and never should; it stays reachable
on the typed surface (`build_index(scope=…)`, `index(action='refresh', scope=…)`) and is
stated here on the dest those go through. Deleting the value with the flag would have
removed the only opt-out from gh#333's whole-repo default.
@brief An explicit doxyfile scope applies no derived roots.
@version 3
"""
from clew.cli import _apply_scope
root = _repo(tmp_path / "repo", _SIMPLE_CONFIG)
_write(root / "src" / "a.c")
args = _args(
tmp_path / "clew.db",
doxyfile=str(root / "Doxyfile"),
scope=sc.SCOPE_DOXYFILE,
)
_apply_scope(args, root)
assert args.scope == sc.SCOPE_DOXYFILE
assert args.replace_input is False
assert args.extra_input is None
Activity · 8 steps
test_cli_apply_scope_indexes_the_whole_repo_without_a_declaration
None test_scope.test_cli_apply_scope_indexes_the_whole_repo_without_a_declaration(Path tmp_path)
A repo with no declaration gets the whole repo under from-guard.
Checks
assert args.replace_input is Trueassert args.extra_input == [str(root.resolve())]
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_cli_apply_scope_indexes_the_whole_repo_without_a_declaration → _apply_scope → declared_scope_rejection |
| REQ-DDB-GUARD-012 | inferred | test_cli_apply_scope_indexes_the_whole_repo_without_a_declaration → _apply_scope → declared_scope_rejection → _declared_index_scope → load_declaration_located → _checked_sections → _checked_section → _checked_requirements → _validate_node |
| REQ-DDB-PIPE-014 | catalog | |
| REQ-DDB-WIKI-054 | inferred | test_cli_apply_scope_indexes_the_whole_repo_without_a_declaration → _apply_scope → declared_scope_rejection → _declared_index_scope → load_declaration_located → _checked_sections → _checked_section → _checked_list_section → all |
Source · 24 lines
def test_cli_apply_scope_indexes_the_whole_repo_without_a_declaration(tmp_path: Path) -> None:
"""The undeclared branch must not half-apply. It used to `return` before
replacing anything, handing INPUT back to the Doxyfile; gh#333 makes it fold a
real whole-repo scope, so `replace_input` is True and the repo root is the root
list.
@brief An undeclared repo folds the whole-repo scope into the build args.
@version 2
"""
from clew.cli import _apply_scope
root = tmp_path / "repo"
_write(root / "src" / "a.c")
args = _args(
tmp_path / "clew.db",
doxyfile=str(root / "Doxyfile"),
scope=sc.SCOPE_FROM_GUARD,
)
_apply_scope(args, root)
assert args.replace_input is True
assert args.extra_input == [str(root.resolve())]
Activity · 7 steps
test_cli_apply_scope_refuses_a_rejected_declaration
None test_scope.test_cli_apply_scope_refuses_a_rejected_declaration(Path tmp_path)
A rejected declaration refuses the build rather than silently widening it.
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_cli_apply_scope_refuses_a_rejected_declaration → _apply_scope → declared_scope_rejection |
| REQ-DDB-GUARD-012 | inferred | test_cli_apply_scope_refuses_a_rejected_declaration → _apply_scope → declared_scope_rejection → _declared_index_scope → load_declaration_located → _checked_sections → _checked_section → _checked_requirements → _validate_node |
| REQ-DDB-PIPE-014 | catalog | |
| REQ-DDB-WIKI-054 | inferred | test_cli_apply_scope_refuses_a_rejected_declaration → _apply_scope → declared_scope_rejection → _declared_index_scope → load_declaration_located → _checked_sections → _checked_section → _checked_list_section → all |
Source · 26 lines
def test_cli_apply_scope_refuses_a_rejected_declaration(tmp_path: Path) -> None:
"""FIELD-REPORTED: an excludes-only `.clew.yaml` — written by an operator trying to
keep a 1.2GB vendored tree out of the index — was silently absorbed into the
whole-repo tier (a buildlog WARNING, then the widest possible scope anyway), and cost
a real build a 900s doxygen timeout under exactly the tree the declaration was trying
to exclude. `_apply_scope` must now refuse instead, before doxygen ever runs.
@brief An excludes-only declaration makes `_apply_scope` exit rather than fold.
@return None.
@version 1
"""
from clew.cli import _apply_scope
root = tmp_path / "repo"
_write(root / "src" / "a.c")
(root / ".clew.yaml").write_text("index_scope:\n excludes:\n - src\n", encoding="utf-8")
args = _args(
tmp_path / "clew.db",
doxyfile=str(root / "Doxyfile"),
scope=sc.SCOPE_FROM_GUARD,
)
with pytest.raises(SystemExit):
_apply_scope(args, root)
Activity · 7 steps
test_cli_apply_scope_replaces_input
None test_scope.test_cli_apply_scope_replaces_input(Path tmp_path)
--scope from-guard folds the declared roots into the build arguments.
Checks
assert args.replace_input is Trueassert args.extra_input == [str(root.resolve() / "src"), "/elsewhere"]
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_cli_apply_scope_replaces_input → _apply_scope → declared_scope_rejection |
| REQ-DDB-GUARD-012 | inferred | test_cli_apply_scope_replaces_input → _apply_scope → declared_scope_rejection → _declared_index_scope → load_declaration_located → _checked_sections → _checked_section → _checked_requirements → _validate_node |
| REQ-DDB-PIPE-014 | catalog | |
| REQ-DDB-WIKI-054 | inferred | test_cli_apply_scope_replaces_input → _apply_scope → declared_scope_rejection → _declared_index_scope → load_declaration_located → _checked_sections → _checked_section → _checked_list_section → all |
Source · 25 lines
def test_cli_apply_scope_replaces_input(tmp_path: Path) -> None:
"""The declared roots become the INPUT list (replace_input), with any
explicit --extra-input appended on top rather than discarded.
@brief A declared index scope becomes the build's INPUT.
@version 2
"""
from clew.cli import _apply_scope
root = _repo(tmp_path / "repo", _SIMPLE_CONFIG)
_write(root / "src" / "a.c")
(root / ".clew.yaml").write_text("index_scope:\n roots: [src]\n", encoding="utf-8")
args = _args(
tmp_path / "clew.db",
doxyfile=str(root / "Doxyfile"),
scope=sc.SCOPE_FROM_GUARD,
extra_input=["/elsewhere"],
)
_apply_scope(args, root)
assert args.replace_input is True
assert args.extra_input == [str(root.resolve() / "src"), "/elsewhere"]
Activity · 8 steps
test_declared_index_scope_drops_paths_that_do_not_exist
None test_scope.test_declared_index_scope_drops_paths_that_do_not_exist(Path tmp_path)
A stale declared root is dropped rather than passed to doxygen.
Checks
assert [p.name for p in scope.roots] == ["src"]assert scope.excludes == ()
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_declared_index_scope_drops_paths_that_do_not_exist → derive_scope |
| REQ-DDB-GUARD-012 | inferred | test_declared_index_scope_drops_paths_that_do_not_exist → derive_scope → _declared_index_scope → load_declaration_located → _checked_sections → _checked_section → _checked_requirements → _validate_node |
| REQ-DDB-PIPE-014 | catalog | |
| REQ-DDB-WIKI-054 | inferred | test_declared_index_scope_drops_paths_that_do_not_exist → derive_scope → _declared_index_scope → load_declaration_located → _checked_sections → _checked_section → _checked_list_section → all |
Source · 18 lines
def test_declared_index_scope_drops_paths_that_do_not_exist(tmp_path: Path) -> None:
"""A stale entry must not reach doxygen, which would report a confusing
'input not found'. It is dropped with a warning instead.
@brief Non-existent declared roots and excludes are dropped.
@version 2
"""
root = tmp_path / "repo"
root.mkdir()
_repo_gating_only_src(root)
(root / ".clew.yaml").write_text(
"index_scope:\n roots: [src, gone]\n excludes: [also_gone]\n", encoding="utf-8"
)
scope = sc.derive_scope(root)
assert [p.name for p in scope.roots] == ["src"]
assert scope.excludes == ()
Activity · 7 steps
test_declared_scope_rejection_reports_without_falling_back
None test_scope.test_declared_scope_rejection_reports_without_falling_back(Path tmp_path)
declared_scope_rejection reports the reason without derive_scope's fallback.
Checks
assert rejection is not Noneassert "roots" in rejection and "REPLACES" in rejectionassert sc.declared_scope_rejection(plain) is Noneassert sc.declared_scope_rejection(usable) is None
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_declared_scope_rejection_reports_without_falling_back → declared_scope_rejection |
| REQ-DDB-GUARD-012 | inferred | test_declared_scope_rejection_reports_without_falling_back → declared_scope_rejection → _declared_index_scope → load_declaration_located → _checked_sections → _checked_section → _checked_requirements → _validate_node |
| REQ-DDB-PIPE-014 | catalog | |
| REQ-DDB-WIKI-054 | inferred | test_declared_scope_rejection_reports_without_falling_back → declared_scope_rejection → _declared_index_scope → load_declaration_located → _checked_sections → _checked_section → _checked_list_section → all |
Source · 31 lines
def test_declared_scope_rejection_reports_without_falling_back(tmp_path: Path) -> None:
"""THE SEPARATE, BUILD-TIME CHECK a caller who can still refuse uses — `derive_scope`
itself keeps absorbing a rejected declaration into the whole-repo tier for every other
caller (the test right above this one asserts exactly that, unchanged). This one is
for the NEW build-time guard, `_apply_scope`, to consult before committing to a scope.
@brief An excludes-only declaration is reported as rejected by name.
@return None.
@version 1
"""
root = tmp_path / "repo"
(root / "src").mkdir(parents=True)
(root / ".clew.yaml").write_text("index_scope:\n excludes:\n - src\n", encoding="utf-8")
rejection = sc.declared_scope_rejection(root)
assert rejection is not None
assert "roots" in rejection and "REPLACES" in rejection
## AND THE CONTROL: a repo with no declaration at all, or a usable one, is None —
## not "rejected", which would make every ordinary repo refuse to build.
plain = tmp_path / "plain"
(plain / "src").mkdir(parents=True)
assert sc.declared_scope_rejection(plain) is None
usable = tmp_path / "usable"
(usable / "src").mkdir(parents=True)
(usable / ".clew.yaml").write_text("index_scope:\n roots: [src]\n", encoding="utf-8")
assert sc.declared_scope_rejection(usable) is None
Activity · 13 steps
test_dot_directories_are_excluded_from_the_whole_repo_scope
None test_scope.test_dot_directories_are_excluded_from_the_whole_repo_scope(Path tmp_path)
Dot-directories are excluded from the whole-repo scope, not indexed.
Checks
assert scope.source == sc.SOURCE_WHOLE_REPOassert _rel_roots(scope, root) == ["."], "the repo itself is the one INPUT root"assert ".venv" in _rel_excludes(scope, root)assert "src" not in _rel_excludes(scope, root)
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_dot_directories_are_excluded_from_the_whole_repo_scope → whole_repo_scope |
| REQ-DDB-PIPE-014 | catalog |
Source · 20 lines
def test_dot_directories_are_excluded_from_the_whole_repo_scope(tmp_path: Path) -> None:
"""Virtualenvs and tool caches live in dot-directories, and the whole-repo root
is handed to doxygen unwalked — so the rule that prunes them has to travel as an
EXCLUDE entry or it does not apply at all.
@brief A dot-directory under the whole-repo root is excluded.
@version 1
"""
root = tmp_path / "repo"
_write(root / "src" / "a.c")
_write(root / ".venv" / "lib" / "vendor.c")
scope = sc.whole_repo_scope(root)
assert scope.source == sc.SOURCE_WHOLE_REPO
assert _rel_roots(scope, root) == ["."], "the repo itself is the one INPUT root"
assert ".venv" in _rel_excludes(scope, root)
assert "src" not in _rel_excludes(scope, root)
Activity · 8 steps
test_empty_or_absent_index_scope_falls_back_to_the_whole_repo
None test_scope.test_empty_or_absent_index_scope_falls_back_to_the_whole_repo(Path tmp_path)
An empty or absent index_scope falls through to the whole-repo tier.
Checks
assert sc.derive_scope(root).source == sc.SOURCE_WHOLE_REPOassert sc.derive_scope(root).roots == (root.resolve(),)assert sc.derive_scope(root).source == sc.SOURCE_WHOLE_REPOassert sc.derive_scope(root).roots == (root.resolve(),)
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_empty_or_absent_index_scope_falls_back_to_the_whole_repo → derive_scope |
| REQ-DDB-GUARD-012 | inferred | test_empty_or_absent_index_scope_falls_back_to_the_whole_repo → derive_scope → _declared_index_scope → load_declaration_located → _checked_sections → _checked_section → _checked_requirements → _validate_node |
| REQ-DDB-PIPE-014 | catalog | |
| REQ-DDB-WIKI-054 | inferred | test_empty_or_absent_index_scope_falls_back_to_the_whole_repo → derive_scope → _declared_index_scope → load_declaration_located → _checked_sections → _checked_section → _checked_list_section → all |
Source · 23 lines
def test_empty_or_absent_index_scope_falls_back_to_the_whole_repo(tmp_path: Path) -> None:
"""An unusable section must read as "nothing was declared" and drop to the next
tier, never as a declared-and-empty scope — which would blank the index. Since
gh#333 the next tier is the whole repository rather than the Doxyfile, so the
consequence of getting this wrong got LOUDER, not quieter: an empty declared
scope would now be the one way to reach an empty index.
@brief An unusable index_scope section yields the whole repo, not empty roots.
@version 3
"""
root = tmp_path / "repo"
root.mkdir()
_repo_gating_only_src(root)
(root / ".clew.yaml").write_text("shared_key_patterns:\n writers: []\n", encoding="utf-8")
assert sc.derive_scope(root).source == sc.SOURCE_WHOLE_REPO
assert sc.derive_scope(root).roots == (root.resolve(),)
(root / ".clew.yaml").write_text("index_scope:\n roots: []\n", encoding="utf-8")
assert sc.derive_scope(root).source == sc.SOURCE_WHOLE_REPO
assert sc.derive_scope(root).roots == (root.resolve(),)
Activity · 9 steps
test_first_party_platform_directories_are_not_reported_as_vendored
None test_scope.test_first_party_platform_directories_are_not_reported_as_vendored(Path tmp_path)
First-party platform source is never reported as vendored.
Checks
assert "vendored" not in reason.lower(), f"first-party platform code was flagged: {reason}"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_first_party_platform_directories_are_not_reported_as_vendored → whole_repo_scope |
| REQ-DDB-PIPE-014 | catalog |
Source · 24 lines
def test_first_party_platform_directories_are_not_reported_as_vendored(tmp_path: Path) -> None:
"""THE REASON DISCLOSURE WAS CHOSEN OVER EXCLUSION. A React Native app keeps its own native
source under `ios/` and `android/` — committed, first-party, and exactly what an index of
that app should contain. Its native DEPENDENCIES live under `ios/Pods` and build outputs,
which a well-kept repository gitignores and clew already excludes.
So the platform directories must not trip the vendored check. A rule broad enough to flag
them would teach every mobile-app user to ignore the disclosure, which is how a real one
stops being read.
@brief ios/ and android/ are not called vendored.
@return None.
@version 1
"""
root = tmp_path / "app"
_src(root, "src/App.c")
_src(root, "ios/Mattermost/AppDelegate.c")
_src(root, "android/app/src/main/Main.c")
reason = sc.whole_repo_scope(root).reason
assert "vendored" not in reason.lower(), f"first-party platform code was flagged: {reason}"
Activity · 6 steps
test_no_declaration_yields_the_whole_repo
None test_scope.test_no_declaration_yields_the_whole_repo(Path tmp_path)
No declaration at all yields the whole repo, and says why.
Checks
assert derived.source == sc.SOURCE_WHOLE_REPOassert not derived.is_derived()assert derived.roots == (root.resolve(),)assert sc.INDEX_SCOPE_SECTION in derived.reasonassert ".clew.yaml" in derived.reason
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_no_declaration_yields_the_whole_repo → derive_scope |
| REQ-DDB-GUARD-012 | inferred | test_no_declaration_yields_the_whole_repo → derive_scope → _declared_index_scope → load_declaration_located → _checked_sections → _checked_section → _checked_requirements → _validate_node |
| REQ-DDB-PIPE-014 | catalog | |
| REQ-DDB-WIKI-054 | inferred | test_no_declaration_yields_the_whole_repo → derive_scope → _declared_index_scope → load_declaration_located → _checked_sections → _checked_section → _checked_list_section → all |
Source · 25 lines
def test_no_declaration_yields_the_whole_repo(tmp_path: Path) -> None:
"""Fail safe and loud: the tier is explicit in both the source and the reason,
never a silent guess, and the reason names where a declaration was looked for so
"declares nothing" is distinguishable from "we looked in the wrong place".
THE REASON MUST STILL CARRY THE SEARCH (gh#333). Folding the Doxyfile tier away
deleted the function that phrased that clause, and the clause is gh#16's whole
substance — without it a repo whose config we failed to FIND and a repo that
declares nothing produce the same sentence.
@brief An undeclared repo takes the whole-repo tier with a reason naming the search.
@version 3
"""
root = tmp_path / "repo"
_write(root / "src" / "a.c")
derived = sc.derive_scope(root)
assert derived.source == sc.SOURCE_WHOLE_REPO
assert not derived.is_derived()
assert derived.roots == (root.resolve(),)
assert sc.INDEX_SCOPE_SECTION in derived.reason
assert ".clew.yaml" in derived.reason
Activity · 8 steps
test_the_vendored_disclosure_is_bounded
None test_scope.test_the_vendored_disclosure_is_bounded(Path tmp_path)
The vendored disclosure is bounded however many trees match.
Checks
assert "look vendored" in reason, f"precondition: nothing was disclosed: {reason}"assert "12 trees" in reason, f"the true count was lost when summarising: {reason}"assert reason.count("/vendor") <= 5, f"the disclosure was not bounded: {reason}"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_the_vendored_disclosure_is_bounded → whole_repo_scope |
| REQ-DDB-PIPE-014 | catalog |
Source · 22 lines
def test_the_vendored_disclosure_is_bounded(tmp_path: Path) -> None:
"""gh#37: an EXCLUDE list grew to ~390 entries and overflowed a client's reply limit. A
disclosure that names every matching tree repeats that on a repository vendoring many
libraries. Name a few, COUNT the rest, so the reader still learns the true size.
@brief Many vendored trees are summarised, not enumerated.
@return None.
@version 1
"""
root = tmp_path / "mono"
for i in range(12):
_src(root, f"pkg{i}/vendor/lib.c")
reason = sc.whole_repo_scope(root).reason
## THE FIRST DRAFT OF THIS TEST PASSED BEFORE THE FEATURE EXISTED, and is kept honest by
## these anchors. `reason.count("vendor") <= 8` is trivially true when nothing is
## disclosed, and a bare `"12" in reason` matched `git exit 128` in the not-a-repository
## clause — so both assertions held over a reason that disclosed nothing at all.
assert "look vendored" in reason, f"precondition: nothing was disclosed: {reason}"
assert "12 trees" in reason, f"the true count was lost when summarising: {reason}"
assert reason.count("/vendor") <= 5, f"the disclosure was not bounded: {reason}"1 more lines, not shown
Activity · 7 steps
test_unparseable_config_falls_back_to_the_whole_repo
None test_scope.test_unparseable_config_falls_back_to_the_whole_repo(Path tmp_path)
An unparseable pre-commit config falls back to the whole-repo tier.
Checks
assert sc.derive_scope(root).source == sc.SOURCE_WHOLE_REPO
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_unparseable_config_falls_back_to_the_whole_repo → derive_scope |
| REQ-DDB-GUARD-012 | inferred | test_unparseable_config_falls_back_to_the_whole_repo → derive_scope → _declared_index_scope → load_declaration_located → _checked_sections → _checked_section → _checked_requirements → _validate_node |
| REQ-DDB-PIPE-014 | catalog | |
| REQ-DDB-WIKI-054 | inferred | test_unparseable_config_falls_back_to_the_whole_repo → derive_scope → _declared_index_scope → load_declaration_located → _checked_sections → _checked_section → _checked_list_section → all |
Source · 17 lines
def test_unparseable_config_falls_back_to_the_whole_repo(tmp_path: Path) -> None:
"""A malformed config is never guessed at — scope derivation drops to the
whole-repo tier instead of half-reading it. FAILING OPEN is deliberate here and
is the opposite of the fail-closed rule elsewhere: a scope that cannot be read
yields a WIDER index, never a narrower one, because a silently narrow index is
the failure this project keeps paying for.
@brief A malformed pre-commit config leaves scope on the whole-repo tier.
@version 3
"""
root = tmp_path / "repo"
root.mkdir()
(root / ".pre-commit-config.yaml").write_text("repos: [ unbalanced\n", encoding="utf-8")
assert sc.derive_scope(root).source == sc.SOURCE_WHOLE_REPO