Files
seaweedfs/seaweed-block/docs/design/answer-classification.md
T
687c2844c3 seaweed-block: classify operator failures by admission evidence (#13477)
* seaweed-block: unify operator answer policy with admission evidence

* seaweed-block: failover keeps exit 3 for a caller deadline before send

A failover whose caller deadline passed before the request was sent
(e.g. a master that never completes the handshake) is Recover under the
failover contract, so the command prints result=unknown and asks the
operator to read the current line. The canonical projection gave it
exit 1, which the help text reserves for a definite answer, while
v1.1.x returned 3. Add the failover legacy row next to the unsent
remote-failure one so the exit matches the printed outcome.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* seaweed-block: document the failover caller-deadline exit

The failover help, the v1.1.x legacy table and the classification design
note name the caller deadline before send next to the unsent remote
failure as the two failover cases that keep exit 3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Test CA rotation with unused expired and future roots

* Allow unused CA alternatives during certificate rotation

* seaweed-block: workspace caller deadline before send is not a master refusal

A workspace RPC whose caller deadline passed (or was canceled) before it
was sent projects to exit 1, and the exit-1 branch turned it into
OutcomeRefused. force-move then printed "refused by the master (nothing
moved)" and read an admission preview, though the master never answered.
Report these as unsent; the policy exit stays 1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* seaweed-block: master-crash test expects the shared refusal presentation

Competing clean moves after the master restart are still definite
refusals (exit 1). The workspace client now keeps the gRPC status in the
error chain and appends the registry cure, so the stderr line carries the
status prefix and "resolve the server's stated precondition before
retrying".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Cover CA rotation in the Kubernetes status writer

* test: pin answer precedence and certificate-chain boundaries

* fix: preserve answer provenance through observation and recovery

* fix(block): preserve admitted outcomes and caller completion

* fix(block): preserve response precedence and refusal origin

* Preserve definite refusals and admitted operation recovery

* docs(block): forced-move unknown row covers possibly admitted failures

A proven-unsent transport failure of a forced move reports nothing sent
and exits 75, not an unknown outcome. Narrow the row and cover the unsent
path at the command (holder read refused) and in the client (move RPC).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Consolidate domain recovery selection

* Retain response and admission evidence for unusable answers

* Pin command answer entries and preserve recovery identities

* Document uncertain HTTP status outcomes completely

* Keep publication identity when status persistence also fails

* Require size-limit evidence in oversized response controls

* Preserve unresolved results and verify received operation identities

* Focus failure release notes on operator recovery

* Qualify unsent and certificate failure exit guidance

---------

Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-05 22:10:18 -08:00

242 lines
16 KiB
Markdown

