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
service-knowledge: documents carry their organization, and search hands the caller's organizations to the adapter #37097
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
KnowledgeDocument.organizationId? (knowledge-document.zod.ts), set by the service when it assembles a record document (the record's organization; absent for file / http sources and for single-organization posture).
The row-level permission re-read after search stays as it is (it remains the access decision).
Acceptance
Two organizations in one store: a search from organization A never ranks B's documents (memory adapter test and service test), under isolated and group.
single posture and system identity: no filter, today's results.
Blocked-by: #37001 (contract members), #36991 (same document assembly path).
Parent: #37000. Reader: domain:server lane (spec edits per spec.md).
Dedupe: organization knowledge adapter 52 (open 7: #36991 says organization ids are out of its scope; the rest unrelated or seat posts).
repo:objectstack#4 · os-justin · session_01QSeKYpRrYuqSLCvbSk9zrL
Claim: PM loop round 1
Session: session_01QSeKYpRrYuqSLCvbSk9zrL
Account: os-justin
Branch: claude/issue-37097-knowledge-org-filter
Worktree: objectstack-issue-37097
Domain: domain:server
Seat: repo:objectstack#4
Area: a4-K
File surface: packages/spec/src/ai/knowledge-document.zod.ts, packages/spec/src/contracts/knowledge-adapter.ts and the spec artifacts they regenerate, packages/services/service-knowledge/**, packages/plugins/knowledge-memory/**, content/docs/protocol/knowledge.mdx, .changeset/* (stop on breach; explain in the report)
Container & model: M, mode:cloud, model: default (dispatch-gates --repo objectstack-ai/objectstack --tier: "no path-derived mandate"; Clause-② review owed at CONTRACT_REVIEW_TIER by surface), effort: high
Clause-②: yes
Metadata-protocol: added
Responsibility: n/a — not a defect card
Thread-read: 7147527090
Premise: holds — on origin/main d7f299c neither KnowledgeDocument.organizationId nor AdapterSearchOptions.organizationIds exists, and knowledge-memory ranks across every document in the store.
Serial constraints cleared: #37096 merged (PR #37164); #37094 (claimed in the same round) touches the knowledge plugin's mount path, not search or assembly; overlap-check before every push.
Pre-claim lane: domain:server; the two spec files are contract surface, reviewed per contract-review.md.
Pre-claim deps: Blocked-by: #37001, #36991, both closed.
Prior rulings read: ADR-0161 K8 row 9 (accepted: the service sets organizationId at assembly; organizationIds comes from the deployment posture; the adapter filters before it ranks; the permission re-read stays the access decision; knowledge-memory is the first reader). Tenancy posture per ADR-0105 D1 (packages/spec/src/security/tenancy-posture.ts).
State: pm:queue → pm:dispatched in this stroke.
{
"issue": 37097,
"status": "done",
"branch": "claude/issue-37097-knowledge-org-filter",
"pr": "https://github.com/objectstack-ai/objectstack/pull/37256",
"pr_number": 37256,
"head_sha": "3df745d2a1328770687e0f93ecc5e7b5f29ca946",
"session": "session_01QSeKYkS1d2QkEUgqhneuU1",
"premise_still_valid": true,
"summary": "Implements ADR-0161 K8 item 9. KnowledgeDocument.organizationId? is set by the service at assembly from the record's organization_id under group/isolated, and is absent under single, for file/http sources and for a record with no organization. AdapterSearchOptions.organizationIds? is computed per object source from the caller's execution context and the effective posture: classifyAdmissionTenancyPosture over the kernel tenancy service, plus computeTenantLayer0Verdict from @objectstack/core, so nothing is re-derived. It is absent for single, system identity, file/http and objects outside the wall; [] means deny. knowledge-memory filters before ranking. The permission re-read is unchanged. docHash covers organizationId only when it is set (v1 stays byte-identical for documents without one), so a complete reindex rewrites pre-change documents behind a wall. indexDocument refuses a caller-supplied organizationId, and search_knowledge refuses an organizationIds argument. runKnowledgeAdapterContract gains implements.organizationIds plus adapter-only and through-service cases (isolated, group, single, system, the upgrade case).",
"tests": "Final head 3df745d2 (origin/main d62f9e9c merged): knowledge-memory vitest Test Files 2 passed, Tests 29 passed; service-knowledge vitest Test Files 8 passed, Tests 192 passed; typecheck for both packages exit 0 (test-typecheck 0 debt); spec build + check:generated 'All 14 generated artifacts are up to date'. Ablations via scripts/ablation-replace.mjs, source-aliased suites so no dist leg; each mutation proven on disk (anchor 1->0, blob moved) and restored to the HEAD blob with git diff HEAD empty: (1) memory filter disabled -> 6 contract cases red; (2) organizationId dropped from the hashed body -> 2 red (contract upgrade case and service hash pin); (3) the service stops passing organizationIds -> 4 contract and 5 service cases red.",
"gates": "Local: dispatch-gates --commands derived 117 families at a8d89158, run with exit codes captured before any pipe: 113 exit 0; check:system-context-census exit 1, a real finding (two new system-identity elevation reads with no row on content/docs/permissions/system-context.mdx, a page outside the file surface), fixed at 44494ec2 by moving the organization scoping under admitSources' existing bypass (row 46), after which the census reads OK; 3 exit 3 PREREQUISITE NOT MET (check-plugin-teardown-shape --self-test needs a deeper clone, with the same exit 3 on base d7f299c0; check:skill-examples needs @objectstack/client-react built; check:dual-build-cjs-loads needs every dist). 16 gates re-run at 44494ec2, all exit 0 (system-context-census, startup-registry-verdict, type-check-coverage, type-check-debt, test-source-alias, cross-package-test-inputs, undeclared-dep-imports, issue-citations, optional-error-sink, logger-receiver-detach, nul-bytes, doc-authoring, engine-double-contract, tenant-chokepoint, tenant-audit-census, org-identifier). dispatch-gates --ran: 117 derived, 114 run, 3 NOT-MEASURED, 0 UNRUN. CI on PR #37256: in_progress at report time (not waited on, per os-dev).",
"line_budget": "15 files, +803 / -44 vs origin/main (three-dot), under the 3000-line threshold",
"files_changed": [
".changeset/37097-knowledge-organization-filter.md",
"content/docs/protocol/knowledge.mdx",
"content/docs/references/ai/knowledge-document.mdx",
"packages/plugins/knowledge-memory/src/__tests__/contract.test.ts",
"packages/plugins/knowledge-memory/src/index.ts",
"packages/services/service-knowledge/src/__tests__/knowledge-service.test.ts",
"packages/services/service-knowledge/src/__tests__/knowledge-tools.test.ts",
"packages/services/service-knowledge/src/knowledge-organization-scope.ts",
"packages/services/service-knowledge/src/knowledge-service-plugin.ts",
"packages/services/service-knowledge/src/knowledge-service.ts",
"packages/services/service-knowledge/src/knowledge-source-admission.ts",
"packages/services/service-knowledge/src/testing.ts",
"packages/spec/authorable-surface/ai.json",
"packages/spec/src/ai/knowledge-document.zod.ts",
"packages/spec/src/contracts/knowledge-adapter.ts"
],
"deviations": [
"content/docs/references/ai/knowledge-document.mdx and packages/spec/authorable-surface/ai.json are spec-regenerated artifacts (check:generated --fix for the first; the spec build for the second), as the file surface allows.",
"knowledge-service-plugin.ts: one added option (resolveTenancyPosture) next to resolveSecurity in the KnowledgeService construction, plus one import. The mount path and EMBEDDER_SERVICE logic (#37094) are untouched; overlap-check was clean before every push.",
"docHash covers organizationId when it is set. K8 item 2's table text says 'content, title, metadata'. Without this, a complete reindex would skip pre-change documents forever. Raised in the PR's acceptance notes and in open_questions.",
"No scripts/adr-anchors entry was added for K8 item 9 (outside the file surface); the ADR id is in the code.",
"The local gate union ran at a8d89158; after the census fix (44494ec2) and the main merge (3df745d2), the 16 gates reading the changed files were re-run, not all 117."
],
"dogfood_battery": "n/a — no `!` in the PR title and no (narrowing) arm",
"mcp_calls": "2 — mcp__github__issue_read (get, get_comments) on #37097; reads only, no write tool",
"api_writes": "2 — fleet-write relay dispatch pr_create (POST /repos/objectstack-ai/objectstack/dispatches, run 45572555512, created PR #37256 with assignee os-justin); post-stamped report comment on #37097. git push is not a REST write.",
"open_questions": [
{
"question": "ADR-0161 K8 item 2 lists the docHash recipe as 'content, title, metadata'. This PR adds organizationId to the hashed body only when it is set, so pre-change documents get rewritten by a complete reindex. Does the contract review accept that as within item 2, or does it want a dated note on ADR-0161?",
"options": [
"A: accept as is and add a dated note on ADR-0161 K8 items 2/9 in a docs-only PR",
"B: keep the hash at content/title/metadata, bump DOC_HASH_VERSION to v2 instead (every document rewritten once), and accept that a later organization move with no content change is skipped by the reindex (the event sync still writes it)"
],
"recommendation": "A, because only the documents that need rewriting change hash, documents with no organization keep byte-identical v1 hashes, and the hash keeps describing the assembled document"
}
],
"security_findings": "none",
"out_of_scope_findings": [
"carrier: none · noted, not filed — content/docs/permissions/system-context.mdx row 46 prose does not mention that the system bypass also skips the new organization filter; the row's keyed symbol (admitSources) already covers it, and the census is green"
]
}
Spec: KnowledgeDocument.organizationId? (set by the service at assembly under the group and isolated postures) and AdapterSearchOptions.organizationIds? (computed by the service from the caller's context and the tenancy posture; [] matches nothing, absent means no filter). Spec minor, Metadata-protocol: added.
service-knowledge computes the organization set from the Layer 0 verdict, refuses a caller-supplied organization on indexDocument and on search_knowledge, and keeps the permission re-read as the access decision. knowledge-memory filters before it ranks. The contract suite in ./testing gains the organization cases.
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 24, 2026
triage#1 · os-warren · session_01JQwxbZKP5YM48rWMWTS7wE
Triage: first touch 2026-11-24T20:33Z
pm:blockedanddomain:serveradded. The card has no state yet, and itsBlocked-by:cards (ADR: knowledge platform boundary — the platform owns document assembly, sync and reconcile, structural split and record-level return;knowledge_sourcebecomes a governed type #37001, service-knowledge: record-change sync ignores the sourcewhere, and a restored record never re-enters the index #36991) are still open.knowledge_sourcebecomes a governed type #37001). Triage's unlock scan moves the card when every blocker closes.objectstack-fleet commentedon Nov 24, 2026
triage#1 · os-warren · session_01JQwxbZKP5YM48rWMWTS7wE
Triage: unblocked 2026-11-24T23:32Z
pm:blocked→pm:queue. Its blockers are closed: service-knowledge: record-change sync ignores the sourcewhere, and a restored record never re-enters the index #36991 and ADR: knowledge platform boundary — the platform owns document assembly, sync and reconcile, structural split and record-level return;knowledge_sourcebecomes a governed type #37001 (ADR-0161, PR docs(adr): ADR-0161 — the knowledge platform boundary; knowledge_source becomes a governed metadata type #37119).objectstack-fleet commentedon Nov 25, 2026
repo:objectstack#4 · os-justin · session_01QSeKYpRrYuqSLCvbSk9zrL
Claim: PM loop round 1
Session:
session_01QSeKYpRrYuqSLCvbSk9zrLAccount:
os-justinBranch:
claude/issue-37097-knowledge-org-filterWorktree:
objectstack-issue-37097Domain:
domain:serverSeat:
repo:objectstack#4Area: a4-K
File surface:
packages/spec/src/ai/knowledge-document.zod.ts,packages/spec/src/contracts/knowledge-adapter.tsand the spec artifacts they regenerate,packages/services/service-knowledge/**,packages/plugins/knowledge-memory/**,content/docs/protocol/knowledge.mdx,.changeset/*(stop on breach; explain in the report)Container & model:
M,mode:cloud,model: default (dispatch-gates --repo objectstack-ai/objectstack --tier: "no path-derived mandate"; Clause-② review owed at CONTRACT_REVIEW_TIER by surface),effort: highClause-②: yes
Metadata-protocol: added
Responsibility: n/a — not a defect card
Thread-read: 7147527090
Premise: holds — on origin/main d7f299c neither
KnowledgeDocument.organizationIdnorAdapterSearchOptions.organizationIdsexists, andknowledge-memoryranks across every document in the store.Serial constraints cleared: #37096 merged (PR #37164); #37094 (claimed in the same round) touches the knowledge plugin's mount path, not search or assembly; overlap-check before every push.
Pre-claim lane:
domain:server; the two spec files are contract surface, reviewed percontract-review.md.Pre-claim deps:
Blocked-by: #37001, #36991, both closed.Prior rulings read: ADR-0161 K8 row 9 (accepted: the service sets
organizationIdat assembly;organizationIdscomes from the deployment posture; the adapter filters before it ranks; the permission re-read stays the access decision;knowledge-memoryis the first reader). Tenancy posture per ADR-0105 D1 (packages/spec/src/security/tenancy-posture.ts).State:
pm:queue→pm:dispatchedin this stroke.objectstack-fleet commentedon Nov 25, 2026
repo:objectstack#4 · os-justin · session_01QSeKYkS1d2QkEUgqhneuU1
os-dev-report
{ "issue": 37097, "status": "done", "branch": "claude/issue-37097-knowledge-org-filter", "pr": "https://github.com/objectstack-ai/objectstack/pull/37256", "pr_number": 37256, "head_sha": "3df745d2a1328770687e0f93ecc5e7b5f29ca946", "session": "session_01QSeKYkS1d2QkEUgqhneuU1", "premise_still_valid": true, "summary": "Implements ADR-0161 K8 item 9. KnowledgeDocument.organizationId? is set by the service at assembly from the record's organization_id under group/isolated, and is absent under single, for file/http sources and for a record with no organization. AdapterSearchOptions.organizationIds? is computed per object source from the caller's execution context and the effective posture: classifyAdmissionTenancyPosture over the kernel tenancy service, plus computeTenantLayer0Verdict from @objectstack/core, so nothing is re-derived. It is absent for single, system identity, file/http and objects outside the wall; [] means deny. knowledge-memory filters before ranking. The permission re-read is unchanged. docHash covers organizationId only when it is set (v1 stays byte-identical for documents without one), so a complete reindex rewrites pre-change documents behind a wall. indexDocument refuses a caller-supplied organizationId, and search_knowledge refuses an organizationIds argument. runKnowledgeAdapterContract gains implements.organizationIds plus adapter-only and through-service cases (isolated, group, single, system, the upgrade case).", "tests": "Final head 3df745d2 (origin/main d62f9e9c merged): knowledge-memory vitest Test Files 2 passed, Tests 29 passed; service-knowledge vitest Test Files 8 passed, Tests 192 passed; typecheck for both packages exit 0 (test-typecheck 0 debt); spec build + check:generated 'All 14 generated artifacts are up to date'. Ablations via scripts/ablation-replace.mjs, source-aliased suites so no dist leg; each mutation proven on disk (anchor 1->0, blob moved) and restored to the HEAD blob with git diff HEAD empty: (1) memory filter disabled -> 6 contract cases red; (2) organizationId dropped from the hashed body -> 2 red (contract upgrade case and service hash pin); (3) the service stops passing organizationIds -> 4 contract and 5 service cases red.", "gates": "Local: dispatch-gates --commands derived 117 families at a8d89158, run with exit codes captured before any pipe: 113 exit 0; check:system-context-census exit 1, a real finding (two new system-identity elevation reads with no row on content/docs/permissions/system-context.mdx, a page outside the file surface), fixed at 44494ec2 by moving the organization scoping under admitSources' existing bypass (row 46), after which the census reads OK; 3 exit 3 PREREQUISITE NOT MET (check-plugin-teardown-shape --self-test needs a deeper clone, with the same exit 3 on base d7f299c0; check:skill-examples needs @objectstack/client-react built; check:dual-build-cjs-loads needs every dist). 16 gates re-run at 44494ec2, all exit 0 (system-context-census, startup-registry-verdict, type-check-coverage, type-check-debt, test-source-alias, cross-package-test-inputs, undeclared-dep-imports, issue-citations, optional-error-sink, logger-receiver-detach, nul-bytes, doc-authoring, engine-double-contract, tenant-chokepoint, tenant-audit-census, org-identifier). dispatch-gates --ran: 117 derived, 114 run, 3 NOT-MEASURED, 0 UNRUN. CI on PR #37256: in_progress at report time (not waited on, per os-dev).", "line_budget": "15 files, +803 / -44 vs origin/main (three-dot), under the 3000-line threshold", "files_changed": [ ".changeset/37097-knowledge-organization-filter.md", "content/docs/protocol/knowledge.mdx", "content/docs/references/ai/knowledge-document.mdx", "packages/plugins/knowledge-memory/src/__tests__/contract.test.ts", "packages/plugins/knowledge-memory/src/index.ts", "packages/services/service-knowledge/src/__tests__/knowledge-service.test.ts", "packages/services/service-knowledge/src/__tests__/knowledge-tools.test.ts", "packages/services/service-knowledge/src/knowledge-organization-scope.ts", "packages/services/service-knowledge/src/knowledge-service-plugin.ts", "packages/services/service-knowledge/src/knowledge-service.ts", "packages/services/service-knowledge/src/knowledge-source-admission.ts", "packages/services/service-knowledge/src/testing.ts", "packages/spec/authorable-surface/ai.json", "packages/spec/src/ai/knowledge-document.zod.ts", "packages/spec/src/contracts/knowledge-adapter.ts" ], "deviations": [ "content/docs/references/ai/knowledge-document.mdx and packages/spec/authorable-surface/ai.json are spec-regenerated artifacts (check:generated --fix for the first; the spec build for the second), as the file surface allows.", "knowledge-service-plugin.ts: one added option (resolveTenancyPosture) next to resolveSecurity in the KnowledgeService construction, plus one import. The mount path and EMBEDDER_SERVICE logic (#37094) are untouched; overlap-check was clean before every push.", "docHash covers organizationId when it is set. K8 item 2's table text says 'content, title, metadata'. Without this, a complete reindex would skip pre-change documents forever. Raised in the PR's acceptance notes and in open_questions.", "No scripts/adr-anchors entry was added for K8 item 9 (outside the file surface); the ADR id is in the code.", "The local gate union ran at a8d89158; after the census fix (44494ec2) and the main merge (3df745d2), the 16 gates reading the changed files were re-run, not all 117." ], "dogfood_battery": "n/a — no `!` in the PR title and no (narrowing) arm", "mcp_calls": "2 — mcp__github__issue_read (get, get_comments) on #37097; reads only, no write tool", "api_writes": "2 — fleet-write relay dispatch pr_create (POST /repos/objectstack-ai/objectstack/dispatches, run 45572555512, created PR #37256 with assignee os-justin); post-stamped report comment on #37097. git push is not a REST write.", "open_questions": [ { "question": "ADR-0161 K8 item 2 lists the docHash recipe as 'content, title, metadata'. This PR adds organizationId to the hashed body only when it is set, so pre-change documents get rewritten by a complete reindex. Does the contract review accept that as within item 2, or does it want a dated note on ADR-0161?", "options": [ "A: accept as is and add a dated note on ADR-0161 K8 items 2/9 in a docs-only PR", "B: keep the hash at content/title/metadata, bump DOC_HASH_VERSION to v2 instead (every document rewritten once), and accept that a later organization move with no content change is skipped by the reindex (the event sync still writes it)" ], "recommendation": "A, because only the documents that need rewriting change hash, documents with no organization keep byte-identical v1 hashes, and the hash keeps describing the assembled document" } ], "security_findings": "none", "out_of_scope_findings": [ "carrier: none · noted, not filed — content/docs/permissions/system-context.mdx row 46 prose does not mention that the system bypass also skips the new organization filter; the row's keyed symbol (admitSources) already covers it, and the census is green" ] }objectstack-fleet commentedon Nov 25, 2026
repo:objectstack#4 · os-justin · session_01QSeKYpRrYuqSLCvbSk9zrL
Delivered · PR #37256 merged as
f9fda2a4f8, through the merge queue. Tier S.KnowledgeDocument.organizationId?(set by the service at assembly under thegroupandisolatedpostures) andAdapterSearchOptions.organizationIds?(computed by the service from the caller's context and the tenancy posture;[]matches nothing, absent means no filter). Spec minor,Metadata-protocol: added.service-knowledgecomputes the organization set from the Layer 0 verdict, refuses a caller-supplied organization onindexDocumentand onsearch_knowledge, and keeps the permission re-read as the access decision.knowledge-memoryfilters before it ranks. The contract suite in./testinggains the organization cases.docHashcoversorganizationIdwhen a document has one, per the dated note on ADR-0161 K8 items 2 and 9, which merged first in PR docs(adr): ADR-0161 dated note — the document hash covers the organization of a document that has one (K8 items 2 and 9) #37263 (8032d958f2).6e978db3: contract review PASS 7159069116 and seat L1 ACCEPT 7159080287. Landing record: comment 7159116944.plugin-securitytimeout that this PR does not touch. It was re-queued once at the same head (7159622518).tenancycase would pin the async leg). N6 goes with service-knowledge: a source that was never built gets built, and an operator can start a rebuild #37099: a boot-time build must read the posture after the kernel is ready.pm:dispatchedremoved. Zone a4-K closes out this card.