Skip to content

refactor(learn): make /learn contributions a generic plugin seam - #191665

Merged
obviyus merged 2 commits into
mainfrom
seam/learn-contributions
Nov 3, 2026
Merged

obviyus merged 2 commits into
mainfrom
seam/learn-contributions

Conversation

@obviyus

@obviyus obviyus commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

/learn combined two hard-wired writers. Skill Workshop's prompt text and its drafts and undo subcommands lived inside the core command. The memory provider joined through memory-only fields on the memory capability (learnToolNames, learnGuidanceBuilder, read by getMemoryLearnContribution). Because of this, Skill Workshop cannot move into a bundled plugin, and no plugin other than the memory slot owner can add to /learn.

User Impact

None intended. /learn, /learn drafts and /learn undo <id> give the same prompts and replies as before. The prompt for the current setup (Skill Workshop plus the Knowledge memory provider) is byte-identical. Unavailable replies, owner checks and the operator.admin check for undo do not change.

Why This Change Was Made

  • Adds one generic registration: api.registerLearnContribution(contribution). A contribution declares:
    • medium ("skills" or "memory")
    • toolNames, plus optional requiredToolNames
    • buildGuidance({ availableTools, media }), which returns { lines, appendix? }
    • optional subcommands (name, matchArgs?, direct?, handle)
  • /learn stays a reserved core command and becomes a small dispatcher:
    • It checks each contribution's tools against the turn's tool policy.
    • It owns the prompt frame and the routing rule between media.
    • It orders contributions by medium, then plugin id, so prompt bytes stay stable.
    • It runs subcommands. A direct subcommand gets the owner gate and the gateway operator.admin check, and runs without a model turn. Other subcommands run only while their contribution can learn.
  • Skill Workshop is now a contributor through the same path (src/skills/workshop/learn-contribution.ts). Its guidance, its draft-review prompt and its undo handling moved there unchanged. The later plugin move only needs to call registerLearnContribution.
  • Memory moved onto the generic seam completely. The memory-only capability fields and the accessor are removed. These fields never shipped in a tagged release, so no compatibility alias is kept. Only the selected memory slot owner can register a "memory" contribution; the registrar enforces this, as it did for the old fields.
  • Knowledge now declares its required write tools as requiredToolNames. Before, its builder returned [] when those tools were missing. This keeps the "which media take part" decision in the host, before any builder runs.

Evidence

  • Byte identity: a temporary harness ran the base commands-learn.ts (origin/main) and the new one side by side on 272 cases. It covered 17 command forms:

    • /learn with and without a request
    • drafts with no arguments, a skill and focus, drafts:, drafts;, drafts, and Drafts:
    • exact and uppercase undo <id>
    • undo: <id>, undo, <id>, undo; <id>, undo:<id>, undo <id> extra, bare undo, and undo not-a-uuid

    Each form ran under 4 tool policies, with and without a memory contribution, and as owner and non-owner, plus the undo scope replies. All 273 checks matched exactly, including whether undo ran. A committed test pins the full skills-plus-memory prompt.

  • Punctuated undo text stays a learning request: subcommand matchers see the raw remainder with its separator, so only whitespace-separated undo <id> undoes, while drafts keeps its punctuation forms. The Workshop contract pin now also covers undo: <id>, undo, <id> and undo; <id>.

  • Workshop contract pins (6 files, 68 tests, including the 3 new undo cases): passed.

  • commands-learn.test.ts (14), registry.dual-kind-memory-gate.test.ts (5, including memory-owner gating), Knowledge learn-guidance.test.ts: passed. Plugin command, registry and memory-state tests (23 files, 300 tests): passed.

  • gateway-workshop-learning.e2e.test.ts: passed.

  • tsgo:core, tsgo:core:test, tsgo:extensions, type-aware oxlint on the changed files, oxfmt, plugin-sdk:check-exports: clean.

  • check:baseline-ratchets: all ok. The test-lines net delta is −5, because /learn unit tests that duplicated the Workshop contract pins were removed.

  • plugin-sdk:api:diff against the parent commit adds only the registerLearnContribution method and its Learn* types. It removes learnToolNames, learnGuidanceBuilder and MemoryLearnGuidanceBuilder, which no tagged release contains (checked through v2026.10.10).

@clawsweeper

clawsweeper Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation plugin: knowledge size: L labels Nov 3, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Nov 3, 2026
@clawsweeper

clawsweeper Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR moves Workshop and memory learning guidance behind a shared plugin registration API while preserving existing /learn behavior.

Example: A plugin registers a notes subcommand, then the user sends /learn Notes: last week.

  • Before: The text becomes an ordinary learning request.
  • After: The plugin can supply a review prompt when its required tools are allowed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch is coherent and supported by reported command-boundary harness coverage, with no remaining finding; shipped-entry-point evidence for the changed dispatcher was not supplied.
