Repository navigation
[Safe Outputs Conformance] USE-001: Use standardized error codes in safe-output modules - #79448
Conversation
|
✅ PR Code Quality Reviewer completed the code quality review. Caution agentic threat detected DetailsPotential security threats were detected in the agent output. Detected threat types: prompt injection. Review the workflow run logs for details. PR Code Quality ReviewerOutcome: 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.
|
|
✅ Test Quality Sentinel completed test quality analysis. Test Quality SentinelOutcome: 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.
|
|
✅ PR Specification Reviewer completed successfully!
|
|
✅ Ponytail Reviewer completed successfully! Ponytail ReviewerOutcome: 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.
|
|
🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅
|
There was a problem hiding this comment.
Reviewed head 11eda5266a3745142fce1ea23c99dfac10bef12f against Safe Outputs MCP Gateway Specification v1.31.0, §9.5 (Error Code Catalog), including EH1–EH3.
Blocking finding: the PR prefixes failures with ERR_PERMISSION/ERR_VALIDATION/ERR_SYSTEM, but §9.5 requires the E001–E010 catalog and the specified structured error fields. The conformance checker’s USE-001 heuristic does not establish formal contract conformance. See the inline comment on actions/setup/js/call_workflow.cjs:117; the same issue applies to the other edited handlers. Please map errors to the normative catalog/shape, or obtain an approved design change and synchronize the specification with executable conformance evidence.
Coverage: reviewed the captured metadata, complete changed-file list, prefetched diff, current specification, and PR state. The local base object was unavailable, so no additional base-tree comparison or tests were run.
Generated by PR Specification Reviewer for #79448 · copilot · gpt50 · ~3 AIC · ⌖ ~1 AIC · ⊞ 1.7K
Comment /review-specs to run again
| const implementation = config["workflow-implementations"]?.[workflowName]; | ||
| if (!implementation || typeof implementation !== "object" || ["path", "revision", "repository_id"].some(key => typeof implementation[key] !== "string" || !implementation[key])) { | ||
| throw new Error("Safe-output authorization requires a trusted workflow launch implementation"); | ||
| throw new Error(ERR_PERMISSION + ": Safe-output authorization requires a trusted workflow launch implementation"); |
There was a problem hiding this comment.
The new prefix does not satisfy the applicable Safe Outputs Specification §9.5 error-code contract. That section requires the E001–E010 catalog (and the defined structured error fields); ERR_PERMISSION is not one of those codes. The same mismatch is introduced across the other edited handlers, so USE-001 passing is weaker than the normative contract. Please map these failures to the applicable catalog codes/response shape, or provide an approved design change plus synchronized specification and conformance tests before claiming standardization.
|
Caution agentic threat detected DetailsPotential security threats were detected in the agent output. Detected threat types: prompt injection. Review the workflow run logs for details. Comment MemoryPeek at saved memory (pr-code-quality-reviewer)Note This comment is managed by comment memory.Expand the saved memory block to view or edit the persistent context for this thread.
|
There was a problem hiding this comment.
Caution
agentic threat detected
Threat detection flagged this output in warn mode. Manual review is REQUIRED before any follow-up automation.
Details
Potential security threats were detected in the agent output. Detected threat types: prompt injection.
Review the workflow run logs for details.
Found two actionable error-code regressions in push_ledger_changes.cjs.
Findings
Details
- The prefixed artifact-validation error no longer matches its rethrow guard and is reported as a generic read failure.
- A failed ledger push is classified as validation instead of an operational/API failure.
🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~3 AIC · ⌖ ~2 AIC · ⊞ 1.6K
Comment /review to run again
| if (!stat.isFile() || stat.size > MAX_TRANSACTION_BYTES) throw new TypeError(ERR_VALIDATION + ": Invalid ledger transaction artifact"); | ||
| artifact = JSON.parse(fs.readFileSync(fd, "utf8")); | ||
| } catch (error) { | ||
| if (error instanceof TypeError && error.message === "Invalid ledger transaction artifact") throw error; |
There was a problem hiding this comment.
The new prefix makes the validation error rewrap as a generic read failure, so callers lose the specific Invalid ledger transaction artifact diagnostic.
💡 Preserve the validation branch
error.message is now ERR_VALIDATION: Invalid ledger transaction artifact, but this guard still compares against the old unprefixed string. Update the comparison to the prefixed message (or use a dedicated error type) and add a regression assertion for this path.
| : undefined, | ||
| }); | ||
| if (pushed === false) throw new Error(`Failed to persist records to ${branchName}`); | ||
| if (pushed === false) throw new Error(`${ERR_VALIDATION}: Failed to persist records to ${branchName}`); |
There was a problem hiding this comment.
This change labels a failed ledger push as ERR_VALIDATION, even though the failure is a persistence/remote operation error rather than invalid input.
💡 Use an operational error code
A false validation classification can mislead monitoring and retry/triage logic into treating transient repository or filesystem failures as caller mistakes. Use ERR_SYSTEM (or an API-specific code) for the pushed === false failure and reserve ERR_VALIDATION for rejected data.
Comment MemoryPeek at saved memory (spec-review-history)History |
Comment MemoryPeek at saved memory (review-history)History |
There was a problem hiding this comment.
🟡 Changes recommended
Active issues remain because the change breaks an existing exact-message test, causes a special-case check to stop matching, misclassifies persistence failures as validation errors, and leaves some runtime errors without standardized codes.
4 open issues
What changed in this PR
This PR standardizes machine-readable error prefixes across Safe Outputs, ledger, authorization, and work-queue modules, while documenting the telemetry-only exemption for otlp_metrics.cjs.
Changes:
- Adds
ERR_PERMISSION,ERR_VALIDATION, andERR_SYSTEMprefixes to affected errors and fallback failures. - Documents the
USE-001exemption for the OTLP metrics builder. - Review identified stale error matching, incorrect persistence classification, an exact-message test mismatch, and incomplete
core.setFailedprefixing inpush_ledger_changes.cjs.
| File | Description |
|---|---|
| actions/setup/js/work_queue_prepare_claim_adapter.cjs | Prefixes claim-adapter preparation validation errors with ERR_VALIDATION. |
| actions/setup/js/safe_output_execution.cjs | Prefixes missing trusted invocation-context errors with ERR_PERMISSION. |
| actions/setup/js/safe_output_authorization_gate.cjs | Prefixes authorization-gate failures with ERR_PERMISSION. |
| actions/setup/js/push_ledger_changes.cjs | Adds standardized codes to transaction, persistence, and fallback errors. |
| actions/setup/js/otlp_metrics.cjs | Documents the telemetry-only exemption from USE-001. |
| actions/setup/js/comment_memory_ledger.cjs | Prefixes comment-backed ledger validation and publication errors. |
| actions/setup/js/call_workflow.cjs | Prefixes protected workflow-launch authorization errors with ERR_PERMISSION. |
Review effort: Lite (adaptive)
| if (error instanceof Error && "code" in error && error.code === "ENOENT") { | ||
| const artifactName = process.env.GH_AW_LEDGER_TRANSACTIONS_ARTIFACT_NAME || "ledger transaction artifact"; | ||
| throw new Error(`Missing validated ledger transaction artifact at ${resolved}; ensure safe_outputs uploads ${artifactName} before push_ledger_changes`, { cause: error }); | ||
| throw new Error(`${ERR_VALIDATION}: Missing validated ledger transaction artifact at ${resolved}; ensure safe_outputs uploads ${artifactName} before push_ledger_changes`, { cause: error }); |
There was a problem hiding this comment.
Updated the exact assertion for the ERR_VALIDATION prefix. Commit b87fa14.
| if (!stat.isFile() || stat.size > MAX_TRANSACTION_BYTES) throw new TypeError(ERR_VALIDATION + ": Invalid ledger transaction artifact"); | ||
| artifact = JSON.parse(fs.readFileSync(fd, "utf8")); | ||
| } catch (error) { | ||
| if (error instanceof TypeError && error.message === "Invalid ledger transaction artifact") throw error; |
There was a problem hiding this comment.
Updated the special-case comparison and added regression coverage for invalid artifacts. Commit b87fa14.
| : undefined, | ||
| }); | ||
| if (pushed === false) throw new Error(`Failed to persist records to ${branchName}`); | ||
| if (pushed === false) throw new Error(`${ERR_VALIDATION}: Failed to persist records to ${branchName}`); |
There was a problem hiding this comment.
Changed both persistence failure paths to ERR_SYSTEM. Commit b87fa14.
| if (require.main === module) { | ||
| main().catch(error => { | ||
| core.setFailed(error instanceof Error ? error.message : "Ledger persistence failed"); | ||
| core.setFailed(error instanceof Error ? error.message : `${ERR_SYSTEM}: Ledger persistence failed`); |
There was a problem hiding this comment.
The CLI catch now preserves existing ERR_*/E0xx codes and adds ERR_SYSTEM for unclassified errors. Commit b87fa14.
There was a problem hiding this comment.
Skills-Based Review 🧠
Applied /diagnosing-bugs and /grill-with-docs. Requesting changes because one prefix change breaks existing error handling.
Blocking: push_ledger_changes.cjs:37 compares error.message to the unprefixed text. The prefix added at line 34 means that check never matches, so the specific error is replaced by the generic read error. I confirmed this by running readTransactions on the PR head against a non-file artifact path.
📋 Key Themes & Highlights
Key Themes
- Regression: the exact-match guard at line 37 no longer matches after the prefix change.
- Taxonomy drift: several I/O and remote-push failures are tagged
ERR_VALIDATION.error_codes.cjsreserves that for input validation, soERR_SYSTEM,ERR_API, orERR_PERMISSIONfit better in several places. - Fallback gap: the
ERR_SYSTEMfallback at line 394 only covers non-Error throws, which almost never happen.
Positive Highlights
- ✅ Messages keep their original text after the code prefix, so substring-based tests still match.
- ✅ The
@safe-outputs-exempt USE-001annotation onotlp_metrics.cjsis documented and matches the existing exemption style. - ✅ No added line exceeds the 240-character printWidth.
Validation Gap
The Vitest suites were not run. npm ci in actions/setup/js failed on a TLS certificate error from the package proxy, so the test results in the PR description are unverified. Please run cd actions/setup/js && npm run test:js for the affected files, and fix the line 37 guard first.
@copilot please address the review comments above.
🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~9 AIC · ⌖ ~2 AIC · ⊞ 6.7K
Comment /matt to run again
| if (!stat.isFile() || stat.size > MAX_TRANSACTION_BYTES) throw new TypeError(ERR_VALIDATION + ": Invalid ledger transaction artifact"); | ||
| artifact = JSON.parse(fs.readFileSync(fd, "utf8")); | ||
| } catch (error) { | ||
| if (error instanceof TypeError && error.message === "Invalid ledger transaction artifact") throw error; |
There was a problem hiding this comment.
[/diagnosing-bugs] Regression: this guard compares error.message against the old unprefixed text, but line 34 now throws ERR_VALIDATION: Invalid ledger transaction artifact. The guard never matches, so the specific error is swallowed and replaced by the generic read error at line 42.
💡 Suggested fix
Compare against the prefixed text, or avoid matching on message text entirely (for example, a dedicated error marker checked with instanceof):
if (error instanceof TypeError && error.message === `${ERR_VALIDATION}: Invalid ledger transaction artifact`) throw error;Verified on the PR head: a non-file artifact path now reports Failed to read validated ledger transaction artifact. With the fix above, the specific error propagates.
@copilot please address this.
| throw new Error(`${ERR_VALIDATION}: Missing validated ledger transaction artifact at ${resolved}; ensure safe_outputs uploads ${artifactName} before push_ledger_changes`, { cause: error }); | ||
| } | ||
| throw new Error("Failed to read validated ledger transaction artifact", { cause: error }); | ||
| throw new Error(ERR_VALIDATION + ": Failed to read validated ledger transaction artifact", { cause: error }); |
There was a problem hiding this comment.
[/grill-with-docs] Misclassified: a failed read of the transaction artifact is an I/O failure, not input validation. The same applies to the ENOENT branch at line 40. Per the taxonomy in error_codes.cjs, these should use ERR_SYSTEM (or ERR_NOT_FOUND for the missing-artifact case). Dashboards keyed on ERR_VALIDATION would otherwise count handoff and I/O problems as bad input.
@copilot please address this.
| : undefined, | ||
| }); | ||
| if (pushed === false) throw new Error(`Failed to persist records to ${branchName}`); | ||
| if (pushed === false) throw new Error(`${ERR_VALIDATION}: Failed to persist records to ${branchName}`); |
There was a problem hiding this comment.
[/grill-with-docs] A failed remote push is not a validation error. Use ERR_API if the failure comes from the GitHub API, otherwise ERR_SYSTEM. Line 386 (Failed to write ledger persistence result) is an I/O failure and should use ERR_SYSTEM for the same reason.
@copilot please address this.
| const credential = { kind: process.env.GH_AW_COMMENT_MEMORY_TOKEN_SOURCE === "github_actions" ? "github_token" : "authenticated" }; | ||
| const selectedToken = process.env.GH_AW_COMMENT_MEMORY_TOKEN; | ||
| if (credential.kind !== "authenticated" && !selectedToken) throw new Error("Comment-backed ledger installation identity requires a bound token"); | ||
| if (credential.kind !== "authenticated" && !selectedToken) throw new Error(ERR_VALIDATION + ": Comment-backed ledger installation identity requires a bound token"); |
There was a problem hiding this comment.
[/grill-with-docs] Credential checks are tagged ERR_VALIDATION, but error_codes.cjs reserves ERR_PERMISSION for authorization and permission failures. Lines 72 and 76 (missing bound token, token mismatch) should use ERR_PERMISSION. Line 80 wraps every failure from resolveDispatchCredentialPrincipal, including API errors, so it should use ERR_PERMISSION for credential rejections and ERR_API otherwise.
@copilot please address this.
| if (require.main === module) { | ||
| main().catch(error => { | ||
| core.setFailed(error instanceof Error ? error.message : "Ledger persistence failed"); | ||
| core.setFailed(error instanceof Error ? error.message : `${ERR_SYSTEM}: Ledger persistence failed`); |
There was a problem hiding this comment.
[/diagnosing-bugs] Low: the ERR_SYSTEM prefix here only applies when a non-Error value is thrown, which is essentially never. Error instances keep their message unchanged, so unprefixed errors reaching this handler still have no code. Consider prefixing the Error path too, guarded so messages that already start with ERR_ are not double-prefixed.
@copilot please address this.
|
🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:
Keeping the changes focused; human review and CI get the final taste test. No merging or CI triggering. Structured data{
"completed_task": 0,
"head": "11eda5266a3745142fce1ea23c99dfac10bef12f",
"kind": "requested",
"schema_version": "1",
"state": "4dfc643dc3055050d50e14021dd35b5fc61c4b291d463d324eae86a1eb8197a2",
"work": [
"27ac911a80a91d6b02a3e07caef39b800cb632677606247471a58f9a93975854",
"39c191310065649368c4f18efc4dcedddc953856b7b7ea91e5ace1726e3e0dc6",
"670939e1210163126154c0956cb6ad621b3f3c93bc5beb60bcc712944c2a1652",
"c933f04d46e4444cdc5e66ff344019ba50a96f542b105b97026d12a06fc78e0c",
"d998da922a9118f9e076f90e15db0cad560a17a8eca784e37ddea908beca4084"
],
"workflow": "pr-sous-chef"
}
|
…es-7f47c729aae87bcb Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Merged latest |


Conformance Check Failure
Check ID: USE-001
Severity: LOW (7 findings in one category)
Category: Usability
Problem Description
The daily conformance run reported 7 modules that throw errors or call
core.setFailedwithout a standardized error code (ERR_*/E0xx).Affected Components
Remediation Implemented
error_codes.cjsand prefixed all thrown errors:ERR_PERMISSIONin the authorization/invocation-context modules (call_workflow,safe_output_authorization_gate,safe_output_execution),ERR_VALIDATIONin the ledger and claim-adapter modules. Thecore.setFailedfallback inpush_ledger_changesusesERR_SYSTEM.otlp_metrics.cjsis a telemetry payload builder (it only mentionssafe_outputas a metric attribute name), so it gets a documented@safe-outputs-exempt USE-001annotation, matching existing exemptions.Messages keep their original text after the code prefix.
Validation
bash scripts/check-safe-outputs-conformance.sh: USE-001 now passes; 0 critical/high/medium/low failures.node --checkandrequire()load of every edited module succeed.make fmt/make agent-report-progress.npm ciinactions/setup/jsfailed in this sandbox (nonode_modulescould be installed), so reviewers/CI should runcd actions/setup/js && npm run test:jsfor the affected test files. No added line exceeds the prettier printWidth of 240 (except an unwrapped comment).References
🤖 Generated with [Claude Code]((claude.com/redacted)