@synap-core/workspace-templates 0.45.1 → 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.
Files changed (37) hide show
  1. package/README.md +1 -1
  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/vercel.capability.json +8 -1
  18. package/dist/index.js +598 -43
  19. package/dist/index.js.map +1 -1
  20. package/package.json +1 -1
  21. package/src/agency-os.yaml +1 -1
  22. package/src/builder-dev-executor-tier.template.test.ts +40 -6
  23. package/src/builder-dev-playbooks.template.test.ts +23 -0
  24. package/src/builder.yaml +54 -13
  25. package/src/content-os.piece-model.template.test.ts +7 -0
  26. package/src/content-os.yaml +9 -0
  27. package/src/crm.yaml +34 -19
  28. package/src/foundation.yaml +22 -10
  29. package/src/grants.yaml +4 -0
  30. package/src/intent.test.ts +4 -2
  31. package/src/lead-automations.test.ts +93 -0
  32. package/src/lead-becomes-client.template.test.ts +134 -0
  33. package/src/lifecycle-declarations.test.ts +19 -0
  34. package/src/lifecycle-presets.test.ts +39 -7
  35. package/src/operations.yaml +147 -16
  36. package/src/ship-a-change.template.test.ts +19 -0
  37. package/src/templates.ts +216 -24
@@ -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
  });
@@ -1,13 +1,23 @@
1
1
  # Operations workspace template — client-delivery domain.
2
- # How client work gets delivered end to end: the engagements you're running, the
3
- # deliverables due inside them, and the contracts that govern them. Consumes the `crm` domain, provides `operations`.
2
+ # How client work gets delivered end to end: the clients you serve, the
3
+ # engagements you're running, the deliverables due inside them, and the
4
+ # contracts that govern them. Consumes the `crm` domain, provides `operations`.
5
+ #
6
+ # The Clients space (founder, 17 Nov 2026, design 05ed390c). A lead that signs
7
+ # in the CRM becomes a client here: a person moves the lead to `converted`
8
+ # (= signed), the CRM automation `lead-converted-becomes-client` attaches the
9
+ # pod-wide `client` role (handoffStatus handed_off, handoffDestination
10
+ # Operations), and "Onboard a client" below starts on that role: Welcome
11
+ # (clientStatus onboarding) → open or reuse the engagement → kick-off confirmed
12
+ # by a person (active). The engagement then runs "Deliver a client engagement".
13
+ # The 07:00 "Pick up handed-off clients" stays as a safety net.
4
14
  # Validated against types.ts at build time.
5
15
 
6
16
  meta:
7
17
  slug: operations
8
18
  domain: company
9
19
  name: Operations
10
- description: "Deliver client work end to end — the engagements you're running, the deliverables due inside them, and the contracts that govern them. Won deals from CRM hand off into engagements here."
20
+ description: "Deliver client work end to end — the clients you serve, the engagements you're running, the deliverables due inside them, and the contracts that govern them. A lead that signs in the CRM becomes a client here, is onboarded, and its work runs as an engagement."
11
21
  icon: briefcase
12
22
  color: "#0F766E"
13
23
  tags: [operations, delivery, clients, engagements]
@@ -36,9 +46,12 @@ meta:
36
46
  label: Delivery
37
47
  # The ONE primary output (One model decision 3): a delivered engagement (Deliver a client engagement).
38
48
  primary: engagement
49
+ # `client` joined on 17 Nov 2026: Operations is the Clients space (design
50
+ # 05ed390c); the client's lifecycle (onboarding → active …) is worked here.
39
51
  produces:
40
52
  - profile: engagement
41
53
  - profile: deliverable
54
+ - profile: client
42
55
 
43
56
  workspace:
44
57
  name: Operations
@@ -64,9 +77,19 @@ dependencies:
64
77
  - slug: foundation
65
78
  kind: workspace
66
79
  relation: require
67
- reason: "Provides the pod-wide `client` role the daily client-briefing automation queries."
80
+ reason: "Provides the pod-wide `client` role this space onboards and serves (Clients board, Onboard a client) and its automations query."
68
81
 
69
82
  profiles:
83
+ # The pod-wide `client` role, REFERENCED (foundation's SSOT body; crm.yaml
84
+ # declares the same reference). Declaring it grants this space the role, so
85
+ # the Clients board, "Onboard a client" and the engagement's client field
86
+ # see it (founder, 17 Nov 2026, design 05ed390c). No extra properties: the
87
+ # handoff fields are the CRM's overlay.
88
+ - slug: client
89
+ displayName: Client
90
+ scope: shared
91
+ profileKind: role
92
+ properties: []
70
93
  - slug: engagement
71
94
  displayName: Engagement
72
95
  icon: briefcase
@@ -88,10 +111,15 @@ profiles:
88
111
  valueType: string
89
112
  inputType: select
90
113
  constraints: { defaultValue: proposed }
114
+ # The client the work is for: whoever wears the `client` role, a company
115
+ # or a person (founder, 17 Nov 2026: a solo client like Claire is the
116
+ # client herself). It is also the dedupe key of every door that opens an
117
+ # engagement for a client ("Onboard a client", "Pick up handed-off
118
+ # clients"): one engagement per client, whichever door runs first.
91
119
  - slug: engagement-client
92
120
  label: Client
93
121
  valueType: entity_id
94
- targetProfileSlug: company
122
+ targetProfileSlug: client
95
123
  inputType: entity_select
96
124
  - slug: engagement-start
97
125
  label: Start Date
@@ -301,6 +329,15 @@ entityLinks:
301
329
 
302
330
  # CURATED views — the delivery motion, not one per profile
303
331
  views:
332
+ # The flow board of "Onboard a client": the client role's lifecycle, a drag
333
+ # is the governed status move (onboarding → active is a person's call there).
334
+ - name: Clients
335
+ slug: clients
336
+ type: kanban
337
+ scopeProfileSlug: client
338
+ config:
339
+ groupByField: clientStatus
340
+ description: "Clients on a board by status, from onboarding to active."
304
341
  - name: Engagements
305
342
  slug: engagements
306
343
  type: kanban
@@ -372,6 +409,10 @@ layout:
372
409
  defaultView: Engagements
373
410
  defaultApp: null
374
411
  sidebarItems:
412
+ - kind: view
413
+ viewName: Clients
414
+ label: Clients
415
+ icon: users
375
416
  - kind: view
376
417
  viewName: Engagements
377
418
  label: Engagements
@@ -670,14 +711,24 @@ automations:
670
711
  - { id: e-resolve-post, source: resolve-team, target: post-recap }
671
712
 
672
713
  # ══════════════════════════════════════════════════════════════════════════
673
- # CRM → Operations HANDOFF PICKUP
714
+ # CRM → Operations HANDOFF PICKUP — the SAFETY NET
715
+ #
716
+ # Since 17 Nov 2026 (design 05ed390c) a client arrives through ONE door: a
717
+ # person moves the lead to `converted` (= signed), the CRM automation
718
+ # `lead-converted-becomes-client` attaches the pod-wide `client` role with
719
+ # `handoffStatus: handed_off`, and "Onboard a client" (below) starts on that
720
+ # attach and opens or reuses the engagement. This daily job stays as the
721
+ # safety net (founder default 6): a client whose onboarding never started
722
+ # (a declined run, an attach before the cross-space delivery landed, a client
723
+ # attached by another door such as The Arch's "Win and hand off") still gets
724
+ # its delivery shell — a `proposed` engagement plus a `draft` contract — at
725
+ # most 24 h late.
674
726
  #
675
- # The other half of CRM's "Win a deal" (and The Arch's "Win and hand off",
676
- # moved there from business-developer 2026-10-12). Both end by attaching the pod-wide `client` role with `handoffStatus`; nothing on the
677
- # delivery side ever picked it up, so a won deal became a client and then
678
- # nothing happened. This automation is that pickup: once a day it finds
679
- # clients marked ready/handed_off that have NO engagement yet, and opens the
680
- # delivery shell — a `proposed` engagement plus a `draft` contract.
727
+ # ONE DEDUPE KEY for every door: an engagement belongs to a client through
728
+ # its `engagement-client` property (plus the `engagement_for_client` edge).
729
+ # "Onboard a client" sets both on the engagement it opens and reuses the one
730
+ # this job opened; this job skips a client that already has one. Whichever
731
+ # door runs first, a client gets one engagement.
681
732
  #
682
733
  # WHY THE SHARED `client` SLUG MATTERS: this reads foundation's pod-wide
683
734
  # `client` role. When the CRM wrote a workspace-scoped `crm-client` instead,
@@ -724,10 +775,12 @@ automations:
724
775
  - key: operations-crm-handoff-pickup
725
776
  name: Pick up handed-off clients
726
777
  description: >-
727
- Daily. Finds pod-wide clients the CRM marked ready or handed off that have
728
- no engagement yet, and opens the delivery shell for them — a proposed
729
- engagement plus a draft contract, both linked to the client. Deduped per
730
- client, so it is safe to re-run.
778
+ Daily safety net. Finds pod-wide clients the CRM marked ready or handed
779
+ off that have no engagement yet (Onboard a client normally opens it), and
780
+ opens the delivery shell for them — a proposed engagement plus a draft
781
+ contract, both linked to the client. Deduped per client on the
782
+ engagement's client, the key Onboard a client uses too, so it is safe to
783
+ re-run.
731
784
  triggerType: cron
732
785
  triggerConfig:
733
786
  expression: "0 7 * * *"
@@ -924,6 +977,84 @@ automations:
924
977
  - { id: h-contract-link, source: create-contract, target: link-contract }
925
978
 
926
979
  playbooks:
980
+ # ── Onboard a client — the Clients space's process ───────────────────────
981
+ # Founder decision 17 Nov 2026 (design 05ed390c, defaults approved). Its
982
+ # subject is the pod-wide `client` ROLE, whose lifecycle foundation declares
983
+ # (clientStatus, with `onboarding` before `active`). It starts when the role
984
+ # is attached (`on: created` on a role = the attach; `mode: propose`, so a
985
+ # person approves the run): normally by the CRM automation
986
+ # `lead-converted-becomes-client`, once a person moved the lead to converted
987
+ # (= signed). An attach made under the CRM space reaches this Operations rule
988
+ # only once the backend delivers a pod-wide role attach to every space of the
989
+ # entity (wave W1); until then the 07:00 safety net opens the engagement.
990
+ # Engagement dedupe: `engagement-client` (see the pickup automation above).
991
+ # Sending the welcome goes through the pod's one send door (a proposed
992
+ # message a person approves); the commitment, kick-off done → active, is a
993
+ # person's gate.
994
+ - name: Onboard a client
995
+ description: Welcome a new client, open or reuse their engagement, and have a person confirm the kick-off — the client moves from onboarding to active.
996
+ goalTemplate: >-
997
+ Onboard this new client ({client}); each stage moves the client's
998
+ status. WELCOME: read how they became a client — the converted lead,
999
+ the won deal and its proposal, every message with them, and the
1000
+ handoff notes on the client role — and write a short brief in the
1001
+ client's notes: what they bought, who signs, and what they expect
1002
+ first. Draft one welcome message to them as a proposed message in
1003
+ their channel, through the pod's send door (messaging.send): a person
1004
+ approves it before it is sent; never send it another way.
1005
+ ENGAGEMENT: find the engagement whose client is this client (the daily
1006
+ pick-up may already have opened one) and reuse it. Only when there is
1007
+ none, open one at proposed with its client set to this client and its
1008
+ scope and value from the won deal, and link it to the client. Never
1009
+ open a second one. Opening it starts "Deliver a client engagement".
1010
+ KICK-OFF: propose the kick-off (its date, who attends, what is decided
1011
+ there) as the engagement's next step; a person confirms the kick-off
1012
+ happened, which makes the client active.
1013
+ subjectProfile:
1014
+ profileSlug: client
1015
+ activators:
1016
+ - { on: created, mode: propose }
1017
+ params:
1018
+ - { name: client, type: entity, label: Client, required: true }
1019
+ executor: is-agent
1020
+ status: active
1021
+ tools: [list_records, send_message]
1022
+ metadata:
1023
+ lineage: { method: "Agency client onboarding: welcome, engagement set-up, kick-off" }
1024
+ stages:
1025
+ - key: welcome
1026
+ name: Welcome
1027
+ category: planned
1028
+ subjectStatus: onboarding
1029
+ goal: Write the client brief in the client's notes and propose a welcome message in their channel for a person to approve.
1030
+ criteria:
1031
+ - key: welcome-brief
1032
+ statement: The client's notes hold a short brief — what they bought, who signs, and what they expect first.
1033
+ check: { kind: judge }
1034
+ - key: welcome-message-proposed
1035
+ statement: A welcome message to the client is proposed in their channel for a person to approve.
1036
+ check: { kind: judge }
1037
+ - key: engagement
1038
+ name: Open or reuse the engagement
1039
+ category: started
1040
+ goal: Reuse the engagement whose client is this client; only when none exists, open one at proposed with its client set and link it to the client.
1041
+ expectedOutputs:
1042
+ - { kind: engagement, label: Client engagement, relationToSubject: engagement_for_client }
1043
+ criteria:
1044
+ - key: engagement-one-per-client
1045
+ statement: Exactly one engagement names this client as its client.
1046
+ check: { kind: judge }
1047
+ - key: engagement-linked
1048
+ statement: That engagement is linked to the client.
1049
+ check: { kind: judge }
1050
+ - key: kickoff
1051
+ name: Kick-off confirmed
1052
+ category: completed
1053
+ subjectStatus: active
1054
+ goal: A person confirms the kick-off happened; the client becomes active.
1055
+ gate: { kind: human }
1056
+ onFail: { toStage: engagement }
1057
+
927
1058
  - name: Deliver a client engagement
