Skip to content

Report a storage fault on the dependency scratch as scratch_io_failed - #533

Closed
luisleo526 wants to merge 7 commits into
mainfrom
fix/dependency-scratch-io-failure
Closed

luisleo526 wants to merge 7 commits into
mainfrom
fix/dependency-scratch-io-failure

Conversation

@luisleo526

Copy link
Copy Markdown
Collaborator

What

A read, write or resize fault on the scratch that holds waiting requests (the dependency queue of a native run) now ends the run as scratch_io_failed, a non-retryable resource failure, instead of engine_invariant. This is the code the exit-scratch consumer already reports for the same storage status.

A failure the storage layer had already recorded (for example a typed arena failure) still keeps its own code, because it is rethrown first. Non-I/O statuses (programming error, corrupt, not found, cancelled) still raise the same plain logic error as before. The run-failure catalog is unchanged: no code is added, changed or removed.

The change is in require_dependency_scratch in src/native_execution_consumer.cpp (two lines replace five, so the line count of the file is unchanged and the documentation line anchors stay valid). No installed header, virtual function or layout changes.

Tests

tests/test_dependency_scratch_failure.cpp drives the real native consumer (a reversal with 64 waiting descendants, so the dependency pages exceed the two-page cache) over a fault-injecting backing double. One control run completes with real backing reads and writes; four rows each inject one bare I/O error (write, read, growth, byte-cap refusal) and expect scratch_io_failed with no arguments; one row checks that a carried typed failure keeps its code, arguments and errno; one row pins the exit-scratch consumer's existing mapping.

The faults are injected through a backing double. The tests do not claim that a real EFBIG on a disk file reaches this helper; they show that any bare I/O error reaching the consumer is now classified correctly.

On the tests-only commit the four fault rows fail with code=engine_invariant; the control, carried-failure and exit-scratch rows pass. With the fix all pass.

Compatibility

A host that matched engine_invariant for this fault now sees scratch_io_failed (class resource, not retryable). The 1.8.0 changelog says so.

🤖 Generated with Claude Code

luisleo526 and others added 7 commits October 26, 2026 20:12
A bare I/O error from the dependency scratch backing (no carried
exception) reaches require_dependency_scratch as a plain logic error and is
reported as an internal inconsistency, while the exit-scratch consumer
reports the same status as scratch_io_failed. These rows drive a real native
run (a reversal with 64 waiting descendants, so the dependency pages exceed
the two-page cache) over a status-only fault backing:

- unarmed_control: the identical run without a fault completes, with real
  backing reads and writes and an empty store after the drain.
- write_fault, read_fault, growth_fault, byte_cap_refusal: one bare io_error
  after setup must end the run failed with scratch_io_failed and no
  arguments. They fail on the current tree with the observed class, which
  the check prints.
- carried_failure: a carried typed exception keeps its code, arguments and
  errno.
- exit_scratch_sibling: the same status through the exit-scratch consumer
  stays scratch_io_failed.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Preserve carried scratch exceptions and raise scratch_io_failed with no
arguments when a dependency scratch operation returns a bare I/O error, as
the exit-scratch consumer already does for the same status. Successful
operations and contract-error behaviour are unchanged.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@luisleo526
luisleo526 marked this pull request as ready for review October 26, 2026 19:09
luisleo526 added a commit that referenced this pull request Oct 26, 2026
…iagnostics, dependency-scratch storage fault code (#536)

## What

One change set that carries four reviewed pull requests together, so the release gate and the parity sweep run once on the exact tree that ships. Each of the four was reviewed and green on its own; this branch is the first, #536, plus merges of the other three. No line was rewritten.

- #533 Report a storage fault on the dependency scratch as scratch_io_failed
- #534 run_json: report the recorded failure when the internal report sink is refused
- #535 entrypoint: forward an opt-in report descriptor to run_json
- #536 run_json: report the run profile and jailed arena admission in the diagnostics

### Dependency scratch fault (from #533)

A read, write or resize fault on the scratch that holds waiting requests now ends the run as `scratch_io_failed`, a non-retryable `resource` failure, instead of `engine_invariant`, as the exit-scratch consumer already did for the same storage status. A failure the storage layer had already recorded keeps its own code. The run-failure catalog is unchanged. The change is in `require_dependency_scratch` (`src/native_execution_consumer.cpp`) and adds no net lines, so the file keeps its line count and the documentation line anchors stay valid.

### Typed failure for a refused internal report sink (from #534)

On the default route `run_json.py` installs an internal report sink. When the engine refused it, for example because the scratch arena descriptor, size or profile flag in the environment was unusable, the host reported `engine_invariant` and dropped the failure the engine had recorded. It now reads that record before the strategy state is freed and reports it (`report_sink_failed` with reason `arena_backing` for an unusable arena). If the engine recorded nothing, the previous message and code are kept. No success path changes.

### Opt-in report descriptor in the container entrypoint (from #535)

`PINEFORGE_REPORT_SINK_FD=<n>` makes the entrypoint pass `--report-sink-fd <n>` to `run_json.py`, for a caller that opened the descriptor for the report records itself. The value is forwarded unchanged, an empty value as an empty argument, and `run_json.py` stays the only validator (a number below 3, 5, a phase descriptor and a non-number are refused with its usual text and exit 2, mapped to 4 by the entrypoint). With the variable unset nothing changes.

### Run profile in the report diagnostics (from #536)

Every executed success report carries two additive `diagnostics` keys: `run_profile` (`"jailed"` or `"unjailed"`, fixed when the run starts) and `scratch_arena_jailed` (true only when the jailed profile ran and the native scratch arena admission succeeded). The flag comes from the actual admission result, never from the environment. It records the checked profile and the admission; it is not an independent check of operating-system confinement. Failure, capability and validate-only documents, and every existing key and its order, are unchanged. The replay converter keeps both keys. Python only: no native export, no C++ change.

## Tests

Each change keeps the tests it was reviewed with, committed before the fix so each fails on the unchanged tree for the stated reason: the dependency-scratch fault rows (`engine_invariant` observed), the unjailed sink refusal rows (twelve real-module rows and a free-order double), the entrypoint forwarding rows (the logged argument vector lacks the option), and the profile rows (both keys absent). The faults in the first group are injected through a backing double; no claim is made that a real disk `EFBIG` reaches that helper.

## Compatibility

- A host that matched `engine_invariant` for a dependency-scratch storage fault now sees `scratch_io_failed` (class `resource`, not retryable).
- A host that matched `engine_invariant` for a refused internal report sink on the default route now sees `report_sink_failed` / `arena_backing` for the cases above.
- Two additive keys in the success report `diagnostics` object; one opt-in environment variable. The 1.8.0 changelog describes all four.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
@luisleo526

Copy link
Copy Markdown
Collaborator Author

Superseded by #536, which carries this change together with the other report-sink changes in one merge (squash 4c113fc).

@luisleo526 luisleo526 closed this Oct 26, 2026
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