skillhub/openspec/changes/add-team-auto-publication
小妍儿 ✨ 62219af2fb
feat(publish): opt-in trusted TEAM publisher approval after safe scans (#1069)
* feat(publish): gate trusted TEAM member auto-approval on safe scans

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

* docs: design team-only automatic publication

Replace the draft two-switch policy with member grant identities, scan-bound system decisions and irreversible manual-review fallback. Document scope, locking, API/UI and acceptance boundaries before implementation.

Refs #1068

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

* feat(namespace): manage team-only automatic publication grants

Rewrite unreleased V123 around per-member grant identities and review-task eligibility snapshots. Remove the namespace switch, review-exempt flag and old policy endpoints. Grants are session-only member-management writes; every API token is rejected. Revocation, role change, removal and account merge clear the identity, hand pending eligible tasks to normal review and are audited with before/after values. Automatic approval stays inert until the scan-bound approval path lands.

Refs #1068

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

* feat(publish): capture team-only automatic eligibility on submission

Add TeamAutoPublicationPolicy as the single scope owner. Ordinary submissions capture the active member grant only for a new NAMESPACE_ONLY Skill or a new version of an already NAMESPACE_ONLY Skill owned by the submitter in an ACTIVE TEAM namespace. Uploads that change visibility, PUBLIC, PRIVATE, non-MEMBER roles, GitHub sync and Bundle paths never capture it; rerelease reapplies the same policy. Eligible tasks defer the reviewer notification until fallback.

Refs #1068

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

* feat(review): approve team-only publication after current SAFE scan

Add TeamAutoPublicationService, invoked only by the callback that completes a version's current scan round. It locks namespace, Skill and version, refreshes state, and approves only when the captured grant equals the member's current grant, the account, namespace, Skill and version are still eligible, the task is not superseded and the recorded round is an explicit SAFE verdict. Any other outcome irreversibly hands the task to normal review and emits ReviewSubmittedEvent exactly once.

System decisions record decision_method SYSTEM_AUTOMATIC with the scan task id and no human reviewer; human decisions record HUMAN. Review projections, ReviewApprovedEvent, notifications and business logs expose the method. Replayed or late callbacks are ignored before any state change.

Refs #1068

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

* test(auth): pin team-only publication token matrix to current scopes

Express the maintainer combination matrix with today's skill:read/skill:publish scopes in one place so #1078 can swap the submit capability name. Read-only tokens cannot upload, submit-capable tokens reach the same upload policy as browser sessions, and no scope can grant the permission.

Refs #1068

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

* feat(web): manage team-only automatic publication on member page

Show the per-member grant state on the existing TEAM namespace member page, let owners and admins grant or revoke it through a confirmation dialog, and explain that it covers the member's browser submissions in this namespace and every token with submit capability.

Review list, detail and attempt history label system automatic approvals and their scan basis without naming the submitter as reviewer. Add copy to en, zh, ko and ru, regenerate the OpenAPI schema from a running backend and refresh the analytics manifest.

Refs #1068

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

* docs: document team-only automatic publication

Add Chinese and English user guides for team-only automatic publication, link them from the namespace and review guides and the documentation sidebar, and document the session-only grant endpoint, review decision fields, lifecycle transition and business event attributes. Remove the unreleased trusted TEAM publishers draft guide and mark completed OpenSpec tasks.

Refs #1068

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

* test(app): pin site presentation upgrade check to V122

The upgrade test asserts that exactly one migration runs after V121. Pin the upgrade target to V122 so the new V123 team-only automatic publication migration does not change what this V122 upgrade step proves.

Refs #1068

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

* test(app): cover withdrawal racing team-only automatic approval

Run a submitter withdrawal concurrently with the SAFE scan completion on real PostgreSQL. Withdrawal is rejected while the version is scanning or already settled, and the system decision publishes exactly once without losing its review task.

Refs #1068

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

* docs(openspec): mark team-only automatic publication gates complete

Record that backend, web, OpenAPI drift and strict OpenSpec gates ran, failures were classified against 683decad, and the controlled-scan journey environment was cleaned up.

Refs #1068

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

* fix(namespace): revoke team-only publication on platform admin member changes

Platform admin role changes, member removal and ownership transfer changed namespace_member rows directly, so a granted member promoted to ADMIN and demoted back kept the same grant identity and an in-flight task was approved automatically. These paths now call the shared NamespaceMemberService revocation: clear the grant, hand pending eligible tasks to normal review with one notification each, and audit the platform admin with the before value.

Covered on real PostgreSQL for the role round trip, removal and ownership transfer.

Refs #1068

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

* fix(scan): hand undispatchable scans to normal review

A permanent scan outbox dispatch failure set the version to SCAN_FAILED directly. The scan attempt stayed open, team-only eligibility was not cancelled, reviewers were never notified, and a later SAFE retry published automatically. The dispatcher now settles the attempt through the same SecurityScanService failure path as a scanner failure callback, which cancels eligibility irreversibly and emits ReviewSubmittedEvent once. Outbox rows without a scan attempt keep the previous handling.

Covered on real PostgreSQL: SCAN_FAILED, cancelled, notified once, and a SAFE retry stays in manual review.

Refs #1068

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

* fix(auth): audit team-only publication revocation on account merge

Account merge cleared the merged membership's grant silently; pending tasks only fell back at scan time. Merge now uses the shared NamespaceMemberService revocation for the merged membership and for a surviving membership promoted out of MEMBER, so tasks are handed to normal review immediately and the confirming account is audited.

Refs #1068

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

* chore(db): renumber team-only publication migration to V124

#1078 merges first with its own V123 (suite bundle authorization
snapshot), so this unreleased migration moves to V124. No released
migration is changed.

Refs #1068

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

* test(auth): derive the submit scope in the token matrix from the registry

TeamAutoPublicationTokenMatrixTest hard-coded skill:publish as the scope
that means "may submit". After #1078 splits token capabilities, every
upload route requires skill:submit instead, so the two route-policy rows
of the matrix failed on the integrated tree although the policy itself
is correct (read-only tokens are still rejected; submit tokens are still
admitted on every upload route).

Read the required upload scope from RouteSecurityPolicyRegistry and accept
only the known submit scopes (skill:publish before #1078, skill:submit
after), so the matrix keeps proving the same contract on either base.
Test-only change; no production code is touched.

Refs #1068

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

* chore(db): renumber team-only publication migration to V125

Main now ships V123 (homepage recommendations) and #1078 moved its
suite bundle authorization snapshot to V124, so this unreleased
migration moves to V125. No released migration is changed.

Refs #1068

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

* fix(publish): capture submit authority for team auto publication

Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>

* docs(publish): record maintainer runtime validation

Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>

* docs(publish): clarify upgrade and rollback compatibility

Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>

---------

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>
Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>
Co-authored-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>
2026-11-16 14:08:28 +08:00
..
specs/team-auto-publication feat(publish): opt-in trusted TEAM publisher approval after safe scans (#1069) 2026-11-16 14:08:28 +08:00
design.md feat(publish): opt-in trusted TEAM publisher approval after safe scans (#1069) 2026-11-16 14:08:28 +08:00
proposal.md feat(publish): opt-in trusted TEAM publisher approval after safe scans (#1069) 2026-11-16 14:08:28 +08:00
tasks.md feat(publish): opt-in trusted TEAM publisher approval after safe scans (#1069) 2026-11-16 14:08:28 +08:00