@zq-silk/yui 0.16.1 → 1.0.0-alpha
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 +12 -0
- package/ARCHITECTURE.zh-CN.md +8 -0
- package/README.md +9 -4
- package/dist/agent/agent.js +4 -9
- package/dist/agent/executionComponents.js +4 -4
- package/dist/agent/managedRuntimeEnvironment.js +0 -4
- package/dist/agentRun/agentRun.js +13 -23
- package/dist/artifacts/managedGit.js +3 -56
- package/dist/brief/taskBrief.js +3 -3
- package/dist/cli/agentConfigurationPicker.js +24 -21
- package/dist/cli/commandCatalog.js +18 -10
- package/dist/cli/roleWizard.js +41 -30
- package/dist/cli/updateCommand.js +35 -13
- package/dist/cli/updateOrchestrator.js +73 -44
- package/dist/cli/updatePorts.js +76 -86
- package/dist/cli/upgradeCommand.js +4 -8
- package/dist/cli.js +39 -33
- package/dist/commands/controllerCommands.js +2 -2
- package/dist/commands/executionAuditCommands.js +2 -2
- package/dist/commands/projectCommands.js +1 -1
- package/dist/commands/releaseCommands.js +9 -38
- package/dist/commands/taskCommands.js +91 -81
- package/dist/commands/taskCompletionGate.js +0 -117
- package/dist/commands/taskRoleRuntimeStatus.js +2 -2
- package/dist/commands/taskUpstreamCommands.js +93 -54
- package/dist/context/runContextPack.js +30 -54
- package/dist/context/runInputContract.js +9 -0
- package/dist/context/sessionBootstrapManifest.js +11 -19
- package/dist/controller/agentHostObservation.js +4 -2
- package/dist/controller/agentRuntimeObserver.js +4 -4
- package/dist/controller/clientRuntime.js +19 -44
- package/dist/controller/controller.js +24 -10
- package/dist/controller/fileSchedulerStoreAdapter.js +91 -24
- package/dist/controller/globalInputDelivery.js +31 -8
- package/dist/controller/globalRuntimeAttention.js +34 -0
- package/dist/controller/jobSupervisor.js +3 -3
- package/dist/controller/operatorNotification.js +31 -0
- package/dist/controller/providerRetryAdmission.js +3 -1
- package/dist/controller/providerRetryDelivery.js +136 -119
- package/dist/controller/runtime.js +2 -28
- package/dist/controller/sessionOwnerReconciliation.js +42 -24
- package/dist/controller/structuredProviderObservation.js +28 -1
- package/dist/controller/updateReconciliation.js +72 -20
- package/dist/coordination/workMailbox.js +4 -4
- package/dist/core/controllerIdentity.js +25 -0
- package/dist/core/controllerProcessIdentity.js +2 -2
- package/dist/core/controllerServer.js +4 -2
- package/dist/core/protocol.js +1 -1
- package/dist/doctor/doctor.js +2 -1
- package/dist/domain/validation.js +6 -0
- package/dist/event/taskEvent.js +3 -3
- package/dist/execution/workItemExecution.js +2 -2
- package/dist/executor/agentAdapter.js +28 -96
- package/dist/executor/agentConfigurationCatalog.js +13 -68
- package/dist/executor/agentConfigurationFields.js +120 -0
- package/dist/executor/agentConfigurationProbe.js +55 -80
- package/dist/executor/agentExecutor.js +11 -8
- package/dist/executor/effectiveLaunch.js +3 -3
- package/dist/executor/executorRegistry.js +0 -9
- package/dist/executor/fileRoleLaunchPlanner.js +12 -11
- package/dist/grant/capabilityGrant.js +2 -2
- package/dist/input/inputRequest.js +4 -4
- package/dist/integration/changeSet.js +3 -3
- package/dist/integration/integrationAttempt.js +3 -3
- package/dist/integration/integrationSourceApplication.js +1 -1
- package/dist/interaction/operatorPresentation.js +2 -1
- package/dist/job/durableJob.js +1 -1
- package/dist/job/jobRunner.js +2 -2
- package/dist/message/message.js +8 -6
- package/dist/message/messageContinuation.js +8 -9
- package/dist/milestone/milestone.js +3 -3
- package/dist/observability/executionAudit.js +1 -10
- package/dist/observability/runtimeIdentity.js +0 -23
- package/dist/output/agentConfigurationPresentation.js +4 -2
- package/dist/profile/agentProfile.js +3 -3
- package/dist/release/releaseHandover.js +2 -2
- package/dist/release/releaseIdempotencyStore.js +0 -23
- package/dist/release/releaseWorkflowPorts.js +8 -4
- package/dist/release/runtimeRelease.js +9 -7
- package/dist/repository/gitWorkspace.js +66 -19
- package/dist/repository/project.js +3 -3
- package/dist/repository/taskWorkspacePreparer.js +75 -68
- package/dist/resources/liveReferences.js +1 -1
- package/dist/resources/resourceRegistry.js +90 -44
- package/dist/resources/sqliteResourceRegistry.js +5 -7
- package/dist/review/reviewRound.js +5 -5
- package/dist/role/role.js +7 -8
- package/dist/runtime/acpProtocol.js +2 -3
- package/dist/runtime/acpSession.js +21 -5
- package/dist/runtime/agentDriverObservation.js +1 -1
- package/dist/runtime/agentEndpoint.js +4 -1
- package/dist/runtime/agentHost.js +25 -65
- package/dist/runtime/agentHostCleanup.js +85 -0
- package/dist/runtime/agentHostProtocol.js +3 -3
- package/dist/runtime/builtinAgentDrivers.js +46 -119
- package/dist/runtime/builtinTranscriptObserver.js +10 -6
- package/dist/runtime/codexAppServerRuntime.js +55 -89
- package/dist/runtime/codexInteractiveHost.js +1 -1
- package/dist/runtime/jsonLineChannel.js +35 -7
- package/dist/runtime/launchBroker.js +1 -1
- package/dist/runtime/processExitObservation.js +1 -1
- package/dist/runtime/providerContinuationReconciliationService.js +86 -38
- package/dist/runtime/providerRetry.js +15 -0
- package/dist/runtime/providerRuntimeIdentity.js +3 -3
- package/dist/runtime/providerRuntimeReconciler.js +12 -2
- package/dist/runtime/runtimeCoherence.js +7 -3
- package/dist/runtime/runtimeObservation.js +3 -3
- package/dist/runtime/sessionOwnerIdentity.js +1 -1
- package/dist/runtime/structuredProviderHost.js +106 -81
- package/dist/runtime/taskRuntimeIsolation.js +3 -3
- package/dist/runtime/tmuxAdapters.js +3 -3
- package/dist/scheduler/activeRoleRunDelivery.js +5 -1
- package/dist/scheduler/operatorInputNotificationProcessor.js +7 -17
- package/dist/scheduler/taskWake.js +1 -1
- package/dist/storage/baselineSchema.js +606 -0
- package/dist/storage/homeLayout.js +5 -16
- package/dist/storage/recordValidation.js +16 -4
- package/dist/storage/sqliteSchema.js +106 -1741
- package/dist/storage/sqliteStore.js +16 -14
- package/dist/storage/storageSchema.js +8 -7
- package/dist/storage/storageVersions.js +23 -16
- package/dist/storage/taskStore.js +3 -29
- package/dist/storage/upgrade/upgradeOrchestrator.js +14 -112
- package/dist/task/nextAction.js +33 -23
- package/dist/task/task.js +17 -8
- package/dist/task/taskActivation.js +5 -4
- package/dist/telemetry/sqliteTelemetryStore.js +2 -2
- package/dist/verification/gateArtifact.js +5 -3
- package/dist/verification/verificationPlan.js +6 -7
- package/dist/web/assets/assetManifest.js +2 -0
- package/dist/web/assets/client/app.js +72 -3
- package/dist/web/assets/client/components.js +2 -1
- package/dist/web/assets/client/i18n.js +2 -0
- package/dist/web/assets/client/taskSummary.js +345 -0
- package/dist/web/assets/client/taskSurface.js +44 -26
- package/dist/web/assets/client/view.js +33 -0
- package/dist/web/assets/shell.js +1 -0
- package/dist/web/assets/styles/cards.js +21 -0
- package/dist/web/webServer.js +39 -5
- package/dist/web/webSessions.js +165 -0
- package/dist/web/webSnapshot.js +23 -0
- package/dist/web/webTaskSurface.js +23 -0
- package/dist/workItem/workItem.js +6 -6
- package/dist/workspace/cleanupInspection.js +1 -9
- package/dist/worktree/managedWorkspace.js +3 -3
- package/docs/managed-turn-and-session-runtime.md +50 -7
- package/docs/managed-turn-and-session-runtime.zh-CN.md +36 -5
- package/docs/observability/README.md +47 -0
- package/docs/observability/README.zh-CN.md +37 -0
- package/docs/project-refresh.md +9 -0
- package/docs/project-refresh.zh-CN.md +8 -0
- package/docs/provider-retry.md +35 -0
- package/docs/release-workflow.md +70 -214
- package/docs/release-workflow.zh-CN.md +53 -157
- package/docs/roles-and-configuration.md +30 -0
- package/docs/roles-and-configuration.zh-CN.md +20 -0
- package/docs/sqlite-control-plane-design.md +48 -289
- package/docs/sqlite-control-plane-design.zh-CN.md +37 -53
- package/docs/storage-baseline.md +132 -0
- package/docs/storage-baseline.zh-CN.md +106 -0
- package/docs/task-delivery.md +110 -2
- package/docs/task-delivery.zh-CN.md +82 -2
- package/docs/task-discovery.md +9 -0
- package/docs/task-discovery.zh-CN.md +6 -0
- package/docs/testing/verification-levels.md +42 -164
- package/docs/testing/verification-levels.zh-CN.md +29 -115
- package/i18n/README.zh-CN.md +7 -4
- package/package.json +1 -1
- package/skills/yui-leader/SKILL.md +11 -0
- package/skills/yui-leader/references/execution.md +22 -0
- package/skills/yui-leader/references/planning.md +6 -2
- package/skills/yui-operator/SKILL.md +45 -13
- package/skills/yui-operator/references/task-delivery.md +99 -0
- package/skills/yui-runtime/SKILL.md +5 -3
- package/skills/yui-runtime/references/publication.md +56 -5
- package/skills/yui-runtime/references/recovery.md +12 -2
- package/dist/runtime/agentHostCompatibility.js +0 -127
- package/dist/storage/migrations/agentFailureContext.js +0 -22
- package/dist/storage/migrations/agentRunContract.js +0 -159
- package/dist/storage/migrations/artifactsToGit.js +0 -338
- package/dist/storage/migrations/collapseWorktreeLayout.js +0 -963
- package/dist/storage/migrations/currentInputContract.js +0 -86
- package/dist/storage/migrations/currentRuntimeContract.js +0 -228
- package/dist/storage/migrations/historicalVerificationPlan.js +0 -35
- package/dist/storage/migrations/integrationContinuation.js +0 -105
- package/dist/storage/migrations/narrowAgentFailureContext.js +0 -65
- package/dist/storage/migrations/notificationOnlyWakes.js +0 -74
- package/dist/storage/migrations/removeRuntimeGeneration.js +0 -207
- package/dist/storage/migrations/submitIntent.js +0 -126
- package/dist/storage/migrations/unifyHomeLayout.js +0 -925
- package/dist/storage/migrations/verificationPlanV1.js +0 -162
- package/dist/storage/migrations/verificationPolicy.js +0 -74
- package/dist/storage/migrations/workItemHistory.js +0 -46
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
export function readHistoricalVerificationPlan(raw) {
|
|
2
|
-
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) {
|
|
3
|
-
throw new Error("VerificationPlan must be an object.");
|
|
4
|
-
}
|
|
5
|
-
const record = raw;
|
|
6
|
-
if (record.kind !== "verification-plan")
|
|
7
|
-
throw new Error('VerificationPlan kind must be "verification-plan".');
|
|
8
|
-
if ((record.schemaVersion ?? 1) !== 1)
|
|
9
|
-
throw new Error("VerificationPlan schemaVersion must be 1.");
|
|
10
|
-
const mode = record.mode ?? "record";
|
|
11
|
-
if (mode !== "record" && mode !== "reuse" && mode !== "enforce") {
|
|
12
|
-
throw new Error(`VerificationPlan mode is invalid: ${String(mode)}.`);
|
|
13
|
-
}
|
|
14
|
-
const plan = {
|
|
15
|
-
schemaVersion: 1, kind: "verification-plan",
|
|
16
|
-
id: identity(record.id, "VerificationPlan id"),
|
|
17
|
-
version: text(record.version, "VerificationPlan version"),
|
|
18
|
-
mode,
|
|
19
|
-
toolchain: toolchain(record.toolchain),
|
|
20
|
-
bootstrap: steps(record.bootstrap, "bootstrap"),
|
|
21
|
-
l1: { categories: categories(record.l1) },
|
|
22
|
-
l2: { steps: steps(record.l2?.steps, "l2") },
|
|
23
|
-
...(record.l3 === undefined ? {} : {
|
|
24
|
-
l3: { steps: steps(record.l3?.steps, "l3") }
|
|
25
|
-
}),
|
|
26
|
-
...(record.excludedRealResourceChecks === undefined ? {} : {
|
|
27
|
-
excludedRealResourceChecks: textList(record.excludedRealResourceChecks, "VerificationPlan excludedRealResourceChecks")
|
|
28
|
-
}),
|
|
29
|
-
...(record.artifactTtlDays === undefined ? {} : {
|
|
30
|
-
artifactTtlDays: positive(Number(record.artifactTtlDays), "VerificationPlan artifactTtlDays")
|
|
31
|
-
})
|
|
32
|
-
};
|
|
33
|
-
if (plan.l2.steps.length === 0)
|
|
34
|
-
throw new Error("VerificationPlan l2 requires at least one step.");
|
|
35
|
-
return plan;
|
|
36
|
-
}
|
|
37
|
-
export function resolveHistoricalVerificationPlan(project) {
|
|
38
|
-
let found;
|
|
39
|
-
for (const entry of project.knowledge) {
|
|
40
|
-
if (entry.status !== "active")
|
|
41
|
-
continue;
|
|
42
|
-
let parsed;
|
|
43
|
-
try {
|
|
44
|
-
parsed = JSON.parse(entry.body);
|
|
45
|
-
}
|
|
46
|
-
catch {
|
|
47
|
-
continue;
|
|
48
|
-
}
|
|
49
|
-
if (typeof parsed !== "object" || parsed === null
|
|
50
|
-
|| parsed.kind !== "verification-plan")
|
|
51
|
-
continue;
|
|
52
|
-
const plan = readHistoricalVerificationPlan(parsed);
|
|
53
|
-
if (found !== undefined)
|
|
54
|
-
throw new Error(`Project ${project.id} declares multiple VerificationPlans; only one is allowed.`);
|
|
55
|
-
found = plan;
|
|
56
|
-
}
|
|
57
|
-
return found;
|
|
58
|
-
}
|
|
59
|
-
function toolchain(raw) {
|
|
60
|
-
if (raw === undefined)
|
|
61
|
-
return Object.freeze({});
|
|
62
|
-
if (typeof raw !== "object" || raw === null || Array.isArray(raw))
|
|
63
|
-
throw new Error("VerificationPlan toolchain must be an object.");
|
|
64
|
-
const record = raw;
|
|
65
|
-
return {
|
|
66
|
-
...(record.node === undefined ? {} : { node: text(record.node, "VerificationPlan toolchain node") }),
|
|
67
|
-
...(record.npm === undefined ? {} : { npm: text(record.npm, "VerificationPlan toolchain npm") }),
|
|
68
|
-
...(record.platform === undefined ? {} : { platform: text(record.platform, "VerificationPlan toolchain platform") })
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
function steps(raw, label) {
|
|
72
|
-
if (!Array.isArray(raw))
|
|
73
|
-
throw new Error(`VerificationPlan ${label} steps must be an array.`);
|
|
74
|
-
const names = new Set();
|
|
75
|
-
return Object.freeze(raw.map(entry => {
|
|
76
|
-
if (typeof entry !== "object" || entry === null || Array.isArray(entry))
|
|
77
|
-
throw new Error(`VerificationPlan ${label} step must be an object.`);
|
|
78
|
-
const record = entry;
|
|
79
|
-
const name = identity(record.name, `VerificationPlan ${label} step name`);
|
|
80
|
-
if (names.has(name))
|
|
81
|
-
throw new Error(`VerificationPlan ${label} step names must be unique: ${name}.`);
|
|
82
|
-
names.add(name);
|
|
83
|
-
if (!Array.isArray(record.argv) || record.argv.length === 0) {
|
|
84
|
-
throw new Error(`VerificationPlan ${label} step ${name} requires a non-empty argv.`);
|
|
85
|
-
}
|
|
86
|
-
const step = {
|
|
87
|
-
name, argv: Object.freeze(record.argv.map(value => text(value, `VerificationPlan ${label} step ${name} argv`))),
|
|
88
|
-
...(record.cwd === undefined ? {} : { cwd: text(record.cwd, `VerificationPlan ${label} step ${name} cwd`) }),
|
|
89
|
-
...(record.env === undefined ? {} : { env: stepEnv(record.env, `${label} step ${name}`) }),
|
|
90
|
-
...(record.shell === undefined ? {} : { shell: record.shell === true })
|
|
91
|
-
};
|
|
92
|
-
if (step.cwd?.startsWith("/"))
|
|
93
|
-
throw new Error(`VerificationPlan ${label} step ${name} cwd must be workspace-relative.`);
|
|
94
|
-
return step;
|
|
95
|
-
}));
|
|
96
|
-
}
|
|
97
|
-
function stepEnv(raw, label) {
|
|
98
|
-
if (typeof raw !== "object" || raw === null || Array.isArray(raw))
|
|
99
|
-
throw new Error(`VerificationPlan ${label} env must be a map.`);
|
|
100
|
-
const env = {};
|
|
101
|
-
for (const [key, value] of Object.entries(raw)) {
|
|
102
|
-
if (typeof value !== "string")
|
|
103
|
-
throw new Error(`VerificationPlan ${label} env values must be strings: ${key}.`);
|
|
104
|
-
env[identity(key, `VerificationPlan ${label} env key`)] = value;
|
|
105
|
-
}
|
|
106
|
-
return Object.freeze(env);
|
|
107
|
-
}
|
|
108
|
-
function categories(raw) {
|
|
109
|
-
if (raw === undefined)
|
|
110
|
-
return Object.freeze([]);
|
|
111
|
-
if (typeof raw !== "object" || raw === null || Array.isArray(raw))
|
|
112
|
-
throw new Error("VerificationPlan l1 must be an object.");
|
|
113
|
-
const values = raw.categories;
|
|
114
|
-
if (!Array.isArray(values))
|
|
115
|
-
throw new Error("VerificationPlan l1 categories must be an array.");
|
|
116
|
-
const ids = new Set();
|
|
117
|
-
return Object.freeze(values.map(entry => {
|
|
118
|
-
if (typeof entry !== "object" || entry === null || Array.isArray(entry))
|
|
119
|
-
throw new Error("VerificationPlan l1 category must be an object.");
|
|
120
|
-
const record = entry;
|
|
121
|
-
const id = identity(record.id, "VerificationPlan l1 category id");
|
|
122
|
-
if (ids.has(id))
|
|
123
|
-
throw new Error(`VerificationPlan l1 category ids must be unique: ${id}.`);
|
|
124
|
-
ids.add(id);
|
|
125
|
-
return Object.freeze({
|
|
126
|
-
id, paths: textList(record.paths, `VerificationPlan l1 category ${id} paths`),
|
|
127
|
-
checks: steps(record.checks, `l1 ${id}`)
|
|
128
|
-
});
|
|
129
|
-
}));
|
|
130
|
-
}
|
|
131
|
-
function textList(raw, label) {
|
|
132
|
-
if (!Array.isArray(raw))
|
|
133
|
-
throw new Error(`${label} must be an array.`);
|
|
134
|
-
const seen = new Set();
|
|
135
|
-
return Object.freeze(raw.map(value => {
|
|
136
|
-
const next = text(value, label);
|
|
137
|
-
if (seen.has(next))
|
|
138
|
-
throw new Error(`${label} must be unique: ${next}.`);
|
|
139
|
-
seen.add(next);
|
|
140
|
-
return next;
|
|
141
|
-
}));
|
|
142
|
-
}
|
|
143
|
-
function text(value, label) {
|
|
144
|
-
if (typeof value !== "string" || value.includes("\0"))
|
|
145
|
-
throw new Error(`${label} is invalid.`);
|
|
146
|
-
const normalized = value.trim();
|
|
147
|
-
if (normalized.length === 0)
|
|
148
|
-
throw new Error(`${label} is required.`);
|
|
149
|
-
return normalized;
|
|
150
|
-
}
|
|
151
|
-
function identity(value, label) {
|
|
152
|
-
const normalized = text(value, label);
|
|
153
|
-
if ([".", "..", "__proto__", "prototype", "constructor"].includes(normalized) || /[\/\\\0]/u.test(normalized)) {
|
|
154
|
-
throw new Error(`${label} is invalid.`);
|
|
155
|
-
}
|
|
156
|
-
return normalized;
|
|
157
|
-
}
|
|
158
|
-
function positive(value, label) {
|
|
159
|
-
if (!Number.isSafeInteger(value) || value < 1)
|
|
160
|
-
throw new Error(`${label} must be a positive integer.`);
|
|
161
|
-
return value;
|
|
162
|
-
}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { resolveHistoricalVerificationPlan } from "./verificationPlanV1.js";
|
|
2
|
-
/** Read-only: an admitted old gate keeps its original plan identity until it
|
|
3
|
-
* settles. The cutover never relabels a running Job or replays its checks. */
|
|
4
|
-
export function preflightVerificationPolicy(db) {
|
|
5
|
-
const active = db.prepare(`SELECT task_id, integration_id FROM integration_attempts
|
|
6
|
-
WHERE status IN ('running','validating')
|
|
7
|
-
AND json_type(payload,'$.gatePlanDigest') IS NOT NULL LIMIT 1`)
|
|
8
|
-
.get();
|
|
9
|
-
if (active !== undefined) {
|
|
10
|
-
throw new Error(`Verification policy cutover requires the admitted gate to settle: ${active.task_id}/${active.integration_id}. Preserve its Job and continue it with the current release before upgrading.`);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
/** Frozen 32→33 policy cutover. Only declared configuration representations
|
|
14
|
-
* change; old execution artifacts/Job results and their logs remain evidence. */
|
|
15
|
-
export function migrateVerificationPolicy(db) {
|
|
16
|
-
preflightVerificationPolicy(db);
|
|
17
|
-
const configRow = db.prepare("SELECT payload FROM config WHERE id=1").get();
|
|
18
|
-
if (configRow !== undefined) {
|
|
19
|
-
const config = JSON.parse(configRow.payload);
|
|
20
|
-
const mode = config.leaderNextActionMode;
|
|
21
|
-
const budget = config.leaderSemanticBudgetRuns;
|
|
22
|
-
if ((mode != null && (typeof mode !== "string"
|
|
23
|
-
|| !["", "display", "warn", "enforce"].includes(mode.trim().toLowerCase())))
|
|
24
|
-
|| (budget != null && (!Number.isSafeInteger(budget) || budget < 1 || budget > 20))) {
|
|
25
|
-
throw new Error("Invalid retired Leader policy; preserve the config for diagnosis.");
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
const projects = db.prepare("SELECT id,payload FROM projects").all();
|
|
29
|
-
const saveProject = db.prepare("UPDATE projects SET payload=? WHERE id=?");
|
|
30
|
-
for (const row of projects) {
|
|
31
|
-
const project = JSON.parse(row.payload);
|
|
32
|
-
// This frozen reader preserves validation and duplicate-plan rejection.
|
|
33
|
-
resolveHistoricalVerificationPlan(project);
|
|
34
|
-
let changed = false;
|
|
35
|
-
const knowledge = project.knowledge.map(entry => {
|
|
36
|
-
if (entry.status !== "active")
|
|
37
|
-
return entry;
|
|
38
|
-
let value;
|
|
39
|
-
try {
|
|
40
|
-
value = JSON.parse(entry.body);
|
|
41
|
-
}
|
|
42
|
-
catch {
|
|
43
|
-
return entry;
|
|
44
|
-
}
|
|
45
|
-
if (typeof value !== "object" || value === null
|
|
46
|
-
|| value.kind !== "verification-plan")
|
|
47
|
-
return entry;
|
|
48
|
-
const { mode: _mode, ...plan } = value;
|
|
49
|
-
changed = true;
|
|
50
|
-
return { ...entry, body: JSON.stringify({ ...plan, schemaVersion: 1 }) };
|
|
51
|
-
});
|
|
52
|
-
if (changed)
|
|
53
|
-
saveProject.run(JSON.stringify({ ...project, knowledge }), row.id);
|
|
54
|
-
}
|
|
55
|
-
const invalidRerun = db.prepare(`SELECT task_id,integration_id FROM integration_attempts
|
|
56
|
-
WHERE json_type(payload,'$.rerunChecks') IS NOT NULL
|
|
57
|
-
AND json_type(payload,'$.rerunChecks') NOT IN ('true','false') LIMIT 1`).get();
|
|
58
|
-
if (invalidRerun !== undefined)
|
|
59
|
-
throw new Error("Invalid Integration check execution intent; preserve the record.");
|
|
60
|
-
const artifacts = db.prepare(`SELECT key,payload FROM gate_artifacts
|
|
61
|
-
WHERE json_type(payload,'$.potentialReuseCount') IS NOT NULL`).all();
|
|
62
|
-
for (const artifact of artifacts) {
|
|
63
|
-
const count = JSON.parse(artifact.payload).potentialReuseCount;
|
|
64
|
-
if (!Number.isSafeInteger(count) || count < 0) {
|
|
65
|
-
throw new Error(`Invalid historical verification counter: ${artifact.key}. Preserve the artifact for diagnosis.`);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
db.exec(`
|
|
69
|
-
UPDATE config SET payload=json_remove(payload,'$.leaderNextActionMode','$.leaderSemanticBudgetRuns');
|
|
70
|
-
UPDATE integration_attempts SET payload=json_set(payload,'$.rerunChecks',json('false'))
|
|
71
|
-
WHERE json_type(payload,'$.rerunChecks') IS NULL;
|
|
72
|
-
UPDATE gate_artifacts SET payload=json_remove(payload,'$.potentialReuseCount');
|
|
73
|
-
`);
|
|
74
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/** Frozen 31→32 transform: obsolete execution-shaped diagnostics are audit
|
|
2
|
-
* records, not another representation of current WorkItem state. */
|
|
3
|
-
export function migrateWorkItemHistory(db) {
|
|
4
|
-
const rows = db.prepare(`SELECT task_id, work_item_id, payload FROM work_items
|
|
5
|
-
WHERE json_type(payload, '$.historicalState') IS NOT NULL
|
|
6
|
-
ORDER BY task_id, work_item_id`).all();
|
|
7
|
-
for (const row of rows) {
|
|
8
|
-
const value = JSON.parse(row.payload);
|
|
9
|
-
const history = value.historicalState;
|
|
10
|
-
if (value.taskId !== row.task_id || value.id !== row.work_item_id
|
|
11
|
-
|| history === null || typeof history !== "object" || Array.isArray(history)
|
|
12
|
-
|| !["pending", "running", "awaiting_acceptance", "completed", "failed", "retired"].includes(history.status)
|
|
13
|
-
|| (history.outcome !== undefined && !text(history.outcome))
|
|
14
|
-
|| (history.endedAt !== undefined
|
|
15
|
-
&& (!text(history.endedAt) || !Number.isFinite(Date.parse(history.endedAt))))) {
|
|
16
|
-
throw new Error(`Invalid historical WorkItem execution state: ${row.task_id}/${row.work_item_id}. Preserve it for diagnosis.`);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
const highWater = db.prepare(`SELECT max(
|
|
20
|
-
coalesce((SELECT high_water FROM id_sequences WHERE task_id = ? AND kind = 'event'), 0),
|
|
21
|
-
coalesce((SELECT max(CAST(substr(event_id, 7) AS INTEGER)) FROM events WHERE task_id = ?), 0)
|
|
22
|
-
) AS value`);
|
|
23
|
-
const saveEvent = db.prepare("INSERT INTO events(task_id,event_id,type,occurred_at,payload) VALUES(?,?,?,?,?)");
|
|
24
|
-
const saveCounter = db.prepare(`INSERT INTO id_sequences(task_id,kind,high_water) VALUES(?,'event',?)
|
|
25
|
-
ON CONFLICT(task_id,kind) DO UPDATE SET high_water=max(high_water,excluded.high_water)`);
|
|
26
|
-
const removeHistoricalState = db.prepare(`UPDATE work_items SET payload=json_remove(payload,'$.historicalState')
|
|
27
|
-
WHERE task_id=? AND work_item_id=?`);
|
|
28
|
-
const counters = new Map();
|
|
29
|
-
const at = new Date().toISOString();
|
|
30
|
-
for (const row of rows) {
|
|
31
|
-
const sequence = (counters.get(row.task_id)
|
|
32
|
-
?? highWater.get(row.task_id, row.task_id).value) + 1;
|
|
33
|
-
counters.set(row.task_id, sequence);
|
|
34
|
-
const event = {
|
|
35
|
-
schemaVersion: 2, id: `event-${sequence}`, taskId: row.task_id,
|
|
36
|
-
type: "work-item.execution-state-retired", createdAt: at,
|
|
37
|
-
payload: { workItemId: row.work_item_id, record: row.payload, disposition: "audit-only" }
|
|
38
|
-
};
|
|
39
|
-
saveEvent.run(row.task_id, event.id, event.type, at, JSON.stringify(event));
|
|
40
|
-
saveCounter.run(row.task_id, sequence);
|
|
41
|
-
removeHistoricalState.run(row.task_id, row.work_item_id);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
function text(value) {
|
|
45
|
-
return typeof value === "string" && value.trim().length > 0 && !value.includes("\0");
|
|
46
|
-
}
|