@aperant/framework 0.8.0 → 0.8.4

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 (271) hide show
  1. package/CHANGELOG.md +311 -1
  2. package/README.md +12 -0
  3. package/agents/apt-planner.md +5 -4
  4. package/dist/cli/commands/adr.mjs +1 -1
  5. package/dist/cli/commands/audit-branch-current.d.mts +25 -0
  6. package/dist/cli/commands/audit-branch-current.d.mts.map +1 -0
  7. package/dist/cli/commands/audit-branch-current.mjs +252 -0
  8. package/dist/cli/commands/audit-branch-current.mjs.map +1 -0
  9. package/dist/cli/commands/audit.d.mts.map +1 -1
  10. package/dist/cli/commands/audit.mjs +13 -2
  11. package/dist/cli/commands/audit.mjs.map +1 -1
  12. package/dist/cli/commands/check-version.d.mts.map +1 -1
  13. package/dist/cli/commands/check-version.mjs +19 -1
  14. package/dist/cli/commands/check-version.mjs.map +1 -1
  15. package/dist/cli/commands/context.mjs +3 -3
  16. package/dist/cli/commands/context.mjs.map +1 -1
  17. package/dist/cli/commands/detect-runtime.d.mts +6 -0
  18. package/dist/cli/commands/detect-runtime.d.mts.map +1 -0
  19. package/dist/cli/commands/detect-runtime.mjs +136 -0
  20. package/dist/cli/commands/detect-runtime.mjs.map +1 -0
  21. package/dist/cli/commands/driver-doctor.d.mts +29 -0
  22. package/dist/cli/commands/driver-doctor.d.mts.map +1 -0
  23. package/dist/cli/commands/driver-doctor.mjs +291 -0
  24. package/dist/cli/commands/driver-doctor.mjs.map +1 -0
  25. package/dist/cli/commands/gate.mjs +14 -0
  26. package/dist/cli/commands/gate.mjs.map +1 -1
  27. package/dist/cli/commands/init.d.mts.map +1 -1
  28. package/dist/cli/commands/init.mjs +76 -33
  29. package/dist/cli/commands/init.mjs.map +1 -1
  30. package/dist/cli/commands/install-from-source.d.mts +2 -0
  31. package/dist/cli/commands/install-from-source.d.mts.map +1 -0
  32. package/dist/cli/commands/install-from-source.mjs +2 -0
  33. package/dist/cli/commands/install-from-source.mjs.map +1 -0
  34. package/dist/cli/commands/modes.mjs +1 -1
  35. package/dist/cli/commands/route.d.mts.map +1 -1
  36. package/dist/cli/commands/route.mjs +38 -1
  37. package/dist/cli/commands/route.mjs.map +1 -1
  38. package/dist/cli/commands/triage.mjs +1 -1
  39. package/dist/cli/config/load.d.mts.map +1 -1
  40. package/dist/cli/config/load.mjs +9 -3
  41. package/dist/cli/config/load.mjs.map +1 -1
  42. package/dist/cli/coordination/auto-emit-artifact-ready.mjs +1 -1
  43. package/dist/cli/coordination/event-schema.d.mts.map +1 -1
  44. package/dist/cli/coordination/event-schema.mjs +18 -0
  45. package/dist/cli/coordination/event-schema.mjs.map +1 -1
  46. package/dist/cli/design/frontmatter-schema.d.mts +4 -4
  47. package/dist/cli/dispatch.d.mts.map +1 -1
  48. package/dist/cli/dispatch.mjs +18 -1
  49. package/dist/cli/dispatch.mjs.map +1 -1
  50. package/dist/cli/gate/context.d.mts +1 -0
  51. package/dist/cli/gate/context.d.mts.map +1 -1
  52. package/dist/cli/gate/context.mjs +14 -1
  53. package/dist/cli/gate/context.mjs.map +1 -1
  54. package/dist/cli/gate/gates/consistency-check.d.mts +1 -0
  55. package/dist/cli/gate/gates/consistency-check.d.mts.map +1 -1
  56. package/dist/cli/gate/gates/consistency-check.mjs +1 -0
  57. package/dist/cli/gate/gates/consistency-check.mjs.map +1 -1
  58. package/dist/cli/gate/gates/review-clean.d.mts +1 -0
  59. package/dist/cli/gate/gates/review-clean.d.mts.map +1 -1
  60. package/dist/cli/gate/gates/review-clean.mjs +1 -0
  61. package/dist/cli/gate/gates/review-clean.mjs.map +1 -1
  62. package/dist/cli/gate/gates/verify-approved.d.mts +1 -0
  63. package/dist/cli/gate/gates/verify-approved.d.mts.map +1 -1
  64. package/dist/cli/gate/gates/verify-approved.mjs +1 -0
  65. package/dist/cli/gate/gates/verify-approved.mjs.map +1 -1
  66. package/dist/cli/gate/registry.d.mts.map +1 -1
  67. package/dist/cli/gate/registry.mjs +9 -1
  68. package/dist/cli/gate/registry.mjs.map +1 -1
  69. package/dist/cli/install/cli-to-install-root.d.mts.map +1 -1
  70. package/dist/cli/install/cli-to-install-root.mjs +0 -2
  71. package/dist/cli/install/cli-to-install-root.mjs.map +1 -1
  72. package/dist/cli/install/find-workspace-framework-version.d.mts +16 -0
  73. package/dist/cli/install/find-workspace-framework-version.d.mts.map +1 -0
  74. package/dist/cli/install/find-workspace-framework-version.mjs +85 -0
  75. package/dist/cli/install/find-workspace-framework-version.mjs.map +1 -0
  76. package/dist/cli/install/install-from-source.d.mts +10 -0
  77. package/dist/cli/install/install-from-source.d.mts.map +1 -0
  78. package/dist/cli/install/install-from-source.mjs +271 -0
  79. package/dist/cli/install/install-from-source.mjs.map +1 -0
  80. package/dist/cli/install/install-kernel.d.mts.map +1 -1
  81. package/dist/cli/install/install-kernel.mjs +24 -0
  82. package/dist/cli/install/install-kernel.mjs.map +1 -1
  83. package/dist/cli/install/legacy-paths.d.mts +33 -11
  84. package/dist/cli/install/legacy-paths.d.mts.map +1 -1
  85. package/dist/cli/install/legacy-paths.mjs +161 -39
  86. package/dist/cli/install/legacy-paths.mjs.map +1 -1
  87. package/dist/cli/install/runtime-detect.d.mts +2 -6
  88. package/dist/cli/install/runtime-detect.d.mts.map +1 -1
  89. package/dist/cli/install/runtime-detect.mjs +9 -4
  90. package/dist/cli/install/runtime-detect.mjs.map +1 -1
  91. package/dist/cli/install/runtime-migrate.d.mts +34 -14
  92. package/dist/cli/install/runtime-migrate.d.mts.map +1 -1
  93. package/dist/cli/install/runtime-migrate.mjs +63 -30
  94. package/dist/cli/install/runtime-migrate.mjs.map +1 -1
  95. package/dist/cli/install/transforms/codex.d.mts.map +1 -1
  96. package/dist/cli/install/transforms/codex.mjs +28 -17
  97. package/dist/cli/install/transforms/codex.mjs.map +1 -1
  98. package/dist/cli/install/transforms/pi.d.mts +6 -0
  99. package/dist/cli/install/transforms/pi.d.mts.map +1 -0
  100. package/dist/cli/install/transforms/pi.mjs +37 -0
  101. package/dist/cli/install/transforms/pi.mjs.map +1 -0
  102. package/dist/cli/personas/sidecar.d.mts +1 -1
  103. package/dist/cli/roadmap/lifecycle.d.mts +1 -1
  104. package/dist/cli/roadmap/rollup.d.mts +2 -2
  105. package/dist/cli/skill-author/contract.mjs +2 -2
  106. package/dist/cli/skill-author/contract.mjs.map +1 -1
  107. package/dist/cli/verify-proof/audit.d.mts +34 -0
  108. package/dist/cli/verify-proof/audit.d.mts.map +1 -0
  109. package/dist/cli/verify-proof/audit.mjs +53 -0
  110. package/dist/cli/verify-proof/audit.mjs.map +1 -0
  111. package/dist/cli/verify-proof/exec.d.mts +20 -0
  112. package/dist/cli/verify-proof/exec.d.mts.map +1 -0
  113. package/dist/cli/verify-proof/exec.mjs +74 -0
  114. package/dist/cli/verify-proof/exec.mjs.map +1 -0
  115. package/dist/cli/verify-proof/idl/index.d.mts +2 -0
  116. package/dist/cli/verify-proof/idl/index.d.mts.map +1 -0
  117. package/dist/cli/verify-proof/idl/index.mjs +14 -0
  118. package/dist/cli/verify-proof/idl/index.mjs.map +1 -0
  119. package/dist/cli/verify-proof/idl/types.d.ts +9 -0
  120. package/dist/cli/verify-proof/idl/types.d.ts.map +1 -0
  121. package/dist/cli/verify-proof/idl/types.js +9 -0
  122. package/dist/cli/verify-proof/idl/types.js.map +1 -0
  123. package/dist/cli/verify-proof/manifest-validator.d.mts +19 -0
  124. package/dist/cli/verify-proof/manifest-validator.d.mts.map +1 -0
  125. package/dist/cli/verify-proof/manifest-validator.mjs +182 -0
  126. package/dist/cli/verify-proof/manifest-validator.mjs.map +1 -0
  127. package/dist/cli/verify-proof/resolver.d.mts +43 -0
  128. package/dist/cli/verify-proof/resolver.d.mts.map +1 -0
  129. package/dist/cli/verify-proof/resolver.mjs +160 -0
  130. package/dist/cli/verify-proof/resolver.mjs.map +1 -0
  131. package/dist/cli/verify-proof/runtime-detect.d.mts +27 -0
  132. package/dist/cli/verify-proof/runtime-detect.d.mts.map +1 -0
  133. package/dist/cli/verify-proof/runtime-detect.mjs +116 -0
  134. package/dist/cli/verify-proof/runtime-detect.mjs.map +1 -0
  135. package/dist/cli/verify-proof/trust.d.mts +70 -0
  136. package/dist/cli/verify-proof/trust.d.mts.map +1 -0
  137. package/dist/cli/verify-proof/trust.mjs +174 -0
  138. package/dist/cli/verify-proof/trust.mjs.map +1 -0
  139. package/dist/plugin/.claude-plugin/plugin.json +4 -1
  140. package/dist/plugin/agents/apt-executor.md +12 -0
  141. package/dist/plugin/agents/apt-planner.md +5 -4
  142. package/dist/plugin/agents/apt-team-docs-narrator.md +11 -0
  143. package/dist/plugin/skills/apt/SKILL.md +78 -8
  144. package/dist/plugin/skills/apt-caveman/SKILL.md +64 -0
  145. package/dist/plugin/skills/apt-debug/SKILL.md +36 -4
  146. package/dist/plugin/skills/apt-debug/appendices/diagnose-discipline.md +2 -11
  147. package/dist/plugin/skills/apt-discuss/SKILL.md +4 -4
  148. package/dist/plugin/skills/apt-discuss/appendices/grill-discipline.md +2 -11
  149. package/dist/plugin/skills/apt-discuss/appendices/zoom-out-helper.md +0 -8
  150. package/dist/plugin/skills/apt-execute/SKILL.md +40 -4
  151. package/dist/plugin/skills/apt-execute/appendices/tdd-mode.md +2 -10
  152. package/dist/plugin/skills/apt-fan-out/SKILL.md +159 -0
  153. package/dist/plugin/skills/apt-handoff/SKILL.md +228 -0
  154. package/dist/plugin/skills/apt-improve/DEEPENING.md +0 -8
  155. package/dist/plugin/skills/apt-improve/INTERFACE-DESIGN.md +0 -8
  156. package/dist/plugin/skills/apt-improve/LANGUAGE.md +0 -8
  157. package/dist/plugin/skills/apt-improve/SKILL.md +4 -4
  158. package/dist/plugin/skills/apt-plan/SKILL.md +23 -5
  159. package/dist/plugin/skills/apt-plan/adapters/conductor.md +1 -1
  160. package/dist/plugin/skills/apt-pr-review/SKILL.md +8 -1
  161. package/dist/plugin/skills/apt-prototype/LOGIC.md +0 -8
  162. package/dist/plugin/skills/apt-prototype/SKILL.md +4 -4
  163. package/dist/plugin/skills/apt-prototype/UI.md +0 -8
  164. package/dist/plugin/skills/apt-quick/SKILL.md +31 -1
  165. package/dist/plugin/skills/apt-resume/SKILL.md +54 -31
  166. package/dist/plugin/skills/apt-review/SKILL.md +4 -0
  167. package/dist/plugin/skills/apt-run/SKILL.md +134 -21
  168. package/dist/plugin/skills/apt-setup/SKILL.md +97 -8
  169. package/dist/plugin/skills/apt-ship/SKILL.md +165 -9
  170. package/dist/plugin/skills/apt-spar/SKILL.md +77 -25
  171. package/dist/plugin/skills/apt-triage/AGENT-BRIEF.md +0 -8
  172. package/dist/plugin/skills/apt-triage/OUT-OF-SCOPE.md +0 -7
  173. package/dist/plugin/skills/apt-triage/SKILL.md +2 -2
  174. package/dist/plugin/skills/apt-update/SKILL.md +74 -17
  175. package/dist/plugin/skills/apt-verify/SKILL.md +11 -0
  176. package/dist/plugin/skills/apt-verify-proof/SKILL.md +48 -1
  177. package/dist/plugin/skills/apt-watch-ci/SKILL.md +2 -2
  178. package/dist/plugin/skills/apt-zoom-out/SKILL.md +3 -3
  179. package/dist/schemas/quick-task.d.ts +17 -17
  180. package/dist/schemas/quick-task.d.ts.map +1 -1
  181. package/dist/schemas/quick-task.js +2 -2
  182. package/dist/schemas/quick-task.js.map +1 -1
  183. package/dist/types/config.d.ts +33 -0
  184. package/dist/types/config.d.ts.map +1 -1
  185. package/dist/types/state.d.ts +1 -1
  186. package/dist/types/state.d.ts.map +1 -1
  187. package/dist/types/task-record.d.ts +1 -1
  188. package/dist/types/task-record.d.ts.map +1 -1
  189. package/package.json +134 -133
  190. package/prompts/planner.md +1 -1
  191. package/prompts/spec_writer.md +1 -1
  192. package/skills/apt/SKILL.md +78 -8
  193. package/skills/apt-caveman/SKILL.md +64 -0
  194. package/skills/apt-debug/SKILL.md +36 -4
  195. package/skills/apt-debug/appendices/diagnose-discipline.md +2 -11
  196. package/skills/apt-discuss/SKILL.md +4 -4
  197. package/skills/apt-discuss/appendices/grill-discipline.md +2 -11
  198. package/skills/apt-discuss/appendices/zoom-out-helper.md +0 -8
  199. package/skills/apt-execute/SKILL.md +27 -4
  200. package/skills/apt-execute/appendices/tdd-mode.md +2 -10
  201. package/skills/apt-fan-out/SKILL.md +36 -1
  202. package/skills/apt-handoff/SKILL.md +228 -0
  203. package/skills/apt-improve/DEEPENING.md +0 -8
  204. package/skills/apt-improve/INTERFACE-DESIGN.md +0 -8
  205. package/skills/apt-improve/LANGUAGE.md +0 -8
  206. package/skills/apt-improve/SKILL.md +4 -4
  207. package/skills/apt-plan/SKILL.md +23 -5
  208. package/skills/apt-plan/adapters/conductor.md +1 -1
  209. package/skills/apt-planner.md +1 -1
  210. package/skills/apt-prototype/LOGIC.md +0 -8
  211. package/skills/apt-prototype/SKILL.md +4 -4
  212. package/skills/apt-prototype/UI.md +0 -8
  213. package/skills/apt-quick/SKILL.md +31 -1
  214. package/skills/apt-resume/SKILL.md +54 -31
  215. package/skills/apt-run/SKILL.md +114 -16
  216. package/skills/apt-setup/SKILL.md +97 -8
  217. package/skills/apt-ship/SKILL.md +165 -9
  218. package/skills/apt-spar/SKILL.md +65 -16
  219. package/skills/apt-triage/AGENT-BRIEF.md +0 -8
  220. package/skills/apt-triage/OUT-OF-SCOPE.md +0 -7
  221. package/skills/apt-triage/SKILL.md +2 -2
  222. package/skills/apt-update/SKILL.md +74 -17
  223. package/skills/apt-verify-proof/SKILL.md +48 -1
  224. package/skills/apt-zoom-out/SKILL.md +3 -3
  225. package/src/cli/commands/adr.mjs +1 -1
  226. package/src/cli/commands/audit-branch-current.mjs +250 -0
  227. package/src/cli/commands/audit.mjs +13 -2
  228. package/src/cli/commands/check-version.mjs +20 -1
  229. package/src/cli/commands/context.mjs +3 -3
  230. package/src/cli/commands/detect-runtime.mjs +134 -0
  231. package/src/cli/commands/driver-doctor.mjs +294 -0
  232. package/src/cli/commands/gate.mjs +15 -0
  233. package/src/cli/commands/init.mjs +75 -33
  234. package/src/cli/commands/install-from-source.mjs +1 -0
  235. package/src/cli/commands/modes.mjs +1 -1
  236. package/src/cli/commands/route.mjs +42 -1
  237. package/src/cli/commands/triage.mjs +1 -1
  238. package/src/cli/config/load.mjs +9 -3
  239. package/src/cli/coordination/auto-emit-artifact-ready.mjs +1 -1
  240. package/src/cli/coordination/event-schema.mjs +19 -0
  241. package/src/cli/dispatch.mjs +17 -1
  242. package/src/cli/gate/context.mjs +20 -1
  243. package/src/cli/gate/gates/consistency-check.mjs +1 -0
  244. package/src/cli/gate/gates/review-clean.mjs +1 -0
  245. package/src/cli/gate/gates/verify-approved.mjs +1 -0
  246. package/src/cli/gate/registry.mjs +11 -1
  247. package/src/cli/install/cli-to-install-root.mjs +0 -2
  248. package/src/cli/install/find-workspace-framework-version.mjs +88 -0
  249. package/src/cli/install/install-from-source.mjs +276 -0
  250. package/src/cli/install/install-kernel.mjs +24 -0
  251. package/src/cli/install/legacy-paths.mjs +162 -39
  252. package/src/cli/install/runtime-detect.mjs +9 -4
  253. package/src/cli/install/runtime-migrate.mjs +63 -30
  254. package/src/cli/install/transforms/codex.mjs +26 -17
  255. package/src/cli/install/transforms/pi.mjs +37 -0
  256. package/src/cli/skill-author/contract.mjs +2 -2
  257. package/src/cli/verify-proof/.gitkeep +0 -0
  258. package/src/cli/verify-proof/audit.mjs +55 -0
  259. package/src/cli/verify-proof/exec.mjs +74 -0
  260. package/src/cli/verify-proof/idl/index.mjs +24 -0
  261. package/src/cli/verify-proof/idl/types.ts +41 -0
  262. package/src/cli/verify-proof/manifest-schema.json +211 -0
  263. package/src/cli/verify-proof/manifest-validator.mjs +184 -0
  264. package/src/cli/verify-proof/resolver.mjs +163 -0
  265. package/src/cli/verify-proof/runtime-detect.mjs +122 -0
  266. package/src/cli/verify-proof/trust.mjs +187 -0
  267. package/templates/adr-format.md +0 -8
  268. package/templates/aperant-claude-md-appendix.md +1 -1
  269. package/templates/context-format.md +1 -9
  270. package/templates/proof-verification.md +19 -5
  271. package/workflows/verify-proof.md +56 -14
@@ -0,0 +1,53 @@
1
+ /**
2
+ * audit.mjs — append-only JSONL audit log for driver invocations.
3
+ *
4
+ * ID-05: one file per day at .aperant/events/{YYYY-MM-DD}.jsonl.
5
+ * One line per driver invocation:
6
+ * {ts, driver_id, version, manifest_sha256, trust_tier, sandbox_profile,
7
+ * decision: "allow|deny|requires_approval",
8
+ * result: "success|fail|skip"}
9
+ *
10
+ * Append-only — no rewrites. Each appendDriverEvent() opens the file in
11
+ * 'a' mode and writes a single line; concurrent agents may interleave
12
+ * lines but no line is ever overwritten.
13
+ */
14
+ import { appendFileSync, mkdirSync } from 'node:fs';
15
+ import { dirname, join, resolve } from 'node:path';
16
+ /**
17
+ * Compute today's events filename relative to projectDir.
18
+ * @param {string} projectDir
19
+ * @param {Date} [now]
20
+ * @returns {string}
21
+ */
22
+ export function dailyEventsPath(projectDir, now = new Date()) {
23
+ const yyyy = now.getUTCFullYear();
24
+ const mm = String(now.getUTCMonth() + 1).padStart(2, '0');
25
+ const dd = String(now.getUTCDate()).padStart(2, '0');
26
+ return join(resolve(projectDir), '.aperant/events', `${yyyy}-${mm}-${dd}.jsonl`);
27
+ }
28
+ /**
29
+ * Append a driver-invocation audit line.
30
+ *
31
+ * @param {string} projectDir
32
+ * @param {Object} entry
33
+ * @param {string} entry.driver_id
34
+ * @param {string} entry.version
35
+ * @param {string} entry.manifest_sha256
36
+ * @param {string} entry.trust_tier
37
+ * @param {string} entry.sandbox_profile
38
+ * @param {'allow' | 'deny' | 'requires_approval'} entry.decision
39
+ * @param {'success' | 'fail' | 'skip'} entry.result
40
+ * @param {string} [entry.verb] — IDL verb invoked (optional metadata)
41
+ * @param {string} [entry.reason] — decision-rationale string (optional)
42
+ */
43
+ export function appendDriverEvent(projectDir, entry) {
44
+ const path = dailyEventsPath(projectDir);
45
+ mkdirSync(dirname(path), { recursive: true });
46
+ const line = JSON.stringify({
47
+ ts: new Date().toISOString(),
48
+ kind: 'driver_invocation',
49
+ ...entry,
50
+ });
51
+ appendFileSync(path, line + '\n', 'utf-8');
52
+ }
53
+ //#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,EAAE,OAAO,CAAC,CAAA;AAC3C,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Execute a manifest's local_command transport via execFile (no shell).
3
+ * Throws if the transport is not the structured variant.
4
+ *
5
+ * @param {{transport: unknown}} manifest
6
+ * @param {string[]} [extraArgs] — appended to manifest.transport.local_command.args.
7
+ * @param {{cwd?: string, env?: Record<string,string>, timeout?: number}} [options]
8
+ * @returns {Promise<{stdout: string, stderr: string}>}
9
+ */
10
+ export function execLocalCommand(manifest: {
11
+ transport: unknown;
12
+ }, extraArgs?: string[], options?: {
13
+ cwd?: string;
14
+ env?: Record<string, string>;
15
+ timeout?: number;
16
+ }): Promise<{
17
+ stdout: string;
18
+ stderr: string;
19
+ }>;
20
+ //# sourceMappingURL=exec.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exec.d.mts","sourceRoot":"","sources":["../../../src/cli/verify-proof/exec.mjs"],"names":[],"mappings":"AA2CA;;;;;;;;GAQG;AACH,2CALW;IAAC,SAAS,EAAE,OAAO,CAAA;CAAC,cACpB,MAAM,EAAE,YACR;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAC,MAAM,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAC,GAC3D,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAC,CAAC,CAuBrD"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * exec.mjs — execFile-only execution layer for local_command transports.
3
+ *
4
+ * ID-03 security invariant: drivers with `transport: { local_command }`
5
+ * MUST be invoked through execFile (NO shell, NO pipes, NO redirects).
6
+ *
7
+ * This module exposes ONE function — execLocalCommand — which:
8
+ * 1. Asserts the transport is { local_command: { binary, args[] } }
9
+ * (the manifest validator already structurally enforces this; this
10
+ * is defense-in-depth at runtime).
11
+ * 2. Rejects any args entry that is not a plain string.
12
+ * 3. Invokes node:child_process.execFile (NOT child_process.exec, NOT
13
+ * spawn with shell:true).
14
+ *
15
+ * Grep guard (TD-05): the test verify-proof-local-command-security.test.ts
16
+ * statically asserts that exec.mjs imports execFile from
17
+ * 'node:child_process' and never references child_process.exec / spawn
18
+ * with shell:true.
19
+ */
20
+ import { execFile } from 'node:child_process';
21
+ import { promisify } from 'node:util';
22
+ const execFileAsync = promisify(execFile);
23
+ /**
24
+ * Type-check that a transport is the structured local_command variant.
25
+ * @param {unknown} transport
26
+ * @returns {transport is {local_command: {binary: string, args: string[]}}}
27
+ */
28
+ function isStructuredLocalCommand(transport) {
29
+ if (transport === null || typeof transport !== 'object' || Array.isArray(transport))
30
+ return false;
31
+ const obj = /** @type {Record<string, unknown>} */ (transport);
32
+ if (obj.local_command === null || typeof obj.local_command !== 'object')
33
+ return false;
34
+ const lc = /** @type {Record<string, unknown>} */ (obj.local_command);
35
+ if (typeof lc.binary !== 'string')
36
+ return false;
37
+ if (!Array.isArray(lc.args))
38
+ return false;
39
+ for (const a of lc.args) {
40
+ if (typeof a !== 'string')
41
+ return false;
42
+ }
43
+ return true;
44
+ }
45
+ /**
46
+ * Execute a manifest's local_command transport via execFile (no shell).
47
+ * Throws if the transport is not the structured variant.
48
+ *
49
+ * @param {{transport: unknown}} manifest
50
+ * @param {string[]} [extraArgs] — appended to manifest.transport.local_command.args.
51
+ * @param {{cwd?: string, env?: Record<string,string>, timeout?: number}} [options]
52
+ * @returns {Promise<{stdout: string, stderr: string}>}
53
+ */
54
+ export async function execLocalCommand(manifest, extraArgs = [], options = {}) {
55
+ const transport = manifest.transport;
56
+ if (!isStructuredLocalCommand(transport)) {
57
+ throw new Error(`execLocalCommand: transport is not a structured local_command — refusing to invoke. Got: ${JSON.stringify(transport)}`);
58
+ }
59
+ const { binary, args } = transport.local_command;
60
+ for (const arg of extraArgs) {
61
+ if (typeof arg !== 'string') {
62
+ throw new Error(`execLocalCommand: extraArgs must be strings, got ${typeof arg}`);
63
+ }
64
+ }
65
+ return execFileAsync(binary, [...args, ...extraArgs], {
66
+ cwd: options.cwd,
67
+ env: options.env,
68
+ timeout: options.timeout,
69
+ // Explicit — never pass shell:true. execFile defaults to no shell, but
70
+ // we surface the invariant in code for grep-guard purposes.
71
+ shell: false,
72
+ });
73
+ }
74
+ //# sourceMappingURL=exec.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exec.mjs","sourceRoot":"","sources":["../../../src/cli/verify-proof/exec.mjs"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAErC,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAA;AAEzC;;;;GAIG;AACH,SAAS,wBAAwB,CAAC,SAAS;IAC1C,IAAI,SAAS,KAAK,IAAI,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC;QAAE,OAAO,KAAK,CAAA;IACjG,MAAM,GAAG,GAAG,sCAAsC,CAAC,CAAC,SAAS,CAAC,CAAA;IAC9D,IAAI,GAAG,CAAC,aAAa,KAAK,IAAI,IAAI,OAAO,GAAG,CAAC,aAAa,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAA;IACrF,MAAM,EAAE,GAAG,sCAAsC,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,CAAA;IACrE,IAAI,OAAO,EAAE,CAAC,MAAM,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAA;IAC/C,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC;QAAE,OAAO,KAAK,CAAA;IACzC,KAAK,MAAM,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC;QACzB,IAAI,OAAO,CAAC,KAAK,QAAQ;YAAE,OAAO,KAAK,CAAA;IACxC,CAAC;IACD,OAAO,IAAI,CAAA;AACZ,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,QAAQ,EAAE,SAAS,GAAG,EAAE,EAAE,OAAO,GAAG,EAAE;IAC5E,MAAM,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAA;IACpC,IAAI,CAAC,wBAAwB,CAAC,SAAS,CAAC,EAAE,CAAC;QAC1C,MAAM,IAAI,KAAK,CACd,4FAA4F,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,CACvH,CAAA;IACF,CAAC;IACD,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,SAAS,CAAC,aAAa,CAAA;IAChD,KAAK,MAAM,GAAG,IAAI,SAAS,EAAE,CAAC;QAC7B,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,oDAAoD,OAAO,GAAG,EAAE,CAAC,CAAA;QAClF,CAAC;IACF,CAAC;IACD,OAAO,aAAa,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,SAAS,CAAC,EAAE;QACrD,GAAG,EAAE,OAAO,CAAC,GAAG;QAChB,GAAG,EAAE,OAAO,CAAC,GAAG;QAChB,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,uEAAuE;QACvE,4DAA4D;QAC5D,KAAK,EAAE,KAAK;KACZ,CAAC,CAAA;AACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { ASSERTION_VERBS, ASYNC_VERBS, EVIDENCE_VERBS, IDL_VERB_ARGS, IDL_VERB_NAMES, INTERACTION_VERBS, isVerbResult, LIFECYCLE_VERBS, validateVerbArgs } from "@aperant/driver-sdk";
2
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../../src/cli/verify-proof/idl/index.mjs"],"names":[],"mappings":""}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * idl/index.mjs — framework-side re-export of the IDL v1 runtime registry.
3
+ *
4
+ * The SINGLE SOURCE OF TRUTH lives in `@aperant/driver-sdk` (idl.ts) — see
5
+ * ID-04 in spec.md. This file just re-exports those runtime values so
6
+ * framework-internal callers (bundled drivers, resolver, driver-doctor,
7
+ * conformance kit) can import from the existing relative path without
8
+ * paying the cost of refactoring every callsite.
9
+ *
10
+ * If you add a verb, edit packages/framework-driver-sdk/src/idl.ts. This
11
+ * file requires no maintenance.
12
+ */
13
+ export { ASSERTION_VERBS, ASYNC_VERBS, EVIDENCE_VERBS, IDL_VERB_ARGS, IDL_VERB_NAMES, INTERACTION_VERBS, isVerbResult, LIFECYCLE_VERBS, validateVerbArgs, } from '@aperant/driver-sdk';
14
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../../src/cli/verify-proof/idl/index.mjs"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACN,eAAe,EACf,WAAW,EACX,cAAc,EACd,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,gBAAgB,GAChB,MAAM,qBAAqB,CAAA"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * idl/types.ts — re-export the SDK's IDL types for framework-internal use.
3
+ *
4
+ * Single source of truth lives in `@aperant/driver-sdk/idl.ts`. Framework
5
+ * code imports from here so future moves (e.g. an internal-only IDL
6
+ * extension) only touch this re-export, not every call site.
7
+ */
8
+ export type { AssertNetworkArgs, AssertOutputArgs, AssertTextArgs, AssertVisibleArgs, AwaitSignalArgs, CaptureLogsArgs, ClickArgs, DomDumpArgs, DragDropArgs, DriverModule, DumpStateArgs, ExecuteJsArgs, Handle, IdlVerbName, KeyArgs, LaunchArgs, NavigateArgs, RecordVideoArgs, ScreenshotArgs, SelectArgs, SwipeArgs, SwitchContextArgs, Target, TargetKind, TeardownArgs, TriggerArgs, TypeArgs, UploadFileArgs, VerbResult, WaitForEventArgs, WaitForIdleArgs, } from '@aperant/driver-sdk';
9
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/cli/verify-proof/idl/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,YAAY,EACX,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,SAAS,EACT,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,aAAa,EACb,MAAM,EACN,WAAW,EACX,OAAO,EACP,UAAU,EACV,YAAY,EACZ,eAAe,EACf,cAAc,EACd,UAAU,EACV,SAAS,EACT,iBAAiB,EACjB,MAAM,EACN,UAAU,EACV,YAAY,EACZ,WAAW,EACX,QAAQ,EACR,cAAc,EACd,UAAU,EACV,gBAAgB,EAChB,eAAe,GACf,MAAM,qBAAqB,CAAA"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * idl/types.ts — re-export the SDK's IDL types for framework-internal use.
3
+ *
4
+ * Single source of truth lives in `@aperant/driver-sdk/idl.ts`. Framework
5
+ * code imports from here so future moves (e.g. an internal-only IDL
6
+ * extension) only touch this re-export, not every call site.
7
+ */
8
+ export {};
9
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/cli/verify-proof/idl/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
@@ -0,0 +1,19 @@
1
+ /** Read the bundled manifest-schema.json. */
2
+ export function loadManifestSchema(): any;
3
+ /**
4
+ * Validate a manifest object against the bundled schema.
5
+ *
6
+ * @param {unknown} manifest — usually JSON.parse(manifest.json contents).
7
+ * @param {object} [schema] — override the bundled schema (used by tests).
8
+ * @returns {{valid: true} | {valid: false, errors: Array<{path: string, message: string}>}}
9
+ */
10
+ export function validateManifest(manifest: unknown, schema?: object): {
11
+ valid: true;
12
+ } | {
13
+ valid: false;
14
+ errors: Array<{
15
+ path: string;
16
+ message: string;
17
+ }>;
18
+ };
19
+ //# sourceMappingURL=manifest-validator.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest-validator.d.mts","sourceRoot":"","sources":["../../../src/cli/verify-proof/manifest-validator.mjs"],"names":[],"mappings":"AA2BA,6CAA6C;AAC7C,0CAKC;AAED;;;;;;GAMG;AACH,2CAJW,OAAO,WACP,MAAM,GACJ;IAAC,KAAK,EAAE,IAAI,CAAA;CAAC,GAAG;IAAC,KAAK,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,KAAK,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAC,CAAC,CAAA;CAAC,CAQ1F"}
@@ -0,0 +1,182 @@
1
+ /**
2
+ * manifest-validator.mjs — hand-rolled JSON-Schema subset validator.
3
+ *
4
+ * Validates driver manifests against manifest-schema.json. Implements
5
+ * exactly the JSON-Schema keywords we need:
6
+ *
7
+ * type / required / properties / items / enum / const / pattern / oneOf
8
+ *
9
+ * Returns { valid: true } or { valid: false, errors: [{ path, message }] }
10
+ * where `path` is a JSON-pointer (`/transport/local_command/binary`).
11
+ *
12
+ * No external deps — keeps the validator installable as `dist/` with the
13
+ * framework package and avoids dragging ajv (or any v5+ JSON-Schema
14
+ * validator) into the runtime surface for ~80 lines of validator code per
15
+ * AC15. We don't need allOf / anyOf / definitions — manifest-schema.json
16
+ * is intentionally a thin contract.
17
+ */
18
+ import { readFileSync } from 'node:fs';
19
+ import { dirname, join } from 'node:path';
20
+ import { fileURLToPath } from 'node:url';
21
+ const __dirname = dirname(fileURLToPath(import.meta.url));
22
+ /** Lazy-loaded JSON-Schema (read once on first call). */
23
+ let cachedSchema = null;
24
+ /** Read the bundled manifest-schema.json. */
25
+ export function loadManifestSchema() {
26
+ if (cachedSchema !== null)
27
+ return cachedSchema;
28
+ const schemaPath = join(__dirname, 'manifest-schema.json');
29
+ cachedSchema = JSON.parse(readFileSync(schemaPath, 'utf-8'));
30
+ return cachedSchema;
31
+ }
32
+ /**
33
+ * Validate a manifest object against the bundled schema.
34
+ *
35
+ * @param {unknown} manifest — usually JSON.parse(manifest.json contents).
36
+ * @param {object} [schema] — override the bundled schema (used by tests).
37
+ * @returns {{valid: true} | {valid: false, errors: Array<{path: string, message: string}>}}
38
+ */
39
+ export function validateManifest(manifest, schema) {
40
+ const root = schema ?? loadManifestSchema();
41
+ const errors = [];
42
+ validateNode(manifest, root, '', errors);
43
+ if (errors.length === 0)
44
+ return { valid: true };
45
+ return { valid: false, errors };
46
+ }
47
+ /** Type check — JSON-Schema's union of "string", "number", "object", "array", "boolean", "null". */
48
+ function checkType(value, type) {
49
+ if (type === 'string')
50
+ return typeof value === 'string';
51
+ if (type === 'number')
52
+ return typeof value === 'number' && !Number.isNaN(value);
53
+ if (type === 'integer')
54
+ return typeof value === 'number' && Number.isInteger(value);
55
+ if (type === 'boolean')
56
+ return typeof value === 'boolean';
57
+ if (type === 'null')
58
+ return value === null;
59
+ if (type === 'array')
60
+ return Array.isArray(value);
61
+ if (type === 'object') {
62
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
63
+ }
64
+ return false;
65
+ }
66
+ /**
67
+ * Human-readable name for the actual shape of a value. Distinguishes
68
+ * `null`, `array`, and plain `object` — JS `typeof` reports all three as
69
+ * `'object'`, which makes error messages like "expected type object, got
70
+ * object" misleading.
71
+ *
72
+ * @param {unknown} value
73
+ * @returns {string}
74
+ */
75
+ function describeType(value) {
76
+ if (value === null)
77
+ return 'null';
78
+ if (Array.isArray(value))
79
+ return 'array';
80
+ return typeof value;
81
+ }
82
+ /**
83
+ * Recursive validator. `errors` is mutated.
84
+ *
85
+ * @param {unknown} value
86
+ * @param {object} schema
87
+ * @param {string} path — JSON-pointer
88
+ * @param {Array<{path: string, message: string}>} errors
89
+ */
90
+ function validateNode(value, schema, path, errors) {
91
+ // const
92
+ if ('const' in schema) {
93
+ if (value !== schema.const) {
94
+ errors.push({
95
+ path: path || '/',
96
+ message: `expected const ${JSON.stringify(schema.const)}, got ${JSON.stringify(value)}`,
97
+ });
98
+ return;
99
+ }
100
+ }
101
+ // type
102
+ if (schema.type !== undefined) {
103
+ const types = Array.isArray(schema.type) ? schema.type : [schema.type];
104
+ if (!types.some((t) => checkType(value, t))) {
105
+ errors.push({
106
+ path: path || '/',
107
+ message: `expected type ${types.join('|')}, got ${describeType(value)}`,
108
+ });
109
+ return;
110
+ }
111
+ }
112
+ // enum
113
+ if (Array.isArray(schema.enum)) {
114
+ if (!schema.enum.includes(value)) {
115
+ errors.push({
116
+ path: path || '/',
117
+ message: `value ${JSON.stringify(value)} not in enum [${schema.enum.join(', ')}]`,
118
+ });
119
+ return;
120
+ }
121
+ }
122
+ // pattern
123
+ if (typeof schema.pattern === 'string' && typeof value === 'string') {
124
+ const re = new RegExp(schema.pattern);
125
+ if (!re.test(value)) {
126
+ errors.push({
127
+ path: path || '/',
128
+ message: `value ${JSON.stringify(value)} does not match pattern ${schema.pattern}`,
129
+ });
130
+ return;
131
+ }
132
+ }
133
+ // oneOf
134
+ if (Array.isArray(schema.oneOf)) {
135
+ let matchCount = 0;
136
+ const branchErrors = [];
137
+ for (let i = 0; i < schema.oneOf.length; i++) {
138
+ const sub = schema.oneOf[i];
139
+ const subErrors = [];
140
+ validateNode(value, sub, path, subErrors);
141
+ if (subErrors.length === 0)
142
+ matchCount++;
143
+ else
144
+ branchErrors.push({ branch: i, errors: subErrors });
145
+ }
146
+ if (matchCount !== 1) {
147
+ errors.push({
148
+ path: path || '/',
149
+ message: matchCount === 0
150
+ ? `oneOf: value matched no branch (${branchErrors.length} branches tried)`
151
+ : `oneOf: value matched ${matchCount} branches (must match exactly 1)`,
152
+ });
153
+ return;
154
+ }
155
+ }
156
+ // object validation
157
+ if (checkType(value, 'object')) {
158
+ const obj = /** @type {Record<string, unknown>} */ (value);
159
+ if (Array.isArray(schema.required)) {
160
+ for (const key of schema.required) {
161
+ if (!(key in obj)) {
162
+ errors.push({ path: `${path}/${key}`, message: `required property "${key}" missing` });
163
+ }
164
+ }
165
+ }
166
+ if (schema.properties && typeof schema.properties === 'object') {
167
+ for (const [key, subSchema] of Object.entries(schema.properties)) {
168
+ if (key in obj) {
169
+ validateNode(obj[key], /** @type {object} */ (subSchema), `${path}/${key}`, errors);
170
+ }
171
+ }
172
+ }
173
+ }
174
+ // array validation
175
+ if (checkType(value, 'array') && schema.items) {
176
+ const arr = /** @type {unknown[]} */ (value);
177
+ for (let i = 0; i < arr.length; i++) {
178
+ validateNode(arr[i], schema.items, `${path}/${i}`, errors);
179
+ }
180
+ }
181
+ }
182
+ //# sourceMappingURL=manifest-validator.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest-validator.mjs","sourceRoot":"","sources":["../../../src/cli/verify-proof/manifest-validator.mjs"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAExC,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;AAEzD,yDAAyD;AACzD,IAAI,YAAY,GAAG,IAAI,CAAA;AAEvB,6CAA6C;AAC7C,MAAM,UAAU,kBAAkB;IACjC,IAAI,YAAY,KAAK,IAAI;QAAE,OAAO,YAAY,CAAA;IAC9C,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,EAAE,sBAAsB,CAAC,CAAA;IAC1D,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,CAAA;IAC5D,OAAO,YAAY,CAAA;AACpB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAAQ,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,qBAAqB,CAAC,CAAC,SAAS,CAAC,EAAE,GAAG,IAAI,IAAI,GAAG,EAAE,EAAE,MAAM,CAAC,CAAA;gBACpF,CAAC;YACF,CAAC;QACF,CAAC;IACF,CAAC;IAED,mBAAmB;IACnB,IAAI,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;QAC/C,MAAM,GAAG,GAAG,wBAAwB,CAAC,CAAC,KAAK,CAAC,CAAA;QAC5C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACrC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,KAAK,EAAE,GAAG,IAAI,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,CAAA;QAC3D,CAAC;IACF,CAAC;AACF,CAAC"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Score a single driver against the project's runtime + required capabilities.
3
+ *
4
+ * @param {DriverManifest & {locality?: 'bundled'|'user'|'registry'}} manifest
5
+ * @param {RuntimeCapabilities} runtime
6
+ * @param {string[]} required
7
+ * @returns {{score: number[], reason?: string}}
8
+ */
9
+ export function scoreDriver(manifest: DriverManifest & {
10
+ locality?: "bundled" | "user" | "registry";
11
+ }, runtime: RuntimeCapabilities, required: string[]): {
12
+ score: number[];
13
+ reason?: string;
14
+ };
15
+ /**
16
+ * Resolve the best driver for a given (runtime, drivers, override, required)
17
+ * tuple.
18
+ *
19
+ * @param {Object} opts
20
+ * @param {DriverManifest[]} opts.drivers — manifests of every discovered driver.
21
+ * @param {RuntimeCapabilities} opts.runtime — project's runtime capabilities.
22
+ * @param {string[]} opts.required_capabilities — IDL verbs the test needs.
23
+ * @param {string[]} [opts.required_stability] — accepted stability values; default ['ga'].
24
+ * @param {string[]} [opts.override] — config.json:verification.runtimes[]: explicit driverId precedence.
25
+ * @returns {{selected: DriverManifest, fallback_attempts: Array<{driver_id: string, reason: string}>}}
26
+ * @throws {UnsatisfiedRequiredCapabilityError} when no driver satisfies a REQUIRED capability.
27
+ */
28
+ export function resolveDriver(opts: {
29
+ drivers: DriverManifest[];
30
+ runtime: RuntimeCapabilities;
31
+ required_capabilities: string[];
32
+ required_stability?: string[] | undefined;
33
+ override?: string[] | undefined;
34
+ }): {
35
+ selected: DriverManifest;
36
+ fallback_attempts: Array<{
37
+ driver_id: string;
38
+ reason: string;
39
+ }>;
40
+ };
41
+ export type DriverManifest = import("@aperant/driver-sdk").DriverManifest;
42
+ export type RuntimeCapabilities = import("./runtime-detect.mjs").RuntimeCapabilities;
43
+ //# sourceMappingURL=resolver.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolver.d.mts","sourceRoot":"","sources":["../../../src/cli/verify-proof/resolver.mjs"],"names":[],"mappings":"AA8BA;;;;;;;GAOG;AACH,sCALW,cAAc,GAAG;IAAC,QAAQ,CAAC,EAAE,SAAS,GAAC,MAAM,GAAC,UAAU,CAAA;CAAC,WACzD,mBAAmB,YACnB,MAAM,EAAE,GACN;IAAC,KAAK,EAAE,MAAM,EAAE,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAC,CAU9C;AA0CD;;;;;;;;;;;;GAYG;AACH,oCARG;IAA+B,OAAO,EAA9B,cAAc,EAAE;IACU,OAAO,EAAjC,mBAAmB;IACJ,qBAAqB,EAApC,MAAM,EAAE;IACQ,kBAAkB;IAClB,QAAQ;CAChC,GAAU;IAAC,QAAQ,EAAE,cAAc,CAAC;IAAC,iBAAiB,EAAE,KAAK,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAC,CAAC,CAAA;CAAC,CAgErG;6BA3IY,OAAO,qBAAqB,EAAE,cAAc;kCAC5C,OAAO,sBAAsB,EAAE,mBAAmB"}
@@ -0,0 +1,160 @@
1
+ /**
2
+ * resolver.mjs — driver selection + fallback chain.
3
+ *
4
+ * Given a project's runtime capabilities, the discovered drivers, and the
5
+ * test's required IDL capabilities, return the best driver — or throw
6
+ * UnsatisfiedRequiredCapabilityError if no driver in the chain satisfies
7
+ * a REQUIRED capability (ID-02 fail-closed).
8
+ *
9
+ * Scoring (ID-02, ordered high → low):
10
+ * 1. capability_coverage — how many required capabilities the driver has
11
+ * 2. compatibility — does the runtime match the manifest.targets?
12
+ * 3. stability — ga > beta > experimental
13
+ * 4. priority — higher wins (manifest.priority)
14
+ * 5. locality — bundled (packages/framework/drivers/) > user-installed
15
+ * (.aperant/drivers/) > registry (.aperant/registry-cache/)
16
+ *
17
+ * Ties are broken by the next dimension; if every dimension is equal the
18
+ * driver with the lexicographically smaller driverId wins (deterministic).
19
+ */
20
+ import { UnsatisfiedRequiredCapabilityError } from '@aperant/driver-sdk';
21
+ /**
22
+ * @typedef {import('@aperant/driver-sdk').DriverManifest} DriverManifest
23
+ * @typedef {import('./runtime-detect.mjs').RuntimeCapabilities} RuntimeCapabilities
24
+ */
25
+ const STABILITY_RANK = { ga: 3, beta: 2, experimental: 1 };
26
+ const LOCALITY_RANK = { bundled: 3, user: 2, registry: 1 };
27
+ /**
28
+ * Score a single driver against the project's runtime + required capabilities.
29
+ *
30
+ * @param {DriverManifest & {locality?: 'bundled'|'user'|'registry'}} manifest
31
+ * @param {RuntimeCapabilities} runtime
32
+ * @param {string[]} required
33
+ * @returns {{score: number[], reason?: string}}
34
+ */
35
+ export function scoreDriver(manifest, runtime, required) {
36
+ const caps = new Set(manifest.capabilities ?? []);
37
+ const coverage = required.filter((c) => caps.has(c)).length;
38
+ const compatibility = matchesRuntime(manifest, runtime) ? 1 : 0;
39
+ const stability = STABILITY_RANK[manifest.stability] ?? 0;
40
+ const priority = manifest.priority ?? 0;
41
+ const locality = LOCALITY_RANK[manifest.locality ?? 'bundled'] ?? 0;
42
+ return { score: [coverage, compatibility, stability, priority, locality] };
43
+ }
44
+ /**
45
+ * Whether a manifest's targets[] mentions a runtime the project has.
46
+ *
47
+ * @param {DriverManifest} manifest
48
+ * @param {RuntimeCapabilities} runtime
49
+ * @returns {boolean}
50
+ */
51
+ function matchesRuntime(manifest, runtime) {
52
+ const targets = manifest.targets ?? [];
53
+ for (const t of targets) {
54
+ // Strip any version range suffix (e.g. "electron@>=25" → "electron").
55
+ const stripped = String(t).split('@')[0].toLowerCase();
56
+ if (stripped === 'electron' && runtime.is_electron)
57
+ return true;
58
+ if (stripped === 'tauri' && runtime.is_tauri)
59
+ return true;
60
+ if ((stripped === 'browser' || stripped === 'web') && runtime.is_web_frontend)
61
+ return true;
62
+ if (stripped === 'next' && runtime.is_nextjs)
63
+ return true;
64
+ if (stripped === 'nuxt' && runtime.is_nuxt)
65
+ return true;
66
+ if (stripped === 'expo' && runtime.is_expo)
67
+ return true;
68
+ if (stripped === 'react-native' && runtime.is_react_native)
69
+ return true;
70
+ if (stripped === 'node' && runtime.has_node)
71
+ return true;
72
+ if (stripped === 'cli' && runtime.has_node)
73
+ return true;
74
+ if (stripped === 'api' && runtime.has_node)
75
+ return true;
76
+ if (stripped === 'fake')
77
+ return true; // fixture-only — always matches
78
+ }
79
+ return false;
80
+ }
81
+ /**
82
+ * Compare two driver-score tuples lexicographically.
83
+ * @param {number[]} a
84
+ * @param {number[]} b
85
+ * @returns {number}
86
+ */
87
+ function compareScores(a, b) {
88
+ for (let i = 0; i < Math.min(a.length, b.length); i++) {
89
+ if (a[i] !== b[i])
90
+ return b[i] - a[i]; // higher wins
91
+ }
92
+ return 0;
93
+ }
94
+ /**
95
+ * Resolve the best driver for a given (runtime, drivers, override, required)
96
+ * tuple.
97
+ *
98
+ * @param {Object} opts
99
+ * @param {DriverManifest[]} opts.drivers — manifests of every discovered driver.
100
+ * @param {RuntimeCapabilities} opts.runtime — project's runtime capabilities.
101
+ * @param {string[]} opts.required_capabilities — IDL verbs the test needs.
102
+ * @param {string[]} [opts.required_stability] — accepted stability values; default ['ga'].
103
+ * @param {string[]} [opts.override] — config.json:verification.runtimes[]: explicit driverId precedence.
104
+ * @returns {{selected: DriverManifest, fallback_attempts: Array<{driver_id: string, reason: string}>}}
105
+ * @throws {UnsatisfiedRequiredCapabilityError} when no driver satisfies a REQUIRED capability.
106
+ */
107
+ export function resolveDriver(opts) {
108
+ const drivers = opts.drivers ?? [];
109
+ const runtime = opts.runtime;
110
+ const required = opts.required_capabilities ?? [];
111
+ const stabilityFilter = new Set(opts.required_stability ?? ['ga']);
112
+ const override = opts.override ?? [];
113
+ const fallback = [];
114
+ // Apply override precedence first (config-listed driverIds come first).
115
+ const overrideOrdered = [];
116
+ const overrideSet = new Set(override);
117
+ for (const id of override) {
118
+ const d = drivers.find((m) => m.driverId === id);
119
+ if (d)
120
+ overrideOrdered.push(d);
121
+ }
122
+ const remaining = drivers.filter((m) => !overrideSet.has(m.driverId));
123
+ const ordered = [...overrideOrdered, ...remaining];
124
+ // Filter by stability; rejected drivers go into fallback_attempts.
125
+ const stableOnly = [];
126
+ for (const d of ordered) {
127
+ if (!stabilityFilter.has(d.stability)) {
128
+ fallback.push({
129
+ driver_id: d.driverId,
130
+ reason: `stability ${d.stability} not in allowed set [${[...stabilityFilter].join(', ')}]`,
131
+ });
132
+ continue;
133
+ }
134
+ stableOnly.push(d);
135
+ }
136
+ // Score every survivor against required capabilities.
137
+ const scored = stableOnly.map((m) => ({ manifest: m, ...scoreDriver(m, runtime, required) }));
138
+ // Sort highest-first, tie-break on driverId for determinism.
139
+ scored.sort((a, b) => {
140
+ const cmp = compareScores(a.score, b.score);
141
+ if (cmp !== 0)
142
+ return cmp;
143
+ return a.manifest.driverId.localeCompare(b.manifest.driverId);
144
+ });
145
+ // Pick the top scorer that covers EVERY required capability. Others go into fallback.
146
+ for (const candidate of scored) {
147
+ const caps = new Set(candidate.manifest.capabilities ?? []);
148
+ const missing = required.filter((c) => !caps.has(c));
149
+ if (missing.length === 0) {
150
+ return { selected: candidate.manifest, fallback_attempts: fallback };
151
+ }
152
+ fallback.push({
153
+ driver_id: candidate.manifest.driverId,
154
+ reason: `missing required capabilities: ${missing.join(', ')}`,
155
+ });
156
+ }
157
+ // Exhausted the chain — fail closed (ID-02).
158
+ throw new UnsatisfiedRequiredCapabilityError(`No driver in the chain satisfies every required capability: [${required.join(', ')}]`, required[0], fallback);
159
+ }
160
+ //# sourceMappingURL=resolver.mjs.map