Skip to content

fix(lark): state the upload acknowledgement shape once (#7387) - #7395

Merged
huangruiteng merged 2 commits into
loopx-project:mainfrom
Jiaqiiii523:fix/lark-upload-key-shape-foldable
Oct 26, 2026
Merged

huangruiteng merged 2 commits into
loopx-project:mainfrom
Jiaqiiii523:fix/lark-upload-key-shape-foldable

Conversation

@Jiaqiiii523

Copy link
Copy Markdown
Contributor

Goal And Delivered Outcome

  • Outcome basis / optional anchor: Lark identity shape test fails on main: return_files.py builds an unfoldable identifier regex #7387 — a required-suite failure reproduced on unmodified main.

  • Goal/source and gap: tests/architecture/test_lark_identity_shape_owner.py::test_no_lark_module_hides_an_unfoldable_identifier_construction is red on main, because loopx/extensions/lark/return_files.py builds an acknowledgement-key regex twice from a value the scan cannot fold. The scan cannot fold it because the prefix arrives as a parameter, while the two callers that supply it state "file_" and "img_" as literals in this same file. So the shape was decided twice inline, invisible to every layer of the guard, and the reported failure is the honest bill for that.

  • Observable before → after, with the validation row that proves it: the guard row goes 1 failed → 84 passed in that file, and the two use sites (reading a saved acknowledgement back, accepting a fresh one) now answer from the same compiled pattern. Proven by test_no_lark_module_hides_an_unfoldable_identifier_construction plus the parity run below.

  • Issue/task and intended base: Closes Lark identity shape test fails on main: return_files.py builds an unfoldable identifier regex #7387. Base main at c6462f902. The issue reports the site at :100; the scan actually reports two sites (:75 and :100), and both are folded here, so the row closes rather than half-closes.

Author Declaration

  • Written by: model_agent (Claude, Anthropic) — AI-assisted change, disclosed.

Implemented against

Criterion (spec clause) Disposition Symbol / path Test or command
No Lark module hides an identifier construction the scan cannot fold implemented RESULT_FILE_KEY_PATTERN, CHAT_IMAGE_KEY_PATTERN in loopx/extensions/lark/return_files.py tests/architecture/test_lark_identity_shape_owner.py::test_no_lark_module_hides_an_unfoldable_identifier_construction
Folding must not re-decide the shape implemented test_the_folded_patterns_are_the_construction_they_replace tests/extensions/test_lark_upload_key_shape.py::test_the_folded_patterns_are_the_construction_they_replace
Both use sites answer from one pattern implemented _uploaded_resources(..., key_pattern=...) ::test_a_saved_acknowledgement_outside_the_shape_is_not_reused (read-back branch) and ::test_an_acknowledgement_outside_the_shape_is_refused (accept branch)
The two resource kinds stay distinguishable implemented the two exported patterns ::test_the_image_prefix_accepts_what_the_file_prefix_refuses
Declaration table not widened implemented, with reason DECLARED_UNFOLDABLE_SITES unchanged the guard's own count assertions stay green
  • Self-check before submission: read the guard's three layers (folded-value scan, consumer wiring, declaration budget), the two existing DECLARED_UNFOLDABLE_SITES entries, and every key_prefix use in the file. Verified: the guard file, the three existing Lark result-file suites, the CI lint scope on both changed files, a base/head parity run, and seven mutation arms. Deliberately not done: not declaring the sites instead of folding them (see Scope below), and no real lark-cli binary was invoked — the acknowledgement bytes still come from a scripted runner, as in the existing fixtures.

Scope And Continuation

  • Completed scope and remaining work: closes Lark identity shape test fails on main: return_files.py builds an unfoldable identifier regex #7387. loopx/extensions/lark/return_files.py no longer builds a regex at runtime.
  • Slice boundary / successor: the guard's other exit — declaring return_files.py: 2 — was rejected on its own evidence: both current declarations are justified because those sites "decide no identifier shape at all" (a @handle mention lookup, a caller-supplied routing pattern). This site does decide a shape, and the prefix was always a literal in this file, so it can and should be folded. Complete within this scope.
  • One unrelated observation, not touched here: ruff check tests loopx/canary loopx/control_plane loopx/domain_packs loopx/presentation already reports 3 F811 on unmodified main (tests/test_chat_conversation_bindings.py, fixture-parameter names colliding with the # noqa: F401 fixture imports at lines 7 and 9). That is a separate required-gate failure and it is not caused by or fixed by this branch.

Validation

  • Tested revision: 071f903
  • Run state: finished
  • Input classes: synthetic
Check kind Result Public-safe evidence / limitation
unit passed tests/extensions/test_lark_upload_key_shape.py — 14 passed (accept boundary at 1 and 240 tail characters; refuse empty tail, 241, ., space, wrong prefix, missing prefix; both branches; pattern equality)
architecture passed tests/architecture/test_lark_identity_shape_owner.py — 84 passed; the same file reports 1 failed, 83 passed on unmodified main
integration passed tests/extensions/test_lark_private_result_files.py, tests/extensions/test_lark_manager_returns.py, tests/extensions/test_lark_private_manager_returns.py — 108 passed unchanged; they drive upload and read-back through the delivery manager with a scripted CLI runner, which is the accept side of both folded sites
regression_parity passed tests/architecture + tests/canary + those three Lark suites in two checkouts at the same revision: BASE 4 failed / 1800 passed, HEAD 3 failed / 1801 passed, and the failure-set diff is exactly …test_no_lark_module_hides_an_unfoldable_identifier_construction disappearing. Net regression 0
static passed ruff check on both changed files → All checks passed (pinned range, 0.15.22). mypy's declared files list (19 entries) contains neither file, so its scope is unchanged; no new module, so the top-level budget is untouched
mutation passed 7 arms on the folded patterns and call sites, each reverted from the reviewed file: ceiling 240 → 241, floor 1 → 0, class widened to the event-id set, image prefix collapsed onto the file prefix, fullmatch → match at both sites, read-back branch no longer asking the question, prefix dropped entirely. Killed by 2, 2, 2, 2, 4, 1 and 6 failing rows respectively; restored file green again
real_backend not_run no real Lark tenant, lark-cli binary or network call; acknowledgement keys come from a scripted runner, so this PR does not prove provider behavior
integration/windows not_run run on macOS; the existing result-file suite is itself skipif-gated on no-follow directory opens, so the Windows lane is left to CI
  • Coverage and gaps: changed lines are the two exported patterns, the _uploaded_resources keyword, its two callers and the two use sites — all inside one module, and every one of those lines is executed by either the new boundary file or the 108 existing rows. Not covered by choice: uploaded_chat_images is pinned at the pattern level rather than through a full image upload fixture, because that route additionally requires a private transport; and verify_result_files (the download side) is untouched by this change. The 3 pre-existing failures above are named rather than repaired here.

Frontend / Visual Evidence

  • UI impact: none
  • Before: N/A
  • After: N/A
  • States and viewports shown: N/A — no user-visible surface changed.
  • Source data: none
  • Attention 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

Technical Direction

  • Direction / acceptance reference, when applicable: Architecture and research incubator — semantic vocabulary convergence (the guard this satisfies), no new roadmap id.

Shared-authority RFC fixture impact

  • Production-scale fixture schema: N/A.
  • Semantic dimensions changed, or reviewed no-impact rationale: N/A — no shared Goal authority claim.
  • Provider conformance arms run: N/A.
  • Read-only legacy/file/PostgreSQL three-arm rehearsal: N/A.

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.

`_uploaded_resources` built `re.fullmatch(key_prefix + tail, ...)` at both of
its use sites, so the identifier-shape guard could not fold the value and
reported the file as an unfoldable site: `return_files.py:75` when reading a
saved acknowledgement back and `:100` when accepting a fresh one.

The prefix was never caller data -- the two callers in this same file pass
`file_` and `img_` as literals -- so both shapes are now stated once as module
patterns and the use sites answer from them. The guard's other exit (declaring
`return_files.py: 2`) was rejected: the two current declarations are justified
because those sites decide no identifier shape at all, while this one does.

Refs loopx-project#7387

Signed-off-by: Jiaqiiii523 <293262669+Jiaqiiii523@users.noreply.github.com>
The upload and read-back branches had no direct coverage: the existing
result-file fixtures drive the delivery manager and happen to return one valid
key, so nothing pinned what an acknowledgement may contain.

Fourteen rows state the boundary from the contract instead of from observed
output -- one to 240 tail characters accepted, empty tail, 241, a dot, a space,
a missing prefix and the wrong resource prefix refused, both branches, the two
prefixes staying distinct, and one equality row that pins each folded pattern
against the exact string the inline concatenation used to build.

Refs loopx-project#7387

Signed-off-by: Jiaqiiii523 <293262669+Jiaqiiii523@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 · declaration_source=runtime_reported · reasoning_effort=max.

详细中文评审

动机

维护 Lark 结果文件和图片回执、以及执行必需架构检查的集成方。 同一个资源回执的两次检查原来都临时拼接正则,架构扫描看不清来源;现在由资源种类传入同一编译模式,正常、拒绝和缓存重放结果保持一致。 当前头 206 项检查通过,原始基线重现架构失败;15 个真实本地上传入口案例及两种资源各 281 个输入的双侧观察一致,缓存重读不会重新上传。 只常量化既有回执形状和修复扫描可见性,不增加上传权限、协议或能力,不宣称真实 Lark 租户、Windows 或安装后宿主已验收。

APPROVE,精确头 071f9034a842ec87f0db036e973f68a87839746d;未发现阻断问题。 需求来自 #7387,并先读其已有可执行约定 identity-shape guard@c6462f902a1c6a519eb4752b62637580f0e9cd35。folded-shape-visibility 对应扫描可以看清实际构造而不扩大例外表;ack-boundary-parity 对应原前缀、字符和长度/全值匹配;recovery-authority-parity 对应原缓存、拒绝与恢复。它不是借测试通过重新定义一种 Lark 身份。

改动思路

两个现有调用者本来就在本模块中分别提供字面量 file_ 与 img_,因此可以把每种既有资源回执模式编译一次,再交给同一个 _uploaded_resources 的缓存读回和新回执检查。这样让扫描能看到实际值,也消除了两处临时拼装。没有放宽 declaration table,没有借用允许点号/冒号的 event-id 模式,也没有新建通用配置、协议或另一个上传 owner。

具体改动

完整两文件 +164/-5:生产 +14/-5,新增 150 行聚焦测试。资源类型、file_key/image_key、1–240 尾部长度、原字符集合与 fullmatch 保持相同。私有 helper 的 keyword 在两个活跃调用点同时改为 pattern;两个 public 资源入口的签名、快照读字节、缓存身份、lock、权限重检、临时文件与未知图片上传 fence 没有改。

关键代码讲解

  1. RESULT_FILE_KEY_PATTERN@25:文件与紧邻图片模式分别编译原来明确的形状;不是把 file/image 合并,也不是拿其它 ID 家族的宽字符集合替换。源头常量适合资源模块,不需要扩展全局 actor vocabulary。
  2. _uploaded_resources@73:@84 的 saved ACK 和 @109 的 fresh ACK 使用同一 key_pattern.fullmatch。缓存不匹配仍拒绝,verify-only 不能制造新资源;成功回执仍由原路径持久化再返回。
  3. uploaded_chat_images@61:供应 image 模式,保留既有 fence_upload=True。图片 create 已开始但 ACK 丢失时,后续读取不能重新上传补造一次“成功”;该行为已在独立负例中读回。

当前头独立 206 项通过:84 架构、14 新边界、108 既有 manager/file return 消费者。不可变 c6462f902a1c6a519eb4752b62637580f0e9cd35 单独执行同一架构文件为 1 failed/83 passed,准确重现两处隐藏构造;其原 108 个消费者仍通过。没有把新测试在 base 不存在当作失败/通过对照,也没有继承作者对广域 CI 或宿主问题的归因。

另用同一程序在两臂实际运行 public 文件/图片上传入口:原生 TS 附件校验、真实不可变文件快照、文件锁/缓存及独立本地 provider 子进程。15 个正常、1/240/241 边界、错资源/点号、损坏缓存、缺 ACK、verify-only、撤销和空输入案例的完整观察相同;两资源各 281 个输入的判定也相同。有效缓存第二次读取 provider 调用为 0,未知图片 fence 和错误记录继续拒绝而不重造。外部回执是合成值,没有调用真实 Lark 租户、官方 CLI、网络或发送消息;这限定了资格,没有假称 provider 已通过。

对主干的风险

最强反例是模式提取悄悄拓宽字符/边界,或 saved 与 fresh 检查分裂,导致坏 key 被接受、未知上传被再生成。本次同时检查原模式字节/flags、真实入口的错误与缓存、原 108 个消费者,均未出现该变化。搜索也确认 identity_shapes 管理其它 ID 家族,另有 message attachment 的既有校验;本 PR 不宣称把所有 Lark 标识符归为一个新 owner。

scoped Ruff、完整 diff hygiene 与 semantic advisory 通过;advisory 不覆盖全部语义,仍人工确认两个常量只是既有 provider-local 形状的编译表示。严格 cqr_8650bce72c429cdde0c8 为 PASS/valid,物理字段与 native 记录一致。首次 Goal premerge 在新回执写入前读到旧 stale receipt,自动子项都过而 aggregate 保留失败;记录当前精确回执后,同一标准门重跑 6direct+10selected 通过、零人工 hold。原 stale 结果保留,没有改源码或静默豁免。

当前 wait_for_ci=false,未查询、轮询或触发 hosted CI。原生 Windows、安装后 App/Host、真实 Lark provider 和全套 CI 未验;本次是现有纯形状/本地持久回执边界的等价改动,未据它宣称长期收益、完整费用节省或新的用户旅程。默认未授权、撤销、verify-only 和空输入不会因模式可用而激活上传。

我的整体评价

APPROVE,限 071f9034a842ec87f0db036e973f68a87839746d。 既有架构缺口有独立 base 失败与 head 通过,实际本地消费者与正常/负例/恢复保持等价,使用与长期控制面行为均为 preserved。现有资源上传 owner 已拥有两种资源的回执校验;编译一次并复用足够,原快照、缓存、锁与权限检查保持原 owner,不需要新协议或配置。 本 PR 只把原文件/图片回执的模式显式化,保留两条资源入口和已有持久回执行为;没有把它命名为完整 Lark 身份或授权生命周期。 这是有界的复用与简化;不需要新配置或跨层重写。仅内部资源校验与测试变化,visual_review 为 not_applicable;没有把常量存在、回执或 green check 当作调用权限。精确 head closeout/readiness 与维护者合并授权仍分开,本轮不合并。

英文简短结论

English verdict: APPROVE — 071f903. Exposes the existing resource-specific ACK shapes once and reuses them at both saved/fresh checks without changing authority, cache or no-regeneration behavior. Independent206 tests pass; immutable base reproduces the guard failure. Fifteen actual local public-entrypoint cases and281 inputs per resource shape are equivalent across both arms. Exact quality and post-record Goal-bound premerge pass. External ACKs are synthetic; live Lark, native Windows, installed Host, full CI and causal cost/utility remain unqualified. No merge authority.

@huangruiteng
huangruiteng merged commit 92a170f into loopx-project:main Oct 26, 2026
20 of 26 checks 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.

Lark identity shape test fails on main: return_files.py builds an unfoldable identifier regex

3 participants