Skip to content

reward_memory: single-source reference/digest shapes and recall modes - #8612

Closed
psychologister wants to merge 6 commits into
loopx-project:mainfrom
psychologister:codex/reward-memory-utility-shape-owner
Closed

psychologister wants to merge 6 commits into
loopx-project:mainfrom
psychologister:codex/reward-memory-utility-shape-owner

Conversation

@psychologister

Copy link
Copy Markdown
Contributor

What

Two compiled matchers and one mode set were each written out twice in reward_memory:

  • utility_reducer.py restated _OPAQUE_REF_RE and _MEMORY_REF_DIGEST_RE from memory_utility.py; it now imports the owner objects.
  • experiment.py restated _RECALL_MODES from application.py; it now imports RECALL_MODES.

Why

utility_reducer already imports from memory_utility, and experiment already imports from application — the strongest form of the repository duplicate-knowledge case (#4447): a module restating a constant whose owner it already imports from.

Guard

tests/architecture/test_reward_memory_field_vocabulary_owner.py gains the two matchers (folded-value census + identity) and pins RECALL_MODES by identity. RECALL_MODES is pinned by identity rather than the member census because architecture.py lists the same modes in a fixed order inside a descriptive manifest. Two same-value neighbours are deliberately left separate, each with a stated reason (the unanchored inline todo_id in goal_source.py; the ordered manifest list).

Tests

Architecture guard + reward_memory focused tests pass locally; the census is poison-proven (a restated literal fails it). Behavior-preserving: both validators accept/reject the same inputs.

utility_reducer borrows memory_utility's matchers; experiment borrows application's recall modes.

Signed-off-by: psychologister <230141834+psychologister@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.1-sol · OpenAI · runtime_reported · max

本次评审对应提交 030f47d19ff6336b4a54ef8ccddac8b6bb85b1c5。

[P2] 把正则归属检查约束到实际规则。 新增全包检查只看正则正文。隔离用例中会拒绝接受大写的独立导入规则,也会拒绝从未编译的帮助文案。

动机 / Motivation

使用 reward-memory 配置或回读只读 utility projection 的开发者,以及修改 Python 代码的贡献者。reducer 本地重复两个 matcher,experiment 本地重复两个 mode 的集合。两版的 CLI utility projection、v1 配置归一化和 reference/digest 接受或拒绝完全一致。保留 provider 与 reducer 各自的空白、排序和重复规则。两版的 CLI utility projection、v1 配置归一化和 reference/digest 接受或拒绝完全一致。保留 provider 与 reducer 各自的空白、排序和重复规则。本地合成配置与 utility 观察,未调用实际 recall provider、写记忆或查询远端 CI。新增全包检查只看正则正文。隔离用例中会拒绝接受大写的独立导入规则,也会拒绝从未编译的帮助文案。

改动思路 / Approach

两个真实消费者共用已有 owner 可降低同一规则的维护成本。保留生产复用,收窄新增检查对其他模块的影响。 utility reducer 引用 memory_utility 规范形状,experiment 引用 application 的两种 recall mode。消费方自己的空白、排序、重复处理与未知模式拒绝继续在原入口。

具体改动 / Changes

关键代码讲解

  • reducer 调用共享 compiled matcher。两版实际 utility-project 对合法 200 字符、超限、分隔符和上下文错误给出相同结果。 投影校验
  • experiment 复用 application 的 mode。两种模式和已允许的空白归一化通过,未知和大小写变化仍拒绝。 配置入口
  • 新增两个 matcher 进入包级 body 扫描。我用隔离模块验证编译 flag 不同的独立规则和纯帮助文字都失败。 新增匹配项

适用 docs/architecture/rfcs/semantic-vocabulary-convergence-v0.md @ ea67e68。reuse_shared_reward_memory_owners 和 preserve_consumer_behavior 已验证,scope_semantic_owner_guard 未满足。 语义归属准则

对主干的风险 / Risks

在临时包中,允许大写的旧格式导入器与 reward-memory 的小写规则只共享正文。另一模块只是显示表达式。新增包级扫描将二者都报为重复,给独立模块增加了维护例外。真实配置与 reducer 的完整输出在基线和当前头相同。

语义与 CI 对齐

142 项相关测试与 36 项架构测试通过。另跑真实本地 CLI 投影、v1 config 和两个新增 guard 反例。Ruff、DCO 与 git diff --check 通过。未查询远端 CI 或触发 live provider。

我的整体评价 / Verdict

保留生产代码复用。请把新增归属约束限于 reward-memory 的实际规则与消费者,并用已覆盖的行为反例保住原约束。域外不同匹配语义和只读说明通过后再复审。本次评审覆盖现有宿主与 CLI 行为。本地合成配置与 utility 观察,未调用实际 recall provider、写记忆或查询远端 CI。

English verdict: REQUEST_CHANGES. The runtime reuse preserves behavior. The expanded guard rejects unrelated regex semantics and explanatory text.

memory_utility,
[("loopx/capabilities/reward_memory/utility_reducer.py", utility_reducer)],
),
"_MEMORY_REF_DIGEST_RE": (

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] 把正则归属检查约束到实际规则。 这两个新增项会走全包字面量扫描。我用隔离包让另一个导入器以 re.IGNORECASE 编译相同正文,实际可接受大写 digest,reward-memory 的规则拒绝它。新增 guard 仍把该独立规则报成重复。另一项也把只展示表达式的帮助文字报成重复。请把新增检查限定到已有 reward-memory owner 和消费者,保留实际引用及拒绝输入的验证。

The first revision routed _OPAQUE_REF_RE and _MEMORY_REF_DIGEST_RE through the
package-wide body-substring census. As the review showed, that flags two things
that are not this rule: an independent re.compile(<same body>, re.IGNORECASE)
importer that accepts uppercase, and a plain help/display string that quotes the
body but is never compiled.

Gate these two reward-memory-internal matchers with a scoped compiled-rule census
instead: walk only capabilities/reward_memory (the owner and its consumers), count
only real re.compile sites, and compare (body, source flags) so a flag-different
compile is a different rule. The repository and explore patterns keep the original
package-wide embedded-body census.

Production reuse is unchanged: utility_reducer still imports both matchers from
memory_utility, and experiment still borrows application's RECALL_MODES. The
accept/reject behaviour stays pinned through both modules' own validators. Add
poison controls proving the flag-different importer and the never-compiled help
string read as neighbours while a flagless recompilation is still caught, plus a
scope-boundary test showing an out-of-package restatement is not scanned.

Test-only change. Guard 59 passed; architecture suite net regression 0 (identical
96 pre-existing environment failures); reward_memory behaviour 158 passed; ruff
clean.

Signed-off-by: psychologister <230141834+psychologister@users.noreply.github.com>
@mergify

mergify Bot commented Nov 13, 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, @psychologister.

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 13, 2026
Resolve the sole experiment.py import conflict by keeping main's
openviking -> openviking_scope rename together with this branch's
RECALL_MODES import from .application. The single-sourced reference and
digest shapes and the scoped compiled-matcher ownership guard are
unchanged.

Validation on the merged tree: reward_memory suite 413 passed, the
architecture field-vocabulary guard 59 passed, ruff clean, and the full
architecture FAILED set is byte-identical to current main (net
regression 0).

Signed-off-by: psychologister <230141834+psychologister@users.noreply.github.com>
@mergify mergify Bot removed the needs-rebase Mergify: the pull request has merge conflicts with its base branch label Nov 13, 2026

@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
Reviewed commit: d07fb226bf54b0ae811aa620d8415c28497bd25d · merge base 5890cecd436e7d76b0bb5a033aca175c3a2650d9.

[P2] 归属检查将方法名当作正则来源。 将同一 digest 正文分别交给一个只产生帮助文字的 renderer.compile 和真实 re.compile(pattern=...)。 实际得到普通文字的调用被拦,实际与 owner 拥有同样正文、flags 和接受范围的调用被漏过。上一轮两个反例虽已过,这类错误仍发生在新增检查声称要约束的包内。 保留生产复用。仅检查可确认的 re.compile 调用,并覆盖 pattern=;或者收窄到已知 owner/消费者符号的归属与行为,其他语法保持未知。 位置

动机 / Motivation

维护记忆召回配置、使用 utility-project 读取只读效果评估,或维护这两处规则的开发者。 配置和投影各自重复已有规则。若以后只更新其中一份,同一个模式或 digest 可能在一处通过、另一处报错;用同一个定义能减少这种维护偏差。 保留两种已有召回模式和原有输入接受边界;新增归属测试应拦住实际重写的正则,并让独立编译器与说明文本通过。 不改变 recall provider、权限、写入、证据排序或公开数据格式,也不扩大到其他包的规则。

改动思路 / Approach

utility reducer 复用 memory_utility 持有的匹配器,实验配置验证复用 application 持有的模式;两处原先已有依赖边,无需跨到控制面。 投影入口仍检查透明引用长度、路径拒绝与 digest 格式,保留各自的空白、排序和去重规则。配置入口先规范化模式字符串,再检查两种原有模式。架构用例改在 owner 的包内比较正则正文和 flags,避免把包外或普通文本内容当作规则。 保留生产复用。归属检查限于已证明的 reward-memory owner 和消费者边界;不用扩大为通用 Python 语义扫描器。

具体改动 / Changes

以 docs/architecture/rfcs/semantic-vocabulary-convergence-v0.md 在 3cf2f45552dc2fdad0a160e3e736c1b7c9be21ee 的条款为依据。same_semantics 未满足:归属测试把同名方法当成同一语义。Stage 2 read-only projection 已验证:现有只读投影、引用和 digest 接受范围,以及重复输入均保持原行为。另核对两种召回模式。

关键代码讲解

  • _ref: 共用最长 200 字符的引用 matcher,继续拒绝路径和 URL 形式,调用者自己的空白处理保留。
  • _memory_digests: 共用 canonical digest matcher,但仍由 reducer 执行顺序与唯一性检查。
  • _normalize_v1: 共用 application 的两种召回模式,仍由配置入口执行空白处理和字段约束。
  • compiled_rule: 根据被调方法名和首个位置参数识别规则。它没有区分 re 和其他对象,也没有读取 pattern= 参数。
  • _reward_memory_matcher_scan: 包内扫描将上述推断当作能阻断测试的重复定义结论。

3 个文件,生产 +10/-7、测试 +283/-9。已有调用只替换引用,新增的大部分成本是测试扫描机制。 上一轮评审 的问题在当前提交重新验证。当前提交已实测修复上一轮的大写匹配与说明文字两例。剩余问题来自新增检查对真实 re 调用的识别;运行代码保持兼容。

对主干的风险 / Risks

PASS:11 个 reference、9 组 digest、6 种模式输入及真实 utility-project 的有效、重复和错误快照,在分叉、旧提交和当前提交产出相同。当前检查已放过 IGNORECASE、只读说明和包外同字面值。 当前提交 201 项、分叉基线 171 项通过;三版从实际 utility-project 和配置读取路径得到相同结果。另在隔离 fixture 实际执行正则和文字编译器,确认检查在包内一漏一误。

FAIL:在当前提交实际执行 renderer.compile(...),得到的只是渲染说明文字的函数,归属扫描仍报重复;用 re.compile(pattern=...) 则得到相同正文、flags 和接受行为,扫描反而没有记录。 在同一隔离包同时运行真实位置/关键字参数的 re.compile、接受大写的变体、说明文字和另一个对象的 compile,确认只拦截等价的真实重复。

语义与 CI 对齐

复用现有规则,不登记新词表。真正等价的同域规则应拦,独立语义应放行;测试不得仅凭方法名强制这一决定。 Git 差异检查与逐提交签署通过,当前主干模拟合并有实质差异且无文本冲突。UNVERIFIED:未查询托管 CI,未调用真实 recall provider 或写记忆;这里验证配置和只读投影,不能外推到 provider 行为。

我的整体评价 / Verdict

运行结果不变;共用规则减少了今后分叉。但把检查限于真实规则的目标仍未达成,一边可能拦独立实现,一边放过真实副本。 utility-project 返回值和配置有效性维持原样;影响发生在执行架构检查的开发者。 只涉及现有配置读取、CLI 和架构测试,无渲染页面、交互或前端设置变化。 既有只读投影不产生权威状态,旧观察和快照绑定保留;两处导入同一分发中的符号,不新增独立版本或重新解释旧数据。 旧的域外和说明文本两个反例已解除。请用真实 compile 调用、关键字参数及独立编译器做一对正反验证;不需要改已通过实测的运行入口。

