Skip to content

test(runtime): the protocol uninstall door leaves no handler of the package it uninstalls bound - #33844

Merged
objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/area-A5-33624
Nov 15, 2026
Merged

objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/area-A5-33624

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Steedos · project thread

Fixes #33624

Clause-②: no
Metadata-protocol: none

维护者速读

  • 改了什么:只加一个测试文件,钉住"协议卸载门 DELETE /api/v1/packages/ID 卸载后,该包的脚本动作和 body hook 不再在引擎上运行"。没有改任何运行时代码。
  • 为什么改:卡片怀疑这扇门不调用 unbindAppArtifactHandlers,处理器会挂到重启。实测证伪:这扇门能卸的包(经 POST /packages 创作的包)的处理器挂在 metadata-service 名下,卸载时由重载同步撤掉;由运行时绑定器以 app:ID 绑定的包(install-local 安装或代码包)会被这扇门以 422 只读拒绝,根本卸不掉。所以方案 A 不需要,卡片随本测试关闭。
  • 风险与回滚:零运行时风险,只新增测试;回滚即删除该测试文件。
  • 先看:packages/runtime/src/domains/packages-uninstall-handlers-withdrawn.test.ts(两个用例:创作包卸载后动作 404、hook 不再触发、对照包仍运行;绑定器包被 422 拒绝、处理器随包保留)。
  • 两分钟验证:pnpm --filter @objectstack/runtime exec vitest run --maxWorkers=2 src/domains/packages-uninstall-handlers-withdrawn.test.ts,预期 2 passed。
  • 需要你做的:无,席位落地。

What changes

One test file, no runtime code. It answers the card's Step 1 (measure) on a real kernel, through the dispatcher's routes, and pins the answer: the premise does not reproduce, so the card closes with this measurement (the card's own rule: "If it does not reproduce, close this card with the measurement"). Fix A (a runtime.package-handlers uninstall cleanup) is not taken; no uninstall response's cleanups list changes.

The measurement (origin/main d7e1a5a, this branch adds only the pin)

Composition: ObjectKernel + SQL driver (better-sqlite3 in memory) + the real ObjectQLPlugin (engine, registry, protocol, authored resync) + the runtime AppPlugin (default action runner) + HttpDispatcher.dispatch for every call.

  1. A package this door can uninstall is a writable base: installed with POST /api/v1/packages, its script action and body hook saved under it with PUT /api/v1/meta/action|hook/NAME?package=ID. Their handlers are bound under the environment's authored owner metadata-service, never under app:ID. After DELETE /api/v1/packages/ID answers 200 (registryRemoved: true, the action and hook rows in persisted.deleted):
    • the engine lists no holder of the action key ([], was ['metadata-service']);
    • POST /api/v1/actions/OBJECT/NAME/RID answers 404 RESOURCE_NOT_FOUND and the body did not run;
    • a POST /api/v1/data/OBJECT write carries only the CONTROL package's stamp (|q, was |p|q);
    • CONTROL: another authored package's action and hook still run.
  2. A package the runtime binder bound under app:ID, registered through the manifest service with source: 'marketplace' and bound by bindAppArtifactHandlers with install-local's own options (what MarketplaceInstallLocalPlugin's install does): the door answers 422 WRITABLE_PACKAGE_REQUIRED before anything moves (isWritablePackage is false for any id in the engine's manifests; a code boot lands there too). The package stays installed, so its handler and hook stay bound and run, which is correct; its own door (DELETE /api/v1/marketplace/install-local/ID) unbinds them. So the binder's owners never reach this door.

What withdraws the authored handlers (the area's question about the metadata:reloaded announcement from #33546)

Two paths each withdraw them before the door answers; either one is enough on its own:

  • the announcement DELETE makes (announcePackageReload(…, 'uninstalled'), packages.ts), whose metadata:reloaded subscriber in ObjectQLPlugin runs resyncAuthoredHooks + resyncAuthoredActions (a full teardown and rebind of the metadata-service set from the stored rows);
  • the protocol's per-row delete events (onMetadataMutation, state: 'deleted'), which run the same resyncs, fire-and-forget.

The announcement is the one the door awaits, so it is what makes the answer deterministic (see Acceptance notes).

H2 (shared cleanup registry)

It exists and both doors walk it: deletePackage runs runUninstallCleanups at packages/metadata-protocol/src/protocol-package-uninstall.ts:385; install-local's door runs it through protocol.runUninstallCleanups (packages/cloud-connection/src/marketplace-install-local-plugin.ts:3718 → :4107). The runtime registers runtime.package-jobs (app-artifact-handlers.ts:2453), runtime.package-state and runtime.package-datasources there. No runtime.package-handlers exists, and with the measurement above none is needed.

Tests

  • New: packages/runtime/src/domains/packages-uninstall-handlers-withdrawn.test.ts, 2 cases, green.
  • CONTROL through the install-local door: packages/cloud-connection/src/marketplace-install-local-uninstall-handlers.test.ts (the real route handler on a real kernel) 6/6 green on this tree: its uninstall leaves no handler under app:ID.

Ablations (one-time, not kept)

Each leg mutated on disk through scripts/ablation-replace.mjs, objectql legs rebuilt and proved in dist/ with scripts/ablation-dist-preflight.mjs, restored (git status --porcelain empty, --absent on the rebuilt dist/):

Leg Mutation Result
1 no uninstall announcement (packages.ts) green: the delete-event resync still withdraws them
2 no resync on state: 'deleted' mutation events (objectql plugin.ts) green: the announcement alone withdraws them
3 legs 1 + 2 together red: no handler is left under the uninstalled package's action: expected [ 'metadata-service' ] to deeply equal []
4 no read-only refusal on DELETE (packages.ts) red: expected [ 200, undefined ] to deeply equal [ 422, 'WRITABLE_PACKAGE_REQUIRED' ]

Acceptance notes

  • With the announcement ablated the case stays green only because the fire-and-forget delete-event resync finishes before the door answers on this in-memory store; the announcement is the awaited, deterministic path. Not a defect on main (both paths are present), noted for whoever ever touches either.
  • Leg 4 shows the one shape where fix A would matter: were the read-only refusal ever lifted for a registered manifest, the door would answer 200 for a package whose handlers the binder holds under app:ID. Today that shape is unreachable (ADR-0070 refusal), so nothing is filed.

Verification

Local readings: see the os-dev-report comment on #33624 for the gate list with exit codes.

🤖 Generated with Claude Code

https://claude.ai/code/session_01QsR2jTEivi2wogPpeo3xd5

@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

Nothing in this diff resolved to a documentable surface (no symbol, route or SDK anchor derived from 0 changed package(s)), so this run has no opinion about the docs.

What this run could not see

Coarse fallback — 0 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 4b5024de52abdd0b713327e002b9185d7c1cf033 → packageMentionDocs.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#5 · zhuangjianguo · session_01QsR2jTEivi2wogPpeo3xd5

Request: review · PR #33844 · area S3 · Fixes #33624 · head a8b2316

Test-only measurement pin (premise falsified: the protocol uninstall door withdraws authored handlers and hooks; a binder-held app:ID package is refused 422 before anything moves). skip-changeset added by the area in this stroke. Report: comment 6894326244 on #33624.


Generated by Claude Code

@objectstack-fleet objectstack-fleet Bot added the skip-changeset PR has no user-facing published change; bypasses the changeset gate label Nov 15, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#5 · zhuangjianguo · session_01QsR2jTjrNnh6b2BkCXFugM
Review claim (review-a, S3) · head a8b2316 · 2026-11-15T12:31Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#5 · zhuangjianguo · session_01QsR2jTjrNnh6b2BkCXFugM

Review — PASS

Head-sha: a8b2316a243cbc3be61cd689750661047e958081
Reviewer: review-a (areas S1 + S3) · read 2026-11-15T12:33Z
Implemented-by: session_01QsR2jTEivi2wogPpeo3xd5 (area S3 dispatch) · Reviewed-by: session_01QsR2jTjrNnh6b2BkCXFugM

Read at the head: the one test file, card #33624, the DELETE /packages/:id writability gate (requireWritablePackage → isWritablePackage, package-writability.ts), every caller of bindAppArtifactHandlers, and install-local's registration path.

  1. The premise is falsified, and the pin measures it. The card's premise was read from code only. The two-case pin drives the real kernel through HttpDispatcher.dispatch. (a) An authored base's action and hook are withdrawn by the time the door answers (404 RESOURCE_NOT_FOUND, nothing run, the hook no longer fires, no holder left), with another authored package as CONTROL. (b) A binder-held app:<id> package is refused 422 WRITABLE_PACKAGE_REQUIRED before anything moves. Code and status are asserted on every refusal. So fix A is not taken, and closing the card with the measurement is what the card's step 1 prescribes: Fixes #33624 is right.
  2. The area's question: does the 422 leg cover every binder-held owner? Yes. bindAppArtifactHandlers has exactly two callers on the head tree: AppPlugin (code boot, app-plugin.ts) and MarketplaceInstallLocalPlugin (through a dynamic runtime import). Both register the manifest first: AppPlugin through registerApp, and install-local through manifest.register(asMarketplaceRegistration(…), { source: 'marketplace' }), both at install and at the post-restart re-register. registerApp sets engine.manifests for the id (engine-registration.ts), and isWritablePackage answers false for any id in engine.manifests before it reads scope. So no binder-held id reaches the door's delete path. The test's manifest.register stands in for install-local's call; the asMarketplaceRegistration wrapper does not change the id the gate reads.
  3. Ablations. Legs 1 and 2 are each green alone, and only leg 3 (both together) turns the authored case red. That is correct for a pin of the outcome over two redundant paths; the body says the announcement is the deterministic path. Leg 4 (the read-only refusal removed) turns the binder case red. The evidence quotes the red output and a clean restore. Accepted.
  4. Local runtime suite not run on the merged head (lock contention). Accepted: the head's CI check-runs are the evidence, and Test Core is green on this head.
  5. Scope: one new test file under packages/runtime, no source. Test-only takes skip-changeset in this repo, and the label is present. Clause-②: no is right.

Gate to re-run before landing: Check Changeset is red on this head. The run (43711300619) started at 11:56Z, before skip-changeset was added at 12:31Z, and it enforced the changeset check. Re-run that check so it reads the label. Everything else: 34 success, 21 skipped. Landing needs every check green.

No must-fix, no should-fix.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#5 · zhuangjianguo · session_01QsR2jTEivi2wogPpeo3xd5

席位核对

ACCEPT and landing · area S3 · 2026-11-15T12:34Z · head a8b2316a243cbc3be61cd689750661047e958081

Ready + auto-merge under the area S3 landing line (maintainer, project thread, 2026-11-15T11:06Z).


Generated by Claude Code

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 15, 2026 12:35
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 15, 2026
Merged via the queue into main with commit a32d50b Nov 15, 2026
56 of 57 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/area-A5-33624 branch November 15, 2026 12:57
scbdzhwl pushed a commit to scbdzhwl/objectstack-analysis that referenced this pull request Nov 16, 2026
… an unserved verb answers the automation domain, as its bare path does (objectstack-ai#33926)

<!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} -->
_Requested by **Steedos** · [project
thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9UbbCpddLFmKzR39wJWZpkRMCi)_
Fixes objectstack-ai#33026
Clause-②: no
Metadata-protocol: none

## 维护者速读

- 改了什么:独立服务器上,带命名空间地址的
`/automation/:ns/:name/runs`、`/automation/:ns/:name/trigger`、`/automation/trigger/:ns/:name`
收到不支持的方法时,改由自动化领域回答(与不带地址的同一路由一致),不再由传输层回答。
- 为什么改:同一路由因写法不同返回两种错误信封、两种 `Allow`;匿名调用者在带地址写法上拿到 405(暴露路由形状)而不是 401。
- 风险与回滚:只在调度器里多声明三条「领域决定所有方法」的路由;已服务的方法照旧;回滚即还原该 PR。
- 先看:`packages/runtime/src/dispatcher-plugin.ts`
新增的三行声明;`automation-every-verb.hono.integration.test.ts` 的新行与命名空间假数据。
- 两分钟验证:`pnpm --filter @objectstack/runtime exec vitest run
src/automation-every-verb.hono.integration.test.ts`,预期 57/57 通过。
- 需要你做的:无,席位落地。

## What changes

- `registerAutomationRoutes`
(`packages/runtime/src/dispatcher-plugin.ts`) declares three more
patterns through `domainDecidesEveryVerb` (objectstack-ai#24228's mechanism): GET
`/automation/:ns/:name/runs`, POST `/automation/:ns/:name/trigger`, POST
`/automation/trigger/:ns/:name`. These are the addressed shapes
(ADR-0150 D5) of the bare rows that were already declared. A verb the
router cannot route on them now reaches `dispatch()`, so the anonymous
floor answers `401` and the domain's `automationRouteAllow` answers
`405` with `Allow: GET` / `Allow: POST` in the dispatcher's envelope.
- Measured before the change, on a real Hono socket at `1e65a389`:
`DELETE /api/v1/automation/crm/send_digest/runs` answered `405`, `Allow:
GET, HEAD`, with an `error.details` envelope, for a signed-in and an
anonymous caller alike. The bare `DELETE
/api/v1/automation/send_digest/runs` answered the domain's `405 Allow:
GET` (signed in) and `401` (anonymous). The domain itself was never at
fault: dispatched directly, the addressed shapes already answer its
`405` (`automation-addressed-route.test.ts`). The gap was only the
transport declaration. No edit to `runtime/src/domains/automation.ts`.

## Tests

`automation-every-verb.hono.integration.test.ts` (both prefixes):
- Added rows: DELETE / POST / PUT on `/automation/crm/send_digest/runs`,
GET on `/automation/crm/send_digest/trigger` and GET on
`/automation/trigger/crm/send_digest`. Each row has an anonymous `401`
case and a signed-in domain `405` case.
- Added controls: a served POST on both addressed triggers runs the
flow; GET and DELETE on `/automation/no_such_ns/send_digest/runs` answer
the dispatcher's `404 ROUTE_NOT_FOUND`.
- `crm` is installed through an ObjectQL registry double answering the
holder table the address reads.

<details><summary>Ablation, one per declaration
(scripts/ablation-replace.mjs, each restored to the HEAD blob with git
diff HEAD empty)</summary>

- Without `:ns/:name/runs`: `Tests 14 failed | 43 passed (57)`. The
failures are every addressed `/runs` row on both prefixes, plus the
no-namespace DELETE control.
- Without `:ns/:name/trigger`: `Tests 4 failed | 53 passed (57)`. The
failures are the anonymous and signed-in GET on
`/automation/crm/send_digest/trigger`, on both prefixes.
- Without `trigger/:ns/:name`: `Tests 4 failed | 53 passed (57)`. The
failures are the anonymous and signed-in GET on
`/automation/trigger/crm/send_digest`, on both prefixes.

</details>

## Acceptance notes

- Same behaviour on a `createHonoApp` host (catch-all): it already
handed every verb to `dispatch()`. No change there.

## Verification

Readings at `9bdd492b`, the head before the last `origin/main` merge.
That merge brought no change to the three files here.
- `pnpm --filter @objectstack/runtime typecheck`: exit 0.
- `pnpm --filter @objectstack/runtime test`: `Test Files 603 passed
(603) / Tests 10934 passed | 19 skipped`.
- Direct dependents exercising the dispatcher on Hono:
`@objectstack/http-conformance` test, `Test Files 20 passed / Tests 292
passed`. `@objectstack/client` `package-addressing.test.ts`, `83
passed`.
- `automation-every-verb.hono.integration.test.ts`: `57 passed (57)`.
- eslint on both touched `.ts` files: exit 0.
- `dispatch-gates --commands`: 67 run, reconciled with `--ran` (67
derived, 67 run). 65 exit 0. Two NOT MEASURED on prerequisites:
`check:dual-build-cjs-loads` needs a full `pnpm build`;
`check:type-check-debt`'s inner build never got the lock.

Final head `39826829` (merge of `origin/main`, which carries objectstack-ai#33721 and
objectstack-ai#33844 in `packages/runtime`): the scoped re-check (closure build,
runtime typecheck, the every-verb, addressed-route, contract-mounts,
clone-mount and route-ledger suites) is NOT MEASURED. The shared verify
lock was held by another worktree's run for over 27 minutes. CI's Test
Core runs the package on this head.

---

_Generated by [Claude
Code](https://claude.ai/code/session_01QsR2jUZKdq3PK2Sab53cT3)_

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/m skip-changeset PR has no user-facing published change; bypasses the changeset gate tests

Projects

None yet

1 participant