@pome-sh/cli 0.11.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (197) hide show
  1. package/dist/build-info.json +3 -3
  2. package/dist/src/cli/checks-add.js +16 -0
  3. package/dist/src/cli/checks-lint.d.ts +1 -0
  4. package/dist/src/cli/checks-lint.js +59 -0
  5. package/dist/src/cli/criterion-binding.d.ts +41 -0
  6. package/dist/src/cli/criterion-binding.js +111 -0
  7. package/dist/src/cli/main.js +12 -0
  8. package/dist/src/runner/runTask.d.ts +2 -2
  9. package/dist/src/task/insertCriterion.js +6 -1
  10. package/dist/src/task/parseTask.d.ts +21 -0
  11. package/dist/src/task/parseTask.js +48 -1
  12. package/dist/src/task/taskSchema.d.ts +4 -4
  13. package/node_modules/@pome-sh/sdk/dist/checks.d.ts +18 -0
  14. package/node_modules/@pome-sh/sdk/dist/checks.js.map +1 -1
  15. package/node_modules/@pome-sh/sdk/dist/failure-injection.js +7 -0
  16. package/node_modules/@pome-sh/sdk/dist/failure-injection.js.map +1 -1
  17. package/node_modules/@pome-sh/sdk/dist/index.d.ts +8 -0
  18. package/node_modules/@pome-sh/sdk/dist/index.js +1 -0
  19. package/node_modules/@pome-sh/sdk/dist/index.js.map +1 -1
  20. package/node_modules/@pome-sh/sdk/dist/mcp-jsonrpc.js +10 -0
  21. package/node_modules/@pome-sh/sdk/dist/mcp-jsonrpc.js.map +1 -1
  22. package/node_modules/@pome-sh/sdk/dist/recorder.js +8 -4
  23. package/node_modules/@pome-sh/sdk/dist/recorder.js.map +1 -1
  24. package/node_modules/@pome-sh/sdk/dist/request-capture.d.ts +31 -0
  25. package/node_modules/@pome-sh/sdk/dist/request-capture.js +59 -0
  26. package/node_modules/@pome-sh/sdk/dist/request-capture.js.map +1 -0
  27. package/node_modules/@pome-sh/sdk/dist/server.d.ts +1 -0
  28. package/node_modules/@pome-sh/sdk/dist/server.js +13 -0
  29. package/node_modules/@pome-sh/sdk/dist/server.js.map +1 -1
  30. package/node_modules/@pome-sh/sdk/package.json +2 -2
  31. package/node_modules/@pome-sh/shared-types/dist/otel/event-schema.d.ts +6 -0
  32. package/node_modules/@pome-sh/shared-types/dist/otel/legacy-shim.d.ts +2 -0
  33. package/node_modules/@pome-sh/shared-types/dist/recorder-events.d.ts +14 -0
  34. package/node_modules/@pome-sh/shared-types/dist/recorder-events.js +40 -0
  35. package/node_modules/@pome-sh/shared-types/dist/recorder-events.js.map +1 -1
  36. package/node_modules/@pome-sh/shared-types/package.json +1 -1
  37. package/node_modules/@pome-sh/shared-types/trace-contract.json +1 -1
  38. package/node_modules/@pome-sh/twin-github/dist/src/access-control.d.ts +3 -3
  39. package/node_modules/@pome-sh/twin-github/dist/src/check-params.d.ts +1 -0
  40. package/node_modules/@pome-sh/twin-github/dist/src/check-params.js +17 -0
  41. package/node_modules/@pome-sh/twin-github/dist/src/check-params.js.map +1 -1
  42. package/node_modules/@pome-sh/twin-github/dist/src/check-tape.d.ts +5 -0
  43. package/node_modules/@pome-sh/twin-github/dist/src/check-tape.js +159 -0
  44. package/node_modules/@pome-sh/twin-github/dist/src/check-tape.js.map +1 -0
  45. package/node_modules/@pome-sh/twin-github/dist/src/checks.d.ts +2 -0
  46. package/node_modules/@pome-sh/twin-github/dist/src/checks.js +13 -4
  47. package/node_modules/@pome-sh/twin-github/dist/src/checks.js.map +1 -1
  48. package/node_modules/@pome-sh/twin-github/dist/src/domain/checks.d.ts +4 -4
  49. package/node_modules/@pome-sh/twin-github/dist/src/domain/github-domain.d.ts +5 -5
  50. package/node_modules/@pome-sh/twin-github/dist/src/domain/pulls.d.ts +1 -1
  51. package/node_modules/@pome-sh/twin-github/dist/src/routes.js +16 -2
  52. package/node_modules/@pome-sh/twin-github/dist/src/routes.js.map +1 -1
  53. package/node_modules/@pome-sh/twin-github/dist/src/seed.d.ts +1 -1
  54. package/node_modules/@pome-sh/twin-github/dist/src/serializers.d.ts +3 -3
  55. package/node_modules/@pome-sh/twin-github/dist/src/tools.d.ts +22 -21
  56. package/node_modules/@pome-sh/twin-github/dist/src/tools.js +22 -0
  57. package/node_modules/@pome-sh/twin-github/dist/src/tools.js.map +1 -1
  58. package/node_modules/@pome-sh/twin-github/package.json +3 -3
  59. package/node_modules/@pome-sh/twin-stripe/dist/src/idempotency.js +6 -0
  60. package/node_modules/@pome-sh/twin-stripe/dist/src/idempotency.js.map +1 -1
  61. package/node_modules/@pome-sh/twin-stripe/dist/src/routes/_helpers.js +9 -1
  62. package/node_modules/@pome-sh/twin-stripe/dist/src/routes/_helpers.js.map +1 -1
  63. package/node_modules/@pome-sh/twin-stripe/dist/src/seed.d.ts +2 -2
  64. package/node_modules/@pome-sh/twin-stripe/dist/src/session.d.ts +3 -0
  65. package/node_modules/@pome-sh/twin-stripe/dist/src/session.js +72 -0
  66. package/node_modules/@pome-sh/twin-stripe/dist/src/session.js.map +1 -1
  67. package/node_modules/@pome-sh/twin-stripe/dist/src/twin.js +5 -1
  68. package/node_modules/@pome-sh/twin-stripe/dist/src/twin.js.map +1 -1
  69. package/node_modules/@pome-sh/twin-stripe/package.json +4 -4
  70. package/package.json +5 -5
  71. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/admin-gate.d.ts +0 -35
  72. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/admin-gate.js +0 -103
  73. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/admin-gate.js.map +0 -1
  74. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/auth.d.ts +0 -100
  75. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/auth.js +0 -262
  76. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/auth.js.map +0 -1
  77. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/build-info.d.ts +0 -7
  78. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/build-info.js +0 -14
  79. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/build-info.js.map +0 -1
  80. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/db.d.ts +0 -44
  81. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/db.js +0 -113
  82. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/db.js.map +0 -1
  83. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/errors.d.ts +0 -24
  84. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/errors.js +0 -61
  85. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/errors.js.map +0 -1
  86. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/failure-injection.d.ts +0 -43
  87. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/failure-injection.js +0 -160
  88. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/failure-injection.js.map +0 -1
  89. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/fidelity-inventory.d.ts +0 -121
  90. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/fidelity-inventory.js +0 -204
  91. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/fidelity-inventory.js.map +0 -1
  92. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/fidelity.d.ts +0 -8
  93. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/fidelity.js +0 -39
  94. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/fidelity.js.map +0 -1
  95. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/index.d.ts +0 -372
  96. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/index.js +0 -139
  97. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/index.js.map +0 -1
  98. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/mcp-jsonrpc.d.ts +0 -10
  99. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/mcp-jsonrpc.js +0 -221
  100. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/mcp-jsonrpc.js.map +0 -1
  101. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/parity.d.ts +0 -61
  102. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/parity.js +0 -123
  103. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/parity.js.map +0 -1
  104. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/recorder.d.ts +0 -120
  105. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/recorder.js +0 -368
  106. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/recorder.js.map +0 -1
  107. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/redaction.d.ts +0 -1
  108. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/redaction.js +0 -3
  109. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/redaction.js.map +0 -1
  110. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/server-helpers.d.ts +0 -54
  111. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/server-helpers.js +0 -181
  112. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/server-helpers.js.map +0 -1
  113. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/server.d.ts +0 -46
  114. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/server.js +0 -394
  115. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/server.js.map +0 -1
  116. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/tool-context.d.ts +0 -8
  117. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/tool-context.js +0 -22
  118. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/tool-context.js.map +0 -1
  119. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/package.json +0 -54
  120. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/errors.d.ts +0 -39
  121. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/errors.js +0 -33
  122. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/errors.js.map +0 -1
  123. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/finalize-shapes.d.ts +0 -254
  124. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/finalize-shapes.js +0 -122
  125. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/finalize-shapes.js.map +0 -1
  126. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/github-access-control.d.ts +0 -175
  127. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/github-access-control.js +0 -182
  128. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/github-access-control.js.map +0 -1
  129. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/identity.d.ts +0 -90
  130. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/identity.js +0 -72
  131. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/identity.js.map +0 -1
  132. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/index.d.ts +0 -28
  133. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/index.js +0 -35
  134. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/index.js.map +0 -1
  135. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/manifest.d.ts +0 -31
  136. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/manifest.js +0 -76
  137. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/manifest.js.map +0 -1
  138. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/event-schema.d.ts +0 -331
  139. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/event-schema.js +0 -33
  140. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/event-schema.js.map +0 -1
  141. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/fixtures/data.d.ts +0 -65
  142. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/fixtures/data.js +0 -455
  143. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/fixtures/data.js.map +0 -1
  144. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/fixtures/index.d.ts +0 -39
  145. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/fixtures/index.js +0 -47
  146. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/fixtures/index.js.map +0 -1
  147. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/index.d.ts +0 -25
  148. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/index.js +0 -27
  149. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/index.js.map +0 -1
  150. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/legacy-shim.d.ts +0 -100
  151. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/legacy-shim.js +0 -193
  152. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/legacy-shim.js.map +0 -1
  153. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/map-span.d.ts +0 -64
  154. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/map-span.js +0 -112
  155. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/map-span.js.map +0 -1
  156. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/nano.d.ts +0 -26
  157. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/nano.js +0 -61
  158. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/nano.js.map +0 -1
  159. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/project.d.ts +0 -42
  160. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/project.js +0 -104
  161. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/project.js.map +0 -1
  162. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/semconv.d.ts +0 -57
  163. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/semconv.js +0 -102
  164. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/semconv.js.map +0 -1
  165. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/span-event.d.ts +0 -134
  166. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/span-event.js +0 -152
  167. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/span-event.js.map +0 -1
  168. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/recorder-events.d.ts +0 -480
  169. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/recorder-events.js +0 -270
  170. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/recorder-events.js.map +0 -1
  171. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/redaction.d.ts +0 -2
  172. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/redaction.js +0 -152
  173. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/redaction.js.map +0 -1
  174. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/rest.d.ts +0 -257
  175. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/rest.js +0 -335
  176. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/rest.js.map +0 -1
  177. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/run.d.ts +0 -208
  178. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/run.js +0 -170
  179. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/run.js.map +0 -1
  180. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/seed-envelope.d.ts +0 -14
  181. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/seed-envelope.js +0 -46
  182. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/seed-envelope.js.map +0 -1
  183. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/seed-state.d.ts +0 -1006
  184. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/seed-state.js +0 -263
  185. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/seed-state.js.map +0 -1
  186. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/sessions.d.ts +0 -53
  187. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/sessions.js +0 -51
  188. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/sessions.js.map +0 -1
  189. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/task-vocab.d.ts +0 -80
  190. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/task-vocab.js +0 -98
  191. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/task-vocab.js.map +0 -1
  192. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/task.d.ts +0 -859
  193. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/task.js +0 -60
  194. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/task.js.map +0 -1
  195. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/manifest-schema.json +0 -68
  196. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/package.json +0 -55
  197. package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/trace-contract.json +0 -41
@@ -1,160 +0,0 @@
1
- // SPDX-License-Identifier: Apache-2.0
2
- //
3
- // Scenario-level failure injection (FDRS-339), graduated from twin-stripe
4
- // into the engine by the F-684 port ruling: making a twin fail on attempt N
5
- // of a (method, path) tuple is a generic twin capability — any provider
6
- // double needs "the server processed it but the client never saw the
7
- // response" to reproduce lost-response retry bugs. Only the rule *payloads*
8
- // (status + error envelope) are twin-domain; they ride in via the seed.
9
- //
10
- // Two modes:
11
- //
12
- // - `before_handler` → the matched request never reaches the route
13
- // handler; the middleware returns the configured envelope directly and
14
- // records a `state_mutation: false`, `state_delta: null` event.
15
- // - `after_handler` → the handler is invoked normally (state mutation
16
- // and `state_delta` capture proceed). The middleware parks the override
17
- // on the context under `FAILURE_INJECTION_OVERRIDE_KEY`; the twin's
18
- // response path substitutes status + body on the way out, so the
19
- // recorded event and the wire agree. This models a "server processed
20
- // but response delivery failed" failure — required to reproduce the
21
- // FDRS-316 hero scenario.
22
- //
23
- // Counters live per `(account_id, method, path)` so successive POSTs from
24
- // the same account to the same path resolve to `attempt: 1`, `attempt: 2`,
25
- // …, deterministically. Other routes don't influence the counter — only
26
- // requests to a tuple that has at least one registered rule are counted.
27
- import { randomUUID } from "node:crypto";
28
- import { z } from "zod";
29
- export const FAILURE_INJECTION_OVERRIDE_KEY = "failureInjectionOverride";
30
- export const failureInjectionRuleSchema = z.object({
31
- method: z.string().min(1).transform((s) => s.toUpperCase()),
32
- path: z.string().min(1),
33
- attempt: z.number().int().positive(),
34
- mode: z
35
- .enum(["before_handler", "after_handler"])
36
- .default("after_handler"),
37
- status: z.number().int().min(100).max(599),
38
- body: z.unknown(),
39
- });
40
- export function createFailureInjectionStore() {
41
- // The store is intentionally global across accounts. The (account_id,
42
- // method, path) counter keys keep accounts independent for matching;
43
- // rules themselves apply to whichever account issues the matching
44
- // request. Single-account scenarios (the common case, including the
45
- // FDRS-316 hero) don't need to express scope per rule.
46
- let rules = [];
47
- const counters = new Map();
48
- const tuplesWithRules = new Set();
49
- function tupleKey(method, path) {
50
- return `${method.toUpperCase()}\0${path}`;
51
- }
52
- function counterKey(accountId, method, path) {
53
- return `${accountId}\0${method.toUpperCase()}\0${path}`;
54
- }
55
- function rebuildIndex() {
56
- tuplesWithRules.clear();
57
- for (const r of rules)
58
- tuplesWithRules.add(tupleKey(r.method, r.path));
59
- }
60
- return {
61
- setRules(next) {
62
- rules = next.slice();
63
- counters.clear();
64
- rebuildIndex();
65
- },
66
- clear() {
67
- rules = [];
68
- counters.clear();
69
- tuplesWithRules.clear();
70
- },
71
- matchAndConsume(accountId, method, path) {
72
- const tk = tupleKey(method, path);
73
- if (!tuplesWithRules.has(tk))
74
- return null;
75
- const ck = counterKey(accountId, method, path);
76
- const count = (counters.get(ck) ?? 0) + 1;
77
- counters.set(ck, count);
78
- return (rules.find((r) => r.method.toUpperCase() === method.toUpperCase() &&
79
- r.path === path &&
80
- r.attempt === count) ?? null);
81
- },
82
- };
83
- }
84
- export function failureInjectionMiddleware(store, options) {
85
- return async (c, next) => {
86
- const session = c.get("session");
87
- // Auth runs first; if it failed there's no session and we shouldn't
88
- // shadow that with a manufactured failure.
89
- if (!session) {
90
- await next();
91
- return;
92
- }
93
- const accountId = typeof session.account_id === "string" ? session.account_id : String(session.sid ?? "_anon");
94
- const method = c.req.method.toUpperCase();
95
- const rawPath = new URL(c.req.url).pathname;
96
- // Rules are written against the canonical provider path
97
- // (e.g., "/v1/refunds"). Strip the session prefix when present so
98
- // path-mounted (`/s/:sid/v1/refunds`) and root-mounted (`/v1/refunds`,
99
- // stripe F3 SDK compat) requests both match.
100
- const path = stripSessionPrefix(rawPath);
101
- const rule = store.matchAndConsume(accountId, method, path);
102
- if (!rule) {
103
- await next();
104
- return;
105
- }
106
- if (rule.mode === "before_handler") {
107
- const started = Date.now();
108
- let requestBody = null;
109
- try {
110
- requestBody = await c.req.raw.clone().text();
111
- }
112
- catch {
113
- requestBody = null;
114
- }
115
- const requestId = `req_${randomUUID()}`;
116
- const stepId = c.req.header("x-pome-scenario-step-id") ?? null;
117
- options.recorder?.record({
118
- ts: new Date().toISOString(),
119
- run_id: options.runId,
120
- twin: options.twin,
121
- request_id: requestId,
122
- correlation_id: c.req.header("x-pome-correlation-id") ?? requestId,
123
- task_step_id: stepId,
124
- scenario_step_id: stepId,
125
- step_id: null,
126
- tool_call_id: null,
127
- method,
128
- path: rawPath,
129
- request_body: requestBody,
130
- status: rule.status,
131
- response_body: rule.body,
132
- latency_ms: Date.now() - started,
133
- fidelity: "semantic",
134
- state_mutation: false,
135
- state_delta: null,
136
- error: rule.status >= 400 ? errorMessage(rule.body) : null,
137
- });
138
- return c.json(rule.body, rule.status);
139
- }
140
- // after_handler: let the handler run, but stash the override so the
141
- // twin's response path can substitute status + body on the way out.
142
- // state_mutation + state_delta keep the real-handler truth.
143
- const override = { status: rule.status, body: rule.body };
144
- c.set(FAILURE_INJECTION_OVERRIDE_KEY, override);
145
- await next();
146
- };
147
- }
148
- function stripSessionPrefix(path) {
149
- const match = path.match(/^\/s\/[^/]+(\/.*)$/);
150
- return match?.[1] ?? path;
151
- }
152
- function errorMessage(body) {
153
- if (body && typeof body === "object" && "error" in body) {
154
- const err = body.error;
155
- if (err && typeof err.message === "string")
156
- return err.message;
157
- }
158
- return "request failed";
159
- }
160
- //# sourceMappingURL=failure-injection.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"failure-injection.js","sourceRoot":"","sources":["../src/failure-injection.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,EAAE;AACF,0EAA0E;AAC1E,4EAA4E;AAC5E,wEAAwE;AACxE,qEAAqE;AACrE,4EAA4E;AAC5E,wEAAwE;AACxE,EAAE;AACF,aAAa;AACb,EAAE;AACF,qEAAqE;AACrE,2EAA2E;AAC3E,oEAAoE;AACpE,wEAAwE;AACxE,4EAA4E;AAC5E,wEAAwE;AACxE,qEAAqE;AACrE,yEAAyE;AACzE,wEAAwE;AACxE,8BAA8B;AAC9B,EAAE;AACF,0EAA0E;AAC1E,2EAA2E;AAC3E,wEAAwE;AACxE,yEAAyE;AAEzE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,MAAM,CAAC,MAAM,8BAA8B,GAAG,0BAA0B,CAAC;AAkBzE,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC,MAAM,CAAC;IACjD,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAA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;AAC5B,CAAC;AAED,SAAS,YAAY,CAAC,IAAa;IACjC,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,OAAO,IAAI,IAAI,EAAE,CAAC;QACxD,MAAM,GAAG,GAAI,IAAyC,CAAC,KAAK,CAAC;QAC7D,IAAI,GAAG,IAAI,OAAO,GAAG,CAAC,OAAO,KAAK,QAAQ;YAAE,OAAO,GAAG,CAAC,OAAO,CAAC;IACjE,CAAC;IACD,OAAO,gBAAgB,CAAC;AAC1B,CAAC"}
@@ -1,121 +0,0 @@
1
- import { z } from "zod";
2
- export declare const heatTierSchema: z.ZodEnum<{
3
- hot: "hot";
4
- warm: "warm";
5
- cold: "cold";
6
- unclassified: "unclassified";
7
- }>;
8
- export type HeatTier = z.infer<typeof heatTierSchema>;
9
- export declare const fidelitySurfaceSchema: z.ZodObject<{
10
- name: z.ZodString;
11
- heat: z.ZodEnum<{
12
- hot: "hot";
13
- warm: "warm";
14
- cold: "cold";
15
- unclassified: "unclassified";
16
- }>;
17
- fidelity: z.ZodEnum<{
18
- semantic: "semantic";
19
- unsupported: "unsupported";
20
- shape: "shape";
21
- }>;
22
- justification: z.ZodString;
23
- }, z.core.$strict>;
24
- export type FidelitySurface = z.infer<typeof fidelitySurfaceSchema>;
25
- export declare const fidelityDocDriftSchema: z.ZodObject<{
26
- kind: z.ZodEnum<{
27
- tool: "tool";
28
- rest: "rest";
29
- }>;
30
- name: z.ZodString;
31
- reason: z.ZodString;
32
- ticket: z.ZodString;
33
- }, z.core.$strict>;
34
- export type FidelityDocDrift = z.infer<typeof fidelityDocDriftSchema>;
35
- export declare const fidelityInventorySchema: z.ZodObject<{
36
- twin: z.ZodString;
37
- package: z.ZodString;
38
- updated: z.ZodString;
39
- notes: z.ZodOptional<z.ZodString>;
40
- tools: z.ZodArray<z.ZodObject<{
41
- name: z.ZodString;
42
- heat: z.ZodEnum<{
43
- hot: "hot";
44
- warm: "warm";
45
- cold: "cold";
46
- unclassified: "unclassified";
47
- }>;
48
- fidelity: z.ZodEnum<{
49
- semantic: "semantic";
50
- unsupported: "unsupported";
51
- shape: "shape";
52
- }>;
53
- justification: z.ZodString;
54
- }, z.core.$strict>>;
55
- rest: z.ZodArray<z.ZodObject<{
56
- name: z.ZodString;
57
- heat: z.ZodEnum<{
58
- hot: "hot";
59
- warm: "warm";
60
- cold: "cold";
61
- unclassified: "unclassified";
62
- }>;
63
- fidelity: z.ZodEnum<{
64
- semantic: "semantic";
65
- unsupported: "unsupported";
66
- shape: "shape";
67
- }>;
68
- justification: z.ZodString;
69
- }, z.core.$strict>>;
70
- doc_drift: z.ZodDefault<z.ZodArray<z.ZodObject<{
71
- kind: z.ZodEnum<{
72
- tool: "tool";
73
- rest: "rest";
74
- }>;
75
- name: z.ZodString;
76
- reason: z.ZodString;
77
- ticket: z.ZodString;
78
- }, z.core.$strict>>>;
79
- }, z.core.$strict>;
80
- export type FidelityInventory = z.infer<typeof fidelityInventorySchema>;
81
- export declare function loadFidelityInventory(path: string): FidelityInventory;
82
- export interface FidelityDocRow {
83
- name: string;
84
- fidelity: string;
85
- /** Present only when the table carries the optional Heat column. */
86
- heat?: string;
87
- }
88
- export interface FidelityDocSource {
89
- /** Shown in lint problems, e.g. "FIDELITY.md". */
90
- label: string;
91
- kind: "tool" | "rest";
92
- markdown: string;
93
- }
94
- /**
95
- * Expand one name cell into surface names. Backticked spans are the names;
96
- * a span with no `.`, `/`, or space is shorthand for a sibling of the first
97
- * span (Slack-style `` `reactions.add` / `remove` / `get` ``) and inherits
98
- * its dotted prefix. Cells with no backticks name the surface verbatim
99
- * (e.g. "Any unsupported path").
100
- */
101
- export declare function expandSurfaceCell(cell: string): string[];
102
- /**
103
- * Parse every markdown table whose header names surfaces of `kind` + Tier.
104
- * The Heat column (ENDPOINT-TIERS.md) is optional: parsed when the header
105
- * names it, omitted otherwise, so pre-heat tables stay legal.
106
- */
107
- export declare function parseFidelityDocRows(markdown: string, kind: "tool" | "rest"): FidelityDocRow[];
108
- /**
109
- * 1:1-lint the inventory against the FIDELITY doc tables. Returns human-
110
- * readable problems (empty = clean). Directions checked per kind:
111
- * every doc row must be in the inventory with the same fidelity tier, and
112
- * every inventory entry must be documented unless a `doc_drift` entry
113
- * (with its owning ticket) declares the gap. A drift declaration whose
114
- * name IS documented is stale and reported, so drift entries self-expire.
115
- */
116
- export declare function lintFidelityInventory(inventory: FidelityInventory, docs: FidelityDocSource[]): string[];
117
- /** Set-compare tool names: inventory vs the live `listTools()` surface. */
118
- export declare function compareToolNames(inventoryNames: string[], liveNames: string[]): {
119
- missing: string[];
120
- extra: string[];
121
- };
@@ -1,204 +0,0 @@
1
- // SPDX-License-Identifier: Apache-2.0
2
- //
3
- // Structured fidelity inventory (F-730). Each twin ships a machine-readable
4
- // surface list — `fidelity.inventory.json` — carrying, per MCP tool and REST
5
- // surface, the heat tier (how deep the endpoint SHOULD be, ruled by the
6
- // F-729 rubric) orthogonal to the fidelity tier (how deep it IS, per
7
- // `fidelityTierSchema`), plus a justification for the classification.
8
- //
9
- // The FIDELITY doc tables are 1:1-linted against this inventory instead of
10
- // the old soft "docs mention the tool name" checks (which let twin-stripe's
11
- // implemented-but-undocumented refunds drift by silently). Known, ticketed
12
- // doc gaps are declared in `doc_drift`: the lint accepts exactly those
13
- // gaps and fails loudly once the docs catch up, so a declaration can never
14
- // outlive the drift it describes.
15
- import { readFileSync } from "node:fs";
16
- import { z } from "zod";
17
- import { fidelityTierSchema } from "./index.js";
18
- export const heatTierSchema = z.enum(["hot", "warm", "cold", "unclassified"]);
19
- export const fidelitySurfaceSchema = z.strictObject({
20
- /** MCP tool name, or the REST surface string exactly as documented. */
21
- name: z.string().min(1),
22
- heat: heatTierSchema,
23
- fidelity: fidelityTierSchema,
24
- justification: z.string().min(1),
25
- });
26
- export const fidelityDocDriftSchema = z.strictObject({
27
- kind: z.enum(["tool", "rest"]),
28
- /** Must match an inventory entry of the same kind. */
29
- name: z.string().min(1),
30
- reason: z.string().min(1),
31
- /** The Linear ticket that owns reconciling the docs. */
32
- ticket: z.string().regex(/^F-\d+$/),
33
- });
34
- export const fidelityInventorySchema = z.strictObject({
35
- twin: z.string().min(1),
36
- package: z.string().min(1),
37
- /** ISO date (YYYY-MM-DD) of the last human review of this inventory. */
38
- updated: z.string().regex(/^\d{4}-\d{2}-\d{2}$/),
39
- notes: z.string().optional(),
40
- tools: z.array(fidelitySurfaceSchema).min(1),
41
- rest: z.array(fidelitySurfaceSchema),
42
- doc_drift: z.array(fidelityDocDriftSchema).default([]),
43
- });
44
- export function loadFidelityInventory(path) {
45
- return fidelityInventorySchema.parse(JSON.parse(readFileSync(path, "utf8")));
46
- }
47
- const TOOL_NAME_HEADERS = new Set(["tool"]);
48
- const REST_NAME_HEADERS = new Set(["route", "endpoint", "surface"]);
49
- function splitTableRow(line) {
50
- return line
51
- .replace(/^\s*\|/, "")
52
- .replace(/\|\s*$/, "")
53
- .split("|")
54
- .map((cell) => cell.trim());
55
- }
56
- function isSeparatorRow(cells) {
57
- return cells.every((cell) => /^:?-{3,}:?$/.test(cell));
58
- }
59
- /**
60
- * Expand one name cell into surface names. Backticked spans are the names;
61
- * a span with no `.`, `/`, or space is shorthand for a sibling of the first
62
- * span (Slack-style `` `reactions.add` / `remove` / `get` ``) and inherits
63
- * its dotted prefix. Cells with no backticks name the surface verbatim
64
- * (e.g. "Any unsupported path").
65
- */
66
- export function expandSurfaceCell(cell) {
67
- const spans = [...cell.matchAll(/`([^`]+)`/g)].map((match) => match[1].trim());
68
- if (spans.length === 0) {
69
- const text = cell.trim();
70
- return text.length > 0 ? [text] : [];
71
- }
72
- const [first, ...rest] = spans;
73
- const lastDot = first.lastIndexOf(".");
74
- const prefix = lastDot >= 0 ? first.slice(0, lastDot + 1) : "";
75
- return [
76
- first,
77
- ...rest.map((span) => /[./ ]/.test(span) || prefix === "" ? span : `${prefix}${span}`),
78
- ];
79
- }
80
- /**
81
- * Parse every markdown table whose header names surfaces of `kind` + Tier.
82
- * The Heat column (ENDPOINT-TIERS.md) is optional: parsed when the header
83
- * names it, omitted otherwise, so pre-heat tables stay legal.
84
- */
85
- export function parseFidelityDocRows(markdown, kind) {
86
- const nameHeaders = kind === "tool" ? TOOL_NAME_HEADERS : REST_NAME_HEADERS;
87
- const rows = [];
88
- const lines = markdown.split("\n");
89
- let nameIdx = -1;
90
- let tierIdx = -1;
91
- let heatIdx = -1;
92
- let inTable = false;
93
- for (const line of lines) {
94
- if (!line.trimStart().startsWith("|")) {
95
- inTable = false;
96
- nameIdx = -1;
97
- tierIdx = -1;
98
- heatIdx = -1;
99
- continue;
100
- }
101
- const cells = splitTableRow(line);
102
- if (!inTable) {
103
- const headers = cells.map((cell) => cell.toLowerCase());
104
- nameIdx = headers.findIndex((header) => nameHeaders.has(header));
105
- tierIdx = headers.findIndex((header) => header === "tier");
106
- heatIdx = headers.findIndex((header) => header === "heat");
107
- inTable = true;
108
- continue;
109
- }
110
- if (isSeparatorRow(cells) || nameIdx < 0 || tierIdx < 0)
111
- continue;
112
- const fidelity = cells[tierIdx] ?? "";
113
- const heat = heatIdx >= 0 ? { heat: cells[heatIdx] ?? "" } : {};
114
- for (const name of expandSurfaceCell(cells[nameIdx] ?? "")) {
115
- rows.push({ name, fidelity, ...heat });
116
- }
117
- }
118
- return rows;
119
- }
120
- // ─── Lint: inventory ⇔ docs, both directions ─────────────────────────────────
121
- /**
122
- * 1:1-lint the inventory against the FIDELITY doc tables. Returns human-
123
- * readable problems (empty = clean). Directions checked per kind:
124
- * every doc row must be in the inventory with the same fidelity tier, and
125
- * every inventory entry must be documented unless a `doc_drift` entry
126
- * (with its owning ticket) declares the gap. A drift declaration whose
127
- * name IS documented is stale and reported, so drift entries self-expire.
128
- */
129
- export function lintFidelityInventory(inventory, docs) {
130
- const problems = [];
131
- for (const kind of ["tool", "rest"]) {
132
- const sources = docs.filter((doc) => doc.kind === kind);
133
- if (sources.length === 0)
134
- continue;
135
- const labels = sources.map((doc) => doc.label).join(", ");
136
- const entries = kind === "tool" ? inventory.tools : inventory.rest;
137
- const drift = new Map(inventory.doc_drift.filter((d) => d.kind === kind).map((d) => [d.name, d]));
138
- const inventoryByName = new Map();
139
- for (const entry of entries) {
140
- if (inventoryByName.has(entry.name)) {
141
- problems.push(`inventory ${kind} '${entry.name}' is listed twice`);
142
- }
143
- inventoryByName.set(entry.name, entry);
144
- }
145
- const documented = new Map();
146
- for (const source of sources) {
147
- for (const row of parseFidelityDocRows(source.markdown, kind)) {
148
- const existing = documented.get(row.name);
149
- if (existing && existing.fidelity !== row.fidelity) {
150
- problems.push(`${labels}: ${kind} '${row.name}' is documented twice with conflicting tiers ('${existing.fidelity}' vs '${row.fidelity}')`);
151
- continue;
152
- }
153
- if (existing &&
154
- existing.heat !== undefined &&
155
- row.heat !== undefined &&
156
- existing.heat !== row.heat) {
157
- problems.push(`${labels}: ${kind} '${row.name}' is documented twice with conflicting heat ('${existing.heat}' vs '${row.heat}')`);
158
- continue;
159
- }
160
- documented.set(row.name, row);
161
- }
162
- }
163
- for (const [name, row] of documented) {
164
- const entry = inventoryByName.get(name);
165
- if (!entry) {
166
- problems.push(`${labels}: ${kind} '${name}' documented but missing from fidelity.inventory.json`);
167
- continue;
168
- }
169
- if (entry.fidelity !== row.fidelity) {
170
- problems.push(`${kind} '${name}': inventory says fidelity '${entry.fidelity}' but ${labels} says '${row.fidelity}'`);
171
- }
172
- if (row.heat !== undefined && entry.heat !== row.heat) {
173
- problems.push(`${kind} '${name}': inventory says heat '${entry.heat}' but ${labels} says '${row.heat}'`);
174
- }
175
- }
176
- for (const entry of entries) {
177
- if (documented.has(entry.name))
178
- continue;
179
- const declared = drift.get(entry.name);
180
- if (!declared) {
181
- problems.push(`${kind} '${entry.name}' is in fidelity.inventory.json but undocumented in ${labels}; add the row or declare doc_drift`);
182
- }
183
- }
184
- for (const declared of drift.values()) {
185
- if (!inventoryByName.has(declared.name)) {
186
- problems.push(`doc_drift ${kind} '${declared.name}' (${declared.ticket}) matches no inventory entry`);
187
- }
188
- if (documented.has(declared.name)) {
189
- problems.push(`doc_drift ${kind} '${declared.name}' (${declared.ticket}) is stale — ${labels} now documents it; remove the declaration`);
190
- }
191
- }
192
- }
193
- return problems;
194
- }
195
- /** Set-compare tool names: inventory vs the live `listTools()` surface. */
196
- export function compareToolNames(inventoryNames, liveNames) {
197
- const inventory = new Set(inventoryNames);
198
- const live = new Set(liveNames);
199
- return {
200
- missing: [...live].filter((name) => !inventory.has(name)).sort(),
201
- extra: [...inventory].filter((name) => !live.has(name)).sort(),
202
- };
203
- }
204
- //# sourceMappingURL=fidelity-inventory.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fidelity-inventory.js","sourceRoot":"","sources":["../src/fidelity-inventory.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,EAAE;AACF,4EAA4E;AAC5E,6EAA6E;AAC7E,wEAAwE;AACxE,qEAAqE;AACrE,sEAAsE;AACtE,EAAE;AACF,2EAA2E;AAC3E,4EAA4E;AAC5E,2EAA2E;AAC3E,uEAAuE;AACvE,2EAA2E;AAC3E,kCAAkC;AAElC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhD,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC;AAG9E,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,YAAY,CAAC;IAClD,uEAAuE;IACvE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACvB,IAAI,EAAE,cAAc;IACpB,QAAQ,EAAE,kBAAkB;IAC5B,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CACjC,CAAC,CAAC;AAGH,MAAM,CAAC,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AC;IAC1C,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC;IAChC,OAAO;QACL,OAAO,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE;QAChE,KAAK,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE;KAC/D,CAAC;AACJ,CAAC"}
@@ -1,8 +0,0 @@
1
- import type { TwinDefinition } from "./index.js";
2
- export interface EmitFidelityOptions {
3
- /** ISO date (YYYY-MM-DD) embedded in "Last verified". Defaults to today. */
4
- lastVerified?: string;
5
- /** Optional trailing notes section appended after the table. */
6
- notes?: string;
7
- }
8
- export declare function emitFidelityMarkdown<TDb, TSeed, TDomain>(definition: TwinDefinition<TDb, TSeed, TDomain>, options?: EmitFidelityOptions): string;
@@ -1,39 +0,0 @@
1
- // SPDX-License-Identifier: Apache-2.0
2
- //
3
- // FIDELITY.md emitter. Generates the Tools × Tier × Backing surface × Tests
4
- // × Deviations table from a `TwinDefinition`. Per-tool fidelity metadata
5
- // lives on `ToolSpec.fidelity` (optional); when missing, the row falls back
6
- // to the manifest's `fidelity.default` tier and em-dash placeholders.
7
- export function emitFidelityMarkdown(definition, options = {}) {
8
- const lastVerified = options.lastVerified ?? new Date().toISOString().slice(0, 10);
9
- const lines = [];
10
- lines.push(`# ${definition.id} Twin Fidelity`);
11
- lines.push("");
12
- lines.push(`Auto-generated by \`@pome-sh/sdk\` for twin \`${definition.id}\` v${definition.version}.`);
13
- lines.push("");
14
- lines.push(`Last verified: ${lastVerified}.`);
15
- lines.push("");
16
- lines.push("## MCP Tools");
17
- lines.push("");
18
- lines.push("| Tool | Backing surface | Tier | Tests | Known deviations |");
19
- lines.push("| --- | --- | --- | --- | --- |");
20
- for (const tool of definition.tools) {
21
- const fid = tool.fidelity ?? {};
22
- const tier = fid.tier ?? definition.fidelity.default;
23
- const surface = fid.backingSurface ?? "—";
24
- const tests = (fid.tests ?? []).length
25
- ? (fid.tests ?? []).map((t) => `\`${t}\``).join(", ")
26
- : "—";
27
- const deviations = (fid.deviations ?? "—").replace(/\r?\n/g, " ");
28
- lines.push(`| \`${tool.name}\` | ${surface} | ${tier} | ${tests} | ${deviations} |`);
29
- }
30
- if (options.notes) {
31
- lines.push("");
32
- lines.push("## Notes");
33
- lines.push("");
34
- lines.push(options.notes);
35
- }
36
- lines.push("");
37
- return lines.join("\n");
38
- }
39
- //# sourceMappingURL=fidelity.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fidelity.js","sourceRoot":"","sources":["../src/fidelity.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,EAAE;AACF,4EAA4E;AAC5E,yEAAyE;AACzE,4EAA4E;AAC5E,sEAAsE;AAWtE,MAAM,UAAU,oBAAoB,CAClC,UAA+C,EAC/C,UAA+B,EAAE;IAEjC,MAAM,YAAY,GAAG,OAAO,CAAC,YAAY,IAAI,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACnF,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,KAAK,CAAC,IAAI,CAAC,KAAK,UAAU,CAAC,EAAE,gBAAgB,CAAC,CAAC;IAC/C,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,KAAK,CAAC,IAAI,CACR,iDAAiD,UAAU,CAAC,EAAE,OAAO,UAAU,CAAC,OAAO,GAAG,CAC3F,CAAC;IACF,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,KAAK,CAAC,IAAI,CAAC,kBAAkB,YAAY,GAAG,CAAC,CAAC;IAC9C,KAAK,CAAC,IAAI,CAAC,EAAE,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