Repository navigation
Commit ddcdc80
<!-- claude-projects-attribution: {"github_login":"os-elon-musk"} -->
_Requested by **Elon** · [project
thread](https://claude.ai/code/project/chan_01WedDzV26nniwxv7jC88B9D?thread=cmsg_01WedDzV26nniwxv7jC88B9DBD7HivCp9UrtDXykvN12jC)_
domain:server#3 · os-elon-musk · session_016WV4d1YRzpYfqDDnUGmMWK
Refs #30020
Clause-②: no
Metadata-protocol: none
Skills-docs: none — an internal move inside `@objectstack/objectql`;
nothing a metadata author writes changes
## 维护者速读
- 改了什么:`scripts/codemod-split-engine.mjs`
的第四遍(`--members`)学会三条新规则:方法体里的裸 `this` 改读宿主的 `facade` 项(R1),`this[k]`
这类计算键在键都是字面字段名时经宿主读写(R3),`engine.ts` 已导出的名字(`ScopedContext`)从
`./engine.js` 导入(R4);新增第五遍
`--hand-slots`,把手写桩里会计算的宿主槽位搬进它的手写模块(H2)。随后用它把 `ObjectQL`
上八个把引擎本身传出去的方法体搬进各自的 facet,并删掉登记表里对应的八行例外(46 → 38)。这是 #30020 设计 §5
系列的第一个 PR(E1)。
- 为什么改:#30020 要把两个门面类上剩下的例外行换成委托。这八行被 codemod 以 `bare-this` 拒绝。Elon 于
2026-11-06 14:58Z 裁定规则 A:门面仍是唯一的状态持有者,宿主加一个 `facade` 端口,codemod
在逐字节撤销证明下把 `this` 改写为 `this.facade`。
- 风险与回滚:纯搬移,运行时行为不变。撤销证明仍是逐字节比较,不做任何空白或 import 归一化;两遍各有自己的撤销证明。`.d.ts`
的成员行不变,五个私有方法的 docblock 跟着方法体走,所以共享声明块少了这五段注释。回滚即 revert 本 PR。
- 先看:`scripts/codemod-split-engine.mjs` 的 `identityBodyText` /
`identityUndoText`、`literalFieldKeys`、`importsEngineValues`、`runStyles`
和 `generateHandSlots` /
`undoHandSlots`;`packages/objectql/src/engine-defaults-and-autonumbers.ts`
的模块头和 import 块。
- 两分钟验证:`node scripts/codemod-split-engine.mjs --self-test` 预期 169 cases
in 11 batteries pass;`node scripts/check-facade-delegation-only.mjs` 预期
38 named exception(s)。
- 需要你做的:无,席位落地。
## What changes
- **`scripts/codemod-split-engine.mjs`, fourth pass (`--members`), three
rules (#30020 design §3):**
- **R1, the identity port.** A moved body that reads a bare `this`
(handing the engine on: `bindHooksToEngine(this, …)`, `new
ScopedContext(ctx, this)`) now reads `this.facade`, and the pass adds a
`facade: engine` entry to the host interface and its install line. The
undo turns `this.facade` back into `this` and drops the entry. `typeof
this` in a type position stays as written (`this-type`), since it is a
type query, not the value. The first and scoped passes are unchanged and
still refuse `bare-this`.
- **R3, computed field keys.** `this[k]` where every value `k` can take
is a literal field name (`readMigrationFlagRowMemoized`'s cache slots)
reads and writes those fields through host getters and setters, the same
way a named field does.
- **R4, a name `engine.ts` exports.** `createContext` and `buildHookApi`
construct `ScopedContext`, which `engine.ts` exports. The receiving
module imports it from `./engine.js` (the cycle is the one the module
header already names for values), and the header's import paragraph
switches from the types-only sentence to the values one; the undo
switches it back. Refused in a routed module.
- **Hand-grown import lines.** `engine-security-resolvers.ts` carries an
import line #30227 grew past the wrap width. `runStyles` reads each
statement's form (wrapped or one line) and the move and the undo both
keep it, so the proof stays byte for byte.
- **`scripts/codemod-split-engine.mjs`, fifth pass (`--hand-slots STUB`,
H2).** A hand-written stub whose host literal carries a slot that
computes (an arrow with a body, not a forwarder) has that slot moved
into the stub's hand module as `export const SLOT: HOST['SLOT'] =
ARROW;`, one indentation level out, so its contextual types are
unchanged; the slot becomes the shorthand `SLOT,`. It has its own undo
proof, against the tree `--members` left. Used once here:
`serveReferenceNames`' `formulaReadsReference` slot moves into
`engine-reference-name-visible.ts`.
- **The eight moves** (E1 of the design's §5 series), written by the
codemod on the latest `main`:
- `bindHooks` into `engine-hooks-and-functions.ts`;
- `resolveReadableIdsSecurity` into `engine-security-resolvers.ts`;
- `buildHookApi` into `engine-defaults-and-autonumbers.ts`;
- `readMigrationFlagRowMemoized` into `engine-migration-state.ts` (R3);
- `recomputeSummaries` into `engine-summaries-and-expansion.ts`;
- `ownershipQueueService` into `engine-insert.ts`;
- `createContext` into `engine-compatibility-section.ts`;
- `serveReferenceNames`' slot into `engine-reference-name-visible.ts`
(fifth pass).
The stubs, facet members, host interfaces, host factories and imports
are the passes' own output. `engine.ts` goes from 11,153 to 10,977
lines.
- **`scripts/facade-delegation-registry.json`**: the eight `#30020` rows
for these members are removed; `check:facade-delegation-only` is green
with 38 named exceptions (46 on `main`).
- **`.changeset/30020-objectql-identity-port-bodies.md`**:
`@objectstack/objectql` patch, following #30571 / #30716 (source maps
ship).
## Tests
The codemod's self-test (`node scripts/codemod-split-engine.mjs
--self-test`): 169 cases in 11 batteries pass. Two batteries are new,
each floor pinned at its case count:
1. **identity port, computed keys and exported names (fourth pass,
#30020)**, 23 cases:
- the moves prove, and two runs write byte-identical trees;
- R1 rewrites each bare `this` (an object-literal method keeps its own)
and adds the host's identity port under its docblock;
- R3 reads a computed key over field names through the host and adds a
setter for a key the body assigns through;
- R4 imports an exported class from `engine.ts` and switches the header;
- a key of any string or over a method name, and `this` in a type
position, stay;
- refusals: a staying name `engine.ts` does not export, a body that
already reads `this.facade`, a class that declares `facade`;
- failures: a `this.facade` the rewrite did not write, a site put back
to a bare `this`, a factory that does not hand the engine, a port
without its docblock, a header left saying "types only";
- a leaf import a hand grew on one line reads as `line` and stays on one
line when a move adds a name; the first pass's wrapped form reads as
`wrap`; a statement in neither form reads as null.
2. **hand-series host slots (fifth pass, #30020)**, 17 cases:
- the plan names the stub's one computing slot; the move proves; two
runs write byte-identical trees;
- the slot names its const, the hand module holds the arrow one level
out under its docblock with the imports it reads, and `engine.ts` drops
an import only the slot read;
- failures: one edited character in the arrow, an edited docblock, an
import binding nothing reads, an `engine.ts` that kept the slot's
import, a head that moved nothing;
- refusals: a slot that reads the stub's `this` or a local, a stub whose
slots all forward, a slot holding a multi-line template, a method that
is not a hand stub.
<details><summary>Reverse verification (one-time, run on the committed
change, restored to the HEAD blob)</summary>
Each ablation went red, then `git checkout HEAD --
scripts/codemod-split-engine.mjs` and `git status --porcelain` came back
empty:
- the members undo without the identity inverse;
- the identity port turned off (the real tree refuses `bare-this`
again);
- `runStyles` with no `line` form (the `engine-security-resolvers.ts`
move refuses at its import block, and the new one-line case goes red);
- the hand-slots undo with no re-indent.
</details>
## Verification
The final head merges `origin/main` `1b3e22f0`. `engine.ts` is unchanged
between that `main` and the previous merge (`ae82d057`, after #30780 and
#30800); `packages/objectql` moved (#30836's bare-name module,
`registry.ts`). The moves were regenerated on `1b3e22f0` and compared
with the head, not text-merged.
- Regeneration, with the two proofs chained: on a clean `1b3e22f0` tree,
`--members
bindHooks,resolveReadableIdsSecurity,buildHookApi,readMigrationFlagRowMemoized,recomputeSummaries,ownershipQueueService,createContext
--write`, then `--members --verify --base origin/main` (exit 0: "7 moved
method(s) …; engine.ts 11153 -> 10985 lines; undoing the moves does
rebuild the base engine.ts and its modules byte-for-byte once the 6
import binding(s) only moved bodies read are pruned from the base").
That tree was recorded as a scratch commit; `--hand-slots
serveReferenceNames --write`, then `--hand-slots --verify --base <that
commit>` (exit 0: "1 moved (serveReferenceNames#formulaReadsReference);
engine.ts 10985 -> 10977 lines; undoing the moves does rebuild the base
engine.ts and its hand modules byte-for-byte once the 1 import
binding(s) only moved slots read are pruned from the base
(formulaPlanEntry)"). The result equals the head's nine
`packages/objectql/src` files byte for byte. The registry's delta
against `main` is exactly the eight `#30020` rows removed, none added.
- Public `.d.ts` for `@objectstack/objectql`: built at base `1b3e22f0`
and at head. With the shared chunk's hash normalised (`util-XXXXXXXX`),
`dist/index.d.ts` and `dist/core.d.ts` are byte-equal (sha256
`584d6d85…`, `c48657f3…` on both sides). The shared chunk goes from
10,030 to 9,947 lines: the 83 lines are the five private methods'
docblocks, in five hunks, all deletions; no other line differs. Control:
`SecurityResolversFacet.resolveReadableIdsSecurity` occurs 0 times in
the base `dist/index.js` and once in the head's.
- After `pnpm install --frozen-lockfile && pnpm build` on the merged
head: `pnpm --filter @objectstack/objectql typecheck` exit 0 (including
`check:test-typecheck`); `pnpm --filter @objectstack/objectql test` 559
files, 11,200 tests passed; `pnpm --filter @objectstack/spec
check:generated` all 14 artifacts up to date (with
`NODE_OPTIONS=--max-old-space-size=8192`: its `check:test-typecheck`
runs out of heap at the default 2 GB here; this PR does not touch
`packages/spec`).
- `node scripts/pm/dispatch-gates.mjs --commands`: 74 families derived
at head `923ebb82`; all 74 exit 0, including `pnpm
check:dual-build-cjs-loads` (every package's `dist/` was built this
time). `--ran`: 74 derived, 74 run, 0 NOT-MEASURED, 0 UNRUN. The
codemod's and the facade gate's self-tests, `pnpm --filter
@objectstack/spec check:liveness`, `pnpm check:adr-anchors` and eslint
over the changed files are outside the derived set and were run
separately, exit 0.
## Acceptance notes
- **Rule A**, Elon's ruling on #30020 (2026-11-06 14:58Z, forwarded by
the seat): the facade stays the one owner of state; hosts gain a
`facade` port, and the codemod rewrites `this` to `this.facade` under
the byte-exact undo. A facet declares and reaches the state it needs
through its host. No field moves.
- **Series:** this is E1 of the design's §5 order. E2 (`find`,
`findOne`) waits for this PR to land.
- **R7 is deferred to E6**, its only caller (`update`, which starts
`engine-update.ts`). Shipping it here would leave a rule with no caller.
- **`.d.ts` is not byte-equal**: the five private methods' docblocks
moved with their bodies (the first pass's docblock rule), so the shared
declaration chunk loses those docblocks. No member line changes. The
design's "byte-equal" expectation was too strong.
- Surface widened by the seat for this card:
`scripts/codemod-split-engine.mjs`. This PR touches no
`packages/spec/liveness/*.json` and no `system-context.mdx` register.
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
(Not touched.)
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` is CI's run.
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset.
- [x] 6. `packages/spec` touched: its generated artifacts are
regenerated and committed. (Not touched.)
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English (the 维护者速读 block is the
lane's maintainer summary).
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.
---
_Generated by [Claude
Code](https://claude.ai/code/session_016WV4d1YRzpYfqDDnUGmMWK)_
---------
Co-authored-by: Claude <noreply@anthropic.com>
1 parent e7ce606 commit ddcdc80
12 files changed
Lines changed: 1279 additions & 327 deletions
File tree
- .changeset
- packages/objectql/src
- scripts
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
37 | 40 | | |
38 | | - | |
| 41 | + | |
39 | 42 | | |
40 | 43 | | |
41 | 44 | | |
| |||
48 | 51 | | |
49 | 52 | | |
50 | 53 | | |
| 54 | + | |
| 55 | + | |
51 | 56 | | |
52 | 57 | | |
53 | 58 | | |
| |||
113 | 118 | | |
114 | 119 | | |
115 | 120 | | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
116 | 133 | | |
117 | 134 | | |
118 | 135 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
32 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
33 | 35 | | |
34 | 36 | | |
35 | 37 | | |
36 | 38 | | |
| 39 | + | |
37 | 40 | | |
38 | 41 | | |
39 | 42 | | |
| |||
46 | 49 | | |
47 | 50 | | |
48 | 51 | | |
| 52 | + | |
49 | 53 | | |
50 | 54 | | |
51 | 55 | | |
| |||
61 | 65 | | |
62 | 66 | | |
63 | 67 | | |
| 68 | + | |
| 69 | + | |
64 | 70 | | |
65 | 71 | | |
66 | 72 | | |
| |||
189 | 195 | | |
190 | 196 | | |
191 | 197 | | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
192 | 209 | | |
193 | 210 | | |
194 | 211 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
| 46 | + | |
45 | 47 | | |
46 | 48 | | |
47 | 49 | | |
| |||
61 | 63 | | |
62 | 64 | | |
63 | 65 | | |
| 66 | + | |
| 67 | + | |
64 | 68 | | |
65 | 69 | | |
66 | 70 | | |
| |||
229 | 233 | | |
230 | 234 | | |
231 | 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 | + | |
232 | 263 | | |
233 | 264 | | |
234 | 265 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | | - | |
| 6 | + | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
| 37 | + | |
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
| |||
55 | 56 | | |
56 | 57 | | |
57 | 58 | | |
| 59 | + | |
| 60 | + | |
58 | 61 | | |
59 | 62 | | |
60 | 63 | | |
| |||
180 | 183 | | |
181 | 184 | | |
182 | 185 | | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
183 | 201 | | |
184 | 202 | | |
185 | 203 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
| 49 | + | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| 78 | + | |
78 | 79 | | |
79 | 80 | | |
80 | 81 | | |
| |||
195 | 196 | | |
196 | 197 | | |
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 | + | |
198 | 223 | | |
199 | 224 | | |
200 | 225 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| 81 | + | |
81 | 82 | | |
82 | 83 | | |
83 | 84 | | |
| |||
263 | 264 | | |
264 | 265 | | |
265 | 266 | | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
0 commit comments