@capybara-hq/kernel 0.1.0-rc.144 → 0.1.0-rc.146

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist/agents/admin-agents.d.ts +20 -3
  2. package/dist/agents/admin-agents.js +38 -7
  3. package/dist/catalog/marketplace-fetch.d.ts +2 -0
  4. package/dist/catalog/marketplace-fetch.js +7 -2
  5. package/dist/catalog/marketplaces.service.d.ts +1 -1
  6. package/dist/catalog/provenance.d.ts +69 -0
  7. package/dist/catalog/provenance.js +108 -0
  8. package/dist/ctx/create-ctx.d.ts +16 -0
  9. package/dist/ctx/create-ctx.js +269 -34
  10. package/dist/errors.d.ts +1 -1
  11. package/dist/errors.js +2 -2
  12. package/dist/extensions/execution-realm.d.ts +96 -0
  13. package/dist/extensions/execution-realm.js +141 -0
  14. package/dist/extensions/extensions.module.js +3 -0
  15. package/dist/extensions/grant-epoch.d.ts +4 -2
  16. package/dist/extensions/grant-epoch.js +4 -2
  17. package/dist/extensions/host.d.ts +26 -3
  18. package/dist/extensions/host.js +135 -10
  19. package/dist/extensions/instance.d.ts +2 -0
  20. package/dist/extensions/instance.js +1 -0
  21. package/dist/extensions/isolated/admission.d.ts +6 -0
  22. package/dist/extensions/isolated/admission.js +17 -0
  23. package/dist/extensions/isolated/tier.d.ts +14 -0
  24. package/dist/extensions/isolated/tier.js +27 -0
  25. package/dist/extensions/ledger.d.ts +5 -0
  26. package/dist/extensions/ledger.js +16 -0
  27. package/dist/extensions/permission-view.d.ts +2 -2
  28. package/dist/extensions/publisher-proof.job.d.ts +39 -0
  29. package/dist/extensions/publisher-proof.job.js +160 -0
  30. package/dist/extensions/registry.d.ts +6 -0
  31. package/dist/extensions/registry.js +8 -0
  32. package/dist/extensions/review-hash.d.ts +114 -0
  33. package/dist/extensions/review-hash.js +145 -0
  34. package/dist/extensions/revision-grants.d.ts +10 -0
  35. package/dist/extensions/revocation-leases.d.ts +273 -0
  36. package/dist/extensions/revocation-leases.js +533 -0
  37. package/dist/extensions/revocation.d.ts +78 -0
  38. package/dist/extensions/revocation.js +202 -0
  39. package/dist/index.d.ts +6 -2
  40. package/dist/index.js +6 -2
  41. package/dist/lifecycle/kernel-lifecycle.d.ts +3 -1
  42. package/dist/lifecycle/kernel-lifecycle.js +24 -18
  43. package/dist/overrides.d.ts +5 -1
  44. package/dist/overrides.js +2 -0
  45. package/dist/packages/official-publisher.d.ts +44 -0
  46. package/dist/packages/official-publisher.js +147 -48
  47. package/dist/packages/provenance.d.ts +6 -0
  48. package/dist/packages/provenance.js +26 -9
  49. package/dist/platform/ops/admin-items.ops.js +1 -1
  50. package/dist/roles/worker.module.js +3 -0
  51. package/package.json +2 -2
@@ -0,0 +1,202 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
8
+ return function (target, key) { decorator(target, key, paramIndex); }
9
+ };
10
+ import { Inject, Injectable } from "@nestjs/common";
11
+ import { audit } from "../identity/audit.js";
12
+ import { afterCommit } from "../infra/database/after-commit.js";
13
+ import { KernelDb } from "../infra/database/kernel-db.js";
14
+ import { TransactionHost } from "../infra/database/transaction-host.js";
15
+ import { Transactional } from "../infra/database/transactional.decorator.js";
16
+ import { KERNEL_BUS, KERNEL_LOGGER } from "../infra/tokens.js";
17
+ import { ExtensionHost } from "./host.js";
18
+ import { ExtensionRevisionGrants, RevisionGrantError, } from "./revision-grants.js";
19
+ import { revocationView, unrevocableKeys } from "./revocation-leases.js";
20
+ export { classifyKey, PermissionLease, RevisionLeases, realmAfterRevocation, revocationView, } from "./revocation-leases.js";
21
+ /**
22
+ * Revoking revision grants (extension permission model spec 2026-12-04, "Revocation, audit and
23
+ * people"; plan task 1.3e).
24
+ *
25
+ * The grant state and its audit change in one transaction; the store's write advances the grant
26
+ * epoch in the same transaction (the grant tables' triggers of migration 0235). After the commit
27
+ * this replica fences
28
+ * its leases of the plugin at once (the local fence) and publishes {@link GRANT_REVOKED_TOPIC} to
29
+ * the others. The hint is only the fast path: a replica that misses it sees the epoch change and
30
+ * revalidates its leases within the 5 s bound (`grant-epoch.ts`).
31
+ *
32
+ * Shadow mode until plan task 1.5a (`REVOCATION_ENFORCED`): the write, audit, epoch bump, fence and
33
+ * hint are real, and the leases compute and report the decision (logs, the Partially revoked view),
34
+ * but nothing below is enforced yet. Once enforcing, on each replica the leases:
35
+ * - withdraw the registrations of revoked registration keys (routes, tools, providers, hooks,
36
+ * views, setup checks); a revoked policy hook stays registered and denies, so a required
37
+ * policy mount fails closed until the admin disables the extension;
38
+ * - refuse `ctx` operations of revoked capability keys with `ExtensionPermissionError` and abort
39
+ * the handles that relied on them; unaffected keys keep serving;
40
+ * - for revoked server full access, refuse the in-process generation's `ctx` and converge: the
41
+ * generation is unloaded, and an isolated one starts when the remaining grant fits the sandbox
42
+ * (otherwise it waits for a new review).
43
+ *
44
+ * Plugin data stays; durable effects keep their delivery-time authority checks.
45
+ */
46
+ /** The fan-out hint after a committed revocation: `{ plugin }`. Losing it is harmless. */
47
+ export const GRANT_REVOKED_TOPIC = "kernel.extensions.grant-revoked";
48
+ let ExtensionRevocations = class ExtensionRevocations {
49
+ kdb;
50
+ txHost;
51
+ grants;
52
+ host;
53
+ bus;
54
+ log;
55
+ unsubscribe;
56
+ constructor(kdb, txHost, grants, host, bus, log) {
57
+ this.kdb = kdb;
58
+ this.txHost = txHost;
59
+ this.grants = grants;
60
+ this.host = host;
61
+ this.bus = bus;
62
+ this.log = log;
63
+ }
64
+ /**
65
+ * Every replica takes the hints of the others (and its own, a no-op after the local fence).
66
+ * Called by the kernel's start sequence (never in the CLI, which loads no extension).
67
+ */
68
+ async start() {
69
+ if (this.unsubscribe)
70
+ return;
71
+ try {
72
+ this.unsubscribe = await this.bus.subscribe(GRANT_REVOKED_TOPIC, (payload) => {
73
+ const plugin = payload?.plugin;
74
+ if (typeof plugin !== "string")
75
+ return;
76
+ this.fence(plugin);
77
+ });
78
+ }
79
+ catch (err) {
80
+ // the grant epoch still fences every lease within the bound
81
+ this.log.warn("cannot subscribe to grant revocation hints", { err });
82
+ }
83
+ }
84
+ async stop() {
85
+ const unsubscribe = this.unsubscribe;
86
+ this.unsubscribe = undefined;
87
+ await unsubscribe?.().catch(() => { });
88
+ }
89
+ /**
90
+ * Revokes keys of a revision's live grant (**Partially revoked** while others still serve). A
91
+ * key no running surface can withdraw on its own (network, config, tables, embeds, dependencies,
92
+ * client code, raw egress, migration warnings) is refused (`unknown_keys`): the Partially revoked
93
+ * view never shows a still-serving key as withdrawn. Revoke the whole grant to take those away.
94
+ */
95
+ async revokeKeys(revision, keys, by) {
96
+ const unhonoured = unrevocableKeys(keys);
97
+ if (unhonoured.length > 0) {
98
+ throw new RevisionGrantError("unknown_keys", `These keys cannot be revoked on their own; revoke the whole grant instead: ${unhonoured.join(", ")}`);
99
+ }
100
+ const before = await this.lockLive(revision);
101
+ const after = await this.grants.revokeKeys(revision, keys, by.accountId);
102
+ return this.record(before, after, by);
103
+ }
104
+ /** Revokes a revision's live grant entirely: the revision is unloaded and waits for a new review. */
105
+ async revoke(revision, by) {
106
+ const before = await this.lockLive(revision);
107
+ const after = await this.grants.revoke(revision, by.accountId);
108
+ return this.record(before, after, by);
109
+ }
110
+ /** The newest grant of a revision with its withdrawn keys and serving surface. */
111
+ async view(revision) {
112
+ const grant = await this.grants.get(revision);
113
+ return grant ? revocationView(grant) : undefined;
114
+ }
115
+ /** The live grant, locked for this transaction so the audit diff matches the write. */
116
+ async lockLive(revision) {
117
+ await this.kdb.db
118
+ .selectFrom("extension_revision_grants")
119
+ .select("generation")
120
+ .where("plugin", "=", revision.plugin)
121
+ .where("version", "=", revision.version)
122
+ .where("sha512", "=", revision.sha512)
123
+ .where("state", "in", ["approved", "partially_revoked"])
124
+ .forNoKeyUpdate()
125
+ .execute();
126
+ const live = await this.grants.live(revision);
127
+ if (live)
128
+ return live;
129
+ const newest = await this.grants.get(revision);
130
+ throw newest
131
+ ? new RevisionGrantError("terminal", `The grant of ${revision.plugin}@${revision.version} is ${newest.state}`)
132
+ : new RevisionGrantError("not_found", `${revision.plugin}@${revision.version} has no grant`);
133
+ }
134
+ async record(before, after, by) {
135
+ const was = new Set(revocationView(before).withdrawn);
136
+ const view = revocationView(after);
137
+ const withdrawn = view.withdrawn.filter((key) => !was.has(key));
138
+ const { plugin, version, sha512 } = after.revision;
139
+ await audit(this.kdb.db, {
140
+ actorAccountId: by.accountId,
141
+ ...(by.tokenId !== undefined && { actorTokenId: by.tokenId }),
142
+ action: "extension.grant_revoked",
143
+ target: plugin,
144
+ detail: {
145
+ plugin,
146
+ version,
147
+ sha512,
148
+ generation: after.generation,
149
+ previousState: before.state,
150
+ state: after.state,
151
+ keys: withdrawn,
152
+ registrations: view.registrations.filter((key) => !was.has(key)),
153
+ capabilities: view.capabilities.filter((key) => !was.has(key)),
154
+ fullAccess: view.fullAccess,
155
+ serving: view.serving,
156
+ scope: after.approvalScope,
157
+ purposesDigest: after.purposesDigest,
158
+ reviewHash: after.reviewHash,
159
+ publisherEvidence: after.publisherEvidence,
160
+ ...(after.publisher !== null && { publisher: after.publisher }),
161
+ ...(by.reason !== undefined && { reason: by.reason }),
162
+ },
163
+ });
164
+ afterCommit(async () => {
165
+ // The local fence first: this replica revalidates its leases of the plugin at once.
166
+ await this.host
167
+ .fenceRevocation(plugin)
168
+ .catch((err) => this.log.warn("grant revocation fence failed", { plugin, err }));
169
+ try {
170
+ await this.bus.publish(GRANT_REVOKED_TOPIC, { plugin });
171
+ }
172
+ catch (err) {
173
+ this.log.warn("cannot publish a grant revocation hint; the grant epoch fences replicas", {
174
+ plugin,
175
+ err,
176
+ });
177
+ }
178
+ });
179
+ return { grant: after, withdrawn, view };
180
+ }
181
+ fence(plugin) {
182
+ void this.host
183
+ .fenceRevocation(plugin)
184
+ .catch((err) => this.log.warn("grant revocation fence failed", { plugin, err }));
185
+ }
186
+ };
187
+ __decorate([
188
+ Transactional()
189
+ ], ExtensionRevocations.prototype, "revokeKeys", null);
190
+ __decorate([
191
+ Transactional()
192
+ ], ExtensionRevocations.prototype, "revoke", null);
193
+ ExtensionRevocations = __decorate([
194
+ Injectable(),
195
+ __param(0, Inject(KernelDb)),
196
+ __param(1, Inject(TransactionHost)),
197
+ __param(2, Inject(ExtensionRevisionGrants)),
198
+ __param(3, Inject(ExtensionHost)),
199
+ __param(4, Inject(KERNEL_BUS)),
200
+ __param(5, Inject(KERNEL_LOGGER))
201
+ ], ExtensionRevocations);
202
+ export { ExtensionRevocations };
package/dist/index.d.ts CHANGED
@@ -4,6 +4,7 @@ export { type CatalogCli, openCatalogCli } from "./catalog/cli.js";
4
4
  export { GitSourceError, type ReadGitTreeOptions, readGitTree, } from "./catalog/git-source.js";
