Skip to content

Add the attach-only Briosa.Cli JSON engine and commands for SA 2026.1.0529.7 - #465

Merged
davidalucas merged 19 commits into
mainfrom
445-cli-engine
Nov 28, 2026
Merged

davidalucas merged 19 commits into
mainfrom
445-cli-engine

Conversation

@davidalucas

@davidalucas davidalucas commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

First of four pull requests for #445 (Epic #440). It adds Briosa.Cli.exe for SpatialAnalyzer 2026.1.0529.7: the project, the shared engine, and the JSON commands, with their tests and an operations page. The CLI attaches to a local server that is already running, verifies it, and inspects a live session. It runs read-only operations only.

What later slices add

  • B: the stdio MCP server (Briosa.Cli.exe mcp) on the same engine and envelope, with ModelContextProtocol.Core.
  • C: packaging into the Windows ZIP, signing, notices and license evidence, CI and release workflow changes, and packaged fake-worker conformance.
  • D: the scripted licensed SpatialAnalyzer smoke check.

Mutating execution and the 2024.1.0508.5 target are later issues.

What this slice adds

  • targets/2026.1.0529.7/src/Briosa.Cli (console, net10.0-windows, win-x64) and tests/Briosa.Cli.Tests, both in Briosa.slnx with committed lock files. No new NuGet package: the CLI references Briosa.Protocol, Grpc.Net.Client, the existing central System.Diagnostics.DiagnosticSource pin, and a framework reference to Microsoft.AspNetCore.App. Everything restores offline from the cache.
  • Commands: status, ops categories, ops search, ops describe OPERATION_ID, call OPERATION_ID (--json TEXT | --input FILE) [--output FILE], version, help.
  • targets/2026.1.0529.7/docs/operations/briosa-cli.md, linked from the operations index.

Design choices

Engine layering. Engine/ holds everything both front ends need: endpoint parsing, the connection, server verification, discovery views, the JSON Schema, strict input, the dynamic call, outcome classification, result delivery, and the envelope. CommandLine/ only parses arguments, maps the outcome to an exit code, and writes the envelope. The engine never throws for an outcome. It is a generic protocol adapter over the compiled Briosa.Protocol descriptors and standard protobuf reflection, with no per-operation code.

Attach only, one verified connection. Endpoints must be http://, an IP loopback address (127.0.0.0/8 or [::1]), and an explicit port. Hostnames, including localhost, are rejected, as the server rejects them. The channel has no proxy, no redirects, no service config (so no retry or hedging), and a ConnectCallback that connects to the parsed address at most once. If the verified connection drops, the CLI never opens another one. A server that took over the port, perhaps an older one that ignores the restriction header, never receives the call. Below the gRPC client, each request may open exactly one HTTP/2 stream: the HTTP client's own resend of a refused stream is never written (review round 1, finding 2). The CLI's only RPCs are GetServerInfo, ListCapabilities, and the one MP call. A discovery row that names a method without MP execution details is refused, so even a misbehaving server cannot steer it to a lifecycle RPC.

Verification. Every command checks the exact target, the briosa package, and compatibility major 3. call also requires revision 2 (Server 0.10.2). Against an older server it fails closed with exit code 5 and sends nothing after GetServerInfo. Discovery commands work against revisions 0 and 1 and warn about what is missing (mp_step, request options, and so on).

Caller restriction. Every call sends exactly one briosa-caller-restriction: profile=read-only; deny=interactive_ui entry. The CLI does not decide admission. It refuses locally only for an invalid or unknown operation, an operation outside the read-only tier, invalid input, an output file it cannot create, or an unverified or too-old server.

Bridge tiers. These come from discovery metadata only; the first matching rule decides:

Tier Rule Count
excluded Any of physical_motion, device_session, device_config, code_execution, external_io; an exclusive-workflow, unknown or unrecognized scope; an unknown or unrecognized effect or flag; or an unreviewed row (unspecified duration class or validation status) 172
read_only (served by call) Read-only effect, self-contained or global-state-read scope, no flag except filesystem_metadata 184
read_only_restricted Read-only, same scopes, flags among filesystem_metadata, filesystem_read, interactive_ui (the 6 data-share getters and 11 runtime-selects) 17
mutating (reserved) Everything else 645

A pinned test computes the tier of all 1,018 registered operations from the server's own discovery projection and pins the counts.

Strict input. Before the protobuf parser runs, the request is checked against its descriptor:

  • Exact proto field names only. A camelCase alias gets suggested_field_name.
  • No null, no duplicate key at any depth, no unknown field, and at most one field per oneof.
  • 32-bit integers as JSON integers with no fraction or exponent. 64-bit integers as decimal strings, the form the protobuf mapping writes.
  • Doubles as finite numbers or "NaN", "Infinity", "-Infinity".
  • Enums by exact name only. Numbers are rejected, because similar enums number their values differently.
  • At most 256 KiB of UTF-8 and 32 levels of nesting. The encoded request must fit the server's 64 KiB receive limit.
  • Lone surrogates are rejected, never replaced.

A rejection gives a code, a schema path, and a byte offset, line and column. It never includes the offending text, not even an unknown key. MP messages use no other field kinds, and any other kind fails closed.

Envelope. One line of UTF-8 JSON, no BOM. The top-level members are always present: envelope_version, command, outcome, exit_code, endpoint, server, transport, failure, execution, data, warnings, guidance.

  • execution always has the same ten members: request_sent, caller_restriction, disposition, disposition_source, completion_evidence, recovery_guidance, replay_guidance, replay_safety, worker_generation, and mp_execution.
  • A disposition is never invented. Without a typed trailer, or when what came back is not consistent evidence about this call, it is null and completion_evidence is unavailable. The consistency rules are in the operations page and in review rounds 1 and 2. gRPC OK with consistent MP details is reported as COMPLETED from grpc_ok.
  • Result data is the protobuf JSON with exact names. Floating-point text is carried byte for byte.
  • Text from SpatialAnalyzer appears only as JSON string values in the result. It is never in warnings, guidance, stderr, or file names.

Exit codes:

Code Outcome
0 succeeded
1 internal_error
2 usage_error
3 rejected_locally
4 server_unreachable
5 server_incompatible
6 not_started (policy, caller restriction, readiness, capacity)
7 invalid_request
8 mp_failed
9 partial_success or outputs_incomplete
10 completion_evidence_unavailable
11 started_outcome_unknown
12 output_write_failed

Cap and spill. The receive allowance stays at 4 MiB. The default inline cap is 65,536 bytes of result JSON (--max-inline-bytes, 0 to 4 MiB).

  • A larger result goes in full to %LOCALAPPDATA%\Briosa\cli\2026.1.0529.7\results. The volume must keep file permissions, or nothing is spilled and the result is reported lost. Every directory below %LOCALAPPDATA% is opened or created relative to its held parent handle, never by path, without following a reparse point, refused if it is one, and held while the file is created. Only then, through its held handle, does results get a protected DACL for the current user and SYSTEM only, written to it alone, so that existing entries keep their permissions. The file is created relative to that handle with its own protected DACL for the same two, and must resolve to exactly the base's final path and the components. The file name is a timestamp, the requested operation ID and random hex.
  • The envelope gets the path, size, SHA-256, and a value-free field summary.
  • A result file is written, read back through its own handle and compared byte for byte with the result, flushed to the storage device, and closed. Only content known to be incomplete is removed, on either destination, and every file the call leaves on disk is named in the envelope (review round 6).
  • --output must not exist yet. It is created before any RPC and held exclusively, so an unwritable path is refused before anything is sent. An unused reservation is removed through its own handle. If writing it fails after a completion the evidence established, the result goes to the spill directory and the exit code is 12. Without established completion, the outcome stays exit 10. The MP is never run again to fetch data.

Project shape and shared files

On main (5ca27a84), I published the CLI and the server self-contained for win-x64 with the package script's release properties and compared every common file by SHA-256. I repeated the comparison at the head of this PR. All 335 shared files are byte-identical. The CLI adds four files (Briosa.Cli.exe, .dll, .deps.json, .runtimeconfig.json, 384,169 bytes at the head). AllowUnsafeBlocks for the source-generated Win32 calls changes only Briosa.Cli.dll. Both references are still needed:

  • Without the DiagnosticSource pin, System.Diagnostics.DiagnosticSource.dll differs.
  • Without the Microsoft.AspNetCore.App framework reference, Microsoft.Extensions.DependencyInjection.Abstractions.dll and Microsoft.Extensions.Logging.Abstractions.dll differ.

I did not change the package scripts.

How I verified it

Everything ran locally with offline restore (an empty RestoreSources folder and NuGetAudit=false) and no SpatialAnalyzer, license, or real worker. The heavy steps ran under the shared verification lock (Invoke-WithVerificationLock.ps1 -AgainstRef origin/main). All steps below passed.

Full locked run at 89820587:

Step 2026.1.0529.7 2024.1.0508.5
dotnet restore Briosa.slnx --locked-mode pass pass
dotnet build Briosa.slnx -c Release --no-restore (warnings as errors, 10.0-all) pass, 0 warnings pass
./eng/Verify-Protocol.ps1 -AgainstRef origin/main pass pass
dotnet test Briosa.slnx -c Release --no-build --no-restore --filter Category!=Performance, as CI runs it Cli 335, Server 1,564, Worker 415, LicensedProbes 445, Protocol 56 Server 1,535, Worker 432, LicensedProbes 445, Protocol 56, after one flaky failure (note below)
Performance steps (Test-RuntimePerformance.ps1 -NoBuild -IncludeGrpc, Test-ObservabilityPerformance.ps1 -NoBuild) pass pass
Debug reflection and ManualServerStartupTests pass pass
./eng/Test-WindowsPackage.ps1, Test-ProtocolArtifact.ps1, Test-ClientConformancePackage.ps1, Test-ClientScenarios.ps1 on the fresh package pass pass
Local SA host check, Control Center smoke, interop artifacts, MP naming policy pass pass

Note on the 2024 test step: in the locked run at 89820587, one 2024 server test failed: UnaryCallAuditPipelineTests.WithDebugOffGrpcBuildsThePreChangeInvocationPath. It measured 0.038 bytes allocated per call against an allowed 0.01. The 2024 target is identical to main (an empty diff since 5ca27a84), and the test measures allocations, so it is sensitive to noise. I reran the 2024 test step with CI's filter three times under the lock. All three passed, Server 1,535 each time.

Unfiltered dotnet test Briosa.slnx -c Release --no-build --no-restore (2026 target, under the lock):

  • At e7665542: 2 of 3 whole-solution runs failed, always in the server's WorkerProcessSupervisorTests.NormalLifecycleReportsStatesAndReleasesStaOnOwningThread. Its fake worker must stop within a 500 ms graceful bound and was reported Forced. One of those runs also had a performance test whose log directory was still in use when it tried to delete it.
  • Same runs, Briosa.Server.Tests alone: passed.
  • Baseline on main (5ca27a84): 3 of 3 whole-solution runs passed.
  • Cause and fix: the new CLI test assembly ran in parallel beside the server tests. 0a3c5ade runs the CLI test classes one at a time.
  • At 0a3c5ade: 3 of 3 unfiltered whole-solution runs passed, with all 1,571 server tests, including the performance ones.
  • At bbcf78f3: 3 of 3 unfiltered whole-solution runs passed: Cli 275, Server 1,571 including the performance tests, Worker 415, LicensedProbes 445, Protocol 56.
  • At d2b26b83: 3 of 3 unfiltered whole-solution runs passed: Cli 328, Server 1,571 including the performance tests, Worker 415, LicensedProbes 445, Protocol 56.
  • At 89820587: 3 of 3 unfiltered whole-solution runs passed: Cli 335, Server 1,571 including the performance tests, Worker 415, LicensedProbes 445, Protocol 56.
  • At bd1d681b: 3 of 3 unfiltered whole-solution runs passed: Cli 343, Server 1,571 including the performance tests, Worker 415, LicensedProbes 445, Protocol 56.
  • At b192800a: 3 of 3 unfiltered whole-solution runs passed: Cli 350, Server 1,571 including the performance tests, Worker 415, LicensedProbes 445, Protocol 56.
  • At a1fded8f: 3 of 3 unfiltered whole-solution runs passed: Cli 357, Server 1,571 including the performance tests, Worker 415, LicensedProbes 445, Protocol 56.
  • At the head, 444438d5: 3 of 3 unfiltered whole-solution runs passed: Cli 360, Server 1,571 including the performance tests, Worker 415, LicensedProbes 445, Protocol 56. See review round 8 for the rest of that round's verification.

Repository root, at bd1d681b (rounds 6 to 8 reran the isolation and propagation checks at their heads):

  • ./eng/Verify-TargetIsolation.ps1, Verify-CiWorkflow.ps1, Test-DependencySnapshot.ps1, and Test-CrossTargetProtocol.ps1 pass, the last with no new conflicts.
  • ./eng/Test-CrossTargetPropagation.ps1 reports the expected finding below.

Also passed in the locked run at 89820587: Verify-LicensedRunnerWorkflow.ps1 (both targets), Test-ReleaseCatalog.ps1, Test-ReleaseSigning.ps1, Test-RetainedClientPolicy.ps1, the compatibility-matrix checks, and the publishing unit tests.

What the 360 CLI tests cover (no SpatialAnalyzer needed):

  • Round trip: the strict-JSON path round-trips every request and result of all 1,018 registered operations, at least 8,144 cases. The cases cover default, populated, explicit-default and non-finite instances, and every arm of every real oneof. The covered set must equal the handwritten registry and the server's discovery projection.
  • Input: oneof conflicts, enums, 64-bit strings and doubles each have tests, and every strict-input rule is tested through the real call path.
  • Server replies: genuine replies of all 1,018 operations from their own output contracts, the real GrpcOperationOutcomeMapper and their own CreateResult (14,875 cases). An exhaustive enumeration of the mapper (45,207 replies, with every policy-denial rule and payload), and a single-change oracle derived from it (167,688 changes). A single-row case for each of the 26 operations whose result nests one field name under several top-level fields. 36 mapper shapes for one operation, with its real output contracts, through the real CLI.
  • Consistency: the evidence-consistency rules, single submission against a fake server that refuses a stream, and the delivery and preflight rules.
  • Files: real directory junctions at each managed spill level, a base junction re-pointed after each level of the traversal, the effective ACL of the spill directory and file read back from disk, existing entries in results kept byte for byte across two spills, an ancestor that denies new subdirectories, injected failures of the final-path and attribute queries, an unremovable incomplete file, a volume without ACLs, and the reservation-replacement race.
  • Delivery faults: a 664-cell matrix crosses every delivery fault point with the destination, the spill's own fault, refused removal, and whether completion was established. It predicts each cell from its faults alone and checks that prediction and six invariants against the files on disk, the handle log and the envelope (review rounds 6 to 8), including the order of the flush for every matched file. The real flush adapter is tested on a handle Windows refuses to flush.
  • Fake server: an in-process loopback HTTP/2 server with hand-written gRPC framing drives every outcome through the real CLI entry point. Each test checks the envelope, the exit code, and that exactly one MP RPC carried exactly one literal briosa-caller-restriction: profile=read-only; deny=interactive_ui entry, or that none was sent.
  • Hostile strings and tiers: hostile strings appear only as result data, and the tier counts are pinned.

Expected cross-target divergence

./eng/Test-CrossTargetPropagation.ps1 -BaseRef 5ca27a84ed7f80e7dd12cc0e6c0238e71090421e reports one finding: One-sided change: Briosa.slnx (2026.1.0529.7 modified, 2024.1.0508.5 unchanged). This is expected until the 2024.1.0508.5 port. Directory.Packages.props is unchanged.

Left out or worth a look

  • The tests read SpatialAnalyzerApi.Operations, the server's discovery projection (ServerDiscoveryService.BuildCapabilities), each operation's OutputContracts and CreateResult, MpPartialSuccessExceptions, OperationPolicy and the OperationPolicyDenial factory by reflection, because all are internal. Adding InternalsVisibleTo would have changed the server, which this slice must not do.
  • One TCP connection per session means a long-lived MCP session (slice B) must re-attach after Kestrel closes an idle connection. That matches the issue's "invalidate the session on disconnect and require explicit reattachment".
  • Spill files are not deleted automatically; expiry comes in Add controlled mutating execution, async long-running handles, and replay interlock to Briosa.Cli.exe #446.
  • Nothing here has run against a licensed SpatialAnalyzer; that is slice D.

Review round 1

These commits answer the adversarial review of cb435d66: 1c36f11d (the fixes), e7665542 (test literals and documentation), and 0a3c5ade (CLI test classes run one at a time; see "How I verified it"). The approved public surface is unchanged: command names, options, envelope members, exit code numbers, and tier names and counts.

Before changing code, I reproduced each finding with a new test that failed on cb435d66. I then proved each fix with a mutation that compiles and makes its test fail. All 22 mutations do.

# Reproduced on cb435d66 Change Mutation and result
1 OK plus an error trailer: exit 0. VALIDATION/NOT_STARTED for another operation: exit 7. DATA_LOSS + NOT_STARTED + MP success: exit 7. 13 further contradictions: exits 6 to 9. EvidenceConsistency: the trailer must name the requested operation, and every reported output must be a field of the result. Status, kind, disposition and MP details must match a shape the server's mapper produces. An OK must carry no error trailer. Any conflict gives exit 10, a null disposition, no recovery or replay guidance, and reconcile guidance. Correlation and shape check off: 12 tests fail. OK trailer ignored: 1. Result outputs not correlated: 1.
2 The fake server refused the first HTTP/2 stream and received a second MP stream. The resend came from SocketsHttpHandler retrying a REFUSED_STREAM on the same connection. gRPC has no retry policy, and reconnects were already blocked. A DelegatingHandler now grants each logical request one stream. The connection stream reads outgoing HTTP/2 frame headers and never writes a HEADERS frame that would open a stream beyond the grants. The call ends with request-resend-blocked, exit 10, and a warning saying the first attempt was refused and the second blocked. One extra stream permitted: 1 test fails.
3 With production at profile=read-only; deny=invalid_flag, all 232 tests passed. The wire contract is now literals in tests/Briosa.Cli.Tests/Wire.cs, and the fake server reads the header by its literal name (other instances below). Same mutation: 72 tests fail. Header name: 72. Trailer name: 60. Target: 143. Input limit: 3. One excluded flag removed: 3.
4 INTERNAL/worker-output-shape-invalid/COMPLETED without mp_execution: mp_failed, exit 8. This was the only kind of wrong mapping: 34 of the 36 mapper shapes were already right, and the two wrong ones were both shape-invalid cases. A completed failure other than MP_FAILURE is outputs_incomplete, exit 9. ServerFailureShapeTests builds all 36 shapes with the server's own GrpcOperationOutcomeMapper, by reflection, and runs each through the CLI. Old completed rule restored: 2 tests fail.
5 OK with SUCCEEDED and code 4, then a failed spill: exit 12, null disposition, guidance "The operation completed." Exit 12 only when the call's evidence established completion. Otherwise the outcome stays completion_evidence_unavailable (10), with data.result_delivery lost and data.result_delivery_error set. Delivery warnings name completion only when it is established. !delivered alone: 1 test fails.
6 From source, as the review found; tests below. Every directory below %LOCALAPPDATA% is created, opened with FILE_FLAG_OPEN_REPARSE_POINT, refused if it is a reparse point, and held without delete sharing until the file exists. The file is created with delete access and must resolve (GetFinalPathNameByHandle) to exactly the expected path, or it is removed through its handle. A reservation is held exclusively and removed through its own handle (SetFileInformationByHandle), never by name. Junctions made with mklink /J, no elevation: reparse checks and final-path check both removed: 3 of 3 junction levels fail. Reparse checks alone removed: 2 fail, because directories are created through an intermediate junction even though the final-path check stops the file. Delete by name after closing: the file that replaced the reservation is deleted, 1 fails.
7 stderr printed briosa-cli: not_started (customer-part-17). stderr names a code only when it is the CLI's own (source cli or transport) or in the server's documented vocabulary; otherwise server-diagnostic. The code stays in the stdout JSON. Vocabulary bypassed: 1 test fails.
8 A duplicated ID: exit 0 for describe, search and categories. call selected the impostor's method: the example request failed its input schema (exit 3); {} would have dispatched GetWorkingDirectory. Oversized discovery: RESOURCE_EXHAUSTED, exit 4, "start the server". Every listing must have unique, well-formed IDs and unique methods, each equal to /<service>/<rpc>. Otherwise every command gets exit 5, capabilities-inconsistent. RESOURCE_EXHAUSTED is exit 5, discovery-response-too-large. Only unavailable, deadline, internal, unknown and cancelled count as unreachable. Inconsistent listing accepted: 5 tests fail. Oversized read as unreachable: 1.
9 An existing --output file: exit 3 after two discovery RPCs. A call refused for localhost, a zero deadline, or an unknown option: execution: null. --output is reserved before any RPC and released through its handle on every later refusal. A recognized call refused before any RPC, including on usage errors, carries the not-sent execution block. Reservation moved after discovery: 1 test fails. Block omitted: 3.
10 http://127.0.0.1:80 printed as http://127.0.0.1. The stored port is always written. Port 80 dropped: 2 tests fail.
11 A BOM file reported byte offset 1 for a token at byte 4. The skipped preamble is added to the byte offset. Preamble not counted: 1 test fails.

Expected values taken from production code (finding 3), now literals:

  • FakeBriosaServer: the restriction header name, the exact target in GetServerInfo, and the error trailer name.
  • CallOutcomeTests: the restriction value (two assertions), the trailer name, and the MP outcome codes. Result files were compared with ProtocolJson.Format output; they are now decoded and compared with the result's protobuf bytes. Operations of each tier were picked with BridgeTiers.Classify; they are now picked from discovery metadata.
  • StrictInputCommandTests and ProtocolRoundTripTests: InputRejectionCodes.* and the input limits.
  • DiscoveryCommandTests: the requiredness statement and the input limits.
  • CommandLineTests: the usage line count and the target.
  • BridgeTierTests: the five excluded flags. A new test pins the production list to them.

What remains reasoning only:

  • No test races a concurrent rename against a spill while it is being created. Holding the directories without delete sharing and checking the final path close that window.
  • The final-path check covers a redirected %LOCALAPPDATA% itself, which the CLI does not manage.
  • Two mapper paths cannot be built with valid inputs, so the shape test does not include them: worker-result-missing (the outcome type forbids a completed status without an execution) and the transport default branch. The INTERNAL rule covers both.

CI flake: the 2024 package smoke and client scenarios, including watchdog-recovery, passed in both of my locked runs, at cb435d66 and at e7665542. I did not reproduce unexpected-rpc-Cancelled.

Review round 2

These commits answer the re-check of 0a3c5ade: c361a96f (the fixes and their tests) and bbcf78f3 (the operations page). The approved public surface is unchanged: command names, options, envelope members, exit code numbers, and tier names and counts. Diagnostic codes changed:

  • New: operation-error-enum-unrecognized, result-output-missing, spill-permissions-unsupported, and the warning spill-refused.
  • Removed: result-output-not-retrieved, the warning output-not-retrieved, and operation-error-disposition-unrecognized. What they reported is now conflicting evidence, exit 10 (items A and B).

Where this round changes a rule, it supersedes findings 1, 2, 4 and 8 of round 1.

Before changing code, I reproduced each item on 0a3c5ade with new tests. All 21 failed there, and the all-operations test misclassified 2,338 of 13,858 genuine replies. For D, the old behaviors had no test, so I reproduced each one by re-creating it as a mutation of the new code. I then proved every fix with a mutation that compiles and makes its test fail. All 22 mutations do.

Item Found on 0a3c5ade Change Mutation and result
A The server writes OutputRetrievalDetails.field_name from each operation's OutputContracts (CreateMpDetails, CreateSuccessfulMpDetails, CreateSdkFaultOutputDetails): one row per contract, in contract order, in every MP details it sends, with the contract's field name verbatim. Of the 1,018 operations, 312 declare 908 output names: 829 top-level fields, 57 dotted paths and 22 bare names of nested fields; 13 repeat a name for one aggregate field. The other 706 have no outputs. Only top-level names were accepted: every genuine reply with rows from 16 of the 312 operations was a conflict (224 cases), including relationship_operations.get_relationship_status. An OK with none of its outputs was exit 0. Two generic rules, no table of operations. R1: every row names something in the result: a top-level field other than execution, a dotted path that resolves through one, or a bare name of a field nested inside one. R2: every top-level field of the result is named by at least one row. On OK, every row must also be RETRIEVED, because the server answers OK only then. Round-1 rule (top-level names only): 2 tests fail. R2 removed: 2. Unretrieved rows accepted on OK: 3 cases.
B 13 contradictory errors were published with their guidance, with exits 6, 7, 8, 9 and 11. For example, MAY_REPLAY on a completed MP_FAILURE gave exit 8, numeric replay guidance gave exit 6, and OPERATOR_INTERVENTION_REQUIRED on a watchdog timeout without the dialog code gave exit 11. An unspecified disposition gave exit 10, but it kept the server's guidance. EvidenceConsistency carries the mapper's table per kind: status, disposition, replay guidance, recovery guidance, the code where the mapper fixes it, and the MP details. Replay guidance follows the replay safety discovery reported, which the error must also carry. Further rules: worker generation present and not negative; policy denial exactly on POLICY_DENIED with a known rule; request validation only on VALIDATION with request-validation-failed. Unknown enum values give operation-error-enum-unrecognized. An unknown diagnostic code alone stays data. One rule came from the derived oracle, not from reading: the mapper never pairs WORKER_UNAVAILABLE with operator recovery. Each of 8 mutations fails the derived oracle and the 22-case theory: replay unchecked, recovery unchecked, fixed codes unchecked, unknown enums accepted, replay safety uncorrelated, denial detail optional, operator recovery for the worker, generation optional.
C Exchanged IDs of analysis_operations.get_number_of_collections and file_operations.get_working_directory: call and ops search both gave exit 0. Each ID must name its method. With the underscores removed, category.operation equals Service.Rpc, ignoring ASCII case, without the briosa. package. This holds for 1,018 of 1,018 registered operations, with no exception. No ID names any other registered method: 0 of 1,035,306 cross pairs. A pinned test checks both, and a listing that breaks the rule gets exit 5 capabilities-inconsistent before anything else is sent. The round-1 test of a row pointing at a lifecycle RPC now stops here: exit 5, not 3. Binding removed: 3 tests fail. Case-sensitive compare: the pinned test fails.
D From source: the DACL was set by path, the file only inherited, and nothing checked that the volume keeps ACLs. As the review found, removing the ACL call passed every test. results is opened with READ_CONTROL, WRITE_DAC and WRITE_OWNER. Its owner and protected DACL (user and SYSTEM, container and object inherit) are written through that held handle (ObjectSecurity<FileSystemRights>.Persist(SafeHandle)). The file is created with its own self-relative descriptor: owner the user, protected DACL for the user and SYSTEM, no inheritance. GetVolumeInformationByHandleW must report FILE_PERSISTENT_ACLS on the base, before any directory is created. Otherwise the spill is refused: result_delivery is lost, result_delivery_error is spill-permissions-unsupported, and the warning spill-refused says the result was discarded and is in no file. Exit 12 only with established completion. New tests read the effective ACL back from disk, check a base junction re-pointed after the directories are held, and inject a volume without ACLs. No DACL: 2 tests fail. DACL by path: 1 (the re-pointed junction). File inherits: 1. Volume not checked: 2 cases.
E The 706 operations without outputs: every genuine output failure (OUTPUTS_UNAVAILABLE, withheld getter outputs) was a conflict, 2,114 cases. An output failure needs at least one failed row, or no rows at all. With R2, no rows passes only when the result has no output fields. MapperEnumeration drives the real mapper over every constructible worker outcome in finite domains: 90,516 attempted, 42,240 rejected by their own constructors, 49,035 replies (759 results, 48,276 typed errors, 5,523 distinct signatures, all 17 kinds). Every reply is classified as its real outcome. A single-change oracle then changed one field of each signature at a time (status, kind, disposition, recovery, replay, replay safety, code, generation, details, MP state, code and rows): 147,726 changes. The 33,327 producible ones are accepted, the 114,288 never produced are refused, and 111 fall in the gap below. ServerMapperShapes now uses the operation's three real output contracts, not a one-output stand-in. Round-1 rule: 4 tests fail.
F A status-only RESOURCE_EXHAUSTED from discovery was reported as discovery-response-too-large. ReceiveEvidenceHandler passes each response body through unchanged and reads the length prefix of its first gRPC message. Only a declared length above the 4 MiB receive limit is reported as too large. Any other RESOURCE_EXHAUSTED is exit 5 transport-resource-exhausted. Every RESOURCE_EXHAUSTED read as too large: 1 test fails. Prefix never observed: the oversized test fails.
G The warning said the server refused the stream or closed the connection "before processing it". It now says the HTTP client tried a second time, that the CLI blocked it, and that whether the server received or processed the first attempt is not known. Exit 10 is unchanged. Round-1 wording: 1 test fails.

What the rules cannot detect (also on the operations page):

  • A missing row for a nested field when another row already names the same top-level field, for example four of the five status fields of get_relationship_status.
  • Extra, repeated, or reordered rows, or the wrong number of rows for an aggregate.
  • A reply that answers another call, or another operation with the same result message.
  • Whether a retrieved value is the one SpatialAnalyzer returned.

I evaluated a stronger rule, a row for every leaf of a field named only through nested names, over the registry and rejected it. gdt_operations.get_gdt_options shares GdtOptions with a setter, and two of its optional fields are never outputs.

Known gap: MP code 4. The server reports code 4 as an MP failure for four reviewed operations (MpPartialSuccessExceptions). Without a table of operations, the CLI accepts code 4 in an MP failure of any operation, and a code-4 partial success of those four. The oracle counts these 111 cases separately. A pinned test shows that none of the four is in the read-only tier, so call never sends them.

What the enumeration does not cover: worker diagnostic codes beyond the mapper's own codes and fallbacks, one ordinary code and one it must replace; nine sample MP codes; six representative operations (the all-operations test covers the completed paths of all 1,018); worker generations 0 and 3; one policy denial per rule the real policy reaches for the read-only and full profiles; one typed value per output kind. In the all-operations test, the sample values make robot_operations.get_robot_machine_model_link_parameters fail its own result mapping, so that operation's genuine success is the executor's result-mapping-failed, which is classified as such.

Verification: the locked run in "How I verified it" is at the head of this round, for both targets, including the four package scripts. main is still 5ca27a84, so nothing was merged.

Review round 3

These commits answer the second re-check of bbcf78f3: e2376e9a (the fixes and their tests) and d2b26b83 (the operations page). The approved public surface is unchanged: commands, options, envelope members, exit codes, tiers, and diagnostic codes. Before changing code, I reproduced each item on bbcf78f3 with new tests. 45 failed there: the 26 single-row cases, the datum case through the CLI, the 13 denial cases, the served-read code-4 case, and the 4 redirect points. The 7 positive denial cases passed. I then proved each fix with a mutation that compiles and makes its test fail. All 8 do.

Item Found on bbcf78f3 Change Mutation and result
A One RETRIEVED row named collection_name was a success for gdt_operations.get_feature_check_datum_references (exit 0), because the bare name is nested in all three datum fields. The review counted five such operations. Searching the result descriptors for any field name nested under two or more top-level fields finds 26 (15 in the read-only tier), for example the circle, cone and line property getters, whose two vector fields both contain x. A single-row case failed for all 26. R2 is now a matching, not an existence check. Rows are matched to the result's top-level fields (Kuhn's augmenting paths), and every field needs a different row that names it. The genuine replies of all 1,018 operations still pass (14,875 cases). Each of the 26 has a single-row negative case, and the reviewer's case also runs through the real CLI. Existence check restored: all 27 cases fail.
B Changing only a genuine server denial's rule to CALLER_FLAG, with no caller_denied_flag, gave exit 6 with caller-restriction-denied. 13 denials that do not fit their rule were all accepted. Each rule must carry exactly its own fields, as OperationPolicyDenial.ToDetails writes them. PROFILE needs admission_profile; FLAG needs denied_flag; CALLER_PROFILE needs caller_admission_profile; CALLER_FLAG needs caller_denied_flag; OVERRIDE and UNREVIEWED carry nothing; request_option_field is allowed on the others and must not be blank. Caller values are checked against the restriction the CLI sent: the server names the restriction's profile, and the first of the request's flags that the restriction itself denies (EvaluateCallerRestriction), so read-only and interactive_ui. The oracle now enumerates each rule with its payload from the server's denial factory: every profile, every risk flag, and with and without an option. Caller rules use the restriction's own values. A test runs the real policy with the CLI's restriction over every operation and reviewed option (29 caller denials, three payload shapes) and checks that each is one the oracle has. The signature carries each field's presence and the caller values. Payload unchecked: the 13-case theory and the oracle fail. Caller values unchecked: 3 cases and the oracle fail.
C With the base junction re-pointed after the base, Briosa or cli was held, the CLI rewrote the owner and access list of elsewhere\Briosa\cli\results, outside the intended tree, then refused the file. The base is opened by path once and held. Each managed directory is then opened, or created (FILE_OPEN_IF), with NtCreateFile relative to its held parent's handle (RootDirectory), as itself (FILE_OPEN_REPARSE_POINT), refused if it is a reparse point or not a directory, and held without delete sharing. Only then does results get its owner and DACL, through its own handle. The file is created relative to the results handle with its own descriptor. Its reported path is its final path, checked against the base's final path and the components. Every path element must be a single name. Directories opened by path again: 3 of the 4 redirect points fail. File created by path: all 4 redirect points fail.
D A served read that reported MP code 4 as a failure gave exit 8, as a checked-in test expected. The call context carries CodeFourMayBeFailure, which is true only outside the read-only tier. For a served read, code 4 in an MP failure is conflicting evidence, exit 10, with no table of operations. The pinned test that no code-4-as-failure operation is in the read-only tier stays. The engine notes that a later mutating tier must keep the flag true for its operations. The old test now checks, in-process, that each of the four exception operations' genuine code-4 reply is still an MP failure outside the read-only tier. Rule removed: the served-read test and the oracle fail. Engine passes the flag as true for reads: the served-read test fails.

C, what the design guarantees: whatever happens to any path during the call, including a redirection of %LOCALAPPDATA% between two levels, the CLI changes owner or permissions only on the results directory inside the tree that %LOCALAPPDATA% led to when the CLI opened it, and creates the file only there. A new theory re-points the base after each of the four levels and checks the SDDL and existence of every pre-existing entry under the test root. Nothing outside the verified tree changes, and the spill succeeds in the verified tree. What it does not guarantee: that %LOCALAPPDATA% leads where the user expects when the CLI opens it, because whoever can redirect that folder chooses the tree. Another process running as the same user can still change the file or its permissions after the write. An --output file is not a spill file and keeps the permissions of the directory the caller chose.

Oracle at the head: 79,032 attempted outcomes, 34,584 rejected by their constructors, and 45,207 replies (759 results, 44,448 typed errors, 6,216 distinct signatures, all 17 kinds), each classified as its real outcome. 167,688 single changes: 37,575 producible ones accepted, 130,092 never produced refused, and 0 failures. The remaining 21 known-gap accepts are all the mirrored code-4 gap for the one exception operation in the enumeration, which is outside the read-only tier. Denials are no longer crossed with connections and deadlines, which the mapper does not read for them; the limits text says so.

Documentation: the operations page now has the row matching and its limits, the denial payload table, the read-only code-4 rule and its dependency, the spill design and its guarantees, that a fixed-code row conflicts on its code alone, and that a failed --output keeps output-write-failed when its spill fallback is also refused.

Verification: the locked run in "How I verified it" is at the head of this round, for both targets, including the four package scripts, and so are the unfiltered runs and the root checks. main is still 5ca27a84, so nothing was merged. Where this round changes a rule, it supersedes round 2: items A, B and D (spill), and the code-4 gap, which is now closed for every operation call serves.

Review round 4

These commits answer the third re-check of d2b26b83, which found problems in the spill code only: 482a95bb (the fixes and their tests) and 89820587 (the operations page). The approved public surface is unchanged. Before changing code, I reproduced each item on d2b26b83 with a new test. 5 of the 7 new tests failed there. The other two pin behavior that held before and must hold after: a fresh tree, and a refusal where a parent denies creating a missing directory. I then proved each fix with a mutation that compiles and makes its test fail. All 5 do.

Item Found on d2b26b83 Change Mutation and result
1 An ordinary file in results with inherited permissions had a different owner-and-access-list binary after a spill. Writing the directory's security with ObjectSecurity.Persist(SafeHandle) (SetSecurityInfo) propagates inheritable entries to existing children. The owner and protected DACL of results are written with SetKernelObjectSecurity on its held handle, which writes that object alone. The protection comes from the descriptor's SE_DACL_PROTECTED flag. A new test puts an ordinary file and a folder, both with inherited permissions, in results, then spills twice. Both keep their binary owner and access list byte for byte, and so does the first spill file across the second spill. results and both spill files end with the intended protected lists. Earlier spill files carry their own protected list, which propagation does not rewrite, so they should have been unaffected before too. That part is reasoning, not something I tested on d2b26b83; the test now pins it. Propagating write restored: the test fails.
2 With the tree already present and the intermediate directory denying the current user FILE_ADD_SUBDIRECTORY, the spill failed: every level was opened asking for that right. Every directory is opened with FILE_READ_ATTRIBUTES and FILE_TRAVERSE only, plus WRITE_DAC and WRITE_OWNER on results. No right to create is requested on any handle. Where a directory or the file must be created, the file system checks the parent's own permissions at that moment. Tests: an existing ancestor that denies new subdirectories is passed through; a fresh tree is created level by level; a missing directory under a parent that denies it is refused, and nothing is created. Right requested on every level again: the restricted-ancestor test fails. The fresh-tree test passes, as it should.
3 An injected failure of the new file's final-path lookup left an empty file in results. An injected failure of a directory's attribute query left that directory's handle open, so the directory could not be renamed. Both are fixed. Every error path in ResultFiles.cs and the result delivery that uses it is listed below. Created file only closed: the final-path test fails. Directory handle kept: the rename test fails. Failed spill write keeps the file: the new partial-file test fails.

Item 3, every error path checked:

Path Before Now
A new spill file whose final-path lookup, or ResultFile construction, fails Handle closed, empty file left in results Removed through its own handle, then closed (Adopt)
A new --output reservation whose ResultFile construction (the FileStream) fails Handle leaked, empty file left Removed through its own handle, then closed (same Adopt); found in this review
A directory's attribute query throws (base or managed level) Handle left open until finalization Closed before the exception leaves RequireDirectory
A directory that is a reparse point or not a directory Closed Closed (unchanged)
A spill write that fails part way Handle closed, partial file left in results Removed through its own handle (TryWrite discards spill files); found in this review
An --output write that fails part way Partial file kept, as documented Unchanged: the caller named the file
ResultFile.Dispose when the stream's own close throws Handle left open Handle closed in a finally; found in this review
ResultFile.Discard after the file was already closed Would call the delete on a closed handle Does nothing
The base or a level fails to open (CreateFile, NtCreateFile) Handle disposed; parent reference released Unchanged
The volume check, protection or file creation fails Every held directory closed in finally Unchanged
The final-path check of the new file fails Removed through its handle Unchanged
A managed directory created before a later failure Kept Kept by design, as after a successful spill; documented
An unused --output reservation whose cleanup query fails Closed, an empty file may remain Unchanged; documented in round 1

Item 4: the mapper oracle's known-gap text now says that code 4 is accepted as a failure only outside the read-only tier, and that for a served read it is conflicting evidence.

Documentation: the spill section now states that the permissions of results are written to it alone, so existing files, folders and earlier spill files keep their own. It also states which access is requested, that a spill file is removed through its handle if anything fails before it is written in full, and that created directories are kept.

Verification: the locked run in "How I verified it" is at the head of this round, for both targets, and so are the unfiltered runs and the root checks. Only src/Briosa.Cli, tests/Briosa.Cli.Tests and the documentation page changed, so the package scripts and the 2024 target did not need rerunning. They ran anyway, because the shared harness runs everything. The 2024 test step failed once in that run, in a server allocation test, in a target identical to main; three reruns under the lock passed (see the note there). main is still 5ca27a84, so nothing was merged.

Review round 5

These commits answer the CI failure at 89820587 and the fourth re-check of 89820587: 3b078ba6 (the fixes and their tests) and bd1d681b (the operations page). The approved envelope members and exit code table are unchanged. New values: delivery states file_unconfirmed and file_unverified; delivery errors spill-finalize-failed, output-finalize-failed and spill-verify-failed; result-file reason incomplete_not_removed; warnings result-file-unconfirmed, result-file-unverified and incomplete-file-left.

