pi-background-tasks 1.0.7 → 2.0.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.
- package/README.md +7 -7
- package/TESTING.md +3 -3
- package/TEST_PLAN.md +2 -2
- package/docs/INDEX.md +25 -25
- package/docs/choose-a-workflow.md +4 -4
- package/docs/commands/bg-clear.md +1 -1
- package/docs/commands/bg-update.md +1 -1
- package/docs/commands/bg.md +1 -1
- package/docs/commands/fusion-models.md +1 -1
- package/docs/commands/fusion.md +5 -8
- package/docs/commands/jobs.md +1 -1
- package/docs/commands/kill.md +1 -1
- package/docs/commands/logs.md +1 -1
- package/docs/commands/task-manager.md +2 -2
- package/docs/concepts/completion-delivery.md +1 -0
- package/docs/getting-started.md +1 -1
- package/docs/manifest.json +59 -50
- package/docs/read-before-edit.md +1 -0
- package/docs/reference/runtime-contracts.md +48 -45
- package/docs/reference/shortcuts-and-dock.md +2 -2
- package/docs/subsystems/background-task-runtime.md +7 -1
- package/docs/subsystems/docs-freshness-gate.md +4 -4
- package/docs/subsystems/fusion.md +13 -9
- package/docs/subsystems/host-ui-and-telemetry.md +1 -1
- package/docs/tools/bg_delegate.md +1 -1
- package/docs/tools/bg_kill.md +1 -1
- package/docs/tools/bg_logs.md +1 -1
- package/docs/tools/bg_result.md +14 -10
- package/docs/tools/bg_run.md +1 -1
- package/docs/tools/bg_run_pi_attested.md +1 -1
- package/docs/tools/bg_status.md +1 -1
- package/docs/tools/fusion_investigate.md +6 -4
- package/docs/tools/fusion_reason.md +5 -5
- package/docs/tools/fusion_research.md +6 -2
- package/docs/tools/fusion_validate.md +5 -3
- package/package.json +1 -1
- package/src/core/common.ts +50 -2
- package/src/core/fusion/artifacts.ts +72 -20
- package/src/core/fusion/orchestrator.ts +154 -68
- package/src/core/fusion/result-package.ts +385 -0
- package/src/core/fusion/types.ts +9 -0
- package/src/core/registry.ts +187 -20
- package/src/delegate-extension.ts +130 -24
- package/src/extension.ts +17 -6
- package/src/fusion-extension.ts +308 -154
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
| Fact | Value |
|
|
27
27
|
| --- | --- |
|
|
28
28
|
| Package | `pi-background-tasks` |
|
|
29
|
-
| Version | `
|
|
29
|
+
| Version | `2.0.0` |
|
|
30
30
|
| Node engine | `>=22.19.0` |
|
|
31
31
|
| Pi entrypoint | `./extensions/background-tasks.ts` |
|
|
32
32
|
| Package image | [logo.png](https://raw.githubusercontent.com/ismailsaleekh/pi-background-tasks/main/logo.png) |
|
|
@@ -123,13 +123,13 @@ Local paths are loaded from disk without copying; use the path to this package f
|
|
|
123
123
|
|
|
124
124
|
Call this with `bg_result`. Retrieval is hash-verified and never silently truncated.
|
|
125
125
|
|
|
126
|
-
6. For a self-contained synthesis,
|
|
126
|
+
6. For a self-contained synthesis, start Fusion in the background:
|
|
127
127
|
|
|
128
128
|
```json
|
|
129
129
|
{"prompt":"Compare the tradeoffs between a watcher, a one-shot build, and a delegated repo inspection for a large refactor."}
|
|
130
130
|
```
|
|
131
131
|
|
|
132
|
-
Call this with `fusion_reason`, or use `/fusion <prompt>` interactively.
|
|
132
|
+
Call this with `fusion_reason`, or use `/fusion <prompt>` interactively. The launch returns after durable preflight; wait for its terminal notification, then retrieve the verified result with `bg_result`.
|
|
133
133
|
|
|
134
134
|
More walkthrough detail: [Getting started](docs/getting-started.md).
|
|
135
135
|
|
|
@@ -142,10 +142,10 @@ More walkthrough detail: [Getting started](docs/getting-started.md).
|
|
|
142
142
|
| `bg_run` | No | No model child unless command starts one | Runs your shell command; **not sandboxed** | Agent-started long commands | Returns task id/output path; defaults to notification plus automatic follow-up wake. |
|
|
143
143
|
| `bg_delegate` + `bg_result` | No launch; retrieval is point-in-time | Frozen visible conversation projection | Inspect-only child: read, grep, find, ls, artifact read; no shell, writes, network, recursion | Context-aware read-only investigation while parent continues | Launch returns immediately; result is committed by child and hash-verified by retrieval. |
|
|
144
144
|
| `bg_run_pi_attested` | No | Prompt passed to one direct child Pi run | Direct `pi --mode json`; no shell command; writes requested report path | Evidence-oriented direct Pi task | Emits local attestation sidecar only after successful completion. |
|
|
145
|
-
| `/fusion` / `fusion_reason` |
|
|
146
|
-
| `fusion_investigate` |
|
|
147
|
-
| `fusion_research` |
|
|
148
|
-
| `fusion_validate` |
|
|
145
|
+
| `/fusion` / `fusion_reason` | Background launch; point-in-time `bg_result` retrieval | Versioned conversation projection plus prompt | Candidates/evaluator/repair/merger run with no tools | Self-contained reasoning and synthesis | Returns after durable preflight; three candidates → blind evaluator → optional bounded repair → merger. |
|
|
146
|
+
| `fusion_investigate` | Background launch; point-in-time `bg_result` retrieval | Clean task input only | Candidate read-only repo tools; evaluator/repair/merger no tools | Independent repo investigation | Restate needed facts; continue only independent work while the live repository is inspected. |
|
|
147
|
+
| `fusion_research` | Background launch; point-in-time `bg_result` retrieval | Clean task input only | Candidate read-only repo tools plus targeted fetch of caller-supplied public URLs only | URL-backed synthesis | Targeted URL retrieval, **not web search**. |
|
|
148
|
+
| `fusion_validate` | Background launch; point-in-time `bg_result` retrieval | Clean task input only | Advisory read-only validation review | Second-opinion review of completed work | Do not mutate the reviewed scope while it runs; not a substitute for mechanical gates. |
|
|
149
149
|
|
|
150
150
|
See [Choose a workflow](docs/choose-a-workflow.md) for a decision tree and tradeoffs.
|
|
151
151
|
|
package/TESTING.md
CHANGED
|
@@ -186,14 +186,14 @@ npm run test:rpc
|
|
|
186
186
|
npm run test:agent-loop
|
|
187
187
|
```
|
|
188
188
|
|
|
189
|
-
The Fusion SDK/RPC/scripted-provider tests install a deterministic fake child `pi` in a temp `PATH` from `tests/helpers/fusion-fake-pi.ts`. Parent Pi remains the real SDK/RPC runtime; only direct child `pi --mode text` calls with the package-owned private compact metadata extension are intercepted. `PI_CODING_AGENT_DIR` is pointed at the temp agent directory so `fusion-models.json` is never read from the user's real global Pi directory. Fusion v1 public-surface coverage asserts exactly four tools (`fusion_reason`, `fusion_investigate`, `fusion_research`, `fusion_validate`), no public capability argument, retired-tool active-tool removal, `/fusion` mapping to reason/no-tool candidates, closed schemas with Google-compatible enum status, targeted URL fetch not search, URL exfiltration warnings, strict validation verification rules, historical v4 rendering without old-tool activation, and actionable migration errors for `fusion_validate({prompt})`. Fusion context coverage covers both reason conversation projection and clean-task non-interference invariants, including parent-sentinel absence from every clean downstream prompt/artifact and byte-identical clean inputs across unrelated parent sessions. `tests/unit/fusion-context-prompts.test.ts` verifies that a synthetic session carrying more than 1 MB of tool arguments/results still yields a small canonical input, that user and assistant text survive verbatim, that thinking and tool payloads never appear (including no head/tail/preview sentinel), that omission counts, byte totals, and hashes are exact and stable, that repeated construction is byte-identical, that the active Fusion tool leaf and sibling calls stay scope-excluded, that images remain marker-only or ledger-only with no raw base64 in child prompts, and that every retained source block receives exactly one disposition. `tests/unit/fusion-high-cardinality.test.ts` covers the receipt-cardinality regression: a session of many short interleaved tool events (rather than a few enormous results) pins per-receipt cost, proves the compact `omitted_activity` fields are the only model-facing ones, reconciles every receipt against the ledger through `projection_map`, and proves the whole workflow fits a real route budget. `tests/unit/fusion-budget.test.ts` covers stage budgets: each route reserves the larger of Fusion's output contract and the model's declared maximum output, the limiting model is selected by conservative byte capacity (including when it is the evaluator rather than a candidate), unknown or too-small capacities fail before spawn, boundary prompts pass at exactly the limit and fail one byte past it, the child system prompt counts as input, dense multi-byte UTF-8 cannot bypass byte accounting, and candidate, evaluator, evaluation-repair, and merger expansions are each rejected before their child is spawned with zero partial launches. `tests/unit/fusion-pi-child.test.ts` covers the post-launch `fusion-runtime-guard.v1` protocol, exact final-payload measurement, 128-request/192-tool limits, malformed or duplicate evidence rejection, typed parent errors, and failed audit sealing. `tests/unit/fusion-claude-cache.test.ts` pins default one-hour Claude retention, explicit short/none/long policy, model compatibility fallback, non-mutation, no-marker compaction preservation, the four-breakpoint ceiling, and malformed-control refusal, and distinct `child_cache_policy_invalid` parent errors. Child metadata binds each requested/effective cache observation in `fusion-child-result.v3`. Terminal `fusion-child-settlement.v2` is published only at `agent_settled`; recovered non-final provider errors must be zero-content/zero-usage retry markers named by that settlement, and missing/duplicate/tampered/failed settlements or substantive error records remain fatal. `tests/scripted-provider/fusion-runtime-guard.test.ts` drives a real Pi agent loop through Pi's `openai-codex-responses` adapter against local HTTP and proves provider-payload transforms chain in load order and the governor's `ctx.abort()` prevents network transport. `tests/package/typebox-compat.test.ts` pins the TypeBox posture and compiles nullable-array schemas. The release-only `npm run test:compat` packs the package, installs exact supported Pi versions, runs `/jobs`, runs `/fusion` through the installed package entrypoint with the fake child Pi, verifies five child invocations, verifies `/fusion-models` rejects non-TUI mode, requires each supported Pi line to declare terminal `agent_settled` and `before_provider_request`, verifies the installed Anthropic adapter exposes cache breakpoints plus long/tool compatibility controls, asserts the resolved `typebox` is Pi's bundled peer rather than a private or nested copy, and scans the installed package bytes for TypeBox APIs removed in the 1.3.x line. Pi 0.75.5 is intentionally unsupported because it lacks the terminal event required to seal a Fusion audit after retries and compaction. It then drives the current host Pi through a real RPC `fusion_reason` parent-agent loop, checks the persisted tool result carries the complete Pi `Usage.cost` object, invokes `get_session_stats` (the same aggregation boundary used by the TUI footer), reopens the durable session, and verifies identical token/cost totals. All parent and child inference remains deterministic and local.
|
|
189
|
+
The Fusion SDK/RPC/scripted-provider tests install a deterministic fake child `pi` in a temp `PATH` from `tests/helpers/fusion-fake-pi.ts`. Parent Pi remains the real SDK/RPC runtime; only direct child `pi --mode text` calls with the package-owned private compact metadata extension are intercepted. SDK coverage proves the Fusion tools return after durable no-child preflight without waiting for delayed children, transfer cancellation ownership away from the completed tool call, remain tracked through status/dock/kill/notification, verify manifest-bound `result.json` plus `merged.md`, and attach complete usage on the first `bg_result` retrieval exactly once. The scripted provider proves launch → no-poll parent response → terminal wake → `bg_result` → verified answer. `PI_CODING_AGENT_DIR` is pointed at the temp agent directory so `fusion-models.json` is never read from the user's real global Pi directory. Fusion v1 public-surface coverage asserts exactly four tools (`fusion_reason`, `fusion_investigate`, `fusion_research`, `fusion_validate`), no public capability argument, retired-tool active-tool removal, `/fusion` mapping to reason/no-tool candidates, closed schemas with Google-compatible enum status, targeted URL fetch not search, URL exfiltration warnings, strict validation verification rules, historical v4 rendering without old-tool activation, and actionable migration errors for `fusion_validate({prompt})`. Fusion context coverage covers both reason conversation projection and clean-task non-interference invariants, including parent-sentinel absence from every clean downstream prompt/artifact and byte-identical clean inputs across unrelated parent sessions. `tests/unit/fusion-context-prompts.test.ts` verifies that a synthetic session carrying more than 1 MB of tool arguments/results still yields a small canonical input, that user and assistant text survive verbatim, that thinking and tool payloads never appear (including no head/tail/preview sentinel), that omission counts, byte totals, and hashes are exact and stable, that repeated construction is byte-identical, that the active Fusion tool leaf and sibling calls stay scope-excluded, that images remain marker-only or ledger-only with no raw base64 in child prompts, and that every retained source block receives exactly one disposition. `tests/unit/fusion-high-cardinality.test.ts` covers the receipt-cardinality regression: a session of many short interleaved tool events (rather than a few enormous results) pins per-receipt cost, proves the compact `omitted_activity` fields are the only model-facing ones, reconciles every receipt against the ledger through `projection_map`, and proves the whole workflow fits a real route budget. `tests/unit/fusion-budget.test.ts` covers stage budgets: each route reserves the larger of Fusion's output contract and the model's declared maximum output, the limiting model is selected by conservative byte capacity (including when it is the evaluator rather than a candidate), unknown or too-small capacities fail before spawn, boundary prompts pass at exactly the limit and fail one byte past it, the child system prompt counts as input, dense multi-byte UTF-8 cannot bypass byte accounting, and candidate, evaluator, evaluation-repair, and merger expansions are each rejected before their child is spawned with zero partial launches. `tests/unit/fusion-pi-child.test.ts` covers the post-launch `fusion-runtime-guard.v1` protocol, exact final-payload measurement, 128-request/192-tool limits, malformed or duplicate evidence rejection, typed parent errors, and failed audit sealing. `tests/unit/fusion-claude-cache.test.ts` pins default one-hour Claude retention, explicit short/none/long policy, model compatibility fallback, non-mutation, no-marker compaction preservation, the four-breakpoint ceiling, and malformed-control refusal, and distinct `child_cache_policy_invalid` parent errors. Child metadata binds each requested/effective cache observation in `fusion-child-result.v3`. Terminal `fusion-child-settlement.v2` is published only at `agent_settled`; recovered non-final provider errors must be zero-content/zero-usage retry markers named by that settlement, and missing/duplicate/tampered/failed settlements or substantive error records remain fatal. `tests/scripted-provider/fusion-runtime-guard.test.ts` drives a real Pi agent loop through Pi's `openai-codex-responses` adapter against local HTTP and proves provider-payload transforms chain in load order and the governor's `ctx.abort()` prevents network transport. `tests/package/typebox-compat.test.ts` pins the TypeBox posture and compiles nullable-array schemas. The release-only `npm run test:compat` packs the package, installs exact supported Pi versions, runs `/jobs`, runs `/fusion` through the installed package entrypoint with the fake child Pi, verifies five child invocations, verifies `/fusion-models` rejects non-TUI mode, requires each supported Pi line to declare terminal `agent_settled` and `before_provider_request`, verifies the installed Anthropic adapter exposes cache breakpoints plus long/tool compatibility controls, asserts the resolved `typebox` is Pi's bundled peer rather than a private or nested copy, and scans the installed package bytes for TypeBox APIs removed in the 1.3.x line. Pi 0.75.5 is intentionally unsupported because it lacks the terminal event required to seal a Fusion audit after retries and compaction. It then drives the current host Pi through a real RPC `fusion_reason` parent-agent loop, checks the persisted tool result carries the complete Pi `Usage.cost` object, invokes `get_session_stats` (the same aggregation boundary used by the TUI footer), reopens the durable session, and verifies identical token/cost totals. All parent and child inference remains deterministic and local.
|
|
190
190
|
|
|
191
191
|
## Coverage summary
|
|
192
192
|
|
|
193
193
|
Implemented coverage includes:
|
|
194
194
|
|
|
195
|
-
- tools: `bg_run`, `bg_run_pi_attested`, `bg_status`, `bg_logs`, `bg_kill`, `fusion_reason`, `fusion_investigate`, `fusion_research`, `fusion_validate`, including required `isAgent` schema/runtime validation, the event-driven no-sleep/no-poll system-prompt contract, truthful launch receipts for all four notification/wake combinations, non-terminating `bg_run` compatibility, point-in-time status/log guidance, durable terminal-notification authority, attested direct Pi spawn validation, Fusion
|
|
196
|
-
- commands: `/bg`, `/jobs`, `/logs`, `/kill`, `/tasks`, `/bg-tasks`, `/bg-clear`, `/bg-update`, `/fusion`, `/fusion-models` discovery, happy paths, `/fusion`
|
|
195
|
+
- tools: `bg_run`, `bg_run_pi_attested`, `bg_status`, `bg_logs`, `bg_kill`, `fusion_reason`, `fusion_investigate`, `fusion_research`, `fusion_validate`, including required `isAgent` schema/runtime validation, the event-driven no-sleep/no-poll system-prompt contract, truthful launch receipts for all four notification/wake combinations, non-terminating `bg_run` compatibility, point-in-time status/log guidance, durable terminal-notification authority, attested direct Pi spawn validation, Fusion immediate launch receipts, managed progress, hash-verified `bg_result` delivery, exactly-once usage, and context exclusion, reason versioned conversation projection with explicit hash-accounted tool/thinking omissions, clean-task context isolation, pre-spawn stage budget rejection for all four expansion stages, image omission markers with raw image data excluded from child prompts, unknown/ambiguous IDs, completed-kill failure, legacy no-name preparation, head/tail truncation, and notification on/off behavior
|
|
196
|
+
- commands: `/bg`, `/jobs`, `/logs`, `/kill`, `/tasks`, `/bg-tasks`, `/bg-clear`, `/bg-update`, `/fusion`, `/fusion-models` discovery, happy paths, `/fusion` non-blocking managed-task launch and terminal notification, `/fusion` editor/cancel flow, `/fusion-models` TUI save and non-TUI rejection, `/bg --agent` parsing, finished-notice clearing, malformed `/bg`, unknown/ambiguous IDs, completed-task `/kill`, byte-limit normalization, and RPC no-hang fallback behavior
|
|
197
197
|
- update-available notice: semver parse/compare/precedence, `formatUpdateSegment`, npm/`package.json` payload narrowing, and injected-fetch success/404/throw/timeout (unit); localhost-registry footer segment (idle + appended to an active footer), `/bg-update` non-installing instructions, and opt-out/offline/already-current/registry-failure no-segment-and-no-throw paths (SDK); `/bg-update` discovery and offline instructions (RPC). The check is one-shot on `session_start`, time-boxed, offline-safe, gated by `PI_OFFLINE`/`PI_BG_DISABLE_UPDATE_CHECK`, and `PI_BG_REGISTRY_URL` overrides the registry endpoint
|
|
198
198
|
- shortcut/UI: component coverage for focused dock list/detail/key handling, detail output-tail scrolling (arrow/page scroll, follow-pause-on-scroll, `lines X–Y of N` position indicator, resume-follow-at-bottom, and no-scroll when output fits), empty/history/unread states, paging, close aliases, stop/stop-all/rerun/path actions, missing output files; SDK coverage for explicit `/bg-clear` finished-notice clearing, `/bg-clear` footer hinting, optional `Ctrl+Alt+C` fallback shortcut registration, and mixed failed/stopped/done/focused footer status; RPC coverage that `/bg-clear` works as a terminal-independent clear path; and PTY coverage for `/tasks`, `/bg-tasks`, real `Shift+Down`, arrows, page keys, detail/back/history/stop/stop-all/rerun/path/close, failed unread badges, and running/completed/failed/killed rerun paths
|
|
199
199
|
- runtime files: output and metadata files under `.pi/tasks/`, Fusion private `.pi/fusion/<session-id>-<pid>/<run-id>/` artifacts plus global `fusion-models.json`, persisted `isAgent` classification, task-owned context-window telemetry snapshots, cumulative background Pi-agent token usage, tool-use counts, agent model identifier (preferring the fully-qualified `provider/model` form), explicit `isAgent:true` telemetry wrapping for background `pi` agents, `isAgent:false` non-wrapping for scripts, attested Pi flat siblings (`.pi-events.jsonl`, `.stderr`, `.pi-telemetry-wrapper.cjs`, `.attestation.json`), real child `pi --mode json` tool-event parsing for background-agent telemetry, split/large telemetry ingestion, metadata after completion/failure, Fusion v2 compact final-only metadata and explicitly marked partial-response artifacts, and Fusion manifest token plus complete cost-component aggregates equal to the sum of successful and observed failed/cancelled attempts
|
package/TEST_PLAN.md
CHANGED
|
@@ -74,8 +74,8 @@ SDK/RPC/scripted-provider/package/compatibility coverage asserts exactly four to
|
|
|
74
74
|
| Inspect task status | `bg_status` | | yes | | | | | yes | SDK uses exact IDs for deterministic lifecycle observations and verifies the model-facing contract calls status a point-in-time inspection rather than a wait primitive. Scripted-provider ordinary waiting makes zero status calls. |
|
|
75
75
|
| Read task logs | `bg_logs` | yes | yes | | | | | yes | SDK verifies bounded content and the model-facing no-wait-loop contract. Scripted-provider ordinary waiting makes zero log calls. |
|
|
76
76
|
| Stop task from LLM tool | `bg_kill` | | yes | | | | | | Covers running kill and already-finished loud failure. |
|
|
77
|
-
| Fusion command
|
|
78
|
-
| Fusion v1
|
|
77
|
+
| Fusion command background launch | `/fusion`, managed task, terminal notification, `bg_result` | yes | yes | yes | | yes | yes | | Core unit covers deterministic projection, child argv/stdin/metadata parsing, artifacts, pre-abort handling, and orchestration. SDK verifies `/fusion` returns after durable preflight, all five child invocations continue in the managed task, terminal notification is emitted without a parent rewrite, editor/cancel behavior remains correct, and malformed config launches zero children. RPC verifies command discovery, Unicode request preservation, background terminal delivery, no parent `agent_start`, editor protocol, malformed-config admission failure, child failure notification, and child isolation flags. |
|
|
78
|
+
| Fusion v1 background result | `fusion_reason`, `fusion_investigate`, `fusion_research`, `fusion_validate`, `bg_result` | yes | yes | | | current-host stats/replay | yes | yes | Exactly four workflow tools remain registered; each returns a managed-task receipt after durable no-child preflight. `bg_result` verifies manifest-bound `result.json`/`merged.md`, never truncates, and attaches complete `Usage` exactly once. SDK pins non-blocking launch under delayed children, tool-signal ownership handoff, clean-context isolation, failure coordinates, shutdown cancellation, and repeated-retrieval no-double-counting. Scripted-provider coverage proves no polling between launch and terminal wake. |
|
|
79
79
|
| Fusion Anthropic child sanitization | `@ravshansbox/pi-anthropic-sps` dependency, child `--extension` argv | yes | | | | | yes | | Unit proves a Claude route receives exactly two `--extension` paths with the sanitizer first and the package runtime governor/metadata extension second, so final provider-payload measurement occurs after sanitization; every non-Anthropic provider still receives exactly one and never resolves the sanitizer at all, and that the real installed package resolves to an existing file through its manifest `pi.extensions[0]`. Resolution failures are each pinned as loud errors: package unresolvable, manifest unreadable, manifest not JSON, missing `pi` section, empty `pi.extensions`, blank entry, and a declared file that does not exist. Package guards require the sanitizer to be a declared dependency and require the provider gate so non-Anthropic child argv cannot drift. |
|
|
80
80
|
| Fusion validation workflow | structured `fusion_validate`, workflow profiles, `fusion-manifest.v4`, `fusion-result.v5` | yes | yes | | | | yes | | Public validation rejects legacy `{prompt}` with a migration error, enforces non-empty `scope`/`acceptanceCriteria`, and loudly validates `verification` cross-fields (`provided` ↔ evidence, `not_run` ↔ reason). Core validate orchestration is clean/read-only/advisory, enforces source-finding accounting including singleton, duplicate, exclusion, and merger add/drop cases, and remains no build/test substitute claim. |
|
|
81
81
|
| Fusion context boundaries | canonical input `fusion-input.v5`, reason `context-omission-ledger.json`, clean-task inputs | yes | yes | yes | | | yes | | Unit covers reason/session projection for a >1 MB synthetic tool-heavy session, verbatim user/assistant text, thinking exclusion, zero tool-payload preview bytes, exact and stable omission counts/byte totals/hashes, compact tuple round-trip, receipt-to-ledger reconciliation, active-tool-call-leaf and sibling-call exclusion, and byte-identical repeated construction. Clean-task tests assert investigate/research/validate inputs omit parent system prompt, conversation projection, and omission ledger, stay byte-identical across unrelated parent sessions, and keep parent sentinels out of every clean downstream prompt and artifact. SDK/RPC verify clean validate stdin has no `conversation_projection` or transcript while `/fusion`/reason preserve the projected-conversation path. |
|
package/docs/INDEX.md
CHANGED
|
@@ -125,31 +125,31 @@ Generated navigation for every package-local documentation page. This index inte
|
|
|
125
125
|
|
|
126
126
|
| Kind | Name | ID | Provenance |
|
|
127
127
|
| --- | --- | --- | --- |
|
|
128
|
-
| command | `bg` | `command:bg` | `src/extension.ts:
|
|
129
|
-
| command | `bg-clear` | `command:bg-clear` | `src/extension.ts:
|
|
130
|
-
| command | `bg-tasks` | `command:bg-tasks` | `src/extension.ts:
|
|
131
|
-
| command | `bg-update` | `command:bg-update` | `src/extension.ts:
|
|
132
|
-
| command | `fusion` | `command:fusion` | `src/fusion-extension.ts:
|
|
133
|
-
| command | `fusion-models` | `command:fusion-models` | `src/fusion-extension.ts:
|
|
134
|
-
| command | `jobs` | `command:jobs` | `src/extension.ts:
|
|
135
|
-
| command | `kill` | `command:kill` | `src/extension.ts:
|
|
136
|
-
| command | `logs` | `command:logs` | `src/extension.ts:
|
|
137
|
-
| command | `tasks` | `command:tasks` | `src/extension.ts:
|
|
138
|
-
| tool | `bg_delegate` | `tool:bg_delegate` | `src/delegate-extension.ts:
|
|
139
|
-
| tool | `bg_kill` | `tool:bg_kill` | `src/extension.ts:
|
|
140
|
-
| tool | `bg_logs` | `tool:bg_logs` | `src/extension.ts:
|
|
141
|
-
| tool | `bg_result` | `tool:bg_result` | `src/delegate-extension.ts:
|
|
142
|
-
| tool | `bg_run` | `tool:bg_run` | `src/extension.ts:
|
|
143
|
-
| tool | `bg_run_pi_attested` | `tool:bg_run_pi_attested` | `src/extension.ts:
|
|
144
|
-
| tool | `bg_status` | `tool:bg_status` | `src/extension.ts:
|
|
145
|
-
| tool | `fusion_investigate` | `tool:fusion_investigate` | `src/fusion-extension.ts:
|
|
146
|
-
| tool | `fusion_reason` | `tool:fusion_reason` | `src/fusion-extension.ts:
|
|
147
|
-
| tool | `fusion_research` | `tool:fusion_research` | `src/fusion-extension.ts:
|
|
148
|
-
| tool | `fusion_validate` | `tool:fusion_validate` | `src/fusion-extension.ts:
|
|
149
|
-
| shortcut | `ctrl+alt+c` | `shortcut:ctrl+alt+c` | `src/extension.ts:
|
|
150
|
-
| shortcut | `shift+down` | `shortcut:shift+down` | `src/extension.ts:
|
|
151
|
-
| renderer | `background-task-notification` | `renderer:background-task-notification` | `src/extension.ts:
|
|
152
|
-
| renderer | `fusion-result` | `renderer:fusion-result` | `src/fusion-extension.ts:
|
|
128
|
+
| command | `bg` | `command:bg` | `src/extension.ts:517` |
|
|
129
|
+
| command | `bg-clear` | `command:bg-clear` | `src/extension.ts:559` |
|
|
130
|
+
| command | `bg-tasks` | `command:bg-tasks` | `src/extension.ts:551` |
|
|
131
|
+
| command | `bg-update` | `command:bg-update` | `src/extension.ts:567` |
|
|
132
|
+
| command | `fusion` | `command:fusion` | `src/fusion-extension.ts:996` |
|
|
133
|
+
| command | `fusion-models` | `command:fusion-models` | `src/fusion-extension.ts:1029` |
|
|
134
|
+
| command | `jobs` | `command:jobs` | `src/extension.ts:605` |
|
|
135
|
+
| command | `kill` | `command:kill` | `src/extension.ts:649` |
|
|
136
|
+
| command | `logs` | `command:logs` | `src/extension.ts:618` |
|
|
137
|
+
| command | `tasks` | `command:tasks` | `src/extension.ts:543` |
|
|
138
|
+
| tool | `bg_delegate` | `tool:bg_delegate` | `src/delegate-extension.ts:292` |
|
|
139
|
+
| tool | `bg_kill` | `tool:bg_kill` | `src/extension.ts:908` |
|
|
140
|
+
| tool | `bg_logs` | `tool:bg_logs` | `src/extension.ts:863` |
|
|
141
|
+
| tool | `bg_result` | `tool:bg_result` | `src/delegate-extension.ts:453` |
|
|
142
|
+
| tool | `bg_run` | `tool:bg_run` | `src/extension.ts:682` |
|
|
143
|
+
| tool | `bg_run_pi_attested` | `tool:bg_run_pi_attested` | `src/extension.ts:767` |
|
|
144
|
+
| tool | `bg_status` | `tool:bg_status` | `src/extension.ts:832` |
|
|
145
|
+
| tool | `fusion_investigate` | `tool:fusion_investigate` | `src/fusion-extension.ts:1197` |
|
|
146
|
+
| tool | `fusion_reason` | `tool:fusion_reason` | `src/fusion-extension.ts:1179` |
|
|
147
|
+
| tool | `fusion_research` | `tool:fusion_research` | `src/fusion-extension.ts:1216` |
|
|
148
|
+
| tool | `fusion_validate` | `tool:fusion_validate` | `src/fusion-extension.ts:1236` |
|
|
149
|
+
| shortcut | `ctrl+alt+c` | `shortcut:ctrl+alt+c` | `src/extension.ts:597` |
|
|
150
|
+
| shortcut | `shift+down` | `shortcut:shift+down` | `src/extension.ts:590` |
|
|
151
|
+
| renderer | `background-task-notification` | `renderer:background-task-notification` | `src/extension.ts:426` |
|
|
152
|
+
| renderer | `fusion-result` | `renderer:fusion-result` | `src/fusion-extension.ts:980` |
|
|
153
153
|
| eventbus | `background-task-v1` | `eventbus:background-task-v1` | `src/core/extension-api.ts` |
|
|
154
154
|
| workflow | `investigate` | `workflow:investigate` | `src/core/fusion/workflows.ts:80` |
|
|
155
155
|
| workflow | `reason` | `workflow:reason` | `src/core/fusion/workflows.ts:61` |
|
|
@@ -26,10 +26,10 @@ covers_sources: []
|
|
|
26
26
|
| `bg_run` | Async | None by package | Command decides | Command decides | Command decides | Not a model route unless command invokes one | Pi should launch a long command and resume later. |
|
|
27
27
|
| `bg_delegate` + `bg_result` | Async launch, point-in-time retrieval | Frozen visible conversation projection | Yes, inspect-only | No | No | Pinned at launch; no substitution | Context-aware read-only investigation. |
|
|
28
28
|
| `bg_run_pi_attested` | Async | Prompt only | Child Pi decides from prompt/tools | Child Pi route/tools decide | Report path requested | Structured provider/model; OAuth observed for supported subscription routes | Local evidence-producing Pi run. |
|
|
29
|
-
| `fusion_reason` / `/fusion` |
|
|
30
|
-
| `fusion_investigate` |
|
|
31
|
-
| `fusion_research` |
|
|
32
|
-
| `fusion_validate` |
|
|
29
|
+
| `fusion_reason` / `/fusion` | Async launch, point-in-time `bg_result` retrieval | Versioned conversation projection plus prompt | No | No | No | Configured Fusion slots; no silent fallback | Self-contained reasoning/synthesis. |
|
|
30
|
+
| `fusion_investigate` | Async launch, point-in-time `bg_result` retrieval | Clean task input only | Candidate read-only tools | No | No | Configured Fusion slots; no silent fallback | Independent repository investigation. |
|
|
31
|
+
| `fusion_research` | Async launch, point-in-time `bg_result` retrieval | Clean task input only | Candidate read-only tools | Only declared public URLs | No | Configured Fusion slots; no silent fallback | Targeted URL-backed synthesis, not search. |
|
|
32
|
+
| `fusion_validate` | Async launch, point-in-time `bg_result` retrieval | Clean task input only | Candidate read-only tools | No | No | Configured Fusion slots; no silent fallback | Advisory review of completed work. |
|
|
33
33
|
|
|
34
34
|
## Tradeoffs and boundaries
|
|
35
35
|
|
|
@@ -12,7 +12,7 @@ covers_sources: []
|
|
|
12
12
|
<!-- pi-docs:begin name="command-contract-bg-clear" generator="scripts/docs/generate.mjs" -->
|
|
13
13
|
| Command | Description | Provenance |
|
|
14
14
|
| --- | --- | --- |
|
|
15
|
-
| `/bg-clear` | Clear finished background task footer notices | `src/extension.ts:
|
|
15
|
+
| `/bg-clear` | Clear finished background task footer notices | `src/extension.ts:559` |
|
|
16
16
|
<!-- pi-docs:end name="command-contract-bg-clear" -->
|
|
17
17
|
|
|
18
18
|
Clear finished background task footer notices.
|
|
@@ -12,7 +12,7 @@ covers_sources: []
|
|
|
12
12
|
<!-- pi-docs:begin name="command-contract-bg-update" generator="scripts/docs/generate.mjs" -->
|
|
13
13
|
| Command | Description | Provenance |
|
|
14
14
|
| --- | --- | --- |
|
|
15
|
-
| `/bg-update` | Show how to update pi-background-tasks to the latest published version | `src/extension.ts:
|
|
15
|
+
| `/bg-update` | Show how to update pi-background-tasks to the latest published version | `src/extension.ts:567` |
|
|
16
16
|
<!-- pi-docs:end name="command-contract-bg-update" -->
|
|
17
17
|
|
|
18
18
|
Show update instructions for `pi-background-tasks`.
|
package/docs/commands/bg.md
CHANGED
|
@@ -12,7 +12,7 @@ covers_sources: []
|
|
|
12
12
|
<!-- pi-docs:begin name="command-contract-bg" generator="scripts/docs/generate.mjs" -->
|
|
13
13
|
| Command | Description | Provenance |
|
|
14
14
|
| --- | --- | --- |
|
|
15
|
-
| `/bg` | Start a shell command as a tracked background task: /bg [--agent] [--name "Task name"] <command> | `src/extension.ts:
|
|
15
|
+
| `/bg` | Start a shell command as a tracked background task: /bg [--agent] [--name "Task name"] <command> | `src/extension.ts:517` |
|
|
16
16
|
<!-- pi-docs:end name="command-contract-bg" -->
|
|
17
17
|
|
|
18
18
|
Start a shell command as a tracked background task from the command line.
|
|
@@ -12,7 +12,7 @@ covers_sources: []
|
|
|
12
12
|
<!-- pi-docs:begin name="command-contract-fusion-models" generator="scripts/docs/generate.mjs" -->
|
|
13
13
|
| Command | Description | Provenance |
|
|
14
14
|
| --- | --- | --- |
|
|
15
|
-
| `/fusion-models` | Open the five-slot global fusion model selector. | `src/fusion-extension.ts:
|
|
15
|
+
| `/fusion-models` | Open the five-slot global fusion model selector. | `src/fusion-extension.ts:1029` |
|
|
16
16
|
<!-- pi-docs:end name="command-contract-fusion-models" -->
|
|
17
17
|
|
|
18
18
|
Open the global Fusion model selector.
|
package/docs/commands/fusion.md
CHANGED
|
@@ -12,7 +12,7 @@ covers_sources: []
|
|
|
12
12
|
<!-- pi-docs:begin name="command-contract-fusion" generator="scripts/docs/generate.mjs" -->
|
|
13
13
|
| Command | Description | Provenance |
|
|
14
14
|
| --- | --- | --- |
|
|
15
|
-
| `/fusion` |
|
|
15
|
+
| `/fusion` | Start fixed-purpose Fusion reason in the background and return immediately. | `src/fusion-extension.ts:996` |
|
|
16
16
|
<!-- pi-docs:end name="command-contract-fusion" -->
|
|
17
17
|
|
|
18
18
|
Run the fixed-purpose Fusion **reason** workflow from the command line.
|
|
@@ -47,20 +47,17 @@ Reason/session-projection input uses schema `pi-background-tasks.fusion-input.v5
|
|
|
47
47
|
|
|
48
48
|
Omitted payload bytes are not summarized or previewed for the children. If a fact exists only inside omitted tool output, restate it in the prompt.
|
|
49
49
|
|
|
50
|
-
##
|
|
50
|
+
## Background result delivery
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
`/fusion` freezes its reason input, completes durable no-child preflight, registers a managed background task, and returns control immediately. It does not hold a loader open or append a premature result message. The footer dock, `/jobs`, `bg_status`, `bg_logs`, and `bg_kill` operate on the tracked run.
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
2. a visible `fusion-result` record whose content is the merger's exact text and whose details include run id, artifact directory, model summary, usage/cost, evaluator-attempt count, and budget metadata.
|
|
56
|
-
|
|
57
|
-
In TUI mode `/fusion` uses a cancellable loader. Cancelling aborts the active child process tree and records a cancelled run when a run directory exists.
|
|
54
|
+
On terminal state the command emits the standard background-task notification without automatically starting a model turn. Retrieve the verified answer with `bg_result({taskId})`; running retrieval is non-blocking, and oversized results become artifact references rather than truncation.
|
|
58
55
|
|
|
59
56
|
## Calls and failure shape
|
|
60
57
|
|
|
61
58
|
A successful run uses three candidate children, one blind evaluator, and one merger. If the first evaluator response is invalid JSON or violates the closed evaluation schema, Fusion performs exactly one evaluator-repair attempt before failing or continuing. Therefore a successful run may have five or six child invocations; preflight failures launch zero children, and candidate/evaluator/merge failures stop the workflow rather than substituting another model.
|
|
62
59
|
|
|
63
|
-
|
|
60
|
+
Admission failures are reported immediately as `Fusion failed: ...`; prompt-budget forecast failures happen before child creation. Failures after the receipt become terminal failed tasks whose notification and `bg_result` error preserve stage coordinates and artifact directory. Child cancellation, timeout, output caps, model-route admission failures, invalid evaluator JSON after repair, invalid compact child metadata, and invalid tool-call audits remain loud failures.
|
|
64
61
|
|
|
65
62
|
## Related
|
|
66
63
|
|
package/docs/commands/jobs.md
CHANGED
|
@@ -12,7 +12,7 @@ covers_sources: []
|
|
|
12
12
|
<!-- pi-docs:begin name="command-contract-jobs" generator="scripts/docs/generate.mjs" -->
|
|
13
13
|
| Command | Description | Provenance |
|
|
14
14
|
| --- | --- | --- |
|
|
15
|
-
| `/jobs` | List running and recent background tasks | `src/extension.ts:
|
|
15
|
+
| `/jobs` | List running and recent background tasks | `src/extension.ts:605` |
|
|
16
16
|
<!-- pi-docs:end name="command-contract-jobs" -->
|
|
17
17
|
|
|
18
18
|
List running and recent background tasks.
|
package/docs/commands/kill.md
CHANGED
|
@@ -12,7 +12,7 @@ covers_sources: []
|
|
|
12
12
|
<!-- pi-docs:begin name="command-contract-kill" generator="scripts/docs/generate.mjs" -->
|
|
13
13
|
| Command | Description | Provenance |
|
|
14
14
|
| --- | --- | --- |
|
|
15
|
-
| `/kill` | Stop a running background task: /kill <id> | `src/extension.ts:
|
|
15
|
+
| `/kill` | Stop a running background task: /kill <id> | `src/extension.ts:649` |
|
|
16
16
|
<!-- pi-docs:end name="command-contract-kill" -->
|
|
17
17
|
|
|
18
18
|
Stop a running background task.
|
package/docs/commands/logs.md
CHANGED
|
@@ -12,7 +12,7 @@ covers_sources: []
|
|
|
12
12
|
<!-- pi-docs:begin name="command-contract-logs" generator="scripts/docs/generate.mjs" -->
|
|
13
13
|
| Command | Description | Provenance |
|
|
14
14
|
| --- | --- | --- |
|
|
15
|
-
| `/logs` | Show bounded output from a background task: /logs <id> [maxBytes] | `src/extension.ts:
|
|
15
|
+
| `/logs` | Show bounded output from a background task: /logs <id> [maxBytes] | `src/extension.ts:618` |
|
|
16
16
|
<!-- pi-docs:end name="command-contract-logs" -->
|
|
17
17
|
|
|
18
18
|
Show bounded output from a background task.
|
|
@@ -12,8 +12,8 @@ covers_sources: []
|
|
|
12
12
|
<!-- pi-docs:begin name="command-contract-tasks-bg-tasks" generator="scripts/docs/generate.mjs" -->
|
|
13
13
|
| Command | Description | Provenance |
|
|
14
14
|
| --- | --- | --- |
|
|
15
|
-
| `/tasks` | Open the Claude-like background task manager UI | `src/extension.ts:
|
|
16
|
-
| `/bg-tasks` | Open the background task manager UI | `src/extension.ts:
|
|
15
|
+
| `/tasks` | Open the Claude-like background task manager UI | `src/extension.ts:543` |
|
|
16
|
+
| `/bg-tasks` | Open the background task manager UI | `src/extension.ts:551` |
|
|
17
17
|
<!-- pi-docs:end name="command-contract-tasks-bg-tasks" -->
|
|
18
18
|
|
|
19
19
|
Open the interactive background task manager. `/tasks` and `/bg-tasks` are aliases.
|
|
@@ -25,6 +25,7 @@ Background tasks can finish silently, notify the terminal, or notify and wake th
|
|
|
25
25
|
- `/bg` is display-only by default: it sets `notifyOnCompletion:true` and `triggerOnCompletion:false`.
|
|
26
26
|
- `bg_run` defaults to durable notification plus follow-up turn: `notifyOnCompletion:true` and `triggerOnCompletion:true`.
|
|
27
27
|
- `bg_status` and `bg_logs` are point-in-time inspection tools, not polling primitives.
|
|
28
|
+
- Tool-launched Fusion tasks default to notification plus follow-up wake and are retrieved once with `bg_result`; `/fusion` uses notification-only.
|
|
28
29
|
- A received `<background-task-notification>` is metadata-backed terminal-status truth. The output stream has finished/closed, but ordinary `.output` bytes are not explicitly fsynced. Do not call `bg_status` only to reconfirm status; call `bg_logs` only if output bytes are needed.
|
|
29
30
|
|
|
30
31
|
## Notification payload
|
package/docs/getting-started.md
CHANGED
|
@@ -113,7 +113,7 @@ Call this with `fusion_reason`, or use:
|
|
|
113
113
|
/fusion Compare a foreground command, bg_run, and bg_delegate for a ten-minute repository audit.
|
|
114
114
|
```
|
|
115
115
|
|
|
116
|
-
Fusion runs three candidates, blind evaluation, optional bounded repair only if evaluator JSON is invalid, and merger. `/fusion` and `fusion_reason` receive a versioned conversation projection; investigate/research/validate receive clean task input only.
|
|
116
|
+
Fusion returns a tracked background-task receipt after durable no-child preflight. It then runs three candidates, blind evaluation, optional bounded repair only if evaluator JSON is invalid, and merger. Wait for the terminal notification and call `bg_result` once; do not poll. `/fusion` and `fusion_reason` receive a versioned conversation projection; investigate/research/validate receive clean task input only.
|
|
117
117
|
|
|
118
118
|
## Next links
|
|
119
119
|
|