Skip to content

feat(objectql,runtime): 默认 runner setter 改为 first-wins —— 私有字段探测全数退场 (#4251) - #4398

Merged
os-zhuang merged 1 commit into
mainfrom
claude/4251-runner-first-wins
Jul 31, 2026
Merged

feat(objectql,runtime): 默认 runner setter 改为 first-wins —— 私有字段探测全数退场 (#4251)#4398
os-zhuang merged 1 commit into
mainfrom
claude/4251-runner-first-wins

Conversation

@os-zhuang

Copy link
Copy Markdown
Contributor

决策 memo 的 2:runner 幂等收编进引擎。

变更

setDefaultBodyRunner / setDefaultActionRunner 现在自己执行自己文档里写的契约("the runtime layer sets this once per engine")——first-wins:保留第一个,后续调用忽略并返回 false。配上公开访问器 getDefaultBodyRunner() / getDefaultActionRunner(),字段从 (this as any)._defaultBodyRunner 挂载变成真正的 private 成员。

之前的形状,以及为什么它值得修

不变量住在调用方:AppPlugin 靠 any 探引擎私有字段来避免共享 kernel 上互相覆盖 —— 人人持有、无人执行;字段一改名,守卫静默恒 undefined,每个 AppPlugin 都重装。而且读这两个字段的不止它:引擎自己的 bindHooks fallback、ObjectQLPlugin 的 authored-action re-sync,三处同样的 as any 私有伸手。三处现在全走公开访问器;全仓剩下的 _default* 只在注释和 test double 里。

改语义前做了调用方审计:每个 setter 调用点要么持有 fresh engine(sandbox / hook-binder 测试),要么要的恰是 keep-the-first(AppPlugin)—— 没有任何人需要在活引擎上替换 runner。void → boolean 是增量;AppPlugin 用返回值让 "Installed default … runner" 日志保持真实(引擎保留了先前的就不再打)。

测试

  • hook-binder 测试钉住:第二次安装被拒且端到端验证第一个 runner 才是执行的那个;访问器暴露被保留的实例。
  • app-plugin 那条钉住旧调用方守卫的测试,改钉新分工:setter 无条件被调,引擎答 false 时日志跳过。
  • mock 双方(plugin-authored-actions)补 getDefaultActionRunner(),原有直接戳字段的用法保留可用。

验证过程里的两个插曲(如实记录)

  1. 一度以为 main 红了:objectql 22 个 REST 读路径:searchFields / groupBy / aggregations 指向不存在的字段时被静默降级(#4226 收口后剩下的三条轴) #4254 conformance 测试在 clean HEAD 上也失败。二分到三个 commit 后发现是本地 metadata-protocol dist 过期(测试经它的 dist 走 list path,而该包在本 worktree 从未重建)—— 重建后 89/89 绿。main 没红,是我的误报。
  2. 一次 6 文件 FAIL 是本地 vitest 并发抖动(与 spec dts build 并行跑了测试,违反了自己记过的规矩);单文件与串行复跑全绿。

验证

  • objectql 1464 / 89runtime 1001 / 69(串行)
  • objectql + runtime dts build 通过
  • eslint 干净;ratchet 168/36, none new

🤖 Generated with Claude Code

…ivate-field probes are gone (#4251)

setDefaultBodyRunner / setDefaultActionRunner now enforce their own
documented contract -- "the runtime layer sets this once per engine" -- by
keeping the first runner and returning false for any later call. Public
accessors getDefaultBodyRunner() / getDefaultActionRunner() join them, and
the fields become real private members instead of `(this as any)`
attachments.

Before this the invariant lived in the CALLERS: AppPlugin probed the
engine's private _defaultBodyRunner / _defaultActionRunner fields through
`any` to avoid clobbering another AppPlugin's runner on a shared kernel --
an invariant owned by every caller and enforced by none, and a private
reach a field rename would have broken silently. The engine's own
bindHooks fallback and ObjectQLPlugin's authored-action re-sync read the
same fields the same way. All three read the public accessors now; the
only remaining `_default*` mentions are comments and test doubles.

Caller audit before changing semantics: every setter call site either
owns a fresh engine (sandbox + hook-binder tests) or wants exactly
keep-the-first (AppPlugin) -- nobody replaces a runner on a live engine.
void -> boolean is additive; AppPlugin uses it to keep its "Installed
default ... runner" log truthful.

Pinned in hook-binder tests: a second install is refused end-to-end (the
first runner is the one that executes) and the accessors expose what was
kept. The app-plugin test that pinned the caller-side guard now pins the
new division: setter called unconditionally, log skipped when the engine
answers false.

Verified: objectql 1464/89, runtime 1001/69 (serial runs; an earlier
6-file cloud-connection FAIL was local vitest concurrency noise beside a
parallel spec dts build -- single-file and serial reruns green, and the
"22 failures on clean HEAD" scare was a stale metadata-protocol dist, NOT
a main regression); objectql + runtime dts builds; eslint clean; ratchet
holds 168/36 none new.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 31, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
objectstack Ignored Ignored Jul 31, 2026 11:03am

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 2 package(s): @objectstack/objectql, @objectstack/runtime.

27 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:

  • content/docs/api/client-sdk.mdx (via packages/runtime)
  • content/docs/api/index.mdx (via @objectstack/runtime)
  • content/docs/api/wire-format.mdx (via @objectstack/runtime)
  • content/docs/automation/hook-bodies.mdx (via @objectstack/runtime)
  • content/docs/concepts/metadata-lifecycle.mdx (via @objectstack/objectql, @objectstack/runtime)
  • content/docs/concepts/north-star.mdx (via packages/runtime)
  • content/docs/data-modeling/drivers.mdx (via @objectstack/runtime)
  • content/docs/data-modeling/formulas.mdx (via packages/objectql)
  • content/docs/deployment/index.mdx (via @objectstack/runtime)
  • content/docs/deployment/migration-from-objectql.mdx (via @objectstack/objectql)
  • content/docs/deployment/production-readiness.mdx (via @objectstack/runtime)
  • content/docs/deployment/single-project-mode.mdx (via @objectstack/runtime)
  • content/docs/deployment/vercel.mdx (via @objectstack/objectql, @objectstack/runtime)
  • content/docs/getting-started/your-first-project.mdx (via @objectstack/runtime)
  • content/docs/kernel/cluster.mdx (via @objectstack/runtime)
  • content/docs/kernel/services-checklist.mdx (via @objectstack/objectql)
  • content/docs/kernel/services.mdx (via @objectstack/objectql)
  • content/docs/permissions/authentication.mdx (via @objectstack/objectql, @objectstack/runtime)
  • content/docs/permissions/authorization.mdx (via packages/runtime)
  • content/docs/plugins/index.mdx (via @objectstack/objectql)
  • content/docs/plugins/packages.mdx (via @objectstack/objectql, @objectstack/runtime)
  • content/docs/protocol/kernel/http-protocol.mdx (via @objectstack/runtime)
  • content/docs/protocol/kernel/index.mdx (via @objectstack/objectql, @objectstack/runtime)
  • content/docs/protocol/kernel/lifecycle.mdx (via @objectstack/runtime)
  • content/docs/protocol/objectql/query-syntax.mdx (via packages/objectql)
  • content/docs/protocol/objectql/state-machine.mdx (via @objectstack/objectql)
  • content/docs/releases/implementation-status.mdx (via @objectstack/objectql, @objectstack/runtime)

Advisory only. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs origin/main → pass the list as args.docs.

@github-actions github-actions Bot added documentation Improvements or additions to documentation tests tooling size/m labels Jul 31, 2026
@os-zhuang
os-zhuang merged commit 5c13368 into main Jul 31, 2026
17 checks passed
@os-zhuang
os-zhuang deleted the claude/4251-runner-first-wins branch July 31, 2026 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tests tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant