approval-md 0.3.0 → 0.4.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 (226) hide show
  1. package/README.md +83 -914
  2. package/SPEC.md +98 -13
  3. package/cli.js +66 -7
  4. package/dist/src/adapters/smtp.d.ts +18 -0
  5. package/dist/src/adapters/smtp.js +24 -3
  6. package/dist/src/adapters/smtp.js.map +1 -1
  7. package/dist/src/channels/contract.d.ts +19 -0
  8. package/dist/src/channels/contract.js +105 -1
  9. package/dist/src/channels/contract.js.map +1 -1
  10. package/dist/src/channels/relay-server.d.ts +90 -0
  11. package/dist/src/channels/relay-server.js +295 -0
  12. package/dist/src/channels/relay-server.js.map +1 -0
  13. package/dist/src/channels/relay.d.ts +273 -0
  14. package/dist/src/channels/relay.js +564 -0
  15. package/dist/src/channels/relay.js.map +1 -0
  16. package/dist/src/channels/tagging.js +6 -1
  17. package/dist/src/channels/tagging.js.map +1 -1
  18. package/dist/src/channels/telegram-webhook.d.ts +273 -0
  19. package/dist/src/channels/telegram-webhook.js +536 -0
  20. package/dist/src/channels/telegram-webhook.js.map +1 -0
  21. package/dist/src/channels/telegram.d.ts +271 -1
  22. package/dist/src/channels/telegram.js +403 -45
  23. package/dist/src/channels/telegram.js.map +1 -1
  24. package/dist/src/cli/amend.js +350 -4
  25. package/dist/src/cli/amend.js.map +1 -1
  26. package/dist/src/cli/attest.js +43 -6
  27. package/dist/src/cli/attest.js.map +1 -1
  28. package/dist/src/cli/channel-relay.d.ts +108 -0
  29. package/dist/src/cli/channel-relay.js +334 -0
  30. package/dist/src/cli/channel-relay.js.map +1 -0
  31. package/dist/src/cli/channel-telegram-webhook.d.ts +273 -0
  32. package/dist/src/cli/channel-telegram-webhook.js +709 -0
  33. package/dist/src/cli/channel-telegram-webhook.js.map +1 -0
  34. package/dist/src/cli/channel-telegram.d.ts +272 -26
  35. package/dist/src/cli/channel-telegram.js +478 -41
  36. package/dist/src/cli/channel-telegram.js.map +1 -1
  37. package/dist/src/cli/channel.d.ts +1 -1
  38. package/dist/src/cli/channel.js +5 -1
  39. package/dist/src/cli/channel.js.map +1 -1
  40. package/dist/src/cli/daemon.js +37 -5
  41. package/dist/src/cli/daemon.js.map +1 -1
  42. package/dist/src/cli/doctor.d.ts +63 -0
  43. package/dist/src/cli/doctor.js +856 -111
  44. package/dist/src/cli/doctor.js.map +1 -1
  45. package/dist/src/cli/execute.d.ts +17 -1
  46. package/dist/src/cli/execute.js +341 -20
  47. package/dist/src/cli/execute.js.map +1 -1
  48. package/dist/src/cli/exit-codes.d.ts +12 -0
  49. package/dist/src/cli/exit-codes.js +13 -0
  50. package/dist/src/cli/exit-codes.js.map +1 -1
  51. package/dist/src/cli/gate.d.ts +2 -0
  52. package/dist/src/cli/gate.js +233 -2
  53. package/dist/src/cli/gate.js.map +1 -1
  54. package/dist/src/cli/help.d.ts +9 -1
  55. package/dist/src/cli/help.js +246 -38
  56. package/dist/src/cli/help.js.map +1 -1
  57. package/dist/src/cli/hook.d.ts +371 -3
  58. package/dist/src/cli/hook.js +1926 -44
  59. package/dist/src/cli/hook.js.map +1 -1
  60. package/dist/src/cli/init.js +16 -7
  61. package/dist/src/cli/init.js.map +1 -1
  62. package/dist/src/cli/instructions.js +24 -3
  63. package/dist/src/cli/instructions.js.map +1 -1
  64. package/dist/src/cli/log-anchor.d.ts +55 -0
  65. package/dist/src/cli/log-anchor.js +199 -60
  66. package/dist/src/cli/log-anchor.js.map +1 -1
  67. package/dist/src/cli/main.d.ts +0 -12
  68. package/dist/src/cli/main.js +51 -0
  69. package/dist/src/cli/main.js.map +1 -1
  70. package/dist/src/cli/muse.d.ts +2 -0
  71. package/dist/src/cli/muse.js +62 -0
  72. package/dist/src/cli/muse.js.map +1 -0
  73. package/dist/src/cli/payload.js +79 -1
  74. package/dist/src/cli/payload.js.map +1 -1
  75. package/dist/src/cli/scaffold.js +6 -0
  76. package/dist/src/cli/scaffold.js.map +1 -1
  77. package/dist/src/cli/serve.d.ts +53 -0
  78. package/dist/src/cli/serve.js +270 -0
  79. package/dist/src/cli/serve.js.map +1 -0
  80. package/dist/src/cli/up.js +21 -2
  81. package/dist/src/cli/up.js.map +1 -1
  82. package/dist/src/cli/verb-registry.d.ts +2 -0
  83. package/dist/src/cli/verb-registry.js +337 -39
  84. package/dist/src/cli/verb-registry.js.map +1 -1
  85. package/dist/src/cli/wordmark.d.ts +2 -2
  86. package/dist/src/cli/wordmark.js +2 -2
  87. package/dist/src/core/attest-bootstrap.d.ts +95 -0
  88. package/dist/src/core/attest-bootstrap.js +135 -0
  89. package/dist/src/core/attest-bootstrap.js.map +1 -0
  90. package/dist/src/core/attest.d.ts +20 -3
  91. package/dist/src/core/attest.js +25 -0
  92. package/dist/src/core/attest.js.map +1 -1
  93. package/dist/src/core/audit.d.ts +55 -3
  94. package/dist/src/core/audit.js +52 -5
  95. package/dist/src/core/audit.js.map +1 -1
  96. package/dist/src/core/channel-lease.d.ts +322 -0
  97. package/dist/src/core/channel-lease.js +663 -0
  98. package/dist/src/core/channel-lease.js.map +1 -0
  99. package/dist/src/core/command-class.d.ts +51 -0
  100. package/dist/src/core/command-class.js +760 -8
  101. package/dist/src/core/command-class.js.map +1 -1
  102. package/dist/src/core/daemon-host.d.ts +178 -0
  103. package/dist/src/core/daemon-host.js +228 -0
  104. package/dist/src/core/daemon-host.js.map +1 -0
  105. package/dist/src/core/daemon-identity.d.ts +238 -0
  106. package/dist/src/core/daemon-identity.js +252 -0
  107. package/dist/src/core/daemon-identity.js.map +1 -0
  108. package/dist/src/core/gate.d.ts +306 -5
  109. package/dist/src/core/gate.js +772 -24
  110. package/dist/src/core/gate.js.map +1 -1
  111. package/dist/src/core/harness-version.d.ts +128 -4
  112. package/dist/src/core/harness-version.js +179 -12
  113. package/dist/src/core/harness-version.js.map +1 -1
  114. package/dist/src/core/harness-wait.d.ts +82 -3
  115. package/dist/src/core/harness-wait.js +89 -3
  116. package/dist/src/core/harness-wait.js.map +1 -1
  117. package/dist/src/core/log-subscribe.d.ts +21 -0
  118. package/dist/src/core/log-subscribe.js +16 -6
  119. package/dist/src/core/log-subscribe.js.map +1 -1
  120. package/dist/src/core/log-write-layer.d.ts +55 -0
  121. package/dist/src/core/log-write-layer.js +91 -0
  122. package/dist/src/core/log-write-layer.js.map +1 -0
  123. package/dist/src/core/log.d.ts +50 -21
  124. package/dist/src/core/log.js +197 -19
  125. package/dist/src/core/log.js.map +1 -1
  126. package/dist/src/core/payload-census.d.ts +51 -0
  127. package/dist/src/core/payload-census.js +125 -2
  128. package/dist/src/core/payload-census.js.map +1 -1
  129. package/dist/src/core/payload-store.d.ts +31 -0
  130. package/dist/src/core/payload-store.js +113 -8
  131. package/dist/src/core/payload-store.js.map +1 -1
  132. package/dist/src/core/payload.d.ts +18 -3
  133. package/dist/src/core/payload.js +20 -4
  134. package/dist/src/core/payload.js.map +1 -1
  135. package/dist/src/core/policy-diff.d.ts +10 -0
  136. package/dist/src/core/policy-diff.js +10 -2
  137. package/dist/src/core/policy-diff.js.map +1 -1
  138. package/dist/src/core/policy-explain.d.ts +7 -1
  139. package/dist/src/core/policy-explain.js +16 -1
  140. package/dist/src/core/policy-explain.js.map +1 -1
  141. package/dist/src/core/policy-load.d.ts +24 -0
  142. package/dist/src/core/policy-load.js.map +1 -1
  143. package/dist/src/core/policy-match.d.ts +38 -0
  144. package/dist/src/core/policy-match.js +35 -0
  145. package/dist/src/core/policy-match.js.map +1 -1
  146. package/dist/src/core/policy-proposal.d.ts +23 -0
  147. package/dist/src/core/policy-proposal.js +8 -2
  148. package/dist/src/core/policy-proposal.js.map +1 -1
  149. package/dist/src/core/read-scope.d.ts +10 -0
  150. package/dist/src/core/read-scope.js +4 -0
  151. package/dist/src/core/read-scope.js.map +1 -1
  152. package/dist/src/core/run-payload.d.ts +160 -0
  153. package/dist/src/core/run-payload.js +304 -0
  154. package/dist/src/core/run-payload.js.map +1 -0
  155. package/dist/src/core/sender-identity.d.ts +35 -10
  156. package/dist/src/core/sender-identity.js +48 -11
  157. package/dist/src/core/sender-identity.js.map +1 -1
  158. package/dist/src/core/state.d.ts +52 -1
  159. package/dist/src/core/state.js +52 -6
  160. package/dist/src/core/state.js.map +1 -1
  161. package/dist/src/core/telegram-config.d.ts +79 -0
  162. package/dist/src/core/telegram-config.js +108 -0
  163. package/dist/src/core/telegram-config.js.map +1 -1
  164. package/dist/src/core/verify.d.ts +23 -1
  165. package/dist/src/core/verify.js +20 -2
  166. package/dist/src/core/verify.js.map +1 -1
  167. package/dist/src/daemon/audit.d.ts +80 -5
  168. package/dist/src/daemon/audit.js +126 -6
  169. package/dist/src/daemon/audit.js.map +1 -1
  170. package/dist/src/daemon/daemon.d.ts +174 -2
  171. package/dist/src/daemon/daemon.js +298 -7
  172. package/dist/src/daemon/daemon.js.map +1 -1
  173. package/dist/src/daemon/git-evidence.d.ts +2 -2
  174. package/dist/src/daemon/git-evidence.js +1 -1
  175. package/dist/src/daemon/projection.d.ts +13 -2
  176. package/dist/src/daemon/projection.js +39 -6
  177. package/dist/src/daemon/projection.js.map +1 -1
  178. package/dist/src/mcp/server.d.ts +39 -3
  179. package/dist/src/mcp/server.js +22 -3
  180. package/dist/src/mcp/server.js.map +1 -1
  181. package/dist/src/muse/server.d.ts +16 -0
  182. package/dist/src/muse/server.js +238 -0
  183. package/dist/src/muse/server.js.map +1 -0
  184. package/dist/src/serve/archive.d.ts +158 -0
  185. package/dist/src/serve/archive.js +354 -0
  186. package/dist/src/serve/archive.js.map +1 -0
  187. package/dist/src/serve/arguments.d.ts +93 -0
  188. package/dist/src/serve/arguments.js +228 -0
  189. package/dist/src/serve/arguments.js.map +1 -0
  190. package/dist/src/serve/credentials.d.ts +91 -0
  191. package/dist/src/serve/credentials.js +143 -0
  192. package/dist/src/serve/credentials.js.map +1 -0
  193. package/dist/src/serve/follow.d.ts +86 -0
  194. package/dist/src/serve/follow.js +101 -0
  195. package/dist/src/serve/follow.js.map +1 -0
  196. package/dist/src/serve/hook-thread.d.ts +134 -0
  197. package/dist/src/serve/hook-thread.js +333 -0
  198. package/dist/src/serve/hook-thread.js.map +1 -0
  199. package/dist/src/serve/hook-worker.d.ts +134 -0
  200. package/dist/src/serve/hook-worker.js +173 -0
  201. package/dist/src/serve/hook-worker.js.map +1 -0
  202. package/dist/src/serve/server.d.ts +412 -0
  203. package/dist/src/serve/server.js +1251 -0
  204. package/dist/src/serve/server.js.map +1 -0
  205. package/docs/README-extended.md +766 -0
  206. package/docs/cli-reference.md +1633 -43
  207. package/package.json +4 -2
  208. package/schema/event.schema.json +59 -2
  209. package/schema/fixtures/event/invalid/daemon-id-malformed.json +15 -0
  210. package/schema/fixtures/event/invalid/execution-started-truncated-policy-sha256.json +18 -0
  211. package/schema/fixtures/event/invalid/harness-cap-at-margin.json +16 -0
  212. package/schema/fixtures/event/invalid/harness-cap-fractional.json +16 -0
  213. package/schema/fixtures/event/invalid/harness-cap-negative.json +16 -0
  214. package/schema/fixtures/event/invalid/harness-cap-string.json +16 -0
  215. package/schema/fixtures/event/invalid/harness-cap-without-harness-execution.json +16 -0
  216. package/schema/fixtures/event/invalid/harness-cap-zero.json +16 -0
  217. package/schema/fixtures/event/valid/approval-requested-harness-cap.json +18 -0
  218. package/schema/fixtures/event/valid/daemon-identity-declared.json +17 -0
  219. package/schema/fixtures/event/valid/daemon-identity.json +15 -0
  220. package/schema/fixtures/event/valid/execution-started-policy-sha256.json +18 -0
  221. package/schema/fixtures/event/valid/harness-kind-hermes.json +23 -0
  222. package/schema/fixtures/policy/invalid/daemons-malformed-id.json +10 -0
  223. package/schema/fixtures/policy/valid/daemons-allowlist.json +19 -0
  224. package/schema/fixtures/policy-md/invalid/schema-invalid-agent-may-request.md +21 -0
  225. package/schema/fixtures/policy-md/valid/agent-may-request.md +24 -0
  226. package/schema/policy.schema.json +50 -6
@@ -0,0 +1,91 @@
1
+ /**
2
+ * The filesystem calls that put durable bytes on disk: `core/log.ts`'s append
3
+ * (APRV-440) and `core/payload-store.ts`'s atomic write (APRV-457). They are
4
+ * kept in their own module so that `core/log.ts`'s public surface stays what
5
+ * `tests/log.test.ts` pins: no mutation, no reorder, no truncate, and no way to
6
+ * change how its bytes reach the disk.
7
+ *
8
+ * Why a seam at all. The durability claim is "fsync after the write and before
9
+ * ok", and a page cache that was flushed reads back exactly like one that was
10
+ * not until the machine dies. Only a layer that records the ORDER of the calls
11
+ * can prove the claim, so `tests/log-fsync.test.ts` and
12
+ * `tests/payload-fsync.test.ts` install one that records every call and then
13
+ * delegates to the real one, which keeps each log they build a real log built
14
+ * through the real append path.
15
+ *
16
+ * One seam for both writers, deliberately. A log record is only as durable as
17
+ * the payload it binds: a record that survives a crash while its payload comes
18
+ * back NUL-filled verifies and points at nothing (APRV-457). Proving the two
19
+ * through one layer keeps one model of "what reached the disk" for both.
20
+ *
21
+ * Nothing in `src/` calls {@link setAppendWriteLayerForTests}. It changes how
22
+ * the bytes reach the disk and nothing about which bytes, so every check before
23
+ * the write (lock, tail, compare-and-append, schema, payload hashing) runs as in
24
+ * production.
25
+ */
26
+ import { closeSync, constants as fsConstants, fsyncSync, openSync, renameSync, writeSync } from "node:fs";
27
+ /** Node's own `fs`, which is the only layer production ever runs. */
28
+ const NODE_WRITE_LAYER = {
29
+ open: (path, flags, mode) => openSync(path, flags, mode),
30
+ write: (fd, data) => writeSync(fd, data, 0, data.length),
31
+ fsync: (fd) => {
32
+ fsyncSync(fd);
33
+ },
34
+ close: (fd) => {
35
+ closeSync(fd);
36
+ },
37
+ rename: (from, to) => {
38
+ renameSync(from, to);
39
+ },
40
+ };
41
+ let current = NODE_WRITE_LAYER;
42
+ /** The layer the next append (or payload store write) uses. */
43
+ export function appendWriteLayer() {
44
+ return current;
45
+ }
46
+ /**
47
+ * Replace the append's write layer, or restore Node's with `null`. For tests
48
+ * and the opt-in benchmarks only.
49
+ */
50
+ export function setAppendWriteLayerForTests(layer) {
51
+ current = layer ?? NODE_WRITE_LAYER;
52
+ }
53
+ /**
54
+ * The errors a directory fsync returns on a filesystem that cannot sync a
55
+ * directory at all (some FUSE, SMB and drvfs mounts). The same set `core/log.ts`
56
+ * tolerates for its first append (APRV-440); log.ts keeps its own copy so its
57
+ * append path stays exactly what APRV-440 shipped. EIO and everything else
58
+ * still fail.
59
+ */
60
+ const DIRECTORY_FSYNC_UNSUPPORTED = new Set(["EINVAL", "EBADF", "ENOTSUP", "EOPNOTSUPP"]);
61
+ /**
62
+ * fsync a directory through the current layer, so a name created or renamed
63
+ * into it survives a crash. Skipped on Windows (a directory cannot be opened
64
+ * for this there, and its filesystems journal names themselves) and tolerated
65
+ * where the filesystem reports directory fsync as unsupported; every other
66
+ * failure throws for the caller to report. The read-only handle is closed even
67
+ * when the fsync throws.
68
+ */
69
+ export function fsyncDirectory(dir) {
70
+ if (process.platform === "win32")
71
+ return;
72
+ const writeLayer = current;
73
+ const fd = writeLayer.open(dir, fsConstants.O_RDONLY, 0);
74
+ try {
75
+ writeLayer.fsync(fd);
76
+ }
77
+ catch (cause) {
78
+ if (!DIRECTORY_FSYNC_UNSUPPORTED.has(cause.code ?? ""))
79
+ throw cause;
80
+ }
81
+ finally {
82
+ try {
83
+ writeLayer.close(fd);
84
+ }
85
+ catch {
86
+ // The fsync above is what mattered; a failed close of a read-only
87
+ // directory handle changes nothing on disk.
88
+ }
89
+ }
90
+ }
91
+ //# sourceMappingURL=log-write-layer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log-write-layer.js","sourceRoot":"","sources":["../../../src/core/log-write-layer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,SAAS,EAAE,SAAS,IAAI,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAiB1G,qEAAqE;AACrE,MAAM,gBAAgB,GAAqB;IACzC,IAAI,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,KAA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,IAAI,EAAE,CAAC;YAAE,MAAM,KAAK,CAAC;IACjG,CAAC;YAAS,CAAC;QACT,IAAI,CAAC;YACH,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACvB,CAAC;QAAC,MAAM,CAAC;YACP,kEAAkE;YAClE,4CAA4C;QAC9C,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -42,10 +42,31 @@
42
42
  * canonicalization minus the `hash` field. One scheme, two inputs — a
43
43
  * verifier strips `hash` and re-derives. Appended with a single `write(2)`
44
44
  * on a handle opened `O_APPEND`.
45
+ * 5b. **Durable before ok (APRV-440).** The write is followed by `fsync(2)` on
46
+ * the same descriptor, and only then does the append report ok. When this
47
+ * append created the file, the log directory is fsynced too (and the parent
48
+ * of every directory this call created), so the new name survives along with
49
+ * its bytes. Without this, an acknowledged record lived in the page cache
50
+ * only: a platform kill before writeback left the file extended over blocks
51
+ * that were never written, which reads back as a NUL-filled unterminated tail
52
+ * (observed on a hosted tenant on 2026-09-25: an acknowledged attestation
53
+ * lost, 456 NUL bytes in its place). Atomicity against concurrent writers
54
+ * was guarantee 5 all along; durability against the machine dying is this one.
55
+ *
56
+ * 6. **The writing daemon names itself, or is refused (APRV-383).** A record
57
+ * appended by a declaring daemon process carries `daemon`, the id of the
58
+ * instance that wrote it, so a tenant reading a log hosted by somebody else can
59
+ * tell which daemon acted on their behalf. The id comes from this process's own
60
+ * state (`core/daemon-identity.ts`) and never from the caller, and where the
61
+ * attested policy lists the ids that may write, an unlisted one is refused here
62
+ * with nothing written. Every earlier record, carrying no such field, validates
63
+ * and verifies unchanged.
45
64
  *
