Skip to content

search_knowledge: the one definition gains scope, granularity and groupBy, for the MCP door and the in-app agent alike #37311

Description

@objectstack-fleet

repo:cloud#1 · os-warren · session_01JQwxbW5anP6GDaVi5LKi2U

Filing gate: ③ maintainer-directed (topic child). Source: topic #37000; maintainer 2026-11-25 「现在拆阶段三」 (decision card in the project thread) and 「#4 只负责在手任务,你接手专题剩余任务」. Reviewed by an independent Fable pass before filing.
Grading: area:ai · Feature · p2 (topic) · reach: every AI client of search_knowledge (MCP over HTTP and stdio; the hosted in-app agent through objectstack-ai/cloud#4933) · evidence: read.

维护者速读

  • 做什么:AI 用的检索工具 search_knowledge 多三个参数:限定在哪几条记录里搜(比如一份制度)、按记录返回而不是按片段、按某个字段分组(返回「哪几份制度」)。
  • 谁受益:外部 AI(MCP)和应用内对话拿到的是同一份工具定义,制度问询可以先找「哪几份制度」,再在一份制度里细查。
  • 要知道的:被权限或范围过滤掉的命中数量从不告诉 AI。
  • 需要你做的:无。

What

Carries ADR-0161 (docs/adr/0161-knowledge-platform-boundary-platform-owns-assembly-sync-split-record-return-knowledge-source-is-a-governed-type.md) Execution row "rows 11, 12": K9 rule 2 ("A new argument enters that one definition. scope, granularity and groupBy arrive in row 12, after their readers in the service (#37103 and row 11). No transport adds an argument of its own."), with K9 rules 1, 3, 5 and 6 held.

  1. The one definition (packages/services/service-knowledge/src/knowledge-tools.ts): SEARCH_KNOWLEDGE_PARAMETERS (:116) gains scope (row 11's shape, bounded as row 11 bounds it), granularity (chunk | record, default chunk) and groupBy (service-knowledge: search returns records, not chunks — granularity and groupBy #37103's meaning: one of the source's metadataFields). SearchKnowledgeInput (:54), INPUT_KEYS (:167) and parseInput (:170) follow; each malformed value is a VALIDATION_ERROR naming the argument. The description (:104) tells the model when to use each.
  2. The executor (createKnowledgeTools, :246) passes the three to IKnowledgeService.search as options. aiExposed stays enforced here (K9 rule 3): the executor searches only exposed sources, so a scope entry whose object only unexposed sources index is answered exactly as an entry whose object no source indexes (row 11: no hits), and groupBy follows service-knowledge: search returns records, not chunks — granularity and groupBy #37103 (a source without the field answers no hits). Neither answer differs for a withheld source, so it never tells an agent one exists.
  3. The answer. SearchKnowledgeOutput / SearchKnowledgeHit (:68-89) carry what the new modes add and nothing else: in record mode one hit per record; with groupBy the group value; the hit's headingPath where service-knowledge: one service-layer splitter (whole / recursive / markdown, Chinese-aware), the chunk channel and the split key #37098 gives one (service-knowledge: search returns records, not chunks — granularity and groupBy #37103 item 6). Name each new member in the description. No count of hits removed by the permission filter or by the scope, and no "more results exist" flag derived from them (K9 rule 6).
  4. Every transport serves it unchanged (K9 rules 1 and 4): the MCP HTTP door (packages/mcp/src/mcp-http-tools.ts, registerKnowledgeTools at :3559, bridged in packages/runtime/src/domains/mcp.ts around :271 and :1671) and stdio (packages/mcp/src/stdio-data-bridge.ts) register the definition as handed over; the in-app agent registers the same one through objectstack-ai/cloud#4933. No transport-side schema edit.
  5. Docs. The tool's section in content/docs/ai/knowledge-rag.mdx.

Rulings carried (ADR-0161 K10): one search_knowledge definition for every transport, aiExposed at the tool layer; the count of hits the permission filter removed is never returned; answers read content as the asking user (the executor adds no permission and removes none, K9 rule 5).

Acceptance

  • tools/list over MCP HTTP and over stdio return byte-identical search_knowledge definitions that include the three arguments (extend packages/mcp/src/mcp-knowledge-tools.test.ts).
  • Over MCP: granularity: 'record' returns one hit per record; groupBy returns one hit per group with its value; scope returns only hits from the named records.
  • A scope entry whose object only unexposed sources index is answered exactly as an entry whose object no source indexes (row 11: no hits); groupBy follows service-knowledge: search returns records, not chunks — granularity and groupBy #37103 (a source without the field answers no hits). Neither answer differs for a withheld source.
  • No answer field reports a filtered count; a test reads the whole answer for one.
  • Each malformed argument is refused VALIDATION_ERROR naming it.
  • Container run per AGENTS.md.

Out of scope

Blocked-by: #37103 (row 10), #37308 (row 11). Done: #36650. Coordinates with #37100 (K7 rule 5's answer, same file).
Parent: #37000. Reader: domain:server lane (packages/services/service-knowledge, packages/mcp).
Dedupe: search_knowledge 16 (open: #37000, #37100, #37103, #37102, seat posts — none adds tool arguments; #37103 lists them as row 12) · search_knowledge granularity 5 (open: #37103, #37000) · search_knowledge groupBy 3 (open: #37103, #37000) · search_knowledge scope 16 (open: as above).

Activity

  1. added
    priority:p2
    pm:blocked
    area:ai
    domain:server
    on Nov 25, 2026
  2. objectstack-fleet commented on Nov 25, 2026

    @objectstack-fleet
    ContributorAuthor

    triage#1 · os-warren · session_01JQwxbZKP5YM48rWMWTS7wE

    First touch 2026-11-25T14:36Z. Confirmed as filed: Feature · area:ai · domain:server · p2, pm:blocked on #37103 and #37308 (row 12). It is a row of topic #37000, so it routes to repo:objectstack#1 (maintainer 13:49Z 「继续专题 开发 37000」). The body's Blocked-by: line already reads in line form.

  3. objectstack-fleet commented on Nov 26, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:cloud#1 · os-warren · session_01JQwxbW5anP6GDaVi5LKi2U

    Claim: PM loop round 2 (epic #37000 owner seat, card thread)
    Session: session_01JQwxbW5anP6GDaVi5LKi2U
    Thread session: session_01JQwxbXPpBL56eaDCJ6MFm4
    Account: os-warren
    Branch: claude/project-thread-dlk17q
    Worktree: objectstack (the card thread's own checkout)
    Domain: domain:server
    Seat: repo:cloud#1
    File surface: packages/services/service-knowledge/src/knowledge-tools.ts and its tests, packages/mcp/src/mcp-knowledge-tools.test.ts (the byte-identical definition check), and for that test only: packages/mcp/package.json (devDependency @objectstack/service-knowledge), its pnpm-lock.yaml importer line and one source alias in packages/mcp/vitest.config.ts, as for service-record-context (amended 01:1xZ; no runtime or published surface), content/docs/ai/knowledge-rag.mdx (the tool section), .changeset/ (stop on breach; explain in the report)
    Container & model: M, mode:thread, model: default (dispatch-gates --tier: no path-derived mandate; floor sonnet · default opus · ceiling fable), effort: high
    Clause-②: yes
    Metadata-protocol: none
    Responsibility: n/a — not a defect card
    Thread-read: 7165556319
    Premise: holds (Blocked-by #37103 (PR #37335) and #37308 (PR #37342, 98b17fe) both closed and on main)
    Serial constraints cleared: #37107 (this seat, PR #37388) touches adapters only, not knowledge-tools.ts. The transports register the definition as handed over and take no schema edit (K9 rules 1 and 4).

    Ownership: maintainer 2026-11-25 13:49Z, 「#4 只负责在手任务,你接手专题剩余任务」; unlocked when #37308 merged 2026-11-26 01:1xZ. Clause-② yes: three new arguments widen the published search_knowledge tool contract and owe a contract review at the ceiling tier before the queue. Carried from the #37308 reviews: the tool door refuses an id with a NUL byte and bounds each id's length; docHash stays out of the answer's hit whitelist; caller strings are quoted and truncated in messages.

  4. added
    pm:dispatched
    and removed
    pm:blocked
    on Nov 26, 2026
  5. objectstack-fleet commented on Nov 26, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:cloud#1 · os-warren · session_01JQwxbXPpBL56eaDCJ6MFm4
    os-dev-report

    {
      "issue": 37311,
      "status": "done",
      "branch": "claude/project-thread-dlk17q",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/37393",
      "session": "session_01JQwxbXPpBL56eaDCJ6MFm4 (card thread; served tier read from get_session: last_served_model opus, effort high, matching the claim's default)",
      "premise_still_valid": true,
      "summary": "search_knowledge's one definition (knowledge-tools.ts) gains scope (10 entries x 500 ids, names and ids 1..255 chars), granularity (enum chunk|record) and groupBy (1..255 chars). The door refuses each malformed value VALIDATION_ERROR naming it, including a NUL in any id/object/field name and an over-long one, an empty scope or an entry with no ids (stricter than the service, as an empty sourceIds already is), and groupBy with granularity chunk. Refusals quote caller strings (JSON.stringify) and cut them to 64 chars, at most five listed. The executor hands the three to searchWithRefusals unchanged; only aiExposed sources are targeted, so a scope/groupBy only a withheld source answers gets the absent answer. hitOf stays a whitelist and gains headingPath and groupValue (metadata[groupBy], only for an object source listing that field); chunkId, docHash, metadata never leave. Docs: a search_knowledge tool section in content/docs/ai/knowledge-rag.mdx. The MCP test now runs the real definition over HTTP and stdio (surface widened by the seat: packages/mcp devDependency, lockfile importer line, one vitest alias).",
      "tests": "At 1ebae539: service-knowledge knowledge-tools.test.ts 54/54; mcp mcp-knowledge-tools.test.ts 17/17; service-knowledge + mcp typecheck green (test layer included). At 4a2b34e8 (the head before a test-only double fix): service-knowledge full 414/414 (13 files), mcp full 1520/1520 (85 files). Ablations in a scratch worktree via scripts/ablation-replace.mjs, each restored blob==HEAD: scope not handed over 4 red + 1 red over MCP; granularity not handed over 1 red over MCP; groupBy not handed over 1 red over MCP; docHash added to hitOf 2 red; groupValue never set 2 red; NUL check removed 3 red; aiExposed filter removed 9 red; 64-char cut removed 1 red. No dist involved (both suites import source).",
      "gates": "Local derived set: dispatch-gates --commands, 114 commands, reconciled with --ran: 111 exit 0, 3 exit 3 PREREQUISITE NOT MET (check-plugin-teardown-shape --self-test: shallow clone; spec check:skill-examples: client dist not built; check:dual-build-cjs-loads: a package has no dist) = NOT MEASURED locally, CI runs them. Commands 1-60 ran on the 4a2b34e8 tree, 61-114 on 1ebae539 (the delta between is the limit bound on two test doubles). CI at 1ebae539 (pr-state): 62 success, 9 expected skip, 0 failed, 0 pending, mergeable_state clean. CI at 4a2b34e8 was red on check:objectql-double-limit (the new MCP test double was limit-blind): fixed in 1ebae539, local gate green. Results file: /mnt/project-files/issue-37311/gate-results-1ebae539.tsv.",
      "dogfood_battery": "n/a — no `!` in the PR title and no (narrowing) arm",
      "mcp_calls": "0",
      "api_writes": "2 — fleet-write relay pr_create (POST /repos/objectstack-ai/objectstack/pulls + POST issues/37393/assignees), this os-dev-report comment; a PR body edit (issue_patch) follows to pin the local-runs block to 1ebae539",
      "open_questions": [],
      "security_findings": "none",
      "out_of_scope_findings": [
        "carrier: none · noted, not filed — content/docs/ai/connect-mcp.mdx's search_knowledge row (tool table) does not mention the three arguments; still true as written, outside the claimed doc surface",
        "carrier: none · noted, not filed — sourceIds items carry no maxLength; only refusal messages cut them (Acceptance note 3)"
      ]
    }

    Generated by Claude Code

  6. objectstack-fleet commented on Nov 26, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:cloud#1 · os-warren · session_01JQwxbW5anP6GDaVi5LKi2U

    ACCEPT → PR #37393 comment 7181309157 (round 2: L1 ACCEPT + contract review PASS at head 44e00dc; round 1 REWORK 7180869252). Not governed; CI all green at that head; readied and auto-merge armed. Out of scope and routed to triage: the MCP SDK input-validation refusal repeats an unknown key as sent on every tool with a closed schema (packages/mcp).

  7. removed
    pm:dispatched
    on Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:aidomain:serverpriority:p2

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions