@synap-core/workspace-templates 0.70.0 → 0.72.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 (30) hide show
  1. package/README.md +10 -3
  2. package/automations/github-pr-events.automation.json +1 -1
  3. package/automations/ship-a-change-checks-green.automation.json +1 -1
  4. package/automations/ship-a-change-checks-red.automation.json +1 -1
  5. package/automations/ship-a-change-deployed.automation.json +1 -1
  6. package/automations/ship-a-change-pr-merged.automation.json +1 -1
  7. package/automations/ship-a-change-pr-opened.automation.json +1 -1
  8. package/capabilities/apify-linkedin-profiles.capability.json +45 -0
  9. package/capabilities/apify-social-post-capture.capability.json +57 -0
  10. package/capabilities/apify.capability.json +2 -50
  11. package/capabilities/github-issues.capability.json +176 -0
  12. package/capabilities/stripe-payments.capability.json +176 -0
  13. package/capabilities/test-api-3.capability.json +104 -0
  14. package/capabilities/unipile-linkedin.capability.json +5 -3
  15. package/dist/index.js +1095 -41
  16. package/dist/index.js.map +1 -1
  17. package/package.json +1 -1
  18. package/skills/app-factory-research/SKILL.md +1 -1
  19. package/src/apify-social-reader.test.ts +8 -3
  20. package/src/builder-work-views.template.test.ts +111 -0
  21. package/src/builder.yaml +540 -42
  22. package/src/content-os.piece-model.template.test.ts +8 -6
  23. package/src/content-os.yaml +7 -0
  24. package/src/crm.yaml +4 -3
  25. package/src/design-pins.template.test.ts +143 -0
  26. package/src/design-to-implementation.template.test.ts +16 -3
  27. package/src/dev-flow-change.template.test.ts +192 -0
  28. package/src/retired-names.test.ts +68 -0
  29. package/src/templates.ts +896 -37
  30. package/automations/ship-a-change-deployed.catalog.json +0 -18
@@ -153,12 +153,14 @@ const inspirationProps = new Map(
153
153
  );
154
154
 
155
155
  const HERE = dirname(fileURLToPath(import.meta.url));
156
- const apify = JSON.parse(
157
- readFileSync(join(HERE, "../capabilities/apify.capability.json"), "utf8")
158
- );
159
- const reader = (
160
- apify.spec.skills as Array<{ name: string; code?: string }>
161
- ).find((s) => s.name === "capture_social_post")!;
156
+ // `capture_social_post` is the "Social post capture" add-on (its own manifest), no longer a skill of apify.capability.json.
157
+ const skillsOf = (file: string) =>
158
+ JSON.parse(readFileSync(join(HERE, "../capabilities", file), "utf8")).spec
159
+ .skills as Array<{ name: string; code?: string }>;
160
+ const reader = [
161
+ ...skillsOf("apify.capability.json"),
162
+ ...skillsOf("apify-social-post-capture.capability.json"),
163
+ ].find((s) => s.name === "capture_social_post")!;
162
164
  const AsyncFunction = Object.getPrototypeOf(async () => {}).constructor as new (
163
165
  ...args: string[]
164
166
  ) => (...a: unknown[]) => Promise<unknown>;
@@ -424,6 +424,12 @@ profiles:
424
424
  inputType: text
425
425
  placeholder: "https://..."
426
426
  constraints: { format: url }
427
+ # The first comment on the published post (e.g., LinkedIn link in first comment)
428
+ - slug: post-first-comment
429
+ label: First Comment
430
+ valueType: string
431
+ inputType: textarea
432
+ placeholder: "First comment text (e.g., LinkedIn link in first comment)"
427
433
  # The publishing ACCOUNT (a `platform` entity) the post goes out on —
428
434
  # distinct from `post-platform`, the network label above.
429
435
  - slug: post-account
@@ -1337,6 +1343,7 @@ profiles:
1337
1343
  color: blue
1338
1344
  description: "A piece of work: its body is a document (an essay, a post, a chapter), its sources are linked (inspirations, ideas, earlier pieces), and its outputs (posts, a newsletter issue, a site essay) are derived from it. A video or carousel piece also carries its brief, storyboard, project zip, render and key-frame stills."
1339
1345
  semanticSlug: content.composition
1346
+ entityScope: workspace
1340
1347
  # How it renders (entity rendering, decision 8): @synap-core/types/presentation.
1341
1348
  presentation:
1342
1349
  family: document
package/src/crm.yaml CHANGED
@@ -2652,7 +2652,7 @@ playbooks:
2652
2652
  space's workspaceId, type bento). When the space has none, stop and say
2653
2653
  so: never create another dashboard. READ FIRST: what already sits on
2654
2654
  Health (its config.blocks: each widget tile names a cell by widgetType)
2655
- and the space's cells (synap_list_widgets); when a tile already answers
2655
+ and the space's cells (synap_list_cells); when a tile already answers
2656
2656
  the question, say which one and stop. DATA: decide where each number
2657
2657
  comes from. A cell reads the pod ONLY through the cell bridge, at
2658
2658
  render time: window.synap.query(op, params), with an op of the bridge
@@ -2660,8 +2660,9 @@ playbooks:
2660
2660
  lifecycle.board, flow.of, lifecycle.throughput, attention.needsYou,
2661
2661
  attention.count, sessions.list, lifecycle.home, lifecycle.moving,
2662
2662
  documents.get, lens.page, sessions.get, playbook.process,
2663
- playbook.scorecard, project.pillars) and only that op's params; the
2664
- host stamps the space, so never put a workspaceId, a token, a pod URL
2663
+ playbook.scorecard, project.pillars, views.get, views.execute,
2664
+ profiles.get, propertyDefs.list, lifecycle.get, graph.of) and only that
2665
+ op's params; the host stamps the space, so never put a workspaceId, a token, a pod URL
2665
2666
  or a fetch in the page. What the bridge reads stays live: query it in
2666
2667
  the page, never
