fix(server): preserve cyber-policy request logs - #1511
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughThe change preserves recognized ChangesCyber-policy request-log classification
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
✅ Deterministic PR hygiene checks passed. |
✅ READY
Review readiness checklist
✅ 4/4 boxes ticked. This pull request has been marked Ready for Review. |
Wibias
left a comment
There was a problem hiding this comment.
Review on current head 6ef9dce71f4373acd6881d41273f93f6fd1d2c4a.
I did not find a code blocker in the cyber-policy logging fix itself. The structured terminal code is captured before terminal finalization, the semantic HTTP status is used consistently by Responses / Chat Completions / Claude Messages, active-attempt classification is aligned with the final log code, and terminalErrorCode is cleared alongside the existing terminal-status state before policy fallback.
The remaining blocker is integration. This head is now 10 commits behind current dev@70d2e175 after #1464 merged, including overlap in src/server/claude-messages.ts, the transport structure doc, and tests/claude-messages-endpoint.test.ts. Exact-head Cross-platform CI and React Doctor are also action_required; the Cross-platform run executed zero jobs.
Please rebase onto current dev and obtain an executed exact-head CI signal, then request re-review. I am not asking for additional feature changes at this point.
6ef9dce to
2ad05a6
Compare
|
🧠 Learnings used
|
|
Tip For best results, initiate chat on the files or code changes.
🧠 Learnings usedYou are interacting with an AI system. |
Wibias
left a comment
There was a problem hiding this comment.
Re-review on exact head 2ad05a604969a618cfd68aa104b66c4b647591b0.
I still do not find a code-level blocker in the cyber-policy logging fix. The current patch preserves the structured cyber_policy identity narrowly rather than forwarding arbitrary upstream codes, captures the semantic terminal HTTP status before native finalization, and routes Responses / Chat Completions / Claude Messages native terminal callbacks through the context-aware mapper. The active physical attempt is synchronized with the final semantic error code, and policy-candidate fallback clears both terminalHttpStatus and terminalErrorCode, so stale policy classification cannot leak into a later fallback attempt.
The endpoint regressions cover the affected native surfaces, and ordinary terminal behavior remains on the existing mapper when no structured terminal status is present. I do not see a retry, auth, or taxonomy regression introduced by this change.
I am requesting changes for integration/readiness only. Current dev is 4a299fa09352e9f3d5dd119f0d892f92d3d0bab1; this head is 1 ahead / 1 behind with merge base d667367528afa2c604d19af2fc8538b965b88cf1. Exact-head Cross-platform CI (31566369815) and React Doctor (31566369809) are both action_required with 0 jobs, so GitHub CI has not executed this head. The PR is also still draft with the readiness checklist unchecked.
Please rebase onto current dev, obtain executed exact-head CI, and request re-review. No additional feature change is requested from me at this point.
|
Thank you @luvs01 for the work on this PR and for tightening the terminal logging behavior. This is useful because structured |
Summary
cyber_policyterminals as400 / cyber_policyin request logs instead of collapsing them to502 / upstream_server_errorRoot cause and impact
The SSE inspector already classified
response.failedpayloads and stored the semantic HTTP status in the request-log context before invoking the native terminal callback. The three HTTP-derived native callbacks ignored that context and finalized every failed terminal through the genericfailed -> 502mapper. The final log taxonomy then converted the remaining 502 toupstream_server_error.As a result, a Trusted Access for Cyber refusal could appear in
/api/logsandusage.jsonlas an upstream outage even though the provider returned a structuredcyber_policyclient error. This change keeps that policy refusal non-retryable and does not add account switching or request replay.Verification
tsc --noEmitpassed under Bun 1.4.0-canary.1 and Bun 1.3.14bun run privacy:scanpassedgit diff --checkpassedChecklist
Review readiness checklist
This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:
All CI tests are green on my local testing.
I pushed my PR to the latest dev commit.
I resolved all correct Codex and CodeRabbit findings.
My PR is ready for review.
Summary by CodeRabbit
Bug Fixes
cyber_policycode instead of generic 502 errors.Tests