@tangle-network/agent-eval 0.122.1 → 0.122.3

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 (44) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/analyst/index.js +4 -5
  3. package/dist/analyst/index.js.map +1 -1
  4. package/dist/benchmarks/index.js +6 -7
  5. package/dist/campaign/index.d.ts +25 -3
  6. package/dist/campaign/index.js +5 -6
  7. package/dist/{chunk-3A246TSA.js → chunk-BD2OK6ZW.js} +2 -2
  8. package/dist/{chunk-VZ6VKOJT.js → chunk-DHJJACEX.js} +90 -38
  9. package/dist/{chunk-VZ6VKOJT.js.map → chunk-DHJJACEX.js.map} +1 -1
  10. package/dist/{chunk-S5TT5R3L.js → chunk-EAWKAVID.js} +75 -2
  11. package/dist/chunk-EAWKAVID.js.map +1 -0
  12. package/dist/{chunk-TDHX3BVA.js → chunk-IDC74VDL.js} +62 -47
  13. package/dist/chunk-IDC74VDL.js.map +1 -0
  14. package/dist/{chunk-XDIRG3TO.js → chunk-N3QPYIVG.js} +201 -103
  15. package/dist/chunk-N3QPYIVG.js.map +1 -0
  16. package/dist/{chunk-4I2E3LLO.js → chunk-NMN4WGSJ.js} +2 -2
  17. package/dist/{chunk-PICTDURQ.js → chunk-OZFTLMGS.js} +2 -2
  18. package/dist/{chunk-QWMPPZ3X.js → chunk-SFXDMFGV.js} +2 -2
  19. package/dist/{chunk-P62I523A.js → chunk-ULW7AATT.js} +4 -6
  20. package/dist/{chunk-P62I523A.js.map → chunk-ULW7AATT.js.map} +1 -1
  21. package/dist/{chunk-JHOJHHU7.js → chunk-ZMXDQ4K7.js} +8 -5
  22. package/dist/{chunk-JHOJHHU7.js.map → chunk-ZMXDQ4K7.js.map} +1 -1
  23. package/dist/cli.js +2 -2
  24. package/dist/contract/index.d.ts +18 -0
  25. package/dist/contract/index.js +6 -6
  26. package/dist/fuzz.js +1 -1
  27. package/dist/index.d.ts +7 -1
  28. package/dist/index.js +12 -12
  29. package/dist/index.js.map +1 -1
  30. package/dist/openapi.json +1 -1
  31. package/dist/{run-campaign-HNFPJET4.js → run-campaign-2YJ3Z6JS.js} +3 -3
  32. package/dist/wire/index.js +2 -2
  33. package/docs/eval-surface-map.md +1 -1
  34. package/package.json +1 -1
  35. package/dist/chunk-3YYRZDON.js +0 -45
  36. package/dist/chunk-3YYRZDON.js.map +0 -1
  37. package/dist/chunk-S5TT5R3L.js.map +0 -1
  38. package/dist/chunk-TDHX3BVA.js.map +0 -1
  39. package/dist/chunk-XDIRG3TO.js.map +0 -1
  40. /package/dist/{chunk-3A246TSA.js.map → chunk-BD2OK6ZW.js.map} +0 -0
  41. /package/dist/{chunk-4I2E3LLO.js.map → chunk-NMN4WGSJ.js.map} +0 -0
  42. /package/dist/{chunk-PICTDURQ.js.map → chunk-OZFTLMGS.js.map} +0 -0
  43. /package/dist/{chunk-QWMPPZ3X.js.map → chunk-SFXDMFGV.js.map} +0 -0
  44. /package/dist/{run-campaign-HNFPJET4.js.map → run-campaign-2YJ3Z6JS.js.map} +0 -0
@@ -15,7 +15,7 @@ import {
15
15
  runImprovementLoop,
16
16
  surfaceContentHash,
17
17
  surfaceHash
18
- } from "./chunk-VZ6VKOJT.js";
18
+ } from "./chunk-DHJJACEX.js";
19
19
  import {
20
20
  SearchLedgerConflictError,
21
21
  SearchLedgerError,
@@ -26,17 +26,17 @@ import {
26
26
  createRunCostLedger,
27
27
  fsCampaignStorage,
28
28
  planCampaignRun,
29
+ probeAtomicFileLock,
29
30
  resolveRunDir,
30
31
  runCampaign,
31
32
  summarizeBackendIntegrity,
33
+ tryAcquireAtomicFileLock,
32
34
  withSearchLedgerFileLock
33
- } from "./chunk-XDIRG3TO.js";
34
- import {
35
- Mutex
36
- } from "./chunk-3YYRZDON.js";
35
+ } from "./chunk-N3QPYIVG.js";
37
36
  import {
38
37
  AnalystRegistry,
39
38
  DEFAULT_TRACE_ANALYST_KINDS,
39
+ Mutex,
40
40
  POLICY_EDIT_AXES,
41
41
  POLICY_EDIT_TARGET_SURFACES,
42
42
  admitPolicyEdit,
@@ -47,9 +47,10 @@ import {
47
47
  isPolicyEdit,
48
48
  makePolicyEdit,
49
49
  makePolicyEditCandidateRecord,
50
+ mapConcurrent,
50
51
  policyEditsFromFindings,
51
52
  validatePolicyEditCandidateRecord
52
- } from "./chunk-S5TT5R3L.js";
53
+ } from "./chunk-EAWKAVID.js";
53
54
  import {
54
55
  callLlm,
55
56
  callLlmJson,
@@ -68,7 +69,7 @@ import {
68
69
  import {
69
70
  CostAccountingIncompleteError,
70
71
  CostLedger
71
- } from "./chunk-JHOJHHU7.js";
72
+ } from "./chunk-ZMXDQ4K7.js";
72
73
  import {
73
74
  analyzeTraces
74
75
  } from "./chunk-WW2A73HW.js";
@@ -4212,9 +4213,13 @@ function toCandidate(p) {
4212
4213
  async function runLineageLoop(opts) {
4213
4214
  const governor = opts.governor ?? heuristicGovernor();
4214
4215
  const populationSize = opts.populationSize ?? 4;
4216
+ const candidateConcurrency = opts.candidateConcurrency ?? 1;
4215
4217
  if (populationSize < 1) {
4216
4218
  throw new Error("runLineageLoop: populationSize must be >= 1");
4217
4219
  }
4220
+ if (!Number.isInteger(candidateConcurrency) || candidateConcurrency < 1) {
4221
+ throw new Error("runLineageLoop: candidateConcurrency must be a positive integer");
4222
+ }
4218
4223
  let proposer = opts.proposer;
4219
4224
  if (!proposer) {
4220
4225
  if (!opts.llm || !opts.model) {
@@ -4280,18 +4285,17 @@ async function runLineageLoop(opts) {
4280
4285
  objectives.composite = node.score;
4281
4286
  return objectives;
4282
4287
  };
4283
- const scoredSeeds = [];
4284
- for (const seed of opts.seeds) {
4288
+ const scoredSeeds = await mapConcurrent(opts.seeds, candidateConcurrency, async (seed) => {
4285
4289
  const measured = await scoreSurface(seed.surface);
4286
- scoredSeeds.push({
4290
+ return {
4287
4291
  surface: seed.surface,
4288
4292
  track: seed.track,
4289
4293
  proposer: seed.proposer,
4290
4294
  score: measured.score,
4291
4295
  ...seed.vision !== void 0 ? { vision: seed.vision } : {},
4292
4296
  ...measured.scoreVector !== void 0 ? { scoreVector: measured.scoreVector } : {}
4293
- });
4294
- }
4297
+ };
4298
+ });
4295
4299
  const step = async (args) => {
4296
4300
  const proposed = await proposer.propose({
4297
4301
  currentSurface: args.tip.surface,
@@ -4310,16 +4314,21 @@ async function runLineageLoop(opts) {
4310
4314
  ...args.tip.rationale !== void 0 ? { rationale: args.tip.rationale } : {}
4311
4315
  }
4312
4316
  ];
4313
- for (const p of proposed) {
4314
- const { surface, rationale } = toCandidate(p);
4315
- const measured = await scoreSurface(surface);
4316
- pool.push({
4317
- surface,
4318
- score: measured.score,
4319
- ...measured.scoreVector !== void 0 ? { scoreVector: measured.scoreVector } : {},
4320
- ...rationale !== void 0 ? { rationale } : {}
4321
- });
4322
- }
4317
+ const measuredCandidates = await mapConcurrent(
4318
+ proposed,
4319
+ candidateConcurrency,
4320
+ async (p) => {
4321
+ const { surface, rationale } = toCandidate(p);
4322
+ const measured = await scoreSurface(surface);
4323
+ return {
4324
+ surface,
4325
+ score: measured.score,
4326
+ ...measured.scoreVector !== void 0 ? { scoreVector: measured.scoreVector } : {},
4327
+ ...rationale !== void 0 ? { rationale } : {}
4328
+ };
4329
+ }
4330
+ );
4331
+ pool.push(...measuredCandidates);
4323
4332
  let best = pool[0];
4324
4333
  for (const entry of pool) {
4325
4334
  if (entry.score > best.score) best = entry;
@@ -7377,37 +7386,43 @@ function formatZodError(error) {
7377
7386
  }
7378
7387
 
7379
7388
  // src/campaign/single-run-lock.ts
7380
- import { existsSync as existsSync4, readFileSync as readFileSync4, unlinkSync, writeFileSync as writeFileSync3 } from "fs";
7381
- function liveHolder(path) {
7382
- if (!existsSync4(path)) return null;
7383
- const holder = Number(readFileSync4(path, "utf8").trim());
7384
- if (!Number.isFinite(holder) || holder <= 0) return null;
7385
- try {
7386
- process.kill(holder, 0);
7387
- return holder;
7388
- } catch {
7389
- return null;
7389
+ function assertAvailable(path) {
7390
+ const unavailable = probeAtomicFileLock({ lockPath: path, acceptLegacyPid: true });
7391
+ if (unavailable) throw unavailableError(path, unavailable);
7392
+ }
7393
+ function unavailableError(path, unavailable) {
7394
+ if (unavailable.reason === "recovery") {
7395
+ return new Error(
7396
+ `single-run lock recovery is already in progress (${path}); refusing a concurrent run`
7397
+ );
7390
7398
  }
7399
+ return new Error(
7400
+ `single-run lock held by live pid ${unavailable.holder.pid} (${path}); refusing a concurrent run on the shared resource`
7401
+ );
7391
7402
  }
7392
7403
  function acquireSingleRunLock(opts) {
7393
7404
  const pid = opts.pid ?? process.pid;
7394
- for (const path of [opts.lockPath, ...opts.alsoCheck ?? []]) {
7395
- const holder = liveHolder(path);
7396
- if (holder !== null && holder !== pid) {
7397
- throw new Error(
7398
- `single-run lock held by live pid ${holder} (${path}); refusing a concurrent run on the shared resource`
7399
- );
7400
- }
7401
- }
7402
- writeFileSync3(opts.lockPath, String(pid));
7405
+ if (!Number.isSafeInteger(pid) || pid <= 0)
7406
+ throw new Error("single-run lock pid must be a positive integer");
7407
+ for (const path of opts.alsoCheck ?? []) assertAvailable(path);
7408
+ const acquisition = tryAcquireAtomicFileLock({
7409
+ lockPath: opts.lockPath,
7410
+ pid,
7411
+ acceptLegacyPid: true
7412
+ });
7413
+ if (!acquisition.acquired) throw unavailableError(opts.lockPath, acquisition);
7403
7414
  const release = () => {
7404
7415
  try {
7405
- if (existsSync4(opts.lockPath) && readFileSync4(opts.lockPath, "utf8").trim() === String(pid)) {
7406
- unlinkSync(opts.lockPath);
7407
- }
7416
+ acquisition.lock.release();
7408
7417
  } catch {
7409
7418
  }
7410
7419
  };
7420
+ try {
7421
+ for (const path of opts.alsoCheck ?? []) assertAvailable(path);
7422
+ } catch (error) {
7423
+ release();
7424
+ throw error;
7425
+ }
7411
7426
  if (opts.releaseOnExit ?? true) process.on("exit", release);
7412
7427
  return { release };
7413
7428
  }
@@ -7428,7 +7443,7 @@ import { execFileSync } from "child_process";
7428
7443
  import { createHash as createHash8 } from "crypto";
7429
7444
  import {
7430
7445
  closeSync,
7431
- existsSync as existsSync5,
7446
+ existsSync as existsSync4,
7432
7447
  constants as fsConstants,
7433
7448
  fstatSync,
7434
7449
  lstatSync,
@@ -7829,7 +7844,7 @@ function assertRawTreeMatchesWorktree(git, root, candidateCommit) {
7829
7844
  }
7830
7845
  function verifyCodeSurfaceWithGit(surface, path, git) {
7831
7846
  assertCodeSurfaceIdentity(surface);
7832
- if (!existsSync5(path)) {
7847
+ if (!existsSync4(path)) {
7833
7848
  throw new WorktreeAdapterError(`CodeSurface worktree does not exist: ${path}`);
7834
7849
  }
7835
7850
  const lexicalRoot = resolve3(path);
@@ -8108,4 +8123,4 @@ export {
8108
8123
  verifyCodeSurface,
8109
8124
  resolveWorktreePath
8110
8125
  };
8111
- //# sourceMappingURL=chunk-TDHX3BVA.js.map
8126
+ //# sourceMappingURL=chunk-IDC74VDL.js.map