@rune-kit/rune 2.6.0 → 2.8.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.
Files changed (42) hide show
  1. package/README.md +22 -6
  2. package/compiler/__tests__/executive-dashboards.test.js +285 -0
  3. package/compiler/__tests__/inject.test.js +128 -0
  4. package/compiler/__tests__/orchestrators.test.js +151 -0
  5. package/compiler/__tests__/org-templates.test.js +447 -0
  6. package/compiler/__tests__/parser.test.js +201 -147
  7. package/compiler/__tests__/skill-index.test.js +218 -218
  8. package/compiler/__tests__/status.test.js +336 -0
  9. package/compiler/__tests__/templates.test.js +245 -0
  10. package/compiler/__tests__/visualizer.test.js +325 -0
  11. package/compiler/adapters/antigravity.js +71 -71
  12. package/compiler/bin/rune.js +444 -355
  13. package/compiler/doctor.js +272 -1
  14. package/compiler/emitter.js +939 -678
  15. package/compiler/parser.js +498 -267
  16. package/compiler/status.js +342 -0
  17. package/compiler/visualizer.js +622 -0
  18. package/package.json +1 -1
  19. package/skills/autopsy/SKILL.md +48 -1
  20. package/skills/completion-gate/SKILL.md +51 -3
  21. package/skills/context-engine/SKILL.md +141 -2
  22. package/skills/cook/SKILL.md +177 -4
  23. package/skills/debug/SKILL.md +50 -1
  24. package/skills/docs/SKILL.md +28 -3
  25. package/skills/fix/SKILL.md +26 -1
  26. package/skills/mcp-builder/SKILL.md +53 -1
  27. package/skills/onboard/SKILL.md +51 -1
  28. package/skills/perf/SKILL.md +34 -1
  29. package/skills/plan/SKILL.md +27 -1
  30. package/skills/preflight/SKILL.md +35 -1
  31. package/skills/research/SKILL.md +24 -1
  32. package/skills/retro/SKILL.md +95 -1
  33. package/skills/review/SKILL.md +45 -1
  34. package/skills/scope-guard/SKILL.md +1 -0
  35. package/skills/scout/SKILL.md +22 -1
  36. package/skills/sentinel/SKILL.md +35 -1
  37. package/skills/sentinel/references/policy-driven-constraints.md +424 -0
  38. package/skills/sentinel-env/SKILL.md +0 -2
  39. package/skills/session-bridge/SKILL.md +57 -2
  40. package/skills/session-bridge/references/evolutionary-memory-patterns.md +312 -0
  41. package/skills/team/SKILL.md +15 -1
  42. package/skills/verification/SKILL.md +0 -2
@@ -0,0 +1,312 @@
1
+ > Activate when: session-bridge is saving context and the project has accumulated 3+ sessions of history, OR when a task explicitly requires cross-session learning from past decisions and failures.
2
+
3
+ # Evolutionary Memory Patterns
4
+
5
+ Flat session logs answer "what happened?" — typed memory answers "what worked, what failed, and why?" This reference describes how to upgrade session-bridge from append-only logs to a queryable typed memory graph.
6
+
7
+ ---
8
+
9
+ ## 1. Why Typed Memory Beats Flat Logs
10
+
11
+ Flat text logs grow linearly and become noise. After 10 sessions, an agent scanning a flat log must read everything to find relevant context — and still cannot distinguish a recoverable mistake from a permanent architectural constraint.
12
+
13
+ Typed memory solves this with three queryable node types:
14
+
15
+ | Type | Question it answers | When to write |
16
+ |------|--------------------|--------------------|
17
+ | Decision | "What did I choose and did it work?" | Before + after executing a strategic choice |
18
+ | Finding | "What did I discover and has it been acted on?" | Immediately on discovery |
19
+ | Failure | "What broke, why, and what should I never repeat?" | On error or recovery |
20
+
21
+ Each node carries: `timestamp`, `session_id`, `context` (what the agent was doing), `outcome` (updated post-execution), and `tags` (topic labels for retrieval).
22
+
23
+ The key property: **an agent can query by type + tags** instead of scanning chronologically. "Show me all Failures tagged `api-auth` from the last 5 sessions" is impossible with flat logs, trivial with typed nodes.
24
+
25
+ ---
26
+
27
+ ## 2. Memory Node Schema
28
+
29
+ ### Decision Node
30
+
31
+ Captures strategic choices. Written in two passes: intent before execution, outcome after.
32
+
33
+ ```yaml
34
+ # .rune/memory/decisions.md entry
35
+ ---
36
+ type: decision
37
+ id: dec-20260315-001
38
+ session_id: sess-abc123
39
+ timestamp: 2026-03-15T10:22:00Z
40
+ tags: [auth, library-choice, architecture]
41
+ confidence: 0.8
42
+ outcome: success # pending | success | failure | partial
43
+ ---
44
+ what: Chose lucia-auth over next-auth for session management
45
+ alternatives:
46
+ - next-auth: rejected — too opinionated, v5 breaking changes expected
47
+ - custom JWT: rejected — maintenance burden too high
48
+ reasoning: lucia-auth is framework-agnostic, zero dependencies, aligns with our SvelteKit setup
49
+ impact: affects src/lib/auth/, src/hooks.server.ts, all protected routes
50
+ outcome_notes: Shipped cleanly. No issues after 3 weeks. Confidence promoted to 0.9.
51
+ ```
52
+
53
+ ### Finding Node
54
+
55
+ Captures discoveries that affect future work. Marked `consumed_by` once a session acts on it.
56
+
57
+ ```yaml
58
+ # .rune/memory/findings.md entry
59
+ ---
60
+ type: finding
61
+ id: fnd-20260316-003
62
+ session_id: sess-def456
63
+ timestamp: 2026-03-16T14:05:00Z
64
+ tags: [performance, database, n+1]
65
+ significance: high # low | medium | high | critical
66
+ actionable: true
67
+ consumed_by: sess-ghi789 # session that acted on this finding
68
+ ---
69
+ what: UserPosts query triggers N+1 — one DB call per post to fetch author
70
+ source: profiling with Prisma query logs during load test (500 concurrent users)
71
+ context: Investigating why /feed endpoint degraded above 100 users
72
+ recommended_action: Add include:{author:true} to all post list queries
73
+ ```
74
+
75
+ ### Failure Node
76
+
77
+ Captures what broke and why. The `lesson` field is the distilled takeaway — written for a future agent who has no context.
78
+
79
+ ```yaml
80
+ # .rune/memory/failures.md entry
81
+ ---
82
+ type: failure
83
+ id: fail-20260317-002
84
+ session_id: sess-jkl012
85
+ timestamp: 2026-03-17T09:41:00Z
86
+ tags: [deployment, env-vars, ci]
87
+ preventable: true
88
+ recovery: reverted deploy, added env var to CI secrets, re-deployed
89
+ ---
90
+ what: Production deploy failed — app crashed at startup with "DATABASE_URL is undefined"
91
+ root_cause: .env.production was not committed (correct), but CI pipeline did not have DATABASE_URL in secrets vault
92
+ context: First deploy to new environment after migrating CI from GitHub Actions to GitLab
93
+ lesson: Every new environment needs a secrets audit before first deploy — check all required env vars against running config
94
+ ```
95
+
96
+ ---
97
+
98
+ ## 3. Cross-Session Loading Strategy
99
+
100
+ Loading everything on session start causes context flooding. Use selective loading:
101
+
102
+ ```
103
+ Load order (on session start):
104
+ 1. Findings → ALL unread (consumed_by = null), max 10
105
+ 2. Failures → ALL from last 30 days, max 8
106
+ 3. Decisions → ONLY confidence >= 0.7, max 5, sorted by recency
107
+
108
+ Hard cap: 20 nodes total per session load
109
+ ```
110
+
111
+ **Recency bias**: weight recent nodes higher. A failure from last week is more relevant than one from 6 months ago — unless it's pinned.
112
+
113
+ **Relevance filter**: match nodes by tags against the current task description. If the session is working on authentication, load auth-tagged nodes before untagged ones.
114
+
115
+ **Staleness demotion**: nodes older than 30 days without a `pinned: true` flag are excluded from the default load. They remain queryable on demand but don't auto-surface.
116
+
117
+ ```yaml
118
+ # Pinning a node to prevent staleness demotion
119
+ pinned: true
120
+ pin_reason: Core architectural constraint — do not expire
121
+ ```
122
+
123
+ **Memory budget enforcement**: if the filtered set exceeds 20 nodes, apply this priority:
124
+ 1. Pinned nodes (always included)
125
+ 2. Critical-significance findings
126
+ 3. Preventable failures (high lesson value)
127
+ 4. High-confidence decisions with `outcome: success`
128
+ 5. Everything else — truncate here
129
+
130
+ ---
131
+
132
+ ## 4. Memory Accumulation Pattern
133
+
134
+ Write nodes in real-time, not in batch at session end. Batch writing loses context — if the session crashes or is interrupted, nothing is saved.
135
+
136
+ ### Decision write lifecycle
137
+
138
+ ```
139
+ BEFORE executing:
140
+ write node with outcome: pending
141
+ captures intent even if execution fails
142
+
143
+ AFTER executing:
144
+ update outcome: success | failure | partial
145
+ add outcome_notes with evidence
146
+ update confidence (up on success, down on failure)
147
+ ```
148
+
149
+ ### Finding write trigger
150
+
151
+ ```
152
+ IMMEDIATELY on discovery:
153
+ any unexpected behavior → Finding (significance: medium+)
154
+ any constraint discovered → Finding (actionable: true)
155
+ any external API behavior → Finding (tags: [external-api, <service>])
156
+ ```
157
+
158
+ ### Failure write trigger
159
+
160
+ ```
161
+ ON ERROR or unexpected recovery:
162
+ write before resuming normal flow
163
+ root_cause must not be "unknown" — attempt RCA even if uncertain
164
+ lesson must be one sentence, written for future-agent context
165
+ ```
166
+
167
+ ### End-of-session consolidation pass
168
+
169
+ After all nodes are written, run one consolidation sweep:
170
+
171
+ 1. Find duplicate Findings (same `what`, different sessions) — merge into highest-confidence node, archive duplicates
172
+ 2. Find Decisions with `outcome: pending` older than 1 session — mark as `outcome: unknown`, add note
173
+ 3. Find Failures with `preventable: true` — scan conventions.md for existing rules covering the lesson. If no rule exists, create one.
174
+ 4. Prune noise: Findings with `actionable: false` and `significance: low` older than 14 days — delete
175
+
176
+ ---
177
+
178
+ ## 5. Query Patterns for Agents
179
+
180
+ Typed nodes unlock structured recall. These patterns map agent questions to node queries:
181
+
182
+ **"What failed last time I tried to deploy?"**
183
+ ```
184
+ query: type=failure AND tags contains "deploy"
185
+ sort: timestamp DESC
186
+ limit: 5
187
+ → surfaces recent deployment failures with root causes
188
+ ```
189
+
190
+ **"What did I decide about the database layer and did it work?"**
191
+ ```
192
+ query: type=decision AND tags contains "database"
193
+ filter: outcome != pending
194
+ sort: confidence DESC
195
+ → surfaces past DB decisions with confirmed outcomes
196
+ ```
197
+
198
+ **"What have we discovered about the payment API?"**
199
+ ```
200
+ query: type=finding AND tags contains "payment"
201
+ filter: significance in [high, critical]
202
+ → surfaces all significant payment API findings
203
+ ```
204
+
205
+ **"Is there anything actionable I haven't consumed yet?"**
206
+ ```
207
+ query: type=finding AND actionable=true AND consumed_by=null
208
+ sort: significance DESC
209
+ → surfaces backlog of unconsumed findings
210
+ ```
211
+
212
+ **"Show me all preventable failures — what lessons do I have?"**
213
+ ```
214
+ query: type=failure AND preventable=true
215
+ field: lesson
216
+ → quick scan of all distilled lessons
217
+ ```
218
+
219
+ Agents should run the first two queries automatically on session load when the task has a known topic. The "unconsumed findings" query should run every session — it's the cross-session handoff mechanism.
220
+
221
+ ---
222
+
223
+ ## 6. Integration with Session Bridge
224
+
225
+ This pattern layers on top of session-bridge's existing state files. It does not replace decisions.md — it extends it with typed structure.
226
+
227
+ ### File layout
228
+
229
+ ```
230
+ .rune/
231
+ ├── decisions.md ← existing (unstructured log)
232
+ ├── conventions.md ← existing
233
+ ├── progress.md ← existing
234
+ ├── session-log.md ← existing
235
+ ├── memory/
236
+ │ ├── decisions.md ← NEW: typed Decision nodes (YAML frontmatter per entry)
237
+ │ ├── findings.md ← NEW: typed Finding nodes
238
+ │ └── failures.md ← NEW: typed Failure nodes
239
+ ```
240
+
241
+ The original `.rune/decisions.md` stays as a human-readable narrative log. The new `.rune/memory/` files are structured for agent querying.
242
+
243
+ ### Integration points in session-bridge flow
244
+
245
+ **Save Mode — after Step 2 (decisions):**
246
+ - For each architectural decision, also write a typed Decision node to `.rune/memory/decisions.md`
247
+ - Set `outcome: pending` — update after execution confirms result
248
+
249
+ **Save Mode — after Step 3 (conventions):**
250
+ - For each new convention derived from a Failure lesson, cross-reference the failure node: add `convention_created: true` to the Failure node
251
+
252
+ **Load Mode — after Step 2 (load files):**
253
+ - Run typed memory queries: unconsumed findings + recent failures
254
+ - Inject summary into the Step 3 context report:
255
+ ```
256
+ ## Session Bridge — Memory Loaded
257
+ - Unconsumed findings: [N] (see .rune/memory/findings.md)
258
+ - Recent failures (30d): [N], [top lesson preview]
259
+ - High-confidence decisions: [N] loaded
260
+ ```
261
+
262
+ ### Format convention
263
+
264
+ Each node is a YAML frontmatter block followed by a markdown body for extended notes:
265
+
266
+ ```markdown
267
+ ---
268
+ type: finding
269
+ id: fnd-[YYYYMMDD]-[NNN]
270
+ session_id: [session identifier]
271
+ timestamp: [ISO 8601]
272
+ tags: [tag1, tag2, tag3]
273
+ significance: high
274
+ actionable: true
275
+ consumed_by: null
276
+ ---
277
+ what: [one sentence summary]
278
+ source: [how/where this was found]
279
+ context: [what the agent was doing when this was found]
280
+ recommended_action: [what to do with this finding]
281
+ ```
282
+
283
+ Node IDs use the pattern `[type-prefix]-[date]-[sequence]` (e.g., `dec-20260315-001`) to ensure uniqueness across sessions without requiring a database.
284
+
285
+ ---
286
+
287
+ ## Signal Integration
288
+
289
+ ```yaml
290
+ signals:
291
+ emits:
292
+ - memory.decision.written:
293
+ when: Decision node written with outcome=pending
294
+ payload: { node_id, tags, confidence }
295
+ - memory.finding.discovered:
296
+ when: Finding node written with significance=high or critical
297
+ payload: { node_id, tags, actionable }
298
+ - memory.failure.recorded:
299
+ when: Failure node written with preventable=true
300
+ payload: { node_id, tags, lesson }
301
+ - memory.session.loaded:
302
+ when: Load Mode completes typed memory queries
303
+ payload: { decisions_loaded, findings_unconsumed, failures_recent }
304
+
305
+ listens:
306
+ - phase.complete:
307
+ action: Run end-of-session consolidation pass (merge duplicates, prune noise)
308
+ - task.failed:
309
+ action: Write Failure node immediately with root_cause from error context
310
+ - decision.made:
311
+ action: Write Decision node with outcome=pending before execution proceeds
312
+ ```
@@ -5,7 +5,7 @@ context: fork
5
5
  agent: general-purpose
6
6
  metadata:
7
7
  author: runedev
8
- version: "0.6.0"
8
+ version: "0.7.0"
9
9
  layer: L1
10
10
  model: opus
11
11
  group: orchestrator
@@ -160,10 +160,22 @@ GATE CHECK — before proceeding:
160
160
  → COUPLED modules MUST be moved to same stream OR stream B added to A's depends_on
161
161
  [ ] Dependent streams have explicit depends_on declared
162
162
  [ ] Total streams ≤ 3
163
+ [ ] Change Stacking check: no file appears in touches[] of 2+ parallel streams
164
+ [ ] Every stream's requires[] is satisfied by a prior stream's provides[] or existing code
163
165
 
164
166
  If any check fails → re-invoke plan with conflict notes.
165
167
  ```
166
168
 
169
+ **1d. Question Gate (non-trivial tasks only).**
170
+
171
+ > From superpowers (obra/superpowers, 84k★): "Subagents that start work without asking questions produce the wrong thing 40% of the time."
172
+
173
+ Before dispatching streams, include in each NEXUS Handoff: "Before starting, ask up to 3 clarifying questions if anything is unclear about scope, conventions, or expected output."
174
+
175
+ - If a cook agent returns questions instead of starting work → answer them, then re-dispatch
176
+ - If a cook agent starts work without questions → proceed normally (questions are invited, not required)
177
+ - **Skip if**: Lite mode (2 streams, ≤5 files) — overhead exceeds value
178
+
167
179
  Mark todo[0] `completed`.
168
180
 
169
181
  ---
@@ -483,6 +495,8 @@ Known failure modes for this skill. Check these before declaring done.
483
495
  | Poisoned cook report merged blindly | HIGH | Phase 3a.5 integrity-check on all cook reports before merge |
484
496
  | Bare prompt to cook instance — no context, conventions, or scope boundary | HIGH | NEXUS Handoff Template: structured handoff with metadata, deliverables, quality expectations, and evidence requirements |
485
497
  | Cook returns "done" with no acceptance criteria tracking | MEDIUM | Team Report includes Acceptance Criteria table with per-criterion evidence and PASS/FAIL/UNVERIFIED verdict |
498
+ | Subagent builds wrong thing due to ambiguous scope | HIGH | Question Gate (Step 1d): invite questions before work starts. Cost of answering 3 questions << cost of rebuilding 500 LOC |
499
+ | Parallel streams touch same files causing merge conflicts | HIGH | Change Stacking check in Step 1c: validate disjoint `touches[]` across all parallel streams |
486
500
 
487
501
  ## Done When
488
502
 
@@ -101,8 +101,6 @@ Compile all results into the structured report. Update all TodoWrite items to co
101
101
 
102
102
  ### 3-Level Artifact Verification
103
103
 
104
- > From GSD (gsd-build/get-shit-done, 30.8k★): "Task done ≠ Goal achieved."
105
-
106
104
  Every file created or modified during implementation must pass ALL 3 levels:
107
105
 
108
106
  **Level 1 — EXISTS**: File is on disk, non-empty.