@synap-core/workspace-templates 0.46.0 → 0.48.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.
Files changed (54) hide show
  1. package/README.md +4 -3
  2. package/automations/lead-converted-becomes-client.automation.json +89 -0
  3. package/automations/lead-converted-becomes-client.catalog.json +13 -0
  4. package/capabilities/apify.capability.json +8 -1
  5. package/capabilities/apollo.capability.json +8 -1
  6. package/capabilities/cal-com.capability.json +8 -1
  7. package/capabilities/exa.capability.json +8 -1
  8. package/capabilities/fal-ai.capability.json +8 -1
  9. package/capabilities/fal-media-lab.capability.json +8 -1
  10. package/capabilities/fireflies.capability.json +8 -1
  11. package/capabilities/mailgun.capability.json +8 -1
  12. package/capabilities/omniroute.capability.json +7 -1
  13. package/capabilities/posthog-analytics.capability.json +7 -1
  14. package/capabilities/postiz.capability.json +7 -1
  15. package/capabilities/replicate-rvm.capability.json +21 -5
  16. package/capabilities/stripe.capability.json +10 -1
  17. package/capabilities/unipile-linkedin.capability.json +39 -3
  18. package/capabilities/vercel.capability.json +8 -1
  19. package/dist/{define-BAPO0xZf.d.ts → define-Dto5_E47.d.ts} +15 -3
  20. package/dist/index.d.ts +2 -2
  21. package/dist/index.js +623 -96
  22. package/dist/index.js.map +1 -1
  23. package/dist/wire.d.ts +1 -1
  24. package/package.json +1 -1
  25. package/src/agency-os.yaml +1 -1
  26. package/src/brand-library.yaml +6 -6
  27. package/src/builder.yaml +17 -12
  28. package/src/content-os.template.test.ts +38 -22
  29. package/src/content-os.video-takes.template.test.ts +4 -2
  30. package/src/content-os.yaml +33 -23
  31. package/src/crm-absorbs-outreach.template.test.ts +5 -1
  32. package/src/crm.yaml +53 -30
  33. package/src/decisions-wave.template.test.ts +99 -5
  34. package/src/finance.yaml +11 -6
  35. package/src/foundation.yaml +22 -10
  36. package/src/grants.yaml +4 -0
  37. package/src/intent.test.ts +4 -2
  38. package/src/lead-automations.test.ts +93 -0
  39. package/src/lead-becomes-client.template.test.ts +137 -0
  40. package/src/lifecycle-declarations.test.ts +20 -1
  41. package/src/lifecycle-presets.test.ts +39 -7
  42. package/src/marketing.yaml +3 -3
  43. package/src/operations.yaml +155 -24
  44. package/src/postiz-contract.test.ts +3 -2
  45. package/src/process-contract.validate.test.ts +4 -1
  46. package/src/publish-official-lib.test.ts +8 -7
  47. package/src/research-base.yaml +2 -2
  48. package/src/research-decision.yaml +1 -1
  49. package/src/ship-a-change.template.test.ts +11 -2
  50. package/src/templates.ts +223 -74
  51. package/src/types.ts +15 -3
  52. package/src/unipile-lookups-read-only.test.ts +1 -0
  53. package/src/validate-flow.ts +15 -1
  54. package/src/validate.ts +40 -4
package/dist/wire.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { g as PackageDefinitionOutput, X as WorkspaceDefinitionInput } from './define-BAPO0xZf.js';
1
+ import { g as PackageDefinitionOutput, X as WorkspaceDefinitionInput } from './define-Dto5_E47.js';
2
2
  import '@synap-core/types/presentation';
3
3
  import '@synap-core/types/space-brief';
4
4
  import '@synap-core/types/capability-intents';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synap-core/workspace-templates",
3
- "version": "0.46.0",
3
+ "version": "0.48.0",
4
4
  "type": "module",
