@humain/humain-code-contracts 0.3.2

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 (51) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/README.md +92 -0
  3. package/dist/index.d.ts +224 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +218 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/orchestration.d.ts +327 -0
  8. package/dist/orchestration.d.ts.map +1 -0
  9. package/dist/orchestration.js +307 -0
  10. package/dist/orchestration.js.map +1 -0
  11. package/dist/rpc.d.ts +63 -0
  12. package/dist/rpc.d.ts.map +1 -0
  13. package/dist/rpc.js +147 -0
  14. package/dist/rpc.js.map +1 -0
  15. package/dist/subagent-progress.d.ts +106 -0
  16. package/dist/subagent-progress.d.ts.map +1 -0
  17. package/dist/subagent-progress.js +440 -0
  18. package/dist/subagent-progress.js.map +1 -0
  19. package/dist/testing.d.ts +390 -0
  20. package/dist/testing.d.ts.map +1 -0
  21. package/dist/testing.js +431 -0
  22. package/dist/testing.js.map +1 -0
  23. package/dist/trace-api.d.ts +293 -0
  24. package/dist/trace-api.d.ts.map +1 -0
  25. package/dist/trace-api.js +202 -0
  26. package/dist/trace-api.js.map +1 -0
  27. package/dist/trace-artifact.d.ts +94 -0
  28. package/dist/trace-artifact.d.ts.map +1 -0
  29. package/dist/trace-artifact.js +168 -0
  30. package/dist/trace-artifact.js.map +1 -0
  31. package/dist/trace-canonical.d.ts +23 -0
  32. package/dist/trace-canonical.d.ts.map +1 -0
  33. package/dist/trace-canonical.js +240 -0
  34. package/dist/trace-canonical.js.map +1 -0
  35. package/dist/trace-export.d.ts +94 -0
  36. package/dist/trace-export.d.ts.map +1 -0
  37. package/dist/trace-export.js +374 -0
  38. package/dist/trace-export.js.map +1 -0
  39. package/dist/trace-http.d.ts +1294 -0
  40. package/dist/trace-http.d.ts.map +1 -0
  41. package/dist/trace-http.js +1481 -0
  42. package/dist/trace-http.js.map +1 -0
  43. package/dist/trace-payload.d.ts +425 -0
  44. package/dist/trace-payload.d.ts.map +1 -0
  45. package/dist/trace-payload.js +1519 -0
  46. package/dist/trace-payload.js.map +1 -0
  47. package/dist/trace.d.ts +257 -0
  48. package/dist/trace.d.ts.map +1 -0
  49. package/dist/trace.js +1014 -0
  50. package/dist/trace.js.map +1 -0
  51. package/package.json +64 -0
@@ -0,0 +1,293 @@
1
+ import { type Static, Type } from "typebox";
2
+ import { type DhAckV1, type DhArtifactV1, type DhEventV1 } from "./trace.ts";
3
+ /** Candidate HTTP DTOs only. No server routes or retention/access policy are implemented here. */
4
+ export declare const DH_HTTP_MAX_PAGE_ITEMS = 100;
5
+ export declare const DH_HTTP_MAX_CURSOR_LENGTH = 1024;
6
+ export declare const DH_BATCH_SCHEMA_PROPOSAL: "dh.batch/1-proposal";
7
+ export declare const DH_BATCH_MAX_RECORDS = 500;
8
+ export declare const DH_BATCH_MAX_UTF8_BYTES: number;
9
+ declare function generationSchema(): Type.TObject<{
10
+ readonly outcome: Type.TOptional<Type.TEnum<["succeeded", "failed", "cancelled", "unknown"]>>;
11
+ readonly startedAt: Type.TOptional<Type.TString>;
12
+ readonly finishedAt: Type.TOptional<Type.TString>;
13
+ readonly coverage: Type.TOptional<Type.TObject<{
14
+ readonly state: Type.TEnum<["captured", "redacted", "truncated", "unavailable", "not-applicable", "inferred"]>;
15
+ readonly reason: Type.TOptional<Type.TEnum<["secret_redacted", "policy_redacted", "size_limit", "producer_lost", "worker_exited_before_flush", "legacy_producer", "not_captured_by_version", "provider_hidden", "not_applicable", "derived_from_summary"]>>;
16
+ }>>;
17
+ readonly eventCount: Type.TOptional<Type.TInteger>;
18
+ readonly artifactCount: Type.TOptional<Type.TInteger>;
19
+ readonly generationId: Type.TString;
20
+ readonly rootAgentId: Type.TOptional<Type.TString>;
21
+ }>;
22
+ declare function agentSchema(): Type.TObject<{
23
+ readonly outcome: Type.TOptional<Type.TEnum<["succeeded", "failed", "cancelled", "unknown"]>>;
24
+ readonly startedAt: Type.TOptional<Type.TString>;
25
+ readonly finishedAt: Type.TOptional<Type.TString>;
26
+ readonly coverage: Type.TOptional<Type.TObject<{
27
+ readonly state: Type.TEnum<["captured", "redacted", "truncated", "unavailable", "not-applicable", "inferred"]>;
28
+ readonly reason: Type.TOptional<Type.TEnum<["secret_redacted", "policy_redacted", "size_limit", "producer_lost", "worker_exited_before_flush", "legacy_producer", "not_captured_by_version", "provider_hidden", "not_applicable", "derived_from_summary"]>>;
29
+ }>>;
30
+ readonly eventCount: Type.TOptional<Type.TInteger>;
31
+ readonly artifactCount: Type.TOptional<Type.TInteger>;
32
+ readonly generationId: Type.TString;
33
+ readonly agentId: Type.TString;
34
+ readonly parentAgentId: Type.TOptional<Type.TString>;
35
+ }>;
36
+ export type DhGenerationSummary = Static<ReturnType<typeof generationSchema>>;
37
+ export type DhAgentSummary = Static<ReturnType<typeof agentSchema>>;
38
+ export type DhGenerationPage = Static<ReturnType<typeof generationPageSchema>>;
39
+ export type DhAgentPage = Static<ReturnType<typeof agentPageSchema>>;
40
+ declare function generationPageSchema(): Type.TObject<{
41
+ readonly schema: Type.TLiteral<"dh.agent-page/2" | "dh.generation-page/2">;
42
+ readonly cursorBinding: Type.TObject<{
43
+ readonly schema: Type.TLiteral<"dh.cursor-binding/2">;
44
+ readonly environmentId: Type.TString;
45
+ readonly projectId: Type.TString;
46
+ readonly resource: Type.TEnum<["generations", "agents", "events", "manifest"]>;
47
+ readonly generationId: Type.TOptional<Type.TString>;
48
+ readonly bindingId: Type.TOptional<Type.TString>;
49
+ readonly filterSha256: Type.TString;
50
+ readonly view: Type.TUnion<[Type.TLiteral<"metadata">, Type.TLiteral<"content">]>;
51
+ readonly cutoff: Type.TObject<{
52
+ readonly schema: Type.TLiteral<"dh.snapshot-cutoff/1">;
53
+ readonly snapshotId: Type.TString;
54
+ readonly receiptOrdinal: Type.TInteger;
55
+ readonly captureCutoff: Type.TString;
56
+ }>;
57
+ readonly mappingRevision: Type.TString;
58
+ readonly authorizationRevision: Type.TString;
59
+ readonly principalId: Type.TString;
60
+ readonly grantId: Type.TString;
61
+ readonly sessionId: Type.TString;
62
+ readonly pageSize: Type.TInteger;
63
+ }>;
64
+ readonly nextCursor: Type.TUnion<[Type.TNull, Type.TString]>;
65
+ readonly captureCutoff: Type.TString;
66
+ readonly items: Type.TArray<Type.TObject<{
67
+ readonly outcome: Type.TOptional<Type.TEnum<["succeeded", "failed", "cancelled", "unknown"]>>;
68
+ readonly startedAt: Type.TOptional<Type.TString>;
69
+ readonly finishedAt: Type.TOptional<Type.TString>;
70
+ readonly coverage: Type.TOptional<Type.TObject<{
71
+ readonly state: Type.TEnum<["captured", "redacted", "truncated", "unavailable", "not-applicable", "inferred"]>;
72
+ readonly reason: Type.TOptional<Type.TEnum<["secret_redacted", "policy_redacted", "size_limit", "producer_lost", "worker_exited_before_flush", "legacy_producer", "not_captured_by_version", "provider_hidden", "not_applicable", "derived_from_summary"]>>;
73
+ }>>;
74
+ readonly eventCount: Type.TOptional<Type.TInteger>;
75
+ readonly artifactCount: Type.TOptional<Type.TInteger>;
76
+ readonly generationId: Type.TString;
77
+ readonly rootAgentId: Type.TOptional<Type.TString>;
78
+ }>>;
79
+ }>;
80
+ declare function agentPageSchema(): Type.TObject<{
81
+ readonly schema: Type.TLiteral<"dh.agent-page/2" | "dh.generation-page/2">;
82
+ readonly cursorBinding: Type.TObject<{
83
+ readonly schema: Type.TLiteral<"dh.cursor-binding/2">;
84
+ readonly environmentId: Type.TString;
85
+ readonly projectId: Type.TString;
86
+ readonly resource: Type.TEnum<["generations", "agents", "events", "manifest"]>;
87
+ readonly generationId: Type.TOptional<Type.TString>;
88
+ readonly bindingId: Type.TOptional<Type.TString>;
89
+ readonly filterSha256: Type.TString;
90
+ readonly view: Type.TUnion<[Type.TLiteral<"metadata">, Type.TLiteral<"content">]>;
91
+ readonly cutoff: Type.TObject<{
92
+ readonly schema: Type.TLiteral<"dh.snapshot-cutoff/1">;
93
+ readonly snapshotId: Type.TString;
94
+ readonly receiptOrdinal: Type.TInteger;
95
+ readonly captureCutoff: Type.TString;
96
+ }>;
97
+ readonly mappingRevision: Type.TString;
98
+ readonly authorizationRevision: Type.TString;
99
+ readonly principalId: Type.TString;
100
+ readonly grantId: Type.TString;
101
+ readonly sessionId: Type.TString;
102
+ readonly pageSize: Type.TInteger;
103
+ }>;
104
+ readonly nextCursor: Type.TUnion<[Type.TNull, Type.TString]>;
105
+ readonly captureCutoff: Type.TString;
106
+ readonly items: Type.TArray<Type.TObject<{
107
+ readonly outcome: Type.TOptional<Type.TEnum<["succeeded", "failed", "cancelled", "unknown"]>>;
108
+ readonly startedAt: Type.TOptional<Type.TString>;
109
+ readonly finishedAt: Type.TOptional<Type.TString>;
110
+ readonly coverage: Type.TOptional<Type.TObject<{
111
+ readonly state: Type.TEnum<["captured", "redacted", "truncated", "unavailable", "not-applicable", "inferred"]>;
112
+ readonly reason: Type.TOptional<Type.TEnum<["secret_redacted", "policy_redacted", "size_limit", "producer_lost", "worker_exited_before_flush", "legacy_producer", "not_captured_by_version", "provider_hidden", "not_applicable", "derived_from_summary"]>>;
113
+ }>>;
114
+ readonly eventCount: Type.TOptional<Type.TInteger>;
115
+ readonly artifactCount: Type.TOptional<Type.TInteger>;
116
+ readonly generationId: Type.TString;
117
+ readonly agentId: Type.TString;
118
+ readonly parentAgentId: Type.TOptional<Type.TString>;
119
+ }>>;
120
+ }>;
121
+ /** Transport states describe export work, not execution outcome or capture coverage. */
122
+ export declare const DH_EXPORT_STATES: readonly ["queued", "running", "ready", "failed"];
123
+ export type DhExportState = (typeof DH_EXPORT_STATES)[number];
124
+ declare function exportJobSchema(): Type.TObject<{
125
+ readonly jobId: Type.TString;
126
+ readonly state: Type.TEnum<["queued", "running", "ready", "failed"]>;
127
+ }>;
128
+ export type DhExportJob = Static<ReturnType<typeof exportJobSchema>>;
129
+ /** No URLs: a descriptor is not authorization to fetch a recorded or arbitrary URL. */
130
+ declare function exportDownloadSchema(): Type.TUnion<[Type.TObject<{
131
+ readonly schema: Type.TLiteral<"dh.export-download/2">;
132
+ readonly state: Type.TLiteral<"pending">;
133
+ }>, Type.TObject<{
134
+ readonly schema: Type.TLiteral<"dh.export-download/2">;
135
+ readonly state: Type.TLiteral<"unavailable">;
136
+ }>, Type.TObject<{
137
+ readonly schema: Type.TLiteral<"dh.export-download/2">;
138
+ readonly state: Type.TLiteral<"ready">;
139
+ readonly manifestSha256: Type.TString;
140
+ readonly headerSha256: Type.TString;
141
+ readonly sizeBytes: Type.TInteger;
142
+ readonly sha256: Type.TString;
143
+ readonly mediaType: Type.TLiteral<"application/octet-stream">;
144
+ }>]>;
145
+ export type DhExportDownload = Static<ReturnType<typeof exportDownloadSchema>>;
146
+ /** Candidate manifest: identifies included records and cutoff; never claims missing data is complete. */
147
+ declare function exportManifestSchema(): Type.TObject<{
148
+ readonly generationId: Type.TString;
149
+ readonly tenantScope: Type.TObject<{
150
+ readonly environmentId: Type.TString;
151
+ readonly projectId: Type.TString;
152
+ }>;
153
+ readonly captureCutoff: Type.TString;
154
+ readonly contentIncluded: Type.TBoolean;
155
+ readonly eventIds: Type.TArray<Type.TString>;
156
+ readonly artifactIds: Type.TArray<Type.TString>;
157
+ readonly coverage: Type.TObject<{
158
+ readonly state: Type.TEnum<["captured", "redacted", "truncated", "unavailable", "not-applicable", "inferred"]>;
159
+ readonly reason: Type.TOptional<Type.TEnum<["secret_redacted", "policy_redacted", "size_limit", "producer_lost", "worker_exited_before_flush", "legacy_producer", "not_captured_by_version", "provider_hidden", "not_applicable", "derived_from_summary"]>>;
160
+ }>;
161
+ }>;
162
+ export type DhExportManifest = Static<ReturnType<typeof exportManifestSchema>>;
163
+ export declare const parseDhGenerationPage: (value: unknown) => {
164
+ readonly schema: "dh.agent-page/2" | "dh.generation-page/2";
165
+ readonly cursorBinding: {
166
+ readonly schema: "dh.cursor-binding/2";
167
+ readonly environmentId: string;
168
+ readonly projectId: string;
169
+ readonly resource: "agents" | "events" | "generations" | "manifest";
170
+ readonly generationId?: string | undefined;
171
+ readonly bindingId?: string | undefined;
172
+ readonly filterSha256: string;
173
+ readonly view: "content" | "metadata";
174
+ readonly cutoff: {
175
+ readonly schema: "dh.snapshot-cutoff/1";
176
+ readonly snapshotId: string;
177
+ readonly receiptOrdinal: number;
178
+ readonly captureCutoff: string;
179
+ };
180
+ readonly mappingRevision: string;
181
+ readonly authorizationRevision: string;
182
+ readonly principalId: string;
183
+ readonly grantId: string;
184
+ readonly sessionId: string;
185
+ readonly pageSize: number;
186
+ };
187
+ readonly nextCursor: string | null;
188
+ readonly captureCutoff: string;
189
+ readonly items: {
190
+ readonly outcome?: "cancelled" | "failed" | "succeeded" | "unknown" | undefined;
191
+ readonly startedAt?: string | undefined;
192
+ readonly finishedAt?: string | undefined;
193
+ readonly coverage?: {
194
+ readonly state: "captured" | "inferred" | "not-applicable" | "redacted" | "truncated" | "unavailable";
195
+ readonly reason?: "derived_from_summary" | "legacy_producer" | "not_applicable" | "not_captured_by_version" | "policy_redacted" | "producer_lost" | "provider_hidden" | "secret_redacted" | "size_limit" | "worker_exited_before_flush" | undefined;
196
+ } | undefined;
197
+ readonly eventCount?: number | undefined;
198
+ readonly artifactCount?: number | undefined;
199
+ readonly generationId: string;
200
+ readonly rootAgentId?: string | undefined;
201
+ }[];
202
+ };
203
+ export declare const parseDhAgentPage: (value: unknown) => {
204
+ readonly schema: "dh.agent-page/2" | "dh.generation-page/2";
205
+ readonly cursorBinding: {
206
+ readonly schema: "dh.cursor-binding/2";
207
+ readonly environmentId: string;
208
+ readonly projectId: string;
209
+ readonly resource: "agents" | "events" | "generations" | "manifest";
210
+ readonly generationId?: string | undefined;
211
+ readonly bindingId?: string | undefined;
212
+ readonly filterSha256: string;
213
+ readonly view: "content" | "metadata";
214
+ readonly cutoff: {
215
+ readonly schema: "dh.snapshot-cutoff/1";
216
+ readonly snapshotId: string;
217
+ readonly receiptOrdinal: number;
218
+ readonly captureCutoff: string;
219
+ };
220
+ readonly mappingRevision: string;
221
+ readonly authorizationRevision: string;
222
+ readonly principalId: string;
223
+ readonly grantId: string;
224
+ readonly sessionId: string;
225
+ readonly pageSize: number;
226
+ };
227
+ readonly nextCursor: string | null;
228
+ readonly captureCutoff: string;
229
+ readonly items: {
230
+ readonly outcome?: "cancelled" | "failed" | "succeeded" | "unknown" | undefined;
231
+ readonly startedAt?: string | undefined;
232
+ readonly finishedAt?: string | undefined;
233
+ readonly coverage?: {
234
+ readonly state: "captured" | "inferred" | "not-applicable" | "redacted" | "truncated" | "unavailable";
235
+ readonly reason?: "derived_from_summary" | "legacy_producer" | "not_applicable" | "not_captured_by_version" | "policy_redacted" | "producer_lost" | "provider_hidden" | "secret_redacted" | "size_limit" | "worker_exited_before_flush" | undefined;
236
+ } | undefined;
237
+ readonly eventCount?: number | undefined;
238
+ readonly artifactCount?: number | undefined;
239
+ readonly generationId: string;
240
+ readonly agentId: string;
241
+ readonly parentAgentId?: string | undefined;
242
+ }[];
243
+ };
244
+ export declare const parseDhExportJob: (value: unknown) => {
245
+ readonly jobId: string;
246
+ readonly state: "failed" | "queued" | "ready" | "running";
247
+ };
248
+ export declare const parseDhExportDownload: (value: unknown) => {
249
+ readonly schema: "dh.export-download/2";
250
+ readonly state: "pending";
251
+ } | {
252
+ readonly schema: "dh.export-download/2";
253
+ readonly state: "unavailable";
254
+ } | {
255
+ readonly schema: "dh.export-download/2";
256
+ readonly state: "ready";
257
+ readonly manifestSha256: string;
258
+ readonly headerSha256: string;
259
+ readonly sizeBytes: number;
260
+ readonly sha256: string;
261
+ readonly mediaType: "application/octet-stream";
262
+ };
263
+ export declare const parseDhExportManifest: (value: unknown) => {
264
+ readonly generationId: string;
265
+ readonly tenantScope: {
266
+ readonly environmentId: string;
267
+ readonly projectId: string;
268
+ };
269
+ readonly captureCutoff: string;
270
+ readonly contentIncluded: boolean;
271
+ readonly eventIds: string[];
272
+ readonly artifactIds: string[];
273
+ readonly coverage: {
274
+ readonly state: "captured" | "inferred" | "not-applicable" | "redacted" | "truncated" | "unavailable";
275
+ readonly reason?: "derived_from_summary" | "legacy_producer" | "not_applicable" | "not_captured_by_version" | "policy_redacted" | "producer_lost" | "provider_hidden" | "secret_redacted" | "size_limit" | "worker_exited_before_flush" | undefined;
276
+ };
277
+ };
278
+ export interface DhIngestBatch {
279
+ schema: typeof DH_BATCH_SCHEMA_PROPOSAL;
280
+ streamId: string;
281
+ events: readonly DhEventV1[];
282
+ artifacts: readonly DhArtifactV1[];
283
+ }
284
+ /** Artifact metadata and artifact bytes are independent transfers; a batch need not be a complete bundle. */
285
+ export declare function parseDhIngestBatch(value: unknown): DhIngestBatch;
286
+ /**
287
+ * Reuses dh.ack/1. accepted.eventIds, accepted.artifactIds and rejected are independent evidence;
288
+ * ackedThroughSequence never implies artifact metadata or byte acceptance. A PUT acknowledgement
289
+ * can name bytes only in the context of that PUT; a batch acknowledgement names records only.
290
+ */
291
+ export declare function parseDhIngestAck(value: unknown): DhAckV1;
292
+ export {};
293
+ //# sourceMappingURL=trace-api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trace-api.d.ts","sourceRoot":"","sources":["../src/trace-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAgB,IAAI,EAAE,MAAM,SAAS,CAAC;AAE1D,OAAO,EAMN,KAAK,OAAO,EAGZ,KAAK,YAAY,EAEjB,KAAK,SAAS,EAOd,MAAM,YAAY,CAAC;AAIpB,kGAAkG;AAClG,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAC1C,eAAO,MAAM,yBAAyB,OAAO,CAAC;AAC9C,eAAO,MAAM,wBAAwB,EAAG,qBAA8B,CAAC;AACvE,eAAO,MAAM,oBAAoB,MAAM,CAAC;AACxC,eAAO,MAAM,uBAAuB,QAAc,CAAC;AA6BnD,iBAAS,gBAAgB;;;;;;;;;;;;GAMxB;AACD,iBAAS,WAAW;;;;;;;;;;;;;GAOnB;AAWD,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC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WgC,CAAC;AACxD,eAAO,MAAM,gBAAgB,UAZb,OAAO;;;CAYgC,CAAC;AACxD,eAAO,MAAM,qBAAqB,UAblB,OAAO;;;;;;;;;;;;;;CAa0C,CAAC;AAClE,eAAO,MAAM,qBAAqB,UAdlB,OAAO;;;;;;;;;;;;;;CAc0C,CAAC;AAElE,MAAM,WAAW,aAAa;IAC7B,MAAM,EAAE,OAAO,wBAAwB,CAAC;IACxC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,SAAS,SAAS,EAAE,CAAC;IAC7B,SAAS,EAAE,SAAS,YAAY,EAAE,CAAC;CACnC;AAUD,6GAA6G;AAC7G,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,aAAa,CAgChE;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAWxD"}
@@ -0,0 +1,202 @@
1
+ import { Type } from "typebox";
2
+ import { Compile } from "typebox/compile";
3
+ import { DH_COVERAGE_REASONS, DH_COVERAGE_STATES, DH_EVENT_MAX_UTF8_BYTES, DH_MAX_ACK_IDS, DH_OUTCOMES, DhAgentIdSchema, DhArtifactIdSchema, DhEventIdSchema, DhGenerationIdSchema, DhStreamIdSchema, DhTenantScopeSchema, parseDhAck, parseDhArtifact, parseDhEvent, } from "./trace.js";
4
+ import { assertDhPlainData, DhContractError, dhCanonicalText, parseDhRawJson } from "./trace-canonical.js";
5
+ import { assertDhReadPageBinding, dhCursorBindingSchema } from "./trace-http.js";
6
+ /** Candidate HTTP DTOs only. No server routes or retention/access policy are implemented here. */
7
+ export const DH_HTTP_MAX_PAGE_ITEMS = 100;
8
+ export const DH_HTTP_MAX_CURSOR_LENGTH = 1024;
9
+ export const DH_BATCH_SCHEMA_PROPOSAL = "dh.batch/1-proposal";
10
+ export const DH_BATCH_MAX_RECORDS = 500;
11
+ export const DH_BATCH_MAX_UTF8_BYTES = 1024 * 1024;
12
+ const strict = (properties) => Type.Object(properties, { additionalProperties: false });
13
+ const count = Type.Integer({ minimum: 0, maximum: Number.MAX_SAFE_INTEGER });
14
+ const timestamp = Type.String({
15
+ minLength: 20,
16
+ maxLength: 30,
17
+ pattern: "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d{1,9})?Z$",
18
+ });
19
+ const jobId = Type.String({ minLength: 1, maxLength: 256, pattern: "^[A-Za-z0-9_-]+$" });
20
+ const digest = Type.String({ pattern: "^[a-f0-9]{64}$" });
21
+ function metadataCoverageSchema() {
22
+ // Deliberately excludes coverage.detail: it can carry transcript content.
23
+ return strict({ state: Type.Enum(DH_COVERAGE_STATES), reason: Type.Optional(Type.Enum(DH_COVERAGE_REASONS)) });
24
+ }
25
+ function summaryProperties() {
26
+ return {
27
+ outcome: Type.Optional(Type.Enum(DH_OUTCOMES)),
28
+ startedAt: Type.Optional(timestamp),
29
+ finishedAt: Type.Optional(timestamp),
30
+ coverage: Type.Optional(metadataCoverageSchema()),
31
+ eventCount: Type.Optional(count),
32
+ artifactCount: Type.Optional(count),
33
+ };
34
+ }
35
+ function generationSchema() {
36
+ return strict({
37
+ generationId: DhGenerationIdSchema,
38
+ rootAgentId: Type.Optional(DhAgentIdSchema),
39
+ ...summaryProperties(),
40
+ });
41
+ }
42
+ function agentSchema() {
43
+ return strict({
44
+ generationId: DhGenerationIdSchema,
45
+ agentId: DhAgentIdSchema,
46
+ parentAgentId: Type.Optional(DhAgentIdSchema),
47
+ ...summaryProperties(),
48
+ });
49
+ }
50
+ function pageSchema(item, schema) {
51
+ return strict({
52
+ schema: Type.Literal(schema),
53
+ cursorBinding: dhCursorBindingSchema(),
54
+ nextCursor: Type.Union([Type.Null(), Type.String({ minLength: 1, maxLength: DH_HTTP_MAX_CURSOR_LENGTH })]),
55
+ captureCutoff: timestamp,
56
+ items: Type.Array(item, { maxItems: DH_HTTP_MAX_PAGE_ITEMS }),
57
+ });
58
+ }
59
+ function generationPageSchema() {
60
+ return pageSchema(generationSchema(), "dh.generation-page/2");
61
+ }
62
+ function agentPageSchema() {
63
+ return pageSchema(agentSchema(), "dh.agent-page/2");
64
+ }
65
+ /** Transport states describe export work, not execution outcome or capture coverage. */
66
+ export const DH_EXPORT_STATES = ["queued", "running", "ready", "failed"];
67
+ function exportJobSchema() {
68
+ return strict({ jobId, state: Type.Enum(DH_EXPORT_STATES) });
69
+ }
70
+ /** No URLs: a descriptor is not authorization to fetch a recorded or arbitrary URL. */
71
+ function exportDownloadSchema() {
72
+ return Type.Union([
73
+ strict({ schema: Type.Literal("dh.export-download/2"), state: Type.Literal("pending") }),
74
+ strict({ schema: Type.Literal("dh.export-download/2"), state: Type.Literal("unavailable") }),
75
+ strict({
76
+ schema: Type.Literal("dh.export-download/2"),
77
+ state: Type.Literal("ready"),
78
+ manifestSha256: digest,
79
+ headerSha256: digest,
80
+ sizeBytes: count,
81
+ sha256: digest,
82
+ mediaType: Type.Literal("application/octet-stream"),
83
+ }),
84
+ ]);
85
+ }
86
+ /** Candidate manifest: identifies included records and cutoff; never claims missing data is complete. */
87
+ function exportManifestSchema() {
88
+ return strict({
89
+ generationId: DhGenerationIdSchema,
90
+ tenantScope: DhTenantScopeSchema,
91
+ captureCutoff: timestamp,
92
+ contentIncluded: Type.Boolean(),
93
+ eventIds: Type.Array(DhEventIdSchema, { maxItems: DH_MAX_ACK_IDS, uniqueItems: true }),
94
+ artifactIds: Type.Array(DhArtifactIdSchema, { maxItems: DH_MAX_ACK_IDS, uniqueItems: true }),
95
+ coverage: metadataCoverageSchema(),
96
+ });
97
+ }
98
+ function assertMetadataSemantics(value) {
99
+ if (value === null || typeof value !== "object")
100
+ return;
101
+ if (!Array.isArray(value)) {
102
+ const record = value;
103
+ for (const key of ["captureCutoff", "startedAt", "finishedAt"]) {
104
+ const text = record[key];
105
+ if (typeof text !== "string")
106
+ continue;
107
+ const base = text.slice(0, 19);
108
+ const instant = Date.parse(`${base}.000Z`);
109
+ if (!Number.isFinite(instant) || new Date(instant).toISOString().slice(0, 19) !== base) {
110
+ throw new DhContractError("schema_invalid", `Invalid trace HTTP DTO: ${key} is not a calendar-valid UTC instant`);
111
+ }
112
+ }
113
+ const coverage = record.coverage;
114
+ if (coverage && coverage.state !== "captured" && coverage.reason === undefined) {
115
+ throw new DhContractError("schema_invalid", "Invalid trace HTTP DTO: non-captured coverage requires a reason");
116
+ }
117
+ if (Array.isArray(record.items)) {
118
+ for (const item of record.items)
119
+ assertMetadataSemantics(item);
120
+ if (record.schema === "dh.generation-page/2" || record.schema === "dh.agent-page/2")
121
+ assertDhReadPageBinding({
122
+ cursorBinding: record.cursorBinding,
123
+ captureCutoff: record.captureCutoff,
124
+ items: record.items,
125
+ }, record.schema === "dh.generation-page/2" ? "generations" : "agents");
126
+ }
127
+ }
128
+ }
129
+ /** Lazy compilation avoids an initialization cycle with the existing /trace re-export. */
130
+ function parser(schema) {
131
+ let validator;
132
+ return (value) => {
133
+ assertDhPlainData(value);
134
+ validator ??= Compile(schema());
135
+ if (!validator.Check(value))
136
+ throw new DhContractError("schema_invalid", "Invalid trace HTTP DTO");
137
+ const clone = JSON.parse(JSON.stringify(value));
138
+ if (!validator.Check(clone))
139
+ throw new DhContractError("schema_invalid", "Invalid trace HTTP DTO");
140
+ assertMetadataSemantics(clone);
141
+ return clone;
142
+ };
143
+ }
144
+ export const parseDhGenerationPage = parser(generationPageSchema);
145
+ export const parseDhAgentPage = parser(agentPageSchema);
146
+ export const parseDhExportJob = parser(exportJobSchema);
147
+ export const parseDhExportDownload = parser(exportDownloadSchema);
148
+ export const parseDhExportManifest = parser(exportManifestSchema);
149
+ const parseBatchEnvelope = parser(() => strict({
150
+ schema: Type.Literal(DH_BATCH_SCHEMA_PROPOSAL),
151
+ streamId: DhStreamIdSchema,
152
+ events: Type.Array(Type.Unknown(), { maxItems: DH_BATCH_MAX_RECORDS }),
153
+ artifacts: Type.Array(Type.Unknown(), { maxItems: DH_BATCH_MAX_RECORDS }),
154
+ }));
155
+ /** Artifact metadata and artifact bytes are independent transfers; a batch need not be a complete bundle. */
156
+ export function parseDhIngestBatch(value) {
157
+ if (value instanceof Uint8Array)
158
+ value = parseDhRawJson(value, {
159
+ maxBytes: DH_BATCH_MAX_UTF8_BYTES,
160
+ rootArrayItemMaxBytes: { events: DH_EVENT_MAX_UTF8_BYTES },
161
+ });
162
+ assertDhPlainData(value);
163
+ // Validate records before serializing: serialization must not silently discard invalid payload values.
164
+ if (value === null || typeof value !== "object" || Array.isArray(value))
165
+ throw new DhContractError("schema_invalid", "Invalid trace batch");
166
+ const input = value;
167
+ if (!Array.isArray(input.events) || !Array.isArray(input.artifacts))
168
+ throw new DhContractError("schema_invalid", "Invalid trace batch record count");
169
+ if (input.events.length + input.artifacts.length > DH_BATCH_MAX_RECORDS)
170
+ throw new DhContractError("too_large", "Invalid trace batch record count");
171
+ // Array.from visits holes as undefined; map would skip them and serialize invalid null records.
172
+ const events = Array.from(input.events, parseDhEvent);
173
+ const artifacts = Array.from(input.artifacts, parseDhArtifact);
174
+ const envelope = parseBatchEnvelope({ ...input, events, artifacts });
175
+ if (events.some((event) => event.streamId !== envelope.streamId))
176
+ throw new DhContractError("schema_invalid", "Invalid trace batch streamId");
177
+ // Repeating an id (identical or with changed bytes) or a stream sequence inside one batch is never valid.
178
+ if (new Set(events.map((event) => event.eventId)).size !== events.length ||
179
+ new Set(events.map((event) => event.sequence)).size !== events.length ||
180
+ new Set(artifacts.map((artifact) => artifact.artifactId)).size !== artifacts.length)
181
+ throw new DhContractError("schema_invalid", "Invalid trace batch duplicate record");
182
+ const batch = { schema: envelope.schema, streamId: envelope.streamId, events, artifacts };
183
+ if (new TextEncoder().encode(dhCanonicalText(batch)).length > DH_BATCH_MAX_UTF8_BYTES)
184
+ throw new DhContractError("too_large", "Invalid trace batch size");
185
+ return batch;
186
+ }
187
+ /**
188
+ * Reuses dh.ack/1. accepted.eventIds, accepted.artifactIds and rejected are independent evidence;
189
+ * ackedThroughSequence never implies artifact metadata or byte acceptance. A PUT acknowledgement
190
+ * can name bytes only in the context of that PUT; a batch acknowledgement names records only.
191
+ */
192
+ export function parseDhIngestAck(value) {
193
+ const ack = parseDhAck(value);
194
+ const accepted = [...ack.accepted.eventIds, ...ack.accepted.artifactIds];
195
+ const rejected = ack.rejected.map((entry) => entry.id);
196
+ if (new Set(accepted).size !== accepted.length ||
197
+ new Set(rejected).size !== rejected.length ||
198
+ rejected.some((id) => accepted.includes(id)))
199
+ throw new DhContractError("schema_invalid", "Invalid trace acknowledgement: duplicate or conflicting ids");
200
+ return ack;
201
+ }
202
+ //# sourceMappingURL=trace-api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trace-api.js","sourceRoot":"","sources":["../src/trace-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,IAAI,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EACN,mBAAmB,EACnB,kBAAkB,EAClB,uBAAuB,EACvB,cAAc,EACd,WAAW,EAEX,eAAe,EACf,kBAAkB,EAElB,eAAe,EAEf,oBAAoB,EACpB,gBAAgB,EAChB,mBAAmB,EACnB,UAAU,EACV,eAAe,EACf,YAAY,GACZ,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3G,OAAO,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAEjF,kGAAkG;AAClG,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,CAAC;AAC1C,MAAM,CAAC,MAAM,yBAAyB,GAAG,IAAI,CAAC;AAC9C,MAAM,CAAC,MAAM,wBAAwB,GAAG,qBAA8B,CAAC;AACvE,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,CAAC;AACxC,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,GAAG,IAAI,CAAC;AAEnD,MAAM,MAAM,G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\n\ttype DhArtifactV1,\n\tDhEventIdSchema,\n\ttype DhEventV1,\n\tDhGenerationIdSchema,\n\tDhStreamIdSchema,\n\tDhTenantScopeSchema,\n\tparseDhAck,\n\tparseDhArtifact,\n\tparseDhEvent,\n} from \"./trace.ts\";\nimport { assertDhPlainData, DhContractError, dhCanonicalText, parseDhRawJson } from \"./trace-canonical.ts\";\nimport { assertDhReadPageBinding, dhCursorBindingSchema } from \"./trace-http.ts\";\n\n/** Candidate HTTP DTOs only. No server routes or retention/access policy are implemented here. */\nexport const DH_HTTP_MAX_PAGE_ITEMS = 100;\nexport const DH_HTTP_MAX_CURSOR_LENGTH = 1024;\nexport const DH_BATCH_SCHEMA_PROPOSAL = \"dh.batch/1-proposal\" as const;\nexport const DH_BATCH_MAX_RECORDS = 500;\nexport const DH_BATCH_MAX_UTF8_BYTES = 1024 * 1024;\n\nconst strict = <const T extends Parameters<typeof Type.Object>[0]>(properties: T) =>\n\tType.Object(properties, { additionalProperties: false });\nconst count = Type.Integer({ minimum: 0, maximum: Number.MAX_SAFE_INTEGER });\nconst timestamp = Type.String({\n\tminLength: 20,\n\tmaxLength: 30,\n\tpattern: \"^\\\\d{4}-\\\\d{2}-\\\\d{2}T\\\\d{2}:\\\\d{2}:\\\\d{2}(?:\\\\.\\\\d{1,9})?Z$\",\n});\nconst jobId = Type.String({ minLength: 1, maxLength: 256, pattern: \"^[A-Za-z0-9_-]+$\" });\nconst digest = Type.String({ pattern: \"^[a-f0-9]{64}$\" });\n\nfunction metadataCoverageSchema() {\n\t// Deliberately excludes coverage.detail: it can carry transcript content.\n\treturn strict({ state: Type.Enum(DH_COVERAGE_STATES), reason: Type.Optional(Type.Enum(DH_COVERAGE_REASONS)) });\n}\n\nfunction summaryProperties() {\n\treturn {\n\t\toutcome: Type.Optional(Type.Enum(DH_OUTCOMES)),\n\t\tstartedAt: Type.Optional(timestamp),\n\t\tfinishedAt: Type.Optional(timestamp),\n\t\tcoverage: Type.Optional(metadataCoverageSchema()),\n\t\teventCount: Type.Optional(count),\n\t\tartifactCount: Type.Optional(count),\n\t};\n}\n\nfunction generationSchema() {\n\treturn strict({\n\t\tgenerationId: DhGenerationIdSchema,\n\t\trootAgentId: Type.Optional(DhAgentIdSchema),\n\t\t...summaryProperties(),\n\t});\n}\nfunction agentSchema() {\n\treturn strict({\n\t\tgenerationId: DhGenerationIdSchema,\n\t\tagentId: DhAgentIdSchema,\n\t\tparentAgentId: Type.Optional(DhAgentIdSchema),\n\t\t...summaryProperties(),\n\t});\n}\nfunction pageSchema<T extends TSchema>(item: T, schema: \"dh.generation-page/2\" | \"dh.agent-page/2\") {\n\treturn strict({\n\t\tschema: Type.Literal(schema),\n\t\tcursorBinding: dhCursorBindingSchema(),\n\t\tnextCursor: Type.Union([Type.Null(), Type.String({ minLength: 1, maxLength: DH_HTTP_MAX_CURSOR_LENGTH })]),\n\t\tcaptureCutoff: timestamp,\n\t\titems: Type.Array(item, { maxItems: DH_HTTP_MAX_PAGE_ITEMS }),\n\t});\n}\n\nexport type DhGenerationSummary = Static<ReturnType<typeof generationSchema>>;\nexport type DhAgentSummary = Static<ReturnType<typeof agentSchema>>;\nexport type DhGenerationPage = Static<ReturnType<typeof generationPageSchema>>;\nexport type DhAgentPage = Static<ReturnType<typeof agentPageSchema>>;\nfunction generationPageSchema() {\n\treturn pageSchema(generationSchema(), \"dh.generation-page/2\");\n}\nfunction agentPageSchema() {\n\treturn pageSchema(agentSchema(), \"dh.agent-page/2\");\n}\n\n/** Transport states describe export work, not execution outcome or capture coverage. */\nexport const DH_EXPORT_STATES = [\"queued\", \"running\", \"ready\", \"failed\"] as const;\nexport type DhExportState = (typeof DH_EXPORT_STATES)[number];\nfunction exportJobSchema() {\n\treturn strict({ jobId, state: Type.Enum(DH_EXPORT_STATES) });\n}\nexport type DhExportJob = Static<ReturnType<typeof exportJobSchema>>;\n\n/** No URLs: a descriptor is not authorization to fetch a recorded or arbitrary URL. */\nfunction exportDownloadSchema() {\n\treturn Type.Union([\n\t\tstrict({ schema: Type.Literal(\"dh.export-download/2\"), state: Type.Literal(\"pending\") }),\n\t\tstrict({ schema: Type.Literal(\"dh.export-download/2\"), state: Type.Literal(\"unavailable\") }),\n\t\tstrict({\n\t\t\tschema: Type.Literal(\"dh.export-download/2\"),\n\t\t\tstate: Type.Literal(\"ready\"),\n\t\t\tmanifestSha256: digest,\n\t\t\theaderSha256: digest,\n\t\t\tsizeBytes: count,\n\t\t\tsha256: digest,\n\t\t\tmediaType: Type.Literal(\"application/octet-stream\"),\n\t\t}),\n\t]);\n}\nexport type DhExportDownload = Static<ReturnType<typeof exportDownloadSchema>>;\n\n/** Candidate manifest: identifies included records and cutoff; never claims missing data is complete. */\nfunction exportManifestSchema() {\n\treturn strict({\n\t\tgenerationId: DhGenerationIdSchema,\n\t\ttenantScope: DhTenantScopeSchema,\n\t\tcaptureCutoff: timestamp,\n\t\tcontentIncluded: Type.Boolean(),\n\t\teventIds: Type.Array(DhEventIdSchema, { maxItems: DH_MAX_ACK_IDS, uniqueItems: true }),\n\t\tartifactIds: Type.Array(DhArtifactIdSchema, { maxItems: DH_MAX_ACK_IDS, uniqueItems: true }),\n\t\tcoverage: metadataCoverageSchema(),\n\t});\n}\nexport type DhExportManifest = Static<ReturnType<typeof exportManifestSchema>>;\n\nfunction assertMetadataSemantics(value: unknown): void {\n\tif (value === null || typeof value !== \"object\") return;\n\tif (!Array.isArray(value)) {\n\t\tconst record = value as Record<string, unknown>;\n\t\tfor (const key of [\"captureCutoff\", \"startedAt\", \"finishedAt\"]) {\n\t\t\tconst text = record[key];\n\t\t\tif (typeof text !== \"string\") continue;\n\t\t\tconst base = text.slice(0, 19);\n\t\t\tconst instant = Date.parse(`${base}.000Z`);\n\t\t\tif (!Number.isFinite(instant) || new Date(instant).toISOString().slice(0, 19) !== base) {\n\t\t\t\tthrow new DhContractError(\n\t\t\t\t\t\"schema_invalid\",\n\t\t\t\t\t`Invalid trace HTTP DTO: ${key} is not a calendar-valid UTC instant`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tconst coverage = record.coverage as { state?: unknown; reason?: unknown } | undefined;\n\t\tif (coverage && coverage.state !== \"captured\" && coverage.reason === undefined) {\n\t\t\tthrow new DhContractError(\"schema_invalid\", \"Invalid trace HTTP DTO: non-captured coverage requires a reason\");\n\t\t}\n\t\tif (Array.isArray(record.items)) {\n\t\t\tfor (const item of record.items) assertMetadataSemantics(item);\n\t\t\tif (record.schema === \"dh.generation-page/2\" || record.schema === \"dh.agent-page/2\")\n\t\t\t\tassertDhReadPageBinding(\n\t\t\t\t\t{\n\t\t\t\t\t\tcursorBinding: record.cursorBinding,\n\t\t\t\t\t\tcaptureCutoff: record.captureCutoff as string,\n\t\t\t\t\t\titems: record.items,\n\t\t\t\t\t},\n\t\t\t\t\trecord.schema === \"dh.generation-page/2\" ? \"generations\" : \"agents\",\n\t\t\t\t);\n\t\t}\n\t}\n}\n\n/** Lazy compilation avoids an initialization cycle with the existing /trace re-export. */\nfunction parser<T extends TSchema>(schema: () => T) {\n\tlet validator: ReturnType<typeof Compile<T>> | undefined;\n\treturn (value: unknown): Static<T> => {\n\t\tassertDhPlainData(value);\n\t\tvalidator ??= Compile(schema());\n\t\tif (!validator.Check(value)) throw new DhContractError(\"schema_invalid\", \"Invalid trace HTTP DTO\");\n\t\tconst clone: unknown = JSON.parse(JSON.stringify(value));\n\t\tif (!validator.Check(clone)) throw new DhContractError(\"schema_invalid\", \"Invalid trace HTTP DTO\");\n\t\tassertMetadataSemantics(clone);\n\t\treturn clone;\n\t};\n}\nexport const parseDhGenerationPage = parser(generationPageSchema);\nexport const parseDhAgentPage = parser(agentPageSchema);\nexport const parseDhExportJob = parser(exportJobSchema);\nexport const parseDhExportDownload = parser(exportDownloadSchema);\nexport const parseDhExportManifest = parser(exportManifestSchema);\n\nexport interface DhIngestBatch {\n\tschema: typeof DH_BATCH_SCHEMA_PROPOSAL;\n\tstreamId: string;\n\tevents: readonly DhEventV1[];\n\tartifacts: readonly DhArtifactV1[];\n}\nconst parseBatchEnvelope = parser(() =>\n\tstrict({\n\t\tschema: Type.Literal(DH_BATCH_SCHEMA_PROPOSAL),\n\t\tstreamId: DhStreamIdSchema,\n\t\tevents: Type.Array(Type.Unknown(), { maxItems: DH_BATCH_MAX_RECORDS }),\n\t\tartifacts: Type.Array(Type.Unknown(), { maxItems: DH_BATCH_MAX_RECORDS }),\n\t}),\n);\n\n/** Artifact metadata and artifact bytes are independent transfers; a batch need not be a complete bundle. */\nexport function parseDhIngestBatch(value: unknown): DhIngestBatch {\n\tif (value instanceof Uint8Array)\n\t\tvalue = parseDhRawJson(value, {\n\t\t\tmaxBytes: DH_BATCH_MAX_UTF8_BYTES,\n\t\t\trootArrayItemMaxBytes: { events: DH_EVENT_MAX_UTF8_BYTES },\n\t\t});\n\tassertDhPlainData(value);\n\t// Validate records before serializing: serialization must not silently discard invalid payload values.\n\tif (value === null || typeof value !== \"object\" || Array.isArray(value))\n\t\tthrow new DhContractError(\"schema_invalid\", \"Invalid trace batch\");\n\tconst input = value as Record<string, unknown>;\n\tif (!Array.isArray(input.events) || !Array.isArray(input.artifacts))\n\t\tthrow new DhContractError(\"schema_invalid\", \"Invalid trace batch record count\");\n\tif (input.events.length + input.artifacts.length > DH_BATCH_MAX_RECORDS)\n\t\tthrow new DhContractError(\"too_large\", \"Invalid trace batch record count\");\n\t// Array.from visits holes as undefined; map would skip them and serialize invalid null records.\n\tconst events = Array.from(input.events, parseDhEvent);\n\tconst artifacts = Array.from(input.artifacts, parseDhArtifact);\n\tconst envelope = parseBatchEnvelope({ ...input, events, artifacts });\n\tif (events.some((event) => event.streamId !== envelope.streamId))\n\t\tthrow new DhContractError(\"schema_invalid\", \"Invalid trace batch streamId\");\n\t// Repeating an id (identical or with changed bytes) or a stream sequence inside one batch is never valid.\n\tif (\n\t\tnew Set(events.map((event) => event.eventId)).size !== events.length ||\n\t\tnew Set(events.map((event) => event.sequence)).size !== events.length ||\n\t\tnew Set(artifacts.map((artifact) => artifact.artifactId)).size !== artifacts.length\n\t)\n\t\tthrow new DhContractError(\"schema_invalid\", \"Invalid trace batch duplicate record\");\n\tconst batch: DhIngestBatch = { schema: envelope.schema, streamId: envelope.streamId, events, artifacts };\n\tif (new TextEncoder().encode(dhCanonicalText(batch)).length > DH_BATCH_MAX_UTF8_BYTES)\n\t\tthrow new DhContractError(\"too_large\", \"Invalid trace batch size\");\n\treturn batch;\n}\n\n/**\n * Reuses dh.ack/1. accepted.eventIds, accepted.artifactIds and rejected are independent evidence;\n * ackedThroughSequence never implies artifact metadata or byte acceptance. A PUT acknowledgement\n * can name bytes only in the context of that PUT; a batch acknowledgement names records only.\n */\nexport function parseDhIngestAck(value: unknown): DhAckV1 {\n\tconst ack = parseDhAck(value);\n\tconst accepted = [...ack.accepted.eventIds, ...ack.accepted.artifactIds];\n\tconst rejected = ack.rejected.map((entry) => entry.id);\n\tif (\n\t\tnew Set(accepted).size !== accepted.length ||\n\t\tnew Set(rejected).size !== rejected.length ||\n\t\trejected.some((id) => accepted.includes(id))\n\t)\n\t\tthrow new DhContractError(\"schema_invalid\", \"Invalid trace acknowledgement: duplicate or conflicting ids\");\n\treturn ack;\n}\n"]}
@@ -0,0 +1,94 @@
1
+ export declare const DH_ARTIFACT_SCHEMA_IDS: Readonly<{
2
+ readonly capabilityManifest: "dh.capability-manifest/1";
3
+ readonly contractArtifact: "dh.contract-artifact/1";
4
+ }>;
5
+ /** Literal implemented IDs only; lazy to preserve /trace entry-order neutrality. */
6
+ export declare function getDhImplementedSchemaIds(): readonly string[];
7
+ export declare const DH_CAPABILITY_ACTIONS: readonly ["backgroundStatus", "cancelSelected", "cancelWholeRun", "continueLive", "retryFresh"];
8
+ export type DhCapabilityAction = (typeof DH_CAPABILITY_ACTIONS)[number];
9
+ export declare const parseDhCapabilityManifest: (value: unknown) => {
10
+ readonly schema: "dh.capability-manifest/1";
11
+ readonly packageName: "@humain/humain-code-contracts";
12
+ readonly packageVersion: string;
13
+ readonly contractVersion: 1;
14
+ readonly artifactSha256: string;
15
+ readonly canonicalProfile: "dh.canonical-jcs/1";
16
+ readonly schemaIds: string[];
17
+ readonly conformanceVectorSha256: string;
18
+ readonly runtimes: {
19
+ readonly runtime: "cli-bun" | "cli-node" | "flow" | "forge-native";
20
+ readonly buildSha256: string;
21
+ readonly mode: string;
22
+ readonly platform: "darwin" | "linux" | "win32";
23
+ readonly actions: {
24
+ readonly backgroundStatus: {
25
+ readonly status: "supported" | "unknown" | "unsupported";
26
+ readonly channel: "in-process" | "inherited-fd3" | "native-executor" | "none" | "unix-socket";
27
+ readonly qualificationSha256?: string | undefined;
28
+ readonly reasonCode?: string | undefined;
29
+ };
30
+ readonly cancelSelected: {
31
+ readonly status: "supported" | "unknown" | "unsupported";
32
+ readonly channel: "in-process" | "inherited-fd3" | "native-executor" | "none" | "unix-socket";
33
+ readonly qualificationSha256?: string | undefined;
34
+ readonly reasonCode?: string | undefined;
35
+ };
36
+ readonly cancelWholeRun: {
37
+ readonly status: "supported" | "unknown" | "unsupported";
38
+ readonly channel: "in-process" | "inherited-fd3" | "native-executor" | "none" | "unix-socket";
39
+ readonly qualificationSha256?: string | undefined;
40
+ readonly reasonCode?: string | undefined;
41
+ };
42
+ readonly continueLive: {
43
+ readonly status: "supported" | "unknown" | "unsupported";
44
+ readonly channel: "in-process" | "inherited-fd3" | "native-executor" | "none" | "unix-socket";
45
+ readonly qualificationSha256?: string | undefined;
46
+ readonly reasonCode?: string | undefined;
47
+ };
48
+ readonly retryFresh: {
49
+ readonly status: "supported" | "unknown" | "unsupported";
50
+ readonly channel: "in-process" | "inherited-fd3" | "native-executor" | "none" | "unix-socket";
51
+ readonly qualificationSha256?: string | undefined;
52
+ readonly reasonCode?: string | undefined;
53
+ };
54
+ };
55
+ }[];
56
+ };
57
+ export type DhCapabilityManifest = ReturnType<typeof parseDhCapabilityManifest>;
58
+ export type DhCapabilityTarget = Pick<DhCapabilityManifest["runtimes"][number], "runtime" | "buildSha256" | "mode" | "platform">;
59
+ export declare function assertDhCapabilityAction(input: unknown, target: DhCapabilityTarget, action: DhCapabilityAction): DhCapabilityManifest["runtimes"][number]["actions"][DhCapabilityAction];
60
+ export declare const parseDhContractArtifact: (value: unknown) => {
61
+ readonly schema: "dh.contract-artifact/1";
62
+ readonly packageName: "@humain/humain-code-contracts";
63
+ readonly packageVersion: "0.3.2";
64
+ readonly contractVersion: 1;
65
+ readonly tarballFile: string;
66
+ readonly sha256: string;
67
+ readonly npmIntegrity: string;
68
+ readonly capabilityManifestFile: string;
69
+ readonly capabilityManifestSha256: string;
70
+ readonly conformanceVectorSha256: string;
71
+ readonly schemaIds: string[];
72
+ };
73
+ export type DhContractArtifact = ReturnType<typeof parseDhContractArtifact>;
74
+ /** Actual file/digest/export inspection is owned by the installer, not inferred from a descriptor. */
75
+ export interface DhContractArtifactInspection {
76
+ readonly packageName: string;
77
+ readonly packageVersion: string;
78
+ readonly contractVersion: number;
79
+ readonly exports: Readonly<Record<string, {
80
+ readonly types: string;
81
+ readonly import: string;
82
+ }>>;
83
+ readonly distPresent: boolean;
84
+ readonly sha256: string;
85
+ readonly npmIntegrity: string;
86
+ readonly capabilityManifest: unknown;
87
+ readonly capabilityManifestSha256: string;
88
+ readonly conformanceVectorSha256: string;
89
+ readonly schemaIds: readonly string[];
90
+ readonly tarballSymlink: boolean;
91
+ readonly capabilityManifestSymlink: boolean;
92
+ }
93
+ export declare function assertDhContractArtifact(input: unknown, inspection: DhContractArtifactInspection): void;
94
+ //# sourceMappingURL=trace-artifact.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trace-artifact.d.ts","sourceRoot":"","sources":["../src/trace-artifact.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,sBAAsB;iCACd,0BAA0B;+BAC5B,wBAAwB;EAChC,CAAC;AACZ,oFAAoF;AACpF,wBAAgB,yBAAyB,IAAI,SAAS,MAAM,EAAE,CAgB7D;AAUD,eAAO,MAAM,qBAAqB,YACjC,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB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