@boxxy/model 0.1.2 → 0.1.3

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 (234) hide show
  1. package/README.md +8 -6
  2. package/dist/closeouts/build-close-out-schema.d.ts +31 -0
  3. package/dist/closeouts/close-out-answer-schema.d.ts +3 -0
  4. package/dist/closeouts/close-out-schema.d.ts +3 -0
  5. package/dist/closeouts/design-close-out-schema.d.ts +30 -0
  6. package/dist/closeouts/friction-schema.d.ts +14 -0
  7. package/dist/closeouts/open-item-schema.d.ts +3 -0
  8. package/dist/closeouts/review-close-out-schema.d.ts +40 -0
  9. package/dist/closeouts/triage-close-out-schema.d.ts +40 -0
  10. package/dist/closeouts/types.d.ts +221 -0
  11. package/dist/dispatch/build-applied-change.d.ts +6 -0
  12. package/dist/dispatch/collect-seat-sync.d.ts +14 -0
  13. package/dist/dispatch/pick-seat-take.d.ts +10 -0
  14. package/dist/dispatch/types.d.ts +11 -0
  15. package/dist/{outbox-fact-schema.d.ts → facts/outbox-fact-schema.d.ts} +1 -1
  16. package/dist/facts/parse-new-fact.d.ts +2 -0
  17. package/dist/facts/types.d.ts +191 -0
  18. package/dist/facts/work-fact-schemas.d.ts +293 -0
  19. package/dist/index.d.ts +64 -23
  20. package/dist/items/build-item-views.d.ts +4 -0
  21. package/dist/items/collect-retries.d.ts +3 -0
  22. package/dist/items/collect-settled.d.ts +3 -0
  23. package/dist/items/derive-item-state.d.ts +17 -0
  24. package/dist/{live-levers.d.ts → items/live-levers.d.ts} +1 -1
  25. package/dist/items/types.d.ts +12 -0
  26. package/dist/pipeline/advance.d.ts +10 -0
  27. package/dist/pipeline/constants.d.ts +2 -0
  28. package/dist/pipeline/count-trailing.d.ts +1 -0
  29. package/dist/pipeline/find-position.d.ts +9 -0
  30. package/dist/pipeline/find-step.d.ts +3 -0
  31. package/dist/pipeline/merge-by-time.d.ts +9 -0
  32. package/dist/pipeline/position-schema.d.ts +3 -0
  33. package/dist/pipeline/types.d.ts +28 -0
  34. package/dist/planning/define-admission.d.ts +3 -0
  35. package/dist/planning/define-gate.d.ts +3 -0
  36. package/dist/planning/define-signal.d.ts +3 -0
  37. package/dist/planning/is-filter-match.d.ts +3 -0
  38. package/dist/planning/limit-fill-schema.d.ts +3 -0
  39. package/dist/{signal-key.d.ts → planning/signal-key.d.ts} +1 -1
  40. package/dist/planning/types.d.ts +155 -0
  41. package/dist/ports/types.d.ts +289 -0
  42. package/dist/reports/constants.d.ts +3 -0
  43. package/dist/reports/cost-to-land-schema.d.ts +29 -0
  44. package/dist/reports/outbox-status.d.ts +16 -0
  45. package/dist/reports/stage-time-schema.d.ts +25 -0
  46. package/dist/reports/types.d.ts +5 -0
  47. package/dist/rows/actor-ref-schema.d.ts +2 -0
  48. package/dist/rows/attempt-row-schema.d.ts +3 -0
  49. package/dist/rows/attempt-session-row-schema.d.ts +3 -0
  50. package/dist/{brand-schemas.d.ts → rows/brand-schemas.d.ts} +5 -2
  51. package/dist/rows/caller-identity-schema.d.ts +3 -0
  52. package/dist/rows/criterion-schema.d.ts +3 -0
  53. package/dist/rows/decision-row-schema.d.ts +34 -0
  54. package/dist/rows/evidence-row-schema.d.ts +3 -0
  55. package/dist/rows/item-row-schema.d.ts +28 -0
  56. package/dist/rows/item-view-schema.d.ts +3 -0
  57. package/dist/rows/lease-row-schema.d.ts +3 -0
  58. package/dist/rows/lever-row-schema.d.ts +12 -0
  59. package/dist/rows/limit-schema.d.ts +3 -0
  60. package/dist/rows/limit-seat-row-schema.d.ts +3 -0
  61. package/dist/rows/note-row-schema.d.ts +3 -0
  62. package/dist/rows/notice-row-schema.d.ts +3 -0
  63. package/dist/rows/pull-request-row-schema.d.ts +3 -0
  64. package/dist/rows/relation-row-schema.d.ts +3 -0
  65. package/dist/{row-schemas.d.ts → rows/row-schemas.d.ts} +2 -2
  66. package/dist/rows/runner-row-schema.d.ts +3 -0
  67. package/dist/rows/spawn-request-schema.d.ts +3 -0
  68. package/dist/rules/define-phase.d.ts +3 -0
  69. package/dist/rules/load-rejection-schema.d.ts +3 -0
  70. package/dist/rules/types.d.ts +244 -0
  71. package/dist/test-utils/build-mock-cost-to-land.d.ts +2 -0
  72. package/dist/test-utils/build-mock-evidence-row.d.ts +1 -1
  73. package/dist/test-utils/build-mock-fact-id.d.ts +1 -1
  74. package/dist/test-utils/build-mock-frame-item.d.ts +1 -1
  75. package/dist/test-utils/build-mock-frame.d.ts +2 -0
  76. package/dist/test-utils/build-mock-item-rules.d.ts +2 -0
  77. package/dist/test-utils/build-mock-lease-row.d.ts +1 -1
  78. package/dist/test-utils/build-mock-outbox-fact.d.ts +2 -0
  79. package/dist/test-utils/build-mock-phase-kind.d.ts +7 -0
  80. package/dist/test-utils/build-mock-pipeline.d.ts +7 -0
  81. package/dist/test-utils/build-mock-relation-row.d.ts +2 -0
  82. package/dist/test-utils/build-mock-settled.d.ts +9 -0
  83. package/dist/test-utils/build-mock-snapshot.d.ts +1 -1
  84. package/dist/test-utils/build-mock-v1-attempt-row.d.ts +2 -0
  85. package/dist/test-utils/build-mock-v1-item-row.d.ts +2 -0
  86. package/dist/test-utils/build-mock-v1-item-view.d.ts +2 -0
  87. package/dist/test-utils/build-mock-v1-lever-row.d.ts +2 -0
  88. package/dist/test-utils/build-mock-v1-pull-request-row.d.ts +2 -0
  89. package/dist/test-utils/build-mock-work-fact.d.ts +12 -0
  90. package/dist/test-utils/create-fake-notifier.d.ts +9 -0
  91. package/dist/test-utils/create-fake-pepys-reader.d.ts +13 -0
  92. package/dist/test-utils/fact-sink-contract.d.ts +14 -0
  93. package/dist/test-utils/pepys-reader-contract.d.ts +17 -0
  94. package/dist/{types/core.d.ts → types.d.ts} +93 -43
  95. package/package.json +13 -3
  96. package/src/{build-close-out-schema.ts → closeouts/build-close-out-schema.ts} +5 -10
  97. package/src/closeouts/close-out-answer-schema.ts +42 -0
  98. package/src/closeouts/close-out-schema.ts +13 -0
  99. package/src/closeouts/design-close-out-schema.ts +20 -0
  100. package/src/closeouts/friction-schema.ts +11 -0
  101. package/src/closeouts/open-item-schema.ts +8 -0
  102. package/src/closeouts/review-close-out-schema.ts +38 -0
  103. package/src/closeouts/triage-close-out-schema.ts +29 -0
  104. package/src/closeouts/types.ts +230 -0
  105. package/src/dispatch/build-applied-change.ts +57 -0
  106. package/src/dispatch/collect-seat-sync.ts +86 -0
  107. package/src/dispatch/pick-seat-take.ts +39 -0
  108. package/src/dispatch/types.ts +14 -0
  109. package/src/facts/outbox-fact-schema.ts +22 -0
  110. package/src/facts/parse-new-fact.ts +16 -0
  111. package/src/facts/types.ts +235 -0
  112. package/src/facts/work-fact-schemas.ts +201 -0
  113. package/src/index.ts +147 -55
  114. package/src/items/build-item-views.ts +146 -0
  115. package/src/items/collect-retries.ts +12 -0
  116. package/src/items/collect-settled.ts +20 -0
  117. package/src/items/derive-item-state.ts +95 -0
  118. package/src/{live-levers.ts → items/live-levers.ts} +1 -1
  119. package/src/items/types.ts +26 -0
  120. package/src/pipeline/advance.ts +78 -0
  121. package/src/pipeline/constants.ts +12 -0
  122. package/src/pipeline/count-trailing.ts +16 -0
  123. package/src/pipeline/find-position.ts +74 -0
  124. package/src/pipeline/find-step.ts +6 -0
  125. package/src/pipeline/merge-by-time.ts +33 -0
  126. package/src/pipeline/position-schema.ts +27 -0
  127. package/src/pipeline/types.ts +47 -0
  128. package/src/{define-admission.ts → planning/define-admission.ts} +2 -2
  129. package/src/{define-gate.ts → planning/define-gate.ts} +2 -2
  130. package/src/{define-signal.ts → planning/define-signal.ts} +2 -2
  131. package/src/planning/is-filter-match.ts +10 -0
  132. package/src/planning/limit-fill-schema.ts +12 -0
  133. package/src/{signal-key.ts → planning/signal-key.ts} +1 -1
  134. package/src/planning/types.ts +216 -0
  135. package/src/ports/types.ts +412 -0
  136. package/src/reports/constants.ts +6 -0
  137. package/src/reports/cost-to-land-schema.ts +47 -0
  138. package/src/reports/outbox-status.ts +22 -0
  139. package/src/reports/stage-time-schema.ts +21 -0
  140. package/src/reports/types.ts +7 -0
  141. package/src/rows/actor-ref-schema.ts +17 -0
  142. package/src/rows/attempt-row-schema.ts +69 -0
  143. package/src/rows/attempt-session-row-schema.ts +12 -0
  144. package/src/{brand-schemas.ts → rows/brand-schemas.ts} +5 -2
  145. package/src/rows/caller-identity-schema.ts +7 -0
  146. package/src/rows/criterion-schema.ts +9 -0
  147. package/src/rows/decision-row-schema.ts +34 -0
  148. package/src/rows/evidence-row-schema.ts +13 -0
  149. package/src/rows/item-row-schema.ts +32 -0
  150. package/src/rows/item-view-schema.ts +31 -0
  151. package/src/rows/lease-row-schema.ts +12 -0
  152. package/src/rows/lever-row-schema.ts +17 -0
  153. package/src/rows/limit-schema.ts +12 -0
  154. package/src/rows/limit-seat-row-schema.ts +12 -0
  155. package/src/rows/note-row-schema.ts +12 -0
  156. package/src/rows/notice-row-schema.ts +17 -0
  157. package/src/rows/pull-request-row-schema.ts +15 -0
  158. package/src/rows/relation-row-schema.ts +13 -0
  159. package/src/rows/row-schemas.ts +30 -0
  160. package/src/rows/runner-row-schema.ts +9 -0
  161. package/src/rows/spawn-request-schema.ts +15 -0
  162. package/src/rules/define-phase.ts +12 -0
  163. package/src/rules/load-rejection-schema.ts +51 -0
  164. package/src/rules/types.ts +291 -0
  165. package/src/test-utils/build-mock-cost-to-land.ts +31 -0
  166. package/src/test-utils/build-mock-evidence-row.ts +2 -2
  167. package/src/test-utils/build-mock-fact-id.ts +3 -3
  168. package/src/test-utils/build-mock-frame-item.ts +10 -5
  169. package/src/test-utils/build-mock-frame.ts +13 -0
  170. package/src/test-utils/build-mock-item-rules.ts +17 -0
  171. package/src/test-utils/build-mock-lease-row.ts +2 -2
  172. package/src/test-utils/build-mock-outbox-fact.ts +22 -0
  173. package/src/test-utils/build-mock-phase-kind.ts +29 -0
  174. package/src/test-utils/build-mock-pipeline.ts +52 -0
  175. package/src/test-utils/{build-mock-link-row.ts → build-mock-relation-row.ts} +4 -4
  176. package/src/test-utils/build-mock-settled.ts +18 -0
  177. package/src/test-utils/build-mock-snapshot.ts +10 -2
  178. package/src/test-utils/{build-mock-attempt-row.ts → build-mock-v1-attempt-row.ts} +28 -9
  179. package/src/test-utils/{build-mock-item-row.ts → build-mock-v1-item-row.ts} +7 -3
  180. package/src/test-utils/build-mock-v1-item-view.ts +29 -0
  181. package/src/test-utils/{build-mock-lever-row.ts → build-mock-v1-lever-row.ts} +5 -3
  182. package/src/test-utils/build-mock-v1-pull-request-row.ts +26 -0
  183. package/src/test-utils/build-mock-work-fact.ts +179 -0
  184. package/src/test-utils/create-fake-notifier.ts +54 -0
  185. package/src/test-utils/create-fake-pepys-reader.ts +73 -0
  186. package/src/test-utils/fact-sink-contract.ts +103 -0
  187. package/src/test-utils/pepys-reader-contract.ts +117 -0
  188. package/src/{types/core.ts → types.ts} +183 -59
  189. package/dist/actor-ref-schema.d.ts +0 -2
  190. package/dist/build-applied-change.d.ts +0 -13
  191. package/dist/build-close-out-schema.d.ts +0 -3
  192. package/dist/build-item-views.d.ts +0 -2
  193. package/dist/define-admission.d.ts +0 -3
  194. package/dist/define-gate.d.ts +0 -3
  195. package/dist/define-signal.d.ts +0 -3
  196. package/dist/derive-item-state.d.ts +0 -2
  197. package/dist/fact-schemas.d.ts +0 -5
  198. package/dist/find-slot-take.d.ts +0 -5
  199. package/dist/friction-schema.d.ts +0 -3
  200. package/dist/test-utils/build-mock-attempt-row.d.ts +0 -2
  201. package/dist/test-utils/build-mock-item-row.d.ts +0 -2
  202. package/dist/test-utils/build-mock-item-rows.d.ts +0 -2
  203. package/dist/test-utils/build-mock-item-view.d.ts +0 -2
  204. package/dist/test-utils/build-mock-lever-row.d.ts +0 -2
  205. package/dist/test-utils/build-mock-link-row.d.ts +0 -2
  206. package/dist/test-utils/build-mock-pull-request-row.d.ts +0 -2
  207. package/dist/types/dispatch.d.ts +0 -82
  208. package/dist/types/facts.d.ts +0 -154
  209. package/dist/types/planning.d.ts +0 -94
  210. package/dist/types/ports.d.ts +0 -218
  211. package/dist/types/registries.d.ts +0 -150
  212. package/src/actor-ref-schema.ts +0 -9
  213. package/src/build-applied-change.ts +0 -71
  214. package/src/build-item-views.ts +0 -128
  215. package/src/derive-item-state.ts +0 -76
  216. package/src/fact-schemas.ts +0 -132
  217. package/src/find-slot-take.ts +0 -12
  218. package/src/friction-schema.ts +0 -10
  219. package/src/outbox-fact-schema.ts +0 -25
  220. package/src/row-schemas.ts +0 -89
  221. package/src/test-utils/build-mock-item-rows.ts +0 -14
  222. package/src/test-utils/build-mock-item-view.ts +0 -8
  223. package/src/test-utils/build-mock-pull-request-row.ts +0 -16
  224. package/src/types/dispatch.ts +0 -95
  225. package/src/types/facts.ts +0 -166
  226. package/src/types/planning.ts +0 -136
  227. package/src/types/ports.ts +0 -262
  228. package/src/types/registries.ts +0 -185
  229. /package/dist/test-utils/{seed-faker.d.ts → pin-faker-seed.d.ts} +0 -0
  230. /package/dist/{format-key-path.d.ts → utils/format-key-path.d.ts} +0 -0
  231. /package/dist/{to-json-value.d.ts → utils/to-json-value.d.ts} +0 -0
  232. /package/src/test-utils/{seed-faker.ts → pin-faker-seed.ts} +0 -0
  233. /package/src/{format-key-path.ts → utils/format-key-path.ts} +0 -0
  234. /package/src/{to-json-value.ts → utils/to-json-value.ts} +0 -0
