Skip to content

[Safe Outputs Conformance] REQ-002: Complete add_labels and remove_labels specification sections - #77677

Merged
pelikhan merged 1 commit into
mainfrom
conformance/req-002-label-types-d76fa4be825557b1
Nov 14, 2026
Merged

pelikhan merged 1 commit into
mainfrom
conformance/req-002-label-types-d76fa4be825557b1

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Conformance Check Failure

Check ID: REQ-002
Severity: MEDIUM
Category: Specification

Problem Description

scripts/check-safe-outputs-conformance.sh reports REQ-002 failures for 27 safe output types whose specification sections lack required subsections. This PR addresses add_labels and remove_labels (each had 1/5 sections), which share target-authorization rules and handler structure. The other 25 types are left for separate PRs so each can be checked against its own handler.

Affected Components

  • Files: docs/src/content/docs/specs/safe-outputs-specification.md
  • Handlers consulted: actions/setup/js/add_labels.cjs, actions/setup/js/remove_labels.cjs, pkg/workflow/add_labels.go, pkg/workflow/remove_labels.go, pkg/workflow/js/safe_outputs_tools.json
🔍 Current vs Expected Behavior

Current Behavior

Both type sections had only Required Permissions (plus notes and target authorization rules). They lacked MCP Tool Schema, Operational Semantics, Configuration Parameters and Security Requirements.

Expected Behavior

Each type documents all five sections, derived from the implementation.

Remediation Steps

  1. Added an abbreviated MCP Tool Schema for each type, matching safe_outputs_tools.json.
  2. Added Operational Semantics from the handlers: target resolution, required-labels/required-title-prefix filters, max-labels, validation, staged mode, create-if-missing, issue-intent GraphQL path and PR fallback, per-label removal with 404 tolerance, and partial failure reporting.
  3. Added Configuration Parameters and Security Requirements.
  4. Corrected Default Max from 3 to 5 for both types, matching DefaultMax: 5 / defaultMaxAddLabelsCalls = 5 in the code.

Verification

Validation actually run (documentation-only change, so Go/JS tests were not run):

bash scripts/check-safe-outputs-conformance.sh
  • Before: Medium Failures = 27 (REQ-002 listed add_labels 1/5 and remove_labels 1/5).
  • After: Medium Failures = 25; neither type is listed. Critical = 0, High = 0.
  • 25 REQ-002 failures remain for other types (for example update_pull_request, close_pull_request, assign_to_user, create_project). Those are not addressed here.

References

  • Safe Outputs Specification: docs/src/content/docs/specs/safe-outputs-specification.md
  • Conformance Checker: scripts/check-safe-outputs-conformance.sh
  • Run ID: 43562606213
  • Date: 2026-11-14

🤖 Generated with [Claude Code]((claude.com/redacted)

Generated by ✅ Daily Safe Outputs Conformance Checker · claude · routed: sonnet55 high · ~35 AIC · ⌖ ~2 AIC · ⊞ 5.8K · ◷

  • expires on Nov 14, 2026, 9:46 PM UTC-08:00

@pelikhan
pelikhan marked this pull request as ready for review November 14, 2026 05:50
Copilot AI adaptive review requested due to automatic review settings November 14, 2026 05:50
@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

🧪 Test quality analysis by Test Quality Sentinel · copilot · routed: haiku55 xhigh · ~2 AIC · ⌖ ~2 AIC · ◇ ~1 AIC · ⊞ 7.3K · ◷

@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ PR Specification Reviewer completed successfully!

PR Specification Reviewer

Outcome: reported_action

The agent completed and reported one or more actions. The no-op output is a completion signal, not a claim that no action was taken.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated by PR Specification Reviewer for #77677 · copilot · gpt56 · ~5 AIC · ⌖ ~1 AIC · ◇ ~1 AIC · ⊞ 1.6K · ◷

Copilot AI left a comment

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.

🟡 Changes recommended

The specification contains an unresolved security-critical fail-open parsing discrepancy plus additional documented behavior mismatches for validation ordering, 404 handling, and label limits.

4 open issues
What changed in this PR

This documentation-only PR completes the safe-output specification coverage for add_labels and remove_labels, aligning their documented schemas, operational behavior, configuration, permissions, security requirements, and target authorization with the handlers.

Changes:

  • Added MCP schemas and handler-derived operational semantics for both label operations.
  • Documented configuration, filtering, staged execution, intent metadata, label creation/removal, and security requirements.
  • Corrected the documented default operation limit from 3 to 5 for both types.
File Description
docs/​src/​content/​docs/​specs/​safe-outputs-specification.md Completes the add_labels and remove_labels specification sections with schemas, behavior, configuration, permissions, target authorization, and security documentation.

Review effort: Lite (dynamic)

Comment on lines +4507 to +4511
**Security Requirements**:

- Label names MUST undergo sanitization and be validated against `allowed` and `blocked` before any API call
- Cross-repository targets MUST be validated against the `allowed-repos` allowlist
- The target MUST be selected only according to the Target Authorization rules, enforced at runtime
4. **Validation**: Labels are sanitized, de-duplicated, and checked against `allowed` and `blocked`; the number of labels MUST NOT exceed the configured `max`. The item succeeds with no labels removed when none remain valid.
5. **Staged Mode**: In staged mode the handler previews the labels it would remove and performs no mutation.
6. **Per-Label Removal**: Labels are removed one at a time because the GitHub API has no bulk-removal endpoint.
7. **Missing Labels**: A label that is not present on the target (HTTP 404 or "Label does not exist") is skipped silently and is not a failure.

**Security Requirements**:

- Label names MUST undergo sanitization and be validated against `allowed` and `blocked` before any API call
1. **Target Resolution**: The target issue or pull request is resolved per the Target Authorization rules below. When no item number can be resolved, the item fails without calling the GitHub API.
2. **Filter Evaluation**: When `required-labels` or `required-title-prefix` is configured, the handler MUST fetch the target and skip the operation if the target lacks any required label or its title does not start with the required prefix.
3. **Empty Input**: An empty `labels` list fails the item with a message listing the allowed labels when an allowlist is configured.
4. **Validation**: Labels are sanitized, de-duplicated, and checked against `allowed` and `blocked`; the number of labels MUST NOT exceed the configured `max`. The item succeeds with no labels removed when none remain valid.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reviewed head d18ddc1 against the Safe Outputs Specification (sections 7.0.3, add_labels AL-001–AL-005, remove_labels RML-001–RML-005).

Blocking findings:

  1. The add_labels MCP schema omits the functional repo field despite compiled schema/handler support and advertised cross-repository support. With additionalProperties=false, the contract is inaccurate.
  2. The new add_labels security requirement says label validation occurs before any API call, but the handler fetches the target for required-label/title filters before validation.

No specification synchronization was applied; the documented contract must be corrected or implementation evidence/changes supplied.

Generated by PR Specification Reviewer for #77677 · copilot · gpt50 · ~5 AIC · ⌖ ~1 AIC · ⊞ 1.6K
Comment /review-specs to run again

},
"description": "Labels to add. Each entry is a label name string or an object with a name plus optional issue-intent metadata."
},
"item_number": {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

REQUEST_CHANGES: The documented MCP schema omits the repo property that is accepted by the compiled add_labels tool schema and by the handler (AddLabelsMessage.repo). Because additionalProperties is false, this specification would incorrectly declare cross-repository requests invalid while the same section advertises cross-repository support. Please include repo (with its owner/repo description and allowlist behavior) in this schema; the provenance note does not cover functional fields.


**Security Requirements**:

- Label names MUST undergo sanitization and be validated against `allowed` and `blocked` before any API call

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

REQUEST_CHANGES: This new MUST is stronger than the implemented behavior and is not met: when required-labels or required-title-prefix is configured, add_labels.cjs fetches the target via issues.get before it calls validateLabels and checks allowed/blocked (the filter block precedes validation). Either change the contract to require validation before mutation/API writes, or provide implementation evidence that no API call occurs until label validation completes; do not document an unmet security guarantee as conformance.

@github-actions

Copy link
Copy Markdown
Contributor Author

Comment Memory

Peek at saved memory (spec-review-history)
{"id":"ldg-f5a1bb87-dc01-4490-a082-00c2c56cbe0c","parents":[],"payload":{"id":"ldg-ed659e8d-d9d3-46f4-9d04-b6d72b0e4b6c","operation":"append","value":{"finding_count":2,"head_sha":"d18ddc1790c319728bcba83a2896a7b0fb712603","outcome":"regression"}},"sha":"sha256:86970f500dc7c13f41eca00909d645106c793260480beb95a1c7e50b51d3e99d","timestamp":"2026-11-14T06:01:04.522Z","type":"ledger_append","version":1}
History

@pelikhan
pelikhan merged commit fa06189 into main Nov 14, 2026
41 checks passed
@pelikhan
pelikhan deleted the conformance/req-002-label-types-d76fa4be825557b1 branch November 14, 2026 14:14
@github-actions

Copy link
Copy Markdown
Contributor Author

🎉 This pull request is included in a new release.

Release: v1.3.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants