@company-semantics/contracts 0.1.0 → 0.2.1

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/index.ts CHANGED
@@ -21,13 +21,22 @@ export type InsightConfidence = 'low' | 'medium' | 'high'
21
21
  // Invariant enforcement phases (4.0 Observe → 4.1 Stabilize → 4.2 Enforce)
22
22
  export type InvariantPhase = 'observe' | 'stabilize' | 'enforce'
23
23
 
24
- // System snapshot types (Living ASCII Diagram)
24
+ // System diagram types (Living ASCII Diagram)
25
25
  // @see docs/LIVING_ASCII_DIAGRAM_SPEC.md
26
26
  export type {
27
+ // Layer-based manifest (source of truth)
27
28
  FeatureStatus,
28
29
  SystemCapability,
29
30
  SystemLayer,
30
31
  SystemCapabilityManifest,
32
+ // Snapshot metadata
31
33
  SystemSnapshotMeta,
34
+ /** @deprecated Use DiagramSpec instead */
32
35
  SystemSnapshot,
36
+ // Graph-based diagram spec (new architecture)
37
+ DiagramNodeKind,
38
+ DiagramEdgeRelation,
39
+ DiagramNode,
40
+ DiagramEdge,
41
+ DiagramSpec,
33
42
  } from './system/index.js'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@company-semantics/contracts",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
@@ -0,0 +1,46 @@
1
+ # system/
2
+
3
+ ## Purpose
4
+
5
+ TypeScript types for the Living ASCII System Diagram feature.
6
+ Defines the semantic contract between backend (producer) and site (renderer).
7
+
8
+ **Key architecture:**
9
+ - Backend owns MEANING (produces `DiagramSpec` with nodes/edges)
10
+ - Client owns RENDERING (ASCII, SVG, canvas, etc.)
11
+ - No diagram artifacts committed — runtime rendering only
12
+
13
+ ## Invariants
14
+
15
+ - Types only — no runtime code
16
+ - Schema changes require coordinated releases across repos
17
+ - No render hints in contracts — renderers decide presentation independently
18
+ - `layer` metadata is semantic grouping, not layout instruction
19
+
20
+ ## Public API
21
+
22
+ ### Source model (layer-based)
23
+ - `FeatureStatus` — 'prod' | 'experimental' | 'disabled'
24
+ - `SystemCapability` — individual feature definition
25
+ - `SystemLayer` — logical layer grouping
26
+ - `SystemCapabilityManifest` — full manifest structure (YAML representation)
27
+
28
+ ### Diagram graph (new architecture)
29
+ - `DiagramNodeKind` — 'layer' | 'feature' | 'artifact'
30
+ - `DiagramEdgeRelation` — 'contains' | 'flows_to' | 'depends_on'
31
+ - `DiagramNode` — semantic node with optional layer grouping
32
+ - `DiagramEdge` — semantic relationship between nodes
33
+ - `DiagramSpec` — complete graph that crosses system boundaries
34
+
35
+ ### Metadata (retained for compatibility)
36
+ - `SystemSnapshotMeta` — generation metadata
37
+ - `SystemSnapshot` — **deprecated**, use DiagramSpec instead
38
+
39
+ ## Dependencies
40
+
41
+ **Imports from:** (none — leaf module)
42
+ **Imported by:** company-semantics (backend), company-semantics-site
43
+
44
+ ## Specification
45
+
46
+ See [LIVING_ASCII_DIAGRAM_SPEC.md](../docs/LIVING_ASCII_DIAGRAM_SPEC.md) for the canonical system definition.
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Diagram Specification Types
3
+ *
4
+ * Graph-based semantic model for system diagrams.
5
+ * These types define MEANING, not presentation.
6
+ *
7
+ * Key invariants:
8
+ * - No render hints — renderers decide presentation independently
9
+ * - layer metadata is semantic grouping, not layout instruction
10
+ * - Graphs can be rendered as ASCII, SVG, canvas, or any future format
11
+ *
12
+ * @see ../docs/LIVING_ASCII_DIAGRAM_SPEC.md
13
+ */
14
+
15
+ import type { FeatureStatus } from './index.js'
16
+
17
+ /**
18
+ * The semantic role of a node in the diagram.
19
+ */
20
+ export type DiagramNodeKind = 'layer' | 'feature' | 'artifact'
21
+
22
+ /**
23
+ * The semantic relationship between nodes.
24
+ */
25
+ export type DiagramEdgeRelation = 'contains' | 'flows_to' | 'depends_on'
26
+
27
+ /**
28
+ * A node in the diagram graph.
29
+ * Represents a semantic entity, not a visual element.
30
+ */
31
+ export interface DiagramNode {
32
+ /** Unique identifier */
33
+ id: string
34
+ /** Human-readable label */
35
+ label: string
36
+ /** Semantic role */
37
+ kind: DiagramNodeKind
38
+ /** Feature maturity status (only for 'feature' nodes) */
39
+ status?: FeatureStatus
40
+ /** Semantic grouping (not layout instruction) */
41
+ layer?: string
42
+ /** Order within layer for pipeline semantics */
43
+ orderInLayer?: number
44
+ }
45
+
46
+ /**
47
+ * An edge connecting two nodes.
48
+ * Represents a semantic relationship, not a visual connector.
49
+ */
50
+ export interface DiagramEdge {
51
+ /** Source node ID */
52
+ from: string
53
+ /** Target node ID */
54
+ to: string
55
+ /** Type of relationship */
56
+ relation: DiagramEdgeRelation
57
+ }
58
+
59
+ /**
60
+ * Complete diagram specification.
61
+ *
62
+ * This is the contract that crosses system boundaries.
63
+ * Backend produces it, clients consume it, renderers interpret it.
64
+ *
65
+ * IMPORTANT: No render hints. Renderers decide presentation.
66
+ */
67
+ export interface DiagramSpec {
68
+ /** All nodes in the diagram */
69
+ nodes: DiagramNode[]
70
+ /** All edges connecting nodes */
71
+ edges: DiagramEdge[]
72
+ }
package/system/index.ts CHANGED
@@ -1,10 +1,15 @@
1
1
  /**
2
- * System Snapshot Types
2
+ * System Diagram Types
3
3
  *
4
4
  * Schema for the Living ASCII System Diagram feature.
5
5
  * These types define the contract between:
6
- * - company-semantics (generates snapshots)
7
- * - company-semantics-site (renders snapshots)
6
+ * - company-semantics (produces semantic DiagramSpec)
7
+ * - company-semantics-site (renders diagrams client-side)
8
+ *
9
+ * Architecture:
10
+ * - Backend owns MEANING (DiagramSpec with nodes/edges)
11
+ * - Client owns RENDERING (ASCII, SVG, etc.)
12
+ * - No diagram artifacts are committed — runtime rendering only
8
13
  *
9
14
  * @see docs/LIVING_ASCII_DIAGRAM_SPEC.md
10
15
  */
@@ -79,7 +84,8 @@ export interface SystemSnapshotMeta {
79
84
 
80
85
  /**
81
86
  * Complete snapshot bundle (ASCII + metadata).
82
- * Used when fetching/importing into the site.
87
+ * @deprecated Use DiagramSpec instead. This type will be removed in a future version.
88
+ * ASCII rendering now happens client-side from DiagramSpec.
83
89
  */
84
90
  export interface SystemSnapshot {
85
91
  /** Raw ASCII diagram content */
@@ -89,3 +95,12 @@ export interface SystemSnapshot {
89
95
  /** Optional explanation markdown */
90
96
  explanation?: string
91
97
  }
98
+
99
+ // Graph-based diagram types (new architecture)
100
+ export type {
101
+ DiagramNodeKind,
102
+ DiagramEdgeRelation,
103
+ DiagramNode,
104
+ DiagramEdge,
105
+ DiagramSpec,
106
+ } from './diagram.js'