Repository navigation
Commit 6d1dc7f
feat(pm): the fleet-write relay publishes an approved security advisory — reopen, set the versions, publish (#30135)
Fixes #30110
## 维护者速读
- 改了什么:中继(fleet-write)现在能发布安全公告——`advisory_state`
新增「已关闭→草稿」与「草稿→已发布」两种迁移,新增只写版本范围的 `advisory_versions`
一行,发布后回读校验并在运行注释里点名公告编号。
- 为什么改:维护者裁定中继必须能发布(原「发布留给我」一条作废);发布哪些仍由维护者在发版前定清单,中继只执行批准的清单。
- 风险与回滚:发布不可逆、发布即公开;中继在发布前强制要求版本已设、只允许从草稿发布、执行端自读公告再判,任何未知状态一律拒;回滚即还原本
PR(4 个中继脚本 + 3 份技能参考)。
- 先看:`scripts/pm/fleet-write/ops.mjs` 的 `ADVISORY_TRANSITIONS` 与
`ADVISORY_FENCES` 新增的 `versions` 围栏;`execute.mjs` 的 `advisoryPreflight`
/ `confirmAdvisory`;`security-findings.md` 删去的一行(见 Acceptance notes)。
- 两分钟验证:`node scripts/pm/fleet-write/validate.mjs --self-test && node
scripts/pm/fleet-write/execute.mjs --self-test`,预期分别打印 329 与 269 个用例全过。
- 需要你做的:合入后从你批准的发布清单里点一份公告,让席位经中继做首次实发并把运行编号记在本卡。
## What changes
The relay could not publish a security advisory: `published` was refused
by name and `ADVISORY_TRANSITIONS` allowed only `triage → draft` and
`triage|draft → closed`. The maintainer ruled that the relay must
publish (the ruling and the superseded clause are quoted verbatim in the
`ops.mjs` header). What is published stays the maintainer's list,
approved before each release.
- **`advisory_state` gains two transitions.** `closed → draft` (the
reopen; a fixed advisory is closed once its fix merges) and `draft →
published`. Nothing leaves `published` or `withdrawn`. Each move is
still judged on the executor's own GET. A target the table does not name
now has no from-states and fails closed at the state fence (before this
PR, an unknown target would have fallen back to the collaborators' open
states; the validator's enum already kept it out, and now both layers
refuse it).
- **`ADVISORY_REFUSED_STATES` loses `published`** and is empty; the
field's named-refusal hook stays wired.
- **A new row, `advisory_versions`.** It carries `ghsa_id` and
`versions`, a capped list of closed entries: exactly `package` (an npm
name), `vulnerable_version_range` and `patched_versions`. No prose, no
summary or description, no vulnerable functions, no state. The range
takes one comparator, or a lower bound then an upper bound, each an
operator, one space and a release version (GitHub's own example
spelling). The patched list holds one to five release versions. A pair
whose bounds do not rise, a version named twice, and a patched version
inside its own range are refused. The PATCH body is `{ vulnerabilities
}` alone. It travels alone like every advisory row, and its token
carries `repository-advisories: write` for that stroke only.
- **The versions fence.** GitHub's documentation of this PATCH says "To
add vulnerable versions, include existing versions in the array", so the
call replaces the whole list. The executor therefore sends versions only
to a `draft` whose every listed package the action names. A listed entry
of another ecosystem, a nameless one, or one carrying
`vulnerable_functions` (which the row does not write and the PATCH would
drop) is refused with nothing sent. A publish is refused unless the
advisory's GET lists at least one entry and every entry is in the row's
spelling: the versions are set first.
- **The publish read-back.** A publish lands only when the PATCH answer
reads `published` AND lists exactly the entries the preflight GET read
(order ignored), so the advisory is read back as published with the
versions it was sent. A landed publish alone emits a notice annotation
naming the id (public once published). The seat-side reader
(`dispatch.mjs`) parses it, hands it on as `advisories`, and says to
record the run on the seat post. Every other state move stays
unannotated.
- **What crosses the public run.** The versions row and the publish
print the id, the state and counts. They never print a package name or a
version, which belong to the unpublished advisory until the publish.
Refusals never echo a value.
- **Skill references** (`.claude/skills/pm-dispatch/references/`).
`security-findings.md` §3 now says that the seat publishes only the list
the maintainer approved for that release, through the relay, versions
first, recording the run ids on the seat post with no text. §9 says that
the publish list stays the maintainer's. `lanes/security.md` points to
§3 instead of "publish by hand in the UI", per §8's one-place rule.
`rest-channel.md` no longer says that publishing is the maintainer's by
hand. Every file stays at its ratchet ceiling.
**Governed surface:** the diff touches `.claude/**` (Tier S). It lands
on the owning seat's contract-tier review of record, not on green alone.
## Tests
Relay self-tests, at the base `1f13eb3189` and then at this head:
| self-test | base | head | advisory battery floor |
|:--|--:|--:|:--|
| `validate.mjs` | 303 | 329 | 51 → 77 |
| `execute.mjs` | 260 | 269 | 32 → 41 |
| `dispatch.mjs` | 315 | 318 | 14 → 17 |
The pins that said "⛔ published is reachable by NO row" moved with the
ruling. They now say that published is reached by ONE row
(`advisory_state`), through ONE field value, from `draft` alone, through
the versions fence, and that no request any row spells carries it in a
path or a body. The unknown-state cases still fail closed, at the
validator's enum and at the state fence. The executor's marker sweep now
covers 73 runs, up from 46, including every publish and versions run.
The marker reaches no log line, row, summary, annotation or pace log.
**Ablation, one-shot.** Each mutation went through
`scripts/ablation-replace.mjs` (anchor hit 1 → 0, blob changed) and was
restored there (blob == HEAD, `git diff HEAD` empty):
- A: `published` may also leave `closed`. `validate` went red on 2 cases
(the transition table and the fenced transitions). `execute` went red on
1 case: an illegal `closed → published` sent a PATCH.
- B: the fail-closed default removed (an unknown target falls back to
the open states). `validate` went red on 1 case (the unknown target
fails closed). `execute` stayed green: its preflight independently gives
an unknown target no from-states, so the second layer held.
- C: the publish half of the versions fence removed. `validate` went red
on 3 cases. `execute` went red on 1 case: an unversioned publish sent a
PATCH.
## Acceptance notes
- **Measured from documentation, not live.** No advisory was touched
during development. The REST description (operation
`security-advisories/update-repository-advisory`) and the App permission
ledger put `state` (published, closed, draft) and `vulnerabilities`
(package, range, patched versions, functions) on one PATCH, under
`repository_advisories: write` alone, with no additional permission. The
App's PATCH of `state` is already measured live (`triage → draft` and
`draft → closed`, runs 41443030055 and 41443112178). The first live
publish after merge confirms four things: `closed → draft`, `draft →
published` and the versions from the App, the versions answered in the
spelling sent (the read-back compares the strings exactly, so a platform
that normalises them fails closed with nothing re-sent), and whether the
platform needs versions before publishing (the relay needs them either
way).
- **One line deleted to pay the line ratchet.** `security-findings.md`
had zero headroom. Its §2 line "while the relay run log still prints the
whole payload, no mechanism in the relay payload" is conditional on a
state that no longer holds: the relay reads `client_payload` from the
event file and prints none of it (pinned by `validate.mjs`'s event-file
battery and the live marker runs). It also contradicts §3, which routes
the mechanism through `advisory_create`'s payload. If the seat prefers
to keep it, the alternative is a ruled +1 on that file's ceiling.
- **Not edited:** `.github/workflows/fleet-write.yml`'s comment still
lists "FOUR write consumers" of `permission-repository-advisories` and
does not name `advisory_versions`. The mint input itself needs no
change. The comment lives on a Tier H surface, so it was left out of
this Tier S PR.
- `ops.mjs`'s `requests` documentation named a
`confirmAdvisoryCollaborators` that never existed. The sentence was
rewritten to name `confirmAdvisory`.
## Verification
Head `5aa0bddcdc` (the branch merged with `origin/main`): `node
scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` derived 46 families, and all 46 ran locally,
each with its exit captured before any pipe. `--ran` reconciliation: "46
derived famil(ies) accounted for — 46 run, 0 NOT-MEASURED (a DERIVED
zero …)".
<details><summary>Local gate exits</summary>
Every family exited 0. `pnpm --filter @objectstack/lint run
check:doc-formula-expressions` first exited 3 (PREREQUISITE NOT MET:
`@objectstack/formula` and `@objectstack/lint` unbuilt). It exited 0
after `pnpm exec turbo run build --filter=@objectstack/formula
--filter=@objectstack/lint` under the shared verify lock ("VERDICT
command-exit 0"). The relay importers outside the derivation,
`fleet-roster`, `mailbox-open` and `rerun-failed`, were also run with
`--self-test`, and each exited 0.
</details>
Families CI runs beyond the local subset are read from this PR's
check-runs.
## Seat note
- The card's `Claim:` naming this branch was owed by the dispatching
seat at dispatch (step 2) and has now been posted on #30110. This body
edit re-runs `PR-body guards`, which read its absence on the first run.
<!-- signed: security#1 · os-justin · session_01QSeKYn5CmmdShCJifm6WYj
-->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent b83e1d0 commit 6d1dc7f
7 files changed
Lines changed: 714 additions & 190 deletions
File tree
- .claude/skills/pm-dispatch/references
- lanes
- scripts/pm/fleet-write
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
| 50 | + | |
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | 15 | | |
17 | 16 | | |
18 | 17 | | |
| |||
21 | 20 | | |
22 | 21 | | |
23 | 22 | | |
24 | | - | |
| 23 | + | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
63 | | - | |
| 63 | + | |
64 | 64 | | |
0 commit comments