@punica/editor 1.41.1 → 1.42.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@punica/editor",
3
- "version": "1.41.1",
3
+ "version": "1.42.0",
4
4
  "description": "Punica Editor",
5
5
  "private": false,
6
6
  "type": "module",
@@ -66,6 +66,18 @@ declare module 'punica' {
66
66
  * choice, and `approvePending` clamps a wider one to it.
67
67
  */
68
68
  maxScope?: ApprovalScope;
69
+ /**
70
+ * Who may answer (`kernel.PolicyRequest.approvers`). A card whose
71
+ * host identity matches no entry offers no grant and asks a
72
+ * reviewer instead.
73
+ */
74
+ approvers?: readonly string[];
75
+ /**
76
+ * Set by `referPending`: the question was handed to a reviewer
77
+ * outside this host, under this name. A run waiting on it holds
78
+ * for the reviewer's answer instead of timing out.
79
+ */
80
+ referredTo?: string;
69
81
  correlationId?: string;
70
82
  /**
71
83
  * Trace id of the invocation that hit the gate (an agent run id
@@ -760,8 +772,29 @@ declare module 'punica' {
760
772
  runLastPlan(editedPlan?: AiPlan): Promise<AiRun>;
761
773
  getLastPlan(): AiPlan | null;
762
774
  getPendingApprovals(): PendingApproval[];
763
- approvePending(pendingId: string, scope: kernel.ApprovalScope): boolean;
764
- dismissPending(pendingId: string): boolean;
775
+ /**
776
+ * Record the grant a person made. `decider` names who, when the
777
+ * decision was made elsewhere and relayed by the host (a reviewer
778
+ * answering through the registry); absent, the host identity
779
+ * decides. Throws `APPROVER_NOT_ALLOWED` when the pending names
780
+ * approvers and the decider is none of them.
781
+ */
782
+ approvePending(
783
+ pendingId: string,
784
+ scope: kernel.ApprovalScope,
785
+ decider?: { decidedBy?: string; decidedRole?: string }
786
+ ): boolean;
787
+ dismissPending(
788
+ pendingId: string,
789
+ decider?: { decidedBy?: string; decidedRole?: string; reason?: string }
790
+ ): boolean;
791
+ /**
792
+ * Hand a pending question to a reviewer outside this host, by
793
+ * name (`role:ml-lead`, `user:<email>`, `owner`). Writes nothing
794
+ * to the store; publishes `ai.pendingApprovalReferred` so the run
795
+ * that asked waits for the answer instead of timing out.
796
+ */
797
+ referPending(pendingId: string, to: string): boolean;
765
798
  /**
766
799
  * Hand a pending question back with different arguments. No grant
767
800
  * and no decline is written; the loop that asked dispatches again
@@ -72,6 +72,13 @@ declare module 'punica' {
72
72
  * wider grant. Absent means the approver chooses.
73
73
  */
74
74
  maxScope?: ApprovalScope;
75
+ /**
76
+ * Who may answer, from the deciding rule's `approvers:` (set by the
77
+ * gate from `PolicyDecision.approvers`, like `maxScope`). A grant is
78
+ * consulted and recorded only under a decider one entry names;
79
+ * absent means anyone at this host may decide.
80
+ */
81
+ approvers?: readonly string[];
75
82
  }
76
83
 
77
84
  /**
@@ -165,6 +172,12 @@ declare module 'punica' {
165
172
  approval: PolicyApproval;
166
173
  reason?: string;
167
174
  decidedBy?: string;
175
+ /**
176
+ * Under which name the decider satisfied the rule's `approvers:`
177
+ * (`owner`, `role:ml-lead`, `user:<email>`). Absent on a grant no
178
+ * rule named approvers for.
179
+ */
180
+ decidedRole?: string;
168
181
  timestampMs: number;
169
182
  /**
170
183
  * Optional chain reference — Sub-step 3.L. When present,
@@ -209,6 +222,8 @@ declare module 'punica' {
209
222
  * when no rule wrote one.
210
223
  */
211
224
  maxScope?: ApprovalScope;
