Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
docs(spec): record the fake-IP cause and the resolved address in the market specs
vastsabdc7b275430f
diff --git a/docs/spec/03-runtime/01-ipc-protocol.md b/docs/spec/03-runtime/01-ipc-protocol.mdindex 2a25f74db..43d3ac6c2 100644--- a/docs/spec/03-runtime/01-ipc-protocol.md+++ b/docs/spec/03-runtime/01-ipc-protocol.md@@ -1465,16 +1465,19 @@ Desktop-only skill market channels (not host RPC) live on Electron IPC:builtin-safe catalog JSON and GitHub repo SKILL.md scans. Source URLs must passthe public-HTTPS policy (ADR 0243). One failing source is dropped; the reststill return. `failureKinds` maps each name in `failedSources` to `policy`- (the public-network guard judged the target and refused it, so the request- never left the process), `unresolved` (the local DNS lookup returned no answer,- so no address was judged — a resolver or proxy condition, not a verdict on the- source), or `network`. `failureDetails` carries the same keys with the host- that actually failed, the guard's own `reason`, and the class of the refused- address, which is what lets the panel name *what* was refused instead of only- which source went quiet. A judged refusal also surfaces as- `NETWORK_POLICY_BLOCKED` and an unanswered resolver as `NETWORK_RESOLVE_FAILED`- (spec 08 §3.1); the install sheet classifies a failed preview on those two- codes.+ (the guard judged the target's own non-public address), `fake-ip` (it judged a+ fake-IP placeholder the local proxy invented for the name — Clash's+ `198.18.0.0/15`; still refused, because the guard fails closed, but a condition+ of the local network rather than a fact about the source), `unresolved` (the+ local DNS lookup returned no answer, so no address was judged), or `network`.+ `failureDetails` carries the same keys with the host that actually failed, the+ address it resolved to, the guard's own `reason`, and that address's class,+ which is what lets the panel name *what* was refused — "your proxy answered+ github.com with 198.18.0.1" — instead of only which source went quiet. A judged+ refusal and a fake-IP refusal both surface as `NETWORK_POLICY_BLOCKED` (both+ are refusals the guard decided), and an unanswered resolver as+ `NETWORK_RESOLVE_FAILED` (spec 08 §3.1); the install sheet classifies a failed+ preview on those codes together with the structured `reason`.- `pi-desktop/skill/market/fetch` — `{ entry }` → `{ name?, description?, body, resources? }`.Main fetches the document over the same policy, splits frontmatter, and mayattach sibling `.md` files from a jsDelivr listing. The renderer installsdiff --git a/docs/spec/03-runtime/08-error-codes.md b/docs/spec/03-runtime/08-error-codes.mdindex 7a9e5e8aa..faf86c85c 100644--- a/docs/spec/03-runtime/08-error-codes.md+++ b/docs/spec/03-runtime/08-error-codes.md@@ -66,7 +66,7 @@ registered; reserved codes in §3.7 remain intentionally absent from| `APPROVAL_STALE` | no | RACP: the approval was already settled or belongs to an older turn || `PAYLOAD_TOO_LARGE` | no | RACP: a frame exceeded the negotiated size bound || `TIMEOUT` | yes | generic timeout |-| `NETWORK_POLICY_BLOCKED` | no | the main-process public-network guard refused a fetch because it *judged* the target: the URL failed the syntactic public-HTTPS check, or the local DNS lookup returned an address the policy classifies as non-public (ADR 0243). A desktop-only code; a refusal is a verdict, so retrying cannot succeed until the address changes. A resolver that returned no answer at all is `NETWORK_RESOLVE_FAILED` instead (issue #419). |+| `NETWORK_POLICY_BLOCKED` | no | the main-process public-network guard refused a fetch because it *judged* the target: the URL failed the syntactic public-HTTPS check, or the local DNS lookup returned an address the policy classifies as non-public — including a fake-IP placeholder a local proxy invented (ADR 0243). A desktop-only code; a refusal is a verdict, so retrying cannot succeed until the address changes. A resolver that returned no answer at all is `NETWORK_RESOLVE_FAILED` instead (issue #419). || `NETWORK_RESOLVE_FAILED` | yes | the main-process public-network guard could not classify the target host: the local DNS lookup returned no answer, or threw before returning one. The request is refused exactly as a policy refusal is, but no address was judged, so no page or log may report it as an address-check decision. Distinct from `NETWORK_ERROR`, which is a failure of the request itself. Retriable: a resolver or proxy that starts answering the same host makes the same request succeed (ADR 0243, issue #419). || `HOST_SHUTTING_DOWN` | yes | the host received EOF and is draining; the call was refused rather than started || `RATE_LIMITED` | yes | a per-caller host budget (plugin session import, batch operations) was exceeded inside its window |diff --git a/docs/spec/03-runtime/09-logging-and-observability.md b/docs/spec/03-runtime/09-logging-and-observability.mdindex 34d7f718d..3bb670da3 100644--- a/docs/spec/03-runtime/09-logging-and-observability.md+++ b/docs/spec/03-runtime/09-logging-and-observability.md@@ -54,19 +54,21 @@ The application categories are:- `diagnostics` — blocked navigation, menu, template, and outbound-fetchdiagnostics. The skill market's two channels record one`skillMarket.sourceFailed` / `skillMarket.documentFailed` record per source- or document that produced nothing, with `source`, `host`, `kind` and — for a- guard refusal — `reason` and `addressKind` in `data`. `kind` is `policy` when- the guard judged the target, `unresolved` when the local resolver returned no- answer, and `network` otherwise; `code` is `NETWORK_POLICY_BLOCKED` for the- first and `NETWORK_RESOLVE_FAILED` for the second, so one log line separates- "the address is not public" from "the resolver answered nothing". `reason`- names the guard's own branch (`url-syntax`, `resolve-failed`,- `non-public-address`, `redirect-limit`) and `addressKind` the class of the- refused address (`benchmark` for a TUN fake-IP, `private` for RFC1918). The- record carries the host name and that class only — never the address, the URL,- its path, query or credentials — because a catalog source URL is- user-supplied, the refused host is the whole diagnostic value, and the class- is what tells a resolver artifact from a real private target (issue #419).+ or document that produced nothing, with `source`, `host`, `kind`, `address`+ and — for a guard refusal — `reason` and `addressKind` in `data`. `kind` is+ `policy` when the guard judged the target's own address, `fake-ip` when it+ judged a placeholder the local proxy invented for the name (Clash's+ `198.18.0.0/15`), `unresolved` when the local resolver returned no answer, and+ `network` otherwise; `code` is `NETWORK_POLICY_BLOCKED` for the first two and+ `NETWORK_RESOLVE_FAILED` for the third, so one log line separates "the address+ is not public" from "a proxy answered with a fake-IP" from "the resolver+ answered nothing". `reason` names the guard's own branch (`url-syntax`,+ `resolve-failed`, `non-public-address`, `redirect-limit`) and `addressKind` the+ class of the refused address (`benchmark` for a TUN fake-IP, `private` for+ RFC1918). The record carries the host name, the address it resolved to and that+ class — never the URL, its path, query or credentials — because a catalog+ source URL is user-supplied and the refused host and address are the whole+ diagnostic value (issue #419).- `runtime` — host/sidecar lifecycle, uncategorized child output, andmain-process `uncaughtException` / `unhandledRejection` recordsdiff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.mdindex 7b5622f79..36104986c 100644--- a/docs/spec/06-delivery/04-e2e-test-plan.md+++ b/docs/spec/06-delivery/04-e2e-test-plan.md@@ -12172,12 +12172,17 @@ plugin-form fixtures in an isolated temporary directory at runtime.policy error without fetching the private target. A judged refusal is notretried; a local resolver that answered nothing is, and is reported as`NETWORK_RESOLVE_FAILED` (`kind` `unresolved`) rather than as an address-check- refusal — the guard reached no verdict, so nothing may claim it did. Every- other refusal carries `NETWORK_POLICY_BLOCKED` (spec 08 §3.1) with its- `reason` and the class of the refused address, so the install sheet can name- the reason and offer a retry instead of leaving the install button disabled- with no explanation, and the market list can tell a refused source apart from- a merely unreachable one.+ refusal — the guard reached no verdict, so nothing may claim it did. An address+ in a proxy's fake-IP range (`198.18.0.0/15`, Clash's default) is refused and+ not retried, and is reported as `kind` `fake-ip` with `addressKind` `benchmark`+ — distinct from a real private target (`kind` `policy`, `addressKind`+ `private`), because the guard judged the target in the second case and only the+ proxy's placeholder in the first. Every other refusal carries+ `NETWORK_POLICY_BLOCKED` (spec 08 §3.1) with its `reason`, the address it+ resolved to, and the class of that address, so the install sheet can name the+ reason and offer a retry instead of leaving the install button disabled with no+ explanation, and the market list can tell a refused source apart from a merely+ unreachable one.- **Specs linked**: `05-security/01-security.md`, ADR 0243,`03-runtime/01-ipc-protocol.md` §12b- **Acceptance**: Security, Qualitydiff --git a/docs/zh-CN/spec/03-runtime/01-ipc-protocol.md b/docs/zh-CN/spec/03-runtime/01-ipc-protocol.mdindex 98c777c3f..ed2384721 100644--- a/docs/zh-CN/spec/03-runtime/01-ipc-protocol.md+++ b/docs/zh-CN/spec/03-runtime/01-ipc-protocol.md@@ -1214,8 +1214,8 @@ ASCII slug:frontmatter `name` 能 slugify 时用它,否则 `SKILL.md` 用技- `pi-desktop/skill/market/search` — `{ query, sources[] }` →`{ entries, failedSources, failureKinds, failureDetails }`。主进程聚合目录 JSON 与 GitHub 仓库 SKILL.md 扫描。源 URL 必须通过公网 HTTPS 策略(ADR 0243)。单源失败只丢掉该源。- `failureKinds` 把 `failedSources` 中的每个名字映射到 `policy`(公网策略守卫判定了目标并拒绝,请求从未离开进程)、`unresolved`(本地 DNS 解析没有返回答案,因此没有判定任何地址——这是解析器或代理的环境状况,不是对源的判定)或 `network`。`failureDetails` 以同样的键携带真正失败的主机、守卫自己的 `reason` 以及被拒地址的类别;面板据此说明**被拒的是什么**,而不只是哪个源没出结果。- 判定型拒绝以 `NETWORK_POLICY_BLOCKED` 暴露,解析器无应答以 `NETWORK_RESOLVE_FAILED` 暴露(spec 08 §3.1);安装面板正是按这两个错误码分类。+ `failureKinds` 把 `failedSources` 中的每个名字映射到 `policy`(守卫判定的是目标自身的非公网地址)、`fake-ip`(判定的是本地代理伪造的 fake-IP 占位地址,如 Clash 默认的 `198.18.0.0/15`;仍被拒绝,但这是本地网络的状况而不是源的问题)、`unresolved`(本地 DNS 解析没有返回答案,因此没有判定任何地址)或 `network`。`failureDetails` 以同样的键携带真正失败的主机、解析到的地址、守卫自己的 `reason` 与地址类别;面板据此说明**被拒的是什么**(例如「代理把 github.com 应答为 198.18.0.1」),而不只是哪个源没出结果。+ 判定型拒绝与 fake-IP 拒绝都以 `NETWORK_POLICY_BLOCKED` 暴露(两者都是守卫作出的拒绝),解析器无应答以 `NETWORK_RESOLVE_FAILED` 暴露(spec 08 §3.1);安装面板正是按这些错误码与结构化 `reason` 分类。- `pi-desktop/skill/market/fetch` — `{ entry }` → `{ name?, description?, body, resources? }`。主进程按同一策略拉取文档、拆 frontmatter,并可能附上 jsDelivr 目录中的兄弟 `.md`。渲染层通过现有 `skills.create` 安装。该策略即主进程公网网络客户端:语法 URL 防护、DNS 分类、逐跳重定向复核与响应上限——渲染层绝不直接触网。目录 id 会净化为 host `valid_capability_id`。diff --git a/docs/zh-CN/spec/03-runtime/08-error-codes.md b/docs/zh-CN/spec/03-runtime/08-error-codes.mdindex d8a566550..c1ee89cc6 100644--- a/docs/zh-CN/spec/03-runtime/08-error-codes.md+++ b/docs/zh-CN/spec/03-runtime/08-error-codes.md@@ -68,7 +68,7 @@ type AppError = {| `APPROVAL_STALE` | 不 | RACP:审批已被处理或属于更早的回合 || `PAYLOAD_TOO_LARGE` | 不 | RACP:帧超过协商的大小上限 || `TIMEOUT` | 是的 | 通用超时 |-| `NETWORK_POLICY_BLOCKED` | 不 | 主进程公网策略守卫拒绝了一次抓取,因为它**判定了**目标:URL 未通过公网 HTTPS 语法检查,或本地 DNS 解析返回了策略判定为非公网的地址(ADR 0243)。仅桌面端使用;拒绝即判定,因此在地址改变前重试不会成功。本地解析完全没有返回答案时改用 `NETWORK_RESOLVE_FAILED`(issue #419)。 |+| `NETWORK_POLICY_BLOCKED` | 不 | 主进程公网策略守卫拒绝了一次抓取,因为它**判定了**目标:URL 未通过公网 HTTPS 语法检查,或本地 DNS 解析返回了策略判定为非公网的地址——其中包括本地代理生成的 fake-IP 占位地址(ADR 0243)。仅桌面端使用;拒绝即判定,因此在地址改变前重试不会成功。本地解析完全没有返回答案时改用 `NETWORK_RESOLVE_FAILED`(issue #419)。 || `NETWORK_RESOLVE_FAILED` | 是的 | 主进程公网策略守卫无法判定目标主机:本地 DNS 解析没有返回答案,或在返回前抛错。请求仍与策略拒绝一样被拒,但没有判定任何地址,因此任何界面或日志都不得把它描述成地址校验的判定结果。与 `NETWORK_ERROR` 不同,后者是请求本身的失败。可重试:当解析器或代理开始应答同一主机时,同一请求即可成功(ADR 0243,issue #419)。 || `HOST_SHUTTING_DOWN` | 是的 | 主机收到 EOF 正在排空;调用被拒绝而不是被启动 || `RATE_LIMITED` | 是的 | 某个按调用方计的主机预算(插件会话导入、批量操作)在其窗口内被超出 |diff --git a/docs/zh-CN/spec/03-runtime/09-logging-and-observability.md b/docs/zh-CN/spec/03-runtime/09-logging-and-observability.mdindex a852c957a..dc6d9ae4a 100644--- a/docs/zh-CN/spec/03-runtime/09-logging-and-observability.md+++ b/docs/zh-CN/spec/03-runtime/09-logging-and-observability.md@@ -52,7 +52,7 @@ host 和 agent stderr 使用标记进行分类;无法分类的子进程输出- `provider` — provider/model 发现、重试和缓存失败- `persistence` — 成绩单和发件箱持久化失败- `updater` — 更新器诊断和错误-- `diagnostics` — 阻止导航、菜单、模板以及对外请求的诊断。技能市场的两个通道会为每个没有产出结果的源或文档各记录一条 `skillMarket.sourceFailed` / `skillMarket.documentFailed`:`data` 里带 `source`、`host`、`kind`,以及被守卫拒绝时的 `reason` 与 `addressKind`。`kind` 在守卫判定了目标时为 `policy`,本地解析没有返回答案时为 `unresolved`,其余为 `network`;`code` 前者为 `NETWORK_POLICY_BLOCKED`,后者为 `NETWORK_RESOLVE_FAILED`,因此一行日志即可区分「地址不是公网」与「解析器没有应答」。`reason` 记录守卫自己的分支(`url-syntax`、`resolve-failed`、`non-public-address`、`redirect-limit`),`addressKind` 记录被拒地址的类别(TUN fake-IP 为 `benchmark`,RFC1918 为 `private`)。记录中只保留主机名与该类别 —— 绝不包含地址、URL、其路径、查询串或凭据 —— 因为目录源 URL 由用户提供,被拒绝的主机正是全部诊断价值所在,而该类别正是区分解析器产物与真实私网目标的依据(issue #419)。+- `diagnostics` — 阻止导航、菜单、模板以及对外请求的诊断。技能市场的两个通道会为每个没有产出结果的源或文档各记录一条 `skillMarket.sourceFailed` / `skillMarket.documentFailed`:`data` 里带 `source`、`host`、`kind`、`address`,以及被守卫拒绝时的 `reason` 与 `addressKind`。`kind` 在守卫判定的是目标自身地址时为 `policy`,判定的是本地代理伪造的 fake-IP 占位地址时为 `fake-ip`,本地解析没有返回答案时为 `unresolved`,其余为 `network`;`code` 前两者为 `NETWORK_POLICY_BLOCKED`,第三者为 `NETWORK_RESOLVE_FAILED`,因此一行日志即可区分「目标地址不是公网」「代理用了 fake-IP」与「解析器没有应答」。`reason` 记录守卫自己的分支(`url-syntax`、`resolve-failed`、`non-public-address`、`redirect-limit`),`addressKind` 记录被拒地址的类别(TUN fake-IP 为 `benchmark`,RFC1918 为 `private`)。记录会保留主机名、被解析到的地址与该类别 —— 但绝不包含 URL、其路径、查询串或凭据 —— 因为目录源 URL 由用户提供,而被拒绝的主机、地址及其类别正是全部诊断价值所在(issue #419)。- `runtime` — host/sidecar 生命周期、未分类的子进程输出,以及主进程`uncaughtException` / `unhandledRejection` 记录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.mdindex e377701cd..969a47367 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@@ -7367,7 +7367,7 @@ runner 会在运行时的隔离临时目录中生成六个插件形态 fixture- **前提条件**:共享 public-network helper,以及可注入 fetch/DNS 的主进程公网 HTTPS 客户端。- **步骤**:1)分类 trailing-dot localhost、IPv4 回环、IPv4-mapped IPv6、ULA、link-local、RFC1918 与 `http://`。2)将公网主机名解析到私网 A 记录。3)跟随 Location 为 `https://127.0.0.1/` 的 302。-- **预期**:上述绕过形态全部拒绝;公共 CDN 放行。解析到私网地址或 redirect 到回环会抛出策略错误,且不会请求私网目标。判定型拒绝不重试;本地解析没有返回答案时会重试,并且报为 `NETWORK_RESOLVE_FAILED`(`kind` 为 `unresolved`),而不是报成地址校验拒绝——守卫并未得出判定,任何文案都不得声称它得出了。其余每次拒绝都带上 `NETWORK_POLICY_BLOCKED`(spec 08 §3.1)及其 `reason` 与被拒地址的类别,使安装面板能给出原因并提供重试,而不是让安装按钮无解释地保持禁用;市场列表也能把被拒绝的源与单纯不可达的源区分开。+- **预期**:上述绕过形态全部拒绝;公共 CDN 放行。解析到私网地址或 redirect 到回环会抛出策略错误,且不会请求私网目标。判定型拒绝不重试;本地解析没有返回答案时会重试,并且报为 `NETWORK_RESOLVE_FAILED`(`kind` 为 `unresolved`);解析到本地代理伪造的 fake-IP(如 Clash 默认的 `198.18.0.0/15`)仍被拒绝且不重试,并以 `kind` 为 `fake-ip`、`reason` 为 `non-public-address`、`addressKind` 为 `benchmark` 记录,与真实私网目标(`kind` 为 `policy`、`addressKind` 为 `private`)清楚区分——对后者守卫判定了目标,对前者没有。其余每次拒绝都带上 `NETWORK_POLICY_BLOCKED`(spec 08 §3.1)及其 `reason`、被解析到的地址与地址类别,使安装面板能给出原因并提供重试,而不是让安装按钮无解释地保持禁用;市场列表也能把被拒绝的源与单纯不可达的源区分开。- **链接规格**:`05-security/01-security.md`、ADR 0243、`03-runtime/01-ipc-protocol.md` §12b- **验收**:Security、Quality- **里程碑**:M6+