You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
search_knowledge: hits do not return the source's metadataFields, so a child-record passage needs an extra read to find its parent #38291
area:aiAI-native — agent / tool / skill metadata, and the MCP surface an agent drivesdomain:serverDomain lane — seat card indexed by label:pm:seatpriority:p2Medium: important, M3
A search_knowledge hit does not carry the knowledge source's metadataFields. When the indexed object is a child record, the model has to make an extra read after every search to learn which parent record a passage belongs to.
What happens
A hit returns sourceId, documentId, title, snippet, score, record: { object, id } and, under groupBy, groupValue. The fields declared in the source's metadataFields are not returned.
In the BrightRule app the indexed object is a policy clause: one row per article, with metadataFields: ['policy', 'owning_unit', 'clause_hash', 'kind', 'title']. To cite the policy, or to read the whole policy, the model first has to run query_records on the clause ids to get policy. That is one extra tool round per question. On a turn that already re-sends a long context every round, the extra round pushes the token total closer to the per-turn limit (see cloud#4972 for the measured numbers).
Ask
Return the declared metadataFields values on each hit. Or accept a fields argument naming which record fields to return with the hits, subject to the caller's field-level permissions.
Related: objectstack#36994 (a hit's title was read from a hard-coded field).
Claim: PM loop round 17 · area o1-C (epic #37000; area concurrency 10 by the maintainer 2026-11-28T10:17Z; all priorities, maintainer 2026-11-28T06:54Z; this card dispatched on the maintainer's own word 2026-11-28T13:44Z) · 2026-11-28T13:45Z
Session: session_016WV4cwPhGV4g9p1BGQaZbP
Account: os-elon-musk
Branch: claude/area-o1C-38291
Worktree: objectstack-issue-38291
Domain: domain:server
Area: o1-C
Seat: repo:objectstack#1
File surface: packages/services/service-knowledge/src/knowledge-tools.ts (hitOf, the SearchKnowledgeHit shape and the tool's description text), its tests, a changeset.
Container & model: S, mode:subagent, model: default tier (dispatch-gates --tier: "no path-derived mandate"), effort: high (reason: S, but a widened tool answer that must stay inside the field gate)
Clause-②: yes (widening) — each search_knowledge hit gains the values of its source's declared metadataFields
Metadata-protocol: none
Responsibility: objectstack's own code, packages/services/service-knowledge/src/knowledge-tools.ts | a hit answers only groupValue of the stored passage metadata, so a child-record passage needs an extra query_records round to find its parent | every app indexing child records with metadataFields
Approach (the maintainer chose it): always return the declared metadataFields values on each hit, from the metadata the index already stores. No fields argument and no live record read. The source admission field gate already holds every declared metadataFields member QUERYABLE by the caller before a source is searched, so no value the caller could not query is served. Only members the source still declares are answered (a stored key the source no longer lists is not). Teaching goes in the tool's own description, not in skills/**.
Thread-read: none
Premise: read on origin/main 4cb162b: hitOf whitelists the hit and answers metadata only as groupValue.
Serial constraints cleared: no open PR touches knowledge-tools.ts (read live over the 51 open PRs).
Pre-claim lane: packages/services/** ⇒ domain:server.
Pre-claim deps: none.
Prior rulings read: ADR-0161 K8 (field gate), knowledge-source-admission.ts header.
Fold-or-serial: not folded.
Triage (record only; the card is in flight, so labels and state are untouched): lands in packages/services/service-knowledge/src/knowledge-tools.ts · area:ai · domain:server · Feature · p2 · size S. Rationale: search_knowledge hits do not return the source's metadataFields, so a child-record passage needs an extra read. The fix widens the hit shape of an MCP tool answer, which is a public-contract widening, so it is typed Feature. The claim records that the maintainer chose the approach and dispatched it directly. The p2 is a fleet grade and may only rise while in flight. Type set to Feature in this pass.
Path: none
{
"issue": 38291,
"status": "done",
"branch": "claude/area-o1C-38291",
"pr": "https://github.com/objectstack-ai/objectstack/pull/38353",
"session": "session_016WV4cwPhGV4g9p1BGQaZbP",
"premise_still_valid": true,
"summary": "Premise confirmed on origin/main 600197a6a: hitOf whitelisted the hit and answered stored metadata only as groupValue. Each search_knowledge hit of an indexed record now carries `metadata`, the stored values of exactly the fields its source declares in metadataFields now (declaredMetadataOf: listed order, own keys only, null/absent left out, no member when empty). There is no new argument and no record read, and groupValue is unchanged. The tool description teaches the member. Safety check on main: KnowledgeService.admitSources runs admitSourceFields for every non-system caller before searching; servedFieldsOf includes every metadataFields member, so one non-queryable member refuses the whole source. Existing service-level pin: knowledge-source-admission.test.ts '`title` and `metadataFields` are served fields too'; a tool-level pin was added. One sentence added to content/docs/ai/knowledge-rag.mdx (hit shape), which is one file beyond the claim's declared surface; skills/** untouched. Changeset @objectstack/service-knowledge patch (package name confirmed).",
"tests": "head 1c8472c7ea9 (code head; 5282883f385 changes only the changeset's Clause-② line): `pnpm --filter @objectstack/service-knowledge exec vitest run --maxWorkers=2` under os-verify-lock, VERDICT command-exit 0, Test Files 19 passed (19), Tests 686 passed (686); `pnpm --filter @objectstack/service-knowledge typecheck` (tsc --noEmit + check:test-typecheck over tsconfig.test.json, test layer included) exit 0. New tests in knowledge-tools.test.ts: exact declared values per hit; declaration drops `status` so only `policy` is answered from a corpus that still stores both, and declared [] gives no member; null/absent omitted, unlisted stored key never answered, `constructor` not read from the prototype; field gate through the tool (a member who cannot query `status` gets no hit and the source is never searched; a manager gets the values). Ablation via scripts/ablation-replace.mjs on src (the tests import ../knowledge-tools.js, so there is no dist hop): anchor `for (const field of new Set(listed)) {` replaced by `for (const field of Object.keys(stored)) {`, landed (anchor 1 to 0, blob b07dfa562bce to cd682e3614cf); knowledge-tools.test.ts 2 failed | 57 passed (the drop-a-field test and the null/unlisted test); restored, blob == HEAD, git diff HEAD empty.",
"gates": "dispatch-gates --commands (no paths, --repo objectstack-ai/objectstack, tree 1c8472c7ea9): 99 families run with exit codes captured before any pipe. 98 exit 0. check:dual-build-cjs-loads exit 3 (PREREQUISITE NOT MET: needs every package's dist, a full build), so NOT MEASURED locally. check:skill-examples first exit 3 (client-react dist missing), exit 0 after building @objectstack/client-react... under the lock. dispatch-gates --ran: '99 derived famil(ies) accounted for — 98 run, 1 NOT-MEASURED (1 DERIVED from a recorded exit 3)'. At head 5282883f385 (changeset line only) these were re-run: check-adr-0087-registration, check-changeset-no-major, check-empty-changeset and check:nul-bytes, all exit 0. PR check-runs at 5282883f385 when this was written: Lint & Repo Gates lanes, Type Check lanes, Check Changeset, Governed Surface Queue Guard, PR-body guards and Spec property liveness all in_progress; the opt-in, borrowed and queue verdicts were completed/skipped. CI convergence belongs to PM.",
"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 draft + POST /issues/38353/assignees os-elon-musk, one repository_dispatch, run 46156148026, read-back identical); post-stamped os-dev-report comment on #38291 (POST /repos/objectstack-ai/objectstack/issues/38291/comments). git push is not counted.",
"open_questions": [],
"security_findings": "none",
"out_of_scope_findings": [
"carrier: none · noted, not filed (boundary, in the PR's Acceptance notes): a field that turns internal or credential-class after indexing leaves the gate's served set, while a stale stored passage may carry its value until the recipe-change rebuild. The same already holds for groupValue, the scope metadata terms and snippet text, so this PR adds no new class."
],
"deviations": "Branch not merged with origin/main before the PR: the 9 commits since the branch point touch nothing under packages/services/service-knowledge, so the merge was not needed. content/docs/ai/knowledge-rag.mdx was edited beyond the claim's declared file surface (one sentence on the hit shape)."
}
Delivered by PR #38353 (merged 951c779 at 2026-11-28T15:53Z, Tier S): each search_knowledge hit of an indexed record carries metadata, the stored values of exactly the fields its source declares in metadataFields now, behind the same source-admission field gate; no new argument and no record read. The card closed on merge via Fixes. Record N1 (a field reclassified after a build keeps its stored value until the rebuild, as groupValue and snippets already do) is a note for ADR-0161 K8's owner. pm:dispatched removed with this comment.
area:aiAI-native — agent / tool / skill metadata, and the MCP surface an agent drivesdomain:serverDomain lane — seat card indexed by label:pm:seatpriority:p2Medium: important, M3
Activity
objectstack-fleet commentedon Nov 28, 2026
repo:objectstack#1 · os-elon-musk · session_016WV4cwPhGV4g9p1BGQaZbP
Claim: PM loop round 17 · area o1-C (epic #37000; area concurrency 10 by the maintainer 2026-11-28T10:17Z; all priorities, maintainer 2026-11-28T06:54Z; this card dispatched on the maintainer's own word 2026-11-28T13:44Z) · 2026-11-28T13:45Z
Session:
session_016WV4cwPhGV4g9p1BGQaZbPAccount:
os-elon-muskBranch:
claude/area-o1C-38291Worktree:
objectstack-issue-38291Domain:
domain:serverArea: o1-C
Seat:
repo:objectstack#1File surface:
packages/services/service-knowledge/src/knowledge-tools.ts(hitOf, theSearchKnowledgeHitshape and the tool's description text), its tests, a changeset.Container & model: S,
mode:subagent, model: default tier (dispatch-gates --tier: "no path-derived mandate"), effort: high (reason: S, but a widened tool answer that must stay inside the field gate)Clause-②: yes (widening) — each
search_knowledgehit gains the values of its source's declaredmetadataFieldsMetadata-protocol: none
Responsibility: objectstack's own code,
packages/services/service-knowledge/src/knowledge-tools.ts| a hit answers onlygroupValueof the stored passage metadata, so a child-record passage needs an extraquery_recordsround to find its parent | every app indexing child records withmetadataFieldsApproach (the maintainer chose it): always return the declared
metadataFieldsvalues on each hit, from the metadata the index already stores. Nofieldsargument and no live record read. The source admission field gate already holds every declaredmetadataFieldsmember QUERYABLE by the caller before a source is searched, so no value the caller could not query is served. Only members the source still declares are answered (a stored key the source no longer lists is not). Teaching goes in the tool's own description, not inskills/**.Thread-read: none
Premise: read on origin/main 4cb162b:
hitOfwhitelists the hit and answersmetadataonly asgroupValue.Serial constraints cleared: no open PR touches
knowledge-tools.ts(read live over the 51 open PRs).Pre-claim lane:
packages/services/**⇒domain:server.Pre-claim deps: none.
Prior rulings read: ADR-0161 K8 (field gate),
knowledge-source-admission.tsheader.Fold-or-serial: not folded.
objectstack-fleet commentedon Nov 28, 2026
triage#1 · sunhaolin · session_017xRBcSxvUE3fDrox79CL9t
Triage (record only; the card is in flight, so labels and state are untouched): lands in
packages/services/service-knowledge/src/knowledge-tools.ts· area:ai · domain:server · Feature · p2 · size S. Rationale:search_knowledgehits do not return the source'smetadataFields, so a child-record passage needs an extra read. The fix widens the hit shape of an MCP tool answer, which is a public-contract widening, so it is typed Feature. The claim records that the maintainer chose the approach and dispatched it directly. The p2 is a fleet grade and may only rise while in flight. Type set to Feature in this pass.Path: none
Recorded 2026-11-28T14:15Z.
objectstack-fleet commentedon Nov 28, 2026
repo:objectstack#1 · os-elon-musk · session_016WV4cwPhGV4g9p1BGQaZbP
os-dev-report
{ "issue": 38291, "status": "done", "branch": "claude/area-o1C-38291", "pr": "https://github.com/objectstack-ai/objectstack/pull/38353", "session": "session_016WV4cwPhGV4g9p1BGQaZbP", "premise_still_valid": true, "summary": "Premise confirmed on origin/main 600197a6a: hitOf whitelisted the hit and answered stored metadata only as groupValue. Each search_knowledge hit of an indexed record now carries `metadata`, the stored values of exactly the fields its source declares in metadataFields now (declaredMetadataOf: listed order, own keys only, null/absent left out, no member when empty). There is no new argument and no record read, and groupValue is unchanged. The tool description teaches the member. Safety check on main: KnowledgeService.admitSources runs admitSourceFields for every non-system caller before searching; servedFieldsOf includes every metadataFields member, so one non-queryable member refuses the whole source. Existing service-level pin: knowledge-source-admission.test.ts '`title` and `metadataFields` are served fields too'; a tool-level pin was added. One sentence added to content/docs/ai/knowledge-rag.mdx (hit shape), which is one file beyond the claim's declared surface; skills/** untouched. Changeset @objectstack/service-knowledge patch (package name confirmed).", "tests": "head 1c8472c7ea9 (code head; 5282883f385 changes only the changeset's Clause-② line): `pnpm --filter @objectstack/service-knowledge exec vitest run --maxWorkers=2` under os-verify-lock, VERDICT command-exit 0, Test Files 19 passed (19), Tests 686 passed (686); `pnpm --filter @objectstack/service-knowledge typecheck` (tsc --noEmit + check:test-typecheck over tsconfig.test.json, test layer included) exit 0. New tests in knowledge-tools.test.ts: exact declared values per hit; declaration drops `status` so only `policy` is answered from a corpus that still stores both, and declared [] gives no member; null/absent omitted, unlisted stored key never answered, `constructor` not read from the prototype; field gate through the tool (a member who cannot query `status` gets no hit and the source is never searched; a manager gets the values). Ablation via scripts/ablation-replace.mjs on src (the tests import ../knowledge-tools.js, so there is no dist hop): anchor `for (const field of new Set(listed)) {` replaced by `for (const field of Object.keys(stored)) {`, landed (anchor 1 to 0, blob b07dfa562bce to cd682e3614cf); knowledge-tools.test.ts 2 failed | 57 passed (the drop-a-field test and the null/unlisted test); restored, blob == HEAD, git diff HEAD empty.", "gates": "dispatch-gates --commands (no paths, --repo objectstack-ai/objectstack, tree 1c8472c7ea9): 99 families run with exit codes captured before any pipe. 98 exit 0. check:dual-build-cjs-loads exit 3 (PREREQUISITE NOT MET: needs every package's dist, a full build), so NOT MEASURED locally. check:skill-examples first exit 3 (client-react dist missing), exit 0 after building @objectstack/client-react... under the lock. dispatch-gates --ran: '99 derived famil(ies) accounted for — 98 run, 1 NOT-MEASURED (1 DERIVED from a recorded exit 3)'. At head 5282883f385 (changeset line only) these were re-run: check-adr-0087-registration, check-changeset-no-major, check-empty-changeset and check:nul-bytes, all exit 0. PR check-runs at 5282883f385 when this was written: Lint & Repo Gates lanes, Type Check lanes, Check Changeset, Governed Surface Queue Guard, PR-body guards and Spec property liveness all in_progress; the opt-in, borrowed and queue verdicts were completed/skipped. CI convergence belongs to PM.", "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 draft + POST /issues/38353/assignees os-elon-musk, one repository_dispatch, run 46156148026, read-back identical); post-stamped os-dev-report comment on #38291 (POST /repos/objectstack-ai/objectstack/issues/38291/comments). git push is not counted.", "open_questions": [], "security_findings": "none", "out_of_scope_findings": [ "carrier: none · noted, not filed (boundary, in the PR's Acceptance notes): a field that turns internal or credential-class after indexing leaves the gate's served set, while a stale stored passage may carry its value until the recipe-change rebuild. The same already holds for groupValue, the scope metadata terms and snippet text, so this PR adds no new class." ], "deviations": "Branch not merged with origin/main before the PR: the 9 commits since the branch point touch nothing under packages/services/service-knowledge, so the merge was not needed. content/docs/ai/knowledge-rag.mdx was edited beyond the claim's declared file surface (one sentence on the hit shape)." }objectstack-fleet commentedon Nov 28, 2026
repo:objectstack#1 · os-elon-musk · session_016WV4cwPhGV4g9p1BGQaZbP
Close-out · area o1-C · 2026-11-28T15:53Z
Delivered by PR #38353 (merged 951c779 at 2026-11-28T15:53Z, Tier S): each
search_knowledgehit of an indexed record carriesmetadata, the stored values of exactly the fields its source declares inmetadataFieldsnow, behind the same source-admission field gate; no new argument and no record read. The card closed on merge viaFixes. Record N1 (a field reclassified after a build keeps its stored value until the rebuild, asgroupValueand snippets already do) is a note for ADR-0161 K8's owner.pm:dispatchedremoved with this comment.