pi-harness-runtime 1.1.350 → 1.1.352
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/README.md +3 -0
- package/index.ts +32 -23
- package/package.json +1 -1
- package/packages/a2a-adapter/package.json +1 -1
- package/packages/agent-policy/package.json +1 -1
- package/packages/architecture-generator/package.json +1 -1
- package/packages/auth/package.json +1 -1
- package/packages/autonomous-refactor/package.json +1 -1
- package/packages/autonomous-runtime/package.json +1 -1
- package/packages/cache-strategy/package.json +1 -1
- package/packages/capability-registry/package.json +1 -1
- package/packages/checkpoint/package.json +1 -1
- package/packages/cli-plugin-sdk/package.json +1 -1
- package/packages/clipboard/package.json +1 -1
- package/packages/clipboard-plugin/package.json +1 -1
- package/packages/code-generation/package.json +1 -1
- package/packages/code-review/package.json +1 -1
- package/packages/codex-adapter/package.json +1 -1
- package/packages/codex-watcher/package.json +1 -1
- package/packages/config-capture/package.json +1 -1
- package/packages/connection-runtime/package.json +1 -1
- package/packages/context-compiler/package.json +1 -1
- package/packages/context-discovery/package.json +1 -1
- package/packages/context-manager/package.json +1 -1
- package/packages/contracts/dist/delegation-store.d.ts +35 -0
- package/packages/contracts/dist/delegation-store.js +172 -0
- package/packages/contracts/dist/index.d.ts +2 -0
- package/packages/contracts/dist/index.js +2 -0
- package/packages/contracts/dist/work-partitioner.d.ts +57 -0
- package/packages/contracts/dist/work-partitioner.js +165 -0
- package/packages/contracts/package.json +1 -1
- package/packages/contracts/src/delegation-store.ts +204 -0
- package/packages/contracts/src/index.ts +2 -0
- package/packages/contracts/src/work-partitioner.ts +251 -0
- package/packages/contracts/test/delegation.test.ts +350 -0
- package/packages/cookie-sanitizer/package.json +1 -1
- package/packages/cost-optimizer/package.json +1 -1
- package/packages/dependency-analyzer/package.json +1 -1
- package/packages/django-plugin/package.json +1 -1
- package/packages/doc-generator/package.json +1 -1
- package/packages/durable-review/package.json +1 -1
- package/packages/e2e-tester/package.json +1 -1
- package/packages/evaluation-engine/package.json +1 -1
- package/packages/evaluation-runner/package.json +1 -1
- package/packages/event-bus/package.json +1 -1
- package/packages/event-sink/package.json +1 -1
- package/packages/event-store/package.json +1 -1
- package/packages/experience-replay/package.json +1 -1
- package/packages/feedback-collector/package.json +1 -1
- package/packages/file-copy-helper/package.json +1 -1
- package/packages/framework-detector/package.json +1 -1
- package/packages/framework-plugin-sdk/package.json +1 -1
- package/packages/frappe-plugin/package.json +1 -1
- package/packages/generic-web-plugin/package.json +1 -1
- package/packages/health-monitor/package.json +1 -1
- package/packages/intent-analyzer/package.json +1 -1
- package/packages/jev-judge/package.json +1 -1
- package/packages/knowledge-graph/package.json +1 -1
- package/packages/knowledge-retrieval/package.json +1 -1
- package/packages/laravel-plugin/package.json +1 -1
- package/packages/learning-engine/package.json +1 -1
- package/packages/mcp-adapter/package.json +1 -1
- package/packages/memory-engine/package.json +1 -1
- package/packages/milestone-manager/package.json +1 -1
- package/packages/model-registry/package.json +1 -1
- package/packages/nextjs-plugin/package.json +1 -1
- package/packages/notification/package.json +1 -1
- package/packages/observability/package.json +1 -1
- package/packages/okf-indexer/package.json +1 -1
- package/packages/paperclip-integration/package.json +1 -1
- package/packages/performance-optimizer/package.json +1 -1
- package/packages/permission-mode/package.json +1 -1
- package/packages/privilege-broker/package.json +1 -1
- package/packages/project-analyzer/package.json +1 -1
- package/packages/project-bootstrap/package.json +1 -1
- package/packages/projection-engine/package.json +1 -1
- package/packages/prompt-compiler/package.json +1 -1
- package/packages/prompt-versioning/package.json +1 -1
- package/packages/provider-adapter-sdk/package.json +1 -1
- package/packages/provider-router/package.json +1 -1
- package/packages/provider-selector/package.json +1 -1
- package/packages/providers/package.json +1 -1
- package/packages/qdrant-skills/package.json +1 -1
- package/packages/quota-manager/package.json +1 -1
- package/packages/rate-limiter/package.json +1 -1
- package/packages/react-vite-plugin/package.json +1 -1
- package/packages/relay/package.json +1 -1
- package/packages/release-manager/package.json +1 -1
- package/packages/requirement-compiler/package.json +1 -1
- package/packages/runtime/package.json +1 -1
- package/packages/scheduler/package.json +1 -1
- package/packages/scheduler-adapter/package.json +1 -1
- package/packages/session/package.json +1 -1
- package/packages/session-api/package.json +1 -1
- package/packages/session-export/package.json +1 -1
- package/packages/shared-context/package.json +1 -1
- package/packages/skill-mcp-client/package.json +1 -1
- package/packages/skill-registry/package.json +1 -1
- package/packages/skills/package.json +1 -1
- package/packages/sprint-planner/package.json +1 -1
- package/packages/subscription-engine/package.json +1 -1
- package/packages/task-compiler/package.json +1 -1
- package/packages/telegram/package.json +1 -1
- package/packages/tencentdb-memory/package.json +1 -1
- package/packages/tencentdb-sync/package.json +1 -1
- package/packages/test-data-generator/package.json +1 -1
- package/packages/test-generator/package.json +1 -1
- package/packages/todo-bd-sync/package.json +1 -1
- package/packages/token-estimation/package.json +1 -1
- package/packages/token-optimizer/package.json +1 -1
- package/packages/trajectory/package.json +1 -1
- package/packages/tui/package.json +1 -1
- package/packages/types/package.json +1 -1
- package/packages/voice-api/package.json +1 -1
- package/packages/webmcp-tester/package.json +1 -1
- package/packages/wiki/package.json +1 -1
- package/packages/workflow-events/package.json +1 -1
- package/packages/workspace-scanner/package.json +1 -1
- package/packages/worktree/package.json +1 -1
- package/packages/write-review/package.json +1 -1
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Delegation Assessment Tests
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { describe, it, expect, beforeEach } from "bun:test";
|
|
6
|
+
import {
|
|
7
|
+
shouldTriggerAssessment,
|
|
8
|
+
DEFAULT_DELEGATION_TRIGGERS,
|
|
9
|
+
type ScopeFacts,
|
|
10
|
+
type DelegationTriggerConfig,
|
|
11
|
+
type DelegationStrategy,
|
|
12
|
+
type WorkGroup,
|
|
13
|
+
} from "../src/delegation.js";
|
|
14
|
+
import {
|
|
15
|
+
partitionWork,
|
|
16
|
+
detectOwnershipConflicts,
|
|
17
|
+
getUnownedFiles,
|
|
18
|
+
updateGroupStatus,
|
|
19
|
+
areAllGroupsComplete,
|
|
20
|
+
DEFAULT_PARTITION_CONFIG,
|
|
21
|
+
} from "../src/work-partitioner.js";
|
|
22
|
+
|
|
23
|
+
describe("Delegation Triggers", () => {
|
|
24
|
+
it("should trigger on 10+ files", () => {
|
|
25
|
+
const facts: ScopeFacts = {
|
|
26
|
+
estimatedFiles: 15,
|
|
27
|
+
observedFiles: 15,
|
|
28
|
+
estimatedCallSites: 20,
|
|
29
|
+
observedCallSites: 20,
|
|
30
|
+
independentComponents: 1,
|
|
31
|
+
tightlyCoupled: false,
|
|
32
|
+
isMechanical: false,
|
|
33
|
+
isComplex: false,
|
|
34
|
+
fileTypes: {},
|
|
35
|
+
fingerprint: "",
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
expect(shouldTriggerAssessment(facts)).toBe(true);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("should trigger on 50+ call sites", () => {
|
|
42
|
+
const facts: ScopeFacts = {
|
|
43
|
+
estimatedFiles: 5,
|
|
44
|
+
observedFiles: 5,
|
|
45
|
+
estimatedCallSites: 60,
|
|
46
|
+
observedCallSites: 60,
|
|
47
|
+
independentComponents: 1,
|
|
48
|
+
tightlyCoupled: false,
|
|
49
|
+
isMechanical: false,
|
|
50
|
+
isComplex: false,
|
|
51
|
+
fileTypes: {},
|
|
52
|
+
fingerprint: "",
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
expect(shouldTriggerAssessment(facts)).toBe(true);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it("should trigger on 2+ independent components", () => {
|
|
59
|
+
const facts: ScopeFacts = {
|
|
60
|
+
estimatedFiles: 5,
|
|
61
|
+
observedFiles: 5,
|
|
62
|
+
estimatedCallSites: 10,
|
|
63
|
+
observedCallSites: 10,
|
|
64
|
+
independentComponents: 3,
|
|
65
|
+
tightlyCoupled: false,
|
|
66
|
+
isMechanical: false,
|
|
67
|
+
isComplex: false,
|
|
68
|
+
fileTypes: {},
|
|
69
|
+
fingerprint: "",
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
expect(shouldTriggerAssessment(facts)).toBe(true);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it("should not trigger on small scope", () => {
|
|
76
|
+
const facts: ScopeFacts = {
|
|
77
|
+
estimatedFiles: 3,
|
|
78
|
+
observedFiles: 3,
|
|
79
|
+
estimatedCallSites: 5,
|
|
80
|
+
observedCallSites: 5,
|
|
81
|
+
independentComponents: 1,
|
|
82
|
+
tightlyCoupled: false,
|
|
83
|
+
isMechanical: false,
|
|
84
|
+
isComplex: false,
|
|
85
|
+
fileTypes: {},
|
|
86
|
+
fingerprint: "",
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
expect(shouldTriggerAssessment(facts)).toBe(false);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it("should respect custom config", () => {
|
|
93
|
+
const facts: ScopeFacts = {
|
|
94
|
+
estimatedFiles: 5,
|
|
95
|
+
observedFiles: 5,
|
|
96
|
+
estimatedCallSites: 10,
|
|
97
|
+
observedCallSites: 10,
|
|
98
|
+
independentComponents: 1,
|
|
99
|
+
tightlyCoupled: false,
|
|
100
|
+
isMechanical: false,
|
|
101
|
+
isComplex: false,
|
|
102
|
+
fileTypes: {},
|
|
103
|
+
fingerprint: "",
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
const customConfig: DelegationTriggerConfig = {
|
|
107
|
+
minFiles: 5,
|
|
108
|
+
minCallSites: 10,
|
|
109
|
+
minIndependentComponents: 1,
|
|
110
|
+
assessOnDiscovery: true,
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
expect(shouldTriggerAssessment(facts, customConfig)).toBe(true);
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
describe("Work Partitioning", () => {
|
|
118
|
+
it("should partition files by directory", () => {
|
|
119
|
+
const files = [
|
|
120
|
+
"src/components/Button.ts",
|
|
121
|
+
"src/components/Modal.ts",
|
|
122
|
+
"src/utils/helper.ts",
|
|
123
|
+
"src/utils/format.ts",
|
|
124
|
+
];
|
|
125
|
+
|
|
126
|
+
const facts: ScopeFacts = {
|
|
127
|
+
estimatedFiles: 4,
|
|
128
|
+
observedFiles: 4,
|
|
129
|
+
estimatedCallSites: 10,
|
|
130
|
+
observedCallSites: 10,
|
|
131
|
+
independentComponents: 2,
|
|
132
|
+
tightlyCoupled: false,
|
|
133
|
+
isMechanical: false,
|
|
134
|
+
isComplex: false,
|
|
135
|
+
fileTypes: { ".ts": 4 },
|
|
136
|
+
fingerprint: "",
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
const groups = partitionWork(files, facts);
|
|
140
|
+
|
|
141
|
+
expect(groups.length).toBe(2);
|
|
142
|
+
expect(groups.some((g) => g.description.includes("components"))).toBe(true);
|
|
143
|
+
expect(groups.some((g) => g.description.includes("utils"))).toBe(true);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
it("should limit files per group", () => {
|
|
147
|
+
const files = Array.from({ length: 40 }, (_, i) => `src/dir${i % 3}/file${i}.ts`);
|
|
148
|
+
|
|
149
|
+
const facts: ScopeFacts = {
|
|
150
|
+
estimatedFiles: 40,
|
|
151
|
+
observedFiles: 40,
|
|
152
|
+
estimatedCallSites: 100,
|
|
153
|
+
observedCallSites: 100,
|
|
154
|
+
independentComponents: 3,
|
|
155
|
+
tightlyCoupled: false,
|
|
156
|
+
isMechanical: false,
|
|
157
|
+
isComplex: false,
|
|
158
|
+
fileTypes: { ".ts": 40 },
|
|
159
|
+
fingerprint: "",
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
const groups = partitionWork(files, facts);
|
|
163
|
+
|
|
164
|
+
// Should have multiple groups (max 15 files per group for 40 files = 3 groups)
|
|
165
|
+
expect(groups.length).toBeGreaterThanOrEqual(3);
|
|
166
|
+
for (const group of groups) {
|
|
167
|
+
expect(group.ownedPaths.length).toBeLessThanOrEqual(
|
|
168
|
+
DEFAULT_PARTITION_CONFIG.maxFilesPerGroup + 5 // Allow small overflow
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
it("should exclude shared paths", () => {
|
|
174
|
+
const files = [
|
|
175
|
+
"index.ts",
|
|
176
|
+
"src/main.ts",
|
|
177
|
+
"src/index.ts",
|
|
178
|
+
"src/components/Button.ts",
|
|
179
|
+
];
|
|
180
|
+
|
|
181
|
+
const facts: ScopeFacts = {
|
|
182
|
+
estimatedFiles: 4,
|
|
183
|
+
observedFiles: 4,
|
|
184
|
+
estimatedCallSites: 10,
|
|
185
|
+
observedCallSites: 10,
|
|
186
|
+
independentComponents: 1,
|
|
187
|
+
tightlyCoupled: false,
|
|
188
|
+
isMechanical: false,
|
|
189
|
+
isComplex: false,
|
|
190
|
+
fileTypes: { ".ts": 4 },
|
|
191
|
+
fingerprint: "",
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
const groups = partitionWork(files, facts);
|
|
195
|
+
|
|
196
|
+
// All groups combined should not include shared paths
|
|
197
|
+
const allOwned = groups.flatMap((g) => g.ownedPaths);
|
|
198
|
+
expect(allOwned).not.toContain("index.ts");
|
|
199
|
+
expect(allOwned).not.toContain("main.ts");
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
describe("Ownership Conflicts", () => {
|
|
204
|
+
it("should detect conflicts", () => {
|
|
205
|
+
const groups: WorkGroup[] = [
|
|
206
|
+
{
|
|
207
|
+
groupId: "group-1",
|
|
208
|
+
description: "components",
|
|
209
|
+
ownedPaths: ["src/components/Button.ts"],
|
|
210
|
+
isMechanical: false,
|
|
211
|
+
status: "pending",
|
|
212
|
+
},
|
|
213
|
+
];
|
|
214
|
+
|
|
215
|
+
const conflicts = detectOwnershipConflicts(groups, ["src/components/Button.ts"]);
|
|
216
|
+
|
|
217
|
+
expect(conflicts.length).toBe(1);
|
|
218
|
+
expect(conflicts[0]).toContain("already owned");
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
it("should detect conflict with completed groups (already owned)", () => {
|
|
222
|
+
const groups: WorkGroup[] = [
|
|
223
|
+
{
|
|
224
|
+
groupId: "group-1",
|
|
225
|
+
description: "components",
|
|
226
|
+
ownedPaths: ["src/components/Button.ts"],
|
|
227
|
+
isMechanical: false,
|
|
228
|
+
status: "completed",
|
|
229
|
+
},
|
|
230
|
+
];
|
|
231
|
+
|
|
232
|
+
// Completed groups still own files - conflict should be detected
|
|
233
|
+
const conflicts = detectOwnershipConflicts(groups, ["src/components/Button.ts"]);
|
|
234
|
+
|
|
235
|
+
expect(conflicts.length).toBe(1);
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
it("should not conflict with cancelled groups", () => {
|
|
239
|
+
const groups: WorkGroup[] = [
|
|
240
|
+
{
|
|
241
|
+
groupId: "group-1",
|
|
242
|
+
description: "components",
|
|
243
|
+
ownedPaths: ["src/components/Button.ts"],
|
|
244
|
+
isMechanical: false,
|
|
245
|
+
status: "cancelled",
|
|
246
|
+
},
|
|
247
|
+
];
|
|
248
|
+
|
|
249
|
+
const conflicts = detectOwnershipConflicts(groups, ["src/components/Button.ts"]);
|
|
250
|
+
|
|
251
|
+
expect(conflicts.length).toBe(0);
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
describe("Group Status Updates", () => {
|
|
256
|
+
it("should update group status", () => {
|
|
257
|
+
const groups: WorkGroup[] = [
|
|
258
|
+
{
|
|
259
|
+
groupId: "group-1",
|
|
260
|
+
description: "test",
|
|
261
|
+
ownedPaths: ["file.ts"],
|
|
262
|
+
isMechanical: false,
|
|
263
|
+
status: "pending",
|
|
264
|
+
},
|
|
265
|
+
];
|
|
266
|
+
|
|
267
|
+
const updated = updateGroupStatus(groups, "group-1", "dispatched", "child-123");
|
|
268
|
+
|
|
269
|
+
expect(updated[0].status).toBe("dispatched");
|
|
270
|
+
expect(updated[0].childId).toBe("child-123");
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
it("should check completion", () => {
|
|
274
|
+
const groups: WorkGroup[] = [
|
|
275
|
+
{
|
|
276
|
+
groupId: "group-1",
|
|
277
|
+
description: "test1",
|
|
278
|
+
ownedPaths: ["file1.ts"],
|
|
279
|
+
isMechanical: false,
|
|
280
|
+
status: "completed",
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
groupId: "group-2",
|
|
284
|
+
description: "test2",
|
|
285
|
+
ownedPaths: ["file2.ts"],
|
|
286
|
+
isMechanical: false,
|
|
287
|
+
status: "completed",
|
|
288
|
+
},
|
|
289
|
+
];
|
|
290
|
+
|
|
291
|
+
expect(areAllGroupsComplete(groups)).toBe(true);
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
it("should not report complete with pending", () => {
|
|
295
|
+
const groups: WorkGroup[] = [
|
|
296
|
+
{
|
|
297
|
+
groupId: "group-1",
|
|
298
|
+
description: "test1",
|
|
299
|
+
ownedPaths: ["file1.ts"],
|
|
300
|
+
isMechanical: false,
|
|
301
|
+
status: "completed",
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
groupId: "group-2",
|
|
305
|
+
description: "test2",
|
|
306
|
+
ownedPaths: ["file2.ts"],
|
|
307
|
+
isMechanical: false,
|
|
308
|
+
status: "pending",
|
|
309
|
+
},
|
|
310
|
+
];
|
|
311
|
+
|
|
312
|
+
expect(areAllGroupsComplete(groups)).toBe(false);
|
|
313
|
+
});
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
describe("Unowned Files", () => {
|
|
317
|
+
it("should identify unowned files", () => {
|
|
318
|
+
const allFiles = ["file1.ts", "file2.ts", "file3.ts"];
|
|
319
|
+
const groups: WorkGroup[] = [
|
|
320
|
+
{
|
|
321
|
+
groupId: "group-1",
|
|
322
|
+
description: "test",
|
|
323
|
+
ownedPaths: ["file1.ts", "file2.ts"],
|
|
324
|
+
isMechanical: false,
|
|
325
|
+
status: "pending",
|
|
326
|
+
},
|
|
327
|
+
];
|
|
328
|
+
|
|
329
|
+
const unowned = getUnownedFiles(allFiles, groups);
|
|
330
|
+
|
|
331
|
+
expect(unowned).toEqual(["file3.ts"]);
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
it("should consider completed groups as owned", () => {
|
|
335
|
+
const allFiles = ["file1.ts", "file2.ts"];
|
|
336
|
+
const groups: WorkGroup[] = [
|
|
337
|
+
{
|
|
338
|
+
groupId: "group-1",
|
|
339
|
+
description: "test",
|
|
340
|
+
ownedPaths: ["file1.ts"],
|
|
341
|
+
isMechanical: false,
|
|
342
|
+
status: "completed",
|
|
343
|
+
},
|
|
344
|
+
];
|
|
345
|
+
|
|
346
|
+
const unowned = getUnownedFiles(allFiles, groups);
|
|
347
|
+
|
|
348
|
+
expect(unowned).toEqual(["file2.ts"]);
|
|
349
|
+
});
|
|
350
|
+
});
|