225
+ /** The deciding `require` rule's `approvers:`, when it wrote them. */
226
+ approvers?: readonly string[];
212
227
  reason?: string;
213
228
  /**
214
229
  * Set when a rule from a policy template decided this. Absent
@@ -284,6 +299,15 @@ declare module 'punica' {
284
299
  ctx?: {
285
300
  workspaceId?: string;
286
301
  decidedBy?: string;
302
+ /**
303
+ * The name the decider decides under, when a trusted caller
304
+ * relays a decision made elsewhere (a reviewer answering
305
+ * through the registry): `owner`, `role:<name>` or
306
+ * `user:<email>`. With `req.approvers` set and this absent,
307
+ * the host identity's roles are matched instead; a decider
308
+ * no entry names is refused with `APPROVER_NOT_ALLOWED`.
309
+ */
310
+ decidedRole?: string;
287
311
  /**
288
312
  * Time-bound the approval — Sub-step 3.F. Epoch ms;
289
313
  * `hasApproval` rejects after this point. Undefined =
@@ -328,6 +352,8 @@ declare module 'punica' {
328
352
  ctx?: {
329
353
  workspaceId?: string;
330
354
  decidedBy?: string;
355
+ /** As on `recordApproval`: the name a relayed decider decided under. */
356
+ decidedRole?: string;
331
357
  /** Why, in the decider's words. Stored verbatim. */
332
358
  reason?: string;
333
359
  traceId?: string;
@@ -506,6 +532,15 @@ declare module 'punica' {
506
532
  * effect on the next call without anyone revoking anything.
507
533
  */
508
534
  scope?: ApprovalScope;
535
+ /**
536
+ * Who may answer, only on `effect: 'require'`: `owner`,
537
+ * `role:<name>` or `user:<email>`, any one of which is enough. A
538
+ * grant recorded by anyone else does not satisfy the rule, and a
539
+ * host whose identity matches no entry cannot grant it — it asks
540
+ * a reviewer instead. Absent means anyone at the host decides,
541
+ * which is what every rule written before this field meant.
542
+ */
543
+ approvers?: string[];
509
544
  /** Shown to the user on a denial and written into the audit record. */
510
545
  reason?: string;
511
546
  }
@@ -520,6 +555,8 @@ declare module 'punica' {
520
555
  reason?: string;
521
556
  /** The rule's `scope`, when it wrote one (`effect: require` only). */
522
557
  scope?: ApprovalScope;
558
+ /** The rule's `approvers`, when it wrote them (`effect: require` only). */
559
+ approvers?: string[];
523
560
  /** Digest of the template's rules — which policy text was in force. */
524
561
  digest?: string;
525
562
  /**
@@ -235,6 +235,13 @@ declare module 'punica' {
235
235
  * invents nothing to fill it. Passing `undefined` clears it.
236
236
  */
237
237
  setHostIdentity: (identity: HostIdentity | undefined) => void;
238
+ /**
239
+ * The identity the host injected, or `undefined`. Read by a card
240
+ * deciding whether the person at this host may answer a rule that
241
+ * names its approvers (`roles`), and by a host asking a reviewer
242
+ * (`orgs`). Never a substitute for the audit record's `actor.id`.
243
+ */
244
+ getHostIdentity: () => HostIdentity | undefined;
238
245
 
239
246
  /**
240
247
  * Package signing. A host installs a signer during bootstrap so an
@@ -395,6 +402,15 @@ declare module 'punica' {
395
402
  export interface HostIdentity {
396
403
  email: string;
397
404
  displayName?: string | null;
405
+ /**
406
+ * The person's organisation roles, as the registry lists them
407
+ * (`owner`, `ml-lead`, …), across every organisation they belong
408
+ * to. Read by a `require` rule that names its `approvers:`; absent
409
+ * or empty means such a rule matches nobody at this host.
410
+ */
411
+ roles?: readonly string[];
412
+ /** The organisations behind those roles, for a host that asks a reviewer. */
413
+ orgs?: ReadonlyArray<{ id: string; name: string; role: string }>;
398
414
  }
399
415
 
400
416
  /**