@synap-core/workspace-templates 0.76.0 → 0.76.1

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.76.0",
3
+ "version": "0.76.1",
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",
@@ -0,0 +1,87 @@
1
+ {
2
+ "_about": "Recorded 3 Dec 2026 (lane R3, session 1286c739). merged = the dev.pr_merged fact the org flow 'GitHub pull requests and checks -> dev-loop facts' (43ae349d, node pr-merged) records for Synap-core/backend#1530, its mapping applied to GitHub's real payload (read 15:40 UTC), body cut to its first line; the pod recorded this fact at 11:21:20 UTC, 68 s after the merge (get_timeline). changes = six change entities on the pod read between 15:20 and 15:25 UTC: backend#1530 Checks running (merged 11:20:12, its run of 'A pull request moves its change' at 11:22:37 linked it and moved nothing), #1540 Ready to merge (merged 14:59:27, moved to Merged at 15:28:38), #1536 Checks running (merged 15:24:50, Merged at 15:53:13), synap-bridge#4 Checks running (merged 15:00:26, Merged at 15:30:44), #1538 Merged, #1532 Checks running (open then).",
3
+ "facts": {
4
+ "merged": {
5
+ "eventType": "dev.pr_merged",
6
+ "data": {
7
+ "repo": "Synap-core/backend",
8
+ "number": 1530,
9
+ "url": "https://github.com/Synap-core/backend/pull/1530",
10
+ "sha": "1afe5c6cb939730dfa47912b58e8f51ac92f11f5",
11
+ "branch": "feat/proposed-entity-layer",
12
+ "base": "main",
13
+ "intoDefault": true,
14
+ "title": "feat(pod-admin): a pending entity request draws the entity, its change marked on it",
15
+ "body": "Pod session: 4b724dc3-8d8f-403f-90e2-c256cf775d9c (wave 7 slice 2; design fe9803a4 §2.4, §6.3, §6.4; F1-F8 founder-validated 1 Dec 2026)",
16
+ "action": "closed",
17
+ "merged": true,
18
+ "headSha": "11db4c9a26c9faa3aa4d9b578d09efc51089daad",
19
+ "author": "Antoinesrvt",
20
+ "source": "github-webhook",
21
+ "subjectRef": "Synap-core/backend#1530"
22
+ }
23
+ }
24
+ },
25
+ "changes": [
26
+ {
27
+ "id": "a0fe8e2e-1033-41c8-90a4-a6fb8d8d5d4f",
28
+ "properties": {
29
+ "prRef": "Synap-core/backend#1530",
30
+ "repo": "Synap-core/backend",
31
+ "number": 1530,
32
+ "headSha": "11db4c9a26c9faa3aa4d9b578d09efc51089daad",
33
+ "changeStatus": "checks"
34
+ }
35
+ },
36
+ {
37
+ "id": "f778b630-6dec-4dba-84f0-254db4bb321c",
38
+ "properties": {
39
+ "prRef": "Synap-core/backend#1532",
40
+ "repo": "Synap-core/backend",
41
+ "number": 1532,
42
+ "headSha": "b92dfcc687f713d0d94d4e360038185faab00b75",
43
+ "changeStatus": "checks"
44
+ }
45
+ },
46
+ {
47
+ "id": "862bf8be-5d4a-4f74-8701-73125a287cf4",
48
+ "properties": {
49
+ "prRef": "Synap-core/backend#1536",
50
+ "repo": "Synap-core/backend",
51
+ "number": 1536,
52
+ "headSha": "5bc481c67775b1f0d3f23925db3a41b75b672e30",
53
+ "changeStatus": "checks"
54
+ }
55
+ },
56
+ {
57
+ "id": "eb92ff8e-f17b-4e54-8710-1bd3dc91e411",
58
+ "properties": {
59
+ "prRef": "Synap-core/backend#1538",
60
+ "repo": "Synap-core/backend",
61
+ "number": 1538,
62
+ "headSha": "83c920fd27845a5380ec2ceb08bb76e47e27b8a2",
63
+ "changeStatus": "merged"
64
+ }
65
+ },
66
+ {
67
+ "id": "bf55fb27-f8e6-47d3-82ba-964ff8798c91",
68
+ "properties": {
69
+ "prRef": "Synap-core/backend#1540",
70
+ "repo": "Synap-core/backend",
71
+ "number": 1540,
72
+ "headSha": "64440901fb81a3057850dcc4aa093e1f38dd2ded",
73
+ "changeStatus": "ready"
74
+ }
75
+ },
76
+ {
77
+ "id": "e5eee4d5-db18-4506-ac0c-2f0d0715248e",
78
+ "properties": {
79
+ "prRef": "Synap-core/synap-bridge#4",
80
+ "repo": "Synap-core/synap-bridge",
81
+ "number": 4,
82
+ "headSha": "af018bee8c6fa15931087e2adcedf5a46c1ae07c",
83
+ "changeStatus": "checks"
84
+ }
85
+ }
86
+ ]
87
+ }
package/src/builder.yaml CHANGED
@@ -4448,6 +4448,82 @@ automations:
4448
4448
  - { id: has-change--no-session-yet, source: has-change, target: no-session-yet, sourceHandle: "yes" }
4449
4449
  - { id: no-session-yet--name-session, source: no-session-yet, target: name-session, sourceHandle: "yes" }
4450
4450
 
4451
+ # A merged pull request settles its change, whatever happened to its run of
4452
+ # "A pull request moves its change" (lane R3, 3 Dec 2026, session 1286c739).
4453
+ # Measured that day: backend#1530 merged at 11:20 and its change stayed
4454
+ # Checks running (the run of its merge event linked the change and moved
4455
+ # nothing). So the merge reaches the change a second, independent way: the
4456
+ # `dev.pr_merged` fact the org-wide source "GitHub" (github-pr-events)
4457
+ # records, the fact the Ship page folds (`GET /work-release`). It only ever
4458
+ # writes Merged, on a change not already Merged; a pull request with no
4459
+ # change moves nothing. Every "nothing to do" ends on a condition, never a
4460
+ # guard (a guard stop posts a run summary). It listens to `dev.pr_merged`
4461
+ # only (a few dozen runs a day), never `dev.*`: each run of a flow that
4462
+ # writes an entity opens a session and waits on the pod's one automation
4463
+ # queue, which already ran up to ~30 min late that afternoon.
4464
+ - key: merged-pull-request-settles-change
4465
+ name: A merged pull request settles its change
4466
+ description: >-
4467
+ A dev.pr_merged fact into the default branch moves the pull request's
4468
+ change to Merged when GitHub's own event did not: a change already
4469
+ Merged, or a pull request with no change, moves nothing.
4470
+ triggerType: event
4471
+ triggerConfig:
4472
+ eventPattern: dev.pr_merged
4473
+ status: active
4474
+ flow:
4475
+ nodes:
4476
+ - id: t
4477
+ type: trigger
4478
+ position: { x: 0, y: 0 }
4479
+ data:
4480
+ label: A pull request merged
4481
+ triggerType: event
4482
+ config:
4483
+ eventPattern: dev.pr_merged
4484
+ - id: into-default
4485
+ type: condition
4486
+ position: { x: 0, y: 120 }
4487
+ data:
4488
+ label: It merged into the default branch
4489
+ expression: trigger.payload.data.intoDefault == "true"
4490
+ - id: find
4491
+ type: query
4492
+ position: { x: 0, y: 240 }
4493
+ data:
4494
+ label: Its change
4495
+ profileSlug: change
4496
+ limit: 1
4497
+ filter: '{"prRef": "{{trigger.payload.data.repo}}#{{trigger.payload.data.number}}"}'
4498
+ - id: has-change
4499
+ type: condition
4500
+ position: { x: 0, y: 360 }
4501
+ data:
4502
+ label: It has a change
4503
+ expression: steps.find.output.count >= 1
4504
+ - id: not-merged
4505
+ type: condition
4506
+ position: { x: 0, y: 480 }
4507
+ data:
4508
+ label: Its change is not Merged yet
4509
+ expression: steps.find.output.entities[0].properties.changeStatus != "merged"
4510
+ - id: settle
4511
+ type: output
4512
+ position: { x: 0, y: 600 }
4513
+ data:
4514
+ label: The change is Merged
4515
+ outputType: entity_update
4516
+ config:
4517
+ entityId: "{{steps.find.output.entities[0].id}}"
4518
+ properties:
4519
+ changeStatus: merged
4520
+ edges:
4521
+ - { id: t--into-default, source: t, target: into-default }
4522
+ - { id: into-default--find, source: into-default, target: find, sourceHandle: "yes" }
4523
+ - { id: find--has-change, source: find, target: has-change }
4524
+ - { id: has-change--not-merged, source: has-change, target: not-merged, sourceHandle: "yes" }
4525
+ - { id: not-merged--settle, source: not-merged, target: settle, sourceHandle: "yes" }
4526
+
4451
4527
  # The skills every AI working in Dev is told exist (installed by the
4452
4528
  # `require` dependencies above; this is the LINK, that is the INSTALL).
4453
4529
  skills:
@@ -360,3 +360,132 @@ describe("A pull request names its change's session", () => {
360
360
  expect(runFlow(without("has-change"), recorded.facts.namesSession, none)).not.toEqual([]);
361
361
  });
362
362
  });
363
+
364
+ describe("A merged pull request settles its change", () => {
365
+ const settles = (builder.automations ?? []).find((a: any) => a.key === "merged-pull-request-settles-change");
366
+ type Flow = { nodes: FlowNode[]; edges: FlowEdge[] };
367
+ type Fact = { eventType: string; data: Record<string, any> };
368
+ type Change = { id: string; properties: Record<string, unknown> };
369
+ const flow: Flow = settles?.flow;
370
+ const recorded = JSON.parse(
371
+ readFileSync(new URL("./__fixtures__/dev-facts.merged.json", import.meta.url), "utf8")
372
+ ) as { facts: { merged: Fact }; changes: Change[] };
373
+ const fact = recorded.facts.merged;
374
+ const change1530 = recorded.changes.find((c) => c.properties.prRef === "Synap-core/backend#1530")!;
375
+
376
+ /** `{{a.b[0].c}}` read the way the pod reads it: a miss or a null renders "". */
377
+ function lookup(path: string, ctx: Record<string, unknown>): unknown {
378
+ let cur: any = ctx;
379
+ for (const part of path.trim().replace(/\[(\d+)\]/g, ".$1").split(".")) {
380
+ if (cur == null || typeof cur !== "object") return undefined;
381
+ cur = cur[part];
382
+ }
383
+ return cur;
384
+ }
385
+ const render = (t: string, ctx: Record<string, unknown>) =>
386
+ t.replace(/\{\{(.+?)\}\}/g, (_, p: string) => {
387
+ const v = lookup(p, ctx);
388
+ return v == null ? "" : typeof v === "object" ? JSON.stringify(v) : String(v);
389
+ });
390
+ /** The pod's condition grammar (condition-eval.ts) for the operators this flow uses: the left side renders to a string. */
391
+ function condition(expr: string, ctx: Record<string, unknown>): boolean {
392
+ const [, leftPath, op, rightRaw] = /^(.+?)\s*(===|!==|==|!=|>=|<=|>|<)\s*(.+)$/.exec(expr)!;
393
+ const r = rightRaw.trim();
394
+ const right: string | number = /^(["']).*\1$/.test(r) ? r.slice(1, -1) : r !== "" && !isNaN(Number(r)) ? Number(r) : r;
395
+ const leftStr = render(`{{${leftPath}}}`, ctx);
396
+ const left = typeof right === "number" ? (leftStr === "" ? NaN : Number(leftStr)) : leftStr;
397
+ switch (op) {
398
+ case "==": case "===": return left === right;
399
+ case "!=": case "!==": return left !== right;
400
+ case ">=": return Number(left) >= Number(right);
401
+ default: throw new Error(`operator ${op} is not simulated`);
402
+ }
403
+ }
404
+ /** Walk the flow on one fact: what it writes (entity_update), given the changes on the pod. */
405
+ function runFlow(f: Flow, input: Fact, changes: Change[]) {
406
+ const ctx: Record<string, any> = { trigger: { payload: { eventType: input.eventType, data: input.data } }, steps: {} };
407
+ const writes: { entityId: string; properties: Record<string, string> }[] = [];
408
+ const queue = f.nodes.filter((n) => n.type === "trigger").map((n) => n.id);
409
+ while (queue.length) {
410
+ const next = queue.shift()!;
411
+ const n = f.nodes.find((x) => x.id === next)!;
412
+ let handle: string | undefined;
413
+ if (n.type === "condition") {
414
+ handle = condition(n.data.expression, ctx) ? "yes" : "no";
415
+ ctx.steps[n.id] = { output: { result: handle === "yes" } };
416
+ } else if (n.type === "query") {
417
+ const filter = JSON.parse(render(n.data.filter, ctx)) as Record<string, string>;
418
+ const hits = changes.filter((c) => Object.entries(filter).every(([k, v]) => String(c.properties[k]) === v));
419
+ const entities = hits.slice(0, n.data.limit);
420
+ ctx.steps[n.id] = { output: { count: entities.length, entities } };
421
+ } else if (n.type === "output") {
422
+ expect(n.data.outputType).toBe("entity_update");
423
+ const props = Object.fromEntries(
424
+ Object.entries(n.data.config.properties as Record<string, string>).map(([k, v]) => [k, render(v, ctx)])
425
+ );
426
+ writes.push({ entityId: render(n.data.config.entityId, ctx), properties: props });
427
+ } else if (n.type !== "trigger") {
428
+ throw new Error(`node type ${n.type} is not simulated`);
429
+ }
430
+ for (const e of f.edges.filter((e) => e.source === n.id)) {
431
+ if (e.sourceHandle === undefined || e.sourceHandle === handle) queue.push(e.target);
432
+ }
433
+ }
434
+ return writes;
435
+ }
436
+ /** The flow with one node cut out, its predecessor wired straight to its successors. */
437
+ function without(id: string): Flow {
438
+ const into = flow.edges.filter((e) => e.target === id);
439
+ const out = flow.edges.filter((e) => e.source === id);
440
+ const kept = flow.edges.filter((e) => e.source !== id && e.target !== id);
441
+ const bridged = into.flatMap((i) => out.map((o) => ({ ...i, id: `${i.id}~${o.id}`, target: o.target })));
442
+ return { nodes: flow.nodes.filter((n) => n.id !== id), edges: [...kept, ...bridged] };
443
+ }
444
+
445
+ it("listens to dev.pr_merged only, passes the flow validator, and writes only Merged", () => {
446
+ expect(settles.triggerType).toBe("event");
447
+ // Not dev.*: every run of an entity-writing flow opens a session on the pod's one automation queue.
448
+ expect(settles.triggerConfig).toEqual({ eventPattern: "dev.pr_merged" });
449
+ expect(flow.nodes.find((n) => n.type === "trigger")!.data.config).toEqual({ eventPattern: "dev.pr_merged" });
450
+ expect(validateFlowDefinition(flow).errors).toEqual([]);
451
+ const outs = flow.nodes.filter((n) => n.type === "output");
452
+ expect(outs.map((n) => [n.data.outputType, n.data.config.properties])).toEqual([
453
+ ["entity_update", { changeStatus: "merged" }],
454
+ ]);
455
+ expect(options).toContain("merged");
456
+ });
457
+
458
+ it("finds the change by the prRef 'A pull request moves its change' writes", () => {
459
+ const find = flow.nodes.find((n) => n.type === "query")!;
460
+ expect(find.data.profileSlug).toBe("change");
461
+ expect(typeof find.data.filter).toBe("string");
462
+ const written = (node("upsert").data.config.properties.prRef as string).replace(/\{\{[^}]*\}\}/g, "x");
463
+ expect((JSON.parse(find.data.filter).prRef as string).replace(/\{\{[^}]*\}\}/g, "x")).toBe(written);
464
+ });
465
+
466
+ it("the recorded merge of backend#1530 settles its change, stuck in Checks running, and only it", () => {
467
+ expect(fact.eventType).toBe("dev.pr_merged");
468
+ expect(change1530.properties.changeStatus).toBe("checks");
469
+ expect(runFlow(flow, fact, recorded.changes)).toEqual([
470
+ { entityId: change1530.id, properties: { changeStatus: "merged" } },
471
+ ]);
472
+ });
473
+
474
+ it("a change already Merged moves nothing (and the case rules out dropping that condition)", () => {
475
+ const done = recorded.changes.map((c) => ({ ...c, properties: { ...c.properties, changeStatus: "merged" } }));
476
+ expect(runFlow(flow, fact, done)).toEqual([]);
477
+ expect(runFlow(without("not-merged"), fact, done)).not.toEqual([]);
478
+ });
479
+
480
+ it("a pull request with no change moves nothing (and the case rules out dropping that condition)", () => {
481
+ const none = recorded.changes.filter((c) => c.id !== change1530.id);
482
+ expect(runFlow(flow, fact, none)).toEqual([]);
483
+ expect(runFlow(without("has-change"), fact, none)).not.toEqual([]);
484
+ });
485
+
486
+ it("a merge into another branch moves nothing (and the case rules out dropping that condition)", () => {
487
+ const elsewhere = { ...fact, data: { ...fact.data, base: "release", intoDefault: false } };
488
+ expect(runFlow(flow, elsewhere, recorded.changes)).toEqual([]);
489
+ expect(runFlow(without("into-default"), elsewhere, recorded.changes)).not.toEqual([]);
490
+ });
491
+ });
package/src/templates.ts CHANGED
@@ -10366,6 +10366,133 @@ const DATA = {
10366
10366
  }
