@intentius/chant 0.124.61 → 0.124.63

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 (234) hide show
  1. package/dist/cli/handlers/approve.d.ts +18 -0
  2. package/dist/cli/handlers/approve.d.ts.map +1 -1
  3. package/dist/cli/handlers/approve.js +142 -16
  4. package/dist/cli/handlers/plan.d.ts +10 -0
  5. package/dist/cli/handlers/plan.d.ts.map +1 -0
  6. package/dist/cli/handlers/plan.js +71 -0
  7. package/dist/cli/handlers/release.d.ts +6 -4
  8. package/dist/cli/handlers/release.d.ts.map +1 -1
  9. package/dist/cli/handlers/release.js +13 -7
  10. package/dist/cli/main.d.ts.map +1 -1
  11. package/dist/cli/main.js +34 -5
  12. package/dist/cli/mcp/workspace-tools.d.ts.map +1 -1
  13. package/dist/cli/mcp/workspace-tools.js +2 -1
  14. package/dist/cli/parse-args.d.ts.map +1 -1
  15. package/dist/cli/parse-args.js +31 -0
  16. package/dist/cli/registry.d.ts +13 -1
  17. package/dist/cli/registry.d.ts.map +1 -1
  18. package/dist/config.d.ts +32 -0
  19. package/dist/config.d.ts.map +1 -1
  20. package/dist/gate-decision.d.ts +1 -1
  21. package/dist/gate-decision.d.ts.map +1 -1
  22. package/dist/gate-decision.js +4 -2
  23. package/dist/gate-statement.schema.json +44 -0
  24. package/dist/lifecycle/__fixtures__/publish-fakes.d.ts +20 -0
  25. package/dist/lifecycle/__fixtures__/publish-fakes.d.ts.map +1 -1
  26. package/dist/lifecycle/__fixtures__/publish-fakes.js +119 -3
  27. package/dist/lifecycle/gate-ledger.d.ts +17 -3
  28. package/dist/lifecycle/gate-ledger.d.ts.map +1 -1
  29. package/dist/lifecycle/gate-seal.d.ts +39 -3
  30. package/dist/lifecycle/gate-seal.d.ts.map +1 -1
  31. package/dist/lifecycle/gate-seal.js +50 -10
  32. package/dist/lifecycle/gate-statement.d.ts +70 -0
  33. package/dist/lifecycle/gate-statement.d.ts.map +1 -0
  34. package/dist/lifecycle/gate-statement.js +74 -0
  35. package/dist/lifecycle/gate-webauthn.d.ts +79 -0
  36. package/dist/lifecycle/gate-webauthn.d.ts.map +1 -0
  37. package/dist/lifecycle/gate-webauthn.js +105 -0
  38. package/dist/lifecycle/git.d.ts +1 -1
  39. package/dist/lifecycle/git.d.ts.map +1 -1
  40. package/dist/lifecycle/git.js +24 -19
  41. package/dist/lifecycle/ledger-remote.d.ts +37 -0
  42. package/dist/lifecycle/ledger-remote.d.ts.map +1 -0
  43. package/dist/lifecycle/ledger-remote.js +42 -0
  44. package/dist/lifecycle/plan-stale.d.ts +76 -0
  45. package/dist/lifecycle/plan-stale.d.ts.map +1 -0
  46. package/dist/lifecycle/plan-stale.js +121 -0
  47. package/dist/lifecycle/publish-credentials.d.ts +1 -1
  48. package/dist/lifecycle/publish-credentials.d.ts.map +1 -1
  49. package/dist/lifecycle/publish-credentials.js +2 -0
  50. package/dist/lifecycle/publish-declaration.d.ts +87 -0
  51. package/dist/lifecycle/publish-declaration.d.ts.map +1 -1
  52. package/dist/lifecycle/publish-declaration.js +87 -1
  53. package/dist/lifecycle/publish-forge.d.ts +5 -1
  54. package/dist/lifecycle/publish-forge.d.ts.map +1 -1
  55. package/dist/lifecycle/publish-forge.js +14 -4
  56. package/dist/lifecycle/publish-github.d.ts +69 -0
  57. package/dist/lifecycle/publish-github.d.ts.map +1 -0
  58. package/dist/lifecycle/publish-github.js +153 -0
  59. package/dist/lifecycle/publish-homebrew.d.ts +66 -0
  60. package/dist/lifecycle/publish-homebrew.d.ts.map +1 -0
  61. package/dist/lifecycle/publish-homebrew.js +173 -0
  62. package/dist/lifecycle/publish-marketplace.d.ts +51 -0
  63. package/dist/lifecycle/publish-marketplace.d.ts.map +1 -0
  64. package/dist/lifecycle/publish-marketplace.js +254 -0
  65. package/dist/lifecycle/publish-targets.d.ts +6 -0
  66. package/dist/lifecycle/publish-targets.d.ts.map +1 -1
  67. package/dist/lifecycle/publish-targets.js +15 -0
  68. package/dist/lifecycle/publish-tauri.d.ts +61 -0
  69. package/dist/lifecycle/publish-tauri.d.ts.map +1 -0
  70. package/dist/lifecycle/publish-tauri.js +182 -0
  71. package/dist/lifecycle/release-publish.d.ts +5 -2
  72. package/dist/lifecycle/release-publish.d.ts.map +1 -1
  73. package/dist/lifecycle/snapshot-store.d.ts.map +1 -1
  74. package/dist/lifecycle/snapshot-store.js +17 -9
  75. package/dist/lifecycle/test-passkey.d.ts +25 -0
  76. package/dist/lifecycle/test-passkey.d.ts.map +1 -0
  77. package/dist/lifecycle/test-passkey.js +39 -0
  78. package/dist/notify.d.ts +23 -3
  79. package/dist/notify.d.ts.map +1 -1
  80. package/dist/notify.js +8 -2
  81. package/dist/notify.schema.json +12 -3
  82. package/dist/op/activities/activity-contracts.d.ts +4 -4
  83. package/dist/pr-forge.d.ts +20 -0
  84. package/dist/pr-forge.d.ts.map +1 -1
  85. package/dist/pr-forge.js +61 -2
  86. package/dist/release-floors.d.ts +1 -1
  87. package/dist/release-floors.js +1 -1
  88. package/dist/wave-runtime.mjs +331 -330
  89. package/dist/workspace/ci-builds.d.ts +21 -0
  90. package/dist/workspace/ci-builds.d.ts.map +1 -1
  91. package/dist/workspace/ci-builds.js +14 -0
  92. package/dist/workspace/ci-green-workflow.d.ts +2 -0
  93. package/dist/workspace/ci-green-workflow.d.ts.map +1 -1
  94. package/dist/workspace/ci-green-workflow.js +9 -0
  95. package/dist/workspace/ci-green.d.ts +45 -2
  96. package/dist/workspace/ci-green.d.ts.map +1 -1
  97. package/dist/workspace/ci-green.js +127 -9
  98. package/dist/workspace/ci-quarantine-report.d.ts +80 -0
  99. package/dist/workspace/ci-quarantine-report.d.ts.map +1 -0
  100. package/dist/workspace/ci-quarantine-report.js +205 -0
  101. package/dist/workspace/ci-quarantine.d.ts +73 -0
  102. package/dist/workspace/ci-quarantine.d.ts.map +1 -0
  103. package/dist/workspace/ci-quarantine.js +171 -0
  104. package/dist/workspace/ci-serve.d.ts.map +1 -1
  105. package/dist/workspace/ci-serve.js +7 -4
  106. package/dist/workspace/class-data.d.ts +3 -1
  107. package/dist/workspace/class-data.d.ts.map +1 -1
  108. package/dist/workspace/class-data.js +4 -1
  109. package/dist/workspace/declaration.d.ts +45 -2
  110. package/dist/workspace/declaration.d.ts.map +1 -1
  111. package/dist/workspace/declaration.js +45 -2
  112. package/dist/workspace/declaration.schema.json +51 -3
  113. package/dist/workspace/forge-work.d.ts +76 -0
  114. package/dist/workspace/forge-work.d.ts.map +1 -0
  115. package/dist/workspace/forge-work.js +160 -0
  116. package/dist/workspace/identity-gate-rule.d.ts +3 -2
  117. package/dist/workspace/identity-gate-rule.d.ts.map +1 -1
  118. package/dist/workspace/identity-gate-rule.js +5 -7
  119. package/dist/workspace/identity.d.ts +3 -2
  120. package/dist/workspace/identity.d.ts.map +1 -1
  121. package/dist/workspace/identity.js +6 -3
  122. package/dist/workspace/intent-cli.d.ts +3 -2
  123. package/dist/workspace/intent-cli.d.ts.map +1 -1
  124. package/dist/workspace/intent-cli.js +26 -5
  125. package/dist/workspace/intent-record.d.ts +3 -0
  126. package/dist/workspace/intent-record.d.ts.map +1 -1
  127. package/dist/workspace/intent-record.schema.json +32 -0
  128. package/dist/workspace/intent.d.ts +9 -0
  129. package/dist/workspace/intent.d.ts.map +1 -1
  130. package/dist/workspace/intent.js +3 -0
  131. package/dist/workspace/intent.schema.json +32 -0
  132. package/dist/workspace/kind-readers.d.ts.map +1 -1
  133. package/dist/workspace/kind-readers.js +2 -1
  134. package/dist/workspace/kinds.d.ts +6 -1
  135. package/dist/workspace/kinds.d.ts.map +1 -1
  136. package/dist/workspace/kinds.js +8 -3
  137. package/dist/workspace/plan-stale.schema.json +286 -0
  138. package/dist/workspace/release-candidates.d.ts +33 -6
  139. package/dist/workspace/release-candidates.d.ts.map +1 -1
  140. package/dist/workspace/release-candidates.js +49 -20
  141. package/dist/workspace/release-candidates.schema.json +48 -2
  142. package/dist/workspace/trust/policy.d.ts +10 -0
  143. package/dist/workspace/trust/policy.d.ts.map +1 -1
  144. package/dist/workspace/trust/policy.js +19 -1
  145. package/dist/workspace/trust/run-commits.d.ts.map +1 -1
  146. package/dist/workspace/trust/run-commits.js +2 -1
  147. package/dist/workspace/trust/seal.d.ts.map +1 -1
  148. package/dist/workspace/trust/seal.js +34 -3
  149. package/dist/workspace/trust/trust-files.d.ts.map +1 -1
  150. package/dist/workspace/trust/trust-files.js +6 -1
  151. package/package.json +2 -1
  152. package/src/cli/handlers/approve-external-signature.test.ts +226 -0
  153. package/src/cli/handlers/approve.ts +174 -16
  154. package/src/cli/handlers/plan.ts +74 -0
  155. package/src/cli/handlers/release.ts +12 -7
  156. package/src/cli/main.ts +34 -5
  157. package/src/cli/mcp/workspace-tools.ts +2 -1
  158. package/src/cli/parse-args.ts +24 -0
  159. package/src/cli/registry.ts +13 -1
  160. package/src/gate-decision-bundle.test.ts +4 -2
  161. package/src/gate-decision.ts +11 -2
  162. package/src/gate-statement.schema.json +44 -0
  163. package/src/lifecycle/__fixtures__/publish-fakes.ts +125 -5
  164. package/src/lifecycle/gate-ledger.ts +17 -3
  165. package/src/lifecycle/gate-seal.ts +62 -9
  166. package/src/lifecycle/gate-statement.ts +107 -0
  167. package/src/lifecycle/gate-webauthn.test.ts +77 -0
  168. package/src/lifecycle/gate-webauthn.ts +133 -0
  169. package/src/lifecycle/git.ts +23 -19
  170. package/src/lifecycle/ledger-remote.test.ts +183 -0
  171. package/src/lifecycle/ledger-remote.ts +46 -0
  172. package/src/lifecycle/plan-stale.test.ts +150 -0
  173. package/src/lifecycle/plan-stale.ts +173 -0
  174. package/src/lifecycle/publish-credentials.ts +2 -0
  175. package/src/lifecycle/publish-declaration.ts +93 -1
  176. package/src/lifecycle/publish-forge.ts +15 -4
  177. package/src/lifecycle/publish-github.ts +174 -0
  178. package/src/lifecycle/publish-homebrew.test.ts +179 -0
  179. package/src/lifecycle/publish-homebrew.ts +187 -0
  180. package/src/lifecycle/publish-marketplace.test.ts +254 -0
  181. package/src/lifecycle/publish-marketplace.ts +259 -0
  182. package/src/lifecycle/publish-target-context.test.ts +2 -2
  183. package/src/lifecycle/publish-targets.test.ts +23 -0
  184. package/src/lifecycle/publish-targets.ts +15 -0
  185. package/src/lifecycle/publish-tauri.test.ts +163 -0
  186. package/src/lifecycle/publish-tauri.ts +199 -0
  187. package/src/lifecycle/release-publish.ts +5 -3
  188. package/src/lifecycle/snapshot-store.ts +16 -9
  189. package/src/lifecycle/test-passkey.ts +55 -0
  190. package/src/notify-bundle.test.ts +3 -1
  191. package/src/notify.schema.json +12 -3
  192. package/src/notify.ts +20 -3
  193. package/src/override-gate-bundle.test.ts +2 -0
  194. package/src/pr-forge-bundle.test.ts +2 -2
  195. package/src/pr-forge.test.ts +38 -0
  196. package/src/pr-forge.ts +68 -5
  197. package/src/release-floors.ts +1 -1
  198. package/src/stage-hooks-bundle.test.ts +2 -0
  199. package/src/wave-runtime-bundle.test.ts +3 -2
  200. package/src/workspace/ci-builds.ts +27 -0
  201. package/src/workspace/ci-green-stale.test.ts +193 -0
  202. package/src/workspace/ci-green-workflow.test.ts +9 -0
  203. package/src/workspace/ci-green-workflow.ts +9 -0
  204. package/src/workspace/ci-green.ts +141 -10
  205. package/src/workspace/ci-quarantine-report.test.ts +146 -0
  206. package/src/workspace/ci-quarantine-report.ts +235 -0
  207. package/src/workspace/ci-quarantine.test.ts +161 -0
  208. package/src/workspace/ci-quarantine.ts +189 -0
  209. package/src/workspace/ci-serve.ts +7 -4
  210. package/src/workspace/class-data.ts +5 -1
  211. package/src/workspace/declaration.schema.json +51 -3
  212. package/src/workspace/declaration.test.ts +1 -0
  213. package/src/workspace/declaration.ts +88 -5
  214. package/src/workspace/forge-work.test.ts +143 -0
  215. package/src/workspace/forge-work.ts +195 -0
  216. package/src/workspace/identity-gate-rule.ts +6 -8
  217. package/src/workspace/identity.ts +6 -3
  218. package/src/workspace/intent-cli.ts +24 -5
  219. package/src/workspace/intent-record.schema.json +32 -0
  220. package/src/workspace/intent-record.ts +3 -0
  221. package/src/workspace/intent.schema.json +32 -0
  222. package/src/workspace/intent.ts +10 -0
  223. package/src/workspace/kind-readers.ts +2 -1
  224. package/src/workspace/kinds.test.ts +13 -0
  225. package/src/workspace/kinds.ts +12 -3
  226. package/src/workspace/plan-stale.schema.json +286 -0
  227. package/src/workspace/release-candidates.schema.json +48 -2
  228. package/src/workspace/release-candidates.test.ts +77 -4
  229. package/src/workspace/release-candidates.ts +62 -20
  230. package/src/workspace/trust/policy.ts +24 -1
  231. package/src/workspace/trust/run-commits.ts +2 -1
  232. package/src/workspace/trust/seal.ts +35 -3
  233. package/src/workspace/trust/trust-files.test.ts +5 -0
  234. package/src/workspace/trust/trust-files.ts +15 -1
@@ -1 +1 @@
1
- {"version":3,"file":"run-commits.d.ts","sourceRoot":"","sources":["../../../src/workspace/trust/run-commits.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAsE,KAAK,OAAO,EAAE,MAAM,SAAS,CAAC;AAE3G,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAW1C,0FAA0F;AAC1F,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG;IAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,IAAI,EAAE,OAAO,EAAE,CAAA;CAAE,CAmBxG;AAED,+FAA+F;AAC/F,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,yFAAyF;IACzF,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,qFAAqF;IACrF,QAAQ,EAAE,OAAO,CAAC;IAClB,wDAAwD;IACxD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,UAAU;IACzB,4E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BAAgB,EAAE,CAAC;CAC7B;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,SAAS,SAAS,EAAE,GAAG,UAAU,CAuCrG"}
@@ -12,6 +12,7 @@
12
12
  import { execFileSync } from "node:child_process";
13
13
  import { AGENT_RUNS_DIR, LEDGER_BRANCH, foldRun, parseRunFile, readRunFiles } from "../runs.js";
14
14
  import { RUN_TRAILER } from "../trailers.js";
15
+ import { lifecycleRemoteOverride } from "../../lifecycle/ledger-remote.js";
15
16
  import { attestRun } from "./run-statement.js";
16
17
  function git(repo, args) {
17
18
  try {
@@ -23,7 +24,7 @@ function git(repo, args) {
23
24
  }
24
25
  /** Every run on the ledger, in every member's `_agent-runs`, and the ref and tip read. */
25
26
  export function readLedgerRuns(repo) {
26
- for (const ref of [`refs/heads/${LEDGER_BRANCH}`, `refs/remotes/origin/${LEDGER_BRANCH}`]) {
27
+ for (const ref of [`refs/heads/${LEDGER_BRANCH}`, `refs/remotes/${lifecycleRemoteOverride() ?? "origin"}/${LEDGER_BRANCH}`]) {
27
28
  const tip = git(repo, ["rev-parse", "--verify", "--quiet", `${ref}^{commit}`])?.trim();
28
29
  if (!tip)
29
30
  continue;
@@ -1 +1 @@
1
- {"version":3,"file":"seal.d.ts","sourceRoot":"","sources":["../../../src/workspace/trust/seal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAMH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AAG5C,OAAO,EAAmG,KAAK,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAGrK,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,eAAe,EAAE,cAAc,EAAE,KAAK,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE3I,qDAAqD;AACrD,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CAAoC;AACpC,qBAAa,SAAU,SAAQ,KAAK;IAClC,YAAY,OAAO,EAAE,MAAM,EAG1B;CACF;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,GAAG,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,IAAI,CAAA;CAAE,CAuBzG;AAMD;;;GAGG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,WAAW,CAE9I;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAAG,WAAW,CAEpI;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE,kBAAkB,GAAG,WAAW,CAEpF;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE;IAAE,aAAa,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAAG,WAAW,CAEnJ"}
@@ -26,7 +26,7 @@ import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
26
26
  import { homedir, tmpdir } from "node:os";
27
27
  import { join, resolve } from "node:path";
28
28
  import { sshKeygen, verifySshSignature } from "./ssh-commit.js";
29
- import { GATE_SEAL_NAMESPACE, gateSealPayload, namespaceAllowed, sshSignatureKey, verifySshSignatureWith } from "../../lifecycle/gate-seal.js";
29
+ import { checkGateSignature, GATE_SEAL_NAMESPACE, gateSealPayload, sshSignatureKey, verifySshSignatureWith, WEBAUTHN_SEAL_KIND } from "../../lifecycle/gate-seal.js";
30
30
  import { RELEASE_SEAL_NAMESPACE, releaseSealPayload } from "../identity-gate-rule.js";
31
31
  export { GATE_SEAL_NAMESPACE, gateSealPayload, gateSealVersion, sealedFieldsOf } from "../../lifecycle/gate-seal.js";
32
32
  /** The ssh signature namespace of a verdict seal. */
@@ -94,6 +94,9 @@ export function checkRecordSeal(policy, r) {
94
94
  * when the signers file at base lists a key for the approver.
95
95
  */
96
96
  export function checkGateSeal(policy, a) {
97
+ // #4646: a seal of kind webauthn is a passkey's assertion, listed in .chant/trust.json, not the signers file.
98
+ if (isWebAuthnSeal(a.seal))
99
+ return checkWebAuthnGateSeal(policy, a);
97
100
  return checkSeal(policy, {
98
101
  principal: a.resolvedBy,
99
102
  what: `the approval of gate ${a.gate} by ${a.resolvedBy}`,
@@ -150,10 +153,38 @@ function checkSeal(policy, s) {
150
153
  }
151
154
  /** A gate seal checked with node:crypto (#3785) against the keys `listed` for the approver in the gate namespace. */
152
155
  function verifyGate(listed, payload, signature) {
153
- const keys = listed.filter((x) => namespaceAllowed(x.namespaces, GATE_SEAL_NAMESPACE)).map((x) => Buffer.from(x.key.split(" ")[1] ?? "", "base64"));
154
- const r = verifySshSignatureWith(signature, payload, GATE_SEAL_NAMESPACE, keys);
156
+ const r = checkGateSignature({ signers: listed }, listed[0].principal, { signature }, payload);
155
157
  return r.ok ? { ok: true, principal: listed[0].principal, key: r.key } : { ok: false, reason: r.reason };
156
158
  }
159
+ const isWebAuthnSeal = (seal) => typeof seal === "object" && seal !== null && !Array.isArray(seal) && seal.kind === WEBAUTHN_SEAL_KIND;
160
+ /**
161
+ * A passkey's seal on a gate approval (#4646), checked against the passkeys
162
+ * `.chant/trust.json` lists at base for the approver. As with an ssh seal,
163
+ * attestation is on only when the signers file exists at base; with none, a
164
+ * seal that verifies against a listed passkey is intact and unattested.
165
+ */
166
+ function checkWebAuthnGateSeal(policy, a) {
167
+ const what = `the approval of gate ${a.gate} by ${a.resolvedBy}`;
168
+ const seal = a.seal;
169
+ if (typeof seal.signer !== "string" || typeof seal.signature !== "string") {
170
+ return { attested: false, code: "seal-signature-invalid", message: `the seal on ${what} is malformed: it needs signer and signature` };
171
+ }
172
+ if (normalise(seal.signer) !== normalise(a.resolvedBy)) {
173
+ return { attested: false, code: "seal-signature-invalid", message: `the seal on ${what} is by ${seal.signer}, and its approver is ${a.resolvedBy || "empty"}` };
174
+ }
175
+ const r = checkGateSignature(policy, a.resolvedBy, seal, gateSealPayload(a));
176
+ if (r.ok && !policy.active) {
177
+ return { attested: null, code: "seal-unverifiable", message: `the passkey signature is intact (${r.key}), and there is no signers file at base to turn attestation on`, key: r.key };
178
+ }
179
+ if (r.ok)
180
+ return { attested: true, message: `sealed by ${a.resolvedBy} with passkey ${r.key}, which .chant/trust.json at base lists`, key: r.key };
181
+ if (r.unlisted) {
182
+ return policy.active
183
+ ? { attested: false, code: "seal-signer-unlisted", message: `${a.resolvedBy} has no passkey in .chant/trust.json at base, so the seal can't count` }
184
+ : { attested: null, code: "seal-unverifiable", message: `the seal by ${a.resolvedBy} is a passkey's, and .chant/trust.json at base lists none for them` };
185
+ }
186
+ return { attested: false, code: "seal-signature-invalid", message: `the seal does not verify for ${a.resolvedBy} against .chant/trust.json at base: ${r.reason}` };
187
+ }
157
188
  /** A seal checked with no signers file: is the signature over these bytes intact? */
158
189
  function checkIntegrity(principal, payload, signature, namespace) {
159
190
  if (namespace === GATE_SEAL_NAMESPACE) {
@@ -1 +1 @@
1
- {"version":3,"file":"trust-files.d.ts","sourceRoot":"","sources":["../../../src/workspace/trust/trust-files.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,0GAA0G;AAC1G,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C,EAAE,MAAM,CAAC;IACpB,wCAAwC;IACxC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,4DAA4D;AAC5D,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,EAAE,cAAc,EAAE,CAAC;CAC5B;AAmDD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAkD3D;AAED,8FAA8F;AAC9F,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CAM9D;AASD,yEAAyE;AACzE,wBAAgB,UAAU,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,MAAM,CAElD;AAOD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,EAAE,CA4D1D"}
@@ -175,7 +175,7 @@ export function trustConfigProblems(raw) {
175
175
  if (!ok)
176
176
  problems.push(`${field}: ${message}`);
177
177
  };
178
- check("/", only(raw, ["schema", "signers", "roles", "adopted", "runners", "admitted"]), "unknown key");
178
+ check("/", only(raw, ["schema", "signers", "roles", "adopted", "runners", "passkeys", "admitted"]), "unknown key");
179
179
  check("schema", raw.schema === 1, "expected 1");
180
180
  check("signers", optional(raw.signers, isRepoPath), "a path inside the repository, with / separators and no ..");
181
181
  check("roles", optional(raw.roles, (r) => isObject(r) && Object.entries(r).every(([k, v]) => /^[a-z][a-z0-9-]*$/.test(k) && Array.isArray(v) && v.every(nonEmpty))), "role names to lists of principals");
@@ -183,6 +183,11 @@ export function trustConfigProblems(raw) {
183
183
  a.every((e) => isObject(e) && only(e, ["from", "to", "note"]) && optional(e.from, (f) => typeof f === "string" && FULL_COMMIT.test(f)) && typeof e.to === "string" && FULL_COMMIT.test(e.to) && optional(e.note, (n) => typeof n === "string"))), "commit ranges of full commit ids");
184
184
  check("runners", optional(raw.runners, (a) => Array.isArray(a) &&
185
185
  a.every((e) => isObject(e) && only(e, ["principal", "class", "key"]) && nonEmpty(e.principal) && (e.class === "runner" || e.class === "service") && typeof e.key === "string" && SSH_ED25519.test(e.key))), "runner keys: a principal, a class and an ssh-ed25519 key");
186
+ const b64url = (v) => typeof v === "string" && /^[A-Za-z0-9_-]+$/.test(v);
187
+ check("passkeys", optional(raw.passkeys, (a) => Array.isArray(a) &&
188
+ a.every((e) => isObject(e) && only(e, ["principal", "id", "publicKey", "rpId", "origins"]) &&
189
+ nonEmpty(e.principal) && b64url(e.id) && b64url(e.publicKey) && nonEmpty(e.rpId) &&
190
+ Array.isArray(e.origins) && e.origins.length > 0 && e.origins.every(nonEmpty))), "passkeys: a principal, a credential id, a public key, an rpId and origins");
186
191
  check("admitted", optional(raw.admitted, (a) => Array.isArray(a) &&
187
192
  a.every((e) => isObject(e) && only(e, ["return", "signers", "note"]) &&
188
193
  typeof e.return === "string" && /^ret-[0-9a-f]{12}$/.test(e.return) &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intentius/chant",
3
- "version": "0.124.61",
3
+ "version": "0.124.63",
4
4
  "description": "Declarative infrastructure-as-code toolkit — TypeScript on Node.js",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://intentius.io/chant",
@@ -57,6 +57,7 @@
57
57
  "./capabilities/templates.json": "./src/capabilities/templates.json",
58
58
  "./notify.schema.json": "./src/notify.schema.json",
59
59
  "./health.schema.json": "./src/health.schema.json",
60
+ "./gate-statement.schema.json": "./src/gate-statement.schema.json",
60
61
  "./workspace/factory-rules": {
61
62
  "development": "./src/workspace/factory-rules.ts",
62
63
  "types": "./dist/workspace/factory-rules.d.ts",
@@ -0,0 +1,226 @@
1
+ /**
2
+ * #4646: an approval signed outside chant counts toward a gate that counts
3
+ * only signed approvals. `chant approve --statement` prints the bytes, an ssh
4
+ * key on another machine or a passkey signs them, and `chant approve
5
+ * --signature` records the signature, checked against the signers file and
6
+ * the passkeys in `.chant/trust.json` at base. Real keys: ssh-keygen and
7
+ * node:crypto. Against temp repos; nothing is pushed.
8
+ */
9
+
10
+ import { afterAll, afterEach, beforeAll, describe, expect, test, vi } from "vitest";
11
+ import { writeFileSync } from "node:fs";
12
+ import { join } from "node:path";
13
+ import { appendPendingGate, readGateLedger } from "../../lifecycle/gate-ledger";
14
+ import { resetGateOrigin } from "../../lifecycle/gate-origin";
15
+ import { gateSealPayload } from "../../lifecycle/gate-seal";
16
+ import { GATE_STATEMENT_SCHEMA_ID, type GateStatement } from "../../lifecycle/gate-statement";
17
+ import { assert, passkey, type Passkey } from "../../lifecycle/test-passkey";
18
+ import { gateAdmission } from "../../workspace/identity";
19
+ import { checkGateSeal } from "../../workspace/trust/seal";
20
+ import { readTrustPolicy } from "../../workspace/trust/policy";
21
+ import { gitRevisionSource } from "../../workspace/record-source";
22
+ import { hasSshKeygen, TestRepo, type Key } from "../../workspace/trust/test-repo";
23
+ import { contract, validSchema } from "../../workspace/__fixtures__/contract-repo";
24
+ import { gateApprovalStatement, recordGateApproval, runApprove } from "./approve";
25
+ import { parseArgs } from "../main";
26
+ import type { ParsedArgs } from "../registry";
27
+ import schema from "../../gate-statement.schema.json";
28
+
29
+ vi.mock("../../op/discover", () => ({ discoverOps: async () => ({ errors: [], ops: new Map() }) }));
30
+
31
+ const PLAN = `sha256:${"a".repeat(64)}`;
32
+ const OTHER = `sha256:${"b".repeat(64)}`;
33
+ const PENDING_AT = "2026-01-01T09:00:00.000Z";
34
+
35
+ const repos: TestRepo[] = [];
36
+ const home = process.cwd();
37
+ afterEach(() => {
38
+ process.chdir(home);
39
+ resetGateOrigin();
40
+ while (repos.length) repos.pop()!.cleanup();
41
+ });
42
+
43
+ let keys: TestRepo;
44
+ let alice: Key;
45
+ let mallory: Key;
46
+ let erin: Passkey;
47
+ let frank: Passkey;
48
+ beforeAll(() => {
49
+ erin = passkey("github:erin", "cred-erin", "EdDSA");
50
+ frank = passkey("github:frank", "cred-frank", "ES256");
51
+ if (!hasSshKeygen) return;
52
+ keys = new TestRepo("4646-keys");
53
+ alice = keys.key("alice");
54
+ mallory = keys.key("mallory");
55
+ });
56
+ afterAll(() => keys?.cleanup());
57
+
58
+ /** A workspace whose gate `ship` counts only signed approvals, with alice's ssh key and two passkeys at base, waiting at the gate for PLAN. */
59
+ async function waiting(): Promise<TestRepo> {
60
+ const r = new TestRepo("4646");
61
+ repos.push(r);
62
+ r.git(["config", "user.email", "t@example.test"]);
63
+ r.git(["config", "user.name", "t"]);
64
+ r.git(["config", "commit.gpgsign", "false"]);
65
+ r.write("chant.workspace.json", JSON.stringify({ name: "acme", schema: 1, members: [], identity: { gates: { ship: {} } } }));
66
+ r.write(".chant/allowed_signers", `github:alice ${alice.pub}\n`);
67
+ r.write(".chant/trust.json", JSON.stringify({ schema: 1, passkeys: [erin.signer, frank.signer] }));
68
+ r.commit("base");
69
+ await appendPendingGate(
70
+ { op: "deploy", gate: "ship", timestamp: PENDING_AT, origin: "cli", expiresAt: "2999-01-01T00:00:00.000Z", planDigest: PLAN, environment: "prod" },
71
+ { cwd: r.dir },
72
+ );
73
+ process.chdir(r.dir);
74
+ return r;
75
+ }
76
+
77
+ async function statementFor(r: TestRepo, actor: string, extra: { plan?: string } = {}): Promise<GateStatement> {
78
+ const s = await gateApprovalStatement("deploy", "ship", { origin: "cli", actor, cwd: r.dir, ...extra });
79
+ expect(s).not.toBeNull();
80
+ return s!;
81
+ }
82
+
83
+ function file(r: TestRepo, name: string, text: string): string {
84
+ const f = join(r.dir, "..", `${name}-${Math.random().toString(36).slice(2)}`);
85
+ writeFileSync(f, text);
86
+ return f;
87
+ }
88
+
89
+ const { expectValid } = contract(schema);
90
+
91
+ describe.skipIf(!hasSshKeygen)("an approval signed outside chant (#4646)", () => {
92
+ test("--statement prints the bytes --sign would sign, and records nothing", async () => {
93
+ expect(validSchema(schema)).toBe(true);
94
+ expect(schema.$id).toBe(GATE_STATEMENT_SCHEMA_ID);
95
+ const r = await waiting();
96
+ const s = await statementFor(r, "github:erin");
97
+ expectValid(s);
98
+ const bytes = gateSealPayload({ op: "deploy", gate: "ship", environment: "prod", planDigest: PLAN, resolvedBy: "github:erin", timestamp: s.timestamp });
99
+ expect(Buffer.from(s.statement, "base64")).toEqual(bytes);
100
+ expect(s.text).toBe(`deploy\nship\nprod\n${PLAN}\ngithub:erin\n${s.timestamp}`);
101
+ expect(s).toMatchObject({ planDigest: PLAN, environment: "prod", relayedBy: null, sealVersion: 1, namespace: "chant-gate" });
102
+ expect((await readGateLedger("deploy", { cwd: r.dir })).resolutions).toEqual([]);
103
+ });
104
+
105
+ test("an ssh signature made on another machine by a wrong key, over another plan or at another time is refused", async () => {
106
+ const r = await waiting();
107
+ const s = await statementFor(r, "github:alice");
108
+ const signed = keys.sshSign(alice, Buffer.from(s.statement, "base64"), s.namespace);
109
+
110
+ // mallory's key, and alice's key over the statement for another plan.
111
+ const bad = keys.sshSign(mallory, Buffer.from(s.statement, "base64"), s.namespace);
112
+ expect((await recordGateApproval("deploy", "ship", { origin: "cli", actor: "github:alice", at: s.timestamp, signature: file(r, "bad", bad), cwd: r.dir })).ok).toBe(false);
113
+ const other = await statementFor(r, "github:alice", { plan: OTHER });
114
+ const elsewhere = keys.sshSign(alice, Buffer.from(other.statement, "base64"), s.namespace);
115
+ expect((await recordGateApproval("deploy", "ship", { origin: "cli", actor: "github:alice", at: other.timestamp, signature: file(r, "other", elsewhere), cwd: r.dir })).ok).toBe(false);
116
+ // The right signature at another time.
117
+ const later = new Date(Date.parse(s.timestamp) + 1).toISOString();
118
+ expect((await recordGateApproval("deploy", "ship", { origin: "cli", actor: "github:alice", at: later, signature: file(r, "late", signed), cwd: r.dir })).ok).toBe(false);
119
+ expect((await readGateLedger("deploy", { cwd: r.dir })).resolutions).toEqual([]);
120
+ });
121
+
122
+ test("an ssh signature made on another machine counts, and the record re-checks offline", async () => {
123
+ const r = await waiting();
124
+ const s = await statementFor(r, "github:alice");
125
+ const signed = keys.sshSign(alice, Buffer.from(s.statement, "base64"), s.namespace);
126
+ const out = await recordGateApproval("deploy", "ship", { origin: "cli", actor: "github:alice", at: s.timestamp, signature: file(r, "sig", signed), cwd: r.dir });
127
+ expect(out.ok).toBe(true);
128
+ if (!out.ok) return;
129
+ expect(out.record.timestamp).toBe(s.timestamp);
130
+ expect(out.record.seal).toMatchObject({ signer: "github:alice", signature: signed });
131
+ expect(out.record.seal?.key).toMatch(/^SHA256:/);
132
+ expect(out.record.seal?.kind).toBeUndefined();
133
+ expect(gateAdmission(r.dir, "ship")!.refuses(out.record)).toBeNull();
134
+ expect(checkGateSeal(readTrustPolicy(gitRevisionSource(r.dir, "HEAD"), null), out.record).attested).toBe(true);
135
+ });
136
+
137
+ test.each([["an Ed25519", () => erin], ["a P-256", () => frank]] as const)("%s passkey's assertion counts, and the record re-checks offline", async (_name, who) => {
138
+ const pk = who();
139
+ const r = await waiting();
140
+ const s = await statementFor(r, pk.signer.principal);
141
+ const a = assert(pk, Buffer.from(s.statement, "base64"));
142
+ const out = await recordGateApproval("deploy", "ship", { origin: "cli", actor: pk.signer.principal, at: s.timestamp, signature: file(r, "assertion", JSON.stringify(a)), cwd: r.dir });
143
+ expect(out.ok).toBe(true);
144
+ if (!out.ok) return;
145
+ expect(out.record.seal).toEqual({
146
+ kind: "webauthn",
147
+ signer: pk.signer.principal,
148
+ key: pk.signer.id,
149
+ signature: a.signature,
150
+ clientDataJSON: a.clientDataJSON,
151
+ authenticatorData: a.authenticatorData,
152
+ });
153
+ // Read back off the ledger and judged again, as a run and verify judge it.
154
+ const [line] = (await readGateLedger("deploy", { cwd: r.dir })).resolutions;
155
+ expect(gateAdmission(r.dir, "ship")!.refuses(line!)).toBeNull();
156
+ const policy = readTrustPolicy(gitRevisionSource(r.dir, "HEAD"), null);
157
+ expect(checkGateSeal(policy, line!)).toMatchObject({ attested: true, key: pk.signer.id });
158
+ // Moving the approval to another plan breaks it.
159
+ expect(checkGateSeal(policy, { ...line!, planDigest: OTHER }).attested).toBe(false);
160
+ expect(gateAdmission(r.dir, "ship")!.refuses({ ...line!, planDigest: OTHER })).toMatch(/challenge/);
161
+ });
162
+
163
+ test("a passkey's assertion is refused for another approver, another plan, or without user verification", async () => {
164
+ const r = await waiting();
165
+ const s = await statementFor(r, "github:erin");
166
+ const bytes = Buffer.from(s.statement, "base64");
167
+ const refused = async (actor: string, assertion: object, at = s.timestamp) =>
168
+ !(await recordGateApproval("deploy", "ship", { origin: "cli", actor, at, signature: file(r, "a", JSON.stringify(assertion)), cwd: r.dir })).ok;
169
+ // frank's passkey over erin's statement, recorded as erin: the credential isn't erin's.
170
+ expect(await refused("github:erin", assert(frank, bytes))).toBe(true);
171
+ // erin's passkey recorded as frank: the statement names erin.
172
+ expect(await refused("github:frank", assert(erin, bytes))).toBe(true);
173
+ const other = await statementFor(r, "github:erin", { plan: OTHER });
174
+ expect(await refused("github:erin", assert(erin, Buffer.from(other.statement, "base64")))).toBe(true);
175
+ expect(await refused("github:erin", assert(erin, bytes, { flags: 0x01 }))).toBe(true);
176
+ expect(await refused("github:erin", assert(erin, bytes, { origin: "https://evil.example" }))).toBe(true);
177
+ expect((await readGateLedger("deploy", { cwd: r.dir })).resolutions).toEqual([]);
178
+ });
179
+
180
+ test("--at must be the statement's, in chant's form, not before the pending fact or in the future", async () => {
181
+ const r = await waiting();
182
+ const s = await statementFor(r, "github:erin");
183
+ const a = file(r, "a", JSON.stringify(assert(erin, Buffer.from(s.statement, "base64"))));
184
+ const tryAt = async (at: string | undefined) =>
185
+ (await recordGateApproval("deploy", "ship", { origin: "cli", actor: "github:erin", ...(at !== undefined ? { at } : {}), signature: a, cwd: r.dir })).ok;
186
+ expect(await tryAt(undefined)).toBe(false);
187
+ expect(await tryAt("2026-11-01T10:00:00Z")).toBe(false);
188
+ expect(await tryAt("2026-01-01T08:00:00.000Z")).toBe(false);
189
+ expect(await tryAt(new Date(Date.now() + 60 * 60 * 1000).toISOString())).toBe(false);
190
+ expect(await gateApprovalStatement("deploy", "ship", { origin: "cli", actor: "github:erin", at: "2026-01-01T08:00:00.000Z", cwd: r.dir })).toBeNull();
191
+ expect(await tryAt(s.timestamp)).toBe(true);
192
+ });
193
+
194
+ test("--at goes with --statement or --signature, and --signature not with --sign", async () => {
195
+ const r = await waiting();
196
+ const s = await statementFor(r, "github:erin");
197
+ const a = file(r, "a", JSON.stringify(assert(erin, Buffer.from(s.statement, "base64"))));
198
+ expect((await recordGateApproval("deploy", "ship", { origin: "cli", actor: "github:erin", at: s.timestamp, cwd: r.dir })).ok).toBe(false);
199
+ expect((await recordGateApproval("deploy", "ship", { origin: "cli", actor: "github:alice", at: s.timestamp, sign: alice.file, signature: a, cwd: r.dir })).ok).toBe(false);
200
+ expect((await readGateLedger("deploy", { cwd: r.dir })).resolutions).toEqual([]);
201
+ });
202
+
203
+ test("chant approve --statement prints the document, and --signature - reads stdin's path through the flags", async () => {
204
+ expect(parseArgs(["approve", "deploy", "ship", "--statement", "--actor", "github:erin"])).toMatchObject({ statement: true, actor: "github:erin" });
205
+ expect(parseArgs(["approve", "deploy", "ship", "--signature", "-", "--at", "2026-11-01T10:00:00.000Z"])).toMatchObject({ signature: "-", at: "2026-11-01T10:00:00.000Z" });
206
+ expect(() => parseArgs(["approve", "deploy", "ship", "--signature", "--at", "x"])).toThrow(/--signature needs a file/);
207
+ await waiting();
208
+ const printed: string[] = [];
209
+ const log = vi.spyOn(console, "log").mockImplementation((t: string) => void printed.push(t));
210
+ try {
211
+ const args = { command: "approve", path: "deploy", extraPositional: "ship", format: "", fix: false, watch: false, verbose: false, help: false, live: false, yes: true, statement: true, actor: "github:erin" } as ParsedArgs;
212
+ expect(await runApprove({ args, plugins: [], serializers: [] } as never)).toBe(0);
213
+ expect(await runApprove({ args: { ...args, signature: "x" }, plugins: [], serializers: [] } as never)).toBe(1);
214
+ } finally {
215
+ log.mockRestore();
216
+ }
217
+ const doc = JSON.parse(printed.join(""));
218
+ expectValid(doc);
219
+ expect(doc).toMatchObject({ schema: "chant-gate-statement/v1", resolvedBy: "github:erin", planDigest: PLAN });
220
+ });
221
+
222
+ test("an unsigned approval of the gate is still refused", async () => {
223
+ const r = await waiting();
224
+ expect((await recordGateApproval("deploy", "ship", { origin: "cli", actor: "github:erin", cwd: r.dir })).ok).toBe(false);
225
+ });
226
+ });
@@ -27,6 +27,12 @@ import { PR_GATE_OP } from "../../pr-loop";
27
27
  import { pushLifecycleReport, requireLifecycleLedger } from "../../lifecycle/git";
28
28
  import { LIFECYCLE_LOCAL_NOTE, isLifecycleLocalNote } from "../../lifecycle/local-note";
29
29
  import { ledgerRecordingOff, NO_RECORD_ENV } from "../../lifecycle/no-record";
30
+ import { checkGateSignature, gateSealPayload, gateSealVersion, WEBAUTHN_SEAL_KIND, type SealedGateApproval } from "../../lifecycle/gate-seal";
31
+ import { gateStatement, readExternalSignature, type GateStatement } from "../../lifecycle/gate-statement";
32
+ import type { GateApprovalSeal } from "../../lifecycle/gate-ledger";
33
+ import type { TrustPolicy } from "../../workspace/trust/policy";
34
+ import { readFileSync } from "node:fs";
35
+ import { resolve as resolvePath } from "node:path";
30
36
  import { formatError, formatWarning, formatSuccess, formatInfo } from "../format";
31
37
  import type { CommandContext } from "../registry";
32
38
 
@@ -158,12 +164,41 @@ export async function runApprove(ctx: CommandContext): Promise<number> {
158
164
  // has applied since #2126 (`../handlers/run.ts`'s `runOpApprove`). Reading
159
165
  // only `--actor` here meant every README that teaches `--approver you`
160
166
  // recorded the shell user instead (#2192).
167
+ // #4646: the statement for a signature made elsewhere, on stdout, with nothing recorded.
168
+ if (ctx.args.statement) {
169
+ if (ctx.args.sign !== undefined || ctx.args.signature !== undefined) {
170
+ console.error(formatError({ message: "--statement prints what to sign and records nothing, so it takes neither --sign nor --signature" }));
171
+ return 1;
172
+ }
173
+ const shared: GateApprovalOptions = {
174
+ actor: ctx.args.approver ?? ctx.args.actor,
175
+ ...(ctx.args.plan !== undefined ? { plan: ctx.args.plan } : {}),
176
+ ...(ctx.args.env !== undefined ? { environment: ctx.args.env } : {}),
177
+ ...(ctx.args.relayedBy !== undefined ? { relayedBy: ctx.args.relayedBy } : {}),
178
+ ...(ctx.args.at !== undefined ? { at: ctx.args.at } : {}),
179
+ allowSameOrigin: ctx.args.allowSameOrigin,
180
+ };
181
+ const statement = await gateApprovalStatement(opName, gate, shared);
182
+ if (!statement) return 1;
183
+ console.log(JSON.stringify(statement, null, 2));
184
+ console.error(formatInfo(
185
+ `Have ${statement.resolvedBy} sign these bytes (an ssh key in the ${statement.namespace} namespace, or a passkey with challenge ${statement.challenge}), ` +
186
+ `then record it: chant approve ${opName} ${gate} --actor ${statement.resolvedBy}` +
187
+ (statement.relayedBy !== null ? ` --relayed-by ${statement.relayedBy}` : "") +
188
+ (statement.planDigest !== null ? ` --plan ${statement.planDigest}` : "") +
189
+ (statement.environment !== null ? ` --env ${statement.environment}` : "") +
190
+ ` --at ${statement.timestamp} --signature <file>`,
191
+ ));
192
+ return 0;
193
+ }
194
+
161
195
  // #4575: a person at a terminal sees the plan and types the target's name
162
196
  // first, and the approval binds the digest they were shown. --yes, --json,
163
197
  // CI and no terminal record as before.
164
198
  let plan = ctx.args.plan;
165
199
  const confirm = await import("./approve-confirm");
166
- if (await confirm.interactiveApproval(ctx.args)) {
200
+ // #4646: an approval signed elsewhere was confirmed where it was signed.
201
+ if (ctx.args.signature === undefined && (await confirm.interactiveApproval(ctx.args))) {
167
202
  const answered = await confirm.confirmApproval(opName, gate, {
168
203
  ...(plan !== undefined ? { plan } : {}),
169
204
  ...(ctx.args.env !== undefined ? { environment: ctx.args.env } : {}),
@@ -181,6 +216,8 @@ export async function runApprove(ctx: CommandContext): Promise<number> {
181
216
  ...(ctx.args.roles ? { roles: ctx.args.roles } : {}),
182
217
  ...(ctx.args.agent ? { agent: true } : {}),
183
218
  ...(ctx.args.sign !== undefined ? { sign: ctx.args.sign } : {}),
219
+ ...(ctx.args.signature !== undefined ? { signature: ctx.args.signature } : {}),
220
+ ...(ctx.args.at !== undefined ? { at: ctx.args.at } : {}),
184
221
  ...(ctx.args.relayedBy !== undefined ? { relayedBy: ctx.args.relayedBy } : {}),
185
222
  });
186
223
  if (!outcome.ok) return 1;
@@ -267,6 +304,15 @@ export interface GateApprovalOptions {
267
304
  * the declaration's `identity.gates` names counts only sealed approvals.
268
305
  */
269
306
  sign?: string | true;
307
+ /**
308
+ * `--signature <file>` (#4646): a signature made outside chant over the
309
+ * approval's statement (`--statement`), an armored ssh signature or a
310
+ * WebAuthn assertion in JSON; `-` reads it from stdin. Checked against the
311
+ * keys and passkeys listed at base for the approver, and kept as the seal.
312
+ */
313
+ signature?: string;
314
+ /** `--at <timestamp>` (#4646): the statement's time, which `--statement` fixes and `--signature` records. */
315
+ at?: string;
270
316
  /** Where the workspace and the key file are looked up from. Defaults to the process's directory. */
271
317
  cwd?: string;
272
318
  /** Replaces the lexicon evaluator a gate policy is loaded from. For tests. */
@@ -337,8 +383,30 @@ export async function recordGateApproval(
337
383
  gate: string,
338
384
  opts: GateApprovalOptions,
339
385
  ): Promise<GateApprovalOutcome> {
386
+ const r = await approveGate(opName, gate, opts, false);
387
+ return "statement" in r ? { ok: false } : r;
388
+ }
389
+
390
+ /**
391
+ * The statement an approval of this gate would sign (#4646), for a signature
392
+ * made outside chant: what `chant approve <op> <gate> --statement` prints.
393
+ * It runs every check {@link recordGateApproval} runs before signing, with
394
+ * the same options, and writes nothing. Null when a check refuses, which it
395
+ * prints.
396
+ */
397
+ export async function gateApprovalStatement(opName: string, gate: string, opts: GateApprovalOptions): Promise<GateStatement | null> {
398
+ const r = await approveGate(opName, gate, opts, true);
399
+ return "statement" in r ? r.statement : null;
400
+ }
401
+
402
+ async function approveGate(
403
+ opName: string,
404
+ gate: string,
405
+ opts: GateApprovalOptions,
406
+ statementOnly: boolean,
407
+ ): Promise<GateApprovalOutcome | { statement: GateStatement }> {
340
408
  // #3955: with recording off the approval would be dropped with the process.
341
- if (ledgerRecordingOff()) {
409
+ if (!statementOnly && ledgerRecordingOff()) {
342
410
  console.error(formatError({
343
411
  message: `Cannot record the approval of "${gate}": ${NO_RECORD_ENV} is set, so nothing is written to chant/lifecycle`,
344
412
  hint: `Unset ${NO_RECORD_ENV} to approve the gate.`,
@@ -557,34 +625,78 @@ export async function recordGateApproval(
557
625
  }));
558
626
  return { ok: false };
559
627
  }
628
+ // #4646: --statement prints the bytes a signature made elsewhere signs, at
629
+ // a time it fixes; --signature records that signature with the same time.
630
+ const refuse = (message: string, hint?: string) => {
631
+ console.error(formatError({ message: `Gate "${gate}" on "${opName}" was not approved: ${message}`, ...(hint ? { hint } : {}) }));
632
+ return { ok: false } as const;
633
+ };
634
+ if (opts.signature !== undefined && opts.sign !== undefined) {
635
+ return refuse("--sign signs here and --signature brings a signature made elsewhere; pass one of them");
636
+ }
637
+ if (opts.at !== undefined && !statementOnly && opts.signature === undefined) {
638
+ return refuse("--at sets the time of a statement signed elsewhere, so it goes with --statement or --signature");
639
+ }
640
+ if (opts.signature !== undefined && opts.at === undefined) {
641
+ return refuse(
642
+ "--signature needs --at <timestamp>, the statement's time, since the signature covers it",
643
+ `Pass the timestamp \`chant approve ${opName} ${gate} --statement\` printed.`,
644
+ );
645
+ }
646
+ let timestamp = new Date().toISOString();
647
+ if (opts.at !== undefined) {
648
+ const at = Date.parse(opts.at);
649
+ if (!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/.test(opts.at) || Number.isNaN(at) || new Date(at).toISOString() !== opts.at) {
650
+ return refuse(`--at takes a UTC time as chant writes one, such as ${timestamp}, not ${JSON.stringify(opts.at)}`);
651
+ }
652
+ if (at > Date.now() + AT_SKEW_MS) return refuse(`--at ${opts.at} is in the future`);
653
+ if (standing && opts.at < standing.timestamp) {
654
+ return refuse(
655
+ `--at ${opts.at} is before the pending fact it answers (${standing.timestamp}), and a run counts only approvals newer than that`,
656
+ `Take a fresh statement: chant approve ${opName} ${gate} --statement.`,
657
+ );
658
+ }
659
+ timestamp = opts.at;
660
+ }
661
+ const sealed: SealedGateApproval = {
662
+ op: opName,
663
+ gate,
664
+ ...(environment !== undefined ? { environment } : {}),
665
+ ...(planDigest !== undefined ? { planDigest } : {}),
666
+ resolvedBy,
667
+ ...(relayedBy ? { relayedBy } : {}),
668
+ timestamp,
669
+ ...(checkpointDigest !== undefined ? { checkpointDigest } : {}),
670
+ };
671
+ if (statementOnly) {
672
+ const { CHANT_VERSION } = await import("../../chant-version");
673
+ return { statement: gateStatement(sealed, CHANT_VERSION) };
674
+ }
675
+
560
676
  const rule = identity.gateAdmissionFrom(scope, gate);
561
- if (rule && opts.sign === undefined) {
677
+ if (rule && opts.sign === undefined && opts.signature === undefined) {
562
678
  console.error(formatError({
563
679
  message:
564
680
  `Gate "${gate}" needs a signed approval: chant.workspace.json at base names it in identity.gates` +
565
681
  (rule.requirement.class !== null ? `, from the class ${rule.requirement.class}` : "") +
566
682
  `, and this approval is not signed`,
567
- hint: `chant approve ${opName} ${gate} --actor <principal> --sign [<key file>], with a key ${scope.policy.signersPath} at base lists for that principal.`,
683
+ hint:
684
+ `chant approve ${opName} ${gate} --actor <principal> --sign [<key file>], with a key ${scope.policy.signersPath} at base lists for that principal, ` +
685
+ `or --signature <file> --at <timestamp> with a signature made elsewhere over the statement --statement prints.`,
568
686
  }));
569
687
  return { ok: false };
570
688
  }
571
- const timestamp = new Date().toISOString();
572
689
  let seal: GateResolutionRecord["seal"];
690
+ if (opts.signature !== undefined) {
691
+ const made = externalSeal(opts.signature, sealed, scope.policy, cwd);
692
+ if ("refused" in made) return refuse(made.refused);
693
+ seal = made.seal;
694
+ }
573
695
  if (opts.sign !== undefined) {
574
696
  const { resolveSigningKey, sealGateApproval, gateSealVersion, SealError } = await import("../../workspace/trust/seal");
575
697
  try {
576
698
  const key = resolveSigningKey(opts.sign, cwd);
577
699
  try {
578
- const sealed = {
579
- op: opName,
580
- gate,
581
- ...(environment !== undefined ? { environment } : {}),
582
- ...(planDigest !== undefined ? { planDigest } : {}),
583
- resolvedBy,
584
- ...(relayedBy ? { relayedBy } : {}),
585
- timestamp,
586
- ...(checkpointDigest !== undefined ? { checkpointDigest } : {}),
587
- };
588
700
  // #3947: a seal over a checkpoint digest is seal version 2.
589
701
  seal = { ...sealGateApproval(key.file, sealed), ...(gateSealVersion(sealed) === 2 ? { version: 2 as const } : {}) };
590
702
  } finally {
@@ -704,7 +816,7 @@ export async function recordGateApproval(
704
816
  (record.relayedBy ? `, relayed by ${record.relayedBy},` : "") +
705
817
  ` at ${record.timestamp}` +
706
818
  (record.url ? ` (${record.url})` : "") +
707
- (record.seal ? `, signed with ${record.seal.key}` : "") +
819
+ (record.seal ? `, signed with ${record.seal.kind === WEBAUTHN_SEAL_KIND ? "passkey " : ""}${record.seal.key}` : "") +
708
820
  push.suffix,
709
821
  ));
710
822
  if (record.planDigest) {
@@ -736,6 +848,52 @@ export async function recordGateApproval(
736
848
  return { ok: true, record, pushed: push.pushed };
737
849
  }
738
850
 
851
+ /** How far in the future `--at` may be (#4646), for a clock that runs a little ahead of this one. */
852
+ const AT_SKEW_MS = 5 * 60 * 1000;
853
+
854
+ /**
855
+ * The seal for a signature made outside chant (#4646): the file `--signature`
856
+ * names (`-` for stdin), read as an armored ssh signature or a WebAuthn
857
+ * assertion, and checked over `sealed`'s statement against the keys and
858
+ * passkeys listed at base for the approver. A signature nothing at base
859
+ * vouches for is refused rather than recorded.
860
+ */
861
+ function externalSeal(
862
+ from: string,
863
+ sealed: SealedGateApproval,
864
+ policy: TrustPolicy,
865
+ cwd: string,
866
+ ): { seal: GateApprovalSeal } | { refused: string } {
867
+ let text: string;
868
+ try {
869
+ text = from === "-" ? readFileSync(0, "utf-8") : readFileSync(resolvePath(cwd, from), "utf-8");
870
+ } catch (err) {
871
+ return { refused: `--signature ${from} can't be read: ${err instanceof Error ? err.message : String(err)}` };
872
+ }
873
+ const sig = readExternalSignature(text);
874
+ if ("problem" in sig) return { refused: `--signature ${from}: ${sig.problem}` };
875
+ const candidate: GateApprovalSeal =
876
+ sig.kind === "ssh"
877
+ ? { signer: sealed.resolvedBy, key: "", signature: sig.signature }
878
+ : {
879
+ kind: WEBAUTHN_SEAL_KIND,
880
+ signer: sealed.resolvedBy,
881
+ key: sig.assertion.id,
882
+ signature: sig.assertion.signature,
883
+ clientDataJSON: sig.assertion.clientDataJSON,
884
+ authenticatorData: sig.assertion.authenticatorData,
885
+ };
886
+ const r = checkGateSignature(policy, sealed.resolvedBy, candidate as unknown as { signature: string } & Record<string, unknown>, gateSealPayload(sealed));
887
+ if (!r.ok) {
888
+ return {
889
+ refused: r.unlisted
890
+ ? `${sealed.resolvedBy} has no ${sig.kind === "ssh" ? `key in ${policy.signersPath}` : "passkey in .chant/trust.json"} at base, so a signature made elsewhere can't be checked`
891
+ : `the ${sig.kind === "ssh" ? "ssh signature" : "passkey's assertion"} does not verify for ${sealed.resolvedBy} over this approval's statement: ${r.reason}`,
892
+ };
893
+ }
894
+ return { seal: { ...candidate, key: r.key, ...(gateSealVersion(sealed) === 2 ? { version: 2 as const } : {}) } };
895
+ }
896
+
739
897
  /**
740
898
  * What a just-recorded approval did to a gate with an `approval` block
741
899
  * (#2508): the policy's decision and whether it binds, then the quorum count