@defrex/autobuild 1.11.1 → 1.13.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 +601 -203
- package/bin/ab-build-runner.ts +8 -0
- package/docs/answering-blocked-builds.md +32 -2
- package/docs/architecture.md +188 -57
- package/docs/assets/headline-wide.png +0 -0
- package/docs/cli.md +1 -1
- package/docs/configuration.md +120 -23
- package/docs/dispatcher.md +19 -8
- package/docs/integration-overview.md +1 -1
- package/docs/integration-tree.md +33 -18
- package/docs/merge-policy.md +7 -2
- package/docs/operating.md +5 -3
- package/docs/operator-api.md +48 -25
- package/docs/operator-surfaces.md +39 -3
- package/docs/optimization-nodes.md +10 -8
- package/docs/plugin-authoring.md +46 -18
- package/docs/remote-store-protocol.md +51 -12
- package/docs/remote-ticket-protocol.md +85 -38
- package/docs/restacking.md +48 -3
- package/docs/setup.md +2 -1
- package/docs/ticket-migration.md +2 -2
- package/docs/ticket-sources.md +23 -8
- package/docs/tickets.md +4 -4
- package/docs/troubleshooting.md +17 -2
- package/docs/verification.md +3 -1
- package/package.json +3 -3
- package/packages/core/src/cli/ambient-errors.ts +17 -0
- package/packages/core/src/cli/bounded-io.ts +174 -0
- package/packages/core/src/cli/build-control.ts +72 -6
- package/packages/core/src/cli/dashboard/actions.ts +4 -0
- package/packages/core/src/cli/dashboard/integration-row.ts +43 -19
- package/packages/core/src/cli/dashboard/model.ts +93 -29
- package/packages/core/src/cli/dashboard/poll.ts +231 -34
- package/packages/core/src/cli/dashboard/queue.ts +21 -10
- package/packages/core/src/cli/dashboard/render.ts +14 -37
- package/packages/core/src/cli/dashboard/row-text.ts +26 -8
- package/packages/core/src/cli/dashboard/tone-ansi.ts +39 -0
- package/packages/core/src/cli/dashboard/vocabulary.ts +165 -20
- package/packages/core/src/cli/dispatch-frontend.ts +2 -1
- package/packages/core/src/cli/dispatch-handoff.ts +41 -10
- package/packages/core/src/cli/dispatch-launch-contract.ts +5 -0
- package/packages/core/src/cli/dispatch-launcher-cadence.ts +80 -0
- package/packages/core/src/cli/dispatch-launcher.ts +9 -10
- package/packages/core/src/cli/dispatch-preflight.ts +12 -3
- package/packages/core/src/cli/dispatch-release-observer.ts +53 -0
- package/packages/core/src/cli/dispatch-runtime-cache.ts +204 -82
- package/packages/core/src/cli/dispatch-runtime-dependencies.ts +250 -43
- package/packages/core/src/cli/dispatch-tickets.ts +33 -12
- package/packages/core/src/cli/dispatch-upgrade-install.ts +36 -16
- package/packages/core/src/cli/dispatch-upgrade-source.ts +8 -2
- package/packages/core/src/cli/dispatch-yield-observer.ts +82 -0
- package/packages/core/src/cli/dispatch.ts +595 -149
- package/packages/core/src/cli/env.ts +2 -15
- package/packages/core/src/cli/help.ts +43 -28
- package/packages/core/src/cli/main.ts +11 -7
- package/packages/core/src/cli/production-store.ts +102 -0
- package/packages/core/src/cli/publication-settlement.ts +4 -0
- package/packages/core/src/cli/remote-poll.ts +22 -5
- package/packages/core/src/cli/repo-state.ts +2 -3
- package/packages/core/src/cli/repository-status.ts +44 -28
- package/packages/core/src/cli/sessionless-store.ts +26 -0
- package/packages/core/src/cli/status.ts +188 -47
- package/packages/core/src/cli/store-opening.ts +26 -57
- package/packages/core/src/cli/store-ref.ts +6 -1
- package/packages/core/src/cli/ticket-start.ts +3 -3
- package/packages/core/src/cli/ticket.ts +12 -11
- package/packages/core/src/cli/wait.ts +8 -28
- package/packages/core/src/cli/watch.ts +113 -50
- package/packages/core/src/config/reference-metadata.ts +7 -1
- package/packages/core/src/config/reference.ts +5 -2
- package/packages/core/src/config/schema.ts +51 -16
- package/packages/core/src/distribution-packaging.ts +156 -18
- package/packages/core/src/events/catalog-identity.ts +28 -0
- package/packages/core/src/events/catalog.ts +3 -9
- package/packages/core/src/events/compatibility.ts +2 -30
- package/packages/core/src/events/payloads.ts +85 -14
- package/packages/core/src/events/policy.ts +3 -0
- package/packages/core/src/events/repository.ts +15 -4
- package/packages/core/src/events/sessions.ts +1 -1
- package/packages/core/src/events/validation-error.ts +12 -0
- package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +36 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/0a10010ee5cf2e47.json +577 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/227701361be6d1e0.json +490 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/3064e337cc75f8d6.json +310 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/76e5043bae7a80ab.json +86 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/87a917802870bbed.json +87 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/9d85616e5b9e24c1.json +500 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/a1e90a969d32a367.json +307 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/c7c94fbe7f63cf07.json +84 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/da3bc91c49211eab.json +310 -0
- package/packages/core/src/kernel/auto-merge-default.ts +2 -1
- package/packages/core/src/kernel/capacity-build.ts +21 -0
- package/packages/core/src/kernel/clean-restack-policy.ts +40 -0
- package/packages/core/src/kernel/discard-in-flight.ts +13 -0
- package/packages/core/src/kernel/dispatch-capacity.ts +578 -235
- package/packages/core/src/kernel/done-escalations.ts +269 -0
- package/packages/core/src/kernel/engine.ts +30 -17
- package/packages/core/src/kernel/integration-landing.ts +24 -4
- package/packages/core/src/kernel/integration-stack.ts +39 -0
- package/packages/core/src/kernel/janitor-failure.ts +20 -1
- package/packages/core/src/kernel/log-index-value.ts +3 -0
- package/packages/core/src/kernel/log-index.ts +41 -2
- package/packages/core/src/kernel/measurement.ts +24 -0
- package/packages/core/src/kernel/open-pr-backpressure.ts +3 -3
- package/packages/core/src/kernel/read-facts.ts +8 -370
- package/packages/core/src/kernel/reducer-registry.ts +43 -125
- package/packages/core/src/kernel/reducer-revisions.ts +18 -0
- package/packages/core/src/kernel/reducer-value-entry.ts +98 -0
- package/packages/core/src/kernel/reducer-value-index.ts +75 -0
- package/packages/core/src/kernel/reducer.ts +84 -16
- package/packages/core/src/kernel/reopen-state.ts +10 -0
- package/packages/core/src/kernel/repository-attention.ts +14 -5
- package/packages/core/src/kernel/repository-read-facts.ts +375 -0
- package/packages/core/src/kernel/ticket-starts.ts +15 -4
- package/packages/core/src/kernel/verify-stage-state.ts +145 -3
- package/packages/core/src/kernel/verify-stages.ts +46 -7
- package/packages/core/src/operator/attention.ts +28 -3
- package/packages/core/src/operator/done-escalations.ts +38 -0
- package/packages/core/src/operator/presentation.ts +14 -1
- package/packages/core/src/operator/protocol.ts +8 -5
- package/packages/core/src/operator/query.ts +72 -57
- package/packages/core/src/operator/registry.ts +19 -15
- package/packages/core/src/operator/ticket-start.ts +8 -7
- package/packages/core/src/operator/tickets.ts +28 -9
- package/packages/core/src/plugin-sdk/index.ts +10 -0
- package/packages/core/src/plugins/manifest.ts +14 -1
- package/packages/core/src/ports/forge/create.ts +8 -0
- package/packages/core/src/ports/forge/github-transport.ts +5 -1
- package/packages/core/src/ports/forge/github.ts +3 -0
- package/packages/core/src/ports/tickets/contract.ts +147 -76
- package/packages/core/src/ports/tickets/create.ts +47 -7
- package/packages/core/src/ports/tickets/fake.ts +8 -4
- package/packages/core/src/ports/tickets/file-codec.ts +4 -3
- package/packages/core/src/ports/tickets/file.ts +7 -3
- package/packages/core/src/ports/tickets/github.ts +1 -0
- package/packages/core/src/ports/tickets/grants.ts +11 -3
- package/packages/core/src/ports/tickets/hosted-index.ts +5 -0
- package/packages/core/src/ports/tickets/linear.ts +28 -9
- package/packages/core/src/ports/tickets/migration.ts +4 -4
- package/packages/core/src/ports/tickets/operations.ts +4 -2
- package/packages/core/src/ports/tickets/priority-labels.ts +213 -0
- package/packages/core/src/ports/tickets/priority.ts +127 -21
- package/packages/core/src/ports/tickets/remote-protocol.ts +10 -0
- package/packages/core/src/ports/tickets/remote.ts +104 -11
- package/packages/core/src/ports/tickets/revision.ts +5 -3
- package/packages/core/src/ports/tickets/search.ts +9 -0
- package/packages/core/src/ports/tickets/tree.ts +8 -6
- package/packages/core/src/ports/types.ts +30 -15
- package/packages/core/src/ports/workspace/build-execution.ts +4 -0
- package/packages/core/src/ports/workspace/builtin-capabilities.ts +4 -0
- package/packages/core/src/ports/workspace/create.ts +16 -3
- package/packages/core/src/ports/workspace/execution-exit-marker.ts +41 -0
- package/packages/core/src/ports/workspace/fake.ts +15 -3
- package/packages/core/src/ports/workspace/recovery-step.ts +101 -0
- package/packages/core/src/ports/workspace/vercel-sandbox.ts +510 -145
- package/packages/core/src/processes/build-execution-state.ts +4 -0
- package/packages/core/src/processes/build-runner.ts +14 -1
- package/packages/core/src/processes/dispatcher.ts +777 -288
- package/packages/core/src/processes/execution-no-progress.ts +1 -0
- package/packages/core/src/processes/execution-settlement.ts +1 -0
- package/packages/core/src/processes/harvest-runner.ts +12 -7
- package/packages/core/src/processes/infrastructure-failure-budget.ts +7 -2
- package/packages/core/src/processes/invocation-budget.ts +176 -0
- package/packages/core/src/processes/publication-loss.ts +38 -3
- package/packages/core/src/processes/workspace-preservation.ts +86 -15
- package/packages/core/src/store/contract.ts +81 -3
- package/packages/core/src/store/event-reads.ts +30 -1
- package/packages/core/src/store/local/capabilities.ts +115 -0
- package/packages/core/src/store/local/store.ts +86 -56
- package/packages/core/src/store/reduced-reads.ts +32 -1
- package/packages/core/src/store/reducer-value-read.ts +235 -0
- package/packages/core/src/store/reducer-value-shapes.json +6722 -6475
- package/packages/core/src/store/reducer-value-validation.ts +181 -33
- package/packages/core/src/store/reducer-values.ts +36 -204
- package/packages/core/src/store/remote/client.ts +169 -29
- package/packages/core/src/store/remote/compatibility.ts +113 -56
- package/packages/core/src/store/remote/credentials.ts +4 -1
- package/packages/core/src/store/remote/protocol.ts +3 -0
- package/packages/core/src/store/remote/released-clients.json +22 -0
- package/packages/core/src/store/remote/released-reducer-values/1.12.0.json +35806 -0
- package/packages/core/src/store/remote/released-reducer-values/1.13.0.json +35966 -0
- package/packages/core/src/store/remote/released-reducer-values/index.ts +20 -16
- package/packages/core/src/store/remote/released-value-policy.ts +144 -0
- package/packages/core/src/store/remote/retry.ts +406 -0
- package/packages/core/src/store/rollup-lease.ts +41 -0
- package/packages/core/src/store/rollups.ts +7 -38
- package/packages/core/src/store/snapshots.ts +1 -1
- package/packages/core/src/testing/dispatch-read-budget.ts +409 -14
- package/packages/core/src/testing/import-graph.ts +78 -0
- package/packages/core/src/testing/index.ts +2 -0
- package/packages/core/src/testing/invocation-budget.ts +42 -0
- package/packages/core/src/testing/reduced-read-budget.ts +602 -40
- package/packages/core/src/testing/released-value-coverage.ts +423 -0
- package/packages/core/src/testing/slot-agreement.ts +52 -0
- package/packages/core/src/web/assets/app.js +5 -5
- package/packages/core/src/web/overview-source.ts +19 -6
- package/skills/guide/SKILL.md +245 -103
- package/skills/guide/references/integration-tree.md +33 -18
- package/skills/guide/references/merge-policy.md +7 -2
- package/skills/guide/references/operator-api.md +48 -25
- package/skills/guide/references/optimization-nodes.md +10 -8
- package/skills/guide/references/plugin-authoring.md +46 -18
- package/skills/guide/references/remote-store-protocol.md +51 -12
- package/skills/guide/references/remote-ticket-protocol.md +85 -38
- package/skills/guide/references/restacking.md +48 -3
- package/skills/guide/references/setup.md +2 -1
- package/skills/guide/references/ticket-migration.md +2 -2
- package/skills/operate/SKILL.md +114 -65
- package/skills/plan/SKILL.md +4 -3
- package/skills/spec/SKILL.md +9 -5
- package/skills/tickets/SKILL.md +25 -17
- package/templates/hosted-service/package.json +2 -2
|
@@ -55,21 +55,8 @@ export interface JudgeCliEnv {
|
|
|
55
55
|
export type AmbientReadSession = CliEnv | HarvestCliEnv
|
|
56
56
|
|
|
57
57
|
const PHASE_FORMAT = "'<phase>[@<round>]' (e.g. 'implement@2', 'verify:acceptance@1')"
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
/** Optional ambient identity is present but cannot safely select one scope. */
|
|
62
|
-
export class InvalidAmbientContextError extends Error {
|
|
63
|
-
override readonly name = 'InvalidAmbientContextError'
|
|
64
|
-
|
|
65
|
-
constructor(detail: string) {
|
|
66
|
-
super(
|
|
67
|
-
`invalid ambient context: ${detail}. Expected no agent identity markers, ` +
|
|
68
|
-
`a complete build tuple (${BUILD_AMBIENT_TUPLE}), or a complete Harvest tuple ` +
|
|
69
|
-
`(${HARVEST_AMBIENT_TUPLE})`,
|
|
70
|
-
)
|
|
71
|
-
}
|
|
72
|
-
}
|
|
58
|
+
export { InvalidAmbientContextError } from './ambient-errors'
|
|
59
|
+
import { InvalidAmbientContextError } from './ambient-errors'
|
|
73
60
|
|
|
74
61
|
/** A required runner-provided session value is absent or empty. Callers that
|
|
75
62
|
* resolve ambient auth directly still receive the variable-specific message;
|
|
@@ -231,12 +231,12 @@ export const HELP_CATALOG: readonly HelpEntry[] = [
|
|
|
231
231
|
detail: page([
|
|
232
232
|
'Usage:',
|
|
233
233
|
' ab ticket tree [--json]',
|
|
234
|
-
' ab ticket create <title> --body <file> [--state <state>] [--labels a,b] [--blocked-by id,id] [--issues N[:refs],...] [--priority urgent|normal] [--assignees a,b] [--kind work|node] [--target <id> | --no-target] [--json]',
|
|
234
|
+
' ab ticket create <title> --body <file> [--state <state>] [--labels a,b] [--blocked-by id,id] [--issues N[:refs],...] [--priority urgent|high|normal|low] [--assignees a,b] [--kind work|node] [--target <id> | --no-target] [--json]',
|
|
235
235
|
' ab ticket edit <id>',
|
|
236
236
|
' ab ticket export <dir> [--store <ref>]',
|
|
237
237
|
' ab ticket import <dir> [--states <state,...>] [--store <ref>]',
|
|
238
238
|
' ab ticket migration record <dir> [--store <ref>]',
|
|
239
|
-
' ab ticket update <id> [--kind work|node] [--target <id> | --no-target] [--title <title>] [--body <file>] [--labels a,b] [--issues N[:refs],...] [--priority urgent|normal] [--assignees a,b] [--expected-revision <opaque>] [--json]',
|
|
239
|
+
' ab ticket update <id> [--kind work|node] [--target <id> | --no-target] [--title <title>] [--body <file>] [--labels a,b] [--issues N[:refs],...] [--priority urgent|high|normal|low] [--assignees a,b] [--expected-revision <opaque>] [--json]',
|
|
240
240
|
' ab ticket block <id> <blocker-id[,blocker-id...]> [--expected-revision <opaque>] [--json]',
|
|
241
241
|
' ab ticket unblock <id> <blocker-id[,blocker-id...]> [--expected-revision <opaque>] [--json]',
|
|
242
242
|
' ab ticket list [--state <state>] [--labels a,b] [--json]',
|
|
@@ -272,10 +272,12 @@ These fields describe intent; dispatch and merge behavior are unchanged.`,
|
|
|
272
272
|
'or N:refs for partial work, comma-separated. On update it replaces the set',
|
|
273
273
|
'and --issues "" clears it. Sources that cannot store issue links refuse the',
|
|
274
274
|
'write, name the source, and write nothing.',
|
|
275
|
-
'--priority
|
|
276
|
-
'
|
|
277
|
-
'
|
|
278
|
-
'source
|
|
275
|
+
'--priority sets the level: urgent, high, normal (the default) or low. Ready',
|
|
276
|
+
'tickets are claimed by level, urgent first and low last, each level in source',
|
|
277
|
+
'order; a running build is never preempted. On update, normal clears the level. A',
|
|
278
|
+
'source without native priority stores the level as exactly one label,',
|
|
279
|
+
'priority:urgent, priority:high or priority:low; those labels report as the',
|
|
280
|
+
'priority, never in labels, and --labels may not name them.',
|
|
279
281
|
'--assignees entries are usernames or me (the owner of the source credential).',
|
|
280
282
|
'On create they replace the [tickets].createAssignee default and --assignees ""',
|
|
281
283
|
'creates an unassigned ticket; on update they replace the set and "" clears it.',
|
|
@@ -283,7 +285,7 @@ These fields describe intent; dispatch and merge behavior are unchanged.`,
|
|
|
283
285
|
'write nothing.',
|
|
284
286
|
'',
|
|
285
287
|
'With no list filters, list uses the same ready criteria as dispatch. show one ticket, including its body/spec.',
|
|
286
|
-
'Human output is the default and marks
|
|
288
|
+
'Human output is the default and marks every level but normal. --json emits exactly',
|
|
287
289
|
'one bare value, and every JSON ticket names its priority: Ticket[]',
|
|
288
290
|
'for list, the hierarchy for tree, and the resulting Ticket for ticket mutations; show',
|
|
289
291
|
'adds an assets array (kind, name, revision, size, layout, fileCount). Sources',
|
|
@@ -452,12 +454,13 @@ These fields describe intent; dispatch and merge behavior are unchanged.`,
|
|
|
452
454
|
'',
|
|
453
455
|
'Default filter — actionable attention only. Builds: escalation.raised, phase.deferral-escalated, integration.landed,',
|
|
454
456
|
'integration.verification-failed (failed node verification), build.janitor-failing, build.janitor-escalated,',
|
|
455
|
-
'build.compatibility-deferred,
|
|
456
|
-
'conflicted restack.replayed,',
|
|
457
|
+
'build.compatibility-deferred, target.rewritten (a node, once per rejected baseline),',
|
|
457
458
|
'landing.consent-revoked (protected merge consent revoked by a reconcile),',
|
|
458
459
|
"pr.checks-failed (failing forge CI on a finished leaf's live PR head),",
|
|
459
460
|
"optimization.noise-exceeded (an optimization node's ε is below its measured noise), derived build.consent-ready and",
|
|
460
461
|
'build.merge-decision (a current actionable merge-gate deferral, a landing awaiting a human merge, or an unsafe forge outcome).',
|
|
462
|
+
'Restack conflicts (conflicted restack.replayed, node.item-conflicted) are routine: reconcile resolves them.',
|
|
463
|
+
'Follow them with --event; an unresolvable conflict arrives as escalation.raised or landing.consent-revoked.',
|
|
461
464
|
'Consent and held ready merges use only build.consent-ready, once per readiness episode.',
|
|
462
465
|
'Unready or stale consent candidates stay silent; one merge gate decision per build/PR.',
|
|
463
466
|
'Repository: harvest.escalated, harvest.recovery-exhausted, dispatcher.config-rejected, dispatcher.forge-readiness-failed,',
|
|
@@ -578,8 +581,9 @@ These fields describe intent; dispatch and merge behavior are unchanged.`,
|
|
|
578
581
|
'Conditions (--for, repeatable): blocked, paused, running, done, aborted, terminal (done',
|
|
579
582
|
'or aborted), pr=open, pr=merged, pr=closed, consent, node-merged, restack-conflicted, pr=conflicted, phase=<phase> (a core phase —',
|
|
580
583
|
'plan, plan-review, implement, code-review, finalize, reconcile, propose — or verify:<step>), and',
|
|
581
|
-
"attention (an open escalation other than a ticket wait's own, failed node verification, consent readiness, a node merge
|
|
582
|
-
'failing forge CI on a finished leaf, or a build waiting for a merge decision).
|
|
584
|
+
"attention (an open escalation other than a ticket wait's own, failed node verification, consent readiness, a node merge,",
|
|
585
|
+
'failing forge CI on a finished leaf, or a build waiting for a merge decision). Routine restack conflicts are',
|
|
586
|
+
'not attention: reconcile resolves them, and --for restack-conflicted waits for them. Merge attention',
|
|
583
587
|
'requires a current actionable gate deferral or an unsafe forge outcome;',
|
|
584
588
|
'armed pending consent, routine outcomes and self-healing failures stay silent.',
|
|
585
589
|
'An unknown condition value is rejected before',
|
|
@@ -707,10 +711,11 @@ These fields describe intent; dispatch and merge behavior are unchanged.`,
|
|
|
707
711
|
'dashboard’s global-row r: it durably releases the queued-build hold, then',
|
|
708
712
|
'turns ticket intake back on, then requests a resume on every cleanly paused',
|
|
709
713
|
'build that does not already have one. A released queued build becomes',
|
|
710
|
-
'launchable on the next ordinary tick with no further action. Running
|
|
711
|
-
'
|
|
712
|
-
'
|
|
713
|
-
'
|
|
714
|
+
'launchable on the next ordinary tick with no further action. Running builds,',
|
|
715
|
+
'builds with a resume already pending, and blocked and finished builds are',
|
|
716
|
+
'skipped without error, and a build still holding an open escalation is',
|
|
717
|
+
'left to ab answer. Output names every build that received a request, the',
|
|
718
|
+
'hold, and the intake value written; --json emits that',
|
|
714
719
|
'summary as JSON. Re-running it changes nothing further. A phase session may not',
|
|
715
720
|
'use --all. A failure exits nonzero and reports which of the two repository',
|
|
716
721
|
'facts landed and which builds were requested.',
|
|
@@ -757,6 +762,10 @@ These fields describe intent; dispatch and merge behavior are unchanged.`,
|
|
|
757
762
|
"the build's own commits onto the current target before any further verification.",
|
|
758
763
|
'Other answer forms skip that escalation; ab abort is the other way out.',
|
|
759
764
|
'',
|
|
765
|
+
'On a completed build, guidance or a bare answer only acknowledges open escalations,',
|
|
766
|
+
'such as a post-landing integration audit; the build stays done and every other',
|
|
767
|
+
'form is refused.',
|
|
768
|
+
'',
|
|
760
769
|
'If paused and every blocker clears, resume is requested last. --store overrides the',
|
|
761
770
|
'BuildStore path or URL. This command is sessionless; a phase may not answer its',
|
|
762
771
|
'own build.',
|
|
@@ -768,7 +777,7 @@ These fields describe intent; dispatch and merge behavior are unchanged.`,
|
|
|
768
777
|
summary: 'Ask the running dispatcher to start one ticket, even while intake is off.',
|
|
769
778
|
detail: page([
|
|
770
779
|
'Usage:',
|
|
771
|
-
' ab start <ticket-id> [--priority manual|urgent|normal] [--cancel] [--json] [--store <ref>]',
|
|
780
|
+
' ab start <ticket-id> [--priority manual|urgent|high|normal|low] [--cancel] [--json] [--store <ref>]',
|
|
772
781
|
'',
|
|
773
782
|
'Record a durable start request for one ticket. The running dispatcher, local or',
|
|
774
783
|
"hosted, claims it on its next tick with a free slot in the request's priority",
|
|
@@ -782,11 +791,15 @@ These fields describe intent; dispatch and merge behavior are unchanged.`,
|
|
|
782
791
|
'Priority tiers (free slots go to them in this order, among parked work and claims):',
|
|
783
792
|
' manual (default) Ahead of every waiting build and ticket claim, urgent ones included.',
|
|
784
793
|
' urgent After urgent parked work; ahead of urgent ready tickets and all',
|
|
785
|
-
' normal work.',
|
|
786
|
-
'
|
|
794
|
+
' high, normal and low work.',
|
|
795
|
+
' high After high parked work and urgent claims; ahead of high ready',
|
|
796
|
+
' tickets and all normal and low work.',
|
|
797
|
+
' normal After normal parked work and high claims; ahead of normal ready',
|
|
798
|
+
' tickets and all low work.',
|
|
799
|
+
' low After low parked work and normal claims; ahead of low ready',
|
|
787
800
|
' tickets.',
|
|
788
|
-
|
|
789
|
-
"
|
|
801
|
+
"manual is admission-only: the claimed build takes its ticket's level. Any other",
|
|
802
|
+
"tier sets the claimed build's level to the request's.",
|
|
790
803
|
'',
|
|
791
804
|
'Every ordinary gate still applies: the ticket must be in the configured ready',
|
|
792
805
|
'state, conform to the spec standard (a nonconforming one is bounced to triage),',
|
|
@@ -797,7 +810,8 @@ These fields describe intent; dispatch and merge behavior are unchanged.`,
|
|
|
797
810
|
'blocked, invalid, missing, not-ready, terminal or claim-refused. Pending and',
|
|
798
811
|
'recently settled requests appear, with their priority, in ab repository status.',
|
|
799
812
|
'',
|
|
800
|
-
' --priority <tier> manual (default), urgent or
|
|
813
|
+
' --priority <tier> manual (default), urgent, high, normal or low; not allowed with',
|
|
814
|
+
' --cancel.',
|
|
801
815
|
' --cancel Cancel the pending request instead; a no-op when none is pending.',
|
|
802
816
|
' --json Print the result object.',
|
|
803
817
|
' --store <ref> Override the BuildStore path or URL.',
|
|
@@ -960,13 +974,14 @@ These fields describe intent; dispatch and merge behavior are unchanged.`,
|
|
|
960
974
|
audience: 'human',
|
|
961
975
|
summary: "Set an active build's slot-admission priority.",
|
|
962
976
|
detail: page([
|
|
963
|
-
'Usage: ab priority <slug> urgent|normal [--store <ref>]',
|
|
964
|
-
'',
|
|
965
|
-
|
|
966
|
-
'
|
|
967
|
-
|
|
968
|
-
'
|
|
969
|
-
'Use it to expedite a waiting build
|
|
977
|
+
'Usage: ab priority <slug> urgent|high|normal|low [--store <ref>]',
|
|
978
|
+
'',
|
|
979
|
+
"Records build.priority-set. A build starts at its ticket's level; this changes",
|
|
980
|
+
'only the build, never the ticket. Free slots go, in order, to manual start',
|
|
981
|
+
"requests, then for each level, urgent, high, normal and low: that level's parked",
|
|
982
|
+
'work (re-verification, reconcile, resume, reopen, propose), then its ticket',
|
|
983
|
+
'claims. Running work is never preempted. Use it to expedite a waiting build',
|
|
984
|
+
'that became a blocker, defer one with low, or return it to normal.',
|
|
970
985
|
'Requires a running, paused or blocked build. This command is sessionless; a phase',
|
|
971
986
|
'may not control its own build.',
|
|
972
987
|
]),
|
|
@@ -243,11 +243,13 @@ export function buildControlConfirmation(result: BuildControlResult): string {
|
|
|
243
243
|
if (result.event.type === 'build.hold-requested' && result.event.payload.reason !== undefined)
|
|
244
244
|
return `build ${result.slug}: merge hold requested (reason: ${result.event.payload.reason})`
|
|
245
245
|
if (result.event.type === 'build.priority-set')
|
|
246
|
-
return `build ${result.slug}: priority set to ${result.event.payload.priority}`
|
|
246
|
+
return `build ${result.slug}: priority set to ${result.event.payload.level ?? result.event.payload.priority}`
|
|
247
247
|
return `build ${result.slug}: ${outcome[result.command]}`
|
|
248
248
|
}
|
|
249
249
|
case 'answered': {
|
|
250
250
|
const plural = result.count === 1 ? '' : 's'
|
|
251
|
+
if (result.acknowledged)
|
|
252
|
+
return `build ${result.slug}: acknowledged ${result.count} escalation${plural} on the completed build; status stays done`
|
|
251
253
|
const terminal = result.terminalSignal
|
|
252
254
|
if (terminal !== undefined) {
|
|
253
255
|
const ending =
|
|
@@ -1000,7 +1002,7 @@ async function dispatch(argv: string[], deps: SessionlessCliDeps): Promise<numbe
|
|
|
1000
1002
|
}
|
|
1001
1003
|
|
|
1002
1004
|
case 'builds': {
|
|
1003
|
-
const { abBuilds } = await import('./status')
|
|
1005
|
+
const { abBuilds, statusColor } = await import('./status')
|
|
1004
1006
|
const usage = 'usage: ab builds [--queued] [--all] [--json] [--store <ref>] (§8.2)'
|
|
1005
1007
|
const parsed = parseArgs(
|
|
1006
1008
|
rest,
|
|
@@ -1020,6 +1022,7 @@ async function dispatch(argv: string[], deps: SessionlessCliDeps): Promise<numbe
|
|
|
1020
1022
|
queued: parsed.flags.has('queued'),
|
|
1021
1023
|
all: parsed.flags.has('all'),
|
|
1022
1024
|
json: parsed.flags.has('json'),
|
|
1025
|
+
color: statusColor(deps.terminal, parsed.flags.has('json')),
|
|
1023
1026
|
...(storeRef !== undefined ? { storeRef } : {}),
|
|
1024
1027
|
...(deps.openStore !== undefined ? { openStore: deps.openStore } : {}),
|
|
1025
1028
|
...(deps.clock !== undefined ? { now: deps.clock } : {}),
|
|
@@ -1050,7 +1053,7 @@ async function dispatch(argv: string[], deps: SessionlessCliDeps): Promise<numbe
|
|
|
1050
1053
|
}
|
|
1051
1054
|
|
|
1052
1055
|
case 'build': {
|
|
1053
|
-
const { abBuildAssetGet, abBuildStatus } = await import('./status')
|
|
1056
|
+
const { abBuildAssetGet, abBuildStatus, statusColor } = await import('./status')
|
|
1054
1057
|
const usage =
|
|
1055
1058
|
'usage: ab build status <slug> [--events <n>] [--json] [--store <ref>] (§8.2)\n' +
|
|
1056
1059
|
' ab build asset get <slug> <kind> <name> <dest> [--rev <n>] [--json] [--store <ref>] (§8.8)'
|
|
@@ -1117,6 +1120,7 @@ async function dispatch(argv: string[], deps: SessionlessCliDeps): Promise<numbe
|
|
|
1117
1120
|
stdout,
|
|
1118
1121
|
slug,
|
|
1119
1122
|
json: parsed.flags.has('json'),
|
|
1123
|
+
color: statusColor(deps.terminal, parsed.flags.has('json')),
|
|
1120
1124
|
...(events !== undefined ? { events } : {}),
|
|
1121
1125
|
...(storeRef !== undefined ? { storeRef } : {}),
|
|
1122
1126
|
...(deps.openStore !== undefined ? { openStore: deps.openStore } : {}),
|
|
@@ -1377,7 +1381,7 @@ async function dispatch(argv: string[], deps: SessionlessCliDeps): Promise<numbe
|
|
|
1377
1381
|
const { abTicketStart } = await import('./ticket-start')
|
|
1378
1382
|
const { parseStartPriorityFlag } = await import('../ports/tickets/priority')
|
|
1379
1383
|
const usage =
|
|
1380
|
-
'usage: ab start <ticket-id> [--priority manual|urgent|normal] [--cancel] [--json] [--store <ref>]'
|
|
1384
|
+
'usage: ab start <ticket-id> [--priority manual|urgent|high|normal|low] [--cancel] [--json] [--store <ref>]'
|
|
1381
1385
|
const parsed = parseArgs(
|
|
1382
1386
|
rest,
|
|
1383
1387
|
{ cancel: 'boolean', json: 'boolean', priority: 'value', store: 'value' },
|
|
@@ -1446,11 +1450,11 @@ async function dispatch(argv: string[], deps: SessionlessCliDeps): Promise<numbe
|
|
|
1446
1450
|
}
|
|
1447
1451
|
|
|
1448
1452
|
case 'priority': {
|
|
1449
|
-
const {
|
|
1450
|
-
const usage = 'usage: ab priority <slug> urgent|normal [--store <ref>]'
|
|
1453
|
+
const { parseBuildPriorityFlag } = await import('../ports/tickets/priority')
|
|
1454
|
+
const usage = 'usage: ab priority <slug> urgent|high|normal|low [--store <ref>]'
|
|
1451
1455
|
const parsed = parseArgs(rest, { store: 'value' }, usage)
|
|
1452
1456
|
if (parsed.positionals.length !== 2) throw new Error(usage)
|
|
1453
|
-
const priority =
|
|
1457
|
+
const priority = parseBuildPriorityFlag(parsed.positionals[1]!, 'priority')
|
|
1454
1458
|
await runBuildControl(
|
|
1455
1459
|
deps,
|
|
1456
1460
|
parsed.positionals[0]!,
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The adapter-free half of production store composition. A local reference
|
|
3
|
+
* never evaluates the remote HTTP adapter or repository configuration: the
|
|
4
|
+
* remote client loads only when `openProductionStoreAsync` opens an http(s)
|
|
5
|
+
* reference, and repository-state resolution lives in `store-opening.ts` and
|
|
6
|
+
* `sessionless-store.ts`. `store-opening.ts` re-exposes all of this with its
|
|
7
|
+
* eager remote factory, so its exports and behavior are unchanged.
|
|
8
|
+
*/
|
|
9
|
+
import { AccountRedactor, redactAccountStore } from '../store/account-redaction'
|
|
10
|
+
import type { BuildStore } from '../store/types'
|
|
11
|
+
import { InvalidAmbientContextError } from './ambient-errors'
|
|
12
|
+
import { projectToken } from './project-credentials'
|
|
13
|
+
import type { RepoStatePaths } from './repo-state'
|
|
14
|
+
import { isRemoteStoreRef, resolveStore, type ResolveStoreOpts } from './store-ref'
|
|
15
|
+
|
|
16
|
+
/** Shared injection seam used by every command that opens a BuildStore. */
|
|
17
|
+
export type StoreOpener = (ref: string, token?: string) => BuildStore
|
|
18
|
+
|
|
19
|
+
export function optionalToken(value: string | undefined): string | undefined {
|
|
20
|
+
// Bearer credentials are opaque. Only absence and the exact empty value mean
|
|
21
|
+
// "no token"; nonempty values are forwarded byte-for-byte.
|
|
22
|
+
return value !== undefined && value !== '' ? value : undefined
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Production local/remote composition over a supplied remote factory. */
|
|
26
|
+
export function composeProductionStore(
|
|
27
|
+
ref: string,
|
|
28
|
+
token: string | undefined,
|
|
29
|
+
remoteFactory?: ResolveStoreOpts['remoteFactory'],
|
|
30
|
+
): BuildStore {
|
|
31
|
+
const forwardedToken = optionalToken(token)
|
|
32
|
+
const store = resolveStore(ref, {
|
|
33
|
+
...(remoteFactory ? { remoteFactory } : {}),
|
|
34
|
+
...(forwardedToken !== undefined ? { token: forwardedToken } : {}),
|
|
35
|
+
})
|
|
36
|
+
const raw = process.env.AB_ACCOUNT_CREDENTIAL_ENVS
|
|
37
|
+
if (!raw) return store
|
|
38
|
+
const names: unknown = JSON.parse(raw)
|
|
39
|
+
if (!Array.isArray(names) || !names.every((name) => typeof name === 'string'))
|
|
40
|
+
throw new Error('Invalid account credential variable inventory')
|
|
41
|
+
return redactAccountStore(
|
|
42
|
+
store,
|
|
43
|
+
new AccountRedactor(() => names.map((name) => process.env[name])),
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** The production remote factory, loaded with the remote adapter. */
|
|
48
|
+
export async function loadRemoteFactory(): Promise<NonNullable<ResolveStoreOpts['remoteFactory']>> {
|
|
49
|
+
const { RemoteBuildStore } = await import('../store/remote/client')
|
|
50
|
+
return (url, remoteToken) => new RemoteBuildStore({ url, token: remoteToken })
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** The production opener for `ref`: the remote adapter loads only for an
|
|
54
|
+
* http(s) reference. */
|
|
55
|
+
export async function productionOpenerFor(ref: string): Promise<StoreOpener> {
|
|
56
|
+
const remoteFactory = isRemoteStoreRef(ref) ? await loadRemoteFactory() : undefined
|
|
57
|
+
return (selected, token) => composeProductionStore(selected, token, remoteFactory)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** `openProductionStore` without loading the remote adapter for a local ref. */
|
|
61
|
+
export async function openProductionStoreAsync(ref: string, token?: string): Promise<BuildStore> {
|
|
62
|
+
return (await productionOpenerFor(ref))(ref, token)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface OpenStoreForRepoStateOpts {
|
|
66
|
+
env: Record<string, string | undefined>
|
|
67
|
+
openStore?: StoreOpener
|
|
68
|
+
useProjectCredential?: boolean
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface OpenedStoreContext extends RepoStatePaths {
|
|
72
|
+
store: BuildStore
|
|
73
|
+
token?: string
|
|
74
|
+
/** The validated ambient phase/Harvest identity this invocation carries, if
|
|
75
|
+
* any — the same value that scoped `store`. Exposed for commands whose
|
|
76
|
+
* repository selection also depends on ambient own-build authority. */
|
|
77
|
+
ambient?: import('./env').AmbientReadSession
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Open from an already canonicalized state selection with `opener`. */
|
|
81
|
+
export function openStoreForRepoStateWith(
|
|
82
|
+
state: RepoStatePaths,
|
|
83
|
+
opts: OpenStoreForRepoStateOpts,
|
|
84
|
+
opener: StoreOpener,
|
|
85
|
+
): OpenedStoreContext {
|
|
86
|
+
// A judge session's only store authority is its one preference.
|
|
87
|
+
if (opts.env.AB_JUDGE !== undefined)
|
|
88
|
+
throw new InvalidAmbientContextError('a judge session has no read authority')
|
|
89
|
+
const token =
|
|
90
|
+
opts.useProjectCredential !== false && isRemoteStoreRef(state.storeRef)
|
|
91
|
+
? projectToken(state.storeRef, state.repo, opts.env)
|
|
92
|
+
: optionalToken(opts.env.AB_TOKEN)
|
|
93
|
+
if (!token && isRemoteStoreRef(state.storeRef) && state.configStore === state.storeRef) {
|
|
94
|
+
throw new Error('No project credential for this service; run ab connect')
|
|
95
|
+
}
|
|
96
|
+
const store = opener(state.storeRef, token)
|
|
97
|
+
return {
|
|
98
|
+
...state,
|
|
99
|
+
store,
|
|
100
|
+
...(token !== undefined ? { token } : {}),
|
|
101
|
+
}
|
|
102
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { recoverLostCandidate } from '../kernel/reconcile-restack'
|
|
2
2
|
import { publicationRetryGate, retryPublicationEffect } from '../kernel/publication-retry'
|
|
3
3
|
import { ForgeRequestDeferred } from '../ports/forge-request-context'
|
|
4
|
+
import { isRecoveryDeferred } from '../ports/workspace/recovery-step'
|
|
4
5
|
import { stat } from 'node:fs/promises'
|
|
5
6
|
import { deferMixedVersion, MixedVersionDeferral } from '../kernel/mixed-version'
|
|
6
7
|
import { suspendNativeLanding } from '../kernel/landing-publication'
|
|
@@ -427,6 +428,9 @@ export async function settlePendingPublication(
|
|
|
427
428
|
}
|
|
428
429
|
} catch (error) {
|
|
429
430
|
if (error instanceof ForgeRequestDeferred) throw error
|
|
431
|
+
// The invocation deadline cut recovery short: the request stays pending
|
|
432
|
+
// and a later invocation settles it. Never a failed finalize step.
|
|
433
|
+
if (isRecoveryDeferred(error)) throw error
|
|
430
434
|
if (error instanceof MixedVersionDeferral) return
|
|
431
435
|
if (request.payload.operation !== 'finalize-step') throw error
|
|
432
436
|
const detail = error instanceof Error ? error.message : String(error)
|
|
@@ -21,6 +21,13 @@ import { isTerminalEventReadError } from '../store/event-reads'
|
|
|
21
21
|
*/
|
|
22
22
|
import { REMOTE_EVENT_WAIT_SECONDS } from '../store/remote/client'
|
|
23
23
|
|
|
24
|
+
/**
|
|
25
|
+
* A stream poll resolves this when its stream has left tracking: the task
|
|
26
|
+
* ends quietly — no `requestStop`, no `endCheck` — and its siblings keep
|
|
27
|
+
* polling. Only `ab watch` returns it (a settled build retiring).
|
|
28
|
+
*/
|
|
29
|
+
export const STREAM_RETIRED: unique symbol = Symbol('stream-retired')
|
|
30
|
+
|
|
24
31
|
/** The read options one held long-poll request carries. */
|
|
25
32
|
export interface RemotePollReadOpts {
|
|
26
33
|
waitSeconds?: number
|
|
@@ -116,8 +123,10 @@ export interface RemotePollRunner {
|
|
|
116
123
|
readonly stopped: boolean
|
|
117
124
|
/** Abort every in-flight held read, wake the gap sleeps, mark stopped. */
|
|
118
125
|
requestStop(): void
|
|
119
|
-
/** Launch one per-stream long-poll task; idempotent per key
|
|
120
|
-
* runs after each successful poll; true ⇒ requestStop +
|
|
126
|
+
/** Launch one per-stream long-poll task; idempotent per key while the task
|
|
127
|
+
* runs. `endCheck` runs after each successful poll; true ⇒ requestStop +
|
|
128
|
+
* return. A poll resolving `STREAM_RETIRED` ends only its own task and
|
|
129
|
+
* frees the key. */
|
|
121
130
|
launch(
|
|
122
131
|
key: string,
|
|
123
132
|
poll: (readOpts: RemotePollReadOpts) => Promise<unknown>,
|
|
@@ -185,7 +194,9 @@ export function createRemotePollRunner(opts: RemotePollRunnerOpts): RemotePollRu
|
|
|
185
194
|
)
|
|
186
195
|
}
|
|
187
196
|
|
|
197
|
+
const launched = new Set<string>()
|
|
188
198
|
const runStreamTask = async (
|
|
199
|
+
key: string,
|
|
189
200
|
poll: (readOpts: RemotePollReadOpts) => Promise<unknown>,
|
|
190
201
|
endCheck?: () => boolean,
|
|
191
202
|
): Promise<void> => {
|
|
@@ -195,8 +206,15 @@ export function createRemotePollRunner(opts: RemotePollRunnerOpts): RemotePollRu
|
|
|
195
206
|
const controller = new AbortController()
|
|
196
207
|
inFlightReads.add(controller)
|
|
197
208
|
try {
|
|
198
|
-
await poll({
|
|
209
|
+
const result = await poll({
|
|
210
|
+
waitSeconds: readWaitSeconds(started),
|
|
211
|
+
signal: controller.signal,
|
|
212
|
+
})
|
|
199
213
|
streak.onSuccess()
|
|
214
|
+
if (result === STREAM_RETIRED) {
|
|
215
|
+
launched.delete(key)
|
|
216
|
+
return
|
|
217
|
+
}
|
|
200
218
|
if (endCheck?.()) {
|
|
201
219
|
requestStop()
|
|
202
220
|
return
|
|
@@ -219,7 +237,6 @@ export function createRemotePollRunner(opts: RemotePollRunnerOpts): RemotePollRu
|
|
|
219
237
|
}
|
|
220
238
|
}
|
|
221
239
|
|
|
222
|
-
const launched = new Set<string>()
|
|
223
240
|
const launch = (
|
|
224
241
|
key: string,
|
|
225
242
|
poll: (readOpts: RemotePollReadOpts) => Promise<unknown>,
|
|
@@ -227,7 +244,7 @@ export function createRemotePollRunner(opts: RemotePollRunnerOpts): RemotePollRu
|
|
|
227
244
|
): void => {
|
|
228
245
|
if (launched.has(key)) return
|
|
229
246
|
launched.add(key)
|
|
230
|
-
track(runStreamTask(poll, endCheck))
|
|
247
|
+
track(runStreamTask(key, poll, endCheck))
|
|
231
248
|
}
|
|
232
249
|
|
|
233
250
|
const runDiscovery = (discovery: {
|
|
@@ -32,9 +32,8 @@ export { normalizeGitRemoteUrl } from '../kernel/origin'
|
|
|
32
32
|
|
|
33
33
|
export const LOCAL_STATE_DIR = '.autobuild'
|
|
34
34
|
|
|
35
|
-
export
|
|
36
|
-
|
|
37
|
-
}
|
|
35
|
+
export { isRemoteStoreRef } from './store-ref'
|
|
36
|
+
import { isRemoteStoreRef } from './store-ref'
|
|
38
37
|
|
|
39
38
|
export { resolveMainRepo } from './main-checkout'
|
|
40
39
|
import { resolveMainRepo } from './main-checkout'
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { startTierOf, type StartTier } from '../ports/tickets/priority'
|
|
2
2
|
import { repositoryReadFactsReducer } from '../kernel/read-facts'
|
|
3
3
|
import {
|
|
4
4
|
ticketStartsReducer,
|
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
} from '../kernel/ticket-starts'
|
|
8
8
|
import { normalizeEffectiveConfigArtifact } from '../config/effective-artifact'
|
|
9
9
|
import { OPERATOR_PRESENCE_TTL_MS, type OperatorPresence } from '../store/operator-presence'
|
|
10
|
-
import { migrationIdentity } from '../kernel/ticket-migrations'
|
|
11
10
|
import {
|
|
12
11
|
dispatchUpgradeReducer,
|
|
13
12
|
upgradeRunRecency,
|
|
@@ -15,14 +14,15 @@ import {
|
|
|
15
14
|
type UpgradeRun,
|
|
16
15
|
} from '../kernel/dispatch-upgrade'
|
|
17
16
|
import { formatRuntimeIdentity } from '../events/runtime'
|
|
18
|
-
import {
|
|
17
|
+
import { capacityBuildFromFacts } from '../kernel/capacity-build'
|
|
19
18
|
import {
|
|
20
19
|
dispatchCapacity,
|
|
21
20
|
startClaimDemand,
|
|
22
|
-
|
|
21
|
+
claimDemand,
|
|
23
22
|
waitingExplanation,
|
|
24
23
|
type DispatchCapacity,
|
|
25
24
|
type CapacityBuild,
|
|
25
|
+
type SlotState,
|
|
26
26
|
} from '../kernel/dispatch-capacity'
|
|
27
27
|
import { backpressureStatusLine } from '../kernel/open-pr-backpressure'
|
|
28
28
|
import {
|
|
@@ -266,11 +266,13 @@ export interface RepositoryTicketStarts {
|
|
|
266
266
|
pending: Array<{
|
|
267
267
|
ticket: { source: string; id: string }
|
|
268
268
|
request: number
|
|
269
|
-
|
|
269
|
+
/** The request's admission tier (`startTierOf`). */
|
|
270
|
+
priority: StartTier
|
|
270
271
|
requestedAt: string
|
|
271
272
|
by?: string
|
|
272
273
|
}>
|
|
273
|
-
|
|
274
|
+
/** Settled or cancelled requests, newest last, each naming its tier. */
|
|
275
|
+
recent: Array<Omit<SettledTicketStart, 'priority' | 'level'> & { priority: StartTier }>
|
|
274
276
|
}
|
|
275
277
|
|
|
276
278
|
function projectTicketStarts(starts: TicketStarts): { ticketStarts?: RepositoryTicketStarts } {
|
|
@@ -279,12 +281,20 @@ function projectTicketStarts(starts: TicketStarts): { ticketStarts?: RepositoryT
|
|
|
279
281
|
.map((entry) => ({
|
|
280
282
|
ticket: entry.ticket,
|
|
281
283
|
request: entry.seq,
|
|
282
|
-
priority: entry
|
|
284
|
+
priority: startTierOf(entry),
|
|
283
285
|
requestedAt: entry.ts,
|
|
284
286
|
...(entry.by !== undefined ? { by: entry.by } : {}),
|
|
285
287
|
}))
|
|
286
288
|
return pending.length || starts.recent.length
|
|
287
|
-
? {
|
|
289
|
+
? {
|
|
290
|
+
ticketStarts: {
|
|
291
|
+
pending,
|
|
292
|
+
recent: starts.recent.map(({ level: _level, ...entry }) => ({
|
|
293
|
+
...entry,
|
|
294
|
+
priority: startTierOf({ priority: entry.priority, level: _level }),
|
|
295
|
+
})),
|
|
296
|
+
},
|
|
297
|
+
}
|
|
288
298
|
: {}
|
|
289
299
|
}
|
|
290
300
|
|
|
@@ -574,9 +584,10 @@ export function renderRepositoryStatus(status: RepositoryStatus): string[] {
|
|
|
574
584
|
`repository: ${status.repo}`,
|
|
575
585
|
...(status.capacity
|
|
576
586
|
? [
|
|
577
|
-
`capacity: ${status.capacity.occupied}/${status.capacity.
|
|
587
|
+
`capacity: ${status.capacity.occupied}/${status.capacity.configured}${status.capacity.waitingNodes?.length || status.capacity.waitingBuilds?.length || status.capacity.urgentClaims || status.capacity.highClaims || status.capacity.normalClaims || status.capacity.startRequests ? `; ${waitingExplanation(status.capacity, { requests: true })}` : ''}`,
|
|
578
588
|
]
|
|
579
589
|
: []),
|
|
590
|
+
...(status.capacity?.slots ? [slotsStatusLine(status.capacity.slots)] : []),
|
|
580
591
|
...(status.capacity?.backpressure
|
|
581
592
|
? [backpressureStatusLine(status.capacity.backpressure)]
|
|
582
593
|
: []),
|
|
@@ -723,6 +734,24 @@ export function localOverridesFromArtifact(
|
|
|
723
734
|
|
|
724
735
|
/** Capacity is optional when no held dispatcher has a retrievable configuration
|
|
725
736
|
* (`artifact` comes from `readHeldEffectiveConfig`). */
|
|
737
|
+
/** Every reported build's slot state, grouped held, requested and none,
|
|
738
|
+
* each group sorted by slug; `none` when no build is reported. Builds whose
|
|
739
|
+
* state is unknown are not listed. */
|
|
740
|
+
function slotsStatusLine(slots: Record<string, SlotState>): string {
|
|
741
|
+
const entries = Object.entries(slots).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))
|
|
742
|
+
const label = (slug: string, slot: SlotState) =>
|
|
743
|
+
slot.state === 'requested'
|
|
744
|
+
? `${slug} (${slot.request}${slot.priority !== undefined ? `, ${slot.priority}` : ''})`
|
|
745
|
+
: slug
|
|
746
|
+
const clauses = (['held', 'requested', 'none'] as const).flatMap((state) => {
|
|
747
|
+
const members = entries.filter(([, slot]) => slot.state === state)
|
|
748
|
+
return members.length
|
|
749
|
+
? [`${state} ${members.map(([slug, slot]) => label(slug, slot)).join(', ')}`]
|
|
750
|
+
: []
|
|
751
|
+
})
|
|
752
|
+
return `slots: ${clauses.length ? clauses.join('; ') : 'none'}`
|
|
753
|
+
}
|
|
754
|
+
|
|
726
755
|
export async function readRepositoryCapacity(
|
|
727
756
|
store: BuildStore,
|
|
728
757
|
repo: string,
|
|
@@ -739,26 +768,13 @@ export async function readRepositoryCapacity(
|
|
|
739
768
|
// settled build, so this read stays flat as history accumulates.
|
|
740
769
|
for (const { record, digest } of await store.listOpenBuilds(repo)) {
|
|
741
770
|
if (digest.terminal) continue
|
|
742
|
-
|
|
743
|
-
builds.push({
|
|
744
|
-
record,
|
|
745
|
-
state: build.state,
|
|
746
|
-
workspace: build.workspace !== null,
|
|
747
|
-
provisioning: build.provisionMarker !== undefined,
|
|
748
|
-
restackDue: landingRestackDue(build.state, build.log),
|
|
749
|
-
})
|
|
771
|
+
builds.push(capacityBuildFromFacts(record, (await readBuildFacts(store, record.slug)).value))
|
|
750
772
|
}
|
|
751
|
-
return dispatchCapacity(
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
{
|
|
757
|
-
urgentClaims: urgentClaimDemand(facts),
|
|
758
|
-
startRequests: startClaimDemand(facts),
|
|
759
|
-
openPrs: { policy: config.policy, engaged: facts.openPrBackpressure !== undefined },
|
|
760
|
-
},
|
|
761
|
-
)
|
|
773
|
+
return dispatchCapacity(builds, config.capacity, now, {
|
|
774
|
+
claims: claimDemand(facts),
|
|
775
|
+
startRequests: startClaimDemand(facts),
|
|
776
|
+
openPrs: { policy: config.policy, engaged: facts.openPrBackpressure !== undefined },
|
|
777
|
+
})
|
|
762
778
|
}
|
|
763
779
|
|
|
764
780
|
/**
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `openSessionlessStore` for callers that must not evaluate the remote adapter
|
|
3
|
+
* for a local reference. This is the only light-path module that resolves
|
|
4
|
+
* repository state (and with it configuration), so readers that already know
|
|
5
|
+
* their journal never load it.
|
|
6
|
+
*/
|
|
7
|
+
import { resolveRepoState } from './repo-state'
|
|
8
|
+
import {
|
|
9
|
+
openStoreForRepoStateWith,
|
|
10
|
+
productionOpenerFor,
|
|
11
|
+
type OpenedStoreContext,
|
|
12
|
+
} from './production-store'
|
|
13
|
+
import type { SessionlessStoreOpts } from './store-opening'
|
|
14
|
+
|
|
15
|
+
export async function openSessionlessStoreLazily(
|
|
16
|
+
opts: SessionlessStoreOpts,
|
|
17
|
+
): Promise<OpenedStoreContext> {
|
|
18
|
+
const state = await resolveRepoState({
|
|
19
|
+
targetRepo: opts.targetRepo,
|
|
20
|
+
exec: opts.exec,
|
|
21
|
+
...(opts.storeRef !== undefined ? { storeRef: opts.storeRef } : {}),
|
|
22
|
+
...(opts.env.AB_STORE !== undefined ? { envStore: opts.env.AB_STORE } : {}),
|
|
23
|
+
})
|
|
24
|
+
const opener = opts.openStore ?? (await productionOpenerFor(state.storeRef))
|
|
25
|
+
return openStoreForRepoStateWith(state, opts, opener)
|
|
26
|
+
}
|