arkaik-mcp 0.12.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/kritik/library.json +88 -0
- package/dist/index.js +2286 -200
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -14635,7 +14635,7 @@ function date4(params) {
|
|
|
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", "option"];
|
|
14639
14639
|
var STATUS_IDS = [
|
|
14640
14640
|
"idea",
|
|
14641
14641
|
"discovery",
|
|
@@ -14646,7 +14646,7 @@ var STATUS_IDS = [
|
|
|
14646
14646
|
"archived"
|
|
14647
14647
|
];
|
|
14648
14648
|
var PLATFORM_IDS = ["web", "ios", "android"];
|
|
14649
|
-
var EDGE_TYPE_IDS = ["composes", "calls", "displays", "queries", "covers", "supersedes", "generates", "impacts"];
|
|
14649
|
+
var EDGE_TYPE_IDS = ["composes", "calls", "displays", "queries", "covers", "supersedes", "generates", "impacts", "concerns", "addresses"];
|
|
14650
14650
|
var VALID_EDGE_SEMANTICS = {
|
|
14651
14651
|
composes: [
|
|
14652
14652
|
["flow", "view"],
|
|
@@ -14674,17 +14674,42 @@ var VALID_EDGE_SEMANTICS = {
|
|
|
14674
14674
|
["acceptance", "view"],
|
|
14675
14675
|
["acceptance", "flow"]
|
|
14676
14676
|
],
|
|
14677
|
-
// Decision edges (cycle 2
|
|
14678
|
-
//
|
|
14679
|
-
//
|
|
14680
|
-
//
|
|
14677
|
+
// Decision edges (cycle 2, widened in the stake architecture's part A).
|
|
14678
|
+
// `generates` and `impacts` stay disjoint by pair: no pair is admitted by
|
|
14679
|
+
// both. What a decision edge means now depends on its target species, not
|
|
14680
|
+
// on the edge type alone. `generates` reaches an acceptance or an option (a
|
|
14681
|
+
// decision's output); `impacts` reaches anatomy or a stake (what it acts
|
|
14682
|
+
// on). An acceptance is still *generated*, never merely impacted
|
|
14683
|
+
// (docs/superpowers/specs/2026-08-03-decisions-species-design.md §3,
|
|
14684
|
+
// docs/rfcs/stake-architecture.md § 14.0 call 2).
|
|
14681
14685
|
supersedes: [["decision", "decision"]],
|
|
14682
|
-
generates: [
|
|
14686
|
+
generates: [
|
|
14687
|
+
["decision", "acceptance"],
|
|
14688
|
+
["decision", "option"]
|
|
14689
|
+
],
|
|
14683
14690
|
impacts: [
|
|
14684
14691
|
["decision", "flow"],
|
|
14685
14692
|
["decision", "view"],
|
|
14686
14693
|
["decision", "data-model"],
|
|
14687
|
-
["decision", "api-endpoint"]
|
|
14694
|
+
["decision", "api-endpoint"],
|
|
14695
|
+
["decision", "stake"]
|
|
14696
|
+
],
|
|
14697
|
+
// Stake edge (docs/rfcs/stake-architecture.md § 4). A stake is anchored to
|
|
14698
|
+
// the product's anatomy only, never to an acceptance or a decision, and
|
|
14699
|
+
// `impacts` stays decision-only.
|
|
14700
|
+
concerns: [
|
|
14701
|
+
["stake", "flow"],
|
|
14702
|
+
["stake", "view"],
|
|
14703
|
+
["stake", "data-model"],
|
|
14704
|
+
["stake", "api-endpoint"]
|
|
14705
|
+
],
|
|
14706
|
+
// Option edge (docs/rfcs/stake-architecture.md § 14.0). An option addresses a
|
|
14707
|
+
// stake; an acceptance addresses the stake it settles, or the option it
|
|
14708
|
+
// carries out.
|
|
14709
|
+
addresses: [
|
|
14710
|
+
["option", "stake"],
|
|
14711
|
+
["acceptance", "stake"],
|
|
14712
|
+
["acceptance", "option"]
|
|
14688
14713
|
]
|
|
14689
14714
|
};
|
|
14690
14715
|
var VALUE_TIER_IDS = ["functional", "emotional", "life-changing", "social-impact"];
|
|
@@ -14857,10 +14882,110 @@ function decisionStatusOf(node) {
|
|
|
14857
14882
|
return DECISION_STATUS_IDS.includes(raw) ? raw : "proposed";
|
|
14858
14883
|
}
|
|
14859
14884
|
|
|
14885
|
+
// ../schema/src/stake.ts
|
|
14886
|
+
var STAKE_SPECIES_IDS = ["bug", "friction", "need", "requirement", "risk", "defect"];
|
|
14887
|
+
var STAKE_PROVENANCE_IDS = ["observed", "anticipated"];
|
|
14888
|
+
var STAKE_LIFECYCLE_STATUSES = ["idea", "discovery", "archived"];
|
|
14889
|
+
var ANTICIPATED_STAKE_SPECIES = ["need", "requirement", "risk", "defect"];
|
|
14890
|
+
var USER_FACING_STAKE_SPECIES = ["bug", "friction", "need"];
|
|
14891
|
+
var QUALITY_STAKE_SPECIES = ["requirement", "risk", "defect"];
|
|
14892
|
+
var STAKE_ANCHOR_SPECIES = VALID_EDGE_SEMANTICS.concerns.map(([, target]) => target);
|
|
14893
|
+
var STAKE_CATALOG_SOURCES = ["kritik", "values"];
|
|
14894
|
+
var STAKE_FELT_IDS = ["expected", "wanted", "delight"];
|
|
14895
|
+
var STAKE_MATTERS_LEVELS = [1, 2, 3, 4];
|
|
14896
|
+
var STAKE_FREQUENCY_IDS = ["rare", "some", "often"];
|
|
14897
|
+
var STAKE_EVIDENCE_VOICES = ["person", "maintainer", "agent"];
|
|
14898
|
+
function catalogSourceForStakeSpecies(species) {
|
|
14899
|
+
return QUALITY_STAKE_SPECIES.includes(species) ? "kritik" : "values";
|
|
14900
|
+
}
|
|
14901
|
+
function isUserFacingStakeSpecies(species) {
|
|
14902
|
+
return USER_FACING_STAKE_SPECIES.includes(species);
|
|
14903
|
+
}
|
|
14904
|
+
function stakeSpeciesOf(node) {
|
|
14905
|
+
const raw = node.metadata?.stake_species;
|
|
14906
|
+
return STAKE_SPECIES_IDS.includes(raw) ? raw : void 0;
|
|
14907
|
+
}
|
|
14908
|
+
function stakeProvenanceOf(node) {
|
|
14909
|
+
const raw = node.metadata?.provenance;
|
|
14910
|
+
return STAKE_PROVENANCE_IDS.includes(raw) ? raw : "observed";
|
|
14911
|
+
}
|
|
14912
|
+
function stakeCatalogOf(node) {
|
|
14913
|
+
const raw = node.metadata?.catalog;
|
|
14914
|
+
if (!raw || typeof raw !== "object") return void 0;
|
|
14915
|
+
const { source, id } = raw;
|
|
14916
|
+
if (!STAKE_CATALOG_SOURCES.includes(source)) return void 0;
|
|
14917
|
+
if (typeof id !== "string" || id === "") return void 0;
|
|
14918
|
+
return { source, id };
|
|
14919
|
+
}
|
|
14920
|
+
function stakeFeltOf(node) {
|
|
14921
|
+
const raw = node.metadata?.felt;
|
|
14922
|
+
return STAKE_FELT_IDS.includes(raw) ? raw : void 0;
|
|
14923
|
+
}
|
|
14924
|
+
function stakeMattersOf(node) {
|
|
14925
|
+
const raw = node.metadata?.matters;
|
|
14926
|
+
return STAKE_MATTERS_LEVELS.includes(raw) ? raw : void 0;
|
|
14927
|
+
}
|
|
14928
|
+
function stakeFrequencyOf(node) {
|
|
14929
|
+
const raw = node.metadata?.frequency;
|
|
14930
|
+
return STAKE_FREQUENCY_IDS.includes(raw) ? raw : void 0;
|
|
14931
|
+
}
|
|
14932
|
+
function stakeReverifyDaysOf(node) {
|
|
14933
|
+
const raw = node.metadata?.reverify_every_days;
|
|
14934
|
+
return typeof raw === "number" && Number.isFinite(raw) && raw > 0 ? raw : void 0;
|
|
14935
|
+
}
|
|
14936
|
+
function stakeVerifiedCriterionVersionOf(node) {
|
|
14937
|
+
const raw = node.metadata?.verified_criterion_version;
|
|
14938
|
+
return typeof raw === "number" && Number.isInteger(raw) && raw >= 1 ? raw : void 0;
|
|
14939
|
+
}
|
|
14940
|
+
function stakeMetadataWith(metadata, change) {
|
|
14941
|
+
const next = { ...metadata ?? {} };
|
|
14942
|
+
const catalogBefore = stakeCatalogOf({ metadata: next });
|
|
14943
|
+
for (const key of ["stake_species", "provenance", "catalog", "felt", "matters", "frequency", "reverify_every_days", "verified_criterion_version"]) {
|
|
14944
|
+
if (!(key in change)) continue;
|
|
14945
|
+
const value = change[key];
|
|
14946
|
+
if (value === void 0) delete next[key];
|
|
14947
|
+
else next[key] = value;
|
|
14948
|
+
}
|
|
14949
|
+
if (next.provenance === "observed") delete next.provenance;
|
|
14950
|
+
const species = stakeSpeciesOf({ metadata: next });
|
|
14951
|
+
const catalog = stakeCatalogOf({ metadata: next });
|
|
14952
|
+
if (species !== void 0 && catalog !== void 0 && catalog.source !== catalogSourceForStakeSpecies(species)) {
|
|
14953
|
+
delete next.catalog;
|
|
14954
|
+
}
|
|
14955
|
+
const fittingCatalog = stakeCatalogOf({ metadata: next });
|
|
14956
|
+
const linkMoved = catalogBefore?.source !== fittingCatalog?.source || catalogBefore?.id !== fittingCatalog?.id;
|
|
14957
|
+
if (species === void 0 || isUserFacingStakeSpecies(species) || fittingCatalog === void 0 || fittingCatalog.source !== "kritik" || linkMoved && !("verified_criterion_version" in change)) {
|
|
14958
|
+
delete next.verified_criterion_version;
|
|
14959
|
+
}
|
|
14960
|
+
if (species !== void 0 && !isUserFacingStakeSpecies(species)) {
|
|
14961
|
+
delete next.felt;
|
|
14962
|
+
delete next.matters;
|
|
14963
|
+
delete next.frequency;
|
|
14964
|
+
} else if (species === "bug") {
|
|
14965
|
+
next.felt = "expected";
|
|
14966
|
+
}
|
|
14967
|
+
return next;
|
|
14968
|
+
}
|
|
14969
|
+
function stakeEvidenceOf(node) {
|
|
14970
|
+
const raw = node.metadata?.evidence;
|
|
14971
|
+
if (!Array.isArray(raw)) return [];
|
|
14972
|
+
return raw.filter((entry) => typeof entry === "object" && entry !== null && !Array.isArray(entry));
|
|
14973
|
+
}
|
|
14974
|
+
function stakeEvidenceEventIds(nodes) {
|
|
14975
|
+
const ids = /* @__PURE__ */ new Set();
|
|
14976
|
+
for (const node of nodes) {
|
|
14977
|
+
if (node.species !== "stake") continue;
|
|
14978
|
+
for (const entry of stakeEvidenceOf(node)) {
|
|
14979
|
+
if (typeof entry.event_id === "string" && entry.event_id !== "") ids.add(entry.event_id);
|
|
14980
|
+
}
|
|
14981
|
+
}
|
|
14982
|
+
return ids;
|
|
14983
|
+
}
|
|
14984
|
+
|
|
14860
14985
|
// ../schema/src/enums.ts
|
|
14861
14986
|
var SpeciesSchema = external_exports.enum(SPECIES_IDS).meta({
|
|
14862
14987
|
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."
|
|
14988
|
+
description: "The species of a node. flow = ordered sequence of views/sub-flows. view = reusable page or screen. data-model = data entity/table. api-endpoint = API endpoint. acceptance = a testable promise (one Given/When/Then) with per-platform status. decision = an ADR-style record (context, consequences, supersession). stake = something that matters about the product (a bug, friction, need, requirement, risk or defect), anchored to the anatomy by concerns edges. option = one way to address a stake, never without a stake, weighed against the other options for it."
|
|
14864
14989
|
});
|
|
14865
14990
|
var StatusSchema = external_exports.enum(STATUS_IDS).meta({
|
|
14866
14991
|
id: "Status",
|
|
@@ -14876,7 +15001,7 @@ var PlatformSchema = external_exports.enum(PLATFORM_IDS).meta({
|
|
|
14876
15001
|
});
|
|
14877
15002
|
var EdgeTypeSchema = external_exports.enum(EDGE_TYPE_IDS).meta({
|
|
14878
15003
|
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)."
|
|
15004
|
+
description: "composes = structural hierarchy (flow\u2194view). calls = view/flow \u2192 api-endpoint, or api-endpoint \u2192 api-endpoint (endpoint fan-out to internal/external APIs). displays = view \u2192 data-model. queries = api-endpoint \u2192 data-model. covers = acceptance \u2192 view/flow (which surface the acceptance is proven on). supersedes = decision \u2192 decision. generates = decision \u2192 acceptance or option (what the decision produced). impacts = decision \u2192 flow/view/data-model/api-endpoint or stake (what the decision acts on). concerns = stake \u2192 flow/view/data-model/api-endpoint (the part of the anatomy the stake is about). addresses = option \u2192 stake, acceptance \u2192 stake or acceptance \u2192 option (what answers a stake)."
|
|
14880
15005
|
});
|
|
14881
15006
|
var ValueTierSchema = external_exports.enum(VALUE_TIER_IDS).meta({
|
|
14882
15007
|
id: "ValueTier",
|
|
@@ -14890,6 +15015,34 @@ var DecisionStatusSchema = external_exports.enum(DECISION_STATUS_IDS).meta({
|
|
|
14890
15015
|
id: "DecisionStatus",
|
|
14891
15016
|
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
15017
|
});
|
|
15018
|
+
var StakeSpeciesSchema = external_exports.enum(STAKE_SPECIES_IDS).meta({
|
|
15019
|
+
id: "StakeSpecies",
|
|
15020
|
+
description: "Stake nodes only: bug | friction | need (user-facing, weighed on the value pyramid) or requirement | risk | defect (quality, read against Kritik criteria)."
|
|
15021
|
+
});
|
|
15022
|
+
var StakeProvenanceSchema = external_exports.enum(STAKE_PROVENANCE_IDS).meta({
|
|
15023
|
+
id: "StakeProvenance",
|
|
15024
|
+
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)."
|
|
15025
|
+
});
|
|
15026
|
+
var StakeCatalogSourceSchema = external_exports.enum(STAKE_CATALOG_SOURCES).meta({
|
|
15027
|
+
id: "StakeCatalogSource",
|
|
15028
|
+
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)."
|
|
15029
|
+
});
|
|
15030
|
+
var StakeEvidenceVoiceSchema = external_exports.enum(STAKE_EVIDENCE_VOICES).meta({
|
|
15031
|
+
id: "StakeEvidenceVoice",
|
|
15032
|
+
description: "Who voiced a piece of stake evidence: person (the one the signal came from), maintainer, or agent."
|
|
15033
|
+
});
|
|
15034
|
+
var StakeFeltSchema = external_exports.enum(STAKE_FELT_IDS).meta({
|
|
15035
|
+
id: "StakeFelt",
|
|
15036
|
+
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)."
|
|
15037
|
+
});
|
|
15038
|
+
var StakeMattersSchema = external_exports.union([external_exports.literal(1), external_exports.literal(2), external_exports.literal(3), external_exports.literal(4)]).meta({
|
|
15039
|
+
id: "StakeMatters",
|
|
15040
|
+
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."
|
|
15041
|
+
});
|
|
15042
|
+
var StakeFrequencySchema = external_exports.enum(STAKE_FREQUENCY_IDS).meta({
|
|
15043
|
+
id: "StakeFrequency",
|
|
15044
|
+
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."
|
|
15045
|
+
});
|
|
14893
15046
|
|
|
14894
15047
|
// ../schema/src/id-gen.ts
|
|
14895
15048
|
var SPECIES_PREFIXES = {
|
|
@@ -14898,7 +15051,9 @@ var SPECIES_PREFIXES = {
|
|
|
14898
15051
|
"data-model": "DM-",
|
|
14899
15052
|
"api-endpoint": "API-",
|
|
14900
15053
|
acceptance: "AC-",
|
|
14901
|
-
decision: "DEC-"
|
|
15054
|
+
decision: "DEC-",
|
|
15055
|
+
stake: "STK-",
|
|
15056
|
+
option: "OPT-"
|
|
14902
15057
|
};
|
|
14903
15058
|
function kebabCase(input) {
|
|
14904
15059
|
return input.normalize("NFKD").replace(/[\u0300-\u036f]/g, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
@@ -15046,6 +15201,14 @@ function reduceScreenshotSlots(ordered) {
|
|
|
15046
15201
|
}
|
|
15047
15202
|
|
|
15048
15203
|
// ../schema/src/journal.ts
|
|
15204
|
+
var SIGNAL_SOURCE_KINDS = ["ticket", "interview", "form", "feedback", "audit-finding", "idea", "benchmark", "other"];
|
|
15205
|
+
function signalSourceKindOf(event) {
|
|
15206
|
+
return SIGNAL_SOURCE_KINDS.includes(event.source_kind) ? event.source_kind : void 0;
|
|
15207
|
+
}
|
|
15208
|
+
function signalStakeIds(event) {
|
|
15209
|
+
const raw = event.stake_ids;
|
|
15210
|
+
return Array.isArray(raw) ? raw.filter((id) => typeof id === "string" && id !== "") : [];
|
|
15211
|
+
}
|
|
15049
15212
|
var SCREENSHOT_SOURCES = ["ci", "manual"];
|
|
15050
15213
|
var SCREENSHOT_FORMS = ["url", "path", "data"];
|
|
15051
15214
|
function orderEvents(events) {
|
|
@@ -15234,6 +15397,22 @@ function crossCheckJournal(bundle) {
|
|
|
15234
15397
|
}
|
|
15235
15398
|
}
|
|
15236
15399
|
}
|
|
15400
|
+
const eventIds = /* @__PURE__ */ new Set();
|
|
15401
|
+
for (const { ev } of valid) eventIds.add(ev.id);
|
|
15402
|
+
nodesRaw.forEach((n, index) => {
|
|
15403
|
+
if (n?.species !== "option") return;
|
|
15404
|
+
const metadata = n.metadata;
|
|
15405
|
+
if (!metadata || typeof metadata !== "object" || Array.isArray(metadata)) return;
|
|
15406
|
+
const ref = str(metadata.suggested_by);
|
|
15407
|
+
if (ref !== void 0 && ref !== "" && !eventIds.has(ref)) {
|
|
15408
|
+
findings.push({
|
|
15409
|
+
path: `nodes[${index}].metadata.suggested_by`,
|
|
15410
|
+
rule: "option-suggested-by-dangling",
|
|
15411
|
+
message: `Option "${String(n.id)}": suggested_by names journal event "${ref}", which is not in the journal.`,
|
|
15412
|
+
severity: "warning"
|
|
15413
|
+
});
|
|
15414
|
+
}
|
|
15415
|
+
});
|
|
15237
15416
|
for (const { ev, index } of valid) {
|
|
15238
15417
|
const nodeFields = NODE_REF_FIELDS[ev.type];
|
|
15239
15418
|
if (nodeFields) {
|
|
@@ -15262,6 +15441,19 @@ function crossCheckJournal(bundle) {
|
|
|
15262
15441
|
}
|
|
15263
15442
|
});
|
|
15264
15443
|
}
|
|
15444
|
+
if (ev.type === "request.filed" && Array.isArray(ev.stake_ids)) {
|
|
15445
|
+
ev.stake_ids.forEach((raw, i) => {
|
|
15446
|
+
const ref = str(raw);
|
|
15447
|
+
if (ref !== void 0 && !everNodes.has(ref)) {
|
|
15448
|
+
findings.push({
|
|
15449
|
+
path: `journal[${index}].stake_ids[${i}]`,
|
|
15450
|
+
rule: "journal-dangling-stake-ref",
|
|
15451
|
+
message: `journal[${index}] (${ev.type}): names stake "${ref}" that never existed in the snapshot or journal.`,
|
|
15452
|
+
severity: "warning"
|
|
15453
|
+
});
|
|
15454
|
+
}
|
|
15455
|
+
});
|
|
15456
|
+
}
|
|
15265
15457
|
if (ev.type === "edge.removed") {
|
|
15266
15458
|
const ref = str(ev.edge_id);
|
|
15267
15459
|
if (ref !== void 0 && !everEdges.has(ref)) {
|
|
@@ -15394,6 +15586,7 @@ var WeighingCriteriaSetSchema = external_exports.object({
|
|
|
15394
15586
|
version: leaf("Semver. Levels are comparable only within a major."),
|
|
15395
15587
|
title: leaf("A human title."),
|
|
15396
15588
|
subject: leaf("What the set judges: acceptance today."),
|
|
15589
|
+
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
15590
|
scale: documented(WeighingScaleSchema).optional().meta({ description: "The scale. A positioning may leave it out and use its ruler's." }),
|
|
15398
15591
|
groups: documented(external_exports.array(documented(WeighingGroupSchema))).optional(),
|
|
15399
15592
|
criteria: documented(external_exports.array(documented(WeighingCriterionSchema))).optional(),
|
|
@@ -15526,8 +15719,17 @@ var RequestFiledEventSchema = external_exports.object({
|
|
|
15526
15719
|
type: external_exports.literal("request.filed"),
|
|
15527
15720
|
title: external_exports.string(),
|
|
15528
15721
|
description: external_exports.string().optional(),
|
|
15529
|
-
source: external_exports.string().optional(),
|
|
15530
|
-
node_id: external_exports.string().optional()
|
|
15722
|
+
source: external_exports.string().optional().meta({ description: `The source's own name, a free string ("user", "beta-feedback"). Never retyped.` }),
|
|
15723
|
+
node_id: external_exports.string().optional(),
|
|
15724
|
+
source_kind: external_exports.enum(SIGNAL_SOURCE_KINDS).optional().meta({
|
|
15725
|
+
description: "What sort of source: ticket | interview | form | feedback | audit-finding | idea | benchmark | other. Absent on a legacy request."
|
|
15726
|
+
}),
|
|
15727
|
+
verbatim: external_exports.string().optional().meta({ description: "The input exactly as voiced, never edited." }),
|
|
15728
|
+
provenance: StakeProvenanceSchema.optional().meta({ description: "observed (default when absent) or anticipated." }),
|
|
15729
|
+
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[]." }),
|
|
15730
|
+
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." }),
|
|
15731
|
+
criterion_id: external_exports.string().optional().meta({ description: "source_kind audit-finding: the criterion the finding was raised against." }),
|
|
15732
|
+
url: external_exports.string().optional().meta({ description: "An external reference for the source item." })
|
|
15531
15733
|
}).catchall(external_exports.unknown());
|
|
15532
15734
|
var RefAddedEventSchema = external_exports.object({
|
|
15533
15735
|
...envelope,
|
|
@@ -15736,8 +15938,10 @@ function mergeKritikLibrary(pack, overlay) {
|
|
|
15736
15938
|
for (const criterion of asArray(overlay.criteria)) {
|
|
15737
15939
|
if (typeof criterion?.id !== "string" || criterion.id === "") continue;
|
|
15738
15940
|
const at = criteria.findIndex((existing) => existing?.id === criterion.id);
|
|
15739
|
-
if (at >= 0)
|
|
15740
|
-
|
|
15941
|
+
if (at >= 0) {
|
|
15942
|
+
const packVersion = criteria[at].version;
|
|
15943
|
+
criteria[at] = criterion.version === void 0 && packVersion !== void 0 ? { ...criterion, version: packVersion } : criterion;
|
|
15944
|
+
} else criteria.push(criterion);
|
|
15741
15945
|
}
|
|
15742
15946
|
const scales = pack.scales || overlay.scales ? { ...pack.scales ?? {}, ...overlay.scales ?? {} } : void 0;
|
|
15743
15947
|
return { ...pack, domains, criteria, ...scales ? { scales } : {} };
|
|
@@ -15925,6 +16129,7 @@ function deriveQualityMatrix(bundle, library) {
|
|
|
15925
16129
|
}
|
|
15926
16130
|
|
|
15927
16131
|
// ../schema/src/quality-ops.ts
|
|
16132
|
+
var DEFAULT_TARGET_LEVEL = 3;
|
|
15928
16133
|
function upsertAssessment(assessments, next) {
|
|
15929
16134
|
const index = assessments.findIndex(
|
|
15930
16135
|
(candidate) => candidate.criterion_id === next.criterion_id && candidate.surface === next.surface
|
|
@@ -16135,10 +16340,10 @@ function dollars(value) {
|
|
|
16135
16340
|
function where(commit) {
|
|
16136
16341
|
return commit === null ? "not a git checkout" : `commit ${commit}`;
|
|
16137
16342
|
}
|
|
16138
|
-
function estimateSentence(
|
|
16139
|
-
if (
|
|
16343
|
+
function estimateSentence(tokens2, usd, calibrated) {
|
|
16344
|
+
if (tokens2 === null) return "";
|
|
16140
16345
|
const cost = usd === null ? "" : ` (${dollars(usd.low)}\u2013${dollars(usd.high)})`;
|
|
16141
|
-
return ` Estimate: ${tokenCount(
|
|
16346
|
+
return ` Estimate: ${tokenCount(tokens2.low)}\u2013${tokenCount(tokens2.high)} tokens${cost}${calibrated ? "" : ", uncalibrated"}.`;
|
|
16142
16347
|
}
|
|
16143
16348
|
function scopeSentence(cells, steps) {
|
|
16144
16349
|
return `${plural(cells, "cell")}, ${plural(steps, "checklist step")}`;
|
|
@@ -16229,15 +16434,15 @@ function planIdOfPartId(id) {
|
|
|
16229
16434
|
}
|
|
16230
16435
|
var RUN_TOKEN = /^([A-Za-z0-9]{2,5}):([A-Za-z0-9_-]+)$/;
|
|
16231
16436
|
var PLANNABLE_DOMAIN = /^[A-Z0-9]{2,5}$/;
|
|
16232
|
-
function parseRun(
|
|
16233
|
-
if (
|
|
16437
|
+
function parseRun(tokens2, vocabulary) {
|
|
16438
|
+
if (tokens2.length === 0) throw new Error("at least one --run DOMAIN:SURFACE is required");
|
|
16234
16439
|
const surfaces = vocabulary.surfaces.filter((id) => id !== CROSS_SURFACE_ID);
|
|
16235
16440
|
const plannable = vocabulary.domains.filter((code) => PLANNABLE_DOMAIN.test(code));
|
|
16236
16441
|
const unplannable = vocabulary.domains.filter((code) => !PLANNABLE_DOMAIN.test(code));
|
|
16237
16442
|
const runs = [];
|
|
16238
16443
|
const warnings = [];
|
|
16239
16444
|
const tokenBySuffix = /* @__PURE__ */ new Map();
|
|
16240
|
-
for (const token of
|
|
16445
|
+
for (const token of tokens2) {
|
|
16241
16446
|
const match = RUN_TOKEN.exec(token);
|
|
16242
16447
|
if (match === null) {
|
|
16243
16448
|
throw new Error(
|
|
@@ -16544,7 +16749,7 @@ var KritikIssueTemplateSchema = external_exports.object({
|
|
|
16544
16749
|
}).catchall(external_exports.unknown()).meta({ id: "KritikIssueTemplate", description: "Per-criterion issue skeleton \u2014 what `arkaik kritik issue` prefills." });
|
|
16545
16750
|
var KritikDomainSchema = external_exports.object({ code: external_exports.string(), name: external_exports.string(), description: external_exports.string().optional() }).catchall(external_exports.unknown()).meta({ id: "KritikDomain", description: "A top-level criteria category owning a roll-up row in the matrix." });
|
|
16546
16751
|
var KritikCriterionSchema = external_exports.object({
|
|
16547
|
-
id: external_exports.string().meta({ description: "Stable identifier, `<DOMAIN>-NN`.
|
|
16752
|
+
id: external_exports.string().meta({ description: "Stable identifier, `<DOMAIN>-NN`. A changed definition bumps `version` and keeps the id; a replacement is retired via superseded_by." }),
|
|
16548
16753
|
domain: external_exports.string(),
|
|
16549
16754
|
subcategory: external_exports.string().optional(),
|
|
16550
16755
|
name: external_exports.string().optional(),
|
|
@@ -16555,6 +16760,7 @@ var KritikCriterionSchema = external_exports.object({
|
|
|
16555
16760
|
level_anchors: external_exports.record(external_exports.string(), external_exports.string()).optional().meta({ description: "Observable descriptions per maturity level, keyed l0\u2026l4." }),
|
|
16556
16761
|
default_impact: external_exports.number().optional(),
|
|
16557
16762
|
weight: external_exports.number().optional().meta({ description: "Weight in the domain roll-up (1\u20133; 3 = load-bearing). Absent means 1." }),
|
|
16763
|
+
version: external_exports.number().optional().meta({ description: "Counts changes to the definition or level anchors; the id stays. An integer from 1; absent reads as 1." }),
|
|
16558
16764
|
references: external_exports.array(KritikReferenceSchema).optional(),
|
|
16559
16765
|
checklist: external_exports.array(external_exports.string()).optional(),
|
|
16560
16766
|
signals: external_exports.array(external_exports.string()).optional().meta({ description: "Mechanically checkable monitoring hooks run between audits." }),
|
|
@@ -16796,10 +17002,46 @@ var NodeMetadataSchema = external_exports.object({
|
|
|
16796
17002
|
}),
|
|
16797
17003
|
decided_at: external_exports.string().optional().meta({
|
|
16798
17004
|
description: "Decision nodes only: ISO 8601 date the decision was made."
|
|
16799
|
-
})
|
|
17005
|
+
}),
|
|
17006
|
+
stake_species: StakeSpeciesSchema.optional().meta({
|
|
17007
|
+
description: "Stake nodes only: bug | friction | need | requirement | risk | defect."
|
|
17008
|
+
}),
|
|
17009
|
+
provenance: StakeProvenanceSchema.optional().meta({
|
|
17010
|
+
description: "Stake nodes only: observed (default when absent) or anticipated."
|
|
17011
|
+
}),
|
|
17012
|
+
catalog: external_exports.object({
|
|
17013
|
+
source: StakeCatalogSourceSchema,
|
|
17014
|
+
id: external_exports.string().meta({ description: "A Kritik criterion id (SAF-01) or a value id (reduces-anxiety). Nothing else is copied." })
|
|
17015
|
+
}).optional().meta({ description: "Stake nodes only: link into the Kritik criteria or the value pyramid, by id." }),
|
|
17016
|
+
evidence: external_exports.array(
|
|
17017
|
+
external_exports.object({
|
|
17018
|
+
event_id: external_exports.string().optional().meta({ description: "The journal event (a request.filed) the evidence came from." }),
|
|
17019
|
+
quote: external_exports.string().optional().meta({ description: "The line that matters, exactly as voiced." }),
|
|
17020
|
+
voice: StakeEvidenceVoiceSchema.optional().meta({ description: "Who voiced it: person | maintainer | agent." }),
|
|
17021
|
+
date: external_exports.string().optional().meta({ description: "ISO 8601 date the evidence was voiced." })
|
|
17022
|
+
}).catchall(external_exports.unknown())
|
|
17023
|
+
).optional().meta({ description: "Stake nodes only: the signals behind the stake, one entry per signal. Written at qualification." }),
|
|
17024
|
+
felt: StakeFeltSchema.optional(),
|
|
17025
|
+
matters: StakeMattersSchema.optional(),
|
|
17026
|
+
frequency: StakeFrequencySchema.optional(),
|
|
17027
|
+
reverify_every_days: external_exports.number().optional().meta({
|
|
17028
|
+
description: "Stake nodes only: the verified half expires this many days after the latest check. A positive number."
|
|
17029
|
+
}),
|
|
17030
|
+
verified_criterion_version: external_exports.number().optional().meta({
|
|
17031
|
+
description: "Stake nodes only: the Kritik criterion version a requirement was last verified against. An integer from 1."
|
|
17032
|
+
}),
|
|
17033
|
+
suggested_by: external_exports.string().optional().meta({
|
|
17034
|
+
description: "Option nodes only: the id of the request.filed journal event that seeded this option."
|
|
17035
|
+
}),
|
|
17036
|
+
closed_options: external_exports.array(
|
|
17037
|
+
external_exports.object({
|
|
17038
|
+
option_id: external_exports.string().meta({ description: "The id of the option that was not chosen." }),
|
|
17039
|
+
reason: external_exports.string().meta({ description: "Why it was not chosen." })
|
|
17040
|
+
}).catchall(external_exports.unknown())
|
|
17041
|
+
).optional().meta({ description: "Decision nodes only: the options that lost, each with the reason." })
|
|
16800
17042
|
}).catchall(external_exports.unknown()).meta({ id: "NodeMetadata", description: "Optional metadata for a node." });
|
|
16801
17043
|
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)." }),
|
|
17044
|
+
id: external_exports.string().meta({ description: "Unique node ID. Convention: prefix with species \u2014 F- (flow), V- (view), DM- (data-model), API- (api-endpoint), AC- (acceptance), DEC- (decision), STK- (stake), OPT- (option)." }),
|
|
16803
17045
|
project_id: external_exports.string().meta({ description: "Must match project.id." }),
|
|
16804
17046
|
species: SpeciesSchema,
|
|
16805
17047
|
title: external_exports.string().meta({ description: "Human-readable node title." }),
|
|
@@ -16915,6 +17157,292 @@ var ProjectBundleSchema = external_exports.object({
|
|
|
16915
17157
|
description: "The import/export format for an Arkaik product graph. Contains a project, its nodes (flows, views, data models, API endpoints), and edges (relationships between nodes)."
|
|
16916
17158
|
});
|
|
16917
17159
|
|
|
17160
|
+
// ../schema/src/acceptance.ts
|
|
17161
|
+
var DEFAULT_DELIVERED_STATUSES = ["live"];
|
|
17162
|
+
function resolvePlatformStatus(node, platform) {
|
|
17163
|
+
if (!node.platforms.includes(platform)) return void 0;
|
|
17164
|
+
return node.metadata?.platformStatuses?.[platform] ?? node.status;
|
|
17165
|
+
}
|
|
17166
|
+
function hasParityGap(node, deliveredStatuses = DEFAULT_DELIVERED_STATUSES) {
|
|
17167
|
+
if (node.status === "archived") return false;
|
|
17168
|
+
const resolved = node.platforms.map((platform) => resolvePlatformStatus(node, platform)).filter((status) => status !== void 0);
|
|
17169
|
+
const delivered = resolved.filter((status) => deliveredStatuses.includes(status));
|
|
17170
|
+
return delivered.length > 0 && delivered.length < resolved.length;
|
|
17171
|
+
}
|
|
17172
|
+
function acceptancesCovering(anchorId, nodes, edges) {
|
|
17173
|
+
const coveringIds = new Set(
|
|
17174
|
+
edges.filter((edge) => edge.edge_type === "covers" && edge.target_id === anchorId).map((edge) => edge.source_id)
|
|
17175
|
+
);
|
|
17176
|
+
return nodes.filter((node) => node.species === "acceptance" && coveringIds.has(node.id));
|
|
17177
|
+
}
|
|
17178
|
+
|
|
17179
|
+
// ../schema/src/option.ts
|
|
17180
|
+
var OPTION_LIFECYCLE_STATUSES = STAKE_LIFECYCLE_STATUSES;
|
|
17181
|
+
var ANSWER_TYPE_IDS = ["fix", "enhancement", "feature", "diligence", "mitigation", "resolution"];
|
|
17182
|
+
var ANSWER_TYPE_FOR_STAKE_SPECIES = {
|
|
17183
|
+
bug: "fix",
|
|
17184
|
+
friction: "enhancement",
|
|
17185
|
+
need: "feature",
|
|
17186
|
+
requirement: "diligence",
|
|
17187
|
+
risk: "mitigation",
|
|
17188
|
+
defect: "resolution"
|
|
17189
|
+
};
|
|
17190
|
+
function answerTypeForStake(stake) {
|
|
17191
|
+
const species = stakeSpeciesOf(stake);
|
|
17192
|
+
return species === void 0 ? void 0 : ANSWER_TYPE_FOR_STAKE_SPECIES[species];
|
|
17193
|
+
}
|
|
17194
|
+
function stakesAddressedBy(optionId, nodes, edges) {
|
|
17195
|
+
const byId = new Map(nodes.map((n) => [n.id, n]));
|
|
17196
|
+
const seen = /* @__PURE__ */ new Set();
|
|
17197
|
+
const found = [];
|
|
17198
|
+
for (const edge of edges) {
|
|
17199
|
+
if (edge.edge_type !== "addresses" || edge.source_id !== optionId || seen.has(edge.target_id)) continue;
|
|
17200
|
+
const target = byId.get(edge.target_id);
|
|
17201
|
+
if (target?.species !== "stake") continue;
|
|
17202
|
+
seen.add(edge.target_id);
|
|
17203
|
+
found.push(target);
|
|
17204
|
+
}
|
|
17205
|
+
return found;
|
|
17206
|
+
}
|
|
17207
|
+
function optionsAddressing(stakeId, nodes, edges) {
|
|
17208
|
+
const byId = new Map(nodes.map((n) => [n.id, n]));
|
|
17209
|
+
const seen = /* @__PURE__ */ new Set();
|
|
17210
|
+
const found = [];
|
|
17211
|
+
for (const edge of edges) {
|
|
17212
|
+
if (edge.edge_type !== "addresses" || edge.target_id !== stakeId || seen.has(edge.source_id)) continue;
|
|
17213
|
+
const source = byId.get(edge.source_id);
|
|
17214
|
+
if (source?.species !== "option") continue;
|
|
17215
|
+
seen.add(edge.source_id);
|
|
17216
|
+
found.push(source);
|
|
17217
|
+
}
|
|
17218
|
+
return found;
|
|
17219
|
+
}
|
|
17220
|
+
function answerTypesOf(optionId, nodes, edges) {
|
|
17221
|
+
const types = /* @__PURE__ */ new Set();
|
|
17222
|
+
for (const stake of stakesAddressedBy(optionId, nodes, edges)) {
|
|
17223
|
+
const type = answerTypeForStake(stake);
|
|
17224
|
+
if (type !== void 0) types.add(type);
|
|
17225
|
+
}
|
|
17226
|
+
return ANSWER_TYPE_IDS.filter((id) => types.has(id));
|
|
17227
|
+
}
|
|
17228
|
+
var SETTLING_DECISION_STATUSES = ["approved", "enacted"];
|
|
17229
|
+
function targetsOf(sourceId, edgeType, edges) {
|
|
17230
|
+
const seen = /* @__PURE__ */ new Set();
|
|
17231
|
+
const found = [];
|
|
17232
|
+
for (const edge of edges) {
|
|
17233
|
+
if (edge.edge_type !== edgeType || edge.source_id !== sourceId || seen.has(edge.target_id)) continue;
|
|
17234
|
+
seen.add(edge.target_id);
|
|
17235
|
+
found.push(edge.target_id);
|
|
17236
|
+
}
|
|
17237
|
+
return found;
|
|
17238
|
+
}
|
|
17239
|
+
function sourcesOf(targetId, edgeType, edges) {
|
|
17240
|
+
const seen = /* @__PURE__ */ new Set();
|
|
17241
|
+
const found = [];
|
|
17242
|
+
for (const edge of edges) {
|
|
17243
|
+
if (edge.edge_type !== edgeType || edge.target_id !== targetId || seen.has(edge.source_id)) continue;
|
|
17244
|
+
seen.add(edge.source_id);
|
|
17245
|
+
found.push(edge.source_id);
|
|
17246
|
+
}
|
|
17247
|
+
return found;
|
|
17248
|
+
}
|
|
17249
|
+
function isSettlingDecision(decision) {
|
|
17250
|
+
return SETTLING_DECISION_STATUSES.includes(decisionStatusOf(decision));
|
|
17251
|
+
}
|
|
17252
|
+
function decidedAtMs(decision) {
|
|
17253
|
+
const raw = decision.metadata?.decided_at;
|
|
17254
|
+
const ms = typeof raw === "string" ? Date.parse(raw) : Number.NaN;
|
|
17255
|
+
return Number.isFinite(ms) ? ms : Number.NEGATIVE_INFINITY;
|
|
17256
|
+
}
|
|
17257
|
+
function latestFirst(a, b) {
|
|
17258
|
+
const byDate = decidedAtMs(b) - decidedAtMs(a);
|
|
17259
|
+
if (byDate !== 0 && !Number.isNaN(byDate)) return byDate;
|
|
17260
|
+
return a.id < b.id ? 1 : a.id > b.id ? -1 : 0;
|
|
17261
|
+
}
|
|
17262
|
+
function decisionsImpacting(stakeId, nodes, edges) {
|
|
17263
|
+
const impacting = new Set(sourcesOf(stakeId, "impacts", edges));
|
|
17264
|
+
return nodes.filter((node) => node.species === "decision" && impacting.has(node.id));
|
|
17265
|
+
}
|
|
17266
|
+
function settlingDecisionsFor(stakeId, nodes, edges) {
|
|
17267
|
+
return decisionsImpacting(stakeId, nodes, edges).filter(isSettlingDecision).sort(latestFirst);
|
|
17268
|
+
}
|
|
17269
|
+
function optionsGeneratedBy(decisionId, nodes, edges) {
|
|
17270
|
+
const byId = new Map(nodes.map((n) => [n.id, n]));
|
|
17271
|
+
const found = [];
|
|
17272
|
+
for (const id of targetsOf(decisionId, "generates", edges)) {
|
|
17273
|
+
const target = byId.get(id);
|
|
17274
|
+
if (target?.species === "option") found.push(target);
|
|
17275
|
+
}
|
|
17276
|
+
return found;
|
|
17277
|
+
}
|
|
17278
|
+
function answeringOptions(decisionId, stakeId, nodes, edges) {
|
|
17279
|
+
const addressing = new Set(optionsAddressing(stakeId, nodes, edges).map((option) => option.id));
|
|
17280
|
+
return optionsGeneratedBy(decisionId, nodes, edges).filter((option) => addressing.has(option.id));
|
|
17281
|
+
}
|
|
17282
|
+
function answerFor(stakeId, nodes, edges) {
|
|
17283
|
+
const [latest, ...rest] = settlingDecisionsFor(stakeId, nodes, edges);
|
|
17284
|
+
if (latest === void 0) return void 0;
|
|
17285
|
+
const option = answeringOptions(latest.id, stakeId, nodes, edges)[0];
|
|
17286
|
+
return option === void 0 ? void 0 : { decision: latest, option, competing: rest.map((decision) => decision.id) };
|
|
17287
|
+
}
|
|
17288
|
+
function acceptancesAddressing(targetId, nodes, edges) {
|
|
17289
|
+
const byId = new Map(nodes.map((n) => [n.id, n]));
|
|
17290
|
+
const found = [];
|
|
17291
|
+
for (const id of sourcesOf(targetId, "addresses", edges)) {
|
|
17292
|
+
const source = byId.get(id);
|
|
17293
|
+
if (source?.species === "acceptance") found.push(source);
|
|
17294
|
+
}
|
|
17295
|
+
return found;
|
|
17296
|
+
}
|
|
17297
|
+
function isPromise(acceptance, nodes, edges) {
|
|
17298
|
+
if (acceptance.species !== "acceptance" || acceptance.status === "archived") return false;
|
|
17299
|
+
if (acceptance.platforms.some((platform) => resolvePlatformStatus(acceptance, platform) === "live")) return true;
|
|
17300
|
+
const settling = new Set(nodes.filter((n) => n.species === "decision" && isSettlingDecision(n)).map((n) => n.id));
|
|
17301
|
+
if (sourcesOf(acceptance.id, "generates", edges).some((id) => settling.has(id))) return true;
|
|
17302
|
+
const options = new Set(targetsOf(acceptance.id, "addresses", edges));
|
|
17303
|
+
if (options.size === 0) return false;
|
|
17304
|
+
return edges.some((edge) => edge.edge_type === "generates" && settling.has(edge.source_id) && options.has(edge.target_id));
|
|
17305
|
+
}
|
|
17306
|
+
function isCandidate(acceptance, nodes, edges) {
|
|
17307
|
+
if (acceptance.species !== "acceptance") return false;
|
|
17308
|
+
if (acceptance.status !== "idea" && acceptance.status !== "discovery") return false;
|
|
17309
|
+
return !isPromise(acceptance, nodes, edges);
|
|
17310
|
+
}
|
|
17311
|
+
function promisesOf(stakeId, nodes, edges) {
|
|
17312
|
+
const found = /* @__PURE__ */ new Map();
|
|
17313
|
+
const answer = answerFor(stakeId, nodes, edges);
|
|
17314
|
+
if (answer !== void 0) {
|
|
17315
|
+
for (const acceptance of acceptancesAddressing(answer.option.id, nodes, edges)) {
|
|
17316
|
+
if (acceptance.status !== "archived") found.set(acceptance.id, acceptance);
|
|
17317
|
+
}
|
|
17318
|
+
}
|
|
17319
|
+
for (const acceptance of acceptancesAddressing(stakeId, nodes, edges)) {
|
|
17320
|
+
if (isPromise(acceptance, nodes, edges)) found.set(acceptance.id, acceptance);
|
|
17321
|
+
}
|
|
17322
|
+
return [...found.values()];
|
|
17323
|
+
}
|
|
17324
|
+
function candidatesFor(stakeId, nodes, edges) {
|
|
17325
|
+
const found = /* @__PURE__ */ new Map();
|
|
17326
|
+
const targets = [stakeId, ...optionsAddressing(stakeId, nodes, edges).map((option) => option.id)];
|
|
17327
|
+
for (const target of targets) {
|
|
17328
|
+
for (const acceptance of acceptancesAddressing(target, nodes, edges)) {
|
|
17329
|
+
if (isCandidate(acceptance, nodes, edges)) found.set(acceptance.id, acceptance);
|
|
17330
|
+
}
|
|
17331
|
+
}
|
|
17332
|
+
return [...found.values()];
|
|
17333
|
+
}
|
|
17334
|
+
function refusedSelection(reasons) {
|
|
17335
|
+
return { action: "refused", ops: [], reasons, handToHuman: [] };
|
|
17336
|
+
}
|
|
17337
|
+
function planSelectOption(input) {
|
|
17338
|
+
const byId = new Map(input.nodes.map((n) => [n.id, n]));
|
|
17339
|
+
const stake = byId.get(input.stakeId);
|
|
17340
|
+
const option = byId.get(input.optionId);
|
|
17341
|
+
const status = input.status ?? "approved";
|
|
17342
|
+
const reason = input.reason.trim();
|
|
17343
|
+
const problems = [];
|
|
17344
|
+
if (stake === void 0) problems.push(`No node with id "${input.stakeId}".`);
|
|
17345
|
+
else if (stake.species !== "stake") problems.push(`"${input.stakeId}" is a ${stake.species}, not a stake.`);
|
|
17346
|
+
if (option === void 0) problems.push(`No node with id "${input.optionId}".`);
|
|
17347
|
+
else if (option.species !== "option") problems.push(`"${input.optionId}" is a ${option.species}, not an option.`);
|
|
17348
|
+
if (status !== "approved" && status !== "enacted") problems.push(`A decision is created at approved or enacted, not "${String(status)}".`);
|
|
17349
|
+
if (reason === "") problems.push("A decision needs a reason: say why this option was chosen.");
|
|
17350
|
+
if (problems.length > 0 || stake === void 0 || option === void 0) return refusedSelection(problems);
|
|
17351
|
+
const addressing = optionsAddressing(stake.id, input.nodes, input.edges);
|
|
17352
|
+
if (!addressing.some((candidate) => candidate.id === option.id)) {
|
|
17353
|
+
problems.push(`Option "${option.id}" does not address stake "${stake.id}": add the addresses edge first.`);
|
|
17354
|
+
}
|
|
17355
|
+
if (option.status === "archived") problems.push(`Option "${option.id}" is archived: an archived option cannot be selected.`);
|
|
17356
|
+
const settling = settlingDecisionsFor(stake.id, input.nodes, input.edges);
|
|
17357
|
+
if (settling.length > 0 && input.supersede !== true) {
|
|
17358
|
+
problems.push(
|
|
17359
|
+
`Stake "${stake.id}" already has a settling decision (${settling.map((d) => d.id).join(", ")}): pass supersede to replace it.`
|
|
17360
|
+
);
|
|
17361
|
+
}
|
|
17362
|
+
const addressingIds = new Set(addressing.map((candidate) => candidate.id));
|
|
17363
|
+
const closed = /* @__PURE__ */ new Map();
|
|
17364
|
+
for (const entry of input.closed ?? []) {
|
|
17365
|
+
if (entry.option_id === option.id) {
|
|
17366
|
+
problems.push(`"${option.id}" is the selected option and cannot also be closed.`);
|
|
17367
|
+
} else if (!addressingIds.has(entry.option_id)) {
|
|
17368
|
+
problems.push(`Closed option "${entry.option_id}" does not address stake "${stake.id}".`);
|
|
17369
|
+
} else if (!closed.has(entry.option_id)) {
|
|
17370
|
+
closed.set(entry.option_id, entry.reason.trim());
|
|
17371
|
+
}
|
|
17372
|
+
}
|
|
17373
|
+
if (problems.length > 0) return refusedSelection(problems);
|
|
17374
|
+
const handToHuman = [];
|
|
17375
|
+
const closedOptions = [];
|
|
17376
|
+
for (const [optionId, given] of closed) closedOptions.push({ option_id: optionId, reason: given });
|
|
17377
|
+
for (const other of addressing) {
|
|
17378
|
+
if (other.id === option.id || other.status === "archived" || closed.has(other.id)) continue;
|
|
17379
|
+
closedOptions.push({ option_id: other.id, reason: "" });
|
|
17380
|
+
}
|
|
17381
|
+
for (const entry of closedOptions) {
|
|
17382
|
+
if (entry.reason !== "") continue;
|
|
17383
|
+
entry.reason = `Not selected: "${option.title}" was chosen.`;
|
|
17384
|
+
handToHuman.push(`No reason was given for closing "${byId.get(entry.option_id)?.title ?? entry.option_id}" (${entry.option_id}): the default reason was recorded. Write the real one.`);
|
|
17385
|
+
}
|
|
17386
|
+
const title = input.title !== void 0 && input.title.trim() !== "" ? input.title.trim() : `Select "${option.title}" for "${stake.title}"`;
|
|
17387
|
+
const decisionId = deriveNodeId("decision", title, input.nodes.map((n) => n.id));
|
|
17388
|
+
const ops = [];
|
|
17389
|
+
const reasons = [];
|
|
17390
|
+
if (input.supersede === true) {
|
|
17391
|
+
for (const previous of settling) {
|
|
17392
|
+
const was = decisionStatusOf(previous);
|
|
17393
|
+
ops.push({
|
|
17394
|
+
op: "update_node",
|
|
17395
|
+
node_id: previous.id,
|
|
17396
|
+
patch: {
|
|
17397
|
+
status: lifecycleStatusForDecision("superseded"),
|
|
17398
|
+
metadata: { ...byId.get(previous.id)?.metadata ?? {}, decision_status: "superseded" }
|
|
17399
|
+
}
|
|
17400
|
+
});
|
|
17401
|
+
reasons.push(`Supersedes ${previous.id} (it was ${was}).`);
|
|
17402
|
+
const others = targetsOf(previous.id, "impacts", input.edges).filter((id) => id !== stake.id && byId.get(id)?.species === "stake");
|
|
17403
|
+
if (others.length > 0) {
|
|
17404
|
+
handToHuman.push(
|
|
17405
|
+
`${previous.id} also settles ${others.join(", ")}: superseding it un-settles ${others.length === 1 ? "that stake" : "those stakes"}. Decide again for ${others.length === 1 ? "it" : "them"}, or keep ${previous.id}.`
|
|
17406
|
+
);
|
|
17407
|
+
}
|
|
17408
|
+
}
|
|
17409
|
+
}
|
|
17410
|
+
ops.push({
|
|
17411
|
+
op: "create_node",
|
|
17412
|
+
node: {
|
|
17413
|
+
id: decisionId,
|
|
17414
|
+
project_id: input.projectId,
|
|
17415
|
+
title,
|
|
17416
|
+
species: "decision",
|
|
17417
|
+
status: lifecycleStatusForDecision(status),
|
|
17418
|
+
platforms: [],
|
|
17419
|
+
metadata: {
|
|
17420
|
+
decision_status: status,
|
|
17421
|
+
context: reason,
|
|
17422
|
+
...input.decidedAt !== void 0 && input.decidedAt !== "" ? { decided_at: input.decidedAt } : {},
|
|
17423
|
+
...closedOptions.length > 0 ? { closed_options: closedOptions } : {}
|
|
17424
|
+
}
|
|
17425
|
+
}
|
|
17426
|
+
});
|
|
17427
|
+
ops.push({
|
|
17428
|
+
op: "create_edge",
|
|
17429
|
+
edge: { id: edgeId(decisionId, stake.id), project_id: input.projectId, source_id: decisionId, target_id: stake.id, edge_type: "impacts" }
|
|
17430
|
+
});
|
|
17431
|
+
ops.push({
|
|
17432
|
+
op: "create_edge",
|
|
17433
|
+
edge: { id: edgeId(decisionId, option.id), project_id: input.projectId, source_id: decisionId, target_id: option.id, edge_type: "generates" }
|
|
17434
|
+
});
|
|
17435
|
+
if (input.supersede === true) {
|
|
17436
|
+
for (const previous of settling) {
|
|
17437
|
+
ops.push({
|
|
17438
|
+
op: "create_edge",
|
|
17439
|
+
edge: { id: edgeId(decisionId, previous.id), project_id: input.projectId, source_id: decisionId, target_id: previous.id, edge_type: "supersedes" }
|
|
17440
|
+
});
|
|
17441
|
+
}
|
|
17442
|
+
}
|
|
17443
|
+
return { action: "decide", ops, decision_id: decisionId, reasons, handToHuman };
|
|
17444
|
+
}
|
|
17445
|
+
|
|
16918
17446
|
// ../schema/src/products.ts
|
|
16919
17447
|
var PRODUCT_MEMBERSHIP_SPECIES = ["flow", "view", "acceptance"];
|
|
16920
17448
|
function resolveProducts(project) {
|
|
@@ -16936,6 +17464,14 @@ function productOf(node) {
|
|
|
16936
17464
|
const product = node.metadata?.product;
|
|
16937
17465
|
return typeof product === "string" ? product : null;
|
|
16938
17466
|
}
|
|
17467
|
+
function effectiveNodePlatforms(node, product) {
|
|
17468
|
+
const own = Array.isArray(node.platforms) ? node.platforms : [];
|
|
17469
|
+
if (!product || !Array.isArray(product.platforms)) {
|
|
17470
|
+
return PLATFORM_IDS.filter((platform) => own.includes(platform));
|
|
17471
|
+
}
|
|
17472
|
+
const menu = new Set(product.platforms);
|
|
17473
|
+
return PLATFORM_IDS.filter((platform) => own.includes(platform) && menu.has(platform));
|
|
17474
|
+
}
|
|
16939
17475
|
var SYSTEM_LAYER_SPECIES = ["api-endpoint", "data-model"];
|
|
16940
17476
|
var USAGE_EDGE_TYPES = /* @__PURE__ */ new Set(["calls", "displays", "queries"]);
|
|
16941
17477
|
function buildProductUsageIndex(nodes, edges) {
|
|
@@ -17144,7 +17680,7 @@ var LADDERS = {
|
|
|
17144
17680
|
"-1": "Costs the person a little time on one task inside the product.",
|
|
17145
17681
|
"1": "Saves a little time on one task inside the product.",
|
|
17146
17682
|
"2": "Saves time on tasks the person does regularly in this domain.",
|
|
17147
|
-
"3": "Gives the person back hours of their life
|
|
17683
|
+
"3": "Gives the person back hours of their life."
|
|
17148
17684
|
},
|
|
17149
17685
|
simplifies: {
|
|
17150
17686
|
"-3": "Makes a part of the person's life confusing or hard to manage.",
|
|
@@ -17152,7 +17688,7 @@ var LADDERS = {
|
|
|
17152
17688
|
"-1": "Adds a step or a choice inside the product.",
|
|
17153
17689
|
"1": "Removes a step or a choice inside the product.",
|
|
17154
17690
|
"2": "Makes a whole task in this domain clearly simpler.",
|
|
17155
|
-
"3": "Makes a complicated part of the person's life simple
|
|
17691
|
+
"3": "Makes a complicated part of the person's life simple."
|
|
17156
17692
|
},
|
|
17157
17693
|
"makes-money": {
|
|
17158
17694
|
"-3": "Costs the person a meaningful part of their income.",
|
|
@@ -17168,7 +17704,7 @@ var LADDERS = {
|
|
|
17168
17704
|
"-1": "Exposes the person to a small mistake or loss inside the product.",
|
|
17169
17705
|
"1": "Guards against a small mistake or loss inside the product.",
|
|
17170
17706
|
"2": "Protects against a serious loss or error in this domain.",
|
|
17171
|
-
"3": "Protects against a major loss in the person's life
|
|
17707
|
+
"3": "Protects against a major loss in the person's life."
|
|
17172
17708
|
},
|
|
17173
17709
|
organizes: {
|
|
17174
17710
|
"-3": "Brings disorder to a large part of the person's life.",
|
|
@@ -17176,7 +17712,7 @@ var LADDERS = {
|
|
|
17176
17712
|
"-1": "Leaves a few things in disorder inside the product.",
|
|
17177
17713
|
"1": "Keeps a few things in order inside the product.",
|
|
17178
17714
|
"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
|
|
17715
|
+
"3": "Brings order to a large part of the person's life."
|
|
17180
17716
|
},
|
|
17181
17717
|
integrates: {
|
|
17182
17718
|
"-3": "Pulls separate parts of the person's life further apart.",
|
|
@@ -17196,10 +17732,10 @@ var LADDERS = {
|
|
|
17196
17732
|
},
|
|
17197
17733
|
"reduces-effort": {
|
|
17198
17734
|
"-3": "Puts a heavy burden of work on the person's life.",
|
|
17199
|
-
"-2": "
|
|
17735
|
+
"-2": "Makes a whole task clearly more demanding.",
|
|
17200
17736
|
"-1": "Adds a little effort to one task inside the product.",
|
|
17201
17737
|
"1": "Saves a little effort on one task inside the product.",
|
|
17202
|
-
"2": "
|
|
17738
|
+
"2": "Makes a whole task clearly less demanding.",
|
|
17203
17739
|
"3": "Lifts a heavy burden of work off the person's life."
|
|
17204
17740
|
},
|
|
17205
17741
|
"avoids-hassles": {
|
|
@@ -17208,7 +17744,7 @@ var LADDERS = {
|
|
|
17208
17744
|
"-1": "Adds a small annoyance inside the product.",
|
|
17209
17745
|
"1": "Avoids a small annoyance inside the product.",
|
|
17210
17746
|
"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
|
|
17747
|
+
"3": "Takes a whole kind of annoyance out of the person's life."
|
|
17212
17748
|
},
|
|
17213
17749
|
"reduces-cost": {
|
|
17214
17750
|
"-3": "Costs the person a significant amount of money over their life.",
|
|
@@ -17220,25 +17756,25 @@ var LADDERS = {
|
|
|
17220
17756
|
},
|
|
17221
17757
|
quality: {
|
|
17222
17758
|
"-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
|
|
17759
|
+
"-2": "The product feels unreliable and poorly made throughout.",
|
|
17760
|
+
"-1": "Something inside the product feels unreliable or half-made.",
|
|
17761
|
+
"1": "Something inside the product feels robust.",
|
|
17762
|
+
"2": "The product feels dependable and well crafted throughout.",
|
|
17227
17763
|
"3": "Craft so good the person would call it the best they have used."
|
|
17228
17764
|
},
|
|
17229
17765
|
variety: {
|
|
17230
|
-
"-3": "
|
|
17231
|
-
"-2": "
|
|
17232
|
-
"-1": "
|
|
17233
|
-
"1": "Offers a few
|
|
17234
|
-
"2": "Offers a wide
|
|
17235
|
-
"3": "
|
|
17766
|
+
"-3": "Locks the person into a narrow range of choices in their life.",
|
|
17767
|
+
"-2": "Limits the person to a narrow range of choices.",
|
|
17768
|
+
"-1": "Does not offer enough options inside the product.",
|
|
17769
|
+
"1": "Offers the person a few options inside the product.",
|
|
17770
|
+
"2": "Offers the person a wide choice.",
|
|
17771
|
+
"3": "Offers the person a breadth of choice they can shape to their own life."
|
|
17236
17772
|
},
|
|
17237
17773
|
"sensory-appeal": {
|
|
17238
17774
|
"-3": "A sensory experience the person avoids.",
|
|
17239
17775
|
"-2": "The product looks, sounds or feels bad and the person dislikes using it.",
|
|
17240
|
-
"-1": "
|
|
17241
|
-
"1": "A
|
|
17776
|
+
"-1": "A look, a sound or a feel the person would point to as unpleasant.",
|
|
17777
|
+
"1": "A look, a sound or a feel the person would point to as pleasant.",
|
|
17242
17778
|
"2": "The product looks, sounds or feels good and the person enjoys using it.",
|
|
17243
17779
|
"3": "A sensory experience the person seeks out for its own sake."
|
|
17244
17780
|
},
|
|
@@ -17251,25 +17787,25 @@ var LADDERS = {
|
|
|
17251
17787
|
"3": "Informs the person deeply and efficiently about the service area or domain."
|
|
17252
17788
|
},
|
|
17253
17789
|
"reduces-anxiety": {
|
|
17254
|
-
"-3": "
|
|
17790
|
+
"-3": "Leaves the person anxious about something important in their life.",
|
|
17255
17791
|
"-2": "Stirs up a worry the person has in this domain.",
|
|
17256
17792
|
"-1": "Adds a small worry inside the product.",
|
|
17257
17793
|
"1": "Removes a small worry inside the product.",
|
|
17258
17794
|
"2": "Calms a worry the person has in this domain.",
|
|
17259
|
-
"3": "
|
|
17795
|
+
"3": "Brings the person lasting peace of mind about something important."
|
|
17260
17796
|
},
|
|
17261
17797
|
"rewards-me": {
|
|
17262
|
-
"-3": "
|
|
17263
|
-
"-2": "
|
|
17264
|
-
"-1": "
|
|
17798
|
+
"-3": "Does not give rewards the person values as much as the product itself.",
|
|
17799
|
+
"-2": "Does not give the perks the person regularly expects.",
|
|
17800
|
+
"-1": "Does not give a small perk where the person would expect one.",
|
|
17265
17801
|
"1": "Gives the person a small perk for engaging.",
|
|
17266
17802
|
"2": "Gives the person regular perks they value.",
|
|
17267
17803
|
"3": "Gives the person rewards they value as much as the product itself."
|
|
17268
17804
|
},
|
|
17269
17805
|
nostalgia: {
|
|
17270
|
-
"-3": "
|
|
17271
|
-
"-2": "
|
|
17272
|
-
"-1": "
|
|
17806
|
+
"-3": "Ruins a cherished memory for good.",
|
|
17807
|
+
"-2": "Clearly tarnishes a good memory of the past.",
|
|
17808
|
+
"-1": "Dulls a pleasant memory of the past.",
|
|
17273
17809
|
"1": "Faintly recalls a pleasant memory of the past.",
|
|
17274
17810
|
"2": "Clearly brings back a good memory of the past.",
|
|
17275
17811
|
"3": "Brings back a cherished past in a vivid and deeply felt way."
|
|
@@ -17299,9 +17835,9 @@ var LADDERS = {
|
|
|
17299
17835
|
"3": "Lastingly improves the person's physical or mental well-being."
|
|
17300
17836
|
},
|
|
17301
17837
|
"therapeutic-value": {
|
|
17302
|
-
"-3": "
|
|
17838
|
+
"-3": "Causes the person lasting emotional hurt.",
|
|
17303
17839
|
"-2": "Makes a difficult feeling harder for the person to work through.",
|
|
17304
|
-
"-1": "
|
|
17840
|
+
"-1": "Gets in the way of a moment of emotional relief.",
|
|
17305
17841
|
"1": "Gives a small moment of emotional relief.",
|
|
17306
17842
|
"2": "Helps the person work through a difficult feeling.",
|
|
17307
17843
|
"3": "Supports real healing of something that hurts the person."
|
|
@@ -17315,68 +17851,68 @@ var LADDERS = {
|
|
|
17315
17851
|
"3": "Delight the person would seek out and tell others about."
|
|
17316
17852
|
},
|
|
17317
17853
|
attractiveness: {
|
|
17318
|
-
"-3": "
|
|
17854
|
+
"-3": "Leaves the person feeling unattractive in their everyday life.",
|
|
17319
17855
|
"-2": "Clearly makes the person feel less attractive.",
|
|
17320
17856
|
"-1": "Makes the person feel slightly worse about how they look.",
|
|
17321
17857
|
"1": "Makes the person feel slightly better about how they look.",
|
|
17322
17858
|
"2": "Clearly makes the person feel more attractive.",
|
|
17323
|
-
"3": "
|
|
17859
|
+
"3": "Leaves the person feeling attractive in their everyday life."
|
|
17324
17860
|
},
|
|
17325
17861
|
"provides-access": {
|
|
17326
|
-
"-3": "
|
|
17327
|
-
"-2": "
|
|
17328
|
-
"-1": "Puts a
|
|
17329
|
-
"1": "
|
|
17330
|
-
"2": "
|
|
17331
|
-
"3": "
|
|
17862
|
+
"-3": "Makes something that matters in the person's life much harder to reach.",
|
|
17863
|
+
"-2": "Makes services, people, knowledge or capabilities harder to reach.",
|
|
17864
|
+
"-1": "Puts a barrier in front of a feature inside the product.",
|
|
17865
|
+
"1": "Lowers a barrier to a feature inside the product.",
|
|
17866
|
+
"2": "Makes services, people, knowledge or capabilities easier to reach.",
|
|
17867
|
+
"3": "Makes something that matters in the person's life much easier to reach."
|
|
17332
17868
|
},
|
|
17333
17869
|
"provides-hope": {
|
|
17334
17870
|
"-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
|
|
17871
|
+
"-2": "Gives the person a reason to doubt that things can improve.",
|
|
17872
|
+
"-1": "Gets in the way of the person's hope.",
|
|
17873
|
+
"1": "Gives the person a glimmer of hope.",
|
|
17874
|
+
"2": "Gives a real reason to believe that things can improve.",
|
|
17339
17875
|
"3": "Gives a lasting belief that the person's life can get better."
|
|
17340
17876
|
},
|
|
17341
17877
|
"self-actualization": {
|
|
17342
|
-
"-3": "
|
|
17343
|
-
"-2": "
|
|
17344
|
-
"-1": "
|
|
17878
|
+
"-3": "A drift away from who the person wants to be.",
|
|
17879
|
+
"-2": "A step away from who the person wants to be.",
|
|
17880
|
+
"-1": "Keeps the person from becoming who they want to be.",
|
|
17345
17881
|
"1": "A small step toward who the person wants to be.",
|
|
17346
17882
|
"2": "Clear progress toward who the person wants to be.",
|
|
17347
17883
|
"3": "Helps the person become who they want to be."
|
|
17348
17884
|
},
|
|
17349
17885
|
motivation: {
|
|
17350
|
-
"-3": "Drains the person's
|
|
17351
|
-
"-2": "
|
|
17352
|
-
"-1": "
|
|
17353
|
-
"1": "
|
|
17354
|
-
"2": "
|
|
17886
|
+
"-3": "Drains the person's energy toward goals that matter in their life.",
|
|
17887
|
+
"-2": "A drag on the person's drive.",
|
|
17888
|
+
"-1": "Discourages the person from starting.",
|
|
17889
|
+
"1": "Gives the person a spark of motivation.",
|
|
17890
|
+
"2": "Keeps the person energized toward a goal.",
|
|
17355
17891
|
"3": "Sustains the person's drive toward goals that matter in their life."
|
|
17356
17892
|
},
|
|
17357
17893
|
heirloom: {
|
|
17358
|
-
"-3": "
|
|
17359
|
-
"-2": "
|
|
17360
|
-
"-1": "
|
|
17894
|
+
"-3": "Prevents something meaningful from being passed on to others.",
|
|
17895
|
+
"-2": "Prevents something meaningful from being preserved for years.",
|
|
17896
|
+
"-1": "Gets in the way of keeping something worth keeping.",
|
|
17361
17897
|
"1": "Keeps something worth keeping for a while.",
|
|
17362
17898
|
"2": "Preserves something meaningful for years.",
|
|
17363
17899
|
"3": "Holds something meaningful enough to be passed on to others across time."
|
|
17364
17900
|
},
|
|
17365
17901
|
"affiliation-belonging": {
|
|
17366
17902
|
"-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
|
|
17903
|
+
"-2": "Keeps the person from becoming part of a group or community.",
|
|
17904
|
+
"-1": "Gets in the way of feeling part of something meaningful.",
|
|
17905
|
+
"1": "A feeling of being part of something meaningful.",
|
|
17906
|
+
"2": "Makes the person part of a group or community.",
|
|
17371
17907
|
"3": "Makes the person part of a group that matters deeply to who they are."
|
|
17372
17908
|
},
|
|
17373
17909
|
"self-transcendence": {
|
|
17374
|
-
"-3": "
|
|
17375
|
-
"-2": "
|
|
17376
|
-
"-1": "
|
|
17377
|
-
"1": "
|
|
17378
|
-
"2": "
|
|
17379
|
-
"3": "
|
|
17910
|
+
"-3": "Keeps the person from contributing to major or meaningful causes.",
|
|
17911
|
+
"-2": "Keeps the person from making a lasting difference for other people or causes.",
|
|
17912
|
+
"-1": "Keeps the person from giving something real to others.",
|
|
17913
|
+
"1": "Lets the person give something real to others at a human scale.",
|
|
17914
|
+
"2": "Lets the person make a lasting difference for other people or causes.",
|
|
17915
|
+
"3": "Lets the person contribute to major or meaningful causes."
|
|
17380
17916
|
}
|
|
17381
17917
|
};
|
|
17382
17918
|
var VALUE_REACH_LADDERS = Object.freeze(
|
|
@@ -17401,8 +17937,8 @@ var WEIGHING_PROBABILITY_FIELDS = ["p_serves", "p_costs"];
|
|
|
17401
17937
|
function isWeighingProbability(value) {
|
|
17402
17938
|
return typeof value === "number" && Number.isFinite(value) && value >= 0 && value <= 1;
|
|
17403
17939
|
}
|
|
17404
|
-
var WEIGHING_CLEAR_AT = 0.
|
|
17405
|
-
var WEIGHING_UNSETTLED_AT = 0.
|
|
17940
|
+
var WEIGHING_CLEAR_AT = 0.9;
|
|
17941
|
+
var WEIGHING_UNSETTLED_AT = 0.5;
|
|
17406
17942
|
function isUncertainCell(row) {
|
|
17407
17943
|
const serves = isWeighingProbability(row.p_serves) ? row.p_serves : void 0;
|
|
17408
17944
|
const costs = isWeighingProbability(row.p_costs) ? row.p_costs : void 0;
|
|
@@ -17458,6 +17994,19 @@ function acceptanceFingerprint(node) {
|
|
|
17458
17994
|
const text = JSON.stringify([squash(node.title ?? ""), squash(gherkin), values]);
|
|
17459
17995
|
return `fp1-${hash53(text).toString(16).padStart(14, "0")}`;
|
|
17460
17996
|
}
|
|
17997
|
+
function stakeFingerprint(node) {
|
|
17998
|
+
const species = typeof node.metadata?.stake_species === "string" ? node.metadata.stake_species : "";
|
|
17999
|
+
const text = JSON.stringify(["stake", squash(node.title ?? ""), species]);
|
|
18000
|
+
return `fp1-${hash53(text).toString(16).padStart(14, "0")}`;
|
|
18001
|
+
}
|
|
18002
|
+
function fingerprintOf(node) {
|
|
18003
|
+
return node.species === "stake" ? stakeFingerprint(node) : acceptanceFingerprint(node);
|
|
18004
|
+
}
|
|
18005
|
+
function stakeSpeciesDeclaredBy(set2) {
|
|
18006
|
+
const raw = set2.stake_species;
|
|
18007
|
+
if (!Array.isArray(raw)) return [];
|
|
18008
|
+
return raw.filter((entry) => STAKE_SPECIES_IDS.includes(entry));
|
|
18009
|
+
}
|
|
17461
18010
|
function upsertWeighingAssessment(assessments, next) {
|
|
17462
18011
|
const key = assessmentKey(next);
|
|
17463
18012
|
const index = assessments.findIndex((candidate) => assessmentKey(candidate) === key);
|
|
@@ -17487,6 +18036,7 @@ var VALUE_SET_ID = "value-contribution";
|
|
|
17487
18036
|
var VALUE_SET_VERSION = "2.0.0";
|
|
17488
18037
|
var VALUE_SET_V1_VERSION = "1.0.0";
|
|
17489
18038
|
var VALUE_MATRIX_ID = "value";
|
|
18039
|
+
var STAKE_MATRIX_ID = "stakes";
|
|
17490
18040
|
var POSITIONING_SET_ID = "positioning";
|
|
17491
18041
|
var VALUE_SCALE_ANCHORS = {
|
|
17492
18042
|
"3": "Life-wide. It gives the person this well beyond the product and its domain, in their life.",
|
|
@@ -17557,6 +18107,8 @@ var VALUE_CONTRIBUTION_SET = deepFreeze({
|
|
|
17557
18107
|
version: VALUE_SET_VERSION,
|
|
17558
18108
|
title: "Elements of value",
|
|
17559
18109
|
subject: "acceptance",
|
|
18110
|
+
// The reference declares what it scores (stake architecture, part 4): the user-facing stakes are weighed on the pyramid.
|
|
18111
|
+
stake_species: [...USER_FACING_STAKE_SPECIES],
|
|
17560
18112
|
scale: VALUE_SCALE,
|
|
17561
18113
|
groups: GROUPS,
|
|
17562
18114
|
criteria: VALUE_IDS.map((id) => ({
|
|
@@ -17591,8 +18143,15 @@ var VALUE_MATRIX = deepFreeze({
|
|
|
17591
18143
|
positioning: POSITIONING_SET_ID,
|
|
17592
18144
|
status: "active"
|
|
17593
18145
|
});
|
|
18146
|
+
var STAKE_MATRIX = deepFreeze({
|
|
18147
|
+
id: STAKE_MATRIX_ID,
|
|
18148
|
+
title: "Stakes",
|
|
18149
|
+
set: `${VALUE_SET_ID}@2`,
|
|
18150
|
+
subjects: { kind: "query", species: "stake" },
|
|
18151
|
+
status: "active"
|
|
18152
|
+
});
|
|
17594
18153
|
var BUILT_IN_SETS = [VALUE_CONTRIBUTION_SET, VALUE_CONTRIBUTION_SET_V1];
|
|
17595
|
-
var BUILT_IN_MATRICES = [VALUE_MATRIX];
|
|
18154
|
+
var BUILT_IN_MATRICES = [VALUE_MATRIX, STAKE_MATRIX];
|
|
17596
18155
|
var isObject2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
17597
18156
|
function cleaned(set2) {
|
|
17598
18157
|
const usable = set2.criteria.filter((criterion) => isObject2(criterion) && typeof criterion.id === "string");
|
|
@@ -17640,10 +18199,17 @@ function isOlderMajorRef(resolved, ref) {
|
|
|
17640
18199
|
const now = Number(majorOf(current.version));
|
|
17641
18200
|
return Number.isFinite(now) && Number(major) < now;
|
|
17642
18201
|
}
|
|
18202
|
+
function isMatrixSubject(node, matrix, set2) {
|
|
18203
|
+
if (matrix.subjects.kind !== "query") return matrix.subjects.items.some((item) => (item?.node_id ?? item?.id) === node.id);
|
|
18204
|
+
if (node.species !== matrix.subjects.species) return false;
|
|
18205
|
+
if (node.species !== "stake") return true;
|
|
18206
|
+
const kind = stakeSpeciesOf({ metadata: node.metadata });
|
|
18207
|
+
return kind !== void 0 && set2 !== void 0 && stakeSpeciesDeclaredBy(set2).includes(kind);
|
|
18208
|
+
}
|
|
17643
18209
|
|
|
17644
18210
|
// ../schema/src/weighing-validate.ts
|
|
17645
18211
|
var isObject3 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
17646
|
-
function validateWeighingSection(section, nodeSpecies, journal) {
|
|
18212
|
+
function validateWeighingSection(section, nodeSpecies, journal, stakeSpecies = /* @__PURE__ */ new Map()) {
|
|
17647
18213
|
const out = [];
|
|
17648
18214
|
const warn = (path, rule, message) => out.push({ path, rule, message });
|
|
17649
18215
|
if (section !== void 0 && section !== null && !isObject3(section)) {
|
|
@@ -17700,6 +18266,12 @@ function validateWeighingSection(section, nodeSpecies, journal) {
|
|
|
17700
18266
|
}
|
|
17701
18267
|
}
|
|
17702
18268
|
checkStatus(path, who, entry);
|
|
18269
|
+
if (entry.stake_species !== void 0) {
|
|
18270
|
+
const declared2 = entry.stake_species;
|
|
18271
|
+
if (!Array.isArray(declared2) || !declared2.every((kind) => STAKE_SPECIES_IDS.includes(kind))) {
|
|
18272
|
+
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`);
|
|
18273
|
+
}
|
|
18274
|
+
}
|
|
17703
18275
|
if (isObject3(entry.scale)) {
|
|
17704
18276
|
const scale = entry.scale;
|
|
17705
18277
|
if (typeof scale.min !== "number" || typeof scale.max !== "number" || !isLevelMap(scale.anchors)) {
|
|
@@ -17812,6 +18384,15 @@ function validateWeighingSection(section, nodeSpecies, journal) {
|
|
|
17812
18384
|
warn(`${path}.subject`, "weighing-unknown-subject", `${label}: subject "${entry.subject}" is not a node in this bundle`);
|
|
17813
18385
|
} else if (species !== matrix.subjects.species) {
|
|
17814
18386
|
warn(`${path}.subject`, "weighing-subject-species", `${label}: subject "${entry.subject}" is a ${species}, and matrix "${matrix.id}" judges ${String(matrix.subjects.species)} nodes`);
|
|
18387
|
+
} else if (species === "stake" && set2 !== void 0) {
|
|
18388
|
+
const kind = stakeSpecies.get(entry.subject);
|
|
18389
|
+
if (kind === void 0 || !stakeSpeciesDeclaredBy(set2).includes(kind)) {
|
|
18390
|
+
warn(
|
|
18391
|
+
`${path}.subject`,
|
|
18392
|
+
"weighing-subject-stake-species",
|
|
18393
|
+
`${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`
|
|
18394
|
+
);
|
|
18395
|
+
}
|
|
17815
18396
|
}
|
|
17816
18397
|
}
|
|
17817
18398
|
if (entry.evidence !== void 0 && typeof entry.evidence !== "string") {
|
|
@@ -17960,7 +18541,7 @@ function validateBundle(input) {
|
|
|
17960
18541
|
}
|
|
17961
18542
|
const platforms = node.platforms;
|
|
17962
18543
|
if (!platforms || platforms.length === 0) {
|
|
17963
|
-
if (species !== "decision") {
|
|
18544
|
+
if (species !== "decision" && species !== "stake" && species !== "option") {
|
|
17964
18545
|
error51(`${base}.platforms`, "platforms-non-empty", `Node ${nodeId}: platforms array is empty or missing`);
|
|
17965
18546
|
}
|
|
17966
18547
|
} else {
|
|
@@ -18254,7 +18835,7 @@ function validateBundle(input) {
|
|
|
18254
18835
|
const membership = typeof metadata.product === "string" ? metadata.product : void 0;
|
|
18255
18836
|
const storesMembership = species !== void 0 && PRODUCT_MEMBERSHIP_SPECIES.includes(species);
|
|
18256
18837
|
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";
|
|
18838
|
+
const detail = species === "decision" || species === "stake" || species === "option" ? `${species} nodes store no product membership (they show under every product scope)` : SPECIES_IDS.includes(species) ? `${species} membership is derived from consumers and must not be stored` : "metadata.product is only meaningful on flow, view, and acceptance nodes";
|
|
18258
18839
|
warn(`${base}.metadata.product`, "product-membership-wrong-species", `Node ${nodeId}: ${detail}`);
|
|
18259
18840
|
return;
|
|
18260
18841
|
}
|
|
@@ -18370,6 +18951,274 @@ function validateBundle(input) {
|
|
|
18370
18951
|
composesSet.add(`${sourceId}->${targetId}`);
|
|
18371
18952
|
}
|
|
18372
18953
|
});
|
|
18954
|
+
const concernsSources = /* @__PURE__ */ new Set();
|
|
18955
|
+
for (const edge of edges) {
|
|
18956
|
+
if (edge.edge_type === "concerns" && typeof edge.source_id === "string") concernsSources.add(edge.source_id);
|
|
18957
|
+
}
|
|
18958
|
+
nodes.forEach((node, index) => {
|
|
18959
|
+
const nodeId = typeof node.id === "string" ? node.id : `#${index}`;
|
|
18960
|
+
const species = node.species;
|
|
18961
|
+
const base = `nodes[${index}]`;
|
|
18962
|
+
const stakeMd = node.metadata ?? {};
|
|
18963
|
+
if (species !== "stake") {
|
|
18964
|
+
for (const field of [
|
|
18965
|
+
"stake_species",
|
|
18966
|
+
"provenance",
|
|
18967
|
+
"catalog",
|
|
18968
|
+
"evidence",
|
|
18969
|
+
"felt",
|
|
18970
|
+
"matters",
|
|
18971
|
+
"frequency",
|
|
18972
|
+
"reverify_every_days",
|
|
18973
|
+
"verified_criterion_version"
|
|
18974
|
+
]) {
|
|
18975
|
+
if (stakeMd[field] !== void 0) {
|
|
18976
|
+
warn(
|
|
18977
|
+
`${base}.metadata.${field}`,
|
|
18978
|
+
"stake-species-wrong-species",
|
|
18979
|
+
`${field} is meaningful on stake nodes only; "${nodeId}" is a ${species}.`
|
|
18980
|
+
);
|
|
18981
|
+
}
|
|
18982
|
+
}
|
|
18983
|
+
return;
|
|
18984
|
+
}
|
|
18985
|
+
const stakeNode = { metadata: node.metadata };
|
|
18986
|
+
const stakeSpecies = stakeSpeciesOf(stakeNode);
|
|
18987
|
+
if (stakeSpecies === void 0) {
|
|
18988
|
+
warn(
|
|
18989
|
+
`${base}.metadata.stake_species`,
|
|
18990
|
+
"stake-species-missing",
|
|
18991
|
+
`Stake ${nodeId}: metadata.stake_species is missing (bug, friction, need, requirement, risk or defect)`
|
|
18992
|
+
);
|
|
18993
|
+
}
|
|
18994
|
+
if (!STAKE_LIFECYCLE_STATUSES.includes(node.status)) {
|
|
18995
|
+
warn(
|
|
18996
|
+
`${base}.status`,
|
|
18997
|
+
"stake-lifecycle",
|
|
18998
|
+
`Stake ${nodeId}: status "${node.status}" is not stored on a stake (idea, discovery or archived only; every other state is derived)`
|
|
18999
|
+
);
|
|
19000
|
+
}
|
|
19001
|
+
if (stakeSpecies !== void 0 && stakeProvenanceOf(stakeNode) === "anticipated" && !ANTICIPATED_STAKE_SPECIES.includes(stakeSpecies)) {
|
|
19002
|
+
warn(
|
|
19003
|
+
`${base}.metadata.provenance`,
|
|
19004
|
+
"stake-anticipated-species",
|
|
19005
|
+
`Stake ${nodeId}: an anticipated stake cannot be a ${stakeSpecies} (nothing exists yet to have one) \u2014 reroute it as a need`
|
|
19006
|
+
);
|
|
19007
|
+
}
|
|
19008
|
+
const catalog = stakeCatalogOf(stakeNode);
|
|
19009
|
+
if (catalog && stakeSpecies !== void 0) {
|
|
19010
|
+
const quality2 = QUALITY_STAKE_SPECIES.includes(stakeSpecies);
|
|
19011
|
+
const userFacing = USER_FACING_STAKE_SPECIES.includes(stakeSpecies);
|
|
19012
|
+
if (quality2 && catalog.source === "values" || userFacing && catalog.source === "kritik") {
|
|
19013
|
+
warn(
|
|
19014
|
+
`${base}.metadata.catalog`,
|
|
19015
|
+
"stake-catalog-mismatch",
|
|
19016
|
+
`Stake ${nodeId}: a ${stakeSpecies} links to ${quality2 ? "a Kritik criterion" : "a value of the pyramid"}, not ${catalog.source}`
|
|
19017
|
+
);
|
|
19018
|
+
}
|
|
19019
|
+
}
|
|
19020
|
+
if (catalog && catalog.source === "values" && !VALUE_IDS.includes(catalog.id)) {
|
|
19021
|
+
warn(
|
|
19022
|
+
`${base}.metadata.catalog`,
|
|
19023
|
+
"stake-catalog-unknown-value",
|
|
19024
|
+
`Stake ${nodeId}: catalog value "${catalog.id}" is not a value of the pyramid`
|
|
19025
|
+
);
|
|
19026
|
+
}
|
|
19027
|
+
if (stakeSpecies !== void 0 && QUALITY_STAKE_SPECIES.includes(stakeSpecies)) {
|
|
19028
|
+
for (const field of ["felt", "matters", "frequency"]) {
|
|
19029
|
+
if (stakeMd[field] !== void 0) {
|
|
19030
|
+
warn(
|
|
19031
|
+
`${base}.metadata.${field}`,
|
|
19032
|
+
"stake-evaluation-quality-species",
|
|
19033
|
+
`Stake ${nodeId}: ${field} is for bugs, frictions and needs; a ${stakeSpecies} is read against a Kritik criterion's criticality`
|
|
19034
|
+
);
|
|
19035
|
+
}
|
|
19036
|
+
}
|
|
19037
|
+
}
|
|
19038
|
+
if (stakeSpecies === "bug" && stakeMd.felt !== void 0 && stakeMd.felt !== "expected") {
|
|
19039
|
+
warn(
|
|
19040
|
+
`${base}.metadata.felt`,
|
|
19041
|
+
"stake-bug-felt",
|
|
19042
|
+
`Stake ${nodeId}: a bug is always felt as expected (a must-be), not ${JSON.stringify(stakeMd.felt)}`
|
|
19043
|
+
);
|
|
19044
|
+
}
|
|
19045
|
+
if (stakeMd.reverify_every_days !== void 0) {
|
|
19046
|
+
const days = stakeMd.reverify_every_days;
|
|
19047
|
+
if (typeof days !== "number" || !Number.isFinite(days) || days <= 0) {
|
|
19048
|
+
warn(
|
|
19049
|
+
`${base}.metadata.reverify_every_days`,
|
|
19050
|
+
"stake-reverify-invalid",
|
|
19051
|
+
`Stake ${nodeId}: reverify_every_days must be a positive number of days, not ${JSON.stringify(days)}`
|
|
19052
|
+
);
|
|
19053
|
+
}
|
|
19054
|
+
}
|
|
19055
|
+
if (stakeMd.verified_criterion_version !== void 0) {
|
|
19056
|
+
const version2 = stakeMd.verified_criterion_version;
|
|
19057
|
+
if (typeof version2 !== "number" || !Number.isInteger(version2) || version2 < 1) {
|
|
19058
|
+
warn(
|
|
19059
|
+
`${base}.metadata.verified_criterion_version`,
|
|
19060
|
+
"stake-criterion-version-invalid",
|
|
19061
|
+
`Stake ${nodeId}: verified_criterion_version must be a positive integer, not ${JSON.stringify(version2)}`
|
|
19062
|
+
);
|
|
19063
|
+
} else if (catalog?.source !== "kritik") {
|
|
19064
|
+
warn(
|
|
19065
|
+
`${base}.metadata.verified_criterion_version`,
|
|
19066
|
+
"stake-criterion-version-unlinked",
|
|
19067
|
+
`Stake ${nodeId}: verified_criterion_version names a Kritik criterion version, but the stake has no Kritik catalog link`
|
|
19068
|
+
);
|
|
19069
|
+
}
|
|
19070
|
+
}
|
|
19071
|
+
if (!concernsSources.has(nodeId)) {
|
|
19072
|
+
warn(
|
|
19073
|
+
`${base}`,
|
|
19074
|
+
"stake-unanchored",
|
|
19075
|
+
`Stake ${nodeId}: no outgoing concerns edge \u2014 anchor it to the flow, view, data model or endpoint it is about`
|
|
19076
|
+
);
|
|
19077
|
+
}
|
|
19078
|
+
});
|
|
19079
|
+
{
|
|
19080
|
+
const speciesById = /* @__PURE__ */ new Map();
|
|
19081
|
+
const nodeById = /* @__PURE__ */ new Map();
|
|
19082
|
+
nodes.forEach((node) => {
|
|
19083
|
+
if (typeof node.id === "string") {
|
|
19084
|
+
speciesById.set(node.id, node.species);
|
|
19085
|
+
nodeById.set(node.id, node);
|
|
19086
|
+
}
|
|
19087
|
+
});
|
|
19088
|
+
const targetsOf2 = (edgeType, targetSpecies) => {
|
|
19089
|
+
const out = /* @__PURE__ */ new Map();
|
|
19090
|
+
for (const edge of edges) {
|
|
19091
|
+
if (edge.edge_type !== edgeType) continue;
|
|
19092
|
+
const from = edge.source_id;
|
|
19093
|
+
const to = edge.target_id;
|
|
19094
|
+
if (typeof from !== "string" || typeof to !== "string") continue;
|
|
19095
|
+
if (speciesById.get(to) !== targetSpecies) continue;
|
|
19096
|
+
const list = out.get(from) ?? [];
|
|
19097
|
+
if (!list.includes(to)) list.push(to);
|
|
19098
|
+
out.set(from, list);
|
|
19099
|
+
}
|
|
19100
|
+
return out;
|
|
19101
|
+
};
|
|
19102
|
+
const stakesAddressed = targetsOf2("addresses", "stake");
|
|
19103
|
+
const stakesImpacted = targetsOf2("impacts", "stake");
|
|
19104
|
+
const optionsGenerated = targetsOf2("generates", "option");
|
|
19105
|
+
const decisionsInForce = /* @__PURE__ */ new Map();
|
|
19106
|
+
for (const [decisionId, stakeIds] of stakesImpacted) {
|
|
19107
|
+
const decision = nodeById.get(decisionId);
|
|
19108
|
+
if (!decision || decision.species !== "decision") continue;
|
|
19109
|
+
const status = decisionStatusOf({ metadata: decision.metadata });
|
|
19110
|
+
if (status !== "approved" && status !== "enacted") continue;
|
|
19111
|
+
for (const stakeId of stakeIds) {
|
|
19112
|
+
const list = decisionsInForce.get(stakeId) ?? [];
|
|
19113
|
+
list.push(decisionId);
|
|
19114
|
+
decisionsInForce.set(stakeId, list);
|
|
19115
|
+
}
|
|
19116
|
+
}
|
|
19117
|
+
nodes.forEach((node, index) => {
|
|
19118
|
+
const nodeId = typeof node.id === "string" ? node.id : `#${index}`;
|
|
19119
|
+
const species = node.species;
|
|
19120
|
+
const base = `nodes[${index}]`;
|
|
19121
|
+
const md = node.metadata ?? {};
|
|
19122
|
+
if (species !== "option" && md.suggested_by !== void 0) {
|
|
19123
|
+
warn(
|
|
19124
|
+
`${base}.metadata.suggested_by`,
|
|
19125
|
+
"option-field-wrong-species",
|
|
19126
|
+
`suggested_by is meaningful on option nodes only; "${nodeId}" is a ${species}.`
|
|
19127
|
+
);
|
|
19128
|
+
}
|
|
19129
|
+
if (species !== "decision" && md.closed_options !== void 0) {
|
|
19130
|
+
warn(
|
|
19131
|
+
`${base}.metadata.closed_options`,
|
|
19132
|
+
"option-field-wrong-species",
|
|
19133
|
+
`closed_options is meaningful on decision nodes only; "${nodeId}" is a ${species}.`
|
|
19134
|
+
);
|
|
19135
|
+
}
|
|
19136
|
+
if (species === "option") {
|
|
19137
|
+
if (!OPTION_LIFECYCLE_STATUSES.includes(node.status)) {
|
|
19138
|
+
warn(
|
|
19139
|
+
`${base}.status`,
|
|
19140
|
+
"option-lifecycle",
|
|
19141
|
+
`Option ${nodeId}: status "${node.status}" is not stored on an option (idea, discovery or archived only; selected and closed are read from its decision)`
|
|
19142
|
+
);
|
|
19143
|
+
}
|
|
19144
|
+
const addressed = stakesAddressed.get(nodeId) ?? [];
|
|
19145
|
+
if (addressed.length === 0) {
|
|
19146
|
+
warn(
|
|
19147
|
+
`${base}`,
|
|
19148
|
+
"option-unaddressed",
|
|
19149
|
+
`Option ${nodeId}: no outgoing addresses edge to a stake \u2014 an option never exists without the stake it addresses`
|
|
19150
|
+
);
|
|
19151
|
+
}
|
|
19152
|
+
const answerTypes = /* @__PURE__ */ new Set();
|
|
19153
|
+
for (const stakeId of addressed) {
|
|
19154
|
+
const stakeSpecies = stakeSpeciesOf({ metadata: nodeById.get(stakeId)?.metadata });
|
|
19155
|
+
if (stakeSpecies !== void 0) answerTypes.add(ANSWER_TYPE_FOR_STAKE_SPECIES[stakeSpecies]);
|
|
19156
|
+
}
|
|
19157
|
+
if (answerTypes.size > 1) {
|
|
19158
|
+
warn(
|
|
19159
|
+
`${base}`,
|
|
19160
|
+
"option-mixed-answer-types",
|
|
19161
|
+
`Option ${nodeId}: addresses stakes that ask for different answers (${[...answerTypes].join(", ")}) \u2014 split it into one option per answer type`
|
|
19162
|
+
);
|
|
19163
|
+
}
|
|
19164
|
+
return;
|
|
19165
|
+
}
|
|
19166
|
+
if (species === "decision") {
|
|
19167
|
+
const impacted = stakesImpacted.get(nodeId) ?? [];
|
|
19168
|
+
const generated = optionsGenerated.get(nodeId) ?? [];
|
|
19169
|
+
if (impacted.length > 1) {
|
|
19170
|
+
warn(
|
|
19171
|
+
`${base}`,
|
|
19172
|
+
"decision-multiple-stakes",
|
|
19173
|
+
`Decision ${nodeId}: impacts ${impacted.length} stakes (${impacted.join(", ")}) \u2014 a decision settles one stake`
|
|
19174
|
+
);
|
|
19175
|
+
}
|
|
19176
|
+
if (generated.length > 1) {
|
|
19177
|
+
warn(
|
|
19178
|
+
`${base}`,
|
|
19179
|
+
"decision-multiple-options",
|
|
19180
|
+
`Decision ${nodeId}: generates ${generated.length} options (${generated.join(", ")}) \u2014 a decision selects one option; the others go in closed_options`
|
|
19181
|
+
);
|
|
19182
|
+
}
|
|
19183
|
+
if (impacted.length > 0) {
|
|
19184
|
+
for (const optionId of generated) {
|
|
19185
|
+
const addressed = stakesAddressed.get(optionId) ?? [];
|
|
19186
|
+
if (!impacted.some((stakeId) => addressed.includes(stakeId))) {
|
|
19187
|
+
warn(
|
|
19188
|
+
`${base}`,
|
|
19189
|
+
"decision-option-not-addressing",
|
|
19190
|
+
`Decision ${nodeId}: generates option ${optionId}, which does not address the stake the decision impacts (${impacted.join(", ")})`
|
|
19191
|
+
);
|
|
19192
|
+
}
|
|
19193
|
+
}
|
|
19194
|
+
}
|
|
19195
|
+
const closed = md.closed_options;
|
|
19196
|
+
if (Array.isArray(closed)) {
|
|
19197
|
+
closed.forEach((entry, i) => {
|
|
19198
|
+
const optionId = typeof entry === "object" && entry !== null ? entry.option_id : void 0;
|
|
19199
|
+
if (typeof optionId !== "string" || speciesById.get(optionId) !== "option") {
|
|
19200
|
+
warn(
|
|
19201
|
+
`${base}.metadata.closed_options[${i}].option_id`,
|
|
19202
|
+
"decision-closed-option-unknown",
|
|
19203
|
+
`Decision ${nodeId}: closed_options[${i}] names ${typeof optionId === "string" ? `"${optionId}"` : "no option id"}, which is not an option in this bundle`
|
|
19204
|
+
);
|
|
19205
|
+
}
|
|
19206
|
+
});
|
|
19207
|
+
}
|
|
19208
|
+
return;
|
|
19209
|
+
}
|
|
19210
|
+
if (species === "stake") {
|
|
19211
|
+
const inForce = decisionsInForce.get(nodeId) ?? [];
|
|
19212
|
+
if (inForce.length > 1) {
|
|
19213
|
+
warn(
|
|
19214
|
+
`${base}`,
|
|
19215
|
+
"stake-multiple-decisions",
|
|
19216
|
+
`Stake ${nodeId}: ${inForce.length} approved or enacted decisions impact it (${inForce.join(", ")}) \u2014 supersede the earlier one`
|
|
19217
|
+
);
|
|
19218
|
+
}
|
|
19219
|
+
}
|
|
19220
|
+
});
|
|
19221
|
+
}
|
|
18373
19222
|
const PLAYLIST_ENTRY_TYPES = ["view", "flow", "condition", "junction"];
|
|
18374
19223
|
const checkPlaylistShape = (entries, flowId, path, depth = 0) => {
|
|
18375
19224
|
if (depth > 50) return;
|
|
@@ -18708,32 +19557,17 @@ function validateBundle(input) {
|
|
|
18708
19557
|
const embeddedJournal = Array.isArray(bundle.journal) ? bundle.journal : [];
|
|
18709
19558
|
const weighingSpecies = /* @__PURE__ */ new Map();
|
|
18710
19559
|
for (const [id, node] of nodeMap) weighingSpecies.set(id, String(node.species));
|
|
18711
|
-
|
|
19560
|
+
const weighingStakeSpecies = /* @__PURE__ */ new Map();
|
|
19561
|
+
for (const [id, node] of nodeMap) {
|
|
19562
|
+
if (node.species === "stake") weighingStakeSpecies.set(id, stakeSpeciesOf({ metadata: node.metadata }));
|
|
19563
|
+
}
|
|
19564
|
+
for (const finding of validateWeighingSection(weighing, weighingSpecies, embeddedJournal, weighingStakeSpecies)) {
|
|
18712
19565
|
warn(finding.path, finding.rule, finding.message);
|
|
18713
19566
|
}
|
|
18714
19567
|
for (const finding of crossCheckJournal(bundle)) findings.push(finding);
|
|
18715
19568
|
return result();
|
|
18716
19569
|
}
|
|
18717
19570
|
|
|
18718
|
-
// ../schema/src/acceptance.ts
|
|
18719
|
-
var DEFAULT_DELIVERED_STATUSES = ["live"];
|
|
18720
|
-
function resolvePlatformStatus(node, platform) {
|
|
18721
|
-
if (!node.platforms.includes(platform)) return void 0;
|
|
18722
|
-
return node.metadata?.platformStatuses?.[platform] ?? node.status;
|
|
18723
|
-
}
|
|
18724
|
-
function hasParityGap(node, deliveredStatuses = DEFAULT_DELIVERED_STATUSES) {
|
|
18725
|
-
if (node.status === "archived") return false;
|
|
18726
|
-
const resolved = node.platforms.map((platform) => resolvePlatformStatus(node, platform)).filter((status) => status !== void 0);
|
|
18727
|
-
const delivered = resolved.filter((status) => deliveredStatuses.includes(status));
|
|
18728
|
-
return delivered.length > 0 && delivered.length < resolved.length;
|
|
18729
|
-
}
|
|
18730
|
-
function acceptancesCovering(anchorId, nodes, edges) {
|
|
18731
|
-
const coveringIds = new Set(
|
|
18732
|
-
edges.filter((edge) => edge.edge_type === "covers" && edge.target_id === anchorId).map((edge) => edge.source_id)
|
|
18733
|
-
);
|
|
18734
|
-
return nodes.filter((node) => node.species === "acceptance" && coveringIds.has(node.id));
|
|
18735
|
-
}
|
|
18736
|
-
|
|
18737
19571
|
// ../schema/src/serialize.ts
|
|
18738
19572
|
var BUNDLE_KEY_ORDER = ["schema_version", "project", "nodes", "edges", "journal"];
|
|
18739
19573
|
var PROJECT_KEY_ORDER = [
|
|
@@ -18832,7 +19666,7 @@ function serializeBundle(bundle) {
|
|
|
18832
19666
|
function asString(value) {
|
|
18833
19667
|
return typeof value === "string" ? value : void 0;
|
|
18834
19668
|
}
|
|
18835
|
-
function computeNodeTimeline(events, nodeId) {
|
|
19669
|
+
function computeNodeTimeline(events, nodeId, options = {}) {
|
|
18836
19670
|
const edgeEndpoints = /* @__PURE__ */ new Map();
|
|
18837
19671
|
for (const ev of events) {
|
|
18838
19672
|
if (ev.type === "edge.added") {
|
|
@@ -18847,6 +19681,10 @@ function computeNodeTimeline(events, nodeId) {
|
|
|
18847
19681
|
}
|
|
18848
19682
|
const touches = (ev) => {
|
|
18849
19683
|
if (asString(ev.node_id) === nodeId) return true;
|
|
19684
|
+
if (ev.type === "request.filed") {
|
|
19685
|
+
if (signalStakeIds(ev).includes(nodeId)) return true;
|
|
19686
|
+
if (options.evidenceEventIds?.has(ev.id)) return true;
|
|
19687
|
+
}
|
|
18850
19688
|
if (ev.type === "edge.added") {
|
|
18851
19689
|
const edge = ev;
|
|
18852
19690
|
return asString(edge.source_id) === nodeId || asString(edge.target_id) === nodeId;
|
|
@@ -18939,7 +19777,7 @@ function computeBacklog(events, options = {}) {
|
|
|
18939
19777
|
for (const ev of ordered) {
|
|
18940
19778
|
if (ev.type !== "idea.proposed" && ev.type !== "request.filed") continue;
|
|
18941
19779
|
const linkedId = asString(ev.node_id);
|
|
18942
|
-
const closed = linkedId !== void 0 && existing.has(linkedId);
|
|
19780
|
+
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
19781
|
if (!closed) items.push(ev);
|
|
18944
19782
|
}
|
|
18945
19783
|
return {
|
|
@@ -20324,18 +21162,26 @@ function planWeighingEvents(section, nodes, inputs, ctx) {
|
|
|
20324
21162
|
const problem = assessmentProblem(entry);
|
|
20325
21163
|
if (problem !== void 0) return refuse("invalid_entry", problem);
|
|
20326
21164
|
const input = entry;
|
|
20327
|
-
const
|
|
21165
|
+
const node = byId.get(input.subject);
|
|
21166
|
+
const matrixId = input.matrix ?? (node?.species === "stake" ? STAKE_MATRIX_ID : VALUE_MATRIX_ID);
|
|
21167
|
+
const matrix = resolved.matrices.find((candidate) => candidate.id === matrixId);
|
|
20328
21168
|
if (matrix === void 0) {
|
|
20329
|
-
return refuse("unknown_matrix", `no matrix "${
|
|
21169
|
+
return refuse("unknown_matrix", `no matrix "${matrixId}" (have: ${resolved.matrices.map((m) => m.id).join(", ")})`);
|
|
20330
21170
|
}
|
|
20331
21171
|
const set2 = setOfRef(resolved, matrix.set);
|
|
20332
21172
|
if (set2 === void 0) return refuse("unknown_matrix", `matrix "${matrix.id}" names set "${matrix.set}", which is not available`);
|
|
20333
21173
|
if (isOlderMajorRef(resolved, matrix.set)) {
|
|
20334
21174
|
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
21175
|
}
|
|
20336
|
-
|
|
20337
|
-
|
|
20338
|
-
|
|
21176
|
+
if (node === void 0 || !isMatrixSubject(node, matrix, set2)) {
|
|
21177
|
+
if (node?.species === "stake" && matrix.subjects.kind === "query" && matrix.subjects.species === "stake") {
|
|
21178
|
+
const kind = stakeSpeciesOf(node);
|
|
21179
|
+
const declared2 = stakeSpeciesDeclaredBy(set2);
|
|
21180
|
+
return refuse(
|
|
21181
|
+
"unknown_subject",
|
|
21182
|
+
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" : ""}`
|
|
21183
|
+
);
|
|
21184
|
+
}
|
|
20339
21185
|
return refuse("unknown_subject", `"${input.subject}" is not a subject of matrix "${matrix.id}"`);
|
|
20340
21186
|
}
|
|
20341
21187
|
const criterion = set2.criteria.find((candidate) => candidate.id === input.criterion);
|
|
@@ -20368,7 +21214,7 @@ function planWeighingEvents(section, nodes, inputs, ctx) {
|
|
|
20368
21214
|
...input.evidence !== void 0 ? { evidence: input.evidence } : {},
|
|
20369
21215
|
...input.refs !== void 0 ? { refs: input.refs } : {},
|
|
20370
21216
|
basis: {
|
|
20371
|
-
fingerprint:
|
|
21217
|
+
fingerprint: fingerprintOf(node),
|
|
20372
21218
|
set_version: set2.version,
|
|
20373
21219
|
...input.commit !== void 0 ? { commit: input.commit } : {}
|
|
20374
21220
|
},
|
|
@@ -20411,7 +21257,7 @@ function claimedElements(node, set2) {
|
|
|
20411
21257
|
return out;
|
|
20412
21258
|
}
|
|
20413
21259
|
function seedAssessments(node, matrix, set2) {
|
|
20414
|
-
const fingerprint =
|
|
21260
|
+
const fingerprint = fingerprintOf(node);
|
|
20415
21261
|
return claimedElements(node, set2).map((criterion, position) => ({
|
|
20416
21262
|
matrix: matrix.id,
|
|
20417
21263
|
subject: node.id,
|
|
@@ -20519,11 +21365,12 @@ function keptShare(node) {
|
|
|
20519
21365
|
}
|
|
20520
21366
|
var share = (guess, total) => total > 0 ? guess / total : 0;
|
|
20521
21367
|
function weighPromise(node, ctx) {
|
|
20522
|
-
const fingerprint =
|
|
21368
|
+
const fingerprint = fingerprintOf(node);
|
|
20523
21369
|
const current = { fingerprint, setVersion: ctx.set.version };
|
|
20524
|
-
const
|
|
21370
|
+
const isStake = node.species === "stake";
|
|
21371
|
+
const claimedList = isStake ? [] : claimedElements(node, ctx.set);
|
|
20525
21372
|
const claimedSet = new Set(claimedList);
|
|
20526
|
-
const seeds = new Map(seedAssessments(node, ctx.matrix, ctx.set).map((seed) => [seed.criterion, seed]));
|
|
21373
|
+
const seeds = new Map((isStake ? [] : seedAssessments(node, ctx.matrix, ctx.set)).map((seed) => [seed.criterion, seed]));
|
|
20527
21374
|
const order = [...claimedList, ...ctx.set.criteria.map((criterion) => criterion.id).filter((id) => !claimedSet.has(id))];
|
|
20528
21375
|
const cells = [];
|
|
20529
21376
|
for (const criterion of order) {
|
|
@@ -20564,7 +21411,7 @@ function weighPromise(node, ctx) {
|
|
|
20564
21411
|
if (cell.stale) stale.push(cell.criterion);
|
|
20565
21412
|
if (cell.review) review.push(cell.criterion);
|
|
20566
21413
|
if (cell.uncertain) uncertain.push(cell.criterion);
|
|
20567
|
-
if (cell.source === "stored") {
|
|
21414
|
+
if (cell.source === "stored" && !isStake) {
|
|
20568
21415
|
if (cell.claimed) {
|
|
20569
21416
|
if (cell.level < 0) flags.claim_contradicted.push(cell.criterion);
|
|
20570
21417
|
else if (cell.level === 0) flags.claim_not_supported.push(cell.criterion);
|
|
@@ -20594,14 +21441,13 @@ function weighPromise(node, ctx) {
|
|
|
20594
21441
|
uncertain
|
|
20595
21442
|
};
|
|
20596
21443
|
}
|
|
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;
|
|
21444
|
+
function matrixSubjects(nodes, matrix, set2) {
|
|
20600
21445
|
const seen = /* @__PURE__ */ new Set();
|
|
20601
21446
|
const out = [];
|
|
20602
21447
|
for (const node of nodes) {
|
|
20603
21448
|
if (seen.has(node.id)) continue;
|
|
20604
|
-
|
|
21449
|
+
const judged = set2 === void 0 && matrix.subjects.kind === "query" ? node.species === matrix.subjects.species : isMatrixSubject(node, matrix, set2);
|
|
21450
|
+
if (!judged) continue;
|
|
20605
21451
|
seen.add(node.id);
|
|
20606
21452
|
out.push(node);
|
|
20607
21453
|
}
|
|
@@ -20610,7 +21456,7 @@ function matrixSubjects(nodes, matrix) {
|
|
|
20610
21456
|
function deriveWeighing(nodes, section, matrixId = VALUE_MATRIX_ID) {
|
|
20611
21457
|
const ctx = buildWeighingContext(section, matrixId);
|
|
20612
21458
|
if (ctx === void 0) return void 0;
|
|
20613
|
-
const promises = matrixSubjects(nodes, ctx.matrix).map((node) => weighPromise(node, ctx));
|
|
21459
|
+
const promises = matrixSubjects(nodes, ctx.matrix, ctx.set).map((node) => weighPromise(node, ctx));
|
|
20614
21460
|
const empty = () => ({ promised: 0, promisedGuess: 0, kept: 0, keptGuess: 0, cost: 0, costGuess: 0 });
|
|
20615
21461
|
const raw = new Map(ctx.set.criteria.map((criterion) => [criterion.id, empty()]));
|
|
20616
21462
|
let assessed = 0;
|
|
@@ -20673,6 +21519,670 @@ function sortPromises(promises, key) {
|
|
|
20673
21519
|
return [...promises].sort((a, b) => key === "title" ? byTitle(a, b) : value(b) - value(a) || byTitle(a, b));
|
|
20674
21520
|
}
|
|
20675
21521
|
|
|
21522
|
+
// ../schema/src/qualify.ts
|
|
21523
|
+
var QUALIFY_DOORS = ["collect", "imagine"];
|
|
21524
|
+
var QUALIFY_SCOPES = ["product", "internal", "off-scope"];
|
|
21525
|
+
var QUALIFY_FACINGS = ["value", "quality"];
|
|
21526
|
+
var QUALIFY_EXPECTATIONS = ["broken", "as-designed", "absent"];
|
|
21527
|
+
var QUALIFY_THREATS = ["obligation", "own-flaw", "mitigable-only"];
|
|
21528
|
+
var QUALIFY_BASES = ["stated", "inferred"];
|
|
21529
|
+
var ROUTING_QUESTIONS = [
|
|
21530
|
+
{
|
|
21531
|
+
id: "scope",
|
|
21532
|
+
question: "Is this about the product a person meets?",
|
|
21533
|
+
answers: {
|
|
21534
|
+
product: "continue",
|
|
21535
|
+
internal: "routed out: about operating the product (CI, telemetry, maker analytics), nobody experiences it",
|
|
21536
|
+
"off-scope": "routed out: not this product's business"
|
|
21537
|
+
},
|
|
21538
|
+
askedWhen: "always, first"
|
|
21539
|
+
},
|
|
21540
|
+
{
|
|
21541
|
+
id: "door",
|
|
21542
|
+
question: "Does the product exist and do people use it (collect), or is it still being shaped (imagine)?",
|
|
21543
|
+
answers: {
|
|
21544
|
+
collect: "observed; all six species are open",
|
|
21545
|
+
imagine: "anticipated; only need, requirement, risk and defect are open (nothing exists yet to have a bug or a friction)"
|
|
21546
|
+
},
|
|
21547
|
+
askedWhen: "after scope is product"
|
|
21548
|
+
},
|
|
21549
|
+
{
|
|
21550
|
+
id: "facing",
|
|
21551
|
+
question: "Does it face a person's value, or the product's quality and obligations?",
|
|
21552
|
+
answers: {
|
|
21553
|
+
value: "bug, friction or need: weighed on the value pyramid",
|
|
21554
|
+
quality: "requirement, risk or defect: read against Kritik criteria"
|
|
21555
|
+
},
|
|
21556
|
+
askedWhen: "after door"
|
|
21557
|
+
},
|
|
21558
|
+
{
|
|
21559
|
+
id: "expectation",
|
|
21560
|
+
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)?",
|
|
21561
|
+
answers: {
|
|
21562
|
+
broken: "bug",
|
|
21563
|
+
"as-designed": "friction",
|
|
21564
|
+
absent: "need"
|
|
21565
|
+
},
|
|
21566
|
+
askedWhen: "facing is value"
|
|
21567
|
+
},
|
|
21568
|
+
{
|
|
21569
|
+
id: "threat",
|
|
21570
|
+
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)?",
|
|
21571
|
+
answers: {
|
|
21572
|
+
obligation: "requirement",
|
|
21573
|
+
"own-flaw": "defect",
|
|
21574
|
+
"mitigable-only": "risk"
|
|
21575
|
+
},
|
|
21576
|
+
askedWhen: "facing is quality"
|
|
21577
|
+
},
|
|
21578
|
+
{
|
|
21579
|
+
id: "basis",
|
|
21580
|
+
question: "Did the source say this (stated), or is it the analyst's hypothesis (inferred)?",
|
|
21581
|
+
answers: {
|
|
21582
|
+
stated: "carried through as stated",
|
|
21583
|
+
inferred: "a person must confirm before the species is trusted"
|
|
21584
|
+
},
|
|
21585
|
+
askedWhen: "optional; defaults to stated"
|
|
21586
|
+
}
|
|
21587
|
+
];
|
|
21588
|
+
var SPECIES_BY_EXPECTATION = { broken: "bug", "as-designed": "friction", absent: "need" };
|
|
21589
|
+
var SPECIES_BY_THREAT = { obligation: "requirement", "own-flaw": "defect", "mitigable-only": "risk" };
|
|
21590
|
+
function inList(list, value) {
|
|
21591
|
+
return list.includes(value);
|
|
21592
|
+
}
|
|
21593
|
+
function routeSpecies(answers) {
|
|
21594
|
+
const handToHuman = [];
|
|
21595
|
+
const reasons = [];
|
|
21596
|
+
const out = (route, extra = {}) => ({ route, ask: [], reasons, handToHuman, ...extra });
|
|
21597
|
+
const reached = (species2, provenance2) => {
|
|
21598
|
+
if (provenance2 === "anticipated") {
|
|
21599
|
+
handToHuman.push("Anticipated (imagine door): nobody has met this yet, so the stake is inferred until a person confirms it.");
|
|
21600
|
+
}
|
|
21601
|
+
return out("stake", { species: species2, provenance: provenance2 });
|
|
21602
|
+
};
|
|
21603
|
+
const basis = inList(QUALIFY_BASES, answers.basis) ? answers.basis : "stated";
|
|
21604
|
+
if (basis === "inferred") handToHuman.push("The answers are inferred, not stated: a person confirms the species before it is trusted.");
|
|
21605
|
+
const scope = inList(QUALIFY_SCOPES, answers.scope) ? answers.scope : void 0;
|
|
21606
|
+
if (scope === void 0) return out("incomplete", { ask: ["scope"], reasons: ["scope is not answered"] });
|
|
21607
|
+
if (scope !== "product") {
|
|
21608
|
+
reasons.push(`Routed out as ${scope}: it is not a stake to weigh.`);
|
|
21609
|
+
handToHuman.push(`Routed out as ${scope}: a person can overrule it. Nothing is written; the signal stays in the journal.`);
|
|
21610
|
+
return out(scope);
|
|
21611
|
+
}
|
|
21612
|
+
const door = inList(QUALIFY_DOORS, answers.door) ? answers.door : void 0;
|
|
21613
|
+
if (door === void 0) return out("incomplete", { ask: ["door"], reasons: ["door is not answered"] });
|
|
21614
|
+
const provenance = door === "collect" ? "observed" : "anticipated";
|
|
21615
|
+
const facing = inList(QUALIFY_FACINGS, answers.facing) ? answers.facing : void 0;
|
|
21616
|
+
if (facing === void 0) return out("incomplete", { ask: ["facing"], provenance, reasons: ["facing is not answered"] });
|
|
21617
|
+
if (facing === "value") {
|
|
21618
|
+
const expectation = inList(QUALIFY_EXPECTATIONS, answers.expectation) ? answers.expectation : void 0;
|
|
21619
|
+
if (expectation === void 0) return out("incomplete", { ask: ["expectation"], provenance, reasons: ["expectation is not answered"] });
|
|
21620
|
+
const species2 = SPECIES_BY_EXPECTATION[expectation];
|
|
21621
|
+
if (door === "imagine" && !ANTICIPATED_STAKE_SPECIES.includes(species2)) {
|
|
21622
|
+
reasons.push(`An anticipated stake is never a ${species2}: nothing exists yet to have one. Reroute as need.`);
|
|
21623
|
+
handToHuman.push(`Refused: a ${species2} cannot come through the imagine door. Reroute as need, or take the collect door if the product exists.`);
|
|
21624
|
+
return out("refused", { provenance, rerouteAs: "need" });
|
|
21625
|
+
}
|
|
21626
|
+
reasons.push(`Value-facing, ${expectation}: ${species2}.`);
|
|
21627
|
+
return reached(species2, provenance);
|
|
21628
|
+
}
|
|
21629
|
+
const threat = inList(QUALIFY_THREATS, answers.threat) ? answers.threat : void 0;
|
|
21630
|
+
if (threat === void 0) return out("incomplete", { ask: ["threat"], provenance, reasons: ["threat is not answered"] });
|
|
21631
|
+
const species = SPECIES_BY_THREAT[threat];
|
|
21632
|
+
reasons.push(`Quality-facing, ${threat}: ${species}.`);
|
|
21633
|
+
return reached(species, provenance);
|
|
21634
|
+
}
|
|
21635
|
+
var MERGE_HIGH = 0.6;
|
|
21636
|
+
var MERGE_MEDIUM = 0.35;
|
|
21637
|
+
var MERGE_LOW = 0.15;
|
|
21638
|
+
var WEIGHT_CATALOG = 0.35;
|
|
21639
|
+
var WEIGHT_ANCHOR = 0.25;
|
|
21640
|
+
var WEIGHT_TEXT = 0.4;
|
|
21641
|
+
var STOPWORDS = /* @__PURE__ */ new Set([
|
|
21642
|
+
"the",
|
|
21643
|
+
"and",
|
|
21644
|
+
"for",
|
|
21645
|
+
"with",
|
|
21646
|
+
"that",
|
|
21647
|
+
"this",
|
|
21648
|
+
"from",
|
|
21649
|
+
"are",
|
|
21650
|
+
"was",
|
|
21651
|
+
"has",
|
|
21652
|
+
"not",
|
|
21653
|
+
"but",
|
|
21654
|
+
"can",
|
|
21655
|
+
"when",
|
|
21656
|
+
"you",
|
|
21657
|
+
"your",
|
|
21658
|
+
"its",
|
|
21659
|
+
"have",
|
|
21660
|
+
"had",
|
|
21661
|
+
"will",
|
|
21662
|
+
"would",
|
|
21663
|
+
"into",
|
|
21664
|
+
"than",
|
|
21665
|
+
"then",
|
|
21666
|
+
"they",
|
|
21667
|
+
"them",
|
|
21668
|
+
"there",
|
|
21669
|
+
"what",
|
|
21670
|
+
"which",
|
|
21671
|
+
"who",
|
|
21672
|
+
"how",
|
|
21673
|
+
"why",
|
|
21674
|
+
"all",
|
|
21675
|
+
"any",
|
|
21676
|
+
"out",
|
|
21677
|
+
"off",
|
|
21678
|
+
"too",
|
|
21679
|
+
"very",
|
|
21680
|
+
"just",
|
|
21681
|
+
"les",
|
|
21682
|
+
"des",
|
|
21683
|
+
"une",
|
|
21684
|
+
"pour",
|
|
21685
|
+
"que",
|
|
21686
|
+
"qui",
|
|
21687
|
+
"dans",
|
|
21688
|
+
"sur",
|
|
21689
|
+
"pas",
|
|
21690
|
+
"est",
|
|
21691
|
+
"mon",
|
|
21692
|
+
"mes",
|
|
21693
|
+
"son",
|
|
21694
|
+
"ses",
|
|
21695
|
+
"avec",
|
|
21696
|
+
"sans",
|
|
21697
|
+
"plus",
|
|
21698
|
+
"par"
|
|
21699
|
+
]);
|
|
21700
|
+
function tokens(text) {
|
|
21701
|
+
const out = /* @__PURE__ */ new Set();
|
|
21702
|
+
for (const word of kebabCase(text).split("-")) {
|
|
21703
|
+
if (word.length >= 3 && !STOPWORDS.has(word)) out.add(word);
|
|
21704
|
+
}
|
|
21705
|
+
return out;
|
|
21706
|
+
}
|
|
21707
|
+
function jaccard(a, b) {
|
|
21708
|
+
if (a.size === 0 || b.size === 0) return 0;
|
|
21709
|
+
let shared = 0;
|
|
21710
|
+
for (const item of a) if (b.has(item)) shared += 1;
|
|
21711
|
+
return shared / (a.size + b.size - shared);
|
|
21712
|
+
}
|
|
21713
|
+
var round3 = (value) => Math.round(value * 1e3) / 1e3;
|
|
21714
|
+
function stakeAnchors(stakeId, edges) {
|
|
21715
|
+
const anchors = /* @__PURE__ */ new Set();
|
|
21716
|
+
for (const edge of edges) if (edge.edge_type === "concerns" && edge.source_id === stakeId) anchors.add(edge.target_id);
|
|
21717
|
+
return [...anchors].sort();
|
|
21718
|
+
}
|
|
21719
|
+
function findMergeCandidates(signal, stakes, options = {}) {
|
|
21720
|
+
const edges = options.edges ?? [];
|
|
21721
|
+
const signalAnchors = new Set(signal.node_ids ?? []);
|
|
21722
|
+
const signalWords = tokens(`${signal.title} ${signal.verbatim ?? ""}`);
|
|
21723
|
+
const found = [];
|
|
21724
|
+
for (const stake of stakes) {
|
|
21725
|
+
if (stake.species !== "stake" || stakeSpeciesOf(stake) !== signal.species) continue;
|
|
21726
|
+
const reasons = [];
|
|
21727
|
+
const alreadyCited = signal.event_id !== void 0 && stakeEvidenceOf(stake).some((entry) => entry.event_id === signal.event_id);
|
|
21728
|
+
const anchors = new Set(stakeAnchors(stake.id, edges));
|
|
21729
|
+
let score = 0;
|
|
21730
|
+
if (alreadyCited) {
|
|
21731
|
+
score = 1;
|
|
21732
|
+
reasons.push("This stake already cites the signal as evidence.");
|
|
21733
|
+
} else {
|
|
21734
|
+
const anchorScore = jaccard(signalAnchors, anchors);
|
|
21735
|
+
const catalog = stakeCatalogOf(stake);
|
|
21736
|
+
const sameCatalog = signal.catalog_id !== void 0 && catalog?.id === signal.catalog_id;
|
|
21737
|
+
const anchorsAgree = anchorScore > 0;
|
|
21738
|
+
if (sameCatalog) {
|
|
21739
|
+
score += anchorsAgree ? WEIGHT_CATALOG : WEIGHT_CATALOG / 2;
|
|
21740
|
+
reasons.push(
|
|
21741
|
+
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.`
|
|
21742
|
+
);
|
|
21743
|
+
}
|
|
21744
|
+
if (anchorScore > 0) {
|
|
21745
|
+
score += WEIGHT_ANCHOR * anchorScore;
|
|
21746
|
+
reasons.push(`Shares an anchor (${[...signalAnchors].filter((id) => anchors.has(id)).join(", ")}).`);
|
|
21747
|
+
}
|
|
21748
|
+
const textScore = jaccard(signalWords, tokens(`${stake.title} ${stake.description ?? ""}`));
|
|
21749
|
+
if (textScore > 0) {
|
|
21750
|
+
score += WEIGHT_TEXT * textScore;
|
|
21751
|
+
reasons.push(`Shares words with the title (${Math.round(textScore * 100)}% overlap).`);
|
|
21752
|
+
}
|
|
21753
|
+
}
|
|
21754
|
+
const rounded = round3(Math.min(score, 1));
|
|
21755
|
+
if (rounded < MERGE_LOW) continue;
|
|
21756
|
+
found.push({
|
|
21757
|
+
stake_id: stake.id,
|
|
21758
|
+
title: stake.title,
|
|
21759
|
+
status: stake.status,
|
|
21760
|
+
stake_species: signal.species,
|
|
21761
|
+
score: rounded,
|
|
21762
|
+
confidence: rounded >= MERGE_HIGH ? "high" : rounded >= MERGE_MEDIUM ? "medium" : "low",
|
|
21763
|
+
reasons,
|
|
21764
|
+
archived: stake.status === "archived",
|
|
21765
|
+
alreadyCited,
|
|
21766
|
+
countsAsEvidence: signal.source_kind !== "benchmark"
|
|
21767
|
+
});
|
|
21768
|
+
}
|
|
21769
|
+
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);
|
|
21770
|
+
return found.slice(0, options.limit ?? 5);
|
|
21771
|
+
}
|
|
21772
|
+
function evidenceEntryFor(signal) {
|
|
21773
|
+
const entry = {
|
|
21774
|
+
...signal.event_id !== void 0 ? { event_id: signal.event_id } : {},
|
|
21775
|
+
...signal.verbatim !== void 0 && signal.verbatim !== "" ? { quote: signal.verbatim } : {},
|
|
21776
|
+
...signal.voice !== void 0 ? { voice: signal.voice } : {},
|
|
21777
|
+
...signal.date !== void 0 ? { date: signal.date } : {}
|
|
21778
|
+
};
|
|
21779
|
+
if (Object.keys(entry).length === 0) entry.quote = signal.title;
|
|
21780
|
+
return entry;
|
|
21781
|
+
}
|
|
21782
|
+
function refused(reasons) {
|
|
21783
|
+
return { action: "refused", ops: [], reasons, handToHuman: [] };
|
|
21784
|
+
}
|
|
21785
|
+
function stakeCiting(nodes, eventId) {
|
|
21786
|
+
if (eventId === void 0) return void 0;
|
|
21787
|
+
return nodes.find((node) => node.species === "stake" && stakeEvidenceOf(node).some((entry) => entry.event_id === eventId));
|
|
21788
|
+
}
|
|
21789
|
+
function planSignalToStake(input) {
|
|
21790
|
+
const { signal, species, provenance, nodes } = input;
|
|
21791
|
+
const cited = stakeCiting(nodes, signal.event_id);
|
|
21792
|
+
if (cited !== void 0) {
|
|
21793
|
+
const citedSpecies = stakeSpeciesOf(cited);
|
|
21794
|
+
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.`] : [];
|
|
21795
|
+
return { action: "noop", ops: [], stake_id: cited.id, reasons: [`${cited.id} already cites this signal as evidence.`], handToHuman: handToHuman2 };
|
|
21796
|
+
}
|
|
21797
|
+
const problems = [];
|
|
21798
|
+
if (provenance === "anticipated" && !ANTICIPATED_STAKE_SPECIES.includes(species)) {
|
|
21799
|
+
problems.push(`An anticipated stake is never a ${species}: reroute as need.`);
|
|
21800
|
+
}
|
|
21801
|
+
if (input.catalog !== void 0 && input.catalog.source !== catalogSourceForStakeSpecies(species)) {
|
|
21802
|
+
problems.push(`A ${species} links to the ${catalogSourceForStakeSpecies(species)} catalog, not ${input.catalog.source}.`);
|
|
21803
|
+
}
|
|
21804
|
+
if (input.catalog !== void 0 && input.catalog.source === "values" && !VALUE_IDS.includes(input.catalog.id)) {
|
|
21805
|
+
problems.push(`"${input.catalog.id}" is not a value of the pyramid: a ${species} links to one of the 30 value ids.`);
|
|
21806
|
+
}
|
|
21807
|
+
const anchors = [...new Set(input.anchors ?? [])];
|
|
21808
|
+
const byId = new Map(nodes.map((node2) => [node2.id, node2]));
|
|
21809
|
+
for (const anchor of anchors) {
|
|
21810
|
+
const target = byId.get(anchor);
|
|
21811
|
+
if (target === void 0) problems.push(`Anchor "${anchor}" does not exist.`);
|
|
21812
|
+
else if (!STAKE_ANCHOR_SPECIES.includes(target.species)) {
|
|
21813
|
+
problems.push(`Anchor "${anchor}" is a ${target.species}: a stake concerns a flow, view, data model or endpoint.`);
|
|
21814
|
+
}
|
|
21815
|
+
}
|
|
21816
|
+
const title = (input.title ?? signal.title).trim();
|
|
21817
|
+
if (title === "") problems.push("A stake needs a title.");
|
|
21818
|
+
if (problems.length > 0) return refused(problems);
|
|
21819
|
+
const id = deriveNodeId("stake", title, nodes.map((node2) => node2.id));
|
|
21820
|
+
const metadata = stakeMetadataWith(void 0, {
|
|
21821
|
+
stake_species: species,
|
|
21822
|
+
provenance,
|
|
21823
|
+
...input.catalog !== void 0 ? { catalog: input.catalog } : {}
|
|
21824
|
+
});
|
|
21825
|
+
metadata.evidence = [evidenceEntryFor(signal)];
|
|
21826
|
+
const node = { id, project_id: input.projectId, title, species: "stake", status: "idea", platforms: [], metadata };
|
|
21827
|
+
const ops = [{ op: "create_node", node }];
|
|
21828
|
+
for (const anchor of anchors) {
|
|
21829
|
+
ops.push({ op: "create_edge", edge: { id: edgeId(id, anchor), project_id: input.projectId, source_id: id, target_id: anchor, edge_type: "concerns" } });
|
|
21830
|
+
}
|
|
21831
|
+
const handToHuman = [];
|
|
21832
|
+
if (anchors.length === 0) handToHuman.push("The stake has no anchor yet: name the flow, view, data model or endpoint it concerns.");
|
|
21833
|
+
if (input.title === void 0) handToHuman.push("The stake carries the signal's own title: reword it positively and solution-neutrally.");
|
|
21834
|
+
return { action: "create", ops, stake_id: id, reasons: [`Create ${id} (${species}, ${provenance}).`], handToHuman };
|
|
21835
|
+
}
|
|
21836
|
+
function planSignalMerge(input) {
|
|
21837
|
+
const { signal, target } = input;
|
|
21838
|
+
if (target.species !== "stake") return refused([`${target.id} is a ${target.species}, not a stake.`]);
|
|
21839
|
+
const targetSpecies = stakeSpeciesOf(target);
|
|
21840
|
+
if (input.species !== void 0 && targetSpecies !== input.species) {
|
|
21841
|
+
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.`]);
|
|
21842
|
+
}
|
|
21843
|
+
const existing = stakeEvidenceOf(target);
|
|
21844
|
+
if (signal.event_id !== void 0 && existing.some((entry) => entry.event_id === signal.event_id)) {
|
|
21845
|
+
return { action: "noop", ops: [], stake_id: target.id, reasons: [`${target.id} already cites this signal as evidence.`], handToHuman: [] };
|
|
21846
|
+
}
|
|
21847
|
+
const other = stakeCiting(input.nodes, signal.event_id);
|
|
21848
|
+
const handToHuman = [];
|
|
21849
|
+
if (other !== void 0) handToHuman.push(`${other.id} also cites this signal: the same signal now backs two stakes.`);
|
|
21850
|
+
if (target.status === "archived") handToHuman.push(`${target.id} is archived: a person decides whether the new evidence reopens it.`);
|
|
21851
|
+
const metadata = { ...target.metadata ?? {}, evidence: [...existing, evidenceEntryFor(signal)] };
|
|
21852
|
+
return {
|
|
21853
|
+
action: "merge",
|
|
21854
|
+
ops: [{ op: "update_node", node_id: target.id, patch: { metadata } }],
|
|
21855
|
+
stake_id: target.id,
|
|
21856
|
+
reasons: [`Append evidence to ${target.id}.`],
|
|
21857
|
+
handToHuman
|
|
21858
|
+
};
|
|
21859
|
+
}
|
|
21860
|
+
|
|
21861
|
+
// ../schema/src/stake-evaluation.ts
|
|
21862
|
+
function referenceForStakeSpecies(species) {
|
|
21863
|
+
const set2 = BUILT_IN_SETS.find((candidate) => stakeSpeciesDeclaredBy(candidate).includes(species));
|
|
21864
|
+
return set2 === void 0 ? { kind: "kritik" } : { kind: "weighing-set", set: `${set2.id}@${majorOf(set2.version)}` };
|
|
21865
|
+
}
|
|
21866
|
+
function kritikCriterionVersion(criterionId, library) {
|
|
21867
|
+
const criterion = Array.isArray(library?.criteria) ? library.criteria.find((candidate) => candidate?.id === criterionId) : void 0;
|
|
21868
|
+
if (criterion === void 0) return void 0;
|
|
21869
|
+
const version2 = criterion.version;
|
|
21870
|
+
return typeof version2 === "number" && Number.isInteger(version2) && version2 >= 1 ? version2 : 1;
|
|
21871
|
+
}
|
|
21872
|
+
|
|
21873
|
+
// ../schema/src/stake-proof.ts
|
|
21874
|
+
var PROOF_EVENT_TYPES = [
|
|
21875
|
+
"node.created",
|
|
21876
|
+
"node.status_changed",
|
|
21877
|
+
"decision.status_changed",
|
|
21878
|
+
"quality.finding.opened",
|
|
21879
|
+
"quality.finding.resolved",
|
|
21880
|
+
"quality.finding.accepted",
|
|
21881
|
+
"quality.assessment.scored"
|
|
21882
|
+
];
|
|
21883
|
+
var STAKE_STATES = ["raised", "considered", "promised", "verified-not-delivered", "partly-addressed", "addressed"];
|
|
21884
|
+
var DAY_MS = 864e5;
|
|
21885
|
+
var VERIFIED_STATUSES = ["releasing", "live"];
|
|
21886
|
+
var DELIVERED_STATUSES = ["live"];
|
|
21887
|
+
var isRecord7 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
21888
|
+
var asString2 = (value) => typeof value === "string" && value !== "" ? value : void 0;
|
|
21889
|
+
function timeMs(value) {
|
|
21890
|
+
if (typeof value !== "string") return void 0;
|
|
21891
|
+
const ms = Date.parse(value);
|
|
21892
|
+
return Number.isFinite(ms) ? ms : void 0;
|
|
21893
|
+
}
|
|
21894
|
+
function nowMsOf(now) {
|
|
21895
|
+
if (now instanceof Date) return Number.isFinite(now.getTime()) ? now.getTime() : void 0;
|
|
21896
|
+
if (typeof now === "number") return Number.isFinite(now) ? now : void 0;
|
|
21897
|
+
return timeMs(now);
|
|
21898
|
+
}
|
|
21899
|
+
var isoOf2 = (ms) => new Date(ms).toISOString();
|
|
21900
|
+
function proofEventsOf(events) {
|
|
21901
|
+
if (!Array.isArray(events)) return [];
|
|
21902
|
+
const kept = events.filter((event) => isRecord7(event) && PROOF_EVENT_TYPES.includes(event.type));
|
|
21903
|
+
return orderEvents(kept);
|
|
21904
|
+
}
|
|
21905
|
+
function sanitizeNode(raw) {
|
|
21906
|
+
if (!isRecord7(raw) || typeof raw.id !== "string") return void 0;
|
|
21907
|
+
const node = raw;
|
|
21908
|
+
const metadata = isRecord7(node.metadata) ? node.metadata : void 0;
|
|
21909
|
+
if (Array.isArray(node.platforms) && metadata === node.metadata) return node;
|
|
21910
|
+
return { ...node, platforms: Array.isArray(node.platforms) ? node.platforms : [], metadata };
|
|
21911
|
+
}
|
|
21912
|
+
var sanitizeEdge = (raw) => isRecord7(raw) && typeof raw.source_id === "string" && typeof raw.target_id === "string" && typeof raw.edge_type === "string";
|
|
21913
|
+
function deliveryFor(species) {
|
|
21914
|
+
if (species === "requirement" || species === "defect") return "optional";
|
|
21915
|
+
if (species === "risk") return "not-required";
|
|
21916
|
+
return "required";
|
|
21917
|
+
}
|
|
21918
|
+
function statusChecksByNode(events) {
|
|
21919
|
+
const checks = /* @__PURE__ */ new Map();
|
|
21920
|
+
for (const event of events) {
|
|
21921
|
+
if (event.type !== "node.status_changed") continue;
|
|
21922
|
+
const nodeId = asString2(event.node_id);
|
|
21923
|
+
const to = typeof event.to === "string" ? normalizeStatus(event.to) : void 0;
|
|
21924
|
+
const ms = timeMs(event.ts);
|
|
21925
|
+
if (nodeId === void 0 || to === void 0 || ms === void 0 || !VERIFIED_STATUSES.includes(to)) continue;
|
|
21926
|
+
const named = event.platform;
|
|
21927
|
+
const platform = typeof named === "string" && PLATFORM_IDS.includes(named) ? named : void 0;
|
|
21928
|
+
if (named !== void 0 && platform === void 0) continue;
|
|
21929
|
+
const list = checks.get(nodeId) ?? [];
|
|
21930
|
+
list.push({ ms, platform });
|
|
21931
|
+
checks.set(nodeId, list);
|
|
21932
|
+
}
|
|
21933
|
+
return checks;
|
|
21934
|
+
}
|
|
21935
|
+
function findingFacts(criterionId, section, events) {
|
|
21936
|
+
const stored = /* @__PURE__ */ new Map();
|
|
21937
|
+
const storedFindings = isRecord7(section) && Array.isArray(section.findings) ? section.findings : [];
|
|
21938
|
+
for (const finding of storedFindings) {
|
|
21939
|
+
if (isRecord7(finding) && typeof finding.id === "string") stored.set(finding.id, finding);
|
|
21940
|
+
}
|
|
21941
|
+
const replay = /* @__PURE__ */ new Map();
|
|
21942
|
+
const nodeIdsOf2 = (raw) => Array.isArray(raw) ? raw.filter((id) => typeof id === "string") : [];
|
|
21943
|
+
for (const event of events) {
|
|
21944
|
+
const findingId = asString2(event.finding_id);
|
|
21945
|
+
if (findingId === void 0) continue;
|
|
21946
|
+
if (event.type === "quality.finding.opened") {
|
|
21947
|
+
const row = replay.get(findingId) ?? { nodeIds: [], open: true, closedMs: void 0 };
|
|
21948
|
+
row.criterion = asString2(event.criterion_id) ?? row.criterion;
|
|
21949
|
+
row.nodeIds = nodeIdsOf2(event.node_ids).length > 0 ? nodeIdsOf2(event.node_ids) : row.nodeIds;
|
|
21950
|
+
row.open = true;
|
|
21951
|
+
row.closedMs = void 0;
|
|
21952
|
+
replay.set(findingId, row);
|
|
21953
|
+
} else if (event.type === "quality.finding.resolved" || event.type === "quality.finding.accepted") {
|
|
21954
|
+
const row = replay.get(findingId) ?? { nodeIds: [], open: false, closedMs: void 0 };
|
|
21955
|
+
row.open = false;
|
|
21956
|
+
row.closedMs = timeMs(event.ts);
|
|
21957
|
+
if (row.nodeIds.length === 0) row.nodeIds = nodeIdsOf2(event.node_ids);
|
|
21958
|
+
replay.set(findingId, row);
|
|
21959
|
+
}
|
|
21960
|
+
}
|
|
21961
|
+
const facts = [];
|
|
21962
|
+
for (const id of /* @__PURE__ */ new Set([...stored.keys(), ...replay.keys()])) {
|
|
21963
|
+
const row = stored.get(id);
|
|
21964
|
+
const replayed = replay.get(id);
|
|
21965
|
+
const criterion = row !== void 0 ? asString2(row.criterion_id) : replayed?.criterion;
|
|
21966
|
+
if (criterion !== criterionId) continue;
|
|
21967
|
+
const storedNodeIds = row !== void 0 ? nodeIdsOf2(row.node_ids) : [];
|
|
21968
|
+
facts.push({
|
|
21969
|
+
open: row !== void 0 ? isOpenFinding(row) : replayed?.open ?? false,
|
|
21970
|
+
nodeIds: storedNodeIds.length > 0 ? storedNodeIds : replayed?.nodeIds ?? [],
|
|
21971
|
+
closedMs: replayed?.closedMs
|
|
21972
|
+
});
|
|
21973
|
+
}
|
|
21974
|
+
return facts;
|
|
21975
|
+
}
|
|
21976
|
+
function scoresOf(criterionId, section, events) {
|
|
21977
|
+
const scores = [];
|
|
21978
|
+
const add = (row, ts) => {
|
|
21979
|
+
const ms = timeMs(ts);
|
|
21980
|
+
const level = row.level;
|
|
21981
|
+
if (asString2(row.criterion_id) !== criterionId || ms === void 0) return;
|
|
21982
|
+
if (typeof level !== "number" || !Number.isInteger(level) || level < 0 || level > 4) return;
|
|
21983
|
+
scores.push({ surface: typeof row.surface === "string" ? row.surface : "", level, ms });
|
|
21984
|
+
};
|
|
21985
|
+
const assessments = isRecord7(section) && Array.isArray(section.assessments) ? section.assessments : [];
|
|
21986
|
+
for (const row of assessments) if (isRecord7(row)) add(row, row.ts);
|
|
21987
|
+
for (const event of events) if (event.type === "quality.assessment.scored") add(event, event.ts);
|
|
21988
|
+
return scores;
|
|
21989
|
+
}
|
|
21990
|
+
function raisedMsOf(stake, events) {
|
|
21991
|
+
const created = events.filter((event) => event.type === "node.created" && event.node_id === stake.id).map((event) => timeMs(event.ts)).filter((ms) => ms !== void 0);
|
|
21992
|
+
if (created.length > 0) return Math.min(...created);
|
|
21993
|
+
const dated = stakeEvidenceOf(stake).map((entry) => timeMs(entry.date)).filter((ms) => ms !== void 0);
|
|
21994
|
+
return dated.length > 0 ? Math.min(...dated) : void 0;
|
|
21995
|
+
}
|
|
21996
|
+
function kritikReading(stake, criterionId, anchors, quality, events) {
|
|
21997
|
+
const reasons = [];
|
|
21998
|
+
const atAnchor = (nodeIds) => anchors.length === 0 || nodeIds.some((id) => anchors.includes(id));
|
|
21999
|
+
const facts = findingFacts(criterionId, quality, events).filter((fact) => atAnchor(fact.nodeIds));
|
|
22000
|
+
const blocking = facts.filter((fact) => fact.open).length;
|
|
22001
|
+
if (blocking > 0) reasons.push(`${blocking} open ${criterionId} finding${blocking === 1 ? "" : "s"} at the stake's anchor.`);
|
|
22002
|
+
const raisedMs = raisedMsOf(stake, events);
|
|
22003
|
+
const counted = scoresOf(criterionId, quality, events).filter((score) => raisedMs === void 0 || score.ms > raisedMs);
|
|
22004
|
+
const latest = /* @__PURE__ */ new Map();
|
|
22005
|
+
for (const score of counted) {
|
|
22006
|
+
const current = latest.get(score.surface);
|
|
22007
|
+
if (current === void 0 || score.ms > current.ms || score.ms === current.ms && score.level < current.level) latest.set(score.surface, score);
|
|
22008
|
+
}
|
|
22009
|
+
let scoresPass = latest.size > 0;
|
|
22010
|
+
if (latest.size === 0) {
|
|
22011
|
+
reasons.push(`No ${criterionId} score dated after the stake was raised.`);
|
|
22012
|
+
} else {
|
|
22013
|
+
const below = [...latest.entries()].filter(([, score]) => score.level < DEFAULT_TARGET_LEVEL);
|
|
22014
|
+
if (below.length > 0) {
|
|
22015
|
+
scoresPass = false;
|
|
22016
|
+
reasons.push(`${criterionId} is below level ${DEFAULT_TARGET_LEVEL} on ${below.map(([surface]) => surface || "a surface").join(", ")}.`);
|
|
22017
|
+
}
|
|
22018
|
+
}
|
|
22019
|
+
const checks = [...counted.map((score) => score.ms), ...facts.filter((fact) => !fact.open && fact.closedMs !== void 0).map((fact) => fact.closedMs)];
|
|
22020
|
+
return { holds: blocking === 0 && scoresPass, checkedMs: checks.length > 0 ? Math.max(...checks) : void 0, reasons };
|
|
22021
|
+
}
|
|
22022
|
+
function prepare(input) {
|
|
22023
|
+
const nodes = (Array.isArray(input.nodes) ? input.nodes : []).map(sanitizeNode).filter((node) => node !== void 0);
|
|
22024
|
+
const edges = (Array.isArray(input.edges) ? input.edges : []).filter(sanitizeEdge);
|
|
22025
|
+
const events = proofEventsOf(input.events);
|
|
22026
|
+
const products = resolveProducts(input.project);
|
|
22027
|
+
const scopeId = typeof input.productId === "string" ? input.productId : null;
|
|
22028
|
+
return {
|
|
22029
|
+
nodes,
|
|
22030
|
+
edges,
|
|
22031
|
+
events,
|
|
22032
|
+
statusChecks: statusChecksByNode(events),
|
|
22033
|
+
products,
|
|
22034
|
+
scopeProduct: scopeId === null ? null : products.find((product) => product.id === scopeId) ?? null,
|
|
22035
|
+
nowMs: nowMsOf(input.now),
|
|
22036
|
+
input
|
|
22037
|
+
};
|
|
22038
|
+
}
|
|
22039
|
+
function platformsOf(acceptance, prepared) {
|
|
22040
|
+
const ownId = productOf(acceptance);
|
|
22041
|
+
const own = ownId === null ? null : prepared.products.find((product) => product.id === ownId) ?? null;
|
|
22042
|
+
return effectiveNodePlatforms(acceptance, own ?? prepared.scopeProduct);
|
|
22043
|
+
}
|
|
22044
|
+
function reads(acceptance, platform, statuses) {
|
|
22045
|
+
if (acceptance.status === "archived") return false;
|
|
22046
|
+
const status = platform === null ? acceptance.status : resolvePlatformStatus(acceptance, platform);
|
|
22047
|
+
return status !== void 0 && statuses.includes(status);
|
|
22048
|
+
}
|
|
22049
|
+
function latestCheckMs(acceptance, platform, prepared) {
|
|
22050
|
+
const hasOwnEntry = platform !== null && isRecord7(acceptance.metadata?.platformStatuses) && acceptance.metadata?.platformStatuses?.[platform] !== void 0;
|
|
22051
|
+
let latest;
|
|
22052
|
+
for (const check2 of prepared.statusChecks.get(acceptance.id) ?? []) {
|
|
22053
|
+
const applies = platform === null || check2.platform === platform || check2.platform === void 0 && !hasOwnEntry;
|
|
22054
|
+
if (applies && (latest === void 0 || check2.ms > latest)) latest = check2.ms;
|
|
22055
|
+
}
|
|
22056
|
+
return latest;
|
|
22057
|
+
}
|
|
22058
|
+
function lapsed(days, checkedMs, nowMs) {
|
|
22059
|
+
if (days === void 0 || nowMs === void 0) return false;
|
|
22060
|
+
return checkedMs === void 0 || nowMs - checkedMs > days * DAY_MS;
|
|
22061
|
+
}
|
|
22062
|
+
function deliveredEverywhere(acceptances, prepared) {
|
|
22063
|
+
if (acceptances.length === 0) return false;
|
|
22064
|
+
return acceptances.every((acceptance) => {
|
|
22065
|
+
const platforms = platformsOf(acceptance, prepared);
|
|
22066
|
+
return platforms.length === 0 ? reads(acceptance, null, DELIVERED_STATUSES) : platforms.every((platform) => reads(acceptance, platform, DELIVERED_STATUSES));
|
|
22067
|
+
});
|
|
22068
|
+
}
|
|
22069
|
+
function proofFor(prepared, stake) {
|
|
22070
|
+
const { nodes, edges, events, nowMs } = prepared;
|
|
22071
|
+
const species = stakeSpeciesOf(stake);
|
|
22072
|
+
const answerType = answerTypeForStake(stake);
|
|
22073
|
+
const delivery = deliveryFor(species);
|
|
22074
|
+
const isRequirement = species === "requirement";
|
|
22075
|
+
const userFacing = species !== void 0 && USER_FACING_STAKE_SPECIES.includes(species);
|
|
22076
|
+
const quality = species !== void 0 && QUALITY_STAKE_SPECIES.includes(species);
|
|
22077
|
+
const reverifyDays = stakeReverifyDaysOf(stake);
|
|
22078
|
+
const reasons = [];
|
|
22079
|
+
const answerNodes = answerFor(stake.id, nodes, edges);
|
|
22080
|
+
const answer = answerNodes === void 0 ? void 0 : { decision_id: answerNodes.decision.id, option_id: answerNodes.option.id };
|
|
22081
|
+
if (answerNodes !== void 0 && answerNodes.competing.length > 0) {
|
|
22082
|
+
reasons.push(`More than one decision settles this stake (${[answerNodes.decision.id, ...answerNodes.competing].join(", ")}): the latest, ${answerNodes.decision.id}, is read.`);
|
|
22083
|
+
}
|
|
22084
|
+
const directPromises = acceptancesAddressing(stake.id, nodes, edges).filter((acceptance) => isPromise(acceptance, nodes, edges));
|
|
22085
|
+
const promises = promisesOf(stake.id, nodes, edges);
|
|
22086
|
+
const catalog = stakeCatalogOf(stake);
|
|
22087
|
+
const criterionId = catalog?.source === "kritik" ? catalog.id : void 0;
|
|
22088
|
+
const dod = isRequirement ? [] : promises;
|
|
22089
|
+
const hasDod = isRequirement ? criterionId !== void 0 : dod.length > 0;
|
|
22090
|
+
const cells = [];
|
|
22091
|
+
if (isRequirement) {
|
|
22092
|
+
const anchors = edges.filter((edge) => edge.edge_type === "concerns" && edge.source_id === stake.id).map((edge) => edge.target_id);
|
|
22093
|
+
let holds = false;
|
|
22094
|
+
let checkedMs;
|
|
22095
|
+
if (criterionId === void 0) {
|
|
22096
|
+
reasons.push("The requirement names no Kritik criterion, so nothing can be checked.");
|
|
22097
|
+
} else {
|
|
22098
|
+
const reading = kritikReading(stake, criterionId, anchors, prepared.input.quality, events);
|
|
22099
|
+
holds = reading.holds;
|
|
22100
|
+
checkedMs = reading.checkedMs;
|
|
22101
|
+
reasons.push(...reading.reasons);
|
|
22102
|
+
}
|
|
22103
|
+
const storedVersion = stakeVerifiedCriterionVersionOf(stake);
|
|
22104
|
+
const currentVersion = criterionId === void 0 ? void 0 : kritikCriterionVersion(criterionId, prepared.input.library);
|
|
22105
|
+
const newerVersion = storedVersion !== void 0 && currentVersion !== void 0 && currentVersion > storedVersion;
|
|
22106
|
+
const expired = holds && lapsed(reverifyDays, checkedMs, nowMs);
|
|
22107
|
+
const stale = holds && (expired || newerVersion);
|
|
22108
|
+
if (holds && newerVersion) reasons.push(`${criterionId} is at version ${currentVersion}, newer than version ${storedVersion} this was verified against.`);
|
|
22109
|
+
if (expired) reasons.push(checkedMs === void 0 ? "The check has no date, and the stake expires." : `The latest check is older than ${reverifyDays} days.`);
|
|
22110
|
+
cells.push({
|
|
22111
|
+
platform: null,
|
|
22112
|
+
verified: holds && !stale,
|
|
22113
|
+
delivered: deliveredEverywhere(promises, prepared),
|
|
22114
|
+
stale,
|
|
22115
|
+
...checkedMs !== void 0 ? { checked_at: isoOf2(checkedMs) } : {}
|
|
22116
|
+
});
|
|
22117
|
+
} else {
|
|
22118
|
+
const platforms = PLATFORM_IDS.filter((platform) => dod.some((acceptance) => platformsOf(acceptance, prepared).includes(platform)));
|
|
22119
|
+
const targets = platforms.length > 0 ? platforms : [null];
|
|
22120
|
+
for (const platform of targets) {
|
|
22121
|
+
const applying = platform === null ? dod : dod.filter((acceptance) => platformsOf(acceptance, prepared).includes(platform));
|
|
22122
|
+
const holds = applying.length > 0 && applying.every((acceptance) => reads(acceptance, platform, VERIFIED_STATUSES));
|
|
22123
|
+
const delivered = applying.length > 0 && applying.every((acceptance) => reads(acceptance, platform, DELIVERED_STATUSES));
|
|
22124
|
+
const checks = applying.map((acceptance) => latestCheckMs(acceptance, platform, prepared));
|
|
22125
|
+
const checkedMs = checks.every((ms) => ms !== void 0) && checks.length > 0 ? Math.min(...checks) : void 0;
|
|
22126
|
+
const stale = holds && lapsed(reverifyDays, checkedMs, nowMs);
|
|
22127
|
+
if (stale) reasons.push(`${platform ?? "The"} verification has lapsed: ${checkedMs === void 0 ? "no dated check" : `the latest check is older than ${reverifyDays} days`}.`);
|
|
22128
|
+
cells.push({
|
|
22129
|
+
platform,
|
|
22130
|
+
verified: holds && !stale,
|
|
22131
|
+
delivered,
|
|
22132
|
+
stale,
|
|
22133
|
+
...holds && checkedMs !== void 0 ? { checked_at: isoOf2(checkedMs) } : {}
|
|
22134
|
+
});
|
|
22135
|
+
}
|
|
22136
|
+
}
|
|
22137
|
+
const deliveryRequired = delivery === "required";
|
|
22138
|
+
const committed = answer !== void 0 || directPromises.length > 0;
|
|
22139
|
+
let state;
|
|
22140
|
+
if (stake.status === "archived") {
|
|
22141
|
+
state = null;
|
|
22142
|
+
reasons.unshift("Archived: an archived stake derives no state.");
|
|
22143
|
+
} else if (committed && hasDod && cells.every((cell) => cell.verified && (!deliveryRequired || cell.delivered))) {
|
|
22144
|
+
state = "addressed";
|
|
22145
|
+
reasons.push(deliveryRequired ? "Verified and delivered on every platform concerned." : "Verified on every platform concerned.");
|
|
22146
|
+
} else if (hasDod && deliveryRequired && cells.every((cell) => cell.verified) && !cells.some((cell) => cell.delivered)) {
|
|
22147
|
+
state = "verified-not-delivered";
|
|
22148
|
+
reasons.push("Verified everywhere, delivered nowhere: merged, not yet live.");
|
|
22149
|
+
} else if (cells.some((cell) => !cell.stale && (cell.verified || cell.delivered && delivery !== "not-required"))) {
|
|
22150
|
+
state = "partly-addressed";
|
|
22151
|
+
reasons.push("The proof holds on some platforms, not on every one the answer concerns.");
|
|
22152
|
+
} else if (answer !== void 0 && hasDod || directPromises.length > 0) {
|
|
22153
|
+
state = "promised";
|
|
22154
|
+
reasons.push(cells.some((cell) => cell.stale) ? "Promised: the verification lapsed, so it reads as promised until a new check passes." : "Promised: a decision chose an answer and it has a definition of done.");
|
|
22155
|
+
} else if (optionsAddressing(stake.id, nodes, edges).length > 0 || candidatesFor(stake.id, nodes, edges).length > 0 || userFacing && (prepared.input.weighing?.assessments?.some?.((row) => isRecord7(row) && row.subject === stake.id) === true || stakeMattersOf(stake) !== void 0) || quality && criterionId !== void 0) {
|
|
22156
|
+
state = "considered";
|
|
22157
|
+
reasons.push(
|
|
22158
|
+
answer !== void 0 ? "Considered: a decision chose an option, but the answer has no definition of done yet." : "Considered: an option or a candidate addresses it, or it has been evaluated."
|
|
22159
|
+
);
|
|
22160
|
+
} else {
|
|
22161
|
+
state = "raised";
|
|
22162
|
+
reasons.push("Raised: nothing addresses it yet.");
|
|
22163
|
+
}
|
|
22164
|
+
return {
|
|
22165
|
+
stake_id: stake.id,
|
|
22166
|
+
...species !== void 0 ? { stake_species: species } : {},
|
|
22167
|
+
...answerType !== void 0 ? { answer_type: answerType } : {},
|
|
22168
|
+
state,
|
|
22169
|
+
...answer !== void 0 ? { answer } : {},
|
|
22170
|
+
definition_of_done: dod.map((acceptance) => acceptance.id),
|
|
22171
|
+
delivery,
|
|
22172
|
+
cells,
|
|
22173
|
+
reasons
|
|
22174
|
+
};
|
|
22175
|
+
}
|
|
22176
|
+
function deriveStakeProof(input) {
|
|
22177
|
+
const prepared = prepare(input);
|
|
22178
|
+
const stake = prepared.nodes.find((node) => node.id === input.stakeId);
|
|
22179
|
+
return stake === void 0 || stake.species !== "stake" ? null : proofFor(prepared, stake);
|
|
22180
|
+
}
|
|
22181
|
+
function deriveStakeProofs(input) {
|
|
22182
|
+
const prepared = prepare(input);
|
|
22183
|
+
return prepared.nodes.filter((node) => node.species === "stake").map((stake) => proofFor(prepared, stake));
|
|
22184
|
+
}
|
|
22185
|
+
|
|
20676
22186
|
// ../schema/src/cli/kritik-audit.ts
|
|
20677
22187
|
import { existsSync as existsSync2, readdirSync, statSync } from "node:fs";
|
|
20678
22188
|
import { join as join2 } from "node:path";
|
|
@@ -22550,6 +24060,450 @@ function buildKritikCatalog(ctx) {
|
|
|
22550
24060
|
return { tools: tools2, handlers: handlers2 };
|
|
22551
24061
|
}
|
|
22552
24062
|
|
|
24063
|
+
// src/decide-tools.ts
|
|
24064
|
+
function requireString2(args, key) {
|
|
24065
|
+
const value = args[key];
|
|
24066
|
+
if (typeof value !== "string" || value.trim() === "") throw new ToolError(`\`${key}\` is required.`);
|
|
24067
|
+
return value;
|
|
24068
|
+
}
|
|
24069
|
+
var ISO_8601 = /^(\d{4})-(\d{2})-(\d{2})(?:T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?)?$/;
|
|
24070
|
+
function isIsoDate2(value) {
|
|
24071
|
+
const match = ISO_8601.exec(value);
|
|
24072
|
+
if (match === null || !Number.isFinite(Date.parse(value))) return false;
|
|
24073
|
+
const [year, month, day] = [Number(match[1]), Number(match[2]), Number(match[3])];
|
|
24074
|
+
const real = new Date(Date.UTC(year, month - 1, day));
|
|
24075
|
+
return real.getUTCFullYear() === year && real.getUTCMonth() === month - 1 && real.getUTCDate() === day;
|
|
24076
|
+
}
|
|
24077
|
+
function optionalString(args, key) {
|
|
24078
|
+
const value = args[key];
|
|
24079
|
+
if (value === void 0) return void 0;
|
|
24080
|
+
if (typeof value !== "string") throw new ToolError(`\`${key}\` must be a string.`);
|
|
24081
|
+
return value.trim() === "" ? void 0 : value;
|
|
24082
|
+
}
|
|
24083
|
+
function readClosed(args) {
|
|
24084
|
+
const raw = args.closed;
|
|
24085
|
+
if (raw === void 0) return void 0;
|
|
24086
|
+
if (!Array.isArray(raw)) throw new ToolError("`closed` must be an array of { option_id, reason }.");
|
|
24087
|
+
return raw.map((entry, index) => {
|
|
24088
|
+
if (typeof entry !== "object" || entry === null || Array.isArray(entry)) throw new ToolError(`closed[${index}] must be an object with an option_id.`);
|
|
24089
|
+
const { option_id, reason } = entry;
|
|
24090
|
+
if (typeof option_id !== "string" || option_id === "") throw new ToolError(`closed[${index}].option_id is required.`);
|
|
24091
|
+
if (reason !== void 0 && typeof reason !== "string") throw new ToolError(`closed[${index}].reason must be a string.`);
|
|
24092
|
+
return { option_id, reason: reason ?? "" };
|
|
24093
|
+
});
|
|
24094
|
+
}
|
|
24095
|
+
function today() {
|
|
24096
|
+
return (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
24097
|
+
}
|
|
24098
|
+
function proofSources(ctx, graph) {
|
|
24099
|
+
const bundle = graph.loaded.bundle;
|
|
24100
|
+
const embedded = bundle.quality !== void 0 && Array.isArray(bundle.quality.findings) && Array.isArray(bundle.quality.assessments) ? bundle.quality : void 0;
|
|
24101
|
+
if (ctx.qualityRoot === void 0) {
|
|
24102
|
+
return {
|
|
24103
|
+
...embedded !== void 0 ? { quality: embedded, library: resolveKritikLibrary(embedded) } : {},
|
|
24104
|
+
...bundle.weighing !== void 0 ? { weighing: bundle.weighing } : {}
|
|
24105
|
+
};
|
|
24106
|
+
}
|
|
24107
|
+
let library;
|
|
24108
|
+
let quality;
|
|
24109
|
+
let weighing;
|
|
24110
|
+
try {
|
|
24111
|
+
library = loadKritikLibrary(ctx.qualityRoot).library;
|
|
24112
|
+
quality = loadCurrentQualitySection(ctx.qualityRoot, library);
|
|
24113
|
+
} catch {
|
|
24114
|
+
}
|
|
24115
|
+
try {
|
|
24116
|
+
weighing = loadWeighingSection(ctx.qualityRoot);
|
|
24117
|
+
} catch {
|
|
24118
|
+
}
|
|
24119
|
+
quality ??= embedded;
|
|
24120
|
+
library ??= embedded === void 0 ? void 0 : resolveKritikLibrary(embedded);
|
|
24121
|
+
weighing ??= bundle.weighing;
|
|
24122
|
+
return { ...quality !== void 0 ? { quality } : {}, ...library !== void 0 ? { library } : {}, ...weighing !== void 0 ? { weighing } : {} };
|
|
24123
|
+
}
|
|
24124
|
+
function buildDecideCatalog(ctx, io) {
|
|
24125
|
+
const tools2 = [];
|
|
24126
|
+
const handlers2 = {};
|
|
24127
|
+
const tool = (definition, handler) => {
|
|
24128
|
+
tools2.push(definition);
|
|
24129
|
+
handlers2[definition.name] = handler;
|
|
24130
|
+
};
|
|
24131
|
+
tool(
|
|
24132
|
+
{
|
|
24133
|
+
name: "decide_option",
|
|
24134
|
+
description: "Record that one option was chosen to answer a stake. Creates a decision (approved by default; `status: enacted` when the work is already done) with `reason` as its context, an `impacts` edge to the stake and a `generates` edge to the option. Every other non-archived option addressing the stake is closed in the decision's `closed_options`: name a reason for each loser in `closed`, or it gets a default reason and is handed back to a human. The option must address the stake and must not be archived. A stake that already has an approved or enacted decision is refused unless `supersede: true`, which moves that decision to superseded (the journal records the change) and links the new one to it. The server stamps the author; `decided_at` defaults to today. Whether an option is selected or closed is read from the decision, never stored on the option. Works on a repo and a hosted project.",
|
|
24135
|
+
inputSchema: {
|
|
24136
|
+
type: "object",
|
|
24137
|
+
properties: {
|
|
24138
|
+
stake_id: { type: "string", description: "The stake the decision settles." },
|
|
24139
|
+
option_id: { type: "string", description: "The option chosen. It must address the stake." },
|
|
24140
|
+
reason: { type: "string", description: "Why this option: the decision's context. Required." },
|
|
24141
|
+
closed: {
|
|
24142
|
+
type: "array",
|
|
24143
|
+
description: "Why each loser lost. Options not named here are still closed, with a default reason.",
|
|
24144
|
+
items: {
|
|
24145
|
+
type: "object",
|
|
24146
|
+
properties: {
|
|
24147
|
+
option_id: { type: "string", description: "An option that addresses the same stake." },
|
|
24148
|
+
reason: { type: "string", description: "Why it lost." }
|
|
24149
|
+
},
|
|
24150
|
+
required: ["option_id"],
|
|
24151
|
+
additionalProperties: false
|
|
24152
|
+
}
|
|
24153
|
+
},
|
|
24154
|
+
title: { type: "string", description: `The decision's title. Default: Select "<option>" for "<stake>".` },
|
|
24155
|
+
status: { type: "string", enum: ["approved", "enacted"], description: "Default approved." },
|
|
24156
|
+
supersede: { type: "boolean", description: "Replace the stake's existing approved or enacted decision. Required when there is one." },
|
|
24157
|
+
decided_at: { type: "string", description: "An ISO 8601 date. Default today." }
|
|
24158
|
+
},
|
|
24159
|
+
required: ["stake_id", "option_id", "reason"],
|
|
24160
|
+
additionalProperties: false
|
|
24161
|
+
}
|
|
24162
|
+
},
|
|
24163
|
+
async (args) => {
|
|
24164
|
+
const graph = await io.load();
|
|
24165
|
+
const status = optionalString(args, "status");
|
|
24166
|
+
if (status !== void 0 && status !== "approved" && status !== "enacted") throw new ToolError("`status` must be approved or enacted.");
|
|
24167
|
+
const decidedAt = optionalString(args, "decided_at") ?? today();
|
|
24168
|
+
if (!isIsoDate2(decidedAt)) throw new ToolError("`decided_at` must be an ISO 8601 date.");
|
|
24169
|
+
if (args.supersede !== void 0 && typeof args.supersede !== "boolean") throw new ToolError("`supersede` must be a boolean.");
|
|
24170
|
+
const closed = readClosed(args);
|
|
24171
|
+
const title = optionalString(args, "title");
|
|
24172
|
+
const plan = planSelectOption({
|
|
24173
|
+
projectId: graph.project.id,
|
|
24174
|
+
stakeId: requireString2(args, "stake_id"),
|
|
24175
|
+
optionId: requireString2(args, "option_id"),
|
|
24176
|
+
reason: requireString2(args, "reason"),
|
|
24177
|
+
decidedAt,
|
|
24178
|
+
nodes: graph.nodes,
|
|
24179
|
+
edges: graph.edges,
|
|
24180
|
+
...closed !== void 0 ? { closed } : {},
|
|
24181
|
+
...title !== void 0 ? { title } : {},
|
|
24182
|
+
...status !== void 0 ? { status } : {},
|
|
24183
|
+
...args.supersede === true ? { supersede: true } : {}
|
|
24184
|
+
});
|
|
24185
|
+
if (plan.action === "refused") throw new ToolError(`Not decided: ${plan.reasons.join(" ")}`, { reasons: plan.reasons });
|
|
24186
|
+
const outcome = io.mutate(graph, plan.ops);
|
|
24187
|
+
const result = await ctx.store.persist(graph, { nodes: outcome.nodes, edges: outcome.edges, ops: plan.ops }, outcome.eventInputs);
|
|
24188
|
+
const { warnings, events } = io.unwrap(result);
|
|
24189
|
+
const decisionId = plan.decision_id;
|
|
24190
|
+
return {
|
|
24191
|
+
action: plan.action,
|
|
24192
|
+
decision_id: decisionId,
|
|
24193
|
+
decision: outcome.nodes.find((node) => node.id === decisionId),
|
|
24194
|
+
reasons: plan.reasons,
|
|
24195
|
+
ops: plan.ops,
|
|
24196
|
+
events,
|
|
24197
|
+
warnings,
|
|
24198
|
+
handToHuman: plan.handToHuman
|
|
24199
|
+
};
|
|
24200
|
+
}
|
|
24201
|
+
);
|
|
24202
|
+
tool(
|
|
24203
|
+
{
|
|
24204
|
+
name: "stake_proof",
|
|
24205
|
+
description: "Read-only. Where a stake stands, derived and never stored: its state (raised, considered, promised, verified-not-delivered, partly-addressed, addressed; null for an archived stake), the answer a decision chose, the definition of done, and one cell per platform concerned saying whether the verified half holds (an acceptance at releasing or live), the answer is delivered (live) or the verification is stale (its reverify_every_days ran out, or the Kritik criterion moved to a newer version). A requirement is read against its Kritik criterion: no open finding at its anchor and a score of at least 3 dated after the stake was raised. Pass stake_id for one stake, or leave it off for every stake with a count per state. product narrows the platforms to a product's menu; now (ISO 8601) defaults to the server's clock. Never writes. Works on a repo and a hosted project.",
|
|
24206
|
+
inputSchema: {
|
|
24207
|
+
type: "object",
|
|
24208
|
+
properties: {
|
|
24209
|
+
stake_id: { type: "string", description: "One stake. Leave off for every stake." },
|
|
24210
|
+
product: { type: "string", description: "A product id declared in the project: read the platforms through its menu. Default: all products." },
|
|
24211
|
+
now: { type: "string", description: "An ISO 8601 instant to read the expiry against. Default: the server's clock." }
|
|
24212
|
+
},
|
|
24213
|
+
additionalProperties: false
|
|
24214
|
+
}
|
|
24215
|
+
},
|
|
24216
|
+
async (args) => {
|
|
24217
|
+
const graph = await io.load();
|
|
24218
|
+
const stakeId = optionalString(args, "stake_id");
|
|
24219
|
+
const product = optionalString(args, "product");
|
|
24220
|
+
const nowArg = optionalString(args, "now");
|
|
24221
|
+
if (product !== void 0) {
|
|
24222
|
+
const known = resolveProducts(graph.project).map((entry) => entry.id);
|
|
24223
|
+
if (!known.includes(product)) {
|
|
24224
|
+
throw new ToolError(known.length === 0 ? `This project declares no products, so \`product\` "${product}" names none.` : `No product "${product}" (declared: ${known.join(", ")}).`);
|
|
24225
|
+
}
|
|
24226
|
+
}
|
|
24227
|
+
if (nowArg !== void 0 && !isIsoDate2(nowArg)) throw new ToolError("`now` must be an ISO 8601 date or date-time.");
|
|
24228
|
+
const now = nowArg !== void 0 ? new Date(nowArg) : /* @__PURE__ */ new Date();
|
|
24229
|
+
const input = {
|
|
24230
|
+
nodes: graph.nodes,
|
|
24231
|
+
edges: graph.edges,
|
|
24232
|
+
events: graph.journal,
|
|
24233
|
+
now,
|
|
24234
|
+
project: graph.project,
|
|
24235
|
+
productId: product ?? null,
|
|
24236
|
+
...proofSources(ctx, graph)
|
|
24237
|
+
};
|
|
24238
|
+
const common = { now: now.toISOString(), product: product ?? null };
|
|
24239
|
+
if (stakeId !== void 0) {
|
|
24240
|
+
const proof = deriveStakeProof({ ...input, stakeId });
|
|
24241
|
+
if (proof === null) {
|
|
24242
|
+
const found = graph.nodes.find((node) => node.id === stakeId);
|
|
24243
|
+
throw new ToolError(found === void 0 ? `No node with id "${stakeId}".` : `"${stakeId}" is a ${found.species}, not a stake.`);
|
|
24244
|
+
}
|
|
24245
|
+
return { ...common, stake: proof };
|
|
24246
|
+
}
|
|
24247
|
+
const stakes = deriveStakeProofs(input);
|
|
24248
|
+
const counts = Object.fromEntries([...STAKE_STATES, "archived"].map((state) => [state, 0]));
|
|
24249
|
+
for (const proof of stakes) counts[proof.state ?? "archived"]++;
|
|
24250
|
+
return { ...common, count: stakes.length, counts, stakes };
|
|
24251
|
+
}
|
|
24252
|
+
);
|
|
24253
|
+
return { tools: tools2, handlers: handlers2 };
|
|
24254
|
+
}
|
|
24255
|
+
|
|
24256
|
+
// src/qualify-tools.ts
|
|
24257
|
+
var questionText = ROUTING_QUESTIONS.map((q) => `${q.id}: ${q.question} (${Object.keys(q.answers).join(" | ")})`).join(" ");
|
|
24258
|
+
var ANSWER_PROPERTIES = {
|
|
24259
|
+
scope: { type: "string", enum: [...QUALIFY_SCOPES] },
|
|
24260
|
+
door: { type: "string", enum: [...QUALIFY_DOORS], description: "Default: collect for an observed signal, imagine for an anticipated one or an idea." },
|
|
24261
|
+
facing: { type: "string", enum: [...QUALIFY_FACINGS] },
|
|
24262
|
+
expectation: { type: "string", enum: [...QUALIFY_EXPECTATIONS], description: "When facing is value." },
|
|
24263
|
+
threat: { type: "string", enum: [...QUALIFY_THREATS], description: "When facing is quality." },
|
|
24264
|
+
basis: { type: "string", enum: [...QUALIFY_BASES], description: "Default: stated." }
|
|
24265
|
+
};
|
|
24266
|
+
var SIGNAL_PROPERTIES = {
|
|
24267
|
+
signal_id: { type: "string", description: "A request.filed or idea.proposed event id from the backlog. Or pass title inline." },
|
|
24268
|
+
title: { type: "string", description: "Inline signal, when it has no journal event (then no evidence event_id is recorded)." },
|
|
24269
|
+
verbatim: { type: "string", description: "Inline signal: the input exactly as voiced." },
|
|
24270
|
+
anchors: {
|
|
24271
|
+
type: "array",
|
|
24272
|
+
items: { type: "string" },
|
|
24273
|
+
description: "Flow, view, data-model or api-endpoint ids the stake concerns. Defaults to the signal's node_id when that is one."
|
|
24274
|
+
},
|
|
24275
|
+
catalog_id: { type: "string", description: "A Kritik criterion id (requirement, risk, defect) or a value id (bug, friction, need). Defaults to an audit finding's criterion_id." }
|
|
24276
|
+
};
|
|
24277
|
+
function optionalString2(args, key) {
|
|
24278
|
+
const value = args[key];
|
|
24279
|
+
return typeof value === "string" && value !== "" ? value : void 0;
|
|
24280
|
+
}
|
|
24281
|
+
function readEnum(args, key, allowed) {
|
|
24282
|
+
const value = args[key];
|
|
24283
|
+
if (value === void 0) return void 0;
|
|
24284
|
+
if (!allowed.includes(value)) throw new ToolError(`\`${key}\` must be one of: ${allowed.join(", ")}.`);
|
|
24285
|
+
return value;
|
|
24286
|
+
}
|
|
24287
|
+
function isIdea(signal) {
|
|
24288
|
+
return signal.provenance === "anticipated" || signal.source_kind === "idea";
|
|
24289
|
+
}
|
|
24290
|
+
function readAnswers(args, signal) {
|
|
24291
|
+
const answers = { door: readEnum(args, "door", QUALIFY_DOORS) ?? (isIdea(signal) ? "imagine" : "collect") };
|
|
24292
|
+
const scope = readEnum(args, "scope", QUALIFY_SCOPES);
|
|
24293
|
+
const facing = readEnum(args, "facing", QUALIFY_FACINGS);
|
|
24294
|
+
const expectation = readEnum(args, "expectation", QUALIFY_EXPECTATIONS);
|
|
24295
|
+
const threat = readEnum(args, "threat", QUALIFY_THREATS);
|
|
24296
|
+
const basis = readEnum(args, "basis", QUALIFY_BASES);
|
|
24297
|
+
if (scope !== void 0) answers.scope = scope;
|
|
24298
|
+
if (facing !== void 0) answers.facing = facing;
|
|
24299
|
+
if (expectation !== void 0) answers.expectation = expectation;
|
|
24300
|
+
if (threat !== void 0) answers.threat = threat;
|
|
24301
|
+
if (basis !== void 0) answers.basis = basis;
|
|
24302
|
+
return answers;
|
|
24303
|
+
}
|
|
24304
|
+
function resolveSignal(args, journal) {
|
|
24305
|
+
const signalId = optionalString2(args, "signal_id");
|
|
24306
|
+
if (signalId === void 0) {
|
|
24307
|
+
const title = optionalString2(args, "title");
|
|
24308
|
+
if (title === void 0) throw new ToolError("Pass `signal_id` (a backlog event id) or an inline `title`.");
|
|
24309
|
+
const verbatim = optionalString2(args, "verbatim");
|
|
24310
|
+
return { title, ...verbatim !== void 0 ? { verbatim } : {} };
|
|
24311
|
+
}
|
|
24312
|
+
const event = journal.find((candidate) => candidate.id === signalId);
|
|
24313
|
+
if (event === void 0 || event.type !== "request.filed" && event.type !== "idea.proposed") {
|
|
24314
|
+
throw new ToolError(`No request.filed or idea.proposed event with id "${signalId}".`);
|
|
24315
|
+
}
|
|
24316
|
+
const request = event;
|
|
24317
|
+
const kind = event.type === "idea.proposed" ? "idea" : signalSourceKindOf(request);
|
|
24318
|
+
return {
|
|
24319
|
+
event_id: event.id,
|
|
24320
|
+
title: typeof request.title === "string" ? request.title : signalId,
|
|
24321
|
+
...typeof request.verbatim === "string" && request.verbatim !== "" ? { verbatim: request.verbatim } : {},
|
|
24322
|
+
date: event.ts,
|
|
24323
|
+
...kind !== void 0 ? { source_kind: kind } : {},
|
|
24324
|
+
...request.provenance === "anticipated" || request.provenance === "observed" ? { provenance: request.provenance } : {},
|
|
24325
|
+
...typeof request.node_id === "string" ? { node_id: request.node_id } : {},
|
|
24326
|
+
...typeof request.criterion_id === "string" ? { criterion_id: request.criterion_id } : {}
|
|
24327
|
+
};
|
|
24328
|
+
}
|
|
24329
|
+
function resolveAnchors(args, signal, nodes) {
|
|
24330
|
+
if (args.anchors !== void 0) {
|
|
24331
|
+
if (!Array.isArray(args.anchors) || args.anchors.some((id) => typeof id !== "string" || id === "")) {
|
|
24332
|
+
throw new ToolError("`anchors` must be an array of node ids.");
|
|
24333
|
+
}
|
|
24334
|
+
return args.anchors;
|
|
24335
|
+
}
|
|
24336
|
+
const node = signal.node_id === void 0 ? void 0 : nodes.find((candidate) => candidate.id === signal.node_id);
|
|
24337
|
+
return node !== void 0 && STAKE_ANCHOR_SPECIES.includes(node.species) ? [node.id] : [];
|
|
24338
|
+
}
|
|
24339
|
+
function resolveCatalogId(args, signal, species) {
|
|
24340
|
+
const explicit = optionalString2(args, "catalog_id");
|
|
24341
|
+
if (explicit !== void 0) return explicit;
|
|
24342
|
+
return QUALITY_STAKE_SPECIES.includes(species) ? signal.criterion_id : void 0;
|
|
24343
|
+
}
|
|
24344
|
+
function routeFor(args, signal) {
|
|
24345
|
+
const answers = readAnswers(args, signal);
|
|
24346
|
+
const routing = routeSpecies(answers);
|
|
24347
|
+
if (routing.route === "stake" && answers.door === "collect" && isIdea(signal)) {
|
|
24348
|
+
routing.handToHuman.push("This signal is an idea but came through the collect door: it is read as observed. A person confirms the door.");
|
|
24349
|
+
}
|
|
24350
|
+
return routing;
|
|
24351
|
+
}
|
|
24352
|
+
function suggestionFor(routing, candidates, citing) {
|
|
24353
|
+
if (routing.route === "incomplete") return { action: "ask" };
|
|
24354
|
+
if (routing.route === "refused") return { action: "refused" };
|
|
24355
|
+
if (routing.route !== "stake") return { action: "route-out" };
|
|
24356
|
+
if (citing !== void 0) return { action: "already-qualified", stake_id: citing.id };
|
|
24357
|
+
const top = candidates[0];
|
|
24358
|
+
if (top?.alreadyCited) return { action: "already-qualified", stake_id: top.stake_id };
|
|
24359
|
+
if (top !== void 0 && (top.confidence === "high" || top.confidence === "medium")) {
|
|
24360
|
+
return { action: "merge", merge_into: top.stake_id, confidence: top.confidence };
|
|
24361
|
+
}
|
|
24362
|
+
return { action: "create" };
|
|
24363
|
+
}
|
|
24364
|
+
function buildQualifyCatalog(ctx, io) {
|
|
24365
|
+
const tools2 = [];
|
|
24366
|
+
const handlers2 = {};
|
|
24367
|
+
const tool = (definition, handler) => {
|
|
24368
|
+
tools2.push(definition);
|
|
24369
|
+
handlers2[definition.name] = handler;
|
|
24370
|
+
};
|
|
24371
|
+
tool(
|
|
24372
|
+
{
|
|
24373
|
+
name: "qualify_signal",
|
|
24374
|
+
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.`,
|
|
24375
|
+
inputSchema: {
|
|
24376
|
+
type: "object",
|
|
24377
|
+
properties: { ...SIGNAL_PROPERTIES, ...ANSWER_PROPERTIES },
|
|
24378
|
+
additionalProperties: false
|
|
24379
|
+
}
|
|
24380
|
+
},
|
|
24381
|
+
async (args) => {
|
|
24382
|
+
const graph = await io.load();
|
|
24383
|
+
const signal = resolveSignal(args, graph.journal);
|
|
24384
|
+
const routing = routeFor(args, signal);
|
|
24385
|
+
const anchors = resolveAnchors(args, signal, graph.nodes);
|
|
24386
|
+
const citing = routing.route === "stake" ? stakeCiting(graph.nodes, signal.event_id) : void 0;
|
|
24387
|
+
if (citing !== void 0 && routing.species !== void 0 && stakeSpeciesOf(citing) !== routing.species) {
|
|
24388
|
+
const was = stakeSpeciesOf(citing);
|
|
24389
|
+
routing.handToHuman.push(
|
|
24390
|
+
`${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.`
|
|
24391
|
+
);
|
|
24392
|
+
}
|
|
24393
|
+
const catalog_id = routing.species !== void 0 ? resolveCatalogId(args, signal, routing.species) : void 0;
|
|
24394
|
+
let candidates = [];
|
|
24395
|
+
if (routing.route === "stake" && routing.species !== void 0) {
|
|
24396
|
+
const like = {
|
|
24397
|
+
title: signal.title,
|
|
24398
|
+
species: routing.species,
|
|
24399
|
+
node_ids: anchors,
|
|
24400
|
+
...signal.event_id !== void 0 ? { event_id: signal.event_id } : {},
|
|
24401
|
+
...signal.verbatim !== void 0 ? { verbatim: signal.verbatim } : {},
|
|
24402
|
+
...catalog_id !== void 0 ? { catalog_id } : {},
|
|
24403
|
+
...signal.source_kind !== void 0 ? { source_kind: signal.source_kind } : {}
|
|
24404
|
+
};
|
|
24405
|
+
candidates = findMergeCandidates(like, graph.nodes, { edges: graph.edges });
|
|
24406
|
+
}
|
|
24407
|
+
return {
|
|
24408
|
+
signal: {
|
|
24409
|
+
...signal.event_id !== void 0 ? { event_id: signal.event_id } : {},
|
|
24410
|
+
title: signal.title,
|
|
24411
|
+
...signal.source_kind !== void 0 ? { source_kind: signal.source_kind } : {},
|
|
24412
|
+
...signal.provenance !== void 0 ? { provenance: signal.provenance } : {}
|
|
24413
|
+
},
|
|
24414
|
+
routing,
|
|
24415
|
+
anchors,
|
|
24416
|
+
...catalog_id !== void 0 ? { catalog_id } : {},
|
|
24417
|
+
candidates,
|
|
24418
|
+
suggestion: suggestionFor(routing, candidates, citing),
|
|
24419
|
+
...routing.route === "incomplete" ? { questions: ROUTING_QUESTIONS.filter((question) => routing.ask.includes(question.id)) } : {}
|
|
24420
|
+
};
|
|
24421
|
+
}
|
|
24422
|
+
);
|
|
24423
|
+
tool(
|
|
24424
|
+
{
|
|
24425
|
+
name: "promote_signal",
|
|
24426
|
+
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.`,
|
|
24427
|
+
inputSchema: {
|
|
24428
|
+
type: "object",
|
|
24429
|
+
properties: {
|
|
24430
|
+
...SIGNAL_PROPERTIES,
|
|
24431
|
+
...ANSWER_PROPERTIES,
|
|
24432
|
+
create: { type: "boolean", description: "Create a new stake. Exactly one of create / merge_into." },
|
|
24433
|
+
merge_into: { type: "string", description: "The stake id to add the signal to as evidence." },
|
|
24434
|
+
stake_title: { type: "string", description: "The new stake's wording." },
|
|
24435
|
+
voice: { type: "string", enum: [...STAKE_EVIDENCE_VOICES], description: "Who voiced the signal." }
|
|
24436
|
+
},
|
|
24437
|
+
additionalProperties: false
|
|
24438
|
+
}
|
|
24439
|
+
},
|
|
24440
|
+
async (args) => {
|
|
24441
|
+
const graph = await io.load();
|
|
24442
|
+
const signal = resolveSignal(args, graph.journal);
|
|
24443
|
+
const mergeInto = optionalString2(args, "merge_into");
|
|
24444
|
+
if (mergeInto !== void 0 === (args.create === true)) {
|
|
24445
|
+
throw new ToolError("Pass exactly one of `create: true` or `merge_into` (a stake id).");
|
|
24446
|
+
}
|
|
24447
|
+
const routing = routeFor(args, signal);
|
|
24448
|
+
if (routing.route !== "stake" || routing.species === void 0 || routing.provenance === void 0) {
|
|
24449
|
+
throw new ToolError(
|
|
24450
|
+
routing.route === "incomplete" ? `Not enough answers to route the species: ${routing.ask.join(", ")}. Call qualify_signal first.` : `Not promoted: ${routing.reasons.join(" ")}`,
|
|
24451
|
+
{ routing }
|
|
24452
|
+
);
|
|
24453
|
+
}
|
|
24454
|
+
const voice = readEnum(args, "voice", STAKE_EVIDENCE_VOICES);
|
|
24455
|
+
const evidenceSignal = {
|
|
24456
|
+
title: signal.title,
|
|
24457
|
+
...signal.event_id !== void 0 ? { event_id: signal.event_id } : {},
|
|
24458
|
+
...signal.verbatim !== void 0 ? { verbatim: signal.verbatim } : {},
|
|
24459
|
+
...signal.date !== void 0 ? { date: signal.date } : {},
|
|
24460
|
+
...voice !== void 0 ? { voice } : {}
|
|
24461
|
+
};
|
|
24462
|
+
let plan;
|
|
24463
|
+
if (mergeInto !== void 0) {
|
|
24464
|
+
const target = graph.nodes.find((node) => node.id === mergeInto);
|
|
24465
|
+
if (target === void 0) throw new ToolError(`No node with id "${mergeInto}".`);
|
|
24466
|
+
plan = planSignalMerge({ signal: evidenceSignal, target, species: routing.species, nodes: graph.nodes });
|
|
24467
|
+
} else {
|
|
24468
|
+
const catalogId = resolveCatalogId(args, signal, routing.species);
|
|
24469
|
+
const catalog = catalogId !== void 0 ? { source: catalogSourceForStakeSpecies(routing.species), id: catalogId } : void 0;
|
|
24470
|
+
const title = optionalString2(args, "stake_title");
|
|
24471
|
+
plan = planSignalToStake({
|
|
24472
|
+
projectId: graph.project.id,
|
|
24473
|
+
signal: evidenceSignal,
|
|
24474
|
+
species: routing.species,
|
|
24475
|
+
provenance: routing.provenance,
|
|
24476
|
+
anchors: resolveAnchors(args, signal, graph.nodes),
|
|
24477
|
+
nodes: graph.nodes,
|
|
24478
|
+
edges: graph.edges,
|
|
24479
|
+
...title !== void 0 ? { title } : {},
|
|
24480
|
+
...catalog !== void 0 ? { catalog } : {}
|
|
24481
|
+
});
|
|
24482
|
+
}
|
|
24483
|
+
const handToHuman = [...routing.handToHuman, ...plan.handToHuman];
|
|
24484
|
+
if (plan.action === "refused") throw new ToolError(`Not promoted: ${plan.reasons.join(" ")}`, { reasons: plan.reasons });
|
|
24485
|
+
if (plan.action === "noop") {
|
|
24486
|
+
return { action: "noop", stake_id: plan.stake_id, reasons: plan.reasons, ops: [], events: [], warnings: [], handToHuman };
|
|
24487
|
+
}
|
|
24488
|
+
const outcome = io.mutate(graph, plan.ops);
|
|
24489
|
+
const result = await ctx.store.persist(graph, { nodes: outcome.nodes, edges: outcome.edges, ops: plan.ops }, outcome.eventInputs);
|
|
24490
|
+
const { warnings, events } = io.unwrap(result);
|
|
24491
|
+
const stakeId = plan.stake_id;
|
|
24492
|
+
return {
|
|
24493
|
+
action: plan.action,
|
|
24494
|
+
stake_id: stakeId,
|
|
24495
|
+
stake: outcome.nodes.find((node) => node.id === stakeId),
|
|
24496
|
+
anchors: stakeAnchors(stakeId, outcome.edges),
|
|
24497
|
+
ops: plan.ops,
|
|
24498
|
+
events,
|
|
24499
|
+
warnings,
|
|
24500
|
+
handToHuman
|
|
24501
|
+
};
|
|
24502
|
+
}
|
|
24503
|
+
);
|
|
24504
|
+
return { tools: tools2, handlers: handlers2 };
|
|
24505
|
+
}
|
|
24506
|
+
|
|
22553
24507
|
// src/weighing-tools.ts
|
|
22554
24508
|
import { execFile } from "node:child_process";
|
|
22555
24509
|
|
|
@@ -22661,7 +24615,7 @@ async function resolveOnBehalfOf(root, env = process.env) {
|
|
|
22661
24615
|
}
|
|
22662
24616
|
return void 0;
|
|
22663
24617
|
}
|
|
22664
|
-
function
|
|
24618
|
+
function requireString3(args, key) {
|
|
22665
24619
|
const value = args[key];
|
|
22666
24620
|
if (typeof value !== "string" || value.length === 0) throw new ToolError(`\`${key}\` is required and must be a non-empty string.`);
|
|
22667
24621
|
return value;
|
|
@@ -22673,7 +24627,7 @@ function requireInt2(args, key, min, max) {
|
|
|
22673
24627
|
}
|
|
22674
24628
|
return value;
|
|
22675
24629
|
}
|
|
22676
|
-
var
|
|
24630
|
+
var optionalString3 = (args, key) => typeof args[key] === "string" && args[key] !== "" ? args[key] : void 0;
|
|
22677
24631
|
function cellRow(cell, withProbabilities) {
|
|
22678
24632
|
return {
|
|
22679
24633
|
criterion: cell.criterion,
|
|
@@ -22692,8 +24646,30 @@ function cellRow(cell, withProbabilities) {
|
|
|
22692
24646
|
...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
24647
|
};
|
|
22694
24648
|
}
|
|
22695
|
-
function
|
|
24649
|
+
function stakeFacts(node) {
|
|
24650
|
+
if (node === void 0 || node.species !== "stake") return {};
|
|
24651
|
+
const kind = stakeSpeciesOf(node);
|
|
22696
24652
|
return {
|
|
24653
|
+
stake: {
|
|
24654
|
+
stake_species: kind ?? null,
|
|
24655
|
+
...kind !== void 0 ? { reference: referenceForStakeSpecies(kind) } : {},
|
|
24656
|
+
...stakeFeltOf(node) !== void 0 ? { felt: stakeFeltOf(node) } : {},
|
|
24657
|
+
...stakeMattersOf(node) !== void 0 ? { matters: stakeMattersOf(node) } : {},
|
|
24658
|
+
...stakeFrequencyOf(node) !== void 0 ? { frequency: stakeFrequencyOf(node) } : {}
|
|
24659
|
+
}
|
|
24660
|
+
};
|
|
24661
|
+
}
|
|
24662
|
+
function stakeGroupOf(node) {
|
|
24663
|
+
const species = node === void 0 ? void 0 : stakeSpeciesOf(node);
|
|
24664
|
+
const felt = node === void 0 ? void 0 : species === "bug" ? "expected" : stakeFeltOf(node);
|
|
24665
|
+
return { key: `${species ?? "unknown"}${felt !== void 0 ? `:${felt}` : ""}`, stake_species: species ?? null, ...felt !== void 0 ? { felt } : {} };
|
|
24666
|
+
}
|
|
24667
|
+
var STAKE_GROUP_ORDER = ["bug", "friction", "need"];
|
|
24668
|
+
var FELT_ORDER = ["expected", "wanted", "delight"];
|
|
24669
|
+
var defaultMatrixFor = (nodes, subject) => nodes.find((candidate) => candidate.id === subject)?.species === "stake" ? STAKE_MATRIX_ID : VALUE_MATRIX_ID;
|
|
24670
|
+
function promiseRow(promise2, withCells, withProbabilities = false, node) {
|
|
24671
|
+
return {
|
|
24672
|
+
...stakeFacts(node),
|
|
22697
24673
|
node_id: promise2.node_id,
|
|
22698
24674
|
title: promise2.title,
|
|
22699
24675
|
status: promise2.status,
|
|
@@ -22765,12 +24741,12 @@ function buildWeighingCatalog(ctx) {
|
|
|
22765
24741
|
tool(
|
|
22766
24742
|
{
|
|
22767
24743
|
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.",
|
|
24744
|
+
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
24745
|
inputSchema: {
|
|
22770
24746
|
type: "object",
|
|
22771
24747
|
properties: {
|
|
22772
|
-
matrix: { type: "string", description: `Default: ${VALUE_MATRIX_ID}.` },
|
|
22773
|
-
subject: { type: "string", description: "An acceptance id: return that promise with every cell." },
|
|
24748
|
+
matrix: { type: "string", description: `Default: ${VALUE_MATRIX_ID}, or ${STAKE_MATRIX_ID} when \`subject\` is a stake.` },
|
|
24749
|
+
subject: { type: "string", description: "An acceptance or stake id: return that promise with every cell." },
|
|
22774
24750
|
sort: { type: "string", enum: ["served", "cost", "positioned", "title"], description: "Default: served, heaviest first." },
|
|
22775
24751
|
filter: { type: "string", enum: [...FILTERS] },
|
|
22776
24752
|
limit: { type: "integer", minimum: 1, maximum: 200, description: "Default 25." },
|
|
@@ -22783,9 +24759,11 @@ function buildWeighingCatalog(ctx) {
|
|
|
22783
24759
|
const graph = await load2();
|
|
22784
24760
|
const section = sectionOf(graph);
|
|
22785
24761
|
const nodes = graph.nodes;
|
|
22786
|
-
const matrixId =
|
|
24762
|
+
const matrixId = optionalString3(args, "matrix") ?? defaultMatrixFor(nodes, optionalString3(args, "subject"));
|
|
22787
24763
|
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
|
|
24764
|
+
if (view === void 0) throw new ToolError(`No usable matrix "${matrixId}" (unknown, or a draft \u2014 a draft feeds no roll-up). The built-in ones are "${VALUE_MATRIX_ID}" and "${STAKE_MATRIX_ID}".`);
|
|
24765
|
+
const judgesStakes = view.matrix.subjects.kind === "query" && view.matrix.subjects.species === "stake";
|
|
24766
|
+
const nodesById = new Map(nodes.map((node) => [node.id, node]));
|
|
22789
24767
|
const positioning = view.positioning === null ? null : {
|
|
22790
24768
|
status: view.positioning.active ? "active" : "draft",
|
|
22791
24769
|
elements: [...view.positioning.weights].map(([id, weight]) => {
|
|
@@ -22797,8 +24775,10 @@ function buildWeighingCatalog(ctx) {
|
|
|
22797
24775
|
const notes = [];
|
|
22798
24776
|
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
24777
|
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
|
-
|
|
24778
|
+
if (view.totals.assessed === 0) {
|
|
24779
|
+
notes.push(judgesStakes ? "Nothing has been assessed yet \u2014 a stake is never seeded, so every cell is blank until someone scores it." : "Nothing has been assessed yet \u2014 every claimed value is seeded at +1 (confidence 0), a guess.");
|
|
24780
|
+
}
|
|
24781
|
+
const subject = optionalString3(args, "subject");
|
|
22802
24782
|
if (subject !== void 0) {
|
|
22803
24783
|
const promise2 = view.promises.find((candidate) => candidate.node_id === subject);
|
|
22804
24784
|
if (promise2 === void 0) throw new ToolError(`"${subject}" is not a subject of matrix "${matrixId}" (it judges ${view.matrix.subjects.kind === "query" ? `${view.matrix.subjects.species} nodes` : "a listed set"}).`);
|
|
@@ -22816,19 +24796,17 @@ function buildWeighingCatalog(ctx) {
|
|
|
22816
24796
|
})),
|
|
22817
24797
|
confidence_anchors: CONFIDENCE_ANCHORS,
|
|
22818
24798
|
positioning,
|
|
22819
|
-
promise: promiseRow(promise2, true, args.probabilities === true),
|
|
24799
|
+
promise: promiseRow(promise2, true, args.probabilities === true, nodesById.get(promise2.node_id)),
|
|
22820
24800
|
...skipped.length > 0 ? { skipped } : {},
|
|
22821
24801
|
...notes.length > 0 ? { notes } : {}
|
|
22822
24802
|
};
|
|
22823
24803
|
}
|
|
22824
|
-
const sort =
|
|
24804
|
+
const sort = optionalString3(args, "sort") ?? "served";
|
|
22825
24805
|
if (!["served", "cost", "positioned", "title"].includes(sort)) throw new ToolError("`sort` must be served, cost, positioned or title.");
|
|
22826
|
-
const filter =
|
|
24806
|
+
const filter = optionalString3(args, "filter");
|
|
22827
24807
|
if (filter !== void 0 && !FILTERS.includes(filter)) throw new ToolError(`\`filter\` must be one of ${FILTERS.join(", ")}.`);
|
|
22828
24808
|
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 }) => ({
|
|
24809
|
+
const elementRows = (v) => v.set.criteria.map((criterion) => ({ criterion, mass: v.elements[criterion.id] })).filter(({ mass }) => mass.promised > 0 || mass.cost > 0).sort((a, b) => b.mass.promised - a.mass.promised).map(({ criterion, mass }) => ({
|
|
22832
24810
|
id: criterion.id,
|
|
22833
24811
|
name: criterion.name,
|
|
22834
24812
|
tier: criterion.group,
|
|
@@ -22837,20 +24815,59 @@ function buildWeighingCatalog(ctx) {
|
|
|
22837
24815
|
cost: round2(mass.cost),
|
|
22838
24816
|
guesswork: { promised: round2(mass.guesswork.promised), kept: round2(mass.guesswork.kept), cost: round2(mass.guesswork.cost) }
|
|
22839
24817
|
}));
|
|
24818
|
+
const totalsOf = (v) => ({
|
|
24819
|
+
promises: v.totals.promises,
|
|
24820
|
+
archived: v.totals.archived,
|
|
24821
|
+
assessed: v.totals.assessed,
|
|
24822
|
+
promised: round2(v.totals.promised),
|
|
24823
|
+
kept: round2(v.totals.kept),
|
|
24824
|
+
cost: round2(v.totals.cost),
|
|
24825
|
+
guesswork: { promised: round2(v.totals.guesswork.promised), kept: round2(v.totals.guesswork.kept), cost: round2(v.totals.guesswork.cost) }
|
|
24826
|
+
});
|
|
24827
|
+
const rowsOf4 = (v) => {
|
|
24828
|
+
const matching = v.promises.filter((promise2) => filter === void 0 || matchesFilter(promise2, filter));
|
|
24829
|
+
const ordered2 = sortPromises(matching, sort);
|
|
24830
|
+
return { ordered: ordered2, rows: ordered2.slice(0, limit).map((promise2) => promiseRow(promise2, false, false, nodesById.get(promise2.node_id))) };
|
|
24831
|
+
};
|
|
24832
|
+
if (judgesStakes) {
|
|
24833
|
+
const members = /* @__PURE__ */ new Map();
|
|
24834
|
+
for (const promise2 of view.promises) {
|
|
24835
|
+
const group = stakeGroupOf(nodesById.get(promise2.node_id));
|
|
24836
|
+
const entry = members.get(group.key) ?? { group, ids: /* @__PURE__ */ new Set() };
|
|
24837
|
+
entry.ids.add(promise2.node_id);
|
|
24838
|
+
members.set(group.key, entry);
|
|
24839
|
+
}
|
|
24840
|
+
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));
|
|
24841
|
+
const groups = [...members.values()].sort((a, b) => rank(a.group) - rank(b.group)).map(({ group, ids }) => {
|
|
24842
|
+
const groupView = deriveWeighing(nodes.filter((node) => node.species !== "stake" || ids.has(node.id)), section, matrixId);
|
|
24843
|
+
if (groupView === void 0) throw new ToolError(`No usable matrix "${matrixId}".`);
|
|
24844
|
+
const { ordered: ordered2, rows: rows2 } = rowsOf4(groupView);
|
|
24845
|
+
return {
|
|
24846
|
+
stake_species: group.stake_species,
|
|
24847
|
+
...group.felt !== void 0 ? { felt: group.felt } : {},
|
|
24848
|
+
totals: totalsOf(groupView),
|
|
24849
|
+
elements: elementRows(groupView),
|
|
24850
|
+
promises: rows2,
|
|
24851
|
+
matching: ordered2.length
|
|
24852
|
+
};
|
|
24853
|
+
});
|
|
24854
|
+
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.");
|
|
24855
|
+
return {
|
|
24856
|
+
matrix: { id: view.matrix.id, set: view.matrix.set, set_version: view.set.version },
|
|
24857
|
+
positioning,
|
|
24858
|
+
totals: { promises: view.totals.promises, archived: view.totals.archived, assessed: view.totals.assessed },
|
|
24859
|
+
groups,
|
|
24860
|
+
...skipped.length > 0 ? { skipped } : {},
|
|
24861
|
+
...notes.length > 0 ? { notes } : {}
|
|
24862
|
+
};
|
|
24863
|
+
}
|
|
24864
|
+
const { ordered, rows } = rowsOf4(view);
|
|
22840
24865
|
return {
|
|
22841
24866
|
matrix: { id: view.matrix.id, set: view.matrix.set, set_version: view.set.version },
|
|
22842
24867
|
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)),
|
|
24868
|
+
totals: totalsOf(view),
|
|
24869
|
+
elements: elementRows(view),
|
|
24870
|
+
promises: rows,
|
|
22854
24871
|
matching: ordered.length,
|
|
22855
24872
|
...skipped.length > 0 ? { skipped } : {},
|
|
22856
24873
|
...notes.length > 0 ? { notes } : {}
|
|
@@ -22860,11 +24877,11 @@ function buildWeighingCatalog(ctx) {
|
|
|
22860
24877
|
tool(
|
|
22861
24878
|
{
|
|
22862
24879
|
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.",
|
|
24880
|
+
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
24881
|
inputSchema: {
|
|
22865
24882
|
type: "object",
|
|
22866
24883
|
properties: {
|
|
22867
|
-
subject: { type: "string", description: "An acceptance id." },
|
|
24884
|
+
subject: { type: "string", description: "An acceptance id, or a bug, friction or need stake id." },
|
|
22868
24885
|
criterion: { type: "string", description: "A value element id, e.g. reduces-anxiety." },
|
|
22869
24886
|
level: { type: "integer", minimum: -3, maximum: 3 },
|
|
22870
24887
|
confidence: { type: "integer", enum: [0, 1, 2, 3] },
|
|
@@ -22873,7 +24890,7 @@ function buildWeighingCatalog(ctx) {
|
|
|
22873
24890
|
model: { type: "string", maxLength: 200, description: "The model you are, when you know. At most 200 characters." },
|
|
22874
24891
|
run: { type: "string", maxLength: 200, description: "The audit or session this score belongs to. At most 200 characters." },
|
|
22875
24892
|
commit: { type: "string", maxLength: 200 },
|
|
22876
|
-
matrix: { type: "string", description: `Default: ${VALUE_MATRIX_ID}.` },
|
|
24893
|
+
matrix: { type: "string", description: `Default: ${VALUE_MATRIX_ID}, or ${STAKE_MATRIX_ID} when the subject is a stake.` },
|
|
22877
24894
|
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
24895
|
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
24896
|
},
|
|
@@ -22882,12 +24899,12 @@ function buildWeighingCatalog(ctx) {
|
|
|
22882
24899
|
}
|
|
22883
24900
|
},
|
|
22884
24901
|
async (args) => {
|
|
22885
|
-
const subject =
|
|
22886
|
-
const criterion =
|
|
24902
|
+
const subject = requireString3(args, "subject");
|
|
24903
|
+
const criterion = requireString3(args, "criterion");
|
|
22887
24904
|
const level = args.level;
|
|
22888
24905
|
if (typeof level !== "number" || !Number.isInteger(level)) throw new ToolError("`level` is required and must be an integer (the scale is -3 to +3).");
|
|
22889
24906
|
const confidence = requireInt2(args, "confidence", 0, 3);
|
|
22890
|
-
const evidence =
|
|
24907
|
+
const evidence = optionalString3(args, "evidence");
|
|
22891
24908
|
if (confidence > 0 && (evidence === void 0 || evidence.trim() === "")) {
|
|
22892
24909
|
throw new ToolError("`evidence` is required above confidence 0 \u2014 a score without a citation is an opinion, not an assessment. Say what you read, or score at confidence 0.");
|
|
22893
24910
|
}
|
|
@@ -22898,12 +24915,12 @@ function buildWeighingCatalog(ctx) {
|
|
|
22898
24915
|
criterion,
|
|
22899
24916
|
level,
|
|
22900
24917
|
confidence,
|
|
22901
|
-
...
|
|
24918
|
+
...optionalString3(args, "matrix") !== void 0 ? { matrix: optionalString3(args, "matrix") } : {},
|
|
22902
24919
|
...evidence !== void 0 ? { evidence } : {},
|
|
22903
24920
|
...refs !== void 0 && refs.length > 0 ? { refs } : {},
|
|
22904
|
-
...
|
|
22905
|
-
...
|
|
22906
|
-
...
|
|
24921
|
+
...optionalString3(args, "model") !== void 0 ? { model: optionalString3(args, "model") } : {},
|
|
24922
|
+
...optionalString3(args, "run") !== void 0 ? { run: optionalString3(args, "run") } : {},
|
|
24923
|
+
...optionalString3(args, "commit") !== void 0 ? { commit: optionalString3(args, "commit") } : {},
|
|
22907
24924
|
// Passed as given: a value off 0..1 is the planner's to refuse, with the reason.
|
|
22908
24925
|
...args.p_serves !== void 0 ? { p_serves: args.p_serves } : {},
|
|
22909
24926
|
...args.p_costs !== void 0 ? { p_costs: args.p_costs } : {}
|
|
@@ -22911,11 +24928,11 @@ function buildWeighingCatalog(ctx) {
|
|
|
22911
24928
|
const graph = await load2();
|
|
22912
24929
|
const section = sectionOf(graph);
|
|
22913
24930
|
const nodes = graph.nodes;
|
|
22914
|
-
const matrixId = input.matrix ??
|
|
24931
|
+
const matrixId = input.matrix ?? defaultMatrixFor(nodes, subject);
|
|
22915
24932
|
const view = buildWeighingContext(section, matrixId);
|
|
22916
24933
|
if (view === void 0) {
|
|
22917
24934
|
const matrix = resolveWeighing(section).matrices.find((candidate) => candidate.id === matrixId);
|
|
22918
|
-
if (matrix === void 0) throw new ToolError(`No matrix "${matrixId}". The built-in
|
|
24935
|
+
if (matrix === void 0) throw new ToolError(`No matrix "${matrixId}". The built-in ones are "${VALUE_MATRIX_ID}" and "${STAKE_MATRIX_ID}".`);
|
|
22919
24936
|
if (!isActiveWeighingSet(matrix)) throw new ToolError("This matrix is a draft and feeds no roll-up; activate it first.");
|
|
22920
24937
|
throw new ToolError(`Matrix "${matrixId}" names the set "${matrix.set}", which is not available.`);
|
|
22921
24938
|
}
|
|
@@ -22982,7 +24999,7 @@ function buildWeighingCatalog(ctx) {
|
|
|
22982
24999
|
},
|
|
22983
25000
|
async (args) => {
|
|
22984
25001
|
if (!Array.isArray(args.elements) || args.elements.length === 0) throw new ToolError("`elements` is required: at least one element of value.");
|
|
22985
|
-
const status =
|
|
25002
|
+
const status = optionalString3(args, "status") ?? "draft";
|
|
22986
25003
|
if (status !== "draft" && status !== "active") throw new ToolError("`status` must be draft or active.");
|
|
22987
25004
|
const graph = await load2();
|
|
22988
25005
|
const section = sectionOf(graph);
|
|
@@ -22991,7 +25008,7 @@ function buildWeighingCatalog(ctx) {
|
|
|
22991
25008
|
const set2 = {
|
|
22992
25009
|
id: POSITIONING_SET_ID,
|
|
22993
25010
|
version: "1.0.0",
|
|
22994
|
-
title:
|
|
25011
|
+
title: optionalString3(args, "title") ?? "Positioning",
|
|
22995
25012
|
subject: ruler.subject,
|
|
22996
25013
|
scale: weighingScaleOf(ruler),
|
|
22997
25014
|
role: "positioning",
|
|
@@ -23042,7 +25059,7 @@ async function load(ctx) {
|
|
|
23042
25059
|
journal: graph.journal
|
|
23043
25060
|
};
|
|
23044
25061
|
}
|
|
23045
|
-
function
|
|
25062
|
+
function requireString4(args, key) {
|
|
23046
25063
|
const value = args[key];
|
|
23047
25064
|
if (typeof value !== "string" || value.length === 0) {
|
|
23048
25065
|
throw new ToolError(`\`${key}\` is required and must be a non-empty string.`);
|
|
@@ -23061,8 +25078,23 @@ function findNode(nodes, nodeId) {
|
|
|
23061
25078
|
if (!node) throw new ToolError(`No node with id "${nodeId}".`);
|
|
23062
25079
|
return node;
|
|
23063
25080
|
}
|
|
23064
|
-
function nodeSummary(node) {
|
|
25081
|
+
function nodeSummary(node, graph) {
|
|
23065
25082
|
const base = { id: node.id, title: node.title, species: node.species, status: node.status, platforms: node.platforms };
|
|
25083
|
+
if (node.species === "stake") {
|
|
25084
|
+
const md = node.metadata;
|
|
25085
|
+
return {
|
|
25086
|
+
...base,
|
|
25087
|
+
stake_species: md?.stake_species ?? null,
|
|
25088
|
+
provenance: md?.provenance ?? "observed",
|
|
25089
|
+
// The user-facing kinds only carry these (a requirement, risk or defect is read against a Kritik criterion).
|
|
25090
|
+
...md?.felt !== void 0 ? { felt: md.felt } : {},
|
|
25091
|
+
...md?.matters !== void 0 ? { matters: md.matters } : {},
|
|
25092
|
+
...md?.frequency !== void 0 ? { frequency: md.frequency } : {}
|
|
25093
|
+
};
|
|
25094
|
+
}
|
|
25095
|
+
if (node.species === "option") {
|
|
25096
|
+
return graph ? { ...base, answer_types: answerTypesOf(node.id, graph.nodes, graph.edges) } : base;
|
|
25097
|
+
}
|
|
23066
25098
|
if (node.species !== "acceptance") return base;
|
|
23067
25099
|
const platform_statuses = Object.fromEntries(
|
|
23068
25100
|
node.platforms.map((platform) => [platform, resolvePlatformStatus(node, platform)])
|
|
@@ -23080,7 +25112,7 @@ function unwrap(result) {
|
|
|
23080
25112
|
}
|
|
23081
25113
|
var UPDATABLE_NODE_FIELDS = /* @__PURE__ */ new Set(["title", "description", "status", "platforms", "metadata"]);
|
|
23082
25114
|
function requirePlatform(args) {
|
|
23083
|
-
const raw =
|
|
25115
|
+
const raw = requireString4(args, "platform");
|
|
23084
25116
|
const platform = PLATFORM_IDS.find((id) => id === raw);
|
|
23085
25117
|
if (platform === void 0) {
|
|
23086
25118
|
throw new ToolError(`"${raw}" is not a platform (expected one of: ${PLATFORM_IDS.join(", ")}).`);
|
|
@@ -23088,7 +25120,7 @@ function requirePlatform(args) {
|
|
|
23088
25120
|
return platform;
|
|
23089
25121
|
}
|
|
23090
25122
|
function requireScreenshotForm(args) {
|
|
23091
|
-
const raw =
|
|
25123
|
+
const raw = requireString4(args, "form");
|
|
23092
25124
|
if (raw === "url" || raw === "path" || raw === "data") return raw;
|
|
23093
25125
|
throw new ToolError(`"${raw}" is not a screenshot form (url, path or data).`);
|
|
23094
25126
|
}
|
|
@@ -23172,7 +25204,7 @@ ${node.description ?? ""}`.toLowerCase();
|
|
|
23172
25204
|
}
|
|
23173
25205
|
return true;
|
|
23174
25206
|
});
|
|
23175
|
-
return { total: matches.length, nodes: matches.slice(0, limit).map(nodeSummary) };
|
|
25207
|
+
return { total: matches.length, nodes: matches.slice(0, limit).map((node) => nodeSummary(node, { nodes, edges })) };
|
|
23176
25208
|
}
|
|
23177
25209
|
);
|
|
23178
25210
|
tool(
|
|
@@ -23187,7 +25219,7 @@ ${node.description ?? ""}`.toLowerCase();
|
|
|
23187
25219
|
}
|
|
23188
25220
|
},
|
|
23189
25221
|
async (args) => {
|
|
23190
|
-
const nodeId =
|
|
25222
|
+
const nodeId = requireString4(args, "node_id");
|
|
23191
25223
|
const { nodes, edges, journal } = await load(ctx);
|
|
23192
25224
|
const node = findNode(nodes, nodeId);
|
|
23193
25225
|
const nodesById = new Map(nodes.map((candidate) => [candidate.id, candidate]));
|
|
@@ -23212,12 +25244,12 @@ ${node.description ?? ""}`.toLowerCase();
|
|
|
23212
25244
|
}
|
|
23213
25245
|
}
|
|
23214
25246
|
const whereUsedFlows = [...composingFlowIds].map((flowId) => nodesById.get(flowId)).filter((flow) => flow !== void 0 && flow.species === "flow").map((flow) => ({ id: flow.id, title: flow.title }));
|
|
23215
|
-
const covered_by = node.species === "view" || node.species === "flow" ? acceptancesCovering(nodeId, nodes, edges).map(nodeSummary) : void 0;
|
|
25247
|
+
const covered_by = node.species === "view" || node.species === "flow" ? acceptancesCovering(nodeId, nodes, edges).map((node2) => nodeSummary(node2)) : void 0;
|
|
23216
25248
|
return {
|
|
23217
25249
|
node,
|
|
23218
25250
|
edges: relatedEdges,
|
|
23219
25251
|
whereUsedFlows,
|
|
23220
|
-
timeline: computeNodeTimeline(journal, nodeId),
|
|
25252
|
+
timeline: computeNodeTimeline(journal, nodeId, { evidenceEventIds: stakeEvidenceEventIds([node]) }),
|
|
23221
25253
|
...covered_by !== void 0 ? { covered_by } : {}
|
|
23222
25254
|
};
|
|
23223
25255
|
}
|
|
@@ -23249,7 +25281,10 @@ ${node.description ?? ""}`.toLowerCase();
|
|
|
23249
25281
|
},
|
|
23250
25282
|
async () => {
|
|
23251
25283
|
const { nodes, journal } = await load(ctx);
|
|
23252
|
-
return computeBacklog(journal, {
|
|
25284
|
+
return computeBacklog(journal, {
|
|
25285
|
+
existingNodeIds: new Set(nodes.map((node) => node.id)),
|
|
25286
|
+
evidencedEventIds: stakeEvidenceEventIds(nodes)
|
|
25287
|
+
});
|
|
23253
25288
|
}
|
|
23254
25289
|
);
|
|
23255
25290
|
tool(
|
|
@@ -23281,7 +25316,7 @@ ${node.description ?? ""}`.toLowerCase();
|
|
|
23281
25316
|
}
|
|
23282
25317
|
},
|
|
23283
25318
|
async (args) => {
|
|
23284
|
-
const mapId =
|
|
25319
|
+
const mapId = requireString4(args, "map_id");
|
|
23285
25320
|
const { nodes, edges, project } = await load(ctx);
|
|
23286
25321
|
const definition = listMaps(project).find((candidate) => candidate.id === mapId);
|
|
23287
25322
|
if (!definition) throw new ToolError(`No map with id "${mapId}".`);
|
|
@@ -23308,7 +25343,7 @@ ${node.description ?? ""}`.toLowerCase();
|
|
|
23308
25343
|
tool(
|
|
23309
25344
|
{
|
|
23310
25345
|
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.",
|
|
25346
|
+
description: "Create a node. The id derives from species + title; the mutation is refused (nothing written) if the result fails validation. For a flow, pass its populated metadata.playlist here \u2014 the matching composes edges to every referenced view/sub-flow are synthesized in the same mutation, so a full flow lands in one call. A decision, a stake or an option takes platforms: []; a stake also takes metadata.stake_species (bug, friction, need, requirement, risk or defect) and is anchored with a concerns edge to the flow, view, data model or endpoint it is about; an option never exists without a stake, so link it to the stake it addresses with an addresses edge.",
|
|
23312
25347
|
inputSchema: {
|
|
23313
25348
|
type: "object",
|
|
23314
25349
|
properties: {
|
|
@@ -23325,8 +25360,8 @@ ${node.description ?? ""}`.toLowerCase();
|
|
|
23325
25360
|
},
|
|
23326
25361
|
async (args) => {
|
|
23327
25362
|
const graph = await load(ctx);
|
|
23328
|
-
const species =
|
|
23329
|
-
const title =
|
|
25363
|
+
const species = requireString4(args, "species");
|
|
25364
|
+
const title = requireString4(args, "title");
|
|
23330
25365
|
const platforms = Array.isArray(args.platforms) ? args.platforms : [];
|
|
23331
25366
|
const node = {
|
|
23332
25367
|
id: deriveNodeId(species, title, graph.nodes.map((candidate) => candidate.id)),
|
|
@@ -23352,7 +25387,7 @@ ${node.description ?? ""}`.toLowerCase();
|
|
|
23352
25387
|
tool(
|
|
23353
25388
|
{
|
|
23354
25389
|
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.",
|
|
25390
|
+
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
25391
|
inputSchema: {
|
|
23357
25392
|
type: "object",
|
|
23358
25393
|
properties: {
|
|
@@ -23374,7 +25409,7 @@ ${node.description ?? ""}`.toLowerCase();
|
|
|
23374
25409
|
}
|
|
23375
25410
|
},
|
|
23376
25411
|
async (args) => {
|
|
23377
|
-
const nodeId =
|
|
25412
|
+
const nodeId = requireString4(args, "node_id");
|
|
23378
25413
|
if (typeof args.patch !== "object" || args.patch === null || Array.isArray(args.patch)) {
|
|
23379
25414
|
throw new ToolError("`patch` is required and must be an object.");
|
|
23380
25415
|
}
|
|
@@ -23387,6 +25422,22 @@ ${node.description ?? ""}`.toLowerCase();
|
|
|
23387
25422
|
if (typeof patch.status === "string") patch.status = normalizeStatusArg(patch.status);
|
|
23388
25423
|
const graph = await load(ctx);
|
|
23389
25424
|
const current = findNode(graph.nodes, nodeId);
|
|
25425
|
+
if (current.species === "stake" && patch.metadata !== void 0) {
|
|
25426
|
+
if (typeof patch.metadata !== "object" || patch.metadata === null || Array.isArray(patch.metadata)) {
|
|
25427
|
+
throw new ToolError("`patch.metadata` must be an object.");
|
|
25428
|
+
}
|
|
25429
|
+
const merged = { ...current.metadata ?? {} };
|
|
25430
|
+
for (const [key, value] of Object.entries(patch.metadata)) {
|
|
25431
|
+
if (value === null) delete merged[key];
|
|
25432
|
+
else merged[key] = value;
|
|
25433
|
+
}
|
|
25434
|
+
const before = stakeCatalogOf(current);
|
|
25435
|
+
const after = stakeCatalogOf({ metadata: merged });
|
|
25436
|
+
if ((before?.source !== after?.source || before?.id !== after?.id) && !("verified_criterion_version" in patch.metadata)) {
|
|
25437
|
+
delete merged.verified_criterion_version;
|
|
25438
|
+
}
|
|
25439
|
+
patch.metadata = stakeMetadataWith(merged, {});
|
|
25440
|
+
}
|
|
23390
25441
|
const ops = [{ op: "update_node", node_id: nodeId, patch }];
|
|
23391
25442
|
const outcome = mutate(graph, ops);
|
|
23392
25443
|
if (outcome.eventInputs.length === 0) {
|
|
@@ -23420,10 +25471,10 @@ ${node.description ?? ""}`.toLowerCase();
|
|
|
23420
25471
|
}
|
|
23421
25472
|
},
|
|
23422
25473
|
async (args) => {
|
|
23423
|
-
const nodeId =
|
|
25474
|
+
const nodeId = requireString4(args, "node_id");
|
|
23424
25475
|
const platform = requirePlatform(args);
|
|
23425
25476
|
const form = requireScreenshotForm(args);
|
|
23426
|
-
const value =
|
|
25477
|
+
const value = requireString4(args, "value");
|
|
23427
25478
|
const graph = await load(ctx);
|
|
23428
25479
|
const ops = [
|
|
23429
25480
|
{
|
|
@@ -23458,7 +25509,7 @@ ${node.description ?? ""}`.toLowerCase();
|
|
|
23458
25509
|
}
|
|
23459
25510
|
},
|
|
23460
25511
|
async (args) => {
|
|
23461
|
-
const nodeId =
|
|
25512
|
+
const nodeId = requireString4(args, "node_id");
|
|
23462
25513
|
const platform = requirePlatform(args);
|
|
23463
25514
|
const graph = await load(ctx);
|
|
23464
25515
|
const ops = [{ op: "remove_screenshot", node_id: nodeId, platform }];
|
|
@@ -23482,7 +25533,7 @@ ${node.description ?? ""}`.toLowerCase();
|
|
|
23482
25533
|
}
|
|
23483
25534
|
},
|
|
23484
25535
|
async (args) => {
|
|
23485
|
-
const nodeId =
|
|
25536
|
+
const nodeId = requireString4(args, "node_id");
|
|
23486
25537
|
const graph = await load(ctx);
|
|
23487
25538
|
const node = findNode(graph.nodes, nodeId);
|
|
23488
25539
|
const ops = [{ op: "delete_node", node_id: nodeId }];
|
|
@@ -23512,9 +25563,9 @@ ${node.description ?? ""}`.toLowerCase();
|
|
|
23512
25563
|
}
|
|
23513
25564
|
},
|
|
23514
25565
|
async (args) => {
|
|
23515
|
-
const sourceId =
|
|
23516
|
-
const targetId =
|
|
23517
|
-
const edgeType =
|
|
25566
|
+
const sourceId = requireString4(args, "source_id");
|
|
25567
|
+
const targetId = requireString4(args, "target_id");
|
|
25568
|
+
const edgeType = requireString4(args, "edge_type");
|
|
23518
25569
|
const graph = await load(ctx);
|
|
23519
25570
|
const edge = {
|
|
23520
25571
|
id: edgeId(sourceId, targetId),
|
|
@@ -23549,7 +25600,7 @@ ${node.description ?? ""}`.toLowerCase();
|
|
|
23549
25600
|
}
|
|
23550
25601
|
},
|
|
23551
25602
|
async (args) => {
|
|
23552
|
-
const edgeIdArg =
|
|
25603
|
+
const edgeIdArg = requireString4(args, "edge_id");
|
|
23553
25604
|
const graph = await load(ctx);
|
|
23554
25605
|
const edge = graph.edges.find((candidate) => candidate.id === edgeIdArg);
|
|
23555
25606
|
if (!edge) throw new ToolError(`No edge with id "${edgeIdArg}".`);
|
|
@@ -23565,12 +25616,34 @@ ${node.description ?? ""}`.toLowerCase();
|
|
|
23565
25616
|
}
|
|
23566
25617
|
);
|
|
23567
25618
|
const journalOnly = (type) => async (args) => {
|
|
23568
|
-
const title =
|
|
25619
|
+
const title = requireString4(args, "title");
|
|
23569
25620
|
const graph = await load(ctx);
|
|
23570
25621
|
const payload = { title };
|
|
23571
25622
|
if (typeof args.description === "string") payload.description = args.description;
|
|
23572
25623
|
if (typeof args.node_id === "string") payload.node_id = args.node_id;
|
|
23573
|
-
if (type === "request.filed"
|
|
25624
|
+
if (type === "request.filed") {
|
|
25625
|
+
for (const key of ["source", "verbatim", "finding_id", "criterion_id", "url"]) {
|
|
25626
|
+
if (typeof args[key] === "string") payload[key] = args[key];
|
|
25627
|
+
}
|
|
25628
|
+
if (args.source_kind !== void 0) {
|
|
25629
|
+
if (!SIGNAL_SOURCE_KINDS.includes(args.source_kind)) {
|
|
25630
|
+
throw new ToolError(`source_kind must be one of: ${SIGNAL_SOURCE_KINDS.join(", ")}.`);
|
|
25631
|
+
}
|
|
25632
|
+
payload.source_kind = args.source_kind;
|
|
25633
|
+
}
|
|
25634
|
+
if (args.provenance !== void 0) {
|
|
25635
|
+
if (!STAKE_PROVENANCE_IDS.includes(args.provenance)) {
|
|
25636
|
+
throw new ToolError(`provenance must be one of: ${STAKE_PROVENANCE_IDS.join(", ")}.`);
|
|
25637
|
+
}
|
|
25638
|
+
payload.provenance = args.provenance;
|
|
25639
|
+
}
|
|
25640
|
+
if (args.stake_ids !== void 0) {
|
|
25641
|
+
if (!Array.isArray(args.stake_ids) || args.stake_ids.some((id) => typeof id !== "string" || id === "")) {
|
|
25642
|
+
throw new ToolError("stake_ids must be an array of stake node ids.");
|
|
25643
|
+
}
|
|
25644
|
+
payload.stake_ids = args.stake_ids;
|
|
25645
|
+
}
|
|
25646
|
+
}
|
|
23574
25647
|
const input = { type, payload };
|
|
23575
25648
|
const result = await ctx.store.persist(graph, {}, [input]);
|
|
23576
25649
|
const { warnings, events } = unwrap(result);
|
|
@@ -23596,14 +25669,21 @@ ${node.description ?? ""}`.toLowerCase();
|
|
|
23596
25669
|
tool(
|
|
23597
25670
|
{
|
|
23598
25671
|
name: "file_request",
|
|
23599
|
-
description: "Record
|
|
25672
|
+
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
25673
|
inputSchema: {
|
|
23601
25674
|
type: "object",
|
|
23602
25675
|
properties: {
|
|
23603
25676
|
title: { type: "string" },
|
|
23604
25677
|
description: { type: "string" },
|
|
23605
|
-
source: { type: "string" },
|
|
23606
|
-
node_id: { type: "string" }
|
|
25678
|
+
source: { type: "string", description: `The source's own name, free text ("beta-feedback"). Not an enum.` },
|
|
25679
|
+
node_id: { type: "string" },
|
|
25680
|
+
source_kind: { type: "string", enum: [...SIGNAL_SOURCE_KINDS] },
|
|
25681
|
+
verbatim: { type: "string", description: "The input exactly as voiced." },
|
|
25682
|
+
provenance: { type: "string", enum: [...STAKE_PROVENANCE_IDS] },
|
|
25683
|
+
stake_ids: { type: "array", items: { type: "string" }, description: "Stakes known at filing time." },
|
|
25684
|
+
finding_id: { type: "string", description: "source_kind audit-finding: the Kritik finding id." },
|
|
25685
|
+
criterion_id: { type: "string", description: "source_kind audit-finding: the criterion id." },
|
|
25686
|
+
url: { type: "string" }
|
|
23607
25687
|
},
|
|
23608
25688
|
required: ["title"],
|
|
23609
25689
|
additionalProperties: false
|
|
@@ -23617,6 +25697,12 @@ ${node.description ?? ""}`.toLowerCase();
|
|
|
23617
25697
|
const weighing = buildWeighingCatalog(ctx);
|
|
23618
25698
|
tools2.push(...weighing.tools);
|
|
23619
25699
|
Object.assign(handlers2, weighing.handlers);
|
|
25700
|
+
const qualify = buildQualifyCatalog(ctx, { load: () => load(ctx), mutate, unwrap });
|
|
25701
|
+
tools2.push(...qualify.tools);
|
|
25702
|
+
Object.assign(handlers2, qualify.handlers);
|
|
25703
|
+
const decide = buildDecideCatalog(ctx, { load: () => load(ctx), mutate, unwrap });
|
|
25704
|
+
tools2.push(...decide.tools);
|
|
25705
|
+
Object.assign(handlers2, decide.handlers);
|
|
23620
25706
|
return { tools: tools2, handlers: handlers2 };
|
|
23621
25707
|
}
|
|
23622
25708
|
|
|
@@ -23858,7 +25944,7 @@ function resolveRemoteConfig(argv2, env, cwd) {
|
|
|
23858
25944
|
}
|
|
23859
25945
|
|
|
23860
25946
|
// src/index.ts
|
|
23861
|
-
var VERSION = "0.
|
|
25947
|
+
var VERSION = "0.14.0";
|
|
23862
25948
|
var argv = process.argv.slice(2);
|
|
23863
25949
|
if (argv.includes("--help") || argv.includes("-h")) {
|
|
23864
25950
|
process.stdout.write(
|