Repository navigation
fix(knowledge): scope conversation learning to its agent - #205665
Conversation
Co-authored-by: RomneyDa <[email protected]>
Worked on by: - @RomneyDa Co-authored-by: RomneyDa <[email protected]> OpenClaw-Publication: f4ee47f-60ff-4553-a51c-ea272fa46a6c
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Codex review: needs maintainer review before merge. What this changesThis PR limits conversation-learning scribes to their own agent’s sessions and documents how to review previously copied Knowledge. Example: Agent beta runs Learn from conversations while agent alpha has private conversations.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR addresses a verified ingestion bug that remains on main; no definite introduced defect was found. Reviewed head: Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherKnowledge scribes run agent turns through the Gateway; tool construction applies the scribe ceiling before session inventory or transcript results reach the model. flowchart TD
A[Scribes start request] --> C[Agent tool construction]
B[Scheduled execution context] --> C
C --> D[Agent read ceiling]
D --> E[Session inventory and history]
E --> F[Learning model]
F --> G[Agent Knowledge store]
Technical reviewBest possible solution: Keep the scribe-specific ceiling in the existing session-policy owner while preserving ordinary cross-agent capabilities and historical Knowledge records. Do we have a high-confidence way to reproduce the issue? Current main’s unfiltered learning instructions and broad session visibility establish the reported path; supplied Gateway results corroborate it, but this review executed no target code. Is this the best way to solve the issue? The focused ceiling is appropriate: list filtering, history authorization, and session-ID resolution prevent foreign ingestion without changing ordinary session access or introducing another policy owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against eb704f55cad9. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +64, Tests +76, Docs +17. Total +157 across 12 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes: No label changes. Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
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 HistoryReviewed November 26, 2026, 12:50 AM ET / 05:50 UTC (Revision 3). |
|
ClawSweeper status: applying reviewed decision. I am applying the reviewed decision for this pull request: fix(knowledge): scope conversation learning to its agent This is item 1/1 in the current shard. Shard 1/1. This transient lease prevents a newer review from overlapping label, comment, or close mutations. Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted. |
|
Gateway-level before/after evidence for #205581 (updated 2026-11-26) Result: the fix behaves as intended. On
Setup. Each build ran a real in-process Gateway: the repo's
git fetch origin pull/205665/head:pr-205665 # 683e8b6740eddfdccfcc5287e0b92e569d4b7444
git worktree add --detach ../knowledge-e2e-main 90ba7624dbdd4aef7aa17fa683ae7fef47c54856
pnpm install --frozen-lockfile --prefer-offline # each worktree; identical lockfile
git add src/gateway/knowledge-scribe-scope.proof.e2e.test.ts # staged only, adapter snapshots tracked files
# private Podman: HOME=$root/home (storage.conf graphroot/runroot under $root), XDG_RUNTIME_DIR=$root/runtime
umask 022; HOME=$root/home XDG_RUNTIME_DIR=$root/runtime npm_execpath=<native pnpm 12.15.0> \
node scripts/run-vitest.mjs --isolated-image sha256:a0d7b2b4… run \
--config test/vitest/vitest.e2e.config.ts --configLoader runner \
src/gateway/knowledge-scribe-scope.proof.e2e.test.ts --maxWorkers=1
# after: 2 passed, exit=0, container absence confirmed
# before: 2 failed on the after-contract (alpha listed/read), exit=1, container absence confirmedGaps:
No product code was changed. No push, merge, or backport. The task-owned containers, Podman storage, scratch worktree, and staged spec were removed after collection. |
Co-authored-by: RomneyDa <[email protected]>
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Drop the early sessions_history refusal: the shared session access check already denies cross-agent targets for agent-only runs, and the early check could refuse a run's own "current" session under a fixed session store. Keep non-scribe list and session-id parsing identical to main. Co-authored-by: RomneyDa <[email protected]>
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
* fix(knowledge): scope conversation learning to its agent Co-authored-by: RomneyDa <[email protected]> * fix(knowledge): scope conversation learning to its agent Worked on by: - @RomneyDa Co-authored-by: RomneyDa <[email protected]> OpenClaw-Publication: f4ee47f-60ff-4553-a51c-ea272fa46a6c * docs(knowledge): cite the incident for agent-only learning rules Co-authored-by: RomneyDa <[email protected]> * fix(knowledge): keep one agent-scope refusal for history reads Drop the early sessions_history refusal: the shared session access check already denies cross-agent targets for agent-only runs, and the early check could refuse a run's own "current" session under a fixed session store. Keep non-scribe list and session-id parsing identical to main. Co-authored-by: RomneyDa <[email protected]> --------- Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit 0780dd6) Release adaptation: keep the branch message-tool predicate and sessions_list supportsActiveOnly option; thread the upstream conversation-scribe read ceiling through the existing list/history/search and Cron dispatch paths. Extract that lookup wiring into one factory to bring the file under the existing lint cap. Co-authored-by: vincentkoc <[email protected]> Co-authored-by: RomneyDa <[email protected]>
* fix(knowledge): scope conversation learning to its agent Co-authored-by: RomneyDa <[email protected]> * fix(knowledge): scope conversation learning to its agent Worked on by: - @RomneyDa Co-authored-by: RomneyDa <[email protected]> OpenClaw-Publication: f4ee47f-60ff-4553-a51c-ea272fa46a6c * docs(knowledge): cite the incident for agent-only learning rules Co-authored-by: RomneyDa <[email protected]> * fix(knowledge): keep one agent-scope refusal for history reads Drop the early sessions_history refusal: the shared session access check already denies cross-agent targets for agent-only runs, and the early check could refuse a run's own "current" session under a fixed session store. Keep non-scribe list and session-id parsing identical to main. Co-authored-by: RomneyDa <[email protected]> --------- Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit 0780dd6) Co-authored-by: RomneyDa <[email protected]> Co-authored-by: vincentkoc <[email protected]>
…5665) * fix(knowledge): scope conversation learning to its agent Co-authored-by: RomneyDa <[email protected]> * fix(knowledge): scope conversation learning to its agent Worked on by: - @RomneyDa Co-authored-by: RomneyDa <[email protected]> OpenClaw-Publication: f4ee47f-60ff-4553-a51c-ea272fa46a6c * docs(knowledge): cite the incident for agent-only learning rules Co-authored-by: RomneyDa <[email protected]> * fix(knowledge): keep one agent-scope refusal for history reads Drop the early sessions_history refusal: the shared session access check already denies cross-agent targets for agent-only runs, and the early check could refuse a run's own "current" session under a fixed session store. Keep non-scribe list and session-id parsing identical to main. Co-authored-by: RomneyDa <[email protected]> --------- Co-authored-by: RomneyDa <[email protected]>
Problem
The Knowledge conversation-learning scribe could read transcripts outside the agent that runs it when ordinary session visibility is broad. Ref: #205581.
Fix
For Run once and ongoing conversation learning, cap session listing and history reads at the owning agent, without widening stricter visibility. The scribe uses these bounded tools rather than transcript search. Checkpoints remain progress cursors: an old entry is not permission to read a session that is absent from this run’s list.
The cap is switched on only for:
declarationKeyis exactlyknowledge:scribe:conversations, orknowledge:scribe:conversations:<this run's own session key>:(the Scribes page start request).A caller-chosen run ID can only narrow tools. Every other run keeps today's session-tool behavior.
No schema or data migration is needed. Existing checkpoints, claims, and evidence are left unchanged. The docs explain how a vault owner can review historical claims and citations.
Error surfaces
Full diff against merge-base
3fa253a2dc68. This PR adds no throws, exits, rollback triggers, or turn/update failures, and does not touch update, Doctor, migration, config validation, or startup paths. The only new failures are tool results returned to the model inside an agent-only scribe run.invocation_agent_scope_restricted(forbidden, "This run can read only its own agent's sessions.") fromsessions_historyon another agent's key, via the shared session-access checksessions_listin a scribe run:agentIdclamped to the run's agent, other agents' rows filtered,visibility.restricted: truesessions_historywith a bare session ID in a scribe run resolves only inside the run's agent, so other agents' IDs return the existing "Session not found"sessions_searchin a scribe run returnsforbidden("Use sessions_list and sessions_history for this agent-scoped run.")Earlysessions_historyrefusal ("…only its own agent's session history.")currentsession whenagents.defaults.sessionStore.agentIdpins a different agent9a23272. The shared access check above already covers it.sessions_listvisibility checker switched to the core decision checker.allowedis read, and requester derivation matches main9a23272dropped an explicitrequesterAgentIdthat could have changed ordinary list results.Accepted edge: a fixed shared session store (
agents.defaults.sessionStore.agentId) attributes legacy, non-agent-qualified rows to that store's agent. In a scribe run for a different agent, those rows count as cross-agent and are skipped. The run fails closed and visibly, and nothing outside scribe runs changes.Evidence
End-to-end on exact head
9a23272911d93ee98cfa5534c76f8b1f37c5b44c, before = merge-base3fa253a2dc68. Each side ran a real in-process Gateway with its own HOME, state, config, and loopback port, inside the repository's isolated Vitest adapter. That ran in private rootless Podman (network=none) with task-owned storage and runtime dirs, not the default store or the live Gateway. Config had agentsmain,alpha, andbetaand the defaulttools.sessions.visibility. Sessions were seeded withchat.send. A deterministic loopback model issued the tool calls.3fa253a29a23272sessions_list/ withagentId: alphaforbidden/ not found /forbiddensessions_searchforbiddencurrentdeclarationKey: knowledge:scribe:conversations,cron.runforce): list / listagentId: alpha/ alpha key / checkpoint alpha key / own beta1 /currentforbidden/forbidden/ readable / readableagentId: alpha, alpha history by key and by ID,sessions_search,currentcron.runforce): listagentId: alpha, alpha historyokResult: after, 2/2 passed (exit 0, 311 s wall including the in-container build; tests 38.6 s). Before failed on the scribe rows (alpha listed and read). A second before run used
expect.softon the two scribe tables, the only spec difference, so the control rows could run on main. They passed and match the after rows. Imagemcr.microsoft.com/playwright:v1.64.1-noble=sha256:a0d7b2b49ffa…; Node v26.12.1, pnpm 12.15.0, Vitest 5.0.5. The scratch spec (sha2567d4409a6aa77…) was staged only and not committed.Gaps:
learning.mdtext. The refusal is enforced at the tool either way.release/2026.11.11by source inspection. No release changes were made.Review requested from @jalehman and @openclaw/openclaw-secops. Keep CODEOWNERS and security review gates in place.
Worked on by