pi-task-dispatcher 3.1.2 → 3.2.1
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 +11 -10
- package/extensions/task-dispatcher.ts +659 -46
- package/package.json +1 -1
- package/tests/fake-rpc-check.mjs +313 -127
- package/tests/fake-rpc-worker.mjs +287 -148
- package/tests/gate-probe.mjs +185 -162
- package/tests/static-check.mjs +26 -3
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ Each delegation runs in an isolated, in-memory Pi RPC session. After every cohes
|
|
|
10
10
|
- **Enforced supervision:** a private parent-child IPC gate calls `ctx.abort()` after persisted tool results; pausing does not depend on the worker following a prompt.
|
|
11
11
|
- **Explicit control:** continue, revise, recalculate, compact, checkpoint, cancel, or take over.
|
|
12
12
|
- **Resumable context:** continuation uses the same in-memory worker session and completed tool results.
|
|
13
|
-
- **
|
|
13
|
+
- **Manager-granted capabilities:** every start snapshots exact selected tools from the manager's current capabilities. Every selected non-`codemode` tool must be callable through `ctx.tools`/`ctx.executeTool()` and becomes a nonce-bound child proxy back to that manager path; unselected, recursive, replayed, cross-job, and paused requests fail closed. Active `codemode` is the deliberate exception: when explicitly selected, a runtime-temporary extension loads Pi's public native factory in `only` mode, and it is never injected otherwise.
|
|
14
14
|
- **Model agnostic:** every role inherits Pi's active model and thinking level unless an explicit role override is configured.
|
|
15
15
|
- **Formula-owned budgets:** the manager supplies semantic workload units, while the dispatcher calculates turn and time ceilings from workload, role, and delegated-model limits.
|
|
16
16
|
- **Context insight:** boundary reports include worker context usage, compactions, turns, elapsed time, action counts, and recommendations.
|
|
@@ -23,7 +23,7 @@ Each delegation runs in an isolated, in-memory Pi RPC session. After every cohes
|
|
|
23
23
|
- Node.js 22.19.0 or later
|
|
24
24
|
- One active, authenticated Pi model; optional role-specific models must also be available and authenticated
|
|
25
25
|
|
|
26
|
-
The supervision gate
|
|
26
|
+
The supervision gate and manager-tool proxies require the parent Pi process and child Pi CLI to run under Node.js with an inherited IPC channel. The dispatcher fails closed when that boundary cannot be established; it does not fall back to prompt-only supervision or direct child access to manager capabilities. Worker processes disable ordinary extension discovery and load a generated proxy extension, the generated supervision gate, and a generated native codemode-only extension only when that tool was explicitly selected.
|
|
27
27
|
|
|
28
28
|
## Installation
|
|
29
29
|
|
|
@@ -64,10 +64,10 @@ The designer can inspect images with `read`, use image models through `codemode`
|
|
|
64
64
|
Every role tool requires:
|
|
65
65
|
|
|
66
66
|
- `task`: a self-contained objective, scope, constraints, and acceptance checks;
|
|
67
|
-
- `tools`: the smallest exact
|
|
67
|
+
- `tools`: the smallest exact capability grant selected from tools callable in the current manager context; this can include compatible extension-defined tools, but cannot include delegation tools or names unavailable through `ctx.executeTool()`—except active `codemode`, which is recreated child-locally;
|
|
68
68
|
- `workload`: semantic estimates used by the deterministic budget formula.
|
|
69
69
|
|
|
70
|
-
When `codemode` is active and delegated work materially benefits from JavaScript orchestration, batched/parallel/filtering of selected tools, or classifier/image models, include it in the delegated
|
|
70
|
+
When `codemode` is active and delegated work materially benefits from JavaScript orchestration, batched/parallel/filtering of selected tools, or classifier/image models, include it in the delegated capability grant rather than reserving it for the manager. Also include each selected tool its script must call through the child proxy; otherwise omit `codemode`.
|
|
71
71
|
|
|
72
72
|
```json
|
|
73
73
|
{
|
|
@@ -91,7 +91,7 @@ A workload unit is intentionally semantic:
|
|
|
91
91
|
|
|
92
92
|
At least one investigation, change, or verification unit is required.
|
|
93
93
|
|
|
94
|
-
|
|
94
|
+
The worker receives exactly the selected capability names: manager-callable tools plus active `codemode` when requested. For every selected name except `codemode`, a generated child extension recreates the public tool metadata and sends execution through a private nonce-bound IPC proxy to the manager's `ctx.executeTool()` path, so manager validation, hooks, policy, and nested usage accounting remain authoritative. Calls that a selected manager tool makes transitively are blocked unless their names are also in the same grant. Proxy manifests, individual arguments/results, concurrent requests, and total per-job requests have fixed limits and fail closed when exceeded. The proxy grant is rebuilt and definition-fingerprinted before continuation; a changed or unavailable callable tool hard-stops the job rather than weakening the original grant. If `codemode` is selected, the child additionally generates a temporary extension using Pi's public `createCodemodeExtension({ mode: "only" })` API while ordinary extension discovery remains disabled. This makes `codemode` model-visible; its scripts can call only selected proxied tools and the non-LLM model catalog. Unrelated manager extensions and delegation tools remain unavailable.
|
|
95
95
|
|
|
96
96
|
The current formula derives planned work turns from those units, applies a role factor and a bounded scale based on the selected delegated model's own context window, reserves two additional turns for synthesis or recovery, then derives active execution time from calculated turns plus expected long-running time. Administrative ceilings always win. Formula inputs and results are returned in every state report so they can be reviewed and recalculated. Time spent paused for manager deliberation does not consume the active execution budget.
|
|
97
97
|
|
|
@@ -143,7 +143,7 @@ A paused result contains:
|
|
|
143
143
|
- a session-local sequential identity such as `engineer-2`, plus role, model, and status;
|
|
144
144
|
- the delegated task and live command or tool activity while execution is running;
|
|
145
145
|
- boundary sequence and current phase;
|
|
146
|
-
- completed, failed, and potentially mutating action counts;
|
|
146
|
+
- completed, failed, and potentially mutating action counts, where only an explicit tool `annotations.readOnlyHint: true` is classified as non-mutating;
|
|
147
147
|
- recent bounded activity labels in completion order and image-output MIME/size metadata without retained base64 payloads;
|
|
148
148
|
- active elapsed time and turns against calculated budgets;
|
|
149
149
|
- context tokens, context window, percentage, and compaction counts;
|
|
@@ -209,8 +209,9 @@ Version 3 intentionally ignores the version 2 fields `maxTurns`, `timeoutSeconds
|
|
|
209
209
|
- A parent-operation abort stops the active worker stage.
|
|
210
210
|
- A paused lease eventually closes an abandoned worker.
|
|
211
211
|
- Session shutdown or extension reload disposes the child and runtime-controlled temporary files.
|
|
212
|
-
- Worker process failures reject pending RPC operations and
|
|
213
|
-
-
|
|
212
|
+
- Worker process failures reject pending RPC operations and revoke every in-flight manager proxy execution.
|
|
213
|
+
- A manager executor lease exists only while `delegate_*` start or `delegate_control` continuation is running; returning paused or terminal state aborts remaining proxied executions.
|
|
214
|
+
- Worker role instructions, the tool-proxy extension, and the supervision gate exist only in a runtime-controlled temporary directory.
|
|
214
215
|
- The selected native codemode-only extension may create runtime-temporary image outputs; the designer must persist requested outputs explicitly before completion.
|
|
215
216
|
- The worker uses `--no-session`; no worker session file is persisted.
|
|
216
217
|
|
|
@@ -223,7 +224,7 @@ npm run check
|
|
|
223
224
|
npm run test:gate
|
|
224
225
|
```
|
|
225
226
|
|
|
226
|
-
`check` runs static release invariants and deterministic fake-RPC lifecycle and renderer scenarios. The fake child verifies
|
|
227
|
+
`check` runs static release invariants and deterministic fake-RPC lifecycle and renderer scenarios. The fake child verifies exact manager capability grants, extension-defined tools, built-in-name manager overrides, transitive-call confinement, codemode-only loading, proxy streaming/results/usage stripping, images and structured content, concurrent manager execution, nonce/name/replay/paused-request rejection, continuation revalidation, cancellation, child-exit/session-shutdown cleanup, pause/resume, output-limit recovery, presentation compaction, and existing fail-closed lifecycle paths without a model request.
|
|
227
228
|
|
|
228
|
-
`test:gate` performs a small live model integration check with the active parent model exported by Pi through `PI_PROVIDER`, `PI_MODEL`, and `PI_REASONING_LEVEL`, falling back to
|
|
229
|
+
`test:gate` loads the release extension and performs a small live model integration check with the active parent model exported by Pi through `PI_PROVIDER`, `PI_MODEL`, and `PI_REASONING_LEVEL`, falling back to the first available model listed by Pi when those values are unavailable; it contains no provider assumption. Optional `PI_TASK_DISPATCHER_GATE_MODEL` and `PI_TASK_DISPATCHER_GATE_THINKING` overrides are available for explicit test matrices. The probe verifies generated native codemode-only loading, a codemode script calling `read` through the manager proxy exactly once, a private pause after that completed batch, and subsequent completion in the same in-memory child. It requires configured credentials and therefore is not a hermetic unit test.
|
|
229
230
|
|