@rune-kit/rune 2.10.0 → 2.12.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 (240) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +65 -6
  3. package/commands/rune.md +168 -168
  4. package/compiler/__tests__/detect-invariants.test.js +136 -0
  5. package/compiler/__tests__/doctor-mesh.test.js +229 -0
  6. package/compiler/__tests__/hook-dispatch.test.js +91 -0
  7. package/compiler/__tests__/hooks-antigravity.test.js +118 -0
  8. package/compiler/__tests__/hooks-cursor.test.js +139 -0
  9. package/compiler/__tests__/hooks-install.test.js +305 -0
  10. package/compiler/__tests__/hooks-merge.test.js +204 -0
  11. package/compiler/__tests__/hooks-tiers.test.js +519 -0
  12. package/compiler/__tests__/hooks-windsurf.test.js +115 -0
  13. package/compiler/__tests__/inject-claude-md.test.js +152 -0
  14. package/compiler/__tests__/load-invariants.test.js +408 -0
  15. package/compiler/__tests__/onboard-invariants.test.js +240 -0
  16. package/compiler/adapters/hooks/antigravity.js +140 -0
  17. package/compiler/adapters/hooks/claude.js +166 -0
  18. package/compiler/adapters/hooks/cursor.js +191 -0
  19. package/compiler/adapters/hooks/index.js +82 -0
  20. package/compiler/adapters/hooks/tier-emitter.js +182 -0
  21. package/compiler/adapters/hooks/windsurf.js +202 -0
  22. package/compiler/bin/rune.js +196 -6
  23. package/compiler/commands/hook-dispatch.js +87 -0
  24. package/compiler/commands/hooks/install.js +120 -0
  25. package/compiler/commands/hooks/merge.js +211 -0
  26. package/compiler/commands/hooks/presets.js +116 -0
  27. package/compiler/commands/hooks/status.js +112 -0
  28. package/compiler/commands/hooks/tiers.js +221 -0
  29. package/compiler/commands/hooks/uninstall.js +94 -0
  30. package/compiler/doctor.js +236 -0
  31. package/contexts/dev.md +34 -34
  32. package/contexts/research.md +43 -43
  33. package/contexts/review.md +55 -55
  34. package/extensions/ai-ml/PACK.md +88 -88
  35. package/extensions/ai-ml/skills/ai-agents.md +172 -172
  36. package/extensions/ai-ml/skills/code-sandbox.md +187 -187
  37. package/extensions/ai-ml/skills/deep-research.md +146 -146
  38. package/extensions/ai-ml/skills/embedding-search.md +66 -66
  39. package/extensions/ai-ml/skills/fine-tuning-guide.md +74 -74
  40. package/extensions/ai-ml/skills/llm-architect.md +125 -125
  41. package/extensions/ai-ml/skills/llm-integration.md +64 -64
  42. package/extensions/ai-ml/skills/prompt-patterns.md +72 -72
  43. package/extensions/ai-ml/skills/rag-patterns.md +66 -66
  44. package/extensions/ai-ml/skills/web-extraction.md +114 -114
  45. package/extensions/analytics/PACK.md +92 -92
  46. package/extensions/analytics/skills/ab-testing.md +72 -72
  47. package/extensions/analytics/skills/dashboard-patterns.md +83 -83
  48. package/extensions/analytics/skills/data-validation.md +68 -68
  49. package/extensions/analytics/skills/funnel-analysis.md +81 -81
  50. package/extensions/analytics/skills/sql-patterns.md +57 -57
  51. package/extensions/analytics/skills/statistical-analysis.md +79 -79
  52. package/extensions/analytics/skills/tracking-setup.md +71 -71
  53. package/extensions/backend/PACK.md +104 -104
  54. package/extensions/backend/skills/api-patterns.md +84 -84
  55. package/extensions/backend/skills/async-pipeline.md +193 -193
  56. package/extensions/backend/skills/auth-patterns.md +97 -97
  57. package/extensions/backend/skills/background-jobs.md +133 -133
  58. package/extensions/backend/skills/caching-patterns.md +108 -108
  59. package/extensions/backend/skills/cli-generation.md +133 -133
  60. package/extensions/backend/skills/database-patterns.md +87 -87
  61. package/extensions/backend/skills/middleware-patterns.md +104 -104
  62. package/extensions/chrome-ext/PACK.md +93 -93
  63. package/extensions/chrome-ext/skills/cws-preflight.md +143 -143
  64. package/extensions/chrome-ext/skills/cws-publish.md +104 -104
  65. package/extensions/chrome-ext/skills/ext-ai-integration.md +251 -251
  66. package/extensions/chrome-ext/skills/ext-messaging.md +139 -139
  67. package/extensions/chrome-ext/skills/ext-storage.md +133 -133
  68. package/extensions/chrome-ext/skills/mv3-scaffold.md +164 -164
  69. package/extensions/content/PACK.md +96 -96
  70. package/extensions/content/skills/blog-patterns.md +88 -88
  71. package/extensions/content/skills/cms-integration.md +131 -131
  72. package/extensions/content/skills/content-scoring.md +107 -107
  73. package/extensions/content/skills/i18n.md +83 -83
  74. package/extensions/content/skills/mdx-authoring.md +137 -137
  75. package/extensions/content/skills/reference.md +1014 -1014
  76. package/extensions/content/skills/seo-patterns.md +67 -67
  77. package/extensions/content/skills/video-repurpose.md +153 -153
  78. package/extensions/devops/PACK.md +101 -101
  79. package/extensions/devops/skills/chaos-testing.md +67 -67
  80. package/extensions/devops/skills/ci-cd.md +75 -75
  81. package/extensions/devops/skills/docker.md +58 -58
  82. package/extensions/devops/skills/edge-serverless.md +163 -163
  83. package/extensions/devops/skills/infra-as-code.md +158 -158
  84. package/extensions/devops/skills/kubernetes.md +110 -110
  85. package/extensions/devops/skills/monitoring.md +57 -57
  86. package/extensions/devops/skills/server-setup.md +64 -64
  87. package/extensions/devops/skills/ssl-domain.md +42 -42
  88. package/extensions/ecommerce/PACK.md +116 -116
  89. package/extensions/ecommerce/skills/cart-system.md +79 -79
  90. package/extensions/ecommerce/skills/inventory-mgmt.md +102 -102
  91. package/extensions/ecommerce/skills/order-management.md +126 -126
  92. package/extensions/ecommerce/skills/payment-integration.md +472 -472
  93. package/extensions/ecommerce/skills/shopify-dev.md +69 -69
  94. package/extensions/ecommerce/skills/subscription-billing.md +93 -93
  95. package/extensions/ecommerce/skills/tax-compliance.md +117 -117
  96. package/extensions/gamedev/PACK.md +142 -142
  97. package/extensions/gamedev/skills/asset-pipeline.md +74 -74
  98. package/extensions/gamedev/skills/audio-system.md +129 -129
  99. package/extensions/gamedev/skills/camera-system.md +87 -87
  100. package/extensions/gamedev/skills/ecs.md +98 -98
  101. package/extensions/gamedev/skills/game-loops.md +72 -72
  102. package/extensions/gamedev/skills/input-system.md +199 -199
  103. package/extensions/gamedev/skills/multiplayer.md +180 -180
  104. package/extensions/gamedev/skills/particles.md +105 -105
  105. package/extensions/gamedev/skills/physics-engine.md +89 -89
  106. package/extensions/gamedev/skills/scene-management.md +146 -146
  107. package/extensions/gamedev/skills/threejs-patterns.md +90 -90
  108. package/extensions/gamedev/skills/webgl.md +71 -71
  109. package/extensions/mobile/PACK.md +106 -106
  110. package/extensions/mobile/skills/app-store-connect.md +152 -152
  111. package/extensions/mobile/skills/app-store-prep.md +66 -66
  112. package/extensions/mobile/skills/deep-linking.md +109 -109
  113. package/extensions/mobile/skills/flutter.md +60 -60
  114. package/extensions/mobile/skills/ios-build-pipeline.md +142 -142
  115. package/extensions/mobile/skills/native-bridge.md +66 -66
  116. package/extensions/mobile/skills/ota-updates.md +97 -97
  117. package/extensions/mobile/skills/push-notifications.md +111 -111
  118. package/extensions/mobile/skills/react-native.md +82 -82
  119. package/extensions/saas/PACK.md +116 -116
  120. package/extensions/saas/skills/billing-integration.md +200 -200
  121. package/extensions/saas/skills/feature-flags.md +130 -130
  122. package/extensions/saas/skills/multi-tenant.md +103 -103
  123. package/extensions/saas/skills/onboarding-flow.md +139 -139
  124. package/extensions/saas/skills/subscription-flow.md +95 -95
  125. package/extensions/saas/skills/team-management.md +144 -144
  126. package/extensions/security/PACK.md +99 -99
  127. package/extensions/security/skills/api-security.md +140 -140
  128. package/extensions/security/skills/compliance.md +68 -68
  129. package/extensions/security/skills/owasp-audit.md +64 -64
  130. package/extensions/security/skills/pentest-patterns.md +77 -77
  131. package/extensions/security/skills/secret-mgmt.md +65 -65
  132. package/extensions/security/skills/supply-chain.md +65 -65
  133. package/extensions/trading/PACK.md +80 -80
  134. package/extensions/trading/skills/chart-components.md +55 -55
  135. package/extensions/trading/skills/experiment-loop.md +125 -125
  136. package/extensions/trading/skills/fintech-patterns.md +47 -47
  137. package/extensions/trading/skills/indicator-library.md +58 -58
  138. package/extensions/trading/skills/quant-analysis.md +111 -111
  139. package/extensions/trading/skills/realtime-data.md +58 -58
  140. package/extensions/trading/skills/trade-logic.md +104 -104
  141. package/extensions/ui/PACK.md +130 -130
  142. package/extensions/ui/skills/a11y-audit.md +91 -91
  143. package/extensions/ui/skills/animation-patterns.md +127 -127
  144. package/extensions/ui/skills/component-patterns.md +100 -100
  145. package/extensions/ui/skills/design-decision.md +108 -108
  146. package/extensions/ui/skills/design-system.md +68 -68
  147. package/extensions/ui/skills/landing-patterns.md +155 -155
  148. package/extensions/ui/skills/palette-picker.md +173 -173
  149. package/extensions/ui/skills/react-health.md +90 -90
  150. package/extensions/ui/skills/type-system.md +125 -125
  151. package/extensions/ui/skills/web-vitals.md +153 -153
  152. package/extensions/zalo/PACK.md +145 -145
  153. package/extensions/zalo/skills/zalo-oa-mcp.md +317 -317
  154. package/extensions/zalo/skills/zalo-oa-messaging.md +429 -429
  155. package/extensions/zalo/skills/zalo-oa-setup.md +236 -236
  156. package/extensions/zalo/skills/zalo-oa-webhook.md +189 -189
  157. package/extensions/zalo/skills/zalo-personal-messaging.md +194 -194
  158. package/extensions/zalo/skills/zalo-personal-setup.md +153 -153
  159. package/extensions/zalo/skills/zalo-rate-guard.md +219 -219
  160. package/hooks/auto-format/index.cjs +48 -48
  161. package/hooks/hooks.json +111 -111
  162. package/hooks/post-session-reflect/index.cjs +189 -189
  163. package/hooks/pre-compact/index.cjs +95 -95
  164. package/hooks/run-hook.cmd +1 -1
  165. package/hooks/secrets-scan/index.cjs +100 -100
  166. package/hooks/session-start/index.cjs +71 -71
  167. package/hooks/typecheck/index.cjs +65 -65
  168. package/package.json +63 -63
  169. package/references/ui-pro-max-data/LICENSE-UI-PRO-MAX +21 -21
  170. package/references/ui-pro-max-data/charts.csv +26 -26
  171. package/references/ui-pro-max-data/colors.csv +161 -161
  172. package/references/ui-pro-max-data/styles.csv +68 -68
  173. package/references/ui-pro-max-data/typography.csv +74 -74
  174. package/references/ui-pro-max-data/ui-reasoning.csv +162 -162
  175. package/references/ui-pro-max-data/ux-guidelines.csv +99 -99
  176. package/skills/adversary/SKILL.md +283 -283
  177. package/skills/asset-creator/SKILL.md +157 -157
  178. package/skills/audit/SKILL.md +147 -2
  179. package/skills/autopsy/SKILL.md +335 -335
  180. package/skills/ba/SKILL.md +85 -1
  181. package/skills/brainstorm/SKILL.md +380 -342
  182. package/skills/browser-pilot/SKILL.md +169 -168
  183. package/skills/constraint-check/SKILL.md +165 -165
  184. package/skills/context-engine/SKILL.md +408 -404
  185. package/skills/cook/SKILL.md +917 -863
  186. package/skills/db/SKILL.md +273 -273
  187. package/skills/debug/SKILL.md +465 -465
  188. package/skills/dependency-doctor/SKILL.md +265 -235
  189. package/skills/deploy/SKILL.md +274 -231
  190. package/skills/design/DESIGN-REFERENCE.md +365 -365
  191. package/skills/design/SKILL.md +590 -589
  192. package/skills/doc-processor/SKILL.md +254 -254
  193. package/skills/docs/SKILL.md +374 -374
  194. package/skills/docs-seeker/SKILL.md +178 -177
  195. package/skills/fix/SKILL.md +332 -330
  196. package/skills/git/SKILL.md +339 -339
  197. package/skills/hallucination-guard/SKILL.md +220 -219
  198. package/skills/incident/SKILL.md +254 -253
  199. package/skills/integrity-check/SKILL.md +169 -169
  200. package/skills/journal/SKILL.md +241 -240
  201. package/skills/launch/SKILL.md +344 -344
  202. package/skills/logic-guardian/SKILL.md +269 -251
  203. package/skills/marketing/SKILL.md +351 -289
  204. package/skills/mcp-builder/SKILL.md +425 -425
  205. package/skills/neural-memory/SKILL.md +359 -362
  206. package/skills/onboard/SKILL.md +432 -403
  207. package/skills/onboard/references/invariants-template.md +76 -0
  208. package/skills/onboard/scripts/detect-invariants.js +439 -0
  209. package/skills/onboard/scripts/inject-claude-md.js +150 -0
  210. package/skills/onboard/scripts/onboard-invariants.js +194 -0
  211. package/skills/perf/SKILL.md +347 -346
  212. package/skills/plan/SKILL.md +435 -428
  213. package/skills/preflight/SKILL.md +415 -415
  214. package/skills/problem-solver/SKILL.md +380 -284
  215. package/skills/rescue/SKILL.md +474 -474
  216. package/skills/research/SKILL.md +4 -0
  217. package/skills/retro/SKILL.md +3 -1
  218. package/skills/review/SKILL.md +614 -588
  219. package/skills/review-intake/SKILL.md +249 -249
  220. package/skills/safeguard/SKILL.md +200 -200
  221. package/skills/sast/SKILL.md +190 -190
  222. package/skills/scaffold/SKILL.md +328 -287
  223. package/skills/scope-guard/SKILL.md +183 -180
  224. package/skills/scout/SKILL.md +269 -263
  225. package/skills/sentinel/SKILL.md +384 -381
  226. package/skills/sentinel-env/SKILL.md +254 -254
  227. package/skills/sequential-thinking/SKILL.md +234 -234
  228. package/skills/session-bridge/SKILL.md +595 -543
  229. package/skills/session-bridge/scripts/load-invariants.js +397 -0
  230. package/skills/skill-forge/SKILL.md +581 -581
  231. package/skills/skill-router/SKILL.md +3 -0
  232. package/skills/slides/SKILL.md +19 -0
  233. package/skills/surgeon/SKILL.md +215 -215
  234. package/skills/team/SKILL.md +557 -537
  235. package/skills/test/SKILL.md +620 -614
  236. package/skills/trend-scout/SKILL.md +145 -145
  237. package/skills/verification/SKILL.md +334 -326
  238. package/skills/video-creator/SKILL.md +201 -201
  239. package/skills/watchdog/SKILL.md +168 -168
  240. package/skills/worktree/SKILL.md +140 -140
@@ -1,415 +1,415 @@
1
- ---
2
- name: preflight
3
- description: Pre-commit quality gate that catches "almost right" code. Goes beyond linting — checks logic correctness, error handling, regressions, and completeness.
4
- metadata:
5
- author: runedev
6
- version: "0.8.0"
7
- layer: L2
8
- model: sonnet
9
- group: quality
10
- tools: "Read, Bash, Glob, Grep"
11
- emit: preflight.passed, preflight.blocked
12
- listen: code.changed
13
- ---
14
-
15
- # preflight
16
-
17
- ## Purpose
18
-
19
- <HARD-GATE>
20
- Preflight verdict of BLOCK stops the pipeline. The calling skill (cook, deploy, launch) MUST halt until all BLOCK findings are resolved and preflight re-runs clean.
21
- </HARD-GATE>
22
-
23
- Pre-commit quality gate that catches "almost right" code — the kind that compiles and passes linting but has logic errors, missing error handling, or incomplete implementations. Goes beyond static analysis to check data flow, edge cases, async correctness, and regression impact. The last defense before code enters the repository.
24
-
25
- ## Triggers
26
-
27
- - Called automatically by `cook` before commit phase
28
- - Called by `fix` after applying fixes (verify fix quality)
29
- - `/rune preflight` — manual quality check
30
- - Auto-trigger: when staged changes exceed 100 LOC
31
-
32
- ## Calls (outbound)
33
-
34
- - `scout` (L2): find code affected by changes (dependency tracing)
35
- - `sentinel` (L2): security sub-check on changed files
36
- - `hallucination-guard` (L3): verify imports and API references exist
37
- - `test` (L2): run test suite as pre-commit check
38
-
39
- ## Called By (inbound)
40
-
41
- - `cook` (L1): before commit phase — mandatory gate
42
-
43
- ## Check Categories
44
-
45
- ```
46
- LOGIC — data flow errors, edge case misses, async bugs
47
- ERROR — missing try/catch, bare catches, unhelpful error messages
48
- REGRESSION — untested impact zones, breaking changes to public API
49
- COMPLETE — missing validation, missing loading states, missing tests
50
- SECURITY — delegated to sentinel
51
- IMPORTS — delegated to hallucination-guard
52
- ```
53
-
54
- ## Executable Steps
55
-
56
- ### Stage A — Spec Compliance (Plan vs Diff)
57
-
58
- Before checking code quality, verify the code matches what was planned.
59
-
60
- Use `Bash` to get the diff: `git diff --cached` (staged) or `git diff HEAD` (all changes).
61
- Use `Read` to load the approved plan from the calling skill (cook passes plan context).
62
-
63
- **Check each plan phase against the diff:**
64
-
65
- | Plan says... | Diff shows... | Verdict |
66
- |---|---|---|
67
- | "Add function X to file Y" | Function X exists in file Y | PASS |
68
- | "Add function X to file Y" | Function X missing | BLOCK — incomplete implementation |
69
- | "Modify function Z" | Function Z untouched | BLOCK — planned change not applied |
70
- | Nothing about file W | File W modified | WARN — out-of-scope change (scope creep) |
71
-
72
- **Output**: List of plan-vs-diff mismatches. Any missing planned change = BLOCK. Any unplanned change = WARN.
73
-
74
- If no plan is available (manual preflight invocation), skip Stage A and proceed to Step 1.
75
-
76
- ### Step 1 — Logic Review
77
- Use `Read` to load each changed file. For every modified function or method:
78
- - Trace the data flow from input to output. Identify where a `null`, `undefined`, empty array, or 0 value would cause a runtime error or wrong result.
79
- - Check async/await: every `async` function that calls an async operation must `await` it. Identify missing `await` that would cause race conditions or unhandled promise rejections.
80
- - Check boundary conditions: off-by-one in loops, array index out of bounds, division by zero.
81
- - Check type coercions: implicit `==` comparisons that could produce wrong results, string-to-number conversions without validation.
82
-
83
- **Common patterns to flag:**
84
-
85
- ```typescript
86
- // BAD — missing await (race condition)
87
- async function processOrder(orderId: string) {
88
- const order = db.orders.findById(orderId); // order is a Promise, not a value
89
- return calculateTotal(order.items); // crashes: order.items is undefined
90
- }
91
- // GOOD
92
- async function processOrder(orderId: string) {
93
- const order = await db.orders.findById(orderId);
94
- return calculateTotal(order.items);
95
- }
96
- ```
97
-
98
- ```typescript
99
- // BAD — sequential independent I/O
100
- const user = await fetchUser(id);
101
- const permissions = await fetchPermissions(id); // waits unnecessarily
102
- // GOOD — parallel
103
- const [user, permissions] = await Promise.all([fetchUser(id), fetchPermissions(id)]);
104
- ```
105
-
106
- Flag each issue with: file path, line number, category (null-deref | missing-await | off-by-one | type-coerce), and a one-line description.
107
-
108
- ### Step 2 — Error Handling
109
- For every changed file, verify:
110
- - Every `async` function has a `try/catch` block OR the caller explicitly handles the rejected promise.
111
- - No bare `catch(e) {}` or `except: pass` — every catch must log or rethrow with context.
112
- - Every `fetch` / HTTP client call checks the response status before consuming the body.
113
- - Error messages are user-friendly: no raw stack traces, no internal variable names exposed to the client.
114
- - API route handlers return appropriate HTTP status codes (4xx for client errors, 5xx for server errors).
115
-
116
- **Common patterns to flag:**
117
-
118
- ```typescript
119
- // BAD — swallowed exception
120
- try {
121
- await saveUser(data);
122
- } catch (e) {} // silent failure, caller never knows
123
-
124
- // BAD — leaks internals to client
125
- app.use((err, req, res, next) => {
126
- res.status(500).json({ error: err.stack }); // exposes stack trace
127
- });
128
- // GOOD — log internally, generic message to client
129
- app.use((err, req, res, next) => {
130
- logger.error(err);
131
- res.status(500).json({ error: 'Internal server error' });
132
- });
133
- ```
134
-
135
- Flag each violation with: file path, line number, category (bare-catch | missing-status-check | raw-error-exposure), and description.
136
-
137
- ### Step 3 — Regression Check
138
- Use `rune:scout` to identify all files that import or depend on the changed files/functions.
139
- For each dependent file:
140
- - Check if the changed function signature is still compatible (parameter count, types, return type).
141
- - Check if the dependent file has tests that cover the interaction with the changed code.
142
- - Flag untested impact zones: dependents with zero test coverage of the affected code path.
143
-
144
- Flag each regression risk with: dependent file path, what changed, whether tests exist, severity (breaking | degraded | untested).
145
-
146
- ### Step 4 — Completeness Check
147
- Verify that new code ships complete:
148
- - New API endpoint → has input validation schema (Zod, Pydantic, Joi, etc.)
149
- - New React/Svelte component → has loading state AND error state
150
- - New feature → has at least one test file
151
- - New configuration option → has documentation (inline comment or docs file)
152
- - New database query → has corresponding migration file if schema changed
153
-
154
- **Framework-specific completeness (apply only if detected):**
155
- - React component with async data → must have `loading` state AND `error` state
156
- - Next.js Server Action → must have `try/catch` and return typed result
157
- - FastAPI endpoint → must have Pydantic request/response models
158
- - Django ViewSet → must have explicit `permission_classes`
159
- - Express route → must have input validation middleware before handler
160
-
161
- If any completeness item is missing, flag as **WARN** with: what is missing, which file needs it.
162
-
163
- ### Step 4.2 — Coherence Check
164
-
165
- Verify that new code is **consistent with existing project patterns** — not just correct, but coherent with the codebase it lives in.
166
-
167
- | Check | What To Look For | Severity |
168
- |-------|------------------|----------|
169
- | Naming conventions | New functions/variables follow project's existing naming style (camelCase, snake_case, etc.) | WARN |
170
- | File organization | New files placed in correct directory per project structure (e.g., utils/ not lib/, components/ not ui/) | WARN |
171
- | Import patterns | Uses project's established import style (absolute vs relative, barrel exports vs direct) | WARN |
172
- | Error handling style | Matches project's existing pattern (Result type, try/catch, error codes) | WARN |
173
- | State management | Uses same state approach as rest of project (Zustand, context, stores) | BLOCK if different paradigm |
174
- | API patterns | Follows existing response format, middleware chain, auth pattern | BLOCK if diverges |
175
- | Design system usage | Uses existing design tokens/components, not inline overrides | WARN |
176
-
177
- **Detection**: Read 2-3 existing files in the same directory as the change. Compare patterns. Flag divergences.
178
-
179
- **Skip if**: Project has no established patterns (greenfield, <5 files), or CLAUDE.md/conventions.md explicitly says "no conventions yet."
180
-
181
- ### Step 4.3 — Eval Verification
182
-
183
- If `.rune/evals/` directory exists with eval definition files, verify eval results as part of the quality gate.
184
-
185
- | Check | Action | Severity |
186
- |-------|--------|----------|
187
- | Capability eval defined but not run | Feature has `.rune/evals/<feature>.md` with CAP-* entries but no results | WARN: "Capability evals defined but not executed" |
188
- | Regression eval failing | Any REG-* eval with status=fail | BLOCK: "Regression detected — existing behavior broken" |
189
- | Capability eval below threshold | CAP-* eval pass@k below defined threshold | WARN: "Capability eval below threshold (X% vs Y% required)" |
190
- | No eval file for new feature | New feature added (detected by new test files + new source files) but no `.rune/evals/` entry | INFO: "Consider defining capability evals for new feature" |
191
-
192
- **Skip if**: No `.rune/evals/` directory exists (project hasn't adopted eval-driven development).
193
-
194
- ### Step 4.5 — Domain Quality Hooks
195
-
196
- Apply domain-specific quality checks based on detected file types in the diff. These extend the generic completeness checks in Step 4 with deeper domain validation.
197
-
198
- <HARD-GATE>
199
- Domain hooks are additive — they add checks, never remove generic ones from Steps 1-4.
200
- If a domain hook flags BLOCK, the overall preflight verdict is BLOCK regardless of other steps.
201
- </HARD-GATE>
202
-
203
- #### Hook Selection (auto-detect from diff)
204
-
205
- | Detected Pattern | Domain Hook | Key Checks |
206
- |-----------------|-------------|------------|
207
- | `migrations/*.sql`, `*.migration.*` | Database | Rollback script present, no bare DROP/DELETE, migration tested |
208
- | `openapi.*`, `*.graphql`, `*.proto` | API Contract | Breaking changes flagged, version bumped, deprecated fields documented |
209
- | `docs/policies/*`, `PRIVACY*`, `TERMS*` | Legal/Compliance | No placeholder text, review date current, practice matches policy |
210
- | `**/billing*`, `**/payment*`, `**/invoice*` | Financial | Decimal precision correct, currency locale-aware, no hardcoded rates |
211
- | `*.tsx`, `*.jsx`, `*.svelte`, `*.vue`, `components/*` | UI/Frontend | Design token compliance, animation a11y, touch targets, visual hierarchy |
212
- | `skills/*/SKILL.md`, `extensions/*/PACK.md` | Rune Skill | Frontmatter valid, all required sections present, word count within layer budget |
213
- | `*.test.*`, `*.spec.*`, `__tests__/*` | Test Quality | No `.skip`/`.only` left in, assertions present (not empty tests), no hardcoded timeouts |
214
-
215
- #### Domain Hook Execution
216
-
217
- For each detected domain, run its checks on the relevant files in the diff:
218
-
219
- 1. **Identify** which domain hooks apply based on changed file patterns
220
- 2. **Load** domain-specific check rules (inline above, or from pack reference files if a pack is installed)
221
- 3. **Scan** each relevant file for domain violations
222
- 4. **Classify** findings: BLOCK (data loss risk, breaking contract) or WARN (best practice, incomplete)
223
- 5. **Append** to preflight report under `### Domain Quality` section
224
-
225
- #### UI/Frontend Domain Checks
226
-
227
- When UI/Frontend hook is triggered, run these checks on all `.tsx`/`.jsx`/`.svelte`/`.vue` files in the diff:
228
-
229
- | Check | What to Scan | Severity |
230
- |-------|-------------|----------|
231
- | **Design token compliance** | Hardcoded colors (`#fff`, `rgb(`, `hsl(`) instead of CSS variables or Tailwind tokens | WARN: "Hardcoded color at {file}:{line} — use design token" |
232
- | **UI-SPEC drift** | If `.rune/ui-spec.md` exists, compare component decisions (card style, form layout, nav type) against spec | BLOCK: "Component at {file} uses bordered cards but UI-SPEC locks elevated cards" |
233
- | **Animation accessibility** | Animations/transitions without `prefers-reduced-motion` guard | WARN: "Animation at {file}:{line} missing reduced-motion check" |
234
- | **Touch target size** | Interactive elements with explicit small sizing (`w-5 h-5`, `p-0.5` on buttons/links) < 44×44px | WARN: "Touch target too small at {file}:{line}" |
235
- | **Missing states** | Components fetching data without loading/error/empty states | WARN: "Async component at {file} missing [loading|error|empty] state" |
236
- | **Icon accessibility** | Decorative icons without `aria-hidden="true"`, functional icons without `aria-label` | WARN: "Icon at {file}:{line} missing aria attribute" |
237
- | **Inline styles** | `style={{` or `style=` attribute usage instead of classes/tokens | WARN: "Inline style at {file}:{line} — use CSS class or Tailwind" |
238
- | **Font loading** | Custom font imports without `font-display: swap` or Next.js font optimization | WARN: "Font at {file} may cause layout shift — add font-display: swap" |
239
- | **Placeholder content** | Strings like "Lorem ipsum", "TODO", "placeholder", "test text" in JSX/template | BLOCK: "Placeholder content at {file}:{line} — replace before shipping" |
240
-
241
- **Skip if**: Diff contains only test files, config files, or non-UI code (detected by absence of JSX/template syntax).
242
-
243
- #### Pack Integration
244
-
245
- When a domain pack is installed (e.g., `@rune-pro/finance`, `@rune-pro/legal`), preflight checks the pack's **Hard-Stop Thresholds** table and applies matching rules to staged files. This means:
246
- - Installing `@rune-pro/finance` automatically adds financial quality gates to preflight
247
- - Installing `@rune-pro/legal` automatically adds compliance checks to preflight
248
- - No manual configuration needed — pack presence = hooks active
249
-
250
- #### Output Section
251
-
252
- ```
253
- ### Domain Quality
254
- - **Domains detected**: [Database, Financial]
255
- - `migrations/003-add-billing.sql` — BLOCK: DROP TABLE without rollback script
256
- - `src/billing/invoice.ts:42` — WARN: price calculation uses `toFixed(2)` instead of `Intl.NumberFormat`
257
- ```
258
-
259
- ### Step 4.6 — Organization Approval Requirements (Business)
260
-
261
- If `.rune/org/org.md` exists, load organization approval workflows and enforce them as additional quality gates.
262
-
263
- 1. `Read` `.rune/org/org.md` and extract `## Policies`, `## Approval Flows`, and `## Governance Level`
264
- 2. Apply organization-level quality requirements:
265
-
266
- | Org Policy | Preflight Check | Severity |
267
- |------------|----------------|----------|
268
- | `minimum_reviewers` | Verify PR has required reviewer count before merge | WARN: "Org requires {N} reviewers" |
269
- | `self-merge_allowed` | If "Never" or "No", flag self-merge attempts | BLOCK if org prohibits |
270
- | `required_checks` | Verify all org-required checks (tests, security scan, type check, lint) are passing | BLOCK if missing |
271
- | `staging_required` | If "Yes", verify staging deployment exists before production | WARN if no staging step |
272
- | `feature_flags` | If "Required for user-facing changes", flag new UI without feature flag | WARN |
273
- | `cross-domain_changes` | If changes span multiple team domains, require reviewer from each | WARN |
274
-
275
- 3. Load `## Approval Flows > ### Feature Launch` and display the required approval chain:
276
- - Output: "Org approval chain: {flow}" so developer knows the full pipeline
277
- - If governance level is "Maximum", flag any attempt to skip gates
278
-
279
- 4. Append org findings under `### Organization Requirements` section:
280
-
281
- ```
282
- ### Organization Requirements
283
- - **Org template**: [startup|mid-size|enterprise]
284
- - **Governance level**: [Minimal|Moderate|Maximum]
285
- - **Minimum reviewers**: 2 (1 must be director+)
286
- - **Required checks**: tests (≥80% coverage), security scan, type check, lint
287
- - **Approval chain**: contributor proposes → lead reviews → vp approves → deploy
288
- - WARN: Self-merge not allowed per org policy
289
- ```
290
-
291
- If `.rune/org/org.md` does not exist, skip and log INFO: "no org config, organization requirements check skipped".
292
-
293
- ### Step 4.8 — Preflight Composite Score
294
-
295
- After all domain hooks (Step 4.5) and completeness checks (Step 4) complete, compute a **Preflight Health Score** to make the verdict numeric and comparable across runs.
296
-
297
- ### Formula
298
-
299
- ```
300
- Preflight Score = (Logic × 0.30) + (Error Handling × 0.20) + (Completeness × 0.20) + (Coherence × 0.15) + (Regression Risk × 0.15)
301
- ```
302
-
303
- **5 verification axes** (Completeness + Correctness via Logic + Coherence — 3D verification model):
304
-
305
- Each dimension is scored per staged files:
306
- - 0 BLOCK findings in dimension → 100
307
- - 1 BLOCK → dimension capped at 30
308
- - 1 WARN → dimension capped at 75
309
- - Each additional WARN → subtract 10 (floor: 40)
310
-
311
- ### Grade Thresholds
312
-
313
- | Score | Grade | Verdict |
314
- |-------|-------|---------|
315
- | 90–100 | Excellent | PASS |
316
- | 75–89 | Good | PASS with notes |
317
- | 60–74 | Fair | WARN |
318
- | 40–59 | Poor | WARN (escalate to developer) |
319
- | 0–39 | Critical | BLOCK |
320
-
321
- Score is appended to the Preflight Report footer. Useful for tracking quality trend across sprints when cook logs preflight scores to `.rune/metrics/`.
322
-
323
-
324
- ### Step 5 — Security Sub-Check
325
- Invoke `rune:sentinel` on the changed files. Attach sentinel's output verbatim under the "Security" section of the preflight report. If sentinel returns BLOCK, preflight verdict is also BLOCK.
326
-
327
- ### Step 6 — Generate Verdict
328
- Aggregate all findings:
329
- - Any BLOCK from sentinel OR a logic issue that would cause data corruption or security bypass → overall **BLOCK**
330
- - Any missing error handling, regression risk with no tests, or incomplete feature → **WARN**
331
- - Only style or best-practice suggestions → **PASS**
332
-
333
- Report PASS, WARN, or BLOCK. For WARN, list each item the developer must acknowledge. For BLOCK, list each item that must be fixed before proceeding.
334
-
335
- ## Output Format
336
-
337
- ```
338
- ## Preflight Report
339
- - **Status**: PASS | WARN | BLOCK
340
- - **Files Checked**: [count]
341
- - **Changes**: +[added] -[removed] lines across [files] files
342
-
343
- ### Logic Issues
344
- - `path/to/file.ts:42` — null-deref: `user.name` accessed without null check
345
- - `path/to/api.ts:85` — missing-await: async database call not awaited
346
-
347
- ### Error Handling
348
- - `path/to/handler.ts:20` — bare-catch: error swallowed silently
349
-
350
- ### Regression Risk
351
- - `utils/format.ts` — changed function used by 5 modules, 2 have tests, 3 untested (WARN)
352
-
353
- ### Completeness
354
- - `api/users.ts` — new POST endpoint missing input validation schema
355
- - `components/Form.tsx` — no loading state during submission
356
-
357
- ### Coherence
358
- - `api/users.ts` — uses `res.json()` but project convention is `sendResponse()` wrapper
359
- - `utils/newHelper.ts` — placed in utils/ but project uses helpers/ directory
360
-
361
- ### Security (from sentinel)
362
- - [sentinel findings if any]
363
-
364
- ### Composite Score
365
- - Logic: [score] | Error: [score] | Completeness: [score] | Coherence: [score] | Regression: [score]
366
- - **Preflight Score**: [weighted value] → Grade: [Excellent/Good/Fair/Poor/Critical]
367
-
368
- ### Verdict
369
- WARN — 3 issues found (0 blocking, 3 must-acknowledge). Resolve before commit or explicitly acknowledge each WARN.
370
- ```
371
-
372
- ## Constraints
373
-
374
- 1. MUST check: logic errors, error handling, edge cases, type safety, naming conventions
375
- 2. MUST reference specific file:line for every finding
376
- 3. MUST NOT skip edge case analysis — "happy path works" is insufficient
377
- 4. MUST verify error messages are user-friendly and don't leak internal details
378
- 5. MUST check that async operations have proper error handling and cleanup
379
-
380
- ## Returns
381
-
382
- | Artifact | Format | Location |
383
- |----------|--------|----------|
384
- | Preflight report | Markdown | inline (chat output) |
385
- | Issue list (BLOCK/WARN by category) | Markdown list | inline |
386
- | Preflight health score | Markdown table | inline (footer of report) |
387
- | Spec compliance verdict | Markdown table | inline |
388
- | Domain quality findings | Markdown section | inline |
389
-
390
- ## Sharp Edges
391
-
392
- | Failure Mode | Severity | Mitigation |
393
- |---|---|---|
394
- | Stopping at first BLOCK finding without checking remaining files | HIGH | Aggregate all findings first — developer needs the complete list, not just the first blocker |
395
- | "Happy path works" accepted as sufficient | HIGH | CONSTRAINT blocks this — edge case analysis is mandatory on every function |
396
- | Calling verification directly instead of the test skill | MEDIUM | Preflight calls rune:test for test suite execution; rune:verification for lint/type/build checks |
397
- | Skipping sentinel sub-check because "this file doesn't look security-relevant" | HIGH | MUST invoke sentinel — security relevance is sentinel's job to determine, not preflight's |
398
- | Skipping Stage A (spec compliance) when plan is available | HIGH | If cook provides an approved plan, Stage A is mandatory — catches incomplete implementations |
399
- | Agent modified files not in plan without flagging | MEDIUM | Stage A flags unplanned file changes as WARN — scope creep detection |
400
- | Domain hooks not triggered when pack is installed | HIGH | Step 4.5 auto-detects file patterns — if pack is installed but hooks don't fire, check file pattern matching |
401
- | Domain hooks overriding generic checks | HIGH | HARD-GATE: domain hooks are ADDITIVE — they never replace Steps 1-4 |
402
- | Pack Hard-Stop Thresholds ignored in preflight | MEDIUM | Step 4.5 Pack Integration must read installed pack thresholds — test with each new pack |
403
-
404
- ## Done When
405
-
406
- - Every changed function traced for null-deref, missing-await, and off-by-one
407
- - Error handling verified on all async functions and HTTP calls
408
- - Regression impact assessed — dependent files identified via scout
409
- - Completeness checklist passed (validation schema, loading/error states, test file)
410
- - Sentinel invoked and its output attached in Security section
411
- - Structured report emitted with PASS / WARN / BLOCK verdict and file:line for every finding
412
-
413
- ## Cost Profile
414
-
415
- ~2000-4000 tokens input, ~500-1500 tokens output. Sonnet for logic analysis quality.
1
+ ---
2
+ name: preflight
3
+ description: Pre-commit quality gate that catches "almost right" code. Goes beyond linting — checks logic correctness, error handling, regressions, and completeness.
4
+ metadata:
5
+ author: runedev
6
+ version: "1.0.0"
7
+ layer: L2
8
+ model: sonnet
9
+ group: quality
10
+ tools: "Read, Bash, Glob, Grep"
11
+ emit: preflight.passed, preflight.blocked
12
+ listen: code.changed
13
+ ---
14
+
15
+ # preflight
16
+
17
+ ## Purpose
18
+
19
+ <HARD-GATE>
20
+ Preflight verdict of BLOCK stops the pipeline. The calling skill (cook, deploy, launch) MUST halt until all BLOCK findings are resolved and preflight re-runs clean.
21
+ </HARD-GATE>
22
+
23
+ Pre-commit quality gate that catches "almost right" code — the kind that compiles and passes linting but has logic errors, missing error handling, or incomplete implementations. Goes beyond static analysis to check data flow, edge cases, async correctness, and regression impact. The last defense before code enters the repository.
24
+
25
+ ## Triggers
26
+
27
+ - Called automatically by `cook` before commit phase
28
+ - Called by `fix` after applying fixes (verify fix quality)
29
+ - `/rune preflight` — manual quality check
30
+ - Auto-trigger: when staged changes exceed 100 LOC
31
+
32
+ ## Calls (outbound)
33
+
34
+ - `scout` (L2): find code affected by changes (dependency tracing)
35
+ - `sentinel` (L2): security sub-check on changed files
36
+ - `hallucination-guard` (L3): verify imports and API references exist
37
+ - `test` (L2): run test suite as pre-commit check
38
+
39
+ ## Called By (inbound)
40
+
41
+ - `cook` (L1): before commit phase — mandatory gate
42
+
43
+ ## Check Categories
44
+
45
+ ```
46
+ LOGIC — data flow errors, edge case misses, async bugs
47
+ ERROR — missing try/catch, bare catches, unhelpful error messages
48
+ REGRESSION — untested impact zones, breaking changes to public API
49
+ COMPLETE — missing validation, missing loading states, missing tests
50
+ SECURITY — delegated to sentinel
51
+ IMPORTS — delegated to hallucination-guard
52
+ ```
53
+
54
+ ## Executable Steps
55
+
56
+ ### Stage A — Spec Compliance (Plan vs Diff)
57
+
58
+ Before checking code quality, verify the code matches what was planned.
59
+
60
+ Use `Bash` to get the diff: `git diff --cached` (staged) or `git diff HEAD` (all changes).
61
+ Use `Read` to load the approved plan from the calling skill (cook passes plan context).
62
+
63
+ **Check each plan phase against the diff:**
64
+
65
+ | Plan says... | Diff shows... | Verdict |
66
+ |---|---|---|
67
+ | "Add function X to file Y" | Function X exists in file Y | PASS |
68
+ | "Add function X to file Y" | Function X missing | BLOCK — incomplete implementation |
69
+ | "Modify function Z" | Function Z untouched | BLOCK — planned change not applied |
70
+ | Nothing about file W | File W modified | WARN — out-of-scope change (scope creep) |
71
+
72
+ **Output**: List of plan-vs-diff mismatches. Any missing planned change = BLOCK. Any unplanned change = WARN.
73
+
74
+ If no plan is available (manual preflight invocation), skip Stage A and proceed to Step 1.
75
+
76
+ ### Step 1 — Logic Review
77
+ Use `Read` to load each changed file. For every modified function or method:
78
+ - Trace the data flow from input to output. Identify where a `null`, `undefined`, empty array, or 0 value would cause a runtime error or wrong result.
79
+ - Check async/await: every `async` function that calls an async operation must `await` it. Identify missing `await` that would cause race conditions or unhandled promise rejections.
80
+ - Check boundary conditions: off-by-one in loops, array index out of bounds, division by zero.
81
+ - Check type coercions: implicit `==` comparisons that could produce wrong results, string-to-number conversions without validation.
82
+
83
+ **Common patterns to flag:**
84
+
85
+ ```typescript
86
+ // BAD — missing await (race condition)
87
+ async function processOrder(orderId: string) {
88
+ const order = db.orders.findById(orderId); // order is a Promise, not a value
89
+ return calculateTotal(order.items); // crashes: order.items is undefined
90
+ }
91
+ // GOOD
92
+ async function processOrder(orderId: string) {
93
+ const order = await db.orders.findById(orderId);
94
+ return calculateTotal(order.items);
95
+ }
96
+ ```
97
+
98
+ ```typescript
99
+ // BAD — sequential independent I/O
100
+ const user = await fetchUser(id);
101
+ const permissions = await fetchPermissions(id); // waits unnecessarily
102
+ // GOOD — parallel
103
+ const [user, permissions] = await Promise.all([fetchUser(id), fetchPermissions(id)]);
104
+ ```
105
+
106
+ Flag each issue with: file path, line number, category (null-deref | missing-await | off-by-one | type-coerce), and a one-line description.
107
+
108
+ ### Step 2 — Error Handling
109
+ For every changed file, verify:
110
+ - Every `async` function has a `try/catch` block OR the caller explicitly handles the rejected promise.
111
+ - No bare `catch(e) {}` or `except: pass` — every catch must log or rethrow with context.
112
+ - Every `fetch` / HTTP client call checks the response status before consuming the body.
113
+ - Error messages are user-friendly: no raw stack traces, no internal variable names exposed to the client.
114
+ - API route handlers return appropriate HTTP status codes (4xx for client errors, 5xx for server errors).
115
+
116
+ **Common patterns to flag:**
117
+
118
+ ```typescript
119
+ // BAD — swallowed exception
120
+ try {
121
+ await saveUser(data);
122
+ } catch (e) {} // silent failure, caller never knows
123
+
124
+ // BAD — leaks internals to client
125
+ app.use((err, req, res, next) => {
126
+ res.status(500).json({ error: err.stack }); // exposes stack trace
127
+ });
128
+ // GOOD — log internally, generic message to client
129
+ app.use((err, req, res, next) => {
130
+ logger.error(err);
131
+ res.status(500).json({ error: 'Internal server error' });
132
+ });
133
+ ```
134
+
135
+ Flag each violation with: file path, line number, category (bare-catch | missing-status-check | raw-error-exposure), and description.
136
+
137
+ ### Step 3 — Regression Check
138
+ Use `rune:scout` to identify all files that import or depend on the changed files/functions.
139
+ For each dependent file:
140
+ - Check if the changed function signature is still compatible (parameter count, types, return type).
141
+ - Check if the dependent file has tests that cover the interaction with the changed code.
142
+ - Flag untested impact zones: dependents with zero test coverage of the affected code path.
143
+
144
+ Flag each regression risk with: dependent file path, what changed, whether tests exist, severity (breaking | degraded | untested).
145
+
146
+ ### Step 4 — Completeness Check
147
+ Verify that new code ships complete:
148
+ - New API endpoint → has input validation schema (Zod, Pydantic, Joi, etc.)
149
+ - New React/Svelte component → has loading state AND error state
150
+ - New feature → has at least one test file
151
+ - New configuration option → has documentation (inline comment or docs file)
152
+ - New database query → has corresponding migration file if schema changed
153
+
154
+ **Framework-specific completeness (apply only if detected):**
155
+ - React component with async data → must have `loading` state AND `error` state
156
+ - Next.js Server Action → must have `try/catch` and return typed result
157
+ - FastAPI endpoint → must have Pydantic request/response models
158
+ - Django ViewSet → must have explicit `permission_classes`
159
+ - Express route → must have input validation middleware before handler
160
+
161
+ If any completeness item is missing, flag as **WARN** with: what is missing, which file needs it.
162
+
163
+ ### Step 4.2 — Coherence Check
164
+
165
+ Verify that new code is **consistent with existing project patterns** — not just correct, but coherent with the codebase it lives in.
166
+
167
+ | Check | What To Look For | Severity |
168
+ |-------|------------------|----------|
169
+ | Naming conventions | New functions/variables follow project's existing naming style (camelCase, snake_case, etc.) | WARN |
170
+ | File organization | New files placed in correct directory per project structure (e.g., utils/ not lib/, components/ not ui/) | WARN |
171
+ | Import patterns | Uses project's established import style (absolute vs relative, barrel exports vs direct) | WARN |
172
+ | Error handling style | Matches project's existing pattern (Result type, try/catch, error codes) | WARN |
173
+ | State management | Uses same state approach as rest of project (Zustand, context, stores) | BLOCK if different paradigm |
174
+ | API patterns | Follows existing response format, middleware chain, auth pattern | BLOCK if diverges |
175
+ | Design system usage | Uses existing design tokens/components, not inline overrides | WARN |
176
+
177
+ **Detection**: Read 2-3 existing files in the same directory as the change. Compare patterns. Flag divergences.
178
+
179
+ **Skip if**: Project has no established patterns (greenfield, <5 files), or CLAUDE.md/conventions.md explicitly says "no conventions yet."
180
+
181
+ ### Step 4.3 — Eval Verification
182
+
183
+ If `.rune/evals/` directory exists with eval definition files, verify eval results as part of the quality gate.
184
+
185
+ | Check | Action | Severity |
186
+ |-------|--------|----------|
187
+ | Capability eval defined but not run | Feature has `.rune/evals/<feature>.md` with CAP-* entries but no results | WARN: "Capability evals defined but not executed" |
188
+ | Regression eval failing | Any REG-* eval with status=fail | BLOCK: "Regression detected — existing behavior broken" |
189
+ | Capability eval below threshold | CAP-* eval pass@k below defined threshold | WARN: "Capability eval below threshold (X% vs Y% required)" |
190
+ | No eval file for new feature | New feature added (detected by new test files + new source files) but no `.rune/evals/` entry | INFO: "Consider defining capability evals for new feature" |
191
+
192
+ **Skip if**: No `.rune/evals/` directory exists (project hasn't adopted eval-driven development).
193
+
194
+ ### Step 4.5 — Domain Quality Hooks
195
+
196
+ Apply domain-specific quality checks based on detected file types in the diff. These extend the generic completeness checks in Step 4 with deeper domain validation.
197
+
198
+ <HARD-GATE>
199
+ Domain hooks are additive — they add checks, never remove generic ones from Steps 1-4.
200
+ If a domain hook flags BLOCK, the overall preflight verdict is BLOCK regardless of other steps.
201
+ </HARD-GATE>
202
+
203
+ #### Hook Selection (auto-detect from diff)
204
+
205
+ | Detected Pattern | Domain Hook | Key Checks |
206
+ |-----------------|-------------|------------|
207
+ | `migrations/*.sql`, `*.migration.*` | Database | Rollback script present, no bare DROP/DELETE, migration tested |
208
+ | `openapi.*`, `*.graphql`, `*.proto` | API Contract | Breaking changes flagged, version bumped, deprecated fields documented |
209
+ | `docs/policies/*`, `PRIVACY*`, `TERMS*` | Legal/Compliance | No placeholder text, review date current, practice matches policy |
210
+ | `**/billing*`, `**/payment*`, `**/invoice*` | Financial | Decimal precision correct, currency locale-aware, no hardcoded rates |
211
+ | `*.tsx`, `*.jsx`, `*.svelte`, `*.vue`, `components/*` | UI/Frontend | Design token compliance, animation a11y, touch targets, visual hierarchy |
212
+ | `skills/*/SKILL.md`, `extensions/*/PACK.md` | Rune Skill | Frontmatter valid, all required sections present, word count within layer budget |
213
+ | `*.test.*`, `*.spec.*`, `__tests__/*` | Test Quality | No `.skip`/`.only` left in, assertions present (not empty tests), no hardcoded timeouts |
214
+
215
+ #### Domain Hook Execution
216
+
217
+ For each detected domain, run its checks on the relevant files in the diff:
218
+
219
+ 1. **Identify** which domain hooks apply based on changed file patterns
220
+ 2. **Load** domain-specific check rules (inline above, or from pack reference files if a pack is installed)
221
+ 3. **Scan** each relevant file for domain violations
222
+ 4. **Classify** findings: BLOCK (data loss risk, breaking contract) or WARN (best practice, incomplete)
223
+ 5. **Append** to preflight report under `### Domain Quality` section
224
+
225
+ #### UI/Frontend Domain Checks
226
+
227
+ When UI/Frontend hook is triggered, run these checks on all `.tsx`/`.jsx`/`.svelte`/`.vue` files in the diff:
228
+
229
+ | Check | What to Scan | Severity |
230
+ |-------|-------------|----------|
231
+ | **Design token compliance** | Hardcoded colors (`#fff`, `rgb(`, `hsl(`) instead of CSS variables or Tailwind tokens | WARN: "Hardcoded color at {file}:{line} — use design token" |
232
+ | **UI-SPEC drift** | If `.rune/ui-spec.md` exists, compare component decisions (card style, form layout, nav type) against spec | BLOCK: "Component at {file} uses bordered cards but UI-SPEC locks elevated cards" |
233
+ | **Animation accessibility** | Animations/transitions without `prefers-reduced-motion` guard | WARN: "Animation at {file}:{line} missing reduced-motion check" |
234
+ | **Touch target size** | Interactive elements with explicit small sizing (`w-5 h-5`, `p-0.5` on buttons/links) < 44×44px | WARN: "Touch target too small at {file}:{line}" |
235
+ | **Missing states** | Components fetching data without loading/error/empty states | WARN: "Async component at {file} missing [loading|error|empty] state" |
236
+ | **Icon accessibility** | Decorative icons without `aria-hidden="true"`, functional icons without `aria-label` | WARN: "Icon at {file}:{line} missing aria attribute" |
237
+ | **Inline styles** | `style={{` or `style=` attribute usage instead of classes/tokens | WARN: "Inline style at {file}:{line} — use CSS class or Tailwind" |
238
+ | **Font loading** | Custom font imports without `font-display: swap` or Next.js font optimization | WARN: "Font at {file} may cause layout shift — add font-display: swap" |
239
+ | **Placeholder content** | Strings like "Lorem ipsum", "TODO", "placeholder", "test text" in JSX/template | BLOCK: "Placeholder content at {file}:{line} — replace before shipping" |
240
+
241
+ **Skip if**: Diff contains only test files, config files, or non-UI code (detected by absence of JSX/template syntax).
242
+
243
+ #### Pack Integration
244
+
245
+ When a domain pack is installed (e.g., `@rune-pro/finance`, `@rune-pro/legal`), preflight checks the pack's **Hard-Stop Thresholds** table and applies matching rules to staged files. This means:
246
+ - Installing `@rune-pro/finance` automatically adds financial quality gates to preflight
247
+ - Installing `@rune-pro/legal` automatically adds compliance checks to preflight
248
+ - No manual configuration needed — pack presence = hooks active
249
+
250
+ #### Output Section
251
+
252
+ ```
253
+ ### Domain Quality
254
+ - **Domains detected**: [Database, Financial]
255
+ - `migrations/003-add-billing.sql` — BLOCK: DROP TABLE without rollback script
256
+ - `src/billing/invoice.ts:42` — WARN: price calculation uses `toFixed(2)` instead of `Intl.NumberFormat`
257
+ ```
258
+
259
+ ### Step 4.6 — Organization Approval Requirements (Business)
260
+
261
+ If `.rune/org/org.md` exists, load organization approval workflows and enforce them as additional quality gates.
262
+
263
+ 1. `Read` `.rune/org/org.md` and extract `## Policies`, `## Approval Flows`, and `## Governance Level`
264
+ 2. Apply organization-level quality requirements:
265
+
266
+ | Org Policy | Preflight Check | Severity |
267
+ |------------|----------------|----------|
268
+ | `minimum_reviewers` | Verify PR has required reviewer count before merge | WARN: "Org requires {N} reviewers" |
269
+ | `self-merge_allowed` | If "Never" or "No", flag self-merge attempts | BLOCK if org prohibits |
270
+ | `required_checks` | Verify all org-required checks (tests, security scan, type check, lint) are passing | BLOCK if missing |
271
+ | `staging_required` | If "Yes", verify staging deployment exists before production | WARN if no staging step |
272
+ | `feature_flags` | If "Required for user-facing changes", flag new UI without feature flag | WARN |
273
+ | `cross-domain_changes` | If changes span multiple team domains, require reviewer from each | WARN |
274
+
275
+ 3. Load `## Approval Flows > ### Feature Launch` and display the required approval chain:
276
+ - Output: "Org approval chain: {flow}" so developer knows the full pipeline
277
+ - If governance level is "Maximum", flag any attempt to skip gates
278
+
279
+ 4. Append org findings under `### Organization Requirements` section:
280
+
281
+ ```
282
+ ### Organization Requirements
283
+ - **Org template**: [startup|mid-size|enterprise]
284
+ - **Governance level**: [Minimal|Moderate|Maximum]
285
+ - **Minimum reviewers**: 2 (1 must be director+)
286
+ - **Required checks**: tests (≥80% coverage), security scan, type check, lint
287
+ - **Approval chain**: contributor proposes → lead reviews → vp approves → deploy
288
+ - WARN: Self-merge not allowed per org policy
289
+ ```
290
+
291
+ If `.rune/org/org.md` does not exist, skip and log INFO: "no org config, organization requirements check skipped".
292
+
293
+ ### Step 4.8 — Preflight Composite Score
294
+
295
+ After all domain hooks (Step 4.5) and completeness checks (Step 4) complete, compute a **Preflight Health Score** to make the verdict numeric and comparable across runs.
296
+
297
+ ### Formula
298
+
299
+ ```
300
+ Preflight Score = (Logic × 0.30) + (Error Handling × 0.20) + (Completeness × 0.20) + (Coherence × 0.15) + (Regression Risk × 0.15)
301
+ ```
302
+
303
+ **5 verification axes** (Completeness + Correctness via Logic + Coherence — 3D verification model):
304
+
305
+ Each dimension is scored per staged files:
306
+ - 0 BLOCK findings in dimension → 100
307
+ - 1 BLOCK → dimension capped at 30
308
+ - 1 WARN → dimension capped at 75
309
+ - Each additional WARN → subtract 10 (floor: 40)
310
+
311
+ ### Grade Thresholds
312
+
313
+ | Score | Grade | Verdict |
314
+ |-------|-------|---------|
315
+ | 90–100 | Excellent | PASS |
316
+ | 75–89 | Good | PASS with notes |
317
+ | 60–74 | Fair | WARN |
318
+ | 40–59 | Poor | WARN (escalate to developer) |
319
+ | 0–39 | Critical | BLOCK |
320
+
321
+ Score is appended to the Preflight Report footer. Useful for tracking quality trend across sprints when cook logs preflight scores to `.rune/metrics/`.
322
+
323
+
324
+ ### Step 5 — Security Sub-Check
325
+ Invoke `rune:sentinel` on the changed files. Attach sentinel's output verbatim under the "Security" section of the preflight report. If sentinel returns BLOCK, preflight verdict is also BLOCK.
326
+
327
+ ### Step 6 — Generate Verdict
328
+ Aggregate all findings:
329
+ - Any BLOCK from sentinel OR a logic issue that would cause data corruption or security bypass → overall **BLOCK**
330
+ - Any missing error handling, regression risk with no tests, or incomplete feature → **WARN**
331
+ - Only style or best-practice suggestions → **PASS**
332
+
333
+ Report PASS, WARN, or BLOCK. For WARN, list each item the developer must acknowledge. For BLOCK, list each item that must be fixed before proceeding.
334
+
335
+ ## Output Format
336
+
337
+ ```
338
+ ## Preflight Report
339
+ - **Status**: PASS | WARN | BLOCK
340
+ - **Files Checked**: [count]
341
+ - **Changes**: +[added] -[removed] lines across [files] files
342
+
343
+ ### Logic Issues
344
+ - `path/to/file.ts:42` — null-deref: `user.name` accessed without null check
345
+ - `path/to/api.ts:85` — missing-await: async database call not awaited
346
+
347
+ ### Error Handling
348
+ - `path/to/handler.ts:20` — bare-catch: error swallowed silently
349
+
350
+ ### Regression Risk
351
+ - `utils/format.ts` — changed function used by 5 modules, 2 have tests, 3 untested (WARN)
352
+
353
+ ### Completeness
354
+ - `api/users.ts` — new POST endpoint missing input validation schema
355
+ - `components/Form.tsx` — no loading state during submission
356
+
357
+ ### Coherence
358
+ - `api/users.ts` — uses `res.json()` but project convention is `sendResponse()` wrapper
359
+ - `utils/newHelper.ts` — placed in utils/ but project uses helpers/ directory
360
+
361
+ ### Security (from sentinel)
362
+ - [sentinel findings if any]
363
+
364
+ ### Composite Score
365
+ - Logic: [score] | Error: [score] | Completeness: [score] | Coherence: [score] | Regression: [score]
366
+ - **Preflight Score**: [weighted value] → Grade: [Excellent/Good/Fair/Poor/Critical]
367
+
368
+ ### Verdict
369
+ WARN — 3 issues found (0 blocking, 3 must-acknowledge). Resolve before commit or explicitly acknowledge each WARN.
370
+ ```
371
+
372
+ ## Constraints
373
+
374
+ 1. MUST check: logic errors, error handling, edge cases, type safety, naming conventions
375
+ 2. MUST reference specific file:line for every finding
376
+ 3. MUST NOT skip edge case analysis — "happy path works" is insufficient
377
+ 4. MUST verify error messages are user-friendly and don't leak internal details
378
+ 5. MUST check that async operations have proper error handling and cleanup
379
+
380
+ ## Returns
381
+
382
+ | Artifact | Format | Location |
383
+ |----------|--------|----------|
384
+ | Preflight report | Markdown | inline (chat output) |
385
+ | Issue list (BLOCK/WARN by category) | Markdown list | inline |
386
+ | Preflight health score | Markdown table | inline (footer of report) |
387
+ | Spec compliance verdict | Markdown table | inline |
388
+ | Domain quality findings | Markdown section | inline |
389
+
390
+ ## Sharp Edges
391
+
392
+ | Failure Mode | Severity | Mitigation |
393
+ |---|---|---|
394
+ | Stopping at first BLOCK finding without checking remaining files | HIGH | Aggregate all findings first — developer needs the complete list, not just the first blocker |
395
+ | "Happy path works" accepted as sufficient | HIGH | CONSTRAINT blocks this — edge case analysis is mandatory on every function |
396
+ | Calling verification directly instead of the test skill | MEDIUM | Preflight calls rune:test for test suite execution; rune:verification for lint/type/build checks |
397
+ | Skipping sentinel sub-check because "this file doesn't look security-relevant" | HIGH | MUST invoke sentinel — security relevance is sentinel's job to determine, not preflight's |
398
+ | Skipping Stage A (spec compliance) when plan is available | HIGH | If cook provides an approved plan, Stage A is mandatory — catches incomplete implementations |
399
+ | Agent modified files not in plan without flagging | MEDIUM | Stage A flags unplanned file changes as WARN — scope creep detection |
400
+ | Domain hooks not triggered when pack is installed | HIGH | Step 4.5 auto-detects file patterns — if pack is installed but hooks don't fire, check file pattern matching |
401
+ | Domain hooks overriding generic checks | HIGH | HARD-GATE: domain hooks are ADDITIVE — they never replace Steps 1-4 |
402
+ | Pack Hard-Stop Thresholds ignored in preflight | MEDIUM | Step 4.5 Pack Integration must read installed pack thresholds — test with each new pack |
403
+
404
+ ## Done When
405
+
406
+ - Every changed function traced for null-deref, missing-await, and off-by-one
407
+ - Error handling verified on all async functions and HTTP calls
408
+ - Regression impact assessed — dependent files identified via scout
409
+ - Completeness checklist passed (validation schema, loading/error states, test file)
410
+ - Sentinel invoked and its output attached in Security section
411
+ - Structured report emitted with PASS / WARN / BLOCK verdict and file:line for every finding
412
+
413
+ ## Cost Profile
414
+
415
+ ~2000-4000 tokens input, ~500-1500 tokens output. Sonnet for logic analysis quality.