@llblab/pi-actors 0.41.0 → 0.42.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.
Files changed (150) hide show
  1. package/AGENTS.md +13 -8
  2. package/BACKLOG.md +2 -81
  3. package/CHANGELOG.md +22 -0
  4. package/README.md +22 -4
  5. package/dist/index.js +29 -82
  6. package/dist/lib/async-runs.d.ts +25 -5
  7. package/dist/lib/async-runs.js +136 -47
  8. package/dist/lib/automatic-review-runtime.d.ts +18 -0
  9. package/dist/lib/automatic-review-runtime.js +96 -0
  10. package/dist/lib/draft-consolidation-transaction.d.ts +65 -0
  11. package/dist/lib/draft-consolidation-transaction.js +610 -0
  12. package/dist/lib/draft-consolidation.d.ts +35 -0
  13. package/dist/lib/draft-consolidation.js +126 -0
  14. package/dist/lib/draft-review.d.ts +56 -0
  15. package/dist/lib/draft-review.js +254 -0
  16. package/dist/lib/draft-sleep.d.ts +65 -0
  17. package/dist/lib/draft-sleep.js +468 -0
  18. package/dist/lib/file-state.d.ts +8 -1
  19. package/dist/lib/file-state.js +115 -18
  20. package/dist/lib/inspector-actions.d.ts +16 -0
  21. package/dist/lib/inspector-actions.js +57 -0
  22. package/dist/lib/inspector-command.d.ts +7 -0
  23. package/dist/lib/inspector-command.js +37 -0
  24. package/dist/lib/inspector-overlay.d.ts +29 -1
  25. package/dist/lib/inspector-overlay.js +537 -90
  26. package/dist/lib/inspector.d.ts +9 -0
  27. package/dist/lib/inspector.js +52 -1
  28. package/dist/lib/observability.d.ts +39 -3
  29. package/dist/lib/observability.js +162 -34
  30. package/dist/lib/paths.d.ts +7 -0
  31. package/dist/lib/paths.js +28 -0
  32. package/dist/lib/recipes-discovery.js +32 -24
  33. package/dist/lib/recipes-usage.d.ts +18 -6
  34. package/dist/lib/recipes-usage.js +445 -34
  35. package/dist/lib/review-control.d.ts +14 -0
  36. package/dist/lib/review-control.js +111 -0
  37. package/dist/lib/review-diagnostics.d.ts +11 -0
  38. package/dist/lib/review-diagnostics.js +148 -0
  39. package/dist/lib/review-projection.d.ts +14 -0
  40. package/dist/lib/review-projection.js +170 -0
  41. package/dist/lib/run-ui-runtime.d.ts +18 -0
  42. package/dist/lib/run-ui-runtime.js +123 -0
  43. package/dist/lib/runs-artifacts.d.ts +1 -1
  44. package/dist/lib/runs-artifacts.js +1 -1
  45. package/dist/lib/runs-control.d.ts +8 -2
  46. package/dist/lib/runs-control.js +23 -6
  47. package/dist/lib/runs-identity.d.ts +1 -1
  48. package/dist/lib/runs-identity.js +1 -1
  49. package/dist/lib/runs-index.d.ts +11 -2
  50. package/dist/lib/runs-index.js +46 -23
  51. package/dist/lib/runs-mailbox.d.ts +1 -1
  52. package/dist/lib/runs-mailbox.js +1 -1
  53. package/dist/lib/runs-messages.d.ts +1 -1
  54. package/dist/lib/runs-messages.js +1 -1
  55. package/dist/lib/runs-outbox.d.ts +1 -1
  56. package/dist/lib/runs-outbox.js +1 -1
  57. package/dist/lib/runs-ownership.d.ts +1 -1
  58. package/dist/lib/runs-ownership.js +1 -1
  59. package/dist/lib/runs-parent-teardown.d.ts +51 -0
  60. package/dist/lib/runs-parent-teardown.js +172 -0
  61. package/dist/lib/runs-process.d.ts +1 -1
  62. package/dist/lib/runs-process.js +1 -1
  63. package/dist/lib/runs-retention.d.ts +1 -1
  64. package/dist/lib/runs-retention.js +1 -1
  65. package/dist/lib/runs-start.d.ts +5 -3
  66. package/dist/lib/runs-start.js +6 -48
  67. package/dist/lib/runs-status.d.ts +5 -3
  68. package/dist/lib/runs-status.js +4 -6
  69. package/dist/lib/runtime.d.ts +7 -1
  70. package/dist/lib/runtime.js +32 -18
  71. package/dist/lib/tool-review-lineage-transaction.d.ts +27 -0
  72. package/dist/lib/tool-review-lineage-transaction.js +597 -0
  73. package/dist/lib/tool-review-lineage.d.ts +24 -0
  74. package/dist/lib/tool-review-lineage.js +98 -0
  75. package/dist/lib/tool-review-scheduler.d.ts +80 -0
  76. package/dist/lib/tool-review-scheduler.js +494 -0
  77. package/dist/lib/tool-review-transaction.d.ts +50 -0
  78. package/dist/lib/tool-review-transaction.js +362 -0
  79. package/dist/lib/tool-review.d.ts +56 -0
  80. package/dist/lib/tool-review.js +197 -0
  81. package/dist/lib/tools-inspect.js +26 -3
  82. package/dist/lib/tools-local.js +4 -2
  83. package/dist/lib/tools-message.d.ts +1 -0
  84. package/dist/lib/tools-message.js +29 -17
  85. package/dist/lib/tools-response.d.ts +1 -1
  86. package/dist/lib/tools-response.js +5 -7
  87. package/dist/lib/tools-spawn.js +4 -1
  88. package/dist/lib/tools.d.ts +1 -0
  89. package/dist/lib/tools.js +1 -0
  90. package/dist/recipes/draft-review.json +24 -0
  91. package/dist/recipes/tool-review.json +24 -0
  92. package/dist/scripts/release-gates.mjs +165 -0
  93. package/dist/skills/actors/SKILL.md +11 -14
  94. package/dist/skills/swarm/SKILL.md +1 -1
  95. package/docs/actor-inspector.md +32 -18
  96. package/docs/async-runs.md +10 -2
  97. package/docs/recipe-library.md +7 -3
  98. package/docs/template-recipes.md +4 -11
  99. package/docs/tool-registry.md +11 -4
  100. package/index.ts +29 -103
  101. package/lib/async-runs.ts +218 -62
  102. package/lib/automatic-review-runtime.ts +135 -0
  103. package/lib/draft-consolidation-transaction.ts +821 -0
  104. package/lib/draft-consolidation.ts +181 -0
  105. package/lib/draft-review.ts +325 -0
  106. package/lib/draft-sleep.ts +576 -0
  107. package/lib/file-state.ts +143 -19
  108. package/lib/inspector-actions.ts +79 -0
  109. package/lib/inspector-command.ts +54 -0
  110. package/lib/inspector-overlay.ts +675 -105
  111. package/lib/inspector.ts +78 -3
  112. package/lib/observability.ts +219 -40
  113. package/lib/paths.ts +43 -0
  114. package/lib/recipes-discovery.ts +34 -26
  115. package/lib/recipes-usage.ts +569 -40
  116. package/lib/review-control.ts +137 -0
  117. package/lib/review-diagnostics.ts +164 -0
  118. package/lib/review-projection.ts +200 -0
  119. package/lib/run-ui-runtime.ts +153 -0
  120. package/lib/runs-artifacts.ts +1 -1
  121. package/lib/runs-control.ts +49 -5
  122. package/lib/runs-identity.ts +1 -1
  123. package/lib/runs-index.ts +57 -21
  124. package/lib/runs-mailbox.ts +1 -1
  125. package/lib/runs-messages.ts +1 -1
  126. package/lib/runs-outbox.ts +1 -1
  127. package/lib/runs-ownership.ts +1 -1
  128. package/lib/runs-parent-teardown.ts +257 -0
  129. package/lib/runs-process.ts +1 -1
  130. package/lib/runs-retention.ts +1 -1
  131. package/lib/runs-start.ts +12 -68
  132. package/lib/runs-status.ts +12 -8
  133. package/lib/runtime.ts +34 -17
  134. package/lib/tool-review-lineage-transaction.ts +881 -0
  135. package/lib/tool-review-lineage.ts +145 -0
  136. package/lib/tool-review-scheduler.ts +635 -0
  137. package/lib/tool-review-transaction.ts +563 -0
  138. package/lib/tool-review.ts +270 -0
  139. package/lib/tools-inspect.ts +33 -3
  140. package/lib/tools-local.ts +8 -2
  141. package/lib/tools-message.ts +45 -30
  142. package/lib/tools-response.ts +5 -6
  143. package/lib/tools-spawn.ts +8 -1
  144. package/lib/tools.ts +5 -0
  145. package/package.json +3 -2
  146. package/recipes/draft-review.json +24 -0
  147. package/recipes/tool-review.json +24 -0
  148. package/scripts/release-gates.mjs +165 -0
  149. package/skills/actors/SKILL.md +11 -14
  150. package/skills/swarm/SKILL.md +1 -1
@@ -124,16 +124,20 @@ export function createAutoToolsRuntime(deps) {
124
124
  registerRuntimeTool,
125
125
  };
126
126
  }
127
- export function createRecipeToolReloadWatcher(runtime) {
127
+ export function createRecipeToolReloadWatcher(runtime, deps = {}) {
128
+ const pathExists = deps.exists ?? existsSync;
129
+ const watchPath = deps.watchPath ?? watch;
128
130
  let reloadTimeout;
129
131
  let rootWatcher;
130
132
  let parentWatcher;
131
133
  let failureNotified = false;
132
134
  const close = () => {
133
- rootWatcher?.close();
135
+ const closingRoot = rootWatcher;
134
136
  rootWatcher = undefined;
135
- parentWatcher?.close();
137
+ closingRoot?.close();
138
+ const closingParent = parentWatcher;
136
139
  parentWatcher = undefined;
140
+ closingParent?.close();
137
141
  if (reloadTimeout)
138
142
  clearTimeout(reloadTimeout);
139
143
  reloadTimeout = undefined;
@@ -158,27 +162,32 @@ export function createRecipeToolReloadWatcher(runtime) {
158
162
  if (parentWatcher || rootWatcher)
159
163
  return;
160
164
  const parent = dirname(recipeRoot);
161
- if (!existsSync(parent)) {
165
+ if (!pathExists(parent)) {
162
166
  notifyFailure(ctx);
163
167
  return;
164
168
  }
165
169
  try {
166
- parentWatcher = watch(parent, (_event, changedFile) => {
170
+ const watcher = watchPath(parent, (_event, changedFile) => {
171
+ if (parentWatcher !== watcher)
172
+ return;
167
173
  if (changedFile &&
168
174
  String(changedFile) !== basename(recipeRoot) &&
169
- !existsSync(recipeRoot)) {
175
+ !pathExists(recipeRoot)) {
170
176
  return;
171
177
  }
172
- if (!existsSync(recipeRoot))
178
+ if (!pathExists(recipeRoot))
173
179
  return;
174
- parentWatcher?.close();
175
180
  parentWatcher = undefined;
181
+ watcher.close();
176
182
  watchRoot(ctx, recipeRoot);
177
183
  scheduleReload(ctx);
178
184
  });
179
- parentWatcher.on("error", () => {
180
- parentWatcher?.close();
185
+ parentWatcher = watcher;
186
+ watcher.on("error", () => {
187
+ if (parentWatcher !== watcher)
188
+ return;
181
189
  parentWatcher = undefined;
190
+ watcher.close();
182
191
  notifyFailure(ctx);
183
192
  });
184
193
  }
@@ -189,25 +198,30 @@ export function createRecipeToolReloadWatcher(runtime) {
189
198
  const watchRoot = (ctx, recipeRoot) => {
190
199
  if (rootWatcher)
191
200
  return;
192
- if (!existsSync(recipeRoot)) {
201
+ if (!pathExists(recipeRoot)) {
193
202
  watchParent(ctx, recipeRoot);
194
203
  return;
195
204
  }
196
205
  try {
197
- rootWatcher = watch(recipeRoot, () => {
198
- if (!existsSync(recipeRoot)) {
199
- rootWatcher?.close();
206
+ const watcher = watchPath(recipeRoot, () => {
207
+ if (rootWatcher !== watcher)
208
+ return;
209
+ if (!pathExists(recipeRoot)) {
200
210
  rootWatcher = undefined;
211
+ watcher.close();
201
212
  scheduleReload(ctx);
202
213
  watchParent(ctx, recipeRoot);
203
214
  return;
204
215
  }
205
216
  scheduleReload(ctx);
206
217
  });
207
- rootWatcher.on("error", () => {
208
- rootWatcher?.close();
218
+ rootWatcher = watcher;
219
+ watcher.on("error", () => {
220
+ if (rootWatcher !== watcher)
221
+ return;
209
222
  rootWatcher = undefined;
210
- if (existsSync(recipeRoot))
223
+ watcher.close();
224
+ if (pathExists(recipeRoot))
211
225
  notifyFailure(ctx);
212
226
  else
213
227
  watchParent(ctx, recipeRoot);
@@ -222,7 +236,7 @@ export function createRecipeToolReloadWatcher(runtime) {
222
236
  watch(ctx) {
223
237
  if (rootWatcher || parentWatcher)
224
238
  return;
225
- watchRoot(ctx, Paths.getRecipeRoot());
239
+ watchRoot(ctx, deps.recipeRoot ?? Paths.getRecipeRoot());
226
240
  },
227
241
  };
228
242
  }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Journaled tool-review lineage finalization.
3
+ * Zones: lineage projection persistence, ledger/index CAS, crash roll-forward
4
+ * Owns idempotent ledger mutation after portfolio filesystem commit; admission-state activation and quarantine cleanup remain separate.
5
+ */
6
+ export interface ToolReviewLineageTransactionResult {
7
+ journalPath: string;
8
+ phase: "committed";
9
+ }
10
+ export interface ToolReviewLineageTransactionOptions {
11
+ checkpoint?(checkpoint: "ledger_written" | "prepared"): void;
12
+ now?(): Date;
13
+ recipeRoot: string;
14
+ }
15
+ export declare function finalizeToolReviewLineage(approvedPath: string, options: ToolReviewLineageTransactionOptions): ToolReviewLineageTransactionResult;
16
+ export interface ToolReviewRevisionRollbackResult {
17
+ journalPath: string;
18
+ lineageName: string;
19
+ restoredRevision: number;
20
+ targetPath: string;
21
+ }
22
+ export interface ToolReviewRevisionRollbackOptions {
23
+ checkpoint?(checkpoint: "ledger_written" | "prepared" | "recipe_written"): void;
24
+ now?(): Date;
25
+ recipeRoot: string;
26
+ }
27
+ export declare function rollbackToolRecipeRevision(lineageName: string, revision: number, options: ToolReviewRevisionRollbackOptions): ToolReviewRevisionRollbackResult;