# Shared failure policy
The operator policy is a pure lookup of `(phase, error kind)`. Its result
contains a typed code, retryable flag, same-operation retry rule, cure and
exit code. Transport adapters retain facts and translate concrete errors
to kinds. They do not decide which operations may be resent.
A definite typed domain answer from the server takes precedence over a
local transport diagnosis. Otherwise an initial attempt is **unsent** only
when the transport proves that no request stream was sent. Missing evidence
is **possibly admitted**. A reset, EOF, cancellation or deadline after a
request may have left cannot authorize a second non-idempotent operation.
Recover through the original operation's replay key or existing poll handle.
This projects the existing CutTime `Poll` / `CliGiveUp` boundary and the
snapshot same-request-id replay contract. It introduces no server state or
authority transition.
## Transport registry
The registry is in `core/rpc/answer`. Classification precedes one global
class-to-exit projection. A short explicit legacy list preserves documented
v1.1.x exceptions; every row has a source, reason, test and v1.2 removal
boundary. An undocumented exit is canonicalized.
The common chunk contract is shown below. Thirteen wire contracts
(chunk, incomplete verify, workspace, create, resolve, cluster, restore, failover, whole-job
volume operations, stop, placement, shell and ops) remain explicit cells
in that same registry. The legacy exit never changes class or authorizes unsafe retry.
| Kind | Unsent | Possibly admitted |
| --- | --- | --- |
| Connection failure or EOF | `remote_unavailable`, retryable, resend the same operation, 75 | `outcome_unknown`, recover by replay key or poll, 3 |
| DNS failure | `remote_unavailable`, retryable, check resolution and resend the same operation, 75 | `outcome_unknown`, recover by replay key or poll, 3 |
| Timeout | `remote_unavailable`, retryable, resend the same operation, 75 | `outcome_unknown`, recover by replay key or poll, 3 |
| Caller-owned deadline | `deadline_exceeded`, resend the same operation with a sufficient caller window, 1 | `outcome_unknown`, recover by replay key or poll, 3 |
| Local credential load, parse or validity failure | `bad_request`, terminal until local credentials are fixed, 78 | The same local configuration provenance, with the wire contract preserved |
| Caller cancellation | `canceled`, no automatic retry, 1 | `outcome_unknown`, recover by replay key or poll, 3 |
| Certificate rejected or invalid | `not_authorized`, terminal until certificate configuration is fixed, 5 | The same terminal certificate policy for this request, 5 |
| Unknown certificate authority | `not_authorized`, terminal until the CA is fixed, 5 | The same terminal CA policy for this request, 5 |
| Certificate name mismatch | `not_authorized`, terminal until the address or names are fixed, 5 | The same terminal name policy for this request, 5 |
Certificate policy classifies the request whose admission is being decided.
A failed status poll cannot settle an earlier admitted snapshot operation:
certificate validation or rejection on that poll leaves the original operation
`outcome_unknown` (exit 3), with its request id and handle preserved for recovery.
TLS 1.3 can deliver a server's client-certificate rejection on the first
read after the client has written its request. That certificate-family
alert is a definite rejection of this connection, not an ambiguous applied
request. It remains terminal even in the post-write phase. The TLS adapter
recognizes the finite certificate-alert family at the structured TLS error
boundary; it does not search arbitrary gRPC diagnostic text.
HTTP records connection acquisition across the entire call. A missing
`WroteHeaders` callback never proves that a partial write did not happen.
Polling an admitted operation retains its admission evidence even if the
poll's own dial fails. Response-body read failures retain post-send evidence.
gRPC records `OutHeader` per RPC, monotonically across transparent retry
attempts. Unary and streaming failures preserve the original gRPC status
and details. Typed connection-attempt causes are captured before gRPC
flattens the final failure into `Unavailable`. Credentials options retain no
channel-wide last cause. Established RPCs use their own connection's
late-alert evidence; unsent calls require the fresh peer-set proof below. A two-peer control holds a trusted RPC open while another peer fails TLS
verification, then loses the trusted RPC answer. The trusted call remains
UNKNOWN; substituting the channel-wide last TLS error makes the control fail.
## Evidence and remaining work
Tests produce actual loopback TCP refusal and reset, owned DNS NXDOMAIN,
read timeout, caller cancellation, EOF and TLS verification failures. A TLS
1.3 test completes the client handshake and write before observing a missing
client-certificate alert. HTTP and gRPC tests distinguish an unsent call
from a received request whose answer is lost. Unlisted errors, kinds and
phases fail the registry check.
The registry now includes every gRPC status, typed domain answers, local
kernel refusals and caller-owned deadline provenance. Workspace rendering,
chunk catalog and partial verify errors, restore, volume create/resolve,
cluster finalize/retire and failover use the shared policy. HTTP boundaries
retain phase evidence, including snapshot polls and whole-job volume reads.
A thirteen-contract grid checks produced TCP refusal/reset, DNS and timeout
errors in both phases, with an unlisted-row negative for each contract.
The transport semantics correction is `Unavailable` after a
request stream may have been sent: it is UNKNOWN, never proof of safe resend.
A bare status without evidence is conservative. TLS certificate rejection
is a terminal, not-admitted exception even after a TLS 1.3 request write.
Whole-job backup, restore, cut and stop presentation, shell inspection,
and the older ops HTTP/RPC clients use the shared registry. All owned RPC
constructors and HTTP request boundaries are inventoried by a source census;
a raw-client bypass is a failing control. Generated code and explicitly
inventoried non-network sync.Once callbacks are excluded. The inventory
pins current entries; aliases, reflection and future transport libraries
require a new entry and an admission-evidence control.
Typed server codes have a finite registry inventory. A source census checks
constant domain codes and an actual HTTP unlisted-code answer fails closed.
Unknown errors, status codes and output contracts never acquire a safe-resend
default. HTTP protocol callers retain their existing 404/409 state rules;
only responses they already treat as failures enter the registry. The
registered HTTP error statuses project definite rejection or conservative
UNKNOWN according to [HTTP semantics](https://www.rfc-editor.org/rfc/rfc9110.html#section-15.5);
the retry rule follows the [non-idempotent retry constraint](https://www.rfc-editor.org/rfc/rfc9110.html#section-9.2.2).
Native short tests cover the registry, RPC, ops, CSI and launcher packages.
Linux/race and whole CLI qualification remain pending. Native Windows cannot
qualify real-master fixtures that require directory Sync. Transport evidence
and presentation do not change server admission, cleanup or authority guards.
## Cost cells
| Operation | Formula and bound | Exhaustion | Attribution |
| --- | --- | --- | --- |
| Policy lookup | O(1) lookup and fixed registry space, independent of S/C/N/V/H/T | Unlisted key is an explicit check error; never a safe-resend default | Shared registry |
| HTTP evidence | O(1) state per in-flight request, independent of S/C/N/V/H/T | Unsupported trace evidence remains possibly admitted | Calling command |
| RPC evidence | O(1) state per in-flight RPC and per TLS connection, plus O(P) peer-attempt state per channel | Missing provenance cannot prove unsent or certificate rejection | Calling RPC client |
| Local credential validation | O(config bytes) parsing; runs before dialing, independent of stored S/C/N/V/H/T | Invalid or expired material is terminal with local provenance | Client constructor |
| Error presentation | O(diagnostic bytes), with existing caller response limits | Unlisted code fails closed; diagnostic text never authorizes retry | Calling command |
| Command-family policy grid | Thirteen compatibility projections, two admission phases, produced failure controls | Linux/race qualification pending; source census does not prove alias/reflection coverage | CLI adapters |
## Exit compatibility
`exit_projection.go` maps unsent remote failure to 75, possibly-admitted
UNKNOWN to 3, certificate/trust/name rejection to 5, and typed local
credential/configuration failure to 78. Local command syntax and definite
server argument refusals remain distinct from credential validation.
`LegacyExits()` is the complete exception inventory. The documented
`ops volume create` and read-only `ops volume resolve` exceptions retain
75 for UNKNOWN and 78 for definite refusal. Cluster finalize/retire typed
precondition refusal retains 2. Cut/plain-detach `cut_busy` before admission retains 4, separately from integrity/readout-unproven. Incomplete verify UNKNOWN retains 1 (3 means completed findings); failover unsent remote failure and caller deadline before send retain 3 with read-before-another-move recovery. Every exception is removed in v1.2. Typed non-retryable remote-unavailable answers are definite refusals, never exit 75.
The create exception is safe only for identical name, geometry and placement:
`FileStore.CreateVolume` returns the existing compatible record and layout
identity or refuses a conflict. `RegisterWorkspaceBinding` and placement
preserve conflicting assignments. `TestOpsVolumeCreateAndPlaceRetriesAgainstRunningMaster`
loses each of the three replies and proves a same-input rerun converges;
its Linux qualification remains required. This is not permission to change
settings or issue a different operation as a retry.
`TestCanonicalExitProjectionGrid` covers every changed transport class across
the command contracts; `TestEveryLegacyExitHasADocumentedGridRow` covers each
legacy row and its source/removal metadata. Actual credential-file failures
also traverse command entry points, including workspace, create/resolve,
cluster and failover. See the [v1.1.2 corrections](../releases/v1.1.2.md).
## Multi-peer attempt evidence
Connection-attempt facts come from the public gRPC SubConn state listener,
including the typed Origin of TCP/TLS failures before a stream exists. Its
notifications are asynchronous, so delivery time never proves freshness.
The TLS credential/read boundary stamps the actual attempt start and failure;
a terminal certificate proof requires that attempt to have started after
the RPC. An older attempt or a missing source stamp stays conservative. A
Picker associates that peer set with the RPC that is waiting for it. The
observer delegates the existing pick-first algorithm; it does not replace
the dialer, proxy handling, backoff or admission. Established RPCs continue
to use only their own connection's late TLS fact.
Terminal certificate rejection requires fresh certificate-family failures
for every peer attempted for the call, with no pending, unknown or network
failure. Resolver changes during the call invalidate that proof. A mixed
certificate/network failure remains unsent/retryable and reports both peer
causes. Unsupported custom policies lack this proof and remain conservative.
| Evidence operation | Formula / bound | Exhaustion or uncertainty | Attribution |
| --- | --- | --- | --- |
| Peer attempt tracking | O(P) state per channel, P = resolved peers; fixed counters and last typed causes per peer, no history growing with retries | Resolver change, duplicate peer identity, multi-address SubConn or missing cause cannot prove every attempt was certificate-rejected | Resolver-owned peer set |
| Picker observation | O(P) scan on a failed pick; O(1) retained evidence per RPC | No fresh complete set means retryable unsent failure | Waiting RPC |
| Peer diagnostic | At most 8 peer causes plus omitted count; existing individual diagnostics retained | Truncation never authorizes terminal classification | Failing call |
## Plaintext preface compatibility correction
The configured gRPC transport supplies one additional fact: plaintext mode.
An observed unsent connection failure in that mode retains `remote_unavailable`
and same-operation retry. Its shared cure adds a conditional hint to configure
`SW_BLOCK_TLS_CERT`, `SW_BLOCK_TLS_KEY` and `SW_BLOCK_TLS_CA` if the endpoint
requires TLS. A closed preface cannot prove that requirement: a restarting or
closing plaintext endpoint looks identical. Workspace's old heuristic terminal
5 therefore becomes 75 when unsent is proven (3 without admission evidence).
No handshake probe, string-based TLS diagnosis or extra network request is
introduced. `TestPlaintextPrefaceFailureKeepsUnsentRetryAndTLSHint` exercises
both a real TLS server and a closing plaintext peer. The channel retains one
immutable transport-mode boolean; no per-attempt history or new cost bound.
## Trusting HTTP trace evidence
Only `NewHTTPTransport`'s privately owned native path supplies positive
GetConn/GotConn no-send evidence. A concrete `*http.Transport` can delegate
through `RegisterProtocol` before native tracing; its type alone proves nothing.
All caller-supplied transports, including unmodified standard transports, stay
possibly admitted on transport errors unless cancellation prevented dispatch.
A client with nil Transport uses the adapter's owned standard-default transport,
not the mutable global `http.DefaultTransport`. Caller client options (timeout,
redirect policy, jar) are retained. Redirect connection evidence stays monotone.
The owned transport exposes only RoundTrip and CloseIdleConnections, with no
protocol registration, custom dial callback, or inner transport access. It is
constructed from standard default settings, never from a caller's transport.
HTTPPool exposes idle retention limits only; the blob client retains its current
256 total / 64 per-host idle limits. Defaults remain 100 total / 2 per-host;
request concurrency and per-call bounds are unchanged. No new RPC or retry.
The real received-POST/lost-answer controls cover both a GetConn-only custom
transport and that same custom transport registered on a concrete Transport.
Both remain UNKNOWN. The native refused-dial positive still yields UNSENT75.
A separate control poisons the mutable global's protocol registration and proves
a newly owned transport receives the original server answer instead.
`TestDelayedPeerNotificationCannotRefreshAnOldTLSFailure` queues the
SubConn notifications of a failed TLS attempt until after a new RPC starts;
the delayed failure cannot become a terminal answer for that RPC. A fresh
attempt remains eligible, while an unobserved failure lacks proof. This
projects the existing admission/recovery obligation with no new state
machine or request. Source stamps add only fixed counters per TLS attempt
and connection, preserving O(1) connection/RPC state and O(P) peer state.
The observed TLS auth info forwards the underlying `AuthorityValidator`.
A matching per-RPC authority override still reaches the server; a mismatching
name is refused by the original certificate validator before any RPC receipt.
No validator means refusal, never an implicit authorization.
`TestObservedTLSForwardsPerCallAuthorityValidation` exercises the wrapped
master link with matching DNS/IP names and a mismatching name.
An already-ended single-filer preflight records UNSENT and both the context's
completion and its opaque caller cause. No census request starts. The owned
verify-silence sentinel retains its documented deadline mapping.
`TestChunkCensusPreflightPreservesOpaqueContextCause` covers custom cancellation
and deadline causes with zero census calls.
## Local certificate dates during rotation
CA bundles may retain unused expired or not-yet-valid certificates when the
bundle also contains a certificate valid at the current time. Local key-pair
loading checks the identity leaf's dates; unused supplied chain alternatives
do not block it. TLS still validates the chain it selects. A CA bundle with
no currently valid certificate, or an expired local identity leaf, is a local
configuration refusal (exit 78).