Repository navigation
Commit 1f8ce6e
fix(runtime,plugin-security): the declared-webhook activation door switches one of two holders a namespace cannot tell apart, and the upgrade report names each withheld holder (#33204)
epic:#31527#3 · os-tesla · session_01L9qibzECS2npZFku4956Um
<!-- claude-projects-attribution: {"github_login":"os-tesla"} -->
_Requested by **Tesla** · [project
thread](https://claude.ai/code/project/chan_01AXsQkLFKRdQCqQ3RTr6Jao?thread=cmsg_01AXsQkLFKRdQCqQ3RTr6JaoMEcsa8u1Ymjwvb5h8WsfW2)_
Refs #33016 (items 1, 2, 3, 4, 5, 6, 8)
Clause-②: yes (widening)
Metadata-protocol: none
## 维护者速读
- 改了什么:声明式 webhook 的激活门 `POST /security/_activation/webhook/NAME` 新增
`?package=PKG`
精确限定,能单独开关同名的两个持有者之一;升级影响报告对每个持有者(含被禁用的第二个)各报一条,并给出该持有者的开关地址
`?package=PKG`(被禁用的持有者须先启用其包再开关);两条平台测试清单与 liveness 证据改到新的
`declared:PKG/NAME` 引用。
- 为什么改:同一命名空间的两个共有包(或无命名空间的包旁边另有持有者)同时声明一个 webhook
名时两者都在派发,但裸地址与命名空间地址都只答 409,运维无法单独关掉其中一个;两条清单项会把正确的产品判失败。
- 风险与回滚:只放宽一个原本 400 的查询参数,其余答复不变;回滚即 revert 本 PR,不涉及数据迁移。
-
先看:`packages/runtime/src/domains/catalog-activation.ts`(`resolveExactWebhook`
与查询集)、`packages/plugins/plugin-security/src/upgrade-impact-report.ts`(`webhookShippers`)、`packages/runtime/src/domains/catalog-activation-door.test.ts`。
- 两分钟验证:`pnpm --filter @objectstack/runtime exec vitest run
src/domains/catalog-activation-door.test.ts`,应见两个注册顺序下 `?package=`
各写自己的一行、两扇门都 409 点名双方。
- 需要你做的:无,席位落地。
## What changes
**Item 1 (S1), the door.** Two holders the namespace address cannot tell
apart, two co-owners of one namespace or a package that declares no
namespace beside another holder, are both served and both dispatched,
and both `webhook/NAME` and `webhook/NS/NAME` answer `409` naming both,
so neither could be switched. The bare address now takes `?package=PKG`
(`resolveExactWebhook`, `WEBHOOK_DOOR_QUERY_PARAMS` in
`packages/runtime/src/domains/catalog-activation.ts`), the exact
qualifier `/meta` reads (ADR-0150 D2) and the permission-set door
already takes: it addresses exactly PKG's served declaration and writes
PKG's own `(webhook, package_id, name)` row
(`WEBHOOK_LEDGER_ADDRESSING`), the row naming no package left as it is
under two holders and taken over under one (D8,
`webhookAdoptsPackageless`). A PKG that does not serve the name, a
disabled one included, is `409 RESOURCE_CONFLICT`
`not-held-by-qualifier` naming the served holders, or `404` when nothing
serves it. `package` is the one query parameter of the bare webhook
address (AGENTS route rule 5, read by the shared
`readPermissionSetPackageQuery`); the namespace address takes none.
FROM → TO rows (Clause-② widening):
- `POST /security/_activation/webhook/NAME?package=PKG`, PKG serving
NAME: FROM `400 VALIDATION_ERROR` (unknown query parameter) TO `200`,
PKG's row written, `data.packageId` = PKG.
- Same, PKG not serving NAME: FROM `400` TO `409 RESOURCE_CONFLICT`
naming the holders (or `404` when no enabled package declares NAME).
Nothing written.
- `POST /security/_activation/webhook/NS/NAME?package=…`: `400` before
and after.
**Item 2 (S3).** Pinned: B disabled beside A enabled, B's namespace
address is `409` naming A (no code change).
**Item 3 (S5).** `integration-system.webhook-lifecycle` (steps[1]) and
`cli.organization-ownership-ceremony` (acceptance[5].verify) expect
`ref_id declared:com.example.showcase/showcase_task_changed`, as
`packages/qa/dogfood/test/upgrade-18x-harness.dogfood.test.ts` pins;
each item's revision and history bumped.
**Item 4 (nit 1).** `packages/spec/liveness/webhook.json` `name`
evidence: one slot per served `(package, name)` holder and
`declaredWebhookRefId(name, packageId)`.
**Item 5 (nit 2).** The upgrade-impact report's switch line
(`SWITCH_DOORS`) and withheld-webhook line name
`webhook/NAME?package=PACKAGE`, where they named the namespace address.
It addresses the finding's package whatever its namespace, once that
package is enabled: a disabled package holds nothing for the door, so
its address answers `409` until it is enabled again (item 6). Every
webhook finding names a package (a re-enablement's row records one, a
withheld webhook's holder is a package), so the line carries no
bare-address arm.
**Item 6 (nit 3).** `webhookShippers` also counts each holder
`packageScopedHoldersOf(…, { includeDisabledPackages: true })` answers,
confirmed against its own code artifact (`shipsAt`), so a disabled
second holder gets its withheld finding. FROM one finding (the holder
the bare artifact lookup answered) TO one finding per holder. A disabled
holder's finding is marked `packageDisabled: true` (an added optional
field), and the withheld-webhook line says such a package must be
enabled first, then switched at `?package=PACKAGE`, so the line never
sends the operator to a door that answers `409`.
**Item 7.** Not in this PR: a security item is with the owner seat.
**Item 8 (nit 4).** Pinned: one holder with its own row beside a row
naming no package, the bare address writes the holder's own row (no code
change).
**Responsibility.** Producing code: the runtime activation door
(`handleCatalogActivationWrite`) and plugin-security's boot report
(`collectUpgradeImpactFindings`). Existing platform path: none switched
one of two holders a namespace cannot tell apart; a package disable or a
hand-written ledger row were the only stops. Reached by: an operator
(`manage_metadata`, the platform operator under a wall) whose deployment
holds two such webhook holders, rare; the report and checklist lines by
every boot and every checklist run.
**Rulings quoted.** Epic ruling 6842178655 on PR #32577 ("Follow-up card
(p2), not this PR") files these items; ADR-0150 D2 (`?package=` is the
exact qualifier), D4 (one row per holder), D5 (qualified addresses), D8
(a row naming no package is the one holder's). Surface grep
`ruling|Ruling-ref|maintainer|⛔` hits: `catalog-activation.ts` 8
(ADR-0131 seeder ruling, #22621 → A, ADR-0150 D2 ruling, epic ruling MF1
×3, four ⛔ door limits), `upgrade-impact-report.ts` 1 (the ruling on
#24443), `webhook.json` 3 (the #7131 previews ruling, the spec-only
override note); none is touched by this diff.
**File-surface breaches (seat extended the surface):**
`packages/runtime/src/route-ledger.ts` (one sentence on the
`webhook/:ns/:name` row naming `?package=`) and
`content/docs/automation/webhooks.mdx` (one sentence naming the exact
qualifier).
## Red lines
1. **Resolution is never loosened.** The bare and namespace addresses of
two holders still refuse `409` naming both, in both registration orders
(`catalog-activation-door.test.ts` › `[FROM 409 TO switched] …
registered alpha, beta` and `… registered beta, alpha`); `?package=`
resolves only an exact served holder and refuses every other PKG naming
the holders (`… a package that does not hold the name is 409 …`, `… a
disabled package holds nothing …`); the bare read of two co-owners still
throws the 409 naming both (`declared-webhooks.test.ts` › `two co-owners
of one namespace, registered alpha, beta` / `beta, alpha`).
2. **Ambiguity is reported, never guessed.** Under two holders a
`?package=` write never takes over the row naming no package (`[null,
false]` kept beside the holder's own row in both orders); the report
names each holder rather than the first one found
(`upgrade-impact-report.test.ts` › `[FROM one TO each] registered
com.acme.crm, com.acme.addon …` and the reversed order).
3. **Independently releasable.** The phase-1 one-holder pins stay green
(`CONTROL — one holder: the bare address answers as before …`, `CONTROL
— one holder: its namespace address writes the same row`, `CONTROL — one
holder: \`?package=\` writes the row the bare address writes …`, `[FROM
409 TO written] one holder with its own row beside a row naming no
package …`); bare-name URL behaviour is unchanged (every pre-existing
door test unmodified and green); no migration and no ADR-0087 entry: no
stored shape or authorable key moves.
## Tests
- New: `catalog-activation-door.test.ts` 10 cases (S3, the `?package=`
describe ×8: two co-owners of one namespace and a package with no
namespace beside a holder, each in both orders, nit 4);
`declared-webhooks.test.ts` 4 (two co-owners, and a package with no
namespace beside a namespaced holder, each in both orders: both
dispatched under their own ids, the bare read refused naming both);
`upgrade-impact-report.test.ts` 2 (disabled second holder, both orders,
its finding marked `packageDisabled` and the line saying to enable
first) + 1 rewritten (the remedy names the exact-qualifier address and
no bare-address arm).
- Ablations (each mutation landed on disk via
`scripts/ablation-replace.mjs`, test imports resolve to `src/`, restored
blob == HEAD):
- the webhook query set put back to empty ⇒ 7 red (`registered alpha,
beta`, `registered beta, alpha`, `a package with no namespace beside a
holder` ×2, `a package that does not hold the name …`, `a disabled
package holds nothing …`, `CONTROL — one holder: ?package= …`);
- the disabled-holder count removed from `webhookShippers` ⇒ 2 red (both
registration orders);
- the namespace address put back in the switch line ⇒ 1 red (`… the
remedy names the exact-qualifier address`);
- the `packageDisabled` mark removed, or the enable-first sentence
removed from the line ⇒ 2 red each (both registration orders).
## Acceptance notes
- `plugin-webhooks`' own remedies (the name guard and the redelivery
veto, `declaredWebhookActivationPath`) still name the slot's namespace
address, as ruled for #31699 round 2; for two co-owners of one namespace
that address answers `409`, and `?package=` is the one that switches.
Not changed here (a ruled text); the seat files the follow-up.
- Measured, no code change: the environment's own declaration (no
package) beside a packaged holder of the same name. In the registry (the
booted shape) a package-less entry beside one packaged holder is that
holder's customization (ADR-0150 D3), not a second holder: one slot,
switchable as before. Beside two packaged holders it binds to no
package, is in neither slot and is not dispatched. When the declarations
come from the metadata service (no registry item), the name is refused
whole: neither declaration is dispatched, the bare address answers `409`
naming the environment and the package, `?package=PKG` and the namespace
address answer `404`, nothing is written. No holder has a working switch
there, and nothing is delivered either. Left to the seat.
- Item 7's probe result is with the owner seat.
## Verification
All readings at head `0afa1e462` (the review's patch round on
`c68c098f0`; branch base `4c152685`, `origin/main` `f45c0125` merged
once; full `pnpm build` green at `c68c098f0`, 119/119 tasks).
<details><summary>Tests and typecheck</summary>
- `pnpm --filter @objectstack/runtime typecheck && test`: Test Files 597
passed (597), Tests 10619 passed, 19 skipped; lock VERDICT command-exit
0.
- `pnpm --filter @objectstack/plugin-security test`: Test Files 267
passed, Tests 6607 passed (45 skipped); `pnpm --filter
@objectstack/plugin-webhooks test`: Test Files 25 passed, Tests 296
passed.
- `typecheck` of `@objectstack/runtime`, `@objectstack/plugin-security`,
`@objectstack/plugin-webhooks`: exit 0.
</details>
<details><summary>Gates</summary>
- `node scripts/pm/dispatch-gates.mjs --commands` derived 105 families
(the same 105 as at `c68c098f0`); all 105 run with stdin closed, every
exit code 0; `--ran` reconciliation: 105 derived, 105 run, 0
NOT-MEASURED, 0 UNRUN.
- Outside the derivation, also run: `pnpm lint` exit 0; `pnpm --filter
@objectstack/spec check:generated` exit 0.
- At `c68c098f0` the first run (before the merge) found two real
problems, fixed in `95e17a456`: `check:platform-checklist` wanted each
item's top-level `revision` bumped with its history entry. Its three
exit-3 prerequisite refusals (`check:skill-examples`,
`check:dual-build-cjs-loads`, the teardown-shape self-test's fixture
commit) and `check:dts-closure` were local build-state, cleared by the
full build and the fixture fetch; all four exit 0 on the final run.
</details>
<details><summary>Ablations</summary>
Each via `node scripts/ablation-replace.mjs` (anchor 1 → 0 on disk,
restored blob == HEAD, `git diff HEAD` empty); the suites import `src/`
directly.
1. `catalogActivationQueryParams`: the webhook bare address's `package`
taken away ⇒ `catalog-activation-door.test.ts` 7 failed / 84 passed.
2. `webhookShippers`: the disabled-holder loop's add removed ⇒
`upgrade-impact-report.test.ts` 2 failed / 43 passed (at `c68c098f0`;
the loop is unchanged since).
3. `WEBHOOK_SWITCH_DOOR`: the namespace address put back ⇒ 1 failed / 44
passed.
4. The withheld finding's `packageDisabled` spread deleted ⇒
`upgrade-impact-report.test.ts` 2 failed / 43 passed.
5. The enable-first sentence of the withheld-webhook line replaced ⇒ 2
failed / 43 passed.
</details>
dogfood_battery: not run (no `!` in the title and no `(narrowing)` arm).
---
_Generated by [Claude
Code](https://claude.ai/code/session_01L9qibxGWY9FF7Lgr4CiTa3)_
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01L9qibxGWY9FF7Lgr4CiTa3
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 6e1ab9b commit 1f8ce6e
11 files changed
Lines changed: 387 additions & 32 deletions
File tree
- .changeset
- content/docs/automation
- docs/qa/platform-checklist/areas
- packages
- plugins
- plugin-security/src
- plugin-webhooks/src
- runtime/src
- domains
- spec/liveness
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
96 | | - | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
97 | 101 | | |
98 | 102 | | |
99 | 103 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2080 | 2080 | | |
2081 | 2081 | | |
2082 | 2082 | | |
2083 | | - | |
| 2083 | + | |
2084 | 2084 | | |
2085 | 2085 | | |
2086 | 2086 | | |
| |||
2145 | 2145 | | |
2146 | 2146 | | |
2147 | 2147 | | |
2148 | | - | |
| 2148 | + | |
2149 | 2149 | | |
2150 | 2150 | | |
2151 | 2151 | | |
| |||
2222 | 2222 | | |
2223 | 2223 | | |
2224 | 2224 | | |
| 2225 | + | |
| 2226 | + | |
| 2227 | + | |
| 2228 | + | |
| 2229 | + | |
| 2230 | + | |
2225 | 2231 | | |
2226 | 2232 | | |
2227 | 2233 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
588 | 588 | | |
589 | 589 | | |
590 | 590 | | |
591 | | - | |
| 591 | + | |
592 | 592 | | |
593 | 593 | | |
594 | 594 | | |
| |||
615 | 615 | | |
616 | 616 | | |
617 | 617 | | |
618 | | - | |
| 618 | + | |
619 | 619 | | |
620 | 620 | | |
621 | 621 | | |
| |||
770 | 770 | | |
771 | 771 | | |
772 | 772 | | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
773 | 779 | | |
774 | 780 | | |
775 | 781 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
158 | 162 | | |
159 | 163 | | |
160 | 164 | | |
| |||
398 | 402 | | |
399 | 403 | | |
400 | 404 | | |
401 | | - | |
| 405 | + | |
402 | 406 | | |
403 | 407 | | |
404 | 408 | | |
| |||
411 | 415 | | |
412 | 416 | | |
413 | 417 | | |
414 | | - | |
415 | | - | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
416 | 449 | | |
417 | 450 | | |
418 | 451 | | |
| |||
0 commit comments