@afokapu/atdd-flow 0.3.29 → 0.3.30

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/threads.ts +8 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@afokapu/atdd-flow",
3
- "version": "0.3.29",
3
+ "version": "0.3.30",
4
4
  "description": "Filesystem-first Desk registry for projects, seats, tasks, threads, and handoffs.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/threads.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { mkdir, readdir, rm, stat } from "node:fs/promises";
2
2
  import { join } from "node:path";
3
3
  import { notify } from "./adapters";
4
+ import { seatTasks } from "./tasks";
4
5
  import {
5
6
  atomicYaml, canonicalAddress, desk, has, id, now, paths, project, readYaml,
6
7
  required, runtimeAddress, seat, words,
@@ -82,6 +83,13 @@ async function assertRoute(root: string, from: string, recipients: string[]) {
82
83
  throw new Error(`${from} may not directly address operator@desk; route through the responsible coordinator and main seat.`);
83
84
  }
84
85
  if (sender.role === "driver" && targets.some((target) => target.role !== "coordinator")) {
86
+ // A driver may also reach the actual coordinator of its own non-done task in the same project (e.g. main).
87
+ const owners = new Set((await seatTasks(root, sender.project, from))
88
+ .filter(({ task }) => task.assignee === from && task.status !== "done")
89
+ .map(({ task }) => task.coordinator));
90
+ const permitted = (target: { address: string; role: string; project: string }) =>
91
+ target.role === "coordinator" || (target.project === sender.project && owners.has(target.address));
92
+ if (targets.every(permitted)) return;
85
93
  throw new Error(`${from} may message only a coordinator; coordinators and main seats handle further escalation.`);
86
94
  }
87
95
  }