wendkeep 0.78.0 → 0.79.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.
@@ -2,6 +2,7 @@ import { execFileSync } from 'node:child_process';
2
2
  import { cpSync, mkdtempSync, readFileSync, rmSync } from 'node:fs';
3
3
  import { tmpdir } from 'node:os';
4
4
  import { basename, join } from 'node:path';
5
+ import { evaluateReleaseChain } from './provenance-gate.mjs';
5
6
 
6
7
  const DEPENDENCY_FIELDS = Object.freeze([
7
8
  'dependencies',
@@ -52,6 +53,50 @@ export function packIntegrityInIsolatedCopy(root, { execute = execFileSync } = {
52
53
  }
53
54
  }
54
55
 
56
+ /**
57
+ * Calculate the publishable tarball from an immutable target commit. A local,
58
+ * detached clone keeps lifecycle mutations and an incidental worktree out of
59
+ * the observation.
60
+ */
61
+ export function collectArtifactAtCommit({
62
+ repoRoot,
63
+ targetCommit,
64
+ execute = execFileSync,
65
+ } = {}) {
66
+ if (!repoRoot || !/^[0-9a-f]{40}$/i.test(String(targetCommit || ''))) {
67
+ return { ok: false, state: 'unproven', reasonCodes: ['PROVENANCE_COMMIT_MISSING'] };
68
+ }
69
+ const tempRoot = mkdtempSync(join(tmpdir(), 'wendkeep-release-target-'));
70
+ const targetRoot = join(tempRoot, 'target');
71
+ try {
72
+ execute('git', ['clone', '--quiet', '--no-checkout', '--local', repoRoot, targetRoot], {
73
+ encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], shell: false,
74
+ });
75
+ execute('git', ['checkout', '--quiet', '--detach', targetCommit], {
76
+ cwd: targetRoot, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], shell: false,
77
+ });
78
+ const integrity = packIntegrityInIsolatedCopy(targetRoot, { execute });
79
+ if (!integrity) return {
80
+ ok: false, state: 'unproven', commit: targetCommit,
81
+ reasonCodes: ['PROVENANCE_INTEGRITY_UNOBSERVED'],
82
+ };
83
+ return {
84
+ ok: true,
85
+ state: 'verified',
86
+ commit: targetCommit,
87
+ integrity,
88
+ reasonCodes: [],
89
+ };
90
+ } catch {
91
+ return {
92
+ ok: false, state: 'reported', commit: targetCommit,
93
+ reasonCodes: ['PROVENANCE_SOURCE_UNAVAILABLE'],
94
+ };
95
+ } finally {
96
+ rmSync(tempRoot, { recursive: true, force: true });
97
+ }
98
+ }
99
+
55
100
  export function packageHasSelfDependency(pkg = {}) {
56
101
  const name = String(pkg.name || '');
57
102
  if (!name) return false;
@@ -66,7 +111,10 @@ export function evaluateReleaseProvenance({
66
111
  publishedIntegrity = '',
67
112
  localIntegrity = '',
68
113
  requirePublished = false,
114
+ chain = null,
115
+ context = null,
69
116
  } = {}) {
117
+ if (chain) return evaluateReleaseChain({ chain, context: context || {} });
70
118
  const tag = `v${version}`;
71
119
  if (tagCommit && tagCommit !== headCommit) {
72
120
  return {