Skip to content

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

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

psychologister wants to merge 3 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

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