fix(plugin): verify native support only for changes that run a command (#873)

* fix(plugin): verify native support only for changes that run a command

prepareChange probed native command support before applying the
intentional skip rules. When the probe failed under update --all, the
change was marked as a failed target, so the later skip never applied.
An imported Grok plugin always hit this: Grok updates require native
trust, so every update --all exited nonzero even though Grok plugins are
documented as updated natively. #853 patched the same ordering for
imported OMP plugins only.

Run the probe after the skip rules instead, so a skipped change is never
verified, and drop the OMP-specific exemption it made redundant. Host
errors and changes that do run a native command still fail as before.

* docs(plugin): align OMP removal wording and runbook pass criteria

The translated plugin references said OMP removal requires a
scope-matching native registration. English, and the code, only require
that a registration match when one is present; a retry after native
uninstall proceeds from the retained cache. The runbook's Pass Criteria
also did not cover the two scenarios #853 added as steps 4 and 5.
This commit is contained in:
Willie
2026-11-12 14:09:10 +08:00
committed by GitHub
parent caa107b880
commit 0939eb9ad9
7 changed files with 64 additions and 14 deletions
@@ -280,3 +280,5 @@ foreign registrations, links and cache bytes remain unchanged. Reinstall uses a
fresh identity, and no extension executes during management.
A second machine completes a source replacement in one reviewed sync; direct source edits also reconcile through update. Shared intent and retained cache remain intact.
Removal follows a verified native registry version that differs from the binding and keeps both caches. A batch update reports the unverifiable OMP target as failed, exits nonzero in dry run and apply, and still updates the healthy target without changing OMP's registry.
+48
View File
@@ -318,3 +318,51 @@ func TestNativeReplacementPreservesDisabledInstallation(t *testing.T) {
}
}
}
func TestImportedGrokPluginIsSkippedByUpdateAll(t *testing.T) {
home := t.TempDir()
t.Setenv("HOME", home)
s := &Service{ConfigPath: filepath.Join(home, "config.yaml"), StateDir: filepath.Join(home, "state")}
s.Run = func(_ context.Context, _ string, _ []string, _ string, args ...string) ([]byte, error) {
switch command := strings.Join(args, " "); command {
case "--version":
return []byte("1.0.0"), nil
case "plugin list --json":
return []byte(`[{"name":"demo","enabled":true,"version":"1.0.0"}]`), nil
default:
return nil, fmt.Errorf("unexpected command: %s", command)
}
}
applyPluginRequest(t, s, Request{Action: "import", From: "grok", Plugin: "demo"})
// Grok updates natively, so an imported plugin is an intentional skip, not a failed target.
r := Request{Action: "update", All: true}
plan, err := s.Preview(context.Background(), r)
if err != nil || len(plan.Changes) != 1 || plan.Changes[0].Action != "skip" || plan.Changes[0].Failed || plan.Changes[0].MessageKey != "plugins.skip.imported" {
t.Fatalf("imported Grok update should be an intentional skip: %+v %v", plan.Changes, err)
}
result, err := s.Apply(context.Background(), r, plan.Revision)
if err != nil || len(result.Results) != 1 || result.Results[0].Status != "skipped" {
t.Fatalf("imported Grok update failed: %+v %v", result, err)
}
}
func TestGrokInstallStillRequiresNativeTrust(t *testing.T) {
home := t.TempDir()
t.Setenv("HOME", home)
s := &Service{ConfigPath: filepath.Join(home, "config.yaml"), StateDir: filepath.Join(home, "state")}
s.Run = func(_ context.Context, _ string, _ []string, _ string, args ...string) ([]byte, error) {
switch command := strings.Join(args, " "); command {
case "--version":
return []byte("1.0.0"), nil
case "plugin list --json":
return []byte(`[]`), nil
default:
return nil, fmt.Errorf("unexpected command: %s", command)
}
}
plan, err := s.Preview(context.Background(), Request{Action: "add", Source: fixture(t), Targets: []string{"grok"}})
if err != nil || !plan.Blocked || len(plan.Changes) != 1 || plan.Changes[0].Action != "blocked" || !strings.Contains(plan.Changes[0].Message, "native trust") {
t.Fatalf("a Grok install that runs a native command must still be verified: %+v %v", plan.Changes, err)
}
}
+7 -7
View File
@@ -710,13 +710,6 @@ func (s *Service) prepareChange(ctx context.Context, r Request, d *document, hos
if h.Error != "" && c.Action != "blocked" && c.Action != "skip" {
failChange(h.Error, h.ErrorKey, h.ErrorArgs)
}
// Source-less OMP updates are skipped below; they do not need native upgrade support.
importedOMPUpdate := agent == "omp" && c.Action == "update" && c.Binding.Source == ""
if !importedOMPUpdate && c.Action != "blocked" && c.Action != "noop" && c.Action != "forget" && c.Action != "skip" && c.Action != "import" && c.Action != "update-available" && c.Action != "native-check" {
if err := s.verifyCommand(ctx, c.Target, c.Action, c.ID); err != nil {
failChange(err.Error(), "", nil)
}
}
// An update that cannot reach a target skips it, so the plugin's other Agents still update.
skip := func(key, message string, args map[string]string) {
c.Action = "skip"
@@ -807,6 +800,13 @@ func (s *Service) prepareChange(ctx context.Context, r Request, d *document, hos
}
}
}
// Only changes that will run a native command need native support; an intentional skip above
// is not a failed target.
if c.Action != "blocked" && c.Action != "noop" && c.Action != "forget" && c.Action != "skip" && c.Action != "import" && c.Action != "update-available" && c.Action != "native-check" {
if err := s.verifyCommand(ctx, c.Target, c.Action, c.ID); err != nil {
failChange(err.Error(), "", nil)
}
}
// Skips above are not native commands; what is left for omp must not destroy a shared cache.
if agent == "omp" && h.Error == "" {
ompGuard(h, &c)
@@ -161,8 +161,8 @@ plugin 設定は保持され、cache のガベージコレクションは行い
別の project が使っている可能性のあるファイルは置き換えられません。読み取れない、
リンクである、またはディレクトリでない cache の配置先は引き続きブロックされます。登録済みの所有 marketplace へのインストール前にはカタログを更新します。
削除には、検証済みの 18.6.1+ メタデータ契約、binding のバージョンが異なる場合でも、検証済みのバージョンと cache パスを持つスコープ一致のネイティブ登録、
曖昧さのない JSON、そして証明されたランタイムリンクの所有権が必要です。実際のモジュールフォルダー、
削除には、検証済みの 18.6.1+ メタデータ契約、曖昧さのない JSON、そして証明されたランタイムリンクの所有権が必要です。
ネイティブ登録が存在する場合は、binding のバージョンが異なっていても、スコープが一致し、検証済みのバージョンと cache パスを持つ必要があります。実際のモジュールフォルダー、
他者のリンク、npm 依存関係の衝突、曖昧なランタイム所有者は拒否されます。
cache のマニフェストがない場合、アダプタは、スコープ内のリンクがそのインストールの cache を指す一意のランタイムロックキーを要求します。
マーケットプレイス名を推測することはなく、実際のランタイムリンクがまだインストールされたまま成功を報告することもありません。
@@ -132,7 +132,7 @@ skillshare plugin import demo@my-market --from omp --dry-run --json -g
**OMP 18.6.1+의 공유 cache 제한:** 네이티브 uninstall과 upgrade는 다른 프로젝트가 아직 참조하는 plugin cache 파일을 삭제하거나 교체할 수 있습니다. 네이티브 inventory는 사용자 레지스트리와 현재 프로젝트의 레지스트리만 나열하므로, 다른 프로젝트에 대해 이 작업이 안전한지 확인할 수 없습니다. Skillshare는 이런 파괴적인 명령을 호출하지 않습니다. **Remove**와 disable 후 sync는 대신 scope 단위 adapter를 사용해 해당 설치의 레지스트리 항목, 런타임 선택, 검증된 `node_modules` 링크를 삭제합니다. plugin은 단순히 비활성화되는 것이 아니라 그 scope에서 제거됩니다. 공유 cache, marketplace, plugin 설정은 유지되며 cache garbage collection은 시도하지 않습니다. 이전 cache가 아직 남아 있으면 재설치 시 다른 프로젝트가 사용할 수 있는 파일을 교체하지 않고 새로운 marketplace/cache identity를 자동으로 선택합니다. 읽을 수 없거나, 링크이거나, 디렉터리가 아닌 cache 대상 경로는 계속 차단됩니다.
제거하려면 검증된 18.6.1+ 메타데이터 계약, binding 버전이 다르더라도 검증된 버전과 cache 경로를 가진 scope 일치 네이티브 등록, 모호하지 않은 JSON, 증명된 런타임 링크 소유권이 필요합니다. 실제 모듈 폴더, 외부 링크, npm dependency 충돌, 모호한 런타임 소유자는 거부됩니다. 이미 등록된 소유 marketplace에 설치하기 전에 카탈로그를 갱신합니다. cache manifest가 없으면 adapter는 scope-local 링크가 해당 설치의 cache를 가리키는 고유한 runtime-lock 키를 요구합니다. marketplace 이름을 추측하지 않으며, 실제 런타임 링크가 여전히 설치된 상태에서 성공을 보고하지도 않습니다. 검증할 수 없는 활성 설치는 계속 차단됩니다. 네이티브 uninstall이 이미 cache, 등록, 런타임 링크/선택을 제거했다면 Forget은 오래된 Skillshare binding만 삭제합니다. 다른 plugin의 `node_modules` 디렉터리는 이를 막지 않습니다. 네이티브 파일이 바뀌면 미리보기는 무효가 됩니다. 일부만 완료된 제거는 전체 네이티브 설정 백업을 저장하지 않고 유지된 cache와 binding identity에서 다시 시도할 수 있습니다. Windows에서 쓰려면 추가로 검증 가능한 비공개 ACL이 필요합니다. Skillshare는 통과시키기 위해 권한을 변경하지 않습니다. extension 코드는 실행되지 않습니다.
제거하려면 검증된 18.6.1+ 메타데이터 계약, 모호하지 않은 JSON, 증명된 런타임 링크 소유권이 필요합니다. 네이티브 등록이 있으면 binding 버전이 다르더라도 scope가 일치하고 검증된 버전과 cache 경로를 가져야 합니다. 실제 모듈 폴더, 외부 링크, npm dependency 충돌, 모호한 런타임 소유자는 거부됩니다. 이미 등록된 소유 marketplace에 설치하기 전에 카탈로그를 갱신합니다. cache manifest가 없으면 adapter는 scope-local 링크가 해당 설치의 cache를 가리키는 고유한 runtime-lock 키를 요구합니다. marketplace 이름을 추측하지 않으며, 실제 런타임 링크가 여전히 설치된 상태에서 성공을 보고하지도 않습니다. 검증할 수 없는 활성 설치는 계속 차단됩니다. 네이티브 uninstall이 이미 cache, 등록, 런타임 링크/선택을 제거했다면 Forget은 오래된 Skillshare binding만 삭제합니다. 다른 plugin의 `node_modules` 디렉터리는 이를 막지 않습니다. 네이티브 파일이 바뀌면 미리보기는 무효가 됩니다. 일부만 완료된 제거는 전체 네이티브 설정 백업을 저장하지 않고 유지된 cache와 binding identity에서 다시 시도할 수 있습니다. Windows에서 쓰려면 추가로 검증 가능한 비공개 ACL이 필요합니다. Skillshare는 통과시키기 위해 권한을 변경하지 않습니다. extension 코드는 실행되지 않습니다.
adapter는 Skillshare의 제거 작업을 직렬화하고 네이티브 파일 revision을 확인하지만, OMP의 plugin 명령은 그 lock에 참여하지 않습니다. 네이티브 plugin 변경을 동시에 실행하지 마세요. 이것은 여러 파일에 걸친 atomic 네이티브 트랜잭션이 아닙니다. 업데이트는 OMP의 네이티브 upgrade를 실행하지 않습니다. 같은 adapter로 이 scope의 등록을 제거한 뒤 검토한 commit을 새 cache identity에 설치하므로, 유지된 cache는 다른 프로젝트를 위해 남습니다. 제거를 검증할 수 없으면 업데이트는 차단되고, `update --all`은 이유와 함께 실패를 보고하고 다른 대상을 계속 처리합니다. import된 코드는 검토한 source 없이 업그레이드되지 않습니다.
@@ -171,8 +171,8 @@ Catalog 优先使用 `.omp-plugin/marketplace.json`,仅在 OMP catalog 不存
当旧 cache 仍存在时,重新安装会自动选择新的 marketplace/cache 身份,不会替换其他项目可能使用的
文件。无法读取、是链接或不是目录的 cache 目标位置仍会被阻止。安装到已注册且归属已验证的 marketplace 前会刷新目录。
移除需要经过验证的 18.6.1+ 元数据契约、作用域相符且版本和 cache 路径经过验证的原生注册(即使绑定版本不同)、无歧义的 JSON,以及已证实的运行时链接
所有权。真实的模块文件夹、外部链接、npm 依赖冲突或无法确定的运行时拥有者都会被拒绝。如果 cache
移除需要经过验证的 18.6.1+ 元数据契约、无歧义的 JSON,以及已证实的运行时链接所有权。
若存在原生注册,即使绑定版本不同,它也必须作用域相符,且版本和 cache 路径经过验证。真实的模块文件夹、外部链接、npm 依赖冲突或无法确定的运行时拥有者都会被拒绝。如果 cache
manifest 缺失,适配器会要求一个唯一的 runtime-lock key,且其作用域本地链接指向该安装的 cache;
它绝不会猜测 marketplace 名称,也不会在实际运行时链接仍然安装的情况下报告成功。无法验证的有效
安装仍会被阻止。如果原生 uninstall 已经移除了 cache、注册和运行时链接/选择,Forget 只会丢弃过时的
@@ -170,8 +170,8 @@ runtime 選取以及經過驗證的 `node_modules` 連結。Plugin 會從該 sco
重新安裝會自動選擇新的 marketplace/cache 身分,不會取代其他 project 可能使用的檔案。
無法讀取、被連結或不是目錄的 cache 目的地仍會被擋下。安裝至已註冊且歸屬已驗證的 marketplace 前會重新整理目錄。
移除需要經過驗證的 18.6.1+ metadata 契約、scope 相符且版本與 cache 路徑經過驗證的原生註冊(即使綁定版本不同)、明確的 JSON,以及可證明的
runtime 連結所有權。真實的 module 資料夾、外部連結、npm 依賴衝突或不明確的 runtime 擁有者
移除需要經過驗證的 18.6.1+ metadata 契約、明確的 JSON,以及可證明的 runtime 連結所有權。
若存在原生註冊,即使綁定版本不同,它也必須 scope 相符,且版本與 cache 路徑經過驗證。真實的 module 資料夾、外部連結、npm 依賴衝突或不明確的 runtime 擁有者
都會被拒絕。若缺少 cache manifest,adapter 需要一個唯一的 runtime-lock 鍵,且其 scope 本機
連結指向該安裝的 cache;它絕不猜測 marketplace 名稱,也不會在實際 runtime 連結仍在時回報成功。
無法驗證的作用中安裝仍會被擋下。若原生解除安裝已經移除 cache、註冊以及 runtime 連結/選取,