@boxxy/model 0.1.0 → 0.1.1
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/README.md +27 -2
- package/dist/brand-schemas.d.ts +26 -0
- package/dist/build-close-out-schema.d.ts +3 -0
- package/dist/define-admission.d.ts +3 -0
- package/dist/define-gate.d.ts +3 -0
- package/dist/define-signal.d.ts +3 -0
- package/dist/derive-item-state.d.ts +2 -0
- package/dist/fact-schemas.d.ts +5 -0
- package/dist/friction-schema.d.ts +3 -0
- package/dist/index.d.ts +17 -1
- package/dist/live-levers.d.ts +2 -0
- package/dist/signal-key.d.ts +3 -0
- package/dist/test-utils/build-mock-attempt-row.d.ts +2 -0
- package/dist/test-utils/build-mock-item-row.d.ts +2 -0
- package/dist/test-utils/build-mock-item-rows.d.ts +2 -0
- package/dist/test-utils/build-mock-lease-row.d.ts +2 -0
- package/dist/test-utils/build-mock-lever-row.d.ts +2 -0
- package/dist/test-utils/build-mock-link-row.d.ts +2 -0
- package/dist/test-utils/build-mock-pull-request-row.d.ts +2 -0
- package/dist/test-utils/seed-faker.d.ts +1 -0
- package/dist/types/core.d.ts +225 -0
- package/dist/types/dispatch.d.ts +82 -0
- package/dist/types/facts.d.ts +154 -0
- package/dist/types/planning.d.ts +94 -0
- package/dist/types/ports.d.ts +218 -0
- package/dist/types/registries.d.ts +150 -0
- package/package.json +8 -2
- package/src/brand-schemas.ts +46 -0
- package/src/build-close-out-schema.ts +28 -0
- package/src/define-admission.ts +6 -0
- package/src/define-gate.ts +6 -0
- package/src/define-signal.ts +6 -0
- package/src/derive-item-state.ts +76 -0
- package/src/fact-schemas.ts +138 -0
- package/src/friction-schema.ts +10 -0
- package/src/index.ts +182 -1
- package/src/live-levers.ts +22 -0
- package/src/signal-key.ts +7 -0
- package/src/test-utils/build-mock-attempt-row.ts +37 -0
- package/src/test-utils/build-mock-item-row.ts +22 -0
- package/src/test-utils/build-mock-item-rows.ts +14 -0
- package/src/test-utils/build-mock-lease-row.ts +15 -0
- package/src/test-utils/build-mock-lever-row.ts +17 -0
- package/src/test-utils/build-mock-link-row.ts +15 -0
- package/src/test-utils/build-mock-pull-request-row.ts +16 -0
- package/src/test-utils/seed-faker.ts +3 -0
- package/src/types/core.ts +287 -0
- package/src/types/dispatch.ts +95 -0
- package/src/types/facts.ts +166 -0
- package/src/types/planning.ts +136 -0
- package/src/types/ports.ts +262 -0
- package/src/types/registries.ts +185 -0
- package/dist/package-name.d.ts +0 -1
- package/src/package-name.ts +0 -1
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { brandSchemas } from './brand-schemas.ts';
|
|
3
|
+
import { buildCloseOutSchema } from './build-close-out-schema.ts';
|
|
4
|
+
import { frictionSchema } from './friction-schema.ts';
|
|
5
|
+
import type { FactType, SliceOneFacts } from './types/facts.ts';
|
|
6
|
+
|
|
7
|
+
const actorRefSchema = z.union([
|
|
8
|
+
z.literal('boxxy:owner:local'),
|
|
9
|
+
z.templateLiteral(['boxxy:runner:', brandSchemas.runnerId]),
|
|
10
|
+
z.templateLiteral(['boxxy:attempt:', brandSchemas.attemptId]),
|
|
11
|
+
z.templateLiteral(['boxxy:hook:', brandSchemas.attemptId]),
|
|
12
|
+
]);
|
|
13
|
+
|
|
14
|
+
const criterionSchema = z.object({
|
|
15
|
+
id: brandSchemas.criterionId,
|
|
16
|
+
text: z.string().min(1),
|
|
17
|
+
evidence: z.array(brandSchemas.factId),
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const linkPayloadSchema = z.object({
|
|
21
|
+
source: brandSchemas.itemId,
|
|
22
|
+
target: brandSchemas.itemId,
|
|
23
|
+
type: brandSchemas.linkTypeName,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const faultSchema = z.object({
|
|
27
|
+
plugin: z.string().min(1),
|
|
28
|
+
kind: z.enum(['signal', 'gate', 'waiver', 'admission', 'propagation']),
|
|
29
|
+
item: brandSchemas.itemId.nullable(),
|
|
30
|
+
error: z.string(),
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const copiedEvidenceSchema = z.object({
|
|
34
|
+
criterion: brandSchemas.criterionId,
|
|
35
|
+
evidence: z.array(brandSchemas.factId),
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const pullRequestNumberSchema = z.number().int().positive();
|
|
39
|
+
|
|
40
|
+
export const factSchemas: { readonly [T in FactType]: z.ZodType<SliceOneFacts[T]> } = {
|
|
41
|
+
'boxxy.item.filed': z.object({
|
|
42
|
+
id: brandSchemas.itemId,
|
|
43
|
+
kind: brandSchemas.itemKindName,
|
|
44
|
+
repo: brandSchemas.repoName,
|
|
45
|
+
title: z.string().min(1),
|
|
46
|
+
outcome: z.string().min(1),
|
|
47
|
+
acceptance: z.array(criterionSchema),
|
|
48
|
+
foundInAttempt: brandSchemas.attemptId.nullable(),
|
|
49
|
+
filedBy: actorRefSchema,
|
|
50
|
+
filedAt: brandSchemas.instant,
|
|
51
|
+
closedAt: brandSchemas.instant.nullable(),
|
|
52
|
+
closeReason: z.string().nullable(),
|
|
53
|
+
}),
|
|
54
|
+
'boxxy.item.edited': z
|
|
55
|
+
.object({
|
|
56
|
+
title: z.string().min(1).exactOptional(),
|
|
57
|
+
outcome: z.string().min(1).exactOptional(),
|
|
58
|
+
acceptance: z.array(criterionSchema).exactOptional(),
|
|
59
|
+
})
|
|
60
|
+
.refine((fields) => Object.keys(fields).length > 0, 'an edit changes at least one field'),
|
|
61
|
+
'boxxy.item.closed': z.object({ reason: z.string().min(1) }),
|
|
62
|
+
'boxxy.link.added': linkPayloadSchema,
|
|
63
|
+
'boxxy.link.removed': linkPayloadSchema,
|
|
64
|
+
'boxxy.lever.recorded': z.object({
|
|
65
|
+
seq: z.number().int().nonnegative(),
|
|
66
|
+
kind: z.templateLiteral([z.string().min(1), '.', z.string().min(1)]),
|
|
67
|
+
item: brandSchemas.itemId,
|
|
68
|
+
until: brandSchemas.instant.nullable(),
|
|
69
|
+
expiresAt: brandSchemas.instant.nullable(),
|
|
70
|
+
reason: z.string().nullable(),
|
|
71
|
+
actor: actorRefSchema,
|
|
72
|
+
at: brandSchemas.instant,
|
|
73
|
+
}),
|
|
74
|
+
'boxxy.attempt.claimed': z.object({
|
|
75
|
+
item: brandSchemas.itemId,
|
|
76
|
+
phase: brandSchemas.phaseName,
|
|
77
|
+
number: z.number().int().positive(),
|
|
78
|
+
pool: brandSchemas.poolName,
|
|
79
|
+
slot: z.number().int().nonnegative(),
|
|
80
|
+
gen: z.number().int().nonnegative(),
|
|
81
|
+
recipeHash: brandSchemas.recipeHash,
|
|
82
|
+
rulesVersion: brandSchemas.rulesVersion,
|
|
83
|
+
}),
|
|
84
|
+
'boxxy.decision.recorded': z.object({
|
|
85
|
+
id: brandSchemas.decisionId,
|
|
86
|
+
attempt: brandSchemas.attemptId,
|
|
87
|
+
item: brandSchemas.itemId,
|
|
88
|
+
pool: brandSchemas.poolName,
|
|
89
|
+
rulesVersion: brandSchemas.rulesVersion,
|
|
90
|
+
snapshotHash: brandSchemas.snapshotHash,
|
|
91
|
+
storeVersion: z.number().int().nonnegative(),
|
|
92
|
+
pepysOffsets: z.record(brandSchemas.streamName, z.number().int().nonnegative()),
|
|
93
|
+
faults: z.array(faultSchema),
|
|
94
|
+
at: brandSchemas.instant,
|
|
95
|
+
}),
|
|
96
|
+
'boxxy.attempt.started': z.object({ atcSession: brandSchemas.atcSessionId }),
|
|
97
|
+
'boxxy.attempt.reconciling': z.object({ reason: z.string().min(1) }),
|
|
98
|
+
'boxxy.attempt.reconciled': z.object({ atcSession: brandSchemas.atcSessionId }),
|
|
99
|
+
'boxxy.attempt.session_bound': z.object({
|
|
100
|
+
atcSession: brandSchemas.atcSessionId,
|
|
101
|
+
agentSession: brandSchemas.agentSessionId,
|
|
102
|
+
seenAt: brandSchemas.instant,
|
|
103
|
+
}),
|
|
104
|
+
'boxxy.attempt.closed_out': z.object({ closeOut: buildCloseOutSchema }),
|
|
105
|
+
'boxxy.attempt.settled': z.object({
|
|
106
|
+
state: z.enum(['succeeded', 'failed']),
|
|
107
|
+
failure: z.string().min(1).nullable(),
|
|
108
|
+
endedAt: brandSchemas.instant,
|
|
109
|
+
criteria: z.array(copiedEvidenceSchema),
|
|
110
|
+
matched: z.array(brandSchemas.itemId),
|
|
111
|
+
frictionDropped: z.number().int().nonnegative(),
|
|
112
|
+
}),
|
|
113
|
+
'boxxy.evidence.recorded': z.object({
|
|
114
|
+
kind: z.enum(['pr', 'commit', 'test', 'ci-run', 'live-check']),
|
|
115
|
+
ref: z.string().min(1),
|
|
116
|
+
observed: z.string().nullable(),
|
|
117
|
+
}),
|
|
118
|
+
'boxxy.evidence.pr_linked': z.object({
|
|
119
|
+
repo: brandSchemas.repoName,
|
|
120
|
+
number: pullRequestNumberSchema,
|
|
121
|
+
url: z.url(),
|
|
122
|
+
}),
|
|
123
|
+
'boxxy.evidence.commit_linked': z.object({
|
|
124
|
+
repo: brandSchemas.repoName,
|
|
125
|
+
sha: brandSchemas.commitSha,
|
|
126
|
+
pr: pullRequestNumberSchema,
|
|
127
|
+
}),
|
|
128
|
+
'boxxy.pr.merged': z.object({
|
|
129
|
+
repo: brandSchemas.repoName,
|
|
130
|
+
number: pullRequestNumberSchema,
|
|
131
|
+
mergedAt: brandSchemas.instant,
|
|
132
|
+
mergeCommit: brandSchemas.commitSha,
|
|
133
|
+
}),
|
|
134
|
+
'boxxy.pr.closed': z.object({ repo: brandSchemas.repoName, number: pullRequestNumberSchema }),
|
|
135
|
+
'boxxy.proposal.recorded': frictionSchema,
|
|
136
|
+
'boxxy.runner.paused': z.object({ runner: brandSchemas.runnerId }),
|
|
137
|
+
'boxxy.runner.resumed': z.object({ runner: brandSchemas.runnerId }),
|
|
138
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { Friction } from './types/facts.ts';
|
|
3
|
+
|
|
4
|
+
export const frictionSchema: z.ZodType<Friction> = z.object({
|
|
5
|
+
target: z.object({
|
|
6
|
+
kind: z.enum(['skill', 'rule', 'lint', 'agents-md', 'tool']),
|
|
7
|
+
name: z.string().min(1),
|
|
8
|
+
}),
|
|
9
|
+
change: z.string().min(1),
|
|
10
|
+
});
|
package/src/index.ts
CHANGED
|
@@ -1 +1,182 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export type { ContentHash, JsonValue } from '@boxxy/content-hash';
|
|
2
|
+
export { brandSchemas } from './brand-schemas.ts';
|
|
3
|
+
export { buildCloseOutSchema } from './build-close-out-schema.ts';
|
|
4
|
+
export { defineAdmission } from './define-admission.ts';
|
|
5
|
+
export { defineGate } from './define-gate.ts';
|
|
6
|
+
export { defineSignal } from './define-signal.ts';
|
|
7
|
+
export { deriveItemState } from './derive-item-state.ts';
|
|
8
|
+
export { factSchemas } from './fact-schemas.ts';
|
|
9
|
+
export { frictionSchema } from './friction-schema.ts';
|
|
10
|
+
export { liveLevers } from './live-levers.ts';
|
|
11
|
+
export { signalKey } from './signal-key.ts';
|
|
12
|
+
|
|
13
|
+
export type {
|
|
14
|
+
Actor,
|
|
15
|
+
ActorRef,
|
|
16
|
+
AgentSessionId,
|
|
17
|
+
AtcSessionId,
|
|
18
|
+
AttemptId,
|
|
19
|
+
AttemptRow,
|
|
20
|
+
AttemptSessionRow,
|
|
21
|
+
AttemptState,
|
|
22
|
+
CommitSha,
|
|
23
|
+
ConceptPin,
|
|
24
|
+
Criterion,
|
|
25
|
+
CriterionId,
|
|
26
|
+
DecisionId,
|
|
27
|
+
DecisionRow,
|
|
28
|
+
DerivedState,
|
|
29
|
+
Effort,
|
|
30
|
+
EvidenceKind,
|
|
31
|
+
EvidenceRow,
|
|
32
|
+
EvidenceSource,
|
|
33
|
+
FactId,
|
|
34
|
+
FaultRecord,
|
|
35
|
+
ForcedFailure,
|
|
36
|
+
Instant,
|
|
37
|
+
ItemId,
|
|
38
|
+
ItemKindName,
|
|
39
|
+
ItemRow,
|
|
40
|
+
ItemRows,
|
|
41
|
+
ItemState,
|
|
42
|
+
ItemView,
|
|
43
|
+
ItemWithLevers,
|
|
44
|
+
KnownFailure,
|
|
45
|
+
LeaseRow,
|
|
46
|
+
LeverKind,
|
|
47
|
+
LeverRow,
|
|
48
|
+
LinkRow,
|
|
49
|
+
LinkTypeName,
|
|
50
|
+
LiveAttemptState,
|
|
51
|
+
LoadedRecipe,
|
|
52
|
+
MaxAttemptsByKind,
|
|
53
|
+
Minutes,
|
|
54
|
+
ObservationBoundary,
|
|
55
|
+
PhaseName,
|
|
56
|
+
PipelineName,
|
|
57
|
+
PoolName,
|
|
58
|
+
PoolSlotRow,
|
|
59
|
+
PullRequestRef,
|
|
60
|
+
PullRequestRow,
|
|
61
|
+
Recipe,
|
|
62
|
+
RecipeHash,
|
|
63
|
+
RecipeMaterial,
|
|
64
|
+
RecipeName,
|
|
65
|
+
RepoName,
|
|
66
|
+
ResolvedRecipe,
|
|
67
|
+
RulesVersion,
|
|
68
|
+
RunnerId,
|
|
69
|
+
RunnerRow,
|
|
70
|
+
SnapshotHash,
|
|
71
|
+
SourceName,
|
|
72
|
+
StreamName,
|
|
73
|
+
WaitingReason,
|
|
74
|
+
WorkerKindName,
|
|
75
|
+
} from './types/core.ts';
|
|
76
|
+
|
|
77
|
+
export type {
|
|
78
|
+
Claim,
|
|
79
|
+
CloseOutContext,
|
|
80
|
+
CloseOutParse,
|
|
81
|
+
CloseOutParser,
|
|
82
|
+
CloseOutProblem,
|
|
83
|
+
ReconcileAction,
|
|
84
|
+
ReconcileTable,
|
|
85
|
+
SettleInput,
|
|
86
|
+
Settlement,
|
|
87
|
+
SettleRule,
|
|
88
|
+
SpawnContext,
|
|
89
|
+
} from './types/dispatch.ts';
|
|
90
|
+
|
|
91
|
+
export type {
|
|
92
|
+
BuildCloseOut,
|
|
93
|
+
EntityRef,
|
|
94
|
+
FactEnvelope,
|
|
95
|
+
FactType,
|
|
96
|
+
Friction,
|
|
97
|
+
FrictionTargetKind,
|
|
98
|
+
LinkPayload,
|
|
99
|
+
NewFact,
|
|
100
|
+
OpenItem,
|
|
101
|
+
OutboxFact,
|
|
102
|
+
SliceOneFacts,
|
|
103
|
+
} from './types/facts.ts';
|
|
104
|
+
|
|
105
|
+
export type {
|
|
106
|
+
Admission,
|
|
107
|
+
AdmissionGrant,
|
|
108
|
+
AdmissionName,
|
|
109
|
+
Decision,
|
|
110
|
+
Fault,
|
|
111
|
+
Frame,
|
|
112
|
+
FrameItem,
|
|
113
|
+
FrameValues,
|
|
114
|
+
Gate,
|
|
115
|
+
GateName,
|
|
116
|
+
Hold,
|
|
117
|
+
Lift,
|
|
118
|
+
Pick,
|
|
119
|
+
PlanContext,
|
|
120
|
+
Pool,
|
|
121
|
+
PropagationLine,
|
|
122
|
+
Signal,
|
|
123
|
+
SignalKey,
|
|
124
|
+
SignalName,
|
|
125
|
+
Snapshot,
|
|
126
|
+
View,
|
|
127
|
+
ViewName,
|
|
128
|
+
Waiver,
|
|
129
|
+
WaiverName,
|
|
130
|
+
} from './types/planning.ts';
|
|
131
|
+
|
|
132
|
+
export type {
|
|
133
|
+
AnyNewFact,
|
|
134
|
+
ApplyResult,
|
|
135
|
+
ClaimStore,
|
|
136
|
+
Clock,
|
|
137
|
+
CostReader,
|
|
138
|
+
CostToLandInput,
|
|
139
|
+
CostToLandRow,
|
|
140
|
+
FactSink,
|
|
141
|
+
Forge,
|
|
142
|
+
ItemDetailRows,
|
|
143
|
+
ItemFilter,
|
|
144
|
+
NewId,
|
|
145
|
+
PullRequestReading,
|
|
146
|
+
RowWrite,
|
|
147
|
+
SessionFault,
|
|
148
|
+
SessionReading,
|
|
149
|
+
SpawnRequest,
|
|
150
|
+
StartOutcome,
|
|
151
|
+
StoreChange,
|
|
152
|
+
StoreReader,
|
|
153
|
+
StoreTx,
|
|
154
|
+
TableName,
|
|
155
|
+
Tables,
|
|
156
|
+
WorkerKind,
|
|
157
|
+
} from './types/ports.ts';
|
|
158
|
+
|
|
159
|
+
export type {
|
|
160
|
+
Concept,
|
|
161
|
+
ConceptEntry,
|
|
162
|
+
ConceptName,
|
|
163
|
+
FilterField,
|
|
164
|
+
KindRules,
|
|
165
|
+
LoadedRules,
|
|
166
|
+
LoadRejection,
|
|
167
|
+
LoadRejectionReason,
|
|
168
|
+
LoadResult,
|
|
169
|
+
ParamKindName,
|
|
170
|
+
ParamKinds,
|
|
171
|
+
Pipeline,
|
|
172
|
+
PipelineStep,
|
|
173
|
+
PlainKinds,
|
|
174
|
+
PluginKindName,
|
|
175
|
+
PluginRef,
|
|
176
|
+
Registered,
|
|
177
|
+
Registry,
|
|
178
|
+
Resolved,
|
|
179
|
+
RulesFile,
|
|
180
|
+
Schema,
|
|
181
|
+
SignalRef,
|
|
182
|
+
} from './types/registries.ts';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Instant, LeverKind, LeverRow } from './types/core.ts';
|
|
2
|
+
|
|
3
|
+
export function liveLevers(levers: readonly LeverRow[], now: Instant): LeverRow[] {
|
|
4
|
+
return levers.filter((lever) => !isExpired(lever, now) && !isUndone(lever, levers));
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function isExpired(lever: LeverRow, now: Instant): boolean {
|
|
8
|
+
return lever.expiresAt !== null && lever.expiresAt <= now;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const undoKinds: ReadonlyMap<LeverKind, LeverKind> = new Map([
|
|
12
|
+
['plan.defer', 'plan.undefer'],
|
|
13
|
+
['plan.expedite', 'plan.unexpedite'],
|
|
14
|
+
]);
|
|
15
|
+
|
|
16
|
+
function isUndone(lever: LeverRow, levers: readonly LeverRow[]): boolean {
|
|
17
|
+
const undoKind = undoKinds.get(lever.kind);
|
|
18
|
+
|
|
19
|
+
return levers.some(
|
|
20
|
+
(later) => later.item === lever.item && later.kind === undoKind && later.seq > lever.seq,
|
|
21
|
+
);
|
|
22
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { JsonValue } from '@boxxy/content-hash';
|
|
2
|
+
import { contentHash } from '@boxxy/content-hash';
|
|
3
|
+
import type { SignalKey, SignalName } from './types/planning.ts';
|
|
4
|
+
|
|
5
|
+
export function signalKey(name: SignalName, params: JsonValue): SignalKey {
|
|
6
|
+
return `${name}#${contentHash(params)}`;
|
|
7
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { contentHash } from '@boxxy/content-hash';
|
|
2
|
+
import { faker } from '@faker-js/faker';
|
|
3
|
+
import { brandSchemas } from '../brand-schemas.ts';
|
|
4
|
+
import type { AttemptRow } from '../types/core.ts';
|
|
5
|
+
|
|
6
|
+
const hashOptions = { length: 64, casing: 'lower', prefix: '' } as const;
|
|
7
|
+
|
|
8
|
+
export function buildMockAttemptRow(overrides: Partial<AttemptRow> = {}): AttemptRow {
|
|
9
|
+
const spawnRequest =
|
|
10
|
+
overrides.spawnRequest === undefined
|
|
11
|
+
? { prompt: faker.lorem.sentence() }
|
|
12
|
+
: overrides.spawnRequest;
|
|
13
|
+
|
|
14
|
+
return {
|
|
15
|
+
id: brandSchemas.attemptId.parse(faker.string.uuid({ version: 7 })),
|
|
16
|
+
item: brandSchemas.itemId.parse(faker.string.uuid({ version: 7 })),
|
|
17
|
+
phase: brandSchemas.phaseName.parse('build'),
|
|
18
|
+
number: 1,
|
|
19
|
+
runner: brandSchemas.runnerId.parse('runner-1'),
|
|
20
|
+
recipeHash: brandSchemas.recipeHash.parse(faker.string.hexadecimal(hashOptions)),
|
|
21
|
+
rulesVersion: brandSchemas.rulesVersion.parse(faker.string.hexadecimal(hashOptions)),
|
|
22
|
+
pool: brandSchemas.poolName.parse('build'),
|
|
23
|
+
slot: 1,
|
|
24
|
+
slotGen: 1,
|
|
25
|
+
leaseGen: 1,
|
|
26
|
+
spawnRequest,
|
|
27
|
+
spawnRequestHash: contentHash(spawnRequest),
|
|
28
|
+
state: 'succeeded',
|
|
29
|
+
failure: null,
|
|
30
|
+
atcSession: brandSchemas.atcSessionId.parse(faker.string.uuid()),
|
|
31
|
+
closeOut: null,
|
|
32
|
+
claimedAt: brandSchemas.instant.parse(faker.number.int({ max: 1_800_000_000_000 })),
|
|
33
|
+
startedAt: brandSchemas.instant.parse(faker.number.int({ max: 1_800_000_000_000 })),
|
|
34
|
+
endedAt: brandSchemas.instant.parse(faker.number.int({ max: 1_800_000_000_000 })),
|
|
35
|
+
...overrides,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { faker } from '@faker-js/faker';
|
|
2
|
+
import { brandSchemas } from '../brand-schemas.ts';
|
|
3
|
+
import type { ItemRow } from '../types/core.ts';
|
|
4
|
+
|
|
5
|
+
export function buildMockItemRow(overrides: Partial<ItemRow> = {}): ItemRow {
|
|
6
|
+
return {
|
|
7
|
+
id: brandSchemas.itemId.parse(faker.string.uuid({ version: 7 })),
|
|
8
|
+
kind: brandSchemas.itemKindName.parse('core.issue'),
|
|
9
|
+
repo: brandSchemas.repoName.parse(`${faker.string.alpha(8)}/${faker.string.alpha(8)}`),
|
|
10
|
+
title: faker.lorem.sentence(),
|
|
11
|
+
outcome: faker.lorem.sentence(),
|
|
12
|
+
acceptance: [
|
|
13
|
+
{ id: brandSchemas.criterionId.parse('a1'), text: faker.lorem.sentence(), evidence: [] },
|
|
14
|
+
],
|
|
15
|
+
foundInAttempt: null,
|
|
16
|
+
filedBy: 'boxxy:owner:local',
|
|
17
|
+
filedAt: brandSchemas.instant.parse(faker.number.int({ max: 1_800_000_000_000 })),
|
|
18
|
+
closedAt: null,
|
|
19
|
+
closeReason: null,
|
|
20
|
+
...overrides,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ItemRows } from '../types/core.ts';
|
|
2
|
+
|
|
3
|
+
export function buildMockItemRows(overrides: Partial<ItemRows> = {}): ItemRows {
|
|
4
|
+
return {
|
|
5
|
+
links: [],
|
|
6
|
+
blockerStates: new Map(),
|
|
7
|
+
levers: [],
|
|
8
|
+
attempts: [],
|
|
9
|
+
liveLease: null,
|
|
10
|
+
pullRequests: [],
|
|
11
|
+
maxAttempts: 2,
|
|
12
|
+
...overrides,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { faker } from '@faker-js/faker';
|
|
2
|
+
import { brandSchemas } from '../brand-schemas.ts';
|
|
3
|
+
import type { LeaseRow } from '../types/core.ts';
|
|
4
|
+
|
|
5
|
+
export function buildMockLeaseRow(overrides: Partial<LeaseRow> = {}): LeaseRow {
|
|
6
|
+
return {
|
|
7
|
+
item: brandSchemas.itemId.parse(faker.string.uuid({ version: 7 })),
|
|
8
|
+
phase: brandSchemas.phaseName.parse('build'),
|
|
9
|
+
attempt: brandSchemas.attemptId.parse(faker.string.uuid({ version: 7 })),
|
|
10
|
+
gen: 1,
|
|
11
|
+
takenAt: brandSchemas.instant.parse(faker.number.int({ max: 1_800_000_000_000 })),
|
|
12
|
+
releasedAt: null,
|
|
13
|
+
...overrides,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { faker } from '@faker-js/faker';
|
|
2
|
+
import { brandSchemas } from '../brand-schemas.ts';
|
|
3
|
+
import type { LeverRow } from '../types/core.ts';
|
|
4
|
+
|
|
5
|
+
export function buildMockLeverRow(overrides: Partial<LeverRow> = {}): LeverRow {
|
|
6
|
+
return {
|
|
7
|
+
seq: faker.number.int({ min: 1, max: 10_000 }),
|
|
8
|
+
kind: 'plan.defer',
|
|
9
|
+
item: brandSchemas.itemId.parse(faker.string.uuid({ version: 7 })),
|
|
10
|
+
until: null,
|
|
11
|
+
expiresAt: null,
|
|
12
|
+
reason: faker.lorem.sentence(),
|
|
13
|
+
actor: 'boxxy:owner:local',
|
|
14
|
+
at: brandSchemas.instant.parse(faker.number.int({ max: 1_800_000_000_000 })),
|
|
15
|
+
...overrides,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { faker } from '@faker-js/faker';
|
|
2
|
+
import { brandSchemas } from '../brand-schemas.ts';
|
|
3
|
+
import type { LinkRow } from '../types/core.ts';
|
|
4
|
+
|
|
5
|
+
export function buildMockLinkRow(overrides: Partial<LinkRow> = {}): LinkRow {
|
|
6
|
+
return {
|
|
7
|
+
source: brandSchemas.itemId.parse(faker.string.uuid({ version: 7 })),
|
|
8
|
+
target: brandSchemas.itemId.parse(faker.string.uuid({ version: 7 })),
|
|
9
|
+
type: brandSchemas.linkTypeName.parse('blocks'),
|
|
10
|
+
addedBy: 'boxxy:owner:local',
|
|
11
|
+
addedAt: brandSchemas.instant.parse(faker.number.int({ max: 1_800_000_000_000 })),
|
|
12
|
+
removedAt: null,
|
|
13
|
+
...overrides,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { faker } from '@faker-js/faker';
|
|
2
|
+
import { brandSchemas } from '../brand-schemas.ts';
|
|
3
|
+
import type { PullRequestRow } from '../types/core.ts';
|
|
4
|
+
|
|
5
|
+
export function buildMockPullRequestRow(overrides: Partial<PullRequestRow> = {}): PullRequestRow {
|
|
6
|
+
return {
|
|
7
|
+
repo: brandSchemas.repoName.parse(`${faker.string.alpha(8)}/${faker.string.alpha(8)}`),
|
|
8
|
+
number: faker.number.int({ min: 1, max: 10_000 }),
|
|
9
|
+
attempt: brandSchemas.attemptId.parse(faker.string.uuid({ version: 7 })),
|
|
10
|
+
state: 'open',
|
|
11
|
+
mergedAt: null,
|
|
12
|
+
mergeCommit: null,
|
|
13
|
+
checkedAt: brandSchemas.instant.parse(faker.number.int({ max: 1_800_000_000_000 })),
|
|
14
|
+
...overrides,
|
|
15
|
+
};
|
|
16
|
+
}
|