Repository navigation
fix(runtime): attribute the package DELETE and clear the disable record in the uninstall verb - #31183
Conversation
…rd in the uninstall verb (wip) Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017ihL2dLQEXWGsE2SZ3Qn5F
…cord clear Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017ihL2dLQEXWGsE2SZ3Qn5F
…verb's disable-record clear Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017ihL2dLQEXWGsE2SZ3Qn5F
…ckage-delete-actor
…-in actor Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017ihL2dLQEXWGsE2SZ3Qn5F
…age-door pins Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017ihL2dLQEXWGsE2SZ3Qn5F
📓 Docs Drift CheckThis PR changes 1 package(s): 9 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 5 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 28 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 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
|
… 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
|
domain:server#4 · marchtian · session_017ihL2dLQEXWGsE2SZ3Qn5F
|
|
domain:server#4 · marchtian · session_017ihL2dLQEXWGsE2SZ3Qn5F 席位核对 — ACCEPT · domain:server#4 · Head-sha:
|
Requested by 田騏 · project thread
Fixes #31023
Clause-②: no
Metadata-protocol: none
维护者速读
sys_packages那一行的删除仍然没有审计行(见下方说明,需席位定夺)。回滚即 revert 本 PR。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
DELETE /api/v1/packages/:idnow resolves the request's authenticated user withresolvePackageWriteActor(ADR-0146 D1, the one helper its sibling doors use; no second copy) and hands it toprotocol.deletePackageasactor. The verb already forwardedactorto eachdeleteMetaItem, so every metadata delete is now credited:provenance.attributedUserIdon thesys_metadatadelete (what the audit writer records assys_audit_log.user_id) andrecorded_byon the history tombstone. A caller with no user id sends noactor, as before. No new key:actorwas already onDeletePackageRequest.@objectstack/metadata-protocolcannot 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), whichdeletePackageruns as its last step and install-local'sDELETEruns too.AppPlugin.startregisters it once per protocol (ensurePackageStateUninstallCleanup, nameruntime.package-state); it resolves the store when it runs (the host'spackage-state-storeservice, else the file underOS_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'scleanups, through the registry's one runner.protocol-package-uninstall.tsis not edited.persisted.cleanupscarries theruntime.package-stateoutcome, the door leaves the record alone; with no persisted half, or a protocol on a kernel that registered no such cleanup (noAppPlugin), 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 creditsu_adminon the auditedsys_metadatadelete 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 withoutkeepData); CONTROL: a system context sends noactor.package-state-host-store.test.ts(real kernel,ObjectQLPlugin+AppPlugin+ SQLite): an in-processdeletePackageclears 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).deletePackagerequest now expect the signed-in caller'sactorbeside 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-topimport '@objectstack/metadata'(check:test-source-alias).Acceptance notes
sys_packagesdelete is not audited at all.sys_packagesis not an object; the package service deletes its row with raw SQL throughengine.execute, which runs no hooks, so nosys_audit_logrow exists for that delete with or without an actor. Attributing it needs a new audit writer or aPackageService.deletesignature change, which this card'sClause-②: nodoes not cover. What the person did is still recorded: each metadata row the uninstall removed carries the actor.DELETEand 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).AppPlugin's project context would already have its disable door and boot seed disagree.app-plugin.tsandpackage-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_CLEANUPandensurePackageStateUninstallCleanupare module-internal;index.tsnames its exports).provenance.attributedUserIdrather than asys_audit_logrow:@objectstack/plugin-auditis not a runtime dependency, and its own tests pin that field intouser_id.Verification
Reverse verification (each mutation landed on disk, then restored to the HEAD blob)
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.AppPlugin.startregisters no cleanup: 3 red (the in-process delete, the host-store clear, the refusing store).one write, not two).Local runs
pnpm --filter @objectstack/runtime testbefore 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 overpackages/runtimewith--no-inline-config: exit 0.🤖 Generated with Claude Code