English verdict: REQUEST_CHANGES — The runtime reuse preserves tested behavior, but the ownership guard flags a non-regex compile method and misses an equivalent re.compile(pattern=...) call.

The loopx-agent review of the merged head flagged a P2: the scoped
compiled-rule census inferred "this is a regex" from the callee method name
alone and read only the first positional argument. So an independent
renderer.compile(...) that merely renders help text was flagged as a duplicate
(false positive), while a real re.compile(pattern=...) of the identical body,
flags and acceptance was missed (false negative). same_semantics was not met:
a shared method name is not a shared rule.

Confirm the callee is really re.compile -- the re module by its canonical name
or a tracked `import re as` alias, or `from re import compile` -- so any other
object's .compile() and a bare builtin compile() are left unknown. Read the
pattern from the first positional arg or the pattern= keyword, so a real
keyword-form duplicate is caught. Flags handling is unchanged, so a
flag-different compile is still a different rule.

Test-only: the production owner (memory_utility) and consumer (utility_reducer)
are untouched and still share one object. Extend the neighbour corpus across the
whole argument-form/alias equivalence class, and add an executed regression that
places a real re.compile(pattern=) restatement and an independent help-text
compiler in one isolated package: the census bites the former, leaves the
latter, and running both confirms one is the owner's accepting regex and the
other only text.

Signed-off-by: psychologister <230141834+psychologister@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.1-sol · OpenAI · runtime_reported · reasoning_effort=max

评审提交 d685ef1f6d0b9e05948154f9f86fbabc73108326,分叉基线 5890cecd436e7d76b0bb5a033aca175c3a2650d9。

[P2] 修正包内归属检查对别名与 flags 的误判。 模块中 import re as rx 后,函数参数 rx 遮蔽模块别名。调用传入 Renderer 并返回帮助文本,扫描却把这行判成重复。 将 IGNORECASE 通过 **opts 传入时,实际编译的 digest 接受大写,扫描仍判它与原规则相同。显式 re.UNICODE 具有同一 str pattern 及运行时 flags,扫描却漏过。 _re_bindings · _compile_flags

动机 / Motivation

维护记忆召回配置或从命令行读取记忆效果报告的开发者会用到这些规则。 改动前同一种引用、摘要和召回模式有多份定义,今后只更新其中一份会让同一个值在不同入口得出不同结果。 候选的两个运行入口改为从现有模块复用规则,我在原有输入上读到了相同的结果。 这次改动限于配置读取、只读投影和包内测试。

改动思路 / Approach

配置和投影已经依赖相应模块,直接导入现有定义即可完成生产侧收敛。 保留现有 owner 的导入,把架构检查缩到具名消费者的绑定和可运行行为。若仍检查包内其他位置,须对未解析的绑定和 flags 保持未知。 只读报告仍由现有 reducer 输出,配置的 mode 仍经原 loader 规范化。两条生产路径各有成对的行为对照。报告引用 · 配置模式

具体改动 / Changes

三个文件共 +447/−16,生产两处共 +10/−7,其余是测试。沿用 5890cecd436e7d76b0bb5a033aca175c3a2650d9 上的 docs/architecture/rfcs/semantic-vocabulary-convergence-v0.md。第 11 节以 same_semantics 限定应收敛的重复,实质是同类输入得到同样的接受行为。本轮的只读回归对照 read_only_runtime_parity 也用相同输入核对了现有配置读取及投影。语义收敛 RFC · 交付跟踪 #4447

  • 引用和 digest 校验使用同一个已有编译结果,原有路径、去重与排序规则继续在投影入口处理。摘要校验
  • 仓库扫描读取包内每一个 Python 文件。别名收集跨过局部绑定,**opts 在未直接写 flags 时被当成 0。执行代码后再读扫描结果,可以观察到两个不同的错误来源。包内扫描
包内执行 原规则语义 检查结果
参数遮蔽正则模块别名 返回帮助文本 错报重复
**opts 传入 IGNORECASE digest 接受大写 错报重复
显式 re.UNICODE 与默认 str pattern 等价 漏报

对主干的风险 / Risks

