approval-md 0.4.6 → 0.4.7

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 (57) hide show
  1. package/SPEC.md +11 -1
  2. package/dist/src/channels/contract.d.ts +15 -0
  3. package/dist/src/channels/contract.js +23 -1
  4. package/dist/src/channels/contract.js.map +1 -1
  5. package/dist/src/channels/telegram.d.ts +75 -2
  6. package/dist/src/channels/telegram.js +99 -6
  7. package/dist/src/channels/telegram.js.map +1 -1
  8. package/dist/src/cli/channel-telegram.d.ts +14 -0
  9. package/dist/src/cli/channel-telegram.js +44 -2
  10. package/dist/src/cli/channel-telegram.js.map +1 -1
  11. package/dist/src/cli/help.d.ts +2 -0
  12. package/dist/src/cli/help.js +36 -0
  13. package/dist/src/cli/help.js.map +1 -1
  14. package/dist/src/cli/hook.d.ts +29 -0
  15. package/dist/src/cli/hook.js +178 -15
  16. package/dist/src/cli/hook.js.map +1 -1
  17. package/dist/src/cli/instructions.js +9 -6
  18. package/dist/src/cli/instructions.js.map +1 -1
  19. package/dist/src/cli/main.js +9 -0
  20. package/dist/src/cli/main.js.map +1 -1
  21. package/dist/src/cli/study.d.ts +22 -0
  22. package/dist/src/cli/study.js +153 -0
  23. package/dist/src/cli/study.js.map +1 -0
  24. package/dist/src/cli/verb-registry.d.ts +14 -0
  25. package/dist/src/cli/verb-registry.js +37 -0
  26. package/dist/src/cli/verb-registry.js.map +1 -1
  27. package/dist/src/cli/wordmark.d.ts +2 -2
  28. package/dist/src/cli/wordmark.js +2 -2
  29. package/dist/src/core/gate.d.ts +38 -0
  30. package/dist/src/core/gate.js +26 -0
  31. package/dist/src/core/gate.js.map +1 -1
  32. package/dist/src/core/sender-identity.d.ts +13 -1
  33. package/dist/src/core/sender-identity.js +15 -0
  34. package/dist/src/core/sender-identity.js.map +1 -1
  35. package/dist/src/core/study-withdraw.d.ts +137 -0
  36. package/dist/src/core/study-withdraw.js +280 -0
  37. package/dist/src/core/study-withdraw.js.map +1 -0
  38. package/dist/src/daemon/git-evidence.d.ts +2 -2
  39. package/dist/src/daemon/git-evidence.js +1 -1
  40. package/dist/src/mcp/server.js +1 -1
  41. package/dist/src/mcp/server.js.map +1 -1
  42. package/docs/cli-reference.md +63 -0
  43. package/package.json +2 -2
  44. package/schema/event.schema.json +212 -0
  45. package/schema/fixtures/event/invalid/approval-granted-study.json +23 -0
  46. package/schema/fixtures/event/invalid/approval-rejected-looks-wrong-cli-channel.json +23 -0
  47. package/schema/fixtures/event/invalid/approval-rejected-looks-wrong-operator.json +24 -0
  48. package/schema/fixtures/event/invalid/approval-rejected-study-extra-key.json +24 -0
  49. package/schema/fixtures/event/invalid/approval-rejected-study-unknown-reason.json +23 -0
  50. package/schema/fixtures/event/invalid/approval-rejected-study-withdrawn-email-operator.json +20 -0
  51. package/schema/fixtures/event/invalid/approval-rejected-study-withdrawn-no-operator.json +19 -0
  52. package/schema/fixtures/event/invalid/approval-rejected-study-withdrawn-no-ref.json +19 -0
  53. package/schema/fixtures/event/invalid/approval-rejected-study-withdrawn-wrong-actor.json +20 -0
  54. package/schema/fixtures/event/invalid/approval-rejected-study-withdrawn-wrong-channel.json +20 -0
  55. package/schema/fixtures/event/invalid/approval-revoked-study.json +20 -0
  56. package/schema/fixtures/event/valid/approval-rejected-looks-wrong.json +23 -0
  57. package/schema/fixtures/event/valid/approval-rejected-study-withdrawn.json +20 -0
