Skip to content

service-knowledge: search returns a short page after the permission filter instead of refilling #36993

Description

@os-bob

maintainer · os-bob · session_012dn2AecKpLaYkUtNRiqtby

Filing gate: ① product defect. Source: topic #36990.
Grading: area:ai · Bug · Impeded · rare (apps that mount service-knowledge) · evidence: read.

维护者速读

  • 问题:检索先取前 K 条,再按权限过滤,过滤完不补。一个人能看的记录越少,搜到的越接近空。
  • 修法:第一轮多取一些;过滤后不够,再取一轮。
  • 需要你做的:无。

What

  1. knowledge-service.ts search / applyPermissionFilter: first round asks each source for topK × 5; when fewer than topK survive and the adapter returned as many as asked, a second round asks up to topK × 20. At most two rounds (each embeds the query once).
  2. Counting toward topK dedupes by sourceRecordId; what is returned stays chunk-level hits.
  3. System context: one round of topK, no refill. No context: fail closed as today.
  4. The number of hits removed by the filter goes to logs only, never into the result. search's return type is unchanged.
  5. Build on the shape security(knowledge): search hits skip the API-exposure decision and field-level read rules every other row-serving door applies, now that the MCP door serves search_knowledge #36839 leaves in the same function.

Acceptance

  • 100 hits, the caller can read 5 → returns those 5 (within the cap); several sources; an adapter that caps topK does not loop; return-type snapshot unchanged.
  • Container run per AGENTS.md.

Blocked-by: #36839 (same function)
Parent: #36990. Reader: the server lane for service-knowledge.
Dedupe: knowledge search permission filter topK 1 (#36839, claimed by another seat, different mechanism) · applyPermissionFilter 5 (open: #36839 only).

Activity

  1. added
    area:ai
    on Nov 24, 2026
  2. added theissue type on Nov 24, 2026
  3. objectstack-fleet commented on Nov 24, 2026

    @objectstack-fleet
    Contributor

    triage#1 · os-warren · session_01JQwxbZKP5YM48rWMWTS7wE

    Triage: state pm:blocked. Grade, area and type stay as the maintainer filed them. The card's own Blocked-by: names #36839, which is still open, so it waits as blocked. The unlock scan moves it to pm:queue when that closes. Topic order per the parent's table.

  4. added
    pm:blocked
    on Nov 24, 2026
  5. objectstack-fleet commented on Nov 24, 2026

    @objectstack-fleet
    Contributor

    triage#1 · os-warren · session_01JQwxbZKP5YM48rWMWTS7wE

    Triage: unblocked 2026-11-24T16:42Z

  6. added
    pm:queue
    and removed
    pm:blocked
    on Nov 24, 2026
  7. added
    priority:p2
    and removed on Nov 24, 2026
  8. objectstack-fleet commented on Nov 25, 2026

    @objectstack-fleet
    Contributor

    repo:cloud#1 · os-warren · session_01JQwxbW5anP6GDaVi5LKi2U

    Claim: PM loop round 1 (epic #37000 owner seat; folded claim, chain head #36993 + #36994)
    Session: session_01JQwxbW5anP6GDaVi5LKi2U
    Thread session: session_01JQwxbWqwmAwx7eD4Xf3dv1
    Account: os-warren
    Branch: claude/project-thread-u4piwu
    Worktree: objectstack (the card thread's own checkout)
    Domain: domain:server
    Seat: repo:cloud#1
    File surface: packages/services/service-knowledge/src/knowledge-service.ts, packages/services/service-knowledge/src/knowledge-source-admission.ts, their tests under packages/services/service-knowledge/src/__tests__/, content/docs/protocol/knowledge.mdx, content/docs/ai/knowledge-rag.mdx, content/docs/permissions/system-context.mdx, .changeset/ (revised 2026-11-25 at L1: the two docs pages the build touched; 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-②: no
    Metadata-protocol: none
    Responsibility: objectstack's own service-knowledge search / recordToDocument produce the short page and the missing title (packages/services/service-knowledge) | no platform path covers it | every app that mounts service-knowledge with object sources; reached by search_knowledge on the MCP door today
    Thread-read: 7138103961
    Premise: holds (the only blocker, #36839, merged as PR #36850; the epic records it merged)
    Serial constraints cleared: PR #37287 (#37098, seat 4, in flight) edits the same file knowledge-service.ts; the card thread runs scripts/pm/overlap-check.mjs before each push and queues behind #37287 on exit 1. PR #37265 (#37094) touches knowledge-service-plugin.ts only: no shared file. #37103 (row 10, blocked) builds on this card's refill; #36994 is folded here (same file, one PR #37301).

    Ownership: maintainer 2026-11-25 13:49Z in the project chat, 「#4 只负责在手任务,你接手专题剩余任务」 — this seat owns the epic's remaining rows. Draft PR #37301.

  9. added
    pm:dispatched
    and removed
    pm:queue
    on Nov 25, 2026
  10. objectstack-fleet commented on Nov 25, 2026

    @objectstack-fleet
    Contributor

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

    {
      "issue": 36993,
      "status": "done",
      "branch": "claude/project-thread-u4piwu",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/37301",
      "session": "session_01JQwxbWqwmAwx7eD4Xf3dv1",
      "premise_still_valid": true,
      "summary": "Folded #36993 + #36994 (same file). search() over-asks object sources (topK x 5) when the permission re-check can remove hits, and refills once (topK x 20, the cap) from the sources that answered all they were asked; system identity / no context / file-http sources get one round of topK; answer stays <= topK chunk hits; removed count only at debug. recordToDocument's title = the object's display field via documentTitleField (resolveDisplayField; no definition -> 'title'), shared with the admission field gate. Card #36993 point 2 (count toward topK by sourceRecordId) deliberately not applied: with the <= topK chunk-level cut it changes no answer and only adds a round; it belongs to #37103 record mode (PR Acceptance notes).",
      "tests": "head 2b95b310: pnpm --filter @objectstack/service-knowledge test 8 files / 217 tests passed (at 044f1d6f; later commits: file-source fixture type fix re-run 125/125, docs); typecheck exit 0 incl. check:test-typecheck. Ablations via scripts/ablation-replace.mjs, each restored to HEAD (git diff HEAD empty): refill disabled -> 6 red; title back to record.title -> 5 red; field gate back to 'title' -> 2 red.",
      "gates": "local: dispatch-gates --commands (98, derived at ecb0842d) 79 run, 76 exit 0, 3 PREREQUISITE NOT MET (plugin-teardown-shape --self-test shallow clone; spec check:skill-examples no client-react dist; dual-build-cjs-loads no hono/account dist), 19 not finished = NOT MEASURED locally. Also: eslint on changed files 0, check:doc-anchors 0, check:system-context-census 0 (after row 46 keyed search; CI had caught it), overlap-check clean vs main, #37287, #37265. CI on 2b95b310: in_progress at report time (21 success, 15 skipped, 16 running, 0 failed).",
      "dogfood_battery": "n/a — no ! in the PR title and no (narrowing) arm",
      "mcp_calls": "0",
      "api_writes": "2 — relay pr_create (POST pulls + assignees), relay issue_patch PR #37301 body; plus this os-dev-report comment",
      "open_questions": [],
      "security_findings": "none",
      "out_of_scope_findings": [
        "carrier: #37103 · count toward topK by sourceRecordId (card #36993 point 2) belongs to record mode, noted not filed"
      ]
    }

    Generated by Claude Code

  11. objectstack-fleet commented on Nov 25, 2026

    @objectstack-fleet
    Contributor

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

    {
      "issue": 36993,
      "status": "done",
      "branch": "claude/project-thread-u4piwu",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/37301",
      "session": "session_01JQwxbWqwmAwx7eD4Xf3dv1",
      "premise_still_valid": true,
      "summary": "Rework round on L1 REWORK at 2b95b310 (comment 7165662566). Fix 1: servedFieldsOf keeps the declared-title arm beside documentTitleField until the index is proven rebuilt under the display-field rule (ADR-0161 K7, #37099), comment and PR body say so; refusal pin with a stored old-rule hit replaces the preservation test. Fix 2: the refill decision counts distinct records (object hit = sourceId+sourceRecordId, else documentId); several-sources pin from the L1 probe. Fixes 3-5: changeset, knowledge.mdx, knowledge-rag.mdx, SEARCH_REFILL_FACTOR TSDoc, PR body (maintainer summary and Acceptance notes) corrected.",
      "tests": "head 46217388: pnpm --filter @objectstack/service-knowledge test 8 files / 219 passed; typecheck 0 incl. check:test-typecheck. Ablations (scripts/ablation-replace.mjs, restored, git diff HEAD empty): refill decision back to kept.length -> 1 red (the record-counting pin), 150 green; declared-title arm deleted -> 1 red (its refusal pin), 24 green. Earlier round's three ablations unchanged.",
      "gates": "rework round local: eslint on the 4 changed files 0, check:doc-anchors 0, check:system-context-census 0, overlap-check clean vs origin/main, #37287, #37265. First-round derived list readings stand (PR body). CI on 46217388: started at report time; its check-runs are the reading.",
      "dogfood_battery": "n/a — no ! in the PR title and no (narrowing) arm",
      "mcp_calls": "0",
      "api_writes": "rework round: relay issue_patch PR #37301 body; this os-dev-report comment",
      "open_questions": [],
      "security_findings": "none",
      "out_of_scope_findings": [
        "carrier: #37099 · retire the declared-title arm of the field gate once the index is proven rebuilt under the display-field rule (ADR-0161 K7 recipe hash), noted not filed"
      ]
    }

    Generated by Claude Code

  12. objectstack-fleet commented on Nov 25, 2026

    @objectstack-fleet
    Contributor

    repo:cloud#1 · os-warren · session_01JQwxbW5anP6GDaVi5LKi2U

    ACCEPT → PR #37301 comment 7166003818 (L1 round 2, head 4621738). Lands after CI is green on that head.

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

Metadata

Metadata

Assignees

Labels

area:aipriority:p2

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions