arkaik-mcp 0.6.0 → 0.7.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 +378 -77
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -15345,7 +15345,20 @@ var QualityAuditCompletedEventSchema = external_exports.object({
|
|
|
15345
15345
|
partial: external_exports.boolean().optional(),
|
|
15346
15346
|
cells: external_exports.number().optional(),
|
|
15347
15347
|
since: external_exports.string().optional()
|
|
15348
|
-
}).catchall(external_exports.unknown()).optional()
|
|
15348
|
+
}).catchall(external_exports.unknown()).optional(),
|
|
15349
|
+
// A reading synthesized from a stored audit that arrived without one (issue #472).
|
|
15350
|
+
baseline: external_exports.boolean().optional()
|
|
15351
|
+
}).catchall(external_exports.unknown());
|
|
15352
|
+
var QualityAssessmentScoredEventSchema = external_exports.object({
|
|
15353
|
+
...envelope,
|
|
15354
|
+
type: external_exports.literal("quality.assessment.scored"),
|
|
15355
|
+
audit_id: external_exports.string(),
|
|
15356
|
+
criterion_id: external_exports.string(),
|
|
15357
|
+
surface: external_exports.string(),
|
|
15358
|
+
level: external_exports.number().int().min(0).max(4),
|
|
15359
|
+
evidence: external_exports.string(),
|
|
15360
|
+
commit: external_exports.string().optional(),
|
|
15361
|
+
scope: external_exports.object({ since: external_exports.string().optional() }).catchall(external_exports.unknown()).optional()
|
|
15349
15362
|
}).catchall(external_exports.unknown());
|
|
15350
15363
|
var QualityFindingOpenedEventSchema = external_exports.object({
|
|
15351
15364
|
...envelope,
|
|
@@ -15399,6 +15412,7 @@ var JOURNAL_EVENT_SCHEMAS = {
|
|
|
15399
15412
|
"ref.status_changed": RefStatusChangedEventSchema,
|
|
15400
15413
|
"journal.baseline": JournalBaselineEventSchema,
|
|
15401
15414
|
"quality.audit.completed": QualityAuditCompletedEventSchema,
|
|
15415
|
+
"quality.assessment.scored": QualityAssessmentScoredEventSchema,
|
|
15402
15416
|
"quality.finding.opened": QualityFindingOpenedEventSchema,
|
|
15403
15417
|
"quality.finding.resolved": QualityFindingResolvedEventSchema,
|
|
15404
15418
|
"quality.finding.accepted": QualityFindingAcceptedEventSchema,
|
|
@@ -15421,6 +15435,7 @@ var KnownJournalEventSchema = external_exports.union([
|
|
|
15421
15435
|
RefStatusChangedEventSchema,
|
|
15422
15436
|
JournalBaselineEventSchema,
|
|
15423
15437
|
QualityAuditCompletedEventSchema,
|
|
15438
|
+
QualityAssessmentScoredEventSchema,
|
|
15424
15439
|
QualityFindingOpenedEventSchema,
|
|
15425
15440
|
QualityFindingResolvedEventSchema,
|
|
15426
15441
|
QualityFindingAcceptedEventSchema,
|
|
@@ -17931,6 +17946,10 @@ function sameFrameworkMajor(a, b) {
|
|
|
17931
17946
|
const right = frameworkMajor(b);
|
|
17932
17947
|
return left === null || right === null || left === right;
|
|
17933
17948
|
}
|
|
17949
|
+
function scopeOf(raw) {
|
|
17950
|
+
if (!isRecord2(raw) || typeof raw.since !== "string" || raw.since === "") return void 0;
|
|
17951
|
+
return { scope: { since: raw.since, cells: typeof raw.cells === "number" && Number.isFinite(raw.cells) ? raw.cells : null } };
|
|
17952
|
+
}
|
|
17934
17953
|
function cleanScores(raw) {
|
|
17935
17954
|
const scores = {};
|
|
17936
17955
|
if (!isRecord2(raw)) return scores;
|
|
@@ -18001,7 +18020,9 @@ function deriveQualityTrend(events, profile, live) {
|
|
|
18001
18020
|
comparable: true,
|
|
18002
18021
|
scores,
|
|
18003
18022
|
overall,
|
|
18004
|
-
counts: cleanCounts(event.counts)
|
|
18023
|
+
counts: cleanCounts(event.counts),
|
|
18024
|
+
...event.baseline === true ? { baseline: true } : {},
|
|
18025
|
+
...scopeOf(event.scope) ?? {}
|
|
18005
18026
|
};
|
|
18006
18027
|
byAudit.delete(auditId);
|
|
18007
18028
|
byAudit.set(auditId, snapshot);
|
|
@@ -18057,7 +18078,9 @@ function trendRows(trend, filter = {}) {
|
|
|
18057
18078
|
...snapshot.commit !== void 0 ? { commit: snapshot.commit } : {},
|
|
18058
18079
|
...snapshot.framework_version !== void 0 ? { framework_version: snapshot.framework_version } : {},
|
|
18059
18080
|
comparable: snapshot.comparable,
|
|
18060
|
-
cells
|
|
18081
|
+
cells,
|
|
18082
|
+
...snapshot.baseline ? { baseline: true } : {},
|
|
18083
|
+
...snapshot.scope !== void 0 ? { scope: snapshot.scope } : {}
|
|
18061
18084
|
});
|
|
18062
18085
|
});
|
|
18063
18086
|
return { surfaces, rows };
|
|
@@ -18213,6 +18236,49 @@ function deriveAuditScope(events, section, library, options = {}) {
|
|
|
18213
18236
|
);
|
|
18214
18237
|
return { since, since_ts: sinceTs, cells: sorted, findings: drivers, resolved_by: resolvedBy, unknown: unknown2, unscorable, widened };
|
|
18215
18238
|
}
|
|
18239
|
+
function scopedAuditId(input) {
|
|
18240
|
+
const { since, month, requested, known, recorded, open } = input;
|
|
18241
|
+
const newest = [...known].sort().at(-1);
|
|
18242
|
+
if (requested !== void 0) {
|
|
18243
|
+
if (requested === since) {
|
|
18244
|
+
throw new Error(
|
|
18245
|
+
`"${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.`
|
|
18246
|
+
);
|
|
18247
|
+
}
|
|
18248
|
+
if (recorded.includes(requested)) {
|
|
18249
|
+
throw new Error(`"${requested}" is already recorded \u2014 its reading is history. Name a new audit.`);
|
|
18250
|
+
}
|
|
18251
|
+
if (newest !== void 0 && requested < newest) {
|
|
18252
|
+
throw new Error(
|
|
18253
|
+
`"${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)}\`).`
|
|
18254
|
+
);
|
|
18255
|
+
}
|
|
18256
|
+
return requested;
|
|
18257
|
+
}
|
|
18258
|
+
if (open !== void 0 && (newest === void 0 || open >= newest)) return open;
|
|
18259
|
+
for (const candidate of scopedCandidates(month)) {
|
|
18260
|
+
if (known.includes(candidate)) continue;
|
|
18261
|
+
if (newest !== void 0 && candidate < newest) {
|
|
18262
|
+
throw new Error(
|
|
18263
|
+
`"${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)}\`).`
|
|
18264
|
+
);
|
|
18265
|
+
}
|
|
18266
|
+
return candidate;
|
|
18267
|
+
}
|
|
18268
|
+
throw new Error(`99 scoped audits in ${month} \u2014 name the next one yourself.`);
|
|
18269
|
+
}
|
|
18270
|
+
function* scopedCandidates(month) {
|
|
18271
|
+
for (let n = 1; n < 100; n++) yield n === 1 ? `${month}-scoped` : `${month}-scoped-${String(n).padStart(2, "0")}`;
|
|
18272
|
+
}
|
|
18273
|
+
function suggestedAuditId({ since, month, requested, known, recorded }) {
|
|
18274
|
+
const taken = /* @__PURE__ */ new Set([...known, ...recorded, since, ...requested !== void 0 ? [requested] : []]);
|
|
18275
|
+
const floor = [...taken].sort().at(-1);
|
|
18276
|
+
for (const candidate of scopedCandidates(month)) {
|
|
18277
|
+
if (taken.has(candidate)) continue;
|
|
18278
|
+
if (floor === void 0 || candidate > floor) return candidate;
|
|
18279
|
+
}
|
|
18280
|
+
return `${floor}-scoped`;
|
|
18281
|
+
}
|
|
18216
18282
|
function scopeSummary(scope) {
|
|
18217
18283
|
const direct = scope.cells.length - scope.widened;
|
|
18218
18284
|
const cells = `${scope.cells.length} cell${scope.cells.length === 1 ? "" : "s"} to re-score`;
|
|
@@ -18221,6 +18287,78 @@ function scopeSummary(scope) {
|
|
|
18221
18287
|
return `${cells}${split} from ${from}${scope.since !== null ? ` since ${scope.since}` : ""}`;
|
|
18222
18288
|
}
|
|
18223
18289
|
|
|
18290
|
+
// ../schema/src/quality-baseline.ts
|
|
18291
|
+
var EPOCH = "1970-01-01T00:00:00.000Z";
|
|
18292
|
+
var DECISIONS = /* @__PURE__ */ new Set(["quality.finding.resolved", "quality.finding.accepted"]);
|
|
18293
|
+
var REVERTIBLE = /* @__PURE__ */ new Set(["resolved", "accepted-risk"]);
|
|
18294
|
+
var SCOPED_AUDIT_ID = /-scoped(-\d+)?$/;
|
|
18295
|
+
var rowsOf3 = (value) => Array.isArray(value) ? value : [];
|
|
18296
|
+
var isString2 = (value) => typeof value === "string" && value !== "";
|
|
18297
|
+
var isScopedAuditId = (value) => isString2(value) && SCOPED_AUDIT_ID.test(value);
|
|
18298
|
+
var isRow = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
18299
|
+
var objectRowsOf = (value) => rowsOf3(value).filter(isRow);
|
|
18300
|
+
function omit2(obj, keys) {
|
|
18301
|
+
const out = { ...obj };
|
|
18302
|
+
for (const key of keys) delete out[key];
|
|
18303
|
+
return out;
|
|
18304
|
+
}
|
|
18305
|
+
function isoOf(value) {
|
|
18306
|
+
if (!isString2(value)) return void 0;
|
|
18307
|
+
const at = Date.parse(value);
|
|
18308
|
+
return Number.isFinite(at) ? new Date(at).toISOString() : void 0;
|
|
18309
|
+
}
|
|
18310
|
+
function oneMsBefore(iso) {
|
|
18311
|
+
const before = new Date(Date.parse(iso) - 1);
|
|
18312
|
+
return Number.isNaN(before.getTime()) ? EPOCH : before.toISOString();
|
|
18313
|
+
}
|
|
18314
|
+
function implicitAuditBaseline(events, section, library) {
|
|
18315
|
+
const rows = objectRowsOf(events);
|
|
18316
|
+
if (rows.some((event) => event.type === "quality.audit.completed")) return null;
|
|
18317
|
+
const assessmentRows = objectRowsOf(section?.assessments).filter((row) => !isScopedAuditId(row.audit_id));
|
|
18318
|
+
const taggedAssessments = assessmentRows.filter((row) => isString2(row.audit_id));
|
|
18319
|
+
if (taggedAssessments.length === 0) return null;
|
|
18320
|
+
const auditId = taggedAssessments.map((row) => row.audit_id).sort().at(-1);
|
|
18321
|
+
const assessedAts = taggedAssessments.filter((row) => row.audit_id === auditId).map((row) => isoOf(row.ts)).filter((at) => at !== void 0).sort();
|
|
18322
|
+
const auditStart = assessedAts[0];
|
|
18323
|
+
const assessedAt = assessedAts.at(-1);
|
|
18324
|
+
const ordered = orderEvents(rows);
|
|
18325
|
+
const sortKeyOf = (event) => typeof event.ts === "string" ? event.ts : "";
|
|
18326
|
+
const decisions = ordered.filter(
|
|
18327
|
+
(event) => DECISIONS.has(event.type) && (auditStart === void 0 || sortKeyOf(event) >= auditStart)
|
|
18328
|
+
);
|
|
18329
|
+
const firstDecision = decisions[0];
|
|
18330
|
+
let ts;
|
|
18331
|
+
if (firstDecision === void 0) {
|
|
18332
|
+
ts = assessedAt ?? EPOCH;
|
|
18333
|
+
} else {
|
|
18334
|
+
const decidedAt = isoOf(firstDecision.ts);
|
|
18335
|
+
if (decidedAt === void 0) {
|
|
18336
|
+
ts = EPOCH;
|
|
18337
|
+
} else {
|
|
18338
|
+
const justBefore = oneMsBefore(decidedAt);
|
|
18339
|
+
ts = assessedAt !== void 0 && assessedAt < justBefore ? assessedAt : justBefore;
|
|
18340
|
+
}
|
|
18341
|
+
if (!(ts < sortKeyOf(firstDecision))) ts = EPOCH;
|
|
18342
|
+
}
|
|
18343
|
+
const decided = /* @__PURE__ */ new Set();
|
|
18344
|
+
for (const event of decisions) {
|
|
18345
|
+
const id = event.finding_id;
|
|
18346
|
+
if (isString2(id)) decided.add(id);
|
|
18347
|
+
}
|
|
18348
|
+
const findings = objectRowsOf(section?.findings).map((finding) => {
|
|
18349
|
+
if (!isString2(finding.id) || !decided.has(finding.id) || !REVERTIBLE.has(finding.status)) return finding;
|
|
18350
|
+
return { ...omit2(finding, ["resolved_by"]), status: "open" };
|
|
18351
|
+
});
|
|
18352
|
+
const matrix = deriveQualityMatrix({ quality: { ...section, assessments: assessmentRows, findings } }, library);
|
|
18353
|
+
const frameworkVersion = matrix.framework_version ?? library?.version ?? "unknown";
|
|
18354
|
+
const input = auditCompletedInput(matrix, { audit_id: auditId, framework_version: frameworkVersion });
|
|
18355
|
+
return { id: `implicit-baseline:${auditId}`, ts, type: input.type, ...input.payload, baseline: true };
|
|
18356
|
+
}
|
|
18357
|
+
function withImplicitBaseline(events, section, library) {
|
|
18358
|
+
const baseline = implicitAuditBaseline(events, section, library);
|
|
18359
|
+
return baseline === null ? events : [baseline, ...events];
|
|
18360
|
+
}
|
|
18361
|
+
|
|
18224
18362
|
// ../schema/src/cli/kritik-audit.ts
|
|
18225
18363
|
import { existsSync as existsSync2, readdirSync, statSync } from "node:fs";
|
|
18226
18364
|
import { join as join2 } from "node:path";
|
|
@@ -18360,35 +18498,10 @@ function mergeAudits(root, auditIds, library, profile) {
|
|
|
18360
18498
|
};
|
|
18361
18499
|
}
|
|
18362
18500
|
function scopedAuditTarget(root, since, month, requested, recorded = []) {
|
|
18363
|
-
const
|
|
18364
|
-
const newest =
|
|
18365
|
-
|
|
18366
|
-
|
|
18367
|
-
throw new Error(
|
|
18368
|
-
`"${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.`
|
|
18369
|
-
);
|
|
18370
|
-
}
|
|
18371
|
-
if (newest !== void 0 && requested < newest) {
|
|
18372
|
-
throw new Error(
|
|
18373
|
-
`"${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\`).`
|
|
18374
|
-
);
|
|
18375
|
-
}
|
|
18376
|
-
return requested;
|
|
18377
|
-
}
|
|
18378
|
-
if (newest !== void 0 && newest !== since && !recorded.includes(newest) && loadScoresOrEmpty(root, newest).scope?.since === since) {
|
|
18379
|
-
return newest;
|
|
18380
|
-
}
|
|
18381
|
-
for (let n = 1; n < 100; n++) {
|
|
18382
|
-
const candidate = n === 1 ? `${month}-scoped` : `${month}-scoped-${String(n).padStart(2, "0")}`;
|
|
18383
|
-
if (existing.includes(candidate)) continue;
|
|
18384
|
-
if (newest !== void 0 && candidate < newest) {
|
|
18385
|
-
throw new Error(
|
|
18386
|
-
`"${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}".`
|
|
18387
|
-
);
|
|
18388
|
-
}
|
|
18389
|
-
return candidate;
|
|
18390
|
-
}
|
|
18391
|
-
throw new Error(`99 scoped audits in ${month} \u2014 name the next one with --audit.`);
|
|
18501
|
+
const known = listAuditIds(root);
|
|
18502
|
+
const newest = known[known.length - 1];
|
|
18503
|
+
const open = newest !== void 0 && newest !== since && !recorded.includes(newest) && loadScoresOrEmpty(root, newest).scope?.since === since ? newest : void 0;
|
|
18504
|
+
return scopedAuditId({ since, month, requested, known, recorded, open });
|
|
18392
18505
|
}
|
|
18393
18506
|
function declaredScopeSince(auditId, recorded) {
|
|
18394
18507
|
if (recorded.includes(auditId)) {
|
|
@@ -18597,6 +18710,7 @@ async function appendHosted(store2, inputs) {
|
|
|
18597
18710
|
throw new ToolError(error51.message);
|
|
18598
18711
|
}
|
|
18599
18712
|
}
|
|
18713
|
+
var NO_HOSTED_AUDIT = "This hosted project has no audit to measure from. One must be run in the repository and restored (`arkaik restore`) first \u2014 a hosted session cannot write one.";
|
|
18600
18714
|
function hostedSection(graph) {
|
|
18601
18715
|
const section = graph.loaded.bundle.quality;
|
|
18602
18716
|
if (section === void 0 || !Array.isArray(section.findings) || !Array.isArray(section.assessments)) {
|
|
@@ -18609,6 +18723,21 @@ function hostedSection(graph) {
|
|
|
18609
18723
|
function refuseHostedRecord(eventType) {
|
|
18610
18724
|
throw new ToolError(`Recording ${eventType} belongs to the audit run, which reads code. Run the audit where the checkout is.`);
|
|
18611
18725
|
}
|
|
18726
|
+
function hostedMatrixRead(graph) {
|
|
18727
|
+
const { section, library } = hostedSection(graph);
|
|
18728
|
+
const m = deriveQualityMatrix({ quality: section }, library);
|
|
18729
|
+
const { open, lanes, p0 } = openFindingsSummary(section.findings, library);
|
|
18730
|
+
return {
|
|
18731
|
+
...m.framework_version !== void 0 ? { framework_version: m.framework_version } : {},
|
|
18732
|
+
matrix: m.matrix,
|
|
18733
|
+
overall: m.overall,
|
|
18734
|
+
finding_counts: m.finding_counts,
|
|
18735
|
+
assessment_count: section.assessments.length,
|
|
18736
|
+
open_findings: open.length,
|
|
18737
|
+
lanes,
|
|
18738
|
+
p0
|
|
18739
|
+
};
|
|
18740
|
+
}
|
|
18612
18741
|
function openFindingsSummary(findings, library) {
|
|
18613
18742
|
const open = findings.filter(isOpenFinding);
|
|
18614
18743
|
const lanes = { P0: 0, P1: 0, P2: 0, P3: 0 };
|
|
@@ -18740,21 +18869,15 @@ function buildKritikCatalog(ctx) {
|
|
|
18740
18869
|
throw new ToolError(`Cannot load ${ctx.store.describe()}: ${error51.message}`);
|
|
18741
18870
|
}
|
|
18742
18871
|
};
|
|
18743
|
-
const
|
|
18744
|
-
if (options.since !== void 0) {
|
|
18745
|
-
const recorded = recordedAuditIds(graph.journal);
|
|
18746
|
-
if (!recorded.includes(options.since)) {
|
|
18747
|
-
throw new ToolError(
|
|
18748
|
-
`No recorded audit "${options.since}" in this journal (recorded: ${recorded.join(", ") || "none"}). A scope is measured from a recorded reading \u2014 kritik_matrix with record=true writes one.`
|
|
18749
|
-
);
|
|
18750
|
-
}
|
|
18751
|
-
}
|
|
18872
|
+
const scopeOf2 = (graph, options = {}) => {
|
|
18752
18873
|
let section;
|
|
18753
18874
|
let library;
|
|
18875
|
+
let events;
|
|
18754
18876
|
if (ctx.qualityRoot === void 0) {
|
|
18755
18877
|
const hosted = hostedSection(graph);
|
|
18756
18878
|
section = hosted.section;
|
|
18757
18879
|
library = hosted.library ?? { criteria: [] };
|
|
18880
|
+
events = withImplicitBaseline(graph.journal, hosted.section, hosted.library);
|
|
18758
18881
|
} else {
|
|
18759
18882
|
const root = ctx.qualityRoot;
|
|
18760
18883
|
const full = libraryOf(root);
|
|
@@ -18765,24 +18888,39 @@ function buildKritikCatalog(ctx) {
|
|
|
18765
18888
|
throw new ToolError(error51.message);
|
|
18766
18889
|
}
|
|
18767
18890
|
library = full;
|
|
18891
|
+
events = graph.journal;
|
|
18892
|
+
}
|
|
18893
|
+
if (options.since !== void 0) {
|
|
18894
|
+
const recorded = recordedAuditIds(events);
|
|
18895
|
+
if (!recorded.includes(options.since)) {
|
|
18896
|
+
const hint = ctx.qualityRoot !== void 0 ? "A scope is measured from a recorded reading \u2014 kritik_matrix with record=true writes one." : recorded.length > 0 ? "Pass one of the recorded audits, or leave since off to measure from the newest." : NO_HOSTED_AUDIT;
|
|
18897
|
+
throw new ToolError(`No recorded audit "${options.since}" in this journal (recorded: ${recorded.join(", ") || "none"}). ${hint}`);
|
|
18898
|
+
}
|
|
18768
18899
|
}
|
|
18769
|
-
return deriveAuditScope(
|
|
18900
|
+
return deriveAuditScope(events, section, library, options);
|
|
18770
18901
|
};
|
|
18771
18902
|
tool(
|
|
18772
18903
|
{
|
|
18773
18904
|
name: "kritik_matrix",
|
|
18774
|
-
description: "The comparative quality matrix: a score and grade per (domain x surface), the weighted roll-up per surface, and open findings by priority lane. Anti-averaging caps are applied \u2014 one open Critical caps its cell at D, one open High at B \u2014 so a cell full of 3s cannot absorb a live defect. In repo mode this refreshes the audit's matrix.json, and with record=true appends quality.audit.completed; in hosted mode it is a read of the stored quality section
|
|
18905
|
+
description: "The comparative quality matrix: a score and grade per (domain x surface), the weighted roll-up per surface, and open findings by priority lane. Anti-averaging caps are applied \u2014 one open Critical caps its cell at D, one open High at B \u2014 so a cell full of 3s cannot absorb a live defect. In repo mode this refreshes the audit's matrix.json, and with record=true appends quality.audit.completed; in hosted mode it is a read of the stored quality section, and record=true (with the audit_id kritik_score returned) records that scoped re-audit \u2014 the server computes the reading from the scores it holds, rather than accepting one on the wire. A scoped re-audit (scored with kritik_score scope=true, or, in repo mode, declared with scope=true here) returns `scope` and records the MERGED matrix through it with a scope marker, so the trend never reads its unscored cells as dropped; matrix.json stays this audit alone.",
|
|
18775
18906
|
inputSchema: {
|
|
18776
18907
|
type: "object",
|
|
18777
18908
|
properties: {
|
|
18778
|
-
audit_id: {
|
|
18909
|
+
audit_id: {
|
|
18910
|
+
type: "string",
|
|
18911
|
+
description: "Default: the newest audit on disk. Hosted: required with record=true, refused otherwise."
|
|
18912
|
+
},
|
|
18779
18913
|
record: {
|
|
18780
18914
|
type: "boolean",
|
|
18781
|
-
description: "Append quality.audit.completed carrying these scores and counts. Once per finished audit."
|
|
18915
|
+
description: "Append quality.audit.completed carrying these scores and counts. Once per finished audit. Hosted: the server computes the scores and counts."
|
|
18782
18916
|
},
|
|
18783
18917
|
scope: {
|
|
18784
18918
|
type: "boolean",
|
|
18785
18919
|
description: "Treat the audit as a scoped re-audit even though it was scored without kritik_score scope=true (which marks it). Repo mode only."
|
|
18920
|
+
},
|
|
18921
|
+
commit: {
|
|
18922
|
+
type: "string",
|
|
18923
|
+
description: "Hosted record only: the commit the scoped re-audit read. Repo mode reads it from the audit's scores.json."
|
|
18786
18924
|
}
|
|
18787
18925
|
},
|
|
18788
18926
|
additionalProperties: false
|
|
@@ -18791,26 +18929,79 @@ function buildKritikCatalog(ctx) {
|
|
|
18791
18929
|
async (args) => {
|
|
18792
18930
|
const hosted = ctx.qualityRoot === void 0;
|
|
18793
18931
|
if (hosted) {
|
|
18794
|
-
if (args.record === true)
|
|
18795
|
-
|
|
18932
|
+
if (args.record === true) {
|
|
18933
|
+
if (typeof args.audit_id !== "string" || args.audit_id === "") {
|
|
18934
|
+
throw new ToolError(
|
|
18935
|
+
"record=true in a hosted session records a scoped re-audit: pass the audit_id kritik_score returned (e.g. 2026-09-scoped)."
|
|
18936
|
+
);
|
|
18937
|
+
}
|
|
18938
|
+
const auditId2 = args.audit_id;
|
|
18939
|
+
const commit = typeof args.commit === "string" && args.commit !== "" ? args.commit : void 0;
|
|
18940
|
+
const graph3 = await load2();
|
|
18941
|
+
const scope2 = scopeOf2(graph3);
|
|
18942
|
+
const scoredForAudit = graph3.journal.filter(
|
|
18943
|
+
(event) => event.type === "quality.assessment.scored" && event.audit_id === auditId2
|
|
18944
|
+
);
|
|
18945
|
+
const scoredSince = scoredForAudit.map((event) => event.scope?.since).find((since2) => typeof since2 === "string");
|
|
18946
|
+
let leftUnscored2 = [];
|
|
18947
|
+
if (scope2.since !== null && scoredSince === scope2.since) {
|
|
18948
|
+
const done = new Set(
|
|
18949
|
+
scoredForAudit.map(
|
|
18950
|
+
(event) => `${String(event.criterion_id)}::${String(event.surface)}`
|
|
18951
|
+
)
|
|
18952
|
+
);
|
|
18953
|
+
leftUnscored2 = scope2.cells.filter((cell) => !done.has(`${cell.criterion_id}::${cell.surface}`)).map((cell) => ({ criterion_id: cell.criterion_id, surface: cell.surface, kind: cell.kind }));
|
|
18954
|
+
}
|
|
18955
|
+
if (ctx.store.appendQualityEvents === void 0) {
|
|
18956
|
+
throw new ToolError(`${ctx.store.describe()} cannot append quality events.`);
|
|
18957
|
+
}
|
|
18958
|
+
let events2;
|
|
18959
|
+
try {
|
|
18960
|
+
events2 = await ctx.store.appendQualityEvents([
|
|
18961
|
+
{ type: "quality.audit.completed", scope: true, audit_id: auditId2, ...commit !== void 0 ? { commit } : {} }
|
|
18962
|
+
]);
|
|
18963
|
+
} catch (error51) {
|
|
18964
|
+
const refusals = error51.refusals;
|
|
18965
|
+
if (Array.isArray(refusals) && refusals.length > 0 && refusals.every((r) => r.reason === "already_recorded") && scoredForAudit.length > 0) {
|
|
18966
|
+
const reloaded2 = await load2();
|
|
18967
|
+
const landed = reloaded2.journal.find(
|
|
18968
|
+
(event) => event.type === "quality.audit.completed" && event.audit_id === auditId2 && event.baseline !== true && event.scope?.partial === true
|
|
18969
|
+
);
|
|
18970
|
+
if (landed !== void 0) {
|
|
18971
|
+
return {
|
|
18972
|
+
...hostedMatrixRead(reloaded2),
|
|
18973
|
+
audit_id: auditId2,
|
|
18974
|
+
scope: landed.scope,
|
|
18975
|
+
// Not reconstructable: recording re-anchors the scope on
|
|
18976
|
+
// the landed reading itself, so "what's left" no longer
|
|
18977
|
+
// means what it meant before the write landed.
|
|
18978
|
+
events: [landed],
|
|
18979
|
+
note: "Already recorded \u2014 returning the reading that landed. left_unscored can't be reconstructed after recording."
|
|
18980
|
+
};
|
|
18981
|
+
}
|
|
18982
|
+
}
|
|
18983
|
+
throw new ToolError(error51.message);
|
|
18984
|
+
}
|
|
18985
|
+
const reloaded = await load2();
|
|
18986
|
+
const recorded = events2.find((event) => event.type === "quality.audit.completed");
|
|
18987
|
+
return {
|
|
18988
|
+
...hostedMatrixRead(reloaded),
|
|
18989
|
+
audit_id: auditId2,
|
|
18990
|
+
scope: recorded?.scope,
|
|
18991
|
+
left_unscored: leftUnscored2,
|
|
18992
|
+
events: events2
|
|
18993
|
+
};
|
|
18994
|
+
}
|
|
18995
|
+
if (args.scope === true) {
|
|
18996
|
+
throw new ToolError(
|
|
18997
|
+
"In a hosted session a scoped re-audit is recorded with record=true and its audit_id; the read is always the current state."
|
|
18998
|
+
);
|
|
18999
|
+
}
|
|
18796
19000
|
if (typeof args.audit_id === "string" && args.audit_id !== "") {
|
|
18797
19001
|
throw new ToolError("The hosted matrix is the current state, not one audit \u2014 audit_id does not partition it (issue #400 decision 3).");
|
|
18798
19002
|
}
|
|
18799
19003
|
const graph2 = await load2();
|
|
18800
|
-
|
|
18801
|
-
const m = deriveQualityMatrix({ quality: section2 }, library2);
|
|
18802
|
-
const { open: open2, lanes: lanes2, p0: p02 } = openFindingsSummary(section2.findings, library2);
|
|
18803
|
-
return {
|
|
18804
|
-
...m.framework_version !== void 0 ? { framework_version: m.framework_version } : {},
|
|
18805
|
-
matrix: m.matrix,
|
|
18806
|
-
overall: m.overall,
|
|
18807
|
-
finding_counts: m.finding_counts,
|
|
18808
|
-
assessment_count: section2.assessments.length,
|
|
18809
|
-
open_findings: open2.length,
|
|
18810
|
-
lanes: lanes2,
|
|
18811
|
-
p0: p02,
|
|
18812
|
-
events: []
|
|
18813
|
-
};
|
|
19004
|
+
return { ...hostedMatrixRead(graph2), events: [] };
|
|
18814
19005
|
}
|
|
18815
19006
|
const root = repoRootOf(ctx, REPO_MODE_ONLY);
|
|
18816
19007
|
const library = libraryOf(root);
|
|
@@ -18842,7 +19033,7 @@ function buildKritikCatalog(ctx) {
|
|
|
18842
19033
|
let leftUnscored = [];
|
|
18843
19034
|
if (scope !== void 0) {
|
|
18844
19035
|
graph = graph ?? await load2();
|
|
18845
|
-
const current =
|
|
19036
|
+
const current = scopeOf2(graph);
|
|
18846
19037
|
if (current.since === scope.since) {
|
|
18847
19038
|
const done = new Set(section.assessments.map((a) => `${a.criterion_id}::${a.surface}`));
|
|
18848
19039
|
leftUnscored = current.cells.filter((cell) => !done.has(`${cell.criterion_id}::${cell.surface}`)).map((cell) => ({ criterion_id: cell.criterion_id, surface: cell.surface, kind: cell.kind }));
|
|
@@ -18867,6 +19058,7 @@ function buildKritikCatalog(ctx) {
|
|
|
18867
19058
|
})
|
|
18868
19059
|
]);
|
|
18869
19060
|
}
|
|
19061
|
+
const notes = typeof args.commit === "string" && args.commit !== "" ? ["commit is only used when recording in a hosted session \u2014 repo mode reads it from the audit's scores.json"] : void 0;
|
|
18870
19062
|
return {
|
|
18871
19063
|
...file2,
|
|
18872
19064
|
...scope !== void 0 ? { scope, left_unscored: leftUnscored } : {},
|
|
@@ -18874,7 +19066,8 @@ function buildKritikCatalog(ctx) {
|
|
|
18874
19066
|
open_findings: open.length,
|
|
18875
19067
|
lanes,
|
|
18876
19068
|
p0,
|
|
18877
|
-
events
|
|
19069
|
+
events,
|
|
19070
|
+
...notes !== void 0 ? { notes } : {}
|
|
18878
19071
|
};
|
|
18879
19072
|
}
|
|
18880
19073
|
);
|
|
@@ -19041,7 +19234,7 @@ function buildKritikCatalog(ctx) {
|
|
|
19041
19234
|
tool(
|
|
19042
19235
|
{
|
|
19043
19236
|
name: "kritik_trend",
|
|
19044
|
-
description: "Where the product stood at each recorded audit, oldest first: one row per quality.audit.completed in the journal, the overall score per surface (or one domain's score with domain), and how each moved against the row above. The score, not the findings \u2014 'from where we started to where we are now'. Rows are ordered by when they were recorded, a re-recorded audit id keeps only its latest reading, and a framework major bump between two audits marks the later row comparable=false with no delta across it. Works in both modes: repo reads the journal sidecar, hosted reads the hosted journal.",
|
|
19237
|
+
description: "Where the product stood at each recorded audit, oldest first: one row per quality.audit.completed in the journal, the overall score per surface (or one domain's score with domain), and how each moved against the row above. The score, not the findings \u2014 'from where we started to where we are now'. Rows are ordered by when they were recorded, a re-recorded audit id keeps only its latest reading, and a framework major bump between two audits marks the later row comparable=false with no delta across it. Works in both modes: repo reads the journal sidecar, hosted reads the hosted journal \u2014 and there a restored audit with no recorded reading appears as a baseline first row.",
|
|
19045
19238
|
inputSchema: {
|
|
19046
19239
|
type: "object",
|
|
19047
19240
|
properties: {
|
|
@@ -19053,8 +19246,10 @@ function buildKritikCatalog(ctx) {
|
|
|
19053
19246
|
},
|
|
19054
19247
|
async (args) => {
|
|
19055
19248
|
const graph = await load2();
|
|
19056
|
-
const
|
|
19057
|
-
const
|
|
19249
|
+
const quality = ctx.qualityRoot === void 0 ? graph.loaded.bundle.quality : void 0;
|
|
19250
|
+
const profile = ctx.qualityRoot === void 0 ? quality?.profile : loadProfile(ctx.qualityRoot) ?? void 0;
|
|
19251
|
+
const events = quality !== void 0 && Array.isArray(quality.assessments) && Array.isArray(quality.findings) ? withImplicitBaseline(graph.journal, quality, resolveKritikLibrary(quality)) : graph.journal;
|
|
19252
|
+
const trend = deriveQualityTrend(events, profile);
|
|
19058
19253
|
const filter = {
|
|
19059
19254
|
...typeof args.surface === "string" && args.surface !== "" ? { surface: args.surface } : {},
|
|
19060
19255
|
...typeof args.domain === "string" && args.domain !== "" ? { domain: args.domain } : {}
|
|
@@ -19065,14 +19260,21 @@ function buildKritikCatalog(ctx) {
|
|
|
19065
19260
|
surfaces,
|
|
19066
19261
|
rows,
|
|
19067
19262
|
snapshots: trend.snapshots,
|
|
19068
|
-
...trend.snapshots.length === 0 ? { note: "No recorded audits yet \u2014 `kritik_matrix` with record=true writes one." } : {
|
|
19263
|
+
...trend.snapshots.length === 0 ? { note: ctx.qualityRoot === void 0 ? NO_HOSTED_AUDIT : "No recorded audits yet \u2014 `kritik_matrix` with record=true writes one." } : rows[0]?.baseline === true ? {
|
|
19264
|
+
// Synthesized only until the first hosted score writes the
|
|
19265
|
+
// baseline for real (flagged `baseline: true`); after that the
|
|
19266
|
+
// row IS a recorded reading, and saying otherwise is false.
|
|
19267
|
+
note: graph.journal.some(
|
|
19268
|
+
(event) => event.type === "quality.audit.completed" && event.baseline === true
|
|
19269
|
+
) ? "The first row is the restored audit's reading, recorded when the first hosted score landed." : "The first row is the restored audit's reading, rebuilt from its stored scores \u2014 no reading was recorded for it."
|
|
19270
|
+
} : {}
|
|
19069
19271
|
};
|
|
19070
19272
|
}
|
|
19071
19273
|
);
|
|
19072
19274
|
tool(
|
|
19073
19275
|
{
|
|
19074
19276
|
name: "kritik_scope",
|
|
19075
|
-
description: "The cells a batch of fixes made stale \u2014 the work list for a scoped re-audit. A score only moves when its cell is re-scored, so after closing findings this lists exactly which (criterion x surface) cells to re-score instead of running a comprehensive audit: every quality.finding.resolved since the last recorded audit names its cell (`kind: direct`, `because` = finding ids), and one hop over node_ids adds neighbouring assessed cells a shared fix plausibly moved (`kind: widened`, `because` = node ids). Accepted risks are not fixes and never scope anything. `unknown` lists resolved ids that name no finding \u2014 report those, something closed an id that does not exist; `unscorable` lists resolved findings whose cell nothing can re-score (a retired criterion, a surface no longer in the profile). It plans an audit and scores nothing: re-score each cell with kritik_score, evidence and scope=true (which writes into an audit of its own, `<YYYY-MM>-scoped`, never the `since` audit whose recorded reading is history), then kritik_matrix with that audit_id and record=true. Recording closes the window: a cell left unscored drops out of the next scope, so re-score a widened cell that did not move at its current level, saying so in the evidence. Works in both modes \u2014 hosted reads the hosted journal and quality section.",
|
|
19277
|
+
description: "The cells a batch of fixes made stale \u2014 the work list for a scoped re-audit. A score only moves when its cell is re-scored, so after closing findings this lists exactly which (criterion x surface) cells to re-score instead of running a comprehensive audit: every quality.finding.resolved since the last recorded audit names its cell (`kind: direct`, `because` = finding ids), and one hop over node_ids adds neighbouring assessed cells a shared fix plausibly moved (`kind: widened`, `because` = node ids). Accepted risks are not fixes and never scope anything. `unknown` lists resolved ids that name no finding \u2014 report those, something closed an id that does not exist; `unscorable` lists resolved findings whose cell nothing can re-score (a retired criterion, a surface no longer in the profile). It plans an audit and scores nothing: re-score each cell with kritik_score, evidence and scope=true (which writes into an audit of its own, `<YYYY-MM>-scoped`, never the `since` audit whose recorded reading is history), then kritik_matrix with that audit_id and record=true. Recording closes the window: a cell left unscored drops out of the next scope, so re-score a widened cell that did not move at its current level, saying so in the evidence. Works in both modes \u2014 hosted reads the hosted journal and quality section. In a hosted project whose audit arrived by restore with no recorded reading, the scope measures from that audit, dated where it was taken. In a hosted session, open_audit and rescored show what the scoped re-audit in progress has already covered \u2014 record only when every cell is rescored. In a hosted session the server checks each kritik_score against the default scope (measured from the newest recorded audit, widened), so since and widen=false only change what this read shows, not which cells kritik_score accepts.",
|
|
19076
19278
|
inputSchema: {
|
|
19077
19279
|
type: "object",
|
|
19078
19280
|
properties: {
|
|
@@ -19085,14 +19287,52 @@ function buildKritikCatalog(ctx) {
|
|
|
19085
19287
|
async (args) => {
|
|
19086
19288
|
const graph = await load2();
|
|
19087
19289
|
const since = typeof args.since === "string" && args.since !== "" ? args.since : void 0;
|
|
19088
|
-
const scope =
|
|
19290
|
+
const scope = scopeOf2(graph, {
|
|
19089
19291
|
...since !== void 0 ? { since } : {},
|
|
19090
19292
|
...args.widen === false ? { widen: false } : {}
|
|
19091
19293
|
});
|
|
19294
|
+
let openAudit = null;
|
|
19295
|
+
let cells = scope.cells;
|
|
19296
|
+
if (ctx.qualityRoot === void 0 && scope.since !== null) {
|
|
19297
|
+
const { section, library } = hostedSection(graph);
|
|
19298
|
+
const recorded = new Set(recordedAuditIds(withImplicitBaseline(graph.journal, section, library)));
|
|
19299
|
+
const scoredEvents = graph.journal.filter((event) => event.type === "quality.assessment.scored");
|
|
19300
|
+
const auditIdOf = (event) => {
|
|
19301
|
+
const id = event.audit_id;
|
|
19302
|
+
return typeof id === "string" && id !== "" ? id : void 0;
|
|
19303
|
+
};
|
|
19304
|
+
const sinceOf = (event) => {
|
|
19305
|
+
const since2 = event.scope?.since;
|
|
19306
|
+
return typeof since2 === "string" && since2 !== "" ? since2 : void 0;
|
|
19307
|
+
};
|
|
19308
|
+
let open;
|
|
19309
|
+
for (const event of scoredEvents) {
|
|
19310
|
+
const id = auditIdOf(event);
|
|
19311
|
+
if (id !== void 0 && sinceOf(event) === scope.since && !recorded.has(id)) open = id;
|
|
19312
|
+
}
|
|
19313
|
+
if (open !== void 0) {
|
|
19314
|
+
const scored = [];
|
|
19315
|
+
for (const event of scoredEvents) {
|
|
19316
|
+
if (auditIdOf(event) !== open || sinceOf(event) !== scope.since) continue;
|
|
19317
|
+
const criterionId = event.criterion_id;
|
|
19318
|
+
const surface = event.surface;
|
|
19319
|
+
if (typeof criterionId === "string" && typeof surface === "string") scored.push({ criterion_id: criterionId, surface });
|
|
19320
|
+
}
|
|
19321
|
+
openAudit = { audit_id: open, scored };
|
|
19322
|
+
const done = new Set(scored.map((cell) => `${cell.criterion_id}::${cell.surface}`));
|
|
19323
|
+
cells = scope.cells.map(
|
|
19324
|
+
(cell) => done.has(`${cell.criterion_id}::${cell.surface}`) ? { ...cell, rescored: true } : cell
|
|
19325
|
+
);
|
|
19326
|
+
}
|
|
19327
|
+
}
|
|
19092
19328
|
return {
|
|
19093
19329
|
...scope,
|
|
19330
|
+
cells,
|
|
19094
19331
|
summary: scopeSummary(scope),
|
|
19095
|
-
...
|
|
19332
|
+
...ctx.qualityRoot === void 0 ? { open_audit: openAudit } : {},
|
|
19333
|
+
...scope.since === null ? {
|
|
19334
|
+
note: ctx.qualityRoot === void 0 ? NO_HOSTED_AUDIT : "No recorded audit yet \u2014 a scope is measured from one. `kritik_matrix` with record=true writes it."
|
|
19335
|
+
} : {}
|
|
19096
19336
|
};
|
|
19097
19337
|
}
|
|
19098
19338
|
);
|
|
@@ -19156,7 +19396,7 @@ function buildKritikCatalog(ctx) {
|
|
|
19156
19396
|
tool(
|
|
19157
19397
|
{
|
|
19158
19398
|
name: "kritik_score",
|
|
19159
|
-
description: "Record one (criterion x surface) maturity level with the evidence behind it. A cell holds exactly one level, so re-scoring replaces in place. Evidence is required: a score without a citation is an opinion, not an assessment. Score what the code IS, never what an open PR promises \u2014 that is what makes a trend real. For a scoped re-audit pass scope=true: a cell kritik_scope does not list is refused (so a between-milestone re-audit cannot drift into a comprehensive one), and the score lands in a scoped audit of its own (default <YYYY-MM>-scoped).
|
|
19399
|
+
description: "Record one (criterion x surface) maturity level with the evidence behind it. A cell holds exactly one level, so re-scoring replaces in place. Evidence is required: a score without a citation is an opinion, not an assessment. Score what the code IS, never what an open PR promises \u2014 that is what makes a trend real. For a scoped re-audit pass scope=true: a cell kritik_scope does not list is refused (so a between-milestone re-audit cannot drift into a comprehensive one), and the score lands in a scoped audit of its own (default <YYYY-MM>-scoped). In a hosted session scoring is scoped-only (scope=true is required) and nothing is written to disk. The server checks the cell against the scope, names the audit (default <YYYY-MM>-scoped), and, for a restored audit with no recorded reading, records that baseline first. You are still reading code: have the product's code at hand to read \u2014 the session can stay hosted \u2014 and pass commit so the evidence can be checked against it.",
|
|
19160
19400
|
inputSchema: {
|
|
19161
19401
|
type: "object",
|
|
19162
19402
|
properties: {
|
|
@@ -19175,7 +19415,7 @@ function buildKritikCatalog(ctx) {
|
|
|
19175
19415
|
commit: { type: "string" },
|
|
19176
19416
|
scope: {
|
|
19177
19417
|
type: "boolean",
|
|
19178
|
-
description: "This is a scoped re-audit: refuse a cell kritik_scope does not list.
|
|
19418
|
+
description: "This is a scoped re-audit: refuse a cell kritik_scope does not list. In repo mode, leave it off to re-score an out-of-scope cell on purpose; a hosted session must pass it."
|
|
19179
19419
|
}
|
|
19180
19420
|
},
|
|
19181
19421
|
required: ["criterion_id", "surface", "level", "evidence"],
|
|
@@ -19183,6 +19423,60 @@ function buildKritikCatalog(ctx) {
|
|
|
19183
19423
|
}
|
|
19184
19424
|
},
|
|
19185
19425
|
async (args) => {
|
|
19426
|
+
if (ctx.qualityRoot === void 0) {
|
|
19427
|
+
if (args.scope !== true) {
|
|
19428
|
+
throw new ToolError(
|
|
19429
|
+
"A hosted session scores only a scoped re-audit: pass scope=true and score the cells kritik_scope lists. A comprehensive audit is a different, repo-mode operation \u2014 it runs in a session pointed at a checkout, not this one."
|
|
19430
|
+
);
|
|
19431
|
+
}
|
|
19432
|
+
const graph2 = await load2();
|
|
19433
|
+
const { library: library2 } = hostedSection(graph2);
|
|
19434
|
+
const criterionId2 = requireString(args, "criterion_id");
|
|
19435
|
+
const surface2 = requireString(args, "surface");
|
|
19436
|
+
const level2 = requireInt(args, "level", 0, 4);
|
|
19437
|
+
const evidence2 = requireString(args, "evidence");
|
|
19438
|
+
const commit = typeof args.commit === "string" && args.commit !== "" ? args.commit : void 0;
|
|
19439
|
+
const events = await appendHosted(ctx.store, [
|
|
19440
|
+
{
|
|
19441
|
+
type: "quality.assessment.scored",
|
|
19442
|
+
criterion_id: criterionId2,
|
|
19443
|
+
surface: surface2,
|
|
19444
|
+
level: level2,
|
|
19445
|
+
evidence: evidence2,
|
|
19446
|
+
...typeof args.audit_id === "string" && args.audit_id !== "" ? { audit_id: args.audit_id } : {},
|
|
19447
|
+
...commit !== void 0 ? { commit } : {}
|
|
19448
|
+
}
|
|
19449
|
+
]);
|
|
19450
|
+
const scored = events.find((e) => e.type === "quality.assessment.scored");
|
|
19451
|
+
const baseline = events.find(
|
|
19452
|
+
(e) => e.type === "quality.audit.completed" && e.baseline === true
|
|
19453
|
+
);
|
|
19454
|
+
const notes2 = [];
|
|
19455
|
+
if (baseline !== void 0) {
|
|
19456
|
+
notes2.push(
|
|
19457
|
+
`Recorded the baseline reading of ${baseline.audit_id} first, dated where that audit was taken \u2014 the scope and the trend now measure from a real event.`
|
|
19458
|
+
);
|
|
19459
|
+
}
|
|
19460
|
+
if (commit === void 0) {
|
|
19461
|
+
notes2.push("No commit given \u2014 it is the only thing that lets a hosted reader check this evidence against the tree it cites.");
|
|
19462
|
+
}
|
|
19463
|
+
return {
|
|
19464
|
+
assessment: {
|
|
19465
|
+
criterion_id: criterionId2,
|
|
19466
|
+
surface: surface2,
|
|
19467
|
+
level: level2,
|
|
19468
|
+
evidence: evidence2,
|
|
19469
|
+
audit_id: scored?.audit_id,
|
|
19470
|
+
...commit !== void 0 ? { commit } : {},
|
|
19471
|
+
ts: scored?.ts
|
|
19472
|
+
},
|
|
19473
|
+
audit_id: scored?.audit_id,
|
|
19474
|
+
...scored?.scope?.since !== void 0 ? { scoped_from: scored.scope.since } : {},
|
|
19475
|
+
anchor: library2?.criteria?.find((c) => c.id === criterionId2)?.level_anchors?.[`l${level2}`],
|
|
19476
|
+
events,
|
|
19477
|
+
...notes2.length > 0 ? { notes: notes2 } : {}
|
|
19478
|
+
};
|
|
19479
|
+
}
|
|
19186
19480
|
const root = repoRootOf(ctx, "Scoring reads the code \u2014 evidence is file:line against a working tree.");
|
|
19187
19481
|
const library = libraryOf(root);
|
|
19188
19482
|
const profile = profileOf(root);
|
|
@@ -19201,7 +19495,7 @@ function buildKritikCatalog(ctx) {
|
|
|
19201
19495
|
let auditId;
|
|
19202
19496
|
const graph = await load2();
|
|
19203
19497
|
if (args.scope === true) {
|
|
19204
|
-
const scope =
|
|
19498
|
+
const scope = scopeOf2(graph);
|
|
19205
19499
|
if (scope.since === null) {
|
|
19206
19500
|
throw new ToolError("scope=true needs a recorded audit to measure from \u2014 kritik_matrix with record=true writes one.");
|
|
19207
19501
|
}
|
|
@@ -20180,7 +20474,11 @@ function createRemoteStore(options) {
|
|
|
20180
20474
|
// the server holds that journal. Sending an "open" guess from here could
|
|
20181
20475
|
// only be stale the moment two sessions race, so this method does no
|
|
20182
20476
|
// checking of its own — it forwards the inputs and lets the server's
|
|
20183
|
-
//
|
|
20477
|
+
// post-fold verdict be the only one that counts. This route is
|
|
20478
|
+
// deliberately UNLOCKED, unlike `/mutations` — no row lock serializes two
|
|
20479
|
+
// posts — which is exactly why a dropped response is ambiguous and a
|
|
20480
|
+
// caller (`kritik_matrix record=true`) needs a retry path rather than a
|
|
20481
|
+
// guarantee that a refusal here means nothing was written.
|
|
20184
20482
|
async appendQualityEvents(inputs) {
|
|
20185
20483
|
try {
|
|
20186
20484
|
const result = await request("/quality/events", {
|
|
@@ -20191,8 +20489,11 @@ function createRemoteStore(options) {
|
|
|
20191
20489
|
} catch (err) {
|
|
20192
20490
|
const e = err;
|
|
20193
20491
|
if (e.status === 422 && e.body?.error === "refused") {
|
|
20194
|
-
const
|
|
20195
|
-
|
|
20492
|
+
const refusals = e.body.refusals;
|
|
20493
|
+
const detail = refusals ? refusals.map((r) => `${r.finding_id ?? `entry ${r.index}`}: ${r.reason}${r.detail ? ` \u2014 ${r.detail}` : ""}`).join("; ") : e.body.reason ?? "refused";
|
|
20494
|
+
const rejection = new Error(`Quality events refused \u2014 ${detail}`);
|
|
20495
|
+
if (refusals) rejection.refusals = refusals;
|
|
20496
|
+
throw rejection;
|
|
20196
20497
|
}
|
|
20197
20498
|
throw err;
|
|
20198
20499
|
}
|
|
@@ -20255,7 +20556,7 @@ function resolveRemoteConfig(argv2, env, cwd) {
|
|
|
20255
20556
|
}
|
|
20256
20557
|
|
|
20257
20558
|
// src/index.ts
|
|
20258
|
-
var VERSION = "0.
|
|
20559
|
+
var VERSION = "0.7.0";
|
|
20259
20560
|
var argv = process.argv.slice(2);
|
|
20260
20561
|
if (argv.includes("--help") || argv.includes("-h")) {
|
|
20261
20562
|
process.stdout.write(
|
package/package.json
CHANGED