@company-semantics/contracts 0.0.9 → 0.2.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/index.ts +20 -0
- package/package.json +2 -1
- package/system/README.md +46 -0
- package/system/diagram.ts +72 -0
- package/system/index.ts +106 -0
package/index.ts
CHANGED
|
@@ -20,3 +20,23 @@ export type InsightConfidence = 'low' | 'medium' | 'high'
|
|
|
20
20
|
|
|
21
21
|
// Invariant enforcement phases (4.0 Observe → 4.1 Stabilize → 4.2 Enforce)
|
|
22
22
|
export type InvariantPhase = 'observe' | 'stabilize' | 'enforce'
|
|
23
|
+
|
|
24
|
+
// System diagram types (Living ASCII Diagram)
|
|
25
|
+
// @see docs/LIVING_ASCII_DIAGRAM_SPEC.md
|
|
26
|
+
export type {
|
|
27
|
+
// Layer-based manifest (source of truth)
|
|
28
|
+
FeatureStatus,
|
|
29
|
+
SystemCapability,
|
|
30
|
+
SystemLayer,
|
|
31
|
+
SystemCapabilityManifest,
|
|
32
|
+
// Snapshot metadata
|
|
33
|
+
SystemSnapshotMeta,
|
|
34
|
+
/** @deprecated Use DiagramSpec instead */
|
|
35
|
+
SystemSnapshot,
|
|
36
|
+
// Graph-based diagram spec (new architecture)
|
|
37
|
+
DiagramNodeKind,
|
|
38
|
+
DiagramEdgeRelation,
|
|
39
|
+
DiagramNode,
|
|
40
|
+
DiagramEdge,
|
|
41
|
+
DiagramSpec,
|
|
42
|
+
} from './system/index.js'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@company-semantics/contracts",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"types": "./index.ts",
|
|
16
16
|
"files": [
|
|
17
17
|
"index.ts",
|
|
18
|
+
"system/",
|
|
18
19
|
"README.md"
|
|
19
20
|
],
|
|
20
21
|
"publishConfig": {
|
package/system/README.md
ADDED
|
@@ -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
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* System Diagram Types
|
|
3
|
+
*
|
|
4
|
+
* Schema for the Living ASCII System Diagram feature.
|
|
5
|
+
* These types define the contract between:
|
|
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
|
|
13
|
+
*
|
|
14
|
+
* @see docs/LIVING_ASCII_DIAGRAM_SPEC.md
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Feature maturity status.
|
|
19
|
+
* Displayed as markers in the ASCII diagram:
|
|
20
|
+
* [*] prod
|
|
21
|
+
* [~] experimental
|
|
22
|
+
* [ ] disabled
|
|
23
|
+
*/
|
|
24
|
+
export type FeatureStatus = 'prod' | 'experimental' | 'disabled'
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* A single capability within a system layer.
|
|
28
|
+
*/
|
|
29
|
+
export interface SystemCapability {
|
|
30
|
+
/** Unique identifier (e.g., 'entity_extraction') */
|
|
31
|
+
id: string
|
|
32
|
+
/** Human-readable label (e.g., 'Entity Extraction') */
|
|
33
|
+
label: string
|
|
34
|
+
/** Current maturity status */
|
|
35
|
+
status: FeatureStatus
|
|
36
|
+
/** Display order within layer (lower = higher) */
|
|
37
|
+
order: number
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* A logical layer in the system architecture.
|
|
42
|
+
*/
|
|
43
|
+
export interface SystemLayer {
|
|
44
|
+
/** Unique identifier (e.g., 'semantics') */
|
|
45
|
+
id: string
|
|
46
|
+
/** Display label (e.g., 'SEMANTIC PROCESSING') */
|
|
47
|
+
label: string
|
|
48
|
+
/** Whether this layer is active */
|
|
49
|
+
enabled: boolean
|
|
50
|
+
/** Capabilities within this layer */
|
|
51
|
+
features: SystemCapability[]
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Full system capability manifest.
|
|
56
|
+
* This is the TypeScript representation of capabilities.yaml
|
|
57
|
+
*/
|
|
58
|
+
export interface SystemCapabilityManifest {
|
|
59
|
+
/** Manifest format version */
|
|
60
|
+
version: number
|
|
61
|
+
/** Schema version string (e.g., '1.0') */
|
|
62
|
+
schema_version: string
|
|
63
|
+
/** Ordered list of system layers */
|
|
64
|
+
layers: SystemLayer[]
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Metadata accompanying a generated snapshot.
|
|
69
|
+
*/
|
|
70
|
+
export interface SystemSnapshotMeta {
|
|
71
|
+
/** Metadata format version */
|
|
72
|
+
version: number
|
|
73
|
+
/** ISO 8601 timestamp of generation */
|
|
74
|
+
snapshotDate: string
|
|
75
|
+
/** Git commit SHA of source */
|
|
76
|
+
commitSha: string
|
|
77
|
+
/** Schema version used for generation */
|
|
78
|
+
schemaVersion: string
|
|
79
|
+
/** Visibility level (always 'public' for now) */
|
|
80
|
+
visibility: 'public'
|
|
81
|
+
/** SHA256 checksum of the ASCII content */
|
|
82
|
+
checksum?: string
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Complete snapshot bundle (ASCII + metadata).
|
|
87
|
+
* @deprecated Use DiagramSpec instead. This type will be removed in a future version.
|
|
88
|
+
* ASCII rendering now happens client-side from DiagramSpec.
|
|
89
|
+
*/
|
|
90
|
+
export interface SystemSnapshot {
|
|
91
|
+
/** Raw ASCII diagram content */
|
|
92
|
+
ascii: string
|
|
93
|
+
/** Snapshot metadata */
|
|
94
|
+
meta: SystemSnapshotMeta
|
|
95
|
+
/** Optional explanation markdown */
|
|
96
|
+
explanation?: string
|
|
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'
|