@boxxy/closeout 0.2.3 → 0.2.4

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boxxy/closeout",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "boxxy's phase kinds: the input, the close-out parser and the settle rule of triage, design, build and review",
5
5
  "homepage": "https://github.com/zgeoff/boxxy/tree/main/modules/closeout#readme",
6
6
  "bugs": "https://github.com/zgeoff/boxxy/issues",
@@ -30,14 +30,14 @@
30
30
  "typecheck": "tsrs --noEmit"
31
31
  },
32
32
  "dependencies": {
33
- "@boxxy/model": "0.2.3",
33
+ "@boxxy/model": "0.2.4",
34
34
  "tiny-invariant": "1.3.3",
35
35
  "ts-pattern": "5.9.2",
36
36
  "zod": "4.6.7"
37
37
  },
38
38
  "devDependencies": {
39
- "@boxxy/planning": "0.2.3",
40
- "@boxxy/rules": "0.2.3",
39
+ "@boxxy/planning": "0.2.4",
40
+ "@boxxy/rules": "0.2.4",
41
41
  "@faker-js/faker": "10.6.0"
42
42
  },
43
43
  "peerDependencies": {
@@ -1,4 +1,5 @@
1
1
  import type {
2
+ AttemptRow,
2
3
  BuildCloseOut,
3
4
  BuildInput,
4
5
  CloseOutContext,
@@ -15,6 +16,8 @@ import {
15
16
  definePhase,
16
17
  storedReviewCloseOutSchema,
17
18
  toJSONValue,
19
+ verifyCloseOutSchema,
20
+ verifyInputSchema,
18
21
  } from '@boxxy/model';
19
22
  import { match } from 'ts-pattern';
20
23
  import type { z } from 'zod';
@@ -64,21 +67,43 @@ function buildBuildInput(ctx: PhaseInputContext): BuildInput {
64
67
  return {
65
68
  acceptance: buildCriterionTexts(ctx.item),
66
69
  design: findLatestDesign(ctx.history),
67
- sentBack: findReviewSentBack(ctx),
70
+ sentBack: findSentBack(ctx.history),
68
71
  pullRequest: findPullRequestLink(ctx.pullRequests),
69
72
  };
70
73
  }
71
74
 
72
- // Only a latest review that asked for changes sends the build its findings: a build after a
73
- // passed review, sent back by the owner, gets none.
74
- function findReviewSentBack(ctx: PhaseInputContext): SentBack | null {
75
- const reading = findLatestCloseOut(ctx.history, 'review', storedReviewCloseOutSchema)?.reading;
75
+ // The latest grading of the work decides the send-back: a review that asked for changes sends
76
+ // its findings, and a failed verify sends its features. A build after a passed review or a
77
+ // verified verify, sent back by the owner, gets none.
78
+ function findSentBack(history: readonly AttemptRow[]): SentBack | null {
79
+ const graded = history.findLast(
80
+ (row) => (row.phase === 'review' || row.phase === 'verify') && row.state === 'succeeded',
81
+ );
82
+
83
+ if (graded?.phase === 'verify') {
84
+ return findVerifySentBack(graded);
85
+ }
86
+
87
+ const reading = findLatestCloseOut(history, 'review', storedReviewCloseOutSchema)?.reading;
76
88
 
77
89
  return reading?.status === 'blocked' && reading.why === 'open-findings'
78
90
  ? { from: 'review', head: reading.head, open: reading.open, answerHint: reading.answerHint }
79
91
  : null;
80
92
  }
81
93
 
94
+ function findVerifySentBack(verify: AttemptRow): SentBack | null {
95
+ const closeOut = verifyCloseOutSchema.safeParse(verify.closeOut);
96
+ const input = verifyInputSchema.safeParse(verify.input);
97
+
98
+ return closeOut.success && closeOut.data.result.kind === 'failed'
99
+ ? {
100
+ from: 'verify',
101
+ head: input.success ? input.data.head : null,
102
+ features: closeOut.data.result.features,
103
+ }
104
+ : null;
105
+ }
106
+
82
107
  function collectBuildProblems(closeOut: BuildCloseOut, ctx: CloseOutContext): CloseOutProblem[] {
83
108
  const acceptance = new Set(ctx.item.acceptance.map((criterion) => criterion.id));
84
109
  const own = new Set(ctx.evidence.map((row) => row.factId));