@emiliosp/pi-maestro 0.1.0 → 0.1.2

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.
@@ -1,6 +1,6 @@
1
1
  /**
2
- * Objective: Prepare a committed builder launch checkpoint in the current checkout.
3
- * Used: Before Maestro launches a builder pass.
2
+ * Objective: Prepare a committed builder run checkpoint in the current checkout.
3
+ * Used: Before Maestro runs a builder pass.
4
4
  */
5
5
 
6
6
  import { rm } from 'node:fs/promises';
@@ -14,22 +14,22 @@ import { WORKFLOW_EVENTS, WORKFLOW_PHASES } from '#workflow/state/schema.ts';
14
14
  import { writeWorkflowState } from '#workflow/state/writeWorkflowState.ts';
15
15
  import { transitionWorkflow } from '#workflow/transitions.ts';
16
16
 
17
- export type BuilderLaunch = {
17
+ export type BuilderRun = {
18
18
  specId: string;
19
19
  revision: number;
20
20
  repositoryRoot: string;
21
21
  checkpointCommit: string;
22
22
  };
23
23
 
24
- type AssertBuilderLaunchBaseInput = {
24
+ type AssertBuilderRunBaseInput = {
25
25
  paths: MaestroPaths;
26
26
  specId: string;
27
27
  };
28
28
 
29
- async function assertBuilderLaunchBase({
29
+ async function assertBuilderRunBase({
30
30
  paths,
31
31
  specId,
32
- }: AssertBuilderLaunchBaseInput): Promise<void> {
32
+ }: AssertBuilderRunBaseInput): Promise<void> {
33
33
  const state = await readWorkflowState(paths.getWorkflowPath(specId));
34
34
 
35
35
  if (state.specId !== specId) {
@@ -39,13 +39,13 @@ async function assertBuilderLaunchBase({
39
39
  }
40
40
 
41
41
  if (state.phase !== WORKFLOW_PHASES.READY_FOR_BUILDER) {
42
- throw new Error(`Builder launch is not valid from phase "${state.phase}".`);
42
+ throw new Error(`Builder run is not valid from phase "${state.phase}".`);
43
43
  }
44
44
 
45
45
  const status = await getRepositoryStatus(paths.getRepositoryRoot());
46
46
 
47
47
  if (!status.clean) {
48
- throw new Error('Builder launch requires a clean current checkout.');
48
+ throw new Error('Builder run requires a clean current checkout.');
49
49
  }
50
50
 
51
51
  if (!(await pathExists(paths.getSpecFilePath(specId)))) {
@@ -53,24 +53,24 @@ async function assertBuilderLaunchBase({
53
53
  }
54
54
  }
55
55
 
56
- type PrepareBuilderLaunchInput = {
56
+ type PrepareBuilderRunInput = {
57
57
  paths: MaestroPaths;
58
58
  specId: string;
59
59
  };
60
60
 
61
- export const prepareBuilderLaunch = async ({
61
+ export const prepareBuilderRun = async ({
62
62
  paths,
63
63
  specId,
64
- }: PrepareBuilderLaunchInput): Promise<BuilderLaunch> => {
64
+ }: PrepareBuilderRunInput): Promise<BuilderRun> => {
65
65
  const activeSpecId = maestroSessionState.getActiveSpecId();
66
66
 
67
67
  if (activeSpecId !== specId) {
68
68
  throw new Error(
69
- `Builder launch requires active Maestro spec "${specId}", found "${activeSpecId ?? 'none'}".`,
69
+ `Builder run requires active Maestro spec "${specId}", found "${activeSpecId ?? 'none'}".`,
70
70
  );
71
71
  }
72
72
 
73
- await assertBuilderLaunchBase({ paths, specId });
73
+ await assertBuilderRunBase({ paths, specId });
74
74
 
75
75
  const workflowPath = paths.getWorkflowPath(specId);
76
76
  const handoffPath = paths.getBuilderHandoffPath(specId);
@@ -83,7 +83,7 @@ export const prepareBuilderLaunch = async ({
83
83
 
84
84
  const nextState = transitionWorkflow({
85
85
  state: currentState,
86
- event: WORKFLOW_EVENTS.LAUNCH_BUILDER,
86
+ event: WORKFLOW_EVENTS.RUN_BUILDER,
87
87
  });
88
88
 
89
89
  await writeWorkflowState({
@@ -23,13 +23,12 @@ export const WORKFLOW_PHASES = {
23
23
 
24
24
  export const WORKFLOW_EVENTS = {
25
25
  MARK_SPEC_READY: 'mark-spec-ready',
26
- LAUNCH_BUILDER: 'launch-builder',
26
+ RUN_BUILDER: 'run-builder',
27
27
  OPEN_ESCALATION: 'open-escalation',
28
28
  RESOLVE_ESCALATION: 'resolve-escalation',
29
29
  BUILDER_FAILED: 'builder-failed',
30
30
  BUILDER_DONE: 'builder-done',
31
- LAUNCH_VERIFIER: 'launch-verifier',
32
- RETRY_VERIFIER: 'retry-verifier',
31
+ RUN_VERIFIER: 'run-verifier',
33
32
  VERIFIER_FOUND_FINDINGS: 'verifier-found-findings',
34
33
  VERIFIER_APPROVED: 'verifier-approved',
35
34
  REJECT_FINDINGS: 'reject-findings',
@@ -26,7 +26,7 @@ export const WORKFLOW_TRANSITIONS: Record<WorkflowEvent, WorkflowTransition> = {
26
26
  ],
27
27
  to: WORKFLOW_PHASES.READY_FOR_BUILDER,
28
28
  },
29
- [WORKFLOW_EVENTS.LAUNCH_BUILDER]: {
29
+ [WORKFLOW_EVENTS.RUN_BUILDER]: {
30
30
  from: [WORKFLOW_PHASES.READY_FOR_BUILDER],
31
31
  to: WORKFLOW_PHASES.BUILDER_RUNNING,
32
32
  },
@@ -46,14 +46,10 @@ export const WORKFLOW_TRANSITIONS: Record<WorkflowEvent, WorkflowTransition> = {
46
46
  from: [WORKFLOW_PHASES.BUILDER_RUNNING],
47
47
  to: WORKFLOW_PHASES.READY_FOR_VERIFIER,
48
48
  },
49
- [WORKFLOW_EVENTS.LAUNCH_VERIFIER]: {
49
+ [WORKFLOW_EVENTS.RUN_VERIFIER]: {
50
50
  from: [WORKFLOW_PHASES.READY_FOR_VERIFIER],
51
51
  to: WORKFLOW_PHASES.VERIFIER_RUNNING,
52
52
  },
53
- [WORKFLOW_EVENTS.RETRY_VERIFIER]: {
54
- from: [WORKFLOW_PHASES.VERIFIER_RUNNING],
55
- to: WORKFLOW_PHASES.VERIFIER_RUNNING,
56
- },
57
53
  [WORKFLOW_EVENTS.VERIFIER_FOUND_FINDINGS]: {
58
54
  from: [WORKFLOW_PHASES.VERIFIER_RUNNING],
59
55
  to: WORKFLOW_PHASES.FINDINGS_DECISION,
@@ -1,21 +1,20 @@
1
1
  /**
2
- * Objective: Prepare a committed verifier launch checkpoint in the current checkout.
2
+ * Objective: Prepare a committed verifier run checkpoint in the current checkout.
3
3
  * Used: When Maestro starts a verifier pass.
4
4
  */
5
5
 
6
6
  import { rm } from 'node:fs/promises';
7
7
  import { createWorkflowCheckpointCommit } from '#git/commits/createWorkflowCheckpointCommit.ts';
8
- import { getParentCommit } from '#git/history/getParentCommit.ts';
9
- import { getHeadCommit } from '#git/repository/getHeadCommit.ts';
10
8
  import { getRepositoryStatus } from '#git/repository/getRepositoryStatus.ts';
11
9
  import type { MaestroPaths } from '#MaestroPaths.ts';
10
+ import maestroSessionState from '#maestro/session/MaestroSessionState.ts';
12
11
  import { pathExists } from '#utils/path-exists.ts';
13
12
  import { readWorkflowState } from '#workflow/state/readWorkflowState.ts';
14
13
  import { WORKFLOW_EVENTS, WORKFLOW_PHASES } from '#workflow/state/schema.ts';
15
14
  import { writeWorkflowState } from '#workflow/state/writeWorkflowState.ts';
16
15
  import { transitionWorkflow } from '#workflow/transitions.ts';
17
16
 
18
- export type VerifierLaunch = {
17
+ export type VerifierRun = {
19
18
  specId: string;
20
19
  repositoryRoot: string;
21
20
  candidateCommit: string;
@@ -23,15 +22,15 @@ export type VerifierLaunch = {
23
22
  revision: number;
24
23
  };
25
24
 
26
- type PrepareVerifierLaunchInput = {
25
+ type PrepareVerifierRunInput = {
27
26
  paths: MaestroPaths;
28
27
  specId: string;
29
28
  };
30
29
 
31
- export const prepareVerifierLaunch = async ({
30
+ export const prepareVerifierRun = async ({
32
31
  paths,
33
32
  specId,
34
- }: PrepareVerifierLaunchInput): Promise<VerifierLaunch> => {
33
+ }: PrepareVerifierRunInput): Promise<VerifierRun> => {
35
34
  const repositoryRoot = paths.getRepositoryRoot();
36
35
  const workflowPath = paths.getWorkflowPath(specId);
37
36
  const handoffPath = paths.getVerifierHandoffPath(specId);
@@ -45,7 +44,7 @@ export const prepareVerifierLaunch = async ({
45
44
 
46
45
  if (currentState.phase !== WORKFLOW_PHASES.READY_FOR_VERIFIER) {
47
46
  throw new Error(
48
- `Verifier launch requires ready-for-verifier state, found "${currentState.phase}".`,
47
+ `Verifier run requires ready-for-verifier state, found "${currentState.phase}".`,
49
48
  );
50
49
  }
51
50
 
@@ -53,13 +52,13 @@ export const prepareVerifierLaunch = async ({
53
52
 
54
53
  if (!status.clean) {
55
54
  throw new Error(
56
- 'Verifier launch requires a committed ready-for-verifier candidate.',
55
+ 'Verifier run requires a committed ready-for-verifier candidate.',
57
56
  );
58
57
  }
59
58
 
60
59
  const nextState = transitionWorkflow({
61
60
  state: currentState,
62
- event: WORKFLOW_EVENTS.LAUNCH_VERIFIER,
61
+ event: WORKFLOW_EVENTS.RUN_VERIFIER,
63
62
  });
64
63
 
65
64
  const handoffExists = await pathExists(handoffPath);
@@ -80,28 +79,17 @@ export const prepareVerifierLaunch = async ({
80
79
  expectedPaths.push(handoffPath);
81
80
  }
82
81
 
83
- const previousHead = await getHeadCommit(repositoryRoot);
84
-
85
82
  const checkpointCommit = await createWorkflowCheckpointCommit({
86
83
  repositoryRoot,
87
84
  expectedPaths,
88
85
  });
89
86
 
90
- const candidateCommit = await getParentCommit({
91
- repositoryRoot,
92
- commit: checkpointCommit,
93
- });
94
-
95
- if (candidateCommit !== previousHead) {
96
- throw new Error(
97
- 'Verifier candidate changed while creating its checkpoint.',
98
- );
99
- }
87
+ maestroSessionState.setVerifierCheckpointCommit(checkpointCommit);
100
88
 
101
89
  return {
102
90
  specId,
103
91
  repositoryRoot,
104
- candidateCommit,
92
+ candidateCommit: checkpointCommit,
105
93
  checkpointCommit,
106
94
  revision: nextState.revision,
107
95
  };