pi-harness-runtime 1.1.451 → 1.1.452

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 (93) hide show
  1. package/AGENTS.md +53 -0
  2. package/CHANGELOG.md +24 -0
  3. package/index.ts +172 -21
  4. package/package.json +1 -1
  5. package/packages/agent-policy/package.json +1 -1
  6. package/packages/auth/package.json +1 -1
  7. package/packages/autonomous-runtime/package.json +1 -1
  8. package/packages/checkpoint/package.json +1 -1
  9. package/packages/clipboard/package.json +1 -1
  10. package/packages/codex-watcher/package.json +1 -1
  11. package/packages/config-capture/package.json +1 -1
  12. package/packages/contracts/package.json +1 -1
  13. package/packages/cookie-sanitizer/package.json +1 -1
  14. package/packages/evaluation-engine/package.json +1 -1
  15. package/packages/event-bus/package.json +1 -1
  16. package/packages/event-store/package.json +1 -1
  17. package/packages/experience-replay/package.json +1 -1
  18. package/packages/file-copy-helper/package.json +1 -1
  19. package/packages/intent-analyzer/package.json +1 -1
  20. package/packages/jev-judge/dist/continuation-status.d.ts +31 -0
  21. package/packages/jev-judge/dist/continuation-status.d.ts.map +1 -0
  22. package/packages/jev-judge/dist/continuation-status.js +40 -0
  23. package/packages/jev-judge/dist/continuation-status.js.map +1 -0
  24. package/packages/jev-judge/dist/delegation-harness.d.ts +74 -1
  25. package/packages/jev-judge/dist/delegation-harness.d.ts.map +1 -1
  26. package/packages/jev-judge/dist/delegation-harness.js +183 -18
  27. package/packages/jev-judge/dist/delegation-harness.js.map +1 -1
  28. package/packages/jev-judge/dist/delegation-scope.d.ts +88 -0
  29. package/packages/jev-judge/dist/delegation-scope.d.ts.map +1 -0
  30. package/packages/jev-judge/dist/delegation-scope.js +218 -0
  31. package/packages/jev-judge/dist/delegation-scope.js.map +1 -0
  32. package/packages/jev-judge/package.json +1 -1
  33. package/packages/jev-judge/src/continuation-status.ts +41 -0
  34. package/packages/jev-judge/src/delegation-harness.ts +254 -45
  35. package/packages/jev-judge/src/delegation-scope.ts +264 -0
  36. package/packages/knowledge-retrieval/package.json +1 -1
  37. package/packages/learning-engine/package.json +1 -1
  38. package/packages/logging/package.json +1 -1
  39. package/packages/memory-engine/package.json +1 -1
  40. package/packages/notification/package.json +1 -1
  41. package/packages/paperclip-integration/package.json +1 -1
  42. package/packages/performance-optimizer/package.json +1 -1
  43. package/packages/privilege-broker/package.json +1 -1
  44. package/packages/prompt-compiler/package.json +1 -1
  45. package/packages/providers/package.json +1 -1
  46. package/packages/qdrant-skills/package.json +1 -1
  47. package/packages/quota-manager/package.json +1 -1
  48. package/packages/relay/package.json +1 -1
  49. package/packages/skill-mcp-client/package.json +1 -1
  50. package/packages/skills/package.json +1 -1
  51. package/packages/todo-bd-sync/package.json +1 -1
  52. package/packages/token-estimation/package.json +1 -1
  53. package/packages/tooling-preference/package.json +1 -1
  54. package/packages/trajectory/package.json +1 -1
  55. package/packages/tui/package.json +1 -1
  56. package/packages/two-phase-review/dist/classify.d.ts +22 -1
  57. package/packages/two-phase-review/dist/classify.d.ts.map +1 -1
  58. package/packages/two-phase-review/dist/classify.js +37 -1
  59. package/packages/two-phase-review/dist/classify.js.map +1 -1
  60. package/packages/two-phase-review/dist/index.d.ts +4 -2
  61. package/packages/two-phase-review/dist/index.d.ts.map +1 -1
  62. package/packages/two-phase-review/dist/index.js +3 -2
  63. package/packages/two-phase-review/dist/index.js.map +1 -1
  64. package/packages/two-phase-review/dist/rules.d.ts +8 -3
  65. package/packages/two-phase-review/dist/rules.d.ts.map +1 -1
  66. package/packages/two-phase-review/dist/rules.js +36 -5
  67. package/packages/two-phase-review/dist/rules.js.map +1 -1
  68. package/packages/two-phase-review/dist/runtime.d.ts +9 -0
  69. package/packages/two-phase-review/dist/runtime.d.ts.map +1 -1
  70. package/packages/two-phase-review/dist/runtime.js +68 -17
  71. package/packages/two-phase-review/dist/runtime.js.map +1 -1
  72. package/packages/two-phase-review/dist/state.d.ts +15 -0
  73. package/packages/two-phase-review/dist/state.d.ts.map +1 -1
  74. package/packages/two-phase-review/dist/state.js +37 -2
  75. package/packages/two-phase-review/dist/state.js.map +1 -1
  76. package/packages/two-phase-review/dist/types.d.ts +2 -2
  77. package/packages/two-phase-review/dist/types.d.ts.map +1 -1
  78. package/packages/two-phase-review/dist/validation.d.ts +50 -0
  79. package/packages/two-phase-review/dist/validation.d.ts.map +1 -0
  80. package/packages/two-phase-review/dist/validation.js +54 -0
  81. package/packages/two-phase-review/dist/validation.js.map +1 -0
  82. package/packages/two-phase-review/package.json +1 -1
  83. package/packages/two-phase-review/src/classify.ts +38 -1
  84. package/packages/two-phase-review/src/index.ts +16 -0
  85. package/packages/two-phase-review/src/rules.ts +48 -4
  86. package/packages/two-phase-review/src/runtime.ts +88 -17
  87. package/packages/two-phase-review/src/state.ts +38 -2
  88. package/packages/two-phase-review/src/types.ts +2 -1
  89. package/packages/two-phase-review/src/validation.ts +86 -0
  90. package/packages/types/package.json +1 -1
  91. package/packages/webmcp-tester/package.json +1 -1
  92. package/packages/wiki/package.json +1 -1
  93. package/packages/write-review/package.json +1 -1
@@ -29,7 +29,8 @@ const PHASE_ORDER: Record<TwoPhasePhase, number> = {
29
29
  review_pending: 1,
30
30
  review: 2,
31
31
  review_fixes: 3,
32
- complete: 4,
32
+ test_pending: 4,
33
+ complete: 5,
33
34
  };
34
35
 
35
36
  /** Makes the name of a temporary state file unique. */
@@ -66,7 +67,14 @@ function listDir(dir: string): string {
66
67
  function isPhase(value: unknown): value is TwoPhasePhase {
67
68
  return (
68
69
  typeof value === "string" &&
69
- ["implementation", "review_pending", "review", "review_fixes", "complete"].includes(value)
70
+ [
71
+ "implementation",
72
+ "review_pending",
73
+ "review",
74
+ "review_fixes",
75
+ "test_pending",
76
+ "complete",
77
+ ].includes(value)
70
78
  );
71
79
  }
72
80
 
@@ -257,6 +265,18 @@ export function transitionToReviewFixes(state: TwoPhaseState): TwoPhaseState {
257
265
  return moveToPhase(state, "review_fixes");
258
266
  }
259
267
 
268
+ /**
269
+ * The review is done: the validation of the task is now the work.
270
+ *
271
+ * The phase only moves when the review really ran over every chunk: a test
272
+ * phase before the review would hide the work that is still open.
273
+ */
274
+ export function transitionToTestPending(state: TwoPhaseState): TwoPhaseState {
275
+ if (state.phase !== "review" && state.phase !== "review_fixes") return state;
276
+ if (!allChunksDone(state)) return state;
277
+ return moveToPhase(state, "test_pending");
278
+ }
279
+
260
280
  /** Every chunk is finished. */
261
281
  export function allChunksDone(state: TwoPhaseState): boolean {
262
282
  return state.chunks.length > 0 && state.chunks.every((chunk) => chunk.status === "done");
@@ -274,6 +294,22 @@ export function markComplete(state: TwoPhaseState): TwoPhaseState {
274
294
  return moveToPhase(state, "complete");
275
295
  }
276
296
 
297
+ /**
298
+ * The task changed no file, so there is nothing to review.
299
+ *
300
+ * This is the one case in which the implementation phase completes the task
301
+ * on its own: a review without a diff has nothing to cover. A scope with
302
+ * files never completes here - that scope needs the review.
303
+ */
304
+ export function completeWithoutReview(
305
+ state: TwoPhaseState,
306
+ scopeFiles: string[] = [],
307
+ ): TwoPhaseState {
308
+ if (state.phase !== "implementation") return state;
309
+ if (scopeFiles.length > 0) return state;
310
+ return moveToPhase(state, "complete");
311
+ }
312
+
277
313
  /** Is a review queued? */
278
314
  export function hasQueuedReview(state: TwoPhaseState): boolean {
279
315
  return state.signals.length > 0;
@@ -12,10 +12,11 @@ export type TwoPhasePhase =
12
12
  | "review_pending"
13
13
  | "review"
14
14
  | "review_fixes"
15
+ | "test_pending"
15
16
  | "complete";
16
17
 
17
18
  /** What a todo item represents. */
18
- export type TodoKind = "implement" | "review" | "review_fix" | "other";
19
+ export type TodoKind = "implement" | "review" | "review_fix" | "test" | "other";
19
20
 
20
21
  /** A "review now" signal that arrived while the implementation was running. */
21
22
  export interface ReviewSignal {
@@ -0,0 +1,86 @@
1
+ /**
2
+ * The validation gate of the workflow.
3
+ *
4
+ * The workflow does not know how the tests are run: the task author declares
5
+ * the tiers in the metadata of the todo item and the runs are recorded in a
6
+ * ledger. This module only reads the *result* of that ledger, so the phase
7
+ * gate and the ledger can never disagree about whether a tier passed.
8
+ *
9
+ * The shape of the state is mirrored here on purpose: the workflow must not
10
+ * depend on the judge package, so the caller adapts its ledger to this
11
+ * shape.
12
+ */
13
+
14
+ /** The part of a todo item the gate needs. */
15
+ export interface GateTodo {
16
+ id?: number;
17
+ subject?: string;
18
+ status?: string;
19
+ metadata?: Record<string, unknown>;
20
+ }
21
+
22
+ /**
23
+ * The validation state of the test items of a session.
24
+ */
25
+ export interface ValidationGateState {
26
+ /** Could the validation state be read at all? */
27
+ available: boolean;
28
+ /** Why the state could not be read. */
29
+ reason?: string;
30
+ /** Test items whose required final tier has not passed yet. */
31
+ pendingFinalTier: number;
32
+ /** Test items whose final tier failed, timed out or errored. */
33
+ failedFinalTier: number;
34
+ /** Test items whose plan requires a final tier but declares none. */
35
+ incompletePlan: number;
36
+ }
37
+
38
+ /** Reads the validation state of the test items of a session. */
39
+ export type ValidationGateReader = (
40
+ todos: GateTodo[],
41
+ ) => Promise<ValidationGateState>;
42
+
43
+ /** A gate state that says nothing. */
44
+ export function emptyValidationGateState(): ValidationGateState {
45
+ return {
46
+ available: false,
47
+ pendingFinalTier: 0,
48
+ failedFinalTier: 0,
49
+ incompletePlan: 0,
50
+ };
51
+ }
52
+
53
+ /**
54
+ * Is the validation of the test items done?
55
+ *
56
+ * A gate that could not be read is not satisfied: the workflow must never
57
+ * report a test as passed because it does not know how it went.
58
+ */
59
+ export function validationGateSatisfied(state: ValidationGateState): boolean {
60
+ if (!state.available) return false;
61
+ return (
62
+ state.pendingFinalTier === 0 &&
63
+ state.failedFinalTier === 0 &&
64
+ state.incompletePlan === 0
65
+ );
66
+ }
67
+
68
+ /**
69
+ * A short description of the gate, for the status line and the instruction.
70
+ */
71
+ export function describeValidationGate(state: ValidationGateState): string {
72
+ if (!state.available) {
73
+ return `the validation state is not readable (${state.reason ?? "unknown reason"})`;
74
+ }
75
+ const parts: string[] = [];
76
+ if (state.pendingFinalTier > 0) {
77
+ parts.push(`${state.pendingFinalTier} final tier(s) pending`);
78
+ }
79
+ if (state.failedFinalTier > 0) {
80
+ parts.push(`${state.failedFinalTier} final tier(s) failed`);
81
+ }
82
+ if (state.incompletePlan > 0) {
83
+ parts.push(`${state.incompletePlan} plan(s) without a final tier`);
84
+ }
85
+ return parts.length > 0 ? parts.join(", ") : "every required tier passed";
86
+ }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/types",
3
- "version": "1.1.451",
3
+ "version": "1.1.452",
4
4
  "description": "Shared TypeScript types for pi-harness-runtime packages",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/webmcp-tester",
3
- "version": "1.1.451",
3
+ "version": "1.1.452",
4
4
  "description": "WebMCP-powered E2E testing for pi-harness - natural language test scenarios",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/wiki",
3
- "version": "1.1.451",
3
+ "version": "1.1.452",
4
4
  "description": "LLM Wiki integration for pi-harness-runtime",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moocoding/write-review",
3
- "version": "1.1.451",
3
+ "version": "1.1.452",
4
4
  "description": "Two-agent write-review loop with blackboard coordination",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",