Skip to content

fix(public-boundary): unify local-path verdicts across presentation and public guards - #9080

Open
gcl-coder wants to merge 5 commits into
loopx-project:mainfrom
gcl-coder:codex/public-boundary-local-path
Open

gcl-coder wants to merge 5 commits into
loopx-project:mainfrom
gcl-coder:codex/public-boundary-local-path

Conversation

@gcl-coder

@gcl-coder gcl-coder commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Two public boundaries disagreed on the same local-path text, in both directions. Reproduced directly against source at ff9054376:

value presentation before public-output guard before after (both)
see file:///Users/alice/goal.md accept reject reject
path:/Users/alice/goal.md accept reject reject
///tmp/a.log reject accept reject
//Users/alex/x reject accept reject
x=/private/a accept reject reject

The public-output guard is the busiest public surface, so a tuple of guards reaching different verdicts means whether a path leaks depends on which entry point produced the text. The two leading-slash forms were also missing from the shared owner used by classify_private_text.

Review regressions this fixes: the first delegation also started accepting bare directory roots (/home/, ///var/, C:\), began rejecting ordinary http(s) links whose paths contain /home/ or /Users/, and left the global-risk TypeScript mirror without the 2+ leading-slash and directory-root rules.

Change

  • The shared text owner now recognizes the 2+ leading-slash absolute-root form alongside the existing absolute, home-relative, path:-prefixed, boundary-assignment, and file:// shapes.
  • presentation._plain_text delegates its absolute-path verdict to find_public_safe_local_path. Its existing .codex, .git and .local relative-directory rejection remains an explicit presentation policy, with the reason recorded at the definition.
  • Bare directory roots keep the baseline presentation verdict: a root with nothing after it (/home/, ///var/, C:\) is still rejected there, and the shared absolute, slash-run and ~/ arms keep their "root may end the reference" behavior.
  • Ordinary http(s) links are masked before local-path detection, preserving character positions. That covers a trailing-dot host (https://docs.example.test./home/overview), IPv6 authorities, path-shaped query values, and a /Users/ segment inside a public URL. file:// and path: remain local-path references, and credential detection keeps the raw text. The mask is applied in find_public_safe_local_path, the local-path category arms of classify_private_text, public_safe_compact_text, and the TypeScript Vision checkpoint; the publication tier (find_private_text_match) stays strict.
  • The global-risk TypeScript mirror now carries the same 2+ leading-slash and directory-root rules as Python.
  • The shared corpus pins the five table rows in both directions, including the deliberate narrower publication-tier verdict for ///tmp/a.log and x=/private/a, plus a public URL with a /Users/ path segment.
  • A real publish_extension_projection test confirms a rejected view leaves the existing projection bytes and payload digest unchanged.

Controls

https://example.com/docs, https://docs.example.test./home/overview, the token budget is 1200, and /Users/alice prose keep their current verdicts on every surface that already had them. contract.py behavior, the short-assignment credential decision (direction 2), and the other surface migrations are unchanged.

Verification

  • 376 passed: owner parity, credential caller faces, path shapes, text budget, and global-risk parity.
  • 82 passed: extension presentation and presentation public safety, including the real publish_extension_projection publish/readback pair.
  • 8 passed in the TypeScript corpus suite (node --test); npm run typecheck:control-plane passed.
  • ruff check passed on every changed Python file.
  • loopx canary premerge --tier quick --from-git-diff: 3 selected checks, 0 failures, 1 advisory (a maintainability finding outside the changed files).

Refs #5136, direction 3.

…nd guards

Refs loopx-project#5136.

Signed-off-by: ChengLong GU <88359731+gcl-coder@users.noreply.github.com>

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent · gpt-6.2-sol · OpenAI (runtime_reported, max)

[P2] 公开视图漏拒以根分隔符结尾的目录引用

用同一合成扩展先发布合法视图,再更新为只有目录根的标题。基准拒绝三种目录根形态并保留旧快照与摘要,候选全部发布成功,按新摘要能读回。旧检查匹配目录前缀,共享检测对这些根要求后面还有内容。在共享路径 owner 保留原目标表面覆盖的根目录形态,补验 Unix、连续斜杠和盘符路径根,并验证拒绝后已发布快照和摘要不变。 相关代码

[P2] 合法 HTTPS 链接被误判为本地文件路径

将标题设为合法链接 https://docs.example.test./home/overview。基准成功发布,候选抛出本地路径错误。带 DNS 根点的域名后恰好出现普通的 home 路径段,使正则在 URL 内部起匹配。去掉根点的对照两版均可发布。让共享 owner 区分普通 HTTP(S) 链接的路径段与本地引用,保留 file URL 和明确本地引用的拒绝,以及同字段内公开链接以外的检查。 相关代码

动机 / Motivation

扩展作者发布公开面板时,需要保留可用的资料链接,并拦截指向机器文件系统的引用。

旧版会拒绝只指向本机目录根的引用,却漏过部分 file URL。新版补上 file URL,同时在相同发布入口放行了三类原本会拒绝的目录根引用,并误拒了一种合法 HTTPS 链接。

用同一合成扩展走真实发布和按摘要读回。候选写入了三个本应拒绝的目录根引用,并在合法链接上返回本地路径错误。普通 HTTPS 对照和新版拒绝 file URL 均通过。

这次核对聚焦公开视图的输入、发布和读回。凭据阈值和其他扩展权限由原有路径决定。

改动思路 / Approach

共享 owner 适合持有路径识别,扩展发布边界应保留自己的拒绝与原子替换保证。统一到匹配器前须对照旧公开视图已拒绝的值和已接受的普通链接。

本次只对齐现有扩展发布和通用公开输出的本地路径检测,并核对内部状态的 TypeScript 镜像。扩展权限和凭据策略沿用现有规则。

生产调用在写快照前验证已登记的公开视图。真正拒绝时会保留旧版本和摘要,所以用同一提供者在基准和候选各走一次发布,再按摘要读回。单个字符串分类测试无法判断回退是否保存了当前可用版本。

具体改动 / Changes

评审精确提交 bd974e1,基准 ff90543。九个文件增加 229 行、删除 14 行。三处生产代码切换路径检测与同步 Vision 匹配规则,六处测试与语料验证边界。按 issue #5136 的维护者决定 issuecomment-5857977250 核对。direction-3-local-reference 与 direction-3-public-link 仍有缺口。direction-4-real-entrypoint 已通过实际调用补验。 验收约定

关键代码讲解

  • _plain_text 改用共享路径检测,同时保留扩展的私有相对目录策略。 源码
  • LOCAL_PATH_SURFACE_PATTERN 匹配已知根和盘符。候选把这条搜索用于原先的前缀检查处,暴露了两种方向的差异。 源码
  • MULTI_SLASH_LOCAL_PATH_PATTERN 覆盖带子路径的连续斜杠引用。测试需要加上目录根本身。 源码
  • LOCAL_PATH_SHAPE 是已有 Vision 状态校验的 TypeScript 对应规则。共享语料覆盖新增匹配,实际发布调用另行验证。 源码

对主干的风险 / Risks

同一公开扩展发布路径 基准 候选
目录根引用,三种形态 拒绝,原快照保持 发布并读回
带 DNS 根点的 HTTPS 链接 发布并读回 误拒,原快照保持
普通 HTTPS 链接 发布并读回 发布并读回
合成 file URL 发布 拒绝,原快照保持

语义与 CI 对齐

复用已有 local path 类别及发布权限。将共享检测直接用于扩展视图引入了这四处回归,快照写入器仍按此前流程处理。聚焦及相邻 Python 共 478 项通过,TypeScript 82 项通过,类型检查和 Ruff 通过。标准 premerge 通过,6 项直接检查、10 项选中检查,1 项未改动代码的可维护性提示。 补充的真实发布用例在候选发现四处失败。按当前策略未查询远端 CI。

我的整体评价 / Verdict

请求修改这一提交。保留 file URL 收紧,修复目录根漏判和合法链接误判后,在同一个真实发布入口验证老快照与新读回两个方向。当前 diff 改变公开扩展视图的验证与可发布内容,渲染和布局代码无改动。已通过产物读回复核内容差异。

English verdict: REQUEST_CHANGES exact head bd974e1. The new local-path delegate publishes three previously rejected root references and rejects a legitimate HTTPS link. The file-URL fix and ordinary HTTPS control work.

if "\x00" in text or _MARKUP_RE.search(text):
raise ValueError(f"{context} must be plain text without markup")
if _LOCAL_PATH_RE.search(text) or _PRIVATE_RELATIVE_PATH_RE.search(text):
if find_public_safe_local_path(text) or _PRIVATE_RELATIVE_PATH_RE.search(text):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

实际发布用同一个合成提供者和相同输入做了前后对照。这个委派漏掉原先拒绝的目录根引用,也会挡住带 DNS 根点的正常 HTTPS 链接。请在共享检测中保留完整的目录根覆盖,并按 URL 上下文识别普通链接。补验拒绝时旧快照不变,以及合法链接可写入后按摘要读回。

Refs loopx-project#5136; unblocks the repository-wide lint lane used by this PR.

Signed-off-by: ChengLong GU <88359731+gcl-coder@users.noreply.github.com>

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent · Gemini · Google (self_reported)

[P2] 修改 PRESENTATION_LOCAL_PATH_PATTERNS 后未同步 TypeScript 镜像导致双端测试失败与脱敏漂移

  • Trigger / 触发条件:在 public_safe_text.py 中向 PRESENTATION_LOCAL_PATH_PATTERNS(及 PRESENTATION_PUBLIC_BOUNDARY_PATTERNS)加入了 MULTI_SLASH_LOCAL_PATH_PATTERN,但未同步更新声明与之保持镜像的 global_risk_read.ts。
  • Observed Outcome / 实际结果:双端正则一致性测试 tests/test_global_risks_path_pattern_parity.py::test_global_risks_path_patterns_match_python_owner 在基准 ff9054376 通过(1 passed),而在当前提交 bd974e1f4e0cfa2ffa27692fd9c3c71274137758 失败(1 failed,长度 4 对 5 且第 3 项不匹配)。直接调用两者脱敏路径时,Python redact_public_text 会将 ///opt/a.log 和 //Volumes/disk/x 脱敏为 <local-path-redacted>,而 TypeScript global_risk_read.ts 的 LOCAL_PATH_PATTERNS 仍原样保留这两个连续斜杠路径。
  • Minimum Repair / 最小修复:同步更新 loopx/control_plane/presentation/global_risk_read.ts 中的 LOCAL_PATH_PATTERNS(或评估本 PR 是否应改动 PRESENTATION_LOCAL_PATH_PATTERNS),使双端对全部展示根目录和连续斜杠前缀保持一致,并跑通 uv run --extra test python -m pytest tests/test_global_risks_path_pattern_parity.py -q 与 npm run test:control-plane。

[P2] presentation._plain_text 委托共享检测后放行以分隔符结尾的目录根引用

  • Trigger / 触发条件:presentation.py 将原来的 _LOCAL_PATH_RE 替换为 find_public_safe_local_path(text),而扩展视图中的标题等文本只包含目录根引用且以根分隔符结尾(如 see /home/、see /home/ next、see ///var/、see C:\、see D:/)。
  • Observed Outcome / 实际结果:LOCAL_PATH_SURFACE_PATTERN 与 MULTI_SLASH_LOCAL_PATH_PATTERN 均要求根目录后至少跟一个非空白字符,而 LOCAL_PATH_BOUNDARY_REFERENCE_PATTERN 仅覆盖了少数几个根目录前缀,遗漏了 /home/、/var/、多斜杠根及 Windows 盘符根。在同一个真实发布入口 publish_extension_projection 上做基准对照:基准 ff9054376 全部拒绝上述输入并保持已有快照字节与 payload_sha256 不变;当前提交 bd974e1f4e0cfa2ffa27692fd9c3c71274137758 全部成功发布并可通过 read_extension_projection 读回,违背了非静默放宽承诺。
  • Minimum Repair / 最小修复:在共享路径检测或展示边界保留原有完整目录根形态(含单/多斜杠 Unix 根、盘符根与 ~ 根),并通过真实 publish_extension_projection + read_extension_projection 回归测试验证拒绝时旧快照与摘要保持不变。

[P2] 合法 https:// 链接在扩展展示校验中被误判为本地路径

  • Trigger / 触发条件:扩展公开视图文本包含合法 https:// 链接,且紧邻 /home/、/tmp/ 等路径段前出现非字母数字及非 :/ 字符,例如带 DNS 根点的 https://docs.example.test./home/overview、https://docs.example.test./tmp/guide,IPv6 字面量主机 https://[::1]/home/overview,或查询参数中的路径形态 https://example.com/docs?next=/home/alice。
  • Observed Outcome / 实际结果:基准 ff9054376 的 _LOCAL_PATH_RE 要求路径位于行首、空白或左括号之后,因此上述链接均可正常通过 publish_extension_projection 发布并读回;当前提交委托给 find_public_safe_local_path 后,LOCAL_PATH_SURFACE_PATTERN 的单字符负向后顾 (?<![:/A-Za-z0-9]) 会放行域名末尾的 .、IPv6 的 ],而 LOCAL_PATH_BOUNDARY_REFERENCE_PATTERN 会命中查询参数中的 =,导致以上合法 https:// 链接全部以 must not contain a local path 被拒绝(去掉根点的对照 https://docs.example.test/home/overview 则仍可发布)。
  • Minimum Repair / 最小修复:在共享路径识别器或边界判定中按完整 URL 上下文区分普通 http:// / https:// 链接与本地文件系统引用,继续拒绝 file:// URL 与同一字段内混杂的真实本地路径,并用真实发布与读回用例验证正反两向。

动机 / Motivation

扩展作者在发布公开展示面板、控制面调用方在校验公开输出时,需要稳定拦截指向本地文件系统的路径泄漏,同时不能把正常说明文档的 HTTP(S) 链接挡在门外。在合并基线 ff9054376 上,presentation._plain_text 与 validate_public_safe_value 对同一批文本在两个方向上互相冲突:例如 file:// 本地文件链接、path: 前缀以及键值赋值形态的受限目录路径会被 validate_public_safe_value 拒绝,却在扩展展示入口直接放行;而 ///tmp/a.log 等双斜杠以上前缀在扩展展示被拒,在 validate_public_safe_value 与内部状态校验中却被放行。本 PR 旨在把 presentation._plain_text 的绝对/前缀本地路径判断收敛到共享 owner find_public_safe_local_path,为共享 owner 与 TypeScript 内部状态校验补齐多斜杠绝对路径识别,并修正 loopx/contract.py 在测试清册中的说明理由;不涉及短赋值凭据阈值、内部状态整体放宽或其他尚未迁移的调用面。然而在当前提交 bd974e1f4e0cfa2ffa27692fd9c3c71274137758 上实测发现,该合并引入了三处可复现回归:TypeScript 展示脱敏镜像失配导致现有 parity 测试失败、以分隔符结尾的目录根引用被静默放行,以及带 DNS 根点或 IPv6 主机的合法 https:// 链接被误拒,当前尚不能视为可合入的完整收敛。

改动思路 / Approach

从真实入口与数据流来看,presentation.py 的 publish_extension_projection 在写入持久化信封前调用 validate_opaque_presentation_view 与 _plain_text,并在拒绝时通过异常中止写入、维持已有快照和 payload_sha256 不变;另一条热路径 validate_public_safe_value 与能力包校验(decision_context/packets.py、material_lifecycle/_validation.py)则直接消费 public_safe_text.py 中的 find_public_safe_local_path,而全局风险与状态投影的展示脱敏由 PRESENTATION_LOCAL_PATH_PATTERNS 及其 TypeScript 镜像 global_risk_read.ts 共同承担。

真实入口验证观察项 基线 ff9054376 候选 bd974e1f4e 结论
file:// 路径、path: 前缀与赋值受限路径 publish_extension_projection 发布并读回 拒绝并保持原快照不变 预期收紧成立
连续斜杠子路径(如 ///tmp/a.log) presentation 拒绝,validate_public_safe_value 放行 两侧统一拒绝 预期收敛成立
裸目录根(see /home/、see ///var/、see C:\、see D:/) 拒绝并保持原快照不变 发布成功并可读回 静默放宽回归
合法链接 https://docs.example.test./home/overview 发布成功并可读回 误拒并保留原快照 URL 误伤回归
普通对照 https://example.com/docs 与 the token budget is 1200 发布成功并可读回 发布成功并可读回 对照正常
双端脱敏镜像 test_global_risks_path_pattern_parity.py PASS(1 passed) FAIL(index 2 失配) 跨运行时漂移

就架构边界而言,路径识别逻辑应由 loopx/public_safe_text.py 单一持有,loopx/extensions/presentation.py 只保留相对私有目录(.codex、.git、.local)策略及拒绝时的原子不覆写保证;若修改了 PRESENTATION_LOCAL_PATH_PATTERNS,则必须同步更新 TypeScript 镜像 global_risk_read.ts,并先在共享 owner 补全根目录覆盖与 URL 上下文区分后再切换 _plain_text 委托。本 PR 应收敛为:在共享层保留裸目录根覆盖与普通 HTTP(S) URL 豁免、完成 presentation._plain_text 与 validate_public_safe_value 的双向等价对齐,并保证 PRESENTATION_LOCAL_PATH_PATTERNS 与 global_risk_read.ts 同步通过测试;不扩展至其他未迁移模块或凭据阈值改动。

具体改动 / Changes

本次评审精确提交 bd974e1f4e0cfa2ffa27692fd9c3c71274137758(基线 ff905437669054465a4d7aa8c70ba3396aaf9182),共改动 9 个文件(+229 / -14):3 个生产源码文件(loopx/public_safe_text.py、loopx/extensions/presentation.py、loopx/control_plane/goals/vision_checkpoint.ts)与 6 个测试/语料文件。

关键代码讲解

  • loopx/public_safe_text.py — MULTI_SLASH_LOCAL_PATH_PATTERN 与 PRESENTATION_LOCAL_PATH_PATTERNS:在 源码 L246-L251 新增匹配 /{2,} 已知根的规则并加入 PUBLIC_SAFE_LOCAL_PATH_PATTERNS 及 _SHAPE_DETECTORS,使 find_public_safe_local_path 与 classify_private_text 统一覆盖连续斜杠形态,同时保持 find_private_text_match(publication tier)边界不动。但 源码 L310、L348 同时改写了 PRESENTATION_LOCAL_PATH_PATTERNS 与 PRESENTATION_PUBLIC_BOUNDARY_PATTERNS,未同步修改其 TypeScript 镜像。
  • loopx/extensions/presentation.py — _plain_text:在 源码 L169 删除本地 _LOCAL_PATH_RE,改用 find_public_safe_local_path(text) or _PRIVATE_RELATIVE_PATH_RE.search(text)。由于共享正则对部分根目录要求后接非空白字符、且未按完整 URL 上下文豁免 http(s)://,直接暴露了上述放宽与误拒两条行为偏差。
  • loopx/control_plane/goals/vision_checkpoint.ts — LOCAL_PATH_SHAPE:在 源码 L202 将内部状态检测中的 / 改为 /{1,},与 Python classify_private_text 在内部状态层级保持一致,未改变 PRIVATE_TEXT_PATTERNS。
  • tests/control_plane/test_public_safety_credential_caller_faces.py — DECLARED_OPEN_SITES:在 源码 L259-L267 纠正 loopx/contract.py 的保留理由。经实测核验,contract.py 确实通过 CREDENTIAL_ENVIRONMENT_REFERENCE_PATTERN 与 CREDENTIAL_VARIABLE_REFERENCE_PATTERN 放行代码变量/环境引用(例如环境变量查找表达式或变量引用赋值在 contract.py 判定为引用放行,而 find_private_text_match 直接拒绝),并通过 CREDENTIAL_HIGH_ENTROPY_VALUE_PATTERN 拦截高熵值,理由修正准确且未改动运行时行为。

规范与验收标准映射

按 issue #5136 维护者裁定(参考基线 ff905437669054465a4d7aa8c70ba3396aaf9182)逐项核对:

  • D3-LOCAL-PATH -> implemented:loopx/public_safe_text.py::MULTI_SLASH_LOCAL_PATH_PATTERN 补齐连续斜杠子路径识别,相关语料与对齐测试通过。
  • D3-NO-SILENT-LOOSENING -> not_met:presentation._plain_text 迁移后静默放行 see /home/、see ///var/、see C:\、see D:/ 等裸目录根引用。
  • D3-URL-SAFE -> not_met:presentation._plain_text 新增误拒带 DNS 根点或 IPv6 方括号的合法 https:// URL,违反不得误伤普通 HTTP URL 的约束。
  • D3-RUNTIME-PARITY -> not_met:修改 PRESENTATION_LOCAL_PATH_PATTERNS 后未更新 TypeScript 镜像 global_risk_read.ts,导致 tests/test_global_risks_path_pattern_parity.py 失败。
  • D1-CONTRACT-REASON -> implemented:tests/control_plane/test_public_safety_credential_caller_faces.py::DECLARED_OPEN_SITES 修正了 loopx/contract.py 的保留原因,与实际代码规则一致。

对主干的风险 / Risks

如果将当前提交直接合入主干,会带来三方面直接风险:第一,破坏 tests/test_global_risks_path_pattern_parity.py 测试套件,并使 TypeScript /loopx-global-risks 呈现层与 Python presentation/public_safety.py 在多斜杠本地路径脱敏上产生双端行为漂移;第二,允许包含敏感目录根引用(如 /home/、///var/、C:\、D:/)的公开扩展视图写入持久化快照并被读回;第三,阻塞扩展在公开视图字段中发布包含合法特殊域名或 IPv6 主机形态的 https:// 文档链接。

语义与 CI 对齐

  • 语义对齐判定(violated):loopx/public_safe_text.py 中的 PRESENTATION_LOCAL_PATH_PATTERNS 是受跨语言 parity 约束的公开展示边界规则,本次 PR 向其追加 MULTI_SLASH_LOCAL_PATH_PATTERN 时未同步修改 loopx/control_plane/presentation/global_risk_read.ts 的 LOCAL_PATH_PATTERNS,导致双端契约失配,需先对齐双端或收敛修改面后复跑 pytest tests/test_global_risks_path_pattern_parity.py。
  • 本地全量/聚焦验证结果:
    • 聚焦与相关 Python 测试(12 个测试文件):PASS(863 passed)。
    • 全局风险 parity 及扩展示例/上下文测试(9 个测试文件):FAIL(476 passed, 1 failed,唯一失败为本 PR 引入的 tests/test_global_risks_path_pattern_parity.py::test_global_risks_path_patterns_match_python_owner;基线 ff9054376 为 1 passed)。
    • TypeScript 类型检查与 5 组控制面测试(typecheck:control-plane + public_safe_text_corpus / direction_baseline / global_risk_read / content_digest_single_owner / vision_checkpoint):PASS(104 passed)。
    • ruff check(改动 Python 文件):PASS;mypy --strict --follow-imports=silent 在 loopx/public_safe_text.py PASS,在 loopx/extensions/presentation.py 报 2 处基线已有类型错误(L446、L813,与本 PR 无关)。
    • loopx canary premerge --tier quick --from-git-diff(挂载 node_modules 运行 TS 扫描):PASS(semantic-vocabulary-drift-smoke.py 通过;control-plane-maintainability-ratchet-smoke.py 为与本 PR 改动文件无关的已有提示 advisory_inherited_failure);loopx check --scan-path 0 错误。按仓库策略未等待或查询远端 GitHub Actions CI。

我的整体评价 / Verdict

当前 PR 在 ff9054376 到 bd974e1f4e0cfa2ffa27692fd9c3c71274137758 上准确识别并统一了 issue #5136 表格中的五类代表性本地路径形状,DECLARED_OPEN_SITES 修正也有实测支撑,但在工程完整性上存在三处可复现阻塞缺陷:新增规则未同步至 TypeScript 镜像导致 test_global_risks_path_pattern_parity.py 失败、扩展展示端对裸目录根存在静默放宽、以及对合法 https:// 链接出现新的误拒。另外需注意 public_safe_compact_text 仍默认沿用 LOCAL_PATH_SURFACE_PATTERN(本 PR 未声明迁移该辅助函数),且 vision_checkpoint.ts 的 LOCAL_PATH_SHAPE 同样沿用了单字符负向后顾。本次改动不涉及页面渲染与视觉排版(loopx/extensions/presentation.py、loopx/public_safe_text.py、loopx/control_plane/goals/vision_checkpoint.ts 均无渲染层变更),视觉评审不适用,未覆盖域为 none。从可观察语义与长程演进看,presentation._plain_text 的静默放宽和合法链接误拒会直接影响扩展投影的持久化发布与回读,属于明确回归。请在修复上述三项问题(补全目录根覆盖、按完整 URL 上下文放行合法 HTTP(S) 链接、并同步 global_risk_read.ts 使 test_global_risks_path_pattern_parity.py 转绿)后提交新 head 进行复审;复审需在真实 publish_extension_projection + read_extension_projection 路径验证旧快照保留与新读回两向对照。

English verdict: REQUEST_CHANGES exact head bd974e1. Three verified regressions block approval: (1) adding MULTI_SLASH_LOCAL_PATH_PATTERN to PRESENTATION_LOCAL_PATH_PATTERNS without updating loopx/control_plane/presentation/global_risk_read.ts breaks tests/test_global_risks_path_pattern_parity.py and causes TS/Python redaction drift; (2) delegating presentation._plain_text to find_public_safe_local_path silently accepts bare directory-root references (e.g. /home/, ///var/, C:, D:/) that baseline rejected; and (3) valid https:// URLs with DNS root dots, IPv6 host brackets, or path-like query parameters are newly rejected. Focused Python (863 passed) and TS control-plane suites (104 passed) pass, while test_global_risks_path_pattern_parity.py fails on head after passing on base.

Refs loopx-project#5136.

Signed-off-by: ChengLong GU <88359731+gcl-coder@users.noreply.github.com>
A home-directory name inside an ordinary http(s) URL is a URL path segment, the same as the /home/ links the presentation guard already keeps. Mask the URL for the /Users/ local-path arm in the Python classifier and the TypeScript Vision checkpoint, pin the row in the shared corpus, and stay raw on the publication tier.

Signed-off-by: ChengLong GU <88359731+gcl-coder@users.noreply.github.com>
@mergify

mergify Bot commented Nov 20, 2026

Copy link
Copy Markdown

This pull request has merge conflicts with main and cannot be merged
until they are resolved. Please rebase or merge the base branch, @gcl-coder.

Choose the remote for the base repository, not an out-of-date fork.
For a fork clone, first inspect git remote -v; upstream must point
to https://github.com/loopx-project/loopx.git. If it is absent, add it
with git remote add upstream https://github.com/loopx-project/loopx.git.
Then run:

git fetch upstream
git rebase upstream/main
# Resolve each conflict, git add the resolved files, then git rebase --continue.
git push --force-with-lease origin HEAD

For a same-repository clone whose origin points to
https://github.com/loopx-project/loopx.git, use origin instead of
upstream for fetch/rebase. If you prefer merging the base, use
git merge <base-remote>/main and push normally.

Keep the DCO Signed-off-by trailer on every commit when you rebase.
https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify Bot added the needs-rebase Mergify: the pull request has merge conflicts with its base branch label Nov 20, 2026
The unused pytest import is already gone on main; keep this file byte-identical so the PR no longer conflicts with the upstream edit that added the import-group separator.

Signed-off-by: ChengLong GU <88359731+gcl-coder@users.noreply.github.com>
@mergify mergify Bot removed the needs-rebase Mergify: the pull request has merge conflicts with its base branch label Nov 20, 2026
@gcl-coder

Copy link
Copy Markdown
Contributor Author

已按这轮评审的三项意见完成,并额外收掉了一个同类缺口。当前 head 8fb1e868b(5 个提交,13 个文件,+446/−32),与最新主干 cc5392e95 的合并状态为干净(mergeable)。

针对 presentation.py:169 的三项回归:

  1. 裸目录根不被放宽:/home/、///var/、C:\ 这类根后没有内容的写法保持基线的拒绝判定;共享检测器只负责其余形状。真实扩展发布测试确认被拒视图的旧投影字节与 payload_sha256 不变。
  2. 普通 HTTP(S) 链接不再误拒:匹配本地路径前先把 http(s):// URL 整体遮蔽并保留字符位置;覆盖结尾带点的主机、IPv6 authority、路径形查询值,以及 URL 路径里带 /Users/ 段的情况。file:// 与 path: 仍按本地路径处理,凭据检测仍读原值。
  3. TypeScript 镜像同步:global_risk_read.ts 补上连续斜杠与目录根规则;vision_checkpoint.ts 的 /Users/ 与本地路径臂同样先遮蔽 URL。

另补了共享语料一行(URL 内含 /Users/ 段的公开链接),让 Python 与 TypeScript 两端同一条规则被钉住。

验证(本机真实源码、隔离环境):

  • 376 passed:owner parity、凭据调用面、路径形状、文本预算、global-risk parity。
  • 82 passed:扩展呈现与 presentation public safety,含真实 publish_extension_projection 发布/读回对照。
  • 8 passed:TypeScript 语料套件;npm run typecheck:control-plane 通过;ruff check 全过。
  • loopx canary premerge --tier quick --from-git-diff:3 项选中检查,0 失败,1 条 advisory(维护性棘轮命中不在改动文件内)。

另:该文件原先与主干上同一处未使用导入修复冲突,已把该文件对齐主干版本,PR 现在可干净合并。

Windows 文件系统、已安装分发与托管 CI 日志仍未在本地覆盖。

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent | gpt-6.1-sol | OpenAI | runtime_reported | low

[P2] 保留外层 path: 引用后再豁免 URL

mask_http_url_paths 会把 path:/https://example.com/doc 中的 https://example.com/doc 全部遮掉,留下 path:/ 和空格,后续 PATH_PREFIX_LOCAL_PATTERN 因没有路径尾部而不匹配。这是外层已明确标为本地引用的 POSIX 路径,内部 HTTP 形状不应覆盖它的上下文。相同输入在基准共享 owner 命中且嵌套 validate_public_safe_value 拒绝,当前 head owner 未命中、递归 guard 接受;扩展也能发布并按摘要读回。相关代码。先识别并保留显式 path: 本地引用边界,再仅豁免真正的独立 HTTP(S) URL;补验 path:/https://example.com/doc 在公开递归校验中仍拒绝,普通链接仍接受。

动机 / Motivation

公开扩展发布者与生成嵌套公开输出的调用者,需要拒绝明确的本地文件引用,同时保留正常资料链接。原先同一 file URL、path 前缀和多斜杠路径在扩展视图与公共 guard 两向漂移,导致泄漏或重复人工修正。当前改动统一 owner 并修复上轮目录根与合法链接问题,但上述显式本地引用又从拒绝变为接受,仍需修正。显式 path: 引用仍可被 URL 掩码误放行;#5136 其他未迁移表面继续由原 issue 跟踪。

相同 headline 为 path:/https://example.com/doc 时,基准共享 owner 命中且嵌套公开 guard 拒绝;候选掩掉 https://example.com/doc 后两者放行,扩展发布后也能按摘要读回。旧三项问题已通过当前验证;新显式 path: 反例仍失败。不改凭据短赋值策略、扩展执行权限、快照格式或其他领域能力;未测试真实外部扩展、Windows 主机或页面渲染。

改动思路 / Approach

共享 public_safe_text 继续拥有文本分类,presentation 只保留相对私有目录策略;递归 public-output guard 与 TypeScript Vision 镜像消费既有规则。URL 豁免应服从显式本地引用上下文,不应让字符串内出现 HTTP 方案就消除外层本地语义。本 PR 限于本地路径识别、扩展视图发布和受影响镜像;不要求完成 #5136 全部凭据与调用方迁移。与维持两份绝对路径规则相比,删除扩展副本是合理的,TS 镜像则继续由同一语料和 parity 测试约束。最小修复应落在共享上下文判断;给每个调用者再加一个例外会重新制造规则分叉。

发布流程仍先验证 provider 的 view,再交原写入器生成 envelope,消费者用 revision 和摘要读回。验证异常时原文件字节保持,本 PR 没有把检测结果提升为扩展执行权限,也没有新增持久状态或自动重试。

具体改动 / Changes

精确 head 8fb1e868b6bb36fbcb12f869cde90576bbce558f,基准 ff905437669054465a4d7aa8c70ba3396aaf9182;完整范围 13 文件 +446/-32。另区分上轮 bd974e1f4e0cfa2ffa27692fd9c3c71274137758 后的三个修复提交:补根目录、同步展示镜像、豁免 URL。旧发现已在当前 head 实测修复,不能因此直接继承整份批准。

关键代码讲解

  • mask_http_url_paths(loopx/public_safe_text.py:292)整体遮掉 HTTP 字符串;本次问题是未保留外层 path: 上下文。
  • find_public_safe_local_path(同文件 629 行)先掩码再查所有路径臂,因此该错误传播到递归公开 payload 与扩展视图,而不是只影响一个 helper。
  • _plain_text(loopx/extensions/presentation.py:153)移除独立绝对路径 regex,保留私有相对目录和凭据策略;真实拒绝发生在写快照之前。
  • validatePublicSafeText(vision_checkpoint.ts:364)只让本地路径两臂使用掩码;凭据与组织标记仍检查原文。global_risk_read.ts 已同步 Python 展示路径模式,parity 测试通过。

依据 维护者方向,修订标识 issuecomment-5857977250:direction-3-local-reference not_met,原因是显式 path 引用反例;direction-3-public-link implemented,三类普通链接可发布读回;direction-4-real-entrypoint implemented,真实 provider/快照、嵌套 payload 和跨语言验证已执行。未把同一 issue 的全部后续迁移当成本 PR 前置义务。

发布前 head 从 d0f1832 更新到 8fb1e86,唯一新增 diff 是 steward 测试 import 区一行空白;生产实现、依赖、语料和受测调用者均不变。已对新 head 重新执行 453 Python、87 TS、类型检查、同一真实发布反例和标准 premerge,当前结论绑定新 head。

对主干的风险 / Risks

PASS:453 项 Python、87 项 TypeScript、控制面类型检查和标准 premerge;premerge 有一项未改动范围的 inherited maintainability advisory,无 blocking failure。未查询远端 CI。12 类输入在同一脚本、显式 source checkout、immutable base/head 各运行一次。目录根、单独普通链接、链接之外混合真实路径、file URL 与普通 prose 均对照;拒绝时验证了旧快照字节,接受时按摘要读回。

FAIL:明确 path:/https://example.com/doc 的 nested public guard 从基准拒绝变为候选接受。扩展入口在基准也漏拒该值,因此这里区分“公共 guard 新退化”和“扩展迁移仍未闭合”,没有把旧扩展缺口误称为新回归。输入可作为 POSIX 路径,path: 正是现有 owner 明确识别的本地定位符;修复需验证外层定位符的优先级,并保留独立 URL 放行对照。

语义与 CI 对齐

沿用已有 local_path 类别,没有新增公共枚举;新 URL 豁免改变已有 consumer 的默认接受集合,必须满足显式本地引用仍拒绝的合同。测试全部通过未覆盖这一反例,因此不能由 green gate 推导语义正确。先识别并保留显式 path: 本地引用边界,再仅豁免真正的独立 HTTP(S) URL;补验 path:/https://example.com/doc 在公开递归校验中仍拒绝,普通链接仍接受。

我的整体评价 / Verdict

REQUEST_CHANGES。当前单一 owner 与真实发布边界的设计适当,目录根、合法链接和双端镜像旧问题已修;需要先修 URL 掩码对显式本地引用的吞并。长程恢复与原子快照 owner 保持,公开输出安全性出现上述具体退化。范围继续限于现有本地路径迁移,不要求扩展至凭据或新状态机。

视觉评审不适用:完整 diff 无页面、组件、卡片结构或排版改动,内容通过真实发布与读回验证;未覆盖真实第三方扩展、Windows 主机和页面渲染。验证并不证明已经安装或部署。修复后重跑该反例与现有根目录、HTTP URL、嵌套 guard、跨语言语料和标准 premerge。

English verdict: REQUEST_CHANGES exact head 8fb1e86. Earlier root, URL and mirror findings are fixed, but URL masking now lets an explicit path: local reference bypass the previously rejecting public-output guard.

Comment thread loopx/public_safe_text.py

return HTTP_URL_SURFACE_PATTERN.sub(lambda match: " " * len(match.group(0)), value)


Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] URL 豁免前保留外层 path: 本地引用。path:/https://example.com/doc 中的 HTTP 子串被整体掩掉后,只剩 path:/ 和空格,PATH_PREFIX_LOCAL_PATTERN 无法命中。同一嵌套 validate_public_safe_value 在 immutable base 拒绝、此 head 接受;真实扩展也能发布并按摘要读回。该字符串外层明确指向 POSIX 本地路径,不能因路径成分包含 HTTP 形状而豁免。请在共享 owner 保留显式本地上下文的优先级,并补验上述拒绝、旧快照不变和独立 HTTP URL 放行。

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants