Repository navigation
Commit 6af3d29
test(dogfood): re-point the runAs and anonymous-guest flow pins to flow start admission's record rule (#29451)
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi97CjkpAhpM1mjM36Rm8Fvqz)_
Fixes #29426
## 维护者速读
- 改了什么:只改两个 dogfood 测试文件和一个测试 fixture,让它们按 #29365 已落地的规则断言;运行时代码一行未动。
- 为什么改:#29365 之后 main 的 Dogfood Regression Gate
一直红,这四个用例断言的是该规则有意改掉的旧行为(dogfood 分片在 PR 和合并队列里不跑,所以落地前没暴露)。
- 风险与回滚:仅测试面,无发布内容(skip-changeset);回滚即 revert 本 PR,main 会重新变红。
-
先看:`packages/qa/dogfood/test/fixtures/flow-runas-fixture.ts`(新增只读策略与"定义自选行"的读流程)、`packages/qa/dogfood/test/flow-runas.dogfood.test.ts`(拒收断言与读写提权证明)、`packages/qa/dogfood/test/declarative-endpoint-anonymous-guest.dogfood.test.ts`。
- 两分钟验证:构建 dogfood 依赖闭包后运行 `cd packages/qa/dogfood && pnpm exec vitest
run test/flow-runas.dogfood.test.ts
test/declarative-endpoint-anonymous-guest.dogfood.test.ts`,预期 17/17 通过。
- 需要你做的:无,席位落地。
## What changes
The rule these pins now follow: **a start input the definition reads as
a record id is judged as the caller, for every runAs, before the run
exists (#29365).** Four dogfood cases asserted the behaviour that rule
deliberately replaced. They are re-pointed, and the proofs they carried
are kept with inputs the rule admits.
`flow-runas-fixture.ts` (shared with
`flow-runas-schedule.dogfood.test.ts`, which is unaffected):
- A select-only RLS policy (`runas_note_shared_read`) makes an admin
note whose `status` is `shared` readable to the member. No write policy
admits it, so the member still cannot write it.
- Three new flows: `runas_system_read_sealed`, `runas_user_read_sealed`
and `runas_system_read_sealed_via_parent`. Their definition fixes the
row with a literal `name` filter and takes no start input.
- `viaParent` gains an option to hand no input.
`flow-runas.dogfood.test.ts`:
- **Write elevation and de-elevation** now use a shared admin note,
which the member can read but not write. The `runAs: 'system'` child
writes it. The `runAs: 'user'` run fails on its node with `400
FLOW_FAILED`. Because the member can read the row, the node's refusal is
now the record layer's access refusal: `update_record(runas_note)
failed` with `details.innerRefusal.code` `PERMISSION_DENIED`. It used to
be the read door's not-found.
- **Read elevation** now uses the sealed flows. The elevated run returns
the admin note, and the user-mode run returns nothing.
- New case: a member can read the note, and a read flow returns it under
either runAs.
- New precondition: the member can read a shared note but its direct
write is refused.
- **Re-pointed refusals** (two cases, write and read): a member start
that hands an unreadable note id to the `runAs: 'system'` child (through
the user-mode parent's `subflow`) or to the `runAs: 'user'` flow gets
this full answer:
- `404 RECORD_NOT_FOUND` in the ADR-0112 envelope;
- no `data`, and no field of the note in the body (the id in the message
is the caller's own input);
- no run recorded for the started flow or its child;
- the note unchanged.
`declarative-endpoint-anonymous-guest.dogfood.test.ts`:
- The executor-is-handed-the-guest pin now uses a start that names no
row. Admission has nothing to load, so the executor is reached and the
user-less `runAs: 'user'` refusal answers, as before.
- New case: a guest start that names the seeded row gets `404
RECORD_NOT_FOUND` before the run exists. The executor is never called,
the seeded row's name is not in the body, every engine call the door's
load made carries the guest context (`principalKind: 'guest'`,
`isSystem: false`), and the driver is never reached.
Forced test edits (each one named):
`memberTriggerExpectingAccessRefusal`'s message assertion (not-found →
access refusal plus `innerRefusal.code`); the rows the four elevation
and de-elevation legs use; the guest flow pin's start params (`{ noteId
}` → `{}`).
## Tests
All on head `b237bdc7b` (origin/main `f95d0dbad` merged in), with the
dogfood closure rebuilt (`turbo run build --filter='./packages/**'`,
78/78), under `scripts/pm/os-verify-lock.sh`:
- The two files: `cd packages/qa/dogfood && pnpm exec vitest run
test/flow-runas.dogfood.test.ts
test/declarative-endpoint-anonymous-guest.dogfood.test.ts` gives **17/17
passed**. On main `d93acbbe` before this change it gave 4 failed and 8
passed.
- Every dogfood file that starts a flow or declares `runAs` (`grep -l
"/automation/\|runAs" packages/qa/dogfood/test/*.test.ts`, 42 files,
including `flow-runas-schedule`, which shares the fixture) gives **Test
Files 42/42, Tests 428/428 passed**.
- `pnpm --filter @objectstack/dogfood typecheck` exits 0. Root eslint
`--no-inline-config` on the three files exits 0.
<details><summary>Ablations (one per negative pin family; each leg
mutated through scripts/ablation-replace.mjs, rebuilt, proved in dist/
by scripts/ablation-dist-preflight.mjs, restored and proved
absent)</summary>
1. Flow start admission off (`refuseUnreadableFlowStartRecords` returns
at once, `@objectstack/runtime`): **3 failed | 14 passed**. Red: both
member refusal cases and the guest refusal case. Restored: `git diff
HEAD` empty, marker absent from dist.
2. De-elevation off (`resolveRunDataContext` treats `runAs: 'user'` as
`system`, `@objectstack/service-automation`): **2 failed | 15 passed**.
Red: the user-mode write leg (no longer `400 FLOW_FAILED`) and the
user-mode sealed read (returned the row). Restored the same way.
</details>
## Acceptance notes
- No runtime change. Every case is a test that asserted what #29365
changed on purpose. Its code and docs already settle each one: the rule
covers user runs and inputs passed down through `subflow`, and the guest
is judged like any other caller.
- `skip-changeset`: the diff only touches `packages/qa/dogfood/test/**`
(private package, publishes nothing).
- The claim carries no `Clause-②:` / `Metadata-protocol:` lines, so none
are written here.
## Verification
- Gate readings for the 51 derived families, and their `--ran`
reconciliation, are in the os-dev-report on #29426.
- CI: the Dogfood Regression Gate runs on `main` only. These files are
proven by the local runs above, and the first `main` push after merge
confirms them.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01ADHkmSoKQWHgd1oZe8j7Pu)_
Co-authored-by: Claude <noreply@anthropic.com>1 parent cafe8ee commit 6af3d29
3 files changed
Lines changed: 207 additions & 27 deletions
File tree
- packages/qa/dogfood/test
- fixtures
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
24 | 31 | | |
25 | 32 | | |
26 | 33 | | |
| |||
282 | 289 | | |
283 | 290 | | |
284 | 291 | | |
| 292 | + | |
| 293 | + | |
285 | 294 | | |
286 | 295 | | |
287 | 296 | | |
288 | | - | |
| 297 | + | |
289 | 298 | | |
290 | 299 | | |
291 | 300 | | |
| |||
305 | 314 | | |
306 | 315 | | |
307 | 316 | | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
308 | 340 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
37 | 49 | | |
38 | 50 | | |
39 | 51 | | |
| |||
117 | 129 | | |
118 | 130 | | |
119 | 131 | | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
120 | 168 | | |
121 | 169 | | |
122 | 170 | | |
123 | 171 | | |
| 172 | + | |
| 173 | + | |
124 | 174 | | |
125 | 175 | | |
126 | 176 | | |
| |||
129 | 179 | | |
130 | 180 | | |
131 | 181 | | |
132 | | - | |
| 182 | + | |
133 | 183 | | |
134 | 184 | | |
135 | 185 | | |
136 | 186 | | |
137 | 187 | | |
138 | 188 | | |
139 | | - | |
| 189 | + | |
140 | 190 | | |
141 | 191 | | |
142 | 192 | | |
| |||
148 | 198 | | |
149 | 199 | | |
150 | 200 | | |
151 | | - | |
| 201 | + | |
152 | 202 | | |
153 | 203 | | |
154 | 204 | | |
| |||
163 | 213 | | |
164 | 214 | | |
165 | 215 | | |
| 216 | + | |
166 | 217 | | |
167 | 218 | | |
168 | 219 | | |
| |||
182 | 233 | | |
183 | 234 | | |
184 | 235 | | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
185 | 239 | | |
186 | 240 | | |
187 | 241 | | |
| |||
191 | 245 | | |
192 | 246 | | |
193 | 247 | | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
194 | 253 | | |
195 | 254 | | |
196 | 255 | | |
| |||
200 | 259 | | |
201 | 260 | | |
202 | 261 | | |
203 | | - | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
204 | 266 | | |
205 | 267 | | |
206 | 268 | | |
| |||
0 commit comments