@defrex/autobuild 1.5.0 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/README.md +1 -1
  2. package/SPEC.md +192 -24
  3. package/docs/agent-runtimes.md +1 -1
  4. package/docs/answering-blocked-builds.md +7 -4
  5. package/docs/architecture.md +100 -32
  6. package/docs/configuration-overview.md +10 -0
  7. package/docs/configuration.md +340 -10
  8. package/docs/dispatcher.md +2 -2
  9. package/docs/forges.md +1 -0
  10. package/docs/glossary.md +1 -1
  11. package/docs/operating.md +1 -1
  12. package/docs/operator-api.md +33 -10
  13. package/docs/operator-surfaces.md +6 -3
  14. package/docs/plugin-authoring.md +48 -6
  15. package/docs/remote-store-protocol.md +33 -10
  16. package/docs/restacking.md +16 -7
  17. package/docs/ticket-sources.md +34 -6
  18. package/docs/tickets.md +7 -1
  19. package/docs/troubleshooting.md +1 -1
  20. package/docs/workspaces.md +1 -1
  21. package/package.json +3 -3
  22. package/packages/core/src/cli/attention.ts +3 -0
  23. package/packages/core/src/cli/binary-direct.ts +1 -0
  24. package/packages/core/src/cli/dashboard/model.ts +14 -4
  25. package/packages/core/src/cli/dashboard/poll.ts +14 -0
  26. package/packages/core/src/cli/dashboard/render.ts +3 -0
  27. package/packages/core/src/cli/dispatch-frontend.ts +10 -14
  28. package/packages/core/src/cli/dispatch-preflight.ts +5 -1
  29. package/packages/core/src/cli/dispatch-repository-feed.ts +145 -109
  30. package/packages/core/src/cli/dispatch-tickets.ts +47 -0
  31. package/packages/core/src/cli/dispatch-upgrade-controller.ts +3 -0
  32. package/packages/core/src/cli/dispatch.ts +377 -101
  33. package/packages/core/src/cli/help.ts +15 -6
  34. package/packages/core/src/cli/init-validation.ts +14 -1
  35. package/packages/core/src/cli/repo-lease.ts +225 -0
  36. package/packages/core/src/cli/repository-status.ts +40 -3
  37. package/packages/core/src/cli/status.ts +21 -13
  38. package/packages/core/src/cli/ticket.ts +22 -4
  39. package/packages/core/src/cli/wait.ts +4 -1
  40. package/packages/core/src/cli/watch.ts +17 -4
  41. package/packages/core/src/config/live.ts +4 -0
  42. package/packages/core/src/config/profiles.ts +96 -0
  43. package/packages/core/src/config/ready-assignee.ts +43 -11
  44. package/packages/core/src/config/roles.ts +33 -10
  45. package/packages/core/src/config/schema.ts +204 -26
  46. package/packages/core/src/events/catalog.ts +2 -0
  47. package/packages/core/src/events/compatibility.ts +3 -1
  48. package/packages/core/src/events/forge-degradation-policy.ts +16 -2
  49. package/packages/core/src/events/payloads.ts +23 -0
  50. package/packages/core/src/events/policy.ts +3 -0
  51. package/packages/core/src/events/repository.ts +19 -0
  52. package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +267 -352
  53. package/packages/core/src/kernel/build-creation.ts +29 -0
  54. package/packages/core/src/kernel/dispatch-capacity.ts +134 -30
  55. package/packages/core/src/kernel/engine.ts +13 -6
  56. package/packages/core/src/kernel/forge-health.ts +47 -0
  57. package/packages/core/src/kernel/generators/build-log.ts +9 -0
  58. package/packages/core/src/kernel/guarded-forge.ts +76 -18
  59. package/packages/core/src/kernel/incremental-fixtures.ts +1 -0
  60. package/packages/core/src/kernel/janitor-failure.ts +85 -5
  61. package/packages/core/src/kernel/leaf-restack-state.ts +4 -2
  62. package/packages/core/src/kernel/log-index.ts +1 -1
  63. package/packages/core/src/kernel/node-landing.ts +2 -1
  64. package/packages/core/src/kernel/node-parent.ts +2 -0
  65. package/packages/core/src/kernel/read-facts.ts +9 -1
  66. package/packages/core/src/kernel/reducer-registry.ts +6 -1
  67. package/packages/core/src/kernel/reducer.ts +75 -4
  68. package/packages/core/src/kernel/ticket-preparation.ts +15 -8
  69. package/packages/core/src/operator/protocol.ts +10 -0
  70. package/packages/core/src/operator/query.ts +16 -13
  71. package/packages/core/src/operator/registry.ts +25 -5
  72. package/packages/core/src/operator/sandbox-host.ts +3 -0
  73. package/packages/core/src/operator/tickets.ts +15 -3
  74. package/packages/core/src/plugin-sdk/index.ts +4 -0
  75. package/packages/core/src/ports/forge/create.ts +6 -0
  76. package/packages/core/src/ports/forge/github-transport.ts +40 -3
  77. package/packages/core/src/ports/forge/github.ts +12 -1
  78. package/packages/core/src/ports/forge/workspace-ancestry.ts +60 -0
  79. package/packages/core/src/ports/forge-failure.ts +31 -2
  80. package/packages/core/src/ports/runner/routing.ts +66 -5
  81. package/packages/core/src/ports/tickets/assignees.ts +54 -0
  82. package/packages/core/src/ports/tickets/contract.ts +164 -4
  83. package/packages/core/src/ports/tickets/create.ts +35 -7
  84. package/packages/core/src/ports/tickets/github-fake.ts +18 -2
  85. package/packages/core/src/ports/tickets/github.ts +247 -29
  86. package/packages/core/src/ports/tickets/hosted-index.ts +1 -0
  87. package/packages/core/src/ports/tickets/operations.ts +6 -1
  88. package/packages/core/src/ports/tickets/tree.ts +12 -2
  89. package/packages/core/src/ports/tickets/update.ts +6 -2
  90. package/packages/core/src/ports/types.ts +37 -3
  91. package/packages/core/src/ports/workspace/commit-preservation.ts +28 -12
  92. package/packages/core/src/ports/workspace/git-worktree.ts +3 -1
  93. package/packages/core/src/ports/workspace/harvest-execution.ts +4 -2
  94. package/packages/core/src/ports/workspace/vercel-sandbox.ts +12 -0
  95. package/packages/core/src/processes/build-child.ts +28 -7
  96. package/packages/core/src/processes/build-execution-state.ts +4 -1
  97. package/packages/core/src/processes/build-runner.ts +17 -2
  98. package/packages/core/src/processes/dispatcher.ts +329 -59
  99. package/packages/core/src/processes/execution-no-progress.ts +2 -0
  100. package/packages/core/src/processes/harvest-child.ts +8 -2
  101. package/packages/core/src/processes/harvest-execution-state.ts +104 -0
  102. package/packages/core/src/processes/harvest-runner.ts +251 -17
  103. package/packages/core/src/processes/repo-view.ts +2 -0
  104. package/packages/core/src/scenarios/harness.ts +160 -36
  105. package/packages/core/src/store/reduced-reads.ts +10 -0
  106. package/packages/core/src/store/reducer-value-shapes.json +3339 -2898
  107. package/packages/core/src/store/remote/client.ts +21 -8
  108. package/packages/core/src/store/remote/index.ts +4 -0
  109. package/packages/core/src/store/remote/protocol.ts +7 -0
  110. package/packages/core/src/store/remote/released-clients.json +22 -0
  111. package/packages/core/src/store/remote/released-reducer-values/1.6.0.json +27173 -0
  112. package/packages/core/src/store/remote/released-reducer-values/1.7.0.json +27366 -0
  113. package/packages/core/src/store/remote/released-reducer-values/index.ts +4 -0
  114. package/packages/core/src/store/repo-state-events.ts +1 -0
  115. package/packages/core/src/store/types.ts +11 -0
  116. package/packages/core/src/testing/dispatch-read-budget.ts +84 -58
  117. package/packages/core/src/testing/index.ts +2 -0
  118. package/packages/core/src/testing/reduced-read-budget.ts +411 -11
  119. package/skills/guide/SKILL.md +166 -35
  120. package/skills/guide/references/operator-api.md +33 -10
  121. package/skills/guide/references/plugin-authoring.md +48 -6
  122. package/skills/guide/references/remote-store-protocol.md +33 -10
  123. package/skills/guide/references/restacking.md +16 -7
  124. package/skills/operate/SKILL.md +79 -14
  125. package/skills/tickets/SKILL.md +22 -4
  126. package/templates/hosted-service/package.json +2 -2
