Repository navigation
Description
Summary
Add /dewey-distill — a slash command that runs the knowledge pipeline (lint → compile → curate → promote) through the running MCP server, with synthesis executed server-side by a new configurable OpenAI-compatible synthesizer. Includes the server changes that make it possible: synthesizer wiring for the compile/curate tool handlers, mutex unification for compile, and a batch parameter for promote.
Chosen provider instance (user decision): the enmaas provider — OpenAI-compatible API at https://api.enmaas.devshift.net/v1, model rits/zai-org/glm-5-3. The API key must come from environment (DEWEY_SYNTHESIS_API_KEY) or synthesis.api_key in config.yaml — never committed, never logged.
Outcome (the goal — implementation may adapt)
An agent or human can, while the MCP server is running:
- See current knowledge state (lint findings, learning inventory, compiled articles).
- Turn draft learnings into compiled articles and curated knowledge-store content — synthesis performed by the configured provider inside the server, no CLI round-trip, no server restart.
- Review drafts at a human gate (promotion is human validation per the trust-tier model), then promote validated knowledge (learnings and/or compiled articles) to
validatedtier in one batched call.
With graceful fallback: when synthesis is unconfigured or unavailable, behavior is byte-compatible with today's prompt-mode flows (the calling agent synthesizes per cluster and calls store_compiled). If a better design than the one below achieves these outcomes, use it.
Background — verified facts
- The running server owns the store. Exclusive
Flock(LOCK_EX|LOCK_NB)on.uf/dewey/dewey.lockheld for server lifetime (store/store.go:105-120) →dewey compile/curate/lint/promote/doctor/status/indexCLI commands all fail beside it ("another Dewey process is using this database"). The pipeline therefore must go through MCP tools. - MCP
compile/curatecurrently pass nil synthesizers (server.go:130,server.go:136) and return prompt-mode payloads (status: "prompts_ready"/"prompt_ready") expecting the calling agent to synthesize. The status fields already distinguish modes — a synthesizer-injected path returning"compiled"/"complete"is backward compatible. - The server already knows how to build a synthesizer:
backgroundCuration(main.go:797-861, esp. 823-838) doesReadSynthesisConfig→NewSynthesizerFromConfig→Available()check → graceful skip. Reuse the pattern at startup. compilehas a private mutex (tools/compile.go:58) that is not the shared index mutex —curatecorrectly sharescfg.indexMutex(tools/curate.go:76-79). Once compile writes synthesized output this becomes a real concurrency gap; unify.promotetakes a singlepageand only maps draft → validated (tools/promote.go:35-76). Promotingcompiled/{tag}pages currently fails at page lookup — tracked in bug: dewey_promote MCP tool fails with 'Page not found' for compiled articles #91 (umbrella bug: MCP tools cannot access internal store pages (learnings, compiled articles) #90). This issue's batch-promote work must sequence with (or subsume) that fix.- Synthesizer surface (
llm/): interfaceSynthesize(ctx, prompt) (string, error),Available() bool,ModelID() string; existing implementationsOllamaSynthesizer,VertexSynthesizer(429 retry/backoff),NoopSynthesizer(test double); factoryNewSynthesizerFromConfig. - Prior synthesizer regressions to learn from: bug: curation fails with 'unexpected end of JSON input' — VertexSynthesizer MaxTokens hardcoded at 4096 #76 (hardcoded MaxTokens 4096 truncated curation output), bug: VertexSynthesizer HTTP timeout (120s) too short for large curation prompts #77 (120s timeout too short for large prompts). The new provider needs configurable/adequate output limits and timeouts.
- CLI parity note: when the server is NOT running,
dewey compile/dewey curateCLI still build their own synthesizer from config (cli.go:2132-2135,cli.go:2267-2272) — don't break that.
Current implementation direction (adaptable)
llm/ — OpenAI-compatible synthesizer
New Synthesizer implementation speaking an OpenAI-compatible chat-completions API: endpoint, model, api key (env/config), timeouts and retry consistent with Vertex's 429 handling. NewSynthesizerFromConfig gains the branch — exact synthesis.provider naming is the implementer's choice (e.g. openai-compatible with endpoint/model/api_key); document in README and AGENTS.md. dewey doctor's synthesis section validates the new provider's config.
Server wiring
Build the synthesizer at startup (backgroundCuration pattern); pass to compile and curate handlers when configured and Available(), else nil → prompt-mode. Join compile onto the shared index mutex (parity with curate).
promote batch
Add optional pages []string (keep page for single-shot compatibility — DE-005: avoid N-call agent loops). Batch failures fail closed with per-page errors. Coordinate with #91 so compiled/{tag} pages resolve (either fix here or explicitly sequence after it).
/dewey-distill command (.opencode/commands/dewey-distill.md, added to slash_commands.go)
- MCP
lint→ present findings (stale decisions, uncompiled learnings) - Inventory via MCP
list_pages(namespaceslearning/,compiled/) - GATE: what to compile, which stores to curate
- MCP
compile/curate— server-side synthesis when configured; if prompt-mode returns, the agent synthesizes per cluster and callsstore_compiled - GATE (human): review draft articles + stale decisions — promotion is human validation per the trust-tier model
- MCP
promote(batch) - Report + suggest
/dewey-publish(companion issue) to preserve the results
Acceptance criteria
- With synthesis configured + available: MCP
compilereturnsstatus: "compiled"and writes.uf/dewey/compiled/{tag}.md; MCPcuratereturnsstatus: "complete"— no CLI process, no server restart. - Without synthesis: responses byte-compatible with today's prompt-mode (backward compat).
promoteaccepts a batch;learning/{identity}pages promote draft→validated;compiled/{tag}promotes (with bug: dewey_promote MCP tool fails with 'Page not found' for compiled articles #91 resolved or explicitly sequenced).compileandcuraterace-safe against concurrentindex(shared mutex; demonstrated under-race).- API key never appears in logs, errors, or committed files; gitleaks-clean.
- All 37 inherited graphthulhu MCP tools behave identically (regression suite green).
- DE-007 seam tasks in tasks.md: registration surfaces (server.go tool registration, llm factory, slash_commands.go), documented output shapes (
compiledvsprompts_ready), round-trips (compile→promote→tier check; curate→knowledge source indexed). - CI parity per AGENTS.md; review-council APPROVE before PR; README/AGENTS.md/GoDoc updated; website-sync issue filed per AGENTS.md (
gh issue create --repo unbound-force/website).
Constraints
- Packaging decision: single OpenSpec change together with the
/dewey-publishissue (filed separately) and feat: /dewey-configure slash command to configure sources.yaml #122 — adaptable. - No CGO; pure-Go HTTP only. Cloud providers remain opt-in via config (consistent with the Vertex precedent); local-only default preserved.
- Do not change the
Synthesizerinterface contract for existing implementations.
Out of scope
- enmaas/OpenAI-compatible embeddings (embedding provider stays Ollama/Vertex)
- New lint checks or curate scheduling changes
/dewey-configure(see feat: /dewey-configure slash command to configure sources.yaml #122)
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsNo status
Activity
feat: distill knowledge through the running MCP server
docs(openspec): add dewey-distill change for issue unbound-force#133
feat: distill knowledge through the running MCP server
docs(openspec): add dewey-distill change for issue unbound-force#133
docs(openspec): add dewey-distill change for issue unbound-force#133
feat: distill knowledge through the running MCP server
feat: distill knowledge through the running MCP server
docs(openspec): add dewey-distill change for issue #133
feat: distill knowledge through the running MCP server
feat: distill knowledge through the running MCP server