Repository navigation
feat(knowledge): owners can grant group chats access to private knowledge - #186455
Conversation
…te knowledge Co-authored-by: jalehman <[email protected]> Co-authored-by: Patrick-Erichsen <[email protected]>
…edge Worked on by: - @jalehman - @Patrick-Erichsen Co-authored-by: jalehman <[email protected]> Co-authored-by: Patrick-Erichsen <[email protected]> OpenClaw-Publication: 062610a0-91ee-4f4f-ac15-0a1787678ee6
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR lets administrators grant group conversations read or read-and-save access to their agent’s private Knowledge. Example: The owner grants #kg-room read access to the agent’s private Knowledge.
Review scores
ProductKind: Feature · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This maintainer-authored PR adds useful, explicitly granted Knowledge sharing. The prior findings are addressed, and no additional actionable defect was found; current-head CI remains pending. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe Knowledge plugin resolves host-issued conversation audiences through agent store assignments; registry grants select the private partition, and existing live principal checks govern tools, recall, and index delivery. flowchart TD
A[Administrator settings] --> B[Registry grants]
C[Host memory audience] --> D[Knowledge principal resolver]
B --> D
D --> E[Agent store assignment]
E --> F[Storage worker]
F --> G[Tools recall and index]
Technical reviewBest possible solution: Keep grants in the existing registry and enforce them through the shared principal resolver, as this PR does. Do we have a high-confidence way to reproduce the issue? This is a feature request implemented by the PR; current-main source confirms conversations remain confined to their own partitions. Is this the best way to solve the issue? The implementation extends the existing registry and principal owner consistently across tools, provider reads, recall, and index injection, without introducing a competing authorization path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 970d684a52f0. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +586, Tests +369, Docs +55, Other +1. Total +1011 across 26 files. Added test files: 1. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (4 earlier review cycles)
Reviewed October 28, 2026, 5:52 AM ET / 09:52 UTC (Revision 5). |
…ve grants approve recall Co-authored-by: jalehman <[email protected]> Co-authored-by: Patrick-Erichsen <[email protected]>
Worked on by: - @jalehman - @Patrick-Erichsen Co-authored-by: jalehman <[email protected]> Co-authored-by: Patrick-Erichsen <[email protected]> OpenClaw-Publication: 7aa86dfe-eeb0-4003-9b6d-5d997ee5be39
…ixture Co-authored-by: jalehman <[email protected]> Co-authored-by: Patrick-Erichsen <[email protected]>
Worked on by: - @jalehman - @Patrick-Erichsen Co-authored-by: jalehman <[email protected]> Co-authored-by: Patrick-Erichsen <[email protected]> OpenClaw-Publication: 0a7583a7-568d-49aa-bae3-69d25f9b1c2f
Co-authored-by: jalehman <[email protected]> Co-authored-by: Patrick-Erichsen <[email protected]>
Worked on by: - @jalehman - @Patrick-Erichsen Co-authored-by: jalehman <[email protected]> Co-authored-by: Patrick-Erichsen <[email protected]> OpenClaw-Publication: 1116fdfd-f710-4113-9dea-3b2aadb982d1
Co-authored-by: jalehman <[email protected]> Co-authored-by: Patrick-Erichsen <[email protected]>
Worked on by: - @jalehman - @Patrick-Erichsen Co-authored-by: jalehman <[email protected]> Co-authored-by: Patrick-Erichsen <[email protected]> OpenClaw-Publication: d376394a-216a-4166-a9df-bcfae4b11f93
…oup-grants # Conflicts: # extensions/knowledge/src/stores-config.ts
Worked on by: - @jalehman - @Patrick-Erichsen Co-authored-by: jalehman <[email protected]> Co-authored-by: Patrick-Erichsen <[email protected]> OpenClaw-Publication: c2694e27-7bcc-40f2-9320-dabb8737f443
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Current main is already 788 lines over its ceiling; this PR adds 363. Ceiling 6299646 -> 6300797 (the merged total). Co-authored-by: jalehman <[email protected]> Co-authored-by: Patrick-Erichsen <[email protected]>
Worked on by: - @jalehman - @Patrick-Erichsen Co-authored-by: jalehman <[email protected]> Co-authored-by: Patrick-Erichsen <[email protected]> OpenClaw-Publication: 8071815e-d7ac-4597-a66e-6269ae2d6442
…ay isolated Granted conversations follow the agent's store assignment, so the share and use-shared-store dialogs now say so instead of claiming every group chat sees only its own conversation's knowledge. Co-authored-by: jalehman <[email protected]> Co-authored-by: Patrick-Erichsen <[email protected]>
Worked on by: - @jalehman - @Patrick-Erichsen Co-authored-by: jalehman <[email protected]> Co-authored-by: Patrick-Erichsen <[email protected]> OpenClaw-Publication: b1c214b1-3726-4817-94c8-796bb12b1f53
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…oup-grants # Conflicts: # config/test-lines-baseline.txt
Worked on by: - @jalehman - @Patrick-Erichsen Co-authored-by: jalehman <[email protected]> Co-authored-by: Patrick-Erichsen <[email protected]> OpenClaw-Publication: 890dc412-3c25-4c28-a70b-6beeec01f594
Related: #186050, #186066, #186067, #98542
What Problem This Solves
Group and channel conversations can only use their own conversation partition of an agent's Knowledge store, so an owner has no way to let a team chat read, or read and save, the agent's private knowledge.
User Impact
An operator admin can grant a group or channel conversation read or read and save access to its agent's private knowledge from Knowledge → Settings → Stores & sharing → Conversation access. Threads and other key-denoted child sessions of that conversation inherit the grant. Read grants also get the Knowledge index and automatic recall; read-and-save grants can also approve automatic recall (
knowledge_recall); read-only grants refuse saves with a clear error and drop save guidance from the prompt. Removing access returns the conversation to its own partition and fails in-flight work at its next authority check. Ungranted conversations behave exactly as before. There is no save-only grant: saves run against the private partition, so their results (subject matches, duplicates, record IDs) would reveal private records to a conversation that cannot read them.No new config: grants are Knowledge state stored in its existing
registry.sqlite(themetatable, no schema change), so they persist across restarts and apply immediately.Why This Change Was Made
Knowledge already resolves every call from the host-minted memory audience; a conversation audience carries its stable session key. Knowledge now looks that key (or its nearest
:-delimited ancestor) up in owner grants and, when granted, resolves the call to the private partition; a read-only grant refuses saves. It never reads session rows. Because the grant is part of the pinned principal, a revoked or narrowed grant fails the existing live checks for work already in flight. A grant change is one compare-and-set in the registry worker and takes effect when it returns, and the settings page lists the viewed agent's group and channel conversations to pick from, marking grants that match no known conversation.The core memory audience and owner-private paths are unchanged. Recall approval made under a grant is recorded as
approved_by: owner-private, the existing value, so the record format does not change; history still records which agent and session wrote it.Accepted edges, named rather than coded around:
stores_grantrechecks caller currency and the role's agent ceiling both before the registry write and after it commits, and compensates (restores the previous value) if access ended while the write was queued. A Gateway crash between the commit and the compensation would leave that grant in place, visible and revocable in settings.Implementation notes
access.ts:audiencePrincipalmaps a conversation audience to the private partition for granted reads/writes, refuses writes under a read-only grant, and otherwise keeps the conversation partition. Every grant reads; onlyread-writealso saves. Feature and provider principals take the live grant lookup; provider principals reportsessionPrivate(owner audience or read grant) for automatic recall.store-registry.ts: grants in the registry snapshot and a compare-and-setgrantoperation;stores.tsreads them from the published snapshot.store-assignments.ts:stores_grantoperator action (operator.admin, revision check, 500-grant cap matching the settings list; caller currency and the role's agent ceiling are checked before the registry write and again after it commits, with a compensating revert) and grants in the settings snapshot.memory-provider.ts: a provider lease loads the registry before pinning its principal, so a cold lease sees persisted grants.service.ts:knowledge_recallaccepts conversations with a read-and-save grant.memory-index-hook.ts: index for any session whose principal reads the private partition; the opened access must still be private before a pinned index is reused or rendered, so a grant revoked mid-open never serves the old index.conversation-access-view.ts+settings-view.ts: Conversation access section; sessions are listed with the operator's ownsessions.listaccess for labels and the picker only.Evidence
Isolated Gateway, real agent and model (registry-backed grants; later commits reorder the recall check, cap grants at 500, recheck authority at the point of effect, remove the save-only mode, and load grants before provider leases, each covered by tests). A disposable QA Gateway built from this branch (qa-channel transport, live
openai/gpt-5.6-luna, Knowledge as memory slot, empty provider config so no host credentials or state were used) ran the full flow through real agent turns and the realstores_grantoperator action:private/#kg-room: grep / save / indexNOT-FOUND; save lands inconversations/<id>/;INDEX-ABSENTCODENAME=BLUE-HERON;INDEX-PRESENT: Zephyr launch planFAILED: Knowledge is read-only in this conversation…; private unchanged…:kg-room:thread:kg-thread-1grepCODENAME=BLUE-HERON(inherits)#kg-othergrepNOT-FOUNDCODENAME=BLUE-HERON(grant persisted inregistry.sqlite)private/knowledge_recallFAILED: …read-only…→APPROVED; record gainsrecall.summarywithapproved_by: owner-privateNOT-FOUND;INDEX-ABSENTRaces through the real owners (no stubs). Both timing windows ClawSweeper asked about are driven through the production
Stores, registry worker and storage worker, and assert the final effect rather than a principal check:memory-index-hook.test.ts): a granted conversation renders and pins its private index; the grant is then revoked insidestores.openfor the next read with the same session and cutoff.readMemoryIndexreturns"": the pinned private text is not released. Removing the opened-scope guard makes this test fail.conversation-grants.test.ts): the operator's connection ends after the pre-write check, the registry commits, andstores_grantreturnsforbidden; the settings snapshot no longer lists the grant, and the conversation's own read throughknowledge_recordsreturns none of the private records. Removing the post-commit recheck makes this test fail.applied, and the room reads private records), covered in the same file and in the live table above.Settings → Stores & sharing (same isolated Gateway; before uses main's Knowledge UI bundle):
Before:
After (one granted room, one grant whose conversation no longer exists, picker offering the remaining group):
Upgrade. A consistent SQLite backup of this Team host's live Knowledge registry (2 stores, reconciled membership) loaded with this branch's registry code: it reports no grants, grant and remove round-trip, and store bindings are unchanged. The live file was only read.
Tests.
node scripts/run-vitest.mjs run extensions/knowledgeafter merging currentmain: 58/58 files pass; the touched suites rerun green on the final head. Newconversation-grants.test.tscovers per-mode reads/writes through the service, thread inheritance and the:key boundary, read-only prompt guidance, revocation/narrowing fencing an already-opened principal via the registry, admin/revision conflicts, grants surviving a service restart, a memory-provider lease opened first on a cold service, recall approval per grant mode including as the first call after a restart, the operator's agent ceiling lost while a grant waits, and caller authority ending after the registry write commits (each red without its fix);memory-index-hook.test.tscovers index injection per grant mode for a thread and the revocation-while-opening race above;stores-config.test.tscovers most-specific grant lookup.pnpm tsgo:extensions,pnpm tsgo:extensions:test,pnpm tsgo:scripts,pnpm tsgo:test:root, the type-suppression inventory, oxlint on changed files, and format pass.Test-line baseline: no increase needed after merging main (main's ceiling 6302000 covers this PR's 363 lines); the earlier 6299646 → 6300797 bump approved by @jalehman is superseded. The merged tree measures 6301827 test lines against main's unchanged
config/test-lines-baseline.txt(173 lines of slack).Simplification: no config key, schema migration, journal or core contract; grants are one registry
metavalue and reuse the existing principal pinning and settings page.Fresh review: local autoreview (Codex engine, P0–P2). The first revision's config-lag P1 went away with config storage. On the registry version it found one P2:
knowledge_recallas the first call after a restart checked grants before the registry loaded; fixed with a regression. A later pass flagged that grants beyond the settings list's 500-entry bound would be saved but hidden; grants are now capped at 500. That rerun was clean. Hosted ClawSweeper then raised three authority findings on the config-backed revision: write-only results disclosing private metadata (resolved by removing the save-only mode, per @jalehman), a pinned index reusable after revocation mid-open, and the operator's agent ceiling not rechecked at the write (both fixed with regressions). Its re-review of4faf4cbraised two more: operator authority not rechecked once a queued registry write commits (now rechecked after commit with a compensating revert), and a cold provider lease pinning before grants loaded (now loads first); both have regressions. Its re-review offe95306found no defects and asked for final-effect proof of the two races, added above. Merged currentmainto resolve a one-line import conflict and pick up the current test-line ceiling.Requested by @jalehman, with @Patrick-Erichsen.
Work sessions
Worked on by