Skip to content

Commit 24e166c

Browse files
committed
WS3
1 parent 82b37c2 commit 24e166c

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,13 @@ All subclasses carry the same attributes, so existing handlers can migrate by ca
4141

4242
`python -m codetracer_python_recorder` returns:
4343

44-
- `0` when tracing and the target script succeed.
45-
- The script's own exit code when it calls `sys.exit()`.
46-
- `1` when a `RecorderError` bubbles out of startup or shutdown.
47-
- `2` when the CLI arguments are incomplete.
44+
- `0` when the recorder finishes cleanly, even if the traced script exits non-zero. The script's status is still recorded in `trace_metadata.json`, and a warning on stderr highlights the suppressed status.
45+
- `1` when a `RecorderError` bubbles out of startup or shutdown (policy failures, `require_trace`, flush/stop issues).
46+
- `2` when the CLI arguments are incomplete or invalid.
4847

49-
Pass `--codetracer-json-errors` (or set the policy via `configure_policy(json_errors=True)`) to stream a one-line JSON trailer on stderr. The payload includes `run_id`, `trace_id`, `error_code`, `error_kind`, `message`, and the `context` map so downstream tooling can log failures without scraping text.
48+
Opt into mirroring the script's exit code with `--propagate-script-exit` (or `CODETRACER_PROPAGATE_SCRIPT_EXIT=true`). Use `--no-propagate-script-exit` to force suppression, even if the environment enables mirroring.
49+
50+
Pass `--json-errors` (or set the policy via `configure_policy(json_errors=True)`) to stream a one-line JSON trailer on stderr. The payload includes `run_id`, `trace_id`, `error_code`, `error_kind`, `message`, and the `context` map so downstream tooling can log failures without scraping text.
5051

5152
### IO capture configuration
5253

codetracer-python-recorder/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
1010

1111
### Changed
1212
- Module-level call events now prefer the frame's `__name__`, fall back to filter hints, `sys.path`, and package markers, and no longer depend on the legacy resolver/cache. The globals-derived naming flag now defaults to enabled so direct scripts record `<__main__>` while package imports emit `<pkg.mod>`, with CLI and environment overrides available for the legacy resolver.
13+
- The CLI now exits with `0` when recording succeeds regardless of the traced script’s status, records a warning when suppressing non-zero script exits, and exposes `--propagate-script-exit` / `CODETRACER_PROPAGATE_SCRIPT_EXIT` / `configure_policy(propagate_script_exit=True)` to restore passthrough semantics.
1314

1415
## [0.2.0] - 2025-10-17
1516
### Added

design-docs/recorder-exit-code-policy-implementation-plan.status.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
## Workstream Progress
88
-**WS1 – Policy & Configuration Plumbing:** Added `propagate_script_exit` across `RecorderPolicy`, `PolicyUpdate`, PyO3 bindings, env parsing, and Python helpers; introduced `CODETRACER_PROPAGATE_SCRIPT_EXIT`; updated Rust + Python unit coverage; rebuilt the dev wheel (`maturin develop --features integration-test`) and verified via `just test`.
99
-**WS2 – CLI Behaviour & Warning Surface:** CLI now defaults to returning `0` on successful recordings, exposes `--propagate-script-exit`/`--no-propagate-script-exit`, emits a warning when suppressing non-zero script exits, and preserves non-zero statuses for recorder failures; added regression coverage (`test_exit_payloads.py`) and executed `just dev test`.
10-
- **WS3 – Documentation, Tooling, and Release Notes:** _Not started._
10+
- **WS3 – Documentation, Tooling, and Release Notes:** README and onboarding docs describe the new default, flags, and env overrides; changelog notes the behavioural change; `just dev test` re-run after docs to confirm tooling.
1111

1212
## Current Focus
13-
- Plan WS3 documentation updates and release notes covering the new default exit behaviour and configuration surfaces.
13+
- Monitor downstream consumers for feedback on the new default and capture any follow-up doc gaps or migration notes.

docs/onboarding/error-handling.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ else:
2929
- Calling `start` twice raises `RuntimeError` from a thin Python guard. Everything after the guard uses `RecorderError`.
3030

3131
## CLI workflow and JSON trailers
32-
- Run `python -m codetracer_python_recorder --codetracer-format=json app.py` to trace a script.
33-
- Exit codes: `0` for success, script exit code when the script stops itself, `1` when a `RecorderError` escapes startup/shutdown, `2` on CLI misuse.
34-
- Pass `--codetracer-json-errors` (or `configure_policy(json_errors=True)`) to mirror each failure as a one-line JSON object on stderr.
32+
- Run `python -m codetracer_python_recorder --format=json app.py` to trace a script.
33+
- Exit codes: `0` when the recorder completes without errors (default even if the script exits non-zero, warning emitted), `1` when a `RecorderError` escapes startup/shutdown, `2` on CLI misuse.
34+
- Use `--propagate-script-exit` (or set `CODETRACER_PROPAGATE_SCRIPT_EXIT=true`, `configure_policy(propagate_script_exit=True)`) when wrappers must mirror the script status.
35+
- Pass `--json-errors` (or `configure_policy(json_errors=True)`) to mirror each failure as a one-line JSON object on stderr.
3536
- JSON fields: `run_id`, optional `trace_id`, `error_code`, `error_kind`, `message`, `context`.
3637

3738
## Migration checklist for existing clients

0 commit comments

Comments
 (0)