5
5
  export type { PluginConfirmResult, PluginReview } from "./catalog/plugin-import.js";
6
6
  export { type PluginPackage, PluginPackageError, type ReadPluginPackageOptions, readPluginPackage, } from "./catalog/plugin-package.js";
7
+ export { classifyPublisherEvidence, normalizePublisherIdentity, type PublisherEvidence, type PublisherEvidenceOutcome, refClass, samePublisher, } from "./catalog/provenance.js";
7
8
  export { gatewayReplicasKey } from "./channels/supervisor.js";
8
9
  export { envName, renderConfigDocs } from "./config/docs.js";
9
10
  export { envOverrides } from "./config/env.js";
@@ -38,17 +39,20 @@ export { BOOTSTRAP_MANIFEST_FILE, bootstrapManifestSha256, readBootstrapManifest
38
39
  export { type BootstrapGitPlugin, type BootstrapResolveOptions, readBootstrapGitPlugin, resolveBootstrapPackages, } from "./extensions/bootstrap-packages.js";
39
40
  export { type ExtensionCli, openExtensionCli } from "./extensions/cli.js";
40
41
  export { DEPLOYMENT_SECRETS_ORG, type DeploymentConfigField, type DeploymentConfigView, ExtensionDeploymentConfigService, mergeDeploymentConfig, PLUGIN_DEPLOYMENT_CONFIG_TOPIC, readStoredDeploymentConfig, type SecretEntry, } from "./extensions/deployment-config.js";
42
+ export { CONFIG_SCHEMA_UNSUPPORTED_KEY, describeExecution, type ExecutionDecision, type ExecutionInput, executionDecision, fullAccessKeys, HOST_NO_ISOLATION_KEY, type HostIsolation, type RealmPlacement, } from "./extensions/execution-realm.js";
41
43
  export { assertSecretsReachable, ExtensionHost, type ExtensionLoadPlan, type InspectedExtension, type InstalledExtensionLoader, type InstallFailureReason, } from "./extensions/host.js";
42
44
  export { ExtensionUnloadedError, type InflightEntry, InflightTracker, PLUGIN_UNLOADED_TOOL_ERROR, type TrackOptions, trackCalls, } from "./extensions/inflight.js";
43
45
  export { type DesiredExtension, type ExtensionInstallRow, ExtensionInstalls, type IngestSource, type PackageReview, } from "./extensions/installs.js";
44
46
  export { DEFAULT_DISPOSE_TIMEOUT_MS, type DisposeOptions, ExtensionInstance, ImportTracker, type LoadDeps, loadInstance, ManifestMismatchError, type Registration, type RegistrationKind, UPGRADE_WARN_THRESHOLD, } from "./extensions/instance.js";
47
+ export { deploymentConfigIsolatable, isolatedDeploymentSchema, } from "./extensions/isolated/admission.js";
45
48
  export { ExtensionLifecycle, PLUGINS_RECONCILE_JOB, PLUGINS_RECONCILE_TOPIC, } from "./extensions/lifecycle.js";
46
49
  export { ensureMigrated, MIGRATE_LOCK_PREFIX, type MigrateLockDeps, PLUGINS_MIGRATED_TOPIC, unrunMigrations, } from "./extensions/migrate-lock.js";
47
50
  export { EXTENSION_PACKAGE_LIMITS, type ExtensionPackage, ExtensionPackageError, type ExtensionPackageLimits, type ExtensionPackageSection, extractExtensionPackage, HOST_ZOD_VERSION, permissionSetOfPackage, type ReadExtensionPackageOptions, readExtensionPackage, } from "./extensions/package.js";
48
- export { blockingKeys, computePermissionSet, diffPermissions, type PermissionSet, permissionKeys, WARNINGS_KEY_PREFIX, } from "./extensions/permission-set.js";
51
+ export { blockingKeys, buildPermissionSet, computePermissionSet, diffPermissions, type PermissionSet, permissionKeys, WARNINGS_KEY_PREFIX, } from "./extensions/permission-set.js";
49
52
  export { type AdminExtensionView, type DeploymentExtensionStatus, isSensitivePermissionKey, type PermissionGroup, type PermissionItem, permissionGroups, permissionKeyItems, reviewHash, SENSITIVE_EXTENSION_POINTS, type SensitiveReason, } from "./extensions/permission-view.js";
50
53
  export { ExtensionRegistry } from "./extensions/registry.js";
51
54
  export { ExtensionResolveError, resolveExtensions } from "./extensions/resolve.js";
55
+ export { fullAccessPurpose, grantPurposeRows, REVIEW_CONTRACT_VERSION, type ReviewDisplay, type ReviewInput, reviewDisplay, revisionReviewHash, } from "./extensions/review-hash.js";
52
56
  export { type ExtensionLoadStatus, type ExtensionSource, newReplicaId, type PendingReason, ReplicaStatusStore, } from "./extensions/sources.js";
53
57
  export { syncPackage } from "./extensions/sync.js";
54
58
  export type { KernelHttp, KernelHttpApp } from "./http/app.js";
@@ -75,7 +79,7 @@ export { type Org, OrgsService } from "./orgs/orgs.service.js";
75
79
  export type { KernelOverride } from "./overrides.js";
76
80
  export { fetchNpmPackage, IntegrityMismatchError, type NpmFetchConfig, NpmFetchError, PackageTooLargeError, } from "./packages/npm.js";
77
81
  export { fetchOfficialPublisher } from "./packages/official-publisher.js";
78
- export { packPackageTgz } from "./packages/tgz.js";
82
+ export { packPackageTgz, unpackPackageTgz } from "./packages/tgz.js";
79
83
  export { checkInputParity, inputParity, type ParityFinding, type ParityOperation, } from "./platform/parity.js";
80
84
  export { PLATFORM_OPERATION_PROVIDERS } from "./platform/platform-ops.module.js";
81
85
  export { PlatformOperations } from "./platform/registry.js";
package/dist/index.js CHANGED
@@ -4,6 +4,7 @@ export { openCatalogCli } from "./catalog/cli.js";
4
4
  // The git reader marketplaces use; core's check:bootstrap reads the official marketplace with it.
5
5
  export { GitSourceError, readGitTree, } from "./catalog/git-source.js";
6
6
  export { PluginPackageError, readPluginPackage, } from "./catalog/plugin-package.js";
7
+ export { classifyPublisherEvidence, normalizePublisherIdentity, refClass, samePublisher, } from "./catalog/provenance.js";
7
8
  export { gatewayReplicasKey } from "./channels/supervisor.js";
8
9
  export { envName, renderConfigDocs } from "./config/docs.js";
9
10
  export { envOverrides } from "./config/env.js";
@@ -37,17 +38,20 @@ export { BOOTSTRAP_MANIFEST_FILE, bootstrapManifestSha256, readBootstrapManifest
37
38
  export { readBootstrapGitPlugin, resolveBootstrapPackages, } from "./extensions/bootstrap-packages.js";
38
39
  export { openExtensionCli } from "./extensions/cli.js";
39
40
  export { DEPLOYMENT_SECRETS_ORG, ExtensionDeploymentConfigService, mergeDeploymentConfig, PLUGIN_DEPLOYMENT_CONFIG_TOPIC, readStoredDeploymentConfig, } from "./extensions/deployment-config.js";
41
+ export { CONFIG_SCHEMA_UNSUPPORTED_KEY, describeExecution, executionDecision, fullAccessKeys, HOST_NO_ISOLATION_KEY, } from "./extensions/execution-realm.js";
40
42
  export { assertSecretsReachable, ExtensionHost, } from "./extensions/host.js";
41
43
  export { ExtensionUnloadedError, InflightTracker, PLUGIN_UNLOADED_TOOL_ERROR, trackCalls, } from "./extensions/inflight.js";
42
44
  export { ExtensionInstalls, } from "./extensions/installs.js";
43
45
  export { DEFAULT_DISPOSE_TIMEOUT_MS, ExtensionInstance, ImportTracker, loadInstance, ManifestMismatchError, UPGRADE_WARN_THRESHOLD, } from "./extensions/instance.js";
46
+ export { deploymentConfigIsolatable, isolatedDeploymentSchema, } from "./extensions/isolated/admission.js";
44
47
  export { ExtensionLifecycle, PLUGINS_RECONCILE_JOB, PLUGINS_RECONCILE_TOPIC, } from "./extensions/lifecycle.js";
45
48
  export { ensureMigrated, MIGRATE_LOCK_PREFIX, PLUGINS_MIGRATED_TOPIC, unrunMigrations, } from "./extensions/migrate-lock.js";
46
49
  export { EXTENSION_PACKAGE_LIMITS, ExtensionPackageError, extractExtensionPackage, HOST_ZOD_VERSION, permissionSetOfPackage, readExtensionPackage, } from "./extensions/package.js";
47
- export { blockingKeys, computePermissionSet, diffPermissions, permissionKeys, WARNINGS_KEY_PREFIX, } from "./extensions/permission-set.js";
50
+ export { blockingKeys, buildPermissionSet, computePermissionSet, diffPermissions, permissionKeys, WARNINGS_KEY_PREFIX, } from "./extensions/permission-set.js";
48
51
  export { isSensitivePermissionKey, permissionGroups, permissionKeyItems, reviewHash, SENSITIVE_EXTENSION_POINTS, } from "./extensions/permission-view.js";
49
52
  export { ExtensionRegistry } from "./extensions/registry.js";
50
53
  export { ExtensionResolveError, resolveExtensions } from "./extensions/resolve.js";
54
+ export { fullAccessPurpose, grantPurposeRows, REVIEW_CONTRACT_VERSION, reviewDisplay, revisionReviewHash, } from "./extensions/review-hash.js";
51
55
  export { newReplicaId, ReplicaStatusStore, } from "./extensions/sources.js";
52
56
  export { syncPackage } from "./extensions/sync.js";
53
57
  export { AccountsModule, AccountsService } from "./identity/accounts.js";
@@ -72,7 +76,7 @@ export { OrgsService } from "./orgs/orgs.service.js";
72
76
  export { fetchNpmPackage, IntegrityMismatchError, NpmFetchError, PackageTooLargeError, } from "./packages/npm.js";
73
77
  export { fetchOfficialPublisher } from "./packages/official-publisher.js";
74
78
  // The canonical tgz of a package tree; `capybara-plugin bootstrap` pins git entries with it.
75
- export { packPackageTgz } from "./packages/tgz.js";
79
+ export { packPackageTgz, unpackPackageTgz } from "./packages/tgz.js";
76
80
  // Test seam: the Platform input-parity test in tools/checks (no runtime caller).
77
81
  export { checkInputParity, inputParity, } from "./platform/parity.js";
78
82
  // Test seam (the parity test builds every operation from these without a Nest app).
@@ -19,6 +19,7 @@ import { ExtensionHost } from "../extensions/host.js";
19
19
  import { ExtensionInstalls } from "../extensions/installs.js";
20
20
  import { ExtensionLifecycle } from "../extensions/lifecycle.js";
21
21
  import { ExtensionRegistry } from "../extensions/registry.js";
22
+ import { ExtensionRevocations } from "../extensions/revocation.js";
22
23
  import { ReplicaStatusStore } from "../extensions/sources.js";
23
24
  import type { KernelHttpApp } from "../http/app.js";
24
25
  import type { GatewayRoutes } from "../http/gateway-routes.js";
@@ -83,6 +84,7 @@ export declare class KernelLifecycle implements OnApplicationBootstrap, BeforeAp
83
84
  private readonly installs;
84
85
  private readonly blobs;
85
86
  private readonly extensionLifecycle;
87
+ private readonly revocations;
86
88
  private readonly replicaStatus;
87
89
  private readonly bootstrap;
88
90
  private readonly bootstrapDefaults;
@@ -115,7 +117,7 @@ export declare class KernelLifecycle implements OnApplicationBootstrap, BeforeAp
115
117
  private bootstrapPackages;
116
118
  /** The merged bootstrap manifest, read once per start. */
117
119
  private mergedManifest;
118
- constructor(permissionConfig: PermissionConfigPublication, accounts: AccountsService, configService: KernelConfigService, log: KernelLogger, options: KernelAppOptions, pool: Kysely<any>, redis: Redis, kdb: KernelDb, shutdown: GracefulShutdown, host: ExtensionHost, extensionDbIdentity: ExtensionDbIdentity, registry: ExtensionRegistry, installs: ExtensionInstalls, blobs: ExtensionBlobs, extensionLifecycle: ExtensionLifecycle, replicaStatus: ReplicaStatusStore, bootstrap: BootstrapService, bootstrapDefaults: BootstrapDefaultsService, marketplaces: MarketplacesService, pluginImport: PluginImport, pluginUpdater: PlatformPluginUpdater, platformComponents: PlatformComponents, bus: Pick<ExtensionContext["bus"], "publish" | "subscribe">, usageReport: UsageReporter, titles: TitleQueue, suggestions: PromptSuggestionQueue, channelJobs: ChannelJobs, channelOutbound: ChannelOutbound, presence: ReplicaPresence, worker?: WorkerRole | undefined, gateway?: GatewayRole | undefined);
120
+ constructor(permissionConfig: PermissionConfigPublication, accounts: AccountsService, configService: KernelConfigService, log: KernelLogger, options: KernelAppOptions, pool: Kysely<any>, redis: Redis, kdb: KernelDb, shutdown: GracefulShutdown, host: ExtensionHost, extensionDbIdentity: ExtensionDbIdentity, registry: ExtensionRegistry, installs: ExtensionInstalls, blobs: ExtensionBlobs, extensionLifecycle: ExtensionLifecycle, revocations: ExtensionRevocations, replicaStatus: ReplicaStatusStore, bootstrap: BootstrapService, bootstrapDefaults: BootstrapDefaultsService, marketplaces: MarketplacesService, pluginImport: PluginImport, pluginUpdater: PlatformPluginUpdater, platformComponents: PlatformComponents, bus: Pick<ExtensionContext["bus"], "publish" | "subscribe">, usageReport: UsageReporter, titles: TitleQueue, suggestions: PromptSuggestionQueue, channelJobs: ChannelJobs, channelOutbound: ChannelOutbound, presence: ReplicaPresence, worker?: WorkerRole | undefined, gateway?: GatewayRole | undefined);
119
121
  /** The kernel HTTP application (set up by `buildKernelApp` before `init()`). */
120
122
  get http(): KernelHttpApp;
121
123
  attachHttp(http: KernelHttpApp): void;
@@ -29,6 +29,7 @@ import { installedExtensionTier } from "../extensions/isolated/tier.js";
29
29
  import { ExtensionLifecycle } from "../extensions/lifecycle.js";
30
30
  import { ensureMigrated } from "../extensions/migrate-lock.js";
31
31
  import { ExtensionRegistry } from "../extensions/registry.js";
32
+ import { ExtensionRevocations } from "../extensions/revocation.js";
32
33
  import { ReplicaStatusStore } from "../extensions/sources.js";
33
34
  import { syncPackage } from "../extensions/sync.js";
34
35
  import { AccountsService } from "../identity/accounts.js";
@@ -106,6 +107,7 @@ let KernelLifecycle = class KernelLifecycle {
106
107
  installs;
107
108
  blobs;
108
109
  extensionLifecycle;
110
+ revocations;
109
111
  replicaStatus;
110
112
  bootstrap;
111
113
  bootstrapDefaults;
@@ -140,7 +142,7 @@ let KernelLifecycle = class KernelLifecycle {
140
142
  mergedManifest;
141
143
  constructor(permissionConfig, accounts, configService, log, options,
142
144
  // biome-ignore lint/suspicious/noExplicitAny: the pool carries no schema types
143
- pool, redis, kdb, shutdown, host, extensionDbIdentity, registry, installs, blobs, extensionLifecycle, replicaStatus, bootstrap, bootstrapDefaults, marketplaces, pluginImport, pluginUpdater, platformComponents, bus,
145
+ pool, redis, kdb, shutdown, host, extensionDbIdentity, registry, installs, blobs, extensionLifecycle, revocations, replicaStatus, bootstrap, bootstrapDefaults, marketplaces, pluginImport, pluginUpdater, platformComponents, bus,
144
146
  // the producers closed on every role (their consumers are the worker role's)
145
147
  usageReport, titles, suggestions, channelJobs, channelOutbound,
146
148
  // this process's presence beat, on every role (admin overview spec §5.1)
@@ -163,6 +165,7 @@ let KernelLifecycle = class KernelLifecycle {
163
165
  this.installs = installs;
164
166
  this.blobs = blobs;
165
167
  this.extensionLifecycle = extensionLifecycle;
168
+ this.revocations = revocations;
166
169
  this.replicaStatus = replicaStatus;
167
170
  this.bootstrap = bootstrap;
168
171
  this.bootstrapDefaults = bootstrapDefaults;
@@ -336,6 +339,7 @@ let KernelLifecycle = class KernelLifecycle {
336
339
  this.http.mountPlugins(this.host.routeTable());
337
340
  // 订阅插件生命周期主题后补一次 reconcile(启动加载期间错过的消息,并写下第一轮心跳)
338
341
  await this.extensionLifecycle.start();
342
+ await this.revocations.start();
339
343
  this.checkpoint();
340
344
  await this.extensionLifecycle.reconcile("startup");
341
345
  this.checkpoint();
@@ -531,6 +535,7 @@ let KernelLifecycle = class KernelLifecycle {
531
535
  await within("devices", gateway?.stopDevices() ?? Promise.resolve(), DEVICES_STOP_MS);
532
536
  // 不再接 reconcile(进行中的那次由宿主关闭收尾)
533
537
  await within("plugin-lifecycle", this.extensionLifecycle.stop(), 1_000);
538
+ await within("grant-revocation-hints", this.revocations.stop(), 1_000);
534
539
  // http 阶段:等 listen 与关闭 HTTP 共用一个截止时间;listen 卡满预算时关闭只剩 0ms,直接强制断开
535
540
  const httpDeadline = Date.now() + STOP_BUDGET_MS.http;
536
541
  if (this.listenStarted)
@@ -589,23 +594,24 @@ KernelLifecycle = __decorate([
589
594
  __param(12, Inject(ExtensionInstalls)),
590
595
  __param(13, Inject(ExtensionBlobs)),
591
596
  __param(14, Inject(ExtensionLifecycle)),
592
- __param(15, Inject(ReplicaStatusStore)),
593
- __param(16, Inject(BootstrapService)),
594
- __param(17, Inject(BootstrapDefaultsService)),
595
- __param(18, Inject(MarketplacesService)),
596
- __param(19, Inject(PluginImport)),
597
- __param(20, Inject(PlatformPluginUpdater)),
598
- __param(21, Inject(PlatformComponents)),
599
- __param(22, Inject(KERNEL_BUS)),
600
- __param(23, Inject(UsageReporter)),
601
- __param(24, Inject(TitleQueue)),
602
- __param(25, Inject(PromptSuggestionQueue)),
603
- __param(26, Inject(ChannelJobs)),
604
- __param(27, Inject(ChannelOutbound)),
605
- __param(28, Inject(ReplicaPresence)),
606
- __param(29, Optional()),
607
- __param(29, Inject(WorkerRole)),
597
+ __param(15, Inject(ExtensionRevocations)),
598
+ __param(16, Inject(ReplicaStatusStore)),
599
+ __param(17, Inject(BootstrapService)),
600
+ __param(18, Inject(BootstrapDefaultsService)),
601
+ __param(19, Inject(MarketplacesService)),
602
+ __param(20, Inject(PluginImport)),
603
+ __param(21, Inject(PlatformPluginUpdater)),
604
+ __param(22, Inject(PlatformComponents)),
605
+ __param(23, Inject(KERNEL_BUS)),
606
+ __param(24, Inject(UsageReporter)),
607
+ __param(25, Inject(TitleQueue)),
608
+ __param(26, Inject(PromptSuggestionQueue)),
609
+ __param(27, Inject(ChannelJobs)),
610
+ __param(28, Inject(ChannelOutbound)),
611
+ __param(29, Inject(ReplicaPresence)),
608
612
  __param(30, Optional()),
609
- __param(30, Inject(GatewayRole))
613
+ __param(30, Inject(WorkerRole)),
614
+ __param(31, Optional()),
615
+ __param(31, Inject(GatewayRole))
610
616
  ], KernelLifecycle);
611
617
  export { KernelLifecycle };
@@ -8,6 +8,7 @@ import { EXTENSION_NET_SEAMS, type ExtensionNetSeams } from "./ctx/net.js";
8
8
  import type { EvalReplayHooks } from "./evals/run-replay.js";
9
9
  import { EVAL_REPLAY_HOOKS } from "./evals/worker.js";
10
10
  import { BOOTSTRAP_LOCK_TTL } from "./extensions/bootstrap.js";
11
+ import { REVOCATION_ENFORCEMENT } from "./extensions/revocation-leases.js";
11
12
  import { USAGE_SUBSCRIBERS_CLOCK } from "./extensions/usage-subscribers.js";
12
13
  import { FILE_PREVIEW_TIMEOUT } from "./files/previewers.js";
13
14
  import { GIT_UPSTREAM_ORIGIN, type GitUpstreamOrigin } from "./git/gateway.js";
@@ -71,7 +72,9 @@ import { EMBED_TOKEN_CLOCK } from "./ui/embed-token.js";
71
72
  * - `APP_INTERCEPTOR`: one more global interceptor (a probe of the matched routes);
72
73
  * - `TOOL_WATCH_TIMINGS`: shorter watched-wait poll timings (interval, watcher timeout);
73
74
  * - `PERMISSION_AUTO_GRANT_HOOKS`: a barrier after a Full access auto-grant's precheck (two
74
- * replicas racing the same crossing).
75
+ * replicas racing the same crossing);
76
+ * - `REVOCATION_ENFORCEMENT`: enforce grant revocation before plan task 1.5a (the dual-replica tests
77
+ * of the enforcing branches; removed with the shadow switch by 1.5a).
75
78
  */
76
79
  interface KernelSeams {
77
80
  [AGENT_LOOP_FACTORY]: AgentLoopFactory;
@@ -105,6 +108,7 @@ interface KernelSeams {
105
108
  [APP_INTERCEPTOR]: NestInterceptor;
106
109
  [PERMISSION_AUTO_GRANT_HOOKS]: PermissionAutoGrantHooks;
107
110
  [TOOL_WATCH_TIMINGS]: Partial<ToolWatchTimings>;
111
+ [REVOCATION_ENFORCEMENT]: boolean;
108
112
  }
109
113
  /**
110
114
  * A seam of the kernel's own tests (`KernelAppOptions.overrides`): a value for one of the named
package/dist/overrides.js CHANGED
@@ -6,6 +6,7 @@ import { PROMPT_SUGGESTION_TIMEOUT } from "./conversations/prompt-suggestions.js
6
6
  import { EXTENSION_NET_SEAMS } from "./ctx/net.js";
7
7
  import { EVAL_REPLAY_HOOKS } from "./evals/worker.js";
8
8
  import { BOOTSTRAP_LOCK_TTL } from "./extensions/bootstrap.js";
9
+ import { REVOCATION_ENFORCEMENT } from "./extensions/revocation-leases.js";
9
10
  import { USAGE_SUBSCRIBERS_CLOCK } from "./extensions/usage-subscribers.js";
10
11
  import { FILE_PREVIEW_TIMEOUT } from "./files/previewers.js";
11
12
  import { GIT_UPSTREAM_ORIGIN } from "./git/gateway.js";
@@ -61,6 +62,7 @@ const SEAM_TOKENS = [
61
62
  APP_INTERCEPTOR,
62
63
  PERMISSION_AUTO_GRANT_HOOKS,
63
64
  TOOL_WATCH_TIMINGS,
65
+ REVOCATION_ENFORCEMENT,
64
66
  ];
65
67
  const allSeamsListed = true;
66
68
  void allSeamsListed;
@@ -12,8 +12,52 @@ export interface OfficialPublisherProof extends Provenance {
12
12
  evidenceDigest: string;
13
13
  policyVersion: typeof POLICY_VERSION;
14
14
  }
15
+ /** A build signer's GitHub Actions identity, read from the Fulcio certificate extensions. */
16
+ export interface PublisherCertificate {
17
+ /** The OIDC issuer the certificate was issued for. */
18
+ issuer: string;
19
+ /** The certificate's subject alternative name: `<repository>/<workflow>@<ref>`. */
20
+ identity: string;
21
+ /** The source repository URL. */
22
+ repository: string;
23
+ repositoryId: string;
24
+ ownerId: string;
25
+ /** The workflow file path within the repository. */
26
+ workflow: string;
27
+ /** The git ref the workflow ran on. */
28
+ ref: string;
29
+ /** The source commit. */
30
+ commit: string;
31
+ }
32
+ /** A package revision whose registry publish and build attestations both verified. */
33
+ export interface VerifiedPublisher {
34
+ revision: OfficialNpmRevision;
35
+ certificate: PublisherCertificate;
36
+ buildType: string;
37
+ evidenceDigest: string;
38
+ }
39
+ /**
40
+ * Any GitHub Actions publisher (publisher evidence for review and continuity, plan task 1.2e):
41
+ * both attestations verified, and the build predicate in agreement with the certificate. The
42
+ * identity is returned as signed; `catalog/provenance.ts` normalizes it.
43
+ */
44
+ export declare function verifyPublisher(body: unknown, revision: OfficialNpmRevision): VerifiedPublisher;
45
+ /**
46
+ * The one definition of official proof, shared by the official marketplace's admission
47
+ * ({@link verifyOfficialPublisher}) and publisher evidence (`classifyPublisherEvidence`): a revision
48
+ * whose attestations verified ({@link verifyPublisher}: the build predicate agrees with the
49
+ * certificate and its source commit) is official when the certificate is the official release
50
+ * workflow on the official repository's main ref, the build type is the GitHub Actions workflow
51
+ * build, and the package is in the Capybara plugin namespace. Returns why it is not, or undefined.
52
+ */
53
+ export declare function officialPublisherProblem(verified: VerifiedPublisher): string | undefined;
15
54
  /** Checks both signatures, transparency evidence and publisher identity with the bundled roots. */
16
55
  export declare function verifyOfficialPublisher(body: unknown, revision: OfficialNpmRevision): OfficialPublisherProof;
17
56
  /** Uses the same bounded registry client as the review's display-only provenance. */
18
57
  export declare function fetchOfficialPublisher(cfg: NpmFetchConfig, revision: OfficialNpmRevision, signal?: AbortSignal): Promise<OfficialPublisherProof>;
58
+ /** A failed publisher check; `transient` failures (network, timeout, 5xx) may pass on a retry soon. */
59
+ export declare class OfficialPublisherError extends Error {
60
+ readonly transient: boolean;
61
+ constructor(cause: unknown, transient: boolean);
62
+ }
19
63
  export {};