arkaik-mcp 0.13.0 → 0.14.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/assets/kritik/library.json +88 -0
- package/dist/index.js +1879 -1478
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -120,7 +120,7 @@ function asObject(value) {
|
|
|
120
120
|
return { detail: value };
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
//
|
|
123
|
+
// ../../node_modules/zod/v4/classic/external.js
|
|
124
124
|
var external_exports = {};
|
|
125
125
|
__export(external_exports, {
|
|
126
126
|
$brand: () => $brand,
|
|
@@ -363,7 +363,7 @@ __export(external_exports, {
|
|
|
363
363
|
xor: () => xor
|
|
364
364
|
});
|
|
365
365
|
|
|
366
|
-
//
|
|
366
|
+
// ../../node_modules/zod/v4/core/index.js
|
|
367
367
|
var core_exports2 = {};
|
|
368
368
|
__export(core_exports2, {
|
|
369
369
|
$ZodAny: () => $ZodAny,
|
|
@@ -642,7 +642,7 @@ __export(core_exports2, {
|
|
|
642
642
|
version: () => version
|
|
643
643
|
});
|
|
644
644
|
|
|
645
|
-
//
|
|
645
|
+
// ../../node_modules/zod/v4/core/core.js
|
|
646
646
|
var _a;
|
|
647
647
|
var NEVER = /* @__PURE__ */ Object.freeze({
|
|
648
648
|
status: "aborted"
|
|
@@ -719,7 +719,7 @@ function config(newConfig) {
|
|
|
719
719
|
return globalConfig;
|
|
720
720
|
}
|
|
721
721
|
|
|
722
|
-
//
|
|
722
|
+
// ../../node_modules/zod/v4/core/util.js
|
|
723
723
|
var util_exports = {};
|
|
724
724
|
__export(util_exports, {
|
|
725
725
|
BIGINT_FORMAT_RANGES: () => BIGINT_FORMAT_RANGES,
|
|
@@ -1415,7 +1415,7 @@ var Class = class {
|
|
|
1415
1415
|
}
|
|
1416
1416
|
};
|
|
1417
1417
|
|
|
1418
|
-
//
|
|
1418
|
+
// ../../node_modules/zod/v4/core/errors.js
|
|
1419
1419
|
var initializer = (inst, def) => {
|
|
1420
1420
|
inst.name = "$ZodError";
|
|
1421
1421
|
Object.defineProperty(inst, "_zod", {
|
|
@@ -1554,7 +1554,7 @@ function prettifyError(error51) {
|
|
|
1554
1554
|
return lines.join("\n");
|
|
1555
1555
|
}
|
|
1556
1556
|
|
|
1557
|
-
//
|
|
1557
|
+
// ../../node_modules/zod/v4/core/parse.js
|
|
1558
1558
|
var _parse = (_Err) => (schema, value, _ctx, _params) => {
|
|
1559
1559
|
const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
|
|
1560
1560
|
const result = schema._zod.run({ value, issues: [] }, ctx);
|
|
@@ -1642,7 +1642,7 @@ var _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
|
1642
1642
|
};
|
|
1643
1643
|
var safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync($ZodRealError);
|
|
1644
1644
|
|
|
1645
|
-
//
|
|
1645
|
+
// ../../node_modules/zod/v4/core/regexes.js
|
|
1646
1646
|
var regexes_exports = {};
|
|
1647
1647
|
__export(regexes_exports, {
|
|
1648
1648
|
base64: () => base64,
|
|
@@ -1801,7 +1801,7 @@ var sha512_hex = /^[0-9a-fA-F]{128}$/;
|
|
|
1801
1801
|
var sha512_base64 = /* @__PURE__ */ fixedBase64(86, "==");
|
|
1802
1802
|
var sha512_base64url = /* @__PURE__ */ fixedBase64url(86);
|
|
1803
1803
|
|
|
1804
|
-
//
|
|
1804
|
+
// ../../node_modules/zod/v4/core/checks.js
|
|
1805
1805
|
var $ZodCheck = /* @__PURE__ */ $constructor("$ZodCheck", (inst, def) => {
|
|
1806
1806
|
var _a3;
|
|
1807
1807
|
inst._zod ?? (inst._zod = {});
|
|
@@ -2349,7 +2349,7 @@ var $ZodCheckOverwrite = /* @__PURE__ */ $constructor("$ZodCheckOverwrite", (ins
|
|
|
2349
2349
|
};
|
|
2350
2350
|
});
|
|
2351
2351
|
|
|
2352
|
-
//
|
|
2352
|
+
// ../../node_modules/zod/v4/core/doc.js
|
|
2353
2353
|
var Doc = class {
|
|
2354
2354
|
constructor(args = []) {
|
|
2355
2355
|
this.content = [];
|
|
@@ -2385,14 +2385,14 @@ var Doc = class {
|
|
|
2385
2385
|
}
|
|
2386
2386
|
};
|
|
2387
2387
|
|
|
2388
|
-
//
|
|
2388
|
+
// ../../node_modules/zod/v4/core/versions.js
|
|
2389
2389
|
var version = {
|
|
2390
2390
|
major: 4,
|
|
2391
2391
|
minor: 4,
|
|
2392
2392
|
patch: 3
|
|
2393
2393
|
};
|
|
2394
2394
|
|
|
2395
|
-
//
|
|
2395
|
+
// ../../node_modules/zod/v4/core/schemas.js
|
|
2396
2396
|
var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
2397
2397
|
var _a3;
|
|
2398
2398
|
inst ?? (inst = {});
|
|
@@ -4485,7 +4485,7 @@ function handleRefineResult(result, payload, input, inst) {
|
|
|
4485
4485
|
}
|
|
4486
4486
|
}
|
|
4487
4487
|
|
|
4488
|
-
//
|
|
4488
|
+
// ../../node_modules/zod/v4/locales/index.js
|
|
4489
4489
|
var locales_exports = {};
|
|
4490
4490
|
__export(locales_exports, {
|
|
4491
4491
|
ar: () => ar_default,
|
|
@@ -4542,7 +4542,7 @@ __export(locales_exports, {
|
|
|
4542
4542
|
zhTW: () => zh_TW_default
|
|
4543
4543
|
});
|
|
4544
4544
|
|
|
4545
|
-
//
|
|
4545
|
+
// ../../node_modules/zod/v4/locales/ar.js
|
|
4546
4546
|
var error = () => {
|
|
4547
4547
|
const Sizable = {
|
|
4548
4548
|
string: { unit: "\u062D\u0631\u0641", verb: "\u0623\u0646 \u064A\u062D\u0648\u064A" },
|
|
@@ -4649,7 +4649,7 @@ function ar_default() {
|
|
|
4649
4649
|
};
|
|
4650
4650
|
}
|
|
4651
4651
|
|
|
4652
|
-
//
|
|
4652
|
+
// ../../node_modules/zod/v4/locales/az.js
|
|
4653
4653
|
var error2 = () => {
|
|
4654
4654
|
const Sizable = {
|
|
4655
4655
|
string: { unit: "simvol", verb: "olmal\u0131d\u0131r" },
|
|
@@ -4755,7 +4755,7 @@ function az_default() {
|
|
|
4755
4755
|
};
|
|
4756
4756
|
}
|
|
4757
4757
|
|
|
4758
|
-
//
|
|
4758
|
+
// ../../node_modules/zod/v4/locales/be.js
|
|
4759
4759
|
function getBelarusianPlural(count, one, few, many) {
|
|
4760
4760
|
const absCount = Math.abs(count);
|
|
4761
4761
|
const lastDigit = absCount % 10;
|
|
@@ -4912,7 +4912,7 @@ function be_default() {
|
|
|
4912
4912
|
};
|
|
4913
4913
|
}
|
|
4914
4914
|
|
|
4915
|
-
//
|
|
4915
|
+
// ../../node_modules/zod/v4/locales/bg.js
|
|
4916
4916
|
var error4 = () => {
|
|
4917
4917
|
const Sizable = {
|
|
4918
4918
|
string: { unit: "\u0441\u0438\u043C\u0432\u043E\u043B\u0430", verb: "\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430" },
|
|
@@ -5033,7 +5033,7 @@ function bg_default() {
|
|
|
5033
5033
|
};
|
|
5034
5034
|
}
|
|
5035
5035
|
|
|
5036
|
-
//
|
|
5036
|
+
// ../../node_modules/zod/v4/locales/ca.js
|
|
5037
5037
|
var error5 = () => {
|
|
5038
5038
|
const Sizable = {
|
|
5039
5039
|
string: { unit: "car\xE0cters", verb: "contenir" },
|
|
@@ -5142,7 +5142,7 @@ function ca_default() {
|
|
|
5142
5142
|
};
|
|
5143
5143
|
}
|
|
5144
5144
|
|
|
5145
|
-
//
|
|
5145
|
+
// ../../node_modules/zod/v4/locales/cs.js
|
|
5146
5146
|
var error6 = () => {
|
|
5147
5147
|
const Sizable = {
|
|
5148
5148
|
string: { unit: "znak\u016F", verb: "m\xEDt" },
|
|
@@ -5254,7 +5254,7 @@ function cs_default() {
|
|
|
5254
5254
|
};
|
|
5255
5255
|
}
|
|
5256
5256
|
|
|
5257
|
-
//
|
|
5257
|
+
// ../../node_modules/zod/v4/locales/da.js
|
|
5258
5258
|
var error7 = () => {
|
|
5259
5259
|
const Sizable = {
|
|
5260
5260
|
string: { unit: "tegn", verb: "havde" },
|
|
@@ -5370,7 +5370,7 @@ function da_default() {
|
|
|
5370
5370
|
};
|
|
5371
5371
|
}
|
|
5372
5372
|
|
|
5373
|
-
//
|
|
5373
|
+
// ../../node_modules/zod/v4/locales/de.js
|
|
5374
5374
|
var error8 = () => {
|
|
5375
5375
|
const Sizable = {
|
|
5376
5376
|
string: { unit: "Zeichen", verb: "zu haben" },
|
|
@@ -5479,7 +5479,7 @@ function de_default() {
|
|
|
5479
5479
|
};
|
|
5480
5480
|
}
|
|
5481
5481
|
|
|
5482
|
-
//
|
|
5482
|
+
// ../../node_modules/zod/v4/locales/el.js
|
|
5483
5483
|
var error9 = () => {
|
|
5484
5484
|
const Sizable = {
|
|
5485
5485
|
string: { unit: "\u03C7\u03B1\u03C1\u03B1\u03BA\u03C4\u03AE\u03C1\u03B5\u03C2", verb: "\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9" },
|
|
@@ -5589,7 +5589,7 @@ function el_default() {
|
|
|
5589
5589
|
};
|
|
5590
5590
|
}
|
|
5591
5591
|
|
|
5592
|
-
//
|
|
5592
|
+
// ../../node_modules/zod/v4/locales/en.js
|
|
5593
5593
|
var error10 = () => {
|
|
5594
5594
|
const Sizable = {
|
|
5595
5595
|
string: { unit: "characters", verb: "to have" },
|
|
@@ -5702,7 +5702,7 @@ function en_default() {
|
|
|
5702
5702
|
};
|
|
5703
5703
|
}
|
|
5704
5704
|
|
|
5705
|
-
//
|
|
5705
|
+
// ../../node_modules/zod/v4/locales/eo.js
|
|
5706
5706
|
var error11 = () => {
|
|
5707
5707
|
const Sizable = {
|
|
5708
5708
|
string: { unit: "karaktrojn", verb: "havi" },
|
|
@@ -5812,7 +5812,7 @@ function eo_default() {
|
|
|
5812
5812
|
};
|
|
5813
5813
|
}
|
|
5814
5814
|
|
|
5815
|
-
//
|
|
5815
|
+
// ../../node_modules/zod/v4/locales/es.js
|
|
5816
5816
|
var error12 = () => {
|
|
5817
5817
|
const Sizable = {
|
|
5818
5818
|
string: { unit: "caracteres", verb: "tener" },
|
|
@@ -5945,7 +5945,7 @@ function es_default() {
|
|
|
5945
5945
|
};
|
|
5946
5946
|
}
|
|
5947
5947
|
|
|
5948
|
-
//
|
|
5948
|
+
// ../../node_modules/zod/v4/locales/fa.js
|
|
5949
5949
|
var error13 = () => {
|
|
5950
5950
|
const Sizable = {
|
|
5951
5951
|
string: { unit: "\u06A9\u0627\u0631\u0627\u06A9\u062A\u0631", verb: "\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F" },
|
|
@@ -6060,7 +6060,7 @@ function fa_default() {
|
|
|
6060
6060
|
};
|
|
6061
6061
|
}
|
|
6062
6062
|
|
|
6063
|
-
//
|
|
6063
|
+
// ../../node_modules/zod/v4/locales/fi.js
|
|
6064
6064
|
var error14 = () => {
|
|
6065
6065
|
const Sizable = {
|
|
6066
6066
|
string: { unit: "merkki\xE4", subject: "merkkijonon" },
|
|
@@ -6173,7 +6173,7 @@ function fi_default() {
|
|
|
6173
6173
|
};
|
|
6174
6174
|
}
|
|
6175
6175
|
|
|
6176
|
-
//
|
|
6176
|
+
// ../../node_modules/zod/v4/locales/fr.js
|
|
6177
6177
|
var error15 = () => {
|
|
6178
6178
|
const Sizable = {
|
|
6179
6179
|
string: { unit: "caract\xE8res", verb: "avoir" },
|
|
@@ -6299,7 +6299,7 @@ function fr_default() {
|
|
|
6299
6299
|
};
|
|
6300
6300
|
}
|
|
6301
6301
|
|
|
6302
|
-
//
|
|
6302
|
+
// ../../node_modules/zod/v4/locales/fr-CA.js
|
|
6303
6303
|
var error16 = () => {
|
|
6304
6304
|
const Sizable = {
|
|
6305
6305
|
string: { unit: "caract\xE8res", verb: "avoir" },
|
|
@@ -6407,7 +6407,7 @@ function fr_CA_default() {
|
|
|
6407
6407
|
};
|
|
6408
6408
|
}
|
|
6409
6409
|
|
|
6410
|
-
//
|
|
6410
|
+
// ../../node_modules/zod/v4/locales/he.js
|
|
6411
6411
|
var error17 = () => {
|
|
6412
6412
|
const TypeNames = {
|
|
6413
6413
|
string: { label: "\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA", gender: "f" },
|
|
@@ -6602,7 +6602,7 @@ function he_default() {
|
|
|
6602
6602
|
};
|
|
6603
6603
|
}
|
|
6604
6604
|
|
|
6605
|
-
//
|
|
6605
|
+
// ../../node_modules/zod/v4/locales/hr.js
|
|
6606
6606
|
var error18 = () => {
|
|
6607
6607
|
const Sizable = {
|
|
6608
6608
|
string: { unit: "znakova", verb: "imati" },
|
|
@@ -6725,7 +6725,7 @@ function hr_default() {
|
|
|
6725
6725
|
};
|
|
6726
6726
|
}
|
|
6727
6727
|
|
|
6728
|
-
//
|
|
6728
|
+
// ../../node_modules/zod/v4/locales/hu.js
|
|
6729
6729
|
var error19 = () => {
|
|
6730
6730
|
const Sizable = {
|
|
6731
6731
|
string: { unit: "karakter", verb: "legyen" },
|
|
@@ -6834,7 +6834,7 @@ function hu_default() {
|
|
|
6834
6834
|
};
|
|
6835
6835
|
}
|
|
6836
6836
|
|
|
6837
|
-
//
|
|
6837
|
+
// ../../node_modules/zod/v4/locales/hy.js
|
|
6838
6838
|
function getArmenianPlural(count, one, many) {
|
|
6839
6839
|
return Math.abs(count) === 1 ? one : many;
|
|
6840
6840
|
}
|
|
@@ -6982,7 +6982,7 @@ function hy_default() {
|
|
|
6982
6982
|
};
|
|
6983
6983
|
}
|
|
6984
6984
|
|
|
6985
|
-
//
|
|
6985
|
+
// ../../node_modules/zod/v4/locales/id.js
|
|
6986
6986
|
var error21 = () => {
|
|
6987
6987
|
const Sizable = {
|
|
6988
6988
|
string: { unit: "karakter", verb: "memiliki" },
|
|
@@ -7089,7 +7089,7 @@ function id_default() {
|
|
|
7089
7089
|
};
|
|
7090
7090
|
}
|
|
7091
7091
|
|
|
7092
|
-
//
|
|
7092
|
+
// ../../node_modules/zod/v4/locales/is.js
|
|
7093
7093
|
var error22 = () => {
|
|
7094
7094
|
const Sizable = {
|
|
7095
7095
|
string: { unit: "stafi", verb: "a\xF0 hafa" },
|
|
@@ -7199,7 +7199,7 @@ function is_default() {
|
|
|
7199
7199
|
};
|
|
7200
7200
|
}
|
|
7201
7201
|
|
|
7202
|
-
//
|
|
7202
|
+
// ../../node_modules/zod/v4/locales/it.js
|
|
7203
7203
|
var error23 = () => {
|
|
7204
7204
|
const Sizable = {
|
|
7205
7205
|
string: { unit: "caratteri", verb: "avere" },
|
|
@@ -7308,7 +7308,7 @@ function it_default() {
|
|
|
7308
7308
|
};
|
|
7309
7309
|
}
|
|
7310
7310
|
|
|
7311
|
-
//
|
|
7311
|
+
// ../../node_modules/zod/v4/locales/ja.js
|
|
7312
7312
|
var error24 = () => {
|
|
7313
7313
|
const Sizable = {
|
|
7314
7314
|
string: { unit: "\u6587\u5B57", verb: "\u3067\u3042\u308B" },
|
|
@@ -7416,7 +7416,7 @@ function ja_default() {
|
|
|
7416
7416
|
};
|
|
7417
7417
|
}
|
|
7418
7418
|
|
|
7419
|
-
//
|
|
7419
|
+
// ../../node_modules/zod/v4/locales/ka.js
|
|
7420
7420
|
var error25 = () => {
|
|
7421
7421
|
const Sizable = {
|
|
7422
7422
|
string: { unit: "\u10E1\u10D8\u10DB\u10D1\u10DD\u10DA\u10DD", verb: "\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1" },
|
|
@@ -7529,7 +7529,7 @@ function ka_default() {
|
|
|
7529
7529
|
};
|
|
7530
7530
|
}
|
|
7531
7531
|
|
|
7532
|
-
//
|
|
7532
|
+
// ../../node_modules/zod/v4/locales/km.js
|
|
7533
7533
|
var error26 = () => {
|
|
7534
7534
|
const Sizable = {
|
|
7535
7535
|
string: { unit: "\u178F\u17BD\u17A2\u1780\u17D2\u179F\u179A", verb: "\u1782\u17BD\u179A\u1798\u17B6\u1793" },
|
|
@@ -7640,12 +7640,12 @@ function km_default() {
|
|
|
7640
7640
|
};
|
|
7641
7641
|
}
|
|
7642
7642
|
|
|
7643
|
-
//
|
|
7643
|
+
// ../../node_modules/zod/v4/locales/kh.js
|
|
7644
7644
|
function kh_default() {
|
|
7645
7645
|
return km_default();
|
|
7646
7646
|
}
|
|
7647
7647
|
|
|
7648
|
-
//
|
|
7648
|
+
// ../../node_modules/zod/v4/locales/ko.js
|
|
7649
7649
|
var error27 = () => {
|
|
7650
7650
|
const Sizable = {
|
|
7651
7651
|
string: { unit: "\uBB38\uC790", verb: "to have" },
|
|
@@ -7757,7 +7757,7 @@ function ko_default() {
|
|
|
7757
7757
|
};
|
|
7758
7758
|
}
|
|
7759
7759
|
|
|
7760
|
-
//
|
|
7760
|
+
// ../../node_modules/zod/v4/locales/lt.js
|
|
7761
7761
|
var capitalizeFirstCharacter = (text) => {
|
|
7762
7762
|
return text.charAt(0).toUpperCase() + text.slice(1);
|
|
7763
7763
|
};
|
|
@@ -7961,7 +7961,7 @@ function lt_default() {
|
|
|
7961
7961
|
};
|
|
7962
7962
|
}
|
|
7963
7963
|
|
|
7964
|
-
//
|
|
7964
|
+
// ../../node_modules/zod/v4/locales/mk.js
|
|
7965
7965
|
var error29 = () => {
|
|
7966
7966
|
const Sizable = {
|
|
7967
7967
|
string: { unit: "\u0437\u043D\u0430\u0446\u0438", verb: "\u0434\u0430 \u0438\u043C\u0430\u0430\u0442" },
|
|
@@ -8071,7 +8071,7 @@ function mk_default() {
|
|
|
8071
8071
|
};
|
|
8072
8072
|
}
|
|
8073
8073
|
|
|
8074
|
-
//
|
|
8074
|
+
// ../../node_modules/zod/v4/locales/ms.js
|
|
8075
8075
|
var error30 = () => {
|
|
8076
8076
|
const Sizable = {
|
|
8077
8077
|
string: { unit: "aksara", verb: "mempunyai" },
|
|
@@ -8179,7 +8179,7 @@ function ms_default() {
|
|
|
8179
8179
|
};
|
|
8180
8180
|
}
|
|
8181
8181
|
|
|
8182
|
-
//
|
|
8182
|
+
// ../../node_modules/zod/v4/locales/nl.js
|
|
8183
8183
|
var error31 = () => {
|
|
8184
8184
|
const Sizable = {
|
|
8185
8185
|
string: { unit: "tekens", verb: "heeft" },
|
|
@@ -8290,7 +8290,7 @@ function nl_default() {
|
|
|
8290
8290
|
};
|
|
8291
8291
|
}
|
|
8292
8292
|
|
|
8293
|
-
//
|
|
8293
|
+
// ../../node_modules/zod/v4/locales/no.js
|
|
8294
8294
|
var error32 = () => {
|
|
8295
8295
|
const Sizable = {
|
|
8296
8296
|
string: { unit: "tegn", verb: "\xE5 ha" },
|
|
@@ -8399,7 +8399,7 @@ function no_default() {
|
|
|
8399
8399
|
};
|
|
8400
8400
|
}
|
|
8401
8401
|
|
|
8402
|
-
//
|
|
8402
|
+
// ../../node_modules/zod/v4/locales/ota.js
|
|
8403
8403
|
var error33 = () => {
|
|
8404
8404
|
const Sizable = {
|
|
8405
8405
|
string: { unit: "harf", verb: "olmal\u0131d\u0131r" },
|
|
@@ -8509,7 +8509,7 @@ function ota_default() {
|
|
|
8509
8509
|
};
|
|
8510
8510
|
}
|
|
8511
8511
|
|
|
8512
|
-
//
|
|
8512
|
+
// ../../node_modules/zod/v4/locales/ps.js
|
|
8513
8513
|
var error34 = () => {
|
|
8514
8514
|
const Sizable = {
|
|
8515
8515
|
string: { unit: "\u062A\u0648\u06A9\u064A", verb: "\u0648\u0644\u0631\u064A" },
|
|
@@ -8624,7 +8624,7 @@ function ps_default() {
|
|
|
8624
8624
|
};
|
|
8625
8625
|
}
|
|
8626
8626
|
|
|
8627
|
-
//
|
|
8627
|
+
// ../../node_modules/zod/v4/locales/pl.js
|
|
8628
8628
|
var error35 = () => {
|
|
8629
8629
|
const Sizable = {
|
|
8630
8630
|
string: { unit: "znak\xF3w", verb: "mie\u0107" },
|
|
@@ -8734,7 +8734,7 @@ function pl_default() {
|
|
|
8734
8734
|
};
|
|
8735
8735
|
}
|
|
8736
8736
|
|
|
8737
|
-
//
|
|
8737
|
+
// ../../node_modules/zod/v4/locales/pt.js
|
|
8738
8738
|
var error36 = () => {
|
|
8739
8739
|
const Sizable = {
|
|
8740
8740
|
string: { unit: "caracteres", verb: "ter" },
|
|
@@ -8843,7 +8843,7 @@ function pt_default() {
|
|
|
8843
8843
|
};
|
|
8844
8844
|
}
|
|
8845
8845
|
|
|
8846
|
-
//
|
|
8846
|
+
// ../../node_modules/zod/v4/locales/ro.js
|
|
8847
8847
|
var error37 = () => {
|
|
8848
8848
|
const Sizable = {
|
|
8849
8849
|
string: { unit: "caractere", verb: "s\u0103 aib\u0103" },
|
|
@@ -8963,7 +8963,7 @@ function ro_default() {
|
|
|
8963
8963
|
};
|
|
8964
8964
|
}
|
|
8965
8965
|
|
|
8966
|
-
//
|
|
8966
|
+
// ../../node_modules/zod/v4/locales/ru.js
|
|
8967
8967
|
function getRussianPlural(count, one, few, many) {
|
|
8968
8968
|
const absCount = Math.abs(count);
|
|
8969
8969
|
const lastDigit = absCount % 10;
|
|
@@ -9120,7 +9120,7 @@ function ru_default() {
|
|
|
9120
9120
|
};
|
|
9121
9121
|
}
|
|
9122
9122
|
|
|
9123
|
-
//
|
|
9123
|
+
// ../../node_modules/zod/v4/locales/sl.js
|
|
9124
9124
|
var error39 = () => {
|
|
9125
9125
|
const Sizable = {
|
|
9126
9126
|
string: { unit: "znakov", verb: "imeti" },
|
|
@@ -9230,7 +9230,7 @@ function sl_default() {
|
|
|
9230
9230
|
};
|
|
9231
9231
|
}
|
|
9232
9232
|
|
|
9233
|
-
//
|
|
9233
|
+
// ../../node_modules/zod/v4/locales/sv.js
|
|
9234
9234
|
var error40 = () => {
|
|
9235
9235
|
const Sizable = {
|
|
9236
9236
|
string: { unit: "tecken", verb: "att ha" },
|
|
@@ -9341,7 +9341,7 @@ function sv_default() {
|
|
|
9341
9341
|
};
|
|
9342
9342
|
}
|
|
9343
9343
|
|
|
9344
|
-
//
|
|
9344
|
+
// ../../node_modules/zod/v4/locales/ta.js
|
|
9345
9345
|
var error41 = () => {
|
|
9346
9346
|
const Sizable = {
|
|
9347
9347
|
string: { unit: "\u0B8E\u0BB4\u0BC1\u0BA4\u0BCD\u0BA4\u0BC1\u0B95\u0BCD\u0B95\u0BB3\u0BCD", verb: "\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD" },
|
|
@@ -9452,7 +9452,7 @@ function ta_default() {
|
|
|
9452
9452
|
};
|
|
9453
9453
|
}
|
|
9454
9454
|
|
|
9455
|
-
//
|
|
9455
|
+
// ../../node_modules/zod/v4/locales/th.js
|
|
9456
9456
|
var error42 = () => {
|
|
9457
9457
|
const Sizable = {
|
|
9458
9458
|
string: { unit: "\u0E15\u0E31\u0E27\u0E2D\u0E31\u0E01\u0E29\u0E23", verb: "\u0E04\u0E27\u0E23\u0E21\u0E35" },
|
|
@@ -9563,7 +9563,7 @@ function th_default() {
|
|
|
9563
9563
|
};
|
|
9564
9564
|
}
|
|
9565
9565
|
|
|
9566
|
-
//
|
|
9566
|
+
// ../../node_modules/zod/v4/locales/tr.js
|
|
9567
9567
|
var error43 = () => {
|
|
9568
9568
|
const Sizable = {
|
|
9569
9569
|
string: { unit: "karakter", verb: "olmal\u0131" },
|
|
@@ -9669,7 +9669,7 @@ function tr_default() {
|
|
|
9669
9669
|
};
|
|
9670
9670
|
}
|
|
9671
9671
|
|
|
9672
|
-
//
|
|
9672
|
+
// ../../node_modules/zod/v4/locales/uk.js
|
|
9673
9673
|
var error44 = () => {
|
|
9674
9674
|
const Sizable = {
|
|
9675
9675
|
string: { unit: "\u0441\u0438\u043C\u0432\u043E\u043B\u0456\u0432", verb: "\u043C\u0430\u0442\u0438\u043C\u0435" },
|
|
@@ -9778,12 +9778,12 @@ function uk_default() {
|
|
|
9778
9778
|
};
|
|
9779
9779
|
}
|
|
9780
9780
|
|
|
9781
|
-
//
|
|
9781
|
+
// ../../node_modules/zod/v4/locales/ua.js
|
|
9782
9782
|
function ua_default() {
|
|
9783
9783
|
return uk_default();
|
|
9784
9784
|
}
|
|
9785
9785
|
|
|
9786
|
-
//
|
|
9786
|
+
// ../../node_modules/zod/v4/locales/ur.js
|
|
9787
9787
|
var error45 = () => {
|
|
9788
9788
|
const Sizable = {
|
|
9789
9789
|
string: { unit: "\u062D\u0631\u0648\u0641", verb: "\u06C1\u0648\u0646\u0627" },
|
|
@@ -9894,7 +9894,7 @@ function ur_default() {
|
|
|
9894
9894
|
};
|
|
9895
9895
|
}
|
|
9896
9896
|
|
|
9897
|
-
//
|
|
9897
|
+
// ../../node_modules/zod/v4/locales/uz.js
|
|
9898
9898
|
var error46 = () => {
|
|
9899
9899
|
const Sizable = {
|
|
9900
9900
|
string: { unit: "belgi", verb: "bo\u2018lishi kerak" },
|
|
@@ -10005,7 +10005,7 @@ function uz_default() {
|
|
|
10005
10005
|
};
|
|
10006
10006
|
}
|
|
10007
10007
|
|
|
10008
|
-
//
|
|
10008
|
+
// ../../node_modules/zod/v4/locales/vi.js
|
|
10009
10009
|
var error47 = () => {
|
|
10010
10010
|
const Sizable = {
|
|
10011
10011
|
string: { unit: "k\xFD t\u1EF1", verb: "c\xF3" },
|
|
@@ -10114,7 +10114,7 @@ function vi_default() {
|
|
|
10114
10114
|
};
|
|
10115
10115
|
}
|
|
10116
10116
|
|
|
10117
|
-
//
|
|
10117
|
+
// ../../node_modules/zod/v4/locales/zh-CN.js
|
|
10118
10118
|
var error48 = () => {
|
|
10119
10119
|
const Sizable = {
|
|
10120
10120
|
string: { unit: "\u5B57\u7B26", verb: "\u5305\u542B" },
|
|
@@ -10224,7 +10224,7 @@ function zh_CN_default() {
|
|
|
10224
10224
|
};
|
|
10225
10225
|
}
|
|
10226
10226
|
|
|
10227
|
-
//
|
|
10227
|
+
// ../../node_modules/zod/v4/locales/zh-TW.js
|
|
10228
10228
|
var error49 = () => {
|
|
10229
10229
|
const Sizable = {
|
|
10230
10230
|
string: { unit: "\u5B57\u5143", verb: "\u64C1\u6709" },
|
|
@@ -10332,7 +10332,7 @@ function zh_TW_default() {
|
|
|
10332
10332
|
};
|
|
10333
10333
|
}
|
|
10334
10334
|
|
|
10335
|
-
//
|
|
10335
|
+
// ../../node_modules/zod/v4/locales/yo.js
|
|
10336
10336
|
var error50 = () => {
|
|
10337
10337
|
const Sizable = {
|
|
10338
10338
|
string: { unit: "\xE0mi", verb: "n\xED" },
|
|
@@ -10440,7 +10440,7 @@ function yo_default() {
|
|
|
10440
10440
|
};
|
|
10441
10441
|
}
|
|
10442
10442
|
|
|
10443
|
-
//
|
|
10443
|
+
// ../../node_modules/zod/v4/core/registries.js
|
|
10444
10444
|
var _a2;
|
|
10445
10445
|
var $output = /* @__PURE__ */ Symbol("ZodOutput");
|
|
10446
10446
|
var $input = /* @__PURE__ */ Symbol("ZodInput");
|
|
@@ -10490,7 +10490,7 @@ function registry() {
|
|
|
10490
10490
|
(_a2 = globalThis).__zod_globalRegistry ?? (_a2.__zod_globalRegistry = registry());
|
|
10491
10491
|
var globalRegistry = globalThis.__zod_globalRegistry;
|
|
10492
10492
|
|
|
10493
|
-
//
|
|
10493
|
+
// ../../node_modules/zod/v4/core/api.js
|
|
10494
10494
|
// @__NO_SIDE_EFFECTS__
|
|
10495
10495
|
function _string(Class2, params) {
|
|
10496
10496
|
return new Class2({
|
|
@@ -11529,7 +11529,7 @@ function _stringFormat(Class2, format, fnOrRegex, _params = {}) {
|
|
|
11529
11529
|
return inst;
|
|
11530
11530
|
}
|
|
11531
11531
|
|
|
11532
|
-
//
|
|
11532
|
+
// ../../node_modules/zod/v4/core/to-json-schema.js
|
|
11533
11533
|
function initializeContext(params) {
|
|
11534
11534
|
let target = params?.target ?? "draft-2020-12";
|
|
11535
11535
|
if (target === "draft-4")
|
|
@@ -11888,7 +11888,7 @@ var createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) =
|
|
|
11888
11888
|
return finalize(ctx, schema);
|
|
11889
11889
|
};
|
|
11890
11890
|
|
|
11891
|
-
//
|
|
11891
|
+
// ../../node_modules/zod/v4/core/json-schema-processors.js
|
|
11892
11892
|
var formatMap = {
|
|
11893
11893
|
guid: "uuid",
|
|
11894
11894
|
url: "uri",
|
|
@@ -12432,7 +12432,7 @@ function toJSONSchema(input, params) {
|
|
|
12432
12432
|
return finalize(ctx, input);
|
|
12433
12433
|
}
|
|
12434
12434
|
|
|
12435
|
-
//
|
|
12435
|
+
// ../../node_modules/zod/v4/core/json-schema-generator.js
|
|
12436
12436
|
var JSONSchemaGenerator = class {
|
|
12437
12437
|
/** @deprecated Access via ctx instead */
|
|
12438
12438
|
get metadataRegistry() {
|
|
@@ -12507,10 +12507,10 @@ var JSONSchemaGenerator = class {
|
|
|
12507
12507
|
}
|
|
12508
12508
|
};
|
|
12509
12509
|
|
|
12510
|
-
//
|
|
12510
|
+
// ../../node_modules/zod/v4/core/json-schema.js
|
|
12511
12511
|
var json_schema_exports = {};
|
|
12512
12512
|
|
|
12513
|
-
//
|
|
12513
|
+
// ../../node_modules/zod/v4/classic/schemas.js
|
|
12514
12514
|
var schemas_exports2 = {};
|
|
12515
12515
|
__export(schemas_exports2, {
|
|
12516
12516
|
ZodAny: () => ZodAny,
|
|
@@ -12681,7 +12681,7 @@ __export(schemas_exports2, {
|
|
|
12681
12681
|
xor: () => xor
|
|
12682
12682
|
});
|
|
12683
12683
|
|
|
12684
|
-
//
|
|
12684
|
+
// ../../node_modules/zod/v4/classic/checks.js
|
|
12685
12685
|
var checks_exports2 = {};
|
|
12686
12686
|
__export(checks_exports2, {
|
|
12687
12687
|
endsWith: () => _endsWith,
|
|
@@ -12715,7 +12715,7 @@ __export(checks_exports2, {
|
|
|
12715
12715
|
uppercase: () => _uppercase
|
|
12716
12716
|
});
|
|
12717
12717
|
|
|
12718
|
-
//
|
|
12718
|
+
// ../../node_modules/zod/v4/classic/iso.js
|
|
12719
12719
|
var iso_exports = {};
|
|
12720
12720
|
__export(iso_exports, {
|
|
12721
12721
|
ZodISODate: () => ZodISODate,
|
|
@@ -12756,7 +12756,7 @@ function duration2(params) {
|
|
|
12756
12756
|
return _isoDuration(ZodISODuration, params);
|
|
12757
12757
|
}
|
|
12758
12758
|
|
|
12759
|
-
//
|
|
12759
|
+
// ../../node_modules/zod/v4/classic/errors.js
|
|
12760
12760
|
var initializer2 = (inst, issues) => {
|
|
12761
12761
|
$ZodError.init(inst, issues);
|
|
12762
12762
|
inst.name = "ZodError";
|
|
@@ -12796,7 +12796,7 @@ var ZodRealError = /* @__PURE__ */ $constructor("ZodError", initializer2, {
|
|
|
12796
12796
|
Parent: Error
|
|
12797
12797
|
});
|
|
12798
12798
|
|
|
12799
|
-
//
|
|
12799
|
+
// ../../node_modules/zod/v4/classic/parse.js
|
|
12800
12800
|
var parse2 = /* @__PURE__ */ _parse(ZodRealError);
|
|
12801
12801
|
var parseAsync2 = /* @__PURE__ */ _parseAsync(ZodRealError);
|
|
12802
12802
|
var safeParse2 = /* @__PURE__ */ _safeParse(ZodRealError);
|
|
@@ -12810,7 +12810,7 @@ var safeDecode2 = /* @__PURE__ */ _safeDecode(ZodRealError);
|
|
|
12810
12810
|
var safeEncodeAsync2 = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
|
|
12811
12811
|
var safeDecodeAsync2 = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
|
|
12812
12812
|
|
|
12813
|
-
//
|
|
12813
|
+
// ../../node_modules/zod/v4/classic/schemas.js
|
|
12814
12814
|
var _installedGroups = /* @__PURE__ */ new WeakMap();
|
|
12815
12815
|
function _installLazyMethods(inst, group, methods) {
|
|
12816
12816
|
const proto = Object.getPrototypeOf(inst);
|
|
@@ -14100,7 +14100,7 @@ function preprocess(fn, schema) {
|
|
|
14100
14100
|
});
|
|
14101
14101
|
}
|
|
14102
14102
|
|
|
14103
|
-
//
|
|
14103
|
+
// ../../node_modules/zod/v4/classic/compat.js
|
|
14104
14104
|
var ZodIssueCode = {
|
|
14105
14105
|
invalid_type: "invalid_type",
|
|
14106
14106
|
too_big: "too_big",
|
|
@@ -14126,7 +14126,7 @@ var ZodFirstPartyTypeKind;
|
|
|
14126
14126
|
/* @__PURE__ */ (function(ZodFirstPartyTypeKind2) {
|
|
14127
14127
|
})(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
|
|
14128
14128
|
|
|
14129
|
-
//
|
|
14129
|
+
// ../../node_modules/zod/v4/classic/from-json-schema.js
|
|
14130
14130
|
var z = {
|
|
14131
14131
|
...schemas_exports2,
|
|
14132
14132
|
...checks_exports2,
|
|
@@ -14606,7 +14606,7 @@ function fromJSONSchema(schema, params) {
|
|
|
14606
14606
|
return convertSchema(normalized, ctx);
|
|
14607
14607
|
}
|
|
14608
14608
|
|
|
14609
|
-
//
|
|
14609
|
+
// ../../node_modules/zod/v4/classic/coerce.js
|
|
14610
14610
|
var coerce_exports = {};
|
|
14611
14611
|
__export(coerce_exports, {
|
|
14612
14612
|
bigint: () => bigint3,
|
|
@@ -14631,11 +14631,11 @@ function date4(params) {
|
|
|
14631
14631
|
return _coercedDate(ZodDate, params);
|
|
14632
14632
|
}
|
|
14633
14633
|
|
|
14634
|
-
//
|
|
14634
|
+
// ../../node_modules/zod/v4/classic/external.js
|
|
14635
14635
|
config(en_default());
|
|
14636
14636
|
|
|
14637
14637
|
// ../schema/src/ids.ts
|
|
14638
|
-
var SPECIES_IDS = ["flow", "view", "data-model", "api-endpoint", "acceptance", "decision", "stake"];
|
|
14638
|
+
var SPECIES_IDS = ["flow", "view", "data-model", "api-endpoint", "acceptance", "decision", "stake", "option"];
|
|
14639
14639
|
var STATUS_IDS = [
|
|
14640
14640
|
"idea",
|
|
14641
14641
|
"discovery",
|
|
@@ -14646,7 +14646,7 @@ var STATUS_IDS = [
|
|
|
14646
14646
|
"archived"
|
|
14647
14647
|
];
|
|
14648
14648
|
var PLATFORM_IDS = ["web", "ios", "android"];
|
|
14649
|
-
var EDGE_TYPE_IDS = ["composes", "calls", "displays", "queries", "covers", "supersedes", "generates", "impacts", "concerns"];
|
|
14649
|
+
var EDGE_TYPE_IDS = ["composes", "calls", "displays", "queries", "covers", "supersedes", "generates", "impacts", "concerns", "addresses"];
|
|
14650
14650
|
var VALID_EDGE_SEMANTICS = {
|
|
14651
14651
|
composes: [
|
|
14652
14652
|
["flow", "view"],
|
|
@@ -14674,17 +14674,25 @@ var VALID_EDGE_SEMANTICS = {
|
|
|
14674
14674
|
["acceptance", "view"],
|
|
14675
14675
|
["acceptance", "flow"]
|
|
14676
14676
|
],
|
|
14677
|
-
// Decision edges (cycle 2
|
|
14678
|
-
//
|
|
14679
|
-
//
|
|
14680
|
-
//
|
|
14677
|
+
// Decision edges (cycle 2, widened in the stake architecture's part A).
|
|
14678
|
+
// `generates` and `impacts` stay disjoint by pair: no pair is admitted by
|
|
14679
|
+
// both. What a decision edge means now depends on its target species, not
|
|
14680
|
+
// on the edge type alone. `generates` reaches an acceptance or an option (a
|
|
14681
|
+
// decision's output); `impacts` reaches anatomy or a stake (what it acts
|
|
14682
|
+
// on). An acceptance is still *generated*, never merely impacted
|
|
14683
|
+
// (docs/superpowers/specs/2026-08-03-decisions-species-design.md §3,
|
|
14684
|
+
// docs/rfcs/stake-architecture.md § 14.0 call 2).
|
|
14681
14685
|
supersedes: [["decision", "decision"]],
|
|
14682
|
-
generates: [
|
|
14686
|
+
generates: [
|
|
14687
|
+
["decision", "acceptance"],
|
|
14688
|
+
["decision", "option"]
|
|
14689
|
+
],
|
|
14683
14690
|
impacts: [
|
|
14684
14691
|
["decision", "flow"],
|
|
14685
14692
|
["decision", "view"],
|
|
14686
14693
|
["decision", "data-model"],
|
|
14687
|
-
["decision", "api-endpoint"]
|
|
14694
|
+
["decision", "api-endpoint"],
|
|
14695
|
+
["decision", "stake"]
|
|
14688
14696
|
],
|
|
14689
14697
|
// Stake edge (docs/rfcs/stake-architecture.md § 4). A stake is anchored to
|
|
14690
14698
|
// the product's anatomy only, never to an acceptance or a decision, and
|
|
@@ -14694,6 +14702,14 @@ var VALID_EDGE_SEMANTICS = {
|
|
|
14694
14702
|
["stake", "view"],
|
|
14695
14703
|
["stake", "data-model"],
|
|
14696
14704
|
["stake", "api-endpoint"]
|
|
14705
|
+
],
|
|
14706
|
+
// Option edge (docs/rfcs/stake-architecture.md § 14.0). An option addresses a
|
|
14707
|
+
// stake; an acceptance addresses the stake it settles, or the option it
|
|
14708
|
+
// carries out.
|
|
14709
|
+
addresses: [
|
|
14710
|
+
["option", "stake"],
|
|
14711
|
+
["acceptance", "stake"],
|
|
14712
|
+
["acceptance", "option"]
|
|
14697
14713
|
]
|
|
14698
14714
|
};
|
|
14699
14715
|
var VALUE_TIER_IDS = ["functional", "emotional", "life-changing", "social-impact"];
|
|
@@ -14913,9 +14929,18 @@ function stakeFrequencyOf(node) {
|
|
|
14913
14929
|
const raw = node.metadata?.frequency;
|
|
14914
14930
|
return STAKE_FREQUENCY_IDS.includes(raw) ? raw : void 0;
|
|
14915
14931
|
}
|
|
14932
|
+
function stakeReverifyDaysOf(node) {
|
|
14933
|
+
const raw = node.metadata?.reverify_every_days;
|
|
14934
|
+
return typeof raw === "number" && Number.isFinite(raw) && raw > 0 ? raw : void 0;
|
|
14935
|
+
}
|
|
14936
|
+
function stakeVerifiedCriterionVersionOf(node) {
|
|
14937
|
+
const raw = node.metadata?.verified_criterion_version;
|
|
14938
|
+
return typeof raw === "number" && Number.isInteger(raw) && raw >= 1 ? raw : void 0;
|
|
14939
|
+
}
|
|
14916
14940
|
function stakeMetadataWith(metadata, change) {
|
|
14917
14941
|
const next = { ...metadata ?? {} };
|
|
14918
|
-
|
|
14942
|
+
const catalogBefore = stakeCatalogOf({ metadata: next });
|
|
14943
|
+
for (const key of ["stake_species", "provenance", "catalog", "felt", "matters", "frequency", "reverify_every_days", "verified_criterion_version"]) {
|
|
14919
14944
|
if (!(key in change)) continue;
|
|
14920
14945
|
const value = change[key];
|
|
14921
14946
|
if (value === void 0) delete next[key];
|
|
@@ -14927,6 +14952,11 @@ function stakeMetadataWith(metadata, change) {
|
|
|
14927
14952
|
if (species !== void 0 && catalog !== void 0 && catalog.source !== catalogSourceForStakeSpecies(species)) {
|
|
14928
14953
|
delete next.catalog;
|
|
14929
14954
|
}
|
|
14955
|
+
const fittingCatalog = stakeCatalogOf({ metadata: next });
|
|
14956
|
+
const linkMoved = catalogBefore?.source !== fittingCatalog?.source || catalogBefore?.id !== fittingCatalog?.id;
|
|
14957
|
+
if (species === void 0 || isUserFacingStakeSpecies(species) || fittingCatalog === void 0 || fittingCatalog.source !== "kritik" || linkMoved && !("verified_criterion_version" in change)) {
|
|
14958
|
+
delete next.verified_criterion_version;
|
|
14959
|
+
}
|
|
14930
14960
|
if (species !== void 0 && !isUserFacingStakeSpecies(species)) {
|
|
14931
14961
|
delete next.felt;
|
|
14932
14962
|
delete next.matters;
|
|
@@ -14955,7 +14985,7 @@ function stakeEvidenceEventIds(nodes) {
|
|
|
14955
14985
|
// ../schema/src/enums.ts
|
|
14956
14986
|
var SpeciesSchema = external_exports.enum(SPECIES_IDS).meta({
|
|
14957
14987
|
id: "Species",
|
|
14958
|
-
description: "The species of a node. flow = ordered sequence of views/sub-flows. view = reusable page or screen. data-model = data entity/table. api-endpoint = API endpoint. acceptance = a testable promise (one Given/When/Then) with per-platform status. decision = an ADR-style record (context, consequences, supersession). stake = something that matters about the product (a bug, friction, need, requirement, risk or defect), anchored to the anatomy by concerns edges."
|
|
14988
|
+
description: "The species of a node. flow = ordered sequence of views/sub-flows. view = reusable page or screen. data-model = data entity/table. api-endpoint = API endpoint. acceptance = a testable promise (one Given/When/Then) with per-platform status. decision = an ADR-style record (context, consequences, supersession). stake = something that matters about the product (a bug, friction, need, requirement, risk or defect), anchored to the anatomy by concerns edges. option = one way to address a stake, never without a stake, weighed against the other options for it."
|
|
14959
14989
|
});
|
|
14960
14990
|
var StatusSchema = external_exports.enum(STATUS_IDS).meta({
|
|
14961
14991
|
id: "Status",
|
|
@@ -14971,7 +15001,7 @@ var PlatformSchema = external_exports.enum(PLATFORM_IDS).meta({
|
|
|
14971
15001
|
});
|
|
14972
15002
|
var EdgeTypeSchema = external_exports.enum(EDGE_TYPE_IDS).meta({
|
|
14973
15003
|
id: "EdgeType",
|
|
14974
|
-
description: "composes = structural hierarchy (flow\u2194view). calls = view/flow \u2192 api-endpoint, or api-endpoint \u2192 api-endpoint (endpoint fan-out to internal/external APIs). displays = view \u2192 data-model. queries = api-endpoint \u2192 data-model. covers = acceptance \u2192 view/flow (which surface the acceptance is proven on). supersedes = decision \u2192 decision. generates = decision \u2192 acceptance. impacts = decision \u2192 flow/view/data-model/api-endpoint. concerns = stake \u2192 flow/view/data-model/api-endpoint (the part of the anatomy the stake is about)."
|
|
15004
|
+
description: "composes = structural hierarchy (flow\u2194view). calls = view/flow \u2192 api-endpoint, or api-endpoint \u2192 api-endpoint (endpoint fan-out to internal/external APIs). displays = view \u2192 data-model. queries = api-endpoint \u2192 data-model. covers = acceptance \u2192 view/flow (which surface the acceptance is proven on). supersedes = decision \u2192 decision. generates = decision \u2192 acceptance or option (what the decision produced). impacts = decision \u2192 flow/view/data-model/api-endpoint or stake (what the decision acts on). concerns = stake \u2192 flow/view/data-model/api-endpoint (the part of the anatomy the stake is about). addresses = option \u2192 stake, acceptance \u2192 stake or acceptance \u2192 option (what answers a stake)."
|
|
14975
15005
|
});
|
|
14976
15006
|
var ValueTierSchema = external_exports.enum(VALUE_TIER_IDS).meta({
|
|
14977
15007
|
id: "ValueTier",
|
|
@@ -15022,7 +15052,8 @@ var SPECIES_PREFIXES = {
|
|
|
15022
15052
|
"api-endpoint": "API-",
|
|
15023
15053
|
acceptance: "AC-",
|
|
15024
15054
|
decision: "DEC-",
|
|
15025
|
-
stake: "STK-"
|
|
15055
|
+
stake: "STK-",
|
|
15056
|
+
option: "OPT-"
|
|
15026
15057
|
};
|
|
15027
15058
|
function kebabCase(input) {
|
|
15028
15059
|
return input.normalize("NFKD").replace(/[\u0300-\u036f]/g, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
@@ -15366,6 +15397,22 @@ function crossCheckJournal(bundle) {
|
|
|
15366
15397
|
}
|
|
15367
15398
|
}
|
|
15368
15399
|
}
|
|
15400
|
+
const eventIds = /* @__PURE__ */ new Set();
|
|
15401
|
+
for (const { ev } of valid) eventIds.add(ev.id);
|
|
15402
|
+
nodesRaw.forEach((n, index) => {
|
|
15403
|
+
if (n?.species !== "option") return;
|
|
15404
|
+
const metadata = n.metadata;
|
|
15405
|
+
if (!metadata || typeof metadata !== "object" || Array.isArray(metadata)) return;
|
|
15406
|
+
const ref = str(metadata.suggested_by);
|
|
15407
|
+
if (ref !== void 0 && ref !== "" && !eventIds.has(ref)) {
|
|
15408
|
+
findings.push({
|
|
15409
|
+
path: `nodes[${index}].metadata.suggested_by`,
|
|
15410
|
+
rule: "option-suggested-by-dangling",
|
|
15411
|
+
message: `Option "${String(n.id)}": suggested_by names journal event "${ref}", which is not in the journal.`,
|
|
15412
|
+
severity: "warning"
|
|
15413
|
+
});
|
|
15414
|
+
}
|
|
15415
|
+
});
|
|
15369
15416
|
for (const { ev, index } of valid) {
|
|
15370
15417
|
const nodeFields = NODE_REF_FIELDS[ev.type];
|
|
15371
15418
|
if (nodeFields) {
|
|
@@ -15891,12 +15938,26 @@ function mergeKritikLibrary(pack, overlay) {
|
|
|
15891
15938
|
for (const criterion of asArray(overlay.criteria)) {
|
|
15892
15939
|
if (typeof criterion?.id !== "string" || criterion.id === "") continue;
|
|
15893
15940
|
const at = criteria.findIndex((existing) => existing?.id === criterion.id);
|
|
15894
|
-
if (at >= 0)
|
|
15895
|
-
|
|
15941
|
+
if (at >= 0) {
|
|
15942
|
+
const packVersion = criteria[at].version;
|
|
15943
|
+
criteria[at] = criterion.version === void 0 && packVersion !== void 0 ? { ...criterion, version: packVersion } : criterion;
|
|
15944
|
+
} else criteria.push(criterion);
|
|
15896
15945
|
}
|
|
15897
15946
|
const scales = pack.scales || overlay.scales ? { ...pack.scales ?? {}, ...overlay.scales ?? {} } : void 0;
|
|
15898
15947
|
return { ...pack, domains, criteria, ...scales ? { scales } : {} };
|
|
15899
15948
|
}
|
|
15949
|
+
function applicableCells(library, surfaces) {
|
|
15950
|
+
const selected = surfaces.filter((id) => id !== CROSS_SURFACE_ID);
|
|
15951
|
+
const cells = [];
|
|
15952
|
+
for (const criterion of asArray(library.criteria)) {
|
|
15953
|
+
if (typeof criterion?.id !== "string" || criterion.id === "") continue;
|
|
15954
|
+
if (typeof criterion.superseded_by === "string" && criterion.superseded_by !== "") continue;
|
|
15955
|
+
const appliesTo = Array.isArray(criterion.applies_to) ? criterion.applies_to : void 0;
|
|
15956
|
+
const matched = appliesTo === void 0 ? [...selected] : selected.filter((id) => appliesTo.includes(id));
|
|
15957
|
+
if (matched.length > 0) cells.push({ criterion_id: criterion.id, surfaces: matched });
|
|
15958
|
+
}
|
|
15959
|
+
return cells;
|
|
15960
|
+
}
|
|
15900
15961
|
function bucketsOf(library) {
|
|
15901
15962
|
const stored = library?.scales?.severity_buckets;
|
|
15902
15963
|
const out = { ...DEFAULT_SEVERITY_BUCKETS };
|
|
@@ -16068,6 +16129,7 @@ function deriveQualityMatrix(bundle, library) {
|
|
|
16068
16129
|
}
|
|
16069
16130
|
|
|
16070
16131
|
// ../schema/src/quality-ops.ts
|
|
16132
|
+
var DEFAULT_TARGET_LEVEL = 3;
|
|
16071
16133
|
function upsertAssessment(assessments, next) {
|
|
16072
16134
|
const index = assessments.findIndex(
|
|
16073
16135
|
(candidate) => candidate.criterion_id === next.criterion_id && candidate.surface === next.surface
|
|
@@ -16257,12 +16319,104 @@ function signalTrippedInput(trip) {
|
|
|
16257
16319
|
};
|
|
16258
16320
|
}
|
|
16259
16321
|
|
|
16322
|
+
// ../schema/src/kritik-plan-prompt.ts
|
|
16323
|
+
var THOUSANDS = /\B(?=(\d{3})+(?!\d))/g;
|
|
16324
|
+
var SKILL_STEP = 'Follow the Kritik skill (SKILL.md), section "A planned partial audit". Run it in the repository checkout: a hosted session cannot score a plan part.';
|
|
16325
|
+
var USAGE_READOUT = "this session's usage readout: model, tokens in and out, duration, number of agents.";
|
|
16326
|
+
var SIGNALS_EXIT = "It exits 1 when a signal has tripped since the last recorded audit: that is information for this audit, not an error.";
|
|
16327
|
+
var FINDING_FLAGS = '--title "<one line>" --impact <1-5> --likelihood <1-5> --cost <S|M|L|XL> --evidence "<file:line \u2026>"';
|
|
16328
|
+
function planRecordCommand(planId2) {
|
|
16329
|
+
return `arkaik kritik matrix ${planId2} --record --plan`;
|
|
16330
|
+
}
|
|
16331
|
+
function plural(count, noun) {
|
|
16332
|
+
return `${count} ${noun}${count === 1 ? "" : "s"}`;
|
|
16333
|
+
}
|
|
16334
|
+
function tokenCount(value) {
|
|
16335
|
+
return String(Math.round(value)).replace(THOUSANDS, ",");
|
|
16336
|
+
}
|
|
16337
|
+
function dollars(value) {
|
|
16338
|
+
return `$${value.toFixed(2)}`;
|
|
16339
|
+
}
|
|
16340
|
+
function where(commit) {
|
|
16341
|
+
return commit === null ? "not a git checkout" : `commit ${commit}`;
|
|
16342
|
+
}
|
|
16343
|
+
function estimateSentence(tokens2, usd, calibrated) {
|
|
16344
|
+
if (tokens2 === null) return "";
|
|
16345
|
+
const cost = usd === null ? "" : ` (${dollars(usd.low)}\u2013${dollars(usd.high)})`;
|
|
16346
|
+
return ` Estimate: ${tokenCount(tokens2.low)}\u2013${tokenCount(tokens2.high)} tokens${cost}${calibrated ? "" : ", uncalibrated"}.`;
|
|
16347
|
+
}
|
|
16348
|
+
function scopeSentence(cells, steps) {
|
|
16349
|
+
return `${plural(cells, "cell")}, ${plural(steps, "checklist step")}`;
|
|
16350
|
+
}
|
|
16351
|
+
function partSteps(part, first) {
|
|
16352
|
+
const audit = `--audit ${part.auditId}`;
|
|
16353
|
+
return [
|
|
16354
|
+
`${first}. Get the run sheet: \`arkaik kritik signals --domain ${part.domain} --surface ${part.surface}\`. ${SIGNALS_EXIT}`,
|
|
16355
|
+
`${first + 1}. Score exactly these cells and no others:`,
|
|
16356
|
+
...part.cells.map(
|
|
16357
|
+
(cell) => ` - ${cell.criterion_id} on ${cell.surface}: \`arkaik kritik score ${cell.criterion_id} ${cell.surface} <level> --evidence "<file:line \u2026>" ${audit}\``
|
|
16358
|
+
),
|
|
16359
|
+
`${first + 2}. Open every finding on this part's audit: \`arkaik kritik finding open <criterion> ${part.surface} ${FINDING_FLAGS} ${audit}\`. Give file-and-line evidence, and verify every Critical and High finding adversarially before you open it.`
|
|
16360
|
+
];
|
|
16361
|
+
}
|
|
16362
|
+
function renderPartPrompt(plan, part) {
|
|
16363
|
+
const estimate = part.estimate === null ? "" : estimateSentence(part.estimate.tokens, part.estimate.usd, part.estimate.calibrated);
|
|
16364
|
+
return [
|
|
16365
|
+
`Run part ${part.domain}:${part.surface} of Kritik plan ${plan.planId} in this repo (${where(plan.commit)}).`,
|
|
16366
|
+
`Scope: ${scopeSentence(part.cells.length, part.steps)}.${estimate}`,
|
|
16367
|
+
`Audit id for this part: ${part.auditId}`,
|
|
16368
|
+
"",
|
|
16369
|
+
`1. ${SKILL_STEP}`,
|
|
16370
|
+
...partSteps(part, 2),
|
|
16371
|
+
"5. Do not record this part. The plan is recorded once, after every part is scored, with the plan's own command.",
|
|
16372
|
+
`6. Finish by printing ${USAGE_READOUT}`
|
|
16373
|
+
].join("\n");
|
|
16374
|
+
}
|
|
16375
|
+
function renderPlanPrompt(plan) {
|
|
16376
|
+
const included = plan.parts.filter((part) => part.status === "included");
|
|
16377
|
+
const deferred = plan.parts.filter((part) => part.status === "deferred");
|
|
16378
|
+
const calibrated = included.every((part) => part.estimate?.calibrated === true);
|
|
16379
|
+
const lines = [
|
|
16380
|
+
`Run Kritik plan ${plan.planId} in this repo (${where(plan.commit)}): ${plural(included.length, "part")}, one after the other, in this session.`,
|
|
16381
|
+
`Scope: ${scopeSentence(plan.totals.cells, plan.totals.steps)}, of ${plan.totals.applicableCells} applicable cells.` + estimateSentence(plan.totals.tokens, plan.totals.usd, calibrated),
|
|
16382
|
+
"",
|
|
16383
|
+
`1. ${SKILL_STEP} Do not record a part on its own.`
|
|
16384
|
+
];
|
|
16385
|
+
let step = 2;
|
|
16386
|
+
for (const part of included) {
|
|
16387
|
+
lines.push(
|
|
16388
|
+
"",
|
|
16389
|
+
`Part ${part.domain}:${part.surface}, audit id ${part.auditId} (${scopeSentence(part.cells.length, part.steps)}):`,
|
|
16390
|
+
...partSteps(part, step)
|
|
16391
|
+
);
|
|
16392
|
+
step += 3;
|
|
16393
|
+
}
|
|
16394
|
+
lines.push(
|
|
16395
|
+
"",
|
|
16396
|
+
`${step}. Check that every part is scored: \`arkaik kritik plan --status ${plan.planId}\``,
|
|
16397
|
+
`${step + 1}. Print ${USAGE_READOUT}`,
|
|
16398
|
+
`${step + 2}. When every part is scored, run \`${plan.recordCommand}\``
|
|
16399
|
+
);
|
|
16400
|
+
if (deferred.length > 0) {
|
|
16401
|
+
lines.push(
|
|
16402
|
+
"",
|
|
16403
|
+
"Not in this run (over budget):",
|
|
16404
|
+
...deferred.map((part) => ` - ${part.domain}:${part.surface} (${part.auditId}). Do not score it.`)
|
|
16405
|
+
);
|
|
16406
|
+
}
|
|
16407
|
+
return lines.join("\n");
|
|
16408
|
+
}
|
|
16409
|
+
|
|
16260
16410
|
// ../schema/src/quality-plan.ts
|
|
16261
16411
|
var KRITIK_PLAN_SCHEMA = "arkaik.kritik.plan/1";
|
|
16412
|
+
var PLAN_PLANS_DIR = "plans";
|
|
16262
16413
|
var SCOPED_AUDIT_ID = /-scoped(-\d+)?$/;
|
|
16263
16414
|
var PLAN_ID = /^\d{4}-\d{2}-zplan-\d{4}$/;
|
|
16264
16415
|
var PLAN_PART_ID = /^\d{4}-\d{2}-zplan-\d{4}-[a-z0-9]{2,5}-.+$/;
|
|
16265
16416
|
var PLAN_ID_LENGTH = 18;
|
|
16417
|
+
function planCellKey(criterionId, surface) {
|
|
16418
|
+
return `${criterionId}::${surface}`;
|
|
16419
|
+
}
|
|
16266
16420
|
function isScopedAuditId(id) {
|
|
16267
16421
|
return typeof id === "string" && SCOPED_AUDIT_ID.test(id);
|
|
16268
16422
|
}
|
|
@@ -16278,6 +16432,77 @@ function isPartialAuditId(id) {
|
|
|
16278
16432
|
function planIdOfPartId(id) {
|
|
16279
16433
|
return isPlanPartId(id) ? id.slice(0, PLAN_ID_LENGTH) : null;
|
|
16280
16434
|
}
|
|
16435
|
+
var RUN_TOKEN = /^([A-Za-z0-9]{2,5}):([A-Za-z0-9_-]+)$/;
|
|
16436
|
+
var PLANNABLE_DOMAIN = /^[A-Z0-9]{2,5}$/;
|
|
16437
|
+
function parseRun(tokens2, vocabulary) {
|
|
16438
|
+
if (tokens2.length === 0) throw new Error("at least one --run DOMAIN:SURFACE is required");
|
|
16439
|
+
const surfaces = vocabulary.surfaces.filter((id) => id !== CROSS_SURFACE_ID);
|
|
16440
|
+
const plannable = vocabulary.domains.filter((code) => PLANNABLE_DOMAIN.test(code));
|
|
16441
|
+
const unplannable = vocabulary.domains.filter((code) => !PLANNABLE_DOMAIN.test(code));
|
|
16442
|
+
const runs = [];
|
|
16443
|
+
const warnings = [];
|
|
16444
|
+
const tokenBySuffix = /* @__PURE__ */ new Map();
|
|
16445
|
+
for (const token of tokens2) {
|
|
16446
|
+
const match = RUN_TOKEN.exec(token);
|
|
16447
|
+
if (match === null) {
|
|
16448
|
+
throw new Error(
|
|
16449
|
+
`--run "${token}" is not DOMAIN:SURFACE \u2014 a domain code of 2 to 5 letters or digits, a colon, then a surface id of letters, digits, "-" or "_" (for example SEC:web).`
|
|
16450
|
+
);
|
|
16451
|
+
}
|
|
16452
|
+
const domain2 = match[1].toUpperCase();
|
|
16453
|
+
const surface = match[2];
|
|
16454
|
+
if (!plannable.includes(domain2)) {
|
|
16455
|
+
throw new Error(
|
|
16456
|
+
`--run "${token}": ${domain2} is not a domain of this library. Domain codes: ${plannable.length > 0 ? plannable.join(", ") : "none that can be planned"}.` + (unplannable.length > 0 ? ` ${unplannable.join(", ")} cannot be planned: a domain code must be 2 to 5 upper-case letters or digits.` : "")
|
|
16457
|
+
);
|
|
16458
|
+
}
|
|
16459
|
+
if (surface === CROSS_SURFACE_ID) {
|
|
16460
|
+
throw new Error(
|
|
16461
|
+
`--run "${token}": ${CROSS_SURFACE_ID} is a lens for findings, not a surface anything is scored on. Plan the surfaces it connects instead.`
|
|
16462
|
+
);
|
|
16463
|
+
}
|
|
16464
|
+
if (!surfaces.includes(surface)) {
|
|
16465
|
+
throw new Error(
|
|
16466
|
+
`--run "${token}": "${surface}" is not a surface of this project's profile. Surfaces: ${surfaces.length > 0 ? surfaces.join(", ") : "none declared"}. A surface must match its id exactly, case included.`
|
|
16467
|
+
);
|
|
16468
|
+
}
|
|
16469
|
+
if (runs.some((run) => run.domain === domain2 && run.surface === surface)) {
|
|
16470
|
+
warnings.push(`--run ${token} repeats ${domain2}:${surface}; the two are one part.`);
|
|
16471
|
+
continue;
|
|
16472
|
+
}
|
|
16473
|
+
const suffix = `${domain2.toLowerCase()}-${surface.toLowerCase()}`;
|
|
16474
|
+
const other = tokenBySuffix.get(suffix);
|
|
16475
|
+
if (other !== void 0) {
|
|
16476
|
+
throw new Error(
|
|
16477
|
+
`--run "${other}" and --run "${token}" name surfaces that differ only by case, so both would score into the one part id "<planId>-${suffix}". Plan one of them, or give the profile's surfaces ids that differ by more than case.`
|
|
16478
|
+
);
|
|
16479
|
+
}
|
|
16480
|
+
tokenBySuffix.set(suffix, token);
|
|
16481
|
+
runs.push({ domain: domain2, surface });
|
|
16482
|
+
}
|
|
16483
|
+
return { runs, warnings };
|
|
16484
|
+
}
|
|
16485
|
+
function planCells(library, surfaces, run) {
|
|
16486
|
+
const byId = /* @__PURE__ */ new Map();
|
|
16487
|
+
for (const criterion of Array.isArray(library.criteria) ? library.criteria : []) {
|
|
16488
|
+
if (typeof criterion?.id === "string" && !byId.has(criterion.id)) byId.set(criterion.id, criterion);
|
|
16489
|
+
}
|
|
16490
|
+
const cells = [];
|
|
16491
|
+
let steps = 0;
|
|
16492
|
+
for (const entry of applicableCells(library, surfaces)) {
|
|
16493
|
+
if (!entry.surfaces.includes(run.surface)) continue;
|
|
16494
|
+
if (domainCodeOf(entry.criterion_id, library) !== run.domain) continue;
|
|
16495
|
+
cells.push({ criterion_id: entry.criterion_id, surface: run.surface });
|
|
16496
|
+
const checklist = byId.get(entry.criterion_id)?.checklist;
|
|
16497
|
+
steps += Array.isArray(checklist) ? checklist.length : 0;
|
|
16498
|
+
}
|
|
16499
|
+
return { cells, steps };
|
|
16500
|
+
}
|
|
16501
|
+
function applicableCellCount(library, surfaces) {
|
|
16502
|
+
let count = 0;
|
|
16503
|
+
for (const entry of applicableCells(library, surfaces)) count += entry.surfaces.length;
|
|
16504
|
+
return count;
|
|
16505
|
+
}
|
|
16281
16506
|
function planPartId(planId2, domain2, surface) {
|
|
16282
16507
|
const id = `${planId2}-${domain2.toLowerCase()}-${surface.toLowerCase()}`;
|
|
16283
16508
|
if (isScopedAuditId(id)) {
|
|
@@ -16287,6 +16512,22 @@ function planPartId(planId2, domain2, surface) {
|
|
|
16287
16512
|
}
|
|
16288
16513
|
return id;
|
|
16289
16514
|
}
|
|
16515
|
+
function planId(input) {
|
|
16516
|
+
const { now, known, runs } = input;
|
|
16517
|
+
if (runs.length === 0) throw new Error("a plan id needs at least one run: with none, no part is checked to sort last");
|
|
16518
|
+
const ids = known.filter((id) => typeof id === "string" && id !== "");
|
|
16519
|
+
const greatest = [...ids].sort().at(-1);
|
|
16520
|
+
const year = String(now.getFullYear()).padStart(4, "0");
|
|
16521
|
+
const month = String(now.getMonth() + 1).padStart(2, "0");
|
|
16522
|
+
const day = String(now.getDate()).padStart(2, "0");
|
|
16523
|
+
for (let n = 0; n < 100; n++) {
|
|
16524
|
+
const candidate = `${year}-${month}-zplan-${day}${String(n).padStart(2, "0")}`;
|
|
16525
|
+
if (ids.some((id) => id === candidate || id.startsWith(`${candidate}-`))) continue;
|
|
16526
|
+
if (greatest !== void 0 && !runs.every((run) => planPartId(candidate, run.domain, run.surface) > greatest)) continue;
|
|
16527
|
+
return candidate;
|
|
16528
|
+
}
|
|
16529
|
+
throw new Error(`no plan id on ${year}-${month}-${day} sorts after "${greatest}"`);
|
|
16530
|
+
}
|
|
16290
16531
|
function outsortedBy(partId, known) {
|
|
16291
16532
|
const plan = planIdOfPartId(partId);
|
|
16292
16533
|
if (plan === null) return [];
|
|
@@ -16328,69 +16569,198 @@ function readPlanScope(scope) {
|
|
|
16328
16569
|
coverage: readCoverage(row.coverage)
|
|
16329
16570
|
};
|
|
16330
16571
|
}
|
|
16331
|
-
function
|
|
16332
|
-
const
|
|
16333
|
-
const
|
|
16334
|
-
|
|
16335
|
-
|
|
16336
|
-
|
|
16337
|
-
|
|
16338
|
-
|
|
16339
|
-
}
|
|
16340
|
-
return notes;
|
|
16341
|
-
}
|
|
16342
|
-
function auditReadings(auditIds) {
|
|
16343
|
-
const readings = [];
|
|
16344
|
-
const byId = /* @__PURE__ */ new Map();
|
|
16345
|
-
const lastAt = /* @__PURE__ */ new Map();
|
|
16346
|
-
auditIds.forEach((auditId, index) => {
|
|
16347
|
-
const id = planIdOfPartId(auditId) ?? auditId;
|
|
16348
|
-
const existing = byId.get(id);
|
|
16349
|
-
if (existing !== void 0) {
|
|
16350
|
-
existing.auditIds.push(auditId);
|
|
16351
|
-
lastAt.set(existing, index);
|
|
16352
|
-
return;
|
|
16572
|
+
function buildKritikPlan(input) {
|
|
16573
|
+
const { library, surfaces, runs, known, now, commit } = input;
|
|
16574
|
+
const counted = runs.map((run) => {
|
|
16575
|
+
const { cells, steps } = planCells(library, surfaces, run);
|
|
16576
|
+
if (cells.length === 0) {
|
|
16577
|
+
throw new Error(
|
|
16578
|
+
`no ${run.domain} criterion applies to "${run.surface}" \u2014 every ${run.domain} criterion's applies_to leaves it out, so this part would score nothing.`
|
|
16579
|
+
);
|
|
16353
16580
|
}
|
|
16354
|
-
|
|
16355
|
-
byId.set(id, reading);
|
|
16356
|
-
lastAt.set(reading, index);
|
|
16357
|
-
readings.push(reading);
|
|
16581
|
+
return { run, cells, steps };
|
|
16358
16582
|
});
|
|
16359
|
-
|
|
16360
|
-
}
|
|
16361
|
-
|
|
16362
|
-
|
|
16363
|
-
|
|
16364
|
-
|
|
16365
|
-
|
|
16366
|
-
|
|
16367
|
-
|
|
16368
|
-
|
|
16369
|
-
|
|
16370
|
-
|
|
16371
|
-
|
|
16372
|
-
|
|
16373
|
-
|
|
16374
|
-
|
|
16375
|
-
|
|
16376
|
-
|
|
16377
|
-
|
|
16378
|
-
|
|
16379
|
-
|
|
16380
|
-
|
|
16381
|
-
|
|
16382
|
-
|
|
16383
|
-
|
|
16384
|
-
|
|
16385
|
-
|
|
16386
|
-
|
|
16387
|
-
|
|
16388
|
-
|
|
16389
|
-
|
|
16390
|
-
|
|
16391
|
-
|
|
16392
|
-
|
|
16393
|
-
|
|
16583
|
+
const id = planId({ now, known, runs });
|
|
16584
|
+
const parts = counted.map(({ run, cells, steps }) => ({
|
|
16585
|
+
domain: run.domain,
|
|
16586
|
+
surface: run.surface,
|
|
16587
|
+
auditId: planPartId(id, run.domain, run.surface),
|
|
16588
|
+
cells,
|
|
16589
|
+
steps,
|
|
16590
|
+
estimate: null,
|
|
16591
|
+
status: "included"
|
|
16592
|
+
}));
|
|
16593
|
+
const included = parts.filter((part) => part.status === "included");
|
|
16594
|
+
const head = {
|
|
16595
|
+
schema: KRITIK_PLAN_SCHEMA,
|
|
16596
|
+
planId: id,
|
|
16597
|
+
createdAt: now.toISOString(),
|
|
16598
|
+
commit,
|
|
16599
|
+
frameworkVersion: library.version,
|
|
16600
|
+
tier: null,
|
|
16601
|
+
budgetTokens: null,
|
|
16602
|
+
budgetUsd: null,
|
|
16603
|
+
pricePerMTok: null,
|
|
16604
|
+
totals: {
|
|
16605
|
+
cells: included.reduce((sum, part) => sum + part.cells.length, 0),
|
|
16606
|
+
steps: included.reduce((sum, part) => sum + part.steps, 0),
|
|
16607
|
+
applicableCells: applicableCellCount(library, surfaces),
|
|
16608
|
+
tokens: null,
|
|
16609
|
+
usd: null
|
|
16610
|
+
},
|
|
16611
|
+
recordCommand: planRecordCommand(id)
|
|
16612
|
+
};
|
|
16613
|
+
return {
|
|
16614
|
+
schema: head.schema,
|
|
16615
|
+
planId: head.planId,
|
|
16616
|
+
createdAt: head.createdAt,
|
|
16617
|
+
commit: head.commit,
|
|
16618
|
+
frameworkVersion: head.frameworkVersion,
|
|
16619
|
+
tier: head.tier,
|
|
16620
|
+
budgetTokens: head.budgetTokens,
|
|
16621
|
+
budgetUsd: head.budgetUsd,
|
|
16622
|
+
pricePerMTok: head.pricePerMTok,
|
|
16623
|
+
parts: parts.map((part) => ({ ...part, prompt: renderPartPrompt({ planId: id, commit }, part) })),
|
|
16624
|
+
totals: head.totals,
|
|
16625
|
+
prompt: renderPlanPrompt({ ...head, parts }),
|
|
16626
|
+
recordCommand: head.recordCommand
|
|
16627
|
+
};
|
|
16628
|
+
}
|
|
16629
|
+
function planPartStatuses(plan, scoresByPart) {
|
|
16630
|
+
return plan.parts.map((part) => {
|
|
16631
|
+
const planned = new Set(part.cells.map((cell) => planCellKey(cell.criterion_id, cell.surface)));
|
|
16632
|
+
const scoredKeys = /* @__PURE__ */ new Set();
|
|
16633
|
+
const strayKeys = /* @__PURE__ */ new Set();
|
|
16634
|
+
const stray = [];
|
|
16635
|
+
const scores = Object.prototype.hasOwnProperty.call(scoresByPart, part.auditId) ? scoresByPart[part.auditId] : [];
|
|
16636
|
+
for (const score of scores) {
|
|
16637
|
+
const key = planCellKey(score.criterion_id, score.surface);
|
|
16638
|
+
if (planned.has(key)) scoredKeys.add(key);
|
|
16639
|
+
else if (!strayKeys.has(key)) {
|
|
16640
|
+
strayKeys.add(key);
|
|
16641
|
+
stray.push({ criterion_id: score.criterion_id, surface: score.surface });
|
|
16642
|
+
}
|
|
16643
|
+
}
|
|
16644
|
+
const missing = part.cells.filter((cell) => !scoredKeys.has(planCellKey(cell.criterion_id, cell.surface)));
|
|
16645
|
+
const scored = part.cells.length - missing.length;
|
|
16646
|
+
const progress = part.status === "deferred" ? "deferred" : scored === 0 && stray.length === 0 ? "not started" : missing.length === 0 ? "scored" : "in progress";
|
|
16647
|
+
return {
|
|
16648
|
+
auditId: part.auditId,
|
|
16649
|
+
domain: part.domain,
|
|
16650
|
+
surface: part.surface,
|
|
16651
|
+
progress,
|
|
16652
|
+
scored,
|
|
16653
|
+
cells: part.cells.length,
|
|
16654
|
+
missing,
|
|
16655
|
+
stray
|
|
16656
|
+
};
|
|
16657
|
+
});
|
|
16658
|
+
}
|
|
16659
|
+
function coverageOf(section, library, scored = 0) {
|
|
16660
|
+
const assessments = Array.isArray(section.assessments) ? section.assessments : [];
|
|
16661
|
+
const listed = section.profile?.surfaces;
|
|
16662
|
+
const surfaces = [];
|
|
16663
|
+
for (const surface of Array.isArray(listed) ? listed : []) {
|
|
16664
|
+
const id = surface?.id;
|
|
16665
|
+
if (typeof id === "string" && id !== "" && id !== CROSS_SURFACE_ID && !surfaces.includes(id)) surfaces.push(id);
|
|
16666
|
+
}
|
|
16667
|
+
if (surfaces.length === 0) {
|
|
16668
|
+
for (const assessment of assessments) {
|
|
16669
|
+
const id = assessment?.surface;
|
|
16670
|
+
if (typeof id === "string" && id !== "" && id !== CROSS_SURFACE_ID && !surfaces.includes(id)) surfaces.push(id);
|
|
16671
|
+
}
|
|
16672
|
+
}
|
|
16673
|
+
const perSurface = /* @__PURE__ */ new Map();
|
|
16674
|
+
for (const surface of surfaces) perSurface.set(surface, { assessed: 0, applicable: 0 });
|
|
16675
|
+
const applicable = /* @__PURE__ */ new Set();
|
|
16676
|
+
for (const entry of applicableCells(library, surfaces)) {
|
|
16677
|
+
for (const surface of entry.surfaces) {
|
|
16678
|
+
const counts = perSurface.get(surface);
|
|
16679
|
+
if (counts === void 0) continue;
|
|
16680
|
+
applicable.add(planCellKey(entry.criterion_id, surface));
|
|
16681
|
+
counts.applicable++;
|
|
16682
|
+
}
|
|
16683
|
+
}
|
|
16684
|
+
const assessed = /* @__PURE__ */ new Set();
|
|
16685
|
+
for (const assessment of assessments) {
|
|
16686
|
+
if (typeof assessment?.criterion_id !== "string" || typeof assessment?.surface !== "string") continue;
|
|
16687
|
+
const key = planCellKey(assessment.criterion_id, assessment.surface);
|
|
16688
|
+
if (!applicable.has(key) || assessed.has(key)) continue;
|
|
16689
|
+
assessed.add(key);
|
|
16690
|
+
const counts = perSurface.get(assessment.surface);
|
|
16691
|
+
if (counts !== void 0) counts.assessed++;
|
|
16692
|
+
}
|
|
16693
|
+
const bySurface = {};
|
|
16694
|
+
for (const [surface, counts] of perSurface) {
|
|
16695
|
+
if (surface === "__proto__") continue;
|
|
16696
|
+
bySurface[surface] = counts;
|
|
16697
|
+
}
|
|
16698
|
+
return { scored, assessed: assessed.size, applicable: applicable.size, surfaces: bySurface };
|
|
16699
|
+
}
|
|
16700
|
+
function coverageNotes(coverage, overall) {
|
|
16701
|
+
const notes = [];
|
|
16702
|
+
const surfaces = coverage.surfaces ?? {};
|
|
16703
|
+
for (const surface of Object.keys(surfaces)) {
|
|
16704
|
+
const { assessed, applicable } = surfaces[surface];
|
|
16705
|
+
if (!(assessed < applicable)) continue;
|
|
16706
|
+
const score = Object.prototype.hasOwnProperty.call(overall, surface) ? overall[surface] : void 0;
|
|
16707
|
+
notes.push(`${surface} ${typeof score === "number" ? score : "\u2014"}, from ${assessed} of ${applicable} cells`);
|
|
16708
|
+
}
|
|
16709
|
+
return notes;
|
|
16710
|
+
}
|
|
16711
|
+
function auditReadings(auditIds) {
|
|
16712
|
+
const readings = [];
|
|
16713
|
+
const byId = /* @__PURE__ */ new Map();
|
|
16714
|
+
const lastAt = /* @__PURE__ */ new Map();
|
|
16715
|
+
auditIds.forEach((auditId, index) => {
|
|
16716
|
+
const id = planIdOfPartId(auditId) ?? auditId;
|
|
16717
|
+
const existing = byId.get(id);
|
|
16718
|
+
if (existing !== void 0) {
|
|
16719
|
+
existing.auditIds.push(auditId);
|
|
16720
|
+
lastAt.set(existing, index);
|
|
16721
|
+
return;
|
|
16722
|
+
}
|
|
16723
|
+
const reading = { id, auditIds: [auditId] };
|
|
16724
|
+
byId.set(id, reading);
|
|
16725
|
+
lastAt.set(reading, index);
|
|
16726
|
+
readings.push(reading);
|
|
16727
|
+
});
|
|
16728
|
+
return readings.sort((a, b) => (lastAt.get(a) ?? 0) - (lastAt.get(b) ?? 0));
|
|
16729
|
+
}
|
|
16730
|
+
function readingOf(readings, id) {
|
|
16731
|
+
return readings.find((reading) => reading.id === id) ?? readings.find((reading) => reading.auditIds.includes(id));
|
|
16732
|
+
}
|
|
16733
|
+
|
|
16734
|
+
// ../schema/src/quality-schemas.ts
|
|
16735
|
+
var GradeSchema = external_exports.enum(["A", "B", "C", "D", "E"]);
|
|
16736
|
+
var KritikScalesSchema = external_exports.object({
|
|
16737
|
+
grades: external_exports.partialRecord(GradeSchema, external_exports.number()).optional(),
|
|
16738
|
+
severity_buckets: external_exports.partialRecord(external_exports.enum(["critical", "high", "medium", "low", "info"]), external_exports.tuple([external_exports.number(), external_exports.number()])).optional(),
|
|
16739
|
+
caps: external_exports.object({ critical_open: GradeSchema.optional(), high_open: GradeSchema.optional() }).catchall(external_exports.unknown()).optional()
|
|
16740
|
+
}).catchall(external_exports.unknown()).meta({
|
|
16741
|
+
id: "KritikScales",
|
|
16742
|
+
description: "Overridable maturity/severity/grade scales carried by a criteria pack. Absent entries fall back to the framework defaults (packages/kritik-library/SPEC.md \xA7 4)."
|
|
16743
|
+
});
|
|
16744
|
+
var KritikReferenceSchema = external_exports.object({ title: external_exports.string(), anchor: external_exports.string().optional(), url: external_exports.string().optional() }).catchall(external_exports.unknown()).meta({ id: "KritikReference", description: "A stable external anchor behind a criterion (OWASP control, GDPR article, WCAG SC\u2026)." });
|
|
16745
|
+
var KritikIssueTemplateSchema = external_exports.object({
|
|
16746
|
+
title_template: external_exports.string().optional(),
|
|
16747
|
+
labels: external_exports.array(external_exports.string()).optional(),
|
|
16748
|
+
body_skeleton: external_exports.string().optional()
|
|
16749
|
+
}).catchall(external_exports.unknown()).meta({ id: "KritikIssueTemplate", description: "Per-criterion issue skeleton \u2014 what `arkaik kritik issue` prefills." });
|
|
16750
|
+
var KritikDomainSchema = external_exports.object({ code: external_exports.string(), name: external_exports.string(), description: external_exports.string().optional() }).catchall(external_exports.unknown()).meta({ id: "KritikDomain", description: "A top-level criteria category owning a roll-up row in the matrix." });
|
|
16751
|
+
var KritikCriterionSchema = external_exports.object({
|
|
16752
|
+
id: external_exports.string().meta({ description: "Stable identifier, `<DOMAIN>-NN`. A changed definition bumps `version` and keeps the id; a replacement is retired via superseded_by." }),
|
|
16753
|
+
domain: external_exports.string(),
|
|
16754
|
+
subcategory: external_exports.string().optional(),
|
|
16755
|
+
name: external_exports.string().optional(),
|
|
16756
|
+
question: external_exports.string().optional(),
|
|
16757
|
+
definition: external_exports.string().optional(),
|
|
16758
|
+
rationale: external_exports.string().optional(),
|
|
16759
|
+
applies_to: external_exports.array(external_exports.string()).optional().meta({ description: "Surface ids where the criterion is meaningful; absence means N/A." }),
|
|
16760
|
+
level_anchors: external_exports.record(external_exports.string(), external_exports.string()).optional().meta({ description: "Observable descriptions per maturity level, keyed l0\u2026l4." }),
|
|
16761
|
+
default_impact: external_exports.number().optional(),
|
|
16762
|
+
weight: external_exports.number().optional().meta({ description: "Weight in the domain roll-up (1\u20133; 3 = load-bearing). Absent means 1." }),
|
|
16763
|
+
version: external_exports.number().optional().meta({ description: "Counts changes to the definition or level anchors; the id stays. An integer from 1; absent reads as 1." }),
|
|
16394
16764
|
references: external_exports.array(KritikReferenceSchema).optional(),
|
|
16395
16765
|
checklist: external_exports.array(external_exports.string()).optional(),
|
|
16396
16766
|
signals: external_exports.array(external_exports.string()).optional().meta({ description: "Mechanically checkable monitoring hooks run between audits." }),
|
|
@@ -16550,6 +16920,13 @@ var KritikPlanSchema = external_exports.object({
|
|
|
16550
16920
|
});
|
|
16551
16921
|
});
|
|
16552
16922
|
});
|
|
16923
|
+
function parseKritikPlan(value) {
|
|
16924
|
+
const result = KritikPlanSchema.safeParse(value);
|
|
16925
|
+
if (result.success) return { ok: true, plan: result.data };
|
|
16926
|
+
const first = result.error.issues[0];
|
|
16927
|
+
const path = first === void 0 ? "" : first.path.map(String).join(".");
|
|
16928
|
+
return { ok: false, issue: `${path === "" ? "(root)" : path}: ${first?.message ?? "not a plan"}` };
|
|
16929
|
+
}
|
|
16553
16930
|
|
|
16554
16931
|
// ../schema/src/bundle.ts
|
|
16555
16932
|
var PlatformStatusMapSchema = external_exports.partialRecord(
|
|
@@ -16646,10 +17023,25 @@ var NodeMetadataSchema = external_exports.object({
|
|
|
16646
17023
|
).optional().meta({ description: "Stake nodes only: the signals behind the stake, one entry per signal. Written at qualification." }),
|
|
16647
17024
|
felt: StakeFeltSchema.optional(),
|
|
16648
17025
|
matters: StakeMattersSchema.optional(),
|
|
16649
|
-
frequency: StakeFrequencySchema.optional()
|
|
17026
|
+
frequency: StakeFrequencySchema.optional(),
|
|
17027
|
+
reverify_every_days: external_exports.number().optional().meta({
|
|
17028
|
+
description: "Stake nodes only: the verified half expires this many days after the latest check. A positive number."
|
|
17029
|
+
}),
|
|
17030
|
+
verified_criterion_version: external_exports.number().optional().meta({
|
|
17031
|
+
description: "Stake nodes only: the Kritik criterion version a requirement was last verified against. An integer from 1."
|
|
17032
|
+
}),
|
|
17033
|
+
suggested_by: external_exports.string().optional().meta({
|
|
17034
|
+
description: "Option nodes only: the id of the request.filed journal event that seeded this option."
|
|
17035
|
+
}),
|
|
17036
|
+
closed_options: external_exports.array(
|
|
17037
|
+
external_exports.object({
|
|
17038
|
+
option_id: external_exports.string().meta({ description: "The id of the option that was not chosen." }),
|
|
17039
|
+
reason: external_exports.string().meta({ description: "Why it was not chosen." })
|
|
17040
|
+
}).catchall(external_exports.unknown())
|
|
17041
|
+
).optional().meta({ description: "Decision nodes only: the options that lost, each with the reason." })
|
|
16650
17042
|
}).catchall(external_exports.unknown()).meta({ id: "NodeMetadata", description: "Optional metadata for a node." });
|
|
16651
17043
|
var NodeSchema = external_exports.object({
|
|
16652
|
-
id: external_exports.string().meta({ description: "Unique node ID. Convention: prefix with species \u2014 F- (flow), V- (view), DM- (data-model), API- (api-endpoint), AC- (acceptance), DEC- (decision), STK- (stake)." }),
|
|
17044
|
+
id: external_exports.string().meta({ description: "Unique node ID. Convention: prefix with species \u2014 F- (flow), V- (view), DM- (data-model), API- (api-endpoint), AC- (acceptance), DEC- (decision), STK- (stake), OPT- (option)." }),
|
|
16653
17045
|
project_id: external_exports.string().meta({ description: "Must match project.id." }),
|
|
16654
17046
|
species: SpeciesSchema,
|
|
16655
17047
|
title: external_exports.string().meta({ description: "Human-readable node title." }),
|
|
@@ -16765,52 +17157,346 @@ var ProjectBundleSchema = external_exports.object({
|
|
|
16765
17157
|
description: "The import/export format for an Arkaik product graph. Contains a project, its nodes (flows, views, data models, API endpoints), and edges (relationships between nodes)."
|
|
16766
17158
|
});
|
|
16767
17159
|
|
|
16768
|
-
// ../schema/src/
|
|
16769
|
-
var
|
|
16770
|
-
function
|
|
16771
|
-
|
|
16772
|
-
|
|
17160
|
+
// ../schema/src/acceptance.ts
|
|
17161
|
+
var DEFAULT_DELIVERED_STATUSES = ["live"];
|
|
17162
|
+
function resolvePlatformStatus(node, platform) {
|
|
17163
|
+
if (!node.platforms.includes(platform)) return void 0;
|
|
17164
|
+
return node.metadata?.platformStatuses?.[platform] ?? node.status;
|
|
17165
|
+
}
|
|
17166
|
+
function hasParityGap(node, deliveredStatuses = DEFAULT_DELIVERED_STATUSES) {
|
|
17167
|
+
if (node.status === "archived") return false;
|
|
17168
|
+
const resolved = node.platforms.map((platform) => resolvePlatformStatus(node, platform)).filter((status) => status !== void 0);
|
|
17169
|
+
const delivered = resolved.filter((status) => deliveredStatuses.includes(status));
|
|
17170
|
+
return delivered.length > 0 && delivered.length < resolved.length;
|
|
17171
|
+
}
|
|
17172
|
+
function acceptancesCovering(anchorId, nodes, edges) {
|
|
17173
|
+
const coveringIds = new Set(
|
|
17174
|
+
edges.filter((edge) => edge.edge_type === "covers" && edge.target_id === anchorId).map((edge) => edge.source_id)
|
|
17175
|
+
);
|
|
17176
|
+
return nodes.filter((node) => node.species === "acceptance" && coveringIds.has(node.id));
|
|
17177
|
+
}
|
|
17178
|
+
|
|
17179
|
+
// ../schema/src/option.ts
|
|
17180
|
+
var OPTION_LIFECYCLE_STATUSES = STAKE_LIFECYCLE_STATUSES;
|
|
17181
|
+
var ANSWER_TYPE_IDS = ["fix", "enhancement", "feature", "diligence", "mitigation", "resolution"];
|
|
17182
|
+
var ANSWER_TYPE_FOR_STAKE_SPECIES = {
|
|
17183
|
+
bug: "fix",
|
|
17184
|
+
friction: "enhancement",
|
|
17185
|
+
need: "feature",
|
|
17186
|
+
requirement: "diligence",
|
|
17187
|
+
risk: "mitigation",
|
|
17188
|
+
defect: "resolution"
|
|
17189
|
+
};
|
|
17190
|
+
function answerTypeForStake(stake) {
|
|
17191
|
+
const species = stakeSpeciesOf(stake);
|
|
17192
|
+
return species === void 0 ? void 0 : ANSWER_TYPE_FOR_STAKE_SPECIES[species];
|
|
17193
|
+
}
|
|
17194
|
+
function stakesAddressedBy(optionId, nodes, edges) {
|
|
17195
|
+
const byId = new Map(nodes.map((n) => [n.id, n]));
|
|
16773
17196
|
const seen = /* @__PURE__ */ new Set();
|
|
16774
|
-
const
|
|
16775
|
-
for (const
|
|
16776
|
-
if (
|
|
16777
|
-
const
|
|
16778
|
-
if (
|
|
16779
|
-
seen.add(
|
|
16780
|
-
|
|
17197
|
+
const found = [];
|
|
17198
|
+
for (const edge of edges) {
|
|
17199
|
+
if (edge.edge_type !== "addresses" || edge.source_id !== optionId || seen.has(edge.target_id)) continue;
|
|
17200
|
+
const target = byId.get(edge.target_id);
|
|
17201
|
+
if (target?.species !== "stake") continue;
|
|
17202
|
+
seen.add(edge.target_id);
|
|
17203
|
+
found.push(target);
|
|
16781
17204
|
}
|
|
16782
|
-
return
|
|
17205
|
+
return found;
|
|
16783
17206
|
}
|
|
16784
|
-
function
|
|
16785
|
-
|
|
16786
|
-
const
|
|
16787
|
-
|
|
17207
|
+
function optionsAddressing(stakeId, nodes, edges) {
|
|
17208
|
+
const byId = new Map(nodes.map((n) => [n.id, n]));
|
|
17209
|
+
const seen = /* @__PURE__ */ new Set();
|
|
17210
|
+
const found = [];
|
|
17211
|
+
for (const edge of edges) {
|
|
17212
|
+
if (edge.edge_type !== "addresses" || edge.target_id !== stakeId || seen.has(edge.source_id)) continue;
|
|
17213
|
+
const source = byId.get(edge.source_id);
|
|
17214
|
+
if (source?.species !== "option") continue;
|
|
17215
|
+
seen.add(edge.source_id);
|
|
17216
|
+
found.push(source);
|
|
17217
|
+
}
|
|
17218
|
+
return found;
|
|
16788
17219
|
}
|
|
16789
|
-
|
|
16790
|
-
|
|
16791
|
-
|
|
16792
|
-
|
|
16793
|
-
|
|
16794
|
-
|
|
17220
|
+
function answerTypesOf(optionId, nodes, edges) {
|
|
17221
|
+
const types = /* @__PURE__ */ new Set();
|
|
17222
|
+
for (const stake of stakesAddressedBy(optionId, nodes, edges)) {
|
|
17223
|
+
const type = answerTypeForStake(stake);
|
|
17224
|
+
if (type !== void 0) types.add(type);
|
|
17225
|
+
}
|
|
17226
|
+
return ANSWER_TYPE_IDS.filter((id) => types.has(id));
|
|
17227
|
+
}
|
|
17228
|
+
var SETTLING_DECISION_STATUSES = ["approved", "enacted"];
|
|
17229
|
+
function targetsOf(sourceId, edgeType, edges) {
|
|
17230
|
+
const seen = /* @__PURE__ */ new Set();
|
|
17231
|
+
const found = [];
|
|
16795
17232
|
for (const edge of edges) {
|
|
16796
|
-
if (
|
|
16797
|
-
|
|
16798
|
-
|
|
16799
|
-
const list = outgoing.get(edge.source_id) ?? [];
|
|
16800
|
-
list.push(edge.target_id);
|
|
16801
|
-
outgoing.set(edge.source_id, list);
|
|
17233
|
+
if (edge.edge_type !== edgeType || edge.source_id !== sourceId || seen.has(edge.target_id)) continue;
|
|
17234
|
+
seen.add(edge.target_id);
|
|
17235
|
+
found.push(edge.target_id);
|
|
16802
17236
|
}
|
|
16803
|
-
|
|
16804
|
-
|
|
16805
|
-
|
|
16806
|
-
|
|
16807
|
-
|
|
16808
|
-
|
|
16809
|
-
|
|
17237
|
+
return found;
|
|
17238
|
+
}
|
|
17239
|
+
function sourcesOf(targetId, edgeType, edges) {
|
|
17240
|
+
const seen = /* @__PURE__ */ new Set();
|
|
17241
|
+
const found = [];
|
|
17242
|
+
for (const edge of edges) {
|
|
17243
|
+
if (edge.edge_type !== edgeType || edge.target_id !== targetId || seen.has(edge.source_id)) continue;
|
|
17244
|
+
seen.add(edge.source_id);
|
|
17245
|
+
found.push(edge.source_id);
|
|
16810
17246
|
}
|
|
16811
|
-
|
|
16812
|
-
|
|
16813
|
-
|
|
17247
|
+
return found;
|
|
17248
|
+
}
|
|
17249
|
+
function isSettlingDecision(decision) {
|
|
17250
|
+
return SETTLING_DECISION_STATUSES.includes(decisionStatusOf(decision));
|
|
17251
|
+
}
|
|
17252
|
+
function decidedAtMs(decision) {
|
|
17253
|
+
const raw = decision.metadata?.decided_at;
|
|
17254
|
+
const ms = typeof raw === "string" ? Date.parse(raw) : Number.NaN;
|
|
17255
|
+
return Number.isFinite(ms) ? ms : Number.NEGATIVE_INFINITY;
|
|
17256
|
+
}
|
|
17257
|
+
function latestFirst(a, b) {
|
|
17258
|
+
const byDate = decidedAtMs(b) - decidedAtMs(a);
|
|
17259
|
+
if (byDate !== 0 && !Number.isNaN(byDate)) return byDate;
|
|
17260
|
+
return a.id < b.id ? 1 : a.id > b.id ? -1 : 0;
|
|
17261
|
+
}
|
|
17262
|
+
function decisionsImpacting(stakeId, nodes, edges) {
|
|
17263
|
+
const impacting = new Set(sourcesOf(stakeId, "impacts", edges));
|
|
17264
|
+
return nodes.filter((node) => node.species === "decision" && impacting.has(node.id));
|
|
17265
|
+
}
|
|
17266
|
+
function settlingDecisionsFor(stakeId, nodes, edges) {
|
|
17267
|
+
return decisionsImpacting(stakeId, nodes, edges).filter(isSettlingDecision).sort(latestFirst);
|
|
17268
|
+
}
|
|
17269
|
+
function optionsGeneratedBy(decisionId, nodes, edges) {
|
|
17270
|
+
const byId = new Map(nodes.map((n) => [n.id, n]));
|
|
17271
|
+
const found = [];
|
|
17272
|
+
for (const id of targetsOf(decisionId, "generates", edges)) {
|
|
17273
|
+
const target = byId.get(id);
|
|
17274
|
+
if (target?.species === "option") found.push(target);
|
|
17275
|
+
}
|
|
17276
|
+
return found;
|
|
17277
|
+
}
|
|
17278
|
+
function answeringOptions(decisionId, stakeId, nodes, edges) {
|
|
17279
|
+
const addressing = new Set(optionsAddressing(stakeId, nodes, edges).map((option) => option.id));
|
|
17280
|
+
return optionsGeneratedBy(decisionId, nodes, edges).filter((option) => addressing.has(option.id));
|
|
17281
|
+
}
|
|
17282
|
+
function answerFor(stakeId, nodes, edges) {
|
|
17283
|
+
const [latest, ...rest] = settlingDecisionsFor(stakeId, nodes, edges);
|
|
17284
|
+
if (latest === void 0) return void 0;
|
|
17285
|
+
const option = answeringOptions(latest.id, stakeId, nodes, edges)[0];
|
|
17286
|
+
return option === void 0 ? void 0 : { decision: latest, option, competing: rest.map((decision) => decision.id) };
|
|
17287
|
+
}
|
|
17288
|
+
function acceptancesAddressing(targetId, nodes, edges) {
|
|
17289
|
+
const byId = new Map(nodes.map((n) => [n.id, n]));
|
|
17290
|
+
const found = [];
|
|
17291
|
+
for (const id of sourcesOf(targetId, "addresses", edges)) {
|
|
17292
|
+
const source = byId.get(id);
|
|
17293
|
+
if (source?.species === "acceptance") found.push(source);
|
|
17294
|
+
}
|
|
17295
|
+
return found;
|
|
17296
|
+
}
|
|
17297
|
+
function isPromise(acceptance, nodes, edges) {
|
|
17298
|
+
if (acceptance.species !== "acceptance" || acceptance.status === "archived") return false;
|
|
17299
|
+
if (acceptance.platforms.some((platform) => resolvePlatformStatus(acceptance, platform) === "live")) return true;
|
|
17300
|
+
const settling = new Set(nodes.filter((n) => n.species === "decision" && isSettlingDecision(n)).map((n) => n.id));
|
|
17301
|
+
if (sourcesOf(acceptance.id, "generates", edges).some((id) => settling.has(id))) return true;
|
|
17302
|
+
const options = new Set(targetsOf(acceptance.id, "addresses", edges));
|
|
17303
|
+
if (options.size === 0) return false;
|
|
17304
|
+
return edges.some((edge) => edge.edge_type === "generates" && settling.has(edge.source_id) && options.has(edge.target_id));
|
|
17305
|
+
}
|
|
17306
|
+
function isCandidate(acceptance, nodes, edges) {
|
|
17307
|
+
if (acceptance.species !== "acceptance") return false;
|
|
17308
|
+
if (acceptance.status !== "idea" && acceptance.status !== "discovery") return false;
|
|
17309
|
+
return !isPromise(acceptance, nodes, edges);
|
|
17310
|
+
}
|
|
17311
|
+
function promisesOf(stakeId, nodes, edges) {
|
|
17312
|
+
const found = /* @__PURE__ */ new Map();
|
|
17313
|
+
const answer = answerFor(stakeId, nodes, edges);
|
|
17314
|
+
if (answer !== void 0) {
|
|
17315
|
+
for (const acceptance of acceptancesAddressing(answer.option.id, nodes, edges)) {
|
|
17316
|
+
if (acceptance.status !== "archived") found.set(acceptance.id, acceptance);
|
|
17317
|
+
}
|
|
17318
|
+
}
|
|
17319
|
+
for (const acceptance of acceptancesAddressing(stakeId, nodes, edges)) {
|
|
17320
|
+
if (isPromise(acceptance, nodes, edges)) found.set(acceptance.id, acceptance);
|
|
17321
|
+
}
|
|
17322
|
+
return [...found.values()];
|
|
17323
|
+
}
|
|
17324
|
+
function candidatesFor(stakeId, nodes, edges) {
|
|
17325
|
+
const found = /* @__PURE__ */ new Map();
|
|
17326
|
+
const targets = [stakeId, ...optionsAddressing(stakeId, nodes, edges).map((option) => option.id)];
|
|
17327
|
+
for (const target of targets) {
|
|
17328
|
+
for (const acceptance of acceptancesAddressing(target, nodes, edges)) {
|
|
17329
|
+
if (isCandidate(acceptance, nodes, edges)) found.set(acceptance.id, acceptance);
|
|
17330
|
+
}
|
|
17331
|
+
}
|
|
17332
|
+
return [...found.values()];
|
|
17333
|
+
}
|
|
17334
|
+
function refusedSelection(reasons) {
|
|
17335
|
+
return { action: "refused", ops: [], reasons, handToHuman: [] };
|
|
17336
|
+
}
|
|
17337
|
+
function planSelectOption(input) {
|
|
17338
|
+
const byId = new Map(input.nodes.map((n) => [n.id, n]));
|
|
17339
|
+
const stake = byId.get(input.stakeId);
|
|
17340
|
+
const option = byId.get(input.optionId);
|
|
17341
|
+
const status = input.status ?? "approved";
|
|
17342
|
+
const reason = input.reason.trim();
|
|
17343
|
+
const problems = [];
|
|
17344
|
+
if (stake === void 0) problems.push(`No node with id "${input.stakeId}".`);
|
|
17345
|
+
else if (stake.species !== "stake") problems.push(`"${input.stakeId}" is a ${stake.species}, not a stake.`);
|
|
17346
|
+
if (option === void 0) problems.push(`No node with id "${input.optionId}".`);
|
|
17347
|
+
else if (option.species !== "option") problems.push(`"${input.optionId}" is a ${option.species}, not an option.`);
|
|
17348
|
+
if (status !== "approved" && status !== "enacted") problems.push(`A decision is created at approved or enacted, not "${String(status)}".`);
|
|
17349
|
+
if (reason === "") problems.push("A decision needs a reason: say why this option was chosen.");
|
|
17350
|
+
if (problems.length > 0 || stake === void 0 || option === void 0) return refusedSelection(problems);
|
|
17351
|
+
const addressing = optionsAddressing(stake.id, input.nodes, input.edges);
|
|
17352
|
+
if (!addressing.some((candidate) => candidate.id === option.id)) {
|
|
17353
|
+
problems.push(`Option "${option.id}" does not address stake "${stake.id}": add the addresses edge first.`);
|
|
17354
|
+
}
|
|
17355
|
+
if (option.status === "archived") problems.push(`Option "${option.id}" is archived: an archived option cannot be selected.`);
|
|
17356
|
+
const settling = settlingDecisionsFor(stake.id, input.nodes, input.edges);
|
|
17357
|
+
if (settling.length > 0 && input.supersede !== true) {
|
|
17358
|
+
problems.push(
|
|
17359
|
+
`Stake "${stake.id}" already has a settling decision (${settling.map((d) => d.id).join(", ")}): pass supersede to replace it.`
|
|
17360
|
+
);
|
|
17361
|
+
}
|
|
17362
|
+
const addressingIds = new Set(addressing.map((candidate) => candidate.id));
|
|
17363
|
+
const closed = /* @__PURE__ */ new Map();
|
|
17364
|
+
for (const entry of input.closed ?? []) {
|
|
17365
|
+
if (entry.option_id === option.id) {
|
|
17366
|
+
problems.push(`"${option.id}" is the selected option and cannot also be closed.`);
|
|
17367
|
+
} else if (!addressingIds.has(entry.option_id)) {
|
|
17368
|
+
problems.push(`Closed option "${entry.option_id}" does not address stake "${stake.id}".`);
|
|
17369
|
+
} else if (!closed.has(entry.option_id)) {
|
|
17370
|
+
closed.set(entry.option_id, entry.reason.trim());
|
|
17371
|
+
}
|
|
17372
|
+
}
|
|
17373
|
+
if (problems.length > 0) return refusedSelection(problems);
|
|
17374
|
+
const handToHuman = [];
|
|
17375
|
+
const closedOptions = [];
|
|
17376
|
+
for (const [optionId, given] of closed) closedOptions.push({ option_id: optionId, reason: given });
|
|
17377
|
+
for (const other of addressing) {
|
|
17378
|
+
if (other.id === option.id || other.status === "archived" || closed.has(other.id)) continue;
|
|
17379
|
+
closedOptions.push({ option_id: other.id, reason: "" });
|
|
17380
|
+
}
|
|
17381
|
+
for (const entry of closedOptions) {
|
|
17382
|
+
if (entry.reason !== "") continue;
|
|
17383
|
+
entry.reason = `Not selected: "${option.title}" was chosen.`;
|
|
17384
|
+
handToHuman.push(`No reason was given for closing "${byId.get(entry.option_id)?.title ?? entry.option_id}" (${entry.option_id}): the default reason was recorded. Write the real one.`);
|
|
17385
|
+
}
|
|
17386
|
+
const title = input.title !== void 0 && input.title.trim() !== "" ? input.title.trim() : `Select "${option.title}" for "${stake.title}"`;
|
|
17387
|
+
const decisionId = deriveNodeId("decision", title, input.nodes.map((n) => n.id));
|
|
17388
|
+
const ops = [];
|
|
17389
|
+
const reasons = [];
|
|
17390
|
+
if (input.supersede === true) {
|
|
17391
|
+
for (const previous of settling) {
|
|
17392
|
+
const was = decisionStatusOf(previous);
|
|
17393
|
+
ops.push({
|
|
17394
|
+
op: "update_node",
|
|
17395
|
+
node_id: previous.id,
|
|
17396
|
+
patch: {
|
|
17397
|
+
status: lifecycleStatusForDecision("superseded"),
|
|
17398
|
+
metadata: { ...byId.get(previous.id)?.metadata ?? {}, decision_status: "superseded" }
|
|
17399
|
+
}
|
|
17400
|
+
});
|
|
17401
|
+
reasons.push(`Supersedes ${previous.id} (it was ${was}).`);
|
|
17402
|
+
const others = targetsOf(previous.id, "impacts", input.edges).filter((id) => id !== stake.id && byId.get(id)?.species === "stake");
|
|
17403
|
+
if (others.length > 0) {
|
|
17404
|
+
handToHuman.push(
|
|
17405
|
+
`${previous.id} also settles ${others.join(", ")}: superseding it un-settles ${others.length === 1 ? "that stake" : "those stakes"}. Decide again for ${others.length === 1 ? "it" : "them"}, or keep ${previous.id}.`
|
|
17406
|
+
);
|
|
17407
|
+
}
|
|
17408
|
+
}
|
|
17409
|
+
}
|
|
17410
|
+
ops.push({
|
|
17411
|
+
op: "create_node",
|
|
17412
|
+
node: {
|
|
17413
|
+
id: decisionId,
|
|
17414
|
+
project_id: input.projectId,
|
|
17415
|
+
title,
|
|
17416
|
+
species: "decision",
|
|
17417
|
+
status: lifecycleStatusForDecision(status),
|
|
17418
|
+
platforms: [],
|
|
17419
|
+
metadata: {
|
|
17420
|
+
decision_status: status,
|
|
17421
|
+
context: reason,
|
|
17422
|
+
...input.decidedAt !== void 0 && input.decidedAt !== "" ? { decided_at: input.decidedAt } : {},
|
|
17423
|
+
...closedOptions.length > 0 ? { closed_options: closedOptions } : {}
|
|
17424
|
+
}
|
|
17425
|
+
}
|
|
17426
|
+
});
|
|
17427
|
+
ops.push({
|
|
17428
|
+
op: "create_edge",
|
|
17429
|
+
edge: { id: edgeId(decisionId, stake.id), project_id: input.projectId, source_id: decisionId, target_id: stake.id, edge_type: "impacts" }
|
|
17430
|
+
});
|
|
17431
|
+
ops.push({
|
|
17432
|
+
op: "create_edge",
|
|
17433
|
+
edge: { id: edgeId(decisionId, option.id), project_id: input.projectId, source_id: decisionId, target_id: option.id, edge_type: "generates" }
|
|
17434
|
+
});
|
|
17435
|
+
if (input.supersede === true) {
|
|
17436
|
+
for (const previous of settling) {
|
|
17437
|
+
ops.push({
|
|
17438
|
+
op: "create_edge",
|
|
17439
|
+
edge: { id: edgeId(decisionId, previous.id), project_id: input.projectId, source_id: decisionId, target_id: previous.id, edge_type: "supersedes" }
|
|
17440
|
+
});
|
|
17441
|
+
}
|
|
17442
|
+
}
|
|
17443
|
+
return { action: "decide", ops, decision_id: decisionId, reasons, handToHuman };
|
|
17444
|
+
}
|
|
17445
|
+
|
|
17446
|
+
// ../schema/src/products.ts
|
|
17447
|
+
var PRODUCT_MEMBERSHIP_SPECIES = ["flow", "view", "acceptance"];
|
|
17448
|
+
function resolveProducts(project) {
|
|
17449
|
+
const stored = project?.metadata?.products;
|
|
17450
|
+
if (!Array.isArray(stored)) return [];
|
|
17451
|
+
const seen = /* @__PURE__ */ new Set();
|
|
17452
|
+
const products = [];
|
|
17453
|
+
for (const entry of stored) {
|
|
17454
|
+
if (typeof entry !== "object" || entry === null || Array.isArray(entry)) continue;
|
|
17455
|
+
const candidate = entry;
|
|
17456
|
+
if (typeof candidate.id !== "string" || candidate.id.trim() === "" || seen.has(candidate.id)) continue;
|
|
17457
|
+
seen.add(candidate.id);
|
|
17458
|
+
products.push(candidate);
|
|
17459
|
+
}
|
|
17460
|
+
return products;
|
|
17461
|
+
}
|
|
17462
|
+
function productOf(node) {
|
|
17463
|
+
if (!PRODUCT_MEMBERSHIP_SPECIES.includes(node.species)) return null;
|
|
17464
|
+
const product = node.metadata?.product;
|
|
17465
|
+
return typeof product === "string" ? product : null;
|
|
17466
|
+
}
|
|
17467
|
+
function effectiveNodePlatforms(node, product) {
|
|
17468
|
+
const own = Array.isArray(node.platforms) ? node.platforms : [];
|
|
17469
|
+
if (!product || !Array.isArray(product.platforms)) {
|
|
17470
|
+
return PLATFORM_IDS.filter((platform) => own.includes(platform));
|
|
17471
|
+
}
|
|
17472
|
+
const menu = new Set(product.platforms);
|
|
17473
|
+
return PLATFORM_IDS.filter((platform) => own.includes(platform) && menu.has(platform));
|
|
17474
|
+
}
|
|
17475
|
+
var SYSTEM_LAYER_SPECIES = ["api-endpoint", "data-model"];
|
|
17476
|
+
var USAGE_EDGE_TYPES = /* @__PURE__ */ new Set(["calls", "displays", "queries"]);
|
|
17477
|
+
function buildProductUsageIndex(nodes, edges) {
|
|
17478
|
+
const speciesById = /* @__PURE__ */ new Map();
|
|
17479
|
+
for (const node of nodes) speciesById.set(node.id, node.species);
|
|
17480
|
+
const outgoing = /* @__PURE__ */ new Map();
|
|
17481
|
+
for (const edge of edges) {
|
|
17482
|
+
if (!USAGE_EDGE_TYPES.has(edge.edge_type)) continue;
|
|
17483
|
+
const targetSpecies = speciesById.get(edge.target_id);
|
|
17484
|
+
if (targetSpecies === void 0 || !SYSTEM_LAYER_SPECIES.includes(targetSpecies)) continue;
|
|
17485
|
+
const list = outgoing.get(edge.source_id) ?? [];
|
|
17486
|
+
list.push(edge.target_id);
|
|
17487
|
+
outgoing.set(edge.source_id, list);
|
|
17488
|
+
}
|
|
17489
|
+
const seedsByProduct = /* @__PURE__ */ new Map();
|
|
17490
|
+
for (const node of nodes) {
|
|
17491
|
+
const product = productOf(node);
|
|
17492
|
+
if (product === null) continue;
|
|
17493
|
+
const seeds = seedsByProduct.get(product) ?? /* @__PURE__ */ new Set();
|
|
17494
|
+
for (const next of outgoing.get(node.id) ?? []) seeds.add(next);
|
|
17495
|
+
seedsByProduct.set(product, seeds);
|
|
17496
|
+
}
|
|
17497
|
+
const byNode = /* @__PURE__ */ new Map();
|
|
17498
|
+
for (const [product, seeds] of seedsByProduct) {
|
|
17499
|
+
const visited = new Set(seeds);
|
|
16814
17500
|
let frontier = [...seeds];
|
|
16815
17501
|
while (frontier.length > 0) {
|
|
16816
17502
|
const next = [];
|
|
@@ -17243,6 +17929,10 @@ var CONFIDENCE_ANCHORS = {
|
|
|
17243
17929
|
};
|
|
17244
17930
|
var SCORER_KINDS = ["human", "agent", "rule"];
|
|
17245
17931
|
var STORED_SCORER_KINDS = ["human", "agent"];
|
|
17932
|
+
function scorerRank(kind) {
|
|
17933
|
+
const index = SCORER_KINDS.indexOf(kind);
|
|
17934
|
+
return index === -1 ? 0 : SCORER_KINDS.length - index;
|
|
17935
|
+
}
|
|
17246
17936
|
var WEIGHING_PROBABILITY_FIELDS = ["p_serves", "p_costs"];
|
|
17247
17937
|
function isWeighingProbability(value) {
|
|
17248
17938
|
return typeof value === "number" && Number.isFinite(value) && value >= 0 && value <= 1;
|
|
@@ -17326,6 +18016,13 @@ function upsertWeighingAssessment(assessments, next) {
|
|
|
17326
18016
|
updated[index] = next;
|
|
17327
18017
|
return { assessments: updated, replaced };
|
|
17328
18018
|
}
|
|
18019
|
+
function sortWeighingAssessments(assessments) {
|
|
18020
|
+
return [...assessments].sort((a, b) => {
|
|
18021
|
+
const text = (x) => typeof x === "string" ? x : "\uFFFF";
|
|
18022
|
+
const by = (x, y) => text(x) < text(y) ? -1 : text(x) > text(y) ? 1 : 0;
|
|
18023
|
+
return by(a?.matrix, b?.matrix) || by(a?.subject, b?.subject) || by(a?.criterion, b?.criterion) || scorerRank(b?.scorer?.kind) - scorerRank(a?.scorer?.kind);
|
|
18024
|
+
});
|
|
18025
|
+
}
|
|
17329
18026
|
|
|
17330
18027
|
// ../schema/src/weighing-library.ts
|
|
17331
18028
|
function deepFreeze(value) {
|
|
@@ -17844,7 +18541,7 @@ function validateBundle(input) {
|
|
|
17844
18541
|
}
|
|
17845
18542
|
const platforms = node.platforms;
|
|
17846
18543
|
if (!platforms || platforms.length === 0) {
|
|
17847
|
-
if (species !== "decision" && species !== "stake") {
|
|
18544
|
+
if (species !== "decision" && species !== "stake" && species !== "option") {
|
|
17848
18545
|
error51(`${base}.platforms`, "platforms-non-empty", `Node ${nodeId}: platforms array is empty or missing`);
|
|
17849
18546
|
}
|
|
17850
18547
|
} else {
|
|
@@ -18138,7 +18835,7 @@ function validateBundle(input) {
|
|
|
18138
18835
|
const membership = typeof metadata.product === "string" ? metadata.product : void 0;
|
|
18139
18836
|
const storesMembership = species !== void 0 && PRODUCT_MEMBERSHIP_SPECIES.includes(species);
|
|
18140
18837
|
if (membership !== void 0 && !storesMembership) {
|
|
18141
|
-
const detail = species === "decision" || species === "stake" ? `${species} nodes store no product membership (they show under every product scope)` : SPECIES_IDS.includes(species) ? `${species} membership is derived from consumers and must not be stored` : "metadata.product is only meaningful on flow, view, and acceptance nodes";
|
|
18838
|
+
const detail = species === "decision" || species === "stake" || species === "option" ? `${species} nodes store no product membership (they show under every product scope)` : SPECIES_IDS.includes(species) ? `${species} membership is derived from consumers and must not be stored` : "metadata.product is only meaningful on flow, view, and acceptance nodes";
|
|
18142
18839
|
warn(`${base}.metadata.product`, "product-membership-wrong-species", `Node ${nodeId}: ${detail}`);
|
|
18143
18840
|
return;
|
|
18144
18841
|
}
|
|
@@ -18264,7 +18961,17 @@ function validateBundle(input) {
|
|
|
18264
18961
|
const base = `nodes[${index}]`;
|
|
18265
18962
|
const stakeMd = node.metadata ?? {};
|
|
18266
18963
|
if (species !== "stake") {
|
|
18267
|
-
for (const field of [
|
|
18964
|
+
for (const field of [
|
|
18965
|
+
"stake_species",
|
|
18966
|
+
"provenance",
|
|
18967
|
+
"catalog",
|
|
18968
|
+
"evidence",
|
|
18969
|
+
"felt",
|
|
18970
|
+
"matters",
|
|
18971
|
+
"frequency",
|
|
18972
|
+
"reverify_every_days",
|
|
18973
|
+
"verified_criterion_version"
|
|
18974
|
+
]) {
|
|
18268
18975
|
if (stakeMd[field] !== void 0) {
|
|
18269
18976
|
warn(
|
|
18270
18977
|
`${base}.metadata.${field}`,
|
|
@@ -18335,6 +19042,32 @@ function validateBundle(input) {
|
|
|
18335
19042
|
`Stake ${nodeId}: a bug is always felt as expected (a must-be), not ${JSON.stringify(stakeMd.felt)}`
|
|
18336
19043
|
);
|
|
18337
19044
|
}
|
|
19045
|
+
if (stakeMd.reverify_every_days !== void 0) {
|
|
19046
|
+
const days = stakeMd.reverify_every_days;
|
|
19047
|
+
if (typeof days !== "number" || !Number.isFinite(days) || days <= 0) {
|
|
19048
|
+
warn(
|
|
19049
|
+
`${base}.metadata.reverify_every_days`,
|
|
19050
|
+
"stake-reverify-invalid",
|
|
19051
|
+
`Stake ${nodeId}: reverify_every_days must be a positive number of days, not ${JSON.stringify(days)}`
|
|
19052
|
+
);
|
|
19053
|
+
}
|
|
19054
|
+
}
|
|
19055
|
+
if (stakeMd.verified_criterion_version !== void 0) {
|
|
19056
|
+
const version2 = stakeMd.verified_criterion_version;
|
|
19057
|
+
if (typeof version2 !== "number" || !Number.isInteger(version2) || version2 < 1) {
|
|
19058
|
+
warn(
|
|
19059
|
+
`${base}.metadata.verified_criterion_version`,
|
|
19060
|
+
"stake-criterion-version-invalid",
|
|
19061
|
+
`Stake ${nodeId}: verified_criterion_version must be a positive integer, not ${JSON.stringify(version2)}`
|
|
19062
|
+
);
|
|
19063
|
+
} else if (catalog?.source !== "kritik") {
|
|
19064
|
+
warn(
|
|
19065
|
+
`${base}.metadata.verified_criterion_version`,
|
|
19066
|
+
"stake-criterion-version-unlinked",
|
|
19067
|
+
`Stake ${nodeId}: verified_criterion_version names a Kritik criterion version, but the stake has no Kritik catalog link`
|
|
19068
|
+
);
|
|
19069
|
+
}
|
|
19070
|
+
}
|
|
18338
19071
|
if (!concernsSources.has(nodeId)) {
|
|
18339
19072
|
warn(
|
|
18340
19073
|
`${base}`,
|
|
@@ -18343,6 +19076,149 @@ function validateBundle(input) {
|
|
|
18343
19076
|
);
|
|
18344
19077
|
}
|
|
18345
19078
|
});
|
|
19079
|
+
{
|
|
19080
|
+
const speciesById = /* @__PURE__ */ new Map();
|
|
19081
|
+
const nodeById = /* @__PURE__ */ new Map();
|
|
19082
|
+
nodes.forEach((node) => {
|
|
19083
|
+
if (typeof node.id === "string") {
|
|
19084
|
+
speciesById.set(node.id, node.species);
|
|
19085
|
+
nodeById.set(node.id, node);
|
|
19086
|
+
}
|
|
19087
|
+
});
|
|
19088
|
+
const targetsOf2 = (edgeType, targetSpecies) => {
|
|
19089
|
+
const out = /* @__PURE__ */ new Map();
|
|
19090
|
+
for (const edge of edges) {
|
|
19091
|
+
if (edge.edge_type !== edgeType) continue;
|
|
19092
|
+
const from = edge.source_id;
|
|
19093
|
+
const to = edge.target_id;
|
|
19094
|
+
if (typeof from !== "string" || typeof to !== "string") continue;
|
|
19095
|
+
if (speciesById.get(to) !== targetSpecies) continue;
|
|
19096
|
+
const list = out.get(from) ?? [];
|
|
19097
|
+
if (!list.includes(to)) list.push(to);
|
|
19098
|
+
out.set(from, list);
|
|
19099
|
+
}
|
|
19100
|
+
return out;
|
|
19101
|
+
};
|
|
19102
|
+
const stakesAddressed = targetsOf2("addresses", "stake");
|
|
19103
|
+
const stakesImpacted = targetsOf2("impacts", "stake");
|
|
19104
|
+
const optionsGenerated = targetsOf2("generates", "option");
|
|
19105
|
+
const decisionsInForce = /* @__PURE__ */ new Map();
|
|
19106
|
+
for (const [decisionId, stakeIds] of stakesImpacted) {
|
|
19107
|
+
const decision = nodeById.get(decisionId);
|
|
19108
|
+
if (!decision || decision.species !== "decision") continue;
|
|
19109
|
+
const status = decisionStatusOf({ metadata: decision.metadata });
|
|
19110
|
+
if (status !== "approved" && status !== "enacted") continue;
|
|
19111
|
+
for (const stakeId of stakeIds) {
|
|
19112
|
+
const list = decisionsInForce.get(stakeId) ?? [];
|
|
19113
|
+
list.push(decisionId);
|
|
19114
|
+
decisionsInForce.set(stakeId, list);
|
|
19115
|
+
}
|
|
19116
|
+
}
|
|
19117
|
+
nodes.forEach((node, index) => {
|
|
19118
|
+
const nodeId = typeof node.id === "string" ? node.id : `#${index}`;
|
|
19119
|
+
const species = node.species;
|
|
19120
|
+
const base = `nodes[${index}]`;
|
|
19121
|
+
const md = node.metadata ?? {};
|
|
19122
|
+
if (species !== "option" && md.suggested_by !== void 0) {
|
|
19123
|
+
warn(
|
|
19124
|
+
`${base}.metadata.suggested_by`,
|
|
19125
|
+
"option-field-wrong-species",
|
|
19126
|
+
`suggested_by is meaningful on option nodes only; "${nodeId}" is a ${species}.`
|
|
19127
|
+
);
|
|
19128
|
+
}
|
|
19129
|
+
if (species !== "decision" && md.closed_options !== void 0) {
|
|
19130
|
+
warn(
|
|
19131
|
+
`${base}.metadata.closed_options`,
|
|
19132
|
+
"option-field-wrong-species",
|
|
19133
|
+
`closed_options is meaningful on decision nodes only; "${nodeId}" is a ${species}.`
|
|
19134
|
+
);
|
|
19135
|
+
}
|
|
19136
|
+
if (species === "option") {
|
|
19137
|
+
if (!OPTION_LIFECYCLE_STATUSES.includes(node.status)) {
|
|
19138
|
+
warn(
|
|
19139
|
+
`${base}.status`,
|
|
19140
|
+
"option-lifecycle",
|
|
19141
|
+
`Option ${nodeId}: status "${node.status}" is not stored on an option (idea, discovery or archived only; selected and closed are read from its decision)`
|
|
19142
|
+
);
|
|
19143
|
+
}
|
|
19144
|
+
const addressed = stakesAddressed.get(nodeId) ?? [];
|
|
19145
|
+
if (addressed.length === 0) {
|
|
19146
|
+
warn(
|
|
19147
|
+
`${base}`,
|
|
19148
|
+
"option-unaddressed",
|
|
19149
|
+
`Option ${nodeId}: no outgoing addresses edge to a stake \u2014 an option never exists without the stake it addresses`
|
|
19150
|
+
);
|
|
19151
|
+
}
|
|
19152
|
+
const answerTypes = /* @__PURE__ */ new Set();
|
|
19153
|
+
for (const stakeId of addressed) {
|
|
19154
|
+
const stakeSpecies = stakeSpeciesOf({ metadata: nodeById.get(stakeId)?.metadata });
|
|
19155
|
+
if (stakeSpecies !== void 0) answerTypes.add(ANSWER_TYPE_FOR_STAKE_SPECIES[stakeSpecies]);
|
|
19156
|
+
}
|
|
19157
|
+
if (answerTypes.size > 1) {
|
|
19158
|
+
warn(
|
|
19159
|
+
`${base}`,
|
|
19160
|
+
"option-mixed-answer-types",
|
|
19161
|
+
`Option ${nodeId}: addresses stakes that ask for different answers (${[...answerTypes].join(", ")}) \u2014 split it into one option per answer type`
|
|
19162
|
+
);
|
|
19163
|
+
}
|
|
19164
|
+
return;
|
|
19165
|
+
}
|
|
19166
|
+
if (species === "decision") {
|
|
19167
|
+
const impacted = stakesImpacted.get(nodeId) ?? [];
|
|
19168
|
+
const generated = optionsGenerated.get(nodeId) ?? [];
|
|
19169
|
+
if (impacted.length > 1) {
|
|
19170
|
+
warn(
|
|
19171
|
+
`${base}`,
|
|
19172
|
+
"decision-multiple-stakes",
|
|
19173
|
+
`Decision ${nodeId}: impacts ${impacted.length} stakes (${impacted.join(", ")}) \u2014 a decision settles one stake`
|
|
19174
|
+
);
|
|
19175
|
+
}
|
|
19176
|
+
if (generated.length > 1) {
|
|
19177
|
+
warn(
|
|
19178
|
+
`${base}`,
|
|
19179
|
+
"decision-multiple-options",
|
|
19180
|
+
`Decision ${nodeId}: generates ${generated.length} options (${generated.join(", ")}) \u2014 a decision selects one option; the others go in closed_options`
|
|
19181
|
+
);
|
|
19182
|
+
}
|
|
19183
|
+
if (impacted.length > 0) {
|
|
19184
|
+
for (const optionId of generated) {
|
|
19185
|
+
const addressed = stakesAddressed.get(optionId) ?? [];
|
|
19186
|
+
if (!impacted.some((stakeId) => addressed.includes(stakeId))) {
|
|
19187
|
+
warn(
|
|
19188
|
+
`${base}`,
|
|
19189
|
+
"decision-option-not-addressing",
|
|
19190
|
+
`Decision ${nodeId}: generates option ${optionId}, which does not address the stake the decision impacts (${impacted.join(", ")})`
|
|
19191
|
+
);
|
|
19192
|
+
}
|
|
19193
|
+
}
|
|
19194
|
+
}
|
|
19195
|
+
const closed = md.closed_options;
|
|
19196
|
+
if (Array.isArray(closed)) {
|
|
19197
|
+
closed.forEach((entry, i) => {
|
|
19198
|
+
const optionId = typeof entry === "object" && entry !== null ? entry.option_id : void 0;
|
|
19199
|
+
if (typeof optionId !== "string" || speciesById.get(optionId) !== "option") {
|
|
19200
|
+
warn(
|
|
19201
|
+
`${base}.metadata.closed_options[${i}].option_id`,
|
|
19202
|
+
"decision-closed-option-unknown",
|
|
19203
|
+
`Decision ${nodeId}: closed_options[${i}] names ${typeof optionId === "string" ? `"${optionId}"` : "no option id"}, which is not an option in this bundle`
|
|
19204
|
+
);
|
|
19205
|
+
}
|
|
19206
|
+
});
|
|
19207
|
+
}
|
|
19208
|
+
return;
|
|
19209
|
+
}
|
|
19210
|
+
if (species === "stake") {
|
|
19211
|
+
const inForce = decisionsInForce.get(nodeId) ?? [];
|
|
19212
|
+
if (inForce.length > 1) {
|
|
19213
|
+
warn(
|
|
19214
|
+
`${base}`,
|
|
19215
|
+
"stake-multiple-decisions",
|
|
19216
|
+
`Stake ${nodeId}: ${inForce.length} approved or enacted decisions impact it (${inForce.join(", ")}) \u2014 supersede the earlier one`
|
|
19217
|
+
);
|
|
19218
|
+
}
|
|
19219
|
+
}
|
|
19220
|
+
});
|
|
19221
|
+
}
|
|
18346
19222
|
const PLAYLIST_ENTRY_TYPES = ["view", "flow", "condition", "junction"];
|
|
18347
19223
|
const checkPlaylistShape = (entries, flowId, path, depth = 0) => {
|
|
18348
19224
|
if (depth > 50) return;
|
|
@@ -18692,25 +19568,6 @@ function validateBundle(input) {
|
|
|
18692
19568
|
return result();
|
|
18693
19569
|
}
|
|
18694
19570
|
|
|
18695
|
-
// ../schema/src/acceptance.ts
|
|
18696
|
-
var DEFAULT_DELIVERED_STATUSES = ["live"];
|
|
18697
|
-
function resolvePlatformStatus(node, platform) {
|
|
18698
|
-
if (!node.platforms.includes(platform)) return void 0;
|
|
18699
|
-
return node.metadata?.platformStatuses?.[platform] ?? node.status;
|
|
18700
|
-
}
|
|
18701
|
-
function hasParityGap(node, deliveredStatuses = DEFAULT_DELIVERED_STATUSES) {
|
|
18702
|
-
if (node.status === "archived") return false;
|
|
18703
|
-
const resolved = node.platforms.map((platform) => resolvePlatformStatus(node, platform)).filter((status) => status !== void 0);
|
|
18704
|
-
const delivered = resolved.filter((status) => deliveredStatuses.includes(status));
|
|
18705
|
-
return delivered.length > 0 && delivered.length < resolved.length;
|
|
18706
|
-
}
|
|
18707
|
-
function acceptancesCovering(anchorId, nodes, edges) {
|
|
18708
|
-
const coveringIds = new Set(
|
|
18709
|
-
edges.filter((edge) => edge.edge_type === "covers" && edge.target_id === anchorId).map((edge) => edge.source_id)
|
|
18710
|
-
);
|
|
18711
|
-
return nodes.filter((node) => node.species === "acceptance" && coveringIds.has(node.id));
|
|
18712
|
-
}
|
|
18713
|
-
|
|
18714
19571
|
// ../schema/src/serialize.ts
|
|
18715
19572
|
var BUNDLE_KEY_ORDER = ["schema_version", "project", "nodes", "edges", "journal"];
|
|
18716
19573
|
var PROJECT_KEY_ORDER = [
|
|
@@ -18965,7 +19822,7 @@ function computeDeliverables(events) {
|
|
|
18965
19822
|
return null;
|
|
18966
19823
|
};
|
|
18967
19824
|
const out = [];
|
|
18968
|
-
for (const [id,
|
|
19825
|
+
for (const [id, anchorIndex2] of firstIndex) {
|
|
18969
19826
|
const ev = latest.get(id);
|
|
18970
19827
|
if (ev === void 0) continue;
|
|
18971
19828
|
const summary = asString(ev.summary);
|
|
@@ -18978,8 +19835,8 @@ function computeDeliverables(events) {
|
|
|
18978
19835
|
...url2 !== void 0 ? { url: url2 } : {},
|
|
18979
19836
|
node_ids: Array.isArray(ev.node_ids) ? ev.node_ids.filter((n) => typeof n === "string") : [],
|
|
18980
19837
|
...platform !== void 0 ? { platform } : {},
|
|
18981
|
-
ts: asString(ordered[
|
|
18982
|
-
releaseVersion: releaseOf(
|
|
19838
|
+
ts: asString(ordered[anchorIndex2].ts) ?? "",
|
|
19839
|
+
releaseVersion: releaseOf(anchorIndex2)
|
|
18983
19840
|
});
|
|
18984
19841
|
}
|
|
18985
19842
|
return out;
|
|
@@ -19739,6 +20596,13 @@ function namesPlan(ordered, id) {
|
|
|
19739
20596
|
return reading !== null && (reading.plan === id || reading.parts.includes(id));
|
|
19740
20597
|
});
|
|
19741
20598
|
}
|
|
20599
|
+
function scopeAnchorId(events) {
|
|
20600
|
+
const ordered = orderedRows(events);
|
|
20601
|
+
const at = anchorIndex(ordered, void 0);
|
|
20602
|
+
if (at === -1) return null;
|
|
20603
|
+
const id = ordered[at].audit_id;
|
|
20604
|
+
return isString(id) ? id : null;
|
|
20605
|
+
}
|
|
19742
20606
|
function deriveAuditScope(events, section, library, options = {}) {
|
|
19743
20607
|
const ordered = orderedRows(events);
|
|
19744
20608
|
const sinceIndex = anchorIndex(ordered, options.since);
|
|
@@ -19912,6 +20776,57 @@ function deriveAuditScope(events, section, library, options = {}) {
|
|
|
19912
20776
|
);
|
|
19913
20777
|
return { since, since_ts: sinceTs, cells: sorted, findings: drivers, resolved_by: resolvedBy, unknown: unknown2, unscorable, widened };
|
|
19914
20778
|
}
|
|
20779
|
+
function scopedAuditId(input) {
|
|
20780
|
+
const { since, month, requested, known, recorded, open } = input;
|
|
20781
|
+
const newest = [...known].sort().at(-1);
|
|
20782
|
+
if (requested !== void 0) {
|
|
20783
|
+
if (requested === since) {
|
|
20784
|
+
throw new Error(
|
|
20785
|
+
`"${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.`
|
|
20786
|
+
);
|
|
20787
|
+
}
|
|
20788
|
+
if (recorded.includes(requested)) {
|
|
20789
|
+
throw new Error(`"${requested}" is already recorded \u2014 its reading is history. Name a new audit.`);
|
|
20790
|
+
}
|
|
20791
|
+
if (isPlanId(requested) || isPlanPartId(requested)) {
|
|
20792
|
+
throw new Error(
|
|
20793
|
+
`"${requested}" is reserved for plans and their parts \u2014 a plan id (YYYY-MM-zplan-DDNN) names a plan, and <planId>-<domain>-<surface> one of its parts, so an audit under that id could never be recorded or read as one. Name a scoped re-audit (e.g. \`${suggestedAuditId({ ...input, requested: void 0 })}\`).`
|
|
20794
|
+
);
|
|
20795
|
+
}
|
|
20796
|
+
if (newest !== void 0 && requested < newest) {
|
|
20797
|
+
throw new Error(
|
|
20798
|
+
`"${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)}\`).`
|
|
20799
|
+
);
|
|
20800
|
+
}
|
|
20801
|
+
return requested;
|
|
20802
|
+
}
|
|
20803
|
+
if (open !== void 0 && (newest === void 0 || open >= newest)) return open;
|
|
20804
|
+
for (const candidate of scopedCandidates(month, known)) {
|
|
20805
|
+
if (known.includes(candidate)) continue;
|
|
20806
|
+
if (newest !== void 0 && candidate < newest) {
|
|
20807
|
+
throw new Error(
|
|
20808
|
+
`"${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)}\`).`
|
|
20809
|
+
);
|
|
20810
|
+
}
|
|
20811
|
+
return candidate;
|
|
20812
|
+
}
|
|
20813
|
+
throw new Error(`99 scoped audits in ${month} \u2014 name the next one yourself.`);
|
|
20814
|
+
}
|
|
20815
|
+
function* scopedCandidates(month, known) {
|
|
20816
|
+
const newest = [...known].sort().at(-1) ?? "";
|
|
20817
|
+
const stem = newest.replace(/-scoped(-\d+)?$/, "");
|
|
20818
|
+
const base = `${month}-scoped` < newest && isPlanPartId(stem) ? stem : month;
|
|
20819
|
+
for (let n = 1; n < 100; n++) yield n === 1 ? `${base}-scoped` : `${base}-scoped-${String(n).padStart(2, "0")}`;
|
|
20820
|
+
}
|
|
20821
|
+
function suggestedAuditId({ since, month, requested, known, recorded }) {
|
|
20822
|
+
const taken = /* @__PURE__ */ new Set([...known, ...recorded, since, ...requested !== void 0 ? [requested] : []]);
|
|
20823
|
+
const floor = [...taken].sort().at(-1);
|
|
20824
|
+
for (const candidate of scopedCandidates(month, known)) {
|
|
20825
|
+
if (taken.has(candidate)) continue;
|
|
20826
|
+
if (floor === void 0 || candidate > floor) return candidate;
|
|
20827
|
+
}
|
|
20828
|
+
return `${floor}-scoped`;
|
|
20829
|
+
}
|
|
19915
20830
|
function scopeSummary(scope) {
|
|
19916
20831
|
const direct = scope.cells.length - scope.widened;
|
|
19917
20832
|
const cells = `${scope.cells.length} cell${scope.cells.length === 1 ? "" : "s"} to re-score`;
|
|
@@ -20948,1227 +21863,525 @@ function referenceForStakeSpecies(species) {
|
|
|
20948
21863
|
const set2 = BUILT_IN_SETS.find((candidate) => stakeSpeciesDeclaredBy(candidate).includes(species));
|
|
20949
21864
|
return set2 === void 0 ? { kind: "kritik" } : { kind: "weighing-set", set: `${set2.id}@${majorOf(set2.version)}` };
|
|
20950
21865
|
}
|
|
21866
|
+
function kritikCriterionVersion(criterionId, library) {
|
|
21867
|
+
const criterion = Array.isArray(library?.criteria) ? library.criteria.find((candidate) => candidate?.id === criterionId) : void 0;
|
|
21868
|
+
if (criterion === void 0) return void 0;
|
|
21869
|
+
const version2 = criterion.version;
|
|
21870
|
+
return typeof version2 === "number" && Number.isInteger(version2) && version2 >= 1 ? version2 : 1;
|
|
21871
|
+
}
|
|
20951
21872
|
|
|
20952
|
-
//
|
|
20953
|
-
|
|
20954
|
-
|
|
20955
|
-
|
|
20956
|
-
|
|
20957
|
-
|
|
20958
|
-
|
|
20959
|
-
|
|
20960
|
-
|
|
20961
|
-
|
|
20962
|
-
|
|
20963
|
-
|
|
20964
|
-
|
|
20965
|
-
|
|
20966
|
-
|
|
20967
|
-
|
|
20968
|
-
|
|
20969
|
-
|
|
20970
|
-
|
|
20971
|
-
|
|
20972
|
-
|
|
20973
|
-
function
|
|
20974
|
-
|
|
20975
|
-
|
|
20976
|
-
|
|
20977
|
-
|
|
20978
|
-
|
|
20979
|
-
|
|
20980
|
-
|
|
20981
|
-
|
|
21873
|
+
// ../schema/src/stake-proof.ts
|
|
21874
|
+
var PROOF_EVENT_TYPES = [
|
|
21875
|
+
"node.created",
|
|
21876
|
+
"node.status_changed",
|
|
21877
|
+
"decision.status_changed",
|
|
21878
|
+
"quality.finding.opened",
|
|
21879
|
+
"quality.finding.resolved",
|
|
21880
|
+
"quality.finding.accepted",
|
|
21881
|
+
"quality.assessment.scored"
|
|
21882
|
+
];
|
|
21883
|
+
var STAKE_STATES = ["raised", "considered", "promised", "verified-not-delivered", "partly-addressed", "addressed"];
|
|
21884
|
+
var DAY_MS = 864e5;
|
|
21885
|
+
var VERIFIED_STATUSES = ["releasing", "live"];
|
|
21886
|
+
var DELIVERED_STATUSES = ["live"];
|
|
21887
|
+
var isRecord7 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
21888
|
+
var asString2 = (value) => typeof value === "string" && value !== "" ? value : void 0;
|
|
21889
|
+
function timeMs(value) {
|
|
21890
|
+
if (typeof value !== "string") return void 0;
|
|
21891
|
+
const ms = Date.parse(value);
|
|
21892
|
+
return Number.isFinite(ms) ? ms : void 0;
|
|
21893
|
+
}
|
|
21894
|
+
function nowMsOf(now) {
|
|
21895
|
+
if (now instanceof Date) return Number.isFinite(now.getTime()) ? now.getTime() : void 0;
|
|
21896
|
+
if (typeof now === "number") return Number.isFinite(now) ? now : void 0;
|
|
21897
|
+
return timeMs(now);
|
|
21898
|
+
}
|
|
21899
|
+
var isoOf2 = (ms) => new Date(ms).toISOString();
|
|
21900
|
+
function proofEventsOf(events) {
|
|
21901
|
+
if (!Array.isArray(events)) return [];
|
|
21902
|
+
const kept = events.filter((event) => isRecord7(event) && PROOF_EVENT_TYPES.includes(event.type));
|
|
21903
|
+
return orderEvents(kept);
|
|
21904
|
+
}
|
|
21905
|
+
function sanitizeNode(raw) {
|
|
21906
|
+
if (!isRecord7(raw) || typeof raw.id !== "string") return void 0;
|
|
21907
|
+
const node = raw;
|
|
21908
|
+
const metadata = isRecord7(node.metadata) ? node.metadata : void 0;
|
|
21909
|
+
if (Array.isArray(node.platforms) && metadata === node.metadata) return node;
|
|
21910
|
+
return { ...node, platforms: Array.isArray(node.platforms) ? node.platforms : [], metadata };
|
|
21911
|
+
}
|
|
21912
|
+
var sanitizeEdge = (raw) => isRecord7(raw) && typeof raw.source_id === "string" && typeof raw.target_id === "string" && typeof raw.edge_type === "string";
|
|
21913
|
+
function deliveryFor(species) {
|
|
21914
|
+
if (species === "requirement" || species === "defect") return "optional";
|
|
21915
|
+
if (species === "risk") return "not-required";
|
|
21916
|
+
return "required";
|
|
21917
|
+
}
|
|
21918
|
+
function statusChecksByNode(events) {
|
|
21919
|
+
const checks = /* @__PURE__ */ new Map();
|
|
21920
|
+
for (const event of events) {
|
|
21921
|
+
if (event.type !== "node.status_changed") continue;
|
|
21922
|
+
const nodeId = asString2(event.node_id);
|
|
21923
|
+
const to = typeof event.to === "string" ? normalizeStatus(event.to) : void 0;
|
|
21924
|
+
const ms = timeMs(event.ts);
|
|
21925
|
+
if (nodeId === void 0 || to === void 0 || ms === void 0 || !VERIFIED_STATUSES.includes(to)) continue;
|
|
21926
|
+
const named = event.platform;
|
|
21927
|
+
const platform = typeof named === "string" && PLATFORM_IDS.includes(named) ? named : void 0;
|
|
21928
|
+
if (named !== void 0 && platform === void 0) continue;
|
|
21929
|
+
const list = checks.get(nodeId) ?? [];
|
|
21930
|
+
list.push({ ms, platform });
|
|
21931
|
+
checks.set(nodeId, list);
|
|
21932
|
+
}
|
|
21933
|
+
return checks;
|
|
21934
|
+
}
|
|
21935
|
+
function findingFacts(criterionId, section, events) {
|
|
21936
|
+
const stored = /* @__PURE__ */ new Map();
|
|
21937
|
+
const storedFindings = isRecord7(section) && Array.isArray(section.findings) ? section.findings : [];
|
|
21938
|
+
for (const finding of storedFindings) {
|
|
21939
|
+
if (isRecord7(finding) && typeof finding.id === "string") stored.set(finding.id, finding);
|
|
21940
|
+
}
|
|
21941
|
+
const replay = /* @__PURE__ */ new Map();
|
|
21942
|
+
const nodeIdsOf2 = (raw) => Array.isArray(raw) ? raw.filter((id) => typeof id === "string") : [];
|
|
21943
|
+
for (const event of events) {
|
|
21944
|
+
const findingId = asString2(event.finding_id);
|
|
21945
|
+
if (findingId === void 0) continue;
|
|
21946
|
+
if (event.type === "quality.finding.opened") {
|
|
21947
|
+
const row = replay.get(findingId) ?? { nodeIds: [], open: true, closedMs: void 0 };
|
|
21948
|
+
row.criterion = asString2(event.criterion_id) ?? row.criterion;
|
|
21949
|
+
row.nodeIds = nodeIdsOf2(event.node_ids).length > 0 ? nodeIdsOf2(event.node_ids) : row.nodeIds;
|
|
21950
|
+
row.open = true;
|
|
21951
|
+
row.closedMs = void 0;
|
|
21952
|
+
replay.set(findingId, row);
|
|
21953
|
+
} else if (event.type === "quality.finding.resolved" || event.type === "quality.finding.accepted") {
|
|
21954
|
+
const row = replay.get(findingId) ?? { nodeIds: [], open: false, closedMs: void 0 };
|
|
21955
|
+
row.open = false;
|
|
21956
|
+
row.closedMs = timeMs(event.ts);
|
|
21957
|
+
if (row.nodeIds.length === 0) row.nodeIds = nodeIdsOf2(event.node_ids);
|
|
21958
|
+
replay.set(findingId, row);
|
|
21959
|
+
}
|
|
21960
|
+
}
|
|
21961
|
+
const facts = [];
|
|
21962
|
+
for (const id of /* @__PURE__ */ new Set([...stored.keys(), ...replay.keys()])) {
|
|
21963
|
+
const row = stored.get(id);
|
|
21964
|
+
const replayed = replay.get(id);
|
|
21965
|
+
const criterion = row !== void 0 ? asString2(row.criterion_id) : replayed?.criterion;
|
|
21966
|
+
if (criterion !== criterionId) continue;
|
|
21967
|
+
const storedNodeIds = row !== void 0 ? nodeIdsOf2(row.node_ids) : [];
|
|
21968
|
+
facts.push({
|
|
21969
|
+
open: row !== void 0 ? isOpenFinding(row) : replayed?.open ?? false,
|
|
21970
|
+
nodeIds: storedNodeIds.length > 0 ? storedNodeIds : replayed?.nodeIds ?? [],
|
|
21971
|
+
closedMs: replayed?.closedMs
|
|
21972
|
+
});
|
|
20982
21973
|
}
|
|
20983
|
-
return
|
|
21974
|
+
return facts;
|
|
20984
21975
|
}
|
|
20985
|
-
function
|
|
20986
|
-
const
|
|
20987
|
-
const
|
|
20988
|
-
|
|
20989
|
-
|
|
20990
|
-
|
|
20991
|
-
if (
|
|
20992
|
-
|
|
20993
|
-
}
|
|
20994
|
-
}
|
|
20995
|
-
return out;
|
|
20996
|
-
}
|
|
20997
|
-
function bandsOf2(library) {
|
|
20998
|
-
const stored = library?.scales?.grades;
|
|
20999
|
-
const out = { ...DEFAULT_GRADE_BANDS2 };
|
|
21000
|
-
if (!stored || typeof stored !== "object") return out;
|
|
21001
|
-
for (const grade of QUALITY_GRADES2) {
|
|
21002
|
-
const min = stored[grade];
|
|
21003
|
-
if (typeof min === "number" && Number.isFinite(min)) out[grade] = min;
|
|
21004
|
-
}
|
|
21005
|
-
return out;
|
|
21006
|
-
}
|
|
21007
|
-
function capsOf2(library) {
|
|
21008
|
-
const stored = library?.scales?.caps;
|
|
21009
|
-
const pick2 = (value, fallback) => typeof value === "string" && QUALITY_GRADES2.includes(value) ? value : fallback;
|
|
21010
|
-
return {
|
|
21011
|
-
critical_open: pick2(stored?.critical_open, DEFAULT_CAPS2.critical_open),
|
|
21012
|
-
high_open: pick2(stored?.high_open, DEFAULT_CAPS2.high_open)
|
|
21976
|
+
function scoresOf(criterionId, section, events) {
|
|
21977
|
+
const scores = [];
|
|
21978
|
+
const add = (row, ts) => {
|
|
21979
|
+
const ms = timeMs(ts);
|
|
21980
|
+
const level = row.level;
|
|
21981
|
+
if (asString2(row.criterion_id) !== criterionId || ms === void 0) return;
|
|
21982
|
+
if (typeof level !== "number" || !Number.isInteger(level) || level < 0 || level > 4) return;
|
|
21983
|
+
scores.push({ surface: typeof row.surface === "string" ? row.surface : "", level, ms });
|
|
21013
21984
|
};
|
|
21985
|
+
const assessments = isRecord7(section) && Array.isArray(section.assessments) ? section.assessments : [];
|
|
21986
|
+
for (const row of assessments) if (isRecord7(row)) add(row, row.ts);
|
|
21987
|
+
for (const event of events) if (event.type === "quality.assessment.scored") add(event, event.ts);
|
|
21988
|
+
return scores;
|
|
21014
21989
|
}
|
|
21015
|
-
function
|
|
21016
|
-
const
|
|
21017
|
-
|
|
21018
|
-
const
|
|
21019
|
-
|
|
21020
|
-
const worstFirst = [...FINDING_SEVERITIES2].sort((a, b) => buckets[b][0] - buckets[a][0]);
|
|
21021
|
-
for (const severity of worstFirst) {
|
|
21022
|
-
if (score >= buckets[severity][0]) return severity;
|
|
21023
|
-
}
|
|
21024
|
-
return "info";
|
|
21990
|
+
function raisedMsOf(stake, events) {
|
|
21991
|
+
const created = events.filter((event) => event.type === "node.created" && event.node_id === stake.id).map((event) => timeMs(event.ts)).filter((ms) => ms !== void 0);
|
|
21992
|
+
if (created.length > 0) return Math.min(...created);
|
|
21993
|
+
const dated = stakeEvidenceOf(stake).map((entry) => timeMs(entry.date)).filter((ms) => ms !== void 0);
|
|
21994
|
+
return dated.length > 0 ? Math.min(...dated) : void 0;
|
|
21025
21995
|
}
|
|
21026
|
-
function
|
|
21027
|
-
const
|
|
21028
|
-
const
|
|
21029
|
-
|
|
21030
|
-
|
|
21996
|
+
function kritikReading(stake, criterionId, anchors, quality, events) {
|
|
21997
|
+
const reasons = [];
|
|
21998
|
+
const atAnchor = (nodeIds) => anchors.length === 0 || nodeIds.some((id) => anchors.includes(id));
|
|
21999
|
+
const facts = findingFacts(criterionId, quality, events).filter((fact) => atAnchor(fact.nodeIds));
|
|
22000
|
+
const blocking = facts.filter((fact) => fact.open).length;
|
|
22001
|
+
if (blocking > 0) reasons.push(`${blocking} open ${criterionId} finding${blocking === 1 ? "" : "s"} at the stake's anchor.`);
|
|
22002
|
+
const raisedMs = raisedMsOf(stake, events);
|
|
22003
|
+
const counted = scoresOf(criterionId, quality, events).filter((score) => raisedMs === void 0 || score.ms > raisedMs);
|
|
22004
|
+
const latest = /* @__PURE__ */ new Map();
|
|
22005
|
+
for (const score of counted) {
|
|
22006
|
+
const current = latest.get(score.surface);
|
|
22007
|
+
if (current === void 0 || score.ms > current.ms || score.ms === current.ms && score.level < current.level) latest.set(score.surface, score);
|
|
21031
22008
|
}
|
|
21032
|
-
|
|
21033
|
-
|
|
21034
|
-
|
|
21035
|
-
|
|
21036
|
-
|
|
21037
|
-
|
|
21038
|
-
|
|
21039
|
-
}
|
|
21040
|
-
|
|
21041
|
-
let weighted = 0;
|
|
21042
|
-
let total = 0;
|
|
21043
|
-
for (const domain2 of Object.keys(scores)) {
|
|
21044
|
-
const score = scores[domain2];
|
|
21045
|
-
if (typeof score !== "number" || !Number.isFinite(score)) continue;
|
|
21046
|
-
const weight = typeof weights?.[domain2] === "number" ? weights[domain2] : 1;
|
|
21047
|
-
weighted += score * weight;
|
|
21048
|
-
total += weight;
|
|
22009
|
+
let scoresPass = latest.size > 0;
|
|
22010
|
+
if (latest.size === 0) {
|
|
22011
|
+
reasons.push(`No ${criterionId} score dated after the stake was raised.`);
|
|
22012
|
+
} else {
|
|
22013
|
+
const below = [...latest.entries()].filter(([, score]) => score.level < DEFAULT_TARGET_LEVEL);
|
|
22014
|
+
if (below.length > 0) {
|
|
22015
|
+
scoresPass = false;
|
|
22016
|
+
reasons.push(`${criterionId} is below level ${DEFAULT_TARGET_LEVEL} on ${below.map(([surface]) => surface || "a surface").join(", ")}.`);
|
|
22017
|
+
}
|
|
21049
22018
|
}
|
|
21050
|
-
|
|
22019
|
+
const checks = [...counted.map((score) => score.ms), ...facts.filter((fact) => !fact.open && fact.closedMs !== void 0).map((fact) => fact.closedMs)];
|
|
22020
|
+
return { holds: blocking === 0 && scoresPass, checkedMs: checks.length > 0 ? Math.max(...checks) : void 0, reasons };
|
|
21051
22021
|
}
|
|
21052
|
-
function
|
|
21053
|
-
const
|
|
21054
|
-
|
|
21055
|
-
|
|
21056
|
-
const
|
|
21057
|
-
|
|
21058
|
-
|
|
21059
|
-
|
|
21060
|
-
|
|
21061
|
-
|
|
21062
|
-
|
|
21063
|
-
|
|
21064
|
-
|
|
22022
|
+
function prepare(input) {
|
|
22023
|
+
const nodes = (Array.isArray(input.nodes) ? input.nodes : []).map(sanitizeNode).filter((node) => node !== void 0);
|
|
22024
|
+
const edges = (Array.isArray(input.edges) ? input.edges : []).filter(sanitizeEdge);
|
|
22025
|
+
const events = proofEventsOf(input.events);
|
|
22026
|
+
const products = resolveProducts(input.project);
|
|
22027
|
+
const scopeId = typeof input.productId === "string" ? input.productId : null;
|
|
22028
|
+
return {
|
|
22029
|
+
nodes,
|
|
22030
|
+
edges,
|
|
22031
|
+
events,
|
|
22032
|
+
statusChecks: statusChecksByNode(events),
|
|
22033
|
+
products,
|
|
22034
|
+
scopeProduct: scopeId === null ? null : products.find((product) => product.id === scopeId) ?? null,
|
|
22035
|
+
nowMs: nowMsOf(input.now),
|
|
22036
|
+
input
|
|
22037
|
+
};
|
|
22038
|
+
}
|
|
22039
|
+
function platformsOf(acceptance, prepared) {
|
|
22040
|
+
const ownId = productOf(acceptance);
|
|
22041
|
+
const own = ownId === null ? null : prepared.products.find((product) => product.id === ownId) ?? null;
|
|
22042
|
+
return effectiveNodePlatforms(acceptance, own ?? prepared.scopeProduct);
|
|
22043
|
+
}
|
|
22044
|
+
function reads(acceptance, platform, statuses) {
|
|
22045
|
+
if (acceptance.status === "archived") return false;
|
|
22046
|
+
const status = platform === null ? acceptance.status : resolvePlatformStatus(acceptance, platform);
|
|
22047
|
+
return status !== void 0 && statuses.includes(status);
|
|
22048
|
+
}
|
|
22049
|
+
function latestCheckMs(acceptance, platform, prepared) {
|
|
22050
|
+
const hasOwnEntry = platform !== null && isRecord7(acceptance.metadata?.platformStatuses) && acceptance.metadata?.platformStatuses?.[platform] !== void 0;
|
|
22051
|
+
let latest;
|
|
22052
|
+
for (const check2 of prepared.statusChecks.get(acceptance.id) ?? []) {
|
|
22053
|
+
const applies = platform === null || check2.platform === platform || check2.platform === void 0 && !hasOwnEntry;
|
|
22054
|
+
if (applies && (latest === void 0 || check2.ms > latest)) latest = check2.ms;
|
|
22055
|
+
}
|
|
22056
|
+
return latest;
|
|
22057
|
+
}
|
|
22058
|
+
function lapsed(days, checkedMs, nowMs) {
|
|
22059
|
+
if (days === void 0 || nowMs === void 0) return false;
|
|
22060
|
+
return checkedMs === void 0 || nowMs - checkedMs > days * DAY_MS;
|
|
22061
|
+
}
|
|
22062
|
+
function deliveredEverywhere(acceptances, prepared) {
|
|
22063
|
+
if (acceptances.length === 0) return false;
|
|
22064
|
+
return acceptances.every((acceptance) => {
|
|
22065
|
+
const platforms = platformsOf(acceptance, prepared);
|
|
22066
|
+
return platforms.length === 0 ? reads(acceptance, null, DELIVERED_STATUSES) : platforms.every((platform) => reads(acceptance, platform, DELIVERED_STATUSES));
|
|
22067
|
+
});
|
|
21065
22068
|
}
|
|
21066
|
-
function
|
|
21067
|
-
const
|
|
21068
|
-
const
|
|
21069
|
-
const
|
|
21070
|
-
const
|
|
21071
|
-
const
|
|
21072
|
-
const
|
|
21073
|
-
const
|
|
21074
|
-
const
|
|
21075
|
-
const
|
|
21076
|
-
const
|
|
21077
|
-
|
|
21078
|
-
|
|
21079
|
-
|
|
21080
|
-
|
|
21081
|
-
|
|
21082
|
-
const
|
|
21083
|
-
const
|
|
21084
|
-
const
|
|
21085
|
-
|
|
21086
|
-
|
|
21087
|
-
|
|
21088
|
-
|
|
21089
|
-
|
|
21090
|
-
|
|
21091
|
-
|
|
21092
|
-
|
|
21093
|
-
|
|
21094
|
-
|
|
21095
|
-
|
|
21096
|
-
|
|
21097
|
-
|
|
21098
|
-
|
|
21099
|
-
|
|
21100
|
-
|
|
21101
|
-
|
|
21102
|
-
|
|
21103
|
-
|
|
21104
|
-
|
|
21105
|
-
|
|
21106
|
-
|
|
21107
|
-
|
|
21108
|
-
|
|
21109
|
-
|
|
21110
|
-
|
|
21111
|
-
|
|
21112
|
-
|
|
21113
|
-
|
|
21114
|
-
|
|
21115
|
-
|
|
21116
|
-
|
|
21117
|
-
|
|
21118
|
-
|
|
21119
|
-
|
|
21120
|
-
|
|
21121
|
-
|
|
21122
|
-
|
|
22069
|
+
function proofFor(prepared, stake) {
|
|
22070
|
+
const { nodes, edges, events, nowMs } = prepared;
|
|
22071
|
+
const species = stakeSpeciesOf(stake);
|
|
22072
|
+
const answerType = answerTypeForStake(stake);
|
|
22073
|
+
const delivery = deliveryFor(species);
|
|
22074
|
+
const isRequirement = species === "requirement";
|
|
22075
|
+
const userFacing = species !== void 0 && USER_FACING_STAKE_SPECIES.includes(species);
|
|
22076
|
+
const quality = species !== void 0 && QUALITY_STAKE_SPECIES.includes(species);
|
|
22077
|
+
const reverifyDays = stakeReverifyDaysOf(stake);
|
|
22078
|
+
const reasons = [];
|
|
22079
|
+
const answerNodes = answerFor(stake.id, nodes, edges);
|
|
22080
|
+
const answer = answerNodes === void 0 ? void 0 : { decision_id: answerNodes.decision.id, option_id: answerNodes.option.id };
|
|
22081
|
+
if (answerNodes !== void 0 && answerNodes.competing.length > 0) {
|
|
22082
|
+
reasons.push(`More than one decision settles this stake (${[answerNodes.decision.id, ...answerNodes.competing].join(", ")}): the latest, ${answerNodes.decision.id}, is read.`);
|
|
22083
|
+
}
|
|
22084
|
+
const directPromises = acceptancesAddressing(stake.id, nodes, edges).filter((acceptance) => isPromise(acceptance, nodes, edges));
|
|
22085
|
+
const promises = promisesOf(stake.id, nodes, edges);
|
|
22086
|
+
const catalog = stakeCatalogOf(stake);
|
|
22087
|
+
const criterionId = catalog?.source === "kritik" ? catalog.id : void 0;
|
|
22088
|
+
const dod = isRequirement ? [] : promises;
|
|
22089
|
+
const hasDod = isRequirement ? criterionId !== void 0 : dod.length > 0;
|
|
22090
|
+
const cells = [];
|
|
22091
|
+
if (isRequirement) {
|
|
22092
|
+
const anchors = edges.filter((edge) => edge.edge_type === "concerns" && edge.source_id === stake.id).map((edge) => edge.target_id);
|
|
22093
|
+
let holds = false;
|
|
22094
|
+
let checkedMs;
|
|
22095
|
+
if (criterionId === void 0) {
|
|
22096
|
+
reasons.push("The requirement names no Kritik criterion, so nothing can be checked.");
|
|
22097
|
+
} else {
|
|
22098
|
+
const reading = kritikReading(stake, criterionId, anchors, prepared.input.quality, events);
|
|
22099
|
+
holds = reading.holds;
|
|
22100
|
+
checkedMs = reading.checkedMs;
|
|
22101
|
+
reasons.push(...reading.reasons);
|
|
22102
|
+
}
|
|
22103
|
+
const storedVersion = stakeVerifiedCriterionVersionOf(stake);
|
|
22104
|
+
const currentVersion = criterionId === void 0 ? void 0 : kritikCriterionVersion(criterionId, prepared.input.library);
|
|
22105
|
+
const newerVersion = storedVersion !== void 0 && currentVersion !== void 0 && currentVersion > storedVersion;
|
|
22106
|
+
const expired = holds && lapsed(reverifyDays, checkedMs, nowMs);
|
|
22107
|
+
const stale = holds && (expired || newerVersion);
|
|
22108
|
+
if (holds && newerVersion) reasons.push(`${criterionId} is at version ${currentVersion}, newer than version ${storedVersion} this was verified against.`);
|
|
22109
|
+
if (expired) reasons.push(checkedMs === void 0 ? "The check has no date, and the stake expires." : `The latest check is older than ${reverifyDays} days.`);
|
|
22110
|
+
cells.push({
|
|
22111
|
+
platform: null,
|
|
22112
|
+
verified: holds && !stale,
|
|
22113
|
+
delivered: deliveredEverywhere(promises, prepared),
|
|
22114
|
+
stale,
|
|
22115
|
+
...checkedMs !== void 0 ? { checked_at: isoOf2(checkedMs) } : {}
|
|
22116
|
+
});
|
|
22117
|
+
} else {
|
|
22118
|
+
const platforms = PLATFORM_IDS.filter((platform) => dod.some((acceptance) => platformsOf(acceptance, prepared).includes(platform)));
|
|
22119
|
+
const targets = platforms.length > 0 ? platforms : [null];
|
|
22120
|
+
for (const platform of targets) {
|
|
22121
|
+
const applying = platform === null ? dod : dod.filter((acceptance) => platformsOf(acceptance, prepared).includes(platform));
|
|
22122
|
+
const holds = applying.length > 0 && applying.every((acceptance) => reads(acceptance, platform, VERIFIED_STATUSES));
|
|
22123
|
+
const delivered = applying.length > 0 && applying.every((acceptance) => reads(acceptance, platform, DELIVERED_STATUSES));
|
|
22124
|
+
const checks = applying.map((acceptance) => latestCheckMs(acceptance, platform, prepared));
|
|
22125
|
+
const checkedMs = checks.every((ms) => ms !== void 0) && checks.length > 0 ? Math.min(...checks) : void 0;
|
|
22126
|
+
const stale = holds && lapsed(reverifyDays, checkedMs, nowMs);
|
|
22127
|
+
if (stale) reasons.push(`${platform ?? "The"} verification has lapsed: ${checkedMs === void 0 ? "no dated check" : `the latest check is older than ${reverifyDays} days`}.`);
|
|
22128
|
+
cells.push({
|
|
22129
|
+
platform,
|
|
22130
|
+
verified: holds && !stale,
|
|
22131
|
+
delivered,
|
|
22132
|
+
stale,
|
|
22133
|
+
...holds && checkedMs !== void 0 ? { checked_at: isoOf2(checkedMs) } : {}
|
|
22134
|
+
});
|
|
21123
22135
|
}
|
|
21124
22136
|
}
|
|
21125
|
-
const
|
|
21126
|
-
|
|
21127
|
-
|
|
21128
|
-
|
|
21129
|
-
|
|
21130
|
-
|
|
21131
|
-
|
|
21132
|
-
|
|
22137
|
+
const deliveryRequired = delivery === "required";
|
|
22138
|
+
const committed = answer !== void 0 || directPromises.length > 0;
|
|
22139
|
+
let state;
|
|
22140
|
+
if (stake.status === "archived") {
|
|
22141
|
+
state = null;
|
|
22142
|
+
reasons.unshift("Archived: an archived stake derives no state.");
|
|
22143
|
+
} else if (committed && hasDod && cells.every((cell) => cell.verified && (!deliveryRequired || cell.delivered))) {
|
|
22144
|
+
state = "addressed";
|
|
22145
|
+
reasons.push(deliveryRequired ? "Verified and delivered on every platform concerned." : "Verified on every platform concerned.");
|
|
22146
|
+
} else if (hasDod && deliveryRequired && cells.every((cell) => cell.verified) && !cells.some((cell) => cell.delivered)) {
|
|
22147
|
+
state = "verified-not-delivered";
|
|
22148
|
+
reasons.push("Verified everywhere, delivered nowhere: merged, not yet live.");
|
|
22149
|
+
} else if (cells.some((cell) => !cell.stale && (cell.verified || cell.delivered && delivery !== "not-required"))) {
|
|
22150
|
+
state = "partly-addressed";
|
|
22151
|
+
reasons.push("The proof holds on some platforms, not on every one the answer concerns.");
|
|
22152
|
+
} else if (answer !== void 0 && hasDod || directPromises.length > 0) {
|
|
22153
|
+
state = "promised";
|
|
22154
|
+
reasons.push(cells.some((cell) => cell.stale) ? "Promised: the verification lapsed, so it reads as promised until a new check passes." : "Promised: a decision chose an answer and it has a definition of done.");
|
|
22155
|
+
} else if (optionsAddressing(stake.id, nodes, edges).length > 0 || candidatesFor(stake.id, nodes, edges).length > 0 || userFacing && (prepared.input.weighing?.assessments?.some?.((row) => isRecord7(row) && row.subject === stake.id) === true || stakeMattersOf(stake) !== void 0) || quality && criterionId !== void 0) {
|
|
22156
|
+
state = "considered";
|
|
22157
|
+
reasons.push(
|
|
22158
|
+
answer !== void 0 ? "Considered: a decision chose an option, but the answer has no definition of done yet." : "Considered: an option or a candidate addresses it, or it has been evaluated."
|
|
22159
|
+
);
|
|
22160
|
+
} else {
|
|
22161
|
+
state = "raised";
|
|
22162
|
+
reasons.push("Raised: nothing addresses it yet.");
|
|
21133
22163
|
}
|
|
21134
|
-
const finding_counts = { critical: 0, high: 0, medium: 0, low: 0, info: 0 };
|
|
21135
|
-
for (const finding of openFindings) finding_counts[severityOf2(finding, pack)]++;
|
|
21136
22164
|
return {
|
|
21137
|
-
|
|
21138
|
-
|
|
21139
|
-
|
|
21140
|
-
|
|
21141
|
-
|
|
21142
|
-
|
|
22165
|
+
stake_id: stake.id,
|
|
22166
|
+
...species !== void 0 ? { stake_species: species } : {},
|
|
22167
|
+
...answerType !== void 0 ? { answer_type: answerType } : {},
|
|
22168
|
+
state,
|
|
22169
|
+
...answer !== void 0 ? { answer } : {},
|
|
22170
|
+
definition_of_done: dod.map((acceptance) => acceptance.id),
|
|
22171
|
+
delivery,
|
|
22172
|
+
cells,
|
|
22173
|
+
reasons
|
|
21143
22174
|
};
|
|
21144
22175
|
}
|
|
21145
|
-
|
|
21146
|
-
|
|
21147
|
-
|
|
21148
|
-
|
|
21149
|
-
"idea",
|
|
21150
|
-
"discovery",
|
|
21151
|
-
"backlog",
|
|
21152
|
-
"development",
|
|
21153
|
-
"releasing",
|
|
21154
|
-
"live",
|
|
21155
|
-
"archived"
|
|
21156
|
-
];
|
|
21157
|
-
var PLATFORM_IDS2 = ["web", "ios", "android"];
|
|
21158
|
-
var EDGE_TYPE_IDS2 = ["composes", "calls", "displays", "queries", "covers", "supersedes", "generates", "impacts"];
|
|
21159
|
-
var VALUE_TIER_IDS2 = ["functional", "emotional", "life-changing", "social-impact"];
|
|
21160
|
-
var VALUE_IDS2 = [
|
|
21161
|
-
// functional (14)
|
|
21162
|
-
"saves-time",
|
|
21163
|
-
"simplifies",
|
|
21164
|
-
"makes-money",
|
|
21165
|
-
"reduces-risk",
|
|
21166
|
-
"organizes",
|
|
21167
|
-
"integrates",
|
|
21168
|
-
"connects",
|
|
21169
|
-
"reduces-effort",
|
|
21170
|
-
"avoids-hassles",
|
|
21171
|
-
"reduces-cost",
|
|
21172
|
-
"quality",
|
|
21173
|
-
"variety",
|
|
21174
|
-
"sensory-appeal",
|
|
21175
|
-
"informs",
|
|
21176
|
-
// emotional (10)
|
|
21177
|
-
"reduces-anxiety",
|
|
21178
|
-
"rewards-me",
|
|
21179
|
-
"nostalgia",
|
|
21180
|
-
"design-aesthetics",
|
|
21181
|
-
"badge-value",
|
|
21182
|
-
"wellness",
|
|
21183
|
-
"therapeutic-value",
|
|
21184
|
-
"fun-entertainment",
|
|
21185
|
-
"attractiveness",
|
|
21186
|
-
"provides-access",
|
|
21187
|
-
// life-changing (5)
|
|
21188
|
-
"provides-hope",
|
|
21189
|
-
"self-actualization",
|
|
21190
|
-
"motivation",
|
|
21191
|
-
"heirloom",
|
|
21192
|
-
"affiliation-belonging",
|
|
21193
|
-
// social-impact (1)
|
|
21194
|
-
"self-transcendence"
|
|
21195
|
-
];
|
|
21196
|
-
|
|
21197
|
-
// ../../../../../packages/schema/src/quality-ops.ts
|
|
21198
|
-
function domainCodeOf2(criterionId, library) {
|
|
21199
|
-
const criterion = (library?.criteria ?? []).find((candidate) => candidate.id === criterionId);
|
|
21200
|
-
if (typeof criterion?.domain === "string" && criterion.domain !== "") return criterion.domain;
|
|
21201
|
-
const dash = criterionId.indexOf("-");
|
|
21202
|
-
return dash > 0 ? criterionId.slice(0, dash) : criterionId;
|
|
22176
|
+
function deriveStakeProof(input) {
|
|
22177
|
+
const prepared = prepare(input);
|
|
22178
|
+
const stake = prepared.nodes.find((node) => node.id === input.stakeId);
|
|
22179
|
+
return stake === void 0 || stake.species !== "stake" ? null : proofFor(prepared, stake);
|
|
21203
22180
|
}
|
|
21204
|
-
function
|
|
21205
|
-
const
|
|
21206
|
-
|
|
21207
|
-
const bySurface = {};
|
|
21208
|
-
for (const domain2 of matrix.domains) {
|
|
21209
|
-
const cell = matrix.matrix[domain2]?.[surface];
|
|
21210
|
-
if (cell) bySurface[domain2] = cell.score;
|
|
21211
|
-
}
|
|
21212
|
-
scores[surface] = bySurface;
|
|
21213
|
-
}
|
|
21214
|
-
return {
|
|
21215
|
-
type: "quality.audit.completed",
|
|
21216
|
-
payload: {
|
|
21217
|
-
audit_id: meta3.audit_id,
|
|
21218
|
-
framework_version: meta3.framework_version,
|
|
21219
|
-
...meta3.commit !== void 0 ? { commit: meta3.commit } : {},
|
|
21220
|
-
scores,
|
|
21221
|
-
counts: matrix.finding_counts,
|
|
21222
|
-
...meta3.scope !== void 0 ? { scope: meta3.scope } : {}
|
|
21223
|
-
}
|
|
21224
|
-
};
|
|
22181
|
+
function deriveStakeProofs(input) {
|
|
22182
|
+
const prepared = prepare(input);
|
|
22183
|
+
return prepared.nodes.filter((node) => node.species === "stake").map((stake) => proofFor(prepared, stake));
|
|
21225
22184
|
}
|
|
21226
22185
|
|
|
21227
|
-
//
|
|
21228
|
-
|
|
21229
|
-
|
|
21230
|
-
|
|
21231
|
-
|
|
21232
|
-
|
|
21233
|
-
|
|
21234
|
-
|
|
22186
|
+
// ../schema/src/cli/kritik-audit.ts
|
|
22187
|
+
import { existsSync as existsSync2, readdirSync, statSync } from "node:fs";
|
|
22188
|
+
import { join as join2 } from "node:path";
|
|
22189
|
+
|
|
22190
|
+
// ../schema/src/cli/kritik-paths.ts
|
|
22191
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
22192
|
+
import { dirname, join, resolve } from "node:path";
|
|
22193
|
+
var QUALITY_DIR = "docs/quality";
|
|
22194
|
+
var PROFILE_FILE = "profile.json";
|
|
22195
|
+
var OVERLAY_FILE = "criteria.custom.json";
|
|
22196
|
+
var AUDITS_DIR = "audits";
|
|
22197
|
+
var PACK_FILE = "library.json";
|
|
22198
|
+
function readJson(path) {
|
|
22199
|
+
const text = readFileSync(path, "utf8");
|
|
22200
|
+
try {
|
|
22201
|
+
return JSON.parse(text);
|
|
22202
|
+
} catch (e) {
|
|
22203
|
+
throw new Error(`${path}: not valid JSON \u2014 ${e.message}`);
|
|
22204
|
+
}
|
|
21235
22205
|
}
|
|
21236
|
-
function
|
|
21237
|
-
|
|
22206
|
+
function writeJson(path, value) {
|
|
22207
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
22208
|
+
writeFileSync(path, JSON.stringify(value, null, 2) + "\n");
|
|
21238
22209
|
}
|
|
21239
|
-
|
|
21240
|
-
|
|
22210
|
+
var profilePath = (root) => join(root, QUALITY_DIR, PROFILE_FILE);
|
|
22211
|
+
var overlayPath = (root) => join(root, QUALITY_DIR, OVERLAY_FILE);
|
|
22212
|
+
var auditsDir = (root) => join(root, QUALITY_DIR, AUDITS_DIR);
|
|
22213
|
+
var auditDir = (root, auditId) => join(auditsDir(root), auditId);
|
|
22214
|
+
function loadProfile(root) {
|
|
22215
|
+
const path = profilePath(root);
|
|
22216
|
+
return existsSync(path) ? readJson(path) : null;
|
|
21241
22217
|
}
|
|
21242
|
-
function
|
|
21243
|
-
|
|
22218
|
+
function loadOverlay(root) {
|
|
22219
|
+
const path = overlayPath(root);
|
|
22220
|
+
return existsSync(path) ? readJson(path) : null;
|
|
21244
22221
|
}
|
|
21245
|
-
|
|
21246
|
-
|
|
22222
|
+
|
|
22223
|
+
// ../schema/src/cli/kritik-audit.ts
|
|
22224
|
+
var SCORES_FILE = "scores.json";
|
|
22225
|
+
var FINDINGS_FILE = "findings.json";
|
|
22226
|
+
var MATRIX_FILE = "matrix.json";
|
|
22227
|
+
var scoresPath = (root, auditId) => join2(auditDir(root, auditId), SCORES_FILE);
|
|
22228
|
+
var findingsPath = (root, auditId) => join2(auditDir(root, auditId), FINDINGS_FILE);
|
|
22229
|
+
var matrixPath = (root, auditId) => join2(auditDir(root, auditId), MATRIX_FILE);
|
|
22230
|
+
function listAuditIds(root) {
|
|
22231
|
+
const dir = auditsDir(root);
|
|
22232
|
+
if (!existsSync2(dir)) return [];
|
|
22233
|
+
return readdirSync(dir).filter((name) => statSync(join2(dir, name)).isDirectory()).sort();
|
|
21247
22234
|
}
|
|
21248
|
-
function
|
|
21249
|
-
|
|
21250
|
-
|
|
21251
|
-
|
|
21252
|
-
}
|
|
21253
|
-
|
|
21254
|
-
return `${plural(cells, "cell")}, ${plural(steps, "checklist step")}`;
|
|
21255
|
-
}
|
|
21256
|
-
function partSteps(part, first) {
|
|
21257
|
-
const audit = `--audit ${part.auditId}`;
|
|
21258
|
-
return [
|
|
21259
|
-
`${first}. Get the run sheet: \`arkaik kritik signals --domain ${part.domain} --surface ${part.surface}\`. ${SIGNALS_EXIT}`,
|
|
21260
|
-
`${first + 1}. Score exactly these cells and no others:`,
|
|
21261
|
-
...part.cells.map(
|
|
21262
|
-
(cell) => ` - ${cell.criterion_id} on ${cell.surface}: \`arkaik kritik score ${cell.criterion_id} ${cell.surface} <level> --evidence "<file:line \u2026>" ${audit}\``
|
|
21263
|
-
),
|
|
21264
|
-
`${first + 2}. Open every finding on this part's audit: \`arkaik kritik finding open <criterion> ${part.surface} ${FINDING_FLAGS} ${audit}\`. Give file-and-line evidence, and verify every Critical and High finding adversarially before you open it.`
|
|
21265
|
-
];
|
|
21266
|
-
}
|
|
21267
|
-
function renderPartPrompt2(plan, part) {
|
|
21268
|
-
const estimate = part.estimate === null ? "" : estimateSentence(part.estimate.tokens, part.estimate.usd, part.estimate.calibrated);
|
|
21269
|
-
return [
|
|
21270
|
-
`Run part ${part.domain}:${part.surface} of Kritik plan ${plan.planId} in this repo (${where(plan.commit)}).`,
|
|
21271
|
-
`Scope: ${scopeSentence(part.cells.length, part.steps)}.${estimate}`,
|
|
21272
|
-
`Audit id for this part: ${part.auditId}`,
|
|
21273
|
-
"",
|
|
21274
|
-
`1. ${SKILL_STEP}`,
|
|
21275
|
-
...partSteps(part, 2),
|
|
21276
|
-
"5. Do not record this part. The plan is recorded once, after every part is scored, with the plan's own command.",
|
|
21277
|
-
`6. Finish by printing ${USAGE_READOUT}`
|
|
21278
|
-
].join("\n");
|
|
21279
|
-
}
|
|
21280
|
-
function renderPlanPrompt2(plan) {
|
|
21281
|
-
const included = plan.parts.filter((part) => part.status === "included");
|
|
21282
|
-
const deferred = plan.parts.filter((part) => part.status === "deferred");
|
|
21283
|
-
const calibrated = included.every((part) => part.estimate?.calibrated === true);
|
|
21284
|
-
const lines = [
|
|
21285
|
-
`Run Kritik plan ${plan.planId} in this repo (${where(plan.commit)}): ${plural(included.length, "part")}, one after the other, in this session.`,
|
|
21286
|
-
`Scope: ${scopeSentence(plan.totals.cells, plan.totals.steps)}, of ${plan.totals.applicableCells} applicable cells.` + estimateSentence(plan.totals.tokens, plan.totals.usd, calibrated),
|
|
21287
|
-
"",
|
|
21288
|
-
`1. ${SKILL_STEP} Do not record a part on its own.`
|
|
21289
|
-
];
|
|
21290
|
-
let step = 2;
|
|
21291
|
-
for (const part of included) {
|
|
21292
|
-
lines.push(
|
|
21293
|
-
"",
|
|
21294
|
-
`Part ${part.domain}:${part.surface}, audit id ${part.auditId} (${scopeSentence(part.cells.length, part.steps)}):`,
|
|
21295
|
-
...partSteps(part, step)
|
|
21296
|
-
);
|
|
21297
|
-
step += 3;
|
|
21298
|
-
}
|
|
21299
|
-
lines.push(
|
|
21300
|
-
"",
|
|
21301
|
-
`${step}. Check that every part is scored: \`arkaik kritik plan --status ${plan.planId}\``,
|
|
21302
|
-
`${step + 1}. Print ${USAGE_READOUT}`,
|
|
21303
|
-
`${step + 2}. When every part is scored, run \`${plan.recordCommand}\``
|
|
21304
|
-
);
|
|
21305
|
-
if (deferred.length > 0) {
|
|
21306
|
-
lines.push(
|
|
21307
|
-
"",
|
|
21308
|
-
"Not in this run (over budget):",
|
|
21309
|
-
...deferred.map((part) => ` - ${part.domain}:${part.surface} (${part.auditId}). Do not score it.`)
|
|
21310
|
-
);
|
|
21311
|
-
}
|
|
21312
|
-
return lines.join("\n");
|
|
21313
|
-
}
|
|
21314
|
-
|
|
21315
|
-
// ../../../../../packages/schema/src/quality-plan.ts
|
|
21316
|
-
var KRITIK_PLAN_SCHEMA2 = "arkaik.kritik.plan/1";
|
|
21317
|
-
var PLAN_PLANS_DIR = "plans";
|
|
21318
|
-
var SCOPED_AUDIT_ID2 = /-scoped(-\d+)?$/;
|
|
21319
|
-
var PLAN_ID2 = /^\d{4}-\d{2}-zplan-\d{4}$/;
|
|
21320
|
-
var PLAN_PART_ID2 = /^\d{4}-\d{2}-zplan-\d{4}-[a-z0-9]{2,5}-.+$/;
|
|
21321
|
-
var PLAN_ID_LENGTH2 = 18;
|
|
21322
|
-
function planCellKey(criterionId, surface) {
|
|
21323
|
-
return `${criterionId}::${surface}`;
|
|
21324
|
-
}
|
|
21325
|
-
function isScopedAuditId2(id) {
|
|
21326
|
-
return typeof id === "string" && SCOPED_AUDIT_ID2.test(id);
|
|
21327
|
-
}
|
|
21328
|
-
function isPlanId2(id) {
|
|
21329
|
-
return typeof id === "string" && PLAN_ID2.test(id);
|
|
21330
|
-
}
|
|
21331
|
-
function isPlanPartId2(id) {
|
|
21332
|
-
return typeof id === "string" && PLAN_PART_ID2.test(id) && !isScopedAuditId2(id);
|
|
21333
|
-
}
|
|
21334
|
-
function planIdOfPartId2(id) {
|
|
21335
|
-
return isPlanPartId2(id) ? id.slice(0, PLAN_ID_LENGTH2) : null;
|
|
21336
|
-
}
|
|
21337
|
-
var RUN_TOKEN = /^([A-Za-z0-9]{2,5}):([A-Za-z0-9_-]+)$/;
|
|
21338
|
-
var PLANNABLE_DOMAIN = /^[A-Z0-9]{2,5}$/;
|
|
21339
|
-
function parseRun(tokens2, vocabulary) {
|
|
21340
|
-
if (tokens2.length === 0) throw new Error("at least one --run DOMAIN:SURFACE is required");
|
|
21341
|
-
const surfaces = vocabulary.surfaces.filter((id) => id !== CROSS_SURFACE_ID2);
|
|
21342
|
-
const plannable = vocabulary.domains.filter((code) => PLANNABLE_DOMAIN.test(code));
|
|
21343
|
-
const unplannable = vocabulary.domains.filter((code) => !PLANNABLE_DOMAIN.test(code));
|
|
21344
|
-
const runs = [];
|
|
21345
|
-
const warnings = [];
|
|
21346
|
-
const tokenBySuffix = /* @__PURE__ */ new Map();
|
|
21347
|
-
for (const token of tokens2) {
|
|
21348
|
-
const match = RUN_TOKEN.exec(token);
|
|
21349
|
-
if (match === null) {
|
|
21350
|
-
throw new Error(
|
|
21351
|
-
`--run "${token}" is not DOMAIN:SURFACE \u2014 a domain code of 2 to 5 letters or digits, a colon, then a surface id of letters, digits, "-" or "_" (for example SEC:web).`
|
|
21352
|
-
);
|
|
21353
|
-
}
|
|
21354
|
-
const domain2 = match[1].toUpperCase();
|
|
21355
|
-
const surface = match[2];
|
|
21356
|
-
if (!plannable.includes(domain2)) {
|
|
21357
|
-
throw new Error(
|
|
21358
|
-
`--run "${token}": ${domain2} is not a domain of this library. Domain codes: ${plannable.length > 0 ? plannable.join(", ") : "none that can be planned"}.` + (unplannable.length > 0 ? ` ${unplannable.join(", ")} cannot be planned: a domain code must be 2 to 5 upper-case letters or digits.` : "")
|
|
21359
|
-
);
|
|
21360
|
-
}
|
|
21361
|
-
if (surface === CROSS_SURFACE_ID2) {
|
|
21362
|
-
throw new Error(
|
|
21363
|
-
`--run "${token}": ${CROSS_SURFACE_ID2} is a lens for findings, not a surface anything is scored on. Plan the surfaces it connects instead.`
|
|
21364
|
-
);
|
|
21365
|
-
}
|
|
21366
|
-
if (!surfaces.includes(surface)) {
|
|
21367
|
-
throw new Error(
|
|
21368
|
-
`--run "${token}": "${surface}" is not a surface of this project's profile. Surfaces: ${surfaces.length > 0 ? surfaces.join(", ") : "none declared"}. A surface must match its id exactly, case included.`
|
|
21369
|
-
);
|
|
21370
|
-
}
|
|
21371
|
-
if (runs.some((run) => run.domain === domain2 && run.surface === surface)) {
|
|
21372
|
-
warnings.push(`--run ${token} repeats ${domain2}:${surface}; the two are one part.`);
|
|
21373
|
-
continue;
|
|
21374
|
-
}
|
|
21375
|
-
const suffix = `${domain2.toLowerCase()}-${surface.toLowerCase()}`;
|
|
21376
|
-
const other = tokenBySuffix.get(suffix);
|
|
21377
|
-
if (other !== void 0) {
|
|
21378
|
-
throw new Error(
|
|
21379
|
-
`--run "${other}" and --run "${token}" name surfaces that differ only by case, so both would score into the one part id "<planId>-${suffix}". Plan one of them, or give the profile's surfaces ids that differ by more than case.`
|
|
21380
|
-
);
|
|
21381
|
-
}
|
|
21382
|
-
tokenBySuffix.set(suffix, token);
|
|
21383
|
-
runs.push({ domain: domain2, surface });
|
|
21384
|
-
}
|
|
21385
|
-
return { runs, warnings };
|
|
21386
|
-
}
|
|
21387
|
-
function planCells(library, surfaces, run) {
|
|
21388
|
-
const byId = /* @__PURE__ */ new Map();
|
|
21389
|
-
for (const criterion of Array.isArray(library.criteria) ? library.criteria : []) {
|
|
21390
|
-
if (typeof criterion?.id === "string" && !byId.has(criterion.id)) byId.set(criterion.id, criterion);
|
|
21391
|
-
}
|
|
21392
|
-
const cells = [];
|
|
21393
|
-
let steps = 0;
|
|
21394
|
-
for (const entry of applicableCells2(library, surfaces)) {
|
|
21395
|
-
if (!entry.surfaces.includes(run.surface)) continue;
|
|
21396
|
-
if (domainCodeOf2(entry.criterion_id, library) !== run.domain) continue;
|
|
21397
|
-
cells.push({ criterion_id: entry.criterion_id, surface: run.surface });
|
|
21398
|
-
const checklist = byId.get(entry.criterion_id)?.checklist;
|
|
21399
|
-
steps += Array.isArray(checklist) ? checklist.length : 0;
|
|
21400
|
-
}
|
|
21401
|
-
return { cells, steps };
|
|
21402
|
-
}
|
|
21403
|
-
function applicableCellCount(library, surfaces) {
|
|
21404
|
-
let count = 0;
|
|
21405
|
-
for (const entry of applicableCells2(library, surfaces)) count += entry.surfaces.length;
|
|
21406
|
-
return count;
|
|
21407
|
-
}
|
|
21408
|
-
function planPartId2(planId2, domain2, surface) {
|
|
21409
|
-
const id = `${planId2}-${domain2.toLowerCase()}-${surface.toLowerCase()}`;
|
|
21410
|
-
if (isScopedAuditId2(id)) {
|
|
21411
|
-
throw new Error(
|
|
21412
|
-
`the part ${domain2}:${surface} would be named "${id}", which reads as a scoped re-audit. A surface named "scoped", or ending in "-scoped" or "-scoped-NN", cannot be planned.`
|
|
21413
|
-
);
|
|
21414
|
-
}
|
|
21415
|
-
return id;
|
|
21416
|
-
}
|
|
21417
|
-
function planId(input) {
|
|
21418
|
-
const { now, known, runs } = input;
|
|
21419
|
-
if (runs.length === 0) throw new Error("a plan id needs at least one run: with none, no part is checked to sort last");
|
|
21420
|
-
const ids = known.filter((id) => typeof id === "string" && id !== "");
|
|
21421
|
-
const greatest = [...ids].sort().at(-1);
|
|
21422
|
-
const year = String(now.getFullYear()).padStart(4, "0");
|
|
21423
|
-
const month = String(now.getMonth() + 1).padStart(2, "0");
|
|
21424
|
-
const day = String(now.getDate()).padStart(2, "0");
|
|
21425
|
-
for (let n = 0; n < 100; n++) {
|
|
21426
|
-
const candidate = `${year}-${month}-zplan-${day}${String(n).padStart(2, "0")}`;
|
|
21427
|
-
if (ids.some((id) => id === candidate || id.startsWith(`${candidate}-`))) continue;
|
|
21428
|
-
if (greatest !== void 0 && !runs.every((run) => planPartId2(candidate, run.domain, run.surface) > greatest)) continue;
|
|
21429
|
-
return candidate;
|
|
21430
|
-
}
|
|
21431
|
-
throw new Error(`no plan id on ${year}-${month}-${day} sorts after "${greatest}"`);
|
|
21432
|
-
}
|
|
21433
|
-
function outsortedBy2(partId, known) {
|
|
21434
|
-
const plan = planIdOfPartId2(partId);
|
|
21435
|
-
if (plan === null) return [];
|
|
21436
|
-
const after = /* @__PURE__ */ new Set();
|
|
21437
|
-
for (const id of known) {
|
|
21438
|
-
if (typeof id !== "string" || !(id > partId)) continue;
|
|
21439
|
-
if (planIdOfPartId2(id) === plan) continue;
|
|
21440
|
-
after.add(id);
|
|
21441
|
-
}
|
|
21442
|
-
return [...after].sort();
|
|
21443
|
-
}
|
|
21444
|
-
var isCount2 = (value) => typeof value === "number" && Number.isInteger(value) && value >= 0;
|
|
21445
|
-
var nonEmptyStrings2 = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string" && item !== "") : [];
|
|
21446
|
-
function readCoverage2(value) {
|
|
21447
|
-
if (typeof value !== "object" || value === null) return null;
|
|
21448
|
-
const row = value;
|
|
21449
|
-
if (!isCount2(row.scored) || !isCount2(row.assessed) || !isCount2(row.applicable)) return null;
|
|
21450
|
-
const surfaces = {};
|
|
21451
|
-
if (typeof row.surfaces === "object" && row.surfaces !== null && !Array.isArray(row.surfaces)) {
|
|
21452
|
-
for (const [surface, entry] of Object.entries(row.surfaces)) {
|
|
21453
|
-
if (surface === "__proto__") continue;
|
|
21454
|
-
if (typeof entry !== "object" || entry === null) continue;
|
|
21455
|
-
const { assessed, applicable } = entry;
|
|
21456
|
-
if (isCount2(assessed) && isCount2(applicable)) surfaces[surface] = { assessed, applicable };
|
|
21457
|
-
}
|
|
21458
|
-
}
|
|
21459
|
-
return { scored: row.scored, assessed: row.assessed, applicable: row.applicable, surfaces };
|
|
21460
|
-
}
|
|
21461
|
-
function readPlanScope2(scope) {
|
|
21462
|
-
if (typeof scope !== "object" || scope === null) return null;
|
|
21463
|
-
const row = scope;
|
|
21464
|
-
if (typeof row.plan !== "string" || row.plan === "") return null;
|
|
21465
|
-
return {
|
|
21466
|
-
plan: row.plan,
|
|
21467
|
-
parts: nonEmptyStrings2(row.parts),
|
|
21468
|
-
scored: nonEmptyStrings2(row.scored),
|
|
21469
|
-
cells: isCount2(row.cells) ? row.cells : null,
|
|
21470
|
-
since: typeof row.since === "string" && row.since !== "" ? row.since : null,
|
|
21471
|
-
coverage: readCoverage2(row.coverage)
|
|
21472
|
-
};
|
|
21473
|
-
}
|
|
21474
|
-
function buildKritikPlan(input) {
|
|
21475
|
-
const { library, surfaces, runs, known, now, commit } = input;
|
|
21476
|
-
const counted = runs.map((run) => {
|
|
21477
|
-
const { cells, steps } = planCells(library, surfaces, run);
|
|
21478
|
-
if (cells.length === 0) {
|
|
21479
|
-
throw new Error(
|
|
21480
|
-
`no ${run.domain} criterion applies to "${run.surface}" \u2014 every ${run.domain} criterion's applies_to leaves it out, so this part would score nothing.`
|
|
21481
|
-
);
|
|
21482
|
-
}
|
|
21483
|
-
return { run, cells, steps };
|
|
21484
|
-
});
|
|
21485
|
-
const id = planId({ now, known, runs });
|
|
21486
|
-
const parts = counted.map(({ run, cells, steps }) => ({
|
|
21487
|
-
domain: run.domain,
|
|
21488
|
-
surface: run.surface,
|
|
21489
|
-
auditId: planPartId2(id, run.domain, run.surface),
|
|
21490
|
-
cells,
|
|
21491
|
-
steps,
|
|
21492
|
-
estimate: null,
|
|
21493
|
-
status: "included"
|
|
21494
|
-
}));
|
|
21495
|
-
const included = parts.filter((part) => part.status === "included");
|
|
21496
|
-
const head = {
|
|
21497
|
-
schema: KRITIK_PLAN_SCHEMA2,
|
|
21498
|
-
planId: id,
|
|
21499
|
-
createdAt: now.toISOString(),
|
|
21500
|
-
commit,
|
|
21501
|
-
frameworkVersion: library.version,
|
|
21502
|
-
tier: null,
|
|
21503
|
-
budgetTokens: null,
|
|
21504
|
-
budgetUsd: null,
|
|
21505
|
-
pricePerMTok: null,
|
|
21506
|
-
totals: {
|
|
21507
|
-
cells: included.reduce((sum, part) => sum + part.cells.length, 0),
|
|
21508
|
-
steps: included.reduce((sum, part) => sum + part.steps, 0),
|
|
21509
|
-
applicableCells: applicableCellCount(library, surfaces),
|
|
21510
|
-
tokens: null,
|
|
21511
|
-
usd: null
|
|
21512
|
-
},
|
|
21513
|
-
recordCommand: planRecordCommand2(id)
|
|
21514
|
-
};
|
|
21515
|
-
return {
|
|
21516
|
-
schema: head.schema,
|
|
21517
|
-
planId: head.planId,
|
|
21518
|
-
createdAt: head.createdAt,
|
|
21519
|
-
commit: head.commit,
|
|
21520
|
-
frameworkVersion: head.frameworkVersion,
|
|
21521
|
-
tier: head.tier,
|
|
21522
|
-
budgetTokens: head.budgetTokens,
|
|
21523
|
-
budgetUsd: head.budgetUsd,
|
|
21524
|
-
pricePerMTok: head.pricePerMTok,
|
|
21525
|
-
parts: parts.map((part) => ({ ...part, prompt: renderPartPrompt2({ planId: id, commit }, part) })),
|
|
21526
|
-
totals: head.totals,
|
|
21527
|
-
prompt: renderPlanPrompt2({ ...head, parts }),
|
|
21528
|
-
recordCommand: head.recordCommand
|
|
21529
|
-
};
|
|
21530
|
-
}
|
|
21531
|
-
function planPartStatuses(plan, scoresByPart) {
|
|
21532
|
-
return plan.parts.map((part) => {
|
|
21533
|
-
const planned = new Set(part.cells.map((cell) => planCellKey(cell.criterion_id, cell.surface)));
|
|
21534
|
-
const scoredKeys = /* @__PURE__ */ new Set();
|
|
21535
|
-
const strayKeys = /* @__PURE__ */ new Set();
|
|
21536
|
-
const stray = [];
|
|
21537
|
-
const scores = Object.prototype.hasOwnProperty.call(scoresByPart, part.auditId) ? scoresByPart[part.auditId] : [];
|
|
21538
|
-
for (const score of scores) {
|
|
21539
|
-
const key = planCellKey(score.criterion_id, score.surface);
|
|
21540
|
-
if (planned.has(key)) scoredKeys.add(key);
|
|
21541
|
-
else if (!strayKeys.has(key)) {
|
|
21542
|
-
strayKeys.add(key);
|
|
21543
|
-
stray.push({ criterion_id: score.criterion_id, surface: score.surface });
|
|
21544
|
-
}
|
|
21545
|
-
}
|
|
21546
|
-
const missing = part.cells.filter((cell) => !scoredKeys.has(planCellKey(cell.criterion_id, cell.surface)));
|
|
21547
|
-
const scored = part.cells.length - missing.length;
|
|
21548
|
-
const progress = part.status === "deferred" ? "deferred" : scored === 0 && stray.length === 0 ? "not started" : missing.length === 0 ? "scored" : "in progress";
|
|
21549
|
-
return {
|
|
21550
|
-
auditId: part.auditId,
|
|
21551
|
-
domain: part.domain,
|
|
21552
|
-
surface: part.surface,
|
|
21553
|
-
progress,
|
|
21554
|
-
scored,
|
|
21555
|
-
cells: part.cells.length,
|
|
21556
|
-
missing,
|
|
21557
|
-
stray
|
|
21558
|
-
};
|
|
21559
|
-
});
|
|
21560
|
-
}
|
|
21561
|
-
function coverageOf(section, library, scored = 0) {
|
|
21562
|
-
const assessments = Array.isArray(section.assessments) ? section.assessments : [];
|
|
21563
|
-
const listed = section.profile?.surfaces;
|
|
21564
|
-
const surfaces = [];
|
|
21565
|
-
for (const surface of Array.isArray(listed) ? listed : []) {
|
|
21566
|
-
const id = surface?.id;
|
|
21567
|
-
if (typeof id === "string" && id !== "" && id !== CROSS_SURFACE_ID2 && !surfaces.includes(id)) surfaces.push(id);
|
|
21568
|
-
}
|
|
21569
|
-
if (surfaces.length === 0) {
|
|
21570
|
-
for (const assessment of assessments) {
|
|
21571
|
-
const id = assessment?.surface;
|
|
21572
|
-
if (typeof id === "string" && id !== "" && id !== CROSS_SURFACE_ID2 && !surfaces.includes(id)) surfaces.push(id);
|
|
21573
|
-
}
|
|
21574
|
-
}
|
|
21575
|
-
const perSurface = /* @__PURE__ */ new Map();
|
|
21576
|
-
for (const surface of surfaces) perSurface.set(surface, { assessed: 0, applicable: 0 });
|
|
21577
|
-
const applicable = /* @__PURE__ */ new Set();
|
|
21578
|
-
for (const entry of applicableCells2(library, surfaces)) {
|
|
21579
|
-
for (const surface of entry.surfaces) {
|
|
21580
|
-
const counts = perSurface.get(surface);
|
|
21581
|
-
if (counts === void 0) continue;
|
|
21582
|
-
applicable.add(planCellKey(entry.criterion_id, surface));
|
|
21583
|
-
counts.applicable++;
|
|
21584
|
-
}
|
|
21585
|
-
}
|
|
21586
|
-
const assessed = /* @__PURE__ */ new Set();
|
|
21587
|
-
for (const assessment of assessments) {
|
|
21588
|
-
if (typeof assessment?.criterion_id !== "string" || typeof assessment?.surface !== "string") continue;
|
|
21589
|
-
const key = planCellKey(assessment.criterion_id, assessment.surface);
|
|
21590
|
-
if (!applicable.has(key) || assessed.has(key)) continue;
|
|
21591
|
-
assessed.add(key);
|
|
21592
|
-
const counts = perSurface.get(assessment.surface);
|
|
21593
|
-
if (counts !== void 0) counts.assessed++;
|
|
21594
|
-
}
|
|
21595
|
-
const bySurface = {};
|
|
21596
|
-
for (const [surface, counts] of perSurface) {
|
|
21597
|
-
if (surface === "__proto__") continue;
|
|
21598
|
-
bySurface[surface] = counts;
|
|
21599
|
-
}
|
|
21600
|
-
return { scored, assessed: assessed.size, applicable: applicable.size, surfaces: bySurface };
|
|
21601
|
-
}
|
|
21602
|
-
|
|
21603
|
-
// ../../../../../packages/schema/src/legacy-status.ts
|
|
21604
|
-
var LEGACY_STATUS_IDS2 = ["prioritized", "blocked"];
|
|
21605
|
-
var LEGACY_STATUS_ALIASES2 = {
|
|
21606
|
-
prioritized: "backlog",
|
|
21607
|
-
blocked: "development"
|
|
21608
|
-
};
|
|
21609
|
-
var LEGACY_ALIAS_REMAP2 = { ...LEGACY_STATUS_ALIASES2 };
|
|
21610
|
-
var LEGACY_VOCABULARY_REMAP2 = {
|
|
21611
|
-
backlog: "idea",
|
|
21612
|
-
...LEGACY_STATUS_ALIASES2
|
|
21613
|
-
};
|
|
21614
|
-
|
|
21615
|
-
// ../../../../../packages/schema/src/journal.ts
|
|
21616
|
-
function orderEvents2(events) {
|
|
21617
|
-
const key = (v) => typeof v === "string" ? v : "";
|
|
21618
|
-
return [...events].sort((a, b) => {
|
|
21619
|
-
const ta = key(a.ts);
|
|
21620
|
-
const tb = key(b.ts);
|
|
21621
|
-
if (ta < tb) return -1;
|
|
21622
|
-
if (ta > tb) return 1;
|
|
21623
|
-
const ia = key(a.id);
|
|
21624
|
-
const ib = key(b.id);
|
|
21625
|
-
if (ia < ib) return -1;
|
|
21626
|
-
if (ia > ib) return 1;
|
|
21627
|
-
return 0;
|
|
21628
|
-
});
|
|
21629
|
-
}
|
|
21630
|
-
|
|
21631
|
-
// ../../../../../packages/schema/src/quality-scope.ts
|
|
21632
|
-
var rowsOf4 = (value) => Array.isArray(value) ? value : [];
|
|
21633
|
-
var isString4 = (value) => typeof value === "string" && value !== "";
|
|
21634
|
-
var stringsOf2 = (value) => rowsOf4(value).filter(isString4);
|
|
21635
|
-
var orderedRows2 = (events) => orderEvents2(rowsOf4(events).filter((event) => typeof event === "object" && event !== null));
|
|
21636
|
-
function isPlanRecord2(event) {
|
|
21637
|
-
if (typeof event !== "object" || event === null) return false;
|
|
21638
|
-
const { type, scope, audit_id: auditId } = event;
|
|
21639
|
-
return type === "quality.audit.completed" && (readPlanScope2(scope) !== null || isPlanId2(auditId));
|
|
21640
|
-
}
|
|
21641
|
-
function recordedPlans2(events) {
|
|
21642
|
-
const plans = [];
|
|
21643
|
-
for (const event of orderedRows2(events)) {
|
|
21644
|
-
if (!isPlanRecord2(event)) continue;
|
|
21645
|
-
const reading = readPlanScope2(event.scope);
|
|
21646
|
-
const ts = isString4(event.ts) ? event.ts : null;
|
|
21647
|
-
if (reading === null) plans.push({ plan: event.audit_id, parts: [], scored: [], ts });
|
|
21648
|
-
else plans.push({ plan: reading.plan, parts: stringsOf2(reading.parts), scored: stringsOf2(reading.scored), ts });
|
|
21649
|
-
}
|
|
21650
|
-
return plans;
|
|
21651
|
-
}
|
|
21652
|
-
function recordedAuditIds2(events) {
|
|
21653
|
-
const ids = [];
|
|
21654
|
-
const note = (id) => {
|
|
21655
|
-
if (isString4(id) && !ids.includes(id)) ids.push(id);
|
|
21656
|
-
};
|
|
21657
|
-
for (const event of orderedRows2(events)) {
|
|
21658
|
-
if (event.type !== "quality.audit.completed") continue;
|
|
21659
|
-
note(event.audit_id);
|
|
21660
|
-
for (const part of readPlanScope2(event.scope)?.parts ?? []) note(part);
|
|
21661
|
-
}
|
|
21662
|
-
return ids;
|
|
21663
|
-
}
|
|
21664
|
-
function neverAnAnchor2(event) {
|
|
21665
|
-
return isPlanRecord2(event) || isPlanPartId2(event?.audit_id);
|
|
21666
|
-
}
|
|
21667
|
-
function anchorIndex2(ordered, since) {
|
|
21668
|
-
for (let i = ordered.length - 1; i >= 0; i--) {
|
|
21669
|
-
const event = ordered[i];
|
|
21670
|
-
if (event.type !== "quality.audit.completed" || neverAnAnchor2(event)) continue;
|
|
21671
|
-
if (since !== void 0 && event.audit_id !== since) continue;
|
|
21672
|
-
return i;
|
|
21673
|
-
}
|
|
21674
|
-
return -1;
|
|
21675
|
-
}
|
|
21676
|
-
function scopeAnchorId(events) {
|
|
21677
|
-
const ordered = orderedRows2(events);
|
|
21678
|
-
const at = anchorIndex2(ordered, void 0);
|
|
21679
|
-
if (at === -1) return null;
|
|
21680
|
-
const id = ordered[at].audit_id;
|
|
21681
|
-
return isString4(id) ? id : null;
|
|
21682
|
-
}
|
|
21683
|
-
function scopedAuditId(input) {
|
|
21684
|
-
const { since, month, requested, known, recorded, open } = input;
|
|
21685
|
-
const newest = [...known].sort().at(-1);
|
|
21686
|
-
if (requested !== void 0) {
|
|
21687
|
-
if (requested === since) {
|
|
21688
|
-
throw new Error(
|
|
21689
|
-
`"${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.`
|
|
21690
|
-
);
|
|
21691
|
-
}
|
|
21692
|
-
if (recorded.includes(requested)) {
|
|
21693
|
-
throw new Error(`"${requested}" is already recorded \u2014 its reading is history. Name a new audit.`);
|
|
21694
|
-
}
|
|
21695
|
-
if (isPlanId2(requested) || isPlanPartId2(requested)) {
|
|
21696
|
-
throw new Error(
|
|
21697
|
-
`"${requested}" is reserved for plans and their parts \u2014 a plan id (YYYY-MM-zplan-DDNN) names a plan, and <planId>-<domain>-<surface> one of its parts, so an audit under that id could never be recorded or read as one. Name a scoped re-audit (e.g. \`${suggestedAuditId({ ...input, requested: void 0 })}\`).`
|
|
21698
|
-
);
|
|
21699
|
-
}
|
|
21700
|
-
if (newest !== void 0 && requested < newest) {
|
|
21701
|
-
throw new Error(
|
|
21702
|
-
`"${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)}\`).`
|
|
21703
|
-
);
|
|
21704
|
-
}
|
|
21705
|
-
return requested;
|
|
21706
|
-
}
|
|
21707
|
-
if (open !== void 0 && (newest === void 0 || open >= newest)) return open;
|
|
21708
|
-
for (const candidate of scopedCandidates(month, known)) {
|
|
21709
|
-
if (known.includes(candidate)) continue;
|
|
21710
|
-
if (newest !== void 0 && candidate < newest) {
|
|
21711
|
-
throw new Error(
|
|
21712
|
-
`"${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)}\`).`
|
|
21713
|
-
);
|
|
21714
|
-
}
|
|
21715
|
-
return candidate;
|
|
21716
|
-
}
|
|
21717
|
-
throw new Error(`99 scoped audits in ${month} \u2014 name the next one yourself.`);
|
|
21718
|
-
}
|
|
21719
|
-
function* scopedCandidates(month, known) {
|
|
21720
|
-
const newest = [...known].sort().at(-1) ?? "";
|
|
21721
|
-
const stem = newest.replace(/-scoped(-\d+)?$/, "");
|
|
21722
|
-
const base = `${month}-scoped` < newest && isPlanPartId2(stem) ? stem : month;
|
|
21723
|
-
for (let n = 1; n < 100; n++) yield n === 1 ? `${base}-scoped` : `${base}-scoped-${String(n).padStart(2, "0")}`;
|
|
21724
|
-
}
|
|
21725
|
-
function suggestedAuditId({ since, month, requested, known, recorded }) {
|
|
21726
|
-
const taken = /* @__PURE__ */ new Set([...known, ...recorded, since, ...requested !== void 0 ? [requested] : []]);
|
|
21727
|
-
const floor = [...taken].sort().at(-1);
|
|
21728
|
-
for (const candidate of scopedCandidates(month, known)) {
|
|
21729
|
-
if (taken.has(candidate)) continue;
|
|
21730
|
-
if (floor === void 0 || candidate > floor) return candidate;
|
|
21731
|
-
}
|
|
21732
|
-
return `${floor}-scoped`;
|
|
21733
|
-
}
|
|
21734
|
-
|
|
21735
|
-
// ../../../../../packages/schema/src/cli/kritik-paths.ts
|
|
21736
|
-
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
21737
|
-
import { dirname, join, resolve } from "node:path";
|
|
21738
|
-
var QUALITY_DIR = "docs/quality";
|
|
21739
|
-
var PROFILE_FILE = "profile.json";
|
|
21740
|
-
var OVERLAY_FILE = "criteria.custom.json";
|
|
21741
|
-
var AUDITS_DIR = "audits";
|
|
21742
|
-
var PACK_FILE = "library.json";
|
|
21743
|
-
function readJson(path) {
|
|
21744
|
-
const text = readFileSync(path, "utf8");
|
|
21745
|
-
try {
|
|
21746
|
-
return JSON.parse(text);
|
|
21747
|
-
} catch (e) {
|
|
21748
|
-
throw new Error(`${path}: not valid JSON \u2014 ${e.message}`);
|
|
21749
|
-
}
|
|
21750
|
-
}
|
|
21751
|
-
function writeJson(path, value) {
|
|
21752
|
-
mkdirSync(dirname(path), { recursive: true });
|
|
21753
|
-
writeFileSync(path, JSON.stringify(value, null, 2) + "\n");
|
|
21754
|
-
}
|
|
21755
|
-
var profilePath = (root) => join(root, QUALITY_DIR, PROFILE_FILE);
|
|
21756
|
-
var overlayPath = (root) => join(root, QUALITY_DIR, OVERLAY_FILE);
|
|
21757
|
-
var auditsDir = (root) => join(root, QUALITY_DIR, AUDITS_DIR);
|
|
21758
|
-
var auditDir = (root, auditId) => join(auditsDir(root), auditId);
|
|
21759
|
-
function loadProfile(root) {
|
|
21760
|
-
const path = profilePath(root);
|
|
21761
|
-
return existsSync(path) ? readJson(path) : null;
|
|
21762
|
-
}
|
|
21763
|
-
function loadOverlay(root) {
|
|
21764
|
-
const path = overlayPath(root);
|
|
21765
|
-
return existsSync(path) ? readJson(path) : null;
|
|
21766
|
-
}
|
|
21767
|
-
|
|
21768
|
-
// ../../../../../packages/schema/src/cli/kritik-audit.ts
|
|
21769
|
-
var SCORES_FILE = "scores.json";
|
|
21770
|
-
var FINDINGS_FILE = "findings.json";
|
|
21771
|
-
var MATRIX_FILE = "matrix.json";
|
|
21772
|
-
var scoresPath = (root, auditId) => join2(auditDir(root, auditId), SCORES_FILE);
|
|
21773
|
-
var findingsPath = (root, auditId) => join2(auditDir(root, auditId), FINDINGS_FILE);
|
|
21774
|
-
var matrixPath = (root, auditId) => join2(auditDir(root, auditId), MATRIX_FILE);
|
|
21775
|
-
function listAuditIds(root) {
|
|
21776
|
-
const dir = auditsDir(root);
|
|
21777
|
-
if (!existsSync2(dir)) return [];
|
|
21778
|
-
return readdirSync(dir).filter((name) => statSync(join2(dir, name)).isDirectory()).sort();
|
|
21779
|
-
}
|
|
21780
|
-
function newestAuditId(root) {
|
|
21781
|
-
const dir = auditsDir(root);
|
|
21782
|
-
if (!existsSync2(dir)) throw new Error(`no audits directory at ${dir}`);
|
|
21783
|
-
const ids = listAuditIds(root);
|
|
21784
|
-
if (ids.length === 0) throw new Error(`no audits found under ${dir}`);
|
|
21785
|
-
return ids[ids.length - 1];
|
|
21786
|
-
}
|
|
21787
|
-
function loadScores(root, auditId) {
|
|
21788
|
-
const path = scoresPath(root, auditId);
|
|
21789
|
-
if (!existsSync2(path)) throw new Error(`no ${SCORES_FILE} at ${path}`);
|
|
21790
|
-
const file2 = readJson(path);
|
|
21791
|
-
return { ...file2, assessments: Array.isArray(file2.assessments) ? file2.assessments : [] };
|
|
21792
|
-
}
|
|
21793
|
-
function loadScoresOrEmpty(root, auditId) {
|
|
21794
|
-
return existsSync2(scoresPath(root, auditId)) ? loadScores(root, auditId) : { audit_id: auditId, assessments: [] };
|
|
21795
|
-
}
|
|
21796
|
-
function loadFindings(root, auditId) {
|
|
21797
|
-
const path = findingsPath(root, auditId);
|
|
21798
|
-
if (!existsSync2(path)) return { audit_id: auditId, findings: [] };
|
|
21799
|
-
const file2 = readJson(path);
|
|
21800
|
-
return { ...file2, findings: Array.isArray(file2.findings) ? file2.findings : [] };
|
|
21801
|
-
}
|
|
21802
|
-
function saveScores(root, auditId, file2) {
|
|
21803
|
-
writeJson(scoresPath(root, auditId), file2);
|
|
21804
|
-
}
|
|
21805
|
-
function saveFindings(root, auditId, file2) {
|
|
21806
|
-
writeJson(findingsPath(root, auditId), file2);
|
|
21807
|
-
}
|
|
21808
|
-
function requireProfile(root) {
|
|
21809
|
-
const profile = loadProfile(root);
|
|
21810
|
-
if (!profile) {
|
|
21811
|
-
throw new Error(
|
|
21812
|
-
`no profile at ${join2(root, QUALITY_DIR, "profile.json")} \u2014 pick this project's surfaces first (\`arkaik kritik profile\`, or the plugin's init-profile.js).`
|
|
21813
|
-
);
|
|
21814
|
-
}
|
|
21815
|
-
return profile;
|
|
21816
|
-
}
|
|
21817
|
-
function loadQualitySection(root, auditId, library, scores = loadScores(root, auditId)) {
|
|
21818
|
-
const findings = loadFindings(root, auditId);
|
|
21819
|
-
return {
|
|
21820
|
-
framework_version: scores.framework_version ?? library.version,
|
|
21821
|
-
profile: requireProfile(root),
|
|
21822
|
-
assessments: scores.assessments,
|
|
21823
|
-
findings: findings.findings
|
|
21824
|
-
};
|
|
21825
|
-
}
|
|
21826
|
-
function stripDerived(finding) {
|
|
21827
|
-
const { severity: _severity, priority: _priority, ...rest } = finding;
|
|
21828
|
-
void _severity;
|
|
21829
|
-
void _priority;
|
|
21830
|
-
return rest;
|
|
21831
|
-
}
|
|
21832
|
-
function requireAudit(root, auditId) {
|
|
21833
|
-
if (!listAuditIds(root).includes(auditId)) {
|
|
21834
|
-
throw new Error(`no audit "${auditId}" under ${auditsDir(root)}`);
|
|
21835
|
-
}
|
|
21836
|
-
}
|
|
21837
|
-
function loadCurrentQualitySection(root, library) {
|
|
21838
|
-
const auditIds = listAuditIds(root);
|
|
21839
|
-
if (auditIds.length === 0) return void 0;
|
|
21840
|
-
const profile = loadProfile(root);
|
|
21841
|
-
if (!profile) return void 0;
|
|
21842
|
-
return mergeAudits(root, auditIds, library, profile);
|
|
21843
|
-
}
|
|
21844
|
-
function loadQualitySectionThrough(root, auditId, library) {
|
|
21845
|
-
requireAudit(root, auditId);
|
|
21846
|
-
const auditIds = listAuditIds(root);
|
|
21847
|
-
return mergeAudits(root, auditIds.slice(0, auditIds.indexOf(auditId) + 1), library, requireProfile(root));
|
|
21848
|
-
}
|
|
21849
|
-
function mergeAudits(root, auditIds, library, profile) {
|
|
21850
|
-
const cells = /* @__PURE__ */ new Map();
|
|
21851
|
-
const findings = [];
|
|
21852
|
-
let frameworkVersion;
|
|
21853
|
-
for (const id of auditIds) {
|
|
21854
|
-
const scores = loadScoresOrEmpty(root, id);
|
|
21855
|
-
if (typeof scores.framework_version === "string") frameworkVersion = scores.framework_version;
|
|
21856
|
-
for (const assessment of scores.assessments) {
|
|
21857
|
-
cells.set(`${assessment.criterion_id}\0${assessment.surface}`, assessment);
|
|
21858
|
-
}
|
|
21859
|
-
for (const finding of loadFindings(root, id).findings) findings.push(stripDerived(finding));
|
|
21860
|
-
}
|
|
21861
|
-
return {
|
|
21862
|
-
framework_version: frameworkVersion ?? library.version,
|
|
21863
|
-
library,
|
|
21864
|
-
profile,
|
|
21865
|
-
assessments: [...cells.values()],
|
|
21866
|
-
findings
|
|
21867
|
-
};
|
|
21868
|
-
}
|
|
21869
|
-
function scopedAuditTarget(root, since, month, requested, recorded = []) {
|
|
21870
|
-
const known = listAuditIds(root);
|
|
21871
|
-
const newest = known[known.length - 1];
|
|
21872
|
-
const open = newest !== void 0 && newest !== since && !recorded.includes(newest) && loadScoresOrEmpty(root, newest).scope?.since === since ? newest : void 0;
|
|
21873
|
-
return scopedAuditId({ since, month, requested, known, recorded, open });
|
|
21874
|
-
}
|
|
21875
|
-
function declaredScopeSince(auditId, recorded) {
|
|
21876
|
-
if (recorded.includes(auditId)) {
|
|
21877
|
-
throw new Error(
|
|
21878
|
-
`"${auditId}" is already recorded, so declaring it scoped would re-record that reading as a partial one. If you re-scored inside the audit a scope was measured from, move those scores into an audit of their own. If "${auditId}" really is a scoped re-audit recorded without its marker, add "scope": { "since": "<the audit it followed>" } to its scores.json and record it again.`
|
|
21879
|
-
);
|
|
21880
|
-
}
|
|
21881
|
-
const before = recorded.filter((id) => id < auditId).sort();
|
|
21882
|
-
const since = before[before.length - 1];
|
|
21883
|
-
if (since === void 0) {
|
|
21884
|
-
throw new Error(
|
|
21885
|
-
`no recorded audit sorts before "${auditId}" \u2014 a scoped re-audit is measured from one, and audits merge latest-wins in id order.`
|
|
21886
|
-
);
|
|
21887
|
-
}
|
|
21888
|
-
return since;
|
|
21889
|
-
}
|
|
21890
|
-
function auditOrderNote(root, auditId) {
|
|
21891
|
-
const plan = planIdOfPartId2(auditId);
|
|
21892
|
-
const later = listAuditIds(root).filter((id) => id > auditId && (plan === null || planIdOfPartId2(id) !== plan));
|
|
21893
|
-
if (later.length === 0) return void 0;
|
|
21894
|
-
return `"${auditId}" sorts before ${later.map((id) => `"${id}"`).join(", ")} \u2014 audits merge latest-wins in id order, so for any cell ${later.length === 1 ? "that audit" : "those audits"} also hold${later.length === 1 ? "s" : ""}, the later score wins. Name a new audit so it sorts last.`;
|
|
21895
|
-
}
|
|
21896
|
-
function computeAuditMatrix(root, auditId, library) {
|
|
21897
|
-
const scores = loadScores(root, auditId);
|
|
21898
|
-
const section = loadQualitySection(root, auditId, library, scores);
|
|
21899
|
-
const matrix = deriveQualityMatrix2({ quality: section }, library);
|
|
21900
|
-
const file2 = {
|
|
21901
|
-
audit_id: auditId,
|
|
21902
|
-
commit: scores.commit,
|
|
21903
|
-
framework_version: section.framework_version,
|
|
21904
|
-
matrix: matrix.matrix,
|
|
21905
|
-
overall: matrix.overall,
|
|
21906
|
-
finding_counts: matrix.finding_counts
|
|
21907
|
-
};
|
|
21908
|
-
writeJson(matrixPath(root, auditId), file2);
|
|
21909
|
-
return { section, matrix, file: file2 };
|
|
21910
|
-
}
|
|
21911
|
-
function locateFinding(root, id) {
|
|
21912
|
-
for (const auditId of [...listAuditIds(root)].reverse()) {
|
|
21913
|
-
const file2 = loadFindings(root, auditId);
|
|
21914
|
-
const finding = file2.findings.find((candidate) => candidate.id === id);
|
|
21915
|
-
if (finding) return { auditId, file: file2, finding };
|
|
21916
|
-
}
|
|
21917
|
-
return void 0;
|
|
22235
|
+
function newestAuditId(root) {
|
|
22236
|
+
const dir = auditsDir(root);
|
|
22237
|
+
if (!existsSync2(dir)) throw new Error(`no audits directory at ${dir}`);
|
|
22238
|
+
const ids = listAuditIds(root);
|
|
22239
|
+
if (ids.length === 0) throw new Error(`no audits found under ${dir}`);
|
|
22240
|
+
return ids[ids.length - 1];
|
|
21918
22241
|
}
|
|
21919
|
-
|
|
21920
|
-
|
|
21921
|
-
|
|
21922
|
-
|
|
21923
|
-
|
|
21924
|
-
|
|
21925
|
-
|
|
21926
|
-
|
|
21927
|
-
|
|
21928
|
-
|
|
21929
|
-
|
|
21930
|
-
|
|
21931
|
-
|
|
21932
|
-
|
|
21933
|
-
|
|
21934
|
-
|
|
21935
|
-
|
|
21936
|
-
|
|
21937
|
-
|
|
21938
|
-
|
|
21939
|
-
}
|
|
21940
|
-
|
|
21941
|
-
|
|
21942
|
-
|
|
21943
|
-
|
|
21944
|
-
|
|
21945
|
-
|
|
21946
|
-
description: "Lifecycle status as stored: the current vocabulary, or a legacy id (prioritized, blocked) accepted from pre-v3 bundles and migrated on load."
|
|
21947
|
-
});
|
|
21948
|
-
var PlatformSchema2 = external_exports.enum(PLATFORM_IDS2).meta({
|
|
21949
|
-
id: "Platform",
|
|
21950
|
-
description: "Target platform."
|
|
21951
|
-
});
|
|
21952
|
-
var EdgeTypeSchema2 = external_exports.enum(EDGE_TYPE_IDS2).meta({
|
|
21953
|
-
id: "EdgeType",
|
|
21954
|
-
description: "composes = structural hierarchy (flow\u2194view). calls = view/flow \u2192 api-endpoint, or api-endpoint \u2192 api-endpoint (endpoint fan-out to internal/external APIs). displays = view \u2192 data-model. queries = api-endpoint \u2192 data-model. covers = acceptance \u2192 view/flow (which surface the acceptance is proven on)."
|
|
21955
|
-
});
|
|
21956
|
-
var ValueTierSchema2 = external_exports.enum(VALUE_TIER_IDS2).meta({
|
|
21957
|
-
id: "ValueTier",
|
|
21958
|
-
description: "Bain value pyramid tier."
|
|
21959
|
-
});
|
|
21960
|
-
var ValueSchema2 = external_exports.enum(VALUE_IDS2).meta({
|
|
21961
|
-
id: "Value",
|
|
21962
|
-
description: "A Bain B2C Elements-of-Value element served by an acceptance (spec \xA73.2)."
|
|
21963
|
-
});
|
|
21964
|
-
var DecisionStatusSchema2 = external_exports.enum(DECISION_STATUS_IDS2).meta({
|
|
21965
|
-
id: "DecisionStatus",
|
|
21966
|
-
description: "Decision nodes only: proposed \u2192 approved (agreed, not yet reality) \u2192 enacted (in effect); terminal: rejected, deprecated, superseded. Not a lifecycle status \u2014 the node's status field is kept in sync (proposed\u2192discovery, approved\u2192backlog, enacted\u2192live, terminals\u2192archived)."
|
|
21967
|
-
});
|
|
21968
|
-
|
|
21969
|
-
// ../../../../../packages/schema/src/quality-schemas.ts
|
|
21970
|
-
var GradeSchema2 = external_exports.enum(["A", "B", "C", "D", "E"]);
|
|
21971
|
-
var KritikScalesSchema2 = external_exports.object({
|
|
21972
|
-
grades: external_exports.partialRecord(GradeSchema2, external_exports.number()).optional(),
|
|
21973
|
-
severity_buckets: external_exports.partialRecord(external_exports.enum(["critical", "high", "medium", "low", "info"]), external_exports.tuple([external_exports.number(), external_exports.number()])).optional(),
|
|
21974
|
-
caps: external_exports.object({ critical_open: GradeSchema2.optional(), high_open: GradeSchema2.optional() }).catchall(external_exports.unknown()).optional()
|
|
21975
|
-
}).catchall(external_exports.unknown()).meta({
|
|
21976
|
-
id: "KritikScales",
|
|
21977
|
-
description: "Overridable maturity/severity/grade scales carried by a criteria pack. Absent entries fall back to the framework defaults (packages/kritik-library/SPEC.md \xA7 4)."
|
|
21978
|
-
});
|
|
21979
|
-
var KritikReferenceSchema2 = external_exports.object({ title: external_exports.string(), anchor: external_exports.string().optional(), url: external_exports.string().optional() }).catchall(external_exports.unknown()).meta({ id: "KritikReference", description: "A stable external anchor behind a criterion (OWASP control, GDPR article, WCAG SC\u2026)." });
|
|
21980
|
-
var KritikIssueTemplateSchema2 = external_exports.object({
|
|
21981
|
-
title_template: external_exports.string().optional(),
|
|
21982
|
-
labels: external_exports.array(external_exports.string()).optional(),
|
|
21983
|
-
body_skeleton: external_exports.string().optional()
|
|
21984
|
-
}).catchall(external_exports.unknown()).meta({ id: "KritikIssueTemplate", description: "Per-criterion issue skeleton \u2014 what `arkaik kritik issue` prefills." });
|
|
21985
|
-
var KritikDomainSchema2 = external_exports.object({ code: external_exports.string(), name: external_exports.string(), description: external_exports.string().optional() }).catchall(external_exports.unknown()).meta({ id: "KritikDomain", description: "A top-level criteria category owning a roll-up row in the matrix." });
|
|
21986
|
-
var KritikCriterionSchema2 = external_exports.object({
|
|
21987
|
-
id: external_exports.string().meta({ description: "Stable identifier, `<DOMAIN>-NN`. Never redefined \u2014 retired via superseded_by." }),
|
|
21988
|
-
domain: external_exports.string(),
|
|
21989
|
-
subcategory: external_exports.string().optional(),
|
|
21990
|
-
name: external_exports.string().optional(),
|
|
21991
|
-
question: external_exports.string().optional(),
|
|
21992
|
-
definition: external_exports.string().optional(),
|
|
21993
|
-
rationale: external_exports.string().optional(),
|
|
21994
|
-
applies_to: external_exports.array(external_exports.string()).optional().meta({ description: "Surface ids where the criterion is meaningful; absence means N/A." }),
|
|
21995
|
-
level_anchors: external_exports.record(external_exports.string(), external_exports.string()).optional().meta({ description: "Observable descriptions per maturity level, keyed l0\u2026l4." }),
|
|
21996
|
-
default_impact: external_exports.number().optional(),
|
|
21997
|
-
weight: external_exports.number().optional().meta({ description: "Weight in the domain roll-up (1\u20133; 3 = load-bearing). Absent means 1." }),
|
|
21998
|
-
references: external_exports.array(KritikReferenceSchema2).optional(),
|
|
21999
|
-
checklist: external_exports.array(external_exports.string()).optional(),
|
|
22000
|
-
signals: external_exports.array(external_exports.string()).optional().meta({ description: "Mechanically checkable monitoring hooks run between audits." }),
|
|
22001
|
-
remediation: external_exports.string().optional(),
|
|
22002
|
-
issue: KritikIssueTemplateSchema2.optional(),
|
|
22003
|
-
superseded_by: external_exports.string().optional()
|
|
22004
|
-
}).catchall(external_exports.unknown()).meta({ id: "KritikCriterion", description: "The atomic auditable unit (packages/kritik-library/SPEC.md \xA7 5)." });
|
|
22005
|
-
var KritikLibrarySchema2 = external_exports.object({
|
|
22006
|
-
version: external_exports.string().meta({ description: "Semver of the pack; matrices are comparable only within a major." }),
|
|
22007
|
-
domains: external_exports.array(KritikDomainSchema2),
|
|
22008
|
-
criteria: external_exports.array(KritikCriterionSchema2),
|
|
22009
|
-
scales: KritikScalesSchema2.optional()
|
|
22010
|
-
}).catchall(external_exports.unknown()).meta({
|
|
22011
|
-
id: "KritikLibrary",
|
|
22012
|
-
description: "A versioned criteria pack. Embedded on export; repos may instead pin it as a sidecar file."
|
|
22013
|
-
});
|
|
22014
|
-
var SurfaceDefSchema2 = external_exports.object({
|
|
22015
|
-
id: external_exports.string(),
|
|
22016
|
-
title: external_exports.string(),
|
|
22017
|
-
platform: PlatformSchema2.optional().meta({
|
|
22018
|
-
description: "Optional bridge to PLATFORM_IDS where a surface is also a view-shipping platform. Surfaces are not platforms (RFC \xA7 2)."
|
|
22019
|
-
}),
|
|
22020
|
-
path: external_exports.string().optional()
|
|
22021
|
-
}).catchall(external_exports.unknown()).meta({ id: "SurfaceDef", description: "One independently assessable body of code \u2014 an audit target, chosen at install." });
|
|
22022
|
-
var QualityProfileSchema2 = external_exports.object({
|
|
22023
|
-
surfaces: external_exports.array(SurfaceDefSchema2),
|
|
22024
|
-
domain_weights: external_exports.record(external_exports.string(), external_exports.number()).optional().meta({
|
|
22025
|
-
description: "Per-domain weight in the surface roll-up, keyed by domain code. A missing weight is 1."
|
|
22026
|
-
})
|
|
22027
|
-
}).catchall(external_exports.unknown()).meta({ id: "QualityProfile", description: "The project's parameterization of the pack (RFC \xA7 6)." });
|
|
22028
|
-
var QualityAssessmentSchema2 = external_exports.object({
|
|
22029
|
-
criterion_id: external_exports.string(),
|
|
22030
|
-
surface: external_exports.string(),
|
|
22031
|
-
level: external_exports.union([external_exports.literal(0), external_exports.literal(1), external_exports.literal(2), external_exports.literal(3), external_exports.literal(4)]).meta({
|
|
22032
|
-
description: "Maturity 0\u20134. N/A is the absence of the row, never a level."
|
|
22033
|
-
}),
|
|
22034
|
-
evidence: external_exports.string().meta({ description: "file:line / config citations. A score without evidence is an opinion, not an assessment." }),
|
|
22035
|
-
audit_id: external_exports.string(),
|
|
22036
|
-
commit: external_exports.string().optional(),
|
|
22037
|
-
ts: external_exports.string()
|
|
22038
|
-
}).catchall(external_exports.unknown()).meta({ id: "QualityAssessment", description: "One (criterion \xD7 surface) score \u2014 latest wins; history lives in the journal." });
|
|
22039
|
-
var QualityFindingSchema2 = external_exports.object({
|
|
22040
|
-
id: external_exports.string(),
|
|
22041
|
-
criterion_id: external_exports.string(),
|
|
22042
|
-
surface: external_exports.string(),
|
|
22043
|
-
title: external_exports.string(),
|
|
22044
|
-
detail: external_exports.string(),
|
|
22045
|
-
evidence: external_exports.string(),
|
|
22046
|
-
impact: external_exports.number().meta({ description: "Worst plausible consequence, 1\u20135." }),
|
|
22047
|
-
likelihood: external_exports.number().meta({ description: "Probability it materializes, 1\u20135." }),
|
|
22048
|
-
cost: external_exports.enum(["S", "M", "L", "XL"]),
|
|
22049
|
-
status: external_exports.enum(["open", "resolved", "refuted", "accepted-risk"]),
|
|
22050
|
-
remediation: external_exports.string().optional(),
|
|
22051
|
-
node_ids: external_exports.array(external_exports.string()).optional().meta({ description: "Graph nodes this finding is about \u2014 the tie deliverable.shipped already uses." }),
|
|
22052
|
-
issue_url: external_exports.string().optional(),
|
|
22053
|
-
commit: external_exports.string().optional().meta({
|
|
22054
|
-
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."
|
|
22055
|
-
}),
|
|
22056
|
-
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." })
|
|
22057
|
-
}).catchall(external_exports.unknown()).meta({
|
|
22058
|
-
id: "QualityFinding",
|
|
22059
|
-
description: "One concrete defect. Severity and priority are deliberately absent \u2014 they are derived from impact \xD7 likelihood and cost (deriveQualityMatrix), so a finding can never carry a severity its own numbers disagree with."
|
|
22060
|
-
});
|
|
22061
|
-
var QualitySectionSchema2 = external_exports.object({
|
|
22062
|
-
framework_version: external_exports.string(),
|
|
22063
|
-
library: KritikLibrarySchema2.optional(),
|
|
22064
|
-
profile: QualityProfileSchema2,
|
|
22065
|
-
assessments: external_exports.array(QualityAssessmentSchema2),
|
|
22066
|
-
findings: external_exports.array(QualityFindingSchema2)
|
|
22067
|
-
}).catchall(external_exports.unknown()).meta({
|
|
22068
|
-
id: "QualitySection",
|
|
22069
|
-
description: "The project's Kritik state (docs/rfcs/kritik.md \xA7 4.1) \u2014 profile, assessments, findings. Criteria are library content, not graph nodes; the matrix is a projection, never stored."
|
|
22070
|
-
});
|
|
22071
|
-
var KritikPlanBandSchema2 = external_exports.object({
|
|
22072
|
-
low: external_exports.number().nonnegative(),
|
|
22073
|
-
mid: external_exports.number().nonnegative(),
|
|
22074
|
-
high: external_exports.number().nonnegative()
|
|
22075
|
-
});
|
|
22076
|
-
var KritikPlanCellSchema2 = external_exports.object({ criterion_id: external_exports.string(), surface: external_exports.string() });
|
|
22077
|
-
var KritikPlanPartSchema2 = external_exports.object({
|
|
22078
|
-
domain: external_exports.string().regex(/^[A-Z0-9]{2,5}$/),
|
|
22079
|
-
surface: external_exports.string().min(1),
|
|
22080
|
-
auditId: external_exports.string(),
|
|
22081
|
-
cells: external_exports.array(KritikPlanCellSchema2).min(1),
|
|
22082
|
-
steps: external_exports.number().int().nonnegative(),
|
|
22083
|
-
estimate: external_exports.object({
|
|
22084
|
-
tokens: KritikPlanBandSchema2,
|
|
22085
|
-
usd: KritikPlanBandSchema2.nullable(),
|
|
22086
|
-
inputs: external_exports.object({
|
|
22087
|
-
P: external_exports.number(),
|
|
22088
|
-
B: external_exports.number(),
|
|
22089
|
-
c: KritikPlanBandSchema2,
|
|
22090
|
-
q: KritikPlanBandSchema2,
|
|
22091
|
-
h: KritikPlanBandSchema2,
|
|
22092
|
-
V: KritikPlanBandSchema2
|
|
22093
|
-
}),
|
|
22094
|
-
calibrated: external_exports.boolean()
|
|
22095
|
-
}).nullable(),
|
|
22096
|
-
status: external_exports.enum(["included", "deferred"]),
|
|
22097
|
-
prompt: external_exports.string()
|
|
22098
|
-
});
|
|
22099
|
-
var KritikPlanSchema2 = external_exports.object({
|
|
22100
|
-
schema: external_exports.literal(KRITIK_PLAN_SCHEMA2),
|
|
22101
|
-
planId: external_exports.string(),
|
|
22102
|
-
createdAt: external_exports.iso.datetime(),
|
|
22103
|
-
commit: external_exports.string().nullable(),
|
|
22104
|
-
frameworkVersion: external_exports.string(),
|
|
22105
|
-
tier: external_exports.string().nullable(),
|
|
22106
|
-
budgetTokens: external_exports.number().int().positive().nullable(),
|
|
22107
|
-
budgetUsd: external_exports.number().positive().nullable(),
|
|
22108
|
-
pricePerMTok: external_exports.number().positive().nullable(),
|
|
22109
|
-
parts: external_exports.array(KritikPlanPartSchema2).min(1),
|
|
22110
|
-
totals: external_exports.object({
|
|
22111
|
-
cells: external_exports.number().int(),
|
|
22112
|
-
steps: external_exports.number().int(),
|
|
22113
|
-
applicableCells: external_exports.number().int(),
|
|
22114
|
-
tokens: KritikPlanBandSchema2.nullable(),
|
|
22115
|
-
usd: KritikPlanBandSchema2.nullable()
|
|
22116
|
-
}),
|
|
22117
|
-
prompt: external_exports.string(),
|
|
22118
|
-
recordCommand: external_exports.string()
|
|
22119
|
-
}).superRefine((plan, ctx) => {
|
|
22120
|
-
if (plan.budgetUsd !== null && plan.pricePerMTok === null) {
|
|
22121
|
-
ctx.addIssue({ code: "custom", path: ["pricePerMTok"], message: "required when budgetUsd is set" });
|
|
22242
|
+
function loadScores(root, auditId) {
|
|
22243
|
+
const path = scoresPath(root, auditId);
|
|
22244
|
+
if (!existsSync2(path)) throw new Error(`no ${SCORES_FILE} at ${path}`);
|
|
22245
|
+
const file2 = readJson(path);
|
|
22246
|
+
return { ...file2, assessments: Array.isArray(file2.assessments) ? file2.assessments : [] };
|
|
22247
|
+
}
|
|
22248
|
+
function loadScoresOrEmpty(root, auditId) {
|
|
22249
|
+
return existsSync2(scoresPath(root, auditId)) ? loadScores(root, auditId) : { audit_id: auditId, assessments: [] };
|
|
22250
|
+
}
|
|
22251
|
+
function loadFindings(root, auditId) {
|
|
22252
|
+
const path = findingsPath(root, auditId);
|
|
22253
|
+
if (!existsSync2(path)) return { audit_id: auditId, findings: [] };
|
|
22254
|
+
const file2 = readJson(path);
|
|
22255
|
+
return { ...file2, findings: Array.isArray(file2.findings) ? file2.findings : [] };
|
|
22256
|
+
}
|
|
22257
|
+
function saveScores(root, auditId, file2) {
|
|
22258
|
+
writeJson(scoresPath(root, auditId), file2);
|
|
22259
|
+
}
|
|
22260
|
+
function saveFindings(root, auditId, file2) {
|
|
22261
|
+
writeJson(findingsPath(root, auditId), file2);
|
|
22262
|
+
}
|
|
22263
|
+
function requireProfile(root) {
|
|
22264
|
+
const profile = loadProfile(root);
|
|
22265
|
+
if (!profile) {
|
|
22266
|
+
throw new Error(
|
|
22267
|
+
`no profile at ${join2(root, QUALITY_DIR, "profile.json")} \u2014 pick this project's surfaces first (\`arkaik kritik profile\`, or the plugin's init-profile.js).`
|
|
22268
|
+
);
|
|
22122
22269
|
}
|
|
22123
|
-
|
|
22124
|
-
|
|
22125
|
-
|
|
22270
|
+
return profile;
|
|
22271
|
+
}
|
|
22272
|
+
function loadQualitySection(root, auditId, library, scores = loadScores(root, auditId)) {
|
|
22273
|
+
const findings = loadFindings(root, auditId);
|
|
22274
|
+
return {
|
|
22275
|
+
framework_version: scores.framework_version ?? library.version,
|
|
22276
|
+
profile: requireProfile(root),
|
|
22277
|
+
assessments: scores.assessments,
|
|
22278
|
+
findings: findings.findings
|
|
22279
|
+
};
|
|
22280
|
+
}
|
|
22281
|
+
function stripDerived(finding) {
|
|
22282
|
+
const { severity: _severity, priority: _priority, ...rest } = finding;
|
|
22283
|
+
void _severity;
|
|
22284
|
+
void _priority;
|
|
22285
|
+
return rest;
|
|
22286
|
+
}
|
|
22287
|
+
function requireAudit(root, auditId) {
|
|
22288
|
+
if (!listAuditIds(root).includes(auditId)) {
|
|
22289
|
+
throw new Error(`no audit "${auditId}" under ${auditsDir(root)}`);
|
|
22126
22290
|
}
|
|
22127
|
-
|
|
22128
|
-
|
|
22129
|
-
|
|
22130
|
-
|
|
22131
|
-
|
|
22132
|
-
|
|
22133
|
-
|
|
22134
|
-
|
|
22135
|
-
|
|
22136
|
-
|
|
22137
|
-
|
|
22138
|
-
|
|
22139
|
-
|
|
22140
|
-
|
|
22141
|
-
|
|
22142
|
-
|
|
22143
|
-
|
|
22144
|
-
|
|
22291
|
+
}
|
|
22292
|
+
function loadCurrentQualitySection(root, library) {
|
|
22293
|
+
const auditIds = listAuditIds(root);
|
|
22294
|
+
if (auditIds.length === 0) return void 0;
|
|
22295
|
+
const profile = loadProfile(root);
|
|
22296
|
+
if (!profile) return void 0;
|
|
22297
|
+
return mergeAudits(root, auditIds, library, profile);
|
|
22298
|
+
}
|
|
22299
|
+
function loadQualitySectionThrough(root, auditId, library) {
|
|
22300
|
+
requireAudit(root, auditId);
|
|
22301
|
+
const auditIds = listAuditIds(root);
|
|
22302
|
+
return mergeAudits(root, auditIds.slice(0, auditIds.indexOf(auditId) + 1), library, requireProfile(root));
|
|
22303
|
+
}
|
|
22304
|
+
function mergeAudits(root, auditIds, library, profile) {
|
|
22305
|
+
const cells = /* @__PURE__ */ new Map();
|
|
22306
|
+
const findings = [];
|
|
22307
|
+
let frameworkVersion;
|
|
22308
|
+
for (const id of auditIds) {
|
|
22309
|
+
const scores = loadScoresOrEmpty(root, id);
|
|
22310
|
+
if (typeof scores.framework_version === "string") frameworkVersion = scores.framework_version;
|
|
22311
|
+
for (const assessment of scores.assessments) {
|
|
22312
|
+
cells.set(`${assessment.criterion_id}\0${assessment.surface}`, assessment);
|
|
22145
22313
|
}
|
|
22146
|
-
|
|
22147
|
-
|
|
22148
|
-
|
|
22149
|
-
|
|
22150
|
-
|
|
22151
|
-
|
|
22152
|
-
|
|
22153
|
-
|
|
22154
|
-
|
|
22155
|
-
|
|
22156
|
-
|
|
22157
|
-
|
|
22158
|
-
const
|
|
22159
|
-
|
|
22160
|
-
|
|
22161
|
-
|
|
22162
|
-
|
|
22314
|
+
for (const finding of loadFindings(root, id).findings) findings.push(stripDerived(finding));
|
|
22315
|
+
}
|
|
22316
|
+
return {
|
|
22317
|
+
framework_version: frameworkVersion ?? library.version,
|
|
22318
|
+
library,
|
|
22319
|
+
profile,
|
|
22320
|
+
assessments: [...cells.values()],
|
|
22321
|
+
findings
|
|
22322
|
+
};
|
|
22323
|
+
}
|
|
22324
|
+
function scopedAuditTarget(root, since, month, requested, recorded = []) {
|
|
22325
|
+
const known = listAuditIds(root);
|
|
22326
|
+
const newest = known[known.length - 1];
|
|
22327
|
+
const open = newest !== void 0 && newest !== since && !recorded.includes(newest) && loadScoresOrEmpty(root, newest).scope?.since === since ? newest : void 0;
|
|
22328
|
+
return scopedAuditId({ since, month, requested, known, recorded, open });
|
|
22329
|
+
}
|
|
22330
|
+
function declaredScopeSince(auditId, recorded) {
|
|
22331
|
+
if (recorded.includes(auditId)) {
|
|
22332
|
+
throw new Error(
|
|
22333
|
+
`"${auditId}" is already recorded, so declaring it scoped would re-record that reading as a partial one. If you re-scored inside the audit a scope was measured from, move those scores into an audit of their own. If "${auditId}" really is a scoped re-audit recorded without its marker, add "scope": { "since": "<the audit it followed>" } to its scores.json and record it again.`
|
|
22334
|
+
);
|
|
22335
|
+
}
|
|
22336
|
+
const before = recorded.filter((id) => id < auditId).sort();
|
|
22337
|
+
const since = before[before.length - 1];
|
|
22338
|
+
if (since === void 0) {
|
|
22339
|
+
throw new Error(
|
|
22340
|
+
`no recorded audit sorts before "${auditId}" \u2014 a scoped re-audit is measured from one, and audits merge latest-wins in id order.`
|
|
22341
|
+
);
|
|
22342
|
+
}
|
|
22343
|
+
return since;
|
|
22344
|
+
}
|
|
22345
|
+
function auditOrderNote(root, auditId) {
|
|
22346
|
+
const plan = planIdOfPartId(auditId);
|
|
22347
|
+
const later = listAuditIds(root).filter((id) => id > auditId && (plan === null || planIdOfPartId(id) !== plan));
|
|
22348
|
+
if (later.length === 0) return void 0;
|
|
22349
|
+
return `"${auditId}" sorts before ${later.map((id) => `"${id}"`).join(", ")} \u2014 audits merge latest-wins in id order, so for any cell ${later.length === 1 ? "that audit" : "those audits"} also hold${later.length === 1 ? "s" : ""}, the later score wins. Name a new audit so it sorts last.`;
|
|
22350
|
+
}
|
|
22351
|
+
function computeAuditMatrix(root, auditId, library) {
|
|
22352
|
+
const scores = loadScores(root, auditId);
|
|
22353
|
+
const section = loadQualitySection(root, auditId, library, scores);
|
|
22354
|
+
const matrix = deriveQualityMatrix({ quality: section }, library);
|
|
22355
|
+
const file2 = {
|
|
22356
|
+
audit_id: auditId,
|
|
22357
|
+
commit: scores.commit,
|
|
22358
|
+
framework_version: section.framework_version,
|
|
22359
|
+
matrix: matrix.matrix,
|
|
22360
|
+
overall: matrix.overall,
|
|
22361
|
+
finding_counts: matrix.finding_counts
|
|
22362
|
+
};
|
|
22363
|
+
writeJson(matrixPath(root, auditId), file2);
|
|
22364
|
+
return { section, matrix, file: file2 };
|
|
22365
|
+
}
|
|
22366
|
+
function locateFinding(root, id) {
|
|
22367
|
+
for (const auditId of [...listAuditIds(root)].reverse()) {
|
|
22368
|
+
const file2 = loadFindings(root, auditId);
|
|
22369
|
+
const finding = file2.findings.find((candidate) => candidate.id === id);
|
|
22370
|
+
if (finding) return { auditId, file: file2, finding };
|
|
22371
|
+
}
|
|
22372
|
+
return void 0;
|
|
22163
22373
|
}
|
|
22164
22374
|
|
|
22165
|
-
//
|
|
22375
|
+
// ../schema/src/cli/kritik-plan.ts
|
|
22376
|
+
import { spawnSync } from "node:child_process";
|
|
22377
|
+
import { existsSync as existsSync3, readdirSync as readdirSync2, statSync as statSync2 } from "node:fs";
|
|
22378
|
+
import { join as join3 } from "node:path";
|
|
22166
22379
|
var plansDir = (root) => join3(root, QUALITY_DIR, PLAN_PLANS_DIR);
|
|
22167
22380
|
var planPath = (root, planId2) => join3(plansDir(root), `${planId2}.json`);
|
|
22168
22381
|
function listPlanIds(root) {
|
|
22169
22382
|
const dir = plansDir(root);
|
|
22170
22383
|
if (!existsSync3(dir)) return [];
|
|
22171
|
-
return readdirSync2(dir).filter((name) => name.endsWith(".json") && statSync2(join3(dir, name)).isFile()).map((name) => name.slice(0, -".json".length)).filter((id) =>
|
|
22384
|
+
return readdirSync2(dir).filter((name) => name.endsWith(".json") && statSync2(join3(dir, name)).isFile()).map((name) => name.slice(0, -".json".length)).filter((id) => isPlanId(id)).sort();
|
|
22172
22385
|
}
|
|
22173
22386
|
function readPlanFile(path) {
|
|
22174
22387
|
if (!existsSync3(path)) throw new Error(`no plan at ${path}`);
|
|
@@ -22177,7 +22390,7 @@ function readPlanFile(path) {
|
|
|
22177
22390
|
return parsed.plan;
|
|
22178
22391
|
}
|
|
22179
22392
|
function loadPlan(root, planId2) {
|
|
22180
|
-
if (!
|
|
22393
|
+
if (!isPlanId(planId2)) {
|
|
22181
22394
|
throw new Error(`"${planId2}" is not a plan id \u2014 a plan id reads YYYY-MM-zplan-DDNN, as \`arkaik kritik plan\` prints it.`);
|
|
22182
22395
|
}
|
|
22183
22396
|
const path = planPath(root, planId2);
|
|
@@ -22228,7 +22441,7 @@ var cellLabel = (cell) => `${cell.criterion_id} on ${cell.surface}`;
|
|
|
22228
22441
|
var runFlags = (parts) => parts.map((part) => `--run ${part.domain}:${part.surface}`).join(" ");
|
|
22229
22442
|
function preparePlanRecord(root, planId2, library, events) {
|
|
22230
22443
|
const plan = loadPlan(root, planId2);
|
|
22231
|
-
if (
|
|
22444
|
+
if (recordedPlans(events).some((recorded) => recorded.plan === planId2) || recordedAuditIds(events).includes(planId2)) {
|
|
22232
22445
|
throw new Error(
|
|
22233
22446
|
`plan "${planId2}" is already recorded \u2014 its reading is history, and the journal is append-only. To correct it, make a new plan for the same parts (\`arkaik kritik plan ${runFlags(plan.parts)}\`) and record that one.`
|
|
22234
22447
|
);
|
|
@@ -22268,7 +22481,7 @@ function preparePlanRecord(root, planId2, library, events) {
|
|
|
22268
22481
|
);
|
|
22269
22482
|
}
|
|
22270
22483
|
const onDiskIds = listAuditIds(root);
|
|
22271
|
-
const outsorted = included.map((part) => ({ part, later:
|
|
22484
|
+
const outsorted = included.map((part) => ({ part, later: outsortedBy(part.auditId, onDiskIds) })).filter((entry) => entry.later.length > 0);
|
|
22272
22485
|
if (outsorted.length > 0) {
|
|
22273
22486
|
throw new Error(
|
|
22274
22487
|
`plan "${planId2}" cannot be recorded \u2014 audits merge latest-wins in id order, and on any cell an audit sorting after a part also holds, that part's scores would lose the merge:
|
|
@@ -22278,13 +22491,13 @@ Make a new plan for the affected parts and score them again: \`arkaik kritik pla
|
|
|
22278
22491
|
}
|
|
22279
22492
|
const last = included.map((part) => part.auditId).sort()[included.length - 1];
|
|
22280
22493
|
const ownParts = new Set(included.map((part) => part.auditId));
|
|
22281
|
-
const recordedIds = new Set(
|
|
22494
|
+
const recordedIds = new Set(recordedAuditIds(events));
|
|
22282
22495
|
const unannounced = onDiskIds.filter((id) => id < last && !ownParts.has(id) && !recordedIds.has(id)).map((id) => ({ id, scores: loadScoresOrEmpty(root, id).assessments.length })).filter((entry) => entry.scores > 0);
|
|
22283
22496
|
if (unannounced.length > 0) {
|
|
22284
22497
|
throw new Error(
|
|
22285
22498
|
`plan "${planId2}" cannot be recorded \u2014 ${unannounced.length === 1 ? "an audit directory sorts" : "audit directories sort"} before its last part, ${unannounced.length === 1 ? "holds scores and was" : "hold scores and were"} never recorded. The record merges every audit through the plan's last part but names only the plan's own cells as re-scored, so ${unannounced.length === 1 ? "its scores" : "their scores"} would enter this plan's record unannounced:
|
|
22286
22499
|
` + unannounced.map(({ id, scores }) => {
|
|
22287
|
-
const owner =
|
|
22500
|
+
const owner = planIdOfPartId(id);
|
|
22288
22501
|
return ` ${id}: ${scores} score${scores === 1 ? "" : "s"}, never recorded` + (owner !== null ? ` (a part of plan "${owner}")` : "");
|
|
22289
22502
|
}).join("\n") + `
|
|
22290
22503
|
Record each first, or remove its scores (docs/quality/audits/<id>/scores.json), then record this plan.`
|
|
@@ -22315,7 +22528,7 @@ Record each first, or remove its scores (docs/quality/audits/<id>/scores.json),
|
|
|
22315
22528
|
);
|
|
22316
22529
|
}
|
|
22317
22530
|
const section = loadQualitySectionThrough(root, last, library);
|
|
22318
|
-
const matrix =
|
|
22531
|
+
const matrix = deriveQualityMatrix({ quality: section }, library);
|
|
22319
22532
|
const scored = included.flatMap((part) => part.cells.map((cell) => planCellKey(cell.criterion_id, cell.surface)));
|
|
22320
22533
|
const since = scopeAnchorId(events);
|
|
22321
22534
|
const scope = {
|
|
@@ -22327,7 +22540,7 @@ Record each first, or remove its scores (docs/quality/audits/<id>/scores.json),
|
|
|
22327
22540
|
scored,
|
|
22328
22541
|
coverage: coverageOf(section, library, scored.length)
|
|
22329
22542
|
};
|
|
22330
|
-
const input =
|
|
22543
|
+
const input = auditCompletedInput(matrix, {
|
|
22331
22544
|
audit_id: plan.planId,
|
|
22332
22545
|
framework_version: plan.frameworkVersion,
|
|
22333
22546
|
...plan.commit !== null ? { commit: plan.commit } : {},
|
|
@@ -22432,25 +22645,9 @@ function resolveQualityRoot(options) {
|
|
|
22432
22645
|
return options.fallback;
|
|
22433
22646
|
}
|
|
22434
22647
|
|
|
22435
|
-
//
|
|
22648
|
+
// ../schema/src/cli/weighing-files.ts
|
|
22436
22649
|
import { existsSync as existsSync7, readdirSync as readdirSync4 } from "node:fs";
|
|
22437
22650
|
import { join as join6 } from "node:path";
|
|
22438
|
-
|
|
22439
|
-
// ../../../../../packages/schema/src/weighing.ts
|
|
22440
|
-
var SCORER_KINDS2 = ["human", "agent", "rule"];
|
|
22441
|
-
function scorerRank(kind) {
|
|
22442
|
-
const index = SCORER_KINDS2.indexOf(kind);
|
|
22443
|
-
return index === -1 ? 0 : SCORER_KINDS2.length - index;
|
|
22444
|
-
}
|
|
22445
|
-
function sortWeighingAssessments(assessments) {
|
|
22446
|
-
return [...assessments].sort((a, b) => {
|
|
22447
|
-
const text = (x) => typeof x === "string" ? x : "\uFFFF";
|
|
22448
|
-
const by = (x, y) => text(x) < text(y) ? -1 : text(x) > text(y) ? 1 : 0;
|
|
22449
|
-
return by(a?.matrix, b?.matrix) || by(a?.subject, b?.subject) || by(a?.criterion, b?.criterion) || scorerRank(b?.scorer?.kind) - scorerRank(a?.scorer?.kind);
|
|
22450
|
-
});
|
|
22451
|
-
}
|
|
22452
|
-
|
|
22453
|
-
// ../../../../../packages/schema/src/cli/weighing-files.ts
|
|
22454
22651
|
var WEIGHING_DIR = "docs/weighing";
|
|
22455
22652
|
var WEIGHING_SETS_DIR = "sets";
|
|
22456
22653
|
var WEIGHING_ASSESSMENTS_DIR = "assessments";
|
|
@@ -23863,6 +24060,199 @@ function buildKritikCatalog(ctx) {
|
|
|
23863
24060
|
return { tools: tools2, handlers: handlers2 };
|
|
23864
24061
|
}
|
|
23865
24062
|
|
|
24063
|
+
// src/decide-tools.ts
|
|
24064
|
+
function requireString2(args, key) {
|
|
24065
|
+
const value = args[key];
|
|
24066
|
+
if (typeof value !== "string" || value.trim() === "") throw new ToolError(`\`${key}\` is required.`);
|
|
24067
|
+
return value;
|
|
24068
|
+
}
|
|
24069
|
+
var ISO_8601 = /^(\d{4})-(\d{2})-(\d{2})(?:T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?)?$/;
|
|
24070
|
+
function isIsoDate2(value) {
|
|
24071
|
+
const match = ISO_8601.exec(value);
|
|
24072
|
+
if (match === null || !Number.isFinite(Date.parse(value))) return false;
|
|
24073
|
+
const [year, month, day] = [Number(match[1]), Number(match[2]), Number(match[3])];
|
|
24074
|
+
const real = new Date(Date.UTC(year, month - 1, day));
|
|
24075
|
+
return real.getUTCFullYear() === year && real.getUTCMonth() === month - 1 && real.getUTCDate() === day;
|
|
24076
|
+
}
|
|
24077
|
+
function optionalString(args, key) {
|
|
24078
|
+
const value = args[key];
|
|
24079
|
+
if (value === void 0) return void 0;
|
|
24080
|
+
if (typeof value !== "string") throw new ToolError(`\`${key}\` must be a string.`);
|
|
24081
|
+
return value.trim() === "" ? void 0 : value;
|
|
24082
|
+
}
|
|
24083
|
+
function readClosed(args) {
|
|
24084
|
+
const raw = args.closed;
|
|
24085
|
+
if (raw === void 0) return void 0;
|
|
24086
|
+
if (!Array.isArray(raw)) throw new ToolError("`closed` must be an array of { option_id, reason }.");
|
|
24087
|
+
return raw.map((entry, index) => {
|
|
24088
|
+
if (typeof entry !== "object" || entry === null || Array.isArray(entry)) throw new ToolError(`closed[${index}] must be an object with an option_id.`);
|
|
24089
|
+
const { option_id, reason } = entry;
|
|
24090
|
+
if (typeof option_id !== "string" || option_id === "") throw new ToolError(`closed[${index}].option_id is required.`);
|
|
24091
|
+
if (reason !== void 0 && typeof reason !== "string") throw new ToolError(`closed[${index}].reason must be a string.`);
|
|
24092
|
+
return { option_id, reason: reason ?? "" };
|
|
24093
|
+
});
|
|
24094
|
+
}
|
|
24095
|
+
function today() {
|
|
24096
|
+
return (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
24097
|
+
}
|
|
24098
|
+
function proofSources(ctx, graph) {
|
|
24099
|
+
const bundle = graph.loaded.bundle;
|
|
24100
|
+
const embedded = bundle.quality !== void 0 && Array.isArray(bundle.quality.findings) && Array.isArray(bundle.quality.assessments) ? bundle.quality : void 0;
|
|
24101
|
+
if (ctx.qualityRoot === void 0) {
|
|
24102
|
+
return {
|
|
24103
|
+
...embedded !== void 0 ? { quality: embedded, library: resolveKritikLibrary(embedded) } : {},
|
|
24104
|
+
...bundle.weighing !== void 0 ? { weighing: bundle.weighing } : {}
|
|
24105
|
+
};
|
|
24106
|
+
}
|
|
24107
|
+
let library;
|
|
24108
|
+
let quality;
|
|
24109
|
+
let weighing;
|
|
24110
|
+
try {
|
|
24111
|
+
library = loadKritikLibrary(ctx.qualityRoot).library;
|
|
24112
|
+
quality = loadCurrentQualitySection(ctx.qualityRoot, library);
|
|
24113
|
+
} catch {
|
|
24114
|
+
}
|
|
24115
|
+
try {
|
|
24116
|
+
weighing = loadWeighingSection(ctx.qualityRoot);
|
|
24117
|
+
} catch {
|
|
24118
|
+
}
|
|
24119
|
+
quality ??= embedded;
|
|
24120
|
+
library ??= embedded === void 0 ? void 0 : resolveKritikLibrary(embedded);
|
|
24121
|
+
weighing ??= bundle.weighing;
|
|
24122
|
+
return { ...quality !== void 0 ? { quality } : {}, ...library !== void 0 ? { library } : {}, ...weighing !== void 0 ? { weighing } : {} };
|
|
24123
|
+
}
|
|
24124
|
+
function buildDecideCatalog(ctx, io) {
|
|
24125
|
+
const tools2 = [];
|
|
24126
|
+
const handlers2 = {};
|
|
24127
|
+
const tool = (definition, handler) => {
|
|
24128
|
+
tools2.push(definition);
|
|
24129
|
+
handlers2[definition.name] = handler;
|
|
24130
|
+
};
|
|
24131
|
+
tool(
|
|
24132
|
+
{
|
|
24133
|
+
name: "decide_option",
|
|
24134
|
+
description: "Record that one option was chosen to answer a stake. Creates a decision (approved by default; `status: enacted` when the work is already done) with `reason` as its context, an `impacts` edge to the stake and a `generates` edge to the option. Every other non-archived option addressing the stake is closed in the decision's `closed_options`: name a reason for each loser in `closed`, or it gets a default reason and is handed back to a human. The option must address the stake and must not be archived. A stake that already has an approved or enacted decision is refused unless `supersede: true`, which moves that decision to superseded (the journal records the change) and links the new one to it. The server stamps the author; `decided_at` defaults to today. Whether an option is selected or closed is read from the decision, never stored on the option. Works on a repo and a hosted project.",
|
|
24135
|
+
inputSchema: {
|
|
24136
|
+
type: "object",
|
|
24137
|
+
properties: {
|
|
24138
|
+
stake_id: { type: "string", description: "The stake the decision settles." },
|
|
24139
|
+
option_id: { type: "string", description: "The option chosen. It must address the stake." },
|
|
24140
|
+
reason: { type: "string", description: "Why this option: the decision's context. Required." },
|
|
24141
|
+
closed: {
|
|
24142
|
+
type: "array",
|
|
24143
|
+
description: "Why each loser lost. Options not named here are still closed, with a default reason.",
|
|
24144
|
+
items: {
|
|
24145
|
+
type: "object",
|
|
24146
|
+
properties: {
|
|
24147
|
+
option_id: { type: "string", description: "An option that addresses the same stake." },
|
|
24148
|
+
reason: { type: "string", description: "Why it lost." }
|
|
24149
|
+
},
|
|
24150
|
+
required: ["option_id"],
|
|
24151
|
+
additionalProperties: false
|
|
24152
|
+
}
|
|
24153
|
+
},
|
|
24154
|
+
title: { type: "string", description: `The decision's title. Default: Select "<option>" for "<stake>".` },
|
|
24155
|
+
status: { type: "string", enum: ["approved", "enacted"], description: "Default approved." },
|
|
24156
|
+
supersede: { type: "boolean", description: "Replace the stake's existing approved or enacted decision. Required when there is one." },
|
|
24157
|
+
decided_at: { type: "string", description: "An ISO 8601 date. Default today." }
|
|
24158
|
+
},
|
|
24159
|
+
required: ["stake_id", "option_id", "reason"],
|
|
24160
|
+
additionalProperties: false
|
|
24161
|
+
}
|
|
24162
|
+
},
|
|
24163
|
+
async (args) => {
|
|
24164
|
+
const graph = await io.load();
|
|
24165
|
+
const status = optionalString(args, "status");
|
|
24166
|
+
if (status !== void 0 && status !== "approved" && status !== "enacted") throw new ToolError("`status` must be approved or enacted.");
|
|
24167
|
+
const decidedAt = optionalString(args, "decided_at") ?? today();
|
|
24168
|
+
if (!isIsoDate2(decidedAt)) throw new ToolError("`decided_at` must be an ISO 8601 date.");
|
|
24169
|
+
if (args.supersede !== void 0 && typeof args.supersede !== "boolean") throw new ToolError("`supersede` must be a boolean.");
|
|
24170
|
+
const closed = readClosed(args);
|
|
24171
|
+
const title = optionalString(args, "title");
|
|
24172
|
+
const plan = planSelectOption({
|
|
24173
|
+
projectId: graph.project.id,
|
|
24174
|
+
stakeId: requireString2(args, "stake_id"),
|
|
24175
|
+
optionId: requireString2(args, "option_id"),
|
|
24176
|
+
reason: requireString2(args, "reason"),
|
|
24177
|
+
decidedAt,
|
|
24178
|
+
nodes: graph.nodes,
|
|
24179
|
+
edges: graph.edges,
|
|
24180
|
+
...closed !== void 0 ? { closed } : {},
|
|
24181
|
+
...title !== void 0 ? { title } : {},
|
|
24182
|
+
...status !== void 0 ? { status } : {},
|
|
24183
|
+
...args.supersede === true ? { supersede: true } : {}
|
|
24184
|
+
});
|
|
24185
|
+
if (plan.action === "refused") throw new ToolError(`Not decided: ${plan.reasons.join(" ")}`, { reasons: plan.reasons });
|
|
24186
|
+
const outcome = io.mutate(graph, plan.ops);
|
|
24187
|
+
const result = await ctx.store.persist(graph, { nodes: outcome.nodes, edges: outcome.edges, ops: plan.ops }, outcome.eventInputs);
|
|
24188
|
+
const { warnings, events } = io.unwrap(result);
|
|
24189
|
+
const decisionId = plan.decision_id;
|
|
24190
|
+
return {
|
|
24191
|
+
action: plan.action,
|
|
24192
|
+
decision_id: decisionId,
|
|
24193
|
+
decision: outcome.nodes.find((node) => node.id === decisionId),
|
|
24194
|
+
reasons: plan.reasons,
|
|
24195
|
+
ops: plan.ops,
|
|
24196
|
+
events,
|
|
24197
|
+
warnings,
|
|
24198
|
+
handToHuman: plan.handToHuman
|
|
24199
|
+
};
|
|
24200
|
+
}
|
|
24201
|
+
);
|
|
24202
|
+
tool(
|
|
24203
|
+
{
|
|
24204
|
+
name: "stake_proof",
|
|
24205
|
+
description: "Read-only. Where a stake stands, derived and never stored: its state (raised, considered, promised, verified-not-delivered, partly-addressed, addressed; null for an archived stake), the answer a decision chose, the definition of done, and one cell per platform concerned saying whether the verified half holds (an acceptance at releasing or live), the answer is delivered (live) or the verification is stale (its reverify_every_days ran out, or the Kritik criterion moved to a newer version). A requirement is read against its Kritik criterion: no open finding at its anchor and a score of at least 3 dated after the stake was raised. Pass stake_id for one stake, or leave it off for every stake with a count per state. product narrows the platforms to a product's menu; now (ISO 8601) defaults to the server's clock. Never writes. Works on a repo and a hosted project.",
|
|
24206
|
+
inputSchema: {
|
|
24207
|
+
type: "object",
|
|
24208
|
+
properties: {
|
|
24209
|
+
stake_id: { type: "string", description: "One stake. Leave off for every stake." },
|
|
24210
|
+
product: { type: "string", description: "A product id declared in the project: read the platforms through its menu. Default: all products." },
|
|
24211
|
+
now: { type: "string", description: "An ISO 8601 instant to read the expiry against. Default: the server's clock." }
|
|
24212
|
+
},
|
|
24213
|
+
additionalProperties: false
|
|
24214
|
+
}
|
|
24215
|
+
},
|
|
24216
|
+
async (args) => {
|
|
24217
|
+
const graph = await io.load();
|
|
24218
|
+
const stakeId = optionalString(args, "stake_id");
|
|
24219
|
+
const product = optionalString(args, "product");
|
|
24220
|
+
const nowArg = optionalString(args, "now");
|
|
24221
|
+
if (product !== void 0) {
|
|
24222
|
+
const known = resolveProducts(graph.project).map((entry) => entry.id);
|
|
24223
|
+
if (!known.includes(product)) {
|
|
24224
|
+
throw new ToolError(known.length === 0 ? `This project declares no products, so \`product\` "${product}" names none.` : `No product "${product}" (declared: ${known.join(", ")}).`);
|
|
24225
|
+
}
|
|
24226
|
+
}
|
|
24227
|
+
if (nowArg !== void 0 && !isIsoDate2(nowArg)) throw new ToolError("`now` must be an ISO 8601 date or date-time.");
|
|
24228
|
+
const now = nowArg !== void 0 ? new Date(nowArg) : /* @__PURE__ */ new Date();
|
|
24229
|
+
const input = {
|
|
24230
|
+
nodes: graph.nodes,
|
|
24231
|
+
edges: graph.edges,
|
|
24232
|
+
events: graph.journal,
|
|
24233
|
+
now,
|
|
24234
|
+
project: graph.project,
|
|
24235
|
+
productId: product ?? null,
|
|
24236
|
+
...proofSources(ctx, graph)
|
|
24237
|
+
};
|
|
24238
|
+
const common = { now: now.toISOString(), product: product ?? null };
|
|
24239
|
+
if (stakeId !== void 0) {
|
|
24240
|
+
const proof = deriveStakeProof({ ...input, stakeId });
|
|
24241
|
+
if (proof === null) {
|
|
24242
|
+
const found = graph.nodes.find((node) => node.id === stakeId);
|
|
24243
|
+
throw new ToolError(found === void 0 ? `No node with id "${stakeId}".` : `"${stakeId}" is a ${found.species}, not a stake.`);
|
|
24244
|
+
}
|
|
24245
|
+
return { ...common, stake: proof };
|
|
24246
|
+
}
|
|
24247
|
+
const stakes = deriveStakeProofs(input);
|
|
24248
|
+
const counts = Object.fromEntries([...STAKE_STATES, "archived"].map((state) => [state, 0]));
|
|
24249
|
+
for (const proof of stakes) counts[proof.state ?? "archived"]++;
|
|
24250
|
+
return { ...common, count: stakes.length, counts, stakes };
|
|
24251
|
+
}
|
|
24252
|
+
);
|
|
24253
|
+
return { tools: tools2, handlers: handlers2 };
|
|
24254
|
+
}
|
|
24255
|
+
|
|
23866
24256
|
// src/qualify-tools.ts
|
|
23867
24257
|
var questionText = ROUTING_QUESTIONS.map((q) => `${q.id}: ${q.question} (${Object.keys(q.answers).join(" | ")})`).join(" ");
|
|
23868
24258
|
var ANSWER_PROPERTIES = {
|
|
@@ -23884,7 +24274,7 @@ var SIGNAL_PROPERTIES = {
|
|
|
23884
24274
|
},
|
|
23885
24275
|
catalog_id: { type: "string", description: "A Kritik criterion id (requirement, risk, defect) or a value id (bug, friction, need). Defaults to an audit finding's criterion_id." }
|
|
23886
24276
|
};
|
|
23887
|
-
function
|
|
24277
|
+
function optionalString2(args, key) {
|
|
23888
24278
|
const value = args[key];
|
|
23889
24279
|
return typeof value === "string" && value !== "" ? value : void 0;
|
|
23890
24280
|
}
|
|
@@ -23912,11 +24302,11 @@ function readAnswers(args, signal) {
|
|
|
23912
24302
|
return answers;
|
|
23913
24303
|
}
|
|
23914
24304
|
function resolveSignal(args, journal) {
|
|
23915
|
-
const signalId =
|
|
24305
|
+
const signalId = optionalString2(args, "signal_id");
|
|
23916
24306
|
if (signalId === void 0) {
|
|
23917
|
-
const title =
|
|
24307
|
+
const title = optionalString2(args, "title");
|
|
23918
24308
|
if (title === void 0) throw new ToolError("Pass `signal_id` (a backlog event id) or an inline `title`.");
|
|
23919
|
-
const verbatim =
|
|
24309
|
+
const verbatim = optionalString2(args, "verbatim");
|
|
23920
24310
|
return { title, ...verbatim !== void 0 ? { verbatim } : {} };
|
|
23921
24311
|
}
|
|
23922
24312
|
const event = journal.find((candidate) => candidate.id === signalId);
|
|
@@ -23947,7 +24337,7 @@ function resolveAnchors(args, signal, nodes) {
|
|
|
23947
24337
|
return node !== void 0 && STAKE_ANCHOR_SPECIES.includes(node.species) ? [node.id] : [];
|
|
23948
24338
|
}
|
|
23949
24339
|
function resolveCatalogId(args, signal, species) {
|
|
23950
|
-
const explicit =
|
|
24340
|
+
const explicit = optionalString2(args, "catalog_id");
|
|
23951
24341
|
if (explicit !== void 0) return explicit;
|
|
23952
24342
|
return QUALITY_STAKE_SPECIES.includes(species) ? signal.criterion_id : void 0;
|
|
23953
24343
|
}
|
|
@@ -24050,7 +24440,7 @@ function buildQualifyCatalog(ctx, io) {
|
|
|
24050
24440
|
async (args) => {
|
|
24051
24441
|
const graph = await io.load();
|
|
24052
24442
|
const signal = resolveSignal(args, graph.journal);
|
|
24053
|
-
const mergeInto =
|
|
24443
|
+
const mergeInto = optionalString2(args, "merge_into");
|
|
24054
24444
|
if (mergeInto !== void 0 === (args.create === true)) {
|
|
24055
24445
|
throw new ToolError("Pass exactly one of `create: true` or `merge_into` (a stake id).");
|
|
24056
24446
|
}
|
|
@@ -24077,7 +24467,7 @@ function buildQualifyCatalog(ctx, io) {
|
|
|
24077
24467
|
} else {
|
|
24078
24468
|
const catalogId = resolveCatalogId(args, signal, routing.species);
|
|
24079
24469
|
const catalog = catalogId !== void 0 ? { source: catalogSourceForStakeSpecies(routing.species), id: catalogId } : void 0;
|
|
24080
|
-
const title =
|
|
24470
|
+
const title = optionalString2(args, "stake_title");
|
|
24081
24471
|
plan = planSignalToStake({
|
|
24082
24472
|
projectId: graph.project.id,
|
|
24083
24473
|
signal: evidenceSignal,
|
|
@@ -24225,7 +24615,7 @@ async function resolveOnBehalfOf(root, env = process.env) {
|
|
|
24225
24615
|
}
|
|
24226
24616
|
return void 0;
|
|
24227
24617
|
}
|
|
24228
|
-
function
|
|
24618
|
+
function requireString3(args, key) {
|
|
24229
24619
|
const value = args[key];
|
|
24230
24620
|
if (typeof value !== "string" || value.length === 0) throw new ToolError(`\`${key}\` is required and must be a non-empty string.`);
|
|
24231
24621
|
return value;
|
|
@@ -24237,7 +24627,7 @@ function requireInt2(args, key, min, max) {
|
|
|
24237
24627
|
}
|
|
24238
24628
|
return value;
|
|
24239
24629
|
}
|
|
24240
|
-
var
|
|
24630
|
+
var optionalString3 = (args, key) => typeof args[key] === "string" && args[key] !== "" ? args[key] : void 0;
|
|
24241
24631
|
function cellRow(cell, withProbabilities) {
|
|
24242
24632
|
return {
|
|
24243
24633
|
criterion: cell.criterion,
|
|
@@ -24369,7 +24759,7 @@ function buildWeighingCatalog(ctx) {
|
|
|
24369
24759
|
const graph = await load2();
|
|
24370
24760
|
const section = sectionOf(graph);
|
|
24371
24761
|
const nodes = graph.nodes;
|
|
24372
|
-
const matrixId =
|
|
24762
|
+
const matrixId = optionalString3(args, "matrix") ?? defaultMatrixFor(nodes, optionalString3(args, "subject"));
|
|
24373
24763
|
const view = deriveWeighing(nodes, section, matrixId);
|
|
24374
24764
|
if (view === void 0) throw new ToolError(`No usable matrix "${matrixId}" (unknown, or a draft \u2014 a draft feeds no roll-up). The built-in ones are "${VALUE_MATRIX_ID}" and "${STAKE_MATRIX_ID}".`);
|
|
24375
24765
|
const judgesStakes = view.matrix.subjects.kind === "query" && view.matrix.subjects.species === "stake";
|
|
@@ -24388,7 +24778,7 @@ function buildWeighingCatalog(ctx) {
|
|
|
24388
24778
|
if (view.totals.assessed === 0) {
|
|
24389
24779
|
notes.push(judgesStakes ? "Nothing has been assessed yet \u2014 a stake is never seeded, so every cell is blank until someone scores it." : "Nothing has been assessed yet \u2014 every claimed value is seeded at +1 (confidence 0), a guess.");
|
|
24390
24780
|
}
|
|
24391
|
-
const subject =
|
|
24781
|
+
const subject = optionalString3(args, "subject");
|
|
24392
24782
|
if (subject !== void 0) {
|
|
24393
24783
|
const promise2 = view.promises.find((candidate) => candidate.node_id === subject);
|
|
24394
24784
|
if (promise2 === void 0) throw new ToolError(`"${subject}" is not a subject of matrix "${matrixId}" (it judges ${view.matrix.subjects.kind === "query" ? `${view.matrix.subjects.species} nodes` : "a listed set"}).`);
|
|
@@ -24411,9 +24801,9 @@ function buildWeighingCatalog(ctx) {
|
|
|
24411
24801
|
...notes.length > 0 ? { notes } : {}
|
|
24412
24802
|
};
|
|
24413
24803
|
}
|
|
24414
|
-
const sort =
|
|
24804
|
+
const sort = optionalString3(args, "sort") ?? "served";
|
|
24415
24805
|
if (!["served", "cost", "positioned", "title"].includes(sort)) throw new ToolError("`sort` must be served, cost, positioned or title.");
|
|
24416
|
-
const filter =
|
|
24806
|
+
const filter = optionalString3(args, "filter");
|
|
24417
24807
|
if (filter !== void 0 && !FILTERS.includes(filter)) throw new ToolError(`\`filter\` must be one of ${FILTERS.join(", ")}.`);
|
|
24418
24808
|
const limit = typeof args.limit === "number" && Number.isInteger(args.limit) ? Math.min(Math.max(args.limit, 1), 200) : 25;
|
|
24419
24809
|
const elementRows = (v) => v.set.criteria.map((criterion) => ({ criterion, mass: v.elements[criterion.id] })).filter(({ mass }) => mass.promised > 0 || mass.cost > 0).sort((a, b) => b.mass.promised - a.mass.promised).map(({ criterion, mass }) => ({
|
|
@@ -24434,7 +24824,7 @@ function buildWeighingCatalog(ctx) {
|
|
|
24434
24824
|
cost: round2(v.totals.cost),
|
|
24435
24825
|
guesswork: { promised: round2(v.totals.guesswork.promised), kept: round2(v.totals.guesswork.kept), cost: round2(v.totals.guesswork.cost) }
|
|
24436
24826
|
});
|
|
24437
|
-
const
|
|
24827
|
+
const rowsOf4 = (v) => {
|
|
24438
24828
|
const matching = v.promises.filter((promise2) => filter === void 0 || matchesFilter(promise2, filter));
|
|
24439
24829
|
const ordered2 = sortPromises(matching, sort);
|
|
24440
24830
|
return { ordered: ordered2, rows: ordered2.slice(0, limit).map((promise2) => promiseRow(promise2, false, false, nodesById.get(promise2.node_id))) };
|
|
@@ -24451,7 +24841,7 @@ function buildWeighingCatalog(ctx) {
|
|
|
24451
24841
|
const groups = [...members.values()].sort((a, b) => rank(a.group) - rank(b.group)).map(({ group, ids }) => {
|
|
24452
24842
|
const groupView = deriveWeighing(nodes.filter((node) => node.species !== "stake" || ids.has(node.id)), section, matrixId);
|
|
24453
24843
|
if (groupView === void 0) throw new ToolError(`No usable matrix "${matrixId}".`);
|
|
24454
|
-
const { ordered: ordered2, rows: rows2 } =
|
|
24844
|
+
const { ordered: ordered2, rows: rows2 } = rowsOf4(groupView);
|
|
24455
24845
|
return {
|
|
24456
24846
|
stake_species: group.stake_species,
|
|
24457
24847
|
...group.felt !== void 0 ? { felt: group.felt } : {},
|
|
@@ -24471,7 +24861,7 @@ function buildWeighingCatalog(ctx) {
|
|
|
24471
24861
|
...notes.length > 0 ? { notes } : {}
|
|
24472
24862
|
};
|
|
24473
24863
|
}
|
|
24474
|
-
const { ordered, rows } =
|
|
24864
|
+
const { ordered, rows } = rowsOf4(view);
|
|
24475
24865
|
return {
|
|
24476
24866
|
matrix: { id: view.matrix.id, set: view.matrix.set, set_version: view.set.version },
|
|
24477
24867
|
positioning,
|
|
@@ -24509,12 +24899,12 @@ function buildWeighingCatalog(ctx) {
|
|
|
24509
24899
|
}
|
|
24510
24900
|
},
|
|
24511
24901
|
async (args) => {
|
|
24512
|
-
const subject =
|
|
24513
|
-
const criterion =
|
|
24902
|
+
const subject = requireString3(args, "subject");
|
|
24903
|
+
const criterion = requireString3(args, "criterion");
|
|
24514
24904
|
const level = args.level;
|
|
24515
24905
|
if (typeof level !== "number" || !Number.isInteger(level)) throw new ToolError("`level` is required and must be an integer (the scale is -3 to +3).");
|
|
24516
24906
|
const confidence = requireInt2(args, "confidence", 0, 3);
|
|
24517
|
-
const evidence =
|
|
24907
|
+
const evidence = optionalString3(args, "evidence");
|
|
24518
24908
|
if (confidence > 0 && (evidence === void 0 || evidence.trim() === "")) {
|
|
24519
24909
|
throw new ToolError("`evidence` is required above confidence 0 \u2014 a score without a citation is an opinion, not an assessment. Say what you read, or score at confidence 0.");
|
|
24520
24910
|
}
|
|
@@ -24525,12 +24915,12 @@ function buildWeighingCatalog(ctx) {
|
|
|
24525
24915
|
criterion,
|
|
24526
24916
|
level,
|
|
24527
24917
|
confidence,
|
|
24528
|
-
...
|
|
24918
|
+
...optionalString3(args, "matrix") !== void 0 ? { matrix: optionalString3(args, "matrix") } : {},
|
|
24529
24919
|
...evidence !== void 0 ? { evidence } : {},
|
|
24530
24920
|
...refs !== void 0 && refs.length > 0 ? { refs } : {},
|
|
24531
|
-
...
|
|
24532
|
-
...
|
|
24533
|
-
...
|
|
24921
|
+
...optionalString3(args, "model") !== void 0 ? { model: optionalString3(args, "model") } : {},
|
|
24922
|
+
...optionalString3(args, "run") !== void 0 ? { run: optionalString3(args, "run") } : {},
|
|
24923
|
+
...optionalString3(args, "commit") !== void 0 ? { commit: optionalString3(args, "commit") } : {},
|
|
24534
24924
|
// Passed as given: a value off 0..1 is the planner's to refuse, with the reason.
|
|
24535
24925
|
...args.p_serves !== void 0 ? { p_serves: args.p_serves } : {},
|
|
24536
24926
|
...args.p_costs !== void 0 ? { p_costs: args.p_costs } : {}
|
|
@@ -24609,7 +24999,7 @@ function buildWeighingCatalog(ctx) {
|
|
|
24609
24999
|
},
|
|
24610
25000
|
async (args) => {
|
|
24611
25001
|
if (!Array.isArray(args.elements) || args.elements.length === 0) throw new ToolError("`elements` is required: at least one element of value.");
|
|
24612
|
-
const status =
|
|
25002
|
+
const status = optionalString3(args, "status") ?? "draft";
|
|
24613
25003
|
if (status !== "draft" && status !== "active") throw new ToolError("`status` must be draft or active.");
|
|
24614
25004
|
const graph = await load2();
|
|
24615
25005
|
const section = sectionOf(graph);
|
|
@@ -24618,7 +25008,7 @@ function buildWeighingCatalog(ctx) {
|
|
|
24618
25008
|
const set2 = {
|
|
24619
25009
|
id: POSITIONING_SET_ID,
|
|
24620
25010
|
version: "1.0.0",
|
|
24621
|
-
title:
|
|
25011
|
+
title: optionalString3(args, "title") ?? "Positioning",
|
|
24622
25012
|
subject: ruler.subject,
|
|
24623
25013
|
scale: weighingScaleOf(ruler),
|
|
24624
25014
|
role: "positioning",
|
|
@@ -24669,7 +25059,7 @@ async function load(ctx) {
|
|
|
24669
25059
|
journal: graph.journal
|
|
24670
25060
|
};
|
|
24671
25061
|
}
|
|
24672
|
-
function
|
|
25062
|
+
function requireString4(args, key) {
|
|
24673
25063
|
const value = args[key];
|
|
24674
25064
|
if (typeof value !== "string" || value.length === 0) {
|
|
24675
25065
|
throw new ToolError(`\`${key}\` is required and must be a non-empty string.`);
|
|
@@ -24688,7 +25078,7 @@ function findNode(nodes, nodeId) {
|
|
|
24688
25078
|
if (!node) throw new ToolError(`No node with id "${nodeId}".`);
|
|
24689
25079
|
return node;
|
|
24690
25080
|
}
|
|
24691
|
-
function nodeSummary(node) {
|
|
25081
|
+
function nodeSummary(node, graph) {
|
|
24692
25082
|
const base = { id: node.id, title: node.title, species: node.species, status: node.status, platforms: node.platforms };
|
|
24693
25083
|
if (node.species === "stake") {
|
|
24694
25084
|
const md = node.metadata;
|
|
@@ -24702,6 +25092,9 @@ function nodeSummary(node) {
|
|
|
24702
25092
|
...md?.frequency !== void 0 ? { frequency: md.frequency } : {}
|
|
24703
25093
|
};
|
|
24704
25094
|
}
|
|
25095
|
+
if (node.species === "option") {
|
|
25096
|
+
return graph ? { ...base, answer_types: answerTypesOf(node.id, graph.nodes, graph.edges) } : base;
|
|
25097
|
+
}
|
|
24705
25098
|
if (node.species !== "acceptance") return base;
|
|
24706
25099
|
const platform_statuses = Object.fromEntries(
|
|
24707
25100
|
node.platforms.map((platform) => [platform, resolvePlatformStatus(node, platform)])
|
|
@@ -24719,7 +25112,7 @@ function unwrap(result) {
|
|
|
24719
25112
|
}
|
|
24720
25113
|
var UPDATABLE_NODE_FIELDS = /* @__PURE__ */ new Set(["title", "description", "status", "platforms", "metadata"]);
|
|
24721
25114
|
function requirePlatform(args) {
|
|
24722
|
-
const raw =
|
|
25115
|
+
const raw = requireString4(args, "platform");
|
|
24723
25116
|
const platform = PLATFORM_IDS.find((id) => id === raw);
|
|
24724
25117
|
if (platform === void 0) {
|
|
24725
25118
|
throw new ToolError(`"${raw}" is not a platform (expected one of: ${PLATFORM_IDS.join(", ")}).`);
|
|
@@ -24727,7 +25120,7 @@ function requirePlatform(args) {
|
|
|
24727
25120
|
return platform;
|
|
24728
25121
|
}
|
|
24729
25122
|
function requireScreenshotForm(args) {
|
|
24730
|
-
const raw =
|
|
25123
|
+
const raw = requireString4(args, "form");
|
|
24731
25124
|
if (raw === "url" || raw === "path" || raw === "data") return raw;
|
|
24732
25125
|
throw new ToolError(`"${raw}" is not a screenshot form (url, path or data).`);
|
|
24733
25126
|
}
|
|
@@ -24811,7 +25204,7 @@ ${node.description ?? ""}`.toLowerCase();
|
|
|
24811
25204
|
}
|
|
24812
25205
|
return true;
|
|
24813
25206
|
});
|
|
24814
|
-
return { total: matches.length, nodes: matches.slice(0, limit).map(nodeSummary) };
|
|
25207
|
+
return { total: matches.length, nodes: matches.slice(0, limit).map((node) => nodeSummary(node, { nodes, edges })) };
|
|
24815
25208
|
}
|
|
24816
25209
|
);
|
|
24817
25210
|
tool(
|
|
@@ -24826,7 +25219,7 @@ ${node.description ?? ""}`.toLowerCase();
|
|
|
24826
25219
|
}
|
|
24827
25220
|
},
|
|
24828
25221
|
async (args) => {
|
|
24829
|
-
const nodeId =
|
|
25222
|
+
const nodeId = requireString4(args, "node_id");
|
|
24830
25223
|
const { nodes, edges, journal } = await load(ctx);
|
|
24831
25224
|
const node = findNode(nodes, nodeId);
|
|
24832
25225
|
const nodesById = new Map(nodes.map((candidate) => [candidate.id, candidate]));
|
|
@@ -24851,7 +25244,7 @@ ${node.description ?? ""}`.toLowerCase();
|
|
|
24851
25244
|
}
|
|
24852
25245
|
}
|
|
24853
25246
|
const whereUsedFlows = [...composingFlowIds].map((flowId) => nodesById.get(flowId)).filter((flow) => flow !== void 0 && flow.species === "flow").map((flow) => ({ id: flow.id, title: flow.title }));
|
|
24854
|
-
const covered_by = node.species === "view" || node.species === "flow" ? acceptancesCovering(nodeId, nodes, edges).map(nodeSummary) : void 0;
|
|
25247
|
+
const covered_by = node.species === "view" || node.species === "flow" ? acceptancesCovering(nodeId, nodes, edges).map((node2) => nodeSummary(node2)) : void 0;
|
|
24855
25248
|
return {
|
|
24856
25249
|
node,
|
|
24857
25250
|
edges: relatedEdges,
|
|
@@ -24923,7 +25316,7 @@ ${node.description ?? ""}`.toLowerCase();
|
|
|
24923
25316
|
}
|
|
24924
25317
|
},
|
|
24925
25318
|
async (args) => {
|
|
24926
|
-
const mapId =
|
|
25319
|
+
const mapId = requireString4(args, "map_id");
|
|
24927
25320
|
const { nodes, edges, project } = await load(ctx);
|
|
24928
25321
|
const definition = listMaps(project).find((candidate) => candidate.id === mapId);
|
|
24929
25322
|
if (!definition) throw new ToolError(`No map with id "${mapId}".`);
|
|
@@ -24950,7 +25343,7 @@ ${node.description ?? ""}`.toLowerCase();
|
|
|
24950
25343
|
tool(
|
|
24951
25344
|
{
|
|
24952
25345
|
name: "create_node",
|
|
24953
|
-
description: "Create a node. The id derives from species + title; the mutation is refused (nothing written) if the result fails validation. For a flow, pass its populated metadata.playlist here \u2014 the matching composes edges to every referenced view/sub-flow are synthesized in the same mutation, so a full flow lands in one call. A decision
|
|
25346
|
+
description: "Create a node. The id derives from species + title; the mutation is refused (nothing written) if the result fails validation. For a flow, pass its populated metadata.playlist here \u2014 the matching composes edges to every referenced view/sub-flow are synthesized in the same mutation, so a full flow lands in one call. A decision, a stake or an option takes platforms: []; a stake also takes metadata.stake_species (bug, friction, need, requirement, risk or defect) and is anchored with a concerns edge to the flow, view, data model or endpoint it is about; an option never exists without a stake, so link it to the stake it addresses with an addresses edge.",
|
|
24954
25347
|
inputSchema: {
|
|
24955
25348
|
type: "object",
|
|
24956
25349
|
properties: {
|
|
@@ -24967,8 +25360,8 @@ ${node.description ?? ""}`.toLowerCase();
|
|
|
24967
25360
|
},
|
|
24968
25361
|
async (args) => {
|
|
24969
25362
|
const graph = await load(ctx);
|
|
24970
|
-
const species =
|
|
24971
|
-
const title =
|
|
25363
|
+
const species = requireString4(args, "species");
|
|
25364
|
+
const title = requireString4(args, "title");
|
|
24972
25365
|
const platforms = Array.isArray(args.platforms) ? args.platforms : [];
|
|
24973
25366
|
const node = {
|
|
24974
25367
|
id: deriveNodeId(species, title, graph.nodes.map((candidate) => candidate.id)),
|
|
@@ -25016,7 +25409,7 @@ ${node.description ?? ""}`.toLowerCase();
|
|
|
25016
25409
|
}
|
|
25017
25410
|
},
|
|
25018
25411
|
async (args) => {
|
|
25019
|
-
const nodeId =
|
|
25412
|
+
const nodeId = requireString4(args, "node_id");
|
|
25020
25413
|
if (typeof args.patch !== "object" || args.patch === null || Array.isArray(args.patch)) {
|
|
25021
25414
|
throw new ToolError("`patch` is required and must be an object.");
|
|
25022
25415
|
}
|
|
@@ -25038,6 +25431,11 @@ ${node.description ?? ""}`.toLowerCase();
|
|
|
25038
25431
|
if (value === null) delete merged[key];
|
|
25039
25432
|
else merged[key] = value;
|
|
25040
25433
|
}
|
|
25434
|
+
const before = stakeCatalogOf(current);
|
|
25435
|
+
const after = stakeCatalogOf({ metadata: merged });
|
|
25436
|
+
if ((before?.source !== after?.source || before?.id !== after?.id) && !("verified_criterion_version" in patch.metadata)) {
|
|
25437
|
+
delete merged.verified_criterion_version;
|
|
25438
|
+
}
|
|
25041
25439
|
patch.metadata = stakeMetadataWith(merged, {});
|
|
25042
25440
|
}
|
|
25043
25441
|
const ops = [{ op: "update_node", node_id: nodeId, patch }];
|
|
@@ -25073,10 +25471,10 @@ ${node.description ?? ""}`.toLowerCase();
|
|
|
25073
25471
|
}
|
|
25074
25472
|
},
|
|
25075
25473
|
async (args) => {
|
|
25076
|
-
const nodeId =
|
|
25474
|
+
const nodeId = requireString4(args, "node_id");
|
|
25077
25475
|
const platform = requirePlatform(args);
|
|
25078
25476
|
const form = requireScreenshotForm(args);
|
|
25079
|
-
const value =
|
|
25477
|
+
const value = requireString4(args, "value");
|
|
25080
25478
|
const graph = await load(ctx);
|
|
25081
25479
|
const ops = [
|
|
25082
25480
|
{
|
|
@@ -25111,7 +25509,7 @@ ${node.description ?? ""}`.toLowerCase();
|
|
|
25111
25509
|
}
|
|
25112
25510
|
},
|
|
25113
25511
|
async (args) => {
|
|
25114
|
-
const nodeId =
|
|
25512
|
+
const nodeId = requireString4(args, "node_id");
|
|
25115
25513
|
const platform = requirePlatform(args);
|
|
25116
25514
|
const graph = await load(ctx);
|
|
25117
25515
|
const ops = [{ op: "remove_screenshot", node_id: nodeId, platform }];
|
|
@@ -25135,7 +25533,7 @@ ${node.description ?? ""}`.toLowerCase();
|
|
|
25135
25533
|
}
|
|
25136
25534
|
},
|
|
25137
25535
|
async (args) => {
|
|
25138
|
-
const nodeId =
|
|
25536
|
+
const nodeId = requireString4(args, "node_id");
|
|
25139
25537
|
const graph = await load(ctx);
|
|
25140
25538
|
const node = findNode(graph.nodes, nodeId);
|
|
25141
25539
|
const ops = [{ op: "delete_node", node_id: nodeId }];
|
|
@@ -25165,9 +25563,9 @@ ${node.description ?? ""}`.toLowerCase();
|
|
|
25165
25563
|
}
|
|
25166
25564
|
},
|
|
25167
25565
|
async (args) => {
|
|
25168
|
-
const sourceId =
|
|
25169
|
-
const targetId =
|
|
25170
|
-
const edgeType =
|
|
25566
|
+
const sourceId = requireString4(args, "source_id");
|
|
25567
|
+
const targetId = requireString4(args, "target_id");
|
|
25568
|
+
const edgeType = requireString4(args, "edge_type");
|
|
25171
25569
|
const graph = await load(ctx);
|
|
25172
25570
|
const edge = {
|
|
25173
25571
|
id: edgeId(sourceId, targetId),
|
|
@@ -25202,7 +25600,7 @@ ${node.description ?? ""}`.toLowerCase();
|
|
|
25202
25600
|
}
|
|
25203
25601
|
},
|
|
25204
25602
|
async (args) => {
|
|
25205
|
-
const edgeIdArg =
|
|
25603
|
+
const edgeIdArg = requireString4(args, "edge_id");
|
|
25206
25604
|
const graph = await load(ctx);
|
|
25207
25605
|
const edge = graph.edges.find((candidate) => candidate.id === edgeIdArg);
|
|
25208
25606
|
if (!edge) throw new ToolError(`No edge with id "${edgeIdArg}".`);
|
|
@@ -25218,7 +25616,7 @@ ${node.description ?? ""}`.toLowerCase();
|
|
|
25218
25616
|
}
|
|
25219
25617
|
);
|
|
25220
25618
|
const journalOnly = (type) => async (args) => {
|
|
25221
|
-
const title =
|
|
25619
|
+
const title = requireString4(args, "title");
|
|
25222
25620
|
const graph = await load(ctx);
|
|
25223
25621
|
const payload = { title };
|
|
25224
25622
|
if (typeof args.description === "string") payload.description = args.description;
|
|
@@ -25302,6 +25700,9 @@ ${node.description ?? ""}`.toLowerCase();
|
|
|
25302
25700
|
const qualify = buildQualifyCatalog(ctx, { load: () => load(ctx), mutate, unwrap });
|
|
25303
25701
|
tools2.push(...qualify.tools);
|
|
25304
25702
|
Object.assign(handlers2, qualify.handlers);
|
|
25703
|
+
const decide = buildDecideCatalog(ctx, { load: () => load(ctx), mutate, unwrap });
|
|
25704
|
+
tools2.push(...decide.tools);
|
|
25705
|
+
Object.assign(handlers2, decide.handlers);
|
|
25305
25706
|
return { tools: tools2, handlers: handlers2 };
|
|
25306
25707
|
}
|
|
25307
25708
|
|
|
@@ -25543,7 +25944,7 @@ function resolveRemoteConfig(argv2, env, cwd) {
|
|
|
25543
25944
|
}
|
|
25544
25945
|
|
|
25545
25946
|
// src/index.ts
|
|
25546
|
-
var VERSION = "0.
|
|
25947
|
+
var VERSION = "0.14.0";
|
|
25547
25948
|
var argv = process.argv.slice(2);
|
|
25548
25949
|
if (argv.includes("--help") || argv.includes("-h")) {
|
|
25549
25950
|
process.stdout.write(
|