Skip to content

fix(daemon): answer an escaped route exception instead of dropping it - #5721

Merged
Sinity merged 5 commits into
masterfrom
fix/4riby-http-request-boundary
Sep 28, 2026
Merged

Sinity merged 5 commits into
masterfrom
fix/4riby-http-request-boundary

Conversation

@Sinity

@Sinity Sinity commented Sep 28, 2026

Copy link
Copy Markdown
Owner

Summary

The daemon HTTP request boundary now answers any exception that escapes a route, using the same typed mapping daemon_safe_handler applies. Bead: polylogue-4riby.

Problem

do_GET/do_POST/do_DELETE caught only client disconnects. An undecorated route that raised (reproduced: GET /p against an archive with index.db but no user.db raises QueryArchiveEpochUnreadableError) reached socketserver, which printed "Exception occurred during processing of request" and closed the socket. The client saw RemoteDisconnected with no status and no outcome envelope.

Solution

  • _answer_route_exception holds the exception-to-answer mapping (PolylogueError status, SQLite busy 503, timeout, backpressure, indeterminate mutation, cancellation, client disconnect). daemon_safe_handler and the three method boundaries both call it.
  • An unexpected exception answers 500 internal_error with outcome: error and is logged once as daemon.http.route_failed.
  • The handler records when a final status line has been written (send_response_only, codes >= 200). A failure after that point is logged and the connection is closed, so no second status line is appended to a partly written response.
  • The SQLite-degradation baseline shrinks by one site, since the separate sqlite3.OperationalError handler is gone.

Verification

  • nix develop --command devtools test tests/unit/daemon/test_http_request_boundary.py tests/unit/daemon/test_daemon_http.py → 14 passed
  • nix develop --command devtools verify --quick → verify: PASSED exit=0
  • Anti-vacuity: without the except Exception boundary, getresponse() raises RemoteDisconnected. Without the _response_started check, the raw socket carries two status lines.

Residuals

The fix was salvaged from an unmerged model-comparison attempt (mx/opus-4riby) and rebased onto the current master unchanged.

🤖 Generated with Claude Code

https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg

The GET/POST/DELETE boundaries caught only client disconnects, so any
other exception from an undecorated route reached socketserver, which
printed a traceback and closed the socket with no status. The request
boundary now applies the same typed mapping as daemon_safe_handler; an
unexpected error answers 500 with outcome=error, and a failure after the
status line was written closes the connection instead of sending a
second status.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@Sinity
Sinity enabled auto-merge (squash) September 28, 2026 14:54
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-28T16:43:46.387323Z 41f8432 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a2bd4d934d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread polylogue/daemon/http.py Resolved
Comment thread polylogue/daemon/http.py Resolved
… of socketserver

QueryErrorPayload declares an optional OutcomeEnvelope, and the boundary's
500 answer carries outcome state=error through it, so clients validating the
shared error model decode it. A disconnect raised while the boundary writes
its answer is logged as client_disconnected instead of escaping.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
@Sinity

Sinity commented Sep 28, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4a6c35ea53

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread polylogue/surfaces/payloads.py Resolved
Ordinary errors keep the four-field QueryErrorPayload envelope; only the
request boundary's unexpected 500 uses QueryFailurePayload with a required
outcome.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dcee83963d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread polylogue/surfaces/payloads.py Resolved
Comment thread polylogue/daemon/http.py Resolved
…lability typed

Every OpenAPI operation declares the request boundary's 500
QueryFailurePayload. An escaped QueryArchiveEpochUnreadableError answers
503 with its own code, as the query-unit route does.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 27c3757c54

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread devtools/render_openapi.py Resolved
@Sinity
Sinity merged commit 841bbb3 into master Sep 28, 2026
3 checks passed
@Sinity
Sinity deleted the fix/4riby-http-request-boundary branch September 28, 2026 16:45
Sinity added a commit that referenced this pull request Sep 28, 2026
Sinity added a commit that referenced this pull request Sep 28, 2026
…ter merge

Master commits #5721/#5729 (already merged, unrelated to this batch)
shifted two sqlite-degradation anchor digests in
polylogue/sources/live/batch.py and
polylogue/sources/live/production_baseline.py. Pruned the one stale
anchor and declared the two new ones via
`devtools.verify_layering --prune-baselines` plus a direct baseline
edit, matching the same reconciliation already done for the first
master merge in 39f6f02.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
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.

1 participant