@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,132 @@
|
|
|
1
|
+
import { isDeepStrictEqual } from 'node:util';
|
|
2
|
+
import { DeliveryRejection } from '../contracts/vocabulary.js';
|
|
3
|
+
import { childOf, currentSelection, entryKey, outputKey, qualifying, reject, requirements, } from './delivery-facts.js';
|
|
4
|
+
/**
|
|
5
|
+
* Validates a complete selection against the current one and the original requirements.
|
|
6
|
+
* An omitted requirement is never a waiver: every original output must stay covered by its own
|
|
7
|
+
* qualifying result or an authorized, criteria-preserving replacement that names the output
|
|
8
|
+
* currently selected.
|
|
9
|
+
*/
|
|
10
|
+
export function reviseSelection(facts, command) {
|
|
11
|
+
const prior = facts.selections.find((entry) => entry.requestId === command.requestId);
|
|
12
|
+
const revision = currentSelection(facts)?.revision ?? 0;
|
|
13
|
+
if (prior !== undefined) {
|
|
14
|
+
if (prior.revision !== command.expectedRevision + 1 || !sameEntries(prior, command))
|
|
15
|
+
throw reject(DeliveryRejection.Conflict, 'Selection request identity was reused');
|
|
16
|
+
return { selection: prior, replay: true };
|
|
17
|
+
}
|
|
18
|
+
if (command.expectedRevision !== revision)
|
|
19
|
+
throw reject(DeliveryRejection.StaleSelection, `Selection is at revision ${revision}, not ${command.expectedRevision}; inspect and retry`);
|
|
20
|
+
const required = requirements(facts.reservations);
|
|
21
|
+
const seen = new Set();
|
|
22
|
+
const entries = command.entries.map((entry) => {
|
|
23
|
+
const requirement = required.find((candidate) => candidate.cohortId === entry.cohortId &&
|
|
24
|
+
candidate.assignmentId === entry.assignmentId &&
|
|
25
|
+
candidate.outputName === entry.output.outputName);
|
|
26
|
+
if (requirement === undefined)
|
|
27
|
+
throw reject(DeliveryRejection.UnknownRequirement, `${entryKey(entry, entry.output.outputName)} is not an original required output`);
|
|
28
|
+
const key = entryKey(entry, requirement.outputName);
|
|
29
|
+
if (seen.has(key))
|
|
30
|
+
throw reject(DeliveryRejection.Conflict, `${key} is selected twice`);
|
|
31
|
+
seen.add(key);
|
|
32
|
+
return selected(facts, entry, requirement);
|
|
33
|
+
});
|
|
34
|
+
const missing = required.filter((requirement) => !seen.has(entryKey(requirement, requirement.outputName)));
|
|
35
|
+
if (missing.length > 0)
|
|
36
|
+
throw reject(DeliveryRejection.UncoveredRequirement, `Original requirements are not covered: ${missing
|
|
37
|
+
.map((requirement) => entryKey(requirement, requirement.outputName))
|
|
38
|
+
.join(', ')}`);
|
|
39
|
+
return {
|
|
40
|
+
replay: false,
|
|
41
|
+
selection: { requestId: command.requestId, revision: revision + 1, entries },
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function selected(facts, entry, requirement) {
|
|
45
|
+
const output = qualifying(facts, entry.output);
|
|
46
|
+
if (output === undefined)
|
|
47
|
+
throw reject(DeliveryRejection.OutputMismatch, `${outputKey(entry.output)} is not a qualifying result`);
|
|
48
|
+
if (entry.output.childWorkItemId === requirement.child.workItemId) {
|
|
49
|
+
if (entry.replaces !== undefined)
|
|
50
|
+
throw reject(DeliveryRejection.ReplacementConflict, `${entryKey(requirement, requirement.outputName)} is not a replacement`);
|
|
51
|
+
}
|
|
52
|
+
else
|
|
53
|
+
assertReplacement(facts, requirement, entry);
|
|
54
|
+
return entryOf(entry, requirement, output);
|
|
55
|
+
}
|
|
56
|
+
function entryOf(entry, requirement, output) {
|
|
57
|
+
return {
|
|
58
|
+
cohortId: requirement.cohortId,
|
|
59
|
+
assignmentId: requirement.assignmentId,
|
|
60
|
+
childWorkItemId: entry.output.childWorkItemId,
|
|
61
|
+
output,
|
|
62
|
+
...(entry.replaces === undefined ? {} : { replaces: entry.replaces }),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function assertReplacement(facts, requirement, entry) {
|
|
66
|
+
const key = entryKey(requirement, requirement.outputName);
|
|
67
|
+
const found = childOf(facts.reservations, entry.output.childWorkItemId);
|
|
68
|
+
if (found?.child.replaces?.cohortId !== requirement.cohortId ||
|
|
69
|
+
found.child.replaces.assignmentId !== requirement.assignmentId)
|
|
70
|
+
throw reject(DeliveryRejection.ReplacementConflict, `${outputKey(entry.output)} was not delegated as a replacement for ${key}`);
|
|
71
|
+
if (!requirement.criteria.every((criterion) => found.child.criteria.includes(criterion)))
|
|
72
|
+
throw reject(DeliveryRejection.ReplacementConflict, `${outputKey(entry.output)} does not preserve the original acceptance criteria`);
|
|
73
|
+
const current = currentFor(facts, requirement);
|
|
74
|
+
if (entry.replaces === undefined && outputKey(entry.output) === outputKey(current))
|
|
75
|
+
return;
|
|
76
|
+
if (entry.replaces === undefined)
|
|
77
|
+
throw reject(DeliveryRejection.ReplacementConflict, `${key} replacement must name the output it replaces`);
|
|
78
|
+
if (outputKey(entry.replaces) !== outputKey(current))
|
|
79
|
+
throw reject(DeliveryRejection.ReplacementConflict, `${key} currently selects ${outputKey(current)}, not ${outputKey(entry.replaces)}`);
|
|
80
|
+
}
|
|
81
|
+
function currentFor(facts, requirement) {
|
|
82
|
+
const entry = currentSelection(facts)?.entries.find((candidate) => entryKey(candidate, candidate.output.name) === entryKey(requirement, requirement.outputName));
|
|
83
|
+
return entry === undefined
|
|
84
|
+
? { childWorkItemId: requirement.child.workItemId, outputName: requirement.outputName }
|
|
85
|
+
: { childWorkItemId: entry.childWorkItemId, outputName: entry.output.name };
|
|
86
|
+
}
|
|
87
|
+
function sameEntries(prior, command) {
|
|
88
|
+
const priorKeys = prior.entries.map((entry) => `${entryKey(entry, entry.output.name)}/${entry.childWorkItemId}`);
|
|
89
|
+
const commandKeys = command.entries.map((entry) => `${entryKey(entry, entry.output.outputName)}/${entry.output.childWorkItemId}`);
|
|
90
|
+
return isDeepStrictEqual(priorKeys.sort(), commandKeys.sort());
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Selected results whose upstream input was replaced. A superseded output makes every consumer
|
|
94
|
+
* stale, transitively; unrelated evidence is untouched and old facts stay in the history.
|
|
95
|
+
*/
|
|
96
|
+
export function staleEntries(facts) {
|
|
97
|
+
const current = currentSelection(facts);
|
|
98
|
+
if (current === undefined)
|
|
99
|
+
return new Set();
|
|
100
|
+
const live = current.entries.map((entry) => entry.output.reference);
|
|
101
|
+
const dead = facts.selections
|
|
102
|
+
.flatMap((selection) => selection.entries)
|
|
103
|
+
.flatMap((entry) => (entry.replaces === undefined ? [] : [qualifying(facts, entry.replaces)]))
|
|
104
|
+
.flatMap((output) => (output === undefined ? [] : [output.reference]))
|
|
105
|
+
.filter((reference) => !live.some((candidate) => sameRevision(candidate, reference)));
|
|
106
|
+
const stale = new Set();
|
|
107
|
+
for (let changed = true; changed;) {
|
|
108
|
+
changed = false;
|
|
109
|
+
for (const entry of current.entries) {
|
|
110
|
+
const key = entryKey(entry, entry.output.name);
|
|
111
|
+
const consumed = facts.consumed.get(entry.childWorkItemId) ?? [];
|
|
112
|
+
if (stale.has(key) || !consumesAny(consumed, dead))
|
|
113
|
+
continue;
|
|
114
|
+
stale.add(key);
|
|
115
|
+
dead.push(entry.output.reference);
|
|
116
|
+
changed = true;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return stale;
|
|
120
|
+
}
|
|
121
|
+
const consumesAny = (consumed, dead) => consumed.some((input) => dead.some((reference) => sameRevision(reference, input.reference)));
|
|
122
|
+
/** Provider metadata can gain a base/merge observation without changing the consumed code. */
|
|
123
|
+
function sameRevision(a, b) {
|
|
124
|
+
if (a.workItemId !== b.workItemId)
|
|
125
|
+
return false;
|
|
126
|
+
if ('revisionId' in a)
|
|
127
|
+
return 'revisionId' in b && a.revisionId === b.revisionId;
|
|
128
|
+
return (!('revisionId' in b) &&
|
|
129
|
+
a.resourceId === b.resourceId &&
|
|
130
|
+
a.repositoryResourceId === b.repositoryResourceId &&
|
|
131
|
+
a.revision === b.revision);
|
|
132
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type ActivityRegistry } from '../../activities/index.js';
|
|
2
|
+
import type { CompiledStage, WorkflowDefinitionConfig } from '../contracts/config.js';
|
|
3
|
+
import { type StageName } from '../contracts/identifiers.js';
|
|
4
|
+
type Stages = Readonly<Record<StageName, CompiledStage>>;
|
|
5
|
+
export declare function assertDeliveryQa(config: WorkflowDefinitionConfig, stages: Stages, activities: ActivityRegistry): void;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ActivityExecutionKind } from '../../activities/index.js';
|
|
2
|
+
import { WorkspaceMode } from '../../execution/index.js';
|
|
3
|
+
import { stageName } from '../contracts/identifiers.js';
|
|
4
|
+
import { DeliveryCompletion } from '../contracts/vocabulary.js';
|
|
5
|
+
export function assertDeliveryQa(config, stages, activities) {
|
|
6
|
+
const qa = config.delegation?.qa;
|
|
7
|
+
if (qa !== undefined) {
|
|
8
|
+
const stage = stages[stageName(qa.stage)];
|
|
9
|
+
if (stage === undefined ||
|
|
10
|
+
stage.execution?.workspace !== WorkspaceMode.ReadOnly ||
|
|
11
|
+
activities.describe(stage.activity).executionKind !== ActivityExecutionKind.Agent)
|
|
12
|
+
throw new Error('Delegation QA must name a configured read-only agent stage');
|
|
13
|
+
}
|
|
14
|
+
assertDeliveryMaintenance(config, stages, activities);
|
|
15
|
+
}
|
|
16
|
+
/** Maintenance writes through branch leases Wake prepares, so its stage brings no workspace. */
|
|
17
|
+
function assertDeliveryMaintenance(config, stages, activities) {
|
|
18
|
+
const maintenance = config.delegation?.maintenance;
|
|
19
|
+
if (maintenance === undefined)
|
|
20
|
+
return;
|
|
21
|
+
const stage = stages[stageName(maintenance.stage)];
|
|
22
|
+
if (config.delegation?.completion !== DeliveryCompletion.MergeRequired ||
|
|
23
|
+
!isLeaseOnlyAgentStage(stage, activities))
|
|
24
|
+
throw new Error('Delegation maintenance must name an agent stage without a workspace of its own in a merge-required delivery; Wake leases the target branches');
|
|
25
|
+
if (maintenance.stage === config.delegation?.qa?.stage)
|
|
26
|
+
throw new Error('Delegation maintenance cannot reuse the QA stage');
|
|
27
|
+
}
|
|
28
|
+
function isLeaseOnlyAgentStage(stage, activities) {
|
|
29
|
+
return (stage !== undefined &&
|
|
30
|
+
(stage.execution?.workspace ?? WorkspaceMode.None) === WorkspaceMode.None &&
|
|
31
|
+
activities.describe(stage.activity).executionKind === ActivityExecutionKind.Agent);
|
|
32
|
+
}
|
|
@@ -11,19 +11,25 @@ import { AwaitTimeoutBlockReason } from './signal-policy.js';
|
|
|
11
11
|
const FailedOutcomeSignal = signalName(ActivityOutcomeKind.Failed);
|
|
12
12
|
export function isOperatorRetryEligible(view) {
|
|
13
13
|
const pending = view.pendingActivation;
|
|
14
|
+
const deliveryGate = view.status === WorkflowStatus.Blocked && view.deliveryGateBlock !== undefined;
|
|
14
15
|
const eligibleActivation = pending !== undefined &&
|
|
15
|
-
pending.status
|
|
16
|
+
retryableActivationStatus(pending.status, deliveryGate) &&
|
|
16
17
|
pending.supplemental !== true &&
|
|
17
|
-
pending.followOnIndex === undefined &&
|
|
18
|
-
view.acceptedOutcomes.includes(pending.activationId);
|
|
18
|
+
(pending.followOnIndex === undefined || deliveryGate) &&
|
|
19
|
+
(deliveryGate || view.acceptedOutcomes.includes(pending.activationId));
|
|
19
20
|
if (!eligibleActivation || pending === undefined)
|
|
20
21
|
return false;
|
|
21
22
|
if (view.status === WorkflowStatus.Blocked)
|
|
22
23
|
return isRetryEligibleBlock(view, pending);
|
|
23
24
|
return isRetryEligibleFailedWait(view);
|
|
24
25
|
}
|
|
26
|
+
function retryableActivationStatus(status, deliveryGate) {
|
|
27
|
+
return (status === ActivityActivationStatus.Completed ||
|
|
28
|
+
(deliveryGate && status === ActivityActivationStatus.Waiting));
|
|
29
|
+
}
|
|
25
30
|
function isRetryEligibleBlock(view, pending) {
|
|
26
|
-
return (view.
|
|
31
|
+
return (view.deliveryGateBlock !== undefined ||
|
|
32
|
+
view.blockReason === AwaitTimeoutBlockReason ||
|
|
27
33
|
(view.blockReason === 'unconfigured outcome failed' &&
|
|
28
34
|
view.lastOutcome?.kind === ActivityOutcomeKind.Failed) ||
|
|
29
35
|
view.executionFailure?.activationId === pending.activationId);
|
|
@@ -114,7 +120,10 @@ function requestRetry(definition, state, input, sessionPolicy) {
|
|
|
114
120
|
kind: 'ignored',
|
|
115
121
|
reason: 'workflow is not in a retryable failed-stage state',
|
|
116
122
|
};
|
|
117
|
-
const
|
|
123
|
+
const retryStage = state.deliveryGateBlock?.retryStage ?? state.currentStage;
|
|
124
|
+
const stage = definition.stages[retryStage];
|
|
125
|
+
if (state.deliveryGateBlock !== undefined)
|
|
126
|
+
sessionPolicy = 'fresh';
|
|
118
127
|
const events = [
|
|
119
128
|
stateDraft(state, input, {
|
|
120
129
|
eventType: OrchestrationEventType.OperatorRetryRequested,
|
|
@@ -123,15 +132,17 @@ function requestRetry(definition, state, input, sessionPolicy) {
|
|
|
123
132
|
commandId: input.commandId,
|
|
124
133
|
},
|
|
125
134
|
}, 1),
|
|
126
|
-
stateDraft(state, input, {
|
|
127
|
-
eventType: OrchestrationEventType.ActivityRequested,
|
|
128
|
-
payload: activation(state.workflowInstanceId, nextOrdinal(state), stage.activity, stage.with, {
|
|
129
|
-
execution: stage.execution,
|
|
130
|
-
stage: stageName(state.currentStage),
|
|
131
|
-
...(sessionPolicy === undefined ? {} : { sessionPolicy }),
|
|
132
|
-
}),
|
|
133
|
-
}, 2),
|
|
134
135
|
];
|
|
136
|
+
if (retryStage !== state.currentStage)
|
|
137
|
+
events.push(stateDraft(state, input, { eventType: OrchestrationEventType.StageEntered, payload: { stage: retryStage } }, 2));
|
|
138
|
+
events.push(stateDraft(state, input, {
|
|
139
|
+
eventType: OrchestrationEventType.ActivityRequested,
|
|
140
|
+
payload: activation(state.workflowInstanceId, nextOrdinal(state), stage.activity, stage.with, {
|
|
141
|
+
execution: stage.execution,
|
|
142
|
+
stage: retryStage,
|
|
143
|
+
...(sessionPolicy === undefined ? {} : { sessionPolicy }),
|
|
144
|
+
}),
|
|
145
|
+
}, events.length + 1));
|
|
135
146
|
return { kind: 'append', events };
|
|
136
147
|
}
|
|
137
148
|
export function requestChangesResume(definition, state, input) {
|
|
@@ -27,6 +27,7 @@ export type MutableWorkflowInstance = {
|
|
|
27
27
|
delegationAttention?: WorkflowInstanceView['delegationAttention'];
|
|
28
28
|
status: WorkflowInstanceView['status'];
|
|
29
29
|
blockReason?: string;
|
|
30
|
+
deliveryGateBlock?: NonNullable<WorkflowInstanceView['deliveryGateBlock']>;
|
|
30
31
|
currentStage: WorkflowInstanceView['currentStage'];
|
|
31
32
|
pendingActivation?: ActivityActivationView;
|
|
32
33
|
repeatCounts: Record<string, number>;
|
|
@@ -139,6 +139,10 @@ function applyLifecycleFact(state, event) {
|
|
|
139
139
|
delete state.delegationAttention;
|
|
140
140
|
state.status = orchestrationStatusTransitions[OrchestrationEventType.InstanceBlocked];
|
|
141
141
|
state.blockReason = event.payload.reason;
|
|
142
|
+
if (event.payload.deliveryGate === undefined)
|
|
143
|
+
delete state.deliveryGateBlock;
|
|
144
|
+
else
|
|
145
|
+
state.deliveryGateBlock = event.payload.deliveryGate;
|
|
142
146
|
return;
|
|
143
147
|
case OrchestrationEventType.OperatorRetryRequested:
|
|
144
148
|
state.operatorRetryCommandIds.push(event.payload.commandId);
|
|
@@ -209,6 +213,10 @@ function applyCoordinationFact(state, event) {
|
|
|
209
213
|
case OrchestrationEventType.DelegationPrerequisiteBlocked:
|
|
210
214
|
case OrchestrationEventType.DelegationChildBlocked:
|
|
211
215
|
case OrchestrationEventType.DelegationResultSelected:
|
|
216
|
+
case OrchestrationEventType.DeliverySelectionRevised:
|
|
217
|
+
case OrchestrationEventType.DeliveryCandidateRecorded:
|
|
218
|
+
case OrchestrationEventType.DeliveryQaRecorded:
|
|
219
|
+
case OrchestrationEventType.DeliveryMaintenanceRecorded:
|
|
212
220
|
return;
|
|
213
221
|
case OrchestrationEventType.DelegationWaitStarted:
|
|
214
222
|
case OrchestrationEventType.DelegationJoined:
|
|
@@ -263,6 +271,7 @@ function updateActivationStatus(state, activationId, status) {
|
|
|
263
271
|
function applyActivityRequested(state, payload) {
|
|
264
272
|
state.status = orchestrationStatusTransitions[OrchestrationEventType.ActivityRequested];
|
|
265
273
|
delete state.waitingFor;
|
|
274
|
+
delete state.deliveryGateBlock;
|
|
266
275
|
state.pendingActivation = {
|
|
267
276
|
...(payload.notBefore === undefined ? {} : { notBefore: payload.notBefore }),
|
|
268
277
|
activationId: payload.activationId,
|
|
@@ -303,6 +312,9 @@ export function immutableWorkflowInstanceView(state) {
|
|
|
303
312
|
: { delegationAttention: state.delegationAttention }),
|
|
304
313
|
status: state.status,
|
|
305
314
|
...(state.blockReason === undefined ? {} : { blockReason: state.blockReason }),
|
|
315
|
+
...(state.deliveryGateBlock === undefined
|
|
316
|
+
? {}
|
|
317
|
+
: { deliveryGateBlock: state.deliveryGateBlock }),
|
|
306
318
|
currentStage: state.currentStage,
|
|
307
319
|
repeatCounts: state.repeatCounts,
|
|
308
320
|
retryCounts: state.retryCounts,
|
|
@@ -35,5 +35,8 @@ export type { WorkflowCompileDiagnostic } from './domain/compile-diagnostics.js'
|
|
|
35
35
|
export type { DelegationArtifacts, DelegationRepositories } from './contracts/delegation-ports.js';
|
|
36
36
|
export { DelegationAttentionError, DelegationConflictError, DelegationPendingError, } from './contracts/delegation.js';
|
|
37
37
|
export type { DelegationAuthority } from './contracts/delegation-ports.js';
|
|
38
|
+
export type { DeliveryIntegration, DeliveryPullRequest } from './contracts/delivery-ports.js';
|
|
39
|
+
export { DeliveryRejectionError, deliveryCandidateCommandSchema, deliveryMaintenanceCommandSchema, deliveryQaCommandSchema, deliverySelectionCommandSchema, } from './contracts/delivery.js';
|
|
40
|
+
export type { DeliveryCandidate, DeliveryCandidateCommand, DeliveryMaintenance, DeliveryMaintenanceCommand, DeliveryQa, DeliveryQaCommand, DeliverySelection, DeliverySelectionCommand, } from './contracts/delivery.js';
|
|
38
41
|
export { delegationAttentionReplySchema, delegationSubmissionSchema, } from './contracts/delegation.js';
|
|
39
42
|
export type { DelegationAttentionBlocker, DelegationAttentionReply, DelegationAttentionRequest, DelegationCaller, DelegationInputs, DelegationPrerequisite, DelegationReservation, DelegationResult, DelegationSubmission, } from './contracts/delegation.js';
|
|
@@ -32,4 +32,5 @@ export * from './domain/workflow-instance.js';
|
|
|
32
32
|
export * from './domain/workflow-selector.js';
|
|
33
33
|
export * from './application/work-completion-summary.js';
|
|
34
34
|
export { DelegationAttentionError, DelegationConflictError, DelegationPendingError, } from './contracts/delegation.js';
|
|
35
|
+
export { DeliveryRejectionError, deliveryCandidateCommandSchema, deliveryMaintenanceCommandSchema, deliveryQaCommandSchema, deliverySelectionCommandSchema, } from './contracts/delivery.js';
|
|
35
36
|
export { delegationAttentionReplySchema, delegationSubmissionSchema, } from './contracts/delegation.js';
|
|
@@ -18,8 +18,50 @@ export interface WorkItemResponse {
|
|
|
18
18
|
/** Raw outcome emitted by the latest agent run, when one is available. */
|
|
19
19
|
readonly lastRunOutcome?: string;
|
|
20
20
|
}
|
|
21
|
+
/** Governed integration progress, derived from provider-observed state; never a separate record. */
|
|
22
|
+
export interface DeliveryIntegrationResponse {
|
|
23
|
+
readonly complete: boolean;
|
|
24
|
+
readonly summary: string;
|
|
25
|
+
readonly targets: readonly {
|
|
26
|
+
/** The child that owns the pull request; integration never transfers ownership. */
|
|
27
|
+
readonly workItemKey: WorkItemKey;
|
|
28
|
+
readonly outputName: string;
|
|
29
|
+
readonly state: string;
|
|
30
|
+
readonly layer: number;
|
|
31
|
+
readonly baseMovement: string;
|
|
32
|
+
readonly evidenceAffected: boolean;
|
|
33
|
+
readonly maintenance?: string;
|
|
34
|
+
readonly detail?: string;
|
|
35
|
+
}[];
|
|
36
|
+
readonly maintenance: readonly {
|
|
37
|
+
readonly maintenanceId: string;
|
|
38
|
+
readonly workItemKey: WorkItemKey;
|
|
39
|
+
readonly outputName: string;
|
|
40
|
+
readonly kind: string;
|
|
41
|
+
readonly previousRevision: string;
|
|
42
|
+
readonly currentRevision: string;
|
|
43
|
+
readonly producerRunId: string;
|
|
44
|
+
}[];
|
|
45
|
+
}
|
|
46
|
+
export interface DeliveryQaResponse {
|
|
47
|
+
readonly integration?: DeliveryIntegrationResponse;
|
|
48
|
+
readonly selectionRevision: number;
|
|
49
|
+
readonly candidateId?: string;
|
|
50
|
+
readonly repositories: readonly {
|
|
51
|
+
readonly resourceId: string;
|
|
52
|
+
readonly revision: string;
|
|
53
|
+
}[];
|
|
54
|
+
readonly stale: readonly string[];
|
|
55
|
+
readonly verdict?: string;
|
|
56
|
+
readonly effective: boolean;
|
|
57
|
+
readonly canComplete: boolean;
|
|
58
|
+
readonly reason?: string;
|
|
59
|
+
readonly exhausted: boolean;
|
|
60
|
+
readonly findings: readonly string[];
|
|
61
|
+
}
|
|
21
62
|
export interface WorkDetailResponse {
|
|
22
63
|
readonly delegation?: {
|
|
64
|
+
readonly qa?: DeliveryQaResponse;
|
|
23
65
|
readonly rootWorkItemKey: WorkItemKey;
|
|
24
66
|
readonly parentWorkItemKey?: WorkItemKey;
|
|
25
67
|
readonly children: readonly {
|
|
@@ -6,6 +6,7 @@ const outcomeSentinels = {
|
|
|
6
6
|
[ActivityOutcomeKind.Blocked]: 'BLOCKED',
|
|
7
7
|
[ActivityOutcomeKind.Failed]: 'FAILED',
|
|
8
8
|
[ActivityOutcomeKind.Waiting]: 'WAITING',
|
|
9
|
+
[ActivityOutcomeKind.Integrated]: 'INTEGRATED',
|
|
9
10
|
};
|
|
10
11
|
// The response preserves optional run facts without introducing a second view model.
|
|
11
12
|
// eslint-disable-next-line complexity
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DelegationAttentionError, DelegationConflictError, delegationAttentionReplySchema, delegationSubmissionSchema, } from '../../orchestration/index.js';
|
|
1
|
+
import { DelegationAttentionError, DelegationConflictError, DeliveryRejectionError, delegationAttentionReplySchema, delegationSubmissionSchema, deliveryCandidateCommandSchema, deliveryMaintenanceCommandSchema, deliveryQaCommandSchema, deliverySelectionCommandSchema, } from '../../orchestration/index.js';
|
|
2
2
|
/** The bound caller is never accepted as a tool argument. */
|
|
3
3
|
export function registerDelegationTools(server, input) {
|
|
4
4
|
server.registerTool('wake_delegation_submit', {
|
|
@@ -39,6 +39,41 @@ export function registerDelegationTools(server, input) {
|
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
|
+
// Rejections carry a typed code so the agent can correct the request instead of retrying.
|
|
43
|
+
const guarded = async (run) => {
|
|
44
|
+
try {
|
|
45
|
+
return { content: [{ type: 'text', text: JSON.stringify(await run()) }] };
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
if (!(error instanceof DeliveryRejectionError))
|
|
49
|
+
throw error;
|
|
50
|
+
return {
|
|
51
|
+
isError: true,
|
|
52
|
+
content: [
|
|
53
|
+
{
|
|
54
|
+
type: 'text',
|
|
55
|
+
text: JSON.stringify({ code: error.code, message: error.message }),
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
server.registerTool('wake_delivery_select', {
|
|
62
|
+
description: 'Record the complete current delivery selection: for every original required output, the qualifying child output that covers it, or an authorized replacement that names the output it replaces. Pass expectedRevision from wake_delegation_inspect (delivery.selectionRevision). Omitting a required output, selecting an unqualified output or replacing a stale choice is rejected.',
|
|
63
|
+
inputSchema: deliverySelectionCommandSchema,
|
|
64
|
+
}, async (command) => guarded(async () => input.orchestration.selectDelivery(await input.caller(), command, input.commandContext())));
|
|
65
|
+
server.registerTool('wake_delivery_candidate', {
|
|
66
|
+
description: 'Record the exact combined candidate for the current selection: one repository entry per repository with selected changes, using the selected output tip (a single change or intentional stack) or an assembled commit pushed under refs/wake/delivery/<root>/<candidateId>/. Wake verifies the commit is fetchable from the repository before QA can rely on it.',
|
|
67
|
+
inputSchema: deliveryCandidateCommandSchema,
|
|
68
|
+
}, async (command) => guarded(async () => input.orchestration.recordDeliveryCandidate(await input.caller(), command, input.commandContext())));
|
|
69
|
+
server.registerTool('wake_delivery_qa', {
|
|
70
|
+
description: 'Record the QA verdict for a recorded candidate. Name the exact repository revisions checked; they must equal the candidate set. Use verdict blocked when the environment or a source is unavailable, fail with findings when defects remain, and pass only after the configured recipe ran.',
|
|
71
|
+
inputSchema: deliveryQaCommandSchema,
|
|
72
|
+
}, async (command) => guarded(async () => input.orchestration.recordDeliveryQa(await input.caller(), command, input.commandContext())));
|
|
73
|
+
server.registerTool('wake_delivery_maintenance', {
|
|
74
|
+
description: 'Record what you actually did to one selected pull request during integration maintenance (retarget, rebase or resolve) in the branch workspace Wake leased for it. Name the head you started from (expectedRevision) and the resulting pushed head and pull request base. Wake verifies the provider head and records a new subject: earlier reviews, checks and QA stay historical, and fresh review, checks and a new candidate with QA are required before the next merge.',
|
|
75
|
+
inputSchema: deliveryMaintenanceCommandSchema,
|
|
76
|
+
}, async (command) => guarded(async () => input.orchestration.recordDeliveryMaintenance(await input.caller(), command, input.commandContext())));
|
|
42
77
|
server.registerTool('wake_delegation_inspect', {
|
|
43
78
|
description: 'Inspect this delivery tree, child workflows, results and blockers, and the Repository Resource IDs an explicit repository selection may name.',
|
|
44
79
|
}, async () => ({
|