/code-review xhigh --fix master
- User
/code-review xhigh --fix master
- User
code-review /code-review xhigh --fix master
Assistant· claude-opus-4-8
I'll start by gathering the diff under review.
Assistant· claude-opus-4-8
Working tree is clean. Let me capture the full diff for the finders.
Assistant· claude-opus-4-8
Now let me read the key enclosing functions in the actual source files to understand context before dispatching finders.
Assistant· claude-opus-4-8
I now understand the diff well. Key context:
author_generic_profile(managed_profiles.rs:157-163) sets the profile endpointhost = upstream_host,path = upstream_path_prefix.unwrap_or("")— which the new endpoint-aware composition check must match against the composed policy rule. Let me dispatch the finder angles in parallel.Assistant· claude-opus-4-8
Strong signal converging on a few clusters. The highest-severity claim — that a transient gRPC error in the new composition wait (and the new
ensure_v2_enabledin reconcile) propagates a hardErrthat hitsrecovery_step'sBreakarm and permanently stops auto-recovery — needs verification against the actual supervisor code. Let me read it.Assistant· claude-opus-4-8
The careful
Ok(Err(diagnosis))degradation pattern (lines 250-291) confirms the intent: transient gateway errors must NOT become hardErr. The new composition wait (432-444) and theensure_v2_enablednow inside reconcile use.map_err(...)?— hardErr. Let me confirmrecovery_step's handling and howbring_up_sandboxis invoked from startup vs recovery.Assistant· claude-opus-4-8
Confirmed — this is the central finding.
recovery_step(line 755-760) treats any hardErrfrombring_up_sandboxasLoopStep::Break("stop retrying"), and the code goes to great lengths (lines 276-291) to degrade transient gateway errors toOk(Err(diag))precisely to avoid that. But the new composition-wait loop (432-444) and the reconcile call propagate hardErr, so a 10s composition timeout or a transient gRPC blip during the poll now permanently stops auto-recovery. Let me look at the diagnose helpers and the startup caller before fixing.Assistant· claude-opus-4-8
SandboxNotReady { sandbox }is the correct recoverable cause ("sandbox exists and gateway reachable but not yet READY... transient and self-clears"). Let me check theconfig.sandboxtype andproviders()so I can extract a clean helper that degrades the whole provider block recoverably.Assistant· claude-opus-4-8
Now I have what I need. Let me read the exact current text around the helper functions and the bring_up call site so I can edit precisely.
Assistant· claude-opus-4-8
The contract docstring (lines 225-227) confirms intent:
Err(_)is only for "non-self-healing hard error" — gateway RPC failures should be recoverableOk(Err(diag)). My fixes align. Let me gather the remaining context for the other findings before editing: the rotate handler, the full generic-create rollback,get_active_policy's signature, and right-openshell's deps.Assistant· claude-opus-4-8
Now the generic-create handler and its rollback helpers, to verify the profile-leak claim (#12) and assess the duplicated-rollback cleanup.
Assistant· claude-opus-4-8
The pre-existing attach-failure rollback (1446-1465) deliberately leaves the authored profile — comment at 1446-1447 says reconcile refreshes it, and all rollback paths follow this convention. So finding #12 (profile leak) is by design, not a regression — REFUTED. I can see 6 identical
detach+delete+reload+warnblocks that are genuine duplication. Let me read the rollback helpers and the built-in create handler to finalize the dedup and built-in fixes.Assistant· claude-opus-4-8
Now I have the full duplication picture (6 identical
detach+delete+reload+warnblocks). Note finder a070's "marker is a prefix" claim is wrong —wait_for_provider_composed((with() is not a substring ofwait_for_provider_composed_with_endpoint(, so that test correctly distinguishes the variant; I'll skip that one. Let me grab the remaining signatures I need.Assistant· claude-opus-4-8
I have everything needed. Let me verify the marker-order reasoning holds, then apply fixes. Starting with the poll-loop hardening (#2) in
openshell.rs.Assistant· claude-opus-4-8
Now the host case-insensitivity hardening in
provider_capabilities.rs(DNS hostnames are case-insensitive by definition — correct regardless of how OpenShell stores them):Assistant· claude-opus-4-8
Now fix #1 — the recovery trap. First add the
reconcile_and_confirm_providershelper afterprovider_policy_reload_needed:Assistant· claude-opus-4-8
Now replace the inline block in
bring_up_sandboxwith a call that degrades errors recoverably:Assistant· claude-opus-4-8
Now the rollback dedup helper in
internal_api_providers.rs, placed afterensure_provider_policy_loaded_after_rollback:Assistant· claude-opus-4-8
Now replace the duplicated rollback blocks. Built-in
handle_provider_create(3 blocks → calls):Assistant· claude-opus-4-8
Now the generic
create_generic_provider(3 blocks → calls):Assistant· claude-opus-4-8
Now the generic yaml-write rollback block (disambiguated by the trailing generic
ProviderView):Assistant· claude-opus-4-8
Now fix #3 — the rotate handler returning
composed: None(always "Unknown"). Read the live composed state instead, mirroring the list handler:Assistant· claude-opus-4-8
All edits applied. Now let me verify compilation of the touched crates.
Assistant· claude-opus-4-8
Compiles cleanly. Now clippy + the targeted tests (especially the ordering-marker tests and supervisor/provider tests that guard the changed code):
Assistant· claude-opus-4-8
Clippy clean. Now the targeted tests for the changed code:
Assistant· claude-opus-4-8
Let me confirm the specific guard tests (ordering markers, supervisor expectation, poll-loop behavior) ran and passed in the
rightcrate too:Assistant· claude-opus-4-8
All guard tests pass, including the stale-rejection test (unaffected since it uses distinct hosts). Let me check whether the mock server supports a cheap regression test for the new poll-loop transient-tolerance behavior.
Assistant· claude-opus-4-8
Now I'll add a regression test for the poll-loop transient-tolerance fix. First, add a mock hook for the policy-status RPC:
Assistant· claude-opus-4-8
Now add the regression test. Let me check the end of
openshell_tests.rs:Assistant· claude-opus-4-8
I'll append the regression test to
openshell_tests.rs(it's the body ofmod tests):Assistant· claude-opus-4-8
Regression test passes (and the 0.31s confirms it polled again after the error). Now the mandatory full workspace test:
Assistant· claude-opus-4-8
All workspace tests pass — 0 failures across every binary. Let me confirm the final diff scope:
Assistant· claude-opus-4-8
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.