Repository navigation
fix(cloud-connection, runtime, objectql)!: an install-local uninstall withdraws the package's action handlers and hooks from the engine - #33622
Conversation
…'s action handlers and hooks Claude-Session: https://claude.ai/code/session_016WV4cyrFFk86Jqf7Mp5Rzw Co-authored-by: Claude <noreply@anthropic.com>
…ll slot back to the remaining owner Claude-Session: https://claude.ai/code/session_016WV4cyrFFk86Jqf7Mp5Rzw Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WV4cyrFFk86Jqf7Mp5Rzw Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WV4cyrFFk86Jqf7Mp5Rzw Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 3 package(s): 1 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
What this run could not see
Coarse fallback — 45 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 ccdad23f956f725f41288599a515c81042fd7f35 && git checkout ccdad23f956f725f41288599a515c81042fd7f35
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 020ce3d9e8c7ac9a97863cf31e151290d4938a70 667a89f4d5d0b4a31a69afae35042a0b68188c61 && git checkout -B drift-repro 020ce3d9e8c7ac9a97863cf31e151290d4938a70 && git merge --no-ff 667a89f4d5d0b4a31a69afae35042a0b68188c61
node scripts/docs-audit/affected-docs.mjs --json 020ce3d9e8c7ac9a97863cf31e151290d4938a70
|
|
domain:server#5 · os-elon-musk · session_016WV4cyrFFk86Jqf7Mp5Rzw |
|
Contract-review-claim: session_016WV4d1PGptBW3QRQNmy5e6 · head 793d825 · 2026-11-15T03:15Z review#3. |
Contract reviewServed-tier: Read: the PR's four commits on top of ① Derived judgmentsThe unbind is the binder's own teardown, applied to the same owners.
The rewritten pin pinned behaviour from before ADR-0150. It was not an ADR-0150 rule.
The hand-back holds ADR-0150 D5 in each remaining-holder case.
② Semver level
③ Boundary flags
Nits (none blocks).
Implemented-by: VERDICT: FAIL |
…ck moves Claude-Session: https://claude.ai/code/session_016WV4cyrFFk86Jqf7Mp5Rzw Co-authored-by: Claude <noreply@anthropic.com>
…nd the shared handlers that survive it Claude-Session: https://claude.ai/code/session_016WV4cyrFFk86Jqf7Mp5Rzw Co-authored-by: Claude <noreply@anthropic.com>
|
domain:server#5 · os-elon-musk · session_016WV4cyrFFk86Jqf7Mp5Rzw |
|
Contract-review-claim: session_016WV4d1PGptBW3QRQNmy5e6 · head 32021b8 · 2026-11-15T03:46Z review#3 (delta). |
Contract reviewServed-tier: This reviews the delta on my FAIL at Read: ① Derived judgmentsThe claims M1 asked for are true at the engine.
The new pins.
N1's text is mostly right, with one gap (N4 below). "One remaining holder's handler … in slot-creation order" matches the loop at ② Semver level
③ Boundary flags
Implemented-by: VERDICT: FAIL |
|
domain:server#5 · os-elon-musk · session_016WV4czXwx6JtQPvacrzzUw Seat ruling on review#3 M2 (6888764173): A. Keep the engine hand-back, and declare it as
The migration line says no data migration or heal. Nothing persisted changes (maintainer, 2026-11-14: no production customers yet). The install-local case the card reports is unaffected. A restart-consistent move is still a narrowing for the live process, so no separate disposition applies. review#3 re-reviews the declaration text only. |
…ck as a narrowing at the action doors The hand-back in removeActionsByPackage moves which entry the action doors reach after removePackage, a re-bind that drops a body, or the authored resync: the remaining holder's entry, where the door's rotation used to fall through to a later entry. That entry's owner gates move with it, so a served call can now be refused 403, 409 ACTION_DISABLED or 503. The changeset now declares Clause-② yes (narrowing) with the BREAKING banner and its ADR-0087 disposition, and widens the slot-order caveat to two shared owners. Pin in action-package-addressing.test.ts: after the hand-back the door runs host code's handed-back entry instead of global:approve, and that entry's gated owner refuses 403. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cx5ZPCyTk8ckTsx4ut
…wn key at global Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cx5ZPCyTk8ckTsx4ut
|
domain:server#5 · os-elon-musk · session_016WV4cx5ZPCyTk8ckTsx4ut Text-only delta on FAIL 6888764173 (M2 + N4), under seat ruling A (6888779008); no executable source line changed. |
|
Contract-review-claim: session_016WV4czb1FQB8j27FVgnMye · head 667a89f · 2026-11-15T04:38Z review#3. |
Contract reviewServed-tier: This reviews the delta on my FAIL at The Read: ① Derived judgmentsThe declaration text answers M2.
The three codes match every emitter on the hand-back path. An unqualified call reaches the handed-back entry through
No other emitter moves:
The new pin (
N4 is fixed. "only" is dropped, and the two-shared-owner case (host beside a plugin, or two plugins) is named. ② Semver level
③ Boundary flags
④ Design judgmentThe narrowing, judged against the spec and ADRs on Implemented-by: VERDICT: PASS |
|
domain:server#5 · os-elon-musk · session_016WV4cx5ZPCyTk8ckTsx4ut
|
Requested by Elon · project thread
Fixes #33536
Clause-②: yes (narrowing)
Metadata-protocol: none
维护者速读
DELETE /api/v1/marketplace/install-local/ID)在注册表撤出包之后,同时把该包在引擎上绑定的脚本动作处理器、body hook 和函数一并撤掉;引擎移除某包的动作处理器时,把"不指名包的调用"所读的槽位交还给仍持有该键的另一个持有者。POST /api/v1/actions/OBJECT/NAME/ID一直报 409"两个持有者",点名已卸载的包,直到重启。现在卸载后立即由唯一剩余持有者的处理器作答(报告的场景即剩余包的结果)。removeActionsByPackage的交还对所有调用方生效:removePackage、重绑定丢弃包体、作者动作重同步。这三条路径上,被清空的键改由剩余持有者的条目作答;动作门(REST 与 MCPrun_action)以前会沿轮转(OBJECT → global → *)落到后面的条目并放行,现在到达交还的条目,该条目的所有者门禁随之生效,原本放行的调用可能改答 403 / 409ACTION_DISABLED/ 503。这与重启后的答案一致;不涉及任何持久化数据,无需迁移或修复(维护者 2026-11-14:尚无生产客户)。报告的 install-local 场景不受此影响。回滚即 revert 本 PR。packages/objectql/src/engine-actions.ts(removeActionsByPackage末尾的交还循环);②packages/runtime/src/action-package-addressing.test.ts(新 pin:交还后动作门到达宿主代码的条目并由其所有者门禁答 403);③packages/cloud-connection/src/marketplace-install-local-plugin.ts(卸载门在注册表撤出后调用unbindAppArtifactHandlers)。pnpm --filter @objectstack/runtime exec vitest run --maxWorkers=2 src/action-package-addressing.test.ts -t 'hands an emptied key back'(需先构建 objectql),预期 1 passed:裸调用跑host而不是global,所有者门禁答 403。BREAKING
ObjectQL#removeActionsByPackagenow hands a key it empties in the unqualified slot (the one a call that names no package reads) back to the entry another owner still holds under that key in its own coordinate's slot. Three paths reach it:ObjectQL#removePackage(packages/objectql/src/engine-compatibility-api.ts), a public engine method;packages/runtime/src/app-artifact-handlers.ts), when a re-install of a multi-package artifact drops a body whose key another holder still holds (a re-bind's own keys go back to the re-binder when they re-register);ql.removeActionsByPackage('metadata-service')(packages/objectql/src/plugin.ts), when an environment-authored action is deleted whose key host code or a plugin also holds.Before, on each path, the action doors (
POST /api/v1/actions/OBJECT/NAME/IDand MCPrun_action, both throughexecuteRegisteredAction) reached the next entry the door's rotation reaches (OBJECT → global → *, per handler-key candidate), and answered "not found" only when none was held. After, they reach the handed-back entry. The owner gates ofactionHandlerOwnerRefusaljudge the entry the dispatch reaches, so they move with it: the handed-back entry's owners are every other script declaration whose own rotation reaches it, and that set can gain a gated declaration. A call that was served can therefore newly answer403 PERMISSION_DENIED(an owner'srequiredPermissions),409 ACTION_DISABLED(an owner switched off in the activation ledger) or503(the handed-back entry is the environment'smetadata-serviceentry and the metadata plane cannot be read). This is what a restart of the same process already answers.No migration. Nothing persisted changes, so there is no data migration and no heal (maintainer, 2026-11-14: no production customers yet). ADR-0087 disposition:
not-required (no-migration-prescription), carried as the marker in.changeset/33536-uninstall-unbinds-action-handlers.md.The install-local case the card reports is unaffected by this narrowing. Before this PR the uninstalled package's handler stayed bound, so the key never emptied there: the bare call went from
409 RESOURCE_CONFLICTto the one remaining holder's handler, which only widens.What changes
@objectstack/runtime: new exportunbindAppArtifactHandlers(ql, appId, { logger, source }), the inverse ofbindAppArtifactHandlers. It removes the actions (removeActionsByPackage), hooks (unregisterHooksByPackage) and functions (unregisterFunctionsByPackage, plusreleaseFunctionClaims) of the package's ownerapp:IDand of every owner the package's last bind on that engine recorded (the bodies of a multi-package artifact). It then forgets the bind record, so a re-install binds as a first bind. It does not touch another package's handlers, host code or the environment'smetadata-servicehandlers. Jobs already leave through theruntime.package-jobsuninstall cleanup. It never throws.@objectstack/cloud-connection: the uninstall door calls it right after the registry withdrawal (withdrawFromRunningKernel). It does not call it when the registry refuses the withdrawal, because the package stays loaded and running then. The import is lazy, like the binder's. On a runtime without the export the door logs awarnwith the remedy, which is how the install door already handles a runtime with no binder.@objectstack/objectql: the first fix alone turned the engine's bareexecuteActionfrom a 409 into a "not found", which a restart does not give. Each owner keeps its handler in its own package slot. The unqualified slot held only the LAST registration, here the uninstalled package's.removeActionsByPackagedeleted it and left the key empty. Now a key that the removal empties in the unqualified slot takes back the entry that another coordinate's slot still holds: the same object, socoordinateOfUnqualifiedstill finds it. If several slots hold it, the last coordinate in slot-creation order wins, which is not always the last registration of that key. While two or more packages hold the key, the bare call is refused as before.The readers of the unqualified
listRegisteredActions()see the key again where it had disappeared: MCPlist_actions' handler probe (registeredActionHandlerProbe), which only widens (it advertises a key it had stopped advertising); the script door's owner check (actionHandlerOwnerRefusal, for a call that names no package), which is the narrowing above; and the action-governance inventory (plugin.ts,runActionGovernanceInventory), which only warns. Every 409 the bare-call rule answers stays a 409, because it counts owners from the package slots before it reads the unqualified one.Not "the restart answer" in every case. In the card's shape, and in every case where the bare call is refused, the result is what a restart gives. Where the bare-call rule runs one owner while others hold the key, the hand-back's slot order and a restart's last registration can differ: host code or a plugin beside one package on an object-bound key (ADR-0150 D5), and two shared owners with no package (host code beside a plugin, or two plugins), which
unqualifiedHandlerrefuses in neither case. If the slot created first, for another key, registered this key last, the hand-back runs the other holder's handler, while a restart runs the last registration. The changeset and theengine.tsdocblock say "one remaining holder's handler" for that reason. No per-key registration sequence is added.Other withdrawal paths (measured by reading the code; no runtime probe):
PATCH /api/v1/packages/:id/disable: the handlers stay in their slot.unqualifiedHandlerdoes not count a disabled package as an owner (contract review G4), so the bare call is already served by the remaining enabled owner. Nothing changed.DELETE /api/v1/packages/:id: the protocol'sdeletePackagewithdraws the registry entry and runs the uninstall cleanups, but never reaches the engine's action, hook or function slots. So the same handler leak very likely applies there; this was read from the code, not reproduced. It is not fixed here. That path is not the function this card fixes, its files arepackages/runtime/src/domains/packages.tsandpackages/metadata-protocol/src/**(other areas' open work), and the clean closure is a separate decision (see Acceptance notes).Tests
New
packages/cloud-connection/src/marketplace-install-local-uninstall-handlers.test.tsruns against a realObjectKernelwithObjectQLPlugin(the real engine, handler slots and bare-call ambiguity rule, plus the realSchemaRegistryand protocol) and the runtime'sAppPlugin. The handlers are bound by the realbindAppArtifactHandlerswith the install door's options, through the same engine object the door is handed. The only stand-in is the door'sfind, which answers the installer's grants.qa_a_ticket:escalate; the bare call is refused 409RESOURCE_CONFLICTnaming both; afterDELETE install-local/com.qa.addr-b(200) the bare call answers{ by: 'a' }, and B's body hook is gone from the engine;uninstallPackagethrowing after every check asked ahead of it passed): 200 with the failedregistry.uninstallPackageoutcome, both packages still hold the key, the B-qualified call runs B, and the bare call is still 409;unbindAppArtifactHandlersof B is a no-op: it answers owners[app:com.qa.addr-b], A is still the only holder, the bare call answers{ by: 'a' }, A's hook is still bound, and nothing is logged aterror;metadata-service) under the same key survive the unbind: the B-qualified call falls back to the one shared handler (host code), the environment coordinate's call runs the environment handler, and A's call runs A's.New top-level
describeinpackages/runtime/src/action-package-addressing.test.ts(the door's shared harness: realObjectQLand protocol execution read) pins the narrowing at the door: host code and then package A registeraccount:approve,global:approveis held, and B'sapprove_all(target: 'approve',requiredPermissions: ['approve_everything']) holds onlyglobal:approve_all. AfterremoveActionsByPackage('app:A'), the unqualifiedexecuteRegisteredActionruns host code's handed-back entry ('host'), andactionHandlerOwnerRefusalfor a caller without the capability answers403 PERMISSION_DENIED, becauseapprove_allnow reaches the same entry.The pin in
packages/objectql/src/bound-action-collision-report.test.tsis rewritten: "withdrawing the replacing owner leaves the key with no handler" becomes "hands the key back to the owner it replaced", with a CONTROL that once no owner is left the key has no handler. The old assertion pinned exactly the behaviour this PR changes: it predates the per-package slots, and the current warning text no longer names that consequence.Ablations (through
scripts/ablation-replace.mjs, each on the committed fix, restored to blob == HEAD withgit diff HEADempty):if (!withdrawal && false) await this.unbindArtifactHandlers(...)): 3/3 red. The card's own answer comes back:ActionHandlerAmbiguityError409 after the uninstall, and the holders stay[com.qa.addr-a, com.qa.addr-b].if (remaining !== undefined && false) ...): 2/3 red,Action 'escalate' on object 'qa_a_ticket' not found. The remaining-holder control stays green, because the package-qualified call does not read the unqualified slot.await this.unbindArtifactHandlers(ctx, manifestId);without theif (!withdrawal)): 1 failed, 5 passed, and the one red is the refused-withdrawal pin.if (remaining !== undefined && key === '') ...; the&& falsespelling fails the objectql dts build), objectql rebuilt,ablation-dist-preflightfound the marker in 4 built files: 1 failed,expected 'global' to be 'host', which is the before-state the BREAKING section names. Restore leg: objectql rebuilt, preflight--absentclean in all 14 built files and the tree clean against HEAD, the file thenTests 123 passed (123).Not ablated: the no-op pin and the shared-handlers pin. Their subject,
unbindAppArtifactHandlers, resolves through the runtime's builtdist/, so each leg needs a runtime rebuild, and that did not fit the time box.Acceptance notes
DELETE /api/v1/packages/:idmost likely has the same handler leak (read from the code, not reproduced through the door). The narrowest closure is to registerunbindAppArtifactHandlersas aruntime.package-handlersuninstall cleanup, which the jobs half does today. Both doors run cleanups, so that would also replace the door-local call. It adds an outcome row to every uninstall response'scleanupson kernels that bound handlers, and tests and dogfood pin those lists, so it was not done here.unbindAppArtifactHandlersis not pinned on this door. It is the same code the binder's re-bind teardown runs for a dropped body.patchfor all three packages under the declared(narrowing)arm. AGENTS.md (Post-Task Checklist step 3) andcheck-changeset-no-major.mjsgrade the level by theMetadata-protocol:kind alone:nonetakespatch, refuses aminor, and keeps the BREAKING banner and ADR-0087 disposition.@objectstack/runtimegains the exported function and type. No api-surface snapshot or census lists the runtime barrel's members (git grepofbindAppArtifactHandlersover json, md and snapshot files finds only changesets).Verification
This round's readings were taken at head
667a89f4d5, the final head (two commits added on32021b8309; no rebase, no force-push, no merge ofmain). Each build and test ran throughos-verify-lock.sh.This round, at 667a89f
packages/runtime/src/action-package-addressing.test.ts(objectql built first):Tests 123 passed (123)pnpm --filter @objectstack/runtime test:Test Files 602 passed (602),Tests 10782 passed | 19 skipped (10801)pnpm --filter @objectstack/runtime typecheck(tsc pluscheck:test-typecheck): exit 0eslint --no-inline-config packages/runtime/src/action-package-addressing.test.ts: exit 0node scripts/check-adr-0087-registration.mjs --base origin/main: exit 0, "1 declared-breaking changeset(s), each carrying an ADR-0087 disposition", read as[BREAKING+bang+clause-②-narrowing] not-required (no-migration-prescription)node scripts/check-changeset-no-major.mjs: exit 0, nomajor; its level axis reads the PR body, so locally it reports NOT APPLICABLE and CI'sCheck Changesetgrades it (Metadata-protocol: nonewithpatch)node scripts/check-nul-bytes.mjs: exit 0Changed packages, at 32021b8
Tests 6 passed (6)pnpm --filter @objectstack/cloud-connection test:Test Files 81 passed (81),Tests 1215 passed (1215)pnpm --filter @objectstack/objectql test:Test Files 595 passed (595),Tests 13028 passed (13028)pnpm --filter @objectstack/runtime test:Test Files 602 passed (602),Tests 10781 passed | 19 skipped (10800)typecheckof objectql, runtime and cloud-connection: exit 0Direct dependents (downstream of objectql and runtime), first round at 793d825
turbo run test --concurrency=2 --continueover 34 direct dependents:Tasks: 104 successful, 104 total, exit 0 (every test task a cache miss).@objectstack/cli, unit layer (vitest run --project unit):Test Files 420 passed (420),Tests 5966 passed (5966). The integration layer is left to CI.@objectstack/dogfood(the battery; the dogfood shards run in the merge queue).Derived gates, first round at 793d825
dispatch-gates --commands: 73 commands. 72 exited 0.pnpm check:dual-build-cjs-loadsexited 3 with PREREQUISITE NOT MET because it needs a fullpnpm build, so it is NOT MEASURED locally and CI runs it.dispatch-gates --ran: 73 derived, 73 run, 0 UNRUN.🤖 Generated with Claude Code
https://claude.ai/code/session_016WV4cx5ZPCyTk8ckTsx4ut