@rune-kit/rune 2.13.0 → 2.15.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 (96) hide show
  1. package/README.md +31 -12
  2. package/compiler/__tests__/adapter-model-mapping.test.js +152 -0
  3. package/compiler/__tests__/adr-scoring.test.js +91 -0
  4. package/compiler/__tests__/context-md-format.test.js +180 -0
  5. package/compiler/__tests__/context-pack-smell-tests.test.js +215 -0
  6. package/compiler/__tests__/context-preview-signal.test.js +166 -0
  7. package/compiler/__tests__/diversity-score.test.js +117 -0
  8. package/compiler/__tests__/improve-architecture.test.js +171 -0
  9. package/compiler/__tests__/openclaw-adapter.test.js +11 -6
  10. package/compiler/__tests__/oracle-bundle-format.test.js +210 -0
  11. package/compiler/__tests__/oracle-pending-schema.test.js +209 -0
  12. package/compiler/__tests__/out-of-scope-format.test.js +303 -0
  13. package/compiler/__tests__/skill-description-quality.test.js +147 -0
  14. package/compiler/__tests__/zoom-out-output.test.js +112 -0
  15. package/compiler/adapters/antigravity.js +17 -1
  16. package/compiler/adapters/claude.js +4 -0
  17. package/compiler/adapters/codex.js +16 -1
  18. package/compiler/adapters/cursor.js +4 -0
  19. package/compiler/adapters/generic.js +14 -1
  20. package/compiler/adapters/openclaw.js +15 -1
  21. package/compiler/adapters/opencode.js +17 -1
  22. package/compiler/adapters/windsurf.js +4 -0
  23. package/package.json +2 -2
  24. package/skills/adversary/SKILL.md +61 -1
  25. package/skills/adversary/evals.md +79 -0
  26. package/skills/adversary/references/context-bundle-format.md +122 -0
  27. package/skills/adversary/references/oracle-mode.md +116 -0
  28. package/skills/asset-creator/SKILL.md +1 -1
  29. package/skills/audit/SKILL.md +3 -1
  30. package/skills/autopsy/SKILL.md +1 -1
  31. package/skills/ba/SKILL.md +242 -83
  32. package/skills/ba/references/context-md-format.md +136 -0
  33. package/skills/ba/references/explore-first.md +107 -0
  34. package/skills/ba/references/out-of-scope-format.md +152 -0
  35. package/skills/brainstorm/SKILL.md +78 -2
  36. package/skills/brainstorm/references/design-it-twice.md +155 -0
  37. package/skills/browser-pilot/SKILL.md +1 -1
  38. package/skills/completion-gate/SKILL.md +1 -1
  39. package/skills/constraint-check/SKILL.md +1 -1
  40. package/skills/context-engine/SKILL.md +85 -1
  41. package/skills/context-engine/references/preview-gate.md +139 -0
  42. package/skills/context-pack/SKILL.md +68 -25
  43. package/skills/context-pack/evals.md +122 -0
  44. package/skills/context-pack/references/brief-template.md +121 -0
  45. package/skills/context-pack/references/durability-rules.md +109 -0
  46. package/skills/cook/SKILL.md +5 -4
  47. package/skills/db/SKILL.md +1 -1
  48. package/skills/debug/SKILL.md +7 -4
  49. package/skills/dependency-doctor/SKILL.md +1 -1
  50. package/skills/design/SKILL.md +1 -1
  51. package/skills/doc-processor/SKILL.md +1 -1
  52. package/skills/docs/SKILL.md +1 -1
  53. package/skills/docs-seeker/SKILL.md +1 -1
  54. package/skills/fix/SKILL.md +5 -3
  55. package/skills/git/SKILL.md +1 -1
  56. package/skills/hallucination-guard/SKILL.md +1 -1
  57. package/skills/improve-architecture/SKILL.md +275 -0
  58. package/skills/improve-architecture/evals.md +145 -0
  59. package/skills/improve-architecture/references/deepening.md +87 -0
  60. package/skills/improve-architecture/references/interface-design.md +68 -0
  61. package/skills/improve-architecture/references/language.md +81 -0
  62. package/skills/improve-architecture/references/scoring.md +122 -0
  63. package/skills/integrity-check/SKILL.md +1 -1
  64. package/skills/journal/SKILL.md +34 -7
  65. package/skills/journal/references/adr-criteria.md +109 -0
  66. package/skills/logic-guardian/SKILL.md +1 -1
  67. package/skills/marketing/SKILL.md +1 -1
  68. package/skills/mcp-builder/SKILL.md +1 -1
  69. package/skills/onboard/SKILL.md +1 -1
  70. package/skills/perf/SKILL.md +1 -1
  71. package/skills/plan/SKILL.md +1 -1
  72. package/skills/preflight/SKILL.md +1 -1
  73. package/skills/research/SKILL.md +1 -1
  74. package/skills/retro/SKILL.md +1 -1
  75. package/skills/review/SKILL.md +3 -2
  76. package/skills/review-intake/SKILL.md +26 -3
  77. package/skills/safeguard/SKILL.md +1 -1
  78. package/skills/scaffold/SKILL.md +1 -1
  79. package/skills/scout/SKILL.md +33 -1
  80. package/skills/sentinel/SKILL.md +1 -1
  81. package/skills/sentinel-env/SKILL.md +1 -1
  82. package/skills/session-bridge/SKILL.md +91 -4
  83. package/skills/session-bridge/references/detach-protocol.md +111 -0
  84. package/skills/skill-forge/SKILL.md +1 -1
  85. package/skills/slides/SKILL.md +1 -1
  86. package/skills/surgeon/SKILL.md +17 -2
  87. package/skills/team/SKILL.md +3 -0
  88. package/skills/test/SKILL.md +48 -1
  89. package/skills/test/evals.md +137 -0
  90. package/skills/test/references/mocking-policy.md +121 -0
  91. package/skills/test/references/test-quality.md +124 -0
  92. package/skills/test/references/vertical-tdd.md +110 -0
  93. package/skills/trend-scout/SKILL.md +1 -1
  94. package/skills/video-creator/SKILL.md +1 -1
  95. package/skills/watchdog/SKILL.md +1 -1
  96. package/skills/worktree/SKILL.md +1 -1
@@ -4,11 +4,12 @@ description: "Context window management. Auto-triggered when context is filling
4
4
  user-invocable: false
5
5
  metadata:
6
6
  author: runedev
7
- version: "1.0.0"
7
+ version: "1.1.0"
8
8
  layer: L3
9
9
  model: haiku
10
10
  group: state
11
11
  tools: "Read, Glob, Grep"
12
+ emit: context.preview
12
13
  ---
13
14
 
14
15
  # context-engine
@@ -49,6 +50,7 @@ Context-engine also manages **behavioral mode injection** via `contexts/` direct
49
50
  - `rescue` (L1): between refactoring sessions for state persistence
50
51
  - `context-pack` (L3): when packaging context for sub-agent handoff
51
52
  - `session-bridge` (L3): coordinates with context-engine for compaction timing
53
+ - `adversary` (L2): (oracle-mode) emit `context.preview` before bundle build to gate token cost
52
54
 
53
55
  ## Execution
54
56
 
@@ -375,11 +377,90 @@ When Context Budget Warning fires, append to Context Health report:
375
377
  - **Recommendation**: Disable [server] to save ~[N]k tokens
376
378
  ```
377
379
 
380
+ ## Mode: preview (v1.1.0)
381
+
382
+ Pre-flight cost check for expensive escalations. Caller (`adversary` oracle-mode, `team` workstream spawn, `review` multi-file, `audit` cross-pack) MUST emit `context.preview` BEFORE building the bundle, so context-engine can estimate token cost and gate the dispatch against a per-caller threshold.
383
+
384
+ ### Why
385
+
386
+ Without preview, callers learn about budget overruns AFTER the bundle is built and dispatched — too late to prune. `team` parallel workstreams especially can blow $20 of Opus tokens in a single session if context bundles are unchecked.
387
+
388
+ ### Token Estimation (no tokenizer dep)
389
+
390
+ ```
391
+ estimated_tokens = total_chars × 0.25
392
+ ```
393
+
394
+ Char count includes the `[SYSTEM]` line, `[USER]` line, and all `### File N:` blocks per `references/preview-gate.md`. The 0.25 ratio is calibrated for English code/markdown — overestimates Japanese/Chinese, underestimates highly-repetitive content. Both error directions are safe (overestimate → over-cautious block; underestimate → caller still hits dispatch-time hard cap).
395
+
396
+ ### Threshold Defaults (per caller)
397
+
398
+ | Caller | warn-at (tokens) | block-at (tokens) |
399
+ |--------|------------------|-------------------|
400
+ | `adversary` oracle-mode | 50k | 100k |
401
+ | `team` parallel workstream (per worker) | 30k | 80k |
402
+ | `review` multi-file | 40k | 100k |
403
+ | `audit` cross-pack | 60k | 120k |
404
+
405
+ Caller passes its identity in the preview request; context-engine resolves to the correct threshold.
406
+
407
+ ### Action Enum
408
+
409
+ `context.preview` payload includes a single `action` field:
410
+
411
+ | Action | Meaning | Caller behavior |
412
+ |--------|---------|-----------------|
413
+ | `proceed` | Under warn threshold | Continue without warning |
414
+ | `warn` | Between warn and block | Log warning to user, continue |
415
+ | `block` | At or over block threshold | Abort dispatch, emit caller-specific failure (e.g. `oracle.failed` reason=`context_budget_exceeded`) |
416
+
417
+ ### Signal Payload Schema
418
+
419
+ ```yaml
420
+ context.preview:
421
+ caller: adversary | team | review | audit
422
+ estimated_tokens: <int>
423
+ file_count: <int>
424
+ top_5_files_by_size:
425
+ - { path: <string>, chars: <int> }
426
+ threshold:
427
+ warn_at: <int>
428
+ block_at: <int>
429
+ action: proceed | warn | block
430
+ ```
431
+
432
+ ### Step P1 — Receive request
433
+
434
+ Caller invokes context-engine with: caller-id, file list (paths + char counts), prompt char count.
435
+
436
+ ### Step P2 — Estimate
437
+
438
+ Sum total chars, multiply by 0.25, identify top 5 files by size.
439
+
440
+ ### Step P3 — Resolve threshold
441
+
442
+ Look up caller in threshold table (defaults above; override via `RUNE_CONTEXT_THRESHOLDS_<CALLER>` env var).
443
+
444
+ ### Step P4 — Determine action
445
+
446
+ ```
447
+ if estimated_tokens >= block_at: action = block
448
+ elif estimated_tokens >= warn_at: action = warn
449
+ else: action = proceed
450
+ ```
451
+
452
+ ### Step P5 — Emit
453
+
454
+ Emit `context.preview` with full payload. Caller decides whether to proceed.
455
+
456
+ See `references/preview-gate.md` for tunable points and integration with each caller.
457
+
378
458
  ## Constraints
379
459
 
380
460
  1. MUST preserve context fidelity — no summarizing away critical details
381
461
  2. MUST flag context conflicts between skills — never silently pick one
382
462
  3. MUST NOT inject stale context from previous sessions without marking it as historical
463
+ 4. (preview) MUST emit `context.preview` BEFORE bundle-building begins (not after) — late emission defeats the gate purpose
383
464
 
384
465
  ## Sharp Edges
385
466
 
@@ -394,6 +475,8 @@ Known failure modes for this skill. Check these before declaring done.
394
475
  | Not activating large-file adjustment on Python/Java codebases | MEDIUM | Track Read calls returning >500 lines; if ≥3 occur, switch to adjusted (0.8x) thresholds for the session |
395
476
  | Mid-loop compaction breaks tool_use/tool_result pair | CRITICAL | Always keep tool pairs together — splitting causes orphaned results and context corruption |
396
477
  | Mid-loop compaction without flushing state first | HIGH | session-bridge + neural-memory MUST run before compaction — losing unsaved decisions is worse than hitting context limit |
478
+ | (preview) Caller bundles before requesting preview | HIGH | Constraint 4 enforces order; reject preview-after-build calls with explicit error |
479
+ | (preview) Estimated tokens off by 2x for non-English content | LOW | Document calibration in `references/preview-gate.md`; safe both directions (block-too-eager or block-too-late but hard cap at dispatch saves us) |
397
480
 
398
481
  ## Done When
399
482
 
@@ -402,6 +485,7 @@ Known failure modes for this skill. Check these before declaring done.
402
485
  - Appropriate advisory emitted matching health level (no advisory for GREEN)
403
486
  - If RED: session-bridge called and confirmed saved before compaction signal
404
487
  - Context Health Report emitted with tool count, status, and recommendation
488
+ - (preview-mode) `context.preview` emitted with `action` ∈ `proceed | warn | block` BEFORE caller builds its bundle
405
489
 
406
490
  ## Cost Profile
407
491
 
