Skip to content

Commit 4fd8c9d

Browse files
feat(engine): add hasPlanSkippedSteps and document plan DAG helpers (#3470)
Closes #2298 Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent e1fa8e5 commit 4fd8c9d

4 files changed

Lines changed: 77 additions & 0 deletions

File tree

packages/gittensory-engine/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,20 @@ rendering.
517517
Each builder returns `RawPlanStep[]` in the shape accepted by `gittensory_build_plan`. Templates are pure data — they
518518
describe step ordering via `dependsOn` but never actuate anything.
519519

520+
## Plan DAG status helpers
521+
522+
`plan-export.ts` renders a validated `PlanDag`; the helpers below are pure predicates over that shape for miner and
523+
dashboard progress summaries:
524+
525+
- `countPlanSteps(plan)` — total step count
526+
- `countPlanStepsByStatus(plan, status)` — steps matching a `PlanStepStatus`
527+
- `isPlanEmpty(plan)` — whether the plan has no steps
528+
- `isPlanFullyCompleted(plan)` — every step is `completed` (empty plans are not complete)
529+
- `hasPlanFailedSteps(plan)` — any step is `failed`
530+
- `hasPlanPendingSteps(plan)` — any step is `pending`
531+
- `hasPlanRunningSteps(plan)` — any step is `running`
532+
- `hasPlanSkippedSteps(plan)` — any step is `skipped`
533+
520534
## Opportunity competition
521535

522536
`computeOpportunityCompetition(highRiskDuplicateClusters, openPullRequests)` mirrors the hosted

packages/gittensory-engine/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ export { isPlanFullyCompleted } from "./plan-completion.js";
143143
export { hasPlanFailedSteps } from "./plan-failure.js";
144144
export { hasPlanPendingSteps } from "./plan-pending.js";
145145
export { hasPlanRunningSteps } from "./plan-running.js";
146+
export { hasPlanSkippedSteps } from "./plan-skipped.js";
146147
export * from "./plan-templates.js";
147148
export * from "./portfolio/queue.js";
148149
export {
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import type { PlanDag } from "./plan-export.js";
2+
3+
/**
4+
* Return whether any step in the plan was skipped. Pure — reads the plan DAG only.
5+
*/
6+
export function hasPlanSkippedSteps(plan: PlanDag): boolean {
7+
return plan.steps.some((step) => step.status === "skipped");
8+
}

test/unit/plan-skipped.test.ts

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import { describe, expect, it } from "vitest";
2+
3+
import { hasPlanSkippedSteps } from "../../packages/gittensory-engine/src/plan-skipped";
4+
import type { PlanStep } from "../../packages/gittensory-engine/src/plan-export";
5+
6+
function step(over: Partial<PlanStep> & { id: string; title: string }): PlanStep {
7+
return {
8+
actionClass: undefined,
9+
dependsOn: [],
10+
status: "pending",
11+
attempts: 0,
12+
maxAttempts: 3,
13+
lastError: null,
14+
...over,
15+
};
16+
}
17+
18+
describe("hasPlanSkippedSteps", () => {
19+
it("returns false for an empty plan", () => {
20+
expect(hasPlanSkippedSteps({ steps: [] })).toBe(false);
21+
});
22+
23+
it("returns false when no step was skipped", () => {
24+
expect(
25+
hasPlanSkippedSteps({
26+
steps: [
27+
step({ id: "a", title: "Build", status: "completed" }),
28+
step({ id: "b", title: "Test", status: "pending" }),
29+
],
30+
}),
31+
).toBe(false);
32+
});
33+
34+
it("returns true when at least one step was skipped", () => {
35+
expect(
36+
hasPlanSkippedSteps({
37+
steps: [
38+
step({ id: "a", title: "Build", status: "completed" }),
39+
step({ id: "b", title: "Deploy", status: "skipped" }),
40+
],
41+
}),
42+
).toBe(true);
43+
});
44+
45+
it("is exported from the package barrel", async () => {
46+
const barrel = await import("../../packages/gittensory-engine/src/index");
47+
expect(typeof barrel.hasPlanSkippedSteps).toBe("function");
48+
expect(
49+
barrel.hasPlanSkippedSteps({
50+
steps: [step({ id: "a", title: "A", status: "skipped" })],
51+
}),
52+
).toBe(true);
53+
});
54+
});

0 commit comments

Comments
 (0)