Skip to content

search joins the workspace read contract, with chant workspace search and a separate --snapshot #4374

Closed

Description

@lex00

Part of INTENTIUS/behold#908. Ruled by the maintainer on 2026-10-23 (behold#908, comment "Design check: chant workspace and the read contract"). Refs #4359, #4360, #4365, #4366, #4367, ws-016, ws-017, ws-052.

Feature

chant search answers through the workspace read contract, and a declared workspace can be searched as one, the way chant workspace graph reads it.

Why

ws-017 chose a versioned contract with a published schema per command, a closed list of reason codes, and MCP tools that wrap the same documents. search --json (#4359, #4367) has none of that, so behold and hud would parse unschema'd CLI JSON, which is ws-017's rejected option b. Search also knows only one project. To answer over a workspace, a reader would have to run it per member and prefix ids itself, and ws-052 says a reader computes no join chant can do itself.

What to build

  1. A contract 1 search document. search --json prints contract: 1, $schema, chant, and the workspace identity when there is one (workspace: {name, root}, at). Failures are error: { code, message } with codes from the closed list (add codes as needed while contract 1 allows it, and say which), and a hint stays as an extra field. The schema goes at src/workspace/search.schema.json, exported like the others, as a oneOf of result and failure, with --count-by's grouped result as a branch. It extends the landed shape (matches, paths, source, explain, drift) without renaming fields. Add it to the contract table in reference/workspace-read-contract.mdx and to the reader conformance suite (@intentius/chant/workspace/conformance).
  2. chant workspace search <query> [--member <name>] [--env <name>] [--snapshot <ref>] [--explain] [--count-by ...] [--json]. It composes members the way workspace graph does: each chant member under its own toolchain (ws-021), ids <member>/<id> identical to workspace graph's, results grouped by member, a member that can't be searched reported with a reason code and never as zero matches, and member stamps from the same rule (ws-059). Search terms evaluate per member. A path that crosses members is out of scope here, and the document says when a member was searched alone.
  3. Two separate times. In the workspace form, --at <rev> is the git revision, as for every contract read, and --snapshot <ref> replays a recorded lifecycle snapshot (search's current --at). Plain chant search --at keeps its meaning for compatibility, and also accepts --snapshot as a synonym. The document says which axis answered: at is the commit and source.snapshot the snapshot.
  4. One MCP API. chant's MCP server gains a workspace-search tool that returns the same document verbatim, beside workspace-graph. Its description covers the grammar and points at the capability catalog once research: a semantic capability catalog for chant search, with each lexicon deriving its own facts #4361 ships.

Acceptance criteria

  • search --json validates against search.schema.json in a test, for a result, a --count-by result, and a refusal. Each refusal carries a code from the contract's list.
  • The conformance suite lists search (and workspace search), and chant's own reader conformance tests pass.
  • On a two-member workspace fixture, chant workspace search "<q>" returns ids equal to the <member>/<id> ids chant workspace graph prints for the same nodes. A test compares the two.
  • A member whose chant is too old, or whose read fails, is reported with a reason code. A test covers each.
  • --at <rev> searches the source at that commit, and --snapshot latest replays the snapshot. A test shows the two are not confused, and that --at with a snapshot ref is refused with a hint naming --snapshot.
  • The MCP workspace-search tool returns exactly the CLI document. A test compares them.
  • Text output without --json is unchanged.
  • Docs: cli/search.mdx, a new cli/workspace-search.mdx, and the contract reference.
  • aws-bench's chant arm does not regress (deferred to the end-of-run pass).
  • Checks: core tsc, npx tsx scripts/typecheck.ts, just lint, targeted vitest, just docs-check.

Activity

  1. added
    enhancement
    area:core
    demo:ask-your-agent
    on Oct 23, 2026
  2. lex00 commented on Oct 23, 2026

    @lex00
    ContributorAuthor

    Landed on epic/908-ask-your-agent at d239908. Part of INTENTIUS/behold#908.

    Box by box:

    • search --json validates against search.schema.json for a result, a --count-by result and refusals; every refusal carries a contract code (search-json.test.ts, search-cli.e2e.test.ts).
    • The conformance suite lists search (run as workspace search <query> --json, MCP tool workspace-search); chant's reader conformance tests pass, CLI and over MCP.
    • Two-member fixture: workspace search ids equal workspace graph's <member>/<id> ids, and member stamps are equal too (search-cli.e2e.test.ts).
    • Too-old member chant -> member-chant-too-old; failed read -> command-failed; missing dir -> dir-missing. A test covers each.
    • --at <rev> searches the source at that commit, --snapshot latest replays a recorded snapshot, --at latest is refused with revision-unknown and a hint naming --snapshot, and --snapshot with --at gives snapshot-at-revision.
    • MCP workspace-search returns exactly the CLI document (workspace-tools.e2e.test.ts).
    • Text output without --json is unchanged (the existing text tests pass untouched).
    • Docs: cli/search.mdx, new cli/workspace-search.mdx, the contract reference, cli/mcp.mdx, the agent-integration guide, and the boundary roster.
    • aws-bench chant arm: deferred to the end-of-run test pass.
    • Checks: core tsc, scripts/typecheck.ts (no regressions), just lint, targeted vitest, just docs-check, docs prose lint.

    Reason codes added within contract 1: query-invalid, usage-invalid, environment-unknown, snapshot-unavailable, build-failed, snapshot-at-revision, member-chant-too-old.

    The member fan-out is not duplicated: readMembers in graph-cli.ts is now shared by workspace graph and workspace search. The MCP tool description covers the grammar; it does not point at the capability catalog yet, since #4361 has not shipped. The schema and docs give the floor as chant 0.124.46; please check that at release.

    Unrelated to this change: lexicons/fountain/src/acp/acp.test.ts fails on the epic branch since #4369. Filed as #4376.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:coredemo:ask-your-agentenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions