Skip to content

fix(chat): avoid Windows path redaction backtracking stalls - #7319

Open
BigDataDZ wants to merge 1 commit into
mainfrom
codex/windows-redaction-backtracking-20261025
Open

BigDataDZ wants to merge 1 commit into
mainfrom
codex/windows-redaction-backtracking-20261025

Conversation

@BigDataDZ

Copy link
Copy Markdown
Contributor

Goal And Delivered Outcome

On Windows, a protected path with a long alphabetic prefix can stall ordinary path redaction when a candidate nearly matches it. The regex lists both upper- and lowercase literals inside IGNORECASE; each letter therefore adds equivalent backtracking branches. The real disposable research backend's per-Goal status request exceeded a 14-second deadline in this owner.

Keep one literal for one-character case mappings, whose alternatives IGNORECASE already recognizes. Preserve explicit multicharacter Unicode mappings, every encoded UTF-8 spelling and streaming-prefix options. No privacy rule, protected-root boundary, source authority or output policy is relaxed.

  • Basis: reproduced native Windows status failure, sampled owning-process profile and controlled immutable-baseline helper intervention.
  • Intended base: main; source baseline f094b2cfb2acde7a4a0d4d875bba52f64ac31ba9. No issue closeout claimed.
  • Placement: existing Python presentation/privacy encoding adapter in loopx/chat.py; no new capability, protocol vocabulary or parallel decision owner.

Author Declaration

Written by: model_agent (OpenAI Codex), under the author's direction. Implemented against the existing chat path-redaction and streaming contracts at the baseline above. Accepted result: preserve confidentiality and supported aliases while removing the demonstrated redundant-case backtracking bottleneck.

Validation

Tested revision: d60c904148b12b6afbd3dfa680bf2579fbbe118d. Run state: finished. Inputs: synthetic. Native Windows / CPython 3.12.10; interpreter and source provenance verified.

  • New isolated 32-letter near-root regression: unchanged baseline exceeds its 20-second watchdog; corrected batch and streamed outputs complete with the expected private-path replacement. This is a hang guard, not a claimed latency budget.
  • Full path-privacy suite 67 passed; adjacent response parsing 18 passed. Explicit Unicode cases retain original/lowercase/multicharacter uppercase and percent-encoded aliases.
  • Independent author-side reviewer reran all 67 privacy tests and checked all 2,927 cased characters in this Python Unicode database: removed single-character alternatives remain matched. No actionable blocker found; this does not prove universal regex complexity bounds.
  • Same 22-letter near-root workload, three uninstrumented samples per arm: source-pinned primary rerun median 1.437s → 0.00363s; independent source-qualified rerun 0.815s → 0.000393s. These are local synthetic measurements, not production percentiles. A separate Pyinstrument 5.1.3 capture identifies the existing redaction call as the hotspot; sampled weights are not used as latency measurements. The optional profiler was isolated in ignored local tooling.
  • Real production HTTP status owner with disposable canonical SQLite research fixtures: baseline-helper intervention times out after 14s; corrected request returns 200 in about 215ms. Directory reads remain successful; final source-byte readback reports unchanged captures and zero mutation attempts. No model dispatch occurs.
  • Full packaged research-history browser remains unqualified: an own-source retry fails during fixture startup with PackUnavailable(source_changed), before target navigation and final browser readback. This separate gap was not repaired or hidden.
  • Ruff, whitespace, bilingual RFC diff and semantic advisory pass. No supported new vocabulary carrier; the advisory's static limits remain.

Reproduce the durable semantic checks using a compatible checkout test environment:

python -m pytest -q tests/test_chat_path_redaction.py tests/test_chat_response_parsing.py

Scope And Continuation

Frontend/Lark/CLI product interfaces and presentation are unchanged; the existing HTTP readback exercises the production consumer. UI impact: none. The bounded future-facing pass reuses the shared character-atom helper without another module or cache. Shared-authority RFC fixture impact: N/A; no store routing or transition rules change.

Current-head CI and maintainer review remain pending. Live workloads, other Python/Unicode versions, sustained latency and the full browser scenario are not qualified. No live Goal, provider/model turn, global upgrade or self-merge. DCO signed; raw profiles, fixtures and logs stay private.

Signed-off-by: BigDataDZ <76271875+BigDataDZ@users.noreply.github.com>
@BigDataDZ

Copy link
Copy Markdown
Contributor Author

Follow-through on the disclosed Windows browser-fixture gap: #7324 now proposes the owning fixture repair, preserving exact UTF-8 source bytes and using the existing native synthetic-provider launcher. Production hash/excerpt checks remain strict; its real HTTP/store/provider tests pass with UTF-8 mode disabled.

