@xemahq/kernel-contracts 0.13.4 → 0.14.0

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://xema.dev/schemas/awp-spec.v1.json",
3
- "emittedAt": "2026-06-22T08:00:29.978Z",
3
+ "emittedAt": "2026-06-22T09:58:02.236Z",
4
4
  "spec": {
5
5
  "id": "awp/v1",
6
6
  "version": "1.2.0",
@@ -2,4 +2,5 @@ export * from './lib/contribution-kind';
2
2
  export * from './lib/contribution-source';
3
3
  export * from './lib/contribution';
4
4
  export * from './lib/registry';
5
+ export * from './lib/sync';
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contribution/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contribution/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC"}
@@ -18,4 +18,5 @@ __exportStar(require("./lib/contribution-kind"), exports);
18
18
  __exportStar(require("./lib/contribution-source"), exports);
19
19
  __exportStar(require("./lib/contribution"), exports);
20
20
  __exportStar(require("./lib/registry"), exports);
21
+ __exportStar(require("./lib/sync"), exports);
21
22
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/contribution/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0DAAwC;AACxC,4DAA0C;AAC1C,qDAAmC;AACnC,iDAA+B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/contribution/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0DAAwC;AACxC,4DAA0C;AAC1C,qDAAmC;AACnC,iDAA+B;AAC/B,6CAA2B"}
@@ -0,0 +1,75 @@
1
+ import { z } from 'zod';
2
+ import { ContributionKind } from './contribution-kind';
3
+ import { AnyContributionEnvelopeSchema } from './contribution';
4
+ export declare enum ContributionOwnerKind {
5
+ Biome = "biome",
6
+ RuntimeService = "runtime_service",
7
+ SystemSeed = "system_seed"
8
+ }
9
+ export declare const ContributionOwnerKindSchema: z.ZodEnum<typeof ContributionOwnerKind>;
10
+ export interface ContributionOwner {
11
+ readonly type: ContributionOwnerKind;
12
+ readonly id: string;
13
+ readonly version?: string;
14
+ }
15
+ export declare const ContributionOwnerSchema: z.ZodObject<{
16
+ type: z.ZodEnum<typeof ContributionOwnerKind>;
17
+ id: z.ZodString;
18
+ version: z.ZodOptional<z.ZodString>;
19
+ }, z.core.$strip>;
20
+ export declare enum ContributionSyncStatus {
21
+ NotSynced = "not_synced",
22
+ Syncing = "syncing",
23
+ Synced = "synced",
24
+ SyncFailed = "sync_failed",
25
+ PendingRetry = "pending_retry",
26
+ Partial = "partial"
27
+ }
28
+ export declare const ContributionSyncStatusSchema: z.ZodEnum<typeof ContributionSyncStatus>;
29
+ export interface ContributionSyncRequest {
30
+ readonly owner: ContributionOwner;
31
+ readonly kind: ContributionKind;
32
+ readonly items: readonly z.infer<typeof AnyContributionEnvelopeSchema>[];
33
+ readonly contentHash: string;
34
+ readonly syncToken: string;
35
+ }
36
+ export declare const ContributionSyncRequestSchema: z.ZodObject<{
37
+ owner: z.ZodObject<{
38
+ type: z.ZodEnum<typeof ContributionOwnerKind>;
39
+ id: z.ZodString;
40
+ version: z.ZodOptional<z.ZodString>;
41
+ }, z.core.$strip>;
42
+ kind: z.ZodEnum<typeof ContributionKind>;
43
+ items: z.ZodArray<z.ZodObject<{
44
+ kind: z.ZodEnum<typeof ContributionKind>;
45
+ slug: z.ZodString;
46
+ source: z.ZodEnum<typeof import("./contribution-source").ContributionSource>;
47
+ version: z.ZodString;
48
+ manifest: z.ZodUnknown;
49
+ }, z.core.$strip>>;
50
+ contentHash: z.ZodString;
51
+ syncToken: z.ZodString;
52
+ }, z.core.$strip>;
53
+ export interface ContributionSyncResult {
54
+ readonly owner: ContributionOwner;
55
+ readonly kind: ContributionKind;
56
+ readonly upserted: number;
57
+ readonly pruned: number;
58
+ readonly unchanged: number;
59
+ readonly skippedNoOp: boolean;
60
+ readonly status: ContributionSyncStatus;
61
+ }
62
+ export declare const ContributionSyncResultSchema: z.ZodObject<{
63
+ owner: z.ZodObject<{
64
+ type: z.ZodEnum<typeof ContributionOwnerKind>;
65
+ id: z.ZodString;
66
+ version: z.ZodOptional<z.ZodString>;
67
+ }, z.core.$strip>;
68
+ kind: z.ZodEnum<typeof ContributionKind>;
69
+ upserted: z.ZodNumber;
70
+ pruned: z.ZodNumber;
71
+ unchanged: z.ZodNumber;
72
+ skippedNoOp: z.ZodBoolean;
73
+ status: z.ZodEnum<typeof ContributionSyncStatus>;
74
+ }, z.core.$strip>;
75
+ //# sourceMappingURL=sync.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../../src/contribution/lib/sync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAA0B,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,6BAA6B,EAAE,MAAM,gBAAgB,CAAC;AAqC/D,oBAAY,qBAAqB;IAC/B,KAAK,UAAU;IACf,cAAc,oBAAoB;IAClC,UAAU,gBAAgB;CAC3B;AAED,eAAO,MAAM,2BAA2B,yCAAsC,CAAC;AAG/E,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,EAAE,qBAAqB,CAAC;IAErC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAEpB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,eAAO,MAAM,uBAAuB;;;;iBAIlC,CAAC;AAgBH,oBAAY,sBAAsB;IAChC,SAAS,eAAe;IACxB,OAAO,YAAY;IACnB,MAAM,WAAW;IACjB,UAAU,gBAAgB;IAC1B,YAAY,kBAAkB;IAC9B,OAAO,YAAY;CACpB;AAED,eAAO,MAAM,4BAA4B,0CAAuC,CAAC;AAWjF,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,KAAK,EAAE,iBAAiB,CAAC;IAClC,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAChC,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,EAAE,CAAC;IACzE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;iBAMxC,CAAC;AAGH,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,KAAK,EAAE,iBAAiB,CAAC;IAClC,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAChC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,sBAAsB,CAAC;CACzC;AAED,eAAO,MAAM,4BAA4B;;;;;;;;;;;;iBAQvC,CAAC"}
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ContributionSyncResultSchema = exports.ContributionSyncRequestSchema = exports.ContributionSyncStatusSchema = exports.ContributionSyncStatus = exports.ContributionOwnerSchema = exports.ContributionOwnerKindSchema = exports.ContributionOwnerKind = void 0;
4
+ const zod_1 = require("zod");
5
+ const contribution_kind_1 = require("./contribution-kind");
6
+ const contribution_1 = require("./contribution");
7
+ var ContributionOwnerKind;
8
+ (function (ContributionOwnerKind) {
9
+ ContributionOwnerKind["Biome"] = "biome";
10
+ ContributionOwnerKind["RuntimeService"] = "runtime_service";
11
+ ContributionOwnerKind["SystemSeed"] = "system_seed";
12
+ })(ContributionOwnerKind || (exports.ContributionOwnerKind = ContributionOwnerKind = {}));
13
+ exports.ContributionOwnerKindSchema = zod_1.z.nativeEnum(ContributionOwnerKind);
14
+ exports.ContributionOwnerSchema = zod_1.z.object({
15
+ type: exports.ContributionOwnerKindSchema,
16
+ id: zod_1.z.string().min(1),
17
+ version: zod_1.z.string().min(1).optional(),
18
+ });
19
+ var ContributionSyncStatus;
20
+ (function (ContributionSyncStatus) {
21
+ ContributionSyncStatus["NotSynced"] = "not_synced";
22
+ ContributionSyncStatus["Syncing"] = "syncing";
23
+ ContributionSyncStatus["Synced"] = "synced";
24
+ ContributionSyncStatus["SyncFailed"] = "sync_failed";
25
+ ContributionSyncStatus["PendingRetry"] = "pending_retry";
26
+ ContributionSyncStatus["Partial"] = "partial";
27
+ })(ContributionSyncStatus || (exports.ContributionSyncStatus = ContributionSyncStatus = {}));
28
+ exports.ContributionSyncStatusSchema = zod_1.z.nativeEnum(ContributionSyncStatus);
29
+ exports.ContributionSyncRequestSchema = zod_1.z.object({
30
+ owner: exports.ContributionOwnerSchema,
31
+ kind: contribution_kind_1.ContributionKindSchema,
32
+ items: zod_1.z.array(contribution_1.AnyContributionEnvelopeSchema),
33
+ contentHash: zod_1.z.string().min(1),
34
+ syncToken: zod_1.z.string().min(1),
35
+ });
36
+ exports.ContributionSyncResultSchema = zod_1.z.object({
37
+ owner: exports.ContributionOwnerSchema,
38
+ kind: contribution_kind_1.ContributionKindSchema,
39
+ upserted: zod_1.z.number().int().nonnegative(),
40
+ pruned: zod_1.z.number().int().nonnegative(),
41
+ unchanged: zod_1.z.number().int().nonnegative(),
42
+ skippedNoOp: zod_1.z.boolean(),
43
+ status: exports.ContributionSyncStatusSchema,
44
+ });
45
+ //# sourceMappingURL=sync.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync.js","sourceRoot":"","sources":["../../../src/contribution/lib/sync.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,2DAA+E;AAC/E,iDAA+D;AAqC/D,IAAY,qBAIX;AAJD,WAAY,qBAAqB;IAC/B,wCAAe,CAAA;IACf,2DAAkC,CAAA;IAClC,mDAA0B,CAAA;AAC5B,CAAC,EAJW,qBAAqB,qCAArB,qBAAqB,QAIhC;AAEY,QAAA,2BAA2B,GAAG,OAAC,CAAC,UAAU,CAAC,qBAAqB,CAAC,CAAC;AAWlE,QAAA,uBAAuB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC9C,IAAI,EAAE,mCAA2B;IACjC,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACrB,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;CACtC,CAAC,CAAC;AAgBH,IAAY,sBAOX;AAPD,WAAY,sBAAsB;IAChC,kDAAwB,CAAA;IACxB,6CAAmB,CAAA;IACnB,2CAAiB,CAAA;IACjB,oDAA0B,CAAA;IAC1B,wDAA8B,CAAA;IAC9B,6CAAmB,CAAA;AACrB,CAAC,EAPW,sBAAsB,sCAAtB,sBAAsB,QAOjC;AAEY,QAAA,4BAA4B,GAAG,OAAC,CAAC,UAAU,CAAC,sBAAsB,CAAC,CAAC;AAmBpE,QAAA,6BAA6B,GAAG,OAAC,CAAC,MAAM,CAAC;IACpD,KAAK,EAAE,+BAAuB;IAC9B,IAAI,EAAE,0CAAsB;IAC5B,KAAK,EAAE,OAAC,CAAC,KAAK,CAAC,4CAA6B,CAAC;IAC7C,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC9B,SAAS,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CAC7B,CAAC,CAAC;AAaU,QAAA,4BAA4B,GAAG,OAAC,CAAC,MAAM,CAAC;IACnD,KAAK,EAAE,+BAAuB;IAC9B,IAAI,EAAE,0CAAsB;IAC5B,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE;IACxC,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE;IACtC,SAAS,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE;IACzC,WAAW,EAAE,OAAC,CAAC,OAAO,EAAE;IACxB,MAAM,EAAE,oCAA4B;CACrC,CAAC,CAAC"}
@@ -3,6 +3,8 @@ export declare enum ResourceManagedBy {
3
3
  Ui = "ui",
4
4
  Iac = "iac",
5
5
  Seeder = "seeder",
6
+ BiomeContributed = "biome_contributed",
7
+ RuntimeRegistered = "runtime_registered",
6
8
  System = "system"
7
9
  }
8
10
  export declare const ResourceManagedBySchema: z.ZodEnum<typeof ResourceManagedBy>;
@@ -1 +1 @@
1
- {"version":3,"file":"resource-managed-by.d.ts","sourceRoot":"","sources":["../../../src/resource/lib/resource-managed-by.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAqBxB,oBAAY,iBAAiB;IAC3B,EAAE,OAAO;IACT,GAAG,QAAQ;IACX,MAAM,WAAW;IACjB,MAAM,WAAW;CAClB;AAED,eAAO,MAAM,uBAAuB,qCAAkC,CAAC"}
1
+ {"version":3,"file":"resource-managed-by.d.ts","sourceRoot":"","sources":["../../../src/resource/lib/resource-managed-by.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAgCxB,oBAAY,iBAAiB;IAC3B,EAAE,OAAO;IACT,GAAG,QAAQ;IACX,MAAM,WAAW;IACjB,gBAAgB,sBAAsB;IACtC,iBAAiB,uBAAuB;IACxC,MAAM,WAAW;CAClB;AAED,eAAO,MAAM,uBAAuB,qCAAkC,CAAC"}
@@ -7,6 +7,8 @@ var ResourceManagedBy;
7
7
  ResourceManagedBy["Ui"] = "ui";
8
8
  ResourceManagedBy["Iac"] = "iac";
9
9
  ResourceManagedBy["Seeder"] = "seeder";
10
+ ResourceManagedBy["BiomeContributed"] = "biome_contributed";
11
+ ResourceManagedBy["RuntimeRegistered"] = "runtime_registered";
10
12
  ResourceManagedBy["System"] = "system";
11
13
  })(ResourceManagedBy || (exports.ResourceManagedBy = ResourceManagedBy = {}));
12
14
  exports.ResourceManagedBySchema = zod_1.z.nativeEnum(ResourceManagedBy);
@@ -1 +1 @@
1
- {"version":3,"file":"resource-managed-by.js","sourceRoot":"","sources":["../../../src/resource/lib/resource-managed-by.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAqBxB,IAAY,iBAKX;AALD,WAAY,iBAAiB;IAC3B,8BAAS,CAAA;IACT,gCAAW,CAAA;IACX,sCAAiB,CAAA;IACjB,sCAAiB,CAAA;AACnB,CAAC,EALW,iBAAiB,iCAAjB,iBAAiB,QAK5B;AAEY,QAAA,uBAAuB,GAAG,OAAC,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC"}
1
+ {"version":3,"file":"resource-managed-by.js","sourceRoot":"","sources":["../../../src/resource/lib/resource-managed-by.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAgCxB,IAAY,iBAOX;AAPD,WAAY,iBAAiB;IAC3B,8BAAS,CAAA;IACT,gCAAW,CAAA;IACX,sCAAiB,CAAA;IACjB,2DAAsC,CAAA;IACtC,6DAAwC,CAAA;IACxC,sCAAiB,CAAA;AACnB,CAAC,EAPW,iBAAiB,iCAAjB,iBAAiB,QAO5B;AAEY,QAAA,uBAAuB,GAAG,OAAC,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xemahq/kernel-contracts",
3
- "version": "0.13.4",
3
+ "version": "0.14.0",
4
4
  "description": "Consolidated Xema OS kernel wire contracts — pure types + zod schemas for the 32 kernel protocol surfaces. One package, one npm scope, wildcard per-surface subpath exports. No framework/runtime deps.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/",
@@ -2,3 +2,4 @@ export * from './lib/contribution-kind';
2
2
  export * from './lib/contribution-source';
3
3
  export * from './lib/contribution';
4
4
  export * from './lib/registry';
5
+ export * from './lib/sync';
@@ -0,0 +1,132 @@
1
+ import { z } from 'zod';
2
+ import { ContributionKind, ContributionKindSchema } from './contribution-kind';
3
+ import { AnyContributionEnvelopeSchema } from './contribution';
4
+
5
+ // NOTE: the `contribution` subpath is a DAG leaf and MUST NOT import the
6
+ // `resource` subpath (enforced by check-subpath-dag.mjs). The mapping from
7
+ // `ContributionOwnerKind` to `ResourceManagedBy` therefore lives in the
8
+ // consuming SDK (`@xemahq/contribution-sync-nest`), which legally depends on
9
+ // both subpaths. Keep that mapping the single source of truth there.
10
+
11
+ // ═══════════════════════════════════════════════════════════════════════════
12
+ // Contribution sync — the declarative, owner-scoped push contract.
13
+ //
14
+ // biome-host (and a runtime service self-registering its own capabilities)
15
+ // pushes the COMPLETE desired set of contributions for one `(owner, kind)`
16
+ // to the owning registry over HTTP. The registry upserts every item and
17
+ // prunes anything it owns for that `(owner, kind)` that is no longer present.
18
+ //
19
+ // This replaces the boot-time local-directory scan: registries no longer read
20
+ // biome trees off disk; they receive their content. Pruning is owner-scoped
21
+ // (NEVER installation-scoped — biome content is platform-global and shared
22
+ // across org/project installs), so a per-tenant enable/disable never deletes
23
+ // shared content.
24
+ // ═══════════════════════════════════════════════════════════════════════════
25
+
26
+ /**
27
+ * Who owns a pushed set of contributions. The typed owner keeps three
28
+ * lifecycles cleanly separated while sharing ONE engine + wire shape:
29
+ *
30
+ * - `Biome` — a biome bundle's contributions, pushed by biome-host.
31
+ * `id` is the biome id, `version` the biome version. Maps to
32
+ * `ResourceManagedBy.BiomeContributed`.
33
+ * - `RuntimeService` — a service self-registering its OWN capabilities (the
34
+ * `@XemaCapability` auto-register path). `id` is the service name. Maps to
35
+ * `ResourceManagedBy.RuntimeRegistered`.
36
+ * - `SystemSeed` — a genuine package/in-service seed that is neither a
37
+ * biome push nor runtime self-registration (`@xemahq/system-skills`,
38
+ * `INITIAL_CAPABILITY_SEED`). Maps to `ResourceManagedBy.Seeder`.
39
+ */
40
+ export enum ContributionOwnerKind {
41
+ Biome = 'biome',
42
+ RuntimeService = 'runtime_service',
43
+ SystemSeed = 'system_seed',
44
+ }
45
+
46
+ export const ContributionOwnerKindSchema = z.nativeEnum(ContributionOwnerKind);
47
+
48
+ /** The typed owner of a pushed contribution set. */
49
+ export interface ContributionOwner {
50
+ readonly type: ContributionOwnerKind;
51
+ /** Biome id, service name, or seed id depending on `type`. */
52
+ readonly id: string;
53
+ /** Biome/bundle version for `Biome` owners; optional otherwise. */
54
+ readonly version?: string;
55
+ }
56
+
57
+ export const ContributionOwnerSchema = z.object({
58
+ type: ContributionOwnerKindSchema,
59
+ id: z.string().min(1),
60
+ version: z.string().min(1).optional(),
61
+ });
62
+
63
+ /**
64
+ * Lifecycle/availability status of a registry's content for one `(owner, kind)`.
65
+ * Persisted by the registry and aggregated by biome-host for the UI AND used by
66
+ * the registry to gate consumption (a not-fully-synced set is not served).
67
+ *
68
+ * - `NOT_SYNCED` — never synced; no rows exist yet (structural empty).
69
+ * - `SYNCING` — a sync is in flight.
70
+ * - `SYNCED` — desired === active; content is the current good set.
71
+ * - `SYNC_FAILED` — last attempt failed (e.g. referential-integrity reject);
72
+ * the prior `active` set is preserved and still served.
73
+ * - `PENDING_RETRY`— transient failure queued for retry (outbox).
74
+ * - `PARTIAL` — synced, but a cross-service dependency is unsatisfied;
75
+ * affected items are not launchable until it resolves.
76
+ */
77
+ export enum ContributionSyncStatus {
78
+ NotSynced = 'not_synced',
79
+ Syncing = 'syncing',
80
+ Synced = 'synced',
81
+ SyncFailed = 'sync_failed',
82
+ PendingRetry = 'pending_retry',
83
+ Partial = 'partial',
84
+ }
85
+
86
+ export const ContributionSyncStatusSchema = z.nativeEnum(ContributionSyncStatus);
87
+
88
+ /**
89
+ * The push request. `items` is the COMPLETE desired set for `(owner, kind)`
90
+ * after the pusher's cross-biome `extends`-dedup — never a delta.
91
+ *
92
+ * `contentHash` is a stable sha256 over the canonicalized `items` (idempotent
93
+ * no-op detection). `syncToken` is a MONOTONIC lifecycle-attempt token (ULID /
94
+ * sequence / transition counter) — deliberately NOT derived from the version,
95
+ * so a downgrade still carries a higher token than the upgrade it reverts.
96
+ */
97
+ export interface ContributionSyncRequest {
98
+ readonly owner: ContributionOwner;
99
+ readonly kind: ContributionKind;
100
+ readonly items: readonly z.infer<typeof AnyContributionEnvelopeSchema>[];
101
+ readonly contentHash: string;
102
+ readonly syncToken: string;
103
+ }
104
+
105
+ export const ContributionSyncRequestSchema = z.object({
106
+ owner: ContributionOwnerSchema,
107
+ kind: ContributionKindSchema,
108
+ items: z.array(AnyContributionEnvelopeSchema),
109
+ contentHash: z.string().min(1),
110
+ syncToken: z.string().min(1),
111
+ });
112
+
113
+ /** The registry's response to a sync push. */
114
+ export interface ContributionSyncResult {
115
+ readonly owner: ContributionOwner;
116
+ readonly kind: ContributionKind;
117
+ readonly upserted: number;
118
+ readonly pruned: number;
119
+ readonly unchanged: number;
120
+ readonly skippedNoOp: boolean;
121
+ readonly status: ContributionSyncStatus;
122
+ }
123
+
124
+ export const ContributionSyncResultSchema = z.object({
125
+ owner: ContributionOwnerSchema,
126
+ kind: ContributionKindSchema,
127
+ upserted: z.number().int().nonnegative(),
128
+ pruned: z.number().int().nonnegative(),
129
+ unchanged: z.number().int().nonnegative(),
130
+ skippedNoOp: z.boolean(),
131
+ status: ContributionSyncStatusSchema,
132
+ });
@@ -4,10 +4,21 @@ import { z } from 'zod';
4
4
  * `ResourceManagedBy` — the ownership marker stamped on every provisionable
5
5
  * resource row. This single concept powers three behaviors with one switch:
6
6
  *
7
- * - `Seeder` — owned by a boot/event reconciler (e.g. portals derived from
8
- * installed web biomes). The reconciler may create/update/retire these.
7
+ * - `Seeder` — owned by a boot/event reconciler that is NOT a biome-bundle
8
+ * push (e.g. portals derived from installed web biomes, or genuine
9
+ * package/in-service seeds such as `@xemahq/system-skills` and
10
+ * `INITIAL_CAPABILITY_SEED`). The reconciler may create/update/retire these.
9
11
  * Retire-removed deletes ONLY `Seeder`-owned rows whose `managedKey` no
10
12
  * longer appears in the desired set.
13
+ * - `BiomeContributed` — owned by the biome-host contribution-sync push: a
14
+ * biome bundle's contributions (agents, skills, specs, …) materialized into
15
+ * an owning registry over HTTP at biome lifecycle time. Pruned biome-scoped
16
+ * (`owner.type=biome`, `owner.id=biomeId`) when a biome upgrade drops an item
17
+ * or the biome leaves the platform — NEVER on per-org/project enable/disable.
18
+ * - `RuntimeRegistered` — self-registered by a runtime service at boot (the
19
+ * `@XemaCapability` auto-register path: a service publishing its OWN
20
+ * capabilities). Owner is `owner.type=runtime_service`, `owner.id=serviceName`;
21
+ * its prune scope is the service, never a biome's content.
11
22
  * - `Iac` — owned by a declarative source (Terraform / `xema.yaml`).
12
23
  * Declared-state-wins: `plan` surfaces drift, `apply` reconciles back. No
13
24
  * reconciler touches a row it does not own.
@@ -23,6 +34,8 @@ export enum ResourceManagedBy {
23
34
  Ui = 'ui',
24
35
  Iac = 'iac',
25
36
  Seeder = 'seeder',
37
+ BiomeContributed = 'biome_contributed',
38
+ RuntimeRegistered = 'runtime_registered',
26
39
  System = 'system',
27
40
  }
28
41
 
@@ -7,10 +7,10 @@
7
7
  //
8
8
  // Runtime-NEUTRAL: a skill bundle (SKILL.md + resources) is identical across
9
9
  // every runtime; only WHERE it is finally placed inside the workspace differs
10
- // (`.opencode/skills`, `.qwen/skills`, `.claude/skills`, `.hermes/skills`), and
10
+ // (each runtime mounts skills under its own per-runtime skills subtree), and
11
11
  // that placement is owned by the worker's RuntimeLayout — NOT by this path.
12
12
  // This module describes the STORAGE location of the pre-staged bytes only, so
13
- // it works for OpenCode / Qwen / Claude / Hermes / any future runtime alike.
13
+ // it works for every runtime adapter alike, present and future.
14
14
  // ═══════════════════════════════════════════════════════════════════════════
15
15
  import { SpaceKind, type SpaceRef } from './space';
16
16