@integrity-labs/agt-cli 0.28.1259 → 0.28.1261

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 (35) hide show
  1. package/dist/{api-client-ATRLQZOU.js → api-client-2YLFNHFZ.js} +3 -3
  2. package/dist/bin/agt.js +7 -7
  3. package/dist/{chunk-5433KPH4.js → chunk-335HKIDZ.js} +2 -2
  4. package/dist/{chunk-BOITSKCM.js → chunk-6NHFZYUP.js} +3 -3
  5. package/dist/{chunk-RBC22FRC.js → chunk-I2NQQOMD.js} +3 -3
  6. package/dist/{chunk-F6U3ZJCG.js → chunk-JYSPPCHG.js} +2 -2
  7. package/dist/{chunk-NRNPYXG6.js → chunk-QFLR5EFT.js} +98 -6
  8. package/dist/chunk-QFLR5EFT.js.map +1 -0
  9. package/dist/{chunk-UAO5VMYK.js → chunk-ZEJUBTXJ.js} +441 -254
  10. package/dist/chunk-ZEJUBTXJ.js.map +1 -0
  11. package/dist/{claude-code-updater-SUL3OSGB.js → claude-code-updater-B2BWPRFE.js} +3 -3
  12. package/dist/{claude-pair-runtime-D6ZRO2FC.js → claude-pair-runtime-FNDHAPXR.js} +3 -3
  13. package/dist/lib/manager-worker.js +580 -427
  14. package/dist/lib/manager-worker.js.map +1 -1
  15. package/dist/mcp/direct-chat-channel.js +94 -2
  16. package/dist/mcp/index.js +94 -2
  17. package/dist/mcp/origami.js +94 -2
  18. package/dist/mcp/slack-channel.js +94 -2
  19. package/dist/mcp/telegram-channel.js +94 -2
  20. package/dist/{persistent-session-UC56OJVB.js → persistent-session-LHQLLU4U.js} +4 -4
  21. package/dist/{responsiveness-probe-KGBRCJQW.js → responsiveness-probe-KDSNPKUY.js} +4 -4
  22. package/dist/{session-auth-dead-AVYJASOL.js → session-auth-dead-3IHR4M2B.js} +3 -3
  23. package/package.json +1 -1
  24. package/dist/chunk-NRNPYXG6.js.map +0 -1
  25. package/dist/chunk-UAO5VMYK.js.map +0 -1
  26. /package/dist/{api-client-ATRLQZOU.js.map → api-client-2YLFNHFZ.js.map} +0 -0
  27. /package/dist/{chunk-5433KPH4.js.map → chunk-335HKIDZ.js.map} +0 -0
  28. /package/dist/{chunk-BOITSKCM.js.map → chunk-6NHFZYUP.js.map} +0 -0
  29. /package/dist/{chunk-RBC22FRC.js.map → chunk-I2NQQOMD.js.map} +0 -0
  30. /package/dist/{chunk-F6U3ZJCG.js.map → chunk-JYSPPCHG.js.map} +0 -0
  31. /package/dist/{claude-code-updater-SUL3OSGB.js.map → claude-code-updater-B2BWPRFE.js.map} +0 -0
  32. /package/dist/{claude-pair-runtime-D6ZRO2FC.js.map → claude-pair-runtime-FNDHAPXR.js.map} +0 -0
  33. /package/dist/{persistent-session-UC56OJVB.js.map → persistent-session-LHQLLU4U.js.map} +0 -0
  34. /package/dist/{responsiveness-probe-KGBRCJQW.js.map → responsiveness-probe-KDSNPKUY.js.map} +0 -0
  35. /package/dist/{session-auth-dead-AVYJASOL.js.map → session-auth-dead-3IHR4M2B.js.map} +0 -0
@@ -44457,7 +44457,10 @@ var GITHUB_EVENT_RULES = {
44457
44457
  pull_request_review: { actions: ["submitted"] },
44458
44458
  check_suite: { actions: ["completed"] },
44459
44459
  issues: { actions: ["opened", "closed"] },
44460
- issue_comment: { actions: ["created"] }
44460
+ issue_comment: { actions: ["created"] },
44461
+ // ENG-12123 (CS-2564): a deployment's status changed. GitHub sends one
44462
+ // deployment_status event per state change, always with action `created`.
44463
+ deployment_status: { actions: ["created"] }
44461
44464
  };
44462
44465
  var GITHUB_WEBHOOK_EVENTS = Object.keys(GITHUB_EVENT_RULES);
44463
44466
  var REPO_FULL_NAME = /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})\/[A-Za-z0-9._-]{1,100}$/;
@@ -44480,6 +44483,28 @@ var CHECK_CONCLUSIONS = /* @__PURE__ */ new Set([
44480
44483
  "startup_failure"
44481
44484
  ]);
44482
44485
  var ISSUE_STATE_REASONS = /* @__PURE__ */ new Set(["completed", "not_planned", "reopened", "duplicate"]);
44486
+ var DEPLOYMENT_STATES = /* @__PURE__ */ new Set(["success", "failure", "error", "pending", "in_progress", "queued", "inactive"]);
44487
+ var ENVIRONMENT_TOKEN = /^[A-Za-z0-9][A-Za-z0-9._/:-]{0,63}$/;
44488
+ var ACTIONS_RUN_PATH = /^\/([^/]+)\/([^/]+)\/actions\/runs\/([1-9][0-9]{0,18})(?:\/job\/([1-9][0-9]{0,18}))?\/?$/;
44489
+ function githubActionsRunUrl(v, repo) {
44490
+ const s = str(v);
44491
+ if (s === null || s.length > 500)
44492
+ return null;
44493
+ let u;
44494
+ try {
44495
+ u = new URL(s);
44496
+ } catch {
44497
+ return null;
44498
+ }
44499
+ if (u.protocol !== "https:" || u.username || u.password || u.port || u.hostname !== "github.com")
44500
+ return null;
44501
+ const m = ACTIONS_RUN_PATH.exec(u.pathname);
44502
+ if (!m)
44503
+ return null;
44504
+ if (`${m[1]}/${m[2]}`.toLowerCase() !== repo.toLowerCase())
44505
+ return null;
44506
+ return `https://github.com/${repo}/actions/runs/${m[3]}${m[4] ? `/job/${m[4]}` : ""}`;
44507
+ }
44483
44508
  function asDict(v) {
44484
44509
  return v !== null && typeof v === "object" && !Array.isArray(v) ? v : null;
44485
44510
  }
@@ -44625,6 +44650,36 @@ function extractGithubFacts(event, payload) {
44625
44650
  summary: `Issue #${n2} ${action} in ${repo}`
44626
44651
  };
44627
44652
  }
44653
+ if (event === "deployment_status") {
44654
+ const status = asDict(root["deployment_status"]);
44655
+ const deployment = asDict(root["deployment"]);
44656
+ if (!status || !deployment)
44657
+ return null;
44658
+ const state = inSet(status["state"], DEPLOYMENT_STATES);
44659
+ const environment = shaped(status["environment"], ENVIRONMENT_TOKEN) ?? shaped(deployment["environment"], ENVIRONMENT_TOKEN);
44660
+ details.push(["Environment", environment ?? "(name withheld: not a plain token)"]);
44661
+ details.push(["State", state ?? "unknown"]);
44662
+ const deploymentId = posInt(deployment["id"]);
44663
+ if (deploymentId !== null)
44664
+ details.push(["Deployment id", String(deploymentId)]);
44665
+ const sha = shaped(str(deployment["sha"])?.toLowerCase(), SHA);
44666
+ if (sha)
44667
+ details.push(["Commit", sha]);
44668
+ const creator = shaped(asDict(status["creator"])?.["login"], LOGIN);
44669
+ if (creator)
44670
+ details.push(["Status set by", creator]);
44671
+ const link = githubActionsRunUrl(status["log_url"], repo) ?? githubActionsRunUrl(status["target_url"], repo);
44672
+ return {
44673
+ event,
44674
+ action,
44675
+ repo,
44676
+ subject: null,
44677
+ url: link ?? `${base}/deployments`,
44678
+ sender,
44679
+ details,
44680
+ summary: `Deployment to ${environment ?? "an environment"} ${state ?? "updated"} in ${repo}`
44681
+ };
44682
+ }
44628
44683
  const issue2 = asDict(root["issue"]);
44629
44684
  const n = issue2 ? posInt(issue2["number"]) : null;
44630
44685
  if (!issue2 || n === null)
@@ -44754,7 +44809,7 @@ var FLAG_REGISTRY = [
44754
44809
  },
44755
44810
  {
44756
44811
  key: "at-rest-scheme-k-writes",
44757
- description: "ADR-0062 increment C arm (ENG-11944). Gates whether an at-rest sink that has an active dek_epochs row seals under a PER-ORG DEK wrapped by the platform KEK (envelope `s: 'k'`) instead of the app key (`s: 'a'`). OFF (default) = scheme a, i.e. the ADR-0061 behaviour, whatever the sink and whatever epochs exist. Resolved FLEET-WIDE and process-global via setSchemeKWritesArmed at the API bootstrap seam \u2014 per-org overrides do NOT apply (the crypto writer carries no request context), despite the DEK itself being per-org. Ships dark; the corpus is empty. NOT REVERSIBLE THE WAY `at-rest-v2-writes` IS, and the difference is the point: clearing that flag returns the writer to v1 and every blob it wrote stays readable under the same app key, whereas clearing THIS one stops new rows but leaves every row already written readable ONLY through the KMS key its inline wrap names (A5 option 2), permanently. Three preconditions for the flip, none of which this flag can check: (1) ENG-10990 \u2014 the re-seal drain never UNWRAPS the survivor it nominates, so DRAIN COMPLETE can be reported over a row whose only path is a kms: ref that does not work; (2) ADR-0062 A9 \u2014 a wrap ref embeds a region and cannot follow a migration. The BINDING check is at the MINT and compares the region in the ARN KMS returns against PRIMARY_APP_REGION; isSecondaryStack() is only its pre-filter (AWS_REGION unset still lets the SDK take a region from the shared profile) and is separately what stops a non-live stack sealing at all. A seal never writes its own region \u2014 it reuses the epoch ref verbatim; (3) an org must have an active dek_epochs row before ANY of its rows can be scheme k, and this flag does not create one. There is no lazy first-write mint (dek-epochs.ts decision 2); the ONE production caller of mintDekEpoch is POST /admin/dek-epochs/:organizationId/mint (ENG-12012), staff-only, one named org per call, and it must be invoked deliberately. So FLIPPING THIS ON BY ITSELF CHANGES NOTHING: every org still seals scheme a until someone mints deliberately. That is the intended rollout for a control whose first row freezes the envelope for the whole corpus: one pilot org, watched. kms:GenerateDataKey is therefore a MINT precondition, not a flip one \u2014 sst.config.ts grants it only where apiSecretsKmsKeyArn is defined (prod and test), so a mint on any other stage fails loudly with AccessDenied, which is the right place to fail. BUT THE GRANT IS NOT THE ONLY PRECONDITION, AND SCHEME K IS PROD-ONLY (Obi Wan 5eda5230451a). This sentence used to stop at the grant, which read as \"prod and test can mint\". Test cannot: deploy-test.yml pins AUGMENTED_APP_REGION=us-east-2, so the test API runs with AWS_REGION=us-east-2, isSecondaryStack() is true there, and BOTH A9 gates refuse \u2014 the arming seam writes scheme a, and mintDekEpoch throws at its pre-filter (and would fail the ARN-region check anyway, since test's stage CMK is itself in us-east-2). So the first scheme-k row ever written will be on PROD, and the one-pilot-org rehearsal above cannot be done on test first. That is a KNOWN LIMITATION, not an oversight: both gates compare against the single PRIMARY_APP_REGION constant, and making them aware of a stage's own home region needs a stage->region source that does not exist at the mint's call site (AUGMENTED_APP_REGION is read only in sst.config.ts at deploy time, and the first mint runs in an operator shell). Do NOT whitelist us-east-2 to make test mint \u2014 that is the pre-cutover region A9 exists to keep out of rows. VERIFIED 2026-11-10 (ENG-11944), replacing the unverified note that stood here: the live key policy on alias/augmented-prod-secrets is the AWS default single statement (account root, kms:*, NO Condition block), so it constrains no EncryptionContext and cannot refuse the per-org one; and the live API role does hold Decrypt + GenerateDataKey on that key, unconditioned. Note what follows: KMS POLICY IS NOT WHAT ISOLATES ONE ORG DEK FROM ANOTHER. AES-GCM AAD is, cryptographically, inside KMS.",
44812
+ description: "ADR-0062 increment C arm (ENG-11944). Gates whether an at-rest sink that has an active dek_epochs row seals under a PER-ORG DEK wrapped by the platform KEK (envelope `s: 'k'`) instead of the app key (`s: 'a'`). OFF (default) = scheme a, i.e. the ADR-0061 behaviour, whatever the sink and whatever epochs exist. Resolved FLEET-WIDE and process-global via setSchemeKWritesArmed at the API bootstrap seam \u2014 per-org overrides do NOT apply (the crypto writer carries no request context), despite the DEK itself being per-org. Ships dark; the corpus is empty. NOT REVERSIBLE THE WAY `at-rest-v2-writes` IS, and the difference is the point: clearing that flag returns the writer to v1 and every blob it wrote stays readable under the same app key, whereas clearing THIS one stops new rows but leaves every row already written readable ONLY through the KMS key its inline wrap names (A5 option 2), permanently. Three preconditions for the flip, none of which this flag can check: (1) ENG-10990 \u2014 the re-seal drain never UNWRAPS the survivor it nominates, so DRAIN COMPLETE can be reported over a row whose only path is a kms: ref that does not work; (2) ADR-0062 A9 \u2014 a wrap ref embeds a region and cannot follow a migration. The BINDING check is at the MINT and compares the region in the ARN KMS returns against PRIMARY_APP_REGION; isSecondaryStack() is only its pre-filter (AWS_REGION unset still lets the SDK take a region from the shared profile) and is separately what stops a non-live stack sealing at all. A seal never writes its own region \u2014 it reuses the epoch ref verbatim; (3) an org must have an active dek_epochs row before ANY of its rows can be scheme k, and this flag does not create one. There is no lazy first-write mint (dek-epochs.ts decision 2); the ONE production caller of mintDekEpoch is POST /admin/dek-epochs/:organizationId/mint (ENG-12012), staff-only, one named org per call, and it must be invoked deliberately. So FLIPPING THIS ON BY ITSELF CHANGES NOTHING: every org still seals scheme a until someone mints deliberately. That is the intended rollout for a control whose first row freezes the envelope for the whole corpus: one pilot org, watched. kms:GenerateDataKey is therefore a MINT precondition, not a flip one \u2014 sst.config.ts grants it only where apiSecretsKmsKeyArn is defined (prod and test), so a mint on any other stage fails loudly with AccessDenied, which is the right place to fail. BUT THE GRANT IS NOT THE ONLY PRECONDITION, AND SCHEME K IS PROD-ONLY (Obi Wan 5eda5230451a). This sentence used to stop at the grant, which read as \"prod and test can mint\". Test cannot \u2014 and as of ENG-11886 the REASON HAS CHANGED, so do not reason from the old one. deploy-test.yml PINNED AUGMENTED_APP_REGION=us-east-2, so the test API RAN with AWS_REGION=us-east-2, isSecondaryStack() WAS true there, and both A9 gates refused \u2014 the arming seam wrote scheme a, and mintDekEpoch threw at its pre-filter. ENG-11886 retired that workflow and its `test` GitHub Environment is gone, so NO workflow deploys a non-prod stage any more: there is no test API to mint from at all, which is now the whole of why test cannot. The region argument is history, not the live mechanism. AND DO NOT INVERT IT INTO \"a hand-rebuilt test stage could mint\": that was NOT measured, and it turns on two things nobody has checked \u2014 which region the operator exports (the resolver defaults to ap-southeast-2 now, which IS PRIMARY_APP_REGION, so the pre-filter would NOT refuse) and where alias/augmented-test-secrets resolves. Measure both before using a rebuilt test stage as the pilot. Either way the first scheme-k row ever written will be on PROD, and the one-pilot-org rehearsal above cannot be done on test first. That is a KNOWN LIMITATION, not an oversight: both gates compare against the single PRIMARY_APP_REGION constant, and making them aware of a stage's own home region needs a stage->region source that does not exist at the mint's call site (AUGMENTED_APP_REGION is read only in sst.config.ts at deploy time, and the first mint runs in an operator shell). Do NOT whitelist us-east-2 to make test mint \u2014 that is the pre-cutover region A9 exists to keep out of rows. VERIFIED 2026-11-10 (ENG-11944), replacing the unverified note that stood here: the live key policy on alias/augmented-prod-secrets is the AWS default single statement (account root, kms:*, NO Condition block), so it constrains no EncryptionContext and cannot refuse the per-org one; and the live API role does hold Decrypt + GenerateDataKey on that key, unconditioned. Note what follows: KMS POLICY IS NOT WHAT ISOLATES ONE ORG DEK FROM ANOTHER. AES-GCM AAD is, cryptographically, inside KMS.",
44758
44813
  flagType: "boolean",
44759
44814
  // Declared safe value is `false` = scheme a. A flag-read error must never arm
44760
44815
  // scheme k on its own: an unintended `a` row is re-sealable, an unintended
@@ -44801,6 +44856,43 @@ var FLAG_REGISTRY = [
44801
44856
  flagType: "boolean",
44802
44857
  defaultValue: false
44803
44858
  },
44859
+ {
44860
+ key: "scratch-sweep-held",
44861
+ description: "ENG-11877: stops ALL scratch sweeping for an agent, including the existing tree rule, for files someone has asked to keep. Resolved per agent by the manager. Sticky on the host: once seen it is written to a marker outside scratch, which keeps the agent held until heartbeats that evaluated it find the flag off for 10 minutes, so a restart or a failed flag read cannot let a sweep through. A host only honours it once its CLI has the reader: check reach before relying on it. Off is the safe default for everyone else.",
44862
+ sensitive: true,
44863
+ flagType: "boolean",
44864
+ defaultValue: false,
44865
+ // No published agt-cli has this reader yet, and a guessed floor would report reach
44866
+ // on hosts that can't act on it. So this reads as "no host yet" on purpose, the
44867
+ // safe direction. ENG-11877 re-pins it from the published dist after merge.
44868
+ since: "0.28.999999"
44869
+ },
44870
+ {
44871
+ key: "scratch-sweep-per-file",
44872
+ description: "ENG-11877: also expire old files inside scratch folders still in use, instead of keeping a whole folder while anything in it is fresh. IRREVERSIBLE on its first pass: every file unchanged for 7 days goes, customer documents included, so arm it per agent and read scratch-sweep-dry-run first. Off = the tree rule only.",
44873
+ sensitive: true,
44874
+ // CodeRabbit on #7378: `sensitive` only forces a confirmation; it does not say
44875
+ // WHO. Its first pass irreversibly deletes old customer files, and arming it is
44876
+ // Brad's rollout decision (ENG-11877), so an org owner/admin must not be able to
44877
+ // switch it on for their own agents. Only the cross-org admin route can write it.
44878
+ platformAdminOnly: true,
44879
+ flagType: "boolean",
44880
+ defaultValue: false,
44881
+ // No published agt-cli has this reader yet, and a guessed floor would report reach
44882
+ // on hosts that can't act on it. So this reads as "no host yet" on purpose, the
44883
+ // safe direction. ENG-11877 re-pins it from the published dist after merge.
44884
+ since: "0.28.999999"
44885
+ },
44886
+ {
44887
+ key: "scratch-sweep-dry-run",
44888
+ description: "ENG-11877: count what scratch-sweep-per-file would remove and log it to manager.log every 6 hours ([scratch] [sweep-dry-run]). Metadata only: never opens a file, never logs a name, removes nothing extra.",
44889
+ flagType: "boolean",
44890
+ defaultValue: false,
44891
+ // No published agt-cli has this reader yet, and a guessed floor would report reach
44892
+ // on hosts that can't act on it. So this reads as "no host yet" on purpose, the
44893
+ // safe direction. ENG-11877 re-pins it from the published dist after merge.
44894
+ since: "0.28.999999"
44895
+ },
44804
44896
  {
44805
44897
  key: "broker-read-jobs",
44806
44898
  description: `Slow broker READ tools finish in a background job (ENG-11476, ADR-0129). When on for an org, an opted-in read tool (Pronto Xi first) that misses an 18s grace window answers "still running, call again with the same arguments" and finishes in the broker-read-job worker instead of timing out. Off = today's synchronous call, so false is the safe value. Evaluated in the API per org, team and agent.`,
package/dist/mcp/index.js CHANGED
@@ -30139,7 +30139,10 @@ var GITHUB_EVENT_RULES = {
30139
30139
  pull_request_review: { actions: ["submitted"] },
30140
30140
  check_suite: { actions: ["completed"] },
30141
30141
  issues: { actions: ["opened", "closed"] },
30142
- issue_comment: { actions: ["created"] }
30142
+ issue_comment: { actions: ["created"] },
30143
+ // ENG-12123 (CS-2564): a deployment's status changed. GitHub sends one
30144
+ // deployment_status event per state change, always with action `created`.
30145
+ deployment_status: { actions: ["created"] }
30143
30146
  };
30144
30147
  var GITHUB_WEBHOOK_EVENTS = Object.keys(GITHUB_EVENT_RULES);
30145
30148
  var REPO_FULL_NAME = /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})\/[A-Za-z0-9._-]{1,100}$/;
