@zhama/tego-plugin-sdk 0.0.0-stage → 1.36.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 (98) hide show
  1. package/LICENSE +172 -0
  2. package/README.md +846 -2
  3. package/access-catalog.schema.json +304 -0
  4. package/access-fixtures/resolve.json +1359 -0
  5. package/bin/tego-plugin-pack.mjs +2 -0
  6. package/bin/tego-plugin.mjs +3 -0
  7. package/dist/access-drizzle.cjs +1 -0
  8. package/dist/access-drizzle.d.cts +726 -0
  9. package/dist/access-drizzle.d.ts +726 -0
  10. package/dist/access-drizzle.js +1 -0
  11. package/dist/access-hono.cjs +3 -0
  12. package/dist/access-hono.d.cts +108 -0
  13. package/dist/access-hono.d.ts +108 -0
  14. package/dist/access-hono.js +3 -0
  15. package/dist/access-implications.cjs +1 -0
  16. package/dist/access-implications.d.cts +25 -0
  17. package/dist/access-implications.d.ts +25 -0
  18. package/dist/access-implications.js +1 -0
  19. package/dist/access.cjs +26 -0
  20. package/dist/access.d.cts +884 -0
  21. package/dist/access.d.ts +884 -0
  22. package/dist/access.js +26 -0
  23. package/dist/catalog-CSSbrfEf.d.cts +361 -0
  24. package/dist/catalog-CSSbrfEf.d.ts +361 -0
  25. package/dist/chunk-3KUOBGJN.js +19 -0
  26. package/dist/chunk-3WA3M347.cjs +1 -0
  27. package/dist/chunk-5CU33JVY.js +1 -0
  28. package/dist/chunk-7K37PVGV.js +5 -0
  29. package/dist/chunk-7XHF3YSK.js +1 -0
  30. package/dist/chunk-AJY7ZHXK.cjs +3 -0
  31. package/dist/chunk-BN6TGHSB.cjs +1 -0
  32. package/dist/chunk-BTHXQWHT.js +1 -0
  33. package/dist/chunk-C2OCOPZQ.cjs +1 -0
  34. package/dist/chunk-IMAVYQ4U.cjs +4 -0
  35. package/dist/chunk-OP64Y4IN.cjs +1 -0
  36. package/dist/chunk-QKSPPMVN.js +1 -0
  37. package/dist/chunk-ROFUQLOZ.cjs +1 -0
  38. package/dist/chunk-SNUCO2MK.js +1 -0
  39. package/dist/chunk-THMWRUAT.cjs +19 -0
  40. package/dist/chunk-VMCGDDGP.js +3 -0
  41. package/dist/chunk-W7C357A6.cjs +5 -0
  42. package/dist/chunk-WLTASJF6.js +4 -0
  43. package/dist/egress.cjs +7 -0
  44. package/dist/egress.d.cts +9 -0
  45. package/dist/egress.d.ts +9 -0
  46. package/dist/egress.js +7 -0
  47. package/dist/frontend.cjs +2 -0
  48. package/dist/frontend.d.cts +353 -0
  49. package/dist/frontend.d.ts +353 -0
  50. package/dist/frontend.js +2 -0
  51. package/dist/gateway-signature.cjs +1 -0
  52. package/dist/gateway-signature.d.cts +112 -0
  53. package/dist/gateway-signature.d.ts +112 -0
  54. package/dist/gateway-signature.js +1 -0
  55. package/dist/index.cjs +1 -0
  56. package/dist/index.d.cts +528 -0
  57. package/dist/index.d.ts +528 -0
  58. package/dist/index.js +1 -0
  59. package/dist/manifest-types-DQARCQJt.d.cts +627 -0
  60. package/dist/manifest-types-DQARCQJt.d.ts +627 -0
  61. package/dist/manifest.cjs +1 -0
  62. package/dist/manifest.d.cts +2824 -0
  63. package/dist/manifest.d.ts +2824 -0
  64. package/dist/manifest.js +1 -0
  65. package/dist/mcp-identity.cjs +2 -0
  66. package/dist/mcp-identity.d.cts +106 -0
  67. package/dist/mcp-identity.d.ts +106 -0
  68. package/dist/mcp-identity.js +2 -0
  69. package/dist/pack.cjs +1 -0
  70. package/dist/pack.d.cts +169 -0
  71. package/dist/pack.d.ts +169 -0
  72. package/dist/pack.js +1 -0
  73. package/dist/publish.cjs +1 -0
  74. package/dist/publish.d.cts +96 -0
  75. package/dist/publish.d.ts +96 -0
  76. package/dist/publish.js +1 -0
  77. package/dist/scaffold.cjs +523 -0
  78. package/dist/scaffold.d.cts +182 -0
  79. package/dist/scaffold.d.ts +182 -0
  80. package/dist/scaffold.js +523 -0
  81. package/dist/server-runtime.cjs +1 -0
  82. package/dist/server-runtime.d.cts +63 -0
  83. package/dist/server-runtime.d.ts +63 -0
  84. package/dist/server-runtime.js +1 -0
  85. package/dist/server.cjs +1 -0
  86. package/dist/server.d.cts +1808 -0
  87. package/dist/server.d.ts +1808 -0
  88. package/dist/server.js +1 -0
  89. package/dist/testing.cjs +2 -0
  90. package/dist/testing.d.cts +92 -0
  91. package/dist/testing.d.ts +92 -0
  92. package/dist/testing.js +2 -0
  93. package/dist/vite.cjs +1 -0
  94. package/dist/vite.d.cts +133 -0
  95. package/dist/vite.d.ts +133 -0
  96. package/dist/vite.js +1 -0
  97. package/package.json +160 -4
  98. package/sql/access.sql +73 -0
