@synap-core/workspace-templates 0.46.0 → 0.47.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synap-core/workspace-templates",
3
- "version": "0.46.0",
3
+ "version": "0.47.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
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 won deal is handed to the
5
- # operating workspace; client delivery belongs to Operations.
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; the lead-becomes-client role flow is not modeled yet (S8, decision 10).
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 a won deal writes ("Win a deal" attaches the role with
378
- # handoffStatus handed_off) and Operations' "Pick up handed-off clients"
379
- # reads. Moved verbatim from business-developer (2026-10-12).
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), and that same move converts the lead. Nurture and drop are the
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, and that same
1071
- step converts the lead. Never mark the lead a client.
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
@@ -1196,13 +1208,15 @@ playbooks:
1196
1208
  nothing is sent without that approval. AWAIT: wait for the client's
1197
1209
  answer and record it on the deal. NEGOTIATE: its check reads that
1198
1210
  answer; log every objection and counter-offer and propose the next step.
1199
- WON: once a person confirms the client said yes, reuse the engagement
1200
- Operations already has for this company; only when there is none, open
1201
- one at proposed with its client set to the company. Then attach the
1202
- client role to the company with handoff status handed_off. The daily
1203
- "Pick up handed-off clients" automation skips any client that already
1204
- has an engagement, so no second one is opened. A lost deal is a
1205
- person's call — record why it was lost.
1211
+ WON: once a person confirms the client said yes, propose moving the
1212
+ deal's lead (the company's lead, else the person's) to converted, which
1213
+ means signed. That move is the person's (converted is human-only), so it
1214
+ comes back proposed for them to approve, which is success. Never attach
1215
+ the client role and never open an engagement yourself: once the person
1216
+ approves, the pod stamps the lead, makes the company (or person) a
1217
+ client handed off to Operations, and Operations' "Onboard a client"
1218
+ opens or reuses the engagement. A lost deal is a person's call — record
1219
+ why it was lost.
1206
1220
  subjectProfile:
1207
1221
  profileSlug: deal
1208
1222
  activators:
@@ -1212,10 +1226,11 @@ playbooks:
1212
1226
  executor: is-agent
1213
1227
  status: active
1214
1228
  tools: [enrich_entity, search_external, list_records, send_message]
1229
+ # No engagement here (17 Nov 2026): the client's engagement is opened or
1230
+ # reused by Operations' "Onboard a client", one door per output.
1215
1231
  expectedOutputs:
1216
1232
  - { kind: person, label: Decision maker, relationToSubject: linked_to_deal }
1217
1233
  - { kind: document, label: Proposal }
1218
- - { kind: engagement, label: Client engagement, relationToSubject: relates_to }
1219
1234
  metadata:
1220
1235
  lineage: { method: "BANT qualification, proposal-led B2B sale" }
1221
1236
  stages:
@@ -1282,7 +1297,7 @@ playbooks:
1282
1297
  name: Won
1283
1298
  category: completed
1284
1299
  subjectStatus: won
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.
1300
+ 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
1301
  gate: { kind: human }
1287
1302
  onFail: { toStage: negotiate }
1288
1303
 
@@ -352,12 +352,18 @@ profiles:
352
352
  applicableKinds:
353
353
  - company
354
354
  - person
