@aigile/engine 0.2.1 → 0.4.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.
Files changed (198) hide show
  1. package/dist/action-item-features.d.ts +33 -0
  2. package/dist/action-item-features.d.ts.map +1 -0
  3. package/dist/action-item-features.js +113 -0
  4. package/dist/action-item-features.js.map +1 -0
  5. package/dist/action-items.d.ts +234 -0
  6. package/dist/action-items.d.ts.map +1 -0
  7. package/dist/action-items.js +722 -0
  8. package/dist/action-items.js.map +1 -0
  9. package/dist/action-sources.d.ts +44 -0
  10. package/dist/action-sources.d.ts.map +1 -0
  11. package/dist/action-sources.js +141 -0
  12. package/dist/action-sources.js.map +1 -0
  13. package/dist/agent-roles.d.ts +9 -0
  14. package/dist/agent-roles.d.ts.map +1 -0
  15. package/dist/agent-roles.js +18 -0
  16. package/dist/agent-roles.js.map +1 -0
  17. package/dist/agent-tasks.d.ts +36 -0
  18. package/dist/agent-tasks.d.ts.map +1 -0
  19. package/dist/agent-tasks.js +151 -0
  20. package/dist/agent-tasks.js.map +1 -0
  21. package/dist/agents/orchestrator.d.ts +26 -6
  22. package/dist/agents/orchestrator.d.ts.map +1 -1
  23. package/dist/agents/orchestrator.js +95 -45
  24. package/dist/agents/orchestrator.js.map +1 -1
  25. package/dist/agents/spec-analyst.d.ts +81 -13
  26. package/dist/agents/spec-analyst.d.ts.map +1 -1
  27. package/dist/agents/spec-analyst.js +350 -89
  28. package/dist/agents/spec-analyst.js.map +1 -1
  29. package/dist/ai-service.d.ts +40 -0
  30. package/dist/ai-service.d.ts.map +1 -1
  31. package/dist/ai-service.js +94 -9
  32. package/dist/ai-service.js.map +1 -1
  33. package/dist/api-tokens.d.ts +67 -0
  34. package/dist/api-tokens.d.ts.map +1 -0
  35. package/dist/api-tokens.js +89 -0
  36. package/dist/api-tokens.js.map +1 -0
  37. package/dist/attachments/extract.d.ts +26 -0
  38. package/dist/attachments/extract.d.ts.map +1 -0
  39. package/dist/attachments/extract.js +160 -0
  40. package/dist/attachments/extract.js.map +1 -0
  41. package/dist/attachments/fixtures.d.ts +9 -0
  42. package/dist/attachments/fixtures.d.ts.map +1 -0
  43. package/dist/attachments/fixtures.js +58 -0
  44. package/dist/attachments/fixtures.js.map +1 -0
  45. package/dist/attachments/service.d.ts +71 -0
  46. package/dist/attachments/service.d.ts.map +1 -0
  47. package/dist/attachments/service.js +220 -0
  48. package/dist/attachments/service.js.map +1 -0
  49. package/dist/build-service.d.ts +1 -1
  50. package/dist/build-service.d.ts.map +1 -1
  51. package/dist/build-service.js +9 -4
  52. package/dist/build-service.js.map +1 -1
  53. package/dist/change-events.d.ts +110 -0
  54. package/dist/change-events.d.ts.map +1 -0
  55. package/dist/change-events.js +238 -0
  56. package/dist/change-events.js.map +1 -0
  57. package/dist/change-sets.d.ts +110 -0
  58. package/dist/change-sets.d.ts.map +1 -0
  59. package/dist/change-sets.js +188 -0
  60. package/dist/change-sets.js.map +1 -0
  61. package/dist/command-runner.d.ts.map +1 -1
  62. package/dist/command-runner.js +2 -1
  63. package/dist/command-runner.js.map +1 -1
  64. package/dist/conversations.d.ts +2 -1
  65. package/dist/conversations.d.ts.map +1 -1
  66. package/dist/conversations.js +1 -1
  67. package/dist/conversations.js.map +1 -1
  68. package/dist/data-access.d.ts +9 -2
  69. package/dist/data-access.d.ts.map +1 -1
  70. package/dist/data-access.js +38 -6
  71. package/dist/data-access.js.map +1 -1
  72. package/dist/decisions.d.ts +56 -0
  73. package/dist/decisions.d.ts.map +1 -0
  74. package/dist/decisions.js +76 -0
  75. package/dist/decisions.js.map +1 -0
  76. package/dist/deliverables.d.ts +96 -0
  77. package/dist/deliverables.d.ts.map +1 -0
  78. package/dist/deliverables.js +344 -0
  79. package/dist/deliverables.js.map +1 -0
  80. package/dist/designs.d.ts +30 -0
  81. package/dist/designs.d.ts.map +1 -0
  82. package/dist/designs.js +154 -0
  83. package/dist/designs.js.map +1 -0
  84. package/dist/git-host.d.ts +10 -0
  85. package/dist/git-host.d.ts.map +1 -1
  86. package/dist/git-host.js +30 -2
  87. package/dist/git-host.js.map +1 -1
  88. package/dist/grounding.d.ts +9 -0
  89. package/dist/grounding.d.ts.map +1 -0
  90. package/dist/grounding.js +12 -0
  91. package/dist/grounding.js.map +1 -0
  92. package/dist/index.d.ts +35 -12
  93. package/dist/index.d.ts.map +1 -1
  94. package/dist/index.js +33 -10
  95. package/dist/index.js.map +1 -1
  96. package/dist/jira-features.d.ts +142 -0
  97. package/dist/jira-features.d.ts.map +1 -0
  98. package/dist/jira-features.js +366 -0
  99. package/dist/jira-features.js.map +1 -0
  100. package/dist/milestones.js +1 -1
  101. package/dist/milestones.js.map +1 -1
  102. package/dist/pull-request-sync.d.ts.map +1 -1
  103. package/dist/pull-request-sync.js +10 -6
  104. package/dist/pull-request-sync.js.map +1 -1
  105. package/dist/questions.d.ts +100 -10
  106. package/dist/questions.d.ts.map +1 -1
  107. package/dist/questions.js +211 -22
  108. package/dist/questions.js.map +1 -1
  109. package/dist/related.d.ts +26 -0
  110. package/dist/related.d.ts.map +1 -0
  111. package/dist/related.js +64 -0
  112. package/dist/related.js.map +1 -0
  113. package/dist/release-gates.d.ts +16 -0
  114. package/dist/release-gates.d.ts.map +1 -0
  115. package/dist/release-gates.js +47 -0
  116. package/dist/release-gates.js.map +1 -0
  117. package/dist/reviews.d.ts.map +1 -1
  118. package/dist/reviews.js +4 -3
  119. package/dist/reviews.js.map +1 -1
  120. package/dist/router.d.ts +2 -2
  121. package/dist/router.d.ts.map +1 -1
  122. package/dist/router.js.map +1 -1
  123. package/dist/scheduler.d.ts +41 -5
  124. package/dist/scheduler.d.ts.map +1 -1
  125. package/dist/scheduler.js +109 -7
  126. package/dist/scheduler.js.map +1 -1
  127. package/dist/services.d.ts +760 -15
  128. package/dist/services.d.ts.map +1 -1
  129. package/dist/services.js +402 -20
  130. package/dist/services.js.map +1 -1
  131. package/dist/source-sync.d.ts +136 -0
  132. package/dist/source-sync.d.ts.map +1 -0
  133. package/dist/source-sync.js +370 -0
  134. package/dist/source-sync.js.map +1 -0
  135. package/dist/sources/front-matter.d.ts +20 -0
  136. package/dist/sources/front-matter.d.ts.map +1 -0
  137. package/dist/sources/front-matter.js +57 -0
  138. package/dist/sources/front-matter.js.map +1 -0
  139. package/dist/sources/git.d.ts +80 -0
  140. package/dist/sources/git.d.ts.map +1 -0
  141. package/dist/sources/git.js +338 -0
  142. package/dist/sources/git.js.map +1 -0
  143. package/dist/sources/http.d.ts +54 -0
  144. package/dist/sources/http.d.ts.map +1 -0
  145. package/dist/sources/http.js +79 -0
  146. package/dist/sources/http.js.map +1 -0
  147. package/dist/spec-cache.d.ts +54 -0
  148. package/dist/spec-cache.d.ts.map +1 -0
  149. package/dist/spec-cache.js +133 -0
  150. package/dist/spec-cache.js.map +1 -0
  151. package/dist/spec-links.d.ts +68 -0
  152. package/dist/spec-links.d.ts.map +1 -0
  153. package/dist/spec-links.js +144 -0
  154. package/dist/spec-links.js.map +1 -0
  155. package/dist/spec-reader.d.ts +44 -0
  156. package/dist/spec-reader.d.ts.map +1 -0
  157. package/dist/spec-reader.js +81 -0
  158. package/dist/spec-reader.js.map +1 -0
  159. package/dist/spec-resolver.d.ts +13 -1
  160. package/dist/spec-resolver.d.ts.map +1 -1
  161. package/dist/spec-resolver.js +45 -8
  162. package/dist/spec-resolver.js.map +1 -1
  163. package/dist/spec-tools.d.ts +10 -0
  164. package/dist/spec-tools.d.ts.map +1 -0
  165. package/dist/spec-tools.js +103 -0
  166. package/dist/spec-tools.js.map +1 -0
  167. package/dist/task-scope.d.ts +11 -0
  168. package/dist/task-scope.d.ts.map +1 -0
  169. package/dist/task-scope.js +11 -0
  170. package/dist/task-scope.js.map +1 -0
  171. package/dist/telemetry.d.ts +34 -0
  172. package/dist/telemetry.d.ts.map +1 -0
  173. package/dist/telemetry.js +72 -0
  174. package/dist/telemetry.js.map +1 -0
  175. package/dist/template.d.ts +341 -0
  176. package/dist/template.d.ts.map +1 -0
  177. package/dist/template.js +142 -0
  178. package/dist/template.js.map +1 -0
  179. package/dist/tool-sandbox.d.ts.map +1 -1
  180. package/dist/tool-sandbox.js +2 -2
  181. package/dist/tool-sandbox.js.map +1 -1
  182. package/dist/tracks.d.ts +3 -3
  183. package/dist/tracks.js +1 -1
  184. package/dist/tracks.js.map +1 -1
  185. package/dist/verifier.d.ts.map +1 -1
  186. package/dist/verifier.js +8 -7
  187. package/dist/verifier.js.map +1 -1
  188. package/dist/vscode-connect.d.ts +48 -0
  189. package/dist/vscode-connect.d.ts.map +1 -0
  190. package/dist/vscode-connect.js +105 -0
  191. package/dist/vscode-connect.js.map +1 -0
  192. package/package.json +14 -3
  193. package/prompts/agent-task.contract.md +9 -0
  194. package/prompts/orchestrator.brief.md +17 -0
  195. package/prompts/orchestrator.contract.md +7 -0
  196. package/prompts/spec-analyst.brief.md +19 -0
  197. package/prompts/spec-analyst.contract.md +5 -0
  198. package/prompts/spec-analyst.sweep.md +2 -0
