@caelo-cms/provisioning 0.12.9 → 0.12.11

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 (123) hide show
  1. package/dist/agent-db.js +76 -3
  2. package/dist/cli.js +23 -2
  3. package/dist/cli.js.map +1 -1
  4. package/dist/collection-stores.d.ts +5 -0
  5. package/dist/collection-stores.d.ts.map +1 -0
  6. package/dist/collection-stores.js +21 -0
  7. package/dist/collection-stores.js.map +1 -0
  8. package/dist/collections-setup.d.ts +66 -0
  9. package/dist/collections-setup.d.ts.map +1 -0
  10. package/dist/collections-setup.js +252 -0
  11. package/dist/collections-setup.js.map +1 -0
  12. package/dist/compose.d.ts +27 -0
  13. package/dist/compose.d.ts.map +1 -1
  14. package/dist/compose.js +52 -1
  15. package/dist/compose.js.map +1 -1
  16. package/dist/gateway-edge.d.ts +13 -0
  17. package/dist/gateway-edge.d.ts.map +1 -1
  18. package/dist/gateway-edge.js +22 -0
  19. package/dist/gateway-edge.js.map +1 -1
  20. package/dist/gcp-names.d.ts +18 -48
  21. package/dist/gcp-names.d.ts.map +1 -1
  22. package/dist/gcp-names.js +11 -69
  23. package/dist/gcp-names.js.map +1 -1
  24. package/dist/infra-contract.d.ts +1 -1
  25. package/dist/infra-contract.d.ts.map +1 -1
  26. package/dist/infra-contract.js +35 -1
  27. package/dist/infra-contract.js.map +1 -1
  28. package/dist/reporting-job-catalog.d.ts +111 -0
  29. package/dist/reporting-job-catalog.d.ts.map +1 -0
  30. package/dist/reporting-job-catalog.js +306 -0
  31. package/dist/reporting-job-catalog.js.map +1 -0
  32. package/dist/reporting-job-setup.d.ts +11 -68
  33. package/dist/reporting-job-setup.d.ts.map +1 -1
  34. package/dist/reporting-job-setup.js +44 -100
  35. package/dist/reporting-job-setup.js.map +1 -1
  36. package/dist/runtime-secrets.d.ts.map +1 -1
  37. package/dist/runtime-secrets.js +3 -0
  38. package/dist/runtime-secrets.js.map +1 -1
  39. package/dist/self-hosted-backup.d.ts.map +1 -1
  40. package/dist/self-hosted-backup.js +18 -6
  41. package/dist/self-hosted-backup.js.map +1 -1
  42. package/dist/stack-contract.d.ts +75 -22
  43. package/dist/stack-contract.d.ts.map +1 -1
  44. package/dist/stack-contract.js +142 -51
  45. package/dist/stack-contract.js.map +1 -1
  46. package/dist/stack-converge.d.ts +20 -1
  47. package/dist/stack-converge.d.ts.map +1 -1
  48. package/dist/stack-converge.js +105 -2
  49. package/dist/stack-converge.js.map +1 -1
  50. package/dist/staging-gateway-setup.d.ts.map +1 -1
  51. package/dist/staging-gateway-setup.js +10 -5
  52. package/dist/staging-gateway-setup.js.map +1 -1
  53. package/dist/upgrade/admin-image-jobs.d.ts +4 -3
  54. package/dist/upgrade/admin-image-jobs.d.ts.map +1 -1
  55. package/dist/upgrade/admin-image-jobs.js +9 -16
  56. package/dist/upgrade/admin-image-jobs.js.map +1 -1
  57. package/dist/upgrade/app-roll.d.ts.map +1 -1
  58. package/dist/upgrade/app-roll.js +8 -7
  59. package/dist/upgrade/app-roll.js.map +1 -1
  60. package/dist/upgrade/converge.d.ts.map +1 -1
  61. package/dist/upgrade/converge.js +78 -50
  62. package/dist/upgrade/converge.js.map +1 -1
  63. package/dist/upgrader-iam-preflight.d.ts.map +1 -1
  64. package/dist/upgrader-iam-preflight.js +8 -18
  65. package/dist/upgrader-iam-preflight.js.map +1 -1
  66. package/dist/upgrader-setup.d.ts.map +1 -1
  67. package/dist/upgrader-setup.js +7 -15
  68. package/dist/upgrader-setup.js.map +1 -1
  69. package/dist/visitor-query-logs.d.ts +40 -0
  70. package/dist/visitor-query-logs.d.ts.map +1 -0
  71. package/dist/visitor-query-logs.js +41 -0
  72. package/dist/visitor-query-logs.js.map +1 -0
  73. package/dist/wizards/gcp-cost.d.ts.map +1 -1
  74. package/dist/wizards/gcp-cost.js +17 -9
  75. package/dist/wizards/gcp-cost.js.map +1 -1
  76. package/dist/wizards/gcp.d.ts.map +1 -1
  77. package/dist/wizards/gcp.js +45 -35
  78. package/dist/wizards/gcp.js.map +1 -1
  79. package/package.json +2 -2
  80. package/src/admin-memory.test.ts +57 -1
  81. package/src/cli.ts +23 -1
  82. package/src/collection-stores.ts +28 -0
  83. package/src/collections-setup.test.ts +237 -0
  84. package/src/collections-setup.ts +317 -0
  85. package/src/compose.ts +54 -1
  86. package/src/gateway-edge.test.ts +28 -0
  87. package/src/gateway-edge.ts +24 -0
  88. package/src/gateway-env-isolation.test.ts +141 -3
  89. package/src/gcp-names.ts +28 -84
  90. package/src/infra-contract.test.ts +5 -3
  91. package/src/infra-contract.ts +35 -1
  92. package/src/remote-mcp.test.ts +13 -1
  93. package/src/reporting-job-catalog.test.ts +156 -0
  94. package/src/reporting-job-catalog.ts +426 -0
  95. package/src/reporting-job-setup.test.ts +119 -6
  96. package/src/reporting-job-setup.ts +51 -158
  97. package/src/runtime-secrets.test.ts +19 -4
  98. package/src/runtime-secrets.ts +3 -0
  99. package/src/self-hosted-backup.test.ts +2 -2
  100. package/src/self-hosted-backup.ts +18 -6
  101. package/src/self-hosted-compose.test.ts +9 -3
  102. package/src/stack-contract.test.ts +62 -4
  103. package/src/stack-contract.ts +172 -59
  104. package/src/stack-converge-secrets.test.ts +4 -0
  105. package/src/stack-converge.test.ts +81 -3
  106. package/src/stack-converge.ts +124 -3
  107. package/src/staging-gateway-setup.test.ts +4 -0
  108. package/src/staging-gateway-setup.ts +16 -6
  109. package/src/upgrade/admin-image-jobs.ts +13 -25
  110. package/src/upgrade/app-roll.ts +7 -6
  111. package/src/upgrade/converge.ts +94 -77
  112. package/src/upgrade/upgrade.test.ts +97 -2
  113. package/src/upgrader-iam-preflight.ts +7 -20
  114. package/src/upgrader-job.test.ts +3 -0
  115. package/src/upgrader-setup.test.ts +3 -0
  116. package/src/upgrader-setup.ts +6 -17
  117. package/src/visitor-query-logs.ts +46 -0
  118. package/src/wizards/gcp-cost.ts +19 -9
  119. package/src/wizards/gcp.ts +51 -45
  120. package/stacks/aws/index.ts +18 -9
  121. package/stacks/azure/index.ts +19 -8
  122. package/stacks/gcp/index.ts +54 -1
  123. package/stacks/gcp-firebase/index.ts +28 -1