Proof confidence 🦐 gold shrimp (3/6) This collaborator-authored refactor is outside the ordinary contributor proof gate; reported command-contract runs exercise prompt routing and persisted undo, while the inspected screenshots show historical Learned-row behavior rather than this change.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Refactor · Worth it: Yes · Fix scope: Complete
User problem: Learning destinations and Workshop subcommands are coupled to core, preventing plugins from contributing through a shared contract.
Reason: The maintainer-authored direction follows the small-core/plugin boundary and migrates both existing consumers without changing configuration or stored formats.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored refactor provides a useful plugin seam, fixes the earlier undo regression, and has no remaining actionable correctness finding.

Priority: P2
Reviewed head: fc7a90bcd0979670cc244ddcf3f6fff8a0e18822

Before merge

None.

Findings

None.

Agent review details

How this fits together

The core chat-command dispatcher combines registered learning guidance with the current tool policy, then produces an agent prompt or executes an authorized direct subcommand.

flowchart TD
  Chat[Chat command] --> Dispatcher[Core learn dispatcher]
  Registry[Workshop and plugin contributions] --> Dispatcher
  Policy[Turn tool policy] --> Dispatcher
  Dispatcher --> Prompt[Learning prompt]
  Prompt --> Tools[Normal agent tools]
  Dispatcher --> Undo[Existing Workshop undo owner]
Loading

Technical review

Best possible solution:

Retain one core dispatcher and contribution contract, with Workshop and Knowledge owning their guidance and the existing mutation owners retaining authority checks.

Do we have a high-confidence way to reproduce the issue?

This is an architectural refactor; source inspection confirms the existing coupling and the corrected undo parser, but no runtime reproduction was performed.

Is this the best way to solve the issue?

The shared registry and existing command gates provide a focused cutover, and the removed memory-specific path has no remaining source references.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 79b3cd528228.

Provenance checked

  • Workshop guidance, drafts and undo keeps the original intent (feat(skills): Learned notice row with one-press Undo #167996: Provide one undo owner and preserve owner/admin authorization; later draft-review and shared-learning-method changes added the guidance being relocated.)
  • Memory learning contribution changes intended behavior with a stated reason (f8d9d25: Let the selected memory provider contribute guidance under the turn's tool policy.)
  • Knowledge required tools keeps the original intent (65ad180: Suppress learning guidance without the tools needed to create linked pages and claims.)
  • Plugin callback lifecycle keeps the original intent (05a2844: Keep registered callbacks and accepted work attached to their supplying plugin instance through retirement.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Ayaan Zaidi: Raw commit 60bee20 adds src/auto-reply/reply/commands.workshop-contract.test.ts:24 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 60bee201456b; files: src/auto-reply/reply/commands.workshop-contract.test.ts)
  • Josh Lehman: Raw commit f8d9d25 adds src/auto-reply/reply/commands-learn.ts:42 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: f8d9d253e1c4; files: src/auto-reply/reply/commands-learn.ts)
  • Peter Steinberger: Raw commit 9e0064b adds src/auto-reply/reply/commands-learn.ts:37 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 9e0064bd7d90; files: src/auto-reply/reply/commands-learn.ts)

PR surface

Source +145, Tests -5, Docs +14. Total +154 across 18 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 12 355 210 +145
Tests 4 114 119 -5
Docs 2 21 7 +14
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 18 490 336 +154

Labels

Label changes:

  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This is a normal-priority plugin extensibility improvement without a reported current outage.
  • merge-risk: 🚨 compatibility: The public plugin API changes; the maintainer-authored PR explicitly accepts replacing the unshipped memory fields, which are absent from the inspected latest stable contract.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-11-03T04:31:42.196Z sha dcb9c8d :: needs changes before merge. :: [P2] [P2] Preserve the whitespace-only separator for direct undo

Reviewed November 2, 2026, 11:59 PM ET / November 3, 2026, 04:59 UTC (Revision 2).

Subcommand matchers now see the raw remainder with its separator, so only
whitespace-separated 'undo <id>' undoes while drafts keeps its punctuation
forms. Drop /learn tests that duplicated the Workshop contract pins.
@obviyus
obviyus force-pushed the seam/learn-contributions branch from dcb9c8d to fc7a90b Compare November 3, 2026 04:52
@obviyus

obviyus commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Nov 3, 2026
@obviyus
obviyus merged commit a5eb424 into main Nov 3, 2026
165 of 166 checks passed
@obviyus
obviyus deleted the seam/learn-contributions branch November 3, 2026 05:11
@obviyus

obviyus commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator Author

