Repository navigation
Commit 6ed0c0f
test(runtime): pin the guest principal an anonymous request executes as at authRequired:false endpoints (#22177)
Part of #22147
Clause-②: no
## Summary
**The card's premise does not hold on `origin/main` `fec87e7e`.** An
anonymous request admitted by an `authRequired: false` declared endpoint
already executes as the guest principal that ruling C names:
`principalKind: 'guest'`, `positions: ['guest']`, `isSystem: false`. It
is not principal-less. This was measured on a real boot, by class.
- **Why:** the dispatcher's scope resolution
(`HttpDispatcher.resolveRequestScope` → `resolveExecutionContext`) takes
the explicit guest entry, `assembleExecutionContextOrGuest`, on the
runtime face. It has done so since commit `f586f1a89`.
- **Where the misreading came from:** a doc comment in
`endpoint-executor.ts` that said "`undefined` for anonymous".
So this PR builds no behaviour change. It does two things:
1. **Pins the ruled posture**, each pin with an ablation, at two tiers:
over a socket (runtime) and on a real boot (dogfood). Once #21908's
engine-level deny lands, a guest and a principal-less call will both
answer `403`. After that, these pins are the only check that can tell
them apart.
2. **Corrects the three comments** that read as principal-less
execution.
The diff publishes nothing (measured below), so it carries no changeset.
## Who reaches what, before and after (by class)
**Before = after.** No runtime behaviour changes. The readings below
were measured at `fec87e7e` with a throwaway, uncommitted probe. The new
pins assert the same facts at `49546b0c`.
| Request (anonymous unless noted) | What is handed down | Security
middleware | Driver | Answer |
|---|---|---|---|---|
| `object_operation` find, get or create, `authRequired: false` | the
guest envelope, no user | Passes the gates that run before the
principal-less hand-off (none fires). Is not handed through. Is refused
at step 2, the CRUD check (ADR-0056 D2 deny baseline). | never reached |
`403 PERMISSION_DENIED`; no byte of the record; a create writes nothing
|
| the same operation, `authRequired: true` | n/a | n/a | n/a | `401
UNAUTHENTICATED`, before the engine is asked anything |
| a signed-in user at the `authRequired: false` endpoint | that user
(`principalKind: 'human'`) | normal evaluation | reached when granted |
served as that user |
| `flow` with a `runAs: 'user'` target, `authRequired: false` | the
automation service receives `positions: ['guest']`, with no user, no
`isSystem` and no `runAs` | none: the run's data step never reaches the
engine | never reached | `400 FLOW_FAILED`: the automation service
refuses a user-less `runAs: 'user'` run fail-closed |
| `flow` with a `runAs: 'system'` target, `authRequired: false` | the
same hand-off as the row above | the flow's data steps run as the system
principal, by the flow's own `runAs` declaration | reached | the flow's
result (see the open question below) |
**The guest's refusal is the same as a member's.** A signed-in member
without a grant gets the same refusal at this door: the same throw site
and the same `403 PERMISSION_DENIED`, byte-identical. The built-in
`/data` route never evaluates a guest at all; on the REST face it
answers an anonymous caller `401`.
## Pins and their ablations
Each ablation was a one-shot, uncommitted mutation made with
`scripts/ablation-replace.mjs`. Each was restored, and the restore was
verified as blob equal to HEAD with an empty `git diff HEAD`.
| Pin | Where | Ablation | Result |
|---|---|---|---|
| An anonymous `object_operation` reaches the engine as the guest, never
principal-less | runtime socket test; dogfood find, get and create |
**A1:** the runtime face's guest entry returns no context for a
sessionless request | Socket: 2 of 21 red. Real boot: runtime rebuilt,
marker proven in `dist/` and then absent after the restore rebuild; 4 of
6 red. The find and the get were **served the row (200)**, and the
create **wrote a row (201)**. |
| Denied, and nothing of the row disclosed | dogfood | A1 (above) | red,
as above |
| `authRequired: true` keeps answering 401 | runtime socket test;
dogfood | **A2:** the policy's `authRequired` branch disabled | Socket:
5 of 21 red (this pin and 4 existing ones) |
| `isSystem` is never set on the anonymous path | runtime socket test |
**A3:** `isSystem: true` injected into the step's context | 2 of 21 red
|
| The flow executor is handed the guest, with no user and no elevation |
runtime socket test; dogfood | A1 (the guest position disappears), and
**A4:** an `isSystem` flag injected into the door's automation context |
A1: red at both tiers. A4: 1 of 21 red. |
| An authenticated request at `authRequired: false` runs as that user |
runtime socket test; dogfood | **A5:** the user id dropped from the
runtime face's input | 2 of 21 red |
A4's first attempt was void. `ablation-replace` refused it before any
test ran, because the replacement text repeated the anchor. It was
redone with a replacement that does not.
## Evidence (at `49546b0c`)
- `pnpm --filter @objectstack/runtime test` (the `local` project): 333
files, 4714 passed, 19 skipped.
- `pnpm --filter @objectstack/runtime typecheck`: exit 0. The test-layer
debt ledger held.
- `pnpm --filter @objectstack/dogfood typecheck`: exit 0. `--listFiles`
confirms the new file is compiled.
- Dogfood: `declarative-endpoint-anonymous-guest` (6) and
`declarative-endpoint-policy` (8), 14 passed.
- Gates: all 67 commands the dispatch named exit 0. `dispatch-gates
--ran`: 59 derived, 59 run, 0 NOT-MEASURED, 0 UNRUN.
- `check:dual-build-cjs-loads` first answered PREREQUISITE NOT MET: 8
packages had no `dist/`. After building them it exits 0.
- `pnpm lint` (full): exit 0.
## No changeset
- **The diff publishes nothing from `@objectstack/runtime`.** Two of the
three corrected comments sit on interfaces the package entry does not
export. The third sits inside a function body, which the bundler strips.
Built, none of the three new texts appears anywhere under
`packages/runtime/dist/`. The control does appear there: the
documentation of the exported `createDispatcherPlugin`. Tests do not
ship.
- **There is no release note to write**, because nothing changed for
anonymous endpoints.
- **This departs from the dispatch.** It asked for a `patch` changeset
and forbade `skip-changeset`, both on the assumption that the PR would
change code. This PR therefore carries neither, and `Check Changeset`
will read red until the seat decides.
## Acceptance notes
- **The identity-resolution fault path.** When identity resolution hits
a fault it does not classify, the `catch` in
`HttpDispatcher.resolveRequestScope` leaves `executionContext`
undefined. At an `authRequired: false` endpoint, that call would then
run principal-less.
- A static read of the anonymous branch found no fault a request can
steer. API-key admission and the session read each absorb their own
faults. The tenancy read and the permission-store read re-raise loudly
(`503`).
- #21908's engine-level deny closes this path at the engine by
construction.
- The file is outside this card's claim, so this is noted here, not
edited.
- **The flow executor sees the guest only as its position.**
`AutomationContext`, the spec contract, has no `principalKind` or
`isSystem` member, so the flow executor receives the guest as the
`guest` position alone. Carrying `principalKind` would need a
`packages/spec` change, which is out of this card's scope.
## Open question for the seat
**Does ruling C's "never the system principal" reach a flow's declared
`runAs`?** An anonymous request at an `authRequired: false` `flow`
endpoint can target a flow that declares `runAs: 'system'`. That flow's
data steps run as the system principal: this is the flow's own explicit
opt-in, and the request itself still arrives as the guest. The options,
and a recommendation along the four axes, are in the dev report on
#22147. This PR builds nothing for it.
#22147 remains open for the seat, because its premise is falsified and
the open question above needs a ruling. #21908 remains open and is not
addressed here. Whether its `Blocked-by` line on #22147 still holds is
the seat's call.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01RWZbGvPFcRKvUqASZtunCU)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 98998ca commit 6ed0c0f
5 files changed
Lines changed: 403 additions & 7 deletions
File tree
- packages
- qa/dogfood/test
- runtime/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 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 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
156 | 156 | | |
157 | 157 | | |
158 | 158 | | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
163 | 167 | | |
164 | 168 | | |
165 | 169 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
543 | 543 | | |
544 | 544 | | |
545 | 545 | | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
546 | 614 | | |
0 commit comments