pi-goal-delegate 0.1.0 → 0.3.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/CHANGELOG.md CHANGED
@@ -4,6 +4,152 @@ All notable changes to this package are recorded here. The format follows
4
4
  [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the project uses
5
5
  [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [0.3.1] - 2026-12-02
8
+
9
+ The tool surface and the waiting model changed. A caller that passed `wait` or
10
+ `inlineSettleMs`, or called `delegate_list`, needs one edit; everything else
11
+ keeps working.
12
+
13
+ ### Changed
14
+
15
+ - **`delegate_start` waits for the outcome by default.** `wait` defaults to
16
+ `true`, and the wait is bounded by the run's own `timeoutMinutes` instead of by
17
+ a separate knob. Every recorded delegation ran longer than 60 seconds (median
18
+ 1102 s), so a synchronous caller could never see a result and was pushed into
19
+ cross-turn polling. Inline completion is now the ordinary path in `codemode`,
20
+ in a fan-out, and under `/goal`; `wait: false` is the deliberate background
21
+ opt-in.
22
+ - **The wait ceiling is the delegation budget.** `MAX_WAIT_MS` follows
23
+ `MAX_TIMEOUT_MINUTES` (4 hours) instead of 50 seconds, for both the inline
24
+ window and `delegate_status.waitMs`. A `codemode` script accepts
25
+ `timeout_ms` up to 2^31-1, so the old 50-second cap was a limit this package
26
+ invented and then enforced against its own callers.
27
+ - **Four tools instead of five.** `delegate_list` folded into
28
+ `delegate_status`, which lists when called with no `runIds` and waits when
29
+ given one. `delegate_start` exposes seven top-level parameters instead of
30
+ eighteen: `goal`, `doneWhen`, `verify`, `context`, `wait`, `worktree`, and
31
+ an `options` object for the budget, model, scope, and resume knobs. The
32
+ declared output schema is a compact projection: the four declarations measure
33
+ 8,223 characters on the same metric that measured 20,257 for the five they
34
+ replace.
35
+ - **`inlineSettleMs` is gone from the tool schema.** One knob decides the mode,
36
+ and the run's own `timeoutMinutes` decides the ceiling: a call can never wait
37
+ longer than the delegation it waits for. `wait: false` returns the handle as
38
+ soon as the run is admitted; any later wait is
39
+ `delegate_status({ runIds, waitMs })`.
40
+ - **`/goal` guidance is unconditional and exact.** When `delegate_start`
41
+ returns a live handle it reads the active goal id from the session and prints
42
+ the `goal_wait` call that pauses Goal mode until `delegate-completion`
43
+ arrives, instead of a paragraph of advice.
44
+
45
+ ### Fixed
46
+
47
+ - **Trusted publishing uses a capable npm CLI.** The release job installs npm
48
+ 11 before publishing. Node 22's bundled npm 10 required an interactive login
49
+ instead of exchanging GitHub's OIDC token, so the first tag stopped at
50
+ `ENEEDAUTH` before any package version was published.
51
+ - **A settle is claimed only by an active caller.** `delegate_start` and
52
+ `delegate_status` leave every settle that races an abort on the completion
53
+ channel. A `codemode` hard deadline can discard a nested return value even
54
+ when the child settled during the abort, so redelivery is safer than a lost
55
+ outcome; an active caller still claims the settle it reports.
56
+ - **The progress callback cannot read a handle that does not exist yet.**
57
+ `registry.start({ onProgress })` passes the run id to the callback, so the
58
+ callback no longer closes over the `const handle` that `await start()` has not
59
+ assigned. The one real call in the 24 November session crashed Pi with exactly
60
+ that temporal-dead-zone read.
61
+ - **A near-miss argument starts the run.** A known option name passed at the top
62
+ level instead of inside `options` is lifted before validation, so `timeoutMinutes`
63
+ is not a schema error.
64
+ - **The run-root probe measures the path a start actually uses.** A missing
65
+ root is checked through its nearest existing ancestor, a symlink to a writable
66
+ directory is accepted, and the probe uses a unique exclusive file. Existing
67
+ files are never truncated, and a failed create, write, close or unlink fails
68
+ the check instead of letting a read-only root pass.
69
+ - **`/delegate` takes its output sink as a dependency.** The print-mode path wrote
70
+ to `process.stdout` directly, so the command suite had to replace that stream to
71
+ read what it wrote; in a test runner that reports over the same stream, every
72
+ result produced while the replacement was installed vanished. Seven tests ran
73
+ without being reported. `DelegateCommandOptions.write` replaces the module-level
74
+ stream, and no suite patches `process.stdout` any more.
75
+
76
+ ### Added
77
+
78
+ - **`/delegate doctor`.** One check per line for the parts that fail silently:
79
+ the extension path and package manifest, run-root existence and writability,
80
+ the child launcher, git, live runs, the retention plan, the configured limits,
81
+ the session mode, and the containment mode. The same run-root check runs at
82
+ `session_start` and warns instead of failing days later.
83
+ - **A reported retention plan.** `scanRetention()` answers what the next prune
84
+ would remove and why, without deleting anything.
85
+ - **`delegate_status` reports the run root** and the record count when the
86
+ session has no runs, so an agent can tell "nothing has run" from "the record
87
+ root moved".
88
+ - **`/delegate --wait` and `/delegate --background`** select the mode the command
89
+ otherwise derives from the session: TUI returns a handle, print mode waits.
90
+ - `tests/surface.test.mjs`: the four-tool surface, the schema size budget, option
91
+ hoisting, the inline default, the `goal_wait` text, and the `onProgress`
92
+ contract.
93
+
94
+ [0.3.1]: https://github.com/Zhuocheng-Lang/pi-goal-delegate/compare/v0.2.0...v0.3.1
95
+
96
+ ## [0.2.0] - 2026-12-01
97
+
98
+ ### Added
99
+
100
+ - **Structured results.** `delegate_start({ resultSchema })` and a third
101
+ `delegate_complete(summary, evidence, result)` argument give a codemode
102
+ orchestrator a validated JSON value instead of prose it has to parse. The value
103
+ is capped at 64,000 characters, and a rejection names the failing instance path
104
+ and the reason, so the repair is one call rather than a guess.
105
+ - **An admission audit for that schema.** A `resultSchema` that no value could
106
+ satisfy - an unresolved local `$ref`, a reference into a document this package
107
+ cannot reach, a shape TypeBox cannot evaluate - is refused at `delegate_start`,
108
+ where the caller can still fix the contract, instead of failing every completion
109
+ claim the child has no way to repair.
110
+ - **Nested delegation.** `maxDepth` (0-3) and `/delegate --depth` let a child
111
+ decompose its own goal. Depth, spend and deadline attenuate down the tree: one
112
+ `attenuationRefusal` in `contract.ts` answers for every entry point, and a
113
+ child's goal prompt reports the minutes the run actually has rather than the
114
+ minutes its parent asked for.
115
+ - **Worktree integration.** A worktree run's outcome carries `integration`: HEAD,
116
+ dirty status with git's positional columns intact, diff statistics, an
117
+ applicable `changes.patch` covering committed, tracked-uncommitted and untracked
118
+ work, and the result of `git apply --check` against the original repository.
119
+ `applyCommand` is the explicit integration path; nothing is committed or merged
120
+ automatically.
121
+ - **`control.jsonl`.** Compact turn, usage, cost, text and breaker records beside
122
+ the capped raw log, so a 32 MiB payload cap can no longer blind the parent's
123
+ budgets or its no-progress enforcement. The stream decodes statefully: a chunk
124
+ that splits a multi-byte character no longer corrupts the last text or a call
125
+ signature, and a final line without a newline is still folded.
126
+ - `/delegate` adds `--depth` and `--schema`.
127
+
128
+ ### Changed
129
+
130
+ - **`verify` gates the completion claim instead of auditing it afterwards.** It
131
+ runs inside the live child at `delegate_complete`: a failure returns the command
132
+ output to the child for repair, and only a passing claim terminates the run. A
133
+ cancelled or expired run does not start the check at all. The parent then
134
+ independently re-runs the same command under the same `PI_DELEGATE_ENV_DROP`
135
+ policy, and `childVerification` keeps the two records apart.
136
+ - **Steering is delivered as `steer` at `turn_start`** instead of being held
137
+ until `agent_settled`, where a child that was already done could miss it.
138
+ - **A resume continues the checkout.** Resuming a worktree-backed run reuses that
139
+ worktree instead of moving back to the shared tree, and records `resumedFrom`.
140
+ Retention removes a clean checkout through `git worktree remove` and preserves a
141
+ dirty or shared one, including the checkout of a run that never sealed.
142
+ - **An ordinary completion carries the whole outcome** within a 24,000-character
143
+ budget, so the parent does not spend a second call on what it already has. The
144
+ compact form keeps `summary`, `evidence` and `needs` as the distinct fields
145
+ they are.
146
+
147
+ ### Fixed
148
+
149
+ - The parent observes the shared circuit breakers from the child's stream, and
150
+ admission slots are reserved synchronously, so a concurrent `Promise.all` cannot
151
+ start more children than the live limit allows.
152
+
7
153
  ## [0.1.0] - 2026-12-01
8
154
 
9
155
  First published release under the package name `pi-goal-delegate`. It replaces
@@ -151,4 +297,5 @@ so there is no `[Unreleased]` section to merge forward.
151
297
  environment is still inherited by default, because a provider key in it is how
152
298
  the child authenticates.
153
299
 
300
+ [0.2.0]: https://github.com/Zhuocheng-Lang/pi-goal-delegate/compare/v0.1.0...v0.2.0
154
301
  [0.1.0]: https://github.com/Zhuocheng-Lang/pi-goal-delegate/releases/tag/v0.1.0