@moretea-labs/forge 1.5.1 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/DESIGN.md +7 -2
- package/README.md +4 -4
- package/README.zh-CN.md +2 -2
- package/THIRD_PARTY_NOTICES.md +1 -1
- package/assets/hooks/pre-edit-guard.sh +8 -39
- package/assets/hooks/prompt-guard.sh +2 -2
- package/assets/plugin-registry.v1.json +54 -3
- package/assets/reference-configs/hook-operations.md +1 -1
- package/assets/reference-configs/sprint-contracts.md +2 -2
- package/assets/skill-version.json +2 -2
- package/assets/templates/helpers/ensure-task-workflow.sh +2 -2
- package/assets/templates/helpers/sprint-backlog.sh +6 -6
- package/docs/architecture/current/automation-and-schedule-engine.md +9 -3
- package/docs/architecture/current/codegraph-context-provider.md +15 -3
- package/docs/architecture/current/dispatch-and-agent-strategy.md +32 -13
- package/docs/architecture/current/entity-model.md +20 -0
- package/docs/architecture/current/external-plugin-governance.md +3 -3
- package/docs/architecture/current/system-overview.md +26 -1
- package/docs/architecture/current/thin-harness-v1.md +10 -0
- package/docs/operations/chatgpt-personal-assistant-runtime.md +12 -2
- package/docs/operations/controller-browser-plugin.md +12 -16
- package/docs/operations/features.md +1 -1
- package/docs/operations/homebrew.md +2 -2
- package/docs/tutorials/01-install-and-start.md +1 -1
- package/docs/tutorials/01-install-and-start.zh-CN.md +1 -1
- package/docs/wiki/Installation.md +1 -1
- package/docs/wiki/Quick-Start.md +1 -1
- package/package.json +1 -1
- package/scripts/check-public-docs.sh +14 -1
- package/scripts/migrate-chatgpt-automation-schedules.ts +64 -0
- package/scripts/sprint-backlog.sh +1 -1
- package/src/cli/commands/chatgpt.ts +31 -2
- package/src/cli/commands/plugin.ts +36 -9
- package/src/cli/controller/context-pack.ts +158 -6
- package/src/cli/hook/prompt-guard-decision.ts +17 -18
- package/src/cli/hook/prompt-intents.ts +1 -1
- package/src/cli/local-bridge/console-automations.ts +205 -23
- package/src/cli/local-bridge/console-view-models.ts +2 -0
- package/src/cli/local-bridge/facade-api.ts +2 -0
- package/src/cli/local-bridge/frontend/src/App.tsx +1 -1
- package/src/cli/local-bridge/frontend/src/features/automations/AutomationsView.tsx +143 -3
- package/src/cli/local-bridge/frontend/src/features/capabilities/CapabilitiesView.tsx +1 -1
- package/src/cli/local-bridge/frontend/src/features/overview/OverviewView.tsx +181 -3
- package/src/cli/local-bridge/frontend/src/features/repositories/RepositoriesView.tsx +1 -1
- package/src/cli/local-bridge/frontend/src/features/work/WorkView.tsx +4 -3
- package/src/cli/local-bridge/frontend/src/lib/api.ts +18 -6
- package/src/cli/local-bridge/frontend/src/shell/CommandBar.tsx +1 -1
- package/src/cli/local-bridge/frontend/src/shell/Sidebar.tsx +2 -1
- package/src/cli/local-bridge/frontend/src/styles.css +27 -11
- package/src/cli/local-bridge/frontend/src/types.ts +6 -2
- package/src/cli/local-bridge/server.ts +29 -19
- package/src/cli/local-bridge/ui-dist/app.css +1 -1
- package/src/cli/local-bridge/ui-dist/app.js +5003 -4815
- package/src/cli/mcp/paths.ts +8 -2
- package/src/cli/mcp/repository-tools.ts +124 -9
- package/src/cli/mcp/server.ts +164 -19
- package/src/cli/mcp/transports/http.ts +25 -2
- package/src/cli/mcp/transports/session-registry.ts +24 -0
- package/src/cli/repositories/command-classifier.ts +113 -0
- package/src/cli/repositories/safe-patch.ts +6 -4
- package/src/cli/repositories/structured-git.ts +49 -7
- package/src/cli/repository/inspector.ts +16 -3
- package/src/runtime/assistant/intent.ts +3 -3
- package/src/runtime/control-plane/execution/direct-edit-work-completion.ts +157 -2
- package/src/runtime/control-plane/execution/execution-identity.ts +65 -14
- package/src/runtime/control-plane/execution/validation.ts +15 -2
- package/src/runtime/control-plane/execution/work-terminal-cleanup.ts +32 -0
- package/src/runtime/control-plane/execution/work-validation-reconciler.ts +6 -7
- package/src/runtime/control-plane/execution/work-verification-snapshot.ts +2 -1
- package/src/runtime/control-plane/facade/capability-registry.ts +1 -1
- package/src/runtime/control-plane/facade/controller-session-store.ts +12 -13
- package/src/runtime/control-plane/facade/goal-workloop-access.ts +7 -2
- package/src/runtime/control-plane/facade/goal-workloop.ts +231 -8
- package/src/runtime/control-plane/facade/plan-contract-store.ts +32 -12
- package/src/runtime/control-plane/facade/requirement-board.ts +24 -8
- package/src/runtime/control-plane/facade/types.ts +33 -6
- package/src/runtime/control-plane/facade/work-contract-store.ts +31 -2
- package/src/runtime/control-plane/launcher/chatgpt-work-continuation.ts +375 -23
- package/src/runtime/control-plane/persistence/requirement-store.ts +15 -11
- package/src/runtime/diagnostics/mcp-timing.ts +6 -0
- package/src/runtime/execution/process-runtime/check-facade.ts +1 -10
- package/src/runtime/execution/process-runtime/check-result.ts +10 -2
- package/src/runtime/execution/process-runtime/command-facade.ts +1 -0
- package/src/runtime/execution/process-runtime/gc.ts +64 -10
- package/src/runtime/execution/process-runtime/persisted-check.ts +10 -2
- package/src/runtime/execution/process-runtime/resource-claims.ts +87 -2
- package/src/runtime/execution/process-runtime/runtime.ts +16 -1
- package/src/runtime/execution/process-runtime/store.ts +6 -0
- package/src/runtime/gateway/mcp/execution-tools.ts +27 -12
- package/src/runtime/gateway/mcp/router.ts +1 -1
- package/src/runtime/gateway/mcp/runtime-tools.ts +482 -178
- package/src/runtime/model-clients/deepseek-adapter.ts +0 -32
- package/src/runtime/plugins/browser-adapter.ts +19 -72
- package/src/runtime/plugins/browser-handoff-host.ts +6 -31
- package/src/runtime/plugins/browser-handoff.ts +0 -3
- package/src/runtime/plugins/browser-macos-bridge.ts +8 -0
- package/src/runtime/plugins/desktop-operator-registration.ts +8 -11
- package/src/runtime/plugins/external-registration.ts +84 -5
- package/src/runtime/plugins/first-party-registry.ts +2 -2
- package/src/runtime/plugins/gmail-adapter.ts +28 -2
- package/src/runtime/plugins/local-system-adapter.ts +2 -2
- package/src/runtime/plugins/plugin-management-adapter.ts +140 -0
- package/src/runtime/plugins/store.ts +107 -5
- package/src/runtime/plugins/types.ts +4 -0
- package/src/runtime/recovery/actions.ts +0 -10
- package/src/runtime/recovery/classifier.ts +0 -9
- package/src/runtime/recovery/maintenance-executor.ts +43 -11
- package/src/runtime/recovery/probe.ts +0 -1
- package/src/runtime/recovery/types.ts +0 -1
- package/src/runtime/root/release-materialize.ts +143 -19
- package/src/runtime/root/service.ts +6 -4
- package/src/runtime/safe-tooling/index.ts +0 -1
- package/src/runtime/safe-tooling/types.ts +0 -30
- package/src/runtime/standalone-recovery/core.ts +2 -2
- package/src/runtime/workflow/schedules/browser-probe.ts +180 -0
- package/src/runtime/workflow/schedules/chatgpt-automation-migration.ts +40 -0
- package/src/runtime/workflow/schedules/engine.ts +357 -64
- package/src/runtime/workflow/schedules/types.ts +5 -0
- package/src/runtime/workflow/schedules/work-continuation.ts +100 -27
- package/bin/forge-desktop-helper.mjs +0 -204
- package/docs/operations/controller-desktop-plugin.md +0 -112
- package/src/runtime/plugins/desktop-adapter.ts +0 -374
- package/src/runtime/safe-tooling/browser-safe.ts +0 -133
|
@@ -28,7 +28,9 @@ export interface RequirementBoardItem {
|
|
|
28
28
|
maintenanceSummary?: string;
|
|
29
29
|
blocker?: string;
|
|
30
30
|
requiredUserDecision?: string;
|
|
31
|
+
/** Compatibility projection for older UI clients; derived from activePlanIds. */
|
|
31
32
|
activePlanId?: string;
|
|
33
|
+
activePlanIds: string[];
|
|
32
34
|
latestDelivery?: {
|
|
33
35
|
workId: string;
|
|
34
36
|
receiptId: string;
|
|
@@ -55,10 +57,14 @@ function explicitUserDecision(requirement: Requirement): string | undefined {
|
|
|
55
57
|
return decision || undefined;
|
|
56
58
|
}
|
|
57
59
|
|
|
58
|
-
function
|
|
60
|
+
function activePlansForRequirement(requirementId: string, plans: readonly PlanContract[]): PlanContract[] {
|
|
61
|
+
return plans.filter((plan) => plan.requirementId === requirementId);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function projectedRequirementState(requirement: Requirement, activePlans: readonly PlanContract[]): RequirementState {
|
|
59
65
|
if (requirement.state !== 'waiting_for_user') return requirement.state;
|
|
60
66
|
if (explicitUserDecision(requirement)) return 'waiting_for_user';
|
|
61
|
-
return
|
|
67
|
+
return activePlans.length > 0 ? 'active' : 'planned';
|
|
62
68
|
}
|
|
63
69
|
|
|
64
70
|
function loadScopedWork(options: RequirementBoardOptions): WorkContract[] {
|
|
@@ -92,8 +98,10 @@ function latestDelivery(requirementId: string, work: readonly WorkContract[]): R
|
|
|
92
98
|
};
|
|
93
99
|
}
|
|
94
100
|
|
|
95
|
-
function projectRequirement(requirement: Requirement, work: readonly WorkContract[]): RequirementBoardItem {
|
|
96
|
-
const
|
|
101
|
+
function projectRequirement(requirement: Requirement, work: readonly WorkContract[], plans: readonly PlanContract[] = []): RequirementBoardItem {
|
|
102
|
+
const activePlans = activePlansForRequirement(requirement.requirementId, plans);
|
|
103
|
+
const activePlanIds = activePlans.map((plan) => plan.planId);
|
|
104
|
+
const state = projectedRequirementState(requirement, activePlans);
|
|
97
105
|
const requiredUserDecision = explicitUserDecision(requirement);
|
|
98
106
|
const maintenanceSummary = requirement.needsAttention
|
|
99
107
|
? boundedText(requirement.attentionSummary, 1_000) || 'This Requirement has a maintenance finding.'
|
|
@@ -108,7 +116,8 @@ function projectRequirement(requirement: Requirement, work: readonly WorkContrac
|
|
|
108
116
|
maintenanceSummary,
|
|
109
117
|
blocker: requirement.needsAttention && state !== 'waiting_for_user' ? maintenanceSummary : undefined,
|
|
110
118
|
requiredUserDecision,
|
|
111
|
-
activePlanId:
|
|
119
|
+
activePlanId: activePlanIds[0],
|
|
120
|
+
activePlanIds,
|
|
112
121
|
latestDelivery: latestDelivery(requirement.requirementId, work),
|
|
113
122
|
updatedAt: requirement.updatedAt,
|
|
114
123
|
detailPointer: {
|
|
@@ -132,7 +141,10 @@ function requirementCounts(requirements: readonly RequirementBoardItem[]): Recor
|
|
|
132
141
|
|
|
133
142
|
export function buildRequirementBoard(options: RequirementBoardOptions): Record<string, unknown> {
|
|
134
143
|
const work = loadScopedWork(options);
|
|
135
|
-
const
|
|
144
|
+
const activePlans = options.repoId?.trim()
|
|
145
|
+
? listPlanContracts({ controllerHome: options.controllerHome, repoId: options.repoId, status: 'active', limit: 100 })
|
|
146
|
+
: [];
|
|
147
|
+
const allRequirements = loadRequirements(options).map((requirement) => projectRequirement(requirement, work, activePlans));
|
|
136
148
|
const requirements = allRequirements.slice(0, DEFAULT_REQUIREMENT_LIMIT);
|
|
137
149
|
const counts = requirementCounts(allRequirements);
|
|
138
150
|
return {
|
|
@@ -229,9 +241,13 @@ export function buildExecutionDiagnostics(
|
|
|
229
241
|
: [];
|
|
230
242
|
const scopedPlans = options.requirementId
|
|
231
243
|
? allPlans.filter((plan) => plan.requirementId === options.requirementId
|
|
232
|
-
|
|
244
|
+
// Legacy migration compatibility only: current Plans own the forward
|
|
245
|
+
// requirementId relation, so the persisted Requirement pointer is not an
|
|
246
|
+
// execution/lifecycle authority.
|
|
247
|
+
|| (!plan.requirementId && selectedRequirements.some((requirement) => requirement.activePlanId === plan.planId)))
|
|
233
248
|
: allPlans;
|
|
234
|
-
const
|
|
249
|
+
const activePlans = allPlans.filter((plan) => !['finalized', 'superseded', 'cancelled', 'invalidated_by_drift'].includes(plan.status));
|
|
250
|
+
const requirements = selectedRequirements.map((requirement) => projectRequirement(requirement, allWork, activePlans));
|
|
235
251
|
const works = scopedWork.slice(0, limit).map(summarizeDiagnosticWork);
|
|
236
252
|
const plans = scopedPlans.slice(0, limit).map((plan) => summarizeDiagnosticPlan(plan, options.detailLevel));
|
|
237
253
|
const maintenanceFindings = requirements
|
|
@@ -156,18 +156,35 @@ export interface LocalEffectCompletionReceipt {
|
|
|
156
156
|
recordedAt: string;
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
+
/** Durable completion authority for one typed remote plugin effect. */
|
|
160
|
+
export interface RemoteEffectCompletionReceipt {
|
|
161
|
+
schemaVersion: 1;
|
|
162
|
+
/** Reuse the authoritative PLG-* receipt id rather than manufacturing parallel evidence. */
|
|
163
|
+
receiptId: string;
|
|
164
|
+
source: 'remote_effect';
|
|
165
|
+
workId: string;
|
|
166
|
+
pluginId: string;
|
|
167
|
+
actionId: string;
|
|
168
|
+
requestId: string;
|
|
169
|
+
semanticKey: string;
|
|
170
|
+
resultDigest: string;
|
|
171
|
+
recordedAt: string;
|
|
172
|
+
}
|
|
173
|
+
|
|
159
174
|
/**
|
|
160
175
|
* Completion authority for a standalone Direct Edit that is not bound to the
|
|
161
|
-
* retired Issue/Task completion model.
|
|
162
|
-
* edit session
|
|
163
|
-
*
|
|
176
|
+
* retired Issue/Task completion model. Normal completion proves one finalized
|
|
177
|
+
* edit session at an exact reachable Git revision. Historical completion may
|
|
178
|
+
* instead reference one explicit reviewed reconciliation after exact revision,
|
|
179
|
+
* path-scope, verification, reachability, and cleanup proof checks.
|
|
164
180
|
*/
|
|
165
181
|
export interface DirectEditWorkCompletionReceipt {
|
|
166
182
|
schemaVersion: 1;
|
|
167
183
|
receiptId: string;
|
|
168
184
|
source: 'direct_edit_work';
|
|
169
185
|
workId: string;
|
|
170
|
-
editSessionId
|
|
186
|
+
editSessionId?: string;
|
|
187
|
+
reconciliationId?: string;
|
|
171
188
|
targetBranch: string;
|
|
172
189
|
targetRevision: string;
|
|
173
190
|
sourceRevision?: string;
|
|
@@ -179,12 +196,18 @@ export interface DirectEditWorkCompletionReceipt {
|
|
|
179
196
|
recordedAt: string;
|
|
180
197
|
}
|
|
181
198
|
|
|
182
|
-
export type WorkCompletionReceipt = RepositoryCompletionReceipt | DirectEditWorkCompletionReceipt | LocalEffectCompletionReceipt;
|
|
199
|
+
export type WorkCompletionReceipt = RepositoryCompletionReceipt | DirectEditWorkCompletionReceipt | LocalEffectCompletionReceipt | RemoteEffectCompletionReceipt;
|
|
183
200
|
|
|
184
201
|
export function isRepositoryCompletionReceipt(
|
|
185
202
|
receipt: WorkCompletionReceipt,
|
|
186
203
|
): receipt is RepositoryCompletionReceipt {
|
|
187
|
-
return receipt.source !== 'local_effect' && receipt.source !== 'direct_edit_work';
|
|
204
|
+
return receipt.source !== 'local_effect' && receipt.source !== 'remote_effect' && receipt.source !== 'direct_edit_work';
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export function isRemoteEffectCompletionReceipt(
|
|
208
|
+
receipt: WorkCompletionReceipt,
|
|
209
|
+
): receipt is RemoteEffectCompletionReceipt {
|
|
210
|
+
return receipt.source === 'remote_effect';
|
|
188
211
|
}
|
|
189
212
|
|
|
190
213
|
export function isDirectEditWorkCompletionReceipt(
|
|
@@ -431,6 +454,10 @@ export interface WorkContract {
|
|
|
431
454
|
phaseEvidence: WorkPhaseEvidenceMap;
|
|
432
455
|
/** Explicit v2 execution semantics. `status` is retained for compatibility. */
|
|
433
456
|
workKind: WorkKind;
|
|
457
|
+
/** Primary is an objective-level business execution lane; execution_child is a resumable low-level operation handle owned by a primary Work or standalone caller. */
|
|
458
|
+
lifecycleRole?: 'primary' | 'execution_child';
|
|
459
|
+
/** Optional objective-level parent when this Work is only an execution child. */
|
|
460
|
+
parentWorkId?: string;
|
|
434
461
|
dispatchState: DispatchState;
|
|
435
462
|
evidenceState: EvidenceState;
|
|
436
463
|
completionOutcome?: CompletionOutcome;
|
|
@@ -32,6 +32,7 @@ import {
|
|
|
32
32
|
type WorkPhaseEvidenceState,
|
|
33
33
|
type WorkContractStore,
|
|
34
34
|
isDirectEditWorkCompletionReceipt,
|
|
35
|
+
isRemoteEffectCompletionReceipt,
|
|
35
36
|
isRepositoryCompletionReceipt,
|
|
36
37
|
isTerminalWorkContractStatus,
|
|
37
38
|
} from './types';
|
|
@@ -195,7 +196,7 @@ function legacyPhaseEvidence(
|
|
|
195
196
|
state,
|
|
196
197
|
source: completedByReceipt ? 'recorded' : source,
|
|
197
198
|
summary: completedByReceipt
|
|
198
|
-
? `Phase ${phase}
|
|
199
|
+
? `Phase ${phase} satisfied by Work completion receipt ${contract.completionReceipt!.receiptId}.`
|
|
199
200
|
: index < currentIndex
|
|
200
201
|
? `Legacy Work advanced beyond ${phase}.`
|
|
201
202
|
: `Legacy Work phase ${phase} is ${state}.`,
|
|
@@ -285,13 +286,20 @@ function validateWorkSemantics(contract: WorkContract): WorkContract {
|
|
|
285
286
|
if (receipt.delivery.status !== 'integrated' || !receipt.delivery.reachable) throw new Error('WORK_COMPLETION_RECEIPT_DELIVERY_NOT_PROVEN');
|
|
286
287
|
if (!['complete', 'maintenance_warning'].includes(receipt.cleanup.status) || receipt.cleanup.blockers.length > 0) throw new Error('WORK_COMPLETION_RECEIPT_CLEANUP_NOT_PROVEN');
|
|
287
288
|
} else if (isDirectEditWorkCompletionReceipt(receipt)) {
|
|
288
|
-
|
|
289
|
+
const directEditAuthorityCount = Number(Boolean(receipt.editSessionId?.trim())) + Number(Boolean(receipt.reconciliationId?.trim()));
|
|
290
|
+
if (directEditAuthorityCount !== 1) throw new Error('WORK_COMPLETION_RECEIPT_DIRECT_EDIT_AUTHORITY_REQUIRED');
|
|
289
291
|
if (!receipt.targetBranch.trim() || !receipt.targetRevision.trim()) throw new Error('WORK_COMPLETION_RECEIPT_TARGET_REQUIRED');
|
|
290
292
|
if (receipt.delivery.status !== 'integrated' || !receipt.delivery.reachable) throw new Error('WORK_COMPLETION_RECEIPT_DELIVERY_NOT_PROVEN');
|
|
291
293
|
if (!['complete', 'maintenance_warning'].includes(receipt.cleanup.status) || receipt.cleanup.blockers.length > 0) throw new Error('WORK_COMPLETION_RECEIPT_CLEANUP_NOT_PROVEN');
|
|
292
294
|
if (!['repository_change', 'completed_no_change'].includes(contract.workKind)) throw new Error('WORK_COMPLETION_RECEIPT_DIRECT_EDIT_KIND_REQUIRED');
|
|
293
295
|
const expectedOutcome = contract.workKind === 'completed_no_change' ? 'completed_no_change' : 'completed_changed';
|
|
294
296
|
if (contract.completionOutcome !== expectedOutcome) throw new Error('WORK_COMPLETION_RECEIPT_DIRECT_EDIT_OUTCOME_REQUIRED');
|
|
297
|
+
} else if (isRemoteEffectCompletionReceipt(receipt)) {
|
|
298
|
+
if (contract.workKind !== 'remote_effect') throw new Error('WORK_COMPLETION_RECEIPT_REMOTE_EFFECT_KIND_REQUIRED');
|
|
299
|
+
if (contract.completionOutcome !== 'completed_remote') throw new Error('WORK_COMPLETION_RECEIPT_REMOTE_EFFECT_OUTCOME_REQUIRED');
|
|
300
|
+
if (!receipt.pluginId.trim() || !receipt.actionId.trim() || !receipt.requestId.trim() || !receipt.semanticKey.trim() || !receipt.resultDigest.trim()) {
|
|
301
|
+
throw new Error('WORK_COMPLETION_RECEIPT_REMOTE_EFFECT_IDENTITY_REQUIRED');
|
|
302
|
+
}
|
|
295
303
|
} else {
|
|
296
304
|
if (contract.workKind !== 'local_effect') throw new Error('WORK_COMPLETION_RECEIPT_LOCAL_EFFECT_KIND_REQUIRED');
|
|
297
305
|
if (contract.completionOutcome !== 'completed_local') throw new Error('WORK_COMPLETION_RECEIPT_LOCAL_EFFECT_OUTCOME_REQUIRED');
|
|
@@ -335,6 +343,9 @@ function validateWorkSemantics(contract: WorkContract): WorkContract {
|
|
|
335
343
|
if (outcome === 'completed_remote' && contract.workKind !== 'remote_effect') {
|
|
336
344
|
throw new Error('WORK_SEMANTICS_INVALID: completed_remote requires remote_effect WorkKind');
|
|
337
345
|
}
|
|
346
|
+
if (outcome === 'completed_remote' && contract.completionReceipt?.source !== 'remote_effect') {
|
|
347
|
+
throw new Error('WORK_SEMANTICS_INVALID: completed_remote requires a remote_effect completion receipt');
|
|
348
|
+
}
|
|
338
349
|
if (outcome === 'superseded' && contract.workKind !== 'superseded') {
|
|
339
350
|
throw new Error('WORK_SEMANTICS_INVALID: superseded requires superseded WorkKind');
|
|
340
351
|
}
|
|
@@ -372,6 +383,12 @@ function validateWorkSemanticTransition(current: WorkContract, next: WorkContrac
|
|
|
372
383
|
if (current.completionOutcome && current.completionOutcome !== next.completionOutcome) {
|
|
373
384
|
throw new Error(`WORK_SEMANTICS_TRANSITION_INVALID: completion outcome ${current.completionOutcome} is immutable`);
|
|
374
385
|
}
|
|
386
|
+
if ((current.lifecycleRole ?? 'primary') !== (next.lifecycleRole ?? 'primary')) {
|
|
387
|
+
throw new Error('WORK_SEMANTICS_TRANSITION_INVALID: lifecycleRole is immutable');
|
|
388
|
+
}
|
|
389
|
+
if (current.parentWorkId !== next.parentWorkId) {
|
|
390
|
+
throw new Error('WORK_SEMANTICS_TRANSITION_INVALID: parentWorkId is immutable');
|
|
391
|
+
}
|
|
375
392
|
return next;
|
|
376
393
|
}
|
|
377
394
|
|
|
@@ -544,6 +561,8 @@ export function createWorkContract(options: WorkContractStoreOptions, input: Cre
|
|
|
544
561
|
constraints: input.constraints ?? { requireHandoffOnAmbiguity: true },
|
|
545
562
|
risk: input.risk ?? 'medium',
|
|
546
563
|
workKind: input.workKind ?? 'repository_change',
|
|
564
|
+
lifecycleRole: input.lifecycleRole ?? 'primary',
|
|
565
|
+
parentWorkId: input.parentWorkId?.trim() || undefined,
|
|
547
566
|
dispatchState: input.dispatchState ?? inferredDispatchState(input.status ?? 'open'),
|
|
548
567
|
evidenceState: input.evidenceState ?? inferredEvidenceState(input.status ?? 'open'),
|
|
549
568
|
completionOutcome: input.completionOutcome,
|
|
@@ -631,6 +650,7 @@ function workRequestIndexPath(controllerHome: string, requestId: string): string
|
|
|
631
650
|
export interface AcceptSubmittedWorkInput {
|
|
632
651
|
requestId: string;
|
|
633
652
|
repoId: string;
|
|
653
|
+
parentWorkId?: string;
|
|
634
654
|
semanticKey: string;
|
|
635
655
|
operation: SubmittedWorkOperation;
|
|
636
656
|
objective?: string;
|
|
@@ -690,6 +710,13 @@ export function acceptSubmittedWorkContract(
|
|
|
690
710
|
if (!input.operation?.name?.trim()) {
|
|
691
711
|
throw new Error('INVALID_ARGUMENT: work_submit is missing required argument(s): operation');
|
|
692
712
|
}
|
|
713
|
+
const parentWorkId = input.parentWorkId?.trim() || undefined;
|
|
714
|
+
if (parentWorkId) {
|
|
715
|
+
const parent = getWorkContract({ controllerHome: home, repoId: input.repoId, now: options.now }, parentWorkId);
|
|
716
|
+
if (!parent) throw new Error(`PARENT_WORK_NOT_FOUND: ${parentWorkId}`);
|
|
717
|
+
if (isTerminalWorkContractStatus(parent.status)) throw new Error(`PARENT_WORK_TERMINAL: ${parentWorkId}:${parent.status}`);
|
|
718
|
+
if ((parent.lifecycleRole ?? 'primary') !== 'primary') throw new Error(`PARENT_WORK_NOT_PRIMARY: ${parentWorkId}`);
|
|
719
|
+
}
|
|
693
720
|
|
|
694
721
|
const requestLockId = createHash('sha256').update(normalizedRequestId).digest('hex').slice(0, 24);
|
|
695
722
|
return withControllerLock(home, { scope: 'global', resource: `work-request-${requestLockId}` }, `accept-work:${normalizedRequestId}`, () => {
|
|
@@ -715,6 +742,8 @@ export function acceptSubmittedWorkContract(
|
|
|
715
742
|
principalId: input.principalId,
|
|
716
743
|
controllerInstanceId: input.controllerInstanceId,
|
|
717
744
|
mode: input.mode ?? 'direct_control',
|
|
745
|
+
lifecycleRole: 'execution_child',
|
|
746
|
+
parentWorkId,
|
|
718
747
|
objective: (input.objective ?? `Accepted operation ${input.operation.name}`).slice(0, 2_000),
|
|
719
748
|
acceptanceCriteria: input.acceptanceCriteria ?? [],
|
|
720
749
|
workKind: input.workKind,
|