@gpustack/loopwright 0.0.0-stage → 0.0.3

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 (477) hide show
  1. package/LICENSE +191 -0
  2. package/README.md +356 -2
  3. package/bin/loopwright.js +3 -0
  4. package/node_modules/@loopwright/agent-pi/dist/adapter-v2.d.ts +9 -0
  5. package/node_modules/@loopwright/agent-pi/dist/adapter-v2.js +122 -0
  6. package/node_modules/@loopwright/agent-pi/dist/adapter.d.ts +30 -0
  7. package/node_modules/@loopwright/agent-pi/dist/adapter.js +340 -0
  8. package/node_modules/@loopwright/agent-pi/dist/admission.d.ts +25 -0
  9. package/node_modules/@loopwright/agent-pi/dist/admission.js +65 -0
  10. package/node_modules/@loopwright/agent-pi/dist/artifacts.d.ts +15 -0
  11. package/node_modules/@loopwright/agent-pi/dist/artifacts.js +76 -0
  12. package/node_modules/@loopwright/agent-pi/dist/boundary.d.ts +18 -0
  13. package/node_modules/@loopwright/agent-pi/dist/boundary.js +113 -0
  14. package/node_modules/@loopwright/agent-pi/dist/broker-channel.d.ts +4 -0
  15. package/node_modules/@loopwright/agent-pi/dist/broker-channel.js +121 -0
  16. package/node_modules/@loopwright/agent-pi/dist/candidate.d.ts +96 -0
  17. package/node_modules/@loopwright/agent-pi/dist/candidate.js +1712 -0
  18. package/node_modules/@loopwright/agent-pi/dist/capture.d.ts +39 -0
  19. package/node_modules/@loopwright/agent-pi/dist/capture.js +146 -0
  20. package/node_modules/@loopwright/agent-pi/dist/cas.d.ts +51 -0
  21. package/node_modules/@loopwright/agent-pi/dist/cas.js +836 -0
  22. package/node_modules/@loopwright/agent-pi/dist/catalog-api.d.ts +3 -0
  23. package/node_modules/@loopwright/agent-pi/dist/catalog-api.js +2 -0
  24. package/node_modules/@loopwright/agent-pi/dist/catalog.d.ts +39 -0
  25. package/node_modules/@loopwright/agent-pi/dist/catalog.js +280 -0
  26. package/node_modules/@loopwright/agent-pi/dist/circuit-breaker-limits.d.ts +9 -0
  27. package/node_modules/@loopwright/agent-pi/dist/circuit-breaker-limits.js +12 -0
  28. package/node_modules/@loopwright/agent-pi/dist/containers.d.ts +29 -0
  29. package/node_modules/@loopwright/agent-pi/dist/containers.js +160 -0
  30. package/node_modules/@loopwright/agent-pi/dist/context.d.ts +56 -0
  31. package/node_modules/@loopwright/agent-pi/dist/context.js +351 -0
  32. package/node_modules/@loopwright/agent-pi/dist/daemon.d.ts +8 -0
  33. package/node_modules/@loopwright/agent-pi/dist/daemon.js +52 -0
  34. package/node_modules/@loopwright/agent-pi/dist/deadline.d.ts +6 -0
  35. package/node_modules/@loopwright/agent-pi/dist/deadline.js +18 -0
  36. package/node_modules/@loopwright/agent-pi/dist/decode-capture.d.ts +39 -0
  37. package/node_modules/@loopwright/agent-pi/dist/decode-capture.js +287 -0
  38. package/node_modules/@loopwright/agent-pi/dist/descriptor.d.ts +12 -0
  39. package/node_modules/@loopwright/agent-pi/dist/descriptor.js +17 -0
  40. package/node_modules/@loopwright/agent-pi/dist/docker-absence.d.ts +2 -0
  41. package/node_modules/@loopwright/agent-pi/dist/docker-absence.js +9 -0
  42. package/node_modules/@loopwright/agent-pi/dist/errors.d.ts +7 -0
  43. package/node_modules/@loopwright/agent-pi/dist/errors.js +19 -0
  44. package/node_modules/@loopwright/agent-pi/dist/event-sequence.d.ts +6 -0
  45. package/node_modules/@loopwright/agent-pi/dist/event-sequence.js +64 -0
  46. package/node_modules/@loopwright/agent-pi/dist/events.d.ts +19 -0
  47. package/node_modules/@loopwright/agent-pi/dist/events.js +132 -0
  48. package/node_modules/@loopwright/agent-pi/dist/execution-guard.d.ts +9 -0
  49. package/node_modules/@loopwright/agent-pi/dist/execution-guard.js +25 -0
  50. package/node_modules/@loopwright/agent-pi/dist/execution-lease.d.ts +24 -0
  51. package/node_modules/@loopwright/agent-pi/dist/execution-lease.js +316 -0
  52. package/node_modules/@loopwright/agent-pi/dist/execution.d.ts +32 -0
  53. package/node_modules/@loopwright/agent-pi/dist/execution.js +476 -0
  54. package/node_modules/@loopwright/agent-pi/dist/external-mcp.d.ts +87 -0
  55. package/node_modules/@loopwright/agent-pi/dist/external-mcp.js +526 -0
  56. package/node_modules/@loopwright/agent-pi/dist/factory-bootstrap.d.ts +15 -0
  57. package/node_modules/@loopwright/agent-pi/dist/factory-bootstrap.js +74 -0
  58. package/node_modules/@loopwright/agent-pi/dist/host-session.d.ts +51 -0
  59. package/node_modules/@loopwright/agent-pi/dist/host-session.js +2094 -0
  60. package/node_modules/@loopwright/agent-pi/dist/http-mcp.d.ts +32 -0
  61. package/node_modules/@loopwright/agent-pi/dist/http-mcp.js +353 -0
  62. package/node_modules/@loopwright/agent-pi/dist/index.d.ts +7 -0
  63. package/node_modules/@loopwright/agent-pi/dist/index.js +4 -0
  64. package/node_modules/@loopwright/agent-pi/dist/lifecycle.d.ts +13 -0
  65. package/node_modules/@loopwright/agent-pi/dist/lifecycle.js +11 -0
  66. package/node_modules/@loopwright/agent-pi/dist/mcp-process.d.ts +35 -0
  67. package/node_modules/@loopwright/agent-pi/dist/mcp-process.js +92 -0
  68. package/node_modules/@loopwright/agent-pi/dist/mcp-transport.d.ts +25 -0
  69. package/node_modules/@loopwright/agent-pi/dist/mcp-transport.js +63 -0
  70. package/node_modules/@loopwright/agent-pi/dist/mcp.d.ts +23 -0
  71. package/node_modules/@loopwright/agent-pi/dist/mcp.js +212 -0
  72. package/node_modules/@loopwright/agent-pi/dist/operation.d.ts +5 -0
  73. package/node_modules/@loopwright/agent-pi/dist/operation.js +28 -0
  74. package/node_modules/@loopwright/agent-pi/dist/policy-v2.d.ts +10 -0
  75. package/node_modules/@loopwright/agent-pi/dist/policy-v2.js +64 -0
  76. package/node_modules/@loopwright/agent-pi/dist/policy.d.ts +13 -0
  77. package/node_modules/@loopwright/agent-pi/dist/policy.js +260 -0
  78. package/node_modules/@loopwright/agent-pi/dist/preflight.d.ts +60 -0
  79. package/node_modules/@loopwright/agent-pi/dist/preflight.js +700 -0
  80. package/node_modules/@loopwright/agent-pi/dist/progress-summary.d.ts +1 -0
  81. package/node_modules/@loopwright/agent-pi/dist/progress-summary.js +119 -0
  82. package/node_modules/@loopwright/agent-pi/dist/protocol.d.ts +17 -0
  83. package/node_modules/@loopwright/agent-pi/dist/protocol.js +131 -0
  84. package/node_modules/@loopwright/agent-pi/dist/provider.d.ts +62 -0
  85. package/node_modules/@loopwright/agent-pi/dist/provider.js +217 -0
  86. package/node_modules/@loopwright/agent-pi/dist/receipt.d.ts +3 -0
  87. package/node_modules/@loopwright/agent-pi/dist/receipt.js +64 -0
  88. package/node_modules/@loopwright/agent-pi/dist/recovery.d.ts +6 -0
  89. package/node_modules/@loopwright/agent-pi/dist/recovery.js +188 -0
  90. package/node_modules/@loopwright/agent-pi/dist/resources.d.ts +13 -0
  91. package/node_modules/@loopwright/agent-pi/dist/resources.js +81 -0
  92. package/node_modules/@loopwright/agent-pi/dist/response.d.ts +20 -0
  93. package/node_modules/@loopwright/agent-pi/dist/response.js +259 -0
  94. package/node_modules/@loopwright/agent-pi/dist/runtime-profile.d.ts +6 -0
  95. package/node_modules/@loopwright/agent-pi/dist/runtime-profile.js +37 -0
  96. package/node_modules/@loopwright/agent-pi/dist/sdk-worker.d.ts +14 -0
  97. package/node_modules/@loopwright/agent-pi/dist/sdk-worker.js +633 -0
  98. package/node_modules/@loopwright/agent-pi/dist/sender.d.ts +46 -0
  99. package/node_modules/@loopwright/agent-pi/dist/sender.js +553 -0
  100. package/node_modules/@loopwright/agent-pi/dist/session-host.d.ts +21 -0
  101. package/node_modules/@loopwright/agent-pi/dist/session-host.js +315 -0
  102. package/node_modules/@loopwright/agent-pi/dist/snapshot-transfer.d.ts +14 -0
  103. package/node_modules/@loopwright/agent-pi/dist/snapshot-transfer.js +102 -0
  104. package/node_modules/@loopwright/agent-pi/dist/snapshot.d.ts +19 -0
  105. package/node_modules/@loopwright/agent-pi/dist/snapshot.js +121 -0
  106. package/node_modules/@loopwright/agent-pi/dist/tool-process.d.ts +32 -0
  107. package/node_modules/@loopwright/agent-pi/dist/tool-process.js +85 -0
  108. package/node_modules/@loopwright/agent-pi/dist/tool-worker.d.ts +2 -0
  109. package/node_modules/@loopwright/agent-pi/dist/tool-worker.js +105 -0
  110. package/node_modules/@loopwright/agent-pi/dist/tools.d.ts +36 -0
  111. package/node_modules/@loopwright/agent-pi/dist/tools.js +128 -0
  112. package/node_modules/@loopwright/agent-pi/dist/types-v2.d.ts +71 -0
  113. package/node_modules/@loopwright/agent-pi/dist/types-v2.js +1 -0
  114. package/node_modules/@loopwright/agent-pi/dist/types.d.ts +314 -0
  115. package/node_modules/@loopwright/agent-pi/dist/types.js +1 -0
  116. package/node_modules/@loopwright/agent-pi/dist/usage.d.ts +18 -0
  117. package/node_modules/@loopwright/agent-pi/dist/usage.js +314 -0
  118. package/node_modules/@loopwright/agent-pi/dist/workspace-mcp.d.ts +27 -0
  119. package/node_modules/@loopwright/agent-pi/dist/workspace-mcp.js +142 -0
  120. package/node_modules/@loopwright/agent-pi/package.json +24 -0
  121. package/node_modules/@loopwright/agent-pi/runtime/Dockerfile +8 -0
  122. package/node_modules/@loopwright/agent-pi/runtime/seccomp.json +1 -0
  123. package/node_modules/@loopwright/cli/dist/arguments.d.ts +19 -0
  124. package/node_modules/@loopwright/cli/dist/arguments.js +358 -0
  125. package/node_modules/@loopwright/cli/dist/closure.d.ts +93 -0
  126. package/node_modules/@loopwright/cli/dist/closure.js +230 -0
  127. package/node_modules/@loopwright/cli/dist/draft.d.ts +9 -0
  128. package/node_modules/@loopwright/cli/dist/draft.js +106 -0
  129. package/node_modules/@loopwright/cli/dist/failure-matrix.d.ts +9 -0
  130. package/node_modules/@loopwright/cli/dist/failure-matrix.js +701 -0
  131. package/node_modules/@loopwright/cli/dist/index.d.ts +6 -0
  132. package/node_modules/@loopwright/cli/dist/index.js +5 -0
  133. package/node_modules/@loopwright/cli/dist/main.d.ts +22 -0
  134. package/node_modules/@loopwright/cli/dist/main.js +1855 -0
  135. package/node_modules/@loopwright/cli/package.json +16 -0
  136. package/node_modules/@loopwright/controller/dist/acceptance.d.ts +43 -0
  137. package/node_modules/@loopwright/controller/dist/acceptance.js +446 -0
  138. package/node_modules/@loopwright/controller/dist/benchmark-gate.d.ts +273 -0
  139. package/node_modules/@loopwright/controller/dist/benchmark-gate.js +3147 -0
  140. package/node_modules/@loopwright/controller/dist/budget-observations.d.ts +25 -0
  141. package/node_modules/@loopwright/controller/dist/budget-observations.js +139 -0
  142. package/node_modules/@loopwright/controller/dist/bundle.d.ts +26 -0
  143. package/node_modules/@loopwright/controller/dist/bundle.js +64 -0
  144. package/node_modules/@loopwright/controller/dist/capture.d.ts +89 -0
  145. package/node_modules/@loopwright/controller/dist/capture.js +587 -0
  146. package/node_modules/@loopwright/controller/dist/compile.d.ts +3 -0
  147. package/node_modules/@loopwright/controller/dist/compile.js +402 -0
  148. package/node_modules/@loopwright/controller/dist/config.d.ts +22 -0
  149. package/node_modules/@loopwright/controller/dist/config.js +255 -0
  150. package/node_modules/@loopwright/controller/dist/controller.d.ts +177 -0
  151. package/node_modules/@loopwright/controller/dist/controller.js +2135 -0
  152. package/node_modules/@loopwright/controller/dist/credentials.d.ts +29 -0
  153. package/node_modules/@loopwright/controller/dist/credentials.js +189 -0
  154. package/node_modules/@loopwright/controller/dist/deadlines.d.ts +18 -0
  155. package/node_modules/@loopwright/controller/dist/deadlines.js +71 -0
  156. package/node_modules/@loopwright/controller/dist/errors.d.ts +27 -0
  157. package/node_modules/@loopwright/controller/dist/errors.js +41 -0
  158. package/node_modules/@loopwright/controller/dist/events.d.ts +52 -0
  159. package/node_modules/@loopwright/controller/dist/events.js +228 -0
  160. package/node_modules/@loopwright/controller/dist/files.d.ts +51 -0
  161. package/node_modules/@loopwright/controller/dist/files.js +386 -0
  162. package/node_modules/@loopwright/controller/dist/finalize.d.ts +25 -0
  163. package/node_modules/@loopwright/controller/dist/finalize.js +32 -0
  164. package/node_modules/@loopwright/controller/dist/gate.d.ts +84 -0
  165. package/node_modules/@loopwright/controller/dist/gate.js +640 -0
  166. package/node_modules/@loopwright/controller/dist/git-objects.d.ts +11 -0
  167. package/node_modules/@loopwright/controller/dist/git-objects.js +59 -0
  168. package/node_modules/@loopwright/controller/dist/git-reader.d.ts +17 -0
  169. package/node_modules/@loopwright/controller/dist/git-reader.js +40 -0
  170. package/node_modules/@loopwright/controller/dist/handlers.d.ts +6 -0
  171. package/node_modules/@loopwright/controller/dist/handlers.js +45 -0
  172. package/node_modules/@loopwright/controller/dist/handoff.d.ts +71 -0
  173. package/node_modules/@loopwright/controller/dist/handoff.js +554 -0
  174. package/node_modules/@loopwright/controller/dist/index.d.ts +41 -0
  175. package/node_modules/@loopwright/controller/dist/index.js +21 -0
  176. package/node_modules/@loopwright/controller/dist/inspect.d.ts +30 -0
  177. package/node_modules/@loopwright/controller/dist/inspect.js +372 -0
  178. package/node_modules/@loopwright/controller/dist/interpolation.d.ts +9 -0
  179. package/node_modules/@loopwright/controller/dist/interpolation.js +79 -0
  180. package/node_modules/@loopwright/controller/dist/ownership.d.ts +41 -0
  181. package/node_modules/@loopwright/controller/dist/ownership.js +666 -0
  182. package/node_modules/@loopwright/controller/dist/parser.d.ts +5 -0
  183. package/node_modules/@loopwright/controller/dist/parser.js +200 -0
  184. package/node_modules/@loopwright/controller/dist/progress.d.ts +41 -0
  185. package/node_modules/@loopwright/controller/dist/progress.js +904 -0
  186. package/node_modules/@loopwright/controller/dist/publication.d.ts +60 -0
  187. package/node_modules/@loopwright/controller/dist/publication.js +329 -0
  188. package/node_modules/@loopwright/controller/dist/reconcile.d.ts +26 -0
  189. package/node_modules/@loopwright/controller/dist/reconcile.js +1378 -0
  190. package/node_modules/@loopwright/controller/dist/recovery.d.ts +10 -0
  191. package/node_modules/@loopwright/controller/dist/recovery.js +315 -0
  192. package/node_modules/@loopwright/controller/dist/refusal-record.d.ts +43 -0
  193. package/node_modules/@loopwright/controller/dist/refusal-record.js +150 -0
  194. package/node_modules/@loopwright/controller/dist/registry.d.ts +6 -0
  195. package/node_modules/@loopwright/controller/dist/registry.js +374 -0
  196. package/node_modules/@loopwright/controller/dist/repair.d.ts +31 -0
  197. package/node_modules/@loopwright/controller/dist/repair.js +102 -0
  198. package/node_modules/@loopwright/controller/dist/report.d.ts +64 -0
  199. package/node_modules/@loopwright/controller/dist/report.js +596 -0
  200. package/node_modules/@loopwright/controller/dist/retained.d.ts +284 -0
  201. package/node_modules/@loopwright/controller/dist/retained.js +193 -0
  202. package/node_modules/@loopwright/controller/dist/rules.d.ts +31 -0
  203. package/node_modules/@loopwright/controller/dist/rules.js +110 -0
  204. package/node_modules/@loopwright/controller/dist/run-eval.d.ts +115 -0
  205. package/node_modules/@loopwright/controller/dist/run-eval.js +959 -0
  206. package/node_modules/@loopwright/controller/dist/scheduler.d.ts +10 -0
  207. package/node_modules/@loopwright/controller/dist/scheduler.js +41 -0
  208. package/node_modules/@loopwright/controller/dist/schema.d.ts +17 -0
  209. package/node_modules/@loopwright/controller/dist/schema.js +78 -0
  210. package/node_modules/@loopwright/controller/dist/source.d.ts +69 -0
  211. package/node_modules/@loopwright/controller/dist/source.js +872 -0
  212. package/node_modules/@loopwright/controller/dist/step.d.ts +38 -0
  213. package/node_modules/@loopwright/controller/dist/step.js +1776 -0
  214. package/node_modules/@loopwright/controller/dist/storage.d.ts +90 -0
  215. package/node_modules/@loopwright/controller/dist/storage.js +1345 -0
  216. package/node_modules/@loopwright/controller/dist/submission.d.ts +51 -0
  217. package/node_modules/@loopwright/controller/dist/submission.js +292 -0
  218. package/node_modules/@loopwright/controller/dist/types.d.ts +585 -0
  219. package/node_modules/@loopwright/controller/dist/types.js +9 -0
  220. package/node_modules/@loopwright/controller/dist/verification.d.ts +124 -0
  221. package/node_modules/@loopwright/controller/dist/verification.js +1308 -0
  222. package/node_modules/@loopwright/controller/dist/verifier-protocol.d.ts +105 -0
  223. package/node_modules/@loopwright/controller/dist/verifier-protocol.js +1312 -0
  224. package/node_modules/@loopwright/controller/dist/verifier-worker.d.ts +1 -0
  225. package/node_modules/@loopwright/controller/dist/verifier-worker.js +33 -0
  226. package/node_modules/@loopwright/controller/package.json +12 -0
  227. package/node_modules/@loopwright/core/dist/acceptance.d.ts +108 -0
  228. package/node_modules/@loopwright/core/dist/acceptance.js +327 -0
  229. package/node_modules/@loopwright/core/dist/artifacts.d.ts +63 -0
  230. package/node_modules/@loopwright/core/dist/artifacts.js +356 -0
  231. package/node_modules/@loopwright/core/dist/boundary.d.ts +21 -0
  232. package/node_modules/@loopwright/core/dist/boundary.js +484 -0
  233. package/node_modules/@loopwright/core/dist/contracts.d.ts +287 -0
  234. package/node_modules/@loopwright/core/dist/contracts.js +694 -0
  235. package/node_modules/@loopwright/core/dist/diagnostics.d.ts +21 -0
  236. package/node_modules/@loopwright/core/dist/diagnostics.js +51 -0
  237. package/node_modules/@loopwright/core/dist/evidence.d.ts +92 -0
  238. package/node_modules/@loopwright/core/dist/evidence.js +85 -0
  239. package/node_modules/@loopwright/core/dist/graph.d.ts +8 -0
  240. package/node_modules/@loopwright/core/dist/graph.js +44 -0
  241. package/node_modules/@loopwright/core/dist/identity.d.ts +162 -0
  242. package/node_modules/@loopwright/core/dist/identity.js +80 -0
  243. package/node_modules/@loopwright/core/dist/index.d.ts +30 -0
  244. package/node_modules/@loopwright/core/dist/index.js +39 -0
  245. package/node_modules/@loopwright/core/dist/limits.d.ts +99 -0
  246. package/node_modules/@loopwright/core/dist/limits.js +59 -0
  247. package/node_modules/@loopwright/core/dist/results.d.ts +161 -0
  248. package/node_modules/@loopwright/core/dist/results.js +98 -0
  249. package/node_modules/@loopwright/core/dist/scope.d.ts +13 -0
  250. package/node_modules/@loopwright/core/dist/scope.js +154 -0
  251. package/node_modules/@loopwright/core/dist/scrubber.d.ts +13 -0
  252. package/node_modules/@loopwright/core/dist/scrubber.js +63 -0
  253. package/node_modules/@loopwright/core/dist/usage.d.ts +68 -0
  254. package/node_modules/@loopwright/core/dist/usage.js +56 -0
  255. package/node_modules/@loopwright/core/package.json +12 -0
  256. package/node_modules/@loopwright/decisions/dist/benchmark.d.ts +23 -0
  257. package/node_modules/@loopwright/decisions/dist/benchmark.js +337 -0
  258. package/node_modules/@loopwright/decisions/dist/client.d.ts +74 -0
  259. package/node_modules/@loopwright/decisions/dist/client.js +292 -0
  260. package/node_modules/@loopwright/decisions/dist/index.d.ts +15 -0
  261. package/node_modules/@loopwright/decisions/dist/index.js +8 -0
  262. package/node_modules/@loopwright/decisions/dist/nodes.d.ts +63 -0
  263. package/node_modules/@loopwright/decisions/dist/nodes.js +282 -0
  264. package/node_modules/@loopwright/decisions/dist/primitives.d.ts +36 -0
  265. package/node_modules/@loopwright/decisions/dist/primitives.js +300 -0
  266. package/node_modules/@loopwright/decisions/dist/redaction.d.ts +23 -0
  267. package/node_modules/@loopwright/decisions/dist/redaction.js +146 -0
  268. package/node_modules/@loopwright/decisions/dist/router.d.ts +55 -0
  269. package/node_modules/@loopwright/decisions/dist/router.js +248 -0
  270. package/node_modules/@loopwright/decisions/dist/schema.d.ts +25 -0
  271. package/node_modules/@loopwright/decisions/dist/schema.js +536 -0
  272. package/node_modules/@loopwright/decisions/dist/types.d.ts +394 -0
  273. package/node_modules/@loopwright/decisions/dist/types.js +80 -0
  274. package/node_modules/@loopwright/decisions/package.json +12 -0
  275. package/node_modules/@loopwright/github-app/dist/action.d.ts +90 -0
  276. package/node_modules/@loopwright/github-app/dist/action.js +2429 -0
  277. package/node_modules/@loopwright/github-app/dist/config.d.ts +23 -0
  278. package/node_modules/@loopwright/github-app/dist/config.js +297 -0
  279. package/node_modules/@loopwright/github-app/dist/digests.d.ts +1 -0
  280. package/node_modules/@loopwright/github-app/dist/digests.js +1 -0
  281. package/node_modules/@loopwright/github-app/dist/index.d.ts +14 -0
  282. package/node_modules/@loopwright/github-app/dist/index.js +13 -0
  283. package/node_modules/@loopwright/github-app/dist/models-config.d.ts +1 -0
  284. package/node_modules/@loopwright/github-app/dist/models-config.js +1 -0
  285. package/node_modules/@loopwright/github-app/dist/output-format.d.ts +1 -0
  286. package/node_modules/@loopwright/github-app/dist/output-format.js +1 -0
  287. package/node_modules/@loopwright/github-app/dist/preflight.d.ts +1 -0
  288. package/node_modules/@loopwright/github-app/dist/preflight.js +1 -0
  289. package/node_modules/@loopwright/github-app/dist/publisher.d.ts +58 -0
  290. package/node_modules/@loopwright/github-app/dist/publisher.js +1368 -0
  291. package/node_modules/@loopwright/github-app/dist/qualification.d.ts +1 -0
  292. package/node_modules/@loopwright/github-app/dist/qualification.js +1 -0
  293. package/node_modules/@loopwright/github-app/dist/sandbox.d.ts +1 -0
  294. package/node_modules/@loopwright/github-app/dist/sandbox.js +1 -0
  295. package/node_modules/@loopwright/github-app/dist/schema.d.ts +1 -0
  296. package/node_modules/@loopwright/github-app/dist/schema.js +1 -0
  297. package/node_modules/@loopwright/github-app/dist/service.d.ts +52 -0
  298. package/node_modules/@loopwright/github-app/dist/service.js +1658 -0
  299. package/node_modules/@loopwright/github-app/dist/suite-pr-lookup.d.ts +90 -0
  300. package/node_modules/@loopwright/github-app/dist/suite-pr-lookup.js +392 -0
  301. package/node_modules/@loopwright/github-app/dist/taskpack.d.ts +1 -0
  302. package/node_modules/@loopwright/github-app/dist/taskpack.js +1 -0
  303. package/node_modules/@loopwright/github-app/dist/tenant-queue.d.ts +44 -0
  304. package/node_modules/@loopwright/github-app/dist/tenant-queue.js +423 -0
  305. package/node_modules/@loopwright/github-app/dist/token-broker.d.ts +50 -0
  306. package/node_modules/@loopwright/github-app/dist/token-broker.js +262 -0
  307. package/node_modules/@loopwright/github-app/dist/turnkey-memory.d.ts +35 -0
  308. package/node_modules/@loopwright/github-app/dist/turnkey-memory.js +1654 -0
  309. package/node_modules/@loopwright/github-app/dist/turnkey.d.ts +16 -0
  310. package/node_modules/@loopwright/github-app/dist/turnkey.js +34 -0
  311. package/node_modules/@loopwright/github-app/dist/types.d.ts +220 -0
  312. package/node_modules/@loopwright/github-app/dist/types.js +14 -0
  313. package/node_modules/@loopwright/github-app/dist/upstreams.d.ts +13 -0
  314. package/node_modules/@loopwright/github-app/dist/upstreams.js +65 -0
  315. package/node_modules/@loopwright/github-app/dist/webhook.d.ts +34 -0
  316. package/node_modules/@loopwright/github-app/dist/webhook.js +241 -0
  317. package/node_modules/@loopwright/github-app/dist/yaml.d.ts +1 -0
  318. package/node_modules/@loopwright/github-app/dist/yaml.js +1 -0
  319. package/node_modules/@loopwright/github-app/package.json +12 -0
  320. package/node_modules/@loopwright/hardware-runner/dist/config.d.ts +48 -0
  321. package/node_modules/@loopwright/hardware-runner/dist/config.js +719 -0
  322. package/node_modules/@loopwright/hardware-runner/dist/evaluator.d.ts +230 -0
  323. package/node_modules/@loopwright/hardware-runner/dist/evaluator.js +3178 -0
  324. package/node_modules/@loopwright/hardware-runner/dist/index.d.ts +13 -0
  325. package/node_modules/@loopwright/hardware-runner/dist/index.js +9 -0
  326. package/node_modules/@loopwright/hardware-runner/dist/provenance.d.ts +128 -0
  327. package/node_modules/@loopwright/hardware-runner/dist/provenance.js +1500 -0
  328. package/node_modules/@loopwright/hardware-runner/dist/queue.d.ts +81 -0
  329. package/node_modules/@loopwright/hardware-runner/dist/queue.js +1081 -0
  330. package/node_modules/@loopwright/hardware-runner/dist/relay-server.d.ts +13 -0
  331. package/node_modules/@loopwright/hardware-runner/dist/relay-server.js +2997 -0
  332. package/node_modules/@loopwright/hardware-runner/dist/types.d.ts +239 -0
  333. package/node_modules/@loopwright/hardware-runner/dist/types.js +12 -0
  334. package/node_modules/@loopwright/hardware-runner/dist/worker.d.ts +49 -0
  335. package/node_modules/@loopwright/hardware-runner/dist/worker.js +1648 -0
  336. package/node_modules/@loopwright/hardware-runner/package.json +12 -0
  337. package/node_modules/@loopwright/memory/dist/cas.d.ts +21 -0
  338. package/node_modules/@loopwright/memory/dist/cas.js +510 -0
  339. package/node_modules/@loopwright/memory/dist/compaction.d.ts +18 -0
  340. package/node_modules/@loopwright/memory/dist/compaction.js +110 -0
  341. package/node_modules/@loopwright/memory/dist/finalizer.d.ts +23 -0
  342. package/node_modules/@loopwright/memory/dist/finalizer.js +538 -0
  343. package/node_modules/@loopwright/memory/dist/index.d.ts +9 -0
  344. package/node_modules/@loopwright/memory/dist/index.js +8 -0
  345. package/node_modules/@loopwright/memory/dist/schema.d.ts +36 -0
  346. package/node_modules/@loopwright/memory/dist/schema.js +510 -0
  347. package/node_modules/@loopwright/memory/dist/selector.d.ts +7 -0
  348. package/node_modules/@loopwright/memory/dist/selector.js +157 -0
  349. package/node_modules/@loopwright/memory/dist/store.d.ts +51 -0
  350. package/node_modules/@loopwright/memory/dist/store.js +554 -0
  351. package/node_modules/@loopwright/memory/dist/types.d.ts +442 -0
  352. package/node_modules/@loopwright/memory/dist/types.js +8 -0
  353. package/node_modules/@loopwright/memory/dist/verifier.d.ts +5 -0
  354. package/node_modules/@loopwright/memory/dist/verifier.js +328 -0
  355. package/node_modules/@loopwright/memory/package.json +12 -0
  356. package/node_modules/@loopwright/state/dist/admission.d.ts +321 -0
  357. package/node_modules/@loopwright/state/dist/admission.js +199 -0
  358. package/node_modules/@loopwright/state/dist/boundary.d.ts +53 -0
  359. package/node_modules/@loopwright/state/dist/boundary.js +194 -0
  360. package/node_modules/@loopwright/state/dist/checkpoint.d.ts +16 -0
  361. package/node_modules/@loopwright/state/dist/checkpoint.js +84 -0
  362. package/node_modules/@loopwright/state/dist/clock.d.ts +8 -0
  363. package/node_modules/@loopwright/state/dist/clock.js +27 -0
  364. package/node_modules/@loopwright/state/dist/connection.d.ts +55 -0
  365. package/node_modules/@loopwright/state/dist/connection.js +391 -0
  366. package/node_modules/@loopwright/state/dist/errors.d.ts +13 -0
  367. package/node_modules/@loopwright/state/dist/errors.js +34 -0
  368. package/node_modules/@loopwright/state/dist/index.d.ts +3 -0
  369. package/node_modules/@loopwright/state/dist/index.js +1 -0
  370. package/node_modules/@loopwright/state/dist/journal.d.ts +119 -0
  371. package/node_modules/@loopwright/state/dist/journal.js +72 -0
  372. package/node_modules/@loopwright/state/dist/model.d.ts +40 -0
  373. package/node_modules/@loopwright/state/dist/model.js +58 -0
  374. package/node_modules/@loopwright/state/dist/ownership.d.ts +14 -0
  375. package/node_modules/@loopwright/state/dist/ownership.js +45 -0
  376. package/node_modules/@loopwright/state/dist/pages.d.ts +11 -0
  377. package/node_modules/@loopwright/state/dist/pages.js +41 -0
  378. package/node_modules/@loopwright/state/dist/receipts.d.ts +33 -0
  379. package/node_modules/@loopwright/state/dist/receipts.js +97 -0
  380. package/node_modules/@loopwright/state/dist/schema.d.ts +28 -0
  381. package/node_modules/@loopwright/state/dist/schema.js +41 -0
  382. package/node_modules/@loopwright/state/dist/settlement.d.ts +10 -0
  383. package/node_modules/@loopwright/state/dist/settlement.js +129 -0
  384. package/node_modules/@loopwright/state/dist/store.d.ts +52 -0
  385. package/node_modules/@loopwright/state/dist/store.js +100 -0
  386. package/node_modules/@loopwright/state/dist/types.d.ts +315 -0
  387. package/node_modules/@loopwright/state/dist/types.js +1 -0
  388. package/node_modules/@loopwright/state/package.json +12 -0
  389. package/node_modules/@loopwright/taskpack/dist/baseline-align.d.ts +195 -0
  390. package/node_modules/@loopwright/taskpack/dist/baseline-align.js +1847 -0
  391. package/node_modules/@loopwright/taskpack/dist/digests.d.ts +61 -0
  392. package/node_modules/@loopwright/taskpack/dist/digests.js +715 -0
  393. package/node_modules/@loopwright/taskpack/dist/index.d.ts +18 -0
  394. package/node_modules/@loopwright/taskpack/dist/index.js +17 -0
  395. package/node_modules/@loopwright/taskpack/dist/models-config.d.ts +112 -0
  396. package/node_modules/@loopwright/taskpack/dist/models-config.js +1026 -0
  397. package/node_modules/@loopwright/taskpack/dist/output-format.d.ts +28 -0
  398. package/node_modules/@loopwright/taskpack/dist/output-format.js +157 -0
  399. package/node_modules/@loopwright/taskpack/dist/preflight.d.ts +130 -0
  400. package/node_modules/@loopwright/taskpack/dist/preflight.js +1497 -0
  401. package/node_modules/@loopwright/taskpack/dist/qualification.d.ts +23 -0
  402. package/node_modules/@loopwright/taskpack/dist/qualification.js +120 -0
  403. package/node_modules/@loopwright/taskpack/dist/sandbox.d.ts +121 -0
  404. package/node_modules/@loopwright/taskpack/dist/sandbox.js +2642 -0
  405. package/node_modules/@loopwright/taskpack/dist/schema.d.ts +197 -0
  406. package/node_modules/@loopwright/taskpack/dist/schema.js +4189 -0
  407. package/node_modules/@loopwright/taskpack/dist/scrubber.d.ts +47 -0
  408. package/node_modules/@loopwright/taskpack/dist/scrubber.js +283 -0
  409. package/node_modules/@loopwright/taskpack/dist/suite.d.ts +124 -0
  410. package/node_modules/@loopwright/taskpack/dist/suite.js +3256 -0
  411. package/node_modules/@loopwright/taskpack/dist/taskpack.d.ts +154 -0
  412. package/node_modules/@loopwright/taskpack/dist/taskpack.js +3634 -0
  413. package/node_modules/@loopwright/taskpack/dist/turnkey-memory.d.ts +122 -0
  414. package/node_modules/@loopwright/taskpack/dist/turnkey-memory.js +483 -0
  415. package/node_modules/@loopwright/taskpack/dist/turnkey.d.ts +437 -0
  416. package/node_modules/@loopwright/taskpack/dist/turnkey.js +7335 -0
  417. package/node_modules/@loopwright/taskpack/dist/types.d.ts +1274 -0
  418. package/node_modules/@loopwright/taskpack/dist/types.js +99 -0
  419. package/node_modules/@loopwright/taskpack/dist/upstreams.d.ts +261 -0
  420. package/node_modules/@loopwright/taskpack/dist/upstreams.js +2242 -0
  421. package/node_modules/@loopwright/taskpack/dist/yaml.d.ts +18 -0
  422. package/node_modules/@loopwright/taskpack/dist/yaml.js +167 -0
  423. package/node_modules/@loopwright/taskpack/package.json +12 -0
  424. package/node_modules/@loopwright/taskpack-runner/dist/compile-taskpack.d.ts +137 -0
  425. package/node_modules/@loopwright/taskpack-runner/dist/compile-taskpack.js +474 -0
  426. package/node_modules/@loopwright/taskpack-runner/dist/corpus.d.ts +8 -0
  427. package/node_modules/@loopwright/taskpack-runner/dist/corpus.js +129 -0
  428. package/node_modules/@loopwright/taskpack-runner/dist/index.d.ts +13 -0
  429. package/node_modules/@loopwright/taskpack-runner/dist/index.js +7 -0
  430. package/node_modules/@loopwright/taskpack-runner/dist/intake.d.ts +149 -0
  431. package/node_modules/@loopwright/taskpack-runner/dist/intake.js +135 -0
  432. package/node_modules/@loopwright/taskpack-runner/dist/parity.d.ts +130 -0
  433. package/node_modules/@loopwright/taskpack-runner/dist/parity.js +927 -0
  434. package/node_modules/@loopwright/taskpack-runner/dist/python-bridge.d.ts +68 -0
  435. package/node_modules/@loopwright/taskpack-runner/dist/python-bridge.js +517 -0
  436. package/node_modules/@loopwright/taskpack-runner/dist/service.d.ts +149 -0
  437. package/node_modules/@loopwright/taskpack-runner/dist/service.js +1796 -0
  438. package/node_modules/@loopwright/taskpack-runner/dist/types.d.ts +29 -0
  439. package/node_modules/@loopwright/taskpack-runner/dist/types.js +11 -0
  440. package/node_modules/@loopwright/taskpack-runner/package.json +12 -0
  441. package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/README.md +77 -0
  442. package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/docs/support-records.md +57 -0
  443. package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/docs/supported-runners.md +98 -0
  444. package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/manifest.json +205 -0
  445. package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/pack/expand_matrix.sh +273 -0
  446. package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/pack/matrix.yaml +280 -0
  447. package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/pack/resolve_dockerfile.sh +24 -0
  448. package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/pyproject.toml +46 -0
  449. package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/runtime_runner/runner.py.json +5270 -0
  450. package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tests/auto_sync/fixtures/discovery/legacy-support.md +86 -0
  451. package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tests/auto_sync/fixtures/github/service.py +401 -0
  452. package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tests/auto_sync/fixtures/proposals/analysis.json +95 -0
  453. package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tests/auto_sync/fixtures/proposals/ready.json +109 -0
  454. package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tests/auto_sync/test_assemble.py +263 -0
  455. package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tests/auto_sync/test_check_draft.py +333 -0
  456. package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tests/auto_sync/test_checks.py +1099 -0
  457. package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tests/auto_sync/test_discovery.py +817 -0
  458. package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tests/auto_sync/test_proposal.py +658 -0
  459. package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tests/auto_sync/test_publish.py +987 -0
  460. package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tests/auto_sync/test_summary.py +107 -0
  461. package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tools/auto_sync/agent.py +610 -0
  462. package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tools/auto_sync/assemble.py +84 -0
  463. package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tools/auto_sync/check_draft.py +94 -0
  464. package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tools/auto_sync/checks.py +1002 -0
  465. package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tools/auto_sync/discovery.py +789 -0
  466. package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tools/auto_sync/model.py +557 -0
  467. package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tools/auto_sync/progress.py +174 -0
  468. package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tools/auto_sync/prompts/analysis.md +40 -0
  469. package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tools/auto_sync/prompts/proposal.md +65 -0
  470. package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tools/auto_sync/prompts/repair.md +17 -0
  471. package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tools/auto_sync/proposal.py +903 -0
  472. package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tools/auto_sync/publish.py +997 -0
  473. package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tools/auto_sync/summary.py +131 -0
  474. package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tools/auto_sync/tool-versions.json +133 -0
  475. package/node_modules/package-lock.json +3025 -0
  476. package/package-lock.json +3025 -0
  477. package/package.json +52 -4
