engineering-behavior-observatory 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.
Files changed (178) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +151 -0
  3. package/contracts/codex-app-server-0.150.1/manifest.json +25 -0
  4. package/contracts/codex-app-server-0.150.1/schema/InitializeParams.json +84 -0
  5. package/contracts/codex-app-server-0.150.1/schema/JSONRPCMessage.json +137 -0
  6. package/contracts/codex-app-server-0.150.1/schema/v2/ThreadReadParams.json +17 -0
  7. package/contracts/codex-app-server-0.150.1/schema/v2/ThreadTokenUsageUpdatedNotification.json +82 -0
  8. package/contracts/codex-app-server-0.150.1/schema/v2/TurnInterruptParams.json +17 -0
  9. package/contracts/codex-app-server-0.150.1/types/AskForApproval.ts +5 -0
  10. package/contracts/codex-app-server-0.150.1/types/ClientNotification.ts +5 -0
  11. package/contracts/codex-app-server-0.150.1/types/SandboxMode.ts +5 -0
  12. package/contracts/codex-app-server-0.150.1/types/ThreadReadParams.ts +9 -0
  13. package/contracts/codex-app-server-0.150.1/types/TokenUsageBreakdown.ts +5 -0
  14. package/contracts/codex-app-server-0.150.1/types/TurnInterruptParams.ts +5 -0
  15. package/contracts/codex-app-server-0.153.4/manifest.json +27 -0
  16. package/contracts/codex-app-server-0.153.4/schema/JSONRPCMessage.json +137 -0
  17. package/contracts/codex-app-server-0.153.4/schema/v1/InitializeParams.json +84 -0
  18. package/contracts/codex-app-server-0.153.4/schema/v2/ThreadReadParams.json +17 -0
  19. package/contracts/codex-app-server-0.153.4/schema/v2/ThreadStartParams.json +515 -0
  20. package/contracts/codex-app-server-0.153.4/schema/v2/ThreadTokenUsageUpdatedNotification.json +82 -0
  21. package/contracts/codex-app-server-0.153.4/schema/v2/TurnInterruptParams.json +17 -0
  22. package/contracts/codex-app-server-0.153.4/schema/v2/TurnStartParams.json +921 -0
  23. package/contracts/codex-app-server-0.153.4/types/AskForApproval.ts +5 -0
  24. package/contracts/codex-app-server-0.153.4/types/ClientNotification.ts +5 -0
  25. package/contracts/codex-app-server-0.153.4/types/SandboxMode.ts +5 -0
  26. package/contracts/codex-app-server-0.153.4/types/ThreadReadParams.ts +12 -0
  27. package/contracts/codex-app-server-0.153.4/types/TokenUsageBreakdown.ts +5 -0
  28. package/contracts/codex-app-server-0.153.4/types/TurnInterruptParams.ts +5 -0
  29. package/contracts/openhands-agent-server-v1.44.1.json +65 -0
  30. package/contracts/openhands-agent-server-v1.46.0.json +46 -0
  31. package/dist/contracts/codex-app-server-0.153.4/types/AskForApproval.d.ts +9 -0
  32. package/dist/contracts/codex-app-server-0.153.4/types/AskForApproval.js +2 -0
  33. package/dist/contracts/codex-app-server-0.153.4/types/ClientNotification.d.ts +3 -0
  34. package/dist/contracts/codex-app-server-0.153.4/types/ClientNotification.js +2 -0
  35. package/dist/contracts/codex-app-server-0.153.4/types/SandboxMode.d.ts +1 -0
  36. package/dist/contracts/codex-app-server-0.153.4/types/SandboxMode.js +2 -0
  37. package/dist/contracts/codex-app-server-0.153.4/types/ThreadReadParams.d.ts +10 -0
  38. package/dist/contracts/codex-app-server-0.153.4/types/ThreadReadParams.js +2 -0
  39. package/dist/contracts/codex-app-server-0.153.4/types/TokenUsageBreakdown.d.ts +8 -0
  40. package/dist/contracts/codex-app-server-0.153.4/types/TokenUsageBreakdown.js +2 -0
  41. package/dist/contracts/codex-app-server-0.153.4/types/TurnInterruptParams.d.ts +4 -0
  42. package/dist/contracts/codex-app-server-0.153.4/types/TurnInterruptParams.js +2 -0
  43. package/dist/src/agent-sdk-normalizer.d.ts +22 -0
  44. package/dist/src/agent-sdk-normalizer.js +995 -0
  45. package/dist/src/agent-sdk-run.d.ts +31 -0
  46. package/dist/src/agent-sdk-run.js +242 -0
  47. package/dist/src/agent-sdk-runner.d.ts +96 -0
  48. package/dist/src/agent-sdk-runner.js +407 -0
  49. package/dist/src/agent-sdk.d.ts +294 -0
  50. package/dist/src/agent-sdk.js +644 -0
  51. package/dist/src/aggregation.d.ts +183 -0
  52. package/dist/src/aggregation.js +513 -0
  53. package/dist/src/artifacts.d.ts +36 -0
  54. package/dist/src/artifacts.js +1372 -0
  55. package/dist/src/atlas-grafana.d.ts +377 -0
  56. package/dist/src/atlas-grafana.js +47 -0
  57. package/dist/src/atlas-html.d.ts +2 -0
  58. package/dist/src/atlas-html.js +34 -0
  59. package/dist/src/atlas.d.ts +130 -0
  60. package/dist/src/atlas.js +235 -0
  61. package/dist/src/behavior-assertions.d.ts +95 -0
  62. package/dist/src/behavior-assertions.js +154 -0
  63. package/dist/src/cli.d.ts +5 -0
  64. package/dist/src/cli.js +957 -0
  65. package/dist/src/codex-judge.d.ts +44 -0
  66. package/dist/src/codex-judge.js +214 -0
  67. package/dist/src/codex-run.d.ts +114 -0
  68. package/dist/src/codex-run.js +519 -0
  69. package/dist/src/codex.d.ts +187 -0
  70. package/dist/src/codex.js +1028 -0
  71. package/dist/src/contracts.d.ts +155 -0
  72. package/dist/src/contracts.js +866 -0
  73. package/dist/src/corpus.d.ts +67 -0
  74. package/dist/src/corpus.js +540 -0
  75. package/dist/src/cursor-sdk-runner.d.ts +81 -0
  76. package/dist/src/cursor-sdk-runner.js +362 -0
  77. package/dist/src/cursor-sdk.d.ts +81 -0
  78. package/dist/src/cursor-sdk.js +1078 -0
  79. package/dist/src/deepseek-adapter.d.ts +152 -0
  80. package/dist/src/deepseek-adapter.js +777 -0
  81. package/dist/src/exports.d.ts +69 -0
  82. package/dist/src/exports.js +966 -0
  83. package/dist/src/human-calibration.d.ts +167 -0
  84. package/dist/src/human-calibration.js +618 -0
  85. package/dist/src/index.d.ts +71 -0
  86. package/dist/src/index.js +38 -0
  87. package/dist/src/lifecycle.d.ts +196 -0
  88. package/dist/src/lifecycle.js +1889 -0
  89. package/dist/src/normalization-integrity.d.ts +128 -0
  90. package/dist/src/normalization-integrity.js +429 -0
  91. package/dist/src/openhands-run.d.ts +36 -0
  92. package/dist/src/openhands-run.js +415 -0
  93. package/dist/src/openhands.d.ts +130 -0
  94. package/dist/src/openhands.js +859 -0
  95. package/dist/src/pi.d.ts +203 -0
  96. package/dist/src/pi.js +1345 -0
  97. package/dist/src/process-protocol.d.ts +245 -0
  98. package/dist/src/process-protocol.js +1261 -0
  99. package/dist/src/retained-evidence.d.ts +12 -0
  100. package/dist/src/retained-evidence.js +201 -0
  101. package/dist/src/run-bundles.d.ts +193 -0
  102. package/dist/src/run-bundles.js +993 -0
  103. package/dist/src/scheduler.d.ts +109 -0
  104. package/dist/src/scheduler.js +1080 -0
  105. package/dist/src/semantic-judge.d.ts +194 -0
  106. package/dist/src/semantic-judge.js +875 -0
  107. package/dist/src/structural-observations.d.ts +124 -0
  108. package/dist/src/structural-observations.js +671 -0
  109. package/dist/src/task-packets.d.ts +115 -0
  110. package/dist/src/task-packets.js +683 -0
  111. package/dist/src/uniform-events.d.ts +120 -0
  112. package/dist/src/uniform-events.js +158 -0
  113. package/dist/src/verifiers.d.ts +116 -0
  114. package/dist/src/verifiers.js +819 -0
  115. package/dist/src/workspaces.d.ts +56 -0
  116. package/dist/src/workspaces.js +1314 -0
  117. package/docs/README.md +60 -0
  118. package/docs/development/README.md +71 -0
  119. package/docs/development/documentation-sync.md +58 -0
  120. package/docs/development/extension-contracts.md +307 -0
  121. package/docs/evaluation/README.md +48 -0
  122. package/docs/evaluation/aggregation.md +112 -0
  123. package/docs/evaluation/behavior-assertions.md +45 -0
  124. package/docs/evaluation/human-calibration.md +170 -0
  125. package/docs/evaluation/normalization-integrity.md +80 -0
  126. package/docs/evaluation/semantic-judge.md +188 -0
  127. package/docs/evaluation/structural-observations.md +84 -0
  128. package/docs/evaluation/uniform-events.md +131 -0
  129. package/docs/guides/atlas.md +144 -0
  130. package/docs/guides/evidence-and-sharing.md +100 -0
  131. package/docs/guides/operator-guide.md +424 -0
  132. package/docs/guides/quickstart.md +152 -0
  133. package/docs/guides/telemetry.md +66 -0
  134. package/docs/harnesses/README.md +31 -0
  135. package/docs/harnesses/claude-agent-sdk.md +61 -0
  136. package/docs/harnesses/codex-harness.md +174 -0
  137. package/docs/harnesses/cursor-sdk.md +149 -0
  138. package/docs/harnesses/deepseek-harness.md +134 -0
  139. package/docs/harnesses/openhands-agent-server.md +153 -0
  140. package/docs/harnesses/pi-sdk.md +66 -0
  141. package/docs/reference/README.md +19 -0
  142. package/docs/reference/agent-sdk-operational-runner.md +118 -0
  143. package/docs/reference/cli.md +114 -0
  144. package/docs/reference/contracts.md +222 -0
  145. package/docs/reference/run-bundle-contract.md +354 -0
  146. package/docs/reference/run-lifecycle.md +54 -0
  147. package/examples/cursor-sdk/README.md +11 -0
  148. package/examples/cursor-sdk/capture-profile.json +1 -0
  149. package/examples/cursor-sdk/harness.json +1 -0
  150. package/examples/cursor-sdk/model.json +1 -0
  151. package/examples/cursor-sdk/native-limits.json +1 -0
  152. package/examples/cursor-sdk/native-tool-policy.json +1 -0
  153. package/ontology/behavior-categories.v1.json +46 -0
  154. package/package.json +66 -0
  155. package/release/0.1.0/KNOWN_LIMITATIONS.md +35 -0
  156. package/release/0.1.0/README.md +46 -0
  157. package/release/0.1.0/reproducibility.json +61 -0
  158. package/release/0.2.0/KNOWN_LIMITATIONS.md +40 -0
  159. package/release/0.2.0/README.md +42 -0
  160. package/release/0.2.0/reproducibility.json +73 -0
  161. package/release/0.2.1/KNOWN_LIMITATIONS.md +18 -0
  162. package/release/0.2.1/README.md +63 -0
  163. package/release/0.2.1/reproducibility.json +73 -0
  164. package/release/README.md +13 -0
  165. package/schemas/aggregation.v1.json +293 -0
  166. package/schemas/behavior-assertions.v1.json +220 -0
  167. package/schemas/deepseek-runtime-composition.v1.schema.json +122 -0
  168. package/schemas/experiment.v1.schema.json +188 -0
  169. package/schemas/human-calibration.v1.json +336 -0
  170. package/schemas/normalization-integrity.v1.json +302 -0
  171. package/schemas/run-bundles/v1.json +1040 -0
  172. package/schemas/run-queue.v1.schema.json +206 -0
  173. package/schemas/semantic-judge.v1.json +380 -0
  174. package/schemas/structural-observations.v1.json +131 -0
  175. package/schemas/task-packet-freeze.v1.schema.json +106 -0
  176. package/schemas/task-packet.v1.schema.json +234 -0
  177. package/schemas/uniform-events/v1.json +289 -0
  178. package/scripts/atlas-grafana.sh +18 -0
