arkaik-mcp 0.3.0 → 0.4.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 +413 -61
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ var __export = (target, all) => {
|
|
|
6
6
|
};
|
|
7
7
|
|
|
8
8
|
// src/index.ts
|
|
9
|
-
import { dirname as dirname4
|
|
9
|
+
import { dirname as dirname4 } from "node:path";
|
|
10
10
|
|
|
11
11
|
// src/protocol.ts
|
|
12
12
|
import { createInterface } from "node:readline";
|
|
@@ -15359,6 +15359,13 @@ var QualityFindingResolvedEventSchema = external_exports.object({
|
|
|
15359
15359
|
resolved_by: external_exports.string().optional(),
|
|
15360
15360
|
node_ids: external_exports.array(external_exports.string()).optional()
|
|
15361
15361
|
}).catchall(external_exports.unknown());
|
|
15362
|
+
var QualityFindingAcceptedEventSchema = external_exports.object({
|
|
15363
|
+
...envelope,
|
|
15364
|
+
type: external_exports.literal("quality.finding.accepted"),
|
|
15365
|
+
finding_id: external_exports.string(),
|
|
15366
|
+
reason: external_exports.string(),
|
|
15367
|
+
node_ids: external_exports.array(external_exports.string()).optional()
|
|
15368
|
+
}).catchall(external_exports.unknown());
|
|
15362
15369
|
var QualitySignalTrippedEventSchema = external_exports.object({
|
|
15363
15370
|
...envelope,
|
|
15364
15371
|
type: external_exports.literal("quality.signal.tripped"),
|
|
@@ -15386,6 +15393,7 @@ var JOURNAL_EVENT_SCHEMAS = {
|
|
|
15386
15393
|
"quality.audit.completed": QualityAuditCompletedEventSchema,
|
|
15387
15394
|
"quality.finding.opened": QualityFindingOpenedEventSchema,
|
|
15388
15395
|
"quality.finding.resolved": QualityFindingResolvedEventSchema,
|
|
15396
|
+
"quality.finding.accepted": QualityFindingAcceptedEventSchema,
|
|
15389
15397
|
"quality.signal.tripped": QualitySignalTrippedEventSchema
|
|
15390
15398
|
};
|
|
15391
15399
|
var KnownJournalEventSchema = external_exports.union([
|
|
@@ -15407,6 +15415,7 @@ var KnownJournalEventSchema = external_exports.union([
|
|
|
15407
15415
|
QualityAuditCompletedEventSchema,
|
|
15408
15416
|
QualityFindingOpenedEventSchema,
|
|
15409
15417
|
QualityFindingResolvedEventSchema,
|
|
15418
|
+
QualityFindingAcceptedEventSchema,
|
|
15410
15419
|
QualitySignalTrippedEventSchema
|
|
15411
15420
|
]);
|
|
15412
15421
|
|
|
@@ -15494,6 +15503,9 @@ var QualityFindingSchema = external_exports.object({
|
|
|
15494
15503
|
remediation: external_exports.string().optional(),
|
|
15495
15504
|
node_ids: external_exports.array(external_exports.string()).optional().meta({ description: "Graph nodes this finding is about \u2014 the tie deliverable.shipped already uses." }),
|
|
15496
15505
|
issue_url: external_exports.string().optional(),
|
|
15506
|
+
commit: external_exports.string().optional().meta({
|
|
15507
|
+
description: "Commit SHA anchoring the file:line evidence. Required by policy on any finding written away from a checkout (issue #400 decision 4) \u2014 without it a stale citation is indistinguishable from a wrong one."
|
|
15508
|
+
}),
|
|
15497
15509
|
verification: external_exports.object({ verdict: external_exports.enum(["CONFIRMED", "REFUTED", "DOWNGRADED"]), note: external_exports.string().optional() }).catchall(external_exports.unknown()).optional().meta({ description: "Result of the adversarial refutation pass. Refuted findings are disclosed, not deleted." })
|
|
15498
15510
|
}).catchall(external_exports.unknown()).meta({
|
|
15499
15511
|
id: "QualityFinding",
|
|
@@ -16942,6 +16954,15 @@ function validateBundle(input) {
|
|
|
16942
16954
|
);
|
|
16943
16955
|
}
|
|
16944
16956
|
}
|
|
16957
|
+
if (type === "quality.finding.accepted" && typeof event.finding_id === "string") {
|
|
16958
|
+
if (!openedInJournal.has(event.finding_id) && !seenFindingIds.has(event.finding_id)) {
|
|
16959
|
+
warn(
|
|
16960
|
+
`journal[${index}].finding_id`,
|
|
16961
|
+
"quality-accepted-never-opened",
|
|
16962
|
+
`Journal event ${index}: accepts finding "${event.finding_id}", which no quality.finding.opened event or stored finding ever declared`
|
|
16963
|
+
);
|
|
16964
|
+
}
|
|
16965
|
+
}
|
|
16945
16966
|
});
|
|
16946
16967
|
}
|
|
16947
16968
|
for (const finding of crossCheckJournal(bundle)) findings.push(finding);
|
|
@@ -17663,11 +17684,14 @@ function resolveFinding(findings, id, resolvedBy) {
|
|
|
17663
17684
|
...resolvedBy !== void 0 ? { resolved_by: resolvedBy } : {}
|
|
17664
17685
|
});
|
|
17665
17686
|
}
|
|
17666
|
-
function
|
|
17667
|
-
|
|
17668
|
-
const detail = existing === void 0 ? note : `${existing.detail}
|
|
17687
|
+
function acceptedDetail(detail, note) {
|
|
17688
|
+
return `${detail}
|
|
17669
17689
|
|
|
17670
17690
|
Accepted risk: ${note}`.trim();
|
|
17691
|
+
}
|
|
17692
|
+
function acceptFinding(findings, id, note) {
|
|
17693
|
+
const existing = findings.find((candidate) => candidate.id === id);
|
|
17694
|
+
const detail = existing === void 0 ? note : acceptedDetail(existing.detail, note);
|
|
17671
17695
|
return patchFinding(findings, id, { status: "accepted-risk", detail });
|
|
17672
17696
|
}
|
|
17673
17697
|
function fillTemplate(text, values) {
|
|
@@ -17799,6 +17823,83 @@ function signalTrippedInput(trip) {
|
|
|
17799
17823
|
};
|
|
17800
17824
|
}
|
|
17801
17825
|
|
|
17826
|
+
// ../schema/src/quality-regressions.ts
|
|
17827
|
+
var REGRESSION_SIGNALS = {
|
|
17828
|
+
"level-drop": "maturity on this cell does not regress",
|
|
17829
|
+
"new-severe-finding": "no open Critical or High finding on this cell",
|
|
17830
|
+
"reopened-finding": "a resolved finding stays resolved"
|
|
17831
|
+
};
|
|
17832
|
+
var cellKey = (criterionId, surface) => `${criterionId}::${surface}`;
|
|
17833
|
+
var rowsOf = (value) => Array.isArray(value) ? value : [];
|
|
17834
|
+
function assessmentsByCell(state) {
|
|
17835
|
+
const cells = /* @__PURE__ */ new Map();
|
|
17836
|
+
for (const assessment of rowsOf(state?.assessments)) {
|
|
17837
|
+
if (typeof assessment?.criterion_id !== "string" || typeof assessment?.surface !== "string") continue;
|
|
17838
|
+
cells.set(cellKey(assessment.criterion_id, assessment.surface), assessment);
|
|
17839
|
+
}
|
|
17840
|
+
return cells;
|
|
17841
|
+
}
|
|
17842
|
+
function severeByCell(state, library) {
|
|
17843
|
+
const cells = /* @__PURE__ */ new Map();
|
|
17844
|
+
for (const finding of rowsOf(state?.findings)) {
|
|
17845
|
+
if (typeof finding?.criterion_id !== "string" || typeof finding?.surface !== "string") continue;
|
|
17846
|
+
if (!isOpenFinding(finding)) continue;
|
|
17847
|
+
const severity = severityOf(finding, library);
|
|
17848
|
+
if (severity !== "critical" && severity !== "high") continue;
|
|
17849
|
+
const key = cellKey(finding.criterion_id, finding.surface);
|
|
17850
|
+
const existing = cells.get(key);
|
|
17851
|
+
if (existing === void 0) cells.set(key, [finding]);
|
|
17852
|
+
else existing.push(finding);
|
|
17853
|
+
}
|
|
17854
|
+
return cells;
|
|
17855
|
+
}
|
|
17856
|
+
function detectRegressions(previous, next, library) {
|
|
17857
|
+
const before = assessmentsByCell(previous);
|
|
17858
|
+
const after = assessmentsByCell(next);
|
|
17859
|
+
const comparable = (key) => before.has(key) && after.has(key);
|
|
17860
|
+
const regressions = [];
|
|
17861
|
+
for (const [key, current] of after) {
|
|
17862
|
+
const earlier = before.get(key);
|
|
17863
|
+
if (earlier === void 0) continue;
|
|
17864
|
+
if (!(Number(current.level) < Number(earlier.level))) continue;
|
|
17865
|
+
regressions.push({
|
|
17866
|
+
kind: "level-drop",
|
|
17867
|
+
criterion_id: current.criterion_id,
|
|
17868
|
+
surface: current.surface,
|
|
17869
|
+
signal: REGRESSION_SIGNALS["level-drop"],
|
|
17870
|
+
detail: `level ${earlier.level} \u2192 ${current.level} (${earlier.audit_id} \u2192 ${current.audit_id})`
|
|
17871
|
+
});
|
|
17872
|
+
}
|
|
17873
|
+
const severeBefore = severeByCell(previous, library);
|
|
17874
|
+
for (const [key, findings] of severeByCell(next, library)) {
|
|
17875
|
+
if (!comparable(key)) continue;
|
|
17876
|
+
if ((severeBefore.get(key) ?? []).length > 0) continue;
|
|
17877
|
+
for (const finding of findings) {
|
|
17878
|
+
regressions.push({
|
|
17879
|
+
kind: "new-severe-finding",
|
|
17880
|
+
criterion_id: finding.criterion_id,
|
|
17881
|
+
surface: finding.surface,
|
|
17882
|
+
signal: REGRESSION_SIGNALS["new-severe-finding"],
|
|
17883
|
+
detail: `${finding.id} \u2014 ${severityOf(finding, library)} (impact ${finding.impact} \xD7 likelihood ${finding.likelihood})`
|
|
17884
|
+
});
|
|
17885
|
+
}
|
|
17886
|
+
}
|
|
17887
|
+
const resolvedBefore = new Set(
|
|
17888
|
+
rowsOf(previous?.findings).filter((finding) => finding?.status === "resolved").map((finding) => finding.id)
|
|
17889
|
+
);
|
|
17890
|
+
for (const finding of rowsOf(next?.findings)) {
|
|
17891
|
+
if (!isOpenFinding(finding) || !resolvedBefore.has(finding.id)) continue;
|
|
17892
|
+
regressions.push({
|
|
17893
|
+
kind: "reopened-finding",
|
|
17894
|
+
criterion_id: finding.criterion_id,
|
|
17895
|
+
surface: finding.surface,
|
|
17896
|
+
signal: REGRESSION_SIGNALS["reopened-finding"],
|
|
17897
|
+
detail: `${finding.id} \u2014 "${finding.title}"`
|
|
17898
|
+
});
|
|
17899
|
+
}
|
|
17900
|
+
return regressions;
|
|
17901
|
+
}
|
|
17902
|
+
|
|
17802
17903
|
// ../schema/src/cli/kritik-audit.ts
|
|
17803
17904
|
import { existsSync as existsSync2, readdirSync, statSync } from "node:fs";
|
|
17804
17905
|
import { join as join2 } from "node:path";
|
|
@@ -17812,7 +17913,12 @@ var OVERLAY_FILE = "criteria.custom.json";
|
|
|
17812
17913
|
var AUDITS_DIR = "audits";
|
|
17813
17914
|
var PACK_FILE = "library.json";
|
|
17814
17915
|
function readJson(path) {
|
|
17815
|
-
|
|
17916
|
+
const text = readFileSync(path, "utf8");
|
|
17917
|
+
try {
|
|
17918
|
+
return JSON.parse(text);
|
|
17919
|
+
} catch (e) {
|
|
17920
|
+
throw new Error(`${path}: not valid JSON \u2014 ${e.message}`);
|
|
17921
|
+
}
|
|
17816
17922
|
}
|
|
17817
17923
|
function writeJson(path, value) {
|
|
17818
17924
|
mkdirSync(dirname(path), { recursive: true });
|
|
@@ -17820,7 +17926,8 @@ function writeJson(path, value) {
|
|
|
17820
17926
|
}
|
|
17821
17927
|
var profilePath = (root) => join(root, QUALITY_DIR, PROFILE_FILE);
|
|
17822
17928
|
var overlayPath = (root) => join(root, QUALITY_DIR, OVERLAY_FILE);
|
|
17823
|
-
var
|
|
17929
|
+
var auditsDir = (root) => join(root, QUALITY_DIR, AUDITS_DIR);
|
|
17930
|
+
var auditDir = (root, auditId) => join(auditsDir(root), auditId);
|
|
17824
17931
|
function loadProfile(root) {
|
|
17825
17932
|
const path = profilePath(root);
|
|
17826
17933
|
return existsSync(path) ? readJson(path) : null;
|
|
@@ -17838,12 +17945,12 @@ var scoresPath = (root, auditId) => join2(auditDir(root, auditId), SCORES_FILE);
|
|
|
17838
17945
|
var findingsPath = (root, auditId) => join2(auditDir(root, auditId), FINDINGS_FILE);
|
|
17839
17946
|
var matrixPath = (root, auditId) => join2(auditDir(root, auditId), MATRIX_FILE);
|
|
17840
17947
|
function listAuditIds(root) {
|
|
17841
|
-
const dir =
|
|
17948
|
+
const dir = auditsDir(root);
|
|
17842
17949
|
if (!existsSync2(dir)) return [];
|
|
17843
17950
|
return readdirSync(dir).filter((name) => statSync(join2(dir, name)).isDirectory()).sort();
|
|
17844
17951
|
}
|
|
17845
17952
|
function newestAuditId(root) {
|
|
17846
|
-
const dir =
|
|
17953
|
+
const dir = auditsDir(root);
|
|
17847
17954
|
if (!existsSync2(dir)) throw new Error(`no audits directory at ${dir}`);
|
|
17848
17955
|
const ids = listAuditIds(root);
|
|
17849
17956
|
if (ids.length === 0) throw new Error(`no audits found under ${dir}`);
|
|
@@ -17970,7 +18077,7 @@ function appendJournalEvent(journalPath, event) {
|
|
|
17970
18077
|
|
|
17971
18078
|
// ../cli/src/lib/kritik-io.ts
|
|
17972
18079
|
import { existsSync as existsSync5 } from "node:fs";
|
|
17973
|
-
import { dirname as dirname3, join as join4 } from "node:path";
|
|
18080
|
+
import { basename, dirname as dirname3, join as join4, resolve as resolve2 } from "node:path";
|
|
17974
18081
|
import { fileURLToPath } from "node:url";
|
|
17975
18082
|
var DEFAULT_BUNDLE_PATH = join4("docs", "arkaik", "bundle.json");
|
|
17976
18083
|
var VENDORED_PACK = join4(QUALITY_DIR, PACK_FILE);
|
|
@@ -17996,10 +18103,18 @@ function resolveJournal(root, bundlePath) {
|
|
|
17996
18103
|
const resolved = bundlePath ?? join4(root, DEFAULT_BUNDLE_PATH);
|
|
17997
18104
|
return { bundlePath: resolved, journalPath: journalPathFor(resolved), present: existsSync5(resolved) };
|
|
17998
18105
|
}
|
|
18106
|
+
function resolveQualityRoot(options) {
|
|
18107
|
+
if (options.root !== void 0) return resolve2(options.fallback, options.root);
|
|
18108
|
+
const envRoot = (options.env ?? process.env).ARKAIK_QUALITY_ROOT;
|
|
18109
|
+
if (envRoot) return resolve2(envRoot);
|
|
18110
|
+
const dir = dirname3(options.bundlePath);
|
|
18111
|
+
if (basename(dir) === "arkaik" && basename(dirname3(dir)) === "docs") return resolve2(dir, "..", "..");
|
|
18112
|
+
return options.fallback;
|
|
18113
|
+
}
|
|
17999
18114
|
|
|
18000
18115
|
// ../cli/src/lib/bundle-validate.ts
|
|
18001
18116
|
import { existsSync as existsSync6, readFileSync as readFileSync4 } from "node:fs";
|
|
18002
|
-
import { basename } from "node:path";
|
|
18117
|
+
import { basename as basename2 } from "node:path";
|
|
18003
18118
|
function validateBundleAt(filePath) {
|
|
18004
18119
|
const bundle = readBundle(filePath);
|
|
18005
18120
|
const loose = bundle;
|
|
@@ -18021,7 +18136,7 @@ function validateBundleAt(filePath) {
|
|
|
18021
18136
|
}
|
|
18022
18137
|
for (const archivePath of archivePathsFor(sidecarPath)) {
|
|
18023
18138
|
const { events, findings } = parseJournalLines(readFileSync4(archivePath, "utf8"));
|
|
18024
|
-
const file2 =
|
|
18139
|
+
const file2 = basename2(archivePath);
|
|
18025
18140
|
for (const finding of findings) archiveFindings.push({ ...finding, file: file2 });
|
|
18026
18141
|
archivesLoaded.push(file2);
|
|
18027
18142
|
folded.push(...events);
|
|
@@ -18048,14 +18163,77 @@ function validateBundleAt(filePath) {
|
|
|
18048
18163
|
}
|
|
18049
18164
|
|
|
18050
18165
|
// src/kritik-tools.ts
|
|
18051
|
-
function
|
|
18166
|
+
function repoRootOf(ctx, needs) {
|
|
18052
18167
|
if (ctx.qualityRoot === void 0) {
|
|
18053
18168
|
throw new ToolError(
|
|
18054
|
-
|
|
18169
|
+
`${needs} This session is connected to a hosted project (${ctx.store.describe()}); run it where the checkout is \u2014 \`arkaik-mcp --bundle <path>\`.`
|
|
18055
18170
|
);
|
|
18056
18171
|
}
|
|
18057
18172
|
return ctx.qualityRoot;
|
|
18058
18173
|
}
|
|
18174
|
+
var REPO_MODE_ONLY = "Repo-mode reads come from docs/quality/ files.";
|
|
18175
|
+
async function appendHosted(store2, inputs) {
|
|
18176
|
+
if (store2.appendQualityEvents === void 0) {
|
|
18177
|
+
throw new ToolError(`${store2.describe()} cannot append quality events.`);
|
|
18178
|
+
}
|
|
18179
|
+
try {
|
|
18180
|
+
return await store2.appendQualityEvents(inputs);
|
|
18181
|
+
} catch (error51) {
|
|
18182
|
+
throw new ToolError(error51.message);
|
|
18183
|
+
}
|
|
18184
|
+
}
|
|
18185
|
+
function hostedSection(graph) {
|
|
18186
|
+
const section = graph.loaded.bundle.quality;
|
|
18187
|
+
if (section === void 0 || !Array.isArray(section.findings) || !Array.isArray(section.assessments)) {
|
|
18188
|
+
throw new ToolError(
|
|
18189
|
+
"This hosted project has no quality section yet. Run an audit in the repository and `arkaik restore` it \u2014 hosted Kritik reads what an audit stored."
|
|
18190
|
+
);
|
|
18191
|
+
}
|
|
18192
|
+
return { section, library: resolveKritikLibrary(section) };
|
|
18193
|
+
}
|
|
18194
|
+
function refuseHostedRecord(eventType) {
|
|
18195
|
+
throw new ToolError(`Recording ${eventType} belongs to the audit run, which reads code. Run the audit where the checkout is.`);
|
|
18196
|
+
}
|
|
18197
|
+
function openFindingsSummary(findings, library) {
|
|
18198
|
+
const open = findings.filter(isOpenFinding);
|
|
18199
|
+
const lanes = { P0: 0, P1: 0, P2: 0, P3: 0 };
|
|
18200
|
+
for (const finding of open) lanes[priorityOf(finding, library)]++;
|
|
18201
|
+
const p0 = open.filter((finding) => priorityOf(finding, library) === "P0").map((finding) => ({
|
|
18202
|
+
id: finding.id,
|
|
18203
|
+
surface: finding.surface,
|
|
18204
|
+
criterion_id: finding.criterion_id,
|
|
18205
|
+
title: finding.title,
|
|
18206
|
+
severity: severityOf(finding, library)
|
|
18207
|
+
}));
|
|
18208
|
+
return { open, lanes, p0 };
|
|
18209
|
+
}
|
|
18210
|
+
function resolveAuditPair(audits, args, notFoundHint) {
|
|
18211
|
+
if (audits.length < 2) {
|
|
18212
|
+
throw new ToolError(
|
|
18213
|
+
`regressions needs two audits to compare \u2014 ${audits.length === 0 ? `${notFoundHint} holds none` : `only "${audits[0]}" exists`}. A regression is the difference between two readings; one reading is a baseline.`
|
|
18214
|
+
);
|
|
18215
|
+
}
|
|
18216
|
+
const known = (id) => {
|
|
18217
|
+
if (!audits.includes(id)) throw new ToolError(`no audit "${id}" ${notFoundHint} (have: ${audits.join(", ")})`);
|
|
18218
|
+
return id;
|
|
18219
|
+
};
|
|
18220
|
+
const to = typeof args.to === "string" && args.to !== "" ? known(args.to) : audits[audits.length - 1];
|
|
18221
|
+
const from = typeof args.from === "string" && args.from !== "" ? known(args.from) : audits[audits.indexOf(to) - 1];
|
|
18222
|
+
if (from === void 0) throw new ToolError(`"${to}" is the oldest audit \u2014 there is nothing before it to compare against.`);
|
|
18223
|
+
if (from === to) throw new ToolError(`from and to name the same audit ("${to}") \u2014 a regression needs two readings.`);
|
|
18224
|
+
if (audits.indexOf(from) > audits.indexOf(to)) {
|
|
18225
|
+
throw new ToolError(`from "${from}" is newer than to "${to}" \u2014 swap them, or the comparison inverts.`);
|
|
18226
|
+
}
|
|
18227
|
+
return { from, to };
|
|
18228
|
+
}
|
|
18229
|
+
function matchesFindingArgs(row, args) {
|
|
18230
|
+
if (typeof args.surface === "string" && row.surface !== args.surface) return false;
|
|
18231
|
+
if (typeof args.status === "string" && (row.status ?? "open") !== args.status) return false;
|
|
18232
|
+
if (typeof args.priority === "string" && row.priority !== args.priority) return false;
|
|
18233
|
+
if (typeof args.criterion_id === "string" && row.criterion_id !== args.criterion_id) return false;
|
|
18234
|
+
if (typeof args.finding_id === "string" && row.id !== args.finding_id) return false;
|
|
18235
|
+
return true;
|
|
18236
|
+
}
|
|
18059
18237
|
function libraryOf(root) {
|
|
18060
18238
|
try {
|
|
18061
18239
|
return loadKritikLibrary(root).library;
|
|
@@ -18150,7 +18328,7 @@ function buildKritikCatalog(ctx) {
|
|
|
18150
18328
|
tool(
|
|
18151
18329
|
{
|
|
18152
18330
|
name: "kritik_matrix",
|
|
18153
|
-
description: "The comparative quality matrix
|
|
18331
|
+
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 (no audit_id/commit \u2014 hosted has no audit file) and record is refused \u2014 recording belongs to the audit run, which reads code.",
|
|
18154
18332
|
inputSchema: {
|
|
18155
18333
|
type: "object",
|
|
18156
18334
|
properties: {
|
|
@@ -18164,7 +18342,29 @@ function buildKritikCatalog(ctx) {
|
|
|
18164
18342
|
}
|
|
18165
18343
|
},
|
|
18166
18344
|
async (args) => {
|
|
18167
|
-
const
|
|
18345
|
+
const hosted = ctx.qualityRoot === void 0;
|
|
18346
|
+
if (hosted) {
|
|
18347
|
+
if (args.record === true) refuseHostedRecord("quality.audit.completed");
|
|
18348
|
+
if (typeof args.audit_id === "string" && args.audit_id !== "") {
|
|
18349
|
+
throw new ToolError("The hosted matrix is the current state, not one audit \u2014 audit_id does not partition it (issue #400 decision 3).");
|
|
18350
|
+
}
|
|
18351
|
+
const graph = await load2();
|
|
18352
|
+
const { section: section2, library: library2 } = hostedSection(graph);
|
|
18353
|
+
const m = deriveQualityMatrix({ quality: section2 }, library2);
|
|
18354
|
+
const { open: open2, lanes: lanes2, p0: p02 } = openFindingsSummary(section2.findings, library2);
|
|
18355
|
+
return {
|
|
18356
|
+
...m.framework_version !== void 0 ? { framework_version: m.framework_version } : {},
|
|
18357
|
+
matrix: m.matrix,
|
|
18358
|
+
overall: m.overall,
|
|
18359
|
+
finding_counts: m.finding_counts,
|
|
18360
|
+
assessment_count: section2.assessments.length,
|
|
18361
|
+
open_findings: open2.length,
|
|
18362
|
+
lanes: lanes2,
|
|
18363
|
+
p0: p02,
|
|
18364
|
+
events: []
|
|
18365
|
+
};
|
|
18366
|
+
}
|
|
18367
|
+
const root = repoRootOf(ctx, REPO_MODE_ONLY);
|
|
18168
18368
|
const library = libraryOf(root);
|
|
18169
18369
|
let auditId;
|
|
18170
18370
|
try {
|
|
@@ -18179,9 +18379,7 @@ function buildKritikCatalog(ctx) {
|
|
|
18179
18379
|
throw new ToolError(error51.message);
|
|
18180
18380
|
}
|
|
18181
18381
|
const { section, matrix, file: file2 } = computed;
|
|
18182
|
-
const open = section.findings
|
|
18183
|
-
const lanes = { P0: 0, P1: 0, P2: 0, P3: 0 };
|
|
18184
|
-
for (const finding of open) lanes[priorityOf(finding, library)]++;
|
|
18382
|
+
const { open, lanes, p0 } = openFindingsSummary(section.findings, library);
|
|
18185
18383
|
let events = [];
|
|
18186
18384
|
if (args.record === true) {
|
|
18187
18385
|
const graph = await load2();
|
|
@@ -18198,13 +18396,7 @@ function buildKritikCatalog(ctx) {
|
|
|
18198
18396
|
assessment_count: section.assessments.length,
|
|
18199
18397
|
open_findings: open.length,
|
|
18200
18398
|
lanes,
|
|
18201
|
-
p0
|
|
18202
|
-
id: finding.id,
|
|
18203
|
-
surface: finding.surface,
|
|
18204
|
-
criterion_id: finding.criterion_id,
|
|
18205
|
-
title: finding.title,
|
|
18206
|
-
severity: severityOf(finding, library)
|
|
18207
|
-
})),
|
|
18399
|
+
p0,
|
|
18208
18400
|
events
|
|
18209
18401
|
};
|
|
18210
18402
|
}
|
|
@@ -18212,7 +18404,7 @@ function buildKritikCatalog(ctx) {
|
|
|
18212
18404
|
tool(
|
|
18213
18405
|
{
|
|
18214
18406
|
name: "kritik_findings",
|
|
18215
|
-
description: "Findings
|
|
18407
|
+
description: "Findings, with their derived severity and priority. Filter by surface, status, priority, criterion, or finding id. Severity and priority are computed from impact x likelihood and cost on every read \u2014 they are never stored, so they cannot drift from the numbers behind them. Repo mode reads across every audit under docs/quality/audits/, filterable by audit_id; hosted findings are a single living pool with no audit_id partition.",
|
|
18216
18408
|
inputSchema: {
|
|
18217
18409
|
type: "object",
|
|
18218
18410
|
properties: {
|
|
@@ -18220,13 +18412,29 @@ function buildKritikCatalog(ctx) {
|
|
|
18220
18412
|
status: { type: "string", enum: [...FINDING_STATUSES] },
|
|
18221
18413
|
priority: { type: "string", enum: ["P0", "P1", "P2", "P3"] },
|
|
18222
18414
|
criterion_id: { type: "string" },
|
|
18223
|
-
|
|
18415
|
+
finding_id: { type: "string" },
|
|
18416
|
+
audit_id: { type: "string", description: "Default: every audit. Not valid in hosted mode." }
|
|
18224
18417
|
},
|
|
18225
18418
|
additionalProperties: false
|
|
18226
18419
|
}
|
|
18227
18420
|
},
|
|
18228
18421
|
async (args) => {
|
|
18229
|
-
const
|
|
18422
|
+
const hosted = ctx.qualityRoot === void 0;
|
|
18423
|
+
if (hosted) {
|
|
18424
|
+
if (typeof args.audit_id === "string" && args.audit_id !== "") {
|
|
18425
|
+
throw new ToolError("Hosted findings are a living pool \u2014 audit_id does not partition them (issue #400 decision 3).");
|
|
18426
|
+
}
|
|
18427
|
+
const graph = await load2();
|
|
18428
|
+
const { section, library: library2 } = hostedSection(graph);
|
|
18429
|
+
const rows2 = section.findings.map((finding) => ({
|
|
18430
|
+
...finding,
|
|
18431
|
+
severity: severityOf(finding, library2),
|
|
18432
|
+
priority: priorityOf(finding, library2)
|
|
18433
|
+
}));
|
|
18434
|
+
const matches2 = rows2.filter((row) => matchesFindingArgs(row, args));
|
|
18435
|
+
return { total: matches2.length, findings: matches2 };
|
|
18436
|
+
}
|
|
18437
|
+
const root = repoRootOf(ctx, REPO_MODE_ONLY);
|
|
18230
18438
|
const library = libraryOf(root);
|
|
18231
18439
|
const auditIds = typeof args.audit_id === "string" && args.audit_id !== "" ? [args.audit_id] : listAuditIds(root);
|
|
18232
18440
|
const rows = auditIds.flatMap(
|
|
@@ -18237,20 +18445,14 @@ function buildKritikCatalog(ctx) {
|
|
|
18237
18445
|
priority: priorityOf(finding, library)
|
|
18238
18446
|
}))
|
|
18239
18447
|
);
|
|
18240
|
-
const matches = rows.filter((row) =>
|
|
18241
|
-
if (typeof args.surface === "string" && row.surface !== args.surface) return false;
|
|
18242
|
-
if (typeof args.status === "string" && (row.status ?? "open") !== args.status) return false;
|
|
18243
|
-
if (typeof args.priority === "string" && row.priority !== args.priority) return false;
|
|
18244
|
-
if (typeof args.criterion_id === "string" && row.criterion_id !== args.criterion_id) return false;
|
|
18245
|
-
return true;
|
|
18246
|
-
});
|
|
18448
|
+
const matches = rows.filter((row) => matchesFindingArgs(row, args));
|
|
18247
18449
|
return { total: matches.length, findings: matches };
|
|
18248
18450
|
}
|
|
18249
18451
|
);
|
|
18250
18452
|
tool(
|
|
18251
18453
|
{
|
|
18252
18454
|
name: "kritik_signals",
|
|
18253
|
-
description: "The signal pack: every applicable criterion's mechanically checkable statements, expanded across the surfaces it applies to, plus anything that has tripped since the last recorded audit. These are statements to CHECK, not commands to run \u2014 a grep that must return nothing, a CI job that must exist \u2014 so run them yourself and report what failed with kritik_trip_signal.",
|
|
18455
|
+
description: "The signal pack: every applicable criterion's mechanically checkable statements, expanded across the surfaces it applies to, plus anything that has tripped since the last recorded audit. These are statements to CHECK, not commands to run \u2014 a grep that must return nothing, a CI job that must exist \u2014 so run them yourself and report what failed with kritik_trip_signal. Repo sessions only: the pack and its run sheet live with the code.",
|
|
18254
18456
|
inputSchema: {
|
|
18255
18457
|
type: "object",
|
|
18256
18458
|
properties: {
|
|
@@ -18262,7 +18464,10 @@ function buildKritikCatalog(ctx) {
|
|
|
18262
18464
|
}
|
|
18263
18465
|
},
|
|
18264
18466
|
async (args) => {
|
|
18265
|
-
const root =
|
|
18467
|
+
const root = repoRootOf(
|
|
18468
|
+
ctx,
|
|
18469
|
+
"Signals are statements checked against the repository \u2014 the pack and its run sheet live with the code."
|
|
18470
|
+
);
|
|
18266
18471
|
const library = libraryOf(root);
|
|
18267
18472
|
const profile = profileOf(root);
|
|
18268
18473
|
const filter = {
|
|
@@ -18278,6 +18483,84 @@ function buildKritikCatalog(ctx) {
|
|
|
18278
18483
|
return { library_version: library.version, total: rows.length, signals: rows, tripped_since_last_audit: tripped };
|
|
18279
18484
|
}
|
|
18280
18485
|
);
|
|
18486
|
+
tool(
|
|
18487
|
+
{
|
|
18488
|
+
name: "kritik_regressions",
|
|
18489
|
+
description: "What got worse between two audits: a cell whose maturity level dropped, a cell that gained an open Critical or High finding, and a finding that was resolved and is open again. Cells scored in only one of the two audits are not compared \u2014 a half-finished audit is not a regression. With record=true, appends one quality.signal.tripped per regression (repo mode only \u2014 hosted comparisons are read-only and cover assessment-level drops, since hosted findings are a living pool rather than per-audit snapshots). A tripped signal is NOT a finding; it is the prompt to go look.",
|
|
18490
|
+
inputSchema: {
|
|
18491
|
+
type: "object",
|
|
18492
|
+
properties: {
|
|
18493
|
+
from: { type: "string", description: "The older audit. Default: the audit before `to`." },
|
|
18494
|
+
to: { type: "string", description: "The newer audit. Default: the newest on disk." },
|
|
18495
|
+
record: { type: "boolean", description: "Append one quality.signal.tripped per regression." }
|
|
18496
|
+
},
|
|
18497
|
+
additionalProperties: false
|
|
18498
|
+
}
|
|
18499
|
+
},
|
|
18500
|
+
async (args) => {
|
|
18501
|
+
const hosted = ctx.qualityRoot === void 0;
|
|
18502
|
+
if (hosted) {
|
|
18503
|
+
if (args.record === true) refuseHostedRecord("quality.signal.tripped");
|
|
18504
|
+
const graph = await load2();
|
|
18505
|
+
const { section, library: library2 } = hostedSection(graph);
|
|
18506
|
+
const grouped = /* @__PURE__ */ new Map();
|
|
18507
|
+
for (const assessment of section.assessments) {
|
|
18508
|
+
if (typeof assessment.audit_id !== "string" || assessment.audit_id === "") continue;
|
|
18509
|
+
const bucket = grouped.get(assessment.audit_id);
|
|
18510
|
+
if (bucket) bucket.push(assessment);
|
|
18511
|
+
else grouped.set(assessment.audit_id, [assessment]);
|
|
18512
|
+
}
|
|
18513
|
+
const audits2 = [...grouped.keys()].sort();
|
|
18514
|
+
const { from: from2, to: to2 } = resolveAuditPair(audits2, args, "in this project's assessments");
|
|
18515
|
+
const fromState = { assessments: grouped.get(from2) ?? [], findings: section.findings };
|
|
18516
|
+
const toState = { assessments: grouped.get(to2) ?? [], findings: section.findings };
|
|
18517
|
+
let regressions2;
|
|
18518
|
+
try {
|
|
18519
|
+
regressions2 = detectRegressions(fromState, toState, library2);
|
|
18520
|
+
} catch (error51) {
|
|
18521
|
+
throw new ToolError(error51.message);
|
|
18522
|
+
}
|
|
18523
|
+
return {
|
|
18524
|
+
from: from2,
|
|
18525
|
+
to: to2,
|
|
18526
|
+
total: regressions2.length,
|
|
18527
|
+
regressions: regressions2,
|
|
18528
|
+
events: [],
|
|
18529
|
+
note: "hosted comparison covers assessment level drops only \u2014 findings are a living pool (issue #400 decision 3)"
|
|
18530
|
+
};
|
|
18531
|
+
}
|
|
18532
|
+
const root = repoRootOf(ctx, REPO_MODE_ONLY);
|
|
18533
|
+
const library = libraryOf(root);
|
|
18534
|
+
const audits = listAuditIds(root);
|
|
18535
|
+
const { from, to } = resolveAuditPair(audits, args, "under docs/quality/audits/");
|
|
18536
|
+
let regressions;
|
|
18537
|
+
try {
|
|
18538
|
+
regressions = detectRegressions(
|
|
18539
|
+
loadQualitySection(root, from, library),
|
|
18540
|
+
loadQualitySection(root, to, library),
|
|
18541
|
+
library
|
|
18542
|
+
);
|
|
18543
|
+
} catch (error51) {
|
|
18544
|
+
throw new ToolError(error51.message);
|
|
18545
|
+
}
|
|
18546
|
+
let events = [];
|
|
18547
|
+
if (args.record === true && regressions.length > 0) {
|
|
18548
|
+
const graph = await load2();
|
|
18549
|
+
events = await record2(
|
|
18550
|
+
graph,
|
|
18551
|
+
regressions.map(
|
|
18552
|
+
(regression) => signalTrippedInput({
|
|
18553
|
+
criterion_id: regression.criterion_id,
|
|
18554
|
+
surface: regression.surface,
|
|
18555
|
+
signal: regression.signal,
|
|
18556
|
+
detail: regression.detail
|
|
18557
|
+
})
|
|
18558
|
+
)
|
|
18559
|
+
);
|
|
18560
|
+
}
|
|
18561
|
+
return { from, to, total: regressions.length, regressions, events };
|
|
18562
|
+
}
|
|
18563
|
+
);
|
|
18281
18564
|
tool(
|
|
18282
18565
|
{
|
|
18283
18566
|
name: "kritik_issue",
|
|
@@ -18295,7 +18578,28 @@ function buildKritikCatalog(ctx) {
|
|
|
18295
18578
|
}
|
|
18296
18579
|
},
|
|
18297
18580
|
async (args) => {
|
|
18298
|
-
const
|
|
18581
|
+
const hosted = ctx.qualityRoot === void 0;
|
|
18582
|
+
if (hosted) {
|
|
18583
|
+
const graph = await load2();
|
|
18584
|
+
const { section, library: library2 } = hostedSection(graph);
|
|
18585
|
+
if (library2 === void 0) {
|
|
18586
|
+
throw new ToolError("This hosted project's quality section carries no criteria vocabulary \u2014 no embedded library and no scored criteria to synthesize one from.");
|
|
18587
|
+
}
|
|
18588
|
+
const criterion2 = criterionOf(library2, requireString(args, "criterion_id"));
|
|
18589
|
+
const surface2 = requireString(args, "surface");
|
|
18590
|
+
if (section.profile) surfaceOf(section.profile, surface2, true);
|
|
18591
|
+
let finding2;
|
|
18592
|
+
if (typeof args.finding_id === "string" && args.finding_id !== "") {
|
|
18593
|
+
finding2 = section.findings.find((candidate) => candidate.id === args.finding_id);
|
|
18594
|
+
if (!finding2) throw new ToolError(`No finding "${args.finding_id}" in this hosted project's quality section.`);
|
|
18595
|
+
}
|
|
18596
|
+
return renderIssue(criterion2, {
|
|
18597
|
+
surface: surface2,
|
|
18598
|
+
...typeof args.level === "number" ? { level: args.level } : {},
|
|
18599
|
+
...finding2 !== void 0 ? { finding: finding2, library: library2 } : {}
|
|
18600
|
+
});
|
|
18601
|
+
}
|
|
18602
|
+
const root = repoRootOf(ctx, REPO_MODE_ONLY);
|
|
18299
18603
|
const library = libraryOf(root);
|
|
18300
18604
|
const criterion = criterionOf(library, requireString(args, "criterion_id"));
|
|
18301
18605
|
const surface = requireString(args, "surface");
|
|
@@ -18317,7 +18621,7 @@ function buildKritikCatalog(ctx) {
|
|
|
18317
18621
|
tool(
|
|
18318
18622
|
{
|
|
18319
18623
|
name: "kritik_score",
|
|
18320
|
-
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.",
|
|
18624
|
+
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. Repo sessions only: scoring reads the code, so a hosted session refuses.",
|
|
18321
18625
|
inputSchema: {
|
|
18322
18626
|
type: "object",
|
|
18323
18627
|
properties: {
|
|
@@ -18337,7 +18641,7 @@ function buildKritikCatalog(ctx) {
|
|
|
18337
18641
|
}
|
|
18338
18642
|
},
|
|
18339
18643
|
async (args) => {
|
|
18340
|
-
const root =
|
|
18644
|
+
const root = repoRootOf(ctx, "Scoring reads the code \u2014 evidence is file:line against a working tree.");
|
|
18341
18645
|
const library = libraryOf(root);
|
|
18342
18646
|
const profile = profileOf(root);
|
|
18343
18647
|
const criterionId = requireString(args, "criterion_id");
|
|
@@ -18382,7 +18686,7 @@ function buildKritikCatalog(ctx) {
|
|
|
18382
18686
|
tool(
|
|
18383
18687
|
{
|
|
18384
18688
|
name: "kritik_open_finding",
|
|
18385
|
-
description: "Open a finding on a (criterion x surface) cell and append quality.finding.opened. One finding is one defect \u2014 not one criterion, and not one surface's worth of grumbling. Verify Critical and High adversarially BEFORE opening: try to refute them against the repo, and record the verdict. Severity and priority come back derived; they are never stored.",
|
|
18689
|
+
description: "Open a finding on a (criterion x surface) cell and append quality.finding.opened. One finding is one defect \u2014 not one criterion, and not one surface's worth of grumbling. Verify Critical and High adversarially BEFORE opening: try to refute them against the repo, and record the verdict. Severity and priority come back derived; they are never stored. Repo sessions only: a new finding cites code, so a hosted session refuses.",
|
|
18386
18690
|
inputSchema: {
|
|
18387
18691
|
type: "object",
|
|
18388
18692
|
properties: {
|
|
@@ -18415,7 +18719,7 @@ function buildKritikCatalog(ctx) {
|
|
|
18415
18719
|
}
|
|
18416
18720
|
},
|
|
18417
18721
|
async (args) => {
|
|
18418
|
-
const root =
|
|
18722
|
+
const root = repoRootOf(ctx, "A new finding cites code: evidence is file:line, verified adversarially against the checkout.");
|
|
18419
18723
|
const library = libraryOf(root);
|
|
18420
18724
|
const profile = profileOf(root);
|
|
18421
18725
|
const criterionId = requireString(args, "criterion_id");
|
|
@@ -18489,14 +18793,30 @@ function buildKritikCatalog(ctx) {
|
|
|
18489
18793
|
}
|
|
18490
18794
|
},
|
|
18491
18795
|
async (args) => {
|
|
18492
|
-
const root = rootOf(ctx);
|
|
18493
18796
|
const id = requireString(args, "finding_id");
|
|
18797
|
+
const resolvedBy = typeof args.resolved_by === "string" && args.resolved_by !== "" ? args.resolved_by : void 0;
|
|
18798
|
+
if (ctx.qualityRoot === void 0) {
|
|
18799
|
+
const graph2 = await load2();
|
|
18800
|
+
const { section } = hostedSection(graph2);
|
|
18801
|
+
const finding2 = section.findings.find((candidate) => candidate.id === id);
|
|
18802
|
+
if (!finding2) throw new ToolError(`No finding "${id}" in this hosted project's quality section.`);
|
|
18803
|
+
if (finding2.status === "resolved") {
|
|
18804
|
+
return { finding: finding2, events: [], note: "Already resolved \u2014 nothing written." };
|
|
18805
|
+
}
|
|
18806
|
+
const events2 = await appendHosted(ctx.store, [
|
|
18807
|
+
{ type: "quality.finding.resolved", finding_id: finding2.id, ...resolvedBy !== void 0 ? { resolved_by: resolvedBy } : {} }
|
|
18808
|
+
]);
|
|
18809
|
+
return {
|
|
18810
|
+
finding: { ...finding2, status: "resolved", ...resolvedBy !== void 0 ? { resolved_by: resolvedBy } : {} },
|
|
18811
|
+
events: events2
|
|
18812
|
+
};
|
|
18813
|
+
}
|
|
18814
|
+
const root = repoRootOf(ctx, REPO_MODE_ONLY);
|
|
18494
18815
|
const located = locateFinding(root, id);
|
|
18495
18816
|
if (!located) throw new ToolError(`No finding "${id}" in any audit under docs/quality/audits/.`);
|
|
18496
18817
|
if (located.finding.status === "resolved") {
|
|
18497
18818
|
return { finding: located.finding, audit_id: located.auditId, events: [], note: "Already resolved \u2014 nothing written." };
|
|
18498
18819
|
}
|
|
18499
|
-
const resolvedBy = typeof args.resolved_by === "string" && args.resolved_by !== "" ? args.resolved_by : void 0;
|
|
18500
18820
|
const graph = await load2();
|
|
18501
18821
|
const events = await record2(graph, [findingResolvedInput(located.finding, resolvedBy)]);
|
|
18502
18822
|
const { findings, finding } = resolveFinding(located.file.findings, id, resolvedBy);
|
|
@@ -18507,7 +18827,7 @@ function buildKritikCatalog(ctx) {
|
|
|
18507
18827
|
tool(
|
|
18508
18828
|
{
|
|
18509
18829
|
name: "kritik_accept_finding",
|
|
18510
|
-
description: "Record a finding as a known, owned risk. The note is required \u2014 an accepted risk is a decision and reads like one, and the findings board renders it as a decision-log entry.
|
|
18830
|
+
description: "Record a finding as a known, owned risk. The note is required \u2014 an accepted risk is a decision and reads like one, and the findings board renders it as a decision-log entry. In repo mode acceptance is a state of the finding, written straight to the findings file with no journal event; a hosted session has no findings file to hold that state, so it appends quality.finding.accepted instead, and the read derives status accepted-risk from it.",
|
|
18511
18831
|
inputSchema: {
|
|
18512
18832
|
type: "object",
|
|
18513
18833
|
properties: {
|
|
@@ -18519,9 +18839,20 @@ function buildKritikCatalog(ctx) {
|
|
|
18519
18839
|
}
|
|
18520
18840
|
},
|
|
18521
18841
|
async (args) => {
|
|
18522
|
-
const root = rootOf(ctx);
|
|
18523
18842
|
const id = requireString(args, "finding_id");
|
|
18524
18843
|
const note = requireString(args, "note");
|
|
18844
|
+
if (ctx.qualityRoot === void 0) {
|
|
18845
|
+
const graph = await load2();
|
|
18846
|
+
const { section } = hostedSection(graph);
|
|
18847
|
+
const finding2 = section.findings.find((candidate) => candidate.id === id);
|
|
18848
|
+
if (!finding2) throw new ToolError(`No finding "${id}" in this hosted project's quality section.`);
|
|
18849
|
+
const events = await appendHosted(ctx.store, [{ type: "quality.finding.accepted", finding_id: finding2.id, reason: note }]);
|
|
18850
|
+
return {
|
|
18851
|
+
finding: { ...finding2, status: "accepted-risk", detail: acceptedDetail(finding2.detail, note) },
|
|
18852
|
+
events
|
|
18853
|
+
};
|
|
18854
|
+
}
|
|
18855
|
+
const root = repoRootOf(ctx, REPO_MODE_ONLY);
|
|
18525
18856
|
const located = locateFinding(root, id);
|
|
18526
18857
|
if (!located) throw new ToolError(`No finding "${id}" in any audit under docs/quality/audits/.`);
|
|
18527
18858
|
const { findings, finding } = acceptFinding(located.file.findings, id, note);
|
|
@@ -18532,7 +18863,7 @@ function buildKritikCatalog(ctx) {
|
|
|
18532
18863
|
tool(
|
|
18533
18864
|
{
|
|
18534
18865
|
name: "kritik_trip_signal",
|
|
18535
|
-
description: "Record that a monitoring signal failed between audits: appends quality.signal.tripped. A tripped signal is NOT a finding \u2014 it is the prompt to go look. Cheap, frequent, and allowed to be wrong, where a finding is expensive, rare, and has survived an adversarial pass.",
|
|
18866
|
+
description: "Record that a monitoring signal failed between audits: appends quality.signal.tripped. A tripped signal is NOT a finding \u2014 it is the prompt to go look. Cheap, frequent, and allowed to be wrong, where a finding is expensive, rare, and has survived an adversarial pass. Repo sessions only: signals are checked against the repository.",
|
|
18536
18867
|
inputSchema: {
|
|
18537
18868
|
type: "object",
|
|
18538
18869
|
properties: {
|
|
@@ -18546,7 +18877,10 @@ function buildKritikCatalog(ctx) {
|
|
|
18546
18877
|
}
|
|
18547
18878
|
},
|
|
18548
18879
|
async (args) => {
|
|
18549
|
-
const root =
|
|
18880
|
+
const root = repoRootOf(
|
|
18881
|
+
ctx,
|
|
18882
|
+
"Signals are statements checked against the repository \u2014 the pack and its run sheet live with the code."
|
|
18883
|
+
);
|
|
18550
18884
|
const library = libraryOf(root);
|
|
18551
18885
|
const profile = profileOf(root);
|
|
18552
18886
|
const criterion = criterionOf(library, requireString(args, "criterion_id"));
|
|
@@ -19082,15 +19416,15 @@ ${node.description ?? ""}`.toLowerCase();
|
|
|
19082
19416
|
|
|
19083
19417
|
// src/store.ts
|
|
19084
19418
|
import { writeFileSync as writeFileSync3 } from "node:fs";
|
|
19085
|
-
import { resolve as
|
|
19419
|
+
import { resolve as resolve3 } from "node:path";
|
|
19086
19420
|
var MCP_ACTOR = "arkaik-mcp";
|
|
19087
19421
|
var DEFAULT_BUNDLE_PATH2 = "docs/arkaik/bundle.json";
|
|
19088
19422
|
function resolveBundlePath(argv2, env) {
|
|
19089
19423
|
const flagIndex = argv2.indexOf("--bundle");
|
|
19090
19424
|
const flagValue2 = flagIndex !== -1 ? argv2[flagIndex + 1] : void 0;
|
|
19091
|
-
if (flagValue2) return
|
|
19092
|
-
if (env.ARKAIK_BUNDLE) return
|
|
19093
|
-
return
|
|
19425
|
+
if (flagValue2) return resolve3(flagValue2);
|
|
19426
|
+
if (env.ARKAIK_BUNDLE) return resolve3(env.ARKAIK_BUNDLE);
|
|
19427
|
+
return resolve3(DEFAULT_BUNDLE_PATH2);
|
|
19094
19428
|
}
|
|
19095
19429
|
function loadBundle(bundlePath) {
|
|
19096
19430
|
return validateBundleAt(bundlePath);
|
|
@@ -19258,6 +19592,30 @@ function createRemoteStore(options) {
|
|
|
19258
19592
|
},
|
|
19259
19593
|
describe() {
|
|
19260
19594
|
return `hosted project: ${options.projectId} at ${base}`;
|
|
19595
|
+
},
|
|
19596
|
+
// `quality.finding.*` events do not fold through `applyOps` — a finding
|
|
19597
|
+
// isn't a node or edge — so they get their own endpoint rather than riding
|
|
19598
|
+
// `/mutations`. And unlike `persist`, there is no client-side gate at all:
|
|
19599
|
+
// whether a finding is still open is a post-fold read of the journal, and
|
|
19600
|
+
// the server holds that journal. Sending an "open" guess from here could
|
|
19601
|
+
// only be stale the moment two sessions race, so this method does no
|
|
19602
|
+
// checking of its own — it forwards the inputs and lets the server's
|
|
19603
|
+
// verdict (post-fold, under its row lock) be the only one that counts.
|
|
19604
|
+
async appendQualityEvents(inputs) {
|
|
19605
|
+
try {
|
|
19606
|
+
const result = await request("/quality/events", {
|
|
19607
|
+
method: "POST",
|
|
19608
|
+
body: JSON.stringify({ events: inputs })
|
|
19609
|
+
});
|
|
19610
|
+
return result.events;
|
|
19611
|
+
} catch (err) {
|
|
19612
|
+
const e = err;
|
|
19613
|
+
if (e.status === 422 && e.body?.error === "refused") {
|
|
19614
|
+
const detail = e.body.refusals ? e.body.refusals.map((r) => `${r.finding_id}: ${r.reason}`).join(", ") : e.body.reason ?? "refused";
|
|
19615
|
+
throw new Error(`Quality events refused \u2014 ${detail}`);
|
|
19616
|
+
}
|
|
19617
|
+
throw err;
|
|
19618
|
+
}
|
|
19261
19619
|
}
|
|
19262
19620
|
};
|
|
19263
19621
|
}
|
|
@@ -19317,7 +19675,7 @@ function resolveRemoteConfig(argv2, env, cwd) {
|
|
|
19317
19675
|
}
|
|
19318
19676
|
|
|
19319
19677
|
// src/index.ts
|
|
19320
|
-
var VERSION = "0.
|
|
19678
|
+
var VERSION = "0.4.0";
|
|
19321
19679
|
var argv = process.argv.slice(2);
|
|
19322
19680
|
if (argv.includes("--help") || argv.includes("-h")) {
|
|
19323
19681
|
process.stdout.write(
|
|
@@ -19354,14 +19712,8 @@ function resolveStore() {
|
|
|
19354
19712
|
};
|
|
19355
19713
|
}
|
|
19356
19714
|
const bundlePath = resolveBundlePath(argv, process.env);
|
|
19357
|
-
|
|
19358
|
-
}
|
|
19359
|
-
function qualityRootFor(bundlePath) {
|
|
19360
|
-
if (process.env.ARKAIK_QUALITY_ROOT) return resolve3(process.env.ARKAIK_QUALITY_ROOT);
|
|
19361
|
-
const dir = dirname4(bundlePath);
|
|
19362
|
-
const parent = dirname4(dir);
|
|
19363
|
-
if (dir.endsWith(`${sep}arkaik`) && parent.endsWith(`${sep}docs`)) return dirname4(parent);
|
|
19364
|
-
return dir;
|
|
19715
|
+
const qualityRoot2 = resolveQualityRoot({ bundlePath, fallback: dirname4(bundlePath) });
|
|
19716
|
+
return { store: createFileStore(bundlePath), qualityRoot: qualityRoot2 };
|
|
19365
19717
|
}
|
|
19366
19718
|
var store;
|
|
19367
19719
|
var qualityRoot;
|
package/package.json
CHANGED