@zq-silk/yui 0.6.0 → 0.6.2

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.
Files changed (150) hide show
  1. package/README.md +5 -5
  2. package/dist/agent/managedRuntimeEnvironment.js +2 -1
  3. package/dist/cli/commandCatalog.js +251 -13
  4. package/dist/cli/updateOrchestrator.js +8 -0
  5. package/dist/cli/updatePorts.js +76 -22
  6. package/dist/cli.js +264 -20
  7. package/dist/commands/configCommands.js +83 -9
  8. package/dist/commands/controllerCommands.js +103 -0
  9. package/dist/commands/deliveryGuardPreflight.js +30 -0
  10. package/dist/commands/durableJobCommands.js +231 -0
  11. package/dist/commands/executionAuditCommands.js +193 -0
  12. package/dist/commands/grantCommands.js +374 -0
  13. package/dist/commands/projectCommands.js +119 -81
  14. package/dist/commands/releaseCommands.js +444 -0
  15. package/dist/commands/resourcesCommands.js +274 -0
  16. package/dist/commands/sessionCommands.js +104 -0
  17. package/dist/commands/taskActor.js +117 -0
  18. package/dist/commands/taskChangeSetCommands.js +60 -0
  19. package/dist/commands/taskCommands.js +618 -202
  20. package/dist/commands/taskCompletionGate.js +78 -1
  21. package/dist/commands/taskContextCommand.js +33 -6
  22. package/dist/commands/taskInputCommands.js +1 -1
  23. package/dist/commands/taskIntegrationCommands.js +136 -33
  24. package/dist/commands/taskIntegrationQueueCommands.js +228 -0
  25. package/dist/commands/taskNextActionCommand.js +100 -0
  26. package/dist/commands/taskOverlapCommands.js +120 -0
  27. package/dist/commands/taskOverviewCommand.js +36 -8
  28. package/dist/commands/telemetryCommands.js +330 -0
  29. package/dist/commands/workflowCommands.js +415 -0
  30. package/dist/config/yuiConfig.js +62 -0
  31. package/dist/controller/clientRuntime.js +42 -1
  32. package/dist/controller/controller.js +402 -56
  33. package/dist/controller/controllerMain.js +25 -2
  34. package/dist/controller/domainIdentity.js +16 -8
  35. package/dist/controller/fileSchedulerStoreAdapter.js +423 -31
  36. package/dist/controller/handoverCandidate.js +168 -0
  37. package/dist/controller/jobClient.js +102 -0
  38. package/dist/controller/jobControl.js +613 -0
  39. package/dist/controller/jobSupervisor.js +498 -0
  40. package/dist/controller/providerHookRunFence.js +34 -5
  41. package/dist/controller/resourceCleanupLinux.js +18 -9
  42. package/dist/controller/resourceInventoryLinux.js +90 -39
  43. package/dist/controller/runtime.js +165 -15
  44. package/dist/controller/runtimeEventInbox.js +234 -57
  45. package/dist/controller/runtimeEventProcessor.js +297 -58
  46. package/dist/controller/sessionOwnerReconciliation.js +321 -0
  47. package/dist/core/controllerServer.js +416 -27
  48. package/dist/core/controllerTelemetry.js +167 -0
  49. package/dist/doctor/doctor.js +113 -16
  50. package/dist/domain/validation.js +9 -0
  51. package/dist/execution/executionGroup.js +40 -3
  52. package/dist/executor/agentExecutor.js +6 -3
  53. package/dist/executor/effectiveLaunch.js +52 -0
  54. package/dist/executor/executorRegistry.js +50 -0
  55. package/dist/executor/fileRoleLaunchPlanner.js +61 -6
  56. package/dist/grant/capabilityGrant.js +282 -0
  57. package/dist/integration/changeSet.js +16 -3
  58. package/dist/integration/changeSetManifest.js +46 -0
  59. package/dist/integration/gitIntegrationService.js +528 -147
  60. package/dist/integration/integrationAttempt.js +54 -5
  61. package/dist/integration/integrationQueueEntry.js +221 -0
  62. package/dist/integration/integrationQueueService.js +955 -0
  63. package/dist/integration/manifestTags.js +99 -0
  64. package/dist/integration/overlapDiagnostics.js +211 -0
  65. package/dist/job/durableJob.js +449 -0
  66. package/dist/job/jobRunner.js +350 -0
  67. package/dist/lifecycle/exactRunTerminalization.js +24 -2
  68. package/dist/lifecycle/providerErrorClass.js +126 -0
  69. package/dist/message/message.js +16 -3
  70. package/dist/observability/executionAudit.js +545 -0
  71. package/dist/observability/faultClassification.js +160 -0
  72. package/dist/observability/runtimeIdentity.js +367 -0
  73. package/dist/release/fakeReleasePorts.js +55 -0
  74. package/dist/release/releaseHandover.js +475 -0
  75. package/dist/release/releaseIdempotencyStore.js +165 -0
  76. package/dist/release/releaseWorkflow.js +459 -0
  77. package/dist/release/releaseWorkflowEngine.js +688 -0
  78. package/dist/release/releaseWorkflowPorts.js +1720 -0
  79. package/dist/release/runtimeRelease.js +495 -0
  80. package/dist/release/workflowFileLock.js +218 -0
  81. package/dist/repository/gitWorkspace.js +177 -1
  82. package/dist/repository/projectMaintenanceLock.js +315 -0
  83. package/dist/repository/taskWorkspaceCoordinator.js +87 -17
  84. package/dist/repository/taskWorkspacePreparer.js +1091 -517
  85. package/dist/resources/autoResourceGc.js +116 -0
  86. package/dist/resources/liveReferences.js +574 -0
  87. package/dist/resources/resourceDiscovery.js +477 -0
  88. package/dist/resources/resourceGc.js +645 -0
  89. package/dist/resources/resourceRegistrar.js +256 -0
  90. package/dist/resources/resourceRegistry.js +150 -0
  91. package/dist/resources/resourceRegistryStore.js +41 -0
  92. package/dist/resources/resourceTypes.js +42 -0
  93. package/dist/resources/sqliteResourceRegistry.js +111 -0
  94. package/dist/review/reviewConfig.js +10 -0
  95. package/dist/review/reviewFinding.js +240 -0
  96. package/dist/review/reviewFindingLedger.js +545 -0
  97. package/dist/review/reviewOutcomeClassifier.js +61 -0
  98. package/dist/review/reviewRound.js +56 -4
  99. package/dist/run/agentRun.js +80 -4
  100. package/dist/run/providerRetry.js +84 -0
  101. package/dist/run/providerRetryConfig.js +63 -0
  102. package/dist/run/yieldReceipt.js +65 -0
  103. package/dist/runtime/exactControlPlane.js +79 -2
  104. package/dist/runtime/index.js +4 -0
  105. package/dist/runtime/sessionOwnerIdentity.js +269 -0
  106. package/dist/runtime/sessionOwnerRegistry.js +132 -0
  107. package/dist/runtime/sessionReconciliation.js +93 -0
  108. package/dist/runtime/sessionTerminationGuard.js +211 -0
  109. package/dist/runtime/taskRuntimeIsolation.js +13 -0
  110. package/dist/runtime/tmuxAdapters.js +34 -1
  111. package/dist/scheduler/actionability.js +155 -0
  112. package/dist/scheduler/activeRoleRunDelivery.js +14 -5
  113. package/dist/scheduler/activeTaskProgress.js +60 -0
  114. package/dist/scheduler/leaderWakeupProcessor.js +22 -11
  115. package/dist/scheduler/roleRunStall.js +135 -29
  116. package/dist/scheduler/taskExecutionProjection.js +11 -0
  117. package/dist/storage/compatibleTaskStore.js +112 -5
  118. package/dist/storage/migration/productionRegistry.js +736 -1
  119. package/dist/storage/sqliteSchema.js +264 -3
  120. package/dist/storage/sqliteStore.js +487 -13
  121. package/dist/storage/storeRpc.js +21 -0
  122. package/dist/storage/taskStore.js +974 -21
  123. package/dist/storage/upgrade/homeClassification.js +120 -2
  124. package/dist/storage/upgrade/migrationReceipt.js +67 -0
  125. package/dist/storage/upgrade/pseudoLayoutRepair.js +241 -0
  126. package/dist/storage/upgrade/recordVersions.js +10 -1
  127. package/dist/storage/upgrade/sqliteMigrationTarget.js +58 -6
  128. package/dist/storage/upgrade/sqliteRecordMigrationTarget.js +290 -0
  129. package/dist/storage/upgrade/sqliteStateMigration.js +258 -2
  130. package/dist/storage/upgrade/upgradeOrchestrator.js +482 -16
  131. package/dist/task/deliveryGuard.js +226 -0
  132. package/dist/task/nextAction.js +738 -0
  133. package/dist/task/repairWave.js +137 -0
  134. package/dist/task/taskRecordReference.js +6 -1
  135. package/dist/telemetry/sqliteTelemetryStore.js +387 -0
  136. package/dist/telemetry/telemetryCompaction.js +251 -0
  137. package/dist/telemetry/telemetryConfig.js +64 -0
  138. package/dist/telemetry/telemetryRouter.js +32 -0
  139. package/dist/telemetry/telemetryStore.js +19 -0
  140. package/dist/telemetry/telemetryWiring.js +33 -0
  141. package/dist/tmux/tmuxManager.js +20 -1
  142. package/dist/tmux/tmuxSocketEndpoint.js +20 -0
  143. package/dist/verification/gateArtifact.js +216 -0
  144. package/dist/verification/gateArtifactStore.js +87 -0
  145. package/dist/verification/verificationGateService.js +414 -0
  146. package/dist/verification/verificationPlan.js +308 -0
  147. package/dist/workspace/gitChangeSetCapture.js +12 -2
  148. package/dist/workspace/workItemChangeSetManager.js +60 -3
  149. package/package.json +1 -1
  150. package/skills/yui-leader/SKILL.md +8 -0
