test(lint): time-relative fixture 改成运行时真能绑的描述符,并对 bind 期同一个 schema 钉住 (#4966) - #5497
Merged
Merged
Conversation
… can bind (#4966) `lint-flow-patterns.test.ts`'s user-less-trigger case described a flow the runtime would never sweep: `{ object: 'task', field: 'due_at', offsetDays: -1 }` fails `TimeRelativeTriggerSchema` on both counts — `field` is a diagnostic alias, not an accepted key (`dateField` is declared), and `offsetDays` is `z.array(z.number().int()).min(1)`, not a scalar. `TimeRelativeTriggerPlugin .start()` `safeParse`s that descriptor at bind time, so the fixture's flow would warn and stay unbound. The fixture stayed green because the rule decides `time-relative` from `startCfg.timeRelative != null` alone and never reads the shape, so nothing in the suite could see it. Correct the spelling to the bindable shape, keep an in-place comment explaining why it must stay bindable, and pin it against the same schema the bind path parses so it cannot rot back. No production behaviour changes — test-only. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018fxLGQdatPbBUvCgiVxg6D
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Contributor
📓 Docs Drift CheckNo hand-written docs reference the 0 changed package(s). ✅ |
This was referenced Aug 5, 2026
os-zhuang
marked this pull request as ready for review
August 5, 2026 15:23
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4966
前提复核(对
origin/main实测,成立)packages/lint/src/lint-flow-patterns.test.ts的用户缺失触发器用例里,fixture 写的是{ object: 'task', field: 'due_at', offsetDays: -1 }。对TimeRelativeTriggerSchema(packages/spec/src/automation/time-relative-trigger.zod.ts)实测safeParse,issue 说的两处全中,外加一条根级 unknown-key:补一处 issue 正文没展开、但值得写下来的细节:
field现在确实出现在该 schema 的aliases表里。但strictObject的aliases只在unrecognized_keys诊断路径上被查阅(packages/spec/src/shared/strict-object.ts的注释写明了这一点),它是「你大概想写dateField」的提示表,不是可接受的键 —— 所以 issue 的结论(「不是别名、不是转换项」)在语义上成立:这个键被拒绝,只是拒绝得比较友好。TimeRelativeTriggerPlugin.start()(packages/triggers/trigger-schedule/src/time-relative-trigger.ts:164)对binding.config.timeRelative做safeParse,失败即 warn 并return—— 不绑定。所以这个 fixture 描述的,正是 issue 说的那种 flow:lint 认定它是 time-relative 触发,运行时永远不会为它装上 sweep。改动
只动
packages/lint/src/lint-flow-patterns.test.ts一个文件:{ object: 'task', dateField: 'due_at', offsetDays: [-1] };safeParse(...).success === true。第 3 点略微超出「fixture 一处 + 注释」,理由见下面的反向验证:没有它,这个 fixture 明天可以再次腐化成不可绑形状,而全仓无人报警 —— 这正是它第一次腐化的原因。
反向验证(方向先判、再跑)
预判:把 fixture 退回旧拼写后,lint 的两条断言不会变红(规则只看
startCfg.timeRelative != null),只有新增的 schema pin 会变红。两半实测都对上。半一 —— 旧 fixture + 保留 pin:
半二 —— 旧 fixture + 注释掉 pin:
这就是 issue「为什么绿」那一节的实证:单改 fixture 不翻转任何一个测试的颜色,本 PR 的可检测性完全来自 pin。按报告纪律如实写在这里,而不是把它包装成「修复后由红转绿」。
按「键 vs 值」判据,这里钉的是一个值的裁决(描述符能不能绑),所以要求 full
safeParse绿,而不是只断言没有unrecognized_keys—— 后者会漏掉offsetDays: -1这一半。验证
消费半径普查:全仓 grep
timeRelative/dateField/offsetDays,除本 fixture 外的描述符 ——packages/services/service-automation/src/engine.test.ts、packages/lint/src/validate-flow-trigger-readiness.test.ts、packages/triggers/trigger-schedule自测、examples/app-showcase/src/automation/flows/index.ts、content/docs/**—— 全部已是 canonical 拼写,没有第二处需要一起改。范围
timeRelative后顺手safeParse)按 PM 指示不在本 PR:实测确认它值得做(canonical 之外的描述符在 authoring 期两条 lint 都返回[]),已按立单纪律另立timeRelative描述符跑不通时 authoring 期零诊断 —— 两条 flow lint 一条只看非空、一条只看对象名(#4966 建议 2) #5496,并与multi: true且filter为空的 delete_record / update_record 是「按声明清空整个对象」,authoring 期零诊断 —— #3810 的守卫按「条件被抹掉」判定,不按「条件为空」判定 #5482 的方案 1 做了交叉引用(同族:节点 config 里「已能判定、authoring 期无人报警」的约束)。Generated by Claude Code