Skip to content

Carry the typed answer from the daemon to every surface - #6690

Merged
Sinity merged 10 commits into
integrate-20261101from
pl-answer-boundary
Nov 1, 2026
Merged

Sinity merged 10 commits into
integrate-20261101from
pl-answer-boundary

Conversation

@Sinity

@Sinity Sinity commented Nov 1, 2026 •

Copy link
Copy Markdown
Owner

The daemon now returns one typed answer, command_surface::Answer, to every surface. Before this change it answered with its own Response enum. That enum turned empty and degraded answers into plain ok, dropped notes and next actions, and stored the failure kind as a string plus an untyped detail object. The edges then worked the outcome back out from payload fields (pending, state, /user_state/pending, currency, incomplete, empty, outcome) and rebuilt failures by reading fields out of detail.

Builds on Sinity/polylogue-sinex-common#68, merged as 149e9e2, which adds a typed candidates list to the shared Failure. Cargo.lock is moved to that commit here.

What changed

  • Deleted: daemon::Response, both From conversions, Response::answer, protocol::answer (the code that worked out the outcome from fields), the detail-parsing protocol::failure(code, message, detail), query::response, execution::exit_code, the daemon::query::Failure that held a string kind and detail, the per-module duplicate error mappings (read::failure, language_error, cursor_failure, page failure), and SelectionError::detail.
  • Where the outcome is decided: each answer's outcome is set by the code that builds it.
    • A write that Sinex has not confirmed yet is degraded, with a note. This covers user writes, context deliveries, assertion queries, and StoreError::PrimaryPending, which is now a degraded receipt.
    • An import whose user state is still pending is degraded.
    • Queries return their computed outcome (QueryAnswer { value, outcome, notes }). An incomplete part makes the answer degraded and names the part in its notes.
    • Status and read pages over an index that is not current are degraded, with a note.
    • SQL, completion and resumable lists that match nothing are empty.
  • Failures:
    • The daemon has one internal error, daemon::Failure, which wraps the shared failure. It exists only so ? can convert into it. Store, selection, query and query-language errors convert into it once, at the owner, with typed position, correction, hint and candidates.
    • The kind is the shared FailureKind. The product code stays in Failure::code, classified once in FAILURE_CLASSES. invalid_cursor, attachment_unavailable, embeddings_off and confirm are now registered.
    • Store selection refusals keep their code in a new StoreError::Selection. An ambiguous ID prefix is now the typed StoreError::Ambiguous, and its matches become candidates.
  • Timeouts: a timeout refusal names its stage from the typed request instead of serializing the request and reading text back. It sets the narrower query as the suggestion and gives the stage and SQLite step count in a note.
  • Edges:
    • The socket, HTTP, web pages and browser routes pass the answer through unchanged. The browser routes keep their JSON body and take their status from the failure kind.
    • MCP structured output passes the answer through unchanged. MCP text stays JSON for values; for a failure it lists the candidates and notes.
    • CLI --json passes the answer through unchanged. On a terminal the CLI prints notes and candidates on stderr.
    • The CLI output handlers receive the whole answer.
  • Docs: interfaces.md says who decides the outcome and notes, and names candidates in the JSON error. query.md lists candidates.

Tests

  • New test cli::query_surfaces::a_degraded_answer_keeps_its_outcome_and_notes_on_every_surface sends a degraded query (similar: with embeddings off) through CLI --json, the socket and MCP structuredContent. On each surface it checks outcome degraded, exit 5, the rows, and the same notes naming the missing part. On the old code the notes were empty, so this test fails there.
  • protocol::tests were rewritten around the explicit constructors.
  • Owned tests:
    • a_name_two_saved_queries_share_is_refused and saved_relation_errors_reach_the_query_error_path now check that ambiguity is refused as ambiguous and lists both roots, through candidates (references.md "Ambiguity is an error").
    • an_assertion_reference_names_the_current_revision_or_one_revision: page: and file: references now answer not_built (query.md, references.md) instead of unknown_field.
    • every_surface_refuses_command_words_and_values_outside_a_set: "test output" is refused because a field name is never a search word (common query-language README). The quoted form still searches.
    • native_hook_failures_reach_ordinary_mcp_reads_and_budgeted_pages: the previous commit's update identifies a message header by its reference. Source.message is the containing message of a block, and a header built by Source::record leaves it unset. Checked against the model and kept.

Verification

These checks ran on head f541cca917, rebased on ee5b55eddb. Cargo.lock is at common 149e9e2, which contains #68, and is no longer linked to a local checkout.

  • fast (AgentCTL job 262): passed. It runs fmt, boundaries and clippy in both configurations.
  • focused -p polylogue -p polylogue-store (job 263): 1455 tests, 1420 passed, 34 failed, 1 timed out, 9 skipped.
  • Against the coordinator's baseline (job 213, the unmodified integration head 93da945931, 58 failures):
    • 32 of this run's 35 failures are baseline failures.
    • 26 baseline failures pass here. They include four of the five assigned tests: an_assertion_reference_names_the_current_revision_or_one_revision, every_surface_refuses_command_words_and_values_outside_a_set, a_name_two_saved_queries_share_is_refused and native_hook_failures_reach_ordinary_mcp_reads_and_budgeted_pages.
    • The new degraded-answer test passes.
  • Three failures are not in the baseline:
    • cli::tests::literal_read_envelope_is_not_expanded_with_cli_defaults: a page read through the CLI now sends the restated call (write_out::call(&request, accepted)) instead of the literal envelope. That line came in with Fix daemon and surface test failures at their owners #6688 after the baseline commit; this PR does not touch it.
    • mcp::tests::generated_ready_mcp_call_executes_its_exact_typed_envelope: timed out after more than 90 seconds while the host was heavily loaded. Not yet reproduced.
    • daemon::service::read::object::tests::actual_no_effect_request_read_records_one_object_run_and_roundtrips_through_directory_import: the run outcome is not yet visible when the test reads it (object/tests.rs:115). In earlier runs a sibling test failed at the same line and then passed again, and record is mechanically unchanged here. It looks like a race between the finish write and the next read, but this is not confirmed.
  • saved_relation_errors_reach_the_query_error_path is still a baseline failure. It now passes the ambiguity check and fails later, where sessions where cost > nonsense is not refused at plan preparation; that is outside this change.

rg '\bResponse\b' crates --type rust finds only HTTP response types, the operation trait's associated Response, the Claude Code parser's own Response struct, comments and fixture text. No outcome is worked out from payload fields any more.

🤖 Generated with Claude Code

https://claude.ai/code/session_01AcQETkbTfFMr1hgNJ8A3em

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
🔒 Security Review ⚠️ Failed 2026-11-01T10:21:15.509376Z
We couldn’t complete this review. Comment @codex security review to try again.
cf88e2d PR opened
ℹ️ 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

Copy link
Copy Markdown

The account paying for this security review has reached its Codex usage limits. The payer can check the Codex usage dashboard. For personal accounts, using credits requires enabling “Use credits for security reviews” in Code review settings. If you do not manage the paying account, contact this repository's admins.

Sinity and others added 10 commits November 1, 2026 13:02
The daemon answered with its own Response enum, which flattened empty and
degraded answers into ok, dropped notes and next actions, and kept the
failure kind as a string with an untyped detail object. Every edge then
guessed the outcome back from payload fields such as pending, currency,
incomplete and outcome, and rebuilt failures by reading detail JSON.

Response and both conversions are deleted. Handlers return
command_surface::Answer directly, deciding the outcome where the answer is
made: writes awaiting Sinex confirmation and imports with unconfirmed user
state are degraded, query answers carry their computed outcome and notes,
reads over a noncurrent index are degraded with a note, and list reads that
matched nothing are empty. The daemon's internal error is one Failure that
wraps the shared failure; store, selection, query and query-language errors
convert into it once, with position, correction, hint and the candidates of
an ambiguous reference as typed fields. The store's selection refusals keep
their code as StoreError::Selection, and an ambiguous ID prefix is the typed
StoreError::Ambiguous. Timeout refusals name the stage from the typed
request instead of re-reading serialized request JSON.

The socket, HTTP, web pages, browser routes, MCP text and structured output,
and CLI JSON and terminal output all pass the answer through unchanged; the
CLI prints notes and candidates to stderr. The candidates field comes from
the paired polylogue-sinex-common change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AcQETkbTfFMr1hgNJ8A3em
The shared failure now boxes its candidates so a Result carrying one
stays under Clippy's large error threshold.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AcQETkbTfFMr1hgNJ8A3em
The shared query language never takes a field name for a search word
(query-language README), so "test output" is refused at `output`;
the quoted word still searches.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AcQETkbTfFMr1hgNJ8A3em
MCP clients parse a tool's text as JSON; the notes belong to the
structured answer, so only a failure's text lists them. Page and commit
references are designed forms with no producer yet (query.md,
references.md); they now answer not_built instead of being read as an
unknown field.

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