@@ -44,6 +44,7 @@ import { ensureAuditJob, resolveAdminImage } from "../audit-job-setup.js";
44
44
  import { ensureCaptureJob } from "../capture-job-setup.js";
45
45
  import { CERT_WAIT_TIMEOUT_MS, lbCertProbe, waitForCert } from "../cert-wait.js";
46
46
  import { redactCredentials } from "../checkpoint-secrets.js";
47
+ import { ensureCollectionStores } from "../collections-setup.js";
47
48
  import { ensureConvergeJob } from "../converge-job-setup.js";
48
49
  import { removeDefaultFirewallRules } from "../default-firewall.js";
49
50
  import {
@@ -80,10 +81,7 @@ import {
80
81
  serviceAccountExists,
81
82
  } from "../gcloud.js";
82
83
  import {
83
- auditRunnerServiceAccountEmail,
84
- buildCarrierServiceAccountEmail,
85
84
  GCP_STACK_ENV,
86
- importCrawlServiceAccountEmail,
87
85
  schedulerServiceAccountEmail,
88
86
  upgraderServiceAccountEmail,
89
87
  } from "../gcp-names.js";
@@ -136,10 +134,11 @@ import {
136
134
  resolveStackRemoteMcpIdentity,
137
135
  } from "../remote-mcp.js";
138
136
  import {
139
- ensureAuditRunnerJob,
140
- ensureBuildCarrierJob,
141
- ensureImportCrawlJob,
142
- } from "../reporting-job-setup.js";
137
+ REPORTING_JOB_CATALOG,
138
+ type ReportingJobKindEntry,
139
+ reportingJobServiceAccounts,
140
+ } from "../reporting-job-catalog.js";
141
+ import { ensureReportingJobKind } from "../reporting-job-setup.js";
143
142
  import type { RunMode } from "../run-mode.js";
