@boxxy/model 0.1.2 → 0.1.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.
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
@@ -0,0 +1,3 @@
1
+ import { z } from 'zod';
2
+ import type { Limit } from '../planning/types.ts';
3
+ export declare const limitSchema: z.ZodType<Limit>;
@@ -0,0 +1,3 @@
1
+ import { z } from 'zod';
2
+ import type { LimitSeatRow } from '../types.ts';
3
+ export declare const limitSeatRowSchema: z.ZodType<LimitSeatRow>;
@@ -0,0 +1,3 @@
1
+ import { z } from 'zod';
2
+ import type { NoteRow } from '../types.ts';
3
+ export declare const noteRowSchema: z.ZodType<NoteRow>;
@@ -0,0 +1,3 @@
1
+ import { z } from 'zod';
2
+ import type { NoticeRow } from '../types.ts';
3
+ export declare const noticeRowSchema: z.ZodType<NoticeRow>;
@@ -0,0 +1,3 @@
1
+ import { z } from 'zod';
2
+ import type { PullRequestRow } from '../types.ts';
3
+ export declare const pullRequestRowSchema: z.ZodType<PullRequestRow>;
@@ -0,0 +1,3 @@
1
+ import { z } from 'zod';
2
+ import type { RelationRow } from '../types.ts';
3
+ export declare const relationRowSchema: z.ZodType<RelationRow>;
@@ -1,5 +1,5 @@
1
- import { z } from 'zod';
2
- import type { TableName, Tables } from './types/ports.ts';
1
+ import type { z } from 'zod';
2
+ import type { TableName, Tables } from '../ports/types.ts';
3
3
  export declare const rowSchemas: {
4
4
  readonly [T in TableName]: z.ZodType<Tables[T]>;
5
5
  };
@@ -0,0 +1,3 @@
1
+ import { z } from 'zod';
2
+ import type { RunnerRow } from '../types.ts';
3
+ export declare const runnerRowSchema: z.ZodType<RunnerRow>;
@@ -0,0 +1,3 @@
1
+ import { z } from 'zod';
2
+ import type { SpawnRequest } from '../ports/types.ts';
3
+ export declare const spawnRequestSchema: z.ZodType<SpawnRequest>;
@@ -0,0 +1,3 @@
1
+ import type { JsonValue } from '@boxxy/content-hash';
2
+ import type { PhaseKind } from './types.ts';
3
+ export declare function definePhase<Body, Input extends JsonValue, const Outcomes extends readonly string[]>(phase: PhaseKind<Body, Input, Outcomes>): PhaseKind;
@@ -0,0 +1,3 @@
1
+ import { z } from 'zod';
2
+ import type { LoadRejection } from './types.ts';
3
+ export declare const loadRejectionSchema: z.ZodType<LoadRejection>;
@@ -0,0 +1,244 @@
1
+ import type { JsonValue } from '@boxxy/content-hash';
2
+ import type { z } from 'zod';
3
+ import type { CloseOutParser, Effect } from '../closeouts/types.ts';
4
+ import type { RulesHoldReason } from '../pipeline/types.ts';
5
+ import type { Admission, FrameItem, Gate, Limit, Pool, PropagationLine, Signal, SignalKey, SignalName, View, Waiver } from '../planning/types.ts';
6
+ import type { AttemptRow, CommitSha, ConceptPin, EngineOutcome, Instant, ItemKindName, ItemView, LeverKind, Minutes, PhaseName, PipelineName, PullRequestRow, RecipeMaterial, RecipeName, RelationTypeName, RulesVersion, SessionMode, WorkerKindName } from '../types.ts';
7
+ export type Schema<T> = z.ZodType<T>;
8
+ export interface ParamKinds<P> {
9
+ signal: Signal<P>;
10
+ gate: Gate<P>;
11
+ admission: Admission<P>;
12
+ }
13
+ export type ParamKindName = keyof ParamKinds<unknown>;
14
+ export interface Registered<K extends ParamKindName> {
15
+ readonly kind: K;
16
+ readonly name: string;
17
+ open: <R>(use: <P>(plugin: ParamKinds<P>[K]) => R) => R;
18
+ }
19
+ export interface Resolved<K extends ParamKindName> {
20
+ readonly kind: K;
21
+ readonly name: string;
22
+ readonly key: string;
23
+ open: <R>(use: <P>(plugin: ParamKinds<P>[K], params: P) => R) => R;
24
+ }
25
+ export type ConceptName = string;
26
+ export interface Concept {
27
+ name: ConceptName;
28
+ version: number;
29
+ signals?: Registered<'signal'>[];
30
+ gates?: Registered<'gate'>[];
31
+ waivers?: Waiver[];
32
+ levers?: LeverKind[];
33
+ filterFields?: FilterField[];
34
+ }
35
+ export interface FilterField {
36
+ name: string;
37
+ value: (item: FrameItem) => string | readonly string[] | null;
38
+ }
39
+ export interface PlainKinds {
40
+ waiver: Waiver;
41
+ 'filter-field': FilterField;
42
+ lever: {
43
+ readonly kind: LeverKind;
44
+ };
45
+ view: View;
46
+ }
47
+ export type PluginKindName = ParamKindName | keyof PlainKinds;
48
+ export type Registry = {
49
+ readonly [K in ParamKindName]: ReadonlyMap<string, Registered<K>>;
50
+ } & {
51
+ readonly [K in keyof PlainKinds]: ReadonlyMap<string, PlainKinds[K]>;
52
+ } & {
53
+ readonly pins: readonly ConceptPin[];
54
+ };
55
+ export interface PhaseKind<Body = unknown, Input extends JsonValue = JsonValue, Outcomes extends readonly string[] = readonly string[]> {
56
+ readonly name: PhaseName;
57
+ readonly version: number;
58
+ readonly worker: WorkerKindName;
59
+ readonly outcomes: Outcomes;
60
+ readonly needsAcceptance: boolean;
61
+ readonly mode?: (item: ItemView) => SessionMode;
62
+ readonly input: (ctx: PhaseInputContext) => Input;
63
+ readonly closeOut: CloseOutParser<Body>;
64
+ readonly settle: BivariantSettle<Body, Outcomes[number]>['settle'];
65
+ }
66
+ interface BivariantSettle<Body, Outcome extends string> {
67
+ settle(input: SettleInput<Body>): Settlement<Outcome>;
68
+ }
69
+ export interface PhaseInputContext {
70
+ readonly item: ItemView;
71
+ readonly history: readonly AttemptRow[];
72
+ readonly pullRequests: readonly PullRequestRow[];
73
+ }
74
+ export interface SettleInput<Body> {
75
+ readonly attempt: AttemptRow;
76
+ readonly item: ItemView;
77
+ readonly closeOut: Body;
78
+ readonly now: Instant;
79
+ }
80
+ export interface Settlement<Outcome extends string = string> {
81
+ readonly state: 'succeeded' | 'failed';
82
+ readonly failure: string | null;
83
+ readonly outcome: Outcome;
84
+ readonly effects: readonly Effect[];
85
+ readonly frictionDropped: number;
86
+ }
87
+ export interface KindRules {
88
+ readonly pipeline: Pipeline;
89
+ readonly recipes: Readonly<Record<string, RecipeName>>;
90
+ }
91
+ export interface Pipeline {
92
+ readonly name: PipelineName;
93
+ readonly steps: readonly PipelineStep[];
94
+ }
95
+ export interface PipelineStep {
96
+ readonly phase: PhaseName;
97
+ readonly maxAttempts: number;
98
+ readonly timeoutMinutes: Minutes;
99
+ readonly on: Readonly<Record<string, Edge>>;
100
+ }
101
+ export type Edge = 'next' | 'again' | {
102
+ readonly to: PhaseName;
103
+ readonly max?: number;
104
+ readonly resume?: boolean;
105
+ } | {
106
+ readonly end: string;
107
+ } | {
108
+ readonly hold: RulesHoldReason;
109
+ };
110
+ export interface SkillsPin {
111
+ readonly source: string;
112
+ readonly ref: CommitSha;
113
+ }
114
+ export interface RelationType {
115
+ readonly name: RelationTypeName;
116
+ }
117
+ export interface SleepRules {
118
+ readonly afterIdleMinutes: Minutes;
119
+ readonly afterQuietMinutes: Minutes;
120
+ readonly afterUnattendedMinutes: Minutes;
121
+ }
122
+ export type ConceptEntry = `${string}@${number}`;
123
+ export type PluginRef = string | Readonly<Record<string, JsonValue>>;
124
+ export type SignalRef = SignalName | Readonly<Record<string, JsonValue>>;
125
+ export interface ItemRules {
126
+ readonly kinds: ReadonlyMap<ItemKindName, {
127
+ readonly pipeline: Pipeline;
128
+ }>;
129
+ readonly phases: ReadonlyMap<PhaseName, {
130
+ readonly needsAcceptance: boolean;
131
+ }>;
132
+ }
133
+ export interface LoadedRules {
134
+ readonly version: RulesVersion;
135
+ readonly commit: string;
136
+ readonly registry: Registry;
137
+ readonly signals: ReadonlyMap<SignalKey, Resolved<'signal'>>;
138
+ readonly gates: readonly Resolved<'gate'>[];
139
+ readonly kinds: ReadonlyMap<ItemKindName, KindRules>;
140
+ readonly phases: ReadonlyMap<PhaseName, PhaseKind>;
141
+ readonly limits: readonly Limit[];
142
+ readonly pools: readonly Pool[];
143
+ readonly propagation: readonly PropagationLine[];
144
+ readonly recipes: ReadonlyMap<RecipeName, RecipeMaterial>;
145
+ readonly sleep: SleepRules;
146
+ readonly skills: SkillsPin | null;
147
+ readonly relationTypes: ReadonlyMap<RelationTypeName, RelationType>;
148
+ }
149
+ export interface LoadRejection {
150
+ readonly file: string;
151
+ readonly path: string;
152
+ readonly reason: LoadRejectionReason;
153
+ }
154
+ export type LoadRejectionReason = {
155
+ readonly kind: 'invalid';
156
+ readonly message: string;
157
+ } | {
158
+ readonly kind: 'unknown-concept';
159
+ readonly ref: string;
160
+ } | {
161
+ readonly kind: 'unknown-signal';
162
+ readonly signal: string;
163
+ } | {
164
+ readonly kind: 'bad-plugin-params';
165
+ readonly pluginKind: ParamKindName;
166
+ readonly name: string;
167
+ readonly message: string;
168
+ } | {
169
+ readonly kind: 'unknown-relation-type';
170
+ readonly relation: string;
171
+ } | {
172
+ readonly kind: 'signal-without-combine';
173
+ readonly signal: string;
174
+ } | {
175
+ readonly kind: 'missing-recipe';
176
+ readonly itemKind: string;
177
+ readonly phase: string;
178
+ } | {
179
+ readonly kind: 'missing-prompt';
180
+ readonly path: string;
181
+ } | {
182
+ readonly kind: 'uncommitted-changes';
183
+ } | {
184
+ readonly kind: 'unknown-filter-field';
185
+ readonly field: string;
186
+ } | {
187
+ readonly kind: 'pool-without-limit';
188
+ readonly pool: string;
189
+ } | {
190
+ readonly kind: 'unknown-phase';
191
+ readonly phase: string;
192
+ } | {
193
+ readonly kind: 'unmapped-outcome';
194
+ readonly phase: PhaseName;
195
+ readonly outcome: string;
196
+ } | {
197
+ readonly kind: 'unknown-outcome';
198
+ readonly phase: PhaseName;
199
+ readonly outcome: string;
200
+ } | {
201
+ readonly kind: 'open-loop';
202
+ readonly phase: PhaseName;
203
+ readonly outcome: string;
204
+ } | {
205
+ readonly kind: 'edge-to-unknown-phase';
206
+ readonly phase: PhaseName;
207
+ readonly to: string;
208
+ } | {
209
+ readonly kind: 'step-without-recipe';
210
+ readonly itemKind: ItemKindName;
211
+ readonly phase: PhaseName;
212
+ } | {
213
+ readonly kind: 'step-without-timeout';
214
+ readonly phase: PhaseName;
215
+ } | {
216
+ readonly kind: 'quiet-below-idle';
217
+ } | {
218
+ readonly kind: 'unattended-below-quiet';
219
+ } | {
220
+ readonly kind: 'engine-outcome-listed';
221
+ readonly phase: PhaseName;
222
+ readonly outcome: EngineOutcome;
223
+ } | {
224
+ readonly kind: 'skills-without-pin';
225
+ readonly recipe: string;
226
+ } | {
227
+ readonly kind: 'resume-on-forward-edge';
228
+ readonly phase: PhaseName;
229
+ readonly outcome: string;
230
+ } | {
231
+ readonly kind: 'engine-hold-reason';
232
+ readonly phase: PhaseName;
233
+ readonly outcome: string;
234
+ readonly reason: string;
235
+ };
236
+ export type LoadResult = {
237
+ readonly kind: 'loaded';
238
+ readonly rules: LoadedRules;
239
+ readonly warnings: readonly string[];
240
+ } | {
241
+ readonly kind: 'rejected';
242
+ readonly rejections: readonly LoadRejection[];
243
+ };
244
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { CostToLand } from '../reports/types.ts';
2
+ export declare function buildMockCostToLand(overrides?: Partial<CostToLand>): CostToLand;
@@ -1,2 +1,2 @@
1
- import type { EvidenceRow } from '../types/core.ts';
1
+ import type { EvidenceRow } from '../types.ts';
2
2
  export declare function buildMockEvidenceRow(overrides?: Partial<EvidenceRow>): EvidenceRow;
@@ -1,2 +1,2 @@
1
- import type { FactId } from '../types/core.ts';
1
+ import type { FactId } from '../types.ts';
2
2
  export declare function buildMockFactId(): FactId;
@@ -1,2 +1,2 @@
1
- import type { FrameItem } from '../types/planning.ts';
1
+ import type { FrameItem } from '../planning/types.ts';
2
2
  export declare function buildMockFrameItem(overrides?: Partial<FrameItem>): FrameItem;
@@ -0,0 +1,2 @@
1
+ import type { Frame } from '../planning/types.ts';
2
+ export declare function buildMockFrame(overrides?: Partial<Frame>): Frame;
@@ -0,0 +1,2 @@
1
+ import type { ItemRules } from '../rules/types.ts';
2
+ export declare function buildMockItemRules(overrides?: Partial<ItemRules>): ItemRules;
@@ -1,2 +1,2 @@
1
- import type { LeaseRow } from '../types/core.ts';
1
+ import type { LeaseRow } from '../types.ts';
2
2
  export declare function buildMockLeaseRow(overrides?: Partial<LeaseRow>): LeaseRow;
@@ -0,0 +1,2 @@
1
+ import type { OutboxFact } from '../facts/types.ts';
2
+ export declare function buildMockOutboxFact(overrides?: Partial<OutboxFact>): OutboxFact;
@@ -0,0 +1,7 @@
1
+ import type { PhaseKind } from '../rules/types.ts';
2
+ interface MockPhaseKindInput {
3
+ readonly name: string;
4
+ readonly outcomes: readonly string[];
5
+ }
6
+ export declare function buildMockPhaseKind(input: MockPhaseKindInput): PhaseKind;
7
+ export {};
@@ -0,0 +1,7 @@
1
+ import type { Pipeline, PipelineStep } from '../rules/types.ts';
2
+ interface MockPipelineInput {
3
+ readonly phases?: readonly string[];
4
+ readonly steps?: Readonly<Record<string, Partial<PipelineStep>>>;
5
+ }
6
+ export declare function buildMockPipeline(input?: MockPipelineInput): Pipeline;
7
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { RelationRow } from '../types.ts';
2
+ export declare function buildMockRelationRow(overrides?: Partial<RelationRow>): RelationRow;
@@ -0,0 +1,9 @@
1
+ import type { Settled } from '../pipeline/types.ts';
2
+ interface MockSettledInput {
3
+ readonly phase: string;
4
+ readonly outcome: string;
5
+ readonly endedAt: number;
6
+ readonly failure?: string | null;
7
+ }
8
+ export declare function buildMockSettled(input: MockSettledInput): Settled;
9
+ export {};
@@ -1,2 +1,2 @@
1
- import type { Snapshot } from '../types/planning.ts';
1
+ import type { Snapshot } from '../planning/types.ts';
2
2
  export declare function buildMockSnapshot(overrides?: Partial<Snapshot>): Snapshot;
@@ -0,0 +1,2 @@
1
+ import type { AttemptRow } from '../types.ts';
2
+ export declare function buildMockV1AttemptRow(overrides?: Partial<AttemptRow>): AttemptRow;
@@ -0,0 +1,2 @@
1
+ import type { ItemRow } from '../types.ts';
2
+ export declare function buildMockV1ItemRow(overrides?: Partial<ItemRow>): ItemRow;
@@ -0,0 +1,2 @@
1
+ import type { ItemView } from '../types.ts';
2
+ export declare function buildMockV1ItemView(overrides?: Partial<ItemView>): ItemView;
@@ -0,0 +1,2 @@
1
+ import type { LeverRow } from '../types.ts';
2
+ export declare function buildMockV1LeverRow(overrides?: Partial<LeverRow>): LeverRow;
@@ -0,0 +1,2 @@
1
+ import type { PullRequestRow } from '../types.ts';
2
+ export declare function buildMockV1PullRequestRow(overrides?: Partial<PullRequestRow>): PullRequestRow;
@@ -0,0 +1,12 @@
1
+ import type { EntityRef, OutboxFact, WorkFacts } from '../facts/types.ts';
2
+ export type MockedFactType = 'boxxy.item.filed' | 'boxxy.item.edited' | 'boxxy.item.closed' | 'boxxy.attempt.claimed' | 'boxxy.attempt.started' | 'boxxy.attempt.reconciled' | 'boxxy.attempt.resumed' | 'boxxy.attempt.session_bound' | 'boxxy.attempt.slept' | 'boxxy.attempt.woken' | 'boxxy.attempt.closed_out' | 'boxxy.attempt.settled' | 'boxxy.pull_request.linked';
3
+ interface WorkFactOverrides<Type extends MockedFactType> {
4
+ readonly payload?: {
5
+ readonly [Key in keyof WorkFacts[Type]]?: unknown;
6
+ };
7
+ readonly at?: number;
8
+ readonly entity?: EntityRef;
9
+ readonly seq?: number;
10
+ }
11
+ export declare function buildMockWorkFact<Type extends MockedFactType>(type: Type, overrides?: WorkFactOverrides<Type>): OutboxFact;
12
+ export {};
@@ -0,0 +1,9 @@
1
+ import type { HoldNotice, Notifier } from '../ports/types.ts';
2
+ export interface FakeNotifier extends Notifier {
3
+ readonly told: readonly HoldNotice[];
4
+ readonly calls: () => number;
5
+ failNext: (reason: string) => void;
6
+ failAlways: (reason: string) => void;
7
+ recover: () => void;
8
+ }
9
+ export declare function createFakeNotifier(): FakeNotifier;
@@ -0,0 +1,13 @@
1
+ import type { PepysReader } from '../ports/types.ts';
2
+ import type { CostToLand, StageTime } from '../reports/types.ts';
3
+ import type { ItemId } from '../types.ts';
4
+ interface FakeValues {
5
+ readonly cost?: CostToLand;
6
+ readonly stageTime?: StageTime;
7
+ }
8
+ export interface FakePepysReader extends PepysReader {
9
+ set: (item: ItemId, values: FakeValues) => void;
10
+ failNext: (reason: string) => void;
11
+ }
12
+ export declare function createFakePepysReader(environment?: string): FakePepysReader;
13
+ export {};
@@ -0,0 +1,14 @@
1
+ import type { FactId, FactSink, OutboxFact } from '@boxxy/model';
2
+ export interface FactSinkHarness {
3
+ readonly sink: FactSink;
4
+ readStored: () => Promise<readonly FactId[]>;
5
+ corrupt: (fact: OutboxFact) => OutboxFact;
6
+ }
7
+ export type FactSinkCase = readonly [
8
+ title: string,
9
+ check: (harness: FactSinkHarness) => Promise<{
10
+ received: unknown;
11
+ expected: unknown;
12
+ }>
13
+ ];
14
+ export declare const factSinkContract: readonly FactSinkCase[];
@@ -0,0 +1,17 @@
1
+ import type { PepysReader } from '../ports/types.ts';
2
+ import type { CostToLand } from '../reports/types.ts';
3
+ import type { ItemId } from '../types.ts';
4
+ export interface PepysReaderHarness {
5
+ readonly reader: PepysReader;
6
+ readonly environment: string;
7
+ writeCost: (item: ItemId, cost: CostToLand) => Promise<void>;
8
+ takeDown: () => Promise<void>;
9
+ }
10
+ export type PepysReaderCase = readonly [
11
+ title: string,
12
+ check: (harness: PepysReaderHarness) => Promise<{
13
+ received: unknown;
14
+ expected: unknown;
15
+ }>
16
+ ];
17
+ export declare const pepysReaderContract: readonly PepysReaderCase[];