arkaik 0.11.1 → 0.12.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/skill/scripts/validate-bundle.js +4 -4
- package/dist/index.js +746 -99
- package/dist/io.js +576 -8
- package/package.json +1 -1
- package/src/io.ts +1 -0
package/dist/io.js
CHANGED
|
@@ -3045,13 +3045,13 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
3045
3045
|
}
|
|
3046
3046
|
return propValues;
|
|
3047
3047
|
});
|
|
3048
|
-
const
|
|
3048
|
+
const isObject4 = isObject;
|
|
3049
3049
|
const catchall = def.catchall;
|
|
3050
3050
|
let value;
|
|
3051
3051
|
inst._zod.parse = (payload, ctx) => {
|
|
3052
3052
|
value ?? (value = _normalized.value);
|
|
3053
3053
|
const input = payload.value;
|
|
3054
|
-
if (!
|
|
3054
|
+
if (!isObject4(input)) {
|
|
3055
3055
|
payload.issues.push({
|
|
3056
3056
|
expected: "object",
|
|
3057
3057
|
code: "invalid_type",
|
|
@@ -3178,7 +3178,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
3178
3178
|
return (payload, ctx) => fn(shape, payload, ctx);
|
|
3179
3179
|
};
|
|
3180
3180
|
let fastpass;
|
|
3181
|
-
const
|
|
3181
|
+
const isObject4 = isObject;
|
|
3182
3182
|
const jit = !globalConfig.jitless;
|
|
3183
3183
|
const allowsEval2 = allowsEval;
|
|
3184
3184
|
const fastEnabled = jit && allowsEval2.value;
|
|
@@ -3187,7 +3187,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
3187
3187
|
inst._zod.parse = (payload, ctx) => {
|
|
3188
3188
|
value ?? (value = _normalized.value);
|
|
3189
3189
|
const input = payload.value;
|
|
3190
|
-
if (!
|
|
3190
|
+
if (!isObject4(input)) {
|
|
3191
3191
|
payload.issues.push({
|
|
3192
3192
|
expected: "object",
|
|
3193
3193
|
code: "invalid_type",
|
|
@@ -14611,6 +14611,38 @@ var VALUE_IDS = [
|
|
|
14611
14611
|
// social-impact (1)
|
|
14612
14612
|
"self-transcendence"
|
|
14613
14613
|
];
|
|
14614
|
+
var VALUE_TIERS = {
|
|
14615
|
+
"saves-time": "functional",
|
|
14616
|
+
simplifies: "functional",
|
|
14617
|
+
"makes-money": "functional",
|
|
14618
|
+
"reduces-risk": "functional",
|
|
14619
|
+
organizes: "functional",
|
|
14620
|
+
integrates: "functional",
|
|
14621
|
+
connects: "functional",
|
|
14622
|
+
"reduces-effort": "functional",
|
|
14623
|
+
"avoids-hassles": "functional",
|
|
14624
|
+
"reduces-cost": "functional",
|
|
14625
|
+
quality: "functional",
|
|
14626
|
+
variety: "functional",
|
|
14627
|
+
"sensory-appeal": "functional",
|
|
14628
|
+
informs: "functional",
|
|
14629
|
+
"reduces-anxiety": "emotional",
|
|
14630
|
+
"rewards-me": "emotional",
|
|
14631
|
+
nostalgia: "emotional",
|
|
14632
|
+
"design-aesthetics": "emotional",
|
|
14633
|
+
"badge-value": "emotional",
|
|
14634
|
+
wellness: "emotional",
|
|
14635
|
+
"therapeutic-value": "emotional",
|
|
14636
|
+
"fun-entertainment": "emotional",
|
|
14637
|
+
attractiveness: "emotional",
|
|
14638
|
+
"provides-access": "emotional",
|
|
14639
|
+
"provides-hope": "life-changing",
|
|
14640
|
+
"self-actualization": "life-changing",
|
|
14641
|
+
motivation: "life-changing",
|
|
14642
|
+
heirloom: "life-changing",
|
|
14643
|
+
"affiliation-belonging": "life-changing",
|
|
14644
|
+
"self-transcendence": "social-impact"
|
|
14645
|
+
};
|
|
14614
14646
|
|
|
14615
14647
|
// ../schema/src/legacy-status.ts
|
|
14616
14648
|
var LEGACY_STATUS_IDS = ["prioritized", "blocked"];
|
|
@@ -15121,6 +15153,82 @@ function missingProvenanceNodeIds(snapshotNodeIds, events) {
|
|
|
15121
15153
|
return missing;
|
|
15122
15154
|
}
|
|
15123
15155
|
|
|
15156
|
+
// ../schema/src/weighing-schemas.ts
|
|
15157
|
+
var documented = (schema) => external_exports.union([schema, external_exports.unknown()]);
|
|
15158
|
+
var leaf = (description) => external_exports.unknown().optional().meta({ description });
|
|
15159
|
+
var WeighingConfidenceSchema = external_exports.unknown().meta({ description: "0 guess \xB7 1 inferred \xB7 2 evidenced \xB7 3 verified." });
|
|
15160
|
+
var WeighingScorerSchema = external_exports.object({
|
|
15161
|
+
kind: leaf("Who judged: human, agent or rule. A human's level beats an agent's, which beats a rule's. Any value parses; the validator warns on another kind."),
|
|
15162
|
+
id: leaf("A person's handle, an agent's name, or a seeding rule's id."),
|
|
15163
|
+
model: leaf("The model behind an agent, when it says."),
|
|
15164
|
+
on_behalf_of: leaf("Whom the scorer acts for: a user id, a handle or a display name, never an email. Stamped by the writer where identity is known.")
|
|
15165
|
+
}).catchall(external_exports.unknown()).meta({ id: "WeighingScorer", description: "Provenance of one assessment." });
|
|
15166
|
+
var WeighingScaleSchema = external_exports.object({
|
|
15167
|
+
min: leaf("The lowest level, e.g. -3."),
|
|
15168
|
+
max: leaf("The highest level, e.g. 3."),
|
|
15169
|
+
anchors: leaf("Every level described in words, keyed by the level as a string.")
|
|
15170
|
+
}).catchall(external_exports.unknown()).meta({ id: "WeighingScale", description: "A criteria set's scale: its bounds and every level's anchor." });
|
|
15171
|
+
var WeighingGroupSchema = external_exports.object({ id: leaf("The group's id."), title: leaf("The group's title.") }).catchall(external_exports.unknown()).meta({ id: "WeighingGroup", description: "A grouping of criteria \u2014 the tiers, for the value set." });
|
|
15172
|
+
var WeighingCriterionSchema = external_exports.object({
|
|
15173
|
+
id: leaf("Stable identifier. Never redefined \u2014 retired via superseded_by."),
|
|
15174
|
+
group: leaf("A group id \u2014 for the value set, the tier."),
|
|
15175
|
+
name: leaf("A short name."),
|
|
15176
|
+
question: leaf("The question a scorer answers."),
|
|
15177
|
+
definition: leaf("What the criterion means."),
|
|
15178
|
+
anchors: leaf("This criterion's own wording of each level \u2014 on a positioning, in the product's words."),
|
|
15179
|
+
weight: leaf("On a positioning: how much the product stands on it, a number above 0. Absent means 1."),
|
|
15180
|
+
superseded_by: leaf("The id of the criterion that replaces this one.")
|
|
15181
|
+
}).catchall(external_exports.unknown()).meta({ id: "WeighingCriterion", description: "One question on a scale where every level is described." });
|
|
15182
|
+
var WeighingCriteriaSetSchema = external_exports.object({
|
|
15183
|
+
id: leaf("The set's id."),
|
|
15184
|
+
version: leaf("Semver. Levels are comparable only within a major."),
|
|
15185
|
+
title: leaf("A human title."),
|
|
15186
|
+
subject: leaf("What the set judges: acceptance today."),
|
|
15187
|
+
scale: documented(WeighingScaleSchema).optional().meta({ description: "The scale. A positioning may leave it out and use its ruler's." }),
|
|
15188
|
+
groups: documented(external_exports.array(documented(WeighingGroupSchema))).optional(),
|
|
15189
|
+
criteria: documented(external_exports.array(documented(WeighingCriterionSchema))).optional(),
|
|
15190
|
+
role: leaf("positioning marks the set a project writes about itself."),
|
|
15191
|
+
status: leaf("Absent or active is active; anything else is a draft, which feeds no roll-up."),
|
|
15192
|
+
extends: leaf("A positioning's ruler, e.g. value-contribution@1.")
|
|
15193
|
+
}).catchall(external_exports.unknown()).meta({ id: "WeighingCriteriaSet", description: "A versioned list of criteria for one kind of subject. The 30 elements of value are one; a positioning is another." });
|
|
15194
|
+
var WeighingMatrixSchema = external_exports.object({
|
|
15195
|
+
id: leaf("The matrix's id."),
|
|
15196
|
+
title: leaf("A human title."),
|
|
15197
|
+
set: leaf("The set's id and major, e.g. value-contribution@1."),
|
|
15198
|
+
subjects: documented(
|
|
15199
|
+
external_exports.object({ kind: leaf("query or list."), species: leaf("For a query: the species judged."), items: leaf("For a list: the subjects.") }).catchall(external_exports.unknown())
|
|
15200
|
+
).optional().meta({ description: "What the matrix judges: { kind: query, species } or { kind: list, items }." }),
|
|
15201
|
+
positioning: leaf("The id of the positioning set that re-weights this matrix."),
|
|
15202
|
+
context: leaf("The node the matrix is about, as { node_id }."),
|
|
15203
|
+
status: leaf("Absent or active is active; anything else is a draft.")
|
|
15204
|
+
}).catchall(external_exports.unknown()).meta({ id: "WeighingMatrix", description: "A criteria set applied to a list of subjects." });
|
|
15205
|
+
var WeighingAssessmentBasisSchema = external_exports.object({
|
|
15206
|
+
fingerprint: leaf("A hash of the subject's judged fields."),
|
|
15207
|
+
commit: leaf("The commit the scorer was looking at."),
|
|
15208
|
+
set_version: leaf("The full version of the set the level was read against.")
|
|
15209
|
+
}).catchall(external_exports.unknown());
|
|
15210
|
+
var WeighingAssessmentSchema = external_exports.object({
|
|
15211
|
+
matrix: leaf("The matrix's id. A row without it cannot be addressed: readers skip it and the validator warns."),
|
|
15212
|
+
subject: leaf("A node id for the value matrix."),
|
|
15213
|
+
criterion: leaf("A criterion id."),
|
|
15214
|
+
level: leaf("A whole number on the set's scale. 0 means unrelated. No half points \u2014 but any value parses; the validator warns on one off the scale."),
|
|
15215
|
+
scorer: documented(WeighingScorerSchema).optional().meta({ description: "Who judged. Required in practice: without it a human, an agent and a rule are indistinguishable, so the validator warns." }),
|
|
15216
|
+
confidence: leaf("0 guess \xB7 1 inferred \xB7 2 evidenced \xB7 3 verified."),
|
|
15217
|
+
evidence: leaf("Markdown."),
|
|
15218
|
+
refs: leaf("Ids cited: nodes, journal events, findings."),
|
|
15219
|
+
basis: documented(WeighingAssessmentBasisSchema).optional().meta({ description: "What the scorer was looking at, so a re-read can tell the score went stale." }),
|
|
15220
|
+
run: leaf("The audit or plan the score belongs to."),
|
|
15221
|
+
ts: leaf("ISO 8601.")
|
|
15222
|
+
}).catchall(external_exports.unknown()).meta({ id: "WeighingAssessment", description: "One (matrix \xD7 subject \xD7 criterion) judgement \u2014 latest per scorer kind wins; history lives in the journal." });
|
|
15223
|
+
var WeighingSectionSchema = external_exports.object({
|
|
15224
|
+
sets: external_exports.array(documented(WeighingCriteriaSetSchema)).optional(),
|
|
15225
|
+
matrices: external_exports.array(documented(WeighingMatrixSchema)).optional(),
|
|
15226
|
+
assessments: external_exports.array(documented(WeighingAssessmentSchema)).optional()
|
|
15227
|
+
}).catchall(external_exports.unknown()).meta({
|
|
15228
|
+
id: "WeighingSection",
|
|
15229
|
+
description: "The project's weighing state (docs/rfcs/weighing.md) \u2014 its own criteria sets (a positioning), matrices and assessments. The built-in value set is library content, not stored; served, cost and kept share are derived, never stored. Each list may be absent; a reader treats it as empty."
|
|
15230
|
+
});
|
|
15231
|
+
|
|
15124
15232
|
// ../schema/src/journal-events.ts
|
|
15125
15233
|
var envelope = {
|
|
15126
15234
|
id: external_exports.string().meta({ description: "ULID \u2014 sortable, collision-free without coordination." }),
|
|
@@ -15311,6 +15419,21 @@ var QualitySignalTrippedEventSchema = external_exports.object({
|
|
|
15311
15419
|
commit: external_exports.string().optional(),
|
|
15312
15420
|
detail: external_exports.string().optional()
|
|
15313
15421
|
}).catchall(external_exports.unknown());
|
|
15422
|
+
var WeighingAssessmentRecordedEventSchema = external_exports.object({
|
|
15423
|
+
...envelope,
|
|
15424
|
+
type: external_exports.literal("weighing.assessment.recorded"),
|
|
15425
|
+
matrix: external_exports.string(),
|
|
15426
|
+
subject: external_exports.string(),
|
|
15427
|
+
criterion: external_exports.string(),
|
|
15428
|
+
level: external_exports.number().int(),
|
|
15429
|
+
scorer: WeighingScorerSchema,
|
|
15430
|
+
confidence: WeighingConfidenceSchema,
|
|
15431
|
+
evidence: external_exports.string().optional(),
|
|
15432
|
+
refs: external_exports.array(external_exports.string()).optional(),
|
|
15433
|
+
basis: WeighingAssessmentBasisSchema.optional(),
|
|
15434
|
+
run: external_exports.string().optional()
|
|
15435
|
+
}).catchall(external_exports.unknown());
|
|
15436
|
+
var WeighingSetSavedEventSchema = external_exports.object({ ...envelope, type: external_exports.literal("weighing.set.saved"), set: WeighingCriteriaSetSchema }).catchall(external_exports.unknown());
|
|
15314
15437
|
var JOURNAL_EVENT_SCHEMAS = {
|
|
15315
15438
|
"node.created": NodeCreatedEventSchema,
|
|
15316
15439
|
"node.updated": NodeUpdatedEventSchema,
|
|
@@ -15334,7 +15457,9 @@ var JOURNAL_EVENT_SCHEMAS = {
|
|
|
15334
15457
|
"quality.finding.opened": QualityFindingOpenedEventSchema,
|
|
15335
15458
|
"quality.finding.resolved": QualityFindingResolvedEventSchema,
|
|
15336
15459
|
"quality.finding.accepted": QualityFindingAcceptedEventSchema,
|
|
15337
|
-
"quality.signal.tripped": QualitySignalTrippedEventSchema
|
|
15460
|
+
"quality.signal.tripped": QualitySignalTrippedEventSchema,
|
|
15461
|
+
"weighing.assessment.recorded": WeighingAssessmentRecordedEventSchema,
|
|
15462
|
+
"weighing.set.saved": WeighingSetSavedEventSchema
|
|
15338
15463
|
};
|
|
15339
15464
|
var KnownJournalEventSchema = external_exports.union([
|
|
15340
15465
|
NodeCreatedEventSchema,
|
|
@@ -15359,7 +15484,9 @@ var KnownJournalEventSchema = external_exports.union([
|
|
|
15359
15484
|
QualityFindingOpenedEventSchema,
|
|
15360
15485
|
QualityFindingResolvedEventSchema,
|
|
15361
15486
|
QualityFindingAcceptedEventSchema,
|
|
15362
|
-
QualitySignalTrippedEventSchema
|
|
15487
|
+
QualitySignalTrippedEventSchema,
|
|
15488
|
+
WeighingAssessmentRecordedEventSchema,
|
|
15489
|
+
WeighingSetSavedEventSchema
|
|
15363
15490
|
]);
|
|
15364
15491
|
|
|
15365
15492
|
// ../schema/src/quality.ts
|
|
@@ -15777,6 +15904,9 @@ var ProjectBundleSchema = external_exports.object({
|
|
|
15777
15904
|
}),
|
|
15778
15905
|
quality: QualitySectionSchema.optional().meta({
|
|
15779
15906
|
description: "Optional Kritik quality state (docs/rfcs/kritik.md \xA7 4.1) \u2014 the pinned pack version, the project's surface profile, its assessments and findings. Additive: a bundle without it is not an error, and the comparative matrix is derived from it (deriveQualityMatrix), never stored."
|
|
15907
|
+
}),
|
|
15908
|
+
weighing: WeighingSectionSchema.optional().meta({
|
|
15909
|
+
description: "Optional weighing state (docs/rfcs/weighing.md) \u2014 the project's own criteria sets (a positioning), matrices and assessments, each assessment carrying its scorer, confidence and basis. Additive: a bundle without it is not an error, and every weight, served and cost figure is derived from it, never stored."
|
|
15780
15910
|
})
|
|
15781
15911
|
}).catchall(external_exports.unknown()).meta({
|
|
15782
15912
|
id: "ProjectBundle",
|
|
@@ -15810,6 +15940,375 @@ function isBuiltInMapId(id) {
|
|
|
15810
15940
|
return BUILT_IN_MAP_IDS.includes(id);
|
|
15811
15941
|
}
|
|
15812
15942
|
|
|
15943
|
+
// ../schema/src/weighing.ts
|
|
15944
|
+
var SCORER_KINDS = ["human", "agent", "rule"];
|
|
15945
|
+
var STORED_SCORER_KINDS = ["human", "agent"];
|
|
15946
|
+
function scorerRank(kind) {
|
|
15947
|
+
const index = SCORER_KINDS.indexOf(kind);
|
|
15948
|
+
return index === -1 ? 0 : SCORER_KINDS.length - index;
|
|
15949
|
+
}
|
|
15950
|
+
var WEIGHING_ASSESSMENT_RECORDED = "weighing.assessment.recorded";
|
|
15951
|
+
var WEIGHING_SET_SAVED = "weighing.set.saved";
|
|
15952
|
+
function cellKey(matrix, subject, criterion) {
|
|
15953
|
+
return `${matrix}\0${subject}\0${criterion}`;
|
|
15954
|
+
}
|
|
15955
|
+
function assessmentKey(a) {
|
|
15956
|
+
const kind = typeof a?.scorer?.kind === "string" ? a.scorer.kind : "";
|
|
15957
|
+
return `${cellKey(String(a?.matrix), String(a?.subject), String(a?.criterion))}\0${kind}`;
|
|
15958
|
+
}
|
|
15959
|
+
var isRecord2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
15960
|
+
function isWeighingAssessmentShape(row) {
|
|
15961
|
+
return isRecord2(row) && typeof row.matrix === "string" && typeof row.subject === "string" && typeof row.criterion === "string";
|
|
15962
|
+
}
|
|
15963
|
+
function splitSetRef(ref) {
|
|
15964
|
+
const at = ref.lastIndexOf("@");
|
|
15965
|
+
if (at === -1) return { id: ref, major: void 0 };
|
|
15966
|
+
return { id: ref.slice(0, at), major: ref.slice(at + 1) };
|
|
15967
|
+
}
|
|
15968
|
+
function majorOf(version2) {
|
|
15969
|
+
const match = /^(\d+)(?:\.|$)/.exec(version2);
|
|
15970
|
+
return match ? match[1] : void 0;
|
|
15971
|
+
}
|
|
15972
|
+
function sortWeighingAssessments(assessments) {
|
|
15973
|
+
return [...assessments].sort((a, b) => {
|
|
15974
|
+
const text = (x) => typeof x === "string" ? x : "\uFFFF";
|
|
15975
|
+
const by = (x, y) => text(x) < text(y) ? -1 : text(x) > text(y) ? 1 : 0;
|
|
15976
|
+
return by(a?.matrix, b?.matrix) || by(a?.subject, b?.subject) || by(a?.criterion, b?.criterion) || scorerRank(b?.scorer?.kind) - scorerRank(a?.scorer?.kind);
|
|
15977
|
+
});
|
|
15978
|
+
}
|
|
15979
|
+
|
|
15980
|
+
// ../schema/src/weighing-library.ts
|
|
15981
|
+
function deepFreeze(value) {
|
|
15982
|
+
if (typeof value === "object" && value !== null && !Object.isFrozen(value)) {
|
|
15983
|
+
Object.freeze(value);
|
|
15984
|
+
for (const child of Object.values(value)) deepFreeze(child);
|
|
15985
|
+
}
|
|
15986
|
+
return value;
|
|
15987
|
+
}
|
|
15988
|
+
var VALUE_SET_ID = "value-contribution";
|
|
15989
|
+
var VALUE_SET_VERSION = "1.0.0";
|
|
15990
|
+
var VALUE_MATRIX_ID = "value";
|
|
15991
|
+
var POSITIONING_SET_ID = "positioning";
|
|
15992
|
+
var VALUE_SCALE_ANCHORS = {
|
|
15993
|
+
"3": "Core. The promise exists for this; take it away and the value goes.",
|
|
15994
|
+
"2": "Supports clearly. The user would notice it missing.",
|
|
15995
|
+
"1": "Touches. A side effect of the promise, not its purpose.",
|
|
15996
|
+
"0": "Unrelated: weighed and found to have nothing to do with it. (No row means nobody has weighed it yet.)",
|
|
15997
|
+
"-1": "Small friction. It costs this value a little.",
|
|
15998
|
+
"-2": "Works against it. The user notices the cost.",
|
|
15999
|
+
"-3": "Costs it at its core. The user feels the opposite."
|
|
16000
|
+
};
|
|
16001
|
+
var TIER_TITLES = {
|
|
16002
|
+
functional: "Functional",
|
|
16003
|
+
emotional: "Emotional",
|
|
16004
|
+
"life-changing": "Life-changing",
|
|
16005
|
+
"social-impact": "Social impact"
|
|
16006
|
+
};
|
|
16007
|
+
var VALUE_TEXT = {
|
|
16008
|
+
"saves-time": { name: "Saves time", definition: "Completes the user's task in less time." },
|
|
16009
|
+
simplifies: { name: "Simplifies", definition: "Reduces steps, choices, or cognitive load." },
|
|
16010
|
+
"makes-money": { name: "Makes money", definition: "Helps the user earn." },
|
|
16011
|
+
"reduces-risk": { name: "Reduces risk", definition: "Protects against loss, error, or uncertainty." },
|
|
16012
|
+
organizes: { name: "Organizes", definition: "Brings order to the user's things or life." },
|
|
16013
|
+
integrates: { name: "Integrates", definition: "Ties different tools or parts of life together." },
|
|
16014
|
+
connects: { name: "Connects", definition: "Brings the user together with other people." },
|
|
16015
|
+
"reduces-effort": { name: "Reduces effort", definition: "Same outcome, less work." },
|
|
16016
|
+
"avoids-hassles": { name: "Avoids hassles", definition: "Prevents friction and annoyance before it happens." },
|
|
16017
|
+
"reduces-cost": { name: "Reduces cost", definition: "Saves the user money." },
|
|
16018
|
+
quality: { name: "Quality", definition: "Superior craft or performance the user can feel." },
|
|
16019
|
+
variety: { name: "Variety", definition: "Meaningful choice and breadth." },
|
|
16020
|
+
"sensory-appeal": { name: "Sensory appeal", definition: "Looks, sounds, or feels good in the moment." },
|
|
16021
|
+
informs: { name: "Informs", definition: "Tells the user something they want to know." },
|
|
16022
|
+
"reduces-anxiety": { name: "Reduces anxiety", definition: "Calms; makes the user feel safe." },
|
|
16023
|
+
"rewards-me": { name: "Rewards me", definition: "Tangible perks for engagement." },
|
|
16024
|
+
nostalgia: { name: "Nostalgia", definition: "Positive memory of the past." },
|
|
16025
|
+
"design-aesthetics": { name: "Design / aesthetics", definition: "Beauty as an experienced value, beyond function." },
|
|
16026
|
+
"badge-value": { name: "Badge value", definition: "Signals identity or status to others." },
|
|
16027
|
+
wellness: { name: "Wellness", definition: "Improves physical or mental well-being." },
|
|
16028
|
+
"therapeutic-value": { name: "Therapeutic value", definition: "Actively supports emotional processing or healing." },
|
|
16029
|
+
"fun-entertainment": { name: "Fun / entertainment", definition: "Enjoyable, playful, delightful." },
|
|
16030
|
+
attractiveness: { name: "Attractiveness", definition: "Makes the user feel attractive." },
|
|
16031
|
+
"provides-access": { name: "Provides access", definition: "Grants entry to something otherwise out of reach." },
|
|
16032
|
+
"provides-hope": { name: "Provides hope", definition: "Reason to believe things can improve." },
|
|
16033
|
+
"self-actualization": { name: "Self-actualization", definition: "Helps the user become who they want to be." },
|
|
16034
|
+
motivation: { name: "Motivation", definition: "Energizes the user toward their goals." },
|
|
16035
|
+
heirloom: { name: "Heirloom", definition: "Something worth passing on across time." },
|
|
16036
|
+
"affiliation-belonging": { name: "Affiliation & belonging", definition: "Makes the user part of a group that matters." },
|
|
16037
|
+
"self-transcendence": { name: "Self-transcendence", definition: "Helps beyond the user themselves." }
|
|
16038
|
+
};
|
|
16039
|
+
var VALUE_SCALE = { min: -3, max: 3, anchors: { ...VALUE_SCALE_ANCHORS } };
|
|
16040
|
+
var VALUE_CONTRIBUTION_SET = deepFreeze({
|
|
16041
|
+
id: VALUE_SET_ID,
|
|
16042
|
+
version: VALUE_SET_VERSION,
|
|
16043
|
+
title: "Elements of value",
|
|
16044
|
+
subject: "acceptance",
|
|
16045
|
+
scale: VALUE_SCALE,
|
|
16046
|
+
groups: Object.keys(TIER_TITLES).map((id) => ({ id, title: TIER_TITLES[id] })),
|
|
16047
|
+
criteria: VALUE_IDS.map((id) => ({
|
|
16048
|
+
id,
|
|
16049
|
+
group: VALUE_TIERS[id],
|
|
16050
|
+
name: VALUE_TEXT[id].name,
|
|
16051
|
+
question: `Does this promise serve, or cost, "${VALUE_TEXT[id].name}"?`,
|
|
16052
|
+
definition: VALUE_TEXT[id].definition
|
|
16053
|
+
}))
|
|
16054
|
+
});
|
|
16055
|
+
var VALUE_MATRIX = deepFreeze({
|
|
16056
|
+
id: VALUE_MATRIX_ID,
|
|
16057
|
+
title: "Value",
|
|
16058
|
+
set: `${VALUE_SET_ID}@1`,
|
|
16059
|
+
subjects: { kind: "query", species: "acceptance" },
|
|
16060
|
+
positioning: POSITIONING_SET_ID,
|
|
16061
|
+
status: "active"
|
|
16062
|
+
});
|
|
16063
|
+
var BUILT_IN_SETS = [VALUE_CONTRIBUTION_SET];
|
|
16064
|
+
var BUILT_IN_MATRICES = [VALUE_MATRIX];
|
|
16065
|
+
var isObject2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
16066
|
+
function cleaned(set2) {
|
|
16067
|
+
const usable = set2.criteria.filter((criterion) => isObject2(criterion) && typeof criterion.id === "string");
|
|
16068
|
+
return usable.length === set2.criteria.length ? set2 : { ...set2, criteria: usable };
|
|
16069
|
+
}
|
|
16070
|
+
function isWeighingSetShape(set2) {
|
|
16071
|
+
return isObject2(set2) && typeof set2.id === "string" && typeof set2.version === "string" && Array.isArray(set2.criteria) && (isObject2(set2.scale) || set2.role === "positioning");
|
|
16072
|
+
}
|
|
16073
|
+
function isWeighingMatrixShape(matrix) {
|
|
16074
|
+
if (!isObject2(matrix) || typeof matrix.id !== "string" || typeof matrix.set !== "string" || !isObject2(matrix.subjects)) return false;
|
|
16075
|
+
const { kind, species, items } = matrix.subjects;
|
|
16076
|
+
return kind === "query" && typeof species === "string" || kind === "list" && Array.isArray(items);
|
|
16077
|
+
}
|
|
16078
|
+
function isUsableScale(scale) {
|
|
16079
|
+
return isObject2(scale) && typeof scale.min === "number" && typeof scale.max === "number" && isObject2(scale.anchors);
|
|
16080
|
+
}
|
|
16081
|
+
function weighingScaleOf(set2, resolved) {
|
|
16082
|
+
if (isUsableScale(set2.scale)) return set2.scale;
|
|
16083
|
+
const ruler = typeof set2.extends === "string" && resolved !== void 0 ? setOfRef(resolved, set2.extends) : void 0;
|
|
16084
|
+
return ruler !== void 0 && isUsableScale(ruler.scale) ? ruler.scale : VALUE_SCALE;
|
|
16085
|
+
}
|
|
16086
|
+
function resolveWeighing(section) {
|
|
16087
|
+
const sets = [...BUILT_IN_SETS];
|
|
16088
|
+
const matrices = [...BUILT_IN_MATRICES];
|
|
16089
|
+
const skipped = [];
|
|
16090
|
+
const idOf = (entry) => isObject2(entry) ? { ...typeof entry.id === "string" ? { id: entry.id } : {}, ...typeof entry.role === "string" ? { role: entry.role } : {} } : {};
|
|
16091
|
+
(Array.isArray(section?.sets) ? section.sets : []).forEach((set2, index) => {
|
|
16092
|
+
if (isWeighingSetShape(set2) && !sets.some((s) => s.id === set2.id)) sets.push(cleaned(set2));
|
|
16093
|
+
else skipped.push({ kind: "set", ...idOf(set2), index });
|
|
16094
|
+
});
|
|
16095
|
+
(Array.isArray(section?.matrices) ? section.matrices : []).forEach((matrix, index) => {
|
|
16096
|
+
if (isWeighingMatrixShape(matrix) && !matrices.some((m) => m.id === matrix.id)) matrices.push(matrix);
|
|
16097
|
+
else skipped.push({ kind: "matrix", ...idOf(matrix), index });
|
|
16098
|
+
});
|
|
16099
|
+
return { sets, matrices, skipped };
|
|
16100
|
+
}
|
|
16101
|
+
function setOfRef(resolved, ref) {
|
|
16102
|
+
const { id, major } = splitSetRef(ref);
|
|
16103
|
+
const set2 = resolved.sets.find((candidate) => candidate.id === id);
|
|
16104
|
+
if (set2 === void 0) return void 0;
|
|
16105
|
+
return major === void 0 || majorOf(set2.version) === major ? set2 : void 0;
|
|
16106
|
+
}
|
|
16107
|
+
|
|
16108
|
+
// ../schema/src/weighing-validate.ts
|
|
16109
|
+
var isObject3 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
16110
|
+
function validateWeighingSection(section, nodeSpecies, journal) {
|
|
16111
|
+
const out = [];
|
|
16112
|
+
const warn = (path, rule, message) => out.push({ path, rule, message });
|
|
16113
|
+
if (section !== void 0 && section !== null && !isObject3(section)) {
|
|
16114
|
+
warn("weighing", "weighing-section-shape", "The weighing section is not an object \u2014 it is ignored");
|
|
16115
|
+
}
|
|
16116
|
+
if (isObject3(section)) {
|
|
16117
|
+
for (const list of ["sets", "matrices", "assessments"]) {
|
|
16118
|
+
if (section[list] !== void 0 && !Array.isArray(section[list])) {
|
|
16119
|
+
warn(`weighing.${list}`, "weighing-section-shape", `weighing.${list} is not an array \u2014 it is ignored`);
|
|
16120
|
+
}
|
|
16121
|
+
}
|
|
16122
|
+
const sets = Array.isArray(section.sets) ? section.sets : [];
|
|
16123
|
+
const matrices = Array.isArray(section.matrices) ? section.matrices : [];
|
|
16124
|
+
const assessments = Array.isArray(section.assessments) ? section.assessments : [];
|
|
16125
|
+
const resolved = resolveWeighing(section);
|
|
16126
|
+
const resolveRef2 = (ref, path, who, unknownRule) => {
|
|
16127
|
+
const set2 = setOfRef(resolved, ref);
|
|
16128
|
+
if (set2 !== void 0) return set2;
|
|
16129
|
+
const named = resolved.sets.find((candidate) => candidate.id === splitSetRef(ref).id);
|
|
16130
|
+
if (named !== void 0) {
|
|
16131
|
+
warn(path, "weighing-set-ref-major", `${who} names ${ref}, but "${named.id}" is at ${named.version} \u2014 levels are comparable only within a major, so the ref resolves to nothing`);
|
|
16132
|
+
} else {
|
|
16133
|
+
warn(path, unknownRule, `${who} names set "${ref}", which is neither built in nor in this section`);
|
|
16134
|
+
}
|
|
16135
|
+
return void 0;
|
|
16136
|
+
};
|
|
16137
|
+
const positioningIds = new Set(
|
|
16138
|
+
resolved.matrices.map((matrix) => matrix.positioning).filter((id) => typeof id === "string")
|
|
16139
|
+
);
|
|
16140
|
+
const checkStatus = (path, who, entry) => {
|
|
16141
|
+
if (entry.status !== void 0 && entry.status !== "draft" && entry.status !== "active") {
|
|
16142
|
+
warn(`${path}.status`, "weighing-set-status", `${who}: status ${JSON.stringify(entry.status)} is not "draft" or "active" \u2014 it is read as a draft, which feeds no roll-up`);
|
|
16143
|
+
}
|
|
16144
|
+
};
|
|
16145
|
+
const isLevelMap = (value) => isObject3(value) && Object.values(value).every((anchor) => typeof anchor === "string");
|
|
16146
|
+
const seenSets = /* @__PURE__ */ new Set();
|
|
16147
|
+
sets.forEach((entry, index) => {
|
|
16148
|
+
const path = `weighing.sets[${index}]`;
|
|
16149
|
+
if (!isObject3(entry)) {
|
|
16150
|
+
warn(path, "weighing-set-shape", "A set is not an object \u2014 it is ignored");
|
|
16151
|
+
return;
|
|
16152
|
+
}
|
|
16153
|
+
const who = `Set "${String(entry.id)}"`;
|
|
16154
|
+
const wellFormed = isWeighingSetShape(entry);
|
|
16155
|
+
if (!wellFormed) {
|
|
16156
|
+
warn(path, "weighing-set-shape", `${who} needs a string id and version, a criteria array and a scale object (a positioning may leave the scale out) \u2014 it is ignored`);
|
|
16157
|
+
}
|
|
16158
|
+
if (typeof entry.id === "string") {
|
|
16159
|
+
if (BUILT_IN_SETS.some((set2) => set2.id === entry.id)) {
|
|
16160
|
+
warn(`${path}.id`, "weighing-pinned-set-redefined", `${who} is built in and pinned by version \u2014 the project's copy is ignored`);
|
|
16161
|
+
} else if (wellFormed) {
|
|
16162
|
+
if (seenSets.has(entry.id)) warn(`${path}.id`, "weighing-duplicate-set", `Duplicate set id "${entry.id}" \u2014 the first well-formed one wins, this one is ignored`);
|
|
16163
|
+
seenSets.add(entry.id);
|
|
16164
|
+
}
|
|
16165
|
+
}
|
|
16166
|
+
checkStatus(path, who, entry);
|
|
16167
|
+
if (isObject3(entry.scale)) {
|
|
16168
|
+
const scale = entry.scale;
|
|
16169
|
+
if (typeof scale.min !== "number" || typeof scale.max !== "number" || !isLevelMap(scale.anchors)) {
|
|
16170
|
+
warn(`${path}.scale`, "weighing-scale-shape", `${who}: a scale needs a numeric min and max and an anchors object of strings`);
|
|
16171
|
+
}
|
|
16172
|
+
}
|
|
16173
|
+
if (Array.isArray(entry.criteria)) {
|
|
16174
|
+
entry.criteria.forEach((criterion, at) => {
|
|
16175
|
+
const cpath = `${path}.criteria[${at}]`;
|
|
16176
|
+
if (!isObject3(criterion) || typeof criterion.id !== "string" || criterion.anchors !== void 0 && !isLevelMap(criterion.anchors)) {
|
|
16177
|
+
warn(cpath, "weighing-criterion-shape", `${who}: criterion ${at} needs a string id, and its anchors (if any) must be an object of strings`);
|
|
16178
|
+
}
|
|
16179
|
+
});
|
|
16180
|
+
}
|
|
16181
|
+
if (entry.role === "positioning" && !(typeof entry.id === "string" && positioningIds.has(entry.id))) {
|
|
16182
|
+
warn(`${path}.id`, "weighing-positioning-id", `A positioning set must have the id "${POSITIONING_SET_ID}" (the one a matrix points at) \u2014 "${String(entry.id)}" would never be applied`);
|
|
16183
|
+
} else if (entry.role !== "positioning" && entry.id === POSITIONING_SET_ID) {
|
|
16184
|
+
warn(`${path}.role`, "weighing-positioning-id", `Set "${POSITIONING_SET_ID}" is where a matrix looks for its positioning, but its role is ${JSON.stringify(entry.role)}, not "positioning" \u2014 it would never be applied`);
|
|
16185
|
+
}
|
|
16186
|
+
if (entry.role === "positioning") {
|
|
16187
|
+
const ruler = typeof entry.extends === "string" ? resolveRef2(entry.extends, `${path}.extends`, `Positioning "${String(entry.id)}"`, "weighing-positioning-unknown-ruler") : void 0;
|
|
16188
|
+
if (typeof entry.extends !== "string") {
|
|
16189
|
+
warn(`${path}.extends`, "weighing-positioning-unknown-ruler", `Positioning "${String(entry.id)}" does not say which set it re-weights \u2014 set extends to e.g. value-contribution@1`);
|
|
16190
|
+
} else if (ruler !== void 0 && ruler.role === "positioning") {
|
|
16191
|
+
warn(`${path}.extends`, "weighing-positioning-unknown-ruler", `Positioning "${String(entry.id)}" extends "${entry.extends}", which is itself a positioning \u2014 it must extend a criteria set such as value-contribution@1`);
|
|
16192
|
+
}
|
|
16193
|
+
const known = new Set(ruler !== void 0 && ruler.role !== "positioning" ? ruler.criteria.map((criterion) => criterion?.id) : []);
|
|
16194
|
+
(Array.isArray(entry.criteria) ? entry.criteria : []).forEach((criterion, at) => {
|
|
16195
|
+
if (!isObject3(criterion)) return;
|
|
16196
|
+
const cpath = `${path}.criteria[${at}]`;
|
|
16197
|
+
if (known.size > 0 && typeof criterion.id === "string" && !known.has(criterion.id)) {
|
|
16198
|
+
warn(`${cpath}.id`, "weighing-positioning-unknown-element", `Positioning names "${criterion.id}", which is not in ${String(entry.extends)}`);
|
|
16199
|
+
}
|
|
16200
|
+
if (criterion.weight !== void 0 && (typeof criterion.weight !== "number" || !(criterion.weight > 0))) {
|
|
16201
|
+
warn(`${cpath}.weight`, "weighing-positioning-weight", `Positioning weight for "${String(criterion.id)}" must be a number above 0 \u2014 leave the element out to leave it unpositioned`);
|
|
16202
|
+
}
|
|
16203
|
+
});
|
|
16204
|
+
}
|
|
16205
|
+
});
|
|
16206
|
+
const seenMatrices = /* @__PURE__ */ new Set();
|
|
16207
|
+
matrices.forEach((entry, index) => {
|
|
16208
|
+
const path = `weighing.matrices[${index}]`;
|
|
16209
|
+
if (!isObject3(entry)) {
|
|
16210
|
+
warn(path, "weighing-matrix-shape", "A matrix is not an object \u2014 it is ignored");
|
|
16211
|
+
return;
|
|
16212
|
+
}
|
|
16213
|
+
const who = `Matrix "${String(entry.id)}"`;
|
|
16214
|
+
const wellFormed = isWeighingMatrixShape(entry);
|
|
16215
|
+
if (!wellFormed) {
|
|
16216
|
+
warn(path, "weighing-matrix-shape", `${who} needs a string id, a set ref and a subjects object of kind query or list \u2014 it is ignored`);
|
|
16217
|
+
}
|
|
16218
|
+
if (typeof entry.id === "string") {
|
|
16219
|
+
if (BUILT_IN_MATRICES.some((matrix) => matrix.id === entry.id)) {
|
|
16220
|
+
warn(`${path}.id`, "weighing-pinned-matrix-redefined", `${who} is built in \u2014 the project's copy is ignored`);
|
|
16221
|
+
} else if (wellFormed) {
|
|
16222
|
+
if (seenMatrices.has(entry.id)) warn(`${path}.id`, "weighing-duplicate-matrix", `Duplicate matrix id "${entry.id}" \u2014 the first well-formed one wins, this one is ignored`);
|
|
16223
|
+
seenMatrices.add(entry.id);
|
|
16224
|
+
}
|
|
16225
|
+
}
|
|
16226
|
+
checkStatus(path, who, entry);
|
|
16227
|
+
if (wellFormed) resolveRef2(entry.set, `${path}.set`, who, "weighing-unknown-set");
|
|
16228
|
+
});
|
|
16229
|
+
const seenCells = /* @__PURE__ */ new Set();
|
|
16230
|
+
assessments.forEach((entry, index) => {
|
|
16231
|
+
const path = `weighing.assessments[${index}]`;
|
|
16232
|
+
const label = `Assessment ${index}`;
|
|
16233
|
+
if (!isWeighingAssessmentShape(entry)) {
|
|
16234
|
+
warn(path, "weighing-assessment-shape", `${label}: not an object with a string matrix, subject and criterion \u2014 it cannot be addressed, so every reader skips it`);
|
|
16235
|
+
return;
|
|
16236
|
+
}
|
|
16237
|
+
if (typeof entry.ts !== "string" || Number.isNaN(Date.parse(entry.ts))) {
|
|
16238
|
+
warn(`${path}.ts`, "weighing-assessment-ts", `${label}: ts must be an ISO 8601 string \u2014 without it "latest wins" cannot order this row`);
|
|
16239
|
+
}
|
|
16240
|
+
const matrix = resolved.matrices.find((candidate) => candidate.id === entry.matrix);
|
|
16241
|
+
if (matrix === void 0) {
|
|
16242
|
+
warn(`${path}.matrix`, "weighing-unknown-matrix", `${label}: matrix "${entry.matrix}" is not defined`);
|
|
16243
|
+
}
|
|
16244
|
+
const set2 = matrix === void 0 ? void 0 : setOfRef(resolved, matrix.set);
|
|
16245
|
+
const criterion = set2?.criteria.find((candidate) => candidate?.id === entry.criterion);
|
|
16246
|
+
if (set2 !== void 0 && criterion === void 0) {
|
|
16247
|
+
warn(`${path}.criterion`, "weighing-unknown-criterion", `${label}: criterion "${entry.criterion}" is not in set "${set2.id}"`);
|
|
16248
|
+
}
|
|
16249
|
+
if (criterion !== void 0 && typeof criterion.superseded_by === "string" && criterion.superseded_by !== "") {
|
|
16250
|
+
warn(`${path}.criterion`, "weighing-retired-criterion", `${label}: criterion "${criterion.id}" is retired \u2014 superseded by "${criterion.superseded_by}"`);
|
|
16251
|
+
}
|
|
16252
|
+
const scale = set2 === void 0 ? void 0 : weighingScaleOf(set2, resolved);
|
|
16253
|
+
const min = typeof scale?.min === "number" ? scale.min : -3;
|
|
16254
|
+
const max = typeof scale?.max === "number" ? scale.max : 3;
|
|
16255
|
+
if (typeof entry.level !== "number" || !Number.isInteger(entry.level) || entry.level < min || entry.level > max) {
|
|
16256
|
+
warn(`${path}.level`, "weighing-level-range", `${label}: level must be an integer ${min}..${max} (a blank cell is the absence of the row; 0 means weighed and unrelated)`);
|
|
16257
|
+
}
|
|
16258
|
+
if (![0, 1, 2, 3].includes(entry.confidence)) {
|
|
16259
|
+
warn(`${path}.confidence`, "weighing-confidence-range", `${label}: confidence must be 0, 1, 2 or 3`);
|
|
16260
|
+
}
|
|
16261
|
+
const scorer = isObject3(entry.scorer) ? entry.scorer : void 0;
|
|
16262
|
+
if (scorer === void 0 || typeof scorer.kind !== "string" || typeof scorer.id !== "string" || scorer.id === "") {
|
|
16263
|
+
warn(`${path}.scorer`, "weighing-scorer-missing", `${label}: no scorer with a string kind and id \u2014 human, agent and rule levels become indistinguishable, and the row can win no cell`);
|
|
16264
|
+
} else if (!SCORER_KINDS.includes(scorer.kind)) {
|
|
16265
|
+
warn(`${path}.scorer.kind`, "weighing-scorer-kind", `${label}: scorer kind "${scorer.kind}" is not one of ${SCORER_KINDS.join(", ")} \u2014 it ranks below every other scorer`);
|
|
16266
|
+
} else if (!STORED_SCORER_KINDS.includes(scorer.kind)) {
|
|
16267
|
+
warn(`${path}.scorer.kind`, "weighing-rule-stored", `${label}: scorer kind "${scorer.kind}" is never stored \u2014 a seeding rule is computed on read`);
|
|
16268
|
+
}
|
|
16269
|
+
if (matrix?.subjects.kind === "query") {
|
|
16270
|
+
const species = nodeSpecies.get(entry.subject);
|
|
16271
|
+
if (species === void 0) {
|
|
16272
|
+
warn(`${path}.subject`, "weighing-unknown-subject", `${label}: subject "${entry.subject}" is not a node in this bundle`);
|
|
16273
|
+
} else if (species !== matrix.subjects.species) {
|
|
16274
|
+
warn(`${path}.subject`, "weighing-subject-species", `${label}: subject "${entry.subject}" is a ${species}, and matrix "${matrix.id}" judges ${String(matrix.subjects.species)} nodes`);
|
|
16275
|
+
}
|
|
16276
|
+
}
|
|
16277
|
+
if (entry.evidence !== void 0 && typeof entry.evidence !== "string") {
|
|
16278
|
+
warn(`${path}.evidence`, "weighing-evidence-type", `${label}: evidence must be a markdown string`);
|
|
16279
|
+
} else if ((entry.confidence === 2 || entry.confidence === 3) && (entry.evidence === void 0 || entry.evidence.trim() === "")) {
|
|
16280
|
+
warn(`${path}.evidence`, "weighing-no-evidence", `${label}: confidence ${String(entry.confidence)} claims evidence and cites none`);
|
|
16281
|
+
}
|
|
16282
|
+
if (entry.refs !== void 0 && !(Array.isArray(entry.refs) && entry.refs.every((ref) => typeof ref === "string"))) {
|
|
16283
|
+
warn(`${path}.refs`, "weighing-refs-type", `${label}: refs must be an array of id strings`);
|
|
16284
|
+
}
|
|
16285
|
+
if (entry.basis !== void 0 && !(isObject3(entry.basis) && ["fingerprint", "commit", "set_version"].every((key) => entry.basis[key] === void 0 || typeof entry.basis[key] === "string"))) {
|
|
16286
|
+
warn(`${path}.basis`, "weighing-basis-shape", `${label}: basis must be an object whose fingerprint, commit and set_version are strings`);
|
|
16287
|
+
}
|
|
16288
|
+
if (scorer !== void 0 && typeof scorer.kind === "string") {
|
|
16289
|
+
const key = assessmentKey(entry);
|
|
16290
|
+
if (seenCells.has(key)) {
|
|
16291
|
+
warn(path, "weighing-duplicate-assessment", `${label}: a second ${scorer.kind} score for the same cell \u2014 the section stores latest-per-scorer-kind, so this cell is ambiguous`);
|
|
16292
|
+
}
|
|
16293
|
+
seenCells.add(key);
|
|
16294
|
+
}
|
|
16295
|
+
const setVersion = isObject3(entry.basis) && typeof entry.basis.set_version === "string" ? entry.basis.set_version : void 0;
|
|
16296
|
+
if (set2 !== void 0 && setVersion !== void 0 && majorOf(setVersion) !== majorOf(set2.version)) {
|
|
16297
|
+
warn(`${path}.basis.set_version`, "weighing-set-major", `${label}: scored against ${set2.id} ${setVersion}, and the set is now ${set2.version} \u2014 levels are comparable only within a major`);
|
|
16298
|
+
}
|
|
16299
|
+
});
|
|
16300
|
+
}
|
|
16301
|
+
journal.forEach((entry, index) => {
|
|
16302
|
+
if (!isObject3(entry)) return;
|
|
16303
|
+
const type = typeof entry.type === "string" ? entry.type : "";
|
|
16304
|
+
if (type !== WEIGHING_ASSESSMENT_RECORDED && type !== WEIGHING_SET_SAVED) return;
|
|
16305
|
+
if (typeof entry.actor !== "string" || entry.actor.trim() === "") {
|
|
16306
|
+
warn(`journal[${index}].actor`, "weighing-event-no-actor", `Journal event ${index}: ${type} has no actor \u2014 human, agent and CI scores become indistinguishable`);
|
|
16307
|
+
}
|
|
16308
|
+
});
|
|
16309
|
+
return out;
|
|
16310
|
+
}
|
|
16311
|
+
|
|
15813
16312
|
// ../schema/src/validate.ts
|
|
15814
16313
|
var VALID_STAGES = ["beta", "monitoring", "deprecated"];
|
|
15815
16314
|
var VALID_VIEW_CARD_VARIANTS = ["compact", "large"];
|
|
@@ -16660,6 +17159,13 @@ function validateBundle(input) {
|
|
|
16660
17159
|
}
|
|
16661
17160
|
});
|
|
16662
17161
|
}
|
|
17162
|
+
const weighing = bundle.weighing;
|
|
17163
|
+
const embeddedJournal = Array.isArray(bundle.journal) ? bundle.journal : [];
|
|
17164
|
+
const weighingSpecies = /* @__PURE__ */ new Map();
|
|
17165
|
+
for (const [id, node] of nodeMap) weighingSpecies.set(id, String(node.species));
|
|
17166
|
+
for (const finding of validateWeighingSection(weighing, weighingSpecies, embeddedJournal)) {
|
|
17167
|
+
warn(finding.path, finding.rule, finding.message);
|
|
17168
|
+
}
|
|
16663
17169
|
for (const finding of crossCheckJournal(bundle)) findings.push(finding);
|
|
16664
17170
|
return result();
|
|
16665
17171
|
}
|
|
@@ -16720,6 +17226,10 @@ function makeEvent(type, payload = {}, options = {}) {
|
|
|
16720
17226
|
return schema.parse(event);
|
|
16721
17227
|
}
|
|
16722
17228
|
|
|
17229
|
+
// ../schema/src/weighing-derive.ts
|
|
17230
|
+
var SEED_SCORER_ID = "seed-by-claim-order";
|
|
17231
|
+
var SEED_SCORER = Object.freeze({ kind: "rule", id: SEED_SCORER_ID });
|
|
17232
|
+
|
|
16723
17233
|
// src/lib/bundle-io.ts
|
|
16724
17234
|
function readBundle(filePath) {
|
|
16725
17235
|
if (!existsSync(filePath)) throw new Error(`File not found: ${filePath}`);
|
|
@@ -16888,8 +17398,65 @@ function resolveQualityRoot(options) {
|
|
|
16888
17398
|
return options.fallback;
|
|
16889
17399
|
}
|
|
16890
17400
|
|
|
17401
|
+
// ../schema/src/cli/weighing-files.ts
|
|
17402
|
+
import { existsSync as existsSync5, readdirSync as readdirSync2 } from "node:fs";
|
|
17403
|
+
import { join as join4 } from "node:path";
|
|
17404
|
+
var WEIGHING_DIR = "docs/weighing";
|
|
17405
|
+
var WEIGHING_SETS_DIR = "sets";
|
|
17406
|
+
var WEIGHING_ASSESSMENTS_DIR = "assessments";
|
|
17407
|
+
var weighingDir = (root) => join4(root, WEIGHING_DIR);
|
|
17408
|
+
function jsonFilesIn(dir) {
|
|
17409
|
+
if (!existsSync5(dir)) return [];
|
|
17410
|
+
return readdirSync2(dir).filter((name) => name.endsWith(".json")).sort().map((name) => join4(dir, name));
|
|
17411
|
+
}
|
|
17412
|
+
function assessmentsOfFile(file2) {
|
|
17413
|
+
const parsed = readJson(file2);
|
|
17414
|
+
const assessments = typeof parsed === "object" && parsed !== null ? parsed.assessments : void 0;
|
|
17415
|
+
if (!Array.isArray(assessments)) throw new Error(`${file2}: expected { "matrix": \u2026, "assessments": [] }`);
|
|
17416
|
+
return assessments;
|
|
17417
|
+
}
|
|
17418
|
+
function loadWeighingSets(root) {
|
|
17419
|
+
return jsonFilesIn(join4(weighingDir(root), WEIGHING_SETS_DIR)).map((file2) => {
|
|
17420
|
+
const parsed = readJson(file2);
|
|
17421
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) throw new Error(`${file2}: expected a criteria set object`);
|
|
17422
|
+
return parsed;
|
|
17423
|
+
});
|
|
17424
|
+
}
|
|
17425
|
+
function loadWeighingAssessments(root) {
|
|
17426
|
+
return jsonFilesIn(join4(weighingDir(root), WEIGHING_ASSESSMENTS_DIR)).flatMap(assessmentsOfFile);
|
|
17427
|
+
}
|
|
17428
|
+
function loadWeighingSection(root) {
|
|
17429
|
+
const sets = loadWeighingSets(root);
|
|
17430
|
+
const assessments = loadWeighingAssessments(root);
|
|
17431
|
+
if (sets.length === 0 && assessments.length === 0) return void 0;
|
|
17432
|
+
return { sets, matrices: [], assessments: sortWeighingAssessments(assessments) };
|
|
17433
|
+
}
|
|
17434
|
+
|
|
17435
|
+
// src/lib/weighing-io.ts
|
|
17436
|
+
function isSection(value) {
|
|
17437
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
17438
|
+
}
|
|
17439
|
+
function foldWeighingSection(bundle, root) {
|
|
17440
|
+
const section = loadWeighingSection(root);
|
|
17441
|
+
if (section === void 0) {
|
|
17442
|
+
const carriedSection = isSection(bundle.weighing);
|
|
17443
|
+
return {
|
|
17444
|
+
folded: false,
|
|
17445
|
+
carriedSection,
|
|
17446
|
+
notice: carriedSection ? `Weighing: none to fold \u2014 no files under ${weighingDir(root)}
|
|
17447
|
+
Kept the weighing section this bundle already carried \u2014 nothing replaced it.` : `Weighing: none to fold \u2014 no files under ${weighingDir(root)}`
|
|
17448
|
+
};
|
|
17449
|
+
}
|
|
17450
|
+
bundle.weighing = section;
|
|
17451
|
+
return {
|
|
17452
|
+
folded: true,
|
|
17453
|
+
carriedSection: false,
|
|
17454
|
+
notice: `Weighing: folded ${section.assessments?.length ?? 0} assessment(s), ${section.sets?.length ?? 0} set(s) from ${weighingDir(root)}`
|
|
17455
|
+
};
|
|
17456
|
+
}
|
|
17457
|
+
|
|
16891
17458
|
// src/lib/bundle-validate.ts
|
|
16892
|
-
import { existsSync as
|
|
17459
|
+
import { existsSync as existsSync6, readFileSync as readFileSync4 } from "node:fs";
|
|
16893
17460
|
import { basename as basename2 } from "node:path";
|
|
16894
17461
|
function validateBundleAt(filePath) {
|
|
16895
17462
|
const bundle = readBundle(filePath);
|
|
@@ -16904,7 +17471,7 @@ function validateBundleAt(filePath) {
|
|
|
16904
17471
|
if (loose.journal === void 0) {
|
|
16905
17472
|
const sidecarPath = journalPathFor(filePath);
|
|
16906
17473
|
const folded = [];
|
|
16907
|
-
if (
|
|
17474
|
+
if (existsSync6(sidecarPath)) {
|
|
16908
17475
|
const { events, findings } = parseJournalLines(readFileSync4(sidecarPath, "utf8"));
|
|
16909
17476
|
sidecarFindings = findings;
|
|
16910
17477
|
sidecarLoaded = true;
|
|
@@ -16953,6 +17520,7 @@ export {
|
|
|
16953
17520
|
archivePathsFor,
|
|
16954
17521
|
compactSlice,
|
|
16955
17522
|
ensureJournalBaseline,
|
|
17523
|
+
foldWeighingSection,
|
|
16956
17524
|
journalLineErrorLines,
|
|
16957
17525
|
journalPathFor,
|
|
16958
17526
|
loadJournalEvents,
|