@app-vitals/agent-admin 1.108.0 → 1.108.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 (34) hide show
  1. package/e2e/real/admin-access.real.e2e.ts +77 -68
  2. package/e2e/real/agent-management.real.e2e.ts +165 -143
  3. package/e2e/real/owner-access.real.e2e.ts +228 -212
  4. package/openapi.platform.json +6 -6
  5. package/package.json +2 -2
  6. package/src/account-created-notifier.ts +1 -1
  7. package/src/account-onboarding.integration.test.ts +69 -0
  8. package/src/account-onboarding.ts +29 -3
  9. package/src/account-trial-expiry-sweeper.ts +1 -1
  10. package/src/accounts-api.integration.test.ts +5 -2
  11. package/src/accounts-api.smoke.test.ts +21 -5
  12. package/src/accounts-api.ts +12 -15
  13. package/src/admin-boot-config.ts +2 -0
  14. package/src/admin-boot-config.unit.test.ts +27 -0
  15. package/src/admin-boot.ts +11 -10
  16. package/src/admin-ui-account.smoke.test.ts +7 -3
  17. package/src/admin-ui-account.ts +10 -15
  18. package/src/admin-ui-accounts.smoke.test.ts +4 -4
  19. package/src/admin-ui-accounts.ts +7 -11
  20. package/src/admin-ui-settings-nav-context.smoke.test.ts +24 -0
  21. package/src/admin-ui-settings.smoke.test.ts +17 -1
  22. package/src/admin-ui.smoke.test.ts +168 -2
  23. package/src/admin-ui.ts +39 -26
  24. package/src/agent-management-access.integration.test.ts +18 -6
  25. package/src/agent-manifest.ts +2 -1
  26. package/src/agent-provisioner.integration.test.ts +10 -10
  27. package/src/agent-provisioner.ts +10 -1
  28. package/src/agent-provisioner.unit.test.ts +110 -36
  29. package/src/agent-templates-api.integration.test.ts +23 -5
  30. package/src/agent-templates-api.ts +11 -8
  31. package/src/caller-scope.integration.test.ts +8 -6
  32. package/src/caller-scope.ts +32 -26
  33. package/src/caller-scope.unit.test.ts +15 -11
  34. package/src/platform-routes.ts +2 -2
@@ -613,7 +613,77 @@ describe("admin UI — Google callback self-serve signup (SSP-3.1)", () => {
613
613
  expect(notified).toEqual([]);
614
614
  });
615
615
 