@@ -30162,6 +30165,28 @@ var CHECK_CONCLUSIONS = /* @__PURE__ */ new Set([
30162
30165
  "startup_failure"
30163
30166
  ]);
30164
30167
  var ISSUE_STATE_REASONS = /* @__PURE__ */ new Set(["completed", "not_planned", "reopened", "duplicate"]);
30168
+ var DEPLOYMENT_STATES = /* @__PURE__ */ new Set(["success", "failure", "error", "pending", "in_progress", "queued", "inactive"]);
30169
+ var ENVIRONMENT_TOKEN = /^[A-Za-z0-9][A-Za-z0-9._/:-]{0,63}$/;
30170
+ var ACTIONS_RUN_PATH = /^\/([^/]+)\/([^/]+)\/actions\/runs\/([1-9][0-9]{0,18})(?:\/job\/([1-9][0-9]{0,18}))?\/?$/;
30171
+ function githubActionsRunUrl(v, repo) {
30172
+ const s = str(v);
30173
+ if (s === null || s.length > 500)
30174
+ return null;
30175
+ let u;
30176
+ try {
30177
+ u = new URL(s);
30178
+ } catch {
30179
+ return null;
30180
+ }
30181
+ if (u.protocol !== "https:" || u.username || u.password || u.port || u.hostname !== "github.com")
30182
+ return null;
30183
+ const m = ACTIONS_RUN_PATH.exec(u.pathname);
30184
+ if (!m)
30185
+ return null;
30186
+ if (`${m[1]}/${m[2]}`.toLowerCase() !== repo.toLowerCase())
30187
+ return null;
30188
+ return `https://github.com/${repo}/actions/runs/${m[3]}${m[4] ? `/job/${m[4]}` : ""}`;
30189
+ }
30165
30190
  function asDict(v) {
30166
30191
  return v !== null && typeof v === "object" && !Array.isArray(v) ? v : null;
30167
30192
  }
@@ -30307,6 +30332,36 @@ function extractGithubFacts(event, payload) {
30307
30332
  summary: `Issue #${n2} ${action} in ${repo}`
30308
30333
  };
30309
30334
  }
30335
+ if (event === "deployment_status") {
30336
+ const status = asDict(root["deployment_status"]);
30337
+ const deployment = asDict(root["deployment"]);
30338
+ if (!status || !deployment)
30339
+ return null;
30340
+ const state = inSet(status["state"], DEPLOYMENT_STATES);
30341
+ const environment = shaped(status["environment"], ENVIRONMENT_TOKEN) ?? shaped(deployment["environment"], ENVIRONMENT_TOKEN);
30342
+ details.push(["Environment", environment ?? "(name withheld: not a plain token)"]);
30343
+ details.push(["State", state ?? "unknown"]);
30344
+ const deploymentId = posInt(deployment["id"]);
30345
+ if (deploymentId !== null)
30346
+ details.push(["Deployment id", String(deploymentId)]);
30347
+ const sha = shaped(str(deployment["sha"])?.toLowerCase(), SHA);
30348
+ if (sha)
30349
+ details.push(["Commit", sha]);
30350
+ const creator = shaped(asDict(status["creator"])?.["login"], LOGIN);
30351
+ if (creator)
30352
+ details.push(["Status set by", creator]);
30353
+ const link = githubActionsRunUrl(status["log_url"], repo) ?? githubActionsRunUrl(status["target_url"], repo);
30354
+ return {
30355
+ event,
30356
+ action,
30357
+ repo,
30358
+ subject: null,
30359
+ url: link ?? `${base}/deployments`,
30360
+ sender,
30361
+ details,
30362
+ summary: `Deployment to ${environment ?? "an environment"} ${state ?? "updated"} in ${repo}`
30363
+ };
30364
+ }
30310
30365
  const issue2 = asDict(root["issue"]);
30311
30366
  const n = issue2 ? posInt(issue2["number"]) : null;
30312
30367
  if (!issue2 || n === null)
@@ -30436,7 +30491,7 @@ var FLAG_REGISTRY = [
30436
30491
  },
