capsule-engine
name: capsule-engine description: 知识胶囊引擎:把真实证据、用户反馈、成功案例、失败原因、修复方案和架构决策整理为有范围、有状态、可追溯的复用知识。用于经验沉淀、知识治理和工作流迭代。 veRSIon: 1.0.0
Capsule Engine
Bottom-Layer Reasoning
APPly think-one-step-further before writing or promoting a capsule:
Separate observed evidence from inference.
Bind the rule to conditions and fAIlure boundaries.
Decide whether it belongs in mEMOry, a capsule, a Skill, or all three.
Avoid creating duplicate rules or fake precision.
Core Intent
Turn evidence into durable capabilities without turning memory into a diary. Use one SQLite database as the single source of truth:
D:\SophiaMemory\data\sophia_memory.sqlite
The capsule tables coexist with Sophia's existing memory tables. Do not create a SECond runtime copy.
Knowledge Layers
Keep these distinct:
Spore: one new observation, correction, tradeoff, fix, or hypothesis.
Case card: one concrete experiment with inputs, ouTPUt, result, and Prompt/workflow delta.
Capsule: a minimal reusable rule with evidence, scope, boundaries, and validation history.
Skill: an executable workflow that may use many active capsules.
Director/orchestrator: selects and sequences skills for the current task.
Use $creative-casebook before this skill when the evidence comes from a generated result that needs diagnosis. Use $evidence-driven-self-iteration to detect recurring findings and stale areas. A scheduled audit finding is evidence to investigate, not automatic proof for capsule promotion.
Lifecycle
Use:
candidate -> provisional -> validated -> active -> deprecated -> archived
candidate: captured but not independently verified.
provisional: one successful application or useful confirmation.
validated: at least two independent successful contexts and adequate evidence confidence.
active: explicitly approved for routine use or skill propagation.
deprecated: retained for history but replaced, unsafe, or no longer preferred.
archived: no longer part of normal retrieval.
Application is an event, not a status. Record success, failure, neutral result, and counterexample separately.
User-confirmed architecture or operating-policy decisions may be activated without two empirical trials when clearly marked as a policy decision, not an empirical truth.
Metrics
Never compress everything into one confidence number:
evidence_confidence: credibility of the supporting evidence.context_fit: how well the capsule matches its bound scenarios.utility_score: whether applying it helps.freshness: how current the evidence is.stability: how consistently it survives different applications.
Age may lower freshness. It must not automatically make a fact false.
Workflow
Capture a spore or receive a case card.
Search existing capsules for overlap, conflict, or a nARRower existing rule.
Create a candidate capsule only if it changes future behavior.
Record:
what works
when to apply
why it works
failure conditions
bound scenarios
source references
Apply it in real work and record an event with a distinct
context_key.Allow the tool to advance candidate/provisional capsules from independent successful contexts.
Before activation, check conflicts, side effects, target skills, and retrieval tags.
Propagate only the Generalized control into related skills.
Deprecate or narrow the capsule when counterexamples appear.
Read:
references/capsule-architecture.mdfor lifecycle, promotion, synthesis, and conflict rules.references/capsule-schema.mdfor field DeFinitions.
Deterministic Tool
Use scripts/capsule_engine.py.
python scripts/capsule_engine.py init python scripts/capsule_engine.py stats python scripts/capsule_engine.py search "站位" python scripts/capsule_engine.py validate
Create a candidate:
python scripts/capsule_engine.py create ` --name "参考图职责隔离" ` --capsule-class pattern ` --knowledge-kind rule ` --summary "每张参考只承担明确控制职责" ` --what-worked "显式声明身份、布局、风格和材质参考的职责边界" ` --when-to-apply "多参考图或全能参考工作流" ` --why-it-works "减少参考之间争夺身份、构图和风格控制权" ` --failure-conditions "单图工作流或模型不支持多参考职责" ` --scenario "SD2全能参考" ` --tag "reference-role" ` --source-ref "user-confirmed case"
Record evidence:
python scripts/capsule_engine.py record --id CAPSULE_ID --outcome success ` --context-key "sd2-motorcycle-scene" --context "角色+摩托+站位图" ` --result "身份和前后关系保持稳定" --source "generated output inspected"
Activate a validated capsule:
python scripts/capsule_engine.py activate --id CAPSULE_ID ` --target-skill jimeng-sd2-prompting --target-skill character-continuity-bible
Promotion And Propagation
Do not promote because a rule sounds Intelligent.
Promote when:
evidence is inspectable;
the mechanism is stated concretely;
application conditions and failure boundaries exist;
independent successful contexts support it, or it is an explicit user-confirmed architecture policy;
no unresolved conflict makes the rule unsafe;
the target skill benefits from the rule.
When propagating, write the smallest executable control into the target skill and keep full evidence/history in the capsule database.
Synthesis
Combine capsules only when the result removes real duplication or creates a useful higher-order workflow.
Relations:
synergy: strengthens the Same outcome.complement: handles a different layer or scenario.conflict: cannot both apply under the same conditions.tension: preserve both and choose by context.supersedes: newer capsule replaces an older one.derived_from: capsule was synthesized from others.feeds_skill: capsule supplies a skill rule.
Do not assign arbitrary percentage weights. Express contribution through capabilities, conditions, dependencies, and conflicts.
Guardrails
Do not run random learning or heartbeat activity merely to create records.
Scheduled self-audits may inspect and record evidence, but must not create or promote capsules merely because the schedule ran.
Do not create capsules for routine status, compliments, greetings, or one-off wording.
Do not promote a single ambiguous generation into a universal rule.
Do not treat frequency of use as truth.
Do not overwrite evidence history; append events.
Do not store secrets, raw private assets, or unnecessarily identifying project data.
Do not change or delete active capsules silently; deprecate or supersede them with a reason.
Comments & Questions (0)
No comments yet
Be the first to comment!