test_tiers.py

tests/test_tiers.py

Five-tier layered-option resolution (gh#319).

test_a_corrupt_record_refuses_rather_than_reverting_silently

None test_tiers.test_a_corrupt_record_refuses_rather_than_reverting_silently()

FAIL CLOSED. Reverting to the target's declaration because the record could not be read is the exact defect the read-back exists to remove: the build would report success over a policy nobody chose. Nothing but `tiers` writes this row, so reaching here means the database was hand-edited.

tests/test_tiers.py:734

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-006measuredtest_a_corrupt_record_refuses_rather_than_reverting_silently → recorded_document
Source · 16 lines
def test_a_corrupt_record_refuses_rather_than_reverting_silently() -> None:
    """FAIL CLOSED. Reverting to the target's declaration because the record could not
    be read is the exact defect the read-back exists to remove: the build would report
    success over a policy nobody chose. Nothing but `tiers` writes this row, so
    reaching here means the database was hand-edited.
    """
    ## Both halves of the refusal: JSON that will not parse, and JSON that parses to a
    ## shape no manifest loader can read. The second is the quieter one — it would
    ## otherwise fail several frames away, in a parser whose message names a shape
    ## rather than a corrupt record.
    for raw in ("{not json", "[1,2]"):
        section = {f"o.{TIER_KEY}": TIER_EXPLICIT, f"o.{EXPLICIT_KEY}": raw}
        with pytest.raises(ValueError, match="'o'"):
            recorded_document(section, "o")

Activity · 4 steps
lines 744–744◇ for raw in ("{not json", "[1,2]")lines 745–745section = {f"o.{TIER_KEY}": TIER_EXPLICIT, f"o.{EXPLICIT_KEY}": raw}lines 746–746with pytest.raises(ValueError, match="'o'")lines 747–747recorded_document(section, "o")

test_a_declaration_displaces_the_guesses_and_keeps_the_facts

None test_tiers.test_a_declaration_displaces_the_guesses_and_keeps_the_facts()

Tier 2 behaves exactly as tier 1 does against the guesses.

tests/test_tiers.py:108

Checks

  • assert resolved.values == (*FACTS, *ECOSYSTEM, "%theirs%")
  • assert resolved.tier == TIER_DECLARED

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-006measuredtest_a_declaration_displaces_the_guesses_and_keeps_the_facts → resolve_layered
Source · 9 lines
def test_a_declaration_displaces_the_guesses_and_keeps_the_facts() -> None:
    """Tier 2 behaves exactly as tier 1 does against the guesses."""
    resolved = resolve_layered(
        facts=FACTS, ecosystem=ECOSYSTEM, heuristics=GUESSES, declared=["%theirs%"]
    )
    assert resolved.values == (*FACTS, *ECOSYSTEM, "%theirs%")
    assert resolved.tier == TIER_DECLARED

Activity · 3 steps
lines 110–112resolved = resolve_layered( facts=FACTS, ecosystem=ECOSYSTEM, heuristics=GUESSES, declared=["%theirs%"] )lines 113–113assert resolved.values == (*FACTS, *ECOSYSTEM, "%theirs%")lines 114–114assert resolved.tier == TIER_DECLARED

test_a_declaration_is_not_replayed_from_the_record

None test_tiers.test_a_declaration_is_not_replayed_from_the_record(Path tmp_path)

The recorded row for a tier-2 win carries no statement, so a later build re-reads the declaration file rather than a frozen copy of it.

tests/test_tiers.py:475

Show on the map →

Called by none

Calls _entry_patterns, _recorded_entry_patterns, _stamp

Checks

  • assert _recorded_entry_patterns(args, db) is None

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-001measuredtest_a_declaration_is_not_replayed_from_the_record → _entry_patterns → string_list
REQ-DDB-CONFIG-006measuredtest_a_declaration_is_not_replayed_from_the_record → _stamp → write_build_signature
REQ-DDB-CONFIG-007measuredtest_a_declaration_is_not_replayed_from_the_record → _stamp → write_build_signature
REQ-DDB-MCP-001measuredtest_a_declaration_is_not_replayed_from_the_record → _recorded_entry_patterns → meta_section
REQ-DDB-PIPE-005measuredtest_a_declaration_is_not_replayed_from_the_record → _stamp → write_build_signature
Source · 10 lines
def test_a_declaration_is_not_replayed_from_the_record(tmp_path: Path) -> None:
    """The recorded row for a tier-2 win carries no statement, so a later build
    re-reads the declaration file rather than a frozen copy of it.
    """
    db = tmp_path / "clew.db"
    args = argparse.Namespace(entry_patterns=None)
    _stamp(db, _entry_patterns(args, {SECTION_ENTRY_PATTERNS: ["%trampoline%"]}))
    assert _recorded_entry_patterns(args, db) is None

Activity · 4 steps
lines 479–479db = tmp_path / "clew.db"lines 480–480args = argparse.Namespace(entry_patterns=None)lines 481–481_stamp(db, _entry_patterns(args, {SECTION_ENTRY_PATTERNS: ["%trampoline%"]}))lines 482–482assert _recorded_entry_patterns(args, db) is None

test_a_declared_alias_prefix_does_not_drop_the_ingot_default

None test_tiers.test_a_declared_alias_prefix_does_not_drop_the_ingot_default()

THE BUG, watched failing before the change: `tuple(declared) or DEFAULTS` meant declaring `APP_KEY_` resolved to `('APP_KEY_',)` and the ingot `DM_KEY_` normalization silently stopped, leaving an orphan write-half.

tests/test_tiers.py:248

Checks

  • assert set(resolved.values) == {"APP_KEY_", *DEFAULT_KEY_ALIAS_PREFIXES}
  • assert resolved.tier == TIER_DECLARED

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-006measuredtest_a_declared_alias_prefix_does_not_drop_the_ingot_default → resolve_key_alias_prefixes
REQ-DDB-SCHEMA-005measuredtest_a_declared_alias_prefix_does_not_drop_the_ingot_default → resolve_key_alias_prefixes
Source · 10 lines
def test_a_declared_alias_prefix_does_not_drop_the_ingot_default() -> None:
    """THE BUG, watched failing before the change: `tuple(declared) or DEFAULTS`
    meant declaring `APP_KEY_` resolved to `('APP_KEY_',)` and the ingot `DM_KEY_`
    normalization silently stopped, leaving an orphan write-half.
    """
    resolved = resolve_key_alias_prefixes({KEY_ALIAS_FIELD: ["APP_KEY_"]})
    assert set(resolved.values) == {"APP_KEY_", *DEFAULT_KEY_ALIAS_PREFIXES}
    assert resolved.tier == TIER_DECLARED

Activity · 3 steps
lines 253–253resolved = resolve_key_alias_prefixes({KEY_ALIAS_FIELD: ["APP_KEY_"]})lines 254–254assert set(resolved.values) == {"APP_KEY_", *DEFAULT_KEY_ALIAS_PREFIXES}lines 255–255assert resolved.tier == TIER_DECLARED

test_a_declared_manifest_is_not_replayed_from_the_record

None test_tiers.test_a_declared_manifest_is_not_replayed_from_the_record(Path tmp_path)

A tier-2 declaration re-derives from a file that may have changed since, so no statement is recorded for it and a later build re-reads the declaration rather than a frozen copy.

tests/test_tiers.py:705

Show on the map →

Called by none

Calls _options_meta_section, _stamp_manifest, recorded_document, resolve_document

Checks

  • assert resolution.tier == TIER_DECLARED
  • assert f"{SECTION_SHARED_KEY}.{EXPLICIT_KEY}" not in section
  • assert recorded_document(section, SECTION_SHARED_KEY) is None

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-006measuredtest_a_declared_manifest_is_not_replayed_from_the_record → resolve_document
REQ-DDB-CONFIG-007measuredtest_a_declared_manifest_is_not_replayed_from_the_record → _stamp_manifest → write_build_signature
REQ-DDB-MCP-001measuredtest_a_declared_manifest_is_not_replayed_from_the_record → _options_meta_section → _options_meta → _meta_section
REQ-DDB-PIPE-005measuredtest_a_declared_manifest_is_not_replayed_from_the_record → _stamp_manifest → write_build_signature
Source · 15 lines
def test_a_declared_manifest_is_not_replayed_from_the_record(tmp_path: Path) -> None:
    """A tier-2 declaration re-derives from a file that may have changed since, so no
    statement is recorded for it and a later build re-reads the declaration rather
    than a frozen copy.
    """
    db = tmp_path / "clew.db"
    resolution = resolve_document(explicit=None, declared=STATED_MANIFEST)
    assert resolution.tier == TIER_DECLARED
    _stamp_manifest(db, SECTION_SHARED_KEY, resolution)

    section = _options_meta_section(db)
    assert f"{SECTION_SHARED_KEY}.{EXPLICIT_KEY}" not in section
    assert recorded_document(section, SECTION_SHARED_KEY) is None

Activity · 7 steps
lines 710–710db = tmp_path / "clew.db"lines 711–711resolution = resolve_document(explicit=None, declared=STATED_MANIFEST)lines 712–712assert resolution.tier == TIER_DECLAREDlines 713–713_stamp_manifest(db, SECTION_SHARED_KEY, resolution)lines 715–715section = _options_meta_section(db)lines 716–716assert f"{SECTION_SHARED_KEY}.{EXPLICIT_KEY}" not in sectionlines 717–717assert recorded_document(section, SECTION_SHARED_KEY) is None

test_a_declared_vocabulary_replaces_the_guesses_and_keeps_the_facts

None test_tiers.test_a_declared_vocabulary_replaces_the_guesses_and_keeps_the_facts()

Also watched failing before the change, in the other direction: the declaration used to EXTEND the whole default set, so `%init%` survived.

tests/test_tiers.py:179

Show on the map →

Called by none

Calls _entry_patterns

Checks

  • assert resolved.values == ("main", "app_main", "%trampoline%", "dispatch_%")
  • assert resolved.tier == TIER_DECLARED

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-001measuredtest_a_declared_vocabulary_replaces_the_guesses_and_keeps_the_facts → _entry_patterns → string_list
REQ-DDB-CONFIG-006measuredtest_a_declared_vocabulary_replaces_the_guesses_and_keeps_the_facts → _entry_patterns → resolve_layered
Source · 10 lines
def test_a_declared_vocabulary_replaces_the_guesses_and_keeps_the_facts() -> None:
    """Also watched failing before the change, in the other direction: the
    declaration used to EXTEND the whole default set, so `%init%` survived.
    """
    args = argparse.Namespace(entry_patterns=None)
    resolved = _entry_patterns(args, {SECTION_ENTRY_PATTERNS: ["%trampoline%", "dispatch_%"]})
    assert resolved.values == ("main", "app_main", "%trampoline%", "dispatch_%")
    assert resolved.tier == TIER_DECLARED

Activity · 4 steps
lines 183–183args = argparse.Namespace(entry_patterns=None)lines 184–184resolved = _entry_patterns(args, {SECTION_ENTRY_PATTERNS: ["%trampoline%", "dispatch_%"]})lines 185–185assert resolved.values == ("main", "app_main", "%trampoline%", "dispatch_%")lines 186–186assert resolved.tier == TIER_DECLARED

test_a_manifest_statement_survives_a_later_build_that_states_nothing

None test_tiers.test_a_manifest_statement_survives_a_later_build_that_states_nothing(Path tmp_path)

THE DEFECT, at the unit level. gh#360 made a manifest statable inline and did not persist it, so the next build resolved the manifest from the target's own declaration and the stated layer vanished with the build reporting success — measured on this repo's self-index as a 1.7 s pass that reverted to the undeclared policy. gh#332 shipped the same hole for the path form.

tests/test_tiers.py:593

Show on the map →

Called by none

Calls _manifest_namespace, _replay_manifest_statements, _stamp_manifest, resolve_document

Checks

  • assert _replay_manifest_statements(args, db) == [SECTION_SHARED_KEY]
  • assert args.shared_key_patterns == STATED_MANIFEST
  • assert args.locks is None
  • assert args.thread_patterns is None

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-006measuredtest_a_manifest_statement_survives_a_later_build_that_states_nothing → resolve_document
REQ-DDB-CONFIG-007measuredtest_a_manifest_statement_survives_a_later_build_that_states_nothing → _stamp_manifest → write_build_signature
REQ-DDB-MCP-001measuredtest_a_manifest_statement_survives_a_later_build_that_states_nothing → _replay_manifest_statements → meta_section
REQ-DDB-PIPE-005measuredtest_a_manifest_statement_survives_a_later_build_that_states_nothing → _stamp_manifest → write_build_signature
Source · 27 lines
def test_a_manifest_statement_survives_a_later_build_that_states_nothing(
    tmp_path: Path,
) -> None:
    """THE DEFECT, at the unit level. gh#360 made a manifest statable inline and did
    not persist it, so the next build resolved the manifest from the target's own
    declaration and the stated layer vanished with the build reporting success —
    measured on this repo's self-index as a 1.7 s pass that reverted to the undeclared
    policy. gh#332 shipped the same hole for the path form.

    The build that discards it is usually the MCP server's, which passes no flags at
    all: `status` reports staleness and the guidance says refresh, so a cell's agent
    that brought the index up loses its own bringup work mid-cell and is never told.
    """
    db = tmp_path / "clew.db"
    _stamp_manifest(
        db, SECTION_SHARED_KEY, resolve_document(explicit=STATED_MANIFEST, declared=None)
    )

    args = _manifest_namespace()
    assert _replay_manifest_statements(args, db) == [SECTION_SHARED_KEY]
    assert args.shared_key_patterns == STATED_MANIFEST
    ## The other four are untouched — a replay must not invent a statement for an
    ## option nobody stated.
    assert args.locks is None
    assert args.thread_patterns is None

Activity · 7 steps
lines 606–606db = tmp_path / "clew.db"lines 607–609_stamp_manifest( db, SECTION_SHARED_KEY, resolve_document(explicit=STATED_MANIFEST, declared=None) )lines 611–611args = _manifest_namespace()lines 612–612assert _replay_manifest_statements(args, db) == [SECTION_SHARED_KEY]lines 613–613assert args.shared_key_patterns == STATED_MANIFESTlines 616–616assert args.locks is Nonelines 617–617assert args.thread_patterns is None

test_a_manifest_that_states_no_prefixes_does_not_claim_the_tier

None test_tiers.test_a_manifest_that_states_no_prefixes_does_not_claim_the_tier(Path tmp_path)

A `--shared-key-patterns` file declaring only writers has stated NOTHING about alias prefixes, so recording `tier=explicit` would be a provenance record that is checkable and wrong — the failure `_scope_provenance` calls out.

tests/test_tiers.py:301

Checks

  • assert alone.values == DEFAULT_KEY_ALIAS_PREFIXES
  • assert alone.tier == TIER_HEURISTIC
  • assert beside_a_declaration.tier == TIER_DECLARED, ("the flag stated nothing about prefixes — the DECLARATION did" )
  • assert set(beside_a_declaration.values) == {"DECL_KEY_", *DEFAULT_KEY_ALIAS_PREFIXES}

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-006measuredtest_a_manifest_that_states_no_prefixes_does_not_claim_the_tier → resolve_key_alias_prefixes
REQ-DDB-SCHEMA-005measuredtest_a_manifest_that_states_no_prefixes_does_not_claim_the_tier → resolve_key_alias_prefixes
Source · 28 lines
def test_a_manifest_that_states_no_prefixes_does_not_claim_the_tier(tmp_path: Path) -> None:
    """A `--shared-key-patterns` file declaring only writers has stated NOTHING
    about alias prefixes, so recording `tier=explicit` would be a provenance record
    that is checkable and wrong — the failure `_scope_provenance` calls out.

    THE SECOND CASE IS THE ONE THAT BITES, and the first version of this test did
    not have it. With `extra=None` the two readings are indistinguishable: dropping
    the `bool(contributed)` guard makes `by_flag` true, but the statement is then
    the empty list, which `resolve_layered` treats as a WITHDRAWAL and falls through
    to the same answer. A mutation removing the guard passed. It takes a flag file
    that states nothing ALONGSIDE a declaration that states something to tell them
    apart — and there the wrong reading attributes the DECLARATION's prefixes to the
    flag.
    """
    manifest = tmp_path / "patterns.yaml"
    manifest.write_text("writers:\n  - name_prefix: 'App_Set_'\n", encoding="utf-8")

    alone = resolve_key_alias_prefixes(manifest)
    assert alone.values == DEFAULT_KEY_ALIAS_PREFIXES
    assert alone.tier == TIER_HEURISTIC

    beside_a_declaration = resolve_key_alias_prefixes(manifest, {KEY_ALIAS_FIELD: ["DECL_KEY_"]})
    assert beside_a_declaration.tier == TIER_DECLARED, (
        "the flag stated nothing about prefixes — the DECLARATION did"
    )
    assert set(beside_a_declaration.values) == {"DECL_KEY_", *DEFAULT_KEY_ALIAS_PREFIXES}

Activity · 8 steps
lines 315–315manifest = tmp_path / "patterns.yaml"lines 316–316manifest.write_text("writers:\n - name_prefix: 'App_Set_'\n", encoding="utf-8")lines 318–318alone = resolve_key_alias_prefixes(manifest)lines 319–319assert alone.values == DEFAULT_KEY_ALIAS_PREFIXESlines 320–320assert alone.tier == TIER_HEURISTIClines 322–322beside_a_declaration = resolve_key_alias_prefixes(manifest, {KEY_ALIAS_FIELD: ["DECL_KEY_"]})lines 323–325assert beside_a_declaration.tier == TIER_DECLARED, ( "the flag stated nothing about prefixes — the DECLARATION did" )lines 326–326assert set(beside_a_declaration.values) == {"DECL_KEY_", *DEFAULT_KEY_ALIAS_PREFIXES}

test_a_multi_value_statement_round_trips_through_the_stored_form

None test_tiers.test_a_multi_value_statement_round_trips_through_the_stored_form()

The separator has to survive values containing commas and spaces, which a SQL LIKE pattern legitimately does.

tests/test_tiers.py:401

Checks

  • assert recorded_explicit(options_meta(o=resolution), "o") == tuple(stated)

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-006measuredtest_a_multi_value_statement_round_trips_through_the_stored_form → resolve_layered
Source · 12 lines
def test_a_multi_value_statement_round_trips_through_the_stored_form() -> None:
    """The separator has to survive values containing commas and spaces, which a
    SQL LIKE pattern legitimately does.
    """
    stated = ["handle,%", "on %", "%weird%"]
    resolution = resolve_layered(facts=FACTS, heuristics=GUESSES, explicit=stated)
    # `options_meta` emits the section as `meta_section` hands it back: the
    # `options.` prefix is added by the writer and stripped by the reader, so what
    # `recorded_explicit` sees is exactly this mapping.
    assert recorded_explicit(options_meta(o=resolution), "o") == tuple(stated)

Activity · 3 steps
lines 405–405stated = ["handle,%", "on %", "%weird%"]lines 406–406resolution = resolve_layered(facts=FACTS, heuristics=GUESSES, explicit=stated)lines 410–410assert recorded_explicit(options_meta(o=resolution), "o") == tuple(stated)

test_a_recorded_statement_can_be_withdrawn

None test_tiers.test_a_recorded_statement_can_be_withdrawn(Path tmp_path)

Three states: absent inherits, EMPTY withdraws, non-empty replaces.

tests/test_tiers.py:460

Show on the map →

Called by none

Calls _entry_patterns, _recorded_entry_patterns, _stamp, list

Checks

  • assert withdrawn == []
  • assert list(_entry_patterns(argparse.Namespace(entry_patterns=withdrawn), {}).values) == (DEFAULT_ENTRY_PATTERNS )
  • assert replaced == ["%other%"]

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-001measuredtest_a_recorded_statement_can_be_withdrawn → _entry_patterns → string_list
REQ-DDB-CONFIG-006measuredtest_a_recorded_statement_can_be_withdrawn → _stamp → write_build_signature
REQ-DDB-CONFIG-007measuredtest_a_recorded_statement_can_be_withdrawn → _stamp → write_build_signature
REQ-DDB-MCP-001inferredtest_a_recorded_statement_can_be_withdrawn → _recorded_entry_patterns → meta_section
REQ-DDB-PIPE-005measuredtest_a_recorded_statement_can_be_withdrawn → _stamp → write_build_signature
Source · 15 lines
def test_a_recorded_statement_can_be_withdrawn(tmp_path: Path) -> None:
    """Three states: absent inherits, EMPTY withdraws, non-empty replaces."""
    db = tmp_path / "clew.db"
    _stamp(db, _entry_patterns(argparse.Namespace(entry_patterns=["%mystyle%"]), {}))

    withdrawn = _recorded_entry_patterns(argparse.Namespace(entry_patterns=[]), db)
    assert withdrawn == []
    assert list(_entry_patterns(argparse.Namespace(entry_patterns=withdrawn), {}).values) == (
        DEFAULT_ENTRY_PATTERNS
    )

    replaced = _recorded_entry_patterns(argparse.Namespace(entry_patterns=["%other%"]), db)
    assert replaced == ["%other%"]

Activity · 7 steps
lines 462–462db = tmp_path / "clew.db"lines 463–463_stamp(db, _entry_patterns(argparse.Namespace(entry_patterns=["%mystyle%"]), {}))lines 465–465withdrawn = _recorded_entry_patterns(argparse.Namespace(entry_patterns=[]), db)lines 466–466assert withdrawn == []lines 467–469assert list(_entry_patterns(argparse.Namespace(entry_patterns=withdrawn), {}).values) == ( DEFAULT_ENTRY_PATTERNS )lines 471–471replaced = _recorded_entry_patterns(argparse.Namespace(entry_patterns=["%other%"]), db)lines 472–472assert replaced == ["%other%"]

test_a_restated_fact_is_not_duplicated

None test_tiers.test_a_restated_fact_is_not_duplicated()

An operator restating `main` gets one seed, not two.

tests/test_tiers.py:142

Checks

  • assert resolved.values == (*FACTS, "%mine%")

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-006measuredtest_a_restated_fact_is_not_duplicated → resolve_layered
Source · 6 lines
def test_a_restated_fact_is_not_duplicated() -> None:
    """An operator restating `main` gets one seed, not two."""
    resolved = resolve_layered(facts=FACTS, heuristics=GUESSES, explicit=["fact_a", "%mine%"])
    assert resolved.values == (*FACTS, "%mine%")

Activity · 2 steps
lines 144–144resolved = resolve_layered(facts=FACTS, heuristics=GUESSES, explicit=["fact_a", "%mine%"])lines 145–145assert resolved.values == (*FACTS, "%mine%")

test_a_silent_target_resolves_to_the_whole_built_in_set

None test_tiers.test_a_silent_target_resolves_to_the_whole_built_in_set()

The success path for the migrated consumer specifically.

tests/test_tiers.py:189

Show on the map →

Called by none

Calls _entry_patterns, list

Checks

  • assert list(resolved.values) == DEFAULT_ENTRY_PATTERNS
  • assert resolved.tier == TIER_HEURISTIC

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-001measuredtest_a_silent_target_resolves_to_the_whole_built_in_set → _entry_patterns → string_list
REQ-DDB-CONFIG-006measuredtest_a_silent_target_resolves_to_the_whole_built_in_set → _entry_patterns → resolve_layered
Source · 9 lines
def test_a_silent_target_resolves_to_the_whole_built_in_set() -> None:
    """The success path for the migrated consumer specifically."""
    resolved = _entry_patterns(argparse.Namespace(entry_patterns=None), {})
    assert list(resolved.values) == DEFAULT_ENTRY_PATTERNS
    assert resolved.tier == TIER_HEURISTIC


# ── the second consumer ─────────────────────────────────────────────────────
Activity · 3 steps
lines 191–191resolved = _entry_patterns(argparse.Namespace(entry_patterns=None), {})lines 192–192assert list(resolved.values) == DEFAULT_ENTRY_PATTERNSlines 193–193assert resolved.tier == TIER_HEURISTIC

test_a_stated_data_model_records_its_tier

None test_tiers.test_a_stated_data_model_records_its_tier()

A stated data_model records its tier like every other stated option.

tests/test_tiers.py:815

Show on the map →

Called by none

Calls _manifest_option_tiers, options_meta

Checks

  • assert "data_model" in stated, ("a stated data_model must reach the options meta like every other stated option" )
  • assert options_meta(**stated)[f"data_model.{TIER_KEY}"] == TIER_EXPLICIT
  • assert options_meta(**declared)[f"data_model.{TIER_KEY}"] == TIER_DECLARED

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-001measured
REQ-DDB-CONFIG-006measuredtest_a_stated_data_model_records_its_tier → options_meta
Source · 41 lines
def test_a_stated_data_model_records_its_tier() -> None:
    """gh#42. `status.options` CARRIED TIER ROWS FOR NINE SECTIONS AND NONE FOR
    `data_model`. The reporter stated it through `options`, watched the build log it as tier 1,
    and then found no record of it anywhere in the index — so a consumer reading an unexpected
    data-model catalog could not tell "this operator stated a manifest" from "this repository
    declares one" from "nobody said anything".

    THE STAMP IS THE OWNER'S CONDITION FOR ALLOWING A REPLAYED STATEMENT AT ALL, as
    `_manifest_option_tiers` records: a statement that survives a rebuild means the index
    carries a policy the repository does not declare, so two operators of one commit can hold
    different indexes. That is acceptable only because it is deliberate AND recorded. An option
    that is replayed and NOT recorded is the defect gh#352 rejected.

    IT WAS MISSED BECAUSE OF WHERE IT SITS IN THE OPTION TAXONOMY, not by an argument that it
    should not be stamped: `_manifest_option_tiers` iterates `MANIFEST_OPTIONS`, and
    `data_model` is a PATH option — the one manifest that is not YAML, named by path rather
    than inlined. The taxonomy is right and the stamping loop was reading only half of it.

    @brief The `data_model` option appears in the options meta with its tier.
    @return None.
    @version 1
    """
    from clew.cli import _manifest_option_tiers
    from clew.tiers import TIER_DECLARED, TIER_EXPLICIT, TIER_KEY

    class _Args:
        """@brief A namespace carrying only the stated option."""

        data_model = "app/data/model.toml"

    stated = _manifest_option_tiers(_Args(), {})
    assert "data_model" in stated, (
        "a stated data_model must reach the options meta like every other stated option"
    )
    assert options_meta(**stated)[f"data_model.{TIER_KEY}"] == TIER_EXPLICIT

    class _Bare:
        """@brief A namespace stating nothing."""

    declared = _manifest_option_tiers(_Bare(), {"data_model": "app/data/model.toml"})
    assert options_meta(**declared)[f"data_model.{TIER_KEY}"] == TIER_DECLARED

1 more lines, not shown

Activity · 9 steps
lines 837–837from clew.cli import _manifest_option_tierslines 838–838from clew.tiers import TIER_DECLARED, TIER_EXPLICIT, TIER_KEYlines 840–843class _Args: """@brief A namespace carrying only the stated option.""" data_model = "app/data/model.toml"lines 845–845stated = _manifest_option_tiers(_Args(), {})lines 846–848assert "data_model" in stated, ( "a stated data_model must reach the options meta like every other stated option" )lines 849–849assert options_meta(**stated)[f"data_model.{TIER_KEY}"] == TIER_EXPLICITlines 851–852class _Bare: """@brief A namespace stating nothing."""lines 854–854declared = _manifest_option_tiers(_Bare(), {"data_model": "app/data/model.toml"})lines 855–855assert options_meta(**declared)[f"data_model.{TIER_KEY}"] == TIER_DECLARED

test_a_stated_path_replays_as_a_path

None test_tiers.test_a_stated_path_replays_as_a_path(Path tmp_path)

BOTH INPUT FORMS ARE PERSISTED, because both had the hole (gh#332 shipped the path form). JSON tells them apart with no second key: a path is a string, a document is an object, so the reader cannot get the form wrong.

tests/test_tiers.py:620

Show on the map →

Called by none

Calls _manifest_namespace, _replay_manifest_statements, _stamp_manifest, resolve_document

Checks

  • assert _replay_manifest_statements(args, db) == [SECTION_LOCKS]
  • assert args.locks == stated

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-006measuredtest_a_stated_path_replays_as_a_path → resolve_document
REQ-DDB-CONFIG-007measuredtest_a_stated_path_replays_as_a_path → _stamp_manifest → write_build_signature
REQ-DDB-MCP-001measuredtest_a_stated_path_replays_as_a_path → _replay_manifest_statements → meta_section
REQ-DDB-PIPE-005measuredtest_a_stated_path_replays_as_a_path → _stamp_manifest → write_build_signature
Source · 14 lines
def test_a_stated_path_replays_as_a_path(tmp_path: Path) -> None:
    """BOTH INPUT FORMS ARE PERSISTED, because both had the hole (gh#332 shipped the
    path form). JSON tells them apart with no second key: a path is a string, a
    document is an object, so the reader cannot get the form wrong.
    """
    db = tmp_path / "clew.db"
    stated = str(tmp_path / "locks.yaml")
    _stamp_manifest(db, SECTION_LOCKS, resolve_document(explicit=stated))

    args = _manifest_namespace()
    assert _replay_manifest_statements(args, db) == [SECTION_LOCKS]
    assert args.locks == stated

Activity · 6 steps
lines 625–625db = tmp_path / "clew.db"lines 626–626stated = str(tmp_path / "locks.yaml")lines 627–627_stamp_manifest(db, SECTION_LOCKS, resolve_document(explicit=stated))lines 629–629args = _manifest_namespace()lines 630–630assert _replay_manifest_statements(args, db) == [SECTION_LOCKS]lines 631–631assert args.locks == stated

test_a_statement_made_on_this_call_is_not_overwritten_by_the_record

None test_tiers.test_a_statement_made_on_this_call_is_not_overwritten_by_the_record(Path tmp_path)

The three states, and this is the REPLACE one: what an operator says now wins over what they said before.

tests/test_tiers.py:634

Show on the map →

Called by none

Calls _manifest_namespace, _replay_manifest_statements, _stamp_manifest, resolve_document

Checks

  • assert _replay_manifest_statements(args, db) == []
  • assert args.shared_key_patterns == {"writers": [{"pattern": "Now_Set"}]}

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-006measuredtest_a_statement_made_on_this_call_is_not_overwritten_by_the_record → resolve_document
REQ-DDB-CONFIG-007measuredtest_a_statement_made_on_this_call_is_not_overwritten_by_the_record → _stamp_manifest → write_build_signature
REQ-DDB-MCP-001measuredtest_a_statement_made_on_this_call_is_not_overwritten_by_the_record → _replay_manifest_statements → meta_section
REQ-DDB-PIPE-005measuredtest_a_statement_made_on_this_call_is_not_overwritten_by_the_record → _stamp_manifest → write_build_signature
Source · 14 lines
def test_a_statement_made_on_this_call_is_not_overwritten_by_the_record(
    tmp_path: Path,
) -> None:
    """The three states, and this is the REPLACE one: what an operator says now wins
    over what they said before.
    """
    db = tmp_path / "clew.db"
    _stamp_manifest(db, SECTION_SHARED_KEY, resolve_document(explicit=STATED_MANIFEST))

    args = _manifest_namespace(shared_key_patterns={"writers": [{"pattern": "Now_Set"}]})
    assert _replay_manifest_statements(args, db) == []
    assert args.shared_key_patterns == {"writers": [{"pattern": "Now_Set"}]}

Activity · 5 steps
lines 640–640db = tmp_path / "clew.db"lines 641–641_stamp_manifest(db, SECTION_SHARED_KEY, resolve_document(explicit=STATED_MANIFEST))lines 643–643args = _manifest_namespace(shared_key_patterns={"writers": [{"pattern": "Now_Set"}]})lines 644–644assert _replay_manifest_statements(args, db) == []lines 645–645assert args.shared_key_patterns == {"writers": [{"pattern": "Now_Set"}]}

test_a_target_declaring_no_alias_prefixes_gets_the_ingot_defaults

None test_tiers.test_a_target_declaring_no_alias_prefixes_gets_the_ingot_defaults()

THE SUCCESS PATH. The equivalent of the entry-pattern control that catches the inverse failure — a rule that protects the defaults by dropping everything else, or one that resolves to nothing at all when no declaration exists.

tests/test_tiers.py:258

Checks

  • assert resolved.values == DEFAULT_KEY_ALIAS_PREFIXES
  • assert resolved.tier == TIER_HEURISTIC
  • assert resolved.stated == ()

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-006measuredtest_a_target_declaring_no_alias_prefixes_gets_the_ingot_defaults → resolve_key_alias_prefixes
REQ-DDB-SCHEMA-005measuredtest_a_target_declaring_no_alias_prefixes_gets_the_ingot_defaults → resolve_key_alias_prefixes
Source · 15 lines
def test_a_target_declaring_no_alias_prefixes_gets_the_ingot_defaults() -> None:
    """THE SUCCESS PATH. The equivalent of the entry-pattern control that catches
    the inverse failure — a rule that protects the defaults by dropping everything
    else, or one that resolves to nothing at all when no declaration exists.

    The tier reads `heuristic` because nothing was stated and this option has an
    EMPTY tier-5 layer; for `key_alias_prefixes` that label means "defaults only",
    not "a guess was used".
    """
    resolved = resolve_key_alias_prefixes(None)
    assert resolved.values == DEFAULT_KEY_ALIAS_PREFIXES
    assert resolved.tier == TIER_HEURISTIC
    assert resolved.stated == ()

Activity · 4 steps
lines 267–267resolved = resolve_key_alias_prefixes(None)lines 268–268assert resolved.values == DEFAULT_KEY_ALIAS_PREFIXESlines 269–269assert resolved.tier == TIER_HEURISTIClines 270–270assert resolved.stated == ()

test_a_target_stating_nothing_gets_facts_and_guesses_together

None test_tiers.test_a_target_stating_nothing_gets_facts_and_guesses_together()

THE SUCCESS PATH, and it is here deliberately.

tests/test_tiers.py:83

Checks

  • assert resolved.values == (*FACTS, *ECOSYSTEM, *GUESSES)
  • assert resolved.tier == TIER_HEURISTIC
  • assert resolved.stated == GUESSES

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-006measuredtest_a_target_stating_nothing_gets_facts_and_guesses_together → resolve_layered
Source · 14 lines
def test_a_target_stating_nothing_gets_facts_and_guesses_together() -> None:
    """THE SUCCESS PATH, and it is here deliberately.

    A check with a test for its failure path and none for its success path shipped
    a completely broken install path in this repo while the suite stayed green. The
    interesting failure of a rule that protects facts from being dropped is that it
    drops the guesses instead, and only this asserts otherwise.
    """
    resolved = resolve_layered(facts=FACTS, ecosystem=ECOSYSTEM, heuristics=GUESSES)
    assert resolved.values == (*FACTS, *ECOSYSTEM, *GUESSES)
    assert resolved.tier == TIER_HEURISTIC
    assert resolved.stated == GUESSES

Activity · 4 steps
lines 91–91resolved = resolve_layered(facts=FACTS, ecosystem=ECOSYSTEM, heuristics=GUESSES)lines 92–92assert resolved.values == (*FACTS, *ECOSYSTEM, *GUESSES)lines 93–93assert resolved.tier == TIER_HEURISTIClines 94–94assert resolved.stated == GUESSES

test_a_withdrawn_manifest_statement_is_not_replayed_from_a_stale_row

None test_tiers.test_a_withdrawn_manifest_statement_is_not_replayed_from_a_stale_row(Path tmp_path)

THE TIER CROSS-CHECK, CONFIRMED FOR THE DOCUMENT FORM RATHER THAN ASSUMED.

tests/test_tiers.py:680

Show on the map →

Called by none

Calls _manifest_namespace, _options_meta_section, _replay_manifest_statements, _stamp_manifest, canonical_document, recorded_document, resolve_document

Checks

  • assert section[f"{SECTION_SHARED_KEY}.{EXPLICIT_KEY}"] == canonical_document(STATED_MANIFEST), ("the stale row must still be present — otherwise this test proves nothing" )
  • assert section[f"{SECTION_SHARED_KEY}.{TIER_KEY}"] == TIER_HEURISTIC
  • assert recorded_document(section, SECTION_SHARED_KEY) is None
  • assert _replay_manifest_statements(_manifest_namespace(), db) == []

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-006measuredtest_a_withdrawn_manifest_statement_is_not_replayed_from_a_stale_row → canonical_document
REQ-DDB-CONFIG-007measuredtest_a_withdrawn_manifest_statement_is_not_replayed_from_a_stale_row → _stamp_manifest → write_build_signature
REQ-DDB-MCP-001measuredtest_a_withdrawn_manifest_statement_is_not_replayed_from_a_stale_row → _replay_manifest_statements → meta_section
REQ-DDB-PIPE-005measuredtest_a_withdrawn_manifest_statement_is_not_replayed_from_a_stale_row → _stamp_manifest → write_build_signature
Source · 25 lines
def test_a_withdrawn_manifest_statement_is_not_replayed_from_a_stale_row(
    tmp_path: Path,
) -> None:
    """THE TIER CROSS-CHECK, CONFIRMED FOR THE DOCUMENT FORM RATHER THAN ASSUMED.

    The guard lives in the READER, so a second reader that skipped it would replay a
    withdrawn statement while `recorded_explicit` refused to — and the task asked for
    this to be confirmed, not inherited. `write_build_signature` upserts and never
    deletes, so stamping a withdrawal onto a database that already carries a statement
    leaves the retracted `<option>.explicit` row beside a fresh
    `<option>.tier = heuristic`.
    """
    db = tmp_path / "clew.db"
    _stamp_manifest(db, SECTION_SHARED_KEY, resolve_document(explicit=STATED_MANIFEST))
    _stamp_manifest(db, SECTION_SHARED_KEY, resolve_document())

    section = _options_meta_section(db)
    assert section[f"{SECTION_SHARED_KEY}.{EXPLICIT_KEY}"] == canonical_document(STATED_MANIFEST), (
        "the stale row must still be present — otherwise this test proves nothing"
    )
    assert section[f"{SECTION_SHARED_KEY}.{TIER_KEY}"] == TIER_HEURISTIC
    assert recorded_document(section, SECTION_SHARED_KEY) is None
    assert _replay_manifest_statements(_manifest_namespace(), db) == []

Activity · 8 steps
lines 692–692db = tmp_path / "clew.db"lines 693–693_stamp_manifest(db, SECTION_SHARED_KEY, resolve_document(explicit=STATED_MANIFEST))lines 694–694_stamp_manifest(db, SECTION_SHARED_KEY, resolve_document())lines 696–696section = _options_meta_section(db)lines 697–699assert section[f"{SECTION_SHARED_KEY}.{EXPLICIT_KEY}"] == canonical_document(STATED_MANIFEST), ( "the stale row must still be present — otherwise this test proves nothing" )lines 700–700assert section[f"{SECTION_SHARED_KEY}.{TIER_KEY}"] == TIER_HEURISTIClines 701–701assert recorded_document(section, SECTION_SHARED_KEY) is Nonelines 702–702assert _replay_manifest_statements(_manifest_namespace(), db) == []

test_a_withdrawn_statement_is_not_replayed_from_a_stale_row

None test_tiers.test_a_withdrawn_statement_is_not_replayed_from_a_stale_row(Path tmp_path)

FOUND BY WRITING THE CONTROL IN THE AWKWARD DIRECTION.

tests/test_tiers.py:512

Show on the map →

Called by none

Calls _entry_patterns, _options_meta_section, _recorded_entry_patterns, _stamp, recorded_explicit

Checks

  • assert section[f"{OPTION_ENTRY_PATTERNS}.{EXPLICIT_KEY}"] == "%mine%", ("the stale row must still be present — otherwise this test proves nothing" )
  • assert section[f"{OPTION_ENTRY_PATTERNS}.{TIER_KEY}"] == TIER_HEURISTIC
  • assert recorded_explicit(section, OPTION_ENTRY_PATTERNS) == ()
  • assert _recorded_entry_patterns(argparse.Namespace(entry_patterns=None), db) is None

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-001measuredtest_a_withdrawn_statement_is_not_replayed_from_a_stale_row → _entry_patterns → string_list
REQ-DDB-CONFIG-006measuredtest_a_withdrawn_statement_is_not_replayed_from_a_stale_row → recorded_explicit
REQ-DDB-CONFIG-007measuredtest_a_withdrawn_statement_is_not_replayed_from_a_stale_row → _stamp → write_build_signature
REQ-DDB-MCP-001measuredtest_a_withdrawn_statement_is_not_replayed_from_a_stale_row → _recorded_entry_patterns → meta_section
REQ-DDB-PIPE-005measuredtest_a_withdrawn_statement_is_not_replayed_from_a_stale_row → _stamp → write_build_signature
Source · 30 lines
def test_a_withdrawn_statement_is_not_replayed_from_a_stale_row(tmp_path: Path) -> None:
    """FOUND BY WRITING THE CONTROL IN THE AWKWARD DIRECTION.

    `write_build_signature` upserts and never deletes, so stamping a withdrawal
    onto a database that already carries a statement leaves the retracted
    `<option>.explicit` row beside a fresh `<option>.tier = heuristic`. The first
    version of `recorded_explicit` read the statement key alone and replayed it —
    turning a retraction into a silent re-application.

    The real pipeline does not reach this (every build stamps a fresh temp database
    that then replaces the live one), which is exactly why it needs a test: the
    safety lives in a DIFFERENT module, and `_stamp_refresh_metrics` already stamps
    onto the live database for another section. The tier row is written on every
    stamp, so it is authoritative and a disagreeing statement replays nothing.
    """
    db = tmp_path / "clew.db"
    _stamp(db, _entry_patterns(argparse.Namespace(entry_patterns=["%mine%"]), {}))
    _stamp(db, _entry_patterns(argparse.Namespace(entry_patterns=None), {}))

    section = _options_meta_section(db)
    assert section[f"{OPTION_ENTRY_PATTERNS}.{EXPLICIT_KEY}"] == "%mine%", (
        "the stale row must still be present — otherwise this test proves nothing"
    )
    assert section[f"{OPTION_ENTRY_PATTERNS}.{TIER_KEY}"] == TIER_HEURISTIC
    assert recorded_explicit(section, OPTION_ENTRY_PATTERNS) == ()
    assert _recorded_entry_patterns(argparse.Namespace(entry_patterns=None), db) is None


# ── manifest statements: recorded, replayed, withdrawn (gh#364) ──────────────
Activity · 8 steps
lines 527–527db = tmp_path / "clew.db"lines 528–528_stamp(db, _entry_patterns(argparse.Namespace(entry_patterns=["%mine%"]), {}))lines 529–529_stamp(db, _entry_patterns(argparse.Namespace(entry_patterns=None), {}))lines 531–531section = _options_meta_section(db)lines 532–534assert section[f"{OPTION_ENTRY_PATTERNS}.{EXPLICIT_KEY}"] == "%mine%", ( "the stale row must still be present — otherwise this test proves nothing" )lines 535–535assert section[f"{OPTION_ENTRY_PATTERNS}.{TIER_KEY}"] == TIER_HEURISTIClines 536–536assert recorded_explicit(section, OPTION_ENTRY_PATTERNS) == ()lines 537–537assert _recorded_entry_patterns(argparse.Namespace(entry_patterns=None), db) is None

test_alias_prefixes_accumulate_exactly_as_their_siblings_do

None test_tiers.test_alias_prefixes_accumulate_exactly_as_their_siblings_do()

The inconsistency the migration closes, asserted against the control arm: the writers from the SAME generator already accumulated while the prefixes replaced.

tests/test_tiers.py:273

Checks

  • assert {"App_Set_", "DataModel_Set_"} <= surviving, "writers accumulate — control arm"
  • assert set(prefixes) == {"APP_KEY_", *DEFAULT_KEY_ALIAS_PREFIXES}

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-006measuredtest_alias_prefixes_accumulate_exactly_as_their_siblings_do → resolve_shared_key_patterns
REQ-DDB-SCHEMA-005measuredtest_alias_prefixes_accumulate_exactly_as_their_siblings_do → resolve_shared_key_patterns
REQ-DDB-SCHEMA-012measuredtest_alias_prefixes_accumulate_exactly_as_their_siblings_do → resolve_shared_key_patterns → load_shared_key_patterns → declaration_origin
Source · 13 lines
def test_alias_prefixes_accumulate_exactly_as_their_siblings_do() -> None:
    """The inconsistency the migration closes, asserted against the control arm:
    the writers from the SAME generator already accumulated while the prefixes
    replaced.
    """
    writers, _readers, prefixes = resolve_shared_key_patterns(
        {KEY_ALIAS_FIELD: ["APP_KEY_"], "writers": [{"name_prefix": "App_Set_"}]}
    )
    surviving = {getattr(w, "prefix", None) for w in writers}
    assert {"App_Set_", "DataModel_Set_"} <= surviving, "writers accumulate — control arm"
    assert set(prefixes) == {"APP_KEY_", *DEFAULT_KEY_ALIAS_PREFIXES}

Activity · 4 steps
lines 278–280writers, _readers, prefixes = resolve_shared_key_patterns( {KEY_ALIAS_FIELD: ["APP_KEY_"], "writers": [{"name_prefix": "App_Set_"}]} )lines 281–281surviving = {getattr(w, "prefix", None) for w in writers}lines 282–282assert {"App_Set_", "DataModel_Set_"} <= surviving, "writers accumulate — control arm"lines 283–283assert set(prefixes) == {"APP_KEY_", *DEFAULT_KEY_ALIAS_PREFIXES}

test_an_empty_document_withdraws_the_record_rather_than_ignoring_it

None test_tiers.test_an_empty_document_withdraws_the_record_rather_than_ignoring_it(Path tmp_path)

`{}` DOES BOTH JOBS WITH ONE SPELLING (owner decision, gh#364): it stops overriding this run AND removes the record, because those are one intent.

tests/test_tiers.py:648

Show on the map →

Called by none

Calls _manifest_namespace, _manifest_option_tiers, _options_meta_section, _replay_manifest_statements, _stamp_manifest, recorded_document, resolve_document

Checks

  • assert _replay_manifest_statements(args, db) == [], "an empty document states nothing"
  • assert args.shared_key_patterns == {}
  • assert withdrawn.tier == TIER_HEURISTIC
  • assert withdrawn.as_meta(SECTION_SHARED_KEY) == {
  • assert recorded_document(_options_meta_section(fresh), SECTION_SHARED_KEY) is None
  • assert _replay_manifest_statements(_manifest_namespace(), fresh) == []

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-001measured
REQ-DDB-CONFIG-006measuredtest_an_empty_document_withdraws_the_record_rather_than_ignoring_it → resolve_document
REQ-DDB-CONFIG-007measuredtest_an_empty_document_withdraws_the_record_rather_than_ignoring_it → _stamp_manifest → write_build_signature
REQ-DDB-MCP-001measuredtest_an_empty_document_withdraws_the_record_rather_than_ignoring_it → _replay_manifest_statements → meta_section
REQ-DDB-PIPE-005measuredtest_an_empty_document_withdraws_the_record_rather_than_ignoring_it → _stamp_manifest → write_build_signature
Source · 32 lines
def test_an_empty_document_withdraws_the_record_rather_than_ignoring_it(
    tmp_path: Path,
) -> None:
    """`{}` DOES BOTH JOBS WITH ONE SPELLING (owner decision, gh#364): it stops
    overriding this run AND removes the record, because those are one intent.

    THE ASSERTION THAT MATTERS IS THAT THE RECORD IS GONE, not that this run ignored
    it. A withdrawal that silently fails to withdraw is the `key_arg_idx`-for
    -`key_arg_index` class of defect — a valid mapping no consumer reads — so this
    checks the row a NEXT build would read, not the absence of an error.
    """
    db = tmp_path / "clew.db"
    _stamp_manifest(db, SECTION_SHARED_KEY, resolve_document(explicit=STATED_MANIFEST))

    args = _manifest_namespace(shared_key_patterns={})
    assert _replay_manifest_statements(args, db) == [], "an empty document states nothing"
    assert args.shared_key_patterns == {}

    ## What THIS build would stamp for the withdrawn option: a tier, and no statement.
    ## Every build writes a fresh `build_meta` into the temp database that replaces the
    ## live one, so an absent statement here IS the record being gone.
    withdrawn = _manifest_option_tiers(args, {})[SECTION_SHARED_KEY]
    assert withdrawn.tier == TIER_HEURISTIC
    assert withdrawn.as_meta(SECTION_SHARED_KEY) == {
        f"{SECTION_SHARED_KEY}.{TIER_KEY}": TIER_HEURISTIC
    }
    fresh = tmp_path / "next.db"
    _stamp_manifest(fresh, SECTION_SHARED_KEY, withdrawn)
    assert recorded_document(_options_meta_section(fresh), SECTION_SHARED_KEY) is None
    assert _replay_manifest_statements(_manifest_namespace(), fresh) == []

Activity · 12 steps
lines 659–659db = tmp_path / "clew.db"lines 660–660_stamp_manifest(db, SECTION_SHARED_KEY, resolve_document(explicit=STATED_MANIFEST))lines 662–662args = _manifest_namespace(shared_key_patterns={})lines 663–663assert _replay_manifest_statements(args, db) == [], "an empty document states nothing"lines 664–664assert args.shared_key_patterns == {}lines 669–669withdrawn = _manifest_option_tiers(args, {})[SECTION_SHARED_KEY]lines 670–670assert withdrawn.tier == TIER_HEURISTIClines 671–673assert withdrawn.as_meta(SECTION_SHARED_KEY) == { f"{SECTION_SHARED_KEY}.{TIER_KEY}": TIER_HEURISTIC }lines 674–674fresh = tmp_path / "next.db"lines 675–675_stamp_manifest(fresh, SECTION_SHARED_KEY, withdrawn)lines 676–676assert recorded_document(_options_meta_section(fresh), SECTION_SHARED_KEY) is Nonelines 677–677assert _replay_manifest_statements(_manifest_namespace(), fresh) == []

test_an_empty_explicit_list_withdraws_rather_than_states

None test_tiers.test_an_empty_explicit_list_withdraws_rather_than_states()

`--entry-patterns` with no values falls back, it does not resolve to nothing.

tests/test_tiers.py:126

Checks

  • assert resolved.tier == TIER_DECLARED
  • assert resolved.values == (*FACTS, "%theirs%")
  • assert bare.tier == TIER_HEURISTIC
  • assert bare.values == (*FACTS, *GUESSES)

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-006measuredtest_an_empty_explicit_list_withdraws_rather_than_states → resolve_layered
Source · 16 lines
def test_an_empty_explicit_list_withdraws_rather_than_states() -> None:
    """`--entry-patterns` with no values falls back, it does not resolve to nothing.

    Collapsing this into "states an empty set" would make a recorded statement
    unwithdrawable except by deleting the database, and would seed reachability
    from the facts alone.
    """
    resolved = resolve_layered(facts=FACTS, heuristics=GUESSES, declared=["%theirs%"], explicit=[])
    assert resolved.tier == TIER_DECLARED
    assert resolved.values == (*FACTS, "%theirs%")

    bare = resolve_layered(facts=FACTS, heuristics=GUESSES, explicit=[])
    assert bare.tier == TIER_HEURISTIC
    assert bare.values == (*FACTS, *GUESSES)

Activity · 6 steps
lines 133–133resolved = resolve_layered(facts=FACTS, heuristics=GUESSES, declared=["%theirs%"], explicit=[])lines 134–134assert resolved.tier == TIER_DECLAREDlines 135–135assert resolved.values == (*FACTS, "%theirs%")lines 137–137bare = resolve_layered(facts=FACTS, heuristics=GUESSES, explicit=[])lines 138–138assert bare.tier == TIER_HEURISTIClines 139–139assert bare.values == (*FACTS, *GUESSES)

test_an_explicit_flag_no_longer_drops_the_language_entry_point

None test_tiers.test_an_explicit_flag_no_longer_drops_the_language_entry_point()

THE BUG. Watched failing before the change: `--entry-patterns %mystyle%` resolved to `['%mystyle%']`, so `main` and `app_main` were not seeds, liveness collapsed, and nothing in the build or the index said so.

tests/test_tiers.py:165

Show on the map →

Called by none

Calls _entry_patterns

Checks

  • assert "main" in resolved.values
  • assert "app_main" in resolved.values
  • assert "%mystyle%" in resolved.values
  • assert "%init%" not in resolved.values
  • assert resolved.tier == TIER_EXPLICIT

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-001measuredtest_an_explicit_flag_no_longer_drops_the_language_entry_point → _entry_patterns → string_list
REQ-DDB-CONFIG-006measuredtest_an_explicit_flag_no_longer_drops_the_language_entry_point → _entry_patterns → resolve_layered
Source · 14 lines
def test_an_explicit_flag_no_longer_drops_the_language_entry_point() -> None:
    """THE BUG. Watched failing before the change: `--entry-patterns %mystyle%`
    resolved to `['%mystyle%']`, so `main` and `app_main` were not seeds, liveness
    collapsed, and nothing in the build or the index said so.
    """
    args = argparse.Namespace(entry_patterns=["%mystyle%"])
    resolved = _entry_patterns(args, {})
    assert "main" in resolved.values
    assert "app_main" in resolved.values
    assert "%mystyle%" in resolved.values
    assert "%init%" not in resolved.values
    assert resolved.tier == TIER_EXPLICIT

Activity · 7 steps
lines 170–170args = argparse.Namespace(entry_patterns=["%mystyle%"])lines 171–171resolved = _entry_patterns(args, {})lines 172–172assert "main" in resolved.valueslines 173–173assert "app_main" in resolved.valueslines 174–174assert "%mystyle%" in resolved.valueslines 175–175assert "%init%" not in resolved.valueslines 176–176assert resolved.tier == TIER_EXPLICIT

test_an_explicit_manifest_file_outranks_a_declared_section

None test_tiers.test_an_explicit_manifest_file_outranks_a_declared_section(Path tmp_path)

Tier 1 beats tier 2, and the split is read from the SOURCE TYPE — `cli._declared_or_flag` hands back a Path for `--shared-key-patterns` and the parsed mapping for a declaration, so no second argument has to be kept in sync.

tests/test_tiers.py:286

Checks

  • assert resolved.tier == TIER_EXPLICIT
  • assert set(resolved.values) == {"FLAG_KEY_", "DECL_KEY_", *DEFAULT_KEY_ALIAS_PREFIXES}, ("tier 1 wins the TIER, but tier 2 is still a stated layer contributing values" )

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-006measuredtest_an_explicit_manifest_file_outranks_a_declared_section → resolve_key_alias_prefixes
REQ-DDB-SCHEMA-005measuredtest_an_explicit_manifest_file_outranks_a_declared_section → resolve_key_alias_prefixes
Source · 15 lines
def test_an_explicit_manifest_file_outranks_a_declared_section(tmp_path: Path) -> None:
    """Tier 1 beats tier 2, and the split is read from the SOURCE TYPE —
    `cli._declared_or_flag` hands back a Path for `--shared-key-patterns` and the
    parsed mapping for a declaration, so no second argument has to be kept in sync.
    """
    manifest = tmp_path / "patterns.yaml"
    manifest.write_text(f"{KEY_ALIAS_FIELD}: ['FLAG_KEY_']\n", encoding="utf-8")

    resolved = resolve_key_alias_prefixes(manifest, {KEY_ALIAS_FIELD: ["DECL_KEY_"]})
    assert resolved.tier == TIER_EXPLICIT
    assert set(resolved.values) == {"FLAG_KEY_", "DECL_KEY_", *DEFAULT_KEY_ALIAS_PREFIXES}, (
        "tier 1 wins the TIER, but tier 2 is still a stated layer contributing values"
    )

Activity · 5 steps
lines 291–291manifest = tmp_path / "patterns.yaml"lines 292–292manifest.write_text(f"{KEY_ALIAS_FIELD}: ['FLAG_KEY_']\n", encoding="utf-8")lines 294–294resolved = resolve_key_alias_prefixes(manifest, {KEY_ALIAS_FIELD: ["DECL_KEY_"]})lines 295–295assert resolved.tier == TIER_EXPLICITlines 296–298assert set(resolved.values) == {"FLAG_KEY_", "DECL_KEY_", *DEFAULT_KEY_ALIAS_PREFIXES}, ( "tier 1 wins the TIER, but tier 2 is still a stated layer contributing values" )

test_an_explicit_statement_displaces_the_guesses_and_keeps_the_facts

None test_tiers.test_an_explicit_statement_displaces_the_guesses_and_keeps_the_facts()

Tier 1 replaces tier 5; tiers 3 and 4 accumulate underneath.

tests/test_tiers.py:97

Checks

  • assert resolved.values == (*FACTS, *ECOSYSTEM, "%mine%")
  • assert resolved.tier == TIER_EXPLICIT
  • assert guess not in resolved.values

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-006measuredtest_an_explicit_statement_displaces_the_guesses_and_keeps_the_facts → resolve_layered
Source · 11 lines
def test_an_explicit_statement_displaces_the_guesses_and_keeps_the_facts() -> None:
    """Tier 1 replaces tier 5; tiers 3 and 4 accumulate underneath."""
    resolved = resolve_layered(
        facts=FACTS, ecosystem=ECOSYSTEM, heuristics=GUESSES, explicit=["%mine%"]
    )
    assert resolved.values == (*FACTS, *ECOSYSTEM, "%mine%")
    assert resolved.tier == TIER_EXPLICIT
    for guess in GUESSES:
        assert guess not in resolved.values

Activity · 5 steps
lines 99–101resolved = resolve_layered( facts=FACTS, ecosystem=ECOSYSTEM, heuristics=GUESSES, explicit=["%mine%"] )lines 102–102assert resolved.values == (*FACTS, *ECOSYSTEM, "%mine%")lines 103–103assert resolved.tier == TIER_EXPLICITlines 104–104◇ for guess in GUESSESlines 105–105assert guess not in resolved.values

test_nothing_is_stated_and_nothing_replays_for_a_target_that_states_nothing

None test_tiers.test_nothing_is_stated_and_nothing_replays_for_a_target_that_states_nothing(Path tmp_path)

THE SUCCESS PATH, and the control for "entropic and mbedtls are unchanged". A target that states nothing must record nothing and replay nothing — asserted strictly (an exact section) rather than by absence of a single key, because this repo has shipped a check that tested only its failure path.

tests/test_tiers.py:784

Show on the map →

Called by none

Calls _manifest_namespace, _manifest_option_tiers, _options_meta_section, _replay_manifest_statements, options_meta, stated_options, write_build_signature

Checks

  • assert _options_meta_section(db) == {
  • assert stated_options(_options_meta_section(db)) == ()
  • assert _replay_manifest_statements(_manifest_namespace(), db) == []

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-001measured
REQ-DDB-CONFIG-006measuredtest_nothing_is_stated_and_nothing_replays_for_a_target_that_states_nothing → write_build_signature
REQ-DDB-CONFIG-007measuredtest_nothing_is_stated_and_nothing_replays_for_a_target_that_states_nothing → write_build_signature
REQ-DDB-MCP-001measuredtest_nothing_is_stated_and_nothing_replays_for_a_target_that_states_nothing → _replay_manifest_statements → meta_section
REQ-DDB-PIPE-005measuredtest_nothing_is_stated_and_nothing_replays_for_a_target_that_states_nothing → write_build_signature
Source · 27 lines
def test_nothing_is_stated_and_nothing_replays_for_a_target_that_states_nothing(
    tmp_path: Path,
) -> None:
    """THE SUCCESS PATH, and the control for "entropic and mbedtls are unchanged". A
    target that states nothing must record nothing and replay nothing — asserted
    strictly (an exact section) rather than by absence of a single key, because this
    repo has shipped a check that tested only its failure path.
    """
    db = tmp_path / "clew.db"
    args = _manifest_namespace()
    write_build_signature(db, options=options_meta(**_manifest_option_tiers(args, {})))

    ## gh#42 widened the stamped set: `data_model` is a PATH option rather than a manifest one
    ## — the single manifest that is not YAML — and was previously the one stated option that
    ## recorded nothing. gh#47 widened it again to the SECTION-DOCUMENT options, for the same
    ## reason and found the same way: a consumer asked whether a declaration reached the build
    ## and the row it reads did not exist, so `index_scope` was refused on a build where it had
    ## landed. The assertion stays EXACT, which is the property this test is written for; only
    ## the enumeration follows the set that is actually stamped.
    assert _options_meta_section(db) == {
        f"{option}.{TIER_KEY}": TIER_HEURISTIC
        for option in (*MANIFEST_OPTIONS, SECTION_DATA_MODEL, *SECTION_DOCUMENT_OPTIONS)
    }
    assert stated_options(_options_meta_section(db)) == ()
    assert _replay_manifest_statements(_manifest_namespace(), db) == []

Activity · 6 steps
lines 792–792db = tmp_path / "clew.db"lines 793–793args = _manifest_namespace()lines 794–794write_build_signature(db, options=options_meta(**_manifest_option_tiers(args, {})))lines 803–806assert _options_meta_section(db) == { f"{option}.{TIER_KEY}": TIER_HEURISTIC for option in (*MANIFEST_OPTIONS, SECTION_DATA_MODEL, *SECTION_DOCUMENT_OPTIONS) }lines 807–807assert stated_options(_options_meta_section(db)) == ()lines 808–808assert _replay_manifest_statements(_manifest_namespace(), db) == []

test_only_a_tier_one_statement_is_recorded_for_replay

None test_tiers.test_only_a_tier_one_statement_is_recorded_for_replay()

A declaration re-derives from a file that may have changed since, so replaying a stored copy would freeze a stale declaration.

tests/test_tiers.py:385

Checks

  • assert options_meta(opt=explicit) == {
  • assert options_meta(opt=declared) == {f"opt.{TIER_KEY}": TIER_DECLARED}
  • assert options_meta(opt=silent) == {f"opt.{TIER_KEY}": TIER_HEURISTIC}

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-006measuredtest_only_a_tier_one_statement_is_recorded_for_replay → resolve_layered
Source · 16 lines
def test_only_a_tier_one_statement_is_recorded_for_replay() -> None:
    """A declaration re-derives from a file that may have changed since, so
    replaying a stored copy would freeze a stale declaration.
    """
    explicit = resolve_layered(facts=FACTS, heuristics=GUESSES, explicit=["%mine%"])
    declared = resolve_layered(facts=FACTS, heuristics=GUESSES, declared=["%theirs%"])
    silent = resolve_layered(facts=FACTS, heuristics=GUESSES)

    assert options_meta(opt=explicit) == {
        f"opt.{TIER_KEY}": TIER_EXPLICIT,
        f"opt.{EXPLICIT_KEY}": "%mine%",
    }
    assert options_meta(opt=declared) == {f"opt.{TIER_KEY}": TIER_DECLARED}
    assert options_meta(opt=silent) == {f"opt.{TIER_KEY}": TIER_HEURISTIC}

Activity · 6 steps
lines 389–389explicit = resolve_layered(facts=FACTS, heuristics=GUESSES, explicit=["%mine%"])lines 390–390declared = resolve_layered(facts=FACTS, heuristics=GUESSES, declared=["%theirs%"])lines 391–391silent = resolve_layered(facts=FACTS, heuristics=GUESSES)lines 393–396assert options_meta(opt=explicit) == { f"opt.{TIER_KEY}": TIER_EXPLICIT, f"opt.{EXPLICIT_KEY}": "%mine%", }lines 397–397assert options_meta(opt=declared) == {f"opt.{TIER_KEY}": TIER_DECLARED}lines 398–398assert options_meta(opt=silent) == {f"opt.{TIER_KEY}": TIER_HEURISTIC}

test_options_meta_refuses_a_bare_manifest_mapping

None test_tiers.test_options_meta_refuses_a_bare_manifest_mapping()

The refusal that makes recording the tier structural has to cover the document form too — a bare manifest mapping is exactly what a caller would reach for.

tests/test_tiers.py:750

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-006measuredtest_options_meta_refuses_a_bare_manifest_mapping → options_meta
Source · 8 lines
def test_options_meta_refuses_a_bare_manifest_mapping() -> None:
    """The refusal that makes recording the tier structural has to cover the document
    form too — a bare manifest mapping is exactly what a caller would reach for.
    """
    with pytest.raises(TypeError, match="DocumentResolution"):
        options_meta(**{SECTION_SHARED_KEY: STATED_MANIFEST})  # type: ignore[arg-type]

Activity · 2 steps
lines 754–754with pytest.raises(TypeError, match="DocumentResolution")lines 755–755options_meta(**{SECTION_SHARED_KEY: STATED_MANIFEST})

test_options_meta_refuses_values_whose_tier_was_discarded

None test_tiers.test_options_meta_refuses_values_whose_tier_was_discarded()

THE "CANNOT FORGET" MECHANISM. There is no code path from a bare list to the `options.*` rows, so recording the tier is structural rather than a habit.

tests/test_tiers.py:377

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-006measuredtest_options_meta_refuses_values_whose_tier_was_discarded → options_meta
Source · 8 lines
def test_options_meta_refuses_values_whose_tier_was_discarded() -> None:
    """THE "CANNOT FORGET" MECHANISM. There is no code path from a bare list to the
    `options.*` rows, so recording the tier is structural rather than a habit.
    """
    with pytest.raises(TypeError, match="LayeredResolution"):
        options_meta(entry_patterns=["main", "%init%"])  # type: ignore[arg-type]

Activity · 2 steps
lines 381–381with pytest.raises(TypeError, match="LayeredResolution")lines 382–382options_meta(entry_patterns=["main", "%init%"])

test_reading_provenance_off_an_older_index_is_empty_not_an_error

None test_tiers.test_reading_provenance_off_an_older_index_is_empty_not_an_error(Path tmp_path)

An index built before this section existed answers "not recorded".

tests/test_tiers.py:485

Show on the map →

Called by none

Calls _recorded_entry_patterns, write_build_signature

Checks

  • assert _recorded_entry_patterns(argparse.Namespace(entry_patterns=None), db) is None

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-006measuredtest_reading_provenance_off_an_older_index_is_empty_not_an_error → write_build_signature
REQ-DDB-CONFIG-007measuredtest_reading_provenance_off_an_older_index_is_empty_not_an_error → write_build_signature
REQ-DDB-MCP-001measuredtest_reading_provenance_off_an_older_index_is_empty_not_an_error → _recorded_entry_patterns → meta_section
REQ-DDB-PIPE-005measuredtest_reading_provenance_off_an_older_index_is_empty_not_an_error → write_build_signature
Source · 7 lines
def test_reading_provenance_off_an_older_index_is_empty_not_an_error(tmp_path: Path) -> None:
    """An index built before this section existed answers "not recorded"."""
    db = tmp_path / "clew.db"
    write_build_signature(db)
    assert _recorded_entry_patterns(argparse.Namespace(entry_patterns=None), db) is None

Activity · 3 steps
lines 487–487db = tmp_path / "clew.db"lines 488–488write_build_signature(db)lines 489–489assert _recorded_entry_patterns(argparse.Namespace(entry_patterns=None), db) is None

test_recorded_explicit_is_empty_when_nothing_was_recorded

None test_tiers.test_recorded_explicit_is_empty_when_nothing_was_recorded()

An absent key means "nothing to replay", not an empty statement.

tests/test_tiers.py:413

Checks

  • assert recorded_explicit({}, OPTION_ENTRY_PATTERNS) == ()
  • assert recorded_explicit({f"{OPTION_ENTRY_PATTERNS}.{TIER_KEY}": TIER_HEURISTIC}, "x") == ()

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-006measuredtest_recorded_explicit_is_empty_when_nothing_was_recorded → recorded_explicit
Source · 6 lines
def test_recorded_explicit_is_empty_when_nothing_was_recorded() -> None:
    """An absent key means "nothing to replay", not an empty statement."""
    assert recorded_explicit({}, OPTION_ENTRY_PATTERNS) == ()
    assert recorded_explicit({f"{OPTION_ENTRY_PATTERNS}.{TIER_KEY}": TIER_HEURISTIC}, "x") == ()

Activity · 2 steps
lines 415–415assert recorded_explicit({}, OPTION_ENTRY_PATTERNS) == ()lines 416–416assert recorded_explicit({f"{OPTION_ENTRY_PATTERNS}.{TIER_KEY}": TIER_HEURISTIC}, "x") == ()

test_status_names_the_options_an_operator_stated

None test_tiers.test_status_names_the_options_an_operator_stated(Path tmp_path)

THE VISIBLE STAMP — the owner's condition for allowing the replay at all. A replayed statement means the index carries a policy the repository does not declare, so two operators of one commit can hold different indexes; that is the shape of the defect rejected in gh#352 and it is acceptable only because it is deliberate AND visible. They may differ; never silently.

tests/test_tiers.py:758

Checks

  • assert stated_options(_options_meta(db)) == (SECTION_SHARED_KEY,), ("only a tier-1 win is a STATEMENT — a declaration is the repository's own, and " "the built-in floor is nobody's" )

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-001measuredtest_status_names_the_options_an_operator_stated → _entry_patterns → string_list
REQ-DDB-CONFIG-006measuredtest_status_names_the_options_an_operator_stated → _options_meta
REQ-DDB-CONFIG-007measuredtest_status_names_the_options_an_operator_stated → write_build_signature
REQ-DDB-MCP-001measuredtest_status_names_the_options_an_operator_stated → _options_meta → _meta_section
REQ-DDB-PIPE-005measuredtest_status_names_the_options_an_operator_stated → write_build_signature
Source · 26 lines
def test_status_names_the_options_an_operator_stated(tmp_path: Path) -> None:
    """THE VISIBLE STAMP — the owner's condition for allowing the replay at all. A
    replayed statement means the index carries a policy the repository does not
    declare, so two operators of one commit can hold different indexes; that is the
    shape of the defect rejected in gh#352 and it is acceptable only because it is
    deliberate AND visible. They may differ; never silently.
    """
    from clew.mcp_server.state import _options_meta

    db = tmp_path / "clew.db"
    write_build_signature(
        db,
        options=options_meta(
            **{
                OPTION_ENTRY_PATTERNS: _entry_patterns(argparse.Namespace(entry_patterns=None), {}),
                SECTION_SHARED_KEY: resolve_document(explicit=STATED_MANIFEST),
                SECTION_LOCKS: resolve_document(declared=STATED_MANIFEST),
            }
        ),
    )
    assert stated_options(_options_meta(db)) == (SECTION_SHARED_KEY,), (
        "only a tier-1 win is a STATEMENT — a declaration is the repository's own, and "
        "the built-in floor is nobody's"
    )

Activity · 4 steps
lines 765–765from clew.mcp_server.state import _options_metalines 767–767db = tmp_path / "clew.db"lines 768–777write_build_signature( db, options=options_meta( **{ OPTION_ENTRY_PATTERNS: _entry_patterns(argparse.Namespace(entry_patterns=None), {}), SECTION_SHARED_KEY: resolve_document(explicit=STATED_MANIFEST), SECTION_LOCKS: resolve_document(declared=STATED_MANIFEST), } ), )lines 778–781assert stated_options(_options_meta(db)) == (SECTION_SHARED_KEY,), ( "only a tier-1 win is a STATEMENT — a declaration is the repository's own, and " "the built-in floor is nobody's" )

test_status_reports_which_tier_chose_the_seeds

None test_tiers.test_status_reports_which_tier_chose_the_seeds(Path tmp_path)

RECORDED IS NOT ENOUGH — it has to be REPORTED. A tiered resolution whose winner never reaches a consumer is the same opacity as an untiered one with more moving parts, so `status` carries the section beside scope and coverage.

tests/test_tiers.py:492

Show on the map →

Called by none

Calls _entry_patterns, _options_meta, _stamp

Checks

  • assert _options_meta(db) == {}, "a nonexistent index reports nothing, not a default"
  • assert _options_meta(db) == {
  • assert _options_meta(db)[f"{OPTION_ENTRY_PATTERNS}.{TIER_KEY}"] == TIER_HEURISTIC

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-001measuredtest_status_reports_which_tier_chose_the_seeds → _entry_patterns → string_list
REQ-DDB-CONFIG-006measuredtest_status_reports_which_tier_chose_the_seeds → _options_meta
REQ-DDB-CONFIG-007measuredtest_status_reports_which_tier_chose_the_seeds → _stamp → write_build_signature
REQ-DDB-MCP-001measuredtest_status_reports_which_tier_chose_the_seeds → _options_meta → _meta_section
REQ-DDB-PIPE-005measuredtest_status_reports_which_tier_chose_the_seeds → _stamp → write_build_signature
Source · 20 lines
def test_status_reports_which_tier_chose_the_seeds(tmp_path: Path) -> None:
    """RECORDED IS NOT ENOUGH — it has to be REPORTED. A tiered resolution whose
    winner never reaches a consumer is the same opacity as an untiered one with
    more moving parts, so `status` carries the section beside scope and coverage.
    """
    from clew.mcp_server.state import _options_meta

    db = tmp_path / "clew.db"
    assert _options_meta(db) == {}, "a nonexistent index reports nothing, not a default"

    _stamp(db, _entry_patterns(argparse.Namespace(entry_patterns=["%mine%"]), {}))
    assert _options_meta(db) == {
        f"{OPTION_ENTRY_PATTERNS}.{TIER_KEY}": TIER_EXPLICIT,
        f"{OPTION_ENTRY_PATTERNS}.{EXPLICIT_KEY}": "%mine%",
    }

    _stamp(db, _entry_patterns(argparse.Namespace(entry_patterns=None), {}))
    assert _options_meta(db)[f"{OPTION_ENTRY_PATTERNS}.{TIER_KEY}"] == TIER_HEURISTIC

Activity · 7 steps
lines 497–497from clew.mcp_server.state import _options_metalines 499–499db = tmp_path / "clew.db"lines 500–500assert _options_meta(db) == {}, "a nonexistent index reports nothing, not a default"lines 502–502_stamp(db, _entry_patterns(argparse.Namespace(entry_patterns=["%mine%"]), {}))lines 503–506assert _options_meta(db) == { f"{OPTION_ENTRY_PATTERNS}.{TIER_KEY}": TIER_EXPLICIT, f"{OPTION_ENTRY_PATTERNS}.{EXPLICIT_KEY}": "%mine%", }lines 508–508_stamp(db, _entry_patterns(argparse.Namespace(entry_patterns=None), {}))lines 509–509assert _options_meta(db)[f"{OPTION_ENTRY_PATTERNS}.{TIER_KEY}"] == TIER_HEURISTIC

test_the_alias_tier_is_stamped_beside_the_entry_pattern_tier

None test_tiers.test_the_alias_tier_is_stamped_beside_the_entry_pattern_tier(Path tmp_path)

Both layered options reach `build_meta` through the one producer that refuses values whose tier was discarded.

tests/test_tiers.py:347

Show on the map →

Called by none

Calls _entry_patterns, _options_meta_section, options_meta, recorded_explicit, resolve_key_alias_prefixes, write_build_signature

Checks

  • assert section[f"{OPTION_ENTRY_PATTERNS}.{TIER_KEY}"] == TIER_HEURISTIC
  • assert section[f"{OPTION_KEY_ALIAS_PREFIXES}.{TIER_KEY}"] == TIER_DECLARED
  • assert f"{OPTION_KEY_ALIAS_PREFIXES}.{EXPLICIT_KEY}" not in section
  • assert recorded_explicit(section, OPTION_KEY_ALIAS_PREFIXES) == ()

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-001measuredtest_the_alias_tier_is_stamped_beside_the_entry_pattern_tier → _entry_patterns → string_list
REQ-DDB-CONFIG-006measuredtest_the_alias_tier_is_stamped_beside_the_entry_pattern_tier → resolve_key_alias_prefixes
REQ-DDB-CONFIG-007measuredtest_the_alias_tier_is_stamped_beside_the_entry_pattern_tier → write_build_signature
REQ-DDB-MCP-001measuredtest_the_alias_tier_is_stamped_beside_the_entry_pattern_tier → _options_meta_section → _options_meta → _meta_section
REQ-DDB-PIPE-005measuredtest_the_alias_tier_is_stamped_beside_the_entry_pattern_tier → write_build_signature
REQ-DDB-SCHEMA-005measuredtest_the_alias_tier_is_stamped_beside_the_entry_pattern_tier → resolve_key_alias_prefixes
Source · 30 lines
def test_the_alias_tier_is_stamped_beside_the_entry_pattern_tier(tmp_path: Path) -> None:
    """Both layered options reach `build_meta` through the one producer that refuses
    values whose tier was discarded.
    """
    db = tmp_path / "clew.db"
    write_build_signature(
        db,
        options=options_meta(
            **{
                OPTION_ENTRY_PATTERNS: _entry_patterns(argparse.Namespace(entry_patterns=None), {}),
                OPTION_KEY_ALIAS_PREFIXES: resolve_key_alias_prefixes(
                    {KEY_ALIAS_FIELD: ["APP_KEY_"]}
                ),
            }
        ),
    )
    section = _options_meta_section(db)
    assert section[f"{OPTION_ENTRY_PATTERNS}.{TIER_KEY}"] == TIER_HEURISTIC
    assert section[f"{OPTION_KEY_ALIAS_PREFIXES}.{TIER_KEY}"] == TIER_DECLARED
    ## NOT REPLAYED, and this asserts the absence rather than assuming it. Only a
    ## tier-1 statement is recorded for replay, and a declaration re-derives from a
    ## file that may have changed — so the stale-row hazard `recorded_explicit`
    ## guards against cannot arise for a declared win in the first place.
    assert f"{OPTION_KEY_ALIAS_PREFIXES}.{EXPLICIT_KEY}" not in section
    assert recorded_explicit(section, OPTION_KEY_ALIAS_PREFIXES) == ()


# ── provenance: stamped, and read back rather than re-derived ───────────────

Activity · 7 steps
lines 351–351db = tmp_path / "clew.db"lines 352–362write_build_signature( db, options=options_meta( **{ OPTION_ENTRY_PATTERNS: _entry_patterns(argparse.Namespace(entry_patterns=None), {}), OPTION_KEY_ALIAS_PREFIXES: resolve_key_alias_prefixes( {KEY_ALIAS_FIELD: ["APP_KEY_"]} ), } ), )lines 363–363section = _options_meta_section(db)lines 364–364assert section[f"{OPTION_ENTRY_PATTERNS}.{TIER_KEY}"] == TIER_HEURISTIClines 365–365assert section[f"{OPTION_KEY_ALIAS_PREFIXES}.{TIER_KEY}"] == TIER_DECLAREDlines 370–370assert f"{OPTION_KEY_ALIAS_PREFIXES}.{EXPLICIT_KEY}" not in sectionlines 371–371assert recorded_explicit(section, OPTION_KEY_ALIAS_PREFIXES) == ()

test_the_default_entry_pattern_set_is_exactly_the_two_halves

None test_tiers.test_the_default_entry_pattern_set_is_exactly_the_two_halves()

The composed constant is the ONE answer for "what a silent target gets".

tests/test_tiers.py:158

Show on the map →

Called by none

Calls none

Checks

  • assert DEFAULT_ENTRY_PATTERNS == [*ENTRY_PATTERN_FACTS, *ENTRY_PATTERN_HEURISTICS]
  • assert set(ENTRY_PATTERN_FACTS) == {"main", "app_main"}
  • assert not set(ENTRY_PATTERN_FACTS) & set(ENTRY_PATTERN_HEURISTICS)

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-006catalog
Source · 7 lines
def test_the_default_entry_pattern_set_is_exactly_the_two_halves() -> None:
    """The composed constant is the ONE answer for "what a silent target gets"."""
    assert DEFAULT_ENTRY_PATTERNS == [*ENTRY_PATTERN_FACTS, *ENTRY_PATTERN_HEURISTICS]
    assert set(ENTRY_PATTERN_FACTS) == {"main", "app_main"}
    assert not set(ENTRY_PATTERN_FACTS) & set(ENTRY_PATTERN_HEURISTICS)

Activity · 3 steps
lines 160–160assert DEFAULT_ENTRY_PATTERNS == [*ENTRY_PATTERN_FACTS, *ENTRY_PATTERN_HEURISTICS]lines 161–161assert set(ENTRY_PATTERN_FACTS) == {"main", "app_main"}lines 162–162assert not set(ENTRY_PATTERN_FACTS) & set(ENTRY_PATTERN_HEURISTICS)

test_the_manifest_option_names_are_the_declaration_section_names

None test_tiers.test_the_manifest_option_names_are_the_declaration_section_names()

AN IDENTITY THE REPLAY DEPENDS ON, pinned rather than trusted.

tests/test_tiers.py:572

Show on the map →

Called by none

Calls none

Checks

  • assert set(MANIFEST_OPTIONS) == {
  • assert set(MANIFEST_OPTIONS) <= KNOWN_SECTIONS

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-006catalog
Source · 21 lines
def test_the_manifest_option_names_are_the_declaration_section_names() -> None:
    """AN IDENTITY THE REPLAY DEPENDS ON, pinned rather than trusted.

    `_manifest_option_tiers` reads the target's declared document with
    `section(decl, option)` and `_replay_manifest_statements` reads the argparse dest
    with `getattr(args, option)`, so ONE string serves as the option name, the
    declaration section name and the flag's dest. That is the design
    (`buildoptions`: "THE VOCABULARY IS THE DECLARATION FILE'S"), but nothing enforced
    it — and a renamed section would leave the replay reading a declaration that is
    always empty, stamping `heuristic` over a repo that declares its own conventions.
    """
    assert set(MANIFEST_OPTIONS) == {
        SECTION_SHARED_KEY,
        SECTION_THREADS,
        SECTION_LOCKS,
        SECTION_DISPATCH,
        SECTION_MQTT,
    }
    assert set(MANIFEST_OPTIONS) <= KNOWN_SECTIONS

Activity · 2 steps
lines 583–589assert set(MANIFEST_OPTIONS) == { SECTION_SHARED_KEY, SECTION_THREADS, SECTION_LOCKS, SECTION_DISPATCH, SECTION_MQTT, }lines 590–590assert set(MANIFEST_OPTIONS) <= KNOWN_SECTIONS

test_the_probe_set_straddles_both_halves_of_the_split

None test_tiers.test_the_probe_set_straddles_both_halves_of_the_split()

Without this the agreement test could pass on a consumer reading one half.

tests/test_tiers.py:232

Show on the map →

Called by none

Calls _like, seeds_reachability

Checks

  • assert len(fact_only) >= 2, fact_only
  • assert len(guess_only) >= 2, guess_only
  • assert any(not seeds_reachability(n) for n in _PROBES), "no negative probe"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-001measuredtest_the_probe_set_straddles_both_halves_of_the_split → seeds_reachability
REQ-DDB-CONFIG-006catalog
Source · 16 lines
def test_the_probe_set_straddles_both_halves_of_the_split() -> None:
    """Without this the agreement test could pass on a consumer reading one half.

    A probe set that happened to contain only fact-matching names would be
    satisfied by a `seeds_reachability` that had dropped the heuristics entirely.
    """
    fact_only = [n for n in _PROBES if any(_like(n.lower(), p) for p in ENTRY_PATTERN_FACTS)]
    guess_only = [n for n in _PROBES if any(_like(n.lower(), p) for p in ENTRY_PATTERN_HEURISTICS)]
    assert len(fact_only) >= 2, fact_only
    assert len(guess_only) >= 2, guess_only
    assert any(not seeds_reachability(n) for n in _PROBES), "no negative probe"


# ── key alias prefixes: the second migrated consumer (tier 4) ───────────────

Activity · 5 steps
lines 238–238fact_only = [n for n in _PROBES if any(_like(n.lower(), p) for p in ENTRY_PATTERN_FACTS)]lines 239–239guess_only = [n for n in _PROBES if any(_like(n.lower(), p) for p in ENTRY_PATTERN_HEURISTICS)]lines 240–240assert len(fact_only) >= 2, fact_onlylines 241–241assert len(guess_only) >= 2, guess_onlylines 242–242assert any(not seeds_reachability(n) for n in _PROBES), "no negative probe"

test_the_proposer_and_reachability_agree_on_what_an_entry_point_is

None test_tiers.test_the_proposer_and_reachability_agree_on_what_an_entry_point_is()

CONTROL FOR THE SPLIT'S SECOND CONSUMER.

tests/test_tiers.py:213

Show on the map →

Called by none

Calls _entry_patterns, _like, seeds_reachability

Checks

  • assert seeds_reachability(name) is expected, name

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-001measuredtest_the_proposer_and_reachability_agree_on_what_an_entry_point_is → seeds_reachability
REQ-DDB-CONFIG-006measuredtest_the_proposer_and_reachability_agree_on_what_an_entry_point_is → _entry_patterns → resolve_layered
Source · 19 lines
def test_the_proposer_and_reachability_agree_on_what_an_entry_point_is() -> None:
    """CONTROL FOR THE SPLIT'S SECOND CONSUMER.

    `propose/notindexed.seeds_reachability` mirrors the pattern set "as SQLite
    would apply it", so after splitting the constant it can silently disagree with
    the pass it claims to mirror — and the disagreement surfaces as a hazard report
    that omits the `main` collision the module exists to warn about.

    Compared against the RESOLVER's own no-statement result, not against the
    constant, so a change to how the default set is composed fails here too. Both
    sides use the same `_like`, which is the point: the question under test is
    WHICH PATTERNS each side uses, not how LIKE is implemented.
    """
    expected_patterns = _entry_patterns(argparse.Namespace(entry_patterns=None), {}).values
    for name in _PROBES:
        expected = any(_like(name.lower(), pattern) for pattern in expected_patterns)
        assert seeds_reachability(name) is expected, name

Activity · 4 steps
lines 226–226expected_patterns = _entry_patterns(argparse.Namespace(entry_patterns=None), {}).valueslines 227–227◇ for name in _PROBESlines 228–228expected = any(_like(name.lower(), pattern) for pattern in expected_patterns)lines 229–229assert seeds_reachability(name) is expected, name

test_the_stamped_alias_resolution_matches_the_one_the_pass_uses

None test_tiers.test_the_stamped_alias_resolution_matches_the_one_the_pass_uses()

PINS THE DOUBLE RESOLUTION. `resolve_key_alias_prefixes` is called twice per build — once inside `import_shared_key_edges_inferred` and once in `_build_stages` to stamp the tier — because the value is computed several frames below the stamping stage. It is pure and both calls take the same two locals, so they cannot disagree; this asserts that rather than trusting it, and would fail the moment either call site starts resolving something else.

tests/test_tiers.py:329

Checks

  • assert via_pass == via_stamp, sources

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-006measuredtest_the_stamped_alias_resolution_matches_the_one_the_pass_uses → resolve_shared_key_patterns
REQ-DDB-SCHEMA-005measuredtest_the_stamped_alias_resolution_matches_the_one_the_pass_uses → resolve_shared_key_patterns
REQ-DDB-SCHEMA-012measuredtest_the_stamped_alias_resolution_matches_the_one_the_pass_uses → resolve_shared_key_patterns → load_shared_key_patterns → declaration_origin
Source · 18 lines
def test_the_stamped_alias_resolution_matches_the_one_the_pass_uses() -> None:
    """PINS THE DOUBLE RESOLUTION. `resolve_key_alias_prefixes` is called twice per
    build — once inside `import_shared_key_edges_inferred` and once in
    `_build_stages` to stamp the tier — because the value is computed several frames
    below the stamping stage. It is pure and both calls take the same two locals, so
    they cannot disagree; this asserts that rather than trusting it, and would fail
    the moment either call site starts resolving something else.
    """
    for sources in (
        (None, None),
        ({KEY_ALIAS_FIELD: ["APP_KEY_"]}, None),
        ({"writers": [{"name_prefix": "App_Set_"}]}, {KEY_ALIAS_FIELD: ["WRAP_KEY_"]}),
    ):
        via_pass = resolve_shared_key_patterns(*sources)[2]
        via_stamp = resolve_key_alias_prefixes(*sources).values
        assert via_pass == via_stamp, sources

Activity · 4 steps
lines 337–337◇ for sources in (lines 342–342via_pass = resolve_shared_key_patterns(*sources)[2]lines 343–343via_stamp = resolve_key_alias_prefixes(*sources).valueslines 344–344assert via_pass == via_stamp, sources

test_the_stored_document_is_byte_STABLE_across_key_orderings

None test_tiers.test_the_stored_document_is_byte_STABLE_across_key_orderings()

WHAT PINS THE CANONICAL FORM. `test_warm_rebuild_is_deterministic` compares two real builds' `build_meta` VERBATIM, so a serialisation that preserved insertion order would make the stored row a function of how the caller spelled its mapping — an intermittent failure there rather than a useful one.

tests/test_tiers.py:720

Checks

  • assert canonical_document(STATED_MANIFEST) == canonical_document(STATED_MANIFEST_REORDERED)
  • assert " " not in canonical_document(STATED_MANIFEST)
  • assert (recorded_document(options_meta(o=resolve_document(explicit=STATED_MANIFEST_REORDERED)), "o") == STATED_MANIFEST )

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-006measuredtest_the_stored_document_is_byte_STABLE_across_key_orderings → canonical_document
Source · 14 lines
def test_the_stored_document_is_byte_STABLE_across_key_orderings() -> None:
    """WHAT PINS THE CANONICAL FORM. `test_warm_rebuild_is_deterministic` compares two
    real builds' `build_meta` VERBATIM, so a serialisation that preserved insertion
    order would make the stored row a function of how the caller spelled its mapping —
    an intermittent failure there rather than a useful one.
    """
    assert canonical_document(STATED_MANIFEST) == canonical_document(STATED_MANIFEST_REORDERED)
    assert " " not in canonical_document(STATED_MANIFEST)
    assert (
        recorded_document(options_meta(o=resolve_document(explicit=STATED_MANIFEST_REORDERED)), "o")
        == STATED_MANIFEST
    )

Activity · 3 steps
lines 726–726assert canonical_document(STATED_MANIFEST) == canonical_document(STATED_MANIFEST_REORDERED)lines 727–727assert " " not in canonical_document(STATED_MANIFEST)lines 728–731assert ( recorded_document(options_meta(o=resolve_document(explicit=STATED_MANIFEST_REORDERED)), "o") == STATED_MANIFEST )

test_the_tier_names_partition_into_stated_and_accumulating

None test_tiers.test_the_tier_names_partition_into_stated_and_accumulating()

Nothing may be in both groups, and nothing may be in neither.

tests/test_tiers.py:148

Show on the map →

Called by none

Calls none

Checks

  • assert set(STATED_TIERS) | set(ACCUMULATING_TIERS) == set(TIER_ORDER)
  • assert not set(STATED_TIERS) & set(ACCUMULATING_TIERS)
  • assert set(ACCUMULATING_TIERS) == {TIER_TARGET_FACT, TIER_ECOSYSTEM}

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-006catalog
Source · 10 lines
def test_the_tier_names_partition_into_stated_and_accumulating() -> None:
    """Nothing may be in both groups, and nothing may be in neither."""
    assert set(STATED_TIERS) | set(ACCUMULATING_TIERS) == set(TIER_ORDER)
    assert not set(STATED_TIERS) & set(ACCUMULATING_TIERS)
    assert set(ACCUMULATING_TIERS) == {TIER_TARGET_FACT, TIER_ECOSYSTEM}


# ── entry patterns: the first migrated consumer ─────────────────────────────

Activity · 3 steps
lines 150–150assert set(STATED_TIERS) | set(ACCUMULATING_TIERS) == set(TIER_ORDER)lines 151–151assert not set(STATED_TIERS) & set(ACCUMULATING_TIERS)lines 152–152assert set(ACCUMULATING_TIERS) == {TIER_TARGET_FACT, TIER_ECOSYSTEM}

test_the_winning_tier_reaches_build_meta_and_is_read_back

None test_tiers.test_the_winning_tier_reaches_build_meta_and_is_read_back(Path tmp_path)

PROVENANCE SURVIVES A REFRESH. Scope is re-derived from scratch on every build and nothing consulted what a previous build stamped, so an applied and recorded statement was discarded by the next refresh — which then reported success over a policy the operator had replaced. This is the same read-back `_operator_excludes` does, asserted end to end through the real writer.

tests/test_tiers.py:430

Show on the map →

Called by none

Calls _entry_patterns, _recorded_entry_patterns, _stamp, list

Checks

  • assert rows[f"{OPTIONS_META_PREFIX}.{OPTION_ENTRY_PATTERNS}.{TIER_KEY}"] == TIER_EXPLICIT
  • assert rows[f"{OPTIONS_META_PREFIX}.{OPTION_ENTRY_PATTERNS}.{EXPLICIT_KEY}"] == "%mystyle%"
  • assert inherited == ["%mystyle%"]
  • assert list(_entry_patterns(argparse.Namespace(entry_patterns=inherited), {}).values) == [

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-001measuredtest_the_winning_tier_reaches_build_meta_and_is_read_back → _entry_patterns → string_list
REQ-DDB-CONFIG-006measuredtest_the_winning_tier_reaches_build_meta_and_is_read_back → _stamp → write_build_signature
REQ-DDB-CONFIG-007measuredtest_the_winning_tier_reaches_build_meta_and_is_read_back → _stamp → write_build_signature
REQ-DDB-MCP-001measuredtest_the_winning_tier_reaches_build_meta_and_is_read_back → _recorded_entry_patterns → meta_section
REQ-DDB-PIPE-005measuredtest_the_winning_tier_reaches_build_meta_and_is_read_back → _stamp → write_build_signature
Source · 30 lines
def test_the_winning_tier_reaches_build_meta_and_is_read_back(tmp_path: Path) -> None:
    """PROVENANCE SURVIVES A REFRESH. Scope is re-derived from scratch on every
    build and nothing consulted what a previous build stamped, so an applied and
    recorded statement was discarded by the next refresh — which then reported
    success over a policy the operator had replaced. This is the same read-back
    `_operator_excludes` does, asserted end to end through the real writer.
    """
    db = tmp_path / "clew.db"
    resolution = _entry_patterns(argparse.Namespace(entry_patterns=["%mystyle%"]), {})
    _stamp(db, resolution)

    rows = dict(
        sqlite3.connect(str(db))
        .execute(f"SELECT key, value FROM build_meta WHERE key LIKE '{OPTIONS_META_PREFIX}.%'")
        .fetchall()
    )
    assert rows[f"{OPTIONS_META_PREFIX}.{OPTION_ENTRY_PATTERNS}.{TIER_KEY}"] == TIER_EXPLICIT
    assert rows[f"{OPTIONS_META_PREFIX}.{OPTION_ENTRY_PATTERNS}.{EXPLICIT_KEY}"] == "%mystyle%"

    # A later build passing NO flag inherits the recorded statement rather than
    # silently re-deriving the built-in guesses.
    inherited = _recorded_entry_patterns(argparse.Namespace(entry_patterns=None), db)
    assert inherited == ["%mystyle%"]
    assert list(_entry_patterns(argparse.Namespace(entry_patterns=inherited), {}).values) == [
        "main",
        "app_main",
        "%mystyle%",
    ]

Activity · 9 steps
lines 437–437db = tmp_path / "clew.db"lines 438–438resolution = _entry_patterns(argparse.Namespace(entry_patterns=["%mystyle%"]), {})lines 439–439_stamp(db, resolution)lines 441–445rows = dict( sqlite3.connect(str(db)) .execute(f"SELECT key, value FROM build_meta WHERE key LIKE '{OPTIONS_META_PREFIX}.%'") .fetchall() )lines 446–446assert rows[f"{OPTIONS_META_PREFIX}.{OPTION_ENTRY_PATTERNS}.{TIER_KEY}"] == TIER_EXPLICITlines 447–447assert rows[f"{OPTIONS_META_PREFIX}.{OPTION_ENTRY_PATTERNS}.{EXPLICIT_KEY}"] == "%mystyle%"lines 451–451inherited = _recorded_entry_patterns(argparse.Namespace(entry_patterns=None), db)lines 452–452assert inherited == ["%mystyle%"]lines 453–457assert list(_entry_patterns(argparse.Namespace(entry_patterns=inherited), {}).values) == [ "main", "app_main", "%mystyle%", ]

test_tier_one_beats_tier_two

None test_tiers.test_tier_one_beats_tier_two()

A flag is a deliberate one-off override of the repo's standing statement.

tests/test_tiers.py:117

Checks

  • assert resolved.values == (*FACTS, "%mine%")
  • assert resolved.tier == TIER_EXPLICIT

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-006measuredtest_tier_one_beats_tier_two → resolve_layered
Source · 9 lines
def test_tier_one_beats_tier_two() -> None:
    """A flag is a deliberate one-off override of the repo's standing statement."""
    resolved = resolve_layered(
        facts=FACTS, heuristics=GUESSES, declared=["%theirs%"], explicit=["%mine%"]
    )
    assert resolved.values == (*FACTS, "%mine%")
    assert resolved.tier == TIER_EXPLICIT

Activity · 3 steps
lines 119–121resolved = resolve_layered( facts=FACTS, heuristics=GUESSES, declared=["%theirs%"], explicit=["%mine%"] )lines 122–122assert resolved.values == (*FACTS, "%mine%")lines 123–123assert resolved.tier == TIER_EXPLICIT