@tangle-network/agent-eval 0.112.0 → 0.113.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.
@@ -1928,8 +1928,66 @@ function campaignBreakdown(campaign) {
1928
1928
  return { dimensions, scenarios };
1929
1929
  }
1930
1930
 
1931
- // src/campaign/presets/run-optimization.ts
1931
+ // src/campaign/surface-identity.ts
1932
1932
  import { createHash } from "crypto";
1933
+ var GIT_OBJECT_ID = /^(?:[a-f0-9]{40}|[a-f0-9]{64})$/;
1934
+ var SHA256 = /^sha256:[a-f0-9]{64}$/;
1935
+ function assertCodeSurfaceIdentity(surface) {
1936
+ if (!surface || typeof surface !== "object") {
1937
+ throw new TypeError("CodeSurface must be an object");
1938
+ }
1939
+ const candidate = surface;
1940
+ if (candidate.kind !== "code") throw new TypeError('CodeSurface.kind must be "code"');
1941
+ if (typeof candidate.worktreeRef !== "string" || candidate.worktreeRef.trim().length === 0) {
1942
+ throw new TypeError("CodeSurface.worktreeRef must be a non-empty locator");
1943
+ }
1944
+ if (typeof candidate.baseRef !== "string" || candidate.baseRef.trim().length === 0) {
1945
+ throw new TypeError("CodeSurface.baseRef must be a non-empty ref label");
1946
+ }
1947
+ for (const [field, value] of [
1948
+ ["baseCommit", candidate.baseCommit],
1949
+ ["baseTree", candidate.baseTree],
1950
+ ["candidateCommit", candidate.candidateCommit],
1951
+ ["candidateTree", candidate.candidateTree]
1952
+ ]) {
1953
+ if (typeof value !== "string" || !GIT_OBJECT_ID.test(value)) {
1954
+ throw new TypeError(`CodeSurface.${field} must be a full Git object id`);
1955
+ }
1956
+ }
1957
+ const patch = candidate.patch;
1958
+ if (!patch || typeof patch !== "object" || patch.format !== "git-diff-binary") {
1959
+ throw new TypeError('CodeSurface.patch.format must be "git-diff-binary"');
1960
+ }
1961
+ if (typeof patch.sha256 !== "string" || !SHA256.test(patch.sha256)) {
1962
+ throw new TypeError("CodeSurface.patch.sha256 must be a sha256 digest");
1963
+ }
1964
+ if (!Number.isSafeInteger(patch.byteLength) || patch.byteLength < 0) {
1965
+ throw new TypeError("CodeSurface.patch.byteLength must be a non-negative safe integer");
1966
+ }
1967
+ }
1968
+ function codeSurfaceIdentityMaterial(surface) {
1969
+ assertCodeSurfaceIdentity(surface);
1970
+ return JSON.stringify({
1971
+ schema: "tangle.code-surface.v1",
1972
+ baseCommit: surface.baseCommit,
1973
+ baseTree: surface.baseTree,
1974
+ candidateTree: surface.candidateTree,
1975
+ patch: {
1976
+ format: surface.patch.format,
1977
+ sha256: surface.patch.sha256,
1978
+ byteLength: surface.patch.byteLength
1979
+ }
1980
+ });
1981
+ }
1982
+ function surfaceContentHash(surface) {
1983
+ const material = typeof surface === "string" ? surface : codeSurfaceIdentityMaterial(surface);
1984
+ return `sha256:${createHash("sha256").update(material).digest("hex")}`;
1985
+ }
1986
+ function surfaceHash(surface) {
1987
+ return surfaceContentHash(surface).slice("sha256:".length, "sha256:".length + 16);
1988
+ }
1989
+
1990
+ // src/campaign/presets/run-optimization.ts
1933
1991
  async function runOptimization(opts) {
1934
1992
  const { proposer } = opts;
1935
1993
  const promoteTopK = opts.promoteTopK ?? 2;
@@ -2098,14 +2156,6 @@ function computeParetoFrontier(scored) {
2098
2156
  }));
2099
2157
  return paretoFrontier(scored, objectives).frontier;
2100
2158
  }
2101
- function surfaceHash(surface) {
2102
- const material = typeof surface === "string" ? surface : JSON.stringify({
2103
- kind: surface.kind,
2104
- worktreeRef: surface.worktreeRef,
2105
- baseRef: surface.baseRef ?? null
2106
- });
2107
- return createHash("sha256").update(material).digest("hex").slice(0, 16);
2108
- }
2109
2159
 
2110
2160
  // src/campaign/presets/run-improvement-loop.ts
2111
2161
  var DEFAULT_DISPATCH_TIMEOUT_MS = 6e5;
@@ -2273,14 +2323,6 @@ function evolutionaryProposer(opts) {
2273
2323
  // src/campaign/provenance.ts
2274
2324
  import { createHash as createHash2 } from "crypto";
2275
2325
  import { join as join2 } from "path";
2276
- function surfaceContentHash(surface) {
2277
- const material = typeof surface === "string" ? surface : JSON.stringify({
2278
- kind: surface.kind,
2279
- worktreeRef: surface.worktreeRef,
2280
- baseRef: surface.baseRef ?? null
2281
- });
2282
- return `sha256:${createHash2("sha256").update(material).digest("hex")}`;
2283
- }
2284
2326
  function meanHoldoutComposite(campaign) {
2285
2327
  const xs = [];
2286
2328
  for (const cell of campaign.cells) {
@@ -2314,7 +2356,7 @@ function buildLoopProvenanceRecord(args) {
2314
2356
  const baselineHoldoutComposite = meanHoldoutComposite(args.baselineOnHoldout);
2315
2357
  const winnerHoldoutComposite = meanHoldoutComposite(args.winnerOnHoldout);
2316
2358
  const record = {
2317
- schema: "tangle.loop-provenance.v1",
2359
+ schema: "tangle.loop-provenance.v2",
2318
2360
  runId: args.runId,
2319
2361
  runDir: args.runDir,
2320
2362
  timestamp: args.timestamp,
@@ -2576,17 +2618,19 @@ export {
2576
2618
  countSentenceEdits,
2577
2619
  campaignMeanComposite,
2578
2620
  campaignBreakdown,
2579
- runOptimization,
2621
+ assertCodeSurfaceIdentity,
2622
+ codeSurfaceIdentityMaterial,
2623
+ surfaceContentHash,
2580
2624
  surfaceHash,
2625
+ runOptimization,
2581
2626
  runImprovementLoop,
2582
2627
  defaultRenderDiff,
2583
2628
  runEval,
2584
2629
  evolutionaryProposer,
2585
- surfaceContentHash,
2586
2630
  buildLoopProvenanceRecord,
2587
2631
  loopProvenanceSpans,
2588
2632
  provenanceRecordPath,
2589
2633
  provenanceSpansPath,
2590
2634
  emitLoopProvenance
2591
2635
  };
2592
- //# sourceMappingURL=chunk-RCXMWGRY.js.map
2636
+ //# sourceMappingURL=chunk-F2NV5PQ6.js.map