Skip to content

docs(openspec): plan #2101 Add repo URI to ToolRun and SARIF - #3149

Merged
dan-petty merged 6 commits into
mainfrom
feat/2101-a-tool-run-names-the-repository
Nov 2, 2026
Merged

dan-petty merged 6 commits into
mainfrom
feat/2101-a-tool-run-names-the-repository

Conversation

@devops-cli-service

@devops-cli-service devops-cli-service Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Plans #2101

This change adds a repository_uri field to ToolRun, read from git with git config --local --get remote.origin.url and with the userinfo removed. A remote that is malformed, or is not an absolute URI with a host, gives None. The SARIF export writes versionControlProvenance with repositoryUri and revisionId, one entry for each distinct pair of repository URI and clean commit among the records of a tool. It writes none for a dirty commit or a record with no repository. The change modifies the sarif-export requirement that forbade versionControlProvenance. This satisfies SARIF 2.1.0 section 3.23.3, which requires repositoryUri in versionControlDetails, and section 3.23.4, which says a -dirty commit is not a revision of the scanned files. See #2101.

Change: openspec/changes/2101-a-tool-run-names-the-repository/

@dan-petty

Copy link
Copy Markdown
Owner

Advisory pre-merge review (automated; a person decides).

Recommendation: hold. The plan has two blockers and two major findings. Fix the plan before merge.

Severity Where Problem Evidence Fix
blocker tasks.md 1.2 git remote get-url origin exits with 2, not 1, when no remote exists. The plan uses accepted=(0, 1). _git raises SandboxError for exit 2. The "no remote" test and scenario would fail. In a fresh git init checkout: error: No such remote 'origin', exit=2. _git in src/devops_cli/security/tool_executor.py:401-418 raises when the code is not in accepted. Accept exit 2, or use git config --get remote.origin.url (exit 1 when unset). Put the command output in Feasibility.
blocker tasks.md 1.2 The plan calls the git read in record_tool_run with no guard. Outside a checkout, git exits 128 and _git raises. This breaks two existing behaviors: a tree outside any repository records no commit, and the direct executor records no commit when git cannot read the checkout. In a dir with no repository: fatal: not a git repository, exit=128. Guards exist for the commit: nearest_checkout in _read_tree_commit (line 428) and required in _tree_commit (line 445). The plan reuses neither. Tests at risk: tests/ai/test_tool_executor_contract.py:434 and :900. Use the same guards for the repository read. Name these tests as "must keep passing".
major specs/sarif-export/spec.md The delta uses ADDED for a rule that the base spec forbids. The base requirement says the run SHALL hold no versionControlProvenance. After archive, two requirements contradict each other. openspec/specs/sarif-export/spec.md:10 and :16. The delta has only ## ADDED Requirements. openspec/config.yaml says to change an existing requirement only with MODIFIED, REMOVED or RENAMED. Use MODIFIED with the whole base requirement. Drop the versionControlProvenance ban.
major tasks.md 2.2, design.md The rule is not defined when one tool run has several records with different commits. One entry needs one revisionId. The tests that exist already use two commits in one run. The change point is _run_for, not to_sarif. src/devops_cli/security/sarif.py _run_for; tests/security/test_sarif_emission.py:371-375. State the rule in design.md and a scenario, for example one entry per distinct clean (uri, commit) pair. Test it.
major tasks.md groups 1 and 2 No test file path, no uv run devops ci test <path>, no Kind line. Existing tests that will change or must keep passing are not named: tests/security/test_sarif_emission.py (docstring near line 366 becomes wrong), the snapshot file, tests/ai/test_tool_executor_contract.py. tasks.md verify steps say only uv run devops ci test. Plan 2644 gives Kind, Reads, Changes and a full command. Add Kind, Reads, Changes with test paths. Write the full command in each verify step.
minor tasks.md 1.2, design.md The docstring edit is in group 1, but the export changes in group 2. The urlsplit approach leaves an scp-style remote ([email protected]:a/b.git) unchanged. That text is not a URI. tool_executor.py:72-74. urlsplit on that string gives an empty scheme. Move the docstring edit to group 2. Add a decision and a scenario for scp-style and ssh:// remotes.
minor tasks.md, proposal.md No archive task (AGENTS.md rule 1). Feasibility holds no command output. tasks.md has 0 mentions of archive. Change 2636 has an Archive group. Add an archive group. Add command results to Feasibility.

Checks that I ran:

  • Read the change files in the worktree for docs(openspec): plan #2101 Add repo URI to ToolRun and SARIF #3149 and the lens results.
  • Ran git remote get-url origin in a fresh checkout: exit 2.
  • Ran the same command with no repository: exit 128.
  • Read _git, _read_tree_commit, _tree_commit in tool_executor.py.
  • Read the base sarif-export spec and the delta.
  • Confirmed the two guard tests exist in tests/ai/test_tool_executor_contract.py.
  • The plan lens ran uv run devops openspec check: it passes. That check does not catch the ADDED/MODIFIED conflict.

What is good: every issue criterion maps to a group, the PR body uses "Plans #2101" with no closing keyword, and the paths exist.

Read the remote with git config --local, guard the read as the commit read is guarded, use MODIFIED for the sarif-export requirement, define one entry per distinct clean pair, and add test paths, a docs group and an archive group.
@dan-petty

Copy link
Copy Markdown
Owner

I fixed the review findings in 8290bf7.

  • Task 1.2: the plan now reads the remote with git config --local --get remote.origin.url and accepts exit 0 and 1. I ran the commands: remote get-url origin exits 2 for a missing remote, and config --local --get exits 1. Feasibility shows the results.
  • Task 1.2: the read reuses nearest_checkout and the required flag (_tree_repository_uri). The plan names the four tests that must keep passing (task 1.3).
  • sarif-export: the delta is now MODIFIED, with the whole base requirement. The ban on versionControlProvenance is gone.
  • Records with different commits: one entry for each distinct pair of repository URI and clean commit, in the order of the first record. The design and two scenarios say it. _run_for is the change point.
  • Tasks: each group has Kind, Reads and Changes, and each verify step has a full command. The docstring edit moved to group 2. A docs group (docs/SELF_IMPROVEMENT.md) and an archive group are new.
  • A remote that is not an absolute URI with a host (scp-style, local path, file:) gives None. An ssh:// remote loses its user name. Scenarios cover both.

uv run devops openspec check and tests/invariants/test_change_folders.py pass.

@dan-petty

Copy link
Copy Markdown
Owner

Advisory pre-merge review (automated; a person decides).

Recommendation: hold. The plan has one major gap: a malformed remote URL can make a scan fail for a record. Fix it in the plan, then merge.

Severity Where Problem Evidence Fix
major tasks.md task 1.2, design.md "Strip the userinfo" The plan calls urlsplit on the remote URL. It handles no ValueError. A malformed remote makes urlsplit raise. Then record_tool_run raises and the scan fails for a record. ToolRun says a scan must not fail for a record. _tree_repository_uri catches only SandboxError. No test in 1.1 covers a malformed remote. python3 -I: urlsplit('https://[bad/a.git') raises ValueError: Invalid IPv6 URL. Task 1.2 turns only SandboxError into None. In 1.2, make _read_repository_uri return None for a URL that urlsplit cannot parse. Add a row for it to the parametrized None test in 1.1. Add the case to the review-tool-runs spec.
minor tasks.md 1.1 and 1.3, spec scenarios "Tree outside any checkout" and "Checkout that git cannot read" Two spec scenarios say repository_uri is None. No test asserts it. Task 1.3 re-runs old tests, and they assert commit is None only. tests/ai/test_tool_executor_contract.py lines 434 and 900 hold the two named tests. Add an assertion of repository_uri is None to those tests, or add new tests in 1.1.
minor PR body The body says repository_uri is read from git remote get-url origin. The plan uses git config --local --get remote.origin.url, and the design rejects get-url on purpose. The body becomes the squash commit message, so it would state a wrong fact. PR body text: "read from git remote get-url origin". design.md "Rejected alternatives". Name git config --local --get remote.origin.url in the body.
minor tasks.md group 2 "Reads" Group 2 lists the whole vendored SARIF schema as a read. It is 113691 bytes. With sarif.py, test_sarif_emission.py and tool_executor.py the reads are about 200 KB, above the step token limit. _assert_valid_sarif already loads the schema. ls -la sizes: schema 113691, tool_executor.py 42089, sarif.py 24093, test_sarif_emission.py 19745. Remove the schema from Reads, or name the range near versionControlDetails.

Checks that I ran:

  • I read the plan files in the review worktree and the PR body.
  • I ran urlsplit on a malformed URL with python3 -I. It raises ValueError.
  • I searched the plan for ValueError handling. There is none.
  • Other lenses: all paths in Reads and Changes exist at origin/main. The git premise holds on git 2.55.0 (config --local --get gives exit 128, 1 and 0 as the design says). openspec validate --strict and uv run devops openspec check pass. All five acceptance criteria map to tasks. The title is a Conventional Commit, the body has Plans #2101 and no closing keyword.

Catch the ValueError of urlsplit, test the tree outside a checkout and the unreadable checkout, and list only the schema lines that group 2 reads.
@dan-petty

Copy link
Copy Markdown
Owner

I fixed the third review in 75b6bd7 (pushed as ef4038c with the merge of main).

  • Task 1.2: _read_repository_uri returns None when urlsplit raises ValueError. I ran python3 -I: https://[bad/a.git raises Invalid IPv6 URL. Design, Feasibility and the review-tool-runs spec say it, and the spec has a "Malformed remote" scenario.
  • Task 1.1: the parametrized None test has the row https://[bad/a.git. Two new tests assert repository_uri is None for a tree outside a checkout and for a checkout that git cannot read.
  • Reads: group 2 lists only lines 2153 to 2162 and 2904 to 2942 of the SARIF schema. Group 1 lists only lines 325 to 327 of repo.py.
  • PR body: it names git config --local --get remote.origin.url.

uv run devops openspec check and tests/invariants/test_change_folders.py pass.

@dan-petty

Copy link
Copy Markdown
Owner

Advisory pre-merge review (automated; a person decides).

Recommendation: hold. The plan in group 1 breaks four existing tests, and it does not list them. Fix the plan, then merge.

Severity Where Problem Evidence Fix
major tasks.md group 1, tasks 1.2 and 1.3, and the Changes line The planned git ... config --local --get remote.origin.url call breaks three tests in tests/security/test_scanner_tool_executor.py. The file is not in Changes. Task 1.3 runs this file, so 1.3 fails after 1.2. A copy of the PR tree with the planned call added: 3 tests failed (test_the_tree_of_a_request_is_the_checkout_that_holds_the_targets, test_a_request_names_a_relative_target_by_its_absolute_path, test_a_scan_of_a_checkout_that_git_cannot_read_still_runs). GitFake (tests/support/fakes/git.py, lines 82-107) calls pytest.fail for a git command with no record. The git answers in the test file (lines 51-66) do not answer config. Add the file to Changes. Add a task that gives its git fake an answer for config (exit 1, no output), or add the answer in a shared fake.
major tasks.md group 1, Changes line and task 1.3 tests/security/test_review_tool_runs.py::test_a_review_profile_holds_one_row_per_tool_run_with_every_field fails after the new field is added. The plan names neither the test nor its file. Same run. The test (lines 672-688) asserts that no ToolRun field is "", None or (). The new field repository_uri is None in every row, because the git handler of that file (lines 122-147) answers config with empty output. The output showed pairs such as ('bandit', 'repository_uri'). Plan the change of this test and its git handler: answer config --local --get remote.origin.url with a URL. Add the file to Changes and to the verify commands of group 1.
minor design.md, Rejected alternatives, item git config --get remote.origin.url The text says git "exits 0 with a URL that is not the URL of the tree (see Feasibility)". The Feasibility table does not show this result. The Feasibility row shows exit 1 with no output outside a checkout. A re-run in a /tmp directory gave rc=1, no output. Exit 0 needs a global remote.origin.url, and no run in the plan shows that. Add a Feasibility row with a global remote.origin.url that gives exit 0 outside a checkout, or reword the design.

What is good:

  • All paths and line ranges in the plan exist at origin/main.
  • The five acceptance criteria of feat(review): Add repository URI to SARIF versionControlProvenance #2101 map to groups 1 and 2.
  • The Feasibility commands for remote get-url, config --local and urlsplit match a re-run (git 2.55.0).
  • The delta spec keeps the base requirement text, and the MODIFIED header matches the base.
  • The PR body starts with Plans #2101 and has no closing keyword.
  • Test-first order holds for groups 1 and 2.

Checks that I ran:

  • A scratch copy of the PR tree with the planned record_tool_run call: tests/security/test_scanner_tool_executor.py (3 failed) and tests/security/test_review_tool_runs.py (1 failed).
  • Read tests/support/fakes/git.py and tests/security/test_review_tool_runs.py in the review worktree to confirm both causes.
  • Git feasibility commands and urlsplit cases, re-run outside any repository.
  • uv run devops openspec check in the review worktree: passes.
  • Search of src for repository_uri and versionControlProvenance: no existing implementation.

…2101 plan

Name the ten tests that fail without a config answer in their git fake, plan the answers, and show the global configuration case in Feasibility.
@dan-petty

Copy link
Copy Markdown
Owner

I fixed the fourth review in 690c76a (pushed as 5104db2 with the merge of main).

  • I tested the planned read in a scratch copy of the branch and ran the test suite. Ten tests failed that pass on the base. They are in five files: test_scanner_tool_executor.py (3), test_security_semgrep.py (4), test_security_bandit.py (1), test_review_security_tools.py (1) and test_review_tool_runs.py (1). The review named 4 of them. The proposal lists all ten.
  • With an answer for config in the git fake of each file, all of them pass. Group 1 now has a task for these answers (1.2), lists the five files in Changes, and task 1.4 names the ten tests and runs all six test files.
  • In test_review_tool_runs.py the git answer gives the URL https://example.com/a/b.git, and the profile test asserts it for every row.
  • Feasibility has two new rows for the global configuration. config --get gives exit 0 with the global URL outside a checkout. config --local --get gives exit 128. The design text now says this.
  • Two other tests fail on the base in this devcontainer. They are not part of the change, and the proposal lists them.

uv run devops openspec check and tests/invariants/test_change_folders.py pass.

@dan-petty
dan-petty merged commit 4095791 into main Nov 2, 2026
19 checks passed
@dan-petty
dan-petty deleted the feat/2101-a-tool-run-names-the-repository branch November 2, 2026 04:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant