@synap-core/workspace-templates 0.74.0 → 0.75.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/capabilities/github-webhooks.capability.json +1 -1
- package/dist/index.js +148 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/__fixtures__/dev-facts.pull-request-opened.json +72 -0
- package/src/builder.yaml +83 -0
- package/src/crm.yaml +2 -1
- package/src/dev-flow-change.template.test.ts +170 -0
- package/src/templates.ts +145 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synap-core/workspace-templates",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.75.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Canonical workspace definitions — YAML source + typed exports for browser, backend, CLI, and marketplace",
|
|
6
6
|
"license": "PolyForm-Noncommercial-1.0.0",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"retired.yaml"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@synap-core/types": "^1.12.
|
|
39
|
+
"@synap-core/types": "^1.12.16",
|
|
40
40
|
"zod": "^3.0.0",
|
|
41
41
|
"js-yaml": "^4.1.0"
|
|
42
42
|
},
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_about": "Two dev.pr_opened facts as the pod records them: the org flow 'GitHub pull requests and checks -> dev-loop facts' (43ae349d, node pr-opened) mapping applied to GitHub's real payloads of Synap-core/backend#1504 and #1501 (read 2 Dec 2026), body cut to its first line and its Pod session line, and data.sessionId as the pod stamps it (record-observation withResolvedSession: #1504's body names session 7bf6eed9, which exists; #1501, a Dependabot PR, names none, so no stamp). changes = the two change entities on the pod for those PRs at 15:20 UTC, session empty on both.",
|
|
3
|
+
"facts": {
|
|
4
|
+
"namesSession": {
|
|
5
|
+
"eventType": "dev.pr_opened",
|
|
6
|
+
"data": {
|
|
7
|
+
"sha": "623d70d5732b908198d75760387fa07c7cdcd3e3",
|
|
8
|
+
"url": "https://github.com/Synap-core/backend/pull/1504",
|
|
9
|
+
"base": "main",
|
|
10
|
+
"body": "## What\n\nPod session: 7bf6eed9-cc49-4e85-bc10-fd9ee19481f6",
|
|
11
|
+
"repo": "Synap-core/backend",
|
|
12
|
+
"title": "fix(ci): the merge queue runs the full suite on the combined tree",
|
|
13
|
+
"action": "opened",
|
|
14
|
+
"author": "Antoinesrvt",
|
|
15
|
+
"branch": "ci/queue-runs-full-suite",
|
|
16
|
+
"merged": false,
|
|
17
|
+
"number": 1504,
|
|
18
|
+
"source": "github-webhook",
|
|
19
|
+
"headSha": "623d70d5732b908198d75760387fa07c7cdcd3e3",
|
|
20
|
+
"intoDefault": true,
|
|
21
|
+
"subjectRef": "Synap-core/backend#1504",
|
|
22
|
+
"sessionId": "7bf6eed9-cc49-4e85-bc10-fd9ee19481f6"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"namesNone": {
|
|
26
|
+
"eventType": "dev.pr_opened",
|
|
27
|
+
"data": {
|
|
28
|
+
"sha": "1cfadb1e68b53b4e49b7eb8809055beda3773172",
|
|
29
|
+
"url": "https://github.com/Synap-core/backend/pull/1501",
|
|
30
|
+
"base": "main",
|
|
31
|
+
"body": "Bumps [sigstore/cosign-installer](https://github.com/sigstore/cosign-installer) from 4.1.3 to 4.1.4.",
|
|
32
|
+
"repo": "Synap-core/backend",
|
|
33
|
+
"title": "chore(deps): Bump sigstore/cosign-installer from 4.1.3 to 4.1.4",
|
|
34
|
+
"action": "opened",
|
|
35
|
+
"author": "dependabot[bot]",
|
|
36
|
+
"branch": "dependabot/github_actions/sigstore/cosign-installer-4.1.4",
|
|
37
|
+
"merged": false,
|
|
38
|
+
"number": 1501,
|
|
39
|
+
"source": "github-webhook",
|
|
40
|
+
"headSha": "1cfadb1e68b53b4e49b7eb8809055beda3773172",
|
|
41
|
+
"intoDefault": true,
|
|
42
|
+
"subjectRef": "Synap-core/backend#1501"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"changes": [
|
|
47
|
+
{
|
|
48
|
+
"id": "d8c05238-56fc-4b10-a516-accce8e4cf4c",
|
|
49
|
+
"properties": {
|
|
50
|
+
"prRef": "Synap-core/backend#1504",
|
|
51
|
+
"repo": "Synap-core/backend",
|
|
52
|
+
"number": 1504,
|
|
53
|
+
"branch": "ci/queue-runs-full-suite",
|
|
54
|
+
"url": "https://github.com/Synap-core/backend/pull/1504",
|
|
55
|
+
"headSha": "623d70d5732b908198d75760387fa07c7cdcd3e3",
|
|
56
|
+
"changeStatus": "ready"
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"id": "9214549c-ca0c-4bf3-8a43-08f316931774",
|
|
61
|
+
"properties": {
|
|
62
|
+
"prRef": "Synap-core/backend#1501",
|
|
63
|
+
"repo": "Synap-core/backend",
|
|
64
|
+
"number": 1501,
|
|
65
|
+
"branch": "dependabot/github_actions/sigstore/cosign-installer-4.1.4",
|
|
66
|
+
"url": "https://github.com/Synap-core/backend/pull/1501",
|
|
67
|
+
"headSha": "1cfadb1e68b53b4e49b7eb8809055beda3773172",
|
|
68
|
+
"changeStatus": "ready"
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
]
|
|
72
|
+
}
|
package/src/builder.yaml
CHANGED
|
@@ -4365,6 +4365,89 @@ automations:
|
|
|
4365
4365
|
- { id: verdict--timed-out, source: verdict, target: mark-red, sourceHandle: timed_out }
|
|
4366
4366
|
- { id: verdict--startup, source: verdict, target: mark-red, sourceHandle: startup_failure }
|
|
4367
4367
|
|
|
4368
|
+
# A change names the session that works it (founder, 2 Dec 2026, plan
|
|
4369
|
+
# 963343b8). The session is the one the pod stamps on its own dev facts
|
|
4370
|
+
# (`data.sessionId`: a session that recorded the pull request as an outcome,
|
|
4371
|
+
# else the session its body's "Pod session: <uuid>" line names, when that
|
|
4372
|
+
# session exists; none when nothing or several match). So the ONE rule that
|
|
4373
|
+
# reads the line stays the pod's, and this flow never parses a body.
|
|
4374
|
+
# It reads the dev facts recorded by the org-wide source "GitHub"
|
|
4375
|
+
# (github-pr-events): with no such source, no fact arrives and it never runs.
|
|
4376
|
+
# The wait: a pull request's fact can be recorded before "A pull request moves
|
|
4377
|
+
# its change" has created the change (85 s on backend#1504, 2 Dec 2026).
|
|
4378
|
+
# It never overwrites a session already set, and every "nothing to do" ends on
|
|
4379
|
+
# a condition, never a guard (a guard stop posts a run summary).
|
|
4380
|
+
- key: pull-request-names-change-session
|
|
4381
|
+
name: A pull request names its change's session
|
|
4382
|
+
description: >-
|
|
4383
|
+
A dev fact about a pull request (opened, reopened, queued, merged or
|
|
4384
|
+
closed) that names one session fills its change's Session, once: a change
|
|
4385
|
+
that already names a session keeps it, and a pull request that names no
|
|
4386
|
+
session, or several, leaves it empty.
|
|
4387
|
+
triggerType: event
|
|
4388
|
+
triggerConfig:
|
|
4389
|
+
eventPattern: dev.*
|
|
4390
|
+
status: active
|
|
4391
|
+
flow:
|
|
4392
|
+
nodes:
|
|
4393
|
+
- id: t
|
|
4394
|
+
type: trigger
|
|
4395
|
+
position: { x: 0, y: 0 }
|
|
4396
|
+
data:
|
|
4397
|
+
label: A dev fact is recorded
|
|
4398
|
+
triggerType: event
|
|
4399
|
+
config:
|
|
4400
|
+
eventPattern: dev.*
|
|
4401
|
+
- id: names-session
|
|
4402
|
+
type: condition
|
|
4403
|
+
position: { x: 0, y: 120 }
|
|
4404
|
+
data:
|
|
4405
|
+
label: It names one session
|
|
4406
|
+
expression: trigger.payload.data.sessionId != ""
|
|
4407
|
+
- id: wait
|
|
4408
|
+
type: delay
|
|
4409
|
+
position: { x: 0, y: 240 }
|
|
4410
|
+
data:
|
|
4411
|
+
label: Wait for its change to exist
|
|
4412
|
+
duration: 5m
|
|
4413
|
+
- id: find
|
|
4414
|
+
type: query
|
|
4415
|
+
position: { x: 0, y: 360 }
|
|
4416
|
+
data:
|
|
4417
|
+
label: Its change
|
|
4418
|
+
profileSlug: change
|
|
4419
|
+
limit: 1
|
|
4420
|
+
filter: '{"prRef": "{{trigger.payload.data.repo}}#{{trigger.payload.data.number}}"}'
|
|
4421
|
+
- id: has-change
|
|
4422
|
+
type: condition
|
|
4423
|
+
position: { x: 0, y: 480 }
|
|
4424
|
+
data:
|
|
4425
|
+
label: It has a change
|
|
4426
|
+
expression: steps.find.output.count >= 1
|
|
4427
|
+
- id: no-session-yet
|
|
4428
|
+
type: condition
|
|
4429
|
+
position: { x: 0, y: 600 }
|
|
4430
|
+
data:
|
|
4431
|
+
label: Its change names no session yet
|
|
4432
|
+
expression: steps.find.output.entities[0].properties.session == ""
|
|
4433
|
+
- id: name-session
|
|
4434
|
+
type: output
|
|
4435
|
+
position: { x: 0, y: 720 }
|
|
4436
|
+
data:
|
|
4437
|
+
label: The change names its session
|
|
4438
|
+
outputType: entity_update
|
|
4439
|
+
config:
|
|
4440
|
+
entityId: "{{steps.find.output.entities[0].id}}"
|
|
4441
|
+
properties:
|
|
4442
|
+
session: "{{trigger.payload.data.sessionId}}"
|
|
4443
|
+
edges:
|
|
4444
|
+
- { id: t--names-session, source: t, target: names-session }
|
|
4445
|
+
- { id: names-session--wait, source: names-session, target: wait, sourceHandle: "yes" }
|
|
4446
|
+
- { id: wait--find, source: wait, target: find }
|
|
4447
|
+
- { id: find--has-change, source: find, target: has-change }
|
|
4448
|
+
- { id: has-change--no-session-yet, source: has-change, target: no-session-yet, sourceHandle: "yes" }
|
|
4449
|
+
- { id: no-session-yet--name-session, source: no-session-yet, target: name-session, sourceHandle: "yes" }
|
|
4450
|
+
|
|
4368
4451
|
# The skills every AI working in Dev is told exist (installed by the
|
|
4369
4452
|
# `require` dependencies above; this is the LINK, that is the INSTALL).
|
|
4370
4453
|
skills:
|
package/src/crm.yaml
CHANGED
|
@@ -2661,7 +2661,8 @@ playbooks:
|
|
|
2661
2661
|
attention.count, sessions.list, lifecycle.home, lifecycle.moving,
|
|
2662
2662
|
documents.get, lens.page, sessions.get, playbook.process,
|
|
2663
2663
|
playbook.scorecard, project.pillars, views.get, views.execute,
|
|
2664
|
-
profiles.get, propertyDefs.list, lifecycle.get, graph.of
|
|
2664
|
+
profiles.get, propertyDefs.list, lifecycle.get, graph.of,
|
|
2665
|
+
automations.list, automations.runs, playbooks.list, surfaces.of) and only that
|
|
2665
2666
|
op's params; the host stamps the space, so never put a workspaceId, a token, a pod URL
|
|
2666
2667
|
or a fetch in the page. What the bridge reads stays live: query it in
|
|
2667
2668
|
the page, never
|
|
@@ -22,9 +22,19 @@
|
|
|
22
22
|
* writes the first stage's status: a change further along must not be
|
|
23
23
|
* pulled back), and it is a draft with no activators;
|
|
24
24
|
* 5. Ship a change waits on the change with an entity hold.
|
|
25
|
+
* 6. "A pull request names its change's session" fills the change's Session
|
|
26
|
+
* from the session the pod stamps on its dev fact, only when the fact
|
|
27
|
+
* names one, the change exists and names none yet: run on two recorded
|
|
28
|
+
* facts (`__fixtures__/dev-facts.pull-request-opened.json`), and each case
|
|
29
|
+
* shown to rule a condition out (drop it, then that case writes).
|
|
25
30
|
*
|
|
26
31
|
* Not covered: a pod running it against GitHub's real payloads (NEEDS-DOGFOOD).
|
|
32
|
+
* The session flow runs here through `runFlow` below, a copy of the pod
|
|
33
|
+
* executor's semantics for the node types it uses (template paths, the
|
|
34
|
+
* condition grammar, a query matching properties, `yes` edges): the real
|
|
35
|
+
* executor (backend packages/jobs) is not run.
|
|
27
36
|
*/
|
|
37
|
+
import { readFileSync } from "node:fs";
|
|
28
38
|
import { describe, expect, it } from "vitest";
|
|
29
39
|
import { readYamlTemplates } from "./generate.mjs";
|
|
30
40
|
import { validateFlowDefinition } from "./validate-flow.js";
|
|
@@ -190,3 +200,163 @@ describe("Ship a change waits on the change", () => {
|
|
|
190
200
|
}
|
|
191
201
|
});
|
|
192
202
|
});
|
|
203
|
+
|
|
204
|
+
describe("A pull request names its change's session", () => {
|
|
205
|
+
const named = (builder.automations ?? []).find((a: any) => a.key === "pull-request-names-change-session");
|
|
206
|
+
type Flow = { nodes: FlowNode[]; edges: FlowEdge[] };
|
|
207
|
+
const flow: Flow = named?.flow;
|
|
208
|
+
const recorded = JSON.parse(
|
|
209
|
+
readFileSync(new URL("./__fixtures__/dev-facts.pull-request-opened.json", import.meta.url), "utf8")
|
|
210
|
+
) as {
|
|
211
|
+
facts: Record<"namesSession" | "namesNone", { eventType: string; data: Record<string, unknown> }>;
|
|
212
|
+
changes: { id: string; properties: Record<string, unknown> }[];
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
/** `{{a.b[0].c}}` read the way the pod reads it: a miss or a null renders "". */
|
|
216
|
+
function lookup(path: string, ctx: Record<string, unknown>): unknown {
|
|
217
|
+
let cur: any = ctx;
|
|
218
|
+
for (const part of path.trim().replace(/\[(\d+)\]/g, ".$1").split(".")) {
|
|
219
|
+
if (cur == null || typeof cur !== "object") return undefined;
|
|
220
|
+
cur = cur[part];
|
|
221
|
+
}
|
|
222
|
+
return cur;
|
|
223
|
+
}
|
|
224
|
+
const render = (t: string, ctx: Record<string, unknown>) =>
|
|
225
|
+
t.replace(/\{\{(.+?)\}\}/g, (_, p: string) => {
|
|
226
|
+
const v = lookup(p, ctx);
|
|
227
|
+
return v == null ? "" : typeof v === "object" ? JSON.stringify(v) : String(v);
|
|
228
|
+
});
|
|
229
|
+
/** The pod's condition grammar (condition-eval.ts), for the operators this flow uses. */
|
|
230
|
+
function condition(expr: string, ctx: Record<string, unknown>): boolean {
|
|
231
|
+
const m = /^(.+?)\s*(===|!==|==|!=|>=|<=|>|<)\s*(.+)$/.exec(expr)!;
|
|
232
|
+
const [, leftPath, op, rightRaw] = m;
|
|
233
|
+
const r = rightRaw.trim();
|
|
234
|
+
const right: string | number = /^(["']).*\1$/.test(r) ? r.slice(1, -1) : r !== "" && !isNaN(Number(r)) ? Number(r) : r;
|
|
235
|
+
const leftStr = render(`{{${leftPath}}}`, ctx);
|
|
236
|
+
const left = typeof right === "number" ? (leftStr === "" ? NaN : Number(leftStr)) : leftStr;
|
|
237
|
+
switch (op) {
|
|
238
|
+
case "==": case "===": return left === right;
|
|
239
|
+
case "!=": case "!==": return left !== right;
|
|
240
|
+
case ">=": return Number(left) >= Number(right);
|
|
241
|
+
default: throw new Error(`operator ${op} is not simulated`);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
/** Walk the flow on one fact: what it writes (entity_update), given the changes on the pod. */
|
|
245
|
+
function runFlow(f: Flow, fact: { eventType: string; data: Record<string, unknown> }, changes: typeof recorded.changes) {
|
|
246
|
+
const ctx: Record<string, any> = { trigger: { payload: { eventType: fact.eventType, data: fact.data } }, steps: {} };
|
|
247
|
+
const writes: { entityId: string; properties: Record<string, string> }[] = [];
|
|
248
|
+
const queue = f.nodes.filter((n) => n.type === "trigger").map((n) => n.id);
|
|
249
|
+
const done = new Set<string>();
|
|
250
|
+
while (queue.length) {
|
|
251
|
+
const next = queue.shift()!;
|
|
252
|
+
const n = f.nodes.find((x) => x.id === next)!;
|
|
253
|
+
if (done.has(n.id)) continue;
|
|
254
|
+
done.add(n.id);
|
|
255
|
+
let handle: string | undefined;
|
|
256
|
+
if (n.type === "condition") {
|
|
257
|
+
handle = condition(n.data.expression, ctx) ? "yes" : "no";
|
|
258
|
+
ctx.steps[n.id] = { output: { result: handle === "yes" } };
|
|
259
|
+
} else if (n.type === "query") {
|
|
260
|
+
const filter = JSON.parse(render(n.data.filter, ctx)) as Record<string, string>;
|
|
261
|
+
const hits = changes.filter((c) => Object.entries(filter).every(([k, v]) => String(c.properties[k]) === v));
|
|
262
|
+
const entities = hits.slice(0, n.data.limit);
|
|
263
|
+
ctx.steps[n.id] = { output: { count: entities.length, entities } };
|
|
264
|
+
} else if (n.type === "output") {
|
|
265
|
+
expect(n.data.outputType).toBe("entity_update");
|
|
266
|
+
const props = Object.fromEntries(
|
|
267
|
+
Object.entries(n.data.config.properties as Record<string, string>).map(([k, v]) => [k, render(v, ctx)])
|
|
268
|
+
);
|
|
269
|
+
writes.push({ entityId: render(n.data.config.entityId, ctx), properties: props });
|
|
270
|
+
} else if (!["trigger", "delay"].includes(n.type)) {
|
|
271
|
+
throw new Error(`node type ${n.type} is not simulated`);
|
|
272
|
+
}
|
|
273
|
+
for (const e of f.edges.filter((e) => e.source === n.id)) {
|
|
274
|
+
if (e.sourceHandle === undefined || e.sourceHandle === handle) queue.push(e.target);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
return writes;
|
|
278
|
+
}
|
|
279
|
+
/** The flow with one node cut out, its predecessor wired straight to its successors. */
|
|
280
|
+
function without(id: string): Flow {
|
|
281
|
+
const into = flow.edges.filter((e) => e.target === id);
|
|
282
|
+
const out = flow.edges.filter((e) => e.source === id);
|
|
283
|
+
const kept = flow.edges.filter((e) => e.source !== id && e.target !== id);
|
|
284
|
+
const bridged = into.flatMap((i) => out.map((o) => ({ ...i, id: `${i.id}~${o.id}`, target: o.target })));
|
|
285
|
+
return { nodes: flow.nodes.filter((n) => n.id !== id), edges: [...kept, ...bridged] };
|
|
286
|
+
}
|
|
287
|
+
const change1504 = recorded.changes.find((c) => c.properties.prRef === "Synap-core/backend#1504")!;
|
|
288
|
+
const sessionOf1504 = recorded.facts.namesSession.data.sessionId as string;
|
|
289
|
+
|
|
290
|
+
it("listens to the pod's dev facts, passes the flow validator, and writes the change's Session only", () => {
|
|
291
|
+
expect(named.triggerType).toBe("event");
|
|
292
|
+
expect(named.triggerConfig).toEqual({ eventPattern: "dev.*" });
|
|
293
|
+
expect(flow.nodes.find((n) => n.type === "trigger")!.data.config).toEqual({ eventPattern: "dev.*" });
|
|
294
|
+
expect(validateFlowDefinition(flow).errors).toEqual([]);
|
|
295
|
+
const outs = flow.nodes.filter((n) => n.type === "output");
|
|
296
|
+
expect(outs.map((n) => [n.data.outputType, Object.keys(n.data.config.properties)])).toEqual([
|
|
297
|
+
["entity_update", ["session"]],
|
|
298
|
+
]);
|
|
299
|
+
expect(propertySlugs.has("session")).toBe(true);
|
|
300
|
+
expect(outs[0].data.config.properties.session).toBe("{{trigger.payload.data.sessionId}}");
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
it("finds the change by the prRef 'A pull request moves its change' writes", () => {
|
|
304
|
+
const find = flow.nodes.find((n) => n.type === "query")!;
|
|
305
|
+
expect(find.data.profileSlug).toBe("change");
|
|
306
|
+
const written = (node("upsert").data.config.properties.prRef as string).replace(/\{\{[^}]*\}\}/g, "x");
|
|
307
|
+
const read = (JSON.parse(find.data.filter).prRef as string).replace(/\{\{[^}]*\}\}/g, "x");
|
|
308
|
+
expect(read).toBe(written); // both "x#x": owner/name, then the number
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
it("the write is reachable only through each of its three conditions (yes)", () => {
|
|
312
|
+
const reach = (f: Flow, blocked: string) => {
|
|
313
|
+
const seen = new Set<string>();
|
|
314
|
+
const q = ["t"];
|
|
315
|
+
while (q.length) {
|
|
316
|
+
const id = q.shift()!;
|
|
317
|
+
if (seen.has(id) || id === blocked) continue;
|
|
318
|
+
seen.add(id);
|
|
319
|
+
q.push(...f.edges.filter((e) => e.source === id).map((e) => e.target));
|
|
320
|
+
}
|
|
321
|
+
return seen.has("name-session");
|
|
322
|
+
};
|
|
323
|
+
const conditions = flow.nodes.filter((n) => n.type === "condition").map((n) => n.id);
|
|
324
|
+
expect(conditions).toEqual(["names-session", "has-change", "no-session-yet"]);
|
|
325
|
+
expect(reach(flow, "none")).toBe(true);
|
|
326
|
+
for (const id of conditions) {
|
|
327
|
+
expect(reach(flow, id), id).toBe(false);
|
|
328
|
+
expect(flow.edges.filter((e) => e.source === id).map((e) => e.sourceHandle), id).toEqual(["yes"]);
|
|
329
|
+
}
|
|
330
|
+
// It waits before it looks: the delay sits before the query.
|
|
331
|
+
expect(flow.edges.find((e) => e.target === "find")!.source).toBe("wait");
|
|
332
|
+
expect(flow.nodes.find((n) => n.id === "wait")!.data.duration).toMatch(/^\d+\s*(s|m)$/);
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
it("a recorded fact that names a session fills the change's Session with it", () => {
|
|
336
|
+
expect(String(recorded.facts.namesSession.data.body)).toContain(`Pod session: ${sessionOf1504}`);
|
|
337
|
+
expect(change1504.properties.session).toBeUndefined();
|
|
338
|
+
expect(runFlow(flow, recorded.facts.namesSession, recorded.changes)).toEqual([
|
|
339
|
+
{ entityId: change1504.id, properties: { session: sessionOf1504 } },
|
|
340
|
+
]);
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
it("a fact that names no session writes nothing (and the case rules out dropping that condition)", () => {
|
|
344
|
+
expect(recorded.facts.namesNone.data.sessionId).toBeUndefined();
|
|
345
|
+
expect(runFlow(flow, recorded.facts.namesNone, recorded.changes)).toEqual([]);
|
|
346
|
+
expect(runFlow(without("names-session"), recorded.facts.namesNone, recorded.changes)).not.toEqual([]);
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
it("a change that already names a session keeps it (and the case rules out dropping that condition)", () => {
|
|
350
|
+
const taken = recorded.changes.map((c) =>
|
|
351
|
+
c.id === change1504.id ? { ...c, properties: { ...c.properties, session: "00000000-0000-4000-8000-000000000001" } } : c
|
|
352
|
+
);
|
|
353
|
+
expect(runFlow(flow, recorded.facts.namesSession, taken)).toEqual([]);
|
|
354
|
+
expect(runFlow(without("no-session-yet"), recorded.facts.namesSession, taken)).not.toEqual([]);
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
it("a pull request with no change yet writes nothing (and the case rules out dropping that condition)", () => {
|
|
358
|
+
const none = recorded.changes.filter((c) => c.id !== change1504.id);
|
|
359
|
+
expect(runFlow(flow, recorded.facts.namesSession, none)).toEqual([]);
|
|
360
|
+
expect(runFlow(without("has-change"), recorded.facts.namesSession, none)).not.toEqual([]);
|
|
361
|
+
});
|
|
362
|
+
});
|
package/src/templates.ts
CHANGED
|
@@ -10221,6 +10221,150 @@ const DATA = {
|
|
|
10221
10221
|
}
|
|
10222
10222
|
]
|
|
10223
10223
|
}
|
|
10224
|
+
},
|
|
10225
|
+
{
|
|
10226
|
+
"key": "pull-request-names-change-session",
|
|
10227
|
+
"name": "A pull request names its change's session",
|
|
10228
|
+
"description": "A dev fact about a pull request (opened, reopened, queued, merged or closed) that names one session fills its change's Session, once: a change that already names a session keeps it, and a pull request that names no session, or several, leaves it empty.",
|
|
10229
|
+
"triggerType": "event",
|
|
10230
|
+
"triggerConfig": {
|
|
10231
|
+
"eventPattern": "dev.*"
|
|
10232
|
+
},
|
|
10233
|
+
"status": "active",
|
|
10234
|
+
"flow": {
|
|
10235
|
+
"nodes": [
|
|
10236
|
+
{
|
|
10237
|
+
"id": "t",
|
|
10238
|
+
"type": "trigger",
|
|
10239
|
+
"position": {
|
|
10240
|
+
"x": 0,
|
|
10241
|
+
"y": 0
|
|
10242
|
+
},
|
|
10243
|
+
"data": {
|
|
10244
|
+
"label": "A dev fact is recorded",
|
|
10245
|
+
"triggerType": "event",
|
|
10246
|
+
"config": {
|
|
10247
|
+
"eventPattern": "dev.*"
|
|
10248
|
+
}
|
|
10249
|
+
}
|
|
10250
|
+
},
|
|
10251
|
+
{
|
|
10252
|
+
"id": "names-session",
|
|
10253
|
+
"type": "condition",
|
|
10254
|
+
"position": {
|
|
10255
|
+
"x": 0,
|
|
10256
|
+
"y": 120
|
|
10257
|
+
},
|
|
10258
|
+
"data": {
|
|
10259
|
+
"label": "It names one session",
|
|
10260
|
+
"expression": "trigger.payload.data.sessionId != \"\""
|
|
10261
|
+
}
|
|
10262
|
+
},
|
|
10263
|
+
{
|
|
10264
|
+
"id": "wait",
|
|
10265
|
+
"type": "delay",
|
|
10266
|
+
"position": {
|
|
10267
|
+
"x": 0,
|
|
10268
|
+
"y": 240
|
|
10269
|
+
},
|
|
10270
|
+
"data": {
|
|
10271
|
+
"label": "Wait for its change to exist",
|
|
10272
|
+
"duration": "5m"
|
|
10273
|
+
}
|
|
10274
|
+
},
|
|
10275
|
+
{
|
|
10276
|
+
"id": "find",
|
|
10277
|
+
"type": "query",
|
|
10278
|
+
"position": {
|
|
10279
|
+
"x": 0,
|
|
10280
|
+
"y": 360
|
|
10281
|
+
},
|
|
10282
|
+
"data": {
|
|
10283
|
+
"label": "Its change",
|
|
10284
|
+
"profileSlug": "change",
|
|
10285
|
+
"limit": 1,
|
|
10286
|
+
"filter": "{\"prRef\": \"{{trigger.payload.data.repo}}#{{trigger.payload.data.number}}\"}"
|
|
10287
|
+
}
|
|
10288
|
+
},
|
|
10289
|
+
{
|
|
10290
|
+
"id": "has-change",
|
|
10291
|
+
"type": "condition",
|
|
10292
|
+
"position": {
|
|
10293
|
+
"x": 0,
|
|
10294
|
+
"y": 480
|
|
10295
|
+
},
|
|
10296
|
+
"data": {
|
|
10297
|
+
"label": "It has a change",
|
|
10298
|
+
"expression": "steps.find.output.count >= 1"
|
|
10299
|
+
}
|
|
10300
|
+
},
|
|
10301
|
+
{
|
|
10302
|
+
"id": "no-session-yet",
|
|
10303
|
+
"type": "condition",
|
|
10304
|
+
"position": {
|
|
10305
|
+
"x": 0,
|
|
10306
|
+
"y": 600
|
|
10307
|
+
},
|
|
10308
|
+
"data": {
|
|
10309
|
+
"label": "Its change names no session yet",
|
|
10310
|
+
"expression": "steps.find.output.entities[0].properties.session == \"\""
|
|
10311
|
+
}
|
|
10312
|
+
},
|
|
10313
|
+
{
|
|
10314
|
+
"id": "name-session",
|
|
10315
|
+
"type": "output",
|
|
10316
|
+
"position": {
|
|
10317
|
+
"x": 0,
|
|
10318
|
+
"y": 720
|
|
10319
|
+
},
|
|
10320
|
+
"data": {
|
|
10321
|
+
"label": "The change names its session",
|
|
10322
|
+
"outputType": "entity_update",
|
|
10323
|
+
"config": {
|
|
10324
|
+
"entityId": "{{steps.find.output.entities[0].id}}",
|
|
10325
|
+
"properties": {
|
|
10326
|
+
"session": "{{trigger.payload.data.sessionId}}"
|
|
10327
|
+
}
|
|
10328
|
+
}
|
|
10329
|
+
}
|
|
10330
|
+
}
|
|
10331
|
+
],
|
|
10332
|
+
"edges": [
|
|
10333
|
+
{
|
|
10334
|
+
"id": "t--names-session",
|
|
10335
|
+
"source": "t",
|
|
10336
|
+
"target": "names-session"
|
|
10337
|
+
},
|
|
10338
|
+
{
|
|
10339
|
+
"id": "names-session--wait",
|
|
10340
|
+
"source": "names-session",
|
|
10341
|
+
"target": "wait",
|
|
10342
|
+
"sourceHandle": "yes"
|
|
10343
|
+
},
|
|
10344
|
+
{
|
|
10345
|
+
"id": "wait--find",
|
|
10346
|
+
"source": "wait",
|
|
10347
|
+
"target": "find"
|
|
10348
|
+
},
|
|
10349
|
+
{
|
|
10350
|
+
"id": "find--has-change",
|
|
10351
|
+
"source": "find",
|
|
10352
|
+
"target": "has-change"
|
|
10353
|
+
},
|
|
10354
|
+
{
|
|
10355
|
+
"id": "has-change--no-session-yet",
|
|
10356
|
+
"source": "has-change",
|
|
10357
|
+
"target": "no-session-yet",
|
|
10358
|
+
"sourceHandle": "yes"
|
|
10359
|
+
},
|
|
10360
|
+
{
|
|
10361
|
+
"id": "no-session-yet--name-session",
|
|
10362
|
+
"source": "no-session-yet",
|
|
10363
|
+
"target": "name-session",
|
|
10364
|
+
"sourceHandle": "yes"
|
|
10365
|
+
}
|
|
10366
|
+
]
|
|
10367
|
+
}
|
|
10224
10368
|
}
|
|
10225
10369
|
],
|
|
10226
10370
|
"skills": [
|
|
@@ -18626,7 +18770,7 @@ const DATA = {
|
|
|
18626
18770
|
{
|
|
18627
18771
|
"name": "Propose a Health cell",
|
|
18628
18772
|
"description": "Answer one question about your sales with a tile on the Health dashboard; the AI writes the tile and you approve it before it shows. Run by one of your agents for now (Synap AI cannot place a tile yet).",
|
|
18629
|
-
"goalTemplate": "Propose one Health tile that answers: {question}. FIND THE VIEW: in the CRM space, the bento view named Health (synap_list_views with the space's workspaceId, type bento). When the space has none, stop and say so: never create another dashboard. READ FIRST: what already sits on Health (its config.blocks: each widget tile names a cell by widgetType) and the space's cells (synap_list_cells); when a tile already answers the question, say which one and stop. DATA: decide where each number comes from. A cell reads the pod ONLY through the cell bridge, at render time: window.synap.query(op, params), with an op of the bridge table (entities.list, entities.get, views.list, profiles.list, lifecycle.board, flow.of, lifecycle.throughput, attention.needsYou, attention.count, sessions.list, lifecycle.home, lifecycle.moving, documents.get, lens.page, sessions.get, playbook.process, playbook.scorecard, project.pillars, views.get, views.execute, profiles.get, propertyDefs.list, lifecycle.get, graph.of) and only that op's params; the host stamps the space, so never put a workspaceId, a token, a pod URL or a fetch in the page. What the bridge reads stays live: query it in the page, never paste its rows. What it cannot read yet (messages, replies, sends: the bridge has no message op) you read now with your own tools (synap_get_channel, synap_get_entities) and write into the page as a snapshot, with the date it was taken shown on the tile (for example \"au 8 novembre\") and how it was counted. Never invent a number: a figure you cannot source is left out and the tile says what is missing. THE PAGE: one self-contained HTML page, inline script and style only (no CDN, no remote font or image: the frame's CSP refuses them), that answers the question in one glance (a number, a short table or a small chart), in the person's language (French by default), readable in light and dark, and that shows an error, never an empty tile, when a query fails. FILE IT: synap_create_cell with name = a short title of the question, rendererSource = the page, workspaceId = the CRM space (never pod-wide: the CRM app reads only its space's cells), contentKind widget, placeOn = {viewId: the Health view's id}, and reasoning = the question in the person's words. It comes back proposed: that is success, never retry it; the person approves it in the CRM or the pod, which defines the cell and puts its tile on Health in one act. One cell per run.",
|
|
18773
|
+
"goalTemplate": "Propose one Health tile that answers: {question}. FIND THE VIEW: in the CRM space, the bento view named Health (synap_list_views with the space's workspaceId, type bento). When the space has none, stop and say so: never create another dashboard. READ FIRST: what already sits on Health (its config.blocks: each widget tile names a cell by widgetType) and the space's cells (synap_list_cells); when a tile already answers the question, say which one and stop. DATA: decide where each number comes from. A cell reads the pod ONLY through the cell bridge, at render time: window.synap.query(op, params), with an op of the bridge table (entities.list, entities.get, views.list, profiles.list, lifecycle.board, flow.of, lifecycle.throughput, attention.needsYou, attention.count, sessions.list, lifecycle.home, lifecycle.moving, documents.get, lens.page, sessions.get, playbook.process, playbook.scorecard, project.pillars, views.get, views.execute, profiles.get, propertyDefs.list, lifecycle.get, graph.of, automations.list, automations.runs, playbooks.list, surfaces.of) and only that op's params; the host stamps the space, so never put a workspaceId, a token, a pod URL or a fetch in the page. What the bridge reads stays live: query it in the page, never paste its rows. What it cannot read yet (messages, replies, sends: the bridge has no message op) you read now with your own tools (synap_get_channel, synap_get_entities) and write into the page as a snapshot, with the date it was taken shown on the tile (for example \"au 8 novembre\") and how it was counted. Never invent a number: a figure you cannot source is left out and the tile says what is missing. THE PAGE: one self-contained HTML page, inline script and style only (no CDN, no remote font or image: the frame's CSP refuses them), that answers the question in one glance (a number, a short table or a small chart), in the person's language (French by default), readable in light and dark, and that shows an error, never an empty tile, when a query fails. FILE IT: synap_create_cell with name = a short title of the question, rendererSource = the page, workspaceId = the CRM space (never pod-wide: the CRM app reads only its space's cells), contentKind widget, placeOn = {viewId: the Health view's id}, and reasoning = the question in the person's words. It comes back proposed: that is success, never retry it; the person approves it in the CRM or the pod, which defines the cell and puts its tile on Health in one act. One cell per run.",
|
|
18630
18774
|
"params": [
|
|
18631
18775
|
{
|
|
18632
18776
|
"name": "question",
|