@tomflow/proflow-task-orchestration 0.1.14 → 0.1.15

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @tomflow/proflow-task-orchestration
2
2
 
3
+ ## 0.1.15
4
+
5
+ ### Patch Changes
6
+
7
+ - fix(product): bind phase1 materialization to current authorization
8
+
3
9
  ## 0.1.14
4
10
 
5
11
  ### Patch Changes
@@ -4,7 +4,7 @@ declare const success: () => {
4
4
  readonly ok: true;
5
5
  readonly status: "SUCCEEDED";
6
6
  readonly moduleRef: "task-orchestration";
7
- readonly moduleVersion: "0.1.14";
7
+ readonly moduleVersion: "0.1.15";
8
8
  };
9
9
  observedEffects: string[];
10
10
  };
@@ -17,7 +17,7 @@ export declare const behaviorAdapter: {
17
17
  ok: true;
18
18
  status: "SUCCEEDED";
19
19
  moduleRef: "task-orchestration";
20
- moduleVersion: "0.1.14";
20
+ moduleVersion: "0.1.15";
21
21
  data: {
22
22
  setupStatus: "READY";
23
23
  runtimeStatus: "NOT_APPLICABLE";
@@ -32,7 +32,7 @@ export declare const behaviorAdapter: {
32
32
  ok: true;
33
33
  status: "SUCCEEDED";
34
34
  moduleRef: "task-orchestration";
35
- moduleVersion: "0.1.14";
35
+ moduleVersion: "0.1.15";
36
36
  data: {
37
37
  docs: string;
38
38
  };
@@ -3,7 +3,7 @@ export declare const descriptor: {
3
3
  readonly contractVersion: "1.0.0";
4
4
  readonly moduleRef: "task-orchestration";
5
5
  readonly packageName: "@tomflow/proflow-task-orchestration";
6
- readonly moduleVersion: "0.1.14";
6
+ readonly moduleVersion: "0.1.15";
7
7
  readonly kind: "library";
8
8
  readonly templateVersion: "1.0.0";
9
9
  readonly platformCompatibility: ">=1.0.0 <2.0.0";
@@ -3,7 +3,7 @@ export const descriptor = {
3
3
  contractVersion: "1.0.0",
4
4
  moduleRef: "task-orchestration",
5
5
  packageName: "@tomflow/proflow-task-orchestration",
6
- moduleVersion: "0.1.14",
6
+ moduleVersion: "0.1.15",
7
7
  kind: "library",
8
8
  templateVersion: "1.0.0",
9
9
  platformCompatibility: ">=1.0.0 <2.0.0",
@@ -126,8 +126,23 @@ export function createTaskServices(options) {
126
126
  throw new ProjectionError("PRODUCT_CAMPAIGN_NOT_FOUND");
127
127
  if (campaign.status !== "OPEN")
128
128
  throw new ProjectionError("PRODUCT_CAMPAIGN_CLOSED");
129
+ if (campaign.version !== input.expectedCampaignVersion)
130
+ throw new ProjectionError("PRODUCT_CAMPAIGN_VERSION_CONFLICT", true);
129
131
  if (campaign.discussionRef !== input.discussionRef)
130
132
  throw new ProjectionError("PRODUCT_DISCUSSION_MISMATCH");
133
+ const authorization = tx.campaignAuthorizations.get(input.authorizationRef);
134
+ if (!authorization)
135
+ throw new ProjectionError("CAMPAIGN_AUTHORIZATION_NOT_FOUND");
136
+ if (authorization.version !== input.expectedAuthorizationVersion)
137
+ throw new ProjectionError("CAMPAIGN_AUTHORIZATION_VERSION_CONFLICT", true);
138
+ if (authorization.revokedAt !== null)
139
+ throw new ProjectionError("CAMPAIGN_AUTHORIZATION_REVOKED");
140
+ if (authorization.campaignRef !== campaign.campaignRef)
141
+ throw new ProjectionError("CAMPAIGN_AUTHORIZATION_CAMPAIGN_MISMATCH");
142
+ if (authorization.discussionRef !== input.discussionRef)
143
+ throw new ProjectionError("PRODUCT_DISCUSSION_MISMATCH");
144
+ if (authorization.goalRevision !== campaign.goalRevision)
145
+ throw new ProjectionError("CAMPAIGN_GOAL_REVISION_MISMATCH");
131
146
  const current = tx.productDocuments.get(input.documentRef);
132
147
  if (input.expectedRevision === 0) {
133
148
  if (current)
@@ -58,6 +58,8 @@ const submitProductTaskIntentSchema = z
58
58
  .object({
59
59
  intentRef: id,
60
60
  campaignRef: id.optional(),
61
+ authorizationRef: id.optional(),
62
+ expectedAuthorizationVersion: version.optional(),
61
63
  discussionRef: id,
62
64
  goalRevision: version,
63
65
  intentRevision: version,
@@ -74,11 +76,17 @@ const submitProductTaskIntentSchema = z
74
76
  })
75
77
  .strict()
76
78
  .superRefine((input, context) => {
77
- if ((input.campaignRef === undefined) !== (input.expectedCampaignVersion === undefined))
79
+ const campaignFields = [
80
+ input.campaignRef,
81
+ input.authorizationRef,
82
+ input.expectedAuthorizationVersion,
83
+ input.expectedCampaignVersion,
84
+ ];
85
+ if (campaignFields.some((value) => value !== undefined) && campaignFields.some((value) => value === undefined))
78
86
  context.addIssue({
79
87
  code: "custom",
80
- message: "campaignRef and expectedCampaignVersion must be supplied together",
81
- path: ["expectedCampaignVersion"],
88
+ message: "campaignRef, authorizationRef, expectedAuthorizationVersion, and expectedCampaignVersion must be supplied together",
89
+ path: ["authorizationRef"],
82
90
  });
83
91
  const packages = new Set(input.roleBindings.map((binding) => binding.agentPackageRef));
84
92
  if (packages.size !== requiredTaskAgentPackageRefs.length ||
@@ -128,6 +136,9 @@ const phase4Schemas = {
128
136
  documentRef: id,
129
137
  campaignRef: id,
130
138
  discussionRef: id,
139
+ authorizationRef: id,
140
+ expectedAuthorizationVersion: version,
141
+ expectedCampaignVersion: version,
131
142
  documentType: id,
132
143
  content: z.string().min(1),
133
144
  expectedRevision: revision,
@@ -335,12 +335,21 @@ export function createTaskServices(options) {
335
335
  if (campaign.status !== "OPEN")
336
336
  throw new Phase4DomainError("PRODUCT_CAMPAIGN_CLOSED");
337
337
  checkVersion(campaign.version, input.expectedCampaignVersion, "PRODUCT_CAMPAIGN_VERSION_CONFLICT");
338
- if (campaign.discussionRef !== input.discussionRef ||
339
- campaign.goalRevision !== input.goalRevision)
338
+ if (campaign.discussionRef !== input.discussionRef || campaign.goalRevision !== input.goalRevision)
340
339
  throw new Phase4DomainError("CAMPAIGN_GOAL_REVISION_MISMATCH");
341
- if (!subsetOf(input.scope, campaign.scope))
340
+ const authorization = requireAuthorization(tx, input.authorizationRef);
341
+ checkVersion(authorization.version, input.expectedAuthorizationVersion, "CAMPAIGN_AUTHORIZATION_VERSION_CONFLICT");
342
+ if (authorization.revokedAt !== null)
343
+ throw new Phase4DomainError("CAMPAIGN_AUTHORIZATION_REVOKED");
344
+ if (authorization.campaignRef !== campaign.campaignRef)
345
+ throw new Phase4DomainError("CAMPAIGN_AUTHORIZATION_CAMPAIGN_MISMATCH");
346
+ if (authorization.discussionRef !== input.discussionRef)
347
+ throw new Phase4DomainError("PRODUCT_DISCUSSION_MISMATCH");
348
+ if (authorization.goalRevision !== campaign.goalRevision)
349
+ throw new Phase4DomainError("CAMPAIGN_GOAL_REVISION_MISMATCH");
350
+ if (!subsetOf(input.scope, campaign.scope) || !subsetOf(input.scope, authorization.scope))
342
351
  throw new Phase4DomainError("PRODUCT_INTENT_SCOPE_VIOLATION");
343
- if (!same(input.constraints, campaign.constraints))
352
+ if (!same(input.constraints, campaign.constraints) || !same(input.constraints, authorization.constraints))
344
353
  throw new Phase4DomainError("CAMPAIGN_CONSTRAINT_VIOLATION");
345
354
  }
346
355
  if (input.productDocuments.length > 0 && input.campaignRef === undefined)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tomflow/proflow-task-orchestration",
3
- "version": "0.1.14",
3
+ "version": "0.1.15",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -23,9 +23,9 @@
23
23
  "@tomflow/proflow-module-contract": "^0.1.13"
24
24
  },
25
25
  "devDependencies": {
26
- "@tomflow/proflow-task-store-sqlite": "^0.1.13",
27
- "@tomflow/proflow-task-migration-runner": "^0.1.11",
28
- "@tomflow/proflow-deployment-conformance": "^0.1.13"
26
+ "@tomflow/proflow-deployment-conformance": "^0.1.13",
27
+ "@tomflow/proflow-task-migration-runner": "^0.1.12",
28
+ "@tomflow/proflow-task-store-sqlite": "^0.1.14"
29
29
  },
30
30
  "description": "Owns the Task & Orchestration public contract, domain rules and application services.",
31
31
  "keywords": [
@@ -3,7 +3,7 @@
3
3
  "contractVersion": "1.0.0",
4
4
  "moduleRef": "task-orchestration",
5
5
  "packageName": "@tomflow/proflow-task-orchestration",
6
- "moduleVersion": "0.1.14",
6
+ "moduleVersion": "0.1.15",
7
7
  "kind": "library",
8
8
  "templateVersion": "1.0.0",
9
9
  "platformCompatibility": ">=1.0.0 <2.0.0",