spur-board 0.68.0 → 0.69.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.
@@ -1,5 +1,5 @@
1
- import { d as buildCatalogSnapshot, lt as configSchema, p as OPERATIONS, ut as plainHttpAllowed } from "./chunk-C11wvkRU.mjs";
2
- import { o as CliError, t as fetchCatalogVersion } from "./chunk-t6u2F3E-.mjs";
1
+ import { d as buildCatalogSnapshot, dt as configSchema, p as OPERATIONS, pt as plainHttpAllowed } from "./chunk-a_l5UPaU.mjs";
2
+ import { o as CliError, t as fetchCatalogVersion } from "./chunk-eiqYso44.mjs";
3
3
  import { randomUUID } from "node:crypto";
4
4
  import { closeSync, constants, fstatSync, lstatSync, mkdirSync, openSync, readFileSync, realpathSync, renameSync, statSync, unlinkSync, writeFileSync } from "node:fs";
5
5
  import { homedir } from "node:os";
@@ -55,6 +55,23 @@ const COLUMNS = [
55
55
  const COLUMN_IDS = COLUMNS.map((column) => column.id);
56
56
  /** Columns every project board has, enabled. */
57
57
  const REQUIRED_COLUMN_IDS = COLUMNS.filter((column) => column.required).map((column) => column.id);
58
+ /** Where a column's effective orchestrator comes from: its own column entry or top-level `spurProjects`. */
59
+ const COLUMN_BINDING_SOURCES = ["project", "board-wide"];
60
+ /**
61
+ * Where a project's effective operator comes from: its own `spurProjects`, top-level
62
+ * `spurProjects`, or, while no board-wide operator exists, another board project's list.
63
+ */
64
+ const OPERATOR_BINDING_SOURCES = [
65
+ "project",
66
+ "board-wide",
67
+ "other-project"
68
+ ];
69
+ /** Where the default Slack addressee comes from: `slack.defaultAddressee`, the board-wide operator or a project's operator. */
70
+ const ADDRESSEE_SOURCES = [
71
+ "config",
72
+ "board-wide",
73
+ "project"
74
+ ];
58
75
  /** Whether a task is on the board, outside the tracker filter, or archived. */
59
76
  const MEMBERSHIPS = [
60
77
  "active",
@@ -303,13 +320,15 @@ const spurProject = z.strictObject({
303
320
  });
304
321
  const DEFAULT_CYCLE_LIMIT = 10;
305
322
  const DEFAULT_COURSE_CHECK = 3;
323
+ /** A built-in column id; an unknown string names the built-in columns. */
324
+ const columnId = z.enum(COLUMN_IDS, { error: (issue) => typeof issue.input === "string" ? `Unknown column ${JSON.stringify(issue.input)}: custom columns arrive with custom matchers and are not supported yet. Built-in columns: ${COLUMN_IDS.join(", ")}` : void 0 });
306
325
  const columnConfig = z.strictObject({
307
- id: z.enum(COLUMN_IDS, { error: (issue) => typeof issue.input === "string" ? `Unknown column ${JSON.stringify(issue.input)}: custom columns arrive with custom matchers and are not supported yet. Built-in columns: ${COLUMN_IDS.join(", ")}` : void 0 }).describe("The built-in column this entry configures."),
326
+ id: columnId.describe("The built-in column this entry configures."),
308
327
  enabled: z.boolean().default(true).describe("false skips the column: tasks move past it and its exit condition is not checked. todo, dev and done cannot be disabled."),
309
- orchestrator: nonEmpty.default("none").describe("Who takes the column's turns. none: the task's live worker session, else the operator. operator: the operator, who also gets the questions asked in the column. Otherwise the name of a spurProjects entry with role orchestrator or curator whose sessions orchestrate the column and get the questions others ask in it."),
328
+ orchestrator: nonEmpty.default("none").describe("Who takes the column's turns. none: the task's live worker session, else the operator. operator: the operator, who also gets the questions asked in the column. Otherwise the name of a spurProjects entry with role orchestrator or curator whose sessions orchestrate the column and get the questions others ask in it. A column left at none, and enabled, takes the top-level spurProjects orchestrator that lists it."),
310
329
  cycleLimit: z.int().min(1).default(DEFAULT_CYCLE_LIMIT).describe("How many times a task may return to Dev from this column before the board stops it for the operator. Returns by the column executor, for external comments and for unresolved review threads count, a changes-requested review included (it is an external comment, not a separate return); a conflict, red CI and a draft do not."),
311
330
  courseCheck: z.int().min(0).default(DEFAULT_COURSE_CHECK).describe("How many returns to Dev from this column, counted as for cycleLimit, before the board holds the task and asks courseCheckTo (by default the curator, or the operator when the project has no curator) to check its course. The answer resets the count and reaches the worker as a task comment. 0 turns the check off; cycleLimit is checked first."),
312
- courseCheckTo: nonEmpty.optional().describe("Who answers this column's course check: operator, the curator's name, or the name of a column orchestrator. Without it, the curator, or the operator when the project has no curator. When the addressee has no live session the question moves to the operator; a conductor that is rung and does not answer keeps it, and the operator gets an item."),
331
+ courseCheckTo: nonEmpty.optional().describe("Who answers this column's course check: operator, the curator's name, or the name of a column orchestrator listed in this project's spurProjects; a board-wide orchestrator is refused. Without it, the curator, or the operator when the project has no curator. When the addressee has no live session the question moves to the operator; a conductor that is rung and does not answer keeps it, and the operator gets an item."),
313
332
  requireResolvedThreads: z.boolean().optional().describe("true: a task leaves this column, and every column right of it, only when its PR has no unresolved review thread; an unresolved one sends it back to Dev, and the worker's Dev turn lists each thread. Outdated threads count; a thread counts until someone resolves it, whoever wrote it. Defaults to true on ready-to-merge and false elsewhere; allowed on dev through ready-to-merge.")
314
333
  });
315
334
  /** Columns a task never leaves through the Dev gate, so they cannot require resolved threads. */
@@ -389,7 +408,7 @@ const projectSchema = z.strictObject({
389
408
  });
390
409
  curator ??= item.name;
391
410
  });
392
- }).default([]).describe("Spur projects whose sessions work on this board project, each with a role; at most one curator. Board commands from a session whose Spur project is in no spurProjects list are refused."),
411
+ }).default([]).describe("Spur projects whose sessions work on this board project, each with a role; at most one curator. An operator listed here replaces the top-level spurProjects operator for this project. Board commands from a session whose Spur project is in no spurProjects list, here or top-level, are refused."),
393
412
  columns: z.array(columnConfig).superRefine(checkBoard).default(() => COLUMN_IDS.map((id) => ({
394
413
  id,
395
414
  enabled: true,
@@ -512,13 +531,79 @@ function rejectSharedShortNames(items, ctx) {
512
531
  });
513
532
  });
514
533
  }