355
- # The ONE lifecycle (work model L1): the relationship base as it stands
356
- # (prospect · active · paused · former · churned; lifecycle-presets.ts).
357
- # The compiler writes the options and the select's enumValues.
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
- # is a person's move (CRM build plan A4, 2026-10-22): it happens when a
535
- # person records a booked meeting, which opens the deal; no agent sets it.
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` = a person recorded a booked meeting
584
- # and a deal was opened (the sale then lives on the deal's commercialStage);
585
- # `disqualified` = dropped. Business Developer's `lifecycleStage` overlay
586
- # folded into this; old `prospect` → new, `lost` → disqualified
587
- # (conversions `w12.lead.*`).
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
@@ -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
- expect(table["crm"]).toEqual(["Sales", "lead", "client", "deal", "campaign", "outreach-touch"]);
171
- expect(table["operations"]).toEqual(["Delivery", "engagement", "deliverable"]);
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
+ });
@@ -0,0 +1,134 @@
1
+ /**
2
+ * Lead → client in the product, the catalog half (wave W2 of design 05ed390c,
3
+ * founder-approved 17 Nov 2026 with its defaults: `converted` = signed, lead →
4
+ * client directly, a new client starts at `onboarding`, the converted lead role
5
+ * stays as history, the Clients space is Operations, the 07:00 pick-up stays as
6
+ * a safety net, an engagement's client may be a person).
7
+ *
8
+ * Pinned:
9
+ * - ONE door: CRM's "Win a deal" Won stage proposes the lead's move to
10
+ * converted and no longer attaches the client role or opens an engagement;
11
+ * - Operations declares the `client` role (reference form), a Clients board
12
+ * grouped on its lifecycle, and "Onboard a client": subject the client role,
13
+ * started on the role's attach (propose), Welcome (onboarding) → Open or
14
+ * reuse the engagement (engagement_for_client) → Kick-off confirmed (a
15
+ * person's gate, active);
16
+ * - the engagement's client is whoever wears the client role (company or
17
+ * person), and both doors that open an engagement dedupe on it;
18
+ * - the whole touched corpus validates with zero errors.
19
+ * Not covered (NEEDS-DOGFOOD): that the attach made under the CRM space starts
20
+ * the Operations activator (backend W1), that a role board drags on
21
+ * clientStatus, that the picker lists role holders.
22
+ */
23
+ import { describe, expect, it } from "vitest";
24
+ import { readYamlTemplates } from "./generate.mjs";
25
+ import type { WorkspaceYaml } from "./types.js";
26
+ import { validateTemplate } from "./validate.js";
27
+
28
+ const corpus = readYamlTemplates().map((t) => t.data as WorkspaceYaml);
29
+ const tpl = (slug: string) => {
30
+ const t = corpus.find((x) => x.meta.slug === slug);
31
+ if (!t) throw new Error(`template ${slug} not in the corpus`);
32
+ return t;
33
+ };
34
+ const playbookOf = (t: WorkspaceYaml, name: string) => {
35
+ const pb = t.playbooks?.find((p) => p.name === name);
36
+ if (!pb) throw new Error(`playbook ${name} not in ${t.meta.slug}`);
37
+ return pb;
38
+ };
39
+ const ops = tpl("operations");
40
+ const crm = tpl("crm");
41
+
42
+ describe("Win a deal — one door to a client", () => {
43
+ const win = playbookOf(crm, "Win a deal");
44
+ const won = win.stages!.find((s) => s.key === "won")!;
45
+
46
+ it("the Won stage proposes the lead's move to converted, behind a person's gate", () => {
47
+ expect(won.subjectStatus).toBe("won");
48
+ expect(won.gate).toEqual({ kind: "human" });
49
+ expect(won.goal).toMatch(/propose moving the deal's lead to converted/);
50
+ expect(win.goalTemplate).toMatch(/propose moving the\s+deal's lead \(the company's lead, else the person's\) to converted/);
51
+ });
52
+
53
+ it("it no longer attaches the client role nor opens an engagement itself", () => {
54
+ expect(won.goal).not.toMatch(/attach the client role/);
55
+ expect(win.goalTemplate).toMatch(/Never attach\s+the client role and never open an engagement yourself/);
56
+ expect((win.expectedOutputs ?? []).map((o) => o.kind)).not.toContain("engagement");
57
+ });
58
+
59
+ it("no CRM process converts a lead on a booked meeting any more", () => {
60
+ const text = JSON.stringify(crm.playbooks);
61
+ expect(text).not.toMatch(/that same\s+step converts the lead/);
62
+ expect(text).not.toMatch(/not modeled yet/);
63
+ });
64
+ });
65
+
66
+ describe("Operations — the Clients space", () => {
67
+ it("references the pod-wide client role, with no body restated", () => {
68
+ const client = ops.profiles.find((p) => p.slug === "client")!;
69
+ expect(client).toEqual({ slug: "client", displayName: "Client", scope: "shared", profileKind: "role", properties: [] });
70
+ expect(ops.dependencies).toEqual(expect.arrayContaining([expect.objectContaining({ slug: "foundation", relation: "require" })]));
71
+ });
72
+
73
+ it("a Clients board groups the role on its lifecycle, in the sidebar", () => {
74
+ const view = ops.views!.find((v) => v.slug === "clients")!;
75
+ expect(view).toMatchObject({ name: "Clients", type: "kanban", scopeProfileSlug: "client", config: { groupByField: "clientStatus" } });
76
+ const lc = tpl("foundation").profiles.find((p) => p.slug === "client")!.lifecycle!;
77
+ expect(lc.property).toBe("clientStatus");
78
+ const sidebar = (ops.layout as { sidebarItems?: Array<{ viewName?: string }> }).sidebarItems ?? [];
79
+ expect(sidebar.map((i) => i.viewName)).toContain("Clients");
80
+ });
81
+
82
+ it("an engagement's client is whoever wears the client role (company or person), and both doors dedupe on it", () => {
83
+ const field = ops.profiles.find((p) => p.slug === "engagement")!.properties.find((p) => p.slug === "engagement-client")!;
84
+ expect(field).toMatchObject({ valueType: "entity_id", targetProfileSlug: "client" });
85
+ expect(tpl("foundation").profiles.find((p) => p.slug === "client")!.applicableKinds).toEqual(
86
+ expect.arrayContaining(["company", "person"])
87
+ );
88
+ // The edge exists to a company AND to a person.
89
+ const links = (ops.entityLinks ?? []).filter((l) => l.type === "engagement_for_client").map((l) => l.targetProfileSlug);
90
+ expect(links.sort()).toEqual(["company", "person"]);
91
+ // The 07:00 safety net is kept and dedupes on the same key.
92
+ const pickup = ops.automations!.find((a) => (a as { key?: string }).key === "operations-crm-handoff-pickup")!;
93
+ expect(pickup).toBeDefined();
94
+ const flow = JSON.stringify(pickup);
95
+ expect(flow).toContain('"dedupeBy":"engagement-client"');
96
+ expect(flow).toContain('{\\"engagement-client\\": \\"{{loop.item.id}}\\"}');
97
+ });
98
+
99
+ it("Onboard a client: subject the role, started on its attach, Welcome → engagement → a person's kick-off", () => {
100
+ const pb = playbookOf(ops, "Onboard a client");
101
+ expect(pb.subjectProfile).toEqual({ profileSlug: "client" });
102
+ expect(pb.activators).toEqual([{ on: "created", mode: "propose" }]);
103
+ expect(pb.params).toEqual([{ name: "client", type: "entity", label: "Client", required: true }]);
104
+ expect(pb.goalTemplate).toContain("{client}");
105
+ const stages = pb.stages!.map((s) => [s.key, s.subjectStatus ?? null, s.gate?.kind ?? null]);
106
+ expect(stages).toEqual([
107
+ ["welcome", "onboarding", null],
108
+ ["engagement", null, null],
109
+ ["kickoff", "active", "human"],
110
+ ]);
111
+ const engagement = pb.stages!.find((s) => s.key === "engagement")!;
112
+ expect(engagement.name).toBe("Open or reuse the engagement");
113
+ expect(engagement.expectedOutputs).toEqual([
114
+ { kind: "engagement", label: "Client engagement", relationToSubject: "engagement_for_client" },
115
+ ]);
116
+ expect(pb.stages!.find((s) => s.key === "kickoff")!.onFail).toEqual({ toStage: "engagement" });
117
+ // The statuses it moves are options of the client lifecycle.
118
+ const keys = tpl("foundation").profiles.find((p) => p.slug === "client")!.lifecycle!.options.map((o) => o.key);
119
+ expect(keys).toEqual(expect.arrayContaining(["onboarding", "active"]));
120
+ });
121
+
122
+ it("Operations produces the client; CRM no longer does", () => {
123
+ expect(ops.meta.intent!.produces!.map((p) => p.profile)).toContain("client");
124
+ expect(crm.meta.intent!.produces!.map((p) => p.profile)).not.toContain("client");
125
+ });
126
+ });
127
+
128
+ describe("the touched templates validate", () => {
129
+ for (const slug of ["foundation", "crm", "operations"]) {
130
+ it(`${slug}: zero errors`, () => {
131
+ expect(validateTemplate(tpl(slug), { corpus }).errors).toEqual([]);
132
+ });
133
+ }
134
+ });
@@ -179,6 +179,25 @@ describe("lifecycle declarations — the mandatory four", () => {
179
179
  }
180
180
  });
181
181
 
182
+ // Founder, 17 Nov 2026 (design 05ed390c): a new client starts at onboarding,
183
+ // an open step right before active. Every declaration of the ONE pod-wide
184
+ // role says so (foundation is the SSOT; grants restates the body), and the
185
+ // select offers it. Not person-only: "Onboard a client"'s Welcome stage
186
+ // moves the client there; the person's commitment is the kick-off → active.
187
+ it("client: onboarding is an open status right before active, on every declaration", () => {
188
+ for (const slug of ["foundation", "grants"]) {
189
+ const t = tpl(slug);
190
+ const lc = lifecycleOf(t, "client")!;
191
+ const keys = lc.options.map((o) => o.key);
192
+ expect(keys.indexOf("onboarding"), slug).toBe(keys.indexOf("active") - 1);
193
+ const onboarding = lc.options.find((o) => o.key === "onboarding")!;
194
+ expect(onboarding.category, slug).toBe("open");
195
+ expect(onboarding.humanOnly, slug).toBeUndefined();
196
+ const select = t.profiles.find((p) => p.slug === "client")!.properties.find((p) => p.slug === "clientStatus")!;
197
+ expect(select.enumValues, slug).toEqual(keys);
198
+ }
199
+ });
200
+
182
201
  it("the post Produce Content drives declares post-status", () => {
183
202
  const produce = tpl("content-os").playbooks!.find((p) => p.name === "Produce Content")!;
184
203
  expect(produce.subjectProfile).toEqual({ profileSlug: "post" });
@@ -79,14 +79,46 @@ describe("lifecycle presets — the converted lifecycles compile byte-identical"
79
79
  "brand-asset": { deprecated: "textMuted" },
80
80
  "brand-reference": { archived: "textMuted" },
81
81
  };
82
+ // The second intended change: a step ADDED to a converted lifecycle
83
+ // (`add:` in the YAML), inserted before an existing key. `onboarding` before
84
+ // `active` on the client (founder, 17 Nov 2026, design 05ed390c: a new
85
+ // client starts at onboarding).
86
+ const ADDED_SINCE: Record<string, { key: string; category: string; before: string }[]> = {
87
+ client: [{ key: "onboarding", category: "open", before: "active" }],
88
+ };
89
+ const withAdded = <T extends { key: string }>(list: T[], profile: string, make: (a: { key: string; category: string }) => T): T[] => {
90
+ const out = [...list];
91
+ for (const a of ADDED_SINCE[profile] ?? []) out.splice(out.findIndex((o) => o.key === a.before), 0, make(a));
92
+ return out;
93
+ };
82
94
  const withTone = (b: (typeof before.profiles)[number]) => ({
83
95
  ...b.lifecycle,
84
- options: b.lifecycle.options.map((o) => {
85
- const tone = TONE_SINCE[b.profile]?.[o.key];
86
- if (!tone) return o;
87
- const { key, category, ...rest } = o;
88
- return { key, category, tone, ...rest };
89
- }),
96
+ options: withAdded(
97
+ b.lifecycle.options.map((o) => {
98
+ const tone = TONE_SINCE[b.profile]?.[o.key];
99
+ if (!tone) return o;
100
+ const { key, category, ...rest } = o;
101
+ return { key, category, tone, ...rest };
102
+ }),
103
+ b.profile,
104
+ (a) => ({ key: a.key, category: a.category }) as (typeof b.lifecycle.options)[number]
105
+ ),
106
+ });
107
+ const withAddedEnum = (b: (typeof before.profiles)[number]) =>
108
+ ADDED_SINCE[b.profile]
109
+ ? {
110
+ ...b.property,
111
+ enumValues: withAdded(
112
+ (b.property.enumValues ?? []).map((key) => ({ key })),
113
+ b.profile,
114
+ (a) => ({ key: a.key })
115
+ ).map((o) => o.key),
116
+ }
117
+ : b.property;
118
+
119
+ it("non-vacuity: the added step lands where it is declared (client: onboarding before active)", () => {
120
+ const keys = profileOf(compiled.get("foundation")!, "client").lifecycle!.options.map((o) => o.key);
121
+ expect(keys).toEqual(["prospect", "onboarding", "active", "paused", "former", "churned"]);
90
122
  });
91
123
 
92
124
  for (const b of before.profiles) {
@@ -99,7 +131,7 @@ describe("lifecycle presets — the converted lifecycles compile byte-identical"
99
131
  JSON.stringify(
100
132
  profile.properties.find((p) => p.slug === b.property.slug)
101
133
  )
102
- ).toBe(JSON.stringify(b.property));
134
+ ).toBe(JSON.stringify(withAddedEnum(b)));
103
135
  });
104
136
  }
105
137
  });