30437
30492
  {
30438
30493
  key: "at-rest-scheme-k-writes",
30439
- description: "ADR-0062 increment C arm (ENG-11944). Gates whether an at-rest sink that has an active dek_epochs row seals under a PER-ORG DEK wrapped by the platform KEK (envelope `s: 'k'`) instead of the app key (`s: 'a'`). OFF (default) = scheme a, i.e. the ADR-0061 behaviour, whatever the sink and whatever epochs exist. Resolved FLEET-WIDE and process-global via setSchemeKWritesArmed at the API bootstrap seam \u2014 per-org overrides do NOT apply (the crypto writer carries no request context), despite the DEK itself being per-org. Ships dark; the corpus is empty. NOT REVERSIBLE THE WAY `at-rest-v2-writes` IS, and the difference is the point: clearing that flag returns the writer to v1 and every blob it wrote stays readable under the same app key, whereas clearing THIS one stops new rows but leaves every row already written readable ONLY through the KMS key its inline wrap names (A5 option 2), permanently. Three preconditions for the flip, none of which this flag can check: (1) ENG-10990 \u2014 the re-seal drain never UNWRAPS the survivor it nominates, so DRAIN COMPLETE can be reported over a row whose only path is a kms: ref that does not work; (2) ADR-0062 A9 \u2014 a wrap ref embeds a region and cannot follow a migration. The BINDING check is at the MINT and compares the region in the ARN KMS returns against PRIMARY_APP_REGION; isSecondaryStack() is only its pre-filter (AWS_REGION unset still lets the SDK take a region from the shared profile) and is separately what stops a non-live stack sealing at all. A seal never writes its own region \u2014 it reuses the epoch ref verbatim; (3) an org must have an active dek_epochs row before ANY of its rows can be scheme k, and this flag does not create one. There is no lazy first-write mint (dek-epochs.ts decision 2); the ONE production caller of mintDekEpoch is POST /admin/dek-epochs/:organizationId/mint (ENG-12012), staff-only, one named org per call, and it must be invoked deliberately. So FLIPPING THIS ON BY ITSELF CHANGES NOTHING: every org still seals scheme a until someone mints deliberately. That is the intended rollout for a control whose first row freezes the envelope for the whole corpus: one pilot org, watched. kms:GenerateDataKey is therefore a MINT precondition, not a flip one \u2014 sst.config.ts grants it only where apiSecretsKmsKeyArn is defined (prod and test), so a mint on any other stage fails loudly with AccessDenied, which is the right place to fail. BUT THE GRANT IS NOT THE ONLY PRECONDITION, AND SCHEME K IS PROD-ONLY (Obi Wan 5eda5230451a). This sentence used to stop at the grant, which read as \"prod and test can mint\". Test cannot: deploy-test.yml pins AUGMENTED_APP_REGION=us-east-2, so the test API runs with AWS_REGION=us-east-2, isSecondaryStack() is true there, and BOTH A9 gates refuse \u2014 the arming seam writes scheme a, and mintDekEpoch throws at its pre-filter (and would fail the ARN-region check anyway, since test's stage CMK is itself in us-east-2). So the first scheme-k row ever written will be on PROD, and the one-pilot-org rehearsal above cannot be done on test first. That is a KNOWN LIMITATION, not an oversight: both gates compare against the single PRIMARY_APP_REGION constant, and making them aware of a stage's own home region needs a stage->region source that does not exist at the mint's call site (AUGMENTED_APP_REGION is read only in sst.config.ts at deploy time, and the first mint runs in an operator shell). Do NOT whitelist us-east-2 to make test mint \u2014 that is the pre-cutover region A9 exists to keep out of rows. VERIFIED 2026-11-10 (ENG-11944), replacing the unverified note that stood here: the live key policy on alias/augmented-prod-secrets is the AWS default single statement (account root, kms:*, NO Condition block), so it constrains no EncryptionContext and cannot refuse the per-org one; and the live API role does hold Decrypt + GenerateDataKey on that key, unconditioned. Note what follows: KMS POLICY IS NOT WHAT ISOLATES ONE ORG DEK FROM ANOTHER. AES-GCM AAD is, cryptographically, inside KMS.",
30494
+ description: "ADR-0062 increment C arm (ENG-11944). Gates whether an at-rest sink that has an active dek_epochs row seals under a PER-ORG DEK wrapped by the platform KEK (envelope `s: 'k'`) instead of the app key (`s: 'a'`). OFF (default) = scheme a, i.e. the ADR-0061 behaviour, whatever the sink and whatever epochs exist. Resolved FLEET-WIDE and process-global via setSchemeKWritesArmed at the API bootstrap seam \u2014 per-org overrides do NOT apply (the crypto writer carries no request context), despite the DEK itself being per-org. Ships dark; the corpus is empty. NOT REVERSIBLE THE WAY `at-rest-v2-writes` IS, and the difference is the point: clearing that flag returns the writer to v1 and every blob it wrote stays readable under the same app key, whereas clearing THIS one stops new rows but leaves every row already written readable ONLY through the KMS key its inline wrap names (A5 option 2), permanently. Three preconditions for the flip, none of which this flag can check: (1) ENG-10990 \u2014 the re-seal drain never UNWRAPS the survivor it nominates, so DRAIN COMPLETE can be reported over a row whose only path is a kms: ref that does not work; (2) ADR-0062 A9 \u2014 a wrap ref embeds a region and cannot follow a migration. The BINDING check is at the MINT and compares the region in the ARN KMS returns against PRIMARY_APP_REGION; isSecondaryStack() is only its pre-filter (AWS_REGION unset still lets the SDK take a region from the shared profile) and is separately what stops a non-live stack sealing at all. A seal never writes its own region \u2014 it reuses the epoch ref verbatim; (3) an org must have an active dek_epochs row before ANY of its rows can be scheme k, and this flag does not create one. There is no lazy first-write mint (dek-epochs.ts decision 2); the ONE production caller of mintDekEpoch is POST /admin/dek-epochs/:organizationId/mint (ENG-12012), staff-only, one named org per call, and it must be invoked deliberately. So FLIPPING THIS ON BY ITSELF CHANGES NOTHING: every org still seals scheme a until someone mints deliberately. That is the intended rollout for a control whose first row freezes the envelope for the whole corpus: one pilot org, watched. kms:GenerateDataKey is therefore a MINT precondition, not a flip one \u2014 sst.config.ts grants it only where apiSecretsKmsKeyArn is defined (prod and test), so a mint on any other stage fails loudly with AccessDenied, which is the right place to fail. BUT THE GRANT IS NOT THE ONLY PRECONDITION, AND SCHEME K IS PROD-ONLY (Obi Wan 5eda5230451a). This sentence used to stop at the grant, which read as \"prod and test can mint\". Test cannot \u2014 and as of ENG-11886 the REASON HAS CHANGED, so do not reason from the old one. deploy-test.yml PINNED AUGMENTED_APP_REGION=us-east-2, so the test API RAN with AWS_REGION=us-east-2, isSecondaryStack() WAS true there, and both A9 gates refused \u2014 the arming seam wrote scheme a, and mintDekEpoch threw at its pre-filter. ENG-11886 retired that workflow and its `test` GitHub Environment is gone, so NO workflow deploys a non-prod stage any more: there is no test API to mint from at all, which is now the whole of why test cannot. The region argument is history, not the live mechanism. AND DO NOT INVERT IT INTO \"a hand-rebuilt test stage could mint\": that was NOT measured, and it turns on two things nobody has checked \u2014 which region the operator exports (the resolver defaults to ap-southeast-2 now, which IS PRIMARY_APP_REGION, so the pre-filter would NOT refuse) and where alias/augmented-test-secrets resolves. Measure both before using a rebuilt test stage as the pilot. Either way the first scheme-k row ever written will be on PROD, and the one-pilot-org rehearsal above cannot be done on test first. That is a KNOWN LIMITATION, not an oversight: both gates compare against the single PRIMARY_APP_REGION constant, and making them aware of a stage's own home region needs a stage->region source that does not exist at the mint's call site (AUGMENTED_APP_REGION is read only in sst.config.ts at deploy time, and the first mint runs in an operator shell). Do NOT whitelist us-east-2 to make test mint \u2014 that is the pre-cutover region A9 exists to keep out of rows. VERIFIED 2026-11-10 (ENG-11944), replacing the unverified note that stood here: the live key policy on alias/augmented-prod-secrets is the AWS default single statement (account root, kms:*, NO Condition block), so it constrains no EncryptionContext and cannot refuse the per-org one; and the live API role does hold Decrypt + GenerateDataKey on that key, unconditioned. Note what follows: KMS POLICY IS NOT WHAT ISOLATES ONE ORG DEK FROM ANOTHER. AES-GCM AAD is, cryptographically, inside KMS.",
30440
30495
  flagType: "boolean",
30441
30496
  // Declared safe value is `false` = scheme a. A flag-read error must never arm
30442
30497
  // scheme k on its own: an unintended `a` row is re-sealable, an unintended
@@ -30483,6 +30538,43 @@ var FLAG_REGISTRY = [
30483
30538
  flagType: "boolean",
30484
30539
  defaultValue: false
30485
30540
  },
30541
+ {
30542
+ key: "scratch-sweep-held",
30543
+ description: "ENG-11877: stops ALL scratch sweeping for an agent, including the existing tree rule, for files someone has asked to keep. Resolved per agent by the manager. Sticky on the host: once seen it is written to a marker outside scratch, which keeps the agent held until heartbeats that evaluated it find the flag off for 10 minutes, so a restart or a failed flag read cannot let a sweep through. A host only honours it once its CLI has the reader: check reach before relying on it. Off is the safe default for everyone else.",
30544
+ sensitive: true,
30545
+ flagType: "boolean",
30546
+ defaultValue: false,
30547
+ // No published agt-cli has this reader yet, and a guessed floor would report reach
30548
+ // on hosts that can't act on it. So this reads as "no host yet" on purpose, the
30549
+ // safe direction. ENG-11877 re-pins it from the published dist after merge.
30550
+ since: "0.28.999999"
30551
+ },
30552
+ {
30553
+ key: "scratch-sweep-per-file",
30554
+ description: "ENG-11877: also expire old files inside scratch folders still in use, instead of keeping a whole folder while anything in it is fresh. IRREVERSIBLE on its first pass: every file unchanged for 7 days goes, customer documents included, so arm it per agent and read scratch-sweep-dry-run first. Off = the tree rule only.",
30555
+ sensitive: true,
30556
+ // CodeRabbit on #7378: `sensitive` only forces a confirmation; it does not say
30557
+ // WHO. Its first pass irreversibly deletes old customer files, and arming it is
30558
+ // Brad's rollout decision (ENG-11877), so an org owner/admin must not be able to
30559
+ // switch it on for their own agents. Only the cross-org admin route can write it.
30560
+ platformAdminOnly: true,
30561
+ flagType: "boolean",
30562
+ defaultValue: false,
30563
+ // No published agt-cli has this reader yet, and a guessed floor would report reach
30564
+ // on hosts that can't act on it. So this reads as "no host yet" on purpose, the
30565
+ // safe direction. ENG-11877 re-pins it from the published dist after merge.
30566
+ since: "0.28.999999"
30567
+ },
30568
+ {
30569
+ key: "scratch-sweep-dry-run",
30570
+ description: "ENG-11877: count what scratch-sweep-per-file would remove and log it to manager.log every 6 hours ([scratch] [sweep-dry-run]). Metadata only: never opens a file, never logs a name, removes nothing extra.",
30571
+ flagType: "boolean",
30572
+ defaultValue: false,
30573
+ // No published agt-cli has this reader yet, and a guessed floor would report reach
30574
+ // on hosts that can't act on it. So this reads as "no host yet" on purpose, the
30575
+ // safe direction. ENG-11877 re-pins it from the published dist after merge.
30576
+ since: "0.28.999999"
30577
+ },
30486
30578
  {
30487
30579
  key: "broker-read-jobs",
30488
30580
  description: `Slow broker READ tools finish in a background job (ENG-11476, ADR-0129). When on for an org, an opted-in read tool (Pronto Xi first) that misses an 18s grace window answers "still running, call again with the same arguments" and finishes in the broker-read-job worker instead of timing out. Off = today's synchronous call, so false is the safe value. Evaluated in the API per org, team and agent.`,
@@ -43941,7 +43941,10 @@ var GITHUB_EVENT_RULES = {
43941
43941
  pull_request_review: { actions: ["submitted"] },
43942
43942
  check_suite: { actions: ["completed"] },
43943
43943
  issues: { actions: ["opened", "closed"] },
43944
- issue_comment: { actions: ["created"] }
43944
+ issue_comment: { actions: ["created"] },
43945
+ // ENG-12123 (CS-2564): a deployment's status changed. GitHub sends one
43946
+ // deployment_status event per state change, always with action `created`.
43947
+ deployment_status: { actions: ["created"] }
43945
43948
  };
43946
43949
  var GITHUB_WEBHOOK_EVENTS = Object.keys(GITHUB_EVENT_RULES);
43947
43950
  var REPO_FULL_NAME = /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})\/[A-Za-z0-9._-]{1,100}$/;
