Skip to main content

Scenario 19: Standards check

Import explicit coding rules, run a bounded check, and preserve operational evidence without claiming compliance approval.

User Guides

Scenario 19 checks a bounded source scope against explicit imported coding rules. It produces operational evidence for a reviewer. Rule matches and command exit status do not make a compliance decision.

Prepare and inspect the rule set

From a source checkout, import a reviewed YAML document and make it active:

python -m src.cli standards import standards.yaml --activate
python -m src.cli standards list-documents
python -m src.cli standards list-rules

Import changes the local standards database. Record the source document digest, imported name/version, activation state, CodeGraph revision, and operator. Do not import untrusted YAML or overwrite an accepted rule set without change control.

Run a bounded CLI check

python -m src.cli standards check PATH --output violations.json

Use --document, --category, --severity, and --fail-on only after verifying their current help. The output file is written only when explicitly requested. A nonzero exit code means the selected threshold found violations or the command failed; preserve the detailed output.

Run the typed reviewer scenario

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

request = RoleBoundScenarioInvocationRequest(
    query="Check the bounded component against the accepted coding standards.",
    employee_id="codegraph_reviewer",
    scenario_id="scenario_19",
    event_type="review_start",
    context={
        "project_key": "codegraph",
        "namespace": "default",
        "task_id": "<task-id>",
        "source_refs": ["<revision-ref>", "<standards-document-ref>"],
        "file_paths": ["<bounded-source-path>"],
    },
)
result = invoke_role_bound_scenario_request(request)

The typed scenario is review analysis. Import rule documents, edit code, approve deviations, and close compliance work through their corresponding governed workflows.

Unsupported report and REST surfaces

python -m src.cli standards report is registered but exits 1 with Report generation not yet implemented (requires stored violations). Build durable evidence from the explicit standards check --output artifact instead.

There is no REST API for standards in the current router tree. Do not use or publish examples for the retired generic standards route.

Interpret evidence correctly

A check records which configured rules matched the analyzed files at the recorded revision. Assess rule completeness, runtime behavior, legal conformity, security, and product acceptance in their respective review lanes.

An accountable reviewer must verify false positives, exclusions, rule provenance, remediation, and any accepted deviation. Keep operational evidence separate from the final compliance decision.

Failure and recovery

  • No rules found: inspect imported documents and activation state; do not report a pass.
  • Invalid YAML: correct the reviewed source document and import under controlled identity.
  • Unexpected zero violations: verify path, active rules, category/severity filters, and analyzer coverage.
  • Report command fails: use the explicit check artifact; do not retry the stub as a release gate.

Source contract

This guide is bound to:

  • src/cli/security_suite/standards_commands.py — import, list, check, delete, and report stub;
  • src/workflow/scenarios/code_quality/standards_check.py — Scenario 19 analysis;
  • src/digital_employees/runtime/scenarios/role_bound_scenario_invoker.py — typed routing;
  • src/digital_employees/runtime/scenarios/employee_scenario_invocation.py — reviewer ownership and required event;
  • src/api/routers/security_suite/compliance_gost.py — explicit retirement note for the generic standards REST surface.