928
1059
  description: Run one client engagement from kick-off to close — scope, contract, deliverables, final review and the closing invoice — with a person approving the start and the close.
929
1060
  goalTemplate: >-
@@ -33,6 +33,8 @@ const HERE = dirname(fileURLToPath(import.meta.url));
33
33
  const builder = getWorkspaceTemplate("builder-workspace")!;
34
34
  const pb = builder.playbooks!.find((p) => p.name === "Ship a change")! as unknown as {
35
35
  subjectProfile: { profileSlug: string; statusProperty?: string };
36
+ params?: { name: string; required?: boolean }[];
37
+ goalTemplate: string;
36
38
  activators?: { on: string; status?: string; mode?: string }[];
37
39
  stages: {
38
40
  key: string;
@@ -176,3 +178,20 @@ describe("github-read — read-only, bring your own token", () => {
176
178
  for (const t of cap.tools) expect(refs.has(t.credentialRef), t.name).toBe(true);
177
179
  });
178
180
  });
181
+
182
+ describe("Ship a change - binds with no feature (structural guard P4 d)", () => {
183
+ it("declares the feature param optional, so a session can follow it with no devplane_feature", () => {
184
+ const param = pb.params?.find((p) => p.name === "feature");
185
+ expect(param).toBeDefined();
186
+ expect(param!.required).not.toBe(true);
187
+ });
188
+
189
+ it("every other declared param stays optional too (nothing else can owe a person a card)", () => {
190
+ expect((pb.params ?? []).filter((p) => p.required === true)).toEqual([]);
191
+ });
192
+
193
+ it("the goal reads without a feature: the {feature} reference is a clause, not the subject of the sentence", () => {
194
+ expect(pb.goalTemplate).toContain("Feature, when one is bound: {feature}.");
195
+ expect(pb.goalTemplate).not.toContain("({feature})");
196
+ });
197
+ });