CI failure of ASpillChangesNothingAlreadyInTheResultsDirectory (job https://github.com/spatialanalyzer/briosa/actions/runs/46121899794/job/140908023131, windows-2025-vs2026, as runneradmin with an elevated token). The test failed at line 33, which compares ordinary.txt, a file created in results before the spills, before and after two spills.

  • What the bytes show. .NET writes the owner first, then the access list. The first difference is byte 73, the flags of the access entry at byte 72. It went from inherited (0x10, 20 bytes: a one-subauthority SID such as SYSTEM) to explicit (0x00, 24 bytes: a two-subauthority SID such as BUILTIN\Administrators). The 72 bytes before it are identical: the control flags, the owner, the access list's size and entry count, and the first entry. A 16-byte owner (BUILTIN\Administrators, the default owner under an elevated token) is the only owner size that puts an entry at byte 72.
  • What that rules out. The spill never opens ordinary.txt; it writes security only to the held results handle. Propagation of the spill's list would replace the file's inherited entries with the user (36 bytes) and SYSTEM (20 bytes), changing the count, and could never make an entry explicit. So the change is not the spill's list propagating. Nothing else in the repository sets ACLs on an ancestor of the test tree. (Searched: the only other writer is DesktopStore, which works under %LOCALAPPDATA%\Briosa\ControlCenter.)
  • What is not established. Which mechanism rewrote that entry on the runner. I cannot run under an elevated token here, and the old assertion printed only five bytes. The old fixture also inherited whatever the runner's temporary folder grants, so it was neither deterministic nor, as review item 4 showed, able to detect a propagating writer in every environment.
  • Change. The test now gives its own tree a protected access list: the user and SYSTEM, a BUILTIN\Users entry that any propagation from results would visibly remove, and a CREATOR OWNER entry. The CREATOR OWNER entry resolves to the user under an ordinary token and to Administrators under an elevated one, which exercises the elevated case. On failure, the test reports the owner-and-access-list SDDL of the root, results, both pre-existing entries and both spill files, at each of the three stages. The propagating writer, with the READ_CONTROL it needs, makes the test fail on its comparison (ordinary.txt changed.), not on access denied.
  • Product verdict. The spill's own writes are as documented under both kinds of account; see below. Whether the runner's change is a test assumption or a platform effect of the spill will show in this head's CI: a pass, or a failure that now carries the full descriptors.

Who owns and can access the spill files. The same under an ordinary account and an elevated administrator account. results and each spill file are owned by the current user's own SID, set explicitly, so never BUILTIN\Administrators, which would otherwise own new objects under an elevated token. Each has a protected access list with full control for that user and for SYSTEM only, inheritable on results and not on the file. That is what the documentation promises. An administrator can still take ownership, or read with backup privileges, outside the CLI's control. TheSpillDirectoryAndFileAdmitOnlyTheUserAndSystem, which asserts this owner and list on disk, passed on the elevated runner at 89820587.

Item Found on 89820587 Change Mutation and result
1 As the reviewer's probe found: a flush error after the full payload deleted the complete spill file and reported lost, and a close error kept the file but still reported lost. I reproduced both by re-creating the old behavior as mutations of the new code (right-hand column); the new tests fail on them. A result file is written, then read back through its own handle and compared with the result, then flushed and closed. Result files now open with read access for this. Only content known to be incomplete (shorter or different) is removed. A file that read back intact, but whose write, flush or close reported an error, is kept as file_unconfirmed. One that could not be read back is kept as file_unverified. An --output file that read back intact is kept and reported, with no spill. Tests cover each fault point for a spill (before any byte, after a 3-byte prefix, at flush, at close, at read-back) and for --output (prefix, flush, close). Flush error discards the file: both theories fail. Late error reported as lost: both fail. Unreadable file trusted: the spill theory fails.
2 Confirmed: the partial-write test failed before writing any byte, so removing only empty files passed it. The prefix case writes and flushes 3 bytes before failing. Removal only when empty: the spill theory fails.
3 As the reviewer found: with the 3-byte file made read-only, the delete was refused and nothing reported it. The new test makes the file read-only through its handle; re-creating the silent cleanup as a mutation makes it fail. The incomplete file is named in data.result_file with its size on disk, no SHA-256 and the reason incomplete_not_removed, and the warning incomplete-file-left. The docs now say removal can fail. Leftover not reported: the new test fails.
4 Confirmed by the reviewer: with the temporary folder granting only the user and SYSTEM, a propagating writer passed. The protected, seeded test tree described above. Propagating writer: fails on the comparison.
5 Stale comment; SYNCHRONIZE missing from the docs. Both fixed. n/a

Delivery states (the operations page has the table):

  • none: no result came back.
  • inline: data.result holds the whole result.
  • file: the file read back as exactly the result, and flushed and closed without an error.
  • file_unconfirmed: it read back as exactly the result, but the write, flush or close reported an error, so it is not confirmed to stay intact. It is kept.
  • file_unverified: the spill file could not be read back, so whether it holds the result is not known. It is kept.
  • lost: no file the CLI can vouch for holds the result. result_file may name an incomplete file it could not remove.

Any state other than inline and file, and any failed --output file, is a failed delivery: exit 12 only when the call's own evidence established completion.

Verification at bd1d681b, under the lock, in the 2026 target:

  • Locked offline restore: pass.
  • Release build: pass, 0 warnings.
  • Tests with CI's filter: Cli 343, Server 1,564, Worker 415, LicensedProbes 445, Protocol 56.
  • Unfiltered whole-solution run: 3 of 3 passed, Server 1,571 each time.
  • From the root: Verify-TargetIsolation, Verify-CiWorkflow and Test-DependencySnapshot passed, and Test-CrossTargetProtocol passed with no new conflicts. Test-CrossTargetPropagation reported only the expected Briosa.slnx finding.
  • Only src/Briosa.Cli, tests/Briosa.Cli.Tests and the operations page changed, so I did not rerun the package scripts or the 2024 target. The full harness table above is from 89820587.
  • main is still 5ca27a84, so nothing was merged.

Review round 6

These commits answer the fifth re-check of bd1d681b, which found combinations of faults that result delivery reported wrongly: afc1d4d2 (the change and its tests) and b192800a (the operations page). The approved envelope members and exit code table are unchanged. New values inside existing members:

  • data.result_file gains verification (matched, matched_unconfirmed, not_read_back, incomplete) and other_files, every other file the call left on disk, in the same form.
  • A new delivery error, output-verify-failed, and a new result-file reason, reservation_not_removed.
  • New warnings: result-lost, spill-write-failed and output-reservation-left. spill-write-failed is the spill's own failed write, which round 5 reported as output-write-failed.
  • The statement that no file holds the result moved from spill-refused to result-lost, which is given exactly when the state is lost.

Rather than adding one more case, delivery now keeps one record per file the call wrote or created: what reading it back showed, whether a later step reported an error, and whether it is still on disk. The delivery state, data.result_file, the error, and the warnings are all derived from those records. A fault matrix checks six invariants across every combination of fault points, against the files on disk.

Finding Reproduced on bd1d681b Change Mutation and result
1 Yes, with the reviewer's probe. The --output file held all 821 bytes, yet the delivery was lost, result_file was null, and a warning said the result was "not in this envelope or in any file". Exit 12. An --output file that could not be read back is kept and named as not_read_back, with the result's size and SHA-256 to check it against. The state is file_unverified and the error output-verify-failed, distinct from a known mismatch, and the warning says how to check the file. result-lost appears only when no file may hold the result. The old behavior (the unverified --output file not named) fails the new test and 120 matrix cells (I1, I3). The old wording (a refused spill says "in no file") fails the new test and 8 cells (I1).
2 Confirmed by reading the code; the reviewer also inspected the .NET IL. The documented post-read flush was the parameterless Stream.Flush() on a FileStream with no buffer, which never reaches the operating system. No test could see the difference. After the read-back, RandomAccess.FlushToDisk (FlushFileBuffers on Windows) flushes the file. A failure makes the file matched_unconfirmed. Result files are now written and read through their handle with RandomAccess, behind a small internal IResultFileIo seam that tests use to inject faults and log what really happened. The operations page says what the flush establishes and what it does not. Flush removed: 168 cells (I2) and 4 tests fail. Flush failure ignored: 84 cells (I2) and 3 tests fail.
3 Yes. On bd1d681b with the byte comparison replaced by a length check, all 343 committed tests passed; only the reviewer's probe failed. A unit test (123 read back against 124), a CLI test whose spill file has the right length and one different byte, and the matrix's ContentMismatch fault on both destinations. Length check only: both new tests and 80 cells (I2, I4) fail.
4 Yes, with the reviewer's probe. A zero-byte spill file remained, with result_file null and only output-write-failed. A new spill file is handed over only at its verified path. On any failure before that, it is removed through its handle. If the removal is refused too, ResultFileLeftException carries the path the file was created at, and the envelope names it as incomplete: 0 bytes, incomplete_not_removed, the warning incomplete-file-left. An unused --output reservation that cannot be removed is named as well, with output-reservation-left. Removal is judged by whether the handle accepted the delete, not by File.Exists. The old swallow fails the new test and 24 cells (I3).

The reviewer's three probes pass at afc1d4d2, with one line changed to the new write call.

One behavior change beyond the findings. An --output file that read back shorter or different is now removed through its handle, as a spill file is. The CLI created it, since the path must not exist beforehand. An incomplete file at the caller's path could be taken for the result by anything that reads the path without the envelope. A file that may hold the result is never removed.

Invariants (on the operations page, checked by DeliveryFaultMatrixTests):

  • I1. If any file on disk may hold the whole result, the envelope names it, with its verification and the result's size and SHA-256. It is never removed, and the result is never reported as absent.
  • I2. matched, and the state file, only when the file was read back in full as exactly the result and the write, the flush to disk, and the close all succeeded.
  • I3. Every file the call created and left on disk, complete or not, is named in data.result_file or its other_files.
  • I4. A file known to be incomplete is incomplete, with no SHA-256 and an explicit reason, and never matched or matched_unconfirmed.
  • I5. Exit 12 only when completion is established. Otherwise the evidence's outcome stands and data.result_delivery_error records the failed delivery.
  • I6. Result data is in the envelope only for an inline delivery within the cap.

The matrix. Each cell runs the real CLI entry point against the in-process fake server, and all 664 take about 8 seconds.

  • What each cell checks. The six invariants, against every file under the test's root after the call and a log of the real handle operations: what bytes reached each file, its reads, flushes, closes, and refused removals. A file counts as complete when its bytes on disk equal the result's.

  • Fault points for a spill only: opening a directory, setting the permissions of results, a volume without permissions, creating the file, a failed final-path lookup at hand-over, and a final path that differs.

  • Fault points for either destination: a write that fails before any byte, after a 3-byte prefix, or after the whole payload; the right length with one different byte; the read-back's length query; its read; the flush to disk; and the close. There is no separate open for the read-back: it uses the file's own handle, and the length query is its first step.

  • The cells:

    • inline: the default cap, with every spill fault armed, to show nothing is touched;
    • spill: a cap of 0;
    • --output: each of its faults (or none) crossed with each spill fault (or none).

    Each is crossed with removal that works or is refused, and with completion established (MP code 2) or not (a code-4 contract violation, exit 10). That makes 60, 60 and 540 cells, plus 4 for an unused --output file: no result, or refused before the operation is found, each with removal working or refused. 664 in all.

  • Result: every cell keeps every invariant.

Where an invariant cannot fully hold, or a fault is not real:

  • Refused before the operation is found (2 cells). data is null by the approved shape, so an unremovable reservation is named only by the warning output-reservation-left, which refers to it as "the --output file". The caller supplied that path.

  • A close that reports an error. It can only be injected: .NET's SafeFileHandle ignores the result of CloseHandle. In practice the flush is the last step that can fail.

  • A final path that differs at hand-over. It can only be injected. Real redirections are stopped earlier by the held handles (round 3).

  • Not in the matrix:

    • two faults on the same file at once;
    • creating the --output reservation, which fails before any RPC as a local rejection with nothing on disk, covered by the round 1 tests;
    • the server-side outcomes beyond the two completion cases.

    And by design: the read-back reads what the file system holds, possibly from its cache, and a device that acknowledges writes it has not made durable is beyond the CLI.

Mutations of the product the matrix catches (each compiles; the whole CLI suite ran for each):

Mutation Matrix Other tests that fail
A file that could not be read back is removed 152 cells (I1, I3) 2
A failed flush to disk is ignored 84 cells (I2) 3
An incomplete file left on disk is not named 120 cells (I3) 2
An incomplete file is given the result's SHA-256 120 cells (I4) 2
Exit 12 without established completion 268 cells (I5) 2
A failed spill falls back to an inline result 56 cells (I6) 2

With the five finding mutations above, 11 of 11 mutations fail the matrix. In my first mutation run, the harness kept only the last 400 lines of detailed test output, which dropped the failure of the length-check mutation. I reran all 11 with the whole output, and the counts above are from that run.

Verification at b192800a, under the lock, in the 2026 target:

  • Locked offline restore, from a new empty source with NuGetAudit=false: pass.
  • Release build: pass, 0 warnings.
  • Tests with CI's filter: Cli 350, Server 1,564, Worker 415, LicensedProbes 445, Protocol 56.
  • Unfiltered whole-solution run: 3 of 3 passed, Server 1,571 each time.
  • From the root: Verify-TargetIsolation passed. Test-CrossTargetPropagation reported only the expected Briosa.slnx finding.
  • Only src/Briosa.Cli, tests/Briosa.Cli.Tests and the operations page changed, so I did not rerun the package scripts, the other root checks, or the 2024 target.
  • main is still 5ca27a84, so nothing was merged.

Review round 7

These commits answer the sixth re-check of b192800a: 1dc366c8 (the fixes and their tests) and a1fded8f (the operations page). The approved envelope members and exit code table are unchanged. New values inside existing members:

  • A delivery error, result-report-failed, which marks a defect in the CLI, not a delivery fault.
  • A warning, result-hash-unavailable.
  • output-reservation-left now gives the reservation's path.
  • A null sha256 on a file that may hold the result, when the SHA-256 could not be computed.

I reproduced each finding on b192800a in this worktree, with temporary probes I removed afterwards. Then I proved each fix with a mutation that compiles and makes a test fail.

Finding Reproduced on b192800a Change Mutation and result
1 Yes. With the reference's SHA-256 made to throw, the --output file held the whole result, but the envelope said lost, result-format-failed and result-lost, named no file, and exited 12. Formatting, summarizing and the SHA-256 now run before any file exists. Only formatting and summarizing are caught as result-format-failed. A SHA-256 that cannot be computed leaves sha256 null on every entry, with result-hash-unavailable. The file is still written, read back byte for byte and named. The report is built in memory from the file records, naming the files first. The engine's catch no longer overwrites anything delivery recorded; it only records result-report-failed for a defect. SHA-256 failure not caught: both cases of the new test (--output and spill) fail. SHA-256 taken after the files and unguarded, as before: both fail.
2 Yes. SystemResultFileIo.FlushToDisk returned normally on a real read-only handle, on which Windows refuses the flush with ERROR_ACCESS_DENIED. The adapter calls FlushFileBuffers itself and throws on any failure, which makes the file matched_unconfirmed. A new test calls the real adapter on a real read-only handle and expects ERROR_ACCESS_DENIED; another lets a writable handle pass. Back to RandomAccess.FlushToDisk: the adapter test fails. The reviewer's no-op flush (GC.KeepAlive): the adapter test fails.
3 Yes. With the fallback spill skipped after an unreadable --output file, the old matrix passed all 664 cells; only the separate refused-spill test failed. With the spill winning a tie, all 350 tests passed. The matrix now predicts each cell from its injected faults alone (below), and compares the disk, the handle log and the envelope with that prediction. No fallback spill: 96 cells fail, plus the refused-spill test. Spill wins a tie: 46 cells fail (M-primary).
4 Yes. After an unknown-operation refusal with the reservation's removal refused, the empty --output file remained and the warning gave no path. After a failed hand-over with removal refused, the warning said no spill file could be created while the empty file existed. output-reservation-left gives the resolved --output path, which the caller supplied. A spill file that fails its hand-over checks and cannot be removed is its own outcome: the warning says it failed its checks and could not be removed, with incomplete-file-left. A creation failure says no spill file is left. No path: 2 cells (I3) and the new test fail. Hand-over reported as a creation failure: 24 cells and 2 tests fail.
5 Yes. The read-back measured three bytes, a second length query threw, and removal was refused; the entry said incomplete with bytes null. The read-back returns the length it measured, and an incomplete file keeps that size. No second query is made. Size queried again: the new test fails.

How the matrix's oracle is now derived. Before looking at the envelope, each cell predicts what must happen, using the operations page's rules applied to its faults:

  • What each fault leaves:
    • A creation fault leaves no file.
    • A hand-over fault leaves an empty incomplete file.
    • A write before any byte leaves an incomplete file of 0 bytes; after a prefix, 3 bytes; a content mismatch, the full length.
    • A write error after the payload, a flush error or a close error leaves matched_unconfirmed.
    • A read-back fault leaves not_read_back.
    • No fault leaves matched.
  • Which files are written: the --output file, if given. A spill is written without --output, and also behind an --output file that is neither matched nor matched_unconfirmed.
  • What stays on disk: a file that may hold the result always stays; an incomplete one stays only when removal is refused.
  • Which file is named first: matched, then matched_unconfirmed, not_read_back, incomplete; on a tie, the --output file. This rule is stated on the operations page, in the model, and in the product.
  • The rest of the prediction:
    • State: that of the first file named.
    • Delivered: only when the file the result had to go to is matched.
    • Exit: 10 without established completion; otherwise 0 when delivered, else 12.
    • Error: the --output file's when there is one, otherwise the spill's.
    • Warnings: result-lost, spill-refused, result-spilled and incomplete-file-left.

The checks then compare:

  • the handle log with the predicted write attempts, including the fallback;
  • each file on disk with the predicted file, by size and by whether it holds the result;
  • the envelope with the predicted files named, in order, with their labels, and with the predicted state, error, exit and warnings.

The six invariant checks still run on top. In the unused-reservation cells the model checks the warning's path as well.

Mutations at the head (15; each compiles, and the whole CLI suite ran for each):

Mutation Matrix Other tests that fail
SHA-256 failure not caught passes 2 (the round 7 test)
SHA-256 after the files, unguarded passes 2
Flush through RandomAccess.FlushToDisk passes 1 (the adapter test)
Flush does nothing passes 1
No fallback spill after an unreadable --output 96 cells 1
Spill wins a tie 46 cells 0
Reservation warning without path 2 cells 1
Hand-over reported as creation failure 24 cells 2
Incomplete size queried again passes 1
A file that could not be read back is removed 152 cells 2
A failed flush is ignored 84 cells 3
An incomplete file left on disk is not named 120 cells 3
An incomplete file gets the result's SHA-256 120 cells 2
Exit 12 without established completion 268 cells 2
A failed spill falls back to inline 56 cells 2

The matrix does not inject a SHA-256 failure, a flush denied by the real adapter, or two faults on one file. The dedicated tests cover the five mutations it passes.

Everything that runs after the first file record, and why none of it can remove a record:

  • The spill attempt: its creation and its write catch every failure.
  • The report: in-memory work on one or two records, using values computed before any file existed (path, size, SHA-256). The files are named first.
  • The engine: after delivery it sets the failure and guidance, with no I/O. Its catch, a defect backstop, adds result-report-failed and removes nothing.
  • Releasing the reservation: does nothing once the file has been written and closed.
  • Writing the envelope to standard output: if that fails, there is no envelope. That is outside the invariants' scope, now documented.

What is still not covered, and why:

  • The engine's backstop. No fault can reach it without a seam inside the in-memory report; it is reasoning only.
  • A process killed mid-delivery. It leaves a partial file and no envelope, which the reviewer forced. The operations page now says the invariants hold for calls that end with an envelope, and that a file no envelope names must not be trusted.
  • A denied flush on the CLI's own read/write handles. It cannot be produced on a real disk. The real adapter is tested on a read-only handle, and the matrix maps a thrown flush to matched_unconfirmed.
  • A close error and a path mismatch at hand-over. These can only be injected, as before.
  • Two faults on one file at once. Not in the matrix. Finding 5's test is one such case: a prefix, a failed second length query, and a refused removal.

Documentation: the operations page now says:

  • what the checked flush does, and why RandomAccess.FlushToDisk is not used;
  • that the SHA-256 is computed before any file exists, and what a null sha256 means;
  • to check a not_read_back or matched_unconfirmed file against its size and SHA-256 before using it;
  • the primary-file rule, under its own heading;
  • the new error and warning;
  • that the invariants hold for calls that end with an envelope;
  • how the matrix predicts each cell.

Verification at a1fded8f, under the lock, in the 2026 target:

  • Locked offline restore, from a new empty source with NuGetAudit=false: pass.
  • Release build: pass, 0 warnings.
  • Tests with CI's filter: Cli 357, Server 1,564, Worker 415, LicensedProbes 445, Protocol 56.
  • Unfiltered whole-solution run: 3 of 3 passed, Server 1,571 each time.
  • From the root: Verify-TargetIsolation passed. Test-CrossTargetPropagation reported only the expected Briosa.slnx finding.
  • Only src/Briosa.Cli, tests/Briosa.Cli.Tests and the operations page changed, so I did not rerun the package scripts, the other root checks, or the 2024 target.
  • main is still 5ca27a84, so nothing was merged.

Review round 8

These commits answer the seventh re-check of a1fded8f: 85ed8056 (the fixes and their tests) and 444438d5 (the operations page). The diff is 190 lines added and 35 removed. The surface is unchanged, apart from wording and one new case: an unused --output reservation whose size could not be read now has a null bytes.

Item Change Mutation and result
1 result-hash-unavailable now says only that the SHA-256 is missing. It is given whenever the SHA-256 could not be computed, including when the result is lost; the documentation's promise was right and the code was wrong. The warnings for a not_read_back or matched_unconfirmed file say to check it against its size and SHA-256 when there is one; without one, they say its size alone cannot verify it. New tests: a spill whose length query fails with no SHA-256 (0 bytes read; no warning claims a comparison or a SHA-256), and a lost result with no SHA-256. Old hash wording: the first test fails. Old guidance without a SHA-256: the first test fails. Hash warning left out when lost: the second test fails.
2 The matrix records the order of the handle operations. Every file the model predicts to be matched must have a successful flush after its last write and its last read, and before its close. Only flush on the empty file before the write: 84 cells fail (M-order).
3 The leftover-reservation cells check the entry's bytes against the file's size on disk, a null SHA-256, and an empty other_files. 1 byte reported for the empty reservation: the 1 cell where it is named fails (I4), as does the unknown-size test below.

Other warning and guidance strings checked for item 1. I checked every string the delivery code can give against the records in every case where it can be emitted.

Changed:

  • result-file-unverified said the result "was written to" the file, which is not established when a write also failed. It now says "was sent to".
  • The incomplete-write warnings (output-write-failed, spill-write-failed) said the result "could not be written in full". That is inexact for a file of the right length with different bytes. They now say the file did not read back intact: it is shorter than the result or differs from it.
  • incomplete-file-left pointed only to data.result_file. The file can be in other_files, and the warning now says so.
  • output-reservation-left called the reservation empty even when its size could not be read. It now says so only when the size was measured. A new test checks the unknown-size case, where the entry's bytes is null. Calling it empty regardless fails that test.

Accurate as they were:

  • result-spilled, given only for a matched spill;
  • result-file-unconfirmed's statement that the file read back intact;
  • spill-refused;
  • both spill-write-failed texts for a failed creation and a failed hand-over;
  • result-lost;
  • the engine's guidance "The operation completed…", given only when completion was established and delivery failed.

Documentation: the SHA-256 is computed before any result bytes are written, and the --output reservation already exists by then. A null sha256 is reported in any delivery state. Reading back does not use the SHA-256. An uncertain file without one cannot be verified by its size. An incomplete entry's size may be null.

Verification at 444438d5, under the lock, in the 2026 target:

  • Locked offline restore, from a new empty source with NuGetAudit=false: pass.
  • Release build: pass, 0 warnings.
  • Tests with CI's filter: Cli 360, Server 1,564, Worker 415, LicensedProbes 445, Protocol 56.
  • Unfiltered whole-solution run: 3 of 3 passed, Server 1,571 each time.
  • From the root: Verify-TargetIsolation passed. Test-CrossTargetPropagation reported only the expected Briosa.slnx finding.
  • main is still 5ca27a84, so nothing was merged.

Refs #445

Merge readiness (444438d5)

  • GPT 6.2 Astra approved 444438d5 on its eighth pass, with no blocking finding. The earlier rounds are described above.
  • The branch contains main at 5ca27a84.
  • All 35 CI checks passed on 444438d5, including both build-and-test jobs, both package smoke jobs and every retained-client job.
  • This is the first of four slices for Implement attach-only Briosa.Cli.exe (JSON CLI and local stdio MCP) for SA 2026.1.0529.7 #445, so it refers to the issue and does not close it. The MCP server, packaging and signing, and the licensed smoke check follow.
  • Two documentation corrections noted by the final check are carried into the next slice, which edits the same page: the result-format-failed row should say "before result bytes are written" rather than "before any file exists", and the warning list's "failed write" shorthand should also cover a write whose bytes differ on read-back.

🤖 Generated with Claude Code

davidalucas and others added 2 commits November 27, 2026 20:24
….0529.7

Briosa.Cli is a generic protocol adapter over the compiled Briosa.Protocol
descriptors. A shared engine attaches to an existing loopback server, verifies
its exact target, compatibility major and revision, and returns one stable
result envelope; the JSON command line only parses arguments and maps the
outcome to a process exit code, so the stdio MCP server can sit on the same
engine.

- status, ops categories, ops search, ops describe, and read-only call.
- Attach only: no lifecycle RPC, one verified TCP connection per session,
  IP loopback endpoints only, no retries and no hidden MP calls.
- call sends exactly one briosa-caller-restriction entry
  (profile=read-only; deny=interactive_ui) and refuses servers before 0.10.2.
- Strict JSON input checked against the request descriptor before the
  protobuf parser runs; value-free local rejections.
- Outcomes keep transport status, failure kind, diagnostic code, disposition,
  recovery and replay guidance, and MP result separate; deterministic exit
  codes; inline cap with spill to a protected per-user file.
- Four bridge tiers, pinned over all 1,018 registered operations.

Refs #445

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An OperationError without a recognized execution disposition is still
reported as completion evidence unavailable, but its own diagnostic code
stays in failure.diagnostic_code and the reason moves to a dedicated
warning, so the CLI never overwrites what the server sent.

Refs #445

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
davidalucas and others added 17 commits November 27, 2026 21:59
Review round 1 of the Briosa CLI (findings 1, 2, 4 to 11):

- A typed error trailer counts only when it names the requested operation and
  matches a (status, kind, disposition, MP details) shape the server's
  outcome mapper produces; an OK response must carry no error trailer and name
  only fields of its result. Anything else is completion evidence unavailable
  with a null disposition and reconciliation guidance.
- One submission per call below the gRPC client: each logical request permits
  one HTTP/2 stream, and a HEADERS frame that would open another is never
  written, so a refused-stream resend cannot reach the server.
- A completed internal failure after MP success is outputs_incomplete, not
  mp_failed; the classification is checked against every mapper shape.
- A failed delivery never claims a completion the evidence did not establish.
- Spill directories are opened without following reparse points at every
  managed level, held while the file is created, and the file must resolve
  to the verified path; reservations are removed through their handle.
- Standard error names only locally recognized diagnostic codes.
- Inconsistent or oversized discovery is refused for what it is.
- --output is reserved before any RPC; a refused call carries the not-sent
  execution block; port 80 survives normalization; a BOM counts in offsets.

Refs #445

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review round 1 of the Briosa CLI (finding 3 and documentation):

- The tests no longer take expected values from the code under test. The
  restriction header name and value, the error trailer name, the exact
  target, the input limits, the requiredness statement, the excluded flags,
  and the public diagnostic codes are literals in the tests; result files are
  checked by decoding them against the result itself; the fake server reads
  the header by its literal wire name. Changing the production restriction to
  deny=invalid_flag now fails 72 tests.
- An OK result whose execution details are missing or inconsistent carries
  the same conflict warning as every other rule failure.
- The operations page lists the evidence-consistency rules, single
  submission, when --output is reserved, the spill directory checks, the
  stderr vocabulary, and the updated exit code meanings.

Refs #445

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An unfiltered dotnet test of the whole 2026 solution failed in 2 of 3 runs on
this branch, always in the server's
WorkerProcessSupervisorTests.NormalLifecycleReportsStatesAndReleasesStaOnOwningThread,
whose worker must stop within a 500 ms graceful bound, while main passed 3 of
3. The new CLI test assembly started its in-process servers and message
sweep in parallel beside the server tests. Running its classes serially
keeps its load near one core; the same unfiltered run then passed 3 of 3.

Refs #445

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review round 2 of #465, items A to G.

A. Output rows: the server writes one row per output contract, named by
the contract's field name, which may be a dotted path or the bare name of
a nested field. A row must name something in the result, and every
top-level result field must be named by a row. An OK result must have
every row retrieved. Genuine replies of all 1,018 operations pass.

B. Typed errors must match the mapper's table in status, disposition,
recovery and replay guidance (replay follows discovery's replay safety),
fixed diagnostic codes, details and MP details. Unknown enum values are
conflicts; an unknown diagnostic code alone stays data. An exhaustive
enumeration of the mapper and a single-change oracle derive the table.

C. An operation ID must name its method: without underscores it equals
Service.Rpc, ignoring ASCII case. Holds for all 1,018 operations.

D. The spill directory's DACL is set through its verified handle, the
file gets its own protected DACL, and a volume without persistent ACLs
is refused before anything is created; the result is reported lost.

E. An output failure of an operation with no outputs has no rows.

F. RESOURCE_EXHAUSTED on discovery is "too large" only when a received
gRPC length prefix exceeded the receive limit.

G. The blocked-resend warning no longer says why the first attempt ended.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The CLI page now gives the operation ID rule, the full typed-error table
with replay and recovery guidance and fixed codes, the output-row rules
and what they cannot detect, the MP code 4 limit, the blocked-resend
wording, the evidence behind discovery-response-too-large, and how spill
permissions are set and when a spill is refused.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review round 3 of #465, items A to D.

A. Every top-level result field needs a row of its own: rows are matched
to fields, so one bare-named row never answers for two fields. 26
operations nest one field name under several top-level fields; each gets
a single-row case that must fail.

B. A policy denial carries exactly the fields its rule names, and a caller
rule names the restriction this CLI sent: profile read-only, or the
denied flag interactive_ui. The oracle enumerates each rule with its
payload from the server's denial factory, and a test checks the real
policy's caller denials against it.

C. Spill directories and the file are opened or created relative to the
held parent handle (NtCreateFile with RootDirectory), never by path, and
results gets its owner and DACL only after it is reached that way. A
redirected base between levels changes nothing outside the tree it first
led to.

D. For an operation call serves, an MP failure with code 4 is conflicting
evidence: none of the server's code-4 exceptions is in the read-only tier,
which a pinned test keeps true.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The CLI page now describes the row-to-field matching and its limits, the
payload each denial rule carries and the caller values it is checked
against, the read-only code 4 rule and what a mutating tier must revisit,
the handle-relative spill design with what it guarantees and what it does
not, that a fixed-code row conflicts on its code alone, and that a failed
--output keeps output-write-failed when its spill is also refused.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ean up on failure

Review round 4 of #465.

1. The results directory's owner and protected DACL are written with
   SetKernelObjectSecurity on its held handle, which does not propagate:
   files and folders already in results, including earlier spill files,
   keep their owner and access list byte for byte.

2. Directories are opened with read-attributes and traverse access only.
   Creating a missing directory is decided by the file system from the
   parent's own permissions, so an existing ancestor that denies new
   subdirectories no longer blocks a spill.

3. Nothing created is left behind and no handle leaks on failure: a newly
   created file (spill or --output) is removed through its own handle if
   it cannot be handed over; a directory handle is closed when its check
   throws; a spill file whose write fails is removed; a ResultFile closes
   its handle even when its stream fails to close, and Discard after close
   does nothing.

4. The mapper oracle's known-gap text says what is now true.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The spill section now says that the results directory's permissions are
written to it alone, so existing files, folders and earlier spill files
keep theirs; that only read-attributes and traverse access is requested,
with creation decided by the parent's own permissions; and that a spill
file is removed through its handle if anything fails before it is written
in full, while created directories are kept.

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

Review round 5 of #465, and the CI
failure of ASpillChangesNothingAlreadyInTheResultsDirectory at 8982058.

1. A result file is written, read back through its own handle and compared
   with the result, then flushed and closed. Only content known to be
   incomplete (shorter or different) is removed. A file that read back
   intact but whose write, flush or close reported an error is kept as
   file_unconfirmed; one that could not be read back is kept as
   file_unverified. Result files are opened with read access for this.

2. The partial-write test writes three bytes before failing, so a removal
   that spares non-empty files fails it.

3. An incomplete spill file that cannot be removed is named in
   data.result_file with the reason incomplete_not_removed, and the warning
   incomplete-file-left says so.

4. The existing-entries test gives its own tree a protected access list
   with a BUILTIN\Users entry and a CREATOR OWNER entry, so a propagating
   writer is visible under any account and nothing depends on the temporary
   folder. On failure it reports the SDDL of every object at every stage.

5. The stale code-4 comment is corrected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The CLI page now defines each data.result_delivery state and what it
asserts, says that a file that may hold the result is never removed and
that removal of an incomplete one can fail and is then reported, says when
exit code 12 applies, and lists SYNCHRONIZE among the access requested on
spill directories.

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

Review round 6 of #465.

Result delivery now keeps one record per file the call wrote or created:
what reading it back showed, whether a later step reported an error, and
whether it is still on disk. The delivery state, data.result_file, its new
verification and other_files members, the delivery error, the warnings,
and the result-lost warning are all derived from those records.

1. An --output file that could not be read back is kept and named as
   not_read_back with the result's size and SHA-256, also when the spill
   that should back it is refused. The new error output-verify-failed
   distinguishes it from a known mismatch, and no warning claims that the
   result is in no file while a file may hold it.

2. A file is flushed to the storage device with RandomAccess.FlushToDisk
   (FlushFileBuffers) after the read-back; a failure makes it
   matched_unconfirmed. The parameterless FileStream.Flush on an unbuffered
   stream did not reach the operating system. Result files are now written
   and read through their handle with RandomAccess, behind a small internal
   IResultFileIo seam that tests use to inject faults.

3. Tests cover a file of the right length with different bytes.

4. A new spill file that can be neither handed over nor removed raises
   ResultFileLeftException with the path it was created at, and the
   envelope names it as incomplete. An unused --output reservation that
   cannot be removed is named too, with the warning output-reservation-left.

An --output file that read back shorter or different is now removed
through its handle, as a spill file is.

DeliveryFaultMatrixTests drives 664 cells through the real CLI: each fault
point crossed with the destination, the spill's own fault when --output
fails, removal that works or is refused, and whether completion was
established. It checks six invariants against the files on disk and a log
of the real handle operations.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The CLI page now lists the four steps of writing a result file and what
the flush to disk does and does not establish, the verification labels of
each file, how data.result_file and other_files are chosen, each delivery
state and delivery error, the warnings, the six delivery invariants, and
the fault matrix that checks them, including the two fault points that can
only be injected.

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

Review round 7 of #465.

1. Everything that can fail without touching a file now runs before any
   file exists: formatting, summarizing, and the SHA-256. A formatting
   failure is caught there, and only there. A SHA-256 that cannot be
   computed leaves that field null, with the warning
   result-hash-unavailable, and never loses a file. The report is built in
   memory from the file records, files first, and the engine's catch no
   longer overwrites what delivery recorded; it only marks a defect as
   result-report-failed.

2. The flush calls FlushFileBuffers itself and checks its result. .NET's
   RandomAccess.FlushToDisk treats ERROR_ACCESS_DENIED as success, so a
   denied flush could be reported as matched. A test calls the real adapter
   on a read-only handle.

3. The fault matrix now predicts each cell from its injected faults alone:
   which files must be written, including the fallback spill, what must be
   on disk and how large, which file is named first by the primary-file
   rule, the delivery state, the error, the exit code, and the key
   warnings. The envelope, the disk, and the handle log are compared with
   that prediction.

4. output-reservation-left gives the reservation's resolved path, and a
   spill file that failed its hand-over checks is no longer reported as
   one that could not be created.

5. An incomplete file keeps the size its read-back measured.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The CLI page now says that the flush calls FlushFileBuffers and checks its
result, why RandomAccess.FlushToDisk is not used, that the SHA-256 is
computed before any file exists and what a null sha256 means, that a file
labeled not_read_back or matched_unconfirmed must be checked against its
size and SHA-256 before use, the rule for which file is named first, the
new result-report-failed error and result-hash-unavailable warning, that
output-reservation-left gives the path, that the invariants hold only for
a call that ends with an envelope, and how the fault matrix predicts each
cell from its faults.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review round 8 of #465.

1. result-hash-unavailable now says only that the SHA-256 is missing, and
   is given whenever it could not be computed, also when the result is
   lost. The warnings for a not_read_back or matched_unconfirmed file tell
   the caller to check it against its size and SHA-256 when there is one,
   and otherwise that its size alone cannot verify it. The unverified
   warning no longer says the file was written, the failed-write warnings
   say what the read-back showed, incomplete-file-left points to
   other_files too, and output-reservation-left calls the reservation
   empty only when its size was read; its entry gives no size otherwise.

2. The fault matrix records the order of the handle operations, and every
   file it predicts to be matched must have a successful flush after its
   last write and read and before its close.

3. The leftover-reservation cells check the entry's size against the
   file on disk, a null SHA-256 and empty other_files.

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

The CLI page now says that the SHA-256 is computed before any result bytes
are written, with the --output reservation already in place, that a null
sha256 is reported in any delivery state, that reading back does not use
it, that without it a not_read_back or matched_unconfirmed file cannot be
verified by its size alone, and that an incomplete entry's size may be
null when it could not be read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant