@ixo/topic-protocol 0.8.0 → 1.0.0-rc.1

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 (54) hide show
  1. package/README.md +6 -1
  2. package/dist/schemas/decision-to-pay-template-v2.schema.json +301 -0
  3. package/dist/schemas/payable-obligation-v2.schema.json +319 -0
  4. package/dist/schemas/payment-terms-v2.schema.json +238 -0
  5. package/dist/schemas/topic-contract-body.schema.json +66 -0
  6. package/dist/schemas/topic-contract-state.schema.json +63 -295
  7. package/dist/schemas/topic-recipe.schema.json +19 -0
  8. package/dist/schemas/topic-root.schema.json +17 -1
  9. package/dist/schemas/topic-shape.schema.json +79 -0
  10. package/dist/src/contracts/schemas.d.ts +3417 -1822
  11. package/dist/src/contracts/schemas.js +12 -0
  12. package/dist/src/contracts/schemas.js.map +1 -1
  13. package/dist/src/contracts/topic-contract.d.ts +30 -5
  14. package/dist/src/contracts/topic-contract.js +3 -1
  15. package/dist/src/contracts/topic-contract.js.map +1 -1
  16. package/dist/src/errors.d.ts +1 -1
  17. package/dist/src/errors.js.map +1 -1
  18. package/dist/src/index.d.ts +10 -2
  19. package/dist/src/index.js +9 -1
  20. package/dist/src/index.js.map +1 -1
  21. package/dist/src/projector/types.d.ts +9 -1
  22. package/dist/src/projector/types.js.map +1 -1
  23. package/dist/src/shapes/canonical.d.ts +2 -0
  24. package/dist/src/shapes/canonical.js +20 -0
  25. package/dist/src/shapes/canonical.js.map +1 -0
  26. package/dist/src/shapes/claims.d.ts +12 -0
  27. package/dist/src/shapes/claims.js +20 -0
  28. package/dist/src/shapes/claims.js.map +1 -0
  29. package/dist/src/shapes/now.d.ts +2 -0
  30. package/dist/src/shapes/now.js +42 -0
  31. package/dist/src/shapes/now.js.map +1 -0
  32. package/dist/src/shapes/progress.d.ts +3 -0
  33. package/dist/src/shapes/progress.js +176 -0
  34. package/dist/src/shapes/progress.js.map +1 -0
  35. package/dist/src/shapes/recipes.d.ts +5 -0
  36. package/dist/src/shapes/recipes.js +337 -0
  37. package/dist/src/shapes/recipes.js.map +1 -0
  38. package/dist/src/shapes/resolver.d.ts +14 -0
  39. package/dist/src/shapes/resolver.js +111 -0
  40. package/dist/src/shapes/resolver.js.map +1 -0
  41. package/dist/src/shapes/state.d.ts +53 -0
  42. package/dist/src/shapes/state.js +2 -0
  43. package/dist/src/shapes/state.js.map +1 -0
  44. package/dist/src/shapes/types.d.ts +241 -0
  45. package/dist/src/shapes/types.js +42 -0
  46. package/dist/src/shapes/types.js.map +1 -0
  47. package/package.json +3 -1
  48. package/recipes/README.md +12 -0
  49. package/recipes/agent-delivery.json +607 -0
  50. package/recipes/registry.json +41 -0
  51. package/recipes/research-brief.json +460 -0
  52. package/recipes/verified-work-payment.json +663 -0
  53. package/templates/decision-to-pay/README.md +27 -19
  54. package/templates/decision-to-pay/verified-work-payment.v0.2.template.json +319 -0
