@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/advise/advice-bundle.js
CHANGED
|
@@ -1,155 +1,155 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Advice bundle synthesis.
|
|
3
|
-
*
|
|
4
|
-
* Produces structured guidance bundles for future projects
|
|
5
|
-
* based on surface, execution mode, and archetype.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
queryFindings,
|
|
10
|
-
queryPatterns,
|
|
11
|
-
queryRecommendations,
|
|
12
|
-
queryDoctrine,
|
|
13
|
-
queryFailureClasses
|
|
14
|
-
} from './query.js';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Generate an advice bundle for a given scope.
|
|
18
|
-
*
|
|
19
|
-
* @param {string} rootDir - dogfood-labs repo root
|
|
20
|
-
* @param {object} scope
|
|
21
|
-
* @param {string} [scope.surface] - product surface
|
|
22
|
-
* @param {string} [scope.executionMode] - bot/human/mixed
|
|
23
|
-
* @param {string} [scope.repo] - specific repo
|
|
24
|
-
* @param {string} [scope.journeyStage] - journey stage filter
|
|
25
|
-
* @param {string} [scope.issueKind] - issue kind filter
|
|
26
|
-
* @returns {object} Structured advice bundle
|
|
27
|
-
*/
|
|
28
|
-
export function generateAdviceBundle(rootDir, scope = {}) {
|
|
29
|
-
const recommendations = queryRecommendations(rootDir, scope);
|
|
30
|
-
const doctrine = queryDoctrine(rootDir, scope);
|
|
31
|
-
const patterns = queryPatterns(rootDir, scope);
|
|
32
|
-
const failureClasses = queryFailureClasses(rootDir, scope);
|
|
33
|
-
const findings = queryFindings(rootDir, { ...scope, limit: 8 });
|
|
34
|
-
|
|
35
|
-
// Categorize recommendations by kind
|
|
36
|
-
const starterChecks = recommendations.filter(r =>
|
|
37
|
-
r.recommendation_kind === 'starter_check' || r.recommendation_kind === 'starter_scenario'
|
|
38
|
-
);
|
|
39
|
-
const evidenceExpectations = recommendations.filter(r =>
|
|
40
|
-
r.recommendation_kind === 'evidence_expectation' || r.recommendation_kind === 'policy_seed'
|
|
41
|
-
);
|
|
42
|
-
const verificationRules = recommendations.filter(r =>
|
|
43
|
-
r.recommendation_kind === 'verification_rule' || r.recommendation_kind === 'review_prompt'
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
return {
|
|
47
|
-
query: {
|
|
48
|
-
product_surface: scope.surface || null,
|
|
49
|
-
execution_mode: scope.executionMode || null,
|
|
50
|
-
repo: scope.repo || null
|
|
51
|
-
},
|
|
52
|
-
advice: {
|
|
53
|
-
starter_checks: starterChecks.map(r => ({
|
|
54
|
-
id: r.recommendation_id,
|
|
55
|
-
title: r.title,
|
|
56
|
-
action: r.action,
|
|
57
|
-
confidence: r.confidence
|
|
58
|
-
})),
|
|
59
|
-
evidence_expectations: evidenceExpectations.map(r => ({
|
|
60
|
-
id: r.recommendation_id,
|
|
61
|
-
title: r.title,
|
|
62
|
-
action: r.action,
|
|
63
|
-
confidence: r.confidence
|
|
64
|
-
})),
|
|
65
|
-
verification_rules: verificationRules.map(r => ({
|
|
66
|
-
id: r.recommendation_id,
|
|
67
|
-
title: r.title,
|
|
68
|
-
action: r.action,
|
|
69
|
-
confidence: r.confidence
|
|
70
|
-
})),
|
|
71
|
-
likely_failure_classes: failureClasses,
|
|
72
|
-
relevant_doctrine: doctrine.map(d => ({
|
|
73
|
-
id: d.doctrine_id,
|
|
74
|
-
statement: d.statement,
|
|
75
|
-
strength: d.strength,
|
|
76
|
-
kind: d.doctrine_kind
|
|
77
|
-
}))
|
|
78
|
-
},
|
|
79
|
-
support: {
|
|
80
|
-
pattern_ids: patterns.map(p => p.pattern_id),
|
|
81
|
-
finding_ids: findings.map(f => f.finding_id),
|
|
82
|
-
pattern_count: patterns.length,
|
|
83
|
-
finding_count: findings.length,
|
|
84
|
-
recommendation_count: recommendations.length,
|
|
85
|
-
doctrine_count: doctrine.length
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Generate a sync-friendly export of all accepted artifacts.
|
|
92
|
-
* For repo-knowledge consumption.
|
|
93
|
-
*
|
|
94
|
-
* @param {string} rootDir
|
|
95
|
-
* @returns {object} Export bundle with all accepted artifacts and lineage
|
|
96
|
-
*/
|
|
97
|
-
export function generateSyncExport(rootDir) {
|
|
98
|
-
const findings = queryFindings(rootDir, { limit: 500 });
|
|
99
|
-
const patterns = queryPatterns(rootDir, { limit: 100 });
|
|
100
|
-
const recommendations = queryRecommendations(rootDir, { limit: 100 });
|
|
101
|
-
const doctrine = queryDoctrine(rootDir, { limit: 100 });
|
|
102
|
-
|
|
103
|
-
return {
|
|
104
|
-
exported_at: new Date().toISOString(),
|
|
105
|
-
source: 'dogfood-labs',
|
|
106
|
-
counts: {
|
|
107
|
-
findings: findings.length,
|
|
108
|
-
patterns: patterns.length,
|
|
109
|
-
recommendations: recommendations.length,
|
|
110
|
-
doctrine: doctrine.length
|
|
111
|
-
},
|
|
112
|
-
findings: findings.map(f => ({
|
|
113
|
-
finding_id: f.finding_id,
|
|
114
|
-
title: f.title,
|
|
115
|
-
repo: f.repo,
|
|
116
|
-
product_surface: f.product_surface,
|
|
117
|
-
issue_kind: f.issue_kind,
|
|
118
|
-
root_cause_kind: f.root_cause_kind,
|
|
119
|
-
remediation_kind: f.remediation_kind,
|
|
120
|
-
transfer_scope: f.transfer_scope,
|
|
121
|
-
summary: f.summary,
|
|
122
|
-
doctrine_statement: f.doctrine_statement
|
|
123
|
-
})),
|
|
124
|
-
patterns: patterns.map(p => ({
|
|
125
|
-
pattern_id: p.pattern_id,
|
|
126
|
-
title: p.title,
|
|
127
|
-
pattern_kind: p.pattern_kind,
|
|
128
|
-
pattern_strength: p.pattern_strength,
|
|
129
|
-
transfer_scope: p.transfer_scope,
|
|
130
|
-
summary: p.summary,
|
|
131
|
-
source_finding_ids: p.source_finding_ids,
|
|
132
|
-
dimensions: p.dimensions,
|
|
133
|
-
support: p.support
|
|
134
|
-
})),
|
|
135
|
-
recommendations: recommendations.map(r => ({
|
|
136
|
-
recommendation_id: r.recommendation_id,
|
|
137
|
-
title: r.title,
|
|
138
|
-
recommendation_kind: r.recommendation_kind,
|
|
139
|
-
confidence: r.confidence,
|
|
140
|
-
applies_to: r.applies_to,
|
|
141
|
-
action: r.action,
|
|
142
|
-
based_on_pattern_ids: r.based_on_pattern_ids
|
|
143
|
-
})),
|
|
144
|
-
doctrine: doctrine.map(d => ({
|
|
145
|
-
doctrine_id: d.doctrine_id,
|
|
146
|
-
title: d.title,
|
|
147
|
-
doctrine_kind: d.doctrine_kind,
|
|
148
|
-
strength: d.strength,
|
|
149
|
-
statement: d.statement,
|
|
150
|
-
rationale: d.rationale,
|
|
151
|
-
transfer_scope: d.transfer_scope,
|
|
152
|
-
based_on_pattern_ids: d.based_on_pattern_ids
|
|
153
|
-
}))
|
|
154
|
-
};
|
|
155
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Advice bundle synthesis.
|
|
3
|
+
*
|
|
4
|
+
* Produces structured guidance bundles for future projects
|
|
5
|
+
* based on surface, execution mode, and archetype.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
queryFindings,
|
|
10
|
+
queryPatterns,
|
|
11
|
+
queryRecommendations,
|
|
12
|
+
queryDoctrine,
|
|
13
|
+
queryFailureClasses
|
|
14
|
+
} from './query.js';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Generate an advice bundle for a given scope.
|
|
18
|
+
*
|
|
19
|
+
* @param {string} rootDir - dogfood-labs repo root
|
|
20
|
+
* @param {object} scope
|
|
21
|
+
* @param {string} [scope.surface] - product surface
|
|
22
|
+
* @param {string} [scope.executionMode] - bot/human/mixed
|
|
23
|
+
* @param {string} [scope.repo] - specific repo
|
|
24
|
+
* @param {string} [scope.journeyStage] - journey stage filter
|
|
25
|
+
* @param {string} [scope.issueKind] - issue kind filter
|
|
26
|
+
* @returns {object} Structured advice bundle
|
|
27
|
+
*/
|
|
28
|
+
export function generateAdviceBundle(rootDir, scope = {}) {
|
|
29
|
+
const recommendations = queryRecommendations(rootDir, scope);
|
|
30
|
+
const doctrine = queryDoctrine(rootDir, scope);
|
|
31
|
+
const patterns = queryPatterns(rootDir, scope);
|
|
32
|
+
const failureClasses = queryFailureClasses(rootDir, scope);
|
|
33
|
+
const findings = queryFindings(rootDir, { ...scope, limit: 8 });
|
|
34
|
+
|
|
35
|
+
// Categorize recommendations by kind
|
|
36
|
+
const starterChecks = recommendations.filter(r =>
|
|
37
|
+
r.recommendation_kind === 'starter_check' || r.recommendation_kind === 'starter_scenario'
|
|
38
|
+
);
|
|
39
|
+
const evidenceExpectations = recommendations.filter(r =>
|
|
40
|
+
r.recommendation_kind === 'evidence_expectation' || r.recommendation_kind === 'policy_seed'
|
|
41
|
+
);
|
|
42
|
+
const verificationRules = recommendations.filter(r =>
|
|
43
|
+
r.recommendation_kind === 'verification_rule' || r.recommendation_kind === 'review_prompt'
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
query: {
|
|
48
|
+
product_surface: scope.surface || null,
|
|
49
|
+
execution_mode: scope.executionMode || null,
|
|
50
|
+
repo: scope.repo || null
|
|
51
|
+
},
|
|
52
|
+
advice: {
|
|
53
|
+
starter_checks: starterChecks.map(r => ({
|
|
54
|
+
id: r.recommendation_id,
|
|
55
|
+
title: r.title,
|
|
56
|
+
action: r.action,
|
|
57
|
+
confidence: r.confidence
|
|
58
|
+
})),
|
|
59
|
+
evidence_expectations: evidenceExpectations.map(r => ({
|
|
60
|
+
id: r.recommendation_id,
|
|
61
|
+
title: r.title,
|
|
62
|
+
action: r.action,
|
|
63
|
+
confidence: r.confidence
|
|
64
|
+
})),
|
|
65
|
+
verification_rules: verificationRules.map(r => ({
|
|
66
|
+
id: r.recommendation_id,
|
|
67
|
+
title: r.title,
|
|
68
|
+
action: r.action,
|
|
69
|
+
confidence: r.confidence
|
|
70
|
+
})),
|
|
71
|
+
likely_failure_classes: failureClasses,
|
|
72
|
+
relevant_doctrine: doctrine.map(d => ({
|
|
73
|
+
id: d.doctrine_id,
|
|
74
|
+
statement: d.statement,
|
|
75
|
+
strength: d.strength,
|
|
76
|
+
kind: d.doctrine_kind
|
|
77
|
+
}))
|
|
78
|
+
},
|
|
79
|
+
support: {
|
|
80
|
+
pattern_ids: patterns.map(p => p.pattern_id),
|
|
81
|
+
finding_ids: findings.map(f => f.finding_id),
|
|
82
|
+
pattern_count: patterns.length,
|
|
83
|
+
finding_count: findings.length,
|
|
84
|
+
recommendation_count: recommendations.length,
|
|
85
|
+
doctrine_count: doctrine.length
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Generate a sync-friendly export of all accepted artifacts.
|
|
92
|
+
* For repo-knowledge consumption.
|
|
93
|
+
*
|
|
94
|
+
* @param {string} rootDir
|
|
95
|
+
* @returns {object} Export bundle with all accepted artifacts and lineage
|
|
96
|
+
*/
|
|
97
|
+
export function generateSyncExport(rootDir) {
|
|
98
|
+
const findings = queryFindings(rootDir, { limit: 500 });
|
|
99
|
+
const patterns = queryPatterns(rootDir, { limit: 100 });
|
|
100
|
+
const recommendations = queryRecommendations(rootDir, { limit: 100 });
|
|
101
|
+
const doctrine = queryDoctrine(rootDir, { limit: 100 });
|
|
102
|
+
|
|
103
|
+
return {
|
|
104
|
+
exported_at: new Date().toISOString(),
|
|
105
|
+
source: 'dogfood-labs',
|
|
106
|
+
counts: {
|
|
107
|
+
findings: findings.length,
|
|
108
|
+
patterns: patterns.length,
|
|
109
|
+
recommendations: recommendations.length,
|
|
110
|
+
doctrine: doctrine.length
|
|
111
|
+
},
|
|
112
|
+
findings: findings.map(f => ({
|
|
113
|
+
finding_id: f.finding_id,
|
|
114
|
+
title: f.title,
|
|
115
|
+
repo: f.repo,
|
|
116
|
+
product_surface: f.product_surface,
|
|
117
|
+
issue_kind: f.issue_kind,
|
|
118
|
+
root_cause_kind: f.root_cause_kind,
|
|
119
|
+
remediation_kind: f.remediation_kind,
|
|
120
|
+
transfer_scope: f.transfer_scope,
|
|
121
|
+
summary: f.summary,
|
|
122
|
+
doctrine_statement: f.doctrine_statement
|
|
123
|
+
})),
|
|
124
|
+
patterns: patterns.map(p => ({
|
|
125
|
+
pattern_id: p.pattern_id,
|
|
126
|
+
title: p.title,
|
|
127
|
+
pattern_kind: p.pattern_kind,
|
|
128
|
+
pattern_strength: p.pattern_strength,
|
|
129
|
+
transfer_scope: p.transfer_scope,
|
|
130
|
+
summary: p.summary,
|
|
131
|
+
source_finding_ids: p.source_finding_ids,
|
|
132
|
+
dimensions: p.dimensions,
|
|
133
|
+
support: p.support
|
|
134
|
+
})),
|
|
135
|
+
recommendations: recommendations.map(r => ({
|
|
136
|
+
recommendation_id: r.recommendation_id,
|
|
137
|
+
title: r.title,
|
|
138
|
+
recommendation_kind: r.recommendation_kind,
|
|
139
|
+
confidence: r.confidence,
|
|
140
|
+
applies_to: r.applies_to,
|
|
141
|
+
action: r.action,
|
|
142
|
+
based_on_pattern_ids: r.based_on_pattern_ids
|
|
143
|
+
})),
|
|
144
|
+
doctrine: doctrine.map(d => ({
|
|
145
|
+
doctrine_id: d.doctrine_id,
|
|
146
|
+
title: d.title,
|
|
147
|
+
doctrine_kind: d.doctrine_kind,
|
|
148
|
+
strength: d.strength,
|
|
149
|
+
statement: d.statement,
|
|
150
|
+
rationale: d.rationale,
|
|
151
|
+
transfer_scope: d.transfer_scope,
|
|
152
|
+
based_on_pattern_ids: d.based_on_pattern_ids
|
|
153
|
+
}))
|
|
154
|
+
};
|
|
155
|
+
}
|
package/advise/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Advise layer exports.
|
|
3
|
-
*/
|
|
4
|
-
export { queryFindings, queryPatterns, queryRecommendations, queryDoctrine, queryFailureClasses } from './query.js';
|
|
5
|
-
export { generateAdviceBundle, generateSyncExport } from './advice-bundle.js';
|
|
1
|
+
/**
|
|
2
|
+
* Advise layer exports.
|
|
3
|
+
*/
|
|
4
|
+
export { queryFindings, queryPatterns, queryRecommendations, queryDoctrine, queryFailureClasses } from './query.js';
|
|
5
|
+
export { generateAdviceBundle, generateSyncExport } from './advice-bundle.js';
|