@atolis-hq/wake 0.4.104 → 0.4.106
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/dist/src/activities/agent/agent-activity.js +10 -0
- package/dist/src/activities/contracts/activity.d.ts +28 -0
- package/dist/src/activities/contracts/event-schema.d.ts +314 -8
- package/dist/src/activities/contracts/event-schema.js +20 -2
- package/dist/src/activities/contracts/events.d.ts +10 -0
- package/dist/src/activities/contracts/vocabulary.d.ts +2 -0
- package/dist/src/activities/contracts/vocabulary.js +2 -0
- package/dist/src/activities/index.d.ts +2 -0
- package/dist/src/activities/index.js +2 -0
- package/dist/src/activities/pr/activity-support.d.ts +1 -1
- package/dist/src/activities/pr/activity-support.js +10 -0
- package/dist/src/activities/pr/application.js +8 -1
- package/dist/src/activities/pr/approve.d.ts +2 -1
- package/dist/src/activities/pr/approve.js +33 -11
- package/dist/src/activities/pr/check-evidence.d.ts +10 -0
- package/dist/src/activities/pr/check-evidence.js +16 -0
- package/dist/src/activities/pr/contracts.d.ts +14 -0
- package/dist/src/activities/pr/event-data.js +5 -1
- package/dist/src/activities/pr/merge.d.ts +2 -1
- package/dist/src/activities/pr/merge.js +54 -38
- package/dist/src/activities/pr/parent-scope.d.ts +65 -0
- package/dist/src/activities/pr/parent-scope.js +24 -0
- package/dist/src/activities/pr/parent-target.d.ts +45 -0
- package/dist/src/activities/pr/parent-target.js +59 -0
- package/dist/src/activities/pr/projection.js +10 -2
- package/dist/src/activities/pr/vocabulary.d.ts +8 -0
- package/dist/src/activities/pr/vocabulary.js +8 -0
- package/dist/src/bootstrap/activity-registry.d.ts +2 -2
- package/dist/src/bootstrap/activity-registry.js +3 -3
- package/dist/src/bootstrap/composition-root.js +11 -2
- package/dist/src/bootstrap/config/root-schema.d.ts +22 -0
- package/dist/src/bootstrap/delegation-authority.js +17 -0
- package/dist/src/bootstrap/delivery-integration.d.ts +9 -0
- package/dist/src/bootstrap/delivery-integration.js +46 -0
- package/dist/src/bootstrap/surface-api-delivery.js +52 -0
- package/dist/src/bootstrap/version.js +1 -1
- package/dist/src/control-plane/application/activation-scheduler-ports.d.ts +5 -1
- package/dist/src/control-plane/application/advance-once-dispatch.js +12 -6
- package/dist/src/execution/application/candidate-workspaces.d.ts +13 -0
- package/dist/src/execution/application/candidate-workspaces.js +75 -0
- package/dist/src/execution/application/execution-service.js +37 -11
- package/dist/src/execution/application/maintenance-workspaces.d.ts +17 -0
- package/dist/src/execution/application/maintenance-workspaces.js +84 -0
- package/dist/src/execution/application/run-lifecycle.js +2 -0
- package/dist/src/execution/contracts/candidate.d.ts +31 -0
- package/dist/src/execution/contracts/candidate.js +40 -0
- package/dist/src/execution/contracts/commands.d.ts +4 -0
- package/dist/src/execution/contracts/events.d.ts +24 -0
- package/dist/src/execution/contracts/events.js +4 -0
- package/dist/src/execution/contracts/maintenance.d.ts +36 -0
- package/dist/src/execution/contracts/maintenance.js +44 -0
- package/dist/src/execution/contracts/repository-assignment.d.ts +5 -0
- package/dist/src/execution/contracts/repository-assignment.js +8 -0
- package/dist/src/execution/contracts/views.d.ts +4 -0
- package/dist/src/execution/contracts/vocabulary.d.ts +5 -0
- package/dist/src/execution/contracts/vocabulary.js +4 -0
- package/dist/src/execution/contracts/workspace.d.ts +8 -0
- package/dist/src/execution/index.d.ts +2 -0
- package/dist/src/execution/index.js +2 -0
- package/dist/src/execution/infrastructure/workspace/git-source.d.ts +2 -2
- package/dist/src/execution/infrastructure/workspace/git-source.js +18 -1
- package/dist/src/execution/infrastructure/workspace/git-workspace.d.ts +2 -4
- package/dist/src/execution/infrastructure/workspace/git-workspace.js +12 -1
- package/dist/src/integrations/application/delegation-outputs.js +1 -1
- package/dist/src/integrations/application/delivery-integration-verification.d.ts +13 -0
- package/dist/src/integrations/application/delivery-integration-verification.js +68 -0
- package/dist/src/integrations/delivery/application/delivery-projector.js +3 -0
- package/dist/src/integrations/delivery/application/merged-delivery-evidence.js +9 -1
- package/dist/src/integrations/delivery/contracts/views.d.ts +2 -0
- package/dist/src/integrations/fake/external-source.d.ts +5 -2
- package/dist/src/integrations/fake/external-source.js +12 -2
- package/dist/src/integrations/fake/inbound-translator.js +7 -2
- package/dist/src/integrations/fake/provider.d.ts +17 -0
- package/dist/src/integrations/fake/provider.js +18 -2
- package/dist/src/integrations/github/application/pull-request-translation.js +2 -0
- package/dist/src/integrations/github/contracts/events.d.ts +3 -1
- package/dist/src/integrations/github/contracts/events.js +3 -1
- package/dist/src/integrations/github/contracts/payloads.d.ts +23 -0
- package/dist/src/integrations/github/infrastructure/check-execution.d.ts +9 -0
- package/dist/src/integrations/github/infrastructure/check-execution.js +68 -0
- package/dist/src/integrations/github/infrastructure/checkout-revision.d.ts +2 -0
- package/dist/src/integrations/github/infrastructure/checkout-revision.js +23 -0
- package/dist/src/integrations/github/infrastructure/client.d.ts +2 -0
- package/dist/src/integrations/github/infrastructure/client.js +4 -0
- package/dist/src/integrations/github/infrastructure/pr-check-subject.d.ts +7 -0
- package/dist/src/integrations/github/infrastructure/pr-check-subject.js +77 -0
- package/dist/src/integrations/github/infrastructure/pr-evidence.d.ts +6 -3
- package/dist/src/integrations/github/infrastructure/pr-evidence.js +1 -1
- package/dist/src/integrations/github/infrastructure/pr-source.d.ts +3 -5
- package/dist/src/integrations/github/infrastructure/pr-source.js +11 -1
- package/dist/src/integrations/github/infrastructure/workflow-run-evidence.d.ts +5 -0
- package/dist/src/integrations/github/infrastructure/workflow-run-evidence.js +22 -0
- package/dist/src/integrations/index.d.ts +1 -0
- package/dist/src/integrations/index.js +1 -0
- package/dist/src/orchestration/application/delegated-work.d.ts +5 -0
- package/dist/src/orchestration/application/delegated-work.js +10 -0
- package/dist/src/orchestration/application/delegation-commands.d.ts +16 -0
- package/dist/src/orchestration/application/delivery-coordinator.d.ts +348 -0
- package/dist/src/orchestration/application/delivery-coordinator.js +239 -0
- package/dist/src/orchestration/application/delivery-facts-reader.d.ts +9 -0
- package/dist/src/orchestration/application/delivery-facts-reader.js +47 -0
- package/dist/src/orchestration/application/delivery-integration-reader.d.ts +9 -0
- package/dist/src/orchestration/application/delivery-integration-reader.js +23 -0
- package/dist/src/orchestration/application/delivery-integration-service.d.ts +50 -0
- package/dist/src/orchestration/application/delivery-integration-service.js +228 -0
- package/dist/src/orchestration/application/delivery-preparation.d.ts +16 -0
- package/dist/src/orchestration/application/delivery-preparation.js +105 -0
- package/dist/src/orchestration/application/delivery-sources.d.ts +10 -0
- package/dist/src/orchestration/application/delivery-sources.js +41 -0
- package/dist/src/orchestration/application/orchestration-repository.d.ts +3 -1
- package/dist/src/orchestration/application/orchestration-repository.js +10 -1
- package/dist/src/orchestration/application/orchestration-service.d.ts +341 -2
- package/dist/src/orchestration/application/orchestration-service.js +86 -4
- package/dist/src/orchestration/contracts/config.d.ts +22 -0
- package/dist/src/orchestration/contracts/config.js +13 -1
- package/dist/src/orchestration/contracts/delegation-ports.d.ts +4 -0
- package/dist/src/orchestration/contracts/delegation.d.ts +13 -1
- package/dist/src/orchestration/contracts/delegation.js +5 -0
- package/dist/src/orchestration/contracts/delivery-ports.d.ts +53 -0
- package/dist/src/orchestration/contracts/delivery-ports.js +1 -0
- package/dist/src/orchestration/contracts/delivery.d.ts +310 -0
- package/dist/src/orchestration/contracts/delivery.js +186 -0
- package/dist/src/orchestration/contracts/event-decoder.js +14 -1
- package/dist/src/orchestration/contracts/event-factory.js +8 -0
- package/dist/src/orchestration/contracts/events.d.ts +10 -0
- package/dist/src/orchestration/contracts/events.js +4 -0
- package/dist/src/orchestration/contracts/views.d.ts +3 -0
- package/dist/src/orchestration/contracts/vocabulary.d.ts +90 -0
- package/dist/src/orchestration/contracts/vocabulary.js +82 -0
- package/dist/src/orchestration/domain/compile-diagnostics.d.ts +1 -1
- package/dist/src/orchestration/domain/compile-diagnostics.js +5 -0
- package/dist/src/orchestration/domain/compiler.js +2 -0
- package/dist/src/orchestration/domain/delivery-candidate.d.ts +9 -0
- package/dist/src/orchestration/domain/delivery-candidate.js +105 -0
- package/dist/src/orchestration/domain/delivery-facts.d.ts +89 -0
- package/dist/src/orchestration/domain/delivery-facts.js +66 -0
- package/dist/src/orchestration/domain/delivery-integration-policy.d.ts +7 -0
- package/dist/src/orchestration/domain/delivery-integration-policy.js +15 -0
- package/dist/src/orchestration/domain/delivery-integration.d.ts +54 -0
- package/dist/src/orchestration/domain/delivery-integration.js +144 -0
- package/dist/src/orchestration/domain/delivery-qa.d.ts +33 -0
- package/dist/src/orchestration/domain/delivery-qa.js +97 -0
- package/dist/src/orchestration/domain/delivery-replacement.d.ts +9 -0
- package/dist/src/orchestration/domain/delivery-replacement.js +54 -0
- package/dist/src/orchestration/domain/delivery-selection.d.ts +17 -0
- package/dist/src/orchestration/domain/delivery-selection.js +132 -0
- package/dist/src/orchestration/domain/delivery-workflow-policy.d.ts +6 -0
- package/dist/src/orchestration/domain/delivery-workflow-policy.js +32 -0
- package/dist/src/orchestration/domain/operator-retry-policy.js +24 -13
- package/dist/src/orchestration/domain/workflow-instance-events.d.ts +1 -0
- package/dist/src/orchestration/domain/workflow-instance-events.js +12 -0
- package/dist/src/orchestration/index.d.ts +3 -0
- package/dist/src/orchestration/index.js +1 -0
- package/dist/src/surfaces/api/contracts/transport-values.js +1 -0
- package/dist/src/surfaces/api/contracts/work.d.ts +42 -0
- package/dist/src/surfaces/api/presenters/execution.js +1 -0
- package/dist/src/surfaces/mcp/delegation.js +36 -1
- package/dist/src/surfaces/web-assets/assets/index-ih1h3dxC.js +1192 -0
- package/dist/src/surfaces/web-assets/index.html +1 -1
- package/package.json +1 -1
- package/dist/src/surfaces/web-assets/assets/index-C5R-aWzH.js +0 -1192
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { WorkspaceMode } from '../../execution/index.js';
|
|
2
|
+
import { OrchestrationEventType } from '../contracts/events.js';
|
|
3
|
+
import { CandidateSourceKind, DeliveryCompletion } from '../contracts/vocabulary.js';
|
|
4
|
+
import { currentSelection } from '../domain/delivery-facts.js';
|
|
5
|
+
import { completionDecision, deliveryState } from '../domain/delivery-qa.js';
|
|
6
|
+
import { readDeliveryFacts } from './delivery-facts-reader.js';
|
|
7
|
+
import { DeliveryIntegrationReader } from './delivery-integration-reader.js';
|
|
8
|
+
import { verifyCandidateSources } from './delivery-sources.js';
|
|
9
|
+
export class DeliveryPreparation {
|
|
10
|
+
repository;
|
|
11
|
+
dependencies;
|
|
12
|
+
integration;
|
|
13
|
+
constructor(repository, dependencies) {
|
|
14
|
+
this.repository = repository;
|
|
15
|
+
this.dependencies = dependencies;
|
|
16
|
+
this.integration = new DeliveryIntegrationReader(dependencies);
|
|
17
|
+
}
|
|
18
|
+
async completionBlock(id) {
|
|
19
|
+
const parent = (await this.repository.loadRequired(id)).view;
|
|
20
|
+
const definition = await this.dependencies.definitionFor(parent);
|
|
21
|
+
// Existing direct workflows retain their configured routes.
|
|
22
|
+
if (definition.delegation?.qa === undefined && definition.delegation?.completion === undefined)
|
|
23
|
+
return undefined;
|
|
24
|
+
const facts = await this.facts(parent);
|
|
25
|
+
if (facts.reservations.length === 0)
|
|
26
|
+
return undefined;
|
|
27
|
+
const mode = definition.delegation?.completion ?? DeliveryCompletion.QaApproved;
|
|
28
|
+
const decision = completionDecision(deliveryState(facts), mode, mode === DeliveryCompletion.MergeRequired ? await this.integration.assess(facts) : undefined);
|
|
29
|
+
const retryStage = await this.delegatingStage(id, facts.reservations.at(-1));
|
|
30
|
+
const blocked = (reason) => ({
|
|
31
|
+
reason,
|
|
32
|
+
deliveryGate: { retryStage },
|
|
33
|
+
});
|
|
34
|
+
if (!decision.complete)
|
|
35
|
+
return blocked(decision.reason);
|
|
36
|
+
try {
|
|
37
|
+
await verifyCandidateSources(parent, this.dependencies.repositories, facts.candidates.at(-1), facts);
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
return blocked(error instanceof Error ? error.message : 'Operational candidate source verification failed');
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
async prepare(id) {
|
|
45
|
+
const parent = (await this.repository.loadRequired(id)).view;
|
|
46
|
+
const policy = (await this.dependencies.definitionFor(parent)).delegation?.qa;
|
|
47
|
+
if (policy === undefined || parent.pendingActivation?.stage !== policy.stage)
|
|
48
|
+
return undefined;
|
|
49
|
+
if (parent.pendingActivation.execution?.workspace !== WorkspaceMode.ReadOnly)
|
|
50
|
+
throw new Error('Candidate QA requires read-only workspaces');
|
|
51
|
+
const facts = await this.facts(parent);
|
|
52
|
+
const state = deliveryState(facts);
|
|
53
|
+
if (!state.candidateCurrent || state.candidate === null)
|
|
54
|
+
throw new Error('QA preparation needs a current complete candidate');
|
|
55
|
+
const candidate = state.candidate;
|
|
56
|
+
await verifyCandidateSources(parent, this.dependencies.repositories, candidate, facts);
|
|
57
|
+
return {
|
|
58
|
+
candidateId: candidate.candidateId,
|
|
59
|
+
selectionRevision: candidate.selectionRevision,
|
|
60
|
+
criteria: candidate.criteria,
|
|
61
|
+
inputs: currentSelection(facts).entries.map((entry) => ({
|
|
62
|
+
workItemId: entry.output.reference.workItemId,
|
|
63
|
+
outputName: entry.output.name,
|
|
64
|
+
revision: 'revisionId' in entry.output.reference
|
|
65
|
+
? entry.output.reference.revisionId
|
|
66
|
+
: entry.output.reference.revision,
|
|
67
|
+
})),
|
|
68
|
+
...(policy.recipe === undefined ? {} : { recipe: policy.recipe }),
|
|
69
|
+
repositories: candidate.repositories.map((entry) => ({
|
|
70
|
+
resourceId: entry.resourceId,
|
|
71
|
+
sourceRef: entry.source.kind === CandidateSourceKind.RetainedRef ? entry.source.ref : entry.revision,
|
|
72
|
+
sourceRevision: entry.revision,
|
|
73
|
+
pullRequestBase: entry.pullRequestBase,
|
|
74
|
+
...(entry.source.kind === CandidateSourceKind.RetainedRef
|
|
75
|
+
? { requiredSourceRef: entry.source.ref }
|
|
76
|
+
: {}),
|
|
77
|
+
})),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
async noDescendantCapacity(facts) {
|
|
81
|
+
const root = facts.reservations[0];
|
|
82
|
+
if (root === undefined)
|
|
83
|
+
return false;
|
|
84
|
+
const reservations = new Map();
|
|
85
|
+
for (const { event } of await this.repository.events()) {
|
|
86
|
+
if (event.eventType !== OrchestrationEventType.DelegationReserved ||
|
|
87
|
+
event.payload.rootWorkItemId !== root.rootWorkItemId)
|
|
88
|
+
continue;
|
|
89
|
+
const reservation = event.payload;
|
|
90
|
+
reservations.set(reservation.parentWorkflowInstanceId + '/' + reservation.cohortId, reservation.children.length);
|
|
91
|
+
}
|
|
92
|
+
return [...reservations.values()].reduce((sum, count) => sum + count, 0) >= root.maxDescendants;
|
|
93
|
+
}
|
|
94
|
+
async delegatingStage(id, reservation) {
|
|
95
|
+
const original = (await this.repository.history(id)).events.find(({ event }) => event.eventType === OrchestrationEventType.ActivityRequested &&
|
|
96
|
+
event.payload.activationId === reservation.activationId);
|
|
97
|
+
if (original?.event.eventType !== OrchestrationEventType.ActivityRequested ||
|
|
98
|
+
original.event.payload.stage === undefined)
|
|
99
|
+
throw new Error('Missing delegating activation stage');
|
|
100
|
+
return original.event.payload.stage;
|
|
101
|
+
}
|
|
102
|
+
async facts(parent) {
|
|
103
|
+
return readDeliveryFacts(this.repository, parent, (await this.repository.history(parent.workflowInstanceId)).events);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { DelegationRepositories } from '../contracts/delegation-ports.js';
|
|
2
|
+
import { type DeliveryCandidate } from '../contracts/delivery.js';
|
|
3
|
+
import type { WorkflowInstanceView } from '../contracts/views.js';
|
|
4
|
+
import { type DeliveryFacts } from '../domain/delivery-facts.js';
|
|
5
|
+
/**
|
|
6
|
+
* Proves every candidate commit is fetchable from its authorized repository at the recorded
|
|
7
|
+
* revision. A retained ref is resolved by name, so a moved or deleted ref fails; a selected
|
|
8
|
+
* output is fetched by its exact commit. A local SHA alone is never a durable source.
|
|
9
|
+
*/
|
|
10
|
+
export declare function verifyCandidateSources(parent: WorkflowInstanceView, repositories: DelegationRepositories | undefined, candidate: DeliveryCandidate, facts: DeliveryFacts): Promise<void>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { RepositorySourceError, RepositorySourceFailure } from '../../execution/index.js';
|
|
2
|
+
import { DeliveryRejectionError } from '../contracts/delivery.js';
|
|
3
|
+
import { CandidateSourceKind, DeliveryRejection } from '../contracts/vocabulary.js';
|
|
4
|
+
import { currentSelection, isChange } from '../domain/delivery-facts.js';
|
|
5
|
+
/**
|
|
6
|
+
* Proves every candidate commit is fetchable from its authorized repository at the recorded
|
|
7
|
+
* revision. A retained ref is resolved by name, so a moved or deleted ref fails; a selected
|
|
8
|
+
* output is fetched by its exact commit. A local SHA alone is never a durable source.
|
|
9
|
+
*/
|
|
10
|
+
export async function verifyCandidateSources(parent, repositories, candidate, facts) {
|
|
11
|
+
for (const entry of candidate.repositories) {
|
|
12
|
+
const source = entry.source.kind === CandidateSourceKind.RetainedRef
|
|
13
|
+
? { sourceRef: entry.source.ref }
|
|
14
|
+
: { sourceRef: branchOf(facts, entry.contributions[0]), sourceRevision: entry.revision };
|
|
15
|
+
const unavailable = (detail) => new DeliveryRejectionError(DeliveryRejection.SourceUnavailable, `Candidate source ${source.sourceRef} in ${entry.resourceId} is unavailable: ${detail}`);
|
|
16
|
+
if (repositories === undefined)
|
|
17
|
+
throw unavailable('source verification is not configured');
|
|
18
|
+
let resolved;
|
|
19
|
+
try {
|
|
20
|
+
resolved = await repositories.resolve(parent, {
|
|
21
|
+
resourceId: entry.resourceId,
|
|
22
|
+
pullRequestBase: entry.pullRequestBase,
|
|
23
|
+
...source,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
const detail = error instanceof Error ? error.message : 'unknown source verification failure';
|
|
28
|
+
if (error instanceof RepositorySourceError &&
|
|
29
|
+
error.kind === RepositorySourceFailure.RefUnavailable)
|
|
30
|
+
throw unavailable(detail);
|
|
31
|
+
throw unavailable('operational fetch/check failed; candidate not verified: ' + detail);
|
|
32
|
+
}
|
|
33
|
+
if (resolved.sourceRevision.toLowerCase() !== entry.revision.toLowerCase())
|
|
34
|
+
throw unavailable(`it now points at ${resolved.sourceRevision}, not ${entry.revision}`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function branchOf(facts, contribution) {
|
|
38
|
+
const output = currentSelection(facts)?.entries.find((entry) => entry.childWorkItemId === contribution?.childWorkItemId &&
|
|
39
|
+
entry.output.name === contribution.outputName)?.output;
|
|
40
|
+
return output !== undefined && isChange(output) ? output.reference.branch : 'HEAD';
|
|
41
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type EventJournal } from '@atolis-hq/eventing';
|
|
2
|
+
import type { DeliveryCompletionBlock } from '../contracts/delivery.js';
|
|
2
3
|
import type { WorkflowOrchestrationEvent, WorkflowOrchestrationEventData } from '../contracts/events.js';
|
|
3
4
|
import type { WorkflowInstanceView } from '../contracts/views.js';
|
|
4
5
|
type ListedInstance = {
|
|
@@ -7,8 +8,9 @@ type ListedInstance = {
|
|
|
7
8
|
};
|
|
8
9
|
export declare class OrchestrationRepository {
|
|
9
10
|
private readonly journal;
|
|
11
|
+
private readonly completionBlock?;
|
|
10
12
|
private readonly listed;
|
|
11
|
-
constructor(journal: EventJournal);
|
|
13
|
+
constructor(journal: EventJournal, completionBlock?: ((id: string) => Promise<DeliveryCompletionBlock | undefined>) | undefined);
|
|
12
14
|
load(id: string): Promise<{
|
|
13
15
|
sequence: number;
|
|
14
16
|
view: WorkflowInstanceView | null;
|
|
@@ -6,9 +6,11 @@ import { isWorkflowInstanceStream, workflowInstanceStream } from '../contracts/s
|
|
|
6
6
|
import { foldWorkflowInstance } from '../domain/workflow-instance.js';
|
|
7
7
|
export class OrchestrationRepository {
|
|
8
8
|
journal;
|
|
9
|
+
completionBlock;
|
|
9
10
|
listed;
|
|
10
|
-
constructor(journal) {
|
|
11
|
+
constructor(journal, completionBlock) {
|
|
11
12
|
this.journal = journal;
|
|
13
|
+
this.completionBlock = completionBlock;
|
|
12
14
|
this.listed = cachedJournalView(journal, (events) => {
|
|
13
15
|
const owned = events.flatMap((entry) => {
|
|
14
16
|
const decoded = selectWorkflowOrchestrationEvent(entry);
|
|
@@ -67,6 +69,13 @@ export class OrchestrationRepository {
|
|
|
67
69
|
.filter((event) => drafts.some((draft) => draft.eventId === event.event.eventId))
|
|
68
70
|
.map(decodeOrchestrationEvent)
|
|
69
71
|
.filter(isWorkflowEvent);
|
|
72
|
+
if (drafts.some((draft) => draft.eventType === OrchestrationEventType.InstanceCompleted)) {
|
|
73
|
+
const block = await this.completionBlock?.(id);
|
|
74
|
+
if (block !== undefined)
|
|
75
|
+
drafts = drafts.map((draft) => draft.eventType === OrchestrationEventType.InstanceCompleted
|
|
76
|
+
? { ...draft, eventType: OrchestrationEventType.InstanceBlocked, payload: block }
|
|
77
|
+
: draft);
|
|
78
|
+
}
|
|
70
79
|
const events = await this.journal.appendToStream(workflowInstanceStream(workflowInstanceId(id)), sequence, drafts);
|
|
71
80
|
return events.map(decodeOrchestrationEvent).filter(isWorkflowEvent);
|
|
72
81
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { DelegationArtifacts, DelegationAuthority, DelegationRepositories } from '../contracts/delegation-ports.js';
|
|
2
2
|
import type { DelegationAttentionReply, DelegationCaller, DelegationSubmission } from '../contracts/delegation.js';
|
|
3
|
+
import type { DeliveryIntegration } from '../contracts/delivery-ports.js';
|
|
4
|
+
import type { DeliveryCandidateCommand, DeliveryMaintenanceCommand, DeliveryQaCommand, DeliverySelectionCommand } from '../contracts/delivery.js';
|
|
3
5
|
import type { ResourceTransitionEvidence } from './resource-transition-evidence.js';
|
|
4
6
|
import type { CommandContext, EventJournal, ProjectionStore } from '@atolis-hq/eventing';
|
|
5
|
-
import { type ActivationId, type ActivityOutcome } from '../../activities/index.js';
|
|
6
|
-
import type { ExecutionFailureCode } from '../../execution/index.js';
|
|
7
|
+
import { type ActivationId, type ActivityOutcome, type ParentActionRequest } from '../../activities/index.js';
|
|
8
|
+
import type { ExecutionFailureCode, ExecutionMaintenance } from '../../execution/index.js';
|
|
7
9
|
import { type WorkItemId, type WorkItemView, type WorkService } from '../../work/index.js';
|
|
8
10
|
import type { StartWorkflowInstance } from '../contracts/commands.js';
|
|
9
11
|
import type { CompiledWorkflow, TransitionTarget } from '../contracts/config.js';
|
|
@@ -17,6 +19,7 @@ export declare class OrchestrationService {
|
|
|
17
19
|
private readonly delegationCommands;
|
|
18
20
|
private readonly delegationGate;
|
|
19
21
|
private readonly delegatedWork;
|
|
22
|
+
private readonly delivery;
|
|
20
23
|
private readonly prerequisiteReasons;
|
|
21
24
|
private readonly resumeClarification;
|
|
22
25
|
private readonly repository;
|
|
@@ -34,6 +37,121 @@ export declare class OrchestrationService {
|
|
|
34
37
|
private readonly definitions;
|
|
35
38
|
private readonly work;
|
|
36
39
|
constructor(journal: EventJournal, work: WorkService, definitions: Readonly<Record<string, CompiledWorkflow>>, projections?: ProjectionStore, isAgentActivity?: AgentActivityClassifier, delegation?: DelegationDependenciesFactory);
|
|
40
|
+
deliveryStateFor(workflowInstanceId: string): Promise<{
|
|
41
|
+
integration: import("../domain/delivery-integration.js").IntegrationAssessment | null;
|
|
42
|
+
maintenance: readonly {
|
|
43
|
+
maintenanceId: string;
|
|
44
|
+
target: {
|
|
45
|
+
childWorkItemId: WorkItemId;
|
|
46
|
+
outputName: string;
|
|
47
|
+
};
|
|
48
|
+
kind: "rebase" | "retarget" | "resolve-conflicts";
|
|
49
|
+
resourceId: string;
|
|
50
|
+
repositoryResourceId: string;
|
|
51
|
+
previous: {
|
|
52
|
+
revision: string;
|
|
53
|
+
pullRequestBase: string;
|
|
54
|
+
baseRevision?: string | undefined;
|
|
55
|
+
};
|
|
56
|
+
current: {
|
|
57
|
+
revision: string;
|
|
58
|
+
pullRequestBase: string;
|
|
59
|
+
baseRevision?: string | undefined;
|
|
60
|
+
};
|
|
61
|
+
producer: {
|
|
62
|
+
runId: string;
|
|
63
|
+
activationId: string;
|
|
64
|
+
};
|
|
65
|
+
recordedAt?: string | undefined;
|
|
66
|
+
}[];
|
|
67
|
+
required: {
|
|
68
|
+
cohortId: string;
|
|
69
|
+
assignmentId: string;
|
|
70
|
+
outputName: string;
|
|
71
|
+
childWorkItemId: WorkItemId;
|
|
72
|
+
}[];
|
|
73
|
+
selection: {
|
|
74
|
+
requestId: string;
|
|
75
|
+
revision: number;
|
|
76
|
+
entries: {
|
|
77
|
+
cohortId: string;
|
|
78
|
+
assignmentId: string;
|
|
79
|
+
childWorkItemId: WorkItemId;
|
|
80
|
+
output: {
|
|
81
|
+
name: string;
|
|
82
|
+
reference: {
|
|
83
|
+
workItemId: WorkItemId;
|
|
84
|
+
revisionId: string;
|
|
85
|
+
} | {
|
|
86
|
+
workItemId: WorkItemId;
|
|
87
|
+
resourceId: string;
|
|
88
|
+
repositoryResourceId: string;
|
|
89
|
+
revision: string;
|
|
90
|
+
branch: string;
|
|
91
|
+
pullRequestBase: string;
|
|
92
|
+
runId: string;
|
|
93
|
+
baseRevision?: string | undefined;
|
|
94
|
+
merged?: true | undefined;
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
replaces?: {
|
|
98
|
+
childWorkItemId: WorkItemId;
|
|
99
|
+
outputName: string;
|
|
100
|
+
} | undefined;
|
|
101
|
+
}[];
|
|
102
|
+
} | null;
|
|
103
|
+
history: readonly {
|
|
104
|
+
qaId: string;
|
|
105
|
+
candidateId: string;
|
|
106
|
+
verdict: "blocked" | "pass" | "fail";
|
|
107
|
+
revisions: {
|
|
108
|
+
resourceId: string;
|
|
109
|
+
revision: string;
|
|
110
|
+
}[];
|
|
111
|
+
environment: {
|
|
112
|
+
available: boolean;
|
|
113
|
+
recipe?: string | undefined;
|
|
114
|
+
};
|
|
115
|
+
findings: string[];
|
|
116
|
+
evidence?: {
|
|
117
|
+
workItemId: WorkItemId;
|
|
118
|
+
revisionId: string;
|
|
119
|
+
}[] | undefined;
|
|
120
|
+
exhausted?: boolean | undefined;
|
|
121
|
+
runId?: string | undefined;
|
|
122
|
+
activationId?: string | undefined;
|
|
123
|
+
}[];
|
|
124
|
+
completion: import("../domain/delivery-qa.js").CompletionDecision;
|
|
125
|
+
selectionRevision: number;
|
|
126
|
+
stale: readonly string[];
|
|
127
|
+
candidate: import("../contracts/delivery.js").DeliveryCandidate | null;
|
|
128
|
+
candidateCurrent: boolean;
|
|
129
|
+
qa: import("../contracts/delivery.js").DeliveryQa | null;
|
|
130
|
+
qaEffective: boolean;
|
|
131
|
+
repair: {
|
|
132
|
+
readonly failedRounds: number;
|
|
133
|
+
readonly exhausted: boolean;
|
|
134
|
+
readonly unresolvedFindings: readonly string[];
|
|
135
|
+
};
|
|
136
|
+
}>;
|
|
137
|
+
deliveryQaPreparation(workflowInstanceId: string): Promise<{
|
|
138
|
+
candidateId: string;
|
|
139
|
+
selectionRevision: number;
|
|
140
|
+
criteria: string[];
|
|
141
|
+
inputs: {
|
|
142
|
+
workItemId: string;
|
|
143
|
+
outputName: string;
|
|
144
|
+
revision: string;
|
|
145
|
+
}[];
|
|
146
|
+
repositories: {
|
|
147
|
+
resourceId: string;
|
|
148
|
+
sourceRef: string;
|
|
149
|
+
sourceRevision: string;
|
|
150
|
+
pullRequestBase: string;
|
|
151
|
+
requiredSourceRef?: string | undefined;
|
|
152
|
+
}[];
|
|
153
|
+
recipe?: string | undefined;
|
|
154
|
+
} | undefined>;
|
|
37
155
|
repositoryAuthority(workItemId: string): Promise<string[] | undefined>;
|
|
38
156
|
repositoryAssignment(workItemId: string): Promise<{
|
|
39
157
|
resourceId: string;
|
|
@@ -82,6 +200,10 @@ export declare class OrchestrationService {
|
|
|
82
200
|
cohortId?: string | undefined;
|
|
83
201
|
useAsBase?: boolean | undefined;
|
|
84
202
|
}[] | undefined;
|
|
203
|
+
replaces?: {
|
|
204
|
+
cohortId: string;
|
|
205
|
+
assignmentId: string;
|
|
206
|
+
} | undefined;
|
|
85
207
|
repository?: {
|
|
86
208
|
resourceId: string;
|
|
87
209
|
sourceRef: string;
|
|
@@ -93,13 +215,221 @@ export declare class OrchestrationService {
|
|
|
93
215
|
planRevision?: number | undefined;
|
|
94
216
|
maxConcurrentRuns?: number | undefined;
|
|
95
217
|
}>;
|
|
218
|
+
selectDelivery(caller: DelegationCaller, input: DeliverySelectionCommand, context: CommandContext): Promise<{
|
|
219
|
+
selection: {
|
|
220
|
+
requestId: string;
|
|
221
|
+
revision: number;
|
|
222
|
+
entries: {
|
|
223
|
+
cohortId: string;
|
|
224
|
+
assignmentId: string;
|
|
225
|
+
childWorkItemId: WorkItemId;
|
|
226
|
+
output: {
|
|
227
|
+
name: string;
|
|
228
|
+
reference: {
|
|
229
|
+
workItemId: WorkItemId;
|
|
230
|
+
revisionId: string;
|
|
231
|
+
} | {
|
|
232
|
+
workItemId: WorkItemId;
|
|
233
|
+
resourceId: string;
|
|
234
|
+
repositoryResourceId: string;
|
|
235
|
+
revision: string;
|
|
236
|
+
branch: string;
|
|
237
|
+
pullRequestBase: string;
|
|
238
|
+
runId: string;
|
|
239
|
+
baseRevision?: string | undefined;
|
|
240
|
+
merged?: true | undefined;
|
|
241
|
+
};
|
|
242
|
+
};
|
|
243
|
+
replaces?: {
|
|
244
|
+
childWorkItemId: WorkItemId;
|
|
245
|
+
outputName: string;
|
|
246
|
+
} | undefined;
|
|
247
|
+
}[];
|
|
248
|
+
};
|
|
249
|
+
replay: boolean;
|
|
250
|
+
}>;
|
|
251
|
+
recordDeliveryCandidate(caller: DelegationCaller, input: DeliveryCandidateCommand, context: CommandContext): Promise<{
|
|
252
|
+
candidate: {
|
|
253
|
+
candidateId: string;
|
|
254
|
+
selectionRevision: number;
|
|
255
|
+
repositories: {
|
|
256
|
+
resourceId: string;
|
|
257
|
+
revision: string;
|
|
258
|
+
pullRequestBase: string;
|
|
259
|
+
source: {
|
|
260
|
+
kind: "output";
|
|
261
|
+
tip: {
|
|
262
|
+
childWorkItemId: WorkItemId;
|
|
263
|
+
outputName: string;
|
|
264
|
+
};
|
|
265
|
+
} | {
|
|
266
|
+
kind: "retained-ref";
|
|
267
|
+
ref: string;
|
|
268
|
+
};
|
|
269
|
+
contributions: {
|
|
270
|
+
childWorkItemId: WorkItemId;
|
|
271
|
+
outputName: string;
|
|
272
|
+
}[];
|
|
273
|
+
}[];
|
|
274
|
+
context: {
|
|
275
|
+
childWorkItemId: WorkItemId;
|
|
276
|
+
outputName: string;
|
|
277
|
+
}[];
|
|
278
|
+
criteria: string[];
|
|
279
|
+
subjects?: {
|
|
280
|
+
childWorkItemId: WorkItemId;
|
|
281
|
+
outputName: string;
|
|
282
|
+
revision: string;
|
|
283
|
+
pullRequestBase: string;
|
|
284
|
+
baseRevision?: string | undefined;
|
|
285
|
+
}[] | undefined;
|
|
286
|
+
recipe?: string | undefined;
|
|
287
|
+
};
|
|
288
|
+
replay: boolean;
|
|
289
|
+
}>;
|
|
290
|
+
recordDeliveryQa(caller: DelegationCaller, input: DeliveryQaCommand, context: CommandContext): Promise<{
|
|
291
|
+
qa: {
|
|
292
|
+
qaId: string;
|
|
293
|
+
candidateId: string;
|
|
294
|
+
verdict: "blocked" | "pass" | "fail";
|
|
295
|
+
revisions: {
|
|
296
|
+
resourceId: string;
|
|
297
|
+
revision: string;
|
|
298
|
+
}[];
|
|
299
|
+
environment: {
|
|
300
|
+
available: boolean;
|
|
301
|
+
recipe?: string | undefined;
|
|
302
|
+
};
|
|
303
|
+
findings: string[];
|
|
304
|
+
evidence?: {
|
|
305
|
+
workItemId: WorkItemId;
|
|
306
|
+
revisionId: string;
|
|
307
|
+
}[] | undefined;
|
|
308
|
+
exhausted?: boolean | undefined;
|
|
309
|
+
runId?: string | undefined;
|
|
310
|
+
activationId?: string | undefined;
|
|
311
|
+
};
|
|
312
|
+
replay: boolean;
|
|
313
|
+
}>;
|
|
314
|
+
recordDeliveryMaintenance(caller: DelegationCaller, input: DeliveryMaintenanceCommand, context: CommandContext): Promise<{
|
|
315
|
+
readonly maintenance: import("../contracts/delivery.js").DeliveryMaintenance;
|
|
316
|
+
readonly replay: boolean;
|
|
317
|
+
}>;
|
|
318
|
+
authorizeParentAction(request: ParentActionRequest): Promise<import("../../activities/index.js").ParentActionDecision>;
|
|
319
|
+
/** The branch leases Execution must hold for the configured maintenance stage's activation. */
|
|
320
|
+
deliveryMaintenancePreparation(workflowInstanceId: string): Promise<ExecutionMaintenance | undefined>;
|
|
96
321
|
inspectDelegation(caller: DelegationCaller, context: CommandContext): Promise<{
|
|
322
|
+
delivery: {
|
|
323
|
+
integration: import("../domain/delivery-integration.js").IntegrationAssessment | null;
|
|
324
|
+
maintenance: readonly {
|
|
325
|
+
maintenanceId: string;
|
|
326
|
+
target: {
|
|
327
|
+
childWorkItemId: WorkItemId;
|
|
328
|
+
outputName: string;
|
|
329
|
+
};
|
|
330
|
+
kind: "rebase" | "retarget" | "resolve-conflicts";
|
|
331
|
+
resourceId: string;
|
|
332
|
+
repositoryResourceId: string;
|
|
333
|
+
previous: {
|
|
334
|
+
revision: string;
|
|
335
|
+
pullRequestBase: string;
|
|
336
|
+
baseRevision?: string | undefined;
|
|
337
|
+
};
|
|
338
|
+
current: {
|
|
339
|
+
revision: string;
|
|
340
|
+
pullRequestBase: string;
|
|
341
|
+
baseRevision?: string | undefined;
|
|
342
|
+
};
|
|
343
|
+
producer: {
|
|
344
|
+
runId: string;
|
|
345
|
+
activationId: string;
|
|
346
|
+
};
|
|
347
|
+
recordedAt?: string | undefined;
|
|
348
|
+
}[];
|
|
349
|
+
required: {
|
|
350
|
+
cohortId: string;
|
|
351
|
+
assignmentId: string;
|
|
352
|
+
outputName: string;
|
|
353
|
+
childWorkItemId: WorkItemId;
|
|
354
|
+
}[];
|
|
355
|
+
selection: {
|
|
356
|
+
requestId: string;
|
|
357
|
+
revision: number;
|
|
358
|
+
entries: {
|
|
359
|
+
cohortId: string;
|
|
360
|
+
assignmentId: string;
|
|
361
|
+
childWorkItemId: WorkItemId;
|
|
362
|
+
output: {
|
|
363
|
+
name: string;
|
|
364
|
+
reference: {
|
|
365
|
+
workItemId: WorkItemId;
|
|
366
|
+
revisionId: string;
|
|
367
|
+
} | {
|
|
368
|
+
workItemId: WorkItemId;
|
|
369
|
+
resourceId: string;
|
|
370
|
+
repositoryResourceId: string;
|
|
371
|
+
revision: string;
|
|
372
|
+
branch: string;
|
|
373
|
+
pullRequestBase: string;
|
|
374
|
+
runId: string;
|
|
375
|
+
baseRevision?: string | undefined;
|
|
376
|
+
merged?: true | undefined;
|
|
377
|
+
};
|
|
378
|
+
};
|
|
379
|
+
replaces?: {
|
|
380
|
+
childWorkItemId: WorkItemId;
|
|
381
|
+
outputName: string;
|
|
382
|
+
} | undefined;
|
|
383
|
+
}[];
|
|
384
|
+
} | null;
|
|
385
|
+
history: readonly {
|
|
386
|
+
qaId: string;
|
|
387
|
+
candidateId: string;
|
|
388
|
+
verdict: "blocked" | "pass" | "fail";
|
|
389
|
+
revisions: {
|
|
390
|
+
resourceId: string;
|
|
391
|
+
revision: string;
|
|
392
|
+
}[];
|
|
393
|
+
environment: {
|
|
394
|
+
available: boolean;
|
|
395
|
+
recipe?: string | undefined;
|
|
396
|
+
};
|
|
397
|
+
findings: string[];
|
|
398
|
+
evidence?: {
|
|
399
|
+
workItemId: WorkItemId;
|
|
400
|
+
revisionId: string;
|
|
401
|
+
}[] | undefined;
|
|
402
|
+
exhausted?: boolean | undefined;
|
|
403
|
+
runId?: string | undefined;
|
|
404
|
+
activationId?: string | undefined;
|
|
405
|
+
}[];
|
|
406
|
+
completion: import("../domain/delivery-qa.js").CompletionDecision;
|
|
407
|
+
selectionRevision: number;
|
|
408
|
+
stale: readonly string[];
|
|
409
|
+
candidate: import("../contracts/delivery.js").DeliveryCandidate | null;
|
|
410
|
+
candidateCurrent: boolean;
|
|
411
|
+
qa: import("../contracts/delivery.js").DeliveryQa | null;
|
|
412
|
+
qaEffective: boolean;
|
|
413
|
+
repair: {
|
|
414
|
+
readonly failedRounds: number;
|
|
415
|
+
readonly exhausted: boolean;
|
|
416
|
+
readonly unresolvedFindings: readonly string[];
|
|
417
|
+
};
|
|
418
|
+
};
|
|
97
419
|
policy: {
|
|
98
420
|
workflows: string[];
|
|
99
421
|
maxDepth: number;
|
|
100
422
|
maxDescendants: number;
|
|
101
423
|
maxConcurrentRuns: number;
|
|
102
424
|
repositories?: string[] | undefined;
|
|
425
|
+
completion?: "qa-approved" | "merge-required" | undefined;
|
|
426
|
+
qa?: {
|
|
427
|
+
stage: string;
|
|
428
|
+
recipe?: string | undefined;
|
|
429
|
+
} | undefined;
|
|
430
|
+
maintenance?: {
|
|
431
|
+
stage: string;
|
|
432
|
+
} | undefined;
|
|
103
433
|
} | null;
|
|
104
434
|
repositories: string[];
|
|
105
435
|
planRevision: number;
|
|
@@ -166,6 +496,10 @@ export declare class OrchestrationService {
|
|
|
166
496
|
cohortId?: string | undefined;
|
|
167
497
|
useAsBase?: boolean | undefined;
|
|
168
498
|
}[] | undefined;
|
|
499
|
+
replaces?: {
|
|
500
|
+
cohortId: string;
|
|
501
|
+
assignmentId: string;
|
|
502
|
+
} | undefined;
|
|
169
503
|
repository?: {
|
|
170
504
|
resourceId: string;
|
|
171
505
|
sourceRef: string;
|
|
@@ -249,6 +583,10 @@ export declare class OrchestrationService {
|
|
|
249
583
|
cohortId?: string | undefined;
|
|
250
584
|
useAsBase?: boolean | undefined;
|
|
251
585
|
}[] | undefined;
|
|
586
|
+
replaces?: {
|
|
587
|
+
cohortId: string;
|
|
588
|
+
assignmentId: string;
|
|
589
|
+
} | undefined;
|
|
252
590
|
repository?: {
|
|
253
591
|
resourceId: string;
|
|
254
592
|
sourceRef: string;
|
|
@@ -389,6 +727,7 @@ type DelegationDependenciesFactory = (queries: {
|
|
|
389
727
|
artifacts: DelegationArtifacts;
|
|
390
728
|
authority?: DelegationAuthority;
|
|
391
729
|
repositories?: DelegationRepositories;
|
|
730
|
+
integration?: DeliveryIntegration;
|
|
392
731
|
runHasEnded: (runId: string) => Promise<boolean>;
|
|
393
732
|
};
|
|
394
733
|
export {};
|