Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

MUL-3508: stage sub-issues so the parent wakes per stage, not per child (#4410)

Bohan Jianga123dfc2df75
diff --git a/apps/mobile/data/schemas.ts b/apps/mobile/data/schemas.ts
index 8b8bce2923..f0f6aa613f 100644
--- a/apps/mobile/data/schemas.ts
+++ b/apps/mobile/data/schemas.ts
@@ -664,6 +664,7 @@ export const EMPTY_ISSUE_FALLBACK: import("@multica/core/types").Issue = {
parent_issue_id: null,
project_id: null,
position: 0,
+ stage: null,
start_date: null,
due_date: null,
metadata: {},
diff --git a/packages/core/api/schemas.test.ts b/packages/core/api/schemas.test.ts
index 95042ea565..4823c5116f 100644
--- a/packages/core/api/schemas.test.ts
+++ b/packages/core/api/schemas.test.ts
@@ -34,6 +34,7 @@ const baseIssue = {
parent_issue_id: null,
project_id: null,
position: 0,
+ stage: null,
start_date: null,
due_date: null,
metadata: {},
@@ -74,6 +75,19 @@ describe("IssueSchema (via ListIssuesResponseSchema)", () => {
};
expect(ListIssuesResponseSchema.safeParse(payload).success).toBe(false);
});
+
+ it("accepts a numeric stage", () => {
+ const payload = { issues: [{ ...baseIssue, stage: 2 }], total: 1 };
+ const parsed = ListIssuesResponseSchema.parse(payload);
+ expect(parsed.issues[0]?.stage).toBe(2);
+ });
+
+ it("defaults stage to null when the server omits it (older backend)", () => {
+ const { stage: _omit, ...issueWithoutStage } = baseIssue;
+ const payload = { issues: [issueWithoutStage], total: 1 };
+ const parsed = ListIssuesResponseSchema.parse(payload);
+ expect(parsed.issues[0]?.stage).toBeNull();
+ });
});
describe("TimelineEntriesSchema", () => {
diff --git a/packages/core/api/schemas.ts b/packages/core/api/schemas.ts
index 52bf28f96b..57060958aa 100644
--- a/packages/core/api/schemas.ts
+++ b/packages/core/api/schemas.ts
@@ -241,6 +241,9 @@ export const IssueSchema = z.object({
parent_issue_id: z.string().nullable(),
project_id: z.string().nullable(),
position: z.number(),
+ // Older backends predate `stage`; default to null so a missing field parses
+ // cleanly into the non-optional Issue.stage (number | null).
+ stage: z.number().nullable().default(null),
start_date: z.string().nullable(),
due_date: z.string().nullable(),
metadata: IssueMetadataSchema,
diff --git a/packages/core/issues/batch.test.ts b/packages/core/issues/batch.test.ts
index fbdb951569..93326b0349 100644
--- a/packages/core/issues/batch.test.ts
+++ b/packages/core/issues/batch.test.ts
@@ -19,6 +19,7 @@ function makeIssue(overrides: Partial<Issue> = {}): Issue {
parent_issue_id: null,
project_id: null,
position: 1,
+ stage: null,
start_date: null,
due_date: null,
metadata: {},
diff --git a/packages/core/issues/mutations.test.tsx b/packages/core/issues/mutations.test.tsx
index 997ab8a6df..f11c23a0b0 100644
--- a/packages/core/issues/mutations.test.tsx
+++ b/packages/core/issues/mutations.test.tsx
@@ -46,6 +46,7 @@ function makeIssue(idx: number, overrides: Partial<Issue> = {}): Issue {
parent_issue_id: null,
project_id: null,
position: idx,
+ stage: null,
start_date: null,
due_date: null,
labels: [],
diff --git a/packages/core/issues/queries.test.ts b/packages/core/issues/queries.test.ts
index d9e00abf2d..fff921c594 100644
--- a/packages/core/issues/queries.test.ts
+++ b/packages/core/issues/queries.test.ts
@@ -33,6 +33,7 @@ function makeIssue(idx: number): Issue {
parent_issue_id: null,
project_id: PROJECT_ID,
position: idx,
+ stage: null,
start_date: "2026-05-01T00:00:00Z",
due_date: null,
labels: [],
diff --git a/packages/core/issues/ws-updaters.test.ts b/packages/core/issues/ws-updaters.test.ts
index 9f44a1726f..aad2ad3657 100644
--- a/packages/core/issues/ws-updaters.test.ts
+++ b/packages/core/issues/ws-updaters.test.ts
@@ -72,6 +72,7 @@ const baseIssue: Issue = {
parent_issue_id: null,
project_id: null,
position: 0,
+ stage: null,
start_date: null,
due_date: null,
metadata: {},
diff --git a/packages/core/types/api.ts b/packages/core/types/api.ts
index 5865c1badd..2b67521c83 100644
--- a/packages/core/types/api.ts
+++ b/packages/core/types/api.ts
@@ -12,6 +12,8 @@ export interface CreateIssueRequest {
assignee_id?: string;
parent_issue_id?: string;
project_id?: string;
+ /** Ordered stage (>= 1) grouping this sub-issue under its parent. */
+ stage?: number;
start_date?: string;
due_date?: string;
attachment_ids?: string[];
@@ -29,6 +31,8 @@ export interface UpdateIssueRequest {
due_date?: string | null;
parent_issue_id?: string | null;
project_id?: string | null;
+ /** Ordered stage (>= 1); null clears it (unstaged). */
+ stage?: number | null;
/** Attachment IDs to bind to this issue alongside the description update.
* Used by the description editor to register newly uploaded files so they
* surface in `issueAttachments` and keep their preview Eye on refresh. */
diff --git a/packages/core/types/issue.ts b/packages/core/types/issue.ts
index 2a2566fa8b..adc857aa5f 100644
--- a/packages/core/types/issue.ts
+++ b/packages/core/types/issue.ts
@@ -48,6 +48,10 @@ export interface Issue {
parent_issue_id: string | null;
project_id: string | null;
position: number;
+ // Ordered barrier group among sibling sub-issues (null = unstaged). The
+ // parent assignee is notified/woken only when every sub-issue in a stage
+ // finishes; see server/internal/handler/issue_child_done.go.
+ stage: number | null;
// Calendar days as date-only "YYYY-MM-DD" (no time, no timezone). Use the
// helpers in @multica/core/issues/date to format/compare — never `new Date()`
// + local formatting, which shifts the day by the viewer's offset.
diff --git a/packages/views/issues/components/batch-action-toolbar.test.tsx b/packages/views/issues/components/batch-action-toolbar.test.tsx
index 677f3f91a5..fed43cba28 100644
--- a/packages/views/issues/components/batch-action-toolbar.test.tsx
+++ b/packages/views/issues/components/batch-action-toolbar.test.tsx
@@ -69,6 +69,7 @@ function makeIssue(overrides: Partial<Issue> = {}): Issue {
parent_issue_id: null,
project_id: null,
position: 1,
+ stage: null,
start_date: null,
due_date: null,
metadata: {},
diff --git a/packages/views/issues/components/index.ts b/packages/views/issues/components/index.ts
index 3a4c7bd591..5defb51fd5 100644
--- a/packages/views/issues/components/index.ts
+++ b/packages/views/issues/components/index.ts
@@ -1,7 +1,7 @@
export { StatusIcon } from "./status-icon";
export { StatusHeading } from "./status-heading";
export { PriorityIcon } from "./priority-icon";
-export { StatusPicker, PriorityPicker, AssigneePicker, canAssignAgent, StartDatePicker, DueDatePicker, LabelPicker } from "./pickers";
+export { StatusPicker, PriorityPicker, StagePicker, AssigneePicker, canAssignAgent, StartDatePicker, DueDatePicker, LabelPicker } from "./pickers";
export { IssueDetail } from "./issue-detail";
export { IssuesPage } from "./issues-page";
export { CommentCard } from "./comment-card";
diff --git a/packages/views/issues/components/issue-detail.test.tsx b/packages/views/issues/components/issue-detail.test.tsx
index 1782af9007..b5c6708840 100644
--- a/packages/views/issues/components/issue-detail.test.tsx
+++ b/packages/views/issues/components/issue-detail.test.tsx
@@ -404,6 +404,7 @@ const mockIssue: Issue = {
parent_issue_id: null,
project_id: null,
position: 0,
+ stage: null,
start_date: null,
due_date: "2026-06-01T00:00:00Z",
metadata: {},
@@ -440,7 +441,7 @@ const mockTimeline: TimelineEntry[] = [
// Import component under test (after mocks)
// ---------------------------------------------------------------------------
-import { IssueDetail } from "./issue-detail";
+import { IssueDetail, groupSubIssuesByStage } from "./issue-detail";
// ---------------------------------------------------------------------------
// Helpers
@@ -1231,3 +1232,36 @@ describe("IssueDetail (shared)", () => {
});
});
});
+
+describe("groupSubIssuesByStage", () => {
+ const child = (id: string, stage: number | null): Issue => ({
+ ...mockIssue,
+ id,
+ parent_issue_id: "parent-1",
+ stage,
+ });
+
+ it("returns a single null-stage group when nothing is staged", () => {
+ const groups = groupSubIssuesByStage([child("a", null), child("b", null)]);
+ expect(groups).toHaveLength(1);
+ expect(groups[0]?.stage).toBeNull();
+ expect(groups[0]?.items.map((i) => i.id)).toEqual(["a", "b"]);
+ });
+
+ it("orders staged groups ascending with the unstaged group last", () => {
+ const groups = groupSubIssuesByStage([
+ child("s2", 2),
+ child("u", null),
+ child("s1a", 1),
+ child("s1b", 1),
+ ]);
+ expect(groups.map((g) => g.stage)).toEqual([1, 2, null]);
+ expect(groups[0]?.items.map((i) => i.id)).toEqual(["s1a", "s1b"]);
+ expect(groups[2]?.items.map((i) => i.id)).toEqual(["u"]);
+ });
+
+ it("omits the unstaged group when every child is staged", () => {
+ const groups = groupSubIssuesByStage([child("s1", 1), child("s2", 2)]);
+ expect(groups.map((g) => g.stage)).toEqual([1, 2]);
+ });
+});
diff --git a/packages/views/issues/components/issue-detail.tsx b/packages/views/issues/components/issue-detail.tsx
index e8a96cef96..5b5a17a8e2 100644
--- a/packages/views/issues/components/issue-detail.tsx
+++ b/packages/views/issues/components/issue-detail.tsx
@@ -14,6 +14,7 @@ import {
ChevronLeft,
ChevronRight,
CircleCheck,
+ Hash,
MoreHorizontal,
PanelRight,
Pin,
@@ -48,7 +49,8 @@ import { STATUS_CONFIG, PRIORITY_CONFIG } from "@multica/core/issues/config";
import { formatDateOnly } from "@multica/core/issues/date";
import { useUpdateIssue } from "@multica/core/issues/mutations";
import { toast } from "sonner";
-import { StatusIcon, PriorityIcon, StatusPicker, PriorityPicker, StartDatePicker, DueDatePicker, AssigneePicker, LabelPicker } from ".";
+import { StatusIcon, PriorityIcon, StatusPicker, PriorityPicker, StagePicker, StartDatePicker, DueDatePicker, AssigneePicker, LabelPicker } from ".";
+import { maxSiblingStage } from "./pickers/stage-picker";
import { IssueActionsDropdown, useIssueActions } from "../actions";
import { ProjectPicker } from "../../projects/components/project-picker";
import { LocalDirectoryHint } from "../../projects/components/local-directory-hint";
@@ -303,7 +305,11 @@ const EMPTY_REPLIES: TimelineEntry[] = [];
// means appending here, wiring its row in the JSX switch below, and
// adding a locale key. The picker, visibility rules, and add-property
// menu all flow from this one list.
-const OPTIONAL_PROP_KEYS = ["priority", "start_date", "due_date", "labels"] as const;
+// `stage` is only meaningful for a sub-issue (relative to its siblings), so
+// its row and add-property entry are gated on `issue.parent_issue_id` at the
+// render site below — it stays in this list so seeding/visibility flow through
+// the same machinery as the other optional props.
+const OPTIONAL_PROP_KEYS = ["priority", "stage", "start_date", "due_date", "labels"] as const;
type OptionalPropKey = (typeof OPTIONAL_PROP_KEYS)[number];
function isOptionalPropSet(
@@ -314,6 +320,8 @@ function isOptionalPropSet(
switch (key) {
case "priority":
return issue.priority !== "none";
+ case "stage":
+ return issue.stage !== null && issue.stage !== undefined;
case "start_date":
return !!issue.start_date;
case "due_date":
@@ -323,6 +331,30 @@ function isOptionalPropSet(
}
}
+// groupSubIssuesByStage orders a parent's children for display: staged groups
+// ascending by stage, then the unstaged group (stage === null) last. Callers
+// render a per-group stage header only when the set is actually staged.
+export function groupSubIssuesByStage(
+ children: Issue[],
+): { stage: number | null; items: Issue[] }[] {
+ const byStage = new Map<number, Issue[]>();
+ const unstaged: Issue[] = [];
+ for (const c of children) {
+ if (c.stage != null) {
+ const arr = byStage.get(c.stage);
+ if (arr) arr.push(c);
+ else byStage.set(c.stage, [c]);
+ } else {
+ unstaged.push(c);
+ }
+ }
+ const groups: { stage: number | null; items: Issue[] }[] = [...byStage.keys()]
+ .sort((a, b) => a - b)
+ .map((s) => ({ stage: s, items: byStage.get(s) as Issue[] }));
+ if (unstaged.length > 0) groups.push({ stage: null, items: unstaged });
+ return groups;
+}
+
// Shallow array equality by element identity. Used to reuse the previous
// render's per-thread reply slice when nothing in *this* thread changed,
// even if the surrounding `timeline` array was rebuilt by a WS event in
@@ -1431,6 +1463,17 @@ export function IssueDetail({ issueId, onDelete, onDone, defaultSidebarOpen = tr
/>
</PropRow>
)}
+ {issue.parent_issue_id != null && visibleOptionalProps.has("stage") && (
+ <PropRow label={t(($) => $.detail.prop_stage)}>
+ <StagePicker
+ stage={issue.stage}
+ onUpdate={handleUpdateField}
+ maxStage={maxSiblingStage(parentChildIssues)}
+ align="start"
+ defaultOpen={autoOpenProp === "stage"}
+ />
+ </PropRow>
+ )}
{visibleOptionalProps.has("start_date") && (
<PropRow label={t(($) => $.detail.prop_start_date)}>
<StartDatePicker
@@ -1463,7 +1506,7 @@ export function IssueDetail({ issueId, onDelete, onDone, defaultSidebarOpen = tr
not yet displayed. Hidden once every optional field is on
screen. Sits inside the same grid as a full-row, with its
own padding so the visual rhythm follows the rows above. */}
- {OPTIONAL_PROP_KEYS.some((k) => !visibleOptionalProps.has(k)) && (
+ {OPTIONAL_PROP_KEYS.some((k) => !visibleOptionalProps.has(k) && (k !== "stage" || issue.parent_issue_id != null)) && (
<div className="col-span-2 mt-1">
<Popover open={addPropPopoverOpen} onOpenChange={setAddPropPopoverOpen}>
<PopoverTrigger
@@ -1477,7 +1520,7 @@ export function IssueDetail({ issueId, onDelete, onDone, defaultSidebarOpen = tr
icon the resulting picker uses, so the dropdown reads
as a preview of what will show up below. */}
<PopoverContent align="start" className="w-44 p-1">
- {OPTIONAL_PROP_KEYS.filter((k) => !visibleOptionalProps.has(k)).map((k) => (
+ {OPTIONAL_PROP_KEYS.filter((k) => !visibleOptionalProps.has(k) && (k !== "stage" || issue.parent_issue_id != null)).map((k) => (
<button
key={k}
type="button"
@@ -1487,6 +1530,9 @@ export function IssueDetail({ issueId, onDelete, onDone, defaultSidebarOpen = tr
{k === "priority" && (
<PriorityIcon priority="medium" inheritColor className="text-muted-foreground" />
)}
+ {k === "stage" && (
+ <Hash className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />
+ )}
{k === "start_date" && (
<CalendarClock className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />
)}
@@ -1498,6 +1544,7 @@ export function IssueDetail({ issueId, onDelete, onDone, defaultSidebarOpen = tr
)}
<span className="truncate">
{k === "priority" && t(($) => $.detail.prop_priority)}
+ {k === "stage" && t(($) => $.detail.prop_stage)}
{k === "start_date" && t(($) => $.detail.prop_start_date)}
{k === "due_date" && t(($) => $.detail.prop_due_date)}
{k === "labels" && t(($) => $.detail.prop_labels)}
@@ -2007,13 +2054,28 @@ export function IssueDetail({ issueId, onDelete, onDone, defaultSidebarOpen = tr
<BatchActionToolbar issues={childIssues} placement="inline" />
{/* List */}
- {!subIssuesCollapsed && (
- <div className="overflow-hidden rounded-lg border bg-card/30 divide-y divide-border/60">
- {childIssues.map((child) => (
- <SubIssueRow key={child.id} child={child} />
- ))}
- </div>
- )}
+ {!subIssuesCollapsed && (() => {
+ const groups = groupSubIssuesByStage(childIssues);
+ const staged = childIssues.some((c) => c.stage != null);
+ return (
+ <div className="overflow-hidden rounded-lg border bg-card/30 divide-y divide-border/60">
+ {groups.map(({ stage: groupStage, items }) => (
+ <Fragment key={groupStage ?? "unstaged"}>
+ {staged && (
+ <div className="bg-muted/40 px-3 py-1 text-[11px] font-medium uppercase tracking-wider text-muted-foreground">
+ {groupStage == null
+ ? t(($) => $.stage.none)
+ : t(($) => $.stage.value, { n: groupStage })}
+ </div>
+ )}
+ {items.map((child) => (
+ <SubIssueRow key={child.id} child={child} />
+ ))}
+ </Fragment>
+ ))}
+ </div>
+ );
+ })()}
</div>
);
})()}
diff --git a/packages/views/issues/components/issues-page.test.tsx b/packages/views/issues/components/issues-page.test.tsx
index b99f0129c7..e0d17496a2 100644
--- a/packages/views/issues/components/issues-page.test.tsx
+++ b/packages/views/issues/components/issues-page.test.tsx
@@ -338,6 +338,7 @@ const issueDefaults = {
parent_issue_id: null,
project_id: null,
position: 0,
+ stage: null,
metadata: {},
};
diff --git a/packages/views/issues/components/pickers/index.ts b/packages/views/issues/components/pickers/index.ts
index 691c15afc9..51e7225613 100644
--- a/packages/views/issues/components/pickers/index.ts
+++ b/packages/views/issues/components/pickers/index.ts
@@ -1,6 +1,7 @@
export { PropertyPicker, PickerItem, PickerSection, PickerEmpty } from "./property-picker";
export { StatusPicker } from "./status-picker";
export { PriorityPicker } from "./priority-picker";
+export { StagePicker } from "./stage-picker";
export { AssigneePicker, canAssignAgent } from "./assignee-picker";
export { StartDatePicker } from "./start-date-picker";
export { DueDatePicker } from "./due-date-picker";
diff --git a/packages/views/issues/components/pickers/stage-picker.test.tsx b/packages/views/issues/components/pickers/stage-picker.test.tsx
new file mode 100644
index 0000000000..fb4747226f
--- /dev/null
+++ b/packages/views/issues/components/pickers/stage-picker.test.tsx
@@ -0,0 +1,32 @@
+import { describe, it, expect } from "vitest";
+import { maxSiblingStage, stageOptions } from "./stage-picker";
+
+describe("maxSiblingStage", () => {
+ it("returns 0 when nothing is staged", () => {
+ expect(maxSiblingStage([])).toBe(0);
+ expect(maxSiblingStage([{ stage: null }, { stage: null }])).toBe(0);
+ });
+
+ it("returns the highest assigned stage, ignoring unstaged children", () => {
+ expect(
+ maxSiblingStage([{ stage: 1 }, { stage: 5 }, { stage: null }, { stage: 3 }]),
+ ).toBe(5);
+ });
+});
+
+describe("stageOptions", () => {
+ it("floors at Stage 1–3 when nothing higher exists", () => {
+ expect(stageOptions(null, 0)).toEqual([1, 2, 3]);
+ expect(stageOptions(1, 0)).toEqual([1, 2, 3]);
+ });
+
+ // The regression Elon flagged: a parent already has a Stage 5 child, so the
+ // picker must keep Stage 5 selectable and offer a new Stage 6 — not floor at 3.
+ it("extends one beyond the highest sibling stage", () => {
+ expect(stageOptions(null, 5)).toEqual([1, 2, 3, 4, 5, 6]);
+ });
+
+ it("extends one beyond the current stage even without siblings", () => {
+ expect(stageOptions(5, 0)).toEqual([1, 2, 3, 4, 5, 6]);
+ });
+});
diff --git a/packages/views/issues/components/pickers/stage-picker.tsx b/packages/views/issues/components/pickers/stage-picker.tsx
new file mode 100644
index 0000000000..5c96c1b7bd
--- /dev/null
+++ b/packages/views/issues/components/pickers/stage-picker.tsx
@@ -0,0 +1,104 @@
+"use client";
+
+import { useState } from "react";
+import { Hash } from "lucide-react";
+import type { UpdateIssueRequest } from "@multica/core/types";
+import { PropertyPicker, PickerItem } from "./property-picker";
+import { useT } from "../../../i18n";
+
+/**
+ * Highest stage assigned among a parent's children (0 when none are staged).
+ * Tells {@link StagePicker} how far to extend its option list so an already-used
+ * higher stage stays selectable when creating or editing a sibling.
+ */
+export function maxSiblingStage(children: readonly { stage: number | null }[]): number {
+ return children.reduce((m, c) => (c.stage != null && c.stage > m ? c.stage : m), 0);
+}
+
+/**
+ * Stage options (Stage 1..top) the picker offers. `top` always covers the
+ * current stage, the highest sibling stage (`maxStage`), and one beyond it so a
+ * new stage can be added — floored so Stage 1–3 are always selectable.
+ */
+export function stageOptions(stage: number | null, maxStage = 0): number[] {
+ const top = Math.max(stage ?? 0, maxStage, 2) + 1;
+ return Array.from({ length: top }, (_, i) => i + 1);
+}
+
+export function StagePicker({
+ stage,
+ onUpdate,
+ maxStage = 0,
+ trigger: customTrigger,
+ triggerRender,
+ open: controlledOpen,
+ onOpenChange: controlledOnOpenChange,
+ align,
+ defaultOpen = false,
+}: {
+ stage: number | null;
+ onUpdate: (updates: Partial<UpdateIssueRequest>) => void;
+ /** Highest stage among siblings, so the picker can offer one beyond it. */
+ maxStage?: number;
+ trigger?: React.ReactNode;
+ triggerRender?: React.ReactElement;
+ open?: boolean;
+ onOpenChange?: (v: boolean) => void;
+ align?: "start" | "center" | "end";
+ /** Open the picker on first mount (progressive-disclosure sidebars). */
+ defaultOpen?: boolean;
+}) {
+ const [internalOpen, setInternalOpen] = useState(defaultOpen);
+ const open = controlledOpen ?? internalOpen;
+ const setOpen = controlledOnOpenChange ?? setInternalOpen;
+ const { t } = useT("issues");
+
+ const options = stageOptions(stage, maxStage);
+
+ return (
+ <PropertyPicker
+ open={open}
+ onOpenChange={setOpen}
+ width="w-44"
+ align={align}
+ triggerRender={triggerRender}
+ trigger={
+ customTrigger ?? (
+ <>
+ <Hash className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />
+ <span className="truncate">
+ {stage == null
+ ? t(($) => $.stage.none)
+ : t(($) => $.stage.value, { n: stage })}
+ </span>
+ </>
+ )
+ }
+ >
+ <PickerItem
+ selected={stage == null}
+ onClick={() => {
+ onUpdate({ stage: null });
+ setOpen(false);
+ }}
+ >
+ <span className="truncate text-muted-foreground">{t(($) => $.stage.none)}</span>
+ </PickerItem>
+ {options.map((s) => (
+ <PickerItem
+ key={s}
+ selected={s === stage}
+ onClick={() => {
+ onUpdate({ stage: s });
+ setOpen(false);
+ }}
+ >
+ <span className="inline-flex items-center gap-1.5">
+ <Hash className="h-3 w-3 shrink-0 text-muted-foreground" />
+ {t(($) => $.stage.value, { n: s })}
+ </span>
+ </PickerItem>
+ ))}
+ </PropertyPicker>
+ );
+}
diff --git a/packages/views/issues/components/swimlane-view.test.tsx b/packages/views/issues/components/swimlane-view.test.tsx
index 1bbc5cc8ea..6529bddb39 100644
--- a/packages/views/issues/components/swimlane-view.test.tsx
+++ b/packages/views/issues/components/swimlane-view.test.tsx
@@ -272,6 +272,7 @@ const mockIssues: Issue[] = [
parent_issue_id: null,
project_id: null,
position: 100,
+ stage: null,
start_date: null,
due_date: null,
metadata: {},
@@ -294,6 +295,7 @@ const mockIssues: Issue[] = [
parent_issue_id: "parent-1",
project_id: null,
position: 200,
+ stage: null,
start_date: null,
due_date: null,
metadata: {},
@@ -316,6 +318,7 @@ const mockIssues: Issue[] = [
parent_issue_id: null,
project_id: null,
position: 300,
+ stage: null,
start_date: null,
due_date: null,
metadata: {},
@@ -456,6 +459,7 @@ describe("SwimLaneView", () => {
parent_issue_id: "missing-parent",
project_id: null,
position: 400,
+ stage: null,
start_date: null,
due_date: null,
metadata: {},
@@ -728,6 +732,7 @@ describe("SwimLaneView", () => {
parent_issue_id: null,
project_id: null,
position: 100,
+ stage: null,
start_date: null,
due_date: null,
metadata: {},
@@ -750,6 +755,7 @@ describe("SwimLaneView", () => {
parent_issue_id: null,
project_id: null,
position: 200,
+ stage: null,
start_date: null,
due_date: null,
metadata: {},
@@ -772,6 +778,7 @@ describe("SwimLaneView", () => {
parent_issue_id: "parent-1",
project_id: null,
position: 300,
+ stage: null,
start_date: null,
due_date: null,
metadata: {},
@@ -794,6 +801,7 @@ describe("SwimLaneView", () => {
parent_issue_id: "parent-2",
project_id: null,
position: 400,
+ stage: null,
start_date: null,
due_date: null,
metadata: {},
@@ -1246,6 +1254,7 @@ describe("SwimLaneView", () => {
parent_issue_id: null,
project_id: null,
position: 10,
+ stage: null,
start_date: null,
due_date: null,
metadata: {},
@@ -1319,6 +1328,7 @@ describe("SwimLaneView", () => {
parent_issue_id: null,
project_id: null,
position: 50,
+ stage: null,
start_date: null,
due_date: null,
metadata: {},
@@ -1399,6 +1409,7 @@ describe("SwimLaneView", () => {
parent_issue_id: null,
project_id: null,
position: 10,
+ stage: null,
start_date: null,
due_date: null,
metadata: {},
@@ -1492,6 +1503,7 @@ describe("SwimLaneView", () => {
parent_issue_id: null,
project_id: null,
position: 10,
+ stage: null,
start_date: null,
due_date: null,
metadata: {},
diff --git a/packages/views/issues/hooks/issue-delete-mutations.test.tsx b/packages/views/issues/hooks/issue-delete-mutations.test.tsx
index 4e2f4690ea..417348b881 100644
--- a/packages/views/issues/hooks/issue-delete-mutations.test.tsx
+++ b/packages/views/issues/hooks/issue-delete-mutations.test.tsx
@@ -61,6 +61,7 @@ const baseIssue: Issue = {
parent_issue_id: PARENT_ISSUE_ID,
project_id: null,
position: 0,
+ stage: null,
start_date: null,
due_date: null,
metadata: {},
diff --git a/packages/views/issues/utils/filter.test.ts b/packages/views/issues/utils/filter.test.ts
index ecb11a55ed..e90c32cc38 100644
--- a/packages/views/issues/utils/filter.test.ts
+++ b/packages/views/issues/utils/filter.test.ts
@@ -30,6 +30,7 @@ function makeIssue(overrides: Partial<Issue> = {}): Issue {
parent_issue_id: null,
project_id: null,
position: 0,
+ stage: null,
start_date: null,
due_date: null,
metadata: {},
diff --git a/packages/views/locales/en/issues.json b/packages/views/locales/en/issues.json
index 60f213dcea..6ba87b893a 100644
--- a/packages/views/locales/en/issues.json
+++ b/packages/views/locales/en/issues.json
@@ -22,6 +22,10 @@
"low": "Low",
"none": "No priority"
},
+ "stage": {
+ "none": "No stage",
+ "value": "Stage {{n}}"
+ },
"scope": {
"all_label": "All",
"all_description": "All issues in this workspace",
@@ -196,6 +200,7 @@
"pull_request_card_show_less": "Show less",
"prop_status": "Status",
"prop_priority": "Priority",
+ "prop_stage": "Stage",
"prop_assignee": "Assignee",
"prop_start_date": "Start date",
"prop_due_date": "Due date",
diff --git a/packages/views/locales/ja/issues.json b/packages/views/locales/ja/issues.json
index 39527422c1..0fedf6193c 100644
--- a/packages/views/locales/ja/issues.json
+++ b/packages/views/locales/ja/issues.json
@@ -22,6 +22,10 @@
"low": "低",
"none": "優先度なし"
},
+ "stage": {
+ "none": "ステージなし",
+ "value": "ステージ {{n}}"
+ },
"scope": {
"all_label": "すべて",
"all_description": "このワークスペースのすべてのイシュー",
@@ -193,6 +197,7 @@
"pull_request_card_show_less": "折りたたむ",
"prop_status": "ステータス",
"prop_priority": "優先度",
+ "prop_stage": "ステージ",
"prop_assignee": "担当者",
"prop_start_date": "開始日",
"prop_due_date": "期限",
diff --git a/packages/views/locales/ko/issues.json b/packages/views/locales/ko/issues.json
index e11f0df3c1..060ad6f060 100644
--- a/packages/views/locales/ko/issues.json
+++ b/packages/views/locales/ko/issues.json
@@ -22,6 +22,10 @@
"low": "낮음",
"none": "우선순위 없음"
},
+ "stage": {
+ "none": "단계 없음",
+ "value": "{{n}}단계"
+ },
"scope": {
"all_label": "전체",
"all_description": "이 워크스페이스의 모든 이슈",
@@ -196,6 +200,7 @@
"pull_request_card_show_less": "간단히 보기",
"prop_status": "상태",
"prop_priority": "우선순위",
+ "prop_stage": "단계",
"prop_assignee": "담당자",
"prop_start_date": "시작일",
"prop_due_date": "마감일",
diff --git a/packages/views/locales/zh-Hans/issues.json b/packages/views/locales/zh-Hans/issues.json
index 322d54580a..b279a6dd97 100644
--- a/packages/views/locales/zh-Hans/issues.json
+++ b/packages/views/locales/zh-Hans/issues.json
@@ -22,6 +22,10 @@
"low": "低",
"none": "无优先级"
},
+ "stage": {
+ "none": "无阶段",
+ "value": "阶段 {{n}}"
+ },
"scope": {
"all_label": "全部",
"all_description": "工作区内的全部 issue",
@@ -194,6 +198,7 @@
"pull_request_card_show_less": "收起",
"prop_status": "状态",
"prop_priority": "优先级",
+ "prop_stage": "阶段",
"prop_assignee": "负责人",
"prop_start_date": "开始日期",
"prop_due_date": "截止日期",
diff --git a/packages/views/modals/create-issue.test.tsx b/packages/views/modals/create-issue.test.tsx
index 64180a08a2..55b12eb885 100644
--- a/packages/views/modals/create-issue.test.tsx
+++ b/packages/views/modals/create-issue.test.tsx
@@ -90,6 +90,10 @@ vi.mock("@multica/core/issues/queries", () => ({
queryKey: ["issues", wsId, "detail", id],
queryFn: () => Promise.resolve(null),
}),
+ childIssuesOptions: (wsId: string, id: string) => ({
+ queryKey: ["issues", wsId, "children", id],
+ queryFn: () => Promise.resolve([]),
+ }),
}));
vi.mock("@multica/core/issues/stores/draft-store", () => ({
@@ -210,6 +214,7 @@ vi.mock("../issues/components", () => ({
StatusIcon: ({ status }: { status: string }) => <span data-testid="status-icon">{status}</span>,
StatusPicker: () => <div data-testid="status-picker" />,
PriorityPicker: () => <div data-testid="priority-picker" />,
+ StagePicker: () => <div data-testid="stage-picker" />,
AssigneePicker: () => <div data-testid="assignee-picker" />,
// Surface open/onOpenChange so tests can assert progressive-disclosure
// behavior (mounted only when the user has opted in or has a value).
diff --git a/packages/views/modals/create-issue.tsx b/packages/views/modals/create-issue.tsx
index 9b389e143c..6f96a684fb 100644
--- a/packages/views/modals/create-issue.tsx
+++ b/packages/views/modals/create-issue.tsx
@@ -35,7 +35,8 @@ import { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider } from "@multi
import { Button } from "@multica/ui/components/ui/button";
import { Switch } from "@multica/ui/components/ui/switch";
import { ContentEditor, type ContentEditorRef, TitleEditor, useFileDropZone, FileDropOverlay } from "../editor";
-import { StatusIcon, StatusPicker, PriorityPicker, AssigneePicker, StartDatePicker, DueDatePicker } from "../issues/components";
+import { StatusIcon, StatusPicker, PriorityPicker, StagePicker, AssigneePicker, StartDatePicker, DueDatePicker } from "../issues/components";
+import { maxSiblingStage } from "../issues/components/pickers/stage-picker";
import { BacklogAgentHintContent } from "../issues/components/backlog-agent-hint-dialog";
import { ProjectPicker } from "../projects/components/project-picker";
import { useCurrentWorkspace, useWorkspacePaths } from "@multica/core/paths";
@@ -43,7 +44,7 @@ import { useWorkspaceId } from "@multica/core/hooks";
import { useIssueDraftStore } from "@multica/core/issues/stores/draft-store";
import { useCreateModeStore } from "@multica/core/issues/stores/create-mode-store";
import { useQuickCreateStore } from "@multica/core/issues/stores/quick-create-store";
-import { issueDetailOptions } from "@multica/core/issues/queries";
+import { issueDetailOptions, childIssuesOptions } from "@multica/core/issues/queries";
import { useCreateIssue, useUpdateIssue } from "@multica/core/issues/mutations";
import { useFileUpload } from "@multica/core/hooks/use-file-upload";
import {
@@ -140,6 +141,11 @@ export function ManualCreatePanel({
const [parentIssueId, setParentIssueId] = useState<string | undefined>(
(data?.parent_issue_id as string) || undefined,
);
+ // Stage only applies to a sub-issue; kept local (not in the persisted draft)
+ // since it's a per-creation choice tied to the chosen parent.
+ const [stage, setStage] = useState<number | null>(
+ typeof data?.stage === "number" ? (data.stage as number) : null,
+ );
const [parentPickerOpen, setParentPickerOpen] = useState(false);
// Start date is a low-frequency field — by default it lives in the
// overflow ⋯ menu. Clicking the menu item flips this open, which both
@@ -157,6 +163,12 @@ export function ManualCreatePanel({
...issueDetailOptions(wsId, parentIssueId ?? ""),
enabled: !!parentIssueId,
});
+ // Sibling stages under the chosen parent, so the Stage picker can offer the
+ // already-used max stage (and one beyond) instead of flooring at Stage 1–3.
+ const { data: parentChildren = [] } = useQuery({
+ ...childIssuesOptions(wsId, parentIssueId ?? ""),
+ enabled: !!parentIssueId,
+ });
const draftAttachments = draft.attachments ?? [];
@@ -211,6 +223,7 @@ export function ManualCreatePanel({
setDueDate(null);
setProjectId(undefined);
setParentIssueId(undefined);
+ setStage(null);
setChildIssues([]);
setDraft({
title: "",
@@ -246,6 +259,8 @@ export function ManualCreatePanel({
due_date: dueDate || undefined,
attachment_ids: activeAttachmentIds.length > 0 ? activeAttachmentIds : undefined,
parent_issue_id: parentIssueId,
+ // Stage is only meaningful for a sub-issue (relative to its siblings).
+ stage: parentIssueId && stage != null ? stage : undefined,
project_id: projectId,
});
@@ -570,6 +585,17 @@ export function ManualCreatePanel({
align="start"
/>
+ {/* Stage — only relevant when creating a sub-issue under a parent */}
+ {parentIssueId && (
+ <StagePicker
+ stage={stage}
+ onUpdate={(u) => setStage(u.stage ?? null)}
+ maxStage={maxSiblingStage(parentChildren)}
+ triggerRender={<PillButton />}
+ align="start"
+ />
+ )}
+
{/* Start date — collapsed into the ⋯ menu by default since it's
a low-frequency field. Renders inline only when the field
has a value OR the user just opened it from the overflow
diff --git a/server/cmd/multica/cmd_issue.go b/server/cmd/multica/cmd_issue.go
index 880c2f890b..6d38756e83 100644
--- a/server/cmd/multica/cmd_issue.go
+++ b/server/cmd/multica/cmd_issue.go
@@ -9,6 +9,8 @@ import (
"net/http"
"net/url"
"os"
+ "sort"
+ "strconv"
"strings"
"time"
"unicode/utf8"
@@ -109,6 +111,14 @@ var issuePullRequestsCmd = &cobra.Command{
RunE: runIssuePullRequests,
}
+var issueChildrenCmd = &cobra.Command{
+ Use: "children <id>",
+ Aliases: []string{"subissues"},
+ Short: "List an issue's sub-issues grouped by stage",
+ Args: exactArgs(1),
+ RunE: runIssueChildren,
+}
+
var issueCreateCmd = &cobra.Command{
Use: "create",
Short: "Create a new issue",
@@ -277,6 +287,7 @@ func init() {
issueCmd.AddCommand(issueListCmd)
issueCmd.AddCommand(issueGetCmd)
issueCmd.AddCommand(issuePullRequestsCmd)
+ issueCmd.AddCommand(issueChildrenCmd)
issueCmd.AddCommand(issueCreateCmd)
issueCmd.AddCommand(issueUpdateCmd)
issueCmd.AddCommand(issueAssignCmd)
@@ -317,6 +328,9 @@ func init() {
// issue pull-requests
issuePullRequestsCmd.Flags().String("output", "table", "Output format: table or json")
+ issueChildrenCmd.Flags().String("output", "table", "Output format: table or json")
+ issueChildrenCmd.Flags().Bool("full-id", false, "Show full UUIDs in table output")
+
// issue create
issueCreateCmd.Flags().String("title", "", "Issue title (required)")
issueCreateCmd.Flags().String("description", "", "Issue description (decodes \\n, \\r, \\t, \\\\; pipe via --description-stdin to preserve literal backslashes)")
@@ -327,6 +341,7 @@ func init() {
issueCreateCmd.Flags().String("assignee", "", "Assignee name (member, agent, or squad; fuzzy match)")
issueCreateCmd.Flags().String("assignee-id", "", "Assignee UUID — member, agent, or squad (mutually exclusive with --assignee)")
issueCreateCmd.Flags().String("parent", "", "Parent issue ID")
+ issueCreateCmd.Flags().Int("stage", 0, "Stage ordinal (>=1) grouping this sub-issue into an ordered barrier group under its parent; omit for unstaged. The parent assignee is woken only when every sub-issue in a stage finishes.")
issueCreateCmd.Flags().String("project", "", "Project ID")
issueCreateCmd.Flags().String("start-date", "", "Start date (calendar day, YYYY-MM-DD)")
issueCreateCmd.Flags().String("due-date", "", "Due date (calendar day, YYYY-MM-DD)")
@@ -348,6 +363,7 @@ func init() {
issueUpdateCmd.Flags().String("start-date", "", "New start date (calendar day, YYYY-MM-DD; pass empty string to clear)")
issueUpdateCmd.Flags().String("due-date", "", "New due date (calendar day, YYYY-MM-DD)")
issueUpdateCmd.Flags().String("parent", "", "Parent issue ID (use --parent \"\" to clear)")
+ issueUpdateCmd.Flags().Int("stage", 0, "Stage ordinal (>=1) for this sub-issue; see `issue create --stage`")
issueUpdateCmd.Flags().String("output", "json", "Output format: table or json")
// issue status
@@ -657,6 +673,120 @@ func runIssueGet(cmd *cobra.Command, args []string) error {
return cli.PrintJSON(os.Stdout, issue)
}
+// childStage extracts the integer stage from a child issue response map.
+// Returns ok=false when the child is unstaged (stage null/absent).
+func childStage(m map[string]any) (int, bool) {
+ v, ok := m["stage"]
+ if !ok || v == nil {
+ return 0, false
+ }
+ switch n := v.(type) {
+ case float64:
+ return int(n), true
+ case int:
+ return n, true
+ case json.Number:
+ i, err := n.Int64()
+ if err != nil {
+ return 0, false
+ }
+ return int(i), true
+ }
+ return 0, false
+}
+
+func runIssueChildren(cmd *cobra.Command, args []string) error {
+ client, err := newAPIClient(cmd)
+ if err != nil {
+ return err
+ }
+
+ ctx, cancel := cli.APIContext(context.Background())
+ defer cancel()
+
+ issueRef, err := resolveIssueRef(ctx, client, args[0])
+ if err != nil {
+ return fmt.Errorf("resolve issue: %w", err)
+ }
+
+ var resp struct {
+ Issues []map[string]any `json:"issues"`
+ }
+ if err := client.GetJSON(ctx, "/api/issues/"+issueRef.ID+"/children", &resp); err != nil {
+ return fmt.Errorf("list child issues: %w", err)
+ }
+ children := resp.Issues
+
+ // Order by stage ascending (unstaged last), preserving the API's
+ // within-stage order (position, then created_at desc).
+ sort.SliceStable(children, func(i, j int) bool {
+ si, oki := childStage(children[i])
+ sj, okj := childStage(children[j])
+ if oki != okj {
+ return oki // staged before unstaged
+ }
+ return si < sj
+ })
+
+ output, _ := cmd.Flags().GetString("output")
+ if output == "table" {
+ actors := loadActorDisplayLookup(ctx, client)
+ headers := []string{"STAGE", "KEY", "TITLE", "STATUS", "PRIORITY", "ASSIGNEE"}
+ rows := make([][]string, 0, len(children))
+ for _, c := range children {
+ stageCell := "-"
+ if s, ok := childStage(c); ok {
+ stageCell = strconv.Itoa(s)
+ }
+ rows = append(rows, []string{
+ stageCell,
+ issueDisplayKey(c),
+ strVal(c, "title"),
+ strVal(c, "status"),
+ strVal(c, "priority"),
+ formatAssignee(c, actors),
+ })
+ }
+ cli.PrintTable(os.Stdout, headers, rows)
+ return nil
+ }
+
+ // JSON: group by stage so an agent can see, at a glance, how many
+ // sub-issues there are and which stage each belongs to.
+ type stageGroup struct {
+ Stage int `json:"stage"`
+ Total int `json:"total"`
+ Done int `json:"done"`
+ Issues []map[string]any `json:"issues"`
+ }
+ stages := []stageGroup{}
+ unstaged := []map[string]any{}
+ idxByStage := map[int]int{}
+ for _, c := range children {
+ s, ok := childStage(c)
+ if !ok {
+ unstaged = append(unstaged, c)
+ continue
+ }
+ gi, seen := idxByStage[s]
+ if !seen {
+ stages = append(stages, stageGroup{Stage: s})
+ gi = len(stages) - 1
+ idxByStage[s] = gi
+ }
+ stages[gi].Issues = append(stages[gi].Issues, c)
+ stages[gi].Total++
+ if st := strVal(c, "status"); st == "done" || st == "cancelled" {
+ stages[gi].Done++
+ }
+ }
+ return cli.PrintJSON(os.Stdout, map[string]any{
+ "total": len(children),
+ "stages": stages,
+ "unstaged": unstaged,
+ })
+}
+
// isHTTPURL reports whether path is an http:// or https:// URL.
// Used to skip URL-shaped values passed to --attachment, which only
// accepts local file paths. Trims surrounding whitespace because
@@ -755,6 +885,13 @@ func runIssueCreate(cmd *cobra.Command, _ []string) error {
}
body["project_id"] = project.ID
}
+ if cmd.Flags().Changed("stage") {
+ stage, _ := cmd.Flags().GetInt("stage")
+ if stage < 1 {
+ return fmt.Errorf("--stage must be >= 1")
+ }
+ body["stage"] = stage
+ }
if v, _ := cmd.Flags().GetString("start-date"); v != "" {
body["start_date"] = v
}
@@ -969,6 +1106,13 @@ func runIssueUpdate(cmd *cobra.Command, args []string) error {
body["parent_issue_id"] = parent.ID
}
}
+ if cmd.Flags().Changed("stage") {
+ stage, _ := cmd.Flags().GetInt("stage")
+ if stage < 1 {
+ return fmt.Errorf("--stage must be >= 1")
+ }
+ body["stage"] = stage
+ }
if len(body) == 0 {
return fmt.Errorf("no fields to update; use flags like --title, --status, --priority, --assignee, etc.")
diff --git a/server/internal/handler/handler.go b/server/internal/handler/handler.go
index a89e627cf7..5816d16f14 100644
--- a/server/internal/handler/handler.go
+++ b/server/internal/handler/handler.go
@@ -274,6 +274,8 @@ func timestampToPtr(t pgtype.Timestamptz) *string { return util.TimestampToPtr
func dateToPtr(d pgtype.Date) *string { return util.DateToPtr(d) }
func uuidToPtr(u pgtype.UUID) *string { return util.UUIDToPtr(u) }
func int8ToPtr(v pgtype.Int8) *int64 { return util.Int8ToPtr(v) }
+func int4ToPtr(v pgtype.Int4) *int32 { return util.Int4ToPtr(v) }
+func ptrToInt4(v *int32) pgtype.Int4 { return util.PtrToInt4(v) }
// parseUUIDOrBadRequest validates a UUID string sourced from user input
// (URL params, request body, headers). On invalid input it writes a 400
diff --git a/server/internal/handler/issue.go b/server/internal/handler/issue.go
index 81bd83a215..1ada8c6186 100644
--- a/server/internal/handler/issue.go
+++ b/server/internal/handler/issue.go
@@ -44,10 +44,14 @@ type IssueResponse struct {
ParentIssueID *string `json:"parent_issue_id"`
ProjectID *string `json:"project_id"`
Position float64 `json:"position"`
- StartDate *string `json:"start_date"`
- DueDate *string `json:"due_date"`
- CreatedAt string `json:"created_at"`
- UpdatedAt string `json:"updated_at"`
+ // Stage groups sub-issues under the same parent into ordered barrier
+ // groups (null = unstaged). See issue_child_done.go for how a closed
+ // stage gates the child-done -> parent wake.
+ Stage *int32 `json:"stage"`
+ StartDate *string `json:"start_date"`
+ DueDate *string `json:"due_date"`
+ CreatedAt string `json:"created_at"`
+ UpdatedAt string `json:"updated_at"`
// Metadata is the per-issue KV map (see issue_metadata.go). Always emitted
// (empty object when unset) so frontend code can `issue.metadata[key]`
// without nil-guarding the parent field.
@@ -98,6 +102,7 @@ func issueToResponse(i db.Issue, issuePrefix string) IssueResponse {
ParentIssueID: uuidToPtr(i.ParentIssueID),
ProjectID: uuidToPtr(i.ProjectID),
Position: i.Position,
+ Stage: int4ToPtr(i.Stage),
StartDate: dateToPtr(i.StartDate),
DueDate: dateToPtr(i.DueDate),
CreatedAt: timestampToString(i.CreatedAt),
@@ -125,6 +130,7 @@ func issueListRowToResponse(i db.ListIssuesRow, issuePrefix string) IssueRespons
ParentIssueID: uuidToPtr(i.ParentIssueID),
ProjectID: uuidToPtr(i.ProjectID),
Position: i.Position,
+ Stage: int4ToPtr(i.Stage),
StartDate: dateToPtr(i.StartDate),
DueDate: dateToPtr(i.DueDate),
CreatedAt: timestampToString(i.CreatedAt),
@@ -182,6 +188,7 @@ func openIssueRowToResponse(i db.ListOpenIssuesRow, issuePrefix string) IssueRes
ParentIssueID: uuidToPtr(i.ParentIssueID),
ProjectID: uuidToPtr(i.ProjectID),
Position: i.Position,
+ Stage: int4ToPtr(i.Stage),
StartDate: dateToPtr(i.StartDate),
DueDate: dateToPtr(i.DueDate),
CreatedAt: timestampToString(i.CreatedAt),
@@ -2049,6 +2056,7 @@ type CreateIssueRequest struct {
AssigneeID *string `json:"assignee_id"`
ParentIssueID *string `json:"parent_issue_id"`
ProjectID *string `json:"project_id"`
+ Stage *int32 `json:"stage,omitempty"`
StartDate *string `json:"start_date"`
DueDate *string `json:"due_date"`
AttachmentIDs []string `json:"attachment_ids,omitempty"`
@@ -2105,6 +2113,10 @@ func (h *Handler) CreateIssue(w http.ResponseWriter, r *http.Request) {
if !validateIssueEnum(w, "priority", priority, validIssuePriorities) {
return
}
+ if req.Stage != nil && *req.Stage < 1 {
+ writeError(w, http.StatusBadRequest, "stage must be >= 1")
+ return
+ }
var assigneeType pgtype.Text
var assigneeID pgtype.UUID
@@ -2241,6 +2253,7 @@ func (h *Handler) CreateIssue(w http.ResponseWriter, r *http.Request) {
DueDate: dueDate,
OriginType: originType,
OriginID: originID,
+ Stage: ptrToInt4(req.Stage),
AttachmentIDs: attachmentIDs,
AllowDuplicate: req.AllowDuplicate,
}, service.IssueCreateOpts{
@@ -2298,6 +2311,7 @@ type UpdateIssueRequest struct {
DueDate *string `json:"due_date"`
ParentIssueID *string `json:"parent_issue_id"`
ProjectID *string `json:"project_id"`
+ Stage *int32 `json:"stage"`
// AttachmentIDs lets the description editor bind newly uploaded files to
// this issue so they surface in `GET /api/issues/:id/attachments` and the
// editor's preview Eye keeps working past a refresh. Existing bindings
@@ -2340,6 +2354,7 @@ func (h *Handler) UpdateIssue(w http.ResponseWriter, r *http.Request) {
DueDate: prevIssue.DueDate,
ParentIssueID: prevIssue.ParentIssueID,
ProjectID: prevIssue.ProjectID,
+ Stage: prevIssue.Stage,
}
// COALESCE fields — only set when explicitly provided
@@ -2457,6 +2472,17 @@ func (h *Handler) UpdateIssue(w http.ResponseWriter, r *http.Request) {
params.ProjectID = pgtype.UUID{Valid: false}
}
}
+ if _, ok := rawFields["stage"]; ok {
+ if req.Stage != nil {
+ if *req.Stage < 1 {
+ writeError(w, http.StatusBadRequest, "stage must be >= 1")
+ return
+ }
+ params.Stage = pgtype.Int4{Int32: *req.Stage, Valid: true}
+ } else {
+ params.Stage = pgtype.Int4{Valid: false} // explicit null = unstage
+ }
+ }
// Validate the resulting (assignee_type, assignee_id) pair when the caller
// touches either field. Existing data on the issue is left alone if the
@@ -2839,7 +2865,7 @@ func (h *Handler) BatchUpdateIssues(w http.ResponseWriter, r *http.Request) {
req.Updates.Priority != nil ||
req.Updates.Position != nil
if !hasMutation {
- for _, k := range []string{"assignee_type", "assignee_id", "start_date", "due_date", "parent_issue_id", "project_id"} {
+ for _, k := range []string{"assignee_type", "assignee_id", "start_date", "due_date", "parent_issue_id", "project_id", "stage"} {
if _, ok := rawUpdates[k]; ok {
hasMutation = true
break
@@ -2888,6 +2914,7 @@ func (h *Handler) BatchUpdateIssues(w http.ResponseWriter, r *http.Request) {
DueDate: prevIssue.DueDate,
ParentIssueID: prevIssue.ParentIssueID,
ProjectID: prevIssue.ProjectID,
+ Stage: prevIssue.Stage,
}
if req.Updates.Title != nil {
@@ -2996,6 +3023,16 @@ func (h *Handler) BatchUpdateIssues(w http.ResponseWriter, r *http.Request) {
params.ProjectID = pgtype.UUID{Valid: false}
}
}
+ if _, ok := rawUpdates["stage"]; ok {
+ if req.Updates.Stage != nil {
+ if *req.Updates.Stage < 1 {
+ continue
+ }
+ params.Stage = pgtype.Int4{Int32: *req.Updates.Stage, Valid: true}
+ } else {
+ params.Stage = pgtype.Int4{Valid: false} // explicit null = unstage
+ }
+ }
// Validate the resulting assignee pair when this batch update touches
// either assignee field. Skip the issue silently on failure.
diff --git a/server/internal/handler/issue_batch_test.go b/server/internal/handler/issue_batch_test.go
index 687ddb5f17..0f63e9917f 100644
--- a/server/internal/handler/issue_batch_test.go
+++ b/server/internal/handler/issue_batch_test.go
@@ -121,6 +121,41 @@ func TestBatchUpdateValidUpdatesPersistAndCount(t *testing.T) {
}
}
+// TestBatchUpdateStageOnly — regression for the stage barrier feature: a
+// batch update whose only field is `stage` must count as a mutation (hasMutation
+// includes "stage") and actually persist, not silently return {"updated": 0}.
+func TestBatchUpdateStageOnly(t *testing.T) {
+ a := createTestIssue(t, "BU-stage A", "todo", "low")
+ t.Cleanup(func() { deleteTestIssue(t, a) })
+
+ w := httptest.NewRecorder()
+ req := newRequest("POST", "/api/issues/batch-update", map[string]any{
+ "issue_ids": []string{a},
+ "updates": map[string]any{"stage": 2},
+ })
+ testHandler.BatchUpdateIssues(w, req)
+ if w.Code != http.StatusOK {
+ t.Fatalf("expected 200, got %d: %s", w.Code, w.Body.String())
+ }
+ var resp struct {
+ Updated int `json:"updated"`
+ }
+ json.NewDecoder(w.Body).Decode(&resp)
+ if resp.Updated != 1 {
+ t.Fatalf("expected updated=1 for a stage-only batch update, got %d", resp.Updated)
+ }
+
+ gw := httptest.NewRecorder()
+ gr := newRequest("GET", "/api/issues/"+a, nil)
+ gr = withURLParam(gr, "id", a)
+ testHandler.GetIssue(gw, gr)
+ var got IssueResponse
+ json.NewDecoder(gw.Body).Decode(&got)
+ if got.Stage == nil || *got.Stage != 2 {
+ t.Errorf("expected stage=2 to persist, got %v", got.Stage)
+ }
+}
+
// createTestIssue is a small helper to keep the table-driven cases clean.
// Returns the new issue's id; caller is responsible for cleanup.
func createTestIssue(t *testing.T, title, status, priority string) string {
diff --git a/server/internal/handler/issue_child_done.go b/server/internal/handler/issue_child_done.go
index c629196a2a..401fa1da08 100644
--- a/server/internal/handler/issue_child_done.go
+++ b/server/internal/handler/issue_child_done.go
@@ -4,6 +4,7 @@ import (
"context"
"fmt"
"log/slog"
+ "sort"
"strconv"
"strings"
@@ -20,9 +21,11 @@ import (
// hardcoding because the agent did not always know the workspace prefix).
//
// Guards on whether the comment fires at all:
-// - prev.Status must not already be "done" (idempotent — repeat saves of
-// done do not re-fire; only the transition fires)
-// - issue.Status must be "done"
+// - the child must transition from a non-terminal status INTO a terminal one
+// (done or cancelled). Repeat saves of an already-terminal child do not
+// re-fire; only the entering transition does. Cancelled counts because a
+// cancelled sibling never finishes and so closes its stage (see the entry
+// guard and isTerminalChildStatus).
// - issue.ParentIssueID must be set
// - parent must not be "done" or "cancelled" — the parent is already
// closed and a notification has no follow-up to drive
@@ -36,6 +39,15 @@ import (
// and there is nothing to "trigger" on a human assignee. Skipping the
// comment entirely (Bohan's call on MUL-2538) also sidesteps the
// mention question — no comment, no mention, no inbox row.
+// - the completion must close a STAGE barrier (MUL-3508). Sub-issues under
+// a parent can be grouped into ordered stages via issue.stage; the
+// notification + wake fire only when every sibling in the lowest
+// unfinished stage is terminal (stageBarrierClosed). An unstaged sibling
+// set is one implicit stage, so this fires once when the last sub-issue
+// finishes instead of on every child — the default fix for the
+// fire-on-every-child cascade reported in #4320. The woken assignee
+// decides whether to promote the next stage (agent-driven advancement);
+// the server only detects the barrier and wakes.
//
// The comment is inserted directly via db.Queries (not through the
// CreateComment HTTP handler) so it bypasses the generic on_comment trigger
@@ -57,7 +69,14 @@ func (h *Handler) notifyParentOfChildDone(ctx context.Context, prev, issue db.Is
if !issue.ParentIssueID.Valid {
return
}
- if prev.Status == "done" || issue.Status != "done" {
+ // Fire on a transition INTO a terminal status (done OR cancelled), not only
+ // `done`. A cancelled child can close a stage too: isTerminalChildStatus
+ // treats cancelled as terminal (a cancelled sibling never finishes, so it
+ // must not hold the stage open), so the barrier has to be evaluated when the
+ // last open child of a stage is cancelled. Keying on the transition also
+ // makes a later cancelled -> done edit a no-op (terminal -> terminal), which
+ // avoids a lagging duplicate wake.
+ if isTerminalChildStatus(prev.Status) || !isTerminalChildStatus(issue.Status) {
return
}
parent, err := h.Queries.GetIssue(ctx, issue.ParentIssueID)
@@ -86,20 +105,64 @@ func (h *Handler) notifyParentOfChildDone(ctx context.Context, prev, issue db.Is
return
}
+ // Stage barrier (MUL-3508 / discussion #4320). The notification + assignee
+ // wake fire only when this completion *closes a stage* — i.e. every sibling
+ // in the lowest unfinished stage is now terminal. An unstaged sibling set is
+ // one implicit stage, so this collapses to "wake once when the last
+ // sub-issue finishes" instead of the old fire-on-every-child behavior that
+ // caused the surprise cascade. A completion that does not close a stage is
+ // silent: no comment, no wake. ListChildIssues already reflects this child's
+ // committed `done` status (the status update commits before this runs).
+ children, err := h.Queries.ListChildIssues(ctx, parent.ID)
+ if err != nil {
+ slog.Warn("child done: failed to list siblings for stage barrier",
+ "error", err,
+ "child_id", uuidToString(issue.ID),
+ "parent_id", uuidToString(parent.ID))
+ return
+ }
+ if !stageBarrierClosed(children, issue) {
+ return
+ }
+ staged := siblingsAreStaged(children)
+
prefix := h.getIssuePrefix(ctx, issue.WorkspaceID)
identifier := prefix + "-" + strconv.Itoa(int(issue.Number))
childID := uuidToString(issue.ID)
title := sanitizeChildTitleForSystemComment(issue.Title)
+ parentID := uuidToString(parent.ID)
// Build the parent-assignee mention prefix. Empty when the parent has no
// assignee or the assignee row is missing (deleted member, archived
// agent the workspace lost track of, etc.).
mentionPrefix := h.buildParentAssigneeMention(ctx, parent)
- content := fmt.Sprintf(
- "%sSub-issue [%s](mention://issue/%s) — \"%s\" — is done. Before promoting any waiting `backlog` sub-issue, read each sibling's description and only promote items whose stated dependencies are already satisfied — do not rely on this parent's higher-level breakdown alone. If a sibling's description conflicts with that breakdown (e.g. it lists a prerequisite the parent treats as parallel), do NOT change its status — leave it `backlog` and post a comment to confirm first.",
- mentionPrefix, identifier, childID, title,
- )
+ var content string
+ // When the set is staged and the barrier closed, the completed child is
+ // guaranteed to carry a stage (stageBarrierClosed returns false for an
+ // unstaged completed child in a staged set), so issue.Stage.Int32 is safe.
+ if staged {
+ closedStage := issue.Stage.Int32
+ summary, nextStage := stageProgressSummary(children, closedStage)
+ var advance string
+ if nextStage > 0 {
+ advance = fmt.Sprintf(
+ " Stage %d is next. Review the full layout with `multica issue children %s`, and if Stage %d's dependencies are satisfied promote its `backlog` sub-issues to `todo` to continue. Read each sub-issue's description first and only promote items whose stated dependencies are already met — do not rely on this parent's higher-level breakdown alone. If a description conflicts with that breakdown, leave it `backlog` and post a comment to confirm first.",
+ nextStage, parentID, nextStage,
+ )
+ } else {
+ advance = " This was the final stage. Wrap up the parent — synthesize the results and move it forward, or close it out if nothing remains."
+ }
+ content = fmt.Sprintf(
+ "%sStage %d of this issue is complete — its last sub-issue [%s](mention://issue/%s) — \"%s\" — just finished. Stage progress — %s.%s",
+ mentionPrefix, closedStage, identifier, childID, title, summary, advance,
+ )
+ } else {
+ content = fmt.Sprintf(
+ "%sAll sub-issues are complete — the last one, [%s](mention://issue/%s) — \"%s\", just finished. Continue the parent: synthesize the children's results and move it forward, or close it out if nothing remains.",
+ mentionPrefix, identifier, childID, title,
+ )
+ }
// author_type='system', author_id=zero UUID. The zero UUID is a valid 16
// byte value and the column is NOT NULL; frontend code should branch on
@@ -138,6 +201,105 @@ func (h *Handler) notifyParentOfChildDone(ctx context.Context, prev, issue db.Is
h.dispatchParentAssigneeTrigger(ctx, parent, issue, comment, actorType, actorID)
}
+// isTerminalChildStatus reports whether a child issue status counts as
+// "finished" for stage-barrier purposes. Cancelled counts as terminal: a
+// cancelled sibling will never complete, so it must not hold a stage open.
+func isTerminalChildStatus(status string) bool {
+ return status == "done" || status == "cancelled"
+}
+
+// siblingsAreStaged reports whether any child in the set carries an explicit
+// stage. A set with no stages is treated as a single implicit stage.
+func siblingsAreStaged(children []db.Issue) bool {
+ for _, c := range children {
+ if c.Stage.Valid {
+ return true
+ }
+ }
+ return false
+}
+
+// stageBarrierClosed reports whether the completion of `completed` closed a
+// stage barrier among `children` — the full sibling set under one parent,
+// already reflecting completed's terminal status.
+//
+// - Unstaged sibling set (no child carries a stage): a single implicit
+// stage. The barrier closes only when every child is terminal — the "wake
+// once when the last sub-issue finishes" default.
+// - Staged sibling set: only children that carry a stage form stages.
+// Unstaged children do NOT participate (matches migration 123: a NULL
+// stage does not take part in staged grouping) — completing one closes
+// nothing, and a non-terminal unstaged child never holds a stage open.
+// The completed child's stage S closes when every *staged* child with
+// stage <= S is terminal (frontier closure). Later stages are normally
+// parked in `backlog`, so they cannot fire out of order; the caller's
+// idempotency guard collapses any duplicate wake.
+func stageBarrierClosed(children []db.Issue, completed db.Issue) bool {
+ if !siblingsAreStaged(children) {
+ for _, c := range children {
+ if !isTerminalChildStatus(c.Status) {
+ return false
+ }
+ }
+ return true
+ }
+ // Staged set: an unstaged completed child belongs to no stage, so it closes
+ // nothing.
+ if !completed.Stage.Valid {
+ return false
+ }
+ s := completed.Stage.Int32
+ for _, c := range children {
+ if !c.Stage.Valid {
+ continue // unstaged children are ignored by the frontier
+ }
+ if c.Stage.Int32 <= s && !isTerminalChildStatus(c.Status) {
+ return false
+ }
+ }
+ return true
+}
+
+// stageProgressSummary renders a compact per-stage breakdown for the
+// child-done system comment (e.g. "Stage 1: 3/3 done; Stage 2: 0/4 done") and
+// returns the lowest stage above closedStage that still has non-terminal
+// children — the next group to promote — or 0 when none remain. Unstaged
+// children are skipped (they are not part of any stage), so the breakdown
+// never renders a "Stage 0".
+func stageProgressSummary(children []db.Issue, closedStage int32) (summary string, nextStage int32) {
+ type agg struct{ total, done int }
+ byStage := map[int32]*agg{}
+ order := []int32{}
+ for _, c := range children {
+ if !c.Stage.Valid {
+ continue // unstaged children do not belong to any stage
+ }
+ s := c.Stage.Int32
+ a, ok := byStage[s]
+ if !ok {
+ a = &agg{}
+ byStage[s] = a
+ order = append(order, s)
+ }
+ a.total++
+ if isTerminalChildStatus(c.Status) {
+ a.done++
+ }
+ }
+ sort.Slice(order, func(i, j int) bool { return order[i] < order[j] })
+ parts := make([]string, 0, len(order))
+ for _, s := range order {
+ a := byStage[s]
+ label := fmt.Sprintf("Stage %d: %d/%d done", s, a.done, a.total)
+ if nextStage == 0 && s > closedStage && a.done < a.total {
+ nextStage = s
+ label += " (next)"
+ }
+ parts = append(parts, label)
+ }
+ return strings.Join(parts, "; "), nextStage
+}
+
// sanitizeChildTitleForSystemComment removes mention-style markdown from a
// child issue's title before it is embedded into the parent's system
// comment. Smuggled mentions are already harmless on the listener path
diff --git a/server/internal/handler/issue_child_done_stage_test.go b/server/internal/handler/issue_child_done_stage_test.go
new file mode 100644
index 0000000000..0666ebd1b6
--- /dev/null
+++ b/server/internal/handler/issue_child_done_stage_test.go
@@ -0,0 +1,190 @@
+package handler
+
+import (
+ "testing"
+
+ "github.com/jackc/pgx/v5/pgtype"
+ db "github.com/multica-ai/multica/server/pkg/db/generated"
+)
+
+// child builds a sibling row with the given stage (0 = unstaged/NULL) and
+// status, the only two fields the stage-barrier logic reads.
+func child(stage int32, status string) db.Issue {
+ c := db.Issue{Status: status}
+ if stage != 0 {
+ c.Stage = pgtype.Int4{Int32: stage, Valid: true}
+ }
+ return c
+}
+
+func TestStageBarrierClosed_Unstaged(t *testing.T) {
+ tests := []struct {
+ name string
+ children []db.Issue
+ want bool
+ }{
+ {
+ name: "last child still leaves a sibling open",
+ children: []db.Issue{child(0, "done"), child(0, "in_progress")},
+ want: false,
+ },
+ {
+ name: "every child terminal closes the single implicit stage",
+ children: []db.Issue{child(0, "done"), child(0, "done")},
+ want: true,
+ },
+ {
+ name: "a backlog sibling holds the barrier open (no surprise cascade)",
+ children: []db.Issue{child(0, "done"), child(0, "backlog")},
+ want: false,
+ },
+ {
+ name: "cancelled counts as terminal",
+ children: []db.Issue{child(0, "done"), child(0, "cancelled")},
+ want: true,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ // completed is one of the terminal children; identity doesn't matter
+ // for the unstaged path.
+ if got := stageBarrierClosed(tt.children, child(0, "done")); got != tt.want {
+ t.Fatalf("stageBarrierClosed = %v, want %v", got, tt.want)
+ }
+ })
+ }
+}
+
+func TestStageBarrierClosed_Staged(t *testing.T) {
+ // Three stages: 1 has two children, 2 has two, 3 has one.
+ t.Run("stage 1 not fully done does not fire", func(t *testing.T) {
+ children := []db.Issue{
+ child(1, "done"), child(1, "in_progress"),
+ child(2, "backlog"), child(2, "backlog"),
+ child(3, "backlog"),
+ }
+ if stageBarrierClosed(children, child(1, "done")) {
+ t.Fatal("expected barrier not closed while stage 1 has an open child")
+ }
+ })
+
+ t.Run("closing stage 1 fires even though later stages are parked", func(t *testing.T) {
+ children := []db.Issue{
+ child(1, "done"), child(1, "done"),
+ child(2, "backlog"), child(2, "backlog"),
+ child(3, "backlog"),
+ }
+ if !stageBarrierClosed(children, child(1, "done")) {
+ t.Fatal("expected stage 1 barrier to close")
+ }
+ })
+
+ t.Run("closing stage 2 fires when stages 1 and 2 are terminal", func(t *testing.T) {
+ children := []db.Issue{
+ child(1, "done"), child(1, "done"),
+ child(2, "done"), child(2, "done"),
+ child(3, "backlog"),
+ }
+ if !stageBarrierClosed(children, child(2, "done")) {
+ t.Fatal("expected stage 2 barrier to close")
+ }
+ })
+
+ t.Run("final stage closes once its child finishes", func(t *testing.T) {
+ children := []db.Issue{
+ child(1, "done"), child(1, "done"),
+ child(2, "done"), child(2, "done"),
+ child(3, "done"),
+ }
+ if !stageBarrierClosed(children, child(3, "done")) {
+ t.Fatal("expected final stage barrier to close")
+ }
+ })
+}
+
+func TestStageProgressSummary(t *testing.T) {
+ children := []db.Issue{
+ child(1, "done"), child(1, "done"), child(1, "done"),
+ child(2, "backlog"), child(2, "backlog"), child(2, "backlog"), child(2, "backlog"),
+ child(3, "backlog"), child(3, "backlog"),
+ }
+ summary, next := stageProgressSummary(children, 1)
+ want := "Stage 1: 3/3 done; Stage 2: 0/4 done (next); Stage 3: 0/2 done"
+ if summary != want {
+ t.Fatalf("summary = %q, want %q", summary, want)
+ }
+ if next != 2 {
+ t.Fatalf("nextStage = %d, want 2", next)
+ }
+}
+
+func TestStageProgressSummary_FinalStageNoNext(t *testing.T) {
+ children := []db.Issue{
+ child(1, "done"), child(1, "done"),
+ child(2, "done"),
+ }
+ _, next := stageProgressSummary(children, 2)
+ if next != 0 {
+ t.Fatalf("nextStage = %d, want 0 (no further stages)", next)
+ }
+}
+
+func TestStageProgressSummary_SkipsUnstaged(t *testing.T) {
+ // An unstaged child must not appear as "Stage 0" nor inflate any stage.
+ children := []db.Issue{
+ child(0, "backlog"), // unstaged — ignored
+ child(1, "done"), child(1, "done"),
+ child(2, "backlog"),
+ }
+ summary, next := stageProgressSummary(children, 1)
+ want := "Stage 1: 2/2 done; Stage 2: 0/1 done (next)"
+ if summary != want {
+ t.Fatalf("summary = %q, want %q", summary, want)
+ }
+ if next != 2 {
+ t.Fatalf("nextStage = %d, want 2", next)
+ }
+}
+
+// A stage can close because its last open child is *cancelled*, not only
+// done — a cancelled sibling never finishes, so it must not hold the stage open.
+func TestStageBarrierClosed_CancelledClosesStage(t *testing.T) {
+ t.Run("staged: cancelling the last open child closes the stage", func(t *testing.T) {
+ children := []db.Issue{
+ child(1, "done"), child(1, "cancelled"),
+ child(2, "backlog"),
+ }
+ if !stageBarrierClosed(children, child(1, "cancelled")) {
+ t.Fatal("expected the stage to close when its last open child is cancelled")
+ }
+ })
+ t.Run("unstaged: cancel of the last open child closes the implicit stage", func(t *testing.T) {
+ children := []db.Issue{child(0, "done"), child(0, "cancelled")}
+ if !stageBarrierClosed(children, child(0, "cancelled")) {
+ t.Fatal("expected the implicit stage to close on cancel")
+ }
+ })
+}
+
+// In a staged set, unstaged children do not participate in the frontier:
+// they neither hold a stage open nor close anything on their own completion.
+func TestStageBarrierClosed_UnstagedIgnoredInStagedSet(t *testing.T) {
+ t.Run("a non-terminal unstaged child does not block stage 1", func(t *testing.T) {
+ children := []db.Issue{
+ child(1, "done"), child(1, "done"),
+ child(0, "backlog"), // unstaged, still open — must NOT block
+ }
+ if !stageBarrierClosed(children, child(1, "done")) {
+ t.Fatal("expected stage 1 to close; an unstaged child must not hold it open")
+ }
+ })
+ t.Run("completing an unstaged child in a staged set closes nothing", func(t *testing.T) {
+ children := []db.Issue{
+ child(1, "backlog"),
+ child(0, "done"), // the just-completed unstaged child
+ }
+ if stageBarrierClosed(children, child(0, "done")) {
+ t.Fatal("an unstaged child's completion must not fire a stage barrier")
+ }
+ })
+}
diff --git a/server/internal/service/builtin_skills/multica-working-on-issues/SKILL.md b/server/internal/service/builtin_skills/multica-working-on-issues/SKILL.md
index 31002027e4..809c3a9805 100644
--- a/server/internal/service/builtin_skills/multica-working-on-issues/SKILL.md
+++ b/server/internal/service/builtin_skills/multica-working-on-issues/SKILL.md
@@ -164,6 +164,40 @@ multica issue status <child-id> todo # promote when the previous step is truly
Creating every serial step as `todo` enqueues the whole chain at once.
+### Stages: order sub-issues into barrier groups
+
+`--stage <N>` (N ≥ 1) groups sub-issues under the same parent into ordered
+stages. The parent assignee is woken **once, when a whole stage finishes** —
+i.e. every sub-issue in the lowest unfinished stage has reached a terminal
+status (`done`/`cancelled`). A completion that does not close a stage is silent
+(no comment, no wake). A sibling set with **no** stages is one implicit stage,
+so the parent is woken once when the *last* sub-issue finishes — not on every
+child.
+
+Advancement is agent-driven: the server only detects the closed barrier and
+wakes the parent assignee, who then decides whether to promote the next stage's
+`backlog` sub-issues to `todo`.
+
+```bash
+# Stage 1 runs now; later stages parked until promoted
+multica issue create --title "Research A" --parent <id> --assignee <agent> --stage 1 --status todo
+multica issue create --title "Research B" --parent <id> --assignee <agent> --stage 1 --status todo
+multica issue create --title "Build" --parent <id> --assignee <agent> --stage 2 --status backlog
+multica issue create --title "Ship" --parent <id> --assignee <agent> --stage 3 --status backlog
+```
+
+When both Stage 1 sub-issues finish you (the parent assignee) are woken with a
+"Stage 1 complete" comment. Inspect the layout, then promote the next stage:
+
+```bash
+multica issue children <parent-id> # sub-issues grouped by stage
+multica issue status <stage-2-child-id> todo # promote when its deps are met
+```
+
+Read each sub-issue's description before promoting and only promote items whose
+stated dependencies are met; if a description conflicts with the parent's
+breakdown, leave it `backlog` and comment to confirm first.
+
## Incorrect → correct
PR title (link the issue):
@@ -173,16 +207,18 @@ Fix login redirect # incorrect — no issue key, won't link
MUL-2759: fix login redirect # correct — links the PR
```
-Serial sub-issues (don't start the whole chain):
+Serial / phased sub-issues (don't start the whole chain at once):
```bash
-# incorrect — both fire immediately
+# incorrect — all fire immediately, no ordering
multica issue create --title "Step 2" --parent <issue-id> --assignee <agent> --status todo
multica issue create --title "Step 3" --parent <issue-id> --assignee <agent> --status todo
-# correct — parked, promote in turn
-multica issue create --title "Step 2" --parent <issue-id> --assignee <agent> --status backlog
-multica issue create --title "Step 3" --parent <issue-id> --assignee <agent> --status backlog
+# correct — stage them; Stage 1 runs, later stages park and are promoted as
+# each stage's barrier closes
+multica issue create --title "Step 1" --parent <issue-id> --assignee <agent> --stage 1 --status todo
+multica issue create --title "Step 2" --parent <issue-id> --assignee <agent> --stage 2 --status backlog
+multica issue create --title "Step 3" --parent <issue-id> --assignee <agent> --stage 3 --status backlog
```
## References
@@ -191,4 +227,6 @@ multica issue create --title "Step 3" --parent <issue-id> --assignee <agent> --s
contract above: the `pull-requests` CLI and route, the PR response field list,
`derivePRState`, the two-path link (`extractIdentifiers`) vs close-intent
(`extractClosingIdentifiers`) proof, the backlog enqueue lines, child-done
-notify, and the metadata CLI. Re-derive before depending on an exact line.
+notify, the stage column / `stageBarrierClosed` barrier and the `--stage` /
+`issue children` CLI, and the metadata CLI. Re-derive before depending on an
+exact line.
diff --git a/server/internal/service/builtin_skills/multica-working-on-issues/references/working-on-issues-source-map.md b/server/internal/service/builtin_skills/multica-working-on-issues/references/working-on-issues-source-map.md
index 8b9d5e3ad5..a14e028e61 100644
--- a/server/internal/service/builtin_skills/multica-working-on-issues/references/working-on-issues-source-map.md
+++ b/server/internal/service/builtin_skills/multica-working-on-issues/references/working-on-issues-source-map.md
@@ -104,13 +104,27 @@ Net: a bare title prefix (`MUL-2759: ...`) or a branch ref links only;
| `shouldEnqueueAgentTask` returns false for `backlog` (parking lot) | `server/internal/handler/issue.go:2644-2648` | new citation |
| Backlog → non-backlog (not done/cancelled) enqueues on update | `server/internal/handler/issue.go:2537-2540` | `:2523` |
| Same contract in batch update | `server/internal/handler/issue.go:3021-3024` | new citation |
-| Child → `done` posts a system comment on the parent | `server/internal/handler/issue_child_done.go:51` (`notifyParentOfChildDone`; doc comment at `:15`) | func def `:51` |
+| Child → `done` notifies + wakes the parent, gated by the stage barrier | `server/internal/handler/issue_child_done.go:66` (`notifyParentOfChildDone`; doc comment at `:15`; barrier gate at `:115`) | func def `:51` |
Creation with `--status todo` (or any non-backlog status) on an agent-assigned
issue fires the agent immediately; `--status backlog` parks it with the assignee
set but no trigger. Promoting `backlog → todo` later fires it then (update path,
line 2537).
+## Sub-issue stages (barrier wake)
+
+| Behavior | File:line |
+|---|---|
+| `issue.stage` column (nullable, `>= 1`) | `server/migrations/123_issue_stage.up.sql` |
+| Stage barrier: notify+wake fire only when the lowest unfinished stage is all-terminal; unstaged set = one implicit stage | `server/internal/handler/issue_child_done.go:231` (`stageBarrierClosed`) |
+| Per-stage summary + next stage for the wake comment | `server/internal/handler/issue_child_done.go:254` (`stageProgressSummary`) |
+| `--stage` on `issue create` / `issue update` | `server/cmd/multica/cmd_issue.go:328,350` |
+| `multica issue children <id>` (sub-issues grouped by stage) | `server/cmd/multica/cmd_issue.go:114,678`; route `GET /api/issues/{id}/children` → `ListChildIssues` |
+
+Advancement is agent-driven: the server only detects the closed barrier and
+wakes the parent assignee. Promoting the next stage's `backlog` sub-issues to
+`todo` is the woken agent's decision, not a server side effect.
+
## Metadata CLI
| Behavior | File:line |
diff --git a/server/internal/service/issue.go b/server/internal/service/issue.go
index a18a0badc7..b7cace5606 100644
--- a/server/internal/service/issue.go
+++ b/server/internal/service/issue.go
@@ -67,6 +67,9 @@ type IssueCreateParams struct {
OriginID pgtype.UUID
AttachmentIDs []pgtype.UUID
AllowDuplicate bool
+ // Stage groups this issue into an ordered barrier group under its parent
+ // (NULL = unstaged). See issue_child_done.go for the staged-barrier wake.
+ Stage pgtype.Int4
}
// IssueCreateOpts groups optional knobs for IssueService.Create. Most
@@ -145,7 +148,7 @@ type IssueCreateResult struct {
// 8. Publish EventIssueCreated to the bus (payload via opts.BroadcastPayload).
// 9. Capture the IssueCreated analytics event.
// 10. Enqueue an agent task or trigger the squad leader when the issue is
-// assigned and not in `backlog`.
+// assigned and not in `backlog`.
//
// Validation that lives in the service (parent existence, project
// workspace membership, parent → project back-fill) is enforced here so
@@ -239,6 +242,7 @@ func (s *IssueService) Create(ctx context.Context, p IssueCreateParams, opts Iss
ProjectID: projectID,
OriginType: p.OriginType,
OriginID: p.OriginID,
+ Stage: p.Stage,
})
} else {
issue, err = qtx.CreateIssue(ctx, db.CreateIssueParams{
@@ -257,6 +261,7 @@ func (s *IssueService) Create(ctx context.Context, p IssueCreateParams, opts Iss
DueDate: p.DueDate,
Number: issueNumber,
ProjectID: projectID,
+ Stage: p.Stage,
})
}
if err != nil {
diff --git a/server/internal/util/pgx.go b/server/internal/util/pgx.go
index 7d9c50e376..5b344067c6 100644
--- a/server/internal/util/pgx.go
+++ b/server/internal/util/pgx.go
@@ -144,3 +144,17 @@ func Int8ToPtr(v pgtype.Int8) *int64 {
}
return &v.Int64
}
+
+func Int4ToPtr(v pgtype.Int4) *int32 {
+ if !v.Valid {
+ return nil
+ }
+ return &v.Int32
+}
+
+func PtrToInt4(v *int32) pgtype.Int4 {
+ if v == nil {
+ return pgtype.Int4{}
+ }
+ return pgtype.Int4{Int32: *v, Valid: true}
+}
diff --git a/server/migrations/123_issue_stage.down.sql b/server/migrations/123_issue_stage.down.sql
new file mode 100644
index 0000000000..08240f7eaa
--- /dev/null
+++ b/server/migrations/123_issue_stage.down.sql
@@ -0,0 +1 @@
+ALTER TABLE issue DROP COLUMN IF EXISTS stage;
diff --git a/server/migrations/123_issue_stage.up.sql b/server/migrations/123_issue_stage.up.sql
new file mode 100644
index 0000000000..1141b9ddfa
--- /dev/null
+++ b/server/migrations/123_issue_stage.up.sql
@@ -0,0 +1,15 @@
+-- Per-issue `stage` ordinal: groups sub-issues sharing the same parent into
+-- ordered barrier groups. NULL = unstaged (the issue does not participate in
+-- staged grouping). Stage is interpreted relative to siblings under the same
+-- parent_issue_id; a value on a top-level issue is inert.
+--
+-- The child-done -> parent notification + assignee wake fires only when a
+-- stage barrier closes — i.e. every child in the lowest unfinished stage has
+-- reached a terminal status (done/cancelled). Unstaged sibling sets behave as
+-- a single implicit stage, so the wake fires once when the last child
+-- finishes rather than on every child. See
+-- server/internal/handler/issue_child_done.go (stageBarrierClosed).
+--
+-- Stages are 1-based; the CHECK keeps the column clean (NULL or >= 1) so the
+-- "unstaged" sentinel stays unambiguous.
+ALTER TABLE issue ADD COLUMN stage INTEGER CHECK (stage IS NULL OR stage >= 1);
diff --git a/server/pkg/db/generated/issue.sql.go b/server/pkg/db/generated/issue.sql.go
index 8b974ddd29..085df88ae9 100644
--- a/server/pkg/db/generated/issue.sql.go
+++ b/server/pkg/db/generated/issue.sql.go
@@ -174,10 +174,12 @@ const createIssue = `-- name: CreateIssue :one
INSERT INTO issue (
workspace_id, title, description, status, priority,
assignee_type, assignee_id, creator_type, creator_id,
- parent_issue_id, position, start_date, due_date, number, project_id
+ parent_issue_id, position, start_date, due_date, number, project_id,
+ stage
) VALUES (
- $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15
-) RETURNING id, workspace_id, title, description, status, priority, assignee_type, assignee_id, creator_type, creator_id, parent_issue_id, acceptance_criteria, context_refs, position, due_date, created_at, updated_at, number, project_id, origin_type, origin_id, first_executed_at, start_date, metadata
+ $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15,
+ $16
+) RETURNING id, workspace_id, title, description, status, priority, assignee_type, assignee_id, creator_type, creator_id, parent_issue_id, acceptance_criteria, context_refs, position, due_date, created_at, updated_at, number, project_id, origin_type, origin_id, first_executed_at, start_date, metadata, stage
`
type CreateIssueParams struct {
@@ -196,6 +198,7 @@ type CreateIssueParams struct {
DueDate pgtype.Date `json:"due_date"`
Number int32 `json:"number"`
ProjectID pgtype.UUID `json:"project_id"`
+ Stage pgtype.Int4 `json:"stage"`
}
func (q *Queries) CreateIssue(ctx context.Context, arg CreateIssueParams) (Issue, error) {
@@ -215,6 +218,7 @@ func (q *Queries) CreateIssue(ctx context.Context, arg CreateIssueParams) (Issue
arg.DueDate,
arg.Number,
arg.ProjectID,
+ arg.Stage,
)
var i Issue
err := row.Scan(
@@ -242,6 +246,7 @@ func (q *Queries) CreateIssue(ctx context.Context, arg CreateIssueParams) (Issue
&i.FirstExecutedAt,
&i.StartDate,
&i.Metadata,
+ &i.Stage,
)
return i, err
}
@@ -251,11 +256,11 @@ INSERT INTO issue (
workspace_id, title, description, status, priority,
assignee_type, assignee_id, creator_type, creator_id,
parent_issue_id, position, start_date, due_date, number, project_id,
- origin_type, origin_id
+ origin_type, origin_id, stage
) VALUES (
$1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15,
- $16, $17
-) RETURNING id, workspace_id, title, description, status, priority, assignee_type, assignee_id, creator_type, creator_id, parent_issue_id, acceptance_criteria, context_refs, position, due_date, created_at, updated_at, number, project_id, origin_type, origin_id, first_executed_at, start_date, metadata
+ $16, $17, $18
+) RETURNING id, workspace_id, title, description, status, priority, assignee_type, assignee_id, creator_type, creator_id, parent_issue_id, acceptance_criteria, context_refs, position, due_date, created_at, updated_at, number, project_id, origin_type, origin_id, first_executed_at, start_date, metadata, stage
`
type CreateIssueWithOriginParams struct {
@@ -276,6 +281,7 @@ type CreateIssueWithOriginParams struct {
ProjectID pgtype.UUID `json:"project_id"`
OriginType pgtype.Text `json:"origin_type"`
OriginID pgtype.UUID `json:"origin_id"`
+ Stage pgtype.Int4 `json:"stage"`
}
func (q *Queries) CreateIssueWithOrigin(ctx context.Context, arg CreateIssueWithOriginParams) (Issue, error) {
@@ -297,6 +303,7 @@ func (q *Queries) CreateIssueWithOrigin(ctx context.Context, arg CreateIssueWith
arg.ProjectID,
arg.OriginType,
arg.OriginID,
+ arg.Stage,
)
var i Issue
err := row.Scan(
@@ -324,6 +331,7 @@ func (q *Queries) CreateIssueWithOrigin(ctx context.Context, arg CreateIssueWith
&i.FirstExecutedAt,
&i.StartDate,
&i.Metadata,
+ &i.Stage,
)
return i, err
}
@@ -352,7 +360,7 @@ UPDATE issue SET
metadata = metadata - $1::text,
updated_at = now()
WHERE id = $2 AND workspace_id = $3
-RETURNING id, workspace_id, title, description, status, priority, assignee_type, assignee_id, creator_type, creator_id, parent_issue_id, acceptance_criteria, context_refs, position, due_date, created_at, updated_at, number, project_id, origin_type, origin_id, first_executed_at, start_date, metadata
+RETURNING id, workspace_id, title, description, status, priority, assignee_type, assignee_id, creator_type, creator_id, parent_issue_id, acceptance_criteria, context_refs, position, due_date, created_at, updated_at, number, project_id, origin_type, origin_id, first_executed_at, start_date, metadata, stage
`
type DeleteIssueMetadataKeyParams struct {
@@ -391,12 +399,13 @@ func (q *Queries) DeleteIssueMetadataKey(ctx context.Context, arg DeleteIssueMet
&i.FirstExecutedAt,
&i.StartDate,
&i.Metadata,
+ &i.Stage,
)
return i, err
}
const findActiveDuplicateIssue = `-- name: FindActiveDuplicateIssue :one
-SELECT id, workspace_id, title, description, status, priority, assignee_type, assignee_id, creator_type, creator_id, parent_issue_id, acceptance_criteria, context_refs, position, due_date, created_at, updated_at, number, project_id, origin_type, origin_id, first_executed_at, start_date, metadata FROM issue
+SELECT id, workspace_id, title, description, status, priority, assignee_type, assignee_id, creator_type, creator_id, parent_issue_id, acceptance_criteria, context_refs, position, due_date, created_at, updated_at, number, project_id, origin_type, origin_id, first_executed_at, start_date, metadata, stage FROM issue
WHERE workspace_id = $1
AND status NOT IN ('done', 'cancelled')
AND project_id IS NOT DISTINCT FROM $2::uuid
@@ -446,12 +455,13 @@ func (q *Queries) FindActiveDuplicateIssue(ctx context.Context, arg FindActiveDu
&i.FirstExecutedAt,
&i.StartDate,
&i.Metadata,
+ &i.Stage,
)
return i, err
}
const getIssue = `-- name: GetIssue :one
-SELECT id, workspace_id, title, description, status, priority, assignee_type, assignee_id, creator_type, creator_id, parent_issue_id, acceptance_criteria, context_refs, position, due_date, created_at, updated_at, number, project_id, origin_type, origin_id, first_executed_at, start_date, metadata FROM issue
+SELECT id, workspace_id, title, description, status, priority, assignee_type, assignee_id, creator_type, creator_id, parent_issue_id, acceptance_criteria, context_refs, position, due_date, created_at, updated_at, number, project_id, origin_type, origin_id, first_executed_at, start_date, metadata, stage FROM issue
WHERE id = $1
`
@@ -483,12 +493,13 @@ func (q *Queries) GetIssue(ctx context.Context, id pgtype.UUID) (Issue, error) {
&i.FirstExecutedAt,
&i.StartDate,
&i.Metadata,
+ &i.Stage,
)
return i, err
}
const getIssueByNumber = `-- name: GetIssueByNumber :one
-SELECT id, workspace_id, title, description, status, priority, assignee_type, assignee_id, creator_type, creator_id, parent_issue_id, acceptance_criteria, context_refs, position, due_date, created_at, updated_at, number, project_id, origin_type, origin_id, first_executed_at, start_date, metadata FROM issue
+SELECT id, workspace_id, title, description, status, priority, assignee_type, assignee_id, creator_type, creator_id, parent_issue_id, acceptance_criteria, context_refs, position, due_date, created_at, updated_at, number, project_id, origin_type, origin_id, first_executed_at, start_date, metadata, stage FROM issue
WHERE workspace_id = $1 AND number = $2
`
@@ -525,12 +536,13 @@ func (q *Queries) GetIssueByNumber(ctx context.Context, arg GetIssueByNumberPara
&i.FirstExecutedAt,
&i.StartDate,
&i.Metadata,
+ &i.Stage,
)
return i, err
}
const getIssueByOrigin = `-- name: GetIssueByOrigin :one
-SELECT id, workspace_id, title, description, status, priority, assignee_type, assignee_id, creator_type, creator_id, parent_issue_id, acceptance_criteria, context_refs, position, due_date, created_at, updated_at, number, project_id, origin_type, origin_id, first_executed_at, start_date, metadata FROM issue
+SELECT id, workspace_id, title, description, status, priority, assignee_type, assignee_id, creator_type, creator_id, parent_issue_id, acceptance_criteria, context_refs, position, due_date, created_at, updated_at, number, project_id, origin_type, origin_id, first_executed_at, start_date, metadata, stage FROM issue
WHERE workspace_id = $1
AND origin_type = $2
AND origin_id = $3
@@ -576,12 +588,13 @@ func (q *Queries) GetIssueByOrigin(ctx context.Context, arg GetIssueByOriginPara
&i.FirstExecutedAt,
&i.StartDate,
&i.Metadata,
+ &i.Stage,
)
return i, err
}
const getIssueInWorkspace = `-- name: GetIssueInWorkspace :one
-SELECT id, workspace_id, title, description, status, priority, assignee_type, assignee_id, creator_type, creator_id, parent_issue_id, acceptance_criteria, context_refs, position, due_date, created_at, updated_at, number, project_id, origin_type, origin_id, first_executed_at, start_date, metadata FROM issue
+SELECT id, workspace_id, title, description, status, priority, assignee_type, assignee_id, creator_type, creator_id, parent_issue_id, acceptance_criteria, context_refs, position, due_date, created_at, updated_at, number, project_id, origin_type, origin_id, first_executed_at, start_date, metadata, stage FROM issue
WHERE id = $1 AND workspace_id = $2
`
@@ -618,12 +631,13 @@ func (q *Queries) GetIssueInWorkspace(ctx context.Context, arg GetIssueInWorkspa
&i.FirstExecutedAt,
&i.StartDate,
&i.Metadata,
+ &i.Stage,
)
return i, err
}
const listChildIssues = `-- name: ListChildIssues :many
-SELECT id, workspace_id, title, description, status, priority, assignee_type, assignee_id, creator_type, creator_id, parent_issue_id, acceptance_criteria, context_refs, position, due_date, created_at, updated_at, number, project_id, origin_type, origin_id, first_executed_at, start_date, metadata FROM issue
+SELECT id, workspace_id, title, description, status, priority, assignee_type, assignee_id, creator_type, creator_id, parent_issue_id, acceptance_criteria, context_refs, position, due_date, created_at, updated_at, number, project_id, origin_type, origin_id, first_executed_at, start_date, metadata, stage FROM issue
WHERE parent_issue_id = $1
ORDER BY position ASC, created_at DESC
`
@@ -662,6 +676,7 @@ func (q *Queries) ListChildIssues(ctx context.Context, parentIssueID pgtype.UUID
&i.FirstExecutedAt,
&i.StartDate,
&i.Metadata,
+ &i.Stage,
); err != nil {
return nil, err
}
@@ -674,7 +689,7 @@ func (q *Queries) ListChildIssues(ctx context.Context, parentIssueID pgtype.UUID
}
const listChildrenByParents = `-- name: ListChildrenByParents :many
-SELECT id, workspace_id, title, description, status, priority, assignee_type, assignee_id, creator_type, creator_id, parent_issue_id, acceptance_criteria, context_refs, position, due_date, created_at, updated_at, number, project_id, origin_type, origin_id, first_executed_at, start_date, metadata FROM issue
+SELECT id, workspace_id, title, description, status, priority, assignee_type, assignee_id, creator_type, creator_id, parent_issue_id, acceptance_criteria, context_refs, position, due_date, created_at, updated_at, number, project_id, origin_type, origin_id, first_executed_at, start_date, metadata, stage FROM issue
WHERE workspace_id = $1
AND parent_issue_id = ANY($2::uuid[])
ORDER BY parent_issue_id, position ASC, created_at DESC
@@ -724,6 +739,7 @@ func (q *Queries) ListChildrenByParents(ctx context.Context, arg ListChildrenByP
&i.FirstExecutedAt,
&i.StartDate,
&i.Metadata,
+ &i.Stage,
); err != nil {
return nil, err
}
@@ -738,7 +754,7 @@ func (q *Queries) ListChildrenByParents(ctx context.Context, arg ListChildrenByP
const listIssues = `-- name: ListIssues :many
SELECT i.id, i.workspace_id, i.title, i.description, i.status, i.priority,
i.assignee_type, i.assignee_id, i.creator_type, i.creator_id,
- i.parent_issue_id, i.position, i.start_date, i.due_date, i.created_at, i.updated_at, i.number, i.project_id, i.metadata
+ i.parent_issue_id, i.position, i.start_date, i.due_date, i.created_at, i.updated_at, i.number, i.project_id, i.metadata, i.stage
FROM issue i
WHERE i.workspace_id = $1
AND ($4::text IS NULL OR i.status = $4)
@@ -828,6 +844,7 @@ type ListIssuesRow struct {
Number int32 `json:"number"`
ProjectID pgtype.UUID `json:"project_id"`
Metadata []byte `json:"metadata"`
+ Stage pgtype.Int4 `json:"stage"`
}
// involves_user_id widens the assignee filter to surface issues where the user
@@ -878,6 +895,7 @@ func (q *Queries) ListIssues(ctx context.Context, arg ListIssuesParams) ([]ListI
&i.Number,
&i.ProjectID,
&i.Metadata,
+ &i.Stage,
); err != nil {
return nil, err
}
@@ -892,7 +910,7 @@ func (q *Queries) ListIssues(ctx context.Context, arg ListIssuesParams) ([]ListI
const listOpenIssues = `-- name: ListOpenIssues :many
SELECT i.id, i.workspace_id, i.title, i.description, i.status, i.priority,
i.assignee_type, i.assignee_id, i.creator_type, i.creator_id,
- i.parent_issue_id, i.position, i.start_date, i.due_date, i.created_at, i.updated_at, i.number, i.project_id, i.metadata
+ i.parent_issue_id, i.position, i.start_date, i.due_date, i.created_at, i.updated_at, i.number, i.project_id, i.metadata, i.stage
FROM issue i
WHERE i.workspace_id = $1
AND i.status NOT IN ('done', 'cancelled')
@@ -968,6 +986,7 @@ type ListOpenIssuesRow struct {
Number int32 `json:"number"`
ProjectID pgtype.UUID `json:"project_id"`
Metadata []byte `json:"metadata"`
+ Stage pgtype.Int4 `json:"stage"`
}
// See ListIssues for the semantics of involves_user_id (mirrors the 4-branch
@@ -1010,6 +1029,7 @@ func (q *Queries) ListOpenIssues(ctx context.Context, arg ListOpenIssuesParams)
&i.Number,
&i.ProjectID,
&i.Metadata,
+ &i.Stage,
); err != nil {
return nil, err
}
@@ -1068,7 +1088,7 @@ UPDATE issue SET
metadata = jsonb_set(metadata, ARRAY[$1::text], $2::jsonb),
updated_at = now()
WHERE id = $3 AND workspace_id = $4
-RETURNING id, workspace_id, title, description, status, priority, assignee_type, assignee_id, creator_type, creator_id, parent_issue_id, acceptance_criteria, context_refs, position, due_date, created_at, updated_at, number, project_id, origin_type, origin_id, first_executed_at, start_date, metadata
+RETURNING id, workspace_id, title, description, status, priority, assignee_type, assignee_id, creator_type, creator_id, parent_issue_id, acceptance_criteria, context_refs, position, due_date, created_at, updated_at, number, project_id, origin_type, origin_id, first_executed_at, start_date, metadata, stage
`
type SetIssueMetadataKeyParams struct {
@@ -1115,6 +1135,7 @@ func (q *Queries) SetIssueMetadataKey(ctx context.Context, arg SetIssueMetadataK
&i.FirstExecutedAt,
&i.StartDate,
&i.Metadata,
+ &i.Stage,
)
return i, err
}
@@ -1132,9 +1153,10 @@ UPDATE issue SET
due_date = $10,
parent_issue_id = $11,
project_id = $12,
+ stage = $13,
updated_at = now()
WHERE id = $1
-RETURNING id, workspace_id, title, description, status, priority, assignee_type, assignee_id, creator_type, creator_id, parent_issue_id, acceptance_criteria, context_refs, position, due_date, created_at, updated_at, number, project_id, origin_type, origin_id, first_executed_at, start_date, metadata
+RETURNING id, workspace_id, title, description, status, priority, assignee_type, assignee_id, creator_type, creator_id, parent_issue_id, acceptance_criteria, context_refs, position, due_date, created_at, updated_at, number, project_id, origin_type, origin_id, first_executed_at, start_date, metadata, stage
`
type UpdateIssueParams struct {
@@ -1150,6 +1172,7 @@ type UpdateIssueParams struct {
DueDate pgtype.Date `json:"due_date"`
ParentIssueID pgtype.UUID `json:"parent_issue_id"`
ProjectID pgtype.UUID `json:"project_id"`
+ Stage pgtype.Int4 `json:"stage"`
}
func (q *Queries) UpdateIssue(ctx context.Context, arg UpdateIssueParams) (Issue, error) {
@@ -1166,6 +1189,7 @@ func (q *Queries) UpdateIssue(ctx context.Context, arg UpdateIssueParams) (Issue
arg.DueDate,
arg.ParentIssueID,
arg.ProjectID,
+ arg.Stage,
)
var i Issue
err := row.Scan(
@@ -1193,6 +1217,7 @@ func (q *Queries) UpdateIssue(ctx context.Context, arg UpdateIssueParams) (Issue
&i.FirstExecutedAt,
&i.StartDate,
&i.Metadata,
+ &i.Stage,
)
return i, err
}
@@ -1202,7 +1227,7 @@ UPDATE issue SET
status = $2,
updated_at = now()
WHERE id = $1 AND workspace_id = $3
-RETURNING id, workspace_id, title, description, status, priority, assignee_type, assignee_id, creator_type, creator_id, parent_issue_id, acceptance_criteria, context_refs, position, due_date, created_at, updated_at, number, project_id, origin_type, origin_id, first_executed_at, start_date, metadata
+RETURNING id, workspace_id, title, description, status, priority, assignee_type, assignee_id, creator_type, creator_id, parent_issue_id, acceptance_criteria, context_refs, position, due_date, created_at, updated_at, number, project_id, origin_type, origin_id, first_executed_at, start_date, metadata, stage
`
type UpdateIssueStatusParams struct {
@@ -1240,6 +1265,7 @@ func (q *Queries) UpdateIssueStatus(ctx context.Context, arg UpdateIssueStatusPa
&i.FirstExecutedAt,
&i.StartDate,
&i.Metadata,
+ &i.Stage,
)
return i, err
}
diff --git a/server/pkg/db/generated/models.go b/server/pkg/db/generated/models.go
index 7fdbab1419..1cfbfcd182 100644
--- a/server/pkg/db/generated/models.go
+++ b/server/pkg/db/generated/models.go
@@ -391,6 +391,7 @@ type Issue struct {
FirstExecutedAt pgtype.Timestamptz `json:"first_executed_at"`
StartDate pgtype.Date `json:"start_date"`
Metadata []byte `json:"metadata"`
+ Stage pgtype.Int4 `json:"stage"`
}
type IssueDependency struct {
diff --git a/server/pkg/db/queries/issue.sql b/server/pkg/db/queries/issue.sql
index d2aaedb1ea..e87ae1b1d3 100644
--- a/server/pkg/db/queries/issue.sql
+++ b/server/pkg/db/queries/issue.sql
@@ -7,7 +7,7 @@
-- "Assigned to me"), and the two filters must produce disjoint result sets.
SELECT i.id, i.workspace_id, i.title, i.description, i.status, i.priority,
i.assignee_type, i.assignee_id, i.creator_type, i.creator_id,
- i.parent_issue_id, i.position, i.start_date, i.due_date, i.created_at, i.updated_at, i.number, i.project_id, i.metadata
+ i.parent_issue_id, i.position, i.start_date, i.due_date, i.created_at, i.updated_at, i.number, i.project_id, i.metadata, i.stage
FROM issue i
WHERE i.workspace_id = $1
AND (sqlc.narg('status')::text IS NULL OR i.status = sqlc.narg('status'))
@@ -73,9 +73,11 @@ WHERE id = $1 AND workspace_id = $2;
INSERT INTO issue (
workspace_id, title, description, status, priority,
assignee_type, assignee_id, creator_type, creator_id,
- parent_issue_id, position, start_date, due_date, number, project_id
+ parent_issue_id, position, start_date, due_date, number, project_id,
+ stage
) VALUES (
- $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15
+ $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15,
+ sqlc.narg('stage')
) RETURNING *;
-- name: GetIssueByNumber :one
@@ -95,6 +97,7 @@ UPDATE issue SET
due_date = sqlc.narg('due_date'),
parent_issue_id = sqlc.narg('parent_issue_id'),
project_id = sqlc.narg('project_id'),
+ stage = sqlc.narg('stage'),
updated_at = now()
WHERE id = $1
RETURNING *;
@@ -112,10 +115,10 @@ INSERT INTO issue (
workspace_id, title, description, status, priority,
assignee_type, assignee_id, creator_type, creator_id,
parent_issue_id, position, start_date, due_date, number, project_id,
- origin_type, origin_id
+ origin_type, origin_id, stage
) VALUES (
$1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15,
- sqlc.narg('origin_type'), sqlc.narg('origin_id')
+ sqlc.narg('origin_type'), sqlc.narg('origin_id'), sqlc.narg('stage')
) RETURNING *;
-- name: LockIssueDuplicateKey :exec
@@ -144,7 +147,7 @@ DELETE FROM issue WHERE id = $1 AND workspace_id = $2;
-- filter; member-direct assignment is intentionally excluded).
SELECT i.id, i.workspace_id, i.title, i.description, i.status, i.priority,
i.assignee_type, i.assignee_id, i.creator_type, i.creator_id,
- i.parent_issue_id, i.position, i.start_date, i.due_date, i.created_at, i.updated_at, i.number, i.project_id, i.metadata
+ i.parent_issue_id, i.position, i.start_date, i.due_date, i.created_at, i.updated_at, i.number, i.project_id, i.metadata, i.stage
FROM issue i
WHERE i.workspace_id = $1
AND i.status NOT IN ('done', 'cancelled')