Repository navigation
refactor(paths): single-source the safe path-segment alphabet - #9206
Jiaqiiii523 wants to merge 1 commit into
Conversation
Four capabilities now borrow PATH_SEGMENT_UNSAFE_RE from loopx.paths; each keeps its own fallback, truncation and digest policy. Signed-off-by: Jiaqiiii523 <[email protected]>
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh
动机 / Motivation
维护召回、记忆侧写和历史导出的操作者需要升级后继续找到既有本地文件。 四个实现分别声明相同的文件名字符规则,之后只修改一处会让这些路径规则分叉。 共享声明消除了这处重复,实际输出仍按当前调用方的身份策略生成。 本次仅合并文件名字符规则的声明。行为对照覆盖四个现有调用方以及实际本地文件路径。 这个增量使将来的字符范围调整可在同一所有者检查,同时让现有持久文件仍可读回。
改动思路 / Approach
四个用途从已有路径模块引用同一份正则,继续由各调用方保管身份、摘要和回退策略。 四处使用的规则相同,而截断和语义不同。只共享字符集合保留了各个现有所有者。 变更限于同一字符集合的声明所有权,保留原文件名和存储合同。 正则是原始字符集合而非路径授权检查。它不会替代任务 ID 校验、运行路径定位或存储方对临时及持久文件的选择。
具体改动 / Changes
准确头 58ba9a7,分叉基线 de61cfe,当前主干整合预演 55bae0a。6 个文件,+47/-11。 核对的仓库契约 对应 shared-owner 集中原字符集合。retained-files 保留旧文件名和回读。existing-boundaries 保持禁用和外部提供者边界。四个入口分别核对原摘要、名称长度、特殊字符和回退。用生产辅助函数进行分叉基线、准确头及当前主干整合预演比较,并跑现有召回、奖励记忆、Steward 及历史导出用例。使用现有轻量路径模块,架构导入和文件数量预算就本次变更继续通过。
关键代码讲解
- 统一字符集合 复用当前模块,不增加新的路径授权。
- 召回 回退和摘要仍由调用者生成。
- 奖励记忆 原摘要身份保留。
- Steward 文件名 原截断与时间回退逻辑保留。
- 历史导出 继续使用导出自身的 slug 规则。
对主干的风险 / Risks
未发现阻塞代码问题。最值得检查的是存量文件是否因规则迁移换了名字,或者原禁用路径改变调用。 空输入、全部被移除的字符、控制字符、混合 Unicode 和长名称的回退、截断和校验摘要均保留。 召回和奖励记忆保留原 digest 长度,Steward 仍用原时间回退和 .md 规则,历史导出仍用原 slug 的 80 字符上限。既有禁用与无资格路径仍保持关闭。 44 项 Python 调用及声明测试、37 项导入边界/模块预算、4 项 Steward TypeScript 和准确头标准 quick premerge 均通过。 本轮未接入真实 OpenViking 帐号,也未变更外部提供者配置。
我的整体评价 / Verdict
批准当前准确头。四个生产函数处理 12 组输入的 48 个结果,在分叉基线、准确头和当前主干整合预演逐字一致。调用侧正常写入、回读和已有记录重放的定向套件通过。 对长程任务,原记录可继续读回,重复字符规则由同一模块维护。对使用者,升级后现有文件名和回退不变。 保留当前实现边界。变更限于同一字符集合的声明所有权,保留原文件名和存储合同。
English verdict: APPROVE at 58ba9a7. The alphabet now has one owner. All 48 paired outputs are byte-identical across base, exact head and the main integration preview; existing consumer and architecture tests pass.
Goal And Delivered Outcome
Four capabilities each restated the same safe path-segment alphabet
[^A-Za-z0-9._-]+. They now borrowPATH_SEGMENT_UNSAFE_REfromloopx/paths.py; each caller keeps its own fallback, truncation and digest policy.loopx/capabilities/agent_turn_recall/runtime.py,loopx/capabilities/reward_memory/outcome_lifecycle.py,loopx/capabilities/steward_memory/runtime.py,loopx/extensions/openviking_semantic_preference/history_export.py.loopx/paths.py(PATH_SEGMENT_UNSAFE_RE).tests/architecture/test_path_segment_alphabet_owner.pypins the object identity, the allowed-punctuation behavior at each consumer, and a focused AST check that the four consumers do not restate the literal. It deliberately does not scan the whole package, so legitimate same-value uses elsewhere are not rejected (the false-positive lesson from periodic_report: single-source the reportable trigger kinds #8630).This is a value-level convergence, not a semantic-inventory budget change: the new constant is not a counted twin, and
multi_value_twinsstays at 8.Validation
python -m mypy: 17 files, no issues.ruff checkon the changed files: clean.loopx check --scan-pathon the five files: clean.multi_value_twinsremains 8;PATH_SEGMENT_UNSAFE_REis not counted.loopx canary premerge --git-diff-base de61cfe6a35 ...: 16 selected, 0 failures;self_merge_validation_passed: true.Scope And Continuation
de61cfe6a35; open PRs touching some of these files are unrelated, so a rebase may be needed if they land first.Type of Change
LoopX Area
Technical Direction
Core control-plane hardening.
Written by: model_agent (Qoder CLI). AI disclosure: drafted with AI assistance under the author's direction and review.