@company-semantics/contracts 91.0.0 → 92.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -2
- package/src/api/generated-spec-hash.ts +2 -2
- package/src/api/generated.ts +402 -10
- package/src/generated/openapi-routes.ts +3 -0
- package/src/source-sync/README.md +2 -1
- package/src/source-sync/__tests__/approval-schemas.test.ts +2 -13
- package/src/source-sync/__tests__/current-synthesis.test.ts +1 -0
- package/src/source-sync/__tests__/schemas.test.ts +5 -32
- package/src/source-sync/schemas.ts +6 -15
- package/src/workflows/README.md +7 -5
- package/src/workflows/__tests__/affordances-of-outcome.test.ts +2 -5
- package/src/workflows/__tests__/deferred-route.test.ts +2 -3
- package/src/workflows/__tests__/outcome.test.ts +2 -3
- package/src/workflows/affordances-of-outcome.ts +2 -3
- package/src/workflows/deferred-route.ts +7 -3
- package/src/workflows/index.ts +18 -12
- package/src/workflows/outcome-reasons.ts +248 -0
- package/src/workflows/outcome.ts +16 -227
package/src/workflows/outcome.ts
CHANGED
|
@@ -16,8 +16,9 @@
|
|
|
16
16
|
* record: a renderer that switches on `reason` is exhaustive, and a new fact is
|
|
17
17
|
* a schema change, not a new spelling.
|
|
18
18
|
* - KIND IS A FUNCTION OF REASON. `kind` is carried for consumers that only care
|
|
19
|
-
* about the shape of the ending, but it is fixed by the per-type table
|
|
20
|
-
* (`*_OUTCOME_KIND_OF_REASON`) and the schema
|
|
19
|
+
* about the shape of the ending, but it is fixed by the per-type table
|
|
20
|
+
* (`*_OUTCOME_KIND_OF_REASON` in `./outcome-reasons.ts`) and the schema
|
|
21
|
+
* refuses any other pairing.
|
|
21
22
|
* - DISPOSITION IS EXPLICIT. `review` names the input request a person decides
|
|
22
23
|
* on; `narrate` means the ending is told, not reviewed. `produced` does not
|
|
23
24
|
* imply a review surface, and only a `produced` or `partial` outcome may carry
|
|
@@ -44,26 +45,19 @@ import {
|
|
|
44
45
|
type OfferedAffordance,
|
|
45
46
|
} from "../affordances/affordance";
|
|
46
47
|
import { INPUT_REQUEST_TYPES } from "../input-requests/types";
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
/** The run went silent and the reconciler closed it. */
|
|
61
|
-
"abandoned",
|
|
62
|
-
/** A terminal transition the classifier did not recognize. */
|
|
63
|
-
"unknown",
|
|
64
|
-
] as const;
|
|
65
|
-
|
|
66
|
-
export type WorkflowOutcomeKind = (typeof WORKFLOW_OUTCOME_KINDS)[number];
|
|
48
|
+
import {
|
|
49
|
+
DISCOVER_AFFORDANCES_OF_REASON,
|
|
50
|
+
DISCOVER_OUTCOME_KIND_OF_REASON,
|
|
51
|
+
DiscoverOutcomeFactsSchema,
|
|
52
|
+
ORG_STRUCTURE_AFFORDANCES_OF_REASON,
|
|
53
|
+
ORG_STRUCTURE_OUTCOME_KIND_OF_REASON,
|
|
54
|
+
OrgStructureOutcomeFactsSchema,
|
|
55
|
+
SYNTHESIZE_AFFORDANCES_OF_REASON,
|
|
56
|
+
SYNTHESIZE_OUTCOME_KIND_OF_REASON,
|
|
57
|
+
SynthesizeOutcomeFactsSchema,
|
|
58
|
+
WORKFLOW_OUTCOME_KINDS,
|
|
59
|
+
type WorkflowOutcomeKind,
|
|
60
|
+
} from "./outcome-reasons";
|
|
67
61
|
|
|
68
62
|
const KindSchema = z.enum(WORKFLOW_OUTCOME_KINDS);
|
|
69
63
|
|
|
@@ -85,211 +79,6 @@ export type WorkflowOutcomeDisposition = z.infer<
|
|
|
85
79
|
|
|
86
80
|
const Count = z.number().int().nonnegative();
|
|
87
81
|
|
|
88
|
-
// The affordances an ending may offer, named once for the tables below.
|
|
89
|
-
const FIND_FILES = { id: "sourceSync.findFiles" } as const;
|
|
90
|
-
const CONNECT_GOOGLE_DRIVE = { id: "integrations.connectGoogleDrive" } as const;
|
|
91
|
-
const ENABLE_SOURCE_SYNC = { id: "sourceSync.enable" } as const;
|
|
92
|
-
const OPEN_BILLING = { id: "billing.open" } as const;
|
|
93
|
-
const REANALYZE_STRUCTURE = { id: "orgStructure.reanalyze" } as const;
|
|
94
|
-
const RESYNC_DIRECTORY = { id: "hris.resyncDirectory" } as const;
|
|
95
|
-
|
|
96
|
-
// ---------------------------------------------------------------------------
|
|
97
|
-
// source-sync/discover
|
|
98
|
-
// ---------------------------------------------------------------------------
|
|
99
|
-
|
|
100
|
-
/** Why a Drive discovery run ended the way it did. */
|
|
101
|
-
export const DISCOVER_OUTCOME_KIND_OF_REASON = {
|
|
102
|
-
candidates_found: "produced",
|
|
103
|
-
nothing_found: "empty",
|
|
104
|
-
nothing_relevant: "empty",
|
|
105
|
-
budget_exhausted: "partial",
|
|
106
|
-
file_ceiling: "partial",
|
|
107
|
-
stopped_by_user: "stopped",
|
|
108
|
-
plan_coverage_refused: "failed",
|
|
109
|
-
billing_refused: "failed",
|
|
110
|
-
drive_auth: "failed",
|
|
111
|
-
drive_unavailable: "failed",
|
|
112
|
-
no_connection: "failed",
|
|
113
|
-
source_sync_off: "failed",
|
|
114
|
-
internal_error: "failed",
|
|
115
|
-
abandoned: "abandoned",
|
|
116
|
-
unrecognized_terminal_state: "unknown",
|
|
117
|
-
} as const satisfies Record<string, WorkflowOutcomeKind>;
|
|
118
|
-
|
|
119
|
-
export type DiscoverOutcomeReason =
|
|
120
|
-
keyof typeof DISCOVER_OUTCOME_KIND_OF_REASON;
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* What each discovery ending offers (control ADR affordance-system). TOTAL: an
|
|
124
|
-
* empty list is a decision that no grounded action changes that ending — a
|
|
125
|
-
* re-run of the same search is not "broadening" it, and nothing raises a budget.
|
|
126
|
-
*/
|
|
127
|
-
export const DISCOVER_AFFORDANCES_OF_REASON = {
|
|
128
|
-
candidates_found: [],
|
|
129
|
-
nothing_found: [],
|
|
130
|
-
nothing_relevant: [],
|
|
131
|
-
budget_exhausted: [],
|
|
132
|
-
file_ceiling: [],
|
|
133
|
-
stopped_by_user: [],
|
|
134
|
-
plan_coverage_refused: [],
|
|
135
|
-
billing_refused: [OPEN_BILLING],
|
|
136
|
-
drive_auth: [CONNECT_GOOGLE_DRIVE],
|
|
137
|
-
drive_unavailable: [FIND_FILES],
|
|
138
|
-
no_connection: [CONNECT_GOOGLE_DRIVE],
|
|
139
|
-
source_sync_off: [ENABLE_SOURCE_SYNC],
|
|
140
|
-
internal_error: [FIND_FILES],
|
|
141
|
-
abandoned: [FIND_FILES],
|
|
142
|
-
unrecognized_terminal_state: [],
|
|
143
|
-
} as const satisfies Record<
|
|
144
|
-
DiscoverOutcomeReason,
|
|
145
|
-
readonly OfferedAffordance[]
|
|
146
|
-
>;
|
|
147
|
-
|
|
148
|
-
/** The counts a discovery run reports at its end. */
|
|
149
|
-
export const DiscoverOutcomeFactsSchema = z
|
|
150
|
-
.object({
|
|
151
|
-
probesTotal: Count,
|
|
152
|
-
probesDone: Count,
|
|
153
|
-
filesSeen: Count,
|
|
154
|
-
filesShown: Count,
|
|
155
|
-
filesHidden: Count,
|
|
156
|
-
filesDropped: Count,
|
|
157
|
-
coveragePercent: z.number().min(0).max(100).nullable(),
|
|
158
|
-
})
|
|
159
|
-
.strict();
|
|
160
|
-
|
|
161
|
-
export type DiscoverOutcomeFacts = z.infer<typeof DiscoverOutcomeFactsSchema>;
|
|
162
|
-
|
|
163
|
-
// ---------------------------------------------------------------------------
|
|
164
|
-
// source-sync/synthesize
|
|
165
|
-
// ---------------------------------------------------------------------------
|
|
166
|
-
|
|
167
|
-
/** Why a synthesis (landing then drafting) run ended the way it did. */
|
|
168
|
-
export const SYNTHESIZE_OUTCOME_KIND_OF_REASON = {
|
|
169
|
-
updates_ready: "produced",
|
|
170
|
-
updates_applied: "produced",
|
|
171
|
-
stopped_by_user: "stopped",
|
|
172
|
-
paused_billing: "failed",
|
|
173
|
-
synthesis_incomplete: "failed",
|
|
174
|
-
approval_mismatch: "failed",
|
|
175
|
-
landing_refused: "failed",
|
|
176
|
-
standing_order_refused: "failed",
|
|
177
|
-
no_connection: "failed",
|
|
178
|
-
source_sync_off: "failed",
|
|
179
|
-
internal_error: "failed",
|
|
180
|
-
abandoned: "abandoned",
|
|
181
|
-
unrecognized_terminal_state: "unknown",
|
|
182
|
-
} as const satisfies Record<string, WorkflowOutcomeKind>;
|
|
183
|
-
|
|
184
|
-
export type SynthesizeOutcomeReason =
|
|
185
|
-
keyof typeof SYNTHESIZE_OUTCOME_KIND_OF_REASON;
|
|
186
|
-
|
|
187
|
-
/** What each synthesis ending offers. TOTAL; an empty list is explicit. */
|
|
188
|
-
export const SYNTHESIZE_AFFORDANCES_OF_REASON = {
|
|
189
|
-
updates_ready: [],
|
|
190
|
-
updates_applied: [],
|
|
191
|
-
stopped_by_user: [],
|
|
192
|
-
paused_billing: [OPEN_BILLING],
|
|
193
|
-
synthesis_incomplete: [],
|
|
194
|
-
approval_mismatch: [],
|
|
195
|
-
landing_refused: [],
|
|
196
|
-
standing_order_refused: [],
|
|
197
|
-
no_connection: [CONNECT_GOOGLE_DRIVE],
|
|
198
|
-
source_sync_off: [ENABLE_SOURCE_SYNC],
|
|
199
|
-
internal_error: [],
|
|
200
|
-
abandoned: [],
|
|
201
|
-
unrecognized_terminal_state: [],
|
|
202
|
-
} as const satisfies Record<
|
|
203
|
-
SynthesizeOutcomeReason,
|
|
204
|
-
readonly OfferedAffordance[]
|
|
205
|
-
>;
|
|
206
|
-
|
|
207
|
-
/** The counts a synthesis run reports at its end. */
|
|
208
|
-
export const SynthesizeOutcomeFactsSchema = z
|
|
209
|
-
.object({
|
|
210
|
-
/** Approved scopes the run read. */
|
|
211
|
-
scopeCount: Count,
|
|
212
|
-
/** Authority or size violations that left the batch incomplete. */
|
|
213
|
-
violationCount: Count,
|
|
214
|
-
})
|
|
215
|
-
.strict();
|
|
216
|
-
|
|
217
|
-
export type SynthesizeOutcomeFacts = z.infer<
|
|
218
|
-
typeof SynthesizeOutcomeFactsSchema
|
|
219
|
-
>;
|
|
220
|
-
|
|
221
|
-
// ---------------------------------------------------------------------------
|
|
222
|
-
// org-structure/hris-connect and org-structure/reanalyze
|
|
223
|
-
// ---------------------------------------------------------------------------
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* Why an org-structure analysis ended the way it did. Shared by both
|
|
227
|
-
* org-structure workflow types: they run the same analysis. The directory-only
|
|
228
|
-
* endings (`directory_synced`, `analysis_already_running`, `sync_failed`) occur
|
|
229
|
-
* only on `org-structure/hris-connect`, which syncs the directory first.
|
|
230
|
-
*/
|
|
231
|
-
export const ORG_STRUCTURE_OUTCOME_KIND_OF_REASON = {
|
|
232
|
-
proposal_ready: "produced",
|
|
233
|
-
directory_synced: "produced",
|
|
234
|
-
analysis_already_running: "produced",
|
|
235
|
-
proposal_blocked: "failed",
|
|
236
|
-
no_sync_run: "empty",
|
|
237
|
-
no_persons: "empty",
|
|
238
|
-
reporting_not_keyed: "empty",
|
|
239
|
-
stopped_by_user: "stopped",
|
|
240
|
-
sync_failed: "failed",
|
|
241
|
-
snapshot_too_large: "failed",
|
|
242
|
-
model_failed: "failed",
|
|
243
|
-
run_too_large: "failed",
|
|
244
|
-
placement_failed: "failed",
|
|
245
|
-
internal_error: "failed",
|
|
246
|
-
abandoned: "abandoned",
|
|
247
|
-
unrecognized_terminal_state: "unknown",
|
|
248
|
-
} as const satisfies Record<string, WorkflowOutcomeKind>;
|
|
249
|
-
|
|
250
|
-
export type OrgStructureOutcomeReason =
|
|
251
|
-
keyof typeof ORG_STRUCTURE_OUTCOME_KIND_OF_REASON;
|
|
252
|
-
|
|
253
|
-
/**
|
|
254
|
-
* What each org-structure ending offers; shared by both org-structure workflow
|
|
255
|
-
* types, like the kind table. TOTAL; an empty list is explicit.
|
|
256
|
-
*/
|
|
257
|
-
export const ORG_STRUCTURE_AFFORDANCES_OF_REASON = {
|
|
258
|
-
proposal_ready: [],
|
|
259
|
-
directory_synced: [],
|
|
260
|
-
analysis_already_running: [],
|
|
261
|
-
proposal_blocked: [],
|
|
262
|
-
no_sync_run: [RESYNC_DIRECTORY],
|
|
263
|
-
no_persons: [],
|
|
264
|
-
reporting_not_keyed: [],
|
|
265
|
-
stopped_by_user: [],
|
|
266
|
-
sync_failed: [RESYNC_DIRECTORY],
|
|
267
|
-
snapshot_too_large: [],
|
|
268
|
-
model_failed: [REANALYZE_STRUCTURE],
|
|
269
|
-
run_too_large: [],
|
|
270
|
-
placement_failed: [REANALYZE_STRUCTURE],
|
|
271
|
-
internal_error: [REANALYZE_STRUCTURE],
|
|
272
|
-
abandoned: [REANALYZE_STRUCTURE],
|
|
273
|
-
unrecognized_terminal_state: [],
|
|
274
|
-
} as const satisfies Record<
|
|
275
|
-
OrgStructureOutcomeReason,
|
|
276
|
-
readonly OfferedAffordance[]
|
|
277
|
-
>;
|
|
278
|
-
|
|
279
|
-
/** The counts a finished org-structure proposal carries. */
|
|
280
|
-
export const OrgStructureOutcomeFactsSchema = z
|
|
281
|
-
.object({
|
|
282
|
-
departmentCount: Count,
|
|
283
|
-
teamCount: Count,
|
|
284
|
-
placedCount: Count,
|
|
285
|
-
reviewItemCount: Count,
|
|
286
|
-
})
|
|
287
|
-
.strict();
|
|
288
|
-
|
|
289
|
-
export type OrgStructureOutcomeFacts = z.infer<
|
|
290
|
-
typeof OrgStructureOutcomeFactsSchema
|
|
291
|
-
>;
|
|
292
|
-
|
|
293
82
|
// ---------------------------------------------------------------------------
|
|
294
83
|
// The union
|
|
295
84
|
// ---------------------------------------------------------------------------
|