Repository navigation
refactor(objectql): facade ObjectRepository and ScopedContext in engine.ts with the codemod's second pass (body-identical; 20/24 methods) - #30264
Conversation
…dContext (#30052) Claude-Session: https://claude.ai/code/session_01Utp6Cbo4rDxRL3yugqM5c7 Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Utp6Cbo4rDxRL3yugqM5c7 Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Utp6Cbo4rDxRL3yugqM5c7 Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 1 package(s): 24 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 7 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 21 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 98bad9035bc8664662eea96a2d1e64deefa54c2d && git checkout 98bad9035bc8664662eea96a2d1e64deefa54c2d
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 31260ca8e446fa4fbe94ff8fd2a9030ddfb53a9a 8b84cef82a1f421776040e70dddc6ec36db58e85 && git checkout -B drift-repro 31260ca8e446fa4fbe94ff8fd2a9030ddfb53a9a && git merge --no-ff 8b84cef82a1f421776040e70dddc6ec36db58e85
node scripts/docs-audit/affected-docs.mjs --json 31260ca8e446fa4fbe94ff8fd2a9030ddfb53a9a
|
|
domain:server#3 · os-bill · session_01Utp6CbPxYq1wQmUNWvMZkC 席位核对ACCEPT · head
|
Requested by Bill · project thread
Fixes #30052
Clause-②: no
Metadata-protocol: none
维护者速读
scripts/codemod-split-engine.mjs加了第二遍--scoped,用同一套切法和证明把engine.ts里的ObjectRepository、ScopedContext门面化:24 个方法里 20 个方法体原样移进engine-object-repository.ts/engine-scoped-context.ts,每个实例一个 host(engine-scoped-hosts.ts)。生成物未手改。ObjectQL。engine.ts;公开.d.ts相等;objectql 测试 base 548 文件 / 10,863 = head;回滚就是 revert。engine-scoped-hosts.ts和两个类末尾的 static 块;③ 门禁check-facade-delegation-only改为一个文件可登记多个 facade 类。pnpm install --frozen-lockfile后运行node scripts/codemod-split-engine.mjs --scoped --verify --base 5fa9375e,应看到20/20 moved bodies identical、13587 -> 13522 lines,退出码 0;--self-test86 例通过。What changes
scripts/codemod-split-engine.mjs: a second pass,--scoped. It facades the two classesengine.tsdeclares afterObjectQL, with the first pass's cut pattern, stay rules and byte-identity proof, and touches no other byte.engine.tsthe first pass left (anymainafter Codemod split: generate the objectql engine.ts split with a deterministic script, verified byte-identical #29986) and is proved against that same file, so it is re-run on the latestmainat landing, never rebased. Its marker is[#30052 codemod], so the two passes' stubs and files are told apart.--scoped --verify --base <ref>re-proves the split on disk.SCOPED_CLASSES):engine-object-repository.ts(ObjectRepositoryFacet) andengine-scoped-context.ts(ScopedContextFacet), each a stateless class of static methods that are the bodies, unedited, withthistyped as aPickof the class's host interface (members typed AS the class members).engine-scoped-hosts.ts,InstanceHost<E, H>): refactor: compress the codemod facade stubs in engine.ts and protocol.ts — one shared host per facet instead of a per-call host literal (body-identical; about 1,000 lines off engine.ts) #30051's shape, keyed by the instance instead of the engine. Each class's static block installs its factory; a method goes as a closure called on the instance at call time (spies and overrides are still reached), a field as a getter, and a field a body assigns would also get a setter (no moved body assigns one). The module imports types only, so it forms no evaluation cycle.foreign-private: the body reads a private or protected instance member off another instance (legal in the class body, refused in a module function).private-static: the body reads a non-public static (the statics route isObjectQL's; the scoped classes declare none).already-movedrule. A method was taken for a hand-series stub when anengine-*import shares its name. It now also has to read that import.ObjectRepository#countand#executeshare names with the hand-seriescountandexecuteand read neither, so they move.c2d353d2with this script, it prints the same output tree sha256 as refactor(objectql): one shared host per facet in the engine.ts codemod stubs (body-identical; engine.ts 14,140 -> 13,548) #30083 (09c80319…e3554).--self-test: 86 cases in 7 batteries (was 68 in 6). The new battery "scoped classes (second pass)" (floor 16) covers the stay rules, the proof, determinism, the hosts and the refusals, and feeds the proof inputs it must refuse.--scoped --writeon main5fa9375e, unedited.What moved
ObjectRepositoryfind,findOne,insert,create,update,updateById,delete,deleteById,count,aggregate,executeScopedContextobject,sudo,withRunAs,releaseJoinedHandle,txDriver,beginTransaction,commitTransaction,rollbackTransaction,serveFormulaFieldPublic docblocks stay on the class (ruling 6624345766 item 1). The two private methods' docblocks (
releaseJoinedHandle,txDriver) moved with their bodies.Bodies that stay on the class (4, as #30019 exception rows)
ScopedContext.transaction(137 lines)this:callback(this, …)hands the instance onScopedContext.[SEED_USER_GRANTS](72)this(return this), and a symbol-keyed nameScopedContext.[APP_AUTHORED_HOOK_API](19)appAuthoredon another instanceScopedContext.derive(6)foreign-private: it writeschild.appAuthoredLine counts
5fa9375e)packages/objectql/src/engine.tsengine-object-repository.tsengine-scoped-context.tsengine-scoped-hosts.tsThe two classes were 696 lines. Most of what stays is docblocks on public members (they stay by ruling) and the four bodies above, so
engine.tsloses 65 lines: 155 body lines out, 80 stub lines in, plus the imports and the two install blocks.The #30019 gate (
check-facade-delegation-only)engine.tswas refused as "registered twice". Afacadesrow is now keyed by file and class. Anexceptionsrow may name itsclass, and must when its file registers more than one facade. The success line now counts classes and files.facadesrows (ObjectRepository,ScopedContext, card refactor: facade ObjectRepository and ScopedContext in engine.ts with the same codemod (about 700 lines), as the ObjectQL class already is #30052), the four exception rows above, and"class": "ObjectQL"added to the 30 existingengine.tsrows (their content is unchanged).--self-test: 37 cases (floor 36 → 37). New case E10: two facades in one file are each judged; a row without itsclassthere, aclassthat is not registered, and one class registered twice each go red.ObjectRepository13/13 members are delegations;ScopedContext17 delegations, 2 fields, 4 named exceptions;5 facade class(es) in 3 file(s) hold delegations only, 92 named exception(s).Readers of
engine.tsby pathEach one was run on this head and passed. None needed a change, because no moved body carries a site any of them counts:
federated-injected-column-readers.test.ts(in the suite below).second-object-read-exposure.pin.test.tsandrow-serving-door-exposure.pin.test.ts(7/7).check-system-context-census: OK, register unchanged.query-options/no-any-erasure(pnpm lint): exit 0.Verification
All at head
8b84cef8unless stated.node scripts/codemod-split-engine.mjs --scoped --verify --base 5fa9375e: exit 0. 20/20 moved bodies identical (body, parameters, return type, async). Every stub equals the generated one-call stub, the host module and both install blocks are the generated ones, and the undo rebuilds baseengine.tsbyte for byte (0 import bindings pruned).engine.ts 13587 -> 13522 lines.--scoped --writeruns from baseengine.ts(sha25683dfea29…2d774), one in a separate worktree, print the same output tree sha2563bbd66188e82e6a18a5b9f871a67b052f237e49e2ba2bd6f9d4f4d286d335a66. Both trees equal the committed head byte for byte..d.ts.packages/objectql/distbuilt at base5fa9375etwice and at head twice. Base 1 = base 2 and head 1 = head 2, byte for byte. Base against head:coreandindex(.d.tsand.d.mts) are byte-identical once the shared chunk's content hash in the import specifier is normalized.util-HASHhas 193/193 statements and 332/332 private members; its public surface (each class's private members removed with their docblocks) is EQUAL. The raw difference is the two moved private docblocks, 21 lines. None of the facet, host orInstanceHostnames appears in any.d.ts. Controls: a private member made public is caught, and a public return type changed is caught.test: base 548 files / 10,863 passed, head 548 / 10,863.test:repo: 1 file / 5 = 5. objectqltypecheck(tsc + check:test-typecheck): exit 0.npx turbo run build --concurrency=3exit 0.pnpm lintexit 0.node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstackderived 75 commands and each was run. All exit 0. One (check-plugin-teardown-shape --self-test) exited 3 on the first sweep because its pinned fixture commit was missing in the shallow clone; it passed aftergit fetch origin 621a4876….--ran: 75 derived, 75 run, 0 NOT-MEASURED, 0 UNRUN.codemod-split-engine.mjs --self-test(86 cases) andcheck-facade-delegation-only.mjs --self-test(37 cases).Acceptance notes
--verify --base c2d353d2no longer holds onmain, and that predates this PR. fix(objectql): a data driver receives the declared driver options and nothing else #30151, test: pin that a guest request reaches create hooks as a named caller #30179 and feat(objectql,cli): recompute stored home-currency amounts at the rates in force now, report first, rows without a rate listed and skipped (multi-currency M2-3) #30183 edited the split files by hand after refactor(objectql): one shared host per facet in the engine.ts codemod stubs (body-identical; engine.ts 14,140 -> 13,548) #30083. Onmain5fa9375eit already fails, athomeAmountReadsForandENGINE_DRIVER_PASSTHROUGH_KEYS. That is why the second pass proves against theengine.tsit reads and does not regenerate the first pass. Re-proving the first pass on today'smainwould need its own card. Carrier: the seat.patch,@objectstack/objectql) is included, following AGENTS.md checklist item 3 for a change to a released package. refactor(objectql): generate the engine.ts section split with a deterministic codemod #30012 and refactor(objectql): one shared host per facet in the engine.ts codemod stubs (body-identical; engine.ts 14,140 -> 13,548) #30083 shippedskip-changesetinstead.Human Minimum
packages/specholds no runtime logic. (not touched)pnpm lintpasses.main, one pull request. (the designated thread branch, as the Claim records)packages/spectouched: its generated artifacts are regenerated and committed. (not touched)content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.🤖 Generated with Claude Code
https://claude.ai/code/session_01Utp6Cbo4rDxRL3yugqM5c7