Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions packages/gittensory-engine/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,20 @@ rendering.
Each builder returns `RawPlanStep[]` in the shape accepted by `gittensory_build_plan`. Templates are pure data — they
describe step ordering via `dependsOn` but never actuate anything.

## Plan DAG status helpers

`plan-export.ts` renders a validated `PlanDag`; the helpers below are pure predicates over that shape for miner and
dashboard progress summaries:

- `countPlanSteps(plan)` — total step count
- `countPlanStepsByStatus(plan, status)` — steps matching a `PlanStepStatus`
- `isPlanEmpty(plan)` — whether the plan has no steps
- `isPlanFullyCompleted(plan)` — every step is `completed` (empty plans are not complete)
- `hasPlanFailedSteps(plan)` — any step is `failed`
- `hasPlanPendingSteps(plan)` — any step is `pending`
- `hasPlanRunningSteps(plan)` — any step is `running`
- `hasPlanSkippedSteps(plan)` — any step is `skipped`

## Opportunity competition

`computeOpportunityCompetition(highRiskDuplicateClusters, openPullRequests)` mirrors the hosted
Expand Down
1 change: 1 addition & 0 deletions packages/gittensory-engine/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ export { isPlanFullyCompleted } from "./plan-completion.js";
export { hasPlanFailedSteps } from "./plan-failure.js";
export { hasPlanPendingSteps } from "./plan-pending.js";
export { hasPlanRunningSteps } from "./plan-running.js";
export { hasPlanSkippedSteps } from "./plan-skipped.js";
export * from "./plan-templates.js";
export * from "./portfolio/queue.js";
export {
Expand Down
8 changes: 8 additions & 0 deletions packages/gittensory-engine/src/plan-skipped.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import type { PlanDag } from "./plan-export.js";

/**
* Return whether any step in the plan was skipped. Pure — reads the plan DAG only.
*/
export function hasPlanSkippedSteps(plan: PlanDag): boolean {
return plan.steps.some((step) => step.status === "skipped");
}
54 changes: 54 additions & 0 deletions test/unit/plan-skipped.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { describe, expect, it } from "vitest";

import { hasPlanSkippedSteps } from "../../packages/gittensory-engine/src/plan-skipped";
import type { PlanStep } from "../../packages/gittensory-engine/src/plan-export";

function step(over: Partial<PlanStep> & { id: string; title: string }): PlanStep {
return {
actionClass: undefined,
dependsOn: [],
status: "pending",
attempts: 0,
maxAttempts: 3,
lastError: null,
...over,
};
}

describe("hasPlanSkippedSteps", () => {
it("returns false for an empty plan", () => {
expect(hasPlanSkippedSteps({ steps: [] })).toBe(false);
});

it("returns false when no step was skipped", () => {
expect(
hasPlanSkippedSteps({
steps: [
step({ id: "a", title: "Build", status: "completed" }),
step({ id: "b", title: "Test", status: "pending" }),
],
}),
).toBe(false);
});

it("returns true when at least one step was skipped", () => {
expect(
hasPlanSkippedSteps({
steps: [
step({ id: "a", title: "Build", status: "completed" }),
step({ id: "b", title: "Deploy", status: "skipped" }),
],
}),
).toBe(true);
});

it("is exported from the package barrel", async () => {
const barrel = await import("../../packages/gittensory-engine/src/index");
expect(typeof barrel.hasPlanSkippedSteps).toBe("function");
expect(
barrel.hasPlanSkippedSteps({
steps: [step({ id: "a", title: "A", status: "skipped" })],
}),
).toBe(true);
});
});
Loading