Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): bind organization broker access to package bytes
fmfsaisai6db8c9582b1f
diff --git a/apps/desktop/src/main/cindy-brain/GhostManager.ts b/apps/desktop/src/main/cindy-brain/GhostManager.tsindex 48c2e77b2d..2d39ea1ebc 100644--- a/apps/desktop/src/main/cindy-brain/GhostManager.ts+++ b/apps/desktop/src/main/cindy-brain/GhostManager.ts@@ -1747,9 +1747,10 @@ export class GhostManager {* 坏 locale;迁移时读到坏 locale 只可能是**装入后被损坏**,属 §5 的"自相矛盾即* fail closed",也与 receipt「localeResources 键集必须等于 manifest.locales」的* 不变量一致(跳过坏 locale 会写出被 validateReceipt 拒绝的 receipt);- * - `packageSha256` **不算**(它是 audit-only、运行期不消费,见 §7);省掉它让迁移更快、- * 更不会因安装目录里的异常条目误伤——真正的运行期判据 `skillContentSha256` 仍逐字节算,- * 技能目录含链接等异常会在那里如实 fail closed。+ * - `packageSha256` **不回填**:旧安装目录无法反推出原始 `.cindy` 整包 SHA。省略后,+ * 组织市场 Broker 资格会 fail closed,直到一次经校验的市场更新写入新来源指纹;+ * 既有 organization-market OIDC 仍沿用 manifestDigest,不受影响。其它运行期字节判据+ * `skillContentSha256` 仍逐字节计算,技能目录含链接等异常会在那里如实 fail closed。*/private async backfillLegacyApproval(dir: string,diff --git a/apps/desktop/src/main/cindy-brain/__tests__/connectionAudienceResolver.test.ts b/apps/desktop/src/main/cindy-brain/__tests__/connectionAudienceResolver.test.tsindex f09ffd4262..753a6bc864 100644--- a/apps/desktop/src/main/cindy-brain/__tests__/connectionAudienceResolver.test.ts+++ b/apps/desktop/src/main/cindy-brain/__tests__/connectionAudienceResolver.test.ts@@ -87,6 +87,22 @@ describe('installed Plugin Connection audience resolver', () => {});});+ it('keeps legacy organization-market OIDC independent from receipt package SHA', () => {+ const resolver = loadConnectionAudienceResolver({+ ...resolverOptions(),+ readApprovedPackageSha256: () => null,+ });++ // This is the intentional compatibility boundary: Broker now requires the+ // package hash, but the existing market OIDC path remains manifest-bound.+ expect(resolver.resolve('plugin-a', identity)).toEqual({+ membershipId: 'membership-1',+ audience: 'org-example:plugin-a',+ pluginSlug: 'plugin-a',+ allowedHosts: ['service-a.x.test'],+ });+ });+it('requires a current organization market installation record', () => {const resolver = loadConnectionAudienceResolver(resolverOptions(manifest, { ...marketInstallation, source: 'local-market' }),diff --git a/apps/desktop/src/main/cindy-brain/__tests__/ghostFirstPartyFacts.test.ts b/apps/desktop/src/main/cindy-brain/__tests__/ghostFirstPartyFacts.test.tsindex 8f5770810d..914384850a 100644--- a/apps/desktop/src/main/cindy-brain/__tests__/ghostFirstPartyFacts.test.ts+++ b/apps/desktop/src/main/cindy-brain/__tests__/ghostFirstPartyFacts.test.ts@@ -6,11 +6,15 @@ import { afterEach, describe, expect, it } from 'vitest';import type { PluginMarketInstallationRecord } from '../../plugin-market/ledger.js';import { createOrganizationPrefixStore } from '../../plugin-market/organizationPrefixStore.js';import {+ bindPendingMarketRecordToInspectedPackage,loadGhostFirstPartyFactsLoader,type GhostFirstPartyFactsIdentity,type LoadGhostFirstPartyFactsLoaderOptions,} from '../ghostFirstPartyFacts.js';-import { resolveGhostFirstPartyPrivilege } from '../ghostFirstPartyPrivilege.js';+import {+ authorizeGhostTokenBroker,+ resolveGhostFirstPartyPrivilege,+} from '../ghostFirstPartyPrivilege.js';const PERSONAL: GhostFirstPartyFactsIdentity = {membershipKind: 'personal',@@ -38,6 +42,7 @@ const MARKET_ROW: PluginMarketInstallationRecord = {source: 'market',installed: true,updatedAt: '2026-08-21T00:00:00.000Z',+ manifestDigest: 'c'.repeat(64),};let tempDir: string | null = null;@@ -53,6 +58,7 @@ function loader(overrides: Partial<LoadGhostFirstPartyFactsLoaderOptions> = {})return loadGhostFirstPartyFactsLoader({readInstalledBuiltin: () => false,readMarketInstallation: () => null,+ readApprovedPackageSha256: () => null,lookupOrganizationPrefix: () => ({ kind: 'absent' }),readInstallOrigin: () => 'manual',...overrides,@@ -215,6 +221,7 @@ describe('loadGhostFirstPartyFactsLoader', () => {it('copies a known null pluginPrefix instead of treating it as absent', () => {const loaded = loader({readMarketInstallation: () => MARKET_ROW,+ readApprovedPackageSha256: () => MARKET_ROW.sha256,lookupOrganizationPrefix: () => ({ kind: 'known', pluginPrefix: null }),}).load('acme-tool', 'runtime', ORG_A);@@ -228,6 +235,8 @@ describe('loadGhostFirstPartyFactsLoader', () => {organizationId: 'org-a',source: 'market',installed: true,+ sha256: MARKET_ROW.sha256,+ approvedPackageSha256: MARKET_ROW.sha256,},currentOrganization: { organizationId: 'org-a', pluginPrefix: null },installOrigin: 'manual',@@ -235,6 +244,58 @@ describe('loadGhostFirstPartyFactsLoader', () => {});});+ it('denies the same manifest digest when Release and approved package bytes differ', () => {+ const loaded = loader({+ readMarketInstallation: () => MARKET_ROW,+ readApprovedPackageSha256: () => 'b'.repeat(64),+ lookupOrganizationPrefix: () => ({ kind: 'known', pluginPrefix: 'acme' }),+ }).load('acme-tool', 'runtime', ORG_A);++ expect(loaded).toMatchObject({+ kind: 'ready',+ facts: {+ marketRecord: {+ sha256: 'a'.repeat(64),+ approvedPackageSha256: 'b'.repeat(64),+ },+ },+ });+ expect(MARKET_ROW.manifestDigest).toBe('c'.repeat(64));+ if (loaded.kind !== 'ready') return;+ // This assertion kills an implementation that drops package SHA and falls+ // back to the unchanged manifestDigest for Broker authorization.+ expect(resolveGhostFirstPartyPrivilege(loaded.facts).brokerEligible).toBe(false);+ });++ it('binds pending organization-market authorization to the inspected package bytes', () => {+ const pending = {+ scope: 'organization' as const,+ organizationId: 'org-a',+ source: 'market' as const,+ installed: true,+ sha256: 'a'.repeat(64),+ };+ const installLoad = (inspectedPackageSha256: string) => ({+ kind: 'ready' as const,+ facts: {+ ghostId: 'acme-tool',+ builtin: false,+ marketRecord: bindPendingMarketRecordToInspectedPackage(+ pending,+ inspectedPackageSha256,+ ),+ currentOrganization: { organizationId: 'org-a', pluginPrefix: 'acme' },+ installOrigin: 'manual' as const,+ },+ });++ // Equal bytes preserve the receipt-less first-install path. Different+ // bytes deny before installation, killing a caller-supplied/self-reported+ // pending ticket that never compares with inspect(packageSha256).+ expect(authorizeGhostTokenBroker('acme-tool', installLoad('a'.repeat(64)))).toBe(true);+ expect(authorizeGhostTokenBroker('acme-tool', installLoad('b'.repeat(64)))).toBe(false);+ });+it('treats a missing receipt as manual so builtin official plugins stay unchanged', () => {const loaded = loader({readInstalledBuiltin: (ghostId) => ghostId === 'xd-feishu',diff --git a/apps/desktop/src/main/cindy-brain/__tests__/ghostFirstPartyPrivilege.test.ts b/apps/desktop/src/main/cindy-brain/__tests__/ghostFirstPartyPrivilege.test.tsindex 649de39f75..ebe7012237 100644--- a/apps/desktop/src/main/cindy-brain/__tests__/ghostFirstPartyPrivilege.test.ts+++ b/apps/desktop/src/main/cindy-brain/__tests__/ghostFirstPartyPrivilege.test.ts@@ -42,6 +42,8 @@ function market(organizationId: partial.scope === 'organization' ? (partial.organizationId ?? 'org-acme') : null,source: 'market',installed: true,+ sha256: 'a'.repeat(64),+ approvedPackageSha256: 'a'.repeat(64),...partial,};}@@ -218,6 +220,48 @@ describe('resolveGhostFirstPartyPrivilege', () => {});});+ it('denies same-manifest organization packages when Release and approved package bytes differ', () => {+ const sameManifestDifferentBytes = market({+ scope: 'organization',+ organizationId: 'org-acme',+ sha256: 'a'.repeat(64),+ approvedPackageSha256: 'b'.repeat(64),+ });++ // Both hashes are package identities. No manifest digest participates, so+ // keeping ghost.json identical cannot make these different bytes eligible.+ expect(+ authorizeGhostTokenBroker('acme-feishu', {+ kind: 'ready',+ facts: facts({+ ghostId: 'acme-feishu',+ marketRecord: sameManifestDifferentBytes,+ currentOrganization: CURRENT_ORG,+ }),+ }),+ ).toBe(false);+ });++ it('denies organization Broker for a legacy receipt without package SHA', () => {+ expect(+ resolveGhostFirstPartyPrivilege(+ facts({+ ghostId: 'acme-feishu',+ marketRecord: market({+ scope: 'organization',+ organizationId: 'org-acme',+ approvedPackageSha256: null,+ }),+ currentOrganization: CURRENT_ORG,+ }),+ ),+ ).toEqual({+ brokerEligible: false,+ hostPrimitiveEligible: false,+ basis: 'denied-unknown-origin',+ });+ });+it('denies an official-looking org plugin whose prefix does not belong to the current org', () => {expect(resolveGhostFirstPartyPrivilege(diff --git a/apps/desktop/src/main/cindy-brain/__tests__/ghostOauthAccounts.test.ts b/apps/desktop/src/main/cindy-brain/__tests__/ghostOauthAccounts.test.tsindex f2e8b81f0f..1687c1ac64 100644--- a/apps/desktop/src/main/cindy-brain/__tests__/ghostOauthAccounts.test.ts+++ b/apps/desktop/src/main/cindy-brain/__tests__/ghostOauthAccounts.test.ts@@ -1841,7 +1841,8 @@ describe('tokenBroker 模式', () => {});it('getFreshAccessToken refuses a cached broker token after eligibility is withdrawn', async () => {- let authorized = true;+ const releaseSha256 = 'a'.repeat(64);+ let approvedPackageSha256 = releaseSha256;const vault = seededVault();const mgr = new GhostOauthAccountManager({vault,@@ -1860,18 +1861,39 @@ describe('tokenBroker 模式', () => {})),},sleep: instantSleep,- isTokenBrokerAuthorized: () => authorized,+ isTokenBrokerAuthorized: () => approvedPackageSha256 === releaseSha256,});await expect(mgr.getFreshAccessToken(GHOST, KEY, BROKER_DECL)).resolves.toMatchObject({ok: true,accessToken: 'at-cached',});- authorized = false;+ // Simulate an unchanged manifest with different approved package bytes.+ // Authorization is checked before the token cache, so fixing only the+ // connect path cannot leak the already-cached Broker token.+ approvedPackageSha256 = 'b'.repeat(64);await expect(mgr.getFreshAccessToken(GHOST, KEY, BROKER_DECL)).resolves.toMatchObject({ok: false,error: 'BROKER_FORBIDDEN',});});++ it('connectAccount refuses before opening the browser when byte-bound eligibility is false', async () => {+ const openExternal = vi.fn();+ const mgr = new GhostOauthAccountManager({+ vault: memoryVault(),+ fetchImpl: vi.fn() as unknown as typeof fetch,+ openExternal,+ broker: { exchange: vi.fn(), refresh: vi.fn() },+ isTokenBrokerAuthorized: () => false,+ });++ await expect(mgr.connectAccount(GHOST, KEY, BROKER_DECL)).resolves.toMatchObject({+ ok: false,+ error: 'BROKER_FORBIDDEN',+ });+ // This kills an implementation that adds the SHA check only to token refresh.+ expect(openExternal).not.toHaveBeenCalled();+ });});describe('brokerBounce(双地址弹跳回调)', () => {diff --git a/apps/desktop/src/main/cindy-brain/ghostFirstPartyFacts.ts b/apps/desktop/src/main/cindy-brain/ghostFirstPartyFacts.tsindex 15753e4129..c9f3d6c183 100644--- a/apps/desktop/src/main/cindy-brain/ghostFirstPartyFacts.ts+++ b/apps/desktop/src/main/cindy-brain/ghostFirstPartyFacts.ts@@ -60,6 +60,8 @@ export interface GhostFirstPartyFactsLoader {export interface LoadGhostFirstPartyFactsLoaderOptions {readInstalledBuiltin(ghostId: string): boolean;readMarketInstallation(ghostId: string): PluginMarketInstallationRecord | null;+ /** Missing or legacy package evidence must return null. */+ readApprovedPackageSha256(ghostId: string): string | null;lookupOrganizationPrefix(orgId: string): OrganizationPrefixLookup;/** Missing / unreadable receipts must return `manual`. */readInstallOrigin(ghostId: string): 'manual' | 'agent-forge';@@ -71,15 +73,35 @@ function actionFor(purpose: GhostFirstPartyFactsPurpose): GhostFirstPartyFactsUnfunction toMarketRecord(record: PluginMarketInstallationRecord,+ approvedPackageSha256: string | null,): GhostFirstPartyMarketRecord {return {scope: record.scope,organizationId: record.organizationId,source: record.source,installed: record.installed,+ sha256: record.sha256,+ approvedPackageSha256,};}+export type GhostFirstPartyPendingMarketRecord = Omit<+ GhostFirstPartyMarketRecord,+ 'approvedPackageSha256'+>;++/**+ * The pending install exception is Host-built only after inspecting the real+ * `.cindy` bytes. The caller supplies the ledger Release hash, never the+ * approved side of the comparison.+ */+export function bindPendingMarketRecordToInspectedPackage(+ record: GhostFirstPartyPendingMarketRecord,+ inspectedPackageSha256: string,+): GhostFirstPartyMarketRecord {+ return { ...record, approvedPackageSha256: inspectedPackageSha256 };+}+export type GhostFirstPartyFactsOverrides = {installOrigin?: 'manual' | 'agent-forge';marketRecord?: GhostFirstPartyMarketRecord | null;@@ -124,7 +146,9 @@ export function loadGhostFirstPartyFactsLoader(let marketRecord: GhostFirstPartyMarketRecord | null = null;try {const installation = options.readMarketInstallation(ghostId);- marketRecord = installation ? toMarketRecord(installation) : null;+ marketRecord = installation+ ? toMarketRecord(installation, options.readApprovedPackageSha256(ghostId))+ : null;} catch {// Builtin official plugins do not consult the ledger. A corrupt ledger// must not take away xd-feishu / xd-atlassian broker eligibility.diff --git a/apps/desktop/src/main/cindy-brain/ghostFirstPartyPrivilege.ts b/apps/desktop/src/main/cindy-brain/ghostFirstPartyPrivilege.tsindex 5f0c6d3507..f25e6186b3 100644--- a/apps/desktop/src/main/cindy-brain/ghostFirstPartyPrivilege.ts+++ b/apps/desktop/src/main/cindy-brain/ghostFirstPartyPrivilege.ts@@ -11,7 +11,8 @@** Input priority: first evaluable of* 1. builtin seed → static official table- * 2. plugin-market ledger (source + scope + organizationId)+ * 2. plugin-market ledger (source + scope + organizationId + Release sha256)+ * paired with the approved receipt packageSha256* 3. neither → fail-closed, no privilege** Discriminator is the combination of `source` and `scope`, not `scope`@@ -33,6 +34,8 @@ import { PLUGIN_PREFIX_PATTERN, type PluginScope } from '@cindy/plugin-protocol'import { isBrokerEligibleGhostId, isOfficialGhostId } from '../../shared/ghost.js';+const PACKAGE_SHA256_RE = /^[a-f0-9]{64}$/;+/*** Ghost ids that share Host credential aliases (`GHOST_SECRET_STORAGE_ALIASES`).* A local package impersonating these ids must never receive first-party@@ -60,6 +63,10 @@ export interface GhostFirstPartyMarketRecord {organizationId: string | null;source: 'market' | 'legacy-adopted' | 'git-market' | 'local-market';installed: boolean;+ /** Release package hash retained by the server-market ledger row. */+ sha256: string;+ /** Approved receipt hash; null includes legacy/reapproved receipts without package evidence. */+ approvedPackageSha256: string | null;}export interface GhostFirstPartyCurrentOrganization {@@ -101,6 +108,26 @@ function isCurrentOrganizationRecord();}+/**+ * The single byte-identity gate for organization server-market Broker access.+ * `manifestDigest` is intentionally absent: an attacker can keep ghost.json+ * unchanged while replacing executable package bytes.+ */+export function marketInstallationMatchesApprovedPackage(+ record: GhostFirstPartyMarketRecord,+ currentOrganization: GhostFirstPartyCurrentOrganization | null,+): boolean {+ return (+ record.installed &&+ record.source === 'market' &&+ isCurrentOrganizationRecord(record, currentOrganization) &&+ record.approvedPackageSha256 !== null &&+ PACKAGE_SHA256_RE.test(record.sha256) &&+ PACKAGE_SHA256_RE.test(record.approvedPackageSha256) &&+ record.sha256 === record.approvedPackageSha256+ );+}+function allow(basis: GhostFirstPartyBasis, hostPrimitiveEligible: boolean): GhostFirstPartyPrivilege {return { brokerEligible: true, hostPrimitiveEligible, basis };}@@ -157,6 +184,9 @@ export function resolveGhostFirstPartyPrivilege(facts: GhostFirstPartyFacts): Ghif (!isCurrentOrganizationRecord(record, facts.currentOrganization)) {return deny('denied-foreign-org');}+ if (!marketInstallationMatchesApprovedPackage(record, facts.currentOrganization)) {+ return deny('denied-unknown-origin');+ }if (!matchesCurrentOrgPrefix(facts.ghostId, facts.currentOrganization)) {return deny('denied-unknown-origin');}diff --git a/apps/desktop/src/main/cindy-brain/ghostInstallReceipt.ts b/apps/desktop/src/main/cindy-brain/ghostInstallReceipt.tsindex 64c1c253bd..98c94a8863 100644--- a/apps/desktop/src/main/cindy-brain/ghostInstallReceipt.ts+++ b/apps/desktop/src/main/cindy-brain/ghostInstallReceipt.ts@@ -60,8 +60,9 @@ export interface GhostInstallReceipt {enabled: boolean;trust: GhostTrustInfo;/**- * 批准时点的来源指纹,仅供审计与人工比对:市场/本地包是 `.cindy` 文件哈希,- * 随包种子是内容目录哈希。**运行时不校验它**,不要据此认为安装内容持续完整。+ * 批准时点的来源指纹:市场/本地包是 `.cindy` 文件哈希,随包种子是内容目录哈希。+ * 组织市场 Broker 资格会把它与 ledger 的 Release sha256 比对;除此以外运行时不会+ * 重算可变安装目录的整包字节,所以不要据此认为安装内容持续完整。*/packageSha256?: string;/**diff --git a/apps/desktop/src/main/cindy-brain/index.ts b/apps/desktop/src/main/cindy-brain/index.tsindex c7d802013d..19734d3627 100644--- a/apps/desktop/src/main/cindy-brain/index.ts+++ b/apps/desktop/src/main/cindy-brain/index.ts@@ -294,10 +294,12 @@ import {} from './connectionAudienceResolver.js';import {applyGhostFirstPartyFactsOverrides,+ bindPendingMarketRecordToInspectedPackage,loadGhostFirstPartyFactsLoader,type GhostFirstPartyFactsLoader,type GhostFirstPartyFactsLoad,type GhostFirstPartyFactsOverrides,+ type GhostFirstPartyPendingMarketRecord,type GhostFirstPartyFactsPurpose,} from './ghostFirstPartyFacts.js';import { authorizeGhostTokenBroker } from './ghostFirstPartyPrivilege.js';@@ -2606,6 +2608,8 @@ function getGhostFirstPartyFactsLoader(): GhostFirstPartyFactsLoader {getGhostManager().list().find((candidate) => candidate.manifest.id === ghostId)?.builtin ===true,readMarketInstallation: (ghostId) => getPluginMarketLedger().installationForGhost(ghostId),+ readApprovedPackageSha256: (ghostId) =>+ getGhostManager().approvedInstallEvidence(ghostId)?.packageSha256 ?? null,lookupOrganizationPrefix: (orgId) =>createOrganizationPrefixStore(ownerScopedUserDataPath('plugin-market', 'organization.v1.json'),@@ -5423,7 +5427,7 @@ export async function installOrUpdateMarketGhostPackage(* commitDownloadedPackage path covers org server-market install, update,* defaultInstall, and source replacement.*/- pendingMarketRecord?: GhostFirstPartyFactsOverrides['marketRecord'];+ pendingMarketRecord?: GhostFirstPartyPendingMarketRecord;/** 安装锁内从当前已落位包读取的 canonical 权限基线。 */permissionBaselineManifest?: GhostManifest;/** 用户已在页面确认过的权限清单;真实包未超出则跳过 Host。 */@@ -5456,7 +5460,7 @@ async function installOrUpdateMarketGhostPackageLocked(| { mode: 'manual'; sourceType: PluginMarketItemSource }| { mode: 'cap'; manifest: GhostManifest; sourceType: PluginMarketItemSource };/** Same Host-built org server-market fact as the exported entry; not first-install only. */- pendingMarketRecord?: GhostFirstPartyFactsOverrides['marketRecord'];+ pendingMarketRecord?: GhostFirstPartyPendingMarketRecord;permissionBaselineManifest?: GhostManifest;reviewedManifest?: GhostManifest;approvedPackageSha256?: string;@@ -5592,7 +5596,12 @@ async function installOrUpdateMarketGhostPackageLocked(rejectUnauthorizedTokenBroker(inspected.canonicalManifest,expected.pendingMarketRecord !== undefined- ? { marketRecord: expected.pendingMarketRecord }+ ? {+ marketRecord: bindPendingMarketRecordToInspectedPackage(+ expected.pendingMarketRecord,+ inspected.packageSha256,+ ),+ }: undefined,);diff --git a/apps/desktop/src/main/plugin-market/__tests__/service.test.ts b/apps/desktop/src/main/plugin-market/__tests__/service.test.tsindex cc5bdabf39..600370037b 100644--- a/apps/desktop/src/main/plugin-market/__tests__/service.test.ts+++ b/apps/desktop/src/main/plugin-market/__tests__/service.test.ts@@ -1144,15 +1144,22 @@ describe('PluginMarketService migration and defaultInstall', () => {organizationId: 'org-1',source: 'market',installed: true,+ sha256: orgItem.currentRelease.sha256,},}),);const pending = runtime.install.mock.calls[0]?.[1]?.pendingMarketRecord as {source: string;installed: boolean;+ sha256: string;};expect(pending.source).toBe('market');expect(pending.installed).toBe(true);+ // The pending ticket carries only the server Release hash. The approved+ // side is Host-bound later to inspect(package bytes), so the service cannot+ // mint a self-reported match.+ expect(pending.sha256).toBe(orgItem.currentRelease.sha256);+ expect(pending).not.toHaveProperty('approvedPackageSha256');runtime.install.mockReset();const publicItem = summary({ scope: 'public', organizationId: null });diff --git a/apps/desktop/src/main/plugin-market/ledger.ts b/apps/desktop/src/main/plugin-market/ledger.tsindex 51ea838646..45faf35fe0 100644--- a/apps/desktop/src/main/plugin-market/ledger.ts+++ b/apps/desktop/src/main/plugin-market/ledger.ts@@ -256,7 +256,7 @@ export class PluginMarketLedger {* directory bytes, so an organization-scoped market record is demoted to* legacy-adopted until a verified market update installs fresh bytes. This* keeps automatic updates available without restoring Connection JWT trust- * from audit-only evidence. The compare-and-write prevents a concurrent+ * from historical source evidence. The compare-and-write prevents a concurrent* uninstall or source replacement from being overwritten by a stale snapshot.*/restoreDisconnectedInstallation(diff --git a/apps/desktop/src/main/plugin-market/service.ts b/apps/desktop/src/main/plugin-market/service.tsindex c49e83ed2b..c11c027260 100644--- a/apps/desktop/src/main/plugin-market/service.ts+++ b/apps/desktop/src/main/plugin-market/service.ts@@ -1974,6 +1974,7 @@ export class PluginMarketService {organizationId: plugin.organizationId,source: 'market',installed: true,+ sha256: plugin.currentRelease.sha256,},}: {}),@@ -2126,7 +2127,7 @@ export class PluginMarketService {* Repair an existing server provenance record that an older client left* disconnected while its approved package remained installed.* Recovery is entirely local. Modern receipts must retain the exact Release- * package hash. Legacy receipts intentionally omitted that audit-only hash, so+ * package hash. Legacy receipts intentionally omitted that source hash, so* they additionally require the completed one-time migration to name this id* and the raw installed manifest to equal the manifest frozen in that receipt.* This evidence reconnects the server update route, not current code bytes;diff --git a/docs/dev-rules/plugin-security-and-authoring.md b/docs/dev-rules/plugin-security-and-authoring.mdindex 60b70e2478..6982dbc843 100644--- a/docs/dev-rules/plugin-security-and-authoring.md+++ b/docs/dev-rules/plugin-security-and-authoring.md@@ -92,7 +92,8 @@确认时看到的 token 回传,Main 重新读状态比对,不一致就拒(`state-changed`)。token 是前置条件不是凭证——真值一律由 Main 现读。- receipt 保证的是**授权事实**,**不是安装内容此后一直没被改过**:逻辑页代码仍从可变- 安装目录加载,`packageSha256` 只是批准时点的来源指纹、运行时不校验(见第 7 节)。+ 安装目录加载。`packageSha256` 是批准时点的来源指纹;组织市场 Broker 会把它与 ledger+ 的 Release sha256 比对,但运行时不会重算可变安装目录的整包字节(见第 7 节)。- **Forge 的源码区与 Host 受管根互斥。** `ghost_forge_scaffold` / `ghost_forge_pack` 的目标必须是当前会话工作目录里的独立作者目录;命中安装根或批准状态根一律拒(pack 返回 `SOURCE_IS_INSTALLED_PLUGIN`)。判定按 realpath 比对受管根,同时挡住大小写@@ -344,8 +345,9 @@授权的那一组,此后任何 manifest/权限变化照旧走完整确认)、**只写状态根不动安装目录**(三份旧文件原样保留,回滚到旧客户端时仍按安装目录判定,符合第 5 节兜底第 4 条)。核心授权事实读不出(manifest 不合法、技能目录含链接、声明的 locale 装入后损坏)才对该插件- fail closed、走恢复 UI;trust 镜像缺失降级为 `unverified`、`packageSha256` audit-only- 故省略。改动装入/迁移链路时保持这些不变量,尤其不得把迁移改成"每次缺 receipt 就补"+ fail closed、走恢复 UI;trust 镜像缺失降级为 `unverified`;旧目录无法反推出原始 `.cindy`+ 整包的 `packageSha256`,故省略(组织市场 Broker 因此 fail closed,既有市场 OIDC 不变)。+ 改动装入/迁移链路时保持这些不变量,尤其不得把迁移改成"每次缺 receipt 就补"(那就是把授权事实重新交给可变安装目录,等于回到 #636)。迁移之后批准再丢失的恢复路径:市场包走市场重装确认;本地包走「从已装目录重新确认」(`ghosts:reapprove-inspect`→ 确认卡全量权限清单 → `ghosts:reapprove-installed`,清单字节以 manifestSha256 绑定