@@ -0,0 +1,137 @@
1
+ /**
2
+ * The study operator's withdraw (APRV-527, amended SPEC.md §8, the study record).
3
+ *
4
+ * A hosted operator running a study may DENY one request that is still pending,
5
+ * before it can run. It is never a grant, never an edit of a decision and never
6
+ * a reopening: the verb calls the gate's `decide` with the constant `reject`,
7
+ * under the constant actor `human:study-team` on the constant channel `study`,
8
+ * and the record carries `payload.study {reason: "study_withdrawn", operator,
9
+ * ref}`. Every reader that ignores the field reads an ordinary rejection, so the
10
+ * requester's `wait` exits 1, the queue drops the request, and nothing executes.
11
+ *
12
+ * Four properties are load-bearing, and each is enforced here rather than by
13
+ * whoever calls this:
14
+ *
15
+ * 1. **Off is a no-op.** Unless the process environment holds
16
+ * `APPROVAL_STUDY_MODE` exactly `1`, the verb refuses `study-mode-off` before
17
+ * it opens the log. The value is read from the environment and never from a
18
+ * policy, because nothing an agent can propose into a policy file may switch
19
+ * it on.
20
+ * 2. **Pending only.** The verified log must derive `requested` for the key at
21
+ * this instant; anything else (granted, rejected, revoked, expired, withdrawn,
22
+ * never requested) is `not-pending`. `decide` then re-derives the state under
23
+ * its own head-moved retry, so a resident's tap that lands between this read
24
+ * and the append wins and the withdraw becomes `not-pending` too.
25
+ * 3. **A too-late withdraw is on the record.** Like `approval reject`, a
26
+ * refused attempt that names one request appends ONE `audit.decision_refused`
27
+ * (`recordRefusedDecision`, under `human:study-team` on channel `study`, with
28
+ * the gate's own code): the study team's attempt is a decision a person made,
29
+ * and an invisible refusal would be a gap in the study's own record. Nothing
30
+ * is appended when study mode is off, on a replay, on an ambiguous ref, on a
31
+ * ref or key naming no request, or on a log fault. (The gate's own lazy
32
+ * `approval.expired` can also land when a TTL lapses inside the read-to-append
33
+ * window; see SPEC.md §11.2's preamble.)
34
+ * 4. **Replay-safe.** The `ref` the operator supplies is matched against the
35
+ * verified log first, and again after a lost race, so a concurrent retry of
36
+ * the same `ref` (a control plane's retry after its own timeout) answers
37
+ * `idempotent` and appends nothing rather than a false refusal.
38
+ *
39
+ * The verb is human-only in the verb registry, so neither `approval serve` nor
40
+ * the MCP wrapper publishes it, and its one intended caller is a root exec on
41
+ * the box running as the store's own uid.
42
+ */
43
+ import { type GateOptions, type GateRefusalCode } from "./gate.js";
44
+ import { type RequestState } from "./state.js";
45
+ /** The environment variable that switches study mode on, read from the process alone. */
46
+ export declare const STUDY_MODE_ENV = "APPROVAL_STUDY_MODE";
47
+ /** Study mode is on only when {@link STUDY_MODE_ENV} is exactly `1`. */
48
+ export declare function studyModeOn(env: Readonly<Record<string, string | undefined>>): boolean;
49
+ /** The actor every study withdrawal is recorded under (the schema pins it). */
50
+ export declare const STUDY_TEAM_ACTOR = "human:study-team";
51
+ /** The record's `channel` for a study withdrawal (the schema pins it). */
52
+ export declare const STUDY_CHANNEL = "study";
53
+ /** The record's `payload.note` for a study withdrawal. */
54
+ export declare const STUDY_WITHDRAW_NOTE = "withdrawn by the study team";
55
+ /**
56
+ * The operator id: 8 lowercase hex the control plane derives from the staff email with a key it
57
+ * alone holds (an HMAC, so a staff list cannot reverse it). Never the email; core checks the shape only.
58
+ */
59
+ export declare const STUDY_OPERATOR_PATTERN: RegExp;
60
+ /** The withdraw's replay reference, minted once by the operator's tool. */
61
+ export declare const STUDY_REF_PATTERN: RegExp;
62
+ /** How many hex characters of the key's sha256 an action ref carries. */
63
+ export declare const STUDY_ACTION_REF_HEX = 12;
64
+ /** An action ref: the first {@link STUDY_ACTION_REF_HEX} hex of sha256(action key). */
65
+ export declare const STUDY_ACTION_REF_PATTERN: RegExp;
66
+ /**
67
+ * The short reference an operator names a request by, so that no action key
68
+ * (which can carry text an agent wrote) ever has to leave the box. It is the
69
+ * same 12 hex the Telegram listener's "Looks wrong" line prints
70
+ * (`studyLogRefOf`, a prefix of the callback's `actionRefOf`), so one operator
71
+ * vocabulary covers both study surfaces.
72
+ */
73
+ export declare function studyActionRefOf(actionKey: string): string;
74
+ /**
75
+ * Every way the study withdraw refuses on its own (SPEC.md §11.1 invariant 6,
76
+ * §11.2 `study_withdraw_refusal_codes`), in evaluation order. Only
77
+ * `not-pending` on a request that exists appends, and it appends one
78
+ * `audit.decision_refused`. A log that cannot be read or written reaches the
79
+ * caller under the gate's own code (`log-unreadable`, `log-torn-tail`,
80
+ * `log-corrupt`, `append-failed`), appends nothing, and is not a member here.
81
+ */
82
+ export declare const STUDY_WITHDRAW_REFUSAL_CODES: readonly [
83
+ /** The process was not launched with `APPROVAL_STUDY_MODE=1`. Nothing was read. */
84
+ "study-mode-off",
85
+ /** The request is not pending: decided, expired, withdrawn, never requested, or lost a race. */
86
+ "not-pending",
87
+ /** An action ref names more than one pending request. Nothing was decided. */
88
+ "action-ref-ambiguous"];
89
+ export type StudyWithdrawRefusalCode = (typeof STUDY_WITHDRAW_REFUSAL_CODES)[number];
90
+ /** Which request to withdraw: its key, or the 12-hex ref of a pending one. Exactly one. */
91
+ export type StudyWithdrawTarget = {
92
+ actionKey: string;
93
+ } | {
94
+ actionRef: string;
95
+ };
96
+ export interface StudyWithdrawInput {
97
+ target: StudyWithdrawTarget;
98
+ /** {@link STUDY_OPERATOR_PATTERN}. Validated by the caller; the schema holds it again. */
99
+ operator: string;
100
+ /** {@link STUDY_REF_PATTERN}. Validated by the caller; the schema holds it again. */
101
+ ref: string;
102
+ }
103
+ export interface StudyWithdrawOptions extends GateOptions {
104
+ /** The environment study mode is read from. Defaults to `process.env`. */
105
+ env?: Readonly<Record<string, string | undefined>>;
106
+ }
107
+ export type StudyWithdrawResult = {
108
+ ok: true;
109
+ /** True when the same `ref` had already withdrawn this request: nothing was appended. */
110
+ idempotent: boolean;
111
+ /** The seq of the `approval.rejected` that withdrew it (this run's, or the earlier one's). */
112
+ seq: number;
113
+ /** The key withdrawn. For the caller's own bookkeeping; the CLI never prints it. */
114
+ actionKey: string;
115
+ } | StudyWithdrawRefusal;
116
+ export interface StudyWithdrawRefusal {
117
+ ok: false;
118
+ code: StudyWithdrawRefusalCode | GateRefusalCode;
119
+ message: string;
120
+ /** The derived state, on `not-pending`. */
121
+ state?: RequestState;
122
+ /**
123
+ * The gate's own code for the refusal, on `not-pending` for a request that
124
+ * exists (`already-decided`, `expired`, `request-withdrawn`, or whatever
125
+ * `decide` answered after a race). It is the code the audit record carries.
126
+ */
127
+ gateCode?: GateRefusalCode;
128
+ /** The seq of the `audit.decision_refused` this refusal appended, when it appended one. */
129
+ auditSeq?: number;
130
+ /** How many pending requests the ref named, on `action-ref-ambiguous`. */
131
+ matches?: number;
132
+ }
133
+ /**
134
+ * Withdraw one pending request for the study team. See the module header for
135
+ * the four properties; the order of checks is normative (SPEC.md §11.2).
136
+ */
137
+ export declare function studyWithdraw(logPath: string, input: StudyWithdrawInput, options?: StudyWithdrawOptions): StudyWithdrawResult;
@@ -0,0 +1,280 @@
1
+ /**
2
+ * The study operator's withdraw (APRV-527, amended SPEC.md §8, the study record).
3
+ *
4
+ * A hosted operator running a study may DENY one request that is still pending,
5
+ * before it can run. It is never a grant, never an edit of a decision and never
6
+ * a reopening: the verb calls the gate's `decide` with the constant `reject`,
7
+ * under the constant actor `human:study-team` on the constant channel `study`,
8
+ * and the record carries `payload.study {reason: "study_withdrawn", operator,
9
+ * ref}`. Every reader that ignores the field reads an ordinary rejection, so the
10
+ * requester's `wait` exits 1, the queue drops the request, and nothing executes.
11
+ *
12
+ * Four properties are load-bearing, and each is enforced here rather than by
13
+ * whoever calls this:
14
+ *
15
+ * 1. **Off is a no-op.** Unless the process environment holds
16
+ * `APPROVAL_STUDY_MODE` exactly `1`, the verb refuses `study-mode-off` before
17
+ * it opens the log. The value is read from the environment and never from a
18
+ * policy, because nothing an agent can propose into a policy file may switch
19
+ * it on.
20
+ * 2. **Pending only.** The verified log must derive `requested` for the key at
21
+ * this instant; anything else (granted, rejected, revoked, expired, withdrawn,
22
+ * never requested) is `not-pending`. `decide` then re-derives the state under
23
+ * its own head-moved retry, so a resident's tap that lands between this read
24
+ * and the append wins and the withdraw becomes `not-pending` too.
25
+ * 3. **A too-late withdraw is on the record.** Like `approval reject`, a
26
+ * refused attempt that names one request appends ONE `audit.decision_refused`
27
+ * (`recordRefusedDecision`, under `human:study-team` on channel `study`, with
28
+ * the gate's own code): the study team's attempt is a decision a person made,
29
+ * and an invisible refusal would be a gap in the study's own record. Nothing
30
+ * is appended when study mode is off, on a replay, on an ambiguous ref, on a
31
+ * ref or key naming no request, or on a log fault. (The gate's own lazy
32
+ * `approval.expired` can also land when a TTL lapses inside the read-to-append
33
+ * window; see SPEC.md §11.2's preamble.)
34
+ * 4. **Replay-safe.** The `ref` the operator supplies is matched against the
35
+ * verified log first, and again after a lost race, so a concurrent retry of
36
+ * the same `ref` (a control plane's retry after its own timeout) answers
37
+ * `idempotent` and appends nothing rather than a false refusal.
38
+ *
39
+ * The verb is human-only in the verb registry, so neither `approval serve` nor
40
+ * the MCP wrapper publishes it, and its one intended caller is a root exec on
41
+ * the box running as the store's own uid.
42
+ */
43
+ import { createHash } from "node:crypto";
44
+ import { decide, readGatePolicy, readGateRecords, } from "./gate.js";
45
+ import { tick } from "./clock.js";
46
+ import { recordRefusedDecision } from "./decision-refusal.js";
47
+ import { requestState } from "./state.js";
48
+ /** The environment variable that switches study mode on, read from the process alone. */
49
+ export const STUDY_MODE_ENV = "APPROVAL_STUDY_MODE";
50
+ /** Study mode is on only when {@link STUDY_MODE_ENV} is exactly `1`. */
51
+ export function studyModeOn(env) {
52
+ return env[STUDY_MODE_ENV] === "1";
53
+ }
54
+ /** The actor every study withdrawal is recorded under (the schema pins it). */
55
+ export const STUDY_TEAM_ACTOR = "human:study-team";
56
+ /** The record's `channel` for a study withdrawal (the schema pins it). */
57
+ export const STUDY_CHANNEL = "study";
58
+ /** The record's `payload.note` for a study withdrawal. */
59
+ export const STUDY_WITHDRAW_NOTE = "withdrawn by the study team";
60
+ /**
61
+ * The operator id: 8 lowercase hex the control plane derives from the staff email with a key it
62
+ * alone holds (an HMAC, so a staff list cannot reverse it). Never the email; core checks the shape only.
63
+ */
64
+ export const STUDY_OPERATOR_PATTERN = /^[0-9a-f]{8}$/u;
65
+ /** The withdraw's replay reference, minted once by the operator's tool. */
66
+ export const STUDY_REF_PATTERN = /^[A-Za-z0-9_-]{16,64}$/u;
67
+ /** How many hex characters of the key's sha256 an action ref carries. */
68
+ export const STUDY_ACTION_REF_HEX = 12;
69
+ /** An action ref: the first {@link STUDY_ACTION_REF_HEX} hex of sha256(action key). */
70
+ export const STUDY_ACTION_REF_PATTERN = /^[0-9a-f]{12}$/u;
71
+ /**
72
+ * The short reference an operator names a request by, so that no action key
73
+ * (which can carry text an agent wrote) ever has to leave the box. It is the
74
+ * same 12 hex the Telegram listener's "Looks wrong" line prints
75
+ * (`studyLogRefOf`, a prefix of the callback's `actionRefOf`), so one operator
76
+ * vocabulary covers both study surfaces.
77
+ */
78
+ export function studyActionRefOf(actionKey) {
79
+ return createHash("sha256").update(actionKey, "utf8").digest("hex").slice(0, STUDY_ACTION_REF_HEX);
80
+ }
81
+ /**
82
+ * Every way the study withdraw refuses on its own (SPEC.md §11.1 invariant 6,
83
+ * §11.2 `study_withdraw_refusal_codes`), in evaluation order. Only
84
+ * `not-pending` on a request that exists appends, and it appends one
85
+ * `audit.decision_refused`. A log that cannot be read or written reaches the
86
+ * caller under the gate's own code (`log-unreadable`, `log-torn-tail`,
87
+ * `log-corrupt`, `append-failed`), appends nothing, and is not a member here.
88
+ */
89
+ export const STUDY_WITHDRAW_REFUSAL_CODES = [
90
+ /** The process was not launched with `APPROVAL_STUDY_MODE=1`. Nothing was read. */
91
+ "study-mode-off",
92
+ /** The request is not pending: decided, expired, withdrawn, never requested, or lost a race. */
93
+ "not-pending",
94
+ /** An action ref names more than one pending request. Nothing was decided. */
95
+ "action-ref-ambiguous",
96
+ ];
97
+ /** The gate codes that say the LOG could not be read or written: passed through, never `not-pending`. */
98
+ const LOG_FAULT_CODES = new Set([
99
+ "log-unreadable",
100
+ "log-torn-tail",
101
+ "log-corrupt",
102
+ "append-failed",
103
+ ]);
104
+ function refusal(code, message, extra = {}) {
105
+ return { ok: false, code, message, ...extra };
106
+ }
107
+ function payloadOf(record) {
108
+ const payload = record.payload;
109
+ return typeof payload === "object" && payload !== null ? payload : {};
110
+ }
111
+ function studyOf(record) {
112
+ const study = payloadOf(record)["study"];
113
+ return typeof study === "object" && study !== null && !Array.isArray(study)
114
+ ? study
115
+ : null;
116
+ }
117
+ /** Does the target name this key? A ref matches by its hash prefix. */
118
+ function targets(target, actionKey) {
119
+ return "actionKey" in target
120
+ ? target.actionKey === actionKey
121
+ : studyActionRefOf(actionKey) === target.actionRef;
122
+ }
123
+ /** The earlier withdrawal this `ref` made of the target, if any. */
124
+ function replayOf(records, target, ref) {
125
+ for (const record of records) {
126
+ if (record.event !== "approval.rejected")
127
+ continue;
128
+ if (typeof record.action_key !== "string" || !targets(target, record.action_key))
129
+ continue;
130
+ const study = studyOf(record);
131
+ if (study === null)
132
+ continue;
133
+ if (study["reason"] === "study_withdrawn" && study["ref"] === ref)
134
+ return record;
135
+ }
136
+ return null;
137
+ }
138
+ /**
139
+ * The gate's own code for a request that exists and is not pending: the code
140
+ * `decide` would answer, derived without calling it (a call would also write the
141
+ * gate's lazy expiry record).
142
+ */
143
+ function gateCodeOf(state) {
144
+ if (state === "expired")
145
+ return "expired";
146
+ if (state === "withdrawn")
147
+ return "request-withdrawn";
148
+ return "already-decided";
149
+ }
150
+ /** Every key that has an `approval.requested`, in first-seen order. */
151
+ function requestedKeys(records) {
152
+ const keys = [];
153
+ const seen = new Set();
154
+ for (const record of records) {
155
+ if (record.event !== "approval.requested")
156
+ continue;
157
+ const key = record.action_key;
158
+ if (typeof key !== "string" || key.length === 0 || seen.has(key))
159
+ continue;
160
+ seen.add(key);
161
+ keys.push(key);
162
+ }
163
+ return keys;
164
+ }
165
+ const NOTHING = "Nothing was appended.";
166
+ /**
167
+ * Withdraw one pending request for the study team. See the module header for
168
+ * the four properties; the order of checks is normative (SPEC.md §11.2).
169
+ */
170
+ export function studyWithdraw(logPath, input, options = {}) {
171
+ // 1. The switch, before anything is read.
172
+ if (!studyModeOn(options.env ?? process.env)) {
173
+ return refusal("study-mode-off", `study mode is off: this process was not launched with ${STUDY_MODE_ENV}=1, so no study withdrawal can be recorded. ${NOTHING}`);
174
+ }
175
+ // 2. The verified log. A read fault is the log's, never "not pending".
176
+ const read = readGateRecords(logPath, options.schemaDir);
177
+ if (!read.ok)
178
+ return refusal(read.code, read.message);
179
+ // 3. Replay: the same ref already withdrew this request.
180
+ const earlier = replayOf(read.records, input.target, input.ref);
181
+ if (earlier !== null) {
182
+ return {
183
+ ok: true,
184
+ idempotent: true,
185
+ seq: earlier.seq,
186
+ actionKey: earlier.action_key,
187
+ };
188
+ }
189
+ // 4. Pending, at this instant, under the policy's TTL (the same derivation
190
+ // `approval queue` and the gate use). A lapsed request is `not-pending` with
191
+ // the gate's code `expired`; the gate's lazy expiry record is not written for
192
+ // it here (only the audit record is).
193
+ const ts = tick(options);
194
+ const load = readGatePolicy(options);
195
+ const ttlMs = load.ok ? load.durations.approvalTtlMs : null;
196
+ // The one key the target names. A ref is resolved over every requested key:
197
+ // the pending ones first (so a decided card that shares a ref never shadows a
198
+ // pending one), then all of them, so a too-late withdraw by ref still learns
199
+ // which request it was too late for and can be put on the record.
200
+ let actionKey;
201
+ if ("actionKey" in input.target) {
202
+ actionKey = input.target.actionKey;
203
+ }
204
+ else {
205
+ const target = input.target;
206
+ const named = requestedKeys(read.records).filter((key) => studyActionRefOf(key) === target.actionRef);
207
+ const pending = named.filter((key) => requestState(read.records, key, ts, ttlMs).state === "requested");
208
+ if (pending.length > 1) {
209
+ return refusal("action-ref-ambiguous", `${String(pending.length)} pending requests carry this action ref, so it names no single request. Nothing was decided. ${NOTHING}`, { matches: pending.length });
210
+ }
211
+ if (pending.length === 1) {
212
+ actionKey = pending[0];
213
+ }
214
+ else if (named.length === 1) {
215
+ actionKey = named[0];
216
+ }
217
+ else {
218
+ // No request, or several settled ones (a 48-bit collision among decided
219
+ // cards): there is no one request to account the attempt to.
220
+ return refusal("not-pending", `no pending request carries this action ref; a study withdrawal reaches only a request still awaiting a decision. ${NOTHING}`, { state: "none" });
221
+ }
222
+ }
223
+ const derivation = requestState(read.records, actionKey, ts, ttlMs);
224
+ if (derivation.state === "none") {
225
+ return refusal("not-pending", `no request carries this action key; a study withdrawal reaches only a request still awaiting a decision. ${NOTHING}`, { state: "none" });
226
+ }
227
+ if (derivation.state !== "requested") {
228
+ const gateCode = gateCodeOf(derivation.state);
229
+ return refusedOnRecord(logPath, actionKey, gateCode, `the request is not pending (state ${derivation.state}); a study withdrawal reaches only a request still awaiting a decision`, derivation.state, options);
230
+ }
231
+ // 5. The deny, through the gate's own path: human-only check, fresh
232
+ // derivation under the head-moved retry, schema at the write boundary,
233
+ // compare-and-append. The decision is a constant.
234
+ const decided = decide(logPath, actionKey, "reject", STUDY_TEAM_ACTOR, {
235
+ ...options,
236
+ channel: STUDY_CHANNEL,
237
+ note: STUDY_WITHDRAW_NOTE,
238
+ study: { reason: "study_withdrawn", operator: input.operator, ref: input.ref },
239
+ });
240
+ if (!decided.ok) {
241
+ if (LOG_FAULT_CODES.has(decided.code))
242
+ return refusal(decided.code, decided.message);
243
+ // A concurrent run of this same ref may be what won the race (a control
244
+ // plane retrying after its own timeout): that is this withdrawal, already
245
+ // done, and it answers as the replay it is, with nothing written.
246
+ const again = readGateRecords(logPath, options.schemaDir);
247
+ if (!again.ok)
248
+ return refusal(again.code, again.message);
249
+ const won = replayOf(again.records, { actionKey }, input.ref);
250
+ if (won !== null)
251
+ return { ok: true, idempotent: true, seq: won.seq, actionKey };
252
+ // The one record the gate itself can leave here is the lazy
253
+ // `approval.expired` of a TTL that lapsed inside the window.
254
+ const lapse = decided.record === undefined
255
+ ? ""
256
+ : ` (the gate recorded the lapse it derived: ${decided.record.event}, seq ${String(decided.record.seq)})`;
257
+ return refusedOnRecord(logPath, actionKey, decided.code, `the gate refused the withdrawal (${decided.code}): the request stopped being decidable before the study team's answer could be recorded${lapse}`, decided.state, options, decided.drift);
258
+ }
259
+ return { ok: true, idempotent: false, seq: decided.record.seq, actionKey };
260
+ }
261
+ /**
262
+ * A `not-pending` refusal for a request that exists, put on the record as
263
+ * `approval reject` puts one (cli/gate.ts `commandDecide`): ONE
264
+ * `audit.decision_refused` by the gate, naming `human:study-team` on channel
265
+ * `study` and the gate's own code. Best effort, as there: the refusal stands
266
+ * whatever the write does, and a write that failed is said in the message.
267
+ */
268
+ function refusedOnRecord(logPath, actionKey, gateCode, why, state, options, drift) {
269
+ const recorded = recordRefusedDecision(logPath, { actionKey, decision: "reject", actor: STUDY_TEAM_ACTOR, channel: STUDY_CHANNEL }, { code: gateCode, message: why, ...(drift === undefined ? {} : { drift }) }, options);
270
+ const audit = recorded.ok ? recorded.audit : null;
271
+ const left = audit === null
272
+ ? "The refused attempt could not be put on the record."
273
+ : `The refused attempt is on the record (audit.decision_refused, seq ${String(audit.seq)}).`;
274
+ return refusal("not-pending", `${why}. ${left}`, {
275
+ gateCode,
276
+ ...(state === undefined ? {} : { state }),
277
+ ...(audit === null ? {} : { auditSeq: audit.seq }),
278
+ });
279
+ }
280
+ //# sourceMappingURL=study-withdraw.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"study-withdraw.js","sourceRoot":"","sources":["../../../src/core/study-withdraw.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EACL,MAAM,EACN,cAAc,EACd,eAAe,GAGhB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,OAAO,EAAE,YAAY,EAAqB,MAAM,YAAY,CAAC;AAE7D,yFAAyF;AACzF,MAAM,CAAC,MAAM,cAAc,GAAG,qBAAqB,CAAC;AAEpD,wEAAwE;AACxE,MAAM,UAAU,WAAW,CAAC,GAAiD;IAC3E,OAAO,GAAG,CAAC,cAAc,CAAC,KAAK,GAAG,CAAC;AACrC,CAAC;AAED,+EAA+E;AAC/E,MAAM,CAAC,MAAM,gBAAgB,GAAG,kBAAkB,CAAC;AAEnD,0EAA0E;AAC1E,MAAM,CAAC,MAAM,aAAa,GAAG,OAAO,CAAC;AAErC,0DAA0D;AAC1D,MAAM,CAAC,MAAM,mBAAmB,GAAG,6BAA6B,CAAC;AAEjE;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,gBAAgB,CAAC;AAEvD,2EAA2E;AAC3E,MAAM,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,GAAG,EAAE,SAAS,EAAE,CAAC;AAC7E,CAAC;AAED;;;;;;GAMG;AACH,SAAS,eAAe,CACtB,OAAe,EACf,SAAiB,EACjB,QAAyB,EACzB,GAAW,EACX,KAA+B,EAC/B,OAA6B,EAC7B,KAA+C;IAE/C,MAAM,QAAQ,GAAG,qBAAqB,CACpC,OAAO,EACP,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,aAAa,EAAE,EAClF,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAC3E,OAAO,CACR,CAAC;IACF,MAAM,KAAK,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;IAClD,MAAM,IAAI,GACR,KAAK,KAAK,IAAI;QACZ,CAAC,CAAC,qDAAqD;QACvD,CAAC,CAAC,qEAAqE,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC;IACjG,OAAO,OAAO,CAAC,aAAa,EAAE,GAAG,GAAG,KAAK,IAAI,EAAE,EAAE;QAC/C,QAAQ;QACR,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC;QACzC,GAAG,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC;KACnD,CAAC,CAAC;AACL,CAAC"}
@@ -71,9 +71,9 @@ import type { LogHead } from "../core/log.js";
71
71
  * because a module that resolves its own package root differs between the source
