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
|
@@ -16,51 +16,53 @@ This generated registry lists production environment-variable references, runtim
|
|
|
16
16
|
|
|
17
17
|
| Name | Access | Provenance |
|
|
18
18
|
| --- | --- | --- |
|
|
19
|
-
| `ANTHROPIC_API_KEY` | remove | `src/core/attested-pi-run.ts:135`<br>`src/core/fusion/pi-child.ts:
|
|
20
|
-
| `ANTHROPIC_AUTH_TOKEN` | remove | `src/core/fusion/pi-child.ts:
|
|
21
|
-
| `ANTHROPIC_BASE_URL` | remove | `src/core/attested-pi-run.ts:135`<br>`src/core/fusion/pi-child.ts:
|
|
22
|
-
| `AZURE_OPENAI_AD_TOKEN` | remove | `src/core/fusion/pi-child.ts:
|
|
23
|
-
| `AZURE_OPENAI_API_KEY` | remove | `src/core/fusion/pi-child.ts:
|
|
24
|
-
| `AZURE_OPENAI_API_VERSION` | remove | `src/core/fusion/pi-child.ts:
|
|
25
|
-
| `AZURE_OPENAI_BASE_URL` | remove | `src/core/fusion/pi-child.ts:
|
|
26
|
-
| `AZURE_OPENAI_DEPLOYMENT_NAME_MAP` | remove | `src/core/fusion/pi-child.ts:
|
|
27
|
-
| `AZURE_OPENAI_ENDPOINT` | remove | `src/core/fusion/pi-child.ts:
|
|
28
|
-
| `AZURE_OPENAI_RESOURCE_NAME` | remove | `src/core/fusion/pi-child.ts:
|
|
29
|
-
| `ComSpec` | read | `src/core/common.ts:
|
|
30
|
-
| `OPENAI_API_KEY` | remove | `src/core/attested-pi-run.ts:135`<br>`src/core/fusion/pi-child.ts:
|
|
31
|
-
| `OPENAI_BASE_URL` | remove | `src/core/attested-pi-run.ts:135`<br>`src/core/fusion/pi-child.ts:
|
|
32
|
-
| `OPENROUTER_API_KEY` | remove | `src/core/attested-pi-run.ts:135`<br>`src/core/fusion/pi-child.ts:
|
|
33
|
-
| `OPENROUTER_BASE_URL` | remove | `src/core/attested-pi-run.ts:135`<br>`src/core/fusion/pi-child.ts:
|
|
34
|
-
| `path` | read | `src/core/common.ts:
|
|
35
|
-
| `Path` | read | `src/core/common.ts:
|
|
36
|
-
| `PATH` | read | `src/core/common.ts:
|
|
37
|
-
| `PI_API_BASE_URL` | remove | `src/core/attested-pi-run.ts:135`<br>`src/core/fusion/pi-child.ts:
|
|
38
|
-
| `PI_API_KEY` | remove | `src/core/attested-pi-run.ts:135`<br>`src/core/fusion/pi-child.ts:
|
|
39
|
-
| `PI_AUTH_FILE` | remove | `src/core/attested-pi-run.ts:135`<br>`src/core/fusion/pi-child.ts:
|
|
19
|
+
| `ANTHROPIC_API_KEY` | remove | `src/core/attested-pi-run.ts:135`<br>`src/core/fusion/pi-child.ts:100` |
|
|
20
|
+
| `ANTHROPIC_AUTH_TOKEN` | remove | `src/core/fusion/pi-child.ts:100` |
|
|
21
|
+
| `ANTHROPIC_BASE_URL` | remove | `src/core/attested-pi-run.ts:135`<br>`src/core/fusion/pi-child.ts:100` |
|
|
22
|
+
| `AZURE_OPENAI_AD_TOKEN` | remove | `src/core/fusion/pi-child.ts:100` |
|
|
23
|
+
| `AZURE_OPENAI_API_KEY` | remove | `src/core/fusion/pi-child.ts:100` |
|
|
24
|
+
| `AZURE_OPENAI_API_VERSION` | remove | `src/core/fusion/pi-child.ts:100` |
|
|
25
|
+
| `AZURE_OPENAI_BASE_URL` | remove | `src/core/fusion/pi-child.ts:100` |
|
|
26
|
+
| `AZURE_OPENAI_DEPLOYMENT_NAME_MAP` | remove | `src/core/fusion/pi-child.ts:100` |
|
|
27
|
+
| `AZURE_OPENAI_ENDPOINT` | remove | `src/core/fusion/pi-child.ts:100` |
|
|
28
|
+
| `AZURE_OPENAI_RESOURCE_NAME` | remove | `src/core/fusion/pi-child.ts:100` |
|
|
29
|
+
| `ComSpec` | read | `src/core/common.ts:725`<br>`src/core/common.ts:736` |
|
|
30
|
+
| `OPENAI_API_KEY` | remove | `src/core/attested-pi-run.ts:135`<br>`src/core/fusion/pi-child.ts:100` |
|
|
31
|
+
| `OPENAI_BASE_URL` | remove | `src/core/attested-pi-run.ts:135`<br>`src/core/fusion/pi-child.ts:100` |
|
|
32
|
+
| `OPENROUTER_API_KEY` | remove | `src/core/attested-pi-run.ts:135`<br>`src/core/fusion/pi-child.ts:100` |
|
|
33
|
+
| `OPENROUTER_BASE_URL` | remove | `src/core/attested-pi-run.ts:135`<br>`src/core/fusion/pi-child.ts:100` |
|
|
34
|
+
| `path` | read | `src/core/common.ts:680` |
|
|
35
|
+
| `Path` | read | `src/core/common.ts:680` |
|
|
36
|
+
| `PATH` | read | `src/core/common.ts:680` |
|
|
37
|
+
| `PI_API_BASE_URL` | remove | `src/core/attested-pi-run.ts:135`<br>`src/core/fusion/pi-child.ts:100` |
|
|
38
|
+
| `PI_API_KEY` | remove | `src/core/attested-pi-run.ts:135`<br>`src/core/fusion/pi-child.ts:100` |
|
|
39
|
+
| `PI_AUTH_FILE` | remove | `src/core/attested-pi-run.ts:135`<br>`src/core/fusion/pi-child.ts:100` |
|
|
40
40
|
| `PI_BG_DELEGATE_ARTIFACT_DIR` | read, write | `src/core/delegate/launch.ts:324`<br>`src/delegate-child-extension.ts:277` |
|
|
41
41
|
| `PI_BG_DELEGATE_LAUNCH_NONCE` | read, write | `src/core/delegate/launch.ts:328`<br>`src/delegate-child-extension.ts:281` |
|
|
42
42
|
| `PI_BG_DELEGATE_SEED_PATH` | read, write | `src/core/delegate/launch.ts:325`<br>`src/delegate-child-extension.ts:278` |
|
|
43
43
|
| `PI_BG_DELEGATE_SEED_SHA256` | read, write | `src/core/delegate/launch.ts:326`<br>`src/delegate-child-extension.ts:279` |
|
|
44
44
|
| `PI_BG_DELEGATE_TASK_ID` | read, write | `src/core/delegate/launch.ts:327`<br>`src/delegate-child-extension.ts:280` |
|
|
45
|
-
| `PI_BG_DISABLE_PI_TELEMETRY` | read | `src/core/registry.ts:
|
|
46
|
-
| `PI_BG_DISABLE_UPDATE_CHECK` | read | `src/extension.ts:
|
|
47
|
-
| `PI_BG_MAX_OUTPUT_BYTES` | read | `src/core/registry.ts:
|
|
48
|
-
| `PI_BG_REGISTRY_URL` | read | `src/extension.ts:
|
|
49
|
-
| `PI_BG_SHELL` | read | `src/core/common.ts:
|
|
50
|
-
| `PI_BG_SHELL_PATH` | read | `src/core/common.ts:
|
|
51
|
-
| `PI_CACHE_RETENTION` | read | `src/core/fusion/claude-cache.ts:
|
|
52
|
-
| `
|
|
53
|
-
| `
|
|
54
|
-
| `
|
|
55
|
-
| `
|
|
56
|
-
| `
|
|
57
|
-
| `
|
|
58
|
-
| `
|
|
59
|
-
| `
|
|
60
|
-
| `
|
|
61
|
-
| `
|
|
62
|
-
| `
|
|
63
|
-
| `
|
|
45
|
+
| `PI_BG_DISABLE_PI_TELEMETRY` | read | `src/core/registry.ts:194` |
|
|
46
|
+
| `PI_BG_DISABLE_UPDATE_CHECK` | read | `src/extension.ts:455` |
|
|
47
|
+
| `PI_BG_MAX_OUTPUT_BYTES` | read | `src/core/registry.ts:68` |
|
|
48
|
+
| `PI_BG_REGISTRY_URL` | read | `src/extension.ts:464` |
|
|
49
|
+
| `PI_BG_SHELL` | read | `src/core/common.ts:721` |
|
|
50
|
+
| `PI_BG_SHELL_PATH` | read | `src/core/common.ts:722` |
|
|
51
|
+
| `PI_CACHE_RETENTION` | read, write | `src/core/fusion/anthropic-attribution.ts:577`<br>`src/core/fusion/claude-cache.ts:57`<br>`src/core/fusion/pi-child.ts:273`<br>`src/core/fusion/pi-child.ts:274` |
|
|
52
|
+
| `PI_FUSION_CANDIDATE_OUTPUT_RECOVERY_PATH` | read, remove, write | `src/core/fusion/pi-child.ts:100`<br>`src/core/fusion/pi-child.ts:2060`<br>`src/fusion-child-extension.ts:707` |
|
|
53
|
+
| `PI_FUSION_RESEARCH_ENABLED` | read, remove, write | `src/core/fusion/pi-child.ts:100`<br>`src/core/fusion/pi-child.ts:2083`<br>`src/fusion-child-extension.ts:716` |
|
|
54
|
+
| `PI_FUSION_SOURCE_POLICY_PATH` | read, remove, write | `src/core/fusion/pi-child.ts:100`<br>`src/core/fusion/pi-child.ts:2084`<br>`src/fusion-child-extension.ts:663` |
|
|
55
|
+
| `PI_FUSION_SOURCE_POLICY_SHA256` | read, remove, write | `src/core/fusion/pi-child.ts:100`<br>`src/core/fusion/pi-child.ts:2085`<br>`src/fusion-child-extension.ts:664` |
|
|
56
|
+
| `PI_FUSION_TOOL_CALL_LOG_PATH` | read, remove, write | `src/core/fusion/pi-child.ts:100`<br>`src/core/fusion/pi-child.ts:2072`<br>`src/fusion-child-extension.ts:706` |
|
|
57
|
+
| `PI_MODEL` | remove | `src/core/delegate/launch.ts:301`<br>`src/core/fusion/pi-child.ts:100` |
|
|
58
|
+
| `PI_OFFLINE` | read | `src/extension.ts:456` |
|
|
59
|
+
| `PI_PROVIDER` | remove | `src/core/delegate/launch.ts:301`<br>`src/core/fusion/pi-child.ts:100` |
|
|
60
|
+
| `PI_REASONING_LEVEL` | remove | `src/core/delegate/launch.ts:301`<br>`src/core/fusion/pi-child.ts:100` |
|
|
61
|
+
| `PI_SESSION_FILE` | remove | `src/core/delegate/launch.ts:301`<br>`src/core/fusion/pi-child.ts:100` |
|
|
62
|
+
| `PI_SESSION_ID` | remove | `src/core/delegate/launch.ts:301`<br>`src/core/fusion/pi-child.ts:100` |
|
|
63
|
+
| `PI_SKIP_VERSION_CHECK` | write | `src/core/delegate/launch.ts:323`<br>`src/core/fusion/pi-child.ts:272` |
|
|
64
|
+
| `PIPELINE_ANTHROPIC_ATTRIBUTION_AUDIT_PATH` | read | `src/core/fusion/anthropic-attribution.ts:1003` |
|
|
65
|
+
| `SHELL` | read | `src/core/common.ts:717` |
|
|
64
66
|
| `SystemRoot` | read | `src/core/windows-taskkill.ts:96` |
|
|
65
67
|
| `WINDIR` | read | `src/core/windows-taskkill.ts:101` |
|
|
66
68
|
|
|
@@ -68,7 +70,7 @@ This generated registry lists production environment-variable references, runtim
|
|
|
68
70
|
|
|
69
71
|
| Kind | Path/artifact | Provenance |
|
|
70
72
|
| --- | --- | --- |
|
|
71
|
-
| config | `fusion-models.json` | `src/core/fusion/config.ts:
|
|
73
|
+
| config | `fusion-models.json` | `src/core/fusion/config.ts:21` |
|
|
72
74
|
| delegate-artifact | `budget-plan.json` | `src/core/delegate/artifacts.ts:42` |
|
|
73
75
|
| delegate-artifact | `child-prompt.txt` | `src/core/delegate/artifacts.ts:46` |
|
|
74
76
|
| delegate-artifact | `child.stderr.txt` | `src/core/delegate/artifacts.ts:47` |
|
|
@@ -81,29 +83,30 @@ This generated registry lists production environment-variable references, runtim
|
|
|
81
83
|
| delegate-artifact | `seed.json` | `src/core/delegate/artifacts.ts:40` |
|
|
82
84
|
| delegate-artifact | `spill/<receipt-named-file>` | `src/core/delegate/artifacts.ts:53` |
|
|
83
85
|
| directory | `.pi/delegate/<session-id>-<pid>/<task-id>/` | `src/core/delegate/artifacts.ts:157` |
|
|
84
|
-
| directory | `.pi/fusion/<session-id>-<pid>/<run-id>/` | `src/core/fusion/artifacts.ts:
|
|
85
|
-
| directory | `.pi/tasks/<session-id>-<pid>/` | `src/core/registry.ts:
|
|
86
|
-
| fusion-artifact | `<attempt-prefix> = candidate-<slot>.attempt-<n> \| evaluation.attempt-<n> \| merge.attempt-<n>` | `src/core/fusion/artifacts.ts:
|
|
87
|
-
| fusion-artifact | `<attempt-prefix>.calibration-violation.json` | `src/core/fusion/artifacts.ts:
|
|
88
|
-
| fusion-artifact | `<attempt-prefix>.events.jsonl` | `src/core/fusion/artifacts.ts:
|
|
89
|
-
| fusion-artifact | `<attempt-prefix>.prompt.txt` | `src/core/fusion/artifacts.ts:
|
|
90
|
-
| fusion-artifact | `<attempt-prefix>.stderr.txt` | `src/core/fusion/artifacts.ts:
|
|
91
|
-
| fusion-artifact | `blind-candidates.json` | `src/core/fusion/artifacts.ts:
|
|
92
|
-
| fusion-artifact | `budget-plan.json` | `src/core/fusion/artifacts.ts:
|
|
93
|
-
| fusion-artifact | `candidate-<slot>.attempt-<n>.response.md \| candidate-<slot>.attempt-<n>.response.partial.md` | `src/core/fusion/artifacts.ts:
|
|
94
|
-
| fusion-artifact | `candidate-<slot>.attempt-<n>.tool-calls.jsonl` | `src/core/fusion/artifacts.ts:
|
|
95
|
-
| fusion-artifact | `candidate-<slot>.attempt-<n>.tool-calls.jsonl.seal.json` | `src/core/fusion/child-protocol.ts:
|
|
96
|
-
| fusion-artifact | `canonical-input.json` | `src/core/fusion/artifacts.ts:
|
|
97
|
-
| fusion-artifact | `context-omission-ledger.json` | `src/core/fusion/artifacts.ts:
|
|
98
|
-
| fusion-artifact | `error.json` | `src/core/fusion/artifacts.ts:
|
|
99
|
-
| fusion-artifact | `evaluation.attempt-<n>.response.txt \| evaluation.attempt-<n>.response.partial.txt` | `src/core/fusion/artifacts.ts:
|
|
100
|
-
| fusion-artifact | `evaluation.json` | `src/core/fusion/artifacts.ts:
|
|
101
|
-
| fusion-artifact | `merge.attempt-<n>.response.md \| merge.attempt-<n>.response.partial.md` | `src/core/fusion/artifacts.ts:
|
|
102
|
-
| fusion-artifact | `merged.md` | `src/core/fusion/artifacts.ts:
|
|
103
|
-
| fusion-artifact | `
|
|
86
|
+
| directory | `.pi/fusion/<session-id>-<pid>/<run-id>/` | `src/core/fusion/artifacts.ts:353` |
|
|
87
|
+
| directory | `.pi/tasks/<session-id>-<pid>/` | `src/core/registry.ts:783` |
|
|
88
|
+
| fusion-artifact | `<attempt-prefix> = candidate-<slot>.attempt-<n> \| evaluation.attempt-<n> \| merge.attempt-<n>` | `src/core/fusion/artifacts.ts:242` |
|
|
89
|
+
| fusion-artifact | `<attempt-prefix>.calibration-violation.json` | `src/core/fusion/artifacts.ts:257` |
|
|
90
|
+
| fusion-artifact | `<attempt-prefix>.events.jsonl` | `src/core/fusion/artifacts.ts:541` |
|
|
91
|
+
| fusion-artifact | `<attempt-prefix>.prompt.txt` | `src/core/fusion/artifacts.ts:540` |
|
|
92
|
+
| fusion-artifact | `<attempt-prefix>.stderr.txt` | `src/core/fusion/artifacts.ts:542` |
|
|
93
|
+
| fusion-artifact | `blind-candidates.json` | `src/core/fusion/artifacts.ts:498` |
|
|
94
|
+
| fusion-artifact | `budget-plan.json` | `src/core/fusion/artifacts.ts:494` |
|
|
95
|
+
| fusion-artifact | `candidate-<slot>.attempt-<n>.response.md \| candidate-<slot>.attempt-<n>.response.partial.md` | `src/core/fusion/artifacts.ts:252` |
|
|
96
|
+
| fusion-artifact | `candidate-<slot>.attempt-<n>.tool-calls.jsonl` | `src/core/fusion/artifacts.ts:413` |
|
|
97
|
+
| fusion-artifact | `candidate-<slot>.attempt-<n>.tool-calls.jsonl.seal.json` | `src/core/fusion/child-protocol.ts:22` |
|
|
98
|
+
| fusion-artifact | `canonical-input.json` | `src/core/fusion/artifacts.ts:464` |
|
|
99
|
+
| fusion-artifact | `context-omission-ledger.json` | `src/core/fusion/artifacts.ts:473` |
|
|
100
|
+
| fusion-artifact | `error.json` | `src/core/fusion/artifacts.ts:523` |
|
|
101
|
+
| fusion-artifact | `evaluation.attempt-<n>.response.txt \| evaluation.attempt-<n>.response.partial.txt` | `src/core/fusion/artifacts.ts:252` |
|
|
102
|
+
| fusion-artifact | `evaluation.json` | `src/core/fusion/artifacts.ts:502` |
|
|
103
|
+
| fusion-artifact | `merge.attempt-<n>.response.md \| merge.attempt-<n>.response.partial.md` | `src/core/fusion/artifacts.ts:252` |
|
|
104
|
+
| fusion-artifact | `merged.md` | `src/core/fusion/artifacts.ts:436` |
|
|
105
|
+
| fusion-artifact | `result.json` | `src/core/fusion/artifacts.ts:437` |
|
|
106
|
+
| fusion-artifact | `source-policy.private.json` | `src/core/fusion/artifacts.ts:480` |
|
|
104
107
|
| task-file | `.pi/tasks/<session-id>-<pid>/<task-id>.attestation.json` | `src/core/attested-pi-run.ts:583` |
|
|
105
|
-
| task-file | `.pi/tasks/<session-id>-<pid>/<task-id>.json` | `src/core/registry.ts:
|
|
106
|
-
| task-file | `.pi/tasks/<session-id>-<pid>/<task-id>.output` | `src/core/registry.ts:
|
|
108
|
+
| task-file | `.pi/tasks/<session-id>-<pid>/<task-id>.json` | `src/core/registry.ts:811` |
|
|
109
|
+
| task-file | `.pi/tasks/<session-id>-<pid>/<task-id>.output` | `src/core/registry.ts:810` |
|
|
107
110
|
| task-file | `.pi/tasks/<session-id>-<pid>/<task-id>.pi-events.jsonl` | `src/core/attested-pi-run.ts:580` |
|
|
108
111
|
| task-file | `.pi/tasks/<session-id>-<pid>/<task-id>.pi-telemetry-wrapper.cjs` | `src/core/attested-pi-run.ts:582` |
|
|
109
112
|
| task-file | `.pi/tasks/<session-id>-<pid>/<task-id>.stderr` | `src/core/attested-pi-run.ts:581` |
|
|
@@ -116,41 +119,43 @@ This generated registry lists production environment-variable references, runtim
|
|
|
116
119
|
| `pi-background-tasks.delegate-budget-plan.v2` | `src/core/delegate/types.ts:21` |
|
|
117
120
|
| `pi-background-tasks.delegate-child-terminal.v1` | `src/delegate-child-extension.ts:381` |
|
|
118
121
|
| `pi-background-tasks.delegate-hook-contract.v1` | `src/core/delegate/hook-contract.ts:15` |
|
|
119
|
-
| `pi-background-tasks.delegate-launch.v1` | `src/delegate-extension.ts:
|
|
122
|
+
| `pi-background-tasks.delegate-launch.v1` | `src/delegate-extension.ts:398` |
|
|
120
123
|
| `pi-background-tasks.delegate-ledger.v1` | `src/core/delegate/types.ts:16` |
|
|
121
124
|
| `pi-background-tasks.delegate-manifest.v1` | `src/core/delegate/types.ts:22` |
|
|
122
125
|
| `pi-background-tasks.delegate-outcome.v1` | `src/core/delegate/runner.ts:200` |
|
|
123
126
|
| `pi-background-tasks.delegate-receipt.v1` | `src/core/delegate/types.ts:19` |
|
|
124
|
-
| `pi-background-tasks.delegate-result-view.v1` | `src/delegate-extension.ts:
|
|
127
|
+
| `pi-background-tasks.delegate-result-view.v1` | `src/delegate-extension.ts:629` |
|
|
125
128
|
| `pi-background-tasks.delegate-result.v1` | `src/core/delegate/types.ts:18` |
|
|
126
129
|
| `pi-background-tasks.delegate-seed.v1` | `src/core/delegate/types.ts:15` |
|
|
127
130
|
| `pi-background-tasks.extension-request.v1` | `src/core/extension-api.ts:15` |
|
|
128
131
|
| `pi-background-tasks.extension-response.v1` | `src/core/extension-api.ts:16` |
|
|
129
132
|
| `pi-background-tasks.extension-terminal.v1` | `src/core/extension-api.ts:17` |
|
|
130
|
-
| `pi-background-tasks.fusion-blind-candidates.v1` | `src/core/fusion/prompts.ts:
|
|
131
|
-
| `pi-background-tasks.fusion-budget-plan.v4` | `src/core/fusion/types.ts:
|
|
132
|
-
| `pi-background-tasks.fusion-calibration-violation.v2` | `src/core/fusion/types.ts:
|
|
133
|
-
| `pi-background-tasks.fusion-child-result.
|
|
134
|
-
| `pi-background-tasks.fusion-child-settlement.
|
|
133
|
+
| `pi-background-tasks.fusion-blind-candidates.v1` | `src/core/fusion/prompts.ts:309` |
|
|
134
|
+
| `pi-background-tasks.fusion-budget-plan.v4` | `src/core/fusion/types.ts:27` |
|
|
135
|
+
| `pi-background-tasks.fusion-calibration-violation.v2` | `src/core/fusion/types.ts:29` |
|
|
136
|
+
| `pi-background-tasks.fusion-child-result.v4` | `src/core/fusion/child-protocol.ts:10` |
|
|
137
|
+
| `pi-background-tasks.fusion-child-settlement.v3` | `src/core/fusion/child-protocol.ts:13` |
|
|
135
138
|
| `pi-background-tasks.fusion-claude-cache-observation.v1` | `src/core/fusion/claude-cache.ts:4` |
|
|
136
|
-
| `pi-background-tasks.fusion-
|
|
137
|
-
| `pi-background-tasks.fusion-
|
|
139
|
+
| `pi-background-tasks.fusion-committed-result.v1` | `src/core/fusion/types.ts:22` |
|
|
140
|
+
| `pi-background-tasks.fusion-context-ledger.v2` | `src/core/fusion/types.ts:25` |
|
|
141
|
+
| `pi-background-tasks.fusion-evaluation-repair-input.v1` | `src/core/fusion/prompts.ts:289` |
|
|
138
142
|
| `pi-background-tasks.fusion-evaluation.v1` | `src/core/fusion/types.ts:16` |
|
|
139
143
|
| `pi-background-tasks.fusion-input.v4` | `src/core/fusion/types.ts:14` |
|
|
140
144
|
| `pi-background-tasks.fusion-input.v5` | `src/core/fusion/types.ts:15` |
|
|
141
|
-
| `pi-background-tasks.fusion-
|
|
142
|
-
| `pi-background-tasks.fusion-manifest.
|
|
143
|
-
| `pi-background-tasks.fusion-
|
|
145
|
+
| `pi-background-tasks.fusion-launch.v1` | `src/fusion-extension.ts:1125` |
|
|
146
|
+
| `pi-background-tasks.fusion-manifest.v3` | `src/core/fusion/types.ts:23` |
|
|
147
|
+
| `pi-background-tasks.fusion-manifest.v4` | `src/core/fusion/types.ts:24` |
|
|
148
|
+
| `pi-background-tasks.fusion-merge-input.v1` | `src/core/fusion/prompts.ts:336` |
|
|
144
149
|
| `pi-background-tasks.fusion-models.v1` | `src/core/fusion/types.ts:13` |
|
|
145
|
-
| `pi-background-tasks.fusion-progress.v1` | `src/fusion-extension.ts:
|
|
146
|
-
| `pi-background-tasks.fusion-
|
|
150
|
+
| `pi-background-tasks.fusion-progress.v1` | `src/fusion-extension.ts:59` |
|
|
151
|
+
| `pi-background-tasks.fusion-result-view.v1` | `src/delegate-extension.ts:669` |
|
|
147
152
|
| `pi-background-tasks.fusion-result.v4` | `src/core/fusion/types.ts:19` |
|
|
148
153
|
| `pi-background-tasks.fusion-result.v5` | `src/core/fusion/types.ts:20` |
|
|
149
|
-
| `pi-background-tasks.fusion-runtime-guard.v1` | `src/core/fusion/child-protocol.ts:
|
|
150
|
-
| `pi-background-tasks.fusion-source-policy.v1` | `src/core/fusion/types.ts:
|
|
151
|
-
| `pi-background-tasks.fusion-tool-call-seal.v1` | `src/core/fusion/child-protocol.ts:
|
|
152
|
-
| `pi-background-tasks.fusion-tool-call.v1` | `src/core/fusion/types.ts:
|
|
153
|
-
| `pi-background-tasks.fusion-validation-candidate-contract-event.v1` | `src/core/fusion/types.ts:
|
|
154
|
+
| `pi-background-tasks.fusion-runtime-guard.v1` | `src/core/fusion/child-protocol.ts:24` |
|
|
155
|
+
| `pi-background-tasks.fusion-source-policy.v1` | `src/core/fusion/types.ts:26` |
|
|
156
|
+
| `pi-background-tasks.fusion-tool-call-seal.v1` | `src/core/fusion/child-protocol.ts:21` |
|
|
157
|
+
| `pi-background-tasks.fusion-tool-call.v1` | `src/core/fusion/types.ts:32` |
|
|
158
|
+
| `pi-background-tasks.fusion-validation-candidate-contract-event.v1` | `src/core/fusion/types.ts:31` |
|
|
154
159
|
| `pi-background-tasks.fusion-validation-candidate.v1` | `src/core/fusion/types.ts:18` |
|
|
155
160
|
| `pi-background-tasks.input-token-calibration.v1` | `src/core/context/token-budget.ts:18` |
|
|
156
161
|
|
|
@@ -12,8 +12,8 @@ covers_sources: []
|
|
|
12
12
|
<!-- pi-docs:begin name="shortcut-contracts" generator="scripts/docs/generate.mjs" -->
|
|
13
13
|
| Shortcut | Description | Provenance |
|
|
14
14
|
| --- | --- | --- |
|
|
15
|
-
| `ctrl+alt+c` | Clear finished background task footer notices (terminal-dependent fallback for /bg-clear) | `src/extension.ts:
|
|
16
|
-
| `shift+down` | Open focused background task footer dock | `src/extension.ts:
|
|
15
|
+
| `ctrl+alt+c` | Clear finished background task footer notices (terminal-dependent fallback for /bg-clear) | `src/extension.ts:597` |
|
|
16
|
+
| `shift+down` | Open focused background task footer dock | `src/extension.ts:590` |
|
|
17
17
|
<!-- pi-docs:end name="shortcut-contracts" -->
|
|
18
18
|
|
|
19
19
|
## Registered shortcuts
|
|
@@ -20,6 +20,12 @@ The runtime owns task identity, shell invocation, process lifecycle, bounded log
|
|
|
20
20
|
- In-memory recent retention prunes oldest finished tasks over the limit while preserving running tasks.
|
|
21
21
|
- `resolveTask` accepts exact ids or unambiguous prefixes and fails loudly for empty, unknown, or ambiguous ids.
|
|
22
22
|
|
|
23
|
+
## Starting managed tasks
|
|
24
|
+
|
|
25
|
+
`startManagedTask` tracks a package-owned in-process asynchronous workflow through the same metadata, output, dock, status, logs, kill, EventBus terminal, and notification surfaces as process tasks. Fusion uses this path only after its no-child-yet durable preflight barrier. Managed cancellation invokes a task-owned callback; terminal state is not published until the workflow promise has settled and completed its own child cleanup/audit sealing.
|
|
26
|
+
|
|
27
|
+
Managed task ids are explicit and path-safe. Fusion uses its run id as the single task/run identity. Progress is written as bounded task output and persisted in Fusion task facts. `claimFusionUsage` serializes a once-only durable accounting claim so repeated `bg_result` calls cannot duplicate usage.
|
|
28
|
+
|
|
23
29
|
## Starting ordinary tasks
|
|
24
30
|
|
|
25
31
|
`startTask` trims surrounding command whitespace and rejects an empty command. It derives task name from explicit `name`, then `description`, then command. Names are compacted and truncated; callers should still provide concise names.
|
|
@@ -54,7 +60,7 @@ During finalization, the runtime flushes wrapped-agent output, ends and waits fo
|
|
|
54
60
|
|
|
55
61
|
## Stopping tasks
|
|
56
62
|
|
|
57
|
-
Only `running` tasks can be stopped.
|
|
63
|
+
Only `running` tasks can be stopped. Managed tasks invoke their task-owned cancellation callback and wait for workflow settlement; process tasks use the platform paths below.
|
|
58
64
|
|
|
59
65
|
POSIX stop path:
|
|
60
66
|
|
|
@@ -12,14 +12,14 @@ covers_sources: []
|
|
|
12
12
|
This authored section defines the boundary: documentation facts are extracted from package metadata and TypeScript ASTs, then generated into docs and the manifest. Unsupported syntax fails the gate rather than falling back to regex or stale hand-maintained inventories. Public registrations must remain unconditional top-level direct calls or use the one validated local tool-wrapper shape; host/method aliases, computed access, nested or conditional registration, wrapper chaining/passing, constructor helpers, ambiguous public metadata, destructured Pi parameters, and repeated imported registrars are rejected.
|
|
13
13
|
|
|
14
14
|
<!-- pi-docs:begin name="docs-freshness-gate" generator="scripts/docs/generate.mjs" -->
|
|
15
|
-
- Canonical package version: `1.
|
|
15
|
+
- Canonical package version: `2.1.1`
|
|
16
16
|
- Governed markdown docs: 40
|
|
17
17
|
- Public surfaces extracted: 30
|
|
18
|
-
- Governed production sources:
|
|
18
|
+
- Governed production sources: 48
|
|
19
19
|
- Tool contracts extracted: 11
|
|
20
|
-
- Schema IDs extracted:
|
|
21
|
-
- Environment variable references extracted:
|
|
22
|
-
- Behavioral attestation receipts not passing:
|
|
20
|
+
- Schema IDs extracted: 43
|
|
21
|
+
- Environment variable references extracted: 49
|
|
22
|
+
- Behavioral attestation receipts not passing: 4
|
|
23
23
|
- Receipt store: `docs/attestations.json`
|
|
24
24
|
|
|
25
25
|
`npm run docs:verify` is read-only: it renders generated files twice in memory and compares them with committed bytes. `npm run docs:generate` is the only docs writer.
|
|
@@ -5,7 +5,7 @@ mode: mixed
|
|
|
5
5
|
review_policy: behavioral
|
|
6
6
|
stability: stable
|
|
7
7
|
covers_surfaces: [renderer:fusion-result, workflow:investigate, workflow:reason, workflow:research, workflow:validate]
|
|
8
|
-
covers_sources: [extensions/fusion-child.ts, src/core/fusion/artifacts.ts, src/core/fusion/budget.ts, src/core/fusion/child-protocol.ts, src/core/fusion/claude-cache.ts, src/core/fusion/clean-context.ts, src/core/fusion/config.ts, src/core/fusion/context.ts, src/core/fusion/evaluation.ts, src/core/fusion/orchestrator.ts, src/core/fusion/pi-child.ts, src/core/fusion/prompts.ts, src/core/fusion/source-policy.ts, src/core/fusion/types.ts, src/core/fusion/web-fetch.ts, src/core/fusion/workflows.ts, src/fusion-child-extension.ts, src/fusion-extension.ts, src/ui/fusion-model-selector.ts]
|
|
8
|
+
covers_sources: [extensions/fusion-child.ts, src/core/fusion/anthropic-attribution.ts, src/core/fusion/artifacts.ts, src/core/fusion/budget.ts, src/core/fusion/child-protocol.ts, src/core/fusion/claude-cache.ts, src/core/fusion/clean-context.ts, src/core/fusion/config.ts, src/core/fusion/context.ts, src/core/fusion/evaluation.ts, src/core/fusion/orchestrator.ts, src/core/fusion/output-contract.ts, src/core/fusion/pi-child.ts, src/core/fusion/prompts.ts, src/core/fusion/result-package.ts, src/core/fusion/source-policy.ts, src/core/fusion/types.ts, src/core/fusion/web-fetch.ts, src/core/fusion/workflows.ts, src/fusion-child-extension.ts, src/fusion-extension.ts, src/ui/fusion-model-selector.ts]
|
|
9
9
|
---
|
|
10
10
|
|
|
11
11
|
# Fusion subsystem
|
|
@@ -36,7 +36,7 @@ Every public tool schema is closed and has no public capability/mode switch. The
|
|
|
36
36
|
|
|
37
37
|
## Commands
|
|
38
38
|
|
|
39
|
-
`/fusion <prompt>` trims the command text and
|
|
39
|
+
`/fusion <prompt>` trims the command text and starts the reason workflow as a managed background task. `/fusion` with no arguments opens the multiline editor when UI is available; editor cancellation or blank edited text returns without child spawn. Durable preflight and task registration finish before the command returns; no loader remains open and no premature result message is appended. Terminal state uses the standard background notification, and `bg_result` verifies and retrieves the committed result.
|
|
40
40
|
|
|
41
41
|
`/fusion-models` requires TUI mode. It edits five slots (`Candidate 1`, `Candidate 2`, `Candidate 3`, `Evaluator`, `Merger`), allows duplicates, supports `$current`, shows unavailable configured choices, and persists `fusion-models.json` with schema `pi-background-tasks.fusion-models.v1`. Saves are lock-protected, atomic, and revision-safe: if the file changed after load, the selector reports a config conflict instead of overwriting concurrent work.
|
|
42
42
|
|
|
@@ -51,11 +51,13 @@ Investigate, research, and validate receive clean-task canonical input: exactly
|
|
|
51
51
|
All workflows use the same orchestrator shape:
|
|
52
52
|
|
|
53
53
|
1. plan budget and write artifacts before any child exists;
|
|
54
|
-
2.
|
|
55
|
-
3.
|
|
56
|
-
4.
|
|
57
|
-
5. run
|
|
58
|
-
6. run
|
|
54
|
+
2. pause at a no-child-yet readiness barrier while the managed background-task receipt becomes durable;
|
|
55
|
+
3. run three candidate children in parallel;
|
|
56
|
+
4. anonymize candidate identities as A/B/C before evaluation;
|
|
57
|
+
5. run a blind no-tool evaluator;
|
|
58
|
+
6. run one no-tool evaluator-repair child only if the first evaluator JSON is invalid or schema-invalid;
|
|
59
|
+
7. run a no-tool merger;
|
|
60
|
+
8. durably commit `merged.md` plus manifest-bound `result.json`, then publish terminal task state.
|
|
59
61
|
|
|
60
62
|
Do not describe Fusion as unconditionally exactly five model calls. A completed run may use five or six child invocations, while preflight failures use zero; candidate failures, cancellation, spawn retry, output caps, or invalid repair alter observed attempts.
|
|
61
63
|
|
|
@@ -86,31 +88,35 @@ Inspect/research candidates write sealed tool-call audit logs. The log contains
|
|
|
86
88
|
|
|
87
89
|
## Child process isolation
|
|
88
90
|
|
|
89
|
-
Fusion never calls direct completion APIs. It launches direct child `pi --mode text` processes and writes the prompt over stdin. Child argv includes `--no-session`, `--no-extensions`, `--no-skills`, `--no-prompt-templates`, `--no-themes`, and `--no-context-files`; explicit extensions still load
|
|
91
|
+
Fusion never calls direct completion APIs. It launches direct child `pi --mode text` processes and writes the prompt over stdin. Child argv includes `--no-session`, `--no-extensions`, `--no-skills`, `--no-prompt-templates`, `--no-themes`, and `--no-context-files`; explicit extensions still load. Non-Anthropic children receive only the package-owned compact metadata/runtime-governor extension. Anthropic children receive, in fixed order, the package-owned Claude Code attribution provider, `@ravshansbox/pi-anthropic-sps`, and the runtime governor. The repo-local `spawn-anthropic-attribution` entrypoint re-exports that same package-owned implementation, so normal agent spawns and Fusion cannot drift into different OAuth/cache request shapes. Attribution adds the Claude Code OAuth session header, linked account/device/session metadata, model-policy beta headers, system identity, beta-resource transport, cache surfaces, and model-aware cache usage pricing. It reads `userID` and `oauthAccount.accountUuid` from `~/.claude.json` without writing the file and fails loudly when required attribution data is absent or malformed. The sanitizer then removes only known rejected prompt lines while preserving attribution and cache controls.
|
|
90
92
|
|
|
91
|
-
Child text mode writes the final full answer to stdout. The private child extension emits compact reasoning-free metadata frames to stderr for finalized assistant messages: provider/model, stop reason, text block byte counts and hashes, aggregate text hash, the complete Pi `Usage` object, and a closed cache-policy observation. It
|
|
93
|
+
Child text mode writes the final full answer to stdout. The private child extension emits compact reasoning-free metadata frames to stderr for finalized assistant messages: provider/model, stop reason, text block byte counts and hashes, aggregate text hash, the complete Pi `Usage` object (including Anthropic `cacheWrite1h` and provider-reported reasoning subsets), and a closed cache-policy observation. It governs every final `before_provider_request` payload after attribution and sanitization. For Anthropic routes, the child environment defaults `PI_CACHE_RETENTION` to `long` before provider serialization, so the attribution/Pi adapter creates system, final-tool, and final-conversation breakpoints with `ttl: "1h"`; inherited `PI_CACHE_RETENTION=short|none|long` remains explicit, and call-level `cacheRetention="none"` still wins for compaction. The final governor validates and normalizes those upstream-selected breakpoints, falls back to short when model compatibility rejects long retention, preserves no-marker compaction payloads, enforces Anthropic's four-breakpoint ceiling, and appends the subscription prompt-caching-scope beta idempotently. Its `effective_retention` field describes the final payload, not provider acceptance. Provider usage is preserved verbatim: `cacheWrite1h > 0` proves a one-hour write, but zero is inconclusive on subscription OAuth. Live normal-spawn and exact Fusion-child controls each observed a unique cache read after 370 idle seconds despite `cacheWrite1h = 0`; therefore payload observations prove request intent and `cacheRead` proves reuse, while neither zero telemetry nor a six-minute hit alone proves the full one-hour lifetime. Malformed controls or policy values abort before transport. Non-Anthropic payloads and child environments remain unchanged apart from the governor's existing JSON normalization.
|
|
92
94
|
|
|
93
|
-
After cache normalization, the governor serializes and hashes the exact payload, applies the shared conservative estimator, reserves the model's declared maximum output plus 4,096 safety tokens, and aborts before transport if the payload cannot fit or if the child exceeds 128 provider requests. Pi's provider-hook behavior is characterized through the same `openai-codex-responses` transport adapter used by subscription Codex routes in a real local HTTP agent loop: transforms chain in extension load order and `ctx.abort()` prevents network transport. Cache observations use `pi-background-tasks.fusion-claude-cache-observation.v1`, state requested/effective retention, source, breakpoint count, and provider-request ordinal, and are hash-bound inside `pi-background-tasks.fusion-child-result.
|
|
95
|
+
After cache normalization, the governor serializes and hashes the exact payload, applies the shared conservative estimator, reserves the model's declared maximum output plus 4,096 safety tokens, and aborts before transport if the payload cannot fit or if the child exceeds 128 provider requests. Pi's provider-hook behavior is characterized through the same `openai-codex-responses` transport adapter used by subscription Codex routes in a real local HTTP agent loop: transforms chain in extension load order and `ctx.abort()` prevents network transport. Cache observations use `pi-background-tasks.fusion-claude-cache-observation.v1`, state requested/effective retention, source, breakpoint count, and provider-request ordinal, and are hash-bound inside `pi-background-tasks.fusion-child-result.v4` attempt event artifacts. At terminal `agent_settled`, the extension emits exactly one `pi-background-tasks.fusion-child-settlement.v3` frame binding the complete ordered metadata stream by count and SHA-256, the final record/hash, recovered retry-marker ordinals, and any one recovered oversized-original ordinal. The parent validates closed cache/output-contract evidence and increasing request ordinals, reconstructs stdout against the final metadata, requires final stop reason `stop`, verifies model identity, and preserves usage/cost exactly. Non-final `toolUse` records remain normal. A non-final `error` is accepted only when it is a zero-content, empty-hash, zero-usage retry marker, a later final `stop` exists, and the terminal settlement hash/accounts for that exact ordinal. Exactly one non-final `stop` is accepted only as a hash-bound oversized candidate original immediately followed by its same-session replacement. `length`, `aborted`, `pending`, final `error`, error records carrying text or usage, unbound non-final `stop`, missing/duplicate/tampered settlement, and settlement before terminal idleness all fail loudly.
|
|
94
96
|
|
|
95
97
|
Fusion child environments strip session/model/provider variables plus metered credential/base-url variables for OpenRouter, OpenAI, Anthropic, Azure OpenAI, and generic Pi API credentials before launch. Frontier model routes are admitted only when the registry reports subscription OAuth for trusted `anthropic` or `openai-codex` endpoints. There is no fallback, model substitution, endpoint override, or metered API-key route.
|
|
96
98
|
|
|
97
99
|
## Budgets and output contracts
|
|
98
100
|
|
|
99
|
-
Budget planning is per route and per stage. Every configured candidate, evaluator, and merger route must have a usable context window. The affine estimator from the shared token-budget layer accounts for byte classes plus a 512-token intercept; backed model-family calibrations are used only where applicable, unknown/unbacked providers are reported in artifacts/result details, and multibyte/dense ASCII diagnostics are preserved. Post-run calibration compares that one-request forecast only with the first provider request; cumulative agent-loop and cache usage is retained as total usage but is never misclassified as a prompt under-forecast.
|
|
101
|
+
Budget planning is per route and per stage. Every configured candidate, evaluator, and merger route must have a usable context window. Anthropic routes are conservatively capped to the attribution provider's 200K subscription request policy even when Pi's catalog advertises a larger window; Fusion never budgets against a 1M mode that its attributed transport does not request. The affine estimator from the shared token-budget layer accounts for byte classes plus a 512-token intercept; backed model-family calibrations are used only where applicable, unknown/unbacked providers are reported in artifacts/result details, and multibyte/dense ASCII diagnostics are preserved. Post-run calibration compares that one-request forecast only with the first provider request; cumulative agent-loop and cache usage is retained as total usage but is never misclassified as a prompt under-forecast.
|
|
100
102
|
|
|
101
103
|
`budget-plan.json` uses `pi-background-tasks.fusion-budget-plan.v4` and records route capacities, stage forecasts for candidate/evaluation/evaluation-repair/merge, conditional repair reservation, warnings, blockers, empty-request counterfactuals, and remediation. Each route reserves the larger of Fusion's 32,768-token output contract reserve and the resolved model's declared maximum output; a model advertising a 128,000-token maximum therefore receives the full 128,000-token reserve. Fatal preflight blockers launch zero children. High utilization or worst-case reservation pressure is a warning when input still fits. Exact rendered prompt checks happen again immediately before candidate, evaluation, repair, and merge launches.
|
|
102
104
|
|
|
103
|
-
Output contracts are checked after durable attempt recording: candidate responses up to 48 KiB JSON-rendered bytes, evaluator up to 64 KiB, merger/final report up to 64 KiB, diagnostics contract 8 KiB, child stdout cap 32 MiB, child stderr cap 4 MiB.
|
|
105
|
+
Every candidate system prompt discloses the exact 49,152 JSON-rendered UTF-8 byte hard maximum and requires explicit limitations when the requested scope cannot fit. Output contracts are checked after durable attempt recording: candidate responses up to 48 KiB JSON-rendered bytes, evaluator up to 64 KiB, merger/final report up to 64 KiB, diagnostics contract 8 KiB, child stdout cap 32 MiB, child stderr cap 4 MiB.
|
|
106
|
+
|
|
107
|
+
When a candidate's first complete `stop` response exceeds 48 KiB, the private child extension durably preserves that full original, removes all active tools, and queues one `followUp` user message before `agent_settled`. The same live Pi process, route, model, and in-memory conversation may only compress/restructure its immediately previous answer; it may not investigate again. Pi text mode then emits only the replacement to stdout. A conforming replacement proceeds normally. A second oversized response hard-fails as `child_output_cap`, preserves both the original artifact and replacement partial response, and never queues another continuation. Cancellation during compression preserves any hash-verified original already written. Fusion never clips, silently forwards, or repairs output in a new child session.
|
|
104
108
|
|
|
105
109
|
## Artifacts, usage, and lifecycle
|
|
106
110
|
|
|
107
|
-
Run artifacts are private local evidence under `.pi/fusion/<session-id>-<pid>/<run-id>/`. They include `manifest.json`, `canonical-input.json`, `budget-plan.json`, per-attempt prompts/events/stderr/responses, optional partial responses for failed attempts, optional tool-call logs/seals, `blind-candidates.json`, `evaluation.json`, `merged.md`, `error.json`, and workflow-specific context/source-policy artifacts.
|
|
111
|
+
Run artifacts are private local evidence under `.pi/fusion/<session-id>-<pid>/<run-id>/`. They include `manifest.json`, `canonical-input.json`, `budget-plan.json`, per-attempt prompts/events/stderr/responses, optional partial responses for failed attempts, optional tool-call logs/seals, `blind-candidates.json`, `evaluation.json`, `merged.md`, manifest-bound `result.json`, `error.json`, and workflow-specific context/source-policy artifacts. `bg_result` verifies manifest state, fixed artifact references, byte lengths, SHA-256 values, UTF-8, run/workflow identity, and result details before returning merged bytes.
|
|
108
112
|
|
|
109
|
-
Artifact writes use durable private temp-file/fsync/rename. Manifests enforce legal state transitions and record config, resolved models, fixed capabilities, context policy, tool policy, anonymous map, attempts, artifact refs, cumulative usage, and errors. Successful, failed, and cancelled observed attempts preserve complete Pi usage/cost components; public tool results clone the same `Usage` shape.
|
|
113
|
+
Artifact writes use durable private temp-file/fsync/rename. Manifests enforce legal state transitions and record config, resolved models, fixed capabilities, context policy, tool policy, anonymous map, attempts, artifact refs, cumulative usage, and errors. Successful, failed, and cancelled observed attempts preserve complete Pi usage/cost components, including optional `cacheWrite1h` and `reasoning` subsets; same-session compression includes both provider turns in that one attempt's aggregate; public tool results clone the same `Usage` shape without counting either subset as additional tokens. Terminal failures enrich their stage-local cause from the durable manifest after usage persistence: candidate/evaluator/merger progress reports completed, failed, cancelled, and not-started child facts plus exact usage so far. A late evaluator or merger budget refusal never claims that no child anywhere in the run was created.
|
|
110
114
|
|
|
111
115
|
For tool-enabled children, the private audit journal remains open across every low-level `agent_end`, because Pi may still retry, compact and retry, or process a queued continuation. Only terminal `agent_settled` can exclusively publish the complete hash/count/byte seal. Runtime-guard refusal latches process failure, makes that seal incomplete, and forces the result settlement to failed. The child emits one closed `pi-background-tasks.fusion-runtime-guard.v1` stderr frame containing the refusal code, route capacities, request/tool ordinals, exact payload byte count and SHA-256, conservative token estimate, and a bounded message; it never emits the payload itself. The parent validates this frame and reports typed `child_runtime_budget_exceeded` for runtime capacity/loop refusals or `child_cache_policy_invalid` for Claude cache-policy refusal, instead of accepting a later clean-looking result or reducing it to an unexplained exit code. Tool activity after finalization, duplicate settlement, pre-settlement shutdown, extension diagnostics, malformed/duplicate runtime-guard frames, and missing/failed/stale seals are fatal. This lifecycle requires Pi 0.81.1 or newer; older Pi lines do not expose the required terminal event and are not claimed as compatible.
|
|
112
116
|
|
|
113
|
-
|
|
117
|
+
The four public Fusion tools return a background launch receipt after the readiness barrier. Tool-launched runs default to terminal notification plus follow-up wake; `/fusion` uses notification-only. The first successful `bg_result` retrieval durably claims and attaches complete Fusion usage exactly once; repeated retrieval returns the answer without duplicating session accounting. Running retrieval never waits.
|
|
118
|
+
|
|
119
|
+
Cancellation and shutdown are loud and durable when a run store exists. The extension tracks active runs, managed tasks own their abort controllers, `bg_kill` and session shutdown abort them, and terminal task publication waits for workflow settlement. Child processes have a 30 minute wall timeout, 20 minute idle watchdog, SIGTERM grace, SIGKILL wait, process-group kill on POSIX, bounded stdout/stderr, and cleanup-error propagation.
|
|
114
120
|
|
|
115
121
|
## Troubleshooting
|
|
116
122
|
|
|
@@ -121,6 +127,7 @@ Cancellation and shutdown are loud and durable when a run store exists. The exte
|
|
|
121
127
|
- `prompt_budget_exceeded_measured`: an exact rendered prompt exceeded capacity after upstream output was known; split the workflow or choose a larger-context subscription route.
|
|
122
128
|
- `child_runtime_budget_exceeded`: a later provider payload, provider-request loop, or tool-call loop crossed a child runtime guard after launch. Inspect the attempt stderr guard frame and failed tool seal; narrow the task or select a subscription route with more safe input headroom. Do not ignore intermediate provider errors or weaken the guard.
|
|
123
129
|
- `child_cache_policy_invalid`: `PI_CACHE_RETENTION` or Claude cache-control evidence was malformed. Use exactly `none`, `short`, or `long`; do not remove the final-payload guard.
|
|
130
|
+
- `child_output_cap` after candidate compression: inspect the final candidate response, its `response.oversized.*` original, and v4/v3 child protocol evidence. The single same-session no-tool compression attempt also exceeded 49,152 JSON-rendered bytes; split the task rather than truncating or starting a repair child.
|
|
124
131
|
- `evaluation schema repair failed`: both evaluator attempts failed the closed JSON contract; inspect `evaluation.attempt-*.response.txt` and errors.
|
|
125
132
|
- `tool-call log invalid`: inspect the candidate `*.tool-calls.jsonl` and `*.seal.json`; missing/partial/unsealed logs, non-allowlisted tools, hash/count mismatches, and over-budget tool output fail by design.
|
|
126
133
|
- Research fetch failures are typed and do not retry via other URLs or extraction modes; verify the declared URL is public, reachable, supported content, and within caps.
|
|
@@ -40,7 +40,7 @@ A finished badge is cleared when that task's detail view is opened, or when `/bg
|
|
|
40
40
|
|
|
41
41
|
`/tasks`, `/bg-tasks`, and `Shift+Down` open the same overlay. Non-interactive contexts receive an error notification directing users to `/jobs`, `/logs`, `bg_status`, or `bg_logs`.
|
|
42
42
|
|
|
43
|
-
The list view supports selection, paging, stop, confirmed stop-all, history toggle, rerun, output path, and close. The detail view shows task identity, status, runtime, output path, description, task-owned model/context/tokens/tools when reported, command, error, and an output tail.
|
|
43
|
+
The list view supports selection, paging, stop, confirmed stop-all, history toggle, rerun, output path, and close. Rerun is shell-task-only: typed delegate and Fusion tasks fail with guidance to relaunch through their owning tool rather than executing their display command as a shell command. The detail view shows task identity, status, runtime, output path, description, task-owned model/context/tokens/tools when reported, command, error, and an output tail.
|
|
44
44
|
|
|
45
45
|
Detail output semantics:
|
|
46
46
|
|
|
@@ -11,7 +11,7 @@ covers_sources: []
|
|
|
11
11
|
|
|
12
12
|
<!-- pi-docs:begin name="tool-contract-bg_delegate" generator="scripts/docs/generate.mjs" -->
|
|
13
13
|
- Label: **Background Delegate**
|
|
14
|
-
- Source: `src/delegate-extension.ts:
|
|
14
|
+
- Source: `src/delegate-extension.ts:292`
|
|
15
15
|
- Description: Launch one background Pi agent seeded with a frozen projection of the current conversation, then return a launch receipt immediately. The child has its own session, a route pinned at launch that is never substituted, and read-only tools. Retrieve its verified answer with bg_result.
|
|
16
16
|
- Root schema: `object`; additionalProperties: `false`
|
|
17
17
|
|
package/docs/tools/bg_kill.md
CHANGED
|
@@ -11,7 +11,7 @@ covers_sources: []
|
|
|
11
11
|
|
|
12
12
|
<!-- pi-docs:begin name="tool-contract-bg_kill" generator="scripts/docs/generate.mjs" -->
|
|
13
13
|
- Label: **Background Kill**
|
|
14
|
-
- Source: `src/extension.ts:
|
|
14
|
+
- Source: `src/extension.ts:908`
|
|
15
15
|
- Description: Stop a running background task by ID. Fails loudly if the task is unknown or already finished.
|
|
16
16
|
- Root schema: `object`
|
|
17
17
|
|
package/docs/tools/bg_logs.md
CHANGED
|
@@ -11,7 +11,7 @@ covers_sources: []
|
|
|
11
11
|
|
|
12
12
|
<!-- pi-docs:begin name="tool-contract-bg_logs" generator="scripts/docs/generate.mjs" -->
|
|
13
13
|
- Label: **Background Logs**
|
|
14
|
-
- Source: `src/extension.ts:
|
|
14
|
+
- Source: `src/extension.ts:863`
|
|
15
15
|
- Description: Read bounded output from a background task for deliberate inspection; this is not a waiting primitive. Output is capped at 50.0KB for model safety and points to the full output file when truncated.
|
|
16
16
|
- Root schema: `object`
|
|
17
17
|
|
package/docs/tools/bg_result.md
CHANGED
|
@@ -10,15 +10,15 @@ covers_sources: []
|
|
|
10
10
|
# `bg_result`
|
|
11
11
|
|
|
12
12
|
<!-- pi-docs:begin name="tool-contract-bg_result" generator="scripts/docs/generate.mjs" -->
|
|
13
|
-
- Label: **
|
|
14
|
-
- Source: `src/delegate-extension.ts:
|
|
15
|
-
- Description: Retrieve
|
|
13
|
+
- Label: **Background Result**
|
|
14
|
+
- Source: `src/delegate-extension.ts:453`
|
|
15
|
+
- Description: Retrieve a hash-verified result from a bg_delegate or background Fusion task. Never blocks: a running task returns a typed not-ready result. Oversized answers are never truncated.
|
|
16
16
|
- Root schema: `object`; additionalProperties: `false`
|
|
17
17
|
|
|
18
18
|
| Field | Required | Type | Description | Constraints |
|
|
19
19
|
| --- | --- | --- | --- | --- |
|
|
20
20
|
| `delivery` | no | `string` | inline returns the verified answer text; artifact returns metadata plus the artifact reference. Oversized answers are never truncated. | |
|
|
21
|
-
| `taskId` | yes | `string` |
|
|
21
|
+
| `taskId` | yes | `string` | Background delegate or Fusion task id returned by its launch tool. | |
|
|
22
22
|
|
|
23
23
|
<details>
|
|
24
24
|
<summary>Normalized TypeBox contract</summary>
|
|
@@ -33,7 +33,7 @@ covers_sources: []
|
|
|
33
33
|
"type": "string"
|
|
34
34
|
},
|
|
35
35
|
"taskId": {
|
|
36
|
-
"description": "
|
|
36
|
+
"description": "Background delegate or Fusion task id returned by its launch tool.",
|
|
37
37
|
"type": "string"
|
|
38
38
|
}
|
|
39
39
|
},
|
|
@@ -47,13 +47,13 @@ covers_sources: []
|
|
|
47
47
|
</details>
|
|
48
48
|
<!-- pi-docs:end name="tool-contract-bg_result" -->
|
|
49
49
|
|
|
50
|
-
`bg_result` retrieves the result of a `bg_delegate` task. It never blocks: a running task returns a typed not-ready view, and a terminal task is verified before any answer bytes are returned.
|
|
50
|
+
`bg_result` retrieves the result of a `bg_delegate` or background Fusion task. It never blocks: a running task returns a typed not-ready view, and a terminal task is verified before any answer bytes are returned.
|
|
51
51
|
|
|
52
52
|
## Public arguments
|
|
53
53
|
|
|
54
54
|
Required:
|
|
55
55
|
|
|
56
|
-
- `taskId: string` — task id or unambiguous prefix resolved by the background-task registry. Must be non-empty after trimming.
|
|
56
|
+
- `taskId: string` — delegate or Fusion task id, or an unambiguous prefix resolved by the background-task registry. Must be non-empty after trimming.
|
|
57
57
|
|
|
58
58
|
Optional:
|
|
59
59
|
|
|
@@ -74,7 +74,7 @@ This is not an error and does not wait. End the turn or do other independent wor
|
|
|
74
74
|
|
|
75
75
|
## Verification before return
|
|
76
76
|
|
|
77
|
-
For terminal tasks, the parent evaluates the child artifacts. `result.json` is the child-written commit point. If it is absent, the task has no accepted answer even if the child exited `0`.
|
|
77
|
+
For terminal delegate tasks, the parent evaluates the child artifacts. `result.json` is the child-written commit point. If it is absent, the task has no accepted answer even if the child exited `0`.
|
|
78
78
|
|
|
79
79
|
A present package is accepted only after verifying:
|
|
80
80
|
|
|
@@ -90,6 +90,10 @@ A present package is accepted only after verifying:
|
|
|
90
90
|
|
|
91
91
|
The returned text is decoded from the same aggregate buffer that was hashed. Corruption, stale packages, missing attestations, route drift, or invalid UTF-8 produce typed failures and no answer bytes.
|
|
92
92
|
|
|
93
|
+
## Fusion retrieval
|
|
94
|
+
|
|
95
|
+
A completed Fusion task is accepted only when `manifest.json` is terminal `completed`, its `result.json` and `merged.md` fixed references match, both files match manifest-bound byte lengths and SHA-256 values, run/workflow/artifact identity matches the task, result details carry the current schema, usage is complete, and merged bytes are well-formed UTF-8. The first successful retrieval attaches complete Fusion usage exactly once; later retrievals omit usage to prevent double-counting.
|
|
96
|
+
|
|
93
97
|
## Inline/artifact delivery and no truncation
|
|
94
98
|
|
|
95
99
|
`bg_result` never truncates an answer.
|
|
@@ -102,7 +106,7 @@ Large answers remain complete in `result.json` as base64 blocks plus aggregate h
|
|
|
102
106
|
|
|
103
107
|
## Failure classes users see
|
|
104
108
|
|
|
105
|
-
Common retrieval outcomes:
|
|
109
|
+
Common delegate retrieval outcomes:
|
|
106
110
|
|
|
107
111
|
- `task_unknown` — unknown id/prefix or not a delegate task.
|
|
108
112
|
- `result_unavailable` / `child_exited_without_commit` — terminal task produced no committed result package.
|
|
@@ -113,7 +117,7 @@ Common retrieval outcomes:
|
|
|
113
117
|
- `artifact_read_failed`, `artifact_spill_failed`, `artifact_error` — artifact I/O failure.
|
|
114
118
|
- `result_too_large_for_inline` — explicit inline request exceeded the inline cap.
|
|
115
119
|
|
|
116
|
-
Delegate errors include whether a child process was created, preserved artifact hints when known, and remediation text. Usage missing from the provider is reported as `unavailable`, not synthesized as zero.
|
|
120
|
+
Delegate errors include whether a child process was created, preserved artifact hints when known, and remediation text. Usage missing from the provider is reported as `unavailable`, not synthesized as zero. Fusion retrieval additionally fails on non-completed manifests, identity/schema drift, malformed usage/details, invalid UTF-8, or any manifest/result/merged hash or byte-length mismatch; failed/cancelled runs return their preserved terminal error rather than partial output.
|
|
117
121
|
|
|
118
122
|
## Parent outcome separation
|
|
119
123
|
|
package/docs/tools/bg_run.md
CHANGED
|
@@ -11,7 +11,7 @@ covers_sources: []
|
|
|
11
11
|
|
|
12
12
|
<!-- pi-docs:begin name="tool-contract-bg_run" generator="scripts/docs/generate.mjs" -->
|
|
13
13
|
- Label: **Background Run**
|
|
14
|
-
- Source: `src/extension.ts:
|
|
14
|
+
- Source: `src/extension.ts:682`
|
|
15
15
|
- Description: Start a named long-running shell command in the background and return immediately with a task ID and output path. By default, completed, failed, or killed terminal state is delivered automatically as <background-task-notification> and starts a follow-up agent turn; do not sleep or poll merely to wait. Output is written to .pi/tasks and model-visible logs are bounded to 50.0KB.
|
|
16
16
|
- Root schema: `object`
|
|
17
17
|
|
|
@@ -11,7 +11,7 @@ covers_sources: []
|
|
|
11
11
|
|
|
12
12
|
<!-- pi-docs:begin name="tool-contract-bg_run_pi_attested" generator="scripts/docs/generate.mjs" -->
|
|
13
13
|
- Label: **Attested Pi Run**
|
|
14
|
-
- Source: `src/extension.ts:
|
|
14
|
+
- Source: `src/extension.ts:767`
|
|
15
15
|
- Description: Opt-in evidence-oriented direct Pi spawn. Launches exactly one `pi --mode json` child, records raw Pi events/stderr, hashes prompt/report/output, observes OAuth through ModelRegistry, and emits a strict attestation sidecar only after successful completion.
|
|
16
16
|
- Root schema: `object`
|
|
17
17
|
|
package/docs/tools/bg_status.md
CHANGED
|
@@ -11,7 +11,7 @@ covers_sources: []
|
|
|
11
11
|
|
|
12
12
|
<!-- pi-docs:begin name="tool-contract-bg_status" generator="scripts/docs/generate.mjs" -->
|
|
13
13
|
- Label: **Background Status**
|
|
14
|
-
- Source: `src/extension.ts:
|
|
14
|
+
- Source: `src/extension.ts:832`
|
|
15
15
|
- Description: Inspect one background task or list all running/recent background tasks. This is a point-in-time inspection tool, not a waiting primitive.
|
|
16
16
|
- Root schema: `object`
|
|
17
17
|
|