@@ -0,0 +1,99 @@
1
+ /**
2
+ * Derive semantic tags from a ChangeSet's changed paths.
3
+ *
4
+ * The heuristics are intentionally project-agnostic: they classify by path
5
+ * shape so any repository gets useful overlap diagnostics without declaring
6
+ * its file list up front. The result is sorted and deduplicated.
7
+ */
8
+ export function deriveManifestTags(input) {
9
+ const tags = new Set();
10
+ for (const path of input.changedPaths) {
11
+ for (const tag of manifestTagsForPath(path))
12
+ tags.add(tag);
13
+ }
14
+ if (input.deletedPaths !== undefined && input.deletedPaths.length > 0) {
15
+ tags.add("deletion");
16
+ }
17
+ return CHANGE_SET_TAG_ORDER.filter((tag) => tags.has(tag));
18
+ }
19
+ const CHANGE_SET_TAG_ORDER = [
20
+ "contract",
21
+ "schema",
22
+ "migration",
23
+ "command",
24
+ "test",
25
+ "snapshot",
26
+ "package",
27
+ "deletion"
28
+ ];
29
+ /**
30
+ * Classify a single changed path by every semantic tag it matches. Overlap
31
+ * diagnostics use this to attribute shared paths to a finding category.
32
+ */
33
+ export function manifestTagsForPath(path) {
34
+ const normalized = path.split("\\").join("/");
35
+ const segments = normalized.split("/");
36
+ const file = segments.at(-1) ?? normalized;
37
+ const lower = normalized.toLowerCase();
38
+ const lowerFile = file.toLowerCase();
39
+ const tags = [];
40
+ if (isPackageFile(lower, lowerFile))
41
+ tags.push("package");
42
+ if (isMigrationPath(lower, segments))
43
+ tags.push("migration");
44
+ if (isSchemaPath(lower, lowerFile))
45
+ tags.push("schema");
46
+ if (isSnapshotPath(lower, lowerFile))
47
+ tags.push("snapshot");
48
+ if (isCommandPath(lower, segments, lowerFile))
49
+ tags.push("command");
50
+ if (isContractPath(lower, segments, lowerFile))
51
+ tags.push("contract");
52
+ if (isTestPath(lower, segments, lowerFile))
53
+ tags.push("test");
54
+ return tags;
55
+ }
56
+ function isPackageFile(lowerPath, lowerFile) {
57
+ return lowerFile === "package.json"
58
+ || lowerFile === "package-lock.json"
59
+ || lowerPath.endsWith("/package.json")
60
+ || lowerPath.endsWith("/package-lock.json");
61
+ }
62
+ function isMigrationPath(lowerPath, segments) {
63
+ return segments.some((segment) => segment === "migration" || segment === "migrations")
64
+ || /(?:^|\/)migrations?\//u.test(lowerPath);
65
+ }
66
+ function isSchemaPath(lowerPath, lowerFile) {
67
+ return lowerFile.includes("schema")
68
+ || lowerPath.includes("/schema/")
69
+ || lowerPath.includes("/schemas/");
70
+ }
71
+ function isSnapshotPath(lowerPath, lowerFile) {
72
+ return lowerPath.includes("/__snapshots__/")
73
+ || lowerFile.endsWith(".snap");
74
+ }
75
+ function isCommandPath(lowerPath, segments, lowerFile) {
76
+ return segments.includes("commands")
77
+ || lowerFile.startsWith("cli")
78
+ || lowerPath.includes("/bin/");
79
+ }
80
+ function isContractPath(lowerPath, segments, lowerFile) {
81
+ return lowerFile === "index.ts"
82
+ || lowerFile === "index.js"
83
+ || lowerFile === "index.mjs"
84
+ || lowerFile.endsWith(".d.ts")
85
+ || lowerFile.startsWith("protocol")
86
+ || lowerPath.includes("/api/")
87
+ || lowerPath.includes("/contract/")
88
+ || lowerPath.includes("/contracts/");
89
+ }
90
+ function isTestPath(lowerPath, segments, lowerFile) {
91
+ if (segments.includes("test") || segments.includes("tests") || segments.includes("__tests__")) {
92
+ return true;
93
+ }
94
+ return /(?:^|\/)[^/]+\.(?:test|spec)\.[^/]+$/u.test(lowerFile)
95
+ || lowerFile.endsWith(".test.js")
96
+ || lowerFile.endsWith(".test.ts")
97
+ || lowerFile.endsWith(".spec.js")
98
+ || lowerFile.endsWith(".spec.ts");
99
+ }
@@ -0,0 +1,211 @@
1
+ import { manifestTagsForPath } from "./manifestTags.js";
2
+ import { formatTaskRecordReference } from "../task/taskRecordReference.js";
3
+ /**
4
+ * Qualified Task record reference for a subject's ChangeSet. A bare
5
+ * `changeSetId` is only unique within its Task, so cross-Task findings and
6
+ * ordering key subjects by `taskId/changeSetId`.
7
+ */
8
+ export function overlapSubjectKey(subject) {
9
+ return formatTaskRecordReference(subject.taskId, subject.changeSetId, "changeSet");
10
+ }
11
+ export const OVERLAP_FINDING_KINDS = [
12
+ "path-only",
13
+ "contract",
14
+ "schema-migration",
15
+ "cli-surface",
16
+ "package-version",
17
+ "high-risk-deletion"
18
+ ];
19
+ export function overlapSubjectFromChangeSet(changeSet) {
20
+ return {
21
+ taskId: changeSet.taskId,
22
+ workItemId: changeSet.workItemId,
23
+ projectId: changeSet.projectId,
24
+ changeSetId: changeSet.id,
25
+ baseCommit: changeSet.baseCommit,
26
+ headCommit: changeSet.headCommit,
27
+ changedPaths: changeSet.changedPaths,
28
+ manifestTags: changeSet.manifest?.tags ?? [],
29
+ deletedPaths: changeSet.manifest?.deletedPaths ?? []
30
+ };
31
+ }
32
+ /**
33
+ * Diagnose pairwise overlap between ChangeSets of the same Project.
34
+ * Subjects of different Projects never overlap (a Project is the integration
35
+ * boundary), and a pair may produce several findings when their shared paths
36
+ * span categories.
37
+ */
38
+ export function diagnoseOverlap(subjects) {
39
+ const sortedSubjects = [...subjects].sort(compareSubjects);
40
+ const findings = [];
41
+ for (let index = 0; index < sortedSubjects.length; index += 1) {
42
+ for (let other = index + 1; other < sortedSubjects.length; other += 1) {
43
+ const left = sortedSubjects[index];
44
+ const right = sortedSubjects[other];
45
+ if (left.projectId !== right.projectId)
46
+ continue;
47
+ findings.push(...pairFindings(left, right));
48
+ }
49
+ }
50
+ findings.sort(compareFindings);
51
+ return {
52
+ subjects: sortedSubjects,
53
+ findings,
54
+ suggestedOrder: suggestedOrder(sortedSubjects, findings),
55
+ reviewAreas: reviewAreas(findings)
56
+ };
57
+ }
58
+ function pairFindings(left, right) {
59
+ const shared = sortedIntersection(left.changedPaths, right.changedPaths);
60
+ if (shared.length === 0)
61
+ return [];
62
+ const pair = [overlapSubjectKey(left), overlapSubjectKey(right)].sort();
63
+ const findings = [];
64
+ // Deletions that touch paths the other side still changes are the highest
65
+ // risk: one side removes what the other side builds on. The trigger is the
66
+ // real deleted-path overlap itself; requiring both sides to carry the
67
+ // deletion tag would miss the ordinary delete-vs-modify case, where only
68
+ // the deleting side can record the deletion.
69
+ const deletedVsOther = sortedIntersection(left.deletedPaths, right.changedPaths)
70
+ .concat(sortedIntersection(right.deletedPaths, left.changedPaths));
71
+ const deletedOverlap = [...new Set(deletedVsOther)].sort();
72
+ if (deletedOverlap.length > 0) {
73
+ findings.push({
74
+ kind: "high-risk-deletion",
75
+ risk: "high",
76
+ changeSetIds: pair,
77
+ paths: deletedOverlap,
78
+ detail: "One ChangeSet deletes paths the other still changes; reconcile deletion intent before integration."
79
+ });
80
+ }
81
+ const schemaPaths = shared.filter((path) => manifestTagsForPath(path).some((tag) => tag === "schema" || tag === "migration"));
82
+ if (bothTagged(left, right, "schema") || bothTagged(left, right, "migration")) {
83
+ if (schemaPaths.length > 0) {
84
+ const bothMigration = hasTag(left, "migration") && hasTag(right, "migration");
85
+ findings.push({
86
+ kind: "schema-migration",
87
+ risk: bothMigration ? "high" : "medium",
88
+ changeSetIds: pair,
89
+ paths: schemaPaths,
90
+ detail: bothMigration
91
+ ? "Both ChangeSets add migrations; their sequence must be reviewed to keep the migration order linear."
92
+ : "Both ChangeSets touch schema or migration code; review the schema evolution order."
93
+ });
94
+ }
95
+ }
96
+ const contractPaths = shared.filter((path) => manifestTagsForPath(path).includes("contract"));
97
+ if (bothTagged(left, right, "contract") && contractPaths.length > 0) {
98
+ findings.push({
99
+ kind: "contract",
100
+ risk: "high",
101
+ changeSetIds: pair,
102
+ paths: contractPaths,
103
+ detail: "Both ChangeSets modify the same public contract; review API compatibility before integration."
104
+ });
105
+ }
106
+ const cliPaths = shared.filter((path) => manifestTagsForPath(path).some((tag) => tag === "command" || tag === "snapshot"));
107
+ const bothCli = (hasTag(left, "command") || hasTag(left, "snapshot"))
108
+ && (hasTag(right, "command") || hasTag(right, "snapshot"));
109
+ if (bothCli && cliPaths.length > 0) {
110
+ findings.push({
111
+ kind: "cli-surface",
112
+ risk: "medium",
113
+ changeSetIds: pair,
114
+ paths: cliPaths,
115
+ detail: "Both ChangeSets touch the CLI surface or its snapshots; review the combined command behavior."
116
+ });
117
+ }
118
+ const packagePaths = shared.filter((path) => manifestTagsForPath(path).includes("package"));
119
+ if (bothTagged(left, right, "package") && packagePaths.length > 0) {
120
+ findings.push({
121
+ kind: "package-version",
122
+ risk: "medium",
123
+ changeSetIds: pair,
124
+ paths: packagePaths,
125
+ detail: "Both ChangeSets modify package metadata; review the merged version and dependency set."
126
+ });
127
+ }
128
+ // Everything else that still shares paths is a plain text overlap: likely
129
+ // to conflict on apply, but with no declared semantic surface at stake.
130
+ const claimed = new Set(findings.flatMap((finding) => finding.paths));
131
+ const remaining = shared.filter((path) => !claimed.has(path));
132
+ if (remaining.length > 0) {
133
+ findings.push({
134
+ kind: "path-only",
135
+ risk: "low",
136
+ changeSetIds: pair,
137
+ paths: remaining,
138
+ detail: "Changed paths overlap without a shared semantic tag; expect a text conflict resolved by Git."
139
+ });
140
+ }
141
+ return findings;
142
+ }
143
+ /**
144
+ * Suggested integration order:
145
+ * 1. schema/migration-bearing ChangeSets first (they define the sequence
146
+ * everything else builds on),
147
+ * 2. then subjects by ascending high-risk finding count,
148
+ * 3. then by qualified ChangeSet reference for a deterministic order.
149
+ */
150
+ function suggestedOrder(subjects, findings) {
151
+ const highRiskCount = new Map();
152
+ for (const finding of findings) {
153
+ if (finding.risk !== "high")
154
+ continue;
155
+ for (const ref of finding.changeSetIds) {
156
+ highRiskCount.set(ref, (highRiskCount.get(ref) ?? 0) + 1);
157
+ }
158
+ }
159
+ return [...subjects]
160
+ .sort((left, right) => {
161
+ const leftSchema = carriesSchemaOrMigration(left) ? 0 : 1;
162
+ const rightSchema = carriesSchemaOrMigration(right) ? 0 : 1;
163
+ if (leftSchema !== rightSchema)
164
+ return leftSchema - rightSchema;
165
+ const leftRisk = highRiskCount.get(overlapSubjectKey(left)) ?? 0;
166
+ const rightRisk = highRiskCount.get(overlapSubjectKey(right)) ?? 0;
167
+ if (leftRisk !== rightRisk)
168
+ return leftRisk - rightRisk;
169
+ return compareSubjects(left, right);
170
+ })
171
+ .map((subject) => overlapSubjectKey(subject));
172
+ }
173
+ const REVIEW_AREA_LABELS = {
174
+ "path-only": "path overlap (low): text conflicts resolved by Git",
175
+ contract: "public contract (high): API compatibility",
176
+ "schema-migration": "schema/migration (high/medium): migration sequence and schema evolution",
177
+ "cli-surface": "CLI surface (medium): combined command behavior and snapshots",
178
+ "package-version": "package metadata (medium): merged version and dependencies",
179
+ "high-risk-deletion": "high-risk deletion (high): deletion intent across Tasks"
180
+ };
181
+ function reviewAreas(findings) {
182
+ const kinds = new Set();
183
+ for (const finding of findings) {
184
+ if (finding.risk === "high" || finding.risk === "medium")
185
+ kinds.add(finding.kind);
186
+ }
187
+ return OVERLAP_FINDING_KINDS.filter((kind) => kinds.has(kind))
188
+ .map((kind) => REVIEW_AREA_LABELS[kind]);
189
+ }
190
+ function carriesSchemaOrMigration(subject) {
191
+ return hasTag(subject, "schema") || hasTag(subject, "migration");
192
+ }
193
+ function hasTag(subject, tag) {
194
+ return subject.manifestTags.includes(tag);
195
+ }
196
+ function bothTagged(left, right, tag) {
197
+ return hasTag(left, tag) && hasTag(right, tag);
198
+ }
199
+ function sortedIntersection(left, right) {
200
+ const other = new Set(right);
201
+ return [...new Set(left.filter((path) => other.has(path)))].sort();
202
+ }
203
+ function compareSubjects(left, right) {
204
+ return overlapSubjectKey(left).localeCompare(overlapSubjectKey(right));
205
+ }
206
+ function compareFindings(left, right) {
207
+ const kind = left.kind.localeCompare(right.kind);
208
+ if (kind !== 0)
209
+ return kind;
210
+ return left.changeSetIds.join(",").localeCompare(right.changeSetIds.join(","));
211
+ }