test_stdio_probe.py

tests/integration/test_stdio_probe.py

The gh#48 reporter's own probe, over real JSON-RPC, as a test.

test_the_cwd_only_mode_refuses_by_naming_every_source_of_a_target

None test_stdio_probe.test_the_cwd_only_mode_refuses_by_naming_every_source_of_a_target(Path tmp_path, Path rich_db)

With no target source, the refusal names --repo, the environment and target=.

tests/integration/test_stdio_probe.py:252

Show on the map →

Called by none

Calls _probe, _probe_repo, _read

Checks

  • assert not payload, f"a server with no target must not answer: {payload}"
  • assert "No default target repository" in error, error
  • assert "--repo" in error and PROJECT_DIR_ENV in error and "target=" in error, error

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-MCP-001measuredtest_the_cwd_only_mode_refuses_by_naming_every_source_of_a_target → _probe_repo → target_for
Source · 18 lines
def test_the_cwd_only_mode_refuses_by_naming_every_source_of_a_target(
    tmp_path: Path, rich_db: Path
) -> None:
    """THE FOURTH MODE, WHICH IS CORRECT TO REFUSE. The working directory is deliberately not a
    source for the default target — a client that supplies neither `--repo` nor the environment
    nor roots has said nothing about which repository it means. What the refusal must do is name
    all three routes plus the per-call argument, so a reader can act without knowing the design.

    @brief With no target source, the refusal names --repo, the environment and target=.
    @version 1
    """
    repo, home = _probe_repo(tmp_path, rich_db)

    payload, error = _read(_probe(repo, home, [], None, None))

    assert not payload, f"a server with no target must not answer: {payload}"
    assert "No default target repository" in error, error
    assert "--repo" in error and PROJECT_DIR_ENV in error and "target=" in error, error

1 more lines, not shown

Activity · 5 steps
lines 263–263repo, home = _probe_repo(tmp_path, rich_db)lines 265–265payload, error = _read(_probe(repo, home, [], None, None))lines 267–267assert not payload, f"a server with no target must not answer: {payload}"lines 268–268assert "No default target repository" in error, errorlines 269–269assert "--repo" in error and PROJECT_DIR_ENV in error and "target=" in error, error

test_the_three_target_bearing_modes_answer_from_first_party

None test_stdio_probe.test_the_three_target_bearing_modes_answer_from_first_party(Path tmp_path, Path rich_db)

--repo with and without target, and $CLAUDE_PROJECT_DIR, all answer from first-party.

tests/integration/test_stdio_probe.py:228

Show on the map →

Called by none

Calls _probe, _probe_repo, _read

Checks

  • assert not error, f"{label}: refused — {error}"
  • assert payload.get("found") is not False, f"{label}: {payload}"
  • assert payload.get("sub_index") == FIRST_PARTY_INDEX, f"{label}: {payload}"
  • assert payload.get("target") == str(repo), f"{label}: {payload}"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-MCP-001measuredtest_the_three_target_bearing_modes_answer_from_first_party → _probe_repo → target_for
Source · 24 lines
def test_the_three_target_bearing_modes_answer_from_first_party(
    tmp_path: Path, rich_db: Path
) -> None:
    """THE THREE MODES THAT HAVE A REPOSITORY. Each answers, and each says which part answered:
    a reply that read first-party while looking like a whole-repository answer is the failure
    `Answering` calls this project's most expensive.

    @brief --repo with and without target, and $CLAUDE_PROJECT_DIR, all answer from first-party.
    @version 1
    """
    repo, home = _probe_repo(tmp_path, rich_db)
    modes = {
        "--repo, target supplied": ([f"--repo={repo}"], None, repo),
        "--repo, target omitted": ([f"--repo={repo}"], None, None),
        f"no --repo, ${PROJECT_DIR_ENV} set": ([], repo, None),
    }
    for label, (args, env_repo, target) in modes.items():
        payload, error = _read(_probe(repo, home, args, env_repo, target))
        assert not error, f"{label}: refused — {error}"
        assert payload.get("found") is not False, f"{label}: {payload}"
        assert payload.get("sub_index") == FIRST_PARTY_INDEX, f"{label}: {payload}"
        assert payload.get("target") == str(repo), f"{label}: {payload}"

Activity · 8 steps
lines 238–238repo, home = _probe_repo(tmp_path, rich_db)lines 239–243modes = { "--repo, target supplied": ([f"--repo={repo}"], None, repo), "--repo, target omitted": ([f"--repo={repo}"], None, None), f"no --repo, ${PROJECT_DIR_ENV} set": ([], repo, None), }lines 244–244◇ for label, (args, env_repo, target) in modes.items()lines 245–245payload, error = _read(_probe(repo, home, args, env_repo, target))lines 246–246assert not error, f"{label}: refused — {error}"lines 247–247assert payload.get("found") is not False, f"{label}: {payload}"lines 248–248assert payload.get("sub_index") == FIRST_PARTY_INDEX, f"{label}: {payload}"lines 249–249assert payload.get("target") == str(repo), f"{label}: {payload}"