arkaik-mcp 0.12.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +2457 -772
- 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"];
|
|
14638
|
+
var SPECIES_IDS = ["flow", "view", "data-model", "api-endpoint", "acceptance", "decision", "stake"];
|
|
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"];
|
|
14649
|
+
var EDGE_TYPE_IDS = ["composes", "calls", "displays", "queries", "covers", "supersedes", "generates", "impacts", "concerns"];
|
|
14650
14650
|
var VALID_EDGE_SEMANTICS = {
|
|
14651
14651
|
composes: [
|
|
14652
14652
|
["flow", "view"],
|
|
@@ -14685,6 +14685,15 @@ var VALID_EDGE_SEMANTICS = {
|
|
|
14685
14685
|
["decision", "view"],
|
|
14686
14686
|
["decision", "data-model"],
|
|
14687
14687
|
["decision", "api-endpoint"]
|
|
14688
|
+
],
|
|
14689
|
+
// Stake edge (docs/rfcs/stake-architecture.md § 4). A stake is anchored to
|
|
14690
|
+
// the product's anatomy only, never to an acceptance or a decision, and
|
|
14691
|
+
// `impacts` stays decision-only.
|
|
14692
|
+
concerns: [
|
|
14693
|
+
["stake", "flow"],
|
|
14694
|
+
["stake", "view"],
|
|
14695
|
+
["stake", "data-model"],
|
|
14696
|
+
["stake", "api-endpoint"]
|
|
14688
14697
|
]
|
|
14689
14698
|
};
|
|
14690
14699
|
var VALUE_TIER_IDS = ["functional", "emotional", "life-changing", "social-impact"];
|
|
@@ -14857,10 +14866,96 @@ function decisionStatusOf(node) {
|
|
|
14857
14866
|
return DECISION_STATUS_IDS.includes(raw) ? raw : "proposed";
|
|
14858
14867
|
}
|
|
14859
14868
|
|
|
14869
|
+
// ../schema/src/stake.ts
|
|
14870
|
+
var STAKE_SPECIES_IDS = ["bug", "friction", "need", "requirement", "risk", "defect"];
|
|
14871
|
+
var STAKE_PROVENANCE_IDS = ["observed", "anticipated"];
|
|
14872
|
+
var STAKE_LIFECYCLE_STATUSES = ["idea", "discovery", "archived"];
|
|
14873
|
+
var ANTICIPATED_STAKE_SPECIES = ["need", "requirement", "risk", "defect"];
|
|
14874
|
+
var USER_FACING_STAKE_SPECIES = ["bug", "friction", "need"];
|
|
14875
|
+
var QUALITY_STAKE_SPECIES = ["requirement", "risk", "defect"];
|
|
14876
|
+
var STAKE_ANCHOR_SPECIES = VALID_EDGE_SEMANTICS.concerns.map(([, target]) => target);
|
|
14877
|
+
var STAKE_CATALOG_SOURCES = ["kritik", "values"];
|
|
14878
|
+
var STAKE_FELT_IDS = ["expected", "wanted", "delight"];
|
|
14879
|
+
var STAKE_MATTERS_LEVELS = [1, 2, 3, 4];
|
|
14880
|
+
var STAKE_FREQUENCY_IDS = ["rare", "some", "often"];
|
|
14881
|
+
var STAKE_EVIDENCE_VOICES = ["person", "maintainer", "agent"];
|
|
14882
|
+
function catalogSourceForStakeSpecies(species) {
|
|
14883
|
+
return QUALITY_STAKE_SPECIES.includes(species) ? "kritik" : "values";
|
|
14884
|
+
}
|
|
14885
|
+
function isUserFacingStakeSpecies(species) {
|
|
14886
|
+
return USER_FACING_STAKE_SPECIES.includes(species);
|
|
14887
|
+
}
|
|
14888
|
+
function stakeSpeciesOf(node) {
|
|
14889
|
+
const raw = node.metadata?.stake_species;
|
|
14890
|
+
return STAKE_SPECIES_IDS.includes(raw) ? raw : void 0;
|
|
14891
|
+
}
|
|
14892
|
+
function stakeProvenanceOf(node) {
|
|
14893
|
+
const raw = node.metadata?.provenance;
|
|
14894
|
+
return STAKE_PROVENANCE_IDS.includes(raw) ? raw : "observed";
|
|
14895
|
+
}
|
|
14896
|
+
function stakeCatalogOf(node) {
|
|
14897
|
+
const raw = node.metadata?.catalog;
|
|
14898
|
+
if (!raw || typeof raw !== "object") return void 0;
|
|
14899
|
+
const { source, id } = raw;
|
|
14900
|
+
if (!STAKE_CATALOG_SOURCES.includes(source)) return void 0;
|
|
14901
|
+
if (typeof id !== "string" || id === "") return void 0;
|
|
14902
|
+
return { source, id };
|
|
14903
|
+
}
|
|
14904
|
+
function stakeFeltOf(node) {
|
|
14905
|
+
const raw = node.metadata?.felt;
|
|
14906
|
+
return STAKE_FELT_IDS.includes(raw) ? raw : void 0;
|
|
14907
|
+
}
|
|
14908
|
+
function stakeMattersOf(node) {
|
|
14909
|
+
const raw = node.metadata?.matters;
|
|
14910
|
+
return STAKE_MATTERS_LEVELS.includes(raw) ? raw : void 0;
|
|
14911
|
+
}
|
|
14912
|
+
function stakeFrequencyOf(node) {
|
|
14913
|
+
const raw = node.metadata?.frequency;
|
|
14914
|
+
return STAKE_FREQUENCY_IDS.includes(raw) ? raw : void 0;
|
|
14915
|
+
}
|
|
14916
|
+
function stakeMetadataWith(metadata, change) {
|
|
14917
|
+
const next = { ...metadata ?? {} };
|
|
14918
|
+
for (const key of ["stake_species", "provenance", "catalog", "felt", "matters", "frequency"]) {
|
|
14919
|
+
if (!(key in change)) continue;
|
|
14920
|
+
const value = change[key];
|
|
14921
|
+
if (value === void 0) delete next[key];
|
|
14922
|
+
else next[key] = value;
|
|
14923
|
+
}
|
|
14924
|
+
if (next.provenance === "observed") delete next.provenance;
|
|
14925
|
+
const species = stakeSpeciesOf({ metadata: next });
|
|
14926
|
+
const catalog = stakeCatalogOf({ metadata: next });
|
|
14927
|
+
if (species !== void 0 && catalog !== void 0 && catalog.source !== catalogSourceForStakeSpecies(species)) {
|
|
14928
|
+
delete next.catalog;
|
|
14929
|
+
}
|
|
14930
|
+
if (species !== void 0 && !isUserFacingStakeSpecies(species)) {
|
|
14931
|
+
delete next.felt;
|
|
14932
|
+
delete next.matters;
|
|
14933
|
+
delete next.frequency;
|
|
14934
|
+
} else if (species === "bug") {
|
|
14935
|
+
next.felt = "expected";
|
|
14936
|
+
}
|
|
14937
|
+
return next;
|
|
14938
|
+
}
|
|
14939
|
+
function stakeEvidenceOf(node) {
|
|
14940
|
+
const raw = node.metadata?.evidence;
|
|
14941
|
+
if (!Array.isArray(raw)) return [];
|
|
14942
|
+
return raw.filter((entry) => typeof entry === "object" && entry !== null && !Array.isArray(entry));
|
|
14943
|
+
}
|
|
14944
|
+
function stakeEvidenceEventIds(nodes) {
|
|
14945
|
+
const ids = /* @__PURE__ */ new Set();
|
|
14946
|
+
for (const node of nodes) {
|
|
14947
|
+
if (node.species !== "stake") continue;
|
|
14948
|
+
for (const entry of stakeEvidenceOf(node)) {
|
|
14949
|
+
if (typeof entry.event_id === "string" && entry.event_id !== "") ids.add(entry.event_id);
|
|
14950
|
+
}
|
|
14951
|
+
}
|
|
14952
|
+
return ids;
|
|
14953
|
+
}
|
|
14954
|
+
|
|
14860
14955
|
// ../schema/src/enums.ts
|
|
14861
14956
|
var SpeciesSchema = external_exports.enum(SPECIES_IDS).meta({
|
|
14862
14957
|
id: "Species",
|
|
14863
|
-
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."
|
|
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."
|
|
14864
14959
|
});
|
|
14865
14960
|
var StatusSchema = external_exports.enum(STATUS_IDS).meta({
|
|
14866
14961
|
id: "Status",
|
|
@@ -14876,7 +14971,7 @@ var PlatformSchema = external_exports.enum(PLATFORM_IDS).meta({
|
|
|
14876
14971
|
});
|
|
14877
14972
|
var EdgeTypeSchema = external_exports.enum(EDGE_TYPE_IDS).meta({
|
|
14878
14973
|
id: "EdgeType",
|
|
14879
|
-
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)."
|
|
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)."
|
|
14880
14975
|
});
|
|
14881
14976
|
var ValueTierSchema = external_exports.enum(VALUE_TIER_IDS).meta({
|
|
14882
14977
|
id: "ValueTier",
|
|
@@ -14890,6 +14985,34 @@ var DecisionStatusSchema = external_exports.enum(DECISION_STATUS_IDS).meta({
|
|
|
14890
14985
|
id: "DecisionStatus",
|
|
14891
14986
|
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)."
|
|
14892
14987
|
});
|
|
14988
|
+
var StakeSpeciesSchema = external_exports.enum(STAKE_SPECIES_IDS).meta({
|
|
14989
|
+
id: "StakeSpecies",
|
|
14990
|
+
description: "Stake nodes only: bug | friction | need (user-facing, weighed on the value pyramid) or requirement | risk | defect (quality, read against Kritik criteria)."
|
|
14991
|
+
});
|
|
14992
|
+
var StakeProvenanceSchema = external_exports.enum(STAKE_PROVENANCE_IDS).meta({
|
|
14993
|
+
id: "StakeProvenance",
|
|
14994
|
+
description: "Stake nodes only: observed (seen in the world; the default when absent) or anticipated (reasoned about ahead of it; never a bug or a friction)."
|
|
14995
|
+
});
|
|
14996
|
+
var StakeCatalogSourceSchema = external_exports.enum(STAKE_CATALOG_SOURCES).meta({
|
|
14997
|
+
id: "StakeCatalogSource",
|
|
14998
|
+
description: "Where a stake's catalog link points: kritik (a criterion id such as SAF-01) or values (a value id such as reduces-anxiety)."
|
|
14999
|
+
});
|
|
15000
|
+
var StakeEvidenceVoiceSchema = external_exports.enum(STAKE_EVIDENCE_VOICES).meta({
|
|
15001
|
+
id: "StakeEvidenceVoice",
|
|
15002
|
+
description: "Who voiced a piece of stake evidence: person (the one the signal came from), maintainer, or agent."
|
|
15003
|
+
});
|
|
15004
|
+
var StakeFeltSchema = external_exports.enum(STAKE_FELT_IDS).meta({
|
|
15005
|
+
id: "StakeFelt",
|
|
15006
|
+
description: "Bug, friction and need stakes only: how the person feels it. expected (a must-be: a bug is always this), wanted (a performance) or delight (an attractive)."
|
|
15007
|
+
});
|
|
15008
|
+
var StakeMattersSchema = external_exports.union([external_exports.literal(1), external_exports.literal(2), external_exports.literal(3), external_exports.literal(4)]).meta({
|
|
15009
|
+
id: "StakeMatters",
|
|
15010
|
+
description: "Bug, friction and need stakes only: how much addressing it matters to the person, 4 (most) to 1 (least). Worded per felt kind; never summed with a pyramid level or a Kritik criticality."
|
|
15011
|
+
});
|
|
15012
|
+
var StakeFrequencySchema = external_exports.enum(STAKE_FREQUENCY_IDS).meta({
|
|
15013
|
+
id: "StakeFrequency",
|
|
15014
|
+
description: "Bug, friction and need stakes only: how often the situation comes up for the person: rare, some or often. Shown beside mattering, never sorted by."
|
|
15015
|
+
});
|
|
14893
15016
|
|
|
14894
15017
|
// ../schema/src/id-gen.ts
|
|
14895
15018
|
var SPECIES_PREFIXES = {
|
|
@@ -14898,7 +15021,8 @@ var SPECIES_PREFIXES = {
|
|
|
14898
15021
|
"data-model": "DM-",
|
|
14899
15022
|
"api-endpoint": "API-",
|
|
14900
15023
|
acceptance: "AC-",
|
|
14901
|
-
decision: "DEC-"
|
|
15024
|
+
decision: "DEC-",
|
|
15025
|
+
stake: "STK-"
|
|
14902
15026
|
};
|
|
14903
15027
|
function kebabCase(input) {
|
|
14904
15028
|
return input.normalize("NFKD").replace(/[\u0300-\u036f]/g, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
@@ -15046,6 +15170,14 @@ function reduceScreenshotSlots(ordered) {
|
|
|
15046
15170
|
}
|
|
15047
15171
|
|
|
15048
15172
|
// ../schema/src/journal.ts
|
|
15173
|
+
var SIGNAL_SOURCE_KINDS = ["ticket", "interview", "form", "feedback", "audit-finding", "idea", "benchmark", "other"];
|
|
15174
|
+
function signalSourceKindOf(event) {
|
|
15175
|
+
return SIGNAL_SOURCE_KINDS.includes(event.source_kind) ? event.source_kind : void 0;
|
|
15176
|
+
}
|
|
15177
|
+
function signalStakeIds(event) {
|
|
15178
|
+
const raw = event.stake_ids;
|
|
15179
|
+
return Array.isArray(raw) ? raw.filter((id) => typeof id === "string" && id !== "") : [];
|
|
15180
|
+
}
|
|
15049
15181
|
var SCREENSHOT_SOURCES = ["ci", "manual"];
|
|
15050
15182
|
var SCREENSHOT_FORMS = ["url", "path", "data"];
|
|
15051
15183
|
function orderEvents(events) {
|
|
@@ -15262,6 +15394,19 @@ function crossCheckJournal(bundle) {
|
|
|
15262
15394
|
}
|
|
15263
15395
|
});
|
|
15264
15396
|
}
|
|
15397
|
+
if (ev.type === "request.filed" && Array.isArray(ev.stake_ids)) {
|
|
15398
|
+
ev.stake_ids.forEach((raw, i) => {
|
|
15399
|
+
const ref = str(raw);
|
|
15400
|
+
if (ref !== void 0 && !everNodes.has(ref)) {
|
|
15401
|
+
findings.push({
|
|
15402
|
+
path: `journal[${index}].stake_ids[${i}]`,
|
|
15403
|
+
rule: "journal-dangling-stake-ref",
|
|
15404
|
+
message: `journal[${index}] (${ev.type}): names stake "${ref}" that never existed in the snapshot or journal.`,
|
|
15405
|
+
severity: "warning"
|
|
15406
|
+
});
|
|
15407
|
+
}
|
|
15408
|
+
});
|
|
15409
|
+
}
|
|
15265
15410
|
if (ev.type === "edge.removed") {
|
|
15266
15411
|
const ref = str(ev.edge_id);
|
|
15267
15412
|
if (ref !== void 0 && !everEdges.has(ref)) {
|
|
@@ -15394,6 +15539,7 @@ var WeighingCriteriaSetSchema = external_exports.object({
|
|
|
15394
15539
|
version: leaf("Semver. Levels are comparable only within a major."),
|
|
15395
15540
|
title: leaf("A human title."),
|
|
15396
15541
|
subject: leaf("What the set judges: acceptance today."),
|
|
15542
|
+
stake_species: leaf("The kinds of stake this set may also score (bug, friction, need, requirement, risk, defect). Absent means none; the value ruler declares bug, friction and need."),
|
|
15397
15543
|
scale: documented(WeighingScaleSchema).optional().meta({ description: "The scale. A positioning may leave it out and use its ruler's." }),
|
|
15398
15544
|
groups: documented(external_exports.array(documented(WeighingGroupSchema))).optional(),
|
|
15399
15545
|
criteria: documented(external_exports.array(documented(WeighingCriterionSchema))).optional(),
|
|
@@ -15526,8 +15672,17 @@ var RequestFiledEventSchema = external_exports.object({
|
|
|
15526
15672
|
type: external_exports.literal("request.filed"),
|
|
15527
15673
|
title: external_exports.string(),
|
|
15528
15674
|
description: external_exports.string().optional(),
|
|
15529
|
-
source: external_exports.string().optional(),
|
|
15530
|
-
node_id: external_exports.string().optional()
|
|
15675
|
+
source: external_exports.string().optional().meta({ description: `The source's own name, a free string ("user", "beta-feedback"). Never retyped.` }),
|
|
15676
|
+
node_id: external_exports.string().optional(),
|
|
15677
|
+
source_kind: external_exports.enum(SIGNAL_SOURCE_KINDS).optional().meta({
|
|
15678
|
+
description: "What sort of source: ticket | interview | form | feedback | audit-finding | idea | benchmark | other. Absent on a legacy request."
|
|
15679
|
+
}),
|
|
15680
|
+
verbatim: external_exports.string().optional().meta({ description: "The input exactly as voiced, never edited." }),
|
|
15681
|
+
provenance: StakeProvenanceSchema.optional().meta({ description: "observed (default when absent) or anticipated." }),
|
|
15682
|
+
stake_ids: external_exports.array(external_exports.string()).optional().meta({ description: "Stakes known at filing time. The durable link is the stake's metadata.evidence[]." }),
|
|
15683
|
+
finding_id: external_exports.string().optional().meta({ description: "source_kind audit-finding: the Kritik finding. Never put an F-\u2026 id in node_id or stake_ids." }),
|
|
15684
|
+
criterion_id: external_exports.string().optional().meta({ description: "source_kind audit-finding: the criterion the finding was raised against." }),
|
|
15685
|
+
url: external_exports.string().optional().meta({ description: "An external reference for the source item." })
|
|
15531
15686
|
}).catchall(external_exports.unknown());
|
|
15532
15687
|
var RefAddedEventSchema = external_exports.object({
|
|
15533
15688
|
...envelope,
|
|
@@ -15742,18 +15897,6 @@ function mergeKritikLibrary(pack, overlay) {
|
|
|
15742
15897
|
const scales = pack.scales || overlay.scales ? { ...pack.scales ?? {}, ...overlay.scales ?? {} } : void 0;
|
|
15743
15898
|
return { ...pack, domains, criteria, ...scales ? { scales } : {} };
|
|
15744
15899
|
}
|
|
15745
|
-
function applicableCells(library, surfaces) {
|
|
15746
|
-
const selected = surfaces.filter((id) => id !== CROSS_SURFACE_ID);
|
|
15747
|
-
const cells = [];
|
|
15748
|
-
for (const criterion of asArray(library.criteria)) {
|
|
15749
|
-
if (typeof criterion?.id !== "string" || criterion.id === "") continue;
|
|
15750
|
-
if (typeof criterion.superseded_by === "string" && criterion.superseded_by !== "") continue;
|
|
15751
|
-
const appliesTo = Array.isArray(criterion.applies_to) ? criterion.applies_to : void 0;
|
|
15752
|
-
const matched = appliesTo === void 0 ? [...selected] : selected.filter((id) => appliesTo.includes(id));
|
|
15753
|
-
if (matched.length > 0) cells.push({ criterion_id: criterion.id, surfaces: matched });
|
|
15754
|
-
}
|
|
15755
|
-
return cells;
|
|
15756
|
-
}
|
|
15757
15900
|
function bucketsOf(library) {
|
|
15758
15901
|
const stored = library?.scales?.severity_buckets;
|
|
15759
15902
|
const out = { ...DEFAULT_SEVERITY_BUCKETS };
|
|
@@ -16114,104 +16257,12 @@ function signalTrippedInput(trip) {
|
|
|
16114
16257
|
};
|
|
16115
16258
|
}
|
|
16116
16259
|
|
|
16117
|
-
// ../schema/src/kritik-plan-prompt.ts
|
|
16118
|
-
var THOUSANDS = /\B(?=(\d{3})+(?!\d))/g;
|
|
16119
|
-
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.';
|
|
16120
|
-
var USAGE_READOUT = "this session's usage readout: model, tokens in and out, duration, number of agents.";
|
|
16121
|
-
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.";
|
|
16122
|
-
var FINDING_FLAGS = '--title "<one line>" --impact <1-5> --likelihood <1-5> --cost <S|M|L|XL> --evidence "<file:line \u2026>"';
|
|
16123
|
-
function planRecordCommand(planId2) {
|
|
16124
|
-
return `arkaik kritik matrix ${planId2} --record --plan`;
|
|
16125
|
-
}
|
|
16126
|
-
function plural(count, noun) {
|
|
16127
|
-
return `${count} ${noun}${count === 1 ? "" : "s"}`;
|
|
16128
|
-
}
|
|
16129
|
-
function tokenCount(value) {
|
|
16130
|
-
return String(Math.round(value)).replace(THOUSANDS, ",");
|
|
16131
|
-
}
|
|
16132
|
-
function dollars(value) {
|
|
16133
|
-
return `$${value.toFixed(2)}`;
|
|
16134
|
-
}
|
|
16135
|
-
function where(commit) {
|
|
16136
|
-
return commit === null ? "not a git checkout" : `commit ${commit}`;
|
|
16137
|
-
}
|
|
16138
|
-
function estimateSentence(tokens, usd, calibrated) {
|
|
16139
|
-
if (tokens === null) return "";
|
|
16140
|
-
const cost = usd === null ? "" : ` (${dollars(usd.low)}\u2013${dollars(usd.high)})`;
|
|
16141
|
-
return ` Estimate: ${tokenCount(tokens.low)}\u2013${tokenCount(tokens.high)} tokens${cost}${calibrated ? "" : ", uncalibrated"}.`;
|
|
16142
|
-
}
|
|
16143
|
-
function scopeSentence(cells, steps) {
|
|
16144
|
-
return `${plural(cells, "cell")}, ${plural(steps, "checklist step")}`;
|
|
16145
|
-
}
|
|
16146
|
-
function partSteps(part, first) {
|
|
16147
|
-
const audit = `--audit ${part.auditId}`;
|
|
16148
|
-
return [
|
|
16149
|
-
`${first}. Get the run sheet: \`arkaik kritik signals --domain ${part.domain} --surface ${part.surface}\`. ${SIGNALS_EXIT}`,
|
|
16150
|
-
`${first + 1}. Score exactly these cells and no others:`,
|
|
16151
|
-
...part.cells.map(
|
|
16152
|
-
(cell) => ` - ${cell.criterion_id} on ${cell.surface}: \`arkaik kritik score ${cell.criterion_id} ${cell.surface} <level> --evidence "<file:line \u2026>" ${audit}\``
|
|
16153
|
-
),
|
|
16154
|
-
`${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.`
|
|
16155
|
-
];
|
|
16156
|
-
}
|
|
16157
|
-
function renderPartPrompt(plan, part) {
|
|
16158
|
-
const estimate = part.estimate === null ? "" : estimateSentence(part.estimate.tokens, part.estimate.usd, part.estimate.calibrated);
|
|
16159
|
-
return [
|
|
16160
|
-
`Run part ${part.domain}:${part.surface} of Kritik plan ${plan.planId} in this repo (${where(plan.commit)}).`,
|
|
16161
|
-
`Scope: ${scopeSentence(part.cells.length, part.steps)}.${estimate}`,
|
|
16162
|
-
`Audit id for this part: ${part.auditId}`,
|
|
16163
|
-
"",
|
|
16164
|
-
`1. ${SKILL_STEP}`,
|
|
16165
|
-
...partSteps(part, 2),
|
|
16166
|
-
"5. Do not record this part. The plan is recorded once, after every part is scored, with the plan's own command.",
|
|
16167
|
-
`6. Finish by printing ${USAGE_READOUT}`
|
|
16168
|
-
].join("\n");
|
|
16169
|
-
}
|
|
16170
|
-
function renderPlanPrompt(plan) {
|
|
16171
|
-
const included = plan.parts.filter((part) => part.status === "included");
|
|
16172
|
-
const deferred = plan.parts.filter((part) => part.status === "deferred");
|
|
16173
|
-
const calibrated = included.every((part) => part.estimate?.calibrated === true);
|
|
16174
|
-
const lines = [
|
|
16175
|
-
`Run Kritik plan ${plan.planId} in this repo (${where(plan.commit)}): ${plural(included.length, "part")}, one after the other, in this session.`,
|
|
16176
|
-
`Scope: ${scopeSentence(plan.totals.cells, plan.totals.steps)}, of ${plan.totals.applicableCells} applicable cells.` + estimateSentence(plan.totals.tokens, plan.totals.usd, calibrated),
|
|
16177
|
-
"",
|
|
16178
|
-
`1. ${SKILL_STEP} Do not record a part on its own.`
|
|
16179
|
-
];
|
|
16180
|
-
let step = 2;
|
|
16181
|
-
for (const part of included) {
|
|
16182
|
-
lines.push(
|
|
16183
|
-
"",
|
|
16184
|
-
`Part ${part.domain}:${part.surface}, audit id ${part.auditId} (${scopeSentence(part.cells.length, part.steps)}):`,
|
|
16185
|
-
...partSteps(part, step)
|
|
16186
|
-
);
|
|
16187
|
-
step += 3;
|
|
16188
|
-
}
|
|
16189
|
-
lines.push(
|
|
16190
|
-
"",
|
|
16191
|
-
`${step}. Check that every part is scored: \`arkaik kritik plan --status ${plan.planId}\``,
|
|
16192
|
-
`${step + 1}. Print ${USAGE_READOUT}`,
|
|
16193
|
-
`${step + 2}. When every part is scored, run \`${plan.recordCommand}\``
|
|
16194
|
-
);
|
|
16195
|
-
if (deferred.length > 0) {
|
|
16196
|
-
lines.push(
|
|
16197
|
-
"",
|
|
16198
|
-
"Not in this run (over budget):",
|
|
16199
|
-
...deferred.map((part) => ` - ${part.domain}:${part.surface} (${part.auditId}). Do not score it.`)
|
|
16200
|
-
);
|
|
16201
|
-
}
|
|
16202
|
-
return lines.join("\n");
|
|
16203
|
-
}
|
|
16204
|
-
|
|
16205
16260
|
// ../schema/src/quality-plan.ts
|
|
16206
16261
|
var KRITIK_PLAN_SCHEMA = "arkaik.kritik.plan/1";
|
|
16207
|
-
var PLAN_PLANS_DIR = "plans";
|
|
16208
16262
|
var SCOPED_AUDIT_ID = /-scoped(-\d+)?$/;
|
|
16209
16263
|
var PLAN_ID = /^\d{4}-\d{2}-zplan-\d{4}$/;
|
|
16210
16264
|
var PLAN_PART_ID = /^\d{4}-\d{2}-zplan-\d{4}-[a-z0-9]{2,5}-.+$/;
|
|
16211
16265
|
var PLAN_ID_LENGTH = 18;
|
|
16212
|
-
function planCellKey(criterionId, surface) {
|
|
16213
|
-
return `${criterionId}::${surface}`;
|
|
16214
|
-
}
|
|
16215
16266
|
function isScopedAuditId(id) {
|
|
16216
16267
|
return typeof id === "string" && SCOPED_AUDIT_ID.test(id);
|
|
16217
16268
|
}
|
|
@@ -16227,77 +16278,6 @@ function isPartialAuditId(id) {
|
|
|
16227
16278
|
function planIdOfPartId(id) {
|
|
16228
16279
|
return isPlanPartId(id) ? id.slice(0, PLAN_ID_LENGTH) : null;
|
|
16229
16280
|
}
|
|
16230
|
-
var RUN_TOKEN = /^([A-Za-z0-9]{2,5}):([A-Za-z0-9_-]+)$/;
|
|
16231
|
-
var PLANNABLE_DOMAIN = /^[A-Z0-9]{2,5}$/;
|
|
16232
|
-
function parseRun(tokens, vocabulary) {
|
|
16233
|
-
if (tokens.length === 0) throw new Error("at least one --run DOMAIN:SURFACE is required");
|
|
16234
|
-
const surfaces = vocabulary.surfaces.filter((id) => id !== CROSS_SURFACE_ID);
|
|
16235
|
-
const plannable = vocabulary.domains.filter((code) => PLANNABLE_DOMAIN.test(code));
|
|
16236
|
-
const unplannable = vocabulary.domains.filter((code) => !PLANNABLE_DOMAIN.test(code));
|
|
16237
|
-
const runs = [];
|
|
16238
|
-
const warnings = [];
|
|
16239
|
-
const tokenBySuffix = /* @__PURE__ */ new Map();
|
|
16240
|
-
for (const token of tokens) {
|
|
16241
|
-
const match = RUN_TOKEN.exec(token);
|
|
16242
|
-
if (match === null) {
|
|
16243
|
-
throw new Error(
|
|
16244
|
-
`--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).`
|
|
16245
|
-
);
|
|
16246
|
-
}
|
|
16247
|
-
const domain2 = match[1].toUpperCase();
|
|
16248
|
-
const surface = match[2];
|
|
16249
|
-
if (!plannable.includes(domain2)) {
|
|
16250
|
-
throw new Error(
|
|
16251
|
-
`--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.` : "")
|
|
16252
|
-
);
|
|
16253
|
-
}
|
|
16254
|
-
if (surface === CROSS_SURFACE_ID) {
|
|
16255
|
-
throw new Error(
|
|
16256
|
-
`--run "${token}": ${CROSS_SURFACE_ID} is a lens for findings, not a surface anything is scored on. Plan the surfaces it connects instead.`
|
|
16257
|
-
);
|
|
16258
|
-
}
|
|
16259
|
-
if (!surfaces.includes(surface)) {
|
|
16260
|
-
throw new Error(
|
|
16261
|
-
`--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.`
|
|
16262
|
-
);
|
|
16263
|
-
}
|
|
16264
|
-
if (runs.some((run) => run.domain === domain2 && run.surface === surface)) {
|
|
16265
|
-
warnings.push(`--run ${token} repeats ${domain2}:${surface}; the two are one part.`);
|
|
16266
|
-
continue;
|
|
16267
|
-
}
|
|
16268
|
-
const suffix = `${domain2.toLowerCase()}-${surface.toLowerCase()}`;
|
|
16269
|
-
const other = tokenBySuffix.get(suffix);
|
|
16270
|
-
if (other !== void 0) {
|
|
16271
|
-
throw new Error(
|
|
16272
|
-
`--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.`
|
|
16273
|
-
);
|
|
16274
|
-
}
|
|
16275
|
-
tokenBySuffix.set(suffix, token);
|
|
16276
|
-
runs.push({ domain: domain2, surface });
|
|
16277
|
-
}
|
|
16278
|
-
return { runs, warnings };
|
|
16279
|
-
}
|
|
16280
|
-
function planCells(library, surfaces, run) {
|
|
16281
|
-
const byId = /* @__PURE__ */ new Map();
|
|
16282
|
-
for (const criterion of Array.isArray(library.criteria) ? library.criteria : []) {
|
|
16283
|
-
if (typeof criterion?.id === "string" && !byId.has(criterion.id)) byId.set(criterion.id, criterion);
|
|
16284
|
-
}
|
|
16285
|
-
const cells = [];
|
|
16286
|
-
let steps = 0;
|
|
16287
|
-
for (const entry of applicableCells(library, surfaces)) {
|
|
16288
|
-
if (!entry.surfaces.includes(run.surface)) continue;
|
|
16289
|
-
if (domainCodeOf(entry.criterion_id, library) !== run.domain) continue;
|
|
16290
|
-
cells.push({ criterion_id: entry.criterion_id, surface: run.surface });
|
|
16291
|
-
const checklist = byId.get(entry.criterion_id)?.checklist;
|
|
16292
|
-
steps += Array.isArray(checklist) ? checklist.length : 0;
|
|
16293
|
-
}
|
|
16294
|
-
return { cells, steps };
|
|
16295
|
-
}
|
|
16296
|
-
function applicableCellCount(library, surfaces) {
|
|
16297
|
-
let count = 0;
|
|
16298
|
-
for (const entry of applicableCells(library, surfaces)) count += entry.surfaces.length;
|
|
16299
|
-
return count;
|
|
16300
|
-
}
|
|
16301
16281
|
function planPartId(planId2, domain2, surface) {
|
|
16302
16282
|
const id = `${planId2}-${domain2.toLowerCase()}-${surface.toLowerCase()}`;
|
|
16303
16283
|
if (isScopedAuditId(id)) {
|
|
@@ -16307,22 +16287,6 @@ function planPartId(planId2, domain2, surface) {
|
|
|
16307
16287
|
}
|
|
16308
16288
|
return id;
|
|
16309
16289
|
}
|
|
16310
|
-
function planId(input) {
|
|
16311
|
-
const { now, known, runs } = input;
|
|
16312
|
-
if (runs.length === 0) throw new Error("a plan id needs at least one run: with none, no part is checked to sort last");
|
|
16313
|
-
const ids = known.filter((id) => typeof id === "string" && id !== "");
|
|
16314
|
-
const greatest = [...ids].sort().at(-1);
|
|
16315
|
-
const year = String(now.getFullYear()).padStart(4, "0");
|
|
16316
|
-
const month = String(now.getMonth() + 1).padStart(2, "0");
|
|
16317
|
-
const day = String(now.getDate()).padStart(2, "0");
|
|
16318
|
-
for (let n = 0; n < 100; n++) {
|
|
16319
|
-
const candidate = `${year}-${month}-zplan-${day}${String(n).padStart(2, "0")}`;
|
|
16320
|
-
if (ids.some((id) => id === candidate || id.startsWith(`${candidate}-`))) continue;
|
|
16321
|
-
if (greatest !== void 0 && !runs.every((run) => planPartId(candidate, run.domain, run.surface) > greatest)) continue;
|
|
16322
|
-
return candidate;
|
|
16323
|
-
}
|
|
16324
|
-
throw new Error(`no plan id on ${year}-${month}-${day} sorts after "${greatest}"`);
|
|
16325
|
-
}
|
|
16326
16290
|
function outsortedBy(partId, known) {
|
|
16327
16291
|
const plan = planIdOfPartId(partId);
|
|
16328
16292
|
if (plan === null) return [];
|
|
@@ -16364,161 +16328,33 @@ function readPlanScope(scope) {
|
|
|
16364
16328
|
coverage: readCoverage(row.coverage)
|
|
16365
16329
|
};
|
|
16366
16330
|
}
|
|
16367
|
-
function
|
|
16368
|
-
const
|
|
16369
|
-
const
|
|
16370
|
-
|
|
16371
|
-
|
|
16372
|
-
|
|
16373
|
-
|
|
16374
|
-
|
|
16331
|
+
function coverageNotes(coverage, overall) {
|
|
16332
|
+
const notes = [];
|
|
16333
|
+
const surfaces = coverage.surfaces ?? {};
|
|
16334
|
+
for (const surface of Object.keys(surfaces)) {
|
|
16335
|
+
const { assessed, applicable } = surfaces[surface];
|
|
16336
|
+
if (!(assessed < applicable)) continue;
|
|
16337
|
+
const score = Object.prototype.hasOwnProperty.call(overall, surface) ? overall[surface] : void 0;
|
|
16338
|
+
notes.push(`${surface} ${typeof score === "number" ? score : "\u2014"}, from ${assessed} of ${applicable} cells`);
|
|
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;
|
|
16375
16353
|
}
|
|
16376
|
-
|
|
16377
|
-
|
|
16378
|
-
|
|
16379
|
-
|
|
16380
|
-
domain: run.domain,
|
|
16381
|
-
surface: run.surface,
|
|
16382
|
-
auditId: planPartId(id, run.domain, run.surface),
|
|
16383
|
-
cells,
|
|
16384
|
-
steps,
|
|
16385
|
-
estimate: null,
|
|
16386
|
-
status: "included"
|
|
16387
|
-
}));
|
|
16388
|
-
const included = parts.filter((part) => part.status === "included");
|
|
16389
|
-
const head = {
|
|
16390
|
-
schema: KRITIK_PLAN_SCHEMA,
|
|
16391
|
-
planId: id,
|
|
16392
|
-
createdAt: now.toISOString(),
|
|
16393
|
-
commit,
|
|
16394
|
-
frameworkVersion: library.version,
|
|
16395
|
-
tier: null,
|
|
16396
|
-
budgetTokens: null,
|
|
16397
|
-
budgetUsd: null,
|
|
16398
|
-
pricePerMTok: null,
|
|
16399
|
-
totals: {
|
|
16400
|
-
cells: included.reduce((sum, part) => sum + part.cells.length, 0),
|
|
16401
|
-
steps: included.reduce((sum, part) => sum + part.steps, 0),
|
|
16402
|
-
applicableCells: applicableCellCount(library, surfaces),
|
|
16403
|
-
tokens: null,
|
|
16404
|
-
usd: null
|
|
16405
|
-
},
|
|
16406
|
-
recordCommand: planRecordCommand(id)
|
|
16407
|
-
};
|
|
16408
|
-
return {
|
|
16409
|
-
schema: head.schema,
|
|
16410
|
-
planId: head.planId,
|
|
16411
|
-
createdAt: head.createdAt,
|
|
16412
|
-
commit: head.commit,
|
|
16413
|
-
frameworkVersion: head.frameworkVersion,
|
|
16414
|
-
tier: head.tier,
|
|
16415
|
-
budgetTokens: head.budgetTokens,
|
|
16416
|
-
budgetUsd: head.budgetUsd,
|
|
16417
|
-
pricePerMTok: head.pricePerMTok,
|
|
16418
|
-
parts: parts.map((part) => ({ ...part, prompt: renderPartPrompt({ planId: id, commit }, part) })),
|
|
16419
|
-
totals: head.totals,
|
|
16420
|
-
prompt: renderPlanPrompt({ ...head, parts }),
|
|
16421
|
-
recordCommand: head.recordCommand
|
|
16422
|
-
};
|
|
16423
|
-
}
|
|
16424
|
-
function planPartStatuses(plan, scoresByPart) {
|
|
16425
|
-
return plan.parts.map((part) => {
|
|
16426
|
-
const planned = new Set(part.cells.map((cell) => planCellKey(cell.criterion_id, cell.surface)));
|
|
16427
|
-
const scoredKeys = /* @__PURE__ */ new Set();
|
|
16428
|
-
const strayKeys = /* @__PURE__ */ new Set();
|
|
16429
|
-
const stray = [];
|
|
16430
|
-
const scores = Object.prototype.hasOwnProperty.call(scoresByPart, part.auditId) ? scoresByPart[part.auditId] : [];
|
|
16431
|
-
for (const score of scores) {
|
|
16432
|
-
const key = planCellKey(score.criterion_id, score.surface);
|
|
16433
|
-
if (planned.has(key)) scoredKeys.add(key);
|
|
16434
|
-
else if (!strayKeys.has(key)) {
|
|
16435
|
-
strayKeys.add(key);
|
|
16436
|
-
stray.push({ criterion_id: score.criterion_id, surface: score.surface });
|
|
16437
|
-
}
|
|
16438
|
-
}
|
|
16439
|
-
const missing = part.cells.filter((cell) => !scoredKeys.has(planCellKey(cell.criterion_id, cell.surface)));
|
|
16440
|
-
const scored = part.cells.length - missing.length;
|
|
16441
|
-
const progress = part.status === "deferred" ? "deferred" : scored === 0 && stray.length === 0 ? "not started" : missing.length === 0 ? "scored" : "in progress";
|
|
16442
|
-
return {
|
|
16443
|
-
auditId: part.auditId,
|
|
16444
|
-
domain: part.domain,
|
|
16445
|
-
surface: part.surface,
|
|
16446
|
-
progress,
|
|
16447
|
-
scored,
|
|
16448
|
-
cells: part.cells.length,
|
|
16449
|
-
missing,
|
|
16450
|
-
stray
|
|
16451
|
-
};
|
|
16452
|
-
});
|
|
16453
|
-
}
|
|
16454
|
-
function coverageOf(section, library, scored = 0) {
|
|
16455
|
-
const assessments = Array.isArray(section.assessments) ? section.assessments : [];
|
|
16456
|
-
const listed = section.profile?.surfaces;
|
|
16457
|
-
const surfaces = [];
|
|
16458
|
-
for (const surface of Array.isArray(listed) ? listed : []) {
|
|
16459
|
-
const id = surface?.id;
|
|
16460
|
-
if (typeof id === "string" && id !== "" && id !== CROSS_SURFACE_ID && !surfaces.includes(id)) surfaces.push(id);
|
|
16461
|
-
}
|
|
16462
|
-
if (surfaces.length === 0) {
|
|
16463
|
-
for (const assessment of assessments) {
|
|
16464
|
-
const id = assessment?.surface;
|
|
16465
|
-
if (typeof id === "string" && id !== "" && id !== CROSS_SURFACE_ID && !surfaces.includes(id)) surfaces.push(id);
|
|
16466
|
-
}
|
|
16467
|
-
}
|
|
16468
|
-
const perSurface = /* @__PURE__ */ new Map();
|
|
16469
|
-
for (const surface of surfaces) perSurface.set(surface, { assessed: 0, applicable: 0 });
|
|
16470
|
-
const applicable = /* @__PURE__ */ new Set();
|
|
16471
|
-
for (const entry of applicableCells(library, surfaces)) {
|
|
16472
|
-
for (const surface of entry.surfaces) {
|
|
16473
|
-
const counts = perSurface.get(surface);
|
|
16474
|
-
if (counts === void 0) continue;
|
|
16475
|
-
applicable.add(planCellKey(entry.criterion_id, surface));
|
|
16476
|
-
counts.applicable++;
|
|
16477
|
-
}
|
|
16478
|
-
}
|
|
16479
|
-
const assessed = /* @__PURE__ */ new Set();
|
|
16480
|
-
for (const assessment of assessments) {
|
|
16481
|
-
if (typeof assessment?.criterion_id !== "string" || typeof assessment?.surface !== "string") continue;
|
|
16482
|
-
const key = planCellKey(assessment.criterion_id, assessment.surface);
|
|
16483
|
-
if (!applicable.has(key) || assessed.has(key)) continue;
|
|
16484
|
-
assessed.add(key);
|
|
16485
|
-
const counts = perSurface.get(assessment.surface);
|
|
16486
|
-
if (counts !== void 0) counts.assessed++;
|
|
16487
|
-
}
|
|
16488
|
-
const bySurface = {};
|
|
16489
|
-
for (const [surface, counts] of perSurface) {
|
|
16490
|
-
if (surface === "__proto__") continue;
|
|
16491
|
-
bySurface[surface] = counts;
|
|
16492
|
-
}
|
|
16493
|
-
return { scored, assessed: assessed.size, applicable: applicable.size, surfaces: bySurface };
|
|
16494
|
-
}
|
|
16495
|
-
function coverageNotes(coverage, overall) {
|
|
16496
|
-
const notes = [];
|
|
16497
|
-
const surfaces = coverage.surfaces ?? {};
|
|
16498
|
-
for (const surface of Object.keys(surfaces)) {
|
|
16499
|
-
const { assessed, applicable } = surfaces[surface];
|
|
16500
|
-
if (!(assessed < applicable)) continue;
|
|
16501
|
-
const score = Object.prototype.hasOwnProperty.call(overall, surface) ? overall[surface] : void 0;
|
|
16502
|
-
notes.push(`${surface} ${typeof score === "number" ? score : "\u2014"}, from ${assessed} of ${applicable} cells`);
|
|
16503
|
-
}
|
|
16504
|
-
return notes;
|
|
16505
|
-
}
|
|
16506
|
-
function auditReadings(auditIds) {
|
|
16507
|
-
const readings = [];
|
|
16508
|
-
const byId = /* @__PURE__ */ new Map();
|
|
16509
|
-
const lastAt = /* @__PURE__ */ new Map();
|
|
16510
|
-
auditIds.forEach((auditId, index) => {
|
|
16511
|
-
const id = planIdOfPartId(auditId) ?? auditId;
|
|
16512
|
-
const existing = byId.get(id);
|
|
16513
|
-
if (existing !== void 0) {
|
|
16514
|
-
existing.auditIds.push(auditId);
|
|
16515
|
-
lastAt.set(existing, index);
|
|
16516
|
-
return;
|
|
16517
|
-
}
|
|
16518
|
-
const reading = { id, auditIds: [auditId] };
|
|
16519
|
-
byId.set(id, reading);
|
|
16520
|
-
lastAt.set(reading, index);
|
|
16521
|
-
readings.push(reading);
|
|
16354
|
+
const reading = { id, auditIds: [auditId] };
|
|
16355
|
+
byId.set(id, reading);
|
|
16356
|
+
lastAt.set(reading, index);
|
|
16357
|
+
readings.push(reading);
|
|
16522
16358
|
});
|
|
16523
16359
|
return readings.sort((a, b) => (lastAt.get(a) ?? 0) - (lastAt.get(b) ?? 0));
|
|
16524
16360
|
}
|
|
@@ -16714,13 +16550,6 @@ var KritikPlanSchema = external_exports.object({
|
|
|
16714
16550
|
});
|
|
16715
16551
|
});
|
|
16716
16552
|
});
|
|
16717
|
-
function parseKritikPlan(value) {
|
|
16718
|
-
const result = KritikPlanSchema.safeParse(value);
|
|
16719
|
-
if (result.success) return { ok: true, plan: result.data };
|
|
16720
|
-
const first = result.error.issues[0];
|
|
16721
|
-
const path = first === void 0 ? "" : first.path.map(String).join(".");
|
|
16722
|
-
return { ok: false, issue: `${path === "" ? "(root)" : path}: ${first?.message ?? "not a plan"}` };
|
|
16723
|
-
}
|
|
16724
16553
|
|
|
16725
16554
|
// ../schema/src/bundle.ts
|
|
16726
16555
|
var PlatformStatusMapSchema = external_exports.partialRecord(
|
|
@@ -16796,10 +16625,31 @@ var NodeMetadataSchema = external_exports.object({
|
|
|
16796
16625
|
}),
|
|
16797
16626
|
decided_at: external_exports.string().optional().meta({
|
|
16798
16627
|
description: "Decision nodes only: ISO 8601 date the decision was made."
|
|
16799
|
-
})
|
|
16628
|
+
}),
|
|
16629
|
+
stake_species: StakeSpeciesSchema.optional().meta({
|
|
16630
|
+
description: "Stake nodes only: bug | friction | need | requirement | risk | defect."
|
|
16631
|
+
}),
|
|
16632
|
+
provenance: StakeProvenanceSchema.optional().meta({
|
|
16633
|
+
description: "Stake nodes only: observed (default when absent) or anticipated."
|
|
16634
|
+
}),
|
|
16635
|
+
catalog: external_exports.object({
|
|
16636
|
+
source: StakeCatalogSourceSchema,
|
|
16637
|
+
id: external_exports.string().meta({ description: "A Kritik criterion id (SAF-01) or a value id (reduces-anxiety). Nothing else is copied." })
|
|
16638
|
+
}).optional().meta({ description: "Stake nodes only: link into the Kritik criteria or the value pyramid, by id." }),
|
|
16639
|
+
evidence: external_exports.array(
|
|
16640
|
+
external_exports.object({
|
|
16641
|
+
event_id: external_exports.string().optional().meta({ description: "The journal event (a request.filed) the evidence came from." }),
|
|
16642
|
+
quote: external_exports.string().optional().meta({ description: "The line that matters, exactly as voiced." }),
|
|
16643
|
+
voice: StakeEvidenceVoiceSchema.optional().meta({ description: "Who voiced it: person | maintainer | agent." }),
|
|
16644
|
+
date: external_exports.string().optional().meta({ description: "ISO 8601 date the evidence was voiced." })
|
|
16645
|
+
}).catchall(external_exports.unknown())
|
|
16646
|
+
).optional().meta({ description: "Stake nodes only: the signals behind the stake, one entry per signal. Written at qualification." }),
|
|
16647
|
+
felt: StakeFeltSchema.optional(),
|
|
16648
|
+
matters: StakeMattersSchema.optional(),
|
|
16649
|
+
frequency: StakeFrequencySchema.optional()
|
|
16800
16650
|
}).catchall(external_exports.unknown()).meta({ id: "NodeMetadata", description: "Optional metadata for a node." });
|
|
16801
16651
|
var NodeSchema = external_exports.object({
|
|
16802
|
-
id: external_exports.string().meta({ description: "Unique node ID. Convention: prefix with species \u2014 F- (flow), V- (view), DM- (data-model), API- (api-endpoint)." }),
|
|
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)." }),
|
|
16803
16653
|
project_id: external_exports.string().meta({ description: "Must match project.id." }),
|
|
16804
16654
|
species: SpeciesSchema,
|
|
16805
16655
|
title: external_exports.string().meta({ description: "Human-readable node title." }),
|
|
@@ -17144,7 +16994,7 @@ var LADDERS = {
|
|
|
17144
16994
|
"-1": "Costs the person a little time on one task inside the product.",
|
|
17145
16995
|
"1": "Saves a little time on one task inside the product.",
|
|
17146
16996
|
"2": "Saves time on tasks the person does regularly in this domain.",
|
|
17147
|
-
"3": "Gives the person back hours of their life
|
|
16997
|
+
"3": "Gives the person back hours of their life."
|
|
17148
16998
|
},
|
|
17149
16999
|
simplifies: {
|
|
17150
17000
|
"-3": "Makes a part of the person's life confusing or hard to manage.",
|
|
@@ -17152,7 +17002,7 @@ var LADDERS = {
|
|
|
17152
17002
|
"-1": "Adds a step or a choice inside the product.",
|
|
17153
17003
|
"1": "Removes a step or a choice inside the product.",
|
|
17154
17004
|
"2": "Makes a whole task in this domain clearly simpler.",
|
|
17155
|
-
"3": "Makes a complicated part of the person's life simple
|
|
17005
|
+
"3": "Makes a complicated part of the person's life simple."
|
|
17156
17006
|
},
|
|
17157
17007
|
"makes-money": {
|
|
17158
17008
|
"-3": "Costs the person a meaningful part of their income.",
|
|
@@ -17168,7 +17018,7 @@ var LADDERS = {
|
|
|
17168
17018
|
"-1": "Exposes the person to a small mistake or loss inside the product.",
|
|
17169
17019
|
"1": "Guards against a small mistake or loss inside the product.",
|
|
17170
17020
|
"2": "Protects against a serious loss or error in this domain.",
|
|
17171
|
-
"3": "Protects against a major loss in the person's life
|
|
17021
|
+
"3": "Protects against a major loss in the person's life."
|
|
17172
17022
|
},
|
|
17173
17023
|
organizes: {
|
|
17174
17024
|
"-3": "Brings disorder to a large part of the person's life.",
|
|
@@ -17176,7 +17026,7 @@ var LADDERS = {
|
|
|
17176
17026
|
"-1": "Leaves a few things in disorder inside the product.",
|
|
17177
17027
|
"1": "Keeps a few things in order inside the product.",
|
|
17178
17028
|
"2": "Keeps everything in this domain in order and easy to find.",
|
|
17179
|
-
"3": "Brings order to a large part of the person's life
|
|
17029
|
+
"3": "Brings order to a large part of the person's life."
|
|
17180
17030
|
},
|
|
17181
17031
|
integrates: {
|
|
17182
17032
|
"-3": "Pulls separate parts of the person's life further apart.",
|
|
@@ -17196,10 +17046,10 @@ var LADDERS = {
|
|
|
17196
17046
|
},
|
|
17197
17047
|
"reduces-effort": {
|
|
17198
17048
|
"-3": "Puts a heavy burden of work on the person's life.",
|
|
17199
|
-
"-2": "
|
|
17049
|
+
"-2": "Makes a whole task clearly more demanding.",
|
|
17200
17050
|
"-1": "Adds a little effort to one task inside the product.",
|
|
17201
17051
|
"1": "Saves a little effort on one task inside the product.",
|
|
17202
|
-
"2": "
|
|
17052
|
+
"2": "Makes a whole task clearly less demanding.",
|
|
17203
17053
|
"3": "Lifts a heavy burden of work off the person's life."
|
|
17204
17054
|
},
|
|
17205
17055
|
"avoids-hassles": {
|
|
@@ -17208,7 +17058,7 @@ var LADDERS = {
|
|
|
17208
17058
|
"-1": "Adds a small annoyance inside the product.",
|
|
17209
17059
|
"1": "Avoids a small annoyance inside the product.",
|
|
17210
17060
|
"2": "Avoids an annoyance that keeps coming back in this domain.",
|
|
17211
|
-
"3": "Takes a whole kind of annoyance out of the person's life
|
|
17061
|
+
"3": "Takes a whole kind of annoyance out of the person's life."
|
|
17212
17062
|
},
|
|
17213
17063
|
"reduces-cost": {
|
|
17214
17064
|
"-3": "Costs the person a significant amount of money over their life.",
|
|
@@ -17220,25 +17070,25 @@ var LADDERS = {
|
|
|
17220
17070
|
},
|
|
17221
17071
|
quality: {
|
|
17222
17072
|
"-3": "Craft so poor the person would call it the worst they have used.",
|
|
17223
|
-
"-2": "The product
|
|
17224
|
-
"-1": "Something inside the product
|
|
17225
|
-
"1": "Something inside the product
|
|
17226
|
-
"2": "The product
|
|
17073
|
+
"-2": "The product feels unreliable and poorly made throughout.",
|
|
17074
|
+
"-1": "Something inside the product feels unreliable or half-made.",
|
|
17075
|
+
"1": "Something inside the product feels robust.",
|
|
17076
|
+
"2": "The product feels dependable and well crafted throughout.",
|
|
17227
17077
|
"3": "Craft so good the person would call it the best they have used."
|
|
17228
17078
|
},
|
|
17229
17079
|
variety: {
|
|
17230
|
-
"-3": "
|
|
17231
|
-
"-2": "
|
|
17232
|
-
"-1": "
|
|
17233
|
-
"1": "Offers a few
|
|
17234
|
-
"2": "Offers a wide
|
|
17235
|
-
"3": "
|
|
17080
|
+
"-3": "Locks the person into a narrow range of choices in their life.",
|
|
17081
|
+
"-2": "Limits the person to a narrow range of choices.",
|
|
17082
|
+
"-1": "Does not offer enough options inside the product.",
|
|
17083
|
+
"1": "Offers the person a few options inside the product.",
|
|
17084
|
+
"2": "Offers the person a wide choice.",
|
|
17085
|
+
"3": "Offers the person a breadth of choice they can shape to their own life."
|
|
17236
17086
|
},
|
|
17237
17087
|
"sensory-appeal": {
|
|
17238
17088
|
"-3": "A sensory experience the person avoids.",
|
|
17239
17089
|
"-2": "The product looks, sounds or feels bad and the person dislikes using it.",
|
|
17240
|
-
"-1": "
|
|
17241
|
-
"1": "A
|
|
17090
|
+
"-1": "A look, a sound or a feel the person would point to as unpleasant.",
|
|
17091
|
+
"1": "A look, a sound or a feel the person would point to as pleasant.",
|
|
17242
17092
|
"2": "The product looks, sounds or feels good and the person enjoys using it.",
|
|
17243
17093
|
"3": "A sensory experience the person seeks out for its own sake."
|
|
17244
17094
|
},
|
|
@@ -17251,25 +17101,25 @@ var LADDERS = {
|
|
|
17251
17101
|
"3": "Informs the person deeply and efficiently about the service area or domain."
|
|
17252
17102
|
},
|
|
17253
17103
|
"reduces-anxiety": {
|
|
17254
|
-
"-3": "
|
|
17104
|
+
"-3": "Leaves the person anxious about something important in their life.",
|
|
17255
17105
|
"-2": "Stirs up a worry the person has in this domain.",
|
|
17256
17106
|
"-1": "Adds a small worry inside the product.",
|
|
17257
17107
|
"1": "Removes a small worry inside the product.",
|
|
17258
17108
|
"2": "Calms a worry the person has in this domain.",
|
|
17259
|
-
"3": "
|
|
17109
|
+
"3": "Brings the person lasting peace of mind about something important."
|
|
17260
17110
|
},
|
|
17261
17111
|
"rewards-me": {
|
|
17262
|
-
"-3": "
|
|
17263
|
-
"-2": "
|
|
17264
|
-
"-1": "
|
|
17112
|
+
"-3": "Does not give rewards the person values as much as the product itself.",
|
|
17113
|
+
"-2": "Does not give the perks the person regularly expects.",
|
|
17114
|
+
"-1": "Does not give a small perk where the person would expect one.",
|
|
17265
17115
|
"1": "Gives the person a small perk for engaging.",
|
|
17266
17116
|
"2": "Gives the person regular perks they value.",
|
|
17267
17117
|
"3": "Gives the person rewards they value as much as the product itself."
|
|
17268
17118
|
},
|
|
17269
17119
|
nostalgia: {
|
|
17270
|
-
"-3": "
|
|
17271
|
-
"-2": "
|
|
17272
|
-
"-1": "
|
|
17120
|
+
"-3": "Ruins a cherished memory for good.",
|
|
17121
|
+
"-2": "Clearly tarnishes a good memory of the past.",
|
|
17122
|
+
"-1": "Dulls a pleasant memory of the past.",
|
|
17273
17123
|
"1": "Faintly recalls a pleasant memory of the past.",
|
|
17274
17124
|
"2": "Clearly brings back a good memory of the past.",
|
|
17275
17125
|
"3": "Brings back a cherished past in a vivid and deeply felt way."
|
|
@@ -17299,9 +17149,9 @@ var LADDERS = {
|
|
|
17299
17149
|
"3": "Lastingly improves the person's physical or mental well-being."
|
|
17300
17150
|
},
|
|
17301
17151
|
"therapeutic-value": {
|
|
17302
|
-
"-3": "
|
|
17152
|
+
"-3": "Causes the person lasting emotional hurt.",
|
|
17303
17153
|
"-2": "Makes a difficult feeling harder for the person to work through.",
|
|
17304
|
-
"-1": "
|
|
17154
|
+
"-1": "Gets in the way of a moment of emotional relief.",
|
|
17305
17155
|
"1": "Gives a small moment of emotional relief.",
|
|
17306
17156
|
"2": "Helps the person work through a difficult feeling.",
|
|
17307
17157
|
"3": "Supports real healing of something that hurts the person."
|
|
@@ -17315,68 +17165,68 @@ var LADDERS = {
|
|
|
17315
17165
|
"3": "Delight the person would seek out and tell others about."
|
|
17316
17166
|
},
|
|
17317
17167
|
attractiveness: {
|
|
17318
|
-
"-3": "
|
|
17168
|
+
"-3": "Leaves the person feeling unattractive in their everyday life.",
|
|
17319
17169
|
"-2": "Clearly makes the person feel less attractive.",
|
|
17320
17170
|
"-1": "Makes the person feel slightly worse about how they look.",
|
|
17321
17171
|
"1": "Makes the person feel slightly better about how they look.",
|
|
17322
17172
|
"2": "Clearly makes the person feel more attractive.",
|
|
17323
|
-
"3": "
|
|
17173
|
+
"3": "Leaves the person feeling attractive in their everyday life."
|
|
17324
17174
|
},
|
|
17325
17175
|
"provides-access": {
|
|
17326
|
-
"-3": "
|
|
17327
|
-
"-2": "
|
|
17328
|
-
"-1": "Puts a
|
|
17329
|
-
"1": "
|
|
17330
|
-
"2": "
|
|
17331
|
-
"3": "
|
|
17176
|
+
"-3": "Makes something that matters in the person's life much harder to reach.",
|
|
17177
|
+
"-2": "Makes services, people, knowledge or capabilities harder to reach.",
|
|
17178
|
+
"-1": "Puts a barrier in front of a feature inside the product.",
|
|
17179
|
+
"1": "Lowers a barrier to a feature inside the product.",
|
|
17180
|
+
"2": "Makes services, people, knowledge or capabilities easier to reach.",
|
|
17181
|
+
"3": "Makes something that matters in the person's life much easier to reach."
|
|
17332
17182
|
},
|
|
17333
17183
|
"provides-hope": {
|
|
17334
17184
|
"-3": "Leaves the person believing their life cannot get better.",
|
|
17335
|
-
"-2": "Gives the person a reason to doubt that things
|
|
17336
|
-
"-1": "
|
|
17337
|
-
"1": "Gives a
|
|
17338
|
-
"2": "Gives a real reason to believe things
|
|
17185
|
+
"-2": "Gives the person a reason to doubt that things can improve.",
|
|
17186
|
+
"-1": "Gets in the way of the person's hope.",
|
|
17187
|
+
"1": "Gives the person a glimmer of hope.",
|
|
17188
|
+
"2": "Gives a real reason to believe that things can improve.",
|
|
17339
17189
|
"3": "Gives a lasting belief that the person's life can get better."
|
|
17340
17190
|
},
|
|
17341
17191
|
"self-actualization": {
|
|
17342
|
-
"-3": "
|
|
17343
|
-
"-2": "
|
|
17344
|
-
"-1": "
|
|
17192
|
+
"-3": "A drift away from who the person wants to be.",
|
|
17193
|
+
"-2": "A step away from who the person wants to be.",
|
|
17194
|
+
"-1": "Keeps the person from becoming who they want to be.",
|
|
17345
17195
|
"1": "A small step toward who the person wants to be.",
|
|
17346
17196
|
"2": "Clear progress toward who the person wants to be.",
|
|
17347
17197
|
"3": "Helps the person become who they want to be."
|
|
17348
17198
|
},
|
|
17349
17199
|
motivation: {
|
|
17350
|
-
"-3": "Drains the person's
|
|
17351
|
-
"-2": "
|
|
17352
|
-
"-1": "
|
|
17353
|
-
"1": "
|
|
17354
|
-
"2": "
|
|
17200
|
+
"-3": "Drains the person's energy toward goals that matter in their life.",
|
|
17201
|
+
"-2": "A drag on the person's drive.",
|
|
17202
|
+
"-1": "Discourages the person from starting.",
|
|
17203
|
+
"1": "Gives the person a spark of motivation.",
|
|
17204
|
+
"2": "Keeps the person energized toward a goal.",
|
|
17355
17205
|
"3": "Sustains the person's drive toward goals that matter in their life."
|
|
17356
17206
|
},
|
|
17357
17207
|
heirloom: {
|
|
17358
|
-
"-3": "
|
|
17359
|
-
"-2": "
|
|
17360
|
-
"-1": "
|
|
17208
|
+
"-3": "Prevents something meaningful from being passed on to others.",
|
|
17209
|
+
"-2": "Prevents something meaningful from being preserved for years.",
|
|
17210
|
+
"-1": "Gets in the way of keeping something worth keeping.",
|
|
17361
17211
|
"1": "Keeps something worth keeping for a while.",
|
|
17362
17212
|
"2": "Preserves something meaningful for years.",
|
|
17363
17213
|
"3": "Holds something meaningful enough to be passed on to others across time."
|
|
17364
17214
|
},
|
|
17365
17215
|
"affiliation-belonging": {
|
|
17366
17216
|
"-3": "Cuts the person off from a group that matters deeply to who they are.",
|
|
17367
|
-
"-2": "
|
|
17368
|
-
"-1": "
|
|
17369
|
-
"1": "A feeling of being part of something
|
|
17370
|
-
"2": "Makes the person part of a group
|
|
17217
|
+
"-2": "Keeps the person from becoming part of a group or community.",
|
|
17218
|
+
"-1": "Gets in the way of feeling part of something meaningful.",
|
|
17219
|
+
"1": "A feeling of being part of something meaningful.",
|
|
17220
|
+
"2": "Makes the person part of a group or community.",
|
|
17371
17221
|
"3": "Makes the person part of a group that matters deeply to who they are."
|
|
17372
17222
|
},
|
|
17373
17223
|
"self-transcendence": {
|
|
17374
|
-
"-3": "
|
|
17375
|
-
"-2": "
|
|
17376
|
-
"-1": "
|
|
17377
|
-
"1": "
|
|
17378
|
-
"2": "
|
|
17379
|
-
"3": "
|
|
17224
|
+
"-3": "Keeps the person from contributing to major or meaningful causes.",
|
|
17225
|
+
"-2": "Keeps the person from making a lasting difference for other people or causes.",
|
|
17226
|
+
"-1": "Keeps the person from giving something real to others.",
|
|
17227
|
+
"1": "Lets the person give something real to others at a human scale.",
|
|
17228
|
+
"2": "Lets the person make a lasting difference for other people or causes.",
|
|
17229
|
+
"3": "Lets the person contribute to major or meaningful causes."
|
|
17380
17230
|
}
|
|
17381
17231
|
};
|
|
17382
17232
|
var VALUE_REACH_LADDERS = Object.freeze(
|
|
@@ -17393,16 +17243,12 @@ var CONFIDENCE_ANCHORS = {
|
|
|
17393
17243
|
};
|
|
17394
17244
|
var SCORER_KINDS = ["human", "agent", "rule"];
|
|
17395
17245
|
var STORED_SCORER_KINDS = ["human", "agent"];
|
|
17396
|
-
function scorerRank(kind) {
|
|
17397
|
-
const index = SCORER_KINDS.indexOf(kind);
|
|
17398
|
-
return index === -1 ? 0 : SCORER_KINDS.length - index;
|
|
17399
|
-
}
|
|
17400
17246
|
var WEIGHING_PROBABILITY_FIELDS = ["p_serves", "p_costs"];
|
|
17401
17247
|
function isWeighingProbability(value) {
|
|
17402
17248
|
return typeof value === "number" && Number.isFinite(value) && value >= 0 && value <= 1;
|
|
17403
17249
|
}
|
|
17404
|
-
var WEIGHING_CLEAR_AT = 0.
|
|
17405
|
-
var WEIGHING_UNSETTLED_AT = 0.
|
|
17250
|
+
var WEIGHING_CLEAR_AT = 0.9;
|
|
17251
|
+
var WEIGHING_UNSETTLED_AT = 0.5;
|
|
17406
17252
|
function isUncertainCell(row) {
|
|
17407
17253
|
const serves = isWeighingProbability(row.p_serves) ? row.p_serves : void 0;
|
|
17408
17254
|
const costs = isWeighingProbability(row.p_costs) ? row.p_costs : void 0;
|
|
@@ -17458,6 +17304,19 @@ function acceptanceFingerprint(node) {
|
|
|
17458
17304
|
const text = JSON.stringify([squash(node.title ?? ""), squash(gherkin), values]);
|
|
17459
17305
|
return `fp1-${hash53(text).toString(16).padStart(14, "0")}`;
|
|
17460
17306
|
}
|
|
17307
|
+
function stakeFingerprint(node) {
|
|
17308
|
+
const species = typeof node.metadata?.stake_species === "string" ? node.metadata.stake_species : "";
|
|
17309
|
+
const text = JSON.stringify(["stake", squash(node.title ?? ""), species]);
|
|
17310
|
+
return `fp1-${hash53(text).toString(16).padStart(14, "0")}`;
|
|
17311
|
+
}
|
|
17312
|
+
function fingerprintOf(node) {
|
|
17313
|
+
return node.species === "stake" ? stakeFingerprint(node) : acceptanceFingerprint(node);
|
|
17314
|
+
}
|
|
17315
|
+
function stakeSpeciesDeclaredBy(set2) {
|
|
17316
|
+
const raw = set2.stake_species;
|
|
17317
|
+
if (!Array.isArray(raw)) return [];
|
|
17318
|
+
return raw.filter((entry) => STAKE_SPECIES_IDS.includes(entry));
|
|
17319
|
+
}
|
|
17461
17320
|
function upsertWeighingAssessment(assessments, next) {
|
|
17462
17321
|
const key = assessmentKey(next);
|
|
17463
17322
|
const index = assessments.findIndex((candidate) => assessmentKey(candidate) === key);
|
|
@@ -17467,13 +17326,6 @@ function upsertWeighingAssessment(assessments, next) {
|
|
|
17467
17326
|
updated[index] = next;
|
|
17468
17327
|
return { assessments: updated, replaced };
|
|
17469
17328
|
}
|
|
17470
|
-
function sortWeighingAssessments(assessments) {
|
|
17471
|
-
return [...assessments].sort((a, b) => {
|
|
17472
|
-
const text = (x) => typeof x === "string" ? x : "\uFFFF";
|
|
17473
|
-
const by = (x, y) => text(x) < text(y) ? -1 : text(x) > text(y) ? 1 : 0;
|
|
17474
|
-
return by(a?.matrix, b?.matrix) || by(a?.subject, b?.subject) || by(a?.criterion, b?.criterion) || scorerRank(b?.scorer?.kind) - scorerRank(a?.scorer?.kind);
|
|
17475
|
-
});
|
|
17476
|
-
}
|
|
17477
17329
|
|
|
17478
17330
|
// ../schema/src/weighing-library.ts
|
|
17479
17331
|
function deepFreeze(value) {
|
|
@@ -17487,6 +17339,7 @@ var VALUE_SET_ID = "value-contribution";
|
|
|
17487
17339
|
var VALUE_SET_VERSION = "2.0.0";
|
|
17488
17340
|
var VALUE_SET_V1_VERSION = "1.0.0";
|
|
17489
17341
|
var VALUE_MATRIX_ID = "value";
|
|
17342
|
+
var STAKE_MATRIX_ID = "stakes";
|
|
17490
17343
|
var POSITIONING_SET_ID = "positioning";
|
|
17491
17344
|
var VALUE_SCALE_ANCHORS = {
|
|
17492
17345
|
"3": "Life-wide. It gives the person this well beyond the product and its domain, in their life.",
|
|
@@ -17557,6 +17410,8 @@ var VALUE_CONTRIBUTION_SET = deepFreeze({
|
|
|
17557
17410
|
version: VALUE_SET_VERSION,
|
|
17558
17411
|
title: "Elements of value",
|
|
17559
17412
|
subject: "acceptance",
|
|
17413
|
+
// The reference declares what it scores (stake architecture, part 4): the user-facing stakes are weighed on the pyramid.
|
|
17414
|
+
stake_species: [...USER_FACING_STAKE_SPECIES],
|
|
17560
17415
|
scale: VALUE_SCALE,
|
|
17561
17416
|
groups: GROUPS,
|
|
17562
17417
|
criteria: VALUE_IDS.map((id) => ({
|
|
@@ -17591,8 +17446,15 @@ var VALUE_MATRIX = deepFreeze({
|
|
|
17591
17446
|
positioning: POSITIONING_SET_ID,
|
|
17592
17447
|
status: "active"
|
|
17593
17448
|
});
|
|
17449
|
+
var STAKE_MATRIX = deepFreeze({
|
|
17450
|
+
id: STAKE_MATRIX_ID,
|
|
17451
|
+
title: "Stakes",
|
|
17452
|
+
set: `${VALUE_SET_ID}@2`,
|
|
17453
|
+
subjects: { kind: "query", species: "stake" },
|
|
17454
|
+
status: "active"
|
|
17455
|
+
});
|
|
17594
17456
|
var BUILT_IN_SETS = [VALUE_CONTRIBUTION_SET, VALUE_CONTRIBUTION_SET_V1];
|
|
17595
|
-
var BUILT_IN_MATRICES = [VALUE_MATRIX];
|
|
17457
|
+
var BUILT_IN_MATRICES = [VALUE_MATRIX, STAKE_MATRIX];
|
|
17596
17458
|
var isObject2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
17597
17459
|
function cleaned(set2) {
|
|
17598
17460
|
const usable = set2.criteria.filter((criterion) => isObject2(criterion) && typeof criterion.id === "string");
|
|
@@ -17640,10 +17502,17 @@ function isOlderMajorRef(resolved, ref) {
|
|
|
17640
17502
|
const now = Number(majorOf(current.version));
|
|
17641
17503
|
return Number.isFinite(now) && Number(major) < now;
|
|
17642
17504
|
}
|
|
17505
|
+
function isMatrixSubject(node, matrix, set2) {
|
|
17506
|
+
if (matrix.subjects.kind !== "query") return matrix.subjects.items.some((item) => (item?.node_id ?? item?.id) === node.id);
|
|
17507
|
+
if (node.species !== matrix.subjects.species) return false;
|
|
17508
|
+
if (node.species !== "stake") return true;
|
|
17509
|
+
const kind = stakeSpeciesOf({ metadata: node.metadata });
|
|
17510
|
+
return kind !== void 0 && set2 !== void 0 && stakeSpeciesDeclaredBy(set2).includes(kind);
|
|
17511
|
+
}
|
|
17643
17512
|
|
|
17644
17513
|
// ../schema/src/weighing-validate.ts
|
|
17645
17514
|
var isObject3 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
17646
|
-
function validateWeighingSection(section, nodeSpecies, journal) {
|
|
17515
|
+
function validateWeighingSection(section, nodeSpecies, journal, stakeSpecies = /* @__PURE__ */ new Map()) {
|
|
17647
17516
|
const out = [];
|
|
17648
17517
|
const warn = (path, rule, message) => out.push({ path, rule, message });
|
|
17649
17518
|
if (section !== void 0 && section !== null && !isObject3(section)) {
|
|
@@ -17700,6 +17569,12 @@ function validateWeighingSection(section, nodeSpecies, journal) {
|
|
|
17700
17569
|
}
|
|
17701
17570
|
}
|
|
17702
17571
|
checkStatus(path, who, entry);
|
|
17572
|
+
if (entry.stake_species !== void 0) {
|
|
17573
|
+
const declared2 = entry.stake_species;
|
|
17574
|
+
if (!Array.isArray(declared2) || !declared2.every((kind) => STAKE_SPECIES_IDS.includes(kind))) {
|
|
17575
|
+
warn(`${path}.stake_species`, "weighing-set-stake-species", `${who}: stake_species must be an array of ${STAKE_SPECIES_IDS.join(", ")} \u2014 what it does not name, it does not score`);
|
|
17576
|
+
}
|
|
17577
|
+
}
|
|
17703
17578
|
if (isObject3(entry.scale)) {
|
|
17704
17579
|
const scale = entry.scale;
|
|
17705
17580
|
if (typeof scale.min !== "number" || typeof scale.max !== "number" || !isLevelMap(scale.anchors)) {
|
|
@@ -17812,6 +17687,15 @@ function validateWeighingSection(section, nodeSpecies, journal) {
|
|
|
17812
17687
|
warn(`${path}.subject`, "weighing-unknown-subject", `${label}: subject "${entry.subject}" is not a node in this bundle`);
|
|
17813
17688
|
} else if (species !== matrix.subjects.species) {
|
|
17814
17689
|
warn(`${path}.subject`, "weighing-subject-species", `${label}: subject "${entry.subject}" is a ${species}, and matrix "${matrix.id}" judges ${String(matrix.subjects.species)} nodes`);
|
|
17690
|
+
} else if (species === "stake" && set2 !== void 0) {
|
|
17691
|
+
const kind = stakeSpecies.get(entry.subject);
|
|
17692
|
+
if (kind === void 0 || !stakeSpeciesDeclaredBy(set2).includes(kind)) {
|
|
17693
|
+
warn(
|
|
17694
|
+
`${path}.subject`,
|
|
17695
|
+
"weighing-subject-stake-species",
|
|
17696
|
+
`${label}: stake "${entry.subject}" is ${kind === void 0 ? "of no stake kind" : `a ${kind}`}, and set "${set2.id}" does not declare it scores that \u2014 a requirement, risk or defect is read against Kritik criteria, never weighed`
|
|
17697
|
+
);
|
|
17698
|
+
}
|
|
17815
17699
|
}
|
|
17816
17700
|
}
|
|
17817
17701
|
if (entry.evidence !== void 0 && typeof entry.evidence !== "string") {
|
|
@@ -17960,7 +17844,7 @@ function validateBundle(input) {
|
|
|
17960
17844
|
}
|
|
17961
17845
|
const platforms = node.platforms;
|
|
17962
17846
|
if (!platforms || platforms.length === 0) {
|
|
17963
|
-
if (species !== "decision") {
|
|
17847
|
+
if (species !== "decision" && species !== "stake") {
|
|
17964
17848
|
error51(`${base}.platforms`, "platforms-non-empty", `Node ${nodeId}: platforms array is empty or missing`);
|
|
17965
17849
|
}
|
|
17966
17850
|
} else {
|
|
@@ -18254,7 +18138,7 @@ function validateBundle(input) {
|
|
|
18254
18138
|
const membership = typeof metadata.product === "string" ? metadata.product : void 0;
|
|
18255
18139
|
const storesMembership = species !== void 0 && PRODUCT_MEMBERSHIP_SPECIES.includes(species);
|
|
18256
18140
|
if (membership !== void 0 && !storesMembership) {
|
|
18257
|
-
const detail = 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";
|
|
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";
|
|
18258
18142
|
warn(`${base}.metadata.product`, "product-membership-wrong-species", `Node ${nodeId}: ${detail}`);
|
|
18259
18143
|
return;
|
|
18260
18144
|
}
|
|
@@ -18370,6 +18254,95 @@ function validateBundle(input) {
|
|
|
18370
18254
|
composesSet.add(`${sourceId}->${targetId}`);
|
|
18371
18255
|
}
|
|
18372
18256
|
});
|
|
18257
|
+
const concernsSources = /* @__PURE__ */ new Set();
|
|
18258
|
+
for (const edge of edges) {
|
|
18259
|
+
if (edge.edge_type === "concerns" && typeof edge.source_id === "string") concernsSources.add(edge.source_id);
|
|
18260
|
+
}
|
|
18261
|
+
nodes.forEach((node, index) => {
|
|
18262
|
+
const nodeId = typeof node.id === "string" ? node.id : `#${index}`;
|
|
18263
|
+
const species = node.species;
|
|
18264
|
+
const base = `nodes[${index}]`;
|
|
18265
|
+
const stakeMd = node.metadata ?? {};
|
|
18266
|
+
if (species !== "stake") {
|
|
18267
|
+
for (const field of ["stake_species", "provenance", "catalog", "evidence", "felt", "matters", "frequency"]) {
|
|
18268
|
+
if (stakeMd[field] !== void 0) {
|
|
18269
|
+
warn(
|
|
18270
|
+
`${base}.metadata.${field}`,
|
|
18271
|
+
"stake-species-wrong-species",
|
|
18272
|
+
`${field} is meaningful on stake nodes only; "${nodeId}" is a ${species}.`
|
|
18273
|
+
);
|
|
18274
|
+
}
|
|
18275
|
+
}
|
|
18276
|
+
return;
|
|
18277
|
+
}
|
|
18278
|
+
const stakeNode = { metadata: node.metadata };
|
|
18279
|
+
const stakeSpecies = stakeSpeciesOf(stakeNode);
|
|
18280
|
+
if (stakeSpecies === void 0) {
|
|
18281
|
+
warn(
|
|
18282
|
+
`${base}.metadata.stake_species`,
|
|
18283
|
+
"stake-species-missing",
|
|
18284
|
+
`Stake ${nodeId}: metadata.stake_species is missing (bug, friction, need, requirement, risk or defect)`
|
|
18285
|
+
);
|
|
18286
|
+
}
|
|
18287
|
+
if (!STAKE_LIFECYCLE_STATUSES.includes(node.status)) {
|
|
18288
|
+
warn(
|
|
18289
|
+
`${base}.status`,
|
|
18290
|
+
"stake-lifecycle",
|
|
18291
|
+
`Stake ${nodeId}: status "${node.status}" is not stored on a stake (idea, discovery or archived only; every other state is derived)`
|
|
18292
|
+
);
|
|
18293
|
+
}
|
|
18294
|
+
if (stakeSpecies !== void 0 && stakeProvenanceOf(stakeNode) === "anticipated" && !ANTICIPATED_STAKE_SPECIES.includes(stakeSpecies)) {
|
|
18295
|
+
warn(
|
|
18296
|
+
`${base}.metadata.provenance`,
|
|
18297
|
+
"stake-anticipated-species",
|
|
18298
|
+
`Stake ${nodeId}: an anticipated stake cannot be a ${stakeSpecies} (nothing exists yet to have one) \u2014 reroute it as a need`
|
|
18299
|
+
);
|
|
18300
|
+
}
|
|
18301
|
+
const catalog = stakeCatalogOf(stakeNode);
|
|
18302
|
+
if (catalog && stakeSpecies !== void 0) {
|
|
18303
|
+
const quality2 = QUALITY_STAKE_SPECIES.includes(stakeSpecies);
|
|
18304
|
+
const userFacing = USER_FACING_STAKE_SPECIES.includes(stakeSpecies);
|
|
18305
|
+
if (quality2 && catalog.source === "values" || userFacing && catalog.source === "kritik") {
|
|
18306
|
+
warn(
|
|
18307
|
+
`${base}.metadata.catalog`,
|
|
18308
|
+
"stake-catalog-mismatch",
|
|
18309
|
+
`Stake ${nodeId}: a ${stakeSpecies} links to ${quality2 ? "a Kritik criterion" : "a value of the pyramid"}, not ${catalog.source}`
|
|
18310
|
+
);
|
|
18311
|
+
}
|
|
18312
|
+
}
|
|
18313
|
+
if (catalog && catalog.source === "values" && !VALUE_IDS.includes(catalog.id)) {
|
|
18314
|
+
warn(
|
|
18315
|
+
`${base}.metadata.catalog`,
|
|
18316
|
+
"stake-catalog-unknown-value",
|
|
18317
|
+
`Stake ${nodeId}: catalog value "${catalog.id}" is not a value of the pyramid`
|
|
18318
|
+
);
|
|
18319
|
+
}
|
|
18320
|
+
if (stakeSpecies !== void 0 && QUALITY_STAKE_SPECIES.includes(stakeSpecies)) {
|
|
18321
|
+
for (const field of ["felt", "matters", "frequency"]) {
|
|
18322
|
+
if (stakeMd[field] !== void 0) {
|
|
18323
|
+
warn(
|
|
18324
|
+
`${base}.metadata.${field}`,
|
|
18325
|
+
"stake-evaluation-quality-species",
|
|
18326
|
+
`Stake ${nodeId}: ${field} is for bugs, frictions and needs; a ${stakeSpecies} is read against a Kritik criterion's criticality`
|
|
18327
|
+
);
|
|
18328
|
+
}
|
|
18329
|
+
}
|
|
18330
|
+
}
|
|
18331
|
+
if (stakeSpecies === "bug" && stakeMd.felt !== void 0 && stakeMd.felt !== "expected") {
|
|
18332
|
+
warn(
|
|
18333
|
+
`${base}.metadata.felt`,
|
|
18334
|
+
"stake-bug-felt",
|
|
18335
|
+
`Stake ${nodeId}: a bug is always felt as expected (a must-be), not ${JSON.stringify(stakeMd.felt)}`
|
|
18336
|
+
);
|
|
18337
|
+
}
|
|
18338
|
+
if (!concernsSources.has(nodeId)) {
|
|
18339
|
+
warn(
|
|
18340
|
+
`${base}`,
|
|
18341
|
+
"stake-unanchored",
|
|
18342
|
+
`Stake ${nodeId}: no outgoing concerns edge \u2014 anchor it to the flow, view, data model or endpoint it is about`
|
|
18343
|
+
);
|
|
18344
|
+
}
|
|
18345
|
+
});
|
|
18373
18346
|
const PLAYLIST_ENTRY_TYPES = ["view", "flow", "condition", "junction"];
|
|
18374
18347
|
const checkPlaylistShape = (entries, flowId, path, depth = 0) => {
|
|
18375
18348
|
if (depth > 50) return;
|
|
@@ -18708,7 +18681,11 @@ function validateBundle(input) {
|
|
|
18708
18681
|
const embeddedJournal = Array.isArray(bundle.journal) ? bundle.journal : [];
|
|
18709
18682
|
const weighingSpecies = /* @__PURE__ */ new Map();
|
|
18710
18683
|
for (const [id, node] of nodeMap) weighingSpecies.set(id, String(node.species));
|
|
18711
|
-
|
|
18684
|
+
const weighingStakeSpecies = /* @__PURE__ */ new Map();
|
|
18685
|
+
for (const [id, node] of nodeMap) {
|
|
18686
|
+
if (node.species === "stake") weighingStakeSpecies.set(id, stakeSpeciesOf({ metadata: node.metadata }));
|
|
18687
|
+
}
|
|
18688
|
+
for (const finding of validateWeighingSection(weighing, weighingSpecies, embeddedJournal, weighingStakeSpecies)) {
|
|
18712
18689
|
warn(finding.path, finding.rule, finding.message);
|
|
18713
18690
|
}
|
|
18714
18691
|
for (const finding of crossCheckJournal(bundle)) findings.push(finding);
|
|
@@ -18832,7 +18809,7 @@ function serializeBundle(bundle) {
|
|
|
18832
18809
|
function asString(value) {
|
|
18833
18810
|
return typeof value === "string" ? value : void 0;
|
|
18834
18811
|
}
|
|
18835
|
-
function computeNodeTimeline(events, nodeId) {
|
|
18812
|
+
function computeNodeTimeline(events, nodeId, options = {}) {
|
|
18836
18813
|
const edgeEndpoints = /* @__PURE__ */ new Map();
|
|
18837
18814
|
for (const ev of events) {
|
|
18838
18815
|
if (ev.type === "edge.added") {
|
|
@@ -18847,6 +18824,10 @@ function computeNodeTimeline(events, nodeId) {
|
|
|
18847
18824
|
}
|
|
18848
18825
|
const touches = (ev) => {
|
|
18849
18826
|
if (asString(ev.node_id) === nodeId) return true;
|
|
18827
|
+
if (ev.type === "request.filed") {
|
|
18828
|
+
if (signalStakeIds(ev).includes(nodeId)) return true;
|
|
18829
|
+
if (options.evidenceEventIds?.has(ev.id)) return true;
|
|
18830
|
+
}
|
|
18850
18831
|
if (ev.type === "edge.added") {
|
|
18851
18832
|
const edge = ev;
|
|
18852
18833
|
return asString(edge.source_id) === nodeId || asString(edge.target_id) === nodeId;
|
|
@@ -18939,7 +18920,7 @@ function computeBacklog(events, options = {}) {
|
|
|
18939
18920
|
for (const ev of ordered) {
|
|
18940
18921
|
if (ev.type !== "idea.proposed" && ev.type !== "request.filed") continue;
|
|
18941
18922
|
const linkedId = asString(ev.node_id);
|
|
18942
|
-
const closed = linkedId !== void 0 && existing.has(linkedId);
|
|
18923
|
+
const closed = linkedId !== void 0 && existing.has(linkedId) || ev.type === "request.filed" && signalStakeIds(ev).some((id) => existing.has(id)) || (options.evidencedEventIds?.has(ev.id) ?? false);
|
|
18943
18924
|
if (!closed) items.push(ev);
|
|
18944
18925
|
}
|
|
18945
18926
|
return {
|
|
@@ -18984,7 +18965,7 @@ function computeDeliverables(events) {
|
|
|
18984
18965
|
return null;
|
|
18985
18966
|
};
|
|
18986
18967
|
const out = [];
|
|
18987
|
-
for (const [id,
|
|
18968
|
+
for (const [id, anchorIndex3] of firstIndex) {
|
|
18988
18969
|
const ev = latest.get(id);
|
|
18989
18970
|
if (ev === void 0) continue;
|
|
18990
18971
|
const summary = asString(ev.summary);
|
|
@@ -18997,8 +18978,8 @@ function computeDeliverables(events) {
|
|
|
18997
18978
|
...url2 !== void 0 ? { url: url2 } : {},
|
|
18998
18979
|
node_ids: Array.isArray(ev.node_ids) ? ev.node_ids.filter((n) => typeof n === "string") : [],
|
|
18999
18980
|
...platform !== void 0 ? { platform } : {},
|
|
19000
|
-
ts: asString(ordered[
|
|
19001
|
-
releaseVersion: releaseOf(
|
|
18981
|
+
ts: asString(ordered[anchorIndex3].ts) ?? "",
|
|
18982
|
+
releaseVersion: releaseOf(anchorIndex3)
|
|
19002
18983
|
});
|
|
19003
18984
|
}
|
|
19004
18985
|
return out;
|
|
@@ -19758,13 +19739,6 @@ function namesPlan(ordered, id) {
|
|
|
19758
19739
|
return reading !== null && (reading.plan === id || reading.parts.includes(id));
|
|
19759
19740
|
});
|
|
19760
19741
|
}
|
|
19761
|
-
function scopeAnchorId(events) {
|
|
19762
|
-
const ordered = orderedRows(events);
|
|
19763
|
-
const at = anchorIndex(ordered, void 0);
|
|
19764
|
-
if (at === -1) return null;
|
|
19765
|
-
const id = ordered[at].audit_id;
|
|
19766
|
-
return isString(id) ? id : null;
|
|
19767
|
-
}
|
|
19768
19742
|
function deriveAuditScope(events, section, library, options = {}) {
|
|
19769
19743
|
const ordered = orderedRows(events);
|
|
19770
19744
|
const sinceIndex = anchorIndex(ordered, options.since);
|
|
@@ -19938,57 +19912,6 @@ function deriveAuditScope(events, section, library, options = {}) {
|
|
|
19938
19912
|
);
|
|
19939
19913
|
return { since, since_ts: sinceTs, cells: sorted, findings: drivers, resolved_by: resolvedBy, unknown: unknown2, unscorable, widened };
|
|
19940
19914
|
}
|
|
19941
|
-
function scopedAuditId(input) {
|
|
19942
|
-
const { since, month, requested, known, recorded, open } = input;
|
|
19943
|
-
const newest = [...known].sort().at(-1);
|
|
19944
|
-
if (requested !== void 0) {
|
|
19945
|
-
if (requested === since) {
|
|
19946
|
-
throw new Error(
|
|
19947
|
-
`"${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.`
|
|
19948
|
-
);
|
|
19949
|
-
}
|
|
19950
|
-
if (recorded.includes(requested)) {
|
|
19951
|
-
throw new Error(`"${requested}" is already recorded \u2014 its reading is history. Name a new audit.`);
|
|
19952
|
-
}
|
|
19953
|
-
if (isPlanId(requested) || isPlanPartId(requested)) {
|
|
19954
|
-
throw new Error(
|
|
19955
|
-
`"${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 })}\`).`
|
|
19956
|
-
);
|
|
19957
|
-
}
|
|
19958
|
-
if (newest !== void 0 && requested < newest) {
|
|
19959
|
-
throw new Error(
|
|
19960
|
-
`"${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)}\`).`
|
|
19961
|
-
);
|
|
19962
|
-
}
|
|
19963
|
-
return requested;
|
|
19964
|
-
}
|
|
19965
|
-
if (open !== void 0 && (newest === void 0 || open >= newest)) return open;
|
|
19966
|
-
for (const candidate of scopedCandidates(month, known)) {
|
|
19967
|
-
if (known.includes(candidate)) continue;
|
|
19968
|
-
if (newest !== void 0 && candidate < newest) {
|
|
19969
|
-
throw new Error(
|
|
19970
|
-
`"${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)}\`).`
|
|
19971
|
-
);
|
|
19972
|
-
}
|
|
19973
|
-
return candidate;
|
|
19974
|
-
}
|
|
19975
|
-
throw new Error(`99 scoped audits in ${month} \u2014 name the next one yourself.`);
|
|
19976
|
-
}
|
|
19977
|
-
function* scopedCandidates(month, known) {
|
|
19978
|
-
const newest = [...known].sort().at(-1) ?? "";
|
|
19979
|
-
const stem = newest.replace(/-scoped(-\d+)?$/, "");
|
|
19980
|
-
const base = `${month}-scoped` < newest && isPlanPartId(stem) ? stem : month;
|
|
19981
|
-
for (let n = 1; n < 100; n++) yield n === 1 ? `${base}-scoped` : `${base}-scoped-${String(n).padStart(2, "0")}`;
|
|
19982
|
-
}
|
|
19983
|
-
function suggestedAuditId({ since, month, requested, known, recorded }) {
|
|
19984
|
-
const taken = /* @__PURE__ */ new Set([...known, ...recorded, since, ...requested !== void 0 ? [requested] : []]);
|
|
19985
|
-
const floor = [...taken].sort().at(-1);
|
|
19986
|
-
for (const candidate of scopedCandidates(month, known)) {
|
|
19987
|
-
if (taken.has(candidate)) continue;
|
|
19988
|
-
if (floor === void 0 || candidate > floor) return candidate;
|
|
19989
|
-
}
|
|
19990
|
-
return `${floor}-scoped`;
|
|
19991
|
-
}
|
|
19992
19915
|
function scopeSummary(scope) {
|
|
19993
19916
|
const direct = scope.cells.length - scope.widened;
|
|
19994
19917
|
const cells = `${scope.cells.length} cell${scope.cells.length === 1 ? "" : "s"} to re-score`;
|
|
@@ -20324,18 +20247,26 @@ function planWeighingEvents(section, nodes, inputs, ctx) {
|
|
|
20324
20247
|
const problem = assessmentProblem(entry);
|
|
20325
20248
|
if (problem !== void 0) return refuse("invalid_entry", problem);
|
|
20326
20249
|
const input = entry;
|
|
20327
|
-
const
|
|
20250
|
+
const node = byId.get(input.subject);
|
|
20251
|
+
const matrixId = input.matrix ?? (node?.species === "stake" ? STAKE_MATRIX_ID : VALUE_MATRIX_ID);
|
|
20252
|
+
const matrix = resolved.matrices.find((candidate) => candidate.id === matrixId);
|
|
20328
20253
|
if (matrix === void 0) {
|
|
20329
|
-
return refuse("unknown_matrix", `no matrix "${
|
|
20254
|
+
return refuse("unknown_matrix", `no matrix "${matrixId}" (have: ${resolved.matrices.map((m) => m.id).join(", ")})`);
|
|
20330
20255
|
}
|
|
20331
20256
|
const set2 = setOfRef(resolved, matrix.set);
|
|
20332
20257
|
if (set2 === void 0) return refuse("unknown_matrix", `matrix "${matrix.id}" names set "${matrix.set}", which is not available`);
|
|
20333
20258
|
if (isOlderMajorRef(resolved, matrix.set)) {
|
|
20334
20259
|
return refuse("unknown_matrix", `matrix "${matrix.id}" reads ${matrix.set}, an older ruler \u2014 nothing new is scored against it; point the matrix at the current major`);
|
|
20335
20260
|
}
|
|
20336
|
-
|
|
20337
|
-
|
|
20338
|
-
|
|
20261
|
+
if (node === void 0 || !isMatrixSubject(node, matrix, set2)) {
|
|
20262
|
+
if (node?.species === "stake" && matrix.subjects.kind === "query" && matrix.subjects.species === "stake") {
|
|
20263
|
+
const kind = stakeSpeciesOf(node);
|
|
20264
|
+
const declared2 = stakeSpeciesDeclaredBy(set2);
|
|
20265
|
+
return refuse(
|
|
20266
|
+
"unknown_subject",
|
|
20267
|
+
kind === void 0 ? `"${input.subject}" has no stake kind (metadata.stake_species), so no reference can score it` : `"${input.subject}" is a ${kind}, and set "${set2.id}" scores ${declared2.length > 0 ? declared2.join(", ") : "no stake"} only${QUALITY_STAKE_SPECIES.includes(kind) ? " \u2014 a requirement, risk or defect is read against Kritik criteria, never weighed" : ""}`
|
|
20268
|
+
);
|
|
20269
|
+
}
|
|
20339
20270
|
return refuse("unknown_subject", `"${input.subject}" is not a subject of matrix "${matrix.id}"`);
|
|
20340
20271
|
}
|
|
20341
20272
|
const criterion = set2.criteria.find((candidate) => candidate.id === input.criterion);
|
|
@@ -20368,7 +20299,7 @@ function planWeighingEvents(section, nodes, inputs, ctx) {
|
|
|
20368
20299
|
...input.evidence !== void 0 ? { evidence: input.evidence } : {},
|
|
20369
20300
|
...input.refs !== void 0 ? { refs: input.refs } : {},
|
|
20370
20301
|
basis: {
|
|
20371
|
-
fingerprint:
|
|
20302
|
+
fingerprint: fingerprintOf(node),
|
|
20372
20303
|
set_version: set2.version,
|
|
20373
20304
|
...input.commit !== void 0 ? { commit: input.commit } : {}
|
|
20374
20305
|
},
|
|
@@ -20411,7 +20342,7 @@ function claimedElements(node, set2) {
|
|
|
20411
20342
|
return out;
|
|
20412
20343
|
}
|
|
20413
20344
|
function seedAssessments(node, matrix, set2) {
|
|
20414
|
-
const fingerprint =
|
|
20345
|
+
const fingerprint = fingerprintOf(node);
|
|
20415
20346
|
return claimedElements(node, set2).map((criterion, position) => ({
|
|
20416
20347
|
matrix: matrix.id,
|
|
20417
20348
|
subject: node.id,
|
|
@@ -20519,11 +20450,12 @@ function keptShare(node) {
|
|
|
20519
20450
|
}
|
|
20520
20451
|
var share = (guess, total) => total > 0 ? guess / total : 0;
|
|
20521
20452
|
function weighPromise(node, ctx) {
|
|
20522
|
-
const fingerprint =
|
|
20453
|
+
const fingerprint = fingerprintOf(node);
|
|
20523
20454
|
const current = { fingerprint, setVersion: ctx.set.version };
|
|
20524
|
-
const
|
|
20455
|
+
const isStake = node.species === "stake";
|
|
20456
|
+
const claimedList = isStake ? [] : claimedElements(node, ctx.set);
|
|
20525
20457
|
const claimedSet = new Set(claimedList);
|
|
20526
|
-
const seeds = new Map(seedAssessments(node, ctx.matrix, ctx.set).map((seed) => [seed.criterion, seed]));
|
|
20458
|
+
const seeds = new Map((isStake ? [] : seedAssessments(node, ctx.matrix, ctx.set)).map((seed) => [seed.criterion, seed]));
|
|
20527
20459
|
const order = [...claimedList, ...ctx.set.criteria.map((criterion) => criterion.id).filter((id) => !claimedSet.has(id))];
|
|
20528
20460
|
const cells = [];
|
|
20529
20461
|
for (const criterion of order) {
|
|
@@ -20564,7 +20496,7 @@ function weighPromise(node, ctx) {
|
|
|
20564
20496
|
if (cell.stale) stale.push(cell.criterion);
|
|
20565
20497
|
if (cell.review) review.push(cell.criterion);
|
|
20566
20498
|
if (cell.uncertain) uncertain.push(cell.criterion);
|
|
20567
|
-
if (cell.source === "stored") {
|
|
20499
|
+
if (cell.source === "stored" && !isStake) {
|
|
20568
20500
|
if (cell.claimed) {
|
|
20569
20501
|
if (cell.level < 0) flags.claim_contradicted.push(cell.criterion);
|
|
20570
20502
|
else if (cell.level === 0) flags.claim_not_supported.push(cell.criterion);
|
|
@@ -20594,14 +20526,13 @@ function weighPromise(node, ctx) {
|
|
|
20594
20526
|
uncertain
|
|
20595
20527
|
};
|
|
20596
20528
|
}
|
|
20597
|
-
function matrixSubjects(nodes, matrix) {
|
|
20598
|
-
const wanted = matrix.subjects.kind === "query" ? void 0 : new Set(matrix.subjects.items.map((item) => item?.node_id ?? item?.id));
|
|
20599
|
-
const species = matrix.subjects.kind === "query" ? matrix.subjects.species : void 0;
|
|
20529
|
+
function matrixSubjects(nodes, matrix, set2) {
|
|
20600
20530
|
const seen = /* @__PURE__ */ new Set();
|
|
20601
20531
|
const out = [];
|
|
20602
20532
|
for (const node of nodes) {
|
|
20603
20533
|
if (seen.has(node.id)) continue;
|
|
20604
|
-
|
|
20534
|
+
const judged = set2 === void 0 && matrix.subjects.kind === "query" ? node.species === matrix.subjects.species : isMatrixSubject(node, matrix, set2);
|
|
20535
|
+
if (!judged) continue;
|
|
20605
20536
|
seen.add(node.id);
|
|
20606
20537
|
out.push(node);
|
|
20607
20538
|
}
|
|
@@ -20610,7 +20541,7 @@ function matrixSubjects(nodes, matrix) {
|
|
|
20610
20541
|
function deriveWeighing(nodes, section, matrixId = VALUE_MATRIX_ID) {
|
|
20611
20542
|
const ctx = buildWeighingContext(section, matrixId);
|
|
20612
20543
|
if (ctx === void 0) return void 0;
|
|
20613
|
-
const promises = matrixSubjects(nodes, ctx.matrix).map((node) => weighPromise(node, ctx));
|
|
20544
|
+
const promises = matrixSubjects(nodes, ctx.matrix, ctx.set).map((node) => weighPromise(node, ctx));
|
|
20614
20545
|
const empty = () => ({ promised: 0, promisedGuess: 0, kept: 0, keptGuess: 0, cost: 0, costGuess: 0 });
|
|
20615
20546
|
const raw = new Map(ctx.set.criteria.map((criterion) => [criterion.id, empty()]));
|
|
20616
20547
|
let assessed = 0;
|
|
@@ -20673,16 +20604,1140 @@ function sortPromises(promises, key) {
|
|
|
20673
20604
|
return [...promises].sort((a, b) => key === "title" ? byTitle(a, b) : value(b) - value(a) || byTitle(a, b));
|
|
20674
20605
|
}
|
|
20675
20606
|
|
|
20676
|
-
// ../schema/src/
|
|
20677
|
-
|
|
20678
|
-
|
|
20679
|
-
|
|
20680
|
-
|
|
20681
|
-
|
|
20682
|
-
|
|
20683
|
-
var
|
|
20684
|
-
|
|
20685
|
-
|
|
20607
|
+
// ../schema/src/qualify.ts
|
|
20608
|
+
var QUALIFY_DOORS = ["collect", "imagine"];
|
|
20609
|
+
var QUALIFY_SCOPES = ["product", "internal", "off-scope"];
|
|
20610
|
+
var QUALIFY_FACINGS = ["value", "quality"];
|
|
20611
|
+
var QUALIFY_EXPECTATIONS = ["broken", "as-designed", "absent"];
|
|
20612
|
+
var QUALIFY_THREATS = ["obligation", "own-flaw", "mitigable-only"];
|
|
20613
|
+
var QUALIFY_BASES = ["stated", "inferred"];
|
|
20614
|
+
var ROUTING_QUESTIONS = [
|
|
20615
|
+
{
|
|
20616
|
+
id: "scope",
|
|
20617
|
+
question: "Is this about the product a person meets?",
|
|
20618
|
+
answers: {
|
|
20619
|
+
product: "continue",
|
|
20620
|
+
internal: "routed out: about operating the product (CI, telemetry, maker analytics), nobody experiences it",
|
|
20621
|
+
"off-scope": "routed out: not this product's business"
|
|
20622
|
+
},
|
|
20623
|
+
askedWhen: "always, first"
|
|
20624
|
+
},
|
|
20625
|
+
{
|
|
20626
|
+
id: "door",
|
|
20627
|
+
question: "Does the product exist and do people use it (collect), or is it still being shaped (imagine)?",
|
|
20628
|
+
answers: {
|
|
20629
|
+
collect: "observed; all six species are open",
|
|
20630
|
+
imagine: "anticipated; only need, requirement, risk and defect are open (nothing exists yet to have a bug or a friction)"
|
|
20631
|
+
},
|
|
20632
|
+
askedWhen: "after scope is product"
|
|
20633
|
+
},
|
|
20634
|
+
{
|
|
20635
|
+
id: "facing",
|
|
20636
|
+
question: "Does it face a person's value, or the product's quality and obligations?",
|
|
20637
|
+
answers: {
|
|
20638
|
+
value: "bug, friction or need: weighed on the value pyramid",
|
|
20639
|
+
quality: "requirement, risk or defect: read against Kritik criteria"
|
|
20640
|
+
},
|
|
20641
|
+
askedWhen: "after door"
|
|
20642
|
+
},
|
|
20643
|
+
{
|
|
20644
|
+
id: "expectation",
|
|
20645
|
+
question: "Value-facing: was something expected to work that does not (broken), does it work as designed and still get in the way (as-designed), or is the value simply not there (absent)?",
|
|
20646
|
+
answers: {
|
|
20647
|
+
broken: "bug",
|
|
20648
|
+
"as-designed": "friction",
|
|
20649
|
+
absent: "need"
|
|
20650
|
+
},
|
|
20651
|
+
askedWhen: "facing is value"
|
|
20652
|
+
},
|
|
20653
|
+
{
|
|
20654
|
+
id: "threat",
|
|
20655
|
+
question: "Quality-facing: is it an obligation from outside (obligation), a flaw of our own making that leaves a threat (own-flaw), or a threat that can only be mitigated (mitigable-only)?",
|
|
20656
|
+
answers: {
|
|
20657
|
+
obligation: "requirement",
|
|
20658
|
+
"own-flaw": "defect",
|
|
20659
|
+
"mitigable-only": "risk"
|
|
20660
|
+
},
|
|
20661
|
+
askedWhen: "facing is quality"
|
|
20662
|
+
},
|
|
20663
|
+
{
|
|
20664
|
+
id: "basis",
|
|
20665
|
+
question: "Did the source say this (stated), or is it the analyst's hypothesis (inferred)?",
|
|
20666
|
+
answers: {
|
|
20667
|
+
stated: "carried through as stated",
|
|
20668
|
+
inferred: "a person must confirm before the species is trusted"
|
|
20669
|
+
},
|
|
20670
|
+
askedWhen: "optional; defaults to stated"
|
|
20671
|
+
}
|
|
20672
|
+
];
|
|
20673
|
+
var SPECIES_BY_EXPECTATION = { broken: "bug", "as-designed": "friction", absent: "need" };
|
|
20674
|
+
var SPECIES_BY_THREAT = { obligation: "requirement", "own-flaw": "defect", "mitigable-only": "risk" };
|
|
20675
|
+
function inList(list, value) {
|
|
20676
|
+
return list.includes(value);
|
|
20677
|
+
}
|
|
20678
|
+
function routeSpecies(answers) {
|
|
20679
|
+
const handToHuman = [];
|
|
20680
|
+
const reasons = [];
|
|
20681
|
+
const out = (route, extra = {}) => ({ route, ask: [], reasons, handToHuman, ...extra });
|
|
20682
|
+
const reached = (species2, provenance2) => {
|
|
20683
|
+
if (provenance2 === "anticipated") {
|
|
20684
|
+
handToHuman.push("Anticipated (imagine door): nobody has met this yet, so the stake is inferred until a person confirms it.");
|
|
20685
|
+
}
|
|
20686
|
+
return out("stake", { species: species2, provenance: provenance2 });
|
|
20687
|
+
};
|
|
20688
|
+
const basis = inList(QUALIFY_BASES, answers.basis) ? answers.basis : "stated";
|
|
20689
|
+
if (basis === "inferred") handToHuman.push("The answers are inferred, not stated: a person confirms the species before it is trusted.");
|
|
20690
|
+
const scope = inList(QUALIFY_SCOPES, answers.scope) ? answers.scope : void 0;
|
|
20691
|
+
if (scope === void 0) return out("incomplete", { ask: ["scope"], reasons: ["scope is not answered"] });
|
|
20692
|
+
if (scope !== "product") {
|
|
20693
|
+
reasons.push(`Routed out as ${scope}: it is not a stake to weigh.`);
|
|
20694
|
+
handToHuman.push(`Routed out as ${scope}: a person can overrule it. Nothing is written; the signal stays in the journal.`);
|
|
20695
|
+
return out(scope);
|
|
20696
|
+
}
|
|
20697
|
+
const door = inList(QUALIFY_DOORS, answers.door) ? answers.door : void 0;
|
|
20698
|
+
if (door === void 0) return out("incomplete", { ask: ["door"], reasons: ["door is not answered"] });
|
|
20699
|
+
const provenance = door === "collect" ? "observed" : "anticipated";
|
|
20700
|
+
const facing = inList(QUALIFY_FACINGS, answers.facing) ? answers.facing : void 0;
|
|
20701
|
+
if (facing === void 0) return out("incomplete", { ask: ["facing"], provenance, reasons: ["facing is not answered"] });
|
|
20702
|
+
if (facing === "value") {
|
|
20703
|
+
const expectation = inList(QUALIFY_EXPECTATIONS, answers.expectation) ? answers.expectation : void 0;
|
|
20704
|
+
if (expectation === void 0) return out("incomplete", { ask: ["expectation"], provenance, reasons: ["expectation is not answered"] });
|
|
20705
|
+
const species2 = SPECIES_BY_EXPECTATION[expectation];
|
|
20706
|
+
if (door === "imagine" && !ANTICIPATED_STAKE_SPECIES.includes(species2)) {
|
|
20707
|
+
reasons.push(`An anticipated stake is never a ${species2}: nothing exists yet to have one. Reroute as need.`);
|
|
20708
|
+
handToHuman.push(`Refused: a ${species2} cannot come through the imagine door. Reroute as need, or take the collect door if the product exists.`);
|
|
20709
|
+
return out("refused", { provenance, rerouteAs: "need" });
|
|
20710
|
+
}
|
|
20711
|
+
reasons.push(`Value-facing, ${expectation}: ${species2}.`);
|
|
20712
|
+
return reached(species2, provenance);
|
|
20713
|
+
}
|
|
20714
|
+
const threat = inList(QUALIFY_THREATS, answers.threat) ? answers.threat : void 0;
|
|
20715
|
+
if (threat === void 0) return out("incomplete", { ask: ["threat"], provenance, reasons: ["threat is not answered"] });
|
|
20716
|
+
const species = SPECIES_BY_THREAT[threat];
|
|
20717
|
+
reasons.push(`Quality-facing, ${threat}: ${species}.`);
|
|
20718
|
+
return reached(species, provenance);
|
|
20719
|
+
}
|
|
20720
|
+
var MERGE_HIGH = 0.6;
|
|
20721
|
+
var MERGE_MEDIUM = 0.35;
|
|
20722
|
+
var MERGE_LOW = 0.15;
|
|
20723
|
+
var WEIGHT_CATALOG = 0.35;
|
|
20724
|
+
var WEIGHT_ANCHOR = 0.25;
|
|
20725
|
+
var WEIGHT_TEXT = 0.4;
|
|
20726
|
+
var STOPWORDS = /* @__PURE__ */ new Set([
|
|
20727
|
+
"the",
|
|
20728
|
+
"and",
|
|
20729
|
+
"for",
|
|
20730
|
+
"with",
|
|
20731
|
+
"that",
|
|
20732
|
+
"this",
|
|
20733
|
+
"from",
|
|
20734
|
+
"are",
|
|
20735
|
+
"was",
|
|
20736
|
+
"has",
|
|
20737
|
+
"not",
|
|
20738
|
+
"but",
|
|
20739
|
+
"can",
|
|
20740
|
+
"when",
|
|
20741
|
+
"you",
|
|
20742
|
+
"your",
|
|
20743
|
+
"its",
|
|
20744
|
+
"have",
|
|
20745
|
+
"had",
|
|
20746
|
+
"will",
|
|
20747
|
+
"would",
|
|
20748
|
+
"into",
|
|
20749
|
+
"than",
|
|
20750
|
+
"then",
|
|
20751
|
+
"they",
|
|
20752
|
+
"them",
|
|
20753
|
+
"there",
|
|
20754
|
+
"what",
|
|
20755
|
+
"which",
|
|
20756
|
+
"who",
|
|
20757
|
+
"how",
|
|
20758
|
+
"why",
|
|
20759
|
+
"all",
|
|
20760
|
+
"any",
|
|
20761
|
+
"out",
|
|
20762
|
+
"off",
|
|
20763
|
+
"too",
|
|
20764
|
+
"very",
|
|
20765
|
+
"just",
|
|
20766
|
+
"les",
|
|
20767
|
+
"des",
|
|
20768
|
+
"une",
|
|
20769
|
+
"pour",
|
|
20770
|
+
"que",
|
|
20771
|
+
"qui",
|
|
20772
|
+
"dans",
|
|
20773
|
+
"sur",
|
|
20774
|
+
"pas",
|
|
20775
|
+
"est",
|
|
20776
|
+
"mon",
|
|
20777
|
+
"mes",
|
|
20778
|
+
"son",
|
|
20779
|
+
"ses",
|
|
20780
|
+
"avec",
|
|
20781
|
+
"sans",
|
|
20782
|
+
"plus",
|
|
20783
|
+
"par"
|
|
20784
|
+
]);
|
|
20785
|
+
function tokens(text) {
|
|
20786
|
+
const out = /* @__PURE__ */ new Set();
|
|
20787
|
+
for (const word of kebabCase(text).split("-")) {
|
|
20788
|
+
if (word.length >= 3 && !STOPWORDS.has(word)) out.add(word);
|
|
20789
|
+
}
|
|
20790
|
+
return out;
|
|
20791
|
+
}
|
|
20792
|
+
function jaccard(a, b) {
|
|
20793
|
+
if (a.size === 0 || b.size === 0) return 0;
|
|
20794
|
+
let shared = 0;
|
|
20795
|
+
for (const item of a) if (b.has(item)) shared += 1;
|
|
20796
|
+
return shared / (a.size + b.size - shared);
|
|
20797
|
+
}
|
|
20798
|
+
var round3 = (value) => Math.round(value * 1e3) / 1e3;
|
|
20799
|
+
function stakeAnchors(stakeId, edges) {
|
|
20800
|
+
const anchors = /* @__PURE__ */ new Set();
|
|
20801
|
+
for (const edge of edges) if (edge.edge_type === "concerns" && edge.source_id === stakeId) anchors.add(edge.target_id);
|
|
20802
|
+
return [...anchors].sort();
|
|
20803
|
+
}
|
|
20804
|
+
function findMergeCandidates(signal, stakes, options = {}) {
|
|
20805
|
+
const edges = options.edges ?? [];
|
|
20806
|
+
const signalAnchors = new Set(signal.node_ids ?? []);
|
|
20807
|
+
const signalWords = tokens(`${signal.title} ${signal.verbatim ?? ""}`);
|
|
20808
|
+
const found = [];
|
|
20809
|
+
for (const stake of stakes) {
|
|
20810
|
+
if (stake.species !== "stake" || stakeSpeciesOf(stake) !== signal.species) continue;
|
|
20811
|
+
const reasons = [];
|
|
20812
|
+
const alreadyCited = signal.event_id !== void 0 && stakeEvidenceOf(stake).some((entry) => entry.event_id === signal.event_id);
|
|
20813
|
+
const anchors = new Set(stakeAnchors(stake.id, edges));
|
|
20814
|
+
let score = 0;
|
|
20815
|
+
if (alreadyCited) {
|
|
20816
|
+
score = 1;
|
|
20817
|
+
reasons.push("This stake already cites the signal as evidence.");
|
|
20818
|
+
} else {
|
|
20819
|
+
const anchorScore = jaccard(signalAnchors, anchors);
|
|
20820
|
+
const catalog = stakeCatalogOf(stake);
|
|
20821
|
+
const sameCatalog = signal.catalog_id !== void 0 && catalog?.id === signal.catalog_id;
|
|
20822
|
+
const anchorsAgree = anchorScore > 0;
|
|
20823
|
+
if (sameCatalog) {
|
|
20824
|
+
score += anchorsAgree ? WEIGHT_CATALOG : WEIGHT_CATALOG / 2;
|
|
20825
|
+
reasons.push(
|
|
20826
|
+
anchorsAgree ? `Same catalog id (${signal.catalog_id}).` : signalAnchors.size > 0 && anchors.size > 0 ? `Same catalog id (${signal.catalog_id}) but a different anchor: a related stake, not necessarily the same one.` : `Same catalog id (${signal.catalog_id}) but no anchor to confirm it: a related stake, not necessarily the same one.`
|
|
20827
|
+
);
|
|
20828
|
+
}
|
|
20829
|
+
if (anchorScore > 0) {
|
|
20830
|
+
score += WEIGHT_ANCHOR * anchorScore;
|
|
20831
|
+
reasons.push(`Shares an anchor (${[...signalAnchors].filter((id) => anchors.has(id)).join(", ")}).`);
|
|
20832
|
+
}
|
|
20833
|
+
const textScore = jaccard(signalWords, tokens(`${stake.title} ${stake.description ?? ""}`));
|
|
20834
|
+
if (textScore > 0) {
|
|
20835
|
+
score += WEIGHT_TEXT * textScore;
|
|
20836
|
+
reasons.push(`Shares words with the title (${Math.round(textScore * 100)}% overlap).`);
|
|
20837
|
+
}
|
|
20838
|
+
}
|
|
20839
|
+
const rounded = round3(Math.min(score, 1));
|
|
20840
|
+
if (rounded < MERGE_LOW) continue;
|
|
20841
|
+
found.push({
|
|
20842
|
+
stake_id: stake.id,
|
|
20843
|
+
title: stake.title,
|
|
20844
|
+
status: stake.status,
|
|
20845
|
+
stake_species: signal.species,
|
|
20846
|
+
score: rounded,
|
|
20847
|
+
confidence: rounded >= MERGE_HIGH ? "high" : rounded >= MERGE_MEDIUM ? "medium" : "low",
|
|
20848
|
+
reasons,
|
|
20849
|
+
archived: stake.status === "archived",
|
|
20850
|
+
alreadyCited,
|
|
20851
|
+
countsAsEvidence: signal.source_kind !== "benchmark"
|
|
20852
|
+
});
|
|
20853
|
+
}
|
|
20854
|
+
found.sort((a, b) => b.score !== a.score ? b.score - a.score : a.stake_id < b.stake_id ? -1 : a.stake_id > b.stake_id ? 1 : 0);
|
|
20855
|
+
return found.slice(0, options.limit ?? 5);
|
|
20856
|
+
}
|
|
20857
|
+
function evidenceEntryFor(signal) {
|
|
20858
|
+
const entry = {
|
|
20859
|
+
...signal.event_id !== void 0 ? { event_id: signal.event_id } : {},
|
|
20860
|
+
...signal.verbatim !== void 0 && signal.verbatim !== "" ? { quote: signal.verbatim } : {},
|
|
20861
|
+
...signal.voice !== void 0 ? { voice: signal.voice } : {},
|
|
20862
|
+
...signal.date !== void 0 ? { date: signal.date } : {}
|
|
20863
|
+
};
|
|
20864
|
+
if (Object.keys(entry).length === 0) entry.quote = signal.title;
|
|
20865
|
+
return entry;
|
|
20866
|
+
}
|
|
20867
|
+
function refused(reasons) {
|
|
20868
|
+
return { action: "refused", ops: [], reasons, handToHuman: [] };
|
|
20869
|
+
}
|
|
20870
|
+
function stakeCiting(nodes, eventId) {
|
|
20871
|
+
if (eventId === void 0) return void 0;
|
|
20872
|
+
return nodes.find((node) => node.species === "stake" && stakeEvidenceOf(node).some((entry) => entry.event_id === eventId));
|
|
20873
|
+
}
|
|
20874
|
+
function planSignalToStake(input) {
|
|
20875
|
+
const { signal, species, provenance, nodes } = input;
|
|
20876
|
+
const cited = stakeCiting(nodes, signal.event_id);
|
|
20877
|
+
if (cited !== void 0) {
|
|
20878
|
+
const citedSpecies = stakeSpeciesOf(cited);
|
|
20879
|
+
const handToHuman2 = citedSpecies !== species ? [`${cited.id} already cites this signal as ${citedSpecies === void 0 ? "a stake with no species" : `a ${citedSpecies}`}, but it now routes as ${species}: a person decides which species is right.`] : [];
|
|
20880
|
+
return { action: "noop", ops: [], stake_id: cited.id, reasons: [`${cited.id} already cites this signal as evidence.`], handToHuman: handToHuman2 };
|
|
20881
|
+
}
|
|
20882
|
+
const problems = [];
|
|
20883
|
+
if (provenance === "anticipated" && !ANTICIPATED_STAKE_SPECIES.includes(species)) {
|
|
20884
|
+
problems.push(`An anticipated stake is never a ${species}: reroute as need.`);
|
|
20885
|
+
}
|
|
20886
|
+
if (input.catalog !== void 0 && input.catalog.source !== catalogSourceForStakeSpecies(species)) {
|
|
20887
|
+
problems.push(`A ${species} links to the ${catalogSourceForStakeSpecies(species)} catalog, not ${input.catalog.source}.`);
|
|
20888
|
+
}
|
|
20889
|
+
if (input.catalog !== void 0 && input.catalog.source === "values" && !VALUE_IDS.includes(input.catalog.id)) {
|
|
20890
|
+
problems.push(`"${input.catalog.id}" is not a value of the pyramid: a ${species} links to one of the 30 value ids.`);
|
|
20891
|
+
}
|
|
20892
|
+
const anchors = [...new Set(input.anchors ?? [])];
|
|
20893
|
+
const byId = new Map(nodes.map((node2) => [node2.id, node2]));
|
|
20894
|
+
for (const anchor of anchors) {
|
|
20895
|
+
const target = byId.get(anchor);
|
|
20896
|
+
if (target === void 0) problems.push(`Anchor "${anchor}" does not exist.`);
|
|
20897
|
+
else if (!STAKE_ANCHOR_SPECIES.includes(target.species)) {
|
|
20898
|
+
problems.push(`Anchor "${anchor}" is a ${target.species}: a stake concerns a flow, view, data model or endpoint.`);
|
|
20899
|
+
}
|
|
20900
|
+
}
|
|
20901
|
+
const title = (input.title ?? signal.title).trim();
|
|
20902
|
+
if (title === "") problems.push("A stake needs a title.");
|
|
20903
|
+
if (problems.length > 0) return refused(problems);
|
|
20904
|
+
const id = deriveNodeId("stake", title, nodes.map((node2) => node2.id));
|
|
20905
|
+
const metadata = stakeMetadataWith(void 0, {
|
|
20906
|
+
stake_species: species,
|
|
20907
|
+
provenance,
|
|
20908
|
+
...input.catalog !== void 0 ? { catalog: input.catalog } : {}
|
|
20909
|
+
});
|
|
20910
|
+
metadata.evidence = [evidenceEntryFor(signal)];
|
|
20911
|
+
const node = { id, project_id: input.projectId, title, species: "stake", status: "idea", platforms: [], metadata };
|
|
20912
|
+
const ops = [{ op: "create_node", node }];
|
|
20913
|
+
for (const anchor of anchors) {
|
|
20914
|
+
ops.push({ op: "create_edge", edge: { id: edgeId(id, anchor), project_id: input.projectId, source_id: id, target_id: anchor, edge_type: "concerns" } });
|
|
20915
|
+
}
|
|
20916
|
+
const handToHuman = [];
|
|
20917
|
+
if (anchors.length === 0) handToHuman.push("The stake has no anchor yet: name the flow, view, data model or endpoint it concerns.");
|
|
20918
|
+
if (input.title === void 0) handToHuman.push("The stake carries the signal's own title: reword it positively and solution-neutrally.");
|
|
20919
|
+
return { action: "create", ops, stake_id: id, reasons: [`Create ${id} (${species}, ${provenance}).`], handToHuman };
|
|
20920
|
+
}
|
|
20921
|
+
function planSignalMerge(input) {
|
|
20922
|
+
const { signal, target } = input;
|
|
20923
|
+
if (target.species !== "stake") return refused([`${target.id} is a ${target.species}, not a stake.`]);
|
|
20924
|
+
const targetSpecies = stakeSpeciesOf(target);
|
|
20925
|
+
if (input.species !== void 0 && targetSpecies !== input.species) {
|
|
20926
|
+
return refused([`${target.id} is ${targetSpecies === void 0 ? "a stake with no species" : `a ${targetSpecies}`}; the signal routes to ${input.species}. A signal never merges across species.`]);
|
|
20927
|
+
}
|
|
20928
|
+
const existing = stakeEvidenceOf(target);
|
|
20929
|
+
if (signal.event_id !== void 0 && existing.some((entry) => entry.event_id === signal.event_id)) {
|
|
20930
|
+
return { action: "noop", ops: [], stake_id: target.id, reasons: [`${target.id} already cites this signal as evidence.`], handToHuman: [] };
|
|
20931
|
+
}
|
|
20932
|
+
const other = stakeCiting(input.nodes, signal.event_id);
|
|
20933
|
+
const handToHuman = [];
|
|
20934
|
+
if (other !== void 0) handToHuman.push(`${other.id} also cites this signal: the same signal now backs two stakes.`);
|
|
20935
|
+
if (target.status === "archived") handToHuman.push(`${target.id} is archived: a person decides whether the new evidence reopens it.`);
|
|
20936
|
+
const metadata = { ...target.metadata ?? {}, evidence: [...existing, evidenceEntryFor(signal)] };
|
|
20937
|
+
return {
|
|
20938
|
+
action: "merge",
|
|
20939
|
+
ops: [{ op: "update_node", node_id: target.id, patch: { metadata } }],
|
|
20940
|
+
stake_id: target.id,
|
|
20941
|
+
reasons: [`Append evidence to ${target.id}.`],
|
|
20942
|
+
handToHuman
|
|
20943
|
+
};
|
|
20944
|
+
}
|
|
20945
|
+
|
|
20946
|
+
// ../schema/src/stake-evaluation.ts
|
|
20947
|
+
function referenceForStakeSpecies(species) {
|
|
20948
|
+
const set2 = BUILT_IN_SETS.find((candidate) => stakeSpeciesDeclaredBy(candidate).includes(species));
|
|
20949
|
+
return set2 === void 0 ? { kind: "kritik" } : { kind: "weighing-set", set: `${set2.id}@${majorOf(set2.version)}` };
|
|
20950
|
+
}
|
|
20951
|
+
|
|
20952
|
+
// ../../../../../packages/schema/src/cli/kritik-audit.ts
|
|
20953
|
+
import { existsSync as existsSync2, readdirSync, statSync } from "node:fs";
|
|
20954
|
+
import { join as join2 } from "node:path";
|
|
20955
|
+
|
|
20956
|
+
// ../../../../../packages/schema/src/quality.ts
|
|
20957
|
+
var asArray2 = (value) => Array.isArray(value) ? value : [];
|
|
20958
|
+
var FINDING_SEVERITIES2 = ["critical", "high", "medium", "low", "info"];
|
|
20959
|
+
var QUALITY_GRADES2 = ["A", "B", "C", "D", "E"];
|
|
20960
|
+
var DEFAULT_GRADE_BANDS2 = { A: 85, B: 70, C: 55, D: 40, E: 0 };
|
|
20961
|
+
var DEFAULT_SEVERITY_BUCKETS2 = {
|
|
20962
|
+
critical: [20, 25],
|
|
20963
|
+
high: [12, 19],
|
|
20964
|
+
medium: [6, 11],
|
|
20965
|
+
low: [2, 5],
|
|
20966
|
+
info: [1, 1]
|
|
20967
|
+
};
|
|
20968
|
+
var DEFAULT_CAPS2 = {
|
|
20969
|
+
critical_open: "D",
|
|
20970
|
+
high_open: "B"
|
|
20971
|
+
};
|
|
20972
|
+
var CROSS_SURFACE_ID2 = "cross-surface";
|
|
20973
|
+
function applicableCells2(library, surfaces) {
|
|
20974
|
+
const selected = surfaces.filter((id) => id !== CROSS_SURFACE_ID2);
|
|
20975
|
+
const cells = [];
|
|
20976
|
+
for (const criterion of asArray2(library.criteria)) {
|
|
20977
|
+
if (typeof criterion?.id !== "string" || criterion.id === "") continue;
|
|
20978
|
+
if (typeof criterion.superseded_by === "string" && criterion.superseded_by !== "") continue;
|
|
20979
|
+
const appliesTo = Array.isArray(criterion.applies_to) ? criterion.applies_to : void 0;
|
|
20980
|
+
const matched = appliesTo === void 0 ? [...selected] : selected.filter((id) => appliesTo.includes(id));
|
|
20981
|
+
if (matched.length > 0) cells.push({ criterion_id: criterion.id, surfaces: matched });
|
|
20982
|
+
}
|
|
20983
|
+
return cells;
|
|
20984
|
+
}
|
|
20985
|
+
function bucketsOf2(library) {
|
|
20986
|
+
const stored = library?.scales?.severity_buckets;
|
|
20987
|
+
const out = { ...DEFAULT_SEVERITY_BUCKETS2 };
|
|
20988
|
+
if (!stored || typeof stored !== "object") return out;
|
|
20989
|
+
for (const severity of FINDING_SEVERITIES2) {
|
|
20990
|
+
const band = stored[severity];
|
|
20991
|
+
if (Array.isArray(band) && typeof band[0] === "number" && typeof band[1] === "number") {
|
|
20992
|
+
out[severity] = [band[0], band[1]];
|
|
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)
|
|
21013
|
+
};
|
|
21014
|
+
}
|
|
21015
|
+
function severityOf2(finding, library) {
|
|
21016
|
+
const impact = typeof finding.impact === "number" ? finding.impact : 0;
|
|
21017
|
+
const likelihood = typeof finding.likelihood === "number" ? finding.likelihood : 0;
|
|
21018
|
+
const score = impact * likelihood;
|
|
21019
|
+
const buckets = bucketsOf2(library);
|
|
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";
|
|
21025
|
+
}
|
|
21026
|
+
function gradeOf2(score, library) {
|
|
21027
|
+
const bands = bandsOf2(library);
|
|
21028
|
+
const bestFirst = [...QUALITY_GRADES2].sort((a, b) => bands[b] - bands[a]);
|
|
21029
|
+
for (const grade of bestFirst) {
|
|
21030
|
+
if (score >= bands[grade]) return grade;
|
|
21031
|
+
}
|
|
21032
|
+
return "E";
|
|
21033
|
+
}
|
|
21034
|
+
function capGrade2(grade, cap) {
|
|
21035
|
+
return QUALITY_GRADES2[Math.max(QUALITY_GRADES2.indexOf(grade), QUALITY_GRADES2.indexOf(cap))];
|
|
21036
|
+
}
|
|
21037
|
+
function isOpenFinding2(finding) {
|
|
21038
|
+
return (finding.status ?? "open") === "open";
|
|
21039
|
+
}
|
|
21040
|
+
function rollUpSurface2(scores, weights) {
|
|
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;
|
|
21049
|
+
}
|
|
21050
|
+
return total > 0 ? Math.round(weighted / total) : null;
|
|
21051
|
+
}
|
|
21052
|
+
function resolveKritikLibrary2(section, library) {
|
|
21053
|
+
const explicit = library ?? section?.library;
|
|
21054
|
+
if (explicit && Array.isArray(explicit.criteria) && Array.isArray(explicit.domains)) return explicit;
|
|
21055
|
+
if (!section) return void 0;
|
|
21056
|
+
const ids = /* @__PURE__ */ new Set();
|
|
21057
|
+
for (const row of [...asArray2(section.assessments), ...asArray2(section.findings)]) {
|
|
21058
|
+
if (typeof row?.criterion_id === "string" && row.criterion_id !== "") ids.add(row.criterion_id);
|
|
21059
|
+
}
|
|
21060
|
+
if (ids.size === 0) return void 0;
|
|
21061
|
+
const domainOf = (id) => id.includes("-") ? id.slice(0, id.lastIndexOf("-")) : id;
|
|
21062
|
+
const criteria = [...ids].sort().map((id) => ({ id, domain: domainOf(id), weight: 1 }));
|
|
21063
|
+
const domains = [...new Set(criteria.map((c) => c.domain))].sort().map((code) => ({ code, name: code }));
|
|
21064
|
+
return { version: explicit?.version ?? "unknown", domains, criteria, scales: explicit?.scales };
|
|
21065
|
+
}
|
|
21066
|
+
function deriveQualityMatrix2(bundle, library) {
|
|
21067
|
+
const section = bundle.quality;
|
|
21068
|
+
const pack = resolveKritikLibrary2(section, library);
|
|
21069
|
+
const assessments = asArray2(section?.assessments);
|
|
21070
|
+
const findings = asArray2(section?.findings);
|
|
21071
|
+
const openFindings = findings.filter((finding) => isOpenFinding2(finding));
|
|
21072
|
+
const declared2 = asArray2(section?.profile?.surfaces).map((surface) => surface?.id).filter((id) => typeof id === "string" && id !== "");
|
|
21073
|
+
const surfaces = declared2.length > 0 ? [...new Set(declared2)] : [...new Set(assessments.map((a) => a.surface).filter((id) => typeof id === "string" && id !== ""))].sort();
|
|
21074
|
+
const domains = asArray2(pack?.domains).map((domain2) => domain2?.code).filter((code) => typeof code === "string" && code !== "");
|
|
21075
|
+
const domainOfCriterion = /* @__PURE__ */ new Map();
|
|
21076
|
+
const weightOfCriterion = /* @__PURE__ */ new Map();
|
|
21077
|
+
for (const criterion of asArray2(pack?.criteria)) {
|
|
21078
|
+
if (typeof criterion?.id !== "string") continue;
|
|
21079
|
+
if (typeof criterion.domain === "string") domainOfCriterion.set(criterion.id, criterion.domain);
|
|
21080
|
+
weightOfCriterion.set(criterion.id, typeof criterion.weight === "number" && criterion.weight > 0 ? criterion.weight : 1);
|
|
21081
|
+
}
|
|
21082
|
+
const caps = capsOf2(pack);
|
|
21083
|
+
const weights = section?.profile?.domain_weights;
|
|
21084
|
+
const matrix = {};
|
|
21085
|
+
for (const domain2 of domains) {
|
|
21086
|
+
matrix[domain2] = {};
|
|
21087
|
+
for (const surface of surfaces) {
|
|
21088
|
+
const rows = assessments.filter((a) => a.surface === surface && domainOfCriterion.get(a.criterion_id) === domain2);
|
|
21089
|
+
if (rows.length === 0) {
|
|
21090
|
+
matrix[domain2][surface] = null;
|
|
21091
|
+
continue;
|
|
21092
|
+
}
|
|
21093
|
+
let earned = 0;
|
|
21094
|
+
let available = 0;
|
|
21095
|
+
for (const row of rows) {
|
|
21096
|
+
const weight = weightOfCriterion.get(row.criterion_id) ?? 1;
|
|
21097
|
+
const level = typeof row.level === "number" ? Math.min(Math.max(row.level, 0), 4) : 0;
|
|
21098
|
+
earned += level * weight;
|
|
21099
|
+
available += 4 * weight;
|
|
21100
|
+
}
|
|
21101
|
+
if (available === 0) {
|
|
21102
|
+
matrix[domain2][surface] = null;
|
|
21103
|
+
continue;
|
|
21104
|
+
}
|
|
21105
|
+
const score = Math.round(earned / available * 100);
|
|
21106
|
+
const cellSeverities = openFindings.filter((finding) => finding.surface === surface && domainOfCriterion.get(finding.criterion_id) === domain2).map((finding) => severityOf2(finding, pack));
|
|
21107
|
+
const banded = gradeOf2(score, pack);
|
|
21108
|
+
let grade = banded;
|
|
21109
|
+
if (cellSeverities.includes("critical")) grade = capGrade2(grade, caps.critical_open);
|
|
21110
|
+
else if (cellSeverities.includes("high")) grade = capGrade2(grade, caps.high_open);
|
|
21111
|
+
matrix[domain2][surface] = {
|
|
21112
|
+
score,
|
|
21113
|
+
grade,
|
|
21114
|
+
capped: grade !== banded,
|
|
21115
|
+
criteria: rows.length,
|
|
21116
|
+
findings: {
|
|
21117
|
+
critical: cellSeverities.filter((s) => s === "critical").length,
|
|
21118
|
+
high: cellSeverities.filter((s) => s === "high").length,
|
|
21119
|
+
medium: cellSeverities.filter((s) => s === "medium").length,
|
|
21120
|
+
low: cellSeverities.filter((s) => s === "low").length
|
|
21121
|
+
}
|
|
21122
|
+
};
|
|
21123
|
+
}
|
|
21124
|
+
}
|
|
21125
|
+
const overall = {};
|
|
21126
|
+
for (const surface of surfaces) {
|
|
21127
|
+
const bySurface = {};
|
|
21128
|
+
for (const domain2 of domains) {
|
|
21129
|
+
const cell = matrix[domain2]?.[surface];
|
|
21130
|
+
if (cell) bySurface[domain2] = cell.score;
|
|
21131
|
+
}
|
|
21132
|
+
overall[surface] = rollUpSurface2(bySurface, weights);
|
|
21133
|
+
}
|
|
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
|
+
return {
|
|
21137
|
+
framework_version: section?.framework_version,
|
|
21138
|
+
surfaces,
|
|
21139
|
+
domains,
|
|
21140
|
+
matrix,
|
|
21141
|
+
overall,
|
|
21142
|
+
finding_counts
|
|
21143
|
+
};
|
|
21144
|
+
}
|
|
21145
|
+
|
|
21146
|
+
// ../../../../../packages/schema/src/ids.ts
|
|
21147
|
+
var SPECIES_IDS2 = ["flow", "view", "data-model", "api-endpoint", "acceptance", "decision"];
|
|
21148
|
+
var STATUS_IDS2 = [
|
|
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;
|
|
21203
|
+
}
|
|
21204
|
+
function auditCompletedInput2(matrix, meta3) {
|
|
21205
|
+
const scores = {};
|
|
21206
|
+
for (const surface of matrix.surfaces) {
|
|
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
|
+
};
|
|
21225
|
+
}
|
|
21226
|
+
|
|
21227
|
+
// ../../../../../packages/schema/src/kritik-plan-prompt.ts
|
|
21228
|
+
var THOUSANDS = /\B(?=(\d{3})+(?!\d))/g;
|
|
21229
|
+
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.';
|
|
21230
|
+
var USAGE_READOUT = "this session's usage readout: model, tokens in and out, duration, number of agents.";
|
|
21231
|
+
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.";
|
|
21232
|
+
var FINDING_FLAGS = '--title "<one line>" --impact <1-5> --likelihood <1-5> --cost <S|M|L|XL> --evidence "<file:line \u2026>"';
|
|
21233
|
+
function planRecordCommand2(planId2) {
|
|
21234
|
+
return `arkaik kritik matrix ${planId2} --record --plan`;
|
|
21235
|
+
}
|
|
21236
|
+
function plural(count, noun) {
|
|
21237
|
+
return `${count} ${noun}${count === 1 ? "" : "s"}`;
|
|
21238
|
+
}
|
|
21239
|
+
function tokenCount(value) {
|
|
21240
|
+
return String(Math.round(value)).replace(THOUSANDS, ",");
|
|
21241
|
+
}
|
|
21242
|
+
function dollars(value) {
|
|
21243
|
+
return `$${value.toFixed(2)}`;
|
|
21244
|
+
}
|
|
21245
|
+
function where(commit) {
|
|
21246
|
+
return commit === null ? "not a git checkout" : `commit ${commit}`;
|
|
21247
|
+
}
|
|
21248
|
+
function estimateSentence(tokens2, usd, calibrated) {
|
|
21249
|
+
if (tokens2 === null) return "";
|
|
21250
|
+
const cost = usd === null ? "" : ` (${dollars(usd.low)}\u2013${dollars(usd.high)})`;
|
|
21251
|
+
return ` Estimate: ${tokenCount(tokens2.low)}\u2013${tokenCount(tokens2.high)} tokens${cost}${calibrated ? "" : ", uncalibrated"}.`;
|
|
21252
|
+
}
|
|
21253
|
+
function scopeSentence(cells, steps) {
|
|
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";
|
|
20686
21741
|
var AUDITS_DIR = "audits";
|
|
20687
21742
|
var PACK_FILE = "library.json";
|
|
20688
21743
|
function readJson(path) {
|
|
@@ -20710,7 +21765,7 @@ function loadOverlay(root) {
|
|
|
20710
21765
|
return existsSync(path) ? readJson(path) : null;
|
|
20711
21766
|
}
|
|
20712
21767
|
|
|
20713
|
-
//
|
|
21768
|
+
// ../../../../../packages/schema/src/cli/kritik-audit.ts
|
|
20714
21769
|
var SCORES_FILE = "scores.json";
|
|
20715
21770
|
var FINDINGS_FILE = "findings.json";
|
|
20716
21771
|
var MATRIX_FILE = "matrix.json";
|
|
@@ -20757,121 +21812,363 @@ function requireProfile(root) {
|
|
|
20757
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).`
|
|
20758
21813
|
);
|
|
20759
21814
|
}
|
|
20760
|
-
return profile;
|
|
20761
|
-
}
|
|
20762
|
-
function loadQualitySection(root, auditId, library, scores = loadScores(root, auditId)) {
|
|
20763
|
-
const findings = loadFindings(root, auditId);
|
|
20764
|
-
return {
|
|
20765
|
-
framework_version: scores.framework_version ?? library.version,
|
|
20766
|
-
profile: requireProfile(root),
|
|
20767
|
-
assessments: scores.assessments,
|
|
20768
|
-
findings: findings.findings
|
|
20769
|
-
};
|
|
20770
|
-
}
|
|
20771
|
-
function stripDerived(finding) {
|
|
20772
|
-
const { severity: _severity, priority: _priority, ...rest } = finding;
|
|
20773
|
-
void _severity;
|
|
20774
|
-
void _priority;
|
|
20775
|
-
return rest;
|
|
20776
|
-
}
|
|
20777
|
-
function requireAudit(root, auditId) {
|
|
20778
|
-
if (!listAuditIds(root).includes(auditId)) {
|
|
20779
|
-
throw new Error(`no audit "${auditId}" under ${auditsDir(root)}`);
|
|
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;
|
|
21918
|
+
}
|
|
21919
|
+
|
|
21920
|
+
// ../../../../../packages/schema/src/cli/kritik-plan.ts
|
|
21921
|
+
import { spawnSync } from "node:child_process";
|
|
21922
|
+
import { existsSync as existsSync3, readdirSync as readdirSync2, statSync as statSync2 } from "node:fs";
|
|
21923
|
+
import { join as join3 } from "node:path";
|
|
21924
|
+
|
|
21925
|
+
// ../../../../../packages/schema/src/decision.ts
|
|
21926
|
+
var DECISION_STATUS_IDS2 = [
|
|
21927
|
+
"proposed",
|
|
21928
|
+
"approved",
|
|
21929
|
+
"enacted",
|
|
21930
|
+
"rejected",
|
|
21931
|
+
"deprecated",
|
|
21932
|
+
"superseded"
|
|
21933
|
+
];
|
|
21934
|
+
|
|
21935
|
+
// ../../../../../packages/schema/src/enums.ts
|
|
21936
|
+
var SpeciesSchema2 = external_exports.enum(SPECIES_IDS2).meta({
|
|
21937
|
+
id: "Species",
|
|
21938
|
+
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."
|
|
21939
|
+
});
|
|
21940
|
+
var StatusSchema3 = external_exports.enum(STATUS_IDS2).meta({
|
|
21941
|
+
id: "Status",
|
|
21942
|
+
description: "Lifecycle status of a node."
|
|
21943
|
+
});
|
|
21944
|
+
var AnyStatusSchema2 = external_exports.enum([...STATUS_IDS2, ...LEGACY_STATUS_IDS2]).meta({
|
|
21945
|
+
id: "AnyStatus",
|
|
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" });
|
|
22122
|
+
}
|
|
22123
|
+
if (!isPlanId2(plan.planId)) {
|
|
22124
|
+
ctx.addIssue({ code: "custom", path: ["planId"], message: "not a plan id (YYYY-MM-zplan-DDNN)" });
|
|
22125
|
+
return;
|
|
20780
22126
|
}
|
|
20781
|
-
|
|
20782
|
-
|
|
20783
|
-
|
|
20784
|
-
|
|
20785
|
-
|
|
20786
|
-
|
|
20787
|
-
|
|
20788
|
-
}
|
|
20789
|
-
function loadQualitySectionThrough(root, auditId, library) {
|
|
20790
|
-
requireAudit(root, auditId);
|
|
20791
|
-
const auditIds = listAuditIds(root);
|
|
20792
|
-
return mergeAudits(root, auditIds.slice(0, auditIds.indexOf(auditId) + 1), library, requireProfile(root));
|
|
20793
|
-
}
|
|
20794
|
-
function mergeAudits(root, auditIds, library, profile) {
|
|
20795
|
-
const cells = /* @__PURE__ */ new Map();
|
|
20796
|
-
const findings = [];
|
|
20797
|
-
let frameworkVersion;
|
|
20798
|
-
for (const id of auditIds) {
|
|
20799
|
-
const scores = loadScoresOrEmpty(root, id);
|
|
20800
|
-
if (typeof scores.framework_version === "string") frameworkVersion = scores.framework_version;
|
|
20801
|
-
for (const assessment of scores.assessments) {
|
|
20802
|
-
cells.set(`${assessment.criterion_id}\0${assessment.surface}`, assessment);
|
|
22127
|
+
const seen = /* @__PURE__ */ new Map();
|
|
22128
|
+
plan.parts.forEach((part, index) => {
|
|
22129
|
+
let expected;
|
|
22130
|
+
try {
|
|
22131
|
+
expected = planPartId2(plan.planId, part.domain, part.surface);
|
|
22132
|
+
} catch {
|
|
22133
|
+
expected = null;
|
|
20803
22134
|
}
|
|
20804
|
-
|
|
20805
|
-
|
|
20806
|
-
|
|
20807
|
-
|
|
20808
|
-
|
|
20809
|
-
|
|
20810
|
-
|
|
20811
|
-
|
|
20812
|
-
|
|
20813
|
-
|
|
20814
|
-
|
|
20815
|
-
|
|
20816
|
-
|
|
20817
|
-
|
|
20818
|
-
|
|
20819
|
-
|
|
20820
|
-
|
|
20821
|
-
|
|
20822
|
-
|
|
20823
|
-
|
|
20824
|
-
|
|
20825
|
-
|
|
20826
|
-
|
|
20827
|
-
const
|
|
20828
|
-
if (
|
|
20829
|
-
|
|
20830
|
-
|
|
20831
|
-
|
|
20832
|
-
}
|
|
20833
|
-
return since;
|
|
20834
|
-
}
|
|
20835
|
-
function auditOrderNote(root, auditId) {
|
|
20836
|
-
const plan = planIdOfPartId(auditId);
|
|
20837
|
-
const later = listAuditIds(root).filter((id) => id > auditId && (plan === null || planIdOfPartId(id) !== plan));
|
|
20838
|
-
if (later.length === 0) return void 0;
|
|
20839
|
-
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.`;
|
|
20840
|
-
}
|
|
20841
|
-
function computeAuditMatrix(root, auditId, library) {
|
|
20842
|
-
const scores = loadScores(root, auditId);
|
|
20843
|
-
const section = loadQualitySection(root, auditId, library, scores);
|
|
20844
|
-
const matrix = deriveQualityMatrix({ quality: section }, library);
|
|
20845
|
-
const file2 = {
|
|
20846
|
-
audit_id: auditId,
|
|
20847
|
-
commit: scores.commit,
|
|
20848
|
-
framework_version: section.framework_version,
|
|
20849
|
-
matrix: matrix.matrix,
|
|
20850
|
-
overall: matrix.overall,
|
|
20851
|
-
finding_counts: matrix.finding_counts
|
|
20852
|
-
};
|
|
20853
|
-
writeJson(matrixPath(root, auditId), file2);
|
|
20854
|
-
return { section, matrix, file: file2 };
|
|
20855
|
-
}
|
|
20856
|
-
function locateFinding(root, id) {
|
|
20857
|
-
for (const auditId of [...listAuditIds(root)].reverse()) {
|
|
20858
|
-
const file2 = loadFindings(root, auditId);
|
|
20859
|
-
const finding = file2.findings.find((candidate) => candidate.id === id);
|
|
20860
|
-
if (finding) return { auditId, file: file2, finding };
|
|
20861
|
-
}
|
|
20862
|
-
return void 0;
|
|
22135
|
+
if (part.auditId !== expected) {
|
|
22136
|
+
ctx.addIssue({
|
|
22137
|
+
code: "custom",
|
|
22138
|
+
path: ["parts", index, "auditId"],
|
|
22139
|
+
message: expected === null ? `the surface "${part.surface}" cannot be planned, so no audit id fits this part` : `not this part's audit id: expected "${expected}"`
|
|
22140
|
+
});
|
|
22141
|
+
} else if (seen.has(part.auditId)) {
|
|
22142
|
+
ctx.addIssue({ code: "custom", path: ["parts", index, "auditId"], message: `repeats the audit id of part ${seen.get(part.auditId)}` });
|
|
22143
|
+
} else {
|
|
22144
|
+
seen.set(part.auditId, index);
|
|
22145
|
+
}
|
|
22146
|
+
part.cells.forEach((cell, cellIndex) => {
|
|
22147
|
+
if (cell.surface !== part.surface) {
|
|
22148
|
+
ctx.addIssue({
|
|
22149
|
+
code: "custom",
|
|
22150
|
+
path: ["parts", index, "cells", cellIndex, "surface"],
|
|
22151
|
+
message: `not the part's surface "${part.surface}"`
|
|
22152
|
+
});
|
|
22153
|
+
}
|
|
22154
|
+
});
|
|
22155
|
+
});
|
|
22156
|
+
});
|
|
22157
|
+
function parseKritikPlan(value) {
|
|
22158
|
+
const result = KritikPlanSchema2.safeParse(value);
|
|
22159
|
+
if (result.success) return { ok: true, plan: result.data };
|
|
22160
|
+
const first = result.error.issues[0];
|
|
22161
|
+
const path = first === void 0 ? "" : first.path.map(String).join(".");
|
|
22162
|
+
return { ok: false, issue: `${path === "" ? "(root)" : path}: ${first?.message ?? "not a plan"}` };
|
|
20863
22163
|
}
|
|
20864
22164
|
|
|
20865
|
-
//
|
|
20866
|
-
import { spawnSync } from "node:child_process";
|
|
20867
|
-
import { existsSync as existsSync3, readdirSync as readdirSync2, statSync as statSync2 } from "node:fs";
|
|
20868
|
-
import { join as join3 } from "node:path";
|
|
22165
|
+
// ../../../../../packages/schema/src/cli/kritik-plan.ts
|
|
20869
22166
|
var plansDir = (root) => join3(root, QUALITY_DIR, PLAN_PLANS_DIR);
|
|
20870
22167
|
var planPath = (root, planId2) => join3(plansDir(root), `${planId2}.json`);
|
|
20871
22168
|
function listPlanIds(root) {
|
|
20872
22169
|
const dir = plansDir(root);
|
|
20873
22170
|
if (!existsSync3(dir)) return [];
|
|
20874
|
-
return readdirSync2(dir).filter((name) => name.endsWith(".json") && statSync2(join3(dir, name)).isFile()).map((name) => name.slice(0, -".json".length)).filter((id) =>
|
|
22171
|
+
return readdirSync2(dir).filter((name) => name.endsWith(".json") && statSync2(join3(dir, name)).isFile()).map((name) => name.slice(0, -".json".length)).filter((id) => isPlanId2(id)).sort();
|
|
20875
22172
|
}
|
|
20876
22173
|
function readPlanFile(path) {
|
|
20877
22174
|
if (!existsSync3(path)) throw new Error(`no plan at ${path}`);
|
|
@@ -20880,7 +22177,7 @@ function readPlanFile(path) {
|
|
|
20880
22177
|
return parsed.plan;
|
|
20881
22178
|
}
|
|
20882
22179
|
function loadPlan(root, planId2) {
|
|
20883
|
-
if (!
|
|
22180
|
+
if (!isPlanId2(planId2)) {
|
|
20884
22181
|
throw new Error(`"${planId2}" is not a plan id \u2014 a plan id reads YYYY-MM-zplan-DDNN, as \`arkaik kritik plan\` prints it.`);
|
|
20885
22182
|
}
|
|
20886
22183
|
const path = planPath(root, planId2);
|
|
@@ -20931,7 +22228,7 @@ var cellLabel = (cell) => `${cell.criterion_id} on ${cell.surface}`;
|
|
|
20931
22228
|
var runFlags = (parts) => parts.map((part) => `--run ${part.domain}:${part.surface}`).join(" ");
|
|
20932
22229
|
function preparePlanRecord(root, planId2, library, events) {
|
|
20933
22230
|
const plan = loadPlan(root, planId2);
|
|
20934
|
-
if (
|
|
22231
|
+
if (recordedPlans2(events).some((recorded) => recorded.plan === planId2) || recordedAuditIds2(events).includes(planId2)) {
|
|
20935
22232
|
throw new Error(
|
|
20936
22233
|
`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.`
|
|
20937
22234
|
);
|
|
@@ -20971,7 +22268,7 @@ function preparePlanRecord(root, planId2, library, events) {
|
|
|
20971
22268
|
);
|
|
20972
22269
|
}
|
|
20973
22270
|
const onDiskIds = listAuditIds(root);
|
|
20974
|
-
const outsorted = included.map((part) => ({ part, later:
|
|
22271
|
+
const outsorted = included.map((part) => ({ part, later: outsortedBy2(part.auditId, onDiskIds) })).filter((entry) => entry.later.length > 0);
|
|
20975
22272
|
if (outsorted.length > 0) {
|
|
20976
22273
|
throw new Error(
|
|
20977
22274
|
`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:
|
|
@@ -20981,13 +22278,13 @@ Make a new plan for the affected parts and score them again: \`arkaik kritik pla
|
|
|
20981
22278
|
}
|
|
20982
22279
|
const last = included.map((part) => part.auditId).sort()[included.length - 1];
|
|
20983
22280
|
const ownParts = new Set(included.map((part) => part.auditId));
|
|
20984
|
-
const recordedIds = new Set(
|
|
22281
|
+
const recordedIds = new Set(recordedAuditIds2(events));
|
|
20985
22282
|
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);
|
|
20986
22283
|
if (unannounced.length > 0) {
|
|
20987
22284
|
throw new Error(
|
|
20988
22285
|
`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:
|
|
20989
22286
|
` + unannounced.map(({ id, scores }) => {
|
|
20990
|
-
const owner =
|
|
22287
|
+
const owner = planIdOfPartId2(id);
|
|
20991
22288
|
return ` ${id}: ${scores} score${scores === 1 ? "" : "s"}, never recorded` + (owner !== null ? ` (a part of plan "${owner}")` : "");
|
|
20992
22289
|
}).join("\n") + `
|
|
20993
22290
|
Record each first, or remove its scores (docs/quality/audits/<id>/scores.json), then record this plan.`
|
|
@@ -21018,7 +22315,7 @@ Record each first, or remove its scores (docs/quality/audits/<id>/scores.json),
|
|
|
21018
22315
|
);
|
|
21019
22316
|
}
|
|
21020
22317
|
const section = loadQualitySectionThrough(root, last, library);
|
|
21021
|
-
const matrix =
|
|
22318
|
+
const matrix = deriveQualityMatrix2({ quality: section }, library);
|
|
21022
22319
|
const scored = included.flatMap((part) => part.cells.map((cell) => planCellKey(cell.criterion_id, cell.surface)));
|
|
21023
22320
|
const since = scopeAnchorId(events);
|
|
21024
22321
|
const scope = {
|
|
@@ -21030,7 +22327,7 @@ Record each first, or remove its scores (docs/quality/audits/<id>/scores.json),
|
|
|
21030
22327
|
scored,
|
|
21031
22328
|
coverage: coverageOf(section, library, scored.length)
|
|
21032
22329
|
};
|
|
21033
|
-
const input =
|
|
22330
|
+
const input = auditCompletedInput2(matrix, {
|
|
21034
22331
|
audit_id: plan.planId,
|
|
21035
22332
|
framework_version: plan.frameworkVersion,
|
|
21036
22333
|
...plan.commit !== null ? { commit: plan.commit } : {},
|
|
@@ -21135,9 +22432,25 @@ function resolveQualityRoot(options) {
|
|
|
21135
22432
|
return options.fallback;
|
|
21136
22433
|
}
|
|
21137
22434
|
|
|
21138
|
-
//
|
|
22435
|
+
// ../../../../../packages/schema/src/cli/weighing-files.ts
|
|
21139
22436
|
import { existsSync as existsSync7, readdirSync as readdirSync4 } from "node:fs";
|
|
21140
22437
|
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
|
|
21141
22454
|
var WEIGHING_DIR = "docs/weighing";
|
|
21142
22455
|
var WEIGHING_SETS_DIR = "sets";
|
|
21143
22456
|
var WEIGHING_ASSESSMENTS_DIR = "assessments";
|
|
@@ -22550,6 +23863,257 @@ function buildKritikCatalog(ctx) {
|
|
|
22550
23863
|
return { tools: tools2, handlers: handlers2 };
|
|
22551
23864
|
}
|
|
22552
23865
|
|
|
23866
|
+
// src/qualify-tools.ts
|
|
23867
|
+
var questionText = ROUTING_QUESTIONS.map((q) => `${q.id}: ${q.question} (${Object.keys(q.answers).join(" | ")})`).join(" ");
|
|
23868
|
+
var ANSWER_PROPERTIES = {
|
|
23869
|
+
scope: { type: "string", enum: [...QUALIFY_SCOPES] },
|
|
23870
|
+
door: { type: "string", enum: [...QUALIFY_DOORS], description: "Default: collect for an observed signal, imagine for an anticipated one or an idea." },
|
|
23871
|
+
facing: { type: "string", enum: [...QUALIFY_FACINGS] },
|
|
23872
|
+
expectation: { type: "string", enum: [...QUALIFY_EXPECTATIONS], description: "When facing is value." },
|
|
23873
|
+
threat: { type: "string", enum: [...QUALIFY_THREATS], description: "When facing is quality." },
|
|
23874
|
+
basis: { type: "string", enum: [...QUALIFY_BASES], description: "Default: stated." }
|
|
23875
|
+
};
|
|
23876
|
+
var SIGNAL_PROPERTIES = {
|
|
23877
|
+
signal_id: { type: "string", description: "A request.filed or idea.proposed event id from the backlog. Or pass title inline." },
|
|
23878
|
+
title: { type: "string", description: "Inline signal, when it has no journal event (then no evidence event_id is recorded)." },
|
|
23879
|
+
verbatim: { type: "string", description: "Inline signal: the input exactly as voiced." },
|
|
23880
|
+
anchors: {
|
|
23881
|
+
type: "array",
|
|
23882
|
+
items: { type: "string" },
|
|
23883
|
+
description: "Flow, view, data-model or api-endpoint ids the stake concerns. Defaults to the signal's node_id when that is one."
|
|
23884
|
+
},
|
|
23885
|
+
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
|
+
};
|
|
23887
|
+
function optionalString(args, key) {
|
|
23888
|
+
const value = args[key];
|
|
23889
|
+
return typeof value === "string" && value !== "" ? value : void 0;
|
|
23890
|
+
}
|
|
23891
|
+
function readEnum(args, key, allowed) {
|
|
23892
|
+
const value = args[key];
|
|
23893
|
+
if (value === void 0) return void 0;
|
|
23894
|
+
if (!allowed.includes(value)) throw new ToolError(`\`${key}\` must be one of: ${allowed.join(", ")}.`);
|
|
23895
|
+
return value;
|
|
23896
|
+
}
|
|
23897
|
+
function isIdea(signal) {
|
|
23898
|
+
return signal.provenance === "anticipated" || signal.source_kind === "idea";
|
|
23899
|
+
}
|
|
23900
|
+
function readAnswers(args, signal) {
|
|
23901
|
+
const answers = { door: readEnum(args, "door", QUALIFY_DOORS) ?? (isIdea(signal) ? "imagine" : "collect") };
|
|
23902
|
+
const scope = readEnum(args, "scope", QUALIFY_SCOPES);
|
|
23903
|
+
const facing = readEnum(args, "facing", QUALIFY_FACINGS);
|
|
23904
|
+
const expectation = readEnum(args, "expectation", QUALIFY_EXPECTATIONS);
|
|
23905
|
+
const threat = readEnum(args, "threat", QUALIFY_THREATS);
|
|
23906
|
+
const basis = readEnum(args, "basis", QUALIFY_BASES);
|
|
23907
|
+
if (scope !== void 0) answers.scope = scope;
|
|
23908
|
+
if (facing !== void 0) answers.facing = facing;
|
|
23909
|
+
if (expectation !== void 0) answers.expectation = expectation;
|
|
23910
|
+
if (threat !== void 0) answers.threat = threat;
|
|
23911
|
+
if (basis !== void 0) answers.basis = basis;
|
|
23912
|
+
return answers;
|
|
23913
|
+
}
|
|
23914
|
+
function resolveSignal(args, journal) {
|
|
23915
|
+
const signalId = optionalString(args, "signal_id");
|
|
23916
|
+
if (signalId === void 0) {
|
|
23917
|
+
const title = optionalString(args, "title");
|
|
23918
|
+
if (title === void 0) throw new ToolError("Pass `signal_id` (a backlog event id) or an inline `title`.");
|
|
23919
|
+
const verbatim = optionalString(args, "verbatim");
|
|
23920
|
+
return { title, ...verbatim !== void 0 ? { verbatim } : {} };
|
|
23921
|
+
}
|
|
23922
|
+
const event = journal.find((candidate) => candidate.id === signalId);
|
|
23923
|
+
if (event === void 0 || event.type !== "request.filed" && event.type !== "idea.proposed") {
|
|
23924
|
+
throw new ToolError(`No request.filed or idea.proposed event with id "${signalId}".`);
|
|
23925
|
+
}
|
|
23926
|
+
const request = event;
|
|
23927
|
+
const kind = event.type === "idea.proposed" ? "idea" : signalSourceKindOf(request);
|
|
23928
|
+
return {
|
|
23929
|
+
event_id: event.id,
|
|
23930
|
+
title: typeof request.title === "string" ? request.title : signalId,
|
|
23931
|
+
...typeof request.verbatim === "string" && request.verbatim !== "" ? { verbatim: request.verbatim } : {},
|
|
23932
|
+
date: event.ts,
|
|
23933
|
+
...kind !== void 0 ? { source_kind: kind } : {},
|
|
23934
|
+
...request.provenance === "anticipated" || request.provenance === "observed" ? { provenance: request.provenance } : {},
|
|
23935
|
+
...typeof request.node_id === "string" ? { node_id: request.node_id } : {},
|
|
23936
|
+
...typeof request.criterion_id === "string" ? { criterion_id: request.criterion_id } : {}
|
|
23937
|
+
};
|
|
23938
|
+
}
|
|
23939
|
+
function resolveAnchors(args, signal, nodes) {
|
|
23940
|
+
if (args.anchors !== void 0) {
|
|
23941
|
+
if (!Array.isArray(args.anchors) || args.anchors.some((id) => typeof id !== "string" || id === "")) {
|
|
23942
|
+
throw new ToolError("`anchors` must be an array of node ids.");
|
|
23943
|
+
}
|
|
23944
|
+
return args.anchors;
|
|
23945
|
+
}
|
|
23946
|
+
const node = signal.node_id === void 0 ? void 0 : nodes.find((candidate) => candidate.id === signal.node_id);
|
|
23947
|
+
return node !== void 0 && STAKE_ANCHOR_SPECIES.includes(node.species) ? [node.id] : [];
|
|
23948
|
+
}
|
|
23949
|
+
function resolveCatalogId(args, signal, species) {
|
|
23950
|
+
const explicit = optionalString(args, "catalog_id");
|
|
23951
|
+
if (explicit !== void 0) return explicit;
|
|
23952
|
+
return QUALITY_STAKE_SPECIES.includes(species) ? signal.criterion_id : void 0;
|
|
23953
|
+
}
|
|
23954
|
+
function routeFor(args, signal) {
|
|
23955
|
+
const answers = readAnswers(args, signal);
|
|
23956
|
+
const routing = routeSpecies(answers);
|
|
23957
|
+
if (routing.route === "stake" && answers.door === "collect" && isIdea(signal)) {
|
|
23958
|
+
routing.handToHuman.push("This signal is an idea but came through the collect door: it is read as observed. A person confirms the door.");
|
|
23959
|
+
}
|
|
23960
|
+
return routing;
|
|
23961
|
+
}
|
|
23962
|
+
function suggestionFor(routing, candidates, citing) {
|
|
23963
|
+
if (routing.route === "incomplete") return { action: "ask" };
|
|
23964
|
+
if (routing.route === "refused") return { action: "refused" };
|
|
23965
|
+
if (routing.route !== "stake") return { action: "route-out" };
|
|
23966
|
+
if (citing !== void 0) return { action: "already-qualified", stake_id: citing.id };
|
|
23967
|
+
const top = candidates[0];
|
|
23968
|
+
if (top?.alreadyCited) return { action: "already-qualified", stake_id: top.stake_id };
|
|
23969
|
+
if (top !== void 0 && (top.confidence === "high" || top.confidence === "medium")) {
|
|
23970
|
+
return { action: "merge", merge_into: top.stake_id, confidence: top.confidence };
|
|
23971
|
+
}
|
|
23972
|
+
return { action: "create" };
|
|
23973
|
+
}
|
|
23974
|
+
function buildQualifyCatalog(ctx, io) {
|
|
23975
|
+
const tools2 = [];
|
|
23976
|
+
const handlers2 = {};
|
|
23977
|
+
const tool = (definition, handler) => {
|
|
23978
|
+
tools2.push(definition);
|
|
23979
|
+
handlers2[definition.name] = handler;
|
|
23980
|
+
};
|
|
23981
|
+
tool(
|
|
23982
|
+
{
|
|
23983
|
+
name: "qualify_signal",
|
|
23984
|
+
description: `Read-only. Route a signal (a backlog event or an inline title) to a stake species and list the existing stakes it could merge into. You answer the routing questions; the table decides. ${questionText} A bug or friction cannot come through the imagine door: reroute as need. Anything routed out, refused or inferred is for a person to confirm. Returns { signal, routing, anchors, catalog_id?, candidates, suggestion, questions? (when the route is incomplete) }; it never writes and never merges on its own.`,
|
|
23985
|
+
inputSchema: {
|
|
23986
|
+
type: "object",
|
|
23987
|
+
properties: { ...SIGNAL_PROPERTIES, ...ANSWER_PROPERTIES },
|
|
23988
|
+
additionalProperties: false
|
|
23989
|
+
}
|
|
23990
|
+
},
|
|
23991
|
+
async (args) => {
|
|
23992
|
+
const graph = await io.load();
|
|
23993
|
+
const signal = resolveSignal(args, graph.journal);
|
|
23994
|
+
const routing = routeFor(args, signal);
|
|
23995
|
+
const anchors = resolveAnchors(args, signal, graph.nodes);
|
|
23996
|
+
const citing = routing.route === "stake" ? stakeCiting(graph.nodes, signal.event_id) : void 0;
|
|
23997
|
+
if (citing !== void 0 && routing.species !== void 0 && stakeSpeciesOf(citing) !== routing.species) {
|
|
23998
|
+
const was = stakeSpeciesOf(citing);
|
|
23999
|
+
routing.handToHuman.push(
|
|
24000
|
+
`${citing.id} already cites this signal as ${was === void 0 ? "a stake with no species" : `a ${was}`}, but the answers route it as ${routing.species}: a person decides which species is right.`
|
|
24001
|
+
);
|
|
24002
|
+
}
|
|
24003
|
+
const catalog_id = routing.species !== void 0 ? resolveCatalogId(args, signal, routing.species) : void 0;
|
|
24004
|
+
let candidates = [];
|
|
24005
|
+
if (routing.route === "stake" && routing.species !== void 0) {
|
|
24006
|
+
const like = {
|
|
24007
|
+
title: signal.title,
|
|
24008
|
+
species: routing.species,
|
|
24009
|
+
node_ids: anchors,
|
|
24010
|
+
...signal.event_id !== void 0 ? { event_id: signal.event_id } : {},
|
|
24011
|
+
...signal.verbatim !== void 0 ? { verbatim: signal.verbatim } : {},
|
|
24012
|
+
...catalog_id !== void 0 ? { catalog_id } : {},
|
|
24013
|
+
...signal.source_kind !== void 0 ? { source_kind: signal.source_kind } : {}
|
|
24014
|
+
};
|
|
24015
|
+
candidates = findMergeCandidates(like, graph.nodes, { edges: graph.edges });
|
|
24016
|
+
}
|
|
24017
|
+
return {
|
|
24018
|
+
signal: {
|
|
24019
|
+
...signal.event_id !== void 0 ? { event_id: signal.event_id } : {},
|
|
24020
|
+
title: signal.title,
|
|
24021
|
+
...signal.source_kind !== void 0 ? { source_kind: signal.source_kind } : {},
|
|
24022
|
+
...signal.provenance !== void 0 ? { provenance: signal.provenance } : {}
|
|
24023
|
+
},
|
|
24024
|
+
routing,
|
|
24025
|
+
anchors,
|
|
24026
|
+
...catalog_id !== void 0 ? { catalog_id } : {},
|
|
24027
|
+
candidates,
|
|
24028
|
+
suggestion: suggestionFor(routing, candidates, citing),
|
|
24029
|
+
...routing.route === "incomplete" ? { questions: ROUTING_QUESTIONS.filter((question) => routing.ask.includes(question.id)) } : {}
|
|
24030
|
+
};
|
|
24031
|
+
}
|
|
24032
|
+
);
|
|
24033
|
+
tool(
|
|
24034
|
+
{
|
|
24035
|
+
name: "promote_signal",
|
|
24036
|
+
description: `Record a qualified signal as a stake: create one (create: true) or append the signal as evidence to an existing stake (merge_into). Answer the same routing questions as qualify_signal; a route that is not a stake, or a species the door forbids, is refused. A created stake lands at idea with the species, provenance, a first evidence entry and one concerns edge per anchor; stake_title is the stake's own wording (write it positively and solution-neutral; it defaults to the signal's title). Re-promoting a signal a stake already cites is a no-op. Never merges unless you name merge_into. Works on a repo and a hosted project.`,
|
|
24037
|
+
inputSchema: {
|
|
24038
|
+
type: "object",
|
|
24039
|
+
properties: {
|
|
24040
|
+
...SIGNAL_PROPERTIES,
|
|
24041
|
+
...ANSWER_PROPERTIES,
|
|
24042
|
+
create: { type: "boolean", description: "Create a new stake. Exactly one of create / merge_into." },
|
|
24043
|
+
merge_into: { type: "string", description: "The stake id to add the signal to as evidence." },
|
|
24044
|
+
stake_title: { type: "string", description: "The new stake's wording." },
|
|
24045
|
+
voice: { type: "string", enum: [...STAKE_EVIDENCE_VOICES], description: "Who voiced the signal." }
|
|
24046
|
+
},
|
|
24047
|
+
additionalProperties: false
|
|
24048
|
+
}
|
|
24049
|
+
},
|
|
24050
|
+
async (args) => {
|
|
24051
|
+
const graph = await io.load();
|
|
24052
|
+
const signal = resolveSignal(args, graph.journal);
|
|
24053
|
+
const mergeInto = optionalString(args, "merge_into");
|
|
24054
|
+
if (mergeInto !== void 0 === (args.create === true)) {
|
|
24055
|
+
throw new ToolError("Pass exactly one of `create: true` or `merge_into` (a stake id).");
|
|
24056
|
+
}
|
|
24057
|
+
const routing = routeFor(args, signal);
|
|
24058
|
+
if (routing.route !== "stake" || routing.species === void 0 || routing.provenance === void 0) {
|
|
24059
|
+
throw new ToolError(
|
|
24060
|
+
routing.route === "incomplete" ? `Not enough answers to route the species: ${routing.ask.join(", ")}. Call qualify_signal first.` : `Not promoted: ${routing.reasons.join(" ")}`,
|
|
24061
|
+
{ routing }
|
|
24062
|
+
);
|
|
24063
|
+
}
|
|
24064
|
+
const voice = readEnum(args, "voice", STAKE_EVIDENCE_VOICES);
|
|
24065
|
+
const evidenceSignal = {
|
|
24066
|
+
title: signal.title,
|
|
24067
|
+
...signal.event_id !== void 0 ? { event_id: signal.event_id } : {},
|
|
24068
|
+
...signal.verbatim !== void 0 ? { verbatim: signal.verbatim } : {},
|
|
24069
|
+
...signal.date !== void 0 ? { date: signal.date } : {},
|
|
24070
|
+
...voice !== void 0 ? { voice } : {}
|
|
24071
|
+
};
|
|
24072
|
+
let plan;
|
|
24073
|
+
if (mergeInto !== void 0) {
|
|
24074
|
+
const target = graph.nodes.find((node) => node.id === mergeInto);
|
|
24075
|
+
if (target === void 0) throw new ToolError(`No node with id "${mergeInto}".`);
|
|
24076
|
+
plan = planSignalMerge({ signal: evidenceSignal, target, species: routing.species, nodes: graph.nodes });
|
|
24077
|
+
} else {
|
|
24078
|
+
const catalogId = resolveCatalogId(args, signal, routing.species);
|
|
24079
|
+
const catalog = catalogId !== void 0 ? { source: catalogSourceForStakeSpecies(routing.species), id: catalogId } : void 0;
|
|
24080
|
+
const title = optionalString(args, "stake_title");
|
|
24081
|
+
plan = planSignalToStake({
|
|
24082
|
+
projectId: graph.project.id,
|
|
24083
|
+
signal: evidenceSignal,
|
|
24084
|
+
species: routing.species,
|
|
24085
|
+
provenance: routing.provenance,
|
|
24086
|
+
anchors: resolveAnchors(args, signal, graph.nodes),
|
|
24087
|
+
nodes: graph.nodes,
|
|
24088
|
+
edges: graph.edges,
|
|
24089
|
+
...title !== void 0 ? { title } : {},
|
|
24090
|
+
...catalog !== void 0 ? { catalog } : {}
|
|
24091
|
+
});
|
|
24092
|
+
}
|
|
24093
|
+
const handToHuman = [...routing.handToHuman, ...plan.handToHuman];
|
|
24094
|
+
if (plan.action === "refused") throw new ToolError(`Not promoted: ${plan.reasons.join(" ")}`, { reasons: plan.reasons });
|
|
24095
|
+
if (plan.action === "noop") {
|
|
24096
|
+
return { action: "noop", stake_id: plan.stake_id, reasons: plan.reasons, ops: [], events: [], warnings: [], handToHuman };
|
|
24097
|
+
}
|
|
24098
|
+
const outcome = io.mutate(graph, plan.ops);
|
|
24099
|
+
const result = await ctx.store.persist(graph, { nodes: outcome.nodes, edges: outcome.edges, ops: plan.ops }, outcome.eventInputs);
|
|
24100
|
+
const { warnings, events } = io.unwrap(result);
|
|
24101
|
+
const stakeId = plan.stake_id;
|
|
24102
|
+
return {
|
|
24103
|
+
action: plan.action,
|
|
24104
|
+
stake_id: stakeId,
|
|
24105
|
+
stake: outcome.nodes.find((node) => node.id === stakeId),
|
|
24106
|
+
anchors: stakeAnchors(stakeId, outcome.edges),
|
|
24107
|
+
ops: plan.ops,
|
|
24108
|
+
events,
|
|
24109
|
+
warnings,
|
|
24110
|
+
handToHuman
|
|
24111
|
+
};
|
|
24112
|
+
}
|
|
24113
|
+
);
|
|
24114
|
+
return { tools: tools2, handlers: handlers2 };
|
|
24115
|
+
}
|
|
24116
|
+
|
|
22553
24117
|
// src/weighing-tools.ts
|
|
22554
24118
|
import { execFile } from "node:child_process";
|
|
22555
24119
|
|
|
@@ -22673,7 +24237,7 @@ function requireInt2(args, key, min, max) {
|
|
|
22673
24237
|
}
|
|
22674
24238
|
return value;
|
|
22675
24239
|
}
|
|
22676
|
-
var
|
|
24240
|
+
var optionalString2 = (args, key) => typeof args[key] === "string" && args[key] !== "" ? args[key] : void 0;
|
|
22677
24241
|
function cellRow(cell, withProbabilities) {
|
|
22678
24242
|
return {
|
|
22679
24243
|
criterion: cell.criterion,
|
|
@@ -22692,8 +24256,30 @@ function cellRow(cell, withProbabilities) {
|
|
|
22692
24256
|
...cell.others.length > 0 ? { others: cell.others.map((row) => ({ scorer: row.scorer, level: row.level, confidence: row.confidence, ...row.evidence !== void 0 ? { evidence: row.evidence } : {} })) } : {}
|
|
22693
24257
|
};
|
|
22694
24258
|
}
|
|
22695
|
-
function
|
|
24259
|
+
function stakeFacts(node) {
|
|
24260
|
+
if (node === void 0 || node.species !== "stake") return {};
|
|
24261
|
+
const kind = stakeSpeciesOf(node);
|
|
24262
|
+
return {
|
|
24263
|
+
stake: {
|
|
24264
|
+
stake_species: kind ?? null,
|
|
24265
|
+
...kind !== void 0 ? { reference: referenceForStakeSpecies(kind) } : {},
|
|
24266
|
+
...stakeFeltOf(node) !== void 0 ? { felt: stakeFeltOf(node) } : {},
|
|
24267
|
+
...stakeMattersOf(node) !== void 0 ? { matters: stakeMattersOf(node) } : {},
|
|
24268
|
+
...stakeFrequencyOf(node) !== void 0 ? { frequency: stakeFrequencyOf(node) } : {}
|
|
24269
|
+
}
|
|
24270
|
+
};
|
|
24271
|
+
}
|
|
24272
|
+
function stakeGroupOf(node) {
|
|
24273
|
+
const species = node === void 0 ? void 0 : stakeSpeciesOf(node);
|
|
24274
|
+
const felt = node === void 0 ? void 0 : species === "bug" ? "expected" : stakeFeltOf(node);
|
|
24275
|
+
return { key: `${species ?? "unknown"}${felt !== void 0 ? `:${felt}` : ""}`, stake_species: species ?? null, ...felt !== void 0 ? { felt } : {} };
|
|
24276
|
+
}
|
|
24277
|
+
var STAKE_GROUP_ORDER = ["bug", "friction", "need"];
|
|
24278
|
+
var FELT_ORDER = ["expected", "wanted", "delight"];
|
|
24279
|
+
var defaultMatrixFor = (nodes, subject) => nodes.find((candidate) => candidate.id === subject)?.species === "stake" ? STAKE_MATRIX_ID : VALUE_MATRIX_ID;
|
|
24280
|
+
function promiseRow(promise2, withCells, withProbabilities = false, node) {
|
|
22696
24281
|
return {
|
|
24282
|
+
...stakeFacts(node),
|
|
22697
24283
|
node_id: promise2.node_id,
|
|
22698
24284
|
title: promise2.title,
|
|
22699
24285
|
status: promise2.status,
|
|
@@ -22765,12 +24351,12 @@ function buildWeighingCatalog(ctx) {
|
|
|
22765
24351
|
tool(
|
|
22766
24352
|
{
|
|
22767
24353
|
name: "get_matrix",
|
|
22768
|
-
description: "The value matrix: what each promise (acceptance) is worth, against the 30 elements of value on a signed -3..+3 scale that measures REACH in a person's life: +1 within the product, +2 across the product's domain, +3 life-wide; the negatives mirror it, and 0 is weighed and unrelated. Most real promises land at +1; +3 is rare. Each element has its own ladder of what every level means. Per promise: `served` (sum of positive levels / 3) and `cost` (sum of |negative levels| / 3), NEVER netted; `positioned` (the same over the elements the product's active positioning stands on, each times its weight); `kept_share` (platforms where it is live / platforms it applies to); `guesswork` (the share of served and of cost resting on confidence-0 cells; `positioned` carries its own, and every mass and total says how much of it is guesswork). `flags` is a partition: claim_not_supported (claimed in metadata.values but assessed 0), claim_contradicted (claimed but assessed negative), unclaimed_value (not claimed, assessed 1 or more) and unclaimed_cost (not claimed, assessed negative \u2014 authors claim intent, so a cost is never claimed). `stale` lists elements whose winning level was scored before the promise's title, Gherkin or values changed, or against an older major of the ruler; `review` lists elements where a human and an agent differ by 2 or more; `uncertain` lists elements whose winning level a probabilistic scorer was unsure of (read it as a range). A cell nobody has scored reads at a SEEDED level: every claimed value +1 (scorer rule, confidence 0), a guess, never a score \u2014 negatives are never seeded. A human's level beats an agent's beats a seed, whatever the dates. Pass `subject` for one promise with every cell, its evidence, and each element's question and ladder \u2014 what you read before calling assess. Otherwise it lists promises (sort: served | cost | positioned | title; filter: flagged | stale | review | uncertain | unassessed; limit) plus the per-element promised / kept / cost masses. `probabilities: true` adds each cell's stored p_serves / p_costs. A draft positioning feeds nothing.",
|
|
24354
|
+
description: "The value matrix: what each promise (acceptance) is worth, against the 30 elements of value on a signed -3..+3 scale that measures REACH in a person's life: +1 within the product, +2 across the product's domain, +3 life-wide; the negatives mirror it, and 0 is weighed and unrelated. Most real promises land at +1; +3 is rare. Each element has its own ladder of what every level means. Per promise: `served` (sum of positive levels / 3) and `cost` (sum of |negative levels| / 3), NEVER netted; `positioned` (the same over the elements the product's active positioning stands on, each times its weight); `kept_share` (platforms where it is live / platforms it applies to); `guesswork` (the share of served and of cost resting on confidence-0 cells; `positioned` carries its own, and every mass and total says how much of it is guesswork). `flags` is a partition: claim_not_supported (claimed in metadata.values but assessed 0), claim_contradicted (claimed but assessed negative), unclaimed_value (not claimed, assessed 1 or more) and unclaimed_cost (not claimed, assessed negative \u2014 authors claim intent, so a cost is never claimed). `stale` lists elements whose winning level was scored before the promise's title, Gherkin or values changed, or against an older major of the ruler; `review` lists elements where a human and an agent differ by 2 or more; `uncertain` lists elements whose winning level a probabilistic scorer was unsure of (read it as a range). A cell nobody has scored reads at a SEEDED level: every claimed value +1 (scorer rule, confidence 0), a guess, never a score \u2014 negatives are never seeded. A human's level beats an agent's beats a seed, whatever the dates. Pass `subject` for one promise with every cell, its evidence, and each element's question and ladder \u2014 what you read before calling assess. Otherwise it lists promises (sort: served | cost | positioned | title; filter: flagged | stale | review | uncertain | unassessed; limit) plus the per-element promised / kept / cost masses. `probabilities: true` adds each cell's stored p_serves / p_costs. A draft positioning feeds nothing. The `stakes` matrix weighs stakes of the kinds the ruler declares (bug, friction, need) on the same elements and ladder, in its own cells, never added to the promises'; stakes of different kinds are never ranked or summed against each other, so the result is `groups`, one list (with its own totals and element masses) per species and, for bug, friction and need, per felt kind, each ordered within itself, and the order of the groups is not a priority; a stake is never seeded and claims nothing, so it has no claim flags and no kept share, and each row carries the stake's kind, its reference and its felt / matters / frequency when set (shown beside the score, never summed with it). A requirement, risk or defect is not weighed: it is read against a Kritik criterion.",
|
|
22769
24355
|
inputSchema: {
|
|
22770
24356
|
type: "object",
|
|
22771
24357
|
properties: {
|
|
22772
|
-
matrix: { type: "string", description: `Default: ${VALUE_MATRIX_ID}.` },
|
|
22773
|
-
subject: { type: "string", description: "An acceptance id: return that promise with every cell." },
|
|
24358
|
+
matrix: { type: "string", description: `Default: ${VALUE_MATRIX_ID}, or ${STAKE_MATRIX_ID} when \`subject\` is a stake.` },
|
|
24359
|
+
subject: { type: "string", description: "An acceptance or stake id: return that promise with every cell." },
|
|
22774
24360
|
sort: { type: "string", enum: ["served", "cost", "positioned", "title"], description: "Default: served, heaviest first." },
|
|
22775
24361
|
filter: { type: "string", enum: [...FILTERS] },
|
|
22776
24362
|
limit: { type: "integer", minimum: 1, maximum: 200, description: "Default 25." },
|
|
@@ -22783,9 +24369,11 @@ function buildWeighingCatalog(ctx) {
|
|
|
22783
24369
|
const graph = await load2();
|
|
22784
24370
|
const section = sectionOf(graph);
|
|
22785
24371
|
const nodes = graph.nodes;
|
|
22786
|
-
const matrixId =
|
|
24372
|
+
const matrixId = optionalString2(args, "matrix") ?? defaultMatrixFor(nodes, optionalString2(args, "subject"));
|
|
22787
24373
|
const view = deriveWeighing(nodes, section, matrixId);
|
|
22788
|
-
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
|
|
24374
|
+
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
|
+
const judgesStakes = view.matrix.subjects.kind === "query" && view.matrix.subjects.species === "stake";
|
|
24376
|
+
const nodesById = new Map(nodes.map((node) => [node.id, node]));
|
|
22789
24377
|
const positioning = view.positioning === null ? null : {
|
|
22790
24378
|
status: view.positioning.active ? "active" : "draft",
|
|
22791
24379
|
elements: [...view.positioning.weights].map(([id, weight]) => {
|
|
@@ -22797,8 +24385,10 @@ function buildWeighingCatalog(ctx) {
|
|
|
22797
24385
|
const notes = [];
|
|
22798
24386
|
if (skipped.length > 0) notes.push(`${skipped.length} stored set(s) or matrix(es) are malformed or duplicated and are ignored \u2014 see \`skipped\`.`);
|
|
22799
24387
|
if (view.positioning !== null && !view.positioning.active) notes.push("The positioning is a draft \u2014 `positioned` figures are absent until it is saved as active.");
|
|
22800
|
-
if (view.totals.assessed === 0)
|
|
22801
|
-
|
|
24388
|
+
if (view.totals.assessed === 0) {
|
|
24389
|
+
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
|
+
}
|
|
24391
|
+
const subject = optionalString2(args, "subject");
|
|
22802
24392
|
if (subject !== void 0) {
|
|
22803
24393
|
const promise2 = view.promises.find((candidate) => candidate.node_id === subject);
|
|
22804
24394
|
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"}).`);
|
|
@@ -22816,19 +24406,17 @@ function buildWeighingCatalog(ctx) {
|
|
|
22816
24406
|
})),
|
|
22817
24407
|
confidence_anchors: CONFIDENCE_ANCHORS,
|
|
22818
24408
|
positioning,
|
|
22819
|
-
promise: promiseRow(promise2, true, args.probabilities === true),
|
|
24409
|
+
promise: promiseRow(promise2, true, args.probabilities === true, nodesById.get(promise2.node_id)),
|
|
22820
24410
|
...skipped.length > 0 ? { skipped } : {},
|
|
22821
24411
|
...notes.length > 0 ? { notes } : {}
|
|
22822
24412
|
};
|
|
22823
24413
|
}
|
|
22824
|
-
const sort =
|
|
24414
|
+
const sort = optionalString2(args, "sort") ?? "served";
|
|
22825
24415
|
if (!["served", "cost", "positioned", "title"].includes(sort)) throw new ToolError("`sort` must be served, cost, positioned or title.");
|
|
22826
|
-
const filter =
|
|
24416
|
+
const filter = optionalString2(args, "filter");
|
|
22827
24417
|
if (filter !== void 0 && !FILTERS.includes(filter)) throw new ToolError(`\`filter\` must be one of ${FILTERS.join(", ")}.`);
|
|
22828
24418
|
const limit = typeof args.limit === "number" && Number.isInteger(args.limit) ? Math.min(Math.max(args.limit, 1), 200) : 25;
|
|
22829
|
-
const
|
|
22830
|
-
const ordered = sortPromises(matching, sort);
|
|
22831
|
-
const elements = view.set.criteria.map((criterion) => ({ criterion, mass: view.elements[criterion.id] })).filter(({ mass }) => mass.promised > 0 || mass.cost > 0).sort((a, b) => b.mass.promised - a.mass.promised).map(({ criterion, mass }) => ({
|
|
24419
|
+
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 }) => ({
|
|
22832
24420
|
id: criterion.id,
|
|
22833
24421
|
name: criterion.name,
|
|
22834
24422
|
tier: criterion.group,
|
|
@@ -22837,20 +24425,59 @@ function buildWeighingCatalog(ctx) {
|
|
|
22837
24425
|
cost: round2(mass.cost),
|
|
22838
24426
|
guesswork: { promised: round2(mass.guesswork.promised), kept: round2(mass.guesswork.kept), cost: round2(mass.guesswork.cost) }
|
|
22839
24427
|
}));
|
|
24428
|
+
const totalsOf = (v) => ({
|
|
24429
|
+
promises: v.totals.promises,
|
|
24430
|
+
archived: v.totals.archived,
|
|
24431
|
+
assessed: v.totals.assessed,
|
|
24432
|
+
promised: round2(v.totals.promised),
|
|
24433
|
+
kept: round2(v.totals.kept),
|
|
24434
|
+
cost: round2(v.totals.cost),
|
|
24435
|
+
guesswork: { promised: round2(v.totals.guesswork.promised), kept: round2(v.totals.guesswork.kept), cost: round2(v.totals.guesswork.cost) }
|
|
24436
|
+
});
|
|
24437
|
+
const rowsOf5 = (v) => {
|
|
24438
|
+
const matching = v.promises.filter((promise2) => filter === void 0 || matchesFilter(promise2, filter));
|
|
24439
|
+
const ordered2 = sortPromises(matching, sort);
|
|
24440
|
+
return { ordered: ordered2, rows: ordered2.slice(0, limit).map((promise2) => promiseRow(promise2, false, false, nodesById.get(promise2.node_id))) };
|
|
24441
|
+
};
|
|
24442
|
+
if (judgesStakes) {
|
|
24443
|
+
const members = /* @__PURE__ */ new Map();
|
|
24444
|
+
for (const promise2 of view.promises) {
|
|
24445
|
+
const group = stakeGroupOf(nodesById.get(promise2.node_id));
|
|
24446
|
+
const entry = members.get(group.key) ?? { group, ids: /* @__PURE__ */ new Set() };
|
|
24447
|
+
entry.ids.add(promise2.node_id);
|
|
24448
|
+
members.set(group.key, entry);
|
|
24449
|
+
}
|
|
24450
|
+
const rank = (group) => (STAKE_GROUP_ORDER.includes(group.stake_species ?? "") ? STAKE_GROUP_ORDER.indexOf(group.stake_species ?? "") : 99) * 10 + (group.felt === void 0 ? 9 : FELT_ORDER.indexOf(group.felt));
|
|
24451
|
+
const groups = [...members.values()].sort((a, b) => rank(a.group) - rank(b.group)).map(({ group, ids }) => {
|
|
24452
|
+
const groupView = deriveWeighing(nodes.filter((node) => node.species !== "stake" || ids.has(node.id)), section, matrixId);
|
|
24453
|
+
if (groupView === void 0) throw new ToolError(`No usable matrix "${matrixId}".`);
|
|
24454
|
+
const { ordered: ordered2, rows: rows2 } = rowsOf5(groupView);
|
|
24455
|
+
return {
|
|
24456
|
+
stake_species: group.stake_species,
|
|
24457
|
+
...group.felt !== void 0 ? { felt: group.felt } : {},
|
|
24458
|
+
totals: totalsOf(groupView),
|
|
24459
|
+
elements: elementRows(groupView),
|
|
24460
|
+
promises: rows2,
|
|
24461
|
+
matching: ordered2.length
|
|
24462
|
+
};
|
|
24463
|
+
});
|
|
24464
|
+
notes.push("Stakes of different kinds are not ranked against each other: each list below is ordered within its own kind, and the masses are per kind. The order of the lists is not a priority.");
|
|
24465
|
+
return {
|
|
24466
|
+
matrix: { id: view.matrix.id, set: view.matrix.set, set_version: view.set.version },
|
|
24467
|
+
positioning,
|
|
24468
|
+
totals: { promises: view.totals.promises, archived: view.totals.archived, assessed: view.totals.assessed },
|
|
24469
|
+
groups,
|
|
24470
|
+
...skipped.length > 0 ? { skipped } : {},
|
|
24471
|
+
...notes.length > 0 ? { notes } : {}
|
|
24472
|
+
};
|
|
24473
|
+
}
|
|
24474
|
+
const { ordered, rows } = rowsOf5(view);
|
|
22840
24475
|
return {
|
|
22841
24476
|
matrix: { id: view.matrix.id, set: view.matrix.set, set_version: view.set.version },
|
|
22842
24477
|
positioning,
|
|
22843
|
-
totals:
|
|
22844
|
-
|
|
22845
|
-
|
|
22846
|
-
assessed: view.totals.assessed,
|
|
22847
|
-
promised: round2(view.totals.promised),
|
|
22848
|
-
kept: round2(view.totals.kept),
|
|
22849
|
-
cost: round2(view.totals.cost),
|
|
22850
|
-
guesswork: { promised: round2(view.totals.guesswork.promised), kept: round2(view.totals.guesswork.kept), cost: round2(view.totals.guesswork.cost) }
|
|
22851
|
-
},
|
|
22852
|
-
elements,
|
|
22853
|
-
promises: ordered.slice(0, limit).map((promise2) => promiseRow(promise2, false)),
|
|
24478
|
+
totals: totalsOf(view),
|
|
24479
|
+
elements: elementRows(view),
|
|
24480
|
+
promises: rows,
|
|
22854
24481
|
matching: ordered.length,
|
|
22855
24482
|
...skipped.length > 0 ? { skipped } : {},
|
|
22856
24483
|
...notes.length > 0 ? { notes } : {}
|
|
@@ -22860,11 +24487,11 @@ function buildWeighingCatalog(ctx) {
|
|
|
22860
24487
|
tool(
|
|
22861
24488
|
{
|
|
22862
24489
|
name: "assess",
|
|
22863
|
-
description: "Record one judgement: a signed level (-3..+3) for one promise on one value element, with how sure you are and why. Read the promise first with get_matrix `subject` so you score against the element's own ladder, not from memory: the level is how far into the person's life it reaches (+1 within the product, +2 across its domain, +3 life-wide). 0 means weighed and unrelated; a negative level is a COST (the promise works against that value) \u2014 score costs you find, authors rarely claim them, and an unclaimed cost is the most valuable thing an audit returns. `confidence`: 0 guess \xB7 1 inferred from the promise's own text \xB7 2 evidenced (cites something outside it) \xB7 3 verified. `evidence` is required above confidence 0: a score without a citation is an opinion. Scored as an AGENT \u2014 a human's level for the same cell keeps winning and yours is recorded beside it, flagged for review when you differ by 2 or more. The tool stamps what you cannot: who you are (and, where it can tell, whose hands you are \u2014 in a repository that is your git author name, read from `ARKAIK_ON_BEHALF_OF`, then `git config arkaik.user`, then `git config user.name`, and written into the committed sidecar; set `arkaik.user` to `-` to record nobody), the set's version and a fingerprint of the promise, so a later edit to its title, Gherkin or values marks your score stale. In a repository it upserts docs/weighing/assessments/<matrix>.json (nothing in the journal); on a hosted project it records weighing.assessment.recorded. The write goes through the same validator-gated gate as the app's form: an unknown element, an out-of-range level or a subject that is not an acceptance refuses with the reason.",
|
|
24490
|
+
description: "Record one judgement: a signed level (-3..+3) for one promise on one value element, with how sure you are and why. Read the promise first with get_matrix `subject` so you score against the element's own ladder, not from memory: the level is how far into the person's life it reaches (+1 within the product, +2 across its domain, +3 life-wide). 0 means weighed and unrelated; a negative level is a COST (the promise works against that value) \u2014 score costs you find, authors rarely claim them, and an unclaimed cost is the most valuable thing an audit returns. `confidence`: 0 guess \xB7 1 inferred from the promise's own text \xB7 2 evidenced (cites something outside it) \xB7 3 verified. `evidence` is required above confidence 0: a score without a citation is an opinion. Scored as an AGENT \u2014 a human's level for the same cell keeps winning and yours is recorded beside it, flagged for review when you differ by 2 or more. The tool stamps what you cannot: who you are (and, where it can tell, whose hands you are \u2014 in a repository that is your git author name, read from `ARKAIK_ON_BEHALF_OF`, then `git config arkaik.user`, then `git config user.name`, and written into the committed sidecar; set `arkaik.user` to `-` to record nobody), the set's version and a fingerprint of the promise, so a later edit to its title, Gherkin or values marks your score stale. In a repository it upserts docs/weighing/assessments/<matrix>.json (nothing in the journal); on a hosted project it records weighing.assessment.recorded. The write goes through the same validator-gated gate as the app's form: an unknown element, an out-of-range level or a subject that is not an acceptance (or a stake of a kind the ruler declares) refuses with the reason. A bug, friction or need stake is weighed here too, on the `stakes` matrix (the default for a stake subject): same elements, same ladder, its own cells. A requirement, risk or defect is refused: it is read against a Kritik criterion, and a Kritik criterion is never written as an assessment.",
|
|
22864
24491
|
inputSchema: {
|
|
22865
24492
|
type: "object",
|
|
22866
24493
|
properties: {
|
|
22867
|
-
subject: { type: "string", description: "An acceptance id." },
|
|
24494
|
+
subject: { type: "string", description: "An acceptance id, or a bug, friction or need stake id." },
|
|
22868
24495
|
criterion: { type: "string", description: "A value element id, e.g. reduces-anxiety." },
|
|
22869
24496
|
level: { type: "integer", minimum: -3, maximum: 3 },
|
|
22870
24497
|
confidence: { type: "integer", enum: [0, 1, 2, 3] },
|
|
@@ -22873,7 +24500,7 @@ function buildWeighingCatalog(ctx) {
|
|
|
22873
24500
|
model: { type: "string", maxLength: 200, description: "The model you are, when you know. At most 200 characters." },
|
|
22874
24501
|
run: { type: "string", maxLength: 200, description: "The audit or session this score belongs to. At most 200 characters." },
|
|
22875
24502
|
commit: { type: "string", maxLength: 200 },
|
|
22876
|
-
matrix: { type: "string", description: `Default: ${VALUE_MATRIX_ID}.` },
|
|
24503
|
+
matrix: { type: "string", description: `Default: ${VALUE_MATRIX_ID}, or ${STAKE_MATRIX_ID} when the subject is a stake.` },
|
|
22877
24504
|
p_serves: { type: "number", minimum: 0, maximum: 1, description: "Only from a probabilistic scorer: how sure it is (0 to 1) that the promise serves this element. Certainty, not size." },
|
|
22878
24505
|
p_costs: { type: "number", minimum: 0, maximum: 1, description: "The same for costs, asked independently. A level its scorer was unsure of reads as a range." }
|
|
22879
24506
|
},
|
|
@@ -22887,7 +24514,7 @@ function buildWeighingCatalog(ctx) {
|
|
|
22887
24514
|
const level = args.level;
|
|
22888
24515
|
if (typeof level !== "number" || !Number.isInteger(level)) throw new ToolError("`level` is required and must be an integer (the scale is -3 to +3).");
|
|
22889
24516
|
const confidence = requireInt2(args, "confidence", 0, 3);
|
|
22890
|
-
const evidence =
|
|
24517
|
+
const evidence = optionalString2(args, "evidence");
|
|
22891
24518
|
if (confidence > 0 && (evidence === void 0 || evidence.trim() === "")) {
|
|
22892
24519
|
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.");
|
|
22893
24520
|
}
|
|
@@ -22898,12 +24525,12 @@ function buildWeighingCatalog(ctx) {
|
|
|
22898
24525
|
criterion,
|
|
22899
24526
|
level,
|
|
22900
24527
|
confidence,
|
|
22901
|
-
...
|
|
24528
|
+
...optionalString2(args, "matrix") !== void 0 ? { matrix: optionalString2(args, "matrix") } : {},
|
|
22902
24529
|
...evidence !== void 0 ? { evidence } : {},
|
|
22903
24530
|
...refs !== void 0 && refs.length > 0 ? { refs } : {},
|
|
22904
|
-
...
|
|
22905
|
-
...
|
|
22906
|
-
...
|
|
24531
|
+
...optionalString2(args, "model") !== void 0 ? { model: optionalString2(args, "model") } : {},
|
|
24532
|
+
...optionalString2(args, "run") !== void 0 ? { run: optionalString2(args, "run") } : {},
|
|
24533
|
+
...optionalString2(args, "commit") !== void 0 ? { commit: optionalString2(args, "commit") } : {},
|
|
22907
24534
|
// Passed as given: a value off 0..1 is the planner's to refuse, with the reason.
|
|
22908
24535
|
...args.p_serves !== void 0 ? { p_serves: args.p_serves } : {},
|
|
22909
24536
|
...args.p_costs !== void 0 ? { p_costs: args.p_costs } : {}
|
|
@@ -22911,11 +24538,11 @@ function buildWeighingCatalog(ctx) {
|
|
|
22911
24538
|
const graph = await load2();
|
|
22912
24539
|
const section = sectionOf(graph);
|
|
22913
24540
|
const nodes = graph.nodes;
|
|
22914
|
-
const matrixId = input.matrix ??
|
|
24541
|
+
const matrixId = input.matrix ?? defaultMatrixFor(nodes, subject);
|
|
22915
24542
|
const view = buildWeighingContext(section, matrixId);
|
|
22916
24543
|
if (view === void 0) {
|
|
22917
24544
|
const matrix = resolveWeighing(section).matrices.find((candidate) => candidate.id === matrixId);
|
|
22918
|
-
if (matrix === void 0) throw new ToolError(`No matrix "${matrixId}". The built-in
|
|
24545
|
+
if (matrix === void 0) throw new ToolError(`No matrix "${matrixId}". The built-in ones are "${VALUE_MATRIX_ID}" and "${STAKE_MATRIX_ID}".`);
|
|
22919
24546
|
if (!isActiveWeighingSet(matrix)) throw new ToolError("This matrix is a draft and feeds no roll-up; activate it first.");
|
|
22920
24547
|
throw new ToolError(`Matrix "${matrixId}" names the set "${matrix.set}", which is not available.`);
|
|
22921
24548
|
}
|
|
@@ -22982,7 +24609,7 @@ function buildWeighingCatalog(ctx) {
|
|
|
22982
24609
|
},
|
|
22983
24610
|
async (args) => {
|
|
22984
24611
|
if (!Array.isArray(args.elements) || args.elements.length === 0) throw new ToolError("`elements` is required: at least one element of value.");
|
|
22985
|
-
const status =
|
|
24612
|
+
const status = optionalString2(args, "status") ?? "draft";
|
|
22986
24613
|
if (status !== "draft" && status !== "active") throw new ToolError("`status` must be draft or active.");
|
|
22987
24614
|
const graph = await load2();
|
|
22988
24615
|
const section = sectionOf(graph);
|
|
@@ -22991,7 +24618,7 @@ function buildWeighingCatalog(ctx) {
|
|
|
22991
24618
|
const set2 = {
|
|
22992
24619
|
id: POSITIONING_SET_ID,
|
|
22993
24620
|
version: "1.0.0",
|
|
22994
|
-
title:
|
|
24621
|
+
title: optionalString2(args, "title") ?? "Positioning",
|
|
22995
24622
|
subject: ruler.subject,
|
|
22996
24623
|
scale: weighingScaleOf(ruler),
|
|
22997
24624
|
role: "positioning",
|
|
@@ -23063,6 +24690,18 @@ function findNode(nodes, nodeId) {
|
|
|
23063
24690
|
}
|
|
23064
24691
|
function nodeSummary(node) {
|
|
23065
24692
|
const base = { id: node.id, title: node.title, species: node.species, status: node.status, platforms: node.platforms };
|
|
24693
|
+
if (node.species === "stake") {
|
|
24694
|
+
const md = node.metadata;
|
|
24695
|
+
return {
|
|
24696
|
+
...base,
|
|
24697
|
+
stake_species: md?.stake_species ?? null,
|
|
24698
|
+
provenance: md?.provenance ?? "observed",
|
|
24699
|
+
// The user-facing kinds only carry these (a requirement, risk or defect is read against a Kritik criterion).
|
|
24700
|
+
...md?.felt !== void 0 ? { felt: md.felt } : {},
|
|
24701
|
+
...md?.matters !== void 0 ? { matters: md.matters } : {},
|
|
24702
|
+
...md?.frequency !== void 0 ? { frequency: md.frequency } : {}
|
|
24703
|
+
};
|
|
24704
|
+
}
|
|
23066
24705
|
if (node.species !== "acceptance") return base;
|
|
23067
24706
|
const platform_statuses = Object.fromEntries(
|
|
23068
24707
|
node.platforms.map((platform) => [platform, resolvePlatformStatus(node, platform)])
|
|
@@ -23217,7 +24856,7 @@ ${node.description ?? ""}`.toLowerCase();
|
|
|
23217
24856
|
node,
|
|
23218
24857
|
edges: relatedEdges,
|
|
23219
24858
|
whereUsedFlows,
|
|
23220
|
-
timeline: computeNodeTimeline(journal, nodeId),
|
|
24859
|
+
timeline: computeNodeTimeline(journal, nodeId, { evidenceEventIds: stakeEvidenceEventIds([node]) }),
|
|
23221
24860
|
...covered_by !== void 0 ? { covered_by } : {}
|
|
23222
24861
|
};
|
|
23223
24862
|
}
|
|
@@ -23249,7 +24888,10 @@ ${node.description ?? ""}`.toLowerCase();
|
|
|
23249
24888
|
},
|
|
23250
24889
|
async () => {
|
|
23251
24890
|
const { nodes, journal } = await load(ctx);
|
|
23252
|
-
return computeBacklog(journal, {
|
|
24891
|
+
return computeBacklog(journal, {
|
|
24892
|
+
existingNodeIds: new Set(nodes.map((node) => node.id)),
|
|
24893
|
+
evidencedEventIds: stakeEvidenceEventIds(nodes)
|
|
24894
|
+
});
|
|
23253
24895
|
}
|
|
23254
24896
|
);
|
|
23255
24897
|
tool(
|
|
@@ -23308,7 +24950,7 @@ ${node.description ?? ""}`.toLowerCase();
|
|
|
23308
24950
|
tool(
|
|
23309
24951
|
{
|
|
23310
24952
|
name: "create_node",
|
|
23311
|
-
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.",
|
|
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 or a stake 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.",
|
|
23312
24954
|
inputSchema: {
|
|
23313
24955
|
type: "object",
|
|
23314
24956
|
properties: {
|
|
@@ -23352,7 +24994,7 @@ ${node.description ?? ""}`.toLowerCase();
|
|
|
23352
24994
|
tool(
|
|
23353
24995
|
{
|
|
23354
24996
|
name: "update_node",
|
|
23355
|
-
description: "Patch a node's title, description, status, platforms, or metadata. Journal events derive from the diff; refused if validation fails. When a flow's metadata.playlist gains a view/sub-flow, the matching composes edge is synthesized in the same mutation.",
|
|
24997
|
+
description: "Patch a node's title, description, status, platforms, or metadata. Journal events derive from the diff; refused if validation fails. When a flow's metadata.playlist gains a view/sub-flow, the matching composes edge is synthesized in the same mutation. A patched `metadata` REPLACES the node's metadata whole \u2014 send every key you keep \u2014 except on a stake, where it is MERGED key by key (a key set to null is cleared) and the stake rules apply: a bug is felt as expected, and a requirement, risk or defect carries no felt, matters or frequency. So `{metadata:{felt:\"wanted\"}}` on a need sets only that field.",
|
|
23356
24998
|
inputSchema: {
|
|
23357
24999
|
type: "object",
|
|
23358
25000
|
properties: {
|
|
@@ -23387,6 +25029,17 @@ ${node.description ?? ""}`.toLowerCase();
|
|
|
23387
25029
|
if (typeof patch.status === "string") patch.status = normalizeStatusArg(patch.status);
|
|
23388
25030
|
const graph = await load(ctx);
|
|
23389
25031
|
const current = findNode(graph.nodes, nodeId);
|
|
25032
|
+
if (current.species === "stake" && patch.metadata !== void 0) {
|
|
25033
|
+
if (typeof patch.metadata !== "object" || patch.metadata === null || Array.isArray(patch.metadata)) {
|
|
25034
|
+
throw new ToolError("`patch.metadata` must be an object.");
|
|
25035
|
+
}
|
|
25036
|
+
const merged = { ...current.metadata ?? {} };
|
|
25037
|
+
for (const [key, value] of Object.entries(patch.metadata)) {
|
|
25038
|
+
if (value === null) delete merged[key];
|
|
25039
|
+
else merged[key] = value;
|
|
25040
|
+
}
|
|
25041
|
+
patch.metadata = stakeMetadataWith(merged, {});
|
|
25042
|
+
}
|
|
23390
25043
|
const ops = [{ op: "update_node", node_id: nodeId, patch }];
|
|
23391
25044
|
const outcome = mutate(graph, ops);
|
|
23392
25045
|
if (outcome.eventInputs.length === 0) {
|
|
@@ -23570,7 +25223,29 @@ ${node.description ?? ""}`.toLowerCase();
|
|
|
23570
25223
|
const payload = { title };
|
|
23571
25224
|
if (typeof args.description === "string") payload.description = args.description;
|
|
23572
25225
|
if (typeof args.node_id === "string") payload.node_id = args.node_id;
|
|
23573
|
-
if (type === "request.filed"
|
|
25226
|
+
if (type === "request.filed") {
|
|
25227
|
+
for (const key of ["source", "verbatim", "finding_id", "criterion_id", "url"]) {
|
|
25228
|
+
if (typeof args[key] === "string") payload[key] = args[key];
|
|
25229
|
+
}
|
|
25230
|
+
if (args.source_kind !== void 0) {
|
|
25231
|
+
if (!SIGNAL_SOURCE_KINDS.includes(args.source_kind)) {
|
|
25232
|
+
throw new ToolError(`source_kind must be one of: ${SIGNAL_SOURCE_KINDS.join(", ")}.`);
|
|
25233
|
+
}
|
|
25234
|
+
payload.source_kind = args.source_kind;
|
|
25235
|
+
}
|
|
25236
|
+
if (args.provenance !== void 0) {
|
|
25237
|
+
if (!STAKE_PROVENANCE_IDS.includes(args.provenance)) {
|
|
25238
|
+
throw new ToolError(`provenance must be one of: ${STAKE_PROVENANCE_IDS.join(", ")}.`);
|
|
25239
|
+
}
|
|
25240
|
+
payload.provenance = args.provenance;
|
|
25241
|
+
}
|
|
25242
|
+
if (args.stake_ids !== void 0) {
|
|
25243
|
+
if (!Array.isArray(args.stake_ids) || args.stake_ids.some((id) => typeof id !== "string" || id === "")) {
|
|
25244
|
+
throw new ToolError("stake_ids must be an array of stake node ids.");
|
|
25245
|
+
}
|
|
25246
|
+
payload.stake_ids = args.stake_ids;
|
|
25247
|
+
}
|
|
25248
|
+
}
|
|
23574
25249
|
const input = { type, payload };
|
|
23575
25250
|
const result = await ctx.store.persist(graph, {}, [input]);
|
|
23576
25251
|
const { warnings, events } = unwrap(result);
|
|
@@ -23596,14 +25271,21 @@ ${node.description ?? ""}`.toLowerCase();
|
|
|
23596
25271
|
tool(
|
|
23597
25272
|
{
|
|
23598
25273
|
name: "file_request",
|
|
23599
|
-
description: "Record
|
|
25274
|
+
description: "Record a signal in the journal backlog (request.filed): feedback, a ticket, an interview line, a form answer, an audit finding, an idea or a benchmark. Only title is required. source is the source's free name; source_kind says what sort it is; verbatim is the input exactly as voiced, never edited; provenance is observed (default) or anticipated; stake_ids names stakes already known; an audit-finding carries finding_id and criterion_id (never an F-\u2026 id in node_id or stake_ids). A signal is closed once a stake cites it as evidence.",
|
|
23600
25275
|
inputSchema: {
|
|
23601
25276
|
type: "object",
|
|
23602
25277
|
properties: {
|
|
23603
25278
|
title: { type: "string" },
|
|
23604
25279
|
description: { type: "string" },
|
|
23605
|
-
source: { type: "string" },
|
|
23606
|
-
node_id: { type: "string" }
|
|
25280
|
+
source: { type: "string", description: `The source's own name, free text ("beta-feedback"). Not an enum.` },
|
|
25281
|
+
node_id: { type: "string" },
|
|
25282
|
+
source_kind: { type: "string", enum: [...SIGNAL_SOURCE_KINDS] },
|
|
25283
|
+
verbatim: { type: "string", description: "The input exactly as voiced." },
|
|
25284
|
+
provenance: { type: "string", enum: [...STAKE_PROVENANCE_IDS] },
|
|
25285
|
+
stake_ids: { type: "array", items: { type: "string" }, description: "Stakes known at filing time." },
|
|
25286
|
+
finding_id: { type: "string", description: "source_kind audit-finding: the Kritik finding id." },
|
|
25287
|
+
criterion_id: { type: "string", description: "source_kind audit-finding: the criterion id." },
|
|
25288
|
+
url: { type: "string" }
|
|
23607
25289
|
},
|
|
23608
25290
|
required: ["title"],
|
|
23609
25291
|
additionalProperties: false
|
|
@@ -23617,6 +25299,9 @@ ${node.description ?? ""}`.toLowerCase();
|
|
|
23617
25299
|
const weighing = buildWeighingCatalog(ctx);
|
|
23618
25300
|
tools2.push(...weighing.tools);
|
|
23619
25301
|
Object.assign(handlers2, weighing.handlers);
|
|
25302
|
+
const qualify = buildQualifyCatalog(ctx, { load: () => load(ctx), mutate, unwrap });
|
|
25303
|
+
tools2.push(...qualify.tools);
|
|
25304
|
+
Object.assign(handlers2, qualify.handlers);
|
|
23620
25305
|
return { tools: tools2, handlers: handlers2 };
|
|
23621
25306
|
}
|
|
23622
25307
|
|
|
@@ -23858,7 +25543,7 @@ function resolveRemoteConfig(argv2, env, cwd) {
|
|
|
23858
25543
|
}
|
|
23859
25544
|
|
|
23860
25545
|
// src/index.ts
|
|
23861
|
-
var VERSION = "0.
|
|
25546
|
+
var VERSION = "0.13.0";
|
|
23862
25547
|
var argv = process.argv.slice(2);
|
|
23863
25548
|
if (argv.includes("--help") || argv.includes("-h")) {
|
|
23864
25549
|
process.stdout.write(
|