@zq-silk/yui 0.15.7 → 0.15.9
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/ARCHITECTURE.md +194 -399
- package/ARCHITECTURE.zh-CN.md +151 -0
- package/README.md +306 -1131
- package/dist/agent/adapterCatalog.js +15 -2
- package/dist/agent/agent.js +23 -3
- package/dist/agent/argumentPolicy.js +7 -1
- package/dist/agent/connectionPlan.js +62 -0
- package/dist/agent/executionComponents.js +158 -0
- package/dist/agent/launchEnvironment.js +31 -3
- package/dist/agent/managedRuntimeEnvironment.js +3 -5
- package/dist/{turn/turn.js → agentRun/agentRun.js} +166 -109
- package/dist/{turn/turnIdentity.js → agentRun/runIdentity.js} +4 -4
- package/dist/artifacts/artifactCapability.js +74 -0
- package/dist/artifacts/artifactCommitLock.js +249 -0
- package/dist/artifacts/artifactPaths.js +151 -0
- package/dist/artifacts/gitArtifactRef.js +146 -0
- package/dist/artifacts/managedGit.js +332 -0
- package/dist/artifacts/taskArtifactRepository.js +277 -0
- package/dist/brief/taskBrief.js +12 -0
- package/dist/cli/agentConfigurationPicker.js +13 -0
- package/dist/cli/commandCatalog.js +165 -74
- package/dist/cli/interactionCandidates.js +5 -5
- package/dist/cli/interactionPolicy.js +38 -8
- package/dist/cli/invocationRouter.js +1 -1
- package/dist/cli/managedDiagnostics.js +28 -0
- package/dist/cli/operatorWizard.js +1 -7
- package/dist/cli/roleOptionOrder.js +27 -0
- package/dist/cli/roleWizard.js +50 -14
- package/dist/cli/updateOrchestrator.js +1 -1
- package/dist/cli/updatePorts.js +3 -4
- package/dist/cli.js +245 -95
- package/dist/commands/agentCommands.js +72 -14
- package/dist/commands/capabilityCommands.js +9 -6
- package/dist/commands/configCommands.js +20 -20
- package/dist/commands/deliveryGuardPreflight.js +2 -2
- package/dist/commands/executionAuditCommands.js +24 -24
- package/dist/commands/globalRoleCommands.js +1 -1
- package/dist/commands/grantCommands.js +4 -4
- package/dist/commands/operatorCommands.js +34 -9
- package/dist/commands/projectCommands.js +4 -4
- package/dist/commands/resourcesCommands.js +2 -2
- package/dist/commands/roleConfiguration.js +25 -5
- package/dist/commands/roleRuntimeGuard.js +4 -5
- package/dist/commands/sessionCommands.js +3 -7
- package/dist/commands/taskActivationCommands.js +281 -0
- package/dist/commands/taskActor.js +28 -49
- package/dist/commands/taskCommands.js +1461 -720
- package/dist/commands/taskContextCommand.js +39 -583
- package/dist/commands/taskExecutionCommands.js +32 -32
- package/dist/commands/taskInputCommands.js +40 -104
- package/dist/commands/taskIntegrationCommands.js +3 -2
- package/dist/commands/taskIntegrationQueueCommands.js +1 -1
- package/dist/commands/taskNextActionCommand.js +8 -8
- package/dist/commands/taskOverviewCommand.js +33 -45
- package/dist/commands/taskRemoteDeliveryCommand.js +2 -2
- package/dist/commands/taskRoleRuntimeStatus.js +133 -102
- package/dist/commands/telemetryCommands.js +36 -38
- package/dist/config/configCatalog.js +4 -4
- package/dist/config/yuiConfig.js +8 -8
- package/dist/context/contextSnapshot.js +10 -10
- package/dist/context/dispatchContext.js +11 -11
- package/dist/context/roleSessionContext.js +6 -3
- package/dist/context/{turnContextPack.js → runContextPack.js} +158 -81
- package/dist/context/{turnInputContract.js → runInputContract.js} +73 -60
- package/dist/context/sessionBootstrapManifest.js +21 -2
- package/dist/context/sourceRunContext.js +30 -0
- package/dist/context/taskContext.js +481 -0
- package/dist/context/wakeNotification.js +27 -27
- package/dist/controller/agentRuntimeObserver.js +21 -24
- package/dist/controller/capabilityBridge.js +17 -6
- package/dist/controller/clientRuntime.js +65 -92
- package/dist/controller/controller.js +120 -188
- package/dist/controller/fileSchedulerStoreAdapter.js +787 -887
- package/dist/controller/jobControl.js +54 -85
- package/dist/controller/resourceInventory.js +8 -27
- package/dist/controller/resourceInventoryLinux.js +12 -13
- package/dist/controller/runtime.js +529 -479
- package/dist/controller/runtimeEventInbox.js +55 -25
- package/dist/controller/runtimeEventProcessor.js +22 -31
- package/dist/controller/{runtimeHookTurnFence.js → runtimeHookRunFence.js} +91 -115
- package/dist/controller/runtimeLaunchCoordinator.js +80 -426
- package/dist/controller/runtimeObservationHook.js +14 -18
- package/dist/controller/sessionNotify.js +16 -24
- package/dist/controller/sessionOwnerReconciliation.js +168 -50
- package/dist/controller/structuredProviderObservation.js +138 -99
- package/dist/coordination/workMailbox.js +3 -3
- package/dist/coordination/workMailboxQueue.js +36 -33
- package/dist/core/boundedRpc.js +8 -1
- package/dist/core/controllerClient.js +20 -1
- package/dist/core/controllerServer.js +4 -4
- package/dist/doctor/doctor.js +13 -2
- package/dist/domain/agentResultTransport.js +9 -9
- package/dist/execution/codexThreadNaming.js +2 -8
- package/dist/execution/executionHealth.js +51 -63
- package/dist/execution/reviewMainRun.js +137 -0
- package/dist/execution/workItemExecution.js +28 -29
- package/dist/execution/workItemExecutionProjection.js +99 -107
- package/dist/execution/workItemMainRun.js +141 -0
- package/dist/executor/agentAdapter.js +227 -20
- package/dist/executor/agentConfigurationCatalog.js +126 -4
- package/dist/executor/agentConfigurationProbe.js +162 -4
- package/dist/executor/agentExecutor.js +79 -78
- package/dist/executor/effectiveLaunch.js +105 -18
- package/dist/executor/executorRegistry.js +29 -44
- package/dist/executor/fileRoleLaunchPlanner.js +229 -154
- package/dist/executor/workspacePreflightClassification.js +16 -16
- package/dist/grant/capabilityGrant.js +6 -3
- package/dist/input/inputRequest.js +12 -10
- package/dist/integration/gitIntegrationService.js +4 -11
- package/dist/integration/integrationQueueService.js +4 -4
- package/dist/interaction/operatorPresentation.js +1 -1
- package/dist/kernel/builtinCapabilities.js +255 -12
- package/dist/kernel/capabilityRegistry.js +64 -18
- package/dist/kernel/instanceHost.js +12 -1
- package/dist/kernel/kernelPorts.js +2 -2
- package/dist/lifecycle/canonicalLifecycleEvent.js +44 -49
- package/dist/lifecycle/exactRunTerminalization.js +449 -0
- package/dist/message/message.js +118 -6
- package/dist/message/messageContinuation.js +204 -0
- package/dist/observability/executionAudit.js +70 -72
- package/dist/observability/faultClassification.js +2 -2
- package/dist/observability/orchestrationMetrics.js +8 -8
- package/dist/operator/operatorSessionHistory.js +1 -7
- package/dist/output/agentConfigurationPresentation.js +8 -3
- package/dist/output/agentRunConfigurationPresentation.js +128 -0
- package/dist/output/rolePresentation.js +54 -3
- package/dist/plugins/pluginChild.js +104 -0
- package/dist/plugins/pluginIntent.js +26 -0
- package/dist/plugins/pluginInterpreter.js +43 -0
- package/dist/plugins/pluginPackage.js +101 -0
- package/dist/plugins/pluginProcess.js +112 -0
- package/dist/plugins/pluginService.js +388 -0
- package/dist/profile/agentProfile.js +1 -1
- package/dist/repository/gitWorkspace.js +26 -4
- package/dist/repository/project.js +19 -4
- package/dist/repository/taskBaseFreshness.js +13 -13
- package/dist/repository/taskWorkspaceCoordinator.js +20 -27
- package/dist/repository/taskWorkspacePreparer.js +344 -83
- package/dist/resources/autoResourceGc.js +3 -3
- package/dist/resources/liveReferences.js +3 -3
- package/dist/resources/projectResource.js +75 -0
- package/dist/resources/projectResourceService.js +343 -0
- package/dist/resources/resourceDiscovery.js +6 -6
- package/dist/resources/resourceGc.js +1 -1
- package/dist/resources/resourceRegistrar.js +1 -1
- package/dist/resources/resourceTypes.js +1 -1
- package/dist/review/deltaRecheck.js +3 -3
- package/dist/review/reviewAcceptance.js +16 -16
- package/dist/review/reviewDecision.js +7 -7
- package/dist/review/reviewRound.js +21 -20
- package/dist/review/reviewerAvailability.js +2 -2
- package/dist/role/role.js +51 -7
- package/dist/role/taskRoleUpdate.js +30 -0
- package/dist/runtime/acpProtocol.js +425 -0
- package/dist/runtime/acpSession.js +731 -0
- package/dist/runtime/acpSessionConfiguration.js +260 -0
- package/dist/runtime/agentDriver.js +30 -11
- package/dist/runtime/agentEndpoint.js +278 -0
- package/dist/runtime/agentEndpointIdentity.js +86 -0
- package/dist/runtime/agentEndpointOwnership.js +239 -0
- package/dist/runtime/agentError.js +2 -10
- package/dist/runtime/agentHost.js +565 -314
- package/dist/runtime/agentRunConfiguration.js +258 -0
- package/dist/runtime/builtinAgentDrivers.js +134 -18
- package/dist/runtime/builtinAgentErrorMappers.js +55 -3
- package/dist/runtime/builtinTranscriptUsage.js +1 -1
- package/dist/runtime/claude-process-owner +0 -0
- package/dist/runtime/codexAppServerRuntime.js +38 -30
- package/dist/runtime/codexInteractiveHost.js +41 -6
- package/dist/runtime/continuationManager.js +2 -6
- package/dist/runtime/executionEnvironment.js +30 -0
- package/dist/runtime/firstProgressAdvisory.js +11 -11
- package/dist/runtime/index.js +4 -3
- package/dist/runtime/jsonLineChannel.js +109 -0
- package/dist/runtime/launchBroker.js +91 -16
- package/dist/runtime/launchDiagnostics.js +2 -2
- package/dist/runtime/lifecycleReservation.js +10 -18
- package/dist/runtime/managedCaller.js +61 -17
- package/dist/runtime/nativeSessionControl.js +102 -0
- package/dist/runtime/ports.js +6 -21
- package/dist/runtime/processExitObservation.js +8 -7
- package/dist/runtime/promptEnvelope.js +17 -6
- package/dist/runtime/providerContinuation.js +3 -9
- package/dist/runtime/providerContinuationReconciliationService.js +4 -13
- package/dist/runtime/providerControl.js +2 -7
- package/dist/runtime/providerRuntimeIdentity.js +110 -222
- package/dist/runtime/providerRuntimeReconciler.js +5 -9
- package/dist/runtime/runtimeBinding.js +0 -1
- package/dist/runtime/runtimeContinuationProjection.js +4 -7
- package/dist/runtime/runtimeDeadlines.js +9 -0
- package/dist/runtime/runtimeHealthPolicy.js +1 -1
- package/dist/runtime/runtimeObservation.js +29 -65
- package/dist/runtime/runtimeProjection.js +43 -51
- package/dist/runtime/runtimeSessionCandidate.js +1 -3
- package/dist/runtime/sessionLaunchRequest.js +3 -7
- package/dist/runtime/sessionOwnerIdentity.js +7 -54
- package/dist/runtime/sessionOwnerRegistry.js +22 -17
- package/dist/runtime/sessionReconciliation.js +4 -8
- package/dist/runtime/sessionTerminationGuard.js +70 -259
- package/dist/runtime/sessionTokenMetrics.js +5 -16
- package/dist/runtime/structuredProviderHost.js +237 -117
- package/dist/runtime/taskRuntimeIsolation.js +39 -122
- package/dist/runtime/tmuxAdapters.js +39 -86
- package/dist/scheduler/activeRoleRunDelivery.js +354 -0
- package/dist/scheduler/leaderWakeupProcessor.js +75 -266
- package/dist/scheduler/operatorInputNotificationProcessor.js +1 -1
- package/dist/scheduler/ports.js +80 -9
- package/dist/scheduler/{roleTurnLiveness.js → roleRunLiveness.js} +26 -30
- package/dist/scheduler/{roleTurnStall.js → roleRunStall.js} +128 -139
- package/dist/scheduler/taskExecutionProjection.js +120 -124
- package/dist/scheduler/taskObservabilityProjection.js +29 -29
- package/dist/scheduler/taskWake.js +11 -4
- package/dist/scheduler/wakeReason.js +9 -1
- package/dist/setup/setupCommand.js +3 -7
- package/dist/storage/migrations/agentRunContract.js +159 -0
- package/dist/storage/migrations/artifactsToGit.js +338 -0
- package/dist/storage/migrations/removeRuntimeGeneration.js +207 -0
- package/dist/storage/migrations/submitIntent.js +126 -0
- package/dist/storage/sqliteSchema.js +467 -7
- package/dist/storage/sqliteStore.js +355 -220
- package/dist/storage/storageVersions.js +1 -1
- package/dist/storage/storeRpc.js +10 -5
- package/dist/storage/taskStore.js +13 -11
- package/dist/storage/upgrade/upgradeOrchestrator.js +5 -7
- package/dist/surface/surfaceContributions.js +102 -0
- package/dist/task/completionReadiness.js +32 -6
- package/dist/task/deliveryGuard.js +16 -16
- package/dist/task/draftPlan.js +72 -12
- package/dist/task/nextAction.js +144 -128
- package/dist/task/remoteDelivery.js +6 -6
- package/dist/task/task.js +184 -18
- package/dist/task/taskActivation.js +327 -0
- package/dist/task/taskActivationService.js +408 -0
- package/dist/task/taskRecordReference.js +5 -4
- package/dist/task/taskRecordRetirement.js +1 -1
- package/dist/task/taskSubmission.js +236 -0
- package/dist/telemetry/sqliteTelemetryStore.js +55 -68
- package/dist/telemetry/telemetryConfig.js +14 -14
- package/dist/telemetry/telemetryWiring.js +2 -2
- package/dist/web/assets/assetManifest.js +2 -0
- package/dist/web/assets/client/app.js +121 -20
- package/dist/web/assets/client/components.js +87 -54
- package/dist/web/assets/client/i18n.js +83 -41
- package/dist/web/assets/client/markdown.js +1 -1
- package/dist/web/assets/client/taskSurface.js +442 -0
- package/dist/web/assets/client/view.js +49 -44
- package/dist/web/assets/shell.js +1 -1
- package/dist/web/assets/styles/cards.js +22 -4
- package/dist/web/controllerWeb.js +60 -0
- package/dist/web/webMutation.js +28 -0
- package/dist/web/webServer.js +133 -8
- package/dist/web/webSnapshot.js +81 -74
- package/dist/web/webTaskSurface.js +64 -0
- package/dist/workItem/dependencyGate.js +1 -1
- package/dist/workItem/workItem.js +84 -48
- package/dist/workspace/workItemChangeSetManager.js +16 -9
- package/docs/agent-result-consumption.md +96 -0
- package/docs/agent-result-consumption.zh-CN.md +81 -0
- package/docs/agent-runtime-drivers.md +93 -0
- package/docs/agent-runtime-drivers.zh-CN.md +77 -0
- package/docs/architecture/README.md +50 -0
- package/docs/architecture/README.zh-CN.md +43 -0
- package/docs/architecture/capabilities-and-resources.md +118 -0
- package/docs/architecture/capabilities-and-resources.zh-CN.md +83 -0
- package/docs/managed-turn-and-session-runtime.md +224 -0
- package/docs/managed-turn-and-session-runtime.zh-CN.md +180 -0
- package/docs/observability/README.md +83 -0
- package/docs/observability/README.zh-CN.md +71 -0
- package/docs/plugin-sdk.md +393 -0
- package/docs/plugin-sdk.zh-CN.md +293 -0
- package/docs/provider-runtime.md +165 -0
- package/docs/provider-runtime.zh-CN.md +132 -0
- package/docs/release-workflow.md +305 -0
- package/docs/release-workflow.zh-CN.md +237 -0
- package/docs/roles-and-configuration.md +115 -0
- package/docs/roles-and-configuration.zh-CN.md +96 -0
- package/docs/sqlite-control-plane-design.md +78 -0
- package/docs/sqlite-control-plane-design.zh-CN.md +62 -0
- package/docs/task-dag-semantics.md +80 -0
- package/docs/task-dag-semantics.zh-CN.md +59 -0
- package/docs/task-delivery.md +105 -0
- package/docs/task-delivery.zh-CN.md +82 -0
- package/docs/task-local-identity.md +8 -6
- package/docs/task-local-identity.zh-CN.md +58 -0
- package/docs/testing/verification-levels.md +88 -0
- package/docs/testing/verification-levels.zh-CN.md +69 -0
- package/i18n/README.zh-CN.md +270 -722
- package/package.json +3 -2
- package/skills/yui-leader/SKILL.md +88 -304
- package/skills/yui-leader/references/execution.md +303 -0
- package/skills/yui-leader/references/integration.md +39 -0
- package/skills/yui-leader/references/planning.md +109 -0
- package/skills/yui-leader/references/replicated-execution.md +42 -0
- package/skills/yui-leader/references/task-plugins.md +37 -0
- package/skills/yui-operator/SKILL.md +46 -62
- package/skills/yui-reviewer/SKILL.md +35 -36
- package/skills/yui-runtime/SKILL.md +88 -24
- package/skills/yui-runtime/references/publication.md +22 -0
- package/skills/yui-runtime/references/recovery.md +64 -0
- package/skills/yui-worker/SKILL.md +37 -39
- package/dist/cli/roleOptionCatalog.js +0 -68
- package/dist/context/sourceTurnContext.js +0 -30
- package/dist/execution/reviewMainTurn.js +0 -161
- package/dist/execution/workItemMainTurn.js +0 -164
- package/dist/lifecycle/exactTurnTerminalization.js +0 -407
- package/dist/runtime/preallocatedNativeSession.js +0 -13
- package/dist/runtime/runtimeStopReceipt.js +0 -42
- package/dist/scheduler/activeRoleTurnDelivery.js +0 -315
|
@@ -1,37 +1,41 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: yui-worker
|
|
3
|
-
description: Complete
|
|
3
|
+
description: Complete a bounded Yui WorkItem AgentRun or native child assignment and return evidence without taking over Task coordination.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Yui Worker
|
|
7
7
|
|
|
8
|
-
Follow
|
|
8
|
+
Follow [yui-runtime](../yui-runtime/SKILL.md) first. For a managed AgentRun,
|
|
9
|
+
load its exact Context Pack and
|
|
9
10
|
use only the returned WorkItem, refs, workspace, writable Project IDs, and
|
|
10
11
|
completion actions. The launch Envelope is a pointer, not an execution brief.
|
|
11
12
|
|
|
12
|
-
Complete
|
|
13
|
-
|
|
13
|
+
Complete the assigned WorkItem, or the bounded parent brief for a native child
|
|
14
|
+
without its own WorkItem. Do not create records merely to fit this Skill.
|
|
15
|
+
The Leader owns Task direction, decomposition, acceptance, integration, scope expansion, and conflict
|
|
14
16
|
decisions. A Worker must not create or rebind Yui worktrees, Sessions, Roles,
|
|
15
|
-
|
|
17
|
+
AgentRuns, WorkItems, ReviewRounds, or integration state.
|
|
16
18
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
- This Skill supplies portable Worker behavior.
|
|
22
|
-
- Agent-native Project Skills plus Project Policy and Knowledge supply build,
|
|
23
|
-
test, migration, release, and review rules.
|
|
24
|
-
- The exact WorkItem and Context Snapshot supply this Turn's objective, scope,
|
|
25
|
-
acceptance, dependencies, and evidence contract.
|
|
26
|
-
|
|
27
|
-
Do not promote a Project convention into generic Worker policy or infer Task
|
|
28
|
-
facts by scanning the workspace. Expand only Context refs authorized by the
|
|
29
|
-
pack.
|
|
19
|
+
Use Project Skills, Policy and Knowledge for implementation and checks, and
|
|
20
|
+
the exact WorkItem for acceptance. Do not turn a Project convention into
|
|
21
|
+
generic Worker policy or infer Task requirements from workspace contents.
|
|
22
|
+
Resolve Skill links relative to this Skill's directory.
|
|
30
23
|
|
|
31
24
|
## Execute within the exact boundary
|
|
32
25
|
|
|
33
|
-
|
|
34
|
-
|
|
26
|
+
Leader clarification and continuation arrive as Messages in the exact bounded
|
|
27
|
+
Context Pack. Read those authorized refs; do not request pack-external Leader
|
|
28
|
+
messages or require redispatch/status changes merely to answer a question.
|
|
29
|
+
Continuation preserves the original Assignment, effective permissions and
|
|
30
|
+
workspace, including unfinished files. If you need clarification, preserve
|
|
31
|
+
those files and report the question; a final question is not WorkItem completion
|
|
32
|
+
and does not require a Candidate. While executing, `task message send <task>
|
|
33
|
+
"<question>" --to leader --work-item <work-id>` saves scoped collaboration.
|
|
34
|
+
Do not interpret Message delivery or Context reading as implementation or
|
|
35
|
+
acceptance, and never treat a Message as an expanded grant.
|
|
36
|
+
|
|
37
|
+
- Preserve the Task, WorkItem, Role, AgentRun, native Session, and workspace
|
|
38
|
+
identities supplied by Yui. A new AgentRun is another attempt or continuation of
|
|
35
39
|
the same delivery unit; do not request a fresh Role or Session merely because
|
|
36
40
|
implementation entered another step or repair round.
|
|
37
41
|
- Follow the configured Profile's responsibilities, constraints, access
|
|
@@ -49,12 +53,12 @@ pack.
|
|
|
49
53
|
exact Project, reason, impact, and Leader decision needed. Continue only
|
|
50
54
|
after a new exact dispatch authorizes it.
|
|
51
55
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
Before changing behavior, trace the existing implementation and establish how
|
|
57
|
+
it violates the current WorkItem contract. Distinguish a product defect from
|
|
58
|
+
different test inputs, configuration or resources. Reuse the existing authority
|
|
59
|
+
and mechanism when they fit; make a bounded redesign when the responsibility
|
|
60
|
+
itself is wrong. Keep unrelated improvements and hypothetical variants out of
|
|
61
|
+
the assignment.
|
|
58
62
|
|
|
59
63
|
For Project-backed delivery, commit the Develop workspace changes and leave it
|
|
60
64
|
clean before handoff so Yui can freeze the exact Candidate head. ReviewRound
|
|
@@ -70,10 +74,6 @@ changed behavior; do not repeat an unchanged successful check. Follow Project
|
|
|
70
74
|
Policy for required validation and state passed, failed, and intentionally
|
|
71
75
|
skipped checks honestly.
|
|
72
76
|
|
|
73
|
-
Follow `yui-runtime`'s distinction between normal Agent execution and
|
|
74
|
-
real-resource validation. Ordinary Worker implementation is authorized by this
|
|
75
|
-
Turn; additional live-provider, paid, shared, or production validation is not.
|
|
76
|
-
|
|
77
77
|
## Return a useful result
|
|
78
78
|
|
|
79
79
|
A native child result is best-effort until Yui externalizes it: the result
|
|
@@ -81,28 +81,26 @@ returns through the parent Conversation, and if that Session is lost before
|
|
|
81
81
|
the Leader consumes it, the child may need to rerun. Do not claim Yui
|
|
82
82
|
durability for a native result you only emitted in the provider transcript.
|
|
83
83
|
When the child brief requires a durable, independently recoverable result,
|
|
84
|
-
the Leader must dispatch the work as a managed Yui WorkItem
|
|
85
|
-
direct WorkItem
|
|
84
|
+
the Leader must dispatch the work as a managed Yui WorkItem AgentRun instead. A
|
|
85
|
+
direct WorkItem AgentRun already owns its durable AgentRun, receipt, and workspace;
|
|
86
86
|
replicated Lanes are needed only for multiple independent attempts. Native
|
|
87
|
-
subagents never own a Yui
|
|
88
|
-
|
|
89
|
-
## Task Role Turn
|
|
87
|
+
subagents never own a Yui AgentRun, receipt, or workspace.
|
|
90
88
|
|
|
91
89
|
Summarize the outcome for the Leader's next judgment, not as a transcript or
|
|
92
90
|
file-by-file log. Include the observable result, important mechanism and
|
|
93
91
|
boundary, changed paths and commit state, checks, skipped validation, blockers,
|
|
94
92
|
residual risk, and bounded next action. Use a checkpoint only for material
|
|
95
|
-
semantic progress during a long
|
|
93
|
+
semantic progress during a long AgentRun; it does not replace the final handoff.
|
|
96
94
|
|
|
97
95
|
For a native subagent, return one consolidated child result through the native
|
|
98
96
|
child-result mechanism. Do not run Yui lifecycle commands or invent a child
|
|
99
|
-
Yui Session/
|
|
97
|
+
Yui Session/AgentRun.
|
|
100
98
|
|
|
101
99
|
For a managed Task Role, end the Provider Turn with one complete, truthful
|
|
102
|
-
result. Yui persists it automatically on the exact
|
|
100
|
+
result. Yui persists it automatically on the exact AgentRun. That result does not
|
|
103
101
|
accept, capture, integrate, or complete the WorkItem; the Leader decides its
|
|
104
102
|
disposition. If context or scope is stale or mismatched, report that blocker
|
|
105
|
-
once and stop without wrappers, permission broadening, or another
|
|
103
|
+
once and stop without wrappers, permission broadening, or another AgentRun target.
|
|
106
104
|
|
|
107
105
|
Use clear prose. A helpful default is Outcome, Changes, Verification, Risks or
|
|
108
106
|
blockers, and Recommended next action. This is a communication convention, not
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
const BOTH_ADAPTERS = Object.freeze(["codex", "claude"]);
|
|
2
|
-
const CODEX_ONLY = Object.freeze(["codex"]);
|
|
3
|
-
const CLAUDE_ONLY = Object.freeze(["claude"]);
|
|
4
|
-
export const ROLE_AGENT_OPTION_SPECS = Object.freeze([
|
|
5
|
-
roleAgentOption("--model", "model", "model", false, BOTH_ADAPTERS),
|
|
6
|
-
roleAgentOption("--effort", "effort", "effort", false, BOTH_ADAPTERS),
|
|
7
|
-
roleAgentOption("--permission-strategy", "permission.strategy", "strategy", false, BOTH_ADAPTERS, { staticValues: ["default", "bypass", "configured"] }),
|
|
8
|
-
roleAgentOption("--sandbox", "permission.sandbox", "mode", false, CODEX_ONLY),
|
|
9
|
-
roleAgentOption("--approval", "permission.approval", "policy", false, CODEX_ONLY),
|
|
10
|
-
roleAgentOption("--permission-mode", "permission.mode", "mode", false, CLAUDE_ONLY),
|
|
11
|
-
roleAgentOption("--allowed-tool", "permission.allowedTools", "tool", true, CLAUDE_ONLY),
|
|
12
|
-
roleAgentOption("--disallowed-tool", "permission.disallowedTools", "tool", true, CLAUDE_ONLY),
|
|
13
|
-
roleAgentOption("--search", "search", "true", false, CODEX_ONLY, { staticValues: ["true"] }),
|
|
14
|
-
roleAgentOption("--profile", "profile", "profile", false, CODEX_ONLY),
|
|
15
|
-
roleAgentOption("--add-dir", "additionalDirectories", "path", true, BOTH_ADAPTERS, { fileValue: true }),
|
|
16
|
-
roleAgentOption("--settings", "settingsFile", "file", false, CLAUDE_ONLY, { fileValue: true }),
|
|
17
|
-
roleAgentOption("--setting-source", "settingsSources", "source", true, CLAUDE_ONLY),
|
|
18
|
-
roleAgentOption("--raw-arg", "advanced.rawArgs", "arg", true, BOTH_ADAPTERS, { allowOptionLikeValue: true })
|
|
19
|
-
]);
|
|
20
|
-
export const ROLE_AGENT_INHERIT_OPTION = "--inherit";
|
|
21
|
-
export const ROLE_EXPECT_UPDATED_AT_OPTION = "--expect-updated-at";
|
|
22
|
-
export const ROLE_AGENT_INHERITABLE_FIELDS = Object.freeze(ROLE_AGENT_OPTION_SPECS.map(({ fieldKey }) => fieldKey));
|
|
23
|
-
export const ROLE_PROFILE_INHERITABLE_FIELDS = Object.freeze(["systemPrompt"]);
|
|
24
|
-
export const ROLE_INHERITABLE_FIELDS = Object.freeze([
|
|
25
|
-
...ROLE_AGENT_INHERITABLE_FIELDS,
|
|
26
|
-
...ROLE_PROFILE_INHERITABLE_FIELDS
|
|
27
|
-
]);
|
|
28
|
-
export const ROLE_AGENT_SCRIPTED_OPTIONS = Object.freeze([
|
|
29
|
-
...ROLE_AGENT_OPTION_SPECS.map(({ option }) => option),
|
|
30
|
-
ROLE_AGENT_INHERIT_OPTION
|
|
31
|
-
]);
|
|
32
|
-
export const ROLE_AGENT_FILE_OPTIONS = Object.freeze(ROLE_AGENT_OPTION_SPECS.filter(({ fileValue }) => fileValue === true).map(({ option }) => option));
|
|
33
|
-
export function roleAgentOptionSpecsForAdapter(adapterId) {
|
|
34
|
-
return ROLE_AGENT_OPTION_SPECS.filter(({ adapters }) => adapters.includes(adapterId));
|
|
35
|
-
}
|
|
36
|
-
export function roleAgentOptionUsage() {
|
|
37
|
-
return [
|
|
38
|
-
...ROLE_AGENT_OPTION_SPECS.map(({ option, valueLabel, repeatable }) => `[${option} <${valueLabel}>${repeatable ? " ..." : ""}]`),
|
|
39
|
-
`[${ROLE_AGENT_INHERIT_OPTION} <field-key> ...]`
|
|
40
|
-
].join(" ");
|
|
41
|
-
}
|
|
42
|
-
function roleAgentOption(option, fieldKey, valueLabel, repeatable, adapters, extra = {}) {
|
|
43
|
-
return Object.freeze({ option, fieldKey, valueLabel, arity: "value", repeatable, adapters, ...extra });
|
|
44
|
-
}
|
|
45
|
-
export const FIRST_CLASS_AGENT_OPTIONS = Object.freeze([
|
|
46
|
-
Object.freeze({ id: "codex", label: "Codex" }),
|
|
47
|
-
Object.freeze({ id: "claude", label: "Claude" })
|
|
48
|
-
]);
|
|
49
|
-
export function orderRoleOptions(roles) {
|
|
50
|
-
return [...roles].sort((left, right) => {
|
|
51
|
-
const rank = roleRank(left) - roleRank(right);
|
|
52
|
-
if (rank !== 0)
|
|
53
|
-
return rank;
|
|
54
|
-
return roleName(left).localeCompare(roleName(right));
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
function roleRank(role) {
|
|
58
|
-
const kind = role.kind?.toLowerCase();
|
|
59
|
-
const name = roleName(role).toLowerCase();
|
|
60
|
-
if (kind === "operator" || name === "operator")
|
|
61
|
-
return 0;
|
|
62
|
-
if (kind === "leader" || name === "leader")
|
|
63
|
-
return 1;
|
|
64
|
-
return 2;
|
|
65
|
-
}
|
|
66
|
-
function roleName(role) {
|
|
67
|
-
return role.name ?? role.id ?? "";
|
|
68
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { MAX_TURN_RESULT_OUTPUT_BYTES } from "../domain/agentResultTransport.js";
|
|
2
|
-
export const MAX_SYNTHESIS_SOURCE_TURNS = 8;
|
|
3
|
-
export const MAX_CONTEXT_SOURCE_TURNS = MAX_SYNTHESIS_SOURCE_TURNS + 1;
|
|
4
|
-
export const MAX_CONTEXT_SOURCE_TURN_BYTES = MAX_CONTEXT_SOURCE_TURNS * (MAX_TURN_RESULT_OUTPUT_BYTES + 16 * 1024);
|
|
5
|
-
/**
|
|
6
|
-
* Frozen input for synthesis. The main Agent needs the producer identity and
|
|
7
|
-
* exact result, not another copy of its prompt history, launch configuration,
|
|
8
|
-
* or workspace descriptor.
|
|
9
|
-
*/
|
|
10
|
-
export function sourceTurnContextValue(turn) {
|
|
11
|
-
if (turn.result === undefined) {
|
|
12
|
-
throw new Error(`Source Turn has no result: ${turn.id}.`);
|
|
13
|
-
}
|
|
14
|
-
return Object.freeze({
|
|
15
|
-
schemaVersion: 1,
|
|
16
|
-
id: turn.id,
|
|
17
|
-
taskId: turn.taskId,
|
|
18
|
-
roleName: turn.roleName,
|
|
19
|
-
purpose: turn.purpose,
|
|
20
|
-
...(turn.workItemId === undefined ? {} : { workItemId: turn.workItemId }),
|
|
21
|
-
...(turn.reviewRoundId === undefined ? {} : { reviewRoundId: turn.reviewRoundId }),
|
|
22
|
-
...(turn.executionGroupId === undefined
|
|
23
|
-
? {}
|
|
24
|
-
: { executionGroupId: turn.executionGroupId }),
|
|
25
|
-
...(turn.executionLaneId === undefined ? {} : { executionLaneId: turn.executionLaneId }),
|
|
26
|
-
result: turn.result,
|
|
27
|
-
createdAt: turn.createdAt,
|
|
28
|
-
updatedAt: turn.updatedAt
|
|
29
|
-
});
|
|
30
|
-
}
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
import { enqueueRoleTurnDispatch } from "../coordination/workMailboxQueue.js";
|
|
2
|
-
import { createTurnInput } from "../context/turnInputContract.js";
|
|
3
|
-
import { contextSnapshotDeltaRefIds, freezeTurnContextSnapshot } from "../context/turnContextPack.js";
|
|
4
|
-
import { contextSnapshotRef } from "../context/contextSnapshot.js";
|
|
5
|
-
import { roleAgentSessionResumeMode } from "../executor/agentExecutor.js";
|
|
6
|
-
import { resolveEffectiveLaunch } from "../executor/effectiveLaunch.js";
|
|
7
|
-
import { createTaskEvent } from "../event/taskEvent.js";
|
|
8
|
-
import { finishReviewRound, startReviewRound } from "../review/reviewRound.js";
|
|
9
|
-
import { createTurn } from "../turn/turn.js";
|
|
10
|
-
import { executionGroupSettled, MINIMUM_SYNTHESIS_RESULTS } from "./workItemExecution.js";
|
|
11
|
-
export function successfulReviewSynthesisProducers(store, round, group) {
|
|
12
|
-
if (!executionGroupSettled(group)) {
|
|
13
|
-
throw new Error(`Review ExecutionGroup is not settled: ${round.id}/${group.id}.`);
|
|
14
|
-
}
|
|
15
|
-
return [...group.lanes]
|
|
16
|
-
.sort((left, right) => left.ordinal - right.ordinal || left.id.localeCompare(right.id))
|
|
17
|
-
.flatMap((lane) => {
|
|
18
|
-
if (lane.disposition !== "succeeded")
|
|
19
|
-
return [];
|
|
20
|
-
const turn = lane.successfulTurnId === undefined
|
|
21
|
-
? null
|
|
22
|
-
: store.getTurn(round.taskId, lane.successfulTurnId);
|
|
23
|
-
if (turn === null
|
|
24
|
-
|| turn.status !== "completed"
|
|
25
|
-
|| turn.purpose !== "review"
|
|
26
|
-
|| turn.reviewRoundId !== round.id
|
|
27
|
-
|| turn.executionGroupId !== group.id
|
|
28
|
-
|| turn.executionLaneId !== lane.id
|
|
29
|
-
|| turn.result === undefined) {
|
|
30
|
-
throw new Error(`Successful Review ExecutionLane has no exact Producer result: `
|
|
31
|
-
+ `${group.id}/${lane.id}.`);
|
|
32
|
-
}
|
|
33
|
-
return [{
|
|
34
|
-
laneId: lane.id,
|
|
35
|
-
roleName: lane.roleName,
|
|
36
|
-
turnId: turn.id
|
|
37
|
-
}];
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Projects a settled replicated Review into exactly one initial main Reviewer
|
|
42
|
-
* synthesis Turn. Explicit Turn retry may create later main attempts with the
|
|
43
|
-
* same source Group; successful producer Lanes remain immutable.
|
|
44
|
-
*/
|
|
45
|
-
export function reconcileReviewMainTurns(store, taskId, now) {
|
|
46
|
-
const task = store.getTask(taskId);
|
|
47
|
-
if (task === null || task.status !== "active") {
|
|
48
|
-
return { createdTurns: [], failedReviewRoundIds: [] };
|
|
49
|
-
}
|
|
50
|
-
const createdTurns = [];
|
|
51
|
-
const failedReviewRoundIds = [];
|
|
52
|
-
const rounds = [...store.listReviewRounds(taskId)]
|
|
53
|
-
.sort((left, right) => left.createdAt.localeCompare(right.createdAt) || left.id.localeCompare(right.id));
|
|
54
|
-
for (const round of rounds) {
|
|
55
|
-
const group = round.executionGroup;
|
|
56
|
-
if (round.status !== "running"
|
|
57
|
-
|| group === undefined
|
|
58
|
-
|| round.reviewerTurnId !== undefined
|
|
59
|
-
|| !executionGroupSettled(group))
|
|
60
|
-
continue;
|
|
61
|
-
const producers = successfulReviewSynthesisProducers(store, round, group);
|
|
62
|
-
if (producers.length < MINIMUM_SYNTHESIS_RESULTS) {
|
|
63
|
-
const summary = `Review ExecutionGroup ${group.id} settled with ${producers.length} `
|
|
64
|
-
+ `successful Producer result${producers.length === 1 ? "" : "s"}; at least `
|
|
65
|
-
+ `${MINIMUM_SYNTHESIS_RESULTS} are required.`;
|
|
66
|
-
store.saveReviewRound(taskId, finishReviewRound(round, "failed", now, { kind: "quorum", message: summary }));
|
|
67
|
-
store.saveEvent(taskId, createTaskEvent(store.nextEventId(taskId), taskId, "review.execution-group-failed", {
|
|
68
|
-
reviewRoundId: round.id,
|
|
69
|
-
executionGroupId: group.id,
|
|
70
|
-
successfulProducerCount: String(producers.length),
|
|
71
|
-
requiredProducerCount: String(MINIMUM_SYNTHESIS_RESULTS)
|
|
72
|
-
}, now));
|
|
73
|
-
failedReviewRoundIds.push(round.id);
|
|
74
|
-
continue;
|
|
75
|
-
}
|
|
76
|
-
const existing = store.listTurns(taskId).filter((turn) => (turn.purpose === "review"
|
|
77
|
-
&& turn.reviewRoundId === round.id
|
|
78
|
-
&& turn.sourceExecutionGroupId === group.id));
|
|
79
|
-
if (existing.some(({ status }) => status !== "failed"))
|
|
80
|
-
continue;
|
|
81
|
-
const role = store.getRole(taskId, round.reviewerRoleName);
|
|
82
|
-
if (role === null) {
|
|
83
|
-
throw new Error(`Review main Role is missing: ${taskId}/${round.reviewerRoleName}.`);
|
|
84
|
-
}
|
|
85
|
-
if (store.getActiveTurn(taskId, role.name) !== null)
|
|
86
|
-
continue;
|
|
87
|
-
const workspace = store.getReviewRoundWorkspace(taskId, round.id);
|
|
88
|
-
if (workspace === null) {
|
|
89
|
-
throw new Error(`Review main workspace is missing: ${taskId}/${round.id}.`);
|
|
90
|
-
}
|
|
91
|
-
const effective = resolveEffectiveLaunch({
|
|
92
|
-
role,
|
|
93
|
-
purpose: "review",
|
|
94
|
-
workspace,
|
|
95
|
-
reviewRoundId: round.id,
|
|
96
|
-
reviewBaseCommit: round.reviewBaseCommit
|
|
97
|
-
});
|
|
98
|
-
const snapshot = freezeTurnContextSnapshot(store, {
|
|
99
|
-
taskId,
|
|
100
|
-
roleName: role.name,
|
|
101
|
-
purpose: "review",
|
|
102
|
-
...(round.workItemId === undefined ? {} : { workItemId: round.workItemId }),
|
|
103
|
-
reviewRoundId: round.id,
|
|
104
|
-
sourceExecutionGroupId: group.id
|
|
105
|
-
}, now, "controller", group.assignment.contextSnapshotRef);
|
|
106
|
-
const turn = createTurn(store.nextTurnId(taskId), taskId, role.name, roleAgentSessionResumeMode(store.getTaskRoleSessionSet(taskId, role.name), effective.agentId, effective), createTurnInput({
|
|
107
|
-
source: {
|
|
108
|
-
type: "yui",
|
|
109
|
-
channel: round.workItemId === undefined ? "task-dispatch" : "workitem-dispatch"
|
|
110
|
-
},
|
|
111
|
-
directive: synthesisDirective(group, producers),
|
|
112
|
-
contextSnapshotRef: contextSnapshotRef(snapshot),
|
|
113
|
-
deltaRefIds: contextSnapshotDeltaRefIds(store, snapshot)
|
|
114
|
-
}), now, {
|
|
115
|
-
...(round.workItemId === undefined ? {} : { workItemId: round.workItemId }),
|
|
116
|
-
purpose: "review",
|
|
117
|
-
reviewRoundId: round.id,
|
|
118
|
-
sourceExecutionGroupId: group.id,
|
|
119
|
-
workspace,
|
|
120
|
-
effective
|
|
121
|
-
});
|
|
122
|
-
store.saveTurn(turn);
|
|
123
|
-
store.saveReviewRound(taskId, startReviewRound(round, turn.id));
|
|
124
|
-
store.saveActiveTurn(turn);
|
|
125
|
-
enqueueRoleTurnDispatch(store, {
|
|
126
|
-
taskId,
|
|
127
|
-
roleName: role.name,
|
|
128
|
-
turnId: turn.id,
|
|
129
|
-
reason: "review-synthesis-ready",
|
|
130
|
-
occurredAt: now
|
|
131
|
-
});
|
|
132
|
-
store.saveEvent(taskId, createTaskEvent(store.nextEventId(taskId), taskId, "turn.review-dispatched", {
|
|
133
|
-
turnId: turn.id,
|
|
134
|
-
role: turn.roleName,
|
|
135
|
-
purpose: turn.purpose,
|
|
136
|
-
mode: turn.mode,
|
|
137
|
-
agent: `${turn.effective.agentId}/${turn.effective.adapterId}`,
|
|
138
|
-
effectiveRevision: String(turn.effective.sourceDesiredRevision),
|
|
139
|
-
profileAccess: turn.effective.profileAccess,
|
|
140
|
-
effectivePermission: turn.effective.permission.strategy,
|
|
141
|
-
writeProjectIds: turn.effective.writeProjectIds.join(",") || "none",
|
|
142
|
-
reviewRoundId: round.id,
|
|
143
|
-
sourceExecutionGroupId: group.id
|
|
144
|
-
}, now));
|
|
145
|
-
createdTurns.push(turn);
|
|
146
|
-
}
|
|
147
|
-
return { createdTurns, failedReviewRoundIds };
|
|
148
|
-
}
|
|
149
|
-
function synthesisDirective(group, producers) {
|
|
150
|
-
return [
|
|
151
|
-
"Act as the main Reviewer over every frozen successful Producer result in stable Lane order.",
|
|
152
|
-
"Expand each exact source Turn from the frozen Context Snapshot and consume its original result text plus Core-authored system evidence.",
|
|
153
|
-
"Resolve disagreements through review judgment against the frozen candidate. Do not rerun, retry, append, select, or abandon Lanes.",
|
|
154
|
-
"Return one complete original review result for the Leader; Yui Core does not parse or validate its semantic structure.",
|
|
155
|
-
JSON.stringify({
|
|
156
|
-
schemaVersion: 1,
|
|
157
|
-
sourceExecutionGroupId: group.id,
|
|
158
|
-
producers
|
|
159
|
-
}, null, 2)
|
|
160
|
-
].join("\n\n");
|
|
161
|
-
}
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
import { isDeepStrictEqual } from "node:util";
|
|
2
|
-
import { enqueueRoleTurnDispatch } from "../coordination/workMailboxQueue.js";
|
|
3
|
-
import { createTurnInput } from "../context/turnInputContract.js";
|
|
4
|
-
import { contextSnapshotDeltaRefIds, freezeTurnContextSnapshot } from "../context/turnContextPack.js";
|
|
5
|
-
import { contextSnapshotRef } from "../context/contextSnapshot.js";
|
|
6
|
-
import { roleAgentSessionResumeMode } from "../executor/agentExecutor.js";
|
|
7
|
-
import { resolveEffectiveLaunch } from "../executor/effectiveLaunch.js";
|
|
8
|
-
import { createTaskEvent } from "../event/taskEvent.js";
|
|
9
|
-
import { createTurn } from "../turn/turn.js";
|
|
10
|
-
import { currentWorkItemExecutionGroup, updateWorkItemStatus } from "../workItem/workItem.js";
|
|
11
|
-
import { MINIMUM_WORK_ITEM_SYNTHESIS_RESULTS, workItemExecutionGroupSettled } from "./workItemExecution.js";
|
|
12
|
-
export function successfulWorkItemSynthesisProducers(store, item, group) {
|
|
13
|
-
if (!workItemExecutionGroupSettled(group)) {
|
|
14
|
-
throw new Error(`WorkItem ExecutionGroup is not settled: ${item.id}/${group.id}.`);
|
|
15
|
-
}
|
|
16
|
-
return [...group.lanes]
|
|
17
|
-
.sort((left, right) => left.ordinal - right.ordinal || left.id.localeCompare(right.id))
|
|
18
|
-
.flatMap((lane) => {
|
|
19
|
-
if (lane.disposition !== "succeeded")
|
|
20
|
-
return [];
|
|
21
|
-
const turn = lane.successfulTurnId === undefined
|
|
22
|
-
? null
|
|
23
|
-
: store.getTurn(item.taskId, lane.successfulTurnId);
|
|
24
|
-
if (turn === null
|
|
25
|
-
|| turn.status !== "completed"
|
|
26
|
-
|| turn.workItemId !== item.id
|
|
27
|
-
|| turn.executionGroupId !== group.id
|
|
28
|
-
|| turn.executionLaneId !== lane.id
|
|
29
|
-
|| turn.result === undefined) {
|
|
30
|
-
throw new Error(`Successful ExecutionLane has no exact Producer Turn result: ${group.id}/${lane.id}.`);
|
|
31
|
-
}
|
|
32
|
-
return [{
|
|
33
|
-
laneId: lane.id,
|
|
34
|
-
roleName: lane.roleName,
|
|
35
|
-
turnId: turn.id
|
|
36
|
-
}];
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Reconcile every settled replicated WorkItem in one Task. The Turn row is the
|
|
41
|
-
* durable caller/idempotency record: at most one initial main Turn may name a
|
|
42
|
-
* source Group, while explicit retries append more Turns with the same source.
|
|
43
|
-
*/
|
|
44
|
-
export function reconcileWorkItemMainTurns(store, taskId, now) {
|
|
45
|
-
const task = store.getTask(taskId);
|
|
46
|
-
if (task === null || task.status !== "active" || task.executionGate.state !== "enabled") {
|
|
47
|
-
return { createdTurns: [], failedWorkItemIds: [] };
|
|
48
|
-
}
|
|
49
|
-
const createdTurns = [];
|
|
50
|
-
const failedWorkItemIds = [];
|
|
51
|
-
const items = [...store.listWorkItems(taskId)].sort((left, right) => (left.createdAt.localeCompare(right.createdAt) || left.id.localeCompare(right.id)));
|
|
52
|
-
for (const item of items) {
|
|
53
|
-
if (item.status !== "running")
|
|
54
|
-
continue;
|
|
55
|
-
const group = currentWorkItemExecutionGroup(item);
|
|
56
|
-
if (group === undefined || !workItemExecutionGroupSettled(group))
|
|
57
|
-
continue;
|
|
58
|
-
const producers = successfulWorkItemSynthesisProducers(store, item, group);
|
|
59
|
-
if (producers.length < MINIMUM_WORK_ITEM_SYNTHESIS_RESULTS) {
|
|
60
|
-
const summary = `ExecutionGroup ${group.id} settled with ${producers.length} successful `
|
|
61
|
-
+ `Producer result${producers.length === 1 ? "" : "s"}; at least `
|
|
62
|
-
+ `${MINIMUM_WORK_ITEM_SYNTHESIS_RESULTS} are required.`;
|
|
63
|
-
store.saveWorkItem(taskId, updateWorkItemStatus(item, "failed", now, summary));
|
|
64
|
-
store.saveEvent(taskId, createTaskEvent(store.nextEventId(taskId), taskId, "work.execution-group-failed", {
|
|
65
|
-
workItemId: item.id,
|
|
66
|
-
executionGroupId: group.id,
|
|
67
|
-
successfulProducerCount: String(producers.length),
|
|
68
|
-
requiredProducerCount: String(MINIMUM_WORK_ITEM_SYNTHESIS_RESULTS)
|
|
69
|
-
}, now));
|
|
70
|
-
failedWorkItemIds.push(item.id);
|
|
71
|
-
continue;
|
|
72
|
-
}
|
|
73
|
-
const existing = store.listTurns(taskId).some((turn) => (turn.purpose === "execution"
|
|
74
|
-
&& turn.workItemId === item.id
|
|
75
|
-
&& turn.sourceExecutionGroupId === group.id));
|
|
76
|
-
if (existing)
|
|
77
|
-
continue;
|
|
78
|
-
if (item.assignee === undefined) {
|
|
79
|
-
throw new Error(`Replicated WorkItem has no main assignee: ${item.id}.`);
|
|
80
|
-
}
|
|
81
|
-
const role = store.getRole(taskId, item.assignee);
|
|
82
|
-
if (role === null)
|
|
83
|
-
throw new Error(`WorkItem main Role is missing: ${taskId}/${item.assignee}.`);
|
|
84
|
-
if (store.getActiveTurn(taskId, role.name) !== null)
|
|
85
|
-
continue;
|
|
86
|
-
const workspace = role.name === "leader"
|
|
87
|
-
? store.getTaskWorkspace(taskId)
|
|
88
|
-
: store.getWorkItemWorkspace(taskId, item.id);
|
|
89
|
-
if (workspace === null) {
|
|
90
|
-
throw new Error(`WorkItem main workspace is missing: ${taskId}/${item.id}.`);
|
|
91
|
-
}
|
|
92
|
-
const visibleProjectIds = workspace.entries.map(({ projectId }) => projectId).sort();
|
|
93
|
-
const taskProjectIds = task.projectBindings.map(({ projectId }) => projectId).sort();
|
|
94
|
-
const writableProjectIds = workspace.entries
|
|
95
|
-
.filter(({ access }) => access === "write")
|
|
96
|
-
.map(({ projectId }) => projectId)
|
|
97
|
-
.sort();
|
|
98
|
-
if (!isDeepStrictEqual(visibleProjectIds, taskProjectIds)
|
|
99
|
-
|| !isDeepStrictEqual(writableProjectIds, [...item.writeProjectIds].sort())) {
|
|
100
|
-
throw new Error(`WorkItem main workspace does not match its approved scope: ${item.id}.`);
|
|
101
|
-
}
|
|
102
|
-
const effective = resolveEffectiveLaunch({
|
|
103
|
-
role,
|
|
104
|
-
purpose: "execution",
|
|
105
|
-
workspace,
|
|
106
|
-
workItemWriteProjectIds: item.writeProjectIds
|
|
107
|
-
});
|
|
108
|
-
const snapshot = freezeTurnContextSnapshot(store, {
|
|
109
|
-
taskId,
|
|
110
|
-
roleName: role.name,
|
|
111
|
-
purpose: "execution",
|
|
112
|
-
workItemId: item.id,
|
|
113
|
-
sourceExecutionGroupId: group.id,
|
|
114
|
-
workspace
|
|
115
|
-
}, now, "controller", group.assignment.contextSnapshotRef);
|
|
116
|
-
const turn = createTurn(store.nextTurnId(taskId), taskId, role.name, roleAgentSessionResumeMode(store.getTaskRoleSessionSet(taskId, role.name), effective.agentId, effective), createTurnInput({
|
|
117
|
-
source: { type: "yui", channel: "workitem-dispatch" },
|
|
118
|
-
directive: synthesisDirective(group, producers),
|
|
119
|
-
contextSnapshotRef: contextSnapshotRef(snapshot),
|
|
120
|
-
deltaRefIds: contextSnapshotDeltaRefIds(store, snapshot)
|
|
121
|
-
}), now, {
|
|
122
|
-
workItemId: item.id,
|
|
123
|
-
sourceExecutionGroupId: group.id,
|
|
124
|
-
workspace,
|
|
125
|
-
effective
|
|
126
|
-
});
|
|
127
|
-
store.saveTurn(turn);
|
|
128
|
-
store.saveActiveTurn(turn);
|
|
129
|
-
enqueueRoleTurnDispatch(store, {
|
|
130
|
-
taskId,
|
|
131
|
-
roleName: role.name,
|
|
132
|
-
turnId: turn.id,
|
|
133
|
-
reason: "workitem-synthesis-ready",
|
|
134
|
-
occurredAt: now
|
|
135
|
-
});
|
|
136
|
-
store.saveEvent(taskId, createTaskEvent(store.nextEventId(taskId), taskId, "turn.dispatched", {
|
|
137
|
-
turnId: turn.id,
|
|
138
|
-
role: turn.roleName,
|
|
139
|
-
purpose: turn.purpose,
|
|
140
|
-
mode: turn.mode,
|
|
141
|
-
agent: `${turn.effective.agentId}/${turn.effective.adapterId}`,
|
|
142
|
-
effectiveRevision: String(turn.effective.sourceDesiredRevision),
|
|
143
|
-
profileAccess: turn.effective.profileAccess,
|
|
144
|
-
effectivePermission: turn.effective.permission.strategy,
|
|
145
|
-
writeProjectIds: turn.effective.writeProjectIds.join(",") || "none",
|
|
146
|
-
workItemId: item.id,
|
|
147
|
-
sourceExecutionGroupId: group.id
|
|
148
|
-
}, now));
|
|
149
|
-
createdTurns.push(turn);
|
|
150
|
-
}
|
|
151
|
-
return { createdTurns, failedWorkItemIds };
|
|
152
|
-
}
|
|
153
|
-
function synthesisDirective(group, producers) {
|
|
154
|
-
return [
|
|
155
|
-
"Synthesize every frozen successful Producer result in stable Lane order.",
|
|
156
|
-
"Expand each exact source Turn from the frozen Context Snapshot and consume its original result text plus Core-authored system evidence.",
|
|
157
|
-
"Do not rerun, retry, append, or abandon any Lane. Form the final WorkItem result from these records.",
|
|
158
|
-
JSON.stringify({
|
|
159
|
-
schemaVersion: 1,
|
|
160
|
-
sourceExecutionGroupId: group.id,
|
|
161
|
-
producers
|
|
162
|
-
}, null, 2)
|
|
163
|
-
].join("\n\n");
|
|
164
|
-
}
|