@@ -0,0 +1,111 @@
1
+ import { TopicProtocolError } from "../errors.js";
2
+ import { topicRecipeForKind } from "../contracts/topic-contract.js";
3
+ import { shapeDigest } from "./canonical.js";
4
+ import { BASE_RECIPE_REGISTRY, KIND_SHAPE_REGISTRY, TOPIC_RECIPE_REGISTRY } from "./recipes.js";
5
+ function replaceByCode(base, overlay) {
6
+ const values = new Map(base.map((value) => [value.code, value]));
7
+ for (const value of overlay)
8
+ values.set(value.code, value);
9
+ return [...values.values()].sort((left, right) => left.code.localeCompare(right.code));
10
+ }
11
+ function mergeShape(base, overlay) {
12
+ return {
13
+ version: 1,
14
+ code: overlay.code,
15
+ axes: replaceByCode(base.axes, overlay.axes ?? []),
16
+ transitions: replaceByCode(base.transitions, overlay.transitions ?? []),
17
+ progressRules: replaceByCode(base.progressRules, overlay.progressRules ?? []),
18
+ inferredRecordPolicy: {
19
+ autoAccept: [...new Set([...base.inferredRecordPolicy.autoAccept, ...overlay.inferredRecordPolicy.autoAccept])].sort(),
20
+ neverAutoAccept: [...new Set([...base.inferredRecordPolicy.neverAutoAccept, ...overlay.inferredRecordPolicy.neverAutoAccept])].sort(),
21
+ },
22
+ };
23
+ }
24
+ function validateAxis(axis) {
25
+ const states = new Set(axis.states.map(({ code }) => code));
26
+ if (states.has(axis.initialState) && states.size === axis.states.length)
27
+ return;
28
+ throw new TopicProtocolError("SHAPE_INVALID", `Shape axis is invalid: ${axis.code}`, { axis: axis.code });
29
+ }
30
+ function validateTransition(transition, axes) {
31
+ const predecessor = axes.get(transition.predecessor.axis);
32
+ const target = axes.get(transition.target.axis);
33
+ const valid = predecessor?.states.some(({ code }) => code === transition.predecessor.state) === true
34
+ && target?.states.some(({ code }) => code === transition.target.state) === true;
35
+ if (valid)
36
+ return;
37
+ throw new TopicProtocolError("SHAPE_INVALID", `Shape transition is invalid: ${transition.code}`, { transition: transition.code });
38
+ }
39
+ function validateShape(shape) {
40
+ for (const axis of shape.axes)
41
+ validateAxis(axis);
42
+ const axes = new Map(shape.axes.map((axis) => [axis.code, axis]));
43
+ for (const transition of shape.transitions)
44
+ validateTransition(transition, axes);
45
+ const completion = shape.transitions.filter(({ completesTopic }) => completesTopic === true);
46
+ if (completion.length === 1)
47
+ return;
48
+ throw new TopicProtocolError("SHAPE_INVALID", "A Shape must define exactly one Topic completion transition");
49
+ }
50
+ function recipeFor(ref, registry) {
51
+ const recipe = Object.values(registry).find(({ id, recipeVersion }) => id === ref.id && recipeVersion === ref.version);
52
+ if (recipe === undefined)
53
+ throw new TopicProtocolError("SHAPE_SOURCE_NOT_FOUND", `Topic Recipe not found: ${ref.id}`);
54
+ const digest = shapeDigest(recipe);
55
+ if (digest === ref.digest)
56
+ return recipe;
57
+ throw new TopicProtocolError("SHAPE_DIGEST_MISMATCH", `Topic Recipe digest does not match: ${ref.id}`, { expected: ref.digest, actual: digest });
58
+ }
59
+ function baseSource(baseRecipe, shape) {
60
+ return {
61
+ kind: "base-recipe",
62
+ id: `https://topic-protocol.ixo.world/base-recipes/${baseRecipe}`,
63
+ version: "1.0.0-rc.1",
64
+ digest: shapeDigest(shape),
65
+ };
66
+ }
67
+ export function resolveEffectiveTopicShape(input) {
68
+ const base = BASE_RECIPE_REGISTRY[input.baseRecipe];
69
+ let effective = base;
70
+ const sources = [baseSource(input.baseRecipe, base)];
71
+ if (input.topicRecipeRef !== undefined) {
72
+ const recipe = recipeFor(input.topicRecipeRef, input.recipeRegistry ?? TOPIC_RECIPE_REGISTRY);
73
+ if (recipe.baseRecipe !== input.baseRecipe) {
74
+ throw new TopicProtocolError("SHAPE_INVALID", "Topic Recipe does not extend the selected Base Recipe", {
75
+ baseRecipe: input.baseRecipe,
76
+ recipeBaseRecipe: recipe.baseRecipe,
77
+ });
78
+ }
79
+ effective = mergeShape(effective, recipe.shape);
80
+ sources.push({ kind: "topic-recipe", id: recipe.id, version: recipe.recipeVersion, digest: input.topicRecipeRef.digest });
81
+ }
82
+ if (input.kind !== undefined) {
83
+ const expectedBaseRecipe = topicRecipeForKind({ source: "standard", kind: input.kind });
84
+ if (expectedBaseRecipe !== input.baseRecipe) {
85
+ throw new TopicProtocolError("SHAPE_INVALID", "Topic Kind does not use the selected Base Recipe", {
86
+ kind: input.kind,
87
+ baseRecipe: input.baseRecipe,
88
+ expectedBaseRecipe,
89
+ });
90
+ }
91
+ const overlay = KIND_SHAPE_REGISTRY[input.kind];
92
+ effective = mergeShape(effective, overlay);
93
+ sources.push({
94
+ kind: "kind",
95
+ id: `https://topic-protocol.ixo.world/kinds/${input.kind}`,
96
+ version: "1.0.0-rc.1",
97
+ digest: shapeDigest(overlay),
98
+ });
99
+ }
100
+ for (const overlay of input.overlays ?? []) {
101
+ effective = mergeShape(effective, overlay.shape);
102
+ sources.push(overlay.source);
103
+ }
104
+ validateShape(effective);
105
+ const sortedSources = [...sources].sort((left, right) => `${left.kind}:${left.id}`.localeCompare(`${right.kind}:${right.id}`));
106
+ return { version: 1, shape: effective, sources: sortedSources, digest: shapeDigest({ shape: effective, sources: sortedSources }) };
107
+ }
108
+ export function topicRecipeRef(recipe) {
109
+ return { id: recipe.id, version: recipe.recipeVersion, digest: shapeDigest(recipe) };
110
+ }
111
+ //# sourceMappingURL=resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolver.js","sourceRoot":"","sources":["../../../src/shapes/resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAA2B,MAAM,gCAAgC,CAAC;AAC7F,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAwBhG,SAAS,aAAa,CAAsC,IAAkB,EAAE,OAAqB;IACnG,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IACjE,KAAK,MAAM,KAAK,IAAI,OAAO;QAAE,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC3D,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;AACzF,CAAC;AAED,SAAS,UAAU,CAAC,IAAkB,EAAE,OAA4B;IAClE,OAAO;QACL,OAAO,EAAE,CAAC;QACV,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,IAAI,EAAE,aAAa,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC;QAClD,WAAW,EAAE,aAAa,CAAC,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,WAAW,IAAI,EAAE,CAAC;QACvE,aAAa,EAAE,aAAa,CAAC,IA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OAAO,CAAC,KAAK,CAAC,CAAC;QACjD,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC/B,CAAC;IACD,aAAa,CAAC,SAAS,CAAC,CAAC;IACzB,MAAM,aAAa,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC,aAAa,CAAC,GAAG,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;IAC/H,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,aAAa,EAAE,CAAC,EAAE,CAAC;AACrI,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,MAAqB;IAClD,OAAO,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,aAAa,EAAE,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC;AACvF,CAAC"}
@@ -0,0 +1,53 @@
1
+ import type { TopicContractBodyV3 } from "../contracts/topic-contract.js";
2
+ import type { TopicFlowBindingV1 } from "../action-runtime/types.js";
3
+ import type { TopicAnchor, TopicContractHeads, TopicRootV3 } from "../projector/types.js";
4
+ import type { ResolvedTopicClaimBindingV1, TopicClaimBindingV1, TopicProgressProjectionV1, TopicShapeSourceRefV1 } from "./types.js";
5
+ export declare const TOPIC_STATE_PROFILE_V3 = "qi.topic-contract-state/v3";
6
+ export interface TopicContractReferenceV3 {
7
+ readonly revision: string;
8
+ readonly bodyHash: string;
9
+ readonly bodyRef: Readonly<Record<string, unknown>>;
10
+ readonly body?: TopicContractBodyV3;
11
+ }
12
+ export interface TopicStateBindingsV3 {
13
+ readonly flows?: readonly TopicFlowBindingV1[];
14
+ readonly context?: readonly {
15
+ readonly type: "ixo.resource" | "ixo.flow" | "matrix.conversation" | "ixo.entity" | "ixo.service";
16
+ readonly id: string;
17
+ readonly label?: string;
18
+ }[];
19
+ readonly udidReferences?: readonly {
20
+ readonly id: string;
21
+ readonly role: "evaluation" | "decision" | "effect" | "settlement";
22
+ readonly digest?: `sha256:${string}`;
23
+ }[];
24
+ }
25
+ export interface TopicContractStateV3 {
26
+ readonly version: 3;
27
+ readonly profile: typeof TOPIC_STATE_PROFILE_V3;
28
+ readonly schema: "https://topic-protocol.ixo.world/schemas/topic-contract-state.schema.json";
29
+ readonly topicId: string;
30
+ readonly anchor: TopicAnchor;
31
+ readonly manifest: TopicRootV3;
32
+ readonly contracts: TopicContractHeads;
33
+ readonly shape: {
34
+ readonly digest: `sha256:${string}`;
35
+ readonly sources: readonly TopicShapeSourceRefV1[];
36
+ };
37
+ readonly progress: TopicProgressProjectionV1;
38
+ readonly projection: {
39
+ readonly revision: string;
40
+ readonly contractRevision: string;
41
+ readonly title: string;
42
+ readonly status: TopicRootV3["status"];
43
+ readonly kindRef: TopicContractBodyV3["kindRef"];
44
+ readonly attachmentCount: number;
45
+ readonly operationCount: number;
46
+ readonly claimBinding?: TopicClaimBindingV1;
47
+ readonly claimResolution?: ResolvedTopicClaimBindingV1;
48
+ };
49
+ readonly policy: Readonly<Record<string, unknown>>;
50
+ readonly bindings: TopicStateBindingsV3;
51
+ readonly provenance: Readonly<Record<string, unknown>>;
52
+ readonly extensions?: Readonly<Record<string, unknown>>;
53
+ }
@@ -0,0 +1,2 @@
1
+ export const TOPIC_STATE_PROFILE_V3 = "qi.topic-contract-state/v3";
2
+ //# sourceMappingURL=state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.js","sourceRoot":"","sources":["../../../src/shapes/state.ts"],"names":[],"mappings":"AAUA,MAAM,CAAC,MAAM,sBAAsB,GAAG,4BAA4B,CAAC"}
@@ -0,0 +1,241 @@
1
+ export declare const SHAPE_PHASES: readonly ["forming", "working", "verifying", "deciding", "effecting", "settling", "complete", "dormant"];
2
+ export declare const SHAPE_CONDITIONS: readonly ["on-track", "needs-input", "needs-acceptance", "waiting", "blocked", "failed", "disputed", "degraded"];
3
+ export declare const SHAPE_ATTENTION_STATES: readonly ["none", "viewer-action-required", "viewer-review-required", "viewer-confirmation-required"];
4
+ export declare const BASE_RECIPE_CODES: readonly ["project", "flow", "proposal", "evaluation", "claims", "research", "discussion", "incident"];
5
+ export declare const TOPIC_RECIPE_CODES: readonly ["research-brief", "agent-delivery", "verified-work-payment"];
6
+ export type ShapePhaseV1 = (typeof SHAPE_PHASES)[number];
7
+ export type ShapeConditionV1 = (typeof SHAPE_CONDITIONS)[number];
8
+ export type ShapeAttentionV1 = (typeof SHAPE_ATTENTION_STATES)[number];
9
+ export type BaseRecipeCodeV1 = (typeof BASE_RECIPE_CODES)[number];
10
+ export type TopicRecipeCodeV1 = (typeof TOPIC_RECIPE_CODES)[number];
11
+ export type ShapeConsequenceClassV1 = "none" | "shared-state" | "external-effect" | "settlement";
12
+ export type ShapeConfirmationPolicyV1 = "none" | "viewer" | "authority";
13
+ export type ShapeEvidenceRequirementV1 = {
14
+ readonly kind: "operation" | "record" | "receipt";
15
+ readonly type: string;
16
+ readonly finality?: "observed" | "accepted" | "verified" | "final";
17
+ };
18
+ export type ShapeGateV1 = {
19
+ readonly kind: "field";
20
+ readonly path: string;
21
+ readonly predicate: "present" | "accepted";
22
+ } | {
23
+ readonly kind: "field-any";
24
+ readonly paths: readonly string[];
25
+ readonly predicate: "present" | "accepted";
26
+ } | {
27
+ readonly kind: "record";
28
+ readonly type: string;
29
+ readonly status?: string;
30
+ } | {
31
+ readonly kind: "receipt";
32
+ readonly type: string;
33
+ readonly status?: string;
34
+ } | {
35
+ readonly kind: "axis";
36
+ readonly axis: string;
37
+ readonly states: readonly string[];
38
+ } | {
39
+ readonly kind: "binding";
40
+ readonly type: "flow" | "claim" | "resource";
41
+ } | {
42
+ readonly kind: "condition";
43
+ readonly states: readonly ("waiting" | "blocked" | "failed" | "disputed")[];
44
+ };
45
+ export interface ShapeStateDefinitionV1 {
46
+ readonly code: string;
47
+ readonly labelKey?: string;
48
+ readonly terminal?: boolean;
49
+ readonly condition?: ShapeConditionV1;
50
+ }
51
+ export interface ShapeStateAxisV1 {
52
+ readonly code: string;
53
+ readonly phase: ShapePhaseV1;
54
+ readonly required: boolean;
55
+ readonly initialState: string;
56
+ readonly states: readonly ShapeStateDefinitionV1[];
57
+ }
58
+ export interface ShapeTransitionV1 {
59
+ readonly code: string;
60
+ readonly phase: ShapePhaseV1;
61
+ readonly predecessor: {
62
+ readonly axis: string;
63
+ readonly state: string;
64
+ };
65
+ readonly target: {
66
+ readonly axis: string;
67
+ readonly state: string;
68
+ };
69
+ readonly command: string;
70
+ readonly requiredAbility: string;
71
+ readonly assignedTo: {
72
+ readonly kind: "actor" | "role";
73
+ readonly value: string;
74
+ };
75
+ readonly gates: readonly ShapeGateV1[];
76
+ readonly confirmation: ShapeConfirmationPolicyV1;
77
+ readonly consequence: ShapeConsequenceClassV1;
78
+ readonly evidence: ShapeEvidenceRequirementV1;
79
+ readonly completesTopic?: boolean;
80
+ readonly handoff?: {
81
+ readonly kind: "flow" | "resource";
82
+ readonly binding: string;
83
+ };
84
+ readonly presentation?: {
85
+ readonly reasonCode: string;
86
+ readonly actionLabelKey?: string;
87
+ };
88
+ }
89
+ export interface ShapeProgressRuleV1 {
90
+ readonly code: string;
91
+ readonly condition: Exclude<ShapeConditionV1, "on-track" | "degraded">;
92
+ readonly priority: number;
93
+ readonly source: {
94
+ readonly kind: "axis" | "record" | "receipt" | "topic";
95
+ readonly value: string;
96
+ };
97
+ readonly states?: readonly string[];
98
+ readonly requiresTarget?: boolean;
99
+ }
100
+ export interface TopicShapeV1 {
101
+ readonly version: 1;
102
+ readonly code: string;
103
+ readonly axes: readonly ShapeStateAxisV1[];
104
+ readonly transitions: readonly ShapeTransitionV1[];
105
+ readonly progressRules: readonly ShapeProgressRuleV1[];
106
+ readonly inferredRecordPolicy: {
107
+ readonly autoAccept: readonly string[];
108
+ readonly neverAutoAccept: readonly string[];
109
+ };
110
+ }
111
+ export type TopicShapeOverlayV1 = Omit<TopicShapeV1, "axes" | "transitions" | "progressRules"> & {
112
+ readonly axes?: readonly ShapeStateAxisV1[];
113
+ readonly transitions?: readonly ShapeTransitionV1[];
114
+ readonly progressRules?: readonly ShapeProgressRuleV1[];
115
+ };
116
+ export interface TopicShapeSourceRefV1 {
117
+ readonly kind: "base-recipe" | "topic-recipe" | "kind" | "topic";
118
+ readonly id: string;
119
+ readonly version: string;
120
+ readonly digest: `sha256:${string}`;
121
+ }
122
+ export interface TopicRecipeRefV1 {
123
+ readonly id: string;
124
+ readonly version: string;
125
+ readonly digest: `sha256:${string}`;
126
+ }
127
+ export interface TopicRecipeV1 {
128
+ readonly version: 1;
129
+ readonly code: TopicRecipeCodeV1;
130
+ readonly id: string;
131
+ readonly recipeVersion: string;
132
+ readonly label: string;
133
+ readonly description: string;
134
+ readonly baseRecipe: BaseRecipeCodeV1;
135
+ readonly creates: "draft";
136
+ readonly shape: TopicShapeV1;
137
+ }
138
+ export interface EffectiveTopicShapeV1 {
139
+ readonly version: 1;
140
+ readonly shape: TopicShapeV1;
141
+ readonly sources: readonly TopicShapeSourceRefV1[];
142
+ readonly digest: `sha256:${string}`;
143
+ }
144
+ export interface TopicClaimBindingV1 {
145
+ readonly entityDid: string;
146
+ readonly collectionId: string;
147
+ }
148
+ export interface ResolvedTopicClaimBindingV1 extends TopicClaimBindingV1 {
149
+ readonly protocolDid: string;
150
+ readonly rubric: {
151
+ readonly id: string;
152
+ readonly digest?: `sha256:${string}`;
153
+ };
154
+ }
155
+ export interface TopicProgressSourceV1 {
156
+ readonly kind: "operation" | "record" | "receipt";
157
+ readonly type: string;
158
+ readonly id: string;
159
+ readonly status?: string;
160
+ readonly finality?: "observed" | "accepted" | "verified" | "final";
161
+ }
162
+ export interface TopicProgressBlockV1 {
163
+ readonly condition: "waiting" | "blocked" | "failed" | "disputed";
164
+ readonly sourceId: string;
165
+ readonly target: {
166
+ readonly kind: "actor" | "flow" | "resource" | "external";
167
+ readonly id: string;
168
+ };
169
+ readonly reasonCode: string;
170
+ }
171
+ export interface TopicProgressInputV1 {
172
+ readonly topicId: string;
173
+ readonly topicRevision: string;
174
+ readonly contractRevision: string;
175
+ readonly status: "draft" | "active" | "resolved" | "archived" | "redirected";
176
+ readonly shape?: EffectiveTopicShapeV1;
177
+ readonly historyCompatible: boolean;
178
+ readonly axisStates: Readonly<Record<string, string>>;
179
+ readonly sources: readonly TopicProgressSourceV1[];
180
+ readonly presentFields?: readonly string[];
181
+ readonly acceptedFields?: readonly string[];
182
+ readonly bindings?: readonly ("flow" | "claim" | "resource")[];
183
+ readonly actorAssignments?: Readonly<Record<string, readonly string[]>>;
184
+ readonly block?: TopicProgressBlockV1;
185
+ }
186
+ export interface TopicStateTagV1 {
187
+ readonly code: string;
188
+ readonly source: {
189
+ readonly axis: string;
190
+ readonly state: string;
191
+ } | {
192
+ readonly progressRule: string;
193
+ };
194
+ readonly priority: number;
195
+ readonly tone: "neutral" | "info" | "attention" | "warning" | "critical" | "positive";
196
+ readonly provenance: readonly string[];
197
+ }
198
+ export interface TopicTransitionCandidateV1 {
199
+ readonly transition: ShapeTransitionV1;
200
+ readonly assignedActor?: string;
201
+ readonly gateStatus: readonly {
202
+ readonly gate: ShapeGateV1;
203
+ readonly satisfied: boolean;
204
+ }[];
205
+ }
206
+ export interface TopicProgressProjectionV1 {
207
+ readonly version: 1;
208
+ readonly topicId: string;
209
+ readonly topicRevision: string;
210
+ readonly contractRevision: string;
211
+ readonly shapeDigest: `sha256:${string}`;
212
+ readonly phase: ShapePhaseV1;
213
+ readonly condition: ShapeConditionV1;
214
+ readonly reasonCode: string;
215
+ readonly axisStates: Readonly<Record<string, string>>;
216
+ readonly stateTags: readonly TopicStateTagV1[];
217
+ readonly candidates: readonly TopicTransitionCandidateV1[];
218
+ readonly provenance: readonly string[];
219
+ readonly block?: TopicProgressBlockV1;
220
+ }
221
+ export interface TopicViewerAuthorityV1 {
222
+ readonly viewerId: string;
223
+ readonly matrixWrite: boolean;
224
+ readonly verifiedAbilities: readonly string[];
225
+ readonly roleAssignments: Readonly<Record<string, readonly string[]>>;
226
+ }
227
+ export interface TopicNowProjectionV1 {
228
+ readonly version: 1;
229
+ readonly phase: ShapePhaseV1;
230
+ readonly condition: ShapeConditionV1;
231
+ readonly attention: ShapeAttentionV1;
232
+ readonly reasonCode: string;
233
+ readonly stateTags: readonly TopicStateTagV1[];
234
+ readonly transitions: readonly ShapeTransitionV1[];
235
+ readonly cacheKey: {
236
+ readonly topicRevision: string;
237
+ readonly contractRevision: string;
238
+ readonly shapeDigest: `sha256:${string}`;
239
+ };
240
+ readonly blockedOn?: TopicProgressBlockV1["target"];
241
+ }
@@ -0,0 +1,42 @@
1
+ export const SHAPE_PHASES = [
2
+ "forming",
3
+ "working",
4
+ "verifying",
5
+ "deciding",
6
+ "effecting",
7
+ "settling",
8
+ "complete",
9
+ "dormant",
10
+ ];
11
+ export const SHAPE_CONDITIONS = [
12
+ "on-track",
13
+ "needs-input",
14
+ "needs-acceptance",
15
+ "waiting",
16
+ "blocked",
17
+ "failed",
18
+ "disputed",
19
+ "degraded",
20
+ ];
21
+ export const SHAPE_ATTENTION_STATES = [
22
+ "none",
23
+ "viewer-action-required",
24
+ "viewer-review-required",
25
+ "viewer-confirmation-required",
26
+ ];
27
+ export const BASE_RECIPE_CODES = [
28
+ "project",
29
+ "flow",
30
+ "proposal",
31
+ "evaluation",
32
+ "claims",
33
+ "research",
34
+ "discussion",
35
+ "incident",
36
+ ];
37
+ export const TOPIC_RECIPE_CODES = [
38
+ "research-brief",
39
+ "agent-delivery",
40
+ "verified-work-payment",
41
+ ];
42
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/shapes/types.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,SAAS;IACT,SAAS;IACT,WAAW;IACX,UAAU;IACV,WAAW;IACX,UAAU;IACV,UAAU;IACV,SAAS;CACD,CAAC;AAEX,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,UAAU;IACV,aAAa;IACb,kBAAkB;IAClB,SAAS;IACT,SAAS;IACT,QAAQ;IACR,UAAU;IACV,UAAU;CACF,CAAC;AAEX,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,MAAM;IACN,wBAAwB;IACxB,wBAAwB;IACxB,8BAA8B;CACtB,CAAC;AAEX,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,SAAS;IACT,MAAM;IACN,UAAU;IACV,YAAY;IACZ,QAAQ;IACR,UAAU;IACV,YAAY;IACZ,UAAU;CACF,CAAC;AAEX,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,gBAAgB;IAChB,gBAAgB;IAChB,uBAAuB;CACf,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ixo/topic-protocol",
3
- "version": "0.8.0",
3
+ "version": "1.0.0-rc.1",
4
4
  "description": "Reference contracts and deterministic projection for IXO Topics",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -18,6 +18,7 @@
18
18
  "files": [
19
19
  "dist",
20
20
  "profiles",
21
+ "recipes",
21
22
  "templates",
22
23
  "README.md"
23
24
  ],
@@ -28,6 +29,7 @@
28
29
  },
29
30
  "./schemas/*": "./dist/schemas/*",
30
31
  "./profiles/*": "./profiles/*",
32
+ "./recipes/*": "./recipes/*",
31
33
  "./templates/*": "./templates/*"
32
34
  },
33
35
  "scripts": {
@@ -0,0 +1,12 @@
1
+ # Topic Recipe registry
2
+
3
+ These digest-addressed Topic Recipes are Marketplace-ready release-candidate
4
+ artifacts. Every recipe creates a user-reviewable Draft; none grants authority
5
+ or executes its Flow bindings.
6
+
7
+ - `research-brief.json`
8
+ - `agent-delivery.json`
9
+ - `verified-work-payment.json`
10
+
11
+ `registry.json` publishes the corresponding immutable references. Consumers
12
+ must verify the recipe digest before resolving the Effective Topic Shape.