Repository navigation
Commit 391d748
refactor(objectql): ObjectQL#delete's body moves into its facet (codemod R10 puts the module on the statics route) (#31764)
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9KX9KQPGPGgUsuSjbwJeH77)_
Refs #30020
Clause-②: no
Metadata-protocol: none
## 维护者速读
- **改了什么**:把查询引擎 `ObjectQL` 里 `delete`(删除记录)的方法体原封不动地搬进同一节的 facet 模块
`engine-delete-and-aggregate.ts`,类上只留一行转调;搬移工具 codemod
补了一条把模块切到“静态成员转发”路线的规则(R10),并删掉门禁登记表里 `delete` 这一行例外。
- **为什么改**:#30020 拆分大文件 `engine.ts` 的既定顺序第五步(E4)。`delete`
体里读了一个私有静态常量,目标模块原先不走静态转发路线,工具拒绝搬;补上 R10 后由工具确定性生成,不手搬。
- **风险与回滚**:纯搬移:发布的 `.d.ts` 逐字节不变,同样的语句按同样顺序执行;undo 证明逐字节还原
base。风险在删除路径(级联、回收站)全部经过它,dogfood 全量已跑绿。回滚即整体 revert。
- **先看**:① `packages/objectql/src/engine-delete-and-aggregate.ts` 文件头的
import 对和 host 接口(R10 的改写)② `scripts/codemod-split-engine.mjs` 的
`rerouteModule` / `unrouteModule` ③
`scripts/measure-durability-swallow-family.mjs` 改指向的那一条解析控制。
- **两分钟验证**:`node scripts/codemod-split-engine.mjs --members --verify
--base $(git merge-base origin/main HEAD)`,预期打印 `undoing the moves does
rebuild the base engine.ts and its modules byte-for-byte`,退出码 0。
- **需要你做的**:无,席位落地。
## What changes
- **`ObjectQL#delete` moves into its facet**
(`packages/objectql/src/engine.ts` → `engine-delete-and-aggregate.ts`),
generated by `node scripts/codemod-split-engine.mjs --members delete
--write` on `main` `90cea476` (after #31702 landed, so its by-id
withdrawal moves with the body). The stub keeps its docblock and
signature (`async` dropped, as every stub of the series). The one bare
`this` the body hands on, `ql: this` in the hook context, reads `ql:
this.facade` (rule R1). The body's one static read,
`ObjectQL.REFERENCE_PROBE_BATCH`, goes through the `ObjectQLStatics`
forwarder that already carries it for `engine-cascade-planning.ts`.
`engine.ts` 10653 → 9943 lines; 12 import bindings only the moved body
read are pruned from it.
- **Codemod: R10, the statics route for a written module**
(`scripts/codemod-split-engine.mjs`). On `main` the fourth pass refused
this move: `delete reads statics of ObjectQL, and
engine-delete-and-aggregate.ts does not take the statics route: this
pass does not reroute a module`. Now a mover that reads a non-public
static puts a module the first pass wrote off the route onto it, exactly
as the first pass writes a routed module: the one `import type {
ObjectQL }` line becomes the routed pair (`ObjectQLStatics` AS
`ObjectQL`, the class as `ObjectQLClass`), the host interface types its
members by `ObjectQLClass`, and the header gains the statics paragraph
(now one constant, `STATICS_PARA`, shared with the first pass's writer).
It refuses any module that is not the first pass's unrouted shape, and
one whose code names `ObjectQL` anywhere else (static-route-conflict).
The undo (`unrouteModule`) is the inverse rewrite, applied to the head
before the moved members come out. It runs only where the base module
was off the route and a moved member reads a static, and it fails a kept
member that reads one. Separately, the proof now fails a moved member
that reads a static in a module left off the route. Before this change
that case passed the undo proof while the module could not compile. A
public-only static reader still refuses, as before.
- **`scripts/facade-delegation-registry.json`**: the `ObjectQL` ·
`delete` row (#30020, bare-this) leaves; no other row moves.
`check:facade-delegation-only` 9 → 8 named exceptions.
- **`scripts/measure-durability-swallow-family.mjs`** (one control, seat
ruling A, claim amended): the `delete` RESOLUTION control pinned
`engine.ts` · `ObjectQL` · `this.delete()`, whose only call site was the
after-abort re-entry inside the moved body. With the body moved, the
control matched nothing and `pnpm check:swallow-census-controls` went
red (`resolution control matched NO call site`). The control now pins
the same re-entry where it moved: `engine-delete-and-aggregate.ts` ·
`DeleteAndAggregateFacet` · `delete` → `DeleteAndAggregateFacet`.
Measured with the real resolver on the moved tree: this site resolves to
the facet's own `delete` body (the body the host's `delete` stub
reaches). The cascade re-entry in `engine-cascade-planning.ts` resolves
to REFUSAL (no same-file body). The `engine.ts` cross-class collision
stays pinned by the `update` and `transaction` controls.
- **Changeset** `.changeset/30020-objectql-delete-facet.md`,
`@objectstack/objectql` patch. The delta allowed `skip-changeset` when
the `.d.ts` diff is empty, but the published JS changes (positive
control below), and AGENTS.md reserves `skip-changeset` for a diff that
publishes nothing. This is the S1 / E2 precedent.
## Tests
- New self-test battery `statics route for a written module (fourth
pass, #30020 R10)`, 18 cases, floor 18. It runs on the identity fixture
with a `staticReader` method the first pass keeps (bare-this) in a
section it writes off the route. The cases cover: the reroute plan; the
proof; determinism; the routed import pair; the interface alias,
including the identity port; the statics paragraph in place;
reroute/unroute as inverses; five failing heads (paragraph missing,
wrong import pair, a member typed by the class itself, a reroute no
moved member needs, a static read left off the route); and four refusals
(static-route-conflict, R4 into a rerouted module, another `./engine.js`
shape, an already-routed module).
- No existing test edited. No forced test edit.
<details><summary>Ablations (each red, then restored: blob == HEAD, `git
diff HEAD` empty)</summary>
Via `node scripts/ablation-replace.mjs --file
scripts/codemod-split-engine.mjs … -- node
scripts/codemod-split-engine.mjs --self-test`, on head:
| Mutation | Red cases |
|:--|:--|
| R10 off (`generateMembers` does not reroute) | 7, incl. `the generated
move proves against its base — engine-identity.ts: a member this pass
moved reads a static, and the module is off the statics route (R10)` |
| undo guard off (a reroute no moved member needs) | 1: `a module
rerouted though no member the pass moved reads a static fails` |
| static-route-conflict check off | 1: `a module whose code names
ObjectQL outside its import and host interface refuses the route` |
| off-route static read check off | 1: `a moved member that reads a
static in a module left off the route fails` |
The swallow-census control was red against the moved tree before the
re-point (`matched NO call site`) and green after.
</details>
## Acceptance notes
- The `.d.ts` proof bar holds. The JS changes, as for every series PR:
`DeleteAndAggregateFacet.delete` occurs 0× in base `dist/index.mjs` and
1× in head (positive control).
- `ObjectQL#update` and `#insert` still carry their registry rows (E5,
E6). Their own re-entries will meet the same census control shape when
E6 moves `update`.
- Open questions to the seat are in the report: the R10 rule name and
its refusals.
## Verification
All readings through `scripts/pm/os-verify-lock.sh` (`VERDICT
command-exit 0` each), base `90cea476`, head as noted.
| Run | Base | Head |
|:--|:--|:--|
| `node scripts/codemod-split-engine.mjs --members --verify --base
90cea47` | — | exit 0; 1 moved (`delete`), byte-exact, 12 bindings
pruned |
| codemod `--self-test` | 211 cases / 13 batteries | 229 cases / 14
batteries |
| `pnpm check:facade-delegation-only` | 9 exceptions | 8 exceptions |
| `pnpm --filter @objectstack/objectql typecheck` | — | exit 0 |
| `pnpm --filter @objectstack/objectql test` | 574 files / 11711 tests |
574 files / 11711 tests |
| objectql `dist` `.d.ts` (`core.d.ts`, `core.d.mts`, `index.d.ts`,
`index.d.mts`) | — | byte-identical to base (`cmp`) |
| `pnpm --filter @objectstack/dogfood test` (full, no shard, head
`5cf3f796`) | — | 440 passed, 3 skipped files / 3652 passed, 41 skipped
tests |
| `eslint --no-inline-config packages/objectql` + both scripts (objectql
has no `lint` script) | — | exit 0 |
<details><summary>Derived gates: 83 / 83 on head 2a5a3a3,
reconciled</summary>
`node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` at `2a5a3a3d` derived 83 commands; all 83
run after a full `pnpm build` (lock VERDICT exit 0), each exit 0.
`--ran`: "83 derived famil(ies) accounted for — 83 run, 0 NOT-MEASURED
(a DERIVED zero)". On the first round (head `5cf3f796`, before the
control re-point) three gates exited 3 on container prerequisites, not
findings: `check-plugin-teardown-shape --self-test` (shallow clone;
fixture commit fetched), `check:dual-build-cjs-loads` and
`check:published-readme-exports` (no full build yet). One was a real
red, `check:swallow-census-controls`, fixed by the control re-point
above. Extra: `src/http-dispatcher.keys.test.ts` in runtime (names the
census script) 20/20; census `--self-test` (every family) exit 0.
</details>
`test:repo` was not run locally (no diff in that project); CI's Test
Core carries it.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01ADHkmNmrFUKGH6LP8Jj8ZV)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 8dbb4a1 commit 391d748
6 files changed
Lines changed: 1158 additions & 802 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 | + | |
0 commit comments