46
65
  * Determinism: `ts` is supplied by the caller. This module never reads the
47
66
  * clock, because a hash-relevant field sourced from ambient state would make
48
- * the log irreproducible.
67
+ * the log irreproducible. `daemon` is ambient in the same sense and is not a
68
+ * counter-example: a log is reproducible per WRITER, the field says which writer,
69
+ * and a verifier re-derives the hash from the record's own bytes either way.
49
70
  */
50
71
  import { type ValidateOptions, type ValidationError } from "./validate.js";
51
72
  /** SPEC.md §8: the hash scheme identifier stamped on every v0.1 record. */
@@ -159,7 +180,15 @@ export declare const GENESIS_PREV: null;
159
180
  * backdate a sign-off could place it before bytes they never saw.
160
181
  */
161
182
  export type EventType = "task.registered" | "route.proposed" | "route.accepted" | "approval.requested" | "approval.granted" | "approval.rejected" | "approval.expired" | "approval.revoked" | "approval.withdrawn" | "execution.started" | "execution.completed" | "execution.failed" | "execution.indeterminate" | "execution.reconciled" | "budget.exceeded" | "policy.updated" | "policy.proposed" | "policy.declined" | "envelope.drift" | "audit.sampled" | "audit.reviewed" | "audit.dark_session" | "audit.decision_refused" | "audit.gesture_refused" | "audit.question_preempted" | "reconciliation.required" | "reconciliation.satisfied" | "payload.pruned" | "gate.opened" | "gate.closed" | "gate.bypassed" | "gate.organ.attested" | "gate.path.signed_off" | "log.checkpoint";
162
- /** Caller-supplied content of an event. Chain fields are not accepted. */
183
+ /**
184
+ * Caller-supplied content of an event. Chain fields are not accepted.
185
+ *
186
+ * Nor is `daemon` (APRV-383): which daemon wrote a record is a fact about the
187
+ * writing PROCESS, and a member here would be a field any caller could set. It is
188
+ * stamped by {@link buildRecord} from `core/daemon-identity.ts`'s process state,
189
+ * and a caller that puts the property on its input object anyway is ignored,
190
+ * because a record is composed field by field rather than spread.
191
+ */
163
192
  export interface EventInput {
164
193
  /** RFC 3339 timestamp. Supplied by the caller; never read from the clock. */
165
194
  ts: string;
@@ -177,6 +206,19 @@ export interface EventRecord extends EventInput {
177
206
  alg: typeof ALG;
178
207
  hash: string;
179
208
  prev: string | null;
209
+ /**
210
+ * WHICH daemon instance appended this record (APRV-383), present exactly on the
211
+ * records a declaring daemon process wrote.
212
+ *
213
+ * OPTIONAL and additive: every record written before the field existed
214
+ * validates and verifies unchanged, and its absence means what it has always
215
+ * meant — nothing about this record says a daemon wrote it. It is a top-level
216
+ * field, so the record's own chain hash covers it the way it covers `actor`; it
217
+ * never reaches a payload hash or a token, and nothing in the runtime reads it
218
+ * as an input to a verdict (SPEC.md §11.1 invariant 4, and
219
+ * `core/daemon-identity.ts` for the whole of that argument).
220
+ */
221
+ daemon?: string;
180
222
  }
181
223
  /** The hash input: a record with every field except `hash`. */
182
224
  export type UnhashedRecord = Omit<EventRecord, "hash">;
@@ -188,24 +230,7 @@ export type UnhashedRecord = Omit<EventRecord, "hash">;
188
230
  * breaking change. `head-moved` is the APRV-20 addition (finding B1), sanctioned
189
231
  * by the human decision of 2026-08-07.
190
232
  */
191
- export declare const APPEND_ERROR_CODES: readonly [
192
- /** The lockfile was held by another writer for longer than the timeout. */
193
- "lock-timeout",
194
- /** The file's last line is truncated or unparseable; nothing may chain onto it. */
195
- "corrupt-tail",
196
- /** The complete record failed the `event` schema at the write boundary. */
197
- "validation",
198
- /** The record could not be canonicalized (RFC 8785). */
199
- "canonicalization",
200
- /** The log could not be created, opened, or written. */
201
- "io",
202
- /**
203
- * The caller supplied {@link AppendOptions.expectedHead} and the log's actual
204
- * tail, read under the lock, is a different `(seq, hash)`. Someone appended
205
- * between the caller's read and this append, so every read-dependent check the
206
- * caller made is stale. Nothing was written.
207
- */
208
- "head-moved"];
233
+ export declare const APPEND_ERROR_CODES: readonly ["lock-timeout", "corrupt-tail", "validation", "canonicalization", "io", "head-moved", "daemon-id-invalid", "daemon-not-allowed"];
209
234
  export type AppendErrorCode = (typeof APPEND_ERROR_CODES)[number];
210
235
  export interface AppendError {
211
236
  code: AppendErrorCode;
@@ -311,6 +336,10 @@ export declare function serializeRecord(record: EventRecord): string;
311
336
  * guarantee that nobody else is appending while it works.
312
337
  */
313
338
  export declare function withAppendLock<T>(logPath: string, run: () => T, options?: LockOptions): LockedResult<T>;
314
- /** Subscribe to successful appends. Process-wide, memory-only, additive. */
339
+ /**
340
+ * Subscribe to appends that put bytes in the file: every successful one, and
341
+ * since APRV-440 one that wrote and then failed to confirm them durable (a
342
+ * short write, a failed fsync). Process-wide, memory-only, additive.
343
+ */
315
344
  export declare function onLogAppended(listener: (logPath: string) => void): void;
316
345
  export declare function appendEvent(logPath: string, input: EventInput, options?: AppendOptions): AppendResult;
@@ -42,15 +42,38 @@
42
42
  * canonicalization minus the `hash` field. One scheme, two inputs — a
43
43
  * verifier strips `hash` and re-derives. Appended with a single `write(2)`
44
44
  * on a handle opened `O_APPEND`.
45
+ * 5b. **Durable before ok (APRV-440).** The write is followed by `fsync(2)` on
46
+ * the same descriptor, and only then does the append report ok. When this
47
+ * append created the file, the log directory is fsynced too (and the parent
48
+ * of every directory this call created), so the new name survives along with
49
+ * its bytes. Without this, an acknowledged record lived in the page cache
50
+ * only: a platform kill before writeback left the file extended over blocks
51
+ * that were never written, which reads back as a NUL-filled unterminated tail
52
+ * (observed on a hosted tenant on 2026-09-25: an acknowledged attestation
53
+ * lost, 456 NUL bytes in its place). Atomicity against concurrent writers
54
+ * was guarantee 5 all along; durability against the machine dying is this one.
55
+ *
56
+ * 6. **The writing daemon names itself, or is refused (APRV-383).** A record
57
+ * appended by a declaring daemon process carries `daemon`, the id of the
58
+ * instance that wrote it, so a tenant reading a log hosted by somebody else can
59
+ * tell which daemon acted on their behalf. The id comes from this process's own
60
+ * state (`core/daemon-identity.ts`) and never from the caller, and where the
61
+ * attested policy lists the ids that may write, an unlisted one is refused here
62
+ * with nothing written. Every earlier record, carrying no such field, validates
63
+ * and verifies unchanged.
45
64
  *
46
65
  * Determinism: `ts` is supplied by the caller. This module never reads the
47
66
  * clock, because a hash-relevant field sourced from ambient state would make
48
- * the log irreproducible.
67
+ * the log irreproducible. `daemon` is ambient in the same sense and is not a
68
+ * counter-example: a log is reproducible per WRITER, the field says which writer,
69
+ * and a verifier re-derives the hash from the record's own bytes either way.
49
70
  */
50
71
  import { createHash } from "node:crypto";
51
- import { closeSync, fstatSync, mkdirSync, openSync, readSync, unlinkSync, writeSync, } from "node:fs";
72
+ import { closeSync, constants as fsConstants, fstatSync, mkdirSync, openSync, readSync, unlinkSync, } from "node:fs";
52
73
  import { dirname } from "node:path";
74
+ import { DAEMON_APPEND_REFUSAL_CODES, daemonStampForAppend, } from "./daemon-identity.js";
53
75
  import { canonicalize, JcsError } from "./jcs.js";
76
+ import { appendWriteLayer } from "./log-write-layer.js";
54
77
  import { validate } from "./validate.js";
55
78
  /** SPEC.md §8: the hash scheme identifier stamped on every v0.1 record. */
56
79
  export const ALG = "sha256/jcs";
@@ -85,6 +108,15 @@ export const APPEND_ERROR_CODES = [
85
108
  * caller made is stale. Nothing was written.
86
109
  */
87
110
  "head-moved",
111
+ /**
112
+ * The two identity refusals of APRV-383, spread in from
113
+ * `core/daemon-identity.ts` where the logic that emits them lives: a daemon that
114
+ * declared an unusable id, and a daemon whose id the attested policy's `daemons`
115
+ * list does not admit. Both leave the file byte-identical, like every member
116
+ * above them, and both are additions to the closed union rather than renames of
117
+ * anything in it.
118
+ */
119
+ ...DAEMON_APPEND_REFUSAL_CODES,
88
120
  ];
89
121
  const DEFAULT_LOCK_TIMEOUT_MS = 2_000;
90
122
  const DEFAULT_LOCK_RETRY_MS = 20;
@@ -138,6 +170,82 @@ function sleepSync(ms) {
138
170
  const buffer = new Int32Array(new SharedArrayBuffer(4));
139
171
  Atomics.wait(buffer, 0, 0, ms);
140
172
  }
173
+ /** `O_APPEND` writer flags; `O_EXCL` added for the first try, so creation is known. */
174
+ const APPEND_FLAGS = fsConstants.O_WRONLY | fsConstants.O_APPEND | fsConstants.O_CREAT;
175
+ /** The mode Node's `"a"` opens with; the umask applies as it always did. */
176
+ const APPEND_MODE = 0o666;
177
+ /**
178
+ * Open `logPath` for append and say whether this call created it. `O_EXCL`
179
+ * first: under the append lock no other sanctioned writer can race the create, so
180
+ * `EEXIST` means the file was already there and a plain append open follows.
181
+ */
182
+ function openForAppend(logPath) {
183
+ const writeLayer = appendWriteLayer();
184
+ try {
185
+ return { fd: writeLayer.open(logPath, APPEND_FLAGS | fsConstants.O_EXCL, APPEND_MODE), created: true };
186
+ }
187
+ catch (cause) {
188
+ if (cause.code !== "EEXIST")
189
+ throw cause;
190
+ }
191
+ return { fd: writeLayer.open(logPath, APPEND_FLAGS, APPEND_MODE), created: false };
192
+ }
193
+ /**
194
+ * The errors a directory fsync returns on a filesystem that cannot sync a
195
+ * directory at all (some FUSE, SMB and drvfs mounts). PostgreSQL ignores the
196
+ * same set for the same reason: there, every first append would otherwise
197
+ * report io with record 1 already in the file, inviting a re-run and a
198
+ * duplicate. EIO and everything else still fail the append.
199
+ */
200
+ const DIRECTORY_FSYNC_UNSUPPORTED = new Set(["EINVAL", "EBADF", "ENOTSUP", "EOPNOTSUPP"]);
201
+ /**
202
+ * fsync a directory, so a name created in it survives a crash. Windows cannot
203
+ * open a directory for this and its filesystems journal names themselves, so it
204
+ * is skipped there, as is a filesystem that reports directory fsync as
205
+ * unsupported; everywhere else a failure is the caller's to report.
206
+ */
207
+ function fsyncDirectory(dir) {
208
+ if (process.platform === "win32")
209
+ return;
210
+ const writeLayer = appendWriteLayer();
211
+ const fd = writeLayer.open(dir, fsConstants.O_RDONLY, 0);
212
+ try {
213
+ writeLayer.fsync(fd);
214
+ }
215
+ catch (cause) {
216
+ if (!DIRECTORY_FSYNC_UNSUPPORTED.has(cause.code ?? ""))
217
+ throw cause;
218
+ }
219
+ finally {
220
+ try {
221
+ writeLayer.close(fd);
222
+ }
223
+ catch {
224
+ // The fsync above is what mattered; a failed close of a read-only
225
+ // directory handle changes nothing on disk.
226
+ }
227
+ }
228
+ }
229
+ /**
230
+ * The directories whose entries a first append made new: the log's own
231
+ * directory (which gained the file), and, when `withAppendLock` had to create
232
+ * directories, the parent of each one it created, up to and including the
233
+ * parent of the topmost. Ordered innermost first.
234
+ */
235
+ function directoriesToSync(logPath, firstCreatedDir) {
236
+ const dirs = [dirname(logPath)];
237
+ if (firstCreatedDir === undefined)
238
+ return dirs;
239
+ const stop = dirname(firstCreatedDir);
240
+ for (let dir = dirs[0]; dir !== stop;) {
241
+ const parent = dirname(dir);
242
+ if (parent === dir)
243
+ break; // the filesystem root: nothing above to sync
244
+ dirs.push(parent);
245
+ dir = parent;
246
+ }
247
+ return dirs;
248
+ }
141
249
  /**
142
250
  * Acquire `<logPath>.lock` by `open(…, "wx")` — atomic create-or-fail, which
143
251
  * needs no dependency and works on every platform Node supports. Retries with
@@ -385,8 +493,13 @@ function headPrecondition(logPath, expected, tail) {
385
493
  * Build a complete record from caller content plus chain state. Property
386
494
  * insertion order is irrelevant to the digest (JCS sorts keys) but is kept
387
495
  * readable here for anyone eyeballing the code.
496
+ *
497
+ * `daemon` comes from the writing process and never from `input`, which is why it
498
+ * is a parameter here rather than a member of {@link EventInput}: this function
499
+ * composes a record field by field, so there is no spelling of a caller's input
500
+ * that can put a `daemon` on a record.
388
501
  */
389
- function buildRecord(input, seq, prev) {
502
+ function buildRecord(input, seq, prev, daemon) {
390
503
  const record = {
391
504
  seq,
392
505
  ts: input.ts,
@@ -396,6 +509,10 @@ function buildRecord(input, seq, prev) {
396
509
  prev,
397
510
  hash: "",
398
511
  };
512
+ // Beside `actor`, because it answers the same question about a different layer:
513
+ // who caused the event, and which process wrote it down.
514
+ if (daemon !== null)
515
+ record.daemon = daemon;
399
516
  if (input.task !== undefined)
400
517
  record.task = input.task;
401
518
  if (input.action_key !== undefined)
@@ -434,8 +551,17 @@ function buildRecord(input, seq, prev) {
434
551
  * guarantee that nobody else is appending while it works.
435
552
  */
436
553
  export function withAppendLock(logPath, run, options = {}) {
554
+ return lockedRun(logPath, () => run(), options);
555
+ }
556
+ /**
557
+ * {@link withAppendLock}, also telling `run` the first directory its `mkdir`
558
+ * created (`undefined` when the log's directory already existed), which the
559
+ * append needs to know which directory entries are new (APRV-440).
560
+ */
561
+ function lockedRun(logPath, run, options) {
562
+ let firstCreatedDir;
437
563
  try {
438
- mkdirSync(dirname(logPath), { recursive: true });
564
+ firstCreatedDir = mkdirSync(dirname(logPath), { recursive: true });
439
565
  }
440
566
  catch (cause) {
441
567
  return {
@@ -450,7 +576,7 @@ export function withAppendLock(logPath, run, options = {}) {
450
576
  if (!lock.ok)
451
577
  return { ok: false, error: lock.error };
452
578
  try {
453
- return { ok: true, value: run() };
579
+ return { ok: true, value: run(firstCreatedDir) };
454
580
  }
455
581
  finally {
456
582
  releaseLock(lock.path);
@@ -467,7 +593,11 @@ export function withAppendLock(logPath, run, options = {}) {
467
593
  * not turn a written record into a failed one, so throws are swallowed.
468
594
  */
469
595
  const appendListeners = [];
470
- /** Subscribe to successful appends. Process-wide, memory-only, additive. */
596
+ /**
597
+ * Subscribe to appends that put bytes in the file: every successful one, and
598
+ * since APRV-440 one that wrote and then failed to confirm them durable (a
599
+ * short write, a failed fsync). Process-wide, memory-only, additive.
600
+ */
471
601
  export function onLogAppended(listener) {
472
602
  appendListeners.push(listener);
473
603
  }
@@ -482,7 +612,22 @@ function noteAppend(logPath) {
482
612
  }
483
613
  }
484
614
  export function appendEvent(logPath, input, options = {}) {
485
- const held = withAppendLock(logPath, () => {
615
+ // Which daemon is writing, and whether it may (APRV-383). Asked of this
616
+ // process's own state rather than of the caller, and asked BEFORE the lock
617
+ // because it reads no log state: taking a lock only to refuse would make every
618
+ // other writer wait for an answer that was never going to touch the file. It is
619
+ // the write boundary in the sense that matters — one code path, nothing written
620
+ // on the refused branch, and the record's own schema pins the field's shape so a
621
+ // malformed id could not land even if this check were absent.
622
+ const stamp = daemonStampForAppend();
623
+ if (stamp.kind === "refuse")
624
+ return fail(stamp.code, stamp.message);
625
+ const daemon = stamp.kind === "stamp" ? stamp.id : null;
626
+ // Set once bytes may reach the file, success or not: the read cache
627
+ // must re-prove a log whose bytes changed even when the append then failed to
628
+ // confirm them durable.
629
+ let wrote = false;
630
+ const held = lockedRun(logPath, (firstCreatedDir) => {
486
631
  const tail = readTail(logPath);
487
632
  if (!tail.ok)
488
633
  return { ok: false, error: tail.error };
@@ -497,7 +642,7 @@ export function appendEvent(logPath, input, options = {}) {
497
642
  let record;
498
643
  let line;
499
644
  try {
500
- record = buildRecord(input, tail.tail.seq + 1, tail.tail.hash);
645
+ record = buildRecord(input, tail.tail.seq + 1, tail.tail.hash, daemon);
501
646
  // Stored line = JCS of the complete record; digest input excluded `hash`.
502
647
  line = serializeRecord(record);
503
648
  }
@@ -512,34 +657,67 @@ export function appendEvent(logPath, input, options = {}) {
512
657
  if (!validation.ok) {
513
658
  return fail("validation", `event failed schema validation at the write boundary; log left unchanged`, validation.errors);
514
659
  }
515
- let fd;
660
+ let opened;
516
661
  try {
517
- fd = openSync(logPath, "a");
662
+ opened = openForAppend(logPath);
518
663
  }
519
664
  catch (cause) {
520
665
  return fail("io", `log ${logPath} could not be opened for append: ${errorMessage(cause)}`);
521
666
  }
667
+ const { fd, created } = opened;
668
+ const writeLayer = appendWriteLayer();
669
+ const bytes = Buffer.from(`${line}\n`, "utf8");
522
670
  try {
523
671
  // Single write syscall on an O_APPEND handle: the line lands whole or not at all.
524
- writeSync(fd, `${line}\n`);
525
- }
526
- catch (cause) {
527
- return fail("io", `log ${logPath} could not be written: ${errorMessage(cause)}`);
672
+ // Set BEFORE the write: one that throws may still have put bytes in the
673
+ // file, and a needless re-proof by the read cache costs only time.
674
+ wrote = true;
675
+ let written;
676
+ try {
677
+ written = writeLayer.write(fd, bytes);
678
+ }
679
+ catch (cause) {
680
+ return fail("io", `log ${logPath} could not be written: ${errorMessage(cause)}`);
681
+ }
682
+ if (written !== bytes.length) {
683
+ return fail("io", `log ${logPath} took ${String(written)} of ${String(bytes.length)} bytes of seq ${String(record.seq)}: the write was short, so the file now ends with a torn line and the record was not appended`);
684
+ }
685
+ // Durable before ok (guarantee 5b). Until this returns, the record exists
686
+ // in the page cache only, and a kill before writeback leaves the file
687
+ // extended over unwritten blocks: a NUL-filled tail where the record was.
688
+ try {
689
+ writeLayer.fsync(fd);
690
+ }
691
+ catch (cause) {
692
+ return fail("io", `log ${logPath}: seq ${String(record.seq)} was written but fsync failed (${errorMessage(cause)}), so it is not known to be durable: it may be in the file now and gone after a crash. Re-read the log before deciding anything from it.`);
693
+ }
528
694
  }
529
695
  finally {
530
696
  try {
531
- closeSync(fd);
697
+ writeLayer.close(fd);
532
698
  }
533
699
  catch {
534
- // Nothing actionable; the data is already handed to the kernel.
700
+ // Nothing actionable: the bytes are written and, on the ok path, synced.
701
+ }
702
+ }
703
+ // A new file is a new directory entry, and fsync of the file does not make
704
+ // its NAME durable: without this a crash can keep the bytes and lose the file.
705
+ if (created) {
706
+ for (const dir of directoriesToSync(logPath, firstCreatedDir)) {
707
+ try {
708
+ fsyncDirectory(dir);
709
+ }
710
+ catch (cause) {
711
+ return fail("io", `log ${logPath}: seq ${String(record.seq)} was written and synced but its directory ${dir} could not be (${errorMessage(cause)}), so the newly created file is not known to survive a crash. Re-read the log before deciding anything from it.`);
712
+ }
535
713
  }
536
714
  }
537
715
  return { ok: true, record, line };
538
716
  }, options);
539
717
  const result = held.ok ? held.value : { ok: false, error: held.error };
540
- // After the lock is released and only for a record that actually landed: the
541
- // reader cache must not serve a prefix proof anchored before this write.
542
- if (result.ok)
718
+ // After the lock is released, for every append that put bytes in the file:
719
+ // the reader cache must not serve a prefix proof anchored before this write.
720
+ if (wrote)
543
721
  noteAppend(logPath);
544
722
  return result;
545
723
  }
@@ -1 +1 @@
1
- {"version":3,"file":"log.js","sourceRoot":"","sources":["../../../src/core/log.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACL,SAAS,EACT,SAAS,EACT,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,SAAS,GACV,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,QAAQ,EAA8C,MAAM,eAAe,CAAC;AAErF,2EAA2E;AAC3E,MAAM,CAAC,MAAM,GAAG,GAAG,YAAY,CAAC;AAEhC;;;GAGG;AACH,MAAM,CAA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AAE,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC;IACrF,2EAA2E;IAC3E,6EAA6E;IAC7E,IAAI,KAAK;QAAE,UAAU,CAAC,OAAO,CAAC,CAAC;IAC/B,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -72,3 +72,54 @@ export interface PayloadStoreCensus {
72
72
  * them is a health verdict; a reader is being told what is there.
73
73
  */
74
74
  export declare function payloadStoreCensus(records: EventRecord[], storeDir: string): PayloadStoreCensus;
75
+ /**
76
+ * One bound payload the store does not hold intact.
77
+ *
78
+ * - `torn`: the file is there and is empty or every byte is NUL. That is what a
79
+ * crash before writeback leaves (the name reached the disk, the data did
80
+ * not), and it is the only reading this module gives the crash signature. No
81
+ * valid payload can look like it: an RFC 8785 serialization is never empty
82
+ * and never carries a raw NUL byte.
83
+ * - `lost`: the file is absent although a record proves the store held it when
84
+ * the record was appended (see {@link heldAtAppend}). That is the other half of
85
+ * the same crash: the name never reached the disk.
86
+ * - `mismatch`: the file holds at least one non-NUL byte and does not verify
87
+ * against its name. Not the crash signature, by construction: a crash does not
88
+ * write bytes nobody wrote. Read as tampering or corruption.
89
+ * - `unreadable`: the file exists and could not be read (a permission, an I/O
90
+ * error); nothing about its bytes is known.
91
+ */
92
+ export type PayloadDamage = {
93
+ kind: "torn";
94
+ hash: string;
95
+ seq: number;
96
+ bytes: number;
97
+ path: string;
98
+ } | {
99
+ kind: "lost";
100
+ hash: string;
101
+ seq: number;
102
+ event: string;
103
+ path: string;
104
+ } | {
105
+ kind: "mismatch";
106
+ hash: string;
107
+ seq: number;
108
+ detail: string;
109
+ path: string;
110
+ } | {
111
+ kind: "unreadable";
112
+ hash: string;
113
+ seq: number;
114
+ detail: string;
115
+ path: string;
116
+ };
117
+ /**
118
+ * Every payload a verified record binds that the store does not hold intact,
119
+ * in log order. Reads files; writes, moves and deletes nothing.
120
+ *
121
+ * `records` must be the verified chain (doctor passes the records of its one
122
+ * verified walk). A hash a `payload.pruned` record names is skipped whatever
123
+ * its file holds: retention removed it on purpose and the log says so.
124
+ */
125
+ export declare function payloadIntegrity(records: EventRecord[], storeDir: string): PayloadDamage[];