@unified-product-graph/core 0.33.1 → 0.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1199,6 +1199,19 @@ var UPG_EDGE_CATALOG = {
1199
1199
  product_contains_research_study: { forward_verb: "contains", reverse_verb: "belongs_to", classification: "hierarchy", source_type: "product", target_type: "research_study" },
1200
1200
  research_study_enrolls_participant: { forward_verb: "enrolls", reverse_verb: "enrolled_in", classification: "hierarchy", source_type: "research_study", target_type: "participant" },
1201
1201
  research_study_captures_observation: { forward_verb: "captures", reverse_verb: "captured_in", classification: "hierarchy", source_type: "research_study", target_type: "observation" },
1202
+ // (0.35.0) Provenance for a verbatim quote: which study produced it. The
1203
+ // quote card wanted an outbound `quote_from_research_study`; canon answers it
1204
+ // study-first, matching the whole `research_study_*` family (enrolls ·
1205
+ // captures · clusters_into · produces · investigates · follows · collects),
1206
+ // so the quote renders it INBOUND on its connections rail. The `captures`
1207
+ // verb is deliberately reused from the observation twin above: the F3
1208
+ // duplicate gate is on the (source, target) pair, which is new, and a study
1209
+ // captures raw material by one verb regardless of which raw shape it is.
1210
+ // Companion: `UPG_VALID_CHILDREN.research_study` gains 'quote'. A quote may
1211
+ // now hang from observation (raw-capture parent), insight (synthesis parent)
1212
+ // or research_study (provenance parent) — multi-parent grammar is explicitly
1213
+ // sanctioned, and per-INSTANCE parentage stays single via `parent_id`.
1214
+ research_study_captures_quote: { forward_verb: "captures", reverse_verb: "captured_in", classification: "hierarchy", source_type: "research_study", target_type: "quote" },
1202
1215
  research_study_clusters_into_affinity_cluster: { forward_verb: "clusters_into", reverse_verb: "clustered_from", classification: "hierarchy", source_type: "research_study", target_type: "affinity_cluster" },
1203
1216
  research_study_produces_insight: { forward_verb: "produces", reverse_verb: "produced_by", classification: "hierarchy", source_type: "research_study", target_type: "insight" },
1204
1217
  research_study_investigates_research_question: { forward_verb: "investigates", reverse_verb: "investigated_by", classification: "hierarchy", source_type: "research_study", target_type: "research_question" },
@@ -1480,6 +1493,22 @@ var UPG_EDGE_CATALOG = {
1480
1493
  // the work into `task`; v0.7.0/UPG-571 re-canonicalised the statement
1481
1494
  // story_statement → user_story; see UPG_EDGE_MIGRATIONS['0.7.0'].)
1482
1495
  epic_specified_by_user_story: { forward_verb: "specified_by", reverse_verb: "specifies", classification: "hierarchy", source_type: "epic", target_type: "user_story" },
1496
+ // (0.35.0) The feature-level rung of the same ladder. `epic` is OPTIONAL in
1497
+ // UPG — `feature_decomposed_into_epic` is not mandatory — so a feature that
1498
+ // skips the epic level had no way to reach the stories that specify it, and
1499
+ // `user_story` had exactly one declared parent. Verb pair is cloned verbatim
1500
+ // from the epic rung above so the two rungs read identically; it is NOT
1501
+ // `groups`, which would invent a second verb for one relationship.
1502
+ //
1503
+ // This is also the reason `feature_contains_acceptance_criterion` is NOT
1504
+ // here: with this rung the path is feature → user_story → acceptance_
1505
+ // criterion, and a direct containment edge would be the "X_contains_Y verb
1506
+ // that duplicates the parent link" ARCHITECTURE.md forbids.
1507
+ //
1508
+ // Companion: `UPG_VALID_CHILDREN.feature` gains 'user_story'. Per-instance
1509
+ // parentage stays single (`parent_id`), so the dual declared parent is a
1510
+ // grammar widening, not a dual-parent instance.
1511
+ feature_specified_by_user_story: { forward_verb: "specified_by", reverse_verb: "specifies", classification: "hierarchy", source_type: "feature", target_type: "user_story" },
1483
1512
  user_story_verified_by_acceptance_criterion: { forward_verb: "verified_by", reverse_verb: "verifies", classification: "hierarchy", source_type: "user_story", target_type: "acceptance_criterion" },
1484
1513
  task_implements_user_story: { forward_verb: "implements", reverse_verb: "implemented_by", classification: "cross-domain", source_type: "task", target_type: "user_story" },
1485
1514
  feature_affected_by_bug: { forward_verb: "affected_by", reverse_verb: "affects", classification: "hierarchy", source_type: "feature", target_type: "bug" },
@@ -2397,6 +2426,51 @@ var UPG_EDGE_CATALOG = {
2397
2426
  // evidence co-reside), so NOT cross_product_eligible.
2398
2427
  document_contains_quote: { forward_verb: "contains", reverse_verb: "contained_in", classification: "semantic", source_type: "document", target_type: "quote" },
2399
2428
  document_contains_observation: { forward_verb: "contains", reverse_verb: "contained_in", classification: "semantic", source_type: "document", target_type: "observation" },
2429
+ /**
2430
+ * A document EMBEDS this node's live value at a position in its prose.
2431
+ *
2432
+ * @remarks
2433
+ * NOT `describes`. `document_describes_persona` says the document is ABOUT the
2434
+ * persona. Transclusion says the document RENDERS that node where the prose
2435
+ * sits, so the value a reader sees is the node's current value rather than a
2436
+ * copy taken when the sentence was written. A PRD that transcludes a metric is
2437
+ * not "about" the metric, and collapsing the two would lose the only property
2438
+ * transclusion is bought for: current by construction. The nine-member
2439
+ * `document_describes_*` family is untouched and keeps its meaning.
2440
+ *
2441
+ * POLYMORPHIC because the target set is genuinely open. Anything renderable can
2442
+ * be embedded, and the nine enumerated describe-targets are none of `metric`,
2443
+ * `research_study`, `specification` or `architecture_decision`, which is what
2444
+ * 65% of measured documents carrying zero outbound edges were reaching for.
2445
+ *
2446
+ * THE ANCHOR BINDING (normative). `@unified-product-graph/markdown` already
2447
+ * parses an inline reference form and records the source line of every
2448
+ * occurrence: `[[type:id]]`, `[[type:id|label]]`, `[[type:id|k:v|...]]`,
2449
+ * `[[+type:id]]` for creation, and `[[type:id@product]]` across products. The
2450
+ * grammar is published as Appendix F of the specification paper. The rule that
2451
+ * was missing, and is stated here: an anchor appearing in the body of a
2452
+ * `document` IS a transclusion anchor, and a conformant parser WRITES this edge
2453
+ * beside it. Anchor and edge are one fact recorded twice, so they must be
2454
+ * written together or they drift.
2455
+ *
2456
+ * NO POSITION PROPERTY, deliberately. The obvious `anchor_line` is the most
2457
+ * volatile value a text document has: every insertion above moves every anchor
2458
+ * below, so a stored line number is wrong after the next paragraph and nothing
2459
+ * reports the drift. The anchor IS the position, and it lives in the prose
2460
+ * where ordinary editing moves it for free. What the law asks is that the edge
2461
+ * be written BESIDE the anchor, which is a write-time discipline rather than a
2462
+ * stored field.
2463
+ *
2464
+ * `deliberate_only`, and the 0.33.0 trap is why that is safe here. Flagging a
2465
+ * widened edge `deliberate_only` silently switched five adapters off in the
2466
+ * last release, two of them under a green suite. The rule that came out of it:
2467
+ * an adapter reading an explicit field the SOURCE stores carries an authored
2468
+ * fact rather than an inferred one and must emit deliberate-only edges
2469
+ * EXPLICITLY. A `[[type:id]]` anchor is as explicit as a source gets, because a
2470
+ * person typed it, so the markdown emitter keys on the ANCHOR and never on the
2471
+ * `node` wildcard. No generic pair-resolution path may ever produce one.
2472
+ */
2473
+ document_transcludes_node: { forward_verb: "transcludes", reverse_verb: "transcluded_in", classification: "semantic", source_type: "document", target_type: "node", deliberate_only: true },
2400
2474
  // 5.3 Customer Education & Training Domain
2401
2475
  product_educates_via_education_program: { forward_verb: "educates_via", reverse_verb: "educates", classification: "hierarchy", source_type: "product", target_type: "education_program" },
2402
2476
  education_program_teaches_via_tutorial: { forward_verb: "teaches_via", reverse_verb: "teaches", classification: "hierarchy", source_type: "education_program", target_type: "tutorial" },
@@ -2462,10 +2536,10 @@ var UPG_EDGE_CATALOG = {
2462
2536
  // and G2b is not engaged.
2463
2537
  // Membership is UNQUALIFIED: no role property on the edge. `role` is already an
2464
2538
  // entity type with team_staffed_with_role, so a role string here would be a
2465
- // second role model beside a node type. The consequence is stated rather than
2466
- // hidden: the graph can say a team has a slot and that a person is on the team,
2467
- // and not that the person fills the slot. `person_holds_role` is banked, with
2468
- // its condition the first field graph carrying both where the join is asked for.
2539
+ // second role model beside a node type. The consequence that used to follow is
2540
+ // now closed rather than accepted: the graph can say a team has a slot, that a
2541
+ // person is on the team, AND that the person fills the slot, the last through
2542
+ // `person_holds_role` (0.34.0) rather than through a qualifier here.
2469
2543
  //
2470
2544
  // Neither is cross_product_eligible: `person` is not portfolio_shared, so the
2471
2545
  // 0.18.0 both-endpoints gate rejects the flag regardless of any team-scoping
@@ -2486,6 +2560,41 @@ var UPG_EDGE_CATALOG = {
2486
2560
  // the person / team / department triangle is decided once rather than three
2487
2561
  // times.
2488
2562
  person_reports_to_person: { forward_verb: "reports_to", reverse_verb: "has_report", classification: "semantic", source_type: "person", target_type: "person" },
2563
+ // MINTED 0.34.0 on a grammar-versus-catalog inconsistency readable entirely
2564
+ // inside this package, NOT on the field condition the 0.33.0 bank named. That
2565
+ // condition is still unmet and saying so is the honest framing: both org edges
2566
+ // exist in exactly one graph and it is the saturation fixture, whose person set
2567
+ // contains teams mistyped as people. What replaced it is stronger on its own
2568
+ // terms because it is checkable and adoption-independent:
2569
+ //
2570
+ // `role`'s lifecycle terminates at `filled` and `vacant`, and `filled` is
2571
+ // described "Role is staffed." `team_staffed_with_role` runs team -> slot.
2572
+ // `person_member_of_team` runs person -> team. NOTHING connected a person to
2573
+ // a role. So a graph could legally mark a role `filled` and no edge in the
2574
+ // catalog could say by whom.
2575
+ //
2576
+ // A terminal lifecycle phase that no edge can substantiate is dead schema, and
2577
+ // it is worse than a phantom edge name: a phantom is inert, while `filled` is a
2578
+ // value graphs will actually carry. Same class as the anti-pattern entry that
2579
+ // instructed users toward an edge the catalog refused, which is what minted
2580
+ // `person_reports_to_person` one release ago.
2581
+ //
2582
+ // `semantic`, not `cross-domain`. `person`, `role` and `team` are one domain
2583
+ // (domains.ts, team_org), and T1.7 forbids new same-domain cross-domain edges.
2584
+ // This is the third member of that triangle and it is decided on exactly the
2585
+ // ground the other two were decided on mid-build at 0.33.0.
2586
+ //
2587
+ // Direction is person -> role, matching both 0.33.0 person edges, so the
2588
+ // containment reading stays UNAVAILABLE rather than merely unchosen and
2589
+ // UPG_VALID_CHILDREN is untouched. `role_filled_by_person` would source the
2590
+ // edge on the slot, which reads as the slot owning the person.
2591
+ //
2592
+ // Unqualified, for the reason the membership edge above gives: `role` is a type,
2593
+ // not a string, so a qualifier here would be a second role model.
2594
+ //
2595
+ // Not cross_product_eligible: `person` is not portfolio_shared, so the 0.18.0
2596
+ // both-endpoints gate rejects the flag regardless.
2597
+ person_holds_role: { forward_verb: "holds", reverse_verb: "held_by", classification: "semantic", source_type: "person", target_type: "role" },
2489
2598
  team_staffed_with_role: { forward_verb: "staffed_with", reverse_verb: "staffed_in", classification: "hierarchy", source_type: "team", target_type: "role" },
2490
2599
  team_targets_team_okr: { forward_verb: "targets", reverse_verb: "targeted_by", classification: "hierarchy", source_type: "team", target_type: "team_okr" },
2491
2600
  team_reflects_in_retrospective: { forward_verb: "reflects_in", reverse_verb: "reflects", classification: "hierarchy", source_type: "team", target_type: "retrospective" },
@@ -2496,6 +2605,16 @@ var UPG_EDGE_CATALOG = {
2496
2605
  team_decides_decision: { forward_verb: "decides", reverse_verb: "decided_by", classification: "hierarchy", source_type: "team", target_type: "decision" },
2497
2606
  decision_references_decision: { forward_verb: "references", reverse_verb: "referenced_by", classification: "cross-domain", source_type: "decision", target_type: "decision" },
2498
2607
  stakeholder_maps_to_persona: { forward_verb: "maps_to", reverse_verb: "mapped_by", classification: "cross-domain", source_type: "stakeholder", target_type: "persona" },
2608
+ // (0.35.0) The stakeholder-map relation: who cares about which outcome.
2609
+ // Deliberately a verb-only edge and NOT a `kind: 'scale'` property on a
2610
+ // generic `stakeholder_relates_to_node` — UPG edges are payload-free outside
2611
+ // the gated `carries_properties` set, and the MAGNITUDE of the stake is
2612
+ // already `influence` / `interest` on the stakeholder itself. The reverse
2613
+ // reading is what makes the pair right: "outcome matters_to stakeholder".
2614
+ // Sits beside `persona_pursues_outcome` (the persona twin) and
2615
+ // `product_influenced_by_stakeholder`. Retires the manifest's denormalised
2616
+ // `stake_in` string: the subtitle renders the target outcome's title.
2617
+ stakeholder_invested_in_outcome: { forward_verb: "invested_in", reverse_verb: "matters_to", classification: "cross-domain", source_type: "stakeholder", target_type: "outcome" },
2499
2618
  team_okr_aligns_with_objective: { forward_verb: "aligns_with", reverse_verb: "aligned_by", classification: "cross-domain", source_type: "team_okr", target_type: "objective" },
2500
2619
  team_okr_aligns_with_key_result: { forward_verb: "aligns_with", reverse_verb: "aligned_by", classification: "cross-domain", source_type: "team_okr", target_type: "key_result" },
2501
2620
  ceremony_involves_team: { forward_verb: "involves", reverse_verb: "involved_in", classification: "cross-domain", source_type: "ceremony", target_type: "team" },
@@ -2574,6 +2693,27 @@ var UPG_EDGE_CATALOG = {
2574
2693
  compliance_requirement_constrains_feature: { forward_verb: "constrains", reverse_verb: "constrained_by", classification: "cross-domain", source_type: "compliance_requirement", target_type: "feature" },
2575
2694
  compliance_requirement_constrains_decision: { forward_verb: "constrains", reverse_verb: "constrained_by", classification: "cross-domain", source_type: "compliance_requirement", target_type: "decision" },
2576
2695
  risk_manifests_as_technical_debt_item: { forward_verb: "manifests_as", reverse_verb: "manifested_by", classification: "cross-domain", source_type: "risk", target_type: "technical_debt_item" },
2696
+ // ── Risk exposure (0.35.0) ──────────────────────────────────────────────────
2697
+ // Typed source, wildcard target: the 16th registered polymorphic family, and
2698
+ // structurally the "decision-to-anything" construction with `risk` in the
2699
+ // source slot. Both are `cross-domain`, so neither enters UPG_VALID_CHILDREN
2700
+ // and neither can be walked as containment.
2701
+ //
2702
+ // Why wildcard rather than typed-per-target: what a risk puts at stake is
2703
+ // genuinely unbounded (outcome, key_result, release, service, contract,
2704
+ // launch, metric, feature), and so is what mitigates it (decision, feature,
2705
+ // experiment, security_control, compliance_requirement). Enumerating either
2706
+ // side balloons the catalogue across two open sets while the endpoint carries
2707
+ // no structural role — the exact condition ARCHITECTURE.md admits polymorphism
2708
+ // for. The typed `security_control_mitigates_threat` stays as the
2709
+ // security-domain edge; `risk_mitigated_by_node` is the product generalisation.
2710
+ //
2711
+ // These two replace three manifest fields that were properties pretending to
2712
+ // be relations: `scope_entities` (an entity-reference list) is
2713
+ // risk_threatens_node, and `mitigation_actions` (a top-list of action
2714
+ // strings) is risk_mitigated_by_node. The prose `mitigation?: string` stays.
2715
+ risk_threatens_node: { forward_verb: "threatens", reverse_verb: "threatened_by", classification: "cross-domain", source_type: "risk", target_type: "node" },
2716
+ risk_mitigated_by_node: { forward_verb: "mitigated_by", reverse_verb: "mitigates", classification: "cross-domain", source_type: "risk", target_type: "node" },
2577
2717
  data_contract_governs_data_source: { forward_verb: "governs", reverse_verb: "governed_by", classification: "cross-domain", source_type: "data_contract", target_type: "data_source" },
2578
2718
  compliance_framework_requires_security_control: { forward_verb: "requires", reverse_verb: "required_by", classification: "cross-domain", source_type: "compliance_framework", target_type: "security_control" },
2579
2719
  security_audit_validates_compliance_framework: { forward_verb: "validates", reverse_verb: "validated_by", classification: "cross-domain", source_type: "security_audit", target_type: "compliance_framework" },
@@ -3856,8 +3996,63 @@ var UPG_POLYMORPHIC_EDGE_KEYS = [
3856
3996
  // Project membership (0.33.0, widened from project_delivers_epic):
3857
3997
  // endpoint-polymorphic over the work-item set {feature, epic, user_story, task,
3858
3998
  // bug}. Same construction and same reasoning as the cadence edge above.
3859
- "project_delivers_work_item"
3999
+ "project_delivers_work_item",
4000
+ // Document transclusion (0.34.0): a document embeds any renderable node's live
4001
+ // value at a position in its prose. Open by nature rather than by an
4002
+ // enumeration nobody wanted to write out.
4003
+ "document_transcludes_node",
4004
+ // Risk exposure (0.35.0): what a risk threatens, and what mitigates it.
4005
+ // Typed source, wildcard target — the decision-to-anything construction with
4006
+ // `risk` in the source slot. Both cross-domain, so containment is untouched.
4007
+ "risk_threatens_node",
4008
+ "risk_mitigated_by_node"
3860
4009
  ];
4010
+ var UPG_POLYMORPHIC_EDGE_FAMILIES = {
4011
+ "universal semantic verbs": ["node_informs_node", "node_constrains_node", "node_inspires_node"],
4012
+ "decision-to-anything": ["decision_influences_node", "decision_constrained_by_node", "decision_produces_node"],
4013
+ "universal ownership": [
4014
+ "node_owned_by_team",
4015
+ "node_owned_by_role",
4016
+ "node_owned_by_stakeholder",
4017
+ "node_owned_by_department",
4018
+ "node_owned_by_person"
4019
+ ],
4020
+ "universal architecture references": ["node_belongs_to_bounded_context"],
4021
+ "framework exercises": ["framework_exercise_includes_node"],
4022
+ "universal classification": ["node_classified_as_classification_value"],
4023
+ "work-item issue links": [
4024
+ "work_item_blocks_work_item",
4025
+ "work_item_relates_to_work_item",
4026
+ "work_item_duplicates_work_item"
4027
+ ],
4028
+ "workspace provenance": ["workspace_produced_node"],
4029
+ "canvas arrangement and published-view focus": ["workspace_arranges_node", "composition_focuses_node"],
4030
+ "benchmark subject": ["eval_benchmark_measures_node"],
4031
+ // 0.32.0. Assignment is its OWN family and deliberately not a member of
4032
+ // 'universal ownership': keeping them apart in this partition is the same
4033
+ // ruling the edge itself makes, so a future author who merges them here is
4034
+ // making that decision visibly rather than by tidying a list.
4035
+ "universal assignment": ["node_assigned_to_person"],
4036
+ "capture subject": ["capture_renders_node"],
4037
+ "cadence scheduling": ["planning_cycle_schedules_work_item"],
4038
+ // 0.33.0. Project membership is its own family and deliberately not a member
4039
+ // of 'cadence scheduling', even though both range over the same work-item set:
4040
+ // a cycle SCHEDULES work in time and a project REFERENCES the work it delivers,
4041
+ // and merging them here would quietly assert those are one relation.
4042
+ "project membership": ["project_delivers_work_item"],
4043
+ // 0.34.0. Its own family and deliberately not merged with the nine-member
4044
+ // `document_describes_*` set, which is not polymorphic at all: those are
4045
+ // enumerated edges saying a document is ABOUT a thing. Transclusion says it
4046
+ // RENDERS the thing, and the difference is the whole reason the edge exists.
4047
+ "document transclusion": ["document_transcludes_node"],
4048
+ // 0.35.0. Its own family and deliberately NOT merged into
4049
+ // 'decision-to-anything', which it mirrors structurally. The two say different
4050
+ // things: a decision INFLUENCES what it touches, a risk ENDANGERS what it
4051
+ // threatens, and a partition that merged them on shape alone would assert
4052
+ // those are one relation. Two members because exposure has two directions,
4053
+ // and collapsing them would lose which way an edge points.
4054
+ "risk exposure": ["risk_threatens_node", "risk_mitigated_by_node"]
4055
+ };
3861
4056
  var _POLY_KEY_SET = new Set(UPG_POLYMORPHIC_EDGE_KEYS);
3862
4057
  function isPolymorphicEdge(key) {
3863
4058
  const def = UPG_EDGE_CATALOG[key];
@@ -3875,1243 +4070,102 @@ function getEdgePropertySchema(type) {
3875
4070
  return def?.property_schema;
3876
4071
  }
3877
4072
 
3878
- // src/catalog/legacy-product-stages.ts
3879
- var LEGACY_PRODUCT_STAGES = Object.freeze({
3880
- idea: "concept"
3881
- });
3882
- function migrateProductStage(stage) {
3883
- if (stage === void 0 || stage === null) {
3884
- return void 0;
3885
- }
3886
- if (typeof stage !== "string") {
3887
- return stage;
3888
- }
3889
- const lower = stage.toLowerCase();
3890
- const mapped = LEGACY_PRODUCT_STAGES[lower];
3891
- return mapped ?? stage;
3892
- }
3893
- function isLegacyProductStage(stage) {
3894
- return typeof stage === "string" && stage.toLowerCase() in LEGACY_PRODUCT_STAGES;
3895
- }
3896
-
3897
- // src/shapes/base-node.ts
3898
- var BASE_NODE_FIELD_PRESENCE = {
3899
- id: true,
3900
- type: true,
3901
- title: true,
3902
- slug: true,
3903
- aliases: true,
3904
- key: true,
3905
- description: true,
3906
- tags: true,
3907
- status: true,
3908
- archived: true,
3909
- archived_at: true,
3910
- source_id: true,
3911
- source_type: true,
3912
- mapping_confidence: true,
3913
- external_tool: true,
3914
- external_ref: true,
3915
- external_id: true,
3916
- external_links: true,
3917
- created_at: true,
3918
- updated_at: true,
3919
- properties: true
3920
- };
3921
- var UPG_BASE_NODE_FIELDS = Object.freeze(
3922
- Object.keys(BASE_NODE_FIELD_PRESENCE)
3923
- );
3924
- var UPG_BASE_NODE_FIELD_SET = new Set(UPG_BASE_NODE_FIELDS);
3925
- var UPG_BASE_NODE_SPECIAL_MERGE_FIELDS = /* @__PURE__ */ new Set([
3926
- "id",
3927
- "type",
3928
- "slug",
3929
- "aliases",
3930
- "properties"
3931
- ]);
3932
-
3933
- // src/shapes/document.ts
3934
- var UPG_CROSS_ONLY_EDGE_TYPES = [
3935
- // Peer overlap: "these two products share / overlap on this thing." Symmetric,
3936
- // no canonical instance_of identity. shares_job / shares_need are the job/need
3937
- // siblings of the persona/competitor/metric peers (connective layer, 0.13.1).
3938
- "shares_persona",
3939
- "shares_competitor",
3940
- "shares_metric",
3941
- "shares_job",
3942
- "shares_need",
3943
- // Product-to-product relationships.
3944
- "depends_on_product",
3945
- // runtime dependency (built-on / dogfood), not containment
3946
- "cannibalises",
3947
- "succeeds",
3948
- "hosts",
3949
- // host runs the hosted product inside itself (container -> contained)
3950
- // OKR / measurement rollup primitives: the cascade ACROSS products (subordinate
3951
- // -> superior). `contributes_to` rolls a product strategy entity up to a higher-
3952
- // level one; `rolls_up_to` feeds a product metric into a higher-level north-star.
3953
- "contributes_to",
3954
- "rolls_up_to",
3955
- // Canonical instance + area-to-audience: the target lives in the portfolio
3956
- // `registry` section (`registry/{node_id}`). `instance_of` is same-type
3957
- // canonical-to-instance; the area edges are minted via `link_area_to_audience`.
3958
- "instance_of",
3959
- "area_serves_persona",
3960
- "area_targets_market_segment",
3961
- // Foundations (0.9.12): a product-graph entity links to a canonical specification
3962
- // or primitive in the registry (`registry/{node_id}` target, same shape as
3963
- // instance_of). Registry-internal spec-to-spec links are catalog edges, not these.
3964
- "product_implements_specification",
3965
- "product_exposes_specification",
3966
- "feature_conforms_to_specification",
3967
- "api_contract_speaks_specification",
3968
- "product_exposes_primitive",
3969
- "feature_manipulates_primitive",
3970
- "primitive_stored_as_data_type"
3971
- ];
3972
- var UPG_CROSS_EDGE_TYPES = [
3973
- ...UPG_CROSS_ONLY_EDGE_TYPES,
3974
- ...UPG_CROSS_ELIGIBLE_CATALOG_EDGE_TYPES
3975
- ];
3976
- var REGISTRY_PRODUCT_ID = "registry";
3977
- var UPG_PORTFOLIO_KINDS = ["owned", "watched", "strategic", "internal", "gtm"];
3978
-
3979
- // src/registry/entity-type-resolution.ts
3980
- var TYPES = getTypes();
3981
- var TYPES_SET = new Set(TYPES);
3982
- var UnknownEntityTypeError = class extends Error {
3983
- suggestions;
3984
- rawType;
3985
- constructor(rawType, suggestions) {
3986
- const suffix = suggestions.length > 0 ? ` Did you mean: ${suggestions.join(", ")}?` : "";
3987
- super(`Unknown entity type: "${rawType}".${suffix}`);
3988
- this.name = "UnknownEntityTypeError";
3989
- this.rawType = rawType;
3990
- this.suggestions = suggestions;
3991
- }
4073
+ // src/grammar/lifecycles.ts
4074
+ var PRODUCT_LIFECYCLE = {
4075
+ entity_type: "product",
4076
+ initial_phase: "concept",
4077
+ terminal_phases: ["sunset"],
4078
+ phases: [
4079
+ {
4080
+ id: "concept",
4081
+ status_category: "triage",
4082
+ label: "Concept",
4083
+ description: "Napkin idea. Problem shape and solution sketch, pre-validation.",
4084
+ transitions_to: ["validation", "build", "beta", "launch", "growth", "mature", "sunset"]
4085
+ },
4086
+ {
4087
+ id: "validation",
4088
+ status_category: "started",
4089
+ label: "Validation",
4090
+ description: "Testing demand. User conversations and experiments pressure-test assumptions before build commits.",
4091
+ transitions_to: ["build", "beta", "launch", "growth", "mature", "sunset"]
4092
+ },
4093
+ {
4094
+ id: "build",
4095
+ status_category: "started",
4096
+ label: "Build",
4097
+ description: "Actively developing v1. Core functionality is being authored, pre-user.",
4098
+ transitions_to: ["beta", "launch", "growth", "mature", "sunset"]
4099
+ },
4100
+ {
4101
+ id: "beta",
4102
+ status_category: "started",
4103
+ label: "Beta",
4104
+ description: "Early users, iterating. Feature-complete enough to learn from, still changing weekly.",
4105
+ transitions_to: ["launch", "growth", "mature", "maintenance", "sunset"]
4106
+ },
4107
+ {
4108
+ id: "launch",
4109
+ status_category: "started",
4110
+ label: "Launch",
4111
+ description: "Generally available. Announced to the target audience, open past beta access.",
4112
+ transitions_to: ["growth", "mature", "maintenance", "sunset"]
4113
+ },
4114
+ {
4115
+ id: "growth",
4116
+ status_category: "started",
4117
+ label: "Growth",
4118
+ description: "Scaling users and revenue. Product fit validated; focus is acquisition, retention, expansion.",
4119
+ transitions_to: ["mature", "maintenance", "sunset"]
4120
+ },
4121
+ {
4122
+ id: "mature",
4123
+ status_category: "started",
4124
+ label: "Mature",
4125
+ description: "Stable. Growth levelled; investment weights toward optimisation, efficiency, and durability.",
4126
+ transitions_to: ["maintenance", "sunset"]
4127
+ },
4128
+ {
4129
+ id: "maintenance",
4130
+ status_category: "started",
4131
+ label: "Maintenance",
4132
+ description: "Sustaining. Minimal investment keeps the product running for existing users. Can transition back to `mature` on a strategic revival.",
4133
+ transitions_to: ["mature", "sunset"]
4134
+ },
4135
+ {
4136
+ id: "sunset",
4137
+ status_category: "completed",
4138
+ label: "Sunset",
4139
+ description: "Winding down or retired. Existing users are being migrated or offboarded.",
4140
+ transitions_to: []
4141
+ }
4142
+ ]
3992
4143
  };
3993
- function withinEditDistance1(a, b) {
3994
- if (a === b) return true;
3995
- const al = a.length;
3996
- const bl = b.length;
3997
- if (Math.abs(al - bl) > 1) return false;
3998
- let i = 0;
3999
- let j = 0;
4000
- let edits = 0;
4001
- while (i < al && j < bl) {
4002
- if (a[i] !== b[j]) {
4003
- if (++edits > 1) return false;
4004
- if (al > bl) i++;
4005
- else if (bl > al) j++;
4006
- else {
4007
- i++;
4008
- j++;
4009
- }
4010
- } else {
4011
- i++;
4012
- j++;
4013
- }
4014
- }
4015
- if (i < al || j < bl) edits++;
4016
- return edits <= 1;
4017
- }
4018
- function resolveEntityType(rawType) {
4019
- if (typeof rawType !== "string" || rawType.length === 0) {
4020
- throw new UnknownEntityTypeError(String(rawType ?? ""), []);
4021
- }
4022
- if (TYPES_SET.has(rawType)) {
4023
- return { canonical: rawType };
4024
- }
4025
- const replacement = getReplacementType(rawType);
4026
- if (replacement && TYPES_SET.has(replacement)) {
4027
- return { canonical: replacement, alias: { from: rawType, to: replacement } };
4028
- }
4029
- const suggestions = [];
4030
- for (const t of TYPES) {
4031
- if (withinEditDistance1(t, rawType)) suggestions.push(t);
4032
- if (suggestions.length >= 5) break;
4033
- }
4034
- throw new UnknownEntityTypeError(rawType, suggestions);
4035
- }
4036
-
4037
- // src/grammar/hierarchy.ts
4038
- var UPG_VALID_CHILDREN = {
4039
- // ── Foundations (0.9.12): registry canonicals that self-nest. A
4040
- // specification extends a specification (a dialect of a parent spec); a
4041
- // primitive composes primitives (a block contains spans). These back the
4042
- // hierarchy-classified specification_extends_specification /
4043
- // primitive_composes_primitive catalog edges.
4044
- specification: ["specification"],
4045
- primitive: ["primitive"],
4046
- // An operating_lifecycle (e.g. the content-ops lifecycle) contains its ordered
4047
- // operating_stage children. Backs the operating_lifecycle_contains_operating_stage edge.
4048
- operating_lifecycle: ["operating_stage"],
4049
- // ── Product (root) ─────────────────────────────────────────────────────────
4050
- product: [
4051
- // Strategy
4052
- "vision",
4053
- "outcome",
4054
- "objective",
4055
- "metric",
4056
- "decision",
4057
- "constraint",
4058
- // User
4059
- "persona",
4060
- // Discovery (via outcome children)
4061
- // Validation (via hypothesis children)
4062
- // Market Intelligence
4063
- "competitor",
4064
- "market_trend",
4065
- "market_segment",
4066
- "competitive_analysis",
4067
- // User Research
4068
- "research_study",
4069
- // Experience Design
4070
- "user_journey",
4071
- "user_flow",
4072
- "wireframe",
4073
- "screen",
4074
- // Design System
4075
- "design_system",
4076
- "design_component",
4077
- // Brand Identity
4078
- "brand_identity",
4079
- // Product Specification
4080
- "feature",
4081
- "feature_area",
4082
- "release",
4083
- "roadmap",
4084
- "roadmap_theme",
4085
- "planning_cycle",
4086
- // Configuration (0.30.0): the levers whose values select which surface tree
4087
- // the product renders. Few per product, and top-level because an axis is a
4088
- // product-wide fact rather than a child of any one feature or surface.
4089
- "configuration_axis",
4090
- // Classification (0.32.0): the product's own taxonomies — the grouped-label
4091
- // case, one named group over a set of values. Same reasoning as the
4092
- // configuration axis above, and until now the only parent a
4093
- // classification_axis could have was a competitive_analysis.
4094
- "classification_axis",
4095
- // Engineering
4096
- "bounded_context",
4097
- "code_repository",
4098
- "integration_pattern",
4099
- "external_api",
4100
- "data_flow",
4101
- // Growth
4102
- "funnel",
4103
- "acquisition_channel",
4104
- "cohort",
4105
- "behavioral_segment",
4106
- "growth_loop",
4107
- "attribution_model",
4108
- // Business Model
4109
- "business_model",
4110
- // Go-To-Market
4111
- "gtm_strategy",
4112
- // Team & Organisation
4113
- // `person` is containment-free (see UPG_CONTAINMENT_FREE_TYPES below)
4114
- // (referenced via edges, not nested under product)
4115
- "team",
4116
- "stakeholder",
4117
- "department",
4118
- // Data & Analytics
4119
- "data_source",
4120
- "event_schema",
4121
- "dashboard",
4122
- "data_domain",
4123
- "glossary_term",
4124
- // Content & Knowledge
4125
- "content_piece",
4126
- "knowledge_base_article",
4127
- "brand_asset",
4128
- "document",
4129
- "documentation_template",
4130
- // Legal
4131
- "legal_entity",
4132
- "privacy_policy",
4133
- // Compliance
4134
- "compliance_requirement",
4135
- "risk",
4136
- "data_contract",
4137
- "audit_log_policy",
4138
- "compliance_framework",
4139
- // DevOps & Platform
4140
- "service_level_objective",
4141
- "incident",
4142
- "runbook",
4143
- "monitor",
4144
- "ci_pipeline",
4145
- "release_strategy",
4146
- "on_call_rotation",
4147
- "infrastructure_component",
4148
- // Security
4149
- "threat_model",
4150
- "security_control",
4151
- "security_policy",
4152
- "penetration_test",
4153
- "security_review",
4154
- "data_classification",
4155
- "access_policy",
4156
- // Accessibility
4157
- "a11y_standard",
4158
- "a11y_audit",
4159
- "a11y_annotation",
4160
- // Quality Assurance
4161
- "test_plan",
4162
- "test_suite",
4163
- "qa_session",
4164
- "test_coverage_report",
4165
- "test_environment",
4166
- // Customer Feedback
4167
- "feedback_program",
4168
- "user_advisory_board",
4169
- "beta_program",
4170
- // Pricing & Packaging
4171
- "pricing_strategy",
4172
- // AI & Machine Learning
4173
- "ai_model",
4174
- "model_comparison",
4175
- // Workflows & Agents
4176
- "workflow_template",
4177
- "agent_definition",
4178
- // Sales & Revenue
4179
- "pipeline_sales",
4180
- "account",
4181
- "lead",
4182
- "subscription",
4183
- "forecast",
4184
- // Program Management
4185
- // `milestone` is a SECOND, shallower parent here (Portfolio Phase 2,
4186
- // 2026-08-14), alongside its existing `project` parent: a product can own a
4187
- // milestone outright with no program/project above it. Required by the
4188
- // hierarchy-orphan guard now that `product_targets_milestone` exists.
4189
- "program",
4190
- "milestone",
4191
- // Marketing
4192
- "marketing_strategy",
4193
- "press_release",
4194
- "event",
4195
- "community_initiative",
4196
- // Customer Success
4197
- "support_ticket",
4198
- "customer_feedback",
4199
- "churn_reason",
4200
- "customer_health_score",
4201
- "playbook",
4202
- "service_level_agreement",
4203
- "success_milestone",
4204
- "service_blueprint",
4205
- "nps_campaign",
4206
- // Localisation
4207
- "locale",
4208
- "locale_config",
4209
- // Customer Education
4210
- "education_program",
4211
- // Partners & Ecosystem
4212
- "partner_program",
4213
- "api_ecosystem",
4214
- "developer_portal",
4215
- // Portfolio
4216
- // (UPG-677) product no longer lists product_area as a child: the
4217
- // product↔product_area containment is the single direction
4218
- // product_area_contains_product (product_area → product). The inverse
4219
- // product_categorised_in_product_area edge was collapsed.
4220
- // Workspace
4221
- "workspace"
4222
- ],
4223
- // ── Metric & Outcome hierarchy ──────────────────────────────────────────────
4224
- outcome: ["metric", "opportunity", "feature"],
4225
- // ── User & Jobs hierarchy ───────────────────────────────────────────────────
4226
- persona: ["job", "need", "switching_cost", "desired_outcome"],
4227
- job: ["need", "desired_outcome", "job_step"],
4228
- // ── Discovery hierarchy ─────────────────────────────────────────────────────
4229
- opportunity: ["solution", "design_concept", "feasibility_study", "design_sprint"],
4230
- // solutions now propose hypothesis (the templated
4231
- // belief), not the legacy hypothesis type.
4232
- solution: ["hypothesis", "prototype", "metric"],
4233
- // ── Validation hierarchy ────────────────────────────────────────────────────
4234
- // (UPG-664) The validation chain is a single-parent line:
4235
- // hypothesis ▷ experiment_plan ▷ experiment ▷ experiment_run.
4236
- // hypothesis is canonical (hypothesis_evidence collapsed into evidence;
4237
- // relationship expressed via hypothesis_has_evidence edge; evidence.direction
4238
- // carries supports/refutes/neutral semantics). `test_plan` re-homed to the
4239
- // QA/testing domain (UPG-678), so it is no longer a hypothesis child.
4240
- hypothesis: ["experiment_plan", "research_plan", "evidence"],
4241
- // experiment_plan is the canonical validation PLAN (graduated stable,
4242
- // UPG-664). It designs the experiment it produces; the plan owns the
4243
- // experiment in the containment line. It also retains experiment_run as a
4244
- // child for the v0.2.6 split-migration path
4245
- // (`experiment_plan_ran_as_experiment_run`), where a legacy experiment routes
4246
- // directly to a plan + run pair.
4247
- experiment_plan: ["experiment", "experiment_run"],
4248
- // experiment is the canonical structured test. It owns its run(s) and the
4249
- // learning/evidence it produces. The optional experiment_run child captures
4250
- // the multi-run / replication case.
4251
- experiment: ["experiment_run", "learning", "evidence"],
4252
- // experiment_run carries learning/evidence/metric children (run produces
4253
- // evidence) and self-nests for replications/multi-armed runs (V9: this is
4254
- // where self-nesting genuinely lives, not on `experiment`).
4255
- experiment_run: ["learning", "evidence", "metric", "experiment_run"],
4256
- // ── OKR hierarchy ──────────────────────────────────────────────────────────
4257
- // strategic_question (0.17.4): an open coordination question raised under an
4258
- // objective (objective_raises_strategic_question, hierarchy).
4259
- objective: ["key_result", "metric", "strategic_question"],
4260
- key_result: ["metric"],
4261
- // ── Strategic cascade: vision → mission → strategic_pillar → strategic_theme →
4262
- // { initiative, objective } ───────────────────────────────────────────────
4263
- //
4264
- // strategic_pillar vs strategic_theme (UPG-692 T3.3 — distinct cascade levels,
4265
- // NOT duplicates; sharpened rather than merged):
4266
- // - strategic_pillar = a DURABLE structural division of the strategy. A
4267
- // standing area the org organises around for years (e.g. "Structured
4268
- // content", "Developer experience"). Few, long-lived; time_horizon is
4269
- // multi-year / open-ended; carries its own `success_indicator`.
4270
- // - strategic_theme = a TIME-BOUND thrust WITHIN a pillar. The current bet
4271
- // for a period (e.g. "Go AI-native this year"). More numerous, rotates;
4272
- // time_horizon is bounded (Q / FY); has NO `success_indicator` because it
4273
- // is measured through its child objectives (strategic_theme_contains_objective).
4274
- // That success-measurement asymmetry is the load-bearing distinction.
4275
- vision: ["mission"],
4276
- mission: ["strategic_pillar"],
4277
- // 0.20.1: metric added as a strategic_pillar child, backing
4278
- // strategic_pillar_measured_by_metric (hierarchy) — the pillar's own
4279
- // north-star, mirrored from objective: ['key_result', 'metric', ...] one
4280
- // level down the cascade.
4281
- strategic_pillar: ["strategic_theme", "capability", "value_stream", "decision", "metric"],
4282
- // v0.5.4 (UPG-511): objectives are the specific quarterly bets *within* a
4283
- // strategic theme. The theme is the multi-quarter focus area; objectives are
4284
- // subordinate. Pairs with `strategic_theme_contains_objective` in the edge
4285
- // catalog (hierarchy, strategic_theme → objective, reverse_verb: rolls_up_to;
4286
- // renamed from objective_rolls_up_to_strategic_theme in UPG-676).
4287
- strategic_theme: ["initiative", "objective"],
4288
- initiative: ["assumption", "strategic_question"],
4289
- // v0.5.2 (UPG-528): capability decomposes into sub-capabilities (Wardley
4290
- // value-chain spine) and is realised by user-facing features. Pairs with
4291
- // `capability_depends_on_capability` and `capability_implemented_by_feature`
4292
- // in the edge catalogue. The self-loop guard (UPG-520) keeps A → A refused;
4293
- // A → B between distinct capabilities is the supported decomposition.
4294
- capability: ["capability", "feature"],
4295
- // ── Market hierarchy ────────────────────────────────────────────────────────
4296
- // competitive_analysis hosts classification axes (its dimensions);
4297
- // each axis hosts its values; values are reusable across the row and column
4298
- // dossiers of a 2-axis matrix.
4299
- competitive_analysis: ["competitor", "market_trend", "market_segment", "classification_axis"],
4300
- competitor: ["competitor_feature", "competitor_signal"],
4301
- classification_axis: ["classification_value"],
4302
- // ── UX Research hierarchy ───────────────────────────────────────────────────
4303
- research_study: [
4304
- "participant",
4305
- "observation",
4306
- "affinity_cluster",
4307
- "research_question",
4308
- "interview_guide",
4309
- "insight",
4310
- "survey_response"
4311
- ],
4312
- observation: ["quote"],
4313
- // F6 (UPG-672): affinity_cluster owns the observations it groups, in addition
4314
- // to the insights it synthesises. Pairs with `affinity_cluster_groups_observation`
4315
- // in the edge catalog (hierarchy). An observation can be both directly owned by
4316
- // its research_study and grouped under an affinity_cluster (multi-parent grammar).
4317
- affinity_cluster: ["insight", "observation"],
4318
- // insight refines into insight; a raw insight can be distilled
4319
- // into a more specific insight (refines_into chain).
4320
- // v0.5.8 (UPG-528 Part 2d): insights own their evidencing quotes;
4321
- // parallel to `observation: ['quote']`. Research-synthesis canon.
4322
- // Pairs with `insight_evidenced_by_quote` in the edge catalog.
4323
- // ── Design hierarchy ────────────────────────────────────────────────────────
4324
- // (UPG-663, v0.9.2) A user_journey owns its steps (the stable 0.1.0 spine)
4325
- // and carries phases as a non-owning band overlay. A journey_phase is NO
4326
- // LONGER a containment parent of journey_step: it SPANS steps via the
4327
- // `journey_phase_spans_journey_step` edge (mirroring the marketing
4328
- // `customer_journey_stage_spans_journey_step` precedent), so each step has
4329
- // exactly one containment parent and the journey has one canonical step list.
4330
- user_journey: ["journey_step", "journey_phase"],
4331
- journey_step: ["journey_action"],
4332
- // v0.5.8 (UPG-528 Part 2d): insights own their evidencing quotes;
4333
- // parallel to `observation: ['quote']`. Research-synthesis canon
4334
- // (insight ← quote evidencing) extends quote's hierarchy parents to
4335
- // both observation (raw-capture parent) and insight (synthesis parent).
4336
- // Pairs with `insight_evidenced_by_quote` in the edge catalog.
4337
- insight: ["design_question", "insight", "quote"],
4338
- // v0.5.2 (UPG-528): need anchors a Wardley value chain; capabilities
4339
- // fulfil the need at the chain top. Cross-domain hierarchy (need ∈ Design,
4340
- // capability ∈ Strategy) is intentional: Wardley analysis starts from a
4341
- // user need and decomposes into the capabilities required to fulfil it.
4342
- need: ["design_question", "capability"],
4343
- design_question: ["design_concept"],
4344
- design_concept: ["prototype", "wireframe"],
4345
- design_component: [
4346
- "design_token",
4347
- "design_pattern",
4348
- "design_guideline",
4349
- "interaction_spec",
4350
- "design_component"
4351
- ],
4352
- // self-nesting for atomic hierarchy (organism → molecule → atom)
4353
- prototype: ["annotation"],
4354
- // ── Brand hierarchy ─────────────────────────────────────────────────────────
4355
- brand_identity: [
4356
- "brand_colour",
4357
- "brand_typography",
4358
- "brand_asset",
4359
- "brand_voice",
4360
- "brand_logo",
4361
- "brand_imagery"
4362
- ],
4363
- // ── Product Specification hierarchy ─────────────────────────────────────────
4364
- // story_task collapsed into canonical task. feature now owns
4365
- // task directly; story-derived tasks implement user_story via
4366
- // task_implements_user_story edge.
4367
- feature: ["epic", "bug", "task"],
4368
- feature_area: ["feature", "feature_area"],
4369
- // epic owns user_story (the templated promise) and, mirroring feature, may
4370
- // also directly contain bug/task — heterogeneous imported tickets that belong
4371
- // to one epic rather than the feature as a whole (feedback df99026a).
4372
- epic: ["user_story", "bug", "task"],
4373
- user_story: ["acceptance_criterion"],
4374
- task: ["task"],
4375
- // planning_cycle (0.20.0): the cadence axis self-nests (a program-increment
4376
- // contains iterations; a cycle contains its cooldown) via
4377
- // planning_cycle_contains_planning_cycle. It does NOT contain user_story as a
4378
- // child: scheduling work into a cycle is the semantic, deliberate-only
4379
- // planning_cycle_schedules_work_item edge, so the item keeps its feature/epic
4380
- // containment parent and is merely referenced by the cycle.
4381
- planning_cycle: ["planning_cycle"],
4382
- // ── Engineering hierarchy ───────────────────────────────────────────────────
4383
- bounded_context: [
4384
- "service",
4385
- "domain_event",
4386
- "decision",
4387
- "data_model",
4388
- "aggregate",
4389
- "read_model",
4390
- "code_repository",
4391
- "integration_pattern",
4392
- "external_api",
4393
- "data_flow",
4394
- // v0.5.7 (UPG-528 Part 2c): BCs publish api_contracts as their "published
4395
- // language" (DDD canon). api_contract has two valid hierarchy parents now:
4396
- // service (per-service exposure) AND bounded_context (BC-level surface).
4397
- "api_contract"
4398
- ],
4399
- service: [
4400
- "api_contract",
4401
- "technical_debt_item",
4402
- "feature_flag",
4403
- "deployment",
4404
- "api_endpoint",
4405
- "database_schema",
4406
- "queue_topic",
4407
- "build_artifact",
4408
- "library_dependency"
4409
- ],
4410
- // v0.5.1 (UPG-517 C2): contracts contain their endpoints. Service still
4411
- // serves endpoints directly (legacy / non-contract endpoints); both
4412
- // parent-child paths coexist.
4413
- api_contract: ["api_endpoint"],
4414
- decision: ["technical_debt_item"],
4415
- aggregate: ["domain_entity", "value_object", "command"],
4416
- // ── Growth hierarchy ────────────────────────────────────────────────────────
4417
- funnel: ["funnel_step"],
4418
- acquisition_channel: ["growth_campaign"],
4419
- growth_campaign: ["experiment_plan", "variant"],
4420
- // ── Business Model hierarchy ─────────────────────────────────────────────────
4421
- business_model: [
4422
- "value_proposition",
4423
- "revenue_stream",
4424
- "cost_structure",
4425
- "unit_economics",
4426
- "partnership",
4427
- "key_resource",
4428
- "key_activity",
4429
- "customer_relationship",
4430
- "distribution_channel"
4431
- ],
4432
- revenue_stream: ["pricing_tier"],
4433
- // ── Go-To-Market hierarchy ───────────────────────────────────────────────────
4434
- gtm_strategy: [
4435
- "ideal_customer_profile",
4436
- "positioning",
4437
- "launch",
4438
- "content_strategy",
4439
- "sales_motion",
4440
- "competitive_battle_card",
4441
- "demand_gen_program",
4442
- "territory"
4443
- ],
4444
- positioning: ["messaging", "objection", "proof_point"],
4445
- value_proposition: ["objection", "proof_point"],
4446
- competitive_battle_card: ["objection"],
4447
- objection: ["rebuttal"],
4448
- rebuttal: ["proof_point"],
4449
- // ── Team & Organisation hierarchy ───────────────────────────────────────────
4450
- department: ["team", "stakeholder"],
4451
- team: [
4452
- "role",
4453
- "team_okr",
4454
- "retrospective",
4455
- "dependency",
4456
- "skill",
4457
- "ceremony",
4458
- "capacity_plan",
4459
- "decision",
4460
- // Self-nesting (0.17.2): a parent team contains its sub-teams / squads, one
4461
- // level below department_contains_team. Backs team_contains_team. Mirrors
4462
- // feature_area_contains_feature_area (same-type child listed last).
4463
- "team"
4464
- ],
4465
- // ── Data & Analytics hierarchy ───────────────────────────────────────────────
4466
- data_source: ["metric", "data_pipeline", "data_lineage", "event_schema"],
4467
- // UPG-685 T0.4 (0.13.0 Wave 1): `outcome` removed as a metric child. It closed a
4468
- // containment cycle (outcome ⊃ metric ⊃ outcome) and was backed only by the CAUSAL
4469
- // `metric_drives_outcome` edge, not a hierarchy edge — the "metric leads to outcome"
4470
- // meaning lives correctly on that causal edge. The real containment (outcome ⊃ metric)
4471
- // is kept. Sub-metric trees (metric ⊃ metric) stay.
4472
- metric: ["metric", "data_quality_rule", "metric_quality_assessment"],
4473
- data_domain: ["data_product", "data_source", "glossary_term", "data_model", "dashboard"],
4474
- dashboard: ["report", "experiment_run"],
4475
- // ── Content & Knowledge hierarchy ────────────────────────────────────────────
4476
- // release contains features and bugs (GitHub milestone→issue import).
4477
- release: ["changelog", "feature", "bug"],
4478
- content_strategy: ["content_calendar", "content_theme"],
4479
- content_calendar: [
4480
- "content_theme",
4481
- "content_piece",
4482
- "knowledge_base_article",
4483
- "brand_asset",
4484
- "document",
4485
- "documentation_template"
4486
- ],
4487
- // ── Operations & CS hierarchy ────────────────────────────────────────────────
4488
- service_blueprint: [
4489
- "user_flow",
4490
- "playbook",
4491
- "service_level_agreement",
4492
- "customer_health_score",
4493
- "support_ticket",
4494
- "customer_feedback"
4495
- ],
4496
- customer_health_score: ["nps_campaign", "success_milestone"],
4497
- customer_feedback: ["churn_reason"],
4498
- user_flow: ["screen", "customer_journey_stage"],
4499
- customer_journey_stage: ["touchpoint"],
4500
- // ── Legal, Compliance & Risk hierarchy ──────────────────────────────────────
4501
- legal_entity: ["ip_asset", "contract"],
4502
- contract: ["contract_clause"],
4503
- compliance_framework: [
4504
- "security_audit",
4505
- "compliance_requirement",
4506
- "privacy_policy",
4507
- "audit_log_policy",
4508
- "risk",
4509
- "data_contract",
4510
- "legal_entity"
4511
- ],
4512
- // ── DevOps & Platform hierarchy ──────────────────────────────────────────────
4513
- infrastructure_component: [
4514
- "service_level_objective",
4515
- "monitor",
4516
- "ci_pipeline",
4517
- "incident",
4518
- "runbook",
4519
- "release_strategy",
4520
- "on_call_rotation"
4521
- ],
4522
- service_level_objective: ["service_level_indicator", "error_budget"],
4523
- incident: ["postmortem"],
4524
- monitor: ["alert_rule"],
4525
- ci_pipeline: ["build_artifact"],
4526
- // ── Security hierarchy ───────────────────────────────────────────────────────
4527
- security_policy: [
4528
- "security_control",
4529
- "access_policy",
4530
- "data_classification",
4531
- "threat_model",
4532
- "security_review",
4533
- "incident"
4534
- ],
4535
- security_review: ["penetration_test"],
4536
- threat_model: ["threat", "vulnerability"],
4537
- // ── Sales & Revenue hierarchy ────────────────────────────────────────────────
4538
- pipeline_sales: ["pipeline_stage", "lead", "account", "forecast", "subscription"],
4539
- account: ["contact", "deal"],
4540
- deal: ["quote_document"],
4541
- subscription: ["invoice"],
4542
- // ── Program Management hierarchy ─────────────────────────────────────────────
4543
- program: ["project", "risk_register", "change_request", "resource_allocation", "status_report"],
4544
- project: ["milestone", "deliverable"],
4545
- risk_register: ["risk"],
4546
- // ── Accessibility hierarchy ──────────────────────────────────────────────────
4547
- a11y_standard: ["a11y_guideline", "a11y_audit", "a11y_annotation"],
4548
- a11y_audit: ["a11y_issue"],
4549
- // ── Product Specification expansion ─────────────────────────────────────────
4550
- roadmap: ["roadmap_item", "roadmap_theme", "release"],
4551
- roadmap_theme: ["feature"],
4552
- // ── Unified Context Layer hierarchy ─────────────────────────────────────────
4553
- design_system: [
4554
- "design_component",
4555
- "design_token",
4556
- "design_guideline",
4557
- "brand_identity",
4558
- "user_journey",
4559
- "user_flow",
4560
- "insight"
4561
- ],
4562
- screen: ["screen_state", "screen", "surface", "design_component", "wireframe"],
4563
- // self-nesting + surfaces + components + wireframes
4564
- // surface (0.27.0): the place inside a screen. Self-nests, so a shell holds
4565
- // panes, a pane holds regions, a region holds slots. A surface is reached
4566
- // through the screen that renders it (`screen: [... 'surface']`), never as a
4567
- // top-level product child: every UPG_VALID_CHILDREN pair must be backed by a
4568
- // hierarchy-classified edge (guardrail G2b), and the ratified ten do not
4569
- // include a product-to-surface verb. An app-shell surface therefore hangs off
4570
- // the screen that mounts it.
4571
- //
4572
- // NOTE: `surface_kind` narrows this further than UPG_VALID_CHILDREN can
4573
- // express. UPG_VALID_CHILDREN is keyed on entity TYPE, so it can only say
4574
- // "a surface may contain a surface"; the kind ordering (shell > tool > pane >
4575
- // region > slot / gutter / action_bar, with overlay and ambient parented by
4576
- // whatever raises them) is a property-level rule documented on `SurfaceKind`
4577
- // and enforced by validators, not by this table. Precedent: the same split
4578
- // applies to `planning_cycle`, whose `cadence_kind` narrows its self-nesting.
4579
- surface: ["surface", "design_component"],
4580
- // ── Marketing & Communications hierarchy ────────────────────────────────────
4581
- marketing_strategy: [
4582
- "marketing_channel",
4583
- "seo_keyword",
4584
- "press_release",
4585
- "event",
4586
- "community_initiative"
4587
- ],
4588
- marketing_channel: ["marketing_campaign_plan"],
4589
- marketing_campaign_plan: ["email_sequence", "social_post", "ad_creative"],
4590
- // ── Localisation & i18n hierarchy ───────────────────────────────────────────
4591
- locale: ["translation_bundle", "cultural_adaptation", "regional_pricing", "locale_config"],
4592
- translation_bundle: ["translation_key"],
4593
- // ── Customer Education & Training hierarchy ──────────────────────────────────
4594
- education_program: [
4595
- "tutorial",
4596
- "walkthrough",
4597
- "webinar",
4598
- "certification",
4599
- "help_video",
4600
- "learning_path"
4601
- ],
4602
- // a learning_path can include its terminal certification.
4603
- learning_path: ["tutorial", "certification"],
4604
- // ── Quality Assurance & Testing hierarchy ────────────────────────────────────
4605
- // (UPG-678) test_plan re-homed validation → QA. It is the QA planning layer:
4606
- // the verification approach (scope, environments, pass criteria) that the
4607
- // test suites execute. A test_plan groups the suites that carry it out.
4608
- test_plan: ["test_suite", "test_environment"],
4609
- test_suite: [
4610
- "test_case",
4611
- "regression_test",
4612
- "qa_session",
4613
- "test_coverage_report",
4614
- "test_environment",
4615
- "test_result"
4616
- ],
4617
- test_case: ["test_result"],
4618
- qa_session: ["bug"],
4619
- // ── Partner & Ecosystem Management hierarchy ─────────────────────────────────
4620
- partner_program: [
4621
- "partner_tier",
4622
- "integration_partner",
4623
- "partner_revenue_share",
4624
- "api_ecosystem",
4625
- "developer_portal"
4626
- ],
4627
- api_ecosystem: ["marketplace_listing"],
4628
- // ── Feedback & Voice of Customer hierarchy ───────────────────────────────────
4629
- feedback_program: [
4630
- "feature_request",
4631
- "nps_campaign",
4632
- "feedback_theme",
4633
- "user_advisory_board",
4634
- "beta_program"
4635
- ],
4636
- feature_request: ["feedback_vote"],
4637
- // v0.5.8 (UPG-528 Part 2d): CABs convene as quarterly ceremonies;
4638
- // CAB owns its meeting cadence (Stettler, Moore CAB playbook canon).
4639
- // Pairs with `user_advisory_board_convenes_as_ceremony` in the edge
4640
- // catalog. ceremony now has two valid hierarchy parents (team for sprint
4641
- // ceremonies, user_advisory_board for CAB meetings).
4642
- user_advisory_board: ["ceremony"],
4643
- // ── Pricing & Packaging hierarchy ────────────────────────────────────────────
4644
- pricing_strategy: [
4645
- "experiment_plan",
4646
- "pricing_tier",
4647
- "discount_strategy",
4648
- "trial_config",
4649
- "paywall"
4650
- ],
4651
- // ── AI/ML Operations hierarchy ───────────────────────────────────────────────
4652
- // (UPG-665) The prompt abstraction is corrected: ai_model → prompt_template →
4653
- // prompt_version (a model has templates; each template has versions). The
4654
- // model no longer owns prompt_version directly.
4655
- ai_model: [
4656
- "prompt_template",
4657
- "eval_benchmark",
4658
- "ai_cost_tracker",
4659
- "hallucination_report",
4660
- "ai_guardrail",
4661
- "model_comparison",
4662
- "ai_experiment",
4663
- "ai_dataset",
4664
- "ai_trace"
4665
- ],
4666
- // prompt_template owns its prompt_versions the way a file owns its commits.
4667
- prompt_template: ["prompt_version"],
4668
- // v0.5.7 (UPG-528 Part 2c): benchmarks define the metric set they measure
4669
- // (HELM, MLPerf, BIG-bench all spec a metric list). metric already has many
4670
- // hierarchy parents (outcome, objective, key_result, solution, data_source).
4671
- eval_benchmark: ["eval_run", "metric"],
4672
- // ai_trace spawns child traces for sub-calls (tool calls, chained
4673
- // prompts). Self-nesting enables call-tree representation.
4674
- ai_trace: ["ai_trace"],
4675
- // ── Agentic Workflows & Process hierarchy ────────────────────────────────────
4676
- workflow_template: ["workflow_run", "review_gate", "agent_task"],
4677
- workflow_run: ["workflow_artifact"],
4678
- agent_definition: ["agent_session", "agent_skill", "agent_hook", "workflow_template", "agent_task"],
4679
- // v0.5.8 (UPG-528 Part 2d): review gates also vet research insights
4680
- // (ResearchOps insight-review pattern). Pairs with `review_gate_vets_insight`
4681
- // in the edge catalog. The gate now owns two child types: approval records
4682
- // for workflow gates, insights for research-democratisation gates.
4683
- review_gate: ["approval_record", "insight"],
4684
- // ── Investigation hierarchy ──────────────────────────────────────────────────
4685
- investigation: ["symptom", "root_cause"],
4686
- root_cause: ["fix"],
4687
- // ── Portfolio layer hierarchy ────────────────────────────────────────────────
4688
- // organization → product_area is the org-axis anchor (who owns what);
4689
- // organization → portfolio is the strategic-axis anchor (where you invest).
4690
- // organization → workspace (WS3, 2026-07-05): org-altitude workspace anchor
4691
- // (organization_thinks_in_workspace) — a workspace scoped to org altitude
4692
- // lives in the same portfolio-level graph as its organization node.
4693
- organization: ["portfolio", "product_area", "workspace"],
4694
- // portfolios can nest (multi-level investment structures).
4695
- portfolio: ["product", "portfolio"],
4696
- // product_area is the organisational container for products and can
4697
- // nest (parent → sub-area). product_area also groups features; the
4698
- // "Studio area owns 6 features" mental model. product_area → workspace
4699
- // (WS3, 2026-07-05): plane-altitude workspace anchor
4700
- // (product_area_thinks_in_workspace) — "plane" is Entopo's app-level name
4701
- // for product_area, not a distinct spec entity.
4702
- product_area: ["product", "product_area", "feature", "workspace"]
4703
- };
4704
- function getValidChildren(entityType) {
4705
- return UPG_VALID_CHILDREN[entityType] ?? [];
4706
- }
4707
- function canBeChildOf(childType, parentType) {
4708
- return getValidChildren(parentType).includes(childType);
4709
- }
4710
- var UPG_CONTAINMENT_FREE_TYPES = /* @__PURE__ */ new Set([
4711
- "person",
4712
- // A framework_exercise has no structural parent: it anchors to the entities
4713
- // it scores via the `framework_exercise_includes_node` edge, not by
4714
- // containment. Modelling it as a product child would force a containment edge
4715
- // and read against the whole point of the exercise model (relational, not
4716
- // hierarchical). Same posture as `person`. See ADR 2026-06-02-framework-exercises.
4717
- "framework_exercise",
4718
- // A composition has no structural parent for the same reason a
4719
- // framework_exercise does not: it anchors to what it SHOWS, relationally, via
4720
- // `composition_focuses_node`. Modelling it as a product child would force a
4721
- // containment edge that reads against the point — a published view is not a
4722
- // part of the product, it is a lens onto one. This is also what keeps the
4723
- // type to two edges rather than three: no provenance edge is minted (that is
4724
- // `workspace_produced_node`, reused) and no parent edge is needed.
4725
- "composition",
4726
- // A capture has no structural parent for the same reason: it anchors to what
4727
- // it RENDERS, via `capture_renders_node`. Giving it a product parent would
4728
- // claim a capture is part of the product rather than a picture of one, and
4729
- // would mint a containment edge whose only job is to satisfy the hierarchy.
4730
- "capture"
4731
- ]);
4732
- function isContainmentFreeType(entityType) {
4733
- return UPG_CONTAINMENT_FREE_TYPES.has(entityType);
4734
- }
4735
-
4736
- // src/grammar/projection.ts
4737
- var VARIES_BY_EDGE = "surface_varies_by_configuration_axis";
4738
- var PRESENT_UNDER_PROPERTY = "present_under";
4739
- var ACTIVE_WHEN_PROPERTY = "active_when";
4740
- var QUALIFIABLE_EDGE_TYPES = [
4741
- "surface_contains_surface",
4742
- "feature_occupies_surface"
4743
- ];
4744
- function readStringArray(properties, key) {
4745
- const raw = properties?.[key];
4746
- if (!Array.isArray(raw)) return void 0;
4747
- return raw.filter((v) => typeof v === "string");
4748
- }
4749
- function readActiveWhen(edge) {
4750
- const raw = edge.properties?.[ACTIVE_WHEN_PROPERTY];
4751
- if (!raw || typeof raw !== "object" || Array.isArray(raw)) return void 0;
4752
- const axis = raw.axis;
4753
- const values = readStringArray(raw, "values");
4754
- if (typeof axis !== "string" || axis.length === 0 || !values || values.length === 0) {
4755
- return void 0;
4756
- }
4757
- return { axis, values };
4758
- }
4759
- function projectGraph(nodes, edges, configuration) {
4760
- const axes = Object.keys(configuration);
4761
- if (axes.length === 0) {
4762
- return {
4763
- nodes: [...nodes],
4764
- edges: [...edges],
4765
- excluded_node_ids: [],
4766
- deactivated_edge_count: 0,
4767
- dangling_edge_count: 0
4768
- };
4769
- }
4770
- const excluded = /* @__PURE__ */ new Set();
4771
- for (const edge of edges) {
4772
- if (edge.type !== VARIES_BY_EDGE) continue;
4773
- const chosen = configuration[edge.target];
4774
- if (chosen === void 0) continue;
4775
- const presentUnder = readStringArray(edge.properties, PRESENT_UNDER_PROPERTY);
4776
- if (!presentUnder) continue;
4777
- if (!presentUnder.includes(chosen)) excluded.add(edge.source);
4778
- }
4779
- const survivingNodes = excluded.size === 0 ? [...nodes] : nodes.filter((n) => !excluded.has(n.id));
4780
- let deactivated = 0;
4781
- let dangling = 0;
4782
- const survivingEdges = [];
4783
- for (const edge of edges) {
4784
- const qualifier = readActiveWhen(edge);
4785
- if (qualifier) {
4786
- const chosen = configuration[qualifier.axis];
4787
- if (chosen !== void 0 && !qualifier.values.includes(chosen)) {
4788
- deactivated++;
4789
- continue;
4790
- }
4791
- }
4792
- if (excluded.has(edge.source) || excluded.has(edge.target)) {
4793
- dangling++;
4794
- continue;
4795
- }
4796
- survivingEdges.push(edge);
4797
- }
4798
- return {
4799
- nodes: survivingNodes,
4800
- edges: survivingEdges,
4801
- excluded_node_ids: [...excluded].sort(),
4802
- deactivated_edge_count: deactivated,
4803
- dangling_edge_count: dangling
4804
- };
4805
- }
4806
- function enumerateProjections(nodes) {
4807
- const out = [
4808
- { configuration: {} }
4809
- ];
4810
- for (const node of nodes) {
4811
- if (node.type !== "configuration_axis") continue;
4812
- const values = readStringArray(node.properties, "values");
4813
- if (!values) continue;
4814
- for (const value of values) {
4815
- out.push({ axis: node.id, value, configuration: { [node.id]: value } });
4816
- }
4817
- }
4818
- return out;
4819
- }
4820
-
4821
- // src/grammar/configuration-drift.ts
4822
- var ALTERNATES_EDGE = "surface_alternates_with_surface";
4823
- var PARENT_EDGE_TYPES = /* @__PURE__ */ new Set(["surface_contains_surface", "screen_renders_surface"]);
4824
- function edgeLabel(edge) {
4825
- return edge.id ?? `${edge.source} -> ${edge.target}`;
4826
- }
4827
- function checkConfigurationDrift(nodes, edges) {
4828
- const findings = [];
4829
- const axisValues = /* @__PURE__ */ new Map();
4830
- for (const node of nodes) {
4831
- if (node.type !== "configuration_axis") continue;
4832
- const values = readStringArray(node.properties, "values");
4833
- if (!values || values.length === 0) {
4834
- findings.push({
4835
- kind: "axis_values_empty",
4836
- severity: "error",
4837
- node_id: node.id,
4838
- axis_id: node.id,
4839
- message: "Configuration axis declares no values. An axis with no values selects nothing, so no projection can be taken along it."
4840
- });
4841
- axisValues.set(node.id, []);
4842
- continue;
4843
- }
4844
- axisValues.set(node.id, values);
4845
- const rawDefault = node.properties?.default_value;
4846
- if (typeof rawDefault === "string" && rawDefault.length > 0 && !values.includes(rawDefault)) {
4847
- findings.push({
4848
- kind: "axis_default_not_a_value",
4849
- severity: "error",
4850
- node_id: node.id,
4851
- axis_id: node.id,
4852
- message: `default_value "${rawDefault}" is not one of the axis values [${values.join(", ")}]. It names a value of this axis, so it has to be one the axis declares.`
4853
- });
4854
- }
4855
- }
4856
- for (const edge of edges) {
4857
- if (edge.type !== VARIES_BY_EDGE) continue;
4858
- const values = axisValues.get(edge.target);
4859
- const presentUnder = readStringArray(edge.properties, PRESENT_UNDER_PROPERTY);
4860
- if (!presentUnder || presentUnder.length === 0) {
4861
- findings.push({
4862
- kind: "present_under_empty",
4863
- severity: "error",
4864
- edge_id: edge.id,
4865
- node_id: edge.source,
4866
- axis_id: edge.target,
4867
- message: `${edgeLabel(edge)} declares variance without a non-empty present_under. A surface that exists under no configuration should be deleted rather than declared; a surface that exists under all of them should carry no varies_by edge at all.`
4868
- });
4869
- continue;
4870
- }
4871
- if (!values) continue;
4872
- for (const value of presentUnder) {
4873
- if (!values.includes(value)) {
4874
- findings.push({
4875
- kind: "present_under_unknown_value",
4876
- severity: "error",
4877
- edge_id: edge.id,
4878
- node_id: edge.source,
4879
- axis_id: edge.target,
4880
- message: `present_under names "${value}", which the axis does not declare. Its values are [${values.join(", ")}].`
4881
- });
4882
- }
4883
- }
4884
- }
4885
- for (const edge of edges) {
4886
- const hasQualifierKey = edge.properties !== void 0 && Object.prototype.hasOwnProperty.call(edge.properties, ACTIVE_WHEN_PROPERTY);
4887
- if (!hasQualifierKey) continue;
4888
- if (edge.type !== void 0 && !QUALIFIABLE_EDGE_TYPES.includes(edge.type)) {
4889
- findings.push({
4890
- kind: "qualifier_on_illegal_edge",
4891
- severity: "error",
4892
- edge_id: edge.id,
4893
- message: `active_when is not legal on ${edge.type}. The qualifier is scoped to [${QUALIFIABLE_EDGE_TYPES.join(", ")}] deliberately: conditional composition is the question this release answers, and a general modality system is not.`
4894
- });
4895
- continue;
4896
- }
4897
- const qualifier = readActiveWhen(edge);
4898
- if (!qualifier) {
4899
- const rawQualifier = edge.properties?.[ACTIVE_WHEN_PROPERTY];
4900
- const rawValues = rawQualifier && typeof rawQualifier === "object" && !Array.isArray(rawQualifier) ? rawQualifier.values : void 0;
4901
- if (Array.isArray(rawValues) && rawValues.length === 0) {
4902
- findings.push({
4903
- kind: "qualifier_values_empty",
4904
- severity: "error",
4905
- edge_id: edge.id,
4906
- message: `${edgeLabel(edge)} carries an active_when with an empty values list. Read literally that would remove the relationship from every configuration, which is a way to delete an edge by writing a property; it is treated as absent instead. To say a relationship never holds, delete the edge.`
4907
- });
4908
- continue;
4909
- }
4910
- findings.push({
4911
- kind: "qualifier_axis_unresolved",
4912
- severity: "error",
4913
- edge_id: edge.id,
4914
- message: `${edgeLabel(edge)} carries a malformed active_when. It must be an object with an axis id and a non-empty values array; anything else reads as absent, which silently makes the relationship invariant.`
4915
- });
4916
- continue;
4917
- }
4918
- const values = axisValues.get(qualifier.axis);
4919
- if (!values) {
4920
- findings.push({
4921
- kind: "qualifier_axis_unresolved",
4922
- severity: "error",
4923
- edge_id: edge.id,
4924
- axis_id: qualifier.axis,
4925
- message: `active_when names axis "${qualifier.axis}", which is not a configuration_axis node in this graph.`
4926
- });
4927
- continue;
4928
- }
4929
- for (const value of qualifier.values) {
4930
- if (!values.includes(value)) {
4931
- findings.push({
4932
- kind: "qualifier_unknown_value",
4933
- severity: "error",
4934
- edge_id: edge.id,
4935
- axis_id: qualifier.axis,
4936
- message: `active_when names value "${value}", which axis "${qualifier.axis}" does not declare. Its values are [${values.join(", ")}].`
4937
- });
4938
- }
4939
- }
4940
- }
4941
- const varianceBySource = /* @__PURE__ */ new Map();
4942
- for (const edge of edges) {
4943
- if (edge.type !== VARIES_BY_EDGE) continue;
4944
- const values = readStringArray(edge.properties, PRESENT_UNDER_PROPERTY) ?? [];
4945
- const list = varianceBySource.get(edge.source) ?? [];
4946
- list.push({ axis: edge.target, values });
4947
- varianceBySource.set(edge.source, list);
4948
- }
4949
- for (const edge of edges) {
4950
- if (edge.type !== ALTERNATES_EDGE) continue;
4951
- const left = varianceBySource.get(edge.source) ?? [];
4952
- const right = varianceBySource.get(edge.target) ?? [];
4953
- if (left.length === 0 || right.length === 0) {
4954
- findings.push({
4955
- kind: "alternation_axis_mismatch",
4956
- severity: "error",
4957
- edge_id: edge.id,
4958
- message: `${edgeLabel(edge)} declares an alternation, but at least one endpoint declares no variance at all. Two surfaces that are both always present are not alternatives; they co-exist.`
4959
- });
4960
- continue;
4961
- }
4962
- const sharedAxes = left.filter((l) => right.some((r) => r.axis === l.axis)).map((l) => l.axis);
4963
- if (sharedAxes.length === 0) {
4964
- findings.push({
4965
- kind: "alternation_axis_mismatch",
4966
- severity: "error",
4967
- edge_id: edge.id,
4968
- message: `${edgeLabel(edge)} declares an alternation between surfaces that vary on different axes. Alternatives are selected by ONE lever; surfaces on different levers can both be present at once.`
4969
- });
4970
- continue;
4971
- }
4972
- for (const axis of sharedAxes) {
4973
- const leftValues = left.find((l) => l.axis === axis)?.values ?? [];
4974
- const rightValues = right.find((r) => r.axis === axis)?.values ?? [];
4975
- const overlap = leftValues.filter((v) => rightValues.includes(v));
4976
- if (overlap.length > 0) {
4977
- findings.push({
4978
- kind: "alternation_overlap",
4979
- severity: "error",
4980
- edge_id: edge.id,
4981
- axis_id: axis,
4982
- message: `${edgeLabel(edge)} declares an alternation, but both surfaces are present under [${overlap.join(", ")}] on axis "${axis}". They co-exist there, so the graph is asserting "one of these" and "both, together" about the same pair.`
4983
- });
4984
- }
4985
- }
4986
- }
4987
- const parentsByChild = /* @__PURE__ */ new Map();
4988
- for (const edge of edges) {
4989
- if (edge.type && PARENT_EDGE_TYPES.has(edge.type)) {
4990
- parentsByChild.set(edge.target, (parentsByChild.get(edge.target) ?? 0) + 1);
4991
- }
4992
- }
4993
- for (const [axisId, values] of axisValues) {
4994
- for (const value of values) {
4995
- const projected = projectGraph(nodes, edges, { [axisId]: value });
4996
- const survivingParents = /* @__PURE__ */ new Map();
4997
- for (const edge of projected.edges) {
4998
- if (edge.type && PARENT_EDGE_TYPES.has(edge.type)) {
4999
- survivingParents.set(edge.target, (survivingParents.get(edge.target) ?? 0) + 1);
5000
- }
5001
- }
5002
- for (const node of projected.nodes) {
5003
- if (node.type !== "surface") continue;
5004
- if ((parentsByChild.get(node.id) ?? 0) === 0) continue;
5005
- if ((survivingParents.get(node.id) ?? 0) > 0) continue;
5006
- findings.push({
5007
- kind: "orphaned_under_projection",
5008
- severity: "warning",
5009
- node_id: node.id,
5010
- axis_id: axisId,
5011
- message: `Surface is present under ${axisId} = "${value}" but every containment parent it has is absent there. Either it needs a parent in that configuration, or it should declare that it is absent from it too.`
5012
- });
5013
- }
5014
- }
5015
- }
5016
- return findings;
5017
- }
5018
-
5019
- // src/grammar/lifecycles.ts
5020
- var PRODUCT_LIFECYCLE = {
5021
- entity_type: "product",
5022
- initial_phase: "concept",
5023
- terminal_phases: ["sunset"],
5024
- phases: [
5025
- {
5026
- id: "concept",
5027
- status_category: "triage",
5028
- label: "Concept",
5029
- description: "Napkin idea. Problem shape and solution sketch, pre-validation.",
5030
- transitions_to: ["validation", "build", "beta", "launch", "growth", "mature", "sunset"]
5031
- },
5032
- {
5033
- id: "validation",
5034
- status_category: "started",
5035
- label: "Validation",
5036
- description: "Testing demand. User conversations and experiments pressure-test assumptions before build commits.",
5037
- transitions_to: ["build", "beta", "launch", "growth", "mature", "sunset"]
5038
- },
5039
- {
5040
- id: "build",
5041
- status_category: "started",
5042
- label: "Build",
5043
- description: "Actively developing v1. Core functionality is being authored, pre-user.",
5044
- transitions_to: ["beta", "launch", "growth", "mature", "sunset"]
5045
- },
5046
- {
5047
- id: "beta",
5048
- status_category: "started",
5049
- label: "Beta",
5050
- description: "Early users, iterating. Feature-complete enough to learn from, still changing weekly.",
5051
- transitions_to: ["launch", "growth", "mature", "maintenance", "sunset"]
5052
- },
5053
- {
5054
- id: "launch",
5055
- status_category: "started",
5056
- label: "Launch",
5057
- description: "Generally available. Announced to the target audience, open past beta access.",
5058
- transitions_to: ["growth", "mature", "maintenance", "sunset"]
5059
- },
5060
- {
5061
- id: "growth",
5062
- status_category: "started",
5063
- label: "Growth",
5064
- description: "Scaling users and revenue. Product fit validated; focus is acquisition, retention, expansion.",
5065
- transitions_to: ["mature", "maintenance", "sunset"]
5066
- },
5067
- {
5068
- id: "mature",
5069
- status_category: "started",
5070
- label: "Mature",
5071
- description: "Stable. Growth levelled; investment weights toward optimisation, efficiency, and durability.",
5072
- transitions_to: ["maintenance", "sunset"]
5073
- },
5074
- {
5075
- id: "maintenance",
5076
- status_category: "started",
5077
- label: "Maintenance",
5078
- description: "Sustaining. Minimal investment keeps the product running for existing users. Can transition back to `mature` on a strategic revival.",
5079
- transitions_to: ["mature", "sunset"]
5080
- },
5081
- {
5082
- id: "sunset",
5083
- status_category: "completed",
5084
- label: "Sunset",
5085
- description: "Winding down or retired. Existing users are being migrated or offboarded.",
5086
- transitions_to: []
5087
- }
5088
- ]
5089
- };
5090
- var NEED_LIFECYCLE = {
5091
- entity_type: "need",
5092
- initial_phase: "raw",
5093
- terminal_phases: ["prioritized"],
5094
- phases: [
5095
- {
5096
- id: "raw",
5097
- status_category: "triage",
5098
- label: "Raw",
5099
- description: "Captured from an interview, observation, or support ticket. Articulation may be rough; may duplicate an existing need.",
5100
- transitions_to: ["validated"]
5101
- },
5102
- {
5103
- id: "validated",
5104
- status_category: "started",
5105
- label: "Validated",
5106
- description: "Corroborated by multiple data points or targeted research. The team agrees it is a real, recurring need.",
5107
- transitions_to: ["prioritized"]
5108
- },
5109
- {
5110
- id: "prioritized",
5111
- status_category: "completed",
5112
- label: "Prioritized",
5113
- description: "Ranked against other needs. Ready to inform opportunity definition and solution exploration.",
5114
- transitions_to: []
4144
+ var NEED_LIFECYCLE = {
4145
+ entity_type: "need",
4146
+ initial_phase: "raw",
4147
+ terminal_phases: ["prioritized"],
4148
+ phases: [
4149
+ {
4150
+ id: "raw",
4151
+ status_category: "triage",
4152
+ label: "Raw",
4153
+ description: "Captured from an interview, observation, or support ticket. Articulation may be rough; may duplicate an existing need.",
4154
+ transitions_to: ["validated"]
4155
+ },
4156
+ {
4157
+ id: "validated",
4158
+ status_category: "started",
4159
+ label: "Validated",
4160
+ description: "Corroborated by multiple data points or targeted research. The team agrees it is a real, recurring need.",
4161
+ transitions_to: ["prioritized"]
4162
+ },
4163
+ {
4164
+ id: "prioritized",
4165
+ status_category: "completed",
4166
+ label: "Prioritized",
4167
+ description: "Ranked against other needs. Ready to inform opportunity definition and solution exploration.",
4168
+ transitions_to: []
5115
4169
  }
5116
4170
  ]
5117
4171
  };
@@ -7263,284 +6317,1828 @@ var UPG_LIFECYCLES = [
7263
6317
  PROMPT_VERSION_LIFECYCLE,
7264
6318
  EVAL_BENCHMARK_LIFECYCLE,
7265
6319
  // Business Model
7266
- BUSINESS_MODEL_LIFECYCLE,
7267
- REVENUE_STREAM_LIFECYCLE,
7268
- // Customer Success
7269
- CUSTOMER_HEALTH_SCORE_LIFECYCLE,
7270
- PLAYBOOK_LIFECYCLE,
6320
+ BUSINESS_MODEL_LIFECYCLE,
6321
+ REVENUE_STREAM_LIFECYCLE,
6322
+ // Customer Success
6323
+ CUSTOMER_HEALTH_SCORE_LIFECYCLE,
6324
+ PLAYBOOK_LIFECYCLE,
6325
+ // Team & Organisation
6326
+ TEAM_OKR_LIFECYCLE,
6327
+ RETROSPECTIVE_LIFECYCLE,
6328
+ DEPENDENCY_LIFECYCLE,
6329
+ ROLE_LIFECYCLE,
6330
+ CAPACITY_PLAN_LIFECYCLE,
6331
+ // Product & Growth
6332
+ VARIANT_LIFECYCLE,
6333
+ GROWTH_CAMPAIGN_LIFECYCLE,
6334
+ // Workspace
6335
+ FRAMEWORK_EXERCISE_LIFECYCLE,
6336
+ COMPOSITION_LIFECYCLE,
6337
+ // ── Template-generated lifecycles ─────────────────────────────────
6338
+ ...TEMPLATE_LIFECYCLES
6339
+ ];
6340
+ function getLifecycleForType(entityType) {
6341
+ return UPG_LIFECYCLES.find((l) => l.entity_type === entityType);
6342
+ }
6343
+ var UPG_LIFECYCLE_FREE_TYPES = /* @__PURE__ */ new Set([
6344
+ // ── Foundations (3 of 4): a primitive either exists or is deprecated; no
6345
+ // phase ladder (like metric). `operating_lifecycle`/`operating_stage` are
6346
+ // static ordered reference data (the loop is a `cyclic` flag, not a state
6347
+ // machine). `specification` carries a lifecycle. ──
6348
+ "primitive",
6349
+ "operating_lifecycle",
6350
+ "operating_stage",
6351
+ // ── User (5): personas and JTBD atoms are reference data ──────────────────
6352
+ "persona",
6353
+ "job",
6354
+ "job_step",
6355
+ "desired_outcome",
6356
+ "switching_cost",
6357
+ // ── Market Intelligence (7 of 8): competitor landscape is reference data;
6358
+ // competitor_signal is an append-only dated event (no phase ladder);
6359
+ // competitive_analysis shipped PUBLISHING lifecycle in Phase C;
6360
+ // classification_axis and classification_value are reference taxonomy
6361
+ // atoms with no state machine. ─
6362
+ "competitor",
6363
+ "competitor_feature",
6364
+ "competitor_signal",
6365
+ "market_trend",
6366
+ "market_segment",
6367
+ "classification_axis",
6368
+ "classification_value",
6369
+ // ── Product Specification (1): a configuration_axis is a structural
6370
+ // DECLARATION (a lever and its closed value set), not a thing that
6371
+ // progresses through states. Same reading as classification_axis above.
6372
+ "configuration_axis",
6373
+ // ── User Research (5 of 8): participants, quotes, observations,
6374
+ // clusters, survey responses are immutable data points ────────────────
6375
+ "participant",
6376
+ "observation",
6377
+ "quote",
6378
+ "affinity_cluster",
6379
+ "survey_response",
6380
+ // ── UX Design (3 of 8): journey structural atoms ──────────────────────────
6381
+ "journey_step",
6382
+ "journey_phase",
6383
+ "journey_action",
6384
+ "screen_state",
6385
+ // ── Design System (3 of 7): tokens and annotations are atomic values ────
6386
+ "design_token",
6387
+ "annotation",
6388
+ // ── Brand (4 of 6): colour/typography/imagery/voice are reference atoms ──
6389
+ "brand_colour",
6390
+ "brand_typography",
6391
+ "brand_imagery",
6392
+ // ── Product Specification (4 of 5): criteria, grouping, historical, +
6393
+ // user_story (the templated promise is a stable design artefact; the paired
6394
+ // task carries the lifecycle). Re-canon story_statement → user_story at
6395
+ // v0.7.0/UPG-571. ─
6396
+ "acceptance_criterion",
6397
+ "changelog",
6398
+ "roadmap_theme",
6399
+ "user_story",
6400
+ // ── Strategy: metric is a measurement definition; metric_quality_assessment
6401
+ // is a point-in-time snapshot; value_stream is a mapped flow;
6402
+ // constraint carries its own `constraint_status` enum (binding/advisory/
6403
+ // lifted) as a property; base-node `status` not used.
6404
+ // vision/mission/capability/outcome get lifecycles in Phase B or C ─────
6405
+ "metric",
6406
+ "metric_quality_assessment",
6407
+ "value_stream",
6408
+ "constraint",
6409
+ // ── Engineering (15 of 17): DDD modelling primitives + infra references.
6410
+ // root_cause / symptom / fix are investigation findings, not workflows
6411
+ // (investigation itself has a lifecycle) ────────────────────────────────
6412
+ "aggregate",
6413
+ "domain_entity",
6414
+ "value_object",
6415
+ "command",
6416
+ "read_model",
6417
+ "domain_event",
6418
+ "bounded_context",
6419
+ "api_endpoint",
6420
+ "queue_topic",
6421
+ "build_artifact",
6422
+ "code_repository",
6423
+ "library_dependency",
6424
+ "integration_pattern",
6425
+ "data_flow",
6426
+ "root_cause",
6427
+ "symptom",
6428
+ "fix",
6429
+ // ── Business Model (6 of 9): BMC cells are structural frames ────────────
6430
+ "cost_structure",
6431
+ "unit_economics",
6432
+ "key_resource",
6433
+ "key_activity",
6434
+ "customer_relationship",
6435
+ "distribution_channel",
6436
+ // ── Go-To-Market (8 of 13): positioning/ICP/territory/sales_motion are
6437
+ // configuration; objection/rebuttal/proof_point are catalog entries ───
6438
+ "ideal_customer_profile",
6439
+ "positioning",
6440
+ "sales_motion",
6441
+ "territory",
6442
+ "objection",
6443
+ "rebuttal",
6444
+ "proof_point",
6445
+ // ── Team & Organisation (7 of 11): org structural atoms ───────────────────
6446
+ "team",
6447
+ "stakeholder",
6448
+ "person",
6449
+ "department",
6450
+ "skill",
6451
+ "ceremony",
6452
+ // ── Data & Analytics (4 of 10): lineage and domain containers, plus
6453
+ // atomic definitions ────────────────────────────────────────────────────
6454
+ "data_lineage",
6455
+ "data_domain",
6456
+ "data_quality_rule",
6457
+ // ── AI (3 of 10): traces and cost trackers are append-only; model
6458
+ // comparison snapshots are immutable ───────────────────────────────────
6459
+ "ai_cost_tracker",
6460
+ "ai_trace",
6461
+ // ── Automation (2 of 6): approvals and artifacts are ledger entries ──────
6462
+ "approval_record",
6463
+ "workflow_artifact",
6464
+ // ── Growth (7 of 9): funnels and attribution are structural definitions;
6465
+ // cohorts/segments are computed snapshots ────────────────────────────
6466
+ "funnel",
6467
+ "funnel_step",
6468
+ "acquisition_channel",
6469
+ "cohort",
6470
+ "behavioral_segment",
6471
+ "growth_loop",
6472
+ "attribution_model",
6473
+ // ── Sales (5 of 6): pipeline structure + accounts/contacts + forecast
6474
+ // snapshots. Only `deal` has a lifecycle (Phase B SALES_DEAL template) ─
6475
+ "account",
6476
+ "contact",
6477
+ "pipeline_sales",
6478
+ "pipeline_stage",
6479
+ "forecast",
6480
+ // ── Customer Success (5 of 9): journey structure + derived values ────────
6481
+ "customer_journey_stage",
6482
+ "touchpoint",
6483
+ "churn_reason",
6484
+ "service_level_agreement",
6485
+ // ── DevOps (5 of 10): indicators and budgets are measurement references;
6486
+ // strategies and pipelines are configuration ──────────────────────────
6487
+ "service_level_indicator",
6488
+ "service_level_objective",
6489
+ "error_budget",
6490
+ "ci_pipeline",
6491
+ "release_strategy",
6492
+ // ── Security (1 of 5): data classification is a reference label ──────────
6493
+ "data_classification",
6494
+ // ── Accessibility (2 of 4): standards and annotations ─────────────────────
6495
+ "a11y_standard",
6496
+ "a11y_annotation",
6497
+ // ── Testing (3 of 5): regression tests are reference definitions; test
6498
+ // results and coverage reports are immutable records ───────────────────
6499
+ "regression_test",
6500
+ "test_coverage_report",
6501
+ "test_result",
6502
+ // ── Customer Feedback (2 of 3): themes and votes are atomic data points ──
6503
+ "feedback_theme",
6504
+ "feedback_vote",
6505
+ // ── Pricing (2 of 4): trial and paywall are configuration ─────────────────
6506
+ "trial_config",
6507
+ "paywall",
6508
+ // ── Content (2 of 5): calendars and themes are planning configuration ────
6509
+ "content_calendar",
6510
+ "content_theme",
6511
+ // ── Legal (2 of 3): legal_entity is an org; contract_clause is an atom
6512
+ // of a contract (which has its own lifecycle) ───────────────────────────
6513
+ "legal_entity",
6514
+ "contract_clause",
6515
+ // ── Portfolio (3 of 3): structural containers ─────────────────────────────
6516
+ "organization",
6517
+ "portfolio",
6518
+ "product_area",
6519
+ // ── Program Management (2 of 3): allocations and registers are tracking
6520
+ // containers ────────────────────────────────────────────────────────────
6521
+ "resource_allocation",
6522
+ "risk_register",
6523
+ // ── Localisation (4 of 5): translation keys, configs, and regional
6524
+ // adaptations are reference data ────────────────────────────────────────
6525
+ "translation_key",
6526
+ "locale_config",
6527
+ "cultural_adaptation",
6528
+ "regional_pricing",
6529
+ // ── Marketing (1 of 4): SEO keywords are tracked reference terms ─────────
6530
+ "seo_keyword",
6531
+ // ── Ecosystem (2 of 2): partner tiers and rev-share terms are config ─────
6532
+ "partner_tier",
6533
+ "partner_revenue_share",
6534
+ // ── Validation (2 of 4): evidence + learning are data points captured
6535
+ // from experiment_runs (which have lifecycles); hypothesis_evidence was
6536
+ // lifecycle-free here but is deprecated at v0.4.0 ──────────────────────────────────────
6537
+ "evidence",
6538
+ "learning",
6539
+ // ── Workspace (1 of 4): a capture is a fact about a moment, not a workflow.
6540
+ // It is taken, and from then on it either still matches its subject or it
6541
+ // does not — which is what `content_hash` answers, not a phase. ─────────
6542
+ "capture"
6543
+ ]);
6544
+ function isLifecycleFreeType(entityType) {
6545
+ return UPG_LIFECYCLE_FREE_TYPES.has(entityType);
6546
+ }
6547
+ var UPG_LIFECYCLE_PLANNED_TYPES = /* @__PURE__ */ new Set([
6548
+ // Phase B cleared this set entirely. Every type that was triaged
6549
+ // into Phase B/C/D under now either has a lifecycle in
6550
+ // `UPG_LIFECYCLES` or is documented as lifecycle-free in
6551
+ // `UPG_LIFECYCLE_FREE_TYPES`.
6552
+ //
6553
+ // Reintroduce entries here when a new entity type is added to the spec
6554
+ // and decided to be lifecycle-bearing but its phases have not yet been
6555
+ // designed. The `10-lifecycle-coverage` audit will surface uncovered
6556
+ // active types until they're either implemented or moved to the
6557
+ // free-types set.
6558
+ ]);
6559
+ function isLifecyclePlannedType(entityType) {
6560
+ return UPG_LIFECYCLE_PLANNED_TYPES.has(entityType);
6561
+ }
6562
+ function getLifecycleRenderShape(entityType) {
6563
+ const lifecycle = getLifecycleForType(entityType);
6564
+ if (!lifecycle) return null;
6565
+ const terminalSet = new Set(lifecycle.terminal_phases);
6566
+ const phaseIndex = new Map(lifecycle.phases.map((p, i) => [p.id, i]));
6567
+ const states = lifecycle.phases.map((phase) => ({
6568
+ id: phase.id,
6569
+ label: phase.label,
6570
+ description: phase.description,
6571
+ terminal: terminalSet.has(phase.id)
6572
+ }));
6573
+ const transitions = [];
6574
+ for (const phase of lifecycle.phases) {
6575
+ const fromTerminal = terminalSet.has(phase.id);
6576
+ for (const to of phase.transitions_to) {
6577
+ const toTerminal = terminalSet.has(to);
6578
+ let kind;
6579
+ if (fromTerminal && !toTerminal) {
6580
+ kind = "reopen";
6581
+ } else if (toTerminal && !fromTerminal) {
6582
+ kind = "terminal";
6583
+ } else {
6584
+ const fromIdx = phaseIndex.get(phase.id) ?? 0;
6585
+ const toIdx = phaseIndex.get(to) ?? 0;
6586
+ kind = toIdx < fromIdx ? "backward" : "forward";
6587
+ }
6588
+ transitions.push({ from: phase.id, to, kind });
6589
+ }
6590
+ }
6591
+ return {
6592
+ entity_type: lifecycle.entity_type,
6593
+ ...lifecycle.template_id !== void 0 && { template_id: lifecycle.template_id },
6594
+ states,
6595
+ transitions,
6596
+ initial_state: lifecycle.initial_phase
6597
+ };
6598
+ }
6599
+
6600
+ // src/catalog/legacy-product-stages.ts
6601
+ var LEGACY_PRODUCT_STAGES = Object.freeze({
6602
+ idea: "concept"
6603
+ });
6604
+ function migrateProductStage(stage) {
6605
+ if (stage === void 0 || stage === null) {
6606
+ return void 0;
6607
+ }
6608
+ if (typeof stage !== "string") {
6609
+ return stage;
6610
+ }
6611
+ const lower = stage.toLowerCase();
6612
+ const mapped = LEGACY_PRODUCT_STAGES[lower];
6613
+ return mapped ?? stage;
6614
+ }
6615
+ function isLegacyProductStage(stage) {
6616
+ return typeof stage === "string" && stage.toLowerCase() in LEGACY_PRODUCT_STAGES;
6617
+ }
6618
+
6619
+ // src/catalog/entity-descriptions.ts
6620
+ var UPG_ENTITY_DESCRIPTIONS = Object.freeze({
6621
+ // Strategy
6622
+ product: "The product being created, the root of the graph",
6623
+ outcome: "A desired business or user outcome",
6624
+ objective: "A strategic goal (OKR)",
6625
+ key_result: "A measurable result tied to an objective",
6626
+ metric: "A unified metric that measures progress, health, or behaviour across the product",
6627
+ metric_quality_assessment: "An assessment of whether a metric is well-defined, measurable, and aligned to a meaningful outcome.",
6628
+ vision: "A long-term aspirational statement of the future state",
6629
+ mission: "The purpose and reason the product exists",
6630
+ strategic_theme: "A high-level strategic focus area for a planning period. Its own time_horizon is now deprecated: promote the period to a planning_cycle and link the two with strategic_theme_scoped_to_planning_cycle, so themes share one dated, nestable interval instead of a drifting per-theme label.",
6631
+ initiative: "A large coordinated effort to achieve a strategic goal",
6632
+ capability: "An ability that enables value delivery",
6633
+ value_stream: "An end-to-end flow delivering value to the customer",
6634
+ strategic_pillar: "A foundational principle that guides decisions",
6635
+ strategic_question: "An open strategic question a plan must resolve (of coordination, ownership, sequencing, or which bet to place), held explicitly until a decision retires it; the strategy sibling of research_question and design_question",
6636
+ assumption: "A belief taken as true that underpins a strategy",
6637
+ decision: "A recorded decision with context, rationale, and consequences",
6638
+ constraint: "A limit, requirement, or ceiling the product must respect, whether a self-imposed principle or an externally imposed boundary",
6639
+ // User
6640
+ persona: "An archetype representing a user segment",
6641
+ job: "Job To Be Done: what the user is trying to accomplish",
6642
+ need: "A user need, pain, desire, or constraint",
6643
+ desired_outcome: "What the user hopes to achieve",
6644
+ job_step: "A discrete step within a Job To Be Done",
6645
+ switching_cost: "A barrier preventing users from switching alternatives",
6646
+ // Discovery
6647
+ opportunity: "A validated gap worth solving",
6648
+ solution: "A proposed approach to address an opportunity",
6649
+ feasibility_study: "An assessment of technical or business viability",
6650
+ design_sprint: "A time-boxed sprint to prototype and validate ideas",
6651
+ // Validation
6652
+ hypothesis: "A testable belief about a solution",
6653
+ experiment: "A test designed to validate a hypothesis",
6654
+ experiment_plan: "An experiment plan describing the hypothesis, setup, success criteria, and methodology before a test runs.",
6655
+ experiment_run: "An execution instance of an experiment that records actual conditions, observations, and raw results.",
6656
+ learning: "An insight gained from an experiment",
6657
+ test_plan: "A structured plan for testing a hypothesis",
6658
+ evidence: "Data supporting or refuting a hypothesis",
6659
+ research_plan: "A plan for gathering evidence to validate a draft entity",
6660
+ // Market Intelligence
6661
+ competitor: "A competing product or company",
6662
+ competitor_feature: "A feature offered by a competitor",
6663
+ market_trend: "An emerging trend in the market",
6664
+ market_segment: "A distinct group of potential customers",
6665
+ competitive_analysis: "A structured analysis of the competitive landscape",
6666
+ classification_axis: "A single dimension in a competitive classification matrix that defines one axis of comparison across alternatives.",
6667
+ classification_value: "A position or value on a classification axis, representing where one option lands on that dimension.",
6668
+ competitor_signal: "An observed competitor move or datapoint (a pricing change, launch, or hire) that feeds competitive analysis",
6669
+ // User Research
6670
+ research_study: "A planned research activity",
6671
+ insight: "A synthesised finding from research",
6672
+ participant: "A person participating in research",
6673
+ observation: "A specific behaviour or statement observed",
6674
+ quote: "A direct quote from a research participant",
6675
+ affinity_cluster: "A group of related observations",
6676
+ research_question: "A question guiding a research study",
6677
+ interview_guide: "A structured guide for conducting interviews",
6678
+ survey_response: "A response to a survey instrument",
6679
+ // Experience Design
6680
+ user_journey: "An end-to-end map of a user experience",
6681
+ journey_step: "A single step in a user journey",
6682
+ journey_phase: "A named phase in a user journey that groups a sequence of actions the user performs to reach a milestone.",
6683
+ journey_action: "A single step a user takes within a journey phase, the atomic unit of observable user behaviour.",
6684
+ user_flow: "A navigation path through the product",
6685
+ screen: "A distinct screen or view in the product",
6686
+ screen_state: "A specific state of a screen (e.g., empty, loading, error)",
6687
+ surface: "A place inside a screen, the features that occupy it, and the rule that decides who wins it",
6688
+ design_question: "An open design problem to explore",
6689
+ design_concept: "A possible design direction or approach",
6690
+ prototype: "An interactive mockup for testing",
6691
+ wireframe: "A low-fidelity structural layout",
6692
+ annotation: "A note or markup on a design artifact",
6693
+ interaction_spec: "A specification for an interaction behaviour",
6694
+ // Design System
6695
+ design_component: "A reusable UI component",
6696
+ design_token: "A design token (colour, spacing, typography)",
6697
+ design_system: "The root design system entity",
6698
+ design_pattern: "A documented design pattern",
6699
+ design_guideline: "A design usage guideline",
6700
+ // Brand Identity
6701
+ brand_identity: "The root brand identity entity",
6702
+ brand_colour: "A brand colour definition",
6703
+ brand_typography: "Brand typography specifications",
6704
+ brand_voice: "Brand voice and tone guidelines",
6705
+ brand_logo: "A brand logo or mark",
6706
+ brand_imagery: "Brand imagery and photography guidelines",
6707
+ // Product Specification
6708
+ feature: "A product capability or feature",
6709
+ feature_area: "A grouping of related features",
6710
+ epic: "A large body of work that can be broken into stories",
6711
+ user_story: `A user's goal and the value they expect, in the "As a\u2026 I want\u2026 So that\u2026" format. Now also a first-class plannable unit (priority, effort, assignee, due_date) that schedules into a planning_cycle, and it round-trips an external board's column via workflow_state.`,
6712
+ acceptance_criterion: "A condition that must be met for a story to be done",
6713
+ release: "A shipped version of the product",
6714
+ task: "A unit of work within a story or epic",
6715
+ bug: "A defect or unexpected behaviour",
6716
+ roadmap: "A strategic plan of features and milestones",
6717
+ roadmap_item: "An item on the product roadmap",
6718
+ theme: "A strategic grouping of related features",
6719
+ roadmap_theme: "A customer problem used as the organising unit of a roadmap",
6720
+ changelog: "A record of changes shipped in a release",
6721
+ planning_cycle: "The cadence axis of a plan: a dated interval a team plans in, be it a sprint, iteration, quarter, or program increment. Cycles self-nest, so a fine iteration sits inside a coarse period to form a granularity ladder.",
6722
+ configuration_axis: "A named dimension along which the product's composition differs: a feature flag, a plan tier, a permission level, a beta programme. The stored graph is the union of the family; one configuration is a projection of it.",
6723
+ // Engineering
6724
+ bounded_context: "A DDD bounded context defining a service boundary",
6725
+ service: "A deployable service or microservice",
6726
+ domain_event: "An event published when something happens in the domain",
6727
+ api_contract: "An API contract or specification",
6728
+ technical_debt_item: "A known piece of technical debt",
6729
+ feature_flag: "A feature toggle for controlled rollout",
6730
+ deployment: "A deployment event",
6731
+ aggregate: "A DDD aggregate root",
6732
+ domain_entity: "A DDD domain entity: a core object with a distinct identity and lifecycle inside a bounded context",
6733
+ value_object: "A DDD value object",
6734
+ command: "A DDD command (write operation)",
6735
+ read_model: "A DDD read model (query projection)",
6736
+ api_endpoint: "A specific API endpoint",
6737
+ database_schema: "A database schema definition",
6738
+ queue_topic: "A message queue topic",
6739
+ build_artifact: "A build output (binary, container image)",
6740
+ code_repository: "A source code repository",
6741
+ library_dependency: "A third-party library dependency",
6742
+ integration_pattern: "An integration pattern (saga, event sourcing, etc.)",
6743
+ external_api: "An external API consumed by the product",
6744
+ data_flow: "A data flow between systems",
6745
+ investigation: "An investigation into an issue or incident",
6746
+ root_cause: "An identified root cause of an issue",
6747
+ symptom: "A symptom of a problem",
6748
+ fix: "A fix applied to resolve an issue",
6749
+ // Growth
6750
+ funnel: "A conversion funnel tracking user progression",
6751
+ funnel_step: "A stage within a conversion funnel",
6752
+ acquisition_channel: "A channel through which users are acquired",
6753
+ growth_campaign: "A growth-focused campaign",
6754
+ cohort: "A group of users sharing a common characteristic",
6755
+ behavioral_segment: "A user segment based on behaviour",
6756
+ growth_loop: "A self-reinforcing growth cycle",
6757
+ variant: "A variant in an A/B test",
6758
+ attribution_model: "A model for attributing conversions to touchpoints",
6759
+ // Business Model
6760
+ business_model: "The business model canvas or definition",
6761
+ value_proposition: "A unique value offered to customers",
6762
+ revenue_stream: "A source of revenue",
6763
+ pricing_tier: "A pricing tier or plan",
6764
+ cost_structure: "A cost category or structure",
6765
+ unit_economics: "Per-unit economic metrics (CAC, LTV, etc.)",
6766
+ partnership: "A strategic partnership",
6767
+ key_resource: "A key resource required by the business",
6768
+ key_activity: "A key activity the business performs",
6769
+ target_customer_segment: "A target customer segment",
6770
+ customer_relationship: "A type of customer relationship",
6771
+ distribution_channel: "A channel for delivering value to customers",
6772
+ // Go-To-Market
6773
+ gtm_strategy: "A go-to-market strategy",
6774
+ ideal_customer_profile: "The ideal customer profile (ICP)",
6775
+ positioning: "Product positioning statement",
6776
+ messaging: "Messaging framework and key messages",
6777
+ launch: "A product launch event",
6778
+ content_strategy: "A content strategy for thought leadership",
6779
+ sales_motion: "A repeatable sales motion",
6780
+ competitive_battle_card: "A competitive battle card for sales enablement",
6781
+ demand_gen_program: "A demand generation program",
6782
+ territory: "A sales territory",
6783
+ objection: "A common sales objection",
6784
+ rebuttal: "A rebuttal to a sales objection",
6785
+ proof_point: "Evidence supporting a sales claim",
7271
6786
  // Team & Organisation
7272
- TEAM_OKR_LIFECYCLE,
7273
- RETROSPECTIVE_LIFECYCLE,
7274
- DEPENDENCY_LIFECYCLE,
7275
- ROLE_LIFECYCLE,
7276
- CAPACITY_PLAN_LIFECYCLE,
7277
- // Product & Growth
7278
- VARIANT_LIFECYCLE,
7279
- GROWTH_CAMPAIGN_LIFECYCLE,
6787
+ team: "A cross-functional team",
6788
+ role: "A role within a team",
6789
+ stakeholder: "A person with influence over the product",
6790
+ team_okr: "A team-level OKR",
6791
+ retrospective: "A team retrospective",
6792
+ dependency: "A cross-team or system dependency",
6793
+ department: "An organisational department",
6794
+ skill: "A skill or competency within a team",
6795
+ ceremony: "A recurring team ritual (standup, planning)",
6796
+ capacity_plan: "A plan for allocating team capacity",
6797
+ person: "A named individual (owner, stakeholder, or participant) referenced across the graph",
6798
+ // Data & Analytics
6799
+ data_source: "A data source or integration",
6800
+ event_schema: "An event schema for tracking",
6801
+ dashboard: "An analytics dashboard",
6802
+ data_model: "A data model or schema",
6803
+ data_quality_rule: "A data quality validation rule",
6804
+ data_product: "A curated, reusable data asset",
6805
+ data_pipeline: "An automated pipeline for data transformation",
6806
+ data_lineage: "A record of data origin and transformations",
6807
+ glossary_term: "A defined term for shared understanding",
6808
+ data_domain: "A logical grouping of related data assets",
6809
+ report: "A structured analytical report",
6810
+ // Customer Success
6811
+ support_ticket: "Customer support request or issue",
6812
+ customer_feedback: "Voice-of-customer input",
6813
+ churn_reason: "Why a customer left",
6814
+ customer_health_score: "A composite health score for a customer",
6815
+ playbook: "A standard operating procedure for CS",
6816
+ service_level_agreement: "A service level agreement with customers",
6817
+ customer_journey_stage: "A stage in the post-sale customer journey",
6818
+ touchpoint: "A customer interaction touchpoint",
6819
+ success_milestone: "A customer success milestone",
6820
+ service_blueprint: "A blueprint of the full service delivery",
6821
+ // Content & Knowledge
6822
+ content_piece: "A piece of content (article, video, etc.)",
6823
+ knowledge_base_article: "A knowledge base article",
6824
+ brand_asset: "A brand asset (logo, image, etc.)",
6825
+ internal_doc: "An internal documentation page",
6826
+ prompt_template: "A reusable prompt template",
6827
+ content_calendar: "A content publication calendar",
6828
+ content_theme: "A thematic grouping for content",
6829
+ documentation_template: "A template for documentation",
6830
+ document: "A general-purpose document",
6831
+ // Legal
6832
+ legal_entity: "A legal entity (company, subsidiary)",
6833
+ ip_asset: "An intellectual property asset",
6834
+ contract: "A legal contract",
6835
+ contract_clause: "A clause within a contract",
6836
+ privacy_policy: "A privacy policy",
6837
+ // Compliance
6838
+ compliance_requirement: "A compliance requirement",
6839
+ risk: "A risk to the product or business",
6840
+ data_contract: "A data-sharing contract",
6841
+ audit_log_policy: "An audit logging policy",
6842
+ compliance_framework: "A compliance framework (SOC 2, GDPR, etc.)",
6843
+ security_audit: "A security audit",
6844
+ // DevOps & Platform
6845
+ service_level_indicator: "A service level indicator (SLI)",
6846
+ service_level_objective: "A service level objective (SLO)",
6847
+ error_budget: "An error budget for a service",
6848
+ incident: "A production incident",
6849
+ postmortem: "A post-incident review",
6850
+ runbook: "A runbook for incident response",
6851
+ monitor: "A monitoring check",
6852
+ alert_rule: "An alerting rule",
6853
+ ci_pipeline: "A CI/CD pipeline",
6854
+ release_strategy: "A release strategy (canary, blue-green, etc.)",
6855
+ on_call_rotation: "An on-call rotation schedule",
6856
+ infrastructure_component: "An infrastructure component (server, CDN, etc.)",
6857
+ // Security
6858
+ threat_model: "A threat model for the system",
6859
+ threat: "A specific security threat",
6860
+ vulnerability: "A known vulnerability",
6861
+ security_control: "A security control or mitigation",
6862
+ security_policy: "A security policy",
6863
+ penetration_test: "A penetration test",
6864
+ security_review: "A security review",
6865
+ data_classification: "A data classification level",
6866
+ access_policy: "An access control policy",
6867
+ // Accessibility
6868
+ a11y_standard: "An accessibility standard (WCAG, Section 508)",
6869
+ a11y_guideline: "An accessibility guideline",
6870
+ a11y_audit: "An accessibility audit",
6871
+ a11y_issue: "An accessibility issue",
6872
+ a11y_annotation: "An accessibility annotation on a design",
6873
+ // Quality Assurance
6874
+ test_suite: "A suite of related tests",
6875
+ test_case: "An individual test case",
6876
+ qa_session: "An exploratory QA session",
6877
+ regression_test: "A regression test",
6878
+ test_coverage_report: "A test coverage report",
6879
+ test_environment: "A testing environment",
6880
+ test_result: "A test execution result",
6881
+ // Customer Feedback
6882
+ feedback_program: "A structured feedback collection program",
6883
+ feature_request: "A user-submitted feature request",
6884
+ feedback_vote: "A vote on a feature request or feedback item",
6885
+ nps_campaign: "A Net Promoter Score survey campaign",
6886
+ user_advisory_board: "A panel of users providing ongoing feedback",
6887
+ beta_program: "A beta testing program",
6888
+ feedback_theme: "A recurring theme across feedback items",
6889
+ // Pricing & Packaging
6890
+ pricing_strategy: "An overarching pricing strategy",
6891
+ package: "A bundled package of features at a price point",
6892
+ discount_strategy: "A strategy for offering discounts",
6893
+ trial_config: "Configuration for a free trial",
6894
+ paywall: "A paywall gating premium features",
6895
+ // AI & Machine Learning
6896
+ ai_model: "An AI or ML model used within the product",
6897
+ prompt_version: "A version of a prompt template",
6898
+ eval_benchmark: "A benchmark for evaluating AI quality",
6899
+ eval_run: "An evaluation run against a benchmark",
6900
+ ai_cost_tracker: "A tracker for AI inference costs",
6901
+ hallucination_report: "A report of an AI hallucination",
6902
+ ai_guardrail: "A guardrail for AI safety",
6903
+ model_comparison: "A comparison between AI models",
6904
+ ai_experiment: "An AI-focused experiment",
6905
+ ai_dataset: "A dataset for AI training or evaluation",
6906
+ ai_trace: "An AI inference trace",
6907
+ // Workflows & Agents
6908
+ workflow_template: "A reusable workflow template",
6909
+ workflow_run: "An execution of a workflow",
6910
+ agent_definition: "An autonomous agent definition",
6911
+ agent_session: "An agent working session",
6912
+ review_gate: "A human review checkpoint in a workflow",
6913
+ approval_record: "A record of an approval decision",
6914
+ agent_skill: "A capability of an agent",
6915
+ agent_hook: "A trigger connecting an agent to an event",
6916
+ workflow_artifact: "An output artifact from a workflow run",
6917
+ agent_task: "A discrete unit of agent work",
6918
+ // Portfolio
6919
+ organization: "The top-level organisational entity",
6920
+ portfolio: "A grouping of products by strategic axis",
6921
+ product_area: "A grouping of products by organisational axis",
6922
+ // Sales & Revenue
6923
+ account: "A customer account",
6924
+ contact: "A person within an account",
6925
+ lead: "An inbound lead",
6926
+ deal: "An active sales opportunity",
6927
+ pipeline_sales: "A sales pipeline",
6928
+ pipeline_stage: "A stage in the sales pipeline",
6929
+ quote_document: "A formal quote document",
6930
+ subscription: "A recurring subscription",
6931
+ invoice: "An invoice for billing",
6932
+ forecast: "A revenue forecast",
6933
+ // Program Management
6934
+ program: "A program coordinating multiple projects",
6935
+ project: "A project within a program",
6936
+ milestone: "A key date or achievement",
6937
+ risk_register: "A register of project risks",
6938
+ change_request: "A request to change project scope",
6939
+ deliverable: "A deliverable from a project",
6940
+ resource_allocation: "An allocation of team capacity",
6941
+ status_report: "A project status report",
6942
+ // Marketing
6943
+ marketing_strategy: "A marketing strategy",
6944
+ marketing_channel: "A marketing channel",
6945
+ marketing_campaign_plan: "A marketing campaign plan",
6946
+ email_sequence: "An email nurture sequence",
6947
+ social_post: "A social media post",
6948
+ seo_keyword: "An SEO keyword target",
6949
+ ad_creative: "An ad creative",
6950
+ press_release: "A press release",
6951
+ event: "A marketing event",
6952
+ community_initiative: "A community engagement initiative",
6953
+ // Localisation
6954
+ locale: "A supported locale (language + region)",
6955
+ translation_key: "A translatable string key",
6956
+ translation_bundle: "A bundle of translation keys",
6957
+ locale_config: "Per-locale configuration settings",
6958
+ cultural_adaptation: "A region-specific cultural adaptation",
6959
+ regional_pricing: "Location-based pricing",
6960
+ // Customer Education
6961
+ education_program: "A customer education program",
6962
+ tutorial: "A step-by-step tutorial",
6963
+ walkthrough: "A guided product walkthrough",
6964
+ webinar: "A live or recorded webinar",
6965
+ certification: "A certification program",
6966
+ help_video: "A help video",
6967
+ learning_path: "A structured learning path",
6968
+ // Partners & Ecosystem
6969
+ partner_program: "A partner program",
6970
+ partner_tier: "A partner tier level",
6971
+ api_ecosystem: "An API ecosystem",
6972
+ marketplace_listing: "A marketplace listing",
6973
+ developer_portal: "A developer portal",
6974
+ integration_partner: "An integration partner",
6975
+ partner_revenue_share: "A partner revenue sharing arrangement",
6976
+ // Foundations
6977
+ operating_lifecycle: "A canonical, ordered (often cyclic) operating process a product's journey phases map onto",
6978
+ operating_stage: "One ordered stage of an operating_lifecycle",
6979
+ specification: "A canonical open standard or specification that primitives and products conform to",
6980
+ primitive: "A canonical reusable building block defined by a specification",
7280
6981
  // Workspace
7281
- FRAMEWORK_EXERCISE_LIFECYCLE,
7282
- COMPOSITION_LIFECYCLE,
7283
- // ── Template-generated lifecycles ─────────────────────────────────
7284
- ...TEMPLATE_LIFECYCLES
6982
+ workspace: "A spatial thinking space for arranging entities",
6983
+ framework_exercise: "A recorded run of a product framework (RICE, OST, and the like) over specific entities, holding its inputs and outputs",
6984
+ composition: "A published arrangement of graph entities that has an identity of its own: a gallery, a board, a deck. Membership can be derived by running its query, position is authored by a person, and both are stored because both are real.",
6985
+ capture: "A dated, hashed rendition of something already in the graph: a screenshot of a surface, a PDF of a report, an export of a canvas. The subject stays a graph node; the capture records what it looked like at one moment, and the content hash says whether it still does."
6986
+ });
6987
+ function getEntityDescription(type) {
6988
+ return UPG_ENTITY_DESCRIPTIONS[type];
6989
+ }
6990
+
6991
+ // src/shapes/base-node.ts
6992
+ var BASE_NODE_FIELD_PRESENCE = {
6993
+ id: true,
6994
+ type: true,
6995
+ title: true,
6996
+ slug: true,
6997
+ aliases: true,
6998
+ key: true,
6999
+ description: true,
7000
+ tags: true,
7001
+ status: true,
7002
+ archived: true,
7003
+ archived_at: true,
7004
+ source_id: true,
7005
+ source_type: true,
7006
+ mapping_confidence: true,
7007
+ external_tool: true,
7008
+ external_ref: true,
7009
+ external_id: true,
7010
+ external_links: true,
7011
+ created_at: true,
7012
+ updated_at: true,
7013
+ properties: true
7014
+ };
7015
+ var UPG_BASE_NODE_FIELDS = Object.freeze(
7016
+ Object.keys(BASE_NODE_FIELD_PRESENCE)
7017
+ );
7018
+ var UPG_BASE_NODE_FIELD_SET = new Set(UPG_BASE_NODE_FIELDS);
7019
+ var UPG_BASE_NODE_SPECIAL_MERGE_FIELDS = /* @__PURE__ */ new Set([
7020
+ "id",
7021
+ "type",
7022
+ "slug",
7023
+ "aliases",
7024
+ "properties"
7025
+ ]);
7026
+
7027
+ // src/shapes/document.ts
7028
+ var UPG_CROSS_ONLY_EDGE_TYPES = [
7029
+ // Peer overlap: "these two products share / overlap on this thing." Symmetric,
7030
+ // no canonical instance_of identity. shares_job / shares_need are the job/need
7031
+ // siblings of the persona/competitor/metric peers (connective layer, 0.13.1).
7032
+ "shares_persona",
7033
+ "shares_competitor",
7034
+ "shares_metric",
7035
+ "shares_job",
7036
+ "shares_need",
7037
+ // Product-to-product relationships.
7038
+ "depends_on_product",
7039
+ // runtime dependency (built-on / dogfood), not containment
7040
+ "cannibalises",
7041
+ "succeeds",
7042
+ "hosts",
7043
+ // host runs the hosted product inside itself (container -> contained)
7044
+ // OKR / measurement rollup primitives: the cascade ACROSS products (subordinate
7045
+ // -> superior). `contributes_to` rolls a product strategy entity up to a higher-
7046
+ // level one; `rolls_up_to` feeds a product metric into a higher-level north-star.
7047
+ "contributes_to",
7048
+ "rolls_up_to",
7049
+ // Canonical instance + area-to-audience: the target lives in the portfolio
7050
+ // `registry` section (`registry/{node_id}`). `instance_of` is same-type
7051
+ // canonical-to-instance; the area edges are minted via `link_area_to_audience`.
7052
+ "instance_of",
7053
+ "area_serves_persona",
7054
+ "area_targets_market_segment",
7055
+ // Foundations (0.9.12): a product-graph entity links to a canonical specification
7056
+ // or primitive. Registry-internal spec-to-spec links are catalog edges, not these.
7057
+ //
7058
+ // CORRECTED 0.34.0 — the target contract. This comment said `registry/{node_id}`,
7059
+ // "same shape as instance_of". Every live instance disagrees: all three in the
7060
+ // field target `{product_id}/{node_id}`, and the portfolio's `registry` section
7061
+ // is EMPTY. A reader following the old sentence would look for a registry entry
7062
+ // that has never existed. Both target forms are legitimate — a specification held
7063
+ // as a canonical in the registry, or one held inside the product graph that owns
7064
+ // it — and the field has so far only produced the second.
7065
+ //
7066
+ // THE GAP THIS TIER LEAVES, restated 0.34.0 because the 0.33.0 wording named a
7067
+ // case no graph instantiates. It is NOT "a specification in a graph with no
7068
+ // portfolio around it". It is the HOLDER PRODUCT, and it is live today: the
7069
+ // product graph that HOLDS a specification node has three sibling products
7070
+ // reaching it through this tier and no way to state its own relation to it,
7071
+ // because the cross tier requires two distinct products and there is no
7072
+ // within-graph conformance edge. Not closed in 0.34.0. The verb the live case
7073
+ // wants is `defines` rather than `conforms_to` — a product does not conform to
7074
+ // the specification it authors — and one instance of evidence is not enough to
7075
+ // mint a catalog edge in the area that cost 0.33.0 its shape mid-build. The
7076
+ // condition is the second holder-product instance, or any single-product graph
7077
+ // modelling a specification it conforms to.
7078
+ "product_implements_specification",
7079
+ "product_exposes_specification",
7080
+ "feature_conforms_to_specification",
7081
+ "api_contract_speaks_specification",
7082
+ "product_exposes_primitive",
7083
+ "feature_manipulates_primitive",
7084
+ "primitive_stored_as_data_type"
7285
7085
  ];
7286
- function getLifecycleForType(entityType) {
7287
- return UPG_LIFECYCLES.find((l) => l.entity_type === entityType);
7086
+ var UPG_CROSS_EDGE_TYPES = [
7087
+ ...UPG_CROSS_ONLY_EDGE_TYPES,
7088
+ ...UPG_CROSS_ELIGIBLE_CATALOG_EDGE_TYPES
7089
+ ];
7090
+ var REGISTRY_PRODUCT_ID = "registry";
7091
+ var UPG_PORTFOLIO_KINDS = ["owned", "watched", "strategic", "internal", "gtm"];
7092
+
7093
+ // src/registry/entity-type-resolution.ts
7094
+ var TYPES = getTypes();
7095
+ var TYPES_SET = new Set(TYPES);
7096
+ var UnknownEntityTypeError = class extends Error {
7097
+ suggestions;
7098
+ rawType;
7099
+ constructor(rawType, suggestions) {
7100
+ const suffix = suggestions.length > 0 ? ` Did you mean: ${suggestions.join(", ")}?` : "";
7101
+ super(`Unknown entity type: "${rawType}".${suffix}`);
7102
+ this.name = "UnknownEntityTypeError";
7103
+ this.rawType = rawType;
7104
+ this.suggestions = suggestions;
7105
+ }
7106
+ };
7107
+ function withinEditDistance1(a, b) {
7108
+ if (a === b) return true;
7109
+ const al = a.length;
7110
+ const bl = b.length;
7111
+ if (Math.abs(al - bl) > 1) return false;
7112
+ let i = 0;
7113
+ let j = 0;
7114
+ let edits = 0;
7115
+ while (i < al && j < bl) {
7116
+ if (a[i] !== b[j]) {
7117
+ if (++edits > 1) return false;
7118
+ if (al > bl) i++;
7119
+ else if (bl > al) j++;
7120
+ else {
7121
+ i++;
7122
+ j++;
7123
+ }
7124
+ } else {
7125
+ i++;
7126
+ j++;
7127
+ }
7128
+ }
7129
+ if (i < al || j < bl) edits++;
7130
+ return edits <= 1;
7131
+ }
7132
+ function resolveEntityType(rawType) {
7133
+ if (typeof rawType !== "string" || rawType.length === 0) {
7134
+ throw new UnknownEntityTypeError(String(rawType ?? ""), []);
7135
+ }
7136
+ if (TYPES_SET.has(rawType)) {
7137
+ return { canonical: rawType };
7138
+ }
7139
+ const replacement = getReplacementType(rawType);
7140
+ if (replacement && TYPES_SET.has(replacement)) {
7141
+ return { canonical: replacement, alias: { from: rawType, to: replacement } };
7142
+ }
7143
+ const suggestions = [];
7144
+ for (const t of TYPES) {
7145
+ if (withinEditDistance1(t, rawType)) suggestions.push(t);
7146
+ if (suggestions.length >= 5) break;
7147
+ }
7148
+ throw new UnknownEntityTypeError(rawType, suggestions);
7288
7149
  }
7289
- var UPG_LIFECYCLE_FREE_TYPES = /* @__PURE__ */ new Set([
7290
- // ── Foundations (3 of 4): a primitive either exists or is deprecated; no
7291
- // phase ladder (like metric). `operating_lifecycle`/`operating_stage` are
7292
- // static ordered reference data (the loop is a `cyclic` flag, not a state
7293
- // machine). `specification` carries a lifecycle. ──
7294
- "primitive",
7295
- "operating_lifecycle",
7296
- "operating_stage",
7297
- // ── User (5): personas and JTBD atoms are reference data ──────────────────
7298
- "persona",
7299
- "job",
7300
- "job_step",
7301
- "desired_outcome",
7302
- "switching_cost",
7303
- // ── Market Intelligence (7 of 8): competitor landscape is reference data;
7304
- // competitor_signal is an append-only dated event (no phase ladder);
7305
- // competitive_analysis shipped PUBLISHING lifecycle in Phase C;
7306
- // classification_axis and classification_value are reference taxonomy
7307
- // atoms with no state machine. ─
7308
- "competitor",
7309
- "competitor_feature",
7310
- "competitor_signal",
7311
- "market_trend",
7312
- "market_segment",
7313
- "classification_axis",
7314
- "classification_value",
7315
- // ── Product Specification (1): a configuration_axis is a structural
7316
- // DECLARATION (a lever and its closed value set), not a thing that
7317
- // progresses through states. Same reading as classification_axis above.
7318
- "configuration_axis",
7319
- // ── User Research (5 of 8): participants, quotes, observations,
7320
- // clusters, survey responses are immutable data points ────────────────
7321
- "participant",
7322
- "observation",
7323
- "quote",
7324
- "affinity_cluster",
7325
- "survey_response",
7326
- // ── UX Design (3 of 8): journey structural atoms ──────────────────────────
7327
- "journey_step",
7328
- "journey_phase",
7329
- "journey_action",
7330
- "screen_state",
7331
- // ── Design System (3 of 7): tokens and annotations are atomic values ────
7332
- "design_token",
7333
- "annotation",
7334
- // ── Brand (4 of 6): colour/typography/imagery/voice are reference atoms ──
7335
- "brand_colour",
7336
- "brand_typography",
7337
- "brand_imagery",
7338
- // ── Product Specification (4 of 5): criteria, grouping, historical, +
7339
- // user_story (the templated promise is a stable design artefact; the paired
7340
- // task carries the lifecycle). Re-canon story_statement → user_story at
7341
- // v0.7.0/UPG-571. ─
7342
- "acceptance_criterion",
7343
- "changelog",
7344
- "roadmap_theme",
7345
- "user_story",
7346
- // ── Strategy: metric is a measurement definition; metric_quality_assessment
7347
- // is a point-in-time snapshot; value_stream is a mapped flow;
7348
- // constraint carries its own `constraint_status` enum (binding/advisory/
7349
- // lifted) as a property; base-node `status` not used.
7350
- // vision/mission/capability/outcome get lifecycles in Phase B or C ─────
7351
- "metric",
7352
- "metric_quality_assessment",
7353
- "value_stream",
7354
- "constraint",
7355
- // ── Engineering (15 of 17): DDD modelling primitives + infra references.
7356
- // root_cause / symptom / fix are investigation findings, not workflows
7357
- // (investigation itself has a lifecycle) ────────────────────────────────
7358
- "aggregate",
7359
- "domain_entity",
7360
- "value_object",
7361
- "command",
7362
- "read_model",
7363
- "domain_event",
7364
- "bounded_context",
7365
- "api_endpoint",
7366
- "queue_topic",
7367
- "build_artifact",
7368
- "code_repository",
7369
- "library_dependency",
7370
- "integration_pattern",
7371
- "data_flow",
7372
- "root_cause",
7373
- "symptom",
7374
- "fix",
7375
- // ── Business Model (6 of 9): BMC cells are structural frames ────────────
7376
- "cost_structure",
7377
- "unit_economics",
7378
- "key_resource",
7379
- "key_activity",
7380
- "customer_relationship",
7381
- "distribution_channel",
7382
- // ── Go-To-Market (8 of 13): positioning/ICP/territory/sales_motion are
7383
- // configuration; objection/rebuttal/proof_point are catalog entries ───
7384
- "ideal_customer_profile",
7385
- "positioning",
7386
- "sales_motion",
7387
- "territory",
7388
- "objection",
7389
- "rebuttal",
7390
- "proof_point",
7391
- // ── Team & Organisation (7 of 11): org structural atoms ───────────────────
7392
- "team",
7393
- "stakeholder",
7150
+
7151
+ // src/grammar/hierarchy.ts
7152
+ var UPG_VALID_CHILDREN = {
7153
+ // ── Foundations (0.9.12): registry canonicals that self-nest. A
7154
+ // specification extends a specification (a dialect of a parent spec); a
7155
+ // primitive composes primitives (a block contains spans). These back the
7156
+ // hierarchy-classified specification_extends_specification /
7157
+ // primitive_composes_primitive catalog edges.
7158
+ specification: ["specification"],
7159
+ primitive: ["primitive"],
7160
+ // An operating_lifecycle (e.g. the content-ops lifecycle) contains its ordered
7161
+ // operating_stage children. Backs the operating_lifecycle_contains_operating_stage edge.
7162
+ operating_lifecycle: ["operating_stage"],
7163
+ // ── Product (root) ─────────────────────────────────────────────────────────
7164
+ product: [
7165
+ // Strategy
7166
+ "vision",
7167
+ "outcome",
7168
+ "objective",
7169
+ "metric",
7170
+ "decision",
7171
+ "constraint",
7172
+ // User
7173
+ "persona",
7174
+ // Discovery (via outcome children)
7175
+ // Validation (via hypothesis children)
7176
+ // Market Intelligence
7177
+ "competitor",
7178
+ "market_trend",
7179
+ "market_segment",
7180
+ "competitive_analysis",
7181
+ // User Research
7182
+ "research_study",
7183
+ // Experience Design
7184
+ "user_journey",
7185
+ "user_flow",
7186
+ "wireframe",
7187
+ "screen",
7188
+ // Design System
7189
+ "design_system",
7190
+ "design_component",
7191
+ // Brand Identity
7192
+ "brand_identity",
7193
+ // Product Specification
7194
+ "feature",
7195
+ "feature_area",
7196
+ "release",
7197
+ "roadmap",
7198
+ "roadmap_theme",
7199
+ "planning_cycle",
7200
+ // Configuration (0.30.0): the levers whose values select which surface tree
7201
+ // the product renders. Few per product, and top-level because an axis is a
7202
+ // product-wide fact rather than a child of any one feature or surface.
7203
+ "configuration_axis",
7204
+ // Classification (0.32.0): the product's own taxonomies — the grouped-label
7205
+ // case, one named group over a set of values. Same reasoning as the
7206
+ // configuration axis above, and until now the only parent a
7207
+ // classification_axis could have was a competitive_analysis.
7208
+ "classification_axis",
7209
+ // Engineering
7210
+ "bounded_context",
7211
+ "code_repository",
7212
+ "integration_pattern",
7213
+ "external_api",
7214
+ "data_flow",
7215
+ // Growth
7216
+ "funnel",
7217
+ "acquisition_channel",
7218
+ "cohort",
7219
+ "behavioral_segment",
7220
+ "growth_loop",
7221
+ "attribution_model",
7222
+ // Business Model
7223
+ "business_model",
7224
+ // Go-To-Market
7225
+ "gtm_strategy",
7226
+ // Team & Organisation
7227
+ // `person` is containment-free (see UPG_CONTAINMENT_FREE_TYPES below)
7228
+ // (referenced via edges, not nested under product)
7229
+ "team",
7230
+ "stakeholder",
7231
+ "department",
7232
+ // Data & Analytics
7233
+ "data_source",
7234
+ "event_schema",
7235
+ "dashboard",
7236
+ "data_domain",
7237
+ "glossary_term",
7238
+ // Content & Knowledge
7239
+ "content_piece",
7240
+ "knowledge_base_article",
7241
+ "brand_asset",
7242
+ "document",
7243
+ "documentation_template",
7244
+ // Legal
7245
+ "legal_entity",
7246
+ "privacy_policy",
7247
+ // Compliance
7248
+ "compliance_requirement",
7249
+ "risk",
7250
+ "data_contract",
7251
+ "audit_log_policy",
7252
+ "compliance_framework",
7253
+ // DevOps & Platform
7254
+ "service_level_objective",
7255
+ "incident",
7256
+ "runbook",
7257
+ "monitor",
7258
+ "ci_pipeline",
7259
+ "release_strategy",
7260
+ "on_call_rotation",
7261
+ "infrastructure_component",
7262
+ // Security
7263
+ "threat_model",
7264
+ "security_control",
7265
+ "security_policy",
7266
+ "penetration_test",
7267
+ "security_review",
7268
+ "data_classification",
7269
+ "access_policy",
7270
+ // Accessibility
7271
+ "a11y_standard",
7272
+ "a11y_audit",
7273
+ "a11y_annotation",
7274
+ // Quality Assurance
7275
+ "test_plan",
7276
+ "test_suite",
7277
+ "qa_session",
7278
+ "test_coverage_report",
7279
+ "test_environment",
7280
+ // Customer Feedback
7281
+ "feedback_program",
7282
+ "user_advisory_board",
7283
+ "beta_program",
7284
+ // Pricing & Packaging
7285
+ "pricing_strategy",
7286
+ // AI & Machine Learning
7287
+ "ai_model",
7288
+ "model_comparison",
7289
+ // Workflows & Agents
7290
+ "workflow_template",
7291
+ "agent_definition",
7292
+ // Sales & Revenue
7293
+ "pipeline_sales",
7294
+ "account",
7295
+ "lead",
7296
+ "subscription",
7297
+ "forecast",
7298
+ // Program Management
7299
+ // `milestone` is a SECOND, shallower parent here (Portfolio Phase 2,
7300
+ // 2026-08-14), alongside its existing `project` parent: a product can own a
7301
+ // milestone outright with no program/project above it. Required by the
7302
+ // hierarchy-orphan guard now that `product_targets_milestone` exists.
7303
+ "program",
7304
+ "milestone",
7305
+ // Marketing
7306
+ "marketing_strategy",
7307
+ "press_release",
7308
+ "event",
7309
+ "community_initiative",
7310
+ // Customer Success
7311
+ "support_ticket",
7312
+ "customer_feedback",
7313
+ "churn_reason",
7314
+ "customer_health_score",
7315
+ "playbook",
7316
+ "service_level_agreement",
7317
+ "success_milestone",
7318
+ "service_blueprint",
7319
+ "nps_campaign",
7320
+ // Localisation
7321
+ "locale",
7322
+ "locale_config",
7323
+ // Customer Education
7324
+ "education_program",
7325
+ // Partners & Ecosystem
7326
+ "partner_program",
7327
+ "api_ecosystem",
7328
+ "developer_portal",
7329
+ // Portfolio
7330
+ // (UPG-677) product no longer lists product_area as a child: the
7331
+ // product↔product_area containment is the single direction
7332
+ // product_area_contains_product (product_area → product). The inverse
7333
+ // product_categorised_in_product_area edge was collapsed.
7334
+ // Workspace
7335
+ "workspace"
7336
+ ],
7337
+ // ── Metric & Outcome hierarchy ──────────────────────────────────────────────
7338
+ outcome: ["metric", "opportunity", "feature"],
7339
+ // ── User & Jobs hierarchy ───────────────────────────────────────────────────
7340
+ persona: ["job", "need", "switching_cost", "desired_outcome"],
7341
+ job: ["need", "desired_outcome", "job_step"],
7342
+ // ── Discovery hierarchy ─────────────────────────────────────────────────────
7343
+ opportunity: ["solution", "design_concept", "feasibility_study", "design_sprint"],
7344
+ // solutions now propose hypothesis (the templated
7345
+ // belief), not the legacy hypothesis type.
7346
+ solution: ["hypothesis", "prototype", "metric"],
7347
+ // ── Validation hierarchy ────────────────────────────────────────────────────
7348
+ // (UPG-664) The validation chain is a single-parent line:
7349
+ // hypothesis ▷ experiment_plan ▷ experiment ▷ experiment_run.
7350
+ // hypothesis is canonical (hypothesis_evidence collapsed into evidence;
7351
+ // relationship expressed via hypothesis_has_evidence edge; evidence.direction
7352
+ // carries supports/refutes/neutral semantics). `test_plan` re-homed to the
7353
+ // QA/testing domain (UPG-678), so it is no longer a hypothesis child.
7354
+ hypothesis: ["experiment_plan", "research_plan", "evidence"],
7355
+ // experiment_plan is the canonical validation PLAN (graduated stable,
7356
+ // UPG-664). It designs the experiment it produces; the plan owns the
7357
+ // experiment in the containment line. It also retains experiment_run as a
7358
+ // child for the v0.2.6 split-migration path
7359
+ // (`experiment_plan_ran_as_experiment_run`), where a legacy experiment routes
7360
+ // directly to a plan + run pair.
7361
+ experiment_plan: ["experiment", "experiment_run"],
7362
+ // experiment is the canonical structured test. It owns its run(s) and the
7363
+ // learning/evidence it produces. The optional experiment_run child captures
7364
+ // the multi-run / replication case.
7365
+ experiment: ["experiment_run", "learning", "evidence"],
7366
+ // experiment_run carries learning/evidence/metric children (run produces
7367
+ // evidence) and self-nests for replications/multi-armed runs (V9: this is
7368
+ // where self-nesting genuinely lives, not on `experiment`).
7369
+ experiment_run: ["learning", "evidence", "metric", "experiment_run"],
7370
+ // ── OKR hierarchy ──────────────────────────────────────────────────────────
7371
+ // strategic_question (0.17.4): an open coordination question raised under an
7372
+ // objective (objective_raises_strategic_question, hierarchy).
7373
+ objective: ["key_result", "metric", "strategic_question"],
7374
+ key_result: ["metric"],
7375
+ // ── Strategic cascade: vision → mission → strategic_pillar → strategic_theme →
7376
+ // { initiative, objective } ───────────────────────────────────────────────
7377
+ //
7378
+ // strategic_pillar vs strategic_theme (UPG-692 T3.3 — distinct cascade levels,
7379
+ // NOT duplicates; sharpened rather than merged):
7380
+ // - strategic_pillar = a DURABLE structural division of the strategy. A
7381
+ // standing area the org organises around for years (e.g. "Structured
7382
+ // content", "Developer experience"). Few, long-lived; time_horizon is
7383
+ // multi-year / open-ended; carries its own `success_indicator`.
7384
+ // - strategic_theme = a TIME-BOUND thrust WITHIN a pillar. The current bet
7385
+ // for a period (e.g. "Go AI-native this year"). More numerous, rotates;
7386
+ // time_horizon is bounded (Q / FY); has NO `success_indicator` because it
7387
+ // is measured through its child objectives (strategic_theme_contains_objective).
7388
+ // That success-measurement asymmetry is the load-bearing distinction.
7389
+ vision: ["mission"],
7390
+ mission: ["strategic_pillar"],
7391
+ // 0.20.1: metric added as a strategic_pillar child, backing
7392
+ // strategic_pillar_measured_by_metric (hierarchy) — the pillar's own
7393
+ // north-star, mirrored from objective: ['key_result', 'metric', ...] one
7394
+ // level down the cascade.
7395
+ strategic_pillar: ["strategic_theme", "capability", "value_stream", "decision", "metric"],
7396
+ // v0.5.4 (UPG-511): objectives are the specific quarterly bets *within* a
7397
+ // strategic theme. The theme is the multi-quarter focus area; objectives are
7398
+ // subordinate. Pairs with `strategic_theme_contains_objective` in the edge
7399
+ // catalog (hierarchy, strategic_theme → objective, reverse_verb: rolls_up_to;
7400
+ // renamed from objective_rolls_up_to_strategic_theme in UPG-676).
7401
+ strategic_theme: ["initiative", "objective"],
7402
+ initiative: ["assumption", "strategic_question"],
7403
+ // v0.5.2 (UPG-528): capability decomposes into sub-capabilities (Wardley
7404
+ // value-chain spine) and is realised by user-facing features. Pairs with
7405
+ // `capability_depends_on_capability` and `capability_implemented_by_feature`
7406
+ // in the edge catalogue. The self-loop guard (UPG-520) keeps A → A refused;
7407
+ // A → B between distinct capabilities is the supported decomposition.
7408
+ capability: ["capability", "feature"],
7409
+ // ── Market hierarchy ────────────────────────────────────────────────────────
7410
+ // competitive_analysis hosts classification axes (its dimensions);
7411
+ // each axis hosts its values; values are reusable across the row and column
7412
+ // dossiers of a 2-axis matrix.
7413
+ competitive_analysis: ["competitor", "market_trend", "market_segment", "classification_axis"],
7414
+ competitor: ["competitor_feature", "competitor_signal"],
7415
+ classification_axis: ["classification_value"],
7416
+ // ── UX Research hierarchy ───────────────────────────────────────────────────
7417
+ // (0.35.0) 'quote' added: a study is the provenance parent of the verbatim
7418
+ // quotes it captured, pairing with `research_study_captures_quote`. A quote
7419
+ // now has three declared parents — observation (raw capture), insight
7420
+ // (synthesis) and research_study (provenance) — which is multi-parent
7421
+ // GRAMMAR; per-instance parentage stays single via `parent_id`.
7422
+ research_study: [
7423
+ "participant",
7424
+ "observation",
7425
+ "affinity_cluster",
7426
+ "research_question",
7427
+ "interview_guide",
7428
+ "insight",
7429
+ "survey_response",
7430
+ "quote"
7431
+ ],
7432
+ observation: ["quote"],
7433
+ // F6 (UPG-672): affinity_cluster owns the observations it groups, in addition
7434
+ // to the insights it synthesises. Pairs with `affinity_cluster_groups_observation`
7435
+ // in the edge catalog (hierarchy). An observation can be both directly owned by
7436
+ // its research_study and grouped under an affinity_cluster (multi-parent grammar).
7437
+ affinity_cluster: ["insight", "observation"],
7438
+ // insight refines into insight; a raw insight can be distilled
7439
+ // into a more specific insight (refines_into chain).
7440
+ // v0.5.8 (UPG-528 Part 2d): insights own their evidencing quotes;
7441
+ // parallel to `observation: ['quote']`. Research-synthesis canon.
7442
+ // Pairs with `insight_evidenced_by_quote` in the edge catalog.
7443
+ // ── Design hierarchy ────────────────────────────────────────────────────────
7444
+ // (UPG-663, v0.9.2) A user_journey owns its steps (the stable 0.1.0 spine)
7445
+ // and carries phases as a non-owning band overlay. A journey_phase is NO
7446
+ // LONGER a containment parent of journey_step: it SPANS steps via the
7447
+ // `journey_phase_spans_journey_step` edge (mirroring the marketing
7448
+ // `customer_journey_stage_spans_journey_step` precedent), so each step has
7449
+ // exactly one containment parent and the journey has one canonical step list.
7450
+ user_journey: ["journey_step", "journey_phase"],
7451
+ journey_step: ["journey_action"],
7452
+ // v0.5.8 (UPG-528 Part 2d): insights own their evidencing quotes;
7453
+ // parallel to `observation: ['quote']`. Research-synthesis canon
7454
+ // (insight ← quote evidencing) extends quote's hierarchy parents to
7455
+ // both observation (raw-capture parent) and insight (synthesis parent).
7456
+ // Pairs with `insight_evidenced_by_quote` in the edge catalog.
7457
+ insight: ["design_question", "insight", "quote"],
7458
+ // v0.5.2 (UPG-528): need anchors a Wardley value chain; capabilities
7459
+ // fulfil the need at the chain top. Cross-domain hierarchy (need ∈ Design,
7460
+ // capability ∈ Strategy) is intentional: Wardley analysis starts from a
7461
+ // user need and decomposes into the capabilities required to fulfil it.
7462
+ need: ["design_question", "capability"],
7463
+ design_question: ["design_concept"],
7464
+ design_concept: ["prototype", "wireframe"],
7465
+ design_component: [
7466
+ "design_token",
7467
+ "design_pattern",
7468
+ "design_guideline",
7469
+ "interaction_spec",
7470
+ "design_component"
7471
+ ],
7472
+ // self-nesting for atomic hierarchy (organism → molecule → atom)
7473
+ prototype: ["annotation"],
7474
+ // ── Brand hierarchy ─────────────────────────────────────────────────────────
7475
+ brand_identity: [
7476
+ "brand_colour",
7477
+ "brand_typography",
7478
+ "brand_asset",
7479
+ "brand_voice",
7480
+ "brand_logo",
7481
+ "brand_imagery"
7482
+ ],
7483
+ // ── Product Specification hierarchy ─────────────────────────────────────────
7484
+ // story_task collapsed into canonical task. feature now owns
7485
+ // task directly; story-derived tasks implement user_story via
7486
+ // task_implements_user_story edge.
7487
+ // (0.35.0) 'user_story' added, pairing with `feature_specified_by_user_story`.
7488
+ // The epic rung is optional in UPG, so a feature that skips it could not
7489
+ // reach the stories that specify it and `user_story` had a single declared
7490
+ // parent. Same widening shape as the 0.23.0 epic twins: an existing leaf type
7491
+ // gains a second, SHALLOWER parent, verbs inherited from the deeper edge.
7492
+ feature: ["epic", "bug", "task", "user_story"],
7493
+ feature_area: ["feature", "feature_area"],
7494
+ // epic owns user_story (the templated promise) and, mirroring feature, may
7495
+ // also directly contain bug/task — heterogeneous imported tickets that belong
7496
+ // to one epic rather than the feature as a whole (feedback df99026a).
7497
+ epic: ["user_story", "bug", "task"],
7498
+ user_story: ["acceptance_criterion"],
7499
+ task: ["task"],
7500
+ // planning_cycle (0.20.0): the cadence axis self-nests (a program-increment
7501
+ // contains iterations; a cycle contains its cooldown) via
7502
+ // planning_cycle_contains_planning_cycle. It does NOT contain user_story as a
7503
+ // child: scheduling work into a cycle is the semantic, deliberate-only
7504
+ // planning_cycle_schedules_work_item edge, so the item keeps its feature/epic
7505
+ // containment parent and is merely referenced by the cycle.
7506
+ planning_cycle: ["planning_cycle"],
7507
+ // ── Engineering hierarchy ───────────────────────────────────────────────────
7508
+ bounded_context: [
7509
+ "service",
7510
+ "domain_event",
7511
+ "decision",
7512
+ "data_model",
7513
+ "aggregate",
7514
+ "read_model",
7515
+ "code_repository",
7516
+ "integration_pattern",
7517
+ "external_api",
7518
+ "data_flow",
7519
+ // v0.5.7 (UPG-528 Part 2c): BCs publish api_contracts as their "published
7520
+ // language" (DDD canon). api_contract has two valid hierarchy parents now:
7521
+ // service (per-service exposure) AND bounded_context (BC-level surface).
7522
+ "api_contract"
7523
+ ],
7524
+ service: [
7525
+ "api_contract",
7526
+ "technical_debt_item",
7527
+ "feature_flag",
7528
+ "deployment",
7529
+ "api_endpoint",
7530
+ "database_schema",
7531
+ "queue_topic",
7532
+ "build_artifact",
7533
+ "library_dependency"
7534
+ ],
7535
+ // v0.5.1 (UPG-517 C2): contracts contain their endpoints. Service still
7536
+ // serves endpoints directly (legacy / non-contract endpoints); both
7537
+ // parent-child paths coexist.
7538
+ api_contract: ["api_endpoint"],
7539
+ decision: ["technical_debt_item"],
7540
+ aggregate: ["domain_entity", "value_object", "command"],
7541
+ // ── Growth hierarchy ────────────────────────────────────────────────────────
7542
+ funnel: ["funnel_step"],
7543
+ acquisition_channel: ["growth_campaign"],
7544
+ growth_campaign: ["experiment_plan", "variant"],
7545
+ // ── Business Model hierarchy ─────────────────────────────────────────────────
7546
+ business_model: [
7547
+ "value_proposition",
7548
+ "revenue_stream",
7549
+ "cost_structure",
7550
+ "unit_economics",
7551
+ "partnership",
7552
+ "key_resource",
7553
+ "key_activity",
7554
+ "customer_relationship",
7555
+ "distribution_channel"
7556
+ ],
7557
+ revenue_stream: ["pricing_tier"],
7558
+ // ── Go-To-Market hierarchy ───────────────────────────────────────────────────
7559
+ gtm_strategy: [
7560
+ "ideal_customer_profile",
7561
+ "positioning",
7562
+ "launch",
7563
+ "content_strategy",
7564
+ "sales_motion",
7565
+ "competitive_battle_card",
7566
+ "demand_gen_program",
7567
+ "territory"
7568
+ ],
7569
+ positioning: ["messaging", "objection", "proof_point"],
7570
+ value_proposition: ["objection", "proof_point"],
7571
+ competitive_battle_card: ["objection"],
7572
+ objection: ["rebuttal"],
7573
+ rebuttal: ["proof_point"],
7574
+ // ── Team & Organisation hierarchy ───────────────────────────────────────────
7575
+ department: ["team", "stakeholder"],
7576
+ team: [
7577
+ "role",
7578
+ "team_okr",
7579
+ "retrospective",
7580
+ "dependency",
7581
+ "skill",
7582
+ "ceremony",
7583
+ "capacity_plan",
7584
+ "decision",
7585
+ // Self-nesting (0.17.2): a parent team contains its sub-teams / squads, one
7586
+ // level below department_contains_team. Backs team_contains_team. Mirrors
7587
+ // feature_area_contains_feature_area (same-type child listed last).
7588
+ "team"
7589
+ ],
7590
+ // ── Data & Analytics hierarchy ───────────────────────────────────────────────
7591
+ data_source: ["metric", "data_pipeline", "data_lineage", "event_schema"],
7592
+ // UPG-685 T0.4 (0.13.0 Wave 1): `outcome` removed as a metric child. It closed a
7593
+ // containment cycle (outcome ⊃ metric ⊃ outcome) and was backed only by the CAUSAL
7594
+ // `metric_drives_outcome` edge, not a hierarchy edge — the "metric leads to outcome"
7595
+ // meaning lives correctly on that causal edge. The real containment (outcome ⊃ metric)
7596
+ // is kept. Sub-metric trees (metric ⊃ metric) stay.
7597
+ metric: ["metric", "data_quality_rule", "metric_quality_assessment"],
7598
+ data_domain: ["data_product", "data_source", "glossary_term", "data_model", "dashboard"],
7599
+ dashboard: ["report", "experiment_run"],
7600
+ // ── Content & Knowledge hierarchy ────────────────────────────────────────────
7601
+ // release contains features and bugs (GitHub milestone→issue import).
7602
+ release: ["changelog", "feature", "bug"],
7603
+ content_strategy: ["content_calendar", "content_theme"],
7604
+ content_calendar: [
7605
+ "content_theme",
7606
+ "content_piece",
7607
+ "knowledge_base_article",
7608
+ "brand_asset",
7609
+ "document",
7610
+ "documentation_template"
7611
+ ],
7612
+ // ── Operations & CS hierarchy ────────────────────────────────────────────────
7613
+ service_blueprint: [
7614
+ "user_flow",
7615
+ "playbook",
7616
+ "service_level_agreement",
7617
+ "customer_health_score",
7618
+ "support_ticket",
7619
+ "customer_feedback"
7620
+ ],
7621
+ customer_health_score: ["nps_campaign", "success_milestone"],
7622
+ customer_feedback: ["churn_reason"],
7623
+ user_flow: ["screen", "customer_journey_stage"],
7624
+ customer_journey_stage: ["touchpoint"],
7625
+ // ── Legal, Compliance & Risk hierarchy ──────────────────────────────────────
7626
+ legal_entity: ["ip_asset", "contract"],
7627
+ contract: ["contract_clause"],
7628
+ compliance_framework: [
7629
+ "security_audit",
7630
+ "compliance_requirement",
7631
+ "privacy_policy",
7632
+ "audit_log_policy",
7633
+ "risk",
7634
+ "data_contract",
7635
+ "legal_entity"
7636
+ ],
7637
+ // ── DevOps & Platform hierarchy ──────────────────────────────────────────────
7638
+ infrastructure_component: [
7639
+ "service_level_objective",
7640
+ "monitor",
7641
+ "ci_pipeline",
7642
+ "incident",
7643
+ "runbook",
7644
+ "release_strategy",
7645
+ "on_call_rotation"
7646
+ ],
7647
+ service_level_objective: ["service_level_indicator", "error_budget"],
7648
+ incident: ["postmortem"],
7649
+ monitor: ["alert_rule"],
7650
+ ci_pipeline: ["build_artifact"],
7651
+ // ── Security hierarchy ───────────────────────────────────────────────────────
7652
+ security_policy: [
7653
+ "security_control",
7654
+ "access_policy",
7655
+ "data_classification",
7656
+ "threat_model",
7657
+ "security_review",
7658
+ "incident"
7659
+ ],
7660
+ security_review: ["penetration_test"],
7661
+ threat_model: ["threat", "vulnerability"],
7662
+ // ── Sales & Revenue hierarchy ────────────────────────────────────────────────
7663
+ pipeline_sales: ["pipeline_stage", "lead", "account", "forecast", "subscription"],
7664
+ account: ["contact", "deal"],
7665
+ deal: ["quote_document"],
7666
+ subscription: ["invoice"],
7667
+ // ── Program Management hierarchy ─────────────────────────────────────────────
7668
+ program: ["project", "risk_register", "change_request", "resource_allocation", "status_report"],
7669
+ project: ["milestone", "deliverable"],
7670
+ risk_register: ["risk"],
7671
+ // ── Accessibility hierarchy ──────────────────────────────────────────────────
7672
+ a11y_standard: ["a11y_guideline", "a11y_audit", "a11y_annotation"],
7673
+ a11y_audit: ["a11y_issue"],
7674
+ // ── Product Specification expansion ─────────────────────────────────────────
7675
+ roadmap: ["roadmap_item", "roadmap_theme", "release"],
7676
+ roadmap_theme: ["feature"],
7677
+ // ── Unified Context Layer hierarchy ─────────────────────────────────────────
7678
+ design_system: [
7679
+ "design_component",
7680
+ "design_token",
7681
+ "design_guideline",
7682
+ "brand_identity",
7683
+ "user_journey",
7684
+ "user_flow",
7685
+ "insight"
7686
+ ],
7687
+ screen: ["screen_state", "screen", "surface", "design_component", "wireframe"],
7688
+ // self-nesting + surfaces + components + wireframes
7689
+ // surface (0.27.0): the place inside a screen. Self-nests, so a shell holds
7690
+ // panes, a pane holds regions, a region holds slots. A surface is reached
7691
+ // through the screen that renders it (`screen: [... 'surface']`), never as a
7692
+ // top-level product child: every UPG_VALID_CHILDREN pair must be backed by a
7693
+ // hierarchy-classified edge (guardrail G2b), and the ratified ten do not
7694
+ // include a product-to-surface verb. An app-shell surface therefore hangs off
7695
+ // the screen that mounts it.
7696
+ //
7697
+ // NOTE: `surface_kind` narrows this further than UPG_VALID_CHILDREN can
7698
+ // express. UPG_VALID_CHILDREN is keyed on entity TYPE, so it can only say
7699
+ // "a surface may contain a surface"; the kind ordering (shell > tool > pane >
7700
+ // region > slot / gutter / action_bar, with overlay and ambient parented by
7701
+ // whatever raises them) is a property-level rule documented on `SurfaceKind`
7702
+ // and enforced by validators, not by this table. Precedent: the same split
7703
+ // applies to `planning_cycle`, whose `cadence_kind` narrows its self-nesting.
7704
+ surface: ["surface", "design_component"],
7705
+ // ── Marketing & Communications hierarchy ────────────────────────────────────
7706
+ marketing_strategy: [
7707
+ "marketing_channel",
7708
+ "seo_keyword",
7709
+ "press_release",
7710
+ "event",
7711
+ "community_initiative"
7712
+ ],
7713
+ marketing_channel: ["marketing_campaign_plan"],
7714
+ marketing_campaign_plan: ["email_sequence", "social_post", "ad_creative"],
7715
+ // ── Localisation & i18n hierarchy ───────────────────────────────────────────
7716
+ locale: ["translation_bundle", "cultural_adaptation", "regional_pricing", "locale_config"],
7717
+ translation_bundle: ["translation_key"],
7718
+ // ── Customer Education & Training hierarchy ──────────────────────────────────
7719
+ education_program: [
7720
+ "tutorial",
7721
+ "walkthrough",
7722
+ "webinar",
7723
+ "certification",
7724
+ "help_video",
7725
+ "learning_path"
7726
+ ],
7727
+ // a learning_path can include its terminal certification.
7728
+ learning_path: ["tutorial", "certification"],
7729
+ // ── Quality Assurance & Testing hierarchy ────────────────────────────────────
7730
+ // (UPG-678) test_plan re-homed validation → QA. It is the QA planning layer:
7731
+ // the verification approach (scope, environments, pass criteria) that the
7732
+ // test suites execute. A test_plan groups the suites that carry it out.
7733
+ test_plan: ["test_suite", "test_environment"],
7734
+ test_suite: [
7735
+ "test_case",
7736
+ "regression_test",
7737
+ "qa_session",
7738
+ "test_coverage_report",
7739
+ "test_environment",
7740
+ "test_result"
7741
+ ],
7742
+ test_case: ["test_result"],
7743
+ qa_session: ["bug"],
7744
+ // ── Partner & Ecosystem Management hierarchy ─────────────────────────────────
7745
+ partner_program: [
7746
+ "partner_tier",
7747
+ "integration_partner",
7748
+ "partner_revenue_share",
7749
+ "api_ecosystem",
7750
+ "developer_portal"
7751
+ ],
7752
+ api_ecosystem: ["marketplace_listing"],
7753
+ // ── Feedback & Voice of Customer hierarchy ───────────────────────────────────
7754
+ feedback_program: [
7755
+ "feature_request",
7756
+ "nps_campaign",
7757
+ "feedback_theme",
7758
+ "user_advisory_board",
7759
+ "beta_program"
7760
+ ],
7761
+ feature_request: ["feedback_vote"],
7762
+ // v0.5.8 (UPG-528 Part 2d): CABs convene as quarterly ceremonies;
7763
+ // CAB owns its meeting cadence (Stettler, Moore CAB playbook canon).
7764
+ // Pairs with `user_advisory_board_convenes_as_ceremony` in the edge
7765
+ // catalog. ceremony now has two valid hierarchy parents (team for sprint
7766
+ // ceremonies, user_advisory_board for CAB meetings).
7767
+ user_advisory_board: ["ceremony"],
7768
+ // ── Pricing & Packaging hierarchy ────────────────────────────────────────────
7769
+ pricing_strategy: [
7770
+ "experiment_plan",
7771
+ "pricing_tier",
7772
+ "discount_strategy",
7773
+ "trial_config",
7774
+ "paywall"
7775
+ ],
7776
+ // ── AI/ML Operations hierarchy ───────────────────────────────────────────────
7777
+ // (UPG-665) The prompt abstraction is corrected: ai_model → prompt_template →
7778
+ // prompt_version (a model has templates; each template has versions). The
7779
+ // model no longer owns prompt_version directly.
7780
+ ai_model: [
7781
+ "prompt_template",
7782
+ "eval_benchmark",
7783
+ "ai_cost_tracker",
7784
+ "hallucination_report",
7785
+ "ai_guardrail",
7786
+ "model_comparison",
7787
+ "ai_experiment",
7788
+ "ai_dataset",
7789
+ "ai_trace"
7790
+ ],
7791
+ // prompt_template owns its prompt_versions the way a file owns its commits.
7792
+ prompt_template: ["prompt_version"],
7793
+ // v0.5.7 (UPG-528 Part 2c): benchmarks define the metric set they measure
7794
+ // (HELM, MLPerf, BIG-bench all spec a metric list). metric already has many
7795
+ // hierarchy parents (outcome, objective, key_result, solution, data_source).
7796
+ eval_benchmark: ["eval_run", "metric"],
7797
+ // ai_trace spawns child traces for sub-calls (tool calls, chained
7798
+ // prompts). Self-nesting enables call-tree representation.
7799
+ ai_trace: ["ai_trace"],
7800
+ // ── Agentic Workflows & Process hierarchy ────────────────────────────────────
7801
+ workflow_template: ["workflow_run", "review_gate", "agent_task"],
7802
+ workflow_run: ["workflow_artifact"],
7803
+ agent_definition: ["agent_session", "agent_skill", "agent_hook", "workflow_template", "agent_task"],
7804
+ // v0.5.8 (UPG-528 Part 2d): review gates also vet research insights
7805
+ // (ResearchOps insight-review pattern). Pairs with `review_gate_vets_insight`
7806
+ // in the edge catalog. The gate now owns two child types: approval records
7807
+ // for workflow gates, insights for research-democratisation gates.
7808
+ review_gate: ["approval_record", "insight"],
7809
+ // ── Investigation hierarchy ──────────────────────────────────────────────────
7810
+ investigation: ["symptom", "root_cause"],
7811
+ root_cause: ["fix"],
7812
+ // ── Portfolio layer hierarchy ────────────────────────────────────────────────
7813
+ // organization → product_area is the org-axis anchor (who owns what);
7814
+ // organization → portfolio is the strategic-axis anchor (where you invest).
7815
+ // organization → workspace (WS3, 2026-07-05): org-altitude workspace anchor
7816
+ // (organization_thinks_in_workspace) — a workspace scoped to org altitude
7817
+ // lives in the same portfolio-level graph as its organization node.
7818
+ organization: ["portfolio", "product_area", "workspace"],
7819
+ // portfolios can nest (multi-level investment structures).
7820
+ portfolio: ["product", "portfolio"],
7821
+ // product_area is the organisational container for products and can
7822
+ // nest (parent → sub-area). product_area also groups features; the
7823
+ // "Studio area owns 6 features" mental model. product_area → workspace
7824
+ // (WS3, 2026-07-05): plane-altitude workspace anchor
7825
+ // (product_area_thinks_in_workspace) — "plane" is Entopo's app-level name
7826
+ // for product_area, not a distinct spec entity.
7827
+ product_area: ["product", "product_area", "feature", "workspace"]
7828
+ };
7829
+ function getValidChildren(entityType) {
7830
+ return UPG_VALID_CHILDREN[entityType] ?? [];
7831
+ }
7832
+ function canBeChildOf(childType, parentType) {
7833
+ return getValidChildren(parentType).includes(childType);
7834
+ }
7835
+ var UPG_CONTAINMENT_FREE_TYPES = /* @__PURE__ */ new Set([
7394
7836
  "person",
7395
- "department",
7396
- "skill",
7397
- "ceremony",
7398
- // ── Data & Analytics (4 of 10): lineage and domain containers, plus
7399
- // atomic definitions ────────────────────────────────────────────────────
7400
- "data_lineage",
7401
- "data_domain",
7402
- "data_quality_rule",
7403
- // ── AI (3 of 10): traces and cost trackers are append-only; model
7404
- // comparison snapshots are immutable ───────────────────────────────────
7405
- "ai_cost_tracker",
7406
- "ai_trace",
7407
- // ── Automation (2 of 6): approvals and artifacts are ledger entries ──────
7408
- "approval_record",
7409
- "workflow_artifact",
7410
- // ── Growth (7 of 9): funnels and attribution are structural definitions;
7411
- // cohorts/segments are computed snapshots ────────────────────────────
7412
- "funnel",
7413
- "funnel_step",
7414
- "acquisition_channel",
7415
- "cohort",
7416
- "behavioral_segment",
7417
- "growth_loop",
7418
- "attribution_model",
7419
- // ── Sales (5 of 6): pipeline structure + accounts/contacts + forecast
7420
- // snapshots. Only `deal` has a lifecycle (Phase B SALES_DEAL template) ─
7421
- "account",
7422
- "contact",
7423
- "pipeline_sales",
7424
- "pipeline_stage",
7425
- "forecast",
7426
- // ── Customer Success (5 of 9): journey structure + derived values ────────
7427
- "customer_journey_stage",
7428
- "touchpoint",
7429
- "churn_reason",
7430
- "service_level_agreement",
7431
- // ── DevOps (5 of 10): indicators and budgets are measurement references;
7432
- // strategies and pipelines are configuration ──────────────────────────
7433
- "service_level_indicator",
7434
- "service_level_objective",
7435
- "error_budget",
7436
- "ci_pipeline",
7437
- "release_strategy",
7438
- // ── Security (1 of 5): data classification is a reference label ──────────
7439
- "data_classification",
7440
- // ── Accessibility (2 of 4): standards and annotations ─────────────────────
7441
- "a11y_standard",
7442
- "a11y_annotation",
7443
- // ── Testing (3 of 5): regression tests are reference definitions; test
7444
- // results and coverage reports are immutable records ───────────────────
7445
- "regression_test",
7446
- "test_coverage_report",
7447
- "test_result",
7448
- // ── Customer Feedback (2 of 3): themes and votes are atomic data points ──
7449
- "feedback_theme",
7450
- "feedback_vote",
7451
- // ── Pricing (2 of 4): trial and paywall are configuration ─────────────────
7452
- "trial_config",
7453
- "paywall",
7454
- // ── Content (2 of 5): calendars and themes are planning configuration ────
7455
- "content_calendar",
7456
- "content_theme",
7457
- // ── Legal (2 of 3): legal_entity is an org; contract_clause is an atom
7458
- // of a contract (which has its own lifecycle) ───────────────────────────
7459
- "legal_entity",
7460
- "contract_clause",
7461
- // ── Portfolio (3 of 3): structural containers ─────────────────────────────
7462
- "organization",
7463
- "portfolio",
7464
- "product_area",
7465
- // ── Program Management (2 of 3): allocations and registers are tracking
7466
- // containers ────────────────────────────────────────────────────────────
7467
- "resource_allocation",
7468
- "risk_register",
7469
- // ── Localisation (4 of 5): translation keys, configs, and regional
7470
- // adaptations are reference data ────────────────────────────────────────
7471
- "translation_key",
7472
- "locale_config",
7473
- "cultural_adaptation",
7474
- "regional_pricing",
7475
- // ── Marketing (1 of 4): SEO keywords are tracked reference terms ─────────
7476
- "seo_keyword",
7477
- // ── Ecosystem (2 of 2): partner tiers and rev-share terms are config ─────
7478
- "partner_tier",
7479
- "partner_revenue_share",
7480
- // ── Validation (2 of 4): evidence + learning are data points captured
7481
- // from experiment_runs (which have lifecycles); hypothesis_evidence was
7482
- // lifecycle-free here but is deprecated at v0.4.0 ──────────────────────────────────────
7483
- "evidence",
7484
- "learning",
7485
- // ── Workspace (1 of 4): a capture is a fact about a moment, not a workflow.
7486
- // It is taken, and from then on it either still matches its subject or it
7487
- // does not — which is what `content_hash` answers, not a phase. ─────────
7837
+ // A framework_exercise has no structural parent: it anchors to the entities
7838
+ // it scores via the `framework_exercise_includes_node` edge, not by
7839
+ // containment. Modelling it as a product child would force a containment edge
7840
+ // and read against the whole point of the exercise model (relational, not
7841
+ // hierarchical). Same posture as `person`. See ADR 2026-06-02-framework-exercises.
7842
+ "framework_exercise",
7843
+ // A composition has no structural parent for the same reason a
7844
+ // framework_exercise does not: it anchors to what it SHOWS, relationally, via
7845
+ // `composition_focuses_node`. Modelling it as a product child would force a
7846
+ // containment edge that reads against the point — a published view is not a
7847
+ // part of the product, it is a lens onto one. This is also what keeps the
7848
+ // type to two edges rather than three: no provenance edge is minted (that is
7849
+ // `workspace_produced_node`, reused) and no parent edge is needed.
7850
+ "composition",
7851
+ // A capture has no structural parent for the same reason: it anchors to what
7852
+ // it RENDERS, via `capture_renders_node`. Giving it a product parent would
7853
+ // claim a capture is part of the product rather than a picture of one, and
7854
+ // would mint a containment edge whose only job is to satisfy the hierarchy.
7488
7855
  "capture"
7489
7856
  ]);
7490
- function isLifecycleFreeType(entityType) {
7491
- return UPG_LIFECYCLE_FREE_TYPES.has(entityType);
7857
+ function isContainmentFreeType(entityType) {
7858
+ return UPG_CONTAINMENT_FREE_TYPES.has(entityType);
7492
7859
  }
7493
- var UPG_LIFECYCLE_PLANNED_TYPES = /* @__PURE__ */ new Set([
7494
- // Phase B cleared this set entirely. Every type that was triaged
7495
- // into Phase B/C/D under now either has a lifecycle in
7496
- // `UPG_LIFECYCLES` or is documented as lifecycle-free in
7497
- // `UPG_LIFECYCLE_FREE_TYPES`.
7498
- //
7499
- // Reintroduce entries here when a new entity type is added to the spec
7500
- // and decided to be lifecycle-bearing but its phases have not yet been
7501
- // designed. The `10-lifecycle-coverage` audit will surface uncovered
7502
- // active types until they're either implemented or moved to the
7503
- // free-types set.
7504
- ]);
7505
- function isLifecyclePlannedType(entityType) {
7506
- return UPG_LIFECYCLE_PLANNED_TYPES.has(entityType);
7860
+
7861
+ // src/grammar/projection.ts
7862
+ var VARIES_BY_EDGE = "surface_varies_by_configuration_axis";
7863
+ var PRESENT_UNDER_PROPERTY = "present_under";
7864
+ var ACTIVE_WHEN_PROPERTY = "active_when";
7865
+ var QUALIFIABLE_EDGE_TYPES = [
7866
+ "surface_contains_surface",
7867
+ "feature_occupies_surface"
7868
+ ];
7869
+ function readStringArray(properties, key) {
7870
+ const raw = properties?.[key];
7871
+ if (!Array.isArray(raw)) return void 0;
7872
+ return raw.filter((v) => typeof v === "string");
7507
7873
  }
7508
- function getLifecycleRenderShape(entityType) {
7509
- const lifecycle = getLifecycleForType(entityType);
7510
- if (!lifecycle) return null;
7511
- const terminalSet = new Set(lifecycle.terminal_phases);
7512
- const phaseIndex = new Map(lifecycle.phases.map((p, i) => [p.id, i]));
7513
- const states = lifecycle.phases.map((phase) => ({
7514
- id: phase.id,
7515
- label: phase.label,
7516
- description: phase.description,
7517
- terminal: terminalSet.has(phase.id)
7518
- }));
7519
- const transitions = [];
7520
- for (const phase of lifecycle.phases) {
7521
- const fromTerminal = terminalSet.has(phase.id);
7522
- for (const to of phase.transitions_to) {
7523
- const toTerminal = terminalSet.has(to);
7524
- let kind;
7525
- if (fromTerminal && !toTerminal) {
7526
- kind = "reopen";
7527
- } else if (toTerminal && !fromTerminal) {
7528
- kind = "terminal";
7529
- } else {
7530
- const fromIdx = phaseIndex.get(phase.id) ?? 0;
7531
- const toIdx = phaseIndex.get(to) ?? 0;
7532
- kind = toIdx < fromIdx ? "backward" : "forward";
7874
+ function readActiveWhen(edge) {
7875
+ const raw = edge.properties?.[ACTIVE_WHEN_PROPERTY];
7876
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) return void 0;
7877
+ const axis = raw.axis;
7878
+ const values = readStringArray(raw, "values");
7879
+ if (typeof axis !== "string" || axis.length === 0 || !values || values.length === 0) {
7880
+ return void 0;
7881
+ }
7882
+ return { axis, values };
7883
+ }
7884
+ function projectGraph(nodes, edges, configuration) {
7885
+ const axes = Object.keys(configuration);
7886
+ if (axes.length === 0) {
7887
+ return {
7888
+ nodes: [...nodes],
7889
+ edges: [...edges],
7890
+ excluded_node_ids: [],
7891
+ deactivated_edge_count: 0,
7892
+ dangling_edge_count: 0
7893
+ };
7894
+ }
7895
+ const excluded = /* @__PURE__ */ new Set();
7896
+ for (const edge of edges) {
7897
+ if (edge.type !== VARIES_BY_EDGE) continue;
7898
+ const chosen = configuration[edge.target];
7899
+ if (chosen === void 0) continue;
7900
+ const presentUnder = readStringArray(edge.properties, PRESENT_UNDER_PROPERTY);
7901
+ if (!presentUnder) continue;
7902
+ if (!presentUnder.includes(chosen)) excluded.add(edge.source);
7903
+ }
7904
+ const survivingNodes = excluded.size === 0 ? [...nodes] : nodes.filter((n) => !excluded.has(n.id));
7905
+ let deactivated = 0;
7906
+ let dangling = 0;
7907
+ const survivingEdges = [];
7908
+ for (const edge of edges) {
7909
+ const qualifier = readActiveWhen(edge);
7910
+ if (qualifier) {
7911
+ const chosen = configuration[qualifier.axis];
7912
+ if (chosen !== void 0 && !qualifier.values.includes(chosen)) {
7913
+ deactivated++;
7914
+ continue;
7915
+ }
7916
+ }
7917
+ if (excluded.has(edge.source) || excluded.has(edge.target)) {
7918
+ dangling++;
7919
+ continue;
7920
+ }
7921
+ survivingEdges.push(edge);
7922
+ }
7923
+ return {
7924
+ nodes: survivingNodes,
7925
+ edges: survivingEdges,
7926
+ excluded_node_ids: [...excluded].sort(),
7927
+ deactivated_edge_count: deactivated,
7928
+ dangling_edge_count: dangling
7929
+ };
7930
+ }
7931
+ function enumerateProjections(nodes) {
7932
+ const out = [
7933
+ { configuration: {} }
7934
+ ];
7935
+ for (const node of nodes) {
7936
+ if (node.type !== "configuration_axis") continue;
7937
+ const values = readStringArray(node.properties, "values");
7938
+ if (!values) continue;
7939
+ for (const value of values) {
7940
+ out.push({ axis: node.id, value, configuration: { [node.id]: value } });
7941
+ }
7942
+ }
7943
+ return out;
7944
+ }
7945
+
7946
+ // src/grammar/configuration-drift.ts
7947
+ var ALTERNATES_EDGE = "surface_alternates_with_surface";
7948
+ var PARENT_EDGE_TYPES = /* @__PURE__ */ new Set(["surface_contains_surface", "screen_renders_surface"]);
7949
+ function edgeLabel(edge) {
7950
+ return edge.id ?? `${edge.source} -> ${edge.target}`;
7951
+ }
7952
+ function checkConfigurationDrift(nodes, edges) {
7953
+ const findings = [];
7954
+ const axisValues = /* @__PURE__ */ new Map();
7955
+ for (const node of nodes) {
7956
+ if (node.type !== "configuration_axis") continue;
7957
+ const values = readStringArray(node.properties, "values");
7958
+ if (!values || values.length === 0) {
7959
+ findings.push({
7960
+ kind: "axis_values_empty",
7961
+ severity: "error",
7962
+ node_id: node.id,
7963
+ axis_id: node.id,
7964
+ message: "Configuration axis declares no values. An axis with no values selects nothing, so no projection can be taken along it."
7965
+ });
7966
+ axisValues.set(node.id, []);
7967
+ continue;
7968
+ }
7969
+ axisValues.set(node.id, values);
7970
+ const rawDefault = node.properties?.default_value;
7971
+ if (typeof rawDefault === "string" && rawDefault.length > 0 && !values.includes(rawDefault)) {
7972
+ findings.push({
7973
+ kind: "axis_default_not_a_value",
7974
+ severity: "error",
7975
+ node_id: node.id,
7976
+ axis_id: node.id,
7977
+ message: `default_value "${rawDefault}" is not one of the axis values [${values.join(", ")}]. It names a value of this axis, so it has to be one the axis declares.`
7978
+ });
7979
+ }
7980
+ }
7981
+ for (const edge of edges) {
7982
+ if (edge.type !== VARIES_BY_EDGE) continue;
7983
+ const values = axisValues.get(edge.target);
7984
+ const presentUnder = readStringArray(edge.properties, PRESENT_UNDER_PROPERTY);
7985
+ if (!presentUnder || presentUnder.length === 0) {
7986
+ findings.push({
7987
+ kind: "present_under_empty",
7988
+ severity: "error",
7989
+ edge_id: edge.id,
7990
+ node_id: edge.source,
7991
+ axis_id: edge.target,
7992
+ message: `${edgeLabel(edge)} declares variance without a non-empty present_under. A surface that exists under no configuration should be deleted rather than declared; a surface that exists under all of them should carry no varies_by edge at all.`
7993
+ });
7994
+ continue;
7995
+ }
7996
+ if (!values) continue;
7997
+ for (const value of presentUnder) {
7998
+ if (!values.includes(value)) {
7999
+ findings.push({
8000
+ kind: "present_under_unknown_value",
8001
+ severity: "error",
8002
+ edge_id: edge.id,
8003
+ node_id: edge.source,
8004
+ axis_id: edge.target,
8005
+ message: `present_under names "${value}", which the axis does not declare. Its values are [${values.join(", ")}].`
8006
+ });
7533
8007
  }
7534
- transitions.push({ from: phase.id, to, kind });
7535
8008
  }
7536
8009
  }
7537
- return {
7538
- entity_type: lifecycle.entity_type,
7539
- ...lifecycle.template_id !== void 0 && { template_id: lifecycle.template_id },
7540
- states,
7541
- transitions,
7542
- initial_state: lifecycle.initial_phase
7543
- };
8010
+ for (const edge of edges) {
8011
+ const hasQualifierKey = edge.properties !== void 0 && Object.prototype.hasOwnProperty.call(edge.properties, ACTIVE_WHEN_PROPERTY);
8012
+ if (!hasQualifierKey) continue;
8013
+ if (edge.type !== void 0 && !QUALIFIABLE_EDGE_TYPES.includes(edge.type)) {
8014
+ findings.push({
8015
+ kind: "qualifier_on_illegal_edge",
8016
+ severity: "error",
8017
+ edge_id: edge.id,
8018
+ message: `active_when is not legal on ${edge.type}. The qualifier is scoped to [${QUALIFIABLE_EDGE_TYPES.join(", ")}] deliberately: conditional composition is the question this release answers, and a general modality system is not.`
8019
+ });
8020
+ continue;
8021
+ }
8022
+ const qualifier = readActiveWhen(edge);
8023
+ if (!qualifier) {
8024
+ const rawQualifier = edge.properties?.[ACTIVE_WHEN_PROPERTY];
8025
+ const rawValues = rawQualifier && typeof rawQualifier === "object" && !Array.isArray(rawQualifier) ? rawQualifier.values : void 0;
8026
+ if (Array.isArray(rawValues) && rawValues.length === 0) {
8027
+ findings.push({
8028
+ kind: "qualifier_values_empty",
8029
+ severity: "error",
8030
+ edge_id: edge.id,
8031
+ message: `${edgeLabel(edge)} carries an active_when with an empty values list. Read literally that would remove the relationship from every configuration, which is a way to delete an edge by writing a property; it is treated as absent instead. To say a relationship never holds, delete the edge.`
8032
+ });
8033
+ continue;
8034
+ }
8035
+ findings.push({
8036
+ kind: "qualifier_axis_unresolved",
8037
+ severity: "error",
8038
+ edge_id: edge.id,
8039
+ message: `${edgeLabel(edge)} carries a malformed active_when. It must be an object with an axis id and a non-empty values array; anything else reads as absent, which silently makes the relationship invariant.`
8040
+ });
8041
+ continue;
8042
+ }
8043
+ const values = axisValues.get(qualifier.axis);
8044
+ if (!values) {
8045
+ findings.push({
8046
+ kind: "qualifier_axis_unresolved",
8047
+ severity: "error",
8048
+ edge_id: edge.id,
8049
+ axis_id: qualifier.axis,
8050
+ message: `active_when names axis "${qualifier.axis}", which is not a configuration_axis node in this graph.`
8051
+ });
8052
+ continue;
8053
+ }
8054
+ for (const value of qualifier.values) {
8055
+ if (!values.includes(value)) {
8056
+ findings.push({
8057
+ kind: "qualifier_unknown_value",
8058
+ severity: "error",
8059
+ edge_id: edge.id,
8060
+ axis_id: qualifier.axis,
8061
+ message: `active_when names value "${value}", which axis "${qualifier.axis}" does not declare. Its values are [${values.join(", ")}].`
8062
+ });
8063
+ }
8064
+ }
8065
+ }
8066
+ const varianceBySource = /* @__PURE__ */ new Map();
8067
+ for (const edge of edges) {
8068
+ if (edge.type !== VARIES_BY_EDGE) continue;
8069
+ const values = readStringArray(edge.properties, PRESENT_UNDER_PROPERTY) ?? [];
8070
+ const list = varianceBySource.get(edge.source) ?? [];
8071
+ list.push({ axis: edge.target, values });
8072
+ varianceBySource.set(edge.source, list);
8073
+ }
8074
+ for (const edge of edges) {
8075
+ if (edge.type !== ALTERNATES_EDGE) continue;
8076
+ const left = varianceBySource.get(edge.source) ?? [];
8077
+ const right = varianceBySource.get(edge.target) ?? [];
8078
+ if (left.length === 0 || right.length === 0) {
8079
+ findings.push({
8080
+ kind: "alternation_axis_mismatch",
8081
+ severity: "error",
8082
+ edge_id: edge.id,
8083
+ message: `${edgeLabel(edge)} declares an alternation, but at least one endpoint declares no variance at all. Two surfaces that are both always present are not alternatives; they co-exist.`
8084
+ });
8085
+ continue;
8086
+ }
8087
+ const sharedAxes = left.filter((l) => right.some((r) => r.axis === l.axis)).map((l) => l.axis);
8088
+ if (sharedAxes.length === 0) {
8089
+ findings.push({
8090
+ kind: "alternation_axis_mismatch",
8091
+ severity: "error",
8092
+ edge_id: edge.id,
8093
+ message: `${edgeLabel(edge)} declares an alternation between surfaces that vary on different axes. Alternatives are selected by ONE lever; surfaces on different levers can both be present at once.`
8094
+ });
8095
+ continue;
8096
+ }
8097
+ for (const axis of sharedAxes) {
8098
+ const leftValues = left.find((l) => l.axis === axis)?.values ?? [];
8099
+ const rightValues = right.find((r) => r.axis === axis)?.values ?? [];
8100
+ const overlap = leftValues.filter((v) => rightValues.includes(v));
8101
+ if (overlap.length > 0) {
8102
+ findings.push({
8103
+ kind: "alternation_overlap",
8104
+ severity: "error",
8105
+ edge_id: edge.id,
8106
+ axis_id: axis,
8107
+ message: `${edgeLabel(edge)} declares an alternation, but both surfaces are present under [${overlap.join(", ")}] on axis "${axis}". They co-exist there, so the graph is asserting "one of these" and "both, together" about the same pair.`
8108
+ });
8109
+ }
8110
+ }
8111
+ }
8112
+ const parentsByChild = /* @__PURE__ */ new Map();
8113
+ for (const edge of edges) {
8114
+ if (edge.type && PARENT_EDGE_TYPES.has(edge.type)) {
8115
+ parentsByChild.set(edge.target, (parentsByChild.get(edge.target) ?? 0) + 1);
8116
+ }
8117
+ }
8118
+ for (const [axisId, values] of axisValues) {
8119
+ for (const value of values) {
8120
+ const projected = projectGraph(nodes, edges, { [axisId]: value });
8121
+ const survivingParents = /* @__PURE__ */ new Map();
8122
+ for (const edge of projected.edges) {
8123
+ if (edge.type && PARENT_EDGE_TYPES.has(edge.type)) {
8124
+ survivingParents.set(edge.target, (survivingParents.get(edge.target) ?? 0) + 1);
8125
+ }
8126
+ }
8127
+ for (const node of projected.nodes) {
8128
+ if (node.type !== "surface") continue;
8129
+ if ((parentsByChild.get(node.id) ?? 0) === 0) continue;
8130
+ if ((survivingParents.get(node.id) ?? 0) > 0) continue;
8131
+ findings.push({
8132
+ kind: "orphaned_under_projection",
8133
+ severity: "warning",
8134
+ node_id: node.id,
8135
+ axis_id: axisId,
8136
+ message: `Surface is present under ${axisId} = "${value}" but every containment parent it has is absent there. Either it needs a parent in that configuration, or it should declare that it is absent from it too.`
8137
+ });
8138
+ }
8139
+ }
8140
+ }
8141
+ return findings;
7544
8142
  }
7545
8143
 
7546
8144
  // src/grammar/scales.ts
@@ -7677,6 +8275,37 @@ var UPG_SCALES = {
7677
8275
  // the existing classify-edge population, so nothing needs re-stamping.
7678
8276
  friendly_aliases: { low: 2, medium: 3, high: 4 }
7679
8277
  },
8278
+ // ── Likelihood ─────────────────────────────────────────────────────────────
8279
+ /**
8280
+ * (0.35.0) How likely a future event is to occur.
8281
+ *
8282
+ * Added because the nine pre-existing ladders had no probability ladder, and
8283
+ * `likelihood` was resolving to `confidence_5` — which is EPISTEMIC. Confidence
8284
+ * says how sure you are of a judgment ("Guessing → Data-backed"); likelihood
8285
+ * says how probable the event is. A risk you are certain about and a risk that
8286
+ * is certain to happen are different facts, and one ladder cannot hold both.
8287
+ *
8288
+ * Vocabulary is ISO 31000's, which is also what `risk.likelihood`,
8289
+ * `threat.likelihood` and the Notion fixtures already say in prose.
8290
+ *
8291
+ * Polarity is `low-is-good` (rendered by the design system's direction map,
8292
+ * which is where numeric-scale polarity lives): 5 on this ladder is bad news.
8293
+ */
8294
+ likelihood_5: {
8295
+ id: "likelihood_5",
8296
+ label: "Likelihood (5-point)",
8297
+ description: "How likely this event is to occur",
8298
+ min: 1,
8299
+ max: 5,
8300
+ steps: 5,
8301
+ points: [
8302
+ { value: 1, label: "Rare", description: "Would be surprising; no known precedent" },
8303
+ { value: 2, label: "Unlikely", description: "Could happen, but not expected" },
8304
+ { value: 3, label: "Possible", description: "Might happen; roughly even odds" },
8305
+ { value: 4, label: "Likely", description: "Expected to happen absent intervention" },
8306
+ { value: 5, label: "Almost certain", description: "Expected to happen; plan for it" }
8307
+ ]
8308
+ },
7680
8309
  // ── Effort ─────────────────────────────────────────────────────────────────
7681
8310
  effort_5: {
7682
8311
  id: "effort_5",
@@ -7749,12 +8378,17 @@ var PROPERTY_SCALE_MAP = {
7749
8378
  // discovery, validation, sales, product-spec
7750
8379
  current_confidence: "confidence_5",
7751
8380
  // validation/hypothesis (UPG-579 Option B)
7752
- likelihood: "confidence_5",
7753
- // market/risk (UPG-579 Option B)
7754
8381
  probability: "confidence_5",
7755
8382
  // sales/forecast (UPG-579 Option B)
7756
8383
  qualification_score: "confidence_5",
7757
8384
  // sales/deal — how confident the qualification is (0.24.0)
8385
+ // ── Likelihood ───────────────────────────────────────────────────────────
8386
+ // (0.35.0) Moved off confidence_5. `likelihood` is how probable the event is,
8387
+ // not how well-evidenced the judgment is; the two were sharing one ladder
8388
+ // because no probability ladder existed. Carries market/risk (`risk`,
8389
+ // `market_trend`) and `security.threat.likelihood` in one line.
8390
+ likelihood: "likelihood_5",
8391
+ // compliance/risk, security/threat, market
7758
8392
  // ── Effort ───────────────────────────────────────────────────────────────
7759
8393
  effort: "effort_5",
7760
8394
  // discovery
@@ -7784,9 +8418,18 @@ var PROPERTY_SCALE_MAP = {
7784
8418
  // rarity : VRIO distinctiveness; no canonical named scale fits.
7785
8419
  // strength : deprecated (validation/evidence; superseded by weight).
7786
8420
  };
8421
+ var PROPERTY_SCALE_MAP_BY_ENTITY = {
8422
+ risk: {
8423
+ // Severity of consequences, not magnitude of benefit. See above.
8424
+ impact: "severity_5",
8425
+ // The DEPRECATED spelling of `likelihood`, held on the same ladder as its
8426
+ // replacement for the length of the deprecation window. See above.
8427
+ probability: "likelihood_5"
8428
+ }
8429
+ };
7787
8430
  var DEFAULT_SCALE_ID = "scale_5";
7788
- function getPropertyDefaultScale(_entityType, propertyName) {
7789
- return PROPERTY_SCALE_MAP[propertyName] ?? DEFAULT_SCALE_ID;
8431
+ function getPropertyDefaultScale(entityType, propertyName) {
8432
+ return PROPERTY_SCALE_MAP_BY_ENTITY[entityType]?.[propertyName] ?? PROPERTY_SCALE_MAP[propertyName] ?? DEFAULT_SCALE_ID;
7790
8433
  }
7791
8434
  function getPropertiesForScale(scaleId) {
7792
8435
  return Object.entries(PROPERTY_SCALE_MAP).filter(([, id]) => id === scaleId).map(([property]) => property);
@@ -7877,6 +8520,29 @@ var UPG_ENUM_SCALES = {
7877
8520
  { value: "guideline", label: "Guideline", description: "Recommendation: encouraged and expected in most cases, but not enforced." }
7878
8521
  ]
7879
8522
  },
8523
+ // ── EngagementPosture ────────────────────────────────────────────────
8524
+ /**
8525
+ * (0.35.0) The third axis of stakeholder canon, beside the power/interest
8526
+ * grid `influence` / `interest` carry. Those two say how much weight a
8527
+ * stakeholder has and how much they care; neither says which WAY they lean,
8528
+ * and "who blocks this?" is the question a stakeholder map is drawn to answer.
8529
+ *
8530
+ * `tone_direction: 'high-is-good'` reading champion → blocker: the first
8531
+ * value is the desirable end, matching HealthStatus's convention.
8532
+ */
8533
+ EngagementPosture: {
8534
+ id: "EngagementPosture",
8535
+ label: "Engagement posture",
8536
+ description: "Which way a stakeholder leans on the thing at hand: actively for it, against it, or neither.",
8537
+ tone_direction: "high-is-good",
8538
+ values: [
8539
+ { value: "champion", label: "Champion", description: "Actively advocates for it and spends their own capital doing so." },
8540
+ { value: "supporter", label: "Supporter", description: "In favour and will say so when asked, but does not drive it." },
8541
+ { value: "neutral", label: "Neutral", description: "No position taken; neither helps nor hinders." },
8542
+ { value: "skeptic", label: "Skeptic", description: "Unconvinced and voices objections, but is not blocking." },
8543
+ { value: "blocker", label: "Blocker", description: "Actively opposes, and holds enough leverage to stop it." }
8544
+ ]
8545
+ },
7880
8546
  // ── ProxyConfidence ─────────────────────────────────────────────────
7881
8547
  ProxyConfidence: {
7882
8548
  id: "ProxyConfidence",
@@ -8389,6 +9055,62 @@ function getDeprecatedTypes() {
8389
9055
  return deprecated;
8390
9056
  }
8391
9057
  var UPG_PROPERTY_MIGRATIONS = {
9058
+ // ── v0.35.0: risk.probability → risk.likelihood, STAGED ─────────────────────
9059
+ //
9060
+ // Deliberately EMPTY, and the emptiness is the design rather than an omission.
9061
+ // The rename is staged: `RiskProperties.probability` is kept, marked
9062
+ // `@deprecated since="0.35.0" removeIn="1.0.0"`, and still read. 0.35.0 changes
9063
+ // what writers emit (`likelihood`) and what readers prefer; it changes no
9064
+ // stored bytes, so there is nothing for a load-time rule to do. A graph
9065
+ // written before 0.35.0 carries `probability` and no `likelihood` and reads
9066
+ // correctly — which is what staging BUYS, and a rule here would spend it.
9067
+ //
9068
+ // Three reasons there is no executable rule, in order of weight:
9069
+ //
9070
+ // 1. A staged deprecation that rewrites data is not staged. The point of the
9071
+ // `epic.estimate` → `effort` pattern this follows is that both names live
9072
+ // through the window and the consumer chooses; migrating the key on load
9073
+ // would end the window on the first read and break any reader still
9074
+ // asking for the old name.
9075
+ // 2. The executable step belongs at the REMOVAL version, not here. That is
9076
+ // the two-step the `removeIn="0.5.0"` properties followed: declared
9077
+ // deprecated with a deadline at 0.4.0, dropped by `drop_props` rules in
9078
+ // the '0.5.0' block below. `probability` is scheduled for the same
9079
+ // treatment at 1.0.0.
9080
+ // 3. No kind fits, and inventing one would be the larger change. Checked
9081
+ // against the APPLIER, not just the type union:
9082
+ // - `drop_props` deletes, which is the 1.0.0 step, not this one.
9083
+ // - `lift_property_to_top_level` targets `UPGBaseNode`, and `likelihood`
9084
+ // is a property, not a top-level field.
9085
+ // - `rename_top_level` renames a top-level field, same mismatch.
9086
+ // - `remap_property_value` is the near miss and still misses twice: it
9087
+ // `break`s unless `typeof oldValue === 'string'` (these values are
9088
+ // `UPGAssessment` objects, or bare numbers in older graphs), and its
9089
+ // `to_property` split OVERWRITES the source with `reset_value`, which
9090
+ // is precisely the staging this release is buying.
9091
+ // - `reshape_value_to_assessment` wraps a bare number on a named scale;
9092
+ // it does not move a key.
9093
+ // The edge-side `kind: 'rename'` (UPG_EDGE_MIGRATIONS, e.g. 0.8.0's
9094
+ // `theme_groups_feature` -> `roadmap_theme_groups_feature`) renames an
9095
+ // EDGE TYPE across instances and has no property-key analogue. Adding one
9096
+ // is new spec surface: a ratified decision, not a side effect of one
9097
+ // property rename.
9098
+ //
9099
+ // The scale moves ride along and need no rule either. `PROPERTY_SCALE_MAP`
9100
+ // resolves `likelihood` to `likelihood_5` (which carries `threat.likelihood`
9101
+ // off `confidence_5` in the same line, since the map is keyed by name) and
9102
+ // `PROPERTY_SCALE_MAP_BY_ENTITY` resolves `risk.impact` to `severity_5`. Both
9103
+ // resolve at READ time, and an assessment only overrides them by PINNING a
9104
+ // `scale_id` on the stored value. Measured across all 36 `.upg` files in the
9105
+ // repo: zero assessments pin a `scale_id` on `likelihood`, `probability` or
9106
+ // `impact`, so there is nothing stamped to re-stamp. One that does pin a
9107
+ // `scale_id` keeps it, by the existing contract.
9108
+ //
9109
+ // What lands at 1.0.0, written down now so it is not rediscovered:
9110
+ // { kind: 'drop_props', type: 'risk', drop_props: ['probability'],
9111
+ // reason: '1.0.0: risk.probability was @deprecated since 0.35.0 with
9112
+ // removeIn="1.0.0"; superseded by `likelihood` on likelihood_5.' }
9113
+ "0.35.0": [],
8392
9114
  "0.32.0": [
8393
9115
  // C3 — archive becomes a base-node axis. WorkspaceProperties.archived /
8394
9116
  // archived_at shipped the orthogonal-archive idea for exactly one type;
@@ -11966,8 +12688,8 @@ var UPG_PROPERTY_SCHEMA = {
11966
12688
  },
11967
12689
  // CompositionProperties
11968
12690
  composition: {
11969
- member_query: { type: "object", description: "When present, membership is DERIVED: members are produced by running this query rather than authored by placement.", notes: "This is the portable statement of what the layer shows. On a composition, `CompositionMember.href` remains the publishing tool's own resolved route and stays opaque to everyone else; a member may carry both, and then the href is a fast path while the query is the meaning. A consumer that cannot parse the href can still render the layer, which is the whole reason the declaration is here rather than in a tool-namespaced bag key. A layer with no `member_query` is authored, which is what every composition written before 0.32.0 is. DECLARED ON BOTH HALVES OF THE PAIR since 0.33.0. A layer is query-driven while it is being worked on, not only once it is published, so declaring the query only on the durable composition would make it a fact invented at publish time rather than one recorded." },
11970
- presentation: { type: "object", description: "Advisory rendering intent for the layer as a whole. A consumer may ignore it entirely and still be conformant." },
12691
+ member_query: { type: "object", description: "When present, membership is DERIVED: members are produced by running this query rather than authored by placement. The clause list is authoritative and the named fields are a positive-only projection of it; since 0.34.0 a clause is a discriminated union on `dimension`, so the `type` axis carries entity types rather than free strings.", notes: "This is the portable statement of what the layer shows. On a composition, `CompositionMember.href` remains the publishing tool's own resolved route and stays opaque to everyone else; a member may carry both, and then the href is a fast path while the query is the meaning. A consumer that cannot parse the href can still render the layer, which is the whole reason the declaration is here rather than in a tool-namespaced bag key. A layer with no `member_query` is authored, which is what every composition written before 0.32.0 is. DECLARED ON BOTH HALVES OF THE PAIR since 0.33.0. A layer is query-driven while it is being worked on, not only once it is published, so declaring the query only on the durable composition would make it a fact invented at publish time rather than one recorded." },
12692
+ presentation: { type: "object", description: "Advisory rendering intent for the layer as a whole: `group_by`, `sort`, `layout`, `nest_by`, and `orphan_disposition` (0.34.0, absent means `'root'`). A consumer may ignore it entirely and still be conformant, because every default it then applies is the safe one.", notes: "THE DESCRIPTION LISTS THE FIELDS ON PURPOSE. This property is `object` in the runtime property registry, so an agent reading `get_entity_schema` gets an opaque blob and this sentence. For an object-typed property the description IS the declared shape, which is why `check:editorial` hashes it (E.4, 0.34.0) and why a field added to `UPGViewPresentation` without a word here would be invisible to every gate and every agent at once." },
11971
12693
  members: { type: "object[]", description: "The frozen member arrangement, captured at publish. Layout and pointers only, never resolved content." },
11972
12694
  rev: { type: "number", description: "Monotonic revision, bumped on each republish of the same slug.", notes: "A published revision is a fact about the composition, user-visible as a new print from the same plate, so it is serialised. Worth distinguishing from a store's concurrency token, which shares the name in some backends but is a fact about the table rather than about the thing, and is not spec data." },
11973
12695
  published_at: { type: "string", description: "ISO timestamp of the most recent publish or republish." },
@@ -13793,10 +14515,23 @@ var UPG_PROPERTY_SCHEMA = {
13793
14515
  // RiskProperties: Risk.
13794
14516
  risk: {
13795
14517
  risk_type: { type: "string", enum: ["technical", "business", "legal", "security", "operational", "program"], description: "Domain the risk belongs to. The single kind axis for `risk`: there is no second classification vocabulary. `program` added in v0.26.0 so the retired `risk_item` (Program Management) type has a home on the canonical `risk` after consolidation, rather than a parallel `risk_domain` field free to drift from this one." },
14518
+ likelihood: {
14519
+ type: "assessment",
14520
+ scale_id: "likelihood_5",
14521
+ description: "How likely this risk is to materialise. Rated on `likelihood_5` (Rare \u2192 Almost certain).",
14522
+ notes: 'Canonical name since 0.35.0, superseding `probability` below. Three reasons, in order of weight. (1) `probability` was one name for two incompatible types (`UPGAssessment` here, a bare `number` on `forecast.probability`), and `PROPERTY_SCALE_MAP` is keyed by name alone, so a sales percentage and a risk judgment resolved to the same ladder. (2) `likelihood` is already the spec\'s own word: the RISK_ITEM lifecycle prose says "Likelihood and impact have been evaluated", and `threat.likelihood` has been a `UPGAssessment` all along: one name, one type, one ladder. (3) ISO 31000 says likelihood. The ladder moved with the name: `likelihood_5` is new in 0.35.0 because no probability ladder existed and `confidence_5` is epistemic. It says how sure the assessor is, not how likely the event is.',
14523
+ properties: {
14524
+ value: { type: "number", description: "The numeric value, used for computation." },
14525
+ label: { type: "string", description: "The qualitative label (what the assessor meant)." },
14526
+ scale_id: { type: "string", description: "Which assessment scale this was rated on (optional)." },
14527
+ normalized: { type: "number", description: "Normalized 0-1 value for cross-tool comparison (optional)." }
14528
+ },
14529
+ required: ["value", "label"]
14530
+ },
13796
14531
  probability: {
13797
14532
  type: "assessment",
13798
- scale_id: "confidence_5",
13799
- description: "How likely this risk is to materialise (1 = unlikely, 5 = near certain)",
14533
+ scale_id: "likelihood_5",
14534
+ description: 'How likely this risk is to materialise (1 = unlikely, 5 = near certain). @deprecated since="0.35.0" removeIn="1.0.0". Use `likelihood`, which is the spec\'s own word for this in the risk lifecycle and on `threat`. Both names resolve to the same `likelihood_5` ladder for the length of the deprecation window (`PROPERTY_SCALE_MAP_BY_ENTITY.risk.probability`, Captain-ratified 2026-08-22): a deprecated field that renders on a DIFFERENT ladder from its replacement would make one stored 4 read "Confident" under the old name and "Likely" under the new one, which is the data changing meaning at the rename, which is the exact thing staging exists to prevent. `forecast.probability` is untouched and stays on `confidence_5`. STAGED, not renamed. The field is KEPT and still read: 0.35.0 changes what writers emit and what readers prefer, and changes NO stored bytes. A graph written before 0.35.0 carries `probability` and no `likelihood`, and reads correctly, which is the whole point of staging it. Writers: emit `likelihood`. Readers: prefer `likelihood`, fall back to `probability`. The fallback is a CONTRACT on consumers, not executable spec machinery, exactly as it is for `epic.estimate` \u2192 `effort`. `removeIn="1.0.0"` is a deadline, not a wish: at 1.0.0 this field is dropped by a `drop_props` rule in `UPG_PROPERTY_MIGRATIONS`, the same two-step the `removeIn="0.5.0"` properties followed (declared at 0.4.0, dropped by the 0.5.0 rules). Until then there is deliberately no executable rule: see the `\'0.35.0\'` block in `grammar/migrations.ts`.',
13800
14535
  properties: {
13801
14536
  value: { type: "number", description: "The numeric value, used for computation." },
13802
14537
  label: { type: "string", description: "The qualitative label (what the assessor meant)." },
@@ -13807,8 +14542,9 @@ var UPG_PROPERTY_SCHEMA = {
13807
14542
  },
13808
14543
  impact: {
13809
14544
  type: "assessment",
13810
- scale_id: "impact_5",
13811
- description: "Severity of consequences if the risk materialises (1 = negligible, 5 = catastrophic)",
14545
+ scale_id: "severity_5",
14546
+ description: "Severity of consequences if the risk materialises. Rated on `severity_5` (Mild inconvenience \u2192 Blocker), NOT the benefit-framed `impact_5`.",
14547
+ notes: "The ladder is set by `PROPERTY_SCALE_MAP_BY_ENTITY.risk.impact` (0.35.0), the per-entity override layer. `impact` legitimately means magnitude of BENEFIT on discovery and market entities, where high is good; on a risk it means severity of harm, where high is bad. Sharing `impact_5` rendered a catastrophic risk green.",
13812
14548
  properties: {
13813
14549
  value: { type: "number", description: "The numeric value, used for computation." },
13814
14550
  label: { type: "string", description: "The qualitative label (what the assessor meant)." },
@@ -13817,7 +14553,7 @@ var UPG_PROPERTY_SCHEMA = {
13817
14553
  },
13818
14554
  required: ["value", "label"]
13819
14555
  },
13820
- mitigation: { type: "string", description: "Planned or implemented mitigation strategy" }
14556
+ mitigation: { type: "string", description: "Planned or implemented mitigation strategy, as prose.", notes: "Prose only. A structured list of mitigating ACTIONS is a set of edges: `risk_mitigated_by_node` (0.35.0), pointing at the decisions, features and experiments that actually do the mitigating; a string array of them is unqueryable by construction. Likewise, what the risk puts at stake is `risk_threatens_node`, not a scope-list property." }
13821
14557
  },
13822
14558
  // RiskRegisterProperties: Risk register.
13823
14559
  risk_register: {
@@ -14071,7 +14807,9 @@ var UPG_PROPERTY_SCHEMA = {
14071
14807
  normalized: { type: "number", description: "Normalized 0-1 value for cross-tool comparison (optional)." }
14072
14808
  },
14073
14809
  required: ["value", "label"]
14074
- }
14810
+ },
14811
+ engagement_posture: { type: "string", enum: ["champion", "supporter", "neutral", "skeptic", "blocker"], description: "Which way this stakeholder leans: actively for, actively against, or neither. The third axis of the stakeholder model (0.35.0), beside the power/interest grid `influence` and `interest` describe.", notes: "`influence` and `interest` are magnitudes and carry no direction: a high-influence, high-interest stakeholder can be the strongest champion or the one who kills it, and the grid renders them identically. This closed enum is what makes \"who blocks this?\" a query rather than a reading exercise. Pairs with `UPG_ENUM_SCALES.EngagementPosture`. Posture is about the person's stance; it is NOT delivery health, which belongs to work items, and NOT the relationship's operational state." },
14812
+ engagement_cadence: { type: "string", enum: ["continuous", "hourly", "daily", "weekly", "monthly", "quarterly", "yearly", "on_demand", "other"], description: "How often this stakeholder is engaged. Uses the shared `Cadence` scale.", notes: 'Typed as `Cadence` rather than free text on purpose: v0.4.0 introduced that enum precisely to retire strings like `"2x/week"`, and a cadence that cannot be compared across stakeholders cannot answer "who have we not spoken to this quarter?". WHERE you meet them (the channel) is an app-level concern and is deliberately not modelled here.' }
14075
14813
  },
14076
14814
  // StatusReportProperties: Status report.
14077
14815
  status_report: {
@@ -14218,7 +14956,7 @@ var UPG_PROPERTY_SCHEMA = {
14218
14956
  team_type: { type: "string", enum: ["product", "engineering", "design", "growth", "customer_success"], description: "Functional area of the team" },
14219
14957
  size: { type: "number", description: "Number of people on the team" },
14220
14958
  mission: { type: "string", description: "Team's mission statement" },
14221
- key_prefix: { type: "string", description: 'Prefix this team mints node keys with (e.g. `"ENTP"`, giving `ENTP-1`, `ENTP-2`, ...). @example "ENTP"', notes: "SUPERSEDES `product.key_prefix` FOR THIS PRODUCT. The moment any team declares a prefix, the product-level prefix stops being consulted and the declared team prefixes become the candidate set a create surface offers. A product-level prefix that still resolved would win on order alone, and a multi-team product would then silently mint everything under it, which is the defect this field exists to end. A DECLARED PREFIX IS A CANDIDATE BEFORE IT IS OBSERVED. Candidates derived only from keys that already exist cannot see a team's first create, which is the one that most needs asking about. UNIQUENESS IS PRODUCT-SCOPED, AND A TEAM PREFIX DOES NOT WIDEN IT. The key sequence runs per product across entity types, so two teams in one product share one number line and never collide with each other. A team prefix names a team WITHIN that scope; it does not create a sequence that spans products. MINTING IS PRODUCT-SCOPED (normative, 0.33.0). `team` is `portfolio_shared`, so one team node can be referenced from two products. Minting is not portfolio-scoped with it. The rule, and it is a requirement rather than a recommendation: 1. A portfolio-shared team's prefix is NOT a minting candidate in a second product. The first product a team mints under is the only product that prefix mints in. 2. Refusal is NO-KEY. The node is created without a key. Refusal MUST NOT be an exception: a keyless create is a legal outcome everywhere else in the ladder, and throwing here would break creates that succeed today on every surface. Throwing stays reserved for a broken invariant, not for policy. 3. The rule applies on the MINT path, not the picker path, and it covers the INFERRED case. A prefix that was never requested by anyone, and was derived from keys that already exist in the second product, is refused on the same terms as one a caller named. A guard that only inspects an explicitly requested prefix misses the quiet path, and the quiet path is the one a fixture reproduces. WHY THE SCOPE STOPS AT THE PRODUCT. Key uniqueness is enforced by a `(product_id, key)` index, which permits the same key under two product ids by construction. A prefix that minted in two products would therefore run two independent sequences under one name and hand two different nodes the same citation, with nothing objecting. Portfolio-shared team minting is DEFERRED until a supra-product uniqueness design exists, rather than approximated. This rule states the CONTRACT. The behaviour belongs to whatever mints keys, which is not this package: see `UPGBaseNode.key`." }
14959
+ key_prefix: { type: "string", description: 'Prefix this team mints node keys with (e.g. `"ENTP"`, giving `ENTP-1`, `ENTP-2`, ...). @example "ENTP"', notes: "SUPERSEDES `product.key_prefix` FOR THIS PRODUCT, AND NOTHING ELSE (normative, narrowed in 0.34.0). The moment any team declares a prefix, the PRODUCT-LEVEL prefix stops being consulted. A product-level prefix that still resolved would win on order alone, and a multi-team product would then silently mint everything under it, which is the defect this field exists to end. THE CANDIDATE SET IS THE UNION OF DECLARED AND OBSERVED PREFIXES. A declaration adds a candidate; it does not remove one. A prefix stops being offered only when something claims it or when nothing has ever minted under it, and while more than one candidate stands the create surface keeps asking. WHY THIS WAS NARROWED, stated because 0.33.0 shipped the wider reading and an implementer built against it. The paragraph above made ANY declaration replace the candidate set outright, and its own stated rationale is entirely about `product.key_prefix`: a SINGLE STRING, declared once, that cannot represent two teams. An OBSERVED prefix is not that. It is evidence of a namespace already in active use. Suppressing it reproduces the precise defect this field exists to end, inside one product, and does so silently. Measured on the only keyed graph in the estate: it carries two observed prefixes, 370 keys under one and 662 under the other, and declares neither. Under the wider reading, one team declaring the smaller prefix collapses the candidate set to it, the picker disappears, and every later create mints under it, including the 662 keys' worth of work belonging to the other namespace. The sentence over-reached beyond its own reason, and this narrows it back to that reason. Shipped as a CHANGE in 0.34.0 rather than as a patch correction. Read as a correction it is defensible, but implementers had already built to the wider text, and moving a contract under them in a patch is how a patch becomes a surprise. A DECLARED PREFIX IS A CANDIDATE BEFORE IT IS OBSERVED. Candidates derived only from keys that already exist cannot see a team's first create, which is the one that most needs asking about. That is why declaration ADDS to the candidate set; it is not a reason for it to subtract. UNIQUENESS IS PRODUCT-SCOPED, AND A TEAM PREFIX DOES NOT WIDEN IT. The key sequence runs per product across entity types, so two teams in one product share one number line and never collide with each other. A team prefix names a team WITHIN that scope; it does not create a sequence that spans products. MINTING IS PRODUCT-SCOPED (normative, 0.33.0). `team` is `portfolio_shared`, so one team node can be referenced from two products. Minting is not portfolio-scoped with it. The rule, and it is a requirement rather than a recommendation: 1. A portfolio-shared team's prefix is NOT a minting candidate in a second product. The first product a team mints under is the only product that prefix mints in. 2. Refusal is NO-KEY. The node is created without a key. Refusal MUST NOT be an exception: a keyless create is a legal outcome everywhere else in the ladder, and throwing here would break creates that succeed today on every surface. Throwing stays reserved for a broken invariant, not for policy. 3. The rule applies on the MINT path, not the picker path, and it covers the INFERRED case. A prefix that was never requested by anyone, and was derived from keys that already exist in the second product, is refused on the same terms as one a caller named. A guard that only inspects an explicitly requested prefix misses the quiet path, and the quiet path is the one a fixture reproduces. WHY THE SCOPE STOPS AT THE PRODUCT. Key uniqueness is enforced by a `(product_id, key)` index, which permits the same key under two product ids by construction. A prefix that minted in two products would therefore run two independent sequences under one name and hand two different nodes the same citation, with nothing objecting. Portfolio-shared team minting is DEFERRED until a supra-product uniqueness design exists, rather than approximated. HOW RULE 1 IS DECIDED: THE EVIDENCE RULE (normative, 0.34.0). Rule 1 names a first product without saying how a minter knows which one it is. It is decided by EVIDENCE, not by a stored marker: at mint, if any other IN-SCOPE product already holds a key under the prefix, refuse. Evidence is derivable from the graphs themselves, needs no migration, cannot go stale, and cannot disagree with the keys. A durable home marker could do all three, and would mint state for a fact the graph already carries. The cost is stated rather than hidden: evidence is SCOPE-DEPENDENT, which is why the scope is ruled below in the same breath rather than left open. THE UNDECIDABLE CASE: NEITHER MINTS (normative, 0.34.0). When two products already hold keys under one prefix and nothing establishes which was first, NEITHER mints. No tiebreak is invented. Creation order is not recorded, and `max(existing)` measures import volume rather than precedence, so any tiebreak would be a guess wearing a rule, and a silent one, since it would attribute a namespace to a product with nothing to say it was wrong. Refusing both is the NO-KEY outcome rule 2 already sanctions, and it is recoverable: once either product declares the prefix, the other is unambiguous and a backfill can run. WHAT \"IN SCOPE\" MEANS: ENGINE-DEFINED, WITH A FLOOR AND A CEILING (normative, 0.34.0). The scope over which the evidence rule looks is defined by the engine, bounded on both sides. FLOOR. It MUST include every product the engine can enumerate for this caller. An engine that looks at fewer products than it can see is choosing not to notice a collision it could have seen. CEILING. It MUST NEVER include a product the caller could not otherwise read. A wider read is a cross-tenant information channel: refusing a mint because of a key in a graph the caller cannot see leaks that the graph exists and what is in it. This half is a security constraint and is not negotiable. PORTFOLIO ALTITUDE IS THE WRONG NORMATIVE ALTITUDE, and it was measured rather than argued: deleting the portfolio document changes nothing about minting, because no minter consults the portfolio seam. Stating the invariant there states it where nobody looks. In practice the local engine's scope is every graph in the workspace folder and the cloud engine's is the caller's own product list. THE HONEST CONSEQUENCE, which belongs in the text rather than in a later surprise: the invariant is SCOPE-RELATIVE. Two engines can legitimately disagree about whether one mint is safe, because they can legitimately see different sets of products. That is a real limitation of the evidence rule and the price of the ceiling. IMMUTABLE ONCE ANYTHING HAS MINTED UNDER IT, PER PRODUCT (normative, 0.34.0). Once any key exists under this prefix IN A GIVEN PRODUCT, the declaration cannot be edited for that product. Refusal-shaped and NO-KEY, matching rule 2: never an exception, because a keyless create is legal everywhere else in the ladder. SCOPED PER PRODUCT, NOT PER TEAM, and the reason is that `team` is `portfolio_shared`: a team that has never minted in product B must still be free to declare there. A per-team global lock would strand it. WHAT IT PREVENTS. Without it, a team edits its prefix after four hundred mints and one product silently carries two number lines under two names, with nothing recording that they were ever one sequence. RENAMING STAYS POSSIBLE BY THE HONEST ROUTE: a migration that rewrites the existing keys. That is a deliberate act with a visible cost, which is the difference between renaming a namespace and forking it by accident. THE PICKER MAY OFFER WHAT THE MINT REFUSES, AND THE SURFACE OWNS THE DIVERGENCE (0.34.0). Rule 3 applies on the MINT path and not the picker path, which is deliberate: the picker cannot cheaply know the answer, since knowing it requires reading other products. The consequence is that a surface can present a choice that then fails. The owner is named here rather than left implicit: A CREATE SURFACE THAT OFFERS A PREFIX THE MINT MAY REFUSE MUST BE ABLE TO REPORT THE REFUSAL, AND MUST BE ABLE TO PRESENT NO-KEY AS AN OUTCOME RATHER THAN AS AN ERROR. This is a design obligation on the surface, not a spec mechanic: the spec cannot fix a UX gap and should not pretend to. The union ruling above shrinks the divergence considerably, because the picker now keeps asking in exactly the case that would otherwise resolve wrongly. This rule states the CONTRACT. The behaviour belongs to whatever mints keys, which is not this package: see `UPGBaseNode.key`." }
14222
14960
  },
14223
14961
  // TeamOkrProperties: TeamOkr entity.
14224
14962
  team_okr: {
@@ -14329,7 +15067,7 @@ var UPG_PROPERTY_SCHEMA = {
14329
15067
  category: { type: "string", description: 'Attack or threat scenario. @example "injection", "misconfiguration", "social engineering", "supply chain"' },
14330
15068
  likelihood: {
14331
15069
  type: "assessment",
14332
- scale_id: "confidence_5",
15070
+ scale_id: "likelihood_5",
14333
15071
  description: "Likelihood (1 = theoretical, 5 = actively exploited). @example value 5 for a known, exploitable, commonly targeted pattern",
14334
15072
  properties: {
14335
15073
  value: { type: "number", description: "The numeric value, used for computation." },
@@ -14544,8 +15282,8 @@ var UPG_PROPERTY_SCHEMA = {
14544
15282
  },
14545
15283
  // WorkspaceProperties: Workspace: a spatial thinking space for arranging entities.
14546
15284
  workspace: {
14547
- member_query: { type: "object", description: "When present, membership is DERIVED: members are produced by running this query rather than authored by placement.", notes: "This is the portable statement of what the layer shows. On a composition, `CompositionMember.href` remains the publishing tool's own resolved route and stays opaque to everyone else; a member may carry both, and then the href is a fast path while the query is the meaning. A consumer that cannot parse the href can still render the layer, which is the whole reason the declaration is here rather than in a tool-namespaced bag key. A layer with no `member_query` is authored, which is what every composition written before 0.32.0 is. DECLARED ON BOTH HALVES OF THE PAIR since 0.33.0. A layer is query-driven while it is being worked on, not only once it is published, so declaring the query only on the durable composition would make it a fact invented at publish time rather than one recorded." },
14548
- presentation: { type: "object", description: "Advisory rendering intent for the layer as a whole. A consumer may ignore it entirely and still be conformant." },
15285
+ member_query: { type: "object", description: "When present, membership is DERIVED: members are produced by running this query rather than authored by placement. The clause list is authoritative and the named fields are a positive-only projection of it; since 0.34.0 a clause is a discriminated union on `dimension`, so the `type` axis carries entity types rather than free strings.", notes: "This is the portable statement of what the layer shows. On a composition, `CompositionMember.href` remains the publishing tool's own resolved route and stays opaque to everyone else; a member may carry both, and then the href is a fast path while the query is the meaning. A consumer that cannot parse the href can still render the layer, which is the whole reason the declaration is here rather than in a tool-namespaced bag key. A layer with no `member_query` is authored, which is what every composition written before 0.32.0 is. DECLARED ON BOTH HALVES OF THE PAIR since 0.33.0. A layer is query-driven while it is being worked on, not only once it is published, so declaring the query only on the durable composition would make it a fact invented at publish time rather than one recorded." },
15286
+ presentation: { type: "object", description: "Advisory rendering intent for the layer as a whole: `group_by`, `sort`, `layout`, `nest_by`, and `orphan_disposition` (0.34.0, absent means `'root'`). A consumer may ignore it entirely and still be conformant, because every default it then applies is the safe one.", notes: "THE DESCRIPTION LISTS THE FIELDS ON PURPOSE. This property is `object` in the runtime property registry, so an agent reading `get_entity_schema` gets an opaque blob and this sentence. For an object-typed property the description IS the declared shape, which is why `check:editorial` hashes it (E.4, 0.34.0) and why a field added to `UPGViewPresentation` without a word here would be invisible to every gate and every agent at once." },
14549
15287
  visibility: { type: "string", enum: ["private", "shared", "public"], description: "Who can see this workspace" },
14550
15288
  purpose: { type: "string", description: "Free-text description. Pairs with the closed-enum `workspace_purpose`." },
14551
15289
  workspace_purpose: { type: "string", enum: ["discovery", "planning", "retrospective", "design", "research", "strategy", "general"], description: "What the workspace is for. Drives template suggestions and surfaces in workspace browsers.", notes: "`discovery` is persona, job and opportunity exploration. `planning` covers roadmap and decision sessions. `retrospective` is reflection on shipped work. `design` is experience or UI exploration. `research` organises study data and synthesis. `strategy` is high-level direction setting. `general` is the catch-all." },
@@ -21314,10 +22052,16 @@ function validateUPGDocument(doc) {
21314
22052
  }
21315
22053
  const d = doc;
21316
22054
  if (!d.upg_version || typeof d.upg_version !== "string") {
21317
- errors.push({ path: "$.upg_version", message: "upg_version is required and must be a string" });
22055
+ errors.push({
22056
+ path: "$upg.spec_version",
22057
+ message: "spec_version is required and must be a string"
22058
+ });
21318
22059
  }
21319
22060
  if (!d.exported_at || typeof d.exported_at !== "string") {
21320
- errors.push({ path: "$.exported_at", message: "exported_at is required and must be an ISO 8601 string" });
22061
+ errors.push({
22062
+ path: "$upg.provenance.exported_at",
22063
+ message: "provenance.exported_at is required and must be an ISO 8601 string"
22064
+ });
21321
22065
  }
21322
22066
  if (!d.source || typeof d.source !== "object") {
21323
22067
  errors.push({ path: "$.source", message: "source is required and must be an object" });
@@ -29013,6 +29757,48 @@ var UPG_ANTI_PATTERNS = [
29013
29757
  severity: "medium",
29014
29758
  source: { kind: "fundamental" }
29015
29759
  },
29760
+ // ── Citable-key collision (0.34.0): portfolio-scoped, and the FIRST detector
29761
+ // to ship with a labeled corpus behind it (packages/upg-evals/corpora/
29762
+ // intelligence/duplicate-key-across-products/).
29763
+ //
29764
+ // WHY IT CANNOT BE A SINGLE-GRAPH CHECK. Key uniqueness is enforced by a
29765
+ // `(product_id, key)` index, so each product reports its own key as valid. The
29766
+ // collision is only visible from above, which is why this is `scope: 'portfolio'`
29767
+ // and carries no structured_condition: the detector reads across products, and
29768
+ // IntelligenceCondition composes aggregate counts within one graph.
29769
+ //
29770
+ // MECHANICALLY DECIDABLE, which is unusual in this file and is why it can ship
29771
+ // enforced: one `(prefix, number)` pair appearing in two products of one
29772
+ // portfolio, with no judgement about intent. Every other portfolio entry here
29773
+ // approximates a per-node rule; this one is exact.
29774
+ //
29775
+ // ENFORCED FROM DAY ONE. What was staged is the CORPUS, not the enforcement.
29776
+ // The tempting shape was a check that ships "defined" and becomes "enforced"
29777
+ // later, and there is no such mechanic: a registered detector that declines to
29778
+ // fire is worse than either real option, and nothing in the spec could hang it.
29779
+ // The detector has little to fire on until a second keyed product exists, and
29780
+ // that is a property of the estate rather than of the check.
29781
+ //
29782
+ // THE NEAR-MISSES ARE CONSTRUCTED, and the corpus says so in its own README
29783
+ // rather than in a plan nobody opens. Three classes: two products sharing a
29784
+ // prefix over DISJOINT number ranges (latent, not yet colliding); a
29785
+ // DELIBERATELY shared prefix across a product family wanting one citation
29786
+ // namespace; and a product holding IMPORTED keys minted elsewhere. Until a real
29787
+ // collision is sampled, the recall figure is a claim about the author's
29788
+ // imagination. The corpus carries a dated obligation to re-grade precision and
29789
+ // recall on the first sampled collision.
29790
+ {
29791
+ id: "duplicate-key-across-products",
29792
+ since: "0.34.0",
29793
+ scope: "portfolio",
29794
+ name: "One citable key, two products",
29795
+ description: "The same (prefix, number) pair identifies a node in two or more products of one portfolio. Keys are minted per product and uniqueness is enforced by a (product_id, key) index, so two products minting under one prefix run two independent sequences under one name. Each product reports its own key as valid and only the portfolio can see that the citation is ambiguous.",
29796
+ why_it_matters: "A key exists to be cited. When one citation resolves to two different things, every reference made with it becomes ambiguous after the fact, including references already written down outside the graph where nothing can be corrected. The damage is retroactive and grows with adoption: the longer both sequences run, the more citations a reconciliation has to rewrite.",
29797
+ remediation: "Decide which product owns the prefix and declare it there with team.key_prefix, so ownership is explicit rather than inferred. Migrate the other product by rewriting its existing keys, which is deliberate and visibly costly, never by editing a declaration under a live sequence. If both products want one namespace, record that decision so it does not read as drift.",
29798
+ stages: ["build", "beta", "launch", "growth", "mature"],
29799
+ severity: "high",
29800
+ source: { kind: "fundamental" }
29801
+ },
29016
29802
  // ── surface (0.27.0): the place, its guest list, and its arbitration rule ──
29017
29803
  // Three patterns, calibrated so the contention one leads and the two coverage
29018
29804
  // companions sit a tier below it. Like every entry in this file, each detector
@@ -32757,8 +33543,8 @@ var NODE_KEY_ORDER = [
32757
33543
  "sort_order",
32758
33544
  "properties"
32759
33545
  ];
32760
- var EDGE_KEY_ORDER = ["id", "source", "target", "type", "mapping_confidence", "properties"];
32761
- var CROSS_EDGE_KEY_ORDER = ["id", "source", "target", "type", "source_product_id", "target_product_id", "mapping_confidence", "alias", "relevance", "audience_role"];
33546
+ var EDGE_KEY_ORDER = ["id", "source", "target", "type", "mapping_confidence", "provenance", "properties"];
33547
+ var CROSS_EDGE_KEY_ORDER = ["id", "source", "target", "type", "source_product_id", "target_product_id", "mapping_confidence", "properties", "alias", "relevance", "audience_role"];
32762
33548
  var PRODUCT_KEY_ORDER = ["id", "title", "description", "stage", "properties"];
32763
33549
  function canonicalNode(node) {
32764
33550
  const repaired = repairNodeDrift(node);
@@ -32775,7 +33561,14 @@ function canonicalEdge(edge) {
32775
33561
  }
32776
33562
  function canonicalCrossEdge(edge) {
32777
33563
  return orderedObject(edge, CROSS_EDGE_KEY_ORDER, {
32778
- forceKeys: ["id", "source", "target", "type"]
33564
+ forceKeys: ["id", "source", "target", "type"],
33565
+ // `properties` is an OPEN bag and must be canonicalised like every other one
33566
+ // (node, edge, product all pass it). Without this, two writers emitting the
33567
+ // same parity assessment with their keys in a different order produce
33568
+ // different bytes, which breaks contract 3 of this format: input key order
33569
+ // does not change the output. Free to fix today and measured as such: zero
33570
+ // of the 61 cross-edges in the estate carry properties.
33571
+ openKeys: ["properties"]
32779
33572
  });
32780
33573
  }
32781
33574
  function canonicalProduct(product) {
@@ -33036,7 +33829,7 @@ function checkHeaderSealText(text) {
33036
33829
  }
33037
33830
 
33038
33831
  // src/index.ts
33039
- var UPG_VERSION = "0.33.1";
33832
+ var UPG_VERSION = "0.35.0";
33040
33833
  var UPG_FORMAT_VERSION = "0.4.0";
33041
33834
  var MARKDOWN_FORMAT_VERSION = "0.1";
33042
33835
  var UPG_TYPES = getTypes();
@@ -33099,6 +33892,14 @@ var UPG_ENTITY_COUNT = UPG_TYPES.length;
33099
33892
  var UPG_DOMAIN_COUNT = UPG_DOMAINS.length;
33100
33893
  var UPG_EDGE_COUNT = UPG_EDGE_TYPES.length;
33101
33894
  var UPG_META_COUNT = UPG_ENTITY_META.length;
33895
+ var UPG_PHASE_COUNT = (() => {
33896
+ const pairs = /* @__PURE__ */ new Set();
33897
+ for (const lifecycle of UPG_LIFECYCLES) {
33898
+ const owner = lifecycle.template_id ? `T:${lifecycle.template_id}` : `E:${lifecycle.entity_type}`;
33899
+ for (const phase of lifecycle.phases) pairs.add(`${owner}::${phase.id}`);
33900
+ }
33901
+ return pairs.size;
33902
+ })();
33102
33903
  export {
33103
33904
  ACTIVE_WHEN_PROPERTY,
33104
33905
  ANALYTICS_DATA_PLAYBOOK,
@@ -33110,10 +33911,12 @@ export {
33110
33911
  CONFIGURATION_VARIANCE_EDGE_PROPERTY_SCHEMA,
33111
33912
  CONTENT_DEPTH_WARNING_RULES,
33112
33913
  COVERAGE_ANTI_PATTERNS,
33914
+ CROSS_EDGE_KEY_ORDER,
33113
33915
  DEFAULT_ENTITY_EMOJI,
33114
33916
  DEFERRED_PROPOSED_BY_CONTRACT,
33115
33917
  DEFER_EDGE_PROPERTY_SCHEMA,
33116
33918
  DISCOVERY_RESEARCH_VALIDATION_PLAYBOOK,
33919
+ EDGE_KEY_ORDER,
33117
33920
  ENGINEERING_PLATFORM_PLAYBOOK,
33118
33921
  ENTITY_EMOJI,
33119
33922
  EXPERIENCE_DESIGN_BRAND_PLAYBOOK,
@@ -33128,6 +33931,7 @@ export {
33128
33931
  PROPERTY_MODIFIERS,
33129
33932
  PROPERTY_MODIFIER_SEMANTICS,
33130
33933
  PROPERTY_SCALE_MAP,
33934
+ PROPERTY_SCALE_MAP_BY_ENTITY,
33131
33935
  QUALIFIABLE_EDGE_TYPES,
33132
33936
  RECORD_ENTITY_TYPES,
33133
33937
  REFLECT_MODES,
@@ -33164,6 +33968,7 @@ export {
33164
33968
  UPG_EDGE_PAIR_MAP,
33165
33969
  UPG_EDGE_TYPES,
33166
33970
  UPG_ENTITY_COUNT,
33971
+ UPG_ENTITY_DESCRIPTIONS,
33167
33972
  UPG_ENTITY_FILTER_SPECS,
33168
33973
  UPG_ENTITY_META,
33169
33974
  UPG_ENTITY_META_BY_ID,
@@ -33181,7 +33986,9 @@ export {
33181
33986
  UPG_LIFECYCLE_PLANNED_TYPES,
33182
33987
  UPG_META_COUNT,
33183
33988
  UPG_MIGRATIONS,
33989
+ UPG_PHASE_COUNT,
33184
33990
  UPG_PLAYBOOKS,
33991
+ UPG_POLYMORPHIC_EDGE_FAMILIES,
33185
33992
  UPG_POLYMORPHIC_EDGE_KEYS,
33186
33993
  UPG_PORTFOLIO_KINDS,
33187
33994
  UPG_PORTFOLIO_SHARED_TYPES,
@@ -33263,6 +34070,7 @@ export {
33263
34070
  getDomainIdForType,
33264
34071
  getDomainsInRing,
33265
34072
  getEdgePropertySchema,
34073
+ getEntityDescription,
33266
34074
  getEntityModifierSummary,
33267
34075
  getEnumScale,
33268
34076
  getEnumValueMeta,