@olegkoval/agent-skills 1.81.0 → 1.82.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/adapters/claude/olko-github-pr/skills/lekker-review/scripts/defect-policy.mjs +58 -0
- package/package.json +1 -1
- package/plugins/olko-apple-kit/.claude-plugin/plugin.json +1 -1
- package/plugins/olko-creative/.claude-plugin/plugin.json +1 -1
- package/plugins/olko-garmin-kit/.claude-plugin/plugin.json +1 -1
- package/plugins/olko-git-tools/.claude-plugin/plugin.json +1 -1
- package/plugins/olko-github-pr/.claude-plugin/plugin.json +1 -1
- package/plugins/olko-github-pr/skills/lekker-review/scripts/defect-policy.mjs +58 -0
- package/plugins/olko-obsidian/.claude-plugin/plugin.json +1 -1
- package/plugins/olko-product/.claude-plugin/plugin.json +1 -1
- package/plugins/olko-reflection/.claude-plugin/plugin.json +1 -1
- package/plugins/olko-release/.claude-plugin/plugin.json +1 -1
- package/plugins/olko-skill-meta/.claude-plugin/plugin.json +1 -1
- package/plugins/olko-web-ops/.claude-plugin/plugin.json +1 -1
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// Pure validation for frozen defect cases and adjudication records.
|
|
2
|
+
const FULL_SHA = /^[a-f0-9]{40}$/i
|
|
3
|
+
const SHA256 = /^[a-f0-9]{64}$/i
|
|
4
|
+
const RUN_ID = /^[A-Za-z0-9][A-Za-z0-9._-]*$/
|
|
5
|
+
const VERDICTS = new Set(['confirmed', 'false-alarm', 'suggestion', 'unresolved'])
|
|
6
|
+
const SEVERITIES = new Set(['critical', 'important', 'observation', 'idiomatic'])
|
|
7
|
+
|
|
8
|
+
const requireValue = (condition, message) => {
|
|
9
|
+
if (!condition) throw new Error(message)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function validateDefectManifest(manifest) {
|
|
13
|
+
requireValue(manifest?.schema === 1 && Array.isArray(manifest.cases) && manifest.cases.length > 0
|
|
14
|
+
&& Array.isArray(manifest.defects), 'defect manifest needs schema 1, cases, and defects')
|
|
15
|
+
requireValue(manifest.defects.every(defect => defect && typeof defect === 'object'), 'defects must be objects')
|
|
16
|
+
const defectIds = manifest.defects.map(defect => defect.id)
|
|
17
|
+
requireValue(defectIds.every(id => typeof id === 'string' && id) && new Set(defectIds).size === defectIds.length,
|
|
18
|
+
'defect ids must be unique non-empty strings')
|
|
19
|
+
requireValue(manifest.defects.every(defect => typeof defect.contract === 'string' && defect.contract.trim()
|
|
20
|
+
&& typeof defect.reproductionEvidence === 'string' && defect.reproductionEvidence.trim()),
|
|
21
|
+
'every defect needs a reproduction contract and evidence')
|
|
22
|
+
requireValue(manifest.cases.every(item => item && typeof item === 'object'), 'cases must be objects')
|
|
23
|
+
const caseIds = manifest.cases.map(item => item.id)
|
|
24
|
+
requireValue(caseIds.every(id => typeof id === 'string' && id) && new Set(caseIds).size === caseIds.length,
|
|
25
|
+
'case ids must be unique non-empty strings')
|
|
26
|
+
requireValue(manifest.cases.every(item => typeof item.headSha === 'string' && FULL_SHA.test(item.headSha)
|
|
27
|
+
&& Number.isInteger(item.expectedRuns) && item.expectedRuns > 0 && Array.isArray(item.expectedDefects)
|
|
28
|
+
&& item.expectedDefects.every(id => defectIds.includes(id))
|
|
29
|
+
&& new Set(item.expectedDefects).size === item.expectedDefects.length), 'case identity or expected defects are malformed')
|
|
30
|
+
return { caseIds, defectIds }
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function validateDefectEvaluation(manifest, evaluation, findingsSha256, previousRunIds = []) {
|
|
34
|
+
const registry = validateDefectManifest(manifest)
|
|
35
|
+
const run = evaluation?.run
|
|
36
|
+
const adjudication = evaluation?.adjudication
|
|
37
|
+
const unavailable = reason => ({ valid: false, reason, caseId: run?.caseId })
|
|
38
|
+
if (!run || !adjudication || !registry.caseIds.includes(run.caseId)) return unavailable('run or registered case unavailable')
|
|
39
|
+
const testCase = manifest.cases.find(item => item.id === run.caseId)
|
|
40
|
+
if (run.status !== 'completed') return unavailable('run is not completed')
|
|
41
|
+
if (typeof run.runId !== 'string' || !RUN_ID.test(run.runId) || previousRunIds.includes(run.runId)) return unavailable('unsafe or duplicate runId')
|
|
42
|
+
if (run.headSha !== testCase.headSha || adjudication.headSha !== run.headSha || adjudication.runId !== run.runId) return unavailable('run identity mismatch')
|
|
43
|
+
// The edge hashes exact findings bytes; this pure check only binds that supplied hash.
|
|
44
|
+
if (!SHA256.test(findingsSha256 || '') || adjudication.findingsSha256 !== findingsSha256) return unavailable('finding bytes hash mismatch')
|
|
45
|
+
if (!Array.isArray(run.findings) || run.findings.some(finding => !finding || typeof finding.file !== 'string' || !finding.file.trim()
|
|
46
|
+
|| !(finding.line === null || (Number.isInteger(finding.line) && finding.line > 0)) || !SEVERITIES.has(finding.severity))) return unavailable('malformed findings')
|
|
47
|
+
const decisions = adjudication.decisions
|
|
48
|
+
if (!Array.isArray(decisions) || decisions.length !== run.findings.length || decisions.some(item => !item || typeof item !== 'object')) {
|
|
49
|
+
return unavailable('adjudication coverage incomplete or malformed')
|
|
50
|
+
}
|
|
51
|
+
const indexes = decisions.map(item => item.findingIndex)
|
|
52
|
+
const valid = decisions.every((item, index) => Number.isInteger(item.findingIndex) && item.findingIndex >= 0
|
|
53
|
+
&& item.findingIndex < run.findings.length && indexes.indexOf(item.findingIndex) === index && VERDICTS.has(item.verdict)
|
|
54
|
+
&& typeof item.rationale === 'string' && item.rationale.trim() && typeof item.evidence === 'string' && item.evidence.trim()
|
|
55
|
+
&& (item.verdict !== 'confirmed' || (typeof item.defectId === 'string' && item.defectId)))
|
|
56
|
+
if (!valid) return unavailable('finding decisions are malformed or duplicated')
|
|
57
|
+
return { valid: true, caseId: run.caseId, runId: run.runId, testCase, decisions }
|
|
58
|
+
}
|
package/package.json
CHANGED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// Pure validation for frozen defect cases and adjudication records.
|
|
2
|
+
const FULL_SHA = /^[a-f0-9]{40}$/i
|
|
3
|
+
const SHA256 = /^[a-f0-9]{64}$/i
|
|
4
|
+
const RUN_ID = /^[A-Za-z0-9][A-Za-z0-9._-]*$/
|
|
5
|
+
const VERDICTS = new Set(['confirmed', 'false-alarm', 'suggestion', 'unresolved'])
|
|
6
|
+
const SEVERITIES = new Set(['critical', 'important', 'observation', 'idiomatic'])
|
|
7
|
+
|
|
8
|
+
const requireValue = (condition, message) => {
|
|
9
|
+
if (!condition) throw new Error(message)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function validateDefectManifest(manifest) {
|
|
13
|
+
requireValue(manifest?.schema === 1 && Array.isArray(manifest.cases) && manifest.cases.length > 0
|
|
14
|
+
&& Array.isArray(manifest.defects), 'defect manifest needs schema 1, cases, and defects')
|
|
15
|
+
requireValue(manifest.defects.every(defect => defect && typeof defect === 'object'), 'defects must be objects')
|
|
16
|
+
const defectIds = manifest.defects.map(defect => defect.id)
|
|
17
|
+
requireValue(defectIds.every(id => typeof id === 'string' && id) && new Set(defectIds).size === defectIds.length,
|
|
18
|
+
'defect ids must be unique non-empty strings')
|
|
19
|
+
requireValue(manifest.defects.every(defect => typeof defect.contract === 'string' && defect.contract.trim()
|
|
20
|
+
&& typeof defect.reproductionEvidence === 'string' && defect.reproductionEvidence.trim()),
|
|
21
|
+
'every defect needs a reproduction contract and evidence')
|
|
22
|
+
requireValue(manifest.cases.every(item => item && typeof item === 'object'), 'cases must be objects')
|
|
23
|
+
const caseIds = manifest.cases.map(item => item.id)
|
|
24
|
+
requireValue(caseIds.every(id => typeof id === 'string' && id) && new Set(caseIds).size === caseIds.length,
|
|
25
|
+
'case ids must be unique non-empty strings')
|
|
26
|
+
requireValue(manifest.cases.every(item => typeof item.headSha === 'string' && FULL_SHA.test(item.headSha)
|
|
27
|
+
&& Number.isInteger(item.expectedRuns) && item.expectedRuns > 0 && Array.isArray(item.expectedDefects)
|
|
28
|
+
&& item.expectedDefects.every(id => defectIds.includes(id))
|
|
29
|
+
&& new Set(item.expectedDefects).size === item.expectedDefects.length), 'case identity or expected defects are malformed')
|
|
30
|
+
return { caseIds, defectIds }
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function validateDefectEvaluation(manifest, evaluation, findingsSha256, previousRunIds = []) {
|
|
34
|
+
const registry = validateDefectManifest(manifest)
|
|
35
|
+
const run = evaluation?.run
|
|
36
|
+
const adjudication = evaluation?.adjudication
|
|
37
|
+
const unavailable = reason => ({ valid: false, reason, caseId: run?.caseId })
|
|
38
|
+
if (!run || !adjudication || !registry.caseIds.includes(run.caseId)) return unavailable('run or registered case unavailable')
|
|
39
|
+
const testCase = manifest.cases.find(item => item.id === run.caseId)
|
|
40
|
+
if (run.status !== 'completed') return unavailable('run is not completed')
|
|
41
|
+
if (typeof run.runId !== 'string' || !RUN_ID.test(run.runId) || previousRunIds.includes(run.runId)) return unavailable('unsafe or duplicate runId')
|
|
42
|
+
if (run.headSha !== testCase.headSha || adjudication.headSha !== run.headSha || adjudication.runId !== run.runId) return unavailable('run identity mismatch')
|
|
43
|
+
// The edge hashes exact findings bytes; this pure check only binds that supplied hash.
|
|
44
|
+
if (!SHA256.test(findingsSha256 || '') || adjudication.findingsSha256 !== findingsSha256) return unavailable('finding bytes hash mismatch')
|
|
45
|
+
if (!Array.isArray(run.findings) || run.findings.some(finding => !finding || typeof finding.file !== 'string' || !finding.file.trim()
|
|
46
|
+
|| !(finding.line === null || (Number.isInteger(finding.line) && finding.line > 0)) || !SEVERITIES.has(finding.severity))) return unavailable('malformed findings')
|
|
47
|
+
const decisions = adjudication.decisions
|
|
48
|
+
if (!Array.isArray(decisions) || decisions.length !== run.findings.length || decisions.some(item => !item || typeof item !== 'object')) {
|
|
49
|
+
return unavailable('adjudication coverage incomplete or malformed')
|
|
50
|
+
}
|
|
51
|
+
const indexes = decisions.map(item => item.findingIndex)
|
|
52
|
+
const valid = decisions.every((item, index) => Number.isInteger(item.findingIndex) && item.findingIndex >= 0
|
|
53
|
+
&& item.findingIndex < run.findings.length && indexes.indexOf(item.findingIndex) === index && VERDICTS.has(item.verdict)
|
|
54
|
+
&& typeof item.rationale === 'string' && item.rationale.trim() && typeof item.evidence === 'string' && item.evidence.trim()
|
|
55
|
+
&& (item.verdict !== 'confirmed' || (typeof item.defectId === 'string' && item.defectId)))
|
|
56
|
+
if (!valid) return unavailable('finding decisions are malformed or duplicated')
|
|
57
|
+
return { valid: true, caseId: run.caseId, runId: run.runId, testCase, decisions }
|
|
58
|
+
}
|