@gate-forge/core 0.1.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/LICENSE +202 -0
- package/dist/baselines/adoption.d.ts +76 -0
- package/dist/baselines/adoption.d.ts.map +1 -0
- package/dist/baselines/adoption.js +163 -0
- package/dist/baselines/adoption.js.map +1 -0
- package/dist/baselines/index.d.ts +102 -0
- package/dist/baselines/index.d.ts.map +1 -0
- package/dist/baselines/index.js +186 -0
- package/dist/baselines/index.js.map +1 -0
- package/dist/canonical-json.d.ts +51 -0
- package/dist/canonical-json.d.ts.map +1 -0
- package/dist/canonical-json.js +112 -0
- package/dist/canonical-json.js.map +1 -0
- package/dist/classifier/bind.d.ts +64 -0
- package/dist/classifier/bind.d.ts.map +1 -0
- package/dist/classifier/bind.js +188 -0
- package/dist/classifier/bind.js.map +1 -0
- package/dist/classifier/classify.d.ts +154 -0
- package/dist/classifier/classify.d.ts.map +1 -0
- package/dist/classifier/classify.js +1207 -0
- package/dist/classifier/classify.js.map +1 -0
- package/dist/classifier/glob.d.ts +48 -0
- package/dist/classifier/glob.d.ts.map +1 -0
- package/dist/classifier/glob.js +104 -0
- package/dist/classifier/glob.js.map +1 -0
- package/dist/classifier/index.d.ts +10 -0
- package/dist/classifier/index.d.ts.map +1 -0
- package/dist/classifier/index.js +21 -0
- package/dist/classifier/index.js.map +1 -0
- package/dist/classifier/schema.d.ts +150 -0
- package/dist/classifier/schema.d.ts.map +1 -0
- package/dist/classifier/schema.js +139 -0
- package/dist/classifier/schema.js.map +1 -0
- package/dist/config/index.d.ts +259 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +523 -0
- package/dist/config/index.js.map +1 -0
- package/dist/fingerprints.d.ts +56 -0
- package/dist/fingerprints.d.ts.map +1 -0
- package/dist/fingerprints.js +59 -0
- package/dist/fingerprints.js.map +1 -0
- package/dist/graph/build.d.ts +16 -0
- package/dist/graph/build.d.ts.map +1 -0
- package/dist/graph/build.js +423 -0
- package/dist/graph/build.js.map +1 -0
- package/dist/graph/index.d.ts +12 -0
- package/dist/graph/index.d.ts.map +1 -0
- package/dist/graph/index.js +10 -0
- package/dist/graph/index.js.map +1 -0
- package/dist/graph/schema.d.ts +448 -0
- package/dist/graph/schema.d.ts.map +1 -0
- package/dist/graph/schema.js +237 -0
- package/dist/graph/schema.js.map +1 -0
- package/dist/graph/symbols.d.ts +129 -0
- package/dist/graph/symbols.d.ts.map +1 -0
- package/dist/graph/symbols.js +177 -0
- package/dist/graph/symbols.js.map +1 -0
- package/dist/graph/util.d.ts +40 -0
- package/dist/graph/util.d.ts.map +1 -0
- package/dist/graph/util.js +41 -0
- package/dist/graph/util.js.map +1 -0
- package/dist/index.d.ts +683 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +563 -0
- package/dist/index.js.map +1 -0
- package/dist/mapping/resolve.d.ts +177 -0
- package/dist/mapping/resolve.d.ts.map +1 -0
- package/dist/mapping/resolve.js +523 -0
- package/dist/mapping/resolve.js.map +1 -0
- package/dist/policy/coverage.d.ts +79 -0
- package/dist/policy/coverage.d.ts.map +1 -0
- package/dist/policy/coverage.js +119 -0
- package/dist/policy/coverage.js.map +1 -0
- package/dist/policy/evaluate.d.ts +275 -0
- package/dist/policy/evaluate.d.ts.map +1 -0
- package/dist/policy/evaluate.js +382 -0
- package/dist/policy/evaluate.js.map +1 -0
- package/dist/policy/index.d.ts +15 -0
- package/dist/policy/index.d.ts.map +1 -0
- package/dist/policy/index.js +14 -0
- package/dist/policy/index.js.map +1 -0
- package/dist/policy/trusted.d.ts +59 -0
- package/dist/policy/trusted.d.ts.map +1 -0
- package/dist/policy/trusted.js +96 -0
- package/dist/policy/trusted.js.map +1 -0
- package/dist/provenance.d.ts +170 -0
- package/dist/provenance.d.ts.map +1 -0
- package/dist/provenance.js +306 -0
- package/dist/provenance.js.map +1 -0
- package/dist/receipt/index.d.ts +74 -0
- package/dist/receipt/index.d.ts.map +1 -0
- package/dist/receipt/index.js +154 -0
- package/dist/receipt/index.js.map +1 -0
- package/dist/report/index.d.ts +100 -0
- package/dist/report/index.d.ts.map +1 -0
- package/dist/report/index.js +355 -0
- package/dist/report/index.js.map +1 -0
- package/dist/schemas/adoption.d.ts +40 -0
- package/dist/schemas/adoption.d.ts.map +1 -0
- package/dist/schemas/adoption.js +87 -0
- package/dist/schemas/adoption.js.map +1 -0
- package/dist/schemas/baseline.d.ts +19 -0
- package/dist/schemas/baseline.d.ts.map +1 -0
- package/dist/schemas/baseline.js +45 -0
- package/dist/schemas/baseline.js.map +1 -0
- package/dist/schemas/claim.d.ts +32 -0
- package/dist/schemas/claim.d.ts.map +1 -0
- package/dist/schemas/claim.js +34 -0
- package/dist/schemas/claim.js.map +1 -0
- package/dist/schemas/classification-policy.d.ts +84 -0
- package/dist/schemas/classification-policy.d.ts.map +1 -0
- package/dist/schemas/classification-policy.js +130 -0
- package/dist/schemas/classification-policy.js.map +1 -0
- package/dist/schemas/classification-signal.d.ts +125 -0
- package/dist/schemas/classification-signal.d.ts.map +1 -0
- package/dist/schemas/classification-signal.js +126 -0
- package/dist/schemas/classification-signal.js.map +1 -0
- package/dist/schemas/classification.d.ts +120 -0
- package/dist/schemas/classification.d.ts.map +1 -0
- package/dist/schemas/classification.js +154 -0
- package/dist/schemas/classification.js.map +1 -0
- package/dist/schemas/common.d.ts +73 -0
- package/dist/schemas/common.d.ts.map +1 -0
- package/dist/schemas/common.js +60 -0
- package/dist/schemas/common.js.map +1 -0
- package/dist/schemas/coverage-policy.d.ts +89 -0
- package/dist/schemas/coverage-policy.d.ts.map +1 -0
- package/dist/schemas/coverage-policy.js +81 -0
- package/dist/schemas/coverage-policy.js.map +1 -0
- package/dist/schemas/evidence.d.ts +65 -0
- package/dist/schemas/evidence.d.ts.map +1 -0
- package/dist/schemas/evidence.js +64 -0
- package/dist/schemas/evidence.js.map +1 -0
- package/dist/schemas/execution-result.d.ts +214 -0
- package/dist/schemas/execution-result.d.ts.map +1 -0
- package/dist/schemas/execution-result.js +240 -0
- package/dist/schemas/execution-result.js.map +1 -0
- package/dist/schemas/gate-receipt.d.ts +86 -0
- package/dist/schemas/gate-receipt.d.ts.map +1 -0
- package/dist/schemas/gate-receipt.js +193 -0
- package/dist/schemas/gate-receipt.js.map +1 -0
- package/dist/schemas/index.d.ts +22 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/index.js +22 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/schemas/obligation.d.ts +37 -0
- package/dist/schemas/obligation.d.ts.map +1 -0
- package/dist/schemas/obligation.js +46 -0
- package/dist/schemas/obligation.js.map +1 -0
- package/dist/schemas/plugin.d.ts +19 -0
- package/dist/schemas/plugin.d.ts.map +1 -0
- package/dist/schemas/plugin.js +20 -0
- package/dist/schemas/plugin.js.map +1 -0
- package/dist/schemas/policy.d.ts +73 -0
- package/dist/schemas/policy.d.ts.map +1 -0
- package/dist/schemas/policy.js +46 -0
- package/dist/schemas/policy.js.map +1 -0
- package/dist/schemas/resource.d.ts +26 -0
- package/dist/schemas/resource.d.ts.map +1 -0
- package/dist/schemas/resource.js +29 -0
- package/dist/schemas/resource.js.map +1 -0
- package/dist/schemas/run-manifest.d.ts +72 -0
- package/dist/schemas/run-manifest.d.ts.map +1 -0
- package/dist/schemas/run-manifest.js +125 -0
- package/dist/schemas/run-manifest.js.map +1 -0
- package/dist/schemas/runner-adapter.d.ts +169 -0
- package/dist/schemas/runner-adapter.d.ts.map +1 -0
- package/dist/schemas/runner-adapter.js +2 -0
- package/dist/schemas/runner-adapter.js.map +1 -0
- package/dist/schemas/test-catalog.d.ts +472 -0
- package/dist/schemas/test-catalog.d.ts.map +1 -0
- package/dist/schemas/test-catalog.js +311 -0
- package/dist/schemas/test-catalog.js.map +1 -0
- package/dist/schemas/test-map.d.ts +99 -0
- package/dist/schemas/test-map.d.ts.map +1 -0
- package/dist/schemas/test-map.js +103 -0
- package/dist/schemas/test-map.js.map +1 -0
- package/dist/schemas/verdict.d.ts +73 -0
- package/dist/schemas/verdict.d.ts.map +1 -0
- package/dist/schemas/verdict.js +92 -0
- package/dist/schemas/verdict.js.map +1 -0
- package/dist/schemas/waiver.d.ts +36 -0
- package/dist/schemas/waiver.d.ts.map +1 -0
- package/dist/schemas/waiver.js +42 -0
- package/dist/schemas/waiver.js.map +1 -0
- package/dist/supervision/index.d.ts +170 -0
- package/dist/supervision/index.d.ts.map +1 -0
- package/dist/supervision/index.js +354 -0
- package/dist/supervision/index.js.map +1 -0
- package/dist/testing/clock.d.ts +50 -0
- package/dist/testing/clock.d.ts.map +1 -0
- package/dist/testing/clock.js +75 -0
- package/dist/testing/clock.js.map +1 -0
- package/dist/testing/env.d.ts +66 -0
- package/dist/testing/env.d.ts.map +1 -0
- package/dist/testing/env.js +106 -0
- package/dist/testing/env.js.map +1 -0
- package/dist/testing/gate-runner.d.ts +141 -0
- package/dist/testing/gate-runner.d.ts.map +1 -0
- package/dist/testing/gate-runner.js +173 -0
- package/dist/testing/gate-runner.js.map +1 -0
- package/dist/testing/gf19.d.ts +106 -0
- package/dist/testing/gf19.d.ts.map +1 -0
- package/dist/testing/gf19.js +282 -0
- package/dist/testing/gf19.js.map +1 -0
- package/dist/testing/index.d.ts +20 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +14 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/testing/red-probe.d.ts +138 -0
- package/dist/testing/red-probe.d.ts.map +1 -0
- package/dist/testing/red-probe.js +251 -0
- package/dist/testing/red-probe.js.map +1 -0
- package/dist/testing/temp-repo.d.ts +126 -0
- package/dist/testing/temp-repo.d.ts.map +1 -0
- package/dist/testing/temp-repo.js +214 -0
- package/dist/testing/temp-repo.js.map +1 -0
- package/dist/verdict/cause.d.ts +99 -0
- package/dist/verdict/cause.d.ts.map +1 -0
- package/dist/verdict/cause.js +206 -0
- package/dist/verdict/cause.js.map +1 -0
- package/dist/verdict/evaluate.d.ts +135 -0
- package/dist/verdict/evaluate.d.ts.map +1 -0
- package/dist/verdict/evaluate.js +1513 -0
- package/dist/verdict/evaluate.js.map +1 -0
- package/dist/verdict/index.d.ts +21 -0
- package/dist/verdict/index.d.ts.map +1 -0
- package/dist/verdict/index.js +20 -0
- package/dist/verdict/index.js.map +1 -0
- package/dist/verdict/pack-verifiers.d.ts +97 -0
- package/dist/verdict/pack-verifiers.d.ts.map +1 -0
- package/dist/verdict/pack-verifiers.js +763 -0
- package/dist/verdict/pack-verifiers.js.map +1 -0
- package/dist/verdict/registry.d.ts +180 -0
- package/dist/verdict/registry.d.ts.map +1 -0
- package/dist/verdict/registry.js +67 -0
- package/dist/verdict/registry.js.map +1 -0
- package/dist/waivers/index.d.ts +103 -0
- package/dist/waivers/index.d.ts.map +1 -0
- package/dist/waivers/index.js +192 -0
- package/dist/waivers/index.js.map +1 -0
- package/package.json +40 -0
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resource-graph input/output schemas (Phase 1 "resource graph
|
|
3
|
+
* construction"). The graph consumes detector contributions — the
|
|
4
|
+
* discovery-spike output shape pinned by GPP/3 (`resources`,
|
|
5
|
+
* `unresolved`, `findings`) plus detector provenance — and produces the
|
|
6
|
+
* normalized, deterministically ordered graph the policy engine and
|
|
7
|
+
* verdict engine speak.
|
|
8
|
+
*
|
|
9
|
+
* ADR 0001 encoded here:
|
|
10
|
+
* - D5.3: resource ids are plane-qualified `plane.name`; `source`
|
|
11
|
+
* paths are normalized repo-root-relative (discovery-spike
|
|
12
|
+
* limitation 5: spike ids embed command-line-relative paths);
|
|
13
|
+
* - D1: `unresolved` entries stay first-class and gate-visible;
|
|
14
|
+
* - invariant 9: references to removed/renamed resources surface as
|
|
15
|
+
* typed `stale` entries, never silent disappearance.
|
|
16
|
+
*/
|
|
17
|
+
import { z } from 'zod';
|
|
18
|
+
/**
|
|
19
|
+
* Canonical detector attribute vocabulary (camelCase). The graph reads
|
|
20
|
+
* `resourceName` as THE identity attribute of every resource; detectors
|
|
21
|
+
* set it to the table name for table kinds. Class-symbol resources
|
|
22
|
+
* additionally use the attribute keys declared in
|
|
23
|
+
* {@link ClassSymbolAttributesSchema}.
|
|
24
|
+
*/
|
|
25
|
+
export declare const RESOURCE_NAME_ATTRIBUTE = "resourceName";
|
|
26
|
+
/**
|
|
27
|
+
* Reserved resource `kind` marking a class-symbol declaration used by
|
|
28
|
+
* the graph's symbol table for cross-module inheritance resolution
|
|
29
|
+
* (go/no-go first action #2). Detectors emit one per table candidate
|
|
30
|
+
* class whose identity the graph may need to resolve through base
|
|
31
|
+
* classes; these resources are consumed by the symbol table and are
|
|
32
|
+
* NOT emitted as business resources.
|
|
33
|
+
*/
|
|
34
|
+
export declare const CLASS_SYMBOL_KIND = "gateforge.class";
|
|
35
|
+
/**
|
|
36
|
+
* Evidence-only resource kinds beyond the class-symbol channel (ADR 0004
|
|
37
|
+
* D1). Resources of these kinds are consumed by the engine's endpoint
|
|
38
|
+
* compiler, never emitted as business resources, and never classified —
|
|
39
|
+
* keeping route facts out of the business-identity namespace (the
|
|
40
|
+
* route/table collision red probe). This set is ENGINE-OWNED and closed:
|
|
41
|
+
* a detector cannot invent a new evidence-only kind or flag arbitrary
|
|
42
|
+
* resources out of classification, because that would be a
|
|
43
|
+
* detector-controlled suppressive-authority leak.
|
|
44
|
+
*/
|
|
45
|
+
export declare const EVIDENCE_ONLY_RESOURCE_KINDS: readonly string[];
|
|
46
|
+
/**
|
|
47
|
+
* Resource `kind` the engine's endpoint compiler emits for joined
|
|
48
|
+
* endpoints (ADR 0004 D1/D5). Endpoints ARE classified and carry their
|
|
49
|
+
* own HTTP obligations, but `crud:*`/`persistence:*` contracts never
|
|
50
|
+
* generate against them: CRUD state flows through the LINKED business
|
|
51
|
+
* resource's own obligations — routes are never conflated with tables.
|
|
52
|
+
* Mirrors `HTTP_ENDPOINT_KIND` in `@gate-forge/http-contract` (core cannot
|
|
53
|
+
* depend on it); keep the two in lockstep.
|
|
54
|
+
*/
|
|
55
|
+
export declare const HTTP_ENDPOINT_RESOURCE_KIND = "http.endpoint";
|
|
56
|
+
/** True when a raw resource kind is engine-owned evidence-only. */
|
|
57
|
+
export declare function isEvidenceOnlyKind(kind: string): boolean;
|
|
58
|
+
/** Attribute payload of a {@link CLASS_SYMBOL_KIND} resource. */
|
|
59
|
+
export declare const ClassSymbolAttributesSchema: z.ZodObject<{
|
|
60
|
+
qname: z.ZodString;
|
|
61
|
+
resourceKind: z.ZodString;
|
|
62
|
+
baseNames: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
63
|
+
tableName: z.ZodOptional<z.ZodString>;
|
|
64
|
+
abstract: z.ZodOptional<z.ZodBoolean>;
|
|
65
|
+
tablenameUnresolved: z.ZodOptional<z.ZodBoolean>;
|
|
66
|
+
}, z.core.$strict>;
|
|
67
|
+
/** Inferred class-symbol attribute shape. */
|
|
68
|
+
export type ClassSymbolAttributes = z.infer<typeof ClassSymbolAttributesSchema>;
|
|
69
|
+
/**
|
|
70
|
+
* Detector finding (discovery-spike lineage, e.g.
|
|
71
|
+
* `DUPLICATE_TABLE_NAME`): a non-resource observation about the
|
|
72
|
+
* scanned sources. This is the canonical home of the shape;
|
|
73
|
+
* `@gate-forge/plugin-protocol` carries a wire-compatible copy.
|
|
74
|
+
*/
|
|
75
|
+
export declare const FindingSchema: z.ZodObject<{
|
|
76
|
+
code: z.ZodString;
|
|
77
|
+
detail: z.ZodString;
|
|
78
|
+
locations: z.ZodArray<z.ZodObject<{
|
|
79
|
+
file: z.ZodString;
|
|
80
|
+
line: z.ZodNumber;
|
|
81
|
+
col: z.ZodNumber;
|
|
82
|
+
}, z.core.$strict>>;
|
|
83
|
+
}, z.core.$strict>;
|
|
84
|
+
/** Inferred finding shape. */
|
|
85
|
+
export type Finding = z.infer<typeof FindingSchema>;
|
|
86
|
+
/**
|
|
87
|
+
* A finding with provenance: graph-issued findings use `gateforge.graph`.
|
|
88
|
+
*/
|
|
89
|
+
export declare const GraphFindingSchema: z.ZodObject<{
|
|
90
|
+
code: z.ZodString;
|
|
91
|
+
detail: z.ZodString;
|
|
92
|
+
locations: z.ZodArray<z.ZodObject<{
|
|
93
|
+
file: z.ZodString;
|
|
94
|
+
line: z.ZodNumber;
|
|
95
|
+
col: z.ZodNumber;
|
|
96
|
+
}, z.core.$strict>>;
|
|
97
|
+
detectorId: z.ZodString;
|
|
98
|
+
}, z.core.$strict>;
|
|
99
|
+
/** Inferred graph-finding shape. */
|
|
100
|
+
export type GraphFinding = z.infer<typeof GraphFindingSchema>;
|
|
101
|
+
/**
|
|
102
|
+
* One detector's contribution to the graph: its pinned identity plus
|
|
103
|
+
* the discovery-spike output shape. `resources` entries are validated
|
|
104
|
+
* individually by the graph — invalid entries become `INVALID_RESOURCE`
|
|
105
|
+
* findings instead of aborting the run (fail visible, never crash).
|
|
106
|
+
*
|
|
107
|
+
* Since GPP/3 (ADR 0003 D6) every contribution also carries
|
|
108
|
+
* `classificationSignals` — the GPP/2 discovery shape is rejected
|
|
109
|
+
* fail-closed with an actionable diagnostic naming the missing field.
|
|
110
|
+
*/
|
|
111
|
+
export declare const DetectorOutputSchema: z.ZodObject<{
|
|
112
|
+
detectorId: z.ZodString;
|
|
113
|
+
detectorVersion: z.ZodString;
|
|
114
|
+
resources: z.ZodArray<z.ZodObject<{
|
|
115
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
116
|
+
id: z.ZodString;
|
|
117
|
+
kind: z.ZodString;
|
|
118
|
+
source: z.ZodString;
|
|
119
|
+
location: z.ZodObject<{
|
|
120
|
+
file: z.ZodString;
|
|
121
|
+
line: z.ZodNumber;
|
|
122
|
+
col: z.ZodNumber;
|
|
123
|
+
}, z.core.$strict>;
|
|
124
|
+
detectorVersion: z.ZodString;
|
|
125
|
+
attributes: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
126
|
+
}, z.core.$strict>>;
|
|
127
|
+
unresolved: z.ZodArray<z.ZodObject<{
|
|
128
|
+
code: z.ZodString;
|
|
129
|
+
detail: z.ZodString;
|
|
130
|
+
location: z.ZodObject<{
|
|
131
|
+
file: z.ZodString;
|
|
132
|
+
line: z.ZodNumber;
|
|
133
|
+
col: z.ZodNumber;
|
|
134
|
+
}, z.core.$strict>;
|
|
135
|
+
}, z.core.$strict>>;
|
|
136
|
+
findings: z.ZodArray<z.ZodObject<{
|
|
137
|
+
code: z.ZodString;
|
|
138
|
+
detail: z.ZodString;
|
|
139
|
+
locations: z.ZodArray<z.ZodObject<{
|
|
140
|
+
file: z.ZodString;
|
|
141
|
+
line: z.ZodNumber;
|
|
142
|
+
col: z.ZodNumber;
|
|
143
|
+
}, z.core.$strict>>;
|
|
144
|
+
}, z.core.$strict>>;
|
|
145
|
+
classificationSignals: z.ZodArray<z.ZodObject<{
|
|
146
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
147
|
+
target: z.ZodObject<{
|
|
148
|
+
resourceName: z.ZodOptional<z.ZodString>;
|
|
149
|
+
resourceId: z.ZodOptional<z.ZodString>;
|
|
150
|
+
symbol: z.ZodOptional<z.ZodString>;
|
|
151
|
+
}, z.core.$strict>;
|
|
152
|
+
dimension: z.ZodEnum<{
|
|
153
|
+
exposure: "exposure";
|
|
154
|
+
plane: "plane";
|
|
155
|
+
identity: "identity";
|
|
156
|
+
"lifecycle.create": "lifecycle.create";
|
|
157
|
+
"lifecycle.read": "lifecycle.read";
|
|
158
|
+
"lifecycle.update": "lifecycle.update";
|
|
159
|
+
"lifecycle.delete": "lifecycle.delete";
|
|
160
|
+
"delete-semantics": "delete-semantics";
|
|
161
|
+
"archive-state": "archive-state";
|
|
162
|
+
"adapter-binding": "adapter-binding";
|
|
163
|
+
internality: "internality";
|
|
164
|
+
}>;
|
|
165
|
+
assertion: z.ZodUnion<readonly [z.ZodString, z.ZodBoolean, z.ZodArray<z.ZodString>, z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>]>;
|
|
166
|
+
basis: z.ZodEnum<{
|
|
167
|
+
"code-positive": "code-positive";
|
|
168
|
+
"code-negative-closed-world": "code-negative-closed-world";
|
|
169
|
+
declaration: "declaration";
|
|
170
|
+
"organization-policy": "organization-policy";
|
|
171
|
+
}>;
|
|
172
|
+
source: z.ZodString;
|
|
173
|
+
location: z.ZodObject<{
|
|
174
|
+
file: z.ZodString;
|
|
175
|
+
line: z.ZodNumber;
|
|
176
|
+
col: z.ZodNumber;
|
|
177
|
+
}, z.core.$strict>;
|
|
178
|
+
detector: z.ZodObject<{
|
|
179
|
+
id: z.ZodString;
|
|
180
|
+
version: z.ZodString;
|
|
181
|
+
}, z.core.$strict>;
|
|
182
|
+
}, z.core.$strict>>;
|
|
183
|
+
scannedPaths: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
184
|
+
}, z.core.$strict>;
|
|
185
|
+
/** Inferred detector-contribution shape. */
|
|
186
|
+
export type DetectorOutput = z.infer<typeof DetectorOutputSchema>;
|
|
187
|
+
/**
|
|
188
|
+
* Everything the graph ingests: one or more detector contributions and
|
|
189
|
+
* the artifact populations stale-reference validation watches
|
|
190
|
+
* (invariant 9 / GF-06). Since the automatic-classification cutover
|
|
191
|
+
* (plan phase 5, ADR 0003 D5) the graph binds NO business meaning —
|
|
192
|
+
* business meaning comes only from the deterministic classifier
|
|
193
|
+
* (`runClassification`) over detector signals; the manual
|
|
194
|
+
* classifications document no longer exists.
|
|
195
|
+
*
|
|
196
|
+
* `claims` and `waivers` are deliberately typed `unknown`-tolerant: the
|
|
197
|
+
* graph validates each entry individually and converts invalid ones
|
|
198
|
+
* into `INVALID_CLAIM`/`INVALID_WAIVER` findings instead of aborting
|
|
199
|
+
* the run (fail visible, never crash).
|
|
200
|
+
*/
|
|
201
|
+
export interface ResourceGraphInput {
|
|
202
|
+
/** Detector contributions; ≥1. */
|
|
203
|
+
detectors: DetectorOutput[];
|
|
204
|
+
/** Claims to watch for stale references (obligation ids). */
|
|
205
|
+
claims?: unknown[];
|
|
206
|
+
/** Adapter file names or paths (`.gateforge/adapters/<resourceId>.mjs`). */
|
|
207
|
+
adapters?: string[];
|
|
208
|
+
/** Waivers to watch for stale references (exact-scope resourceIds). */
|
|
209
|
+
waivers?: unknown[];
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* A normalized graph resource. `id` is the plane-qualified `plane.name`
|
|
213
|
+
* identity (D5.3); it is `null` while the resource is unclassified and
|
|
214
|
+
* no plane could be derived. `classification`/`exposure` are `null`
|
|
215
|
+
* until a classification entry binds the resource. Class-symbol
|
|
216
|
+
* resources never appear here (consumed by the symbol table).
|
|
217
|
+
*/
|
|
218
|
+
export declare const GraphResourceSchema: z.ZodObject<{
|
|
219
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
220
|
+
id: z.ZodNullable<z.ZodString>;
|
|
221
|
+
name: z.ZodString;
|
|
222
|
+
plane: z.ZodNullable<z.ZodEnum<{
|
|
223
|
+
tenant: "tenant";
|
|
224
|
+
master: "master";
|
|
225
|
+
global: "global";
|
|
226
|
+
}>>;
|
|
227
|
+
kind: z.ZodString;
|
|
228
|
+
source: z.ZodString;
|
|
229
|
+
location: z.ZodObject<{
|
|
230
|
+
file: z.ZodString;
|
|
231
|
+
line: z.ZodNumber;
|
|
232
|
+
col: z.ZodNumber;
|
|
233
|
+
}, z.core.$strict>;
|
|
234
|
+
exposure: z.ZodNullable<z.ZodEnum<{
|
|
235
|
+
"user-facing": "user-facing";
|
|
236
|
+
internal: "internal";
|
|
237
|
+
}>>;
|
|
238
|
+
classification: z.ZodNullable<z.ZodObject<{
|
|
239
|
+
exposure: z.ZodEnum<{
|
|
240
|
+
"user-facing": "user-facing";
|
|
241
|
+
internal: "internal";
|
|
242
|
+
}>;
|
|
243
|
+
plane: z.ZodEnum<{
|
|
244
|
+
tenant: "tenant";
|
|
245
|
+
master: "master";
|
|
246
|
+
global: "global";
|
|
247
|
+
}>;
|
|
248
|
+
lifecycle: z.ZodObject<{
|
|
249
|
+
create: z.ZodBoolean;
|
|
250
|
+
read: z.ZodBoolean;
|
|
251
|
+
update: z.ZodBoolean;
|
|
252
|
+
delete: z.ZodBoolean;
|
|
253
|
+
deleteSemantics: z.ZodOptional<z.ZodEnum<{
|
|
254
|
+
hard: "hard";
|
|
255
|
+
archive: "archive";
|
|
256
|
+
}>>;
|
|
257
|
+
archiveFields: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
|
|
258
|
+
updateableFields: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
259
|
+
}, z.core.$strict>;
|
|
260
|
+
primaryKey: z.ZodArray<z.ZodString>;
|
|
261
|
+
evidenceAdapter: z.ZodOptional<z.ZodString>;
|
|
262
|
+
evidenceLane: z.ZodOptional<z.ZodEnum<{
|
|
263
|
+
adapter: "adapter";
|
|
264
|
+
claims: "claims";
|
|
265
|
+
}>>;
|
|
266
|
+
notes: z.ZodOptional<z.ZodString>;
|
|
267
|
+
}, z.core.$strict>>;
|
|
268
|
+
classificationTrace: z.ZodNullable<z.ZodObject<{
|
|
269
|
+
rules: z.ZodArray<z.ZodString>;
|
|
270
|
+
defaultsApplied: z.ZodArray<z.ZodString>;
|
|
271
|
+
contributingSignalIds: z.ZodArray<z.ZodString>;
|
|
272
|
+
contributingDetectors: z.ZodArray<z.ZodString>;
|
|
273
|
+
contradictions: z.ZodArray<z.ZodObject<{
|
|
274
|
+
dimension: z.ZodString;
|
|
275
|
+
detail: z.ZodString;
|
|
276
|
+
locations: z.ZodArray<z.ZodObject<{
|
|
277
|
+
file: z.ZodString;
|
|
278
|
+
line: z.ZodNumber;
|
|
279
|
+
col: z.ZodNumber;
|
|
280
|
+
}, z.core.$strict>>;
|
|
281
|
+
}, z.core.$strict>>;
|
|
282
|
+
unresolvedDimensions: z.ZodArray<z.ZodString>;
|
|
283
|
+
decisionFingerprint: z.ZodString;
|
|
284
|
+
}, z.core.$strict>>;
|
|
285
|
+
detector: z.ZodObject<{
|
|
286
|
+
id: z.ZodString;
|
|
287
|
+
version: z.ZodString;
|
|
288
|
+
}, z.core.$strict>;
|
|
289
|
+
attributes: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
290
|
+
}, z.core.$strict>;
|
|
291
|
+
/** Inferred normalized-resource shape. */
|
|
292
|
+
export type GraphResource = z.infer<typeof GraphResourceSchema>;
|
|
293
|
+
/** One gate-visible unresolved entry with its detector provenance. */
|
|
294
|
+
export declare const GraphUnresolvedSchema: z.ZodObject<{
|
|
295
|
+
reason: z.ZodObject<{
|
|
296
|
+
code: z.ZodString;
|
|
297
|
+
detail: z.ZodString;
|
|
298
|
+
location: z.ZodObject<{
|
|
299
|
+
file: z.ZodString;
|
|
300
|
+
line: z.ZodNumber;
|
|
301
|
+
col: z.ZodNumber;
|
|
302
|
+
}, z.core.$strict>;
|
|
303
|
+
}, z.core.$strict>;
|
|
304
|
+
detectorId: z.ZodString;
|
|
305
|
+
detectorVersion: z.ZodNullable<z.ZodString>;
|
|
306
|
+
}, z.core.$strict>;
|
|
307
|
+
/** Inferred graph-unresolved shape. */
|
|
308
|
+
export type GraphUnresolved = z.infer<typeof GraphUnresolvedSchema>;
|
|
309
|
+
/** Artifact kinds stale-reference validation watches (invariant 9). */
|
|
310
|
+
export declare const StaleReferenceKindSchema: z.ZodEnum<{
|
|
311
|
+
adapter: "adapter";
|
|
312
|
+
claim: "claim";
|
|
313
|
+
waiver: "waiver";
|
|
314
|
+
}>;
|
|
315
|
+
/** Inferred stale-reference-kind shape. */
|
|
316
|
+
export type StaleReferenceKind = z.infer<typeof StaleReferenceKindSchema>;
|
|
317
|
+
/**
|
|
318
|
+
* A reference to a resource that no longer exists. `reference` is the
|
|
319
|
+
* stale pointer itself: an obligation id, an adapter name, or a
|
|
320
|
+
* waiver-scoped resource id.
|
|
321
|
+
*/
|
|
322
|
+
export declare const StaleReferenceSchema: z.ZodObject<{
|
|
323
|
+
kind: z.ZodEnum<{
|
|
324
|
+
adapter: "adapter";
|
|
325
|
+
claim: "claim";
|
|
326
|
+
waiver: "waiver";
|
|
327
|
+
}>;
|
|
328
|
+
reference: z.ZodString;
|
|
329
|
+
detail: z.ZodString;
|
|
330
|
+
}, z.core.$strict>;
|
|
331
|
+
/** Inferred stale-reference shape. */
|
|
332
|
+
export type StaleReference = z.infer<typeof StaleReferenceSchema>;
|
|
333
|
+
/**
|
|
334
|
+
* The built resource graph. Deterministic: every array is sorted by a
|
|
335
|
+
* total order, so identical inputs serialize byte-for-byte identically
|
|
336
|
+
* under `canonicalJson`.
|
|
337
|
+
*/
|
|
338
|
+
export declare const ResourceGraphSchema: z.ZodObject<{
|
|
339
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
340
|
+
resources: z.ZodArray<z.ZodObject<{
|
|
341
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
342
|
+
id: z.ZodNullable<z.ZodString>;
|
|
343
|
+
name: z.ZodString;
|
|
344
|
+
plane: z.ZodNullable<z.ZodEnum<{
|
|
345
|
+
tenant: "tenant";
|
|
346
|
+
master: "master";
|
|
347
|
+
global: "global";
|
|
348
|
+
}>>;
|
|
349
|
+
kind: z.ZodString;
|
|
350
|
+
source: z.ZodString;
|
|
351
|
+
location: z.ZodObject<{
|
|
352
|
+
file: z.ZodString;
|
|
353
|
+
line: z.ZodNumber;
|
|
354
|
+
col: z.ZodNumber;
|
|
355
|
+
}, z.core.$strict>;
|
|
356
|
+
exposure: z.ZodNullable<z.ZodEnum<{
|
|
357
|
+
"user-facing": "user-facing";
|
|
358
|
+
internal: "internal";
|
|
359
|
+
}>>;
|
|
360
|
+
classification: z.ZodNullable<z.ZodObject<{
|
|
361
|
+
exposure: z.ZodEnum<{
|
|
362
|
+
"user-facing": "user-facing";
|
|
363
|
+
internal: "internal";
|
|
364
|
+
}>;
|
|
365
|
+
plane: z.ZodEnum<{
|
|
366
|
+
tenant: "tenant";
|
|
367
|
+
master: "master";
|
|
368
|
+
global: "global";
|
|
369
|
+
}>;
|
|
370
|
+
lifecycle: z.ZodObject<{
|
|
371
|
+
create: z.ZodBoolean;
|
|
372
|
+
read: z.ZodBoolean;
|
|
373
|
+
update: z.ZodBoolean;
|
|
374
|
+
delete: z.ZodBoolean;
|
|
375
|
+
deleteSemantics: z.ZodOptional<z.ZodEnum<{
|
|
376
|
+
hard: "hard";
|
|
377
|
+
archive: "archive";
|
|
378
|
+
}>>;
|
|
379
|
+
archiveFields: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
|
|
380
|
+
updateableFields: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
381
|
+
}, z.core.$strict>;
|
|
382
|
+
primaryKey: z.ZodArray<z.ZodString>;
|
|
383
|
+
evidenceAdapter: z.ZodOptional<z.ZodString>;
|
|
384
|
+
evidenceLane: z.ZodOptional<z.ZodEnum<{
|
|
385
|
+
adapter: "adapter";
|
|
386
|
+
claims: "claims";
|
|
387
|
+
}>>;
|
|
388
|
+
notes: z.ZodOptional<z.ZodString>;
|
|
389
|
+
}, z.core.$strict>>;
|
|
390
|
+
classificationTrace: z.ZodNullable<z.ZodObject<{
|
|
391
|
+
rules: z.ZodArray<z.ZodString>;
|
|
392
|
+
defaultsApplied: z.ZodArray<z.ZodString>;
|
|
393
|
+
contributingSignalIds: z.ZodArray<z.ZodString>;
|
|
394
|
+
contributingDetectors: z.ZodArray<z.ZodString>;
|
|
395
|
+
contradictions: z.ZodArray<z.ZodObject<{
|
|
396
|
+
dimension: z.ZodString;
|
|
397
|
+
detail: z.ZodString;
|
|
398
|
+
locations: z.ZodArray<z.ZodObject<{
|
|
399
|
+
file: z.ZodString;
|
|
400
|
+
line: z.ZodNumber;
|
|
401
|
+
col: z.ZodNumber;
|
|
402
|
+
}, z.core.$strict>>;
|
|
403
|
+
}, z.core.$strict>>;
|
|
404
|
+
unresolvedDimensions: z.ZodArray<z.ZodString>;
|
|
405
|
+
decisionFingerprint: z.ZodString;
|
|
406
|
+
}, z.core.$strict>>;
|
|
407
|
+
detector: z.ZodObject<{
|
|
408
|
+
id: z.ZodString;
|
|
409
|
+
version: z.ZodString;
|
|
410
|
+
}, z.core.$strict>;
|
|
411
|
+
attributes: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
412
|
+
}, z.core.$strict>>;
|
|
413
|
+
unresolved: z.ZodArray<z.ZodObject<{
|
|
414
|
+
reason: z.ZodObject<{
|
|
415
|
+
code: z.ZodString;
|
|
416
|
+
detail: z.ZodString;
|
|
417
|
+
location: z.ZodObject<{
|
|
418
|
+
file: z.ZodString;
|
|
419
|
+
line: z.ZodNumber;
|
|
420
|
+
col: z.ZodNumber;
|
|
421
|
+
}, z.core.$strict>;
|
|
422
|
+
}, z.core.$strict>;
|
|
423
|
+
detectorId: z.ZodString;
|
|
424
|
+
detectorVersion: z.ZodNullable<z.ZodString>;
|
|
425
|
+
}, z.core.$strict>>;
|
|
426
|
+
findings: z.ZodArray<z.ZodObject<{
|
|
427
|
+
code: z.ZodString;
|
|
428
|
+
detail: z.ZodString;
|
|
429
|
+
locations: z.ZodArray<z.ZodObject<{
|
|
430
|
+
file: z.ZodString;
|
|
431
|
+
line: z.ZodNumber;
|
|
432
|
+
col: z.ZodNumber;
|
|
433
|
+
}, z.core.$strict>>;
|
|
434
|
+
detectorId: z.ZodString;
|
|
435
|
+
}, z.core.$strict>>;
|
|
436
|
+
stale: z.ZodArray<z.ZodObject<{
|
|
437
|
+
kind: z.ZodEnum<{
|
|
438
|
+
adapter: "adapter";
|
|
439
|
+
claim: "claim";
|
|
440
|
+
waiver: "waiver";
|
|
441
|
+
}>;
|
|
442
|
+
reference: z.ZodString;
|
|
443
|
+
detail: z.ZodString;
|
|
444
|
+
}, z.core.$strict>>;
|
|
445
|
+
}, z.core.$strict>;
|
|
446
|
+
/** Inferred resource-graph shape. */
|
|
447
|
+
export type ResourceGraph = z.infer<typeof ResourceGraphSchema>;
|
|
448
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/graph/schema.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resource-graph input/output schemas (Phase 1 "resource graph
|
|
3
|
+
* construction"). The graph consumes detector contributions — the
|
|
4
|
+
* discovery-spike output shape pinned by GPP/3 (`resources`,
|
|
5
|
+
* `unresolved`, `findings`) plus detector provenance — and produces the
|
|
6
|
+
* normalized, deterministically ordered graph the policy engine and
|
|
7
|
+
* verdict engine speak.
|
|
8
|
+
*
|
|
9
|
+
* ADR 0001 encoded here:
|
|
10
|
+
* - D5.3: resource ids are plane-qualified `plane.name`; `source`
|
|
11
|
+
* paths are normalized repo-root-relative (discovery-spike
|
|
12
|
+
* limitation 5: spike ids embed command-line-relative paths);
|
|
13
|
+
* - D1: `unresolved` entries stay first-class and gate-visible;
|
|
14
|
+
* - invariant 9: references to removed/renamed resources surface as
|
|
15
|
+
* typed `stale` entries, never silent disappearance.
|
|
16
|
+
*/
|
|
17
|
+
import { z } from 'zod';
|
|
18
|
+
import { ExposureSchema, LocationSchema, PlaneSchema, SchemaVersionField } from '../schemas/common.js';
|
|
19
|
+
import { ClassificationSchema } from '../schemas/classification.js';
|
|
20
|
+
import { ClassificationSignalSchema } from '../schemas/classification-signal.js';
|
|
21
|
+
import { ClassificationDecisionTraceSchema } from '../classifier/schema.js';
|
|
22
|
+
import { ResourceSchema } from '../schemas/resource.js';
|
|
23
|
+
import { UnresolvedReasonSchema } from '../schemas/verdict.js';
|
|
24
|
+
/**
|
|
25
|
+
* Canonical detector attribute vocabulary (camelCase). The graph reads
|
|
26
|
+
* `resourceName` as THE identity attribute of every resource; detectors
|
|
27
|
+
* set it to the table name for table kinds. Class-symbol resources
|
|
28
|
+
* additionally use the attribute keys declared in
|
|
29
|
+
* {@link ClassSymbolAttributesSchema}.
|
|
30
|
+
*/
|
|
31
|
+
export const RESOURCE_NAME_ATTRIBUTE = 'resourceName';
|
|
32
|
+
/**
|
|
33
|
+
* Reserved resource `kind` marking a class-symbol declaration used by
|
|
34
|
+
* the graph's symbol table for cross-module inheritance resolution
|
|
35
|
+
* (go/no-go first action #2). Detectors emit one per table candidate
|
|
36
|
+
* class whose identity the graph may need to resolve through base
|
|
37
|
+
* classes; these resources are consumed by the symbol table and are
|
|
38
|
+
* NOT emitted as business resources.
|
|
39
|
+
*/
|
|
40
|
+
export const CLASS_SYMBOL_KIND = 'gateforge.class';
|
|
41
|
+
/**
|
|
42
|
+
* Evidence-only resource kinds beyond the class-symbol channel (ADR 0004
|
|
43
|
+
* D1). Resources of these kinds are consumed by the engine's endpoint
|
|
44
|
+
* compiler, never emitted as business resources, and never classified —
|
|
45
|
+
* keeping route facts out of the business-identity namespace (the
|
|
46
|
+
* route/table collision red probe). This set is ENGINE-OWNED and closed:
|
|
47
|
+
* a detector cannot invent a new evidence-only kind or flag arbitrary
|
|
48
|
+
* resources out of classification, because that would be a
|
|
49
|
+
* detector-controlled suppressive-authority leak.
|
|
50
|
+
*/
|
|
51
|
+
export const EVIDENCE_ONLY_RESOURCE_KINDS = ['http.contract'];
|
|
52
|
+
/**
|
|
53
|
+
* Resource `kind` the engine's endpoint compiler emits for joined
|
|
54
|
+
* endpoints (ADR 0004 D1/D5). Endpoints ARE classified and carry their
|
|
55
|
+
* own HTTP obligations, but `crud:*`/`persistence:*` contracts never
|
|
56
|
+
* generate against them: CRUD state flows through the LINKED business
|
|
57
|
+
* resource's own obligations — routes are never conflated with tables.
|
|
58
|
+
* Mirrors `HTTP_ENDPOINT_KIND` in `@gate-forge/http-contract` (core cannot
|
|
59
|
+
* depend on it); keep the two in lockstep.
|
|
60
|
+
*/
|
|
61
|
+
export const HTTP_ENDPOINT_RESOURCE_KIND = 'http.endpoint';
|
|
62
|
+
/** True when a raw resource kind is engine-owned evidence-only. */
|
|
63
|
+
export function isEvidenceOnlyKind(kind) {
|
|
64
|
+
return kind === CLASS_SYMBOL_KIND || EVIDENCE_ONLY_RESOURCE_KINDS.includes(kind);
|
|
65
|
+
}
|
|
66
|
+
/** Attribute payload of a {@link CLASS_SYMBOL_KIND} resource. */
|
|
67
|
+
export const ClassSymbolAttributesSchema = z
|
|
68
|
+
.strictObject({
|
|
69
|
+
/** Scope-qualified class name (dotted), e.g. `pkg.models.Base`. */
|
|
70
|
+
qname: z.string().min(1),
|
|
71
|
+
/** `kind` the graph must use for a table materialized from this class. */
|
|
72
|
+
resourceKind: z.string().min(1),
|
|
73
|
+
/** Direct base classes as written in source, in declaration order. */
|
|
74
|
+
baseNames: z.array(z.string().min(1)).optional(),
|
|
75
|
+
/** Literal `__tablename__` declared on the class itself, if any. */
|
|
76
|
+
tableName: z.string().min(1).optional(),
|
|
77
|
+
/** True for `__abstract__ = True` bases (never materialize directly). */
|
|
78
|
+
abstract: z.boolean().optional(),
|
|
79
|
+
/**
|
|
80
|
+
* Detector assertion that this class's tablename is unresolved;
|
|
81
|
+
* when the symbol table cannot resolve it either, the graph
|
|
82
|
+
* synthesizes a typed `inherited_tablename_unresolved` entry so
|
|
83
|
+
* the class never vanishes silently.
|
|
84
|
+
*/
|
|
85
|
+
tablenameUnresolved: z.boolean().optional(),
|
|
86
|
+
});
|
|
87
|
+
/**
|
|
88
|
+
* Detector finding (discovery-spike lineage, e.g.
|
|
89
|
+
* `DUPLICATE_TABLE_NAME`): a non-resource observation about the
|
|
90
|
+
* scanned sources. This is the canonical home of the shape;
|
|
91
|
+
* `@gate-forge/plugin-protocol` carries a wire-compatible copy.
|
|
92
|
+
*/
|
|
93
|
+
export const FindingSchema = z
|
|
94
|
+
.strictObject({
|
|
95
|
+
/** Short stable finding code, e.g. `DUPLICATE_TABLE_NAME`. */
|
|
96
|
+
code: z.string().min(1),
|
|
97
|
+
/** Single-cause human explanation. */
|
|
98
|
+
detail: z.string().min(1),
|
|
99
|
+
/** Source locations the finding points at (≥1, deterministically ordered). */
|
|
100
|
+
locations: z.array(LocationSchema).min(1),
|
|
101
|
+
});
|
|
102
|
+
/**
|
|
103
|
+
* A finding with provenance: graph-issued findings use `gateforge.graph`.
|
|
104
|
+
*/
|
|
105
|
+
export const GraphFindingSchema = z
|
|
106
|
+
.strictObject({
|
|
107
|
+
code: z.string().min(1),
|
|
108
|
+
detail: z.string().min(1),
|
|
109
|
+
/**
|
|
110
|
+
* Source locations the finding points at. Detector findings carry
|
|
111
|
+
* ≥1 (the pinned shape); graph-issued findings may carry zero when
|
|
112
|
+
* no single source location applies (e.g. schema-invalid claims).
|
|
113
|
+
*/
|
|
114
|
+
locations: z.array(LocationSchema),
|
|
115
|
+
/** Detector that issued the finding. */
|
|
116
|
+
detectorId: z.string().min(1),
|
|
117
|
+
});
|
|
118
|
+
/**
|
|
119
|
+
* One detector's contribution to the graph: its pinned identity plus
|
|
120
|
+
* the discovery-spike output shape. `resources` entries are validated
|
|
121
|
+
* individually by the graph — invalid entries become `INVALID_RESOURCE`
|
|
122
|
+
* findings instead of aborting the run (fail visible, never crash).
|
|
123
|
+
*
|
|
124
|
+
* Since GPP/3 (ADR 0003 D6) every contribution also carries
|
|
125
|
+
* `classificationSignals` — the GPP/2 discovery shape is rejected
|
|
126
|
+
* fail-closed with an actionable diagnostic naming the missing field.
|
|
127
|
+
*/
|
|
128
|
+
export const DetectorOutputSchema = z
|
|
129
|
+
.strictObject({
|
|
130
|
+
/** Plugin id pinned at the GPP/3 handshake (or in-process loader). */
|
|
131
|
+
detectorId: z.string().min(1),
|
|
132
|
+
/** Plugin version pinned at the handshake. */
|
|
133
|
+
detectorVersion: z.string().min(1),
|
|
134
|
+
/** Discovered resources (frozen core `Resource` shape). */
|
|
135
|
+
resources: z.array(ResourceSchema),
|
|
136
|
+
/** Typed reasons parts of the input could not be resolved. */
|
|
137
|
+
unresolved: z.array(UnresolvedReasonSchema),
|
|
138
|
+
/** Non-resource observations (duplicates, ambiguities). */
|
|
139
|
+
findings: z.array(FindingSchema),
|
|
140
|
+
/**
|
|
141
|
+
* Classification-signal facts (ADR 0003 D1) for the discovered
|
|
142
|
+
* resources. Detectors that cannot emit signals contribute an empty
|
|
143
|
+
* array — conservative defaults classify their resources.
|
|
144
|
+
*/
|
|
145
|
+
classificationSignals: z.array(ClassificationSignalSchema),
|
|
146
|
+
/**
|
|
147
|
+
* Repo-root-relative files the detector actually examined
|
|
148
|
+
* successfully (coverage evidence, ADR 0003 D4). Optional: a
|
|
149
|
+
* contribution that omits it leaves the complete-scan attestation
|
|
150
|
+
* unknown, which fails closed.
|
|
151
|
+
*/
|
|
152
|
+
scannedPaths: z.array(z.string().min(1)).optional(),
|
|
153
|
+
});
|
|
154
|
+
/**
|
|
155
|
+
* A normalized graph resource. `id` is the plane-qualified `plane.name`
|
|
156
|
+
* identity (D5.3); it is `null` while the resource is unclassified and
|
|
157
|
+
* no plane could be derived. `classification`/`exposure` are `null`
|
|
158
|
+
* until a classification entry binds the resource. Class-symbol
|
|
159
|
+
* resources never appear here (consumed by the symbol table).
|
|
160
|
+
*/
|
|
161
|
+
export const GraphResourceSchema = z
|
|
162
|
+
.strictObject({
|
|
163
|
+
schemaVersion: SchemaVersionField,
|
|
164
|
+
/** `plane.name`, or `null` while the plane is unknown (unclassified). */
|
|
165
|
+
id: z.string().min(1).nullable(),
|
|
166
|
+
/** Bare resource name (`resourceName` attribute). */
|
|
167
|
+
name: z.string().min(1),
|
|
168
|
+
/** Resolved plane, or `null` while unclassified-without-plane. */
|
|
169
|
+
plane: PlaneSchema.nullable(),
|
|
170
|
+
/** Detector framework kind, e.g. `sqlalchemy.table`. */
|
|
171
|
+
kind: z.string().min(1),
|
|
172
|
+
/** Repo-root-relative source path (posix separators, no `./`). */
|
|
173
|
+
source: z.string().min(1),
|
|
174
|
+
/** Exact declaration location in `source`. */
|
|
175
|
+
location: LocationSchema,
|
|
176
|
+
/** Classification exposure, or `null` while unclassified. */
|
|
177
|
+
exposure: ExposureSchema.nullable(),
|
|
178
|
+
/** Bound classification entry, or `null` while unclassified. */
|
|
179
|
+
classification: ClassificationSchema.nullable(),
|
|
180
|
+
/**
|
|
181
|
+
* Explainability provenance of an automatically classified resource
|
|
182
|
+
* (ADR 0003 D1): decision fingerprint, contributing signal ids,
|
|
183
|
+
* rules, defaults, contradictions. Sibling metadata — NEVER
|
|
184
|
+
* smuggled into detector attributes, never authoritative input.
|
|
185
|
+
* `null` while the resource is unclassified or the classifier has
|
|
186
|
+
* not produced a decision for it (manual classifications carry no
|
|
187
|
+
* trace).
|
|
188
|
+
*/
|
|
189
|
+
classificationTrace: ClassificationDecisionTraceSchema.nullable(),
|
|
190
|
+
/** Detector provenance (handshake-pinned id + version). */
|
|
191
|
+
detector: z.strictObject({ id: z.string().min(1), version: z.string().min(1) }),
|
|
192
|
+
/** Detector-specific attributes, open payload. */
|
|
193
|
+
attributes: z.record(z.string(), z.unknown()),
|
|
194
|
+
});
|
|
195
|
+
/** One gate-visible unresolved entry with its detector provenance. */
|
|
196
|
+
export const GraphUnresolvedSchema = z
|
|
197
|
+
.strictObject({
|
|
198
|
+
/** Typed reason, verbatim from the detector or graph-synthesized. */
|
|
199
|
+
reason: UnresolvedReasonSchema,
|
|
200
|
+
/** Issuing detector; graph-synthesized entries use `gateforge.graph`. */
|
|
201
|
+
detectorId: z.string().min(1),
|
|
202
|
+
/** Issuing detector version; `null` for graph-synthesized entries. */
|
|
203
|
+
detectorVersion: z.string().min(1).nullable(),
|
|
204
|
+
});
|
|
205
|
+
/** Artifact kinds stale-reference validation watches (invariant 9). */
|
|
206
|
+
export const StaleReferenceKindSchema = z.enum(['claim', 'adapter', 'waiver']);
|
|
207
|
+
/**
|
|
208
|
+
* A reference to a resource that no longer exists. `reference` is the
|
|
209
|
+
* stale pointer itself: an obligation id, an adapter name, or a
|
|
210
|
+
* waiver-scoped resource id.
|
|
211
|
+
*/
|
|
212
|
+
export const StaleReferenceSchema = z
|
|
213
|
+
.strictObject({
|
|
214
|
+
kind: StaleReferenceKindSchema,
|
|
215
|
+
/** The stale pointer (key / obligation id / adapter name / resourceId). */
|
|
216
|
+
reference: z.string().min(1),
|
|
217
|
+
/** Single-cause human explanation. */
|
|
218
|
+
detail: z.string().min(1),
|
|
219
|
+
});
|
|
220
|
+
/**
|
|
221
|
+
* The built resource graph. Deterministic: every array is sorted by a
|
|
222
|
+
* total order, so identical inputs serialize byte-for-byte identically
|
|
223
|
+
* under `canonicalJson`.
|
|
224
|
+
*/
|
|
225
|
+
export const ResourceGraphSchema = z
|
|
226
|
+
.strictObject({
|
|
227
|
+
schemaVersion: SchemaVersionField,
|
|
228
|
+
/** Normalized resources, sorted by id (id-less entries last, by name). */
|
|
229
|
+
resources: z.array(GraphResourceSchema),
|
|
230
|
+
/** Gate-visible unresolved entries, sorted by location then code. */
|
|
231
|
+
unresolved: z.array(GraphUnresolvedSchema),
|
|
232
|
+
/** Detector findings + graph-issued findings, sorted deterministically. */
|
|
233
|
+
findings: z.array(GraphFindingSchema),
|
|
234
|
+
/** References to removed/renamed resources (invariant 9), sorted. */
|
|
235
|
+
stale: z.array(StaleReferenceSchema),
|
|
236
|
+
});
|
|
237
|
+
//# sourceMappingURL=schema.js.map
|