@dogfood-lab/findings 1.2.2 → 1.2.3
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/advise/advice-bundle.js +155 -155
- package/advise/index.js +5 -5
- package/advise/query.js +182 -182
- package/derive/dedupe.js +107 -107
- package/derive/derive-findings.js +187 -187
- package/derive/ids.js +48 -48
- package/derive/index.js +9 -9
- package/derive/load-records.js +153 -153
- package/derive/rules.js +415 -415
- package/derive/write-findings.js +63 -63
- package/index.js +11 -11
- package/lib/file-lock.js +359 -359
- package/package.json +2 -2
- package/reader.js +156 -156
- package/review/index.js +6 -6
- package/review/transitions.js +79 -79
- package/synthesis/doctrine-derivation.js +128 -128
- package/synthesis/index.js +8 -8
- package/synthesis/pattern-derivation.js +184 -184
- package/synthesis/recommendation-derivation.js +156 -156
- package/synthesis/validate-artifacts.js +46 -46
- package/synthesis/write-artifacts.js +75 -75
- package/validate.js +87 -87
package/derive/write-findings.js
CHANGED
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Write derived candidate findings to disk as YAML files.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { mkdirSync, existsSync } from 'node:fs';
|
|
6
|
-
import { resolve, dirname } from 'node:path';
|
|
7
|
-
import yaml from 'js-yaml';
|
|
8
|
-
|
|
9
|
-
import { atomicWriteFileSync } from '../lib/atomic-write.js';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Write a candidate finding to its canonical location.
|
|
13
|
-
*
|
|
14
|
-
* findings/<org>/<repo>/<finding_id>.yaml
|
|
15
|
-
*
|
|
16
|
-
* @param {string} rootDir - dogfood-labs repo root.
|
|
17
|
-
* @param {object} finding - Schema-valid candidate finding object.
|
|
18
|
-
* @returns {string} - Path written.
|
|
19
|
-
*/
|
|
20
|
-
export function writeFinding(rootDir, finding) {
|
|
21
|
-
const [org, repo] = (finding.repo || '').split('/');
|
|
22
|
-
if (!org || !repo) throw new Error(`Invalid repo in finding: ${finding.repo}`);
|
|
23
|
-
|
|
24
|
-
const dir = resolve(rootDir, 'findings', org, repo);
|
|
25
|
-
mkdirSync(dir, { recursive: true });
|
|
26
|
-
|
|
27
|
-
const filePath = resolve(dir, `${finding.finding_id}.yaml`);
|
|
28
|
-
|
|
29
|
-
// Strip undefined values for clean YAML
|
|
30
|
-
const clean = JSON.parse(JSON.stringify(finding));
|
|
31
|
-
const yamlStr = yaml.dump(clean, {
|
|
32
|
-
lineWidth: 120,
|
|
33
|
-
noRefs: true,
|
|
34
|
-
quotingType: '"',
|
|
35
|
-
forceQuotes: false
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
atomicWriteFileSync(filePath, yamlStr);
|
|
39
|
-
return filePath;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Write multiple findings and return write stats.
|
|
44
|
-
*
|
|
45
|
-
* @param {string} rootDir
|
|
46
|
-
* @param {Array} findings
|
|
47
|
-
* @returns {{ written: string[], errors: Array<{ findingId: string, error: string }> }}
|
|
48
|
-
*/
|
|
49
|
-
export function writeFindings(rootDir, findings) {
|
|
50
|
-
const written = [];
|
|
51
|
-
const errors = [];
|
|
52
|
-
|
|
53
|
-
for (const f of findings) {
|
|
54
|
-
try {
|
|
55
|
-
const path = writeFinding(rootDir, f);
|
|
56
|
-
written.push(path);
|
|
57
|
-
} catch (err) {
|
|
58
|
-
errors.push({ findingId: f.finding_id, error: err.message });
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return { written, errors };
|
|
63
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Write derived candidate findings to disk as YAML files.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { mkdirSync, existsSync } from 'node:fs';
|
|
6
|
+
import { resolve, dirname } from 'node:path';
|
|
7
|
+
import yaml from 'js-yaml';
|
|
8
|
+
|
|
9
|
+
import { atomicWriteFileSync } from '../lib/atomic-write.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Write a candidate finding to its canonical location.
|
|
13
|
+
*
|
|
14
|
+
* findings/<org>/<repo>/<finding_id>.yaml
|
|
15
|
+
*
|
|
16
|
+
* @param {string} rootDir - dogfood-labs repo root.
|
|
17
|
+
* @param {object} finding - Schema-valid candidate finding object.
|
|
18
|
+
* @returns {string} - Path written.
|
|
19
|
+
*/
|
|
20
|
+
export function writeFinding(rootDir, finding) {
|
|
21
|
+
const [org, repo] = (finding.repo || '').split('/');
|
|
22
|
+
if (!org || !repo) throw new Error(`Invalid repo in finding: ${finding.repo}`);
|
|
23
|
+
|
|
24
|
+
const dir = resolve(rootDir, 'findings', org, repo);
|
|
25
|
+
mkdirSync(dir, { recursive: true });
|
|
26
|
+
|
|
27
|
+
const filePath = resolve(dir, `${finding.finding_id}.yaml`);
|
|
28
|
+
|
|
29
|
+
// Strip undefined values for clean YAML
|
|
30
|
+
const clean = JSON.parse(JSON.stringify(finding));
|
|
31
|
+
const yamlStr = yaml.dump(clean, {
|
|
32
|
+
lineWidth: 120,
|
|
33
|
+
noRefs: true,
|
|
34
|
+
quotingType: '"',
|
|
35
|
+
forceQuotes: false
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
atomicWriteFileSync(filePath, yamlStr);
|
|
39
|
+
return filePath;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Write multiple findings and return write stats.
|
|
44
|
+
*
|
|
45
|
+
* @param {string} rootDir
|
|
46
|
+
* @param {Array} findings
|
|
47
|
+
* @returns {{ written: string[], errors: Array<{ findingId: string, error: string }> }}
|
|
48
|
+
*/
|
|
49
|
+
export function writeFindings(rootDir, findings) {
|
|
50
|
+
const written = [];
|
|
51
|
+
const errors = [];
|
|
52
|
+
|
|
53
|
+
for (const f of findings) {
|
|
54
|
+
try {
|
|
55
|
+
const path = writeFinding(rootDir, f);
|
|
56
|
+
written.push(path);
|
|
57
|
+
} catch (err) {
|
|
58
|
+
errors.push({ findingId: f.finding_id, error: err.message });
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return { written, errors };
|
|
63
|
+
}
|
package/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @dogfood-labs/findings
|
|
3
|
-
*
|
|
4
|
-
* Finding contract spine for dogfood-labs.
|
|
5
|
-
* The fourth contract alongside record, scenario, and policy.
|
|
6
|
-
*
|
|
7
|
-
* Exports: validation, reading, listing, filtering, duplicate detection.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
export { parseFinding, validateFinding, validateFindingFile } from './validate.js';
|
|
11
|
-
export { discoverFindings, discoverFixtures, loadFindings, findById, filterFindings, findDuplicates } from './reader.js';
|
|
1
|
+
/**
|
|
2
|
+
* @dogfood-labs/findings
|
|
3
|
+
*
|
|
4
|
+
* Finding contract spine for dogfood-labs.
|
|
5
|
+
* The fourth contract alongside record, scenario, and policy.
|
|
6
|
+
*
|
|
7
|
+
* Exports: validation, reading, listing, filtering, duplicate detection.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export { parseFinding, validateFinding, validateFindingFile } from './validate.js';
|
|
11
|
+
export { discoverFindings, discoverFixtures, loadFindings, findById, filterFindings, findDuplicates } from './reader.js';
|