Skip to content

feat(ghost): rank closest nodes in gather + ERR_UNKNOWN_SURFACE grounding#197

Draft
nahiyankhan wants to merge 2 commits into
ghost/07-directory-treefrom
ghost/08-search-and-grounding
Draft

feat(ghost): rank closest nodes in gather + ERR_UNKNOWN_SURFACE grounding#197
nahiyankhan wants to merge 2 commits into
ghost/07-directory-treefrom
ghost/08-search-and-grounding

Conversation

@nahiyankhan

@nahiyankhan nahiyankhan commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

Stacked on ghost/07-directory-tree.

Borrows two agent-grounding ideas from Meta's Astryx design system, adapted to Ghost's prose-node-graph model and to the project's "one road" values. I verified Astryx's actual behaviour against its live MCP search endpoint rather than its docs — its "fuzzy for typos" claim does not hold (buton returns nothing) — so this does not copy that, and adds proper multi-word handling instead.

What's here

Ranked node matching, folded into gather

Rather than adding a standalone search command (Astryx's shape, which suits a 150-component library), the ranking is folded into gather — the act is the same as picking from the node menu, done intelligently:

  • ghost gather (no arg) → full node menu
  • ghost gather <exact-id> → compose the slice
  • ghost gather <inexact-query>ranked candidates instead of dumping the whole menu

Ranking is deterministic and LLM-free: verbatim match (exact id > name > description > body), then a whole-name typo fallback, then multi-word token coverage so a natural phrase like payment confirmation finds the right surface. searchGraph stays as the reusable ranking engine in ghost-core.

ERR_UNKNOWN_SURFACE

A node/surface absent from the package is an error, not a silent empty result. gather returns ranked candidates under this code; checks and review emit it with closest-id suggestions. One stable code — not a broad ERR_* taxonomy.

Self-check skill recipe

A pre-generation probe that tests grounding/provenance (what you gathered, Ghost-backed vs provisional, where the fingerprint is silent) rather than presuming composition facets exist — so it holds for any fingerprint regardless of author, product, or maturity. Composition prompts are optional and treat silence as a valid answer.

Design notes

  • No standalone search command. It overlapped gather's existing "no-arg lists the menu to match against" behaviour, and the cross-domain story was weak: checks are routed by surface, not keyword-searched. Folding it keeps the CLI at 9 commands.
  • No --dense. --format json already serves the machine path; Ghost's payload is authored prose we don't want to mechanically compress.
  • closestIds is the shared fuzzy seam between gather's ranking and the surface guard.

Verification

  • pnpm test (113 passing, +search unit tests, +gather candidate CLI tests)
  • pnpm check green (biome, typecheck, file-size, terminology, install-bundle, cli-manifest in sync)
  • minor changeset added.

Add a ranked, cross-domain  over nodes, surfaces, and
checks: verbatim matches first, a whole-name typo fallback, then
multi-word token coverage so a natural phrase like 'payment confirmation
screen' still finds the right surface. Each hit carries its follow-up
command.

Emit the stable ERR_UNKNOWN_SURFACE code with closest-id suggestions
when gather, checks, or review is given a surface absent from the
package, instead of silently empty-routing.

Add a provenance-based self-check skill recipe that probes grounding
(what you gathered, Ghost-backed vs provisional, where it is silent)
rather than presuming composition facets exist.
Collapse the standalone `ghost search` command into `gather`: an
inexact `gather <query>` now ranks the closest nodes as candidates
instead of dumping the whole menu, the same act as picking from the
menu done intelligently. This drops a command in keeping with the
project's one-road values, retains `searchGraph` as the ranking engine
(node-only now; the weak check-keyword domain is removed since checks
are routed by surface, not searched), and keeps `closestIds` feeding
ERR_UNKNOWN_SURFACE suggestions on checks/review.
@nahiyankhan nahiyankhan changed the title feat(ghost): ghost search + ERR_UNKNOWN_SURFACE grounding feat(ghost): rank closest nodes in gather + ERR_UNKNOWN_SURFACE grounding Jun 29, 2026
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