@@ -0,0 +1,139 @@
1
+ # Context Preview Gate
2
+
3
+ ## Purpose
4
+
5
+ Pre-flight cost check for expensive escalations. Before any caller bundles a large context for dispatch (oracle-mode second-opinion, parallel workstream spawn, multi-file review, cross-pack audit), `context-engine` emits `context.preview` with a token-cost estimate and an action recommendation. The caller decides whether to proceed, warn, or abort.
6
+
7
+ ## Why
8
+
9
+ Without a preview gate:
10
+ - Callers learn about budget overruns only after dispatch — too late to prune
11
+ - `team` parallel workstreams can blow $20 of Opus tokens silently
12
+ - Users have no way to enforce per-call cost ceilings
13
+
14
+ With the preview gate:
15
+ - Costs are visible at decision time, not bill time
16
+ - Per-caller thresholds enforce different budgets per use case
17
+ - Hard `block` action prevents accidental runaway
18
+
19
+ ## Token Estimation
20
+
21
+ ```
22
+ estimated_tokens = total_chars × 0.25
23
+ ```
24
+
25
+ Where `total_chars` includes:
26
+ - The bundle's `[SYSTEM]` line
27
+ - The `[USER]` problem statement
28
+ - Every `### File N: <path>` header
29
+ - Every file body (post-truncation, post-redaction)
30
+
31
+ The `0.25` ratio is calibrated for English code/markdown:
32
+
33
+ | Content type | Calibration |
34
+ |--------------|-------------|
35
+ | English code (TypeScript/Python/JS) | accurate ±10% |
36
+ | English markdown / docs | accurate ±5% |
37
+ | Japanese / Chinese / Korean | underestimates by 30-50% |
38
+ | Highly-repetitive (lots of imports) | overestimates by 20-30% |
39
+
40
+ Both error directions are safe:
41
+ - Overestimate → over-cautious block, caller can manually override
42
+ - Underestimate → caller still hits the dispatch-time hard cap (e.g. adversary's 100k token limit) and aborts with `oracle.failed`
43
+
44
+ ## Threshold Defaults
45
+
46
+ | Caller | warn-at | block-at | Rationale |
47
+ |--------|---------|----------|-----------|
48
+ | `adversary` oracle-mode | 50,000 | 100,000 | Single-shot diagnosis; 100k matches second-model context budget |
49
+ | `team` parallel workstream (per worker) | 30,000 | 80,000 | Per-worker; total may be 5x if 5 workers spawn |
50
+ | `review` multi-file | 40,000 | 100,000 | Code review benefits from breadth; cap protects opus budget |
51
+ | `audit` cross-pack | 60,000 | 120,000 | Audit is intentionally broad; raised cap reflects intent |
52
+
53
+ ### Override
54
+
55
+ Set environment variables to override per-caller thresholds:
56
+
57
+ ```
58
+ RUNE_CONTEXT_THRESHOLDS_ADVERSARY=warn:60000,block:120000
59
+ RUNE_CONTEXT_THRESHOLDS_TEAM=warn:40000,block:100000
60
+ RUNE_CONTEXT_THRESHOLDS_REVIEW=warn:50000,block:130000
61
+ RUNE_CONTEXT_THRESHOLDS_AUDIT=warn:80000,block:150000
62
+ ```
63
+
64
+ ## Action Decision
65
+
66
+ ```
67
+ if estimated_tokens >= block_at:
68
+ action = "block"
69
+ elif estimated_tokens >= warn_at:
70
+ action = "warn"
71
+ else:
72
+ action = "proceed"
73
+ ```
74
+
75
+ ## Caller Integration
76
+
77
+ ### `adversary` oracle-mode
78
+
79
+ ```
80
+ Phase 0 (pre-bundle): emit context.preview { caller: adversary, files: [...], prompt: "..." }
81
+ context-engine returns { action: "proceed" } → continue with bundle build
82
+ context-engine returns { action: "warn" } → log warning, continue
83
+ context-engine returns { action: "block" } → abort, emit oracle.failed reason=context_budget_exceeded
84
+ ```
85
+
86
+ ### `team` parallel workstream
87
+
88
+ ```
89
+ Phase 2 ASSIGN (per worker): emit context.preview { caller: team, files: [...] }
90
+ proceed → spawn worker
91
+ warn → log warning, spawn worker
92
+ block → reduce worker scope or split into 2 smaller workers
93
+ ```
94
+
95
+ ### `review` multi-file
96
+
97
+ ```
98
+ Entry step: emit context.preview { caller: review, files: [...] }
99
+ proceed → run review
100
+ warn → log warning, run review
101
+ block → ask user to narrow file scope (e.g. specific subdirectory)
102
+ ```
103
+
104
+ ### `audit` cross-pack
105
+
106
+ ```
107
+ Entry step: emit context.preview { caller: audit, files: [...] }
108
+ proceed → run audit
109
+ warn → log warning, run audit
110
+ block → reduce audit scope (e.g. one pack at a time)
111
+ ```
112
+
113
+ ## Signal Payload
114
+
115
+ ```yaml
116
+ context.preview:
117
+ caller: adversary | team | review | audit
118
+ estimated_tokens: 73000
119
+ file_count: 8
120
+ top_5_files_by_size:
121
+ - { path: "src/auth/login.ts", chars: 12400 }
122
+ - { path: "src/middleware/auth.ts", chars: 9800 }
123
+ - { path: "src/services/session.ts", chars: 8200 }
124
+ - { path: "tests/auth.test.ts", chars: 6100 }
125
+ - { path: "src/types/user.ts", chars: 4500 }
126
+ threshold:
127
+ warn_at: 50000
128
+ block_at: 100000
129
+ action: warn
130
+ ```
131
+
132
+ ## Failure Modes
133
+
134
+ | Symptom | Reason | Mitigation |
135
+ |---------|--------|------------|
136
+ | Caller bundles before preview | Caller didn't follow contract | context-engine rejects late preview requests with explicit error |
137
+ | Estimate way off for non-English content | Tokenizer ratio assumes English | Document limitation; safe both directions due to dispatch-time hard cap |
138
+ | Block action ignored by caller | Caller bug | Each caller's Done When MUST verify `action != block` before dispatch |
139
+ | Threshold env-var malformed | User typo | context-engine logs warning, falls back to default |
@@ -4,7 +4,7 @@ description: "Creates structured handoff briefings between agents. Use when dele
4
4
  user-invocable: false
5
5
  metadata:
6
6
  author: runedev
7
- version: "0.1.0"
7
+ version: "0.2.0"
8
8
  layer: L3
9
9
  model: haiku
10
10
  group: state
@@ -52,12 +52,13 @@ When a parent agent delegates work to a subagent, critical context gets lost —
52
52
  ## Workflow
53
53
 
54
54
  1. **COLLECT** — Gather context from the current conversation:
55
- - Task description and user intent
55
+ - Task description and user intent (verb-led behavioral phrasing)
56
56
  - Decisions already made (and WHY)
57
57
  - Constraints and hard-stops
58
58
  - Failed attempts (what NOT to do)
59
59
  - Files already read or modified
60
60
  - Current progress state
61
+ - **Type Surface** — types / function signatures / contracts that callers cross. These are the durable spine of the brief.
61
62
 
62
63
  2. **COMPRESS** — Reduce to essential information:
63
64
  - Strip conversational noise
@@ -65,46 +66,74 @@ When a parent agent delegates work to a subagent, critical context gets lost —
65
66
  - Prioritize by relevance to the delegated task
66
67
  - Target: <500 tokens for simple tasks, <1500 tokens for complex
67
68
 
68
- 3. **STRUCTURE** — Format as a context packet (see Output Format)
69
+ 3. **STRUCTURE** — Format as a context packet (v2 — see Output Format and [references/brief-template.md](references/brief-template.md))
69
70
 
70
71
  4. **VALIDATE** — Check packet completeness:
71
72
  - Does it include the task goal?
72
73
  - Does it include constraints that could cause failure?
73
74
  - Does it include what was already tried?
75
+ - Does it include `### Out of scope`? (mandatory)
76
+ - Does it include `### Type Surface` (mandatory if task >= 300 tokens)?
74
77
  - Is it small enough for the target agent's context budget?
75
78
 
76
- ## Output Format
79
+ 5. **PHASE 4.5 — SMELL TESTS** — Run mechanical regex gates before emit. See [references/durability-rules.md](references/durability-rules.md).
80
+
81
+ | Regex | Tier | Reason |
82
+ |-------|------|--------|
83
+ | `\b\S+\.[a-z]{1,4}:\d+\b` | BLOCK | file:line reference (e.g., `login.ts:42`) — line numbers go stale |
84
+ | `^- \S*[\\/]\S+\.(ts\|js\|py\|go\|rs\|java)\b` outside `### Files Touched` | BLOCK | Path-only bullet in narrative |
85
+ | `\b(line \|on line )\d+\b` | BLOCK | "line 42" / "on line 100" |
86
+ | `\b(src\|lib\|app)/\S+` in narrative paragraphs | WARN | Path mention; verify it belongs in Files Touched section |
87
+
88
+ <HARD-GATE>
89
+ Any BLOCK-tier match → DO NOT emit. Rewrite the offending lines to use type/function/module names.
90
+ Missing `### Out of scope` section → DO NOT emit (completion-gate rejects).
91
+ Missing `### Type Surface` for tasks >= 300 tokens → DO NOT emit.
92
+ </HARD-GATE>
93
+
94
+ 6. **EMIT** — Send the validated packet to the receiving agent.
95
+
96
+ ## Output Format (v2)
77
97
 
78
98
  ```markdown
79
99
  ## Context Packet
80
100
 
81
- **Task**: [One-line description of what the subagent must do]
82
- **Parent**: [Which skill/agent is delegating]
83
- **Scope**: [Specific files, modules, or boundaries]
101
+ **Task**: [One-line behavioral description, verb-led]
102
+ **Parent**: [delegating skill]
103
+ **Scope**: [type names / module names — NOT file paths]
84
104
 
85
105
  ### Decisions Made
86
- - [Decision 1]: [choice] because [reason]
87
- - [Decision 2]: [choice] — because [reason]
106
+ - [Decision]: chose [X] over [Y] because [reason]
88
107
 
89
108
  ### Constraints
90
- - MUST: [requirement 1]
91
- - MUST NOT: [prohibition 1]
92
- - BLOCKED BY: [dependency, if any]
109
+ - MUST: [behavioral assertion]
110
+ - MUST NOT: [behavioral prohibition]
111
+ - BLOCKED BY: [contract dependency, not file path]
93
112
 
94
113
  ### Already Tried
95
- - [Approach that failed] — [why it failed]
114
+ - [approach] — [observable failure mode]
96
115
 
97
- ### Files Touched
98
- - `path/to/file.ts` [what was done / what needs doing]
116
+ ### Type Surface (durable)
117
+ - `TypeName { field: type }` [what it represents]
118
+ - `Module.method(input: T): Result<O, E>` — [contract]
99
119
 
100
- ### Success Criteria
101
- - [ ] [Verifiable criterion 1]
102
- - [ ] [Verifiable criterion 2]
120
+ ### Files Touched (locator-only, may rename)
121
+ - `path/to/file.ts` (TypeName, Module.method) — [behavioral hint]
122
+
123
+ ### Acceptance Criteria
124
+ - [ ] [verb-led testable statement starting with: accepts, rejects, produces, notifies, persists, retries, times-out, validates, returns, dispatches, redirects, throws, logs, increments, decrements, retrieves, emits, caches, invalidates, authenticates]
125
+ - [ ] ...
126
+
127
+ ### Out of scope
128
+ - [Thing the receiver should NOT do]
129
+ - (or "(none)" if explicitly empty)
103
130
 
104
131
  ### Progress
105
- - [What's done so far, if partial handoff]
132
+ - [partial state if mid-handoff — omit if fresh start]
106
133
  ```
107
134
 
135
+ Full template + worked examples: [references/brief-template.md](references/brief-template.md).
136
+
108
137
  ## Returns
109
138
 
110
139
  | Field | Type | Description |
@@ -116,32 +145,46 @@ When a parent agent delegates work to a subagent, critical context gets lost —
116
145
 
117
146
  ## Constraints
118
147
 
119
- 1. MUST include task goal and success criteria — subagent needs to know when it's done
148
+ 1. MUST include task goal and acceptance criteria — subagent needs to know when it's done
120
149
  2. MUST include failed attempts — prevents subagent from repeating mistakes
121
150
  3. MUST include hard-stop constraints — prevents constraint violations in delegated work
122
151
  4. MUST NOT exceed 2000 tokens — context packets that are too large defeat the purpose
123
- 5. MUST NOT include full file contents — use file paths and summaries instead
152
+ 5. MUST NOT include full file contents — use type names + summaries instead
124
153
  6. MUST NOT fabricate context — only include information from the actual conversation
154
+ 7. MUST emit `### Out of scope` section — empty `(none)` allowed, missing section is rejected by completion-gate
155
+ 8. MUST emit `### Type Surface` section for tasks >= 300 tokens — durable contract spine
156
+ 9. MUST pass all BLOCK-tier smell tests — no file:line references, no "line N", no narrative path-only bullets
157
+ 10. MUST use behavior verbs in Acceptance Criteria — shape verbs ("is defined", "has property") rejected
125
158
 
126
159
  ## Sharp Edges
127
160
 
128
161
  | Failure Mode | Severity | Mitigation |
129
162
  |---|---|---|
130
- | Packet too large (>2000 tokens) | HIGH | Compress aggressively — file paths not contents, decisions not discussions |
163
+ | Packet too large (>2000 tokens) | HIGH | Compress aggressively — type names not file contents, decisions not discussions |
131
164
  | Missing constraint causes subagent violation | CRITICAL | Always scan for MUST/MUST NOT in parent conversation |
132
165
  | Stale context from prior session included | MEDIUM | Cross-check session-bridge state with current files |
133
166
  | Over-constraining subagent with parent's approach | MEDIUM | Include constraints and goals, not implementation approach (unless approach is the constraint) |
167
+ | File:line references in packet (rotting briefs) | CRITICAL | Phase 4.5 BLOCK gate — regex `\b\S+\.[a-z]{1,4}:\d+\b` catches them; rewrite to type/function names |
168
+ | Narrative paragraphs with bare paths (`src/auth/`) | MEDIUM | WARN tier — surface and rewrite or move to Files Touched table |
169
+ | Missing Type Surface section for non-trivial task | HIGH | Mandatory for tasks >= 300 tokens; the durable spine is what survives file moves |
170
+ | Missing Out of scope section | HIGH | Always required (even "(none)"); completion-gate rejects briefs without it |
171
+ | Acceptance Criteria using shape verbs ("is defined", "has property") | MEDIUM | Rewrite to behavior verbs from the whitelist |
134
172
 
135
173
  ## Self-Validation
136
174
 
137
175
  ```
138
176
  SELF-VALIDATION (run before emitting output):
139
- - [ ] Packet includes a clear task goal
140
- - [ ] Packet includes success criteria (verifiable, not vague)
177
+ - [ ] Packet includes a clear task goal (verb-led)
178
+ - [ ] Packet includes acceptance criteria (verb-led, testable, not vague)
141
179
  - [ ] All MUST/MUST NOT constraints from parent are present
142
180
  - [ ] Failed attempts are listed (if any exist)
143
181
  - [ ] Token estimate is under 2000
144
- - [ ] No full file contents embedded (paths only)
182
+ - [ ] No full file contents embedded (type names + paths only)
183
+ - [ ] No file:line references anywhere (regex check)
184
+ - [ ] No bare-path narrative bullets outside Files Touched
185
+ - [ ] ### Out of scope section present (even if "(none)")
186
+ - [ ] ### Type Surface section present (if task >= 300 tokens)
187
+ - [ ] Files Touched entries include (TypeName, function) annotations
145
188
  IF ANY check fails → fix before reporting done. Do NOT defer to completion-gate.
146
189
  ```
147
190
 
@@ -0,0 +1,122 @@
1
+ # Eval Scenarios — `context-pack` skill
2
+
3
+ ## Eval: E01 — happy-path good packet emits cleanly
4
+
5
+ ### Prompt
6
+ Cook calls context-pack to hand off a feature: "Add device_id field to login flow." Decisions: track at login, optional field. Constraints: preserve backward compat, don't touch rate limits.
7
+
8
+ ### Expected Reasoning
9
+ Agent emits a v2-format packet with all required sections (Task / Parent / Scope / Decisions / Constraints / Type Surface / Files Touched / Acceptance Criteria / Out of scope). Acceptance criteria use behavior verbs. Type Surface lists `LoginInput`, `AuthService.authenticate`, `Session`. Files Touched annotated with type names.
10
+
11
+ ### Must Include
12
+ - `### Type Surface (durable)` section with at least 2 type entries
13
+ - `### Out of scope` section (even if "(none)")
14
+ - All ACs start with whitelisted behavior verbs
15
+ - Files Touched entries include `(TypeName, function)` annotations
16
+
17
+ ### Must NOT
18
+ - Reference file:line (e.g., `login.ts:42`)
19
+ - Use shape verbs ("should be defined", "has property")
20
+ - Skip Out of scope section
21
+
22
+ ### Category
23
+ happy-path
24
+
25
+ ---
26
+
27
+ ## Eval: E02 — file:line BLOCK violation caught
28
+
29
+ ### Prompt
30
+ A draft packet contains: "Modify the function at `src/auth/login.ts:42` to handle the new field."
31
+
32
+ ### Expected Reasoning
33
+ Agent runs the smell-test regex `\b\S+\.[a-z]{1,4}:\d+\b` and matches `login.ts:42`. BLOCK tier. Refuses to emit. Rewrites the prose to use type/function names: "Modify `AuthService.authenticate` to handle the new field."
34
+
35
+ ### Must Include
36
+ - Smell-test BLOCK verdict surfaced
37
+ - Specific regex match cited
38
+ - Rewrite suggestion that uses behavioral language
39
+
40
+ ### Must NOT
41
+ - Emit the packet with the file:line still present
42
+ - "Just this once" exception language
43
+
44
+ ### Category
45
+ adversarial
46
+
47
+ ---
48
+
49
+ ## Eval: E03 — narrative path WARN handling
50
+
51
+ ### Prompt
52
+ A draft packet contains a narrative paragraph: "The work is centered around `src/auth/`, particularly the login flow."
53
+
54
+ ### Expected Reasoning
55
+ Agent matches narrative path regex (WARN tier). Surfaces the warning, asks: is this narrative the right section? If it belongs in `### Files Touched`, move it; if it stays in narrative, rewrite to a type/module name.
56
+
57
+ ### Must Include
58
+ - WARN verdict (not BLOCK — narrative paths are softer)
59
+ - Suggestion to either move or rewrite
60
+ - No automatic emission until resolved
61
+
62
+ ### Must NOT
63
+ - BLOCK on a WARN-tier match
64
+ - Auto-rewrite without surfacing
65
+
66
+ ### Category
67
+ edge-case
68
+
69
+ ---
70
+
71
+ ## Eval: E04 — missing Out of scope section
72
+
73
+ ### Prompt
74
+ A draft packet has all sections except Out of scope.
75
+
76
+ ### Expected Reasoning
77
+ Agent recognizes mandatory section. Either prompts the parent for the out-of-scope list, OR explicitly emits `### Out of scope\n- (none)` if the parent confirms there's nothing to exclude. Never silently omits.
78
+
79
+ ### Must Include
80
+ - Either an Out of scope section (potentially empty with explicit "(none)")
81
+ - OR a request back to parent for the exclusion list
82
+ - Reference to Phase 4.5 / `completion-gate` rejection rule
83
+
84
+ ### Must NOT
85
+ - Emit the packet without Out of scope
86
+ - Auto-fill with assumed exclusions
87
+
88
+ ### Category
89
+ adversarial
90
+
91
+ ---
92
+
93
+ ## Eval: E05 — Type Surface optional for short task
94
+
95
+ ### Prompt
96
+ A simple bug fix handoff: "Fix typo in error message — '404 Note Found' → '404 Not Found'." Task body is ~80 tokens.
97
+
98
+ ### Expected Reasoning
99
+ Agent recognizes that the task is below the 300-token threshold where Type Surface becomes mandatory. Emits a packet without Type Surface, but still includes Out of scope and behavioral ACs.
100
+
101
+ ### Must Include
102
+ - Out of scope section (mandatory regardless of task size)
103
+ - AC with behavior verb (e.g., "Returns the corrected error message on 404")
104
+ - Note in packet header that Type Surface is omitted because task is below threshold
105
+
106
+ ### Must NOT
107
+ - Force a Type Surface section for a one-line text fix
108
+ - Skip Out of scope (still mandatory)
109
+
110
+ ### Category
111
+ edge-case
112
+
113
+ ---
114
+
115
+ ## Eval Coverage
116
+
117
+ | Category | Count | Status |
118
+ |---|---|---|
119
+ | happy-path | 1 | ✅ E01 |
120
+ | edge-case | 2 | ✅ E03, E05 |
121
+ | adversarial | 2 | ✅ E02, E04 |
122
+ | **Total** | **5** | **✅ above minimum (4)** |
@@ -0,0 +1,121 @@
1
+ # Brief Template (v2)
2
+
3
+ Use this verbatim. Receivers expect every section. Sections marked optional may be omitted only if there's nothing to record (not because the writer didn't bother).
4
+
5
+ ```markdown
6
+ ## Context Packet
7
+
8
+ **Task**: [One-line behavioral description, verb-led: "Add rate limiting to login route"]
9
+ **Parent**: [delegating skill — e.g., cook]
10
+ **Scope**: [type names / module names — NOT file paths]
11
+
12
+ ### Decisions Made
13
+ - [Decision]: chose [X] over [Y] because [reason]
14
+ - ...
15
+
16
+ ### Constraints
17
+ - MUST: [behavioral assertion — "preserve existing 1hr rate-limit window"]
18
+ - MUST NOT: [behavioral prohibition — "modify the audit log writer"]
19
+ - BLOCKED BY: [contract dependency — "the auth.token-refresh contract finalized in PR #42"]
20
+
21
+ ### Already Tried
22
+ - [Approach] — [observable failure mode]
23
+
24
+ ### Type Surface (durable)
25
+ - `TypeName { field: type; field: type }` — what it represents
26
+ - `Module.method(input: T): Result<O, E>` — the contract
27
+ - `ErrorEnum = "case_a" | "case_b"` — what callers switch on
28
+
29
+ ### Files Touched (locator-only, may rename)
30
+ - `path/to/file.ts` (TypeName, Module.method) — [behavioral hint]
31
+ - ...
32
+
33
+ ### Acceptance Criteria
34
+ - [ ] [Verb-led testable statement — "Rejects login attempts with 429 after 5 failures within 1 hour"]
35
+ - [ ] ...
36
+
37
+ ### Out of scope
38
+ - [Thing the receiver should NOT do]
39
+ - [Adjacent feature that might seem related but is separate]
40
+ - (or "(none)" if nothing to exclude)
41
+
42
+ ### Progress
43
+ - [What's done so far, if partial handoff — omit if fresh start]
44
+ ```
45
+
46
+ ## Behavioral verb whitelist
47
+
48
+ Every Acceptance Criterion must start with one of these:
49
+
50
+ ```
51
+ accepts dispatches logs redirects retrieves
52
+ rejects throws increments retries returns
53
+ produces times-out decrements notifies validates
54
+ persists emits caches invalidates authenticates
55
+ ```
56
+
57
+ Verbs not on the whitelist may still be valid; check whether the criterion describes *observable behavior* (good) or *shape* ("is defined", "has property", "exists") — shape verbs are banned.
58
+
59
+ ## Worked example
60
+
61
+ ### ✅ Good packet
62
+
63
+ ```markdown
64
+ ## Context Packet
65
+
66
+ **Task**: Add device tracking to login flow
67
+ **Parent**: cook
68
+ **Scope**: AuthService, LoginInput, sessions table
69
+
70
+ ### Decisions Made
71
+ - Track device_id at login: chose passing through to session storage over hashing in-app, because compliance requires preserving raw values for audit window
72
+ - Optional field: chose nullable rather than required, because mobile clients prior to v3.2 don't send it
73
+
74
+ ### Constraints
75
+ - MUST: preserve backward-compatible login for clients without device_id
76
+ - MUST NOT: change rate-limit window (currently 1hr)
77
+
78
+ ### Already Tried
79
+ - Storing in JWT claims — rejected because tokens grow past mobile size limit
80
+
81
+ ### Type Surface (durable)
82
+ - `LoginInput { email: string; password: string; device_id?: string }` — payload accepted by login route
83
+ - `AuthService.authenticate(input: LoginInput): Result<Session, AuthError>` — primary contract
84
+ - `Session { user_id: string; created_at: Date; device_id: string | null }` — issued on success
85
+
86
+ ### Files Touched (locator-only, may rename)
87
+ - `src/auth/login.ts` (LoginInput, AuthService.authenticate) — route handler
88
+ - `src/db/migrations/sessions.sql` (sessions table) — schema
89
+
90
+ ### Acceptance Criteria
91
+ - [ ] Persists device_id to sessions table when login succeeds and device_id is provided
92
+ - [ ] Persists null when device_id is absent
93
+ - [ ] Returns AuthError 'invalid_credentials' on bad password (existing behavior unchanged)
94
+
95
+ ### Out of scope
96
+ - Changing rate-limit window
97
+ - Updating mobile client SDKs
98
+ - Audit log writer
99
+ ```
100
+
101
+ ### ❌ Bad packet (would fail smell tests)
102
+
103
+ ```markdown
104
+ ## Context Packet
105
+
106
+ **Task**: fix the login
107
+
108
+ **Files**: src/auth/login.ts:42, src/types.ts:18
109
+
110
+ The function around line 100 has a bug. Add a device field. See `src/handlers/`.
111
+ ```
112
+
113
+ Failures:
114
+ - No section structure
115
+ - File:line references (`login.ts:42`)
116
+ - "line 100" — line-number reference
117
+ - "around line" — narrative path
118
+ - No Type Surface
119
+ - No Out of scope
120
+ - No Acceptance Criteria with behavior verbs
121
+ - Vague task description ("fix the login")