515
- /** The board config file. Every object rejects unknown keys; no key holds a secret. */
516
- const configSchema = z.strictObject({
534
+ /** A Spur project bound for every board project at once, in top-level `spurProjects`. */
535
+ const boardWideEntry = z.strictObject({
536
+ name: spurProject.shape.name.describe("The name of the project in Spur. It must not also be listed under any projects[].spurProjects, and none and operator are reserved."),
537
+ role: z.enum(["orchestrator", "operator"]).describe("orchestrator: sessions execute the listed columns in every board project that enables the column and leaves its orchestrator at none. operator: sessions act as the operator of every board project that lists no operator of its own; while one exists, a project's own operator acts only in its project. At most one operator."),
538
+ columns: z.array(columnId.describe("A built-in column this orchestrator executes.")).optional().describe("Required for role orchestrator, not allowed for operator. The columns it executes board-wide. A project column whose orchestrator is set to anything but none keeps it, and a disabled column is never filled; it must fill at least one column in some board project."),
539
+ shortName: spurProject.shape.shortName.describe("The name the operator types as @<shortName> at the start of a new message in the orchestrators channel to start a conversation with this Spur project's live session. Unique across the board, top-level and projects[].spurProjects alike."),
540
+ displayName: spurProject.shape.displayName.describe("The name Slack messages this Spur project's sessions write are posted under. Defaults to the Spur project name."),
541
+ icon: spurProject.shape.icon.describe("The emoji shortcode, such as :owl:, shown on those messages instead of the role icon.")
542
+ });
543
+ /** Checks within top-level `spurProjects`: R1 names, R2 reserved names, R3 shared columns, R6 operators, R8 columns. */
544
+ function checkBoardWide(items, ctx) {
545
+ rejectDuplicates(items, "name", "spur project name", ctx);
546
+ const bound = /* @__PURE__ */ new Map();
547
+ let operator;
548
+ items.forEach((item, i) => {
549
+ if (item.name === "none" || item.name === "operator") ctx.addIssue({
550
+ code: "custom",
551
+ path: [i, "name"],
552
+ message: `Spur project name ${JSON.stringify(item.name)} is reserved for columns[].orchestrator`
553
+ });
554
+ if (item.role === "operator") {
555
+ if (operator !== void 0) ctx.addIssue({
556
+ code: "custom",
557
+ path: [i, "role"],
558
+ message: `Second board-wide operator ${JSON.stringify(item.name)}: ${JSON.stringify(operator)} is already the board-wide operator`
559
+ });
560
+ operator ??= item.name;
561
+ if (item.columns !== void 0) ctx.addIssue({
562
+ code: "custom",
563
+ path: [i, "columns"],
564
+ message: `Board-wide operator ${JSON.stringify(item.name)} takes no columns: remove columns, or bind the column to operator in projects[].columns`
565
+ });
566
+ return;
567
+ }
568
+ if (item.columns === void 0 || item.columns.length === 0) {
569
+ ctx.addIssue({
570
+ code: "custom",
571
+ path: [i, "columns"],
572
+ message: `Board-wide orchestrator ${JSON.stringify(item.name)} needs columns: list the columns it executes`
573
+ });
574
+ return;
575
+ }
576
+ item.columns.forEach((column, j) => {
577
+ if (item.columns?.indexOf(column) !== j) {
578
+ ctx.addIssue({
579
+ code: "custom",
580
+ path: [i, "columns"],
581
+ message: `Duplicate column: ${JSON.stringify(column)}`
582
+ });
583
+ return;
584
+ }
585
+ const other = bound.get(column);
586
+ if (other === void 0) bound.set(column, item.name);
587
+ else ctx.addIssue({
588
+ code: "custom",
589
+ path: [
590
+ i,
591
+ "columns",
592
+ j
593
+ ],
594
+ message: `Column ${JSON.stringify(column)} is bound board-wide by ${JSON.stringify(other)} and ${JSON.stringify(item.name)}: bind it once`
595
+ });
596
+ });
597
+ });
598
+ }
599
+ /** The board config file before the checks across its sections. */
600
+ const configObject = z.strictObject({
517
601
  projects: z.array(projectSchema).min(1).superRefine((items, ctx) => {
518
602
  rejectDuplicates(items, "id", "project id", ctx);
519
603
  rejectSharedSpurProjects(items, ctx);
520
604
  rejectSharedShortNames(items, ctx);
521
- }).describe("Board projects, at least one. Each reads tasks from one tracker and PRs from its repos. A Spur project can be listed under only one board project."),
605
+ }).describe("Board projects, at least one. Each reads tasks from one tracker and PRs from its repos. A Spur project can be listed under only one board project; one that serves several goes in top-level spurProjects."),
606
+ spurProjects: z.array(boardWideEntry).superRefine(checkBoardWide).default([]).describe("Spur projects bound board-wide, each with role orchestrator or operator. A project-level binding wins for its own project. A Spur project here serves every board project it binds, and one of its sessions acts on the turns, inbox, questions and doorbells of each of them and no other."),
522
607
  operator: z.strictObject({ slack: nonEmpty.describe("Slack user ID of the operator, such as U0123456789. Slack commands, button presses and messages from anyone else are denied. A feed line the operator resolves names this user.") }),
523
608
  slack: z.strictObject({
524
609
  appName: z.string().trim().min(1).default(DEFAULT_SLACK_APP_NAME).describe("Slack app and bot display name that board slack manifest writes when --app-name is not given."),
@@ -528,7 +613,7 @@ const configSchema = z.strictObject({
528
613
  orchestrators: nonEmpty.optional().describe("Slack channel ID, such as C0123456789, where the board opens a thread for each block addressed to the operator by someone else. Once either channel is set, the daemon does not start without the other channel and SLACK_BOT_TOKEN, and without SLACK_APP_TOKEN it reads nothing from Slack."),
529
614
  feed: nonEmpty.optional().describe("Slack channel ID where the board posts a line for each curator answer, each newly installed version, each revoked operator token, each `/board tokens` list and each operator item, with the buttons the operator presses. Operator items about failed Slack posts, transport health, undelivered answers and ended workers, and those shown as operator blocks, get no feed line. A line whose item clears before it is first sent, such as an expired token request, is dropped. Set it together with orchestrators.")
530
615
  }).prefault({}),
531
- defaultAddressee: z.string().optional().describe("The shortName of the Spur project that gets a new orchestrators-channel message which does not start with a known @<shortName>. Without it, such a message gets one reply listing the valid prefixes. Ignored when no shortName is configured.")
616
+ defaultAddressee: z.string().optional().describe("The shortName, top-level or under projects[].spurProjects, of the Spur project that gets a new orchestrators-channel message which does not start with a known @<shortName>. Without it, such a message goes to the top-level spurProjects operator; without one, when any shortName is set, to the operator of the first board project that lists one; otherwise it gets one reply listing the valid prefixes, or is skipped when no shortName is configured.")
532
617
  }).prefault({}),
533
618
  thresholds: z.strictObject({
534
619
  staleMultiplier: z.number().min(1).default(3).describe("A source with no complete poll for this many of its poll intervals turns blind stale. board status marks that source, and an operator item whose fact is older than that, as stale."),
@@ -578,15 +663,193 @@ const configSchema = z.strictObject({
578
663
  maxEpisodeMs: durationMs(3e5, "Longest a host-load episode lasts before error flags resume")
579
664
  }).prefault({})
580
665
  }).prefault({})
581
- }).superRefine((config, ctx) => {
666
+ });
667
+ /** The project's copy of a top-level entry: its role and Slack identity, without `columns`. */
668
+ function boardWideCopy(entry) {
669
+ return {
670
+ name: entry.name,
671
+ role: entry.role,
672
+ ...entry.shortName === void 0 ? {} : { shortName: entry.shortName },
673
+ ...entry.displayName === void 0 ? {} : { displayName: entry.displayName },
674
+ ...entry.icon === void 0 ? {} : { icon: entry.icon }
675
+ };
676
+ }
677
+ /** Whether a board-wide orchestrator takes this column: listed, enabled and left at none. */
678
+ function fills(entry, column) {
679
+ return column.enabled && column.orchestrator === "none" && entry.columns?.includes(column.id) === true;
680
+ }
681
+ /**
682
+ * One board project with the top-level entries applied: an orchestrator fills each listed
683
+ * enabled column left at none, an operator joins a project without its own. Each entry that
684
+ * binds the project is appended to its `spurProjects`.
685
+ */
686
+ function expandProject(project, entries) {
687
+ const ownOperator = project.spurProjects.some((spur) => spur.role === "operator");
688
+ let columns = project.columns;
689
+ const added = [];
690
+ for (const entry of entries) {
691
+ if (entry.role === "operator") {
692
+ if (!ownOperator) added.push(boardWideCopy(entry));
693
+ continue;
694
+ }
695
+ if (!columns.some((column) => fills(entry, column))) continue;
696
+ columns = columns.map((column) => fills(entry, column) ? {
697
+ ...column,
698
+ orchestrator: entry.name
699
+ } : column);
700
+ added.push(boardWideCopy(entry));
701
+ }
702
+ if (added.length === 0) return project;
703
+ return {
704
+ ...project,
705
+ columns,
706
+ spurProjects: [...project.spurProjects, ...added]
707
+ };
708
+ }
709
+ function expandBoardWide(config) {
710
+ if (config.spurProjects.length === 0) return config;
711
+ return {
712
+ ...config,
713
+ projects: config.projects.map((project) => expandProject(project, config.spurProjects))
714
+ };
715
+ }
716
+ /** Checks between top-level `spurProjects` and the board projects: R4, R5, R7 and R9. */
717
+ function checkBoardWideAgainstProjects(config, ctx) {
718
+ const entries = config.spurProjects;
719
+ if (entries.length === 0) return;
720
+ const byName = new Map(entries.map((entry) => [entry.name, entry]));
721
+ config.projects.forEach((project, i) => {
722
+ project.spurProjects.forEach((spur, j) => {
723
+ if (!byName.has(spur.name)) return;
724
+ ctx.addIssue({
725
+ code: "custom",
726
+ path: [
727
+ "projects",
728
+ i,
729
+ "spurProjects",
730
+ j,
731
+ "name"
732
+ ],
733
+ message: `Spur project ${JSON.stringify(spur.name)} is bound board-wide in spurProjects and listed under projects[${project.id}].spurProjects as ${spur.role}: remove one; a board-wide Spur project serves every board project it binds`
734
+ });
735
+ });
736
+ });
737
+ const projectShortNames = new Set(config.projects.flatMap((project) => project.spurProjects.map((spur) => spur.shortName)));
738
+ const shortNames = /* @__PURE__ */ new Set();
739
+ entries.forEach((entry, i) => {
740
+ const name = JSON.stringify(entry.name);
741
+ if (entry.role === "orchestrator") {
742
+ if (!config.projects.some((project) => project.columns.some((c) => fills(entry, c)))) ctx.addIssue({
743
+ code: "custom",
744
+ path: [
745
+ "spurProjects",
746
+ i,
747
+ "columns"
748
+ ],
749
+ message: `Board-wide orchestrator ${name} executes no column: in every board project each listed column is missing, disabled or bound to another orchestrator`
750
+ });
751
+ } else if (config.projects.every((project) => project.spurProjects.some((spur) => spur.role === "operator"))) ctx.addIssue({
752
+ code: "custom",
753
+ path: [
754
+ "spurProjects",
755
+ i,
756
+ "name"
757
+ ],
758
+ message: `Board-wide operator ${name} serves no board project: every board project lists its own operator`
759
+ });
760
+ const { shortName } = entry;
761
+ if (shortName === void 0) return;
762
+ if (shortNames.has(shortName) || projectShortNames.has(shortName)) ctx.addIssue({
763
+ code: "custom",
764
+ path: [
765
+ "spurProjects",
766
+ i,
767
+ "shortName"
768
+ ],
769
+ message: `Duplicate short name: ${JSON.stringify(shortName)}`
770
+ });
771
+ shortNames.add(shortName);
772
+ });
773
+ }
774
+ /**
775
+ * The board config file. Every object rejects unknown keys; no key holds a secret. The parsed
776
+ * value has top-level `spurProjects` applied to every board project's columns and
777
+ * `spurProjects` (`expandBoardWide`), so readers of `projects[]` see the effective bindings.
778
+ */
779
+ const configSchema = configObject.superRefine(checkBoardWideAgainstProjects).superRefine((config, ctx) => {
582
780
  const addressee = config.slack.defaultAddressee;
583
781
  if (addressee === void 0) return;
584
- if (!config.projects.some((project) => project.spurProjects.some(({ shortName }) => shortName === addressee))) ctx.addIssue({
782
+ if (!(config.spurProjects.some(({ shortName }) => shortName === addressee) || config.projects.some((project) => project.spurProjects.some(({ shortName }) => shortName === addressee)))) ctx.addIssue({
585
783
  code: "custom",
586
784
  path: ["slack", "defaultAddressee"],
587
- message: `Unknown short name ${JSON.stringify(addressee)}: set it as projects[].spurProjects[].shortName first`
785
+ message: `Unknown short name ${JSON.stringify(addressee)}: set it as spurProjects[].shortName or projects[].spurProjects[].shortName first`
588
786
  });
589
- });
787
+ }).overwrite(expandBoardWide);
788
+ /** The top-level `spurProjects` entry named `name`: a Spur project bound board-wide. */
789
+ function boardWideSpurProject(config, name) {
790
+ return config.spurProjects.find((entry) => entry.name === name);
791
+ }
792
+ /**
793
+ * `slack.defaultAddressee`; else the board-wide operator; else, once any shortName is set, the
794
+ * operator of the first board project that lists one; else null.
795
+ */
796
+ function defaultAddressee(config) {
797
+ const projectSpurs = config.projects.flatMap((project) => project.spurProjects);
798
+ const named = config.slack.defaultAddressee;
799
+ if (named !== void 0) {
800
+ const spur = [...config.spurProjects, ...projectSpurs].find(({ shortName }) => shortName === named);
801
+ if (spur !== void 0) return {
802
+ spurProject: spur.name,
803
+ source: "config"
804
+ };
805
+ }
806
+ const boardWide = config.spurProjects.find((entry) => entry.role === "operator");
807
+ if (boardWide !== void 0) return {
808
+ spurProject: boardWide.name,
809
+ source: "board-wide"
810
+ };
811
+ if (![...config.spurProjects, ...projectSpurs].some(({ shortName }) => shortName !== void 0)) return null;
812
+ const operator = projectSpurs.find((spur) => spur.role === "operator");
813
+ return operator === void 0 ? null : {
814
+ spurProject: operator.name,
815
+ source: "project"
816
+ };
817
+ }
818
+ /**
819
+ * The effective column orchestrators and operators of `projects`, in config order, and the
820
+ * default Slack addressee. Columns that are disabled or left at none have no row. While no
821
+ * board-wide operator exists, each project also lists the other projects' operators, since those
822
+ * act on every board project then (`isOperator`).
823
+ */
824
+ function configBindings(config, projects) {
825
+ const source = (name) => boardWideSpurProject(config, name) === void 0 ? "project" : "board-wide";
826
+ const operatorsOf = (project) => project.spurProjects.filter((spur) => spur.role === "operator");
827
+ const boardWideOperator = config.spurProjects.some((entry) => entry.role === "operator");
828
+ const served = config.projects.filter((project) => projects.has(project.id));
829
+ return {
830
+ columns: served.flatMap((project) => project.columns.filter((column) => column.enabled && column.orchestrator !== "none").map((column) => ({
831
+ project: project.id,
832
+ column: column.id,
833
+ orchestrator: column.orchestrator,
834
+ source: source(column.orchestrator)
835
+ }))),
836
+ operators: served.flatMap((project) => {
837
+ const own = operatorsOf(project).map((spur) => ({
838
+ project: project.id,
839
+ operator: spur.name,
840
+ source: source(spur.name)
841
+ }));
842
+ if (boardWideOperator) return own;
843
+ const others = config.projects.filter((other) => other.id !== project.id).flatMap(operatorsOf).map((spur) => ({
844
+ project: project.id,
845
+ operator: spur.name,
846
+ source: "other-project"
847
+ }));
848
+ return [...own, ...others];
849
+ }),
850
+ defaultAddressee: defaultAddressee(config)
851
+ };
852
+ }
590
853
  /** Recognized names in the private secrets.env file; values never belong in config.yaml. */