5
5
  "description": "Canonical workspace definitions — YAML source + typed exports for browser, backend, CLI, and marketplace",
6
6
  "repository": {
@@ -29,7 +29,7 @@ dependencies:
29
29
  - slug: operations
30
30
  kind: workspace
31
31
  relation: require
32
- reason: "Client engagements, deliverables and contracts — where won deals are delivered."
32
+ reason: "Clients, their engagements, deliverables and contracts — where a lead that signs becomes a client, is onboarded and delivered."
33
33
  - slug: finance
34
34
  kind: workspace
35
35
  relation: require
@@ -1175,7 +1175,7 @@ playbooks:
1175
1175
  - name: Make a brand asset
1176
1176
  description: Turn a request for a logo, image, icon or template into a draft built from the approved brand, and approve it with a person before anything uses it.
1177
1177
  goalTemplate: >-
1178
- Make this brand asset ({asset}); each stage moves its status. DRAFT: read
1178
+ Make this brand asset ({asset}); each stage moves its status when its work is approved. DRAFT: read
1179
1179
  the request and the approved brand only — approved colours, fonts,
1180
1180
  references and the active token set; never a draft — and load the
1181
1181
  creative-director skill to pick the recipe. Make the draft (or up to
@@ -1200,6 +1200,7 @@ playbooks:
1200
1200
  name: Draft
1201
1201
  category: started
1202
1202
  subjectStatus: draft
1203
+ onApproved: approved
1203
1204
  goal: Build the draft from approved brand sources only and record how it was made.
1204
1205
  criteria:
1205
1206
  - key: asset-approved-sources
@@ -1223,7 +1224,6 @@ playbooks:
1223
1224
  - key: approve
1224
1225
  name: Approve
1225
1226
  category: completed
1226
- subjectStatus: approved
1227
1227
  goal: A person approves one draft as final; with variants, the one they kept.
1228
1228
  gate: { kind: human }
1229
1229
  onFail: { toStage: draft }
@@ -1231,7 +1231,7 @@ playbooks:
1231
1231
  - name: Write the brand voice
1232
1232
  description: Draft or revise the brand voice guide from what the brand already publishes, and approve it with a person.
1233
1233
  goalTemplate: >-
1234
- Write this brand voice guide ({guide}); each stage moves its status.
1234
+ Write this brand voice guide ({guide}); each stage moves its status when its work is approved.
1235
1235
  DRAFT: read the brand identity, the approved assets and the last posts
1236
1236
  and emails the brand published; write the voice in a few traits, each
1237
1237
  with a do and a don't taken from real examples, and the words to use and
@@ -1248,6 +1248,7 @@ playbooks:
1248
1248
  name: Draft
1249
1249
  category: started
1250
1250
  subjectStatus: draft
1251
+ onApproved: approved
1251
1252
  goal: Write the voice traits with real do and don't examples, and the words to use and avoid.
1252
1253
  criteria:
1253
1254
  - key: voice-examples
@@ -1256,7 +1257,6 @@ playbooks:
1256
1257
  - key: approve
1257
1258
  name: Approve
1258
1259
  category: completed
1259
- subjectStatus: approved
1260
1260
  goal: A person approves the guide.
1261
1261
  gate: { kind: human }
1262
1262
  onFail: { toStage: draft }
@@ -1264,7 +1264,7 @@ playbooks:
1264
1264
  - name: Write a content guideline
1265
1265
  description: Distil approved references into a content guideline (base, format or the frame for one goal), and approve it with a person.
1266
1266
  goalTemplate: >-
1267
- Write this content guideline ({guideline}); each stage moves its status.
1267
+ Write this content guideline ({guideline}); each stage moves its status when its work is approved.
1268
1268
  DRAFT: read the brand identity, the approved voice guide and the approved
1269
1269
  references; load the content-taste skill. Write what to take and what to
1270
1270
  avoid as rules a maker can follow, link the guideline to every reference
@@ -1283,6 +1283,7 @@ playbooks:
1283
1283
  name: Draft
1284
1284
  category: started
1285
1285
  subjectStatus: draft
1286
+ onApproved: approved
1286
1287
  goal: Distil the approved references into rules a maker can follow, linked to their sources.
1287
1288
  criteria:
1288
1289
  - key: guideline-sources
@@ -1294,7 +1295,6 @@ playbooks:
1294
1295
  - key: approve
1295
1296
  name: Approve
1296
1297
  category: completed
1297
- subjectStatus: approved
1298
1298
  goal: A person approves the guideline.
1299
1299
  gate: { kind: human }
1300
1300
  onFail: { toStage: draft }
package/src/builder.yaml CHANGED
@@ -1811,6 +1811,7 @@ playbooks:
1811
1811
  - key: verify
1812
1812
  name: Verify
1813
1813
  category: started
1814
+ onApproved: implemented
1814
1815
  goal: Run the gates, capture the implemented story and compare it with the design (and the current story when there is one), and walk the screen in the running app; write what passed and what failed.
1815
1816
  gate: { kind: check }
1816
1817
  onFail: { toStage: implement }
@@ -1831,7 +1832,6 @@ playbooks:
1831
1832
  - key: done
1832
1833
  name: Done
1833
1834
  category: completed
1834
- subjectStatus: implemented
1835
1835
  goal: A person confirms the pull request merged and the screen matches the approved design; approving writes implemented.
1836
1836
  # A HUMAN gate (as Content OS Publish): a check gate judges the stage
1837
1837
  # being LEFT, so it would write implemented before anyone saw the merge.
@@ -2202,8 +2202,8 @@ playbooks:
2202
2202
  - key: verify
2203
2203
  name: Criteria verified
2204
2204
  category: completed
2205
- subjectStatus: done
2206
- goal: Grade every criterion of the session with its evidence, separating VERIFIED (gate or check output quoted) from NEEDS-DOGFOOD; the feature reads Shipped once a person accepts it.
2205
+ onApproved: done
2206
+ goal: Grade every criterion of the session with its evidence, separating VERIFIED (gate or check output quoted) from NEEDS-DOGFOOD. Then, when a feature is bound, move it to done yourself (update_entity, featureStatus done, expectedStatus the status you read); nothing else moves it. Your move into done comes back proposed for the person to approve, which is success; the feature reads Shipped once they accept it.
2207
2207
  criteria:
2208
2208
  - key: criteria-verified
2209
2209
  statement: Every criterion of the session is graded with its evidence, and nothing unverified is reported as verified.
@@ -2404,7 +2404,8 @@ playbooks:
2404
2404
  optional: true
2405
2405
  relationToSubject: relates_to
2406
2406
  - key: verify
2407
- goal: Grade every criterion of the session with its evidence, separating VERIFIED (gate or check output quoted) from NEEDS-DOGFOOD, capture what was learned, and end with the graded criteria as your answer.
2407
+ onApproved: done
2408
+ goal: Grade every criterion of the session with its evidence, separating VERIFIED (gate or check output quoted) from NEEDS-DOGFOOD, and capture what was learned. Then, when a feature is bound, move it to done yourself (synap_update_entity, featureStatus done, expectedStatus the status you read); nothing else moves it. Your move into done comes back proposed for the person to approve, which is success. End with the graded criteria as your answer.
2408
2409
  name: Criteria verified
2409
2410
  category: completed
2410
2411
  criteria:
@@ -2414,7 +2415,6 @@ playbooks:
2414
2415
  statement: Every criterion of the session is graded with its evidence, and nothing unverified is reported as verified.
2415
2416
  description: 'Shared land stage. Never report unverified work as verified. File the lesson, decision or finding the work produced (engineering-memory skill, rule dogfood-journal). Close what you opened: asks answered or withdrawn, worktree removed once merged, then synap_complete_session. Moving the feature to done is a proposal the person approves. Tools: synap_update_session, synap_capture, synap_complete_session. Gate: none.'
2416
2417
  tier: quick
2417
- subjectStatus: done
2418
2418
 
2419
2419
  # --- Fix a bug ---
2420
2420
  - name: Fix a bug
@@ -2587,7 +2587,8 @@ playbooks:
2587
2587
  optional: true
2588
2588
  relationToSubject: relates_to
2589
2589
  - key: verify
2590
- goal: Grade every criterion of the session with its evidence, separating VERIFIED (gate or check output quoted) from NEEDS-DOGFOOD, capture what was learned, and end with the graded criteria as your answer.
2590
+ onApproved: fixed
2591
+ goal: Grade every criterion of the session with its evidence, separating VERIFIED (gate or check output quoted) from NEEDS-DOGFOOD, and capture what was learned. Then move the issue to fixed yourself (synap_update_entity, issueStatus fixed, expectedStatus the status you read); nothing else moves it. Your move into fixed comes back proposed for the person to approve, which is success. End with the graded criteria as your answer.
2591
2592
  name: Criteria verified
2592
2593
  category: completed
2593
2594
  criteria:
@@ -2597,7 +2598,6 @@ playbooks:
2597
2598
  statement: Every criterion of the session is graded with its evidence, and nothing unverified is reported as verified.
2598
2599
  description: 'Shared land stage. Never report unverified work as verified. File the lesson, decision or finding the work produced (engineering-memory skill, rule dogfood-journal). Close what you opened: asks answered or withdrawn, worktree removed once merged, then synap_complete_session. Moving the issue to fixed is a proposal the person approves. Tools: synap_update_session, synap_capture, synap_complete_session. Gate: none.'
2599
2600
  tier: quick
2600
- subjectStatus: fixed
2601
2601
 
2602
2602
  # --- Investigate ---
2603
2603
  - name: Investigate
@@ -3021,19 +3021,24 @@ playbooks:
3021
3021
  stages:
3022
3022
  - key: fix
3023
3023
  name: Fix it
3024
- goal: Find the root cause and ship the fix as a gated PR or commit
3024
+ goal: Find the root cause and ship the fix as a gated PR or commit. Once the pull request is open (or the gated commit pushed), move the session to Fix merged.
3025
3025
  category: started
3026
3026
  subjectStatus: fixing
3027
3027
  - key: merged
3028
3028
  name: Fix merged
3029
- goal: The fix is on main (a merged PR or a gated commit)
3029
+ goal: Record the fix's pull request on this stage's Merged fix output with its url as the ref, and leave it open (synap_update_session); the pod closes it when the pull request merges into main, and that moves the finding to fixed. A fix landed as a gated commit, with no pull request, marks the output done with the commit's url as its ref. Never move the finding yourself.
3030
3030
  category: started
3031
- subjectStatus: fixed
3031
+ onApproved: fixed
3032
+ # REQUIRED (decision D2): the merge itself approves this stage — the merge
3033
+ # sweeper closes the slot whose ref is the merged pull request
3034
+ # (satisfyPullRequestByMerge), even after the run moved on.
3035
+ expectedOutputs:
3036
+ - { kind: pull_request, label: Merged fix, relationToSubject: none }
3032
3037
  - key: verified
3033
3038
  name: Live and verified
3034
- goal: The fix runs on the pod (its build contains the fix) and the finding no longer happens
3039
+ goal: The fix runs on the pod (its build contains the fix) and the finding no longer happens. Then move the finding to verified yourself (synap_update_entity, status verified, expectedStatus fixed); nothing else moves it, and your move into verified comes back proposed for the person to approve, which is success.
3035
3040
  category: completed
3036
- subjectStatus: verified
3041
+ onApproved: verified
3037
3042
 
3038
3043
  # --- Fix in code ---
3039
3044
  # The child run of a hand-off (design 8e1cc3e9, slice 1): "Fix a finding"'s
@@ -147,18 +147,27 @@ describe("Content OS owns the video / visual pipeline", () => {
147
147
 
148
148
  // A stage's `subjectStatus` is written when the run ENTERS it, and the pod holds
149
149
  // it only behind a HUMAN gate (a check gate judges the stage being left, so it
150
- // passes on entry). A status that claims an outside act — the post is live, the
151
- // issue went out — or that starts ANOTHER process must therefore sit behind a
152
- // person's approval, or the record says it happened before anyone confirmed it
153
- // (review M6: Repurpose fired on a post that never shipped).
150
+ // passes on entry). Its `onApproved` (decision D2) is written when its outputs
151
+ // are all delivered, else when the NEXT stage's gate passes — and by nothing at
152
+ // all when it has neither. A status that claims an outside act — the post is
153
+ // live, the issue went out — or that starts ANOTHER process must therefore sit
154
+ // behind a person's approval, or be written by nothing but the act itself, or
155
+ // the record says it happened before anyone confirmed it (review M6: Repurpose
156
+ // fired on a post that never shipped).
154
157
  describe("Content OS never writes an outside act before a person confirms it", () => {
155
158
  const playbooks = (template.playbooks ?? []) as TemplatePlaybook[];
156
159
  type Stage = NonNullable<TemplatePlaybook["stages"]>[number];
157
- const bound: Array<{ playbook: string; stage: Stage }> = playbooks.flatMap((pb) =>
158
- (pb.stages ?? [])
159
- .filter((s) => typeof s.subjectStatus === "string")
160
- .map((stage) => ({ playbook: pb.name, stage })),
161
- );
160
+ const bound: Array<{ playbook: string; stage: Stage; value: string; via: "enter" | "reach"; next?: Stage }> =
161
+ playbooks.flatMap((pb) =>
162
+ (pb.stages ?? []).flatMap((stage, i, all) => [
163
+ ...(typeof stage.subjectStatus === "string"
164
+ ? [{ playbook: pb.name, stage, value: stage.subjectStatus, via: "enter" as const }]
165
+ : []),
166
+ ...(typeof stage.onApproved === "string"
167
+ ? [{ playbook: pb.name, stage, value: stage.onApproved, via: "reach" as const, next: all[i + 1] }]
168
+ : []),
169
+ ]),
170
+ );
162
171
  // Values another playbook's activator listens for, per subject kind.
163
172
  const activatedElsewhere = (owner: string, kind: string | undefined, status: string) =>
164
173
  playbooks.some(
@@ -170,24 +179,29 @@ describe("Content OS never writes an outside act before a person confirms it", (
170
179
  const kindOf = (name: string) => playbooks.find((p) => p.name === name)?.subjectProfile?.profileSlug;
171
180
 
172
181
  const mustBeHuman = bound.filter(
173
- ({ playbook, stage }) =>
174
- stage.category === "completed" ||
175
- activatedElsewhere(playbook, kindOf(playbook), stage.subjectStatus as string),
182
+ ({ playbook, stage, value }) =>
183
+ stage.category === "completed" || activatedElsewhere(playbook, kindOf(playbook), value),
176
184
  );
177
185
 
178
186
  it("finds the stages it guards (non-vacuity)", () => {
179
- expect(mustBeHuman.map(({ playbook, stage }) => `${playbook}/${stage.key}`).sort()).toEqual([
180
- "Newsletter issue/sent",
181
- "Produce Content/publish",
187
+ expect(mustBeHuman.map(({ playbook, stage, via }) => `${playbook}/${stage.key}/${via}`).sort()).toEqual([
188
+ "Newsletter issue/sent/enter",
189
+ "Produce Content/publish/reach",
182
190
  ]);
183
191
  });
184
192
 
185
- it("gates each of them on a person", () => {
186
- for (const { playbook, stage } of mustBeHuman) {
187
- expect({ at: `${playbook}/${stage.key}`, gate: stage.gate }).toEqual({
188
- at: `${playbook}/${stage.key}`,
189
- gate: { kind: "human" },
190
- });
193
+ it("gates each of them on a person, or leaves them to the act itself", () => {
194
+ for (const { playbook, stage, via, next } of mustBeHuman) {
195
+ const at = `${playbook}/${stage.key}`;
196
+ if (via === "enter") {
197
+ expect({ at, gate: stage.gate }).toEqual({ at, gate: { kind: "human" } });
198
+ continue;
199
+ }
200
+ // Reached: approved by the next stage's PERSON gate, or by nothing (no
201
+ // outputs, no next stage) — the sender or a person writes it.
202
+ const approvedBy =
203
+ (stage.expectedOutputs ?? []).length > 0 ? "its outputs" : next ? `next gate: ${next.gate?.kind ?? "none"}` : "nothing";
204
+ expect({ at, ok: approvedBy === "nothing" || approvedBy === "next gate: human" }).toEqual({ at, ok: true });
191
205
  }
192
206
  });
193
207
 
@@ -250,7 +264,9 @@ describe("Content OS scripts a post before generating it", () => {
250
264
  "schedule",
251
265
  "publish",
252
266
  ]);
253
- expect(stage("script")?.subjectStatus).toBe("Scripted");
267
+ // D2: Scripted is REACHED when the Script is approved, not on entry.
268
+ expect(stage("script")?.onApproved).toBe("Scripted");
269
+ expect(stage("script")?.subjectStatus).toBeUndefined();
254
270
  expect(stage("script")?.expectedOutputs).toEqual([
255
271
  expect.objectContaining({ kind: "document", label: "Script" }),
256
272
  ]);
@@ -332,11 +332,13 @@ describe("Produce Content moves the post's status with its stages", () => {
332
332
  const produce = playbook("Produce Content");
333
333
  const goalOf = (key: string) => (produce?.stages?.find((s) => s.key === key)?.goal ?? "").replace(/\s+/g, " ");
334
334
 
335
- it("moves an Idea post to Briefed when the run starts, through the status door", () => {
335
+ it("moves an Idea post to Briefed once the brief is set, through the status door", () => {
336
336
  expect(goalOf("brief")).toContain(
337
- "if the post still reads Idea, move it to Briefed first (synap_update_entity, post-status Briefed, expectedStatus Idea)",
337
+ "Once the brief is set, move the post to Briefed if it still reads Idea (synap_update_entity, post-status Briefed, expectedStatus Idea)",
338
338
  );
339
339
  expect(goalOf("brief")).toContain("never skipping one, takes included");
340
+ // D2: a stage moves the post when its work is APPROVED, not on entry.
341
+ expect(goalOf("brief")).toContain("A stage moves the post when its work is APPROVED, not when it is entered");
340
342
  });
341
343
 
342
344
  it("makes a take's cut plan the script, and says the Draft gate's approval writes In Draft", () => {
@@ -259,6 +259,7 @@ profiles:
259
259
  "Short Video",
260
260
  "Long Video",
261
261
  "Carousel",
262
+ "Text Post",
262
263
  "Image Post",
263
264
  "Story",
264
265
  "Newsletter Section",
@@ -1978,9 +1979,12 @@ relationDefs:
1978
1979
  # (playbooks.subject_profile->>'profileSlug') can offer it when one is captured.
1979
1980
  #
1980
1981
  # THE PROCESS CONTRACT (lifecycle-bound playbooks). A playbook FOLLOWS the kind's
1981
- # declared lifecycle (`post-status`); each stage's `subjectStatus` is the value
1982
- # that stage IS — advancing into the stage writes it to the subject (governed),
1983
- # and the subject entering it advances an open run to the stage. A value no stage
1982
+ # declared lifecycle (`post-status`). A stage's `subjectStatus` is the value the
1983
+ # subject holds WHILE the stage is worked — entering the stage writes it
1984
+ # (governed); its `onApproved` is the value the stage's APPROVED work reaches
1985
+ # (its outputs all delivered, else the next stage's gate passing; decision D2).
1986
+ # The subject entering a value advances an open run to the stage that enters
1987
+ # it, or to the stage AFTER the one that reaches it. A value no stage
1984
1988
  # owns is derived by the pod; a person-only value is `humanOnly` on the lifecycle.
1985
1989
  # `activators` are DECLARATIONS the pod compiles into governed propose-mode rules
1986
1990
  # at install — never hand-written `automations:`. `relationToSubject` is the edge
@@ -1999,7 +2003,7 @@ playbooks:
1999
2003
  re-derive it from a website capture — and load the creative-director skill
2000
2004
  (linked to this space) to pick the approved brand-template (layout and
2001
2005
  recipe), references and assets for this format and style; drafts never feed
2002
- generation. Work the stages in order; each stage moves the post's status.
2006
+ generation. Work the stages in order; a stage's approved work moves the post's status.
2003
2007
  SCRIPT before anything is made: write the script or outline for the format
2004
2008
  (carousel slide outline, deck outline, video script and storyboard, or the
2005
2009
  text draft) by filling the narrative frame for the post's goal — the
@@ -2035,8 +2039,9 @@ playbooks:
2035
2039
  Schedule, a post whose account is a Postiz channel is queued through the
2036
2040
  capability that serves publish_post (postiz_schedule_post); that queueing is
2037
2041
  itself a proposal a person approves. Nothing publishes itself, and the post
2038
- reads Published only once it went live: reported by Postiz, or confirmed
2039
- by a person at Publish.
2042
+ reads Published only once it went live: written by Publish due posts,
2043
+ reported by Postiz, or moved by a person once it is live. The gate at
2044
+ Publish approves the schedule (the post reads Scheduled).
2040
2045
  subjectProfile:
2041
2046
  profileSlug: post
2042
2047
  # Idea is where a capture lands and Archived is a person's call — no stage
@@ -2078,7 +2083,7 @@ playbooks:
2078
2083
  - key: brief
2079
2084
  name: Brief
2080
2085
  category: planned
2081
- subjectStatus: Briefed
2086
+ onApproved: Briefed
2082
2087
  # A run is BORN at its first stage, and nothing writes a stage's status
2083
2088
  # at birth (finding f36420d5: the pilot post stayed at Idea while its
2084
2089
  # run reached Draft). Said here, not only in goalTemplate: a template
@@ -2086,11 +2091,14 @@ playbooks:
2086
2091
  goal: >-
2087
2092
  Pin down the post's angle, platform, format, pillar and journey stage
2088
2093
  before anything is drafted. A run starts at this stage without moving
2089
- the post: if the post still reads Idea, move it to Briefed first
2090
- (synap_update_entity, post-status Briefed, expectedStatus Idea). Then
2091
- advance the run through every stage in order (currentStage), never
2092
- skipping one, takes included: entering a stage moves the post to its
2093
- status, and a reply that says proposed is success.
2094
+ the post. Once the brief is set, move the post to Briefed if it still
2095
+ reads Idea (synap_update_entity, post-status Briefed, expectedStatus
2096
+ Idea): Briefed means the brief is done. Then advance the run through
2097
+ every stage in order (currentStage), never skipping one, takes
2098
+ included. A stage moves the post when its work is APPROVED, not when
2099
+ it is entered: the approved Script moves it to Scripted, the Draft
2100
+ gate's approval to In Draft, the Publish gate's approval to
2101
+ Scheduled; a reply that says proposed is success.
2094
2102
  criteria:
2095
2103
  - key: brief-has-hook
2096
2104
  statement: The post has a hook or headline that states its one idea.
@@ -2105,7 +2113,7 @@ playbooks:
2105
2113
  - key: script
2106
2114
  name: Script
2107
2115
  category: started
2108
- subjectStatus: Scripted
2116
+ onApproved: Scripted
2109
2117
  goal: >-
2110
2118
  Write the script or outline for the post's format — carousel slide
2111
2119
  outline, deck outline, video script and storyboard, or the text draft —
@@ -2262,7 +2270,7 @@ playbooks:
2262
2270
  - key: schedule
2263
2271
  name: Schedule
2264
2272
  category: started
2265
- subjectStatus: Scheduled
2273
+ onApproved: Scheduled
2266
2274
  goal: >-
2267
2275
  Set the publish date and queue the post on its account: its
2268
2276
  post-account, else the Personal account (account-owner) of its
@@ -2302,20 +2310,22 @@ playbooks:
2302
2310
  - key: publish
2303
2311
  name: Publish
2304
2312
  category: completed
2305
- subjectStatus: Published
2313
+ onApproved: Published
2306
2314
  goal: >-
2307
2315
  The post is live at its URL. Armed for Unipile, Publish due posts
2308
2316
  sends it on its day and writes Published, post-url and
2309
2317
  published-at itself; a send that fails writes publish-outcome failed
2310
2318
  and publish-error and leaves the post at Scheduled, for a person to
2311
2319
  fix and arm again. Queued through Postiz, Postiz reports it (its
2312
- webhook records the URL and Published); otherwise a person confirms
2313
- it, and approving writes Published.
2314
- # A HUMAN gate, not a check: the pod holds a gated stage's status until
2315
- # the gate passes, and a check gate judges the stage being LEFT
2316
- # (Schedule), so it would pass on entry and write Published before
2317
- # anyone saw the post go out — firing Repurpose on a post that may
2318
- # never have shipped. Only a person's approval writes Published.
2320
+ webhook records the URL and Published); otherwise a person moves the
2321
+ post to Published once it is live.
2322
+ # A HUMAN gate, not a check: its approval is the approval of the
2323
+ # Schedule stage's work (decision D2), which moves the post to
2324
+ # Scheduled — what Publish due posts sends. Published is this stage's
2325
+ # onApproved, written by what sends the post (Publish due posts, the
2326
+ # Postiz webhook) or by a person once it is live: never by an
2327
+ # approval, so Repurpose never fires on a post that may not have
2328
+ # shipped.
2319
2329
  gate: { kind: human }
2320
2330
  onFail: { toStage: schedule }
2321
2331
  criteria:
@@ -2705,7 +2715,7 @@ playbooks:
2705
2715
  - key: scheduled
2706
2716
  name: Scheduled
2707
2717
  category: started
2708
- subjectStatus: Scheduled
2718
+ onApproved: Scheduled
2709
2719
  goal: Set the send date and queue the issue.
2710
2720
  criteria:
2711
2721
  - key: send-date-set
@@ -111,7 +111,11 @@ describe("CRM absorbs Outreach & Comms", () => {
111
111
  expect(reply.goalTemplate).toMatch(/meeting/);
112
112
  expect(reply.goalTemplate).not.toMatch(/(?<!never )open a deal/i);
113
113
  // The run starts at `sent`: no stage may move the message back to drafted or sent.
114
- expect((reply.stages ?? []).map((s) => s.subjectStatus).filter(Boolean)).toEqual(["replied", "bounced", "no_response"]);
114
+ // D2: `replied` is REACHED when `wait` is approved (the replied stage's
115
+ // check gate); bounced and no_response are outcome stages: entering one
116
+ // IS the outcome, so they stay entered statuses.
117
+ expect((reply.stages ?? []).map((s) => s.subjectStatus).filter(Boolean)).toEqual(["bounced", "no_response"]);
118
+ expect((reply.stages ?? []).find((s) => s.key === "wait")?.onApproved).toBe("replied");
115
119
 
116
120
  const outreach = playbookOf("Personalized Outreach");
117
121
  expect(outreach.subjectProfile).toEqual({ profileSlug: "campaign" });