@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.
- package/README.md +4 -3
- package/automations/lead-converted-becomes-client.automation.json +89 -0
- package/automations/lead-converted-becomes-client.catalog.json +13 -0
- package/capabilities/apify.capability.json +8 -1
- package/capabilities/apollo.capability.json +8 -1
- package/capabilities/cal-com.capability.json +8 -1
- package/capabilities/exa.capability.json +8 -1
- package/capabilities/fal-ai.capability.json +8 -1
- package/capabilities/fal-media-lab.capability.json +8 -1
- package/capabilities/fireflies.capability.json +8 -1
- package/capabilities/mailgun.capability.json +8 -1
- package/capabilities/omniroute.capability.json +7 -1
- package/capabilities/posthog-analytics.capability.json +7 -1
- package/capabilities/postiz.capability.json +7 -1
- package/capabilities/replicate-rvm.capability.json +21 -5
- package/capabilities/stripe.capability.json +10 -1
- package/capabilities/unipile-linkedin.capability.json +39 -3
- package/capabilities/vercel.capability.json +8 -1
- package/dist/{define-BAPO0xZf.d.ts → define-Dto5_E47.d.ts} +15 -3
- package/dist/index.d.ts +2 -2
- package/dist/index.js +623 -96
- package/dist/index.js.map +1 -1
- package/dist/wire.d.ts +1 -1
- package/package.json +1 -1
- package/src/agency-os.yaml +1 -1
- package/src/brand-library.yaml +6 -6
- package/src/builder.yaml +17 -12
- package/src/content-os.template.test.ts +38 -22
- package/src/content-os.video-takes.template.test.ts +4 -2
- package/src/content-os.yaml +33 -23
- package/src/crm-absorbs-outreach.template.test.ts +5 -1
- package/src/crm.yaml +53 -30
- package/src/decisions-wave.template.test.ts +99 -5
- package/src/finance.yaml +11 -6
- package/src/foundation.yaml +22 -10
- package/src/grants.yaml +4 -0
- package/src/intent.test.ts +4 -2
- package/src/lead-automations.test.ts +93 -0
- package/src/lead-becomes-client.template.test.ts +137 -0
- package/src/lifecycle-declarations.test.ts +20 -1
- package/src/lifecycle-presets.test.ts +39 -7
- package/src/marketing.yaml +3 -3
- package/src/operations.yaml +155 -24
- package/src/postiz-contract.test.ts +3 -2
- package/src/process-contract.validate.test.ts +4 -1
- package/src/publish-official-lib.test.ts +8 -7
- package/src/research-base.yaml +2 -2
- package/src/research-decision.yaml +1 -1
- package/src/ship-a-change.template.test.ts +11 -2
- package/src/templates.ts +223 -74
- package/src/types.ts +15 -3
- package/src/unipile-lookups-read-only.test.ts +1 -0
- package/src/validate-flow.ts +15 -1
- package/src/validate.ts +40 -4
package/src/crm.yaml
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
# CRM workspace template
|
|
2
2
|
# The CRM owns pre-sale work only: who is worth pursuing (the `lead` role's
|
|
3
3
|
# leadStage, "Qualify a lead"), the sale (the deal's commercialStage, "Win a
|
|
4
|
-
# deal") and the campaigns people come from. A
|
|
5
|
-
#
|
|
4
|
+
# deal") and the campaigns people come from. A lead that signs becomes a
|
|
5
|
+
# client (founder, 17 Nov 2026, design 05ed390c): a person moves it to
|
|
6
|
+
# `converted` (= signed), the automation `lead-converted-becomes-client` attaches
|
|
7
|
+
# the `client` role handed off to Operations, and Operations onboards it ("Onboard
|
|
8
|
+
# a client"). Clients and client delivery belong to Operations.
|
|
6
9
|
#
|
|
7
10
|
# Business Developer folded into this file (founder decision 2026-10-12): its
|
|
8
11
|
# lead/client fields, the campaign kind and "Qualify a lead" live here now; its
|
|
@@ -68,11 +71,16 @@ meta:
|
|
|
68
71
|
# What this space PRODUCES (homes): the purpose word, then its kinds/roles.
|
|
69
72
|
intent:
|
|
70
73
|
label: Sales
|
|
71
|
-
# The ONE primary output (One model decision 3): the won deal
|
|
74
|
+
# The ONE primary output (One model decision 3): the won deal. A lead
|
|
75
|
+
# that signs becomes a client through ONE door (founder, 17 Nov 2026,
|
|
76
|
+
# design 05ed390c): a person moves it to `converted` (= signed), and the
|
|
77
|
+
# CRM automation `lead-converted-becomes-client` stamps `convertedAt` and
|
|
78
|
+
# attaches the `client` role handed off to Operations. The client is
|
|
79
|
+
# Operations' output (its Clients board and "Onboard a client"), not this
|
|
80
|
+
# space's: the CRM still references the role for the handoff fields.
|
|
72
81
|
primary: deal
|
|
73
82
|
produces:
|
|
74
83
|
- profile: lead
|
|
75
|
-
- profile: client
|
|
76
84
|
- profile: deal
|
|
77
85
|
- profile: campaign
|
|
78
86
|
- profile: outreach-touch
|
|
@@ -374,9 +382,11 @@ profiles:
|
|
|
374
382
|
# equal foundation's (shared-role-ssot rule c). validate.ts rule
|
|
375
383
|
# `shared-role-reference-*` requires foundation in the dependency chain.
|
|
376
384
|
# ═══════════════════════════════════════════════════════════════════════════
|
|
377
|
-
# The handoff context
|
|
378
|
-
#
|
|
379
|
-
#
|
|
385
|
+
# The handoff context written when a lead signs (the CRM automation
|
|
386
|
+
# `lead-converted-becomes-client` attaches the role with becameClientAt,
|
|
387
|
+
# handoffStatus handed_off and handoffDestination Operations) and that
|
|
388
|
+
# Operations' "Pick up handed-off clients" safety net reads. Moved verbatim
|
|
389
|
+
# from business-developer (2026-10-12).
|
|
380
390
|
- slug: client
|
|
381
391
|
displayName: Client
|
|
382
392
|
scope: shared
|
|
@@ -1037,7 +1047,8 @@ playbooks:
|
|
|
1037
1047
|
# again. Pursue sets the lead qualified with the next action "book a
|
|
1038
1048
|
# meeting"; it never opens a deal (CRM build plan A4, 2026-10-22): a deal
|
|
1039
1049
|
# exists only once a person records a booked meeting (founder decision
|
|
1040
|
-
# 2026-10-20)
|
|
1050
|
+
# 2026-10-20). The lead converts only when the client signs (`converted` =
|
|
1051
|
+
# signed, founder 17 Nov 2026), a person's move. Nurture and drop are the
|
|
1041
1052
|
# person's answer, recorded as nurturing / disqualified.
|
|
1042
1053
|
# Next action (CRM review 2026-10-27): every outcome that leaves the lead
|
|
1043
1054
|
# open (score, pursue, nurture) writes the facet's `nextAction` (one
|
|
@@ -1067,8 +1078,9 @@ playbooks:
|
|
|
1067
1078
|
when they chose pursue, set the lead to qualified with `nextAction`
|
|
1068
1079
|
"Book a meeting" (one line naming the channel, e.g. "Ask for a
|
|
1069
1080
|
meeting on LinkedIn") and `nextActionAt` its date. Never create a deal:
|
|
1070
|
-
a deal is opened when a person records a booked meeting
|
|
1071
|
-
|
|
1081
|
+
a deal is opened when a person records a booked meeting. Never move the
|
|
1082
|
+
lead to converted and never mark it a client: the lead converts when the
|
|
1083
|
+
client signs, and that is a person's move.
|
|
1072
1084
|
subjectProfile:
|
|
1073
1085
|
profileSlug: lead
|
|
1074
1086
|
# Manual only (founder decision 2026-10-27): the `created` worker started
|
|
@@ -1128,8 +1140,8 @@ playbooks:
|
|
|
1128
1140
|
- key: pursue
|
|
1129
1141
|
name: Pursue
|
|
1130
1142
|
category: completed
|
|
1131
|
-
|
|
1132
|
-
goal: Only after the person chose pursue, set the lead qualified with nextAction "Book a meeting" (one line naming the channel) and its nextActionAt. Open no deal.
|
|
1143
|
+
onApproved: qualified
|
|
1144
|
+
goal: Only after the person chose pursue, set the lead qualified yourself (update_facet on the lead role, leadStage qualified, expectedStatus the status you read; nothing else moves it) with nextAction "Book a meeting" (one line naming the channel) and its nextActionAt. Open no deal.
|
|
1133
1145
|
criteria:
|
|
1134
1146
|
- key: lead-book-meeting
|
|
1135
1147
|
statement: The lead's nextAction is to book a meeting and its nextActionAt is set.
|
|
@@ -1184,7 +1196,8 @@ playbooks:
|
|
|
1184
1196
|
description: Take a deal from first conversation to won or lost — qualify it, write and send the proposal, negotiate, and hand a won deal to delivery, with a person deciding every commitment.
|
|
1185
1197
|
goalTemplate: >-
|
|
1186
1198
|
Work this deal ({deal}) through its stages; each stage moves the deal's
|
|
1187
|
-
commercial stage
|
|
1199
|
+
commercial stage when its work is approved (the sent proposal moves it
|
|
1200
|
+
to Proposal sent). QUALIFY: from the pod (the company, its people, every
|
|
1188
1201
|
past message and meeting) and public sources, establish the four facts a
|
|
1189
1202
|
proposal needs — the problem the buyer wants solved and what it costs
|
|
1190
1203
|
them, a budget range, who signs, and when they need it — and link the
|
|
@@ -1196,13 +1209,15 @@ playbooks:
|
|
|
1196
1209
|
nothing is sent without that approval. AWAIT: wait for the client's
|
|
1197
1210
|
answer and record it on the deal. NEGOTIATE: its check reads that
|
|
1198
1211
|
answer; log every objection and counter-offer and propose the next step.
|
|
1199
|
-
WON: once a person confirms the client said yes,
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1212
|
+
WON: once a person confirms the client said yes, propose moving the
|
|
1213
|
+
deal's lead (the company's lead, else the person's) to converted, which
|
|
1214
|
+
means signed. That move is the person's (converted is human-only), so it
|
|
1215
|
+
comes back proposed for them to approve, which is success. Never attach
|
|
1216
|
+
the client role and never open an engagement yourself: once the person
|
|
1217
|
+
approves, the pod stamps the lead, makes the company (or person) a
|
|
1218
|
+
client handed off to Operations, and Operations' "Onboard a client"
|
|
1219
|
+
opens or reuses the engagement. A lost deal is a person's call — record
|
|
1220
|
+
why it was lost.
|
|
1206
1221
|
subjectProfile:
|
|
1207
1222
|
profileSlug: deal
|
|
1208
1223
|
activators:
|
|
@@ -1212,10 +1227,11 @@ playbooks:
|
|
|
1212
1227
|
executor: is-agent
|
|
1213
1228
|
status: active
|
|
1214
1229
|
tools: [enrich_entity, search_external, list_records, send_message]
|
|
1230
|
+
# No engagement here (17 Nov 2026): the client's engagement is opened or
|
|
1231
|
+
# reused by Operations' "Onboard a client", one door per output.
|
|
1215
1232
|
expectedOutputs:
|
|
1216
1233
|
- { kind: person, label: Decision maker, relationToSubject: linked_to_deal }
|
|
1217
1234
|
- { kind: document, label: Proposal }
|
|
1218
|
-
- { kind: engagement, label: Client engagement, relationToSubject: relates_to }
|
|
1219
1235
|
metadata:
|
|
1220
1236
|
lineage: { method: "BANT qualification, proposal-led B2B sale" }
|
|
1221
1237
|
stages:
|
|
@@ -1253,8 +1269,14 @@ playbooks:
|
|
|
1253
1269
|
- key: send
|
|
1254
1270
|
name: Send proposal
|
|
1255
1271
|
category: started
|
|
1256
|
-
|
|
1257
|
-
goal: A person approves the proposal; then send it to the decision maker and record when.
|
|
1272
|
+
onApproved: proposed
|
|
1273
|
+
goal: A person approves the proposal; then send it to the decision maker with send_message and record when. Once it has gone, mark this stage's Sent proposal output done with the sent message as its ref (update_run); that moves the deal to Proposal sent. Never move the deal yourself.
|
|
1274
|
+
# REQUIRED (decision D2): the proposal as sent approves this stage, so
|
|
1275
|
+
# the deal reaches Proposal sent only once it has gone. A document,
|
|
1276
|
+
# not a `messaging` output: in CRM that kind is a drafter's proposed
|
|
1277
|
+
# message (DRAFT RULES, crm-messages-cadence).
|
|
1278
|
+
expectedOutputs:
|
|
1279
|
+
- { kind: document, label: Sent proposal, relationToSubject: none }
|
|
1258
1280
|
gate: { kind: human }
|
|
1259
1281
|
onFail: { toStage: write }
|
|
1260
1282
|
- key: await-answer
|
|
@@ -1270,6 +1292,7 @@ playbooks:
|
|
|
1270
1292
|
name: Negotiate
|
|
1271
1293
|
category: started
|
|
1272
1294
|
subjectStatus: negotiating
|
|
1295
|
+
onApproved: won
|
|
1273
1296
|
goal: Answer objections, log every counter-offer on the deal, and propose the next step.
|
|
1274
1297
|
gate: { kind: check }
|
|
1275
1298
|
onFail: { toStage: await-answer }
|
|
@@ -1281,8 +1304,7 @@ playbooks:
|
|
|
1281
1304
|
- key: won
|
|
1282
1305
|
name: Won
|
|
1283
1306
|
category: completed
|
|
1284
|
-
|
|
1285
|
-
goal: A person confirms the client said yes; then reuse the company's engagement in Operations (open one only when none exists) and attach the client role to the company.
|
|
1307
|
+
goal: A person confirms the client said yes; then propose moving the deal's lead to converted (signed), which the person approves. That approved move makes the company (or person) a client handed off to Operations, which onboards it.
|
|
1286
1308
|
gate: { kind: human }
|
|
1287
1309
|
onFail: { toStage: negotiate }
|
|
1288
1310
|
|
|
@@ -1978,7 +2000,8 @@ playbooks:
|
|
|
1978
2000
|
description: Run one outreach campaign — write the angle and its offer, pick the people, draft one personal first message each as a proposed message in their channel; a person approves the list, then approves each message, which the pod sends.
|
|
1979
2001
|
goalTemplate: >-
|
|
1980
2002
|
Run this outreach campaign ({campaign}) on {channel}; each stage moves
|
|
1981
|
-
its status
|
|
2003
|
+
its status when its work is approved, and at Finish you move it to
|
|
2004
|
+
completed yourself. If its type is not outreach, stop and say so. PREPARE: write
|
|
1982
2005
|
the target audience, the value proposition and the call to action (from
|
|
1983
2006
|
the By kind of lead row that fits the audience, when one does). Pick
|
|
1984
2007
|
the people to reach from the pod (and public sources when the pod has
|
|
@@ -2092,8 +2115,8 @@ playbooks:
|
|
|
2092
2115
|
- key: finish
|
|
2093
2116
|
name: Finish
|
|
2094
2117
|
category: completed
|
|
2095
|
-
|
|
2096
|
-
goal: Record how many messages were sent, how many got a reply and how many led to a booked meeting.
|
|
2118
|
+
onApproved: completed
|
|
2119
|
+
goal: Record how many messages were sent, how many got a reply and how many led to a booked meeting, then move the campaign to completed yourself (update_entity, campaign-status completed, expectedStatus active); nothing else moves it, and your move into completed comes back proposed for the person to approve, which is success.
|
|
2097
2120
|
criteria:
|
|
2098
2121
|
- key: outreach-reply-rate
|
|
2099
2122
|
statement: The campaign notes record how many messages were sent, replied to, and led to a booked meeting.
|
|
@@ -2126,7 +2149,7 @@ playbooks:
|
|
|
2126
2149
|
description: Once a person has marked an outreach touch sent (messages recorded before the channels), watch for the reply; summarise it and propose the next step — the free estimate or a meeting — and never open a deal.
|
|
2127
2150
|
goalTemplate: >-
|
|
2128
2151
|
Watch this sent outreach message ({touch}) for a reply; each stage
|
|
2129
|
-
moves its status. WAIT: watch its conversation. Set it bounced when it
|
|
2152
|
+
moves its status when its work is approved. WAIT: watch its conversation. Set it bounced when it
|
|
2130
2153
|
did not reach the person, or no response when its lead's next action
|
|
2131
2154
|
date passes with no reply; that date is the cadence's (the sent day + 3
|
|
2132
2155
|
days after the first message, the sent day + 7 days after each
|
|
@@ -2166,6 +2189,7 @@ playbooks:
|
|
|
2166
2189
|
- key: wait
|
|
2167
2190
|
name: Waiting for a reply
|
|
2168
2191
|
category: started
|
|
2192
|
+
onApproved: replied
|
|
2169
2193
|
goal: Watch the conversation for a reply, a bounce, or the follow-up date passing in silence.
|
|
2170
2194
|
indefinite: true
|
|
2171
2195
|
criteria:
|
|
@@ -2175,7 +2199,6 @@ playbooks:
|
|
|
2175
2199
|
- key: replied
|
|
2176
2200
|
name: Replied
|
|
2177
2201
|
category: completed
|
|
2178
|
-
subjectStatus: replied
|
|
2179
2202
|
goal: Summarise the reply for a person and propose the next step — the free estimate or a meeting; never open a deal.
|
|
2180
2203
|
gate: { kind: check }
|
|
2181
2204
|
onFail: { toStage: wait }
|
|
@@ -63,13 +63,18 @@ describe("decision 1 — Business Developer folds into CRM", () => {
|
|
|
63
63
|
// It owns researching and qualified; the other leadStage values belong to a
|
|
64
64
|
// person or another flow — derived by the pod, never listed (One model
|
|
65
65
|
// decision 4, 7 Nov 2026; conflict C2 on `outreach` closed).
|
|
66
|
-
const owned = (pb?.stages ?? []).
|
|
66
|
+
const owned = (pb?.stages ?? []).flatMap((s) => [s.subjectStatus, s.onApproved]).filter(Boolean);
|
|
67
67
|
expect(owned).toEqual(["researching", "qualified"]);
|
|
68
68
|
for (const s of owned) expect(propOf(tpl("foundation"), "lead", "leadStage")?.enumValues).toContain(s);
|
|
69
|
-
//
|
|
70
|
-
//
|
|
71
|
-
//
|
|
72
|
-
|
|
69
|
+
// The last stage, reached when the person chose pursue, DECLARES
|
|
70
|
+
// qualified (the follow and flow.of read it) but nothing approves it
|
|
71
|
+
// (ungated, no output), so the pod never writes it: its goal tells the
|
|
72
|
+
// run to move the lead through the role's status door (decision D2). It
|
|
73
|
+
// opens no deal (CRM build plan A4, 2026-10-22): a deal is opened when a
|
|
74
|
+
// person records a booked meeting.
|
|
75
|
+
expect(pb?.stages?.at(-1)).toMatchObject({ key: "pursue", onApproved: "qualified" });
|
|
76
|
+
expect(pb?.stages?.at(-1)?.subjectStatus).toBeUndefined();
|
|
77
|
+
expect(pb?.stages?.at(-1)?.goal).toMatch(/set the lead qualified yourself \(update_facet on the lead role, leadStage qualified/);
|
|
73
78
|
expect(pb?.stages?.flatMap((s) => s.expectedOutputs ?? [])).toEqual([]);
|
|
74
79
|
expect(pb?.expectedOutputs).toBeUndefined();
|
|
75
80
|
});
|
|
@@ -82,6 +87,69 @@ describe("decision 1 — Business Developer folds into CRM", () => {
|
|
|
82
87
|
expect(errorsOf(tpl("crm", c), c)).toContain('stage-subject-status-unknown playbooks."Qualify a lead".stages.research.subjectStatus');
|
|
83
88
|
});
|
|
84
89
|
|
|
90
|
+
it("an onApproved outside the lifecycle is refused (D2)", () => {
|
|
91
|
+
const c = structuredClone(corpus);
|
|
92
|
+
const pb = playbookOf(tpl("crm", c), "Qualify a lead")!;
|
|
93
|
+
pb.stages![0]!.onApproved = "won";
|
|
94
|
+
expect(errorsOf(tpl("crm", c), c)).toContain('stage-on-approved-unknown playbooks."Qualify a lead".stages.research.onApproved');
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it("an onApproved nothing approves is KEPT when the stage's goal names the move, refused when it does not (D2)", () => {
|
|
98
|
+
// The shipped catalog: every no-signal onApproved names its move.
|
|
99
|
+
const noSignal = corpus.flatMap((t) => errorsOf(t).filter((e) => e.startsWith("stage-on-approved-no-signal ")));
|
|
100
|
+
expect(noSignal).toEqual([]);
|
|
101
|
+
// NEGATIVE: the same last stage, its goal silent on the move.
|
|
102
|
+
const c = structuredClone(corpus);
|
|
103
|
+
const pursue = playbookOf(tpl("crm", c), "Qualify a lead")!.stages!.at(-1)!;
|
|
104
|
+
expect(pursue.onApproved).toBe("qualified");
|
|
105
|
+
pursue.goal = "Only after the person chose pursue, set the next action to book a meeting.";
|
|
106
|
+
expect(errorsOf(tpl("crm", c), c)).toContain('stage-on-approved-no-signal playbooks."Qualify a lead".stages.pursue.onApproved');
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it("no-signal is the pod's: a required output or the NEXT stage's gate approves; the stage's own gate and an optional output do not (D2)", () => {
|
|
110
|
+
const rule = (c: WorkspaceYaml[]) =>
|
|
111
|
+
errorsOf(tpl("crm", c), c).filter((e) => e.startsWith("stage-on-approved-no-signal ") && e.includes('"Win a deal"'));
|
|
112
|
+
const send = 'stage-on-approved-no-signal playbooks."Win a deal".stages.send.onApproved';
|
|
113
|
+
const silent = () => {
|
|
114
|
+
const c = structuredClone(corpus);
|
|
115
|
+
const s = playbookOf(tpl("crm", c), "Win a deal")!.stages!.find((x) => x.key === "send")!;
|
|
116
|
+
// send carries its own human gate; the next stage (await-answer) has none.
|
|
117
|
+
expect(s.gate).toEqual({ kind: "human" });
|
|
118
|
+
// The shipped stage owes its Sent proposal (signal 1): strip it to judge
|
|
119
|
+
// the gates alone.
|
|
120
|
+
expect(s.expectedOutputs).toEqual([{ kind: "document", label: "Sent proposal", relationToSubject: "none" }]);
|
|
121
|
+
s.expectedOutputs = undefined;
|
|
122
|
+
s.goal = "A person approves the proposal; then send it to the decision maker.";
|
|
123
|
+
return { c, s, pb: playbookOf(tpl("crm", c), "Win a deal")! };
|
|
124
|
+
};
|
|
125
|
+
// Its own gate does not approve it: the goal must name the move.
|
|
126
|
+
expect(rule(silent().c)).toEqual([send]);
|
|
127
|
+
// An optional output does not either.
|
|
128
|
+
{
|
|
129
|
+
const { c, s } = silent();
|
|
130
|
+
s.expectedOutputs = [{ kind: "document", label: "Sent proposal", optional: true }];
|
|
131
|
+
expect(rule(c)).toEqual([send]);
|
|
132
|
+
}
|
|
133
|
+
// A required output does.
|
|
134
|
+
{
|
|
135
|
+
const { c, s } = silent();
|
|
136
|
+
s.expectedOutputs = [{ kind: "document", label: "Sent proposal" }];
|
|
137
|
+
expect(rule(c)).toEqual([]);
|
|
138
|
+
}
|
|
139
|
+
// So does a gate on the NEXT stage.
|
|
140
|
+
{
|
|
141
|
+
const { c, pb } = silent();
|
|
142
|
+
pb.stages!.find((x) => x.key === "await-answer")!.gate = { kind: "human" };
|
|
143
|
+
expect(rule(c)).toEqual([]);
|
|
144
|
+
}
|
|
145
|
+
// The option's LABEL names the move as well as its key ("Proposal sent").
|
|
146
|
+
{
|
|
147
|
+
const { c, s } = silent();
|
|
148
|
+
s.goal = "A person approves the proposal; send it, then move the deal to Proposal sent.";
|
|
149
|
+
expect(rule(c)).toEqual([]);
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
|
|
85
153
|
it("'Advance a commercial proposal' is gone everywhere; CRM's 'Win a deal' remains", () => {
|
|
86
154
|
const names = corpus.flatMap((t) => (t.playbooks ?? []).map((p) => p.name));
|
|
87
155
|
expect(names).not.toContain("Advance a commercial proposal");
|
|
@@ -186,3 +254,29 @@ describe("settled item — a new brand voice guide is a draft", () => {
|
|
|
186
254
|
expect(propOf(tpl("brand-library"), "brand-voice-guide", "voice-status")?.constraints).toEqual({ defaultValue: "draft" });
|
|
187
255
|
});
|
|
188
256
|
});
|
|
257
|
+
|
|
258
|
+
describe("decision D2 — where a real artifact exists, the work itself reaches the status", () => {
|
|
259
|
+
const stageOf = (slug: string, playbook: string, key: string) =>
|
|
260
|
+
playbookOf(tpl(slug), playbook)!.stages!.find((s) => s.key === key)!;
|
|
261
|
+
it("Fix a finding's merged stage owes the merged pull request; the merge moves the finding to fixed", () => {
|
|
262
|
+
const merged = stageOf("builder-workspace", "Fix a finding", "merged");
|
|
263
|
+
expect(merged.onApproved).toBe("fixed");
|
|
264
|
+
expect(merged.expectedOutputs).toEqual([{ kind: "pull_request", label: "Merged fix", relationToSubject: "none" }]);
|
|
265
|
+
expect(merged.goal).toMatch(/with its url as the ref, and leave it open/);
|
|
266
|
+
expect(merged.goal).toMatch(/Never move the finding yourself/);
|
|
267
|
+
// Never the child's "Fix PR" label: the hand-off's draft PR must not close it.
|
|
268
|
+
expect(merged.expectedOutputs!.map((o) => o.label)).not.toContain("Fix PR");
|
|
269
|
+
});
|
|
270
|
+
it("Win a deal's send and Bill a client's send owe what was sent, and never move the subject themselves", () => {
|
|
271
|
+
for (const [slug, pb, label, output] of [
|
|
272
|
+
["crm", "Win a deal", "Sent proposal", { kind: "document", label: "Sent proposal", relationToSubject: "none" }],
|
|
273
|
+
["finance", "Bill a client", "Invoice sent to the client", { kind: "document", label: "Invoice sent to the client" }],
|
|
274
|
+
] as const) {
|
|
275
|
+
const send = stageOf(slug, pb, "send");
|
|
276
|
+
expect(send.expectedOutputs, pb).toEqual([output]);
|
|
277
|
+
expect(send.goal, pb).toContain(`${label} output done with the sent message as its ref (update_run)`);
|
|
278
|
+
expect(send.goal, pb).toMatch(/Never move the (deal|invoice) yourself/);
|
|
279
|
+
expect(send.goal, pb).not.toMatch(/update_entity/);
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
});
|
package/src/finance.yaml
CHANGED
|
@@ -577,7 +577,7 @@ playbooks:
|
|
|
577
577
|
- name: Bill a client
|
|
578
578
|
description: Take an invoice from draft to paid — prepare it, send it with a person's approval, chase it when late, and confirm the payment.
|
|
579
579
|
goalTemplate: >-
|
|
580
|
-
Bill this invoice ({invoice}); each stage moves its status. PREPARE: set
|
|
580
|
+
Bill this invoice ({invoice}); each stage moves its status when its work is approved. PREPARE: set
|
|
581
581
|
the invoice number, customer, amount, currency, issue date and due date
|
|
582
582
|
from the engagement or deal it bills, and check the amount against what
|
|
583
583
|
was agreed. SEND: a person approves the invoice before it goes to the
|
|
@@ -616,8 +616,13 @@ playbooks:
|
|
|
616
616
|
- key: send
|
|
617
617
|
name: Send
|
|
618
618
|
category: started
|
|
619
|
-
|
|
620
|
-
goal: A person approves the invoice before it goes to the client.
|
|
619
|
+
onApproved: sent
|
|
620
|
+
goal: A person approves the invoice before it goes to the client; then send it to the client with send_message. Once it has gone, mark the Invoice sent to the client output done with the sent message as its ref (update_run); that moves the invoice to sent. Never move the invoice yourself.
|
|
621
|
+
# REQUIRED (decision D2): the playbook's own deliverable, declared on
|
|
622
|
+
# the stage that produces it (the same label: entering the stage owes
|
|
623
|
+
# it once), approves this stage.
|
|
624
|
+
expectedOutputs:
|
|
625
|
+
- { kind: document, label: Invoice sent to the client }
|
|
621
626
|
gate: { kind: human }
|
|
622
627
|
onFail: { toStage: prepare }
|
|
623
628
|
- key: due
|
|
@@ -687,7 +692,7 @@ playbooks:
|
|
|
687
692
|
- name: Approve an expense
|
|
688
693
|
description: Review an expense against its budget, get a person's approval, and record the payment.
|
|
689
694
|
goalTemplate: >-
|
|
690
|
-
Handle this expense ({expense}); each stage moves its status. REVIEW:
|
|
695
|
+
Handle this expense ({expense}); each stage moves its status when its work is approved. REVIEW:
|
|
691
696
|
check the vendor, amount, date, category and receipt, link the budget it
|
|
692
697
|
counts against and say how much of that budget is left after it. APPROVE:
|
|
693
698
|
a person approves or rejects the spend. PAY: a person confirms it was
|
|
@@ -706,6 +711,7 @@ playbooks:
|
|
|
706
711
|
name: Review
|
|
707
712
|
category: planned
|
|
708
713
|
subjectStatus: pending
|
|
714
|
+
onApproved: approved
|
|
709
715
|
goal: Check the expense's facts and receipt and link the budget it counts against.
|
|
710
716
|
criteria:
|
|
711
717
|
- key: expense-facts
|
|
@@ -717,14 +723,13 @@ playbooks:
|
|
|
717
723
|
- key: approve
|
|
718
724
|
name: Approve
|
|
719
725
|
category: started
|
|
720
|
-
|
|
726
|
+
onApproved: paid
|
|
721
727
|
goal: A person approves the spend.
|
|
722
728
|
gate: { kind: human }
|
|
723
729
|
onFail: { toStage: review }
|
|
724
730
|
- key: pay
|
|
725
731
|
name: Pay
|
|
726
732
|
category: completed
|
|
727
|
-
subjectStatus: paid
|
|
728
733
|
goal: A person confirms the expense was paid; link the account it was paid from.
|
|
729
734
|
gate: { kind: human }
|
|
730
735
|
onFail: { toStage: approve }
|
package/src/foundation.yaml
CHANGED
|
@@ -352,12 +352,18 @@ profiles:
|
|
|
352
352
|
applicableKinds:
|
|
353
353
|
- company
|
|
354
354
|
- person
|
|
355
|
-
# The ONE lifecycle (work model L1): the relationship base
|
|
356
|
-
# (prospect · active · paused · former · churned;
|
|
357
|
-
#
|
|
355
|
+
# The ONE lifecycle (work model L1): the relationship base plus
|
|
356
|
+
# `onboarding` (prospect · onboarding · active · paused · former · churned;
|
|
357
|
+
# lifecycle-presets.ts). A lead that signs becomes a client (the CRM
|
|
358
|
+
# automation `lead-converted-becomes-client` attaches this role) and starts
|
|
359
|
+
# at onboarding: Operations' "Onboard a client" moves it there, then to
|
|
360
|
+
# active once a person confirms the kick-off (founder, 17 Nov 2026, design
|
|
361
|
+
# 05ed390c). The compiler writes the options and the select's enumValues.
|
|
358
362
|
lifecycle:
|
|
359
363
|
property: clientStatus
|
|
360
364
|
adopts: relationship
|
|
365
|
+
add:
|
|
366
|
+
- { key: onboarding, category: open, before: active }
|
|
361
367
|
properties:
|
|
362
368
|
- slug: clientStatus
|
|
363
369
|
label: Status
|
|
@@ -531,8 +537,13 @@ profiles:
|
|
|
531
537
|
- company
|
|
532
538
|
- person
|
|
533
539
|
# The ONE lifecycle (work model L1): every option's category. `converted`
|
|
534
|
-
#
|
|
535
|
-
#
|
|
540
|
+
# = signed (founder, 17 Nov 2026, design 05ed390c): a person's move, made
|
|
541
|
+
# when the client signs (an agent's move, e.g. "Win a deal"'s Won stage, is
|
|
542
|
+
# a proposal the person approves). The booked meeting is not a conversion:
|
|
543
|
+
# it opens the deal, whose first stage reads "Meeting booked". Moving to
|
|
544
|
+
# converted stamps `convertedAt` and attaches the `client` role (CRM
|
|
545
|
+
# automation `lead-converted-becomes-client`); the converted lead role stays
|
|
546
|
+
# as the history of the sale.
|
|
536
547
|
lifecycle:
|
|
537
548
|
property: leadStage
|
|
538
549
|
# Stage ORDER is the pipeline's reading order (founder, 2026-11-09, board
|
|
@@ -580,11 +591,12 @@ profiles:
|
|
|
580
591
|
- { key: disqualified, category: lost, humanOnly: true }
|
|
581
592
|
properties:
|
|
582
593
|
# The lead role's ONE lifecycle (work model W15, 2026-10-11):
|
|
583
|
-
# qualification only. `converted` =
|
|
584
|
-
#
|
|
585
|
-
#
|
|
586
|
-
#
|
|
587
|
-
# (conversions
|
|
594
|
+
# qualification only. `converted` = the client signed, and the same
|
|
595
|
+
# person or company became a client (the sale itself lives on the deal's
|
|
596
|
+
# commercialStage, from "Meeting booked" to won); `disqualified` =
|
|
597
|
+
# dropped. Business Developer's `lifecycleStage` overlay folded into
|
|
598
|
+
# this; old `prospect` → new, `lost` → disqualified (conversions
|
|
599
|
+
# `w12.lead.*`).
|
|
588
600
|
- slug: leadStage
|
|
589
601
|
label: Stage
|
|
590
602
|
valueType: string
|
package/src/grants.yaml
CHANGED
|
@@ -706,6 +706,9 @@ profiles:
|
|
|
706
706
|
property: clientStatus
|
|
707
707
|
options:
|
|
708
708
|
- { key: prospect, category: open }
|
|
709
|
+
# Mirrors foundation's client lifecycle (one pod-wide role, shared-role
|
|
710
|
+
# SSOT rule b): a new client starts at onboarding (17 Nov 2026).
|
|
711
|
+
- { key: onboarding, category: open }
|
|
709
712
|
- { key: active, category: active }
|
|
710
713
|
- { key: paused, category: paused }
|
|
711
714
|
- { key: former, category: done }
|
|
@@ -717,6 +720,7 @@ profiles:
|
|
|
717
720
|
inputType: select
|
|
718
721
|
enumValues:
|
|
719
722
|
- prospect
|
|
723
|
+
- onboarding
|
|
720
724
|
- active
|
|
721
725
|
- paused
|
|
722
726
|
- former
|
package/src/intent.test.ts
CHANGED
|
@@ -167,8 +167,10 @@ describe("meta.intent — the catalog", () => {
|
|
|
167
167
|
expect(table["builder-workspace"]).toEqual(["Product", "devplane_feature", "devplane_story", "ui-design"]);
|
|
168
168
|
// outreach-touch joined when CRM absorbed Outreach & Comms (founder decision 2026-10-23):
|
|
169
169
|
// the messages drafted for a person to send are part of the commercial job.
|
|
170
|
-
|
|
171
|
-
|
|
170
|
+
// `client` moved from CRM to Operations (founder, 17 Nov 2026, design 05ed390c):
|
|
171
|
+
// a lead that signs becomes a client, and Operations is the Clients space.
|
|
172
|
+
expect(table["crm"]).toEqual(["Sales", "lead", "deal", "campaign", "outreach-touch"]);
|
|
173
|
+
expect(table["operations"]).toEqual(["Delivery", "engagement", "deliverable", "client"]);
|
|
172
174
|
expect(table["content-os"]).toEqual(["Content", "post", "newsletter", "campaign"]);
|
|
173
175
|
expect(table["finance"]).toEqual(["Finance", "invoice", "expense"]);
|
|
174
176
|
expect(table["research-base"]).toEqual(["Research", "hypothesis", "research-finding"]);
|
|
@@ -102,3 +102,96 @@ describe("lead-sent-outreach", () => {
|
|
|
102
102
|
expect(sentHeader.meta.slug).toBe("lead-sent-outreach");
|
|
103
103
|
});
|
|
104
104
|
});
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* A lead signs: it becomes a client (founder, 17 Nov 2026, design 05ed390c;
|
|
108
|
+
* defaults: `converted` = signed, lead → client directly, the converted lead
|
|
109
|
+
* role stays as history). Pinned: the flow validates; the trigger is the ONE
|
|
110
|
+
* transition event filtered on the ROLE whose lifecycle moved (`lifecycleProfile`,
|
|
111
|
+
* never `profileSlug`, which carries the entity's kind) and on `to: converted`;
|
|
112
|
+
* the lead is stamped (`convertedAt`, no status move: the lead stays converted)
|
|
113
|
+
* BEFORE the client role is attached with the handoff fields the CRM declares
|
|
114
|
+
* and Operations' safety net reads; the attach names no `workspaceId` (the
|
|
115
|
+
* facet inherits the pod-wide entity's, and the verb's param cannot be null);
|
|
116
|
+
* nothing detaches the lead role. Not covered: that a pod runs it end to end,
|
|
117
|
+
* and that the attach reaches Operations' "Onboard a client" (backend W1) —
|
|
118
|
+
* NEEDS-DOGFOOD.
|
|
119
|
+
*/
|
|
120
|
+
describe("lead-converted-becomes-client", () => {
|
|
121
|
+
const conv = read("lead-converted-becomes-client.automation.json");
|
|
122
|
+
const convHeader = read("lead-converted-becomes-client.catalog.json");
|
|
123
|
+
const convNodes = conv.flowDefinition.nodes as Array<{ id: string; type: string; data: Record<string, any> }>;
|
|
124
|
+
const byOutput = (t: string) => convNodes.filter((n) => n.data.outputType === t);
|
|
125
|
+
const foundation = getWorkspaceTemplate("foundation")!;
|
|
126
|
+
const crm = getWorkspaceTemplate("crm")!;
|
|
127
|
+
|
|
128
|
+
it("passes the flow validator", () => {
|
|
129
|
+
expect(validateFlowDefinition(conv.flowDefinition).errors).toEqual([]);
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it("fires on the lead's move to converted (the transition event, on the role, on trigger and node)", () => {
|
|
133
|
+
const filter = { lifecycleProfile: "lead", to: "converted" };
|
|
134
|
+
expect(conv.triggerType).toBe("event");
|
|
135
|
+
expect(conv.status).toBe("active");
|
|
136
|
+
expect(conv.triggerConfig).toEqual({ eventPattern: "entity.transition.completed", filters: filter });
|
|
137
|
+
const t = convNodes.find((n) => n.type === "trigger")!;
|
|
138
|
+
expect(t.data.config).toEqual({ eventPattern: "entity.transition.completed", filters: filter });
|
|
139
|
+
const lead = foundation.profiles.find((p) => p.slug === "lead")!;
|
|
140
|
+
const converted = lead.lifecycle!.options.find((o) => o.key === "converted")!;
|
|
141
|
+
// converted is the person's move (= signed): an agent's move is a proposal first.
|
|
142
|
+
expect(converted).toMatchObject({ category: "done", humanOnly: true });
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it("guards on a named entity, computes now once, stamps the lead, then attaches the client role", () => {
|
|
146
|
+
const guard = convNodes.find((n) => n.type === "guard")!;
|
|
147
|
+
expect(guard.data.checks[0]).toMatchObject({ path: "trigger.payload.data.entityId", minLength: 36 });
|
|
148
|
+
const now = convNodes.find((n) => n.type === "compute")!;
|
|
149
|
+
expect(now.data.operation).toBe("now");
|
|
150
|
+
|
|
151
|
+
const [stamp] = byOutput("facet_update");
|
|
152
|
+
expect(stamp.data.config).toEqual({
|
|
153
|
+
entityId: "{{trigger.payload.data.entityId}}",
|
|
154
|
+
facetSlug: "lead",
|
|
155
|
+
properties: { convertedAt: `{{steps.${now.id}.output.result}}` },
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
const [attach] = byOutput("facet_attach");
|
|
159
|
+
expect(attach.data.config).toEqual({
|
|
160
|
+
entityId: "{{trigger.payload.data.entityId}}",
|
|
161
|
+
facetSlug: "client",
|
|
162
|
+
properties: {
|
|
163
|
+
becameClientAt: `{{steps.${now.id}.output.result}}`,
|
|
164
|
+
handoffStatus: "handed_off",
|
|
165
|
+
handoffDestination: "Operations",
|
|
166
|
+
},
|
|
167
|
+
});
|
|
168
|
+
expect("workspaceId" in attach.data.config).toBe(false);
|
|
169
|
+
|
|
170
|
+
// One chain, in order: trigger → guard → now → stamp → attach.
|
|
171
|
+
const order = ["t", guard.id, now.id, stamp.id, attach.id];
|
|
172
|
+
expect(conv.flowDefinition.edges.map((e: { source: string; target: string }) => [e.source, e.target])).toEqual(
|
|
173
|
+
order.slice(0, -1).map((id, i) => [id, order[i + 1]])
|
|
174
|
+
);
|
|
175
|
+
// The lead role is kept as history: nothing moves or detaches it.
|
|
176
|
+
expect(byOutput("facet_detach")).toEqual([]);
|
|
177
|
+
expect(stamp.data.config.status).toBeUndefined();
|
|
178
|
+
expect(convNodes.filter((n) => n.type === "output")).toHaveLength(2);
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
it("writes only fields the catalog declares, with values the selects offer", () => {
|
|
182
|
+
const leadProps = crm.profiles.find((p) => p.slug === "lead")!.properties.map((p) => p.slug);
|
|
183
|
+
expect(leadProps).toContain("convertedAt");
|
|
184
|
+
const clientProps = crm.profiles.find((p) => p.slug === "client")!.properties;
|
|
185
|
+
const [attach] = byOutput("facet_attach");
|
|
186
|
+
for (const key of Object.keys(attach.data.config.properties)) expect(clientProps.map((p) => p.slug)).toContain(key);
|
|
187
|
+
expect(clientProps.find((p) => p.slug === "handoffStatus")!.enumValues).toContain("handed_off");
|
|
188
|
+
// Operations' 07:00 safety net reads the same value.
|
|
189
|
+
expect(JSON.stringify(getWorkspaceTemplate("operations")!.automations)).toContain("contains-any ready,handed_off");
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
it("has a catalog header, so it is published", () => {
|
|
193
|
+
expect(convHeader.kind).toBe("automation");
|
|
194
|
+
expect(convHeader.meta.slug).toBe("lead-converted-becomes-client");
|
|
195
|
+
expect(convHeader.meta.name).toBe(conv.name);
|
|
196
|
+
});
|
|
197
|
+
});
|