@contractspec/lib.surface-runtime 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/README.md +164 -0
- package/dist/adapters/ai-sdk-stub.d.ts +5 -0
- package/dist/adapters/ai-sdk-stub.js +13 -0
- package/dist/adapters/blocknote-stub.d.ts +6 -0
- package/dist/adapters/blocknote-stub.js +31 -0
- package/dist/adapters/dnd-kit-adapter.d.ts +13 -0
- package/dist/adapters/dnd-kit-adapter.js +44 -0
- package/dist/adapters/dnd-kit-stub.d.ts +6 -0
- package/dist/adapters/dnd-kit-stub.js +8 -0
- package/dist/adapters/floating-ui-stub.d.ts +6 -0
- package/dist/adapters/floating-ui-stub.js +19 -0
- package/dist/adapters/index.d.ts +11 -0
- package/dist/adapters/index.js +176 -0
- package/dist/adapters/interfaces.d.ts +75 -0
- package/dist/adapters/interfaces.js +1 -0
- package/dist/adapters/motion-stub.d.ts +7 -0
- package/dist/adapters/motion-stub.js +27 -0
- package/dist/adapters/motion-stub.test.d.ts +1 -0
- package/dist/adapters/resizable-panels-stub.d.ts +6 -0
- package/dist/adapters/resizable-panels-stub.js +46 -0
- package/dist/adapters/resizable-panels-stub.test.d.ts +1 -0
- package/dist/browser/adapters/ai-sdk-stub.js +12 -0
- package/dist/browser/adapters/blocknote-stub.js +30 -0
- package/dist/browser/adapters/dnd-kit-adapter.js +43 -0
- package/dist/browser/adapters/dnd-kit-stub.js +7 -0
- package/dist/browser/adapters/floating-ui-stub.js +18 -0
- package/dist/browser/adapters/index.js +175 -0
- package/dist/browser/adapters/interfaces.js +0 -0
- package/dist/browser/adapters/motion-stub.js +26 -0
- package/dist/browser/adapters/resizable-panels-stub.js +45 -0
- package/dist/browser/evals/golden-context.js +0 -0
- package/dist/browser/evals/golden-harness.js +848 -0
- package/dist/browser/examples/pm-workbench.bundle.js +476 -0
- package/dist/browser/i18n/catalogs/en.js +71 -0
- package/dist/browser/i18n/catalogs/es.js +32 -0
- package/dist/browser/i18n/catalogs/fr.js +32 -0
- package/dist/browser/i18n/catalogs/index.js +133 -0
- package/dist/browser/i18n/index.js +173 -0
- package/dist/browser/i18n/keys.js +19 -0
- package/dist/browser/i18n/messages.js +143 -0
- package/dist/browser/index.js +2466 -0
- package/dist/browser/react/BundleProvider.js +47 -0
- package/dist/browser/react/BundleRenderer.js +726 -0
- package/dist/browser/react/OverlayConflictResolver.js +255 -0
- package/dist/browser/react/PatchProposalCard.js +255 -0
- package/dist/browser/react/RegionRenderer.js +128 -0
- package/dist/browser/react/SlotRenderer.js +118 -0
- package/dist/browser/react/WidgetPalette.js +59 -0
- package/dist/browser/react/index.js +792 -0
- package/dist/browser/runtime/apply-surface-patch.js +322 -0
- package/dist/browser/runtime/audit-events.js +137 -0
- package/dist/browser/runtime/build-context.js +55 -0
- package/dist/browser/runtime/extension-registry.js +58 -0
- package/dist/browser/runtime/field-renderer-registry.js +145 -0
- package/dist/browser/runtime/index.js +1496 -0
- package/dist/browser/runtime/overlay-alignment.js +83 -0
- package/dist/browser/runtime/overlay-signer.js +15 -0
- package/dist/browser/runtime/override-store.js +52 -0
- package/dist/browser/runtime/planner-prompt.js +67 -0
- package/dist/browser/runtime/planner-tools.js +77 -0
- package/dist/browser/runtime/policy-eval.js +155 -0
- package/dist/browser/runtime/preference-adapter.js +67 -0
- package/dist/browser/runtime/resolve-bundle.js +767 -0
- package/dist/browser/runtime/resolve-preferences.js +59 -0
- package/dist/browser/runtime/rollback.js +347 -0
- package/dist/browser/runtime/widget-registry.js +36 -0
- package/dist/browser/spec/define-module-bundle.js +113 -0
- package/dist/browser/spec/index.js +319 -0
- package/dist/browser/spec/types.js +0 -0
- package/dist/browser/spec/validate-bundle.js +65 -0
- package/dist/browser/spec/validate-surface-patch.js +206 -0
- package/dist/browser/spec/verification-snapshot-types.js +0 -0
- package/dist/browser/telemetry/index.js +20 -0
- package/dist/browser/telemetry/surface-metrics.js +20 -0
- package/dist/evals/golden-context.d.ts +24 -0
- package/dist/evals/golden-context.js +1 -0
- package/dist/evals/golden-harness.d.ts +29 -0
- package/dist/evals/golden-harness.js +849 -0
- package/dist/evals/golden-harness.test.d.ts +1 -0
- package/dist/examples/pm-workbench.bundle.d.ts +177 -0
- package/dist/examples/pm-workbench.bundle.js +477 -0
- package/dist/i18n/catalogs/en.d.ts +1 -0
- package/dist/i18n/catalogs/en.js +72 -0
- package/dist/i18n/catalogs/es.d.ts +1 -0
- package/dist/i18n/catalogs/es.js +33 -0
- package/dist/i18n/catalogs/fr.d.ts +1 -0
- package/dist/i18n/catalogs/fr.js +33 -0
- package/dist/i18n/catalogs/index.d.ts +3 -0
- package/dist/i18n/catalogs/index.js +134 -0
- package/dist/i18n/index.d.ts +5 -0
- package/dist/i18n/index.js +174 -0
- package/dist/i18n/keys.d.ts +20 -0
- package/dist/i18n/keys.js +20 -0
- package/dist/i18n/messages.d.ts +5 -0
- package/dist/i18n/messages.js +144 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +2467 -0
- package/dist/node/adapters/ai-sdk-stub.js +12 -0
- package/dist/node/adapters/blocknote-stub.js +30 -0
- package/dist/node/adapters/dnd-kit-adapter.js +43 -0
- package/dist/node/adapters/dnd-kit-stub.js +7 -0
- package/dist/node/adapters/floating-ui-stub.js +18 -0
- package/dist/node/adapters/index.js +175 -0
- package/dist/node/adapters/interfaces.js +0 -0
- package/dist/node/adapters/motion-stub.js +26 -0
- package/dist/node/adapters/resizable-panels-stub.js +45 -0
- package/dist/node/evals/golden-context.js +0 -0
- package/dist/node/evals/golden-harness.js +848 -0
- package/dist/node/examples/pm-workbench.bundle.js +476 -0
- package/dist/node/i18n/catalogs/en.js +71 -0
- package/dist/node/i18n/catalogs/es.js +32 -0
- package/dist/node/i18n/catalogs/fr.js +32 -0
- package/dist/node/i18n/catalogs/index.js +133 -0
- package/dist/node/i18n/index.js +173 -0
- package/dist/node/i18n/keys.js +19 -0
- package/dist/node/i18n/messages.js +143 -0
- package/dist/node/index.js +2466 -0
- package/dist/node/react/BundleProvider.js +47 -0
- package/dist/node/react/BundleRenderer.js +726 -0
- package/dist/node/react/OverlayConflictResolver.js +255 -0
- package/dist/node/react/PatchProposalCard.js +255 -0
- package/dist/node/react/RegionRenderer.js +128 -0
- package/dist/node/react/SlotRenderer.js +118 -0
- package/dist/node/react/WidgetPalette.js +59 -0
- package/dist/node/react/index.js +792 -0
- package/dist/node/runtime/apply-surface-patch.js +322 -0
- package/dist/node/runtime/audit-events.js +137 -0
- package/dist/node/runtime/build-context.js +55 -0
- package/dist/node/runtime/extension-registry.js +58 -0
- package/dist/node/runtime/field-renderer-registry.js +145 -0
- package/dist/node/runtime/index.js +1496 -0
- package/dist/node/runtime/overlay-alignment.js +83 -0
- package/dist/node/runtime/overlay-signer.js +15 -0
- package/dist/node/runtime/override-store.js +52 -0
- package/dist/node/runtime/planner-prompt.js +67 -0
- package/dist/node/runtime/planner-tools.js +77 -0
- package/dist/node/runtime/policy-eval.js +155 -0
- package/dist/node/runtime/preference-adapter.js +67 -0
- package/dist/node/runtime/resolve-bundle.js +767 -0
- package/dist/node/runtime/resolve-preferences.js +59 -0
- package/dist/node/runtime/rollback.js +347 -0
- package/dist/node/runtime/widget-registry.js +36 -0
- package/dist/node/spec/define-module-bundle.js +113 -0
- package/dist/node/spec/index.js +319 -0
- package/dist/node/spec/types.js +0 -0
- package/dist/node/spec/validate-bundle.js +65 -0
- package/dist/node/spec/validate-surface-patch.js +206 -0
- package/dist/node/spec/verification-snapshot-types.js +0 -0
- package/dist/node/telemetry/index.js +20 -0
- package/dist/node/telemetry/surface-metrics.js +20 -0
- package/dist/react/BundleProvider.d.ts +13 -0
- package/dist/react/BundleProvider.js +48 -0
- package/dist/react/BundleRenderer.d.ts +22 -0
- package/dist/react/BundleRenderer.js +727 -0
- package/dist/react/OverlayConflictResolver.d.ts +15 -0
- package/dist/react/OverlayConflictResolver.js +256 -0
- package/dist/react/PatchProposalCard.d.ts +13 -0
- package/dist/react/PatchProposalCard.js +256 -0
- package/dist/react/RegionRenderer.d.ts +13 -0
- package/dist/react/RegionRenderer.js +129 -0
- package/dist/react/SlotRenderer.d.ts +13 -0
- package/dist/react/SlotRenderer.js +119 -0
- package/dist/react/WidgetPalette.d.ts +12 -0
- package/dist/react/WidgetPalette.js +60 -0
- package/dist/react/index.d.ts +7 -0
- package/dist/react/index.js +793 -0
- package/dist/runtime/apply-surface-patch.d.ts +15 -0
- package/dist/runtime/apply-surface-patch.js +323 -0
- package/dist/runtime/apply-surface-patch.test.d.ts +1 -0
- package/dist/runtime/audit-events.d.ts +70 -0
- package/dist/runtime/audit-events.js +138 -0
- package/dist/runtime/audit-events.test.d.ts +1 -0
- package/dist/runtime/build-context.d.ts +9 -0
- package/dist/runtime/build-context.js +56 -0
- package/dist/runtime/extension-registry.d.ts +39 -0
- package/dist/runtime/extension-registry.js +59 -0
- package/dist/runtime/field-renderer-registry.d.ts +23 -0
- package/dist/runtime/field-renderer-registry.js +146 -0
- package/dist/runtime/field-renderer-registry.test.d.ts +1 -0
- package/dist/runtime/index.d.ts +16 -0
- package/dist/runtime/index.js +1497 -0
- package/dist/runtime/overlay-alignment.d.ts +49 -0
- package/dist/runtime/overlay-alignment.js +84 -0
- package/dist/runtime/overlay-alignment.test.d.ts +1 -0
- package/dist/runtime/overlay-signer.d.ts +15 -0
- package/dist/runtime/overlay-signer.js +16 -0
- package/dist/runtime/override-store.d.ts +44 -0
- package/dist/runtime/override-store.js +53 -0
- package/dist/runtime/override-store.test.d.ts +1 -0
- package/dist/runtime/planner-prompt.d.ts +39 -0
- package/dist/runtime/planner-prompt.js +68 -0
- package/dist/runtime/planner-prompt.test.d.ts +1 -0
- package/dist/runtime/planner-tools.d.ts +106 -0
- package/dist/runtime/planner-tools.js +78 -0
- package/dist/runtime/planner-tools.test.d.ts +1 -0
- package/dist/runtime/policy-eval.d.ts +23 -0
- package/dist/runtime/policy-eval.js +156 -0
- package/dist/runtime/preference-adapter.d.ts +6 -0
- package/dist/runtime/preference-adapter.js +68 -0
- package/dist/runtime/resolve-bundle.d.ts +68 -0
- package/dist/runtime/resolve-bundle.js +768 -0
- package/dist/runtime/resolve-bundle.test.d.ts +1 -0
- package/dist/runtime/resolve-preferences.d.ts +9 -0
- package/dist/runtime/resolve-preferences.js +60 -0
- package/dist/runtime/resolve-preferences.test.d.ts +1 -0
- package/dist/runtime/rollback.d.ts +21 -0
- package/dist/runtime/rollback.js +348 -0
- package/dist/runtime/rollback.test.d.ts +1 -0
- package/dist/runtime/widget-registry.d.ts +26 -0
- package/dist/runtime/widget-registry.js +37 -0
- package/dist/runtime/widget-registry.test.d.ts +1 -0
- package/dist/spec/define-module-bundle.d.ts +17 -0
- package/dist/spec/define-module-bundle.js +114 -0
- package/dist/spec/define-module-bundle.test.d.ts +1 -0
- package/dist/spec/index.d.ts +5 -0
- package/dist/spec/index.js +320 -0
- package/dist/spec/types.d.ts +494 -0
- package/dist/spec/types.js +1 -0
- package/dist/spec/validate-bundle.d.ts +23 -0
- package/dist/spec/validate-bundle.js +66 -0
- package/dist/spec/validate-bundle.test.d.ts +1 -0
- package/dist/spec/validate-surface-patch.d.ts +39 -0
- package/dist/spec/validate-surface-patch.js +207 -0
- package/dist/spec/validate-surface-patch.test.d.ts +1 -0
- package/dist/spec/verification-snapshot-types.d.ts +23 -0
- package/dist/spec/verification-snapshot-types.js +1 -0
- package/dist/spec/verification-snapshot.test.d.ts +5 -0
- package/dist/telemetry/index.d.ts +5 -0
- package/dist/telemetry/index.js +21 -0
- package/dist/telemetry/surface-metrics.d.ts +17 -0
- package/dist/telemetry/surface-metrics.js +21 -0
- package/package.json +920 -0
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/spec/validate-surface-patch.ts
|
|
3
|
+
var VALID_OPS = [
|
|
4
|
+
"insert-node",
|
|
5
|
+
"replace-node",
|
|
6
|
+
"remove-node",
|
|
7
|
+
"move-node",
|
|
8
|
+
"resize-panel",
|
|
9
|
+
"set-layout",
|
|
10
|
+
"reveal-field",
|
|
11
|
+
"hide-field",
|
|
12
|
+
"promote-action",
|
|
13
|
+
"set-focus"
|
|
14
|
+
];
|
|
15
|
+
var VALID_NODE_KINDS = [
|
|
16
|
+
"metric-strip",
|
|
17
|
+
"data-view",
|
|
18
|
+
"entity-card",
|
|
19
|
+
"entity-header",
|
|
20
|
+
"entity-summary",
|
|
21
|
+
"entity-section",
|
|
22
|
+
"entity-field",
|
|
23
|
+
"entity-activity",
|
|
24
|
+
"entity-relations",
|
|
25
|
+
"entity-timeline",
|
|
26
|
+
"entity-comments",
|
|
27
|
+
"entity-attachments",
|
|
28
|
+
"entity-view-switcher",
|
|
29
|
+
"entity-automation-panel",
|
|
30
|
+
"rich-doc",
|
|
31
|
+
"chat-thread",
|
|
32
|
+
"assistant-panel",
|
|
33
|
+
"action-bar",
|
|
34
|
+
"timeline",
|
|
35
|
+
"board",
|
|
36
|
+
"table",
|
|
37
|
+
"calendar",
|
|
38
|
+
"form",
|
|
39
|
+
"chart",
|
|
40
|
+
"relation-graph",
|
|
41
|
+
"custom-widget"
|
|
42
|
+
];
|
|
43
|
+
function validateSurfaceNode(node, path) {
|
|
44
|
+
if (!node.nodeId || typeof node.nodeId !== "string") {
|
|
45
|
+
throw new Error(`${path}: nodeId must be a non-empty string`);
|
|
46
|
+
}
|
|
47
|
+
if (!node.kind || !VALID_NODE_KINDS.includes(node.kind)) {
|
|
48
|
+
throw new Error(`${path}: kind must be one of ${VALID_NODE_KINDS.join(", ")}`);
|
|
49
|
+
}
|
|
50
|
+
if (node.children) {
|
|
51
|
+
for (let i = 0;i < node.children.length; i++) {
|
|
52
|
+
const child = node.children[i];
|
|
53
|
+
if (child)
|
|
54
|
+
validateSurfaceNode(child, `${path}.children[${i}]`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function validateSurfacePatchOp(op, index) {
|
|
59
|
+
const path = `ops[${index}]`;
|
|
60
|
+
if (!op || typeof op !== "object" || !("op" in op)) {
|
|
61
|
+
throw new Error(`${path}: must be an object with op field`);
|
|
62
|
+
}
|
|
63
|
+
const opType = op.op;
|
|
64
|
+
if (!VALID_OPS.includes(opType)) {
|
|
65
|
+
throw new Error(`${path}: op must be one of ${VALID_OPS.join(", ")}`);
|
|
66
|
+
}
|
|
67
|
+
switch (op.op) {
|
|
68
|
+
case "insert-node":
|
|
69
|
+
if (!op.slotId || typeof op.slotId !== "string") {
|
|
70
|
+
throw new Error(`${path}: insert-node requires slotId string`);
|
|
71
|
+
}
|
|
72
|
+
if (!op.node) {
|
|
73
|
+
throw new Error(`${path}: insert-node requires node`);
|
|
74
|
+
}
|
|
75
|
+
validateSurfaceNode(op.node, `${path}.node`);
|
|
76
|
+
if (op.index !== undefined && typeof op.index !== "number") {
|
|
77
|
+
throw new Error(`${path}: insert-node index must be number if present`);
|
|
78
|
+
}
|
|
79
|
+
break;
|
|
80
|
+
case "replace-node":
|
|
81
|
+
if (!op.nodeId || typeof op.nodeId !== "string") {
|
|
82
|
+
throw new Error(`${path}: replace-node requires nodeId string`);
|
|
83
|
+
}
|
|
84
|
+
if (!op.node) {
|
|
85
|
+
throw new Error(`${path}: replace-node requires node`);
|
|
86
|
+
}
|
|
87
|
+
validateSurfaceNode(op.node, `${path}.node`);
|
|
88
|
+
break;
|
|
89
|
+
case "remove-node":
|
|
90
|
+
if (!op.nodeId || typeof op.nodeId !== "string") {
|
|
91
|
+
throw new Error(`${path}: remove-node requires nodeId string`);
|
|
92
|
+
}
|
|
93
|
+
break;
|
|
94
|
+
case "move-node":
|
|
95
|
+
if (!op.nodeId || typeof op.nodeId !== "string") {
|
|
96
|
+
throw new Error(`${path}: move-node requires nodeId string`);
|
|
97
|
+
}
|
|
98
|
+
if (!op.toSlotId || typeof op.toSlotId !== "string") {
|
|
99
|
+
throw new Error(`${path}: move-node requires toSlotId string`);
|
|
100
|
+
}
|
|
101
|
+
if (op.index !== undefined && typeof op.index !== "number") {
|
|
102
|
+
throw new Error(`${path}: move-node index must be number if present`);
|
|
103
|
+
}
|
|
104
|
+
break;
|
|
105
|
+
case "resize-panel":
|
|
106
|
+
if (!op.persistKey || typeof op.persistKey !== "string") {
|
|
107
|
+
throw new Error(`${path}: resize-panel requires persistKey string`);
|
|
108
|
+
}
|
|
109
|
+
if (!Array.isArray(op.sizes) || op.sizes.some((s) => typeof s !== "number")) {
|
|
110
|
+
throw new Error(`${path}: resize-panel requires sizes number[]`);
|
|
111
|
+
}
|
|
112
|
+
break;
|
|
113
|
+
case "set-layout":
|
|
114
|
+
if (!op.layoutId || typeof op.layoutId !== "string") {
|
|
115
|
+
throw new Error(`${path}: set-layout requires layoutId string`);
|
|
116
|
+
}
|
|
117
|
+
break;
|
|
118
|
+
case "reveal-field":
|
|
119
|
+
case "hide-field":
|
|
120
|
+
if (!op.fieldId || typeof op.fieldId !== "string") {
|
|
121
|
+
throw new Error(`${path}: ${op.op} requires fieldId string`);
|
|
122
|
+
}
|
|
123
|
+
break;
|
|
124
|
+
case "promote-action": {
|
|
125
|
+
if (!op.actionId || typeof op.actionId !== "string") {
|
|
126
|
+
throw new Error(`${path}: promote-action requires actionId string`);
|
|
127
|
+
}
|
|
128
|
+
const validPlacements = ["header", "inline", "context", "assistant"];
|
|
129
|
+
if (!op.placement || !validPlacements.includes(op.placement)) {
|
|
130
|
+
throw new Error(`${path}: promote-action placement must be one of ${validPlacements.join(", ")}`);
|
|
131
|
+
}
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
case "set-focus":
|
|
135
|
+
if (!op.targetId || typeof op.targetId !== "string") {
|
|
136
|
+
throw new Error(`${path}: set-focus requires targetId string`);
|
|
137
|
+
}
|
|
138
|
+
break;
|
|
139
|
+
default:
|
|
140
|
+
throw new Error(`${path}: unknown op "${opType}"`);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
function validateSurfacePatch(ops) {
|
|
144
|
+
if (!Array.isArray(ops)) {
|
|
145
|
+
throw new Error("Patch ops must be an array");
|
|
146
|
+
}
|
|
147
|
+
for (let i = 0;i < ops.length; i++) {
|
|
148
|
+
const op = ops[i];
|
|
149
|
+
if (op)
|
|
150
|
+
validateSurfacePatchOp(op, i);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
function validateSurfaceNodeAgainstKinds(node, allowedKinds, path) {
|
|
154
|
+
if (!allowedKinds.includes(node.kind)) {
|
|
155
|
+
throw new Error(`${path}: kind "${node.kind}" not in allowed list [${allowedKinds.join(", ")}]`);
|
|
156
|
+
}
|
|
157
|
+
if (node.children) {
|
|
158
|
+
for (let i = 0;i < node.children.length; i++) {
|
|
159
|
+
const child = node.children[i];
|
|
160
|
+
if (child)
|
|
161
|
+
validateSurfaceNodeAgainstKinds(child, allowedKinds, `${path}.children[${i}]`);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
function validatePatchProposal(ops, constraints) {
|
|
166
|
+
if (!Array.isArray(ops)) {
|
|
167
|
+
throw new Error("Patch ops must be an array");
|
|
168
|
+
}
|
|
169
|
+
const { allowedOps, allowedSlots, allowedNodeKinds } = constraints;
|
|
170
|
+
for (let i = 0;i < ops.length; i++) {
|
|
171
|
+
const op = ops[i];
|
|
172
|
+
if (!op)
|
|
173
|
+
continue;
|
|
174
|
+
const path = `ops[${i}]`;
|
|
175
|
+
if (!allowedOps.includes(op.op)) {
|
|
176
|
+
throw new Error(`${path}: op "${op.op}" not in allowed list [${allowedOps.join(", ")}]`);
|
|
177
|
+
}
|
|
178
|
+
switch (op.op) {
|
|
179
|
+
case "insert-node":
|
|
180
|
+
if (!allowedSlots.includes(op.slotId)) {
|
|
181
|
+
throw new Error(`${path}: slotId "${op.slotId}" not in allowed slots [${allowedSlots.join(", ")}]`);
|
|
182
|
+
}
|
|
183
|
+
if (op.node) {
|
|
184
|
+
validateSurfaceNodeAgainstKinds(op.node, allowedNodeKinds, `${path}.node`);
|
|
185
|
+
}
|
|
186
|
+
break;
|
|
187
|
+
case "move-node":
|
|
188
|
+
if (!allowedSlots.includes(op.toSlotId)) {
|
|
189
|
+
throw new Error(`${path}: toSlotId "${op.toSlotId}" not in allowed slots [${allowedSlots.join(", ")}]`);
|
|
190
|
+
}
|
|
191
|
+
break;
|
|
192
|
+
case "replace-node":
|
|
193
|
+
if (op.node) {
|
|
194
|
+
validateSurfaceNodeAgainstKinds(op.node, allowedNodeKinds, `${path}.node`);
|
|
195
|
+
}
|
|
196
|
+
break;
|
|
197
|
+
default:
|
|
198
|
+
break;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
validateSurfacePatch(ops);
|
|
202
|
+
}
|
|
203
|
+
export {
|
|
204
|
+
validateSurfacePatchOp,
|
|
205
|
+
validateSurfacePatch,
|
|
206
|
+
validatePatchProposal
|
|
207
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for verification snapshots (14_verification_matrix.md).
|
|
3
|
+
* Captures surface + preference combination for regression coverage.
|
|
4
|
+
*/
|
|
5
|
+
import type { PreferenceDimensions } from './types';
|
|
6
|
+
/** Input for a verification snapshot: preferences + human-readable label. */
|
|
7
|
+
export interface VerificationSnapshotInput {
|
|
8
|
+
/** Short label for the snapshot (e.g. "density=minimal"). */
|
|
9
|
+
label: string;
|
|
10
|
+
/** Preference overrides for this snapshot. */
|
|
11
|
+
preferences: Partial<PreferenceDimensions>;
|
|
12
|
+
/** Optional description of what this combination tests. */
|
|
13
|
+
description?: string;
|
|
14
|
+
}
|
|
15
|
+
/** Minimal serializable summary of a resolved plan for snapshot comparison. */
|
|
16
|
+
export interface VerificationSnapshotSummary {
|
|
17
|
+
bundleKey: string;
|
|
18
|
+
surfaceId: string;
|
|
19
|
+
layoutId: string;
|
|
20
|
+
layoutRootType: string;
|
|
21
|
+
preferences: PreferenceDimensions;
|
|
22
|
+
slotCount: number;
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// @bun
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Surface runtime telemetry: tracing, metrics, structured logging.
|
|
3
|
+
* No PII in logs or metric attributes.
|
|
4
|
+
*/
|
|
5
|
+
export { resolutionDurationMs, patchAcceptanceCounter, patchRejectionCounter, policyDenialCounter, surfaceFallbackCounter, missingRendererCounter, } from './surface-metrics';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/telemetry/surface-metrics.ts
|
|
3
|
+
import {
|
|
4
|
+
createCounter,
|
|
5
|
+
createHistogram
|
|
6
|
+
} from "@contractspec/lib.observability/metrics";
|
|
7
|
+
var METER_NAME = "@contractspec/lib.surface-runtime";
|
|
8
|
+
var resolutionDurationMs = createHistogram("bundle_surface_resolution_duration_ms", "Time to resolve bundle spec to surface plan in milliseconds", METER_NAME);
|
|
9
|
+
var patchAcceptanceCounter = createCounter("bundle_surface_patch_acceptance_total", "Total AI patch proposals accepted by user", METER_NAME);
|
|
10
|
+
var patchRejectionCounter = createCounter("bundle_surface_patch_rejection_total", "Total AI patch proposals rejected by user", METER_NAME);
|
|
11
|
+
var policyDenialCounter = createCounter("bundle_surface_policy_denial_total", "Total policy denials (actions denied by policy)", METER_NAME);
|
|
12
|
+
var surfaceFallbackCounter = createCounter("bundle_surface_fallback_total", "Total surface or layout fallbacks during resolution", METER_NAME);
|
|
13
|
+
var missingRendererCounter = createCounter("bundle_surface_renderer_missing_total", "Total slots with no renderer for requested node kind", METER_NAME);
|
|
14
|
+
export {
|
|
15
|
+
surfaceFallbackCounter,
|
|
16
|
+
resolutionDurationMs,
|
|
17
|
+
policyDenialCounter,
|
|
18
|
+
patchRejectionCounter,
|
|
19
|
+
patchAcceptanceCounter,
|
|
20
|
+
missingRendererCounter
|
|
21
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Surface runtime metrics for resolution, patch acceptance, and policy events.
|
|
3
|
+
* Integrates with @contractspec/lib.observability.
|
|
4
|
+
* No PII in metric attributes.
|
|
5
|
+
*/
|
|
6
|
+
/** Resolution duration in milliseconds. */
|
|
7
|
+
export declare const resolutionDurationMs: import("@opentelemetry/api").Histogram<import("@opentelemetry/api").Attributes>;
|
|
8
|
+
/** Patch acceptance counter (approved). Incremented when user accepts AI patch. */
|
|
9
|
+
export declare const patchAcceptanceCounter: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
|
|
10
|
+
/** Patch rejection counter. Incremented when user rejects AI patch. */
|
|
11
|
+
export declare const patchRejectionCounter: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
|
|
12
|
+
/** Policy denial counter. Incremented when policy denies an action. */
|
|
13
|
+
export declare const policyDenialCounter: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
|
|
14
|
+
/** Surface fallback counter. Incremented when resolver uses fallback surface/layout. */
|
|
15
|
+
export declare const surfaceFallbackCounter: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
|
|
16
|
+
/** Missing renderer counter. Incremented when slot has no renderer for a node. */
|
|
17
|
+
export declare const missingRendererCounter: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/telemetry/surface-metrics.ts
|
|
3
|
+
import {
|
|
4
|
+
createCounter,
|
|
5
|
+
createHistogram
|
|
6
|
+
} from "@contractspec/lib.observability/metrics";
|
|
7
|
+
var METER_NAME = "@contractspec/lib.surface-runtime";
|
|
8
|
+
var resolutionDurationMs = createHistogram("bundle_surface_resolution_duration_ms", "Time to resolve bundle spec to surface plan in milliseconds", METER_NAME);
|
|
9
|
+
var patchAcceptanceCounter = createCounter("bundle_surface_patch_acceptance_total", "Total AI patch proposals accepted by user", METER_NAME);
|
|
10
|
+
var patchRejectionCounter = createCounter("bundle_surface_patch_rejection_total", "Total AI patch proposals rejected by user", METER_NAME);
|
|
11
|
+
var policyDenialCounter = createCounter("bundle_surface_policy_denial_total", "Total policy denials (actions denied by policy)", METER_NAME);
|
|
12
|
+
var surfaceFallbackCounter = createCounter("bundle_surface_fallback_total", "Total surface or layout fallbacks during resolution", METER_NAME);
|
|
13
|
+
var missingRendererCounter = createCounter("bundle_surface_renderer_missing_total", "Total slots with no renderer for requested node kind", METER_NAME);
|
|
14
|
+
export {
|
|
15
|
+
surfaceFallbackCounter,
|
|
16
|
+
resolutionDurationMs,
|
|
17
|
+
policyDenialCounter,
|
|
18
|
+
patchRejectionCounter,
|
|
19
|
+
patchAcceptanceCounter,
|
|
20
|
+
missingRendererCounter
|
|
21
|
+
};
|