@kungfu-tech/buildchain 2.3.1-alpha.0 → 2.3.1-alpha.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.
@@ -1,6 +1,7 @@
1
1
  export {
2
2
  discoverConfiguredVersionStateFiles,
3
3
  getLifecycleStage,
4
+ getNativeDiagnosticsProfile,
4
5
  getPublishContract,
5
6
  getVersionStrategy,
6
7
  loadBuildchainConfig,
@@ -53,6 +54,37 @@ export {
53
54
  verifyBuildchainLogEvents,
54
55
  } from "./logging.js";
55
56
 
57
+ export {
58
+ BUILDCHAIN_ANCHORED_PACKAGE_RELEASE_VALIDATION_CONTRACT,
59
+ BUILDCHAIN_DIAGNOSTICS_CONTRACT,
60
+ BUILDCHAIN_DIAGNOSTICS_MANIFEST_CONTRACT,
61
+ BUILDCHAIN_DIAGNOSTICS_SUMMARY_CONTRACT,
62
+ BUILDCHAIN_LIFECYCLE_OBSERVABILITY_CONTRACT,
63
+ BUILDCHAIN_PROCESS_SAMPLE_REPORT_CONTRACT,
64
+ BUILDCHAIN_PROCESS_SAMPLE_SUMMARY_CONTRACT,
65
+ classifyProcessCommand,
66
+ collectBuildchainDiagnostics,
67
+ collectCacheDiagnostics,
68
+ collectCompilerCacheDiagnostics,
69
+ collectGitDiagnostics,
70
+ collectNativeDiagnostics,
71
+ collectProcessTreeSnapshot,
72
+ collectRunnerDiagnostics,
73
+ collectToolDiagnostics,
74
+ createDiagnosticsArtifact,
75
+ detectRequestedParallelism,
76
+ detectRequestedParallelismFromProcessSamples,
77
+ formatDiagnosticsSummaryTable,
78
+ readDiagnosticsArtifact,
79
+ redactDiagnosticsValue,
80
+ startProcessSampler,
81
+ summarizeDiagnosticsArtifacts,
82
+ summarizeLifecycleObservability,
83
+ summarizeProcessSamples,
84
+ validateAnchoredPackageRelease,
85
+ writeDiagnosticsArtifact,
86
+ } from "./diagnostics.js";
87
+
56
88
  export {
57
89
  AGENT_INDEX_CONTRACT,
58
90
  ARTIFACT_EVIDENCE_CONTRACT,
@@ -1,4 +1,5 @@
1
1
  import crypto from "node:crypto";
2
+ import { spawnSync as nodeSpawnSync } from "node:child_process";
2
3
  import fs from "node:fs";
3
4
  import path from "node:path";
4
5
 
@@ -267,6 +268,54 @@ export function createBuildchainLogger(options = {}) {
267
268
  }
268
269
  }
269
270
 
271
+ function spanSync(eventName, details = {}, callback = () => undefined) {
272
+ const spanId = details.spanId || crypto.randomUUID();
273
+ const startedAt = Date.now();
274
+ emit("info", `${eventName}.start`, { ...details, spanId });
275
+ try {
276
+ const result = callback({ spanId });
277
+ emit("info", `${eventName}.end`, {
278
+ ...details,
279
+ spanId,
280
+ durationMs: Date.now() - startedAt,
281
+ });
282
+ return result;
283
+ } catch (error) {
284
+ emit("error", `${eventName}.error`, {
285
+ ...details,
286
+ spanId,
287
+ durationMs: Date.now() - startedAt,
288
+ message: error.message,
289
+ attributes: {
290
+ ...(details.attributes || {}),
291
+ errorName: error.name,
292
+ },
293
+ });
294
+ throw error;
295
+ }
296
+ }
297
+
298
+ function spawnSync(eventName, command, args = [], spawnOptions = {}, details = {}) {
299
+ return spanSync(eventName, details, () => {
300
+ const result = nodeSpawnSync(command, args, {
301
+ cwd,
302
+ env: process.env,
303
+ stdio: "inherit",
304
+ ...spawnOptions,
305
+ });
306
+ if (result.error) {
307
+ throw result.error;
308
+ }
309
+ if (result.status !== 0) {
310
+ const error = new Error(`command exited with ${result.status ?? "signal"}`);
311
+ error.status = result.status;
312
+ error.signal = result.signal;
313
+ throw error;
314
+ }
315
+ return result;
316
+ });
317
+ }
318
+
270
319
  return {
271
320
  path: resolvedPath,
272
321
  events: inMemoryEvents,
@@ -276,6 +325,8 @@ export function createBuildchainLogger(options = {}) {
276
325
  error: (eventName, details) => emit("error", eventName, details),
277
326
  mark: (eventName, details) => emit("info", eventName, details),
278
327
  span,
328
+ spanSync,
329
+ spawnSync,
279
330
  summary: () => summarizeBuildchainLogEvents(resolvedPath ? { path: resolvedPath } : inMemoryEvents),
280
331
  };
281
332
  }