2667
2668
  paste its rows. What it cannot read yet (messages, replies, sends: the
@@ -0,0 +1,143 @@
1
+ /**
2
+ * The board's pins in the design playbooks (plan 48854969 §10.3): "Design to
3
+ * implementation" and "Review a UI component" read the open pins on their
4
+ * subject, treat a stale one as stale, reply in each pin's thread, and never
5
+ * resolve one (agents propose, people resolve: backend comments.ts refuses an
6
+ * agent's resolve).
7
+ *
8
+ * What this guards:
9
+ * 1. each playbook's run text reads the pins through the agent read door,
10
+ * `synap_get_thread_context` with `object` + `state: open` (backend#1316),
11
+ * and replies through `synap_post_message` with `comment.replyTo`;
12
+ * 2. the door it names takes those arguments: read from the backend's MCP
13
+ * tool manifest when synap-backend is a sibling checkout (skipped
14
+ * otherwise, and said so);
15
+ * 3. the stale rule compares `locator.contentVersion` with the value the
16
+ * board stamps (lane pins-app, apps/ui-gallery pinModel.ts isStale): the
17
+ * component's `source-hash` property (checked to exist on the kind), the
18
+ * design entity's own `updatedAt` (an entity column, not a property, so
19
+ * only the text is checked);
20
+ * 4. no text tells the agent to resolve a pin, and the person's gate says
21
+ * the person resolves them;
22
+ * 5. the stage that reads the pins owes a reply to every open pin: a
23
+ * criterion on Review a UI component; on Design to implementation, which
24
+ * sits at the pod's 12-criteria cap (build.mjs refuses a 13th), the
25
+ * stage goal says it.
26
+ *
27
+ * Not covered: whether the pod run can call the doors (it cannot: the run has
28
+ * no comment tool, a known gap in run-tools.guard), and the board's stamping.
29
+ */
30
+ import { existsSync, readFileSync } from "node:fs";
31
+ import { dirname, join } from "node:path";
32
+ import { fileURLToPath } from "node:url";
33
+ import { describe, expect, it } from "vitest";
34
+ import { getWorkspaceTemplate } from "./templates.js";
35
+
36
+ const builder = getWorkspaceTemplate("builder-workspace")!;
37
+ type Stage = { key: string; goal?: string; criteria?: { key: string }[] };
38
+ type Pb = { name: string; goalTemplate: string; stages: Stage[] };
39
+ const playbook = (name: string) => (builder.playbooks as unknown as Pb[]).find((p) => p.name === name)!;
40
+ const props = (slug: string) => new Set(builder.profiles.find((p) => p.slug === slug)!.properties.map((p) => p.slug));
41
+ const textOf = (p: Pb) => [p.goalTemplate, ...p.stages.map((s) => s.goal ?? "")].join("\n");
42
+
43
+ /**
44
+ * What the board stamps into a pin's contentVersion: the ui-design entity's
45
+ * `updatedAt` (ISO), a component record's `source-hash` property.
46
+ */
47
+ const CASES = [
48
+ { name: "Design to implementation", subject: "ui-design", version: "updatedAt", isProperty: false, readStage: "generate", criterion: null, gate: "review" },
49
+ { name: "Review a UI component", subject: "ui-component", version: "source-hash", isProperty: true, readStage: "critique", criterion: "critique-pins-read", gate: "approve" },
50
+ ] as const;
51
+
52
+ describe("design playbooks read the board's pins", () => {
53
+ for (const c of CASES) {
54
+ describe(c.name, () => {
55
+ const p = playbook(c.name);
56
+
57
+ it("reads the open pins through the agent read door and replies in each thread", () => {
58
+ expect(p, c.name).toBeDefined();
59
+ expect(p.goalTemplate).toMatch(/synap_get_thread_context\s*\{object: \{type: entity, id: <the [a-z]+>\},\s*state: open\}/);
60
+ expect(p.goalTemplate).toContain("anchor.locator");
61
+ expect(textOf(p)).toMatch(/synap_post_message, comment\.replyTo/);
62
+ });
63
+
64
+ it("calls a pin stale against the value the board stamps", () => {
65
+ if (c.isProperty) expect(props(c.subject).has(c.version), `${c.subject}.${c.version}`).toBe(true);
66
+ else expect(props(c.subject).has(c.version), `${c.version} is an entity column, never a property`).toBe(false);
67
+ const rule = p.goalTemplate.match(/contentVersion\s+is not ([^.]*)\./);
68
+ expect(rule, "the goal states the stale rule").not.toBeNull();
69
+ expect(rule![1]).toContain(c.version);
70
+ const stage = p.stages.find((s) => s.key === c.readStage)!;
71
+ expect(stage.goal).toContain(c.version);
72
+ });
73
+
74
+ it("never has the agent resolve a pin; the person does at the gate", () => {
75
+ const text = textOf(p);
76
+ expect(text).not.toMatch(/(?<!never )\bresolve (?:each|every|the|a) pin/i);
77
+ expect(text).toMatch(/never resolve a pin/);
78
+ const gate = p.stages.find((s) => s.key === c.gate)!;
79
+ expect(gate.goal).toMatch(/person resolves? (?:it|them|the pins)/i);
80
+ });
81
+
82
+ it("the reading stage owes a reply to every open pin", () => {
83
+ const stage = p.stages.find((s) => s.key === c.readStage)!;
84
+ expect(stage.goal).toContain("synap_get_thread_context");
85
+ if (c.criterion) expect((stage.criteria ?? []).map((k) => k.key)).toContain(c.criterion);
86
+ else expect(stage.goal).toMatch(/Reply in each pin's thread/);
87
+ });
88
+ });
89
+ }
90
+
91
+ it("self-check: the resolve scan catches an imperative and spares the refusal", () => {
92
+ const re = /(?<!never )\bresolve (?:each|every|the|a) pin/i;
93
+ expect(re.test("Apply it, then resolve each pin you applied.")).toBe(true);
94
+ expect(re.test("never resolve a pin: the person does")).toBe(false);
95
+ });
96
+ });
97
+
98
+ const MANIFEST = join(
99
+ dirname(fileURLToPath(import.meta.url)),
100
+ "../../../../synap-backend/packages/api/src/routers/mcp/tools/mcp-tools.manifest.json"
101
+ );
102
+
103
+ describe.skipIf(!existsSync(MANIFEST))("the doors the stages name take those arguments (backend MCP manifest)", () => {
104
+ const raw = existsSync(MANIFEST) ? JSON.parse(readFileSync(MANIFEST, "utf8")) : [];
105
+ const tools = (Array.isArray(raw) ? raw : raw.tools) as { name: string; inputSchema?: { properties?: Record<string, { type?: string; enum?: string[]; properties?: Record<string, unknown> }> } }[];
106
+ const tool = (name: string) => tools.find((t) => t.name === name);
107
+
108
+ it("synap_get_thread_context reads an object's threads by state", () => {
109
+ // The manifest declares `object` as an object and spells its {type, id}
110
+ // in the description (backend#1316), so the keys are not checked here.
111
+ const schema = tool("synap_get_thread_context")?.inputSchema?.properties ?? {};
112
+ expect(schema.object?.type).toBe("object");
113
+ expect(schema.state?.enum).toEqual(expect.arrayContaining(["open", "resolved"]));
114
+ });
115
+
116
+ it("synap_post_message replies in a comment thread", () => {
117
+ const schema = tool("synap_post_message")?.inputSchema?.properties ?? {};
118
+ expect(Object.keys(schema.comment?.properties ?? {})).toContain("replyTo");
119
+ });
120
+ });
121
+
122
+ /**
123
+ * Plan §10.4 (founder: the automatic start is back on): a new ui-design
124
+ * PROPOSES a run of Design to implementation, never runs one, and the
125
+ * variants Generate creates (they carry the request's variant-group) do not.
126
+ * Not covered: the pod honouring `unless` on a created worker (backend
127
+ * jobs playbook-run.ts skippedByUnless, read, not run here).
128
+ */
129
+ describe("Design to implementation starts itself on a new design, as a proposal", () => {
130
+ type Activator = { on: string; mode?: string; unless?: { property: string; present: boolean } };
131
+ const p = playbook("Design to implementation") as unknown as Pb & { activators?: Activator[] };
132
+
133
+ it("declares a created activator in propose mode that skips the variants", () => {
134
+ const created = (p.activators ?? []).filter((a) => a.on === "created");
135
+ expect(created).toEqual([{ on: "created", mode: "propose", unless: { property: "variant-group", present: true } }]);
136
+ expect(props("ui-design").has("variant-group")).toBe(true);
137
+ });
138
+
139
+ it("no activator of it runs without a person", () => {
140
+ expect((p.activators ?? []).length).toBeGreaterThanOrEqual(2);
141
+ for (const a of p.activators ?? []) expect(a.mode, a.on).toBe("propose");
142
+ });
143
+ });
@@ -81,7 +81,15 @@ describe("Design to implementation — the design loop", () => {
81
81
  expect(critique.onFail).toEqual({ toStage: "generate" });
82
82
  });
83
83
 
84
- it("no process that produces its own subject kind starts on `created` (corpus-wide)", () => {
84
+ // A process that creates things of its own subject kind and starts on
85
+ // `created` would start itself on each of them. It may start on `created`
86
+ // only with an `unless` on a property every thing it creates already
87
+ // carries (Design to implementation: its variants carry the request's
88
+ // variant-group, plan §10.4). What is checked: the property is named in
89
+ // the process beyond the filter itself (a name check: it does not prove
90
+ // the process writes the property onto what it creates). An activator with
91
+ // no `unless`, or one on a property the process never names, fails.
92
+ it("no process that produces its own subject kind starts on `created` unfiltered (corpus-wide)", () => {
85
93
  const selfProducing: string[] = [];
86
94
  const offenders: string[] = [];
87
95
  for (const t of Object.values(WORKSPACE_TEMPLATES))
@@ -95,8 +103,13 @@ describe("Design to implementation — the design loop", () => {
95
103
  ];
96
104
  if (!subject || !outs.some((o) => o.kind === subject)) continue;
97
105
  selfProducing.push(`${t.meta.slug}:${p.name}`);
98
- if ((p.activators ?? []).some((a) => a.on === "created"))
99
- offenders.push(`${t.meta.slug}:${p.name}`);
106
+ const text = JSON.stringify(p);
107
+ for (const a of (p.activators ?? []) as { on: string; unless?: { property: string } }[]) {
108
+ if (a.on !== "created") continue;
109
+ const prop = a.unless?.property;
110
+ const stamped = !!prop && (text.match(new RegExp(`\\b${prop}\\b`, "g")) ?? []).length >= 2;
111
+ if (!stamped) offenders.push(`${t.meta.slug}:${p.name}`);
112
+ }
100
113
  }
101
114
  expect(selfProducing).toContain(
102
115
  "builder-workspace:Design to implementation"
@@ -0,0 +1,192 @@
1
+ /**
2
+ * The dev flow as catalog content (founder decision, 27 Nov 2026, audit
3
+ * dec915cb): Builder's `change` kind (one pull request), the automation "A
4
+ * pull request moves its change" (GitHub's events → the change's status,
5
+ * generic doors only), the view "Changes by state", the playbook "Land a
6
+ * change" that follows the change, and Ship a change's holds on it.
7
+ *
8
+ * What this guards:
9
+ * 1. the change's lifecycle is the one the flow writes: every status the
10
+ * automation sets (literal or a select's value) and every stage status of
11
+ * Land a change is an option of it; the dedupe key and every property the
12
+ * flow writes are properties of the kind;
13
+ * 2. the automation passes the shipped flow validator, declares its inbound
14
+ * source by NAME (portable, never one pod's subscription id), and finds
15
+ * the change by prRef + headSha through a JSON-STRING filter (an object
16
+ * filter is read without templating by the pod's query step);
17
+ * 3. REACHABILITY: no checks verdict reaches a status write except through
18
+ * the guard that the change is waiting on its checks, and no pull request
19
+ * event reaches the create/move except through "its base is the default
20
+ * branch" (drop the gate, then no write may stay reachable);
21
+ * 4. Land a change binds the kind, its first stage writes no status (a birth
22
+ * writes the first stage's status: a change further along must not be
23
+ * pulled back), and it is a draft with no activators;
24
+ * 5. Ship a change waits on the change with an entity hold.
25
+ *
26
+ * Not covered: a pod running it against GitHub's real payloads (NEEDS-DOGFOOD).
27
+ */
28
+ import { describe, expect, it } from "vitest";
29
+ import { readYamlTemplates } from "./generate.mjs";
30
+ import { validateFlowDefinition } from "./validate-flow.js";
31
+ import { validateTemplate } from "./validate.js";
32
+ import { webhookSourceProblems } from "../scripts/catalog-lib.mjs";
33
+ import type { WorkspaceYaml } from "./types.js";
34
+
35
+ type FlowNode = { id: string; type: string; data: Record<string, any> };
36
+ type FlowEdge = { id: string; source: string; target: string; sourceHandle?: string };
37
+
38
+ const corpus = readYamlTemplates().map((t) => t.data as WorkspaceYaml);
39
+ const builder = readYamlTemplates().find((t) => t.file === "builder.yaml")!.data as any;
40
+ const kind = builder.profiles.find((p: any) => p.slug === "change");
41
+ const options: string[] = kind.lifecycle.options.map((o: any) => o.key);
42
+ const propertySlugs = new Set<string>(kind.properties.map((p: any) => p.slug));
43
+ const automation = (builder.automations ?? []).find((a: any) => a.key === "pull-request-moves-change");
44
+ const nodes: FlowNode[] = automation.flow.nodes;
45
+ const edges: FlowEdge[] = automation.flow.edges;
46
+ const node = (id: string) => nodes.find((n) => n.id === id)!;
47
+ const writes = nodes.filter(
48
+ (n) => n.type === "output" && ["entity_create", "entity_update"].includes(n.data.outputType)
49
+ );
50
+
51
+ /** Node ids reachable from the trigger when `blocked` nodes stop the walk. */
52
+ function reachable(blocked: Set<string>): Set<string> {
53
+ const seen = new Set<string>();
54
+ const queue = nodes.filter((n) => n.type === "trigger").map((n) => n.id);
55
+ while (queue.length) {
56
+ const id = queue.shift()!;
57
+ if (seen.has(id) || blocked.has(id)) continue;
58
+ seen.add(id);
59
+ queue.push(...edges.filter((e) => e.source === id).map((e) => e.target));
60
+ }
61
+ return seen;
62
+ }
63
+
64
+ describe("the change kind", () => {
65
+ it("declares its lifecycle once, with these categories", () => {
66
+ // Workspace-scoped (founder, 29 Nov 2026): a kind left unscoped is pod-wide.
67
+ expect(kind.entityScope).toBe("workspace");
68
+ expect(kind.lifecycle.property).toBe("changeStatus");
69
+ expect(kind.lifecycle.options.map((o: any) => [o.key, o.category])).toEqual([
70
+ ["working", "open"],
71
+ ["checks", "active"],
72
+ ["red", "active"],
73
+ ["ready", "active"],
74
+ ["merged", "done"],
75
+ ["closed", "lost"],
76
+ ]);
77
+ const select = kind.properties.find((p: any) => p.slug === "changeStatus");
78
+ expect(select.enumValues).toEqual(options);
79
+ });
80
+
81
+ it("Builder validates with it (kind, view, playbook, automation)", () => {
82
+ expect(validateTemplate(builder, { corpus }).errors).toEqual([]);
83
+ });
84
+
85
+ it("the view groups the changes by their lifecycle", () => {
86
+ const view = builder.views.find((v: any) => v.slug === "changes-by-state");
87
+ expect(view).toMatchObject({ type: "kanban", scopeProfileSlug: "change", config: { groupByField: "changeStatus" } });
88
+ });
89
+ });
90
+
91
+ describe("A pull request moves its change", () => {
92
+ it("passes the flow validator", () => {
93
+ expect(validateFlowDefinition(automation.flow).errors).toEqual([]);
94
+ });
95
+
96
+ it("listens to an inbound source by name, never one pod's subscription id", () => {
97
+ expect(automation.triggerType).toBe("webhook");
98
+ expect(automation.triggerConfig.webhookSource).toEqual({ name: "GitHub changes" });
99
+ expect(webhookSourceProblems({ ...automation, flow: automation.flow })).toEqual([]);
100
+ });
101
+
102
+ it("writes only statuses of the change's lifecycle", () => {
103
+ const written = writes.flatMap((n) => {
104
+ const v = n.data.config.properties?.changeStatus;
105
+ if (v === undefined) return [];
106
+ const ref = /^\{\{steps\.([\w-]+)\.output\.value\}\}$/.exec(v);
107
+ if (!ref) return [v];
108
+ // Follow the select chain to every literal it can yield.
109
+ const out: string[] = [];
110
+ const walk = (id: string) => {
111
+ const sel = node(id);
112
+ expect(sel.type).toBe("select");
113
+ for (const branch of [sel.data.ifTrue, sel.data.ifFalse]) {
114
+ const inner = /^\{\{steps\.([\w-]+)\.output\.value\}\}$/.exec(branch);
115
+ if (inner) walk(inner[1]);
116
+ else out.push(branch);
117
+ }
118
+ };
119
+ walk(ref[1]);
120
+ return out;
121
+ });
122
+ // non-vacuity: the pull request path and both verdicts
123
+ expect(new Set(written)).toEqual(new Set(["working", "checks", "closed", "merged", "ready", "red"]));
124
+ expect(written.filter((s) => !options.includes(s))).toEqual([]);
125
+ });
126
+
127
+ it("writes only properties of the kind, and dedupes on one of them", () => {
128
+ const keys = writes.flatMap((n) => Object.keys(n.data.config.properties ?? {}));
129
+ expect(keys.length).toBeGreaterThanOrEqual(10);
130
+ expect(keys.filter((k) => !propertySlugs.has(k))).toEqual([]);
131
+ const create = writes.find((n) => n.data.outputType === "entity_create")!;
132
+ expect(create.data.config).toMatchObject({ profileSlug: "change", dedupeBy: "prRef" });
133
+ expect(propertySlugs.has(create.data.config.dedupeBy)).toBe(true);
134
+ });
135
+
136
+ it("finds the change by prRef and head commit through a JSON-string filter", () => {
137
+ const find = node("find");
138
+ expect(find.type).toBe("query");
139
+ expect(find.data.profileSlug).toBe("change");
140
+ expect(typeof find.data.filter).toBe("string");
141
+ const parsed = JSON.parse(find.data.filter.replace(/\{\{[^}]*\}\}/g, "x"));
142
+ expect(Object.keys(parsed).sort()).toEqual(["headSha", "prRef"]);
143
+ });
144
+
145
+ it("a verdict writes only through the guard that the change waits on its checks", () => {
146
+ const verdictWrites = ["mark-ready", "mark-red"];
147
+ expect(verdictWrites.every((id) => reachable(new Set()).has(id))).toBe(true);
148
+ const guard = node("open-change");
149
+ expect(guard.type).toBe("guard");
150
+ const allowed = guard.data.checks.flatMap((c: any) => (c.anyOf ?? []).map((a: any) => a.equals));
151
+ expect(allowed.sort()).toEqual(["checks", "ready", "red"]);
152
+ const past = reachable(new Set(["open-change"]));
153
+ expect(verdictWrites.filter((id) => past.has(id))).toEqual([]);
154
+ });
155
+
156
+ it("a pull request event writes only through 'its base is the default branch' (yes)", () => {
157
+ const prWrites = ["upsert", "move"];
158
+ expect(prWrites.every((id) => reachable(new Set()).has(id))).toBe(true);
159
+ const out = edges.filter((e) => e.source === "into-default");
160
+ expect(out.map((e) => e.sourceHandle)).toEqual(["yes"]);
161
+ const past = reachable(new Set(["into-default"]));
162
+ expect(prWrites.filter((id) => past.has(id))).toEqual([]);
163
+ });
164
+ });
165
+
166
+ describe("Land a change follows the change", () => {
167
+ const pb = builder.playbooks.find((p: any) => p.name === "Land a change");
168
+
169
+ it("binds the kind, a draft with no activators", () => {
170
+ expect(pb.subjectProfile).toEqual({ profileSlug: "change" });
171
+ expect(pb.status).toBe("draft");
172
+ expect(pb.activators ?? []).toEqual([]);
173
+ });
174
+
175
+ it("every stage status is an option, the first stage writes none, and only Closed has no stage", () => {
176
+ const statuses = pb.stages.map((s: any) => s.subjectStatus).filter(Boolean);
177
+ expect(statuses.filter((s: string) => !options.includes(s))).toEqual([]);
178
+ expect(pb.stages[0].subjectStatus).toBeUndefined();
179
+ expect(options.filter((o) => !statuses.includes(o))).toEqual(["working", "closed"]);
180
+ });
181
+ });
182
+
183
+ describe("Ship a change waits on the change", () => {
184
+ const ship = builder.playbooks.find((p: any) => p.name === "Ship a change");
185
+ it("its checks and merge stages pause with a hold on the change entity", () => {
186
+ for (const key of ["checks", "merge"]) {
187
+ const goal = ship.stages.find((s: any) => s.key === key).goal as string;
188
+ // wake: the resume hands the session back to its agent (backend#1376).
189
+ expect(goal, key).toContain('until: {moves: "entity:<change id>"}, wake: true}');
190
+ }
191
+ });
192
+ });
@@ -0,0 +1,68 @@
1
+ /**
2
+ * The catalog never teaches a retired name (surfaces review, 27 Nov 2026,
3
+ * architecture S8). What a playbook goal or a catalog skill says is what an
4
+ * agent calls on every pod the catalog reaches, so an old name keeps the old
5
+ * way alive after the doors moved on:
6
+ *
7
+ * - `synap_list_widgets` is the old name of `synap_list_cells` (backend#1310;
8
+ * the pod still dispatches it as an alias, but the word is Cell);
9
+ * - `DEPRECATED_SURFACES` (`@synap-core/types/surfaces`) is now
10
+ * `DEPRECATED_IN_HOSTS` in `@synap-core/types/hosts` (a host app or tab,
11
+ * not a Surface).
12
+ *
13
+ * Scanned set derived from disk: every `src/*.yaml` and every `.md` under
14
+ * `skills/`. Does NOT cover backend-owned texts (the pod's tool descriptions
15
+ * and system skills), which have their own guards there.
16
+ */
17
+
18
+ import { readdirSync, readFileSync } from "node:fs";
19
+ import { dirname, join } from "node:path";
20
+ import { fileURLToPath } from "node:url";
21
+ import { describe, expect, it } from "vitest";
22
+
23
+ const ROOT = join(dirname(fileURLToPath(import.meta.url)), "..");
24
+ const RETIRED = [/\bsynap_list_widgets\b/, /\bDEPRECATED_SURFACES\b/];
25
+
26
+ function walk(dir: string, keep: (name: string) => boolean): string[] {
27
+ const out: string[] = [];
28
+ for (const e of readdirSync(dir, { withFileTypes: true })) {
29
+ const p = join(dir, e.name);
30
+ if (e.isDirectory()) out.push(...walk(p, keep));
31
+ else if (keep(e.name)) out.push(p);
32
+ }
33
+ return out;
34
+ }
35
+
36
+ const files = [
37
+ ...readdirSync(join(ROOT, "src"))
38
+ .filter((n) => n.endsWith(".yaml"))
39
+ .map((n) => join(ROOT, "src", n)),
40
+ ...walk(join(ROOT, "skills"), (n) => n.endsWith(".md")),
41
+ ];
42
+
43
+ describe("the catalog teaches no retired name", () => {
44
+ it("scans the catalog's playbooks and skills (non-vacuous)", () => {
45
+ expect(files.filter((f) => f.endsWith(".yaml")).length).toBeGreaterThan(20);
46
+ expect(files.filter((f) => f.endsWith(".md")).length).toBeGreaterThan(20);
47
+ // The CRM Health playbook lists the space's cells: it must name the live door.
48
+ expect(readFileSync(join(ROOT, "src", "crm.yaml"), "utf8")).toContain("synap_list_cells");
49
+ });
50
+
51
+ it("no playbook or skill names synap_list_widgets or DEPRECATED_SURFACES", () => {
52
+ const hits: string[] = [];
53
+ for (const f of files) {
54
+ const lines = readFileSync(f, "utf8").split("\n");
55
+ lines.forEach((line, i) => {
56
+ if (RETIRED.some((re) => re.test(line))) hits.push(`${f.slice(ROOT.length + 1)}:${i + 1}: ${line.trim()}`);
57
+ });
58
+ }
59
+ expect(hits).toEqual([]);
60
+ });
61
+
62
+ it("self-check: the patterns catch the old names and spare the new ones", () => {
63
+ expect(RETIRED.some((re) => re.test("the space's cells (synap_list_widgets)"))).toBe(true);
64
+ expect(RETIRED.some((re) => re.test("`DEPRECATED_SURFACES` in `@synap-core/types/surfaces`"))).toBe(true);
65
+ expect(RETIRED.some((re) => re.test("the space's cells (synap_list_cells)"))).toBe(false);
66
+ expect(RETIRED.some((re) => re.test("`DEPRECATED_IN_HOSTS` in `@synap-core/types/hosts`"))).toBe(false);
67
+ });
68
+ });