@@ -1 +1 @@
1
- {"version":3,"file":"services.d.ts","sourceRoot":"","sources":["../src/services.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,QAAQ,EAER,SAAS,EACT,OAAO,EACP,YAAY,EACZ,OAAO,EACP,YAAY,EACZ,IAAI,EACJ,cAAc,EACd,IAAI,EACJ,IAAI,EACJ,WAAW,EACZ,MAAM,cAAc,CAAC;AAoBtB,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,KAAK,QAAQ,EAAa,MAAM,gBAAgB,CAAC;AAE1D;;;;;;;GAOG;AAEH,MAAM,WAAW,KAAK;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,uEAAuE;IACvE,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,UAAU,GAAG,QAAQ,CAAC;AAC9D,eAAO,MAAM,iBAAiB,EAAE,SAAS,cAAc,EAAqC,CAAC;AAE7F,iDAA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e,EAAE,SAAS,MAAM,EAAE,CAAC;QAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAA;KAAE,GAAG,OAAO;YAM/G,gBAAgB;IAO9B,kGAAkG;IAC5F,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAIrC;;;;OAIG;IACG,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAKjD,iHAAiH;IAC3G,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAUhF,OAAO,CAAC,YAAY;YAIN,WAAW;CAM1B"}
package/dist/services.js CHANGED
@@ -1,6 +1,8 @@
1
- import { ADMIN_APP_ROLES, DECIDING_APP_ROLES, COLLECTIONS, conflictSchema, conflictStatusSchema, messageSchema, newId, nowIso, organizationSchema, parseRole, parseUser, fullName, projectSchema, roleAssignmentSchema, roleSchema, specSchema, userSchema, } from '@aigile/core';
1
+ import { SUBJECT_LABELS, subjectOf } from '@aigile/core';
2
+ import { ADMIN_APP_ROLES, DECIDING_APP_ROLES, COLLECTIONS, conflictSchema, conflictStatusSchema, messageSchema, newId, nowIso, organizationSchema, parseRole, parseUser, fullName, projectSchema, roleAssignmentSchema, roleSchema, specSchema, userSchema, specDraftSchema, SourceConflictError, wouldCycle, } from '@aigile/core';
2
3
  import { z } from 'zod';
3
4
  import { DataAccess } from './data-access.js';
5
+ import { specReaderFor } from './spec-reader.js';
4
6
  import { diffLines } from './text-diff.js';
5
7
  export const CHILDREN_POLICIES = ['refuse', 'reparent', 'delete'];
6
8
  /** An error the API can map to a status code. */
@@ -28,19 +30,21 @@ function defined(obj) {
28
30
  const stamp = { id: true, createdAt: true, updatedAt: true };
29
31
  export const organizationInputSchema = organizationSchema.omit(stamp);
30
32
  /** What a person may change about themselves. */
31
- export const profileInputSchema = userSchema.pick({ firstName: true, lastName: true, email: true, jobTitle: true, organizationId: true }).partial();
33
+ export const profileInputSchema = userSchema.pick({ firstName: true, lastName: true, email: true, jobTitle: true, organizationId: true, prioritySetterIds: true, defersTo: true }).partial();
32
34
  /** What an admin may change about a user: the profile fields plus `disabled`. */
33
35
  export const userAdminInputSchema = userSchema
34
- .pick({ firstName: true, lastName: true, email: true, jobTitle: true, organizationId: true, managerId: true, disabled: true })
36
+ .pick({ firstName: true, lastName: true, email: true, jobTitle: true, organizationId: true, managerId: true, disabled: true, prioritySetterIds: true, defersTo: true })
35
37
  .partial();
36
38
  /** The ranking is not typed in: it comes from the order of the roles (RoleService.reorder). */
37
- export const roleInputSchema = roleSchema.omit(stamp).omit({ ranking: true });
39
+ /** What a person may set on a role: never its origin or whether it is the seeded instance (the install and a fork set those). */
40
+ export const roleInputSchema = roleSchema.omit(stamp).omit({ ranking: true, origin: true, seeded: true });
38
41
  export const RANKING_STEP = 10;
39
42
  export const roleAssignmentInputSchema = roleAssignmentSchema.omit(stamp);
40
43
  /** Kept for callers that still read it; administration follows the application role now. */
41
44
  export const ADMIN_RANKING = 80;
42
45
  export const projectInputSchema = projectSchema.omit(stamp);
43
- export const specInputSchema = specSchema.omit(stamp).omit({ authorUserId: true });
46
+ /** What a person may set on a spec: never its author or its provenance (the sync sets `source`). */
47
+ export const specInputSchema = specSchema.omit(stamp).omit({ authorUserId: true, source: true, anchored: true, subject: true });
44
48
  export class OrganizationService {
45
49
  store;
46
50
  data;
@@ -62,7 +66,7 @@ export class OrganizationService {
62
66
  if (data.parentId !== null)
63
67
  await this.get(data.parentId);
64
68
  const ts = nowIso();
65
- const org = { id: newId(), ...data, createdAt: ts, updatedAt: ts };
69
+ const org = { id: newId('organization'), ...data, createdAt: ts, updatedAt: ts };
66
70
  await this.store.put(COLLECTIONS.organizations, org.id, org, {
67
71
  message: `Create organization ${org.name}`,
68
72
  ...(actor.author ? { author: actor.author } : {}),
@@ -155,7 +159,7 @@ export class ProjectService {
155
159
  const data = parse(projectInputSchema, input);
156
160
  await this.assertReferences(data.organizationId, data.parentProjectId, null);
157
161
  const ts = nowIso();
158
- const project = { id: newId(), ...data, createdAt: ts, updatedAt: ts };
162
+ const project = { id: newId('project'), ...data, createdAt: ts, updatedAt: ts };
159
163
  await this.store.put(COLLECTIONS.projects, project.id, project, {
160
164
  message: `Create project ${project.name}`,
161
165
  ...(actor.author ? { author: actor.author } : {}),
@@ -199,6 +203,28 @@ export class ProjectService {
199
203
  await remapReferences(this.store, 'projectIds', id, children === 'reparent' ? project.parentProjectId : null, actor);
200
204
  await this.store.delete(COLLECTIONS.projects, id, write(`Delete project ${project.name}`));
201
205
  }
206
+ /**
207
+ * Which role instance plays a seat for this project (documentation/templates.md
208
+ * "Instances"): a role on that seat, or null to use the installation's shared
209
+ * instance again. Pointing two projects at one role is this call, made on
210
+ * purpose; forking makes them independent again.
211
+ */
212
+ async setAgentRole(projectId, agentKey, roleId, actor) {
213
+ const project = await this.get(projectId);
214
+ if (roleId) {
215
+ const role = await new RoleService(this.store).get(roleId);
216
+ if (role.agentKey !== agentKey)
217
+ throw new ServiceError(400, `${role.name} is not on the ${agentKey} seat`);
218
+ }
219
+ const agentRoleIds = { ...project.agentRoleIds };
220
+ if (roleId)
221
+ agentRoleIds[agentKey] = roleId;
222
+ else
223
+ delete agentRoleIds[agentKey];
224
+ const next = { ...project, agentRoleIds, updatedAt: nowIso() };
225
+ await this.store.put(COLLECTIONS.projects, projectId, next, { message: `Project ${project.name}: ${agentKey} is ${roleId ? 'its own role' : 'the shared role'}`, ...(actor.author ? { author: actor.author } : {}) });
226
+ return next;
227
+ }
202
228
  async assertReferences(organizationId, parentProjectId, selfId) {
203
229
  if ((await this.store.get(COLLECTIONS.organizations, organizationId)) === null) {
204
230
  throw notFound('organization', organizationId);
@@ -274,18 +300,177 @@ export class SpecService {
274
300
  async create(input, actor) {
275
301
  return (await this.createRevision(input, actor)).spec;
276
302
  }
277
- /** Create, and say which revision the datastore gave it (what the Spec Analyst reviews). */
303
+ /**
304
+ * Create, and say which revision it got (what the Spec Analyst reviews).
305
+ * With a writable source configured for new specs (`specs.source`), the
306
+ * document is written there first and the record points at it; otherwise
307
+ * the datastore holds it.
308
+ */
278
309
  async createRevision(input, actor) {
279
310
  const data = parse(specInputSchema, input);
280
311
  await this.assertMappings(data);
312
+ if (data.parentId)
313
+ await this.assertParent(null, data.parentId);
281
314
  const ts = nowIso();
282
- const spec = { id: newId(), ...data, authorUserId: actor.userId, createdAt: ts, updatedAt: ts };
315
+ const target = specReaderFor(this.store)?.createIn ?? null;
316
+ if (target) {
317
+ if (!target.capabilities.write || !target.write)
318
+ throw new ServiceError(409, `source ${target.id} does not take saves; new specs cannot be created there`);
319
+ const written = await this.writeToSource(target, { externalId: null, title: data.title, content: data.content, baseVersion: null, actor, message: `Create spec ${data.title}` });
320
+ const spec = { id: newId('spec'), ...data, authorUserId: actor.userId, subject: null, source: { sourceId: target.id, kind: target.kind, externalId: written.externalId, version: written.version, url: written.url, syncedAt: ts, removedAt: null, meta: {} }, anchored: false, createdAt: ts, updatedAt: ts };
321
+ await this.store.put(COLLECTIONS.specs, spec.id, spec, { message: `Create spec ${spec.title} in ${target.id}`, ...(actor.author ? { author: actor.author } : {}) });
322
+ return { spec, revision: { revision: written.version, timestamp: ts, message: `Create spec ${spec.title}`, ...(actor.author ? { author: actor.author.name } : {}) } };
323
+ }
324
+ const spec = { id: newId('spec'), ...data, authorUserId: actor.userId, source: null, anchored: false, subject: null, createdAt: ts, updatedAt: ts };
283
325
  const revision = await this.store.put(COLLECTIONS.specs, spec.id, spec, {
284
326
  message: `Create spec ${spec.title}`,
285
327
  ...(actor.author ? { author: actor.author } : {}),
286
328
  });
287
329
  return { spec, revision };
288
330
  }
331
+ /** The inline spec of an organization, project, user or role (documentation/specs.md "Inline specs"), or null when none is written yet. */
332
+ async inline(subject) {
333
+ return (await this.list()).find((s) => {
334
+ const of = subjectOf(s);
335
+ return of !== null && of.kind === subject.kind && of.id === subject.id;
336
+ }) ?? null;
337
+ }
338
+ /**
339
+ * Write a subject's inline spec: created on first save, mapped to the
340
+ * subject alone, titled after it ("Project: FD Cloud"); an organization's is
341
+ * its Charter. Kept in the datastore, never sent to a source for new specs.
342
+ */
343
+ async saveInline(subject, name, content, actor) {
344
+ const existing = await this.inline(subject);
345
+ const title = `${SUBJECT_LABELS[subject.kind]}: ${name}`;
346
+ if (existing?.source)
347
+ return this.save(existing.id, actor, { title, content });
348
+ const ts = nowIso();
349
+ const only = (kind) => (subject.kind === kind ? [subject.id] : []);
350
+ const spec = existing
351
+ ? { ...existing, title, content, subject, updatedAt: ts }
352
+ : {
353
+ id: `inline-${subject.kind}-${subject.id}`,
354
+ title,
355
+ content,
356
+ authorUserId: actor.userId,
357
+ organizationIds: only('organization'),
358
+ projectIds: only('project'),
359
+ roleIds: only('role'),
360
+ userIds: only('user'),
361
+ seed: null,
362
+ source: null,
363
+ grounding: subject.kind === 'organization',
364
+ parentId: null,
365
+ order: null,
366
+ anchored: false,
367
+ subject,
368
+ createdAt: ts,
369
+ updatedAt: ts,
370
+ };
371
+ const revision = await this.store.put(COLLECTIONS.specs, spec.id, spec, { message: `${existing ? 'Revise' : 'Write'} the spec of ${title}`, ...(actor.author ? { author: actor.author } : {}) });
372
+ await this.discardDraft(spec.id, actor);
373
+ return { spec, revision };
374
+ }
375
+ /** The edit in progress on a spec, if any. */
376
+ async draft(id) {
377
+ const raw = await this.store.get(COLLECTIONS.specDrafts, id);
378
+ return raw === null ? null : specDraftSchema.parse(raw);
379
+ }
380
+ /** Keep an edit in progress beside the spec; nothing reaches the source until `save`. */
381
+ async saveDraft(id, input, actor) {
382
+ const spec = await this.get(id);
383
+ const data = defined(parse(specInputSchema.pick({ title: true, content: true }).partial(), input));
384
+ const existing = await this.draft(id);
385
+ const ts = nowIso();
386
+ const draft = {
387
+ id,
388
+ title: data.title ?? existing?.title ?? spec.title,
389
+ content: data.content ?? existing?.content ?? spec.content,
390
+ authorUserId: actor.userId,
391
+ baseRevision: existing?.baseRevision ?? (await this.data.specCurrentRevision(id)),
392
+ createdAt: existing?.createdAt ?? ts,
393
+ updatedAt: ts,
394
+ };
395
+ await this.store.put(COLLECTIONS.specDrafts, id, draft, { message: `Draft of spec ${draft.title}`, ...(actor.author ? { author: actor.author } : {}) });
396
+ return draft;
397
+ }
398
+ async discardDraft(id, actor) {
399
+ if ((await this.draft(id)) === null)
400
+ return;
401
+ await this.store.delete(COLLECTIONS.specDrafts, id, { message: `Discard the draft of spec ${id}`, ...(actor.author ? { author: actor.author } : {}) });
402
+ }
403
+ /**
404
+ * Save the draft (or the title and content given) as the spec's next
405
+ * version: at its source when it has one, else in the datastore. The draft
406
+ * goes away; the revision is the source's version id.
407
+ */
408
+ async save(id, actor, input) {
409
+ const spec = await this.get(id);
410
+ const given = input === undefined ? {} : defined(parse(specInputSchema.pick({ title: true, content: true }).partial(), input));
411
+ const draft = await this.draft(id);
412
+ const title = given.title ?? draft?.title ?? spec.title;
413
+ const content = given.content ?? draft?.content ?? spec.content;
414
+ const ts = nowIso();
415
+ if (!spec.source) {
416
+ const next = { ...spec, title, content, updatedAt: ts };
417
+ const revision = await this.store.put(COLLECTIONS.specs, id, next, { message: `Revise spec ${title}`, ...(actor.author ? { author: actor.author } : {}) });
418
+ await this.discardDraft(id, actor);
419
+ return { spec: next, revision };
420
+ }
421
+ const reader = specReaderFor(this.store);
422
+ const source = reader?.source(spec.source.sourceId) ?? null;
423
+ if (!source)
424
+ throw new ServiceError(409, `source ${spec.source.sourceId} is not configured; the spec cannot be saved there`);
425
+ if (!source.capabilities.write || !source.write)
426
+ throw new ServiceError(409, `source ${spec.source.sourceId} does not take saves; edit the document there${spec.source.url ? ` (${spec.source.url})` : ''}`);
427
+ const written = await this.writeToSource(source, { externalId: spec.source.externalId, title, content, baseVersion: draft?.baseRevision ?? spec.source.version, actor, message: `Revise spec ${title}` });
428
+ return this.applyWritten(spec, title, content, written, actor, `Revise spec ${title}`);
429
+ }
430
+ /** Record a version the source now holds (after a save there): the record, the cache, the draft gone. */
431
+ async applyWritten(spec, title, content, written, actor, message) {
432
+ if (!spec.source)
433
+ throw new ServiceError(409, `spec ${spec.id} has no source`);
434
+ const ts = nowIso();
435
+ const reader = specReaderFor(this.store);
436
+ if (reader)
437
+ await reader.warm(spec.source.sourceId, { externalId: written.externalId, title, content, author: actor.author ? { name: actor.author.name, email: actor.author.email } : null, version: written.version, updatedAt: ts, url: written.url, mappings: null });
438
+ const next = { ...spec, title, content, updatedAt: ts, source: { ...spec.source, externalId: written.externalId, version: written.version, url: written.url, syncedAt: ts, removedAt: null } };
439
+ await this.store.put(COLLECTIONS.specs, spec.id, next, { message: `Save spec ${title} to ${spec.source.sourceId} @ ${written.version.slice(0, 12)}`, ...(actor.author ? { author: actor.author } : {}) });
440
+ await this.discardDraft(spec.id, actor);
441
+ return { spec: next, revision: { revision: written.version, timestamp: ts, message, ...(actor.author ? { author: actor.author.name } : {}) } };
442
+ }
443
+ /** A record for a document a source now holds (created there by a change set). */
444
+ async recordCreated(input, source, written, actor) {
445
+ await this.assertMappings({ ...input, userIds: [] });
446
+ const ts = nowIso();
447
+ const spec = { id: newId('spec'), title: input.title, content: input.content, organizationIds: input.organizationIds, projectIds: input.projectIds, roleIds: input.roleIds, userIds: [], seed: null, subject: null, authorUserId: actor.userId, source: { sourceId: source.id, kind: source.kind, externalId: written.externalId, version: written.version, url: written.url, syncedAt: ts, removedAt: null, meta: {} }, grounding: false, parentId: null, order: null, anchored: false, createdAt: ts, updatedAt: ts };
448
+ await this.store.put(COLLECTIONS.specs, spec.id, spec, { message: `Create spec ${spec.title} in ${source.id}`, ...(actor.author ? { author: actor.author } : {}) });
449
+ const reader = specReaderFor(this.store);
450
+ if (reader)
451
+ await reader.warm(source.id, { externalId: written.externalId, title: spec.title, content: spec.content, author: actor.author ? { name: actor.author.name, email: actor.author.email } : null, version: written.version, updatedAt: ts, url: written.url, mappings: null });
452
+ return spec;
453
+ }
454
+ /** Mark a sourced spec removed after its source dropped the document (the record stays, hidden). */
455
+ async recordRemoved(spec, actor) {
456
+ if (!spec.source)
457
+ throw new ServiceError(409, `spec ${spec.id} has no source`);
458
+ const ts = nowIso();
459
+ const next = { ...spec, updatedAt: ts, source: { ...spec.source, removedAt: ts } };
460
+ await this.store.put(COLLECTIONS.specs, spec.id, next, { message: `Remove spec ${spec.title} at ${spec.source.sourceId}`, ...(actor.author ? { author: actor.author } : {}) });
461
+ await this.discardDraft(spec.id, actor);
462
+ return next;
463
+ }
464
+ async writeToSource(source, w) {
465
+ try {
466
+ return await source.write({ externalId: w.externalId, title: w.title, content: w.content, baseVersion: w.baseVersion, author: w.actor.author ? { name: w.actor.author.name, email: w.actor.author.email } : null, message: w.message });
467
+ }
468
+ catch (err) {
469
+ if (err instanceof SourceConflictError)
470
+ throw new ServiceError(409, `${err.message}; take the newer version into the draft and save again`);
471
+ throw err;
472
+ }
473
+ }
289
474
  /** Every update is a new revision; the author of the spec stays its creator. */
290
475
  async update(id, input, actor) {
291
476
  return (await this.revise(id, input, actor)).spec;
@@ -294,8 +479,26 @@ export class SpecService {
294
479
  async revise(id, input, actor) {
295
480
  const current = await this.get(id);
296
481
  const data = defined(parse(specInputSchema.partial(), input));
297
- const next = { ...current, ...data, updatedAt: nowIso() };
482
+ if (current.source) {
483
+ // A sourced spec's text is the source's: it changes through a draft and a save, never here.
484
+ const changed = ['title', 'content'].filter((k) => data[k] !== undefined && data[k] !== current[k]);
485
+ if (changed.length > 0)
486
+ throw new ServiceError(409, `spec ${id} lives at ${current.source.kind} source ${current.source.sourceId}: save a draft and save it to the source${current.source.url ? `, or edit it there (${current.source.url})` : ''}`);
487
+ // Its place in the outline is the source's (a page's parent, a file's folder), except under a spec of another source or one written in aigile: an anchor the sync keeps (documentation/sources.md "Outlines"). Back to null gives the source its say again.
488
+ const reparent = data.parentId !== undefined && data.parentId !== current.parentId;
489
+ if (reparent && data.parentId !== null) {
490
+ const parent = await this.get(data.parentId);
491
+ if (parent.source?.sourceId === current.source.sourceId)
492
+ throw new ServiceError(409, `spec ${id} takes its place among ${current.source.sourceId}'s documents from ${current.source.kind}; move it there`);
493
+ }
494
+ if (!reparent && data.order !== undefined && data.order !== current.order && !current.anchored)
495
+ throw new ServiceError(409, `spec ${id} takes its order from ${current.source.kind} source ${current.source.sourceId}; move it there`);
496
+ }
497
+ const anchored = current.source ? (data.parentId === undefined ? current.anchored : data.parentId !== null) : false;
498
+ const next = { ...current, ...data, anchored, updatedAt: nowIso() };
298
499
  await this.assertMappings(next);
500
+ if (next.parentId && next.parentId !== current.parentId)
501
+ await this.assertParent(id, next.parentId);
299
502
  const revision = await this.store.put(COLLECTIONS.specs, id, next, {
300
503
  message: `Revise spec ${next.title}`,
301
504
  ...(actor.author ? { author: actor.author } : {}),
@@ -304,6 +507,9 @@ export class SpecService {
304
507
  }
305
508
  async delete(id, actor) {
306
509
  const spec = await this.get(id);
510
+ if (spec.source)
511
+ throw new ServiceError(409, `spec ${id} lives at ${spec.source.kind} source ${spec.source.sourceId}; remove it there, or detach the source (aigile sources detach ${spec.source.sourceId})`);
512
+ await this.discardDraft(id, actor);
307
513
  await this.store.delete(COLLECTIONS.specs, id, {
308
514
  message: `Delete spec ${spec.title}`,
309
515
  ...(actor.author ? { author: actor.author } : {}),
@@ -326,6 +532,15 @@ export class SpecService {
326
532
  const [before, after] = await Promise.all([this.atRevision(id, from), to ? this.atRevision(id, to) : this.get(id)]);
327
533
  return diffLines(before.content, after.content);
328
534
  }
535
+ /** A parent must exist and must not be the spec itself or one of its descendants. */
536
+ async assertParent(specId, parentId) {
537
+ const all = await this.data.specs();
538
+ const byId = new Map(all.map((s) => [s.id, s]));
539
+ if (!byId.has(parentId))
540
+ throw notFound('spec', parentId);
541
+ if (specId && wouldCycle(specId, parentId, byId))
542
+ throw new ServiceError(400, 'a spec cannot sit under itself or one of the specs under it');
543
+ }
329
544
  async assertMappings(spec) {
330
545
  const targets = [
331
546
  ['organization', COLLECTIONS.organizations, spec.organizationIds],
@@ -383,6 +598,17 @@ export class UserService {
383
598
  cursor = byId.get(cursor)?.managerId ?? null;
384
599
  }
385
600
  }
601
+ /** The people a person points at (priority setters, deference) must exist and must not be the person. */
602
+ async assertPeople(userId, ids) {
603
+ if (ids.length === 0)
604
+ return;
605
+ if (ids.includes(userId))
606
+ throw new ServiceError(400, 'a person cannot set their own priorities or defer to themselves');
607
+ const known = new Set((await this.list()).map((u) => u.id));
608
+ for (const id of ids)
609
+ if (!known.has(id))
610
+ throw notFound('user', id);
611
+ }
386
612
  async apply(id, patch, actor, verb) {
387
613
  const current = await this.get(id);
388
614
  const data = defined(patch);
@@ -397,6 +623,7 @@ export class UserService {
397
623
  }
398
624
  if (data.managerId)
399
625
  await this.assertManager(id, data.managerId);
626
+ await this.assertPeople(id, [...(data.prioritySetterIds ?? []), ...(data.defersTo ?? []).map((d) => d.userId)]);
400
627
  const next = { ...current, ...data, updatedAt: nowIso() };
401
628
  await this.store.put(COLLECTIONS.users, id, next, {
402
629
  message: `${verb} ${next.email ?? next.id}`,
@@ -427,7 +654,7 @@ export class RoleService {
427
654
  const existing = await this.list();
428
655
  const lowest = existing.length > 0 ? Math.min(...existing.map((r) => r.ranking)) : RANKING_STEP;
429
656
  const ts = nowIso();
430
- const role = { id: newId(), ...data, ranking: lowest - RANKING_STEP, createdAt: ts, updatedAt: ts };
657
+ const role = { id: newId('role'), ...data, origin: null, seeded: false, ranking: lowest - RANKING_STEP, createdAt: ts, updatedAt: ts };
431
658
  await this.store.put(COLLECTIONS.roles, role.id, role, {
432
659
  message: `Create role ${role.name}`,
433
660
  ...(actor.author ? { author: actor.author } : {}),
@@ -436,6 +663,79 @@ export class RoleService {
436
663
  const ordered = await this.reorder([...existing.map((r) => r.id), role.id], actor);
437
664
  return ordered.find((r) => r.id === role.id) ?? role;
438
665
  }
666
+ /**
667
+ * The install's seeding of a template seat (documentation/templates.md): the
668
+ * shared instance, with its origin. A role already on the seat is kept (and
669
+ * given its origin if it predates origins); otherwise one is created.
670
+ */
671
+ async seedAgent(seed, templateId, actor) {
672
+ const existing = (await this.list()).find((r) => r.agentKey === seed.agentKey && r.seeded) ?? (await this.list()).find((r) => r.agentKey === seed.agentKey);
673
+ if (existing) {
674
+ if (existing.origin)
675
+ return { role: existing, created: false };
676
+ const next = { ...existing, origin: { templateId, agentKey: seed.agentKey }, seeded: true, updatedAt: nowIso() };
677
+ await this.store.put(COLLECTIONS.roles, next.id, next, { message: `Record where role ${next.name} came from`, ...(actor.author ? { author: actor.author } : {}) });
678
+ return { role: next, created: false };
679
+ }
680
+ const created = await this.create(seed, actor);
681
+ const next = { ...created, origin: { templateId, agentKey: seed.agentKey }, seeded: true, updatedAt: nowIso() };
682
+ await this.store.put(COLLECTIONS.roles, next.id, next, { message: `Seed role ${next.name} from the ${templateId} template`, ...(actor.author ? { author: actor.author } : {}) });
683
+ return { role: next, created: true };
684
+ }
685
+ /**
686
+ * Link a role a person made to a template seat (documentation/templates.md
687
+ * "Linking roles to seats"): it takes the seat's `agentKey` and an `origin`,
688
+ * and becomes the installation's instance of the seat, so `seedAgent` reuses
689
+ * it instead of creating a duplicate. Refused when another role already has
690
+ * the seat, when the role is linked to another seat, or when a human role
691
+ * would take an agent seat (or the reverse).
692
+ */
693
+ async link(id, seat, actor) {
694
+ const role = await this.get(id);
695
+ if (role.kind !== seat.kind)
696
+ throw new ServiceError(400, `${role.name} is ${role.kind === 'agent' ? 'an agent' : 'a role people hold'}; the seat ${seat.agentKey} is ${seat.kind === 'agent' ? 'an agent' : 'a seat people hold'}`);
697
+ const holder = (await this.list()).find((r) => r.id !== id && r.agentKey === seat.agentKey);
698
+ if (holder)
699
+ throw new ServiceError(409, `the seat ${seat.agentKey} is already ${holder.name}'s; unlink it first`);
700
+ if (role.agentKey && role.agentKey !== seat.agentKey)
701
+ throw new ServiceError(409, `${role.name} is linked to the seat ${role.agentKey}; unlink it first`);
702
+ if (role.agentKey === seat.agentKey && role.origin?.templateId === seat.templateId)
703
+ return role;
704
+ const next = { ...role, agentKey: seat.agentKey, origin: { templateId: seat.templateId, agentKey: seat.agentKey }, seeded: true, updatedAt: nowIso() };
705
+ await this.store.put(COLLECTIONS.roles, id, next, { message: `Link role ${role.name} to the ${seat.templateId} seat ${seat.agentKey}`, ...(actor.author ? { author: actor.author } : {}) });
706
+ return next;
707
+ }
708
+ /** Undo `link`: the role keeps its name and holders and loses its seat; the next install seeds the seat as a role of its own. */
709
+ async unlink(id, actor) {
710
+ const role = await this.get(id);
711
+ if (!role.agentKey && !role.origin)
712
+ return role;
713
+ const next = { ...role, agentKey: null, origin: null, seeded: false, updatedAt: nowIso() };
714
+ await this.store.put(COLLECTIONS.roles, id, next, { message: `Unlink role ${role.name} from the seat ${role.agentKey ?? role.origin?.agentKey}`, ...(actor.author ? { author: actor.author } : {}) });
715
+ return next;
716
+ }
717
+ /**
718
+ * An independent copy of a role for one project to customize (documentation/
719
+ * templates.md "Instances"): the same seat and origin, its own name, and its own
720
+ * copy of every brief that applies to the source everywhere (the global ones),
721
+ * so edits diverge from here on. Nobody holds it; nothing points at it until a
722
+ * project does.
723
+ */
724
+ async fork(id, name, actor) {
725
+ const source = await this.get(id);
726
+ if (!source.agentKey)
727
+ throw new ServiceError(400, `${source.name} is not an agent role; only a template seat is forked`);
728
+ const created = await this.create({ name, description: source.description, appRole: source.appRole, kind: source.kind, agentKey: source.agentKey }, actor);
729
+ const role = { ...created, origin: source.origin, seeded: false, updatedAt: nowIso() };
730
+ await this.store.put(COLLECTIONS.roles, role.id, role, { message: `Fork role ${source.name} as ${name}`, ...(actor.author ? { author: actor.author } : {}) });
731
+ const briefs = (await this.store.list(COLLECTIONS.specs)).map((s) => specSchema.parse(s)).filter((s) => s.roleIds.includes(source.id) && s.organizationIds.length + s.projectIds.length === 0);
732
+ for (const brief of briefs) {
733
+ const ts = nowIso();
734
+ const copy = { ...brief, id: newId('spec'), title: brief.title.replace(source.name, name), roleIds: [role.id], seed: null, source: null, grounding: false, createdAt: ts, updatedAt: ts };
735
+ await this.store.put(COLLECTIONS.specs, copy.id, copy, { message: `Copy the ${source.name} brief for ${name}`, ...(actor.author ? { author: actor.author } : {}) });
736
+ }
737
+ return role;
738
+ }
439
739
  async update(id, input, actor) {
440
740
  const current = await this.get(id);
441
741
  const data = defined(parse(roleInputSchema.partial(), input));
@@ -478,11 +778,14 @@ export class RoleService {
478
778
  }
479
779
  return out;
480
780
  }
481
- /** Only a role nobody holds can go; the package's agents stay (install would seed them again). */
781
+ /** Only a role nobody holds and no project points at can go; a seeded agent stays (install would seed it again). */
482
782
  async delete(id, actor) {
483
783
  const role = await this.get(id);
484
- if (role.agentKey)
485
- throw new ServiceError(409, `${role.name} is one of aigile's agents and cannot be deleted`);
784
+ if (role.agentKey && role.seeded)
785
+ throw new ServiceError(409, `${role.name} is a template's shared ${role.kind === 'agent' ? 'agent' : 'seat'} and cannot be deleted (install would seed it again)`);
786
+ const pointing = (await new ProjectService(this.store).list()).filter((p) => Object.values(p.agentRoleIds).includes(id));
787
+ if (pointing.length > 0)
788
+ throw new ServiceError(409, `role ${role.name} is used by ${pointing.map((p) => p.name).join(', ')}; point them elsewhere first`);
486
789
  const assignments = (await this.store.list(COLLECTIONS.roleAssignments)).map((a) => roleAssignmentSchema.parse(a));
487
790
  if (assignments.some((a) => a.roleId === id))
488
791
  throw new ServiceError(409, `role ${role.name} is still assigned`);
@@ -516,7 +819,7 @@ export class RoleAssignmentService {
516
819
  const data = parse(roleAssignmentInputSchema, input);
517
820
  await this.assertReferences(data);
518
821
  const ts = nowIso();
519
- const assignment = { id: newId(), ...data, createdAt: ts, updatedAt: ts };
822
+ const assignment = { id: newId('role-assignment'), ...data, createdAt: ts, updatedAt: ts };
520
823
  await this.store.put(COLLECTIONS.roleAssignments, assignment.id, assignment, {
521
824
  message: `Assign role ${data.roleId} to ${data.userId}`,
522
825
  ...(actor.author ? { author: actor.author } : {}),
@@ -590,7 +893,7 @@ export class ConflictService {
590
893
  throw notFound('spec', side.specId);
591
894
  }
592
895
  const ts = nowIso();
593
- const conflict = { id: newId(), status: 'active', left: input.left, right: input.right, resolutions: [], detectedBy: input.detectedBy ?? 'user', createdAt: ts, updatedAt: ts };
896
+ const conflict = { id: newId('conflict'), status: 'active', left: input.left, right: input.right, resolutions: [], detectedBy: input.detectedBy ?? 'user', createdAt: ts, updatedAt: ts };
594
897
  await this.store.put(COLLECTIONS.conflicts, conflict.id, conflict, {
595
898
  message: `Open conflict between specs ${input.left.specId} and ${input.right.specId}`,
596
899
  ...(actor.author ? { author: actor.author } : {}),
@@ -623,7 +926,7 @@ export class MessageService {
623
926
  if ((await this.store.get(COLLECTIONS.conflicts, conflictId)) === null)
624
927
  throw notFound('conflict', conflictId);
625
928
  const ts = nowIso();
626
- const message = { id: newId(), conflictId, timestamp: ts, body: text, author, createdAt: ts, updatedAt: ts };
929
+ const message = { id: newId('message'), conflictId, timestamp: ts, body: text, author, createdAt: ts, updatedAt: ts };
627
930
  await this.store.put(COLLECTIONS.messages, message.id, messageSchema.parse(message), {
628
931
  message: `Message on conflict ${conflictId}`,
629
932
  ...(actor.author ? { author: actor.author } : {}),
@@ -631,7 +934,7 @@ export class MessageService {
631
934
  return message;
632
935
  }
633
936
  }
634
- /** Who administers the installation. */
937
+ /** Who administers the installation, and how far. */
635
938
  export class AuthzService {
636
939
  store;
637
940
  constructor(store) {
@@ -642,10 +945,56 @@ export class AuthzService {
642
945
  * ranking (spec precedence) and a ranking override play no part. While
643
946
  * nobody holds such a role, everyone is: a fresh installation has to be set
644
947
  * up by somebody, and losing the last admin must not lock everyone out.
948
+ * A scoped admin assignment makes a per-organization admin (`adminScope`).
645
949
  */
646
950
  async isAdmin(userId) {
647
- const admins = await this.adminUserIds();
648
- return admins.size === 0 || admins.has(userId);
951
+ return (await this.adminScope(userId)) !== null;
952
+ }
953
+ /** An admin with no scope at all (or under the bootstrap rule). */
954
+ async isGlobalAdmin(userId) {
955
+ return (await this.adminScope(userId))?.all === true;
956
+ }
957
+ /** How far a person administers, or null when they do not. */
958
+ async adminScope(userId) {
959
+ const admins = await this.adminAssignments();
960
+ if (admins.length === 0)
961
+ return { all: true };
962
+ const mine = admins.filter((a) => a.userId === userId);
963
+ if (mine.length === 0)
964
+ return null;
965
+ // The owner application role owns the installation, wherever the assignment is scoped; an admin is scoped to where it is assigned.
966
+ const roles = (await this.store.list(COLLECTIONS.roles)).map((r) => parseRole(r));
967
+ const owner = new Set(roles.filter((r) => r.appRole === 'owner').map((r) => r.id));
968
+ if (mine.some((a) => owner.has(a.roleId) || (a.organizationIds.length === 0 && a.projectIds.length === 0)))
969
+ return { all: true };
970
+ const [organizations, projects] = await Promise.all([this.store.list(COLLECTIONS.organizations), this.store.list(COLLECTIONS.projects)]);
971
+ const orgs = organizations.map((o) => organizationSchema.parse(o));
972
+ const projs = projects.map((p) => projectSchema.parse(p));
973
+ const organizationIds = closure(mine.flatMap((a) => a.organizationIds), orgs.map((o) => [o.id, o.parentId]));
974
+ const projectIds = closure([...mine.flatMap((a) => a.projectIds), ...projs.filter((p) => organizationIds.has(p.organizationId)).map((p) => p.id)], projs.map((p) => [p.id, p.parentProjectId]));
975
+ return { all: false, organizationIds, projectIds };
976
+ }
977
+ /** True when a scope covers a user: their organization is in it (a user with no organization is the global admins'). */
978
+ static userInScope(scope, user) {
979
+ return scope.all || (user.organizationId !== null && scope.organizationIds.has(user.organizationId));
980
+ }
981
+ /**
982
+ * True when a scope covers a thing scoped to organizations and projects: every
983
+ * organization and project named is inside it, and something is named (an
984
+ * unscoped thing is the installation's, so the global admins').
985
+ */
986
+ static withinScope(scope, target) {
987
+ if (scope.all)
988
+ return true;
989
+ if (target.organizationIds.length === 0 && target.projectIds.length === 0)
990
+ return false;
991
+ return target.organizationIds.every((id) => scope.organizationIds.has(id)) && target.projectIds.every((id) => scope.projectIds.has(id));
992
+ }
993
+ async adminAssignments() {
994
+ const assignments = (await this.store.list(COLLECTIONS.roleAssignments)).map((a) => roleAssignmentSchema.parse(a));
995
+ const roles = (await this.store.list(COLLECTIONS.roles)).map((r) => parseRole(r));
996
+ const appRoleOf = new Map(roles.map((r) => [r.id, r.appRole]));
997
+ return assignments.filter((a) => ADMIN_APP_ROLES.includes(appRoleOf.get(a.roleId) ?? 'viewer'));
649
998
  }
650
999
  /** True while the bootstrap rule is in force: nobody holds an owner or admin application role. */
651
1000
  async isBootstrap() {
@@ -661,6 +1010,17 @@ export class AuthzService {
661
1010
  return true;
662
1011
  return (await this.userIdsWith(DECIDING_APP_ROLES)).has(userId);
663
1012
  }
1013
+ /** Whether the person holds a role the test accepts (a tester's seat: the QA role, by its agent key or name). */
1014
+ async holdsRole(userId, test) {
1015
+ const assignments = (await this.store.list(COLLECTIONS.roleAssignments)).map((a) => roleAssignmentSchema.parse(a)).filter((a) => a.userId === userId);
1016
+ if (!assignments.length)
1017
+ return false;
1018
+ const roles = new Map((await this.store.list(COLLECTIONS.roles)).map((r) => parseRole(r)).map((r) => [r.id, r]));
1019
+ return assignments.some((a) => {
1020
+ const r = roles.get(a.roleId);
1021
+ return !!r && test(r);
1022
+ });
1023
+ }
664
1024
  adminUserIds() {
665
1025
  return this.userIdsWith(ADMIN_APP_ROLES);
666
1026
  }
@@ -671,4 +1031,26 @@ export class AuthzService {
671
1031
  return new Set(assignments.filter((a) => appRoles.includes(appRoleOf.get(a.roleId) ?? 'viewer')).map((a) => a.userId));
672
1032
  }
673
1033
  }
1034
+ /** The ids given plus every descendant, over (id, parentId) pairs. */
1035
+ function closure(roots, edges) {
1036
+ const children = new Map();
1037
+ for (const [id, parent] of edges) {
1038
+ if (parent === null)
1039
+ continue;
1040
+ const list = children.get(parent) ?? [];
1041
+ list.push(id);
1042
+ children.set(parent, list);
1043
+ }
1044
+ const out = new Set();
1045
+ const stack = [...roots];
1046
+ while (stack.length > 0) {
1047
+ const id = stack.pop();
1048
+ if (out.has(id))
1049
+ continue;
1050
+ out.add(id);
1051
+ for (const child of children.get(id) ?? [])
1052
+ stack.push(child);
1053
+ }
1054
+ return out;
1055
+ }
674
1056
  //# sourceMappingURL=services.js.map