Repository navigation
feat(daemon): expose query completion metadata endpoint (#1844) - #2039
Conversation
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.
There was a problem hiding this comment.
💡 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".
| 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)}) |
There was a problem hiding this comment.
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 👍 / 👎.
Summary
Adds a read-only daemon/web API endpoint for shared query-completion metadata.
GET /api/query-completionsnow returns the samequery_completionspayload 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
GET /api/query-completionsthroughpolylogue.archive.query.completions.query_completion_payload.kindtofield, matching the most useful discovery case.kind=structural-fieldwithoutunit.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.devtools verify --quickatb884da43— exit_code 0.Ref #1844
Ref #1846