feat(kb): maintainer raw-inbox drain (SP-4) — Phase 4c#26
Merged
Conversation
Conservative create/update/never-auto-discard drain of the raw inbox into wiki nodes, modeled on Phase 4b (explicit-only, 50/run cap, no invented content). Bidirectional provenance (node ## Sources line + raw target_node back-ref). SP-2 CLI gains pending + process; new markProcessed in raw-inbox.ts. No server/schema change. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…k-ref (SP-4 Task 1) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- High: grant Bash(node *) to the maintainer agent — Phase 4c (and pre-existing Phase 4b) shell out to node CLIs; without the grant the process call would prompt/deny, leaving items unprocessed → re-drained → duplicate nodes. - pending now tab-sanitizes target_node (fmValue strips CR/LF, not tabs) so a tab can't shift the TSV columns and corrupt the work-list. - Strengthen the agent guard: tightened the '## Sources' grep (was satisfied by the pre-existing '### Sources' ENRICH heading), pinned 'process <id> --node <slug>', and assert the Bash(node *) grant. New tests for markProcessed's update-branch (no duplicate target_node) and the TSV tab-safety. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…n row Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds SP-4 Phase 4c “raw-inbox drain” support to close the SP-2 → SP-3 → SP-4 pipeline: the knowledge-maintainer agent can now turn unprocessed raw-inbox captures into wiki nodes via a deterministic CLI work-list + a processed/back-ref transition, with explicit-only execution and provenance.
Changes:
- Introduces
raw-capture-cli pending(TSV work-list) andraw-capture-cli process(mark item processed + optionaltarget_nodeback-ref). - Adds
markProcessed()plumbing toraw-inbox(atomic rewrite) with new vitest + bash e2e coverage. - Wires Phase 4c into
knowledge-maintainerprompt, bumps plugin version to0.24.13, and adds an upgrade/migration row + design/plan docs.
Reviewed changes
Copilot reviewed 11 out of 20 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test-raw-capture.sh | Adds e2e coverage for pending TSV output, process transition, and tab-sanitization. |
| tests/test-maintainer-raw-drain.sh | Adds a structural guard ensuring the maintainer prompt includes Phase 4c behavior and tool grants. |
| skills/upgrade/SKILL.md | Adds 0.24.13 migration row documenting the Phase 4c feature and operational notes. |
| mcp/src/tools/raw-inbox.ts | Adds markProcessed() to flip status → processed and optionally update/insert target_node. |
| mcp/src/tools/raw-inbox.test.ts | Adds vitest coverage for markProcessed() (status flip, back-ref, unsafe id, no-duplicate target_node). |
| mcp/src/tools/raw-capture-cli.ts | Adds pending and process CLI actions; sanitizes TSV cells to keep output machine-safe. |
| mcp/dist/tools/raw-inbox.test.js.map | Updates built artifact map for new markProcessed tests. |
| mcp/dist/tools/raw-inbox.test.js | Updates built artifact for new markProcessed tests. |
| mcp/dist/tools/raw-inbox.js.map | Updates built artifact map for markProcessed implementation. |
| mcp/dist/tools/raw-inbox.js | Updates built artifact for markProcessed implementation. |
| mcp/dist/tools/raw-inbox.d.ts.map | Updates built type map for new markProcessed export. |
| mcp/dist/tools/raw-inbox.d.ts | Updates built types to include markProcessed signature. |
| mcp/dist/tools/raw-capture-cli.js.map | Updates built artifact map for new CLI actions. |
| mcp/dist/tools/raw-capture-cli.js | Updates built artifact for new CLI actions. |
| mcp/dist/tools/raw-capture-cli.bundle.js | Updates bundled CLI used by skills/agents to include pending/process and markProcessed. |
| docs/specs/2026-06-04-maintainer-raw-drain-design.md | Adds the Phase 4c design spec (goals, contract, boundary, provenance). |
| docs/plans/2026-06-04-maintainer-raw-drain.md | Adds implementation plan and TDD steps for SP-4 Phase 4c. |
| agents/knowledge-maintainer.md | Grants Bash(node *), adds Phase 4c instructions, and updates the auto-dispatch exception to skip 4b/4c. |
| .claude-plugin/plugin.json | Bumps plugin version 0.24.12 → 0.24.13. |
| .claude-plugin/marketplace.json | Bumps marketplace version 0.24.12 → 0.24.13. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+168
to
+170
| let next = /^status:[ \t]*.*$/m.test(content) | ||
| ? content.replace(/^status:[ \t]*.*$/m, 'status: processed') | ||
| : content.replace(/^---\r?\n/, '---\nstatus: processed\n'); |
| run process "$PID" --node my-node | grep -q "Processed $PID" || fail "process did not report" | ||
| grep -q '^status: processed$' "$RAW/$PID.md" || fail "status not flipped to processed" | ||
| grep -q '^target_node: my-node$' "$RAW/$PID.md" || fail "target_node back-ref not set" | ||
| [ -z "$(run pending | grep "$PID" || true)" ] || fail "processed item still appears in pending" |
Comment on lines
+293
to
+295
| - **Decide the target node:** | ||
| - `target_node` non-empty → **update** that wiki page (`Read` it in full first). | ||
| - else `knowledge_search` the gist / key terms → a top hit that is a *strong, same-topic* match → |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SP-4 — Maintainer Raw-Inbox Drain (Phase 4c)
Closes the SP-2 → SP-3 → SP-4 pipeline: the
knowledge-maintaineragent now turns unprocessed raw-inbox items (from/second-brain:capture+ setup deep-scan) into wiki nodes. Spec:docs/specs/2026-06-04-maintainer-raw-drain-design.md.What it does
raw-capture-cli pending) → author per item →knowledge_validateself-check → shared 50/run cap → explicit-invocation only (auto-dispatched runs skip it).target_nodeset → update it; else strongknowledge_searchmatch → update; else create a typed node (8 categories, authored only from the material — never invented). Never auto-discards — low-value items left unprocessed and reported for manual prune. Node gets a## Sourcesline; the raw item is markedprocessedwith atarget_nodeback-ref (kept as the audit trail).markProcessed(raw-inbox.ts, reuses the SP-2isSafeId/fmValueguards) +raw-capture-cli pending(TSV) andprocess <id> --node <slug>.Deep-review gate (findings fixed before merge)
Bash(node *)— Phase 4c and pre-existing Phase 4b shell out to node CLIs; without the grant theprocesscall would prompt/deny → items stay unprocessed → re-drained duplicate nodes. Fixes a latent 4b gap too.pendingnow tab-sanitizestarget_node(fmValuestrips CR/LF, not tabs) so a tab can't shift the TSV columns.## Sourcesgrep matched the pre-existing### SourcesENRICH heading). Added tests formarkProcessed's update-branch (no duplicatetarget_node) + the TSV tab-safety.Notes
processedalready valid; the 8 categories already exist; server stays 2.6.4).Plugin 0.24.12 → 0.24.13 + migration row.
🤖 Generated with Claude Code