Repository navigation
refactor(learn): make /learn contributions a generic plugin seam - #191665
Conversation
|
🦞👀 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 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.
Review scores
ProductKind: Refactor · Worth it: Yes · Fix scope: Complete 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 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe 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]
Technical reviewBest 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
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +145, Tests -5, Docs +14. Total +154 across 18 files. Added test files: 0. View PR surface stats
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 (1 earlier review cycle)
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.
dcb9c8d to
fc7a90b
Compare
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Landed as a5eb424. |
…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]>
What Problem This Solves
/learncombined two hard-wired writers. Skill Workshop's prompt text and itsdraftsandundosubcommands lived inside the core command. The memory provider joined through memory-only fields on the memory capability (learnToolNames,learnGuidanceBuilder, read bygetMemoryLearnContribution). 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 draftsand/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 theoperator.admincheck for undo do not change.Why This Change Was Made
api.registerLearnContribution(contribution). A contribution declares:medium("skills"or"memory")toolNames, plus optionalrequiredToolNamesbuildGuidance({ availableTools, media }), which returns{ lines, appendix? }subcommands(name,matchArgs?,direct?,handle)/learnstays a reserved core command and becomes a small dispatcher:directsubcommand gets the owner gate and the gatewayoperator.admincheck, and runs without a model turn. Other subcommands run only while their contribution can learn.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 callregisterLearnContribution."memory"contribution; the registrar enforces this, as it did for the old fields.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:/learnwith and without a requestdraftswith no arguments, a skill and focus,drafts:,drafts;,drafts,andDrafts:undo <id>undo: <id>,undo, <id>,undo; <id>,undo:<id>,undo <id> extra, bareundo, andundo not-a-uuidEach 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
undotext stays a learning request: subcommand matchers see the raw remainder with its separator, so only whitespace-separatedundo <id>undoes, whiledraftskeeps its punctuation forms. The Workshop contract pin now also coversundo: <id>,undo, <id>andundo; <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), Knowledgelearn-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-awareoxlinton the changed files,oxfmt,plugin-sdk:check-exports: clean.check:baseline-ratchets: all ok. The test-lines net delta is −5, because/learnunit tests that duplicated the Workshop contract pins were removed.plugin-sdk:api:diffagainst the parent commit adds only theregisterLearnContributionmethod and itsLearn*types. It removeslearnToolNames,learnGuidanceBuilderandMemoryLearnGuidanceBuilder, which no tagged release contains (checked through v2026.10.10).