@dzhechkov/keysarium 1.1.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +10 -2
- package/src/commands/init.js +1 -1
- package/templates/.claude/commands/dream.md +101 -0
- package/templates/.claude/commands/feature-adr.md +92 -0
- package/templates/.claude/commands/init-platform.md +161 -0
- package/templates/.claude/commands/learning-stats.md +130 -0
- package/templates/.claude/commands/workers.md +140 -0
- package/templates/.claude/rules/background-workers.md +72 -0
- package/templates/.claude/rules/dream-cycles.md +90 -0
- package/templates/.claude/rules/feature-adr-conventions.md +82 -0
- package/templates/.claude/rules/reward-learning.md +124 -0
- package/templates/.claude/shards/feature-adr.shard.md +98 -0
- package/templates/.claude/skills/feature-adr/SKILL.md +252 -0
- package/templates/.claude/skills/feature-adr/examples/sample-feature-output.md +257 -0
- package/templates/.claude/skills/feature-adr/modules/00-complexity-router.md +114 -0
- package/templates/.claude/skills/feature-adr/modules/01-requirements.md +113 -0
- package/templates/.claude/skills/feature-adr/modules/02-research.md +92 -0
- package/templates/.claude/skills/feature-adr/modules/03-adr.md +135 -0
- package/templates/.claude/skills/feature-adr/modules/04-ddd.md +114 -0
- package/templates/.claude/skills/feature-adr/modules/05-architecture.md +149 -0
- package/templates/.claude/skills/feature-adr/modules/06-implementation-plan.md +129 -0
- package/templates/.claude/skills/feature-adr/modules/07-code.md +126 -0
- package/templates/.claude/skills/feature-adr/modules/08-qe.md +167 -0
- package/templates/.claude/skills/feature-adr/references/adr-template.md +102 -0
- package/templates/.claude/skills/feature-adr/references/c4-template.md +120 -0
- package/templates/.claude/skills/feature-adr/references/complexity-matrix.md +139 -0
- package/templates/.claude/skills/feature-adr/references/qe-checklist.md +86 -0
- package/templates/CLAUDE.md +124 -3
- package/templates/docs/improvement-directions.md +16 -16
- package/templates/docs/keysarium/01-deployment-guide.md +21 -12
- package/templates/docs/keysarium/02-admin-guide.md +204 -3
- package/templates/docs/keysarium/03-user-guide.md +224 -0
- package/templates/docs/keysarium/05-architecture.md +181 -0
- package/templates/docs/keysarium/06-user-flows.md +235 -0
- package/templates/lib/background-workers.md +278 -0
- package/templates/lib/dream-engine.md +460 -0
- package/templates/lib/judge-attestation.md +322 -0
- package/templates/lib/memory-protocol.md +239 -0
- package/templates/lib/platform-adapters.md +100 -0
- package/templates/lib/platform-templates/copilot.md +134 -0
- package/templates/lib/platform-templates/cursor.md +95 -0
- package/templates/lib/platform-templates/opencode.md +155 -0
- package/templates/lib/reward-tracker.md +256 -0
- package/templates/lib/witness-chain.md +372 -0
- package/templates/lib/worker-templates/brain-export.md +187 -0
- package/templates/lib/worker-templates/consolidate.md +180 -0
- package/templates/lib/worker-templates/dream-cycle.md +154 -0
- package/templates/lib/worker-templates/health-check.md +255 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# Background Workers Rules
|
|
2
|
+
|
|
3
|
+
## When to Auto-Launch Workers
|
|
4
|
+
|
|
5
|
+
| Trigger | Worker Type | Condition |
|
|
6
|
+
|---------|------------|-----------|
|
|
7
|
+
| Case completion | `consolidate` | After 3rd completed `/casarium` case in project |
|
|
8
|
+
| Post-BTO test | `health-check` | After any `/bto-test` run (advisory, not enforced) |
|
|
9
|
+
| Manual | Any | User runs `/workers start <type>` |
|
|
10
|
+
|
|
11
|
+
Auto-launch triggers are ADVISORY. The system may suggest launching a worker but
|
|
12
|
+
MUST wait for user confirmation before actually spawning a background agent.
|
|
13
|
+
|
|
14
|
+
## Worker Isolation Rules
|
|
15
|
+
|
|
16
|
+
1. Workers MUST only write to `.keysarium/workers/{worker_id}/` directory
|
|
17
|
+
2. Workers MUST NOT modify files in `researches/` (active research data)
|
|
18
|
+
3. Workers MUST NOT modify files in `features/` (active feature data)
|
|
19
|
+
4. Workers MUST NOT modify files in `.claude/` (commands, rules, skills)
|
|
20
|
+
5. Workers MUST NOT modify `CLAUDE.md`, `TOOLKIT_HARVEST.md`, or any root-level file
|
|
21
|
+
6. Workers MAY read any file in the project for analysis purposes
|
|
22
|
+
7. Exception: `export-brain` worker MAY write to `.keysarium/exports/` (standard export location)
|
|
23
|
+
|
|
24
|
+
## Model Routing for Workers
|
|
25
|
+
|
|
26
|
+
| Worker Type | Model | Rationale |
|
|
27
|
+
|-------------|-------|-----------|
|
|
28
|
+
| `consolidate` | sonnet | Pattern synthesis requires analytical reasoning |
|
|
29
|
+
| `export-brain` | haiku | Primarily file reading and JSON assembly |
|
|
30
|
+
| `health-check` | haiku | Structural checks, simple pattern matching |
|
|
31
|
+
| `pattern-analysis` | sonnet | Trend analysis requires deeper reasoning |
|
|
32
|
+
|
|
33
|
+
NEVER use opus for background workers -- workers perform routine tasks, not creative work.
|
|
34
|
+
ALWAYS specify the model parameter when spawning a worker agent.
|
|
35
|
+
|
|
36
|
+
## Concurrency Limits
|
|
37
|
+
|
|
38
|
+
- Maximum concurrent workers: **3**
|
|
39
|
+
- If limit reached, new worker requests MUST be rejected (not queued)
|
|
40
|
+
- Rationale: prevent context exhaustion and ensure foreground responsiveness
|
|
41
|
+
|
|
42
|
+
## Worker Naming Convention
|
|
43
|
+
|
|
44
|
+
When spawning worker agents, use this naming format:
|
|
45
|
+
```
|
|
46
|
+
"Background Worker: {type} ({worker_id})"
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Example: `"Background Worker: consolidate (wkr-20260301-143022-consolidate)"`
|
|
50
|
+
|
|
51
|
+
## Worker Timeout
|
|
52
|
+
|
|
53
|
+
- Workers are subject to the Agent tool's built-in timeout (~10 minutes)
|
|
54
|
+
- Design workers to complete within this window
|
|
55
|
+
- If a worker needs more time, it should checkpoint its progress and be re-launched
|
|
56
|
+
|
|
57
|
+
## Registry Management
|
|
58
|
+
|
|
59
|
+
- Only the `/workers` command (orchestrator) may write to `registry.json`
|
|
60
|
+
- Workers write to their own `status.json` in their output directory
|
|
61
|
+
- This prevents write conflicts between the orchestrator and workers
|
|
62
|
+
|
|
63
|
+
## Anti-Patterns
|
|
64
|
+
|
|
65
|
+
| Anti-Pattern | Detection | Fix |
|
|
66
|
+
|-------------|-----------|-----|
|
|
67
|
+
| Worker modifies research files | File write outside `.keysarium/workers/` | BLOCK -- enforce isolation |
|
|
68
|
+
| Worker uses opus model | Model parameter check | Use haiku or sonnet per routing table |
|
|
69
|
+
| More than 3 concurrent workers | Registry count check | Reject new worker start |
|
|
70
|
+
| Worker spawns sub-agents | Instruction check in template | Templates explicitly forbid sub-agents |
|
|
71
|
+
| Auto-launch without user consent | Missing user confirmation | Always ask before auto-launching |
|
|
72
|
+
| Worker runs indefinitely | No progress updates | Workers must update status.json periodically |
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# Dream Cycles Integration Rules
|
|
2
|
+
|
|
3
|
+
## Auto-Trigger Rules
|
|
4
|
+
|
|
5
|
+
When starting a new pipeline run (`/casarium` or `/feature-adr`), the orchestrator SHOULD check dream triggers:
|
|
6
|
+
|
|
7
|
+
1. Read `.keysarium/insights/trigger-state.json`
|
|
8
|
+
2. Evaluate triggers using the protocol in `lib/dream-engine.md`
|
|
9
|
+
3. If any trigger is met, suggest to the user:
|
|
10
|
+
```
|
|
11
|
+
Dream cycle trigger met ({reason}). Consider running /dream run for fresh insights.
|
|
12
|
+
```
|
|
13
|
+
4. This is ADVISORY only -- do not auto-launch without user confirmation
|
|
14
|
+
5. If user declines, proceed normally
|
|
15
|
+
|
|
16
|
+
### Trigger Check Timing
|
|
17
|
+
|
|
18
|
+
- Check triggers at pipeline START (before Phase 0 or Step 0)
|
|
19
|
+
- Do NOT check triggers mid-pipeline (would interrupt flow)
|
|
20
|
+
- Do NOT check triggers on simple commands (/harvest, /brain-export, /learning-stats)
|
|
21
|
+
|
|
22
|
+
## Insight Application Rules
|
|
23
|
+
|
|
24
|
+
### At /casarium Phase 0 (Discovery)
|
|
25
|
+
|
|
26
|
+
1. After domain detection, check `.keysarium/insights/` for the most recent dream result
|
|
27
|
+
2. Filter insights by detected domain
|
|
28
|
+
3. For each relevant insight, apply:
|
|
29
|
+
- **Performance insights**: Adjust time budget recommendations for flagged phases
|
|
30
|
+
- **Effectiveness insights**: Note skill preferences in the case brief
|
|
31
|
+
- **Preference insights**: Flag preferred CJM variants for Phase 2.5
|
|
32
|
+
- **Anti-pattern insights**: Add explicit warnings to the case brief
|
|
33
|
+
4. Log loaded insights: "Applied {count} dream insights for {domain} domain"
|
|
34
|
+
|
|
35
|
+
### At /casarium Phase 2 (Research)
|
|
36
|
+
|
|
37
|
+
If a performance insight flags Phase 2 as problematic for the current domain:
|
|
38
|
+
- Log a warning: "Dream insight: Phase 2 is historically challenging for {domain}. Extra attention recommended."
|
|
39
|
+
- This is informational only -- does not change the research protocol
|
|
40
|
+
|
|
41
|
+
### At /feature-adr Step 0 (Complexity Router)
|
|
42
|
+
|
|
43
|
+
Dream insights are NOT applied to feature-adr (different pipeline, different context).
|
|
44
|
+
|
|
45
|
+
## Retention Rules
|
|
46
|
+
|
|
47
|
+
1. Maximum 10 dream result files in `.keysarium/insights/`
|
|
48
|
+
2. Retention is enforced at the END of each dream cycle (Step 5)
|
|
49
|
+
3. Retention is also enforced by `/dream clear`
|
|
50
|
+
4. `trigger-state.json` is NEVER deleted by retention (it is state, not a result)
|
|
51
|
+
5. Dream result files are named `dream-{YYYYMMDD}-{HHmmss}.json` for chronological sorting
|
|
52
|
+
|
|
53
|
+
## Integration with memory_store()
|
|
54
|
+
|
|
55
|
+
After writing a reward record via `memory_store()`, the system SHOULD:
|
|
56
|
+
1. Attempt to read `.keysarium/insights/trigger-state.json`
|
|
57
|
+
2. If it exists, increment `records_since_last_dream` and write back
|
|
58
|
+
3. If it does not exist, skip silently (dream cycles not yet initialized)
|
|
59
|
+
4. If write fails, log warning and continue (non-critical)
|
|
60
|
+
|
|
61
|
+
This integration is ADVISORY -- memory_store() must succeed even if trigger state update fails.
|
|
62
|
+
|
|
63
|
+
## Integration with Event Triggers
|
|
64
|
+
|
|
65
|
+
### Quality Gate Failure
|
|
66
|
+
|
|
67
|
+
When a BTO quality gate fails (Layer 0 rejection after 3 retries):
|
|
68
|
+
1. Append event to `trigger-state.json`:
|
|
69
|
+
```json
|
|
70
|
+
{ "event_type": "quality_gate_failure", "timestamp": "...", "details": "BTO Layer 0 failed 3x" }
|
|
71
|
+
```
|
|
72
|
+
2. Suggest running `/dream run` to analyze the failure pattern
|
|
73
|
+
|
|
74
|
+
### Case Completion
|
|
75
|
+
|
|
76
|
+
When a `/casarium` run completes (Phase 6 packaging done):
|
|
77
|
+
1. Append event to `trigger-state.json`:
|
|
78
|
+
```json
|
|
79
|
+
{ "event_type": "case_completion", "timestamp": "...", "details": "Completed {slug}" }
|
|
80
|
+
```
|
|
81
|
+
2. If `records_since_last_dream >= 10` (half of volume threshold), suggest a dream run
|
|
82
|
+
|
|
83
|
+
## Model Routing
|
|
84
|
+
|
|
85
|
+
| Operation | Model | Rationale |
|
|
86
|
+
|-----------|-------|-----------|
|
|
87
|
+
| Dream cycle execution | sonnet | Analytical pattern detection |
|
|
88
|
+
| Trigger evaluation | N/A | Deterministic JSON operations |
|
|
89
|
+
| Insight display | N/A | File reading and formatting |
|
|
90
|
+
| Status display | N/A | File reading and formatting |
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# Feature ADR Conventions
|
|
2
|
+
|
|
3
|
+
## When to Use /feature-adr vs Other Commands
|
|
4
|
+
|
|
5
|
+
| Situation | Command |
|
|
6
|
+
|-----------|---------|
|
|
7
|
+
| Implementing a software feature | `/feature-adr` |
|
|
8
|
+
| Researching an AI case for hackathon | `/casarium` |
|
|
9
|
+
| Solving a complex problem (no code) | `/solve` |
|
|
10
|
+
| Designing architecture only (no code) | `/architecture-phase` |
|
|
11
|
+
| Building a new skill/command | `/bto-build` |
|
|
12
|
+
|
|
13
|
+
## Output Directory
|
|
14
|
+
|
|
15
|
+
All `/feature-adr` artifacts go into `features/<feature-slug>/`.
|
|
16
|
+
NEVER create feature artifacts in the project root or in `researches/`.
|
|
17
|
+
|
|
18
|
+
`researches/` is for `/casarium` pipeline only.
|
|
19
|
+
`features/` is for `/feature-adr` pipeline only.
|
|
20
|
+
|
|
21
|
+
## Slug Naming
|
|
22
|
+
|
|
23
|
+
- Format: `kebab-case`, Latin characters only
|
|
24
|
+
- Max length: 40 characters
|
|
25
|
+
- Examples: `add-user-auth`, `refactor-payment-flow`, `migrate-to-postgres`
|
|
26
|
+
- NO dates, NO ticket numbers in slug (put those in the artifact files)
|
|
27
|
+
|
|
28
|
+
## Artifact Naming
|
|
29
|
+
|
|
30
|
+
All artifacts use numbered prefix matching their step:
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
00_complexity_assessment.md
|
|
34
|
+
01_requirements.md
|
|
35
|
+
02_research.md
|
|
36
|
+
03_adr/001-{decision-slug}.md
|
|
37
|
+
04_domain_model.md
|
|
38
|
+
05_architecture.md
|
|
39
|
+
06_implementation_plan.md
|
|
40
|
+
07_code_changes/change_manifest.md
|
|
41
|
+
08_qe_report.md
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Complexity Tier Rules
|
|
45
|
+
|
|
46
|
+
- Tier is determined by Step 0 (Complexity Router) — never guess
|
|
47
|
+
- User can override tier at Checkpoint 0
|
|
48
|
+
- Once confirmed, tier determines which steps run
|
|
49
|
+
- Tier CANNOT change mid-pipeline (restart if scope changes significantly)
|
|
50
|
+
|
|
51
|
+
## Integration with Existing Pipeline
|
|
52
|
+
|
|
53
|
+
`/feature-adr` is independent from the Casarium pipeline.
|
|
54
|
+
It does NOT use:
|
|
55
|
+
- Phase numbering (Phase 0-6)
|
|
56
|
+
- Research artifacts (00_product_discovery.md, etc.)
|
|
57
|
+
- CJM prototypes
|
|
58
|
+
- Presentation generation
|
|
59
|
+
|
|
60
|
+
It DOES share:
|
|
61
|
+
- Skills (`explore`, `problem-solver-enhanced`, `frontend-design`)
|
|
62
|
+
- Agent swarm patterns
|
|
63
|
+
- Checkpoint protocol
|
|
64
|
+
- Promise tag system
|
|
65
|
+
- Model routing rules
|
|
66
|
+
|
|
67
|
+
## Feature Lifecycle
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
/feature-adr [description]
|
|
71
|
+
→ Step 0: classify
|
|
72
|
+
→ Steps 1-5: design (per tier)
|
|
73
|
+
→ Step 6: plan
|
|
74
|
+
→ Step 7: code
|
|
75
|
+
→ Step 8: QE
|
|
76
|
+
→ Done: README.md + code changes in repo
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
After completion:
|
|
80
|
+
- Code changes live in the actual codebase (not just in `features/`)
|
|
81
|
+
- `features/<slug>/` contains the design artifacts (ADRs, diagrams, reports)
|
|
82
|
+
- These artifacts serve as documentation for the feature
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# Reward Learning Rules
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
Govern how the Keysarium pipeline integrates with the Reward-Calibrated Learning System. These rules define when and how to call `memory_query()` and `memory_store()`, how reward scores are assigned, and how historical patterns influence phase execution.
|
|
6
|
+
|
|
7
|
+
## Core Protocol
|
|
8
|
+
|
|
9
|
+
Read `lib/memory-protocol.md` for the full protocol specification.
|
|
10
|
+
Read `lib/reward-tracker.md` for analytics and pattern detection.
|
|
11
|
+
|
|
12
|
+
## When to Call memory_query()
|
|
13
|
+
|
|
14
|
+
**Trigger:** At the START of every pipeline phase (Phase 0 through Phase 5).
|
|
15
|
+
|
|
16
|
+
**Protocol:**
|
|
17
|
+
1. Before loading the phase's governance shard, check if `.keysarium/memory/` exists.
|
|
18
|
+
2. If it exists, call `memory_query()` with the current context:
|
|
19
|
+
- `phase`: Current phase identifier (e.g., "phase-2")
|
|
20
|
+
- `domain`: Detected domain from Phase 0 (or "unknown" if Phase 0 has not run yet)
|
|
21
|
+
- `slug`: Current case slug
|
|
22
|
+
- `skill`: Skill about to be loaded for this phase
|
|
23
|
+
3. Log the number of patterns loaded.
|
|
24
|
+
4. If relevant patterns are found, incorporate the top 3 into the phase brief:
|
|
25
|
+
- Include high-reward approaches from similar past cases
|
|
26
|
+
- Apply actionable advice from domain patterns
|
|
27
|
+
- Note any bottleneck warnings for the current phase/domain combination
|
|
28
|
+
5. If no patterns are found (first run or no relevant data), proceed normally.
|
|
29
|
+
|
|
30
|
+
**Exception:** Phase 0 (Discovery) may not have a domain yet. Query with `domain: "unknown"` to load cross-domain patterns.
|
|
31
|
+
|
|
32
|
+
## When to Call memory_store()
|
|
33
|
+
|
|
34
|
+
**Trigger:** At every CHECKPOINT, after the user responds.
|
|
35
|
+
|
|
36
|
+
**Protocol:**
|
|
37
|
+
1. After displaying the checkpoint banner and receiving user response.
|
|
38
|
+
2. Classify the user response into a reward level (see Reward Assignment below).
|
|
39
|
+
3. Call `memory_store()` with:
|
|
40
|
+
- The phase result (artifacts created, promise tag emitted)
|
|
41
|
+
- The reward score and label
|
|
42
|
+
- Context metadata (upstream promises, patterns loaded, agent count)
|
|
43
|
+
- Outcome metadata (user response, iteration count)
|
|
44
|
+
4. Log the stored reward.
|
|
45
|
+
5. Continue with the checkpoint protocol as normal (proceed / adjust / redo).
|
|
46
|
+
|
|
47
|
+
**Exception:** If the session ends without a user response at the checkpoint, do NOT store a record. Only explicit user responses generate reward data.
|
|
48
|
+
|
|
49
|
+
## Reward Assignment
|
|
50
|
+
|
|
51
|
+
Map the user's checkpoint response to a reward score:
|
|
52
|
+
|
|
53
|
+
| User Response Pattern | Reward | Label | Examples |
|
|
54
|
+
|----------------------|--------|-------|----------|
|
|
55
|
+
| Immediate approval | 1.0 | excellent | "ok", "ок", "next", "продолжай", "good", single-word approval |
|
|
56
|
+
| Minor adjustments | 0.7 | good | "углуби X", "expand section Y", "add one more competitor", feedback on 1 area |
|
|
57
|
+
| Significant rework | 0.3 | needs_work | "rework the approach", "this misses the point of X and Y", feedback on 3+ areas |
|
|
58
|
+
| Complete restart | 0.0 | failed | "start over", "this is wrong", "redo this phase completely" |
|
|
59
|
+
|
|
60
|
+
### Classification Rules
|
|
61
|
+
|
|
62
|
+
1. **Count the areas of feedback:** 0 areas = 1.0, 1 area = 0.7, 2+ areas = 0.3, full restart = 0.0
|
|
63
|
+
2. **Positive feedback with minor note** counts as 1.0 (e.g., "great work, just fix the typo")
|
|
64
|
+
3. **Multiple rounds:** If user gives feedback more than twice on the same phase, cap reward at 0.3
|
|
65
|
+
4. **Ambiguous responses:** Default to 0.7 (assume minor adjustment)
|
|
66
|
+
|
|
67
|
+
## Integration with Promise Tags
|
|
68
|
+
|
|
69
|
+
Every `memory_store()` call includes the promise tag emitted at the checkpoint:
|
|
70
|
+
|
|
71
|
+
| Phase | Promise Tag in Record |
|
|
72
|
+
|-------|----------------------|
|
|
73
|
+
| Phase 0 | `DISCOVERY_COMPLETE` |
|
|
74
|
+
| Phase 1 | `CASE_EXPLORED` |
|
|
75
|
+
| Phase 2 | `RESEARCH_PARANOID_PASSED` |
|
|
76
|
+
| Phase 2.5 | `CJM_VALIDATED` |
|
|
77
|
+
| Phase 3 | `SOLUTION_DESIGNED` |
|
|
78
|
+
| Phase 4 | `ARCHITECTURE_DEFINED` |
|
|
79
|
+
| Phase 5 | `PRESENTATION_READY` |
|
|
80
|
+
|
|
81
|
+
If a promise is `_INCOMPLETE`, the reward should be 0.3 or lower.
|
|
82
|
+
|
|
83
|
+
## Integration with Feedback Loops
|
|
84
|
+
|
|
85
|
+
This system adds a new feedback loop to the Variable Registry (see `.claude/rules/feedback-loops.md`):
|
|
86
|
+
|
|
87
|
+
### Loop 7: Memory -> All Phases
|
|
88
|
+
|
|
89
|
+
| Property | Value |
|
|
90
|
+
|----------|-------|
|
|
91
|
+
| Direction | `.keysarium/memory/` -> Phase 0-5 start |
|
|
92
|
+
| Variable | `{MEMORY_PATTERNS}` |
|
|
93
|
+
| Payload | Top reward records + domain patterns from memory_query() |
|
|
94
|
+
| Consumers | All phases (loaded at phase start) |
|
|
95
|
+
| Persistence | `.keysarium/memory/{domain}/{slug}/` |
|
|
96
|
+
|
|
97
|
+
**Contract:** `memory_query()` is called before each phase starts. Empty result is acceptable (first run).
|
|
98
|
+
|
|
99
|
+
## Retention Policy
|
|
100
|
+
|
|
101
|
+
- **Default:** 90 days from record creation
|
|
102
|
+
- **Configuration:** Set in `.keysarium/memory/config.json` via `retention_days`
|
|
103
|
+
- **Enforcement:** Expired records are purged during `memory_query()` calls
|
|
104
|
+
- **Override:** Set `retention_days: 0` to disable expiration (keep forever)
|
|
105
|
+
- **Manual purge:** Delete `.keysarium/memory/` directory to reset all memory
|
|
106
|
+
|
|
107
|
+
## Error Handling
|
|
108
|
+
|
|
109
|
+
| Situation | Behavior |
|
|
110
|
+
|-----------|----------|
|
|
111
|
+
| `.keysarium/memory/` does not exist | `memory_query()` returns empty; `memory_store()` creates it |
|
|
112
|
+
| `config.json` missing | Use defaults (90 days, 10 max results, enabled) |
|
|
113
|
+
| Corrupted JSON file during query | Skip file, log warning, continue with other records |
|
|
114
|
+
| Write failure during store | Log error, continue pipeline (memory is non-blocking) |
|
|
115
|
+
| Unknown domain | Store under `unknown/` directory |
|
|
116
|
+
|
|
117
|
+
## Rules Summary
|
|
118
|
+
|
|
119
|
+
1. **ALWAYS** call `memory_query()` at the start of every phase
|
|
120
|
+
2. **ALWAYS** call `memory_store()` at every checkpoint after user responds
|
|
121
|
+
3. **NEVER** block the pipeline if memory operations fail
|
|
122
|
+
4. **NEVER** store a record without an explicit user response
|
|
123
|
+
5. **ALWAYS** log memory operations (patterns loaded, reward stored)
|
|
124
|
+
6. Memory operations are **advisory** -- they enhance quality but are not mandatory gates
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# Feature ADR — Governance Shard
|
|
2
|
+
|
|
3
|
+
## Skill
|
|
4
|
+
Load: `.claude/skills/feature-adr/SKILL.md`
|
|
5
|
+
|
|
6
|
+
## Prerequisites
|
|
7
|
+
- None (standalone command, not part of casarium pipeline)
|
|
8
|
+
|
|
9
|
+
## Mandatory Outputs by Tier
|
|
10
|
+
|
|
11
|
+
### Tier S
|
|
12
|
+
- `features/<slug>/00_complexity_assessment.md`
|
|
13
|
+
- `features/<slug>/06_implementation_plan.md` (or inline)
|
|
14
|
+
- `features/<slug>/08_qe_report.md`
|
|
15
|
+
- `features/<slug>/README.md`
|
|
16
|
+
- Actual code changes in repository
|
|
17
|
+
|
|
18
|
+
### Tier M
|
|
19
|
+
All of S, plus:
|
|
20
|
+
- `features/<slug>/01_requirements.md`
|
|
21
|
+
- `features/<slug>/03_adr/001-*.md`
|
|
22
|
+
- `features/<slug>/05_architecture.md`
|
|
23
|
+
- `features/<slug>/07_code_changes/change_manifest.md`
|
|
24
|
+
- `features/<slug>/diagrams/` (component diagram)
|
|
25
|
+
|
|
26
|
+
### Tier L
|
|
27
|
+
All of M, plus:
|
|
28
|
+
- `features/<slug>/02_research.md`
|
|
29
|
+
- `features/<slug>/04_domain_model.md`
|
|
30
|
+
- `features/<slug>/diagrams/domain-model.mermaid`
|
|
31
|
+
- `features/<slug>/diagrams/architecture-c4.mermaid`
|
|
32
|
+
- `features/<slug>/diagrams/sequence-*.mermaid`
|
|
33
|
+
|
|
34
|
+
### Tier XL
|
|
35
|
+
All of L (full depth on every artifact)
|
|
36
|
+
|
|
37
|
+
## Step-Level Quality Gates
|
|
38
|
+
|
|
39
|
+
| Step | Gate |
|
|
40
|
+
|------|------|
|
|
41
|
+
| 0 | Tier classification justified with dimension scores |
|
|
42
|
+
| 1 | All requirements have acceptance criteria (M+) |
|
|
43
|
+
| 2 | Research findings verified, not hallucinated (L/XL) |
|
|
44
|
+
| 3 | Every ADR has ≥2 alternatives (M+) |
|
|
45
|
+
| 4 | Domain model compatible with existing codebase (L/XL) |
|
|
46
|
+
| 5 | Mermaid diagrams valid syntax (M+) |
|
|
47
|
+
| 6 | Task dependencies form valid DAG |
|
|
48
|
+
| 7 | Code follows existing codebase conventions |
|
|
49
|
+
| 8 | No blocker findings remain, all MUST requirements pass |
|
|
50
|
+
|
|
51
|
+
## Agent Swarm
|
|
52
|
+
|
|
53
|
+
### S/M tier
|
|
54
|
+
Sequential execution. No parallel agents needed.
|
|
55
|
+
|
|
56
|
+
### L tier
|
|
57
|
+
- Steps 2+3: 2 parallel agents (sonnet + opus)
|
|
58
|
+
- Step 8: 3 parallel agents (sonnet × 3)
|
|
59
|
+
|
|
60
|
+
### XL tier
|
|
61
|
+
- Steps 2+3: 2 parallel agents
|
|
62
|
+
- Steps 4+5: 2 parallel agents (if Step 3 done)
|
|
63
|
+
- Step 7: N parallel agents (per module)
|
|
64
|
+
- Step 8: 3 parallel agents (review panel)
|
|
65
|
+
|
|
66
|
+
## Model Routing
|
|
67
|
+
|
|
68
|
+
| Step | Model | Rationale |
|
|
69
|
+
|------|-------|-----------|
|
|
70
|
+
| 0 | haiku | Simple classification |
|
|
71
|
+
| 1 | sonnet | Analytical requirements |
|
|
72
|
+
| 2 | sonnet | Research synthesis |
|
|
73
|
+
| 3 | opus | Complex trade-off reasoning |
|
|
74
|
+
| 4 | opus | Domain modeling |
|
|
75
|
+
| 5 | opus | System design |
|
|
76
|
+
| 6 | sonnet | Task decomposition |
|
|
77
|
+
| 7 | opus | Code generation |
|
|
78
|
+
| 8 | sonnet | Review and testing |
|
|
79
|
+
|
|
80
|
+
## Promise Tags
|
|
81
|
+
|
|
82
|
+
| Step | Promise |
|
|
83
|
+
|------|---------|
|
|
84
|
+
| 0 | `<promise>FEATURE_ADR_ROUTED</promise>` |
|
|
85
|
+
| 1 | `<promise>FEATURE_ADR_REQUIREMENTS_GATHERED</promise>` |
|
|
86
|
+
| 2-5 | `<promise>FEATURE_ADR_DESIGNED</promise>` |
|
|
87
|
+
| 6 | `<promise>FEATURE_ADR_PLANNED</promise>` |
|
|
88
|
+
| 7 | `<promise>FEATURE_ADR_IMPLEMENTED</promise>` |
|
|
89
|
+
| 8 | `<promise>FEATURE_ADR_VERIFIED</promise>` |
|
|
90
|
+
|
|
91
|
+
## Anti-Patterns to Check
|
|
92
|
+
|
|
93
|
+
- Skip Step 0 → BLOCK
|
|
94
|
+
- Code without plan (skip Step 6) → BLOCK
|
|
95
|
+
- No QE (skip Step 8) → BLOCK
|
|
96
|
+
- Over-engineer S-tier (run full pipeline for trivial change) → FLAG
|
|
97
|
+
- Under-engineer XL-tier (skip ADR/DDD) → FLAG
|
|
98
|
+
- ADR with only 1 alternative → FLAG
|