Skip to content

Add target field support to submit_pull_request_review safe-output#36546

Merged
pelikhan merged 8 commits into
mainfrom
copilot/add-target-field-support
Jun 3, 2026
Merged

Add target field support to submit_pull_request_review safe-output#36546
pelikhan merged 8 commits into
mainfrom
copilot/add-target-field-support

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jun 2, 2026

submit_pull_request_review lacked pull_request_number and repo fields, making it impossible to use with target: "*" — unlike create_pull_request_review_comment and reply_to_pull_request_review_comment which already support them. The tool description actively told agents not to pass these fields.

Changes

  • safe_outputs_validation_config.go — Add pull_request_number (OptionalPositiveInteger) and repo fields to submit_pull_request_review, matching the pattern of sibling PR tools.
  • safe_outputs_tools.json (both copies) — Add pull_request_number and repo to the input schema; replace the "do NOT pass pull_request_number" guidance with correct target: "*" instructions.
  • schemas/agent-output.json — Add pull_request_number and repo to SubmitPullRequestReviewOutput.
  • tool_description_enhancer.go — Surface target and target-repo constraints in the enhanced description, consistent with add_comment, close_pull_request, etc.
  • Tests — Cover wildcard/numeric/invalid target validation for submit_pull_request_review; add enhancer tests for target and target-repo constraints.
  • JavaScript validation tests — Update actions/setup/js/safe_output_type_validator.test.cjs to include pull_request_number and repo in submit_pull_request_review validation config and add explicit cases for both fields present, each field independently, neither field, and invalid pull_request_number values.

Example

safe-outputs:
  submit-pull-request-review:
    target: "*"         # agent must supply pull_request_number in the tool call
    allowed-events:
      - APPROVE
      - REQUEST_CHANGES

Copilot AI and others added 2 commits June 2, 2026 23:03
…eview

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
… safe-output

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan pelikhan marked this pull request as ready for review June 3, 2026 00:51
Copilot AI review requested due to automatic review settings June 3, 2026 00:51
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the submit_pull_request_review safe-output type to support pull_request_number and repo, enabling workflows configured with target: "*" to submit reviews on arbitrary PRs/repositories (consistent with sibling PR review comment tools) and improving tool descriptions to surface target constraints.

Changes:

  • Added pull_request_number and repo support for submit_pull_request_review across validation config, tool schemas (both copies), and agent output schema.
  • Enhanced submit_pull_request_review tool descriptions to include target / target-repo constraints, with accompanying tests.
  • Added safe-outputs target validation tests covering wildcard/numeric/invalid targets for submit-pull-request-review.
Show a summary per file
File Description
schemas/agent-output.json Adds pull_request_number and repo fields to SubmitPullRequestReviewOutput.
pkg/workflow/safe_outputs_validation_config.go Allows pull_request_number and repo fields for submit_pull_request_review validation.
pkg/workflow/js/safe_outputs_tools.json Updates tool description and input schema to accept pull_request_number and repo.
actions/setup/js/safe_outputs_tools.json Mirrors the same tool description and schema updates for the runtime copy.
pkg/workflow/tool_description_enhancer.go Appends Target and TargetRepoSlug constraints to enhanced tool descriptions for submit review.
pkg/workflow/tool_description_enhancer_test.go Adds tests asserting target/target-repo constraints appear in enhanced descriptions.
pkg/workflow/safe_outputs_target_validation_test.go Adds target validation test cases for submit-pull-request-review.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 7/7 changed files
  • Comments generated: 2

Comment on lines +249 to +272
{
name: "valid wildcard target for submit-pull-request-review",
config: &SafeOutputsConfig{
SubmitPullRequestReview: &SubmitPullRequestReviewConfig{
BaseSafeOutputConfig: BaseSafeOutputConfig{},
SafeOutputTargetConfig: SafeOutputTargetConfig{
Target: "*",
},
},
},
wantErr: false,
},
{
name: "valid numeric target for submit-pull-request-review",
config: &SafeOutputsConfig{
SubmitPullRequestReview: &SubmitPullRequestReviewConfig{
BaseSafeOutputConfig: BaseSafeOutputConfig{},
SafeOutputTargetConfig: SafeOutputTargetConfig{
Target: "99",
},
},
},
wantErr: false,
},
Comment on lines +273 to +285
{
name: "invalid target for submit-pull-request-review",
config: &SafeOutputsConfig{
SubmitPullRequestReview: &SubmitPullRequestReviewConfig{
BaseSafeOutputConfig: BaseSafeOutputConfig{},
SafeOutputTargetConfig: SafeOutputTargetConfig{
Target: "invalid-value",
},
},
},
wantErr: true,
errText: "invalid target value for submit-pull-request-review: \"invalid-value\"",
},
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 3, 2026

🧪 Test Quality Sentinel completed test quality analysis.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 3, 2026

Design Decision Gate 🏗️ completed the design decision gate check.

No ADR enforcement needed: PR #36546 does not have the 'implementation' label and has 85 new lines of code in business logic directories (≤100 threshold). Neither enforcement condition is met.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 3, 2026

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 3, 2026

PR Code Quality Reviewer completed the code quality review.

@github-actions github-actions Bot mentioned this pull request Jun 3, 2026
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skills-Based Review 🧠

Applied /tdd and /diagnose — requesting changes on a formatting issue and a test coverage gap.

📋 Key Themes & Highlights

Issues

  • Test formatting: New table entries are indented one extra level — make fmt / CI will catch this.
  • Missing runtime validation test: Config-level tests are good, but there's no test confirming that omitting pull_request_number when target: "*" is active actually rejects the tool call at runtime.
  • Cryptic enhancer constraint: "Target: *." in the enhanced description doesn't guide the agent; it should mirror the actionable wording already added to the tool schema.

Positive Highlights

  • ✅ Clean parity fix — submit_pull_request_review now aligns with sibling PR tools (create_pull_request_review_comment, reply_to_pull_request_review_comment).
  • ✅ Both JSON copies updated in lockstep — easy to miss, good discipline.
  • ✅ Validation config change is minimal and pattern-matched (OptionalPositiveInteger for pull_request_number, bounded string for repo).
  • ✅ Schema updated to match the new fields — no drift between contract and implementation.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · sonnet46 1.2M

@@ -246,6 +246,43 @@ func TestValidateSafeOutputsTarget(t *testing.T) {
},
wantErr: false,
},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/tdd] The new test cases are indented one extra level (3 tabs) compared to the surrounding table entries (2 tabs), which will fail go fmt / CI formatting check.

💡 Fix

Align the new entries with the existing pattern:

		{
			name: "valid wildcard target for submit-pull-request-review",
			...
		},

Run make fmt to auto-fix.

@@ -246,6 +246,43 @@ func TestValidateSafeOutputsTarget(t *testing.T) {
},
wantErr: false,
},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/tdd] The tests validate that the config accepts wildcard/numeric/invalid targets, but there's no test covering the runtime check: when target: "*" is active and the agent omits pull_request_number from the tool call, the call should be rejected. Without this regression test the enforcement path is untested.

💡 Suggested test shape
{
    name: "wildcard target requires pull_request_number in tool call",
    // Set up config with target: "*"
    // Call validateToolOutput without pull_request_number
    // Expect wantErr: true with errText matching "pull_request_number is required"
},

This directly mirrors the existing coverage for create_pull_request_review_comment (if it exists), and makes the fix self-documenting.

if templatableIntValue(config.Max) > 0 {
constraints = append(constraints, fmt.Sprintf("Maximum %d review(s) can be submitted.", templatableIntValue(config.Max)))
}
if config.Target != "" {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/diagnose] "Target: *." is cryptic guidance for an agent. When target: "*" is set the agent must supply pull_request_number — the description should say so explicitly, consistent with the tool schema description that was just updated.

💡 Suggested wording
if config.Target == "*" {
    constraints = append(constraints, "Target: any PR — you must supply pull_request_number in each call.")
} else if config.Target != "" {
    constraints = append(constraints, fmt.Sprintf("Target: PR #%s.", config.Target))
}

This matches the level of guidance already added to the tool schema description.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 3, 2026

🧪 Test Quality Sentinel Report

Test Quality Score: 90/100 — Excellent

Analyzed 5 test group(s): 5 design, 0 implementation, 0 guideline violation(s). Minor test inflation detected (both test files exceed the 2:1 line-ratio threshold vs production code).

📊 Metrics & Test Classification (5 tests analyzed)
Metric Value
New/modified tests analyzed 5
✅ Design tests (behavioral contracts) 5 (100%)
⚠️ Implementation tests (low value) 0 (0%)
Tests with error/edge cases 5 (100%)
Duplicate test clusters 0
Test inflation detected Yes (both test files)
🚨 Coding-guideline violations 0

Test Classification Details

Test File Classification Issues Detected
TestValidateSafeOutputsTarget (3 new rows for submit-pull-request-review) pkg/workflow/safe_outputs_target_validation_test.go ✅ Design None — covers valid wildcard, valid numeric, and invalid target values
TestValidateTargetValue pkg/workflow/safe_outputs_target_validation_test.go ✅ Design None — 13 cases including empty, GitHub expression, negative, zero, float, leading-zeros
TestContainsExpressionForTargetValidation pkg/workflow/safe_outputs_target_validation_test.go ✅ Design None — 10 cases including incomplete, wrong-order, empty expression
TestEnhanceToolDescriptionSubmitPullRequestReviewTarget pkg/workflow/tool_description_enhancer_test.go ✅ Design Happy-path only; no test for empty/nil target
TestEnhanceToolDescriptionSubmitPullRequestReviewTargetRepo pkg/workflow/tool_description_enhancer_test.go ✅ Design Happy-path only

Language Support

Tests analyzed:

  • 🐹 Go (*_test.go): 5 tests — unit (//go:build !integration)
  • 🟨 JavaScript (*.test.cjs, *.test.js): 0 tests

Verdict

Check passed. 0% of new tests are implementation tests (threshold: 30%). The table-driven tests in safe_outputs_target_validation_test.go are thorough and well-structured. Note: both test files have a test-to-production line ratio above 2:1 (safe_outputs_target_validation_test.go ~9:1, tool_description_enhancer_test.go ~4:1), which is expected for validation code with comprehensive table-driven tests.

📖 Understanding Test Classifications

Design Tests (High Value) verify what the system does:

  • Assert on observable outputs, return values, or state changes
  • Cover error paths and boundary conditions
  • Would catch a behavioral regression if deleted
  • Remain valid even after internal refactoring

Implementation Tests (Low Value) verify how the system does it:

  • Assert on internal function calls (mocking internals)
  • Only test the happy path with typical inputs
  • Break during legitimate refactoring even when behavior is correct
  • Give false assurance: they pass even when the system is wrong

Goal: Shift toward tests that describe the system's behavioral contract — the promises it makes to its users and collaborators.

🧪 Test quality analysis by Test Quality Sentinel · sonnet46 1.1M ·

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Test Quality Sentinel: 90/100. Test quality is excellent — 0% of new tests are implementation tests (threshold: 30%). All 5 new/modified test groups are design tests with comprehensive edge-case coverage.

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two blocking issues must be fixed before merge.

### Findings

1. CI will fail — test indentation (safe_outputs_target_validation_test.go)
The three new test entries open at 3-tab indent; every existing entry in the slice opens at 2-tab. gofmt normalises this, so the CI formatting gate (make fmt + diff) will fail immediately. Run make fmt before pushing.

2. Missing addRepoParameterIfNeeded case for submit_pull_request_review (safe_outputs_tools_repo_params.go)
computeRepoParamForTool("submit_pull_request_review", ...) always returns nil because there is no case for this tool. Consequence: when a workflow configures submit-pull-request-review with allowed-repos or target-repo: "*", agents receive no context-aware repo description — they cannot determine which repositories are valid targets. Every other cross-repo tool (e.g. create_pull_request_review_comment) has the corresponding case.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • proxy.golang.org

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "proxy.golang.org"

See Network Configuration for more information.

🔎 Code quality review by PR Code Quality Reviewer · sonnet46 308.3K

},
wantErr: false,
},
{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test cases indented one extra level — make fmt (and CI) will fail.

💡 Details

New test entries (lines 249–287) open their { at three tabs while all existing test entries in this slice open at two tabs. gofmt normalises composite-literal indentation, so the CI formatting gate (make fmt + diff) will detect a mismatch and fail.

Fix: remove the extra leading tab from the three new test cases, or run make fmt before committing.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 3, 2026

@copilot review all comments and address unresolved review feedback. Please refresh the branch and rerun checks after applying fixes.

Generated by 👨‍🍳 PR Sous Chef · gpt54mini 6.3M ·

@pelikhan
Copy link
Copy Markdown
Collaborator

pelikhan commented Jun 3, 2026

@copilot merge main and recompile
Review all comments

Copilot AI and others added 3 commits June 3, 2026 03:35
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…eld-support

# Conflicts:
#	.github/workflows/grumpy-reviewer.lock.yml

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jun 3, 2026

@copilot merge main and recompile
Review all comments

Done in commits 44fbdd9 and fd09658: merged latest main, resolved the merge conflict, recompiled workflows, and re-ran lint plus the target-validation test.

@pelikhan
Copy link
Copy Markdown
Collaborator

pelikhan commented Jun 3, 2026

@copilot ensure implementation is complete all the way to JavaScript

Copilot AI and others added 2 commits June 3, 2026 04:28
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jun 3, 2026

@copilot ensure implementation is complete all the way to JavaScript

Implemented through JavaScript coverage in commits 651b296 and fd310ee. I updated the JS validator test config for submit_pull_request_review to include pull_request_number/repo and added tests for both fields, each field individually, neither field, and invalid PR number values.

@pelikhan pelikhan merged commit 0403f8a into main Jun 3, 2026
39 checks passed
@pelikhan pelikhan deleted the copilot/add-target-field-support branch June 3, 2026 04:49
github-actions Bot added a commit that referenced this pull request Jun 3, 2026
…rget

- Add `license` field to the repository package manifest specification
  (table row + section), matching the schema field added in #36583.
- Document the `pull_request_number`/`repo` requirement for
  submit-pull-request-review when target: "*", matching the support
  added in #36546.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

3 participants