@dzhechkov/harness-core 0.4.5 → 0.5.1

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 (141) hide show
  1. package/.dz-manifest.json +489 -105
  2. package/README.md +116 -5
  3. package/dist/agents-policy.d.ts +67 -0
  4. package/dist/agents-policy.d.ts.map +1 -0
  5. package/dist/agents-policy.js +258 -0
  6. package/dist/agents-policy.js.map +1 -0
  7. package/dist/codex-hooks-assets.d.ts +47 -0
  8. package/dist/codex-hooks-assets.d.ts.map +1 -0
  9. package/dist/codex-hooks-assets.js +324 -0
  10. package/dist/codex-hooks-assets.js.map +1 -0
  11. package/dist/codex-hooks-verify.d.ts +95 -0
  12. package/dist/codex-hooks-verify.d.ts.map +1 -0
  13. package/dist/codex-hooks-verify.js +169 -0
  14. package/dist/codex-hooks-verify.js.map +1 -0
  15. package/dist/codex-hooks.d.ts +341 -0
  16. package/dist/codex-hooks.d.ts.map +1 -0
  17. package/dist/codex-hooks.js +541 -0
  18. package/dist/codex-hooks.js.map +1 -0
  19. package/dist/discrimination-gate.d.ts +88 -15
  20. package/dist/discrimination-gate.d.ts.map +1 -1
  21. package/dist/discrimination-gate.js +343 -51
  22. package/dist/discrimination-gate.js.map +1 -1
  23. package/dist/feature-adr-checkpoints.d.ts +22 -0
  24. package/dist/feature-adr-checkpoints.d.ts.map +1 -1
  25. package/dist/feature-adr-checkpoints.js +42 -0
  26. package/dist/feature-adr-checkpoints.js.map +1 -1
  27. package/dist/feature-adr-routing.d.ts +218 -5
  28. package/dist/feature-adr-routing.d.ts.map +1 -1
  29. package/dist/feature-adr-routing.js +583 -54
  30. package/dist/feature-adr-routing.js.map +1 -1
  31. package/dist/guard.d.ts +13 -0
  32. package/dist/guard.d.ts.map +1 -1
  33. package/dist/guard.js +25 -1
  34. package/dist/guard.js.map +1 -1
  35. package/dist/index.d.ts +23 -7
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.js +37 -4
  38. package/dist/index.js.map +1 -1
  39. package/dist/loop-blobs.generated.d.ts +1 -1
  40. package/dist/loop-blobs.generated.d.ts.map +1 -1
  41. package/dist/loop-blobs.generated.js +12 -3
  42. package/dist/loop-blobs.generated.js.map +1 -1
  43. package/dist/loop-plan.d.ts +70 -0
  44. package/dist/loop-plan.d.ts.map +1 -1
  45. package/dist/loop-plan.js +103 -0
  46. package/dist/loop-plan.js.map +1 -1
  47. package/dist/loop-render.d.ts.map +1 -1
  48. package/dist/loop-render.js +37 -129
  49. package/dist/loop-render.js.map +1 -1
  50. package/dist/loop-run-semantics.d.ts +130 -0
  51. package/dist/loop-run-semantics.d.ts.map +1 -0
  52. package/dist/loop-run-semantics.js +257 -0
  53. package/dist/loop-run-semantics.js.map +1 -0
  54. package/dist/loop-trace.d.ts +31 -2
  55. package/dist/loop-trace.d.ts.map +1 -1
  56. package/dist/loop-trace.js +89 -12
  57. package/dist/loop-trace.js.map +1 -1
  58. package/dist/managed-hooks.d.ts +86 -0
  59. package/dist/managed-hooks.d.ts.map +1 -0
  60. package/dist/managed-hooks.js +101 -0
  61. package/dist/managed-hooks.js.map +1 -0
  62. package/dist/mutation-gate.d.ts +14 -0
  63. package/dist/mutation-gate.d.ts.map +1 -1
  64. package/dist/mutation-gate.js +25 -2
  65. package/dist/mutation-gate.js.map +1 -1
  66. package/dist/named-lock.d.ts +57 -0
  67. package/dist/named-lock.d.ts.map +1 -0
  68. package/dist/named-lock.js +247 -0
  69. package/dist/named-lock.js.map +1 -0
  70. package/dist/operations.d.ts +229 -0
  71. package/dist/operations.d.ts.map +1 -1
  72. package/dist/operations.js +880 -26
  73. package/dist/operations.js.map +1 -1
  74. package/dist/parity.d.ts +106 -1
  75. package/dist/parity.d.ts.map +1 -1
  76. package/dist/parity.js +209 -5
  77. package/dist/parity.js.map +1 -1
  78. package/dist/qe-bridge.d.ts +291 -0
  79. package/dist/qe-bridge.d.ts.map +1 -0
  80. package/dist/qe-bridge.js +538 -0
  81. package/dist/qe-bridge.js.map +1 -0
  82. package/dist/recall-usage.d.ts +53 -0
  83. package/dist/recall-usage.d.ts.map +1 -1
  84. package/dist/recall-usage.js +125 -2
  85. package/dist/recall-usage.js.map +1 -1
  86. package/dist/score.d.ts.map +1 -1
  87. package/dist/score.js +43 -9
  88. package/dist/score.js.map +1 -1
  89. package/dist/setup.d.ts.map +1 -1
  90. package/dist/setup.js +14 -26
  91. package/dist/setup.js.map +1 -1
  92. package/dist/shell-veto-policy.d.ts +53 -0
  93. package/dist/shell-veto-policy.d.ts.map +1 -0
  94. package/dist/shell-veto-policy.js +103 -0
  95. package/dist/shell-veto-policy.js.map +1 -0
  96. package/dist/skills.d.ts +86 -1
  97. package/dist/skills.d.ts.map +1 -1
  98. package/dist/skills.js +116 -1
  99. package/dist/skills.js.map +1 -1
  100. package/dist/targets.d.ts +75 -0
  101. package/dist/targets.d.ts.map +1 -1
  102. package/dist/targets.js +160 -0
  103. package/dist/targets.js.map +1 -1
  104. package/dist/workflow-run-dispatch.d.ts +230 -0
  105. package/dist/workflow-run-dispatch.d.ts.map +1 -0
  106. package/dist/workflow-run-dispatch.js +363 -0
  107. package/dist/workflow-run-dispatch.js.map +1 -0
  108. package/dist/workflow-run.d.ts +498 -0
  109. package/dist/workflow-run.d.ts.map +1 -0
  110. package/dist/workflow-run.js +1359 -0
  111. package/dist/workflow-run.js.map +1 -0
  112. package/package.json +6 -5
  113. package/sbom.json +1099 -139
  114. package/src/agents-policy.ts +338 -0
  115. package/src/codex-hooks-assets.ts +328 -0
  116. package/src/codex-hooks-verify.ts +237 -0
  117. package/src/codex-hooks.ts +723 -0
  118. package/src/discrimination-gate.ts +456 -58
  119. package/src/feature-adr-checkpoints.ts +38 -0
  120. package/src/feature-adr-routing.ts +697 -75
  121. package/src/guard.ts +36 -1
  122. package/src/index.ts +162 -2
  123. package/src/loop-blobs.generated.ts +12 -3
  124. package/src/loop-plan.ts +185 -0
  125. package/src/loop-render.ts +37 -127
  126. package/src/loop-run-semantics.ts +278 -0
  127. package/src/loop-trace.ts +84 -10
  128. package/src/managed-hooks.ts +150 -0
  129. package/src/mutation-gate.ts +24 -2
  130. package/src/named-lock.ts +277 -0
  131. package/src/operations.ts +1121 -29
  132. package/src/parity.ts +295 -6
  133. package/src/qe-bridge.ts +737 -0
  134. package/src/recall-usage.ts +184 -1
  135. package/src/score.ts +50 -9
  136. package/src/setup.ts +26 -27
  137. package/src/shell-veto-policy.ts +119 -0
  138. package/src/skills.ts +174 -1
  139. package/src/targets.ts +189 -0
  140. package/src/workflow-run-dispatch.ts +459 -0
  141. package/src/workflow-run.ts +1743 -0