@@ -0,0 +1,120 @@
1
+ export declare const UNIFORM_EVENT_FAMILIES: readonly ["message", "model-request", "tool", "context", "permission", "delegation", "artifact", "validation", "runtime", "outcome"];
2
+ export type UniformEventFamily = typeof UNIFORM_EVENT_FAMILIES[number];
3
+ export type EvidenceUnavailable = {
4
+ status: "unknown" | "unsupported";
5
+ reason: string;
6
+ };
7
+ export type EvidenceValue<Value> = {
8
+ status: "known";
9
+ value: Value;
10
+ } | EvidenceUnavailable;
11
+ export type NativeOrderEvidence = {
12
+ status: "known";
13
+ value: number;
14
+ domain: string;
15
+ } | EvidenceUnavailable;
16
+ export type NativeEvidenceReference = {
17
+ artifactId: string;
18
+ recordLocator: string;
19
+ };
20
+ export type ContentReference = {
21
+ nativeReference: NativeEvidenceReference;
22
+ mediaType?: string;
23
+ role?: string;
24
+ };
25
+ export type UniformAttributeScalar = string | number | boolean | null;
26
+ export type UniformAttributeValue = UniformAttributeScalar | readonly UniformAttributeScalar[];
27
+ export type UniformEvent = {
28
+ schemaVersion: "ebo.uniform-event/v1";
29
+ id: string;
30
+ runId: string;
31
+ attemptId: string;
32
+ source: {
33
+ harness: string;
34
+ nativeType: string;
35
+ nativeReference: NativeEvidenceReference;
36
+ };
37
+ nativeOrder: NativeOrderEvidence;
38
+ nativeTime: EvidenceValue<string>;
39
+ actor: {
40
+ kind: "user" | "agent" | "model" | "tool" | "harness" | "operator" | "system";
41
+ id?: string;
42
+ };
43
+ family: UniformEventFamily;
44
+ phase: "before" | "during" | "after" | "instant";
45
+ scope: {
46
+ kind: "run" | "attempt" | "session" | "turn" | "operation" | "workspace" | "artifact";
47
+ id?: string;
48
+ };
49
+ relations: {
50
+ parent: EvidenceValue<string>;
51
+ known: ReadonlyArray<{
52
+ kind: "child" | "caused-by" | "correlates-with";
53
+ eventId: string;
54
+ }>;
55
+ };
56
+ attributes: Readonly<Record<string, UniformAttributeValue>>;
57
+ content: EvidenceValue<readonly ContentReference[]>;
58
+ };
59
+ export type AdapterCapability = {
60
+ status: "available" | "partial" | "unsupported";
61
+ detail?: string;
62
+ };
63
+ export type AdapterCapabilityProfile = {
64
+ schemaVersion: "ebo.adapter-capability-profile/v1";
65
+ adapterId: string;
66
+ harness: string;
67
+ nativeTypes: readonly string[];
68
+ families: Record<UniformEventFamily, AdapterCapability>;
69
+ evidence: Record<"nativeOrder" | "nativeTime" | "parentage" | "content", AdapterCapability>;
70
+ };
71
+ export type CapturedNativeRecord<NativeRecord> = {
72
+ reference: NativeEvidenceReference;
73
+ record: NativeRecord;
74
+ };
75
+ export interface NativeCaptureAdapter<Request, NativeRecord> {
76
+ readonly id: string;
77
+ readonly harness: string;
78
+ capture(request: Request): Promise<QualifiedNativeCapture<NativeRecord>>;
79
+ }
80
+ export type QualifiedNativeCapture<NativeRecord> = {
81
+ runId: string;
82
+ attemptId: string;
83
+ qualification: "qualified" | "qualified-with-gaps";
84
+ records: readonly CapturedNativeRecord<NativeRecord>[];
85
+ };
86
+ export type NormalizationInput<NativeRecord> = QualifiedNativeCapture<NativeRecord>;
87
+ export type UnmappedNativeRecord = {
88
+ reference: NativeEvidenceReference;
89
+ reason: string;
90
+ };
91
+ export type NormalizationResult = {
92
+ events: readonly UniformEvent[];
93
+ unmapped: readonly UnmappedNativeRecord[];
94
+ };
95
+ export interface UniformEventNormalizationAdapter<NativeRecord> {
96
+ readonly id: string;
97
+ readonly harness: string;
98
+ readonly capabilityProfile: AdapterCapabilityProfile;
99
+ normalize(input: NormalizationInput<NativeRecord>): Promise<NormalizationResult>;
100
+ }
101
+ export type HarnessAdapter<Request = unknown, NativeRecord = unknown> = {
102
+ capture: NativeCaptureAdapter<Request, NativeRecord>;
103
+ normalization: UniformEventNormalizationAdapter<NativeRecord>;
104
+ };
105
+ export interface NativeEvidenceResolver {
106
+ resolve(reference: NativeEvidenceReference): boolean | NativeEvidenceResolution | Promise<boolean | NativeEvidenceResolution>;
107
+ }
108
+ export type NativeEvidenceResolution = {
109
+ runId: string;
110
+ attemptId: string;
111
+ digest: `sha256:${string}`;
112
+ };
113
+ export declare class AdapterRegistry {
114
+ #private;
115
+ constructor(adapters: readonly HarnessAdapter[]);
116
+ get(harness: string): HarnessAdapter | undefined;
117
+ list(): readonly HarnessAdapter[];
118
+ }
119
+ export declare function validateUniformEvents(events: readonly UniformEvent[], resolver: NativeEvidenceResolver): Promise<void>;
120
+ export declare function assertAdapterContract<Request, NativeRecord>(adapter: HarnessAdapter<Request, NativeRecord>, request: Request, resolver: NativeEvidenceResolver): Promise<NormalizationResult>;
@@ -0,0 +1,158 @@
1
+ import { validateArtifact } from "./artifacts.js";
2
+ export const UNIFORM_EVENT_FAMILIES = [
3
+ "message",
4
+ "model-request",
5
+ "tool",
6
+ "context",
7
+ "permission",
8
+ "delegation",
9
+ "artifact",
10
+ "validation",
11
+ "runtime",
12
+ "outcome",
13
+ ];
14
+ export class AdapterRegistry {
15
+ #adapters;
16
+ constructor(adapters) {
17
+ const entries = adapters.map((adapter) => {
18
+ assertAdapterIdentity(adapter);
19
+ return [adapter.capture.harness, adapter];
20
+ });
21
+ if (new Set(entries.map(([harness]) => harness)).size !== entries.length) {
22
+ throw new Error("Adapter registry contains duplicate harnesses.");
23
+ }
24
+ this.#adapters = new Map(entries);
25
+ }
26
+ get(harness) {
27
+ return this.#adapters.get(harness);
28
+ }
29
+ list() {
30
+ return [...this.#adapters.values()];
31
+ }
32
+ }
33
+ export async function validateUniformEvents(events, resolver) {
34
+ const ids = new Set();
35
+ for (const event of events) {
36
+ assertValidArtifact(`uniform event ${event.id}`, event);
37
+ if (ids.has(event.id))
38
+ throw new Error(`Duplicate uniform event ID "${event.id}".`);
39
+ ids.add(event.id);
40
+ }
41
+ for (const event of events) {
42
+ await assertResolvable(event.source.nativeReference, resolver);
43
+ if (event.content.status === "known") {
44
+ for (const content of event.content.value)
45
+ await assertResolvable(content.nativeReference, resolver);
46
+ }
47
+ const relationTargets = [
48
+ ...(event.relations.parent.status === "known" ? [event.relations.parent.value] : []),
49
+ ...event.relations.known.map(({ eventId }) => eventId),
50
+ ];
51
+ if (relationTargets.some((eventId) => !ids.has(eventId))) {
52
+ throw new Error(`Uniform event "${event.id}" has an unresolved event relation.`);
53
+ }
54
+ }
55
+ const parentById = new Map(events.flatMap((event) => event.relations.parent.status === "known"
56
+ ? [[event.id, event.relations.parent.value]]
57
+ : []));
58
+ const resolved = new Set();
59
+ for (const event of events) {
60
+ if (resolved.has(event.id))
61
+ continue;
62
+ const ancestry = new Set();
63
+ const path = [];
64
+ let current = event.id;
65
+ while (current !== undefined && !resolved.has(current)) {
66
+ if (ancestry.has(current))
67
+ throw new Error(`Uniform event "${event.id}" has cyclic parentage.`);
68
+ ancestry.add(current);
69
+ path.push(current);
70
+ current = parentById.get(current);
71
+ }
72
+ for (const eventId of path)
73
+ resolved.add(eventId);
74
+ }
75
+ }
76
+ export async function assertAdapterContract(adapter, request, resolver) {
77
+ assertAdapterIdentity(adapter);
78
+ assertValidArtifact(`adapter capability profile ${adapter.normalization.id}`, adapter.normalization.capabilityProfile);
79
+ const capture = await adapter.capture.capture(request);
80
+ if (!["qualified", "qualified-with-gaps"].includes(capture.qualification)) {
81
+ throw new Error("Uniform event normalization requires capture-qualified evidence.");
82
+ }
83
+ const result = await adapter.normalization.normalize(capture);
84
+ await validateUniformEvents(result.events, resolver);
85
+ for (const { reference } of capture.records)
86
+ await assertResolvable(reference, resolver);
87
+ for (const event of result.events) {
88
+ if (event.runId !== capture.runId || event.attemptId !== capture.attemptId) {
89
+ throw new Error("Normalized event identity does not match the qualified attempt.");
90
+ }
91
+ if (event.source.harness !== adapter.normalization.harness) {
92
+ throw new Error("Normalized event source does not match its adapter harness.");
93
+ }
94
+ if (!adapter.normalization.capabilityProfile.nativeTypes.includes(event.source.nativeType)) {
95
+ throw new Error(`Adapter emitted undeclared native type "${event.source.nativeType}".`);
96
+ }
97
+ if (adapter.normalization.capabilityProfile.families[event.family].status === "unsupported") {
98
+ throw new Error(`Adapter mapped unsupported event family "${event.family}".`);
99
+ }
100
+ const capabilities = adapter.normalization.capabilityProfile.evidence;
101
+ assertEvidenceCapability(capabilities.nativeOrder, event.nativeOrder.status, "nativeOrder");
102
+ assertEvidenceCapability(capabilities.nativeTime, event.nativeTime.status, "nativeTime");
103
+ assertEvidenceCapability(capabilities.content, event.content.status, "content");
104
+ assertEvidenceCapability(capabilities.parentage, event.relations.parent.status, "parentage");
105
+ if (capabilities.parentage.status === "unsupported" && event.relations.known.length > 0) {
106
+ throw new Error("Adapter evidence capability contradicts event parentage.");
107
+ }
108
+ }
109
+ const capturedKeys = capture.records.map(({ reference }) => referenceKey(reference));
110
+ if (new Set(capturedKeys).size !== capturedKeys.length) {
111
+ throw new Error("Capture adapter returned duplicate native references.");
112
+ }
113
+ const captured = new Set(capturedKeys);
114
+ const mapped = new Set(result.events.map(({ source }) => referenceKey(source.nativeReference)));
115
+ const unmapped = result.unmapped.map(({ reference }) => referenceKey(reference));
116
+ if (new Set(unmapped).size !== unmapped.length)
117
+ throw new Error("Normalizer returned a native record as unmapped more than once.");
118
+ const unmappedSet = new Set(unmapped);
119
+ for (const reference of new Set([...mapped, ...unmappedSet])) {
120
+ if (!captured.has(reference))
121
+ throw new Error("Normalizer returned a native reference that was not captured.");
122
+ }
123
+ for (const reference of captured) {
124
+ if (mapped.has(reference) === unmappedSet.has(reference)) {
125
+ throw new Error("Every captured native record must be mapped or explicitly retained as unmapped.");
126
+ }
127
+ }
128
+ return result;
129
+ }
130
+ function assertAdapterIdentity(adapter) {
131
+ if (adapter.capture.id !== adapter.normalization.id || adapter.capture.harness !== adapter.normalization.harness) {
132
+ throw new Error("Capture and normalization adapters must have matching identities.");
133
+ }
134
+ const profile = adapter.normalization.capabilityProfile;
135
+ if (profile.adapterId !== adapter.normalization.id || profile.harness !== adapter.normalization.harness) {
136
+ throw new Error("Adapter capability profile does not match its adapter identity.");
137
+ }
138
+ }
139
+ function assertEvidenceCapability(capability, evidenceStatus, field) {
140
+ if ((capability.status === "unsupported") !== (evidenceStatus === "unsupported")
141
+ && capability.status !== "partial") {
142
+ throw new Error(`Adapter evidence capability contradicts event ${field}.`);
143
+ }
144
+ }
145
+ function assertValidArtifact(artifact, document) {
146
+ const errors = validateArtifact(artifact, document);
147
+ if (errors.length > 0) {
148
+ throw new Error(errors.map(({ field, message }) => `${artifact} ${field}: ${message}`).join("\n"));
149
+ }
150
+ }
151
+ async function assertResolvable(reference, resolver) {
152
+ if (!await resolver.resolve(reference)) {
153
+ throw new Error(`Native evidence reference ${reference.artifactId}:${reference.recordLocator} is unresolved.`);
154
+ }
155
+ }
156
+ function referenceKey(reference) {
157
+ return JSON.stringify([reference.artifactId, reference.recordLocator]);
158
+ }
@@ -0,0 +1,116 @@
1
+ import { type ArtifactReference } from "./contracts.js";
2
+ export type VerifierAssertionStatus = "passed" | "failed" | "not-run";
3
+ export type VerifierAssertion = {
4
+ id: string;
5
+ status: VerifierAssertionStatus;
6
+ };
7
+ export type VerifierPassedAssertion = Omit<VerifierAssertion, "status"> & {
8
+ status: "passed";
9
+ };
10
+ export type VerifierNotRunAssertion = Omit<VerifierAssertion, "status"> & {
11
+ status: "not-run";
12
+ };
13
+ export type VerifierWorkspace = {
14
+ artifactId: string;
15
+ digest: string;
16
+ fingerprint?: string;
17
+ };
18
+ export type DiagnosticOrigin = {
19
+ stream: "stdout" | "stderr";
20
+ locator: string;
21
+ digest: string;
22
+ sizeBytes: number;
23
+ truncated: boolean;
24
+ };
25
+ export type DiagnosticReference = DiagnosticOrigin & {
26
+ source?: DiagnosticOrigin;
27
+ };
28
+ export type VerifierExecutionReference = {
29
+ locator: string;
30
+ digest: string;
31
+ format?: "commonjs" | "module";
32
+ };
33
+ type VerifierResultBase = {
34
+ schemaVersion: "verifier-result/v1";
35
+ bundleId: string;
36
+ durationMs?: number;
37
+ error?: string;
38
+ errorRedacted?: boolean;
39
+ verifier?: VerifierExecutionReference;
40
+ assertions: VerifierAssertion[];
41
+ diagnostics?: DiagnosticReference[];
42
+ };
43
+ export type VerifierPassedResult = Omit<VerifierResultBase, "error" | "assertions"> & {
44
+ status: "passed";
45
+ error?: never;
46
+ errorRedacted?: never;
47
+ exitCode?: 0;
48
+ workspace: VerifierWorkspace;
49
+ assertions: VerifierPassedAssertion[];
50
+ };
51
+ export type VerifierFailedResult = Omit<VerifierResultBase, "error"> & {
52
+ status: "failed";
53
+ error?: never;
54
+ errorRedacted?: never;
55
+ exitCode: number;
56
+ workspace: VerifierWorkspace;
57
+ };
58
+ export type VerifierRunResult = VerifierPassedResult | VerifierFailedResult | VerifierErrorResult;
59
+ export type VerifierErrorResult = VerifierResultBase & {
60
+ status: "error";
61
+ error: string;
62
+ exitCode?: number;
63
+ workspace?: VerifierWorkspace;
64
+ };
65
+ export type VerifierNotRunResult = Omit<VerifierResultBase, "durationMs" | "diagnostics" | "assertions" | "errorRedacted"> & {
66
+ status: "not-run";
67
+ durationMs?: never;
68
+ diagnostics?: never;
69
+ workspace?: never;
70
+ exitCode?: never;
71
+ errorRedacted?: never;
72
+ assertions: VerifierNotRunAssertion[];
73
+ };
74
+ export type VerifierResult = VerifierRunResult | VerifierNotRunResult;
75
+ type CompleteResultFields = {
76
+ durationMs: number;
77
+ diagnostics: DiagnosticReference[];
78
+ };
79
+ export type CompleteVerifierResult = (VerifierPassedResult & CompleteResultFields) | (VerifierFailedResult & CompleteResultFields) | (VerifierErrorResult & CompleteResultFields & {
80
+ workspace: VerifierWorkspace;
81
+ });
82
+ export type ExecuteVerifierOptions = {
83
+ bundleId: string;
84
+ verifierRoot: string;
85
+ verifier: ArtifactReference;
86
+ workspacePath: string;
87
+ workspaceFingerprint: string;
88
+ workspace: VerifierWorkspace & {
89
+ fingerprint: string;
90
+ };
91
+ artifactRoot: string;
92
+ command?: string;
93
+ args?: readonly string[];
94
+ moduleFormat?: "commonjs" | "module";
95
+ env?: NodeJS.ProcessEnv;
96
+ timeoutMs?: number;
97
+ maxOutputBytes?: number;
98
+ diagnosticDirectory?: string;
99
+ signal?: AbortSignal;
100
+ };
101
+ export declare function digestWorkspace(workspacePath: string, signal?: AbortSignal): Promise<string>;
102
+ export declare function digestWorkspaceTree(workspacePath: string, signal?: AbortSignal): Promise<string>;
103
+ /**
104
+ * Execute a digest-pinned verifier in a private staging directory.
105
+ *
106
+ * The verifier receives the staged implementation path followed by the
107
+ * evaluated workspace path. Its stdout is the assertion JSON protocol; stderr
108
+ * is retained as bounded diagnostic evidence.
109
+ */
110
+ export declare function executeVerifier(options: ExecuteVerifierOptions): Promise<CompleteVerifierResult>;
111
+ export declare function serializeVerifierResult(result: VerifierResult): string;
112
+ export declare function writeVerifierResult(artifactRoot: string, relativePath: string, result: VerifierResult): Promise<{
113
+ algorithm: "sha256";
114
+ value: string;
115
+ }>;
116
+ export {};