@@ -43964,6 +43967,28 @@ var CHECK_CONCLUSIONS = /* @__PURE__ */ new Set([
43964
43967
  "startup_failure"
43965
43968
  ]);
43966
43969
  var ISSUE_STATE_REASONS = /* @__PURE__ */ new Set(["completed", "not_planned", "reopened", "duplicate"]);
43970
+ var DEPLOYMENT_STATES = /* @__PURE__ */ new Set(["success", "failure", "error", "pending", "in_progress", "queued", "inactive"]);
43971
+ var ENVIRONMENT_TOKEN = /^[A-Za-z0-9][A-Za-z0-9._/:-]{0,63}$/;
43972
+ var ACTIONS_RUN_PATH = /^\/([^/]+)\/([^/]+)\/actions\/runs\/([1-9][0-9]{0,18})(?:\/job\/([1-9][0-9]{0,18}))?\/?$/;
43973
+ function githubActionsRunUrl(v, repo) {
43974
+ const s = str(v);
43975
+ if (s === null || s.length > 500)
43976
+ return null;
43977
+ let u;
43978
+ try {
43979
+ u = new URL(s);
43980
+ } catch {
43981
+ return null;
43982
+ }
43983
+ if (u.protocol !== "https:" || u.username || u.password || u.port || u.hostname !== "github.com")
43984
+ return null;
43985
+ const m = ACTIONS_RUN_PATH.exec(u.pathname);
43986
+ if (!m)
43987
+ return null;
43988
+ if (`${m[1]}/${m[2]}`.toLowerCase() !== repo.toLowerCase())
43989
+ return null;
43990
+ return `https://github.com/${repo}/actions/runs/${m[3]}${m[4] ? `/job/${m[4]}` : ""}`;
43991
+ }
43967
43992
  function asDict(v) {
43968
43993
  return v !== null && typeof v === "object" && !Array.isArray(v) ? v : null;
43969
43994
  }
@@ -44109,6 +44134,36 @@ function extractGithubFacts(event, payload) {
44109
44134
  summary: `Issue #${n2} ${action} in ${repo}`
44110
44135
  };
44111
44136
  }
44137
+ if (event === "deployment_status") {
44138
+ const status = asDict(root["deployment_status"]);
44139
+ const deployment = asDict(root["deployment"]);
44140
+ if (!status || !deployment)
44141
+ return null;
44142
+ const state = inSet(status["state"], DEPLOYMENT_STATES);
44143
+ const environment = shaped(status["environment"], ENVIRONMENT_TOKEN) ?? shaped(deployment["environment"], ENVIRONMENT_TOKEN);
44144
+ details.push(["Environment", environment ?? "(name withheld: not a plain token)"]);
44145
+ details.push(["State", state ?? "unknown"]);
44146
+ const deploymentId = posInt(deployment["id"]);
44147
+ if (deploymentId !== null)
44148
+ details.push(["Deployment id", String(deploymentId)]);
44149
+ const sha = shaped(str(deployment["sha"])?.toLowerCase(), SHA);
44150
+ if (sha)
44151
+ details.push(["Commit", sha]);
44152
+ const creator = shaped(asDict(status["creator"])?.["login"], LOGIN);
44153
+ if (creator)
44154
+ details.push(["Status set by", creator]);
44155
+ const link = githubActionsRunUrl(status["log_url"], repo) ?? githubActionsRunUrl(status["target_url"], repo);
44156
+ return {
44157
+ event,
44158
+ action,
44159
+ repo,
44160
+ subject: null,
44161
+ url: link ?? `${base}/deployments`,
44162
+ sender,
44163
+ details,
44164
+ summary: `Deployment to ${environment ?? "an environment"} ${state ?? "updated"} in ${repo}`
44165
+ };
44166
+ }
44112
44167
  const issue2 = asDict(root["issue"]);
44113
44168
  const n = issue2 ? posInt(issue2["number"]) : null;
44114
44169
  if (!issue2 || n === null)
@@ -44238,7 +44293,7 @@ var FLAG_REGISTRY = [
44238
44293
  },
