doc_discovery
The user-scope driver for semantic content discovery. Forwards a free-text query
to the trusted discovery.start / discovery.poll async job (the authenticated
GET to ZeroMind /v1/discover lives in the trusted VM) and returns the raw
ranked hit list. Merging with the engine's local lexical results happens
Rust-side, behind the guides and search_tools MCP tools — this module only
drives the async fetch across frames.
local discovery = require("@builtin::modules.doc_discovery")
local res = discovery.fetch("render an outline", {}, "guide", 10)
-- res = { ok = true, hits = { … }, elapsedMs = 8944 }
-- | { ok = false, reason = "unavailable" | "timeout" | "invalid", error = "…" }
fetch(query, worlds, kind, limit, budgetMs) — worlds is the optional scope
set (world guids), kind filters by asset kind, limit caps results, and
budgetMs is the wall clock to wait for the answer, defaulting to
DEFAULT_BUDGET_MS. It returns ok = false (never throws), with reason
saying which class of failure it was:
reason | What happened |
|---|---|
invalid | The call itself was wrong — an empty query. Nothing was sent. |
unavailable | The query did not reach ZeroMind, or ZeroMind answered with an error. error names the cause. |
timeout | ZeroMind was still working when budgetMs ran out. budgetMs says how long that was. |
A caller reading zero hits needs reason to know what to do next: a timeout
means the ranking exists and was not waited for, while unavailable means there
is nothing to wait for. guides and search_tools carry it into their
responses as semantic_status.
awaitJob(poll, budgetMs) is the wait itself, exposed so the budget can be
tested without a backend: it polls until a terminal status lands or budgetMs
of wall clock has passed, returning the terminal table and how long it took, or
nil and the time spent.
Scoped to this part · feeds back into the world's score.