72
72
  * tree and the build output for no benefit at all.
73
73
  */
74
- export declare const APPROVALD_VERSION = "0.4.6";
74
+ export declare const APPROVALD_VERSION = "0.4.7";
75
75
  /** `user.name` on every commit this module makes. */
76
- export declare const GIT_EVIDENCE_AUTHOR_NAME = "approvald 0.4.6";
76
+ export declare const GIT_EVIDENCE_AUTHOR_NAME = "approvald 0.4.7";
77
77
  /** `user.email` on every commit: fixed, and deliberately undeliverable. */
78
78
  export declare const GIT_EVIDENCE_AUTHOR_EMAIL = "approvald@noreply.approval.md";
79
79
  /**
@@ -75,7 +75,7 @@ import { PAYLOAD_STORE_DIRNAME } from "../core/payload-store.js";
75
75
  * because a module that resolves its own package root differs between the source
76
76
  * tree and the build output for no benefit at all.
77
77
  */
78
- export const APPROVALD_VERSION = "0.4.6";
78
+ export const APPROVALD_VERSION = "0.4.7";
79
79
  /** `user.name` on every commit this module makes. */
80
80
  export const GIT_EVIDENCE_AUTHOR_NAME = `approvald ${APPROVALD_VERSION}`;
81
81
  /** `user.email` on every commit: fixed, and deliberately undeliverable. */
