@fungi.computer/approvals 0.1.0 → 0.2.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.
- package/dist/contract.d.ts +8 -0
- package/dist/contract.js +6 -0
- package/dist/denial-message.d.ts +3 -0
- package/dist/denial-message.js +8 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/ledger.d.ts +2 -0
- package/dist/ledger.js +21 -9
- package/docs/api/README.md +163 -58
- package/package.json +1 -1
package/dist/contract.d.ts
CHANGED
|
@@ -39,6 +39,10 @@ export type PendingApproval = typeof PendingApprovalSchema.Type;
|
|
|
39
39
|
export declare const ApprovalStateSchema: Schema.Literals<readonly ["requested", "pending", "approved", "claimed", "applied", "denied", "expired", "outcome_unknown"]>;
|
|
40
40
|
/** Why a decision or apply was refused; unknown dispatch is never a denial. */
|
|
41
41
|
export declare const ApprovalRefusalReasonSchema: Schema.Literals<readonly ["not-found", "not-eligible", "already-answered", "stale-revision", "expired", "declined", "fenced", "not-granted", "read-only", "pending", "in-flight", "outcome-unknown", "identity-conflict"]>;
|
|
42
|
+
/** Human explanation for a denied approval; distinct from the typed refusal cause. */
|
|
43
|
+
export declare const MAX_APPROVAL_DENIAL_NOTE_LENGTH = 512;
|
|
44
|
+
/** Bounded nonempty human feedback; user text, never approval authority. */
|
|
45
|
+
export declare const ApprovalDenialNoteSchema: Schema.String;
|
|
42
46
|
/** Defensive display limits, not authority to fetch or interpret image content. */
|
|
43
47
|
export declare const MAX_APPROVAL_EVIDENCE = 4;
|
|
44
48
|
/** Maximum attested PNG byte length in one evidence descriptor. */
|
|
@@ -85,6 +89,7 @@ export declare const ApprovalRecordSchema: Schema.Struct<{
|
|
|
85
89
|
readonly kind: Schema.Literal<"policy">;
|
|
86
90
|
}>]>>;
|
|
87
91
|
readonly reason: Schema.NullOr<Schema.Literals<readonly ["not-found", "not-eligible", "already-answered", "stale-revision", "expired", "declined", "fenced", "not-granted", "read-only", "pending", "in-flight", "outcome-unknown", "identity-conflict"]>>;
|
|
92
|
+
readonly denialNote: Schema.optionalKey<Schema.String>;
|
|
88
93
|
readonly requestedAt: Schema.Int;
|
|
89
94
|
readonly expiresAt: Schema.Int;
|
|
90
95
|
readonly updatedAt: Schema.Int;
|
|
@@ -124,6 +129,7 @@ export declare const ApprovalViewSchema: Schema.Struct<{
|
|
|
124
129
|
readonly kind: Schema.Literal<"policy">;
|
|
125
130
|
}>]>>;
|
|
126
131
|
readonly reason: Schema.NullOr<Schema.Literals<readonly ["not-found", "not-eligible", "already-answered", "stale-revision", "expired", "declined", "fenced", "not-granted", "read-only", "pending", "in-flight", "outcome-unknown", "identity-conflict"]>>;
|
|
132
|
+
readonly denialNote: Schema.optionalKey<Schema.String>;
|
|
127
133
|
readonly requestedAt: Schema.Int;
|
|
128
134
|
readonly expiresAt: Schema.Int;
|
|
129
135
|
readonly updatedAt: Schema.Int;
|
|
@@ -147,6 +153,7 @@ export declare const ApprovalAnswerInputSchema: Schema.Struct<{
|
|
|
147
153
|
readonly recordId: Schema.String;
|
|
148
154
|
readonly decision: Schema.Literals<readonly ["approve", "deny"]>;
|
|
149
155
|
readonly expectedRevision: Schema.Int;
|
|
156
|
+
readonly denialNote: Schema.optionalKey<Schema.String>;
|
|
150
157
|
}>;
|
|
151
158
|
/** Explicit policy mutation. A false rule narrows a broader true rule. */
|
|
152
159
|
export declare const AutoApproveInputSchema: Schema.Struct<{
|
|
@@ -173,6 +180,7 @@ export type AutoApproveInput = typeof AutoApproveInputSchema.Type;
|
|
|
173
180
|
export type ApprovalRefusal = Readonly<{
|
|
174
181
|
kind: "refused";
|
|
175
182
|
reason: typeof ApprovalRefusalReasonSchema.Type;
|
|
183
|
+
denialNote?: typeof ApprovalDenialNoteSchema.Type;
|
|
176
184
|
}>;
|
|
177
185
|
/** The member-bound capability. Host authentication supplies the actor. */
|
|
178
186
|
export type Approvals = Readonly<{
|
package/dist/contract.js
CHANGED
|
@@ -59,6 +59,10 @@ export const ApprovalRefusalReasonSchema = Schema.Literals([
|
|
|
59
59
|
"outcome-unknown",
|
|
60
60
|
"identity-conflict",
|
|
61
61
|
]);
|
|
62
|
+
/** Human explanation for a denied approval; distinct from the typed refusal cause. */
|
|
63
|
+
export const MAX_APPROVAL_DENIAL_NOTE_LENGTH = 512;
|
|
64
|
+
/** Bounded nonempty human feedback; user text, never approval authority. */
|
|
65
|
+
export const ApprovalDenialNoteSchema = Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(MAX_APPROVAL_DENIAL_NOTE_LENGTH), Schema.isPattern(/^(?=.*\S)[^\p{Cc}\u2028\u2029]*$/u));
|
|
62
66
|
/** Defensive display limits, not authority to fetch or interpret image content. */
|
|
63
67
|
export const MAX_APPROVAL_EVIDENCE = 4;
|
|
64
68
|
/** Maximum attested PNG byte length in one evidence descriptor. */
|
|
@@ -87,6 +91,7 @@ export const ApprovalRecordSchema = Schema.Struct({
|
|
|
87
91
|
Schema.Struct({ kind: Schema.Literal("policy") }),
|
|
88
92
|
])),
|
|
89
93
|
reason: Schema.NullOr(ApprovalRefusalReasonSchema),
|
|
94
|
+
denialNote: Schema.optionalKey(ApprovalDenialNoteSchema),
|
|
90
95
|
requestedAt: Timestamp,
|
|
91
96
|
expiresAt: Timestamp,
|
|
92
97
|
updatedAt: Timestamp,
|
|
@@ -111,6 +116,7 @@ export const ApprovalAnswerInputSchema = Schema.Struct({
|
|
|
111
116
|
recordId: Identity,
|
|
112
117
|
decision: Schema.Literals(["approve", "deny"]),
|
|
113
118
|
expectedRevision: Revision,
|
|
119
|
+
denialNote: Schema.optionalKey(ApprovalDenialNoteSchema),
|
|
114
120
|
});
|
|
115
121
|
/** Explicit policy mutation. A false rule narrows a broader true rule. */
|
|
116
122
|
export const AutoApproveInputSchema = Schema.Struct({
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Host-supplied human identity; the bounded reason remains quoted user text. */
|
|
2
|
+
export function denialFeedbackOpening(record, person) {
|
|
3
|
+
return record.state === "denied" &&
|
|
4
|
+
record.by?.kind === "human" &&
|
|
5
|
+
record.denialNote !== undefined
|
|
6
|
+
? `Denied by ${JSON.stringify(person)}: ${JSON.stringify(record.denialNote)}`
|
|
7
|
+
: null;
|
|
8
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export * from "./contract.js";
|
|
2
|
+
export { denialFeedbackOpening } from "./denial-message.js";
|
|
2
3
|
export { ApprovalLedger, ApprovalRefusalSchema, DEFAULT_APPROVAL_EXPIRY_MS, type AutoApproveQuery, type ApprovalHome, type ApprovalRequest, type ApprovalAnswerer, type ApprovalAdmission, type ApprovalRuleSetter, type ApprovalApplyHost, type ApprovalSubmitHost, type ApprovalDispatchCompletion, type ApprovalApplyResult, type ApprovalResultNotice, type ApprovalHandoffResult, } from "./ledger.js";
|
package/dist/index.js
CHANGED
package/dist/ledger.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { type ApprovalEvidence, type ApprovalRecord, type Approvals, type Approv
|
|
|
5
5
|
export declare const ApprovalRefusalSchema: Schema.Struct<{
|
|
6
6
|
readonly kind: Schema.Literal<"refused">;
|
|
7
7
|
readonly reason: Schema.Literals<readonly ["not-found", "not-eligible", "already-answered", "stale-revision", "expired", "declined", "fenced", "not-granted", "read-only", "pending", "in-flight", "outcome-unknown", "identity-conflict"]>;
|
|
8
|
+
readonly denialNote: Schema.optionalKey<Schema.String>;
|
|
8
9
|
}>;
|
|
9
10
|
/** Native owner of this ledger; the Local runtime supplies its own SQLite owner. */
|
|
10
11
|
export type ApprovalHome = Readonly<{
|
|
@@ -202,6 +203,7 @@ export declare class ApprovalLedger {
|
|
|
202
203
|
private finishDenied;
|
|
203
204
|
/** Native host boot only: orphaned durable claims must never be redispatched. */
|
|
204
205
|
recoverClaims(): readonly ApprovalRecord[];
|
|
206
|
+
private deniedResult;
|
|
205
207
|
private payload;
|
|
206
208
|
private save;
|
|
207
209
|
/** Read a record from this home only; the maintained decoder owns stored JSON. */
|
package/dist/ledger.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import * as Schema from "effect/Schema";
|
|
2
|
-
import { ApprovalRecordSchema, ApprovalEvidenceSchema, ApprovalRefusalReasonSchema, ApprovalGetInputSchema, ApprovalListInputSchema, ApprovalAnswerInputSchema, AutoApproveInputSchema, } from "./contract.js";
|
|
2
|
+
import { ApprovalRecordSchema, ApprovalEvidenceSchema, ApprovalRefusalReasonSchema, ApprovalDenialNoteSchema, ApprovalGetInputSchema, ApprovalListInputSchema, ApprovalAnswerInputSchema, AutoApproveInputSchema, } from "./contract.js";
|
|
3
3
|
/** Canonical zero-effect or lifecycle refusal at a tool result boundary. */
|
|
4
4
|
export const ApprovalRefusalSchema = Schema.Struct({
|
|
5
5
|
kind: Schema.Literal("refused"),
|
|
6
6
|
reason: ApprovalRefusalReasonSchema,
|
|
7
|
+
denialNote: Schema.optionalKey(ApprovalDenialNoteSchema),
|
|
7
8
|
});
|
|
8
9
|
const defaultAutoApprove = {
|
|
9
10
|
team: false,
|
|
@@ -174,7 +175,7 @@ export class ApprovalLedger {
|
|
|
174
175
|
return { kind: "applied", record, output: decodeJson(output) };
|
|
175
176
|
}
|
|
176
177
|
case "denied":
|
|
177
|
-
return
|
|
178
|
+
return this.deniedResult(record);
|
|
178
179
|
case "expired":
|
|
179
180
|
return { kind: "refused", reason: "expired" };
|
|
180
181
|
case "outcome_unknown":
|
|
@@ -269,6 +270,8 @@ export class ApprovalLedger {
|
|
|
269
270
|
answer(input, actor) {
|
|
270
271
|
if (!this.eligible(actor))
|
|
271
272
|
return { kind: "refused", reason: "not-eligible" };
|
|
273
|
+
if (input.decision !== "deny" && input.denialNote !== undefined)
|
|
274
|
+
return { kind: "refused", reason: "not-eligible" };
|
|
272
275
|
return this.options.owner.transactionSync(() => {
|
|
273
276
|
const record = this.get(input.recordId);
|
|
274
277
|
if (record === null)
|
|
@@ -287,8 +290,11 @@ export class ApprovalLedger {
|
|
|
287
290
|
revision: record.revision + 1,
|
|
288
291
|
updatedAt: this.options.now(),
|
|
289
292
|
};
|
|
290
|
-
|
|
291
|
-
|
|
293
|
+
const result = input.decision === "deny" && input.denialNote !== undefined
|
|
294
|
+
? { ...answered, denialNote: input.denialNote }
|
|
295
|
+
: answered;
|
|
296
|
+
this.save(result);
|
|
297
|
+
return { kind: "answered", record: result };
|
|
292
298
|
});
|
|
293
299
|
}
|
|
294
300
|
/** Policy changes are attributed; an Agent can never enable its own writes. */
|
|
@@ -427,7 +433,7 @@ export class ApprovalLedger {
|
|
|
427
433
|
break;
|
|
428
434
|
}
|
|
429
435
|
case "denied":
|
|
430
|
-
result =
|
|
436
|
+
result = this.deniedResult(record);
|
|
431
437
|
break;
|
|
432
438
|
case "expired":
|
|
433
439
|
result = { kind: "refused", reason: "expired" };
|
|
@@ -510,10 +516,7 @@ export class ApprovalLedger {
|
|
|
510
516
|
if (record.state === "expired")
|
|
511
517
|
return { kind: "refused", reason: "expired" };
|
|
512
518
|
if (record.state === "denied")
|
|
513
|
-
return
|
|
514
|
-
kind: "refused",
|
|
515
|
-
reason: record.reason ?? "declined",
|
|
516
|
-
};
|
|
519
|
+
return this.deniedResult(record);
|
|
517
520
|
if (record.state === "claimed")
|
|
518
521
|
return {
|
|
519
522
|
kind: "refused",
|
|
@@ -629,6 +632,15 @@ export class ApprovalLedger {
|
|
|
629
632
|
});
|
|
630
633
|
});
|
|
631
634
|
}
|
|
635
|
+
deniedResult(record) {
|
|
636
|
+
const refusal = {
|
|
637
|
+
kind: "refused",
|
|
638
|
+
reason: record.reason ?? "declined",
|
|
639
|
+
};
|
|
640
|
+
return record.denialNote === undefined
|
|
641
|
+
? refusal
|
|
642
|
+
: { ...refusal, denialNote: record.denialNote };
|
|
643
|
+
}
|
|
632
644
|
payload(recordId) {
|
|
633
645
|
const raw = this.options.owner.sql
|
|
634
646
|
.exec("SELECT input_json, output_json FROM approval_payloads WHERE home_key = ? AND record_id = ?", this.homeKey, recordId)
|
package/docs/api/README.md
CHANGED
|
@@ -104,32 +104,33 @@ A retried request's current outcome, without claiming any work.
|
|
|
104
104
|
|
|
105
105
|
###### Parameters
|
|
106
106
|
|
|
107
|
-
| Parameter | Type
|
|
108
|
-
| -------------------------------- |
|
|
109
|
-
| `record` | \{ `recordId`: `string`; `requester`: \{ `principalId`: `string`; `agentId`: `string` \| `null`; `sessionId`: `string` \| `null`; `displayName`: `string`; \}; `module`: `string`; `operation`: `string`; `access`: `"write"` \| `"external"`; `description`: \{ `title`: `string`; `inputBytes`: `number`; `inputSha256`: `string`; \}; `evidence?`: readonly `object`[]; `authorityFence`: `string`; `reversibility`: `"reversible"` \| `"irreversible-external"`; `state`: \| `"pending"` \| `"expired"` \| `"denied"` \| `"requested"` \| `"approved"` \| `"claimed"` \| `"applied"` \| `"outcome_unknown"`; `by`: \| \{ `kind`: `"human"`; `memberId`: `string`; \} \| \{ `kind`: `"policy"`; \} \| `null`; `reason`: \| `"pending"` \| `"expired"` \| `"not-found"` \| `"not-eligible"` \| `"already-answered"` \| `"stale-revision"` \| `"declined"` \| `"fenced"` \| `"not-granted"` \| `"read-only"` \| `"in-flight"` \| `"outcome-unknown"` \| `"identity-conflict"` \| `null`; `requestedAt`: `number`; `expiresAt`: `number`; `updatedAt`: `number`; `revision`: `number`; \} |
|
|
110
|
-
| `record.recordId` | `string`
|
|
111
|
-
| `record.requester` | \{ `principalId`: `string`; `agentId`: `string` \| `null`; `sessionId`: `string` \| `null`; `displayName`: `string`; \}
|
|
112
|
-
| `record.requester.principalId` | `string`
|
|
113
|
-
| `record.requester.agentId` | `string` \| `null`
|
|
114
|
-
| `record.requester.sessionId` | `string` \| `null`
|
|
115
|
-
| `record.requester.displayName` | `string`
|
|
116
|
-
| `record.module` | `string`
|
|
117
|
-
| `record.operation` | `string`
|
|
118
|
-
| `record.access` | `"write"` \| `"external"`
|
|
119
|
-
| `record.description` | \{ `title`: `string`; `inputBytes`: `number`; `inputSha256`: `string`; \}
|
|
120
|
-
| `record.description.title` | `string`
|
|
121
|
-
| `record.description.inputBytes` | `number`
|
|
122
|
-
| `record.description.inputSha256` | `string`
|
|
123
|
-
| `record.evidence?` | readonly `object`[]
|
|
124
|
-
| `record.authorityFence` | `string`
|
|
125
|
-
| `record.reversibility` | `"reversible"` \| `"irreversible-external"`
|
|
126
|
-
| `record.state` | \| `"pending"` \| `"expired"` \| `"denied"` \| `"requested"` \| `"approved"` \| `"claimed"` \| `"applied"` \| `"outcome_unknown"`
|
|
127
|
-
| `record.by` | \| \{ `kind`: `"human"`; `memberId`: `string`; \} \| \{ `kind`: `"policy"`; \} \| `null`
|
|
128
|
-
| `record.reason` | \| `"pending"` \| `"expired"` \| `"not-found"` \| `"not-eligible"` \| `"already-answered"` \| `"stale-revision"` \| `"declined"` \| `"fenced"` \| `"not-granted"` \| `"read-only"` \| `"in-flight"` \| `"outcome-unknown"` \| `"identity-conflict"` \| `null`
|
|
129
|
-
| `record.
|
|
130
|
-
| `record.
|
|
131
|
-
| `record.
|
|
132
|
-
| `record.
|
|
107
|
+
| Parameter | Type |
|
|
108
|
+
| -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
109
|
+
| `record` | \{ `recordId`: `string`; `requester`: \{ `principalId`: `string`; `agentId`: `string` \| `null`; `sessionId`: `string` \| `null`; `displayName`: `string`; \}; `module`: `string`; `operation`: `string`; `access`: `"write"` \| `"external"`; `description`: \{ `title`: `string`; `inputBytes`: `number`; `inputSha256`: `string`; \}; `evidence?`: readonly `object`[]; `authorityFence`: `string`; `reversibility`: `"reversible"` \| `"irreversible-external"`; `state`: \| `"pending"` \| `"expired"` \| `"denied"` \| `"requested"` \| `"approved"` \| `"claimed"` \| `"applied"` \| `"outcome_unknown"`; `by`: \| \{ `kind`: `"human"`; `memberId`: `string`; \} \| \{ `kind`: `"policy"`; \} \| `null`; `reason`: \| `"pending"` \| `"expired"` \| `"not-found"` \| `"not-eligible"` \| `"already-answered"` \| `"stale-revision"` \| `"declined"` \| `"fenced"` \| `"not-granted"` \| `"read-only"` \| `"in-flight"` \| `"outcome-unknown"` \| `"identity-conflict"` \| `null`; `denialNote?`: `string`; `requestedAt`: `number`; `expiresAt`: `number`; `updatedAt`: `number`; `revision`: `number`; \} |
|
|
110
|
+
| `record.recordId` | `string` |
|
|
111
|
+
| `record.requester` | \{ `principalId`: `string`; `agentId`: `string` \| `null`; `sessionId`: `string` \| `null`; `displayName`: `string`; \} |
|
|
112
|
+
| `record.requester.principalId` | `string` |
|
|
113
|
+
| `record.requester.agentId` | `string` \| `null` |
|
|
114
|
+
| `record.requester.sessionId` | `string` \| `null` |
|
|
115
|
+
| `record.requester.displayName` | `string` |
|
|
116
|
+
| `record.module` | `string` |
|
|
117
|
+
| `record.operation` | `string` |
|
|
118
|
+
| `record.access` | `"write"` \| `"external"` |
|
|
119
|
+
| `record.description` | \{ `title`: `string`; `inputBytes`: `number`; `inputSha256`: `string`; \} |
|
|
120
|
+
| `record.description.title` | `string` |
|
|
121
|
+
| `record.description.inputBytes` | `number` |
|
|
122
|
+
| `record.description.inputSha256` | `string` |
|
|
123
|
+
| `record.evidence?` | readonly `object`[] |
|
|
124
|
+
| `record.authorityFence` | `string` |
|
|
125
|
+
| `record.reversibility` | `"reversible"` \| `"irreversible-external"` |
|
|
126
|
+
| `record.state` | \| `"pending"` \| `"expired"` \| `"denied"` \| `"requested"` \| `"approved"` \| `"claimed"` \| `"applied"` \| `"outcome_unknown"` |
|
|
127
|
+
| `record.by` | \| \{ `kind`: `"human"`; `memberId`: `string`; \} \| \{ `kind`: `"policy"`; \} \| `null` |
|
|
128
|
+
| `record.reason` | \| `"pending"` \| `"expired"` \| `"not-found"` \| `"not-eligible"` \| `"already-answered"` \| `"stale-revision"` \| `"declined"` \| `"fenced"` \| `"not-granted"` \| `"read-only"` \| `"in-flight"` \| `"outcome-unknown"` \| `"identity-conflict"` \| `null` |
|
|
129
|
+
| `record.denialNote?` | `string` |
|
|
130
|
+
| `record.requestedAt` | `number` |
|
|
131
|
+
| `record.expiresAt` | `number` |
|
|
132
|
+
| `record.updatedAt` | `number` |
|
|
133
|
+
| `record.revision` | `number` |
|
|
133
134
|
|
|
134
135
|
###### Returns
|
|
135
136
|
|
|
@@ -156,6 +157,7 @@ request(input, evidence?): Promise<
|
|
|
156
157
|
| "in-flight"
|
|
157
158
|
| "outcome-unknown"
|
|
158
159
|
| "identity-conflict";
|
|
160
|
+
denialNote?: string;
|
|
159
161
|
}>
|
|
160
162
|
| Readonly<{
|
|
161
163
|
kind: "record";
|
|
@@ -208,6 +210,7 @@ request(input, evidence?): Promise<
|
|
|
208
210
|
| "outcome-unknown"
|
|
209
211
|
| "identity-conflict"
|
|
210
212
|
| null;
|
|
213
|
+
denialNote?: string;
|
|
211
214
|
requestedAt: number;
|
|
212
215
|
expiresAt: number;
|
|
213
216
|
updatedAt: number;
|
|
@@ -233,21 +236,22 @@ action; created says whether this call staged the record.
|
|
|
233
236
|
`"expired"` \| `"not-found"` \| `"not-eligible"` \| `"already-answered"` \|
|
|
234
237
|
`"stale-revision"` \| `"declined"` \| `"fenced"` \| `"not-granted"` \|
|
|
235
238
|
`"read-only"` \| `"in-flight"` \| `"outcome-unknown"` \| `"identity-conflict"`;
|
|
236
|
-
\}\> \| `Readonly`\<\{ `kind`: `"record"`; `record`: \{
|
|
237
|
-
`requester`: \{ `principalId`: `string`; `agentId`:
|
|
238
|
-
`sessionId`: `string` \| `null`; `displayName`: `string`;
|
|
239
|
-
`string`; `operation`: `string`; `access`: `"write"` \|
|
|
240
|
-
`description`: \{ `title`: `string`; `inputBytes`: `number`;
|
|
241
|
-
`string`; \}; `evidence?`: readonly `object`[]; `authorityFence`:
|
|
242
|
-
`reversibility`: `"reversible"` \| `"irreversible-external"`; `state`:
|
|
243
|
-
`"pending"` \| `"expired"` \| `"denied"` \| `"requested"` \| `"approved"` \|
|
|
239
|
+
`denialNote?`: `string`; \}\> \| `Readonly`\<\{ `kind`: `"record"`; `record`: \{
|
|
240
|
+
`recordId`: `string`; `requester`: \{ `principalId`: `string`; `agentId`:
|
|
241
|
+
`string` \| `null`; `sessionId`: `string` \| `null`; `displayName`: `string`;
|
|
242
|
+
\}; `module`: `string`; `operation`: `string`; `access`: `"write"` \|
|
|
243
|
+
`"external"`; `description`: \{ `title`: `string`; `inputBytes`: `number`;
|
|
244
|
+
`inputSha256`: `string`; \}; `evidence?`: readonly `object`[]; `authorityFence`:
|
|
245
|
+
`string`; `reversibility`: `"reversible"` \| `"irreversible-external"`; `state`:
|
|
246
|
+
\| `"pending"` \| `"expired"` \| `"denied"` \| `"requested"` \| `"approved"` \|
|
|
244
247
|
`"claimed"` \| `"applied"` \| `"outcome_unknown"`; `by`: \| \{ `kind`:
|
|
245
248
|
`"human"`; `memberId`: `string`; \} \| \{ `kind`: `"policy"`; \} \| `null`;
|
|
246
249
|
`reason`: \| `"pending"` \| `"expired"` \| `"not-found"` \| `"not-eligible"` \|
|
|
247
250
|
`"already-answered"` \| `"stale-revision"` \| `"declined"` \| `"fenced"` \|
|
|
248
251
|
`"not-granted"` \| `"read-only"` \| `"in-flight"` \| `"outcome-unknown"` \|
|
|
249
|
-
`"identity-conflict"` \| `null`; `
|
|
250
|
-
`
|
|
252
|
+
`"identity-conflict"` \| `null`; `denialNote?`: `string`; `requestedAt`:
|
|
253
|
+
`number`; `expiresAt`: `number`; `updatedAt`: `number`; `revision`: `number`;
|
|
254
|
+
\}; `created`: `boolean`; \}\>\>
|
|
251
255
|
|
|
252
256
|
##### answer()
|
|
253
257
|
|
|
@@ -268,6 +272,7 @@ answer(input, actor):
|
|
|
268
272
|
| "in-flight"
|
|
269
273
|
| "outcome-unknown"
|
|
270
274
|
| "identity-conflict";
|
|
275
|
+
denialNote?: string;
|
|
271
276
|
}>
|
|
272
277
|
| Readonly<{
|
|
273
278
|
kind: "answered";
|
|
@@ -320,6 +325,7 @@ answer(input, actor):
|
|
|
320
325
|
| "outcome-unknown"
|
|
321
326
|
| "identity-conflict"
|
|
322
327
|
| null;
|
|
328
|
+
denialNote?: string;
|
|
323
329
|
requestedAt: number;
|
|
324
330
|
expiresAt: number;
|
|
325
331
|
updatedAt: number;
|
|
@@ -333,13 +339,14 @@ grants.
|
|
|
333
339
|
|
|
334
340
|
###### Parameters
|
|
335
341
|
|
|
336
|
-
| Parameter | Type
|
|
337
|
-
| ------------------------ |
|
|
338
|
-
| `input` | \{ `recordId`: `string`; `decision`: `"approve"` \| `"deny"`; `expectedRevision`: `number`; \} |
|
|
339
|
-
| `input.recordId` | `string`
|
|
340
|
-
| `input.decision` | `"approve"` \| `"deny"`
|
|
341
|
-
| `input.expectedRevision` | `number`
|
|
342
|
-
| `
|
|
342
|
+
| Parameter | Type |
|
|
343
|
+
| ------------------------ | ----------------------------------------------------------------------------------------------------------------------- |
|
|
344
|
+
| `input` | \{ `recordId`: `string`; `decision`: `"approve"` \| `"deny"`; `expectedRevision`: `number`; `denialNote?`: `string`; \} |
|
|
345
|
+
| `input.recordId` | `string` |
|
|
346
|
+
| `input.decision` | `"approve"` \| `"deny"` |
|
|
347
|
+
| `input.expectedRevision` | `number` |
|
|
348
|
+
| `input.denialNote?` | `string` |
|
|
349
|
+
| `actor` | [`ApprovalAnswerer`](#approvalanswerer) \| `null` |
|
|
343
350
|
|
|
344
351
|
###### Returns
|
|
345
352
|
|
|
@@ -347,21 +354,22 @@ grants.
|
|
|
347
354
|
\| `"not-found"` \| `"not-eligible"` \| `"already-answered"` \|
|
|
348
355
|
`"stale-revision"` \| `"declined"` \| `"fenced"` \| `"not-granted"` \|
|
|
349
356
|
`"read-only"` \| `"in-flight"` \| `"outcome-unknown"` \| `"identity-conflict"`;
|
|
350
|
-
\}\> \| `Readonly`\<\{ `kind`: `"answered"`; `record`:
|
|
351
|
-
`requester`: \{ `principalId`: `string`; `agentId`:
|
|
352
|
-
`sessionId`: `string` \| `null`; `displayName`: `string`;
|
|
353
|
-
`string`; `operation`: `string`; `access`: `"write"` \|
|
|
354
|
-
`description`: \{ `title`: `string`; `inputBytes`: `number`;
|
|
355
|
-
`string`; \}; `evidence?`: readonly `object`[]; `authorityFence`:
|
|
356
|
-
`reversibility`: `"reversible"` \| `"irreversible-external"`; `state`:
|
|
357
|
-
`"pending"` \| `"expired"` \| `"denied"` \| `"requested"` \| `"approved"` \|
|
|
357
|
+
`denialNote?`: `string`; \}\> \| `Readonly`\<\{ `kind`: `"answered"`; `record`:
|
|
358
|
+
\{ `recordId`: `string`; `requester`: \{ `principalId`: `string`; `agentId`:
|
|
359
|
+
`string` \| `null`; `sessionId`: `string` \| `null`; `displayName`: `string`;
|
|
360
|
+
\}; `module`: `string`; `operation`: `string`; `access`: `"write"` \|
|
|
361
|
+
`"external"`; `description`: \{ `title`: `string`; `inputBytes`: `number`;
|
|
362
|
+
`inputSha256`: `string`; \}; `evidence?`: readonly `object`[]; `authorityFence`:
|
|
363
|
+
`string`; `reversibility`: `"reversible"` \| `"irreversible-external"`; `state`:
|
|
364
|
+
\| `"pending"` \| `"expired"` \| `"denied"` \| `"requested"` \| `"approved"` \|
|
|
358
365
|
`"claimed"` \| `"applied"` \| `"outcome_unknown"`; `by`: \| \{ `kind`:
|
|
359
366
|
`"human"`; `memberId`: `string`; \} \| \{ `kind`: `"policy"`; \} \| `null`;
|
|
360
367
|
`reason`: \| `"pending"` \| `"expired"` \| `"not-found"` \| `"not-eligible"` \|
|
|
361
368
|
`"already-answered"` \| `"stale-revision"` \| `"declined"` \| `"fenced"` \|
|
|
362
369
|
`"not-granted"` \| `"read-only"` \| `"in-flight"` \| `"outcome-unknown"` \|
|
|
363
|
-
`"identity-conflict"` \| `null`; `
|
|
364
|
-
`updatedAt`: `number`; `revision`: `number`;
|
|
370
|
+
`"identity-conflict"` \| `null`; `denialNote?`: `string`; `requestedAt`:
|
|
371
|
+
`number`; `expiresAt`: `number`; `updatedAt`: `number`; `revision`: `number`;
|
|
372
|
+
\}; \}\>
|
|
365
373
|
|
|
366
374
|
##### setAutoApprove()
|
|
367
375
|
|
|
@@ -382,6 +390,7 @@ setAutoApprove(input, setter):
|
|
|
382
390
|
| "in-flight"
|
|
383
391
|
| "outcome-unknown"
|
|
384
392
|
| "identity-conflict";
|
|
393
|
+
denialNote?: string;
|
|
385
394
|
}>
|
|
386
395
|
| Readonly<{
|
|
387
396
|
kind: "updated";
|
|
@@ -419,9 +428,10 @@ Policy changes are attributed; an Agent can never enable its own writes.
|
|
|
419
428
|
\| `"not-found"` \| `"not-eligible"` \| `"already-answered"` \|
|
|
420
429
|
`"stale-revision"` \| `"declined"` \| `"fenced"` \| `"not-granted"` \|
|
|
421
430
|
`"read-only"` \| `"in-flight"` \| `"outcome-unknown"` \| `"identity-conflict"`;
|
|
422
|
-
\}\> \| `Readonly`\<\{ `kind`: `"updated"`; `rule`: \{
|
|
423
|
-
`string` \| `null`; \}; `family`: \{ `module`: `string`
|
|
424
|
-
`"write"` \| `"external"`; \}; `enabled`: `boolean`; \};
|
|
431
|
+
`denialNote?`: `string`; \}\> \| `Readonly`\<\{ `kind`: `"updated"`; `rule`: \{
|
|
432
|
+
`scope`: \{ `agentId`: `string` \| `null`; \}; `family`: \{ `module`: `string`
|
|
433
|
+
\| `null`; `access`: `"write"` \| `"external"`; \}; `enabled`: `boolean`; \};
|
|
434
|
+
\}\>
|
|
425
435
|
|
|
426
436
|
##### selectAutoApprove()
|
|
427
437
|
|
|
@@ -479,6 +489,24 @@ dispatches.
|
|
|
479
489
|
|
|
480
490
|
readonly `string`[]
|
|
481
491
|
|
|
492
|
+
##### readInput()
|
|
493
|
+
|
|
494
|
+
```ts
|
|
495
|
+
readInput(recordId): Json;
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
Host-private display recovery; never exposed by the member-bound capability.
|
|
499
|
+
|
|
500
|
+
###### Parameters
|
|
501
|
+
|
|
502
|
+
| Parameter | Type |
|
|
503
|
+
| ---------- | -------- |
|
|
504
|
+
| `recordId` | `string` |
|
|
505
|
+
|
|
506
|
+
###### Returns
|
|
507
|
+
|
|
508
|
+
`Json`
|
|
509
|
+
|
|
482
510
|
##### pendingHandoffs()
|
|
483
511
|
|
|
484
512
|
```ts
|
|
@@ -617,6 +645,7 @@ get(recordId):
|
|
|
617
645
|
| "outcome-unknown"
|
|
618
646
|
| "identity-conflict"
|
|
619
647
|
| null;
|
|
648
|
+
denialNote?: string;
|
|
620
649
|
requestedAt: number;
|
|
621
650
|
expiresAt: number;
|
|
622
651
|
updatedAt: number;
|
|
@@ -647,8 +676,9 @@ Read a record from this home only; the maintained decoder owns stored JSON.
|
|
|
647
676
|
`reason`: \| `"pending"` \| `"expired"` \| `"not-found"` \| `"not-eligible"` \|
|
|
648
677
|
`"already-answered"` \| `"stale-revision"` \| `"declined"` \| `"fenced"` \|
|
|
649
678
|
`"not-granted"` \| `"read-only"` \| `"in-flight"` \| `"outcome-unknown"` \|
|
|
650
|
-
`"identity-conflict"` \| `null`; `
|
|
651
|
-
`updatedAt`: `number`; `revision`: `number`; \}
|
|
679
|
+
`"identity-conflict"` \| `null`; `denialNote?`: `string`; `requestedAt`:
|
|
680
|
+
`number`; `expiresAt`: `number`; `updatedAt`: `number`; `revision`: `number`; \}
|
|
681
|
+
\| `null`
|
|
652
682
|
|
|
653
683
|
## Type Aliases
|
|
654
684
|
|
|
@@ -728,6 +758,7 @@ One per-home or per-Agent module/access rule.
|
|
|
728
758
|
type ApprovalRefusal = Readonly<{
|
|
729
759
|
kind: "refused";
|
|
730
760
|
reason: typeof ApprovalRefusalReasonSchema.Type;
|
|
761
|
+
denialNote?: typeof ApprovalDenialNoteSchema.Type;
|
|
731
762
|
}>;
|
|
732
763
|
```
|
|
733
764
|
|
|
@@ -798,6 +829,7 @@ type Approvals = Readonly<{
|
|
|
798
829
|
| "outcome-unknown"
|
|
799
830
|
| "identity-conflict"
|
|
800
831
|
| null;
|
|
832
|
+
denialNote?: string;
|
|
801
833
|
requestedAt: number;
|
|
802
834
|
expiresAt: number;
|
|
803
835
|
updatedAt: number;
|
|
@@ -810,6 +842,7 @@ type Approvals = Readonly<{
|
|
|
810
842
|
| Readonly<{
|
|
811
843
|
kind: "refused";
|
|
812
844
|
reason: typeof ApprovalRefusalReasonSchema.Type;
|
|
845
|
+
denialNote?: typeof ApprovalDenialNoteSchema.Type;
|
|
813
846
|
}>
|
|
814
847
|
| Readonly<{
|
|
815
848
|
kind: "answered";
|
|
@@ -820,6 +853,7 @@ type Approvals = Readonly<{
|
|
|
820
853
|
| Readonly<{
|
|
821
854
|
kind: "refused";
|
|
822
855
|
reason: typeof ApprovalRefusalReasonSchema.Type;
|
|
856
|
+
denialNote?: typeof ApprovalDenialNoteSchema.Type;
|
|
823
857
|
}>
|
|
824
858
|
| Readonly<{
|
|
825
859
|
kind: "updated";
|
|
@@ -858,6 +892,8 @@ type ApprovalRequest = Readonly<{
|
|
|
858
892
|
authorityFence: string;
|
|
859
893
|
idempotencyKey: string;
|
|
860
894
|
inputJson: string;
|
|
895
|
+
requireHumanApproval?: boolean;
|
|
896
|
+
prefixPolicyApproved?: boolean;
|
|
861
897
|
}>;
|
|
862
898
|
```
|
|
863
899
|
|
|
@@ -1169,6 +1205,26 @@ Why a decision or apply was refused; unknown dispatch is never a denial.
|
|
|
1169
1205
|
|
|
1170
1206
|
---
|
|
1171
1207
|
|
|
1208
|
+
### MAX\_APPROVAL\_DENIAL\_NOTE\_LENGTH
|
|
1209
|
+
|
|
1210
|
+
```ts
|
|
1211
|
+
const MAX_APPROVAL_DENIAL_NOTE_LENGTH: 512 = 512;
|
|
1212
|
+
```
|
|
1213
|
+
|
|
1214
|
+
Human explanation for a denied approval; distinct from the typed refusal cause.
|
|
1215
|
+
|
|
1216
|
+
---
|
|
1217
|
+
|
|
1218
|
+
### ApprovalDenialNoteSchema
|
|
1219
|
+
|
|
1220
|
+
```ts
|
|
1221
|
+
const ApprovalDenialNoteSchema: String;
|
|
1222
|
+
```
|
|
1223
|
+
|
|
1224
|
+
Bounded nonempty human feedback; user text, never approval authority.
|
|
1225
|
+
|
|
1226
|
+
---
|
|
1227
|
+
|
|
1172
1228
|
### MAX\_APPROVAL\_EVIDENCE
|
|
1173
1229
|
|
|
1174
1230
|
```ts
|
|
@@ -1282,6 +1338,7 @@ const ApprovalRecordSchema: Struct<{
|
|
|
1282
1338
|
]
|
|
1283
1339
|
>
|
|
1284
1340
|
>;
|
|
1341
|
+
denialNote: optionalKey<String>;
|
|
1285
1342
|
requestedAt: Int;
|
|
1286
1343
|
expiresAt: Int;
|
|
1287
1344
|
updatedAt: Int;
|
|
@@ -1370,6 +1427,7 @@ const ApprovalViewSchema: Struct<{
|
|
|
1370
1427
|
]
|
|
1371
1428
|
>
|
|
1372
1429
|
>;
|
|
1430
|
+
denialNote: optionalKey<String>;
|
|
1373
1431
|
requestedAt: Int;
|
|
1374
1432
|
expiresAt: Int;
|
|
1375
1433
|
updatedAt: Int;
|
|
@@ -1430,6 +1488,7 @@ const ApprovalAnswerInputSchema: Struct<{
|
|
|
1430
1488
|
recordId: String;
|
|
1431
1489
|
decision: Literals<readonly ["approve", "deny"]>;
|
|
1432
1490
|
expectedRevision: Int;
|
|
1491
|
+
denialNote: optionalKey<String>;
|
|
1433
1492
|
}>;
|
|
1434
1493
|
```
|
|
1435
1494
|
|
|
@@ -1478,6 +1537,7 @@ const ApprovalRefusalSchema: Struct<{
|
|
|
1478
1537
|
"identity-conflict",
|
|
1479
1538
|
]
|
|
1480
1539
|
>;
|
|
1540
|
+
denialNote: optionalKey<String>;
|
|
1481
1541
|
}>;
|
|
1482
1542
|
```
|
|
1483
1543
|
|
|
@@ -1492,3 +1552,48 @@ const DEFAULT_APPROVAL_EXPIRY_MS: number;
|
|
|
1492
1552
|
```
|
|
1493
1553
|
|
|
1494
1554
|
The initial owner-controlled wait duration; passing the deadline never approves.
|
|
1555
|
+
|
|
1556
|
+
## Functions
|
|
1557
|
+
|
|
1558
|
+
### denialFeedbackOpening()
|
|
1559
|
+
|
|
1560
|
+
```ts
|
|
1561
|
+
function denialFeedbackOpening(record, person): string | null;
|
|
1562
|
+
```
|
|
1563
|
+
|
|
1564
|
+
Host-supplied human identity; the bounded reason remains quoted user text.
|
|
1565
|
+
|
|
1566
|
+
#### Parameters
|
|
1567
|
+
|
|
1568
|
+
| Parameter | Type |
|
|
1569
|
+
| -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
1570
|
+
| `record` | \{ `recordId`: `string`; `requester`: \{ `principalId`: `string`; `agentId`: `string` \| `null`; `sessionId`: `string` \| `null`; `displayName`: `string`; \}; `module`: `string`; `operation`: `string`; `access`: `"write"` \| `"external"`; `description`: \{ `title`: `string`; `inputBytes`: `number`; `inputSha256`: `string`; \}; `evidence?`: readonly `object`[]; `authorityFence`: `string`; `reversibility`: `"reversible"` \| `"irreversible-external"`; `state`: \| `"pending"` \| `"expired"` \| `"denied"` \| `"requested"` \| `"approved"` \| `"claimed"` \| `"applied"` \| `"outcome_unknown"`; `by`: \| \{ `kind`: `"human"`; `memberId`: `string`; \} \| \{ `kind`: `"policy"`; \} \| `null`; `reason`: \| `"pending"` \| `"expired"` \| `"not-found"` \| `"not-eligible"` \| `"already-answered"` \| `"stale-revision"` \| `"declined"` \| `"fenced"` \| `"not-granted"` \| `"read-only"` \| `"in-flight"` \| `"outcome-unknown"` \| `"identity-conflict"` \| `null`; `denialNote?`: `string`; `requestedAt`: `number`; `expiresAt`: `number`; `updatedAt`: `number`; `revision`: `number`; \} |
|
|
1571
|
+
| `record.recordId` | `string` |
|
|
1572
|
+
| `record.requester` | \{ `principalId`: `string`; `agentId`: `string` \| `null`; `sessionId`: `string` \| `null`; `displayName`: `string`; \} |
|
|
1573
|
+
| `record.requester.principalId` | `string` |
|
|
1574
|
+
| `record.requester.agentId` | `string` \| `null` |
|
|
1575
|
+
| `record.requester.sessionId` | `string` \| `null` |
|
|
1576
|
+
| `record.requester.displayName` | `string` |
|
|
1577
|
+
| `record.module` | `string` |
|
|
1578
|
+
| `record.operation` | `string` |
|
|
1579
|
+
| `record.access` | `"write"` \| `"external"` |
|
|
1580
|
+
| `record.description` | \{ `title`: `string`; `inputBytes`: `number`; `inputSha256`: `string`; \} |
|
|
1581
|
+
| `record.description.title` | `string` |
|
|
1582
|
+
| `record.description.inputBytes` | `number` |
|
|
1583
|
+
| `record.description.inputSha256` | `string` |
|
|
1584
|
+
| `record.evidence?` | readonly `object`[] |
|
|
1585
|
+
| `record.authorityFence` | `string` |
|
|
1586
|
+
| `record.reversibility` | `"reversible"` \| `"irreversible-external"` |
|
|
1587
|
+
| `record.state` | \| `"pending"` \| `"expired"` \| `"denied"` \| `"requested"` \| `"approved"` \| `"claimed"` \| `"applied"` \| `"outcome_unknown"` |
|
|
1588
|
+
| `record.by` | \| \{ `kind`: `"human"`; `memberId`: `string`; \} \| \{ `kind`: `"policy"`; \} \| `null` |
|
|
1589
|
+
| `record.reason` | \| `"pending"` \| `"expired"` \| `"not-found"` \| `"not-eligible"` \| `"already-answered"` \| `"stale-revision"` \| `"declined"` \| `"fenced"` \| `"not-granted"` \| `"read-only"` \| `"in-flight"` \| `"outcome-unknown"` \| `"identity-conflict"` \| `null` |
|
|
1590
|
+
| `record.denialNote?` | `string` |
|
|
1591
|
+
| `record.requestedAt` | `number` |
|
|
1592
|
+
| `record.expiresAt` | `number` |
|
|
1593
|
+
| `record.updatedAt` | `number` |
|
|
1594
|
+
| `record.revision` | `number` |
|
|
1595
|
+
| `person` | `string` |
|
|
1596
|
+
|
|
1597
|
+
#### Returns
|
|
1598
|
+
|
|
1599
|
+
`string` \| `null`
|