普通 renderer.compile 通过,真实 re.compile(pattern=...) 被抓,直接写 IGNORECASE 的非等价 digest 也通过。 完整 CLI 数据和返回状态逐项一致。检查了 11 个引用、9 组 digest、6 个配置及 3 个 utility-project 案例;未创建运行时目录。 分叉点 117 项与候选 175 项定向 Python 检查通过,另通过 Ruff、DCO、RFC 双语 diff、git diff --check 及本地主干合并树检查。 新增误判发生在包内的真实测试入口,可能让后续正常改动停在架构检查。

语义与 CI 对齐

运行检查限于配置、只读投影和架构测试;没有执行真实记忆 provider 或写入。托管 CI 未查询。

我的整体评价 / Verdict

请求修改测试的阻断范围。生产规则共享可保留,配置和只读投影已有配对证据。用可执行的包内代码分别覆盖文本渲染器、不同 flags、同等 flags 与真实 re.compile(pattern=...),再验证只有可证实的等价副本被报出。

English verdict: REQUEST_CHANGES at d685ef1. Production behavior matches the base. The new scoped guard flags a shadowed re alias and an IGNORECASE digest with expanded kwargs, and misses an equal pattern compiled with explicit default Unicode flags.


module_names = {"re"}
compile_names: set[str] = set()
for node in ast.walk(tree):

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] 将测试中的正则别名解析限定到实际绑定。 模块先导入 re as rx,随后 def render(rx) 使用调用者传入的 Renderer。同一句 rx.compile 返回帮助文字,这里的文件级别别名集合仍会触发重复检查。直接断言已知消费者复用 owner,并跑实际匹配用例,可以覆盖目前的生产改动。 同一包检验的 flags 反例也需要覆盖。 flags 判定

…guard

The loopx-agent review of the merged head flagged a further P2: even after
confirming re.compile, the scoped census still over-reached in three ways and
so did not meet same_semantics. (1) A module alias shadowed by a local binding
-- `import re as rx` then `def f(rx): rx.compile(...)` -- was still read as the
re module, flagging an independent renderer (false positive). (2) A `**opts`
expansion was assumed to carry no flags, so a copy that really passes
re.IGNORECASE through **opts was flagged as the flagless owner rule (false
positive). (3) An explicit `re.compile(body, re.UNICODE)` was treated as a
different rule, missing a copy that is byte-for-byte the owner's accepting
regex, since UNICODE is the default for a str pattern (false negative).

Narrow the census to report only provably-equivalent copies, leaving everything
unresolved unknown rather than guessing. Bindings come from module-level imports
only; any name rebound in a local scope -- a parameter, assignment, nested
import or def -- drops the alias, so a call through it is unknown, not the
module. A `**opts` expansion or any non-literal flag expression is unknown, never
assumed 0. Flags are normalised by stripping re.UNICODE (the str-pattern default)
before comparing, so an explicit-Unicode compile equals a flagless one, while a
genuinely different flag such as re.IGNORECASE or re.ASCII stays a different
rule.

Test-only: the production owner (memory_utility) and consumer (utility_reducer)
are untouched and still share one object. Extend the neighbour corpus across the
shadowed-alias, **opts and explicit-UNICODE equivalence classes, and add an
executed regression that places flagless / explicit-UNICODE / pattern= copies
alongside an IGNORECASE copy, a **opts-IGNORECASE copy, a shadowed alias and an
independent help-text renderer in one isolated package: the census reports
exactly the three provably-equivalent copies and leaves the rest, and running
the compilers confirms the equal-flag copies match the owner while IGNORECASE
(direct or via **opts) widens acceptance and the shadowed alias only returns
text.

Signed-off-by: psychologister <230141834+psychologister@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.1-sol · OpenAI · runtime_reported · reasoning_effort=max

评审提交 a2b263b,目标分支提交 5890cec。与当前主干 8ade78c 的合并树检查无冲突。

[P2] 核对正则 flag 的实际来源。 代码位置

动机 / Motivation

投影和配置各自重复了记忆引用、摘要和模式定义。前次复审发现,测试会混淆遮蔽的别名和展开的 flags,且漏过标准库显式 Unicode。 维护 reward-memory 引用、摘要和召回配置的贡献者。 让现有调用共享定义,同时只拦住确实与共享规则等价的重复编译。 复审记录

同包独立导入器使用 re.compile,传入自有的 ImportFlags.UNICODE。该属性实际绑定 re.IGNORECASE,以兼容大写旧摘要。 测试只读取属性名,直接拿 re.UNICODE 的值判断。实际编译结果接受大写。归属测试却把它判为等价副本并失败。 对照使用合成快照和配置,实际 recall provider 与托管 CI 未验证。

改动思路 / Approach

包内硬断言限于已证实等价的摘要、引用规则。独立导入器保有自己的接受范围。

  • 已验证交付。4 组实际 utility-project 和 5 组召回配置在基线和候选上得到相同的 JSON 与退出码。摘要大写、透明引用含路径、未知模式等原拒绝保持。 仓库规则
  • 约束范围。分别保护共享规则和独立匹配语义。 收敛合同 关联来源

具体改动 / Changes

utility_reducer 改用 memory_utility 的两个 matcher。experiment 引用 application.RECALL_MODES。测试新增包内正则扫描和输入对照。

对主干的风险 / Risks

  • PASS。452 项源码测试通过,归属反例在隔离副本触发 1 项现有断言失败。 真实标准库的 pattern= 和显式 Unicode 都被识别,直接传入或展开传入 IGNORECASE 则通过范围检查。
  • FAIL。维护者新增一个匹配语义独立的包内导入器时会被当前架构测试错误阻断。
  • CLI 返回结构化文本。证据来自实际源码入口和架构测试。

我的整体评价 / Verdict

REQUEST_CHANGES。只折叠来源已确认的标准库 flag。保留独立属性为未知,或直接约束具名消费者的 owner 绑定和实际匹配行为。 在同一份架构测试中使用默认编译、标准库显式 Unicode、自有同名属性和 IGNORECASE,确认真正等价的副本触发断言。

English verdict: REQUEST_CHANGES at a2b263b. The production imports preserve the tested outcomes. The test treats an independent UNICODE attribute as re.UNICODE and rejects an intentionally case-insensitive matcher. Resolve the actual flag binding or limit the hard check to the known consumers.

if isinstance(node, ast.Constant) and isinstance(node.value, int):
return node.value
if isinstance(node, ast.Attribute):
value = getattr(re, node.attr, None)

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] 核对正则 flag 的实际来源。 测试只读取属性名,直接拿 re.UNICODE 的值判断。实际编译结果接受大写。归属测试却把它判为等价副本并失败。 只折叠来源已确认的标准库 flag。保留独立属性为未知,或直接约束具名消费者的 owner 绑定和实际匹配行为。

The loopx-agent review of the merged head flagged another P2: the scoped census
read a flag from its attribute name alone, without checking which object the
attribute belongs to. So `ImportFlags.UNICODE` -- an independent object's
attribute that actually binds `re.IGNORECASE`, kept for legacy uppercase
digests -- was read as `re.UNICODE`, normalised away, and its file reported as a
flagless duplicate of the owner. The matcher is intentionally case-insensitive,
so this was a false positive and same_semantics was not met: a same-named
attribute is not the stdlib flag.

Fold a flag only when its source is confirmably the stdlib `re` module. An
attribute `X.FLAG` is read only when `X` is an unshadowed `re` module name (the
`re` object itself or a module-level `import re as` alias); `ImportFlags.UNICODE`
and any other object's attribute are left unknown. A bare name is read only when
it was imported from `re` (`from re import UNICODE`), mapped back to its original
attribute so `from re import IGNORECASE as UNICODE` resolves to IGNORECASE rather
than to the name it was bound under. Anything unresolved is unknown and never
reported, so only provably-equivalent copies are flagged.

Test-only: the production owner (memory_utility) and consumer (utility_reducer)
are untouched and still share one object. Extend the neighbour corpus across the
own-attribute, bare custom name and `from re import` (including aliased) classes,
and extend the executed isolated-package regression with the review's four
categories -- default compile, stdlib explicit Unicode, an own `ImportFlags
.UNICODE` that really binds `re.IGNORECASE`, and `re.IGNORECASE` -- asserting the
census reports only the provably-equivalent copies and that running the compilers
shows the own-attribute/IGNORECASE copies accept uppercase the owner rejects.

