spur-board 0.68.0 → 0.70.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.
@@ -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
  {
@@ -1201,6 +1464,20 @@ const checkSchema = z.strictObject({
1201
1464
  state: z.enum(CHECK_STATES).describe("State of the latest run of this check on the head commit."),
1202
1465
  completedAt: at$2.nullable().describe("When the latest run finished; null while it runs.")
1203
1466
  });
1467
+ /**
1468
+ * Link and edit fields a feedback entry and a handed entry share: the direct URL, the newest edit
1469
+ * and a review's inline comments.
1470
+ */
1471
+ const feedbackLinkShape = {
1472
+ url: webUrl.optional().describe("Web URL of the comment or review; missing in snapshots and handed entries written before it."),
1473
+ editedAt: at$2.optional().describe("When it was last edited; for a review the newest edit of its body or its inline comments. Missing when never edited or not yet read."),
1474
+ comments: z.array(z.strictObject({
1475
+ id: z.string().min(1).describe("Stable id of the inline review comment in the source."),
1476
+ url: webUrl.optional().describe("Web URL that opens the inline comment, a thread reply included, in its thread."),
1477
+ threadId: z.string().min(1).optional().describe("Id of the review thread the inline comment belongs to."),
1478
+ editedAt: at$2.optional().describe("When the inline comment was last edited; missing when never edited.")
1479
+ })).optional().describe("A review's inline comments, thread replies included, oldest first within each thread; missing for a comment and a review without inline comments.")
1480
+ };
1204
1481
  const feedbackSchema = z.strictObject({
1205
1482
  kind: z.enum(FEEDBACK_KINDS).describe("Whether this is a comment or a submitted review."),
1206
1483
  id: z.string().min(1).describe("Stable id of the comment or review in the source."),
@@ -1210,7 +1487,8 @@ const feedbackSchema = z.strictObject({
1210
1487
  }).nullable().describe("Who posted it; null for a deleted account."),
1211
1488
  postedAt: at$2.describe("When the comment was posted or the review submitted."),
1212
1489
  state: z.enum(REVIEW_STATES).optional().describe("State of this review; missing for a comment and in snapshots written before it."),
1213
- statusComment: z.literal(true).optional().describe("True for a status comment of a reviewer service, marked by its last line; it is not external feedback. Missing otherwise.")
1490
+ statusComment: z.literal(true).optional().describe("True for a status comment of a reviewer service, marked by its last line; it is not external feedback. Missing otherwise."),
1491
+ ...feedbackLinkShape
1214
1492
  });
1215
1493
  const prFactsSchema = z.strictObject({
1216
1494
  repo: repoSlugSchema.describe("Repository as owner/name."),
@@ -2127,6 +2405,57 @@ function defineOperation(spec) {
2127
2405
  };
2128
2406
  }
2129
2407
  //#endregion
2408
+ //#region ../contracts/src/ops/turn-schemas.ts
2409
+ /** One pull request comment or review a turn handed to its executor. */
2410
+ const turnHandedSchema = z.strictObject({
2411
+ ...prRefSchema.shape,
2412
+ kind: z.enum(FEEDBACK_KINDS).describe("Whether this is a comment or a submitted review."),
2413
+ id: z.string().min(1).describe("Stable id of the comment or review in the source."),
2414
+ postedAt: z.iso.datetime().describe("When the comment was posted or the review submitted, ISO 8601 UTC."),
2415
+ ...feedbackLinkShape
2416
+ }).describe("Pull request feedback a turn handed; an edit after the hand hands it again.");
2417
+ /** The return that opened the Dev visit a turn belongs to. */
2418
+ const turnReturnSchema = z.strictObject({
2419
+ by: actorIdSchema.describe("Who returned the task to Dev."),
2420
+ from: z.enum(COLUMN_IDS).describe("Column the task was returned from."),
2421
+ turn: turnIdSchema.describe("The turn the return closed."),
2422
+ block: blockIdSchema.describe("The code block the return opened."),
2423
+ reason: z.string().describe("Reason of the return, verbatim from its code block.")
2424
+ }).describe("The return that sent the task back to Dev and opened this visit.");
2425
+ const turnViewSchema = z.strictObject({
2426
+ id: turnIdSchema,
2427
+ task: taskKeySchema,
2428
+ column: z.enum(COLUMN_IDS).describe("Board column the turn belongs to."),
2429
+ addressee: z.enum(ADDRESSEE_ROLES).describe("Who executes the turn."),
2430
+ reason: z.string().describe("Why the turn was handed to the executor."),
2431
+ handed: z.array(turnHandedSchema).describe("Pull request feedback handed over with the turn."),
2432
+ returned: turnReturnSchema.optional().describe("The return that opened this Dev visit: who returned it, from which column, the closed turn, the code block and its reason. Missing when the visit did not start with a return."),
2433
+ head: commitShaSchema.nullable().describe("Head commit of the task's pull request when the turn was opened; null when the task had no pull request."),
2434
+ at: z.iso.datetime().describe("When the turn was opened, ISO 8601 UTC."),
2435
+ taken: z.strictObject({
2436
+ by: actorIdSchema,
2437
+ at: z.iso.datetime().describe("When the turn was taken, ISO 8601 UTC.")
2438
+ }).nullable().describe("Who took the turn and when; null until it is taken."),
2439
+ threads: z.array(z.strictObject({
2440
+ id: z.string().min(1).describe("Node ID of the review thread."),
2441
+ url: z.url({ protocol: /^https?$/ }).describe("Web URL of the thread's first comment."),
2442
+ outdated: z.boolean().describe("Whether the thread is on a diff line the head no longer has.")
2443
+ }).describe("One unresolved review thread.")).min(1).optional().describe("The unresolved review threads on the task's open pull request, read live, in a Dev turn of a project requiring resolved threads; absent when none, or when the pull request is closed, merged or missing. Fix or answer each thread, then resolve it.")
2444
+ }).describe("A turn: the executor of a column is asked to act on a task.");
2445
+ /** A turn as `task.get` shows it: who executes it, whether it was taken, and how it closed. */
2446
+ const taskTurnSchema = turnViewSchema.pick({
2447
+ id: true,
2448
+ column: true,
2449
+ addressee: true,
2450
+ at: true,
2451
+ taken: true,
2452
+ handed: true,
2453
+ returned: true
2454
+ }).extend({ closed: z.strictObject({
2455
+ at: z.iso.datetime().describe("When the turn closed, ISO 8601 UTC."),
2456
+ outcome: z.enum(TURN_OUTCOMES).describe("How the turn closed; turns closed by a return or a mode switch before those were recorded read moved.")
2457
+ }).nullable().describe("How and when the turn closed; null while it is open.") }).describe("A task's turn: the executor of a column is asked to act on it.");
2458
+ //#endregion
2130
2459
  //#region ../contracts/src/ops/schemas.ts
2131
2460
  /**
2132
2461
  * A comment as every output returns it. `untrusted` is always `true`: the text comes from a
@@ -2164,43 +2493,6 @@ const blockViewSchema = z.strictObject({
2164
2493
  unblockedBy: actorIdSchema.nullable().describe("Actor that unblocked the block; null while open."),
2165
2494
  unblockedAt: z.iso.datetime().nullable().describe("When the block was unblocked; null while open.")
2166
2495
  }).describe("A block on a task.");
2167
- /** One pull request comment or review a turn handed to its executor. */
2168
- const turnHandedSchema = z.strictObject({
2169
- ...prRefSchema.shape,
2170
- kind: z.enum(FEEDBACK_KINDS).describe("Whether this is a comment or a submitted review."),
2171
- id: z.string().min(1).describe("Stable id of the comment or review in the source."),
2172
- postedAt: z.iso.datetime().describe("When the comment was posted or the review submitted, ISO 8601 UTC.")
2173
- }).describe("Pull request feedback handed over with a turn.");
2174
- const turnViewSchema = z.strictObject({
2175
- id: turnIdSchema,
2176
- task: taskKeySchema,
2177
- column: z.enum(COLUMN_IDS).describe("Board column the turn belongs to."),
2178
- addressee: z.enum(ADDRESSEE_ROLES).describe("Who executes the turn."),
2179
- reason: z.string().describe("Why the turn was handed to the executor."),
2180
- handed: z.array(turnHandedSchema).describe("Pull request feedback handed over with the turn."),
2181
- head: commitShaSchema.nullable().describe("Head commit of the task's pull request when the turn was opened; null when the task had no pull request."),
2182
- at: z.iso.datetime().describe("When the turn was opened, ISO 8601 UTC."),
2183
- taken: z.strictObject({
2184
- by: actorIdSchema,
2185
- at: z.iso.datetime().describe("When the turn was taken, ISO 8601 UTC.")
2186
- }).nullable().describe("Who took the turn and when; null until it is taken."),
2187
- threads: z.array(z.strictObject({
2188
- id: z.string().min(1).describe("Node ID of the review thread."),
2189
- url: z.url({ protocol: /^https?$/ }).describe("Web URL of the thread's first comment."),
2190
- outdated: z.boolean().describe("Whether the thread is on a diff line the head no longer has.")
2191
- }).describe("One unresolved review thread.")).min(1).optional().describe("The unresolved review threads on the task's open pull request, read live, in a Dev turn of a project requiring resolved threads; absent when none, or when the pull request is closed, merged or missing. Fix or answer each thread, then resolve it.")
2192
- }).describe("A turn: the executor of a column is asked to act on a task.");
2193
- /** A turn as `task.get` shows it: who executes it, whether it was taken, and how it closed. */
2194
- const taskTurnSchema = turnViewSchema.pick({
2195
- id: true,
2196
- column: true,
2197
- addressee: true,
2198
- at: true,
2199
- taken: true
2200
- }).extend({ closed: z.strictObject({
2201
- at: z.iso.datetime().describe("When the turn closed, ISO 8601 UTC."),
2202
- outcome: z.enum(TURN_OUTCOMES).describe("How the turn closed; turns closed by a return or a mode switch before those were recorded read moved.")
2203
- }).nullable().describe("How and when the turn closed; null while it is open.") }).describe("A task's turn: the executor of a column is asked to act on it.");
2204
2496
  /** One column move from the journal: a dispatcher move, a return to Dev or a correction. */
2205
2497
  const moveViewSchema = z.strictObject({
2206
2498
  at: z.iso.datetime().describe("When the task moved, ISO 8601 UTC."),
@@ -2483,7 +2775,21 @@ const handedReview = {
2483
2775
  number: 42,
2484
2776
  kind: "review",
2485
2777
  id: "PRR_kwDOA1",
2486
- postedAt: at
2778
+ postedAt: at,
2779
+ url: "https://github.com/acme/web/pull/42#pullrequestreview-2001",
2780
+ comments: [{
2781
+ id: "PRRC_kwDOA2",
2782
+ url: "https://github.com/acme/web/pull/42#discussion_r3001",
2783
+ threadId: "PRRT_kwDOA3"
2784
+ }]
2785
+ };
2786
+ /** The return from Review that opened the Dev visit, with its code block. */
2787
+ const returnFromReview = {
2788
+ by: "agent:rev/rev-1",
2789
+ from: "review",
2790
+ turn: "T2",
2791
+ block: codeBlock.id,
2792
+ reason: codeBlock.reason
2487
2793
  };
2488
2794
  const submittedSha = "9f2c4e1b7a3d5c8e0f1a2b3c4d5e6f708192a3b4";
2489
2795
  const item = {
@@ -2581,6 +2887,24 @@ const reviewGates = [
2581
2887
  conditions: []
2582
2888
  }
2583
2889
  ];
2890
+ /** The effective column orchestrators and operators of the requested projects (`configBindings`). */
2891
+ const statusBindingsSchema = z.strictObject({
2892
+ columns: z.array(z.strictObject({
2893
+ project: z.string().min(1).describe("Board project."),
2894
+ column: z.enum(COLUMN_IDS).describe("Enabled column with an orchestrator."),
2895
+ orchestrator: z.string().min(1).describe("Spur project, or operator, that takes the column turns."),
2896
+ source: z.enum(COLUMN_BINDING_SOURCES).describe("project: set in projects[].columns; board-wide: filled from top-level spurProjects.")
2897
+ }).describe("One column binding.")).describe("Column orchestrators of each requested project; columns left at none are absent."),
2898
+ operators: z.array(z.strictObject({
2899
+ project: z.string().min(1).describe("Board project."),
2900
+ operator: z.string().min(1).describe("Spur project acting as operator there."),
2901
+ 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.")
2902
+ }).describe("One operator binding.")).describe("Operator Spur projects of each requested project."),
2903
+ defaultAddressee: z.strictObject({
2904
+ spurProject: z.string().min(1).describe("Spur project the message goes to."),
2905
+ 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.")
2906
+ }).nullable().describe("Who an orchestrators-channel message without a known @shortName goes to; null when it is left unhandled or answered with the prefixes.")
2907
+ }).describe("Effective column orchestrators, operators and default Slack addressee.");
2584
2908
  const taskOutput = z.strictObject({ task: taskViewSchema });
2585
2909
  const blockOutput = z.strictObject({ block: blockViewSchema });
2586
2910
  const itemOutput = z.strictObject({ item: itemViewSchema });
@@ -2627,7 +2951,8 @@ const OPERATIONS = [
2627
2951
  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
2952
  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
2953
  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.")
2954
+ 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."),
2955
+ bindings: statusBindingsSchema
2631
2956
  }),
2632
2957
  grants: operatorOrProjectAgent,
2633
2958
  errors: ["not_found"],
@@ -2663,7 +2988,24 @@ const OPERATIONS = [
2663
2988
  unlinkedPrs: [],
2664
2989
  unlinkedSessions: [],
2665
2990
  hiddenUnlinkedPrs: 0,
2666
- hiddenUnlinkedSessions: 0
2991
+ hiddenUnlinkedSessions: 0,
2992
+ bindings: {
2993
+ columns: [{
2994
+ project: "web",
2995
+ column: "review",
2996
+ orchestrator: "web-review",
2997
+ source: "project"
2998
+ }],
2999
+ operators: [{
3000
+ project: "web",
3001
+ operator: "hq",
3002
+ source: "board-wide"
3003
+ }],
3004
+ defaultAddressee: {
3005
+ spurProject: "hq",
3006
+ source: "board-wide"
3007
+ }
3008
+ }
2667
3009
  }
2668
3010
  }, {
2669
3011
  summary: "Show the board with full facts and links",
@@ -2693,7 +3035,12 @@ const OPERATIONS = [
2693
3035
  unlinkedPrs: [],
2694
3036
  unlinkedSessions: [],
2695
3037
  hiddenUnlinkedPrs: 0,
2696
- hiddenUnlinkedSessions: 0
3038
+ hiddenUnlinkedSessions: 0,
3039
+ bindings: {
3040
+ columns: [],
3041
+ operators: [],
3042
+ defaultAddressee: null
3043
+ }
2697
3044
  }
2698
3045
  }]
2699
3046
  }),
@@ -2741,9 +3088,13 @@ const OPERATIONS = [
2741
3088
  input: { task: "PROJ-123" },
2742
3089
  output: {
2743
3090
  task,
2744
- turn: devTurn,
3091
+ turn: {
3092
+ ...devTurn,
3093
+ handed: [handedReview],
3094
+ returned: returnFromReview
3095
+ },
2745
3096
  links: [],
2746
- blocks: [question],
3097
+ blocks: [question, codeBlock],
2747
3098
  comments: [comment]
2748
3099
  }
2749
3100
  },
@@ -2767,6 +3118,7 @@ const OPERATIONS = [
2767
3118
  by: "agent:rev/rev-1",
2768
3119
  at
2769
3120
  },
3121
+ handed: [],
2770
3122
  closed: null
2771
3123
  },
2772
3124
  links: [],
@@ -2814,10 +3166,12 @@ const OPERATIONS = [
2814
3166
  taken: {
2815
3167
  by: "agent:web/web-7",
2816
3168
  at: later
2817
- }
3169
+ },
3170
+ handed: []
2818
3171
  },
2819
3172
  turns: [{
2820
3173
  ...devTurn,
3174
+ handed: [],
2821
3175
  closed: {
2822
3176
  at: later,
2823
3177
  outcome: "submitted"
@@ -4098,4 +4452,4 @@ function assertNever(value) {
4098
4452
  throw new Error(`Unexpected value: ${JSON.stringify(value)}`);
4099
4453
  }
4100
4454
  //#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 };
4455
+ 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-BBfFVeh3.mjs";
2
2
  import { randomUUID } from "node:crypto";
3
3
  import { z } from "zod";
4
4
  import { request } from "node:http";
@@ -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-BBfFVeh3.mjs";
2
+ import { o as CliError, t as fetchCatalogVersion } from "./chunk-BxDheuT8.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";