Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

docs(plugins): state that pi.net.fetch is never retried for a plugin

vastsad50e98f9c5b6
diff --git a/docs/plugin-development.md b/docs/plugin-development.md
index 910cacf63..b793a8d9d 100644
--- a/docs/plugin-development.md
+++ b/docs/plugin-development.md
@@ -490,6 +490,11 @@ allowed host cannot bounce a request to one you did not declare. Bundle assets
into the plugin rather than loading them from a CDN you would otherwise have to
declare.
+`fetch` returns what the server answered, `429` and `Retry-After` included: the
+host never retries a request your plugin makes, so backoff after a rate limit is
+your own policy rather than a hidden host behaviour. A call that comes back
+`>= 400` is still audited, as `ok: false` with the delay the response advertised.
+
### 6.7 Theme
Declare a CSS file and `ui.theme`:
diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.md
index 5fadaf9a5..596dcfe3f 100644
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@ -11051,16 +11051,23 @@ are withdrawn with ADR 0165.
- **Preconditions**: A dev plugin with `net.domains: ["allowed.test"]` and
`net.fetch`. A local server on `allowed.test` answers `/hop` with a 302 to
- `http://undeclared.test/leak` and `/ok` with 200.
+ `http://undeclared.test/leak`, `/ok` with 200, and `/limited` with 429 and
+ `Retry-After: 2`.
- **Steps**: 1) Call `pi.net.fetch({ url: "https://allowed.test/ok" })`. 2)
- Call `pi.net.fetch({ url: "https://allowed.test/hop" })`.
+ Call `pi.net.fetch({ url: "https://allowed.test/hop" })`. 3) Call
+ `pi.net.fetch({ url: "https://allowed.test/limited" })`.
- **Expected**: Step 1 returns 200. Step 2 fails with `PERMISSION_DENIED`
naming `undeclared.test`, and the undeclared server records no request. The
- audit log shows the denied hop.
-- **Specs linked**: `07-plugins/04-plugin-security.md` §8.0
+ audit log shows the denied hop. Step 3 returns 429 with its `Retry-After`
+ header intact, the server records exactly one request for it, and the audit
+ log shows `ok: false` with the advertised `retryAfter` — the host retries
+ nothing.
+- **Specs linked**: `07-plugins/04-plugin-security.md` §8.0,
+ `07-plugins/03-plugin-api.md` §7
- **Acceptance**: D, Security
- **Milestone**: M4+
- **Status**: runtime-covered by `apps/desktop/test/plugin-egress.test.mjs`
+ (per-hop egress and failed-call audit)
#### E2E-238: Tool requests for an unknown session do not fall back
diff --git a/docs/spec/07-plugins/03-plugin-api.md b/docs/spec/07-plugins/03-plugin-api.md
index 73445dc74..975cd9c2d 100644
--- a/docs/spec/07-plugins/03-plugin-api.md
+++ b/docs/spec/07-plugins/03-plugin-api.md
@@ -638,6 +638,14 @@ pi.net.fetch(input: {
}): Promise<{ status: number; headers: Record<string, string>; bodyText: string }>
```
+`fetch` answers with the upstream response unchanged — `status`, `headers`, and
+`bodyText` — so a `429` is data your plugin can read, `Retry-After` included,
+rather than an error the host hides. The host does not retry, throttle, or
+re-issue the request: retry and backoff after a `429` are your plugin's own
+policy, and the response headers are the only backoff signal you get. A failed
+call (`status >= 400`) is audited as `ok: false`, together with the
+`retryAfter` it advertised when the response states one (§7).
+
```ts
pi.net.websocket.connect(input: {
url: string
@@ -991,6 +999,8 @@ Log fields:
- ts
- sessionId?
- ok / errorCode
+- status / retryAfter (`net.fetch`: the upstream status of a completed call, and
+ for a failed one the `Retry-After` it stated — never the header set or body)
## 8. Versioning strategy
diff --git a/docs/spec/07-plugins/04-plugin-security.md b/docs/spec/07-plugins/04-plugin-security.md
index aa4801433..3c4f512b8 100644
--- a/docs/spec/07-plugins/04-plugin-security.md
+++ b/docs/spec/07-plugins/04-plugin-security.md
@@ -322,7 +322,11 @@ generous `fs.read` scope affordable (§6).
Still open, tracked separately: `agent.prompt.inject` (skill text can ask a
shell-capable agent to do the carrying), `shell.openExternal`, a `bus.publish`
relayed to a net-capable plugin, and raw `fetch` inside the plugin process — the
-last one needs the sandboxed plugin runtime from ADR 0008 D009.
+last one needs the sandboxed plugin runtime from ADR 0008 D009. `pi.net.fetch`
+narrows none of that: the host applies the allowlist, follows redirects by hand,
+and audits the call, but it never retries, throttles, or re-issues a request. An
+upstream `429` reaches the plugin as `429` plus whatever `Retry-After` the server
+sent, and what the plugin does about it is the plugin's own policy.
## 8.1 MCP server egress and credentials
diff --git a/docs/zh-CN/plugin-development.md b/docs/zh-CN/plugin-development.md
index 17bb4cc14..77d87ebda 100644
--- a/docs/zh-CN/plugin-development.md
+++ b/docs/zh-CN/plugin-development.md
@@ -471,6 +471,10 @@ root 本身。`net.fetch` 接受 HTTP(S),并且只能到达 `manifest.net.doma
一个你没声明的主机上。请把资源打进插件包,而不是从一个你还得额外声明的 CDN
上加载。
+`fetch` 返回服务器实际给出的内容,`429` 和 `Retry-After` 都在内:宿主从不重试
+你的插件发出的请求,所以遇到限流之后的退避是你自己的策略,而不是主机隐藏的
+行为。返回 `>= 400` 的调用依然会进审计,记为 `ok: false` 并带上它通告的延迟。
+
### 6.7 主题
声明 CSS 文件和 `ui.theme`:
diff --git a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md
index 8d4e22d7f..c2d4936d0 100644
--- a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md
@@ -7075,15 +7075,20 @@ runner 会在运行时的隔离临时目录中生成六个插件形态 fixture
- **前提条件**:一个声明 `net.domains: ["allowed.test"]` 和 `net.fetch` 的开发插件。
`allowed.test` 上的本地服务器对 `/hop` 返回 302 到 `http://undeclared.test/leak`,
- 对 `/ok` 返回 200。
+ 对 `/ok` 返回 200,对 `/limited` 返回 429 且带 `Retry-After: 2`。
- **步骤**:1)调用 `pi.net.fetch({ url: "https://allowed.test/ok" })`。2)调用
- `pi.net.fetch({ url: "https://allowed.test/hop" })`。
+ `pi.net.fetch({ url: "https://allowed.test/hop" })`。3)调用
+ `pi.net.fetch({ url: "https://allowed.test/limited" })`。
- **预期**:步骤 1 返回 200。步骤 2 以点名 `undeclared.test` 的 `PERMISSION_DENIED`
- 失败,未声明的服务器没有记录到任何请求。审计日志显示被拒绝的那一跳。
-- **链接规格**:`07-plugins/04-plugin-security.md` §8.0
+ 失败,未声明的服务器没有记录到任何请求。审计日志显示被拒绝的那一跳。步骤 3
+ 原样返回 429 及其 `Retry-After` 头,服务器只记录到一次请求,审计日志记为
+ `ok: false` 并带有它通告的 `retryAfter` —— 宿主不重试任何东西。
+- **链接规格**:`07-plugins/04-plugin-security.md` §8.0、
+ `07-plugins/03-plugin-api.md` §7
- **验收**:D、安全
- **里程碑**:M4+
- **状态**:由 `apps/desktop/test/plugin-egress.test.mjs` 运行时覆盖
+ (逐跳出网与失败调用的审计)
#### E2E-238:未知会话的工具请求不会回退
diff --git a/docs/zh-CN/spec/07-plugins/03-plugin-api.md b/docs/zh-CN/spec/07-plugins/03-plugin-api.md
index 92d34a9b6..a721fca3c 100644
--- a/docs/zh-CN/spec/07-plugins/03-plugin-api.md
+++ b/docs/zh-CN/spec/07-plugins/03-plugin-api.md
@@ -519,6 +519,12 @@ pi.net.fetch(input: {
}): Promise<{ status: number; headers: Record<string, string>; bodyText: string }>
```
+`fetch` 原样返回上游响应 —— `status`、`headers`、`bodyText` —— 所以 `429`
+是插件能读到的数据(`Retry-After` 也在里面),而不是被主机藏起来的错误。宿主
+不重试、不限流、也不重新发起请求:遇到 `429` 之后的重试与退避是插件自己的
+策略,响应头就是插件唯一能拿到的退避信号。失败的调用(`status >= 400`)在
+审计里记为 `ok: false`,并在响应声明了延迟时附带它通告的 `retryAfter`(§7)。
+
```ts
pi.net.websocket.connect(input: {
url: string
@@ -820,6 +826,8 @@ window.pluginBridge.on(event, handler)
- TS
- 会话 ID?
- 好的/错误代码
+- status / retryAfter(仅 `net.fetch`:已完成调用的上游状态码,以及失败调用所
+ 声明的 `Retry-After` —— 绝不记录整个头部集合或响应体)
## 8. 版本控制策略
diff --git a/docs/zh-CN/spec/07-plugins/04-plugin-security.md b/docs/zh-CN/spec/07-plugins/04-plugin-security.md
index bcfeafd20..c75b14e7a 100644
--- a/docs/zh-CN/spec/07-plugins/04-plugin-security.md
+++ b/docs/zh-CN/spec/07-plugins/04-plugin-security.md
@@ -256,7 +256,10 @@ Plan 是代理工具的附加主机策略边界:
仍然敞着、单独跟踪的:`agent.prompt.inject`(技能文本可以让一个有 shell
能力的 Agent 替它搬运)、`shell.openExternal`、`bus.publish` 转给一个有网络
能力的插件,以及插件进程里的原生 `fetch` —— 最后一项需要 ADR 0008 D009
-的沙箱化插件运行时。
+的沙箱化插件运行时。`pi.net.fetch` 并不会缩小这些缺口:宿主只负责套用白名单、
+手工跟随重定向并审计这次调用,它从不重试、不限流、也不重新发起请求 —— 上游的
+`429` 会带着服务器给出的 `Retry-After` 原样到达插件,插件怎么处理是插件自己
+的策略。
## 8. 1 MCP 服务器出口和凭证