616
- it("flag off: unknown email still gets 403 and nothing is provisioned", async () => {
616
+ it("flag off: unknown email still gets 403 and no account is created", async () => {
617
+ const calls: string[] = [];
618
+ const app = createAdminUIApp(
619
+ makeMockDeps({
620
+ googleClient: identity(),
621
+ selfServe: { ...enabled, enabled: false },
622
+ accountOnboarding: {
623
+ provisionForEmail: async () => {
624
+ calls.push("provision");
625
+ return { kind: "created", accountId: "acc-1" };
626
+ },
627
+ joinForEmail: async (email) => {
628
+ calls.push(`join:${email}`);
629
+ return null;
630
+ },
631
+ },
632
+ }),
633
+ );
634
+ const res = await app.request(callbackRequest(nonce));
635
+ expect(res.status).toBe(403);
636
+ expect(res.headers.get("Set-Cookie") ?? "").not.toContain("admin_session=");
637
+ expect(calls).toEqual(["join:new.user@example.com"]);
638
+ });
639
+
640
+ it("flag off: an invited email joins its account and signs in, without a notification", async () => {
641
+ const notified: unknown[] = [];
642
+ let provisioned = false;
643
+ const app = createAdminUIApp(
644
+ makeMockDeps({
645
+ googleClient: identity(),
646
+ selfServe: { ...enabled, enabled: false },
647
+ accountOnboarding: {
648
+ provisionForEmail: async () => {
649
+ provisioned = true;
650
+ return { kind: "created", accountId: "acc-1" };
651
+ },
652
+ joinForEmail: async () => ({ kind: "joined", accountId: "acc-1" }),
653
+ },
654
+ accountCreatedNotifier: async (info) => {
655
+ notified.push(info);
656
+ },
657
+ }),
658
+ );
659
+ const res = await app.request(callbackRequest(nonce));
660
+ expect(res.status).toBe(302);
661
+ expect(res.headers.get("Location")).toBe("/admin/agents");
662
+ expect(res.headers.get("Set-Cookie")).toContain("admin_session=");
663
+ expect(provisioned).toBe(false);
664
+ expect(notified).toEqual([]);
665
+ });
666
+
667
+ it("flag off: an existing account owner with no agent memberships signs in", async () => {
668
+ const app = createAdminUIApp(
669
+ makeMockDeps({
670
+ googleClient: identity(),
671
+ selfServe: { ...enabled, enabled: false },
672
+ accountOnboarding: {
673
+ provisionForEmail: async () => {
674
+ throw new Error("must not create");
675
+ },
676
+ joinForEmail: async () => ({ kind: "existing", accountId: "acc-1" }),
677
+ },
678
+ }),
679
+ );
680
+ const res = await app.request(callbackRequest(nonce));
681
+ expect(res.status).toBe(302);
682
+ expect(res.headers.get("Location")).toBe("/admin/agents");
683
+ expect(res.headers.get("Set-Cookie")).toContain("admin_session=");
684
+ });
685
+
686
+ it("flag off: onboarding without joinForEmail keeps the 403", async () => {
617
687
  let called = false;
618
688
  const app = createAdminUIApp(
619
689
  makeMockDeps({
@@ -632,6 +702,25 @@ describe("admin UI — Google callback self-serve signup (SSP-3.1)", () => {
632
702
  expect(called).toBe(false);
633
703
  });
634
704
 
705
+ it("flag off: a join failure redirects to server_error without a session", async () => {
706
+ const app = createAdminUIApp(
707
+ makeMockDeps({
708
+ googleClient: identity(),
709
+ selfServe: { ...enabled, enabled: false },
710
+ accountOnboarding: {
711
+ provisionForEmail: async () => ({ kind: "created", accountId: "a" }),
712
+ joinForEmail: async () => {
713
+ throw new Error("db down");
714
+ },
715
+ },
716
+ }),
717
+ );
718
+ const res = await app.request(callbackRequest(nonce));
719
+ expect(res.status).toBe(302);
720
+ expect(res.headers.get("Location")).toContain("error=server_error");
721
+ expect(res.headers.get("Set-Cookie") ?? "").not.toContain("admin_session=");
722
+ });
723
+
635
724
  it("flag on: unverified email creates nothing", async () => {
636
725
  let called = false;
637
726
  const app = createAdminUIApp(
@@ -7884,7 +7973,7 @@ describe("admin UI — agent management is limited to admins and account owners"
7884
7973
  expect(res.status).toBe(403);
7885
7974
  });
7886
7975
 
7887
- it(`flag off (no account on scope): owner gets 403 on POST /admin/agents/:id/${path}`, async () => {
7976
+ it(`owner with no account on the scope gets 403 on POST /admin/agents/:id/${path}`, async () => {
7888
7977
  const res = await makeApp(scopeOf(null, "owner")).request(
7889
7978
  `/admin/agents/${AGENT_ID}/${path}`,
7890
7979
  form(fields, await callerCookie()),
@@ -8217,3 +8306,80 @@ describe("admin UI — admin sign-in ensures an AccountMember", () => {
8217
8306
  expect(emails).toEqual(["dev@localhost"]);
8218
8307
  });
8219
8308
  });
8309
+
8310
+ // ─── Agents list account features do not depend on the self-serve flag ─────
8311
+
8312
+ describe("admin UI — agents list account features, self-serve off and on", () => {
8313
+ const OWNER = "owner@example.com";
8314
+ const agent = {
8315
+ id: AGENT_ID,
8316
+ name: "Test Agent",
8317
+ slackId: "U123456",
8318
+ selfHosted: false,
8319
+ specialty: "coding",
8320
+ accountId: "acct-a",
8321
+ createdAt: new Date("2024-01-01"),
8322
+ updatedAt: new Date("2024-01-01"),
8323
+ };
8324
+ const makeApp = (enabled: boolean) => {
8325
+ const base = makeMockDeps();
8326
+ return createAdminUIApp(
8327
+ makeMockDeps({
8328
+ selfServe: {
8329
+ enabled,
8330
+ defaultMaxAgents: 0,
8331
+ contactEmail: "quota@example.com",
8332
+ },
8333
+ callerScopeResolver: async () => ({
8334
+ kind: "scoped" as const,
8335
+ accountId: "acct-a",
8336
+ agentIds: [AGENT_ID],
8337
+ role: "owner" as const,
8338
+ }),
8339
+ agentService: {
8340
+ ...base.agentService,
8341
+ listAll: async () => [agent],
8342
+ listByIds: async () => [agent],
8343
+ } as never,
8344
+ accountServices: {
8345
+ accounts: {
8346
+ getByMemberEmail: async (email: string) =>
8347
+ email === OWNER
8348
+ ? { id: "acct-a", name: "Acme Co", maxAgents: 0 }
8349
+ : null,
8350
+ listWithCounts: async () => [{ id: "acct-a", name: "Acme Co" }],
8351
+ },
8352
+ members: { getByEmail: async () => null },
8353
+ } as never,
8354
+ }),
8355
+ );
8356
+ };
8357
+
8358
+ for (const enabled of [false, true]) {
8359
+ const label = enabled ? "on" : "off";
8360
+
8361
+ it(`self-serve ${label}: admins see the Account column`, async () => {
8362
+ const res = await makeApp(enabled).request("/admin/agents", {
8363
+ headers: { Cookie: `admin_session=${await makeSessionCookie()}` },
8364
+ });
8365
+ expect(res.status).toBe(200);
8366
+ const body = await res.text();
8367
+ expect(body).toContain("<th>Account</th>");
8368
+ expect(body).toContain('href="/admin/accounts/acct-a"');
8369
+ });
8370
+
8371
+ it(`self-serve ${label}: an owner of a zero-limit account sees the contact notice`, async () => {
8372
+ const cookie = await makeSessionCookie(
8373
+ SESSION_SECRET,
8374
+ "google-sub-owner",
8375
+ OWNER,
8376
+ false,
8377
+ );
8378
+ const res = await makeApp(enabled).request("/admin/agents", {
8379
+ headers: { Cookie: `admin_session=${cookie}` },
8380
+ });
8381
+ expect(res.status).toBe(200);
8382
+ expect(await res.text()).toContain("quota@example.com");
8383
+ });
8384
+ }
8385
+ });
package/src/admin-ui.ts CHANGED
@@ -494,13 +494,21 @@ export interface AdminUIDeps {
494
494
  appBaseUrl: string;
495
495
  /** Enable the /admin/dev-login route. Hard-blocked in production regardless of this value. */
496
496
  devAuthEnabled?: boolean;
497
- /** Resolved self-serve provisioning config (SSP-1.3). */
497
+ /**
498
+ * Resolved self-serve config (SSP-1.3). `enabled` controls only open signup
499
+ * (an unknown verified Google user creating an account); `contactEmail` is
500
+ * shown on the agent-limit notices.
501
+ */
498
502
  selfServe?: SelfServeConfig;
499
503
  /**
500
- * First-login account provisioning (SSP-3.1). Consulted by the Google
501
- * callback only, and only when selfServe.enabled; absent → no auto-create.
504
+ * First-login account resolution (SSP-3.1), consulted by the Google callback
505
+ * only, for a verified email with no AgentMember rows. Signup on
506
+ * (selfServe.enabled): provisionForEmail (join, existing or create). Signup
507
+ * off: joinForEmail (join or existing, never create); without it the
508
+ * caller gets 403. Absent → 403.
502
509
  */
503
- accountOnboarding?: Pick<AccountOnboardingService, "provisionForEmail">;
510
+ accountOnboarding?: Pick<AccountOnboardingService, "provisionForEmail"> &
511
+ Partial<Pick<AccountOnboardingService, "joinForEmail">>;
504
512
  /**
505
513
  * GHE-1.4: the GHE-1.3 /github-enterprise API app's `request`. Optional
506
514
  * (additive): when absent the Settings page and its nav entry are not
@@ -548,8 +556,9 @@ export interface AdminUIDeps {
548
556
  creator?: MemberCreator;
549
557
  }) => Promise<EnsureAccountMemberResult>;
550
558
  /**
551
- * Account page + nav services (SSP-3.2). Used only when selfServe.enabled;
552
- * absent → no /admin/account routes content, no nav entry, no quota notice.
559
+ * Account page + nav services (SSP-3.2), independent of the self-serve
560
+ * setting; absent → no /admin/account(s) routes, no nav entry, no quota
561
+ * notice and no Account column.
553
562
  */
554
563
  accountServices?: {
555
564
  accounts: Pick<
@@ -1032,7 +1041,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
1032
1041
  devAuthEnabled,
1033
1042
  });
1034
1043
 
1035
- const accountNavEnabled = Boolean(selfServe?.enabled && accountServices);
1044
+ const accountNavEnabled = accountServices !== undefined;
1036
1045
 
1037
1046
  const settingsNav = buildSettingsNav({
1038
1047
  githubEnterprise: Boolean(githubEnterpriseApi),
@@ -1064,7 +1073,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
1064
1073
  if (user) {
1065
1074
  const role = await resolveNavRole(user.email, user.isAdmin === true);
1066
1075
  nav = filterSettingsNavForRole(settingsNav, role);
1067
- if (accountNavEnabled && accountServices) {
1076
+ if (accountServices) {
1068
1077
  const account = await accountServices.accounts
1069
1078
  .getByMemberEmail(user.email)
1070
1079
  .catch(() => null);
@@ -1186,7 +1195,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
1186
1195
  c: Context<AdminUIEnv, any>,
1187
1196
  userInfo: { sub: string; email?: string; email_verified?: boolean },
1188
1197
  returnTo: string | undefined,
1189
- opts: { selfServeSignup?: boolean } = {},
1198
+ opts: { accountSignIn?: boolean } = {},
1190
1199
  ): Promise<Response> {
1191
1200
  if (!userInfo.email) {
1192
1201
  return c.redirect("/admin/login?error=auth_failed", 302);
@@ -1208,21 +1217,26 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
1208
1217
  userInfo.email.toLowerCase(),
1209
1218
  );
1210
1219
  if (memberships.length === 0) {
1211
- // Self-serve (SSP-3.1): a verified Google email with no AgentMember
1212
- // rows joins its invited account or gets a new one. Okta and flag-off
1213
- // keep the existing 403.
1214
- const onboarding = accountOnboarding;
1215
- if (!(opts.selfServeSignup && selfServe?.enabled && onboarding)) {
1220
+ // SSP-3.1: a verified Google email with no AgentMember rows signs in
1221
+ // through its account: an existing membership, else a pending invite,
1222
+ // else (signup on only) a new account. Okta keeps the existing 403.
1223
+ const onboarding = opts.accountSignIn ? accountOnboarding : undefined;
1224
+ const resolveAccount =
1225
+ selfServe?.enabled === true
1226
+ ? onboarding?.provisionForEmail.bind(onboarding)
1227
+ : onboarding?.joinForEmail?.bind(onboarding);
1228
+ if (!resolveAccount) {
1216
1229
  return new Response("Forbidden", { status: 403 });
1217
1230
  }
1218
1231
  const email = userInfo.email.toLowerCase();
1219
- let result: Awaited<ReturnType<typeof onboarding.provisionForEmail>>;
1232
+ let result: Awaited<ReturnType<typeof resolveAccount>>;
1220
1233
  try {
1221
- result = await onboarding.provisionForEmail(email);
1234
+ result = await resolveAccount(email);
1222
1235
  } catch (err) {
1223
- console.error("[admin] self-serve account provisioning failed", err);
1236
+ console.error("[admin] account sign-in resolution failed", err);
1224
1237
  return c.redirect("/admin/login?error=server_error", 302);
1225
1238
  }
1239
+ if (!result) return new Response("Forbidden", { status: 403 });
1226
1240
  if (result.kind !== "existing") {
1227
1241
  console.log(
1228
1242
  JSON.stringify({
@@ -1476,7 +1490,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
1476
1490
  return c.redirect("/admin/login?error=auth_failed", 302);
1477
1491
  }
1478
1492
 
1479
- return completeLogin(c, userInfo, returnTo, { selfServeSignup: true });
1493
+ return completeLogin(c, userInfo, returnTo, { accountSignIn: true });
1480
1494
  });
1481
1495
 
1482
1496
  app.get("/admin/auth/okta", (c) => {
@@ -1613,17 +1627,18 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
1613
1627
  // SSP-3.2: a zero-quota account sees a request-a-trial message and a
1614
1628
  // disabled create button instead of the create CTA.
1615
1629
  let zeroQuotaContactEmail: string | undefined;
1616
- if (accountNavEnabled && accountServices && selfServe) {
1630
+ if (accountServices) {
1617
1631
  const account = await accountServices.accounts.getByMemberEmail(
1618
1632
  c.var.userEmail,
1619
1633
  );
1620
1634
  if (account && account.maxAgents === 0) {
1621
- zeroQuotaContactEmail = selfServe.contactEmail;
1635
+ zeroQuotaContactEmail =
1636
+ selfServe?.contactEmail ?? DEFAULT_SELF_SERVE_CONTACT_EMAIL;
1622
1637
  }
1623
1638
  }
1624
- // SSP-5.2: admins get an Account column (flag on only).
1639
+ // SSP-5.2: admins get an Account column.
1625
1640
  let accountNames: Map<string, string> | undefined;
1626
- if (c.var.isAdmin && accountNavEnabled && accountServices) {
1641
+ if (c.var.isAdmin && accountServices) {
1627
1642
  accountNames = new Map(
1628
1643
  (await accountServices.accounts.listWithCounts()).map((a) => [
1629
1644
  a.id,
@@ -4572,7 +4587,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
4572
4587
 
4573
4588
  app.get("/admin/provision", (c) => c.redirect("/admin/agents/new", 302));
4574
4589
 
4575
- // ─── Member management (admin, or any agent-access holder when self-serve is on) ──────────────────────────────────────
4590
+ // ─── Member management (platform admin, or the owner of the agent's account) ───
4576
4591
 
4577
4592
  app.post("/admin/agents/:id/members", requireAuth, async (c) => {
4578
4593
  const agentId = c.req.param("id");
@@ -4663,7 +4678,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
4663
4678
  c.var.isAdmin === true,
4664
4679
  );
4665
4680
  let nav = settingsNav;
4666
- if (accountNavEnabled && accountServices) {
4681
+ if (accountServices) {
4667
4682
  const account = await accountServices.accounts
4668
4683
  .getByMemberEmail(c.var.userEmail)
4669
4684
  .catch(() => null);
@@ -4733,14 +4748,12 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
4733
4748
 
4734
4749
  if (accountServices) {
4735
4750
  registerAccountRoutes(app, {
4736
- enabled: accountNavEnabled,
4737
4751
  requireAuth,
4738
4752
  settingsNav,
4739
4753
  ...accountServices,
4740
4754
  html,
4741
4755
  });
4742
4756
  registerAdminAccountsRoutes(app, {
4743
- enabled: accountNavEnabled,
4744
4757
  requireAuth,
4745
4758
  settingsNav,
4746
4759
  ...accountServices,
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * admin/src/agent-management-access.integration.test.ts
3
- * Agent management (JSON API) against a real PostgreSQL DB with self-serve on:
4
- * only platform admins and the owner of the agent's own account may manage an
3
+ * Agent management (JSON API) against a real PostgreSQL DB, with the
4
+ * self-serve setting off and on (it must not change the outcome): only
5
+ * platform admins and the owner of the agent's own account may manage an
5
6
  * agent; a member of the agent (or of its account) and an owner of another
6
7
  * account get 403, while read access is unchanged.
7
8
  *
@@ -145,7 +146,10 @@ const cookieFor = (email: string, isAdmin: boolean) =>
145
146
  "HS256",
146
147
  );
147
148
 
148
- describeOrSkip("agent management access (integration)", () => {
149
+ /** Run with the self-serve setting off and on; the outcome must not differ. */
150
+ const SELF_SERVE = [false, true];
151
+
152
+ describeOrSkip.each(SELF_SERVE)("management, self-serve=%p", (enabled) => {
149
153
  let prisma: PrismaClient;
150
154
  let app: ReturnType<typeof createAdminApp>;
151
155
  let agentId: string;
@@ -180,8 +184,12 @@ describeOrSkip("agent management access (integration)", () => {
180
184
  await prisma.accountMember.deleteMany();
181
185
  await prisma.account.deleteMany();
182
186
 
183
- const one = await prisma.account.create({ data: { name: "Account One" } });
184
- const two = await prisma.account.create({ data: { name: "Account Two" } });
187
+ const one = await prisma.account.create({
188
+ data: { name: "Account One" },
189
+ });
190
+ const two = await prisma.account.create({
191
+ data: { name: "Account Two" },
192
+ });
185
193
  const mk = (accountId: string, email: string, role: string) =>
186
194
  prisma.accountMember.create({ data: { accountId, email, role } });
187
195
  await mk(one.id, "owner-one@example.com", "owner");
@@ -199,12 +207,16 @@ describeOrSkip("agent management access (integration)", () => {
199
207
  const deps = makeDeps(prisma);
200
208
  app = createAdminApp({
201
209
  ...deps,
210
+ selfServe: {
211
+ enabled,
212
+ defaultMaxAgents: 0,
213
+ contactEmail: "ops@example.com",
214
+ },
202
215
  callerScopeResolver: createCallerScopeResolver(
203
216
  callerScopeDepsFromServices({
204
217
  accountService: new AccountService(prisma),
205
218
  agentMemberService: new AgentMemberService(prisma),
206
219
  }),
207
- true,
208
220
  ),
209
221
  });
210
222
  });
@@ -262,7 +262,8 @@ export interface AgentDeploymentOpts {
262
262
  /**
263
263
  * Owning account. When set the pod is a tenant pod: the tenant label is added
264
264
  * to the Deployment and pod template, and a CPU limit is applied. Omit for
265
- * platform agents (manifest unchanged).
265
+ * platform agents (manifest unchanged). The Kubernetes provisioner passes it
266
+ * only when tenant pod restrictions are on (SHIPWRIGHT_SELF_SERVE_ENABLED).
266
267
  */
267
268
  accountId?: string | null;
268
269
  /**
@@ -407,18 +407,18 @@ describeOrSkip("KubernetesAgentProvisioner (integration)", () => {
407
407
  // ─── PVC name template ───────────────────────────────────────────────────────
408
408
 
409
409
  it("provision() uses slug for PVC name when pvcName template is configured", async () => {
410
- const agentId = await createAgent("OkWOW Agent");
410
+ const agentId = await createAgent("Widget Agent");
411
411
  const k8s = emptyClient();
412
412
  const provisioner = new KubernetesAgentProvisioner(k8s, tokens, {
413
413
  ...CONFIG,
414
414
  pvcName: (name) => `acme-agent-${name}-home`,
415
415
  });
416
416
 
417
- await provisioner.provision(agentId, { slug: "okwow" });
417
+ await provisioner.provision(agentId, { slug: "widget" });
418
418
 
419
419
  // PVC must use the slug, not the sanitized agentId.
420
420
  await expect(
421
- k8s.getPvc(NAMESPACE, "acme-agent-okwow-home"),
421
+ k8s.getPvc(NAMESPACE, "acme-agent-widget-home"),
422
422
  ).resolves.toBeDefined();
423
423
  // Default-named PVC must NOT exist.
424
424
  const resourceName = sanitizeAgentName(agentId);
@@ -477,13 +477,13 @@ describeOrSkip("KubernetesAgentProvisioner (integration)", () => {
477
477
 
478
478
  // Agent exists in DB, no k8s Deployment — reconcile should provision it.
479
479
  const result = await provisioner.reconcile([
480
- { id: agentId, slug: "okwow" },
480
+ { id: agentId, slug: "widget" },
481
481
  ]);
482
482
 
483
483
  expect(result.recreated).toEqual([agentId]);
484
484
  // PVC must use the slug passed through reconcile.
485
485
  await expect(
486
- k8s.getPvc(NAMESPACE, "acme-agent-okwow-home"),
486
+ k8s.getPvc(NAMESPACE, "acme-agent-widget-home"),
487
487
  ).resolves.toBeDefined();
488
488
  });
489
489
 
@@ -533,22 +533,22 @@ describeOrSkip("KubernetesAgentProvisioner (integration)", () => {
533
533
  });
534
534
 
535
535
  it("deprovision() deletes the templated PVC name derived from slug", async () => {
536
- const agentId = await createAgent("OkWOW Agent");
536
+ const agentId = await createAgent("Widget Agent");
537
537
  const k8s = emptyClient();
538
538
  const provisioner = new KubernetesAgentProvisioner(k8s, tokens, {
539
539
  ...CONFIG,
540
540
  pvcName: (name) => `acme-agent-${name}-home`,
541
541
  });
542
542
 
543
- await provisioner.provision(agentId, { slug: "okwow" });
543
+ await provisioner.provision(agentId, { slug: "widget" });
544
544
  await expect(
545
- k8s.getPvc(NAMESPACE, "acme-agent-okwow-home"),
545
+ k8s.getPvc(NAMESPACE, "acme-agent-widget-home"),
546
546
  ).resolves.toBeDefined();
547
547
 
548
- await provisioner.deprovision(agentId, { slug: "okwow" });
548
+ await provisioner.deprovision(agentId, { slug: "widget" });
549
549
 
550
550
  await expect(
551
- k8s.getPvc(NAMESPACE, "acme-agent-okwow-home"),
551
+ k8s.getPvc(NAMESPACE, "acme-agent-widget-home"),
552
552
  ).rejects.toThrow();
553
553
  });
554
554
 
@@ -241,6 +241,14 @@ export interface AgentProvisioner {
241
241
  export interface KubernetesAgentProvisionerConfig {
242
242
  /** Additional labels managed on new and existing agent pod templates. */
243
243
  podLabels?: Record<string, string>;
244
+ /**
245
+ * Tenant pod restrictions (SSP-7.1): when true, an agent with an account
246
+ * gets the tenant label (`shipwright.dev/tenant`, selected by the tenant
247
+ * NetworkPolicy) and a CPU limit, on provision and reconcile. Off when
248
+ * unset. Sourced from SHIPWRIGHT_SELF_SERVE_ENABLED in buildProvisioner, so
249
+ * the restrictions apply only on deployments with open signup.
250
+ */
251
+ tenantPodRestrictions?: boolean;
244
252
  /** Namespace the agent resources live in. */
245
253
  namespace: string;
246
254
  /** Agent container image (without tag). */
@@ -982,7 +990,8 @@ export class KubernetesAgentProvisioner implements AgentProvisioner {
982
990
  chatServiceUrl: this.config.chatServiceUrl,
983
991
  claudePolicy: this.config.claudePolicy,
984
992
  anthropicFederation: federation,
985
- accountId,
993
+ // The manifest treats an accountId as a tenant pod (label + CPU limit).
994
+ accountId: this.config.tenantPodRestrictions === true ? accountId : null,
986
995
  ...(this.config.podServiceAccount?.enabled && podServiceAccountName
987
996
  ? { podServiceAccountName }
988
997
  : {}),