Skip to content

fix(runtime): attribute the package DELETE and clear the disable record in the uninstall verb - #31183

Merged
objectstack-fleet[bot] merged 7 commits into
mainfrom
claude/issue-31023-package-delete-actor
Nov 7, 2026
Merged

objectstack-fleet[bot] merged 7 commits into
mainfrom
claude/issue-31023-package-delete-actor

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by 田騏 · project thread
Fixes #31023
Clause-②: no
Metadata-protocol: none

维护者速读

  • 改了什么:Studio 删除应用时,把当前登录的人传给卸载动作,被删的每条元数据在审计日志和历史里都记下是谁删的;「此包在本环境已停用」的记录改由卸载动作自己清掉,平台内部任何地方调用删除都会清。
  • 为什么改:删除接口原先不传操作人,审计里删除人一栏是空的;cloud 的 AI 工具、本地安装撤销、导入回滚这些内部删除不清停用记录,重启后再装同一个包一装上就是停用。
  • 风险与回滚:只改 runtime;卸载结果的 cleanups 里多一条 runtime.package-state;对一个已不存在的包发删除(404)现在也会清掉同名的停用记录;sys_packages 那一行的删除仍然没有审计行(见下方说明,需席位定夺)。回滚即 revert 本 PR。
  • 先看:packages/runtime/src/package-state-host-store.ts(新的卸载清理)、packages/runtime/src/domains/packages.ts(DELETE 分支的操作人与「卸载动作已清则门不再写」判断)、packages/runtime/src/app-plugin.ts(start 里注册清理)。
  • 两分钟验证:pnpm --filter @objectstack/runtime exec vitest run src/package-state-host-store.test.ts src/domains/packages-write-actor-session.test.ts src/package-uninstall-store-refusal.integration.test.ts,预期三个文件全绿。
  • 需要你做的:无,席位落地。

