arkaik 0.6.0 → 0.8.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/dist/index.js +340 -34
- package/dist/io.js +16 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -15202,7 +15202,20 @@ var QualityAuditCompletedEventSchema = external_exports.object({
|
|
|
15202
15202
|
partial: external_exports.boolean().optional(),
|
|
15203
15203
|
cells: external_exports.number().optional(),
|
|
15204
15204
|
since: external_exports.string().optional()
|
|
15205
|
-
}).catchall(external_exports.unknown()).optional()
|
|
15205
|
+
}).catchall(external_exports.unknown()).optional(),
|
|
15206
|
+
// A reading synthesized from a stored audit that arrived without one (issue #472).
|
|
15207
|
+
baseline: external_exports.boolean().optional()
|
|
15208
|
+
}).catchall(external_exports.unknown());
|
|
15209
|
+
var QualityAssessmentScoredEventSchema = external_exports.object({
|
|
15210
|
+
...envelope,
|
|
15211
|
+
type: external_exports.literal("quality.assessment.scored"),
|
|
15212
|
+
audit_id: external_exports.string(),
|
|
15213
|
+
criterion_id: external_exports.string(),
|
|
15214
|
+
surface: external_exports.string(),
|
|
15215
|
+
level: external_exports.number().int().min(0).max(4),
|
|
15216
|
+
evidence: external_exports.string(),
|
|
15217
|
+
commit: external_exports.string().optional(),
|
|
15218
|
+
scope: external_exports.object({ since: external_exports.string().optional() }).catchall(external_exports.unknown()).optional()
|
|
15206
15219
|
}).catchall(external_exports.unknown());
|
|
15207
15220
|
var QualityFindingOpenedEventSchema = external_exports.object({
|
|
15208
15221
|
...envelope,
|
|
@@ -15256,6 +15269,7 @@ var JOURNAL_EVENT_SCHEMAS = {
|
|
|
15256
15269
|
"ref.status_changed": RefStatusChangedEventSchema,
|
|
15257
15270
|
"journal.baseline": JournalBaselineEventSchema,
|
|
15258
15271
|
"quality.audit.completed": QualityAuditCompletedEventSchema,
|
|
15272
|
+
"quality.assessment.scored": QualityAssessmentScoredEventSchema,
|
|
15259
15273
|
"quality.finding.opened": QualityFindingOpenedEventSchema,
|
|
15260
15274
|
"quality.finding.resolved": QualityFindingResolvedEventSchema,
|
|
15261
15275
|
"quality.finding.accepted": QualityFindingAcceptedEventSchema,
|
|
@@ -15278,6 +15292,7 @@ var KnownJournalEventSchema = external_exports.union([
|
|
|
15278
15292
|
RefStatusChangedEventSchema,
|
|
15279
15293
|
JournalBaselineEventSchema,
|
|
15280
15294
|
QualityAuditCompletedEventSchema,
|
|
15295
|
+
QualityAssessmentScoredEventSchema,
|
|
15281
15296
|
QualityFindingOpenedEventSchema,
|
|
15282
15297
|
QualityFindingResolvedEventSchema,
|
|
15283
15298
|
QualityFindingAcceptedEventSchema,
|
|
@@ -17342,6 +17357,10 @@ function sameFrameworkMajor(a, b) {
|
|
|
17342
17357
|
const right = frameworkMajor(b);
|
|
17343
17358
|
return left === null || right === null || left === right;
|
|
17344
17359
|
}
|
|
17360
|
+
function scopeOf(raw) {
|
|
17361
|
+
if (!isRecord(raw) || typeof raw.since !== "string" || raw.since === "") return void 0;
|
|
17362
|
+
return { scope: { since: raw.since, cells: typeof raw.cells === "number" && Number.isFinite(raw.cells) ? raw.cells : null } };
|
|
17363
|
+
}
|
|
17345
17364
|
function cleanScores(raw) {
|
|
17346
17365
|
const scores = {};
|
|
17347
17366
|
if (!isRecord(raw)) return scores;
|
|
@@ -17412,7 +17431,9 @@ function deriveQualityTrend(events, profile, live) {
|
|
|
17412
17431
|
comparable: true,
|
|
17413
17432
|
scores,
|
|
17414
17433
|
overall,
|
|
17415
|
-
counts: cleanCounts(event.counts)
|
|
17434
|
+
counts: cleanCounts(event.counts),
|
|
17435
|
+
...event.baseline === true ? { baseline: true } : {},
|
|
17436
|
+
...scopeOf(event.scope) ?? {}
|
|
17416
17437
|
};
|
|
17417
17438
|
byAudit.delete(auditId);
|
|
17418
17439
|
byAudit.set(auditId, snapshot);
|
|
@@ -17468,7 +17489,9 @@ function trendRows(trend, filter = {}) {
|
|
|
17468
17489
|
...snapshot.commit !== void 0 ? { commit: snapshot.commit } : {},
|
|
17469
17490
|
...snapshot.framework_version !== void 0 ? { framework_version: snapshot.framework_version } : {},
|
|
17470
17491
|
comparable: snapshot.comparable,
|
|
17471
|
-
cells
|
|
17492
|
+
cells,
|
|
17493
|
+
...snapshot.baseline ? { baseline: true } : {},
|
|
17494
|
+
...snapshot.scope !== void 0 ? { scope: snapshot.scope } : {}
|
|
17472
17495
|
});
|
|
17473
17496
|
});
|
|
17474
17497
|
return { surfaces, rows };
|
|
@@ -17630,6 +17653,49 @@ function deriveAuditScope(events, section, library, options = {}) {
|
|
|
17630
17653
|
);
|
|
17631
17654
|
return { since, since_ts: sinceTs, cells: sorted, findings: drivers, resolved_by: resolvedBy, unknown: unknown2, unscorable, widened };
|
|
17632
17655
|
}
|
|
17656
|
+
function scopedAuditId(input) {
|
|
17657
|
+
const { since, month, requested, known, recorded, open } = input;
|
|
17658
|
+
const newest = [...known].sort().at(-1);
|
|
17659
|
+
if (requested !== void 0) {
|
|
17660
|
+
if (requested === since) {
|
|
17661
|
+
throw new Error(
|
|
17662
|
+
`"${requested}" is the audit this scope is measured from \u2014 its recorded reading is history. Name a new audit (e.g. \`${suggestedAuditId(input)}\`); every other cell keeps its score through the merge.`
|
|
17663
|
+
);
|
|
17664
|
+
}
|
|
17665
|
+
if (recorded.includes(requested)) {
|
|
17666
|
+
throw new Error(`"${requested}" is already recorded \u2014 its reading is history. Name a new audit.`);
|
|
17667
|
+
}
|
|
17668
|
+
if (newest !== void 0 && requested < newest) {
|
|
17669
|
+
throw new Error(
|
|
17670
|
+
`"${requested}" sorts before "${newest}", and audits merge latest-wins in lexical order \u2014 its scores would be outvoted by the older ones they replace. Name one that sorts last (e.g. \`${suggestedAuditId(input)}\`).`
|
|
17671
|
+
);
|
|
17672
|
+
}
|
|
17673
|
+
return requested;
|
|
17674
|
+
}
|
|
17675
|
+
if (open !== void 0 && (newest === void 0 || open >= newest)) return open;
|
|
17676
|
+
for (const candidate of scopedCandidates(month)) {
|
|
17677
|
+
if (known.includes(candidate)) continue;
|
|
17678
|
+
if (newest !== void 0 && candidate < newest) {
|
|
17679
|
+
throw new Error(
|
|
17680
|
+
`"${candidate}" would sort before "${newest}", so its scores would lose the latest-wins merge. Name the scoped audit yourself, one that sorts after "${newest}" (e.g. \`${suggestedAuditId(input)}\`).`
|
|
17681
|
+
);
|
|
17682
|
+
}
|
|
17683
|
+
return candidate;
|
|
17684
|
+
}
|
|
17685
|
+
throw new Error(`99 scoped audits in ${month} \u2014 name the next one yourself.`);
|
|
17686
|
+
}
|
|
17687
|
+
function* scopedCandidates(month) {
|
|
17688
|
+
for (let n = 1; n < 100; n++) yield n === 1 ? `${month}-scoped` : `${month}-scoped-${String(n).padStart(2, "0")}`;
|
|
17689
|
+
}
|
|
17690
|
+
function suggestedAuditId({ since, month, requested, known, recorded }) {
|
|
17691
|
+
const taken = /* @__PURE__ */ new Set([...known, ...recorded, since, ...requested !== void 0 ? [requested] : []]);
|
|
17692
|
+
const floor = [...taken].sort().at(-1);
|
|
17693
|
+
for (const candidate of scopedCandidates(month)) {
|
|
17694
|
+
if (taken.has(candidate)) continue;
|
|
17695
|
+
if (floor === void 0 || candidate > floor) return candidate;
|
|
17696
|
+
}
|
|
17697
|
+
return `${floor}-scoped`;
|
|
17698
|
+
}
|
|
17633
17699
|
function scopeSummary(scope) {
|
|
17634
17700
|
const direct = scope.cells.length - scope.widened;
|
|
17635
17701
|
const cells = `${scope.cells.length} cell${scope.cells.length === 1 ? "" : "s"} to re-score`;
|
|
@@ -17638,6 +17704,167 @@ function scopeSummary(scope) {
|
|
|
17638
17704
|
return `${cells}${split} from ${from}${scope.since !== null ? ` since ${scope.since}` : ""}`;
|
|
17639
17705
|
}
|
|
17640
17706
|
|
|
17707
|
+
// ../schema/src/quality-burndown.ts
|
|
17708
|
+
var EVENT_CAUSE = {
|
|
17709
|
+
"quality.finding.opened": "opened",
|
|
17710
|
+
"quality.finding.resolved": "resolved",
|
|
17711
|
+
"quality.finding.accepted": "accepted",
|
|
17712
|
+
"quality.audit.completed": "audit"
|
|
17713
|
+
};
|
|
17714
|
+
var isRecord2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
17715
|
+
var isString2 = (value) => typeof value === "string" && value !== "";
|
|
17716
|
+
var emptyCounts = () => ({ critical: 0, high: 0, medium: 0, low: 0, info: 0 });
|
|
17717
|
+
var asSeverity = (value) => typeof value === "string" && FINDING_SEVERITIES.includes(value) ? value : null;
|
|
17718
|
+
function cleanCounts2(raw) {
|
|
17719
|
+
const counts = emptyCounts();
|
|
17720
|
+
if (!isRecord2(raw)) return counts;
|
|
17721
|
+
for (const severity of FINDING_SEVERITIES) {
|
|
17722
|
+
const value = raw[severity];
|
|
17723
|
+
if (typeof value === "number" && Number.isFinite(value) && value > 0) counts[severity] = value;
|
|
17724
|
+
}
|
|
17725
|
+
return counts;
|
|
17726
|
+
}
|
|
17727
|
+
function openTotal(open) {
|
|
17728
|
+
return FINDING_SEVERITIES.reduce((sum, severity) => sum + (open[severity] ?? 0), 0);
|
|
17729
|
+
}
|
|
17730
|
+
function deriveFindingsBurndown(events, options = {}) {
|
|
17731
|
+
const { surface, domain: domain2, library } = options;
|
|
17732
|
+
const filtered = surface !== void 0 || domain2 !== void 0;
|
|
17733
|
+
const sectionById = /* @__PURE__ */ new Map();
|
|
17734
|
+
for (const finding of Array.isArray(options.findings) ? options.findings : []) {
|
|
17735
|
+
if (isRecord2(finding) && isString2(finding.id)) sectionById.set(finding.id, finding);
|
|
17736
|
+
}
|
|
17737
|
+
const inView = (where) => {
|
|
17738
|
+
if (!filtered) return true;
|
|
17739
|
+
if (where === void 0) return false;
|
|
17740
|
+
if (surface !== void 0 && where.surface !== surface) return false;
|
|
17741
|
+
if (domain2 !== void 0 && (!isString2(where.criterion_id) || domainCodeOf(where.criterion_id, library) !== domain2)) {
|
|
17742
|
+
return false;
|
|
17743
|
+
}
|
|
17744
|
+
return true;
|
|
17745
|
+
};
|
|
17746
|
+
const relevant = (Array.isArray(events) ? events : []).filter(
|
|
17747
|
+
(event) => isRecord2(event) && typeof event.type === "string" && event.type in EVENT_CAUSE
|
|
17748
|
+
);
|
|
17749
|
+
const openedIds = /* @__PURE__ */ new Set();
|
|
17750
|
+
const decidedIds = /* @__PURE__ */ new Set();
|
|
17751
|
+
for (const event of relevant) {
|
|
17752
|
+
if (!isString2(event.finding_id)) continue;
|
|
17753
|
+
if (event.type === "quality.finding.opened") openedIds.add(event.finding_id);
|
|
17754
|
+
else if (event.type !== "quality.audit.completed") decidedIds.add(event.finding_id);
|
|
17755
|
+
}
|
|
17756
|
+
const seedable = (id, finding) => {
|
|
17757
|
+
if (openedIds.has(id) || !inView(finding)) return false;
|
|
17758
|
+
if (finding.status === "open") return true;
|
|
17759
|
+
return (finding.status === "resolved" || finding.status === "accepted-risk") && decidedIds.has(id);
|
|
17760
|
+
};
|
|
17761
|
+
const tracked = /* @__PURE__ */ new Map();
|
|
17762
|
+
const open = emptyCounts();
|
|
17763
|
+
const points = [];
|
|
17764
|
+
const totals = { opened: 0, resolved: 0, accepted: 0 };
|
|
17765
|
+
let since = null;
|
|
17766
|
+
let seeded = false;
|
|
17767
|
+
const bump = (severity, by) => {
|
|
17768
|
+
if (severity !== null) open[severity] = Math.max(0, open[severity] + by);
|
|
17769
|
+
};
|
|
17770
|
+
const mark = (event, type, id) => {
|
|
17771
|
+
points.push({ ts: typeof event.ts === "string" ? event.ts : "", open: { ...open }, cause: { type, id } });
|
|
17772
|
+
};
|
|
17773
|
+
const count = (type) => {
|
|
17774
|
+
totals[type]++;
|
|
17775
|
+
if (since !== null) since[type]++;
|
|
17776
|
+
};
|
|
17777
|
+
for (const event of orderEvents(relevant)) {
|
|
17778
|
+
const type = EVENT_CAUSE[event.type];
|
|
17779
|
+
if (type === "audit") {
|
|
17780
|
+
if (!seeded) {
|
|
17781
|
+
seeded = true;
|
|
17782
|
+
for (const [id2, finding] of sectionById) {
|
|
17783
|
+
if (tracked.has(id2) || !seedable(id2, finding)) continue;
|
|
17784
|
+
const severity = severityOf(finding, library);
|
|
17785
|
+
tracked.set(id2, { severity, open: true, surface: finding.surface, criterion_id: finding.criterion_id });
|
|
17786
|
+
bump(severity, 1);
|
|
17787
|
+
}
|
|
17788
|
+
}
|
|
17789
|
+
if (!filtered) Object.assign(open, cleanCounts2(event.counts));
|
|
17790
|
+
const auditId = isString2(event.audit_id) ? event.audit_id : isString2(event.id) ? event.id : "";
|
|
17791
|
+
since = { audit_id: auditId, ts: typeof event.ts === "string" ? event.ts : "", opened: 0, resolved: 0, accepted: 0 };
|
|
17792
|
+
mark(event, "audit", auditId);
|
|
17793
|
+
continue;
|
|
17794
|
+
}
|
|
17795
|
+
const id = event.finding_id;
|
|
17796
|
+
if (!isString2(id)) continue;
|
|
17797
|
+
const known = tracked.get(id);
|
|
17798
|
+
if (type === "opened") {
|
|
17799
|
+
if (known?.open) continue;
|
|
17800
|
+
if (!inView(event)) continue;
|
|
17801
|
+
const severity = asSeverity(event.severity);
|
|
17802
|
+
tracked.set(id, {
|
|
17803
|
+
severity,
|
|
17804
|
+
open: true,
|
|
17805
|
+
...typeof event.surface === "string" ? { surface: event.surface } : {},
|
|
17806
|
+
...typeof event.criterion_id === "string" ? { criterion_id: event.criterion_id } : {}
|
|
17807
|
+
});
|
|
17808
|
+
bump(severity, 1);
|
|
17809
|
+
count("opened");
|
|
17810
|
+
mark(event, "opened", id);
|
|
17811
|
+
continue;
|
|
17812
|
+
}
|
|
17813
|
+
if (known !== void 0) {
|
|
17814
|
+
if (!known.open) continue;
|
|
17815
|
+
known.open = false;
|
|
17816
|
+
bump(known.severity, -1);
|
|
17817
|
+
} else {
|
|
17818
|
+
const fromSection = sectionById.get(id);
|
|
17819
|
+
if (!inView(fromSection)) continue;
|
|
17820
|
+
tracked.set(id, {
|
|
17821
|
+
severity: null,
|
|
17822
|
+
open: false,
|
|
17823
|
+
...fromSection ? { surface: fromSection.surface, criterion_id: fromSection.criterion_id } : {}
|
|
17824
|
+
});
|
|
17825
|
+
}
|
|
17826
|
+
count(type);
|
|
17827
|
+
mark(event, type, id);
|
|
17828
|
+
}
|
|
17829
|
+
return { points, ...totals, since };
|
|
17830
|
+
}
|
|
17831
|
+
function burndownRows(burndown) {
|
|
17832
|
+
const { points, since } = burndown;
|
|
17833
|
+
if (points.length === 0) return { reference: null, rows: [] };
|
|
17834
|
+
let referenceIndex = 0;
|
|
17835
|
+
if (since !== null) {
|
|
17836
|
+
for (let index = points.length - 1; index >= 0; index--) {
|
|
17837
|
+
if (points[index].cause.type === "audit") {
|
|
17838
|
+
referenceIndex = index;
|
|
17839
|
+
break;
|
|
17840
|
+
}
|
|
17841
|
+
}
|
|
17842
|
+
}
|
|
17843
|
+
const reference = points[referenceIndex];
|
|
17844
|
+
const last = points[points.length - 1];
|
|
17845
|
+
return {
|
|
17846
|
+
reference: {
|
|
17847
|
+
kind: since !== null ? "audit" : "start",
|
|
17848
|
+
id: reference.cause.id,
|
|
17849
|
+
ts: reference.ts
|
|
17850
|
+
},
|
|
17851
|
+
rows: FINDING_SEVERITIES.map((severity) => ({
|
|
17852
|
+
severity,
|
|
17853
|
+
at_reference: reference.open[severity],
|
|
17854
|
+
now: last.open[severity],
|
|
17855
|
+
change: last.open[severity] - reference.open[severity]
|
|
17856
|
+
}))
|
|
17857
|
+
};
|
|
17858
|
+
}
|
|
17859
|
+
function burndownSummary(burndown, openNow) {
|
|
17860
|
+
if (burndown.points.length === 0) return null;
|
|
17861
|
+
const tally = burndown.since ?? burndown;
|
|
17862
|
+
const closed = tally.resolved + tally.accepted;
|
|
17863
|
+
const where = burndown.since ? ` since the ${burndown.since.audit_id} audit` : "";
|
|
17864
|
+
const open = openNow ?? openTotal(burndown.points[burndown.points.length - 1].open);
|
|
17865
|
+
return `${closed} closed${where} (${tally.resolved} resolved, ${tally.accepted} accepted) \xB7 ${tally.opened} opened \xB7 ${open} open`;
|
|
17866
|
+
}
|
|
17867
|
+
|
|
17641
17868
|
// src/commands/init.ts
|
|
17642
17869
|
var DEFAULT_BUNDLE_PATH = "docs/arkaik/bundle.json";
|
|
17643
17870
|
var DEFAULT_JOURNAL_PATH = "docs/arkaik/journal.jsonl";
|
|
@@ -19151,35 +19378,10 @@ function mergeAudits(root, auditIds, library, profile) {
|
|
|
19151
19378
|
};
|
|
19152
19379
|
}
|
|
19153
19380
|
function scopedAuditTarget(root, since, month, requested, recorded = []) {
|
|
19154
|
-
const
|
|
19155
|
-
const newest =
|
|
19156
|
-
|
|
19157
|
-
|
|
19158
|
-
throw new Error(
|
|
19159
|
-
`"${requested}" is the audit this scope is measured from \u2014 its recorded reading is history. Re-score into a new audit (e.g. \`--audit ${month}-scoped\`); every other cell keeps its score through the merge.`
|
|
19160
|
-
);
|
|
19161
|
-
}
|
|
19162
|
-
if (newest !== void 0 && requested < newest) {
|
|
19163
|
-
throw new Error(
|
|
19164
|
-
`"${requested}" sorts before "${newest}", and audits merge latest-wins in lexical order \u2014 its scores would be outvoted by the older ones they replace. Name one that sorts last (e.g. \`${month}-scoped\`).`
|
|
19165
|
-
);
|
|
19166
|
-
}
|
|
19167
|
-
return requested;
|
|
19168
|
-
}
|
|
19169
|
-
if (newest !== void 0 && newest !== since && !recorded.includes(newest) && loadScoresOrEmpty(root, newest).scope?.since === since) {
|
|
19170
|
-
return newest;
|
|
19171
|
-
}
|
|
19172
|
-
for (let n = 1; n < 100; n++) {
|
|
19173
|
-
const candidate = n === 1 ? `${month}-scoped` : `${month}-scoped-${String(n).padStart(2, "0")}`;
|
|
19174
|
-
if (existing.includes(candidate)) continue;
|
|
19175
|
-
if (newest !== void 0 && candidate < newest) {
|
|
19176
|
-
throw new Error(
|
|
19177
|
-
`"${candidate}" would sort before "${newest}", so its scores would lose the latest-wins merge. Name the scoped audit yourself with --audit, one that sorts after "${newest}".`
|
|
19178
|
-
);
|
|
19179
|
-
}
|
|
19180
|
-
return candidate;
|
|
19181
|
-
}
|
|
19182
|
-
throw new Error(`99 scoped audits in ${month} \u2014 name the next one with --audit.`);
|
|
19381
|
+
const known = listAuditIds(root);
|
|
19382
|
+
const newest = known[known.length - 1];
|
|
19383
|
+
const open = newest !== void 0 && newest !== since && !recorded.includes(newest) && loadScoresOrEmpty(root, newest).scope?.since === since ? newest : void 0;
|
|
19384
|
+
return scopedAuditId({ since, month, requested, known, recorded, open });
|
|
19183
19385
|
}
|
|
19184
19386
|
function declaredScopeSince(auditId, recorded) {
|
|
19185
19387
|
if (recorded.includes(auditId)) {
|
|
@@ -22092,6 +22294,7 @@ Subcommands:
|
|
|
22092
22294
|
signals The signal pack, and what has tripped since the last audit.
|
|
22093
22295
|
regressions What got worse between two audits.
|
|
22094
22296
|
trend Every recorded audit's scores, and which way each moved.
|
|
22297
|
+
burndown Open findings over time, and what closed since the last audit.
|
|
22095
22298
|
scope The cells your resolved findings made stale since the last audit.
|
|
22096
22299
|
issue <criterion> Print the prefilled GitHub issue skeleton.
|
|
22097
22300
|
criterion add ... Add a project-specific criterion to the overlay.
|
|
@@ -22208,6 +22411,21 @@ Reads the journal, so it needs a bundle (--bundle, default docs/arkaik/bundle.js
|
|
|
22208
22411
|
and audits recorded with \`arkaik kritik matrix --record\`. A framework major
|
|
22209
22412
|
bump between two audits breaks the comparison there (SPEC \xA7 8): the row still
|
|
22210
22413
|
prints, without an arrow.`;
|
|
22414
|
+
var BURNDOWN_USAGE = `arkaik kritik burndown [--surface <s>] [--domain <CODE>] [--json]
|
|
22415
|
+
|
|
22416
|
+
How many findings closed since the last recorded audit, and how many are open
|
|
22417
|
+
by severity then and now. The findings, not the score: a score only moves when
|
|
22418
|
+
its cell is re-scored, and this moves the day a finding closes.
|
|
22419
|
+
|
|
22420
|
+
--surface <s> Only findings on that surface.
|
|
22421
|
+
--domain <CODE> Only findings in that domain (SEC, PRF, \u2026).
|
|
22422
|
+
--json Print the totals, the table and every point as JSON.
|
|
22423
|
+
|
|
22424
|
+
Replays quality.finding.opened / resolved / accepted from the journal, so it
|
|
22425
|
+
needs a bundle (--bundle, default docs/arkaik/bundle.json). Each recorded audit
|
|
22426
|
+
(\`arkaik kritik matrix --record\`) re-baselines the counts to what it counted,
|
|
22427
|
+
which corrects a finding closed by hand. A narrowed view is never re-baselined:
|
|
22428
|
+
an audit's counts are project-wide.`;
|
|
22211
22429
|
var SCOPE_USAGE = `arkaik kritik scope [--since <audit>] [--no-widen] [--json]
|
|
22212
22430
|
|
|
22213
22431
|
The cells a batch of fixes made stale. A score is an assessment, so closing
|
|
@@ -22496,7 +22714,7 @@ ${SCORE_USAGE}`);
|
|
|
22496
22714
|
try {
|
|
22497
22715
|
auditId = scopedAuditTarget(common.root, scope.since, currentAuditId(), single.audit, recorded);
|
|
22498
22716
|
} catch (error51) {
|
|
22499
|
-
return fail12(`kritik: ${error51.message}
|
|
22717
|
+
return fail12(`kritik: ${error51.message} Pass it with --audit <id>.`);
|
|
22500
22718
|
}
|
|
22501
22719
|
scopedFrom = scope.since;
|
|
22502
22720
|
} else {
|
|
@@ -23025,6 +23243,12 @@ function runTrend(args, common) {
|
|
|
23025
23243
|
if (!row.comparable) {
|
|
23026
23244
|
console.log(` ${"".padEnd(widths[0])} framework ${row.framework_version ?? "?"} \u2014 not comparable to the audit above`);
|
|
23027
23245
|
}
|
|
23246
|
+
if (row.baseline) {
|
|
23247
|
+
console.log(` ${"".padEnd(widths[0])} baseline \u2014 rebuilt from a restored audit's stored scores`);
|
|
23248
|
+
}
|
|
23249
|
+
if (row.scope) {
|
|
23250
|
+
console.log(` ${"".padEnd(widths[0])} scoped re-audit of ${row.scope.cells ?? "?"} cell(s) since ${row.scope.since}`);
|
|
23251
|
+
}
|
|
23028
23252
|
}
|
|
23029
23253
|
console.log(
|
|
23030
23254
|
`
|
|
@@ -23033,6 +23257,86 @@ function runTrend(args, common) {
|
|
|
23033
23257
|
);
|
|
23034
23258
|
process.exit(0);
|
|
23035
23259
|
}
|
|
23260
|
+
function runBurndown(args, common) {
|
|
23261
|
+
const { single, flags } = collect(args, [], ["json"]);
|
|
23262
|
+
if (flags.has("help")) {
|
|
23263
|
+
console.log(BURNDOWN_USAGE);
|
|
23264
|
+
process.exit(0);
|
|
23265
|
+
}
|
|
23266
|
+
const journal = resolveJournal(common.root, common.bundlePath);
|
|
23267
|
+
if (!journal.present) {
|
|
23268
|
+
fail12(
|
|
23269
|
+
`kritik: no bundle at ${journal.bundlePath} \u2014 the burndown is read from the journal's quality.finding.* events, and there is no journal without a bundle.`
|
|
23270
|
+
);
|
|
23271
|
+
}
|
|
23272
|
+
const events = readFullJournalEvents(journal.journalPath);
|
|
23273
|
+
let library;
|
|
23274
|
+
let section;
|
|
23275
|
+
try {
|
|
23276
|
+
library = loadKritikLibrary(common.root).library;
|
|
23277
|
+
section = loadCurrentQualitySection(common.root, library);
|
|
23278
|
+
} catch {
|
|
23279
|
+
}
|
|
23280
|
+
const filter = {
|
|
23281
|
+
...single.surface !== void 0 ? { surface: single.surface } : {},
|
|
23282
|
+
...single.domain !== void 0 ? { domain: single.domain } : {}
|
|
23283
|
+
};
|
|
23284
|
+
const burndown = deriveFindingsBurndown(events, { ...filter, library, findings: section?.findings });
|
|
23285
|
+
const openNow = section ? section.findings.filter(
|
|
23286
|
+
(finding) => isOpenFinding(finding) && (filter.surface === void 0 || finding.surface === filter.surface) && (filter.domain === void 0 || domainCodeOf(finding.criterion_id, library) === filter.domain)
|
|
23287
|
+
).length : void 0;
|
|
23288
|
+
const { reference, rows } = burndownRows(burndown);
|
|
23289
|
+
const summary = burndownSummary(burndown, openNow);
|
|
23290
|
+
if (flags.has("json")) {
|
|
23291
|
+
console.log(
|
|
23292
|
+
JSON.stringify(
|
|
23293
|
+
{
|
|
23294
|
+
summary,
|
|
23295
|
+
opened: burndown.opened,
|
|
23296
|
+
resolved: burndown.resolved,
|
|
23297
|
+
accepted: burndown.accepted,
|
|
23298
|
+
since: burndown.since,
|
|
23299
|
+
...openNow !== void 0 ? { open: openNow } : {},
|
|
23300
|
+
reference,
|
|
23301
|
+
rows,
|
|
23302
|
+
points: burndown.points
|
|
23303
|
+
},
|
|
23304
|
+
null,
|
|
23305
|
+
2
|
|
23306
|
+
)
|
|
23307
|
+
);
|
|
23308
|
+
process.exit(0);
|
|
23309
|
+
}
|
|
23310
|
+
if (summary === null || reference === null) {
|
|
23311
|
+
console.log(
|
|
23312
|
+
`
|
|
23313
|
+
no finding history yet \u2014 \`arkaik kritik finding open\` and \`finding resolve\` write it, and \`arkaik kritik matrix --record\` records an audit to measure from.
|
|
23314
|
+
`
|
|
23315
|
+
);
|
|
23316
|
+
process.exit(0);
|
|
23317
|
+
}
|
|
23318
|
+
const referenceTitle = reference.kind === "audit" ? `at ${reference.id}` : "at start";
|
|
23319
|
+
const header = ["severity", referenceTitle, "now", "change"];
|
|
23320
|
+
const table = rows.map((row) => [
|
|
23321
|
+
row.severity,
|
|
23322
|
+
String(row.at_reference),
|
|
23323
|
+
String(row.now),
|
|
23324
|
+
row.change === 0 ? "=" : row.change > 0 ? `+${row.change}` : `\u2212${Math.abs(row.change)}`
|
|
23325
|
+
]);
|
|
23326
|
+
const widths = header.map((title2, column) => Math.max(title2.length, ...table.map((line3) => line3[column].length)));
|
|
23327
|
+
const line2 = (cells) => ` ${cells.map((cell, column) => cell.padEnd(widths[column])).join(" ")}`.trimEnd();
|
|
23328
|
+
console.log(`
|
|
23329
|
+
${summary}
|
|
23330
|
+
`);
|
|
23331
|
+
console.log(line2(header));
|
|
23332
|
+
for (const cells of table) console.log(line2(cells));
|
|
23333
|
+
if (reference.kind === "start") {
|
|
23334
|
+
console.log(`
|
|
23335
|
+
no recorded audit \u2014 read from the first event (${reference.ts.slice(0, 10)}).`);
|
|
23336
|
+
}
|
|
23337
|
+
console.log("");
|
|
23338
|
+
process.exit(0);
|
|
23339
|
+
}
|
|
23036
23340
|
function scopeReason(cell, resolvedBy) {
|
|
23037
23341
|
if (cell.kind === "widened") return `widened via ${cell.because.join(", ")}`;
|
|
23038
23342
|
const findings = cell.because.map((id) => resolvedBy[id] !== void 0 ? `${id} (resolved by ${resolvedBy[id]})` : id);
|
|
@@ -23265,6 +23569,8 @@ function runKritik(args) {
|
|
|
23265
23569
|
return runRegressions(subArgs, common);
|
|
23266
23570
|
case "trend":
|
|
23267
23571
|
return runTrend(subArgs, common);
|
|
23572
|
+
case "burndown":
|
|
23573
|
+
return runBurndown(subArgs, common);
|
|
23268
23574
|
case "scope":
|
|
23269
23575
|
return runScope(subArgs, common);
|
|
23270
23576
|
case "issue":
|
|
@@ -23306,7 +23612,7 @@ Options:
|
|
|
23306
23612
|
-v, --version Print the version.
|
|
23307
23613
|
|
|
23308
23614
|
Run "arkaik <command> --help" for command-specific help.`;
|
|
23309
|
-
var VERSION = "0.
|
|
23615
|
+
var VERSION = "0.8.0";
|
|
23310
23616
|
function main(argv) {
|
|
23311
23617
|
const [command, ...rest] = argv;
|
|
23312
23618
|
if (command === void 0 || command === "--help" || command === "-h" || command === "help") {
|
package/dist/io.js
CHANGED
|
@@ -15189,7 +15189,20 @@ var QualityAuditCompletedEventSchema = external_exports.object({
|
|
|
15189
15189
|
partial: external_exports.boolean().optional(),
|
|
15190
15190
|
cells: external_exports.number().optional(),
|
|
15191
15191
|
since: external_exports.string().optional()
|
|
15192
|
-
}).catchall(external_exports.unknown()).optional()
|
|
15192
|
+
}).catchall(external_exports.unknown()).optional(),
|
|
15193
|
+
// A reading synthesized from a stored audit that arrived without one (issue #472).
|
|
15194
|
+
baseline: external_exports.boolean().optional()
|
|
15195
|
+
}).catchall(external_exports.unknown());
|
|
15196
|
+
var QualityAssessmentScoredEventSchema = external_exports.object({
|
|
15197
|
+
...envelope,
|
|
15198
|
+
type: external_exports.literal("quality.assessment.scored"),
|
|
15199
|
+
audit_id: external_exports.string(),
|
|
15200
|
+
criterion_id: external_exports.string(),
|
|
15201
|
+
surface: external_exports.string(),
|
|
15202
|
+
level: external_exports.number().int().min(0).max(4),
|
|
15203
|
+
evidence: external_exports.string(),
|
|
15204
|
+
commit: external_exports.string().optional(),
|
|
15205
|
+
scope: external_exports.object({ since: external_exports.string().optional() }).catchall(external_exports.unknown()).optional()
|
|
15193
15206
|
}).catchall(external_exports.unknown());
|
|
15194
15207
|
var QualityFindingOpenedEventSchema = external_exports.object({
|
|
15195
15208
|
...envelope,
|
|
@@ -15243,6 +15256,7 @@ var JOURNAL_EVENT_SCHEMAS = {
|
|
|
15243
15256
|
"ref.status_changed": RefStatusChangedEventSchema,
|
|
15244
15257
|
"journal.baseline": JournalBaselineEventSchema,
|
|
15245
15258
|
"quality.audit.completed": QualityAuditCompletedEventSchema,
|
|
15259
|
+
"quality.assessment.scored": QualityAssessmentScoredEventSchema,
|
|
15246
15260
|
"quality.finding.opened": QualityFindingOpenedEventSchema,
|
|
15247
15261
|
"quality.finding.resolved": QualityFindingResolvedEventSchema,
|
|
15248
15262
|
"quality.finding.accepted": QualityFindingAcceptedEventSchema,
|
|
@@ -15265,6 +15279,7 @@ var KnownJournalEventSchema = external_exports.union([
|
|
|
15265
15279
|
RefStatusChangedEventSchema,
|
|
15266
15280
|
JournalBaselineEventSchema,
|
|
15267
15281
|
QualityAuditCompletedEventSchema,
|
|
15282
|
+
QualityAssessmentScoredEventSchema,
|
|
15268
15283
|
QualityFindingOpenedEventSchema,
|
|
15269
15284
|
QualityFindingResolvedEventSchema,
|
|
15270
15285
|
QualityFindingAcceptedEventSchema,
|