Repository navigation
Exit PRECONDITION when the investigation record cannot be written - #61
Merged
Merged
Conversation
InvestigationStore.save let an OSError from the write escape unwrapped, so a run whose investigations folder could not be written crashed with a traceback. In a stream whose reader closed stdout the crash came from the generator's close, which treaty reports with a traceback and exit 0, so the stopped run broke D-3. The store now wraps the error as agent_investigations_unwritable, naming the folder, which agent investigate already maps to PRECONDITION. The stopped path keeps the error for cloudfall.cli, which writes it to stderr as a JSON line and exits PRECONDITION (D-5): the record is lost, the exit stays non-zero. Fixes #56 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
agent investigatenow exits 4PRECONDITION(codeagent_investigations_unwritable), naming the investigations folder, when it cannot write its record, as D-5 (#59) settles.InvestigationStore.savewraps anOSErrorfrom creating the folder or writing the record (not the id-collisionFileExistsError, which still moves to the next suffix) inInvestigationError. The existing_save_investigationmaps that toPRECONDITION, so the normal end and the model-unavailable save are covered with no new mappingGeneratorExit) can't raise: treaty closes the handler itself, prints whatever close raises as a traceback, and exits 0 anyway (_close_events, thenoutput_closed). So the handler keeps the error incloudfall.app.stream_unrecorded, likestream_stopped, and does not setstream_stopped.cloudfall.clithen writes one JSON line to stderr ({"code": "PRECONDITION", "message": ..., "context": {"code": "agent_investigations_unwritable"}}, the same shape as the stream's warning lines) and exits 4 instead of 0/141. The record is lost; the exit stays non-zero (D-3, D-5)Exit codes other than this case are unchanged.
Test plan
test_an_unwritable_investigations_folder_is_refused_naming_it(store level, a file where the folder goes)test_a_record_that_cannot_be_written_exits_precondition(CLI, stream runs to the end: exit 4,PRECONDITION, folder named, no traceback on stderr)test_a_stopped_run_whose_record_cannot_be_written_exits_precondition(real subprocess, reader closes stdout after the first turn and call: exit 4, no traceback, the stderr JSON line names the folder). Fails on main with exit 0 and the treaty traceback_closed_mid_runuv run ruff check .,uv run mypy,uv run pytest(full suite, 469 passed),uv run cloudfall config validate --project config/examples: all passFixes #56
🤖 Generated with Claude Code