arkaik-mcp 0.2.1 → 0.2.3
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/LICENSE +21 -0
- package/dist/index.js +842 -66
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -14632,19 +14632,58 @@ function date4(params) {
|
|
|
14632
14632
|
config(en_default());
|
|
14633
14633
|
|
|
14634
14634
|
// ../schema/src/ids.ts
|
|
14635
|
-
var SPECIES_IDS = ["flow", "view", "data-model", "api-endpoint", "acceptance"];
|
|
14635
|
+
var SPECIES_IDS = ["flow", "view", "data-model", "api-endpoint", "acceptance", "decision"];
|
|
14636
14636
|
var STATUS_IDS = [
|
|
14637
14637
|
"idea",
|
|
14638
|
+
"discovery",
|
|
14638
14639
|
"backlog",
|
|
14639
|
-
"prioritized",
|
|
14640
14640
|
"development",
|
|
14641
14641
|
"releasing",
|
|
14642
14642
|
"live",
|
|
14643
|
-
"archived"
|
|
14644
|
-
"blocked"
|
|
14643
|
+
"archived"
|
|
14645
14644
|
];
|
|
14646
14645
|
var PLATFORM_IDS = ["web", "ios", "android"];
|
|
14647
|
-
var EDGE_TYPE_IDS = ["composes", "calls", "displays", "queries", "covers"];
|
|
14646
|
+
var EDGE_TYPE_IDS = ["composes", "calls", "displays", "queries", "covers", "supersedes", "generates", "impacts"];
|
|
14647
|
+
var VALID_EDGE_SEMANTICS = {
|
|
14648
|
+
composes: [
|
|
14649
|
+
["flow", "view"],
|
|
14650
|
+
["flow", "flow"],
|
|
14651
|
+
["view", "flow"],
|
|
14652
|
+
["view", "view"]
|
|
14653
|
+
],
|
|
14654
|
+
// `calls` names the initiator, which is why it runs in both directions
|
|
14655
|
+
// between a view and an endpoint: view → api is the outbound/write
|
|
14656
|
+
// affordance, api → view the inbound/read one a server opens itself (a
|
|
14657
|
+
// webhook, an SSE channel, a push). Both project onto the View card
|
|
14658
|
+
// (docs/graph-model.md § Edge Types). Consumers that walk `calls` must
|
|
14659
|
+
// therefore not assume it points down into the system layer — see
|
|
14660
|
+
// `buildProductUsageIndex` in ./products.ts, which restricts hops by
|
|
14661
|
+
// target species for exactly this reason.
|
|
14662
|
+
calls: [
|
|
14663
|
+
["view", "api-endpoint"],
|
|
14664
|
+
["flow", "api-endpoint"],
|
|
14665
|
+
["api-endpoint", "api-endpoint"],
|
|
14666
|
+
["api-endpoint", "view"]
|
|
14667
|
+
],
|
|
14668
|
+
displays: [["view", "data-model"]],
|
|
14669
|
+
queries: [["api-endpoint", "data-model"]],
|
|
14670
|
+
covers: [
|
|
14671
|
+
["acceptance", "view"],
|
|
14672
|
+
["acceptance", "flow"]
|
|
14673
|
+
],
|
|
14674
|
+
// Decision edges (cycle 2). `generates` and `impacts` are deliberately
|
|
14675
|
+
// disjoint: an acceptance is *generated* by a decision, never merely
|
|
14676
|
+
// impacted, so `impacts` does not admit an acceptance target
|
|
14677
|
+
// (docs/superpowers/specs/2026-08-03-decisions-species-design.md §3).
|
|
14678
|
+
supersedes: [["decision", "decision"]],
|
|
14679
|
+
generates: [["decision", "acceptance"]],
|
|
14680
|
+
impacts: [
|
|
14681
|
+
["decision", "flow"],
|
|
14682
|
+
["decision", "view"],
|
|
14683
|
+
["decision", "data-model"],
|
|
14684
|
+
["decision", "api-endpoint"]
|
|
14685
|
+
]
|
|
14686
|
+
};
|
|
14648
14687
|
var VALUE_TIER_IDS = ["functional", "emotional", "life-changing", "social-impact"];
|
|
14649
14688
|
var VALUE_IDS = [
|
|
14650
14689
|
// functional (14)
|
|
@@ -14683,6 +14722,106 @@ var VALUE_IDS = [
|
|
|
14683
14722
|
"self-transcendence"
|
|
14684
14723
|
];
|
|
14685
14724
|
|
|
14725
|
+
// ../schema/src/legacy-status.ts
|
|
14726
|
+
var LEGACY_STATUS_IDS = ["prioritized", "blocked"];
|
|
14727
|
+
var LEGACY_STATUS_ALIASES = {
|
|
14728
|
+
prioritized: "backlog",
|
|
14729
|
+
blocked: "development"
|
|
14730
|
+
};
|
|
14731
|
+
var STATUS_VOCABULARY_VERSION = 3;
|
|
14732
|
+
var BLOCKED_BY_MIGRATION_NOTE = "migrated from legacy blocked status";
|
|
14733
|
+
function normalizeStatus(value) {
|
|
14734
|
+
if (STATUS_IDS.includes(value)) return value;
|
|
14735
|
+
return LEGACY_STATUS_ALIASES[value];
|
|
14736
|
+
}
|
|
14737
|
+
var LEGACY_ALIAS_REMAP = { ...LEGACY_STATUS_ALIASES };
|
|
14738
|
+
var LEGACY_VOCABULARY_REMAP = {
|
|
14739
|
+
backlog: "idea",
|
|
14740
|
+
...LEGACY_STATUS_ALIASES
|
|
14741
|
+
};
|
|
14742
|
+
function migrateNode(node, remap) {
|
|
14743
|
+
let changed = false;
|
|
14744
|
+
let wasBlocked = node.status === "blocked";
|
|
14745
|
+
const mappedStatus = remap[node.status];
|
|
14746
|
+
const status = mappedStatus ?? node.status;
|
|
14747
|
+
if (mappedStatus !== void 0) changed = true;
|
|
14748
|
+
let metadata = node.metadata;
|
|
14749
|
+
const platformStatuses = node.metadata?.platformStatuses;
|
|
14750
|
+
if (platformStatuses !== void 0) {
|
|
14751
|
+
let anyMapped = false;
|
|
14752
|
+
const next = {};
|
|
14753
|
+
for (const [platform, value] of Object.entries(platformStatuses)) {
|
|
14754
|
+
if (value === "blocked") wasBlocked = true;
|
|
14755
|
+
const mapped = remap[value];
|
|
14756
|
+
next[platform] = mapped ?? value;
|
|
14757
|
+
if (mapped !== void 0) anyMapped = true;
|
|
14758
|
+
}
|
|
14759
|
+
if (anyMapped) {
|
|
14760
|
+
metadata = { ...metadata, platformStatuses: next };
|
|
14761
|
+
changed = true;
|
|
14762
|
+
}
|
|
14763
|
+
}
|
|
14764
|
+
const refs = node.metadata?.refs;
|
|
14765
|
+
if (Array.isArray(refs)) {
|
|
14766
|
+
let anyMapped = false;
|
|
14767
|
+
const nextRefs = refs.map((ref) => {
|
|
14768
|
+
if (ref.status_mapped === void 0) return ref;
|
|
14769
|
+
const mapped = remap[ref.status_mapped];
|
|
14770
|
+
if (mapped === void 0) return ref;
|
|
14771
|
+
anyMapped = true;
|
|
14772
|
+
return { ...ref, status_mapped: mapped };
|
|
14773
|
+
});
|
|
14774
|
+
if (anyMapped) {
|
|
14775
|
+
metadata = { ...metadata, refs: nextRefs };
|
|
14776
|
+
changed = true;
|
|
14777
|
+
}
|
|
14778
|
+
}
|
|
14779
|
+
if (wasBlocked && !metadata?.blocked_by) {
|
|
14780
|
+
metadata = { ...metadata, blocked_by: BLOCKED_BY_MIGRATION_NOTE };
|
|
14781
|
+
changed = true;
|
|
14782
|
+
}
|
|
14783
|
+
if (!changed) return node;
|
|
14784
|
+
return { ...node, status, ...metadata !== void 0 ? { metadata } : {} };
|
|
14785
|
+
}
|
|
14786
|
+
function migrateStatusVocabulary(bundle) {
|
|
14787
|
+
const current = typeof bundle.schema_version === "number" && bundle.schema_version >= STATUS_VOCABULARY_VERSION;
|
|
14788
|
+
const remap = current ? LEGACY_ALIAS_REMAP : LEGACY_VOCABULARY_REMAP;
|
|
14789
|
+
const nodes = bundle.nodes.map((node) => migrateNode(node, remap));
|
|
14790
|
+
if (current) {
|
|
14791
|
+
const untouched = nodes.every((node, i) => node === bundle.nodes[i]);
|
|
14792
|
+
return untouched ? bundle : { ...bundle, nodes };
|
|
14793
|
+
}
|
|
14794
|
+
return { ...bundle, schema_version: STATUS_VOCABULARY_VERSION, nodes };
|
|
14795
|
+
}
|
|
14796
|
+
|
|
14797
|
+
// ../schema/src/decision.ts
|
|
14798
|
+
var DECISION_STATUS_IDS = [
|
|
14799
|
+
"proposed",
|
|
14800
|
+
"approved",
|
|
14801
|
+
"enacted",
|
|
14802
|
+
"rejected",
|
|
14803
|
+
"deprecated",
|
|
14804
|
+
"superseded"
|
|
14805
|
+
];
|
|
14806
|
+
function lifecycleStatusForDecision(decisionStatus) {
|
|
14807
|
+
switch (decisionStatus) {
|
|
14808
|
+
case "proposed":
|
|
14809
|
+
return "discovery";
|
|
14810
|
+
case "approved":
|
|
14811
|
+
return "backlog";
|
|
14812
|
+
case "enacted":
|
|
14813
|
+
return "live";
|
|
14814
|
+
case "rejected":
|
|
14815
|
+
case "deprecated":
|
|
14816
|
+
case "superseded":
|
|
14817
|
+
return "archived";
|
|
14818
|
+
}
|
|
14819
|
+
}
|
|
14820
|
+
function decisionStatusOf(node) {
|
|
14821
|
+
const raw = node.metadata?.decision_status;
|
|
14822
|
+
return DECISION_STATUS_IDS.includes(raw) ? raw : "proposed";
|
|
14823
|
+
}
|
|
14824
|
+
|
|
14686
14825
|
// ../schema/src/enums.ts
|
|
14687
14826
|
var SpeciesSchema = external_exports.enum(SPECIES_IDS).meta({
|
|
14688
14827
|
id: "Species",
|
|
@@ -14692,6 +14831,10 @@ var StatusSchema = external_exports.enum(STATUS_IDS).meta({
|
|
|
14692
14831
|
id: "Status",
|
|
14693
14832
|
description: "Lifecycle status of a node."
|
|
14694
14833
|
});
|
|
14834
|
+
var AnyStatusSchema = external_exports.enum([...STATUS_IDS, ...LEGACY_STATUS_IDS]).meta({
|
|
14835
|
+
id: "AnyStatus",
|
|
14836
|
+
description: "Lifecycle status as stored: the current vocabulary, or a legacy id (prioritized, blocked) accepted from pre-v3 bundles and migrated on load."
|
|
14837
|
+
});
|
|
14695
14838
|
var PlatformSchema = external_exports.enum(PLATFORM_IDS).meta({
|
|
14696
14839
|
id: "Platform",
|
|
14697
14840
|
description: "Target platform."
|
|
@@ -14708,6 +14851,10 @@ var ValueSchema = external_exports.enum(VALUE_IDS).meta({
|
|
|
14708
14851
|
id: "Value",
|
|
14709
14852
|
description: "A Bain B2C Elements-of-Value element served by an acceptance (spec \xA73.2)."
|
|
14710
14853
|
});
|
|
14854
|
+
var DecisionStatusSchema = external_exports.enum(DECISION_STATUS_IDS).meta({
|
|
14855
|
+
id: "DecisionStatus",
|
|
14856
|
+
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)."
|
|
14857
|
+
});
|
|
14711
14858
|
|
|
14712
14859
|
// ../schema/src/id-gen.ts
|
|
14713
14860
|
var SPECIES_PREFIXES = {
|
|
@@ -14715,7 +14862,8 @@ var SPECIES_PREFIXES = {
|
|
|
14715
14862
|
view: "V-",
|
|
14716
14863
|
"data-model": "DM-",
|
|
14717
14864
|
"api-endpoint": "API-",
|
|
14718
|
-
acceptance: "AC-"
|
|
14865
|
+
acceptance: "AC-",
|
|
14866
|
+
decision: "DEC-"
|
|
14719
14867
|
};
|
|
14720
14868
|
function kebabCase(input) {
|
|
14721
14869
|
return input.normalize("NFKD").replace(/[\u0300-\u036f]/g, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
@@ -14856,6 +15004,7 @@ function parseJournalLines(text) {
|
|
|
14856
15004
|
var NODE_REF_FIELDS = {
|
|
14857
15005
|
"node.updated": ["node_id"],
|
|
14858
15006
|
"node.status_changed": ["node_id"],
|
|
15007
|
+
"decision.status_changed": ["node_id"],
|
|
14859
15008
|
"node.deleted": ["node_id"],
|
|
14860
15009
|
"edge.added": ["source_id", "target_id"],
|
|
14861
15010
|
"ref.added": ["node_id"],
|
|
@@ -14864,6 +15013,12 @@ var NODE_REF_FIELDS = {
|
|
|
14864
15013
|
"idea.proposed": ["node_id"],
|
|
14865
15014
|
"request.filed": ["node_id"]
|
|
14866
15015
|
};
|
|
15016
|
+
function statusesAgree(last, snapshot) {
|
|
15017
|
+
if (last === snapshot) return true;
|
|
15018
|
+
if (typeof snapshot !== "string") return false;
|
|
15019
|
+
if (last === "backlog" && snapshot === "idea") return true;
|
|
15020
|
+
return (normalizeStatus(last) ?? last) === (normalizeStatus(snapshot) ?? snapshot);
|
|
15021
|
+
}
|
|
14867
15022
|
function crossCheckJournal(bundle) {
|
|
14868
15023
|
const findings = [];
|
|
14869
15024
|
const journalRaw = bundle.journal;
|
|
@@ -14882,9 +15037,15 @@ function crossCheckJournal(bundle) {
|
|
|
14882
15037
|
const nodesRaw = Array.isArray(bundle.nodes) ? bundle.nodes : [];
|
|
14883
15038
|
const edgesRaw = Array.isArray(bundle.edges) ? bundle.edges : [];
|
|
14884
15039
|
const snapshotNodeStatus = /* @__PURE__ */ new Map();
|
|
15040
|
+
const snapshotDecisionStatus = /* @__PURE__ */ new Map();
|
|
14885
15041
|
for (const n of nodesRaw) {
|
|
14886
15042
|
const id = str(n?.id);
|
|
14887
|
-
if (id !== void 0)
|
|
15043
|
+
if (id !== void 0) {
|
|
15044
|
+
snapshotNodeStatus.set(id, n.status);
|
|
15045
|
+
const metadata = n.metadata;
|
|
15046
|
+
const decisionStatus = metadata && typeof metadata === "object" && !Array.isArray(metadata) ? metadata.decision_status : void 0;
|
|
15047
|
+
snapshotDecisionStatus.set(id, decisionStatus ?? "proposed");
|
|
15048
|
+
}
|
|
14888
15049
|
}
|
|
14889
15050
|
const snapshotEdgeIds = /* @__PURE__ */ new Set();
|
|
14890
15051
|
for (const e of edgesRaw) {
|
|
@@ -14921,6 +15082,7 @@ function crossCheckJournal(bundle) {
|
|
|
14921
15082
|
});
|
|
14922
15083
|
const everNodes = new Set(snapshotNodeStatus.keys());
|
|
14923
15084
|
const everEdges = new Set(snapshotEdgeIds);
|
|
15085
|
+
const baselined = /* @__PURE__ */ new Set();
|
|
14924
15086
|
for (const { ev } of valid) {
|
|
14925
15087
|
if (ev.type === "node.created") {
|
|
14926
15088
|
const nid = str(ev.node_id);
|
|
@@ -14928,11 +15090,20 @@ function crossCheckJournal(bundle) {
|
|
|
14928
15090
|
} else if (ev.type === "edge.added") {
|
|
14929
15091
|
const eid = str(ev.edge_id);
|
|
14930
15092
|
if (eid) everEdges.add(eid);
|
|
15093
|
+
} else if (ev.type === "journal.baseline" && Array.isArray(ev.node_ids)) {
|
|
15094
|
+
for (const raw of ev.node_ids) {
|
|
15095
|
+
const nid = str(raw);
|
|
15096
|
+
if (nid) {
|
|
15097
|
+
baselined.add(nid);
|
|
15098
|
+
everNodes.add(nid);
|
|
15099
|
+
}
|
|
15100
|
+
}
|
|
14931
15101
|
}
|
|
14932
15102
|
}
|
|
14933
15103
|
const ordered = orderEvents(valid.map((v) => v.ev));
|
|
14934
15104
|
const created = /* @__PURE__ */ new Set();
|
|
14935
15105
|
const lastProjectStatus = /* @__PURE__ */ new Map();
|
|
15106
|
+
const lastDecisionStatus = /* @__PURE__ */ new Map();
|
|
14936
15107
|
for (const ev of ordered) {
|
|
14937
15108
|
if (ev.type === "node.created") {
|
|
14938
15109
|
const nid = str(ev.node_id);
|
|
@@ -14943,6 +15114,12 @@ function crossCheckJournal(bundle) {
|
|
|
14943
15114
|
const to = str(ev.to);
|
|
14944
15115
|
if (to !== void 0) lastProjectStatus.set(nid, to);
|
|
14945
15116
|
}
|
|
15117
|
+
} else if (ev.type === "decision.status_changed") {
|
|
15118
|
+
const nid = str(ev.node_id);
|
|
15119
|
+
if (nid) {
|
|
15120
|
+
const to = str(ev.to);
|
|
15121
|
+
if (to !== void 0) lastDecisionStatus.set(nid, to);
|
|
15122
|
+
}
|
|
14946
15123
|
}
|
|
14947
15124
|
}
|
|
14948
15125
|
for (const { ev, index } of valid) {
|
|
@@ -14960,6 +15137,19 @@ function crossCheckJournal(bundle) {
|
|
|
14960
15137
|
}
|
|
14961
15138
|
}
|
|
14962
15139
|
}
|
|
15140
|
+
if (ev.type === "deliverable.shipped" && Array.isArray(ev.node_ids)) {
|
|
15141
|
+
ev.node_ids.forEach((raw, i) => {
|
|
15142
|
+
const ref = str(raw);
|
|
15143
|
+
if (ref !== void 0 && !everNodes.has(ref)) {
|
|
15144
|
+
findings.push({
|
|
15145
|
+
path: `journal[${index}].node_ids[${i}]`,
|
|
15146
|
+
rule: "journal-dangling-node-ref",
|
|
15147
|
+
message: `journal[${index}] (${ev.type}): references node "${ref}" that never existed in the snapshot or journal.`,
|
|
15148
|
+
severity: "error"
|
|
15149
|
+
});
|
|
15150
|
+
}
|
|
15151
|
+
});
|
|
15152
|
+
}
|
|
14963
15153
|
if (ev.type === "edge.removed") {
|
|
14964
15154
|
const ref = str(ev.edge_id);
|
|
14965
15155
|
if (ref !== void 0 && !everEdges.has(ref)) {
|
|
@@ -14973,7 +15163,7 @@ function crossCheckJournal(bundle) {
|
|
|
14973
15163
|
}
|
|
14974
15164
|
}
|
|
14975
15165
|
for (const [nodeId, status] of snapshotNodeStatus) {
|
|
14976
|
-
if (!created.has(nodeId)) {
|
|
15166
|
+
if (!created.has(nodeId) && !baselined.has(nodeId)) {
|
|
14977
15167
|
findings.push({
|
|
14978
15168
|
path: "journal",
|
|
14979
15169
|
rule: "journal-missing-node-created",
|
|
@@ -14982,7 +15172,7 @@ function crossCheckJournal(bundle) {
|
|
|
14982
15172
|
});
|
|
14983
15173
|
}
|
|
14984
15174
|
const last = lastProjectStatus.get(nodeId);
|
|
14985
|
-
if (last !== void 0 && last
|
|
15175
|
+
if (last !== void 0 && !statusesAgree(last, status)) {
|
|
14986
15176
|
findings.push({
|
|
14987
15177
|
path: "journal",
|
|
14988
15178
|
rule: "journal-status-mismatch",
|
|
@@ -14991,8 +15181,40 @@ function crossCheckJournal(bundle) {
|
|
|
14991
15181
|
});
|
|
14992
15182
|
}
|
|
14993
15183
|
}
|
|
15184
|
+
for (const [nodeId, last] of lastDecisionStatus) {
|
|
15185
|
+
if (!snapshotDecisionStatus.has(nodeId)) continue;
|
|
15186
|
+
const current = snapshotDecisionStatus.get(nodeId) ?? "proposed";
|
|
15187
|
+
if (last !== current) {
|
|
15188
|
+
findings.push({
|
|
15189
|
+
path: "journal",
|
|
15190
|
+
rule: "journal-decision-status-mismatch",
|
|
15191
|
+
message: `Node "${nodeId}": journal's last decision.status_changed.to "${last}" disagrees with snapshot decision_status "${String(current)}".`,
|
|
15192
|
+
severity: "error"
|
|
15193
|
+
});
|
|
15194
|
+
}
|
|
15195
|
+
}
|
|
14994
15196
|
return findings;
|
|
14995
15197
|
}
|
|
15198
|
+
function missingProvenanceNodeIds(snapshotNodeIds, events) {
|
|
15199
|
+
const covered = /* @__PURE__ */ new Set();
|
|
15200
|
+
for (const ev of events) {
|
|
15201
|
+
if (ev.type === "node.created") {
|
|
15202
|
+
if (typeof ev.node_id === "string") covered.add(ev.node_id);
|
|
15203
|
+
} else if (ev.type === "journal.baseline" && Array.isArray(ev.node_ids)) {
|
|
15204
|
+
for (const id of ev.node_ids) {
|
|
15205
|
+
if (typeof id === "string") covered.add(id);
|
|
15206
|
+
}
|
|
15207
|
+
}
|
|
15208
|
+
}
|
|
15209
|
+
const missing = [];
|
|
15210
|
+
const seen = /* @__PURE__ */ new Set();
|
|
15211
|
+
for (const id of snapshotNodeIds) {
|
|
15212
|
+
if (covered.has(id) || seen.has(id)) continue;
|
|
15213
|
+
seen.add(id);
|
|
15214
|
+
missing.push(id);
|
|
15215
|
+
}
|
|
15216
|
+
return missing;
|
|
15217
|
+
}
|
|
14996
15218
|
|
|
14997
15219
|
// ../schema/src/journal-events.ts
|
|
14998
15220
|
var envelope = {
|
|
@@ -15021,10 +15243,19 @@ var NodeStatusChangedEventSchema = external_exports.object({
|
|
|
15021
15243
|
...envelope,
|
|
15022
15244
|
type: external_exports.literal("node.status_changed"),
|
|
15023
15245
|
node_id: external_exports.string(),
|
|
15024
|
-
|
|
15025
|
-
|
|
15246
|
+
// History is never rewritten (docs/spec/journal.md): pre-v3 events keep
|
|
15247
|
+
// their legacy status ids, so strict per-type validation must accept them.
|
|
15248
|
+
from: AnyStatusSchema,
|
|
15249
|
+
to: AnyStatusSchema,
|
|
15026
15250
|
platform: PlatformSchema.optional()
|
|
15027
15251
|
}).catchall(external_exports.unknown());
|
|
15252
|
+
var DecisionStatusChangedEventSchema = external_exports.object({
|
|
15253
|
+
...envelope,
|
|
15254
|
+
type: external_exports.literal("decision.status_changed"),
|
|
15255
|
+
node_id: external_exports.string(),
|
|
15256
|
+
from: DecisionStatusSchema,
|
|
15257
|
+
to: DecisionStatusSchema
|
|
15258
|
+
}).catchall(external_exports.unknown());
|
|
15028
15259
|
var NodeDeletedEventSchema = external_exports.object({ ...envelope, type: external_exports.literal("node.deleted"), node_id: external_exports.string() }).catchall(external_exports.unknown());
|
|
15029
15260
|
var EdgeAddedEventSchema = external_exports.object({
|
|
15030
15261
|
...envelope,
|
|
@@ -15042,6 +15273,16 @@ var ReleaseTaggedEventSchema = external_exports.object({
|
|
|
15042
15273
|
notes: external_exports.string().optional(),
|
|
15043
15274
|
platform: PlatformSchema.optional()
|
|
15044
15275
|
}).catchall(external_exports.unknown());
|
|
15276
|
+
var DeliverableShippedEventSchema = external_exports.object({
|
|
15277
|
+
...envelope,
|
|
15278
|
+
type: external_exports.literal("deliverable.shipped"),
|
|
15279
|
+
deliverable_id: external_exports.string(),
|
|
15280
|
+
title: external_exports.string(),
|
|
15281
|
+
summary: external_exports.string().optional(),
|
|
15282
|
+
url: external_exports.string().optional(),
|
|
15283
|
+
node_ids: external_exports.array(external_exports.string()).optional(),
|
|
15284
|
+
platform: PlatformSchema.optional()
|
|
15285
|
+
}).catchall(external_exports.unknown());
|
|
15045
15286
|
var IdeaProposedEventSchema = external_exports.object({
|
|
15046
15287
|
...envelope,
|
|
15047
15288
|
type: external_exports.literal("idea.proposed"),
|
|
@@ -15075,39 +15316,47 @@ var RefStatusChangedEventSchema = external_exports.object({
|
|
|
15075
15316
|
to: external_exports.string(),
|
|
15076
15317
|
synced_at: external_exports.string()
|
|
15077
15318
|
}).catchall(external_exports.unknown());
|
|
15319
|
+
var JournalBaselineEventSchema = external_exports.object({ ...envelope, type: external_exports.literal("journal.baseline"), node_ids: external_exports.array(external_exports.string()) }).catchall(external_exports.unknown());
|
|
15078
15320
|
var JOURNAL_EVENT_SCHEMAS = {
|
|
15079
15321
|
"node.created": NodeCreatedEventSchema,
|
|
15080
15322
|
"node.updated": NodeUpdatedEventSchema,
|
|
15081
15323
|
"node.status_changed": NodeStatusChangedEventSchema,
|
|
15324
|
+
"decision.status_changed": DecisionStatusChangedEventSchema,
|
|
15082
15325
|
"node.deleted": NodeDeletedEventSchema,
|
|
15083
15326
|
"edge.added": EdgeAddedEventSchema,
|
|
15084
15327
|
"edge.removed": EdgeRemovedEventSchema,
|
|
15085
15328
|
"release.tagged": ReleaseTaggedEventSchema,
|
|
15329
|
+
"deliverable.shipped": DeliverableShippedEventSchema,
|
|
15086
15330
|
"idea.proposed": IdeaProposedEventSchema,
|
|
15087
15331
|
"request.filed": RequestFiledEventSchema,
|
|
15088
15332
|
"ref.added": RefAddedEventSchema,
|
|
15089
15333
|
"ref.removed": RefRemovedEventSchema,
|
|
15090
|
-
"ref.status_changed": RefStatusChangedEventSchema
|
|
15334
|
+
"ref.status_changed": RefStatusChangedEventSchema,
|
|
15335
|
+
"journal.baseline": JournalBaselineEventSchema
|
|
15091
15336
|
};
|
|
15092
15337
|
var KnownJournalEventSchema = external_exports.union([
|
|
15093
15338
|
NodeCreatedEventSchema,
|
|
15094
15339
|
NodeUpdatedEventSchema,
|
|
15095
15340
|
NodeStatusChangedEventSchema,
|
|
15341
|
+
DecisionStatusChangedEventSchema,
|
|
15096
15342
|
NodeDeletedEventSchema,
|
|
15097
15343
|
EdgeAddedEventSchema,
|
|
15098
15344
|
EdgeRemovedEventSchema,
|
|
15099
15345
|
ReleaseTaggedEventSchema,
|
|
15346
|
+
DeliverableShippedEventSchema,
|
|
15100
15347
|
IdeaProposedEventSchema,
|
|
15101
15348
|
RequestFiledEventSchema,
|
|
15102
15349
|
RefAddedEventSchema,
|
|
15103
15350
|
RefRemovedEventSchema,
|
|
15104
|
-
RefStatusChangedEventSchema
|
|
15351
|
+
RefStatusChangedEventSchema,
|
|
15352
|
+
JournalBaselineEventSchema
|
|
15105
15353
|
]);
|
|
15106
15354
|
|
|
15107
15355
|
// ../schema/src/bundle.ts
|
|
15108
15356
|
var PlatformStatusMapSchema = external_exports.partialRecord(
|
|
15109
15357
|
PlatformSchema,
|
|
15110
|
-
|
|
15358
|
+
// legacy-tolerant: migrateStatusVocabulary normalizes on load
|
|
15359
|
+
AnyStatusSchema
|
|
15111
15360
|
).meta({ id: "PlatformStatusMap", description: "Per-platform status overrides for view nodes." });
|
|
15112
15361
|
var PlatformNotesMapSchema = external_exports.partialRecord(
|
|
15113
15362
|
PlatformSchema,
|
|
@@ -15130,7 +15379,8 @@ var RefSchema = external_exports.object({
|
|
|
15130
15379
|
external_status: external_exports.string().optional().meta({
|
|
15131
15380
|
description: 'Mirrored external state, verbatim (e.g. "open", "merged", "In Progress").'
|
|
15132
15381
|
}),
|
|
15133
|
-
|
|
15382
|
+
// legacy-tolerant: migrateStatusVocabulary normalizes on load
|
|
15383
|
+
status_mapped: AnyStatusSchema.optional().meta({
|
|
15134
15384
|
description: "Optional mapping of external_status into the arkaik lifecycle. Advisory display data \u2014 never mutates node.status."
|
|
15135
15385
|
}),
|
|
15136
15386
|
platform: PlatformSchema.optional().meta({ description: "Optional scoping to one platform variant." }),
|
|
@@ -15138,6 +15388,9 @@ var RefSchema = external_exports.object({
|
|
|
15138
15388
|
}).meta({ id: "Ref", description: "A typed external reference on a node (docs/spec/bundle-format.md \xA7 References)." });
|
|
15139
15389
|
var NodeMetadataSchema = external_exports.object({
|
|
15140
15390
|
stage: external_exports.string().optional(),
|
|
15391
|
+
blocked_by: external_exports.string().optional().meta({
|
|
15392
|
+
description: "Non-empty = blocked at the current status. A node id (rendered as a link) or free text naming the dependency."
|
|
15393
|
+
}),
|
|
15141
15394
|
playlist: FlowPlaylistSchema.optional(),
|
|
15142
15395
|
platformNotes: PlatformNotesMapSchema.optional(),
|
|
15143
15396
|
platformStatuses: PlatformStatusMapSchema.optional(),
|
|
@@ -15148,6 +15401,21 @@ var NodeMetadataSchema = external_exports.object({
|
|
|
15148
15401
|
}),
|
|
15149
15402
|
values: external_exports.array(ValueSchema).optional().meta({
|
|
15150
15403
|
description: "Acceptance nodes only: 1..n Bain value elements served (the Why)."
|
|
15404
|
+
}),
|
|
15405
|
+
product: external_exports.string().optional().meta({
|
|
15406
|
+
description: "Product membership (docs/spec/bundle-format.md \xA7 Products); flow, view, and acceptance only."
|
|
15407
|
+
}),
|
|
15408
|
+
decision_status: DecisionStatusSchema.optional().meta({
|
|
15409
|
+
description: "Decision nodes only: proposed | approved | enacted | rejected | deprecated | superseded. The node's lifecycle status is kept in sync (spec \xA72)."
|
|
15410
|
+
}),
|
|
15411
|
+
context: external_exports.string().optional().meta({
|
|
15412
|
+
description: "Decision nodes only: Context \u2014 the Why (markdown)."
|
|
15413
|
+
}),
|
|
15414
|
+
consequences: external_exports.string().optional().meta({
|
|
15415
|
+
description: "Decision nodes only: Consequences \u2014 the How (markdown)."
|
|
15416
|
+
}),
|
|
15417
|
+
decided_at: external_exports.string().optional().meta({
|
|
15418
|
+
description: "Decision nodes only: ISO 8601 date the decision was made."
|
|
15151
15419
|
})
|
|
15152
15420
|
}).catchall(external_exports.unknown()).meta({ id: "NodeMetadata", description: "Optional metadata for a node." });
|
|
15153
15421
|
var NodeSchema = external_exports.object({
|
|
@@ -15156,7 +15424,8 @@ var NodeSchema = external_exports.object({
|
|
|
15156
15424
|
species: SpeciesSchema,
|
|
15157
15425
|
title: external_exports.string().meta({ description: "Human-readable node title." }),
|
|
15158
15426
|
description: external_exports.string().optional().meta({ description: "Optional description of the node's purpose." }),
|
|
15159
|
-
|
|
15427
|
+
// legacy-tolerant: migrateStatusVocabulary normalizes on load
|
|
15428
|
+
status: AnyStatusSchema,
|
|
15160
15429
|
platforms: external_exports.array(PlatformSchema).meta({ description: "One or more target platforms." }),
|
|
15161
15430
|
metadata: NodeMetadataSchema.optional()
|
|
15162
15431
|
}).meta({ id: "Node" });
|
|
@@ -15168,6 +15437,18 @@ var EdgeSchema = external_exports.object({
|
|
|
15168
15437
|
edge_type: EdgeTypeSchema,
|
|
15169
15438
|
metadata: external_exports.record(external_exports.string(), external_exports.unknown()).optional().meta({ description: "Optional edge metadata." })
|
|
15170
15439
|
}).meta({ id: "Edge" });
|
|
15440
|
+
var MapDisplayOptionsSchema = external_exports.object({
|
|
15441
|
+
images: external_exports.boolean().optional().meta({ description: "Screenshot (or cover) art on view cards." }),
|
|
15442
|
+
flow_platforms: external_exports.string().optional().meta({
|
|
15443
|
+
description: "A flow card's platform delivery: rings (default) | bars."
|
|
15444
|
+
}),
|
|
15445
|
+
view_platforms: external_exports.string().optional().meta({
|
|
15446
|
+
description: "A view card's platform availability: chips (default) | rows."
|
|
15447
|
+
}),
|
|
15448
|
+
minimap_color: external_exports.string().optional().meta({
|
|
15449
|
+
description: "What a minimap node's fill encodes: status (default) | species."
|
|
15450
|
+
})
|
|
15451
|
+
}).catchall(external_exports.unknown()).meta({ id: "MapDisplayOptions", description: "How a map draws its cards (docs/spec/maps.md \xA7 Display Options)." });
|
|
15171
15452
|
var MapDefinitionSchema = external_exports.object({
|
|
15172
15453
|
id: external_exports.string().meta({
|
|
15173
15454
|
description: "Kebab-case, unique within the project; built-in ids (journey, system) are reserved."
|
|
@@ -15186,13 +15467,32 @@ var MapDefinitionSchema = external_exports.object({
|
|
|
15186
15467
|
root_node_id: external_exports.string().optional().meta({
|
|
15187
15468
|
description: "Scope anchor: the subgraph is the undirected neighborhood reachable from this node."
|
|
15188
15469
|
}),
|
|
15470
|
+
product: external_exports.string().optional().meta({ description: "Product scope; absent = every product." }),
|
|
15189
15471
|
depth: external_exports.number().optional().meta({ description: "Traversal bound from the root; absent = unbounded." }),
|
|
15190
|
-
layout: external_exports.object({ direction: external_exports.string().optional() }).catchall(external_exports.unknown()).optional().meta({ description: "Renderer layout hints (e.g. direction: DOWN | RIGHT)." })
|
|
15472
|
+
layout: external_exports.object({ direction: external_exports.string().optional() }).catchall(external_exports.unknown()).optional().meta({ description: "Renderer layout hints (e.g. direction: DOWN | RIGHT)." }),
|
|
15473
|
+
display: MapDisplayOptionsSchema.optional().meta({
|
|
15474
|
+
description: "Card rendering; the human twin is project.metadata.map_display[id]."
|
|
15475
|
+
})
|
|
15191
15476
|
}).catchall(external_exports.unknown()).meta({ id: "MapDefinition", description: "A stored map definition (docs/spec/maps.md \xA7 MapDefinition)." });
|
|
15477
|
+
var ProductDefinitionSchema = external_exports.object({
|
|
15478
|
+
id: external_exports.string().meta({ description: "Kebab-case, unique within the project." }),
|
|
15479
|
+
title: external_exports.string().meta({ description: "Display title." }),
|
|
15480
|
+
description: external_exports.string().optional().meta({ description: "What this product is." }),
|
|
15481
|
+
platforms: external_exports.array(PlatformSchema).meta({
|
|
15482
|
+
description: "The platforms this product can ship on; empty means availability is not tracked."
|
|
15483
|
+
}),
|
|
15484
|
+
root_node_id: external_exports.string().optional().meta({ description: "This product's journey anchor." })
|
|
15485
|
+
}).catchall(external_exports.unknown()).meta({ id: "ProductDefinition", description: "A product definition (docs/spec/bundle-format.md \xA7 Products)." });
|
|
15192
15486
|
var ProjectMetadataSchema = external_exports.object({
|
|
15193
15487
|
view_card_variant: external_exports.enum(["compact", "large"]).optional(),
|
|
15194
15488
|
maps: external_exports.array(MapDefinitionSchema).optional().meta({
|
|
15195
15489
|
description: "Stored map definitions (docs/spec/maps.md \xA7 Storage) \u2014 additive; unknown fields preserved."
|
|
15490
|
+
}),
|
|
15491
|
+
map_display: external_exports.record(external_exports.string(), MapDisplayOptionsSchema).optional().meta({
|
|
15492
|
+
description: "Per-map display overrides keyed by map id (docs/spec/maps.md \xA7 Display Options) \u2014 the only path open to the built-in maps."
|
|
15493
|
+
}),
|
|
15494
|
+
products: external_exports.array(ProductDefinitionSchema).optional().meta({
|
|
15495
|
+
description: "Product definitions (docs/spec/bundle-format.md \xA7 Products) \u2014 additive; unknown fields preserved."
|
|
15196
15496
|
})
|
|
15197
15497
|
}).catchall(external_exports.unknown()).meta({ id: "ProjectMetadata", description: "Optional project-level UI settings." });
|
|
15198
15498
|
var ProjectSchema = external_exports.object({
|
|
@@ -15228,7 +15528,119 @@ var ProjectBundleSchema = external_exports.object({
|
|
|
15228
15528
|
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)."
|
|
15229
15529
|
});
|
|
15230
15530
|
|
|
15531
|
+
// ../schema/src/products.ts
|
|
15532
|
+
var PRODUCT_MEMBERSHIP_SPECIES = ["flow", "view", "acceptance"];
|
|
15533
|
+
function resolveProducts(project) {
|
|
15534
|
+
const stored = project?.metadata?.products;
|
|
15535
|
+
if (!Array.isArray(stored)) return [];
|
|
15536
|
+
const seen = /* @__PURE__ */ new Set();
|
|
15537
|
+
const products = [];
|
|
15538
|
+
for (const entry of stored) {
|
|
15539
|
+
if (typeof entry !== "object" || entry === null || Array.isArray(entry)) continue;
|
|
15540
|
+
const candidate = entry;
|
|
15541
|
+
if (typeof candidate.id !== "string" || candidate.id.trim() === "" || seen.has(candidate.id)) continue;
|
|
15542
|
+
seen.add(candidate.id);
|
|
15543
|
+
products.push(candidate);
|
|
15544
|
+
}
|
|
15545
|
+
return products;
|
|
15546
|
+
}
|
|
15547
|
+
function productOf(node) {
|
|
15548
|
+
if (!PRODUCT_MEMBERSHIP_SPECIES.includes(node.species)) return null;
|
|
15549
|
+
const product = node.metadata?.product;
|
|
15550
|
+
return typeof product === "string" ? product : null;
|
|
15551
|
+
}
|
|
15552
|
+
var SYSTEM_LAYER_SPECIES = ["api-endpoint", "data-model"];
|
|
15553
|
+
var USAGE_EDGE_TYPES = /* @__PURE__ */ new Set(["calls", "displays", "queries"]);
|
|
15554
|
+
function buildProductUsageIndex(nodes, edges) {
|
|
15555
|
+
const speciesById = /* @__PURE__ */ new Map();
|
|
15556
|
+
for (const node of nodes) speciesById.set(node.id, node.species);
|
|
15557
|
+
const outgoing = /* @__PURE__ */ new Map();
|
|
15558
|
+
for (const edge of edges) {
|
|
15559
|
+
if (!USAGE_EDGE_TYPES.has(edge.edge_type)) continue;
|
|
15560
|
+
const targetSpecies = speciesById.get(edge.target_id);
|
|
15561
|
+
if (targetSpecies === void 0 || !SYSTEM_LAYER_SPECIES.includes(targetSpecies)) continue;
|
|
15562
|
+
const list = outgoing.get(edge.source_id) ?? [];
|
|
15563
|
+
list.push(edge.target_id);
|
|
15564
|
+
outgoing.set(edge.source_id, list);
|
|
15565
|
+
}
|
|
15566
|
+
const seedsByProduct = /* @__PURE__ */ new Map();
|
|
15567
|
+
for (const node of nodes) {
|
|
15568
|
+
const product = productOf(node);
|
|
15569
|
+
if (product === null) continue;
|
|
15570
|
+
const seeds = seedsByProduct.get(product) ?? /* @__PURE__ */ new Set();
|
|
15571
|
+
for (const next of outgoing.get(node.id) ?? []) seeds.add(next);
|
|
15572
|
+
seedsByProduct.set(product, seeds);
|
|
15573
|
+
}
|
|
15574
|
+
const byNode = /* @__PURE__ */ new Map();
|
|
15575
|
+
for (const [product, seeds] of seedsByProduct) {
|
|
15576
|
+
const visited = new Set(seeds);
|
|
15577
|
+
let frontier = [...seeds];
|
|
15578
|
+
while (frontier.length > 0) {
|
|
15579
|
+
const next = [];
|
|
15580
|
+
for (const current of frontier) {
|
|
15581
|
+
const products = byNode.get(current) ?? /* @__PURE__ */ new Set();
|
|
15582
|
+
products.add(product);
|
|
15583
|
+
byNode.set(current, products);
|
|
15584
|
+
for (const neighbor of outgoing.get(current) ?? []) {
|
|
15585
|
+
if (visited.has(neighbor)) continue;
|
|
15586
|
+
visited.add(neighbor);
|
|
15587
|
+
next.push(neighbor);
|
|
15588
|
+
}
|
|
15589
|
+
}
|
|
15590
|
+
frontier = next;
|
|
15591
|
+
}
|
|
15592
|
+
}
|
|
15593
|
+
const index = /* @__PURE__ */ new Map();
|
|
15594
|
+
for (const [nodeId, products] of byNode) index.set(nodeId, [...products].sort());
|
|
15595
|
+
return index;
|
|
15596
|
+
}
|
|
15597
|
+
function productsUsingNode(nodeId, index) {
|
|
15598
|
+
return index.get(nodeId) ?? [];
|
|
15599
|
+
}
|
|
15600
|
+
function buildProductGraph(nodes, edges) {
|
|
15601
|
+
return {
|
|
15602
|
+
edges,
|
|
15603
|
+
nodesById: new Map(nodes.map((node) => [node.id, node])),
|
|
15604
|
+
usageIndex: buildProductUsageIndex(nodes, edges)
|
|
15605
|
+
};
|
|
15606
|
+
}
|
|
15607
|
+
function coveredAnchorIds(acceptanceId, edges) {
|
|
15608
|
+
return edges.filter((edge) => edge.edge_type === "covers" && edge.source_id === acceptanceId).map((edge) => edge.target_id);
|
|
15609
|
+
}
|
|
15610
|
+
function productsOfAcceptance(acceptance, edges, nodesById) {
|
|
15611
|
+
const anchors = coveredAnchorIds(acceptance.id, edges).map((anchorId) => nodesById.get(anchorId)).filter((anchor) => anchor !== void 0);
|
|
15612
|
+
if (anchors.length === 0) {
|
|
15613
|
+
const stored = productOf(acceptance);
|
|
15614
|
+
return stored === null ? /* @__PURE__ */ new Set() : /* @__PURE__ */ new Set([stored]);
|
|
15615
|
+
}
|
|
15616
|
+
const products = /* @__PURE__ */ new Set();
|
|
15617
|
+
for (const anchor of anchors) {
|
|
15618
|
+
const product = productOf(anchor);
|
|
15619
|
+
if (product !== null) products.add(product);
|
|
15620
|
+
}
|
|
15621
|
+
return products;
|
|
15622
|
+
}
|
|
15623
|
+
function productsOfNode(node, graph) {
|
|
15624
|
+
if (node.species === "acceptance") {
|
|
15625
|
+
return productsOfAcceptance(node, graph.edges, graph.nodesById);
|
|
15626
|
+
}
|
|
15627
|
+
if (PRODUCT_MEMBERSHIP_SPECIES.includes(node.species)) {
|
|
15628
|
+
const stored = productOf(node);
|
|
15629
|
+
return stored === null ? /* @__PURE__ */ new Set() : /* @__PURE__ */ new Set([stored]);
|
|
15630
|
+
}
|
|
15631
|
+
return new Set(productsUsingNode(node.id, graph.usageIndex));
|
|
15632
|
+
}
|
|
15633
|
+
function nodeInProduct(node, productId, graph) {
|
|
15634
|
+
if (productId === null) return true;
|
|
15635
|
+
const products = productsOfNode(node, graph);
|
|
15636
|
+
if (products.size === 0) return !PRODUCT_MEMBERSHIP_SPECIES.includes(node.species);
|
|
15637
|
+
return products.has(productId);
|
|
15638
|
+
}
|
|
15639
|
+
|
|
15231
15640
|
// ../schema/src/maps.ts
|
|
15641
|
+
var MAP_FLOW_PLATFORMS_MODES = ["rings", "bars"];
|
|
15642
|
+
var MAP_VIEW_PLATFORMS_MODES = ["chips", "rows"];
|
|
15643
|
+
var MAP_MINIMAP_COLOR_MODES = ["status", "species"];
|
|
15232
15644
|
var KIND_DEFAULTS = {
|
|
15233
15645
|
journey: { species: ["flow", "view"], edge_types: ["composes"] },
|
|
15234
15646
|
system: { species: ["view", "api-endpoint", "data-model"], edge_types: ["calls", "displays", "queries"] }
|
|
@@ -15260,11 +15672,20 @@ function resolveMapDefaults(definition) {
|
|
|
15260
15672
|
edge_types: definition.edge_types ?? defaults?.edge_types ?? []
|
|
15261
15673
|
};
|
|
15262
15674
|
}
|
|
15263
|
-
function
|
|
15675
|
+
function declared(value) {
|
|
15676
|
+
return typeof value === "string" && value.trim() !== "" ? value : void 0;
|
|
15677
|
+
}
|
|
15678
|
+
function mapProductId(definition, defaultProductId = null) {
|
|
15679
|
+
return declared(definition?.product) ?? defaultProductId;
|
|
15680
|
+
}
|
|
15681
|
+
function computeMapSubgraph(definition, nodes, edges, options) {
|
|
15264
15682
|
const resolved = resolveMapDefaults(definition);
|
|
15265
15683
|
const speciesSet = new Set(resolved.species);
|
|
15266
15684
|
const edgeTypeSet = new Set(resolved.edge_types);
|
|
15267
|
-
const
|
|
15685
|
+
const productId = options?.product !== void 0 ? options.product : mapProductId(definition);
|
|
15686
|
+
const productGraph = productId === null ? void 0 : options?.graph ?? buildProductGraph(nodes, edges);
|
|
15687
|
+
const selectable = productGraph === void 0 ? nodes : nodes.filter((node) => nodeInProduct(node, productId, productGraph));
|
|
15688
|
+
const keptNodes = selectable.filter((node) => speciesSet.has(node.species));
|
|
15268
15689
|
const keptNodeIds = new Set(keptNodes.map((node) => node.id));
|
|
15269
15690
|
const keptEdges = edges.filter(
|
|
15270
15691
|
(edge) => edgeTypeSet.has(edge.edge_type) && keptNodeIds.has(edge.source_id) && keptNodeIds.has(edge.target_id)
|
|
@@ -15330,25 +15751,6 @@ function estimateDataUriBytes(dataUri) {
|
|
|
15330
15751
|
const padding = payload.endsWith("==") ? 2 : payload.endsWith("=") ? 1 : 0;
|
|
15331
15752
|
return Math.floor(payload.length * 3 / 4) - padding;
|
|
15332
15753
|
}
|
|
15333
|
-
var VALID_EDGE_SEMANTICS = {
|
|
15334
|
-
composes: [
|
|
15335
|
-
["flow", "view"],
|
|
15336
|
-
["flow", "flow"],
|
|
15337
|
-
["view", "flow"],
|
|
15338
|
-
["view", "view"]
|
|
15339
|
-
],
|
|
15340
|
-
calls: [
|
|
15341
|
-
["view", "api-endpoint"],
|
|
15342
|
-
["flow", "api-endpoint"],
|
|
15343
|
-
["api-endpoint", "api-endpoint"]
|
|
15344
|
-
],
|
|
15345
|
-
displays: [["view", "data-model"]],
|
|
15346
|
-
queries: [["api-endpoint", "data-model"]],
|
|
15347
|
-
covers: [
|
|
15348
|
-
["acceptance", "view"],
|
|
15349
|
-
["acceptance", "flow"]
|
|
15350
|
-
]
|
|
15351
|
-
};
|
|
15352
15754
|
function isIsoDate(value) {
|
|
15353
15755
|
return typeof value === "string" && !Number.isNaN(Date.parse(value));
|
|
15354
15756
|
}
|
|
@@ -15444,7 +15846,9 @@ function validateBundle(input) {
|
|
|
15444
15846
|
}
|
|
15445
15847
|
const platforms = node.platforms;
|
|
15446
15848
|
if (!platforms || platforms.length === 0) {
|
|
15447
|
-
|
|
15849
|
+
if (species !== "decision") {
|
|
15850
|
+
error51(`${base}.platforms`, "platforms-non-empty", `Node ${nodeId}: platforms array is empty or missing`);
|
|
15851
|
+
}
|
|
15448
15852
|
} else {
|
|
15449
15853
|
for (const p of platforms) {
|
|
15450
15854
|
if (!PLATFORM_IDS.includes(p)) {
|
|
@@ -15566,6 +15970,25 @@ function validateBundle(input) {
|
|
|
15566
15970
|
}
|
|
15567
15971
|
});
|
|
15568
15972
|
}
|
|
15973
|
+
const decisionStatus = md.decision_status;
|
|
15974
|
+
if (decisionStatus !== void 0 && species !== "decision") {
|
|
15975
|
+
warn(
|
|
15976
|
+
`${base}.metadata.decision_status`,
|
|
15977
|
+
"decision-status-wrong-species",
|
|
15978
|
+
`decision_status is meaningful on decision nodes only; "${nodeId}" is a ${species}.`
|
|
15979
|
+
);
|
|
15980
|
+
}
|
|
15981
|
+
if (species === "decision") {
|
|
15982
|
+
const effective = decisionStatusOf({ metadata: node.metadata });
|
|
15983
|
+
const expected = lifecycleStatusForDecision(effective);
|
|
15984
|
+
if (node.status !== expected) {
|
|
15985
|
+
warn(
|
|
15986
|
+
`${base}.status`,
|
|
15987
|
+
"decision-lifecycle-mismatch",
|
|
15988
|
+
`Decision "${nodeId}" is ${effective}, whose lifecycle status should be "${expected}", but status is "${node.status}" (spec \xA72).`
|
|
15989
|
+
);
|
|
15990
|
+
}
|
|
15991
|
+
}
|
|
15569
15992
|
if (species === "flow") {
|
|
15570
15993
|
const playlist = md.playlist;
|
|
15571
15994
|
if (!node.metadata || !playlist || !playlist.entries) {
|
|
@@ -15583,6 +16006,38 @@ function validateBundle(input) {
|
|
|
15583
16006
|
`project.root_node_id "${rootNodeId}" does not reference an existing node`
|
|
15584
16007
|
);
|
|
15585
16008
|
}
|
|
16009
|
+
const checkMapDisplay = (display, path, subject) => {
|
|
16010
|
+
if (typeof display !== "object" || display === null || Array.isArray(display)) return;
|
|
16011
|
+
const options = display;
|
|
16012
|
+
const modes = [
|
|
16013
|
+
["flow_platforms", MAP_FLOW_PLATFORMS_MODES],
|
|
16014
|
+
["view_platforms", MAP_VIEW_PLATFORMS_MODES],
|
|
16015
|
+
["minimap_color", MAP_MINIMAP_COLOR_MODES]
|
|
16016
|
+
];
|
|
16017
|
+
for (const [key, allowed] of modes) {
|
|
16018
|
+
const value = options[key];
|
|
16019
|
+
if (value !== void 0 && (typeof value !== "string" || !allowed.includes(value))) {
|
|
16020
|
+
warn(
|
|
16021
|
+
`${path}.${key}`,
|
|
16022
|
+
"map-unknown-display",
|
|
16023
|
+
`${subject} sets ${key} to "${String(value)}"; expected one of ${allowed.join(", ")} (renderers fall back to the default)`
|
|
16024
|
+
);
|
|
16025
|
+
}
|
|
16026
|
+
}
|
|
16027
|
+
if (options.images !== void 0 && typeof options.images !== "boolean") {
|
|
16028
|
+
warn(
|
|
16029
|
+
`${path}.images`,
|
|
16030
|
+
"map-unknown-display",
|
|
16031
|
+
`${subject} sets images to a non-boolean value (renderers fall back to the default)`
|
|
16032
|
+
);
|
|
16033
|
+
}
|
|
16034
|
+
};
|
|
16035
|
+
const mapDisplayOverrides = projectMetadata?.map_display;
|
|
16036
|
+
if (typeof mapDisplayOverrides === "object" && mapDisplayOverrides !== null && !Array.isArray(mapDisplayOverrides)) {
|
|
16037
|
+
for (const [mapId, display] of Object.entries(mapDisplayOverrides)) {
|
|
16038
|
+
checkMapDisplay(display, `project.metadata.map_display.${mapId}`, `Map "${mapId}"`);
|
|
16039
|
+
}
|
|
16040
|
+
}
|
|
15586
16041
|
const storedMaps = projectMetadata?.maps;
|
|
15587
16042
|
if (Array.isArray(storedMaps)) {
|
|
15588
16043
|
const seenMapIds = /* @__PURE__ */ new Set();
|
|
@@ -15630,8 +16085,122 @@ function validateBundle(input) {
|
|
|
15630
16085
|
}
|
|
15631
16086
|
});
|
|
15632
16087
|
}
|
|
16088
|
+
checkMapDisplay(map2.display, `${path}.display`, `Map "${mapId ?? index}"`);
|
|
15633
16089
|
});
|
|
15634
16090
|
}
|
|
16091
|
+
const storedProducts = projectMetadata?.products;
|
|
16092
|
+
const declaredProductIds = /* @__PURE__ */ new Set();
|
|
16093
|
+
if (Array.isArray(storedProducts)) {
|
|
16094
|
+
const seenProductIds = /* @__PURE__ */ new Set();
|
|
16095
|
+
storedProducts.forEach((definition, index) => {
|
|
16096
|
+
if (typeof definition !== "object" || definition === null || Array.isArray(definition)) return;
|
|
16097
|
+
const product = definition;
|
|
16098
|
+
const path = `project.metadata.products[${index}]`;
|
|
16099
|
+
const productId = typeof product.id === "string" ? product.id : void 0;
|
|
16100
|
+
if (productId === void 0) return;
|
|
16101
|
+
if (seenProductIds.has(productId)) {
|
|
16102
|
+
warn(`${path}.id`, "product-duplicate-id", `Duplicate product id "${productId}" \u2014 the first wins`);
|
|
16103
|
+
} else {
|
|
16104
|
+
seenProductIds.add(productId);
|
|
16105
|
+
if (productId.trim() !== "") declaredProductIds.add(productId);
|
|
16106
|
+
}
|
|
16107
|
+
if (!/^[a-z0-9]+(-[a-z0-9]+)*$/.test(productId)) {
|
|
16108
|
+
warn(`${path}.id`, "product-invalid-id", `Product id "${productId}" is not kebab-case`);
|
|
16109
|
+
}
|
|
16110
|
+
});
|
|
16111
|
+
}
|
|
16112
|
+
const hasProducts = declaredProductIds.size > 0;
|
|
16113
|
+
const anchorsByAcceptance = /* @__PURE__ */ new Map();
|
|
16114
|
+
for (const edge of edges) {
|
|
16115
|
+
if (edge.edge_type !== "covers") continue;
|
|
16116
|
+
const source = typeof edge.source_id === "string" ? edge.source_id : void 0;
|
|
16117
|
+
const target = typeof edge.target_id === "string" ? edge.target_id : void 0;
|
|
16118
|
+
if (source === void 0 || target === void 0) continue;
|
|
16119
|
+
const list = anchorsByAcceptance.get(source) ?? [];
|
|
16120
|
+
list.push(target);
|
|
16121
|
+
anchorsByAcceptance.set(source, list);
|
|
16122
|
+
}
|
|
16123
|
+
const menuByProduct = /* @__PURE__ */ new Map();
|
|
16124
|
+
if (hasProducts) {
|
|
16125
|
+
for (const definition of resolveProducts({ metadata: projectMetadata })) {
|
|
16126
|
+
menuByProduct.set(
|
|
16127
|
+
definition.id,
|
|
16128
|
+
new Set(Array.isArray(definition.platforms) ? definition.platforms : [])
|
|
16129
|
+
);
|
|
16130
|
+
}
|
|
16131
|
+
}
|
|
16132
|
+
const productByNodeId = /* @__PURE__ */ new Map();
|
|
16133
|
+
const indexByNodeId = /* @__PURE__ */ new Map();
|
|
16134
|
+
nodes.forEach((node, index) => {
|
|
16135
|
+
const nodeId = typeof node.id === "string" ? node.id : `#${index}`;
|
|
16136
|
+
const species = node.species;
|
|
16137
|
+
const base = `nodes[${index}]`;
|
|
16138
|
+
indexByNodeId.set(nodeId, index);
|
|
16139
|
+
const metadata = node.metadata ?? {};
|
|
16140
|
+
const membership = typeof metadata.product === "string" ? metadata.product : void 0;
|
|
16141
|
+
const storesMembership = species !== void 0 && PRODUCT_MEMBERSHIP_SPECIES.includes(species);
|
|
16142
|
+
if (membership !== void 0 && !storesMembership) {
|
|
16143
|
+
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";
|
|
16144
|
+
warn(`${base}.metadata.product`, "product-membership-wrong-species", `Node ${nodeId}: ${detail}`);
|
|
16145
|
+
return;
|
|
16146
|
+
}
|
|
16147
|
+
if (!storesMembership) return;
|
|
16148
|
+
if (membership === void 0) {
|
|
16149
|
+
if (!hasProducts) return;
|
|
16150
|
+
if (species === "acceptance") {
|
|
16151
|
+
if (!anchorsByAcceptance.has(nodeId)) {
|
|
16152
|
+
warn(
|
|
16153
|
+
`${base}.metadata.product`,
|
|
16154
|
+
"acceptance-product-unassigned",
|
|
16155
|
+
`Acceptance ${nodeId} covers nothing and names no product \u2014 it will show only under "All products"`
|
|
16156
|
+
);
|
|
16157
|
+
}
|
|
16158
|
+
} else {
|
|
16159
|
+
warn(
|
|
16160
|
+
`${base}.metadata.product`,
|
|
16161
|
+
"unassigned-membership",
|
|
16162
|
+
`Node ${nodeId}: no product membership \u2014 it will show only under "All products"`
|
|
16163
|
+
);
|
|
16164
|
+
}
|
|
16165
|
+
return;
|
|
16166
|
+
}
|
|
16167
|
+
productByNodeId.set(nodeId, membership);
|
|
16168
|
+
if (!declaredProductIds.has(membership)) {
|
|
16169
|
+
warn(
|
|
16170
|
+
`${base}.metadata.product`,
|
|
16171
|
+
"product-unknown-reference",
|
|
16172
|
+
`Node ${nodeId}: product "${membership}" is not declared on the project`
|
|
16173
|
+
);
|
|
16174
|
+
return;
|
|
16175
|
+
}
|
|
16176
|
+
const menu = menuByProduct.get(membership);
|
|
16177
|
+
const nodePlatforms = Array.isArray(node.platforms) ? node.platforms : [];
|
|
16178
|
+
if (menu) {
|
|
16179
|
+
for (const platform of nodePlatforms) {
|
|
16180
|
+
if (typeof platform === "string" && !menu.has(platform)) {
|
|
16181
|
+
warn(
|
|
16182
|
+
`${base}.platforms`,
|
|
16183
|
+
"product-platform-not-in-menu",
|
|
16184
|
+
`Node ${nodeId}: platform "${platform}" is not in product "${membership}"'s menu`
|
|
16185
|
+
);
|
|
16186
|
+
}
|
|
16187
|
+
}
|
|
16188
|
+
}
|
|
16189
|
+
});
|
|
16190
|
+
if (hasProducts) {
|
|
16191
|
+
for (const [acceptanceId, anchors] of anchorsByAcceptance) {
|
|
16192
|
+
const acceptanceIndex = indexByNodeId.get(acceptanceId);
|
|
16193
|
+
if (acceptanceIndex === void 0) continue;
|
|
16194
|
+
const spanned = new Set(anchors.map((id) => productByNodeId.get(id)).filter((id) => Boolean(id)));
|
|
16195
|
+
if (spanned.size > 1) {
|
|
16196
|
+
warn(
|
|
16197
|
+
`nodes[${acceptanceIndex}].metadata.product`,
|
|
16198
|
+
"acceptance-covers-span-products",
|
|
16199
|
+
`Acceptance ${acceptanceId} covers anchors in ${[...spanned].sort().join(" and ")} \u2014 statuses may conflate products`
|
|
16200
|
+
);
|
|
16201
|
+
}
|
|
16202
|
+
}
|
|
16203
|
+
}
|
|
15635
16204
|
const edgeIds = /* @__PURE__ */ new Set();
|
|
15636
16205
|
const edgeSignatures = /* @__PURE__ */ new Set();
|
|
15637
16206
|
const composesSet = /* @__PURE__ */ new Set();
|
|
@@ -15687,13 +16256,98 @@ function validateBundle(input) {
|
|
|
15687
16256
|
composesSet.add(`${sourceId}->${targetId}`);
|
|
15688
16257
|
}
|
|
15689
16258
|
});
|
|
16259
|
+
const PLAYLIST_ENTRY_TYPES = ["view", "flow", "condition", "junction"];
|
|
16260
|
+
const checkPlaylistShape = (entries, flowId, path, depth = 0) => {
|
|
16261
|
+
if (depth > 50) return;
|
|
16262
|
+
if (!Array.isArray(entries)) {
|
|
16263
|
+
error51(path, "playlist-entry-shape", `Flow ${flowId}: ${path} must be an array of playlist entries`);
|
|
16264
|
+
return;
|
|
16265
|
+
}
|
|
16266
|
+
entries.forEach((raw, i) => {
|
|
16267
|
+
const p = `${path}[${i}]`;
|
|
16268
|
+
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) {
|
|
16269
|
+
error51(p, "playlist-entry-shape", `Flow ${flowId}: ${p} must be a playlist entry object`);
|
|
16270
|
+
return;
|
|
16271
|
+
}
|
|
16272
|
+
const entry = raw;
|
|
16273
|
+
const type = entry.type;
|
|
16274
|
+
if (typeof type !== "string" || !PLAYLIST_ENTRY_TYPES.includes(type)) {
|
|
16275
|
+
error51(
|
|
16276
|
+
`${p}.type`,
|
|
16277
|
+
"playlist-entry-shape",
|
|
16278
|
+
`Flow ${flowId}: ${p}.type must be one of ${PLAYLIST_ENTRY_TYPES.join(", ")} (got ${JSON.stringify(type)})`
|
|
16279
|
+
);
|
|
16280
|
+
return;
|
|
16281
|
+
}
|
|
16282
|
+
if (type === "view") {
|
|
16283
|
+
if (typeof entry.view_id !== "string") {
|
|
16284
|
+
error51(`${p}.view_id`, "playlist-entry-shape", `Flow ${flowId}: ${p} is a view entry with no view_id string`);
|
|
16285
|
+
}
|
|
16286
|
+
} else if (type === "flow") {
|
|
16287
|
+
if (typeof entry.flow_id !== "string") {
|
|
16288
|
+
error51(`${p}.flow_id`, "playlist-entry-shape", `Flow ${flowId}: ${p} is a flow entry with no flow_id string`);
|
|
16289
|
+
}
|
|
16290
|
+
} else if (type === "condition") {
|
|
16291
|
+
if (typeof entry.label !== "string") {
|
|
16292
|
+
error51(`${p}.label`, "playlist-entry-shape", `Flow ${flowId}: ${p} is a condition with no label string`);
|
|
16293
|
+
}
|
|
16294
|
+
for (const branch of ["if_true", "if_false"]) {
|
|
16295
|
+
if (!Array.isArray(entry[branch])) {
|
|
16296
|
+
error51(
|
|
16297
|
+
`${p}.${branch}`,
|
|
16298
|
+
"playlist-entry-shape",
|
|
16299
|
+
`Flow ${flowId}: ${p}.${branch} must be an array of playlist entries (both branches are required, use [] for an empty one)`
|
|
16300
|
+
);
|
|
16301
|
+
} else {
|
|
16302
|
+
checkPlaylistShape(entry[branch], flowId, `${p}.${branch}`, depth + 1);
|
|
16303
|
+
}
|
|
16304
|
+
}
|
|
16305
|
+
} else {
|
|
16306
|
+
if (typeof entry.label !== "string") {
|
|
16307
|
+
error51(`${p}.label`, "playlist-entry-shape", `Flow ${flowId}: ${p} is a junction with no label string`);
|
|
16308
|
+
}
|
|
16309
|
+
if (!Array.isArray(entry.cases)) {
|
|
16310
|
+
error51(`${p}.cases`, "playlist-entry-shape", `Flow ${flowId}: ${p}.cases must be an array of junction cases`);
|
|
16311
|
+
return;
|
|
16312
|
+
}
|
|
16313
|
+
entry.cases.forEach((rawCase, j) => {
|
|
16314
|
+
const cp = `${p}.cases[${j}]`;
|
|
16315
|
+
if (typeof rawCase !== "object" || rawCase === null || Array.isArray(rawCase)) {
|
|
16316
|
+
error51(cp, "playlist-entry-shape", `Flow ${flowId}: ${cp} must be a junction case object`);
|
|
16317
|
+
return;
|
|
16318
|
+
}
|
|
16319
|
+
const branch = rawCase;
|
|
16320
|
+
if (typeof branch.label !== "string") {
|
|
16321
|
+
error51(`${cp}.label`, "playlist-entry-shape", `Flow ${flowId}: ${cp} has no label string`);
|
|
16322
|
+
}
|
|
16323
|
+
if (!Array.isArray(branch.entries)) {
|
|
16324
|
+
error51(
|
|
16325
|
+
`${cp}.entries`,
|
|
16326
|
+
"playlist-entry-shape",
|
|
16327
|
+
`Flow ${flowId}: ${cp}.entries must be an array of playlist entries \u2014 a junction case holds its own entries, not a bare view_id/flow_id`
|
|
16328
|
+
);
|
|
16329
|
+
} else {
|
|
16330
|
+
checkPlaylistShape(branch.entries, flowId, `${cp}.entries`, depth + 1);
|
|
16331
|
+
}
|
|
16332
|
+
});
|
|
16333
|
+
}
|
|
16334
|
+
});
|
|
16335
|
+
};
|
|
16336
|
+
nodes.forEach((node, i) => {
|
|
16337
|
+
const md = node.metadata;
|
|
16338
|
+
if (node.species === "flow" && md?.playlist?.entries) {
|
|
16339
|
+
checkPlaylistShape(md.playlist.entries, node.id, `nodes[${i}].metadata.playlist.entries`);
|
|
16340
|
+
}
|
|
16341
|
+
});
|
|
15690
16342
|
const collectPlaylistRefs = (entries, flowId, path, depth = 0) => {
|
|
15691
16343
|
if (depth > 50) {
|
|
15692
16344
|
error51(path, "playlist-depth", `Flow ${flowId}: playlist nesting too deep (possible cycle)`);
|
|
15693
16345
|
return [];
|
|
15694
16346
|
}
|
|
15695
16347
|
const refs = [];
|
|
16348
|
+
if (!Array.isArray(entries)) return refs;
|
|
15696
16349
|
for (const entry of entries) {
|
|
16350
|
+
if (typeof entry !== "object" || entry === null) continue;
|
|
15697
16351
|
if (entry.type === "view") {
|
|
15698
16352
|
if (!nodeIds.has(entry.view_id)) {
|
|
15699
16353
|
error51(path, "playlist-ref-exists", `Flow ${flowId}: playlist references non-existent view "${entry.view_id}"`);
|
|
@@ -15745,7 +16399,9 @@ function validateBundle(input) {
|
|
|
15745
16399
|
const nodeId = node.id;
|
|
15746
16400
|
const subFlows = [];
|
|
15747
16401
|
const findSubFlows = (entries) => {
|
|
16402
|
+
if (!Array.isArray(entries)) return;
|
|
15748
16403
|
for (const e of entries) {
|
|
16404
|
+
if (typeof e !== "object" || e === null) continue;
|
|
15749
16405
|
if (e.type === "flow") subFlows.push(e.flow_id);
|
|
15750
16406
|
if (e.type === "condition") {
|
|
15751
16407
|
if (e.if_true) findSubFlows(e.if_true);
|
|
@@ -15942,6 +16598,9 @@ function eventAffectsPlatform(ev, platform, nodesById) {
|
|
|
15942
16598
|
const edge = ev;
|
|
15943
16599
|
return onPlatform(edge.source_id) || onPlatform(edge.target_id);
|
|
15944
16600
|
}
|
|
16601
|
+
if (ev.type === "deliverable.shipped" && Array.isArray(ev.node_ids)) {
|
|
16602
|
+
return ev.node_ids.some(onPlatform);
|
|
16603
|
+
}
|
|
15945
16604
|
return false;
|
|
15946
16605
|
}
|
|
15947
16606
|
function computeChangelog(events, toVersion, options = {}) {
|
|
@@ -15955,7 +16614,7 @@ function computeChangelog(events, toVersion, options = {}) {
|
|
|
15955
16614
|
}
|
|
15956
16615
|
}
|
|
15957
16616
|
if (toIndex === -1) {
|
|
15958
|
-
return { fromVersion: null, toVersion, events: [] };
|
|
16617
|
+
return { fromVersion: null, toVersion, events: [], deliverables: [] };
|
|
15959
16618
|
}
|
|
15960
16619
|
const platform = asString(ordered[toIndex].platform);
|
|
15961
16620
|
let fromIndex = -1;
|
|
@@ -15984,7 +16643,8 @@ function computeChangelog(events, toVersion, options = {}) {
|
|
|
15984
16643
|
fromVersion: fromIndex >= 0 ? asString(ordered[fromIndex].version) ?? null : null,
|
|
15985
16644
|
toVersion,
|
|
15986
16645
|
...platform ? { platform } : {},
|
|
15987
|
-
events: slice
|
|
16646
|
+
events: slice,
|
|
16647
|
+
deliverables: computeDeliverables(ordered).filter((d) => d.releaseVersion === toVersion)
|
|
15988
16648
|
};
|
|
15989
16649
|
}
|
|
15990
16650
|
function deriveExistingNodeIds(orderedEvents) {
|
|
@@ -16013,6 +16673,61 @@ function computeBacklog(events, options = {}) {
|
|
|
16013
16673
|
items
|
|
16014
16674
|
};
|
|
16015
16675
|
}
|
|
16676
|
+
function computeDeliverables(events) {
|
|
16677
|
+
const ordered = orderEvents(events);
|
|
16678
|
+
const firstIndex = /* @__PURE__ */ new Map();
|
|
16679
|
+
const latest = /* @__PURE__ */ new Map();
|
|
16680
|
+
ordered.forEach((ev, i) => {
|
|
16681
|
+
if (ev.type !== "deliverable.shipped") return;
|
|
16682
|
+
const id = asString(ev.deliverable_id);
|
|
16683
|
+
if (id === void 0) return;
|
|
16684
|
+
if (!firstIndex.has(id)) firstIndex.set(id, i);
|
|
16685
|
+
latest.set(id, ev);
|
|
16686
|
+
});
|
|
16687
|
+
if (firstIndex.size === 0) return [];
|
|
16688
|
+
const markerLatest = /* @__PURE__ */ new Map();
|
|
16689
|
+
ordered.forEach((ev, i) => {
|
|
16690
|
+
if (ev.type !== "release.tagged") return;
|
|
16691
|
+
const version2 = asString(ev.version);
|
|
16692
|
+
if (version2 !== void 0) markerLatest.set(version2, i);
|
|
16693
|
+
});
|
|
16694
|
+
const windows = [];
|
|
16695
|
+
for (const [version2, toIndex] of markerLatest) {
|
|
16696
|
+
let fromIndex = -1;
|
|
16697
|
+
for (let i = toIndex - 1; i >= 0; i -= 1) {
|
|
16698
|
+
if (ordered[i].type === "release.tagged") {
|
|
16699
|
+
fromIndex = i;
|
|
16700
|
+
break;
|
|
16701
|
+
}
|
|
16702
|
+
}
|
|
16703
|
+
windows.push({ version: version2, from: fromIndex, to: toIndex });
|
|
16704
|
+
}
|
|
16705
|
+
const releaseOf = (index) => {
|
|
16706
|
+
for (const w of windows) {
|
|
16707
|
+
if (index > w.from && index < w.to) return w.version;
|
|
16708
|
+
}
|
|
16709
|
+
return null;
|
|
16710
|
+
};
|
|
16711
|
+
const out = [];
|
|
16712
|
+
for (const [id, anchorIndex] of firstIndex) {
|
|
16713
|
+
const ev = latest.get(id);
|
|
16714
|
+
if (ev === void 0) continue;
|
|
16715
|
+
const summary = asString(ev.summary);
|
|
16716
|
+
const url2 = asString(ev.url);
|
|
16717
|
+
const platform = asString(ev.platform);
|
|
16718
|
+
out.push({
|
|
16719
|
+
deliverable_id: id,
|
|
16720
|
+
title: asString(ev.title) ?? id,
|
|
16721
|
+
...summary !== void 0 ? { summary } : {},
|
|
16722
|
+
...url2 !== void 0 ? { url: url2 } : {},
|
|
16723
|
+
node_ids: Array.isArray(ev.node_ids) ? ev.node_ids.filter((n) => typeof n === "string") : [],
|
|
16724
|
+
...platform !== void 0 ? { platform } : {},
|
|
16725
|
+
ts: asString(ordered[anchorIndex].ts) ?? "",
|
|
16726
|
+
releaseVersion: releaseOf(anchorIndex)
|
|
16727
|
+
});
|
|
16728
|
+
}
|
|
16729
|
+
return out;
|
|
16730
|
+
}
|
|
16016
16731
|
|
|
16017
16732
|
// ../schema/src/emit.ts
|
|
16018
16733
|
var ENCODING = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
|
|
@@ -16197,6 +16912,12 @@ function diffNodeUpdate(current, patch) {
|
|
|
16197
16912
|
for (const platform of changedMapKeys(prevMeta[key], nextMeta[key])) {
|
|
16198
16913
|
changedPaths.push(`metadata.${key}.${platform}`);
|
|
16199
16914
|
}
|
|
16915
|
+
} else if (key === "decision_status") {
|
|
16916
|
+
const from = prevMeta[key] ?? "proposed";
|
|
16917
|
+
const to = nextMeta[key] ?? "proposed";
|
|
16918
|
+
if (!valueEqual(from, to)) {
|
|
16919
|
+
events.push({ type: "decision.status_changed", payload: { node_id: nodeId, from, to } });
|
|
16920
|
+
}
|
|
16200
16921
|
} else if (!valueEqual(prevMeta[key], nextMeta[key])) {
|
|
16201
16922
|
changedPaths.push(`metadata.${key}`);
|
|
16202
16923
|
}
|
|
@@ -16408,6 +17129,13 @@ function requireString(args, key) {
|
|
|
16408
17129
|
}
|
|
16409
17130
|
return value;
|
|
16410
17131
|
}
|
|
17132
|
+
function normalizeStatusArg(value) {
|
|
17133
|
+
const normalized = normalizeStatus(value);
|
|
17134
|
+
if (normalized === void 0) {
|
|
17135
|
+
throw new ToolError(`"${value}" is not a status (expected one of: ${STATUS_IDS.join(", ")}).`);
|
|
17136
|
+
}
|
|
17137
|
+
return normalized;
|
|
17138
|
+
}
|
|
16411
17139
|
function findNode(nodes, nodeId) {
|
|
16412
17140
|
const node = nodes.find((candidate) => candidate.id === nodeId);
|
|
16413
17141
|
if (!node) throw new ToolError(`No node with id "${nodeId}".`);
|
|
@@ -16494,10 +17222,11 @@ function buildCatalog(ctx) {
|
|
|
16494
17222
|
const { nodes, edges } = await load(ctx);
|
|
16495
17223
|
const query = typeof args.query === "string" ? args.query.toLowerCase() : void 0;
|
|
16496
17224
|
const limit = typeof args.limit === "number" && args.limit >= 1 ? Math.floor(args.limit) : 50;
|
|
17225
|
+
const status = typeof args.status === "string" ? normalizeStatusArg(args.status) : void 0;
|
|
16497
17226
|
const anchorCoveringIds = typeof args.anchor === "string" ? new Set(acceptancesCovering(args.anchor, nodes, edges).map((node) => node.id)) : void 0;
|
|
16498
17227
|
const matches = nodes.filter((node) => {
|
|
16499
17228
|
if (typeof args.species === "string" && node.species !== args.species) return false;
|
|
16500
|
-
if (
|
|
17229
|
+
if (status !== void 0 && node.status !== status) return false;
|
|
16501
17230
|
if (typeof args.platform === "string" && !node.platforms.includes(args.platform))
|
|
16502
17231
|
return false;
|
|
16503
17232
|
if (typeof args.value === "string" && (node.species !== "acceptance" || !(node.metadata?.values ?? []).includes(args.value))) return false;
|
|
@@ -16593,14 +17322,15 @@ ${node.description ?? ""}`.toLowerCase();
|
|
|
16593
17322
|
tool(
|
|
16594
17323
|
{
|
|
16595
17324
|
name: "list_maps",
|
|
16596
|
-
description: "Every map the project offers \u2014 built-ins plus stored definitions \u2014 with live subgraph sizes.",
|
|
17325
|
+
description: "Every map the project offers \u2014 built-ins plus stored definitions \u2014 with live subgraph sizes. A definition carrying a `product` is counted through that restriction, as the canvas draws it.",
|
|
16597
17326
|
inputSchema: { type: "object", properties: {}, additionalProperties: false }
|
|
16598
17327
|
},
|
|
16599
17328
|
async () => {
|
|
16600
17329
|
const { nodes, edges, project } = await load(ctx);
|
|
17330
|
+
const graph = buildProductGraph(nodes, edges);
|
|
16601
17331
|
return {
|
|
16602
17332
|
maps: listMaps(project).map((definition) => {
|
|
16603
|
-
const subgraph = computeMapSubgraph(definition, nodes, edges);
|
|
17333
|
+
const subgraph = computeMapSubgraph(definition, nodes, edges, { graph });
|
|
16604
17334
|
return { definition, nodeCount: subgraph.nodes.length, edgeCount: subgraph.edges.length };
|
|
16605
17335
|
})
|
|
16606
17336
|
};
|
|
@@ -16609,7 +17339,7 @@ ${node.description ?? ""}`.toLowerCase();
|
|
|
16609
17339
|
tool(
|
|
16610
17340
|
{
|
|
16611
17341
|
name: "get_map",
|
|
16612
|
-
description: "Resolve a map definition (built-in or stored) and return its computed subgraph.",
|
|
17342
|
+
description: "Resolve a map definition (built-in or stored) and return its computed subgraph. A definition carrying a `product` returns only that product's nodes \u2014 the same subgraph the canvas draws.",
|
|
16613
17343
|
inputSchema: {
|
|
16614
17344
|
type: "object",
|
|
16615
17345
|
properties: { map_id: { type: "string" } },
|
|
@@ -16670,7 +17400,7 @@ ${node.description ?? ""}`.toLowerCase();
|
|
|
16670
17400
|
project_id: graph.project.id,
|
|
16671
17401
|
title,
|
|
16672
17402
|
species,
|
|
16673
|
-
status: typeof args.status === "string" ? args.status : "idea",
|
|
17403
|
+
status: typeof args.status === "string" ? normalizeStatusArg(args.status) : "idea",
|
|
16674
17404
|
platforms,
|
|
16675
17405
|
...typeof args.description === "string" ? { description: args.description } : {},
|
|
16676
17406
|
...typeof args.metadata === "object" && args.metadata !== null ? { metadata: args.metadata } : {}
|
|
@@ -16721,6 +17451,7 @@ ${node.description ?? ""}`.toLowerCase();
|
|
|
16721
17451
|
throw new ToolError(`Field "${key}" cannot be patched (allowed: ${[...UPDATABLE_NODE_FIELDS].join(", ")}).`);
|
|
16722
17452
|
}
|
|
16723
17453
|
}
|
|
17454
|
+
if (typeof patch.status === "string") patch.status = normalizeStatusArg(patch.status);
|
|
16724
17455
|
const graph = await load(ctx);
|
|
16725
17456
|
const current = findNode(graph.nodes, nodeId);
|
|
16726
17457
|
const ops = [{ op: "update_node", node_id: nodeId, patch }];
|
|
@@ -16899,16 +17630,23 @@ function readBundle(filePath) {
|
|
|
16899
17630
|
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
16900
17631
|
throw new Error("Bundle must be a JSON object.");
|
|
16901
17632
|
}
|
|
16902
|
-
|
|
17633
|
+
const record2 = parsed;
|
|
17634
|
+
if (!Array.isArray(record2.nodes)) return record2;
|
|
17635
|
+
return migrateStatusVocabulary(record2);
|
|
16903
17636
|
}
|
|
16904
17637
|
|
|
16905
17638
|
// ../cli/src/lib/journal-io.ts
|
|
16906
|
-
import { appendFileSync, existsSync as existsSync2, mkdirSync, readFileSync as readFileSync2, writeFileSync } from "node:fs";
|
|
17639
|
+
import { appendFileSync, existsSync as existsSync2, mkdirSync, readdirSync, readFileSync as readFileSync2, writeFileSync } from "node:fs";
|
|
16907
17640
|
import { dirname, join } from "node:path";
|
|
16908
17641
|
var JOURNAL_SIDECAR = "journal.jsonl";
|
|
16909
17642
|
function journalPathFor(bundlePath) {
|
|
16910
17643
|
return join(dirname(bundlePath), JOURNAL_SIDECAR);
|
|
16911
17644
|
}
|
|
17645
|
+
function archivePathsFor(journalPath) {
|
|
17646
|
+
const dir = join(dirname(journalPath), "journal");
|
|
17647
|
+
if (!existsSync2(dir)) return [];
|
|
17648
|
+
return readdirSync(dir).filter((name) => name.startsWith("archive-") && name.endsWith(".jsonl")).sort().map((name) => join(dir, name));
|
|
17649
|
+
}
|
|
16912
17650
|
function toLine(event) {
|
|
16913
17651
|
return JSON.stringify(event) + "\n";
|
|
16914
17652
|
}
|
|
@@ -16926,8 +17664,7 @@ function appendJournalEvent(journalPath, event) {
|
|
|
16926
17664
|
|
|
16927
17665
|
// ../cli/src/lib/bundle-validate.ts
|
|
16928
17666
|
import { existsSync as existsSync3, readFileSync as readFileSync3 } from "node:fs";
|
|
16929
|
-
import {
|
|
16930
|
-
var JOURNAL_SIDECAR2 = "journal.jsonl";
|
|
17667
|
+
import { basename } from "node:path";
|
|
16931
17668
|
function validateBundleAt(filePath) {
|
|
16932
17669
|
const bundle = readBundle(filePath);
|
|
16933
17670
|
const loose = bundle;
|
|
@@ -16936,21 +17673,43 @@ function validateBundleAt(filePath) {
|
|
|
16936
17673
|
}
|
|
16937
17674
|
let sidecarFindings = [];
|
|
16938
17675
|
let sidecarLoaded = false;
|
|
17676
|
+
const archiveFindings = [];
|
|
17677
|
+
const archivesLoaded = [];
|
|
16939
17678
|
if (loose.journal === void 0) {
|
|
16940
|
-
const sidecarPath =
|
|
17679
|
+
const sidecarPath = journalPathFor(filePath);
|
|
17680
|
+
const folded = [];
|
|
16941
17681
|
if (existsSync3(sidecarPath)) {
|
|
16942
17682
|
const { events, findings } = parseJournalLines(readFileSync3(sidecarPath, "utf8"));
|
|
16943
17683
|
sidecarFindings = findings;
|
|
16944
17684
|
sidecarLoaded = true;
|
|
16945
|
-
|
|
17685
|
+
folded.push(...events);
|
|
17686
|
+
}
|
|
17687
|
+
for (const archivePath of archivePathsFor(sidecarPath)) {
|
|
17688
|
+
const { events, findings } = parseJournalLines(readFileSync3(archivePath, "utf8"));
|
|
17689
|
+
const file2 = basename(archivePath);
|
|
17690
|
+
for (const finding of findings) archiveFindings.push({ ...finding, file: file2 });
|
|
17691
|
+
archivesLoaded.push(file2);
|
|
17692
|
+
folded.push(...events);
|
|
16946
17693
|
}
|
|
17694
|
+
if (sidecarLoaded || archivesLoaded.length > 0) loose.journal = folded;
|
|
16947
17695
|
}
|
|
16948
17696
|
const nodes = Array.isArray(loose.nodes) ? loose.nodes : [];
|
|
16949
17697
|
const edges = Array.isArray(loose.edges) ? loose.edges : [];
|
|
16950
17698
|
const journal = Array.isArray(loose.journal) ? loose.journal : [];
|
|
16951
17699
|
const result = validateBundle(bundle);
|
|
16952
|
-
const valid = sidecarFindings.length === 0 && result.errors.length === 0;
|
|
16953
|
-
return {
|
|
17700
|
+
const valid = sidecarFindings.length === 0 && archiveFindings.length === 0 && result.errors.length === 0;
|
|
17701
|
+
return {
|
|
17702
|
+
bundle,
|
|
17703
|
+
nodes,
|
|
17704
|
+
edges,
|
|
17705
|
+
journal,
|
|
17706
|
+
sidecarLoaded,
|
|
17707
|
+
sidecarFindings,
|
|
17708
|
+
archivesLoaded,
|
|
17709
|
+
archiveFindings,
|
|
17710
|
+
result,
|
|
17711
|
+
valid
|
|
17712
|
+
};
|
|
16954
17713
|
}
|
|
16955
17714
|
|
|
16956
17715
|
// src/store.ts
|
|
@@ -16966,8 +17725,15 @@ function resolveBundlePath(argv2, env) {
|
|
|
16966
17725
|
function loadBundle(bundlePath) {
|
|
16967
17726
|
return validateBundleAt(bundlePath);
|
|
16968
17727
|
}
|
|
17728
|
+
function nodeIdsOf(nodes) {
|
|
17729
|
+
return nodes.map((node) => node?.id).filter((id) => typeof id === "string");
|
|
17730
|
+
}
|
|
16969
17731
|
function persistMutation(bundlePath, loaded, next, inputs) {
|
|
16970
|
-
const
|
|
17732
|
+
const baselineNodeIds = inputs.length === 0 ? [] : missingProvenanceNodeIds(nodeIdsOf(loaded.nodes), loaded.journal);
|
|
17733
|
+
const events = [
|
|
17734
|
+
...baselineNodeIds.length > 0 ? [makeEvent("journal.baseline", { node_ids: baselineNodeIds }, { actor: MCP_ACTOR })] : [],
|
|
17735
|
+
...toJournalEvents(inputs, MCP_ACTOR)
|
|
17736
|
+
];
|
|
16971
17737
|
const nextNodes = next.nodes ?? loaded.nodes;
|
|
16972
17738
|
const nextEdges = next.edges ?? loaded.edges;
|
|
16973
17739
|
const candidate = {
|
|
@@ -16980,7 +17746,8 @@ function persistMutation(bundlePath, loaded, next, inputs) {
|
|
|
16980
17746
|
if (result.errors.length > 0) {
|
|
16981
17747
|
return { ok: false, errors: result.errors, warnings: result.warnings };
|
|
16982
17748
|
}
|
|
16983
|
-
const
|
|
17749
|
+
const journalOnDisk = loaded.sidecarLoaded || loaded.archivesLoaded.length > 0;
|
|
17750
|
+
const embeddedJournal = !journalOnDisk && loaded.bundle.journal !== void 0;
|
|
16984
17751
|
if (embeddedJournal) {
|
|
16985
17752
|
writeFileSync2(bundlePath, serializeBundle(candidate));
|
|
16986
17753
|
} else {
|
|
@@ -17053,19 +17820,28 @@ function createRemoteStore(options) {
|
|
|
17053
17820
|
]);
|
|
17054
17821
|
const nodes = bundle.nodes ?? [];
|
|
17055
17822
|
const edges = bundle.edges ?? [];
|
|
17823
|
+
const folded = { ...bundle, journal };
|
|
17824
|
+
let validation;
|
|
17825
|
+
const validate = () => validation ??= validateBundle(folded);
|
|
17056
17826
|
return {
|
|
17057
|
-
// `loaded` mirrors the file store's BundleValidation shape closely
|
|
17058
|
-
// enough for the read tools, which only ever touch bundle/nodes/edges/
|
|
17059
|
-
// journal. The server has already validated everything it stores, so
|
|
17060
|
-
// there are no findings to carry here.
|
|
17061
17827
|
loaded: {
|
|
17062
|
-
bundle:
|
|
17828
|
+
bundle: folded,
|
|
17063
17829
|
nodes,
|
|
17064
17830
|
edges,
|
|
17065
17831
|
journal,
|
|
17066
17832
|
sidecarLoaded: false,
|
|
17067
|
-
|
|
17068
|
-
|
|
17833
|
+
// Nothing was folded in from a JSONL sidecar or a compaction archive,
|
|
17834
|
+
// so there are no line findings — hosted journals arrive already
|
|
17835
|
+
// parsed, and compaction is a repo-mode concern.
|
|
17836
|
+
sidecarFindings: [],
|
|
17837
|
+
archivesLoaded: [],
|
|
17838
|
+
archiveFindings: [],
|
|
17839
|
+
get result() {
|
|
17840
|
+
return validate();
|
|
17841
|
+
},
|
|
17842
|
+
get valid() {
|
|
17843
|
+
return validate().errors.length === 0;
|
|
17844
|
+
}
|
|
17069
17845
|
},
|
|
17070
17846
|
nodes,
|
|
17071
17847
|
edges,
|
|
@@ -17125,12 +17901,12 @@ function describeFailure(status, body) {
|
|
|
17125
17901
|
|
|
17126
17902
|
// src/config.ts
|
|
17127
17903
|
import { readFileSync as readFileSync4 } from "node:fs";
|
|
17128
|
-
import { join as
|
|
17904
|
+
import { join as join2 } from "node:path";
|
|
17129
17905
|
var LINK_FILE = "docs/arkaik/arkaik.json";
|
|
17130
17906
|
var DEFAULT_BASE_URL = "https://arkaik.app";
|
|
17131
17907
|
function readLinkFile(cwd) {
|
|
17132
17908
|
try {
|
|
17133
|
-
const parsed = JSON.parse(readFileSync4(
|
|
17909
|
+
const parsed = JSON.parse(readFileSync4(join2(cwd, LINK_FILE), "utf8"));
|
|
17134
17910
|
if (typeof parsed !== "object" || parsed === null) return null;
|
|
17135
17911
|
return parsed;
|
|
17136
17912
|
} catch {
|
|
@@ -17171,7 +17947,7 @@ function resolveRemoteConfig(argv2, env, cwd) {
|
|
|
17171
17947
|
}
|
|
17172
17948
|
|
|
17173
17949
|
// src/index.ts
|
|
17174
|
-
var VERSION = "0.2.
|
|
17950
|
+
var VERSION = "0.2.3";
|
|
17175
17951
|
var argv = process.argv.slice(2);
|
|
17176
17952
|
if (argv.includes("--help") || argv.includes("-h")) {
|
|
17177
17953
|
process.stdout.write(
|