mirror of
https://github.com/morluto/rea.git
synced 2026-12-06 17:23:37 +08:00
fix(errors)!: make retry_class the only retry field of a target failure (#15450)
* fix(errors)!: make retry_class the only retry field of a target failure A target failure reported two retry fields: its own `retry` hint (`none | backoff | after_change`) and the `retry_class` every error carries. They mapped one to one, so readers had to reconcile both. `retry_class` is now the single owner: the target-failure table declares it directly, the projection no longer emits `retry`, the error schema no longer accepts it, and the CLI recovery rewrite reads `retry_class`. BREAKING CHANGE: target failures no longer include `retry`, and the error schema rejects it. Read `retry_class` instead: `backoff` is `same_call`, `after_change` is `change_first` and `none` is `never`. * test(errors): readers reject the removed target-failure retry field
This commit is contained in:
@@ -26,10 +26,6 @@
|
||||
"type": "string",
|
||||
"enum": ["same_call", "change_first", "never", "unknown_outcome"]
|
||||
},
|
||||
"retry": {
|
||||
"type": "string",
|
||||
"enum": ["none", "backoff", "after_change"]
|
||||
},
|
||||
"remediation": {
|
||||
"type": "object",
|
||||
"properties": { "action": { "type": "string", "minLength": 1 } },
|
||||
@@ -106,10 +102,6 @@
|
||||
"type": "string",
|
||||
"enum": ["same_call", "change_first", "never", "unknown_outcome"]
|
||||
},
|
||||
"retry": {
|
||||
"type": "string",
|
||||
"enum": ["none", "backoff", "after_change"]
|
||||
},
|
||||
"remediation": {
|
||||
"type": "object",
|
||||
"properties": { "action": { "type": "string", "minLength": 1 } },
|
||||
@@ -186,10 +178,6 @@
|
||||
"type": "string",
|
||||
"enum": ["same_call", "change_first", "never", "unknown_outcome"]
|
||||
},
|
||||
"retry": {
|
||||
"type": "string",
|
||||
"enum": ["none", "backoff", "after_change"]
|
||||
},
|
||||
"remediation": {
|
||||
"type": "object",
|
||||
"properties": { "action": { "type": "string", "minLength": 1 } },
|
||||
@@ -266,10 +254,6 @@
|
||||
"type": "string",
|
||||
"enum": ["same_call", "change_first", "never", "unknown_outcome"]
|
||||
},
|
||||
"retry": {
|
||||
"type": "string",
|
||||
"enum": ["none", "backoff", "after_change"]
|
||||
},
|
||||
"remediation": {
|
||||
"type": "object",
|
||||
"properties": { "action": { "type": "string", "minLength": 1 } },
|
||||
@@ -346,10 +330,6 @@
|
||||
"type": "string",
|
||||
"enum": ["same_call", "change_first", "never", "unknown_outcome"]
|
||||
},
|
||||
"retry": {
|
||||
"type": "string",
|
||||
"enum": ["none", "backoff", "after_change"]
|
||||
},
|
||||
"remediation": {
|
||||
"type": "object",
|
||||
"properties": { "action": { "type": "string", "minLength": 1 } },
|
||||
@@ -426,10 +406,6 @@
|
||||
"type": "string",
|
||||
"enum": ["same_call", "change_first", "never", "unknown_outcome"]
|
||||
},
|
||||
"retry": {
|
||||
"type": "string",
|
||||
"enum": ["none", "backoff", "after_change"]
|
||||
},
|
||||
"remediation": {
|
||||
"type": "object",
|
||||
"properties": { "action": { "type": "string", "minLength": 1 } },
|
||||
@@ -506,10 +482,6 @@
|
||||
"type": "string",
|
||||
"enum": ["same_call", "change_first", "never", "unknown_outcome"]
|
||||
},
|
||||
"retry": {
|
||||
"type": "string",
|
||||
"enum": ["none", "backoff", "after_change"]
|
||||
},
|
||||
"remediation": {
|
||||
"type": "object",
|
||||
"properties": { "action": { "type": "string", "minLength": 1 } },
|
||||
@@ -586,10 +558,6 @@
|
||||
"type": "string",
|
||||
"enum": ["same_call", "change_first", "never", "unknown_outcome"]
|
||||
},
|
||||
"retry": {
|
||||
"type": "string",
|
||||
"enum": ["none", "backoff", "after_change"]
|
||||
},
|
||||
"remediation": {
|
||||
"type": "object",
|
||||
"properties": { "action": { "type": "string", "minLength": 1 } },
|
||||
@@ -666,10 +634,6 @@
|
||||
"type": "string",
|
||||
"enum": ["same_call", "change_first", "never", "unknown_outcome"]
|
||||
},
|
||||
"retry": {
|
||||
"type": "string",
|
||||
"enum": ["none", "backoff", "after_change"]
|
||||
},
|
||||
"remediation": {
|
||||
"type": "object",
|
||||
"properties": { "action": { "type": "string", "minLength": 1 } },
|
||||
@@ -746,10 +710,6 @@
|
||||
"type": "string",
|
||||
"enum": ["same_call", "change_first", "never", "unknown_outcome"]
|
||||
},
|
||||
"retry": {
|
||||
"type": "string",
|
||||
"enum": ["none", "backoff", "after_change"]
|
||||
},
|
||||
"remediation": {
|
||||
"type": "object",
|
||||
"properties": { "action": { "type": "string", "minLength": 1 } },
|
||||
@@ -826,10 +786,6 @@
|
||||
"type": "string",
|
||||
"enum": ["same_call", "change_first", "never", "unknown_outcome"]
|
||||
},
|
||||
"retry": {
|
||||
"type": "string",
|
||||
"enum": ["none", "backoff", "after_change"]
|
||||
},
|
||||
"remediation": {
|
||||
"type": "object",
|
||||
"properties": { "action": { "type": "string", "minLength": 1 } },
|
||||
@@ -1019,10 +975,6 @@
|
||||
"type": "string",
|
||||
"enum": ["same_call", "change_first", "never", "unknown_outcome"]
|
||||
},
|
||||
"retry": {
|
||||
"type": "string",
|
||||
"enum": ["none", "backoff", "after_change"]
|
||||
},
|
||||
"remediation": {
|
||||
"type": "object",
|
||||
"properties": { "action": { "type": "string", "minLength": 1 } },
|
||||
@@ -1099,10 +1051,6 @@
|
||||
"type": "string",
|
||||
"enum": ["same_call", "change_first", "never", "unknown_outcome"]
|
||||
},
|
||||
"retry": {
|
||||
"type": "string",
|
||||
"enum": ["none", "backoff", "after_change"]
|
||||
},
|
||||
"remediation": {
|
||||
"type": "object",
|
||||
"properties": { "action": { "type": "string", "minLength": 1 } },
|
||||
@@ -1179,10 +1127,6 @@
|
||||
"type": "string",
|
||||
"enum": ["same_call", "change_first", "never", "unknown_outcome"]
|
||||
},
|
||||
"retry": {
|
||||
"type": "string",
|
||||
"enum": ["none", "backoff", "after_change"]
|
||||
},
|
||||
"remediation": {
|
||||
"type": "object",
|
||||
"properties": { "action": { "type": "string", "minLength": 1 } },
|
||||
@@ -1259,10 +1203,6 @@
|
||||
"type": "string",
|
||||
"enum": ["same_call", "change_first", "never", "unknown_outcome"]
|
||||
},
|
||||
"retry": {
|
||||
"type": "string",
|
||||
"enum": ["none", "backoff", "after_change"]
|
||||
},
|
||||
"remediation": {
|
||||
"type": "object",
|
||||
"properties": { "action": { "type": "string", "minLength": 1 } },
|
||||
@@ -1339,10 +1279,6 @@
|
||||
"type": "string",
|
||||
"enum": ["same_call", "change_first", "never", "unknown_outcome"]
|
||||
},
|
||||
"retry": {
|
||||
"type": "string",
|
||||
"enum": ["none", "backoff", "after_change"]
|
||||
},
|
||||
"remediation": {
|
||||
"type": "object",
|
||||
"properties": { "action": { "type": "string", "minLength": 1 } },
|
||||
@@ -1419,10 +1355,6 @@
|
||||
"type": "string",
|
||||
"enum": ["same_call", "change_first", "never", "unknown_outcome"]
|
||||
},
|
||||
"retry": {
|
||||
"type": "string",
|
||||
"enum": ["none", "backoff", "after_change"]
|
||||
},
|
||||
"remediation": {
|
||||
"type": "object",
|
||||
"properties": { "action": { "type": "string", "minLength": 1 } },
|
||||
@@ -1499,10 +1431,6 @@
|
||||
"type": "string",
|
||||
"enum": ["same_call", "change_first", "never", "unknown_outcome"]
|
||||
},
|
||||
"retry": {
|
||||
"type": "string",
|
||||
"enum": ["none", "backoff", "after_change"]
|
||||
},
|
||||
"remediation": {
|
||||
"type": "object",
|
||||
"properties": { "action": { "type": "string", "minLength": 1 } },
|
||||
@@ -1579,10 +1507,6 @@
|
||||
"type": "string",
|
||||
"enum": ["same_call", "change_first", "never", "unknown_outcome"]
|
||||
},
|
||||
"retry": {
|
||||
"type": "string",
|
||||
"enum": ["none", "backoff", "after_change"]
|
||||
},
|
||||
"remediation": {
|
||||
"type": "object",
|
||||
"properties": { "action": { "type": "string", "minLength": 1 } },
|
||||
@@ -1659,10 +1583,6 @@
|
||||
"type": "string",
|
||||
"enum": ["same_call", "change_first", "never", "unknown_outcome"]
|
||||
},
|
||||
"retry": {
|
||||
"type": "string",
|
||||
"enum": ["none", "backoff", "after_change"]
|
||||
},
|
||||
"remediation": {
|
||||
"type": "object",
|
||||
"properties": { "action": { "type": "string", "minLength": 1 } },
|
||||
@@ -1739,10 +1659,6 @@
|
||||
"type": "string",
|
||||
"enum": ["same_call", "change_first", "never", "unknown_outcome"]
|
||||
},
|
||||
"retry": {
|
||||
"type": "string",
|
||||
"enum": ["none", "backoff", "after_change"]
|
||||
},
|
||||
"remediation": {
|
||||
"type": "object",
|
||||
"properties": { "action": { "type": "string", "minLength": 1 } },
|
||||
@@ -1819,10 +1735,6 @@
|
||||
"type": "string",
|
||||
"enum": ["same_call", "change_first", "never", "unknown_outcome"]
|
||||
},
|
||||
"retry": {
|
||||
"type": "string",
|
||||
"enum": ["none", "backoff", "after_change"]
|
||||
},
|
||||
"remediation": {
|
||||
"type": "object",
|
||||
"properties": { "action": { "type": "string", "minLength": 1 } },
|
||||
@@ -1899,10 +1811,6 @@
|
||||
"type": "string",
|
||||
"enum": ["same_call", "change_first", "never", "unknown_outcome"]
|
||||
},
|
||||
"retry": {
|
||||
"type": "string",
|
||||
"enum": ["none", "backoff", "after_change"]
|
||||
},
|
||||
"remediation": {
|
||||
"type": "object",
|
||||
"properties": { "action": { "type": "string", "minLength": 1 } },
|
||||
|
||||
@@ -495,8 +495,8 @@ Each category says which selected file is at fault:
|
||||
- **conflict**: both files parsed but do not agree. They may come from
|
||||
different builds, either file may be damaged, or the binary's registration
|
||||
layout may be outside coverage; nothing establishes which. The refusal has
|
||||
code `input_conflict`, `details.failure_kind` `conflict`, `retry`
|
||||
`after_change` and no `recovery`. `details.inputs` lists both files as
|
||||
code `input_conflict`, `details.failure_kind` `conflict`, `retry_class`
|
||||
`change_first` and no `recovery`. `details.inputs` lists both files as
|
||||
`{ field, path }`: `path` for the metadata and `binary_path` for the binary
|
||||
(`binary` in the CLI, after its `--binary` option). `details.path` names
|
||||
the metadata. Neither file is called malformed; select a pair from the same
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
# Target failures
|
||||
|
||||
When REA cannot read a target, `details.failure_kind` identifies why. It is the primary machine identifier, in the sense of an RFC 9457 problem type. `code` is a coarse class derived from it, and `retry` says whether repeating the request can help. Clients should branch on `failure_kind` and must not parse `message`, `remediation.action` or `details.reason`.
|
||||
When REA cannot read a target, `details.failure_kind` identifies why. It is the primary machine identifier, in the sense of an RFC 9457 problem type. `code` is a coarse class derived from it, and `retry_class` says whether repeating the request can help. Clients should branch on `failure_kind` and must not parse `message`, `remediation.action` or `details.reason`.
|
||||
|
||||
## Kinds
|
||||
|
||||
| `failure_kind` | Meaning | `code` | `category` | `retry` | What to do |
|
||||
| -------------- | -------------------------------------------------------------------------------- | --------------------------- | -------------------- | ------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
|
||||
| `selection` | The request names something that is not a valid target for this operation. | `invalid_request` | `invalid_input` | `after_change` | Fix the request. |
|
||||
| `unrecognized` | No reader for this operation recognizes the bytes. | `unsupported_target` | `unsupported_target` | `none` | Choose another operation or provider. |
|
||||
| `unsupported` | A recognized format, but in a version or variant this reader does not implement. | `unsupported_target` | `unsupported_target` | `none` | Choose another operation or provider. |
|
||||
| `malformed` | The bytes break the format's own rules. | `unsupported_target` | `unsupported_target` | `none` | Choose another target, or a well-formed copy. |
|
||||
| `truncated` | The bytes end before a structure they declare. | `unsupported_target` | `unsupported_target` | `none` | Re-acquire the complete file. |
|
||||
| `integrity` | The bytes contradict a digest or checksum they declare. | `target_integrity_mismatch` | `integrity_mismatch` | `none` | Get a fresh copy, or keep the observed bytes with `integrity_policy=record-and-continue` where it is offered. |
|
||||
| `conflict` | Two or more inputs each parse, but disagree. None is blamed. | `input_conflict` | `invalid_input` | `after_change` | Select inputs that belong together. |
|
||||
| `changed` | The file changed while it was read. | `artifact_changed` | `integrity_mismatch` | `backoff` | Retry once it is stable. |
|
||||
| `access` | Host permissions denied the read. | `access_denied` | `unavailable` | `after_change` | Grant read access. |
|
||||
| `io` | The host could not read the file. | `host_io_failed` | `execution_failure` | `backoff` (transient errno) or `none` | Retry with backoff for a transient error. Otherwise check the device and file. |
|
||||
| `failure_kind` | Meaning | `code` | `category` | `retry_class` | What to do |
|
||||
| -------------- | -------------------------------------------------------------------------------- | --------------------------- | -------------------- | ---------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
|
||||
| `selection` | The request names something that is not a valid target for this operation. | `invalid_request` | `invalid_input` | `change_first` | Fix the request. |
|
||||
| `unrecognized` | No reader for this operation recognizes the bytes. | `unsupported_target` | `unsupported_target` | `never` | Choose another operation or provider. |
|
||||
| `unsupported` | A recognized format, but in a version or variant this reader does not implement. | `unsupported_target` | `unsupported_target` | `never` | Choose another operation or provider. |
|
||||
| `malformed` | The bytes break the format's own rules. | `unsupported_target` | `unsupported_target` | `never` | Choose another target, or a well-formed copy. |
|
||||
| `truncated` | The bytes end before a structure they declare. | `unsupported_target` | `unsupported_target` | `never` | Re-acquire the complete file. |
|
||||
| `integrity` | The bytes contradict a digest or checksum they declare. | `target_integrity_mismatch` | `integrity_mismatch` | `never` | Get a fresh copy, or keep the observed bytes with `integrity_policy=record-and-continue` where it is offered. |
|
||||
| `conflict` | Two or more inputs each parse, but disagree. None is blamed. | `input_conflict` | `invalid_input` | `change_first` | Select inputs that belong together. |
|
||||
| `changed` | The file changed while it was read. | `artifact_changed` | `integrity_mismatch` | `same_call` | Retry once it is stable. |
|
||||
| `access` | Host permissions denied the read. | `access_denied` | `unavailable` | `change_first` | Grant read access. |
|
||||
| `io` | The host could not read the file. | `host_io_failed` | `execution_failure` | `same_call` (transient errno) or `never` | Retry with backoff for a transient error. Otherwise check the device and file. |
|
||||
|
||||
The four target refusals share `unsupported_target` because the caller cannot use the target as it stands, and each needs a different target or tool. `failure_kind` says which. No other code covers more than one kind.
|
||||
|
||||
@@ -27,13 +27,15 @@ A caller's cancellation (`cancelled`) and an admission limit (`resource_constrai
|
||||
|
||||
## Retry
|
||||
|
||||
| `retry` | Meaning |
|
||||
| `retry_class` | Meaning |
|
||||
| -------------- | ----------------------------------------------------------------- |
|
||||
| `none` | Repeating the request cannot help. The target itself must change. |
|
||||
| `backoff` | The unchanged request may succeed later. Retry with backoff. |
|
||||
| `after_change` | Only a changed request, input or host permission can succeed. |
|
||||
| `never` | Repeating the request cannot help. The target itself must change. |
|
||||
| `same_call` | The unchanged request may succeed later. Retry with backoff. |
|
||||
| `change_first` | Only a changed request, input or host permission can succeed. |
|
||||
|
||||
`retryable` keeps the meaning it has across all REA errors: the unchanged request may succeed. For a target failure, it is `true` exactly when `retry` is `backoff`, and `retry_class` maps `backoff`, `after_change` and `none` to `same_call`, `change_first` and `never`.
|
||||
`retry_class` is the same field every REA error reports. `retryable` is `true` exactly when `retry_class` is `same_call`.
|
||||
|
||||
Earlier releases also reported a separate `retry` field on target failures. It is removed; read `retry_class` instead: `backoff` is `same_call`, `after_change` is `change_first` and `none` is `never`.
|
||||
|
||||
## Details
|
||||
|
||||
@@ -71,8 +73,8 @@ Container and inventory readers (ZIP, ASAR, PyInstaller, .NET bundles, Node SEA,
|
||||
- The Playwright trace, NTFS journal, release exposure and web capture operations report a damaged selected file as `unsupported_target`, not `invalid_request`.
|
||||
- `inspect_sqlite_database`, `inspect_binary_layout`, `inspect_recorded_crash` and `inspect_evm_interface` also report a damaged selected file as `unsupported_target` (`failure_kind: "malformed"`, with `format` `sqlite`, `elf`, `elf-core` or `evm-bytecode`), not `invalid_request`.
|
||||
- A short read after REA measured the file is now an integrity failure with `details.integrity_check: "read-coverage"` (the file changed during the read), not a format error.
|
||||
- An inventory, inspection or extraction of a container (`inventory_artifact`, `inspect_artifact`, `extract_artifact` and the bundle readers such as `inspect_keyed_archive`) reports damaged or unsupported bytes as a target failure of the selected `path`, with top-level `retry`, like every other operation. `details.reason` is now the owner's description, and `details.detail` is gone. Before, these refusals reported `details.reason: "malformed"`, `"truncated"` or `"unsupported"` with the description in `details.detail`, and no `path`.
|
||||
- An inventory, inspection or extraction of a container (`inventory_artifact`, `inspect_artifact`, `extract_artifact` and the bundle readers such as `inspect_keyed_archive`) reports damaged or unsupported bytes as a target failure of the selected `path`, with top-level `retry_class`, like every other operation. `details.reason` is now the owner's description, and `details.detail` is gone. Before, these refusals reported `details.reason: "malformed"`, `"truncated"` or `"unsupported"` with the description in `details.detail`, and no `path`.
|
||||
- A file that is not a native image at all is now `unrecognized`, not `malformed` or `unsupported`. `inspect_native_initializers` reports a file with neither ELF nor Mach-O magic, such as a PE file, as `unrecognized` (`format: "native-binary"`). Thin Mach-O readers, such as `inspect_macho_function_starts`, report bytes without Mach-O magic as `unrecognized` (`format: "macho"`). The Go and Rust binary readers report bytes that are not ELF, PE or Mach-O as `unrecognized` too. A recognized header that is cut off or broken stays `truncated` or `malformed`.
|
||||
- Every unsupported or unrecognized target is now a target failure too: `failure_kind` is `unsupported` or `unrecognized`, with the owner's `format`, top-level `retry`, and a recovery from the table. Where the owner knows which operations read the target, the recovery names them and `details.related_operations` lists them. Producer-written remediation sentences are gone; their guidance is in `details.reason`.
|
||||
- Every unsupported or unrecognized target is now a target failure too: `failure_kind` is `unsupported` or `unrecognized`, with the owner's `format`, top-level `retry_class`, and a recovery from the table. Where the owner knows which operations read the target, the recovery names them and `details.related_operations` lists them. Producer-written remediation sentences are gone; their guidance is in `details.reason`.
|
||||
|
||||
Related: [settings, limits and recovery](limits-and-recovery.md) for limit failures, and `docs/user-visible-errors.csv` for every error case and its code.
|
||||
|
||||
@@ -366,7 +366,7 @@ it("reports a $MFT stream that shrinks during decoding as a changed file, not ma
|
||||
),
|
||||
).toMatchObject({
|
||||
code: "artifact_changed",
|
||||
retry: "backoff",
|
||||
retry_class: "same_call",
|
||||
retryable: true,
|
||||
details: { failure_kind: "changed" },
|
||||
});
|
||||
|
||||
@@ -281,17 +281,19 @@ const cliTargetFailureRemediation = (
|
||||
details: Record<string, JsonValue>,
|
||||
context: CliCommandOutputProjectionContext,
|
||||
): Record<string, JsonValue> | undefined => {
|
||||
const { remediation, retry } = error;
|
||||
// `io` is the only kind whose table text depends on the retry hint.
|
||||
// cleanup_incomplete keeps the target recovery and drops `retry`, so the
|
||||
// other kinds still rewrite when the action starts with that table text.
|
||||
const { remediation, retry_class: retryClass } = error;
|
||||
// `io` is the only kind whose table text depends on the retry class. A
|
||||
// cleanup_incomplete error keeps the target recovery but its retry class
|
||||
// is the cleanup's, so its `io` text is left as produced; the other kinds
|
||||
// still rewrite when the action starts with that table text.
|
||||
if (
|
||||
!isObject(remediation) ||
|
||||
typeof remediation.action !== "string" ||
|
||||
!isTargetFailureKind(details.failure_kind) ||
|
||||
typeof details.format !== "string" ||
|
||||
typeof details.operation !== "string" ||
|
||||
(details.failure_kind === "io" && typeof retry !== "string")
|
||||
(details.failure_kind === "io" &&
|
||||
(error.code === "cleanup_incomplete" || typeof retryClass !== "string"))
|
||||
)
|
||||
return undefined;
|
||||
const inputFields = targetInputFields(details);
|
||||
@@ -300,7 +302,7 @@ const cliTargetFailureRemediation = (
|
||||
kind: details.failure_kind,
|
||||
format: details.format,
|
||||
inputFields,
|
||||
transient: retry === "backoff",
|
||||
transient: retryClass === "same_call",
|
||||
alternatives: {
|
||||
operations: stringList(details.related_operations),
|
||||
providers: stringList(details.related_providers),
|
||||
|
||||
@@ -6,9 +6,8 @@ import {
|
||||
import {
|
||||
TARGET_FAILURE_KINDS,
|
||||
TARGET_FAILURE_PROJECTIONS,
|
||||
targetFailureRetry,
|
||||
targetFailureRetryClass,
|
||||
type TargetFailureKind,
|
||||
type TargetFailureRetry,
|
||||
} from "./targetFailure.js";
|
||||
import {
|
||||
domainErrorTag,
|
||||
@@ -65,13 +64,6 @@ export interface AnalysisErrorClassification {
|
||||
readonly retry: AnalysisRetryClass;
|
||||
}
|
||||
|
||||
/** A target failure kind's public retry hint, as the shared retry class. */
|
||||
const TARGET_FAILURE_RETRY_CLASSES = {
|
||||
backoff: "same_call",
|
||||
after_change: "change_first",
|
||||
none: "never",
|
||||
} as const satisfies Readonly<Record<TargetFailureRetry, AnalysisRetryClass>>;
|
||||
|
||||
/** Domain tags whose classification depends on the error's own facts. */
|
||||
type SpecializedErrorTag =
|
||||
| "AnalysisTargetFailureError"
|
||||
@@ -167,8 +159,8 @@ const availableLaterCapability = (
|
||||
const kindClassification = (
|
||||
kind: TargetFailureKind,
|
||||
): AnalysisErrorClassification => {
|
||||
const { code, category, retry } = TARGET_FAILURE_PROJECTIONS[kind];
|
||||
return { code, category, retry: TARGET_FAILURE_RETRY_CLASSES[retry] };
|
||||
const { code, category, retryClass } = TARGET_FAILURE_PROJECTIONS[kind];
|
||||
return { code, category, retry: retryClass };
|
||||
};
|
||||
|
||||
const ARTIFACT_OPERATION_CLASSIFICATIONS = {
|
||||
@@ -523,7 +515,7 @@ export const classifyAnalysisError = (
|
||||
if (error instanceof AnalysisTargetFailureError)
|
||||
return {
|
||||
...kindClassification(error.failure.kind),
|
||||
retry: TARGET_FAILURE_RETRY_CLASSES[targetFailureRetry(error.failure)],
|
||||
retry: targetFailureRetryClass(error.failure),
|
||||
};
|
||||
if (error instanceof ProviderSelectionError)
|
||||
return PROVIDER_SELECTION_CLASSIFICATIONS[error.reason];
|
||||
|
||||
@@ -27,12 +27,7 @@ import {
|
||||
AnalysisTimeoutError,
|
||||
AnalysisResourceConstraintError,
|
||||
} from "./analysisErrorCore.js";
|
||||
import {
|
||||
TARGET_FAILURE_PROJECTIONS,
|
||||
targetFailureDetails,
|
||||
targetFailureRetry,
|
||||
type TargetFailureRetry,
|
||||
} from "./targetFailure.js";
|
||||
import { targetFailureDetails } from "./targetFailure.js";
|
||||
import {
|
||||
ArtifactOperationError,
|
||||
integrityCheckMeansChanged,
|
||||
@@ -580,15 +575,6 @@ const projectError = (
|
||||
? `${remediation}${retentionGuidance}${publicationRemediation}`
|
||||
: `${remediation}${retentionGuidance} ${cleanupRetryRemediation(cleanupRetry)}${publicationRemediation}`,
|
||||
},
|
||||
...(error instanceof AnalysisTargetFailureError &&
|
||||
code !== "cleanup_incomplete"
|
||||
? { retry: targetFailureRetry(error.failure) }
|
||||
: {}),
|
||||
// Every producer of a changed target, typed or not, takes the changed
|
||||
// kind's retry hint.
|
||||
...(code === "artifact_changed"
|
||||
? { retry: TARGET_FAILURE_PROJECTIONS.changed.retry }
|
||||
: {}),
|
||||
...(recovery === undefined ? {} : { recovery }),
|
||||
...(Object.keys(details).length === 0 ? {} : { details }),
|
||||
};
|
||||
@@ -1038,8 +1024,6 @@ export interface AnalysisErrorProjection extends Readonly<
|
||||
* by an earlier release may lack it.
|
||||
*/
|
||||
readonly retry_class?: AnalysisRetryClass;
|
||||
/** A target failure's retry hint, derived from its kind. */
|
||||
readonly retry?: TargetFailureRetry;
|
||||
readonly remediation: Readonly<{
|
||||
action: string;
|
||||
}>;
|
||||
|
||||
@@ -30,7 +30,6 @@ const common = {
|
||||
retry_class: z
|
||||
.enum(["same_call", "change_first", "never", "unknown_outcome"])
|
||||
.optional(),
|
||||
retry: z.enum(["none", "backoff", "after_change"]).optional(),
|
||||
remediation: remediationSchema,
|
||||
recovery: analysisErrorRecoverySchema.optional(),
|
||||
};
|
||||
|
||||
@@ -52,15 +52,15 @@ describe("target failure projection", () => {
|
||||
it.each(TARGET_FAILURE_KINDS)(
|
||||
"derives the public contract of %s from its kind",
|
||||
(kind) => {
|
||||
const { code, category, retry } = TARGET_FAILURE_CONTRACT[kind];
|
||||
const { code, category, retry_class } = TARGET_FAILURE_CONTRACT[kind];
|
||||
const failure = failureOf(kind);
|
||||
const projected = project(failure);
|
||||
expect(projected).toMatchObject({
|
||||
code,
|
||||
category,
|
||||
retry,
|
||||
retry_class,
|
||||
// `retryable` keeps its contract meaning: the unchanged request may succeed.
|
||||
retryable: retry === "backoff",
|
||||
retryable: retry_class === "same_call",
|
||||
remediation: {
|
||||
action: targetFailureRecovery("inspect_elf_notes", failure),
|
||||
},
|
||||
@@ -74,6 +74,7 @@ describe("target failure projection", () => {
|
||||
},
|
||||
});
|
||||
expect(projected).not.toHaveProperty("recovery");
|
||||
expect(projected).not.toHaveProperty("retry");
|
||||
// The generated catalogue row states the same retry contract.
|
||||
expect(
|
||||
analysisErrorCatalogue().find(
|
||||
@@ -116,7 +117,6 @@ describe("target failure projection", () => {
|
||||
retryable: false,
|
||||
});
|
||||
expect(projected.retry_class).not.toBe("same_call");
|
||||
expect(projected).not.toHaveProperty("retry");
|
||||
});
|
||||
|
||||
it("gives no two kinds with unrelated caller actions one code", () => {
|
||||
@@ -133,14 +133,14 @@ describe("target failure projection", () => {
|
||||
).toEqual([["unrecognized", "unsupported", "malformed", "truncated"]]);
|
||||
});
|
||||
|
||||
it("refines an io failure's retry hint from its errno fact", () => {
|
||||
it("refines an io failure's retry class from its errno fact", () => {
|
||||
expect(project(failureOf("io"))).toMatchObject({
|
||||
retry: "none",
|
||||
retry_class: "never",
|
||||
retryable: false,
|
||||
});
|
||||
expect(
|
||||
project({ ...failureOf("io"), kind: "io", transient: true }),
|
||||
).toMatchObject({ retry: "backoff", retryable: true });
|
||||
).toMatchObject({ retry_class: "same_call", retryable: true });
|
||||
});
|
||||
|
||||
it("reports measured extents for a truncated structure", () => {
|
||||
|
||||
+23
-23
@@ -3,7 +3,7 @@
|
||||
* or filesystem owner that established it. Wrappers carry it unchanged.
|
||||
*
|
||||
* `failure_kind` is the primary machine identifier (RFC 9457's problem type).
|
||||
* The coarse `code`, its `category`, the `retry` hint, the recovery and the
|
||||
* The coarse `code`, its `category`, the `retry_class`, the recovery and the
|
||||
* `details` are all derived from the kind by {@link TARGET_FAILURE_PROJECTIONS}
|
||||
* and {@link targetFailureDetails}. See `docs/reference/target-failures.md`.
|
||||
*
|
||||
@@ -127,12 +127,12 @@ export const isFormatTargetFailureKind = (
|
||||
(FORMAT_TARGET_FAILURE_KINDS as readonly string[]).includes(kind);
|
||||
|
||||
/**
|
||||
* When repeating the request can help, after gRPC's status semantics:
|
||||
* `none` (never, the target itself must change), `backoff` (the unchanged
|
||||
* request may succeed later), `after_change` (only once the caller changes
|
||||
* When repeating the request can help, as the error's `retry_class`:
|
||||
* `never` (the target itself must change), `same_call` (the unchanged
|
||||
* request may succeed later), `change_first` (only once the caller changes
|
||||
* the request or a control).
|
||||
*/
|
||||
export type TargetFailureRetry = "none" | "backoff" | "after_change";
|
||||
export type TargetFailureRetryClass = "never" | "same_call" | "change_first";
|
||||
|
||||
/** What a caller should do next. Each adapter renders it in its own words. */
|
||||
export type TargetFailureRecovery =
|
||||
@@ -165,8 +165,8 @@ export interface TargetFailureProjection {
|
||||
| "integrity_mismatch"
|
||||
| "unavailable"
|
||||
| "execution_failure";
|
||||
/** The kind's retry hint; `io` refines it from its errno fact. */
|
||||
readonly retry: TargetFailureRetry;
|
||||
/** The kind's retry class; `io` refines it from its errno fact. */
|
||||
readonly retryClass: TargetFailureRetryClass;
|
||||
readonly recovery: TargetFailureRecovery;
|
||||
}
|
||||
|
||||
@@ -180,70 +180,70 @@ export const TARGET_FAILURE_PROJECTIONS = {
|
||||
title: "Unselectable",
|
||||
code: "invalid_request",
|
||||
category: "invalid_input",
|
||||
retry: "after_change",
|
||||
retryClass: "change_first",
|
||||
recovery: "fix_request",
|
||||
},
|
||||
unrecognized: {
|
||||
title: "Unrecognized",
|
||||
code: "unsupported_target",
|
||||
category: "unsupported_target",
|
||||
retry: "none",
|
||||
retryClass: "never",
|
||||
recovery: "choose_another_tool",
|
||||
},
|
||||
unsupported: {
|
||||
title: "Unsupported",
|
||||
code: "unsupported_target",
|
||||
category: "unsupported_target",
|
||||
retry: "none",
|
||||
retryClass: "never",
|
||||
recovery: "choose_another_tool",
|
||||
},
|
||||
malformed: {
|
||||
title: "Malformed",
|
||||
code: "unsupported_target",
|
||||
category: "unsupported_target",
|
||||
retry: "none",
|
||||
retryClass: "never",
|
||||
recovery: "choose_another_target",
|
||||
},
|
||||
truncated: {
|
||||
title: "Truncated",
|
||||
code: "unsupported_target",
|
||||
category: "unsupported_target",
|
||||
retry: "none",
|
||||
retryClass: "never",
|
||||
recovery: "reacquire_complete_file",
|
||||
},
|
||||
integrity: {
|
||||
title: "Integrity-mismatched",
|
||||
code: "target_integrity_mismatch",
|
||||
category: "integrity_mismatch",
|
||||
retry: "none",
|
||||
retryClass: "never",
|
||||
recovery: "replace_or_record_integrity",
|
||||
},
|
||||
conflict: {
|
||||
title: "Conflicting",
|
||||
code: "input_conflict",
|
||||
category: "invalid_input",
|
||||
retry: "after_change",
|
||||
retryClass: "change_first",
|
||||
recovery: "check_input_pairing",
|
||||
},
|
||||
changed: {
|
||||
title: "Changed",
|
||||
code: "artifact_changed",
|
||||
category: "integrity_mismatch",
|
||||
retry: "backoff",
|
||||
retryClass: "same_call",
|
||||
recovery: "retry_on_stable_copy",
|
||||
},
|
||||
access: {
|
||||
title: "Inaccessible",
|
||||
code: "access_denied",
|
||||
category: "unavailable",
|
||||
retry: "after_change",
|
||||
retryClass: "change_first",
|
||||
recovery: "fix_permissions",
|
||||
},
|
||||
io: {
|
||||
title: "Unreadable",
|
||||
code: "host_io_failed",
|
||||
category: "execution_failure",
|
||||
retry: "none",
|
||||
retryClass: "never",
|
||||
recovery: "check_host",
|
||||
},
|
||||
} as const satisfies Readonly<
|
||||
@@ -257,13 +257,13 @@ export const unhandledTargetFailureCase = (value: never): never => {
|
||||
);
|
||||
};
|
||||
|
||||
/** The retry hint of one failure: its kind's, refined by an `io` errno fact. */
|
||||
export const targetFailureRetry = (
|
||||
/** The retry class of one failure: its kind's, refined by an `io` errno fact. */
|
||||
export const targetFailureRetryClass = (
|
||||
failure: TargetFailure,
|
||||
): TargetFailureRetry =>
|
||||
): TargetFailureRetryClass =>
|
||||
failure.kind === "io" && failure.transient
|
||||
? "backoff"
|
||||
: TARGET_FAILURE_PROJECTIONS[failure.kind].retry;
|
||||
? "same_call"
|
||||
: TARGET_FAILURE_PROJECTIONS[failure.kind].retryClass;
|
||||
|
||||
type DetailValue =
|
||||
| string
|
||||
@@ -345,7 +345,7 @@ export interface TargetFailureRecoveryFacts {
|
||||
readonly format: string;
|
||||
/** The conflicting inputs' request fields, in the adapter's spelling. */
|
||||
readonly inputFields?: readonly string[];
|
||||
/** The owner's errno was transient (`retry: "backoff"` for `io`). */
|
||||
/** The owner's errno was transient (`retry_class: "same_call"` for `io`). */
|
||||
readonly transient?: boolean;
|
||||
readonly alternatives?: TargetFailureAlternatives;
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ it.each([
|
||||
expect(projectAnalysisError(generic)).toMatchObject({
|
||||
code: "unsupported_target",
|
||||
category: "unsupported_target",
|
||||
retry: "none",
|
||||
retry_class: "never",
|
||||
details: {
|
||||
operation: "inspect_artifact",
|
||||
path,
|
||||
@@ -451,7 +451,7 @@ it("projects a session digest mismatch as admitted identity, not a retryable cha
|
||||
integrity_check: "admitted-identity",
|
||||
},
|
||||
});
|
||||
expect(projected.retry).toBeUndefined();
|
||||
expect(projected.retry_class).not.toBe("same_call");
|
||||
});
|
||||
|
||||
it("names the failed integrity check through cleanup wrapping and public projection", () => {
|
||||
@@ -558,7 +558,7 @@ it("reports a reader integrity failure as changed only for a changed check", ()
|
||||
expect(projectAnalysisError(changed)).toMatchObject({
|
||||
code: "artifact_changed",
|
||||
retryable: true,
|
||||
retry: "backoff",
|
||||
retry_class: "same_call",
|
||||
message: expect.stringContaining("changed during acquisition"),
|
||||
details: {
|
||||
path: "/target",
|
||||
@@ -593,7 +593,7 @@ it("reports a reader integrity failure as changed only for a changed check", ()
|
||||
integrity_check: "admitted-identity",
|
||||
},
|
||||
});
|
||||
expect(stale.retry).toBeUndefined();
|
||||
expect(stale.retry_class).not.toBe("same_call");
|
||||
});
|
||||
|
||||
// A reader's target reasons mean the bytes; only `path` names the
|
||||
|
||||
@@ -77,7 +77,7 @@ cliTest.for([
|
||||
integrity_check: "admitted-identity",
|
||||
},
|
||||
});
|
||||
expect(staleError.retry).toBeUndefined();
|
||||
expect(staleError.retry_class).not.toBe("same_call");
|
||||
|
||||
expect((await call("open_binary", { path: app })).isError).not.toBe(true);
|
||||
const after = await call(operation, parameters);
|
||||
|
||||
@@ -629,7 +629,7 @@ cliTest(
|
||||
code: "unsupported_target",
|
||||
category: "unsupported_target",
|
||||
retryable: false,
|
||||
retry: "none",
|
||||
retry_class: "never",
|
||||
details: {
|
||||
failure_kind: "malformed",
|
||||
format: "zip",
|
||||
|
||||
@@ -104,7 +104,7 @@ cliTest(
|
||||
expect(await inspect()).toMatchObject({
|
||||
code: "unsupported_target",
|
||||
retryable: false,
|
||||
retry: "none",
|
||||
retry_class: "never",
|
||||
details: {
|
||||
path: source,
|
||||
failure_kind: "truncated",
|
||||
|
||||
@@ -751,7 +751,7 @@ cliTest(
|
||||
code: "unsupported_target",
|
||||
category: "unsupported_target",
|
||||
retryable: false,
|
||||
retry: "none",
|
||||
retry_class: "never",
|
||||
remediation: {
|
||||
action: expect.stringContaining(
|
||||
"Choose another operation or provider for this target.",
|
||||
|
||||
@@ -957,7 +957,7 @@ const expectNotADatabaseRefusal = (error: unknown, selected: string): void => {
|
||||
// The selected file's bytes are at fault, not the request.
|
||||
expect(error).toMatchObject({
|
||||
code: "unsupported_target",
|
||||
retry: "none",
|
||||
retry_class: "never",
|
||||
details: {
|
||||
path: selected,
|
||||
failure_kind: "malformed",
|
||||
|
||||
@@ -156,7 +156,7 @@ cliTest(
|
||||
expect(notDirectory.json).toMatchObject({
|
||||
code: "invalid_request",
|
||||
category: "invalid_input",
|
||||
retry: "after_change",
|
||||
retry_class: "change_first",
|
||||
details: {
|
||||
operation: "inspect_desktop_application",
|
||||
path: file,
|
||||
|
||||
@@ -144,7 +144,7 @@ describe.skipIf(process.platform !== "darwin")(
|
||||
const expectedRefusal = {
|
||||
code: "unsupported_target",
|
||||
category: "unsupported_target",
|
||||
retry: "none",
|
||||
retry_class: "never",
|
||||
details: {
|
||||
path,
|
||||
failure_kind: "unsupported",
|
||||
|
||||
@@ -442,7 +442,7 @@ it("rewrites target recovery when cleanup drops the retry hint", () => {
|
||||
code: "cleanup_incomplete",
|
||||
details: { failure_kind: "malformed", format: "zip" },
|
||||
});
|
||||
expect(projected.retry).toBeUndefined();
|
||||
expect(projected.retry_class).not.toBe("same_call");
|
||||
expect(projected.remediation.action).toContain("inspect_artifact");
|
||||
const cliProjected = projectCliCommandOutput(projected, {
|
||||
operations: entry.operations,
|
||||
|
||||
+1
-1
@@ -316,7 +316,7 @@ describe("Selected JavaScript source failure diagnostics", () => {
|
||||
);
|
||||
expect(projectAnalysisError(result.error)).toMatchObject({
|
||||
code: "artifact_changed",
|
||||
retry: "backoff",
|
||||
retry_class: "same_call",
|
||||
details: { reason: "integrity", failure_kind: "changed" },
|
||||
});
|
||||
});
|
||||
|
||||
@@ -316,7 +316,7 @@ it("directs unsupported parent views to the original Evidence", async () => {
|
||||
expect(error).toMatchObject({
|
||||
code: "unsupported_target",
|
||||
retryable: false,
|
||||
retry: "none",
|
||||
retry_class: "never",
|
||||
details: {
|
||||
operation: "inspect_analysis_view",
|
||||
failure_kind: "unsupported",
|
||||
@@ -1825,7 +1825,7 @@ it("extracts an environment state identically from retained, portable and file M
|
||||
const hiddenError = parseMcpToolError(refused).error;
|
||||
expect(hiddenError).toMatchObject({
|
||||
code: "unsupported_target",
|
||||
retry: "none",
|
||||
retry_class: "never",
|
||||
details: {
|
||||
failure_kind: "unsupported",
|
||||
format: "evidence",
|
||||
@@ -2089,7 +2089,7 @@ it("projects an environment manifest identically from retained, portable and fil
|
||||
const hiddenError = parseMcpToolError(refused).error;
|
||||
expect(hiddenError).toMatchObject({
|
||||
code: "unsupported_target",
|
||||
retry: "none",
|
||||
retry_class: "never",
|
||||
details: {
|
||||
failure_kind: "unsupported",
|
||||
format: "evidence",
|
||||
|
||||
@@ -125,7 +125,7 @@ it("traces dylib resolution for an opened app bundle and rejects a changed targe
|
||||
details: { reason: "integrity", integrity_check: "admitted-identity" },
|
||||
},
|
||||
});
|
||||
expect(changedError.error.retry).toBeUndefined();
|
||||
expect(changedError.error.retry_class).not.toBe("same_call");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ mcpTest(
|
||||
});
|
||||
expect(parseMcpToolError(response).error).toMatchObject({
|
||||
code: "unsupported_target",
|
||||
retry: "none",
|
||||
retry_class: "never",
|
||||
details: {
|
||||
path,
|
||||
failure_kind: "malformed",
|
||||
|
||||
@@ -13,6 +13,7 @@ import { BrowserObservationError } from "../../../src/domain/browserObservationE
|
||||
import {
|
||||
AnalysisCancelledError,
|
||||
AnalysisTimeoutError,
|
||||
unsupportedTarget,
|
||||
} from "../../../src/domain/analysisErrorCore.js";
|
||||
import type { AnalysisError } from "../../../src/domain/analysisErrorBase.js";
|
||||
|
||||
@@ -51,6 +52,29 @@ it.each([
|
||||
expect(validate(projected), JSON.stringify(validate.errors)).toBe(true);
|
||||
});
|
||||
|
||||
it("rejects the removed target-failure retry field in every reader", () => {
|
||||
const projected = projectAnalysisError(
|
||||
unsupportedTarget(
|
||||
"inspect_elf_notes",
|
||||
"/tmp/t",
|
||||
"elf",
|
||||
"not an ELF variant this reader decodes",
|
||||
),
|
||||
);
|
||||
const validate = new Ajv2020({ strict: false }).compile(
|
||||
analysisErrorJsonSchema,
|
||||
);
|
||||
// The projection itself is valid in both readers.
|
||||
expect(analysisErrorProjectionSchema.safeParse(projected).success).toBe(true);
|
||||
expect(validate(projected), JSON.stringify(validate.errors)).toBe(true);
|
||||
// retry_class owns retry semantics; the old field is not accepted back.
|
||||
const withRetry = { ...projected, retry: "none" };
|
||||
expect(analysisErrorProjectionSchema.safeParse(withRetry).success).toBe(
|
||||
false,
|
||||
);
|
||||
expect(validate(withRetry)).toBe(false);
|
||||
});
|
||||
|
||||
describe("analysis error projection contract", () => {
|
||||
it("keeps cleanup failure distinct from unreadable collected output", () => {
|
||||
const projected = projectAnalysisError(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type {
|
||||
TargetFailureKind,
|
||||
TargetFailureRetry,
|
||||
TargetFailureRetryClass,
|
||||
} from "../../../src/domain/targetFailure.js";
|
||||
|
||||
/**
|
||||
@@ -12,58 +12,58 @@ export const TARGET_FAILURE_CONTRACT = {
|
||||
selection: {
|
||||
code: "invalid_request",
|
||||
category: "invalid_input",
|
||||
retry: "after_change",
|
||||
retry_class: "change_first",
|
||||
},
|
||||
unrecognized: {
|
||||
code: "unsupported_target",
|
||||
category: "unsupported_target",
|
||||
retry: "none",
|
||||
retry_class: "never",
|
||||
},
|
||||
unsupported: {
|
||||
code: "unsupported_target",
|
||||
category: "unsupported_target",
|
||||
retry: "none",
|
||||
retry_class: "never",
|
||||
},
|
||||
malformed: {
|
||||
code: "unsupported_target",
|
||||
category: "unsupported_target",
|
||||
retry: "none",
|
||||
retry_class: "never",
|
||||
},
|
||||
truncated: {
|
||||
code: "unsupported_target",
|
||||
category: "unsupported_target",
|
||||
retry: "none",
|
||||
retry_class: "never",
|
||||
},
|
||||
integrity: {
|
||||
code: "target_integrity_mismatch",
|
||||
category: "integrity_mismatch",
|
||||
retry: "none",
|
||||
retry_class: "never",
|
||||
},
|
||||
conflict: {
|
||||
code: "input_conflict",
|
||||
category: "invalid_input",
|
||||
retry: "after_change",
|
||||
retry_class: "change_first",
|
||||
},
|
||||
changed: {
|
||||
code: "artifact_changed",
|
||||
category: "integrity_mismatch",
|
||||
retry: "backoff",
|
||||
retry_class: "same_call",
|
||||
},
|
||||
access: {
|
||||
code: "access_denied",
|
||||
category: "unavailable",
|
||||
retry: "after_change",
|
||||
retry_class: "change_first",
|
||||
},
|
||||
io: {
|
||||
code: "host_io_failed",
|
||||
category: "execution_failure",
|
||||
retry: "none",
|
||||
retry_class: "never",
|
||||
},
|
||||
} as const satisfies Record<
|
||||
TargetFailureKind,
|
||||
{
|
||||
readonly code: string;
|
||||
readonly category: string;
|
||||
readonly retry: TargetFailureRetry;
|
||||
readonly retry_class: TargetFailureRetryClass;
|
||||
}
|
||||
>;
|
||||
|
||||
Reference in New Issue
Block a user