@duckcodeailabs/dql-governance 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 +123 -0
- package/dist/certifier.d.ts +50 -0
- package/dist/certifier.d.ts.map +1 -0
- package/dist/certifier.js +158 -0
- package/dist/certifier.js.map +1 -0
- package/dist/cost-estimator.d.ts +24 -0
- package/dist/cost-estimator.d.ts.map +1 -0
- package/dist/cost-estimator.js +85 -0
- package/dist/cost-estimator.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/multi-domain.d.ts +74 -0
- package/dist/multi-domain.d.ts.map +1 -0
- package/dist/multi-domain.js +86 -0
- package/dist/multi-domain.js.map +1 -0
- package/dist/policy-engine.d.ts +48 -0
- package/dist/policy-engine.d.ts.map +1 -0
- package/dist/policy-engine.js +85 -0
- package/dist/policy-engine.js.map +1 -0
- package/dist/test-runner.d.ts +33 -0
- package/dist/test-runner.d.ts.map +1 -0
- package/dist/test-runner.js +124 -0
- package/dist/test-runner.js.map +1 -0
- package/package.json +42 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction, and
|
|
10
|
+
distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by the copyright
|
|
13
|
+
owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all other entities
|
|
16
|
+
that control, are controlled by, or are under common control with that entity.
|
|
17
|
+
For the purposes of this definition, "control" means (i) the power, direct or
|
|
18
|
+
indirect, to cause the direction or management of such entity, whether by
|
|
19
|
+
contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
20
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
21
|
+
|
|
22
|
+
"You" (or "Your") shall mean an individual or Legal Entity exercising
|
|
23
|
+
permissions granted by this License.
|
|
24
|
+
|
|
25
|
+
"Source" form shall mean the preferred form for making modifications, including
|
|
26
|
+
but not limited to software source code, documentation source, and configuration
|
|
27
|
+
files.
|
|
28
|
+
|
|
29
|
+
"Object" form shall mean any form resulting from mechanical transformation or
|
|
30
|
+
translation of a Source form, including but not limited to compiled object code,
|
|
31
|
+
generated documentation, and conversions to other media types.
|
|
32
|
+
|
|
33
|
+
"Work" shall mean the work of authorship, whether in Source or Object form, made
|
|
34
|
+
available under the License, as indicated by a copyright notice that is included
|
|
35
|
+
in or attached to the work.
|
|
36
|
+
|
|
37
|
+
"Derivative Works" shall mean any work, whether in Source or Object form, that
|
|
38
|
+
is based on (or derived from) the Work and for which the editorial revisions,
|
|
39
|
+
annotations, elaborations, or other modifications represent, as a whole, an
|
|
40
|
+
original work of authorship.
|
|
41
|
+
|
|
42
|
+
"Contribution" shall mean any work of authorship, including the original version
|
|
43
|
+
of the Work and any modifications or additions to that Work or Derivative Works
|
|
44
|
+
thereof, that is intentionally submitted to Licensor for inclusion in the Work
|
|
45
|
+
by the copyright owner or by an individual or Legal Entity authorized to submit
|
|
46
|
+
on behalf of the copyright owner.
|
|
47
|
+
|
|
48
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
|
|
49
|
+
of whom a Contribution has been received by Licensor and subsequently
|
|
50
|
+
incorporated within the Work.
|
|
51
|
+
|
|
52
|
+
2. Grant of Copyright License.
|
|
53
|
+
|
|
54
|
+
Subject to the terms and conditions of this License, each Contributor hereby
|
|
55
|
+
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
|
56
|
+
irrevocable copyright license to reproduce, prepare Derivative Works of,
|
|
57
|
+
publicly display, publicly perform, sublicense, and distribute the Work and such
|
|
58
|
+
Derivative Works in Source or Object form.
|
|
59
|
+
|
|
60
|
+
3. Grant of Patent License.
|
|
61
|
+
|
|
62
|
+
Subject to the terms and conditions of this License, each Contributor hereby
|
|
63
|
+
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
|
64
|
+
irrevocable patent license to make, have made, use, offer to sell, sell, import,
|
|
65
|
+
and otherwise transfer the Work.
|
|
66
|
+
|
|
67
|
+
4. Redistribution.
|
|
68
|
+
|
|
69
|
+
You may reproduce and distribute copies of the Work or Derivative Works thereof
|
|
70
|
+
in any medium, with or without modifications, and in Source or Object form,
|
|
71
|
+
provided that You meet the following conditions:
|
|
72
|
+
|
|
73
|
+
(a) You must give any other recipients of the Work or Derivative Works a copy of
|
|
74
|
+
this License; and
|
|
75
|
+
|
|
76
|
+
(b) You must cause any modified files to carry prominent notices stating that
|
|
77
|
+
You changed the files; and
|
|
78
|
+
|
|
79
|
+
(c) You must retain, in the Source form of any Derivative Works that You
|
|
80
|
+
distribute, all copyright, patent, trademark, and attribution notices from the
|
|
81
|
+
Source form of the Work, excluding those notices that do not pertain to any part
|
|
82
|
+
of the Derivative Works; and
|
|
83
|
+
|
|
84
|
+
(d) If the Work includes a "NOTICE" text file as part of its distribution, then
|
|
85
|
+
any Derivative Works that You distribute must include a readable copy of the
|
|
86
|
+
attribution notices contained within such NOTICE file, excluding those notices
|
|
87
|
+
that do not pertain to any part of the Derivative Works.
|
|
88
|
+
|
|
89
|
+
5. Submission of Contributions.
|
|
90
|
+
|
|
91
|
+
Unless You explicitly state otherwise, any Contribution intentionally submitted
|
|
92
|
+
for inclusion in the Work by You to the Licensor shall be under the terms and
|
|
93
|
+
conditions of this License, without any additional terms or conditions.
|
|
94
|
+
|
|
95
|
+
6. Trademarks.
|
|
96
|
+
|
|
97
|
+
This License does not grant permission to use the trade names, trademarks,
|
|
98
|
+
service marks, or product names of the Licensor, except as required for
|
|
99
|
+
reasonable and customary use in describing the origin of the Work.
|
|
100
|
+
|
|
101
|
+
7. Disclaimer of Warranty.
|
|
102
|
+
|
|
103
|
+
Unless required by applicable law or agreed to in writing, Licensor provides the
|
|
104
|
+
Work on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
|
|
105
|
+
express or implied, including, without limitation, any warranties or conditions
|
|
106
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR
|
|
107
|
+
PURPOSE.
|
|
108
|
+
|
|
109
|
+
8. Limitation of Liability.
|
|
110
|
+
|
|
111
|
+
In no event and under no legal theory, whether in tort (including negligence),
|
|
112
|
+
contract, or otherwise, unless required by applicable law, shall any Contributor
|
|
113
|
+
be liable to You for damages, including any direct, indirect, special,
|
|
114
|
+
incidental, or consequential damages of any character arising as a result of this
|
|
115
|
+
License or out of the use or inability to use the Work.
|
|
116
|
+
|
|
117
|
+
9. Accepting Warranty or Additional Liability.
|
|
118
|
+
|
|
119
|
+
While redistributing the Work or Derivative Works thereof, You may choose to
|
|
120
|
+
offer, and charge a fee for, acceptance of support, warranty, indemnity, or
|
|
121
|
+
other liability obligations and/or rights consistent with this License.
|
|
122
|
+
|
|
123
|
+
END OF TERMS AND CONDITIONS
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { BlockRecord, TestResultSummary } from '@duckcodeailabs/dql-project';
|
|
2
|
+
/**
|
|
3
|
+
* Certification rule that a block must pass to be certified.
|
|
4
|
+
*/
|
|
5
|
+
export interface CertificationRule {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
severity: 'error' | 'warning';
|
|
10
|
+
check: (block: BlockRecord, testResults?: TestResultSummary) => CertificationCheckResult;
|
|
11
|
+
}
|
|
12
|
+
export interface CertificationCheckResult {
|
|
13
|
+
passed: boolean;
|
|
14
|
+
message?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface CertificationResult {
|
|
17
|
+
blockId: string;
|
|
18
|
+
blockName: string;
|
|
19
|
+
certified: boolean;
|
|
20
|
+
errors: Array<{
|
|
21
|
+
rule: string;
|
|
22
|
+
message: string;
|
|
23
|
+
}>;
|
|
24
|
+
warnings: Array<{
|
|
25
|
+
rule: string;
|
|
26
|
+
message: string;
|
|
27
|
+
}>;
|
|
28
|
+
checkedAt: Date;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Built-in certification rules.
|
|
32
|
+
*/
|
|
33
|
+
export declare const BUILTIN_RULES: CertificationRule[];
|
|
34
|
+
export declare const PROMOTABLE_RULES: CertificationRule[];
|
|
35
|
+
/**
|
|
36
|
+
* Certifier evaluates blocks against certification rules.
|
|
37
|
+
*/
|
|
38
|
+
export declare class Certifier {
|
|
39
|
+
private rules;
|
|
40
|
+
constructor(rules?: CertificationRule[]);
|
|
41
|
+
/**
|
|
42
|
+
* Add a custom rule.
|
|
43
|
+
*/
|
|
44
|
+
addRule(rule: CertificationRule): void;
|
|
45
|
+
/**
|
|
46
|
+
* Evaluate a block against all rules.
|
|
47
|
+
*/
|
|
48
|
+
evaluate(block: BlockRecord, testResults?: TestResultSummary): CertificationResult;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=certifier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"certifier.d.ts","sourceRoot":"","sources":["../src/certifier.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAElF;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B,KAAK,EAAE,CAAC,KAAK,EAAE,WAAW,EAAE,WAAW,CAAC,EAAE,iBAAiB,KAAK,wBAAwB,CAAC;CAC1F;AAED,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACjD,QAAQ,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACnD,SAAS,EAAE,IAAI,CAAC;CACjB;AAED;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,iBAAiB,EAuF5C,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,iBAAiB,EAsB/C,CAAC;AAEF;;GAEG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,KAAK,CAAsB;gBAEvB,KAAK,CAAC,EAAE,iBAAiB,EAAE;IAIvC;;OAEG;IACH,OAAO,CAAC,IAAI,EAAE,iBAAiB,GAAG,IAAI;IAItC;;OAEG;IACH,QAAQ,CACN,KAAK,EAAE,WAAW,EAClB,WAAW,CAAC,EAAE,iBAAiB,GAC9B,mBAAmB;CAyBvB"}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in certification rules.
|
|
3
|
+
*/
|
|
4
|
+
export const BUILTIN_RULES = [
|
|
5
|
+
{
|
|
6
|
+
id: 'has-description',
|
|
7
|
+
name: 'Block has description',
|
|
8
|
+
description: 'Every block must have a non-empty description',
|
|
9
|
+
severity: 'error',
|
|
10
|
+
check: (block) => ({
|
|
11
|
+
passed: !!block.description && block.description.trim().length > 0,
|
|
12
|
+
message: block.description ? undefined : 'Missing description',
|
|
13
|
+
}),
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
id: 'has-owner',
|
|
17
|
+
name: 'Block has owner',
|
|
18
|
+
description: 'Every block must have an assigned owner',
|
|
19
|
+
severity: 'error',
|
|
20
|
+
check: (block) => ({
|
|
21
|
+
passed: !!block.owner && block.owner.trim().length > 0,
|
|
22
|
+
message: block.owner ? undefined : 'Missing owner',
|
|
23
|
+
}),
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
id: 'has-domain',
|
|
27
|
+
name: 'Block has domain',
|
|
28
|
+
description: 'Every block must belong to a domain',
|
|
29
|
+
severity: 'error',
|
|
30
|
+
check: (block) => ({
|
|
31
|
+
passed: !!block.domain && block.domain.trim().length > 0,
|
|
32
|
+
message: block.domain ? undefined : 'Missing domain',
|
|
33
|
+
}),
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
id: 'has-tags',
|
|
37
|
+
name: 'Block has tags',
|
|
38
|
+
description: 'Blocks should have at least one tag for discoverability',
|
|
39
|
+
severity: 'warning',
|
|
40
|
+
check: (block) => ({
|
|
41
|
+
passed: block.tags.length > 0,
|
|
42
|
+
message: block.tags.length > 0 ? undefined : 'No tags specified',
|
|
43
|
+
}),
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
id: 'tests-pass',
|
|
47
|
+
name: 'All tests pass',
|
|
48
|
+
description: 'Block tests must all pass for certification',
|
|
49
|
+
severity: 'error',
|
|
50
|
+
check: (_block, testResults) => {
|
|
51
|
+
if (!testResults) {
|
|
52
|
+
return { passed: false, message: 'No test results available' };
|
|
53
|
+
}
|
|
54
|
+
if (testResults.failed > 0) {
|
|
55
|
+
return {
|
|
56
|
+
passed: false,
|
|
57
|
+
message: `${testResults.failed} test(s) failed`,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
return { passed: true };
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
id: 'has-tests',
|
|
65
|
+
name: 'Block has tests',
|
|
66
|
+
description: 'Blocks should have at least one test assertion',
|
|
67
|
+
severity: 'warning',
|
|
68
|
+
check: (_block, testResults) => {
|
|
69
|
+
if (!testResults || testResults.assertions.length === 0) {
|
|
70
|
+
return { passed: false, message: 'No test assertions defined' };
|
|
71
|
+
}
|
|
72
|
+
return { passed: true };
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
id: 'cost-reasonable',
|
|
77
|
+
name: 'Query cost is reasonable',
|
|
78
|
+
description: 'Estimated query cost should be below threshold',
|
|
79
|
+
severity: 'warning',
|
|
80
|
+
check: (block) => {
|
|
81
|
+
if (block.costEstimate == null)
|
|
82
|
+
return { passed: true };
|
|
83
|
+
if (block.costEstimate > 100) {
|
|
84
|
+
return {
|
|
85
|
+
passed: false,
|
|
86
|
+
message: `Cost estimate ${block.costEstimate} exceeds threshold of 100`,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
return { passed: true };
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
];
|
|
93
|
+
export const PROMOTABLE_RULES = [
|
|
94
|
+
...BUILTIN_RULES,
|
|
95
|
+
{
|
|
96
|
+
id: 'canonical-git-path',
|
|
97
|
+
name: 'Block is in a canonical Git path',
|
|
98
|
+
description: 'Promotable blocks must not live under draft-only paths',
|
|
99
|
+
severity: 'error',
|
|
100
|
+
check: (block) => ({
|
|
101
|
+
passed: !!block.gitPath && !block.gitPath.includes('/_drafts/') && !block.gitPath.startsWith('blocks/_drafts/'),
|
|
102
|
+
message: block.gitPath ? 'Block is still stored in a draft-only path' : 'Missing Git path',
|
|
103
|
+
}),
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
id: 'stable-version',
|
|
107
|
+
name: 'Block has a stable version',
|
|
108
|
+
description: 'Promotable blocks must have a semantic version',
|
|
109
|
+
severity: 'error',
|
|
110
|
+
check: (block) => ({
|
|
111
|
+
passed: /^\d+\.\d+\.\d+$/.test(block.version),
|
|
112
|
+
message: `Version "${block.version}" is not a stable semantic version`,
|
|
113
|
+
}),
|
|
114
|
+
},
|
|
115
|
+
];
|
|
116
|
+
/**
|
|
117
|
+
* Certifier evaluates blocks against certification rules.
|
|
118
|
+
*/
|
|
119
|
+
export class Certifier {
|
|
120
|
+
rules;
|
|
121
|
+
constructor(rules) {
|
|
122
|
+
this.rules = rules ?? BUILTIN_RULES;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Add a custom rule.
|
|
126
|
+
*/
|
|
127
|
+
addRule(rule) {
|
|
128
|
+
this.rules.push(rule);
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Evaluate a block against all rules.
|
|
132
|
+
*/
|
|
133
|
+
evaluate(block, testResults) {
|
|
134
|
+
const errors = [];
|
|
135
|
+
const warnings = [];
|
|
136
|
+
for (const rule of this.rules) {
|
|
137
|
+
const result = rule.check(block, testResults);
|
|
138
|
+
if (!result.passed) {
|
|
139
|
+
const entry = { rule: rule.name, message: result.message ?? rule.description };
|
|
140
|
+
if (rule.severity === 'error') {
|
|
141
|
+
errors.push(entry);
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
warnings.push(entry);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return {
|
|
149
|
+
blockId: block.id,
|
|
150
|
+
blockName: block.name,
|
|
151
|
+
certified: errors.length === 0,
|
|
152
|
+
errors,
|
|
153
|
+
warnings,
|
|
154
|
+
checkedAt: new Date(),
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
//# sourceMappingURL=certifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"certifier.js","sourceRoot":"","sources":["../src/certifier.ts"],"names":[],"mappings":"AA2BA;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAwB;IAChD;QACE,EAAE,EAAE,iBAAiB;QACrB,IAAI,EAAE,uBAAuB;QAC7B,WAAW,EAAE,+CAA+C;QAC5D,QAAQ,EAAE,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,GAAG,KAAK,IAAI,aAAa,CAAC;IACtC,CAAC;IAED;;OAEG;IACH,OAAO,CAAC,IAAuB;QAC7B,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,QAAQ,CACN,KAAkB,EAClB,WAA+B;QAE/B,MAAM,MAAM,GAA6C,EAAE,CAAC;QAC5D,MAAM,QAAQ,GAA6C,EAAE,CAAC;QAE9D,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAC9B,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;YAC9C,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;gBACnB,MAAM,KAAK,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;gBAC/E,IAAI,IAAI,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;oBAC9B,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBACrB,CAAC;qBAAM,CAAC;oBACN,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBACvB,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO;YACL,OAAO,EAAE,KAAK,CAAC,EAAE;YACjB,SAAS,EAAE,KAAK,CAAC,IAAI;YACrB,SAAS,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC;YAC9B,MAAM;YACN,QAAQ;YACR,SAAS,EAAE,IAAI,IAAI,EAAE;SACtB,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CostEstimator provides heuristic query cost estimation.
|
|
3
|
+
* In production, this would integrate with database EXPLAIN plans.
|
|
4
|
+
* For now, it uses SQL analysis heuristics.
|
|
5
|
+
*/
|
|
6
|
+
export interface CostEstimate {
|
|
7
|
+
score: number;
|
|
8
|
+
factors: CostFactor[];
|
|
9
|
+
recommendation?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface CostFactor {
|
|
12
|
+
name: string;
|
|
13
|
+
impact: number;
|
|
14
|
+
description: string;
|
|
15
|
+
}
|
|
16
|
+
export declare class CostEstimator {
|
|
17
|
+
private maxScore;
|
|
18
|
+
constructor(maxScore?: number);
|
|
19
|
+
/**
|
|
20
|
+
* Estimate the cost of a SQL query using heuristic analysis.
|
|
21
|
+
*/
|
|
22
|
+
estimate(sql: string): CostEstimate;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=cost-estimator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cost-estimator.d.ts","sourceRoot":"","sources":["../src/cost-estimator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAS;gBAEb,QAAQ,SAAM;IAI1B;;OAEG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY;CAiFpC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CostEstimator provides heuristic query cost estimation.
|
|
3
|
+
* In production, this would integrate with database EXPLAIN plans.
|
|
4
|
+
* For now, it uses SQL analysis heuristics.
|
|
5
|
+
*/
|
|
6
|
+
export class CostEstimator {
|
|
7
|
+
maxScore;
|
|
8
|
+
constructor(maxScore = 100) {
|
|
9
|
+
this.maxScore = maxScore;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Estimate the cost of a SQL query using heuristic analysis.
|
|
13
|
+
*/
|
|
14
|
+
estimate(sql) {
|
|
15
|
+
const normalized = sql.toUpperCase();
|
|
16
|
+
const factors = [];
|
|
17
|
+
let score = 10; // base cost
|
|
18
|
+
// Full table scan indicator
|
|
19
|
+
if (!normalized.includes('WHERE') && !normalized.includes('LIMIT')) {
|
|
20
|
+
factors.push({ name: 'no-filter', impact: 20, description: 'No WHERE clause or LIMIT — potential full table scan' });
|
|
21
|
+
score += 20;
|
|
22
|
+
}
|
|
23
|
+
// JOIN complexity
|
|
24
|
+
const joinCount = (normalized.match(/\bJOIN\b/g) || []).length;
|
|
25
|
+
if (joinCount > 0) {
|
|
26
|
+
const impact = joinCount * 8;
|
|
27
|
+
factors.push({ name: 'joins', impact, description: `${joinCount} JOIN(s) detected` });
|
|
28
|
+
score += impact;
|
|
29
|
+
}
|
|
30
|
+
// Subquery complexity
|
|
31
|
+
const subqueryCount = (normalized.match(/\bSELECT\b/g) || []).length - 1;
|
|
32
|
+
if (subqueryCount > 0) {
|
|
33
|
+
const impact = subqueryCount * 10;
|
|
34
|
+
factors.push({ name: 'subqueries', impact, description: `${subqueryCount} subquery/subqueries detected` });
|
|
35
|
+
score += impact;
|
|
36
|
+
}
|
|
37
|
+
// Window functions
|
|
38
|
+
const windowCount = (normalized.match(/\bOVER\s*\(/g) || []).length;
|
|
39
|
+
if (windowCount > 0) {
|
|
40
|
+
const impact = windowCount * 5;
|
|
41
|
+
factors.push({ name: 'window-functions', impact, description: `${windowCount} window function(s)` });
|
|
42
|
+
score += impact;
|
|
43
|
+
}
|
|
44
|
+
// DISTINCT
|
|
45
|
+
if (normalized.includes('DISTINCT')) {
|
|
46
|
+
factors.push({ name: 'distinct', impact: 5, description: 'DISTINCT requires deduplication' });
|
|
47
|
+
score += 5;
|
|
48
|
+
}
|
|
49
|
+
// GROUP BY with many columns
|
|
50
|
+
const groupByMatch = normalized.match(/GROUP\s+BY\s+(.+?)(?:HAVING|ORDER|LIMIT|$)/);
|
|
51
|
+
if (groupByMatch) {
|
|
52
|
+
const groupCols = groupByMatch[1].split(',').length;
|
|
53
|
+
if (groupCols > 3) {
|
|
54
|
+
const impact = (groupCols - 3) * 3;
|
|
55
|
+
factors.push({ name: 'high-cardinality-group', impact, description: `GROUP BY with ${groupCols} columns` });
|
|
56
|
+
score += impact;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
// ORDER BY without LIMIT
|
|
60
|
+
if (normalized.includes('ORDER BY') && !normalized.includes('LIMIT')) {
|
|
61
|
+
factors.push({ name: 'unbounded-sort', impact: 8, description: 'ORDER BY without LIMIT — sorts entire result set' });
|
|
62
|
+
score += 8;
|
|
63
|
+
}
|
|
64
|
+
// CROSS JOIN
|
|
65
|
+
if (normalized.includes('CROSS JOIN')) {
|
|
66
|
+
factors.push({ name: 'cross-join', impact: 30, description: 'CROSS JOIN produces cartesian product' });
|
|
67
|
+
score += 30;
|
|
68
|
+
}
|
|
69
|
+
// LIKE with leading wildcard
|
|
70
|
+
if (normalized.match(/LIKE\s+'%/)) {
|
|
71
|
+
factors.push({ name: 'leading-wildcard', impact: 10, description: 'LIKE with leading wildcard prevents index usage' });
|
|
72
|
+
score += 10;
|
|
73
|
+
}
|
|
74
|
+
score = Math.min(score, this.maxScore);
|
|
75
|
+
let recommendation;
|
|
76
|
+
if (score > 70) {
|
|
77
|
+
recommendation = 'High cost query — consider adding filters, indexes, or materializing intermediate results.';
|
|
78
|
+
}
|
|
79
|
+
else if (score > 40) {
|
|
80
|
+
recommendation = 'Moderate cost — review JOINs and subqueries for optimization opportunities.';
|
|
81
|
+
}
|
|
82
|
+
return { score, factors, recommendation };
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=cost-estimator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cost-estimator.js","sourceRoot":"","sources":["../src/cost-estimator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAc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export type { BlockTestAssertion, QueryExecutor } from './test-runner.js';
|
|
3
|
+
export { Certifier, BUILTIN_RULES, PROMOTABLE_RULES } from './certifier.js';
|
|
4
|
+
export type { CertificationRule, CertificationCheckResult, CertificationResult } from './certifier.js';
|
|
5
|
+
export { CostEstimator } from './cost-estimator.js';
|
|
6
|
+
export type { CostEstimate, CostFactor } from './cost-estimator.js';
|
|
7
|
+
export { PolicyEngine } from './policy-engine.js';
|
|
8
|
+
export type { AccessPolicy, AccessCheckResult, AccessLevel, DataClassification, UserContext, } from './policy-engine.js';
|
|
9
|
+
export { MultiDomainGovernance } from './multi-domain.js';
|
|
10
|
+
export type { GovernanceModel, DomainConfig, ApprovalRules, PlatformConfig, DomainSyncResult, } from './multi-domain.js';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,YAAY,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAE1E,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAC5E,YAAY,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAEvG,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEpE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,YAAY,EACV,YAAY,EACZ,iBAAiB,EACjB,WAAW,EACX,kBAAkB,EAClB,WAAW,GACZ,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,YAAY,EACV,eAAe,EACf,YAAY,EACZ,aAAa,EACb,cAAc,EACd,gBAAgB,GACjB,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { TestRunner } from './test-runner.js';
|
|
2
|
+
export { Certifier, BUILTIN_RULES, PROMOTABLE_RULES } from './certifier.js';
|
|
3
|
+
export { CostEstimator } from './cost-estimator.js';
|
|
4
|
+
export { PolicyEngine } from './policy-engine.js';
|
|
5
|
+
export { MultiDomainGovernance } from './multi-domain.js';
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG9C,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAG5E,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AASlD,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Multi-Domain Git Governance — matches architecture spec §8.
|
|
3
|
+
* Supports single-repo, multi-repo, and hybrid models.
|
|
4
|
+
*/
|
|
5
|
+
export type GovernanceModel = 'single-repo' | 'multi-repo' | 'hybrid';
|
|
6
|
+
export interface DomainConfig {
|
|
7
|
+
name: string;
|
|
8
|
+
repo: string;
|
|
9
|
+
path: string;
|
|
10
|
+
owner: string;
|
|
11
|
+
approvalRules: ApprovalRules;
|
|
12
|
+
costThreshold?: number;
|
|
13
|
+
tags?: string[];
|
|
14
|
+
}
|
|
15
|
+
export interface ApprovalRules {
|
|
16
|
+
minReviewers: number;
|
|
17
|
+
autoCertifyOnMerge: boolean;
|
|
18
|
+
requirePassingTests: boolean;
|
|
19
|
+
requiredReviewers?: string[];
|
|
20
|
+
}
|
|
21
|
+
export interface PlatformConfig {
|
|
22
|
+
model: GovernanceModel;
|
|
23
|
+
coreRepo?: string;
|
|
24
|
+
domains: DomainConfig[];
|
|
25
|
+
globalRules: ApprovalRules;
|
|
26
|
+
syncSchedule?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface DomainSyncResult {
|
|
29
|
+
domain: string;
|
|
30
|
+
repo: string;
|
|
31
|
+
blocksFound: number;
|
|
32
|
+
blocksCreated: number;
|
|
33
|
+
blocksUpdated: number;
|
|
34
|
+
blocksUnchanged: number;
|
|
35
|
+
errors: string[];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* MultiDomainGovernance manages governance across multiple repos/domains.
|
|
39
|
+
*/
|
|
40
|
+
export declare class MultiDomainGovernance {
|
|
41
|
+
private config;
|
|
42
|
+
constructor(config: PlatformConfig);
|
|
43
|
+
getModel(): GovernanceModel;
|
|
44
|
+
getDomains(): DomainConfig[];
|
|
45
|
+
getDomain(name: string): DomainConfig | undefined;
|
|
46
|
+
addDomain(domain: DomainConfig): void;
|
|
47
|
+
removeDomain(name: string): void;
|
|
48
|
+
/**
|
|
49
|
+
* Get the effective approval rules for a domain.
|
|
50
|
+
* Domain rules override global rules where specified.
|
|
51
|
+
*/
|
|
52
|
+
getEffectiveRules(domainName: string): ApprovalRules;
|
|
53
|
+
/**
|
|
54
|
+
* Validate that a block meets the governance requirements for its domain.
|
|
55
|
+
*/
|
|
56
|
+
validateBlock(blockDomain: string, block: {
|
|
57
|
+
hasTests: boolean;
|
|
58
|
+
reviewerCount: number;
|
|
59
|
+
reviewers: string[];
|
|
60
|
+
testsPassing: boolean;
|
|
61
|
+
}): {
|
|
62
|
+
valid: boolean;
|
|
63
|
+
violations: string[];
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Generate a sync plan for all domains.
|
|
67
|
+
*/
|
|
68
|
+
getSyncPlan(): Array<{
|
|
69
|
+
domain: string;
|
|
70
|
+
repo: string;
|
|
71
|
+
path: string;
|
|
72
|
+
}>;
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=multi-domain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multi-domain.d.ts","sourceRoot":"","sources":["../src/multi-domain.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,eAAe,GAAG,aAAa,GAAG,YAAY,GAAG,QAAQ,CAAC;AAEtE,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,aAAa,CAAC;IAC7B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,MAAM,WAAW,aAAa;IAC5B,YAAY,EAAE,MAAM,CAAC;IACrB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,mBAAmB,EAAE,OAAO,CAAC;IAC7B,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC9B;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,eAAe,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,WAAW,EAAE,aAAa,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED;;GAEG;AACH,qBAAa,qBAAqB;IAChC,OAAO,CAAC,MAAM,CAAiB;gBAEnB,MAAM,EAAE,cAAc;IAIlC,QAAQ,IAAI,eAAe;IAI3B,UAAU,IAAI,YAAY,EAAE;IAI5B,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;IAIjD,SAAS,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI;IASrC,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAIhC;;;OAGG;IACH,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,aAAa;IAepD;;OAEG;IACH,aAAa,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE;QACxC,QAAQ,EAAE,OAAO,CAAC;QAClB,aAAa,EAAE,MAAM,CAAC;QACtB,SAAS,EAAE,MAAM,EAAE,CAAC;QACpB,YAAY,EAAE,OAAO,CAAC;KACvB,GAAG;QAAE,KAAK,EAAE,OAAO,CAAC;QAAC,UAAU,EAAE,MAAM,EAAE,CAAA;KAAE;IA0B5C;;OAEG;IACH,WAAW,IAAI,KAAK,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CAOrE"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Multi-Domain Git Governance — matches architecture spec §8.
|
|
3
|
+
* Supports single-repo, multi-repo, and hybrid models.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* MultiDomainGovernance manages governance across multiple repos/domains.
|
|
7
|
+
*/
|
|
8
|
+
export class MultiDomainGovernance {
|
|
9
|
+
config;
|
|
10
|
+
constructor(config) {
|
|
11
|
+
this.config = config;
|
|
12
|
+
}
|
|
13
|
+
getModel() {
|
|
14
|
+
return this.config.model;
|
|
15
|
+
}
|
|
16
|
+
getDomains() {
|
|
17
|
+
return [...this.config.domains];
|
|
18
|
+
}
|
|
19
|
+
getDomain(name) {
|
|
20
|
+
return this.config.domains.find((d) => d.name === name);
|
|
21
|
+
}
|
|
22
|
+
addDomain(domain) {
|
|
23
|
+
const existing = this.config.domains.findIndex((d) => d.name === domain.name);
|
|
24
|
+
if (existing >= 0) {
|
|
25
|
+
this.config.domains[existing] = domain;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
this.config.domains.push(domain);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
removeDomain(name) {
|
|
32
|
+
this.config.domains = this.config.domains.filter((d) => d.name !== name);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Get the effective approval rules for a domain.
|
|
36
|
+
* Domain rules override global rules where specified.
|
|
37
|
+
*/
|
|
38
|
+
getEffectiveRules(domainName) {
|
|
39
|
+
const domain = this.getDomain(domainName);
|
|
40
|
+
if (!domain)
|
|
41
|
+
return { ...this.config.globalRules };
|
|
42
|
+
return {
|
|
43
|
+
minReviewers: Math.max(domain.approvalRules.minReviewers, this.config.globalRules.minReviewers),
|
|
44
|
+
autoCertifyOnMerge: domain.approvalRules.autoCertifyOnMerge && this.config.globalRules.autoCertifyOnMerge,
|
|
45
|
+
requirePassingTests: domain.approvalRules.requirePassingTests || this.config.globalRules.requirePassingTests,
|
|
46
|
+
requiredReviewers: [
|
|
47
|
+
...(this.config.globalRules.requiredReviewers ?? []),
|
|
48
|
+
...(domain.approvalRules.requiredReviewers ?? []),
|
|
49
|
+
],
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Validate that a block meets the governance requirements for its domain.
|
|
54
|
+
*/
|
|
55
|
+
validateBlock(blockDomain, block) {
|
|
56
|
+
const rules = this.getEffectiveRules(blockDomain);
|
|
57
|
+
const violations = [];
|
|
58
|
+
if (rules.requirePassingTests && !block.testsPassing) {
|
|
59
|
+
violations.push('Block tests must pass before certification');
|
|
60
|
+
}
|
|
61
|
+
if (!block.hasTests && rules.requirePassingTests) {
|
|
62
|
+
violations.push('Block must have at least one test');
|
|
63
|
+
}
|
|
64
|
+
if (block.reviewerCount < rules.minReviewers) {
|
|
65
|
+
violations.push(`Requires ${rules.minReviewers} reviewer(s), got ${block.reviewerCount}`);
|
|
66
|
+
}
|
|
67
|
+
if (rules.requiredReviewers && rules.requiredReviewers.length > 0) {
|
|
68
|
+
const missing = rules.requiredReviewers.filter((r) => !block.reviewers.includes(r));
|
|
69
|
+
if (missing.length > 0) {
|
|
70
|
+
violations.push(`Missing required reviewer(s): ${missing.join(', ')}`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return { valid: violations.length === 0, violations };
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Generate a sync plan for all domains.
|
|
77
|
+
*/
|
|
78
|
+
getSyncPlan() {
|
|
79
|
+
return this.config.domains.map((d) => ({
|
|
80
|
+
domain: d.name,
|
|
81
|
+
repo: d.repo,
|
|
82
|
+
path: d.path,
|
|
83
|
+
}));
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=multi-domain.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multi-domain.js","sourceRoot":"","sources":["../src/multi-domain.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAuCH;;GAEG;AACH,MAAM,OAAO,qBAAqB;IACxB,MAAM,CAAiB;IAE/B,YAAY,MAAsB;QAChC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;IAC3B,CAAC;IAED,UAAU;QACR,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAClC,CAAC;IAED,SAAS,CAAC,IAAY;QACpB,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;IAC1D,CAAC;IAED,SAAS,CAAC,MAAoB;QAC5B,M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AEG;IACH,WAAW;QACT,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACrC,MAAM,EAAE,CAAC,CAAC,IAAI;YACd,IAAI,EAAE,CAAC,CAAC,IAAI;YACZ,IAAI,EAAE,CAAC,CAAC,IAAI;SACb,CAAC,CAAC,CAAC;IACN,CAAC;CACF"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PolicyEngine enforces access policies and data classification rules.
|
|
3
|
+
*/
|
|
4
|
+
export type DataClassification = 'public' | 'internal' | 'confidential' | 'restricted';
|
|
5
|
+
export type AccessLevel = 'read' | 'write' | 'execute' | 'admin';
|
|
6
|
+
export interface AccessPolicy {
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
description: string;
|
|
10
|
+
/** Domain this policy applies to, or '*' for all */
|
|
11
|
+
domain: string;
|
|
12
|
+
/** Minimum data classification level required */
|
|
13
|
+
minClassification: DataClassification;
|
|
14
|
+
/** Roles that are granted access */
|
|
15
|
+
allowedRoles: string[];
|
|
16
|
+
/** Specific users granted access (overrides roles) */
|
|
17
|
+
allowedUsers: string[];
|
|
18
|
+
/** Access level granted */
|
|
19
|
+
accessLevel: AccessLevel;
|
|
20
|
+
enabled: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface AccessCheckResult {
|
|
23
|
+
allowed: boolean;
|
|
24
|
+
reason?: string;
|
|
25
|
+
matchedPolicy?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface UserContext {
|
|
28
|
+
userId: string;
|
|
29
|
+
roles: string[];
|
|
30
|
+
department?: string;
|
|
31
|
+
}
|
|
32
|
+
export declare class PolicyEngine {
|
|
33
|
+
private policies;
|
|
34
|
+
constructor(policies?: AccessPolicy[]);
|
|
35
|
+
addPolicy(policy: AccessPolicy): void;
|
|
36
|
+
removePolicy(id: string): void;
|
|
37
|
+
listPolicies(): AccessPolicy[];
|
|
38
|
+
/**
|
|
39
|
+
* Check if a user can access a block in a given domain with a given classification.
|
|
40
|
+
*/
|
|
41
|
+
checkAccess(user: UserContext, domain: string, classification: DataClassification, requiredLevel?: AccessLevel): AccessCheckResult;
|
|
42
|
+
/**
|
|
43
|
+
* Get the effective classification for a set of table/column references.
|
|
44
|
+
* In production, this would query a data catalog.
|
|
45
|
+
*/
|
|
46
|
+
classifyData(tables: string[], classificationMap: Record<string, DataClassification>): DataClassification;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=policy-engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy-engine.d.ts","sourceRoot":"","sources":["../src/policy-engine.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,UAAU,GAAG,cAAc,GAAG,YAAY,CAAC;AAEvF,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,OAAO,CAAC;AAEjE,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,oDAAoD;IACpD,MAAM,EAAE,MAAM,CAAC;IACf,iDAAiD;IACjD,iBAAiB,EAAE,kBAAkB,CAAC;IACtC,oCAAoC;IACpC,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,sDAAsD;IACtD,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,2BAA2B;IAC3B,WAAW,EAAE,WAAW,CAAC;IACzB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AASD,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAsB;gBAE1B,QAAQ,CAAC,EAAE,YAAY,EAAE;IAIrC,SAAS,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI;IAIrC,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAI9B,YAAY,IAAI,YAAY,EAAE;IAI9B;;OAEG;IACH,WAAW,CACT,IAAI,EAAE,WAAW,EACjB,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,kBAAkB,EAClC,aAAa,GAAE,WAAoB,GAClC,iBAAiB;IAyCpB;;;OAGG;IACH,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,GAAG,kBAAkB;CAU1G"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PolicyEngine enforces access policies and data classification rules.
|
|
3
|
+
*/
|
|
4
|
+
const CLASSIFICATION_RANK = {
|
|
5
|
+
public: 0,
|
|
6
|
+
internal: 1,
|
|
7
|
+
confidential: 2,
|
|
8
|
+
restricted: 3,
|
|
9
|
+
};
|
|
10
|
+
export class PolicyEngine {
|
|
11
|
+
policies = [];
|
|
12
|
+
constructor(policies) {
|
|
13
|
+
if (policies)
|
|
14
|
+
this.policies = [...policies];
|
|
15
|
+
}
|
|
16
|
+
addPolicy(policy) {
|
|
17
|
+
this.policies.push(policy);
|
|
18
|
+
}
|
|
19
|
+
removePolicy(id) {
|
|
20
|
+
this.policies = this.policies.filter((p) => p.id !== id);
|
|
21
|
+
}
|
|
22
|
+
listPolicies() {
|
|
23
|
+
return [...this.policies];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Check if a user can access a block in a given domain with a given classification.
|
|
27
|
+
*/
|
|
28
|
+
checkAccess(user, domain, classification, requiredLevel = 'read') {
|
|
29
|
+
// Find applicable policies (domain match or wildcard)
|
|
30
|
+
const applicable = this.policies.filter((p) => p.enabled && (p.domain === '*' || p.domain === domain));
|
|
31
|
+
if (applicable.length === 0) {
|
|
32
|
+
// No policies = default allow (open by default)
|
|
33
|
+
return { allowed: true, reason: 'No policies restrict this domain' };
|
|
34
|
+
}
|
|
35
|
+
// Check each policy
|
|
36
|
+
for (const policy of applicable) {
|
|
37
|
+
// Check classification level
|
|
38
|
+
if (CLASSIFICATION_RANK[classification] < CLASSIFICATION_RANK[policy.minClassification]) {
|
|
39
|
+
continue; // This policy doesn't apply to this classification level
|
|
40
|
+
}
|
|
41
|
+
// Check if user is explicitly allowed
|
|
42
|
+
if (policy.allowedUsers.includes(user.userId)) {
|
|
43
|
+
if (accessLevelSufficient(policy.accessLevel, requiredLevel)) {
|
|
44
|
+
return { allowed: true, matchedPolicy: policy.id };
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
// Check if user has an allowed role
|
|
48
|
+
const hasRole = user.roles.some((r) => policy.allowedRoles.includes(r));
|
|
49
|
+
if (hasRole) {
|
|
50
|
+
if (accessLevelSufficient(policy.accessLevel, requiredLevel)) {
|
|
51
|
+
return { allowed: true, matchedPolicy: policy.id };
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
// If we have policies but none matched, deny
|
|
56
|
+
return {
|
|
57
|
+
allowed: false,
|
|
58
|
+
reason: `No policy grants ${requiredLevel} access to domain "${domain}" with classification "${classification}" for user "${user.userId}"`,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Get the effective classification for a set of table/column references.
|
|
63
|
+
* In production, this would query a data catalog.
|
|
64
|
+
*/
|
|
65
|
+
classifyData(tables, classificationMap) {
|
|
66
|
+
let highest = 'public';
|
|
67
|
+
for (const table of tables) {
|
|
68
|
+
const cls = classificationMap[table];
|
|
69
|
+
if (cls && CLASSIFICATION_RANK[cls] > CLASSIFICATION_RANK[highest]) {
|
|
70
|
+
highest = cls;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return highest;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
const ACCESS_LEVEL_RANK = {
|
|
77
|
+
read: 0,
|
|
78
|
+
write: 1,
|
|
79
|
+
execute: 2,
|
|
80
|
+
admin: 3,
|
|
81
|
+
};
|
|
82
|
+
function accessLevelSufficient(granted, required) {
|
|
83
|
+
return ACCESS_LEVEL_RANK[granted] >= ACCESS_LEVEL_RANK[required];
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=policy-engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy-engine.js","sourceRoot":"","sources":["../src/policy-engine.ts"],"names":[],"mappings":"AAAA;;GAEG;AAmCH,MAAM,mBAAmB,GAAuC;IAC9D,MAAM,EAAE,CAAC;IACT,QAAQ,EAAE,CAAC;IACX,YAAY,EAAE,CAAC;IACf,UAAU,EAAE,CAAC;CACd,CAAC;AAEF,MAAM,OAAO,YAAY;IACf,QAAQ,GAAmB,EAAE,CAAC;IAEtC,YAAY,QAAyB;QACnC,IAAI,QAAQ;YAAE,IAAI,CAAC,QAAQ,GAAG,CAAC,GAAG,QAAQ,CAAC,CAAC;IAC9C,CAAC;IAED,SAAS,CAAC,MAAoB;QAC5B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC7B,CAAC;IAED,YAAY,CAAC,EAAU;QACrB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IAC3D,CAAC;IAED,YAAY;QACV,OAAO,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,WAAW,CACT,IAAiB,EACjB,MAAc,EACd,cAAkC,EAClC,gBAA6B,MAAM;QAEnC,sDAA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CAAC;YACH,CAAC;QACH,CAAC;QAED,6CAA6C;QAC7C,OAAO;YACL,OAAO,EAAE,KAAK;YACd,MAAM,EAAE,oBAAoB,aAAa,sBAAsB,MAAM,0BAA0B,cAAc,eAAe,IAAI,CAAC,MAAM,GAAG;SAC3I,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,YAAY,CAAC,MAAgB,EAAE,iBAAqD;QAClF,IAAI,OAAO,GAAuB,QAAQ,CAAC;QAC3C,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YAC3B,MAAM,GAAG,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC;YACrC,IAAI,GAAG,IAAI,mBAAmB,CAAC,GAAG,CAAC,GAAG,mBAAmB,CAAC,OAAO,CAAC,EAAE,CAAC;gBACnE,OAAO,GAAG,GAAG,CAAC;YAChB,CAAC;QACH,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AAED,MAAM,iBAAiB,GAAgC;IACrD,IAAI,EAAE,CAAC;IACP,KAAK,EAAE,CAAC;IACR,OAAO,EAAE,CAAC;IACV,KAAK,EAAE,CAAC;CACT,CAAC;AAEF,SAAS,qBAAqB,CAAC,OAAoB,EAAE,QAAqB;IACxE,OAAO,iBAAiB,CAAC,OAAO,CAAC,IAAI,iBAAiB,CAAC,QAAQ,CAAC,CAAC;AACnE,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { TestResultSummary } from '@duckcodeailabs/dql-project';
|
|
2
|
+
/**
|
|
3
|
+
* A block test assertion parsed from DQL `tests { assert ... }` blocks.
|
|
4
|
+
*/
|
|
5
|
+
export interface BlockTestAssertion {
|
|
6
|
+
name: string;
|
|
7
|
+
sql: string;
|
|
8
|
+
operator: '>' | '<' | '>=' | '<=' | '==' | '!=' | 'IN';
|
|
9
|
+
threshold: number | string | boolean | Array<number | string | boolean>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* QueryExecutor is an adapter interface for running SQL queries.
|
|
13
|
+
* Implementations can use DuckDB, Postgres, etc.
|
|
14
|
+
*/
|
|
15
|
+
export interface QueryExecutor {
|
|
16
|
+
execute(sql: string, params?: Record<string, unknown>): Promise<Record<string, unknown>[]>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* TestRunner executes block test assertions against a database.
|
|
20
|
+
*/
|
|
21
|
+
export declare class TestRunner {
|
|
22
|
+
private executor;
|
|
23
|
+
constructor(executor: QueryExecutor);
|
|
24
|
+
/**
|
|
25
|
+
* Run all assertions for a block and return a summary.
|
|
26
|
+
*/
|
|
27
|
+
runTests(assertions: BlockTestAssertion[], params?: Record<string, unknown>): Promise<TestResultSummary>;
|
|
28
|
+
/**
|
|
29
|
+
* Run a single assertion.
|
|
30
|
+
*/
|
|
31
|
+
private runAssertion;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=test-runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-runner.d.ts","sourceRoot":"","sources":["../src/test-runner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAuB,MAAM,6BAA6B,CAAC;AAE1F;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,GAAG,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IACvD,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;CACzE;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC;CAC5F;AAED;;GAEG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAgB;gBAEpB,QAAQ,EAAE,aAAa;IAInC;;OAEG;IACG,QAAQ,CACZ,UAAU,EAAE,kBAAkB,EAAE,EAChC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,OAAO,CAAC,iBAAiB,CAAC;IAgC7B;;OAEG;YACW,YAAY;CA4B3B"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TestRunner executes block test assertions against a database.
|
|
3
|
+
*/
|
|
4
|
+
export class TestRunner {
|
|
5
|
+
executor;
|
|
6
|
+
constructor(executor) {
|
|
7
|
+
this.executor = executor;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Run all assertions for a block and return a summary.
|
|
11
|
+
*/
|
|
12
|
+
async runTests(assertions, params) {
|
|
13
|
+
const start = Date.now();
|
|
14
|
+
const results = [];
|
|
15
|
+
let passed = 0;
|
|
16
|
+
let failed = 0;
|
|
17
|
+
for (const assertion of assertions) {
|
|
18
|
+
try {
|
|
19
|
+
const result = await this.runAssertion(assertion, params);
|
|
20
|
+
results.push(result);
|
|
21
|
+
if (result.passed)
|
|
22
|
+
passed++;
|
|
23
|
+
else
|
|
24
|
+
failed++;
|
|
25
|
+
}
|
|
26
|
+
catch (err) {
|
|
27
|
+
results.push({
|
|
28
|
+
name: assertion.name,
|
|
29
|
+
passed: false,
|
|
30
|
+
error: err instanceof Error ? err.message : String(err),
|
|
31
|
+
});
|
|
32
|
+
failed++;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
passed,
|
|
37
|
+
failed,
|
|
38
|
+
skipped: 0,
|
|
39
|
+
duration: Date.now() - start,
|
|
40
|
+
assertions: results,
|
|
41
|
+
runAt: new Date(),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Run a single assertion.
|
|
46
|
+
*/
|
|
47
|
+
async runAssertion(assertion, params) {
|
|
48
|
+
const rows = await this.executor.execute(assertion.sql, params);
|
|
49
|
+
if (rows.length === 0) {
|
|
50
|
+
return {
|
|
51
|
+
name: assertion.name,
|
|
52
|
+
passed: false,
|
|
53
|
+
error: 'Query returned no rows',
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
// The assertion SQL should return a single scalar value
|
|
57
|
+
const firstRow = rows[0];
|
|
58
|
+
const keys = Object.keys(firstRow);
|
|
59
|
+
const rawActual = firstRow[keys[0]];
|
|
60
|
+
const comparison = compare(rawActual, assertion.operator, assertion.threshold);
|
|
61
|
+
return {
|
|
62
|
+
name: assertion.name,
|
|
63
|
+
passed: comparison.passed,
|
|
64
|
+
actual: rawActual,
|
|
65
|
+
expected: assertion.threshold,
|
|
66
|
+
error: comparison.error,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function compare(actual, op, threshold) {
|
|
71
|
+
if (op === 'IN') {
|
|
72
|
+
if (!Array.isArray(threshold)) {
|
|
73
|
+
return { passed: false, error: 'IN operator requires an array expected value' };
|
|
74
|
+
}
|
|
75
|
+
const pass = threshold.some((candidate) => candidate === actual);
|
|
76
|
+
return {
|
|
77
|
+
passed: pass,
|
|
78
|
+
error: pass ? undefined : `${String(actual)} IN ${JSON.stringify(threshold)} is false`,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
const actualNumber = Number(actual);
|
|
82
|
+
const thresholdNumber = Number(threshold);
|
|
83
|
+
if (!Number.isFinite(actualNumber) || !Number.isFinite(thresholdNumber)) {
|
|
84
|
+
return {
|
|
85
|
+
passed: false,
|
|
86
|
+
error: `Operator '${op}' requires numeric values (actual=${String(actual)}, expected=${String(threshold)})`,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
switch (op) {
|
|
90
|
+
case '>':
|
|
91
|
+
return {
|
|
92
|
+
passed: actualNumber > thresholdNumber,
|
|
93
|
+
error: actualNumber > thresholdNumber ? undefined : `${actualNumber} > ${thresholdNumber} is false`,
|
|
94
|
+
};
|
|
95
|
+
case '<':
|
|
96
|
+
return {
|
|
97
|
+
passed: actualNumber < thresholdNumber,
|
|
98
|
+
error: actualNumber < thresholdNumber ? undefined : `${actualNumber} < ${thresholdNumber} is false`,
|
|
99
|
+
};
|
|
100
|
+
case '>=':
|
|
101
|
+
return {
|
|
102
|
+
passed: actualNumber >= thresholdNumber,
|
|
103
|
+
error: actualNumber >= thresholdNumber ? undefined : `${actualNumber} >= ${thresholdNumber} is false`,
|
|
104
|
+
};
|
|
105
|
+
case '<=':
|
|
106
|
+
return {
|
|
107
|
+
passed: actualNumber <= thresholdNumber,
|
|
108
|
+
error: actualNumber <= thresholdNumber ? undefined : `${actualNumber} <= ${thresholdNumber} is false`,
|
|
109
|
+
};
|
|
110
|
+
case '==':
|
|
111
|
+
return {
|
|
112
|
+
passed: actualNumber === thresholdNumber,
|
|
113
|
+
error: actualNumber === thresholdNumber ? undefined : `${actualNumber} == ${thresholdNumber} is false`,
|
|
114
|
+
};
|
|
115
|
+
case '!=':
|
|
116
|
+
return {
|
|
117
|
+
passed: actualNumber !== thresholdNumber,
|
|
118
|
+
error: actualNumber !== thresholdNumber ? undefined : `${actualNumber} != ${thresholdNumber} is false`,
|
|
119
|
+
};
|
|
120
|
+
default:
|
|
121
|
+
return { passed: false, error: `Unsupported operator '${op}'` };
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=test-runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-runner.js","sourceRoot":"","sources":["../src/test-runner.ts"],"names":[],"mappings":"AAoBA;;GAEG;AACH,MAAM,OAAO,UAAU;IACb,QAAQ,CAAgB;IAEhC,YAAY,QAAuB;QACjC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,QAAQ,CACZ,UA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C,CAAC,CAAC,GAAG,YAAY,OAAO,eAAe,WAAW;aACvG,CAAC;QACJ,KAAK,IAAI;YACP,OAAO;gBACL,MAAM,EAAE,YAAY,KAAK,eAAe;gBACxC,KAAK,EAAE,YAAY,KAAK,eAAe,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,YAAY,OAAO,eAAe,WAAW;aACvG,CAAC;QACJ;YACE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,yBAAyB,EAAE,GAAG,EAAE,CAAC;IACpE,CAAC;AACH,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@duckcodeailabs/dql-governance",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "DQL Governance: block testing, certification, cost estimation, and access policies",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "https://github.com/duckcode-ai/dql.git",
|
|
21
|
+
"directory": "packages/dql-governance"
|
|
22
|
+
},
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@duckcodeailabs/dql-core": "0.1.0",
|
|
28
|
+
"@duckcodeailabs/dql-project": "0.1.0"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"typescript": "^5.7.0",
|
|
32
|
+
"vitest": "^3.0.0"
|
|
33
|
+
},
|
|
34
|
+
"engines": {
|
|
35
|
+
"node": ">=18.0.0"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "rm -rf dist tsconfig.tsbuildinfo && tsc -b",
|
|
39
|
+
"test": "vitest run --passWithNoTests",
|
|
40
|
+
"clean": "rm -rf dist tsconfig.tsbuildinfo"
|
|
41
|
+
}
|
|
42
|
+
}
|