@@ -0,0 +1,701 @@
1
+ import { execFile } from 'node:child_process';
2
+ import { createHash } from 'node:crypto';
3
+ import { chmod, lstat, mkdir, mkdtemp, readdir, readFile, realpath, rm, writeFile } from 'node:fs/promises';
4
+ import { tmpdir } from 'node:os';
5
+ import { join } from 'node:path';
6
+ import { performance } from 'node:perf_hooks';
7
+ import { promisify } from 'node:util';
8
+ import { admitTask, bindSubject, constructRunResult, digestArtifact, evaluateAcceptance, isWritablePath, validateDocument } from '@loopwright/core';
9
+ import { createLocalRun } from '@loopwright/state';
10
+ import { loadTrustedConfiguration, readStatus, reconcileCycle, signPayload, verifySignedPayload } from '@loopwright/controller';
11
+ import { describePiAdapterFiles, decodePiCapture } from '@loopwright/agent-pi';
12
+ import { DecisionBudgetTracker, DecisionError, DEFAULT_DECISION_POLICY, assertDecisionAuthorityBoundary, evaluateDecision, sanitizeDecisionState } from '@loopwright/decisions';
13
+ import { buildCompactionSummary, evaluateCompactionPolicy, restoreFromCompactionLedger, selectActiveMemory, storeDigestOf } from '@loopwright/memory';
14
+ import { compileLinuxBwrapCommand, compileMacosSeatbeltProfile, loadDeclarativeTaskpack, negotiateSandboxBackend, TaskpackError, validateMcpAuthConfiguration, validateTaskpackManifest } from '@loopwright/taskpack';
15
+ import { GitHubAppError } from '@loopwright/github-app';
16
+ import { computeRunnerCandidateDigest, defaultCorpusRoot, startRunnerTaskpackService } from '@loopwright/taskpack-runner';
17
+ import { diagnosticExit, executionExit } from './main.js';
18
+ export const INTEGRATED_FAILURE_SCENARIO_IDS = Object.freeze([
19
+ 'malformed_or_conflicting_json_submission', 'forged_test_pass_without_verifier_evidence',
20
+ 'missing_provider_usage_retained_reservation', 'nested_tool_double_debit_prevention',
21
+ 'provider_and_decision_deadline_timeout', 'concurrent_owner_and_budget_exhaustion',
22
+ 'signal_interruption_and_workspace_loss', 'unknown_external_effect_reconcile_gate',
23
+ 'expired_or_stale_gate_token_rejection', 'mutated_pr_head_publication_abort',
24
+ 'stale_memory_source_exclusion', 'compaction_pending_operation_preservation',
25
+ 'untrusted_taskpack_and_oauth_boundary_refusal', 'decision_authority_escalation_refusal',
26
+ ]);
27
+ const GIT_ENV = { HOME: '/nonexistent', PATH: '/usr/bin:/bin', LANG: 'C', LC_ALL: 'C', GIT_CONFIG_NOSYSTEM: '1', GIT_CONFIG_GLOBAL: '/dev/null', GIT_TERMINAL_PROMPT: '0' };
28
+ const hexOf = (seed) => ({ algorithm: 'sha256', hex: createHash('sha256').update(seed).digest('hex') });
29
+ function unwrap(result) {
30
+ if (result.ok)
31
+ return result.value;
32
+ throw new Error('errors' in result ? result.errors[0]?.code ?? 'REFUSED' : result.error.code);
33
+ }
34
+ function codeOf(error) {
35
+ if (error instanceof DecisionError || error instanceof GitHubAppError || error instanceof TaskpackError)
36
+ return error.code;
37
+ if (error instanceof Error && 'code' in error && typeof error.code === 'string')
38
+ return error.code;
39
+ return error instanceof Error ? error.name : 'SCENARIO_FAULT';
40
+ }
41
+ async function probe(id, run) {
42
+ const started = performance.now();
43
+ try {
44
+ return await run();
45
+ }
46
+ catch (error) {
47
+ return { scenarioId: id, passed: false, diagnosticCode: codeOf(error), assertions: [], elapsedMs: Math.round(performance.now() - started) };
48
+ }
49
+ }
50
+ function outcome(id, started, assertions, failures, diagnosticCode) {
51
+ const recorded = [...assertions, ...failures.map(failure => `FAILED: ${failure}`)];
52
+ return { scenarioId: id, passed: failures.length === 0, diagnosticCode: failures.length === 0 ? diagnosticCode : diagnosticCode ?? 'ASSERTION_FAILED', assertions: recorded, elapsedMs: Math.round(performance.now() - started) };
53
+ }
54
+ function recorder() {
55
+ const claims = [], failed = [];
56
+ return {
57
+ assert: (condition, claim) => { (condition ? claims : failed).push(condition ? claim : `${claim} [condition false]`); return condition; },
58
+ expect: (observed, expected, claim) => { (observed === expected ? claims : failed).push(observed === expected ? claim : `${claim} [observed=${observed} expected=${expected}]`); return observed === expected; },
59
+ claims: () => claims, failed: () => failed,
60
+ };
61
+ }
62
+ function contractFixture(totalTokens = 1000) {
63
+ return {
64
+ apiVersion: 'loopwright.dev/v1alpha1', kind: 'TaskContract',
65
+ spec: {
66
+ goal: 'Update the pinned package', taskpack: 'package-update',
67
+ target: { repository: 'team/repository', baseRevision: 'base-1', sourceRevision: 'source-1', matrix: null },
68
+ scope: { writable: ['packages/**'], protected: ['packages/policy/**'] },
69
+ roles: [{ id: 'builder', adapter: 'pi', provider: 'github-copilot', model: 'exact-model', thinking: 'high', tools: ['read'] }],
70
+ trustedContext: { revision: 'context-1', discovery: 'disabled', resources: [] },
71
+ budgets: { wallTimeMs: 60000, totalTokens, perCallOutputTokens: 100, maxModelCalls: 10, maxConcurrency: 2, maxFormatRepairs: 0, maxImplementationRepairs: 2, maxTransportRetries: 1,
72
+ enforcement: { wallTime: 'hard_admission', tokens: 'soft_accounting', modelCalls: 'hard_admission', concurrency: 'hard_admission', formatRepairs: 'hard_admission', implementationRepairs: 'hard_admission', transportRetries: 'hard_admission' } },
73
+ steps: [{ id: 'build', kind: 'agent', uses: 'package.patch', roleId: 'builder', dependsOn: [] }],
74
+ acceptance: { required: ['tests'], checks: [{ id: 'tests', allowedEvidenceLevels: ['local_execution'] }] },
75
+ },
76
+ };
77
+ }
78
+ function stateIdentity(directory, lock) {
79
+ return { directory, storeId: 'store-1', lock, policy: { version: 1, leaseMs: 10000, cost: 'observe_only' },
80
+ binding: { coreApiVersion: 'loopwright.dev/v1alpha1', hostVersion: 'closure-matrix', adapters: [{ id: 'pi', version: '1.5.0' }], resourceVersion: 'fixture-host', clockEpoch: 'fixture-boot' } };
81
+ }
82
+ function requestFixture(requestId = 'request-1', patch = {}) {
83
+ return { requestId, roleId: 'builder', nodeId: 'build', attemptId: `attempt-${requestId}`, purpose: 'task', repair: 'none', transportRetryOf: null,
84
+ requestDigest: hexOf('request'), inputUpperBound: 80, outputUpperBound: 20, totalUpperBound: 100,
85
+ capability: { adapterId: 'pi', adapterVersion: '1.5.0', provider: 'github-copilot', model: 'exact-model', kind: 'hard_bound', coversAllBillableTokens: true, enforcesOutputBound: true },
86
+ operationId: `op-${requestId}`, targetIdentity: 'provider/request', ...patch };
87
+ }
88
+ async function scratchDirectory(prefix) { return realpath(await mkdtemp(join(await realpath(tmpdir()), prefix))); }
89
+ async function scenarioOne() {
90
+ const id = 'malformed_or_conflicting_json_submission', started = performance.now(), r = recorder();
91
+ const duplicateCore = validateDocument('{"metadata":{"id":"x"},"metadata":{"id":"y"}}', 'TaskContract');
92
+ r.expect(duplicateCore.ok ? '' : duplicateCore.errors[0].code, 'JSON_DUPLICATE_MEMBER', 'core refuses duplicate JSON members with JSON_DUPLICATE_MEMBER');
93
+ const brokenCore = validateDocument('{"metadata":', 'TaskContract');
94
+ r.expect(brokenCore.ok ? '' : brokenCore.errors[0].code, 'JSON_SYNTAX', 'core refuses truncated JSON with JSON_SYNTAX');
95
+ const root = await scratchDirectory('lw-fm-json-');
96
+ const registry = { apiVersion: 'loopwright.dev/v1alpha1', kind: 'TrustedRegistry', metadata: { name: 'operator' }, spec: { version: 1, resourceVersion: 'context-draft', handlers: [], roleProfiles: [], runtimeProfiles: [], resources: [], credentialBindings: [], environmentBindings: [] } };
97
+ const registryBytes = Buffer.from(JSON.stringify(registry));
98
+ const operator = join(root, 'operator'), task = join(root, 'task');
99
+ await mkdir(operator, { mode: 0o700 });
100
+ await mkdir(task, { mode: 0o700 });
101
+ try {
102
+ const duplicatedRegistry = JSON.stringify(registry).replace('"spec":{', '"spec":{"version":1,');
103
+ const duplicatedBytes = Buffer.from(duplicatedRegistry);
104
+ await writeFile(join(operator, 'duplicated-registry.json'), duplicatedBytes, { mode: 0o600 });
105
+ await writeFile(join(task, 'config.json'), '{"apiVersion":"loopwright.dev/v1alpha1"}', { mode: 0o600 });
106
+ const duplicateLoaded = await loadTrustedConfiguration({ configPath: join(task, 'config.json'), registryPath: join(operator, 'duplicated-registry.json'), registrySha256: createHash('sha256').update(duplicatedBytes).digest('hex'), untrustedRoots: [task] });
107
+ r.expect(duplicateLoaded.ok ? '' : duplicateLoaded.error.code, 'CONFIG_DUPLICATE_KEY', 'controller refuses duplicate-key JSON with CONFIG_DUPLICATE_KEY');
108
+ await writeFile(join(operator, 'registry.json'), registryBytes, { mode: 0o600 });
109
+ await writeFile(join(task, 'config.json'), 'definitely not json {', { mode: 0o600 });
110
+ const syntaxLoaded = await loadTrustedConfiguration({ configPath: join(task, 'config.json'), registryPath: join(operator, 'registry.json'), registrySha256: createHash('sha256').update(registryBytes).digest('hex'), untrustedRoots: [task] });
111
+ r.expect(syntaxLoaded.ok ? '' : syntaxLoaded.error.code, 'CONFIG_SYNTAX', 'controller refuses non-JSON configuration with CONFIG_SYNTAX');
112
+ }
113
+ finally {
114
+ await rm(root, { recursive: true, force: true });
115
+ }
116
+ return outcome(id, started, r.claims(), r.failed(), 'JSON_DUPLICATE_MEMBER');
117
+ }
118
+ function acceptanceInputs(observedStatus) {
119
+ const lock = unwrap(admitTask(contractFixture(), { admissionId: 'admission-1', runId: 'run-1' }));
120
+ const candidateBytes = Buffer.from('candidate patch\n'), logBytes = Buffer.from('test output: pass\n');
121
+ const candidateManifest = { apiVersion: 'loopwright.dev/v1alpha1', kind: 'ArtifactManifest', metadata: { id: 'candidate' }, spec: { entries: [unwrap(digestArtifact('candidate.patch', candidateBytes))] } };
122
+ const subject = unwrap(bindSubject(lock, candidateManifest));
123
+ const evidence = { apiVersion: 'loopwright.dev/v1alpha1', kind: 'Evidence', metadata: { id: 'observation-1' }, spec: { checkId: 'tests', observedStatus, producerId: 'host-verifier', method: 'node-test', level: 'local_execution', subject: structuredClone(subject), artifacts: [unwrap(digestArtifact('test.log', logBytes))], reason: observedStatus === 'failed' ? 'trusted command failed' : null } };
124
+ const artifacts = [{ name: 'candidate.patch', bytes: candidateBytes }, { name: 'test.log', bytes: logBytes }];
125
+ return { lock, candidateManifest, evidence, artifacts };
126
+ }
127
+ async function scenarioTwo() {
128
+ const id = 'forged_test_pass_without_verifier_evidence', started = performance.now(), r = recorder();
129
+ const forged = acceptanceInputs('failed');
130
+ const claims = [{ checkId: 'tests', status: 'passed', evidenceId: 'observation-1', reason: null }];
131
+ const evaluated = evaluateAcceptance({ trusted: { expectedLock: forged.lock, candidateManifest: forged.candidateManifest, eligibleEvidence: [forged.evidence] }, claims }, forged.artifacts);
132
+ r.expect(evaluated.ok ? '' : evaluated.errors[0].code, 'EVIDENCE_CONTRADICTORY', 'acceptance refuses a claimed pass over failed verifier evidence with EVIDENCE_CONTRADICTORY');
133
+ const missing = acceptanceInputs('passed');
134
+ const missingEvaluated = evaluateAcceptance({ trusted: { expectedLock: missing.lock, candidateManifest: missing.candidateManifest, eligibleEvidence: [] }, claims: [{ checkId: 'tests', status: 'passed', evidenceId: null, reason: null }] }, missing.artifacts);
135
+ r.expect(missingEvaluated.ok ? 'passed' : '', 'passed', 'acceptance still evaluates; the missing-evidence check resolves blocked below');
136
+ if (missingEvaluated.ok)
137
+ r.expect(missingEvaluated.value.spec.diagnostics[0]?.code ?? '', 'EVIDENCE_MISSING', 'a claimed pass without evidence stays blocked with EVIDENCE_MISSING');
138
+ const constructed = constructRunResult({ trusted: { expectedLock: forged.lock, candidateManifest: forged.candidateManifest, eligibleEvidence: [forged.evidence], usage: [], externalEffects: 'none', noChange: null }, candidate: { status: 'completed', checks: claims, memory: { status: 'not_requested', reason: null } } }, forged.artifacts);
139
+ r.expect(constructed.ok ? '' : constructed.errors[0].code, 'EVIDENCE_CONTRADICTORY', 'run-result construction refuses a forged completed status');
140
+ const unproven = constructRunResult({ trusted: { expectedLock: forged.lock, candidateManifest: forged.candidateManifest, eligibleEvidence: [], usage: [], externalEffects: 'none', noChange: null }, candidate: { status: 'completed', checks: [], memory: { status: 'not_requested', reason: null } } }, forged.artifacts);
141
+ r.expect(unproven.ok ? '' : unproven.errors[0].code, 'RUN_ACCEPTANCE_REQUIRED', 'completed without satisfied acceptance refuses with RUN_ACCEPTANCE_REQUIRED');
142
+ return outcome(id, started, r.claims(), r.failed(), 'EVIDENCE_CONTRADICTORY');
143
+ }
144
+ async function stateFixture(totalTokens) {
145
+ const root = await scratchDirectory('lw-fm-state-');
146
+ const lock = unwrap(admitTask(contractFixture(totalTokens), { admissionId: 'admission-1', runId: 'run-1' }));
147
+ const store = unwrap(createLocalRun(stateIdentity(join(root, 'store'), lock)));
148
+ const owner = unwrap(store.claim({ ownerId: 'owner-a', expectedGeneration: 0, expectedRevision: 0, mode: 'active' }));
149
+ return { root, store, owner };
150
+ }
151
+ async function scenarioThree() {
152
+ const id = 'missing_provider_usage_retained_reservation', started = performance.now(), r = recorder();
153
+ const tracker = new DecisionBudgetTracker({ maxInputTokens: 1000 });
154
+ tracker.reserve(500);
155
+ tracker.retainUnknown(500);
156
+ r.expect(String(tracker.snapshot().unknownUsageRetained), 'true', 'decision budget retains unknown provider usage');
157
+ const state = await stateFixture(1000);
158
+ try {
159
+ const reserved = unwrap(state.store.reserveRequest(state.owner.authority, requestFixture()));
160
+ r.expect(reserved.kind, 'created', 'state reserves the provider request');
161
+ unwrap(state.store.authorizeRequestDispatch(state.owner.authority, 'request-1'));
162
+ unwrap(state.store.markRequestUnresolved(state.owner.authority, 'request-1', 'timeout'));
163
+ const record = unwrap(state.store.getRequest('request-1'));
164
+ r.expect(String(record.state), 'unresolved', 'the lost request parks unresolved');
165
+ r.expect(String(record.unresolvedReason), 'timeout', 'the unresolved reason is timeout');
166
+ const view = unwrap(state.store.inspect());
167
+ r.expect(String(view.ledger.chargedTokens.decimal), '100', 'the reservation stays charged with no refund');
168
+ }
169
+ finally {
170
+ state.store.close();
171
+ await rm(state.root, { recursive: true, force: true });
172
+ }
173
+ return outcome(id, started, r.claims(), r.failed(), 'COMMIT_UNKNOWN');
174
+ }
175
+ async function scenarioFour() {
176
+ const id = 'nested_tool_double_debit_prevention', started = performance.now(), r = recorder();
177
+ const contract = contractFixture();
178
+ const denied = isWritablePath(contract, 'packages/policy/secret.json');
179
+ r.expect(String(denied.ok && denied.value), 'false', 'a protected-path tool write is blocked before execution');
180
+ const allowed = isWritablePath(contract, 'packages/readme.md');
181
+ r.expect(String(allowed.ok && allowed.value), 'true', 'a writable-path tool write stays admitted');
182
+ const state = await stateFixture(1000);
183
+ try {
184
+ unwrap(state.store.reserveRequest(state.owner.authority, requestFixture()));
185
+ const first = unwrap(state.store.authorizeRequestDispatch(state.owner.authority, 'request-1'));
186
+ r.expect(String(first.kind), 'new_dispatch', 'the first dispatch authorizes one permit');
187
+ const firstPermit = first.kind === 'new_dispatch' ? first.permit : null;
188
+ const second = unwrap(state.store.authorizeRequestDispatch(state.owner.authority, 'request-1'));
189
+ r.expect(String(second.kind), 'existing', 'a repeated dispatch re-issues the existing permit');
190
+ r.expect(String(second.kind === 'existing' ? second.record.dispatch?.dispatchId : ''), String(firstPermit?.dispatchId ?? ''), 'no second generation is minted, so the parent reservation never double-debits');
191
+ const view = unwrap(state.store.inspect());
192
+ r.expect(String(view.ledger.chargedTokens.decimal), '100', 'the ledger charges the single attempt exactly once');
193
+ // @loopwright/agent-pi: the frozen adapter inventory resolves, and a capture bound to a foreign
194
+ // resource identity is refused deterministically before any execution, without Docker or network.
195
+ const described = await describePiAdapterFiles();
196
+ r.expect(String(described.ok), 'true', 'the frozen Pi adapter file inventory resolves');
197
+ if (described.ok)
198
+ r.assert(described.value.sdkIntegrity.length > 0 && described.value.restrictionDigest.hex.length === 64 && described.value.localMcpScriptDigest.hex.length === 64, 'the frozen adapter inventory carries sdk integrity and script digests');
199
+ const piContract = contractFixture();
200
+ piContract.spec = { ...piContract.spec, roles: [{ id: 'builder', adapter: 'pi', provider: 'github-copilot', model: 'claude-sonnet-5.5', thinking: 'xhigh', tools: ['read'] }] };
201
+ const piLock = unwrap(admitTask(piContract, { admissionId: 'admission-pi', runId: 'run-pi' }));
202
+ const workspaceBytes = Buffer.from('workspace snapshot');
203
+ const sessionBytes = Buffer.from('session snapshot');
204
+ const workspaceRef = unwrap(digestArtifact('workspace.bin', workspaceBytes));
205
+ const sessionRef = unwrap(digestArtifact('session.bin', sessionBytes));
206
+ const policy = {
207
+ version: 1, policyId: 'closure-matrix-policy', resourceVersion: 'fixture-host', adapterId: 'pi', adapterVersion: '0.0.0',
208
+ runtime: { sdkIntegrity: described.ok ? described.value.sdkIntegrity : '', graphDigest: hexOf('graph'), imageDigest: 'sha256:' + 'a'.repeat(64), configDigest: described.ok ? described.value.restrictionDigest : hexOf('config'), profile: 'linux/arm64' },
209
+ selection: { provider: 'github-copilot', model: 'claude-sonnet-5.5', thinking: 'xhigh', api: 'anthropic-messages' },
210
+ resources: [], tools: ['read'],
211
+ mcp: { serverId: 'workspace', scriptDigest: described.ok ? described.value.localMcpScriptDigest : hexOf('mcp'), names: [], effects: [], idleTimeoutSeconds: 1, absoluteTimeoutSeconds: 2 },
212
+ context: { mode: 'estimated_guard', estimator: 'lw-pi-final-json-bytes-v1', proofId: null, version: 1, evidence: 'estimated', workingWindowCeiling: 98304, maxRequestBytes: 65536, serviceMargin: 32768, toolReserve: 16384, maxOutputTokens: 1024 },
213
+ accounting: 'soft_only', retry: 'sender_only', extensions: [], privateArtifacts: true,
214
+ limits: Object.freeze({ promptBytes: 16384, diagnosticBytes: 1024, responseBytes: 1048576, frameBytes: 65536, eventBytes: 4096, pendingResponseBytes: 262144, eventQueue: 128, eventQueueBytes: 524288, toolArgsBytes: 65536, toolResultBytes: 65536, sessionBytes: 8388608, artifactBytes: 16777216, candidateEntries: 256, fileBytes: 8388608, toolWallMs: 10000, requests: 1024, operations: 2048, checkpoints: 64 }),
215
+ };
216
+ const checkpoint = { formatVersion: 1, runId: piLock.spec.runId, lockHash: piLock.spec.lockHash, checkpointId: 'checkpoint-pi', storeId: 'store-1', binding: { resourceVersion: 'foreign-host' }, privateSession: sessionRef, subject: {}, clockBasis: {}, ledger: {}, counts: {} };
217
+ const decoded = await decodePiCapture({ version: 1, lock: piLock, policy, checkpoint, sessionId: 'session-pi', roleId: 'builder', stepId: 'build',
218
+ workspace: { ref: workspaceRef, bytes: workspaceBytes }, session: { ref: sessionRef, bytes: sessionBytes }, command: null });
219
+ r.expect(String(decoded.ok ? '' : decoded.error.code), 'BINDING_MISMATCH', 'a capture bound to a foreign resource identity is refused before execution');
220
+ }
221
+ finally {
222
+ state.store.close();
223
+ await rm(state.root, { recursive: true, force: true });
224
+ }
225
+ return outcome(id, started, r.claims(), r.failed(), 'TOOL_DENIED');
226
+ }
227
+ const decisionPolicy = () => ({ ...DEFAULT_DECISION_POLICY, enabled: true, disclosurePolicy: 'repo-approved-redacted-evidence', hardDeadlineMs: 100, maxAttempts: 1 });
228
+ const hangingTransport = { async send() { return new Promise(() => { }); } };
229
+ async function scenarioFive() {
230
+ const id = 'provider_and_decision_deadline_timeout', started = performance.now(), r = recorder();
231
+ // The decision client unrefs its deadline timer so idle CLIs can exit; hold the loop open while the race runs.
232
+ const keepAlive = setInterval(() => { }, 25);
233
+ try {
234
+ const budget = new DecisionBudgetTracker({ maxInputTokens: 1000 });
235
+ const fallbacks = [];
236
+ const result = await evaluateDecision({ policy: decisionPolicy(), state: { question: 'ship' }, budget, questions: [{ type: 'noul', id: 'q1', prompt: 'Proceed?' }],
237
+ apiKey: 'fixture-decision-key', transport: hangingTransport, fallback: context => { fallbacks.push(context.fallbackReason); return 'deterministic-default'; } });
238
+ r.expect(String(result.fallbackReason), 'deadline_exceeded', 'a hanging provider transport routes to the deterministic fallback');
239
+ r.expect(String(result.transportCalls), '1', 'exactly one transport call was attempted');
240
+ r.expect(String(budget.snapshot().unknownUsageRetained), 'true', 'the deadline retains unknown usage in the budget ledger');
241
+ r.expect(fallbacks.join(','), 'deadline_exceeded', 'the fallback handler receives the deadline reason');
242
+ let thrown = null;
243
+ try {
244
+ await evaluateDecision({ policy: decisionPolicy(), state: {}, budget: new DecisionBudgetTracker({}), questions: [{ type: 'noul', id: 'q2', prompt: 'Proceed?' }], apiKey: 'fixture-decision-key', transport: hangingTransport });
245
+ }
246
+ catch (error) {
247
+ thrown = error instanceof DecisionError ? error.code : 'WRONG_ERROR';
248
+ }
249
+ r.expect(thrown ?? '', 'DECISION_DEADLINE_EXCEEDED', 'without a fallback the deadline surfaces DECISION_DEADLINE_EXCEEDED');
250
+ }
251
+ finally {
252
+ clearInterval(keepAlive);
253
+ }
254
+ return outcome(id, started, r.claims(), r.failed(), 'DECISION_DEADLINE_EXCEEDED');
255
+ }
256
+ async function scenarioSix() {
257
+ const id = 'concurrent_owner_and_budget_exhaustion', started = performance.now(), r = recorder();
258
+ const state = await stateFixture(150);
259
+ try {
260
+ const secondOwner = state.store.claim({ ownerId: 'owner-b', expectedGeneration: 1, expectedRevision: 1, mode: 'active' });
261
+ r.expect(String(secondOwner.ok ? '' : secondOwner.error.code), 'OWNER_HELD', 'a concurrent owner takeover refuses with OWNER_HELD');
262
+ unwrap(state.store.reserveRequest(state.owner.authority, requestFixture('request-1')));
263
+ const overBudget = state.store.reserveRequest(state.owner.authority, requestFixture('request-2', { inputUpperBound: 95, outputUpperBound: 70, totalUpperBound: 165 }));
264
+ r.expect(String(overBudget.ok ? '' : overBudget.error.code), 'BUDGET_EXHAUSTED', 'exhausting the token budget refuses with BUDGET_EXHAUSTED');
265
+ const after = unwrap(state.store.inspect());
266
+ r.expect(String(after.ledger.chargedTokens.decimal), '100', 'the refused request leaves the ledger untouched');
267
+ }
268
+ finally {
269
+ state.store.close();
270
+ await rm(state.root, { recursive: true, force: true });
271
+ }
272
+ return outcome(id, started, r.claims(), r.failed(), 'OWNER_HELD');
273
+ }
274
+ async function scenarioSeven() {
275
+ const id = 'signal_interruption_and_workspace_loss', started = performance.now(), r = recorder();
276
+ const cancelled = { kind: 'result', result: { spec: { status: 'cancelled' } } };
277
+ r.expect(String(executionExit(cancelled, 'SIGINT')), '130', 'SIGINT cancellation maps to exit 130');
278
+ r.expect(String(executionExit(cancelled, 'SIGTERM')), '143', 'SIGTERM cancellation maps to exit 143');
279
+ r.expect(String(diagnosticExit({ version: 1, code: 'STATE_UNAVAILABLE', phase: 'execution', path: '', stateCode: null, piCode: null, effect: 'none', retryable: false })), '8', 'missing workspace maps to exit 8');
280
+ const root = await scratchDirectory('lw-fm-signal-');
281
+ const missingRunRoot = join(root, 'runs');
282
+ try {
283
+ const observed = await readStatus({ runRoot: missingRunRoot, runId: 'missing' });
284
+ const source = observed.ok && 'source' in observed.value ? String(observed.value.source) : '';
285
+ r.expect(source, 'unavailable', 'a missing run root reports the unavailable source');
286
+ let directoryCreated = true;
287
+ try {
288
+ await lstat(missingRunRoot);
289
+ }
290
+ catch {
291
+ directoryCreated = false;
292
+ }
293
+ r.expect(String(directoryCreated), 'false', 'the status probe never creates the missing directory');
294
+ }
295
+ finally {
296
+ await rm(root, { recursive: true, force: true });
297
+ }
298
+ return outcome(id, started, r.claims(), r.failed(), 'STATE_UNAVAILABLE');
299
+ }
300
+ async function scenarioEight() {
301
+ const id = 'unknown_external_effect_reconcile_gate', started = performance.now(), r = recorder();
302
+ const root = await scratchDirectory('lw-fm-reconcile-');
303
+ const emptyRunRoot = join(root, 'run-root');
304
+ await mkdir(emptyRunRoot, { mode: 0o700 });
305
+ try {
306
+ const missing = await reconcileCycle({ configuration: {}, runRoot: emptyRunRoot, runId: 'run-1', receipt: join(root, 'missing-receipt.json') });
307
+ r.expect(String(missing.ok ? '' : missing.error.code), 'EVIDENCE_UNAVAILABLE', 'a missing publication receipt refuses reconciliation');
308
+ const wrongKind = join(root, 'wrong-kind.json');
309
+ await writeFile(wrongKind, JSON.stringify({ version: 1, kind: 'unrelated_document' }), { mode: 0o600 });
310
+ const mismatched = await reconcileCycle({ configuration: {}, runRoot: emptyRunRoot, runId: 'run-1', receipt: wrongKind });
311
+ r.expect(String(mismatched.ok ? '' : mismatched.error.code), 'EVIDENCE_UNAVAILABLE', 'a mismatched receipt document refuses reconciliation');
312
+ const leftover = await readdir(emptyRunRoot);
313
+ r.expect(String(leftover.length), '0', 'reconciliation never replays or mutates the run root');
314
+ r.expect(String(diagnosticExit({ version: 1, code: 'RECEIPT_CONFLICT', phase: 'recovery', path: '', stateCode: null, piCode: null, effect: 'none', retryable: false })), '7', 'receipt conflict maps to the stable exit 7');
315
+ }
316
+ finally {
317
+ await rm(root, { recursive: true, force: true });
318
+ }
319
+ return outcome(id, started, r.claims(), r.failed(), 'RECEIPT_CONFLICT');
320
+ }
321
+ async function scenarioNine() {
322
+ const id = 'expired_or_stale_gate_token_rejection', started = performance.now(), r = recorder();
323
+ const secret = 'closure-matrix-gate-secret';
324
+ const payload = JSON.stringify({ version: 1, kind: 'gate_verdict', status: 'approved', expiresAtMs: 1 });
325
+ const signature = signPayload(secret, payload);
326
+ r.expect(String(verifySignedPayload(secret, payload, signature)), 'true', 'an authentic gate token verifies');
327
+ r.expect(String(verifySignedPayload(secret, JSON.stringify({ version: 1, kind: 'gate_verdict', status: 'denied' }), signature)), 'false', 'a tampered token body fails verification');
328
+ r.expect(String(verifySignedPayload('other-secret', payload, signature)), 'false', 'a rotated secret fails verification');
329
+ r.expect(String(verifySignedPayload(secret, payload, 'zz'.repeat(32))), 'false', 'a malformed signature fails verification');
330
+ r.expect(String(verifySignedPayload(secret, payload, 'sha256=' + signature)), 'true', 'the sha256-prefixed form verifies');
331
+ r.expect(String(diagnosticExit({ version: 1, code: 'AUTHORITY_REFUSED', phase: 'verification', path: '', stateCode: null, piCode: null, effect: 'none', retryable: false })), '7', 'stale or forged authority maps to the stable exit 7');
332
+ return outcome(id, started, r.claims(), r.failed(), 'AUTHORITY_REFUSED');
333
+ }
334
+ const SUPPORT_TABLE = '<!-- runner-support-records:start -->\n| Backend | Runtime | Service | Variant | Engine | Plugin | Platforms | Status |\n| --- | --- | --- | --- | --- | --- | --- | --- |\n| cuda | 13.0 | vllm | - | 0.29.0 | - | linux/amd64 | prepared |\n<!-- runner-support-records:end -->\n';
335
+ const DOCKERFILE = 'ARG VLLM_VERSION=0.29.0\nARG CUDA_VERSION=13.0.1\nARG VLLM_BASE_IMAGE=vllm/vllm-openai:v${VLLM_VERSION}\nARG PYTHON_VERSION=3.12\nARG VLLM_LMCACHE_VERSION=0.5.4\nFROM ${VLLM_BASE_IMAGE} AS vllm\n';
336
+ const MATRIX = 'rules:\n - backend: cuda\n services: [vllm]\n platforms: [linux/amd64]\n args: [VLLM_VERSION=0.29.0]\n';
337
+ async function buildRunnerFixture() {
338
+ const root = await mkdtemp(join(await realpath(tmpdir()), 'lw-fm-runner-repo-'));
339
+ await chmod(root, 0o700);
340
+ const git = promisify(execFile);
341
+ const run = async (args) => { await git('/usr/bin/git', ['-c', 'core.hooksPath=/dev/null', ...args], { cwd: root, env: { ...GIT_ENV, HOME: root } }); };
342
+ await run(['init', '-q', '-b', 'main']);
343
+ await run(['config', 'user.name', 'Fixture']);
344
+ await run(['config', 'user.email', 'fixture@example.invalid']);
345
+ await mkdir(join(root, 'pack', 'cuda'), { recursive: true });
346
+ await mkdir(join(root, 'docs'), { recursive: true });
347
+ await writeFile(join(root, 'pack', 'cuda', 'Dockerfile.vllm'), DOCKERFILE);
348
+ await writeFile(join(root, 'pack', 'matrix.yaml'), MATRIX);
349
+ await writeFile(join(root, 'README.md'), '# Runner\n[Supported runners](docs/supported-runners.md)\n');
350
+ await writeFile(join(root, 'docs', 'support-records.md'), SUPPORT_TABLE);
351
+ await run(['add', '.']);
352
+ await run(['commit', '-qm', 'fixture baseline']);
353
+ const headSha = (await git('/usr/bin/git', ['rev-parse', 'HEAD'], { cwd: root, env: { ...GIT_ENV, HOME: root } })).stdout.trim();
354
+ return { path: root, headSha };
355
+ }
356
+ async function scenarioTen() {
357
+ const id = 'mutated_pr_head_publication_abort', started = performance.now(), r = recorder();
358
+ const corpusRoot = defaultCorpusRoot();
359
+ if (corpusRoot === null)
360
+ return { scenarioId: id, passed: false, diagnosticCode: 'CORPUS_ABSENT', assertions: [], elapsedMs: Math.round(performance.now() - started) };
361
+ let fixture = null;
362
+ let service = null;
363
+ const gateSecret = 'closure-matrix-gate-secret', publicationSecret = 'closure-matrix-publication-secret';
364
+ const post = async (url, secret, body) => {
365
+ const payload = Buffer.from(JSON.stringify(body));
366
+ const response = await fetch(url, { method: 'POST', headers: { 'content-type': 'application/json', 'x-loopwright-signature': signPayload(secret, payload) }, body: new Uint8Array(payload) });
367
+ const document = JSON.parse(Buffer.from(await response.arrayBuffer()).toString('utf8'));
368
+ return { status: response.status, document };
369
+ };
370
+ try {
371
+ fixture = await buildRunnerFixture();
372
+ const proposalBytes = await readFile(join(corpusRoot, 'tests', 'auto_sync', 'fixtures', 'proposals', 'ready.json'), 'utf8');
373
+ const proposal = JSON.parse(proposalBytes);
374
+ proposal.identity.default_sha = fixture.headSha;
375
+ proposal.identity.head_sha = fixture.headSha;
376
+ const proposalJson = JSON.stringify(proposal);
377
+ const candidateDigest = (await computeRunnerCandidateDigest({ repositorySnapshot: fixture.path, headSha: fixture.headSha, proposalJson })).digest;
378
+ service = await startRunnerTaskpackService({ gateSecret, publicationSecret, corpusRoot, fakeRepositorySnapshot: fixture.path });
379
+ await service.registerCandidate({ storeId: 'store-1', runId: 'run-1', candidateDigest, proposalJson,
380
+ identity: { repository: 'example-org/runtime-runner', defaultSha: fixture.headSha, headSha: fixture.headSha, mode: 'discover', prNumber: null, commandId: null, commandDigest: null },
381
+ repositorySnapshot: fixture.path, upstreamSources: {}, ascendPairs: {}, enginePrereleases: [], prereleasePackages: [] });
382
+ const gate = await post(service.gateUrl, gateSecret, { version: 1, kind: 'gate_request', gateId: 'runner-candidate-validation', checkId: 'runner-candidate-validation', candidateDigest, subject: { repository: 'example-org/runtime-runner', candidateDigest }, storeId: 'store-1', runId: 'run-1', lockHash: 'a'.repeat(64), operationId: 'op.1', dispatchId: 'dispatch-1', dispatchGeneration: 1, requestDigest: 'b'.repeat(64) });
383
+ r.expect(String(gate.document.status), 'approved', 'the registered candidate passes the frozen gate validators');
384
+ const published = await post(service.publicationUrl, publicationSecret, { version: 1, kind: 'publication_request', storeId: 'store-1', runId: 'run-1', lockHash: 'a'.repeat(64), operationId: 'publish.1', dispatchId: 'dispatch-2', dispatchGeneration: 1, idempotencyKey: 'pub.initial', targetBranch: 'main', headBranch: 'loopwright-runner-run-1', title: 'runner: sync upstream runtime support', candidateDigest, baseRevision: fixture.headSha, sourceRevision: fixture.headSha, requestDigest: 'c'.repeat(64) });
385
+ r.expect(String(published.document.outcome), 'succeeded', 'the initial publication lands the managed pull request');
386
+ const prHead = await service.fakePullHeadSha(1);
387
+ if (prHead === null)
388
+ throw new Error('managed pull request head missing');
389
+ const guidance = '/auto-sync\nPlease refine the report.';
390
+ const commandDigest = createHash('sha256').update(Buffer.from(guidance, 'utf8')).digest('hex');
391
+ const reviseProposal = structuredClone(proposal);
392
+ reviseProposal.identity.default_sha = fixture.headSha;
393
+ reviseProposal.identity.head_sha = prHead;
394
+ reviseProposal.identity.mode = 'revise';
395
+ reviseProposal.identity.pr_number = 1;
396
+ reviseProposal.identity.command_id = 99;
397
+ reviseProposal.identity.command_digest = commandDigest;
398
+ const group = reviseProposal.groups[0];
399
+ group.rows[0].old_engine_version = '0.30.0';
400
+ group.patch = 'diff --git a/README.md b/README.md\n--- a/README.md\n+++ b/README.md\n@@ -1,2 +1,3 @@\n # Runner\n [Supported runners](docs/supported-runners.md)\n+Release report was reviewed.\n';
401
+ const reviseJson = JSON.stringify(reviseProposal);
402
+ const reviseDigest = (await computeRunnerCandidateDigest({ repositorySnapshot: fixture.path, headSha: fixture.headSha, proposalJson: reviseJson })).digest;
403
+ await service.registerCandidate({ storeId: 'store-1', runId: 'run-revise', candidateDigest: reviseDigest, proposalJson: reviseJson,
404
+ identity: { repository: 'example-org/runtime-runner', defaultSha: fixture.headSha, headSha: fixture.headSha, mode: 'revise', prNumber: 1, commandId: 99, commandDigest, prHeadSha: prHead },
405
+ repositorySnapshot: fixture.path, upstreamSources: {}, ascendPairs: {}, enginePrereleases: [], prereleasePackages: [], reviseCommentBody: guidance });
406
+ const reviseGate = await post(service.gateUrl, gateSecret, { version: 1, kind: 'gate_request', gateId: 'runner-candidate-validation', checkId: 'runner-candidate-validation', candidateDigest: reviseDigest, subject: { repository: 'example-org/runtime-runner', candidateDigest: reviseDigest }, storeId: 'store-1', runId: 'run-revise', lockHash: 'a'.repeat(64), operationId: 'op.2', dispatchId: 'dispatch-3', dispatchGeneration: 1, requestDigest: 'd'.repeat(64) });
407
+ r.expect(String(reviseGate.document.status), 'approved', 'the pinned revise candidate passes the gate');
408
+ await service.fakeHumanCommit('README.md', '# Human edit on PR branch\n');
409
+ const refused = await post(service.publicationUrl, publicationSecret, { version: 1, kind: 'publication_request', storeId: 'store-1', runId: 'run-revise', lockHash: 'a'.repeat(64), operationId: 'publish.2', dispatchId: 'dispatch-4', dispatchGeneration: 1, idempotencyKey: 'pub.revise', targetBranch: 'main', headBranch: 'loopwright-runner-run-revise', title: 'runner: sync upstream runtime support', candidateDigest: reviseDigest, baseRevision: fixture.headSha, sourceRevision: fixture.headSha, requestDigest: 'e'.repeat(64) });
410
+ r.expect(String(refused.document.outcome), 'not_executed', 'the mutated PR head aborts publication without executing');
411
+ r.assert(String(refused.document.reason).startsWith('revise_head_changed'), 'the refusal names the moved bound head');
412
+ }
413
+ finally {
414
+ if (service !== null)
415
+ await service.close();
416
+ if (fixture !== null)
417
+ await rm(fixture.path, { recursive: true, force: true });
418
+ }
419
+ return outcome(id, started, r.claims(), r.failed(), 'RECEIPT_CONFLICT');
420
+ }
421
+ function memoryEntry(overrides) {
422
+ const base = {
423
+ version: 1, id: 'entry.alpha', claimKey: 'claim.alpha', claim: 'Stable claim text.', kind: 'fact',
424
+ scope: { taskpack: 'demo', repository: 'org/repo', paths: ['docs/**'], targetMatrix: null },
425
+ sourceRef: { runId: 'run.one', lockHash: hexOf('lock'), candidateDigest: hexOf('candidate') },
426
+ sourceDigest: hexOf('source'), verifiedAtMs: 1000,
427
+ validFor: { baseRevision: 'b'.repeat(40), sourceRevision: 'c'.repeat(40), codeFingerprint: hexOf('fingerprint'), upstreamVersions: { npm: '1.0.0' } },
428
+ expiresAtMs: 2000, supersedes: [],
429
+ evidenceRefs: [{ evidenceId: 'ev.one', checkId: 'check.one', level: 'local_execution', observedStatus: 'passed', artifact: { name: 'artifacts/evidence.json', digest: hexOf('artifact'), byteLength: 10 } }],
430
+ };
431
+ return Object.freeze({ ...base, ...overrides });
432
+ }
433
+ function memoryIndex(entries) {
434
+ const base = { version: 1, taskpack: 'demo', repository: 'org/repo', updatedAtMs: 1500, entries: [...entries], retired: [] };
435
+ return { ...base, storeDigest: storeDigestOf(base) };
436
+ }
437
+ const memoryContract = {
438
+ apiVersion: 'loopwright.dev/v1alpha1', kind: 'TaskContract',
439
+ spec: { goal: 'demo goal', taskpack: 'demo',
440
+ target: { repository: 'org/repo', baseRevision: 'b'.repeat(40), sourceRevision: 'c'.repeat(40), matrix: null },
441
+ scope: { writable: ['src/**'], protected: [] },
442
+ roles: [{ id: 'coder', adapter: 'pi', provider: 'p', model: 'm', thinking: 'off', tools: [] }],
443
+ trustedContext: { revision: 'rev', discovery: 'disabled', resources: [] },
444
+ budgets: { wallTimeMs: 1, totalTokens: 1, perCallOutputTokens: 1, maxModelCalls: 1, maxConcurrency: 1, maxFormatRepairs: 0, maxImplementationRepairs: 0, maxTransportRetries: 0,
445
+ enforcement: { wallTime: 'soft_accounting', tokens: 'soft_accounting', modelCalls: 'soft_accounting', concurrency: 'soft_accounting', formatRepairs: 'soft_accounting', implementationRepairs: 'soft_accounting', transportRetries: 'soft_accounting' } },
446
+ steps: [{ id: 'work', kind: 'agent', uses: 'work', roleId: 'coder', dependsOn: [] }],
447
+ acceptance: { required: ['check.one'], checks: [{ id: 'check.one', allowedEvidenceLevels: ['local_execution'] }] },
448
+ },
449
+ };
450
+ async function scenarioEleven() {
451
+ const id = 'stale_memory_source_exclusion', started = performance.now(), r = recorder();
452
+ const snapshot = selectActiveMemory({ store: memoryIndex([memoryEntry({ id: 'entry.valid' }), memoryEntry({ id: 'entry.expired', expiresAtMs: 1000 }), memoryEntry({ id: 'entry.stale', validFor: { baseRevision: 'b'.repeat(40), sourceRevision: 'c'.repeat(40), codeFingerprint: hexOf('other-fingerprint'), upstreamVersions: { npm: '1.0.0' } } })]),
453
+ contract: memoryContract, nowMs: 1500, currentCodeFingerprint: hexOf('fingerprint'), currentUpstreamVersions: { npm: '1.0.0' }, targetCell: null });
454
+ r.expect(snapshot.activeEntries.map(entry => entry.id).join(','), 'entry.valid', 'only the current review stays active');
455
+ const reasons = new Map(snapshot.excludedEntries.map(entry => [entry.entryId, entry.reason]));
456
+ r.expect(String(reasons.get('entry.expired')), 'expired', 'a stale TTL excludes the entry as expired');
457
+ r.expect(String(reasons.get('entry.stale')), 'fingerprint_mismatch', 'a stale source fingerprint excludes the entry');
458
+ return outcome(id, started, r.claims(), r.failed(), 'MEMORY_SCOPE_VIOLATION');
459
+ }
460
+ const compactionInput = (overrides = {}) => ({
461
+ contextWindowTokens: 1000, nextRequestInputTokens: 700, toolResultReserveTokens: 200, maxOutputTokens: 200,
462
+ postCompactionEstimatedTokens: 300, currentContextTokens: 800, softUtilizationThreshold: 0.8,
463
+ recentRepeatFailureCount: 0, repeatFailureThreshold: 3, upcomingExternalWaitMs: 0, externalWaitThresholdMs: 60000,
464
+ externalReceiptsPersisted: true, expectedReplaySavingsTokens: 500, summaryCostTokens: 10, cacheRebuildCostTokens: 10,
465
+ unpairedToolCallIds: [], sessionMemorySnapshotDigest: hexOf('snapshot'), activeMemorySnapshotDigest: hexOf('snapshot'),
466
+ checkpointId: 'checkpoint-1', pendingOperationIds: ['op-unknown-1'], advisoryDecision: null, ...overrides,
467
+ });
468
+ async function scenarioTwelve() {
469
+ const id = 'compaction_pending_operation_preservation', started = performance.now(), r = recorder();
470
+ const unpaired = evaluateCompactionPolicy(compactionInput({ unpairedToolCallIds: ['tool-call-7'] }));
471
+ r.expect(unpaired.disposition, 'blocked', 'unpaired tool calls refuse compaction');
472
+ r.expect(String(unpaired.disposition === 'blocked' ? unpaired.code : ''), 'COMPACTION_UNSAFE_BOUNDARY', 'the unsafe boundary refuses with COMPACTION_UNSAFE_BOUNDARY');
473
+ const invalidCheckpoint = evaluateCompactionPolicy(compactionInput({ checkpointId: 'bad\u0000checkpoint' }));
474
+ r.expect(String(invalidCheckpoint.disposition === 'blocked' ? invalidCheckpoint.code : ''), 'COMPACTION_UNSAFE_BOUNDARY', 'an invalid checkpoint reference refuses compaction');
475
+ const safe = evaluateCompactionPolicy(compactionInput());
476
+ r.expect(safe.disposition, 'compact_now', 'a safe boundary with a hard trigger compacts now');
477
+ r.expect(safe.disposition === 'compact_now' ? safe.checkpoint.pendingOperationIds.join(',') : '', 'op-unknown-1', 'the unsettled operation stays pinned in the compaction checkpoint');
478
+ const lock = unwrap(admitTask(contractFixture(), { admissionId: 'admission-compact', runId: 'run-compact' }));
479
+ const pending = [{ operationId: 'op-unknown-1', kind: 'publication', state: 'pending_receipt' }];
480
+ const summaryInput = {
481
+ lock, nonGoals: [], currentNodeId: 'build', checks: { passed: ['tests'], failed: [], blocked: [], notRun: [] },
482
+ evidenceRefs: [], modifiedFiles: [], openIssues: [], forbiddenActions: ['force_push'], pendingExternalOperations: pending,
483
+ ledger: { revision: 1, remainingTokens: 500, remainingModelCalls: 3, remainingWallMs: 45000 },
484
+ nextAllowedActions: ['retry_publication'],
485
+ memory: { store: memoryIndex([memoryEntry({ id: 'entry.valid' })]), contract: memoryContract, nowMs: 1500, currentCodeFingerprint: hexOf('fingerprint'), currentUpstreamVersions: { npm: '1.0.0' }, targetCell: null },
486
+ };
487
+ const built = buildCompactionSummary(summaryInput);
488
+ r.expect(built.summary.pendingExternalOperations.map(operation => operation.operationId).join(','), 'op-unknown-1', 'the compaction summary pins the pending external operation');
489
+ r.expect(String(built.digest.hex.length), '64', 'the summary carries a canonical digest');
490
+ const ledger = { lockHash: built.summary.contractHash, writableScope: ['packages/**'], remainingTokens: 500, remainingModelCalls: 3, remainingWallMs: 45000,
491
+ nodes: [{ id: 'build', state: 'completed' }], pendingExternalOperations: pending, activeMemorySnapshot: built.summary.activeMemorySnapshot };
492
+ const restored = restoreFromCompactionLedger({ ledger, summary: built.summary, proposedWritableScope: ['packages/**'], proposedChecks: [{ id: 'build', state: 'completed' }], proposedBudget: { remainingTokens: 400, remainingModelCalls: 2, remainingWallMs: 40000 } });
493
+ r.expect(String(restored.ok), 'true', 'the pinned summary restores cleanly from the ledger');
494
+ if (restored.ok)
495
+ r.expect(restored.state.pendingExternalOperations.map(operation => operation.operationId).join(','), 'op-unknown-1', 'the pending external operation replays after restore');
496
+ const tampered = restoreFromCompactionLedger({ ledger, summary: { ...built.summary, pendingExternalOperations: [] }, proposedWritableScope: ['packages/**'], proposedChecks: [{ id: 'build', state: 'completed' }], proposedBudget: { remainingTokens: 400, remainingModelCalls: 2, remainingWallMs: 40000 } });
497
+ r.expect(String(tampered.ok ? '' : tampered.code), 'COMPACTION_AUTHORITY_VIOLATION', 'a summary that drops the pending operation commits an authority violation');
498
+ return outcome(id, started, r.claims(), r.failed(), 'COMPACTION_AUTHORITY_VIOLATION');
499
+ }
500
+ const VALID_MANIFEST_YAML = `apiVersion: loopwright.dev/v1alpha1
501
+ kind: Taskpack
502
+ metadata:
503
+ name: docs-sync
504
+ spec:
505
+ goal:
506
+ candidate: Refresh documentation from upstream sources and pass every local check.
507
+ noChange: Confirm the documentation needs no change and settle as no change.
508
+ scope:
509
+ writable:
510
+ - docs/**
511
+ protected:
512
+ - docs/protected-notes.md
513
+ upstreams:
514
+ - id: engine
515
+ kind: github-release
516
+ source: octocat/engine
517
+ watchedPaths:
518
+ - docs
519
+ proposal:
520
+ path: docs/proposal.json
521
+ requiredFields:
522
+ - schema_version
523
+ - candidates
524
+ schemaVersion: 1
525
+ verification:
526
+ localChecks:
527
+ - id: docs-proposal-json
528
+ implementation: json-artifact.v1
529
+ externalGates: []
530
+ publication:
531
+ mode: pull_request
532
+ targetBranch: main
533
+ headBranchPrefix: loopwright-docs-
534
+ titleTemplate: 'docs: sync upstream documentation'
535
+ memory:
536
+ directory: .loopwright/memory/docs-sync
537
+ apply: separate-pull-request
538
+ onNoModelBudget: deterministic-observations-only
539
+ triggers:
540
+ schedule: true
541
+ workflowDispatch: true
542
+ releasePublished: false
543
+ commentCommands:
544
+ - retry
545
+ - revise
546
+ - status
547
+ `;
548
+ async function scenarioThirteen() {
549
+ const id = 'untrusted_taskpack_and_oauth_boundary_refusal', started = performance.now(), r = recorder();
550
+ const githubHostPolicy = { policyProfile: 'github', allowPrivileged: false, allowWorkflowWrites: false };
551
+ const manifest = await loadDeclarativeTaskpack({ bytes: Buffer.from(VALID_MANIFEST_YAML, 'utf8'), format: 'yaml', policyProfile: 'github' });
552
+ r.expect(String(manifest.metadata.name), 'docs-sync', 'the declarative taskpack manifest parses and validates');
553
+ const escalated = structuredClone(manifest);
554
+ escalated.spec.scope = { writable: ['.github/workflows/**', 'docs/**'], protected: [] };
555
+ let scopeCode = null;
556
+ try {
557
+ validateTaskpackManifest(escalated, { policyProfile: 'github', hostPolicy: githubHostPolicy });
558
+ }
559
+ catch (error) {
560
+ scopeCode = error instanceof GitHubAppError && error instanceof TaskpackError ? error.code : 'WRONG_ERROR';
561
+ }
562
+ r.expect(scopeCode ?? '', 'TASKPACK_SCOPE_VIOLATION', 'protected-path escalation refuses with TASKPACK_SCOPE_VIOLATION');
563
+ const privilegedWithoutUnlock = structuredClone(manifest);
564
+ privilegedWithoutUnlock.spec.execution = { mode: 'privileged', digests: { pinDigests: false } };
565
+ let privCode = null;
566
+ try {
567
+ validateTaskpackManifest(privilegedWithoutUnlock, { hostPolicy: githubHostPolicy });
568
+ }
569
+ catch (error) {
570
+ privCode = error instanceof GitHubAppError && error instanceof TaskpackError ? error.code : 'WRONG_ERROR';
571
+ }
572
+ r.expect(privCode ?? '', 'TASKPACK_HOST_BINDING_INVALID', 'privileged mode without operator host unlock refuses with TASKPACK_HOST_BINDING_INVALID');
573
+ const wfWithoutUnlock = structuredClone(manifest);
574
+ wfWithoutUnlock.spec.execution = { mode: 'strict', capabilities: { allowWorkflowWrites: true }, digests: { pinDigests: false } };
575
+ wfWithoutUnlock.spec.scope = { writable: ['.github/workflows/**', 'docs/**'], protected: [] };
576
+ let wfCode = null;
577
+ try {
578
+ validateTaskpackManifest(wfWithoutUnlock, { hostPolicy: githubHostPolicy });
579
+ }
580
+ catch (error) {
581
+ wfCode = error instanceof GitHubAppError && error instanceof TaskpackError ? error.code : 'WRONG_ERROR';
582
+ }
583
+ r.expect(wfCode ?? '', 'TASKPACK_SCOPE_VIOLATION', 'allowWorkflowWrites without operator host unlock refuses with TASKPACK_SCOPE_VIOLATION');
584
+ let untrustedInterpCode = null;
585
+ try {
586
+ await loadDeclarativeTaskpack({
587
+ bytes: Buffer.from(VALID_MANIFEST_YAML.replace("titleTemplate: 'docs: sync upstream documentation'", "titleTemplate: 'docs: sync ${AMBIENT_SECRET}'"), 'utf8'),
588
+ format: 'yaml',
589
+ policyProfile: 'github',
590
+ });
591
+ }
592
+ catch (error) {
593
+ untrustedInterpCode = error instanceof GitHubAppError && error instanceof TaskpackError ? error.code : 'WRONG_ERROR';
594
+ }
595
+ r.expect(untrustedInterpCode ?? '', 'TASKPACK_UNTRUSTED_INTERPOLATION', 'undeclared ${...} interpolation refuses with TASKPACK_UNTRUSTED_INTERPOLATION');
596
+ const withDeclaredVars = await loadDeclarativeTaskpack({
597
+ bytes: Buffer.from(VALID_MANIFEST_YAML
598
+ .replace('spec:\n', 'spec:\n vars:\n CHANNEL: stable\n')
599
+ .replace("titleTemplate: 'docs: sync upstream documentation'", "titleTemplate: 'docs: sync ${CHANNEL}'"), 'utf8'),
600
+ format: 'yaml',
601
+ policyProfile: 'github',
602
+ });
603
+ r.expect(withDeclaredVars.spec.publication.titleTemplate ?? '', 'docs: sync stable', 'declared spec.vars interpolate safely in permitted fields');
604
+ for (const oauthProvider of ['github-copilot', 'openai-codex', 'claude-code', 'gemini']) {
605
+ const withOauthModel = structuredClone(manifest);
606
+ withOauthModel.spec.models = [
607
+ { provider: 'zai', id: 'glm-5.3', thinking: 'high' },
608
+ { provider: oauthProvider, id: 'glm-5.3', thinking: 'high' },
609
+ ];
610
+ let modelCode = null;
611
+ try {
612
+ validateTaskpackManifest(withOauthModel, { policyProfile: 'github' });
613
+ }
614
+ catch (error) {
615
+ modelCode = error instanceof GitHubAppError && error instanceof TaskpackError ? error.code : 'WRONG_ERROR';
616
+ }
617
+ r.expect(modelCode ?? '', 'PROVIDER_OAUTH_UNSUPPORTED', `OAuth Pi model provider "${oauthProvider}" refuses with PROVIDER_OAUTH_UNSUPPORTED`);
618
+ }
619
+ const oauth = validateMcpAuthConfiguration({ servers: [{ serverId: 'workspace', auth: { type: 'oauth' } }] });
620
+ r.expect(String(oauth.ok ? '' : oauth.code), 'MCP_OAUTH_UNSUPPORTED', 'interactive OAuth configuration refuses with MCP_OAUTH_UNSUPPORTED');
621
+ const challenge = validateMcpAuthConfiguration({ servers: [{ serverId: 'workspace' }], transportChallenge: { status: 401, wwwAuthenticate: 'Bearer realm="control-plane"' } });
622
+ r.expect(String(challenge.ok ? '' : challenge.code), 'MCP_AUTHENTICATION_REQUIRED', 'an interactive transport challenge refuses with MCP_AUTHENTICATION_REQUIRED');
623
+ let sandboxCode = null;
624
+ try {
625
+ negotiateSandboxBackend({ workspaceRoot: '/tmp/lw-sandbox-probe', writablePaths: ['docs'], preferredBackends: ['direct-dedicated'] }, { platform: 'darwin', arch: 'arm64', probeExecutables: false });
626
+ }
627
+ catch (error) {
628
+ sandboxCode = error instanceof GitHubAppError && error instanceof TaskpackError ? error.code : 'WRONG_ERROR';
629
+ }
630
+ r.expect(sandboxCode ?? '', 'SANDBOX_CAPABILITY_INSUFFICIENT', 'direct-dedicated sandbox without override refuses with SANDBOX_CAPABILITY_INSUFFICIENT');
631
+ const seatbelt = compileMacosSeatbeltProfile({ workspaceRoot: '/tmp/lw-sandbox-probe', writablePaths: ['docs'], protectedPaths: ['docs/protected-notes.md'], networkMode: 'none' }, { platform: 'darwin', arch: 'arm64', homeDirectory: '/var/empty', probeExecutables: false });
632
+ r.assert(seatbelt.profileText.includes('(deny file-write*)') && seatbelt.profileText.includes('(deny network*)'), 'macOS Seatbelt profile enforces write and network containment');
633
+ const bwrap = compileLinuxBwrapCommand({ workspaceRoot: '/tmp/lw-sandbox-probe', writablePaths: ['docs'], protectedPaths: ['docs/protected-notes.md'], networkMode: 'none' }, { platform: 'linux', arch: 'x64', homeDirectory: '/var/empty', probeExecutables: false });
634
+ r.assert(bwrap.args.includes('--unshare-all') && bwrap.args.includes('--ro-bind-try'), 'Linux Bubblewrap command enforces namespace isolation and read-only protected masks');
635
+ return outcome(id, started, r.claims(), r.failed(), 'MCP_OAUTH_UNSUPPORTED');
636
+ }
637
+ async function scenarioFourteen() {
638
+ const id = 'decision_authority_escalation_refusal', started = performance.now(), r = recorder();
639
+ let authorityCode = null;
640
+ try {
641
+ assertDecisionAuthorityBoundary('certify_verification_evidence');
642
+ }
643
+ catch (error) {
644
+ authorityCode = error instanceof DecisionError ? error.code : 'WRONG_ERROR';
645
+ }
646
+ r.expect(authorityCode ?? '', 'DECISION_AUTHORITY_VIOLATION', 'a non-delegable authority intent refuses with DECISION_AUTHORITY_VIOLATION');
647
+ assertDecisionAuthorityBoundary('route_capability_tier');
648
+ r.assert(true, 'a delegable intent passes the authority boundary');
649
+ let disclosureCode = null;
650
+ try {
651
+ sanitizeDecisionState({ note: 'Bearer abcdef' }, decisionPolicy());
652
+ }
653
+ catch (error) {
654
+ disclosureCode = error instanceof DecisionError ? error.code : 'WRONG_ERROR';
655
+ }
656
+ r.expect(disclosureCode ?? '', 'DECISION_DISCLOSURE_VIOLATION', 'secret-bearing state refuses with DECISION_DISCLOSURE_VIOLATION');
657
+ let calls = 0;
658
+ const countingTransport = { async send() { calls += 1; return new Promise(() => { }); } };
659
+ const result = await evaluateDecision({ policy: decisionPolicy(), state: { note: 'Bearer abcdef' }, budget: new DecisionBudgetTracker({}), questions: [{ type: 'noul', id: 'q3', prompt: 'Proceed?' }], apiKey: 'fixture-decision-key', transport: countingTransport, fallback: () => 'deterministic-default' });
660
+ r.expect(String(result.fallbackReason), 'disclosure_violation', 'secret-bearing state routes to the disclosure fallback');
661
+ r.expect(String(calls), '0', 'no transport call ever leaves the boundary');
662
+ r.expect(String(result.transportCalls), '0', 'the evaluation reports zero transport calls');
663
+ return outcome(id, started, r.claims(), r.failed(), 'DECISION_AUTHORITY_VIOLATION');
664
+ }
665
+ const PROBES = [
666
+ { id: 'malformed_or_conflicting_json_submission', run: scenarioOne },
667
+ { id: 'forged_test_pass_without_verifier_evidence', run: scenarioTwo },
668
+ { id: 'missing_provider_usage_retained_reservation', run: scenarioThree },
669
+ { id: 'nested_tool_double_debit_prevention', run: scenarioFour },
670
+ { id: 'provider_and_decision_deadline_timeout', run: scenarioFive },
671
+ { id: 'concurrent_owner_and_budget_exhaustion', run: scenarioSix },
672
+ { id: 'signal_interruption_and_workspace_loss', run: scenarioSeven },
673
+ { id: 'unknown_external_effect_reconcile_gate', run: scenarioEight },
674
+ { id: 'expired_or_stale_gate_token_rejection', run: scenarioNine },
675
+ { id: 'mutated_pr_head_publication_abort', run: scenarioTen },
676
+ { id: 'stale_memory_source_exclusion', run: scenarioEleven },
677
+ { id: 'compaction_pending_operation_preservation', run: scenarioTwelve },
678
+ { id: 'untrusted_taskpack_and_oauth_boundary_refusal', run: scenarioThirteen },
679
+ { id: 'decision_authority_escalation_refusal', run: scenarioFourteen },
680
+ ];
681
+ /** Run all 14 cross-package failure probes in-process; deterministic, offline, and Docker-free. */
682
+ export async function runIntegratedFailureMatrix(options = {}) {
683
+ const scenarios = [];
684
+ const keepAlive = setInterval(() => { }, 1000);
685
+ try {
686
+ for (const entry of PROBES) {
687
+ const override = options.scenarioOverrides?.[entry.id];
688
+ if (process.env.LW_MATRIX_DEBUG === '1')
689
+ console.error('[matrix-debug] start', entry.id);
690
+ const result = override === undefined ? await probe(entry.id, entry.run) : await override();
691
+ if (process.env.LW_MATRIX_DEBUG === '1')
692
+ console.error('[matrix-debug] done', entry.id, result.passed, result.elapsedMs + 'ms');
693
+ scenarios.push(result);
694
+ }
695
+ }
696
+ finally {
697
+ clearInterval(keepAlive);
698
+ }
699
+ const passed = scenarios.filter(result => result.passed).length;
700
+ return { version: 1, total: scenarios.length, passed, failed: scenarios.length - passed, allPassed: passed === scenarios.length, scenarios };
701
+ }