@company-semantics/contracts 88.2.0 → 89.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 +1 -1
- package/src/api/generated-spec-hash.ts +2 -2
- package/src/api/generated.ts +337 -2
- package/src/generated/openapi-routes.ts +4 -0
- package/src/source-sync/README.md +44 -2
- package/src/source-sync/__tests__/barrel.test.ts +11 -1
- package/src/source-sync/__tests__/schemas.test.ts +141 -2
- package/src/source-sync/__tests__/scope-projection.test.ts +1 -1
- package/src/source-sync/__tests__/vocabulary.test.ts +73 -1
- package/src/source-sync/candidate-item.ts +155 -0
- package/src/source-sync/candidate-totals.ts +2 -4
- package/src/source-sync/index.ts +13 -4
- package/src/source-sync/relevance.ts +38 -3
- package/src/source-sync/schemas.ts +5 -127
- package/src/source-sync/vocabulary.ts +45 -0
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The Source Sync discovery and candidate-set wire schemas.
|
|
3
3
|
*
|
|
4
|
-
* A candidate item is ONE source proposed for ONE target
|
|
5
|
-
* treatment and landing are source x target
|
|
4
|
+
* A candidate item (./candidate-item) is ONE source proposed for ONE target
|
|
5
|
+
* document, because treatment and landing are source x target
|
|
6
|
+
* (INV-SOURCESYNC-LANDING-PER-TARGET).
|
|
6
7
|
* The wire carries facts ABOUT a source and a COUNT of people it is shared with,
|
|
7
8
|
* never its content and never their addresses: the external provider remains the
|
|
8
9
|
* ACL authority for the source itself.
|
|
@@ -20,28 +21,14 @@ import { z } from "zod";
|
|
|
20
21
|
import { DecisionQuestionPresentationSchema } from "../decisions/presentation";
|
|
21
22
|
import { IsoDateTime } from "../api/primitives";
|
|
22
23
|
import {
|
|
23
|
-
AUDIENCE_FITS,
|
|
24
|
-
SHARING_BREADTHS,
|
|
25
24
|
SOURCE_CLASSES,
|
|
26
|
-
SOURCE_SENSITIVITY_CLASSES,
|
|
27
25
|
SOURCE_SYNC_DOC_DISPOSITIONS,
|
|
28
26
|
SOURCE_SYNC_DOC_RISKS,
|
|
29
27
|
SOURCE_SYNC_SCOPE_APPROVAL_STATES,
|
|
30
28
|
SOURCE_SYNC_SCOPE_APPROVER_KINDS,
|
|
31
|
-
SOURCE_USES,
|
|
32
29
|
} from "./vocabulary";
|
|
33
|
-
import {
|
|
34
|
-
|
|
35
|
-
CandidateAttentionSchema,
|
|
36
|
-
CandidateDiscoverySummarySchema,
|
|
37
|
-
CLASSIFICATION_STATES,
|
|
38
|
-
PERSON_HOLD_REASONS,
|
|
39
|
-
refineCandidateRelevance,
|
|
40
|
-
RelevanceReasonSchema,
|
|
41
|
-
SELECTION_SOURCES,
|
|
42
|
-
SOURCE_RELEVANCE_TIERS,
|
|
43
|
-
TARGET_AUDIENCES,
|
|
44
|
-
} from "./relevance";
|
|
30
|
+
import { CandidateDiscoverySummarySchema } from "./relevance";
|
|
31
|
+
import { SourceSyncCandidateItemSchema } from "./candidate-item";
|
|
45
32
|
|
|
46
33
|
/** Integer micro-USD as a string — the billing domain's money convention on the wire. */
|
|
47
34
|
const MicroUsd = z.string().regex(/^[0-9]+$/);
|
|
@@ -88,88 +75,6 @@ export const SourceSyncDiscoveryRunResponseSchema = z.object({
|
|
|
88
75
|
workflowType: z.literal("source-sync/discover"),
|
|
89
76
|
});
|
|
90
77
|
|
|
91
|
-
/** ONE source proposed for ONE target document. */
|
|
92
|
-
export const SourceSyncCandidateItemSchema = z
|
|
93
|
-
.object({
|
|
94
|
-
itemId: z.string().uuid(),
|
|
95
|
-
sourceId: z.string().uuid(),
|
|
96
|
-
/**
|
|
97
|
-
* Display facts about the source. Never its content. When `withheld`, `name` is
|
|
98
|
-
* product copy naming only the source's class and period.
|
|
99
|
-
*/
|
|
100
|
-
name: z.string().min(1).max(500),
|
|
101
|
-
mimeType: z.string().min(1).max(255),
|
|
102
|
-
/** Opens the source IN THE PROVIDER, which remains the ACL authority for it. */
|
|
103
|
-
webViewLink: z.string().url().nullable(),
|
|
104
|
-
ownerLabel: z.string().max(255).nullable(),
|
|
105
|
-
modifiedTime: IsoDateTime.nullable(),
|
|
106
|
-
/**
|
|
107
|
-
* True when the caller may not open this source: its identifying fields are
|
|
108
|
-
* withheld (`webViewLink`, `ownerLabel` and `sharedWithCount` are null, and
|
|
109
|
-
* `name` and `matchReason` are product copy). What the approver decides stays.
|
|
110
|
-
*/
|
|
111
|
-
withheld: z.boolean(),
|
|
112
|
-
/** 'company' or 'unit:<uuid>'. */
|
|
113
|
-
scopeKey: z.string().min(1).max(64),
|
|
114
|
-
targetDocId: z.string().uuid(),
|
|
115
|
-
targetDocTitle: z.string().min(1).max(255),
|
|
116
|
-
/** The funnel's verdict for the wire: `dropped` never reaches it. Hidden = behind the drawer, undecided. */
|
|
117
|
-
visibility: z.enum(SOURCE_RELEVANCE_TIERS).exclude(["dropped"]),
|
|
118
|
-
/** Separate from visibility: a shown line may still await classification (machineState pending_classification). */
|
|
119
|
-
classificationState: z.enum(CLASSIFICATION_STATES),
|
|
120
|
-
/** NULL until a classifier has run for this line. */
|
|
121
|
-
sourceClass: z.enum(SOURCE_CLASSES).nullable(),
|
|
122
|
-
periodLabel: z.string().max(64).nullable(),
|
|
123
|
-
seriesRole: z.enum(["current", "history"]).nullable(),
|
|
124
|
-
/** The FUSED relevance score (control ADR source-discovery-relevance-funnel), 0..1. */
|
|
125
|
-
relevance: z.number().min(0).max(1),
|
|
126
|
-
sensitivityClass: z.enum(SOURCE_SENSITIVITY_CLASSES),
|
|
127
|
-
sharingBreadth: z.enum(SHARING_BREADTHS),
|
|
128
|
-
/** A COUNT of people the provider shares it with, when observed. Never addresses. */
|
|
129
|
-
sharedWithCount: z.number().int().min(0).nullable(),
|
|
130
|
-
/**
|
|
131
|
-
* Whether attaching under THIS target would show the source to more people than the provider does.
|
|
132
|
-
* A REQUIRED key with a NULLABLE value. NULL = not computed yet: discovery writes it null and the
|
|
133
|
-
* server computes it per source x target when it builds the draft set item. Every consumer reads
|
|
134
|
-
* null as UNRESOLVED (fail closed) — never as 'fits'.
|
|
135
|
-
*/
|
|
136
|
-
audienceFit: z.enum(AUDIENCE_FITS).nullable(),
|
|
137
|
-
/** Machine state: the sensitivity default. NULL until classified — never `excluded` as a stand-in. */
|
|
138
|
-
recommendedUse: z.enum(SOURCE_USES).nullable(),
|
|
139
|
-
/** The COMMITTED treatment: null until a person (or an accepted approval default) commits one. */
|
|
140
|
-
use: z.enum(SOURCE_USES).nullable(),
|
|
141
|
-
/** Provenance of `use`; null exactly when `use` is null (INV-SOURCESYNC-RECOMMENDATION-IS-NOT-COMMITMENT). */
|
|
142
|
-
selectionSource: z.enum(SELECTION_SOURCES).nullable(),
|
|
143
|
-
/** Field-level write barriers a person placed on this line (INV-SOURCESYNC-HOLDS-ARE-FIELD-BARRIERS). */
|
|
144
|
-
personHoldReasons: z.array(z.enum(PERSON_HOLD_REASONS)).max(4),
|
|
145
|
-
/** The line's machine lifecycle (INV-SOURCESYNC-SET-IS-RECONCILED). */
|
|
146
|
-
machineState: z.enum(CANDIDATE_MACHINE_STATES),
|
|
147
|
-
/** Structured reasons for `relevance`; `matchReason` is rendered from these by the server. */
|
|
148
|
-
relevanceReasons: z.array(RelevanceReasonSchema).max(8),
|
|
149
|
-
/** The audience Attach would disclose to. NULL = unknown — reads as MAY WIDEN (INV-SOURCESYNC-ATTACH-SHOWS-ITS-AUDIENCE). */
|
|
150
|
-
targetAudience: z.enum(TARGET_AUDIENCES).nullable(),
|
|
151
|
-
/** Which lane earned each model tier's attention (INV-SOURCESYNC-EXPLORATION-RESERVED). */
|
|
152
|
-
attention: CandidateAttentionSchema,
|
|
153
|
-
/**
|
|
154
|
-
* Whether this line is in the set that approval would land — the SERVER's
|
|
155
|
-
* answer, never derived from `use`. A decoy, a series' history or a line a
|
|
156
|
-
* person left out is false while its `use` is still null.
|
|
157
|
-
*/
|
|
158
|
-
included: z.boolean(),
|
|
159
|
-
/** True while a `widens` item — or one whose fit is not computed yet — has no person-chosen use: approval is refused until none remain. */
|
|
160
|
-
treatmentUnresolved: z.boolean(),
|
|
161
|
-
/**
|
|
162
|
-
* Product-owned copy saying why this file was proposed, rendered by the server from
|
|
163
|
-
* `relevanceReasons`. Never model-authored prose. Deprecated: removed next release.
|
|
164
|
-
*/
|
|
165
|
-
matchReason: z.string().min(1).max(500),
|
|
166
|
-
/** Non-null when the source could not be read (a scanned PDF, an unsupported kind). */
|
|
167
|
-
unreadableReason: z
|
|
168
|
-
.enum(["unsupported_type", "needs_ocr", "unsupported_kind"])
|
|
169
|
-
.nullable(),
|
|
170
|
-
})
|
|
171
|
-
.superRefine(refineCandidateRelevance);
|
|
172
|
-
|
|
173
78
|
/** Distinct-file totals over every line of a candidate set the caller may see. */
|
|
174
79
|
export const SourceSyncCandidateTotalsSchema = z.object({
|
|
175
80
|
/** Files in the review: at least one line, included or left out. */
|
|
@@ -216,27 +121,6 @@ export const SourceSyncCandidateSetResponseSchema = z.object({
|
|
|
216
121
|
discovery: z.nullable(CandidateDiscoverySummarySchema),
|
|
217
122
|
});
|
|
218
123
|
|
|
219
|
-
/**
|
|
220
|
-
* One edit to one candidate item: a PATCH names EXACTLY ONE thing that changes, so bringing
|
|
221
|
-
* a line into review never also commits a treatment.
|
|
222
|
-
* The SERVER bumps the set's revision on every accepted edit; the client never sends one here.
|
|
223
|
-
*/
|
|
224
|
-
export const SourceSyncCandidateItemPatchSchema = z
|
|
225
|
-
.object({
|
|
226
|
-
/** Bring into review: hidden → shown. Changes VISIBILITY ONLY (INV-SOURCESYNC-RECOMMENDATION-IS-NOT-COMMITMENT). */
|
|
227
|
-
visibility: z.literal("shown").optional(),
|
|
228
|
-
/** Attach, direction only, or leave out. Choosing one on a `widens` item RESOLVES its treatment. */
|
|
229
|
-
use: z.enum(SOURCE_USES).optional(),
|
|
230
|
-
/** Correct the class the classifier chose. */
|
|
231
|
-
sourceClass: z.enum(SOURCE_CLASSES).optional(),
|
|
232
|
-
/** Re-route to another target document. The server re-computes audienceFit for the new target. */
|
|
233
|
-
targetDocId: z.string().uuid().optional(),
|
|
234
|
-
})
|
|
235
|
-
.strict()
|
|
236
|
-
.refine((patch) => Object.keys(patch).length === 1, {
|
|
237
|
-
message: "a patch changes exactly one thing",
|
|
238
|
-
});
|
|
239
|
-
|
|
240
124
|
/** "Add one I missed": a file the person picked in the provider's own search. */
|
|
241
125
|
export const SourceSyncAddCandidateRequestSchema = z
|
|
242
126
|
.object({
|
|
@@ -440,18 +324,12 @@ export const SourceSyncCurrentSynthesisResponseSchema = z.object({
|
|
|
440
324
|
export type SourceSyncDiscoveryRunResponse = z.infer<
|
|
441
325
|
typeof SourceSyncDiscoveryRunResponseSchema
|
|
442
326
|
>;
|
|
443
|
-
export type SourceSyncCandidateItem = z.infer<
|
|
444
|
-
typeof SourceSyncCandidateItemSchema
|
|
445
|
-
>;
|
|
446
327
|
export type SourceSyncCandidateSetResponse = z.infer<
|
|
447
328
|
typeof SourceSyncCandidateSetResponseSchema
|
|
448
329
|
>;
|
|
449
330
|
export type SourceSyncCandidateTotals = z.infer<
|
|
450
331
|
typeof SourceSyncCandidateTotalsSchema
|
|
451
332
|
>;
|
|
452
|
-
export type SourceSyncCandidateItemPatch = z.infer<
|
|
453
|
-
typeof SourceSyncCandidateItemPatchSchema
|
|
454
|
-
>;
|
|
455
333
|
export type SourceSyncAddCandidateRequest = z.infer<
|
|
456
334
|
typeof SourceSyncAddCandidateRequestSchema
|
|
457
335
|
>;
|
|
@@ -110,3 +110,48 @@ export const SOURCE_SYNC_SCOPE_APPROVER_KINDS = [
|
|
|
110
110
|
] as const;
|
|
111
111
|
export type SourceSyncScopeApproverKind =
|
|
112
112
|
(typeof SOURCE_SYNC_SCOPE_APPROVER_KINDS)[number];
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* What a source IS — a STRUCTURAL name the model observes, never a relevance verdict
|
|
116
|
+
* (control ADR source-discovery-observation-vs-policy). Product policy in the backend maps a
|
|
117
|
+
* resolved type to a family, a source class, a sensitivity and a relevance policy; none of
|
|
118
|
+
* that travels on the wire. A medium is not a meaning: `image_or_screenshot` is graded on
|
|
119
|
+
* content. `unknown` is a real answer (the model could not tell, or two reads disagreed).
|
|
120
|
+
* Five strings are shared with other sets on purpose: board_deck, board_minutes,
|
|
121
|
+
* investor_update, roadmap (SOURCE_CLASSES) and unknown (SHARING_BREADTHS) — same word,
|
|
122
|
+
* separate axis.
|
|
123
|
+
*/
|
|
124
|
+
export const DOCUMENT_TYPES = [
|
|
125
|
+
"board_deck",
|
|
126
|
+
"board_minutes",
|
|
127
|
+
"strategy_memo",
|
|
128
|
+
"planning_doc",
|
|
129
|
+
"okr_doc",
|
|
130
|
+
"roadmap",
|
|
131
|
+
"operating_review",
|
|
132
|
+
"all_hands_deck",
|
|
133
|
+
"offsite_notes",
|
|
134
|
+
"investor_update",
|
|
135
|
+
"pitch_deck",
|
|
136
|
+
"product_spec",
|
|
137
|
+
"research_analysis",
|
|
138
|
+
"general_meeting_notes",
|
|
139
|
+
"financial_plan",
|
|
140
|
+
"financial_actuals",
|
|
141
|
+
"equity_admin_record",
|
|
142
|
+
"corporate_formation_record",
|
|
143
|
+
"corporate_governance_record",
|
|
144
|
+
"government_filing",
|
|
145
|
+
"equity_agreement",
|
|
146
|
+
"commercial_agreement",
|
|
147
|
+
"employment_agreement",
|
|
148
|
+
"transaction_record",
|
|
149
|
+
"personal_document",
|
|
150
|
+
"social_event_material",
|
|
151
|
+
"coursework",
|
|
152
|
+
"empty_template",
|
|
153
|
+
"image_or_screenshot",
|
|
154
|
+
"unknown",
|
|
155
|
+
] as const;
|
|
156
|
+
export type DocumentType = (typeof DOCUMENT_TYPES)[number];
|
|
157
|
+
export type KnownDocumentType = Exclude<DocumentType, "unknown">;
|