591
854
  const SECRET_ENV_KEYS = [
592
855
  {
@@ -2581,6 +2844,24 @@ const reviewGates = [
2581
2844
  conditions: []
2582
2845
  }
2583
2846
  ];
2847
+ /** The effective column orchestrators and operators of the requested projects (`configBindings`). */
2848
+ const statusBindingsSchema = z.strictObject({
2849
+ columns: z.array(z.strictObject({
2850
+ project: z.string().min(1).describe("Board project."),
2851
+ column: z.enum(COLUMN_IDS).describe("Enabled column with an orchestrator."),
2852
+ orchestrator: z.string().min(1).describe("Spur project, or operator, that takes the column turns."),
2853
+ source: z.enum(COLUMN_BINDING_SOURCES).describe("project: set in projects[].columns; board-wide: filled from top-level spurProjects.")
2854
+ }).describe("One column binding.")).describe("Column orchestrators of each requested project; columns left at none are absent."),
2855
+ operators: z.array(z.strictObject({
2856
+ project: z.string().min(1).describe("Board project."),
2857
+ operator: z.string().min(1).describe("Spur project acting as operator there."),
2858
+ source: z.enum(OPERATOR_BINDING_SOURCES).describe("project: its own spurProjects; board-wide: top-level spurProjects; other-project: another project's operator, without a board-wide one.")
2859
+ }).describe("One operator binding.")).describe("Operator Spur projects of each requested project."),
2860
+ defaultAddressee: z.strictObject({
2861
+ spurProject: z.string().min(1).describe("Spur project the message goes to."),
2862
+ source: z.enum(ADDRESSEE_SOURCES).describe("config: slack.defaultAddressee; board-wide: the board-wide operator; project: the operator of the first board project, in config order, that lists one.")
2863
+ }).nullable().describe("Who an orchestrators-channel message without a known @shortName goes to; null when it is left unhandled or answered with the prefixes.")
2864
+ }).describe("Effective column orchestrators, operators and default Slack addressee.");
2584
2865
  const taskOutput = z.strictObject({ task: taskViewSchema });
2585
2866
  const blockOutput = z.strictObject({ block: blockViewSchema });
2586
2867
  const itemOutput = z.strictObject({ item: itemViewSchema });
@@ -2627,7 +2908,8 @@ const OPERATIONS = [
2627
2908
  unlinkedPrs: z.array(statusUnlinkedPrSchema).describe("Observed pull requests without a task link; merged or closed ones with no change for over 7 days are left out."),
2628
2909
  unlinkedSessions: z.array(statusUnlinkedSessionSchema).describe("Observed sessions without a task link; ones ended, or gone from Spur's session list, for over 7 days are left out."),
2629
2910
  hiddenUnlinkedPrs: z.int().min(0).describe("Unlinked pull requests not listed: merged or closed, with no change for over 7 days. Counted within the requested projects; detail does not list them."),
2630
- hiddenUnlinkedSessions: z.int().min(0).describe("Unlinked sessions not listed: ended, or gone from Spur's session list, for over 7 days. Counted within the requested projects; detail does not list them.")
2911
+ hiddenUnlinkedSessions: z.int().min(0).describe("Unlinked sessions not listed: ended, or gone from Spur's session list, for over 7 days. Counted within the requested projects; detail does not list them."),
2912
+ bindings: statusBindingsSchema
2631
2913
  }),
2632
2914
  grants: operatorOrProjectAgent,
2633
2915
  errors: ["not_found"],
@@ -2663,7 +2945,24 @@ const OPERATIONS = [
2663
2945
  unlinkedPrs: [],
2664
2946
  unlinkedSessions: [],
2665
2947
  hiddenUnlinkedPrs: 0,
2666
- hiddenUnlinkedSessions: 0
2948
+ hiddenUnlinkedSessions: 0,
2949
+ bindings: {
2950
+ columns: [{
2951
+ project: "web",
2952
+ column: "review",
2953
+ orchestrator: "web-review",
2954
+ source: "project"
2955
+ }],
2956
+ operators: [{
2957
+ project: "web",
2958
+ operator: "hq",
2959
+ source: "board-wide"
2960
+ }],
2961
+ defaultAddressee: {
2962
+ spurProject: "hq",
2963
+ source: "board-wide"
2964
+ }
2965
+ }
2667
2966
  }
2668
2967
  }, {
2669
2968
  summary: "Show the board with full facts and links",
@@ -2693,7 +2992,12 @@ const OPERATIONS = [
2693
2992
  unlinkedPrs: [],
2694
2993
  unlinkedSessions: [],
2695
2994
  hiddenUnlinkedPrs: 0,
2696
- hiddenUnlinkedSessions: 0
2995
+ hiddenUnlinkedSessions: 0,
2996
+ bindings: {
2997
+ columns: [],
2998
+ operators: [],
2999
+ defaultAddressee: null
3000
+ }
2697
3001
  }
2698
3002
  }]
2699
3003
  }),
@@ -4098,4 +4402,4 @@ function assertNever(value) {
4098
4402
  throw new Error(`Unexpected value: ${JSON.stringify(value)}`);
4099
4403
  }
4100
4404
  //#endregion
4101
- export { err as $, prSourceId as A, prFactsSchema as B, userIdSchema as C, AdapterError as D, eventPayloadSchemas as E, REVIEW_STATES as F, JIRA_PROJECT_KEY as G, ringMarker as H, SESSION_HEALTH_STATES as I, encodeActorId as J, REF_NUMBER as K, SESSION_STATUSES as L, sourceCursorSchema as M, trackerSourceId as N, batchSchema as O, PR_STATES as P, ERRORS as Q, isExternalAuthor as R, messageRefSchema as S, GATE_REASONS as T, sessionFactsSchema as U, prRefSchema as V, ticketFactsSchema as W, parseActorId as X, errorCodeOf as Y, parseRef as Z, renderMcpError as _, requestHashOf as a, DEFAULT_LINK as at, inboundEventSchema as b, tokenRequestStatusSchema as c, RESERVED_PROJECT as ct, buildCatalogSnapshot as d, requiredSecretKeys as dt, errorContextSchema as et, roleCanUseOperation as f, COLUMN_IDS as ft, renderJsonError as g, renderHttpProblem as h, TASK_HOLDS as ht, TOKEN_REQUEST_LIMITS as i, DEFAULT_HTTP_PORT as it, sessionTransitionSchema as j, entityRefSchema as k, BOARD_TICK_MS as l, configSchema as lt, turnHandedSchema as m, SLACK_BOT_SCOPES as mt, doctorReportSchema as n, ok as nt, tokenRequestResultSchema as o, DEFAULT_SLACK_APP_NAME as ot, OPERATIONS as p, DISPATCHER_MODES as pt, actorIdSchema as q, remoteDoctorReportSchema as r, successEnvelopeSchema as rt, tokenRequestSchema as s, DEFAULT_SLACK_COMMAND as st, assertNever as t, errorEnvelopeSchema as tt, SYSTEMD_SERVICE_SETTINGS as u, plainHttpAllowed as ut, SPACE_IDS as v, EVENT_KINDS as w, interactionRefSchema as x, conversationRefSchema as y, parseRingMarker as z };
4405
+ export { err as $, prSourceId as A, prFactsSchema as B, userIdSchema as C, AdapterError as D, eventPayloadSchemas as E, REVIEW_STATES as F, JIRA_PROJECT_KEY as G, ringMarker as H, SESSION_HEALTH_STATES as I, encodeActorId as J, REF_NUMBER as K, SESSION_STATUSES as L, sourceCursorSchema as M, trackerSourceId as N, batchSchema as O, PR_STATES as P, ERRORS as Q, isExternalAuthor as R, messageRefSchema as S, GATE_REASONS as T, sessionFactsSchema as U, prRefSchema as V, ticketFactsSchema as W, parseActorId as X, errorCodeOf as Y, parseRef as Z, renderMcpError as _, SLACK_BOT_SCOPES as _t, requestHashOf as a, DEFAULT_LINK as at, inboundEventSchema as b, tokenRequestStatusSchema as c, RESERVED_PROJECT as ct, buildCatalogSnapshot as d, configSchema as dt, errorContextSchema as et, roleCanUseOperation as f, defaultAddressee as ft, renderJsonError as g, DISPATCHER_MODES as gt, renderHttpProblem as h, COLUMN_IDS as ht, TOKEN_REQUEST_LIMITS as i, DEFAULT_HTTP_PORT as it, sessionTransitionSchema as j, entityRefSchema as k, BOARD_TICK_MS as l, boardWideSpurProject as lt, turnHandedSchema as m, requiredSecretKeys as mt, doctorReportSchema as n, ok as nt, tokenRequestResultSchema as o, DEFAULT_SLACK_APP_NAME as ot, OPERATIONS as p, plainHttpAllowed as pt, actorIdSchema as q, remoteDoctorReportSchema as r, successEnvelopeSchema as rt, tokenRequestSchema as s, DEFAULT_SLACK_COMMAND as st, assertNever as t, errorEnvelopeSchema as tt, SYSTEMD_SERVICE_SETTINGS as u, configBindings as ut, SPACE_IDS as v, TASK_HOLDS as vt, EVENT_KINDS as w, interactionRefSchema as x, conversationRefSchema as y, parseRingMarker as z };
@@ -1,4 +1,4 @@
1
- import { Q as ERRORS, c as tokenRequestStatusSchema, et as errorContextSchema, g as renderJsonError, o as tokenRequestResultSchema, rt as successEnvelopeSchema, tt as errorEnvelopeSchema } from "./chunk-C11wvkRU.mjs";
1
+ import { Q as ERRORS, c as tokenRequestStatusSchema, et as errorContextSchema, g as renderJsonError, o as tokenRequestResultSchema, rt as successEnvelopeSchema, tt as errorEnvelopeSchema } from "./chunk-a_l5UPaU.mjs";
2
2
  import { randomUUID } from "node:crypto";
3
3
  import { z } from "zod";
4
4
  import { request } from "node:http";
package/dist/cli.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import { Q as ERRORS, a as requestHashOf, dt as requiredSecretKeys, f as roleCanUseOperation, lt as configSchema, mt as SLACK_BOT_SCOPES, p as OPERATIONS, q as actorIdSchema, r as remoteDoctorReportSchema, rt as successEnvelopeSchema, u as SYSTEMD_SERVICE_SETTINGS } from "./chunk-C11wvkRU.mjs";
1
+ import { Q as ERRORS, _t as SLACK_BOT_SCOPES, a as requestHashOf, dt as configSchema, f as roleCanUseOperation, mt as requiredSecretKeys, p as OPERATIONS, q as actorIdSchema, r as remoteDoctorReportSchema, rt as successEnvelopeSchema, u as SYSTEMD_SERVICE_SETTINGS } from "./chunk-a_l5UPaU.mjs";
2
2
  import { t as apiBaseUrl } from "./chunk-DAMwWWmT.mjs";
3
- import { a as requestTokenEnrollment, c as renderCliError, i as requestSkillReload, l as escapeTerminalControls, n as fetchTokenStatus, o as CliError, r as requestOperation, s as errorExitCode } from "./chunk-t6u2F3E-.mjs";
4
- import { a as memoryVerdictCache, c as loadClientConfig, d as resolveDaemonAddress, f as tokenInFolder, i as fileVerdictCache, l as loadEnrollmentConfig, n as cliPackageVersion, o as configFile, s as dataDirectory, t as checkCatalog, u as readConfiguredPort } from "./chunk-AwNJBvcj.mjs";
3
+ import { a as requestTokenEnrollment, c as renderCliError, i as requestSkillReload, l as escapeTerminalControls, n as fetchTokenStatus, o as CliError, r as requestOperation, s as errorExitCode } from "./chunk-eiqYso44.mjs";
4
+ import { a as memoryVerdictCache, c as loadClientConfig, d as resolveDaemonAddress, f as tokenInFolder, i as fileVerdictCache, l as loadEnrollmentConfig, n as cliPackageVersion, o as configFile, s as dataDirectory, t as checkCatalog, u as readConfiguredPort } from "./chunk-CxD6ZAl9.mjs";
5
5
  import { createHash, randomBytes, randomUUID } from "node:crypto";
6
6
  import { accessSync, chmodSync, closeSync, constants, cpSync, existsSync, ftruncateSync, lstatSync, mkdirSync, openSync, readFileSync, readdirSync, readlinkSync, realpathSync, renameSync, rmSync, statSync, unlinkSync, writeFileSync, writeSync } from "node:fs";
7
7
  import { homedir, hostname, userInfo } from "node:os";
@@ -568,7 +568,7 @@ async function runDoctor(options = {}) {
568
568
  }
569
569
  }
570
570
  const unknown = [...states].filter(([, state]) => state === "unknown").map(([name]) => name);
571
- checks.push(configured.size === 0 ? result("skills.codex_visibility", true, codexVisibilityFix) : projectPaths === null ? warning("skills.codex_visibility", "Start Spur or correct adapters.spur.baseUrl in config.yaml, then rerun board doctor to check the Codex skill install.") : [...states.values()].includes("broken") ? result("skills.codex_visibility", false, codexVisibilityFix) : missing.length > 0 || unknown.length > 0 ? warning("skills.codex_visibility", [...missing.length > 0 ? [`Correct spurProjects in config.yaml or register these projects in Spur${listing(safeIds(missing))}.`] : [], ...unknown.length > 0 ? [`Check that projects.<id>.symlinks in each project's spur.yaml lists .agents/skills/spur-board${listing(safeIds(unknown))}.`] : []].join(" ")) : result("skills.codex_visibility", true, codexVisibilityFix));
571
+ checks.push(configured.size === 0 ? result("skills.codex_visibility", true, codexVisibilityFix) : projectPaths === null ? warning("skills.codex_visibility", "Start Spur or correct adapters.spur.baseUrl in config.yaml, then rerun board doctor to check the Codex skill install.") : [...states.values()].includes("broken") ? result("skills.codex_visibility", false, codexVisibilityFix) : missing.length > 0 || unknown.length > 0 ? warning("skills.codex_visibility", [...missing.length > 0 ? [`Correct spurProjects or projects[].spurProjects in config.yaml or register these projects in Spur${listing(safeIds(missing))}.`] : [], ...unknown.length > 0 ? [`Check that projects.<id>.symlinks in each project's spur.yaml lists .agents/skills/spur-board${listing(safeIds(unknown))}.`] : []].join(" ")) : result("skills.codex_visibility", true, codexVisibilityFix));
572
572
  const oldSessions = codexSessions.filter((session) => session.project !== void 0 && states.get(session.project) === "ok" && !(session.cwd !== void 0 && ports.exists(join(session.cwd, ".agents", "skills", "spur-board", "SKILL.md")) || session.codexHome !== void 0 && ports.exists(join(session.codexHome, "skills", "spur-board", "SKILL.md"))));
573
573
  checks.push(oldSessions.length > 0 ? warning("sessions.codex_skill", `Start new Spur sessions to replace Codex sessions created before the skill link${listing(safeIds([...new Set(oldSessions.map((session) => session.id))]))}; Spur links .agents/skills/spur-board only into new worktrees.`) : result("sessions.codex_skill", true, "Start new Spur sessions."));
574
574
  const version = ports.productVersion();
package/dist/client.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { a as requestTokenEnrollment, i as requestSkillReload, n as fetchTokenStatus, r as requestOperation, t as fetchCatalogVersion } from "./chunk-t6u2F3E-.mjs";
1
+ import { a as requestTokenEnrollment, i as requestSkillReload, n as fetchTokenStatus, r as requestOperation, t as fetchCatalogVersion } from "./chunk-eiqYso44.mjs";
2
2
  export { fetchCatalogVersion, fetchTokenStatus, requestOperation, requestSkillReload, requestTokenEnrollment };
package/dist/daemon.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as err, A as prSourceId, B as prFactsSchema, C as userIdSchema, D as AdapterError, E as eventPayloadSchemas, F as REVIEW_STATES, G as JIRA_PROJECT_KEY, H as ringMarker, I as SESSION_HEALTH_STATES, J as encodeActorId, K as REF_NUMBER, L as SESSION_STATUSES, M as sourceCursorSchema, N as trackerSourceId, O as batchSchema, P as PR_STATES, Q as ERRORS, R as isExternalAuthor, S as messageRefSchema, T as GATE_REASONS, U as sessionFactsSchema, V as prRefSchema, W as ticketFactsSchema, X as parseActorId, Y as errorCodeOf, Z as parseRef$1, a as requestHashOf, at as DEFAULT_LINK, b as inboundEventSchema, c as tokenRequestStatusSchema, ct as RESERVED_PROJECT, d as buildCatalogSnapshot, dt as requiredSecretKeys, f as roleCanUseOperation, ft as COLUMN_IDS, h as renderHttpProblem, ht as TASK_HOLDS, i as TOKEN_REQUEST_LIMITS, j as sessionTransitionSchema, k as entityRefSchema, l as BOARD_TICK_MS, lt as configSchema, m as turnHandedSchema, mt as SLACK_BOT_SCOPES, n as doctorReportSchema, nt as ok, o as tokenRequestResultSchema, p as OPERATIONS, pt as DISPATCHER_MODES, q as actorIdSchema, rt as successEnvelopeSchema, s as tokenRequestSchema, st as DEFAULT_SLACK_COMMAND, t as assertNever, ut as plainHttpAllowed, v as SPACE_IDS, w as EVENT_KINDS, x as interactionRefSchema, y as conversationRefSchema, z as parseRingMarker } from "./chunk-C11wvkRU.mjs";
1
+ import { $ as err, A as prSourceId, B as prFactsSchema, C as userIdSchema, D as AdapterError, E as eventPayloadSchemas, F as REVIEW_STATES, G as JIRA_PROJECT_KEY, H as ringMarker, I as SESSION_HEALTH_STATES, J as encodeActorId, K as REF_NUMBER, L as SESSION_STATUSES, M as sourceCursorSchema, N as trackerSourceId, O as batchSchema, P as PR_STATES, Q as ERRORS, R as isExternalAuthor, S as messageRefSchema, T as GATE_REASONS, U as sessionFactsSchema, V as prRefSchema, W as ticketFactsSchema, X as parseActorId, Y as errorCodeOf, Z as parseRef$1, _t as SLACK_BOT_SCOPES, a as requestHashOf, at as DEFAULT_LINK, b as inboundEventSchema, c as tokenRequestStatusSchema, ct as RESERVED_PROJECT, d as buildCatalogSnapshot, dt as configSchema, f as roleCanUseOperation, ft as defaultAddressee, gt as DISPATCHER_MODES, h as renderHttpProblem, ht as COLUMN_IDS, i as TOKEN_REQUEST_LIMITS, j as sessionTransitionSchema, k as entityRefSchema, l as BOARD_TICK_MS, lt as boardWideSpurProject, m as turnHandedSchema, mt as requiredSecretKeys, n as doctorReportSchema, nt as ok, o as tokenRequestResultSchema, p as OPERATIONS, pt as plainHttpAllowed, q as actorIdSchema, rt as successEnvelopeSchema, s as tokenRequestSchema, st as DEFAULT_SLACK_COMMAND, t as assertNever, ut as configBindings, v as SPACE_IDS, vt as TASK_HOLDS, w as EVENT_KINDS, x as interactionRefSchema, y as conversationRefSchema, z as parseRingMarker } from "./chunk-a_l5UPaU.mjs";
2
2
  import { t as apiBaseUrl } from "./chunk-DAMwWWmT.mjs";
3
3
  import { createRequire } from "node:module";
4
4
  import { createHash, randomUUID } from "node:crypto";
@@ -496,11 +496,24 @@ function projectTarget(project) {
496
496
  }
497
497
  };
498
498
  }
499
- /** True for the operator token and for a session of a Spur project with the `operator` role. */
500
- function isOperator(actor, config) {
499
+ /**
500
+ * True for the operator token and for a session of an operator Spur project. Without a
501
+ * board-wide operator, every operator Spur project acts on every board project, as before
502
+ * top-level `spurProjects`. With one, a session acts as operator on `project` only when that
503
+ * project lists its Spur project as operator, and on no project (`null`) only for the
504
+ * board-wide operator.
505
+ */
506
+ function isOperator(actor, config, project) {
501
507
  if (actor === "operator") return true;
502
508
  const parsed = parseActorId(actor);
503
- return parsed?.actor === "agent" && config.projects.some((project) => project.spurProjects.some((spur) => spur.name === parsed.actorRef.project && spur.role === "operator"));
509
+ if (parsed?.actor !== "agent") return false;
510
+ const name = parsed.actorRef.project;
511
+ const operatorIn = (entry) => entry.spurProjects.some((spur) => spur.name === name && spur.role === "operator");
512
+ const boardWide = config.spurProjects.find((entry) => entry.role === "operator");
513
+ if (boardWide === void 0) return config.projects.some(operatorIn);
514
+ if (project === null) return name === boardWide.name;
515
+ const target = config.projects.find((entry) => entry.id === project);
516
+ return target !== void 0 && operatorIn(target);
504
517
  }
505
518
  /** The Spur project that curates one board project, or null when it has none. */
506
519
  function curatorProject(config, projectId) {
@@ -512,7 +525,7 @@ function worker(actor, target) {
512
525
  }
513
526
  function orchestrator$1(actor, target, config, column) {
514
527
  const configured = config.projects.find((entry) => entry.id === target.project)?.columns.find((entry) => entry.id === column)?.orchestrator;
515
- if (configured === "operator") return isOperator(actor, config);
528
+ if (configured === "operator") return isOperator(actor, config, target.project);
516
529
  const parsed = parseActorId(actor);
517
530
  return parsed?.actor === "agent" && configured !== "none" && configured === parsed.actorRef.project;
518
531
  }
@@ -537,7 +550,7 @@ function blockAuthor(actor, target, config) {
537
550
  function matches(rule, actor, target, config) {
538
551
  const parsed = parseActorId(actor);
539
552
  switch (rule.grant) {
540
- case "operator": return isOperator(actor, config);
553
+ case "operator": return isOperator(actor, config, target.project);
541
554
  case "project-agent": return parsed?.actor === "agent" && config.projects.find((project) => project.id === target.project)?.spurProjects.some((spur) => spur.name === parsed.actorRef.project) === true;
542
555
  case "task-worker": return worker(actor, target);
543
556
  case "column-orchestrator": return target.task !== null && orchestrator$1(actor, target, config, target.task.column);
@@ -547,7 +560,7 @@ function matches(rule, actor, target, config) {
547
560
  if (spur !== null) return parsed?.actor === "agent" && parsed.actorRef.project === spur;
548
561
  const addressee = parseAddressee(target.block.addressee_role);
549
562
  switch (addressee.kind) {
550
- case "operator": return isOperator(actor, config);
563
+ case "operator": return isOperator(actor, config, target.project);
551
564
  case "curator": return parsed?.actor === "agent" && parsed.actorRef.project === curatorProject(config, target.project);
552
565
  case "worker": return worker(actor, target);
553
566
  case "orchestrator": return orchestrator$1(actor, target, config, addressee.column);
@@ -563,7 +576,7 @@ function authorize(grants, actor, state) {
563
576
  const rules = grants.filter((rule) => rule.mode === void 0 || rule.mode === state.mode);
564
577
  const hint = `Allowed role: ${[...new Set(rules.map((rule) => rule.grant))].join(", ") || "none"}.`;
565
578
  if (state.target.kind === "missing") {
566
- if (rules.some((rule) => rule.grant === "operator" && isOperator(actor, state.config))) return { status: "allowed" };
579
+ if (rules.some((rule) => rule.grant === "operator" && isOperator(actor, state.config, null))) return { status: "allowed" };
567
580
  return rules.every((rule) => rule.grant === "operator") ? {
568
581
  status: "denied",
569
582
  hint
@@ -9529,9 +9542,8 @@ function orchestrator(config, task) {
9529
9542
  * column, an agent is the curator or a worker.
9530
9543
  */
9531
9544
  function authorRole(config, subject, actor) {
9532
- if (actor === "operator") return "operator";
9545
+ if (isOperator(actor, config, subject.project)) return "operator";
9533
9546
  const parsed = parseActorId(actor);
9534
- if (parsed?.actor === "agent" && config.projects.some((project) => project.spurProjects.some((spur) => spur.name === parsed.actorRef.project && spur.role === "operator"))) return "operator";
9535
9547
  if (parsed?.actor !== "agent") return "worker";
9536
9548
  const { task } = subject;
9537
9549
  if (task !== null && parsed.actorRef.project === orchestrator(config, task)) return `orchestrator:${task.column}`;
@@ -9679,7 +9691,7 @@ function feedTime(at, config, date = false) {
9679
9691
  }
9680
9692
  /** Who acted, for a non-system actor: an agent by its session, else the operator's mention. */
9681
9693
  function actorInline(by, parsed, config) {
9682
- return parsed.actor === "agent" && !isOperator(by, config) ? {
9694
+ return parsed.actor === "agent" && !isOperator(by, config, null) ? {
9683
9695
  kind: "text",
9684
9696
  text: `${parsed.actorRef.project}/${parsed.actorRef.session}`
9685
9697
  } : {
@@ -11030,7 +11042,7 @@ function sessionActor(project, session, config) {
11030
11042
  if (!actor.success) throw new CommandError("forbidden", "Invalid session identity.");
11031
11043
  const matches = config.projects.filter((entry) => entry.spurProjects.some((spur) => spur.name === project));
11032
11044
  if (matches.length === 0) throw new CommandError("forbidden", `Spur project "${project}" is not listed in any spurProjects in the Board's config.yaml (not Spur's spur.yaml), and inside a Spur session a token is not used. Ask the operator to add it under projects[].spurProjects there and restart the Board daemon, or run the command outside a Spur session.`);
11033
- if (matches.length > 1) throw new CommandError("forbidden", `Spur project "${project}" is listed under several Board projects: ${matches.map((entry) => entry.id).join(", ")}. Ask the operator to keep it under one of them in the Board's config.yaml (not Spur's spur.yaml) and restart the Board daemon.`);
11045
+ if (matches.length > 1 && boardWideSpurProject(config, project) === void 0) throw new CommandError("forbidden", `Spur project "${project}" is listed under several Board projects: ${matches.map((entry) => entry.id).join(", ")}. Ask the operator to keep it under one of them in the Board's config.yaml (not Spur's spur.yaml) and restart the Board daemon.`);
11034
11046
  return actor.data;
11035
11047
  }
11036
11048
  /** Resolve the caller at the HTTP boundary; a session header always outranks a token. */
@@ -12636,8 +12648,15 @@ function createMembershipMutations(config) {
12636
12648
  return {
12637
12649
  add: {
12638
12650
  id: "task.add",
12639
- resolveTargets() {
12640
- return Promise.resolve([]);
12651
+ async resolveTargets(trx, input) {
12652
+ let canonical;
12653
+ try {
12654
+ canonical = canonicalKey(config, input.task);
12655
+ } catch {
12656
+ return [];
12657
+ }
12658
+ const task = await trx.selectFrom("task").selectAll().where("project", "=", canonical.project.id).where("key", "=", canonical.key).executeTakeFirst();
12659
+ return task === void 0 ? [] : [await authorizationTarget(trx, task)];
12641
12660
  },
12642
12661
  async run(trx, input, ctx) {
12643
12662
  const { project, key } = canonicalKey(config, input.task);
@@ -13477,6 +13496,20 @@ async function deliveryTask(trx, item) {
13477
13496
  if (row.kind !== "doorbell") return void 0;
13478
13497
  return ringTask(trx, typeof payload.notificationId === "number" ? payload.notificationId : void 0, row.dedupe_key);
13479
13498
  }
13499
+ /** The task an item belongs to: its own, else its delivery's; undefined for a board item. */
13500
+ async function itemOwner(trx, item) {
13501
+ return item.task_id === null ? deliveryTask(trx, item) : trx.selectFrom("task").selectAll().where("id", "=", item.task_id).executeTakeFirst();
13502
+ }
13503
+ /**
13504
+ * An item of a task is that task's project's; a board item or an unknown ID has no target, so
13505
+ * only the board-wide operator or the token may act on it, and `run` raises the unknown ID.
13506
+ */
13507
+ async function itemTarget(trx, input) {
13508
+ const item = await trx.selectFrom("operator_item").selectAll().where("id", "=", Number(input.item.slice(1))).executeTakeFirst();
13509
+ if (item === void 0) return [];
13510
+ const owner = await itemOwner(trx, item);
13511
+ return owner === void 0 ? [] : [await authorizationTarget(trx, owner)];
13512
+ }
13480
13513
  function view(item, task) {
13481
13514
  return { item: {
13482
13515
  id: `I${String(item.id)}`,
@@ -13525,7 +13558,7 @@ function createItemMutations(deps) {
13525
13558
  return {
13526
13559
  retry: {
13527
13560
  id: "item.retry",
13528
- resolveTargets: () => Promise.resolve([]),
13561
+ resolveTargets: itemTarget,
13529
13562
  async run(trx, input, ctx) {
13530
13563
  const { item, task } = await loadItem(trx, input.item);
13531
13564
  if ((task ?? await deliveryTask(trx, item))?.membership === "archived") throw new CommandError("task_archived", "Add the task again before retrying its item.");
@@ -13536,7 +13569,7 @@ function createItemMutations(deps) {
13536
13569
  },
13537
13570
  close: {
13538
13571
  id: "item.close",
13539
- resolveTargets: () => Promise.resolve([]),
13572
+ resolveTargets: itemTarget,
13540
13573
  async run(trx, input, ctx) {
13541
13574
  const { item, task } = await loadItem(trx, input.item);
13542
13575
  if (item.cleared_at === null) {
@@ -13871,6 +13904,7 @@ async function getStatus(deps, options = {}) {
13871
13904
  const { store, config, clock, completeSince, gateways = [] } = deps;
13872
13905
  const { project: projectId, visibleProjects, detail = false } = options;
13873
13906
  const includeBoardItems = options.includeBoardItems ?? visibleProjects === void 0;
13907
+ const operatorProjects = options.operatorProjects ?? /* @__PURE__ */ new Set();
13874
13908
  const projects = projectId === void 0 ? config.projects.filter((project) => visibleProjects === void 0 || visibleProjects.has(project.id)) : config.projects.filter((project) => project.id === projectId && (visibleProjects === void 0 || visibleProjects.has(project.id)));
13875
13909
  if (projects.length === 0) throw new CommandError("not_found", "Check the project ID.");
13876
13910
  const projectIds = new Set(projects.map((project) => project.id));
@@ -14018,7 +14052,17 @@ async function getStatus(deps, options = {}) {
14018
14052
  });
14019
14053
  const itemRows = await store.db.selectFrom("operator_item").selectAll().where("cleared_at", "is", null).execute();
14020
14054
  const itemTasks = new Map(rows.map((task) => [task.id, task]));
14021
- const items = itemRows.filter((item) => item.task_id !== null ? projectIds.has(itemTasks.get(item.task_id)?.project ?? "") : item.source !== null ? required.has(item.source) : includeBoardItems).map((item) => {
14055
+ const ownedProjects = /* @__PURE__ */ new Map();
14056
+ if (!includeBoardItems && operatorProjects.size > 0) for (const item of itemRows) {
14057
+ if (item.task_id !== null || item.source !== null) continue;
14058
+ const owner = await itemOwner(store.db, item);
14059
+ if (owner !== void 0) ownedProjects.set(item.id, owner.project);
14060
+ }
14061
+ const ownedBy = (item) => {
14062
+ const owner = ownedProjects.get(item.id) ?? "";
14063
+ return projectIds.has(owner) && operatorProjects.has(owner);
14064
+ };
14065
+ const items = itemRows.filter((item) => item.task_id !== null ? projectIds.has(itemTasks.get(item.task_id)?.project ?? "") : item.source !== null ? required.has(item.source) : includeBoardItems || ownedBy(item)).map((item) => {
14022
14066
  const source = item.source === null ? null : sourceById.get(item.source);
14023
14067
  const unconfirmed = item.fact_at !== null && item.source !== null && clock.now() - Date.parse(item.fact_at) > config.thresholds.staleMultiplier * interval(config, item.source) || item.text.includes("no_access") || source !== null && source !== void 0 && source.blind_reason !== null;
14024
14068
  const time = item.fact_at === null ? null : new Date(item.fact_at).toISOString().slice(11, 16);
@@ -14066,7 +14110,8 @@ async function getStatus(deps, options = {}) {
14066
14110
  unlinkedPrs,
14067
14111
  unlinkedSessions,
14068
14112
  hiddenUnlinkedPrs: prRows.length - unlinkedPrs.length,
14069
- hiddenUnlinkedSessions: sessionRows.length - unlinkedSessions.length
14113
+ hiddenUnlinkedSessions: sessionRows.length - unlinkedSessions.length,
14114
+ bindings: configBindings(config, projectIds)
14070
14115
  };
14071
14116
  }
14072
14117
  const HOLD_ONLY = /* @__PURE__ */ new Set([
@@ -16930,6 +16975,10 @@ function createOperationRegistry(deps) {
16930
16975
  config,
16931
16976
  target: { kind: "missing" }
16932
16977
  }).status === "allowed",
16978
+ operatorProjects: new Set(config.projects.filter((project) => authorize([{ grant: "operator" }], actor, {
16979
+ config,
16980
+ target: projectTarget(project.id)
16981
+ }).status === "allowed").map((project) => project.id)),
16933
16982
  detail: input.detail
16934
16983
  });
16935
16984
  }
@@ -16989,12 +17038,16 @@ async function curatorSessions(db, config) {
16989
17038
  });
16990
17039
  return entries;
16991
17040
  }
16992
- /** Configured orchestrators and the same live session selected for their rings. */
17041
+ /**
17042
+ * Configured orchestrators, where each binding comes from, and the same live session selected
17043
+ * for their rings.
17044
+ */
16993
17045
  async function orchestratorSessions(db, config) {
16994
17046
  const entries = [];
16995
17047
  for (const project of config.projects) for (const spur of project.spurProjects.filter((entry) => entry.role === "orchestrator")) entries.push({
16996
17048
  project: project.id,
16997
17049
  orchestrator: spur.name,
17050
+ source: boardWideSpurProject(config, spur.name) === void 0 ? "project" : "board-wide",
16998
17051
  session: (await bestProjectSession(db, spur.name))?.id ?? null,
16999
17052
  columns: project.columns.filter((column) => column.orchestrator !== "none" && column.orchestrator !== "operator" && column.orchestrator === spur.name).map((column) => column.id)
17000
17053
  });
@@ -18122,19 +18175,18 @@ function commandReply(id, value, input) {
18122
18175
  function addressOperatorMessage(text, config) {
18123
18176
  const spurByShortName = /* @__PURE__ */ new Map();
18124
18177
  for (const project of config.projects) for (const spur of project.spurProjects) if (spur.shortName !== void 0) spurByShortName.set(spur.shortName, spur.name);
18125
- if (spurByShortName.size === 0) return null;
18126
18178
  const prefix = /^@(\S+)\s*/.exec(text);
18127
18179
  const named = prefix?.[1] === void 0 ? void 0 : spurByShortName.get(prefix[1]);
18128
18180
  if (prefix?.[1] !== void 0 && named !== void 0) return {
18129
18181
  spur: named,
18130
18182
  text: stripShortName(text, prefix[1])
18131
18183
  };
18132
- const fallback = config.slack.defaultAddressee;
18133
- const fallbackSpur = fallback === void 0 ? void 0 : spurByShortName.get(fallback);
18134
- if (fallbackSpur !== void 0) return {
18135
- spur: fallbackSpur,
18184
+ const fallback = defaultAddressee(config);
18185
+ if (fallback !== null) return {
18186
+ spur: fallback.spurProject,
18136
18187
  text
18137
18188
  };
18189
+ if (spurByShortName.size === 0) return null;
18138
18190
  return { hint: `No addressee. Start with one of: ${[...spurByShortName.keys()].map((name) => `@${name}`).join(", ")}.` };
18139
18191
  }
18140
18192
  /**
@@ -18155,8 +18207,10 @@ async function namedTask(trx, config, project, text) {
18155
18207
  return trx.selectFrom("task").selectAll().where("key", "=", key).where("project", "=", project).where("membership", "!=", "archived").executeTakeFirst();
18156
18208
  }
18157
18209
  /**
18158
- * Opens the conversation an operator's new message starts, or posts the hint in its thread.
18159
- * Returns false, and writes nothing, when no short name is configured.
18210
+ * Opens the conversation an operator's new message starts, or posts the hint in its thread. The
18211
+ * block goes on the task its text names in the first board project listing the addressee that
18212
+ * has that task, else on the first such project. Returns false, and writes nothing, when no short
18213
+ * name and no default addressee exist.
18160
18214
  */
18161
18215
  async function openOperatorConversation(trx, input) {
18162
18216
  const { config } = input;
@@ -18170,11 +18224,16 @@ async function openOperatorConversation(trx, input) {
18170
18224
  });
18171
18225
  return true;
18172
18226
  }
18173
- const project = config.projects.find((entry) => entry.spurProjects.some((spur) => spur.name === address.spur));
18174
- if (project === void 0) return false;
18175
- const role = project.spurProjects.find((spur) => spur.name === address.spur)?.role === "curator" ? "curator" : "worker";
18176
- const task = await namedTask(trx, config, project.id, address.text);
18177
- const subject = task === void 0 ? projectSubject(project.id) : taskSubject(task);
18227
+ const candidates = config.projects.filter((entry) => entry.spurProjects.some((spur) => spur.name === address.spur));
18228
+ const first = candidates[0];
18229
+ if (first === void 0) return false;
18230
+ const role = first.spurProjects.find((spur) => spur.name === address.spur)?.role === "curator" ? "curator" : "worker";
18231
+ let task;
18232
+ for (const candidate of candidates) {
18233
+ task = await namedTask(trx, config, candidate.id, address.text);
18234
+ if (task !== void 0) break;
18235
+ }
18236
+ const subject = task === void 0 ? projectSubject(first.id) : taskSubject(task);
18178
18237
  const ctx = {
18179
18238
  actor: "operator",
18180
18239
  at: input.at
@@ -24049,10 +24108,10 @@ function curatorSessionsCheck(entries) {
24049
24108
  return warning(id, fitFix([...segments.filter((entry) => entry.problem), ...segments.filter((entry) => !entry.problem)], ` ${CURATOR_TAIL}`, `${String(missing)} curators have no live session. Start a Spur session of each.`));
24050
24109
  }
24051
24110
  function orchestratorSessionsCheck(entries) {
24052
- const segments = entries.map(({ project, orchestrator, session, columns }) => ({
24111
+ const segments = entries.map(({ project, orchestrator, source, session, columns }) => ({
24053
24112
  problem: session === null || columns.length === 0,
24054
24113
  unmatched: false,
24055
- text: () => `${project}: orchestrator ${orchestrator}, ${session === null ? "no live session" : `session ${session}`}, ${columns.length === 0 ? "unused by columns" : `columns ${columns.join(", ")}`}`
24114
+ text: () => `${project}: orchestrator ${orchestrator} (${source}), ${session === null ? "no live session" : `session ${session}`}, ${columns.length === 0 ? "unused by columns" : `columns ${columns.join(", ")}`}`
24056
24115
  }));
24057
24116
  const problems = segments.filter((entry) => entry.problem);
24058
24117
  const fix = fitFix([...problems, ...segments.filter((entry) => !entry.problem)], problems.length === 0 ? "" : " Assign a column and start a live session for each orchestrator.", `${String(entries.length)} orchestrators; ${String(problems.length)} need a column or live session.`);
@@ -24063,6 +24122,24 @@ function orchestratorSessionsCheck(entries) {
24063
24122
  fix
24064
24123
  } : warning("orchestrator.sessions", fix);
24065
24124
  }
24125
+ /** Each project's operator Spur projects with their source, then the default Slack addressee. */
24126
+ function operatorBindingsText(config) {
24127
+ const bindings = configBindings(config, new Set(config.projects.map((project) => project.id)));
24128
+ const segments = config.projects.flatMap((project) => {
24129
+ const rows = bindings.operators.filter((row) => row.project === project.id);
24130
+ if (rows.length === 0) return [];
24131
+ const names = rows.map((row) => `${row.operator} (${row.source})`).join(", ");
24132
+ return [{
24133
+ problem: false,
24134
+ unmatched: false,
24135
+ text: () => `${project.id}: operator ${names}`
24136
+ }];
24137
+ });
24138
+ const addressee = bindings.defaultAddressee;
24139
+ const tail = addressee === null ? "" : ` Default Slack addressee: ${addressee.spurProject} (${addressee.source}).`;
24140
+ const count = `${String(segments.length)} projects have an operator Spur project.`;
24141
+ return fitFix(segments, tail, `${count}${tail}`.length <= 300 ? `${count}${tail}` : count);
24142
+ }
24066
24143
  function check(id, ok, fix) {
24067
24144
  return {
24068
24145
  id,
@@ -24200,7 +24277,12 @@ async function runDaemonDoctor(ctx, productVersion, fetcher = fetch, { deadlineM
24200
24277
  }
24201
24278
  const operatorProject = config.projects.some((project) => project.spurProjects.some((spurProject) => spurProject.role === "operator"));
24202
24279
  const token = operatorProject ? void 0 : await ctx.store.db.selectFrom("operator_token").select("id").where("status", "=", "approved").executeTakeFirst();
24203
- checks.push(check("operator.path", operatorProject || token !== void 0, "Configure a Spur project with the operator role or approve a named operator token."));
24280
+ checks.push(operatorProject ? {
24281
+ id: "operator.path",
24282
+ status: "pass",
24283
+ blocking: false,
24284
+ fix: operatorBindingsText(config)
24285
+ } : check("operator.path", token !== void 0, "Configure a Spur project with the operator role or approve a named operator token."));
24204
24286
  checks.push(await operatorTokensCheck(ctx, config));
24205
24287
  checks.push(curatorSessionsCheck(await curatorSessions(ctx.store.db, config)));
24206
24288
  checks.push(orchestratorSessionsCheck(await orchestratorSessions(ctx.store.db, config)));
package/dist/mcp.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { Q as ERRORS, _ as renderMcpError, p as OPERATIONS } from "./chunk-C11wvkRU.mjs";
2
- import { o as CliError, r as requestOperation } from "./chunk-t6u2F3E-.mjs";
3
- import { a as memoryVerdictCache, c as loadClientConfig, r as compareCatalogs, t as checkCatalog } from "./chunk-AwNJBvcj.mjs";
1
+ import { Q as ERRORS, _ as renderMcpError, p as OPERATIONS } from "./chunk-a_l5UPaU.mjs";
2
+ import { o as CliError, r as requestOperation } from "./chunk-eiqYso44.mjs";
3
+ import { a as memoryVerdictCache, c as loadClientConfig, r as compareCatalogs, t as checkCatalog } from "./chunk-CxD6ZAl9.mjs";
4
4
  import { randomUUID } from "node:crypto";
5
5
  import { readFileSync } from "node:fs";
6
6
  import { z } from "zod";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spur-board",
3
- "version": "0.68.0",
3
+ "version": "0.69.0",
4
4
  "license": "MIT",
5
5
  "engines": {
6
6
  "node": "^24.12.0 || ^26.0.0"
@@ -14,6 +14,10 @@ Each column has one executor: `projects[].columns[].orchestrator`:
14
14
  `projects[].spurProjects[].role` accepts `worker`, `operator`, `curator` and
15
15
  `orchestrator`.
16
16
 
17
+ Top-level `spurProjects[].columns` fills `none` columns board-wide;
18
+ `role: operator` there serves operatorless projects, one session acting in
19
+ each. A project-level binding wins.
20
+
17
21
  ## Gates and placement
18
22
 
19
23
  Facts (head, checks, reviews, comments, ticket, sessions) feed gates; two actions: move the task and open an executor turn (at most one
@@ -24,7 +28,7 @@ Moves, turns and course checks need `projects[].dispatcher.mode: on`;
24
28
  default is `shadow`: no doorbells or blocks.
25
29
 
26
30
  Gates are cumulative: each column checks its enabled gate and those to its left. At a turn boundary, failed gates return to the leftmost failing
27
- column. Pending CI, unknown
31
+ column. Taken turns hold until submit, return or a new head. Pending CI, unknown
28
32
  mergeability and incomplete comment history are waits. Downstream handoff waits
29
33
  for settled prerequisites; Dev can receive a repair turn.
30
34
 
@@ -148,18 +152,20 @@ others. Answer in the existing block thread.
148
152
 
149
153
  ## Slack addressing
150
154
 
151
- With `projects[].spurProjects[].shortName`, a new operator message in
155
+ With a `projects[].spurProjects[].shortName`, `spurProjects[].shortName` or
156
+ board-wide operator, a new operator message in
152
157
  `slack.channels.orchestrators` starts a conversation. A leading registered
153
158
  `@shortName` selects that Spur project and is stripped. With absent or unknown
154
- leading name, `slack.defaultAddressee` gets the complete text, retaining any
155
- unknown prefix; without it Board replies once with the valid prefixes.
159
+ leading name, complete text, retaining any
160
+ unknown prefix, goes to `slack.defaultAddressee`, else board-wide operator, else
161
+ first project with an operator; else Board replies once with the valid prefixes.
156
162
  Middle mentions or Slack `<@U…>` address nobody; unknown names cause no lookup
157
163
  error. The operator checks short-name collisions with workspace names.
158
164
  A task key after the prefix attaches it.
159
165
 
160
166
  Read `board inbox`; reply via `board answer`. Each operator thread message rings again; `close` or ✅ in the
161
- thread closes it. Replies use `projects[].spurProjects[].displayName` and `icon`.
162
- No session:
167
+ thread closes it. Replies use `projects[].spurProjects[].displayName` and `icon`, top-level ones too,
168
+ else project name and role icon (`board` for operator). No session:
163
169
  `board status` lists it as waiting.
164
170
 
165
171
  ## Done follows the ticket