@zq-silk/yui 0.13.9 → 0.14.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/ARCHITECTURE.md +69 -428
- package/README.md +108 -298
- package/dist/agent/managedRuntimeEnvironment.js +2 -2
- package/dist/cli/commandCatalog.js +39 -77
- package/dist/cli/interactionCandidates.js +4 -4
- package/dist/cli/interactionPolicy.js +7 -10
- package/dist/cli/invocationRouter.js +1 -1
- package/dist/cli/updateCommand.js +6 -27
- package/dist/cli/updateOrchestrator.js +63 -484
- package/dist/cli/updatePorts.js +15 -333
- package/dist/cli/upgradeCommand.js +8 -65
- package/dist/cli.js +57 -242
- package/dist/commands/configCommands.js +11 -62
- package/dist/commands/executionAuditCommands.js +23 -23
- package/dist/commands/globalRoleCommands.js +2 -7
- package/dist/commands/jobCommands.js +1 -4
- package/dist/commands/projectCommands.js +5 -5
- package/dist/commands/releaseCommands.js +3 -10
- package/dist/commands/resourcesCommands.js +2 -2
- package/dist/commands/sessionCommands.js +2 -2
- package/dist/commands/taskActor.js +31 -39
- package/dist/commands/taskChangeSetCommands.js +5 -12
- package/dist/commands/taskCommands.js +464 -1249
- package/dist/commands/taskContextCommand.js +35 -36
- package/dist/commands/taskExecutionCommands.js +33 -46
- package/dist/commands/taskInputCommands.js +20 -42
- package/dist/commands/taskNextActionCommand.js +9 -9
- package/dist/commands/taskOverviewCommand.js +56 -95
- package/dist/commands/taskRoleRuntimeStatus.js +77 -107
- package/dist/commands/taskUpstreamCommands.js +3 -3
- package/dist/commands/taskWorkspaceCommands.js +7 -79
- package/dist/commands/telemetryCommands.js +32 -124
- package/dist/commands/workflowCommands.js +3 -3
- package/dist/completion/fileCompletionManager.js +1 -1
- package/dist/config/configCatalog.js +4 -6
- package/dist/config/yuiConfig.js +6 -43
- package/dist/context/dispatchContext.js +14 -30
- package/dist/context/roleSessionContext.js +2 -2
- package/dist/context/sessionBootstrapManifest.js +2 -2
- package/dist/context/{runContextPack.js → turnContextPack.js} +58 -73
- package/dist/context/turnInputContract.js +204 -0
- package/dist/context/wakeNotification.js +2 -2
- package/dist/controller/agentRuntimeObserver.js +18 -18
- package/dist/controller/clientRuntime.js +13 -20
- package/dist/controller/controller.js +89 -116
- package/dist/controller/fileSchedulerStoreAdapter.js +511 -742
- package/dist/controller/jobControl.js +17 -17
- package/dist/controller/resourceInventory.js +6 -6
- package/dist/controller/resourceInventoryLinux.js +38 -59
- package/dist/controller/resourceInventoryRpc.js +3 -3
- package/dist/controller/resourceInventoryWorker.js +1 -1
- package/dist/controller/runtime.js +46 -53
- package/dist/controller/runtimeEventInbox.js +23 -31
- package/dist/controller/runtimeEventProcessor.js +15 -15
- package/dist/controller/{runtimeHookRunFence.js → runtimeHookTurnFence.js} +87 -81
- package/dist/controller/runtimeLaunchCoordinator.js +3 -3
- package/dist/controller/runtimeObservationHook.js +11 -8
- package/dist/controller/sessionNotify.js +11 -11
- package/dist/controller/structuredProviderObservation.js +89 -16
- package/dist/coordination/workMailbox.js +309 -579
- package/dist/coordination/workMailboxQueue.js +5 -6
- package/dist/core/controllerClient.js +1 -91
- package/dist/core/controllerServer.js +3 -6
- package/dist/doctor/doctor.js +51 -314
- package/dist/execution/candidateConvergence.js +3 -3
- package/dist/execution/executionGroup.js +32 -33
- package/dist/execution/executionHealth.js +36 -38
- package/dist/execution/resourceBroker.js +12 -12
- package/dist/executor/agentExecutor.js +30 -265
- package/dist/executor/effectiveLaunch.js +9 -19
- package/dist/executor/executorRegistry.js +43 -17
- package/dist/executor/fileRoleLaunchPlanner.js +56 -56
- package/dist/executor/launchPlan.js +3 -3
- package/dist/executor/workspacePreflightClassification.js +16 -16
- package/dist/grant/capabilityGrant.js +20 -25
- package/dist/input/inputRequest.js +12 -12
- package/dist/integration/changeSet.js +9 -13
- package/dist/integration/changeSetManifest.js +1 -1
- package/dist/integration/gitIntegrationService.js +2 -2
- package/dist/integration/integrationQueueService.js +5 -21
- package/dist/integration/overlapDiagnostics.js +2 -2
- package/dist/interaction/operatorPresentation.js +1 -1
- package/dist/job/jobRunner.js +1 -1
- package/dist/lifecycle/canonicalLifecycleEvent.js +25 -25
- package/dist/lifecycle/{exactRunTerminalization.js → exactTurnTerminalization.js} +116 -232
- package/dist/message/message.js +6 -6
- package/dist/observability/executionAudit.js +74 -86
- package/dist/observability/faultClassification.js +7 -24
- package/dist/observability/orchestrationMetrics.js +5 -5
- package/dist/observability/runtimeIdentity.js +34 -101
- package/dist/profile/agentProfile.js +1 -1
- package/dist/release/cliHomeReleaseFence.js +3 -3
- package/dist/release/releaseWorkflowEngine.js +6 -10
- package/dist/release/releaseWorkflowPorts.js +2 -2
- package/dist/release/workflowFileLock.js +1 -1
- package/dist/repository/checkoutSwap.js +1 -1
- package/dist/repository/gitWorkspace.js +0 -13
- package/dist/repository/project.js +1 -1
- package/dist/repository/projectMaintenanceLock.js +1 -2
- package/dist/repository/taskBaseFreshness.js +13 -13
- package/dist/repository/taskWorkspaceCoordinator.js +21 -25
- package/dist/repository/taskWorkspaceIdentity.js +8 -21
- package/dist/repository/taskWorkspacePreparer.js +63 -620
- package/dist/resources/autoResourceGc.js +3 -3
- package/dist/resources/liveReferences.js +1 -1
- package/dist/resources/resourceGc.js +1 -1
- package/dist/resources/sqliteResourceRegistry.js +1 -1
- package/dist/review/reviewDecision.js +7 -7
- package/dist/review/reviewFindingLedger.js +1 -1
- package/dist/review/reviewOutcomeClassifier.js +35 -50
- package/dist/review/reviewRound.js +14 -25
- package/dist/review/reviewerAvailability.js +4 -4
- package/dist/review/taskFinalReviewContractResolution.js +41 -0
- package/dist/role/role.js +6 -3
- package/dist/runtime/agentDriver.js +4 -0
- package/dist/runtime/agentHost.js +151 -36
- package/dist/runtime/builtinAgentDrivers.js +79 -2
- package/dist/runtime/codexAppServerRuntime.js +122 -0
- package/dist/runtime/continuationManager.js +3 -5
- package/dist/runtime/exactControlPlane.js +17 -42
- package/dist/runtime/firstProgressAdvisory.js +1 -1
- package/dist/runtime/index.js +2 -2
- package/dist/runtime/launchDiagnostics.js +2 -2
- package/dist/runtime/lifecycleReservation.js +4 -4
- package/dist/runtime/processExitObservation.js +1 -1
- package/dist/runtime/processExitOutbox.js +0 -32
- package/dist/runtime/promptEnvelope.js +9 -9
- package/dist/runtime/providerContinuation.js +2 -2
- package/dist/runtime/providerContinuationReconciliationService.js +2 -2
- package/dist/runtime/providerRuntimeIdentity.js +76 -24
- package/dist/runtime/recentTurnIds.js +38 -0
- package/dist/runtime/runtimeContinuationProjection.js +2 -2
- package/dist/runtime/runtimeHealthPolicy.js +1 -1
- package/dist/runtime/runtimeObservation.js +58 -21
- package/dist/runtime/runtimeProjection.js +19 -27
- package/dist/runtime/sessionLaunchRequest.js +2 -2
- package/dist/runtime/structuredProviderHost.js +177 -12
- package/dist/runtime/tmuxAdapters.js +46 -11
- package/dist/scheduler/activeRoleTurnDelivery.js +245 -0
- package/dist/scheduler/leaderWakeupProcessor.js +147 -445
- package/dist/scheduler/operatorEvent.js +4 -6
- package/dist/scheduler/resourceQueueProjection.js +71 -0
- package/dist/scheduler/{roleRunLiveness.js → roleTurnLiveness.js} +24 -28
- package/dist/scheduler/{roleRunStall.js → roleTurnStall.js} +162 -247
- package/dist/scheduler/taskExecutionProjection.js +99 -99
- package/dist/scheduler/taskObservabilityProjection.js +10 -10
- package/dist/scheduler/taskWake.js +4 -4
- package/dist/scheduler/wakeReason.js +6 -10
- package/dist/scheduler/wakeupQueue.js +0 -9
- package/dist/setup/setupCommand.js +2 -2
- package/dist/storage/currentTaskStore.js +46 -0
- package/dist/storage/persistenceWorker.js +1 -1
- package/dist/storage/sqliteSchema.js +81 -485
- package/dist/storage/sqliteStore.js +206 -365
- package/dist/storage/storageSchema.js +1 -15
- package/dist/storage/storageVersions.js +8 -9
- package/dist/storage/storeRpc.js +10 -34
- package/dist/storage/taskStore.js +63 -3415
- package/dist/storage/upgrade/recordVersions.js +55 -149
- package/dist/storage/upgrade/upgradeOrchestrator.js +89 -1752
- package/dist/task/completionReadiness.js +5 -5
- package/dist/task/deliveryGuard.js +10 -10
- package/dist/task/nextAction.js +74 -77
- package/dist/task/task.js +2 -4
- package/dist/task/taskRecordReference.js +3 -3
- package/dist/task/taskRecordRetirement.js +1 -1
- package/dist/telemetry/sqliteTelemetryStore.js +53 -53
- package/dist/telemetry/telemetryConfig.js +14 -14
- package/dist/telemetry/telemetryWiring.js +8 -14
- package/dist/turn/turn.js +356 -0
- package/dist/{run/runIdentity.js → turn/turnIdentity.js} +4 -4
- package/dist/verification/gateArtifactStore.js +2 -2
- package/dist/web/assets/client/app.js +1 -1
- package/dist/web/assets/client/components.js +29 -54
- package/dist/web/assets/client/i18n.js +17 -37
- package/dist/web/assets/client/view.js +37 -37
- package/dist/web/assets/shell.js +1 -1
- package/dist/web/assets/styles/cards.js +5 -5
- package/dist/web/assets/styles/widgets.js +1 -2
- package/dist/web/webSnapshot.js +65 -60
- package/dist/workItem/workItem.js +11 -11
- package/dist/workspace/workItemChangeSetManager.js +1 -1
- package/docs/task-local-identity.md +5 -5
- package/i18n/README.zh-CN.md +41 -54
- package/package.json +1 -1
- package/skills/yui-leader/SKILL.md +85 -83
- package/skills/yui-operator/SKILL.md +16 -16
- package/skills/yui-reviewer/SKILL.md +10 -10
- package/skills/yui-runtime/SKILL.md +17 -18
- package/skills/yui-worker/SKILL.md +16 -18
- package/dist/context/runContextContract.js +0 -162
- package/dist/executor/turnCompletion.js +0 -126
- package/dist/review/taskFinalReviewContractEvent.js +0 -1
- package/dist/review/taskFinalReviewContractRebind.js +0 -367
- package/dist/run/agentRun.js +0 -356
- package/dist/run/rejectedYieldAttempt.js +0 -221
- package/dist/run/runControlRequest.js +0 -50
- package/dist/run/yieldReceipt.js +0 -65
- package/dist/runtime/turnCompletion.js +0 -3
- package/dist/scheduler/actionability.js +0 -323
- package/dist/scheduler/activeRoleRunDelivery.js +0 -868
- package/dist/scheduler/activeTaskProgress.js +0 -126
- package/dist/storage/compatibleTaskStore.js +0 -248
- package/dist/storage/migration/baseline.js +0 -78
- package/dist/storage/migration/classifier.js +0 -51
- package/dist/storage/migration/compatibleCodec.js +0 -53
- package/dist/storage/migration/engine.js +0 -147
- package/dist/storage/migration/index.js +0 -33
- package/dist/storage/migration/planner.js +0 -154
- package/dist/storage/migration/productionRegistry.js +0 -3931
- package/dist/storage/migration/registry.js +0 -169
- package/dist/storage/migration/report.js +0 -54
- package/dist/storage/migration/types.js +0 -31
- package/dist/storage/upgrade/homeClassification.js +0 -353
- package/dist/storage/upgrade/homeMigrationTarget.js +0 -595
- package/dist/storage/upgrade/migrationReceipt.js +0 -67
- package/dist/storage/upgrade/offlineUpgradeInventory.js +0 -453
- package/dist/storage/upgrade/productionMigrationRegistry.js +0 -6
- package/dist/storage/upgrade/pseudoLayoutRepair.js +0 -241
- package/dist/storage/upgrade/recordVersionScan.js +0 -176
- package/dist/storage/upgrade/sqliteFileSet.js +0 -50
- package/dist/storage/upgrade/sqliteMigrationTarget.js +0 -375
- package/dist/storage/upgrade/sqliteRecordMigrationTarget.js +0 -305
- package/dist/storage/upgrade/sqliteStateMigration.js +0 -918
- package/dist/storage/upgrade/switchProgress.js +0 -80
- package/dist/storage/upgrade/upgradeReceipt.js +0 -161
- package/dist/storage/upgradeCoordination.js +0 -187
- package/dist/storage/upgradeFence.js +0 -366
- package/dist/telemetry/telemetryCompaction.js +0 -252
|
@@ -191,7 +191,7 @@ export async function enqueueIntegrationQueueEntry(input) {
|
|
|
191
191
|
if (project === null)
|
|
192
192
|
throw new Error(`Project not found: ${input.projectId}.`);
|
|
193
193
|
const targetRef = input.targetRef
|
|
194
|
-
?? changeSet.manifest
|
|
194
|
+
?? changeSet.manifest.targetRef
|
|
195
195
|
?? taskMainBranch(input.store, task.id, input.projectId);
|
|
196
196
|
if (targetRef === undefined) {
|
|
197
197
|
throw new Error(`Task main worktree is not ready; reconcile the Task first: ${task.id}.`);
|
|
@@ -276,7 +276,7 @@ export async function enqueueIntegrationQueueEntry(input) {
|
|
|
276
276
|
changeSetId: input.changeSetId,
|
|
277
277
|
targetRef: canonicalTargetRef,
|
|
278
278
|
checkCommands: requestedChecks,
|
|
279
|
-
evidenceRefs: changeSet.manifest
|
|
279
|
+
evidenceRefs: changeSet.manifest.evidenceRefs
|
|
280
280
|
}, now());
|
|
281
281
|
// Durable positive exact-SHA evidence on an unchanged target, at the lane
|
|
282
282
|
// head, validates the entry so processing skips its checks. The process-
|
|
@@ -341,7 +341,7 @@ export async function enqueueIntegrationQueueEntry(input) {
|
|
|
341
341
|
changeSetId: input.changeSetId,
|
|
342
342
|
targetRef: canonicalTargetRef,
|
|
343
343
|
checkCommands: requestedChecks,
|
|
344
|
-
evidenceRefs: changeSet.manifest
|
|
344
|
+
evidenceRefs: changeSet.manifest.evidenceRefs
|
|
345
345
|
}, now());
|
|
346
346
|
tx.saveIntegrationQueueEntry(task.id, queuedEntry);
|
|
347
347
|
return { entry: queuedEntry, outcome: "queued" };
|
|
@@ -657,7 +657,7 @@ async function evidenceTargetAdvanced(git, repositoryPath, entry, currentTargetH
|
|
|
657
657
|
return true;
|
|
658
658
|
const ownPaths = new Set([
|
|
659
659
|
...changeSet.changedPaths,
|
|
660
|
-
...
|
|
660
|
+
...changeSet.manifest.deletedPaths
|
|
661
661
|
]);
|
|
662
662
|
if (delta.some((path) => ownPaths.has(path)))
|
|
663
663
|
return true;
|
|
@@ -917,25 +917,9 @@ async function findEquivalentCommit(git, repositoryPath, sourceCommit, historyHe
|
|
|
917
917
|
async function findContainedChangeSet(git, repositoryPath, changeSet, targetHead) {
|
|
918
918
|
if (git.treesAgreeOnPaths === undefined)
|
|
919
919
|
return null;
|
|
920
|
-
// A migrated v2 ChangeSet without a manifest has no deletedPaths. Recover
|
|
921
|
-
// the actual deletions from git so the containment proof verifies both
|
|
922
|
-
// sides of a rename: without this, a rename whose destination already
|
|
923
|
-
// exists on the target would converge even though the source still lives
|
|
924
|
-
// there. A ChangeSet with a manifest trusts its declared deletedPaths.
|
|
925
|
-
let extraDeleted = [];
|
|
926
|
-
if (changeSet.manifest === undefined) {
|
|
927
|
-
if (git.deletedFilesBetween === undefined)
|
|
928
|
-
return null;
|
|
929
|
-
extraDeleted = await git.deletedFilesBetween({
|
|
930
|
-
repositoryPath,
|
|
931
|
-
fromCommit: changeSet.baseCommit,
|
|
932
|
-
toCommit: changeSet.headCommit
|
|
933
|
-
});
|
|
934
|
-
}
|
|
935
920
|
const paths = [...new Set([
|
|
936
921
|
...changeSet.changedPaths,
|
|
937
|
-
...
|
|
938
|
-
...extraDeleted
|
|
922
|
+
...changeSet.manifest.deletedPaths
|
|
939
923
|
])];
|
|
940
924
|
if (paths.length === 0)
|
|
941
925
|
return null;
|
|
@@ -25,8 +25,8 @@ export function overlapSubjectFromChangeSet(changeSet) {
|
|
|
25
25
|
baseCommit: changeSet.baseCommit,
|
|
26
26
|
headCommit: changeSet.headCommit,
|
|
27
27
|
changedPaths: changeSet.changedPaths,
|
|
28
|
-
manifestTags: changeSet.manifest
|
|
29
|
-
deletedPaths: changeSet.manifest
|
|
28
|
+
manifestTags: changeSet.manifest.tags,
|
|
29
|
+
deletedPaths: changeSet.manifest.deletedPaths
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
@@ -34,7 +34,7 @@ function eventLabel(event) {
|
|
|
34
34
|
case "task.completed": return "Task completed";
|
|
35
35
|
case "task.retired": return "Task retired";
|
|
36
36
|
case "leader.attention-required": return "Task Leader needs attention";
|
|
37
|
-
case "
|
|
37
|
+
case "turn.stalled": return "Task Leader stalled";
|
|
38
38
|
default: return `Task event ${event.type}`;
|
|
39
39
|
}
|
|
40
40
|
}
|
package/dist/job/jobRunner.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Standalone durable-job runner.
|
|
3
3
|
*
|
|
4
4
|
* Receives exactly one argument: the absolute path to a `spec.json` written
|
|
5
|
-
* atomically by the Controller. The runner MUST NOT open
|
|
5
|
+
* atomically by the Controller. The runner MUST NOT open yui.db or any
|
|
6
6
|
* other control-plane file; its entire contract is the spec + the artifact
|
|
7
7
|
* directory. The Controller supervises the runner through the artifact files
|
|
8
8
|
* (heartbeat, checkpoint.json, exit.json) and the process identity.
|
|
@@ -9,17 +9,17 @@ export class CanonicalLifecycleError extends Error {
|
|
|
9
9
|
this.name = "CanonicalLifecycleError";
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
-
const
|
|
12
|
+
const TURN_SCOPED_PHASES = new Set([
|
|
13
13
|
"prompt-pushed",
|
|
14
14
|
"provider-accepted",
|
|
15
15
|
"turn-progress",
|
|
16
16
|
"turn-terminal"
|
|
17
17
|
]);
|
|
18
18
|
/**
|
|
19
|
-
* Phases that assert durable provider truth about a
|
|
20
|
-
* the complete
|
|
19
|
+
* Phases that assert durable provider truth about a Turn. Every one must carry
|
|
20
|
+
* the complete turn-scoped identity — turnId AND the generation fences
|
|
21
21
|
* (nativeSessionId + launchId) AND, where the transport owns it, the receiptId —
|
|
22
|
-
* because a missing or wrong fence must fail closed rather than advance a
|
|
22
|
+
* because a missing or wrong fence must fail closed rather than advance a Turn or
|
|
23
23
|
* its successor.
|
|
24
24
|
*/
|
|
25
25
|
const PROVIDER_TRUTH_PHASES = new Set([
|
|
@@ -34,7 +34,7 @@ const PROVIDER_TRUTH_PHASES = new Set([
|
|
|
34
34
|
* (acceptance/progress/terminal), so neither a transport/liveness signal nor a
|
|
35
35
|
* shape-only `adapter-mapped` observation can ever forge or terminalize a turn.
|
|
36
36
|
* `adapter-mapped` remains permissible only for the pre-acceptance
|
|
37
|
-
* session-started/ready phases, whose fold never advances
|
|
37
|
+
* session-started/ready phases, whose fold never advances Turn truth.
|
|
38
38
|
*/
|
|
39
39
|
const PHASE_EVIDENCE_MATRIX = {
|
|
40
40
|
"host-process-created": { sources: ["controller"], evidence: ["controller"] },
|
|
@@ -77,11 +77,11 @@ export function createCanonicalLifecycleEvent(input) {
|
|
|
77
77
|
throw new CanonicalLifecycleError(`Phase ${input.phase} rejects evidence ${input.evidence}; only ${rule.evidence.join("/")} may prove it.`);
|
|
78
78
|
}
|
|
79
79
|
const fence = normalizeFence(input.fence);
|
|
80
|
-
if (
|
|
81
|
-
throw new CanonicalLifecycleError(`Phase ${input.phase} requires a
|
|
80
|
+
if (TURN_SCOPED_PHASES.has(input.phase) && fence.turnId === undefined) {
|
|
81
|
+
throw new CanonicalLifecycleError(`Phase ${input.phase} requires a turnId fence.`);
|
|
82
82
|
}
|
|
83
83
|
// Provider-truth phases must carry the complete generation fence so a stale or
|
|
84
|
-
// wrong generation can never advance the
|
|
84
|
+
// wrong generation can never advance the Turn.
|
|
85
85
|
if (PROVIDER_TRUTH_PHASES.has(input.phase)) {
|
|
86
86
|
if (fence.nativeSessionId === undefined) {
|
|
87
87
|
throw new CanonicalLifecycleError(`Phase ${input.phase} requires a nativeSessionId fence.`);
|
|
@@ -176,7 +176,7 @@ export function foldCanonicalLifecycleEvent(event, expectation) {
|
|
|
176
176
|
return { outcome: "obsolete", reason: "push-after-terminal" };
|
|
177
177
|
if (expectation.accepted)
|
|
178
178
|
return { outcome: "obsolete", reason: "push-after-accepted" };
|
|
179
|
-
// Exactly one push: a repeat for an already-pushed
|
|
179
|
+
// Exactly one push: a repeat for an already-pushed Turn is a no-op, never a
|
|
180
180
|
// second Enter.
|
|
181
181
|
if (expectation.pushed)
|
|
182
182
|
return { outcome: "idempotent", reason: "already-pushed" };
|
|
@@ -209,7 +209,7 @@ export function foldCanonicalLifecycleEvent(event, expectation) {
|
|
|
209
209
|
return { outcome: "idempotent", reason: "already-terminal" };
|
|
210
210
|
if (expectation.accepted)
|
|
211
211
|
return { outcome: "advance-terminal" };
|
|
212
|
-
// A terminal for a pushed-but-unaccepted
|
|
212
|
+
// A terminal for a pushed-but-unaccepted Turn must NOT promote acceptance;
|
|
213
213
|
// hold the immutable fact until (or unless) acceptance folds first.
|
|
214
214
|
if (expectation.pushed)
|
|
215
215
|
return { outcome: "deferred", reason: "terminal-before-accept" };
|
|
@@ -219,13 +219,13 @@ export function foldCanonicalLifecycleEvent(event, expectation) {
|
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
221
|
/**
|
|
222
|
-
* Returns null when the event belongs to the expected generation/
|
|
223
|
-
* mismatch reason otherwise. Owner/adapter and
|
|
222
|
+
* Returns null when the event belongs to the expected generation/Turn, or a
|
|
223
|
+
* mismatch reason otherwise. Owner/adapter and turn-scoped turnId are always
|
|
224
224
|
* compared. Provider-truth phases (acceptance/progress/terminal) require the
|
|
225
225
|
* COMPLETE generation fence — nativeSessionId, launchId, and (for acceptance)
|
|
226
226
|
* receiptId must be present and equal, so a missing or wrong generation/receipt
|
|
227
|
-
* fails closed rather than advancing a
|
|
228
|
-
* is already bound, every
|
|
227
|
+
* fails closed rather than advancing a Turn or its successor. Where a native id
|
|
228
|
+
* is already bound, every turn-scoped fact must match it.
|
|
229
229
|
*/
|
|
230
230
|
function matchesFence(expectation, event) {
|
|
231
231
|
const expected = expectation.fence;
|
|
@@ -239,17 +239,17 @@ function matchesFence(expectation, event) {
|
|
|
239
239
|
return "fence-mismatch:agentId";
|
|
240
240
|
if (expected.adapterId !== actual.adapterId)
|
|
241
241
|
return "fence-mismatch:adapterId";
|
|
242
|
-
//
|
|
243
|
-
if (
|
|
244
|
-
if (expected.
|
|
245
|
-
return "fence-mismatch:expected-
|
|
246
|
-
if (actual.
|
|
247
|
-
return "fence-mismatch:
|
|
242
|
+
// Turn-scoped phases must name the exact expected Turn.
|
|
243
|
+
if (TURN_SCOPED_PHASES.has(phase)) {
|
|
244
|
+
if (expected.turnId === undefined)
|
|
245
|
+
return "fence-mismatch:expected-turn-missing";
|
|
246
|
+
if (actual.turnId !== expected.turnId)
|
|
247
|
+
return "fence-mismatch:turnId";
|
|
248
248
|
}
|
|
249
|
-
else if (actual.
|
|
250
|
-
&& expected.
|
|
251
|
-
&& actual.
|
|
252
|
-
return "fence-mismatch:
|
|
249
|
+
else if (actual.turnId !== undefined
|
|
250
|
+
&& expected.turnId !== undefined
|
|
251
|
+
&& actual.turnId !== expected.turnId) {
|
|
252
|
+
return "fence-mismatch:turnId";
|
|
253
253
|
}
|
|
254
254
|
// Provider-truth phases require the complete, equal generation fence. A
|
|
255
255
|
// provider-accepted event additionally must carry the exact receipt it accepts.
|
|
@@ -315,7 +315,7 @@ function normalizeFence(fence) {
|
|
|
315
315
|
roleName,
|
|
316
316
|
agentId,
|
|
317
317
|
adapterId: fence.adapterId,
|
|
318
|
-
...(fence.
|
|
318
|
+
...(fence.turnId === undefined ? {} : { turnId: requireFenceText(fence.turnId, "turnId") }),
|
|
319
319
|
...(fence.nativeSessionId === undefined
|
|
320
320
|
? {}
|
|
321
321
|
: { nativeSessionId: requireFenceText(fence.nativeSessionId, "nativeSessionId") }),
|