pi-background-tasks 1.0.7 → 2.1.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 +8 -8
- package/TESTING.md +3 -3
- package/TEST_PLAN.md +6 -6
- 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 +69 -50
- package/docs/operations/configuration.md +5 -3
- package/docs/read-before-edit.md +3 -0
- package/docs/reference/runtime-contracts.md +87 -82
- 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 +5 -5
- package/docs/subsystems/fusion.md +22 -15
- 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/anthropic-attribution.ts +1930 -0
- package/src/core/fusion/artifacts.ts +168 -21
- package/src/core/fusion/budget.ts +23 -23
- package/src/core/fusion/child-protocol.ts +115 -10
- package/src/core/fusion/claude-cache.ts +21 -0
- package/src/core/fusion/config.ts +10 -2
- package/src/core/fusion/orchestrator.ts +281 -77
- package/src/core/fusion/output-contract.ts +34 -0
- package/src/core/fusion/pi-child.ts +420 -12
- package/src/core/fusion/prompts.ts +11 -1
- package/src/core/fusion/result-package.ts +412 -0
- package/src/core/fusion/types.ts +67 -0
- package/src/core/registry.ts +187 -20
- package/src/delegate-extension.ts +130 -24
- package/src/extension.ts +17 -6
- package/src/fusion-child-extension.ts +117 -2
- 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 | `1.
|
|
29
|
+
| Version | `2.1.1` |
|
|
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
|
|
|
@@ -291,7 +291,7 @@ Agent tasks launched through `pi -p ...` or `pi --mode json ...` and marked `isA
|
|
|
291
291
|
- Shell jobs are tracked by the package, but they are not sandboxed. Treat commands as local processes with your permissions and credentials.
|
|
292
292
|
- Delegate and Fusion child Pi processes are route-pinned where applicable; delegate/Fusion paths do not silently substitute routes.
|
|
293
293
|
- Fusion uses direct child `pi --mode text` processes, not direct completion APIs. Frontier Fusion routes are admitted only through Pi Anthropic or Codex subscription OAuth; metered frontier API credentials are rejected before child creation.
|
|
294
|
-
- Claude Fusion children
|
|
294
|
+
- Claude Fusion children load the package-owned Claude Code OAuth attribution provider shared with the repo spawn path, request `ttl: "1h"` on system/tool/conversation cache breakpoints before serialization, and preserve provider-reported `cacheWrite1h` evidence. Set `PI_CACHE_RETENTION=short|none|long` to choose explicitly; malformed attribution, policy, or cache evidence fails before transport. Provider usage is preserved verbatim, but subscription OAuth can report `cacheWrite1h = 0` even when a unique cache remains readable beyond five minutes; treat positive `cacheWrite1h` as definitive and zero as inconclusive on that channel. Anthropic budgeting follows the provider's 200K subscription policy.
|
|
295
295
|
- Fusion research fetches only caller-supplied public `http(s)` URLs with bounded retrieval. It is not web search and not a secret-exfiltration boundary.
|
|
296
296
|
- Attestation sidecars are local, unsigned, same-user-writable evidence. They are useful for downstream local gates, but not cryptographic proof against local compromise, a compromised Pi binary, or a compromised provider.
|
|
297
297
|
- Metadata, attestations, delegate/Fusion artifacts, and configuration replacements use write/fsync/rename durability patterns. Ordinary task output is closed and drained before terminal publication but is not explicitly fsynced. POSIX directory entries are fsynced after atomic replacement; Windows lacks the same portable directory-entry crash-durability guarantee.
|
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
|
|
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 and stage-local refusal wording; orchestrator coverage derives terminal run progress from durable attempts after usage persistence so late evaluator/merge refusal reports completed, failed, cancelled, and not-started truth instead of claiming zero children. 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 native pre-serialization `ttl: "1h"` requests, explicit short/none/long policy, call-level compaction opt-out, model compatibility fallback, non-mutation, the four-breakpoint ceiling, subscription prompt-caching-scope beta idempotence, malformed-control refusal, and distinct `child_cache_policy_invalid` parent errors. Child argv tests pin the shared attribution provider → sanitizer → runtime-governor order; root attribution tests pin linked OAuth account/device/session metadata, beta-resource request shape, cache surfaces, one-hour provider usage pricing, and the 200K subscription policy. Compact/result usage tests preserve Anthropic `cacheWrite1h` and provider `reasoning` subsets, and child metadata binds each requested/effective payload observation plus JSON-rendered output accounting in `fusion-child-result.v4`. Live subscription-OAuth acceptance on 2026-08-04 proved cold writes plus exact-repeat reads on Sonnet 4.5 and Opus 5 while both reported `cacheWrite1h = 0`. Separate normal-spawn and exact Fusion-child Opus 5 controls—with unique prompts—still read their caches after 370 idle seconds; the Fusion control wrote and reread 9,922 tokens through the attribution → sanitizer → governor path. Documentation therefore treats positive `cacheWrite1h` as definitive but zero as inconclusive on subscription OAuth; payload intent, provider itemization, and behavioral lifetime remain separate evidence. Terminal `fusion-child-settlement.v3` is published only at `agent_settled`; recovered non-final provider errors must be zero-content/zero-usage retry markers named by that settlement, and one non-final candidate `stop` is accepted only when it is a hash-bound oversized original immediately followed by a same-session replacement. `tests/scripted-provider/fusion-output-recovery.test.ts` drives a real Pi print-mode process and proves one PID/session context, one queued continuation before settlement, tool removal on turn two, original-artifact preservation, and replacement-only stdout. 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,15 +74,15 @@ 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
|
|
79
|
-
| Fusion Anthropic
|
|
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
|
+
| Fusion Anthropic attribution and sanitization | package-owned `anthropic-attribution.ts`, `@ravshansbox/pi-anthropic-sps`, child `--extension` argv | yes | | | | | yes | | Unit proves a Claude route receives exactly three explicit extensions in fixed order: the package-owned Claude Code OAuth attribution provider, sanitizer, then runtime governor/metadata extension. The repo-local `spawn-anthropic-attribution` entrypoint re-exports the same implementation. Attribution tests pin linked session/account/device metadata, exact model beta policy, beta-resource transport, cache surfaces, one-hour pricing, and the 200K subscription contract; the governor therefore measures the final attributed and sanitized payload. Every non-Anthropic provider still receives exactly one extension and resolves neither Claude dependency. Resolution failures remain loud, and package guards require the sanitizer dependency plus provider gate. |
|
|
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. |
|
|
82
|
-
| Fusion stage budgets | `budget-plan.json` (v4 per-stage forecasts), typed `prompt_budget_exceeded_forecast` / `prompt_budget_exceeded_measured` | yes | | | | | | | Unit covers the per-family affine estimator, additive segment accounting, multibyte 1.0-token/byte charging, unknown-provider floor visibility, per-route reservation of `max(Fusion output contract, model maximum output)`, byte-capacity route selection, scope guards for small windows, input-only fatal preflight versus warning-only reservations, rejection of unknown/zero/negative/too-small context windows, boundary accept at exactly the limit and reject one byte past, the child system prompt counted as input, per-stage forecasts built from the real prompt builders against each stage's own route, reservation warnings, breach-detector artifacts, safe prompts completing all five calls, persisted route/plan snapshots including negative slack on fatal rejection, and the reproduced 1 MB failure shape now fitting the smallest configured budget. Errors carry stage, measured size, allowed size, limiting model, estimator source, and remediation in both structured detail and message text. |
|
|
82
|
+
| Fusion stage budgets | `budget-plan.json` (v4 per-stage forecasts), typed `prompt_budget_exceeded_forecast` / `prompt_budget_exceeded_measured` | yes | | | | | | | Unit covers stage-local launch-refusal wording plus terminal progress derived from durable attempts and persisted usage, so late evaluator/repair/merger budget failures report completed, failed, cancelled, and not-started run truth. Unit also covers the per-family affine estimator, additive segment accounting, multibyte 1.0-token/byte charging, unknown-provider floor visibility, per-route reservation of `max(Fusion output contract, model maximum output)`, byte-capacity route selection, scope guards for small windows, input-only fatal preflight versus warning-only reservations, rejection of unknown/zero/negative/too-small context windows, boundary accept at exactly the limit and reject one byte past, the child system prompt counted as input, per-stage forecasts built from the real prompt builders against each stage's own route, reservation warnings, breach-detector artifacts, safe prompts completing all five calls, persisted route/plan snapshots including negative slack on fatal rejection, and the reproduced 1 MB failure shape now fitting the smallest configured budget. Errors carry stage, measured size, allowed size, limiting model, estimator source, and remediation in both structured detail and message text. |
|
|
83
83
|
| Fusion fixed-purpose profiles | `/fusion`, `fusion_reason`, `fusion_investigate`, `fusion_research`, `fusion_validate`, candidate child argv | yes | yes | yes | | | yes | | Public surface has no caller-selected capability. SDK/RPC pin `/fusion` to reason/no-tool candidates; investigate is read-only, research is targeted URL fetch with public http(s) source validation, and evaluator/merger remain no-tools by stage policy. Package guards reject extra keys and verify schemas are closed. |
|
|
84
84
|
| Fusion research web fetch | `fusion_web_fetch({ url, extract? })`, `candidate-<slot>.attempt-<n>.tool-calls.jsonl` | yes | | | | | yes | live child | Unit covers the closed schema surface through the child extension, registration only when research mode is enabled, unsupported schemes and URL credentials failing before network access, blocked DNS classes, a mixed public-plus-blocked DNS answer failing loudly, a redirect to a blocked address failing loudly, redirect-loop limit failure, Content-Length and streamed-body response caps, unsupported content types, Markdown extraction preserving links/headings/tables/code blocks, script/style stripping, text/plain passthrough with hash and byte count, UTF-8-safe output truncation, and typed timeout. Unit also proves the resolver is consulted once and the connection is pinned to that vetted address, undeclared research URLs are rejected before fetch with only the attempted URL hash audited, and that audit metadata records `url`, `final_url`, `http_status`, `response_bytes`, and `content_sha256` without raw page content. Package guards require `fusion_web_fetch` registration behind the research env flag. Live verification fetched `https://example.com/`, reported the page H1, read a repository constant, and refused instruction-like text from both a repo file and the fetched page. |
|
|
85
|
-
| Fusion multi-message transcript validation | `*.events.jsonl`, `fusion-child-settlement.
|
|
85
|
+
| Fusion multi-message transcript validation | `*.events.jsonl`, `fusion-child-result.v4`, `fusion-child-settlement.v3`, stop reasons `toolUse`/`stop` plus recovered retry/output-cap markers | yes | | | | | | real Pi print mode | Unit accepts a multi-message tool loop, validates increasing cache-observation request ordinals, reconstructs stdout from the final assistant message only, and sums usage across all compact metadata records. Terminal `agent_settled` emits exactly one settlement binding ordered record bytes/count/final hash. Non-final `toolUse` remains normal; non-final `error` is accepted only when it has zero content and usage, is followed by final `stop`, and its ordinal is hash-bound in the settlement. Exactly one non-final `stop` is accepted only as a hash-bound candidate response over 49,152 JSON-rendered bytes immediately followed by its same-session replacement. A real Pi print-mode characterization proves the queued continuation remains in one PID/conversation, disables tools, delays settlement, and outputs only the replacement. Final/non-zero errors, unbound non-final `stop`, `length`, `aborted`, `pending`, missing/duplicate/tampered/failed settlements, and pre-settlement shutdown fail loudly. |
|
|
86
86
|
| Fusion runtime context governor | `pi-background-tasks.fusion-runtime-guard.v1`, typed `child_runtime_budget_exceeded` | yes | | | | | | scripted provider | Unit proves every exact final provider payload is serialized, hashed, and conservatively estimated against `contextWindow - max(32,768, model.maxTokens) - 4,096`; request 128/tool call 192 are allowed and the next is refused; malformed/duplicate frames and clean-looking post-refusal output fail closed; parent errors preserve observed usage. A real local-HTTP Pi loop through the production `openai-codex-responses` adapter proves earlier payload transforms reach the later governor and `ctx.abort()` prevents network transport. |
|
|
87
87
|
| Fusion stale-action watchdog | `FUSION_CHILD_IDLE_TIMEOUT_MS`, child process lifecycle | yes | | | | | | | Unit proves a child with no stdout or stderr activity fails as `child_timeout` with the stalled-child message and is terminated; stderr activity resets the watchdog and allows success; the 30-minute absolute timeout path remains distinct and is not reported as a stalled child. |
|
|
88
88
|
| Fusion candidate tool-call audit log | `candidate-<slot>.attempt-<n>.tool-calls.jsonl`, `*.seal.json`, `pi-background-tasks.fusion-tool-call.v1` | yes | | | | | | | Unit proves completed tool calls are logged with tool name, byte counts, and hashes while raw arguments/results containing a secret never appear. Children are independently bounded to 192 attempted tool calls and 8 MiB aggregate tool-result bytes; a limit refusal emits structured evidence, aborts, and cannot publish a complete seal. Repeated low-level `agent_end` boundaries publish no seal; terminal `agent_settled` exclusively seals the complete log after all retry/compaction/follow-up work. The 46-call incident regression proves a 22-call prefix is never sealed and duplicate settlement fails without replacement. Shutdown before settlement writes failed evidence and latches process failure. The parent rejects extension diagnostics and missing/failed/mismatched seals and independently rejects aggregate result bytes above 8 MiB. A trailing partial line, ordinal gap, duplicate ordinal, wrong schema version, and inspect-child partial log all fail loudly. |
|
|
@@ -96,7 +96,7 @@ SDK/RPC/scripted-provider/package/compatibility coverage asserts exactly four to
|
|
|
96
96
|
| Delegate isolation boundary | child argv, `--session-id`, `--session-dir`, `--tools` | yes | yes | | | | mutation guard | yes | Unit proves the child receives its own session id and a task-owned session directory, no `--continue`/`--resume`/`--session`/`--fork`, only the inspect tool set, an explicit denylist covering `bash`/`edit`/`write`/`bg_delegate` and all current/retired Fusion tools, disabled discovery of extensions/skills/prompt templates/themes/context files, exactly one explicitly loaded package guard extension, explicit provider/model with no `--api-key`, and parent session identity stripped from the child environment. SDK verifies the same facts from the argv and environment the child actually observed. |
|
|
97
97
|
| Fusion artifact byte immutability | `canonical-input.json`, `context-omission-ledger.json`, `budget-plan.json` | yes | | | | | shared-source guard | | A 28-case differential corpus is rendered to raw bytes and compared against a committed golden file that is never auto-updated once present, and separately against `tests/oracle/fusion-context-pre-extraction.ts`, a verbatim pre-extraction copy of the projection engine used as an **independent oracle**. Equivalence covers canonical input, ledger, and budget-plan bytes, `Object.is` comparison of budget floats including `utilization`, field-for-field accounting parity, ledger root hashes, and identical error type and message for unknown blocks and blank requests. The package guard now scans the shared `context/` modules, not only the Fusion facade, and pins both the shared divisor definition and Fusion's binding to it. |
|
|
98
98
|
| Fusion model selector | `/fusion-models`, `fusion-models.json`, `FusionModelSelector` | yes | yes | yes | yes | yes | yes | | Unit covers strict config parsing, duplicates, slash-containing model IDs, stale model failures, `$current`, atomic save, inter-process lock/revision compare-and-swap, and deterministic concurrent-save conflict. Component covers all five slots, duplicate selection, searchable model list, stale display, reset/save/cancel, persistence errors, and width safety. SDK drives the real command in a synthetic TUI context without `ctx.mode` to cover old Pi compatibility and verifies duplicate `$current`/explicit model persistence; SDK also verifies headless no-UI rejection. RPC verifies non-TUI notification without hanging, PTY verifies the real selector opens in a TUI, and compatibility smoke verifies print-mode rejection for every supported Pi version. |
|
|
99
|
-
| Fusion child isolation/lifecycle | child `pi --mode text`, private compact metadata extension, shutdown cleanup, `.pi/fusion` artifacts | yes | yes | yes | | current-host stats/replay | yes |
|
|
99
|
+
| Fusion child isolation/lifecycle | child `pi --mode text`, private compact metadata extension, shutdown cleanup, `.pi/fusion` artifacts | yes | yes | yes | | current-host stats/replay | yes | real Pi output recovery | BUG-180 coverage proves final-text transport, reasoning exclusion, strict response reconstruction, unchanged caps, isolation, process cleanup, failure artifacts, and lifecycle semantics. Candidate prompts disclose the exact 49,152 JSON-rendered-byte cap. One oversized candidate answer is durably preserved and receives one same-process/session, same-route, tool-disabled compression follow-up before terminal settlement; a second oversize fails without truncation or another child. Unit coverage pins success, second-oversize failure, validation JSON, cancellation, usage, artifact hashing/tampering, and original/replacement artifacts; scripted-provider coverage proves the real Pi print-mode lifecycle. BUG-182 preserves all token and cost components—including optional `cacheWrite1h` and `reasoning` subsets—and proves successful plus failed/cancelled attempt costs aggregate exactly once. Claude cache coverage pins native pre-serialization `ttl: "1h"` requests, explicit short/none/long and call-level-none precedence, model fallback, no-marker compaction preservation, four-breakpoint enforcement, attribution→sanitizer→normalizer ordering, prompt-caching-scope beta idempotence, 200K attributed route capacity, and hash-bound payload observations plus provider-authoritative `cacheWrite1h` usage in child-result v4/settlement v3 artifacts. SDK/RPC verify public child isolation; session shutdown tracks initializing and live runs. |
|
|
100
100
|
| Extension request/response service | `pi-background-tasks:request:v1` → `pi-background-tasks:response:v1` | yes | yes | | | | yes | | Unit covers closed-frame validation, capability handshake, unknown keys, unknown operation, duplicate request IDs, missing `session_start`, shutdown refusal, strict `run.payload`, strict malformed frames, and unsubscribe. SDK loads the real extension with a shared `createEventBus()`, starts `printf api-ok`, reads bounded logs, lists status, starts and kills a real sleep task, and checks malformed/unknown/duplicate controls without model/provider calls. Package tests assert `src/core/extension-api.ts` ships. |
|
|
101
101
|
| Terminal EventBus publication | `pi-background-tasks:terminal:v1` | yes | yes | | | | yes | | Registry unit proves one terminal snapshot after durable metadata when EventBus emit succeeds and loud/retriable delivery failure. Because retry after a listener throws may redeliver to an earlier listener, consumers must deduplicate by task id. Extension API unit proves one strict terminal frame correlated by task id after the run response for immediate, normal, failed, timeout, and killed tasks; SDK observes one terminal event for a completed task and one for a killed task through the real extension service. |
|
|
102
102
|
| Completion notification | custom message `background-task-notification` | yes | yes | | renderer via typecheck | | | yes | BUG-181 unit/SDK coverage pins the durable-terminal guidance and truthful effective delivery receipts. Scripted provider loads the shipped extension, conditionally attempts the old `bg_status` poll when the real system prompt/descriptions/receipt are incomplete, and proves the fixed contract instead yields with exactly one `bg_run`, one terminal notification, and one default follow-up. Notification-only, notification-disabled, failed-task, and display-only `/bg` paths remain covered. |
|
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
|
|