44239
44294
  {
44240
44295
  key: "at-rest-scheme-k-writes",
44241
- description: "ADR-0062 increment C arm (ENG-11944). Gates whether an at-rest sink that has an active dek_epochs row seals under a PER-ORG DEK wrapped by the platform KEK (envelope `s: 'k'`) instead of the app key (`s: 'a'`). OFF (default) = scheme a, i.e. the ADR-0061 behaviour, whatever the sink and whatever epochs exist. Resolved FLEET-WIDE and process-global via setSchemeKWritesArmed at the API bootstrap seam \u2014 per-org overrides do NOT apply (the crypto writer carries no request context), despite the DEK itself being per-org. Ships dark; the corpus is empty. NOT REVERSIBLE THE WAY `at-rest-v2-writes` IS, and the difference is the point: clearing that flag returns the writer to v1 and every blob it wrote stays readable under the same app key, whereas clearing THIS one stops new rows but leaves every row already written readable ONLY through the KMS key its inline wrap names (A5 option 2), permanently. Three preconditions for the flip, none of which this flag can check: (1) ENG-10990 \u2014 the re-seal drain never UNWRAPS the survivor it nominates, so DRAIN COMPLETE can be reported over a row whose only path is a kms: ref that does not work; (2) ADR-0062 A9 \u2014 a wrap ref embeds a region and cannot follow a migration. The BINDING check is at the MINT and compares the region in the ARN KMS returns against PRIMARY_APP_REGION; isSecondaryStack() is only its pre-filter (AWS_REGION unset still lets the SDK take a region from the shared profile) and is separately what stops a non-live stack sealing at all. A seal never writes its own region \u2014 it reuses the epoch ref verbatim; (3) an org must have an active dek_epochs row before ANY of its rows can be scheme k, and this flag does not create one. There is no lazy first-write mint (dek-epochs.ts decision 2); the ONE production caller of mintDekEpoch is POST /admin/dek-epochs/:organizationId/mint (ENG-12012), staff-only, one named org per call, and it must be invoked deliberately. So FLIPPING THIS ON BY ITSELF CHANGES NOTHING: every org still seals scheme a until someone mints deliberately. That is the intended rollout for a control whose first row freezes the envelope for the whole corpus: one pilot org, watched. kms:GenerateDataKey is therefore a MINT precondition, not a flip one \u2014 sst.config.ts grants it only where apiSecretsKmsKeyArn is defined (prod and test), so a mint on any other stage fails loudly with AccessDenied, which is the right place to fail. BUT THE GRANT IS NOT THE ONLY PRECONDITION, AND SCHEME K IS PROD-ONLY (Obi Wan 5eda5230451a). This sentence used to stop at the grant, which read as \"prod and test can mint\". Test cannot: deploy-test.yml pins AUGMENTED_APP_REGION=us-east-2, so the test API runs with AWS_REGION=us-east-2, isSecondaryStack() is true there, and BOTH A9 gates refuse \u2014 the arming seam writes scheme a, and mintDekEpoch throws at its pre-filter (and would fail the ARN-region check anyway, since test's stage CMK is itself in us-east-2). So the first scheme-k row ever written will be on PROD, and the one-pilot-org rehearsal above cannot be done on test first. That is a KNOWN LIMITATION, not an oversight: both gates compare against the single PRIMARY_APP_REGION constant, and making them aware of a stage's own home region needs a stage->region source that does not exist at the mint's call site (AUGMENTED_APP_REGION is read only in sst.config.ts at deploy time, and the first mint runs in an operator shell). Do NOT whitelist us-east-2 to make test mint \u2014 that is the pre-cutover region A9 exists to keep out of rows. VERIFIED 2026-11-10 (ENG-11944), replacing the unverified note that stood here: the live key policy on alias/augmented-prod-secrets is the AWS default single statement (account root, kms:*, NO Condition block), so it constrains no EncryptionContext and cannot refuse the per-org one; and the live API role does hold Decrypt + GenerateDataKey on that key, unconditioned. Note what follows: KMS POLICY IS NOT WHAT ISOLATES ONE ORG DEK FROM ANOTHER. AES-GCM AAD is, cryptographically, inside KMS.",
44296
+ description: "ADR-0062 increment C arm (ENG-11944). Gates whether an at-rest sink that has an active dek_epochs row seals under a PER-ORG DEK wrapped by the platform KEK (envelope `s: 'k'`) instead of the app key (`s: 'a'`). OFF (default) = scheme a, i.e. the ADR-0061 behaviour, whatever the sink and whatever epochs exist. Resolved FLEET-WIDE and process-global via setSchemeKWritesArmed at the API bootstrap seam \u2014 per-org overrides do NOT apply (the crypto writer carries no request context), despite the DEK itself being per-org. Ships dark; the corpus is empty. NOT REVERSIBLE THE WAY `at-rest-v2-writes` IS, and the difference is the point: clearing that flag returns the writer to v1 and every blob it wrote stays readable under the same app key, whereas clearing THIS one stops new rows but leaves every row already written readable ONLY through the KMS key its inline wrap names (A5 option 2), permanently. Three preconditions for the flip, none of which this flag can check: (1) ENG-10990 \u2014 the re-seal drain never UNWRAPS the survivor it nominates, so DRAIN COMPLETE can be reported over a row whose only path is a kms: ref that does not work; (2) ADR-0062 A9 \u2014 a wrap ref embeds a region and cannot follow a migration. The BINDING check is at the MINT and compares the region in the ARN KMS returns against PRIMARY_APP_REGION; isSecondaryStack() is only its pre-filter (AWS_REGION unset still lets the SDK take a region from the shared profile) and is separately what stops a non-live stack sealing at all. A seal never writes its own region \u2014 it reuses the epoch ref verbatim; (3) an org must have an active dek_epochs row before ANY of its rows can be scheme k, and this flag does not create one. There is no lazy first-write mint (dek-epochs.ts decision 2); the ONE production caller of mintDekEpoch is POST /admin/dek-epochs/:organizationId/mint (ENG-12012), staff-only, one named org per call, and it must be invoked deliberately. So FLIPPING THIS ON BY ITSELF CHANGES NOTHING: every org still seals scheme a until someone mints deliberately. That is the intended rollout for a control whose first row freezes the envelope for the whole corpus: one pilot org, watched. kms:GenerateDataKey is therefore a MINT precondition, not a flip one \u2014 sst.config.ts grants it only where apiSecretsKmsKeyArn is defined (prod and test), so a mint on any other stage fails loudly with AccessDenied, which is the right place to fail. BUT THE GRANT IS NOT THE ONLY PRECONDITION, AND SCHEME K IS PROD-ONLY (Obi Wan 5eda5230451a). This sentence used to stop at the grant, which read as \"prod and test can mint\". Test cannot \u2014 and as of ENG-11886 the REASON HAS CHANGED, so do not reason from the old one. deploy-test.yml PINNED AUGMENTED_APP_REGION=us-east-2, so the test API RAN with AWS_REGION=us-east-2, isSecondaryStack() WAS true there, and both A9 gates refused \u2014 the arming seam wrote scheme a, and mintDekEpoch threw at its pre-filter. ENG-11886 retired that workflow and its `test` GitHub Environment is gone, so NO workflow deploys a non-prod stage any more: there is no test API to mint from at all, which is now the whole of why test cannot. The region argument is history, not the live mechanism. AND DO NOT INVERT IT INTO \"a hand-rebuilt test stage could mint\": that was NOT measured, and it turns on two things nobody has checked \u2014 which region the operator exports (the resolver defaults to ap-southeast-2 now, which IS PRIMARY_APP_REGION, so the pre-filter would NOT refuse) and where alias/augmented-test-secrets resolves. Measure both before using a rebuilt test stage as the pilot. Either way the first scheme-k row ever written will be on PROD, and the one-pilot-org rehearsal above cannot be done on test first. That is a KNOWN LIMITATION, not an oversight: both gates compare against the single PRIMARY_APP_REGION constant, and making them aware of a stage's own home region needs a stage->region source that does not exist at the mint's call site (AUGMENTED_APP_REGION is read only in sst.config.ts at deploy time, and the first mint runs in an operator shell). Do NOT whitelist us-east-2 to make test mint \u2014 that is the pre-cutover region A9 exists to keep out of rows. VERIFIED 2026-11-10 (ENG-11944), replacing the unverified note that stood here: the live key policy on alias/augmented-prod-secrets is the AWS default single statement (account root, kms:*, NO Condition block), so it constrains no EncryptionContext and cannot refuse the per-org one; and the live API role does hold Decrypt + GenerateDataKey on that key, unconditioned. Note what follows: KMS POLICY IS NOT WHAT ISOLATES ONE ORG DEK FROM ANOTHER. AES-GCM AAD is, cryptographically, inside KMS.",
44242
44297
  flagType: "boolean",
44243
44298
  // Declared safe value is `false` = scheme a. A flag-read error must never arm
44244
44299
  // scheme k on its own: an unintended `a` row is re-sealable, an unintended
@@ -44285,6 +44340,43 @@ var FLAG_REGISTRY = [
44285
44340
  flagType: "boolean",
44286
44341
  defaultValue: false
44287
44342
  },
44343
+ {
44344
+ key: "scratch-sweep-held",
44345
+ description: "ENG-11877: stops ALL scratch sweeping for an agent, including the existing tree rule, for files someone has asked to keep. Resolved per agent by the manager. Sticky on the host: once seen it is written to a marker outside scratch, which keeps the agent held until heartbeats that evaluated it find the flag off for 10 minutes, so a restart or a failed flag read cannot let a sweep through. A host only honours it once its CLI has the reader: check reach before relying on it. Off is the safe default for everyone else.",
44346
+ sensitive: true,
44347
+ flagType: "boolean",
44348
+ defaultValue: false,
44349
+ // No published agt-cli has this reader yet, and a guessed floor would report reach
44350
+ // on hosts that can't act on it. So this reads as "no host yet" on purpose, the
44351
+ // safe direction. ENG-11877 re-pins it from the published dist after merge.
44352
+ since: "0.28.999999"
44353
+ },
44354
+ {
44355
+ key: "scratch-sweep-per-file",
44356
+ description: "ENG-11877: also expire old files inside scratch folders still in use, instead of keeping a whole folder while anything in it is fresh. IRREVERSIBLE on its first pass: every file unchanged for 7 days goes, customer documents included, so arm it per agent and read scratch-sweep-dry-run first. Off = the tree rule only.",
44357
+ sensitive: true,
44358
+ // CodeRabbit on #7378: `sensitive` only forces a confirmation; it does not say
44359
+ // WHO. Its first pass irreversibly deletes old customer files, and arming it is
44360
+ // Brad's rollout decision (ENG-11877), so an org owner/admin must not be able to
44361
+ // switch it on for their own agents. Only the cross-org admin route can write it.
44362
+ platformAdminOnly: true,
44363
+ flagType: "boolean",
44364
+ defaultValue: false,
44365
+ // No published agt-cli has this reader yet, and a guessed floor would report reach
44366
+ // on hosts that can't act on it. So this reads as "no host yet" on purpose, the
44367
+ // safe direction. ENG-11877 re-pins it from the published dist after merge.
44368
+ since: "0.28.999999"
44369
+ },
44370
+ {
44371
+ key: "scratch-sweep-dry-run",
44372
+ description: "ENG-11877: count what scratch-sweep-per-file would remove and log it to manager.log every 6 hours ([scratch] [sweep-dry-run]). Metadata only: never opens a file, never logs a name, removes nothing extra.",
44373
+ flagType: "boolean",
44374
+ defaultValue: false,
44375
+ // No published agt-cli has this reader yet, and a guessed floor would report reach
44376
+ // on hosts that can't act on it. So this reads as "no host yet" on purpose, the
44377
+ // safe direction. ENG-11877 re-pins it from the published dist after merge.
44378
+ since: "0.28.999999"
44379
+ },
44288
44380
  {
44289
44381
  key: "broker-read-jobs",
44290
44382
  description: `Slow broker READ tools finish in a background job (ENG-11476, ADR-0129). When on for an org, an opted-in read tool (Pronto Xi first) that misses an 18s grace window answers "still running, call again with the same arguments" and finishes in the broker-read-job worker instead of timing out. Off = today's synchronous call, so false is the safe value. Evaluated in the API per org, team and agent.`,
@@ -38796,7 +38796,10 @@ var GITHUB_EVENT_RULES = {
38796
38796
  pull_request_review: { actions: ["submitted"] },
38797
38797
  check_suite: { actions: ["completed"] },
38798
38798
  issues: { actions: ["opened", "closed"] },
38799
- issue_comment: { actions: ["created"] }
38799
+ issue_comment: { actions: ["created"] },
38800
+ // ENG-12123 (CS-2564): a deployment's status changed. GitHub sends one
38801
+ // deployment_status event per state change, always with action `created`.
38802
+ deployment_status: { actions: ["created"] }
38800
38803
  };
38801
38804
  var GITHUB_WEBHOOK_EVENTS = Object.keys(GITHUB_EVENT_RULES);
38802
38805
  var REPO_FULL_NAME = /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})\/[A-Za-z0-9._-]{1,100}$/;
@@ -38819,6 +38822,28 @@ var CHECK_CONCLUSIONS = /* @__PURE__ */ new Set([
38819
38822
  "startup_failure"
38820
38823
  ]);
38821
38824
  var ISSUE_STATE_REASONS = /* @__PURE__ */ new Set(["completed", "not_planned", "reopened", "duplicate"]);
38825
+ var DEPLOYMENT_STATES = /* @__PURE__ */ new Set(["success", "failure", "error", "pending", "in_progress", "queued", "inactive"]);
38826
+ var ENVIRONMENT_TOKEN = /^[A-Za-z0-9][A-Za-z0-9._/:-]{0,63}$/;
38827
+ var ACTIONS_RUN_PATH = /^\/([^/]+)\/([^/]+)\/actions\/runs\/([1-9][0-9]{0,18})(?:\/job\/([1-9][0-9]{0,18}))?\/?$/;
38828
+ function githubActionsRunUrl(v, repo) {
38829
+ const s = str(v);
38830
+ if (s === null || s.length > 500)
38831
+ return null;
38832
+ let u;
38833
+ try {
38834
+ u = new URL(s);
38835
+ } catch {
38836
+ return null;
38837
+ }
38838
+ if (u.protocol !== "https:" || u.username || u.password || u.port || u.hostname !== "github.com")
38839
+ return null;
38840
+ const m = ACTIONS_RUN_PATH.exec(u.pathname);
38841
+ if (!m)
38842
+ return null;
38843
+ if (`${m[1]}/${m[2]}`.toLowerCase() !== repo.toLowerCase())
38844
+ return null;
38845
+ return `https://github.com/${repo}/actions/runs/${m[3]}${m[4] ? `/job/${m[4]}` : ""}`;
38846
+ }
38822
38847
  function asDict(v) {
38823
38848
  return v !== null && typeof v === "object" && !Array.isArray(v) ? v : null;
38824
38849
  }
@@ -38964,6 +38989,36 @@ function extractGithubFacts(event, payload) {
38964
38989
  summary: `Issue #${n2} ${action} in ${repo}`
38965
38990
  };
38966
38991
  }
38992
+ if (event === "deployment_status") {
38993
+ const status = asDict(root["deployment_status"]);
38994
+ const deployment = asDict(root["deployment"]);
38995
+ if (!status || !deployment)
38996
+ return null;
38997
+ const state = inSet(status["state"], DEPLOYMENT_STATES);
38998
+ const environment = shaped(status["environment"], ENVIRONMENT_TOKEN) ?? shaped(deployment["environment"], ENVIRONMENT_TOKEN);
38999
+ details.push(["Environment", environment ?? "(name withheld: not a plain token)"]);
39000
+ details.push(["State", state ?? "unknown"]);
39001
+ const deploymentId = posInt(deployment["id"]);
39002
+ if (deploymentId !== null)
39003
+ details.push(["Deployment id", String(deploymentId)]);
39004
+ const sha = shaped(str(deployment["sha"])?.toLowerCase(), SHA);
39005
+ if (sha)
39006
+ details.push(["Commit", sha]);
39007
+ const creator = shaped(asDict(status["creator"])?.["login"], LOGIN);
39008
+ if (creator)
39009
+ details.push(["Status set by", creator]);
39010
+ const link = githubActionsRunUrl(status["log_url"], repo) ?? githubActionsRunUrl(status["target_url"], repo);
39011
+ return {
39012
+ event,
39013
+ action,
39014
+ repo,
39015
+ subject: null,
39016
+ url: link ?? `${base}/deployments`,
39017
+ sender,
39018
+ details,
39019
+ summary: `Deployment to ${environment ?? "an environment"} ${state ?? "updated"} in ${repo}`
39020
+ };
39021
+ }
38967
39022
  const issue2 = asDict(root["issue"]);
38968
39023
  const n = issue2 ? posInt(issue2["number"]) : null;
38969
39024
  if (!issue2 || n === null)
@@ -39093,7 +39148,7 @@ var FLAG_REGISTRY = [
39093
39148
  },
