Commit f192981
原 Example 把「hook 才有的 `ctx.input.contact_id`」和「hook 拿不到的
`services.data`」拼在一起。实测该块不是「在 hook 里跑得慢」而是根本不成立:
按 check:skill-examples 同款 tsconfig 编译,`services` 与 `ctx` 双双 TS2304
(Cannot find name),因为这两个名字在本运行时里没有任何一处同时在作用域内 ——
hook 有 `ctx` 没 `services`,持有绑定的代码有 `services` 没 `ctx`。
复核 #5720 的结论在 origin/main 未变:engine.ts 四处 `hookContext` 构造点
(4796/4929/5505/6059)逐键构造 object/event/input/session/provenance/user/
api/transaction/ql,`buildSandboxContext`(runtime/src/sandbox/body-runner.ts)
同样只产 input/previous/user/session/event/object/result/api/log/crypto ——
两条路径都没有 `services` 键。
照 PR #5938 定下的模式改(取「去掉 `ctx.` 的 hook 味道」那一支):
- Example 改写为**持有该绑定的代码**在调用(形状对齐 sharing-service.mdx 的
`mayEditContract(sharing: ISharingService, …)`):记录 id 作为普通入参传入,
全块无 `ctx`。顺带修掉两处误读 —— `get` 返回的是信封 `{ object, id, record }`
而非行本身(原文 `contact.id` 是撞对的),`find` 返回 `{ records, … }`。
- 新增 binding note Callout:hook 没有 `services` 键,其跨对象通道是 `ctx.api`,
并指向 examples.mdx 第 2 节(#5938 已进 os:check 真编译的那块),不在本页重复。
- 新增 `## Canonical source` 一节,答分诊点名的措辞问题:本页是全章唯一不指向
`contracts/*-service.ts` 的页,因为 spec 根本没有 `IDataService`;最近邻
`IDataEngine` 是形状不同的更低一层面(`find(objectName, query, options)
: Promise<any[]>`)。故签名取 `ObjectStackClient.data`,返回体对应 spec 的
`*DataResponseSchema`(protocol.zod.ts),托管运行时按同一形状绑定。
os:check 标记:不补,且与 #5945 无关 —— 反向验证给出的是另一条硬约束。给该块
加标记后实测:
content/docs/kernel/runtime-services/data-service.mdx:88:40
error TS2307: Cannot find module '@objectstack/client' or its
corresponding type declarations.
仅此一条诊断。check:skill-examples 的 paths 由 `@objectstack/spec` 自己的
exports 派生,而 spec 不依赖 client,所以标记后只能改成手写 `DataService`
局部类型 —— 那样这块就只钉住它自己。此约束已写进正文,待本面有 spec 侧契约
可 import 时再补标记。本块从不触碰 `ctx.api`,故不受 #5945 裁决影响。
门禁:check:doc-authoring 362 文件干净;check:nul-bytes 5745 文件干净;
check:docs-audit-scope 绿;check:skill-examples 207 块全绿(未变,本页不贡献
标记块也不产生 orphan)。Example 块单独对已构建的 @objectstack/client 声明
编译:tsc --noEmit 退出 0。MDX 以 @mdx-js/mdx 编译通过(examples.mdx /
sharing-service.mdx 作阳性对照)。
Fixes #5944
Claude-Session: https://claude.ai/code/session_01BDmDsu2575gDxeMCxXhDE3
Co-authored-by: Claude <noreply@anthropic.com>
1 parent dd98cba commit f192981
1 file changed
Lines changed: 70 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
10 | 31 | | |
11 | 32 | | |
12 | 33 | | |
| |||
18 | 39 | | |
19 | 40 | | |
20 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
21 | 58 | | |
22 | 59 | | |
23 | 60 | | |
| |||
41 | 78 | | |
42 | 79 | | |
43 | 80 | | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
44 | 86 | | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
51 | 105 | | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
0 commit comments