Landed as a5eb424. /learn stays a core command, and plugins add to it with api.registerLearnContribution (tool names, guidance, optional subcommands). Memory and core Workshop use the same path. Proof: today's memory+Workshop /learn prompt is byte-identical (273 side-by-side checks, including punctuated undo forms staying learning requests), the Workshop contract pins, plugin registry suites and the gateway-workshop-learning e2e.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 4, 2026
…nclaw#191665)

## What Problem This Solves

`/learn` combined two hard-wired writers. Skill Workshop's prompt text and its `drafts` and `undo` subcommands lived inside the core command. The memory provider joined through memory-only fields on the memory capability (`learnToolNames`, `learnGuidanceBuilder`, read by `getMemoryLearnContribution`). Because of this, Skill Workshop cannot move into a bundled plugin, and no plugin other than the memory slot owner can add to `/learn`.

## User Impact

None intended. `/learn`, `/learn drafts` and `/learn undo <id>` give the same prompts and replies as before. The prompt for the current setup (Skill Workshop plus the Knowledge memory provider) is byte-identical. Unavailable replies, owner checks and the `operator.admin` check for undo do not change.

## Why This Change Was Made

- Adds one generic registration: `api.registerLearnContribution(contribution)`. A contribution declares:
  - `medium` (`"skills"` or `"memory"`)
  - `toolNames`, plus optional `requiredToolNames`
  - `buildGuidance({ availableTools, media })`, which returns `{ lines, appendix? }`
  - optional `subcommands` (`name`, `matchArgs?`, `direct?`, `handle`)
- `/learn` stays a reserved core command and becomes a small dispatcher:
  - It checks each contribution's tools against the turn's tool policy.
  - It owns the prompt frame and the routing rule between media.
  - It orders contributions by medium, then plugin id, so prompt bytes stay stable.
  - It runs subcommands. A `direct` subcommand gets the owner gate and the gateway `operator.admin` check, and runs without a model turn. Other subcommands run only while their contribution can learn.
- Skill Workshop is now a contributor through the same path (`src/skills/workshop/learn-contribution.ts`). Its guidance, its draft-review prompt and its undo handling moved there unchanged. The later plugin move only needs to call `registerLearnContribution`.
- Memory moved onto the generic seam completely. The memory-only capability fields and the accessor are removed. These fields never shipped in a tagged release, so no compatibility alias is kept. Only the selected memory slot owner can register a `"memory"` contribution; the registrar enforces this, as it did for the old fields.
- Knowledge now declares its required write tools as `requiredToolNames`. Before, its builder returned `[]` when those tools were missing. This keeps the "which media take part" decision in the host, before any builder runs.

## Evidence

- Byte identity: a temporary harness ran the base `commands-learn.ts` (origin/main) and the new one side by side on 272 cases. It covered 17 command forms:
  - `/learn` with and without a request
  - `drafts` with no arguments, a skill and focus, `drafts:`, `drafts;`, `drafts,` and `Drafts:`
  - exact and uppercase `undo <id>`
  - `undo: <id>`, `undo, <id>`, `undo; <id>`, `undo:<id>`, `undo <id> extra`, bare `undo`, and `undo not-a-uuid`

  Each form ran under 4 tool policies, with and without a memory contribution, and as owner and non-owner, plus the undo scope replies. All 273 checks matched exactly, including whether undo ran. A committed test pins the full skills-plus-memory prompt.
- Punctuated `undo` text stays a learning request: subcommand matchers see the raw remainder with its separator, so only whitespace-separated `undo <id>` undoes, while `drafts` keeps its punctuation forms. The Workshop contract pin now also covers `undo: <id>`, `undo, <id>` and `undo; <id>`.
- Workshop contract pins (6 files, 68 tests, including the 3 new undo cases): passed.
- `commands-learn.test.ts` (14), `registry.dual-kind-memory-gate.test.ts` (5, including memory-owner gating), Knowledge `learn-guidance.test.ts`: passed. Plugin command, registry and memory-state tests (23 files, 300 tests): passed.
- `gateway-workshop-learning.e2e.test.ts`: passed.
- `tsgo:core`, `tsgo:core:test`, `tsgo:extensions`, type-aware `oxlint` on the changed files, `oxfmt`, `plugin-sdk:check-exports`: clean.
- `check:baseline-ratchets`: all ok. The test-lines net delta is −5, because `/learn` unit tests that duplicated the Workshop contract pins were removed.
- `plugin-sdk:api:diff` against the parent commit adds only the `registerLearnContribution` method and its `Learn*` types. It removes `learnToolNames`, `learnGuidanceBuilder` and `MemoryLearnGuidanceBuilder`, which no tagged release contains (checked through v2026.10.10).

Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. plugin: knowledge rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant