Skip to content

feat(review): a tool run records its exit code and its success, and the SARIF export writes one invocation for each run #2100

Description

@dan-petty

Friction

The SARIF export of a review (#1983) carries each ToolRun in the run's property bag, but it writes no invocations for a run. SARIF 2.1.0 says an invocation SHALL hold executionSuccessful (section 3.20.14), and the exit code alone does not tell success. A ToolRun holds neither the exit code nor the success of the run.

What should happen

  • A ToolRun holds its exit code and the success of the run as its scanner decides it (a scanner decides from the exit code and the parsed output together, security/base.py _handle_json_output).
  • The SARIF export writes one invocation for each record, with executionSuccessful, exitCode and a commandLine. The argv placeholders {targets}, {config} and {ruleset} go in run.redactionTokens (sections 3.5.2 and 3.14.28).

Evidence

Order

After #1982, because the change adds a field that tests/support/fakes/tool_executor.py must record.

Source: #1983

Proposed design

Problem statement

The SARIF export of a review carries each ToolRun in the run property bag but writes no invocations. SARIF 2.1.0 requires an invocation to hold executionSuccessful (section 3.20.14). A ToolRun holds neither the exit code nor the success of the run. This issue adds both to the record and makes the SARIF export write one invocation per run with executionSuccessful, exitCode, commandLine, and redactionTokens for the argv placeholders.

Acceptance criteria

  • Criterion 1: ToolRun holds an exit_code field and a success field set by the scanner.
    Verification: A unit test constructs a ToolRun with exit_code and success set and asserts both fields are present on the object.
  • Criterion 2: The SARIF export writes one invocation per ToolRun record with executionSuccessful, exitCode, and commandLine.
    Verification: A test runs to_sarif on a review with at least one tool run and asserts the output JSON contains an invocations array with the three fields for each record.
  • Criterion 3: The placeholders {targets}, {config}, and {ruleset} in commandLine appear in run.redactionTokens.
    Verification: A test asserts the SARIF output run.redactionTokens array contains the strings {targets}, {config}, and {ruleset}.
  • Criterion 4: ToolExecutorFake records the new exit_code and success fields on each ToolRun it builds.
    Verification: A test scripts a ToolAnswer, calls run, and asserts the returned ToolRun has exit_code and success set to the scripted values.

Key questions

  • Where do exit_code and success live: on ToolRun or on ToolResult?: On ToolRun, as the issue body states. ToolRun is currently frozen and built before the run, so the implementation must allow the fields to be set after the run completes. The scanner sets success; the executor sets exit_code. (proposed) [sources: src/devops_cli/security/tool_executor.py]
  • Who decides the success of a run?: The scanner decides success from the exit code and the parsed output together, in _handle_json_output in security/base.py. The exit code alone does not tell success because tools such as Gitleaks and Semgrep exit with 1 when they find a result. [sources: src/devops_cli/security/base.py:457, openspec/changes/archive/2026-10-24-1983-sarif-carries-tool-runs/design.md]
  • What is the commandLine of the invocation?: The argv_template of the ToolRun, which is the command with a placeholder for each path argument that names a target, a config file, or a ruleset file. [sources: src/devops_cli/security/tool_executor.py]
  • What strings go in run.redactionTokens?: The three placeholder strings: {targets}, {config}, and {ruleset}. SARIF section 3.14.28 requires redactionTokens when a redactable property such as commandLine has been redacted, and section 3.5.2 defines what is redactable. [sources: openspec/changes/archive/2026-10-24-1983-sarif-carries-tool-runs/design.md]
  • How is ToolRun updated after the run given it is currently frozen?: The implementation removes the frozen constraint from ToolRun or builds the final ToolRun after the run completes. The executor sets exit_code after _start returns, and the scanner sets success after _handle_json_output decides it. RecordingToolExecutor stores the completed ToolRun. (proposed) [sources: src/devops_cli/security/tool_executor.py]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/feature
    on Oct 24, 2026
  2. dan-petty commented on Oct 24, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones on the board.

    • Type: type/feature. The candidate adds new functionality to record exit codes and success in ToolRun.
    • Priority: P2-Medium. The change improves correctness of SARIF export but does not block other work. The failed run 1983 does not set P0: the author has no write access, and no caller attached it as evidence. A person can set P0 on the board.
    • Value: Medium. The change helps tools that use SARIF export by providing correct execution status.
    • Effort: Medium. Requires modifying ToolRun and SARIF export logic, plus updating tests.
  3. dan-petty commented on Oct 28, 2026

    @dan-petty
    OwnerAuthor

    Status set to Ready at bb46660 (see proposed design in issue body).

  4. added
    priority/p2-medium
    status/ready
    value/medium
    effort/medium
    on Oct 28, 2026
  5. added 2 commits that reference this issue on Oct 29, 2026
    8f8ef44
    4a3242e
  6. removed
    status/ready
    on Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p2-mediumsource/agenttype/featurevalue/medium

    Type

    No type

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions