Skip to content

fix(domain): preserve retryable capability failures through redaction - #2494

Merged
morluto merged 1 commit into
morluto:mainfrom
XiaoBinGan:fix/redaction-retryable-preservation
Oct 13, 2026
Merged

morluto merged 1 commit into
morluto:mainfrom
XiaoBinGan:fix/redaction-retryable-preservation

Conversation

@XiaoBinGan

Copy link
Copy Markdown
Contributor

Explicit-value redaction rebuilds each error from its fields, and AnalysisCapabilityUnavailableError.retryable was missing from the rebuild. Redaction therefore reset a documented semantic field to false.

Summary

redactExplicitFailure reconstructs typed failures field by field so that explicit sensitive literals are removed while the error stays projected as the same code. For AnalysisCapabilityUnavailableError it carried providerId, operation, reason and userMessage, but not retryable:

return new AnalysisCapabilityUnavailableError(
  error.providerId, error.operation, text(error.reason),
  {
    ...context,
    ...(error.userMessage === undefined ? {} : { userMessage: text(error.userMessage) }),
  },
);

retryable is a semantic field with its own doc comment ("Incomplete cleanup must settle before the operation can be retried") and it drives projectAnalysisError, the error category, and the remediation text the caller is shown. Because the constructor defaults it to false, redacting any capability failure silently converted a transient condition into a permanent one: the remediation changed from "Review details.reason, then retry the same analysis after the condition clears." to "This analysis is unavailable for the current target. Choose another analysis or target." The field was recently added to the error class, and the existing redaction test for this class covers userMessage only, so the loss was uncovered.

Change and scope

explicitSensitiveFailure passes the field through with the same conditional-spread shape already used for userMessage:

...(error.retryable ? { retryable: true } : {}),

Passing it is safe by construction: the constructor computes options?.retryable === true && !this.cleanupIncomplete, and cleanup is already part of the reconstructed context, so a value that was true before redaction stays true and a value that was false stays absent. No other class, projection, presentation or remediation path changes, and no new representation or wrapper is introduced.

Related cleanup that remains

The same rebuild covers AnalysisCancelledError, AnalysisTimeoutError, AnalysisAccessDeniedError, AnalysisArtifactChangedError, AnalysisInputError, AnalysisOutputError, AnalysisCapabilityUnavailableError, AnalysisResourceConstraintError, ProviderCleanupError and ProviderAdapterError; AnalysisUnsupportedTargetError is not in the chain and falls through to return error, so its path, reason and remediationAction are returned unredacted. I did not change that here: extending redaction to a class it has never covered is a privacy/evidence decision rather than a field-preservation fix, and the function's doc scopes it to "common acquisition/decoder failures". I am flagging it rather than folding it in.

Contract and boundary impact

  • Semantic owner and earliest changed stage: typed error reconstruction during explicit-value redaction. Projection, presentation, remediation selection, the error classes and every producer are untouched.
  • CLI and MCP/tool-catalog contract: no tool name, command, input field, output schema or error code changes. retryable keeps its documented meaning for redacted and unredacted failures alike; only a redacted transient capability failure no longer reports itself as permanent.
  • Provider, target-format or platform compatibility: none — provider-neutral error modeling.
  • Evidence, artifact, provenance or reconstruction contract: redaction still removes every explicit literal it removed before; the test asserts the redacted projection does not contain the literal. No Evidence value changes.
  • Process execution, authorization, cleanup or containment impact: none. The change does not alter cleanup tracking; it preserves the flag that reports whether cleanup already settled.
  • Generated metadata, package or installation impact: none.

Evidence and regression coverage

A new case in explicitSensitiveFailure.test.ts, "preserves a retryable capability failure through explicit-value redaction", builds a retryable capability failure whose reason embeds an explicit literal, asserts the unredacted projection is already retryable, then asserts the redacted error instance and its projection are both still retryable and still free of the literal.

Before the change it failed with expected false to be true; the 18 existing cases in that file passed throughout, which is why the field was uncovered. Verification on macOS 26.5.1 arm64 with Node.js 24.18.0 and npm 11.16.0, based on bb54082:

  • npm run test:focused over the redaction suite, the error-projection suite, the access-denied suite and the browser capture-failure suite: 66 passed, 0 failed.
  • npm run check:fast: passed.
  • npm run verify:test-discovery: all 1015 test files discovered exactly once.

Unavailable coverage: no Windows or Linux run and no real-provider run — the change is provider-neutral domain logic and the regression input is a constructed error.

redactExplicitFailure rebuilds each typed failure field by field so explicit
literals are removed while the projected code stays the same. The rebuild for
AnalysisCapabilityUnavailableError carried providerId, operation, reason and
userMessage but not retryable, and the constructor defaults that field to false.
Redacting a transient capability failure therefore made it permanent and changed
the remediation shown to the caller.

Pass the field through with the same conditional-spread shape used for
userMessage. The constructor recomputes retryable from cleanupIncomplete, and
cleanup is already part of the reconstructed context, so a value that was true
before redaction stays true and a false value stays absent.

Verified with 66 error projection, access-denied, redaction and capture-failure
tests, check:fast and verify:test-discovery on macOS arm64. The regression test
failed with "expected false to be true" before the change.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

@greptileai review

@greptile-apps

greptile-apps Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5 Tier: plus

[Medium impact] This PR appears safe to merge.

Summary

This PR preserves retryable when redactExplicitFailure rebuilds an AnalysisCapabilityUnavailableError, so removing sensitive text no longer changes the caller’s retry advice.

  • Redacted capability failures keep their retryable status.

Reviews (1) · Last reviewed commit: "fix(domain): preserve retryable capabili..." · Reviewed by Greptile

@morluto
morluto merged commit d73ed6f into morluto:main Oct 13, 2026
35 checks passed
@morluto morluto mentioned this pull request Oct 13, 2026
3 tasks done
@morluto morluto added bug Something isn't working area: domain Domain logic, errors, and pure functions labels Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: domain Domain logic, errors, and pure functions bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants