Skip to content

fix(cloud-connection, runtime, objectql)!: an install-local uninstall withdraws the package's action handlers and hooks from the engine - #33622

Merged
objectstack-fleet[bot] merged 8 commits into
mainfrom
claude/area-E2-33536
Nov 15, 2026
Merged

objectstack-fleet[bot] merged 8 commits into
mainfrom
claude/area-E2-33536

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Elon · project thread

Fixes #33536

Clause-②: yes (narrowing)
Metadata-protocol: none

维护者速读

  • 改了什么:install-local 卸载(DELETE /api/v1/marketplace/install-local/ID)在注册表撤出包之后,同时把该包在引擎上绑定的脚本动作处理器、body hook 和函数一并撤掉;引擎移除某包的动作处理器时,把"不指名包的调用"所读的槽位交还给仍持有该键的另一个持有者。
  • 为什么改:卸载后被撤出的包仍挂着处理器,裸调用 POST /api/v1/actions/OBJECT/NAME/ID 一直报 409"两个持有者",点名已卸载的包,直到重启。现在卸载后立即由唯一剩余持有者的处理器作答(报告的场景即剩余包的结果)。
  • 风险与回滚:这是一次声明的收窄(BREAKING)。removeActionsByPackage 的交还对所有调用方生效:removePackage、重绑定丢弃包体、作者动作重同步。这三条路径上,被清空的键改由剩余持有者的条目作答;动作门(REST 与 MCP run_action)以前会沿轮转(OBJECT → global → *)落到后面的条目并放行,现在到达交还的条目,该条目的所有者门禁随之生效,原本放行的调用可能改答 403 / 409 ACTION_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#removeActionsByPackage now 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;
  • the binder's re-bind teardown (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);
  • the authored-action resync's teardown, 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/ID and MCP run_action, both through executeRegisteredAction) 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 of actionHandlerOwnerRefusal judge 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 answer 403 PERMISSION_DENIED (an owner's requiredPermissions), 409 ACTION_DISABLED (an owner switched off in the activation ledger) or 503 (the handed-back entry is the environment's metadata-service entry 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_CONFLICT to the one remaining holder's handler, which only widens.

What changes

  • @objectstack/runtime: new export unbindAppArtifactHandlers(ql, appId, { logger, source }), the inverse of bindAppArtifactHandlers. It removes the actions (removeActionsByPackage), hooks (unregisterHooksByPackage) and functions (unregisterFunctionsByPackage, plus releaseFunctionClaims) of the package's owner app:ID and 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's metadata-service handlers. Jobs already leave through the runtime.package-jobs uninstall 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 a warn with 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 bare executeAction from 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. removeActionsByPackage deleted 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, so coordinateOfUnqualified still 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: MCP list_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 unqualifiedHandler refuses 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 the engine.ts docblock 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. unqualifiedHandler does 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's deletePackage withdraws 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 are packages/runtime/src/domains/packages.ts and packages/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.ts runs against a real ObjectKernel with ObjectQLPlugin (the real engine, handler slots and bare-call ambiguity rule, plus the real SchemaRegistry and protocol) and the runtime's AppPlugin. The handlers are bound by the real bindAppArtifactHandlers with the install door's options, through the same engine object the door is handed. The only stand-in is the door's find, which answers the installer's grants.

  • the card's shape: two packages hold qa_a_ticket:escalate; the bare call is refused 409 RESOURCE_CONFLICT naming both; after DELETE install-local/com.qa.addr-b (200) the bare call answers { by: 'a' }, and B's body hook is gone from the engine;
  • CONTROL: A still holds its handler and hook, and the package-qualified call for A runs;
  • CONTROL: a re-install of B binds again, the B-qualified call runs B's handler, and the bare call is refused 409 naming both again;
  • a withdrawal the registry refuses (uninstallPackage throwing after every check asked ahead of it passed): 200 with the failed registry.uninstallPackage outcome, both packages still hold the key, the B-qualified call runs B, and the bare call is still 409;
  • a second unbindAppArtifactHandlers of 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 at error;
  • host code (no owner) and an environment-authored handler (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 describe in packages/runtime/src/action-package-addressing.test.ts (the door's shared harness: real ObjectQL and protocol execution read) pins the narrowing at the door: host code and then package A register account:approve, global:approve is held, and B's approve_all (target: 'approve', requiredPermissions: ['approve_everything']) holds only global:approve_all. After removeActionsByPackage('app:A'), the unqualified executeRegisteredAction runs host code's handed-back entry ('host'), and actionHandlerOwnerRefusal for a caller without the capability answers 403 PERMISSION_DENIED, because approve_all now reaches the same entry.

The pin in packages/objectql/src/bound-action-collision-report.test.ts is 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 with git diff HEAD empty):

  1. Door call disabled (if (!withdrawal && false) await this.unbindArtifactHandlers(...)): 3/3 red. The card's own answer comes back: ActionHandlerAmbiguityError 409 after the uninstall, and the holders stay [com.qa.addr-a, com.qa.addr-b].
  2. Engine hand-back disabled (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.
  3. Refused-withdrawal guard removed (await this.unbindArtifactHandlers(ctx, manifestId); without the if (!withdrawal)): 1 failed, 5 passed, and the one red is the refused-withdrawal pin.
  4. This round, for the door pin: engine hand-back disabled with a type-preserving mutation (if (remaining !== undefined && key === '') ...; the && false spelling fails the objectql dts build), objectql rebuilt, ablation-dist-preflight found 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 --absent clean in all 14 built files and the tree clean against HEAD, the file then Tests 123 passed (123).

Not ablated: the no-op pin and the shared-handlers pin. Their subject, unbindAppArtifactHandlers, resolves through the runtime's built dist/, so each leg needs a runtime rebuild, and that did not fit the time box.

Acceptance notes

  • DELETE /api/v1/packages/:id most likely has the same handler leak (read from the code, not reproduced through the door). The narrowest closure is to register unbindAppArtifactHandlers as a runtime.package-handlers uninstall 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's cleanups on kernels that bound handlers, and tests and dogfood pin those lists, so it was not done here.
  • Functions: JSON artifacts carry none (ADR-0088), so the function teardown in unbindAppArtifactHandlers is not pinned on this door. It is the same code the binder's re-bind teardown runs for a dropped body.
  • Log noise (no change to what is accepted): the hand-back adds a warning to two tear-down-then-register paths that were silent before. When a package re-binds beside another holder, the teardown hands the key to that holder, and the re-registration then warns "second owner beside" it. The same happens on each authored-action resync where an environment handler sits beside host code. An upgrade now repeats the install's warning. No code change is made for it here.
  • Changeset level: the changeset stays patch for all three packages under the declared (narrowing) arm. AGENTS.md (Post-Task Checklist step 3) and check-changeset-no-major.mjs grade the level by the Metadata-protocol: kind alone: none takes patch, refuses a minor, and keeps the BREAKING banner and ADR-0087 disposition.
  • @objectstack/runtime gains the exported function and type. No api-surface snapshot or census lists the runtime barrel's members (git grep of bindAppArtifactHandlers over json, md and snapshot files finds only changesets).

Verification

This round's readings were taken at head 667a89f4d5, the final head (two commits added on 32021b8309; no rebase, no force-push, no merge of main). Each build and test ran through os-verify-lock.sh.

This round, at 667a89f
  • the door pin file 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 plus check:test-typecheck): exit 0
  • eslint --no-inline-config packages/runtime/src/action-package-addressing.test.ts: exit 0
  • node 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, no major; its level axis reads the PR body, so locally it reports NOT APPLICABLE and CI's Check Changeset grades it (Metadata-protocol: none with patch)
  • node scripts/check-nul-bytes.mjs: exit 0
  • Not re-run this round (no source line changed): the cloud-connection and objectql suites and the derived gate set; their readings below are from earlier heads.
Changed packages, at 32021b8
  • the uninstall pin file: 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)
  • typecheck of objectql, runtime and cloud-connection: exit 0
Direct dependents (downstream of objectql and runtime), first round at 793d825
  • turbo run test --concurrency=2 --continue over 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.
  • NOT MEASURED: @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-loads exited 3 with PREREQUISITE NOT MET because it needs a full pnpm 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

@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 3 package(s): @objectstack/cloud-connection, @objectstack/objectql, @objectstack/runtime, touching 8 documentable anchor(s). ⚠️ 1 changed file(s) yielded no anchor (packages/runtime/src/index.ts), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

1 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:

  • content/docs/deployment/cli.mdx (via MarketplaceInstallLocalPlugin (symbol, a top-level class))
What this run could not see
  • 1 changed file(s) yielded no anchor (packages/runtime/src/index.ts) — pages documenting those are invisible to this run
  • 1 anchor(s) matched too much of the corpus to be a work list: ObjectQL (symbol, 81 pages)
  • 1 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 65 of 247 client-bound route-ledger rows — the other 182 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 182: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 123 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 45 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 020ce3d9e8c7ac9a97863cf31e151290d4938a70 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from ccdad23f956f725f41288599a515c81042fd7f35 — the merge of head 667a89f4d5d0b4a31a69afae35042a0b68188c61 into base 020ce3d9e8c7ac9a97863cf31e151290d4938a70, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# 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

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs 020ce3d9e8c7ac9a97863cf31e151290d4938a70 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#5 · os-elon-musk · session_016WV4cyrFFk86Jqf7Mp5Rzw
Request: review · area E2 · head 793d825

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

Contract-review-claim: session_016WV4d1PGptBW3QRQNmy5e6 · head 793d825 · 2026-11-15T03:15Z

review#3.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

Contract review

Served-tier: TIER_DEFAULT
Head-sha: 793d8251b23579fd3f5a00d223a4e20373e37b15
Local-runs: none

Read: the PR's four commits on top of 4bba8b8f (c23e4055, 0a2c2b5d, 0305fd3b, 793d8251): 8 files, +439/−2. I compared the new unbind with the binder's teardown in packages/runtime/src/app-artifact-handlers.ts, read every caller of removeActionsByPackage and of listRegisteredActions() at this head, and traced the rewritten pin through its history on GitHub (#24526, #31737, #32213). I ran nothing locally.

① Derived judgments

The unbind is the binder's own teardown, applied to the same owners.

  • Same owners. The binder tears down owner, previous.owners and the owners it binds now, and records those owners for the next bind (app-artifact-handlers.ts:336-372). The unbind tears down owner plus previousBind(ql, owner).owners (:589). That is exactly the set the last bind registered under, because recordBind stores the owners the bind was about to bind.
  • Same verbs. For each owner it calls removeActionsByPackage, unregisterHooksByPackage, unregisterFunctionsByPackage and releaseFunctionClaims (:592-598). These are the binder's teardown verbs. The only other engine calls the binder makes are bindHooks and registerAction under the same owners, so nothing the bind registered is left behind. Jobs leave through the existing runtime.package-jobs cleanup, as the PR says.
  • Nothing of another holder. Every verb removes by the exact owner string app:<id>. removeActionsByPackage drops only stack entries whose package equals that string (engine-actions.ts:447-453), so an override that another package or the environment bound over B's handler stays, with nothing beneath it. Host code is coordinate (host), the environment's resync is metadata-service (coordinate ''), and a plugin is its own name. None of them can equal app:<manifestId>.
  • Idempotent. The unbind deletes the bind record (:607). A second call reads NO_BIND, so it tears down only owner, which no longer holds anything. Every verb is then a no-op, and so is the hand-back loop, because no key empties.
  • Ordered after a successful withdrawal. if (!withdrawal) await this.unbindArtifactHandlers(...) (marketplace-install-local-plugin.ts:3705) sits after withdrawFromRunningKernel. It never runs on a refused withdrawal, and never on the earlier assertPackageUninstallable 409 or a ledger write failure, which both return before it. It runs before the metadata:reloaded announcement, so the authored-action resync that follows sees an engine without B. The new await comes after the withdrawal, so the no-await window between the ledger removal and the withdrawal is unchanged.

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. unqualifiedHandler counts owners from the package slots before it reads the unqualified slot (engine-actions.ts:328-347). So which entry the loop at :479-484 restores never changes a refusal:

  • Two or more packages remain: refused 409 naming them, as before the PR.
  • Object-less key, one package beside host code or a plugin: refused 409, as before.
  • One package remains: its handler runs. This is the card's shape.
  • Only the environment's handler remains: it runs. The environment is never an owner, and this is what a restart answers.
  • A disabled package's handler is restored while an enabled owner remains: the G4 path returns the enabled owner's handler (:350-353). With no enabled owner left, the door's disabled-package gate judges the call, as at boot.
  • Host code or a plugin beside one package on an object-bound key (D5's "last registration" case): one of the two runs. Which one can differ from a restart; see N1.

② Semver level

  • Clause-②: yes (widening) is right. The PR adds the export unbindAppArtifactHandlers and the type AppArtifactHandlerUnbinding, and the moved answers turn a refusal (409 or "not found") into a served answer. Nothing that was accepted before is refused now. Every 409 that D5 rules stays a 409, because the count runs before the slot read. So no !, BREAKING paragraph or ADR-0087 marker is owed.

  • Patch for all three packages is right. No authorable metadata moves, so Metadata-protocol: none holds, and both lines start a line in the PR body and the changeset.

  • must-fix M1: the changeset's Clause-② line names one moved answer, and the engine change moves more. .changeset/33536-uninstall-unbinds-action-handlers.md:9 names only the bare call after an install-local uninstall, 409 → the remaining package's result. The objectql change at engine-actions.ts:479-484 applies to every caller of removeActionsByPackage, and on main (4bba8b8f) these callers already reached the empty key:

    • the authored-action resync teardown, ql.removeActionsByPackage('metadata-service') (packages/objectql/src/plugin.ts:4566). Deleting an environment-authored action whose key host code or a plugin also holds moves the bare call from "not found" to that handler.
    • the binder's re-bind teardown (app-artifact-handlers.ts:342). A re-install of a multi-package artifact that drops a body moves the bare call from "not found" to another package's handler under that key.
    • ObjectQL#removePackage (packages/objectql/src/engine-compatibility-api.ts:264), a public engine method, moves the same way.
    • the unqualified listing listRegisteredActions() now keeps the key after those removals. It feeds MCP list_actions' advertising probe (packages/runtime/src/action-execution.ts:5472), the script door's owner check (:5692) and the governance inventory (plugin.ts:4470). The action is therefore advertised again where it had disappeared.

    Each move is a widening and agrees with D5, so the value stays yes (widening). But the declaration should name them. Add a sentence to the Clause-② line, and to the PR body, such as: "ObjectQL#removeActionsByPackage also hands the key back on every other removal: the authored-action resync, a re-bind that drops a package body, and removePackage. A bare call there moves from 'not found' to the one remaining holder's handler, and listRegisteredActions() keeps listing the key."

③ Boundary flags

  • The diff stays in the three packages the area names. It adds one runtime barrel export and touches no packages/spec, ADR, generated file or protocol.
  • Dogfood battery. It is not needed for a widening-only arm. At ACCEPT, re-read: the amended Clause-② line (M1); CI green, including check:dual-build-cjs-loads, which the PR could not measure locally; and the dogfood shards in the merge queue, which the PR declares as not measured.
  • Open, not in this PR. DELETE /api/v1/packages/:id (protocol deletePackage) never calls an action, hook or function unbind. The leak there is read from the code, not reproduced. File it as its own card. The PR's own suggestion, unbindAppArtifactHandlers as a runtime.package-handlers uninstall cleanup, would close both doors at once, and adds a cleanups row that pins and dogfood read.

Nits (none blocks).

  • N1. The hand-back picks "the last coordinate holding the key, in the order the slots were created" (engine-actions.ts:482). A slot is created the first time its coordinate registers any key, so this is not "the last registration of this key". The changeset (:9, "now answers what it answers after a restart") and the docblock (engine.ts:1129-1134) claim the restart answer. That holds for every refused case and for the card's shape. It can fail in one D5 case: host code beside one package on an object-bound key, when host code's slot was created earlier for another key but registered this key after the package. Then the hand-back runs the package's handler and a restart runs host code's. Either say "one remaining holder's handler" for that case, or keep a per-key registration sequence.
  • N2. The hand-back adds a log warning to two tear-down-then-register paths that were silent before. When B re-binds beside A, the teardown hands the key to A, and B's re-registration then warns "second owner beside A" (engine-actions.ts:176). The same happens on each authored-action resync where an environment handler sits beside host code. This is log-only and does not change the accept set, but an upgrade now repeats the install's warning.
  • N3. Three properties the review relies on have no pin, and no ablation covered them: (a) a refused withdrawal leaves the handlers bound (the !withdrawal guard at :3705); (b) a second unbindAppArtifactHandlers call is a no-op; (c) host code or an environment handler under the same key survives the unbind. A runtime unit case for (b) and (c) next to the binder's re-bind pins, plus a door case for (a) with uninstallPackage refusing, would cover them.

Implemented-by: claude/area-E2-33536
Reviewed-by: session_016WV4d1PGptBW3QRQNmy5e6

VERDICT: FAIL

…nd the shared handlers that survive it

Claude-Session: https://claude.ai/code/session_016WV4cyrFFk86Jqf7Mp5Rzw
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#5 · os-elon-musk · session_016WV4cyrFFk86Jqf7Mp5Rzw
Request: review · area E2 · head 32021b8

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

Contract-review-claim: session_016WV4d1PGptBW3QRQNmy5e6 · head 32021b8 · 2026-11-15T03:46Z

review#3 (delta).

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

Contract review

Served-tier: TIER_DEFAULT
Head-sha: 32021b83094f4bdf06b1a8dc8e7ec467223c5828
Local-runs: none

This reviews the delta on my FAIL at 793d8251 (record 6888444951).

Read: 793d8251..32021b83, two commits with no rebase (5c99acd4 docs(changeset), 32021b83 test). 4 files, +71/−15. The changes to engine.ts and engine-actions.ts are comment-only: the removeActionsByPackage docblock and the hand-back comment. No executable line changed. I re-read every caller of removeActionsByPackage, every reader of the unqualified listRegisteredActions() and the doors' handler-key rotation at this head. I ran nothing locally.

① Derived judgments

The claims M1 asked for are true at the engine.

  • The resync claim, and dropping "or a package", are right. resyncAuthoredActionsNow filters bindable through isArtifactShippedAction (plugin.ts:4560-4562). That test is true for any registry holder's artifact at the owner key (:3997-4011). The exception is a declared .custom override, which registerActionOverride binds at the base's coordinate over the base's handler, so its teardown restores beneath and never empties the key. The teardown at :4566 therefore empties a key only where host code or a plugin holds it. The re-registration loop after it is synchronous, so there is no window in which the key reads empty.
  • The re-bind (app-artifact-handlers.ts:341-343) and removePackage (engine-compatibility-api.ts:264) reach the hand-back as named. A re-bind's own keys go back to the re-binder when they re-register, so only a dropped body leaves a lasting move, as the text says.
  • "Every 409 the bare-call rule answers stays a 409" is true. unqualifiedHandler counts owners from the package slots and throws before it reads this.actions (engine-actions.ts:328-349).
  • The listing readers are correctly named. MCP list_actions' probe (action-execution.ts:5468-5484) only widens: it advertises a key it had stopped advertising. The governance inventory (plugin.ts:4470) only warns. The script door's owner check (:5692) is the subject of M2.

The new pins.

  • (a) A refused withdrawal keeps the handlers bound (…-uninstall-handlers.test.ts:278). It refuses at registry.uninstallPackage itself and asserts that the cleanups row shows the failure. It then checks that both holders are still there, that B's own call still runs, and that the bare call still answers 409 with both owners. It pins the if (!withdrawal) guard (marketplace-install-local-plugin.ts:3705), and the PR reports an ablation for it.
  • (b) A second unbind is a no-op (:296). It is not ablated, but it is real for scoping. A second call that tore down beyond app:B would fail holders() → [A], call() → { by: 'a' }, or the hook count on app:A → 1. It cannot tell whether the bind record was forgotten, because for a single-package artifact the recorded owners and the fallback owner are both [app:B]. That is acceptable: the forgetting is read in my prior ① and is harmless either way.
  • (c) Host code and the environment handler survive (:309). It is not ablated, but it is real for scoping. An unbind that removed the host entry would make call(B) not found, because B has nothing of its own and the shared fallback would be gone. One that removed metadata-service would make call('') fail. It does not assert the bare call, which is fine.
  • None of the three pins the guard except (a), which is the right split.

N1's text is mostly right, with one gap (N4 below). "One remaining holder's handler … in slot-creation order" matches the loop at engine-actions.ts:479-484.

② Semver level

  • must-fix M2: "a bare call moves from 'not found'" holds at executeAction, not at the doors the line names. At the doors, the before-state is often a fallback entry's handler, and a newly reached entry can bring a refusal.
    • The fallback. Both doors dispatch through executeRegisteredAction. It walks actionHandlerObjectKeys(objectName) = [OBJECT, 'global', '*'] × the declaration's handler-key candidates (resolveActionHandlerKeys: primary, target, name). On "not found" it moves to the next pair (action-execution.ts:5428-5440). Before this PR, a key that a resync, a re-bind or removePackage emptied did not answer "not found" at POST /api/v1/actions/... or MCP run_action whenever a later pair was held. The call then ran that pair's handler, for example global:NAME, or OBJECT:<name> behind a target. Now it runs the handed-back holder's handler. That is a different handler, not a refusal turned into an answer.
    • The owner check moves with it. actionHandlerOwnerRefusal judges the entry the dispatch reaches, from the same unqualified listing (:5692, :5756). Its owners are every other script declaration whose own rotation reaches that entry. When the entry moves, the owner set moves too, and it can gain a gated declaration.
    • A concrete narrowing. On ticket:
      • ticket is not P's object, and it declares escalate. Host code holds ticket:escalate, and package P registers it after host code. ticket:escalate_urgent and global:escalate are registered.
      • A declaration escalate_urgent on ticket (target: 'escalate', requiredPermissions: ['supervisor']) has candidates [escalate, escalate_urgent].
      • After removePackage(P) on main, a bare escalate call reaches global:escalate, and escalate_urgent reaches ticket:escalate_urgent. So escalate_urgent owns nothing the call runs, and the call is served.
      • At this head, the hand-back restores ticket:escalate to host code's entry. Both now reach ticket:escalate, and a non-supervisor's call is refused 403 PERMISSION_DENIED (:5766). The same holds for an owner switched off in the activation ledger (409 ACTION_DISABLED, :5777).
      • When the handed-back entry is the environment's metadata-service entry, the hand-back can pick coordinate '', which test (c) sets up. With the plane unreadable, the call is refused 503 (:5720) where the fallback entry was served.
    • Why this matters. These are calls accepted before and refused after: a (narrowing) under AGENTS.md's closed pair, which is BREAKING. It is also what a restart answers, so the behaviour is defensible; the declaration is what is wrong. My record at 793d8251 said "nothing that was accepted before is refused now" and missed this rotation. I own that miss. The delta's new sentence states the before-state as "not found" for every caller, so the line now declares it wrongly.
    • Fix, either way:
      • (i) Keep yes (widening) and show the narrowing cannot occur. I do not see how, given the example.
      • (ii) Declare it. Use Clause-②: yes (narrowing) with the BREAKING banner, the ADR-0087 marker and a migration line, or whatever disposition a seat rules for a restart-consistent narrowing. Name the before-state as "the next entry the door's rotation (OBJECT → global → *, per handler-key candidate) reaches; 'not found' only when none is held". Say that the owner gates of actionHandlerOwnerRefusal move with the entry, and can newly answer 403, 409 ACTION_DISABLED or 503. Make the same change in the PR body's "Every answer the engine hand-back moves" paragraph.
    • Scope. The reported install-local case is not affected. Before the PR, B's handler stayed bound, so the key never emptied there.
  • Patch for all three packages still follows the kind: a non-protocol change. Metadata-protocol: none holds.

③ Boundary flags

  • Delta surface. The delta changes tests, comments and the changeset only. It touches no spec, ADR or generated file.
  • N2 (the re-bind warning) is left to the Acceptance notes, as agreed.
  • N4 (nit). The changeset says the slot-order choice "matters only where the bare-call rule runs one of two owners, host code or a plugin beside one package". It also matters with two shared owners and no package: host code beside a plugin, or two plugins. unqualifiedHandler refuses neither (engine-actions.ts:345-349), so the hand-back's slot order and a restart's last registration can differ there too. That is exactly the named resync case "whose key host code or a plugin also holds" when both do. Either widen the sentence or drop "only".
  • At ACCEPT. Re-read the amended Clause-② line (M2), and check that CI is green, including check:dual-build-cjs-loads and check:adr-0087-registration if the arm becomes (narrowing).

Implemented-by: claude/area-E2-33536
Reviewed-by: session_016WV4d1PGptBW3QRQNmy5e6

VERDICT: FAIL

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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 yes (narrowing):

  • add ! to the title;
  • add a BREAKING paragraph: after removePackage, after a re-bind that drops a body, and on the authored resync, an emptied unqualified key now resolves to the remaining holder's entry, so that owner's gates (403 / 409 ACTION_DISABLED / 503) can answer where the rotation used to fall through to a later entry. This is what a restart already answers;
  • add the ADR-0087 marker, and correct the before-state wording.

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
@github-actions github-actions Bot added size/l and removed size/m labels Nov 15, 2026
…wn key at global

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WV4cx5ZPCyTk8ckTsx4ut
@objectstack-fleet objectstack-fleet Bot changed the title fix(cloud-connection, runtime, objectql): an install-local uninstall withdraws the package's action handlers and hooks from the engine fix(cloud-connection, runtime, objectql)!: an install-local uninstall withdraws the package's action handlers and hooks from the engine Nov 15, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#5 · os-elon-musk · session_016WV4cx5ZPCyTk8ckTsx4ut
Request: review · area E2 · head 667a89f · 2026-11-15T04:33Z

Text-only delta on FAIL 6888764173 (M2 + N4), under seat ruling A (6888779008); no executable source line changed. 32021b83..667a89f4: the changeset now declares Clause-②: yes (narrowing) with the !, a BREAKING paragraph, the ADR-0087 marker not-required (no-migration-prescription) and a no-migration line, and drops "only" from the slot-order caveat (two shared owners). The PR title carries the !, and the body has the corrected before-state, the three paths and the install-local note. One added pin, in packages/runtime/src/action-package-addressing.test.ts: after the hand-back the door runs host code's entry instead of global:approve, and the gated owner answers 403. Its ablation (hand-back disabled, objectql rebuilt) reds with expected 'global' to be 'host'.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

Contract-review-claim: session_016WV4czb1FQB8j27FVgnMye · head 667a89f · 2026-11-15T04:38Z

review#3.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 667a89f4d5d0b4a31a69afae35042a0b68188c61
Local-runs: none
Scope: packages/cloud-connection/src/marketplace-install-local-plugin.ts, packages/cloud-connection/src/marketplace-install-local-uninstall-handlers.test.ts, packages/objectql/src/bound-action-collision-report.test.ts, packages/objectql/src/engine-actions.ts, packages/objectql/src/engine.ts, packages/runtime/src/action-package-addressing.test.ts, packages/runtime/src/app-artifact-handlers.ts, packages/runtime/src/index.ts + packages/runtime/src/action-execution.ts, packages/objectql/src/action-governance.ts, packages/objectql/src/engine-compatibility-api.ts, packages/objectql/src/plugin.ts (cited, read, not reviewed)

This reviews the delta on my FAIL at 32021b83 (record 6888764173), under seat ruling A (6888779008).

The Clause-② arm is now (narrowing), so the face is narrowing, not declaration. This record is therefore at CONTRACT_REVIEW_TIER and carries ④. record-recognisers --template sends a (narrowing) changeset to --face narrowing.

Read: 32021b83..667a89f4, two commits, no rebase: 133d1bb2 (with !) and 667a89f4. Two files change, +33/−3: the changeset and action-package-addressing.test.ts. No executable source line changed. For the source paths in Scope, my readings in records 6888444951 and 6888764173 carry over. Since 32021b83 the only line changes on those paths were comments, tests and the changeset. At this head I re-read the door's rotation (action-execution.ts:5414-5442), actionHandlerOwnerRefusal (:5665-5781), resolveActionHandlerKeys / actionHandlerObjectKeys (action-governance.ts:135,157) and the hand-back loop (engine-actions.ts:478-484). I ran nothing locally.

① Derived judgments

The declaration text answers M2.

  • ! is in the PR title, in commit 133d1bb2's subject and in the changeset summary line.
  • Clause-②: yes (narrowing) and Metadata-protocol: none are line-initial in both the PR body and the changeset body.
  • The changeset carries one ADR-0087 marker, not-required (no-migration-prescription), beside both declaration lines.
  • A BREAKING paragraph names the three paths: removePackage, a re-bind that drops a body, and the authored resync.
  • The before-state is now worded right in both places: "the next entry their handler-key rotation held (OBJECT, then global, then *, per handler-key candidate), and answered 'not found' only when none was held".
  • The no-migration line is present, with the maintainer's 2026-11-14 basis in the PR body. The install-local case is correctly scoped as widening only.

The three codes match every emitter on the hand-back path. An unqualified call reaches the handed-back entry through executeRegisteredAction → ql.executeAction(obj, key). Its owner set is judged by actionHandlerOwnerRefusal over the same unqualified listing. That function has exactly three refusals:

  • 403 at :5766: an owner's requiredPermissions, through actionPermissionError.
  • 409 ACTION_DISABLED at :5777: disabledActionRefusal.
  • 503 at :5720: planeError with packageOf(entry) === 'metadata-service' and entry !== invokedIdentity. The text's condition, "the handed-back entry is the environment's metadata-service entry and the metadata plane cannot be read", matches it.

No other emitter moves:

  • The invoked declaration's own D4 gate and activation consult judge the declaration, not the entry.
  • unqualifiedHandler's 409 RESOURCE_CONFLICT counts owners from the package slots before it reads the unqualified one, so it is unchanged.
  • A business error thrown by the newly reached handler is "the call runs that handler", which the paragraph also states.

The new pin (action-package-addressing.test.ts:213) is discriminating on both assertions.

  • Setup. B's approve_all has a body, so resolveActionHandlerKeys gives [approve_all, approve]. The registrations are host account:approve, then app:A's account:approve (taking the unqualified slot), global:approve_all (app:B) and global:approve.
  • Old code. removeActionsByPackage('app:A') deletes unqualified account:approve and leaves it empty. The bare call then reaches global:approve and returns 'global'. approve_all reaches global:approve_all, a different entry, so it is no owner and the refusal is undefined. Both expects red.
  • This head. The hand-back restores host's entry, so the call returns 'host'. approve_all now reaches account:approve on its second candidate and becomes an owner. The caller lacks approve_everything, so the answer is 403.
  • 667a89f4's global:approve_all registration is what makes the before-state ownerless. Without it, approve_all would fall through to global:approve and the 403 would also hold on the old code.
  • The PR's ablation 4 (expected 'global' to be 'host') agrees.

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

  • Delta surface. The changeset and one test file. No spec, ADR, generated or governed path.
  • Nit N5. The BREAKING paragraph says, without condition, that the moved answer "is what a restart of the same process already answers". The same changeset's objectql bullet says that where one owner is run beside others, the hand-back's slot order can pick a different remaining holder than a restart's last registration. The narrowing class (gates of a remaining holder's entry) is the same either way, so this is wording only. "what a restart answers, up to the slot-order caveat below" would be exact.
  • CI at this head. 33 success, 18 skipped, 2 failure: Test Core (6/8) and the Test Core roll-up. The annotation names packages/cloud-connection pnpm run test exit 1. The delta touches no cloud-connection file, and shard 6/8 was green at 32021b83. Logs not read. A green re-run, or a named cause, is owed before landing. If the red is the PR's own marketplace-install-local-uninstall-handlers.test.ts, that is a flaky pin of this PR and not a main flake.

④ Design judgment

The narrowing, judged against the spec and ADRs on main, makes the spec's own gates real; it takes away no declared capability. ADR-0066 D4 and ADR-0110 D2 (actionHandlerOwnerRefusal's docblock) say a call is judged by the owners of the handler entry its dispatch reaches. Before this PR, after a live removal, the door fell through to a later entry that a restart of the same tree would not reach. That let a caller run past an owner's requiredPermissions or activation switch while the process lived, and be refused after a restart. The hand-back closes that live-vs-boot divergence: the newly refused calls are ones the boot state already refuses. The narrowing stays inside the three named removal paths, and the package-qualified call reads its own slot, so it is untouched. Choosing to keep the hand-back and declare it (ruling A) over reverting it is sound: reverting would leave the engine's bare executeAction answering "not found" for an action a remaining owner holds. No must-fix or should-fix. N5 is a nit.

Implemented-by: claude/area-E2-33536
Reviewed-by: session_016WV4czb1FQB8j27FVgnMye

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#5 · os-elon-musk · session_016WV4cx5ZPCyTk8ckTsx4ut
ACCEPT · area E2 (area-lease pilot #33059) · Fixes #33536 · head 667a89f

  • Review: review#3 delta PASS at 667a89f (record 6889280008, CONTRACT_REVIEW_TIER narrowing), after FAIL 6888764173 at 32021b8. M2 is closed under seat ruling A (6888779008): the engine hand-back in removeActionsByPackage is kept and declared. N4 is fixed. N5 ("what a restart answers" vs the slot-order caveat) is an optional nit, not taken.
  • Declarations: fix(cloud-connection, runtime, objectql)!, Clause-②: yes (narrowing) with a BREAKING paragraph naming the three paths (removePackage, a re-bind that drops a body, the authored resync) and the 403 / 409 ACTION_DISABLED / 503 owner-gate answers; adr-0087 marker not-required (no-migration-prescription); Metadata-protocol: none, so the changeset is a patch (no authored metadata is refused).
  • Pin: runtime action-package-addressing.test.ts asserts the door reaches the handed-back entry and its owner gate answers 403; both assertions fail on the old code (ablation-checked).
  • Governed: check-governed-merges --pr 33622 NOT governed; 527 changed lines.
  • Checks at this head: Test Core (6/8) failed once in cloud-connection marketplace-install-local-storage-dir.test.ts (5000 ms timeout), a file this PR does not touch, green at 32021b8 and 10/10 locally. Its failed jobs are re-running (attempt 2); auto-merge waits for every required check.
  • Landing: the maintainer's instruction (2026-11-15 03:57Z): PRs in every area that passed review go ready + auto-merge.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 15, 2026 04:42
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/l tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

2 participants