@@ -1,4 +1,5 @@
1
1
  import {
2
+ assertCreateAssigneeAccepted,
2
3
  assertReadyAssigneeAccepted,
3
4
  prepareReadyAssigneeForDispatch,
4
5
  } from '../config/ready-assignee'
@@ -168,6 +169,7 @@ import { GitHubForge } from '../ports/forge/github'
168
169
  import { createProductionRuntimes } from '../ports/runner/production'
169
170
  import type { RuntimeRegistry } from '../ports/runner/runtime'
170
171
  import { createTicketSource } from '../ports/tickets/create'
172
+ import { dispatcherTicketSource } from './dispatch-tickets'
171
173
  import type {
172
174
  Forge,
173
175
  TicketSource,
@@ -236,6 +238,14 @@ import {
236
238
  } from '../store/types'
237
239
  import { availableRelease } from './self-update'
238
240
  import { TriageCountSampler, triageReader } from './triage-count-sampler'
241
+ import {
242
+ fenceEffects,
243
+ fenceExec,
244
+ fenceForge,
245
+ isRepositoryAuthorityLapse,
246
+ RepositoryAuthorityLapsed,
247
+ resolveLapsedRepoLease,
248
+ } from './repo-lease'
239
249
  import {
240
250
  startUpgradeNotice,
241
251
  type AvailableReleaseProbe,
@@ -245,11 +255,13 @@ import {
245
255
  /** Watch-loop default cadence between ticks (§3.3 re-run safety makes this a
246
256
  * pure knob — a shorter interval only polls the forge more often). */
247
257
  const DEFAULT_INTERVAL_MS = 10_000
248
- /** Repository supervisor lease (§12 serialization): TTL and heartbeat cadence.
249
- * The heartbeat renews at a third of the TTL, so one lost beat still leaves a
250
- * full interval of margin before a peer can take over. */
251
- const REPO_LEASE_TTL_MS = 60_000
252
- const REPO_LEASE_HEARTBEAT_MS = 20_000
258
+ /** Repository supervisor lease (§12 serialization) timing, as stored by the
259
+ * claim that set it: `[policy].dispatchLeaseTimeoutSeconds` and
260
+ * `dispatchLeaseRenewalSeconds`. */
261
+ interface RepoLeaseTiming {
262
+ ttlMs: number
263
+ renewalMs: number
264
+ }
253
265
  /** Repository artifact containing the schema-validated composed Config used by
254
266
  * one dispatch run. It is the frontend's only config source. Defined in
255
267
  * `store/retention.ts` beside the other kind constants and re-exported here
@@ -584,15 +596,16 @@ async function defaultWire(
584
596
  : {}
585
597
  const opened = openStoreForRepoState(state, { env: opts.env })
586
598
 
587
- const tickets = await createTicketSource(
599
+ const tickets = await dispatcherTicketSource(
588
600
  config.tickets,
589
- opts.env,
590
- state.repo,
601
+ opts,
602
+ state,
591
603
  opened.localStateRoot,
592
604
  plugins,
593
605
  )
594
- // Once, before the loop: whatever a readyAssignee value needs is resolved
595
- // here so neither a tick nor a reload ever spends a request on it.
606
+ // Once, before the loop: whatever a readyAssignee or createAssignee value
607
+ // needs is resolved here so neither a tick nor a reload ever spends a
608
+ // request on it.
596
609
  await prepareReadyAssigneeForDispatch(tickets, config.tickets, (line) => {
597
610
  if (opts.silent !== true) opts.stderr(`warning: ${line}`)
598
611
  })
@@ -743,6 +756,10 @@ class DispatchLoop {
743
756
  * frontend's tick-path journal reads and writes share. Resident for a
744
757
  * watch loop; `--once` builds it cold for its single tick. */
745
758
  private readonly repoView: RepoViewStore
759
+ /** This loop's adapters, with every effect fenced on repository authority. */
760
+ private readonly wiring: DispatchWiring
761
+ /** `opts.exec` with `git push` fenced on repository authority. */
762
+ private readonly exec: Exec
746
763
  private readonly host = hostname()
747
764
  private readonly maxHarvestRecoveryAttempts = DEFAULT_MAX_HARVEST_RECOVERY_ATTEMPTS
748
765
  /** In-flight build and harvest runs (fire-and-forget) — awaited before a
@@ -874,9 +891,20 @@ class DispatchLoop {
874
891
  private repoLeaseValidUntil = 0
875
892
  private repoLeaseHolder: string | undefined
876
893
  private repoLeaseHeartbeat: ReturnType<typeof setInterval> | undefined
877
- /** Set when the store reports this supervisor's repo lease was taken over:
878
- * stop accepting launches, detach/reap, signal continuations, and exit watch
879
- * mode cleanly. */
894
+ /** The timing pair the last successful repository-lease claim stored. Set
895
+ * only by a claim, so the local deadline, the beat cadence and the store's
896
+ * renewal TTL always agree. */
897
+ private heldLease: RepoLeaseTiming | undefined
898
+ /** Advances whenever the stored lease timing may change or the lease is
899
+ * released. A beat answers for the timing it was sent under, so a response
900
+ * from an older generation is discarded rather than trusted. */
901
+ private leaseGeneration = 0
902
+ /** Serializes lease claims and timing adoption, so a claim never captures a
903
+ * timing pair that a concurrent claim is replacing. */
904
+ private leaseMutation: Promise<unknown> = Promise.resolve()
905
+ /** Set only when the lease resolver proves another run took the repository
906
+ * lease: stop accepting launches, detach/reap, signal continuations, and
907
+ * exit watch mode cleanly. An expired lease of our own is never proof. */
880
908
  private superseded = false
881
909
  /** Public teardown fact for the durable `dispatcher.run-stopped` reason. */
882
910
  get supersededByPeer(): boolean {
@@ -905,11 +933,62 @@ class DispatchLoop {
905
933
 
906
934
  constructor(
907
935
  private readonly liveConfig: LiveConfig,
908
- private readonly wiring: DispatchWiring,
936
+ wiring: DispatchWiring,
909
937
  private readonly opts: DispatchOpts,
910
938
  /** The view `abDispatch` already used for its lifecycle appends. */
911
939
  view?: RepoViewStore,
912
940
  ) {
941
+ // Every effect this loop or its Dispatcher calls is fenced where it
942
+ // happens: a continuation that resumes after this run's repository lease
943
+ // lapsed throws `RepositoryAuthorityLapsed` instead of starting it. The
944
+ // caller's wiring object is never mutated, so a second loop over the same
945
+ // wiring cannot inherit this loop's guard.
946
+ const guard = () => this.requireRepoAuthority()
947
+ const fencedWorkspaces = (provider: WorkspaceProvider): WorkspaceProvider =>
948
+ fenceEffects(
949
+ provider,
950
+ {
951
+ methods: ['provision'],
952
+ nested: {
953
+ publication: { methods: ['recoverCandidate', 'preserve', 'rewrite', 'publish'] },
954
+ buildExecution: { methods: ['start'] },
955
+ harvestExecution: { methods: ['start'] },
956
+ },
957
+ },
958
+ guard,
959
+ )
960
+ wiring = {
961
+ ...wiring,
962
+ tickets: fenceEffects(
963
+ wiring.tickets,
964
+ {
965
+ methods: [
966
+ 'claim',
967
+ 'comment',
968
+ 'transition',
969
+ 'create',
970
+ 'update',
971
+ 'addBlocker',
972
+ 'removeBlocker',
973
+ 'addState',
974
+ 'mutateIfRevision',
975
+ ],
976
+ },
977
+ guard,
978
+ ),
979
+ workspaces: fencedWorkspaces(wiring.workspaces),
980
+ buildExecution: fenceEffects(wiring.buildExecution, { methods: ['start'] }, guard),
981
+ ...(wiring.retiredWorkspaces === undefined
982
+ ? {}
983
+ : {
984
+ retiredWorkspaces: wiring.retiredWorkspaces.map((runtime) => ({
985
+ provider: fencedWorkspaces(runtime.provider),
986
+ execution: fenceEffects(runtime.execution, { methods: ['start'] }, guard),
987
+ })),
988
+ }),
989
+ }
990
+ this.wiring = wiring
991
+ this.exec = fenceExec(opts.exec, guard)
913
992
  const config = liveConfig.current().config
914
993
  this.startupRootBranch = config.baseBranch
915
994
  // Minted exactly once per invocation: `wiring.ids` is `randomIds()` and a
@@ -964,13 +1043,18 @@ class DispatchLoop {
964
1043
 
965
1044
  // `abDispatch` hands over a view it already used for the lifecycle appends,
966
1045
  // so those rows are folded, not re-read, and one flush covers them all.
967
- this.repoView =
1046
+ this.repoView = fenceEffects(
968
1047
  view ??
969
- new RepoViewStore(wiring.store, {
970
- repo: this.repoIdentity,
971
- resident: opts.once !== true,
972
- })
973
- wiring.forge = guardForge(wiring.forge, {
1048
+ new RepoViewStore(wiring.store, {
1049
+ repo: this.repoIdentity,
1050
+ resident: opts.once !== true,
1051
+ }),
1052
+ { methods: ['createBuild', 'claimLease'] },
1053
+ guard,
1054
+ )
1055
+ // The fence sits under the health guard, so the Dispatcher's own
1056
+ // `guardForge` call recognises this object and adds no second wrapper.
1057
+ wiring.forge = guardForge(fenceForge(wiring.forge, guard), {
974
1058
  store: this.repoView,
975
1059
  repo: this.repoIdentity,
976
1060
  name: config.forge,
@@ -996,7 +1080,8 @@ class DispatchLoop {
996
1080
  ? { repoOrigin: normalizeGitRemoteUrl(opts.repository) }
997
1081
  : {}),
998
1082
  checkout: opts.targetRepo,
999
- exec: opts.exec,
1083
+ exec: this.exec,
1084
+ holdsRepoAuthority: () => this.holdsRepoAuthority(),
1000
1085
  launchRunner: (slug) => this.launchRunner(slug),
1001
1086
  startHarvest: () => this.launchHarvest(),
1002
1087
  nameSlug,
@@ -1051,7 +1136,7 @@ class DispatchLoop {
1051
1136
  mode: this.opts.repository !== undefined ? 'origin' : 'checkout',
1052
1137
  forge: this.wiring.forge,
1053
1138
  checkout: this.opts.targetRepo,
1054
- exec: this.opts.exec,
1139
+ exec: this.exec,
1055
1140
  ...(workspace !== null ? { workspacePath: workspace.path } : {}),
1056
1141
  onFailure: (failure) => failures.push(failure),
1057
1142
  })
@@ -1229,7 +1314,17 @@ class DispatchLoop {
1229
1314
  )
1230
1315
  }
1231
1316
 
1317
+ /** Status telemetry is new work: a run that held the repository lease
1318
+ * writes none once a peer replaced it, and a lapsed holder resolves its
1319
+ * lease first. A standby that never held it reports as before. */
1232
1320
  private async appendStatus(event: RepositoryEventWrite): Promise<void> {
1321
+ if (this.superseded) return
1322
+ if (
1323
+ this.repoLeaseHolder !== undefined &&
1324
+ !this.holdsRepoAuthority() &&
1325
+ !(await this.reconfirmRepoLease())
1326
+ )
1327
+ return
1233
1328
  await this.repoView.appendRepo(this.repoIdentity, event)
1234
1329
  }
1235
1330
 
@@ -1327,15 +1422,19 @@ class DispatchLoop {
1327
1422
  await this.recordTickYielded()
1328
1423
  return emptyTickReport()
1329
1424
  }
1425
+ // A reloaded `[policy]` lease pair takes effect here, through a claim.
1426
+ await this.adoptConfiguredLease()
1427
+ if (this.superseded) return emptyTickReport()
1330
1428
  // Initialization can read/write the store. Retry it at the tick boundary
1331
1429
  // after a transient failure, even while our repository lease stays valid.
1332
1430
  await this.initializeAutomaticUpgrade()
1333
1431
  await this.reportForgeReadiness()
1334
- const startedAt = await this.repoView.beginRepoTick(this.repoIdentity, this.runId)
1335
- if (startedAt === null) {
1336
- this.superseded = true
1337
- return emptyTickReport()
1338
- }
1432
+ let startedAt = await this.repoView.beginRepoTick(this.repoIdentity, this.runId)
1433
+ // The store refuses a boundary on an expired lease. Ours may only have
1434
+ // lapsed: reclaim it and retry once; the resolver decides supersession.
1435
+ if (startedAt === null && (await this.reconfirmRepoLease()))
1436
+ startedAt = await this.repoView.beginRepoTick(this.repoIdentity, this.runId)
1437
+ if (startedAt === null) return emptyTickReport()
1339
1438
  this.tickStartedAt = startedAt
1340
1439
 
1341
1440
  // Refresh inside the serialized tick so claims and the display both see
@@ -2430,6 +2529,7 @@ class DispatchLoop {
2430
2529
  let tracked: Promise<void>
2431
2530
  tracked = this.launchHarvestIfNeeded()
2432
2531
  .catch((error: unknown) => {
2532
+ if (isRepositoryAuthorityLapse(error)) return
2433
2533
  if (this.stopped || this.localHarvestShutdown.signal.aborted)
2434
2534
  this.localHarvestFailure = error
2435
2535
  // The gate may read the backing store after tick work dirties the view.
@@ -2493,11 +2593,14 @@ class DispatchLoop {
2493
2593
  clock,
2494
2594
  instance: `${this.host}-harvest-${ids('inst')}`,
2495
2595
  ...(this.repoLeaseHolder !== undefined ? { leaseHolder: this.repoLeaseHolder } : {}),
2596
+ holdsAuthority: () => this.holdsRepoAuthority(),
2496
2597
  sessionEnv: {
2497
2598
  AB_STORE: storeRef,
2498
2599
  },
2499
2600
  opts: {
2500
2601
  maxRecoveryAttempts: this.maxHarvestRecoveryAttempts,
2602
+ // Harvest renews this loop's lease; it must never rewrite its TTL.
2603
+ ...(this.heldLease !== undefined ? { leaseTtlMs: this.heldLease.ttlMs } : {}),
2501
2604
  },
2502
2605
  }
2503
2606
 
@@ -2531,6 +2634,7 @@ class DispatchLoop {
2531
2634
  return prepared
2532
2635
  }
2533
2636
  preparedRun = { run: prepared.run }
2637
+ this.requireRepoAuthority()
2534
2638
  await this.repoView.appendRepo(this.repoIdentity, {
2535
2639
  actor: DISPATCHER,
2536
2640
  type: 'harvest.execution.authorized',
@@ -2576,6 +2680,7 @@ class DispatchLoop {
2576
2680
  this.opts.targetRepo,
2577
2681
  undefined,
2578
2682
  this.wiring.plugins,
2683
+ this.opts.repository !== undefined ? { repository: this.repoIdentity } : {},
2579
2684
  )
2580
2685
  const result = await new HarvestRunner({
2581
2686
  ...harvestDeps,
@@ -2609,6 +2714,7 @@ class DispatchLoop {
2609
2714
  if (!/^https?:/i.test(storeRef)) return new HarvestRunner(harvestDeps).run()
2610
2715
  const prepared = await new HarvestRunner(harvestDeps).run(true)
2611
2716
  if (prepared.outcome !== 'prepared') return prepared
2717
+ this.requireRepoAuthority()
2612
2718
  await this.repoView.appendRepo(this.repoIdentity, {
2613
2719
  actor: DISPATCHER,
2614
2720
  type: 'harvest.execution.authorized',
@@ -2645,6 +2751,7 @@ class DispatchLoop {
2645
2751
  storeRef,
2646
2752
  }).localStateRoot,
2647
2753
  this.wiring.plugins,
2754
+ this.opts.repository !== undefined ? { repository: this.repoIdentity } : {},
2648
2755
  )
2649
2756
  : harvestDeps.tickets
2650
2757
  return await new HarvestRunner({
@@ -2681,6 +2788,8 @@ class DispatchLoop {
2681
2788
  this.localHarvestFailure = error
2682
2789
  return
2683
2790
  }
2791
+ // Nothing started without authority; a later tick retries.
2792
+ if (isRepositoryAuthorityLapse(error)) return
2684
2793
  this.pendingHarvest.harvestFailed += 1
2685
2794
  await this.appendStatus({
2686
2795
  actor: DISPATCHER,
@@ -2718,7 +2827,11 @@ class DispatchLoop {
2718
2827
  clock: this.wiring.clock,
2719
2828
  instance,
2720
2829
  ...(this.repoLeaseHolder ? { leaseHolder: this.repoLeaseHolder } : {}),
2721
- opts: { maxRecoveryAttempts: this.maxHarvestRecoveryAttempts },
2830
+ holdsAuthority: () => this.holdsRepoAuthority(),
2831
+ opts: {
2832
+ maxRecoveryAttempts: this.maxHarvestRecoveryAttempts,
2833
+ ...(this.heldLease !== undefined ? { leaseTtlMs: this.heldLease.ttlMs } : {}),
2834
+ },
2722
2835
  }).run(true)
2723
2836
  }
2724
2837
 
@@ -2776,6 +2889,7 @@ class DispatchLoop {
2776
2889
 
2777
2890
  const prepared = await this.prepareHarvest(execution)
2778
2891
  if (prepared.outcome !== 'prepared') return
2892
+ this.requireRepoAuthority()
2779
2893
  await this.repoView.appendRepo(repo, {
2780
2894
  actor: DISPATCHER,
2781
2895
  type: 'harvest.execution.authorized',
@@ -2873,6 +2987,8 @@ class DispatchLoop {
2873
2987
  if (detached.value) {
2874
2988
  // Teardown detached the local wait; the guest keeps running and the
2875
2989
  // execution stays open for durable settlement by a later invocation.
2990
+ // Releasing this invocation's lease does not fence the guest: its
2991
+ // authority is the execution's durable authorization.
2876
2992
  return
2877
2993
  }
2878
2994
  // The guest exit code carries no pipeline outcome: classify from the
@@ -2909,6 +3025,8 @@ class DispatchLoop {
2909
3025
  await this.dispatcher.holdForMissingAccounts(error)
2910
3026
  return
2911
3027
  }
3028
+ // Nothing started without authority; a later tick retries.
3029
+ if (isRepositoryAuthorityLapse(error)) return
2912
3030
  this.pendingHarvest.harvestFailed += 1
2913
3031
  await this.appendStatus({
2914
3032
  actor: DISPATCHER,
@@ -3115,11 +3233,10 @@ class DispatchLoop {
3115
3233
  completed,
3116
3234
  ]
3117
3235
  : []
3118
- const result = await this.finishTick({ outcome: 'completed', counters }, events)
3119
- if (result === null) {
3120
- this.superseded = true
3121
- throw new Error('repository tick lease lost')
3122
- }
3236
+ let result = await this.finishTick({ outcome: 'completed', counters }, events)
3237
+ if (result === null && (await this.reconfirmRepoLease()))
3238
+ result = await this.finishTick({ outcome: 'completed', counters }, events)
3239
+ if (result === null) throw new Error('repository tick lease lost')
3123
3240
  this.tickStartedAt = undefined
3124
3241
  }
3125
3242
 
@@ -3178,6 +3295,15 @@ class DispatchLoop {
3178
3295
  | { original: string; first: string; last: string; count: number }
3179
3296
  | undefined
3180
3297
 
3298
+ /** A tick stopped by a fenced effect is not a failed tick: publish no
3299
+ * `tick-failed`, abandon the open boundary (a successor's or our own next
3300
+ * `beginRepoTick` overwrites it), and resolve the lease. That either stops
3301
+ * this run as superseded or reclaims so the next tick runs normally. */
3302
+ private async settleAuthorityLapse(): Promise<void> {
3303
+ this.tickStartedAt = undefined
3304
+ await this.reconfirmRepoLease()
3305
+ }
3306
+
3181
3307
  /** Reporting is diagnostic: its failure must never replace the operational error. */
3182
3308
  private async reportTickFailure(error: unknown): Promise<void> {
3183
3309
  const original = formatDispatcherError(error)
@@ -3228,25 +3354,23 @@ class DispatchLoop {
3228
3354
  await this.wiring.store.appendRepo(this.repoIdentity, failed)
3229
3355
  return
3230
3356
  }
3231
- const result = await this.finishTick(
3357
+ const completion: RepoTickCompletion = {
3358
+ outcome: 'failed',
3359
+ error: failed.payload.error,
3360
+ forgeRequests: this.dispatcher.lastForgeRequests,
3361
+ }
3362
+ const events: RepositoryEventWrite[] = [
3232
3363
  {
3233
- outcome: 'failed',
3234
- error: failed.payload.error,
3235
- forgeRequests: this.dispatcher.lastForgeRequests,
3364
+ actor: DISPATCHER,
3365
+ type: 'dispatcher.tick-started',
3366
+ payload: { run: this.runId, startedAt: this.tickStartedAt },
3236
3367
  },
3237
- [
3238
- {
3239
- actor: DISPATCHER,
3240
- type: 'dispatcher.tick-started',
3241
- payload: { run: this.runId, startedAt: this.tickStartedAt },
3242
- },
3243
- failed,
3244
- ],
3245
- )
3246
- if (result === null) {
3247
- this.superseded = true
3248
- return
3249
- }
3368
+ failed,
3369
+ ]
3370
+ let result = await this.finishTick(completion, events)
3371
+ if (result === null && (await this.reconfirmRepoLease()))
3372
+ result = await this.finishTick(completion, events)
3373
+ if (result === null) return
3250
3374
  this.tickStartedAt = undefined
3251
3375
  }
3252
3376
 
@@ -3287,7 +3411,7 @@ class DispatchLoop {
3287
3411
  forge: this.wiring.forge,
3288
3412
  workspacePath: this.opts.targetRepo,
3289
3413
  checkoutless: this.opts.repository !== undefined,
3290
- exec: this.opts.exec,
3414
+ exec: this.exec,
3291
3415
  ids: this.wiring.ids,
3292
3416
  runId: this.runId,
3293
3417
  clock: this.wiring.clock,
@@ -3311,7 +3435,9 @@ class DispatchLoop {
3311
3435
  try {
3312
3436
  await this.settlePendingPublication(slug)
3313
3437
  } catch (error) {
3314
- if (!(error instanceof ForgeRequestDeferred)) throw error
3438
+ // A lapsed run publishes nothing; the successor settles from durable facts.
3439
+ if (!(error instanceof ForgeRequestDeferred) && !isRepositoryAuthorityLapse(error))
3440
+ throw error
3315
3441
  }
3316
3442
  }
3317
3443
 
@@ -3541,6 +3667,14 @@ class DispatchLoop {
3541
3667
  this.inFlightKinds.set(tracked, handle.supervision)
3542
3668
  return 'scheduled'
3543
3669
  } catch (error) {
3670
+ if (isRepositoryAuthorityLapse(error)) {
3671
+ // Nothing was started. Release the execution lease (teardown) so a
3672
+ // successor can launch at once, and record no settlement or failure.
3673
+ if (leaseClaimed) await this.repoView.releaseLease(slug, instance).catch(() => {})
3674
+ if (this.activeBuildRuns.get(slug)?.reservation === reservation)
3675
+ this.activeBuildRuns.delete(slug)
3676
+ return 'already-active'
3677
+ }
3544
3678
  if (error instanceof MissingAccountCredentialsError) {
3545
3679
  await this.dispatcher.holdForMissingAccounts(error)
3546
3680
  if (leaseClaimed) await this.repoView.releaseLease(slug, instance)
@@ -4203,17 +4337,59 @@ class DispatchLoop {
4203
4337
 
4204
4338
  // ── Repository supervisor lease (§12 serialization) ────────────────────────
4205
4339
 
4340
+ /** The timing pair the accepted configuration asks for. */
4341
+ private configuredLease(): RepoLeaseTiming {
4342
+ const policy = this.currentConfig().config.policy
4343
+ return {
4344
+ ttlMs: policy.dispatchLeaseTimeoutSeconds * 1000,
4345
+ renewalMs: policy.dispatchLeaseRenewalSeconds * 1000,
4346
+ }
4347
+ }
4348
+
4349
+ /** Whether this run may start an effect now. No I/O: the deadline is the
4350
+ * claim or beat request time plus the held TTL, never later than the
4351
+ * store's expiry, so no peer can have claimed the lease before it. */
4352
+ private holdsRepoAuthority(): boolean {
4353
+ return (
4354
+ !this.superseded &&
4355
+ this.repoLeaseHolder !== undefined &&
4356
+ this.wiring.clock().getTime() < this.repoLeaseValidUntil
4357
+ )
4358
+ }
4359
+
4360
+ /** The synchronous effect fence: throw instead of starting an effect. */
4361
+ private requireRepoAuthority(): void {
4362
+ if (!this.holdsRepoAuthority()) throw new RepositoryAuthorityLapsed()
4363
+ }
4364
+
4206
4365
  /** Claim an unknown or expired repository lease and start the
4207
- * heartbeat timer. False means another supervisor holds it: the caller
4208
- * yields — no claims, launches, or publications. */
4366
+ * heartbeat timer. False means this run may not act this tick: another
4367
+ * supervisor holds the lease, or our own lapsed lease could not be
4368
+ * confirmed yet. The caller yields — no claims, launches, or publications. */
4209
4369
  private async ensureRepoLease(holder: string): Promise<boolean> {
4210
4370
  if (this.superseded) return false
4211
- if (this.repoLeaseHolder === holder && this.wiring.clock().getTime() < this.repoLeaseValidUntil)
4371
+ if (this.repoLeaseHolder === holder) {
4372
+ if (this.wiring.clock().getTime() < this.repoLeaseValidUntil) return true
4373
+ // Our own deadline lapsed (a stall, or beats lost to a store outage).
4374
+ // Only the resolver decides between "reclaim" and "replaced".
4375
+ return await this.reconfirmRepoLease()
4376
+ }
4377
+ const claimed = await this.mutateLease(async () => {
4378
+ if (this.superseded) return false
4379
+ if (this.repoLeaseHolder === holder) return this.holdsRepoAuthority()
4380
+ const lease = this.configuredLease()
4381
+ const requestedAt = this.wiring.clock().getTime()
4382
+ const granted = await this.wiring.store
4383
+ .claimRepoLease(this.repoIdentity, holder, lease.ttlMs)
4384
+ .catch(() => false)
4385
+ if (!granted || this.superseded) return false
4386
+ this.leaseGeneration++
4387
+ this.heldLease = lease
4388
+ this.repoLeaseValidUntil = requestedAt + lease.ttlMs
4389
+ this.repoLeaseHolder = holder
4390
+ this.restartRepoLeaseHeartbeat()
4212
4391
  return true
4213
- const requestedAt = this.wiring.clock().getTime()
4214
- const claimed = await this.wiring.store
4215
- .claimRepoLease(this.repoIdentity, holder, REPO_LEASE_TTL_MS)
4216
- .catch(() => false)
4392
+ })
4217
4393
  if (this.dashboard && !this.opts.once) {
4218
4394
  this.standbyResolver ??= new StandbyIdentityResolver(this.wiring.store, this.repoIdentity)
4219
4395
  this.standby = claimed
@@ -4226,44 +4402,128 @@ class DispatchLoop {
4226
4402
  this.syncModelControls()
4227
4403
  this.paint()
4228
4404
  }
4229
- if (!claimed) {
4230
- if (this.repoLeaseHolder !== undefined) {
4231
- // We held the lease and the store says it is gone: a peer took over.
4232
- this.superseded = true
4233
- }
4405
+ return claimed
4406
+ }
4407
+
4408
+ /** Run one lease claim or timing change after every earlier one settles. */
4409
+ private mutateLease<T>(mutation: () => Promise<T>): Promise<T> {
4410
+ const result = this.leaseMutation.then(mutation)
4411
+ this.leaseMutation = result.catch(() => {})
4412
+ return result
4413
+ }
4414
+
4415
+ /** Resolve a lease that looks lapsed: reclaim it when the record still
4416
+ * names this run, stop as superseded when another run took it, and do
4417
+ * nothing on a store error (the next beat or tick asks again). True only
4418
+ * when this run holds the lease again. A released lease is never
4419
+ * resurrected. */
4420
+ private reconfirmRepoLease(): Promise<boolean> {
4421
+ return this.mutateLease(() => this.reconfirmHeldLease())
4422
+ }
4423
+
4424
+ /** `reconfirmRepoLease` for a caller already inside `mutateLease`. */
4425
+ private async reconfirmHeldLease(): Promise<boolean> {
4426
+ const holder = this.repoLeaseHolder
4427
+ if (this.superseded || holder === undefined) return false
4428
+ const lease = this.heldLease ?? this.configuredLease()
4429
+ const generation = this.leaseGeneration
4430
+ const requestedAt = this.wiring.clock().getTime()
4431
+ const resolution = await resolveLapsedRepoLease(
4432
+ this.wiring.store,
4433
+ this.repoIdentity,
4434
+ holder,
4435
+ lease.ttlMs,
4436
+ )
4437
+ if (this.superseded || this.repoLeaseHolder !== holder || this.leaseGeneration !== generation)
4234
4438
  return false
4439
+ if (resolution === 'held') {
4440
+ this.repoLeaseValidUntil = Math.max(this.repoLeaseValidUntil, requestedAt + lease.ttlMs)
4441
+ return true
4235
4442
  }
4236
- this.repoLeaseValidUntil = requestedAt + REPO_LEASE_TTL_MS
4237
- if (this.repoLeaseHolder === undefined) {
4238
- this.repoLeaseHolder = holder
4239
- this.startRepoLeaseHeartbeat(holder)
4443
+ if (resolution === 'superseded') {
4444
+ // A peer holds or held the repository since. Exit watch mode cleanly
4445
+ // after the same teardown every stop takes (detach remote / reap local,
4446
+ // signal continuations, release the lease).
4447
+ this.superseded = true
4448
+ this.inputStop.abort()
4240
4449
  }
4241
- return true
4450
+ return false
4242
4451
  }
4243
4452
 
4244
- private startRepoLeaseHeartbeat(holder: string): void {
4245
- if (this.repoLeaseHeartbeat !== undefined) return
4453
+ /** Adopt a changed `[policy]` lease pair through a same-holder claim, which
4454
+ * rewrites the stored TTL in every adapter. Unchanged configuration costs
4455
+ * no store request.
4456
+ *
4457
+ * While the claim is in flight the stored TTL may be either pair, so the
4458
+ * beat stops, the generation advances (an in-flight beat's answer is
4459
+ * discarded) and the deadline is held to the shorter TTL. An ambiguous
4460
+ * failure keeps the shorter of both pairs until a later claim settles it. */
4461
+ private adoptConfiguredLease(): Promise<void> {
4462
+ return this.mutateLease(async () => {
4463
+ const holder = this.repoLeaseHolder
4464
+ const held = this.heldLease
4465
+ if (holder === undefined || held === undefined || !this.holdsRepoAuthority()) return
4466
+ const wanted = this.configuredLease()
4467
+ if (wanted.ttlMs === held.ttlMs && wanted.renewalMs === held.renewalMs) return
4468
+ const requestedAt = this.wiring.clock().getTime()
4469
+ this.stopRepoLeaseHeartbeat()
4470
+ this.leaseGeneration++
4471
+ this.repoLeaseValidUntil = Math.min(this.repoLeaseValidUntil, requestedAt + wanted.ttlMs)
4472
+ let claimed: boolean
4473
+ try {
4474
+ claimed = await this.wiring.store.claimRepoLease(this.repoIdentity, holder, wanted.ttlMs)
4475
+ } catch {
4476
+ // The claim may or may not have landed. The next tick retries.
4477
+ claimed = false
4478
+ if (!this.superseded && this.repoLeaseHolder === holder) {
4479
+ this.heldLease = {
4480
+ ttlMs: Math.min(held.ttlMs, wanted.ttlMs),
4481
+ renewalMs: Math.min(held.renewalMs, wanted.renewalMs),
4482
+ }
4483
+ this.restartRepoLeaseHeartbeat()
4484
+ }
4485
+ return
4486
+ }
4487
+ if (this.superseded || this.repoLeaseHolder !== holder) return
4488
+ if (!claimed) {
4489
+ this.restartRepoLeaseHeartbeat()
4490
+ await this.reconfirmHeldLease()
4491
+ return
4492
+ }
4493
+ this.heldLease = wanted
4494
+ this.repoLeaseValidUntil = requestedAt + wanted.ttlMs
4495
+ this.restartRepoLeaseHeartbeat()
4496
+ })
4497
+ }
4498
+
4499
+ /** (Re)start the beat at the held renewal interval. A beat that finds the
4500
+ * lease no longer renewable hands the decision to the resolver; it never
4501
+ * concludes takeover by itself. */
4502
+ private restartRepoLeaseHeartbeat(): void {
4503
+ this.stopRepoLeaseHeartbeat()
4504
+ const holder = this.repoLeaseHolder
4505
+ const lease = this.heldLease
4506
+ if (holder === undefined || lease === undefined) return
4246
4507
  this.repoLeaseHeartbeat = setInterval(() => {
4508
+ const generation = this.leaseGeneration
4247
4509
  const requestedAt = this.wiring.clock().getTime()
4248
4510
  this.wiring.store.heartbeatRepo(this.repoIdentity, holder).then(
4249
4511
  (alive) => {
4250
- if (this.retirement && this.repoLeaseHolder === undefined) return
4512
+ // Released (retirement, shutdown), or the stored timing may have
4513
+ // changed, since this beat was sent: its answer no longer applies.
4514
+ if (this.repoLeaseHolder !== holder || this.leaseGeneration !== generation) return
4251
4515
  if (alive) {
4252
- this.repoLeaseValidUntil = requestedAt + REPO_LEASE_TTL_MS
4516
+ this.repoLeaseValidUntil = requestedAt + lease.ttlMs
4253
4517
  return
4254
4518
  }
4255
- // A peer holds the repository now. Exit watch mode cleanly after
4256
- // the same teardown every stop takes (detach remote / reap local,
4257
- // signal continuations, release the lease).
4258
- this.superseded = true
4259
- this.inputStop.abort()
4519
+ void this.reconfirmRepoLease()
4260
4520
  },
4261
4521
  () => {
4262
- // Store unreachable: retry on the next beat; a later false result
4263
- // proves takeover.
4522
+ // Store unreachable: retry on the next beat. Tick start reclaims
4523
+ // once the store answers again.
4264
4524
  },
4265
4525
  )
4266
- }, REPO_LEASE_HEARTBEAT_MS)
4526
+ }, lease.renewalMs)
4267
4527
  this.repoLeaseHeartbeat.unref?.()
4268
4528
  }
4269
4529
 
@@ -4280,7 +4540,8 @@ class DispatchLoop {
4280
4540
  try {
4281
4541
  const record = await this.wiring.store.getRepo(this.repoIdentity).catch(() => null)
4282
4542
  const holder = record?.lease?.holder
4283
- if (holder === undefined || this.yieldedTo === holder) return
4543
+ // Never a yield to ourselves: our own lapsed lease is resolved, not yielded to.
4544
+ if (holder === undefined || holder === this.runId || this.yieldedTo === holder) return
4284
4545
  this.yieldedTo = holder
4285
4546
  await this.repoView.appendRepo(this.repoIdentity, {
4286
4547
  actor: DISPATCHER,
@@ -4300,6 +4561,7 @@ class DispatchLoop {
4300
4561
  const holder = this.repoLeaseHolder
4301
4562
  this.repoLeaseHolder = undefined
4302
4563
  this.repoLeaseValidUntil = 0
4564
+ this.leaseGeneration++
4303
4565
  if (holder === undefined) return
4304
4566
  try {
4305
4567
  await this.wiring.store.releaseRepoLease(this.repoIdentity, holder)
@@ -4377,14 +4639,7 @@ class DispatchLoop {
4377
4639
  this.abandonUpgradeYield()
4378
4640
  return false
4379
4641
  }
4380
- const lease = (await this.wiring.store.getRepo(this.repoIdentity))?.lease
4381
- if (
4382
- lease?.holder !== this.runId ||
4383
- Date.parse(lease.expiresAt) <= this.wiring.clock().getTime()
4384
- ) {
4385
- this.superseded = true
4386
- return false
4387
- }
4642
+ if (!(await this.upgradeLeaseCurrent())) return false
4388
4643
  // No launch, claim, tick or target continuation may cross this boundary.
4389
4644
  this.yieldPending = true
4390
4645
  this.acceptingBuildLaunches = false
@@ -4401,12 +4656,8 @@ class DispatchLoop {
4401
4656
  ])
4402
4657
  }
4403
4658
  await this.dispatcher.stopProvisioning()
4404
- const currentLease = (await this.wiring.store.getRepo(this.repoIdentity))?.lease
4405
- if (
4406
- currentLease?.holder !== this.runId ||
4407
- Date.parse(currentLease.expiresAt) <= this.wiring.clock().getTime()
4408
- ) {
4409
- this.superseded = true
4659
+ if (!(await this.upgradeLeaseCurrent())) {
4660
+ if (!this.superseded) this.abandonUpgradeYield()
4410
4661
  return false
4411
4662
  }
4412
4663
  const startedAt = this.wiring.clock().toISOString()
@@ -4486,6 +4737,19 @@ class DispatchLoop {
4486
4737
  return this.adoptUpgradeYield(accepted)
4487
4738
  }
4488
4739
 
4740
+ /** Repository authority may transfer only from a current holder. A record
4741
+ * naming another run, or no record, means a peer replaced us. An expired
4742
+ * lease that still names us is resolved like any other lapse. */
4743
+ private async upgradeLeaseCurrent(): Promise<boolean> {
4744
+ const lease = (await this.wiring.store.getRepo(this.repoIdentity))?.lease
4745
+ if (lease?.holder !== this.runId) {
4746
+ this.superseded = true
4747
+ return false
4748
+ }
4749
+ if (Date.parse(lease.expiresAt) > this.wiring.clock().getTime()) return true
4750
+ return await this.reconfirmRepoLease()
4751
+ }
4752
+
4489
4753
  /** Reopen admission after a yield that did not durably transfer authority. */
4490
4754
  private abandonUpgradeYield(): void {
4491
4755
  if (!this.yieldPending) return
@@ -4618,6 +4882,7 @@ class DispatchLoop {
4618
4882
  config.roles,
4619
4883
  config.policy.sessionBudgetSeconds,
4620
4884
  config.accounts,
4885
+ config.profiles,
4621
4886
  )
4622
4887
  const deadline = new Date(
4623
4888
  Date.parse(retirement.startedAt) + config.policy.upgradeDrainSeconds * 1000,
@@ -4741,7 +5006,7 @@ class DispatchLoop {
4741
5006
  ),
4742
5007
  enabled: () =>
4743
5008
  !this.stopped &&
4744
- !this.superseded &&
5009
+ this.holdsRepoAuthority() &&
4745
5010
  this.currentConfig().config.upgrade.automatic &&
4746
5011
  this.upgradeRetirementSettled,
4747
5012
  resolve: (signal) =>
@@ -4751,7 +5016,7 @@ class DispatchLoop {
4751
5016
  originalInstall: launch.originalInstall!,
4752
5017
  sourceLaunch: launch.sourceLaunch,
4753
5018
  forge: this.wiring.forge,
4754
- exec: this.opts.exec,
5019
+ exec: this.exec,
4755
5020
  signal,
4756
5021
  }),
4757
5022
  prepare: (target, signal) =>
@@ -4837,6 +5102,10 @@ class DispatchLoop {
4837
5102
  // One background triage read before the single tick, never inside it.
4838
5103
  this.triageSampler?.poke()
4839
5104
  const initial = await this.dispatcherTick(true).catch(async (error: unknown) => {
5105
+ if (isRepositoryAuthorityLapse(error)) {
5106
+ await this.settleAuthorityLapse()
5107
+ return emptyTickReport()
5108
+ }
4840
5109
  await this.reportTickFailure(error)
4841
5110
  throw error
4842
5111
  })
@@ -4890,8 +5159,12 @@ class DispatchLoop {
4890
5159
  startup = false
4891
5160
  } catch (error) {
4892
5161
  if (this.forgePublicationFailed) throw error
4893
- failed = true
4894
- await this.reportTickFailure(error)
5162
+ if (isRepositoryAuthorityLapse(error)) {
5163
+ await this.settleAuthorityLapse()
5164
+ } else {
5165
+ failed = true
5166
+ await this.reportTickFailure(error)
5167
+ }
4895
5168
  }
4896
5169
  this.triageSampler?.poke()
4897
5170
  if (this.watchStopped || this.superseded) break
@@ -5392,7 +5665,10 @@ export async function abDispatch(opts: DispatchOpts): Promise<void> {
5392
5665
  wiring.updateRuntimeReferences?.(effectiveConfig)
5393
5666
  },
5394
5667
  startupDeprecations,
5395
- (next) => assertReadyAssigneeAccepted(next.tickets, wiring.tickets),
5668
+ (next) => {
5669
+ assertReadyAssigneeAccepted(next.tickets, wiring.tickets)
5670
+ assertCreateAssigneeAccepted(next.tickets, wiring.tickets)
5671
+ },
5396
5672
  )
5397
5673
 
5398
5674
  // Launch flags are durable repository setters. Omission writes nothing, so