@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@company-semantics/contracts",
3
- "version": "88.2.0",
3
+ "version": "89.0.0",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,3 +1,3 @@
1
1
  // AUTO-GENERATED — do not edit. Run pnpm generate:spec-hash to regenerate.
2
- export const SPEC_HASH = 'fa844a445bc5' as const;
3
- export const SPEC_HASH_FULL = 'fa844a445bc5f62afa70d732ba33c9ce0b90b89f0634fabb2d6342743c0efeee' as const;
2
+ export const SPEC_HASH = '280a694d540b' as const;
3
+ export const SPEC_HASH_FULL = '280a694d540b48ca0e4f5985e8529cc5a88f96efca70980012b011cc914cc08c' as const;
@@ -3834,6 +3834,80 @@ export interface paths {
3834
3834
  patch?: never;
3835
3835
  trace?: never;
3836
3836
  };
3837
+ "/api/factory/quality/changes": {
3838
+ parameters: {
3839
+ query?: never;
3840
+ header?: never;
3841
+ path?: never;
3842
+ cookie?: never;
3843
+ };
3844
+ get?: never;
3845
+ put?: never;
3846
+ /**
3847
+ * Report a pull request head and get the evaluation plan to run for it
3848
+ * @description Resolves the changed files to an impact set, records the change and plans its evaluation. Idempotent: the same head reported again answers the same plan. A change no impact rule matches answers { noImpact: true } and records nothing.
3849
+ */
3850
+ post: operations["createQualityChange"];
3851
+ delete?: never;
3852
+ options?: never;
3853
+ head?: never;
3854
+ patch?: never;
3855
+ trace?: never;
3856
+ };
3857
+ "/api/factory/quality/plans/{planId}": {
3858
+ parameters: {
3859
+ query?: never;
3860
+ header?: never;
3861
+ path?: never;
3862
+ cookie?: never;
3863
+ };
3864
+ /** Read an evaluation plan: suites, pinned manifests, samples, model profile, budget */
3865
+ get: operations["getQualityPlan"];
3866
+ put?: never;
3867
+ post?: never;
3868
+ delete?: never;
3869
+ options?: never;
3870
+ head?: never;
3871
+ patch?: never;
3872
+ trace?: never;
3873
+ };
3874
+ "/api/factory/quality/plans/{planId}/decision": {
3875
+ parameters: {
3876
+ query?: never;
3877
+ header?: never;
3878
+ path?: never;
3879
+ cookie?: never;
3880
+ };
3881
+ /** Read where a plan's evaluation stands and, once recorded, its decision */
3882
+ get: operations["getQualityPlanDecision"];
3883
+ put?: never;
3884
+ post?: never;
3885
+ delete?: never;
3886
+ options?: never;
3887
+ head?: never;
3888
+ patch?: never;
3889
+ trace?: never;
3890
+ };
3891
+ "/api/factory/quality/deployments": {
3892
+ parameters: {
3893
+ query?: never;
3894
+ header?: never;
3895
+ path?: never;
3896
+ cookie?: never;
3897
+ };
3898
+ get?: never;
3899
+ put?: never;
3900
+ /**
3901
+ * Report one phase of a deploy run so an applied backend deployment is verified
3902
+ * @description An applied phase that names a backend commit pins the release references, records the deployment as a change to verify, plans the verification and asks for its runs. Idempotent: the same deployment reported again answers the same change and plan. Any other report answers 202 { ignored: true } and records nothing. The deployment is never held for its verification.
3903
+ */
3904
+ post: operations["recordQualityDeployment"];
3905
+ delete?: never;
3906
+ options?: never;
3907
+ head?: never;
3908
+ patch?: never;
3909
+ trace?: never;
3910
+ };
3837
3911
  "/api/internal-admin/impersonate/start": {
3838
3912
  parameters: {
3839
3913
  query?: never;
@@ -8255,6 +8329,87 @@ export interface components {
8255
8329
  [key: string]: unknown;
8256
8330
  } | null;
8257
8331
  };
8332
+ CreateQualityChangeResponse: {
8333
+ /** Format: uuid */
8334
+ planId: string;
8335
+ suites: string[];
8336
+ samples: number;
8337
+ budgetUsd: number;
8338
+ modelProfile: {
8339
+ [key: string]: unknown;
8340
+ };
8341
+ } | {
8342
+ /** @constant */
8343
+ noImpact: true;
8344
+ };
8345
+ CreateQualityChangeRequest: {
8346
+ /** @constant */
8347
+ sourceKind: "pull_request";
8348
+ sourceRef: string;
8349
+ gitSha: string;
8350
+ changedFiles: string[];
8351
+ };
8352
+ QualityPlanResponse: {
8353
+ /** Format: uuid */
8354
+ planId: string;
8355
+ suites: string[];
8356
+ samples: number;
8357
+ budgetUsd: number;
8358
+ modelProfile: {
8359
+ [key: string]: unknown;
8360
+ };
8361
+ /** Format: uuid */
8362
+ changeId: string;
8363
+ /** @enum {string} */
8364
+ state: "active" | "superseded";
8365
+ supersededBy: string | null;
8366
+ manifests: {
8367
+ suite: string;
8368
+ manifestId: string;
8369
+ entries: {
8370
+ caseId: string;
8371
+ caseRevision: string;
8372
+ }[] | null;
8373
+ }[];
8374
+ };
8375
+ QualityPlanDecisionResponse: {
8376
+ /** @enum {string} */
8377
+ state: "queued" | "running" | "blocked" | "complete";
8378
+ /** @enum {string} */
8379
+ blockReason?: "budget_exhausted" | "grader_calibration_pending" | "required_run_pending" | "provider_unavailable" | "manifest_unavailable";
8380
+ decision?: {
8381
+ /** @enum {string} */
8382
+ outcome: "promote" | "reject" | "escalate";
8383
+ reasons: {
8384
+ /** @enum {string} */
8385
+ code: "critical_regression" | "invariant_regression" | "protected_case_failed" | "below_floor" | "bucket_budget_exceeded" | "insufficient_improvement" | "cost_regression" | "latency_regression" | "grader_ineligible" | "insufficient_samples" | "flaky_case" | "policy_ambiguous" | "all_gates_passed" | "human_override";
8386
+ detail?: string;
8387
+ }[];
8388
+ };
8389
+ /** Format: uuid */
8390
+ supersededBy?: string;
8391
+ };
8392
+ RecordQualityDeploymentResponse: {
8393
+ /** Format: uuid */
8394
+ changeId: string;
8395
+ /** Format: uuid */
8396
+ planId: string;
8397
+ releaseReferences: number;
8398
+ };
8399
+ QualityDeploymentIgnored: {
8400
+ /** @constant */
8401
+ ignored: true;
8402
+ };
8403
+ RecordQualityDeploymentRequest: {
8404
+ manifestId: string | null;
8405
+ phase: string;
8406
+ shas: {
8407
+ backend?: string;
8408
+ app?: string;
8409
+ edge?: string;
8410
+ } | null;
8411
+ surfaces: string[];
8412
+ };
8258
8413
  ImpersonationSessionResponse: {
8259
8414
  session: {
8260
8415
  impersonationSessionId: string;
@@ -8816,6 +8971,8 @@ export interface components {
8816
8971
  /** @enum {string} */
8817
8972
  classificationState: "unclassified" | "classified";
8818
8973
  sourceClass: ("board_deck" | "board_minutes" | "investor_update" | "financial_brief" | "budget_forecast" | "okr_plan" | "annual_plan" | "all_hands" | "unit_strategy" | "roadmap" | "qbr" | "other" | "decoy") | null;
8974
+ documentType: ("board_deck" | "board_minutes" | "strategy_memo" | "planning_doc" | "okr_doc" | "roadmap" | "operating_review" | "all_hands_deck" | "offsite_notes" | "investor_update" | "pitch_deck" | "product_spec" | "research_analysis" | "general_meeting_notes" | "financial_plan" | "financial_actuals" | "equity_admin_record" | "corporate_formation_record" | "corporate_governance_record" | "government_filing" | "equity_agreement" | "commercial_agreement" | "employment_agreement" | "transaction_record" | "personal_document" | "social_event_material" | "coursework" | "empty_template" | "image_or_screenshot" | "unknown") | null;
8975
+ documentTypeConfidence: number | null;
8819
8976
  periodLabel: string | null;
8820
8977
  seriesRole: ("current" | "history") | null;
8821
8978
  relevance: number;
@@ -8848,12 +9005,12 @@ export interface components {
8848
9005
  /** @constant */
8849
9006
  kind: "evaluation";
8850
9007
  /** @enum {string} */
8851
- code: "not_evaluated_t1" | "not_evaluated_t2" | "folder_unresolved" | "folder_truncated" | "explored_t1" | "explored_t2";
9008
+ code: "not_evaluated_t1" | "not_evaluated_t2" | "folder_unresolved" | "folder_truncated" | "explored_t1" | "explored_t2" | "peek_insufficient_evidence" | "type_disagreement" | "type_below_confidence" | "execution_failed_t1" | "execution_failed_t2";
8852
9009
  } | {
8853
9010
  /** @constant */
8854
9011
  kind: "model";
8855
9012
  /** @enum {string} */
8856
- code: "title_path_score" | "peek_confirms" | "peek_contradicts";
9013
+ code: "title_path_score" | "peek_confirms" | "peek_contradicts" | "type_policy" | "peek_strategy_evidence_present" | "peek_strategy_evidence_absent";
8857
9014
  score: number | null;
8858
9015
  })[];
8859
9016
  targetAudience: ("restricted" | "unit" | "org_wide") | null;
@@ -16451,6 +16608,184 @@ export interface operations {
16451
16608
  };
16452
16609
  };
16453
16610
  };
16611
+ createQualityChange: {
16612
+ parameters: {
16613
+ query?: never;
16614
+ header?: never;
16615
+ path?: never;
16616
+ cookie?: never;
16617
+ };
16618
+ requestBody: {
16619
+ content: {
16620
+ "application/json": components["schemas"]["CreateQualityChangeRequest"];
16621
+ };
16622
+ };
16623
+ responses: {
16624
+ /** @description The plan to run (planId, suites, samples, budgetUsd, modelProfile), or noImpact */
16625
+ 200: {
16626
+ headers: {
16627
+ [name: string]: unknown;
16628
+ };
16629
+ content: {
16630
+ "application/json": components["schemas"]["CreateQualityChangeResponse"];
16631
+ };
16632
+ };
16633
+ /** @description Payload invalid */
16634
+ 400: {
16635
+ headers: {
16636
+ [name: string]: unknown;
16637
+ };
16638
+ content?: never;
16639
+ };
16640
+ /** @description Missing or invalid Floor bearer token */
16641
+ 401: {
16642
+ headers: {
16643
+ [name: string]: unknown;
16644
+ };
16645
+ content?: never;
16646
+ };
16647
+ /** @description The change was replaced; its replacement is what is planned */
16648
+ 409: {
16649
+ headers: {
16650
+ [name: string]: unknown;
16651
+ };
16652
+ content?: never;
16653
+ };
16654
+ };
16655
+ };
16656
+ getQualityPlan: {
16657
+ parameters: {
16658
+ query?: never;
16659
+ header?: never;
16660
+ path: {
16661
+ planId: string;
16662
+ };
16663
+ cookie?: never;
16664
+ };
16665
+ requestBody?: never;
16666
+ responses: {
16667
+ /** @description The plan as a runner needs it */
16668
+ 200: {
16669
+ headers: {
16670
+ [name: string]: unknown;
16671
+ };
16672
+ content: {
16673
+ "application/json": components["schemas"]["QualityPlanResponse"];
16674
+ };
16675
+ };
16676
+ /** @description Payload invalid */
16677
+ 400: {
16678
+ headers: {
16679
+ [name: string]: unknown;
16680
+ };
16681
+ content?: never;
16682
+ };
16683
+ /** @description Missing or invalid Floor bearer token */
16684
+ 401: {
16685
+ headers: {
16686
+ [name: string]: unknown;
16687
+ };
16688
+ content?: never;
16689
+ };
16690
+ /** @description No such plan */
16691
+ 404: {
16692
+ headers: {
16693
+ [name: string]: unknown;
16694
+ };
16695
+ content?: never;
16696
+ };
16697
+ };
16698
+ };
16699
+ getQualityPlanDecision: {
16700
+ parameters: {
16701
+ query?: never;
16702
+ header?: never;
16703
+ path: {
16704
+ planId: string;
16705
+ };
16706
+ cookie?: never;
16707
+ };
16708
+ requestBody?: never;
16709
+ responses: {
16710
+ /** @description Evaluation state, block reason while blocked, and the decision once decided */
16711
+ 200: {
16712
+ headers: {
16713
+ [name: string]: unknown;
16714
+ };
16715
+ content: {
16716
+ "application/json": components["schemas"]["QualityPlanDecisionResponse"];
16717
+ };
16718
+ };
16719
+ /** @description Payload invalid */
16720
+ 400: {
16721
+ headers: {
16722
+ [name: string]: unknown;
16723
+ };
16724
+ content?: never;
16725
+ };
16726
+ /** @description Missing or invalid Floor bearer token */
16727
+ 401: {
16728
+ headers: {
16729
+ [name: string]: unknown;
16730
+ };
16731
+ content?: never;
16732
+ };
16733
+ /** @description No such plan */
16734
+ 404: {
16735
+ headers: {
16736
+ [name: string]: unknown;
16737
+ };
16738
+ content?: never;
16739
+ };
16740
+ };
16741
+ };
16742
+ recordQualityDeployment: {
16743
+ parameters: {
16744
+ query?: never;
16745
+ header?: never;
16746
+ path?: never;
16747
+ cookie?: never;
16748
+ };
16749
+ requestBody: {
16750
+ content: {
16751
+ "application/json": components["schemas"]["RecordQualityDeploymentRequest"];
16752
+ };
16753
+ };
16754
+ responses: {
16755
+ /** @description The change that verifies the deployment, its plan, and the release references pinned */
16756
+ 200: {
16757
+ headers: {
16758
+ [name: string]: unknown;
16759
+ };
16760
+ content: {
16761
+ "application/json": components["schemas"]["RecordQualityDeploymentResponse"];
16762
+ };
16763
+ };
16764
+ /** @description Not an applied backend deployment: nothing was recorded */
16765
+ 202: {
16766
+ headers: {
16767
+ [name: string]: unknown;
16768
+ };
16769
+ content: {
16770
+ "application/json": components["schemas"]["QualityDeploymentIgnored"];
16771
+ };
16772
+ };
16773
+ /** @description Payload invalid */
16774
+ 400: {
16775
+ headers: {
16776
+ [name: string]: unknown;
16777
+ };
16778
+ content?: never;
16779
+ };
16780
+ /** @description Missing or invalid Floor bearer token */
16781
+ 401: {
16782
+ headers: {
16783
+ [name: string]: unknown;
16784
+ };
16785
+ content?: never;
16786
+ };
16787
+ };
16788
+ };
16454
16789
  startImpersonation: {
16455
16790
  parameters: {
16456
16791
  query?: never;
@@ -93,6 +93,10 @@ export const openApiRoutes = {
93
93
  '/api/executions/{executionId}/undo': ['POST'],
94
94
  '/api/factory/floor': ['GET'],
95
95
  '/api/factory/kpis': ['GET'],
96
+ '/api/factory/quality/changes': ['POST'],
97
+ '/api/factory/quality/deployments': ['POST'],
98
+ '/api/factory/quality/plans/{planId}': ['GET'],
99
+ '/api/factory/quality/plans/{planId}/decision': ['GET'],
96
100
  '/api/factory/snapshot': ['GET'],
97
101
  '/api/ingestion/operations/{id}': ['GET'],
98
102
  '/api/internal-admin/impersonate/end': ['POST'],
@@ -134,7 +134,7 @@ Doctrine: control ADR `source-discovery-relevance-funnel`. Vocabulary: ADR
134
134
  `unclassified` (so `sourceClass` and `recommendedUse` are both null) or
135
135
  `classified` (both non-null). A shown line can still be
136
136
  `pending_classification` in its `machineState`.
137
- - **Reasons are a discriminated union.** `relevanceReasons` (≤ 8) is
137
+ - **Reasons are a discriminated union.** `relevanceReasons` (≤ 16) is
138
138
  `RelevanceReason`: `lexicon` (a product-owned `term` and a `count`),
139
139
  `signal` (a `value` or null), `evaluation` (a code only) or `model` (a
140
140
  `score` or null). Each kind has its own disjoint code set, and the app
@@ -155,6 +155,42 @@ Doctrine: control ADR `source-discovery-relevance-funnel`. Vocabulary: ADR
155
155
  `filesNotRediscovered` and `filesPendingClassification`, counted by
156
156
  `candidateTotalsOf` over distinct files.
157
157
 
158
+ ## Document type
159
+
160
+ Doctrine: control ADR `source-discovery-observation-vs-policy`. Vocabulary: ADR
161
+ `source-discovery-document-type-vocabulary`. The model NAMES what a source is;
162
+ product policy in the backend decides what that means.
163
+
164
+ - **Structural, never a verdict.** `DOCUMENT_TYPES` (in `vocabulary.ts`) says
165
+ what a file IS — `corporate_formation_record`, never `irrelevant_doc` —
166
+ never how relevant it is. A medium is not a meaning: `image_or_screenshot`
167
+ is graded on its content. `unknown` is a real answer (the model could not
168
+ tell, or two reads disagreed) and is always last.
169
+ - **The resolved type travels, nothing else.** The candidate item's
170
+ `documentType` and `documentTypeConfidence` (0..1) carry the RESOLVED type,
171
+ after the backend reconciles the T1 and T2 observations. Both are null on an
172
+ unclassified line and on every line of a run pinned before the typed path
173
+ (v1), where `sourceClass` alone is set. A known type always carries a
174
+ confidence; `unknown` and null never do. Per-tier types and per-layer scores
175
+ are backend evidence and stay off the wire.
176
+ - **Policy lives in the backend.** Families, relevance policy modes, ceilings,
177
+ confidence floors, strategy signals and peek verdicts are backend product
178
+ policy, never contracts vocabulary
179
+ (INV-SOURCESYNC-OBSERVATION-IS-SEPARATE-FROM-POLICY). Changing what a type
180
+ means is a backend change, not a release.
181
+ - **Same word, separate axis.** Five members are also words in other sets:
182
+ `board_deck`, `board_minutes`, `investor_update`, `roadmap`
183
+ (`SOURCE_CLASSES`) and `unknown` (`SHARING_BREADTHS`). `DOCUMENT_TYPES`
184
+ therefore sits outside the cross-set disjointness check, and its overlap is
185
+ pinned to exactly those five.
186
+ - **Typed-relevance reasons.** Model codes `type_policy` (the policy-applied
187
+ score of the resolved type) and `peek_strategy_evidence_present` /
188
+ `peek_strategy_evidence_absent`. Evaluation codes
189
+ `peek_insufficient_evidence`, `type_disagreement`, `type_below_confidence`
190
+ and `execution_failed_t1` / `execution_failed_t2`: a tier that did not run
191
+ is uncertainty, never irrelevance. `peek_confirms` / `peek_contradicts`
192
+ stay for v1-pinned rows.
193
+
158
194
  ## Public API
159
195
 
160
196
  - `SOURCE_CLASSES` / `SourceClass` — what kind of document a source is.
@@ -172,10 +208,14 @@ Doctrine: control ADR `source-discovery-relevance-funnel`. Vocabulary: ADR
172
208
  `pending`, `approved` or `rejected` (no verb writes `rejected` yet).
173
209
  - `SOURCE_SYNC_SCOPE_APPROVER_KINDS` / `SourceSyncScopeApproverKind` —
174
210
  `org_admin` or `unit_head`.
211
+ - `DOCUMENT_TYPES` / `DocumentType` / `KnownDocumentType` — what a source is,
212
+ structurally; `KnownDocumentType` excludes `unknown` (see Document type).
175
213
  - `SourceSyncDiscoveryRunResponseSchema` / `SourceSyncDiscoveryRunResponse` —
176
214
  the discovery run started, and the workflow narrating it.
177
215
  - `SourceSyncCandidateItemSchema` / `SourceSyncCandidateItem` — one source
178
- proposed for one target document, with the server's `included`.
216
+ proposed for one target document, with the server's `included` and the
217
+ resolved `documentType` / `documentTypeConfidence` (null when unclassified
218
+ or v1-pinned).
179
219
  - `SourceSyncCandidateSetResponseSchema` / `SourceSyncCandidateSetResponse` —
180
220
  the draft set under review: its revision, items, presented questions,
181
221
  distinct-file `totals` and cost estimate.
@@ -267,5 +307,7 @@ Doctrine: control ADR `source-discovery-relevance-funnel`. Vocabulary: ADR
267
307
 
268
308
  `rules.ts` imports only `zod`, `../api/primitives` and `./vocabulary`.
269
309
  `upkeep.ts` and `reach.ts` import only `zod` and `../api/primitives`.
310
+ `candidate-item.ts` imports only `zod`, `../api/primitives`, `./vocabulary`
311
+ and `./relevance`.
270
312
  `relevance.ts` imports only `zod`.
271
313
  `vocabulary.ts` itself has no imports.
@@ -18,6 +18,8 @@
18
18
  * standing orders and the Drive-reach shapes.
19
19
  * - Every runtime name `relevance.ts` declares is reachable from the root as
20
20
  * the same binding.
21
+ * - `DOCUMENT_TYPES` is reachable from the root as the same binding, and its
22
+ * two types are named by the barrel.
21
23
  * - `ACTION_ITEM_KINDS` at the root carries `sourceSync.approval_pending`.
22
24
  * - The root re-exports the domain barrel explicitly.
23
25
  *
@@ -67,18 +69,20 @@ import type {
67
69
  SourceSyncStandingOrder,
68
70
  SourceSyncStandingOrdersResponse,
69
71
  } from "../../index";
72
+ import * as candidateItem from "../candidate-item";
70
73
  import * as reach from "../reach";
71
74
  import * as relevance from "../relevance";
72
75
  import * as rules from "../rules";
73
76
  import * as schemas from "../schemas";
74
77
  import * as upkeep from "../upkeep";
78
+ import * as vocabulary from "../vocabulary";
75
79
 
76
80
  /** Runtime names Release C adds, keyed to the module that declares them. */
77
81
  const RELEASE_C_RUNTIME_NAMES: ReadonlyArray<
78
82
  readonly [name: string, module: Record<string, unknown>]
79
83
  > = [
80
84
  ["SOURCE_SYNC_RISK_REASONS", schemas],
81
- ["SourceSyncCandidateItemPatchSchema", schemas],
85
+ ["SourceSyncCandidateItemPatchSchema", candidateItem],
82
86
  ["SourceSyncAddCandidateRequestSchema", schemas],
83
87
  ["SourceSyncApproveRequestSchema", schemas],
84
88
  ["SourceSyncScopeApprovalSchema", schemas],
@@ -250,6 +254,12 @@ describe("source-sync Release C package surface", () => {
250
254
  }
251
255
  });
252
256
 
257
+ it("every document-type name is reachable from the root as the same binding", () => {
258
+ expect(rootBarrel.DOCUMENT_TYPES).toBe(vocabulary.DOCUMENT_TYPES);
259
+ expect([...barrelTypeExports]).toContain("DocumentType");
260
+ expect([...barrelTypeExports]).toContain("KnownDocumentType");
261
+ });
262
+
253
263
  it("exposes sourceSync.approval_pending in ACTION_ITEM_KINDS at the root", () => {
254
264
  expect(rootBarrel.ACTION_ITEM_KINDS).toContain(
255
265
  "sourceSync.approval_pending",