Skip to content

Commit 22687eb

Browse files
committed
fix(cli,lint): 把消费被拒别名拼法的 fixture 改为 canonical (#5017)
#5046 把 validate-expressions / validate-security-posture 收敛为只读 spec 声明的键之后,两处 fixture 用的正是被拒的别名拼法,规则不再读它们: - `packages/cli/test/authoring-rule-command-parity.test.ts:90` —— CI Test Core 判红点。`validations: [{ name: 'r', expression: … }]` 里 `expression` 是 `validation.zod.ts` 按名拒绝的四个别名之一,收敛后没人读,`expression-invalid` 在三命令上都不再触发。改为 canonical `condition`,并补上 `type` / `message` 让 fixture 除了那条**刻意种下的**裸引用缺陷之外完全 spec 合法 —— parity 测试 本就该跑在 spec 合法元数据上,原来的 fixture 等于种了两个缺陷。 - `packages/lint/src/runtime-gate.test.ts:125,150` —— 这两处此前是绿的,但绿得 没有意义:`validationRules` + `expression` 双重别名,使得"上下文里有一条坏 验证规则"的 fixture 实际产生 0 条 finding(实测),所以 D4 那条断言 `result.errors).toEqual([])` 通过的原因是**没有东西可减**,而不是减法正确。 改为 canonical 后上下文真的产出 1 条 `invalid CEL predicate` finding,减法 逻辑第一次被真正跑到 —— 且仍然通过。 全包 grep 过 `expression:` / `predicate:` / `formula:` 作 validation 键、 `criteria:` 作 sharing 键、`validationRules:`、`security: { sharingModel }`、 `reference_to` / `referenceTo`:其余命中要么是 #5046 里刻意 pin 住 schema 拒绝 的别名 fixture,要么属于本 PR 未改动的规则(`validate-rule-compilability.ts` 自己读 `validationRules`,已另开 #5096),要么是 objectql / driver 等包自己的 内部形状,与本次收敛无关。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018iARDqtrhQgz6fVHDeDkbQ
1 parent 23e3f59 commit 22687eb

2 files changed

Lines changed: 19 additions & 3 deletions

File tree

‎packages/cli/test/authoring-rule-command-parity.test.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,13 @@ const CASES: ReadonlyArray<{ rule: string; blindTo: readonly AuthoringCommand[];
8787
rule: 'expression-invalid',
8888
blindTo: ['lint'],
8989
stack: withBaseline({
90-
objects: [{ name: 'parity_lead', label: 'Lead', sharingModel: 'private', fields: { lead_score: { type: 'number', label: 'Score' } }, validations: [{ name: 'r', expression: 'lead_score > 100' }] }],
90+
// The planted defect is the BARE `lead_score` (a record-scoped predicate
91+
// binds fields under `record`, so this silently evaluates to null) — not
92+
// the key it is written under. Spelled `condition`, which is the only key
93+
// `validation.zod.ts` declares: `expression` is one of the four names it
94+
// rejects outright, so a fixture using it planted TWO defects and let the
95+
// rule under test read a stack `os validate` would never accept (#5017).
96+
objects: [{ name: 'parity_lead', label: 'Lead', sharingModel: 'private', fields: { lead_score: { type: 'number', label: 'Score' } }, validations: [{ type: 'script', name: 'r', message: 'Score out of range', condition: 'lead_score > 100' }] }],
9197
}),
9298
},
9399
{

‎packages/lint/src/runtime-gate.test.ts‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,12 @@ describe('runtime publish gate (#4463)', () => {
122122
{
123123
name: 'leave_request',
124124
fields: { owner: { type: 'text' } },
125-
validationRules: [{ name: 'bad', expression: 'record.owner ==', message: 'x' }],
125+
// Spelled with the two keys the spec declares (`validations` /
126+
// `condition`). Written as `validationRules` / `expression` — both
127+
// rejected aliases — the broken CEL was not reachable by the rule at
128+
// all, so this fixture proved the subtraction worked by having nothing
129+
// to subtract (#5017).
130+
validations: [{ type: 'script', name: 'bad', message: 'x', condition: 'record.owner ==' }],
126131
},
127132
];
128133

@@ -147,7 +152,12 @@ describe('runtime publish gate (#4463)', () => {
147152
{
148153
name: 'leave_request',
149154
fields: { owner: { type: 'text' } },
150-
validationRules: [{ name: 'bad', expression: 'record.owner ==', message: 'x' }],
155+
// Spelled with the two keys the spec declares (`validations` /
156+
// `condition`). Written as `validationRules` / `expression` — both
157+
// rejected aliases — the broken CEL was not reachable by the rule at
158+
// all, so this fixture proved the subtraction worked by having nothing
159+
// to subtract (#5017).
160+
validations: [{ type: 'script', name: 'bad', message: 'x', condition: 'record.owner ==' }],
151161
},
152162
];
153163
const result = runRuntimeAuthoringRules({

0 commit comments

Comments
 (0)