@boxxy/model 0.1.1 → 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.
- package/README.md +8 -6
- package/dist/closeouts/build-close-out-schema.d.ts +31 -0
- package/dist/closeouts/close-out-answer-schema.d.ts +3 -0
- package/dist/closeouts/close-out-schema.d.ts +3 -0
- package/dist/closeouts/design-close-out-schema.d.ts +30 -0
- package/dist/closeouts/friction-schema.d.ts +14 -0
- package/dist/closeouts/open-item-schema.d.ts +3 -0
- package/dist/closeouts/review-close-out-schema.d.ts +40 -0
- package/dist/closeouts/triage-close-out-schema.d.ts +40 -0
- package/dist/closeouts/types.d.ts +221 -0
- package/dist/dispatch/build-applied-change.d.ts +6 -0
- package/dist/dispatch/collect-seat-sync.d.ts +14 -0
- package/dist/dispatch/pick-seat-take.d.ts +10 -0
- package/dist/dispatch/types.d.ts +11 -0
- package/dist/facts/outbox-fact-schema.d.ts +3 -0
- package/dist/facts/parse-new-fact.d.ts +2 -0
- package/dist/facts/types.d.ts +191 -0
- package/dist/facts/work-fact-schemas.d.ts +293 -0
- package/dist/index.d.ts +64 -16
- package/dist/items/build-item-views.d.ts +4 -0
- package/dist/items/collect-retries.d.ts +3 -0
- package/dist/items/collect-settled.d.ts +3 -0
- package/dist/items/derive-item-state.d.ts +17 -0
- package/dist/{live-levers.d.ts → items/live-levers.d.ts} +1 -1
- package/dist/items/types.d.ts +12 -0
- package/dist/pipeline/advance.d.ts +10 -0
- package/dist/pipeline/constants.d.ts +2 -0
- package/dist/pipeline/count-trailing.d.ts +1 -0
- package/dist/pipeline/find-position.d.ts +9 -0
- package/dist/pipeline/find-step.d.ts +3 -0
- package/dist/pipeline/merge-by-time.d.ts +9 -0
- package/dist/pipeline/position-schema.d.ts +3 -0
- package/dist/pipeline/types.d.ts +28 -0
- package/dist/planning/define-admission.d.ts +3 -0
- package/dist/planning/define-gate.d.ts +3 -0
- package/dist/planning/define-signal.d.ts +3 -0
- package/dist/planning/is-filter-match.d.ts +3 -0
- package/dist/planning/limit-fill-schema.d.ts +3 -0
- package/dist/{signal-key.d.ts → planning/signal-key.d.ts} +1 -1
- package/dist/planning/types.d.ts +155 -0
- package/dist/ports/types.d.ts +289 -0
- package/dist/reports/constants.d.ts +3 -0
- package/dist/reports/cost-to-land-schema.d.ts +29 -0
- package/dist/reports/outbox-status.d.ts +16 -0
- package/dist/reports/stage-time-schema.d.ts +25 -0
- package/dist/reports/types.d.ts +5 -0
- package/dist/rows/actor-ref-schema.d.ts +2 -0
- package/dist/rows/attempt-row-schema.d.ts +3 -0
- package/dist/rows/attempt-session-row-schema.d.ts +3 -0
- package/dist/{brand-schemas.d.ts → rows/brand-schemas.d.ts} +5 -2
- package/dist/rows/caller-identity-schema.d.ts +3 -0
- package/dist/rows/criterion-schema.d.ts +3 -0
- package/dist/rows/decision-row-schema.d.ts +34 -0
- package/dist/rows/evidence-row-schema.d.ts +3 -0
- package/dist/rows/item-row-schema.d.ts +28 -0
- package/dist/rows/item-view-schema.d.ts +3 -0
- package/dist/rows/lease-row-schema.d.ts +3 -0
- package/dist/rows/lever-row-schema.d.ts +12 -0
- package/dist/rows/limit-schema.d.ts +3 -0
- package/dist/rows/limit-seat-row-schema.d.ts +3 -0
- package/dist/rows/note-row-schema.d.ts +3 -0
- package/dist/rows/notice-row-schema.d.ts +3 -0
- package/dist/rows/pull-request-row-schema.d.ts +3 -0
- package/dist/rows/relation-row-schema.d.ts +3 -0
- package/dist/rows/row-schemas.d.ts +5 -0
- package/dist/rows/runner-row-schema.d.ts +3 -0
- package/dist/rows/spawn-request-schema.d.ts +3 -0
- package/dist/rules/define-phase.d.ts +3 -0
- package/dist/rules/load-rejection-schema.d.ts +3 -0
- package/dist/rules/types.d.ts +244 -0
- package/dist/test-utils/build-mock-cost-to-land.d.ts +2 -0
- package/dist/test-utils/build-mock-evidence-row.d.ts +2 -0
- package/dist/test-utils/build-mock-fact-id.d.ts +2 -0
- package/dist/test-utils/build-mock-frame-item.d.ts +2 -0
- package/dist/test-utils/build-mock-frame.d.ts +2 -0
- package/dist/test-utils/build-mock-item-rules.d.ts +2 -0
- package/dist/test-utils/build-mock-lease-row.d.ts +1 -1
- package/dist/test-utils/build-mock-outbox-fact.d.ts +2 -0
- package/dist/test-utils/build-mock-phase-kind.d.ts +7 -0
- package/dist/test-utils/build-mock-pipeline.d.ts +7 -0
- package/dist/test-utils/build-mock-relation-row.d.ts +2 -0
- package/dist/test-utils/build-mock-settled.d.ts +9 -0
- package/dist/test-utils/build-mock-snapshot.d.ts +2 -0
- package/dist/test-utils/build-mock-v1-attempt-row.d.ts +2 -0
- package/dist/test-utils/build-mock-v1-item-row.d.ts +2 -0
- package/dist/test-utils/build-mock-v1-item-view.d.ts +2 -0
- package/dist/test-utils/build-mock-v1-lever-row.d.ts +2 -0
- package/dist/test-utils/build-mock-v1-pull-request-row.d.ts +2 -0
- package/dist/test-utils/build-mock-work-fact.d.ts +12 -0
- package/dist/test-utils/create-fake-notifier.d.ts +9 -0
- package/dist/test-utils/create-fake-pepys-reader.d.ts +13 -0
- package/dist/test-utils/fact-sink-contract.d.ts +14 -0
- package/dist/test-utils/pepys-reader-contract.d.ts +17 -0
- package/dist/{types/core.d.ts → types.d.ts} +94 -36
- package/dist/utils/format-key-path.d.ts +1 -0
- package/dist/utils/to-json-value.d.ts +2 -0
- package/package.json +14 -3
- package/src/{build-close-out-schema.ts → closeouts/build-close-out-schema.ts} +5 -10
- package/src/closeouts/close-out-answer-schema.ts +42 -0
- package/src/closeouts/close-out-schema.ts +13 -0
- package/src/closeouts/design-close-out-schema.ts +20 -0
- package/src/closeouts/friction-schema.ts +11 -0
- package/src/closeouts/open-item-schema.ts +8 -0
- package/src/closeouts/review-close-out-schema.ts +38 -0
- package/src/closeouts/triage-close-out-schema.ts +29 -0
- package/src/closeouts/types.ts +230 -0
- package/src/dispatch/build-applied-change.ts +57 -0
- package/src/dispatch/collect-seat-sync.ts +86 -0
- package/src/dispatch/pick-seat-take.ts +39 -0
- package/src/dispatch/types.ts +14 -0
- package/src/facts/outbox-fact-schema.ts +22 -0
- package/src/facts/parse-new-fact.ts +16 -0
- package/src/facts/types.ts +235 -0
- package/src/facts/work-fact-schemas.ts +201 -0
- package/src/index.ts +147 -41
- package/src/items/build-item-views.ts +146 -0
- package/src/items/collect-retries.ts +12 -0
- package/src/items/collect-settled.ts +20 -0
- package/src/items/derive-item-state.ts +95 -0
- package/src/{live-levers.ts → items/live-levers.ts} +1 -1
- package/src/items/types.ts +26 -0
- package/src/pipeline/advance.ts +78 -0
- package/src/pipeline/constants.ts +12 -0
- package/src/pipeline/count-trailing.ts +16 -0
- package/src/pipeline/find-position.ts +74 -0
- package/src/pipeline/find-step.ts +6 -0
- package/src/pipeline/merge-by-time.ts +33 -0
- package/src/pipeline/position-schema.ts +27 -0
- package/src/pipeline/types.ts +47 -0
- package/src/{define-admission.ts → planning/define-admission.ts} +2 -2
- package/src/{define-gate.ts → planning/define-gate.ts} +2 -2
- package/src/{define-signal.ts → planning/define-signal.ts} +2 -2
- package/src/planning/is-filter-match.ts +10 -0
- package/src/planning/limit-fill-schema.ts +12 -0
- package/src/{signal-key.ts → planning/signal-key.ts} +1 -1
- package/src/planning/types.ts +216 -0
- package/src/ports/types.ts +412 -0
- package/src/reports/constants.ts +6 -0
- package/src/reports/cost-to-land-schema.ts +47 -0
- package/src/reports/outbox-status.ts +22 -0
- package/src/reports/stage-time-schema.ts +21 -0
- package/src/reports/types.ts +7 -0
- package/src/rows/actor-ref-schema.ts +17 -0
- package/src/rows/attempt-row-schema.ts +69 -0
- package/src/rows/attempt-session-row-schema.ts +12 -0
- package/src/{brand-schemas.ts → rows/brand-schemas.ts} +5 -2
- package/src/rows/caller-identity-schema.ts +7 -0
- package/src/rows/criterion-schema.ts +9 -0
- package/src/rows/decision-row-schema.ts +34 -0
- package/src/rows/evidence-row-schema.ts +13 -0
- package/src/rows/item-row-schema.ts +32 -0
- package/src/rows/item-view-schema.ts +31 -0
- package/src/rows/lease-row-schema.ts +12 -0
- package/src/rows/lever-row-schema.ts +17 -0
- package/src/rows/limit-schema.ts +12 -0
- package/src/rows/limit-seat-row-schema.ts +12 -0
- package/src/rows/note-row-schema.ts +12 -0
- package/src/rows/notice-row-schema.ts +17 -0
- package/src/rows/pull-request-row-schema.ts +15 -0
- package/src/rows/relation-row-schema.ts +13 -0
- package/src/rows/row-schemas.ts +30 -0
- package/src/rows/runner-row-schema.ts +9 -0
- package/src/rows/spawn-request-schema.ts +15 -0
- package/src/rules/define-phase.ts +12 -0
- package/src/rules/load-rejection-schema.ts +51 -0
- package/src/rules/types.ts +291 -0
- package/src/test-utils/build-mock-cost-to-land.ts +31 -0
- package/src/test-utils/build-mock-evidence-row.ts +17 -0
- package/src/test-utils/build-mock-fact-id.ts +7 -0
- package/src/test-utils/build-mock-frame-item.ts +14 -0
- package/src/test-utils/build-mock-frame.ts +13 -0
- package/src/test-utils/build-mock-item-rules.ts +17 -0
- package/src/test-utils/build-mock-lease-row.ts +2 -2
- package/src/test-utils/build-mock-outbox-fact.ts +22 -0
- package/src/test-utils/build-mock-phase-kind.ts +29 -0
- package/src/test-utils/build-mock-pipeline.ts +52 -0
- package/src/test-utils/{build-mock-link-row.ts → build-mock-relation-row.ts} +4 -4
- package/src/test-utils/build-mock-settled.ts +18 -0
- package/src/test-utils/build-mock-snapshot.ts +13 -0
- package/src/test-utils/{build-mock-attempt-row.ts → build-mock-v1-attempt-row.ts} +28 -9
- package/src/test-utils/{build-mock-item-row.ts → build-mock-v1-item-row.ts} +7 -3
- package/src/test-utils/build-mock-v1-item-view.ts +29 -0
- package/src/test-utils/{build-mock-lever-row.ts → build-mock-v1-lever-row.ts} +5 -3
- package/src/test-utils/build-mock-v1-pull-request-row.ts +26 -0
- package/src/test-utils/build-mock-work-fact.ts +179 -0
- package/src/test-utils/create-fake-notifier.ts +54 -0
- package/src/test-utils/create-fake-pepys-reader.ts +73 -0
- package/src/test-utils/fact-sink-contract.ts +103 -0
- package/src/test-utils/pepys-reader-contract.ts +117 -0
- package/src/{types/core.ts → types.ts} +184 -48
- package/src/utils/format-key-path.ts +19 -0
- package/src/utils/to-json-value.ts +25 -0
- package/dist/build-close-out-schema.d.ts +0 -3
- package/dist/define-admission.d.ts +0 -3
- package/dist/define-gate.d.ts +0 -3
- package/dist/define-signal.d.ts +0 -3
- package/dist/derive-item-state.d.ts +0 -2
- package/dist/fact-schemas.d.ts +0 -5
- package/dist/friction-schema.d.ts +0 -3
- package/dist/test-utils/build-mock-attempt-row.d.ts +0 -2
- package/dist/test-utils/build-mock-item-row.d.ts +0 -2
- package/dist/test-utils/build-mock-item-rows.d.ts +0 -2
- package/dist/test-utils/build-mock-lever-row.d.ts +0 -2
- package/dist/test-utils/build-mock-link-row.d.ts +0 -2
- package/dist/test-utils/build-mock-pull-request-row.d.ts +0 -2
- package/dist/types/dispatch.d.ts +0 -82
- package/dist/types/facts.d.ts +0 -154
- package/dist/types/planning.d.ts +0 -94
- package/dist/types/ports.d.ts +0 -218
- package/dist/types/registries.d.ts +0 -150
- package/src/derive-item-state.ts +0 -76
- package/src/fact-schemas.ts +0 -138
- package/src/friction-schema.ts +0 -10
- package/src/test-utils/build-mock-item-rows.ts +0 -14
- package/src/test-utils/build-mock-pull-request-row.ts +0 -16
- package/src/types/dispatch.ts +0 -95
- package/src/types/facts.ts +0 -166
- package/src/types/planning.ts +0 -136
- package/src/types/ports.ts +0 -262
- package/src/types/registries.ts +0 -185
- /package/dist/test-utils/{seed-faker.d.ts → pin-faker-seed.d.ts} +0 -0
- /package/src/test-utils/{seed-faker.ts → pin-faker-seed.ts} +0 -0
package/src/types/planning.ts
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
FaultRecord,
|
|
3
|
-
Instant,
|
|
4
|
-
ItemId,
|
|
5
|
-
ItemView,
|
|
6
|
-
LeverRow,
|
|
7
|
-
LinkRow,
|
|
8
|
-
LinkTypeName,
|
|
9
|
-
PhaseName,
|
|
10
|
-
PoolName,
|
|
11
|
-
} from './core.ts';
|
|
12
|
-
import type { Schema } from './registries.ts';
|
|
13
|
-
|
|
14
|
-
export type SignalName = string;
|
|
15
|
-
|
|
16
|
-
export type GateName = string;
|
|
17
|
-
|
|
18
|
-
export type WaiverName = string;
|
|
19
|
-
|
|
20
|
-
export type AdmissionName = string;
|
|
21
|
-
|
|
22
|
-
export type ViewName = string;
|
|
23
|
-
|
|
24
|
-
export type SignalKey = `${SignalName}#${string}`;
|
|
25
|
-
|
|
26
|
-
export interface Snapshot {
|
|
27
|
-
storeVersion: number;
|
|
28
|
-
|
|
29
|
-
// every item not yet done and not archived, with its state derived at the read's `now`
|
|
30
|
-
items: ItemView[];
|
|
31
|
-
links: LinkRow[];
|
|
32
|
-
levers: LeverRow[];
|
|
33
|
-
freeSlots: Record<PoolName, number>;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export interface FrameItem extends ItemView {
|
|
37
|
-
readonly phase: PhaseName;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export interface Frame {
|
|
41
|
-
// the open items in state `ready`, the only items decide picks
|
|
42
|
-
candidates: FrameItem[];
|
|
43
|
-
fields: Map<ItemId, Readonly<Record<string, readonly string[]>>>;
|
|
44
|
-
values: Map<SignalKey, Map<ItemId, number>>;
|
|
45
|
-
holds: Map<ItemId, Hold[]>;
|
|
46
|
-
lifted: Map<ItemId, Lift[]>;
|
|
47
|
-
faults: Fault[];
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export type FrameValues = ReadonlyMap<SignalKey, ReadonlyMap<ItemId, number>>;
|
|
51
|
-
|
|
52
|
-
export interface Hold {
|
|
53
|
-
readonly gate: GateName;
|
|
54
|
-
readonly reason: string;
|
|
55
|
-
readonly until?: Instant;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export interface Lift {
|
|
59
|
-
readonly waiver: WaiverName;
|
|
60
|
-
readonly gate: GateName;
|
|
61
|
-
readonly reason: string;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export type Fault = FaultRecord;
|
|
65
|
-
|
|
66
|
-
export interface Decision {
|
|
67
|
-
// in pool order, then by each pool's `order`
|
|
68
|
-
picks: Pick[];
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export interface Pick {
|
|
72
|
-
item: ItemId;
|
|
73
|
-
phase: PhaseName;
|
|
74
|
-
pool: PoolName;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export interface Pool {
|
|
78
|
-
readonly name: PoolName;
|
|
79
|
-
readonly slots: number;
|
|
80
|
-
readonly takes: Readonly<Record<string, readonly string[]>>;
|
|
81
|
-
|
|
82
|
-
// `lead`, then the pool's own `order`: lower first, no value last, then item id
|
|
83
|
-
readonly order: readonly SignalKey[];
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export interface PlanContext {
|
|
87
|
-
now: Instant;
|
|
88
|
-
levers: LeverRow[];
|
|
89
|
-
links: LinkRow[];
|
|
90
|
-
values: FrameValues;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export interface Signal<P> {
|
|
94
|
-
name: SignalName;
|
|
95
|
-
params: Schema<P>;
|
|
96
|
-
|
|
97
|
-
// null is no opinion
|
|
98
|
-
value: (item: FrameItem, ctx: PlanContext, params: P) => number | null;
|
|
99
|
-
combine?: (left: number, right: number) => number;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export interface Gate<P> {
|
|
103
|
-
name: GateName;
|
|
104
|
-
liftable: boolean;
|
|
105
|
-
params: Schema<P>;
|
|
106
|
-
hold: (item: FrameItem, ctx: PlanContext, params: P) => Hold | null;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export interface Waiver {
|
|
110
|
-
name: WaiverName;
|
|
111
|
-
lifts: GateName;
|
|
112
|
-
lift: (item: FrameItem, hold: Hold, ctx: PlanContext) => Lift | null;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export interface Admission<P> {
|
|
116
|
-
name: AdmissionName;
|
|
117
|
-
params: Schema<P>;
|
|
118
|
-
admit: (item: FrameItem, ctx: PlanContext, params: P) => AdmissionGrant | null;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export interface AdmissionGrant {
|
|
122
|
-
readonly admission: AdmissionName;
|
|
123
|
-
readonly pools: readonly PoolName[] | 'any';
|
|
124
|
-
readonly reason: string;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
export interface View<I = unknown, O = unknown> {
|
|
128
|
-
name: ViewName;
|
|
129
|
-
render: (frame: Frame, input: I) => O;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
export interface PropagationLine {
|
|
133
|
-
readonly value: SignalName;
|
|
134
|
-
readonly over: LinkTypeName;
|
|
135
|
-
readonly toward: 'source' | 'target';
|
|
136
|
-
}
|
package/src/types/ports.ts
DELETED
|
@@ -1,262 +0,0 @@
|
|
|
1
|
-
import type { JsonValue } from '@boxxy/content-hash';
|
|
2
|
-
import type {
|
|
3
|
-
AgentSessionId,
|
|
4
|
-
AtcSessionId,
|
|
5
|
-
AttemptId,
|
|
6
|
-
AttemptRow,
|
|
7
|
-
AttemptSessionRow,
|
|
8
|
-
CommitSha,
|
|
9
|
-
DecisionRow,
|
|
10
|
-
Effort,
|
|
11
|
-
EvidenceRow,
|
|
12
|
-
FactId,
|
|
13
|
-
Instant,
|
|
14
|
-
ItemId,
|
|
15
|
-
ItemRow,
|
|
16
|
-
ItemState,
|
|
17
|
-
ItemView,
|
|
18
|
-
ItemWithLevers,
|
|
19
|
-
LeaseRow,
|
|
20
|
-
LeverRow,
|
|
21
|
-
LinkRow,
|
|
22
|
-
MaxAttemptsByKind,
|
|
23
|
-
PhaseName,
|
|
24
|
-
PoolName,
|
|
25
|
-
PoolSlotRow,
|
|
26
|
-
PullRequestRef,
|
|
27
|
-
PullRequestRow,
|
|
28
|
-
RepoName,
|
|
29
|
-
RunnerId,
|
|
30
|
-
RunnerRow,
|
|
31
|
-
} from './core.ts';
|
|
32
|
-
import type { FactType, NewFact, OutboxFact } from './facts.ts';
|
|
33
|
-
import type { Snapshot } from './planning.ts';
|
|
34
|
-
|
|
35
|
-
export interface ClaimStore {
|
|
36
|
-
exclusive: <T>(work: (tx: StoreTx) => Promise<T>) => Promise<T>;
|
|
37
|
-
read: <T>(work: (tx: StoreReader) => Promise<T>) => Promise<T>;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export interface StoreReader {
|
|
41
|
-
readSnapshot: (now: Instant, maxAttemptsByKind: MaxAttemptsByKind) => Promise<Snapshot>;
|
|
42
|
-
readItem: (
|
|
43
|
-
id: ItemId,
|
|
44
|
-
now: Instant,
|
|
45
|
-
maxAttemptsByKind: MaxAttemptsByKind,
|
|
46
|
-
) => Promise<ItemView | null>;
|
|
47
|
-
readItemDetail: (
|
|
48
|
-
id: ItemId,
|
|
49
|
-
now: Instant,
|
|
50
|
-
maxAttemptsByKind: MaxAttemptsByKind,
|
|
51
|
-
) => Promise<ItemDetailRows | null>;
|
|
52
|
-
listItems: (
|
|
53
|
-
filter: ItemFilter,
|
|
54
|
-
now: Instant,
|
|
55
|
-
maxAttemptsByKind: MaxAttemptsByKind,
|
|
56
|
-
) => Promise<ItemWithLevers[]>;
|
|
57
|
-
listOpenIssues: (
|
|
58
|
-
repo: RepoName,
|
|
59
|
-
now: Instant,
|
|
60
|
-
maxAttemptsByKind: MaxAttemptsByKind,
|
|
61
|
-
) => Promise<ItemView[]>;
|
|
62
|
-
|
|
63
|
-
// 0 when the item phase has no lease
|
|
64
|
-
readLastLeaseGen: (item: ItemId, phase: PhaseName) => Promise<number>;
|
|
65
|
-
readAttempt: (id: AttemptId) => Promise<AttemptRow | null>;
|
|
66
|
-
listEvidence: (attempt: AttemptId) => Promise<EvidenceRow[]>;
|
|
67
|
-
listLiveAttempts: () => Promise<AttemptRow[]>;
|
|
68
|
-
listSucceededAttemptsWithoutPr: () => Promise<AttemptRow[]>;
|
|
69
|
-
findAttemptBySession: (session: AtcSessionId) => Promise<AttemptRow | null>;
|
|
70
|
-
findAttemptByAgentSession: (session: AgentSessionId) => Promise<AttemptId | null>;
|
|
71
|
-
|
|
72
|
-
// the rows in state `open`
|
|
73
|
-
listWatchedPullRequests: () => Promise<PullRequestRow[]>;
|
|
74
|
-
|
|
75
|
-
// retired rows included
|
|
76
|
-
listPoolSlots: () => Promise<PoolSlotRow[]>;
|
|
77
|
-
|
|
78
|
-
// oldest first
|
|
79
|
-
readUnsentFacts: (limit: number) => Promise<OutboxFact[]>;
|
|
80
|
-
readOutboxLag: () => Promise<{
|
|
81
|
-
readonly unsent: number;
|
|
82
|
-
readonly oldestUnsentAt: Instant | null;
|
|
83
|
-
}>;
|
|
84
|
-
|
|
85
|
-
// null before the runner's first heartbeat, which reads as not paused
|
|
86
|
-
readRunner: (id: RunnerId) => Promise<RunnerRow | null>;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export interface ItemDetailRows {
|
|
90
|
-
readonly item: ItemWithLevers;
|
|
91
|
-
readonly attempts: readonly AttemptRow[];
|
|
92
|
-
readonly links: readonly LinkRow[];
|
|
93
|
-
readonly evidence: readonly EvidenceRow[];
|
|
94
|
-
readonly pullRequests: readonly PullRequestRow[];
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export interface StoreTx extends StoreReader {
|
|
98
|
-
applyChange: (change: StoreChange) => Promise<ApplyResult>;
|
|
99
|
-
markFactsSent: (ids: FactId[], at: Instant) => Promise<void>;
|
|
100
|
-
writeHeartbeat: (runner: RunnerId, at: Instant) => Promise<void>;
|
|
101
|
-
syncPoolSlots: (
|
|
102
|
-
pools: readonly { readonly name: PoolName; readonly slots: number }[],
|
|
103
|
-
) => Promise<void>;
|
|
104
|
-
markPullRequestChecked: (ref: PullRequestRef, at: Instant) => Promise<void>;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
export interface StoreChange {
|
|
108
|
-
at: Instant;
|
|
109
|
-
under?: {
|
|
110
|
-
item: ItemId;
|
|
111
|
-
phase: PhaseName;
|
|
112
|
-
gen: number;
|
|
113
|
-
slot?: { pool: PoolName; slot: number; gen: number };
|
|
114
|
-
};
|
|
115
|
-
writes: RowWrite[];
|
|
116
|
-
facts: AnyNewFact[];
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export type ApplyResult =
|
|
120
|
-
| { kind: 'applied'; slot: { pool: PoolName; slot: number; gen: number } | null }
|
|
121
|
-
| { kind: 'stale-generation' }
|
|
122
|
-
| { kind: 'lease-held' }
|
|
123
|
-
| { kind: 'no-free-slot' }
|
|
124
|
-
| { kind: 'guard-mismatch'; table: TableName; key: JsonValue };
|
|
125
|
-
|
|
126
|
-
export interface ItemFilter {
|
|
127
|
-
readonly state?: ItemState;
|
|
128
|
-
readonly repo?: RepoName;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
export interface Tables {
|
|
132
|
-
items: ItemRow;
|
|
133
|
-
links: LinkRow;
|
|
134
|
-
levers: LeverRow;
|
|
135
|
-
attempts: AttemptRow;
|
|
136
|
-
attempt_sessions: AttemptSessionRow;
|
|
137
|
-
leases: LeaseRow;
|
|
138
|
-
pool_slots: PoolSlotRow;
|
|
139
|
-
decisions: DecisionRow;
|
|
140
|
-
evidence: EvidenceRow;
|
|
141
|
-
pull_requests: PullRequestRow;
|
|
142
|
-
runners: RunnerRow;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
export type TableName = keyof Tables;
|
|
146
|
-
|
|
147
|
-
export type RowWrite =
|
|
148
|
-
| {
|
|
149
|
-
[T in TableName]: { readonly op: 'insert'; readonly table: T; readonly row: Tables[T] };
|
|
150
|
-
}[TableName]
|
|
151
|
-
| {
|
|
152
|
-
[T in TableName]: {
|
|
153
|
-
readonly op: 'update';
|
|
154
|
-
readonly table: T;
|
|
155
|
-
readonly key: Partial<Tables[T]>;
|
|
156
|
-
readonly expect: Partial<Tables[T]>;
|
|
157
|
-
readonly set: Partial<Tables[T]>;
|
|
158
|
-
};
|
|
159
|
-
}[TableName]
|
|
160
|
-
| { readonly op: 'take-slot'; readonly pool: PoolName; readonly holder: AttemptId }
|
|
161
|
-
| {
|
|
162
|
-
readonly op: 'release-slot';
|
|
163
|
-
readonly pool: PoolName;
|
|
164
|
-
readonly slot: number;
|
|
165
|
-
readonly holder: AttemptId;
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
export type AnyNewFact = { [T in FactType]: NewFact<T> }[FactType];
|
|
169
|
-
|
|
170
|
-
export interface WorkerKind {
|
|
171
|
-
start: (request: SpawnRequest) => Promise<StartOutcome>;
|
|
172
|
-
reconcile: (attempt: AttemptRow) => Promise<SessionReading>;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
export type StartOutcome =
|
|
176
|
-
| { kind: 'started'; atcSession: AtcSessionId; agentSession: AgentSessionId | null }
|
|
177
|
-
| { kind: 'refused'; reason: string }
|
|
178
|
-
| { kind: 'unknown'; reason: string };
|
|
179
|
-
|
|
180
|
-
export type SessionReading =
|
|
181
|
-
| { kind: 'running'; atcSession: AtcSessionId; agentSession: AgentSessionId | null }
|
|
182
|
-
| { kind: 'ended'; atcSession: AtcSessionId; agentSession: AgentSessionId | null }
|
|
183
|
-
| { kind: 'absent' };
|
|
184
|
-
|
|
185
|
-
export interface SpawnRequest {
|
|
186
|
-
// the repo's configured local path
|
|
187
|
-
readonly cwd: string;
|
|
188
|
-
readonly prompt: string;
|
|
189
|
-
readonly agent: string;
|
|
190
|
-
readonly model: string;
|
|
191
|
-
readonly effort: Effort;
|
|
192
|
-
readonly pluginDirs: readonly string[];
|
|
193
|
-
readonly name: `boxxy/${string}`;
|
|
194
|
-
readonly idempotencyKey: AttemptId;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
export interface SessionFault {
|
|
198
|
-
readonly kind: 'fault';
|
|
199
|
-
readonly fault: 'agent-session-owned';
|
|
200
|
-
readonly agentSession: AgentSessionId;
|
|
201
|
-
readonly attempt: AttemptId;
|
|
202
|
-
readonly holder: AttemptId;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
export interface FactSink {
|
|
206
|
-
append: (
|
|
207
|
-
facts: OutboxFact[],
|
|
208
|
-
) => Promise<
|
|
209
|
-
'accepted' | { kind: 'unknown'; reason: string } | { kind: 'rejected'; error: string }
|
|
210
|
-
>;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
export interface CostToLandRow {
|
|
214
|
-
readonly item: ItemId;
|
|
215
|
-
readonly title: string;
|
|
216
|
-
readonly repo: RepoName;
|
|
217
|
-
readonly landedAt: Instant;
|
|
218
|
-
readonly model: string;
|
|
219
|
-
readonly attempts: number;
|
|
220
|
-
readonly requests: number;
|
|
221
|
-
readonly inputTokens: number;
|
|
222
|
-
readonly outputTokens: number;
|
|
223
|
-
readonly cacheReadTokens: number;
|
|
224
|
-
readonly cacheCreationTokens: number;
|
|
225
|
-
|
|
226
|
-
// input, cache read and cache creation tokens together
|
|
227
|
-
readonly totalInputTokens: number;
|
|
228
|
-
|
|
229
|
-
// modelled at list price, not billed
|
|
230
|
-
readonly costUsd: number;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
export interface CostToLandInput {
|
|
234
|
-
readonly repo?: string;
|
|
235
|
-
|
|
236
|
-
// ISO 8601, as the pepys query takes it
|
|
237
|
-
readonly landedFrom?: string;
|
|
238
|
-
readonly landedTo?: string;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
export interface CostReader {
|
|
242
|
-
costToLand: (input: CostToLandInput) => Promise<CostToLandRow[]>;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
export interface Forge {
|
|
246
|
-
readPullRequest: (ref: PullRequestRef) => Promise<PullRequestReading | 'not-found'>;
|
|
247
|
-
listOpenPullRequests: (repo: RepoName) => Promise<PullRequestRef[]>;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
export interface PullRequestReading {
|
|
251
|
-
url: string;
|
|
252
|
-
state: 'open' | 'closed' | 'merged';
|
|
253
|
-
mergedAt: Instant | null;
|
|
254
|
-
mergeCommit: CommitSha | null;
|
|
255
|
-
commits: { sha: CommitSha; message: string }[];
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
export interface Clock {
|
|
259
|
-
now: () => Instant;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
export type NewId = () => string;
|
package/src/types/registries.ts
DELETED
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
import type { JsonValue } from '@boxxy/content-hash';
|
|
2
|
-
import type { z } from 'zod';
|
|
3
|
-
import type {
|
|
4
|
-
ConceptPin,
|
|
5
|
-
ItemKindName,
|
|
6
|
-
LeverKind,
|
|
7
|
-
LoadedRecipe,
|
|
8
|
-
MaxAttemptsByKind,
|
|
9
|
-
PhaseName,
|
|
10
|
-
PipelineName,
|
|
11
|
-
RecipeName,
|
|
12
|
-
RulesVersion,
|
|
13
|
-
} from './core.ts';
|
|
14
|
-
import type {
|
|
15
|
-
Admission,
|
|
16
|
-
FrameItem,
|
|
17
|
-
Gate,
|
|
18
|
-
Pool,
|
|
19
|
-
PropagationLine,
|
|
20
|
-
Signal,
|
|
21
|
-
SignalKey,
|
|
22
|
-
SignalName,
|
|
23
|
-
View,
|
|
24
|
-
Waiver,
|
|
25
|
-
} from './planning.ts';
|
|
26
|
-
|
|
27
|
-
export type Schema<T> = z.ZodType<T>;
|
|
28
|
-
|
|
29
|
-
export interface ParamKinds<P> {
|
|
30
|
-
signal: Signal<P>;
|
|
31
|
-
gate: Gate<P>;
|
|
32
|
-
admission: Admission<P>;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export type ParamKindName = keyof ParamKinds<unknown>;
|
|
36
|
-
|
|
37
|
-
export interface Registered<K extends ParamKindName> {
|
|
38
|
-
readonly kind: K;
|
|
39
|
-
readonly name: string;
|
|
40
|
-
open: <R>(use: <P>(plugin: ParamKinds<P>[K]) => R) => R;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export interface Resolved<K extends ParamKindName> {
|
|
44
|
-
readonly kind: K;
|
|
45
|
-
readonly name: string;
|
|
46
|
-
|
|
47
|
-
// `signalKey(name, params)` for a signal, and the name for a gate
|
|
48
|
-
readonly key: string;
|
|
49
|
-
open: <R>(use: <P>(plugin: ParamKinds<P>[K], params: P) => R) => R;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export type ConceptName = string;
|
|
53
|
-
|
|
54
|
-
export interface Concept {
|
|
55
|
-
name: ConceptName;
|
|
56
|
-
version: number;
|
|
57
|
-
signals?: Registered<'signal'>[];
|
|
58
|
-
gates?: Registered<'gate'>[];
|
|
59
|
-
waivers?: Waiver[];
|
|
60
|
-
levers?: LeverKind[];
|
|
61
|
-
filterFields?: FilterField[];
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export interface FilterField {
|
|
65
|
-
name: string;
|
|
66
|
-
|
|
67
|
-
// null never matches a filter on this field
|
|
68
|
-
value: (item: FrameItem) => string | readonly string[] | null;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export interface PlainKinds {
|
|
72
|
-
waiver: Waiver;
|
|
73
|
-
'filter-field': FilterField;
|
|
74
|
-
lever: { readonly kind: LeverKind };
|
|
75
|
-
view: View;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export type PluginKindName = ParamKindName | keyof PlainKinds;
|
|
79
|
-
|
|
80
|
-
export type Registry = { readonly [K in ParamKindName]: ReadonlyMap<string, Registered<K>> } & {
|
|
81
|
-
readonly [K in keyof PlainKinds]: ReadonlyMap<string, PlainKinds[K]>;
|
|
82
|
-
} & { readonly pins: readonly ConceptPin[] };
|
|
83
|
-
|
|
84
|
-
export interface KindRules {
|
|
85
|
-
readonly pipeline: Pipeline;
|
|
86
|
-
readonly recipes: Readonly<Record<PhaseName, RecipeName>>;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export interface Pipeline {
|
|
90
|
-
readonly name: PipelineName;
|
|
91
|
-
readonly steps: readonly PipelineStep[];
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export interface PipelineStep {
|
|
95
|
-
readonly phase: PhaseName;
|
|
96
|
-
|
|
97
|
-
// failed attempts before the item waits on "attempts used up"
|
|
98
|
-
readonly maxAttempts: number;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export type ConceptEntry = `${string}@${number}`;
|
|
102
|
-
|
|
103
|
-
export type PluginRef = string | Readonly<Record<string, JsonValue>>;
|
|
104
|
-
|
|
105
|
-
export type SignalRef = SignalName | Readonly<Record<string, JsonValue>>;
|
|
106
|
-
|
|
107
|
-
export interface RulesFile {
|
|
108
|
-
readonly version: 1;
|
|
109
|
-
readonly concepts: readonly ConceptEntry[];
|
|
110
|
-
readonly kinds: Readonly<
|
|
111
|
-
Record<
|
|
112
|
-
string,
|
|
113
|
-
{
|
|
114
|
-
readonly pipeline: readonly string[] | PipelineName;
|
|
115
|
-
readonly maxAttempts: Readonly<Record<string, number>>;
|
|
116
|
-
readonly recipes: Readonly<Record<string, string>>;
|
|
117
|
-
}
|
|
118
|
-
>
|
|
119
|
-
>;
|
|
120
|
-
readonly pools: readonly {
|
|
121
|
-
readonly name: string;
|
|
122
|
-
readonly slots: number;
|
|
123
|
-
readonly takes: Readonly<Record<string, JsonValue>>;
|
|
124
|
-
readonly order: readonly SignalRef[];
|
|
125
|
-
}[];
|
|
126
|
-
readonly lead: readonly SignalRef[];
|
|
127
|
-
readonly propagation: readonly {
|
|
128
|
-
readonly value: string;
|
|
129
|
-
readonly over: string;
|
|
130
|
-
readonly toward: 'source' | 'target';
|
|
131
|
-
}[];
|
|
132
|
-
readonly recipes: Readonly<
|
|
133
|
-
Record<
|
|
134
|
-
string,
|
|
135
|
-
{
|
|
136
|
-
readonly agent: string;
|
|
137
|
-
readonly model: string;
|
|
138
|
-
readonly effort: string;
|
|
139
|
-
readonly prompt: string;
|
|
140
|
-
readonly source: string;
|
|
141
|
-
}
|
|
142
|
-
>
|
|
143
|
-
>;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
export interface LoadedRules {
|
|
147
|
-
readonly version: RulesVersion;
|
|
148
|
-
readonly commit: string;
|
|
149
|
-
readonly registry: Registry;
|
|
150
|
-
readonly signals: ReadonlyMap<SignalKey, Resolved<'signal'>>;
|
|
151
|
-
readonly gates: readonly Resolved<'gate'>[];
|
|
152
|
-
readonly kinds: ReadonlyMap<ItemKindName, KindRules>;
|
|
153
|
-
readonly maxAttemptsByKind: MaxAttemptsByKind;
|
|
154
|
-
|
|
155
|
-
// in declared order, each pool's `order` starting with `lead`
|
|
156
|
-
readonly pools: readonly Pool[];
|
|
157
|
-
readonly propagation: readonly PropagationLine[];
|
|
158
|
-
readonly recipes: ReadonlyMap<RecipeName, LoadedRecipe>;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
export interface LoadRejection {
|
|
162
|
-
readonly file: string;
|
|
163
|
-
readonly path: string;
|
|
164
|
-
readonly reason: LoadRejectionReason;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
export type LoadRejectionReason =
|
|
168
|
-
| { readonly kind: 'invalid'; readonly message: string }
|
|
169
|
-
| { readonly kind: 'unknown-concept'; readonly ref: string }
|
|
170
|
-
| { readonly kind: 'unknown-signal'; readonly signal: string }
|
|
171
|
-
| {
|
|
172
|
-
readonly kind: 'bad-plugin-params';
|
|
173
|
-
readonly pluginKind: ParamKindName;
|
|
174
|
-
readonly name: string;
|
|
175
|
-
readonly message: string;
|
|
176
|
-
}
|
|
177
|
-
| { readonly kind: 'unknown-link-type'; readonly link: string }
|
|
178
|
-
| { readonly kind: 'signal-without-combine'; readonly signal: string }
|
|
179
|
-
| { readonly kind: 'missing-recipe'; readonly itemKind: string; readonly phase: string }
|
|
180
|
-
| { readonly kind: 'missing-prompt'; readonly path: string }
|
|
181
|
-
| { readonly kind: 'uncommitted-changes' };
|
|
182
|
-
|
|
183
|
-
export type LoadResult =
|
|
184
|
-
| { readonly kind: 'loaded'; readonly rules: LoadedRules; readonly warnings: readonly string[] }
|
|
185
|
-
| { readonly kind: 'rejected'; readonly rejections: readonly LoadRejection[] };
|
|
File without changes
|
|
File without changes
|