This does not change or qualify #7319's current head. With the fixture repair applied in its own worktree, the full browser advances beyond the original source/launch errors but still times out on a later home-card assertion. The original real-HTTP evidence and privacy tests for this PR remain separate from full browser acceptance.

@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 | reasoning_effort=max

未发现阻塞问题。评审对象:d60c904148b12b6afbd3dfa680bf2579fbbe118d。

动机

使用 Chat 或状态页读取含 Windows 路径诊断的用户,会遇到接近受保护根目录的长字母路径。旧版会在重复大小写分支中长时间回溯,状态读取无法及时返回;新版应及时返回,并继续隐藏本机目录、保留允许的项目内相对文件名。独立同输入对照中,旧版长前缀超过看门狗,新版批量、分块流式和真实 HTTP 状态处理均返回预期脱敏结果。本次只修复展示层的这一个卡顿来源,不改变读写权限,也不宣称完整浏览器、原生 Windows 环境或长期生产延迟已经验收。

改动思路

局部字符备选去重即可修复已复现卡顿;无需新增缓存、协议或第二个脱敏 owner。本 PR 仅改变 Windows 路径正则中的单字符大小写备选;流式前缀备选与权限门保持原实现。原有 IGNORECASE 已能识别单字符大小写,把它们再次并列会为近似但最终不匹配的路径反复增加分支。保留原字符和真正展开成多个字符的映射,同时保留每种 UTF-8 百分号编码,能够在既有隐私 owner 内完成修复。正常采集、权限、状态机和模型执行没有新增入口。

具体改动

依据 docs/guides/personal-workspace-user-guide.md,规格版本 f094b2cfb2acde7a4a0d4d875bba52f64ac31ba9,逐项核对 问答中的等待与失败:项目内相对文件名可读、私有子目录和其他机器路径隐藏、状态/提议/权限门完整脱敏、展示不授予读写权限,均由本次对照覆盖。

关键代码讲解

  • _root_character_atoms 只收敛最终正则中的重复单字符备选;用于流式前缀判断的 options 保持原内容,多字符大小写和编码别名仍显式保留。
  • _local_path_pattern 继续组合根边界、分隔符和通用私有路径兜底;近似根输入应当走兜底,而不是无限探索等价大小写分支。
  • VisibleResponseStreamFilter 保持 feed/finish 的原有路径前缀保护;新测试用独立子进程隔离潜在卡死,并补充多字符 Unicode 大小写及百分号别名。

独立验证使用同一 CPython 3.12.15:旧基线原测试 81 过,当前隐私与响应解析 85 过;72 行批量/回答/三处分块输出逐值相同,2,927 个有大小写字符的 11,770 个别名检查无遗漏。32 字母近似根在旧源码超过 20 秒看门狗,新源码批量和流式返回正确。实际状态 HTTP handler 的受控采集场景在旧源码超过 8 秒看门狗,新源码返回 200 和预期脱敏 JSON。

对主干的风险

主要风险是错误去重导致 Unicode/编码别名失配或私有子目录泄漏,上述正反输入覆盖了这一方向。22 字母同输入、一次预热后三次串行测量的本地中位数约为 0.319684 秒到 0.000208 秒;这是批量加分块流式的合成测量,不是生产分位数、Windows 实测或完整费用。没有采集独立采样 profile,作者的 profile 和 Windows 记录仍是作者证据。原生 premerge 的 6 项直接检查和 2 项 catalog canary 全过。按当前策略没有读取、轮询或等待 CI。

HTTP 结果覆盖真实 handler、序列化和脱敏,采集输入由夹具提供,未证明 canonical-store IO 或完整浏览器。作者公开保留的浏览器夹具/后续首页断言缺口不归并为本轮成功,也不要求这个局部字符串修复接管另一个夹具 PR。

我的整体评价

APPROVE,仅限这个完整 head 的有界卡顿修复。长期续行的任务、配额、重放和持久 owner 保持;状态读取的局部使用体验改善,不推断长期净效率。局部字符备选去重即可修复已复现卡顿;无需新增缓存、协议或第二个脱敏 owner。本 PR 仅改变 Windows 路径正则中的单字符大小写备选;流式前缀备选与权限门保持原实现。没有新增共享语义词汇、兼容解码器或状态缓存。已检查 loopx/chat.py、状态 HTTP 调用和答案/流式输出:没有页面布局或渲染组件改动,原有脱敏文本契约保持,因此无需新增截图。未验证范围:完整打包浏览器、原生 Windows 执行、其他 Python/Unicode 版本、生产分位数和完整费用未由本次独立验证资格化。本结论不是合并或安装授权。

English verdict: APPROVE d60c904. The reproduced near-root hang is removed while privacy outputs, Unicode aliases and stream semantics remain intact. Independent local tests, paired HTTP controls and native premerge passed; native Windows, full-browser and sustained production behavior remain outside this validation.

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