144
143
  import { ensureSchedulerTick } from "../scheduler-setup.js";
145
144
  import { selfCommand } from "../self-command.js";
@@ -631,30 +630,19 @@ export async function runGcpConverge(opts: GcpConvergeOpts): Promise<void> {
631
630
  // Before the upgrader, which gets actAs on the job's service account.
632
631
  await stepAuditJob(projectId, region, provider);
633
632
 
634
- // === 11.32. The quality-audit runner: a Stage's audit in its own job (#1359) ===
635
- // After the audit job (it starts its Lighthouse tasks), before the
636
- // upgrader (actAs on its account) and operator access (keeps it on IAP).
637
- await stepReportingJob(projectId, region, provider, ownerEmail, {
638
- starting: "Setting up the quality-audit runner (audits outside the admin)...",
639
- ready: "Quality-audit runner ready",
640
- ensure: ensureAuditRunnerJob,
641
- });
642
-
643
- // === 11.33. The site-import crawler: a site import's crawl in its own job (#1360) ===
644
- // Before the upgrader and operator access, for the same reasons.
645
- await stepReportingJob(projectId, region, provider, ownerEmail, {
646
- starting: "Setting up the site-import crawler (crawls outside the admin)...",
647
- ready: "Site-import crawler ready",
648
- ensure: ensureImportCrawlJob,
649
- });
633
+ // === 11.32. The collection stores + the search-query log exclusion (epic #1644) ===
634
+ // After the staging gateway (its account reads the staging store), before
635
+ // the collection index job (it writes there).
636
+ await stepCollectionStores(projectId, region, provider);
650
637
 
651
- // === 11.34. The build carrier: holds the request a build nobody waits for runs in (#1574) ===
652
- // Before the upgrader and operator access, for the same reasons.
653
- await stepReportingJob(projectId, region, provider, ownerEmail, {
654
- starting: "Setting up the build carrier (builds that outlast their request)...",
655
- ready: "Build carrier ready",
656
- ensure: ensureBuildCarrierJob,
657
- });
638
+ // === 11.33. Every reporting job of the catalog (#1359, #1360, #1574, epic #1644) ===
639
+ // In catalog order, each after what it needs: the quality-audit runner
640
+ // after the audit job (it starts its Lighthouse tasks), the collection
641
+ // index job after the stores. All before the upgrader (actAs on their
642
+ // accounts) and operator access (keeps them on IAP).
643
+ for (const entry of REPORTING_JOB_CATALOG) {
644
+ await stepReportingJob(projectId, region, provider, ownerEmail, entry);
645
+ }
658
646
 
659
647
  // === 11.35. The capture job: server-side screenshots outside the admin (#1217) ===
660
648
  // Before the upgrader as well, which gets actAs on its service account.
@@ -689,10 +677,8 @@ export async function runGcpConverge(opts: GcpConvergeOpts): Promise<void> {
689
677
  keepSigner ? [`serviceAccount:${upgraderServiceAccountEmail(projectId, GCP_STACK_ENV)}`] : [],
690
678
  [
691
679
  ...(keepScheduler ? [schedulerServiceAccountEmail(projectId, GCP_STACK_ENV)] : []),
692
- // #1359 / #1360 / #1574 — set up above (a failure stops the wizard there).
693
- auditRunnerServiceAccountEmail(projectId, GCP_STACK_ENV),
694
- importCrawlServiceAccountEmail(projectId, GCP_STACK_ENV),
695
- buildCarrierServiceAccountEmail(projectId, GCP_STACK_ENV),
680
+ // Every reporting job: set up above (a failure stops the wizard there).
681
+ ...reportingJobServiceAccounts(projectId, GCP_STACK_ENV),
696
682
  ],
697
683
  );
698
684
 
@@ -1556,9 +1542,8 @@ async function stepAuditJob(
1556
1542
  }
1557
1543
 
1558
1544
  /**
1559
- * #1359 / #1360 — set up a reporting job (reporting-job-setup.ts) on the
1560
- * deployed admin's image: the quality-audit runner (a Stage's whole audit)
1561
- * or the site-import crawler (a site import's crawl), each reporting back
1545
+ * #1359 — set up one reporting job of the catalog (reporting-job-catalog.ts,
1546
+ * reporting-job-setup.ts) on the deployed admin's image, reporting back
1562
1547
  * through IAP. A failure stops the wizard: without it that work fails.
1563
1548
  * Idempotent, so it runs on every wizard pass.
1564
1549
  */
@@ -1567,14 +1552,10 @@ async function stepReportingJob(
1567
1552
  region: string,
1568
1553
  provider: "gcp" | "gcp-firebase",
1569
1554
  ownerEmail: string,
1570
- job: {
1571
- readonly starting: string;
1572
- readonly ready: string;
1573
- readonly ensure: typeof ensureAuditRunnerJob;
1574
- },
1555
+ entry: ReportingJobKindEntry,
1575
1556
  ): Promise<void> {
1576
1557
  const s = spinner();
1577
- s.start(job.starting);
1558
+ s.start(entry.wizard.starting);
1578
1559
  const image = await resolveAdminImage({ projectId, region, env: GCP_STACK_ENV });
1579
1560
  const resolved = image.ok
1580
1561
  ? await resolveOperatorAccessTarget({
@@ -1589,7 +1570,7 @@ async function stepReportingJob(
1589
1570
  ? { ok: false as const, done: [], error: image.error }
1590
1571
  : !resolved?.ok
1591
1572
  ? { ok: false as const, done: [], error: resolved?.error ?? "no IAP resource" }
1592
- : await job.ensure({
1573
+ : await ensureReportingJobKind(entry, {
1593
1574
  provider,
1594
1575
  projectId,
1595
1576
  region,
@@ -1603,7 +1584,32 @@ async function stepReportingJob(
1603
1584
  cancel("Aborted.");
1604
1585
  process.exit(1);
1605
1586
  }
1606
- s.stop(green(`${job.ready} (${r.done.length} steps)`));
1587
+ s.stop(green(`${entry.wizard.ready} (${r.done.length} steps)`));
1588
+ }
1589
+
1590
+ /**
1591
+ * Epic #1644 — the collection stores and who may read them, plus the log
1592
+ * exclusion for visitors' search queries (collections-setup.ts). A failure
1593
+ * stops the wizard: without the stores every Stage's plugin collections
1594
+ * fail. Idempotent, so it runs on every wizard pass. A staging gateway
1595
+ * whose setup failed above gets its read access from the next `upgrade`.
1596
+ */
1597
+ async function stepCollectionStores(
1598
+ projectId: string,
1599
+ region: string,
1600
+ provider: "gcp" | "gcp-firebase",
1601
+ ): Promise<void> {
1602
+ const s = spinner();
1603
+ s.start("Setting up the collection stores (plugin indexes such as site search)...");
1604
+ const r = await ensureCollectionStores({ provider, projectId, region, env: GCP_STACK_ENV });
1605
+ if (!r.ok) {
1606
+ s.stop(red(`Failed: ${r.error}`));
1607
+ log.error("Re-run the wizard once the cause is fixed (this step is idempotent).");
1608
+ cancel("Aborted.");
1609
+ process.exit(1);
1610
+ }
1611
+ s.stop(green(`Collection stores ready (${r.done.length} steps)`));
1612
+ for (const p of r.pending) log.warn(` ${p}`);
1607
1613
  }
1608
1614
 
1609
1615
  /**
@@ -455,15 +455,24 @@ new aws.cloudwatch.LogDelivery(
455
455
  // (quality/lighthouse-runner-select.ts) instead of measuring on its own
456
456
  // shared CPU. Nothing is staged on AWS before #749 either.
457
457
  //
458
- // FIXME(issue #749): no reporting-job task yet (#1359, #1360, #1574). On GCP
459
- // a Stage's whole quality audit and a site import's crawl each run in their
460
- // own job that reports back to the admin, and the build carrier holds the
461
- // request a build nobody else waits for runs in (src/reporting-job-setup.ts);
462
- // the AWS equivalent is an ECS task per audit, crawl or carried build behind
463
- // admin-core reporting-jobs/launcher.ts `JobLauncher`, reporting through the
464
- // ALB's Cognito gate. Until it exists the admin records every audit, every
465
- // site import and every carried build as failed with that gap instead of
466
- // running it on its own CPU.
458
+ // FIXME(issue #749): no reporting-job task yet (#1359, #1360, #1574, epic
459
+ // #1644). On GCP a Stage's whole quality audit, a site import's crawl, a
460
+ // Stage's collection index and a plugin's batch run each run in their own
461
+ // job that reports back to the admin, and the build carrier holds the
462
+ // request a build nobody else waits for runs in (src/reporting-job-catalog.ts);
463
+ // the AWS equivalent is an ECS task per kind behind admin-core
464
+ // reporting-jobs/launcher.ts `JobLauncher`, reporting through the ALB's
465
+ // Cognito gate. Until it exists the admin records every such run as failed
466
+ // with that gap instead of running it on its own CPU.
467
+ //
468
+ // FIXME(issue #749): no collection store yet (epic #1644). On GCP plugin
469
+ // collections (a site search's index) live in two private buckets, staging
470
+ // and live, each gateway reading only its own (src/collections-setup.ts);
471
+ // the AWS equivalent is two private S3 buckets with the same per-task
472
+ // grants and CAELO_COLLECTIONS_{STAGING,LIVE}_STORE on the tasks. Until it
473
+ // exists no task gets a store: a plugin's collection write fails with this
474
+ // gap (plugin-host collections-host.ts), the Stage records its collections
475
+ // as failed, and Publish live refuses until the plugin is deactivated.
467
476
  //
468
477
  // FIXME(issue #749): no capture task definition yet. On GCP every
469
478
  // server-side browser render (screenshots, external page renders, the
@@ -433,14 +433,25 @@ const logWorkspace = new azure.operationalinsights.Workspace(`${namePrefix}-logs
433
433
  // before #750 either.
434
434
  //
435
435
  // FIXME(issue #750): no reporting-job Container Apps job yet (#1359, #1360,
436
- // #1574). On GCP a Stage's whole quality audit and a site import's crawl each
437
- // run in their own job that reports back to the admin, and the build carrier
438
- // holds the request a build nobody else waits for runs in
439
- // (src/reporting-job-setup.ts); the Azure equivalent is a Container Apps job
440
- // execution per audit, crawl or carried build behind admin-core
441
- // reporting-jobs/launcher.ts `JobLauncher`, reporting through Easy Auth.
442
- // Until it exists the admin records every audit, every site import and every
443
- // carried build as failed with that gap instead of running it on its own CPU.
436
+ // #1574, epic #1644). On GCP a Stage's whole quality audit, a site import's
437
+ // crawl, a Stage's collection index and a plugin's batch run each run in
438
+ // their own job that reports back to the admin, and the build carrier holds
439
+ // the request a build nobody else waits for runs in
440
+ // (src/reporting-job-catalog.ts); the Azure equivalent is a Container Apps
441
+ // job execution per kind behind admin-core reporting-jobs/launcher.ts
442
+ // `JobLauncher`, reporting through Easy Auth. Until it exists the admin
443
+ // records every such run as failed with that gap instead of running it on
444
+ // its own CPU.
445
+ //
446
+ // FIXME(issue #750): no collection store yet (epic #1644). On GCP plugin
447
+ // collections (a site search's index) live in two private buckets, staging
448
+ // and live, each gateway reading only its own (src/collections-setup.ts);
449
+ // the Azure equivalent is two private Blob containers with the same
450
+ // per-app role assignments and CAELO_COLLECTIONS_{STAGING,LIVE}_STORE on the
451
+ // apps. Until it exists no app gets a store: a plugin's collection write
452
+ // fails with this gap (plugin-host collections-host.ts), the Stage records
453
+ // its collections as failed, and Publish live refuses until the plugin is
454
+ // deactivated.
444
455
  //
445
456
  // FIXME(issue #750): no capture Container Apps job yet. On GCP every
446
457
  // server-side browser render (screenshots, external page renders, the
@@ -35,6 +35,7 @@ import {
35
35
  runServiceAccountId,
36
36
  stagingGatewayServiceAccountId,
37
37
  staticPublisherServiceAccountId,
38
+ visitorQueryLogExclusionName,
38
39
  } from "../../dist/gcp-names.js";
39
40
  import { createSiteUrlMap } from "../../dist/gcp-url-map.js";
40
41
  import {
@@ -59,6 +60,8 @@ import {
59
60
  cloudSqlPrivateDnsName,
60
61
  databaseUrls,
61
62
  defaultStagingHost,
63
+ GATEWAY_CDN_POLICY,
64
+ GATEWAY_MEMORY_DEFAULT,
62
65
  gatewayEnvContract,
63
66
  REMOTE_MCP_IDENTITY_CONFIG,
64
67
  type RuntimeSecret,
@@ -70,6 +73,10 @@ import {
70
73
  } from "../../dist/stack-contract.js";
71
74
  import { DEPLOY_GATEWAYS_CONFIG, parseDeployGateways } from "../../dist/stack-gateways.js";
72
75
  import { GCP_STATIC_RESPONSE_HEADERS } from "../../dist/static-security-headers.js";
76
+ import {
77
+ VISITOR_QUERY_LOG_DESCRIPTION,
78
+ VISITOR_QUERY_LOG_FILTER,
79
+ } from "../../dist/visitor-query-logs.js";
73
80
 
74
81
  const cfg = new pulumi.Config();
75
82
  const domain = cfg.require("domain");
@@ -300,6 +307,9 @@ const runtimeSecretIds: Record<RuntimeSecret, pulumi.Input<string>> = {
300
307
  // then; IAP login, IAP programmatic access and the remote-MCP broker) and
301
308
  // the broker's seal key, both CLI-generated.
302
309
  "operator-oauth-client": gcpSecretId(env, "operator-oauth-client"),
310
+ // #1654 — the visitor AI's key per environment, CLI-generated as `{}`.
311
+ "visitor-ai-key": gcpSecretId(env, "visitor-ai-key"),
312
+ "visitor-ai-staging-key": gcpSecretId(env, "visitor-ai-staging-key"),
303
313
  "mcp-oauth-seal-key": gcpSecretId(env, "mcp-oauth-seal-key"),
304
314
  };
305
315
 
@@ -635,6 +645,28 @@ new gcp.secretmanager.SecretIamMember(
635
645
  opts,
636
646
  );
637
647
 
648
+ // #1654 — the Owner's visitor-AI keys, one secret per environment, the same
649
+ // add-version-only grant: the admin stores or removes a key, never reads
650
+ // one; each gateway reads only its own (stack-contract.ts GCP_COMMON).
651
+ new gcp.secretmanager.SecretIamMember(
652
+ `${namePrefix}-admin-visitor-ai-key-version-adder`,
653
+ {
654
+ secretId: runtimeSecretIds["visitor-ai-key"],
655
+ role: "roles/secretmanager.secretVersionAdder",
656
+ member: pulumi.interpolate`serviceAccount:${runSa.email}`,
657
+ },
658
+ opts,
659
+ );
660
+ new gcp.secretmanager.SecretIamMember(
661
+ `${namePrefix}-admin-visitor-ai-staging-key-version-adder`,
662
+ {
663
+ secretId: runtimeSecretIds["visitor-ai-staging-key"],
664
+ role: "roles/secretmanager.secretVersionAdder",
665
+ member: pulumi.interpolate`serviceAccount:${runSa.email}`,
666
+ },
667
+ opts,
668
+ );
669
+
638
670
  new gcp.storage.BucketIAMMember(
639
671
  `${namePrefix}-media-rw`,
640
672
  {
@@ -976,7 +1008,8 @@ const gatewaySvc = deployGateways
976
1008
  serviceName: "gateway",
977
1009
  minInstances: gatewayMinInstances,
978
1010
  maxInstances: gatewayMaxInstances,
979
- memory: "512Mi",
1011
+ // Epic #1644 — collection index files are cached in memory.
1012
+ memory: GATEWAY_MEMORY_DEFAULT,
980
1013
  // Visitor requests only (#1328 moved remote MCP's long streams to the
981
1014
  // MCP-Auth-Proxy): Cloud Run's default.
982
1015
  timeout: "300s",
@@ -1086,6 +1119,16 @@ function gatewayBackend(service: gcp.cloudrunv2.Service): gcp.compute.BackendSer
1086
1119
  backends: [{ group: gatewayNeg.id }],
1087
1120
  loadBalancingScheme: "EXTERNAL_MANAGED",
1088
1121
  securityPolicy: wafPolicy.id,
1122
+ // Epic #1644 — a collection operation's answer for the release it
1123
+ // names is cacheable; everything else the gateway says is no-store
1124
+ // (stack-contract.ts GATEWAY_CDN_POLICY, converged by upgrade).
1125
+ enableCdn: true,
1126
+ cdnPolicy: {
1127
+ cacheMode: GATEWAY_CDN_POLICY.cacheMode,
1128
+ negativeCaching: GATEWAY_CDN_POLICY.negativeCaching,
1129
+ serveWhileStale: GATEWAY_CDN_POLICY.serveWhileStale,
1130
+ cacheKeyPolicy: { ...GATEWAY_CDN_POLICY.cacheKeyPolicy },
1131
+ },
1089
1132
  },
1090
1133
  opts,
1091
1134
  );
@@ -1396,6 +1439,16 @@ const loggingSink = new gcp.logging.ProjectSink(
1396
1439
  ? pulumi.interpolate`(resource.type="cloud_run_revision" AND resource.labels.service_name="${gatewaySvc.name}") OR (resource.type="cloud_run_revision" AND resource.labels.service_name="${adminSvc.name}" AND severity>=WARNING)`
1397
1440
  : pulumi.interpolate`resource.type="cloud_run_revision" AND resource.labels.service_name="${adminSvc.name}" AND severity>=WARNING`,
1398
1441
  uniqueWriterIdentity: true,
1442
+ // Epic #1644 — visitors' search queries ride in the URL of a gateway
1443
+ // request log; they are never exported (visitor-query-logs.ts; the CLI
1444
+ // puts the same exclusion on _Default).
1445
+ exclusions: [
1446
+ {
1447
+ name: visitorQueryLogExclusionName(env),
1448
+ description: VISITOR_QUERY_LOG_DESCRIPTION,
1449
+ filter: VISITOR_QUERY_LOG_FILTER,
1450
+ },
1451
+ ],
1399
1452
  },
1400
1453
  opts,
1401
1454
  );
@@ -76,6 +76,7 @@ import {
76
76
  databaseUrls,
77
77
  defaultStagingHost,
78
78
  fixedCloudRunServiceName,
79
+ GATEWAY_MEMORY_DEFAULT,
79
80
  gatewayEnvContract,
80
81
  MCP_AUTH_PROXY_TIMEOUT_SECONDS,
81
82
  mcpAuthProxyEnvContract,
@@ -287,6 +288,9 @@ const runtimeSecretIds: Record<RuntimeSecret, pulumi.Input<string>> = {
287
288
  // then; IAP login, IAP programmatic access and the remote-MCP broker) and
288
289
  // the broker's seal key, both CLI-generated.
289
290
  "operator-oauth-client": gcpSecretId(env, "operator-oauth-client"),
291
+ // #1654 — the visitor AI's key per environment, CLI-generated as `{}`.
292
+ "visitor-ai-key": gcpSecretId(env, "visitor-ai-key"),
293
+ "visitor-ai-staging-key": gcpSecretId(env, "visitor-ai-staging-key"),
290
294
  "mcp-oauth-seal-key": gcpSecretId(env, "mcp-oauth-seal-key"),
291
295
  };
292
296
 
@@ -552,6 +556,28 @@ new gcp.secretmanager.SecretIamMember(
552
556
  opts,
553
557
  );
554
558
 
559
+ // #1654 — the Owner's visitor-AI keys, one secret per environment, the same
560
+ // add-version-only grant: the admin stores or removes a key, never reads
561
+ // one; each gateway reads only its own (stack-contract.ts GCP_COMMON).
562
+ new gcp.secretmanager.SecretIamMember(
563
+ `${namePrefix}-admin-visitor-ai-key-version-adder`,
564
+ {
565
+ secretId: runtimeSecretIds["visitor-ai-key"],
566
+ role: "roles/secretmanager.secretVersionAdder",
567
+ member: pulumi.interpolate`serviceAccount:${runSa.email}`,
568
+ },
569
+ opts,
570
+ );
571
+ new gcp.secretmanager.SecretIamMember(
572
+ `${namePrefix}-admin-visitor-ai-staging-key-version-adder`,
573
+ {
574
+ secretId: runtimeSecretIds["visitor-ai-staging-key"],
575
+ role: "roles/secretmanager.secretVersionAdder",
576
+ member: pulumi.interpolate`serviceAccount:${runSa.email}`,
577
+ },
578
+ opts,
579
+ );
580
+
555
581
  new gcp.storage.BucketIAMMember(
556
582
  `${namePrefix}-media-rw`,
557
583
  {
@@ -861,7 +887,8 @@ const gatewaySvc = deployGateways
861
887
  resourceName: `${namePrefix}-data-gateway`,
862
888
  minInstances: gatewayMinInstances,
863
889
  maxInstances: gatewayMaxInstances,
864
- memory: "512Mi",
890
+ // Epic #1644 — collection index files are cached in memory.
891
+ memory: GATEWAY_MEMORY_DEFAULT,
865
892
  // Firebase Hosting cuts a rewritten request at 60 s anyway.
866
893
  timeout: "300s",
867
894
  // All traffic: the Firebase rewrite arrives from Google's edge, and it is