@@ -593,7 +593,7 @@ export function createApprovalMcpServer(options) {
593
593
  const name = request.params.name;
594
594
  const spec = byName.get(name);
595
595
  if (spec === undefined) {
596
- const human = VERB_REGISTRY.find((candidate) => toolName(candidate) === name && candidate.human_only);
596
+ const human = VERB_REGISTRY.find((candidate) => toolName(candidate) === name && candidate.human_only && candidate.operator_only !== true);
597
597
  if (human !== undefined) {
598
598
  // Checked FIRST, and the same answer for a guest as for anyone else:
599
599
  // this verb records a human's authority, which is true of no session on
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../../../src/mcp/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAEnE,OAAO,EACL,qBAAqB,EACrB,SAAS,EACT,sBAAsB,EACtB,QAAQ,GAGT,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,cAAc,EAA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I,EAAE,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QACjE,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC;YACd,MAAM,IAAI,QAAQ,CAAC,SAAS,CAAC,aAAa,EAAE,GAAG,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QACjF,CAAC;QAED,OAAO,UAAU,CAAC,MAAM,SAAS,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IAClF,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,+EAA+E;AAC/E,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,OAAsB,EACtB,SAAoB;IAEpB,MAAM,MAAM,GAAG,uBAAuB,CAAC,OAAO,CAAC,CAAC;IAChD,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -2089,6 +2089,69 @@ success {"ok":true,"task":"...","action_key":"...","state":"withdrawn",
2089
2089
  refusal {"ok":false,"error":{"code":"...","message":"...","state"?:"..."}}
2090
2090
  ```
2091
2091
 
2092
+ ## study withdraw
2093
+
2094
+ A hosted study operator DENIES one request that is still pending, before it can
2095
+ run (SPEC.md §8, the study record). It is the only way a `study_withdrawn`
2096
+ record is written: a channel may pass `looks_wrong` and nothing else.
2097
+
2098
+ **Off unless switched on at launch.** The verb refuses `study-mode-off` before it
2099
+ opens the log unless the process environment holds `APPROVAL_STUDY_MODE`
2100
+ exactly `1`. The switch is never read from a policy, because nothing an agent
2101
+ can propose into a policy file may turn it on. `--help` answers either way, so a
2102
+ control plane can probe whether the installed CLI has the verb.
2103
+
2104
+ **Deny-only, constant identity.** There is no `--as`, no decision flag and no
2105
+ note. The record is one `approval.rejected` by `human:study-team` on channel
2106
+ `study`, with `payload.note` "withdrawn by the study team" and `payload.study`
2107
+ `{reason: "study_withdrawn", operator, ref}`. `--operator` is 8 lowercase hex: a
2108
+ pseudonymous id the control plane derives from the operator's staff email under
2109
+ a key it alone holds (an HMAC), never the email. Core checks only its shape.
2110
+
2111
+ **Pending-only, and a too-late withdrawal is on the record.** A request that is
2112
+ granted, rejected, revoked, expired, withdrawn or never requested is refused
2113
+ `not-pending`. The gate's `decide` re-derives the state under its head-moved
2114
+ retry, so a resident's tap that lands between the verb's read and its append
2115
+ wins and the withdrawal becomes `not-pending`. The gate's own code
2116
+ (`already-decided`, `expired`, `request-withdrawn`, or what `decide` answered)
2117
+ rides as `gate_code`. As with `approval reject`, a refusal for a request that
2118
+ exists appends ONE `audit.decision_refused` by `system:gate`, naming
2119
+ `human:study-team` on channel `study` and that code, so the study's own record
2120
+ shows the attempt. It carries no operator id (the operator is in the control
2121
+ plane's log line). Nothing is appended for `study-mode-off`, a replay, an
2122
+ `action-ref-ambiguous`, a key or ref naming no request, or a log fault.
2123
+
2124
+ **Replay-safe.** The `--ref` is matched against the verified log first, and
2125
+ again when the gate refuses after a lost race, so a concurrent retry of the same
2126
+ ref (a control plane retrying after its own timeout) is not mistaken for a
2127
+ too-late one. The same ref again for the same request answers
2128
+ `idempotent: true` with the earlier record's seq, and appends nothing. A ref is
2129
+ unique per withdrawal by convention (the operator's tool mints a fresh one):
2130
+ the same ref on a different request is a new withdrawal.
2131
+
2132
+ **Name by key or by ref.** `--action-ref` is the first 12 hex of the SHA-256 of
2133
+ the action key (the same 12 hex the Telegram listener's "Looks wrong" line
2134
+ prints), so a control plane never has to carry an action key off the box. More
2135
+ than one pending request under one ref is `action-ref-ambiguous`. A ref that
2136
+ names no pending request but exactly one settled one is resolved to it, so a
2137
+ too-late withdrawal by ref is recorded against that request.
2138
+
2139
+ **Not published.** The registry marks the verb human-only, so neither `approval
2140
+ serve` nor `approval mcp serve` offers it, and operator-only, so the agent's
2141
+ guide (`approval instructions`, its `--json` and `--schemas`) does not list it. Its caller is a root exec running as
2142
+ the store's own uid. The Telegram listener edits the resident's card on its next
2143
+ cycle to "WITHDRAWN BY THE STUDY TEAM" with "withdrawn by the study team at
2144
+ HH:MM UTC · nothing ran", and takes the buttons away. The requester's `wait`
2145
+ exits 1 (rejected).
2146
+
2147
+ **`--json`** (one line; the action key is never printed):
2148
+
2149
+ ```
2150
+ success {"ok":true,"idempotent":false,"seq":12}
2151
+ refusal {"ok":false,"error":{"code":"not-pending","message":"...",
2152
+ "state"?:"...","gate_code"?:"...","matches"?:2}}
2153
+ ```
2154
+
2092
2155
  ## expire
2093
2156
 
2094
2157
  No identity is accepted or resolved: no human decides an expiry, the clock does,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "approval-md",
3
- "version": "0.4.6",
3
+ "version": "0.4.7",
4
4
  "description": "Human approval for agent actions. CLI runtime for the approval.md convention (pre-release).",
5
5
  "type": "module",
6
6
  "bin": {
@@ -59,5 +59,5 @@
59
59
  "better-sqlite3": "12.11.1",
60
60
  "yaml": "2.9.0"
61
61
  },
62
- "gitHead": "539cf3b6b847b0446730ed110b7f188660f2a9d7"
62
+ "gitHead": "eaa762237b6d8303ca791f70dcf9d6831dece5aa"
63
63
  }