10367
10367
  ]
10368
10368
  }
10369
+ },
10370
+ {
10371
+ "key": "merged-pull-request-settles-change",
10372
+ "name": "A merged pull request settles its change",
10373
+ "description": "A dev.pr_merged fact into the default branch moves the pull request's change to Merged when GitHub's own event did not: a change already Merged, or a pull request with no change, moves nothing.",
10374
+ "triggerType": "event",
10375
+ "triggerConfig": {
10376
+ "eventPattern": "dev.pr_merged"
10377
+ },
10378
+ "status": "active",
10379
+ "flow": {
10380
+ "nodes": [
10381
+ {
10382
+ "id": "t",
10383
+ "type": "trigger",
10384
+ "position": {
10385
+ "x": 0,
10386
+ "y": 0
10387
+ },
10388
+ "data": {
10389
+ "label": "A pull request merged",
10390
+ "triggerType": "event",
10391
+ "config": {
10392
+ "eventPattern": "dev.pr_merged"
10393
+ }
10394
+ }
10395
+ },
10396
+ {
10397
+ "id": "into-default",
10398
+ "type": "condition",
10399
+ "position": {
10400
+ "x": 0,
10401
+ "y": 120
10402
+ },
10403
+ "data": {
10404
+ "label": "It merged into the default branch",
10405
+ "expression": "trigger.payload.data.intoDefault == \"true\""
10406
+ }
10407
+ },
10408
+ {
10409
+ "id": "find",
10410
+ "type": "query",
10411
+ "position": {
10412
+ "x": 0,
10413
+ "y": 240
10414
+ },
10415
+ "data": {
10416
+ "label": "Its change",
10417
+ "profileSlug": "change",
10418
+ "limit": 1,
10419
+ "filter": "{\"prRef\": \"{{trigger.payload.data.repo}}#{{trigger.payload.data.number}}\"}"
10420
+ }
10421
+ },
10422
+ {
10423
+ "id": "has-change",
10424
+ "type": "condition",
10425
+ "position": {
10426
+ "x": 0,
10427
+ "y": 360
10428
+ },
10429
+ "data": {
10430
+ "label": "It has a change",
10431
+ "expression": "steps.find.output.count >= 1"
10432
+ }
10433
+ },
10434
+ {
10435
+ "id": "not-merged",
10436
+ "type": "condition",
10437
+ "position": {
10438
+ "x": 0,
10439
+ "y": 480
10440
+ },
10441
+ "data": {
10442
+ "label": "Its change is not Merged yet",
10443
+ "expression": "steps.find.output.entities[0].properties.changeStatus != \"merged\""
10444
+ }
10445
+ },
10446
+ {
10447
+ "id": "settle",
10448
+ "type": "output",
10449
+ "position": {
10450
+ "x": 0,
10451
+ "y": 600
10452
+ },
10453
+ "data": {
10454
+ "label": "The change is Merged",
10455
+ "outputType": "entity_update",
10456
+ "config": {
10457
+ "entityId": "{{steps.find.output.entities[0].id}}",
10458
+ "properties": {
10459
+ "changeStatus": "merged"
10460
+ }
10461
+ }
10462
+ }
10463
+ }
10464
+ ],
10465
+ "edges": [
10466
+ {
10467
+ "id": "t--into-default",
10468
+ "source": "t",
10469
+ "target": "into-default"
10470
+ },
10471
+ {
10472
+ "id": "into-default--find",
10473
+ "source": "into-default",
10474
+ "target": "find",
10475
+ "sourceHandle": "yes"
10476
+ },
10477
+ {
10478
+ "id": "find--has-change",
10479
+ "source": "find",
10480
+ "target": "has-change"
10481
+ },
10482
+ {
10483
+ "id": "has-change--not-merged",
10484
+ "source": "has-change",
10485
+ "target": "not-merged",
10486
+ "sourceHandle": "yes"
10487
+ },
10488
+ {
10489
+ "id": "not-merged--settle",
10490
+ "source": "not-merged",
10491
+ "target": "settle",
10492
+ "sourceHandle": "yes"
10493
+ }
10494
+ ]
10495
+ }
10369
10496
  }
10370
10497
  ],
10371
10498
  "skills": [