From 5172d688c8559b91385e78f9fdd4aab2285e7bc1 Mon Sep 17 00:00:00 2001 From: Troublor <14846504+Troublor@users.noreply.github.com> Date: Tue, 24 Nov 2026 09:34:59 +0800 Subject: [PATCH 1/3] fix(pr-review): salvage completed retry output --- .github/actions/claude-pr-review/action.yml | 44 ++++- .../claude-pr-review/review_pipeline.py | 60 ++++++ .../claude-pr-review/test_review_pipeline.py | 184 ++++++++++++++++++ 3 files changed, 285 insertions(+), 3 deletions(-) diff --git a/.github/actions/claude-pr-review/action.yml b/.github/actions/claude-pr-review/action.yml index 83968bd..b4996d9 100644 --- a/.github/actions/claude-pr-review/action.yml +++ b/.github/actions/claude-pr-review/action.yml @@ -348,6 +348,23 @@ runs: ${{ inputs.extra_prompt }} + - name: Capture first analysis transcript before retry + id: capture_first + if: always() && steps.prepare.outputs.mode != 'skip' + continue-on-error: true + shell: bash + env: + EXECUTION_FILE: ${{ steps.review.outputs.execution_file }} + STATE_DIR: ${{ github.workspace }}/.pr-review + run: | + set -euo pipefail + # Both invocations reuse the vendor's execution-file path. + if [[ -n "$EXECUTION_FILE" && -f "$EXECUTION_FILE" ]]; then + mkdir -p "$STATE_DIR" + cp "$EXECUTION_FILE" "$STATE_DIR/analysis-transcript.json" + echo "captured first analysis transcript before retry" + fi + - name: Classify first analysis attempt id: classify if: steps.prepare.outputs.mode != 'skip' @@ -363,6 +380,7 @@ runs: - name: Retry missing structured review output id: review_retry + continue-on-error: true if: >- steps.prepare.outputs.mode != 'skip' && steps.classify.outputs.retryable != 'false' && @@ -430,14 +448,19 @@ runs: mkdir -p "$STATE_DIR" copy_transcript() { local source="$1" name="$2" session="$3" - if [[ -n "$source" && -f "$source" ]]; then + if [[ -f "$STATE_DIR/$name" ]]; then + echo "preserved $name captured before retry" + elif [[ -n "$source" && -f "$source" ]]; then cp "$source" "$STATE_DIR/$name" echo "captured $name from $source (session ${session:-unknown})" else echo "no transcript available for $name" fi } - copy_transcript "$EXECUTION_FILE" "analysis-transcript.json" "$SESSION_ID" + # After a retry the shared source is no longer the first attempt. + if [[ -z "$RETRY_EXECUTION_FILE" ]]; then + copy_transcript "$EXECUTION_FILE" "analysis-transcript.json" "$SESSION_ID" + fi copy_transcript "$RETRY_EXECUTION_FILE" "analysis-retry-transcript.json" "$RETRY_SESSION_ID" # Keep the raw structured output beside the transcript. `compile` also # writes a parsed copy, but it never runs when compilation is what @@ -449,11 +472,24 @@ runs: printf '%s' "$RETRY_STRUCTURED_OUTPUT" > "$STATE_DIR/structured-output-retry.json" fi + - name: Salvage completed retry output + id: salvage + if: always() && steps.prepare.outputs.mode != 'skip' + shell: bash + env: + REVIEW_STRUCTURED_OUTPUT: ${{ steps.review.outputs.structured_output || steps.review_retry.outputs.structured_output }} + STATE_DIR: ${{ github.workspace }}/.pr-review + run: | + set -euo pipefail + python3 "$GITHUB_ACTION_PATH/review_pipeline.py" salvage \ + --state-dir "$STATE_DIR" + - name: Compile and validate review id: compile + if: always() && steps.prepare.outcome == 'success' && steps.compose.outcome == 'success' shell: bash env: - REVIEW_STRUCTURED_OUTPUT: ${{ steps.review.outputs.structured_output || steps.review_retry.outputs.structured_output }} + REVIEW_STRUCTURED_OUTPUT: ${{ steps.review.outputs.structured_output || steps.review_retry.outputs.structured_output || steps.salvage.outputs.structured_output }} STATE_DIR: ${{ github.workspace }}/.pr-review run: | set -euo pipefail @@ -462,6 +498,7 @@ runs: - name: Publish atomically and persist state id: publish + if: ${{ !cancelled() && steps.compile.outcome == 'success' }} shell: bash env: GH_TOKEN: ${{ inputs.github_identity_token || github.token }} @@ -485,6 +522,7 @@ runs: COMPOSE_OUTCOME: ${{ steps.compose.outcome }} REVIEW_OUTCOME: ${{ steps.review.outcome }} REVIEW_RETRY_OUTCOME: ${{ steps.review_retry.outcome }} + REVIEW_SALVAGED: ${{ steps.salvage.outputs.salvaged }} COMPILE_OUTCOME: ${{ steps.compile.outcome }} PUBLISH_OUTCOME: ${{ steps.publish.outcome }} PUBLISH_PUBLISHED: ${{ steps.publish.outputs.published }} diff --git a/.github/actions/claude-pr-review/review_pipeline.py b/.github/actions/claude-pr-review/review_pipeline.py index 7b887f1..bd135b5 100644 --- a/.github/actions/claude-pr-review/review_pipeline.py +++ b/.github/actions/claude-pr-review/review_pipeline.py @@ -1363,6 +1363,55 @@ def classify_command(args: argparse.Namespace) -> None: write_github_output({"retryable": "true", "code": ""}) +def salvage_command(args: argparse.Namespace) -> None: + """Recover only a completed SDK result, never intermediate tool output.""" + state_dir = Path(args.state_dir) + if os.environ.get("REVIEW_STRUCTURED_OUTPUT", ""): + log("salvaged=0 reason=action_output_available") + write_github_output({"salvaged": "0"}) + return + path = state_dir / "analysis-retry-transcript.json" + try: + text = path.read_text(encoding="utf-8") + except (OSError, UnicodeError) as error: + log(f"salvaged=0 reason=transcript_unavailable error={error}") + write_github_output({"salvaged": "0"}) + return + try: + try: + value = json.loads(text) + records = value if isinstance(value, list) else [value] + except json.JSONDecodeError: + records = [json.loads(line) for line in text.splitlines() if line.strip()] + except json.JSONDecodeError: + log("salvaged=0 reason=malformed_transcript") + write_github_output({"salvaged": "0"}) + return + # Only inspect top-level SDK records: nested tool results and stream events + # can contain arbitrary repository text resembling a completed result. + for record in reversed(records): + if not isinstance(record, dict) or record.get("type") != "result": + continue + output = record.get("structured_output") + if ( + record.get("terminal_reason") != "completed" + or record.get("subtype") != "success" + or record.get("is_error") is not False + or not isinstance(output, dict) + or not output + ): + break + raw = compact_json(output) + (state_dir / "structured-output-retry.json").write_text( + raw + "\n", encoding="utf-8" + ) + write_github_output({"salvaged": "1", "structured_output": raw}) + log("salvaged=1 reason=completed_retry_result") + return + log("salvaged=0 reason=no_completed_structured_result") + write_github_output({"salvaged": "0"}) + + def write_github_output(values: dict[str, Any]) -> None: output_path = os.environ.get("GITHUB_OUTPUT") if not output_path: @@ -3417,6 +3466,8 @@ def inferred_action_failure( ), ) for phase, code, message in candidates: + if phase == "review_retry" and outcomes.get("compile") == "success": + continue if outcomes.get(phase) == "failure": return diagnostic_for( phase, @@ -3426,6 +3477,7 @@ def inferred_action_failure( if ( outcomes.get("review") == "failure" and outcomes.get("review_retry") != "success" + and outcomes.get("compile") != "success" ): return diagnostic_for( "review", @@ -3606,6 +3658,10 @@ def report(args: argparse.Namespace) -> None: f"`{'enabled' if review_input.get('thread_resolution_enabled') else 'disabled'}`", f"- **Model retry used:** `{'yes' if retry_used else 'no'}`", ] + if os.environ.get("REVIEW_SALVAGED", "") == "1": + rows.append( + "- **Note:** Retry output was salvaged after a wrapper turn-count rejection." + ) rows.extend(analysis_settings()) if payload: rows.append( @@ -3840,6 +3896,10 @@ def parser() -> argparse.ArgumentParser: classify_parser.add_argument("--execution-file", default="") classify_parser.set_defaults(func=classify_command) + salvage_parser = subparsers.add_parser("salvage") + salvage_parser.add_argument("--state-dir", required=True) + salvage_parser.set_defaults(func=salvage_command) + compile_parser = subparsers.add_parser("compile") compile_parser.add_argument("--state-dir", required=True) compile_parser.set_defaults(func=compile_command) diff --git a/.github/actions/claude-pr-review/test_review_pipeline.py b/.github/actions/claude-pr-review/test_review_pipeline.py index ce07460..d822783 100644 --- a/.github/actions/claude-pr-review/test_review_pipeline.py +++ b/.github/actions/claude-pr-review/test_review_pipeline.py @@ -2,7 +2,9 @@ import copy import json +import subprocess import tempfile +import textwrap import unittest from pathlib import Path from types import SimpleNamespace @@ -100,6 +102,188 @@ def sample_finding(**overrides): class ReviewPipelineTests(unittest.TestCase): + def test_salvage_completed_retry_compiles_and_reports_success(self): + completed = { + "type": "result", + "subtype": "success", + "terminal_reason": "completed", + "is_error": False, + "num_turns": 67, + "structured_output": clean_output(), + } + # The SDK execution file can be JSONL or a JSON array of records. + for transcript in ( + json.dumps({"type": "assistant"}) + "\n" + json.dumps(completed), + json.dumps([{"type": "assistant"}, completed]), + ): + with self.subTest(transcript=transcript), tempfile.TemporaryDirectory() as directory: + state_dir = Path(directory) + state_dir.joinpath("analysis-retry-transcript.json").write_text( + transcript, encoding="utf-8" + ) + state_dir.joinpath("review-input.json").write_text( + json.dumps(review_input()), encoding="utf-8" + ) + args = pipeline.parser().parse_args(["salvage", "--state-dir", directory]) + with mock.patch.dict("os.environ", {}, clear=True), mock.patch( + "review_pipeline.write_github_output" + ) as output, mock.patch("review_pipeline.log") as log: + args.func(args) + recovered = output.call_args.args[0] + self.assertEqual(recovered["salvaged"], "1") + self.assertEqual(json.loads(recovered["structured_output"]), clean_output()) + self.assertEqual( + json.loads(state_dir.joinpath("structured-output-retry.json").read_text()), + clean_output(), + ) + log.assert_called_once_with("salvaged=1 reason=completed_retry_result") + environment = { + "REVIEW_STRUCTURED_OUTPUT": recovered["structured_output"], + "REVIEW_SALVAGED": recovered["salvaged"], + "GITHUB_STEP_SUMMARY": str(state_dir / "summary.md"), + "PREPARE_OUTCOME": "success", + "COMPOSE_OUTCOME": "success", + "REVIEW_OUTCOME": "failure", + "REVIEW_RETRY_OUTCOME": "failure", + "COMPILE_OUTCOME": "success", + "PUBLISH_OUTCOME": "success", + "PUBLISH_PUBLISHED": "true", + } + with mock.patch.dict("os.environ", environment, clear=True), mock.patch( + "builtins.print" + ): + pipeline.compile_command(args) + pipeline.report(args) + summary = state_dir.joinpath("summary.md").read_text() + self.assertEqual( + json.loads(state_dir.joinpath("review-payload.json").read_text())["verdict"], + "clean", + ) + self.assertIn("Review completed and publication succeeded", summary) + self.assertIn( + "Retry output was salvaged after a wrapper turn-count rejection", summary + ) + self.assertNotIn("MODEL_ACTION_FAILED", summary) + environment["PUBLISH_OUTCOME"] = "failure" + with mock.patch.dict("os.environ", environment, clear=True): + diagnostic = pipeline.inferred_action_failure( + pipeline.step_outcomes(), state_dir=state_dir + ) + self.assertEqual(diagnostic["code"], "PUBLISH_ACTION_FAILED") + + def test_salvage_rejects_incomplete_or_invalid_transcripts(self): + completed = { + "type": "result", + "subtype": "success", + "terminal_reason": "completed", + "is_error": False, + "structured_output": clean_output(), + } + cases = { + "max_turns": json.dumps({ + **completed, "subtype": "error_max_turns", + "terminal_reason": "max_turns", "is_error": True, + }), + "malformed": '{"type":"result",', + "truncated_after_result": json.dumps(completed) + "\n{", + "non_object": json.dumps({**completed, "structured_output": []}), + "string_payload": json.dumps({**completed, "structured_output": "{}"}), + "empty_object": json.dumps({**completed, "structured_output": {}}), + "stream_event": json.dumps({**completed, "type": "stream_event"}), + "nested_tool_result": json.dumps({"type": "user", "content": completed}), + "error_result": json.dumps({**completed, "is_error": True}), + } + for name, transcript in cases.items(): + with self.subTest(name=name), tempfile.TemporaryDirectory() as directory: + state_dir = Path(directory) + state_dir.joinpath("analysis-retry-transcript.json").write_text( + transcript, encoding="utf-8" + ) + with mock.patch.dict("os.environ", {}, clear=True), mock.patch( + "review_pipeline.write_github_output" + ) as output, mock.patch("review_pipeline.log") as log: + pipeline.salvage_command(SimpleNamespace(state_dir=directory)) + output.assert_called_once_with({"salvaged": "0"}) + self.assertIn("salvaged=0 reason=", log.call_args.args[0]) + self.assertFalse(state_dir.joinpath("structured-output-retry.json").exists()) + + def test_salvage_preserves_existing_action_output(self): + with tempfile.TemporaryDirectory() as directory, mock.patch.dict( + "os.environ", {"REVIEW_STRUCTURED_OUTPUT": json.dumps(clean_output())}, + clear=True, + ), mock.patch("review_pipeline.write_github_output") as output, mock.patch( + "review_pipeline.log" + ) as log: + pipeline.salvage_command(SimpleNamespace(state_dir=directory)) + output.assert_called_once_with({"salvaged": "0"}) + log.assert_called_once_with("salvaged=0 reason=action_output_available") + + def test_action_salvage_and_capture_wiring(self): + action = Path(pipeline.__file__).with_name("action.yml").read_text(encoding="utf-8") + steps = { + block.splitlines()[0]: block + for block in action.split(" - name: ")[1:] + } + names = list(steps) + self.assertEqual( + names[names.index("Analyze and verify findings") + 1], + "Capture first analysis transcript before retry", + ) + self.assertLess( + names.index("Capture analysis session transcript"), + names.index("Salvage completed retry output"), + ) + self.assertLess( + names.index("Salvage completed retry output"), + names.index("Compile and validate review"), + ) + salvage = steps["Salvage completed retry output"] + self.assertIn("id: salvage", salvage) + self.assertIn("if: always() && steps.prepare.outputs.mode != 'skip'", salvage) + self.assertIn('review_pipeline.py" salvage', salvage) + compile_step = steps["Compile and validate review"] + self.assertIn("if: always()", compile_step) + self.assertIn( + "REVIEW_STRUCTURED_OUTPUT: ${{ steps.review.outputs.structured_output || " + "steps.review_retry.outputs.structured_output || steps.salvage.outputs.structured_output }}", + compile_step, + ) + self.assertIn("continue-on-error: true", steps["Retry missing structured review output"]) + self.assertIn( + "steps.compile.outcome == 'success'", steps["Publish atomically and persist state"] + ) + self.assertIn( + "REVIEW_SALVAGED: ${{ steps.salvage.outputs.salvaged }}", + steps["Report concise review outcome"], + ) + # Run the actual capture scripts against a reused vendor path. + with tempfile.TemporaryDirectory() as directory: + state_dir = Path(directory, "state") + execution_file = Path(directory, "execution.json") + execution_file.write_text("first attempt", encoding="utf-8") + environment = { + "STATE_DIR": str(state_dir), + "EXECUTION_FILE": str(execution_file), + "RETRY_EXECUTION_FILE": str(execution_file), + "SESSION_ID": "", + "RETRY_SESSION_ID": "", + "STRUCTURED_OUTPUT": "", + "RETRY_STRUCTURED_OUTPUT": "", + } + for name in ( + "Capture first analysis transcript before retry", + "Capture analysis session transcript", + ): + script = textwrap.dedent(steps[name].split(" run: |\n", 1)[1]) + result = subprocess.run( + ["bash", "-c", script], env=environment, + capture_output=True, text=True, check=False, + ) + self.assertEqual(result.returncode, 0, result.stderr) + execution_file.write_text("retry attempt", encoding="utf-8") + self.assertEqual(state_dir.joinpath("analysis-transcript.json").read_text(), "first attempt") + self.assertEqual(state_dir.joinpath("analysis-retry-transcript.json").read_text(), "retry attempt") + def test_action_allows_structured_output(self): action = Path(pipeline.__file__).with_name("action.yml").read_text( encoding="utf-8" From 8ac938d3e517d407bce3667da1333631cf85bace Mon Sep 17 00:00:00 2001 From: Troublor <14846504+Troublor@users.noreply.github.com> Date: Tue, 24 Nov 2026 09:38:05 +0800 Subject: [PATCH 2/3] docs(pr-review): regenerate action step documentation --- .github/actions/claude-pr-review/README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/actions/claude-pr-review/README.md b/.github/actions/claude-pr-review/README.md index 834f369..3d76cce 100644 --- a/.github/actions/claude-pr-review/README.md +++ b/.github/actions/claude-pr-review/README.md @@ -45,11 +45,13 @@ Family: [Claude CI](../CLAUDE-CI.md). 1. Prepare immutable review context 1. Compose bounded LLM analysis 1. Analyze and verify findings — `anthropics/claude-code-action` *(only if `steps.prepare.outputs.mode != 'skip'`)* +1. Capture first analysis transcript before retry *(only if `always() && steps.prepare.outputs.mode != 'skip'`)* 1. Classify first analysis attempt *(only if `steps.prepare.outputs.mode != 'skip'`)* 1. Retry missing structured review output — `anthropics/claude-code-action` *(only if `steps.prepare.outputs.mode != 'skip' && steps.classify.outputs.retryable != 'false' && (steps.review.outcome == 'failure' || steps.review.outputs.structured_output == '')`)* 1. Capture analysis session transcript *(only if `always()`)* -1. Compile and validate review -1. Publish atomically and persist state +1. Salvage completed retry output *(only if `always() && steps.prepare.outputs.mode != 'skip'`)* +1. Compile and validate review *(only if `always() && steps.prepare.outcome == 'success' && steps.compose.outcome == 'success'`)* +1. Publish atomically and persist state *(only if `${{ !cancelled() && steps.compile.outcome == 'success' }}`)* 1. Report concise review outcome *(only if `always()`)* 1. Upload review state for inspection — `actions/upload-artifact` *(only if `always() && inputs.state_artifact == 'true'`)* From 4d186447baa00071e1d4126f9823db6ab8af3fd5 Mon Sep 17 00:00:00 2001 From: Troublor <14846504+Troublor@users.noreply.github.com> Date: Tue, 24 Nov 2026 09:44:05 +0800 Subject: [PATCH 3/3] fix(pr-review): refresh retry transcripts before salvage --- .github/actions/claude-pr-review/README.md | 2 +- .github/actions/claude-pr-review/action.yml | 4 +- .../claude-pr-review/test_review_pipeline.py | 44 ++++++++++++++++--- 3 files changed, 42 insertions(+), 8 deletions(-) diff --git a/.github/actions/claude-pr-review/README.md b/.github/actions/claude-pr-review/README.md index 3d76cce..aa4fe8e 100644 --- a/.github/actions/claude-pr-review/README.md +++ b/.github/actions/claude-pr-review/README.md @@ -49,7 +49,7 @@ Family: [Claude CI](../CLAUDE-CI.md). 1. Classify first analysis attempt *(only if `steps.prepare.outputs.mode != 'skip'`)* 1. Retry missing structured review output — `anthropics/claude-code-action` *(only if `steps.prepare.outputs.mode != 'skip' && steps.classify.outputs.retryable != 'false' && (steps.review.outcome == 'failure' || steps.review.outputs.structured_output == '')`)* 1. Capture analysis session transcript *(only if `always()`)* -1. Salvage completed retry output *(only if `always() && steps.prepare.outputs.mode != 'skip'`)* +1. Salvage completed retry output *(only if `always() && steps.prepare.outputs.mode != 'skip' && steps.review_retry.outcome == 'failure'`)* 1. Compile and validate review *(only if `always() && steps.prepare.outcome == 'success' && steps.compose.outcome == 'success'`)* 1. Publish atomically and persist state *(only if `${{ !cancelled() && steps.compile.outcome == 'success' }}`)* 1. Report concise review outcome *(only if `always()`)* diff --git a/.github/actions/claude-pr-review/action.yml b/.github/actions/claude-pr-review/action.yml index b4996d9..2988b94 100644 --- a/.github/actions/claude-pr-review/action.yml +++ b/.github/actions/claude-pr-review/action.yml @@ -448,7 +448,7 @@ runs: mkdir -p "$STATE_DIR" copy_transcript() { local source="$1" name="$2" session="$3" - if [[ -f "$STATE_DIR/$name" ]]; then + if [[ "$name" == "analysis-transcript.json" && -f "$STATE_DIR/$name" ]]; then echo "preserved $name captured before retry" elif [[ -n "$source" && -f "$source" ]]; then cp "$source" "$STATE_DIR/$name" @@ -474,7 +474,7 @@ runs: - name: Salvage completed retry output id: salvage - if: always() && steps.prepare.outputs.mode != 'skip' + if: always() && steps.prepare.outputs.mode != 'skip' && steps.review_retry.outcome == 'failure' shell: bash env: REVIEW_STRUCTURED_OUTPUT: ${{ steps.review.outputs.structured_output || steps.review_retry.outputs.structured_output }} diff --git a/.github/actions/claude-pr-review/test_review_pipeline.py b/.github/actions/claude-pr-review/test_review_pipeline.py index d822783..f763e74 100644 --- a/.github/actions/claude-pr-review/test_review_pipeline.py +++ b/.github/actions/claude-pr-review/test_review_pipeline.py @@ -239,19 +239,35 @@ def test_action_salvage_and_capture_wiring(self): ) salvage = steps["Salvage completed retry output"] self.assertIn("id: salvage", salvage) - self.assertIn("if: always() && steps.prepare.outputs.mode != 'skip'", salvage) + conditions = { + "Capture first analysis transcript before retry": + "if: always() && steps.prepare.outputs.mode != 'skip'", + "Salvage completed retry output": + "if: always() && steps.prepare.outputs.mode != 'skip' && " + "steps.review_retry.outcome == 'failure'", + "Compile and validate review": + "if: always() && steps.prepare.outcome == 'success' && " + "steps.compose.outcome == 'success'", + "Publish atomically and persist state": + "if: ${{ !cancelled() && steps.compile.outcome == 'success' }}", + } + for name, condition in conditions.items(): + with self.subTest(step=name): + self.assertEqual( + [ + line.strip() for line in steps[name].splitlines() + if line.startswith(" if:") + ], + [condition], + ) self.assertIn('review_pipeline.py" salvage', salvage) compile_step = steps["Compile and validate review"] - self.assertIn("if: always()", compile_step) self.assertIn( "REVIEW_STRUCTURED_OUTPUT: ${{ steps.review.outputs.structured_output || " "steps.review_retry.outputs.structured_output || steps.salvage.outputs.structured_output }}", compile_step, ) self.assertIn("continue-on-error: true", steps["Retry missing structured review output"]) - self.assertIn( - "steps.compile.outcome == 'success'", steps["Publish atomically and persist state"] - ) self.assertIn( "REVIEW_SALVAGED: ${{ steps.salvage.outputs.salvaged }}", steps["Report concise review outcome"], @@ -259,6 +275,10 @@ def test_action_salvage_and_capture_wiring(self): # Run the actual capture scripts against a reused vendor path. with tempfile.TemporaryDirectory() as directory: state_dir = Path(directory, "state") + state_dir.mkdir() + state_dir.joinpath("analysis-retry-transcript.json").write_text( + "stale retry from an earlier round", encoding="utf-8" + ) execution_file = Path(directory, "execution.json") execution_file.write_text("first attempt", encoding="utf-8") environment = { @@ -283,6 +303,20 @@ def test_action_salvage_and_capture_wiring(self): execution_file.write_text("retry attempt", encoding="utf-8") self.assertEqual(state_dir.joinpath("analysis-transcript.json").read_text(), "first attempt") self.assertEqual(state_dir.joinpath("analysis-retry-transcript.json").read_text(), "retry attempt") + # Exercise the first-attempt preserve branch against the reused path. + environment["RETRY_EXECUTION_FILE"] = "" + script = textwrap.dedent( + steps["Capture analysis session transcript"].split(" run: |\n", 1)[1] + ) + result = subprocess.run( + ["bash", "-c", script], env=environment, + capture_output=True, text=True, check=False, + ) + self.assertEqual(result.returncode, 0, result.stderr) + self.assertIn("preserved analysis-transcript.json", result.stdout) + self.assertEqual( + state_dir.joinpath("analysis-transcript.json").read_text(), "first attempt" + ) def test_action_allows_structured_output(self): action = Path(pipeline.__file__).with_name("action.yml").read_text(