@@ -0,0 +1,1359 @@
1
+ {
2
+ "description": "Contract cases for the access resolver, shared by the TypeScript and Python SDKs. Each case is the store's rows plus a caller; both runtimes must reach the same permissions and decisions. Only the built-in scopes (own, all) are matched against resources, so neither side needs a plugin evaluator. A hierarchical case's `inheritance.inherit` stands for the plugin's function: it returns the role's grants named in `keep`, plus `add` as written.",
3
+ "catalog": {
4
+ "version": 1,
5
+ "groups": [
6
+ {
7
+ "key": "docs",
8
+ "labelKey": "access.group.docs"
9
+ },
10
+ {
11
+ "key": "admin",
12
+ "labelKey": "access.group.admin"
13
+ }
14
+ ],
15
+ "scopes": {
16
+ "own": {
17
+ "labelKey": "access.scope.own"
18
+ },
19
+ "team": {
20
+ "labelKey": "access.scope.team"
21
+ },
22
+ "all": {
23
+ "labelKey": "access.scope.all"
24
+ }
25
+ },
26
+ "permissions": {
27
+ "doc.view": {
28
+ "group": "docs",
29
+ "labelKey": "access.permission.docView",
30
+ "scopes": ["own", "team", "all"],
31
+ "agent": {
32
+ "requires": ["records.read"]
33
+ }
34
+ },
35
+ "doc.edit": {
36
+ "group": "docs",
37
+ "labelKey": "access.permission.docEdit",
38
+ "scopes": ["own", "team", "all"],
39
+ "implies": ["doc.view"],
40
+ "agent": {
41
+ "requires": ["records.read", "work.prepare"]
42
+ }
43
+ },
44
+ "doc.delete": {
45
+ "group": "docs",
46
+ "labelKey": "access.permission.docDelete",
47
+ "scopes": ["own", "all"]
48
+ },
49
+ "report.export": {
50
+ "group": "docs",
51
+ "labelKey": "access.permission.reportExport",
52
+ "agent": {
53
+ "requires": ["records.read"]
54
+ }
55
+ },
56
+ "settings.edit": {
57
+ "group": "admin",
58
+ "labelKey": "access.permission.settingsEdit"
59
+ }
60
+ },
61
+ "menus": {
62
+ "reports": "report.export",
63
+ "settings": "settings.edit"
64
+ },
65
+ "roles": {
66
+ "admin": {
67
+ "nameKey": "access.role.admin",
68
+ "grants": {
69
+ "doc.edit": "all",
70
+ "doc.delete": "all",
71
+ "report.export": true,
72
+ "settings.edit": true,
73
+ "access.manage": true
74
+ }
75
+ },
76
+ "editor": {
77
+ "nameKey": "access.role.editor",
78
+ "grants": {
79
+ "doc.edit": "team",
80
+ "report.export": true
81
+ }
82
+ },
83
+ "viewer": {
84
+ "nameKey": "access.role.viewer",
85
+ "grants": {
86
+ "doc.view": "own"
87
+ }
88
+ }
89
+ },
90
+ "hostRoleBindings": {
91
+ "admin": ["admin"],
92
+ "super_admin": ["admin"]
93
+ },
94
+ "defaults": {
95
+ "unassigned": "viewer"
96
+ },
97
+ "domains": {
98
+ "project": {
99
+ "labelKey": "access.domain.project"
100
+ },
101
+ "org": {
102
+ "labelKey": "access.domain.org",
103
+ "hierarchical": true
104
+ }
105
+ },
106
+ "assignment": {
107
+ "principals": ["user", "unit", "group"],
108
+ "maxRolesPerPrincipal": {
109
+ "project": 1
110
+ }
111
+ }
112
+ },
113
+ "roles": [
114
+ {
115
+ "id": "r-admin",
116
+ "key": "admin",
117
+ "builtin": true,
118
+ "domain": null,
119
+ "grants": {
120
+ "doc.edit": "all",
121
+ "doc.delete": "all",
122
+ "report.export": true,
123
+ "settings.edit": true,
124
+ "access.manage": true
125
+ }
126
+ },
127
+ {
128
+ "id": "r-editor",
129
+ "key": "editor",
130
+ "builtin": true,
131
+ "domain": null,
132
+ "grants": {
133
+ "doc.edit": "team",
134
+ "report.export": true
135
+ }
136
+ },
137
+ {
138
+ "id": "r-viewer",
139
+ "key": "viewer",
140
+ "builtin": true,
141
+ "domain": null,
142
+ "grants": {
143
+ "doc.view": "own"
144
+ }
145
+ },
146
+ {
147
+ "id": "r-stale",
148
+ "key": null,
149
+ "builtin": false,
150
+ "domain": null,
151
+ "grants": {
152
+ "doc.view": "galaxy",
153
+ "removed.permission": true,
154
+ "report.export": "all"
155
+ }
156
+ },
157
+ {
158
+ "id": "r-project-editor",
159
+ "key": null,
160
+ "builtin": false,
161
+ "domain": {
162
+ "type": "project",
163
+ "id": "p1"
164
+ },
165
+ "grants": {
166
+ "doc.edit": "all"
167
+ }
168
+ }
169
+ ],
170
+ "cases": [
171
+ {
172
+ "id": "ACC-C-001",
173
+ "description": "A user nobody assigned anything holds the default role",
174
+ "subject": {
175
+ "userId": "u1",
176
+ "hostRoles": ["user"]
177
+ },
178
+ "assignments": [],
179
+ "memberships": [],
180
+ "unassignedRoleId": "r-viewer",
181
+ "domain": null,
182
+ "expect": {
183
+ "permissions": {
184
+ "doc.view": "own"
185
+ },
186
+ "sources": [
187
+ {
188
+ "roleId": "r-viewer",
189
+ "source": "unassigned"
190
+ }
191
+ ],
192
+ "assignedDomains": [],
193
+ "decisions": [
194
+ {
195
+ "permission": "doc.view",
196
+ "allowed": true,
197
+ "scope": "own",
198
+ "reason": "granted"
199
+ },
200
+ {
201
+ "permission": "doc.edit",
202
+ "allowed": false,
203
+ "scope": null,
204
+ "reason": "not_granted"
205
+ }
206
+ ]
207
+ }
208
+ },
209
+ {
210
+ "id": "ACC-C-002",
211
+ "description": "An explicit assignment replaces the default, and implications carry the scope",
212
+ "subject": {
213
+ "userId": "u1",
214
+ "hostRoles": ["user"]
215
+ },
216
+ "assignments": [
217
+ {
218
+ "id": "a1",
219
+ "roleId": "r-editor",
220
+ "principal": {
221
+ "kind": "user",
222
+ "id": "u1",
223
+ "includeDescendants": false,
224
+ "unitRoles": null
225
+ },
226
+ "domain": null
227
+ }
228
+ ],
229
+ "memberships": [],
230
+ "unassignedRoleId": "r-viewer",
231
+ "domain": null,
232
+ "expect": {
233
+ "permissions": {
234
+ "doc.edit": "team",
235
+ "doc.view": "team",
236
+ "report.export": true
237
+ },
238
+ "sources": [
239
+ {
240
+ "roleId": "r-editor",
241
+ "source": "assignment"
242
+ }
243
+ ],
244
+ "assignedDomains": [],
245
+ "decisions": [
246
+ {
247
+ "permission": "doc.view",
248
+ "allowed": true,
249
+ "scope": "team",
250
+ "reason": "granted"
251
+ },
252
+ {
253
+ "permission": "report.export",
254
+ "allowed": true,
255
+ "scope": null,
256
+ "reason": "granted"
257
+ }
258
+ ]
259
+ }
260
+ },
261
+ {
262
+ "id": "ACC-C-003",
263
+ "description": "A host administrator holds the bound role on top of the default",
264
+ "subject": {
265
+ "userId": "u1",
266
+ "hostRoles": ["admin"]
267
+ },
268
+ "assignments": [],
269
+ "memberships": [],
270
+ "unassignedRoleId": "r-viewer",
271
+ "domain": null,
272
+ "expect": {
273
+ "permissions": {
274
+ "doc.edit": "all",
275
+ "doc.view": "all",
276
+ "doc.delete": "all",
277
+ "report.export": true,
278
+ "settings.edit": true,
279
+ "access.manage": true,
280
+ "access.audit": true
281
+ },
282
+ "sources": [
283
+ {
284
+ "roleId": "r-admin",
285
+ "source": "hostRole"
286
+ },
287
+ {
288
+ "roleId": "r-viewer",
289
+ "source": "unassigned"
290
+ }
291
+ ],
292
+ "assignedDomains": [],
293
+ "decisions": [
294
+ {
295
+ "permission": "access.audit",
296
+ "allowed": true,
297
+ "scope": null,
298
+ "reason": "granted"
299
+ }
300
+ ]
301
+ }
302
+ },
303
+ {
304
+ "id": "ACC-C-004",
305
+ "description": "Grants from several roles union, the widest scope winning",
306
+ "subject": {
307
+ "userId": "u1",
308
+ "hostRoles": []
309
+ },
310
+ "assignments": [
311
+ {
312
+ "id": "a1",
313
+ "roleId": "r-viewer",
314
+ "principal": {
315
+ "kind": "user",
316
+ "id": "u1",
317
+ "includeDescendants": false,
318
+ "unitRoles": null
319
+ },
320
+ "domain": null
321
+ },
322
+ {
323
+ "id": "a2",
324
+ "roleId": "r-editor",
325
+ "principal": {
326
+ "kind": "group",
327
+ "id": "g1",
328
+ "includeDescendants": false,
329
+ "unitRoles": null
330
+ },
331
+ "domain": null
332
+ }
333
+ ],
334
+ "memberships": [
335
+ {
336
+ "kind": "group",
337
+ "id": "g1",
338
+ "ancestors": []
339
+ }
340
+ ],
341
+ "unassignedRoleId": "r-viewer",
342
+ "domain": null,
343
+ "expect": {
344
+ "permissions": {
345
+ "doc.view": "team",
346
+ "doc.edit": "team",
347
+ "report.export": true
348
+ },
349
+ "sources": [
350
+ {
351
+ "roleId": "r-viewer",
352
+ "source": "assignment"
353
+ },
354
+ {
355
+ "roleId": "r-editor",
356
+ "source": "assignment"
357
+ }
358
+ ],
359
+ "assignedDomains": [],
360
+ "decisions": [
361
+ {
362
+ "permission": "doc.view",
363
+ "allowed": true,
364
+ "scope": "team",
365
+ "reason": "granted"
366
+ }
367
+ ]
368
+ }
369
+ },
370
+ {
371
+ "id": "ACC-C-005",
372
+ "description": "A unit assignment with descendants reaches a member of a child unit",
373
+ "subject": {
374
+ "userId": "u1",
375
+ "hostRoles": []
376
+ },
377
+ "assignments": [
378
+ {
379
+ "id": "a1",
380
+ "roleId": "r-editor",
381
+ "principal": {
382
+ "kind": "unit",
383
+ "id": "unit-root",
384
+ "includeDescendants": true,
385
+ "unitRoles": null
386
+ },
387
+ "domain": null
388
+ }
389
+ ],
390
+ "memberships": [
391
+ {
392
+ "kind": "unit",
393
+ "id": "unit-child",
394
+ "ancestors": ["unit-root"],
395
+ "role": "member"
396
+ }
397
+ ],
398
+ "unassignedRoleId": "r-viewer",
399
+ "domain": null,
400
+ "expect": {
401
+ "permissions": {
402
+ "doc.edit": "team",
403
+ "doc.view": "team",
404
+ "report.export": true
405
+ },
406
+ "sources": [
407
+ {
408
+ "roleId": "r-editor",
409
+ "source": "assignment"
410
+ }
411
+ ],
412
+ "assignedDomains": [],
413
+ "decisions": []
414
+ }
415
+ },
416
+ {
417
+ "id": "ACC-C-006",
418
+ "description": "Without descendants a unit assignment does not reach a child unit, so the default applies",
419
+ "subject": {
420
+ "userId": "u1",
421
+ "hostRoles": []
422
+ },
423
+ "assignments": [
424
+ {
425
+ "id": "a1",
426
+ "roleId": "r-editor",
427
+ "principal": {
428
+ "kind": "unit",
429
+ "id": "unit-root",
430
+ "includeDescendants": false,
431
+ "unitRoles": null
432
+ },
433
+ "domain": null
434
+ }
435
+ ],
436
+ "memberships": [
437
+ {
438
+ "kind": "unit",
439
+ "id": "unit-child",
440
+ "ancestors": ["unit-root"],
441
+ "role": "member"
442
+ }
443
+ ],
444
+ "unassignedRoleId": "r-viewer",
445
+ "domain": null,
446
+ "expect": {
447
+ "permissions": {
448
+ "doc.view": "own"
449
+ },
450
+ "sources": [
451
+ {
452
+ "roleId": "r-viewer",
453
+ "source": "unassigned"
454
+ }
455
+ ],
456
+ "assignedDomains": [],
457
+ "decisions": []
458
+ }
459
+ },
460
+ {
461
+ "id": "ACC-C-007",
462
+ "description": "A unit assignment limited to unit owners skips an ordinary member",
463
+ "subject": {
464
+ "userId": "u1",
465
+ "hostRoles": []
466
+ },
467
+ "assignments": [
468
+ {
469
+ "id": "a1",
470
+ "roleId": "r-editor",
471
+ "principal": {
472
+ "kind": "unit",
473
+ "id": "unit-root",
474
+ "includeDescendants": false,
475
+ "unitRoles": ["owner"]
476
+ },
477
+ "domain": null
478
+ }
479
+ ],
480
+ "memberships": [
481
+ {
482
+ "kind": "unit",
483
+ "id": "unit-root",
484
+ "ancestors": [],
485
+ "role": "member"
486
+ }
487
+ ],
488
+ "unassignedRoleId": null,
489
+ "domain": null,
490
+ "expect": {
491
+ "permissions": {},
492
+ "sources": [],
493
+ "assignedDomains": [],
494
+ "decisions": [
495
+ {
496
+ "permission": "doc.view",
497
+ "allowed": false,
498
+ "scope": null,
499
+ "reason": "not_granted"
500
+ }
501
+ ]
502
+ }
503
+ },
504
+ {
505
+ "id": "ACC-C-008",
506
+ "description": "A digital employee keeps only what each permission's agent policy and the delegation allow",
507
+ "subject": {
508
+ "userId": "u1",
509
+ "hostRoles": ["admin"],
510
+ "agent": {
511
+ "avatarId": "av1",
512
+ "delegation": ["records.read"]
513
+ }
514
+ },
515
+ "assignments": [],
516
+ "memberships": [],
517
+ "unassignedRoleId": null,
518
+ "domain": null,
519
+ "expect": {
520
+ "permissions": {
521
+ "doc.view": "all",
522
+ "report.export": true
523
+ },
524
+ "sources": [
525
+ {
526
+ "roleId": "r-admin",
527
+ "source": "hostRole"
528
+ }
529
+ ],
530
+ "assignedDomains": [],
531
+ "decisions": [
532
+ {
533
+ "permission": "doc.view",
534
+ "allowed": true,
535
+ "scope": "all",
536
+ "reason": "granted"
537
+ },
538
+ {
539
+ "permission": "doc.edit",
540
+ "allowed": false,
541
+ "scope": null,
542
+ "reason": "delegation_missing"
543
+ },
544
+ {
545
+ "permission": "doc.delete",
546
+ "allowed": false,
547
+ "scope": null,
548
+ "reason": "agent_forbidden"
549
+ },
550
+ {
551
+ "permission": "access.manage",
552
+ "allowed": false,
553
+ "scope": null,
554
+ "reason": "agent_forbidden"
555
+ }
556
+ ]
557
+ }
558
+ },
559
+ {
560
+ "id": "ACC-C-009",
561
+ "description": "A domain assignment counts only in its domain; elsewhere the default applies",
562
+ "subject": {
563
+ "userId": "u1",
564
+ "hostRoles": []
565
+ },
566
+ "assignments": [
567
+ {
568
+ "id": "a1",
569
+ "roleId": "r-project-editor",
570
+ "principal": {
571
+ "kind": "user",
572
+ "id": "u1",
573
+ "includeDescendants": false,
574
+ "unitRoles": null
575
+ },
576
+ "domain": {
577
+ "type": "project",
578
+ "id": "p1"
579
+ }
580
+ }
581
+ ],
582
+ "memberships": [],
583
+ "unassignedRoleId": "r-viewer",
584
+ "domain": null,
585
+ "expect": {
586
+ "permissions": {
587
+ "doc.view": "own"
588
+ },
589
+ "sources": [
590
+ {
591
+ "roleId": "r-viewer",
592
+ "source": "unassigned"
593
+ }
594
+ ],
595
+ "assignedDomains": [
596
+ {
597
+ "type": "project",
598
+ "id": "p1"
599
+ }
600
+ ],
601
+ "decisions": []
602
+ }
603
+ },
604
+ {
605
+ "id": "ACC-C-010",
606
+ "description": "Inside the domain, the domain assignment applies and the default does not",
607
+ "subject": {
608
+ "userId": "u1",
609
+ "hostRoles": []
610
+ },
611
+ "assignments": [
612
+ {
613
+ "id": "a1",
614
+ "roleId": "r-project-editor",
615
+ "principal": {
616
+ "kind": "user",
617
+ "id": "u1",
618
+ "includeDescendants": false,
619
+ "unitRoles": null
620
+ },
621
+ "domain": {
622
+ "type": "project",
623
+ "id": "p1"
624
+ }
625
+ }
626
+ ],
627
+ "memberships": [],
628
+ "unassignedRoleId": "r-viewer",
629
+ "domain": {
630
+ "type": "project",
631
+ "id": "p1"
632
+ },
633
+ "expect": {
634
+ "permissions": {
635
+ "doc.edit": "all",
636
+ "doc.view": "all"
637
+ },
638
+ "sources": [
639
+ {
640
+ "roleId": "r-project-editor",
641
+ "source": "assignment"
642
+ }
643
+ ],
644
+ "assignedDomains": [
645
+ {
646
+ "type": "project",
647
+ "id": "p1"
648
+ }
649
+ ],
650
+ "decisions": []
651
+ }
652
+ },
653
+ {
654
+ "id": "ACC-C-011",
655
+ "description": "A global assignment applies inside every domain",
656
+ "subject": {
657
+ "userId": "u1",
658
+ "hostRoles": []
659
+ },
660
+ "assignments": [
661
+ {
662
+ "id": "a1",
663
+ "roleId": "r-editor",
664
+ "principal": {
665
+ "kind": "user",
666
+ "id": "u1",
667
+ "includeDescendants": false,
668
+ "unitRoles": null
669
+ },
670
+ "domain": null
671
+ }
672
+ ],
673
+ "memberships": [],
674
+ "unassignedRoleId": "r-viewer",
675
+ "domain": {
676
+ "type": "project",
677
+ "id": "p2"
678
+ },
679
+ "expect": {
680
+ "permissions": {
681
+ "doc.edit": "team",
682
+ "doc.view": "team",
683
+ "report.export": true
684
+ },
685
+ "sources": [
686
+ {
687
+ "roleId": "r-editor",
688
+ "source": "assignment"
689
+ }
690
+ ],
691
+ "assignedDomains": [],
692
+ "decisions": []
693
+ }
694
+ },
695
+ {
696
+ "id": "ACC-C-012",
697
+ "description": "Grants the catalog no longer recognises are ignored, never widened",
698
+ "subject": {
699
+ "userId": "u1",
700
+ "hostRoles": []
701
+ },
702
+ "assignments": [
703
+ {
704
+ "id": "a1",
705
+ "roleId": "r-stale",
706
+ "principal": {
707
+ "kind": "user",
708
+ "id": "u1",
709
+ "includeDescendants": false,
710
+ "unitRoles": null
711
+ },
712
+ "domain": null
713
+ }
714
+ ],
715
+ "memberships": [],
716
+ "unassignedRoleId": "r-viewer",
717
+ "domain": null,
718
+ "expect": {
719
+ "permissions": {},
720
+ "sources": [
721
+ {
722
+ "roleId": "r-stale",
723
+ "source": "assignment"
724
+ }
725
+ ],
726
+ "assignedDomains": [],
727
+ "decisions": [
728
+ {
729
+ "permission": "report.export",
730
+ "allowed": false,
731
+ "scope": null,
732
+ "reason": "not_granted"
733
+ }
734
+ ]
735
+ }
736
+ },
737
+ {
738
+ "id": "ACC-C-013",
739
+ "description": "Resource checks: own matches only the caller's resource; all matches any",
740
+ "subject": {
741
+ "userId": "u1",
742
+ "hostRoles": []
743
+ },
744
+ "assignments": [],
745
+ "memberships": [],
746
+ "unassignedRoleId": "r-viewer",
747
+ "domain": null,
748
+ "expect": {
749
+ "permissions": {
750
+ "doc.view": "own"
751
+ },
752
+ "sources": [
753
+ {
754
+ "roleId": "r-viewer",
755
+ "source": "unassigned"
756
+ }
757
+ ],
758
+ "assignedDomains": [],
759
+ "decisions": [
760
+ {
761
+ "permission": "doc.view",
762
+ "resource": {
763
+ "ownerId": "u1"
764
+ },
765
+ "allowed": true,
766
+ "scope": "own",
767
+ "matchedScope": "own",
768
+ "reason": "granted"
769
+ },
770
+ {
771
+ "permission": "doc.view",
772
+ "resource": {
773
+ "ownerId": "u2"
774
+ },
775
+ "allowed": false,
776
+ "scope": "own",
777
+ "reason": "scope_mismatch"
778
+ },
779
+ {
780
+ "permission": "doc.edit",
781
+ "resource": {
782
+ "ownerId": "u1"
783
+ },
784
+ "allowed": false,
785
+ "scope": null,
786
+ "reason": "not_granted"
787
+ }
788
+ ]
789
+ }
790
+ },
791
+ {
792
+ "id": "ACC-C-014",
793
+ "description": "The widest held scope matches first",
794
+ "subject": {
795
+ "userId": "u1",
796
+ "hostRoles": ["super_admin"]
797
+ },
798
+ "assignments": [],
799
+ "memberships": [],
800
+ "unassignedRoleId": null,
801
+ "domain": null,
802
+ "expect": {
803
+ "permissions": {
804
+ "doc.edit": "all",
805
+ "doc.view": "all",
806
+ "doc.delete": "all",
807
+ "report.export": true,
808
+ "settings.edit": true,
809
+ "access.manage": true,
810
+ "access.audit": true
811
+ },
812
+ "sources": [
813
+ {
814
+ "roleId": "r-admin",
815
+ "source": "hostRole"
816
+ }
817
+ ],
818
+ "assignedDomains": [],
819
+ "decisions": [
820
+ {
821
+ "permission": "doc.delete",
822
+ "resource": {
823
+ "ownerId": "u2"
824
+ },
825
+ "allowed": true,
826
+ "scope": "all",
827
+ "matchedScope": "all",
828
+ "reason": "granted"
829
+ }
830
+ ]
831
+ }
832
+ },
833
+ {
834
+ "id": "ACC-C-015",
835
+ "description": "In a hierarchical domain, an ancestor's assignment applies through inherit, and adds to the default",
836
+ "subject": {
837
+ "userId": "u1",
838
+ "hostRoles": ["user"]
839
+ },
840
+ "assignments": [
841
+ {
842
+ "id": "a1",
843
+ "roleId": "r-editor",
844
+ "principal": {
845
+ "kind": "user",
846
+ "id": "u1",
847
+ "includeDescendants": false,
848
+ "unitRoles": null
849
+ },
850
+ "domain": {
851
+ "type": "org",
852
+ "id": "o1"
853
+ }
854
+ }
855
+ ],
856
+ "memberships": [],
857
+ "unassignedRoleId": "r-viewer",
858
+ "domain": {
859
+ "type": "org",
860
+ "id": "o3"
861
+ },
862
+ "inheritance": {
863
+ "ancestors": [
864
+ {
865
+ "type": "org",
866
+ "id": "o2"
867
+ },
868
+ {
869
+ "type": "org",
870
+ "id": "o1"
871
+ }
872
+ ],
873
+ "inherit": {
874
+ "keep": ["doc.view"],
875
+ "add": {}
876
+ }
877
+ },
878
+ "expect": {
879
+ "permissions": {
880
+ "doc.view": "team"
881
+ },
882
+ "sources": [
883
+ {
884
+ "roleId": "r-editor",
885
+ "source": "assignment",
886
+ "inherited": true
887
+ },
888
+ {
889
+ "roleId": "r-viewer",
890
+ "source": "unassigned"
891
+ }
892
+ ],
893
+ "assignedDomains": [
894
+ {
895
+ "type": "org",
896
+ "id": "o1"
897
+ }
898
+ ],
899
+ "decisions": [
900
+ {
901
+ "permission": "doc.view",
902
+ "allowed": true,
903
+ "scope": "team",
904
+ "reason": "granted"
905
+ },
906
+ {
907
+ "permission": "doc.edit",
908
+ "allowed": false,
909
+ "scope": null,
910
+ "reason": "not_granted"
911
+ },
912
+ {
913
+ "permission": "report.export",
914
+ "allowed": false,
915
+ "scope": null,
916
+ "reason": "not_granted"
917
+ }
918
+ ]
919
+ }
920
+ },
921
+ {
922
+ "id": "ACC-C-016",
923
+ "description": "Inherit can only narrow: what it adds beyond the role is dropped, and a widened scope falls back to the role's",
924
+ "subject": {
925
+ "userId": "u1",
926
+ "hostRoles": ["user"]
927
+ },
928
+ "assignments": [
929
+ {
930
+ "id": "a1",
931
+ "roleId": "r-editor",
932
+ "principal": {
933
+ "kind": "user",
934
+ "id": "u1",
935
+ "includeDescendants": false,
936
+ "unitRoles": null
937
+ },
938
+ "domain": {
939
+ "type": "org",
940
+ "id": "o1"
941
+ }
942
+ }
943
+ ],
944
+ "memberships": [],
945
+ "unassignedRoleId": null,
946
+ "domain": {
947
+ "type": "org",
948
+ "id": "o3"
949
+ },
950
+ "inheritance": {
951
+ "ancestors": [
952
+ {
953
+ "type": "org",
954
+ "id": "o2"
955
+ },
956
+ {
957
+ "type": "org",
958
+ "id": "o1"
959
+ }
960
+ ],
961
+ "inherit": {
962
+ "keep": [],
963
+ "add": {
964
+ "doc.edit": "all",
965
+ "settings.edit": true
966
+ }
967
+ }
968
+ },
969
+ "expect": {
970
+ "permissions": {
971
+ "doc.edit": "team",
972
+ "doc.view": "team"
973
+ },
974
+ "sources": [
975
+ {
976
+ "roleId": "r-editor",
977
+ "source": "assignment",
978
+ "inherited": true
979
+ }
980
+ ],
981
+ "assignedDomains": [
982
+ {
983
+ "type": "org",
984
+ "id": "o1"
985
+ }
986
+ ],
987
+ "decisions": [
988
+ {
989
+ "permission": "doc.edit",
990
+ "allowed": true,
991
+ "scope": "team",
992
+ "reason": "granted"
993
+ },
994
+ {
995
+ "permission": "settings.edit",
996
+ "allowed": false,
997
+ "scope": null,
998
+ "reason": "not_granted"
999
+ }
1000
+ ]
1001
+ }
1002
+ },
1003
+ {
1004
+ "id": "ACC-C-017",
1005
+ "description": "An assignment at a domain off the ancestor line does not reach in, so the default applies",
1006
+ "subject": {
1007
+ "userId": "u1",
1008
+ "hostRoles": ["user"]
1009
+ },
1010
+ "assignments": [
1011
+ {
1012
+ "id": "a1",
1013
+ "roleId": "r-editor",
1014
+ "principal": {
1015
+ "kind": "user",
1016
+ "id": "u1",
1017
+ "includeDescendants": false,
1018
+ "unitRoles": null
1019
+ },
1020
+ "domain": {
1021
+ "type": "org",
1022
+ "id": "o9"
1023
+ }
1024
+ }
1025
+ ],
1026
+ "memberships": [],
1027
+ "unassignedRoleId": "r-viewer",
1028
+ "domain": {
1029
+ "type": "org",
1030
+ "id": "o3"
1031
+ },
1032
+ "inheritance": {
1033
+ "ancestors": [
1034
+ {
1035
+ "type": "org",
1036
+ "id": "o2"
1037
+ },
1038
+ {
1039
+ "type": "org",
1040
+ "id": "o1"
1041
+ }
1042
+ ],
1043
+ "inherit": {
1044
+ "keep": ["doc.view"],
1045
+ "add": {}
1046
+ }
1047
+ },
1048
+ "expect": {
1049
+ "permissions": {
1050
+ "doc.view": "own"
1051
+ },
1052
+ "sources": [
1053
+ {
1054
+ "roleId": "r-viewer",
1055
+ "source": "unassigned"
1056
+ }
1057
+ ],
1058
+ "assignedDomains": [
1059
+ {
1060
+ "type": "org",
1061
+ "id": "o9"
1062
+ }
1063
+ ],
1064
+ "decisions": [
1065
+ {
1066
+ "permission": "doc.view",
1067
+ "allowed": true,
1068
+ "scope": "own",
1069
+ "reason": "granted"
1070
+ }
1071
+ ]
1072
+ }
1073
+ },
1074
+ {
1075
+ "id": "ACC-C-018",
1076
+ "description": "A direct assignment and an inherited one union; the direct one is not narrowed",
1077
+ "subject": {
1078
+ "userId": "u1",
1079
+ "hostRoles": ["user"]
1080
+ },
1081
+ "assignments": [
1082
+ {
1083
+ "id": "a1",
1084
+ "roleId": "r-viewer",
1085
+ "principal": {
1086
+ "kind": "user",
1087
+ "id": "u1",
1088
+ "includeDescendants": false,
1089
+ "unitRoles": null
1090
+ },
1091
+ "domain": {
1092
+ "type": "org",
1093
+ "id": "o3"
1094
+ }
1095
+ },
1096
+ {
1097
+ "id": "a2",
1098
+ "roleId": "r-admin",
1099
+ "principal": {
1100
+ "kind": "user",
1101
+ "id": "u1",
1102
+ "includeDescendants": false,
1103
+ "unitRoles": null
1104
+ },
1105
+ "domain": {
1106
+ "type": "org",
1107
+ "id": "o2"
1108
+ }
1109
+ }
1110
+ ],
1111
+ "memberships": [],
1112
+ "unassignedRoleId": null,
1113
+ "domain": {
1114
+ "type": "org",
1115
+ "id": "o3"
1116
+ },
1117
+ "inheritance": {
1118
+ "ancestors": [
1119
+ {
1120
+ "type": "org",
1121
+ "id": "o2"
1122
+ },
1123
+ {
1124
+ "type": "org",
1125
+ "id": "o1"
1126
+ }
1127
+ ],
1128
+ "inherit": {
1129
+ "keep": ["doc.view", "report.export"],
1130
+ "add": {}
1131
+ }
1132
+ },
1133
+ "expect": {
1134
+ "permissions": {
1135
+ "doc.view": "all",
1136
+ "report.export": true
1137
+ },
1138
+ "sources": [
1139
+ {
1140
+ "roleId": "r-viewer",
1141
+ "source": "assignment"
1142
+ },
1143
+ {
1144
+ "roleId": "r-admin",
1145
+ "source": "assignment",
1146
+ "inherited": true
1147
+ }
1148
+ ],
1149
+ "assignedDomains": [
1150
+ {
1151
+ "type": "org",
1152
+ "id": "o3"
1153
+ },
1154
+ {
1155
+ "type": "org",
1156
+ "id": "o2"
1157
+ }
1158
+ ],
1159
+ "decisions": [
1160
+ {
1161
+ "permission": "doc.view",
1162
+ "allowed": true,
1163
+ "scope": "all",
1164
+ "reason": "granted"
1165
+ },
1166
+ {
1167
+ "permission": "access.manage",
1168
+ "allowed": false,
1169
+ "scope": null,
1170
+ "reason": "not_granted"
1171
+ }
1172
+ ]
1173
+ }
1174
+ },
1175
+ {
1176
+ "id": "ACC-C-019",
1177
+ "description": "At the ancestor itself the role applies whole: inherit governs only what passes down",
1178
+ "subject": {
1179
+ "userId": "u1",
1180
+ "hostRoles": ["user"]
1181
+ },
1182
+ "assignments": [
1183
+ {
1184
+ "id": "a1",
1185
+ "roleId": "r-editor",
1186
+ "principal": {
1187
+ "kind": "user",
1188
+ "id": "u1",
1189
+ "includeDescendants": false,
1190
+ "unitRoles": null
1191
+ },
1192
+ "domain": {
1193
+ "type": "org",
1194
+ "id": "o1"
1195
+ }
1196
+ }
1197
+ ],
1198
+ "memberships": [],
1199
+ "unassignedRoleId": "r-viewer",
1200
+ "domain": {
1201
+ "type": "org",
1202
+ "id": "o1"
1203
+ },
1204
+ "inheritance": {
1205
+ "ancestors": [],
1206
+ "inherit": {
1207
+ "keep": ["doc.view"],
1208
+ "add": {}
1209
+ }
1210
+ },
1211
+ "expect": {
1212
+ "permissions": {
1213
+ "doc.edit": "team",
1214
+ "doc.view": "team",
1215
+ "report.export": true
1216
+ },
1217
+ "sources": [
1218
+ {
1219
+ "roleId": "r-editor",
1220
+ "source": "assignment"
1221
+ }
1222
+ ],
1223
+ "assignedDomains": [
1224
+ {
1225
+ "type": "org",
1226
+ "id": "o1"
1227
+ }
1228
+ ],
1229
+ "decisions": [
1230
+ {
1231
+ "permission": "report.export",
1232
+ "allowed": true,
1233
+ "scope": null,
1234
+ "reason": "granted"
1235
+ }
1236
+ ]
1237
+ }
1238
+ },
1239
+ {
1240
+ "id": "ACC-C-020",
1241
+ "description": "An ancestor's role that inherit passes nothing of does not reach below: it is no source, and the default applies",
1242
+ "subject": {
1243
+ "userId": "u1",
1244
+ "hostRoles": ["user"]
1245
+ },
1246
+ "assignments": [
1247
+ {
1248
+ "id": "a1",
1249
+ "roleId": "r-editor",
1250
+ "principal": {
1251
+ "kind": "user",
1252
+ "id": "u1",
1253
+ "includeDescendants": false,
1254
+ "unitRoles": null
1255
+ },
1256
+ "domain": {
1257
+ "type": "org",
1258
+ "id": "o1"
1259
+ }
1260
+ }
1261
+ ],
1262
+ "memberships": [],
1263
+ "unassignedRoleId": "r-viewer",
1264
+ "domain": {
1265
+ "type": "org",
1266
+ "id": "o3"
1267
+ },
1268
+ "inheritance": {
1269
+ "ancestors": [
1270
+ {
1271
+ "type": "org",
1272
+ "id": "o2"
1273
+ },
1274
+ {
1275
+ "type": "org",
1276
+ "id": "o1"
1277
+ }
1278
+ ],
1279
+ "inherit": {
1280
+ "keep": [],
1281
+ "add": {}
1282
+ }
1283
+ },
1284
+ "expect": {
1285
+ "permissions": {
1286
+ "doc.view": "own"
1287
+ },
1288
+ "sources": [
1289
+ {
1290
+ "roleId": "r-viewer",
1291
+ "source": "unassigned"
1292
+ }
1293
+ ],
1294
+ "assignedDomains": [
1295
+ {
1296
+ "type": "org",
1297
+ "id": "o1"
1298
+ }
1299
+ ],
1300
+ "decisions": [
1301
+ {
1302
+ "permission": "doc.edit",
1303
+ "allowed": false,
1304
+ "scope": null,
1305
+ "reason": "not_granted"
1306
+ }
1307
+ ]
1308
+ }
1309
+ },
1310
+ {
1311
+ "id": "ACC-C-021",
1312
+ "description": "A default role holding access.manage — a built-in the catalog changed after the tenant chose it — confers everything but managing access",
1313
+ "subject": {
1314
+ "userId": "u1",
1315
+ "hostRoles": ["user"]
1316
+ },
1317
+ "assignments": [],
1318
+ "memberships": [],
1319
+ "unassignedRoleId": "r-admin",
1320
+ "domain": null,
1321
+ "expect": {
1322
+ "permissions": {
1323
+ "doc.edit": "all",
1324
+ "doc.view": "all",
1325
+ "doc.delete": "all",
1326
+ "report.export": true,
1327
+ "settings.edit": true
1328
+ },
1329
+ "sources": [
1330
+ {
1331
+ "roleId": "r-admin",
1332
+ "source": "unassigned"
1333
+ }
1334
+ ],
1335
+ "assignedDomains": [],
1336
+ "decisions": [
1337
+ {
1338
+ "permission": "access.manage",
1339
+ "allowed": false,
1340
+ "scope": null,
1341
+ "reason": "not_granted"
1342
+ },
1343
+ {
1344
+ "permission": "access.audit",
1345
+ "allowed": false,
1346
+ "scope": null,
1347
+ "reason": "not_granted"
1348
+ },
1349
+ {
1350
+ "permission": "settings.edit",
1351
+ "allowed": true,
1352
+ "scope": null,
1353
+ "reason": "granted"
1354
+ }
1355
+ ]
1356
+ }
1357
+ }
1358
+ ]
1359
+ }