Repository navigation
Commit 968d645
test: pin that a guest request reaches create hooks as a named caller (#30179)
## 维护者速读
- 改了什么:只加测试,三处钉住同一条规则——经访客入口进来的请求,在创建钩子看来始终是"有调用者"的请求,不会被当成内核内部的无上下文调用。
- 为什么改:这条规则此前只靠阅读成立,没有任何测试守住;访客信封里那个让引擎生成会话的字段一旦在重构中丢掉,不会有测试变红。
- 风险与回滚:零运行时改动(三个 `*.test.ts`,发布产物字节不变);回滚即 revert 本 PR。
-
先看:`packages/objectql/src/engine-execution-plumbing.session-locale.test.ts`(会话那一跳的钉子)、`packages/services/service-storage/src/attachment-access-hooks.test.ts`(整机引擎创建被拒)、`packages/core/src/security/assemble-execution-context.test.ts`(信封端)。
- 两分钟验证:`pnpm --filter @objectstack/service-storage exec vitest run
src/attachment-access-hooks.test.ts -t "guest request"`,预期 2 passed。
- 需要你做的:无,席位落地。
## What changes
Test-only. One rule, pinned at three layers: **a request served through
the guest entry reaches create hooks as a named caller, so it is never
read as a context-less (bare-kernel) engine call.**
- `@objectstack/core` — the guest envelope keeps the `guest` position
under every input a face can pass for an anonymous request (no tenant /
no grants, and guest-anchor grants in an organization).
- `@objectstack/objectql` — `buildSession` of the envelope the real
`assembleExecutionContextOrGuest` produces is defined and names no user
(and is not the system arm); a control pins that an envelope naming
nothing the session copies yields no session.
- `@objectstack/service-storage` — through the wired engine (real
`ObjectQL` + the installed attachment hooks), a create of
`sys_attachment` under the real guest envelope is refused `403
RECORD_NOT_ACCESSIBLE` and writes no row; control: the same create by a
signed-in caller resolves and stamps that caller as the uploader.
New pins are top-level `describe` blocks in each component's existing
test file. No product code changes, so `skip-changeset`: none of the
three packages' `files[]` (`dist`, `README.md`, `CHANGELOG.md`) changes
— the new test titles have zero hits in the three `dist/` trees while
`assembleExecutionContextOrGuest` (positive control) hits
`packages/core/dist/index.js`.
## Tests
All on head `36bffe5b4c`.
<details><summary>Changed files and package suites</summary>
- Changed files, one worker each: core
`assemble-execution-context.test.ts` 212/212, objectql
`engine-execution-plumbing.session-locale.test.ts` 5/5, service-storage
`attachment-access-hooks.test.ts` 153/153; each new test confirmed by
name under `--reporter=verbose`.
- Package suites under `os-verify-lock.sh`: core 133 files / 2974 tests
passed; service-storage 71 / 1329 passed; objectql 548 / 10846 passed;
each exit 0.
- `typecheck` for core, objectql, service-storage: exit 0 (each
package's `check:test-typecheck` OK).
</details>
<details><summary>One-shot ablation: drop the guest position from the
guest envelope</summary>
Mutation via `scripts/ablation-replace.mjs` on
`packages/core/src/security/assemble-execution-context.ts`: the guest
arm of `positions` replaced with an expression that evaluates to
undefined (anchor 1 to 0, blob `442040f156df` to `0039cf95db86`). core
rebuilt under the lock; `ablation-dist-preflight` found the marker in
`dist/index.js` and `dist/index.cjs`.
- core (source): exit 1, both new pins red, alongside the existing
frozen-transcription parity pins.
- service-storage (core aliased to source): exit 1, exactly the new
refusal pin red; its control stayed green.
- objectql (core through `dist/`): exit 1, exactly the new session pin
red (`expected undefined to be defined`); its control stayed green.
Restore: blob equals HEAD, `git diff HEAD` empty; core rebuilt,
`--absent` preflight clean over 14 built files, objectql file green
again (5/5).
</details>
## Acceptance notes
- `buildSession` treats an empty `positions: []` as present (its
presence test is `!== undefined`), so the identification hinges on the
key being emitted at all, not on its contents; the pins assert the
`guest` value, which is the declared vocabulary.
- The existing core parity pin (`toEqual` on the guest envelope) already
went red under the ablation; the new pin names the rule so the reason
survives a future edit of that frozen transcription.
## Verification
<details><summary>Gate derivation and reconciliation</summary>
`node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack`: 57 commands for the 3 changed paths. All 57
run, exit codes captured before any pipe; `--ran` reconciliation: "57
derived famil(ies) accounted for — 55 run, 2 NOT-MEASURED".
- 55 exit 0.
- NOT MEASURED (exit 3, PREREQUISITE NOT MET): `pnpm
check:dual-build-cjs-loads` (needs every package's `dist/`) and `pnpm
check:i18n` (needs the CLI build closure). Neither reads test files;
CI's `Lint & Repo Gates` runs both on a full build.
- Repo-wide scans and `test:repo` are left to CI.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01QSeKYn5CmmdShCJifm6WYj)_
Co-authored-by: Claude <noreply@anthropic.com>1 parent fec1f58 commit 968d645
3 files changed
Lines changed: 128 additions & 0 deletions
File tree
- packages
- core/src/security
- objectql/src
- services/service-storage/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
591 | 591 | | |
592 | 592 | | |
593 | 593 | | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
25 | 26 | | |
26 | 27 | | |
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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
2015 | 2016 | | |
2016 | 2017 | | |
2017 | 2018 | | |
| 2019 | + | |
| 2020 | + | |
| 2021 | + | |
| 2022 | + | |
| 2023 | + | |
| 2024 | + | |
| 2025 | + | |
| 2026 | + | |
| 2027 | + | |
| 2028 | + | |
| 2029 | + | |
| 2030 | + | |
| 2031 | + | |
| 2032 | + | |
| 2033 | + | |
| 2034 | + | |
| 2035 | + | |
| 2036 | + | |
| 2037 | + | |
| 2038 | + | |
| 2039 | + | |
| 2040 | + | |
| 2041 | + | |
| 2042 | + | |
| 2043 | + | |
| 2044 | + | |
| 2045 | + | |
| 2046 | + | |
| 2047 | + | |
| 2048 | + | |
| 2049 | + | |
| 2050 | + | |
| 2051 | + | |
| 2052 | + | |
| 2053 | + | |
| 2054 | + | |
| 2055 | + | |
| 2056 | + | |
| 2057 | + | |
| 2058 | + | |
| 2059 | + | |
| 2060 | + | |
| 2061 | + | |
| 2062 | + | |
| 2063 | + | |
0 commit comments