Skip to content

refactor(public-safety): compile the label and identity shapes once - #7677

Merged
huangruiteng merged 1 commit into
loopx-project:mainfrom
lll-hhh:feat/compact-label-shape-owner
Oct 29, 2026
Merged

huangruiteng merged 1 commit into
loopx-project:mainfrom
lll-hhh:feat/compact-label-shape-owner

Conversation

@lll-hhh

@lll-hhh lll-hhh commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Goal And Delivered Outcome

  • Outcome basis / optional anchor: self-contained maintenance outcome (no issue anchor; the repository's own shared-shape rule states the gap).

  • Goal/source and gap: loopx/public_safe_text.py says "Shared identifier shapes stay here with the sibling public-safe text shapes", and tests/control_plane/test_compact_identifier_shape_owner.py already censuses three of those shapes. Two more were still restated per module: the 119-minus-one label body was compiled under five different names (the service-ownership projection, the Issue-Fix repository context, the Issue-Fix repository memory, the memory provider that publishes them, and the reviewer-recommendation route) and the identity-token body under three (goal_id/session_id in the reliability-diagnostics envelope, the command-record goal id, and the OpenViking history export). Nothing stopped a ninth copy, and a bound change had eight places to land.

  • Observable before → after, with the validation row that proves it: before, the two bodies appeared in eight modules and the census did not know either shape; after, each body appears exactly once, in the owner, and the two new census tests assert the found set equals {loopx/public_safe_text.py: 1} — a new local restatement, or a declared site that has already been converted, fails. No consumer's accepted value set moves: each keeps its own name and its own bound, and the regression_parity row below compares head and base failure sets over every test file that touches the changed modules.

  • Issue/task and intended base: intended base main at ed0972c31.

Author Declaration

  • Written by: model_agent (an agent in the Qoder product family).

Implemented against

  • Specification and revision: the shared-identifier-owner rule in loopx/public_safe_text.py (module docstring plus the "Shared identifier shapes stay here" block) at main ed0972c31; the census contract in tests/control_plane/test_compact_identifier_shape_owner.py; the identity-token shape documented for goal_id/session_id in loopx/capabilities/reliability_diagnostics/README.md and README.zh-CN.md.
  • Criteria:
Criterion (spec clause) Disposition Symbol / path Test or command
Shared identifier shapes have one compiled owner implemented COMPACT_LABEL_PATTERN, IDENTITY_TOKEN_PATTERN in loopx/public_safe_text.py python -m pytest tests/control_plane/test_compact_identifier_shape_owner.py
Each consuming contract retains its own field names, error text and additional validation policy implemented eight import aliases keeping the previous names (_LABEL, _SOURCE_ID_PATTERN, _LABEL_PATTERN, REVIEWER_SOURCE_ID_PATTERN, IDENTITY_TOKEN_PATTERN, LOOPX_COMMAND_RECORD_GOAL_ID_PATTERN, _PUBLIC_GOAL_ID_RE) test_labels_and_identities_import_the_owners_object
A new restatement, or an entry whose site has already been converted, fails the census implemented OPEN_LABEL_SITES / OPEN_IDENTITY_SITES in the guard test test_the_label_body_is_compiled_only_by_the_owner_and_declared_sites, test_the_identity_body_is_compiled_only_by_the_owner_and_declared_sites
Syntax only: a fold must not widen or narrow what a site accepts implemented both bounds preserved verbatim (119 stays 119, 120 stays 120) test_the_label_and_identity_bounds_stay_one_character_apart
  • Self-check before submission: verified — the guard test, the direct consumer suites, a head-vs-base failure-set comparison, ruff check on every changed file, and four source mutations re-run against the guard (re-adding a local copy of either body, widening the label bound to the identity bound, and pointing a consumer at the 127-character sibling shape); all four were killed and the tree was restored afterwards. Assumed, not verified — that the two READMEs describing the identity shape stay accurate; this change moves where the body is compiled, not what it accepts, so their tables still state the same grammar. Deliberately left out — loopx/control_plane/collaboration/result_publication.ts states the same 119 body in the other runtime; a Python census cannot guard it and pairing the two runtimes needs its own accepted basis rather than an unrequested twin entry.

Scope And Continuation

  • Completed scope and remaining work: the eight Python sites are folded and both shapes are censused. Remaining: the one TypeScript site above, and any future widening of either bound, which the bound-discrimination test will refuse until a consumer says why.
  • Slice boundary / successor: complete within this scope. A successor that pairs the label shape across both runtimes belongs with the dual-runtime twin budget, not here.

Validation

  • Tested revision: 96d87b1b2 (base ed0972c31)
  • Run state: finished
  • Input classes: synthetic | public_fixture
Check kind Result Public-safe evidence / limitation
unit passed python -m pytest tests/control_plane/test_compact_identifier_shape_owner.py — 23 passed (19 before this change): two new censuses, one owner-object identity test, one bound-discrimination test.
integration passed python -m pytest over the direct consumer suites — service-ownership, the reliability-diagnostics envelope/ledger/readback, presentation public-safety and the extension runtime: 286 passed, 1 skipped.
regression_parity passed The same 35 test files that reference any changed module, run on head and on the base revision: identical failure sets (299 identifiers each), head with four more passed, which are exactly the four added tests. The subset's failures reproduce verbatim on the base and come from running that subset in isolation, so this change carries no net regression.
static passed ruff check on every changed Python file, clean. No TypeScript changed, so the TS typecheck row is not_applicable.
manual passed Four source mutations, each against the real guard test: a local copy of the label body re-added to a consumer, a local copy of the identity body re-added, the label bound widened to the identity bound, and a consumer pointed at the sibling 127-character shape. All four failed the guard; the tree was then restored and the suite re-ran green.
  • Coverage and gaps: the changed paths are the owner's two new constants and eight import conversions, each covered by the census, the identity assertion and that module's own capability suite. Not covered: the TypeScript label site named above, and the browser/dashboard lanes (no UI in this change). Nothing was left unrun because it was inconvenient — the two-tree comparison above is the run that stands in for "did the rest of the suite move?".

Frontend / Visual Evidence

  • UI impact: none
  • Before: N/A
  • After: N/A
  • First viewport and preview: N/A
  • States and viewports shown: N/A
  • Source data: none
  • Attention review: N/A
  • Craft review: N/A

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Refactoring (no functional changes)
  • Documentation update
  • Test update

LoopX Area

  • Control plane (goals, todos, quota, scheduler, registry, runtime)
  • Benchmark boundary (adapters, runners, verifiers, scoring, evidence)
  • Capability or extension (providers, adapters, skills)
  • Public docs or presentation surface (README, protocols, dashboard)
  • Build, packaging, installer, or CI
  • Host or runtime integration

The owner module itself is the shared loopx/public_safe_text.py; six of the eight converted sites live under loopx/capabilities/, one under loopx/control_plane/runtime/ and one under loopx/extensions/.

Shared-authority RFC fixture impact

  • N/A: no promotion, runtime-routing or compatibility-projection change; no fixture schema or provider conformance arm is touched. This PR claims no RFC progress.

Boundary Checklist

  • Neither the diff nor this PR body/comments/attachments disclose private state, credentials, raw traces or verifier output, internal links, or local machine paths (including .loopx/, .codex/goals/, and live ACTIVE_GOAL_STATE.md).
  • I did not duplicate maintainer-owned benchmark work unless a maintainer split out a public issue for it.
  • I kept the change scoped to the linked issue/task.
  • Existing English/Chinese RFC pairs (including ledger entries) both have a diff, and the local premerge check python3 scripts/check_rfc_bilingual.py --base origin/main --head HEAD passes, or no paired RFC changed.
  • I completed the visual evidence section for UI changes, or marked UI impact none.
  • Every commit includes a DCO Signed-off-by trailer (git commit -s).

…s once

Five contracts compiled the 120-character-minus-one label body under their own
names and three compiled the identity-token body, so a bound change had eight
places to land. Move both grammars to the shared identifier owner, keep each
consumer's own name, field text and bound, and extend the shape census so a new
local restatement fails.

Signed-off-by: lll-hhh <169072815+lll-hhh@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: actor_kind=model_agent; model=gpt-6.1-sol; provider=OpenAI; reasoning_effort=max; declaration_source=runtime_reported.

动机 / Motivation

APPROVE:未发现阻断问题。

维护服务、Issue-Fix、诊断和历史导出的开发者,需要在多个入口遵守一致的标识符语法。
过去同一类形状在八处重复声明,修改边界容易遗漏;现在调用方复用两个已有公共语法定义,同时保留原来的不同长度上限。
已验证 label 最长 120 字符、identity 最长 121 字符;真实 CLI 的接受、拒绝、完整输出和诊断 ledger 字节保持一致。
本次不统一两类长度、不改变隐私策略或执行权限,也不声称完成跨运行时迁移或部署采用。
TypeScript 的独立形状与真实部署资格仍属于原有后续边界;本次 Python 共享定义已经可独立使用和回退。

改动思路 / Approach

把语法放回现有公共 owner,而将发布策略和错误保留在消费者,避免把形状合法误当成可公开或可执行。
当前 PR 完成八个 Python 调用方的定义复用和回归防护;不增加新配置、迁移或跨语言同步机制。

这次降低的是维护时修改多份定义的风险。Python 的正则缓存本来就可能复用编译对象,因此我没有把它算成已证明的运行时加速。保留两个形状是必要的:尾部允许 119 与 120 个字符,连同首字符,分别构成 120 与 121 的总长度。合并两者会真实改变输入集合。

具体改动 / Changes

评审完整 head:96d87b1b2b365a1050a1740dce1dd5b0a6a068b9;不可变基线:ed0972c3190ad9f0e864284bdb1d95bdefefb4a6。规范依据 loopx/public_safe_text.py @ ed0972c3190ad9f0e864284bdb1d95bdefefb4a6 的 Shared identifier shapes 与 syntax only 两条约束均为 implemented:共享语法,消费者保留自己的字段、错误和额外策略。诊断 README 原有的 identity 规则没有被改写。

关键代码讲解

现有 census 测试新增两种形状和 owner-object 检查,长度用例防止误接到相邻上限。它保护实际调用方,边界没有扩成新的配置系统;跨 TypeScript 的同步机制可留在既有迁移范围。

对主干的风险 / Risks

最强反例是新共享定义被意外放宽,所有新调用方彼此一致却共同违反旧契约。我用不可变基线和 head 运行真实 issue-fix workflow-plan 与 reliability-diagnostics ingest:共 8 个案例,完整输出、退出状态和物理 ledger 字节一致。将 label 放宽到 121、将 identity 收窄到 120 的两个 mutation 都让相同公开入口的独立 oracle 失败。

PASS:199 项 Python 测试;三个现有 Issue-Fix smoke 在仓库原生隔离 fixture 下,基线和 head 各 3 项全过。另有一次未隔离的辅助 smoke 设置失败,基线/head 完整诊断相同;该次失败未记为通过。原生 Windows PID 用例在 macOS 跳过,不能据此声明 Windows 原生资格。

标准 native premerge 全通过,精确范围 CQR 有效;Ruff 和仓库配置的 17-file mypy 均通过。 没有查询、轮询或等待远端 CI。现有调用方策略、诊断格式和 persisted schema 不变;此处不需要新前端操作流程。

我的整体评价 / Verdict

这是有明确使用者的 justified_increment:长程执行语义 preserved,用户可观察语义 preserved;当前维护收益是集中修改和防止后续漂移,未测量任务层效率收益。相邻 refactor 已在这次别名替换中完成,不再增加包装层或要求无关迁移。语义分类为 reuse_existing,没有新增状态词汇或 authority。

本次只改变 Python 形状定义及测试;没有更改页面、布局或交互渲染。
未验证原生 Windows、真实 DSH/记忆服务部署或安装采用;这些边界未由本 PR 改动。

English verdict: APPROVE

@huangruiteng
huangruiteng merged commit b4c03b1 into loopx-project:main Oct 29, 2026
1 check passed
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