Repository navigation
[issue-3364][slice-2/3] PR C — Supervision hardening (RE-SCOPED... - #3573
Merged
Merged
Conversation
…aced-retry path (PR C, #3364) The supervision reference asserted exit 77 is the only exit code that diverges from the record_abort streak path. PR C (#3364) adds a second divergence: a bare throttle (429 / rate limit / overloaded, excluded from EX_AUTH_FATAL per #3373) now exits EX_RATE_LIMITED, maps to JOB_OUTCOME_RATE_LIMITED, and routes to record_rate_limited — no abnormal streak increment, windowed paced retry across the rolling cap window with no hard ceiling (per cq-1), threshold OVERSEER_ALERT, preserved landed slices, and a deterministic-loop guard. Add the exception subsection, the exit-code table row, and correct the 'one code diverges' summary. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…3364) Reviewers reviewer_contract + reviewer_code NACKed v1: the doc described PR C's supervision symbols (EX_RATE_LIMITED, is_transient_rate_limit_error, JOB_OUTCOME_RATE_LIMITED, record_rate_limited) in present tense as shipped fact, but no PR C code has landed (coder still WORKING; grep-confirmed absent from orchestrator/ + shared/). Documenting ahead of code is premature. Defer the agent-recovery.md update until PR C's implementation lands so the doc describes the real landed symbols. The plan created no documenter task for slice-2; this restores the file to its base state. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…paced retry + loop-guard Re-scoped per binding cq-2 (EX_AUTH_FATAL-style exit-code mirror). A bare throttle (429 / rate limit / overloaded) that auth_errors.py keeps OFF the EX_AUTH_FATAL path currently falls to abnormal, feeds the >=10 agent-invocation-fail-streak halt, and stops the pipeline in minutes (abnormal backoff caps at 30s). This routes it to a NEW transient rate-limit class that never touches the abnormal streak and is PACED across the rolling cap window instead. - task-2-1 auth_errors.py: EX_RATE_LIMITED=69 + is_transient_rate_limit_error(), internally disjoint from is_auth_fatal_error (weekly cap on a 429 stays auth-fatal). - task-2-2 __main__.py: emit EX_RATE_LIMITED for a bare throttle, auth-fatal first. - task-2-3 kubernetes_spawner/_models.py: outcome_for -> JOB_OUTCOME_RATE_LIMITED (after EX_AUTH_FATAL->FATAL); stray code -> abnormal. - task-2-4 event_loop/__init__.py + _loop.py: JOB_OUTCOME_RATE_LIMITED; _observe_jobs routes it to record_rate_limited (NOT record_abort). - task-2-6 supervision_policy.py: paced-backoff + reset-parse helpers, RateLimitFingerprint, threshold + loop-guard constants (separate from 30s abnormal). - task-2-7 concurrent_executor.py: _handle_rate_limited wired as rate_limited_notifier — cq-1 threshold OVERSEER_ALERT (no ceiling) + deterministic-loop-guard halt; paced retry preserves landed slices (normal respawn gate, no cold restart). Also implements nominally-tester task-2-5 (record_rate_limited in _supervisor.py) — coder task-2-4/2-7 hard-depend on it for an import-coherent green proposal; flagged as a merge seam for the tester/reviewers. AC-C1 (no fail-streak halt) / AC-C2+C5 (paced, no ceiling, threshold alert) / AC-C3 (landed slices preserved) / AC-C4 (loop-guard both directions) / AC-C6 (EX_AUTH_FATAL + abnormal unchanged). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…-limit path (task-2-8) Adds the PR C test surface, weighted on the exit-code plumbing seam: - shared/egg_agent/tests/test_auth_errors_rate_limit.py: is_transient_rate_limit_error classification (429/rate-limit/overloaded match; auth-fatal + unrelated do NOT); EX_RATE_LIMITED=69 distinct from EX_AUTH_FATAL(77)/reserved codes; DISJOINTNESS (AC-C6: a weekly cap on a 429 stays auth-fatal, never both true); end-to-end CLI mapping (bare throttle -> EX_RATE_LIMITED, weekly-cap-on-429 -> EX_AUTH_FATAL, ordinary -> neither). CLI tests skip cleanly when claude_agent_sdk is absent. - orchestrator/tests/test_kubernetes_spawner_rate_limited.py: outcome_for maps EX_RATE_LIMITED -> rate_limited; auth-fatal still -> fatal (precedence); stray code + read-failure -> abnormal (AC-C6 regression); live/exited never misclassified. - orchestrator/tests/test_event_loop_rate_limited.py: _observe_jobs routes to record_rate_limited (NOT record_abort), reaps, keeps _key_meta; record_rate_limited never trips the streak halt (AC-C1) while record_abort still does (AC-C6); ready_to_respawn pacing; success/retire clear paced state; loop-guard escalates on identical fingerprint and resets when progression advances (AC-C4); cq-1 cumulative threshold alert latches once (AC-C5). - orchestrator/tests/test_supervision_policy.py: rate-limit constants separate from abnormal SUPERVISION_BACKOFF_*; parse_rate_limit_reset_seconds (hints + clamp); rate_limit_backoff_seconds (bounded + reset precedence); RateLimitFingerprint structural equality/hash. - orchestrator/tests/test_concurrent_executor_rate_limit.py: _handle_rate_limited threshold OVERSEER_ALERT (agent-rate-limited, no halt); deterministic-loop alert + halt_rate_limited; landed-slice preservation (only the looping arm halts); no-op when neither transition fires. make lint (ruff) clean; the new suites are green (80 passed, 5 SDK-gated CLI tests skipped locally — they run in CI). Covers AC-C7 + the AC-C6 regressions for task-2-8. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…genuine cap wall
v1 open-NACK barrier (reviewer_contract / reviewer_concurrency / reviewer_code /
reviewer_code_holistic) — all four flagged the SAME root cause: the
deterministic-loop guard used FROZEN BRC progression as deterministic-failure
evidence, but a genuine account-wide cap wall freezes progression identically
(every producer exits EX_RATE_LIMITED before doing any work, so the consensus
digest cannot move). On the bare-exit-code path the throttle signature is also
invariant, so the guard tripped after 5 identical retries (~7.5 min) and halted
the arm — re-imposing exactly the minutes-scale halt PR C exists to remove and
violating binding cq-1 / AC-C2 / AC-C5 (NO hard wall-clock ceiling).
Fix (upstream, in WHEN deterministic_loop is set — handler halt contract kept):
- record_rate_limited escalates ONLY on POSITIVE evidence the failure is no
longer a fresh transient throttle: an exit signature present AND not
classified as a transient rate limit (via is_transient_rate_limit_error) AND
carrying no parseable reset hint. A genuine throttle (no signature on the
orchestrator path, or throttle-classified text) NEVER satisfies this, so it
paces INDEFINITELY with only the cq-1 threshold OVERSEER_ALERT.
- _observe_jobs no longer passes exit_detail for the rate-limit branch: the pod
exit code ("exit_code=69") is not classifiable error text and would mis-read
a genuine cap wall as deterministic. The param stays for a future enriched
observer.
- The progression fingerprint is retained only to reset the repeat counter when
state advances (AC-C4 "continue when state advances").
Tests (tester file, revised in lockstep per reviewer_code_holistic's explicit
ask; flagged as coder/tester seam): replaced the frozen-throttle-escalates
assertion with (a) AC-C5 regression — a steady frozen throttle paces past the
1800s threshold, alerts once, never exhausted; (b) escalation now requires a
non-throttle signature; kept advancing-progression-resets.
331 passed, ruff clean.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…no-ceiling guard (task-2-8 v2) Builds on the coder's lockstep loop-guard fix (94fbf7c) which reworked this file's TestLoopGuardAndThreshold to the corrected discriminator. Removes the now- redundant test_cumulative_wait_threshold_alert_latches_once: three reviewers (reviewer_code/_contract/_code_holistic) flagged its "advance progression each retry to reach the threshold" framing as a corroborating tell of the wrong contract, and its threshold-latch-once property is now covered on the CORRECT frozen-progression cap-wall path by test_steady_throttle_never_escalates_and_ paces_past_threshold (asserts exactly one threshold_crossed at cumulative wait >= 1800s while never halting). Resulting TestLoopGuardAndThreshold pins the corrected AC-C4/AC-C5 contract: - steady bare throttle (frozen progression, no signature): never deterministic_ loop, never exhausted, threshold alert once, paces indefinitely (cq-1 no ceiling) - steady throttle-classified signature ("429 rate limit"): never escalates - non-throttle signature ("Traceback: KeyError"): escalates once past the guard threshold, sticky (AC-C4 positive deterministic evidence) - advancing progression resets the guard counter 224 passed / 5 SDK-skipped; ruff + bandit(-ll) clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ervision path (PR C, #3364) PR C has landed (2bd6124 + loop-guard correction 94fbf7c). Document the real shipped mechanism in the supervision reference, matched to the code: - exit 69 EX_RATE_LIMITED (distinct from 77), is_transient_rate_limit_error matching 429 / rate limit / overloaded / too many requests; disjoint from auth-fatal (weekly/usage cap delivered as 429 stays exit 77). - outcome_for -> JOB_OUTCOME_RATE_LIMITED; _observe_jobs -> record_rate_limited (abnormal streak untouched -> no fail-streak halt). - windowed paced retry (reset-time-paced else bounded backoff; the five SUPERVISION_RATE_LIMIT_* constants), landed slices preserved, no hard ceiling per cq-1, sticky agent-rate-limited OVERSEER_ALERT at 30 min cumulative wait. - deterministic-loop guard as CORRECTED post-NACK: escalates + halts (rate-limit-deterministic-loop) only on POSITIVE non-throttle evidence, not on a frozen fingerprint (a real cap wall freezes progression identically). Adds the exception subsection + exit-code table row and corrects the 'one code diverges' summary to 'two codes diverge'. Co-Authored-By: Claude Opus 4.8 <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.
Behavioral / medium-high risk (highest here — weight toward test coverage on the exit-code plumbing seam). RE-SCOPED to honor binding HITL cq-2 (human-resolved opt-3: pause + re-plan to reconcile the file set with the #3447 JobSupervisor relocation; opt-2's stay-in-3-files partial-AC-C1 deviation was explicitly NOT chosen). AC-C1 ("classify as transient rate-limit, NOT abnormal, does NOT trip the fail-streak halt") is unreachable within the original 3 files: the orchestrator only propagates a per-agent EXIT CODE to the streak site (never the error TEXT), and #3447 moved the per-arm failure-recording layer (JobSupervisor) out of concurrent_executor.py into orchestrator/event_loop/_supervisor.py (+ _loop.py). The faithful mechanism (== cq-2 opt-1) is a distinct exit code EX_RATE_LIMITED mirroring EX_AUTH_FATAL end-to-end: auth_errors.py (define EX_RATE_LIMITED + is_transient_rate_limit_error for 429/rate-limit/ overloaded) -> egg_agent/main.py (emit it, auth-fatal precedence) -> kubernetes_spawner/_models.py (JOB_OUTCOME_RATE_LIMITED outcome mapping) -> event_loop/_loop.py + init.py (_observe_jobs branch -> record_rate_limited) -> event_loop/_supervisor.py (record_rate_limited: NO abnormal-streak increment) -> supervision_policy.py (pacing/fingerprint/threshold constants) -> concurrent_executor.py (windowed-retry / loop-guard / threshold-alert / landed-slice wiring at the on_exhausted / hitl_probe seam). cq-1: no hard ceiling, OVERSEER_ALERT once cumulative wait crosses threshold. AC-C6 invariance is a NEW risk surface: EX_RATE_LIMITED must not perturb the EX_AUTH_FATAL(=77) exit-code path or the ordinary abnormal path. ~8 source files vs the original 3 — blast radius up; test the plumbing seam heavily.
Base PR: #3524
What's in this PR
Commits (17):
This slice
PR C — Supervision hardening (RE-SCOPED per HITL cq-2): EX_RATE_LIMITED exit-code mirror + windowed paced retry + deterministic-loop guard
Files affected:
shared/egg_agent/auth_errors.pyshared/egg_agent/__main__.pyorchestrator/kubernetes_spawner/_models.pyorchestrator/event_loop/__init__.pyorchestrator/event_loop/_loop.pyorchestrator/event_loop/_supervisor.pyorchestrator/supervision_policy.pyorchestrator/concurrent_executor.pyshared/egg_agent/tests/test_auth_errors_rate_limit.pyorchestrator/tests/test_kubernetes_spawner_rate_limited.pyorchestrator/tests/test_event_loop_rate_limited.pyorchestrator/tests/test_supervision_policy.pyorchestrator/tests/test_concurrent_executor_rate_limit.pyTasks (8) + acceptance criteria
if not result.success and is_auth_fatal_error(result.error): return EX_AUTH_FATAL. auth-fatal MUST take precedence (check it first), so a matched weekly cap still returns EX_AUTH_FATAL; the rate-limit branch fires only for the bare throttling signatures.elif outcome == JOB_OUTCOME_FATAL/JOB_OUTCOME_ABNORMALbranches at _loop.py ~:94/:116) that routes a rate-limited outcome to a NEW supervisor.record_rate_limited(...) call. This is the per-arm interception point that keeps the throttle signature OFF the abnormal streak (record_abort is NOT called for this outcome).Stack
issue-3364egg/issue-3364/work