package/src/index.ts CHANGED
@@ -1,27 +1,57 @@
1
1
  export type { ContentHash, JsonValue } from '@boxxy/content-hash';
2
- export { brandSchemas } from './brand-schemas.ts';
3
-
4
- export {
5
- buildAppliedChange,
6
- type ChangeAssignments,
7
- type TakenSlot,
8
- } from './build-applied-change.ts';
9
-
10
- export { buildCloseOutSchema } from './build-close-out-schema.ts';
11
- export { buildItemViews } from './build-item-views.ts';
12
- export { defineAdmission } from './define-admission.ts';
13
- export { defineGate } from './define-gate.ts';
14
- export { defineSignal } from './define-signal.ts';
15
- export { deriveItemState } from './derive-item-state.ts';
16
- export { factSchemas } from './fact-schemas.ts';
17
- export { findSlotTake, type SlotTake } from './find-slot-take.ts';
18
- export { formatKeyPath } from './format-key-path.ts';
19
- export { frictionSchema } from './friction-schema.ts';
20
- export { liveLevers } from './live-levers.ts';
21
- export { outboxFactSchema } from './outbox-fact-schema.ts';
22
- export { rowSchemas } from './row-schemas.ts';
23
- export { signalKey } from './signal-key.ts';
24
- export { toJSONValue } from './to-json-value.ts';
2
+ export { brandSchemas } from './rows/brand-schemas.ts';
3
+ export { buildAppliedChange, type ChangeAssignments } from './dispatch/build-applied-change.ts';
4
+ export { advance } from './pipeline/advance.ts';
5
+ export { attemptRowSchema } from './rows/attempt-row-schema.ts';
6
+ export { attemptSessionRowSchema } from './rows/attempt-session-row-schema.ts';
7
+ export { buildCloseOutSchema } from './closeouts/build-close-out-schema.ts';
8
+ export { buildItemViews } from './items/build-item-views.ts';
9
+ export { collectRetries } from './items/collect-retries.ts';
10
+ export { collectSettled } from './items/collect-settled.ts';
11
+ export { closeOutAnswerSchema } from './closeouts/close-out-answer-schema.ts';
12
+ export { callerIdentitySchema } from './rows/caller-identity-schema.ts';
13
+ export { closeOutSchema } from './closeouts/close-out-schema.ts';
14
+ export { collectSeatSync, type SeatSync } from './dispatch/collect-seat-sync.ts';
15
+ export { costToLandSchema } from './reports/cost-to-land-schema.ts';
16
+ export { criterionSchema } from './rows/criterion-schema.ts';
17
+ export { decisionRowSchema } from './rows/decision-row-schema.ts';
18
+ export { defineAdmission } from './planning/define-admission.ts';
19
+ export { defineGate } from './planning/define-gate.ts';
20
+ export { definePhase } from './rules/define-phase.ts';
21
+ export { defineSignal } from './planning/define-signal.ts';
22
+ export { buildPhase, deriveItemState } from './items/derive-item-state.ts';
23
+ export { designCloseOutSchema } from './closeouts/design-close-out-schema.ts';
24
+ export { evidenceRowSchema } from './rows/evidence-row-schema.ts';
25
+ export { findPosition } from './pipeline/find-position.ts';
26
+ export { formatKeyPath } from './utils/format-key-path.ts';
27
+ export { frictionSchema } from './closeouts/friction-schema.ts';
28
+ export { isFilterMatch } from './planning/is-filter-match.ts';
29
+ export { itemRowSchema } from './rows/item-row-schema.ts';
30
+ export { itemViewSchema } from './rows/item-view-schema.ts';
31
+ export { leverRowSchema } from './rows/lever-row-schema.ts';
32
+ export { limitFillSchema } from './planning/limit-fill-schema.ts';
33
+ export { limitSchema } from './rows/limit-schema.ts';
34
+ export { limitSeatRowSchema } from './rows/limit-seat-row-schema.ts';
35
+ export { loadRejectionSchema } from './rules/load-rejection-schema.ts';
36
+ export { liveLevers } from './items/live-levers.ts';
37
+ export { noteRowSchema } from './rows/note-row-schema.ts';
38
+ export { noticeRowSchema } from './rows/notice-row-schema.ts';
39
+ export { outboxFactSchema } from './facts/outbox-fact-schema.ts';
40
+ export { positionSchema } from './pipeline/position-schema.ts';
41
+ export { parseNewFact } from './facts/parse-new-fact.ts';
42
+ export { pickSeatTake, type SeatTakeAnswer } from './dispatch/pick-seat-take.ts';
43
+ export { pullRequestRowSchema } from './rows/pull-request-row-schema.ts';
44
+ export { relationRowSchema } from './rows/relation-row-schema.ts';
45
+ export { reviewCloseOutSchema } from './closeouts/review-close-out-schema.ts';
46
+ export { rowSchemas } from './rows/row-schemas.ts';
47
+ export { signalKey } from './planning/signal-key.ts';
48
+ export { spawnRequestSchema } from './rows/spawn-request-schema.ts';
49
+ export { stageTimeSchema } from './reports/stage-time-schema.ts';
50
+ export { toJSONValue } from './utils/to-json-value.ts';
51
+ export { triageCloseOutSchema } from './closeouts/triage-close-out-schema.ts';
52
+ export { workFactSchemas } from './facts/work-fact-schemas.ts';
53
+ export { costBases, phaseSteps, stageSteps } from './reports/constants.ts';
54
+ export { engineHoldReasons, engineOutcomes } from './pipeline/constants.ts';
25
55
 
26
56
  export type {
27
57
  Actor,
@@ -32,6 +62,8 @@ export type {
32
62
  AttemptRow,
33
63
  AttemptSessionRow,
34
64
  AttemptState,
65
+ CallerIdentity,
66
+ ClosingCause,
35
67
  CommitSha,
36
68
  ConceptPin,
37
69
  Criterion,
@@ -39,82 +71,109 @@ export type {
39
71
  DecisionId,
40
72
  DecisionRow,
41
73
  DerivedState,
74
+ DesignMode,
42
75
  Effort,
76
+ EngineOutcome,
43
77
  EvidenceKind,
44
78
  EvidenceRow,
45
79
  EvidenceSource,
46
80
  FactId,
47
81
  FaultRecord,
82
+ FieldValues,
48
83
  ForcedFailure,
49
84
  Instant,
85
+ ItemFields,
50
86
  ItemId,
51
87
  ItemKindName,
52
88
  ItemRow,
53
- ItemRows,
54
- ItemSetRows,
55
89
  ItemState,
56
90
  ItemView,
57
- ItemWithLevers,
91
+ KeptSession,
58
92
  KnownFailure,
59
93
  LeaseRow,
60
94
  LeverKind,
61
95
  LeverRow,
62
- LinkRow,
63
- LinkTypeName,
96
+ LimitCount,
97
+ LimitName,
98
+ LimitSeatRow,
64
99
  LiveAttemptState,
65
- LoadedRecipe,
66
- MaxAttemptsByKind,
67
100
  Minutes,
101
+ NoteRow,
102
+ NoticeRow,
68
103
  ObservationBoundary,
104
+ OutcomeName,
69
105
  PhaseName,
70
106
  PipelineName,
71
107
  PoolName,
72
- PoolSlotRow,
108
+ Product,
73
109
  PullRequestRef,
74
110
  PullRequestRow,
75
111
  Recipe,
76
112
  RecipeHash,
77
113
  RecipeMaterial,
78
114
  RecipeName,
115
+ RelationRow,
116
+ RelationTypeName,
79
117
  RepoName,
80
118
  ResolvedRecipe,
81
119
  RulesVersion,
82
120
  RunnerId,
83
121
  RunnerRow,
122
+ SessionMode,
84
123
  SnapshotHash,
85
124
  SourceName,
86
125
  StreamName,
87
126
  WaitingReason,
88
127
  WorkerKindName,
89
- } from './types/core.ts';
128
+ } from './types.ts';
90
129
 
91
130
  export type {
92
- Claim,
131
+ HoldReason,
132
+ Position,
133
+ RetryLever,
134
+ RulesHoldReason,
135
+ Settled,
136
+ } from './pipeline/types.ts';
137
+
138
+ export type {
139
+ AcceptanceInput,
140
+ BuildCloseOut,
141
+ BuildInput,
142
+ CloseOut,
143
+ CloseOutAnswer,
93
144
  CloseOutContext,
94
145
  CloseOutParse,
95
146
  CloseOutParser,
96
147
  CloseOutProblem,
97
- ReconcileAction,
98
- ReconcileTable,
99
- SettleInput,
100
- Settlement,
101
- SettleRule,
102
- SpawnContext,
103
- } from './types/dispatch.ts';
148
+ CloseOutWorld,
149
+ CriterionText,
150
+ DesignCloseOut,
151
+ DesignRef,
152
+ Effect,
153
+ Finding,
154
+ Friction,
155
+ FrictionTargetKind,
156
+ NoslopSummary,
157
+ OpenItem,
158
+ PullRequestLink,
159
+ RelationDraft,
160
+ ReviewCloseOut,
161
+ ReviewInput,
162
+ TriageCloseOut,
163
+ } from './closeouts/types.ts';
164
+
165
+ export type { Claim } from './dispatch/types.ts';
104
166
 
105
167
  export type {
106
- BuildCloseOut,
168
+ AnyNewFact,
107
169
  EntityRef,
108
170
  FactEnvelope,
109
171
  FactType,
110
- Friction,
111
- FrictionTargetKind,
112
- LinkPayload,
113
172
  NewFact,
114
- OpenItem,
115
173
  OutboxFact,
116
- SliceOneFacts,
117
- } from './types/facts.ts';
174
+ RelationPayload,
175
+ WorkFacts,
176
+ } from './facts/types.ts';
118
177
 
119
178
  export type {
120
179
  Admission,
@@ -122,6 +181,7 @@ export type {
122
181
  AdmissionName,
123
182
  Decision,
124
183
  Fault,
184
+ Filter,
125
185
  Frame,
126
186
  FrameItem,
127
187
  FrameValues,
@@ -129,52 +189,78 @@ export type {
129
189
  GateName,
130
190
  Hold,
131
191
  Lift,
192
+ Limit,
193
+ LimitFill,
132
194
  Pick,
133
195
  PlanContext,
134
196
  Pool,
135
197
  PropagationLine,
198
+ SeatRef,
199
+ SeatRelease,
200
+ SeatTake,
136
201
  Signal,
137
202
  SignalKey,
138
203
  SignalName,
139
204
  Snapshot,
205
+ StartPick,
140
206
  View,
141
207
  ViewName,
208
+ Wait,
209
+ WaitReason,
142
210
  Waiver,
143
211
  WaiverName,
144
- } from './types/planning.ts';
212
+ Wake,
213
+ WakePick,
214
+ } from './planning/types.ts';
145
215
 
146
216
  export type {
147
- AnyNewFact,
148
217
  ApplyResult,
218
+ Attention,
219
+ CallerProof,
220
+ CapacityBackoff,
149
221
  ClaimStore,
150
222
  Clock,
151
- CostReader,
152
- CostToLandInput,
153
- CostToLandRow,
154
223
  FactSink,
224
+ ForgetOutcome,
155
225
  Forge,
226
+ HoldNotice,
156
227
  ItemDetailRows,
157
228
  ItemFilter,
158
229
  NewId,
230
+ NoticeOutcome,
231
+ Notifier,
232
+ OutboxReader,
233
+ PepysAnswer,
234
+ PepysReader,
235
+ SinkAnswer,
159
236
  PullRequestReading,
160
237
  RowWrite,
161
238
  SessionFault,
162
239
  SessionReading,
163
240
  SpawnRequest,
164
241
  StartOutcome,
242
+ StopOutcome,
165
243
  StoreChange,
166
244
  StoreReader,
167
245
  StoreTx,
246
+ SuspendOutcome,
168
247
  TableName,
169
248
  Tables,
249
+ WakeSource,
170
250
  WorkerKind,
171
- } from './types/ports.ts';
251
+ } from './ports/types.ts';
252
+
253
+ export type { CostToLand, StageTime } from './reports/types.ts';
254
+ export type { OutboxStatus } from './reports/outbox-status.ts';
255
+ export type { ItemSetRows, ItemWithLevers } from './items/types.ts';
172
256
 
173
257
  export type {
174
258
  Concept,
175
259
  ConceptEntry,
176
260
  ConceptName,
261
+ Edge,
177
262
  FilterField,
263
+ ItemRules,
178
264
  KindRules,
179
265
  LoadedRules,
180
266
  LoadRejection,
@@ -182,6 +268,8 @@ export type {
182
268
  LoadResult,
183
269
  ParamKindName,
184
270
  ParamKinds,
271
+ PhaseInputContext,
272
+ PhaseKind,
185
273
  Pipeline,
186
274
  PipelineStep,
187
275
  PlainKinds,
@@ -189,8 +277,12 @@ export type {
189
277
  PluginRef,
190
278
  Registered,
191
279
  Registry,
280
+ RelationType,
192
281
  Resolved,
193
- RulesFile,
194
282
  Schema,
283
+ SettleInput,
284
+ Settlement,
195
285
  SignalRef,
196
- } from './types/registries.ts';
286
+ SkillsPin,
287
+ SleepRules,
288
+ } from './rules/types.ts';
@@ -0,0 +1,146 @@
1
+ import { findPosition } from '../pipeline/find-position.ts';
2
+ import type { Position } from '../pipeline/types.ts';
3
+ import type { ItemRules } from '../rules/types.ts';
4
+ import type {
5
+ AttemptId,
6
+ AttemptRow,
7
+ DerivedState,
8
+ Instant,
9
+ ItemId,
10
+ ItemRow,
11
+ ItemState,
12
+ LeaseRow,
13
+ LeverRow,
14
+ PullRequestRow,
15
+ RelationRow,
16
+ } from '../types.ts';
17
+ import { collectRetries } from './collect-retries.ts';
18
+ import { collectSettled } from './collect-settled.ts';
19
+ import { deriveItemState } from './derive-item-state.ts';
20
+ import { liveLevers } from './live-levers.ts';
21
+ import type { ItemSetRows, ItemWithLevers } from './types.ts';
22
+
23
+ export function buildItemViews(
24
+ rows: ItemSetRows,
25
+ now: Instant,
26
+ rules: ItemRules,
27
+ ): ItemWithLevers[] {
28
+ const groups = collectItemGroups(rows, rules);
29
+
30
+ // A blocking source counts only when it is done or archived, and no relation makes an item either,
31
+ // so each source's state derived without its relations settles its targets.
32
+ const ownStates = new Map<ItemId, ItemState>(
33
+ groups.map((group) => [
34
+ group.item.id,
35
+ deriveGroupState(group, rules, { relations: [], blockerStates: new Map() }).state,
36
+ ]),
37
+ );
38
+
39
+ return groups.map((group) =>
40
+ buildItemWithLevers(
41
+ group,
42
+ deriveGroupState(group, rules, { relations: group.relations, blockerStates: ownStates }),
43
+ now,
44
+ ),
45
+ );
46
+ }
47
+
48
+ interface ItemGroup {
49
+ readonly item: ItemRow;
50
+ readonly relations: RelationRow[];
51
+ readonly attempts: AttemptRow[];
52
+ readonly pullRequests: PullRequestRow[];
53
+ readonly levers: LeverRow[];
54
+ liveLease: LeaseRow | null;
55
+ position: Position;
56
+ }
57
+
58
+ // in the order of `rows.items`
59
+ function collectItemGroups(rows: ItemSetRows, rules: ItemRules): ItemGroup[] {
60
+ const groups = new Map<ItemId, ItemGroup>(
61
+ rows.items.map((item) => [
62
+ item.id,
63
+ {
64
+ item,
65
+ relations: [],
66
+ attempts: [],
67
+ pullRequests: [],
68
+ levers: [],
69
+ liveLease: null,
70
+ position: { kind: 'end', reason: 'no-pipeline' },
71
+ },
72
+ ]),
73
+ );
74
+
75
+ const attemptItems = new Map<AttemptId, ItemId>();
76
+
77
+ for (const relation of rows.relations) {
78
+ groups.get(relation.target)?.relations.push(relation);
79
+ }
80
+
81
+ for (const attempt of rows.attempts) {
82
+ attemptItems.set(attempt.id, attempt.item);
83
+ groups.get(attempt.item)?.attempts.push(attempt);
84
+ }
85
+
86
+ for (const pullRequest of rows.pullRequests) {
87
+ const item = attemptItems.get(pullRequest.attempt);
88
+
89
+ if (item !== undefined) {
90
+ groups.get(item)?.pullRequests.push(pullRequest);
91
+ }
92
+ }
93
+
94
+ for (const lever of rows.levers) {
95
+ groups.get(lever.item)?.levers.push(lever);
96
+ }
97
+
98
+ for (const lease of rows.liveLeases) {
99
+ const group = groups.get(lease.item);
100
+
101
+ if (group !== undefined) {
102
+ group.liveLease = lease;
103
+ }
104
+ }
105
+
106
+ for (const group of groups.values()) {
107
+ group.position = findPosition({
108
+ pipeline: rules.kinds.get(group.item.kind)?.pipeline ?? null,
109
+ attempts: collectSettled(group.attempts),
110
+ retries: collectRetries(group.levers),
111
+ });
112
+ }
113
+
114
+ return [...groups.values()];
115
+ }
116
+
117
+ interface Blocking {
118
+ // the live relations whose target is the item
119
+ readonly relations: readonly RelationRow[];
120
+ readonly blockerStates: ReadonlyMap<ItemId, ItemState>;
121
+ }
122
+
123
+ function deriveGroupState(group: ItemGroup, rules: ItemRules, blocking: Blocking): DerivedState {
124
+ return deriveItemState({
125
+ ...blocking,
126
+ item: group.item,
127
+ position: group.position,
128
+ liveLease: group.liveLease,
129
+ phases: rules.phases,
130
+ attempts: group.attempts,
131
+ pullRequests: group.pullRequests,
132
+ });
133
+ }
134
+
135
+ function buildItemWithLevers(
136
+ group: ItemGroup,
137
+ derived: DerivedState,
138
+ now: Instant,
139
+ ): ItemWithLevers {
140
+ return {
141
+ ...group.item,
142
+ derived,
143
+ position: group.position,
144
+ levers: liveLevers(group.levers, now),
145
+ };
146
+ }
@@ -0,0 +1,12 @@
1
+ import type { RetryLever } from '../pipeline/types.ts';
2
+ import type { LeverRow } from '../types.ts';
3
+
4
+ const retryKind = 'item.retry';
5
+
6
+ // every `item.retry` lever the item ever had, so the position never depends on the read's time
7
+ export function collectRetries(levers: readonly LeverRow[]): RetryLever[] {
8
+ return levers
9
+ .filter((lever) => lever.kind === retryKind)
10
+ .map((lever) => ({ at: lever.at, phase: lever.phase }))
11
+ .toSorted((first, second) => first.at - second.at);
12
+ }
@@ -0,0 +1,20 @@
1
+ import type { Settled } from '../pipeline/types.ts';
2
+ import type { AttemptRow } from '../types.ts';
3
+
4
+ // the settled attempts, oldest end first
5
+ export function collectSettled(attempts: readonly AttemptRow[]): Settled[] {
6
+ const settled = attempts.flatMap((attempt) =>
7
+ attempt.endedAt === null || attempt.outcome === null
8
+ ? []
9
+ : [
10
+ {
11
+ phase: attempt.phase,
12
+ outcome: attempt.outcome,
13
+ endedAt: attempt.endedAt,
14
+ failure: attempt.failure,
15
+ },
16
+ ],
17
+ );
18
+
19
+ return settled.toSorted((first, second) => first.endedAt - second.endedAt);
20
+ }
@@ -0,0 +1,95 @@
1
+ import type { Position } from '../pipeline/types.ts';
2
+ import type {
3
+ AttemptRow,
4
+ DerivedState,
5
+ ItemId,
6
+ ItemRow,
7
+ ItemState,
8
+ LeaseRow,
9
+ PhaseName,
10
+ PullRequestRow,
11
+ RelationRow,
12
+ } from '../types.ts';
13
+
14
+ interface DeriveItemStateInput {
15
+ readonly item: ItemRow;
16
+ readonly position: Position;
17
+
18
+ // the item's live item-phase lease, a sleeping or closing attempt's included
19
+ readonly liveLease: LeaseRow | null;
20
+
21
+ // the phase kinds loaded now, by name
22
+ readonly phases: ReadonlyMap<PhaseName, { readonly needsAcceptance: boolean }>;
23
+ readonly attempts: readonly AttemptRow[];
24
+ readonly pullRequests: readonly PullRequestRow[];
25
+
26
+ // the live relations whose target is the item
27
+ readonly relations: readonly RelationRow[];
28
+ readonly blockerStates: ReadonlyMap<ItemId, ItemState>;
29
+ }
30
+
31
+ // The table of section G of the engine sketch; the first match wins.
32
+ export function deriveItemState(input: DeriveItemStateInput): DerivedState {
33
+ const item = input.item;
34
+ const position = input.position;
35
+
36
+ if (item.closedAt !== null) {
37
+ return { state: 'archived' };
38
+ }
39
+
40
+ if (input.liveLease !== null) {
41
+ return { state: 'running' };
42
+ }
43
+
44
+ if (position.kind === 'hold') {
45
+ return { state: 'waiting', reason: position.reason };
46
+ }
47
+
48
+ if (position.kind === 'end') {
49
+ return deriveEndedState(collectBuildPullRequests(input.attempts, input.pullRequests));
50
+ }
51
+
52
+ if (item.acceptance.length === 0 && input.phases.get(position.phase)?.needsAcceptance === true) {
53
+ return { state: 'idea' };
54
+ }
55
+
56
+ return hasOpenBlocker(input) ? { state: 'blocked' } : { state: 'ready' };
57
+ }
58
+
59
+ function deriveEndedState(linked: readonly PullRequestRow[]): DerivedState {
60
+ if (linked.some((pullRequest) => pullRequest.state === 'merged')) {
61
+ return { state: 'done' };
62
+ }
63
+
64
+ if (linked.some((pullRequest) => pullRequest.state === 'open')) {
65
+ return { state: 'waiting', reason: 'pull request open' };
66
+ }
67
+
68
+ return linked.length === 0
69
+ ? { state: 'waiting', reason: 'no pull request linked' }
70
+ : { state: 'waiting', reason: 'pull request closed unmerged' };
71
+ }
72
+
73
+ export const buildPhase = 'build';
74
+
75
+ // the pull requests linked to a succeeded build attempt
76
+ function collectBuildPullRequests(
77
+ attempts: readonly AttemptRow[],
78
+ pullRequests: readonly PullRequestRow[],
79
+ ): PullRequestRow[] {
80
+ const succeededBuilds = new Set(
81
+ attempts
82
+ .filter((attempt) => attempt.phase === buildPhase && attempt.state === 'succeeded')
83
+ .map((attempt) => attempt.id),
84
+ );
85
+
86
+ return pullRequests.filter((pullRequest) => succeededBuilds.has(pullRequest.attempt));
87
+ }
88
+
89
+ function hasOpenBlocker(input: DeriveItemStateInput): boolean {
90
+ return input.relations.some((relation) => {
91
+ const blockerState = input.blockerStates.get(relation.source);
92
+
93
+ return relation.type === 'blocks' && blockerState !== 'done' && blockerState !== 'archived';
94
+ });
95
+ }
@@ -1,4 +1,4 @@
1
- import type { Instant, LeverKind, LeverRow } from './types/core.ts';
1
+ import type { Instant, LeverKind, LeverRow } from '../types.ts';
2
2
 
3
3
  export function liveLevers(levers: readonly LeverRow[], now: Instant): LeverRow[] {
4
4
  return levers.filter((lever) => !isExpired(lever, now) && !isUndone(lever, levers));
@@ -0,0 +1,26 @@
1
+ import type {
2
+ AttemptRow,
3
+ ItemRow,
4
+ ItemView,
5
+ LeaseRow,
6
+ LeverRow,
7
+ PullRequestRow,
8
+ RelationRow,
9
+ } from '../types.ts';
10
+
11
+ // the rows a store reads to derive a set of items, with each blocking source item
12
+ export interface ItemSetRows {
13
+ readonly items: readonly ItemRow[];
14
+
15
+ // live relations only
16
+ readonly relations: readonly RelationRow[];
17
+ readonly levers: readonly LeverRow[];
18
+ readonly attempts: readonly AttemptRow[];
19
+ readonly liveLeases: readonly LeaseRow[];
20
+ readonly pullRequests: readonly PullRequestRow[];
21
+ }
22
+
23
+ export interface ItemWithLevers extends ItemView {
24
+ // the live levers only
25
+ readonly levers: readonly LeverRow[];
26
+ }