What changes

  • The actor. DELETE /api/v1/packages/:id now resolves the request's authenticated user with resolvePackageWriteActor (ADR-0146 D1, the one helper its sibling doors use; no second copy) and hands it to protocol.deletePackage as actor. The verb already forwarded actor to each deleteMetaItem, so every metadata delete is now credited: provenance.attributedUserId on the sys_metadata delete (what the audit writer records as sys_audit_log.user_id) and recorded_by on the history tombstone. A caller with no user id sends no actor, as before. No new key: actor was already on DeletePackageRequest.
  • The disable-record clear moves into the verb, through a seam it already runs. @objectstack/metadata-protocol cannot reach the runtime's package-state store without importing @objectstack/runtime, so the clear rides the protocol's uninstall-cleanup registry (registerUninstallCleanup, ADR-0086 D3), which deletePackage runs as its last step and install-local's DELETE runs too. AppPlugin.start registers it once per protocol (ensurePackageStateUninstallCleanup, name runtime.package-state); it resolves the store when it runs (the host's package-state-store service, else the file under OS_HOME) and clears the key the boot seed reads (AppPlugin's project-context environment). A refusing store is that cleanup's failed outcome on the uninstall's cleanups, through the registry's one runner. protocol-package-uninstall.ts is not edited.
  • The door writes the record only when the verb did not. When persisted.cleanups carries the runtime.package-state outcome, the door leaves the record alone; with no persisted half, or a protocol on a kernel that registered no such cleanup (no AppPlugin), it clears the record itself exactly as before.

Tests

  • package-uninstall-store-refusal.integration.test.ts (real ObjectQL + SQLite + protocol + dispatcher): a signed-in admin's DELETE credits u_admin on the audited sys_metadata delete and on the history tombstone; CONTROL: a system caller's DELETE credits no one.
  • packages-write-actor-session.test.ts: the DELETE door hands the verb the session user (with and without keepData); CONTROL: a system context sends no actor.
  • package-state-host-store.test.ts (real kernel, ObjectQLPlugin + AppPlugin + SQLite): an in-process deletePackage clears the file record and a reinstall after a restart comes up enabled; the same with a host store; a refusing host store is the cleanup's failed outcome and the record stays; the HTTP DELETE leaves the clear to the verb (one write, not two).
  • Four existing pins that asserted the exact deletePackage request now expect the signed-in caller's actor beside the unchanged keys (packages-write-flag-arity, packages-write-doors-closed-query, packages-uninstall-refuse-before-mutate, packages-orgless-grants-capability-gate). The edited test files take a module-top import '@objectstack/metadata' (check:test-source-alias).

Acceptance notes

  • Not done, for the seat to decide: the sys_packages delete is not audited at all. sys_packages is not an object; the package service deletes its row with raw SQL through engine.execute, which runs no hooks, so no sys_audit_log row exists for that delete with or without an actor. Attributing it needs a new audit writer or a PackageService.delete signature change, which this card's Clause-②: no does not cover. What the person did is still recorded: each metadata row the uninstall removed carries the actor.
  • A 404 DELETE now clears a record naming the id. The verb runs its cleanups for every id it is asked to uninstall, so a DELETE of an id that is neither installed nor stored clears a disable record naming it. Before, the door wrote nothing on a 404.
  • install-local's DELETE and the two rollbacks also clear the record now, since they reach the same runner ([Decision] the package boot seed set is never updated by enable/disable, so a flag-absent re-install durably reverts an operator later enable once #18752 lands — and the obvious producer fix re-opens #18058 F1 pins #18877 item 3: a package that no longer exists has no lifecycle state).
  • The environment key is the boot seed's, not the request's. On a standalone boot both are unset; a host whose resolver sets a request environment different from AppPlugin's project context would already have its disable door and boot seed disagree.
  • File surface: app-plugin.ts and package-state-host-store.ts (with its test) are outside the claim's declared surface; they are where the seam has to be registered. No new package export (PACKAGE_STATE_UNINSTALL_CLEANUP and ensurePackageStateUninstallCleanup are module-internal; index.ts names its exports).
  • The audit pin reads the hook's provenance.attributedUserId rather than a sys_audit_log row: @objectstack/plugin-audit is not a runtime dependency, and its own tests pin that field into user_id.

Verification

Reverse verification (each mutation landed on disk, then restored to the HEAD blob)
  • A1, the DELETE door sends no actor: 3 red (a signed-in caller's delete names the caller, beside keepData, the caller is still named, a signed-in admin's delete names the admin on the audited delete and on the history tombstone); both CONTROLs stay green.
  • A2, AppPlugin.start registers no cleanup: 3 red (the in-process delete, the host-store clear, the refusing store).
  • A3, the door clears even when the verb did: 1 red (one write, not two).
Local runs
  • pnpm --filter @objectstack/runtime test before the fixture update: 9 failed in 4 files, all the exact-request pins above, fixed in this PR; the seven edited test files then: 7 files, 148 tests passed.
  • pnpm --filter @objectstack/runtime typecheck: exit 0. eslint over packages/runtime with --no-inline-config: exit 0.
  • The derived gate list, run locally: see the report comment on the card.

🤖 Generated with Claude Code

@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 7, 2026
@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/runtime, touching 5 documentable anchor(s).

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

  • content/docs/api/error-catalog.mdx (via /api/v1/packages/:id (route, a path literal in a comment on a changed line))
  • content/docs/deployment/app-dependencies.mdx (via /api/v1/packages/:id (route, a path literal in a comment on a changed line))
  • content/docs/deployment/cli.mdx (via /api/v1/packages/:id (route, a path literal in a comment on a changed line))
  • content/docs/deployment/marketplace-handbook.mdx (via /api/v1/packages/:id (route, a path literal in a comment on a changed line))
  • content/docs/frontend/plugins/plugin-chatbot.mdx (via /api/v1/packages/:id (route, a path literal in a comment on a changed line))
  • content/docs/kernel/contracts/metadata-service.mdx (via /api/v1/packages/:id (route, a path literal in a comment on a changed line))
  • content/docs/permissions/permission-sets.mdx (via /api/v1/packages/:id (route, a path literal in a comment on a changed line))
  • content/docs/permissions/system-context.mdx (via handlePackagesRequest (symbol, a top-level function))
  • content/docs/protocol/kernel/error-handling.mdx (via /api/v1/packages/:id (route, a path literal in a comment on a changed line))

⛔ 5 release-owned page(s) also name something this change touched. These are read-only:

  • content/docs/releases/v17/17-0.mdx (via /api/v1/packages/:id (route, a path literal in a comment on a changed line))
  • content/docs/releases/v17/17-4.mdx (via /api/v1/packages/:id (route, a path literal in a comment on a changed line))
  • content/docs/releases/v18/18-0.mdx (via /api/v1/packages/:id (route, a path literal in a comment on a changed line))
  • content/docs/releases/v18/18-1.mdx (via /api/v1/packages/:id (route, a path literal in a comment on a changed line))
  • content/docs/releases/v18/18-2.mdx (via /api/v1/packages/:id (route, a path literal in a comment on a changed line))

content/docs/releases/ is RELEASE-OWNED (AGENTS.md "Documentation Guardrails"): release
notes are written centrally at release time, and a code PR that edits them is the exact PR
that guardrail exists to stop. They are still audited — read-only. If one of them is actually
wrong, file an issue or open a dedicated docs-only PR; do not edit it here.

What this run could not see
  • 1 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 63 of 226 client-bound route-ledger rows — the other 163 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 163: 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; 104 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 — 28 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 620b6e6d40c4ef11658a658e1d2c6ae3d4aeb7d6 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 35db54d916ed077834d198f0772b894c658dfaf6 — the merge of head 8e7eb94d50f1599394b77e3caed83679090005ab into base 620b6e6d40c4ef11658a658e1d2c6ae3d4aeb7d6, 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 35db54d916ed077834d198f0772b894c658dfaf6 && git checkout 35db54d916ed077834d198f0772b894c658dfaf6
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 620b6e6d40c4ef11658a658e1d2c6ae3d4aeb7d6 8e7eb94d50f1599394b77e3caed83679090005ab && git checkout -B drift-repro 620b6e6d40c4ef11658a658e1d2c6ae3d4aeb7d6 && git merge --no-ff 8e7eb94d50f1599394b77e3caed83679090005ab

node scripts/docs-audit/affected-docs.mjs --json 620b6e6d40c4ef11658a658e1d2c6ae3d4aeb7d6

⚠️ 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 620b6e6d40c4ef11658a658e1d2c6ae3d4aeb7d6 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

… sees the author as the delete's actor

The package DELETE door now hands deletePackage the signed-in user
(ADR-0146 D1), so the exact-argument pin in the createHonoApp
query-multiplicity suite names `actor: 'u_author'` beside `keepData`.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ihL2dLQEXWGsE2SZ3Qn5F
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#4 · marchtian · session_017ihL2dLQEXWGsE2SZ3Qn5F

Test Core (6/8) red on a6f017e7 · packages/qa/http-conformance/src/hono-query-multiplicity.conformance.test.ts:165 (AssertionError): the keepData control pin asserts deletePackage's exact argument and now also receives actor: 'u_author' — this PR's intended change, in a fifth pin outside packages/runtime the dev's scan missed. Fixed by the seat in 8e7eb94d (pin names the author as actor); the file passes locally 7/7 on the built tree. No other exact-argument deletePackage pin found under packages/rest, packages/qa.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#4 · marchtian · session_017ihL2dLQEXWGsE2SZ3Qn5F

席位核对 — ACCEPT · domain:server#4 · Head-sha: 8e7eb94d50f1599394b77e3caed83679090005ab

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 Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

packages: DELETE /api/v1/packages/:id deletes unattributed (no actor), and the in-process deletePackage leaves the per-environment disable record behind

2 participants