Signed-off-by: psychologister <230141834+psychologister@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.1-sol · OpenAI · runtime_reported · reasoning_effort=max

评审提交 5da34606e13ae52aef319a05363c523bb100dba8,分叉基线 5890cecd436e7d76b0bb5a033aca175c3a2650d9。

[P2] 包内架构测试仍会误拦合法的正则绑定。 from .re import UNICODE as flags 可能来自同包模块。实际传给 re.compile 的值可以是 IGNORECASE。另一例是 case {"flags": flags} 在函数中捕获实际配置,覆盖模块导入的名字。两个模块实际加载后都接受大写摘要,原规则拒绝。当前断言将两者都标为等价副本并失败。 局部绑定 · re 导入识别 · 硬断言

动机 / Motivation

维护记忆投影和召回配置的贡献者需要修改一处校验规则,并能让已有引用和摘要继续读回。 旧实现把同一引用格式、摘要格式和召回模式分别维护。候选让原消费者导入已有定义,并用架构测试阻止重复。 真实投影命令、配置加载及摘要读回的配对结果一致。新的架构断言仍会把两种实际接受大写摘要的独立匹配器判为副本。 证据来自源码、合成输入和本地真实 CLI。没有真实召回 provider 或安装宿主运行结果。

改动思路 / Approach

让投影继续使用 memory_utility 的两个编译对象,实验配置继续使用 application 的模式集合。不同领域的 Todo 引用规则、按顺序展示的描述清单保有对应语义。新增硬断言要依据实际来源和匹配行为,范围只需覆盖该包的已知消费者和可证明的等价编译。 语义收敛约定 · 只读投影协议

具体改动 / Changes

按分叉基线的 docs/architecture/rfcs/semantic-vocabulary-convergence-v0.md 核对三项。shared-rule-owner 已实现,utility-readback 的输入与读回通过配对,bounded-enforcement 仍有真实反例。三文件 +687/−16,生产两处 +10/−7,主要新增行数在测试。

  • _ref 和 _memory_digests 复用相同的引用及摘要匹配器。原短摘要、完整带前缀摘要和排序去重保留。 投影校验
  • _normalize_v1 使用已有的 RECALL_MODES。两种合法模式、输入空格及非法值按原规则处理。 配置校验
  • 相比上一评审,独立对象的 ImportFlags.UNICODE 已正确留在未知范围。相对导入的层级与结构化匹配的捕获名仍不在同一套来源检查里。 前一评审 · 当前编译扫描

对主干的风险 / Risks

同一份输入在分叉点和候选运行了四组实际 utility-project、五组配置加载及七组 reducer 校验,完整结果与返回码一致。基线 493 项通过,候选 595 项通过。标准预合检查 6 项直接、5 项选定通过。当前托管 CI 未查询。

两个新反例都执行了实际模块导入和匹配。独立 matcher 的 flags 为 34,原 matcher 为 32,只有独立 matcher 接受大写摘要。两处都被真实归属测试挡住。保留标准库显式 Unicode 的正例,确认真正同义的编译仍会被发现。 归属断言

语义与 CI 对齐

候选复用既有词汇和运行时校验。开发期阻断的当前范围不满足只报可证实同语义的规则。相对导入和结构化匹配中的名字来自 Python 实际绑定,不能仅由属性拼写推断。 约定与门禁范围

我的整体评价 / Verdict

REQUEST_CHANGES。继续收敛 reward_memory 的三个已有定义,并把可阻断的检查限于已证实的同一规则。 共享导入本身通过了配对验证。包内硬检查的绑定推断会阻断合法的独立导入器,应先收窄。 保留两个生产导入改动。将硬断言限定于已知消费者的实际导入绑定,或仅对可证明来源与词法作用域的匹配器报错。 复验时同时运行两个真实反例和默认编译正例。配置和只读命令保持原入口,无界面改动。

English verdict: REQUEST_CHANGES at 5da34606e13ae52aef319a05363c523bb100dba8. Production parity passes. The package guard falsely rejects legitimate case-insensitive matchers when a flag comes from a relative import or a match capture.

@NIU-123370 NIU-123370 closed this Nov 16, 2026
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.

3 participants