@@ -0,0 +1,541 @@
1
+ /**
2
+ * The Codex hook registry model (`crossrt-2-codex-hooks`, ADR-001).
3
+ *
4
+ * Pure: paths, the managed entry set, sha-based attribution, the manifest, drift, and the TOML text
5
+ * of a trust block. Every filesystem and process action lives in `operations.ts`.
6
+ *
7
+ * ## Measured facts this module encodes (M0 spike, codex-cli 0.147.0 — see
8
+ * `features/crossrt-2-codex-hooks/07_code_changes/probe-results/spike-arming.md`)
9
+ *
10
+ * - `$CODEX_HOME/hooks.json` is the user registry and **`CODEX_HOME` relocates discovery**, which is
11
+ * what makes every automated probe hermetic (G-H). `$CODEX_HOME/hooks/hooks.json` is the PLUGIN
12
+ * bundle layout and does not fire.
13
+ * - Entries are trust-gated. An untrusted entry is silently not run. Trust is persisted per entry in
14
+ * `$CODEX_HOME/config.toml` as `[hooks.state."<key>"] trusted_hash = "<currentHash>"`, and both
15
+ * `key` and `currentHash` come from the runtime's own `hooks/list` RPC — they are **read, never
16
+ * computed**, because `currentHash`'s preimage is internal to codex.
17
+ * - `timeout` is in SECONDS and IS honored (600 → 5, MEASURED). `timeoutSec` in an entry is
18
+ * **silently ignored** and leaves the 600 s default in place — which is why this module emits
19
+ * `timeout` and a test pins the key set (AM-15, now probe-proven by spike S2).
20
+ * - The hook runner spawns via `$SHELL -lc`, so the emitted command is a SHELL string: the
21
+ * interpreter is an absolute `process.execPath` and both paths are single-quoted (AM-32/AM-35d).
22
+ *
23
+ * @packageDocumentation
24
+ */
25
+ import { createHash } from 'node:crypto';
26
+ import { join } from 'node:path';
27
+ import { mergeManagedHookEntries } from './managed-hooks.js';
28
+ /**
29
+ * Bump when a helper BODY changes: a changed body changes codex's `currentHash` ⇒ re-trust.
30
+ *
31
+ * 2 — the independent-QE fix round: the veto note stopped persisting the raw command line and the
32
+ * notes log/dir modes are now enforced on every write (finding 8).
33
+ * 3 — fix round 2: the note's `commandSynopsis` is a binary NAME or `(redacted)` — an
34
+ * env-assignment first token (`SECRET=xyz ssh …`) carried the credential the redaction removed
35
+ * everywhere else (R2-8).
36
+ */
37
+ export const DZ_HOOK_HELPER_VERSION = 3;
38
+ /** Seconds. Probe-proven (spike S2): `timeout` is honored, the unset default is 600 s. */
39
+ export const DZ_HOOK_TIMEOUT_SECONDS = 5;
40
+ /** The wide matcher (AM-8). Narrowing needs a recorded live probe; the guard keys on the payload. */
41
+ export const DZ_VETO_MATCHER = 'Bash|shell|local_shell';
42
+ /** Every path this leg touches, all `CODEX_HOME`-relative (AM-13). */
43
+ export function codexHooksPaths(codexHome) {
44
+ const helperDir = join(codexHome, 'dz-hooks');
45
+ return {
46
+ codexHome,
47
+ registry: join(codexHome, 'hooks.json'),
48
+ configToml: join(codexHome, 'config.toml'),
49
+ helperDir,
50
+ vetoHelper: join(helperDir, 'dz-codex-veto.cjs'),
51
+ recallHelper: join(helperDir, 'dz-codex-recall.cjs'),
52
+ manifest: join(helperDir, 'manifest.json'),
53
+ errorLog: join(helperDir, 'helper-errors.jsonl'),
54
+ };
55
+ }
56
+ /** The EMITTER's write-set (AM-12). The RUNTIME's is stated separately — see {@link runtimeWriteSet}. */
57
+ export function emitterWriteSet(paths) {
58
+ return [paths.registry, paths.vetoHelper, paths.recallHelper, paths.manifest];
59
+ }
60
+ /**
61
+ * The RUNTIME's write-set (AM-33). Exactly one path beyond the emitter's, and it is
62
+ * `CODEX_HOME`-local: a helper must never create a `.dz/` inside a repository the user merely ran
63
+ * `codex` in. (Recall rows are the one exception and they are opt-in-gated: they land in an
64
+ * ALREADY-EXISTING opted-in project's `.dz/`, so nothing is ever created.)
65
+ */
66
+ export function runtimeWriteSet(paths) {
67
+ return [paths.errorLog];
68
+ }
69
+ /* -------------------------------------------------------------------------- */
70
+ /* Quoting */
71
+ /* -------------------------------------------------------------------------- */
72
+ /** A single quote inside a single-quoted shell word cannot be escaped — such a path is REFUSED. */
73
+ export function isSafeForSingleQuote(path) {
74
+ return typeof path === 'string' && path !== '' && !path.includes("'") && !path.includes('\n');
75
+ }
76
+ export function singleQuote(path) {
77
+ return `'${path}'`;
78
+ }
79
+ /**
80
+ * The shell string codex runs. Absolute interpreter + single-quoted paths (AM-32/AM-35d).
81
+ * @throws when either path cannot be safely quoted — never emit a broken entry that READS installed.
82
+ */
83
+ export function buildHookCommand(nodePath, scriptPath) {
84
+ if (!isSafeForSingleQuote(nodePath) || !isSafeForSingleQuote(scriptPath)) {
85
+ throw new Error(`refusing to emit a hook command containing an unquotable path (single quote or newline): ${nodePath} ${scriptPath}`);
86
+ }
87
+ return `${singleQuote(nodePath)} ${singleQuote(scriptPath)}`;
88
+ }
89
+ /** The two entries this leg ships, and nothing else. */
90
+ export const CODEX_MANAGED_HOOKS = [
91
+ { id: 'codex-veto', event: 'PreToolUse', matcher: DZ_VETO_MATCHER, script: 'veto' },
92
+ { id: 'codex-recall', event: 'UserPromptSubmit', script: 'recall' },
93
+ ];
94
+ /**
95
+ * Build the managed entries.
96
+ *
97
+ * Key set is EXACTLY `{matcher?, hooks:[{type, command, timeout}]}` (AM-15). `timeout` is included
98
+ * because spike S2 recorded a probe proving the registry loads with it AND honors it; every other
99
+ * key stays out until it has its own probe.
100
+ */
101
+ export function buildManagedEntries(opts) {
102
+ return CODEX_MANAGED_HOOKS.map((spec) => {
103
+ const script = spec.script === 'veto' ? opts.paths.vetoHelper : opts.paths.recallHelper;
104
+ const command = buildHookCommand(opts.nodePath, script);
105
+ const entry = {
106
+ ...(spec.matcher !== undefined ? { matcher: spec.matcher } : {}),
107
+ hooks: [{ type: 'command', command, timeout: DZ_HOOK_TIMEOUT_SECONDS }],
108
+ };
109
+ return { id: spec.id, event: spec.event, command, entry };
110
+ });
111
+ }
112
+ /** `managed` in the shape {@link mergeManagedHookEntries} takes. */
113
+ export function managedByEvent(entries) {
114
+ const out = {};
115
+ for (const e of entries) {
116
+ (out[e.event] ??= []).push(e.entry);
117
+ }
118
+ return out;
119
+ }
120
+ /* -------------------------------------------------------------------------- */
121
+ /* Manifest + attribution */
122
+ /* -------------------------------------------------------------------------- */
123
+ export function codexHookSha256(text) {
124
+ return createHash('sha256').update(text, 'utf8').digest('hex');
125
+ }
126
+ export function buildCodexHookManifest(opts) {
127
+ return {
128
+ version: 1,
129
+ writtenAt: opts.writtenAt,
130
+ codexVersion: opts.codexVersion,
131
+ registryPath: opts.paths.registry,
132
+ helperVersion: DZ_HOOK_HELPER_VERSION,
133
+ nodePath: opts.nodePath,
134
+ entries: opts.entries.map((e) => {
135
+ const spec = CODEX_MANAGED_HOOKS.find((s) => s.id === e.id);
136
+ const trustKey = opts.trustKeys?.[e.id];
137
+ return {
138
+ id: e.id,
139
+ event: e.event,
140
+ ...(spec?.matcher !== undefined ? { matcher: spec.matcher } : {}),
141
+ commandSha256: codexHookSha256(e.command),
142
+ ...(trustKey !== undefined ? { trustKey } : {}),
143
+ };
144
+ }),
145
+ ...(opts.lastVerify !== undefined ? { lastVerify: opts.lastVerify } : {}),
146
+ };
147
+ }
148
+ export function parseCodexHookManifest(text) {
149
+ try {
150
+ const parsed = JSON.parse(text);
151
+ if (parsed === null || typeof parsed !== 'object')
152
+ return undefined;
153
+ const m = parsed;
154
+ if (m.version !== 1 || !Array.isArray(m.entries))
155
+ return undefined;
156
+ return m;
157
+ }
158
+ catch {
159
+ return undefined;
160
+ }
161
+ }
162
+ function entryCommands(entry) {
163
+ const e = entry;
164
+ if (Array.isArray(e?.hooks))
165
+ return e.hooks.map((h) => String(h?.command ?? ''));
166
+ return [String(e?.command ?? '')];
167
+ }
168
+ /**
169
+ * Attribution is `codexHookSha256(command) ∈ manifest` — never a substring guess.
170
+ *
171
+ * ADR-001 §3: dz deletes only what it can PROVE it wrote. An entry that merely looks like ours (it
172
+ * mentions our helper filename) but whose command hash is absent from the manifest is KEPT, counted
173
+ * in `unattributable`, and warned about. A hand-edited managed command therefore survives.
174
+ */
175
+ export function isDzManagedEntry(entry, manifest) {
176
+ if (manifest === undefined)
177
+ return false;
178
+ const known = new Set(manifest.entries.map((e) => e.commandSha256));
179
+ return entryCommands(entry).some((cmd) => cmd !== '' && known.has(codexHookSha256(cmd)));
180
+ }
181
+ /**
182
+ * Rebuild an OWNED entry from only the handlers that are NOT ours — per-HANDLER attribution.
183
+ *
184
+ * ADR-001 §5 promises that dz deletes only what it can prove it wrote. Attribution was applied to a
185
+ * whole MATCHER GROUP: a group holding one dz handler and one of the user's was removed (or
186
+ * replaced) wholesale, so a foreign handler was deleted by a rule written to protect it
187
+ * (independent review, finding 6). One dz handler in the group must cost exactly that handler.
188
+ *
189
+ * Returns `null` when every handler in the entry was ours (the entry itself is then dropped), and
190
+ * a rebuilt entry — same keys, same order, minus our handlers — when something foreign survives.
191
+ * A legacy FLAT entry (`{type, command}`) is one handler and has nothing to salvage.
192
+ */
193
+ export function retainForeignHandlers(entry, manifest) {
194
+ if (manifest === undefined)
195
+ return entry;
196
+ const known = new Set(manifest.entries.map((e) => e.commandSha256));
197
+ const isOurs = (cmd) => typeof cmd === 'string' && cmd !== '' && known.has(codexHookSha256(cmd));
198
+ const e = entry;
199
+ if (!Array.isArray(e?.hooks))
200
+ return null; // flat shape: the entry IS the handler
201
+ const kept = e.hooks.filter((h) => !isOurs(h?.command));
202
+ if (kept.length === 0)
203
+ return null;
204
+ return { ...entry, hooks: kept };
205
+ }
206
+ /** Cheap resemblance test — drives the `unattributable` COUNT only, never a deletion. */
207
+ export function looksLikeDzEntry(entry) {
208
+ return entryCommands(entry).some((cmd) => cmd.includes('dz-codex-veto.cjs') || cmd.includes('dz-codex-recall.cjs'));
209
+ }
210
+ /**
211
+ * Parse an existing registry. An unparseable file is an ERROR, never an empty registry: silently
212
+ * treating it as `{}` would overwrite entries we promised to preserve (I1).
213
+ */
214
+ export function parseCodexRegistry(text) {
215
+ if (text === undefined || text.trim() === '') {
216
+ return { ok: true, registry: { rest: {}, hooks: {} } };
217
+ }
218
+ let parsed;
219
+ try {
220
+ parsed = JSON.parse(text);
221
+ }
222
+ catch (err) {
223
+ return { ok: false, error: `hooks.json is not valid JSON: ${err.message}` };
224
+ }
225
+ if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed)) {
226
+ return { ok: false, error: 'hooks.json must be a JSON object' };
227
+ }
228
+ const obj = parsed;
229
+ const rawHooks = obj['hooks'];
230
+ if (rawHooks !== undefined && (rawHooks === null || typeof rawHooks !== 'object' || Array.isArray(rawHooks))) {
231
+ return { ok: false, error: 'hooks.json "hooks" must be an object keyed by event name' };
232
+ }
233
+ const hooks = {};
234
+ for (const [event, value] of Object.entries((rawHooks ?? {}))) {
235
+ // REFUSE, never coerce. `Array.isArray(value) ? [...value] : []` silently turned a foreign
236
+ // event whose value dz does not understand into an EMPTY list, and the next write persisted
237
+ // that emptiness — configuration loss dressed as a merge (independent review, finding 5). An
238
+ // unparseable shape is the same class of fact as unparseable JSON: refuse before planning.
239
+ if (!Array.isArray(value)) {
240
+ return {
241
+ ok: false,
242
+ error: `hooks.json event ${JSON.stringify(event)} must be an array of entries (found ${value === null ? 'null' : typeof value}) — dz refuses to rewrite a registry it cannot read without losing it`,
243
+ };
244
+ }
245
+ hooks[event] = [...value];
246
+ }
247
+ const rest = {};
248
+ for (const [k, v] of Object.entries(obj))
249
+ if (k !== 'hooks')
250
+ rest[k] = v;
251
+ return { ok: true, registry: { rest, hooks } };
252
+ }
253
+ export function serializeCodexRegistry(registry) {
254
+ return `${JSON.stringify({ ...registry.rest, hooks: registry.hooks }, null, 2)}\n`;
255
+ }
256
+ /**
257
+ * Compute the merged registry.
258
+ *
259
+ * The merge itself is `mergeManagedHookEntries` — the SAME implementation the Claude path uses
260
+ * (AM-3 / G-E). Only the attribution predicate differs.
261
+ */
262
+ export function planCodexHooks(input) {
263
+ const parsed = parseCodexRegistry(input.currentText);
264
+ if (!parsed.ok)
265
+ return { ok: false, error: parsed.error };
266
+ // The union of the manifest's hashes and the ones we are about to write: on a re-run the manifest
267
+ // is current, on a helper-version bump it is not, and BOTH vintages of our own entry must be
268
+ // replaced rather than duplicated.
269
+ const selfManifest = {
270
+ version: 1,
271
+ writtenAt: '',
272
+ codexVersion: '',
273
+ registryPath: '',
274
+ helperVersion: DZ_HOOK_HELPER_VERSION,
275
+ nodePath: '',
276
+ entries: [
277
+ ...(input.manifest?.entries ?? []),
278
+ ...input.entries.map((e) => ({ id: e.id, event: e.event, commandSha256: codexHookSha256(e.command) })),
279
+ ],
280
+ };
281
+ const plan = mergeManagedHookEntries(parsed.registry.hooks, managedByEvent(input.entries), {
282
+ isManaged: (entry) => isDzManagedEntry(entry, selfManifest),
283
+ looksLikeOurs: (entry) => looksLikeDzEntry(entry) && !isDzManagedEntry(entry, selfManifest),
284
+ // Per-HANDLER salvage (finding 6): an owned entry that also carries the user's own handler is
285
+ // rebuilt without ours, never dropped whole. The Claude path passes no salvage and is
286
+ // byte-identical to before (AM-3).
287
+ retainForeign: (entry) => retainForeignHandlers(entry, selfManifest),
288
+ reportLabel: 'codex',
289
+ });
290
+ const registry = { rest: parsed.registry.rest, hooks: plan.hooks };
291
+ return {
292
+ ok: true,
293
+ plan: {
294
+ registry,
295
+ text: serializeCodexRegistry(registry),
296
+ changed: plan.changed,
297
+ foreignPreserved: plan.foreignPreserved,
298
+ unattributable: plan.unattributable,
299
+ },
300
+ };
301
+ }
302
+ /**
303
+ * `--remove`: delete ONLY manifest-attributed entries.
304
+ *
305
+ * With the manifest deleted this removes **zero** entries and reports them all as `unattributable`.
306
+ * That is the intended, conservative behaviour: dz never deletes what it cannot prove it wrote.
307
+ */
308
+ export function removeCodexHooks(currentText, manifest) {
309
+ const parsed = parseCodexRegistry(currentText);
310
+ if (!parsed.ok)
311
+ return { ok: false, error: parsed.error };
312
+ const hooks = {};
313
+ let removed = 0;
314
+ let unattributable = 0;
315
+ for (const [event, entries] of Object.entries(parsed.registry.hooks)) {
316
+ const kept = [];
317
+ for (const entry of entries) {
318
+ if (isDzManagedEntry(entry, manifest)) {
319
+ removed += 1;
320
+ // Per-HANDLER removal (finding 6): a mixed matcher group keeps every handler that is not
321
+ // ours. Removing dz's guard must never remove the user's alongside it.
322
+ const salvaged = retainForeignHandlers(entry, manifest);
323
+ if (salvaged !== null)
324
+ kept.push(salvaged);
325
+ continue;
326
+ }
327
+ if (looksLikeDzEntry(entry))
328
+ unattributable += 1;
329
+ kept.push(entry);
330
+ }
331
+ hooks[event] = kept;
332
+ }
333
+ const registry = { rest: parsed.registry.rest, hooks };
334
+ return {
335
+ ok: true,
336
+ result: { registry, text: serializeCodexRegistry(registry), removed, changed: removed > 0, unattributable },
337
+ };
338
+ }
339
+ /** `--check` recomputes from the FILE; it never trusts the manifest's claim on its own. */
340
+ export function diffCodexHooks(currentText, entries, manifest) {
341
+ const parsed = parseCodexRegistry(currentText);
342
+ const hooks = parsed.ok ? parsed.registry.hooks : {};
343
+ const present = [];
344
+ const drifted = [];
345
+ let foreignPreserved = 0;
346
+ let unattributable = 0;
347
+ const wantByEvent = new Map(entries.map((e) => [e.event, e]));
348
+ for (const [event, list] of Object.entries(hooks)) {
349
+ for (const entry of list) {
350
+ const want = wantByEvent.get(event);
351
+ const cmds = entryCommands(entry);
352
+ if (want !== undefined && cmds.includes(want.command)) {
353
+ present.push(want.id);
354
+ continue;
355
+ }
356
+ if (isDzManagedEntry(entry, manifest)) {
357
+ // Ours by manifest, but not the command we would write now: an old helper version.
358
+ const id = manifest?.entries.find((m) => cmds.some((c) => codexHookSha256(c) === m.commandSha256))?.id;
359
+ if (id !== undefined)
360
+ drifted.push(id);
361
+ continue;
362
+ }
363
+ foreignPreserved += 1;
364
+ if (looksLikeDzEntry(entry))
365
+ unattributable += 1;
366
+ }
367
+ }
368
+ const missing = entries.map((e) => e.id).filter((id) => !present.includes(id));
369
+ return {
370
+ installed: missing.length === 0,
371
+ presentIds: present,
372
+ missingIds: missing,
373
+ foreignPreserved,
374
+ unattributable,
375
+ drifted,
376
+ };
377
+ }
378
+ /* -------------------------------------------------------------------------- */
379
+ /* Trust (the M0 arming route) */
380
+ /* -------------------------------------------------------------------------- */
381
+ /** codex's snake_case event spelling inside a trust key (MEASURED from `hooks/list`). */
382
+ export function trustEventName(event) {
383
+ return event === 'PreToolUse' ? 'pre_tool_use' : 'user_prompt_submit';
384
+ }
385
+ /**
386
+ * Compare two event spellings the way the runtime actually spells them.
387
+ *
388
+ * MEASURED, both on this machine, on the SAME response shape:
389
+ * - the trust KEY embeds `pre_tool_use` / `user_prompt_submit` (snake_case);
390
+ * - `hooks/list`'s `eventName` FIELD is `preToolUse` / `userPromptSubmit` on **codex-cli 0.148.0**
391
+ * (reproducer: `listCodexHooks(<temp home>)` after an install — the rows are printed verbatim in
392
+ * `07_code_changes/probe-results/fixround/trust-diagnosis.txt`).
393
+ *
394
+ * Pinning either spelling alone silently drops every row: the fix round's first cut compared the
395
+ * field against the KEY spelling, `hooks/list` matched 0 of 2 entries, trust was never written, and
396
+ * the live probe's ARMED leg stopped blocking. Case and separators are therefore normalised away —
397
+ * the spelling is the runtime's cosmetic choice, the EVENT is the fact.
398
+ */
399
+ export function sameHookEvent(a, b) {
400
+ const norm = (v) => v.toLowerCase().replace(/[-_\s]/g, '');
401
+ return norm(a) === norm(b);
402
+ }
403
+ /**
404
+ * The trust key codex uses: `<sourcePath>:<snake_event>:<groupIndex>:<hookIndex>`.
405
+ *
406
+ * This is the EXPECTED spelling, used only to cross-check what `hooks/list` reports. The install
407
+ * path uses the reported key verbatim — a computed key that drifts from the runtime's would arm
408
+ * nothing while reading like success.
409
+ */
410
+ export function expectedTrustKey(registryPath, event, groupIndex, hookIndex) {
411
+ return `${registryPath}:${trustEventName(event)}:${groupIndex}:${hookIndex}`;
412
+ }
413
+ /**
414
+ * Split a `hooks/list` trust key into its parts, or `null` when it is not one.
415
+ *
416
+ * MEASURED shape: `<sourcePath>:<snake_event>:<groupIndex>:<hookIndex>`. The path may itself carry
417
+ * a colon, so the split is anchored at the END — the last two fields are the indices and the third
418
+ * from the end is the event.
419
+ *
420
+ * The INDICES are deliberately not predicted: they are positions inside the user's registry, and a
421
+ * foreign entry shifts them. What IS ours to require is the rest — this key names OUR registry and
422
+ * OUR event (fix round 2, R2-7: a row carrying an arbitrary key was selected on path+event+command
423
+ * alone, and the key is what dz then writes trust against).
424
+ */
425
+ export function parseTrustKey(key) {
426
+ const m = /^(.*):([A-Za-z_][A-Za-z_]*):(\d+):(\d+)$/.exec(key);
427
+ if (m === null)
428
+ return null;
429
+ return { sourcePath: m[1] ?? '', event: m[2] ?? '', groupIndex: Number(m[3]), hookIndex: Number(m[4]) };
430
+ }
431
+ /** TOML-escape a bare-string key (the key is an absolute path plus `:` separators). */
432
+ function tomlQuote(value) {
433
+ return `"${value.replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"`;
434
+ }
435
+ export const DZ_TRUST_BEGIN = '# --- dz codex hooks trust (managed block, dz-rewritten) ---';
436
+ export const DZ_TRUST_END = '# --- end dz codex hooks trust ---';
437
+ /**
438
+ * Render dz's trust rows as a MANAGED BLOCK in `config.toml`.
439
+ *
440
+ * A managed block, not a whole-file rewrite: `~/.codex/config.toml` already carries a
441
+ * `ruvnet-brain` managed block and seven `[projects."…"]` trust rows on this machine (MEASURED),
442
+ * and dz is not the only writer. The block is delimited so a re-run replaces exactly dz's rows and
443
+ * nothing else.
444
+ */
445
+ export function renderTrustBlock(rows) {
446
+ if (rows.length === 0)
447
+ return '';
448
+ const body = rows
449
+ .map((r) => `[hooks.state.${tomlQuote(r.key)}]\ntrusted_hash = ${tomlQuote(r.trustedHash)}`)
450
+ .join('\n');
451
+ return `${DZ_TRUST_BEGIN}\n${body}\n${DZ_TRUST_END}\n`;
452
+ }
453
+ function countOccurrences(haystack, needle) {
454
+ let n = 0;
455
+ let i = haystack.indexOf(needle);
456
+ while (i >= 0) {
457
+ n += 1;
458
+ i = haystack.indexOf(needle, i + needle.length);
459
+ }
460
+ return n;
461
+ }
462
+ /**
463
+ * Replace (or append) dz's managed trust block, leaving every other byte of config.toml alone.
464
+ *
465
+ * The fence must be **exactly one well-ordered pair**, or dz refuses (independent review, finding
466
+ * 9). The old `indexOf`-pair logic was satisfiable by a damaged file in three ways, and each one
467
+ * eats the user's TOML on the NEXT sync: a lone BEGIN made the rewrite append a second block, so
468
+ * the following run's `begin…end` window spanned everything between the orphan marker and the new
469
+ * block's END; a reversed pair did the same; duplicate pairs left an orphan block behind. Refusing
470
+ * costs one manual edit — the alternative silently deletes `[projects."…"]` trust rows.
471
+ */
472
+ export function upsertTrustBlock(configToml, rows) {
473
+ const block = renderTrustBlock(rows);
474
+ const begins = countOccurrences(configToml, DZ_TRUST_BEGIN);
475
+ const ends = countOccurrences(configToml, DZ_TRUST_END);
476
+ const heal = `heal by hand: leave exactly one ${JSON.stringify(DZ_TRUST_BEGIN)} … ${JSON.stringify(DZ_TRUST_END)} pair (or delete both markers) and re-run`;
477
+ if (begins > 1 || ends > 1) {
478
+ return { ok: false, error: `config.toml carries ${begins} dz trust BEGIN and ${ends} END markers — dz refuses to guess which block is its own. ${heal}` };
479
+ }
480
+ if (begins !== ends) {
481
+ return { ok: false, error: `config.toml carries an UNPAIRED dz trust marker (${begins} BEGIN, ${ends} END) — rewriting it would consume unrelated TOML. ${heal}` };
482
+ }
483
+ if (begins === 1) {
484
+ const begin = configToml.indexOf(DZ_TRUST_BEGIN);
485
+ const end = configToml.indexOf(DZ_TRUST_END);
486
+ if (end < begin) {
487
+ return { ok: false, error: `config.toml carries the dz trust END marker BEFORE its BEGIN — the fence is inverted and the span between them is not dz's. ${heal}` };
488
+ }
489
+ const before = configToml.slice(0, begin);
490
+ const after = configToml.slice(end + DZ_TRUST_END.length).replace(/^\n/, '');
491
+ return { ok: true, text: `${before}${block}${after}` };
492
+ }
493
+ const base = configToml === '' || configToml.endsWith('\n') ? configToml : `${configToml}\n`;
494
+ return { ok: true, text: `${base}${base === '' ? '' : '\n'}${block}` };
495
+ }
496
+ /**
497
+ * Pick, from a `hooks/list` response, the metadata of the entries WE wrote.
498
+ *
499
+ * The match is on THREE facts, not one (independent review, finding 7): the row's `sourcePath` is
500
+ * the registry dz wrote, its `eventName` is the event dz registered the entry under, and the
501
+ * command string is byte-equal. Command alone was not enough — a project-scoped
502
+ * `<repo>/.codex/hooks.json` DOES load on codex 0.148 (MEASURED, see ADR-004's addendum), so a
503
+ * shadow copy of dz's own command line could supply the `trusted` row that armed the user-global
504
+ * entry nobody had approved.
505
+ *
506
+ * AMBIGUITY IS REFUSED, not resolved: two rows claiming the same entry drop BOTH, because the one
507
+ * dz would arm is then a coin flip and the trust write is keyed by the row it picked.
508
+ */
509
+ export function selectOwnHookMetadata(hooks, entries, options) {
510
+ const byCommand = new Map(entries.map((e) => [e.command, e]));
511
+ const claims = new Map();
512
+ for (const meta of hooks) {
513
+ if (typeof meta.command !== 'string')
514
+ continue;
515
+ const entry = byCommand.get(meta.command);
516
+ if (entry === undefined)
517
+ continue;
518
+ if (meta.sourcePath !== options.registryPath)
519
+ continue;
520
+ if (!sameHookEvent(meta.eventName, trustEventName(entry.event)))
521
+ continue;
522
+ // The KEY is the thing dz writes trust against, so it — not just the row's other fields — has
523
+ // to be the key our entry would own (R2-7). An arbitrary or foreign key is ambiguous by
524
+ // construction: arming it would persist trust for something we cannot identify.
525
+ const parsedKey = typeof meta.key === 'string' ? parseTrustKey(meta.key) : null;
526
+ if (parsedKey === null)
527
+ continue;
528
+ if (parsedKey.sourcePath !== options.registryPath)
529
+ continue;
530
+ if (!sameHookEvent(parsedKey.event, trustEventName(entry.event)))
531
+ continue;
532
+ (claims.get(entry.id) ?? claims.set(entry.id, []).get(entry.id)).push({ id: entry.id, meta });
533
+ }
534
+ const out = [];
535
+ for (const rows of claims.values()) {
536
+ if (rows.length === 1)
537
+ out.push(rows[0]);
538
+ }
539
+ return out;
540
+ }
541
+ //# sourceMappingURL=codex-hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codex-hooks.js","sourceRoot":"","sources":["../src/codex-hooks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAE7D;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC;AAExC,0FAA0F;AAC1F,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC;AAEzC,qGAAqG;AACrG,MAAM,CAAC,MAAM,eAAe,GAAG,wBAAwB,CAAC;AAaxD,sEAAsE;AACtE,MAAM,UAAU,eAAe,CAAC,SAAiB;IAC/C,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IAC9C,OAAO;QACL,SAAS;QACT,QAAQ,EAAE,IAAI,CAAC,SAAS,EAAE,YAAY,CAAC;QACvC,UAAU,EAAE,IAAI,CAAC,SAAS,EAAE,aAAa,CAAC;QAC1C,SAAS;QACT,UAAU,EAAE,IAAI,CAAC,SAAS,EAAE,mBAAmB,CAAC;QAChD,YAAY,EAAE,IAAI,CAAC,SAAS,EAAE,qBAAqB,CAAC;QACpD,QAAQ,EAAE,IAAI,CAAC,SAAS,EAAE,eAAe,CAAC;QAC1C,QAAQ,EAAE,IAAI,CAAC,SAAS,EAAE,qBAAqB,CAAC;KACjD,CAAC;AACJ,CAAC;AAED,yGAAyG;AACzG,MAAM,UAAU,eAAe,CAAC,KAAsB;IACpD,OAAO,CAAC,KAAK,CAAC,QAAQ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