Repository navigation
fix(lark): state the upload acknowledgement shape once (#7387) - #7395
huangruiteng merged 2 commits into
Conversation
`_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
left a comment
There was a problem hiding this comment.
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 没有改。
关键代码讲解
RESULT_FILE_KEY_PATTERN@25:文件与紧邻图片模式分别编译原来明确的形状;不是把 file/image 合并,也不是拿其它 ID 家族的宽字符集合替换。源头常量适合资源模块,不需要扩展全局 actor vocabulary。_uploaded_resources@73:@84 的 saved ACK 和 @109 的 fresh ACK 使用同一key_pattern.fullmatch。缓存不匹配仍拒绝,verify-only 不能制造新资源;成功回执仍由原路径持久化再返回。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.
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_constructionis red onmain, becauseloopx/extensions/lark/return_files.pybuilds 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 passedin that file, and the two use sites (reading a saved acknowledgement back, accepting a fresh one) now answer from the same compiled pattern. Proven bytest_no_lark_module_hides_an_unfoldable_identifier_constructionplus 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
mainatc6462f902. The issue reports the site at:100; the scan actually reports two sites (:75and:100), and both are folded here, so the row closes rather than half-closes.Author Declaration
Implemented against
Specification and revision: the guard itself —
tests/architecture/test_lark_identity_shape_owner.pyatc6462f902, its docstring ("Decided on the folded value of every regular-expression construction in the product tree, not on spelling") andunfoldable_offender_rows, whose message offers two exits: declare the site or route it to the owner. Plus Lark identity shape test fails on main: return_files.py builds an unfoldable identifier regex #7387.Criteria:
RESULT_FILE_KEY_PATTERN,CHAT_IMAGE_KEY_PATTERNinloopx/extensions/lark/return_files.pytests/architecture/test_lark_identity_shape_owner.py::test_no_lark_module_hides_an_unfoldable_identifier_constructiontest_the_folded_patterns_are_the_construction_they_replacetests/extensions/test_lark_upload_key_shape.py::test_the_folded_patterns_are_the_construction_they_replace_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)::test_the_image_prefix_accepts_what_the_file_prefix_refusesDECLARED_UNFOLDABLE_SITESunchangedDECLARED_UNFOLDABLE_SITESentries, and everykey_prefixuse 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 reallark-clibinary was invoked — the acknowledgement bytes still come from a scripted runner, as in the existing fixtures.Scope And Continuation
loopx/extensions/lark/return_files.pyno longer builds a regex at runtime.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@handlemention 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.ruff check tests loopx/canary loopx/control_plane loopx/domain_packs loopx/presentationalready reports 3F811on unmodifiedmain(tests/test_chat_conversation_bindings.py, fixture-parameter names colliding with the# noqa: F401fixture 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
unittests/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)architecturetests/architecture/test_lark_identity_shape_owner.py— 84 passed; the same file reports1 failed, 83 passedon unmodifiedmainintegrationtests/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 sitesregression_paritytests/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_constructiondisappearing. Net regression 0staticruff checkon both changed files → All checks passed (pinned range, 0.15.22).mypy's declaredfileslist (19 entries) contains neither file, so its scope is unchanged; no new module, so the top-level budget is untouchedmutation240 → 241, floor1 → 0, class widened to the event-id set, image prefix collapsed onto the file prefix,fullmatch → matchat 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 againreal_backendlark-clibinary or network call; acknowledgement keys come from a scripted runner, so this PR does not prove provider behaviorintegration/windowsskipif-gated on no-follow directory opens, so the Windows lane is left to CI_uploaded_resourceskeyword, 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_imagesis pinned at the pattern level rather than through a full image upload fixture, because that route additionally requires a private transport; andverify_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
Type of Change
LoopX Area
Technical Direction
Shared-authority RFC fixture impact
Boundary Checklist
.loopx/,.codex/goals/, and liveACTIVE_GOAL_STATE.md).