39094
39149
  {
39095
39150
  key: "at-rest-scheme-k-writes",
39096
- description: "ADR-0062 increment C arm (ENG-11944). Gates whether an at-rest sink that has an active dek_epochs row seals under a PER-ORG DEK wrapped by the platform KEK (envelope `s: 'k'`) instead of the app key (`s: 'a'`). OFF (default) = scheme a, i.e. the ADR-0061 behaviour, whatever the sink and whatever epochs exist. Resolved FLEET-WIDE and process-global via setSchemeKWritesArmed at the API bootstrap seam \u2014 per-org overrides do NOT apply (the crypto writer carries no request context), despite the DEK itself being per-org. Ships dark; the corpus is empty. NOT REVERSIBLE THE WAY `at-rest-v2-writes` IS, and the difference is the point: clearing that flag returns the writer to v1 and every blob it wrote stays readable under the same app key, whereas clearing THIS one stops new rows but leaves every row already written readable ONLY through the KMS key its inline wrap names (A5 option 2), permanently. Three preconditions for the flip, none of which this flag can check: (1) ENG-10990 \u2014 the re-seal drain never UNWRAPS the survivor it nominates, so DRAIN COMPLETE can be reported over a row whose only path is a kms: ref that does not work; (2) ADR-0062 A9 \u2014 a wrap ref embeds a region and cannot follow a migration. The BINDING check is at the MINT and compares the region in the ARN KMS returns against PRIMARY_APP_REGION; isSecondaryStack() is only its pre-filter (AWS_REGION unset still lets the SDK take a region from the shared profile) and is separately what stops a non-live stack sealing at all. A seal never writes its own region \u2014 it reuses the epoch ref verbatim; (3) an org must have an active dek_epochs row before ANY of its rows can be scheme k, and this flag does not create one. There is no lazy first-write mint (dek-epochs.ts decision 2); the ONE production caller of mintDekEpoch is POST /admin/dek-epochs/:organizationId/mint (ENG-12012), staff-only, one named org per call, and it must be invoked deliberately. So FLIPPING THIS ON BY ITSELF CHANGES NOTHING: every org still seals scheme a until someone mints deliberately. That is the intended rollout for a control whose first row freezes the envelope for the whole corpus: one pilot org, watched. kms:GenerateDataKey is therefore a MINT precondition, not a flip one \u2014 sst.config.ts grants it only where apiSecretsKmsKeyArn is defined (prod and test), so a mint on any other stage fails loudly with AccessDenied, which is the right place to fail. BUT THE GRANT IS NOT THE ONLY PRECONDITION, AND SCHEME K IS PROD-ONLY (Obi Wan 5eda5230451a). This sentence used to stop at the grant, which read as \"prod and test can mint\". Test cannot: deploy-test.yml pins AUGMENTED_APP_REGION=us-east-2, so the test API runs with AWS_REGION=us-east-2, isSecondaryStack() is true there, and BOTH A9 gates refuse \u2014 the arming seam writes scheme a, and mintDekEpoch throws at its pre-filter (and would fail the ARN-region check anyway, since test's stage CMK is itself in us-east-2). So the first scheme-k row ever written will be on PROD, and the one-pilot-org rehearsal above cannot be done on test first. That is a KNOWN LIMITATION, not an oversight: both gates compare against the single PRIMARY_APP_REGION constant, and making them aware of a stage's own home region needs a stage->region source that does not exist at the mint's call site (AUGMENTED_APP_REGION is read only in sst.config.ts at deploy time, and the first mint runs in an operator shell). Do NOT whitelist us-east-2 to make test mint \u2014 that is the pre-cutover region A9 exists to keep out of rows. VERIFIED 2026-11-10 (ENG-11944), replacing the unverified note that stood here: the live key policy on alias/augmented-prod-secrets is the AWS default single statement (account root, kms:*, NO Condition block), so it constrains no EncryptionContext and cannot refuse the per-org one; and the live API role does hold Decrypt + GenerateDataKey on that key, unconditioned. Note what follows: KMS POLICY IS NOT WHAT ISOLATES ONE ORG DEK FROM ANOTHER. AES-GCM AAD is, cryptographically, inside KMS.",
39151
+ description: "ADR-0062 increment C arm (ENG-11944). Gates whether an at-rest sink that has an active dek_epochs row seals under a PER-ORG DEK wrapped by the platform KEK (envelope `s: 'k'`) instead of the app key (`s: 'a'`). OFF (default) = scheme a, i.e. the ADR-0061 behaviour, whatever the sink and whatever epochs exist. Resolved FLEET-WIDE and process-global via setSchemeKWritesArmed at the API bootstrap seam \u2014 per-org overrides do NOT apply (the crypto writer carries no request context), despite the DEK itself being per-org. Ships dark; the corpus is empty. NOT REVERSIBLE THE WAY `at-rest-v2-writes` IS, and the difference is the point: clearing that flag returns the writer to v1 and every blob it wrote stays readable under the same app key, whereas clearing THIS one stops new rows but leaves every row already written readable ONLY through the KMS key its inline wrap names (A5 option 2), permanently. Three preconditions for the flip, none of which this flag can check: (1) ENG-10990 \u2014 the re-seal drain never UNWRAPS the survivor it nominates, so DRAIN COMPLETE can be reported over a row whose only path is a kms: ref that does not work; (2) ADR-0062 A9 \u2014 a wrap ref embeds a region and cannot follow a migration. The BINDING check is at the MINT and compares the region in the ARN KMS returns against PRIMARY_APP_REGION; isSecondaryStack() is only its pre-filter (AWS_REGION unset still lets the SDK take a region from the shared profile) and is separately what stops a non-live stack sealing at all. A seal never writes its own region \u2014 it reuses the epoch ref verbatim; (3) an org must have an active dek_epochs row before ANY of its rows can be scheme k, and this flag does not create one. There is no lazy first-write mint (dek-epochs.ts decision 2); the ONE production caller of mintDekEpoch is POST /admin/dek-epochs/:organizationId/mint (ENG-12012), staff-only, one named org per call, and it must be invoked deliberately. So FLIPPING THIS ON BY ITSELF CHANGES NOTHING: every org still seals scheme a until someone mints deliberately. That is the intended rollout for a control whose first row freezes the envelope for the whole corpus: one pilot org, watched. kms:GenerateDataKey is therefore a MINT precondition, not a flip one \u2014 sst.config.ts grants it only where apiSecretsKmsKeyArn is defined (prod and test), so a mint on any other stage fails loudly with AccessDenied, which is the right place to fail. BUT THE GRANT IS NOT THE ONLY PRECONDITION, AND SCHEME K IS PROD-ONLY (Obi Wan 5eda5230451a). This sentence used to stop at the grant, which read as \"prod and test can mint\". Test cannot \u2014 and as of ENG-11886 the REASON HAS CHANGED, so do not reason from the old one. deploy-test.yml PINNED AUGMENTED_APP_REGION=us-east-2, so the test API RAN with AWS_REGION=us-east-2, isSecondaryStack() WAS true there, and both A9 gates refused \u2014 the arming seam wrote scheme a, and mintDekEpoch threw at its pre-filter. ENG-11886 retired that workflow and its `test` GitHub Environment is gone, so NO workflow deploys a non-prod stage any more: there is no test API to mint from at all, which is now the whole of why test cannot. The region argument is history, not the live mechanism. AND DO NOT INVERT IT INTO \"a hand-rebuilt test stage could mint\": that was NOT measured, and it turns on two things nobody has checked \u2014 which region the operator exports (the resolver defaults to ap-southeast-2 now, which IS PRIMARY_APP_REGION, so the pre-filter would NOT refuse) and where alias/augmented-test-secrets resolves. Measure both before using a rebuilt test stage as the pilot. Either way the first scheme-k row ever written will be on PROD, and the one-pilot-org rehearsal above cannot be done on test first. That is a KNOWN LIMITATION, not an oversight: both gates compare against the single PRIMARY_APP_REGION constant, and making them aware of a stage's own home region needs a stage->region source that does not exist at the mint's call site (AUGMENTED_APP_REGION is read only in sst.config.ts at deploy time, and the first mint runs in an operator shell). Do NOT whitelist us-east-2 to make test mint \u2014 that is the pre-cutover region A9 exists to keep out of rows. VERIFIED 2026-11-10 (ENG-11944), replacing the unverified note that stood here: the live key policy on alias/augmented-prod-secrets is the AWS default single statement (account root, kms:*, NO Condition block), so it constrains no EncryptionContext and cannot refuse the per-org one; and the live API role does hold Decrypt + GenerateDataKey on that key, unconditioned. Note what follows: KMS POLICY IS NOT WHAT ISOLATES ONE ORG DEK FROM ANOTHER. AES-GCM AAD is, cryptographically, inside KMS.",
39097
39152
  flagType: "boolean",
39098
39153
  // Declared safe value is `false` = scheme a. A flag-read error must never arm
39099
39154
  // scheme k on its own: an unintended `a` row is re-sealable, an unintended
@@ -39140,6 +39195,43 @@ var FLAG_REGISTRY = [
39140
39195
  flagType: "boolean",
39141
39196
  defaultValue: false
39142
39197
  },
39198
+ {
39199
+ key: "scratch-sweep-held",
39200
+ description: "ENG-11877: stops ALL scratch sweeping for an agent, including the existing tree rule, for files someone has asked to keep. Resolved per agent by the manager. Sticky on the host: once seen it is written to a marker outside scratch, which keeps the agent held until heartbeats that evaluated it find the flag off for 10 minutes, so a restart or a failed flag read cannot let a sweep through. A host only honours it once its CLI has the reader: check reach before relying on it. Off is the safe default for everyone else.",
39201
+ sensitive: true,
39202
+ flagType: "boolean",
39203
+ defaultValue: false,
39204
+ // No published agt-cli has this reader yet, and a guessed floor would report reach
39205
+ // on hosts that can't act on it. So this reads as "no host yet" on purpose, the
39206
+ // safe direction. ENG-11877 re-pins it from the published dist after merge.
39207
+ since: "0.28.999999"
39208
+ },
39209
+ {
39210
+ key: "scratch-sweep-per-file",
39211
+ description: "ENG-11877: also expire old files inside scratch folders still in use, instead of keeping a whole folder while anything in it is fresh. IRREVERSIBLE on its first pass: every file unchanged for 7 days goes, customer documents included, so arm it per agent and read scratch-sweep-dry-run first. Off = the tree rule only.",
39212
+ sensitive: true,
39213
+ // CodeRabbit on #7378: `sensitive` only forces a confirmation; it does not say
39214
+ // WHO. Its first pass irreversibly deletes old customer files, and arming it is
39215
+ // Brad's rollout decision (ENG-11877), so an org owner/admin must not be able to
39216
+ // switch it on for their own agents. Only the cross-org admin route can write it.
39217
+ platformAdminOnly: true,
39218
+ flagType: "boolean",
39219
+ defaultValue: false,
39220
+ // No published agt-cli has this reader yet, and a guessed floor would report reach
39221
+ // on hosts that can't act on it. So this reads as "no host yet" on purpose, the
39222
+ // safe direction. ENG-11877 re-pins it from the published dist after merge.
39223
+ since: "0.28.999999"
39224
+ },
39225
+ {
39226
+ key: "scratch-sweep-dry-run",
39227
+ description: "ENG-11877: count what scratch-sweep-per-file would remove and log it to manager.log every 6 hours ([scratch] [sweep-dry-run]). Metadata only: never opens a file, never logs a name, removes nothing extra.",
39228
+ flagType: "boolean",
39229
+ defaultValue: false,
39230
+ // No published agt-cli has this reader yet, and a guessed floor would report reach
39231
+ // on hosts that can't act on it. So this reads as "no host yet" on purpose, the
39232
+ // safe direction. ENG-11877 re-pins it from the published dist after merge.
39233
+ since: "0.28.999999"
39234
+ },
39143
39235
  {
39144
39236
  key: "broker-read-jobs",
39145
39237
  description: `Slow broker READ tools finish in a background job (ENG-11476, ADR-0129). When on for an org, an opted-in read tool (Pronto Xi first) that misses an 18s grace window answers "still running, call again with the same arguments" and finishes in the broker-read-job worker instead of timing out. Off = today's synchronous call, so false is the safe value. Evaluated in the API per org, team and agent.`,