Skip to main content

Scenario 07: Find and prioritize test gaps

Use this scenario to combine available runtime coverage with structural evidence such as callers, entry points and test references.

User Guides

Use this scenario to combine available runtime coverage with structural evidence such as callers, entry points and test references. Its purpose is to choose the next valuable test, not to maximize a percentage without regard to risk.

Inspect coverage already owned by the CPG

The current CLI has one read-only display command:

python -m src.cli coverage show --db PATH --uncovered-only

--db is mandatory. The command reads imported coverage from the selected CPG and prints methods with zero or absent coverage when --uncovered-only is set. It does not load a coverage artifact, change the CPG schema, or modify source files.

If the graph does not expose the supported coverage field, the command prints:

Coverage data is not available from the current CPG schema.

That message means runtime coverage is unavailable through this surface. Do not convert it into 0% coverage and do not write directly to GoCPG-owned method tables. Produce coverage with the project’s test tool and use the supported project/GoCPG ingestion path for the installed release.

Typed QA investigation

For graph-backed gap prioritization, invoke the required QA scenario:

from src.digital_employees.runtime.scenarios import (
    RoleBoundScenarioInvocationRequest,
    invoke_role_bound_scenario_request,
)

request = RoleBoundScenarioInvocationRequest(
    query="Prioritize untested behavior in the accepted change scope.",
    employee_id="codegraph_qa",
    scenario_id="scenario_07",
    event_type="qa_start",
    context={
        "project_key": "codegraph",
        "namespace": "default",
        "task_id": "<task-id>",
        "file_paths": ["<changed-source>", "<related-tests>"],
        "source_refs": ["<coverage-artifact-ref>", "<acceptance-criterion-ref>"],
    },
)

result = invoke_role_bound_scenario_request(request)

Missing project_key, namespace, or task_id fails closed with role_bound_scenario_contract_missing.

Prioritize by behavior and risk

Review each candidate against:

  • active acceptance criteria and the changed revision;
  • public entry points and authorization boundaries;
  • error, retry, timeout and rollback paths;
  • persistence and serialization contracts;
  • high-impact callers and previously escaped defects;
  • whether the coverage evidence is current and actually includes the file.

A covered line records execution. Asserted behavior comes from the associated tests. Generated code and defensive branches can be excluded when the exclusion is documented and reviewed.

Tests-first workflow

  1. Select one missing behavior tied to an acceptance criterion or explicit risk.
  2. Add a test that fails for the expected reason.
  3. Make the smallest product change only if the failure reveals missing implementation.
  4. Run the focused test and neighboring regression suite.
  5. Regenerate the project coverage artifact using the project’s own test tool.
  6. Refresh through the supported project path, then rerun the display command.
  7. Record the test execution, revision, artifact basis, and remaining gaps.

Coverage output is one part of QA evidence. Full acceptance combines explicit Pass/Fail evidence for every active criterion with the accountable QA decision.

Maintained source contracts

  • Display-only CLI: src/cli/docs_suite/coverage_commands.py
  • Typed scenario routing: src/digital_employees/runtime/scenarios/role_bound_scenario_invoker.py
  • QA scenario policy: src/digital_employees/runtime/scenarios/employee_scenario_invocation.py

Use Feature Development for a missing implementation and Code Review for revision-bound structural review.