Skip to content

Safety and Trust Boundaries zh CN

JanYork edited this page Aug 14, 2026 · 1 revision

安全模型与信任边界

语言: English · 简体中文

LWC 本地优先,但并不代表不存数据。其安全模型会明确区分规范知识、派生索引、部署配置、外部工具和 Agent 宿主等信任边界。安全与隐私取决于准确 scope、文件系统归属、最小持久内容和有界集成 surface。

数据清单

可能敏感的持久数据包括:

  • 完整 Source snapshot 与 observed origin path;
  • Page body、title、summary、citation、provenance 与 link;
  • Purpose、Schema、tag、strong-context policy 与 operation history;
  • 被记录的 search wording 与 --reason
  • retrieval weight 与 feedback metadata;
  • checkpoint 与 sparse draft database;
  • generated Markdown;
  • CodeGraph symbol name 与 project file path;
  • Agent integration receipt 与 owned host fragment。

Document-graph sidecar、FTS table、span、Viewer response 与 Hook context 都是这些授权状态的派生副本或视图。Derived 不代表不敏感。

数据本地性

LWC core storage、search、graph engine、Viewer 与 MCP 都在本地运行。Grafeo 和 SurrealDB 是 embedded engine,Viewer 使用内嵌资源并只绑定 loopback。

CodeGraph runtime 只有在显式初始化时才从固定 GitHub Release 下载,之后在本地运行并永久关闭 telemetry。可选 MarkItDown 与 AnyDoc 以本地 subprocess 运行,但仍受各自 upstream behavior 约束;转换敏感文档前要先审核这些工具。

Agent host 及其 model provider 是另一个 trust boundary。Agent 读取 Page 或 Hook context 后向已配置模型发送什么内容,不在 LWC 控制范围内。

Secret 扫描

以下 Source 和配置输入会因明显风险被拒绝:

  • 非模板 .env 文件;
  • private-key filename 或 .key.p12.pfx credential file;
  • PEM、OpenSSH 或 PGP private-key marker;
  • AWS、GitHub、OpenAI、Slack 等已知 credential prefix;
  • 明确 conversion credential flag。

Scanner 刻意聚焦明显高风险 pattern,并不是 DLP system,无法识别所有客户 secret、password、private URL、session token 或 proprietary fact。

Ingest 前必须人工审核。不要为了接受一份真实 secret 而削弱 scanner。

最小化持久内容

禁止保存:

  • raw hidden chain-of-thought 或 private model reasoning;
  • transient build log 与大型 debug dump;
  • credential、cookie、access token、private key 或 password;
  • 超出项目授权分级的 customer data;
  • 被写成事实的 unsupported guess;
  • --reason 或可选 recorded search 中的敏感 query wording。

只保存简洁、已验证 conclusion、Source citation,以及未来工作真正需要的最小 evidence。

Query 隐私

searchlint、Viewer 与 MCP 默认只读。只有显式要求记录时,search wording 才进入 operation log。

Retrieval feedback 保存 normalized query terms 的 SHA-256 fingerprint,不保存原 query;但它的 reason 是持久文本。Fingerprint 可以降低意外暴露,却不是 encryption,对已知 query 仍可能关联。

Strong-tag Hook context 会刻意全量载入选中的 Page。Autoload tag 必须保持小而精,禁止把 secret material 标记成全会话规则。

文件系统与路径控制

LWC 会校验 project containment,并拒绝 Store、config、draft runtime、Work、checkpoint、graph、materialization、conversion 与 CodeGraph path 中的不安全 symlink。

系统支持时,owned state file 使用受限 permission,并采用 atomic replacement 或 create-new 语义。lwc init 可以把 .lwc 加入仓库 local Git exclude;应验证仓库策略,而不是提交 runtime state。

本地文件系统权限仍是主要 confidentiality boundary。Backup、checkpoint、temp directory 与 crash report 必须得到和 wiki.db 相同的保护。

MCP 边界

Agent-facing server 只暴露一个 read-only tool:lwc_explore

  • 每次 call 都提供 absolute project path;
  • 拒绝 filesystem root 与 relative path;
  • 验证 mode 与 limit;
  • 缺失 graph capability 保持 unavailable,不会初始化;
  • tool schema 拒绝 write-shaped additional property;
  • CodeGraph 与 memory read 都限制在选中项目内。

Local stdio 之外的 MCP transport security 属于宿主职责。LWC 不开放 network MCP listener。

Hook 与 Instruction 边界

Lifecycle Hook 返回有界 readiness、strong-tag context 与 timing guidance,不会执行 graph initialization 或 conversion setup。

Instruction injection 使用 marker-bounded additive block。Target adapter 只拥有自己的 named MCP entry、Skill directory、recognizable Hook/plugin entry 和 marked Instructions。Receipt hash 可以防止 refresh/uninstall 默默覆盖后来 user edit。

Host trust prompt、UI permission 与 preview activation 保持 user-managed;只有存在官方窄文件 surface 时才自动配置。

Viewer 边界

Viewer:

  • 只监听 127.0.0.1
  • 只开放 GET/HEAD route;
  • 没有 authentication,禁止公开反向代理;
  • 清理 Markdown 并禁止 active embed;
  • 应用 Content Security Policy、frame-ancestors 'none'nosniff
  • 不初始化或修改索引。

同一主机的其他 process 仍可能访问端口。共享系统上查看后要及时停止。

转换边界

默认情况下,LWC 会验证 project-contained input/output,使用 create-new Markdown output,强制 timeout 和 size bound,并且只在最终 safety check 通过后传递 configured adapter argument。

转换不会自动 ingest output。加入 Source 前要检查 prompt injection、恶意 link、异常遗漏与 secret exposure。

External input 必须显式允许。这个选项只扩大 source location,不扩大 output ownership 或 adapter argument authority。

备份与删除

通过 CLI 删除 Page 或 Source,无法清除 checkpoint、旧 draft database、filesystem backup、Agent transcript 或 remote repository history 中已有副本。

以下内容需要各自定义 retention:

  • named checkpoint;
  • failed 或 abandoned draft;
  • generated Markdown backup;
  • CodeGraph index;
  • Agent host log 与 conversation;
  • system backup。

不要把逻辑删除承诺成 cryptographic erasure。

漏洞报告

禁止在 public issue 中包含可用 exploit、secret、private repository path 或 user data。使用仓库的 Security policy,并提供:

  • affected version 与 platform;
  • 被跨越的 trust boundary;
  • 最小非敏感复现;
  • canonical data、credential 或 host file 是否变化;
  • 安全 cleanup 或 containment step;
  • 是否需要 embargo。

安全验收

启用 integration 或导入敏感证据前,确认:

  1. selected scope 与 project path 正确;
  2. data classification 允许本地以及 Agent/model access;
  3. content、argument、reason 或 log 中没有 secret;
  4. optional upstream tool behavior 可接受;
  5. filesystem 与 backup permission 足够;
  6. Hook/tag context 有界;
  7. uninstall 或 recovery 不会破坏 foreign data。

下一篇:发布与升级运维

LWC Wiki

English · 简体中文


Start here · 开始使用

Core capabilities · 核心能力

Practical guides · 实战指南

Capability configuration · 能力配置

Technical design · 技术设计

Operations · 运行与维护

Reference · 参考资料

Contributing · 参与贡献


Repository · Releases

Clone this wiki locally