@defrex/autobuild 1.4.2 → 1.6.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.
- package/README.md +1 -1
- package/SPEC.md +512 -101
- package/bin/ab-dispatch-kernel.ts +1 -0
- package/docs/accounts.md +9 -0
- package/docs/agent-runtimes.md +1 -0
- package/docs/answering-blocked-builds.md +7 -3
- package/docs/architecture.md +313 -130
- package/docs/assets/headline-wide.png +0 -0
- package/docs/build-store.md +33 -3
- package/docs/cli.md +2 -1
- package/docs/configuration-overview.md +9 -0
- package/docs/configuration.md +217 -106
- package/docs/dispatcher-hosting.md +19 -3
- package/docs/dispatcher.md +11 -6
- package/docs/glossary.md +1 -1
- package/docs/integration-overview.md +2 -2
- package/docs/integration-tree.md +91 -28
- package/docs/merge-policy.md +28 -9
- package/docs/operating.md +1 -1
- package/docs/operator-api.md +57 -20
- package/docs/operator-surfaces.md +1 -1
- package/docs/plugin-authoring.md +89 -8
- package/docs/remote-store-protocol.md +39 -11
- package/docs/remote-ticket-protocol.md +126 -12
- package/docs/restacking.md +24 -6
- package/docs/seams.md +2 -2
- package/docs/setup.md +19 -13
- package/docs/spec-standard.md +2 -1
- package/docs/ticket-dependencies.md +26 -8
- package/docs/ticket-migration.md +70 -7
- package/docs/ticket-sources.md +82 -5
- package/docs/tickets.md +34 -2
- package/docs/troubleshooting.md +3 -3
- package/docs/verification.md +5 -5
- package/docs/website.md +8 -0
- package/docs/workspaces.md +1 -1
- package/package.json +4 -3
- package/packages/core/src/accounts/hosted-readiness.ts +21 -0
- package/packages/core/src/cli/attention.ts +3 -0
- package/packages/core/src/cli/build-control.ts +36 -12
- package/packages/core/src/cli/connect.ts +9 -18
- package/packages/core/src/cli/context.ts +44 -0
- package/packages/core/src/cli/dashboard/configuration.ts +11 -0
- package/packages/core/src/cli/dashboard/model.ts +51 -11
- package/packages/core/src/cli/dashboard/poll.ts +14 -0
- package/packages/core/src/cli/dashboard/queue.ts +21 -0
- package/packages/core/src/cli/dashboard/render.ts +43 -22
- package/packages/core/src/cli/dispatch-frontend.ts +63 -30
- package/packages/core/src/cli/dispatch-mode.ts +35 -16
- package/packages/core/src/cli/dispatch-preflight.ts +4 -1
- package/packages/core/src/cli/dispatch-repository-feed.ts +40 -11
- package/packages/core/src/cli/dispatch-tickets.ts +47 -0
- package/packages/core/src/cli/dispatch-upgrade-controller.ts +3 -0
- package/packages/core/src/cli/dispatch.ts +522 -145
- package/packages/core/src/cli/help.ts +63 -24
- package/packages/core/src/cli/init-hosted-accounts.ts +54 -0
- package/packages/core/src/cli/init-readiness-remote.ts +16 -3
- package/packages/core/src/cli/init-validation.ts +144 -42
- package/packages/core/src/cli/issue-links.ts +67 -0
- package/packages/core/src/cli/main.ts +32 -15
- package/packages/core/src/cli/pr-summary-publication.ts +38 -7
- package/packages/core/src/cli/publication-settlement.ts +36 -24
- package/packages/core/src/cli/repo-lease.ts +225 -0
- package/packages/core/src/cli/repository-status.ts +203 -49
- package/packages/core/src/cli/status.ts +42 -4
- package/packages/core/src/cli/terminals.ts +37 -2
- package/packages/core/src/cli/ticket-editor.ts +20 -6
- package/packages/core/src/cli/ticket.ts +264 -46
- package/packages/core/src/cli/triage-count-sampler.ts +59 -0
- package/packages/core/src/cli/wait.ts +4 -1
- package/packages/core/src/cli/watch.ts +19 -4
- package/packages/core/src/config/live.ts +45 -4
- package/packages/core/src/config/load.ts +9 -0
- package/packages/core/src/config/pipeline-source.ts +6 -2
- package/packages/core/src/config/ready-assignee.ts +86 -0
- package/packages/core/src/config/schema.ts +202 -38
- package/packages/core/src/distribution-packaging.ts +1 -1
- package/packages/core/src/events/catalog.ts +7 -0
- package/packages/core/src/events/compatibility.ts +2 -1
- package/packages/core/src/events/payloads.ts +85 -0
- package/packages/core/src/events/policy.ts +10 -0
- package/packages/core/src/events/repository.ts +93 -28
- package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +237 -230
- package/packages/core/src/kernel/build-identity.ts +12 -0
- package/packages/core/src/kernel/change-presence.ts +139 -6
- package/packages/core/src/kernel/dispatch-capacity.ts +189 -19
- package/packages/core/src/kernel/dispatch-status.ts +10 -1
- package/packages/core/src/kernel/dispatch-upgrade.ts +104 -5
- package/packages/core/src/kernel/engine.ts +17 -8
- package/packages/core/src/kernel/finalize-pr-rejection.ts +95 -0
- package/packages/core/src/kernel/generators/build-log.ts +9 -0
- package/packages/core/src/kernel/generators/repository-journals.ts +15 -1
- package/packages/core/src/kernel/harvest.ts +4 -1
- package/packages/core/src/kernel/incremental-fixtures.ts +1 -0
- package/packages/core/src/kernel/integration-completeness.ts +104 -17
- package/packages/core/src/kernel/integration-landing.ts +17 -0
- package/packages/core/src/kernel/integration-state.ts +17 -0
- package/packages/core/src/kernel/issue-keywords.ts +202 -0
- package/packages/core/src/kernel/janitor-failure.ts +96 -5
- package/packages/core/src/kernel/kernel-git.ts +87 -0
- package/packages/core/src/kernel/landing-readiness.ts +25 -17
- package/packages/core/src/kernel/leaf-restack-state.ts +4 -2
- package/packages/core/src/kernel/log-index.ts +1 -1
- package/packages/core/src/kernel/node-issue-links.ts +142 -0
- package/packages/core/src/kernel/node-landing.ts +2 -1
- package/packages/core/src/kernel/node-parent.ts +6 -0
- package/packages/core/src/kernel/node-restack-transaction.ts +2 -0
- package/packages/core/src/kernel/pr-summary.ts +24 -0
- package/packages/core/src/kernel/read-deferrals.ts +75 -12
- package/packages/core/src/kernel/read-facts.ts +32 -1
- package/packages/core/src/kernel/reconcile-restack.ts +1 -1
- package/packages/core/src/kernel/reducer-registry.ts +37 -2
- package/packages/core/src/kernel/reducer.ts +147 -5
- package/packages/core/src/kernel/ticket-preparation.ts +16 -0
- package/packages/core/src/kernel/verify-budget.ts +43 -0
- package/packages/core/src/operator/index.ts +3 -1
- package/packages/core/src/operator/presentation.ts +3 -0
- package/packages/core/src/operator/protocol.ts +38 -2
- package/packages/core/src/operator/query.ts +69 -29
- package/packages/core/src/operator/registry.ts +47 -26
- package/packages/core/src/operator/tickets.ts +77 -10
- package/packages/core/src/plugin-sdk/index.ts +13 -0
- package/packages/core/src/plugins/manifest.ts +1 -1
- package/packages/core/src/plugins/registry.ts +1 -0
- package/packages/core/src/ports/forge/contract.ts +69 -0
- package/packages/core/src/ports/forge/create.ts +5 -0
- package/packages/core/src/ports/forge/fake.ts +184 -3
- package/packages/core/src/ports/forge/git-rewrite.ts +4 -2
- package/packages/core/src/ports/forge/github.ts +175 -38
- package/packages/core/src/ports/forge/local-git.ts +14 -0
- package/packages/core/src/ports/forge/readiness.ts +10 -0
- package/packages/core/src/ports/forge-failure.ts +43 -0
- package/packages/core/src/ports/runner/claude.ts +7 -1
- package/packages/core/src/ports/runner/codex.ts +7 -2
- package/packages/core/src/ports/runner/native-cli-fixture.ts +2 -1
- package/packages/core/src/ports/runner/pi.ts +7 -1
- package/packages/core/src/ports/runner/runtime.ts +3 -0
- package/packages/core/src/ports/runner/start-prompt.ts +37 -0
- package/packages/core/src/ports/tickets/contract.ts +320 -7
- package/packages/core/src/ports/tickets/create.ts +89 -20
- package/packages/core/src/ports/tickets/fake.ts +18 -0
- package/packages/core/src/ports/tickets/file-codec.ts +20 -0
- package/packages/core/src/ports/tickets/file.ts +43 -1
- package/packages/core/src/ports/tickets/github-fake.ts +1123 -0
- package/packages/core/src/ports/tickets/github-issues.ts +431 -0
- package/packages/core/src/ports/tickets/github-validators.ts +194 -0
- package/packages/core/src/ports/tickets/github.ts +2029 -0
- package/packages/core/src/ports/tickets/hosted-index.ts +34 -3
- package/packages/core/src/ports/tickets/issue-links.ts +86 -0
- package/packages/core/src/ports/tickets/lifecycle.ts +60 -4
- package/packages/core/src/ports/tickets/linear.ts +66 -6
- package/packages/core/src/ports/tickets/migration.ts +290 -68
- package/packages/core/src/ports/tickets/operations.ts +98 -12
- package/packages/core/src/ports/tickets/priority.ts +55 -0
- package/packages/core/src/ports/tickets/remote-protocol.ts +195 -29
- package/packages/core/src/ports/tickets/remote.ts +188 -13
- package/packages/core/src/ports/tickets/revision.ts +22 -1
- package/packages/core/src/ports/tickets/states.ts +43 -0
- package/packages/core/src/ports/tickets/tree.ts +58 -12
- package/packages/core/src/ports/tickets/update.ts +12 -2
- package/packages/core/src/ports/types.ts +194 -9
- package/packages/core/src/ports/workspace/commit-preservation.ts +163 -25
- package/packages/core/src/ports/workspace/git-worktree.ts +6 -2
- package/packages/core/src/ports/workspace/harvest-execution.ts +4 -2
- package/packages/core/src/ports/workspace/vercel-sandbox.ts +121 -27
- package/packages/core/src/processes/build-runner.ts +101 -22
- package/packages/core/src/processes/dispatcher.ts +1046 -372
- package/packages/core/src/processes/execution-no-progress.ts +7 -0
- package/packages/core/src/processes/harvest-child.ts +4 -2
- package/packages/core/src/processes/harvest-execution-state.ts +104 -0
- package/packages/core/src/processes/harvest-runner.ts +263 -25
- package/packages/core/src/processes/harvest.ts +5 -8
- package/packages/core/src/processes/tick-publication.ts +12 -2
- package/packages/core/src/processes/ticket-scan-schedule.ts +78 -0
- package/packages/core/src/processes/workspace-preservation.ts +36 -1
- package/packages/core/src/runtime-identity.ts +10 -2
- package/packages/core/src/scenarios/harness.ts +149 -35
- package/packages/core/src/store/adapter.ts +7 -1
- package/packages/core/src/store/contract.ts +83 -2
- package/packages/core/src/store/digest.ts +32 -1
- package/packages/core/src/store/reduced-reads.ts +10 -0
- package/packages/core/src/store/reducer-value-shapes.json +4471 -3427
- package/packages/core/src/store/remote/protocol.ts +2 -0
- package/packages/core/src/store/remote/released-clients.json +22 -0
- package/packages/core/src/store/remote/released-reducer-values/1.5.0.json +26924 -0
- package/packages/core/src/store/remote/released-reducer-values/1.6.0.json +27173 -0
- package/packages/core/src/store/remote/released-reducer-values/index.ts +4 -0
- package/packages/core/src/store/repo-state-events.ts +2 -0
- package/packages/core/src/store/types.ts +5 -0
- package/packages/core/src/testing/dispatch-read-budget.ts +729 -123
- package/packages/core/src/testing/index.ts +18 -1
- package/packages/core/src/testing/presence-history.ts +79 -0
- package/packages/core/src/testing/reduced-read-budget.ts +1424 -33
- package/packages/core/src/testing/upgrade-generations.ts +77 -0
- package/skills/code-review/SKILL.md +4 -3
- package/skills/finalize/SKILL.md +18 -2
- package/skills/guide/SKILL.md +417 -143
- package/skills/guide/references/accounts.md +9 -0
- package/skills/guide/references/integration-tree.md +91 -28
- package/skills/guide/references/merge-policy.md +28 -9
- package/skills/guide/references/operator-api.md +57 -20
- package/skills/guide/references/plugin-authoring.md +89 -8
- package/skills/guide/references/remote-store-protocol.md +39 -11
- package/skills/guide/references/remote-ticket-protocol.md +126 -12
- package/skills/guide/references/restacking.md +24 -6
- package/skills/guide/references/setup.md +19 -13
- package/skills/guide/references/spec-standard.md +2 -1
- package/skills/guide/references/ticket-dependencies.md +26 -8
- package/skills/guide/references/ticket-migration.md +70 -7
- package/skills/harvest-review/SKILL.md +4 -3
- package/skills/implement/SKILL.md +20 -1
- package/skills/operate/SKILL.md +149 -35
- package/skills/plan/SKILL.md +1 -1
- package/skills/reconcile/SKILL.md +5 -4
- package/skills/spec/SKILL.md +15 -2
- package/skills/tickets/SKILL.md +116 -37
- package/templates/autobuild.toml +5 -0
- package/templates/hosted-service/package.json +2 -2
|
@@ -3,6 +3,7 @@ import { formatHandoff } from './handoff'
|
|
|
3
3
|
import { handPushedLabel, handPushedText } from './hand-pushed'
|
|
4
4
|
import { integrationBarCells } from './integration-row'
|
|
5
5
|
import { capacityExplanation } from '../../kernel/dispatch-capacity'
|
|
6
|
+
import { NO_DISPATCHER_RUN_LINE, activeCounterText } from './configuration'
|
|
6
7
|
import { treeVocabulary, consentQueue } from './tree'
|
|
7
8
|
/**
|
|
8
9
|
* The dashboard's other pure half: model → `string[]`. No terminal, no state,
|
|
@@ -73,7 +74,11 @@ export interface RenderOpts {
|
|
|
73
74
|
* must pass `paintableRows(rows)`, not `rows`. This module cannot enforce
|
|
74
75
|
* that — it counts lines and knows nothing of the region's trailing newline.
|
|
75
76
|
*
|
|
76
|
-
*
|
|
77
|
+
* A list-view frame given a height fills it exactly: the body region is
|
|
78
|
+
* padded so the legend (or prompt panel) occupies the last lines.
|
|
79
|
+
*
|
|
80
|
+
* Absent ⇒ unbounded and unpadded, for callers that are not painting a
|
|
81
|
+
* screen.
|
|
77
82
|
*/
|
|
78
83
|
height?: number
|
|
79
84
|
}
|
|
@@ -466,6 +471,9 @@ function renderBuild(
|
|
|
466
471
|
),
|
|
467
472
|
)
|
|
468
473
|
}
|
|
474
|
+
if (build.alert)
|
|
475
|
+
for (const line of wrappedText(build.alert.text, Math.max(1, width - 4), ''))
|
|
476
|
+
lines.push(paint(` ! ${line}`, build.alert.tone, color))
|
|
469
477
|
// Setup failures and blocker questions are dense-list previews. Their model
|
|
470
478
|
// strings remain untouched; newline-aware wrapping and capping happen only
|
|
471
479
|
// at this presentation seam.
|
|
@@ -1620,8 +1628,8 @@ function renderDashboardContent(model: DashboardModel, opts: RenderOpts): string
|
|
|
1620
1628
|
paint('Autobuild', 'bold', color),
|
|
1621
1629
|
displayText(basename(model.repo)),
|
|
1622
1630
|
paint(
|
|
1623
|
-
`
|
|
1624
|
-
`
|
|
1631
|
+
`triage ${model.triage ?? '–'} | queue ${model.queued} | ` +
|
|
1632
|
+
`active ${activeCounterText(model)}${model.configuration === 'no-dispatcher-run' ? '' : capacityExplanation(model.capacity)}`,
|
|
1625
1633
|
'dim',
|
|
1626
1634
|
color,
|
|
1627
1635
|
),
|
|
@@ -1649,6 +1657,9 @@ function renderDashboardContent(model: DashboardModel, opts: RenderOpts): string
|
|
|
1649
1657
|
summary,
|
|
1650
1658
|
toggles,
|
|
1651
1659
|
...standbyLine(model, color, width),
|
|
1660
|
+
...(model.configuration === 'no-dispatcher-run'
|
|
1661
|
+
? [truncate(paint(` ${NO_DISPATCHER_RUN_LINE}`, 'dim', color), width)]
|
|
1662
|
+
: []),
|
|
1652
1663
|
...(upgradeNotice === undefined ? [] : [upgradeNotice]),
|
|
1653
1664
|
...runtimeNoticeLines(model, color, width),
|
|
1654
1665
|
...warnings,
|
|
@@ -1747,13 +1758,14 @@ function renderDashboardContent(model: DashboardModel, opts: RenderOpts): string
|
|
|
1747
1758
|
|
|
1748
1759
|
// Brute force is intentional and tiny (dashboard row counts are bounded
|
|
1749
1760
|
// by operator workload): choose the largest contiguous whole-row window
|
|
1750
|
-
// containing selection, with explicit omission notices.
|
|
1751
|
-
//
|
|
1761
|
+
// containing selection, with explicit omission notices. Each notice
|
|
1762
|
+
// costs two rows: the notice and the blank line separating it from the
|
|
1763
|
+
// builds. Harvest and builds participate identically.
|
|
1752
1764
|
let best: { start: number; end: number; count: number; used: number } | undefined
|
|
1753
1765
|
for (let start = 0; start <= selectedIndex; start += 1) {
|
|
1754
1766
|
for (let end = selectedIndex; end < rows.length; end += 1) {
|
|
1755
1767
|
const rowLines = prefix[end + 1]! - prefix[start]! + (end - start)
|
|
1756
|
-
const notices = (start > 0 ?
|
|
1768
|
+
const notices = (start > 0 ? 2 : 0) + (end < rows.length - 1 ? 2 : 0)
|
|
1757
1769
|
const used = rowLines + notices
|
|
1758
1770
|
if (used > bodyBudget) continue
|
|
1759
1771
|
const count = end - start + 1
|
|
@@ -1770,33 +1782,36 @@ function renderDashboardContent(model: DashboardModel, opts: RenderOpts): string
|
|
|
1770
1782
|
if (best !== undefined) {
|
|
1771
1783
|
body = []
|
|
1772
1784
|
if (best.start > 0) {
|
|
1773
|
-
body.push(overflowNotice(`${best.start} more above`, color, width))
|
|
1785
|
+
body.push(overflowNotice(`${best.start} more above`, color, width), '')
|
|
1774
1786
|
}
|
|
1775
1787
|
body.push(...flattenRows(rows.slice(best.start, best.end + 1)))
|
|
1776
1788
|
const below = rows.length - best.end - 1
|
|
1777
1789
|
if (below > 0) {
|
|
1778
|
-
body.push(overflowNotice(`and ${below} more below`, color, width))
|
|
1790
|
+
body.push('', overflowNotice(`and ${below} more below`, color, width))
|
|
1779
1791
|
}
|
|
1780
1792
|
} else {
|
|
1781
|
-
//
|
|
1782
|
-
// identity visible, then spend remaining
|
|
1793
|
+
// No whole-row window fits once notice gaps are counted. Keep the
|
|
1794
|
+
// selected row's selectable identity visible, then spend remaining
|
|
1795
|
+
// rows on detail and omission. Every notice keeps its one-line gap
|
|
1796
|
+
// from the detail; with no room for a notice and its gap, the
|
|
1797
|
+
// selection wins.
|
|
1783
1798
|
const selectedLines = rows[selectedIndex]!.lines
|
|
1784
1799
|
const above = selectedIndex
|
|
1785
1800
|
const below = rows.length - selectedIndex - 1
|
|
1786
|
-
let
|
|
1787
|
-
if (bodyBudget
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
const detailCapacity = Math.max(1, bodyBudget - noticeLines)
|
|
1801
|
+
let notices = 0
|
|
1802
|
+
if (bodyBudget >= 5 && above > 0 && below > 0) notices = 2
|
|
1803
|
+
else if (bodyBudget >= 3 && (above > 0 || below > 0)) notices = 1
|
|
1804
|
+
const detailCapacity = Math.max(1, bodyBudget - notices * 2)
|
|
1791
1805
|
body = []
|
|
1792
|
-
if (
|
|
1793
|
-
body.push(overflowNotice(`${above} more above`, color, width))
|
|
1806
|
+
if (notices === 2) {
|
|
1807
|
+
body.push(overflowNotice(`${above} more above`, color, width), '')
|
|
1794
1808
|
}
|
|
1795
1809
|
body.push(...selectedLines.slice(0, detailCapacity))
|
|
1796
|
-
if (
|
|
1797
|
-
body.push(overflowNotice(`and ${below} more below`, color, width))
|
|
1798
|
-
} else if (
|
|
1810
|
+
if (notices === 2) {
|
|
1811
|
+
body.push('', overflowNotice(`and ${below} more below`, color, width))
|
|
1812
|
+
} else if (notices === 1) {
|
|
1799
1813
|
body.push(
|
|
1814
|
+
'',
|
|
1800
1815
|
overflowNotice(
|
|
1801
1816
|
above > 0 && below > 0
|
|
1802
1817
|
? `${above} above, ${below} below`
|
|
@@ -1814,8 +1829,14 @@ function renderDashboardContent(model: DashboardModel, opts: RenderOpts): string
|
|
|
1814
1829
|
}
|
|
1815
1830
|
|
|
1816
1831
|
// Both blanks are structural frame chrome, independent of warning/upgrade
|
|
1817
|
-
// content, and are charged exactly once in the body budget above.
|
|
1818
|
-
|
|
1832
|
+
// content, and are charged exactly once in the body budget above. A bounded
|
|
1833
|
+
// frame pads its body region to the budget so the controls are pinned to
|
|
1834
|
+
// the bottom rows; an unbounded frame is not padded.
|
|
1835
|
+
const fill =
|
|
1836
|
+
height === undefined
|
|
1837
|
+
? 0
|
|
1838
|
+
: Math.max(0, height - top.length - separatorCount - body.length - controls.length)
|
|
1839
|
+
return [...top, '', ...body, ...Array.from({ length: fill }, () => ''), '', ...controls]
|
|
1819
1840
|
}
|
|
1820
1841
|
|
|
1821
1842
|
/** Render the dashboard inside a fixed one-column horizontal gutter.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { normalizeEffectiveConfigArtifact } from '../config/effective-artifact'
|
|
2
|
-
import { migrationIdentity
|
|
2
|
+
import { migrationIdentity } from '../kernel/ticket-migrations'
|
|
3
3
|
import type { DispatchUpgradeState } from '../kernel/dispatch-upgrade'
|
|
4
4
|
import { releaseDispatchPresentation } from './dispatch-presentation-ownership'
|
|
5
5
|
import {
|
|
@@ -26,7 +26,6 @@ import { humanActor } from '../events/envelope'
|
|
|
26
26
|
import type { RepositoryEvent } from '../events/repository'
|
|
27
27
|
import { reduceDispatchStatus, type DispatchStatus } from '../kernel/dispatch-status'
|
|
28
28
|
import type { BuildState } from '../kernel/reducer'
|
|
29
|
-
import { unclaimedObservationCount } from '../processes/harvest'
|
|
30
29
|
import {
|
|
31
30
|
controlHarvestRun,
|
|
32
31
|
OperatorControlError,
|
|
@@ -38,6 +37,7 @@ import { systemClock } from '../store/types'
|
|
|
38
37
|
import { BuildControlError, buildControlUser, controlBuild } from './build-control'
|
|
39
38
|
import { bulkControlReport, bulkControlRepository } from './bulk-control'
|
|
40
39
|
import { deleteBefore, insertText, moveCursor, type ComposerMotion } from './dashboard/composer'
|
|
40
|
+
import { NO_DISPATCHER_RUN_LINE } from './dashboard/configuration'
|
|
41
41
|
import { dashboardBuildControl } from './dashboard/actions'
|
|
42
42
|
import {
|
|
43
43
|
buildDashboardFromProjected,
|
|
@@ -72,6 +72,10 @@ import {
|
|
|
72
72
|
} from './dispatch-process'
|
|
73
73
|
|
|
74
74
|
import type { TicketSource } from '../ports/types'
|
|
75
|
+
import { ticketLifecycle } from '../ports/tickets/lifecycle'
|
|
76
|
+
import { boundedStateCount } from '../ports/tickets/states'
|
|
77
|
+
import { TRIAGE_COUNT_REFRESH_MS } from './triage-count-sampler'
|
|
78
|
+
import type { ControlTickets } from './ticket'
|
|
75
79
|
|
|
76
80
|
const PAINT_MS = 250
|
|
77
81
|
const ABORTABLE_STATUSES = new Set(['queued', 'running', 'collecting', 'paused', 'blocked'])
|
|
@@ -110,6 +114,10 @@ export interface DispatchFrontendOptions {
|
|
|
110
114
|
checkout?: string
|
|
111
115
|
storeRef: string
|
|
112
116
|
store: BuildStore
|
|
117
|
+
/** Opens the tickets one control reads, fresh for every control so node
|
|
118
|
+
* completeness sees the current configured rejected role. */
|
|
119
|
+
controlTickets?: () => ControlTickets
|
|
120
|
+
/** Optional display-only source for viewer triage counts. */
|
|
113
121
|
ticketSource?: () => Promise<TicketSource>
|
|
114
122
|
env: Record<string, string | undefined>
|
|
115
123
|
terminal: TerminalOut
|
|
@@ -148,9 +156,6 @@ export class DispatchFrontend {
|
|
|
148
156
|
private config: Config | undefined
|
|
149
157
|
private configRef: string | undefined
|
|
150
158
|
private configRevision = 0
|
|
151
|
-
/** Display-only pressure is sampled by the Store-only frontend. Undefined
|
|
152
|
-
* means no factual sample has succeeded yet; failures retain the last value. */
|
|
153
|
-
private observationCount: number | undefined
|
|
154
159
|
private model: DashboardModel | undefined
|
|
155
160
|
private selection: DashboardSelection | undefined = { kind: 'global' }
|
|
156
161
|
private view: DashboardView | undefined
|
|
@@ -175,6 +180,11 @@ export class DispatchFrontend {
|
|
|
175
180
|
private viewerFacts: RepositoryReadFacts | undefined
|
|
176
181
|
private viewerPosition: string | undefined
|
|
177
182
|
private viewerReadAt = -Infinity
|
|
183
|
+
/** The viewer's own last successful triage count; never published status. */
|
|
184
|
+
private viewerTriage: number | undefined
|
|
185
|
+
private viewerTriageAt = -Infinity
|
|
186
|
+
private viewerTriageRead: Promise<void> | undefined
|
|
187
|
+
private viewerTicketSource: Promise<TicketSource> | undefined
|
|
178
188
|
private lastPlainFrame: string | undefined
|
|
179
189
|
|
|
180
190
|
constructor(private readonly opts: DispatchFrontendOptions) {
|
|
@@ -362,10 +372,43 @@ export class DispatchFrontend {
|
|
|
362
372
|
repositoryFacts: RepositoryReadFacts
|
|
363
373
|
status: DispatchStatus
|
|
364
374
|
config: Config
|
|
365
|
-
observationCount: number
|
|
366
375
|
snapshot: DashboardPollSnapshot
|
|
367
376
|
}>()
|
|
368
377
|
|
|
378
|
+
/** A viewer's display-only triage count: at most one bounded `countStates`
|
|
379
|
+
* request per 60 s (`TRIAGE_COUNT_REFRESH_MS`) while presenting, in the
|
|
380
|
+
* background so a stalled ticket service never holds a frame. Failures keep
|
|
381
|
+
* the last good value. */
|
|
382
|
+
private pollViewerTriage(config: Config): void {
|
|
383
|
+
const open = this.opts.ticketSource ?? this.opts.controlTickets?.().ticketSource
|
|
384
|
+
// A one-shot frame paints before any background read could land.
|
|
385
|
+
if (!this.opts.viewer || this.opts.once || open === undefined || this.presentationRestored)
|
|
386
|
+
return
|
|
387
|
+
const now = this.clock().getTime()
|
|
388
|
+
if (this.viewerTriageRead !== undefined || now - this.viewerTriageAt < TRIAGE_COUNT_REFRESH_MS)
|
|
389
|
+
return
|
|
390
|
+
this.viewerTriageAt = now
|
|
391
|
+
const name = ticketLifecycle(config.tickets).triage
|
|
392
|
+
this.viewerTriageRead = (async () => {
|
|
393
|
+
try {
|
|
394
|
+
this.viewerTicketSource ??= open()
|
|
395
|
+
let source: TicketSource
|
|
396
|
+
try {
|
|
397
|
+
source = await this.viewerTicketSource
|
|
398
|
+
} catch (error) {
|
|
399
|
+
this.viewerTicketSource = undefined
|
|
400
|
+
throw error
|
|
401
|
+
}
|
|
402
|
+
const count = await boundedStateCount(source, name)
|
|
403
|
+
if (count !== undefined) this.viewerTriage = count
|
|
404
|
+
} catch {
|
|
405
|
+
// Display only: the header keeps its last good count, or `–`.
|
|
406
|
+
} finally {
|
|
407
|
+
this.viewerTriageRead = undefined
|
|
408
|
+
}
|
|
409
|
+
})()
|
|
410
|
+
}
|
|
411
|
+
|
|
369
412
|
private async readFrame(): Promise<void> {
|
|
370
413
|
if (this.refresh !== undefined && !this.refresh.admitted) return
|
|
371
414
|
let sampledPosition: string | undefined
|
|
@@ -402,7 +445,9 @@ export class DispatchFrontend {
|
|
|
402
445
|
this.outputFrame(
|
|
403
446
|
renderViewerNotice(
|
|
404
447
|
this.opts.viewer,
|
|
405
|
-
|
|
448
|
+
repositoryFacts.config.run === undefined
|
|
449
|
+
? NO_DISPATCHER_RUN_LINE
|
|
450
|
+
: (status.warningNotice ?? 'Waiting for dispatcher configuration'),
|
|
406
451
|
this.opts.terminal.columns,
|
|
407
452
|
paintableRows(this.opts.terminal.rows),
|
|
408
453
|
),
|
|
@@ -413,18 +458,6 @@ export class DispatchFrontend {
|
|
|
413
458
|
return undefined
|
|
414
459
|
}
|
|
415
460
|
const config = await this.loadConfig(ref.kind, ref.rev)
|
|
416
|
-
let observationCount: number
|
|
417
|
-
try {
|
|
418
|
-
observationCount = unclaimedObservationCount({
|
|
419
|
-
digests: await this.reader.getRepoBuildDigests(this.opts.repo),
|
|
420
|
-
harvestEvents: this.opts.viewer ? repositoryFacts.harvest : repositoryEvents,
|
|
421
|
-
})
|
|
422
|
-
} catch {
|
|
423
|
-
// Incomplete snapshots never acknowledge the sampled position.
|
|
424
|
-
this.syncControls()
|
|
425
|
-
this.paint()
|
|
426
|
-
return undefined
|
|
427
|
-
}
|
|
428
461
|
this.cache ??= new DashboardBuildPollCache(this.reader, this.opts.repo, config)
|
|
429
462
|
const snapshot = await this.cache.refresh(config, this.configRevision, fullEnrichment)
|
|
430
463
|
if (!this.opts.once && !this.opts.viewer)
|
|
@@ -437,7 +470,6 @@ export class DispatchFrontend {
|
|
|
437
470
|
upgrades,
|
|
438
471
|
status,
|
|
439
472
|
config,
|
|
440
|
-
observationCount,
|
|
441
473
|
snapshot,
|
|
442
474
|
}
|
|
443
475
|
},
|
|
@@ -445,11 +477,11 @@ export class DispatchFrontend {
|
|
|
445
477
|
if (frame === undefined) return
|
|
446
478
|
let { repositoryEvents, repositoryFacts, upgrades, status } = frame
|
|
447
479
|
const { config, snapshot } = frame
|
|
480
|
+
this.pollViewerTriage(config)
|
|
448
481
|
const standby =
|
|
449
482
|
this.opts.once || this.opts.viewer
|
|
450
483
|
? undefined
|
|
451
484
|
: this.standbyResolver.current(this.runId, status.yieldedHolder, this.clock())
|
|
452
|
-
this.observationCount = frame.observationCount
|
|
453
485
|
this.refresh?.activity(snapshot.states.size > 0)
|
|
454
486
|
|
|
455
487
|
if (this.resumePrompt !== undefined) {
|
|
@@ -496,15 +528,16 @@ export class DispatchFrontend {
|
|
|
496
528
|
snapshot.capacityBuilds ?? [],
|
|
497
529
|
config.capacity,
|
|
498
530
|
this.clock(),
|
|
499
|
-
migrationIdentity(
|
|
500
|
-
this.opts.viewer
|
|
501
|
-
? repositoryFacts.ticketMigrations
|
|
502
|
-
: ticketMigrationsReducer.reduce(repositoryEvents),
|
|
503
|
-
config.tickets.source,
|
|
504
|
-
),
|
|
531
|
+
migrationIdentity(repositoryFacts.ticketMigrations, config.tickets.source),
|
|
505
532
|
),
|
|
506
|
-
|
|
507
|
-
|
|
533
|
+
// A viewer shows only its own read; headless ticks publish no count.
|
|
534
|
+
...(this.opts.viewer
|
|
535
|
+
? this.viewerTriage !== undefined
|
|
536
|
+
? { triage: this.viewerTriage }
|
|
537
|
+
: {}
|
|
538
|
+
: status.triage !== undefined
|
|
539
|
+
? { triage: status.triage }
|
|
540
|
+
: {}),
|
|
508
541
|
...(status.availableUpgrade !== undefined
|
|
509
542
|
? { availableUpgrade: status.availableUpgrade }
|
|
510
543
|
: {}),
|
|
@@ -807,7 +840,7 @@ export class DispatchFrontend {
|
|
|
807
840
|
): Promise<void> {
|
|
808
841
|
const result = await controlBuild({
|
|
809
842
|
store: this.opts.store,
|
|
810
|
-
|
|
843
|
+
...this.opts.controlTickets?.(),
|
|
811
844
|
repo: this.opts.repo,
|
|
812
845
|
slug,
|
|
813
846
|
env: this.opts.env,
|
|
@@ -1,33 +1,47 @@
|
|
|
1
1
|
import type { Exec } from '../ports/workspace/git-worktree'
|
|
2
2
|
import type { DispatchPlacement } from '../kernel/dispatch-placement'
|
|
3
3
|
import { RemoteBuildStore } from '../store/remote/client'
|
|
4
|
-
import { resolveRepoState, isRemoteStoreRef } from './repo-state'
|
|
4
|
+
import { resolveRepoState, isRemoteStoreRef, type RepoStatePaths } from './repo-state'
|
|
5
5
|
import { projectToken } from './project-credentials'
|
|
6
6
|
|
|
7
7
|
export const TAKEOVER_WARNING =
|
|
8
8
|
'Warning: --takeover dispatches locally and can displace the hosted dispatcher.'
|
|
9
9
|
|
|
10
|
+
function redactDetail(cause: unknown, secrets: string[]): string {
|
|
11
|
+
let detail = cause instanceof Error ? cause.message : String(cause)
|
|
12
|
+
for (const secret of secrets) if (secret) detail = detail.split(secret).join('[redacted]')
|
|
13
|
+
return detail.replace(/https?:\/\/[^\s]+/g, (url) => {
|
|
14
|
+
try {
|
|
15
|
+
const parsed = new URL(url)
|
|
16
|
+
return `${parsed.origin}${parsed.pathname}`
|
|
17
|
+
} catch {
|
|
18
|
+
return '[redacted URL]'
|
|
19
|
+
}
|
|
20
|
+
})
|
|
21
|
+
}
|
|
22
|
+
|
|
10
23
|
export class DispatchPlacementStartupError extends Error {
|
|
11
24
|
readonly code = 'DISPATCH_PLACEMENT_UNREADABLE'
|
|
12
25
|
constructor(cause: unknown, secrets: string[] = []) {
|
|
13
|
-
let detail = cause instanceof Error ? cause.message : String(cause)
|
|
14
|
-
for (const secret of secrets) if (secret) detail = detail.split(secret).join('[redacted]')
|
|
15
|
-
detail = detail.replace(/https?:\/\/[^\s]+/g, (url) => {
|
|
16
|
-
try {
|
|
17
|
-
const parsed = new URL(url)
|
|
18
|
-
return `${parsed.origin}${parsed.pathname}`
|
|
19
|
-
} catch {
|
|
20
|
-
return '[redacted URL]'
|
|
21
|
-
}
|
|
22
|
-
})
|
|
23
26
|
super(
|
|
24
|
-
`Cannot read dispatch placement: ${
|
|
27
|
+
`Cannot read dispatch placement: ${redactDetail(cause, secrets)}. Use --viewer to watch, or --takeover to dispatch locally and potentially displace hosted dispatch.`,
|
|
25
28
|
{ cause },
|
|
26
29
|
)
|
|
27
30
|
this.name = 'DispatchPlacementStartupError'
|
|
28
31
|
}
|
|
29
32
|
}
|
|
30
33
|
|
|
34
|
+
export class DispatchRepositoryResolutionError extends Error {
|
|
35
|
+
readonly code = 'DISPATCH_REPOSITORY_UNRESOLVED'
|
|
36
|
+
constructor(cause: unknown, secrets: string[] = []) {
|
|
37
|
+
super(
|
|
38
|
+
`Cannot resolve the repository's store selection for dispatch: ${redactDetail(cause, secrets)}. Check --store, AB_STORE, and autobuild.toml [store].`,
|
|
39
|
+
{ cause },
|
|
40
|
+
)
|
|
41
|
+
this.name = 'DispatchRepositoryResolutionError'
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
31
45
|
export interface DispatchModeOptions {
|
|
32
46
|
viewer?: boolean
|
|
33
47
|
takeover?: boolean
|
|
@@ -63,16 +77,21 @@ export async function selectDispatchMode(
|
|
|
63
77
|
opts.stderr(TAKEOVER_WARNING)
|
|
64
78
|
return { viewer: false }
|
|
65
79
|
}
|
|
66
|
-
let
|
|
67
|
-
let placement: DispatchPlacement
|
|
80
|
+
let state: RepoStatePaths
|
|
68
81
|
try {
|
|
69
|
-
|
|
82
|
+
state = await (deps.resolve ?? resolveRepoState)({
|
|
70
83
|
targetRepo: opts.targetRepo,
|
|
71
84
|
exec: opts.exec,
|
|
72
85
|
...(opts.storeRef !== undefined ? { storeRef: opts.storeRef } : {}),
|
|
73
86
|
...(opts.env.AB_STORE !== undefined ? { envStore: opts.env.AB_STORE } : {}),
|
|
74
87
|
})
|
|
75
|
-
|
|
88
|
+
} catch (cause) {
|
|
89
|
+
throw new DispatchRepositoryResolutionError(cause, [opts.env.AB_TOKEN ?? ''])
|
|
90
|
+
}
|
|
91
|
+
if (!isRemoteStoreRef(state.storeRef)) return { viewer: false }
|
|
92
|
+
let token: string | undefined
|
|
93
|
+
let placement: DispatchPlacement
|
|
94
|
+
try {
|
|
76
95
|
const repo = opts.repo ?? state.repo
|
|
77
96
|
token = projectToken(state.storeRef, repo, opts.env)
|
|
78
97
|
const reader = (deps.open ?? ((url, token) => new RemoteBuildStore({ url, token })))(
|
|
@@ -207,6 +207,8 @@ async function runGenerationPreflight(
|
|
|
207
207
|
)
|
|
208
208
|
return false
|
|
209
209
|
prepared = true
|
|
210
|
+
// The successor claims with its own configured lease timeout.
|
|
211
|
+
let leaseTtlMs = 60_000
|
|
210
212
|
for (;;) {
|
|
211
213
|
signal.throwIfAborted()
|
|
212
214
|
const current = (await readDispatchUpgrade(opened.store, opened.repo)).value.runs[handoff.run]
|
|
@@ -228,6 +230,7 @@ async function runGenerationPreflight(
|
|
|
228
230
|
facts.stop.payload.outcome === 'normal'))
|
|
229
231
|
if (ready) {
|
|
230
232
|
const config = await loadConfig(join(launch.checkout, 'autobuild.toml'))
|
|
233
|
+
leaseTtlMs = config.policy.dispatchLeaseTimeoutSeconds * 1000
|
|
231
234
|
const accounts = selectedExecutionAccounts(config)
|
|
232
235
|
const available = inspectLocalAccountEnvironment(
|
|
233
236
|
new LocalCredentials(join(launch.checkout, '.autobuild')),
|
|
@@ -245,7 +248,7 @@ async function runGenerationPreflight(
|
|
|
245
248
|
return false
|
|
246
249
|
}
|
|
247
250
|
}
|
|
248
|
-
if (ready && (await opened.store.claimRepoLease(opened.repo, launch.run,
|
|
251
|
+
if (ready && (await opened.store.claimRepoLease(opened.repo, launch.run, leaseTtlMs))) {
|
|
249
252
|
await opened.store.appendRepo(opened.repo, {
|
|
250
253
|
actor: DISPATCHER,
|
|
251
254
|
type: 'dispatcher.takeover',
|
|
@@ -2,6 +2,7 @@ import { CursorTooOldError, REPOSITORY_TAIL_WINDOW } from '../store/event-reads'
|
|
|
2
2
|
import { DISPATCH_HANDOFF_EVENT_TYPES } from '../store/repo-state-events'
|
|
3
3
|
import { type RepositoryEvent, validateRepositoryEventWrite } from '../events/repository'
|
|
4
4
|
import { defineReducer } from '../kernel/incremental'
|
|
5
|
+
import { readRepositoryFacts } from '../store/reduced-reads'
|
|
5
6
|
import { loadReducerSnapshot, persistReducerSnapshotOutcome } from '../store/snapshots'
|
|
6
7
|
import type { BuildStore, Clock } from '../store/types'
|
|
7
8
|
|
|
@@ -44,7 +45,11 @@ export const dispatchFrontendReducer = defineReducer({
|
|
|
44
45
|
})
|
|
45
46
|
|
|
46
47
|
/** One serialized, frontend-only repository projection. The consumed cursor is
|
|
47
|
-
* independent of retained facts: quiet ticks must never survive in the cache.
|
|
48
|
+
* independent of retained facts: quiet ticks must never survive in the cache.
|
|
49
|
+
* Presentation reads canonical repository facts; the dashboard-event cache holds
|
|
50
|
+
* only facts after the feed's restoration point. Without a usable checkpoint,
|
|
51
|
+
* startup and cursor-expiry recovery seed identities from the canonical
|
|
52
|
+
* `repositoryReadFacts` value, never from the journal. */
|
|
48
53
|
export class DispatchRepositoryFeed {
|
|
49
54
|
private cursor = 0
|
|
50
55
|
private ready = false
|
|
@@ -161,15 +166,14 @@ export class DispatchRepositoryFeed {
|
|
|
161
166
|
cursor = snapshot.cursor
|
|
162
167
|
restored = true
|
|
163
168
|
} catch {
|
|
164
|
-
/* A malformed cache uses the
|
|
169
|
+
/* A malformed cache uses the canonical seed. */
|
|
165
170
|
}
|
|
166
171
|
}
|
|
167
172
|
if (!restored) {
|
|
168
|
-
const seed = await this.
|
|
169
|
-
this.validate(seed, 0, false)
|
|
173
|
+
const seed = await this.canonicalSeed(holder)
|
|
170
174
|
incompleteIdentities = true
|
|
171
|
-
retained =
|
|
172
|
-
cursor =
|
|
175
|
+
retained = seed.retained
|
|
176
|
+
cursor = seed.cursor
|
|
173
177
|
}
|
|
174
178
|
delta = await this.readStartupTail(cursor)
|
|
175
179
|
this.validate(delta, cursor, true)
|
|
@@ -212,15 +216,13 @@ export class DispatchRepositoryFeed {
|
|
|
212
216
|
})
|
|
213
217
|
const recovered = next.catch(async (error) => {
|
|
214
218
|
if (!(error instanceof CursorTooOldError)) throw error
|
|
215
|
-
const
|
|
216
|
-
const
|
|
217
|
-
this.validate(seed, 0, false)
|
|
218
|
-
const cursor = Math.max(high, seed.at(-1)?.seq ?? 0)
|
|
219
|
+
const seed = await this.canonicalSeed(this.holder)
|
|
220
|
+
const cursor = seed.cursor
|
|
219
221
|
const delta = await this.readStartupTail(cursor)
|
|
220
222
|
this.validate(delta, cursor, true)
|
|
221
223
|
this.replaceRetained(
|
|
222
224
|
dispatchFrontendReducer.advance(
|
|
223
|
-
{ retained:
|
|
225
|
+
{ retained: seed.retained, incompleteIdentities: true, holder: this.holder },
|
|
224
226
|
delta,
|
|
225
227
|
).retained,
|
|
226
228
|
)
|
|
@@ -236,6 +238,33 @@ export class DispatchRepositoryFeed {
|
|
|
236
238
|
return recovered.then(() => result)
|
|
237
239
|
}
|
|
238
240
|
|
|
241
|
+
/** Missing or unusable presentation state restarts from the canonical reduced
|
|
242
|
+
* repository value: cost is independent of journal and current-run length. */
|
|
243
|
+
private async canonicalSeed(
|
|
244
|
+
holder: string | undefined,
|
|
245
|
+
): Promise<{ cursor: number; retained: RepositoryEvent[] }> {
|
|
246
|
+
const { cursor, value } = await readRepositoryFacts(this.store, this.repo, true)
|
|
247
|
+
const runs = new Map(value.recentRuns)
|
|
248
|
+
const starts = new Map<number, RepositoryEvent>()
|
|
249
|
+
for (const run of [value.latestRun, holder]) {
|
|
250
|
+
const start = run === undefined ? undefined : runs.get(run)?.latestStart
|
|
251
|
+
if (start) starts.set(start.seq, start)
|
|
252
|
+
}
|
|
253
|
+
const sorted = [...starts.values()].sort((a, b) => a.seq - b.seq)
|
|
254
|
+
this.validate(sorted, 0, false)
|
|
255
|
+
if (!Number.isInteger(cursor) || cursor < 0)
|
|
256
|
+
throw new Error('invalid canonical repository cursor')
|
|
257
|
+
if (sorted.some((e) => e.type !== 'dispatcher.run-started' || e.seq > cursor))
|
|
258
|
+
throw new Error('invalid canonical identity')
|
|
259
|
+
return {
|
|
260
|
+
cursor,
|
|
261
|
+
retained: dispatchFrontendReducer.advance(
|
|
262
|
+
{ retained: [], incompleteIdentities: true, holder },
|
|
263
|
+
sorted,
|
|
264
|
+
).retained,
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
239
268
|
private readStartupTail(cursor: number): Promise<RepositoryEvent[]> {
|
|
240
269
|
if (!this.store.getRepositoryTail)
|
|
241
270
|
throw new Error('dashboard restoration requires getRepositoryTail')
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The dispatcher's ticket source (SPEC §3.2): built once per dispatcher
|
|
3
|
+
* process start, before the loop, against the repository's filesystem
|
|
4
|
+
* location rather than its identity.
|
|
5
|
+
*/
|
|
6
|
+
import type { TicketsConfig } from '../config/schema'
|
|
7
|
+
import { normalizeGitRemoteUrl } from '../kernel/origin'
|
|
8
|
+
import type { PluginRegistry } from '../plugins/registry'
|
|
9
|
+
import type { GitHubRequest } from '../ports/forge/github-transport'
|
|
10
|
+
import { createTicketSource } from '../ports/tickets/create'
|
|
11
|
+
import type { TicketSource } from '../ports/types'
|
|
12
|
+
import type { Exec } from '../ports/workspace/git-worktree'
|
|
13
|
+
import type { RepoStatePaths } from './repo-state'
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Construct the dispatcher's ticket source. `state.checkout` is the checkout
|
|
17
|
+
* (or origin mode's scratch root), never the repository identity, so a
|
|
18
|
+
* `github` source resolves its coordinates from the checkout's `origin`.
|
|
19
|
+
* Origin mode supplies its repository directly: its scratch root is no Git
|
|
20
|
+
* checkout.
|
|
21
|
+
*
|
|
22
|
+
* Cost: in checkout mode the `github` and `hosted` sources spend one
|
|
23
|
+
* `git remote get-url origin` spawn; origin mode spends none. It runs once
|
|
24
|
+
* per dispatcher process start, never per tick or config reload, and makes
|
|
25
|
+
* zero store reads.
|
|
26
|
+
*/
|
|
27
|
+
export function dispatcherTicketSource(
|
|
28
|
+
config: TicketsConfig,
|
|
29
|
+
opts: {
|
|
30
|
+
env: Record<string, string | undefined>
|
|
31
|
+
exec: Exec
|
|
32
|
+
/** Origin mode's repository (`--repository` / `AB_REPOSITORY`). */
|
|
33
|
+
repository?: string
|
|
34
|
+
},
|
|
35
|
+
state: Pick<RepoStatePaths, 'checkout'>,
|
|
36
|
+
localStateRoot: string | undefined,
|
|
37
|
+
plugins: PluginRegistry,
|
|
38
|
+
seams: { transport?: GitHubRequest } = {},
|
|
39
|
+
): Promise<TicketSource> {
|
|
40
|
+
return createTicketSource(config, opts.env, state.checkout, localStateRoot, plugins, {
|
|
41
|
+
exec: opts.exec,
|
|
42
|
+
...(opts.repository !== undefined
|
|
43
|
+
? { repository: normalizeGitRemoteUrl(opts.repository) }
|
|
44
|
+
: {}),
|
|
45
|
+
...seams,
|
|
46
|
+
})
|
|
47
|
+
}
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
} from './dispatch-upgrade-target'
|
|
11
11
|
import type { CachedRuntime } from './dispatch-runtime-cache'
|
|
12
12
|
import { releasePreparedRuntime, reservePreparedRuntime } from './dispatch-runtime-use'
|
|
13
|
+
import { isRepositoryAuthorityLapse } from './repo-lease'
|
|
13
14
|
import { captureRuntimeIdentity } from '../runtime-identity'
|
|
14
15
|
import type { DispatchUpgradeState, Handoff } from '../kernel/dispatch-upgrade'
|
|
15
16
|
|
|
@@ -195,6 +196,8 @@ export class DispatchUpgradeController {
|
|
|
195
196
|
}
|
|
196
197
|
} catch (error) {
|
|
197
198
|
if (preparation.signal.aborted || this.abort.signal.aborted) return
|
|
199
|
+
// A fenced effect during a lapsed repository lease skips the check.
|
|
200
|
+
if (isRepositoryAuthorityLapse(error)) return
|
|
198
201
|
if (error instanceof TargetResolutionError) target = error.target
|
|
199
202
|
if (target && !this.failed.has(target.key)) {
|
|
200
203
|
await this.input.append({
|