Skip to content

feat(daemon): expose query completion metadata endpoint (#1844) - #2039

Merged
Sinity merged 1 commit into
masterfrom
feature/feat/web-query-completion-contracts-1844
Jun 17, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/feat/web-query-completion-contracts-1844

Conversation

@Sinity

@Sinity Sinity commented Jun 17, 2026

Copy link
Copy Markdown
Owner

Summary

Adds a read-only daemon/web API endpoint for shared query-completion metadata. GET /api/query-completions now returns the same query_completions payload already used by CLI JSON, Python API, and MCP.

Problem

After #2038, the completion metadata contract was shared across CLI/API/MCP, but the local web/workbench surface still had no route to consume it. That left future query-builder work one step away from either reusing the contract or reimplementing completion metadata in the browser layer.

Solution

  • Route GET /api/query-completions through polylogue.archive.query.completions.query_completion_payload.
  • Default omitted kind to field, matching the most useful discovery case.
  • Return a typed 400 JSON error for invalid completion context, such as kind=structural-field without unit.
  • Add live HTTP tests for success and invalid-context behavior.

Verification

  • nix develop --command devtools test tests/unit/daemon/test_web_reader.py -k query_completions — 2 passed.
  • nix develop --command devtools verify --quick — exit_code 0.
  • Push hook reran devtools verify --quick at b884da43 — exit_code 0.

Ref #1844
Ref #1846

Add a read-only /api/query-completions endpoint over the shared query completion payload so the local web/workbench surface can consume the same metadata as CLI, Python API, and MCP. Invalid completion context returns a typed 400 JSON error instead of falling through as a server exception.

Verification: nix develop --command devtools test tests/unit/daemon/test_web_reader.py -k query_completions; nix develop --command devtools verify --quick.
@Sinity
Sinity merged commit 2f4d57d into master Jun 17, 2026
12 checks passed
@Sinity
Sinity deleted the feature/feat/web-query-completion-contracts-1844 branch June 17, 2026 09:33

@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: b884da43c6

ℹ️ 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
try:
payload = query_completion_payload(kind, incomplete=incomplete, unit=unit, field=field)
except QueryCompletionError as exc:
self._send_json(HTTPStatus.BAD_REQUEST, {"error": "invalid_query_completion", "message": str(exc)})

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Use the canonical daemon error envelope

When completion context is invalid, e.g. GET /api/query-completions?kind=structural-field, this new handler returns an ad-hoc {"error", "message"} body instead of the daemon-wide QueryErrorPayload shape documented by _send_error (ok: false, error, detail, field). Clients that handle daemon API failures uniformly will miss the detail for this endpoint; route this through _send_error(HTTPStatus.BAD_REQUEST, "invalid_query_completion", str(exc)) or the equivalent canonical payload.

Useful? React with 👍 / 👎.

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