Skip to content

feat(28-02): structured JSON failure telemetry + CLI fallback size guards#12

Open
OgeonX-Ai wants to merge 2 commits into
mainfrom
feat/phase-28-fault-injection
Open

feat(28-02): structured JSON failure telemetry + CLI fallback size guards#12
OgeonX-Ai wants to merge 2 commits into
mainfrom
feat/phase-28-fault-injection

Conversation

@OgeonX-Ai

Copy link
Copy Markdown
Contributor

Summary

  • Adds maf_starter/telemetry.py::emit_failure_telemetry — a stdlib-only, non-raising helper that writes one line of parseable JSON to stderr, closing the REQ-1.4.3 gap where provider-fallback and worker-boundary failures were only visible via in-memory state.
  • Wires telemetry into provider_fallback.py's fallback_middleware and _wrap_stream_with_fallback (primary failure, per-fallback-step failure, fallback success, chain exhaustion — both streaming and non-streaming paths) and into worker_boundary.py's WorkerBoundary._run (worker_task_failed).
  • Closes the remaining C6 gap: adds MAX_CLI_OUTPUT_BYTES / MAX_CLI_PROMPT_BYTES (1MB, matching loop_worker_cli.py's existing MAX_REQUEST_BYTES convention) and enforces them in _run_subprocess / _messages_to_prompt.

Test plan

  • python -m pytest tests/test_provider_fallback_telemetry.py tests/test_worker_boundary.py -v — 16/16 passed
  • python -m pytest tests/ (full suite) — 134 passed, 1 skipped, no regressions
  • Simulated primary-provider outage (rate limit marker) proves ordered, parseable JSON telemetry for both the chain-exhaustion path and the fallback-recovery path

Nothing merged; PR only, no branch protection touched.

Aitomates added 2 commits July 7, 2026 18:37
…ack and cap CLI subprocess size

- Add maf_starter/telemetry.py with emit_failure_telemetry(event, **fields),
  a stdlib-only, non-raising helper that writes one line of parseable JSON to
  stderr so failures are observable to log-based monitoring, not just
  in-memory response metadata.
- Wire emit_failure_telemetry into provider_fallback.py's fallback_middleware
  and _wrap_stream_with_fallback at four points: primary-provider failure,
  each fallback step failure, fallback success/recovery, and full-chain
  exhaustion, in both the non-streaming and streaming code paths.
- Add MAX_CLI_OUTPUT_BYTES and MAX_CLI_PROMPT_BYTES (1MB, mirroring
  loop_worker_cli.py's existing MAX_REQUEST_BYTES convention) and enforce
  them in _run_subprocess and _messages_to_prompt, closing the remaining C6
  gap on the CLI-fallback subprocess path.
- Add tests/test_provider_fallback_telemetry.py: parseable single-line JSON
  contract, non-raising stderr-write-failure behavior, ordered telemetry
  events for chain exhaustion vs. fallback recovery, and size-limit
  rejection tests for both new constants.
… task failures

- Call emit_failure_telemetry("worker_task_failed", run_id=run_id,
  error=str(exc)) inside WorkerBoundary._run's existing except block,
  alongside the existing self._status[run_id] = f"error:{exc}" assignment,
  so background workflow failures are visible to log-based monitoring
  instead of only an in-memory status dict polled via get_status.
- Existing status-string contract (get_status/is_done semantics) is
  unchanged; only the additional telemetry call was added.
- Extend tests/test_worker_boundary.py's error-path test to capture stderr
  and assert the emitted worker_task_failed telemetry line is parseable
  JSON containing run_id and error.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

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.

2 participants