@continuum-dev/runtime 0.1.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/LICENSE +21 -0
- package/README.md +403 -0
- package/index.d.ts +5 -0
- package/index.d.ts.map +1 -0
- package/index.js +4 -0
- package/lib/context.d.ts +128 -0
- package/lib/context.d.ts.map +1 -0
- package/lib/context.js +305 -0
- package/lib/reconcile.d.ts +17 -0
- package/lib/reconcile.d.ts.map +1 -0
- package/lib/reconcile.js +76 -0
- package/lib/reconciliation/collection-resolver.d.ts +13 -0
- package/lib/reconciliation/collection-resolver.d.ts.map +1 -0
- package/lib/reconciliation/collection-resolver.js +283 -0
- package/lib/reconciliation/component-resolver.d.ts +10 -0
- package/lib/reconciliation/component-resolver.d.ts.map +1 -0
- package/lib/reconciliation/differ.d.ts +12 -0
- package/lib/reconciliation/differ.d.ts.map +1 -0
- package/lib/reconciliation/differ.js +102 -0
- package/lib/reconciliation/migrator.d.ts +13 -0
- package/lib/reconciliation/migrator.d.ts.map +1 -0
- package/lib/reconciliation/migrator.js +92 -0
- package/lib/reconciliation/node-resolver.d.ts +10 -0
- package/lib/reconciliation/node-resolver.d.ts.map +1 -0
- package/lib/reconciliation/node-resolver.js +190 -0
- package/lib/reconciliation/state-builder.d.ts +13 -0
- package/lib/reconciliation/state-builder.d.ts.map +1 -0
- package/lib/reconciliation/state-builder.js +211 -0
- package/lib/reconciliation/validator.d.ts +14 -0
- package/lib/reconciliation/validator.d.ts.map +1 -0
- package/lib/reconciliation/validator.js +100 -0
- package/lib/reconciliation/view-traversal.d.ts +14 -0
- package/lib/reconciliation/view-traversal.d.ts.map +1 -0
- package/lib/reconciliation/view-traversal.js +72 -0
- package/lib/types.d.ts +153 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +1 -0
- package/package.json +44 -0
package/lib/types.d.ts
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import type { ViewNode, NodeValue, ViewDiff, IssueCode, IssueSeverity, DataSnapshot, DataResolution, ValueLineage, DetachedValue } from '@continuum/contract';
|
|
2
|
+
export interface ReconciliationResult {
|
|
3
|
+
/**
|
|
4
|
+
* The merged snapshot to persist and render after reconciliation.
|
|
5
|
+
*/
|
|
6
|
+
reconciledState: DataSnapshot;
|
|
7
|
+
/**
|
|
8
|
+
* Change events describing what happened to each affected node value.
|
|
9
|
+
*/
|
|
10
|
+
diffs: StateDiff[];
|
|
11
|
+
/**
|
|
12
|
+
* Validation and reconciliation warnings/errors emitted during processing.
|
|
13
|
+
*/
|
|
14
|
+
issues: ReconciliationIssue[];
|
|
15
|
+
/**
|
|
16
|
+
* Per-node explanation of how each value was resolved.
|
|
17
|
+
*/
|
|
18
|
+
resolutions: ReconciliationResolution[];
|
|
19
|
+
}
|
|
20
|
+
export interface StateDiff {
|
|
21
|
+
/**
|
|
22
|
+
* Node id in the reconciled view.
|
|
23
|
+
*/
|
|
24
|
+
nodeId: string;
|
|
25
|
+
/**
|
|
26
|
+
* Diff category such as added, removed, migrated, type-changed, or restored.
|
|
27
|
+
*/
|
|
28
|
+
type: ViewDiff;
|
|
29
|
+
/**
|
|
30
|
+
* Previous value from the prior snapshot (when available).
|
|
31
|
+
*/
|
|
32
|
+
oldValue?: unknown;
|
|
33
|
+
/**
|
|
34
|
+
* New value produced by reconciliation (when available).
|
|
35
|
+
*/
|
|
36
|
+
newValue?: unknown;
|
|
37
|
+
/**
|
|
38
|
+
* Optional machine-readable rationale for the diff.
|
|
39
|
+
*/
|
|
40
|
+
reason?: string;
|
|
41
|
+
}
|
|
42
|
+
export interface ReconciliationResolution {
|
|
43
|
+
/**
|
|
44
|
+
* Node id in the new view this resolution applies to.
|
|
45
|
+
*/
|
|
46
|
+
nodeId: string;
|
|
47
|
+
/**
|
|
48
|
+
* Matched node id from the prior view, if any.
|
|
49
|
+
*/
|
|
50
|
+
priorId: string | null;
|
|
51
|
+
/**
|
|
52
|
+
* How the prior node was matched to the new node.
|
|
53
|
+
*/
|
|
54
|
+
matchedBy: 'id' | 'key' | null;
|
|
55
|
+
/**
|
|
56
|
+
* Prior node type, if a prior node was found.
|
|
57
|
+
*/
|
|
58
|
+
priorType: string | null;
|
|
59
|
+
/**
|
|
60
|
+
* New node type in the current view.
|
|
61
|
+
*/
|
|
62
|
+
newType: string;
|
|
63
|
+
/**
|
|
64
|
+
* Final resolution outcome for this node.
|
|
65
|
+
*/
|
|
66
|
+
resolution: DataResolution;
|
|
67
|
+
/**
|
|
68
|
+
* Value observed in prior state before reconciliation.
|
|
69
|
+
*/
|
|
70
|
+
priorValue: unknown;
|
|
71
|
+
/**
|
|
72
|
+
* Value emitted for this node after reconciliation.
|
|
73
|
+
*/
|
|
74
|
+
reconciledValue: unknown;
|
|
75
|
+
}
|
|
76
|
+
export interface ReconciliationIssue {
|
|
77
|
+
/**
|
|
78
|
+
* Severity level to help route handling (error, warning, info).
|
|
79
|
+
*/
|
|
80
|
+
severity: IssueSeverity;
|
|
81
|
+
/**
|
|
82
|
+
* Optional node id associated with the issue.
|
|
83
|
+
*/
|
|
84
|
+
nodeId?: string;
|
|
85
|
+
/**
|
|
86
|
+
* Human-readable issue message for logs or UI.
|
|
87
|
+
*/
|
|
88
|
+
message: string;
|
|
89
|
+
/**
|
|
90
|
+
* Stable issue code for programmatic handling.
|
|
91
|
+
*/
|
|
92
|
+
code: IssueCode;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Runtime behavior flags and extension points for `reconcile`.
|
|
96
|
+
*/
|
|
97
|
+
export interface ReconciliationOptions {
|
|
98
|
+
/**
|
|
99
|
+
* When true, suppresses node-removed warnings for partial restoration workflows.
|
|
100
|
+
*
|
|
101
|
+
* Useful when your app intentionally allows temporary view pruning while keeping
|
|
102
|
+
* detached values around for later restoration.
|
|
103
|
+
*/
|
|
104
|
+
allowPartialRestore?: boolean;
|
|
105
|
+
/**
|
|
106
|
+
* When true and `priorView` is null, carries values by matching raw node ids.
|
|
107
|
+
*
|
|
108
|
+
* This is a fallback mode for sessions that have data but no previous view AST.
|
|
109
|
+
*/
|
|
110
|
+
allowBlindCarry?: boolean;
|
|
111
|
+
/**
|
|
112
|
+
* Per-node migration overrides keyed by the new node id.
|
|
113
|
+
*
|
|
114
|
+
* Use this when you know a specific node changed schema and needs custom logic.
|
|
115
|
+
*/
|
|
116
|
+
migrationStrategies?: Record<string, MigrationStrategy>;
|
|
117
|
+
/**
|
|
118
|
+
* Named migration functions referenced by view-level migration rules.
|
|
119
|
+
*
|
|
120
|
+
* Use with `newNode.migrations[*].strategyId` to keep migration logic reusable.
|
|
121
|
+
*/
|
|
122
|
+
strategyRegistry?: Record<string, MigrationStrategy>;
|
|
123
|
+
/**
|
|
124
|
+
* Time source used for lineage and detached value timestamps.
|
|
125
|
+
*
|
|
126
|
+
* Override in tests for deterministic assertions.
|
|
127
|
+
*/
|
|
128
|
+
clock?: () => number;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* User-provided transformation function used when a node schema changes.
|
|
132
|
+
*
|
|
133
|
+
* A strategy should return the value shape expected by the new node. The runtime
|
|
134
|
+
* passes raw prior value payloads so strategies can handle both simple and nested
|
|
135
|
+
* structures. Throwing from this function reports a migration failure issue.
|
|
136
|
+
*
|
|
137
|
+
* @param nodeId Node id in the new view being reconciled.
|
|
138
|
+
* @param priorNode Prior view node definition.
|
|
139
|
+
* @param newNode New view node definition.
|
|
140
|
+
* @param priorValue Previous value payload associated with the node.
|
|
141
|
+
* @returns Reconciled value payload for the new node.
|
|
142
|
+
*/
|
|
143
|
+
export type MigrationStrategy = (nodeId: string, priorNode: ViewNode, newNode: ViewNode, priorValue: unknown) => unknown;
|
|
144
|
+
export interface NodeResolutionAccumulator {
|
|
145
|
+
values: Record<string, NodeValue>;
|
|
146
|
+
valueLineage: Record<string, ValueLineage>;
|
|
147
|
+
detachedValues: Record<string, DetachedValue>;
|
|
148
|
+
restoredDetachedKeys: Set<string>;
|
|
149
|
+
diffs: StateDiff[];
|
|
150
|
+
resolutions: ReconciliationResolution[];
|
|
151
|
+
issues: ReconciliationIssue[];
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../packages/runtime/src/lib/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,SAAS,EACT,aAAa,EACb,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,aAAa,EACd,MAAM,qBAAqB,CAAC;AAE7B,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,eAAe,EAAE,YAAY,CAAC;IAC9B;;OAEG;IACH,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB;;OAEG;IACH,MAAM,EAAE,mBAAmB,EAAE,CAAC;IAC9B;;OAEG;IACH,WAAW,EAAE,wBAAwB,EAAE,CAAC;CACzC;AAED,MAAM,WAAW,SAAS;IACxB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,IAAI,EAAE,QAAQ,CAAC;IACf;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,wBAAwB;IACvC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB;;OAEG;IACH,SAAS,EAAE,IAAI,GAAG,KAAK,GAAG,IAAI,CAAC;IAC/B;;OAEG;IACH,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,UAAU,EAAE,cAAc,CAAC;IAC3B;;OAEG;IACH,UAAU,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,eA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.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@continuum-dev/runtime",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
7
|
+
"description": "Reconciliation engine for AI-generated view continuity",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/brytoncooper/cooper-continuum.git",
|
|
12
|
+
"directory": "packages/runtime"
|
|
13
|
+
},
|
|
14
|
+
"author": "CooperContinuum",
|
|
15
|
+
"keywords": [
|
|
16
|
+
"continuum",
|
|
17
|
+
"ai",
|
|
18
|
+
"ui",
|
|
19
|
+
"continuity",
|
|
20
|
+
"reconciliation",
|
|
21
|
+
"engine"
|
|
22
|
+
],
|
|
23
|
+
"type": "module",
|
|
24
|
+
"sideEffects": false,
|
|
25
|
+
"main": "./index.js",
|
|
26
|
+
"types": "./index.d.ts",
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./index.d.ts",
|
|
30
|
+
"import": "./index.js",
|
|
31
|
+
"default": "./index.js"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"files": [
|
|
35
|
+
"**/*.js",
|
|
36
|
+
"**/*.d.ts",
|
|
37
|
+
"**/*.d.ts.map",
|
|
38
|
+
"README.md",
|
|
39
|
+
"LICENSE*"
|
|
40
|
+
],
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@continuum-dev/contract": "^0.1.0"
|
|
43
|
+
}
|
|
44
|
+
}
|