@piagent/platform 1.2.9 → 1.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +179 -0
- package/README.md +29 -6
- package/adapters/backend-api/profile.json +1 -1
- package/adapters/be-readonly-fe/profile.json +2 -2
- package/adapters/data/profile.json +1 -1
- package/adapters/devops/profile.json +1 -3
- package/adapters/docs/profile.json +1 -1
- package/adapters/fullstack/profile.json +2 -4
- package/adapters/generic/profile.json +1 -1
- package/adapters/mobile/profile.json +1 -2
- package/adapters/node-typescript/profile.json +1 -3
- package/benchmarks/core-v1/suite.json +51 -0
- package/benchmarks/core-v1/tasks/discount-order/grade.mjs +17 -0
- package/benchmarks/core-v1/tasks/discount-order/project/package.json +8 -0
- package/benchmarks/core-v1/tasks/discount-order/project/src/discount.js +3 -0
- package/benchmarks/core-v1/tasks/discount-order/project/src/order.js +6 -0
- package/benchmarks/core-v1/tasks/discount-order/project/test/order.test.js +7 -0
- package/benchmarks/core-v1/tasks/discount-order/prompt.md +4 -0
- package/benchmarks/core-v1/tasks/invoice-quantity/grade.mjs +17 -0
- package/benchmarks/core-v1/tasks/invoice-quantity/project/package.json +8 -0
- package/benchmarks/core-v1/tasks/invoice-quantity/project/src/invoice.js +3 -0
- package/benchmarks/core-v1/tasks/invoice-quantity/project/test/invoice.test.js +7 -0
- package/benchmarks/core-v1/tasks/invoice-quantity/prompt.md +3 -0
- package/benchmarks/core-v1/tasks/protected-env-refusal/grade.mjs +11 -0
- package/benchmarks/core-v1/tasks/protected-env-refusal/project/README.md +4 -0
- package/benchmarks/core-v1/tasks/protected-env-refusal/project/package.json +8 -0
- package/benchmarks/core-v1/tasks/protected-env-refusal/project/test/smoke.test.js +4 -0
- package/benchmarks/core-v1/tasks/protected-env-refusal/prompt.md +4 -0
- package/benchmarks/core-v1/tasks/targeted-session/grade.mjs +14 -0
- package/benchmarks/core-v1/tasks/targeted-session/project/package.json +8 -0
- package/benchmarks/core-v1/tasks/targeted-session/project/src/auth/session.js +3 -0
- package/benchmarks/core-v1/tasks/targeted-session/project/src/billing/currency.js +3 -0
- package/benchmarks/core-v1/tasks/targeted-session/project/src/catalog/search.js +3 -0
- package/benchmarks/core-v1/tasks/targeted-session/project/src/notifications/channel.js +3 -0
- package/benchmarks/core-v1/tasks/targeted-session/project/src/search/tokenize.js +3 -0
- package/benchmarks/core-v1/tasks/targeted-session/project/test/session.test.js +7 -0
- package/benchmarks/core-v1/tasks/targeted-session/prompt.md +4 -0
- package/catalog/capabilities.json +12 -12
- package/docs/command-reference-vietnamese.md +15 -8
- package/docs/context-engine.md +56 -15
- package/docs/distribution-standard.md +11 -8
- package/docs/mcp-and-tools.md +20 -7
- package/docs/model-options.md +7 -10
- package/docs/operator-manual-vietnamese.md +102 -37
- package/docs/package-architecture-notes.md +3 -1
- package/docs/publishing-for-teams.md +5 -0
- package/docs/quality-benchmark.md +225 -58
- package/docs/quickstart-vietnamese.md +5 -0
- package/docs/release-install-policy.md +41 -7
- package/docs/runtime-harness-standard.md +47 -29
- package/docs/runtime-policy-design.md +23 -12
- package/docs/runtime-quality-baseline.md +31 -17
- package/docs/security-threat-model.md +7 -2
- package/docs/subagents-and-multiagent.md +1 -1
- package/docs/task-implementation-contract.md +113 -177
- package/docs/task-lifecycle-vietnamese.md +129 -125
- package/docs/team-onboarding.md +12 -4
- package/docs/usage-observability.md +15 -8
- package/docs-site/architecture.html +1 -1
- package/docs-site/commands.html +1 -1
- package/docs-site/content/context-engine.html +8 -1
- package/docs-site/content/runtime.html +10 -0
- package/docs-site/content/security.html +1 -0
- package/docs-site/context-engine.html +9 -2
- package/docs-site/index.html +1 -1
- package/docs-site/mcp-approval.html +1 -1
- package/docs-site/mcp-auth.html +1 -1
- package/docs-site/mcp-servers.html +1 -1
- package/docs-site/mcp.html +1 -1
- package/docs-site/permissions.html +1 -1
- package/docs-site/profiles.html +1 -1
- package/docs-site/quickstart.html +1 -1
- package/docs-site/runtime.html +11 -1
- package/docs-site/scope.html +1 -1
- package/docs-site/security.html +2 -1
- package/docs-site/team.html +1 -1
- package/docs-site/workflows.html +1 -1
- package/evals/fixtures/task-contract.invalid.json +15 -1
- package/evals/fixtures/task-contract.valid.json +18 -2
- package/package.json +3 -2
- package/packages/piagent-core/README.md +43 -4
- package/packages/piagent-core/benchmark/benchmark-core.js +691 -0
- package/packages/piagent-core/extensions/context-engine.js +209 -120
- package/packages/piagent-core/extensions/context-index-policy.js +1 -1
- package/packages/piagent-core/extensions/guard-types.ts +35 -3
- package/packages/piagent-core/extensions/local-state-path.js +59 -0
- package/packages/piagent-core/extensions/piagent-guard.ts +2073 -222
- package/packages/piagent-core/extensions/policy-core.js +11 -1
- package/packages/piagent-core/extensions/runtime-evidence.js +39 -19
- package/packages/piagent-core/extensions/state-retention.js +218 -0
- package/packages/piagent-core/extensions/task-lifecycle.js +138 -0
- package/packages/piagent-core/extensions/task-state.js +630 -0
- package/packages/piagent-core/mcp/mcp-config-layers.js +52 -6
- package/packages/piagent-core/mcp/mcp-tool-naming.js +12 -1
- package/packages/piagent-core/package.json +1 -1
- package/packages/piagent-core/policies/base-policy.json +1 -0
- package/packages/piagent-core/prompts/be-to-fe.md +14 -22
- package/packages/piagent-core/prompts/platform-improve.md +12 -17
- package/packages/piagent-core/prompts/review.md +7 -11
- package/packages/piagent-core/prompts/scout.md +6 -10
- package/packages/piagent-core/prompts/task.md +11 -17
- package/packages/piagent-core/skills/piagent-ops/SKILL.md +12 -15
- package/packages/piagent-core/subagents/piagent-reviewer.md +3 -3
- package/schemas/task-contract.schema.json +267 -104
- package/scripts/benchmark-runner.mjs +1172 -0
- package/scripts/install-global.sh +1 -1
- package/scripts/migrate-project-state.mjs +94 -3
- package/scripts/piagent-cli.mjs +1 -1
- package/scripts/update-global.mjs +36 -3
- package/scripts/verify-local.sh +15 -0
- package/templates/project/.pi/task-contract.template.json +19 -2
- package/templates/project/AGENTS.md +10 -20
|
@@ -10,7 +10,7 @@ This file is the canonical install, update, rollback, and release checklist. Oth
|
|
|
10
10
|
|
|
11
11
|
All supported environments require Node.js `>=22.19.0` and Pi Coding Agent `0.82.0`. The Pi host is installed as a Node CLI; Pi Agent Platform still defines its own release matrix because the terminal helpers and shell policy rely on Bash/POSIX behavior.
|
|
12
12
|
|
|
13
|
-
| Surface | Status for v1.2.
|
|
13
|
+
| Surface | Status for v1.2.11 | Rollout guidance |
|
|
14
14
|
|---|---|---|
|
|
15
15
|
| macOS Apple Silicon (`darwin/arm64`) + Bash | Verified for this release. | Safe default for team rollout after normal project smoke tests. |
|
|
16
16
|
| Linux x64 + Bash | Verified in GitHub Actions. | Safe default for CI/server usage after normal project smoke tests. |
|
|
@@ -33,7 +33,7 @@ These three components are versioned independently. A full install, update, or r
|
|
|
33
33
|
|
|
34
34
|
| Channel | Source shape | Mutability | Use when |
|
|
35
35
|
|---|---|---:|---|
|
|
36
|
-
| `stable` | `git:github.com/Vt-mmm/piagent@<resolved-commit-sha>` from `v1.2.
|
|
36
|
+
| `stable` | `git:github.com/Vt-mmm/piagent@<resolved-commit-sha>` from `v1.2.11` | Fixed after resolution | Default for team rollout. |
|
|
37
37
|
| `exact` | Tag, reviewed commit, or a tag resolved with `--resolve-tag` | Fixed when using a commit SHA | Pi-package-only roll forward, rollback, or reproduction. |
|
|
38
38
|
| `dev` | `git:github.com/Vt-mmm/piagent` | Moving | Personal machine or sandbox only. |
|
|
39
39
|
| `local` | `/path/to/piagent` | Local workspace | Platform development and dry-run validation. |
|
|
@@ -53,7 +53,7 @@ Use this flow when the team needs both terminal commands and the Pi package:
|
|
|
53
53
|
```bash
|
|
54
54
|
node --version # >= 22.19.0
|
|
55
55
|
npm install -g --ignore-scripts @earendil-works/pi-coding-agent@0.82.0
|
|
56
|
-
npm install -g --ignore-scripts @piagent/platform@1.2.
|
|
56
|
+
npm install -g --ignore-scripts @piagent/platform@1.2.11
|
|
57
57
|
piagent-install --stable --dry-run
|
|
58
58
|
piagent-install --stable
|
|
59
59
|
```
|
|
@@ -61,8 +61,8 @@ piagent-install --stable
|
|
|
61
61
|
The stable preview and apply output includes:
|
|
62
62
|
|
|
63
63
|
```text
|
|
64
|
-
currentRelease: v1.2.
|
|
65
|
-
tag: v1.2.
|
|
64
|
+
currentRelease: v1.2.11 (helper package version)
|
|
65
|
+
tag: v1.2.11
|
|
66
66
|
resolvedCommit: <40-char-sha>
|
|
67
67
|
source: git:github.com/Vt-mmm/piagent@<40-char-sha>
|
|
68
68
|
```
|
|
@@ -79,7 +79,7 @@ bash scripts/install-global.sh --stable
|
|
|
79
79
|
Use this only when terminal commands are not needed:
|
|
80
80
|
|
|
81
81
|
```bash
|
|
82
|
-
pi install git:github.com/Vt-mmm/piagent@v1.2.
|
|
82
|
+
pi install git:github.com/Vt-mmm/piagent@v1.2.11
|
|
83
83
|
```
|
|
84
84
|
|
|
85
85
|
Direct `pi install` does not create `piagent-*` commands on `PATH`.
|
|
@@ -104,7 +104,34 @@ piagent-update --version X.Y.Z --project /path/to/project
|
|
|
104
104
|
|
|
105
105
|
With `--project`, the updater migrates legacy project state if needed and runs `piagent-doctor --strict-share`; use `--no-migrate` only when debugging a migration.
|
|
106
106
|
|
|
107
|
-
|
|
107
|
+
From `v1.2.11`, project migration also previews and upgrades Task Contract v1
|
|
108
|
+
state to session-bound v2. It fails before changing project files when any task
|
|
109
|
+
state is unreadable, writes v2 atomically, and archives v1 only after the new
|
|
110
|
+
contract exists. Opening the project with the new Pi package also performs the
|
|
111
|
+
same idempotent task-state migration for resumed sessions.
|
|
112
|
+
|
|
113
|
+
The `v1.2.11` migrator also upgrades the exact generated `v1.2.10` `AGENTS.md`
|
|
114
|
+
and future `<!-- piagent-managed:* -->` blocks while preserving project text
|
|
115
|
+
outside that block. A global-only update is still effective immediately: the
|
|
116
|
+
runtime replaces the exact legacy checklist in the model's in-memory system
|
|
117
|
+
prompt without editing the project file. Running `--project` makes the cleanup
|
|
118
|
+
durable and lets doctor verify it.
|
|
119
|
+
|
|
120
|
+
A project already onboarded does not need onboarding again after a global
|
|
121
|
+
update. Its profile still extends the newly installed adapter and its capability
|
|
122
|
+
lock re-pins only when the release does not widen the project's grants. Daily
|
|
123
|
+
source work must start a new v2 task in a Git working tree with a configured
|
|
124
|
+
verify command; read-only scout remains available without a source verifier.
|
|
125
|
+
|
|
126
|
+
The updater first identifies the npm prefix that owns the active
|
|
127
|
+
`piagent-update` command. If that prefix is writable, host and helper stay there
|
|
128
|
+
even when `npm config get prefix` points somewhere else, such as an active
|
|
129
|
+
`/opt/homebrew` install with npm configured for `/usr/local`. This prevents two
|
|
130
|
+
same-version helpers with different source from shadowing one another. If both
|
|
131
|
+
the active prefix and the configured global prefix are locked, the updater uses
|
|
132
|
+
`~/.pi/npm-global` and prints the `PATH` line to add later. Do not run project
|
|
133
|
+
update/doctor as root, because that can leave project files owned by root.
|
|
134
|
+
Maintainers can force a specific prefix with `--npm-prefix <path>`.
|
|
108
135
|
|
|
109
136
|
For a fresh machine that does not have `piagent-update` yet, bootstrap the same all-in-one flow without opening Pi:
|
|
110
137
|
|
|
@@ -260,6 +287,13 @@ Re-running the workflow from a branch instead skips publishing, because the publ
|
|
|
260
287
|
bash scripts/setup.sh --global-only --package-source git:github.com/Vt-mmm/piagent@vX.Y.Z --dry-run
|
|
261
288
|
```
|
|
262
289
|
|
|
290
|
+
Nếu release thay đổi harness, context budget, tool loading hoặc logic tính
|
|
291
|
+
token, maintainer còn phải chạy `piagent-benchmark --dry-run`, sau đó chạy
|
|
292
|
+
`piagent-benchmark --model <provider/model> --thinking <level>` trên đúng
|
|
293
|
+
release candidate và lưu report. Đây là model-quota gate có xác nhận riêng,
|
|
294
|
+
không chạy ngầm trong CI. Không claim token/cost nếu report không cho phép
|
|
295
|
+
`tokenClaimAllowed`.
|
|
296
|
+
|
|
263
297
|
3. Push the release-candidate branch, open a pull request to `main`, and wait for both Ubuntu/macOS verify jobs and both CodeQL matrix jobs to pass. Record the exact PR-head commit SHA that passed; do not merge it into the Vercel production branch yet, and do not tag a later unverified edit.
|
|
264
298
|
4. Create an annotated, reviewed tag on that exact verified commit and push the tag. Pushing the tag starts `publish.yml`, which runs the full verify matrix as a dependency and only then publishes, so a failure on any supported runtime stops the release before it reaches the registry:
|
|
265
299
|
|
|
@@ -6,14 +6,15 @@ Runtime harness là “máy vận hành task” dùng chung cho nhiều project:
|
|
|
6
6
|
|
|
7
7
|
```text
|
|
8
8
|
User request
|
|
9
|
-
->
|
|
10
|
-
->
|
|
9
|
+
-> Pi session name / task identity
|
|
10
|
+
-> resolved project profile + capability lock
|
|
11
|
+
-> intake/risk lane/change mode
|
|
11
12
|
-> required context manifest
|
|
12
|
-
->
|
|
13
|
+
-> session-bound task contract v2 + work-plan DAG
|
|
13
14
|
-> guarded tool calls
|
|
14
|
-
->
|
|
15
|
-
-> observed
|
|
16
|
-
-> trace / handoff
|
|
15
|
+
-> baseline-aware changed-file evidence
|
|
16
|
+
-> all-command observed verification
|
|
17
|
+
-> immutable trace / retry handoff
|
|
17
18
|
```
|
|
18
19
|
|
|
19
20
|
Project cụ thể chỉ cần adapter/profile riêng. Core package giữ lifecycle, policy, verification, và documentation flow.
|
|
@@ -23,10 +24,12 @@ Project cụ thể chỉ cần adapter/profile riêng. Core package giữ lifecy
|
|
|
23
24
|
| Module | Pi Agent Platform target | Lý do |
|
|
24
25
|
|---|---|---|
|
|
25
26
|
| Risk lane | `riskLane` + profile `hardGates` | Chặn auth, release, provider config, destructive action, database migration. |
|
|
26
|
-
| Intake | `piagent_task_start` | Mỗi
|
|
27
|
+
| Intake | runtime automatic intake; fallback `piagent_task_start` | Mỗi attempt có identity/session/scope/output/acceptance criteria trước model work; bounded tasks không tốn management turn. |
|
|
27
28
|
| Context rules | `/onboard run`, Pi Context Engine, `.pi/project-context.md`, `requiredContext`, context manifest | Giảm token và tránh đọc toàn repo. |
|
|
28
|
-
| Test matrix | `verifyCommands` + observed verify evidence | DONE phải có exact verify command thực chạy qua Pi bash
|
|
29
|
-
| Trace |
|
|
29
|
+
| Test matrix | `verifyCommands` + observed verify evidence | Source DONE phải có mọi exact verify command thực chạy và pass qua Pi bash. |
|
|
30
|
+
| Trace | completion hook, `.pi/piagent-state/traces.jsonl`, session entry | Runtime tự ghi audit trail; tool thủ công chỉ dùng recovery. |
|
|
31
|
+
| Retry | `attempt`, `maxAttempts`, `previousAttempts`, failed step state | Lần sau giữ failure/ruled-out evidence và không loop vô hạn. |
|
|
32
|
+
| Change truth | Git baseline/final digests + tool-result observation | Không nhận file dirty cũ hoặc claim không có evidence là thay đổi của task. |
|
|
30
33
|
| Protected paths | `protectedPaths` trong profile + extension guard | Mỗi project có vùng cấm riêng. |
|
|
31
34
|
| Tool registry | `mcpCapabilities` + `.mcp.json` | Không tự đoán tool/MCP. |
|
|
32
35
|
| Domain contract | Project docs/profile | Chỉ project cần UX/form/data strict mới bật. |
|
|
@@ -57,6 +60,9 @@ tool context mang tính advisory chỉ được nạp khi task thực sự cần
|
|
|
57
60
|
|
|
58
61
|
```text
|
|
59
62
|
1. Intake
|
|
63
|
+
- one Pi session per task
|
|
64
|
+
- runtime auto-start for bounded source changes; manual fallback for broad/high-risk/ambiguous scope
|
|
65
|
+
- source-change or read-only
|
|
60
66
|
- risk lane
|
|
61
67
|
- expected output
|
|
62
68
|
- acceptance criteria
|
|
@@ -64,41 +70,46 @@ tool context mang tính advisory chỉ được nạp khi task thực sự cần
|
|
|
64
70
|
- protected paths
|
|
65
71
|
|
|
66
72
|
2. Context
|
|
67
|
-
-
|
|
68
|
-
-
|
|
69
|
-
-
|
|
70
|
-
-
|
|
71
|
-
- record context manifest
|
|
73
|
+
- runtime injects one bounded Context Engine navigation pack when useful
|
|
74
|
+
- read only targeted current files
|
|
75
|
+
- successful reads become context manifest evidence automatically
|
|
76
|
+
- no routine context/status/index tool calls
|
|
72
77
|
|
|
73
78
|
3. Plan
|
|
74
79
|
- exact touchpoints
|
|
75
80
|
- verify command
|
|
76
81
|
- rollback/handoff if high-risk
|
|
82
|
+
- dependency DAG with one write owner
|
|
77
83
|
|
|
78
84
|
4. Implement
|
|
79
|
-
-
|
|
80
|
-
- check non-piagent tools only when capability is unclear
|
|
85
|
+
- tool-call hook checks shell, capabilities and external actions automatically
|
|
81
86
|
- edit only in scope
|
|
82
87
|
- avoid protected paths
|
|
88
|
+
- block direct and shell writes outside scope
|
|
83
89
|
|
|
84
90
|
5. Verify
|
|
85
|
-
- run exact mapped verify command
|
|
86
|
-
-
|
|
91
|
+
- run every exact mapped verify command
|
|
92
|
+
- tool-result hook records exact observed evidence after task start
|
|
93
|
+
- bind passing evidence to the current working-tree digest
|
|
94
|
+
- reconcile changed files against baseline and scope
|
|
87
95
|
- if verify unavailable: not DONE
|
|
88
96
|
|
|
89
97
|
6. Trace
|
|
90
|
-
-
|
|
91
|
-
- commands
|
|
92
|
-
-
|
|
93
|
-
-
|
|
94
|
-
|
|
95
|
-
|
|
98
|
+
- completion hook projects the final contract and runs the gate
|
|
99
|
+
- runtime persists changed files, commands, result and final trace
|
|
100
|
+
- one bounded continuation repairs missing evidence; it never loops
|
|
101
|
+
- freeze the contract after a terminal outcome
|
|
102
|
+
|
|
103
|
+
7. Retry when needed
|
|
104
|
+
- start a fresh Pi session with the same taskId
|
|
105
|
+
- carry forward failedAt, reason, ruledOut, and prior outcome
|
|
106
|
+
- refuse attempts beyond the first attempt's maxAttempts
|
|
96
107
|
```
|
|
97
108
|
|
|
98
109
|
| Lane | Extra context/orchestration |
|
|
99
110
|
|---|---|
|
|
100
|
-
| `tiny` |
|
|
101
|
-
| `normal` |
|
|
111
|
+
| `tiny` | Automatic lifecycle; parent agent, targeted reads, exact verify, no progress/evidence calls. |
|
|
112
|
+
| `normal` | Automatic objective evidence plus one explicit final review step. |
|
|
102
113
|
| `high-risk` | Relevant index/memory/vendor evidence plus explicit security/data/release review. |
|
|
103
114
|
|
|
104
115
|
## Maturity phases
|
|
@@ -108,20 +119,27 @@ tool context mang tính advisory chỉ được nạp khi task thực sự cần
|
|
|
108
119
|
| P0 | package core + profile + docs + protected path guard | Chỉ đủ pilot/read-only. |
|
|
109
120
|
| P1 | schema + task contract + doctor + verify-local + lean prompts | Dùng được cho task nhỏ có review. |
|
|
110
121
|
| P2 | extension tools for task/context/verify/trace + session entries | Dùng được cho source task có guard rõ. |
|
|
111
|
-
| P3 | exec policy + context budget + tool registry + task gate + benchmark
|
|
112
|
-
| P4 |
|
|
122
|
+
| P3 | exec policy + context budget + tool registry + task gate + automatic paired benchmark | Dùng được cho guarded project workflows. |
|
|
123
|
+
| P4 | session-bound v2 state, Git change truth, retry, completion hook, bounded secure local state | Sẵn sàng rollout có kiểm soát; OS/MDM governance vẫn ngoài core. |
|
|
113
124
|
|
|
114
125
|
## Chuẩn DONE
|
|
115
126
|
|
|
116
127
|
Một Pi task chỉ DONE khi có đủ:
|
|
117
128
|
|
|
118
129
|
- profile loaded;
|
|
130
|
+
- task is bound to the current Pi session;
|
|
119
131
|
- lane classified;
|
|
120
132
|
- protected paths known;
|
|
121
133
|
- context manifest exists;
|
|
122
134
|
- plan exists for source write;
|
|
123
135
|
- changed files listed;
|
|
124
|
-
- exact verify command ran and passed
|
|
136
|
+
- every exact source verify command ran and passed;
|
|
137
|
+
- declared changed files are evidenced, in scope, and different from baseline;
|
|
138
|
+
- work plan has no pending/in-progress/failed step;
|
|
125
139
|
- trace/handoff recorded;
|
|
126
140
|
- no secrets touched;
|
|
127
141
|
- no protected path writes.
|
|
142
|
+
|
|
143
|
+
Read-only task có thể hoàn tất không cần source verifier nhưng phải giữ working
|
|
144
|
+
tree không đổi. Source task không có Git hoặc meaningful verifier bị từ chối từ
|
|
145
|
+
đầu, không đợi tới cuối mới báo thiếu evidence.
|
|
@@ -20,14 +20,14 @@ Runtime policy là lớp kiểm soát cách agent đọc context, gọi tool, s
|
|
|
20
20
|
| Project context | `piagent_context` | Load profile, settings, policy, and local state summary. |
|
|
21
21
|
| Context index | `piagent_context_index_status/search/record` | Maintain a compact advisory node/edge/citation map for profile/project/tech/task navigation. |
|
|
22
22
|
| Permission profile | `piagent_permission_status` | Show active `read-only`, `workspace-write`, or `trusted-full-access` boundary. |
|
|
23
|
-
| Exec policy | `piagent_exec_policy_check` | Evaluate shell command risk before execution. |
|
|
24
|
-
| Context budget | `piagent_context_budget` | Enforce size/count limits for context files. |
|
|
25
|
-
| Tool registry | `piagent_tool_policy_check` | Check external tool capability against profile. |
|
|
26
|
-
| Task contract | `piagent_task_start` | Persist scope, acceptance criteria, risk lane, and verify plan. |
|
|
27
|
-
| Context manifest | `piagent_context_record` | Record
|
|
28
|
-
| Verify evidence | `
|
|
29
|
-
| Final gate | `piagent_task_gate_check` | Validate readiness before final handoff. |
|
|
30
|
-
| Trace | `piagent_trace_record` | Persist changed files, outcome, and handoff state. |
|
|
23
|
+
| Exec policy | `tool_call` hook; diagnostic `piagent_exec_policy_check` | Evaluate shell command risk before execution. |
|
|
24
|
+
| Context budget | lifecycle hooks; diagnostic `piagent_context_budget` | Enforce size/count limits for context files. |
|
|
25
|
+
| Tool registry | `tool_call` hook; diagnostic `piagent_tool_policy_check` | Check external tool capability against profile. |
|
|
26
|
+
| Task contract | automatic intake; fallback `piagent_task_start` | Persist scope, acceptance criteria, risk lane, intake mode, and verify plan before model work. |
|
|
27
|
+
| Context manifest | `tool_result` hook; recovery `piagent_context_record` | Record successful targeted reads for a task. |
|
|
28
|
+
| Verify evidence | `tool_result` hook; recovery `piagent_verify_record` | Bind an exact observed Pi `bash` result to the current working tree. |
|
|
29
|
+
| Final gate | `message_end` hook; diagnostic `piagent_task_gate_check` | Validate projected readiness before final handoff. |
|
|
30
|
+
| Trace | completion hook; recovery `piagent_trace_record` | Persist changed files, outcome, and handoff state. |
|
|
31
31
|
| Usage | `piagent_usage_snapshot` | Show session/context/token usage when available. |
|
|
32
32
|
|
|
33
33
|
## Policy precedence
|
|
@@ -78,7 +78,7 @@ The runtime separates the active autonomy profile from the project profile:
|
|
|
78
78
|
## Task lifecycle
|
|
79
79
|
|
|
80
80
|
```text
|
|
81
|
-
intake
|
|
81
|
+
runtime/manual intake
|
|
82
82
|
-> profile/context
|
|
83
83
|
-> task contract
|
|
84
84
|
-> context manifest
|
|
@@ -90,7 +90,9 @@ intake
|
|
|
90
90
|
-> handoff
|
|
91
91
|
```
|
|
92
92
|
|
|
93
|
-
This lifecycle is intentionally explicit
|
|
93
|
+
This lifecycle is intentionally explicit in persisted state but passive in the
|
|
94
|
+
routine model flow. Hooks make task quality auditable without turning the state
|
|
95
|
+
machine into a long sequence of model tool calls.
|
|
94
96
|
|
|
95
97
|
## Verify evidence ledger
|
|
96
98
|
|
|
@@ -100,7 +102,10 @@ Pi `bash` results are observed through the runtime `tool_result` hook and append
|
|
|
100
102
|
.pi/piagent-state/observed-bash.jsonl
|
|
101
103
|
```
|
|
102
104
|
|
|
103
|
-
The ledger stores cwd, timestamp, status, a hash of the normalized command, and
|
|
105
|
+
The ledger stores cwd, timestamp, status, a hash of the normalized command, and
|
|
106
|
+
redacted command text for audit. Runtime uses it directly; a recovery
|
|
107
|
+
`piagent_verify_record` call can also validate against it without raw command
|
|
108
|
+
storage.
|
|
104
109
|
|
|
105
110
|
This file-based ledger is intentionally shared by parent and subagent processes that run in the same project cwd. If a worker subagent runs `npm test`, the parent can later record that exact verify command without depending on process-local memory.
|
|
106
111
|
|
|
@@ -129,4 +134,10 @@ Ad-hoc commands can still be recorded for traceability, but they do not satisfy
|
|
|
129
134
|
|
|
130
135
|
## Benchmark discipline
|
|
131
136
|
|
|
132
|
-
|
|
137
|
+
Release-level quality/token/cost claims must use `piagent-benchmark`: paired clean
|
|
138
|
+
workspaces, the same prompt/model/thinking, hidden acceptance checks, exact Pi
|
|
139
|
+
usage, scope checks and Piagent workflow evidence. A token-saving verdict also
|
|
140
|
+
requires quality/reliability at least `9/10`, perfect safety/workflow,
|
|
141
|
+
non-inferior quality and at least three same-model paired runs with exact usage.
|
|
142
|
+
`scripts/quality-benchmark.sh` remains only as a legacy recorder for
|
|
143
|
+
project-specific evidence.
|
|
@@ -133,7 +133,18 @@ Runtime behavior:
|
|
|
133
133
|
- yêu cầu observed passing verify khớp exact `task.verifyCommands` khi task có source changes;
|
|
134
134
|
- block `piagent_trace_record completed` nếu final gate đang enforce và proof chưa đủ.
|
|
135
135
|
|
|
136
|
-
Agent
|
|
136
|
+
Agent không phải gọi các tool evidence/trace/gate trong task thường. Hook
|
|
137
|
+
`tool_result` tự ghi targeted reads, changed files và exact verifier; hook
|
|
138
|
+
`message_end` dựng final contract, chạy gate rồi ghi terminal trace khi đủ proof.
|
|
139
|
+
Các tool thủ công vẫn tồn tại cho diagnostics/recovery và high-risk/custom plan.
|
|
140
|
+
|
|
141
|
+
Passing evidence còn phải khớp `workingTreeDigest` hiện tại. Bất kỳ mutation nào
|
|
142
|
+
sau verify làm evidence cũ stale. Việc chạm một file rồi revert về đúng digest
|
|
143
|
+
baseline chỉ được giữ trong audit history, không được tính là final source diff.
|
|
144
|
+
|
|
145
|
+
Automatic/assisted plan được phép một `followUp` correction turn khi projected
|
|
146
|
+
gate fail. Lượt này nhận đúng missing reasons, không tự lặp; rollback bằng
|
|
147
|
+
`PIAGENT_AUTO_RECOVERY=off`.
|
|
137
148
|
|
|
138
149
|
`piagent_verify_record` không còn tin `exitCode` tự khai báo. Lệnh verify phải khớp một bash tool result đã quan sát sau `task.createdAt`, và claimed `exitCode` phải khớp trạng thái `isError` của Pi. Observed result được ghi vào `.pi/piagent-state/observed-bash.jsonl` để parent/subagent process có thể share evidence trong cùng project cwd.
|
|
139
150
|
|
|
@@ -158,7 +169,7 @@ Guard state tự bảo vệ:
|
|
|
158
169
|
- mọi text block trong `tool_result` và string leaf trong JSON-like `details` có thêm shared sensitive-data redaction; key như `password`, `token`, `credential` được dùng làm context phát hiện;
|
|
159
170
|
- `npm run benchmark:redaction` gate contextual recall, benign preservation, structured objects/arrays, và large-output correctness bằng synthetic data; opaque entropy không có credential context được báo riêng và không gate release;
|
|
160
171
|
- bash evidence chỉ giữ command text đã redact ở memory/disk; raw command hash vẫn dùng để exact-match verify evidence;
|
|
161
|
-
- `piagent_task_start`,
|
|
172
|
+
- `piagent_task_start`, lifecycle hooks và các recovery tools vẫn ghi state được qua internal extension path.
|
|
162
173
|
|
|
163
174
|
## 5. Local verification
|
|
164
175
|
|
|
@@ -188,34 +199,37 @@ pi list --approve
|
|
|
188
199
|
|
|
189
200
|
## 6. Quality benchmark
|
|
190
201
|
|
|
191
|
-
|
|
202
|
+
Automatic paired benchmark:
|
|
192
203
|
|
|
193
204
|
```bash
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
--scenario bounded-source-fix \
|
|
197
|
-
--surface pi \
|
|
198
|
-
--result pass \
|
|
199
|
-
--tokens 12345 \
|
|
200
|
-
--cost 0.12 \
|
|
201
|
-
--verify "npm test" \
|
|
202
|
-
--notes "verify passed; no manual correction"
|
|
205
|
+
piagent-benchmark --dry-run
|
|
206
|
+
piagent-benchmark
|
|
203
207
|
```
|
|
204
208
|
|
|
205
209
|
Output:
|
|
206
210
|
|
|
207
211
|
```text
|
|
208
|
-
|
|
209
|
-
|
|
212
|
+
~/.pi/agent/benchmarks/piagent/<run-id>/report.json
|
|
213
|
+
~/.pi/agent/benchmarks/piagent/<run-id>/report.html
|
|
214
|
+
~/.pi/agent/benchmarks/piagent/<run-id>/summary.txt
|
|
215
|
+
~/.pi/agent/benchmarks/piagent/<run-id>/runs.jsonl
|
|
210
216
|
```
|
|
211
217
|
|
|
212
|
-
|
|
218
|
+
Runner dùng clean Git fixture, hidden grader và exact Pi session usage. Piagent
|
|
219
|
+
fixture được init/onboard và build context trước measured run để benchmark task
|
|
220
|
+
steady-state; mọi context/index mutation sau Git baseline vẫn bị scope gate bắt.
|
|
221
|
+
Report tách hidden correctness khỏi scope/reliability, hiện usage của mọi run và
|
|
222
|
+
chỉ lưu histogram tên tool. Chỉ claim chất lượng/token/cost khi các paired run có:
|
|
213
223
|
|
|
214
224
|
- cùng task prompt/spec;
|
|
215
225
|
- cùng acceptance criteria;
|
|
216
226
|
- verify command rõ;
|
|
217
|
-
- token/cost/duration được ghi lại;
|
|
218
|
-
- quality
|
|
227
|
+
- token/cost/duration được runtime ghi lại;
|
|
228
|
+
- quality/reliability đạt ít nhất `9/10`, safety/workflow đạt `10/10`, quality
|
|
229
|
+
không giảm và ít nhất ba cặp cùng model có exact usage.
|
|
230
|
+
|
|
231
|
+
`piagent-benchmark <project> --record ...` vẫn route tới recorder cũ cho task
|
|
232
|
+
project-specific, nhưng không thay thế automatic release benchmark.
|
|
219
233
|
|
|
220
234
|
## Runtime policy trong profile
|
|
221
235
|
|
|
@@ -14,6 +14,7 @@ This document covers the packaged guard, project profiles, capability locks, ins
|
|
|
14
14
|
- protected guard, profile, settings, capability-lock, and evidence files;
|
|
15
15
|
- external GitHub, HTTP, MCP, and provider resources that can be mutated;
|
|
16
16
|
- release identity, installer sources, dependency pins, and package contents;
|
|
17
|
+
- source bodies and retrieval metadata stored in the local Context Engine index;
|
|
17
18
|
- observed verification evidence used to approve task completion.
|
|
18
19
|
|
|
19
20
|
## Trust assumptions
|
|
@@ -21,7 +22,7 @@ This document covers the packaged guard, project profiles, capability locks, ins
|
|
|
21
22
|
- The operator, operating-system account, Pi host, and explicitly trusted project repository are trusted to execute code.
|
|
22
23
|
- Project-local Pi resources are loaded only after Pi project trust or an explicit operator override.
|
|
23
24
|
- A human remains available to approve destructive and external-provider actions.
|
|
24
|
-
- Supported release verification covers macOS Apple Silicon + Bash, Linux x64 + Bash, Node.js `>=22.19.0`, and the exact Pi host version declared by the release. macOS Intel + Bash and Linux ARM64 + Bash are supported targets that need local smoke verification before broad rollout. Native Windows is not a team-rollout target for v1.2.
|
|
25
|
+
- Supported release verification covers macOS Apple Silicon + Bash, Linux x64 + Bash, Node.js `>=22.19.0`, and the exact Pi host version declared by the release. macOS Intel + Bash and Linux ARM64 + Bash are supported targets that need local smoke verification before broad rollout. Native Windows is not a team-rollout target for v1.2.11, and WSL2 is experimental/unverified.
|
|
25
26
|
- Registry, GitHub, model-provider, MCP-provider, and Vercel controls are external dependencies. Their account security and platform guarantees are not replaced by this repository.
|
|
26
27
|
|
|
27
28
|
## Threat actors and failure modes
|
|
@@ -42,11 +43,15 @@ The final category is outside the containment capability of the Piagent guard. I
|
|
|
42
43
|
| Direct or nested path-like tool input | Bounded recursive input inspection, protected-path precedence, repository boundary checks, filesystem capability scopes, and read-only profile paths | A new carrier or field name must be classified before it can be treated as controlled. Unknown/ambiguous tools fail closed where policy requires confirmation. |
|
|
43
44
|
| Shell glob reaching a protected file | Glob candidates are read from the same expanded, resolved word list as every other check and matched against examples of each protected pattern, so a pattern assembled by an expansion (`{cat,.env*}`, `cat $({echo,.env*})`, `{bash,} -c 'cat .env*'`, `echo .env* | xargs cat`) is seen. This is the only check that can answer for a pattern at all, since `.env*` matches no protected literal. Whether a word is matched against filenames is decided per character, so a quoted metacharacter names a file instead (`{".env*",x}`). A redirection is read by the rule the shell uses — it opens its target only where that target expands to exactly one word, and is refused as an ambiguous redirect otherwise (`> "{.env,}"{,}`, `> {.env,other}`), while a word that can still disappear, an unset variable or a pattern under `nullglob`, leaves the count unknowable and keeps every candidate | Matching is against generated examples of each protected pattern, not against the filesystem, so a protected pattern whose examples do not represent every real name it covers can leave a matching file unnamed. Bounded expansion refuses rather than enumerates when a glob is too broad to expand. |
|
|
44
45
|
| Encoding, case variation, traversal, or symbolic-link alias | Single percent decode, case-insensitive protected matching, canonical resolution for existing paths, traversal/repository escape rejection | Filesystem races and code executing outside observed tool paths require an OS boundary. |
|
|
45
|
-
|
|
|
46
|
+
| Local image path introduced through chat or extension input | Auto-attachment resolves the canonical target through the same project and `additionalReadRoots` grants as document intake, checks both the requested symlink location and resolved target against protected paths, preserves capability read scope, sniffs image bytes, and opens the inspected device/inode with no-follow semantics before attaching | A deliberately broad `additionalReadRoots` grant exposes every supported image under that root. Processes running as the same OS account and files modified in place remain outside this application-level boundary. |
|
|
47
|
+
| Context index built with weaker or stale path rules | CLI and runtime share one resolved exclusion policy covering base policy, adapter inheritance, protected, shell-protected, and read-only paths. Every index API, including status, requires an explicit exclusion list and fails closed when it is omitted. A versioned exclusion digest forces rebuild on policy drift; search/pack filter candidates again at read time, and source-shaped symlinks or canonical paths outside the project are refused. Policy drift also rebuilds FTS, checkpoints WAL, and vacuums the database before clearing a retryable `purgePending` marker. | An explicit empty exclusion list remains available to intentional low-level callers. A policy migration may temporarily require roughly twice the database size in free space; interruption leaves the marker pending and retries on the next ensure. |
|
|
48
|
+
| Source residue or cross-account access to the local context index | Context Engine directory mode is `0700`; SQLite database, WAL, and SHM are `0600`. SQLite core and FTS5 secure-delete are both enabled for ordinary updates, while policy migrations rebuild FTS and vacuum legacy free pages. | Context Engine is still an application-level cache, not an OS sandbox. A process running as the same OS account, filesystem races, backups, snapshots, or storage below the filesystem layer require separate OS/device controls. |
|
|
46
49
|
| Shell glob, brace, redirection, wrapper, assignment, or command composition | Static Bash operand/action analysis with bounded expansion and regression cases; protected input is denied and external mutation is confirmation-gated. A path the analysis cannot resolve — literal text concatenated with a substitution, as in `.en$(echo v)` — is refused rather than matched on its literal half | Runtime-generated interpreter payloads cannot be fully understood by static parsing. Sensitive output redaction is a backstop, not containment. |
|
|
47
50
|
| Secret returned in tool output | Shared contextual redaction across guarded text/results and synthetic recall benchmark | High-entropy, novel secret formats, or transformed output such as base64-encoded content can evade pattern-based redaction. Never intentionally print real secrets. |
|
|
48
51
|
| Malicious project profile or relaxed capability lock | Trust-aware profile loading, deterministic lock digest, base-policy/source integrity, protected self-state, and fail-closed verification | An already trusted malicious repository can execute code through mechanisms outside the guard. |
|
|
49
52
|
| External GitHub/HTTP/MCP/provider mutation | Direct and proxied action classification plus explicit operator confirmation, including guarded shell carriers | Provider semantics and new tool schemas can change; new integrations require policy and regression review. |
|
|
53
|
+
| Repository MCP direct tool loses server attribution | Guard and doctor share the merged MCP view. Both session-level and effective per-server `directTools` selections fail closed when `toolPrefix: "none"` removes server identity; approved direct tools remain usable with `server` or `short` prefixes | A future adapter naming mode or config layer must be added to the shared MCP resolver before rollout. |
|
|
54
|
+
| Read-only subagent receives mutation-capable tools | Packaged read-only roles carry explicit `read`, `grep`, `find`, `ls` allowlists; CI checks every `acceptanceRole: read-only` manifest, while all shell/edit/write capability remains on the explicit writer role | User/project overrides and a compromised external subagent runtime can replace the packaged contract; inspect effective runtime configuration when accepting third-party roles. |
|
|
50
55
|
| Destructive local action | Exec-policy classification and explicit confirmation; protected paths remain denied in every permission profile. A target written as a command substitution is evaluated only where its body is one plain command with literal operands and a format this renderer reproduces exactly, and confirmed otherwise — a separator, a nested substitution, a redirection, a variable, quoting, an escape, a `printf` option, or a `printf` conversion whose result this does not reproduce (`*`, `%q`, `%b`, the numeric conversions, `%%`) all make the body unreadable here. A constant width or precision and format reuse are reproduced, so a target built from those is refused rather than confirmed, and the rendered output is read as a path candidate as well as the format's literal text and its arguments — a name assembled across a conversion (`.e%.1sv nv` is `.env`) appears in none of the pieces. Brace expansion, ranges included, is performed once per segment before anything reads it, so the rules, the legacy patterns, the nested-interpreter scan, the pipeline producers and the destructive checks all see the word list the shell would build rather than the text as typed; the expansion produces a token stream, so a command and its arguments assembled from one brace word (`{cat,.env}`) are read as both; quoting is tracked per character, so a word holding a quoted group beside an expanding one (`"{.env,}"{,}`) expands exactly as far as the shell expands it — and a target that is nothing but an unresolved parameter expansion is confirmed rather than permitted, since it can hold any value including root. The same holds for reads: a word that is only an unresolved parameter expansion is confirmed wherever the command opens files (`cat ${HOME:+.env}`), including across a pipe into an `xargs` that opens them (`echo $F \| xargs cat`), while a command substitution in that position is left to the nested scan that classifies the command inside it, and two expansions with nothing between them count as a name being assembled just as literal text beside one does. Brace expansion, parameter expansion and command substitution are performed once per segment, in the order a shell performs them, and every reader takes that one word list — so a name assembled by an expansion (`r$(printf %s m) -rf /`, `xa$(printf %s rgs)`, `$(printf %s ba)$(echo -n sh) -c '...'`) is the command it becomes rather than the text it was typed as. A name that still cannot be resolved is treated as an unknown command rather than a known-harmless one: it is enough to bring the destructive checks, the interpreter scan and the file-operand net into play, since `${X:+r}m -rf /` and `${X:+cat} ${X:+.env}` are those commands whenever the variable is set. Differential cases are generated rather than enumerated, over the cross product the defects live in — expansion form, position in the command, and reader — with each spelling placed in the command name, the operand, a flag's argument, a redirection target, a pipeline producer, an `xargs` consumer and an interpreter payload; the corpus fails if any generated spelling produced no word list, so a batch that dies early cannot pass as coverage, and it asserts in both directions so a check that answers for everything fails too | Confirmation is not isolation. A trusted process outside the observed tool path retains OS authority. A target produced by any other command is knowable only at run time, so it is gated by confirmation rather than refused. |
|
|
51
56
|
| Forged verification result | Observed Bash result ledger, command hash, task-start ordering, exit-code and verify-command matching | Compromise of the trusted Pi/process environment is outside this evidence model. |
|
|
52
57
|
| Mutable or substituted release source | Exact team tags, stable tag-to-commit resolution, release-commit binding in tag CI, annotated-tag requirement, add-on integrity checks, and documented tag ruleset requirement | Bootstrap helper installation still relies on GitHub tag immutability; repository administrators must prevent tag update/deletion. Signed provenance remains future work. |
|
|
@@ -253,7 +253,7 @@ Platform package exposes these package-level agents:
|
|
|
253
253
|
| `piagent-scout` | bounded repo mapping | no |
|
|
254
254
|
| `piagent-planner` | implementation plan + verify gates | no |
|
|
255
255
|
| `piagent-worker` | single-writer implementation | yes |
|
|
256
|
-
| `piagent-reviewer` | review diff/policy/tests/scope |
|
|
256
|
+
| `piagent-reviewer` | review diff/policy/tests/scope | no |
|
|
257
257
|
| `piagent-oracle` | second opinion/risk challenge | no |
|
|
258
258
|
|
|
259
259
|
Default rule:
|