Repository navigation
fix(callbacks): classify HTTP errors and sanitize CLI diagnostics - #966
Conversation
Review (cf1eb48)Important
次要
已核对、未发现问题
测试
Review provenance
|
XuPeng-SH
left a comment
There was a problem hiding this comment.
Reviewed current head 4e76564a120a9e3976f053050661667a807a3e4b, including the follow-up commit. Requesting changes for the remaining P2 classification issue attached inline. It is a residual design defect in the area this PR changes, not a newly introduced regression.
The follow-up fixes the earlier HTML status-hint regression, removes the unreachable 401 classifier arm, and reuses the existing ANSI stripper. Those findings are withdrawn. The HTML 405 incident is addressed, and sharing the existing formatter across callback diagnostics is the right ownership choice.
The remaining issue is the inference that a JSON-shaped HTTP 409 proves an internal lifecycle violation. Existing server outcomes for superseded approval or lost execution authority show why that inference is too broad. Keep the current acknowledgement and detachment safety gates while making the error projection follow the producer's typed outcome.
Existing comment disposition: status-hint loss and the dead 401 arm are now fixed. I do not adopt the claimed turn-auth-refresh regression: current turn_auth_retry uses typed error fields. The admin CLI formatter is also separate from the formatter changed here.
Verification: read the current CLI CI log: 4,710 tests passed, 10 skipped, including both new formatter follow-up tests. Current Clippy and formatting jobs passed. Inspected real callback callers, the server's structured conflict outcomes, auth refresh, approval acknowledgement, and interactive/headless detach consumers. Implementation +90/-23 (net +67); tests +253/-4 (net +249); documentation +11.
Limits: the selected executor failed to become usable, so no local Rust tests, live WAF/provider harness, or performance benchmarks were run by this reviewer. CI execution evidence is distinguished from source inspection. No subagents were used.
4e76564 to
3b46a12
Compare
XuPeng-SH
left a comment
There was a problem hiding this comment.
Re-reviewed eb34cf99ae617a09d35b3a59e40bfc05ac34cbe8 against 1b200734e8fa5c573dbe1e401b9014c130d9c108. No remaining material correctness or design findings. This approval supersedes my earlier Request Changes review on 4e76564a; its P2 has been fixed in code, and the corresponding thread is resolved.
The earlier P2 is addressed at the correct ownership boundary: Server callback handlers project their existing typed outcomes into shared thin-client error-code constants. CLI classification requires HTTP 409 plus the exact edge_callback_payload_conflict code for a contract violation. Authority loss, supersession, and unknown/uncoded JSON or HTML conflicts remain ordinary rejected HTTP requests. They cannot establish approval acknowledgement. The existing approval_decision_already_recorded decoder and durable_allow_was_acknowledged gate remain separate and unchanged.
Design assessment: the patch extends existing response producers, the existing error classifier and the shared API formatter. It removes raw callback-body rendering and broad HTTP-409 inference without adding a lifecycle, storage, authorization, or retry owner. Generic unknown-409 rejection is a fail-closed outcome, not a version-migration path. There is no model-specific or English-message-based classification in the changed callback path. Existing transport/authentication retry and interactive/headless settlement owners remain in place.
Other prior comments are addressed: markup responses retain canonical status hints, the unreachable callback-401 classifier arm is absent, Unicode leading whitespace is handled, and the existing ANSI stripper removes complete CSI/OSC sequences. The actual callback 401 path still uses HTTP status and its existing token-refresh handlers. Live stderr, returned callback errors and detach diagnostics now share the formatter.
Tests and behavior checked:
- Loopback HTTP cases cover both callback endpoints with HTML 405, generic JSON 409, and the three producer codes. Assertions cover denied acknowledgement, preserved failure kind/run identity, child stream cancellation without parent cancellation, bounded diagnostics, exactly one request per endpoint, and no Server cancellation request.
- Server tests cover divergent tool-result replay after consumption, plus authority-lost/superseded approval receipts through both durable and Edge-ledger handler branches.
- Existing acknowledgement, replay, authentication and interactive/headless detach behavior remains covered. The production resolver's existing ordering preserves authority-lost/superseded outcomes ahead of divergent-payload handling, so a nonresuming receipt cannot be upgraded into an execution acknowledgement through that replay path.
Current-head execution evidence is now complete, rather than relying on the prior-head checks noted in the PR description. Inspected logs identify merge commit cdbecc230da22124d823452f2eb65d55fe91cb57 containing this exact head:
- CLI: 4,710 passed, 10 skipped; new formatter, producer-code and loopback callback regressions explicitly passed.
- Runtime: 5,911 passed, 173 skipped; all 40 callback-handler tests, including the extended nonresuming-outcome coverage, passed.
- Online services: 441 passed, 1,819 skipped.
- Static checks: Clippy and formatting passed.
Limits: no local executor is available, so I did not independently rerun Rust tests, native git diff --check, a real WAF/provider harness, or performance benchmarks. Added diff lines contain no observed trailing whitespace/conflict markers. The restart-named regression reconstructs AppState over a shared in-memory lifecycle fixture; it proves response projection without local ledger state, not process-crash/database reload recovery. Output previews are bounded, but response-body reads and formatting scans are not a new memory bound. No additional database/network work is introduced by the production change. No subagents were used.
Change accounting: implementation +121/-38 (net +83); tests +411/-63 (net +348); documentation +19/-0.
Merge Queue Status
This pull request spent 31 minutes 13 seconds in the queue, with no time running CI. ReasonThe merge conditions cannot be satisfied due to failing checks
HintYou may have to fix your CI before adding the pull request to the queue again. Waiting for
All conditions
Requeued — the merge queue status continues in this comment ↓. |
eb34cf9 to
f303c4e
Compare
Merge Queue Status
This pull request spent 14 seconds in the queue, including 1 second running CI. Required conditions to merge
|
Summary
A tool-result or approval callback rejected by a gateway could be classified as a lifecycle contract violation and print a full HTML block page. Classify callback HTTP errors by status and require the producer-authored
edge_callback_payload_conflictcode for HTTP 409 contract conflicts. JSON shape and English detail text are insufficient. The Server now emits stable codes for divergent callback payloads, lost execution authority, and superseded interactions. Recorded interactions that did not resume execution and unknown HTTP 409s remain ordinary conflicts (InvalidRequest), preserving turn evaluation and the existing approval acknowledgement gate. Reuse the CLI API formatter for live stderr, returned errors, and final detach diagnostics: retain status and bounded diagnostic IDs, omit HTML/markup pages, and bound other response previews. HTML responses retain the canonical HTTP status hints used by session-authentication recovery. Callback 401 handling remains owned by the existing authentication handlers; the unreachable classifier branch is removed.Related issue
Related #919. The WAF configuration has been corrected and an end-to-end callback succeeded; this PR addresses the independent CLI diagnostics defect.
Change type
User and compatibility impact
Gateway HTML rejections no longer imply durable lifecycle rejection or flood the terminal. Authentication refresh, coded payload conflicts, transport retry bounds, and existing interactive/headless settlement behavior remain intact. Callback conflict responses gain additive
error_codevalues; request bodies and configuration are unchanged. Older uncoded 409 responses remain ordinary HTTP conflicts and never establish approval acknowledgement.Architecture and complexity delta
Verification
make format-check,git diff --check, andcargo test -p astra-runtime --lib edge_callback_insert_tests -- --test-threads=2passed (40 tests).3b46a12deabc5b267712283a0393bd68df7d935fpassed workspace Clippy and static checks. The remaining test jobs are still running; they are not claimed as passed.New regressions cover both durable and Edge-ledger approval receipt replay after reconstructing AppState; authority loss and supersession remain HTTP 409 without authorizing local execution. Tool-result coverage rejects divergent replay after consumption. CLI loopback tests exercise both callback endpoints with HTML 405, generic JSON 409, and all three producer-authored conflict codes, including acknowledgement and detachment gates.
Database verification: not applicable; response projection changes only, with no persistence or approval-decision changes.
Final checklist