Repository navigation
refactor(tokens): own the letter-led compact token shape once - #7588
Conversation
The domain-state key validator and the ML-experiment public-token validator
compiled the same body `^[A-Za-z][A-Za-z0-9_.:-]{0,79}$` under their own
names since they were split out of one quality change. Both now import
`public_safe_text.LETTER_LED_COMPACT_TOKEN_PATTERN`, the module that already
hosts the sibling compact identifier shapes, and a census guard rejects a new
local copy.
Each consumer keeps its own field names and error text; the value and every
acceptance/rejection decision are unchanged.
Signed-off-by: CTYQAQ <135084081+CTYQAQ@users.noreply.github.com>
82565f9 to
0c1aef4
Compare
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · gpt-6.1-sol · OpenAI · runtime_reported · reasoning_effort=max
未发现当前精确 head 0c1aef4 的阻断问题,结论为 APPROVE。
动机 / Motivation
维护领域状态和 ML 实验公共标识符的开发者。
同一个字母开头、最长80字符的标识符规则原来分散在两处;现在修改一处共同语法即可,原调用方的字段政策和错误仍各自保留。
已验证实际 CLI 的接受、拒绝、完整输出和账本读回不变,并删除两处同体规则。
本次不扩大标识符语法、发布策略、领域能力权限或训练执行权。 这是具体的维护增量;基线本来就能处理合法输入,不能把删除重复声明说成修复了既有执行故障或已经提高模型效果。
改动思路 / Approach
共享语法属于既有 public_safe_text owner;具体字段的公共文本政策继续留在消费者,不能因同用正则而合并业务规则。
本 PR 完成既有两个消费者的语法归一及相称回归,不增加状态、配置或第二个验证器。
只抽取两者真正共有的语法。domain-state 继续验证路径段;ML token 仍先经过自己的长度、路径、远端位置和隐私标记过滤。合并这些业务validator会误改政策,另建框架也没有必要。原CLI处理、锁、原子写入和持久格式均沿原owner;这里用文字即可解释直接调用链,不额外画图。
具体改动 / Changes
无针对本次内部整理的独立书面产品规格;验收依据是PR的明确维护目标、既有两个消费者的语义和仓库相称重构规则,不把新测试当作独立规格。已检查不可变基线 b6db7f7 与当前完整差异:4文件 +32/-6,其中生产3文件 +12/-5,既有测试1文件 +20/-1。
关键代码讲解
- LETTER_LED_COMPACT_TOKEN_PATTERN 把原来的字母起首、总长1至80及既有字符集原样放入已有共享syntax模块,pattern和flags没有变化;它不代表文本获准公开。
- default_domain_state_file_path 仍逐个验证goal_id、domain_pack和filename,再构造项目局部路径;只把原私有正则指向共享对象。错误字段、strip和落盘顺序保留。
- _compact_public_token 仍在原public-text政策后检查语法。实际入口是未改的 handle_ml_experiment_command,成功结果才进入原JSONL upsert。
共享owner的定义普查从两个本地body变成一个;两个新增断言复用原census文件。三生产文件除明确的import、重复赋值和未使用re导入外,AST逐项相同。这证明改动范围,不能单独替代下面的运行对照。
对主干的风险 / Risks
最强反例是抽取时把80字符上限误改成79,或者把ML额外过滤误套到所有路径字段。独立执行35个真实console输入配对:31项覆盖合法/非法token、可选source、错误优先级、默认路径、重复/状态更新及完整JSON/Markdown;另4项覆盖数字起首的普通文本字段、第二个任务、非法任务拒绝及随后恢复。完整stdout、stderr、exit和JSONL逐字段相同,没有归一化。原账本正确保留两个主体,重复及失败恢复不增行。
同一console进程内故意把共享上限改为79,80字符task_id和goal_id两项独立预期确实失败;真实head均通过。默认、明确false及true的原pack公共API结果也与基线相同,默认off不会因导入语法常量而激活,更没有新训练或生产执行权。
PASS:五个相关/架构模块81项;不可变base的原三个focused模块72项。改动文件Ruff、配置17文件mypy、完整TS typecheck、diff/DCO/双语差分均通过。标准premerge的6项direct与2项selected全部通过,零失败/跳过/人工hold;当前严格CQR有效。未查询或等待CI。
早先私有probe先用了不存在的模块入口,随后又被本机默认runtime路由冲突拦住;这些失败保留,未算产品测试。改用实际console和显式隔离registry/runtime后才取得上述真实证据,没有修改全局环境或产品断言。
语义与 CI 对齐
复用既有syntax owner,没有新增状态枚举、默认开关、配置或第二份authority。差分advisory无支持的新carrier;该空报告不证明语义,完整CLI对照和负向mutation承担验证。公共兼容导出和原持久JSONL仍有消费者,保留它们有实际依据,不需为减行删除。
我的整体评价 / Verdict
APPROVE,当前维护目标达到。long_horizon 与 user_experience 均为 preserved:实际接受、拒绝、持久结果和合法后继保持,无新增设置、确认或人工改命令。减少重复知识的增量成立,长期模型/维护成本收益尚未测量。
共享语法属于既有 public_safe_text owner;具体字段的公共文本政策继续留在消费者,不能因同用正则而合并业务规则。 本 PR 完成既有两个消费者的语法归一及相称回归,不增加状态、配置或第二个验证器。
有界整理已应用,不需要新框架或人为后继。已检查 ml-experiment CLI、领域状态写入和现有消费者;没有渲染组件、布局或新前端交互变化,视觉评审不适用。 正式安装、原生 Windows 与真实模型长期收益未在本轮验证。 本评审不授权合并或安装;公开结论只适用于当前未变head。
English verdict: APPROVE — 0c1aef4. All35 real CLI pairs preserve complete output and persisted rows; the stricter-bound mutation fails two independent cases. 81 Python tests, static checks, standard premerge and exact-scope CQR pass. Live adoption and long-term benefit remain unqualified.
Goal And Delivered Outcome
loopx/public_safe_text.py: "Shared identifier shapes stay here with the sibling public-safe text shapes."^[A-Za-z][A-Za-z0-9_.:-]{0,79}$under their own names —loopx/domain_state.py(_DOMAIN_STATE_TOKEN_RE) andloopx/domain_packs/ml_experiment.py(_TOKEN_RE). Both arrived in the same quality change, so any future bound fix had two places to land and no owner to read.loopx/**/*.pyfinds the shape in 2 modules and 0 owners before, and in 1 owner and 0 consumers after; re-adding a local copy failstest_the_letter_led_token_body_is_compiled_only_by_the_owner_and_declared_sites.mainat53dcb03082985bf894b1fca8813ab9f6e92503c5.Author Declaration
Implemented against
loopx/public_safe_text.pyand the existing census intests/control_plane/test_compact_identifier_shape_owner.py, both at53dcb03082985bf894b1fca8813ab9f6e92503c5.public_safe_text.LETTER_LED_COMPACT_TOKEN_PATTERNloopx/**/*.pydomain_state._DOMAIN_STATE_TOKEN_RE,ml_experiment._TOKEN_REtest_domain_state_and_ml_experiment_share_the_letter_led_token_shapeScope And Continuation
Validation
staticpassedpython -m ruff checkon the four changed filesunitpassedtests/control_plane/test_compact_identifier_shape_owner.py,tests/test_ml_experiment_volc_packet.py,tests/control_plane/test_public_safe_text_classifier.py— 74 passed together (2 tests added)regression_paritypassedml_experiment.pymakes the new census fail (1 failed, 18 passed); the restored tree passesintegrationpassedtests/architecture/test_top_level_module_budget.py+tests/test_stage2c_dependency_lock.py— 7 passedb6db7f7c415b356ac94ebfc643977d381a314eb9after submission; the branch patch-id is unchanged (e2051219…), and the three affected files plus the two architecture gates were re-run on the rebased tree — 81 passed.Frontend / Visual Evidence
N/A — no user-visible surface changed.