open-pstack 0.9.173 → 0.9.175

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/NOTICE.md +1 -1
  2. package/lib/bundle.mjs +50 -4
  3. package/lib/cli.mjs +1 -1
  4. package/lib/harnesses.mjs +26 -15
  5. package/lib/steps.mjs +3 -3
  6. package/package.json +1 -1
  7. package/plugin/.antigravity-plugin/plugin.json +1 -1
  8. package/plugin/.claude-plugin/plugin.json +1 -1
  9. package/plugin/.codex-plugin/plugin.json +1 -1
  10. package/plugin/.github/plugin/plugin.json +1 -1
  11. package/plugin/.grok-plugin/plugin.json +1 -1
  12. package/plugin/.muse-plugin/plugin.json +1 -1
  13. package/plugin/hooks/session-start.sh +6 -3
  14. package/plugin/package.json +1 -1
  15. package/plugin/pi/index.ts +3 -2
  16. package/plugin/pi/prompt.ts +8 -3
  17. package/plugin/skills/poteto-mode/playbooks/worktree-cleanup.md +1 -1
  18. package/plugin/skills/poteto-mode/scripts/.prettierignore +3 -0
  19. package/plugin/skills/poteto-mode/scripts/watch-pr/cloud-reader.test.ts +21 -0
  20. package/plugin/skills/poteto-mode/scripts/watch-pr/cloud-reader.ts +7 -0
  21. package/plugin/skills/poteto-mode/scripts/watch-pr/fakes.test-helper.ts +6 -0
  22. package/plugin/skills/poteto-mode/scripts/watch-pr/github.port.test.ts +33 -0
  23. package/plugin/skills/poteto-mode/scripts/watch-pr/github.ts +25 -23
  24. package/plugin/skills/poteto-mode/scripts/watch-pr/head-checks.ts +47 -1
  25. package/plugin/skills/poteto-mode/scripts/watch-pr/policy.port.test.ts +158 -0
  26. package/plugin/skills/poteto-mode/scripts/watch-pr/replay/fixtures/grafana-139602-cancelled-suites-beside-green.json +921 -0
  27. package/plugin/skills/poteto-mode/scripts/watch-pr/replay/fixtures/grafana-139606-approval-gated.json +82 -0
  28. package/plugin/skills/poteto-mode/scripts/watch-pr/replay/fixtures/grafana-139612-cancelled-check-beside-green.json +174 -0
  29. package/plugin/skills/poteto-mode/scripts/watch-pr/replay/fixtures/octocat-hello-world-34-no-checks.json +42 -0
  30. package/plugin/skills/poteto-mode/scripts/watch-pr/replay/gh.ts +144 -0
  31. package/plugin/skills/poteto-mode/scripts/watch-pr/replay/harness.ts +172 -0
  32. package/plugin/skills/poteto-mode/scripts/watch-pr/replay/heads.json +73 -0
  33. package/plugin/skills/poteto-mode/scripts/watch-pr/replay/record.ts +410 -0
  34. package/plugin/skills/poteto-mode/scripts/watch-pr/replay/watch.ts +72 -0
  35. package/plugin/skills/poteto-mode/scripts/watch-pr/replay.port.test.ts +264 -0
  36. package/plugin/skills/poteto-mode/scripts/watch-pr/types.ts +2 -0
  37. package/plugin/skills/poteto-mode/scripts/watch-pr/workflow-runs.ts +58 -21
  38. package/plugin/skills/poteto-mode/scripts/worktree-audit.mjs +75 -6
  39. package/plugin/skills/setup-pstack/scripts/read-sheet.sh +6 -2
  40. package/plugin/vibe/plugin.json +1 -1
@@ -11,6 +11,7 @@ import {
11
11
  import { fakeReader, failedCheck, pendingCheck } from "./fakes.test-helper.ts";
12
12
  import { unsettledSuiteChecks } from "./github.ts";
13
13
  import type {
14
+ Check,
14
15
  GitHubReader,
15
16
  NonEmpty,
16
17
  PollingOptions,
@@ -877,6 +878,163 @@ describe("check suites that no check read shows", () => {
877
878
  });
878
879
  });
879
880
 
881
+ // grafana/grafana PR 139612 at 8c63a54b, read on 2026-12-03: gh pr checks
882
+ // listed a Bundle size job cancelled before its matrix expanded, so no job of
883
+ // the later, passing Bundle size run shares its name. Both runs are workflow
884
+ // 342766777 on pull_request.
885
+ describe("a cancelled check from a run a later run replaced", () => {
886
+ const head = "8c63a54b5334bc97775bbfcfe858424434ff2d1f";
887
+ const jobLink = (run: number, job: number) =>
888
+ `https://github.com/grafana/grafana/actions/runs/${run}/job/${job}`;
889
+ const cancelled = {
890
+ kind: "failed",
891
+ name: "Build ${{ matrix.target }} frontend",
892
+ reportedState: "CANCELLED",
893
+ description: "",
894
+ link: jobLink(47100668579, 144370325863),
895
+ workflow: "Bundle size",
896
+ } as const;
897
+ const rebuilt = {
898
+ kind: "passed",
899
+ name: "Build pr frontend",
900
+ reportedState: "SUCCESS",
901
+ description: "",
902
+ link: jobLink(47139247402, 144371788751),
903
+ workflow: "Bundle size",
904
+ } as const;
905
+ const run = (
906
+ id: number,
907
+ suite: number,
908
+ createdAt: string,
909
+ conclusion: string | null
910
+ ) => ({
911
+ id,
912
+ workflow_id: 342766777,
913
+ check_suite_id: suite,
914
+ event: "pull_request",
915
+ head_sha: head,
916
+ status: conclusion === null ? "in_progress" : "completed",
917
+ conclusion,
918
+ created_at: createdAt,
919
+ name: "Bundle size",
920
+ });
921
+ const first = run(
922
+ 47100668579,
923
+ 127381116871,
924
+ "2026-12-03T11:56:06Z",
925
+ "cancelled"
926
+ );
927
+ const second = run(
928
+ 47139247402,
929
+ 127486757905,
930
+ "2026-12-03T15:29:54Z",
931
+ "success"
932
+ );
933
+ const read = async (
934
+ checks: readonly Check[],
935
+ workflowRuns: readonly unknown[]
936
+ ) => {
937
+ const reader = fakeReader({
938
+ facts: { headRefOid: head },
939
+ fastPath: { kind: "checks", checks: checks as [Check, ...Check[]] },
940
+ commitRollups: [{ oid: head, state: "SUCCESS" }],
941
+ workflowRuns,
942
+ });
943
+ const snapshot = await readSnapshot({
944
+ reader,
945
+ context: context(40),
946
+ pendingHistory: "include",
947
+ allowDraft: false,
948
+ });
949
+ return { snapshot, calls: reader.calls };
950
+ };
951
+
952
+ it("drops it when a later run of the same workflow and event succeeded", async () => {
953
+ const { snapshot, calls } = await read(
954
+ [cancelled, rebuilt],
955
+ [second, first]
956
+ );
957
+ expect(snapshot).toMatchObject({ ci: { kind: "ci-clean" } });
958
+ expect(calls).toContain(`workflowRunPages:${head}`);
959
+ expect(calls).toContain(`unsettledSuites:${head}:reported`);
960
+ });
961
+
962
+ // gh lists only the jobs a run has started, so a running replacement can
963
+ // show nothing but passes between one job and the next.
964
+ it("keeps it failed while the later run is still running", async () => {
965
+ const running = {
966
+ ...rebuilt,
967
+ kind: "pending",
968
+ reportedState: "IN_PROGRESS",
969
+ } as const;
970
+ for (const checks of [
971
+ [cancelled, running],
972
+ [cancelled, rebuilt],
973
+ ])
974
+ expect(
975
+ (
976
+ await read(checks, [
977
+ { ...second, status: "in_progress", conclusion: null },
978
+ first,
979
+ ])
980
+ ).snapshot
981
+ ).toMatchObject({ ci: { kind: "ci-failing", failed: [cancelled] } });
982
+ });
983
+
984
+ it("keeps it failed, and reads no runs, when another check failed", async () => {
985
+ const failing = failedCheck();
986
+ const { snapshot, calls } = await read(
987
+ [cancelled, rebuilt, failing],
988
+ [second, first]
989
+ );
990
+ expect(snapshot).toMatchObject({
991
+ ci: { kind: "ci-failing", failed: [cancelled, failing] },
992
+ });
993
+ expect(calls.filter((call) => call.startsWith("workflowRunPages"))).toEqual(
994
+ []
995
+ );
996
+ });
997
+
998
+ it("keeps it failed when no later run replaced it", async () => {
999
+ for (const runs of [
1000
+ [first],
1001
+ [{ ...second, conclusion: "cancelled" }, first],
1002
+ [{ ...second, event: "push" }, first],
1003
+ ])
1004
+ expect((await read([cancelled, rebuilt], runs)).snapshot).toMatchObject({
1005
+ ci: { kind: "ci-failing", failed: [cancelled] },
1006
+ });
1007
+ });
1008
+
1009
+ it("keeps it failed when its run is not one of the head's runs", async () => {
1010
+ const { snapshot } = await read([cancelled, rebuilt], [second]);
1011
+ expect(snapshot).toMatchObject({
1012
+ ci: { kind: "ci-failing", failed: [cancelled] },
1013
+ });
1014
+ });
1015
+
1016
+ it("keeps it failed, and reads no runs, when its link names no run", async () => {
1017
+ const unlinked = { ...cancelled, link: "" };
1018
+ const { snapshot, calls } = await read(
1019
+ [unlinked, rebuilt],
1020
+ [second, first]
1021
+ );
1022
+ expect(snapshot).toMatchObject({
1023
+ ci: { kind: "ci-failing", failed: [unlinked] },
1024
+ });
1025
+ expect(calls.filter((call) => call.startsWith("workflowRunPages"))).toEqual(
1026
+ []
1027
+ );
1028
+ });
1029
+
1030
+ it("reads no runs when no check was cancelled", async () => {
1031
+ const { calls } = await read([rebuilt, failedCheck()], [second, first]);
1032
+ expect(calls.filter((call) => call.startsWith("workflowRunPages"))).toEqual(
1033
+ []
1034
+ );
1035
+ });
1036
+ });
1037
+
880
1038
  describe("apps named with --expect-app", () => {
881
1039
  const queuedSuite = (slug: string, name: string) => ({
882
1040
  head_sha: "head",