@tangle-network/agent-eval 0.122.1 → 0.122.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 (37) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/analyst/index.js +4 -4
  3. package/dist/benchmarks/index.js +6 -6
  4. package/dist/campaign/index.d.ts +19 -3
  5. package/dist/campaign/index.js +5 -5
  6. package/dist/{chunk-QWMPPZ3X.js → chunk-5BYTIDZ7.js} +2 -2
  7. package/dist/{chunk-S5TT5R3L.js → chunk-5CVUPHJ4.js} +2 -2
  8. package/dist/{chunk-3A246TSA.js → chunk-BD2OK6ZW.js} +2 -2
  9. package/dist/{chunk-TDHX3BVA.js → chunk-EXMKNOP5.js} +37 -29
  10. package/dist/{chunk-TDHX3BVA.js.map → chunk-EXMKNOP5.js.map} +1 -1
  11. package/dist/{chunk-XDIRG3TO.js → chunk-N3QPYIVG.js} +201 -103
  12. package/dist/chunk-N3QPYIVG.js.map +1 -0
  13. package/dist/{chunk-4I2E3LLO.js → chunk-NMN4WGSJ.js} +2 -2
  14. package/dist/{chunk-PICTDURQ.js → chunk-OZFTLMGS.js} +2 -2
  15. package/dist/{chunk-VZ6VKOJT.js → chunk-U4R2AGY5.js} +52 -10
  16. package/dist/{chunk-VZ6VKOJT.js.map → chunk-U4R2AGY5.js.map} +1 -1
  17. package/dist/{chunk-P62I523A.js → chunk-XKSDSGSC.js} +3 -3
  18. package/dist/{chunk-JHOJHHU7.js → chunk-ZMXDQ4K7.js} +8 -5
  19. package/dist/{chunk-JHOJHHU7.js.map → chunk-ZMXDQ4K7.js.map} +1 -1
  20. package/dist/cli.js +2 -2
  21. package/dist/contract/index.d.ts +15 -0
  22. package/dist/contract/index.js +6 -6
  23. package/dist/fuzz.js +1 -1
  24. package/dist/index.js +9 -9
  25. package/dist/openapi.json +1 -1
  26. package/dist/{run-campaign-HNFPJET4.js → run-campaign-2YJ3Z6JS.js} +3 -3
  27. package/dist/wire/index.js +2 -2
  28. package/docs/eval-surface-map.md +1 -1
  29. package/package.json +1 -1
  30. package/dist/chunk-XDIRG3TO.js.map +0 -1
  31. /package/dist/{chunk-QWMPPZ3X.js.map → chunk-5BYTIDZ7.js.map} +0 -0
  32. /package/dist/{chunk-S5TT5R3L.js.map → chunk-5CVUPHJ4.js.map} +0 -0
  33. /package/dist/{chunk-3A246TSA.js.map → chunk-BD2OK6ZW.js.map} +0 -0
  34. /package/dist/{chunk-4I2E3LLO.js.map → chunk-NMN4WGSJ.js.map} +0 -0
  35. /package/dist/{chunk-PICTDURQ.js.map → chunk-OZFTLMGS.js.map} +0 -0
  36. /package/dist/{chunk-P62I523A.js.map → chunk-XKSDSGSC.js.map} +0 -0
  37. /package/dist/{run-campaign-HNFPJET4.js.map → run-campaign-2YJ3Z6JS.js.map} +0 -0
package/CHANGELOG.md CHANGED
@@ -4,6 +4,12 @@ All notable changes to `@tangle-network/agent-eval` and its sibling `agent-eval-
4
4
 
5
5
  ---
6
6
 
7
+ ## [0.122.2] — 2026-07-17 — premeasured optimization continuation
8
+
9
+ ### Added
10
+
11
+ - `runOptimization()` accepts a surface-bound, split-validated complete campaign as `premeasuredBaseline`, preserves its artifacts for analysis, and skips duplicate baseline dispatch.
12
+
7
13
  ## [0.121.0] — 2026-07-15 — one measured-comparison contract
8
14
 
9
15
  ### Changed
@@ -9,13 +9,13 @@ import {
9
9
  diffFindings,
10
10
  emitSkillUsageFindings,
11
11
  runSemanticConceptJudge
12
- } from "../chunk-P62I523A.js";
12
+ } from "../chunk-XKSDSGSC.js";
13
13
  import {
14
14
  behavioralAnalyst,
15
15
  buildDefaultAnalystRegistry,
16
16
  createChatClient,
17
17
  deriveEfficiencyFindings
18
- } from "../chunk-QWMPPZ3X.js";
18
+ } from "../chunk-5BYTIDZ7.js";
19
19
  import "../chunk-HHWE3POT.js";
20
20
  import "../chunk-3YYRZDON.js";
21
21
  import {
@@ -72,11 +72,11 @@ import {
72
72
  validatePolicyEdit,
73
73
  validatePolicyEditCandidateRecord,
74
74
  validateUsageSettlementTimeout
75
- } from "../chunk-S5TT5R3L.js";
75
+ } from "../chunk-5CVUPHJ4.js";
76
76
  import "../chunk-NJC7U437.js";
77
77
  import {
78
78
  CostLedger
79
- } from "../chunk-JHOJHHU7.js";
79
+ } from "../chunk-ZMXDQ4K7.js";
80
80
  import "../chunk-VI2UW6B6.js";
81
81
  import "../chunk-PXD6ZFNY.js";
82
82
  import "../chunk-PC4UYEBM.js";
@@ -16,16 +16,16 @@ import {
16
16
  routing_exports,
17
17
  runBenchmarkAdapter,
18
18
  summarizeBenchmarkCampaign
19
- } from "../chunk-PICTDURQ.js";
20
- import "../chunk-TDHX3BVA.js";
21
- import "../chunk-VZ6VKOJT.js";
22
- import "../chunk-XDIRG3TO.js";
19
+ } from "../chunk-OZFTLMGS.js";
20
+ import "../chunk-EXMKNOP5.js";
21
+ import "../chunk-U4R2AGY5.js";
22
+ import "../chunk-N3QPYIVG.js";
23
23
  import "../chunk-3YYRZDON.js";
24
- import "../chunk-S5TT5R3L.js";
24
+ import "../chunk-5CVUPHJ4.js";
25
25
  import "../chunk-ARU2PZFM.js";
26
26
  import "../chunk-NJC7U437.js";
27
27
  import "../chunk-PJQFMIOX.js";
28
- import "../chunk-JHOJHHU7.js";
28
+ import "../chunk-ZMXDQ4K7.js";
29
29
  import "../chunk-VI2UW6B6.js";
30
30
  import "../chunk-WW2A73HW.js";
31
31
  import "../chunk-GGE4NNQT.js";
@@ -4131,9 +4131,24 @@ declare function parameterSweepProposer(opts: ParameterSweepProposerOptions): Su
4131
4131
  * re-score + release gate + optional PR.
4132
4132
  */
4133
4133
 
4134
+ interface PremeasuredOptimizationBaseline<TArtifact, TScenario extends Scenario> {
4135
+ /** Hash of the exact surface that produced `campaign`. */
4136
+ surfaceHash: string;
4137
+ /** Complete prior measurement reused by identity, including artifactsByPath. */
4138
+ campaign: CampaignResult<TArtifact, TScenario>;
4139
+ }
4134
4140
  interface RunOptimizationBaseOptions<TScenario extends Scenario, TArtifact> extends Omit<RunCampaignOptions<TScenario, TArtifact>, 'dispatch'> {
4135
4141
  /** Initial mutable surface (typically system prompt or addendum). */
4136
4142
  baselineSurface: MutableSurface;
4143
+ /**
4144
+ * Complete prior measurement of `baselineSurface`. When present,
4145
+ * `runOptimization` validates its surface, scenario split, seed, reps, and
4146
+ * normal campaign coverage, then skips the baseline campaign entirely — no
4147
+ * dispatch or resumability-cache lookup. Candidate campaigns still run
4148
+ * normally. Prior spend remains in the imported campaign aggregates and is
4149
+ * not added again to this continuation's CostLedger.
4150
+ */
4151
+ premeasuredBaseline?: PremeasuredOptimizationBaseline<TArtifact, TScenario>;
4137
4152
  /** Dispatcher that takes the CURRENT surface + scenario → artifact. */
4138
4153
  dispatchWithSurface: (surface: MutableSurface, scenario: TScenario, ctx: Parameters<RunCampaignOptions<TScenario, TArtifact>['dispatch']>[1]) => Promise<TArtifact>;
4139
4154
  /** The candidate-generation strategy. Wrap a population `Mutator` via
@@ -7324,7 +7339,7 @@ interface SingleRunLockOptions {
7324
7339
  readonly alsoCheck?: readonly string[];
7325
7340
  /** Install a process 'exit' hook that releases the lock. Default true. */
7326
7341
  readonly releaseOnExit?: boolean;
7327
- /** Owner pid recorded in the lockfile. Default process.pid. */
7342
+ /** Owner pid recorded in the lockfile metadata. Default process.pid. */
7328
7343
  readonly pid?: number;
7329
7344
  }
7330
7345
  interface SingleRunLock {
@@ -7333,7 +7348,8 @@ interface SingleRunLock {
7333
7348
  }
7334
7349
  /**
7335
7350
  * Acquire the lock or throw naming the live holder. A stale lock (holder pid
7336
- * no longer running) is reclaimed silently.
7351
+ * no longer running) is reclaimed by one contender. An interrupted reclaim
7352
+ * leaves a marker that fails closed instead of admitting overlapping runs.
7337
7353
  */
7338
7354
  declare function acquireSingleRunLock(opts: SingleRunLockOptions): SingleRunLock;
7339
7355
 
@@ -7464,4 +7480,4 @@ declare function verifyCodeSurface(surface: CodeSurface, worktreeDir?: string):
7464
7480
  * identity against the checkout at `worktreeRef`. */
7465
7481
  declare function resolveWorktreePath(surface: CodeSurface, worktreeDir?: string): string;
7466
7482
 
7467
- export { type AcceptedEdit, type AceProposerOptions, type AnalystArtifact, type AnalystScenario, type AnalyzeCrossSurfaceInteractionsInput, type ApplySkillPatchResult, type AxisEvidence, type AxisVerdict, type BuildAnalystSurfaceDispatchOptions, type BuildEvidenceVectorOptions, type BuildLoopProvenanceArgs, type CampaignAggregates, type CampaignArtifactWriter, type CampaignBreakdown, type CampaignCellResult, type CampaignCostMeter, type CampaignResult, type CampaignRunPlan, type CampaignRunPlanCell, type CampaignScenarioIdentity, type CampaignStorage, type CampaignTokenUsage, type CampaignTraceWriter, type CodeSurface, type CodeSurfaceVerification, type CompareProposersOptions, type CompositeProposerOptions, type CostLedgerHandle, type CrossSurfaceAdditionDecision, type CrossSurfaceAdditionRejectionReason, type CrossSurfaceAttemptCompleteness, type CrossSurfaceBestSingleSelection, type CrossSurfaceBootstrapPolicy, type CrossSurfaceCandidate, type CrossSurfaceCandidateComparison, type CrossSurfaceCandidateEvidence, type CrossSurfaceCandidateOutcome, type CrossSurfaceCandidateSummary, type CrossSurfaceComponent, type CrossSurfaceComponentEvidence, type CrossSurfaceCompositionStep, type CrossSurfaceDistribution, type CrossSurfaceEligibility, type CrossSurfaceEvidenceBreakdown, type CrossSurfaceIneligibilityReason, type CrossSurfaceInteractionAwareSelection, type CrossSurfaceInteractionEffect, type CrossSurfaceInteractionPath, type CrossSurfaceInteractionReport, type CrossSurfaceInteractionTask, type CrossSurfaceNaiveStackSelection, type CrossSurfacePairCompatibility, type CrossSurfacePairEvidence, type CrossSurfacePairIncompatibilityReason, type CrossSurfacePairwiseEntry, type CrossSurfaceRankedSingle, type CrossSurfaceRelativeCost, type CrossSurfaceSelectionPolicy, type CrossSurfaceSelections, type CrossSurfaceTaskRow, DEFAULT_POLICY_EDIT_HISTORY_LIMITS, type DefaultProductionGateOptions, type DimensionRegression, type DiscriminationScore, type DispatchContext, type DispatchFn, type EmitLoopProvenanceArgs, type EmitLoopProvenanceResult, type EvalFixture, type EvalFixtureFile, type EvalFixtureLoadOptions, type EvalFixtureRunPlan, type EvalFixtureScenario, type EvalFixtureValidationMode, type EvidenceVector, type EvolutionaryProposerOptions, type FailureModeRecallJudgeOptions, type FapoAttributionSignals, type FapoEntryConfig, type FapoFailureCluster, type FapoOptimizationLevel, type FapoProposerOptions, type FapoReviewInput, type FapoReviewIssue, type FapoReviewResult, type FapoScopeContract, FileSearchLedger, FsLabeledScenarioStore, type FsLabeledScenarioStoreOptions, type Gate, type GateContext, type GateDecision, type GateResult, type GenerationCandidate, type GenerationRecord, type GepaProposerConstraints, type GepaProposerOptions, type GitWorktreeAdapterOptions, type Governor, type GovernorContext, type GovernorOp, type HaloProposerOptions, type HeldOutGateOptions, type HeldoutSignificance, type HeldoutSignificanceOptions, type HeuristicGovernorOptions, type JsonPolicyEditTargetSurface, type JsonPrimitive, type JsonValue, type JudgeAggregate, type JudgeConfig, type JudgeDimension, type JudgeScore, type LabelTrust, type LabeledScenarioRecord, type LabeledScenarioSampleArgs, type LabeledScenarioSource, type LabeledScenarioStore, LabeledScenarioStoreError, type LabeledScenarioWrite, Lineage, type LineageEdge, type LineageGraph, type LineageNode, type LineageNodeInput, type LineageStore, type LlmJudgeDimension, type LlmJudgeOptions, type LlmPolicyEditProposerOptions, type LoadEvalFixtureScenariosOptions, type LoopProvenanceArgsFromResult, type LoopProvenanceBackend, type LoopProvenanceCandidate, type LoopProvenanceEvidence, type LoopProvenanceRecord, type MemoryCurationProposerOptions, type MutableSurface, type Mutator, type NeutralizationGateOptions, type ObjectiveSource, type OpenAutoPrOptions, type OpenAutoPrResult, type OpenSearchLedgerOptions, type OptimizationProposer, type OptimizerConfig, type OptimizerEntryConfig, POLICY_EDIT_CANDIDATE_RECORD_SCHEMA, type PairedHoldout, type ParameterCandidate, type ParameterChange, type ParameterSweepProposerOptions, type ParetoParent, type ParetoSignificanceGateOptions, type PlanCampaignRunOptions, type PlanEvalFixtureRunOptions, type PlaybackContext, type PlaybackDriver, type PlaybackStep, type PolicyEditAuthorScenarioRow, type PolicyEditCandidateRecord, type PolicyEditCandidateSummary, type PolicyEditFindingInput, type PolicyEditFindingSource, type PolicyEditHistoryCandidateContext, type PolicyEditHistoryGenerationContext, type PolicyEditHistoryProjectionOptions, type PolicyEditObjective, type PolicyEditOutcomeContext, type PolicyEditProposerOptions, type PowerPreflight, type PowerPreflightOptions, type ProfileDispatchFn, ProfileMatrixError, type ProfileSummary, type PromotionObjective, type PromotionPolicy, type ProposeContext, type ProposePatchesArgs, type ProposedCandidate, type ProposerComparison, type ProposerEntry, type ProposerPairwise, type ProposerScore, type RedactionStatus, type ReferenceEquivalenceJudgeOptions, type ReferenceEquivalenceScenario, type RejectedEdit, type RolloutArgumentDiff, type RolloutArgumentDiffOptions, type RolloutCall, type RunCampaignOptions, type RunEvalOptions, type RunImprovementLoopOptions, type RunImprovementLoopResult, type RunLineageLoopOptions, type RunLineageLoopResult, type RunLineageLoopSeed, type RunLineageOptions, type RunLineageResult, type RunLineageSeed, type RunLineageStepResult, type RunOptimizationOptions, type RunOptimizationResult, type RunProfileMatrixOptions, type RunProfileMatrixResult, type RunSkillOptOptions, type RunSkillOptResult, SEARCH_LEDGER_SCHEMA, type Scenario, type ScenarioAggregate, type ScenarioRollup, type ScenarioSignal, type ScoreboardRenderOptions, type ScoreboardRow, type ScoreboardSummary, type ScoredRollout, type ScoredSurfaceOutcome, type SearchAccountingAudit, type SearchArtifactRef, type SearchAttemptAccounting, type SearchCandidateDecidedEvent, type SearchCandidateLineage, type SearchCandidateRegisteredEvent, type SearchCandidateSlot, type SearchCandidateSlotClosedEvent, type SearchCandidateSurface, type SearchCompletedEvent, type SearchCostAccounting, type SearchFailureReason, type SearchLedger, type SearchLedgerAppendResult, SearchLedgerConflictError, type SearchLedgerEntry, SearchLedgerError, type SearchLedgerEvent, type SearchLedgerHash, SearchLedgerIntegrityError, type SearchLedgerReplay, type SearchModelIdentity, type SearchOperationKind, type SearchOperationRecordedEvent, type SearchPlan, type SearchPlannedEvent, type SearchPlannedOperation, type SearchPlannedTask, type SearchSourceRef, type SearchSurfaceEffect, type SearchSurfaceEvidence, type SearchSurfaceKind, type SearchTaskAttemptedEvent, type SearchTaskOutcome, type SearchTokenAccounting, type SelectPolicyEditAuthorRowsOptions, type SequentialDecideFn, type SequentialDecideOptions, type SequentialDecision, type SequentialObservation, type SequentialPairedGate, type SequentialPairedGateOptions, type SerializedJsonBudget, type SessionScript, type SingleRunLock, type SingleRunLockOptions, type SkillOptEpochRecord, type SkillOptEvidence, type SkillOptProposer, type SkillOptProposerOptions, type SkillPatch, type SkillPatchOp, SkillPatchParseError, type SkillPatchRejection, type SurfaceProposer, type SurfaceScore, type TraceAnalystProposerOptions, type TraceSpan, type TransientFailureOptions, type UngroundedLiteralReport, type UserStory, type UserStoryVerdict, type Worktree, type WorktreeAdapter, WorktreeAdapterError, aceProposer, acquireSingleRunLock, analyzeCrossSurfaceInteractions, applySkillPatch, assertCampaignDesign, assertCampaignSplitIdentity, assertCodeSurfaceIdentity, assertPolicyEditAuthorContextBudget, buildAnalystSurfaceDispatch, buildEvidenceVector, buildLoopProvenanceRecord, callbackGovernor, campaignBreakdown, campaignMeanComposite, campaignMeasurementDigest, campaignScenarioIdentity, campaignSplitDigest, campaignSplitDigestFromIdentities, canonicalDigest, classifyUngroundedLiterals, codeSurfaceIdentityMaterial, compareProposers, composeGate, compositeProposer, countSentenceEdits, createReferenceEquivalenceJudge, createRunCostLedger, defaultProductionGate, detectScale, dimensionRegressions, discoverEvalFixtures, emitLoopProvenance, evolutionaryProposer, extractFapoAttributionSignals, extractH2Sections, failureModeRecallJudge, fapoEscalationEntry, fapoProposer, fsCampaignStorage, fsLineageStore, gepaParetoEntry, gepaProposer, gepaReflectionEntry, gitWorktreeAdapter, haloProposer, heldOutGate, heldoutSignificance, heuristicGovernor, inMemoryCampaignStorage, isProposedCandidate, isTransientTransportFailure, labelTrustRank, lineageNodeId, llmJudge, llmPolicyEditProposer, loadEvalFixture, loadEvalFixtureScenarios, loopProvenanceArgsFromResult, loopProvenanceSpans, makePlaybackDispatch, memLineageStore, memoryCurationProposer, neutralizationGate, neutralizeText, openAutoPr, openSearchLedger, pairHoldout, parameterSweepProposer, paretoPolicy, paretoSignificanceGate, parseSkillPatchResponse, patchEditCount, planCampaignRun, planEvalFixtureRun, policyEditProposer, powerPreflight, projectPolicyEditHistory, provenanceRecordPath, provenanceSpansPath, renderScoreboardMarkdown, renderSurfaceDiff, resolveRunDir, resolveWorktreePath, rolloutArgumentDiff, runCampaign, runEval, runImprovementLoop, runLineage, runLineageLoop, runOptimization, runProfileMatrix, runSkillOpt, scoreDiscrimination, scoreUserStory, scoreboardSummary, selectDiscriminative, selectPolicyEditAuthorRows, sequentialDecide, sequentialPairedGate, skillOptEntry, skillOptProposer, surfaceContentHash, surfaceHash, tangleTracesRoot, traceAnalystProposer, userStoryScoreboard, validatePolicyEditCandidateRecord, validateSearchLedgerEvent, verifyCodeSurface, verifyLoopProvenanceRecord };
7483
+ export { type AcceptedEdit, type AceProposerOptions, type AnalystArtifact, type AnalystScenario, type AnalyzeCrossSurfaceInteractionsInput, type ApplySkillPatchResult, type AxisEvidence, type AxisVerdict, type BuildAnalystSurfaceDispatchOptions, type BuildEvidenceVectorOptions, type BuildLoopProvenanceArgs, type CampaignAggregates, type CampaignArtifactWriter, type CampaignBreakdown, type CampaignCellResult, type CampaignCostMeter, type CampaignResult, type CampaignRunPlan, type CampaignRunPlanCell, type CampaignScenarioIdentity, type CampaignStorage, type CampaignTokenUsage, type CampaignTraceWriter, type CodeSurface, type CodeSurfaceVerification, type CompareProposersOptions, type CompositeProposerOptions, type CostLedgerHandle, type CrossSurfaceAdditionDecision, type CrossSurfaceAdditionRejectionReason, type CrossSurfaceAttemptCompleteness, type CrossSurfaceBestSingleSelection, type CrossSurfaceBootstrapPolicy, type CrossSurfaceCandidate, type CrossSurfaceCandidateComparison, type CrossSurfaceCandidateEvidence, type CrossSurfaceCandidateOutcome, type CrossSurfaceCandidateSummary, type CrossSurfaceComponent, type CrossSurfaceComponentEvidence, type CrossSurfaceCompositionStep, type CrossSurfaceDistribution, type CrossSurfaceEligibility, type CrossSurfaceEvidenceBreakdown, type CrossSurfaceIneligibilityReason, type CrossSurfaceInteractionAwareSelection, type CrossSurfaceInteractionEffect, type CrossSurfaceInteractionPath, type CrossSurfaceInteractionReport, type CrossSurfaceInteractionTask, type CrossSurfaceNaiveStackSelection, type CrossSurfacePairCompatibility, type CrossSurfacePairEvidence, type CrossSurfacePairIncompatibilityReason, type CrossSurfacePairwiseEntry, type CrossSurfaceRankedSingle, type CrossSurfaceRelativeCost, type CrossSurfaceSelectionPolicy, type CrossSurfaceSelections, type CrossSurfaceTaskRow, DEFAULT_POLICY_EDIT_HISTORY_LIMITS, type DefaultProductionGateOptions, type DimensionRegression, type DiscriminationScore, type DispatchContext, type DispatchFn, type EmitLoopProvenanceArgs, type EmitLoopProvenanceResult, type EvalFixture, type EvalFixtureFile, type EvalFixtureLoadOptions, type EvalFixtureRunPlan, type EvalFixtureScenario, type EvalFixtureValidationMode, type EvidenceVector, type EvolutionaryProposerOptions, type FailureModeRecallJudgeOptions, type FapoAttributionSignals, type FapoEntryConfig, type FapoFailureCluster, type FapoOptimizationLevel, type FapoProposerOptions, type FapoReviewInput, type FapoReviewIssue, type FapoReviewResult, type FapoScopeContract, FileSearchLedger, FsLabeledScenarioStore, type FsLabeledScenarioStoreOptions, type Gate, type GateContext, type GateDecision, type GateResult, type GenerationCandidate, type GenerationRecord, type GepaProposerConstraints, type GepaProposerOptions, type GitWorktreeAdapterOptions, type Governor, type GovernorContext, type GovernorOp, type HaloProposerOptions, type HeldOutGateOptions, type HeldoutSignificance, type HeldoutSignificanceOptions, type HeuristicGovernorOptions, type JsonPolicyEditTargetSurface, type JsonPrimitive, type JsonValue, type JudgeAggregate, type JudgeConfig, type JudgeDimension, type JudgeScore, type LabelTrust, type LabeledScenarioRecord, type LabeledScenarioSampleArgs, type LabeledScenarioSource, type LabeledScenarioStore, LabeledScenarioStoreError, type LabeledScenarioWrite, Lineage, type LineageEdge, type LineageGraph, type LineageNode, type LineageNodeInput, type LineageStore, type LlmJudgeDimension, type LlmJudgeOptions, type LlmPolicyEditProposerOptions, type LoadEvalFixtureScenariosOptions, type LoopProvenanceArgsFromResult, type LoopProvenanceBackend, type LoopProvenanceCandidate, type LoopProvenanceEvidence, type LoopProvenanceRecord, type MemoryCurationProposerOptions, type MutableSurface, type Mutator, type NeutralizationGateOptions, type ObjectiveSource, type OpenAutoPrOptions, type OpenAutoPrResult, type OpenSearchLedgerOptions, type OptimizationProposer, type OptimizerConfig, type OptimizerEntryConfig, POLICY_EDIT_CANDIDATE_RECORD_SCHEMA, type PairedHoldout, type ParameterCandidate, type ParameterChange, type ParameterSweepProposerOptions, type ParetoParent, type ParetoSignificanceGateOptions, type PlanCampaignRunOptions, type PlanEvalFixtureRunOptions, type PlaybackContext, type PlaybackDriver, type PlaybackStep, type PolicyEditAuthorScenarioRow, type PolicyEditCandidateRecord, type PolicyEditCandidateSummary, type PolicyEditFindingInput, type PolicyEditFindingSource, type PolicyEditHistoryCandidateContext, type PolicyEditHistoryGenerationContext, type PolicyEditHistoryProjectionOptions, type PolicyEditObjective, type PolicyEditOutcomeContext, type PolicyEditProposerOptions, type PowerPreflight, type PowerPreflightOptions, type PremeasuredOptimizationBaseline, type ProfileDispatchFn, ProfileMatrixError, type ProfileSummary, type PromotionObjective, type PromotionPolicy, type ProposeContext, type ProposePatchesArgs, type ProposedCandidate, type ProposerComparison, type ProposerEntry, type ProposerPairwise, type ProposerScore, type RedactionStatus, type ReferenceEquivalenceJudgeOptions, type ReferenceEquivalenceScenario, type RejectedEdit, type RolloutArgumentDiff, type RolloutArgumentDiffOptions, type RolloutCall, type RunCampaignOptions, type RunEvalOptions, type RunImprovementLoopOptions, type RunImprovementLoopResult, type RunLineageLoopOptions, type RunLineageLoopResult, type RunLineageLoopSeed, type RunLineageOptions, type RunLineageResult, type RunLineageSeed, type RunLineageStepResult, type RunOptimizationOptions, type RunOptimizationResult, type RunProfileMatrixOptions, type RunProfileMatrixResult, type RunSkillOptOptions, type RunSkillOptResult, SEARCH_LEDGER_SCHEMA, type Scenario, type ScenarioAggregate, type ScenarioRollup, type ScenarioSignal, type ScoreboardRenderOptions, type ScoreboardRow, type ScoreboardSummary, type ScoredRollout, type ScoredSurfaceOutcome, type SearchAccountingAudit, type SearchArtifactRef, type SearchAttemptAccounting, type SearchCandidateDecidedEvent, type SearchCandidateLineage, type SearchCandidateRegisteredEvent, type SearchCandidateSlot, type SearchCandidateSlotClosedEvent, type SearchCandidateSurface, type SearchCompletedEvent, type SearchCostAccounting, type SearchFailureReason, type SearchLedger, type SearchLedgerAppendResult, SearchLedgerConflictError, type SearchLedgerEntry, SearchLedgerError, type SearchLedgerEvent, type SearchLedgerHash, SearchLedgerIntegrityError, type SearchLedgerReplay, type SearchModelIdentity, type SearchOperationKind, type SearchOperationRecordedEvent, type SearchPlan, type SearchPlannedEvent, type SearchPlannedOperation, type SearchPlannedTask, type SearchSourceRef, type SearchSurfaceEffect, type SearchSurfaceEvidence, type SearchSurfaceKind, type SearchTaskAttemptedEvent, type SearchTaskOutcome, type SearchTokenAccounting, type SelectPolicyEditAuthorRowsOptions, type SequentialDecideFn, type SequentialDecideOptions, type SequentialDecision, type SequentialObservation, type SequentialPairedGate, type SequentialPairedGateOptions, type SerializedJsonBudget, type SessionScript, type SingleRunLock, type SingleRunLockOptions, type SkillOptEpochRecord, type SkillOptEvidence, type SkillOptProposer, type SkillOptProposerOptions, type SkillPatch, type SkillPatchOp, SkillPatchParseError, type SkillPatchRejection, type SurfaceProposer, type SurfaceScore, type TraceAnalystProposerOptions, type TraceSpan, type TransientFailureOptions, type UngroundedLiteralReport, type UserStory, type UserStoryVerdict, type Worktree, type WorktreeAdapter, WorktreeAdapterError, aceProposer, acquireSingleRunLock, analyzeCrossSurfaceInteractions, applySkillPatch, assertCampaignDesign, assertCampaignSplitIdentity, assertCodeSurfaceIdentity, assertPolicyEditAuthorContextBudget, buildAnalystSurfaceDispatch, buildEvidenceVector, buildLoopProvenanceRecord, callbackGovernor, campaignBreakdown, campaignMeanComposite, campaignMeasurementDigest, campaignScenarioIdentity, campaignSplitDigest, campaignSplitDigestFromIdentities, canonicalDigest, classifyUngroundedLiterals, codeSurfaceIdentityMaterial, compareProposers, composeGate, compositeProposer, countSentenceEdits, createReferenceEquivalenceJudge, createRunCostLedger, defaultProductionGate, detectScale, dimensionRegressions, discoverEvalFixtures, emitLoopProvenance, evolutionaryProposer, extractFapoAttributionSignals, extractH2Sections, failureModeRecallJudge, fapoEscalationEntry, fapoProposer, fsCampaignStorage, fsLineageStore, gepaParetoEntry, gepaProposer, gepaReflectionEntry, gitWorktreeAdapter, haloProposer, heldOutGate, heldoutSignificance, heuristicGovernor, inMemoryCampaignStorage, isProposedCandidate, isTransientTransportFailure, labelTrustRank, lineageNodeId, llmJudge, llmPolicyEditProposer, loadEvalFixture, loadEvalFixtureScenarios, loopProvenanceArgsFromResult, loopProvenanceSpans, makePlaybackDispatch, memLineageStore, memoryCurationProposer, neutralizationGate, neutralizeText, openAutoPr, openSearchLedger, pairHoldout, parameterSweepProposer, paretoPolicy, paretoSignificanceGate, parseSkillPatchResponse, patchEditCount, planCampaignRun, planEvalFixtureRun, policyEditProposer, powerPreflight, projectPolicyEditHistory, provenanceRecordPath, provenanceSpansPath, renderScoreboardMarkdown, renderSurfaceDiff, resolveRunDir, resolveWorktreePath, rolloutArgumentDiff, runCampaign, runEval, runImprovementLoop, runLineage, runLineageLoop, runOptimization, runProfileMatrix, runSkillOpt, scoreDiscrimination, scoreUserStory, scoreboardSummary, selectDiscriminative, selectPolicyEditAuthorRows, sequentialDecide, sequentialPairedGate, skillOptEntry, skillOptProposer, surfaceContentHash, surfaceHash, tangleTracesRoot, traceAnalystProposer, userStoryScoreboard, validatePolicyEditCandidateRecord, validateSearchLedgerEvent, verifyCodeSurface, verifyLoopProvenanceRecord };
@@ -66,7 +66,7 @@ import {
66
66
  userStoryScoreboard,
67
67
  validateSearchLedgerEvent,
68
68
  verifyCodeSurface
69
- } from "../chunk-TDHX3BVA.js";
69
+ } from "../chunk-EXMKNOP5.js";
70
70
  import {
71
71
  assertCodeSurfaceIdentity,
72
72
  buildEvidenceVector,
@@ -107,7 +107,7 @@ import {
107
107
  surfaceContentHash,
108
108
  surfaceHash,
109
109
  verifyLoopProvenanceRecord
110
- } from "../chunk-VZ6VKOJT.js";
110
+ } from "../chunk-U4R2AGY5.js";
111
111
  import {
112
112
  SearchLedgerConflictError,
113
113
  SearchLedgerError,
@@ -124,16 +124,16 @@ import {
124
124
  resolveRunDir,
125
125
  runCampaign,
126
126
  tangleTracesRoot
127
- } from "../chunk-XDIRG3TO.js";
127
+ } from "../chunk-N3QPYIVG.js";
128
128
  import "../chunk-3YYRZDON.js";
129
129
  import {
130
130
  POLICY_EDIT_CANDIDATE_RECORD_SCHEMA,
131
131
  validatePolicyEditCandidateRecord
132
- } from "../chunk-S5TT5R3L.js";
132
+ } from "../chunk-5CVUPHJ4.js";
133
133
  import "../chunk-ARU2PZFM.js";
134
134
  import "../chunk-NJC7U437.js";
135
135
  import "../chunk-PJQFMIOX.js";
136
- import "../chunk-JHOJHHU7.js";
136
+ import "../chunk-ZMXDQ4K7.js";
137
137
  import "../chunk-VI2UW6B6.js";
138
138
  import "../chunk-WW2A73HW.js";
139
139
  import "../chunk-GGE4NNQT.js";
@@ -6,7 +6,7 @@ import {
6
6
  DEFAULT_TRACE_ANALYST_KINDS,
7
7
  createTraceAnalystKind,
8
8
  makeFinding
9
- } from "./chunk-S5TT5R3L.js";
9
+ } from "./chunk-5CVUPHJ4.js";
10
10
  import {
11
11
  LlmClient
12
12
  } from "./chunk-NJC7U437.js";
@@ -547,4 +547,4 @@ export {
547
547
  behavioralAnalyst,
548
548
  buildDefaultAnalystRegistry
549
549
  };
550
- //# sourceMappingURL=chunk-QWMPPZ3X.js.map
550
+ //# sourceMappingURL=chunk-5BYTIDZ7.js.map
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-NJC7U437.js";
7
7
  import {
8
8
  CostLedger
9
- } from "./chunk-JHOJHHU7.js";
9
+ } from "./chunk-ZMXDQ4K7.js";
10
10
  import {
11
11
  buildTraceAnalystTools,
12
12
  runTraceAnalysisLoop
@@ -2665,4 +2665,4 @@ export {
2665
2665
  aggregateRunScore,
2666
2666
  clamp012 as clamp01
2667
2667
  };
2668
- //# sourceMappingURL=chunk-S5TT5R3L.js.map
2668
+ //# sourceMappingURL=chunk-5CVUPHJ4.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  summarizeBackendIntegrity
3
- } from "./chunk-XDIRG3TO.js";
3
+ } from "./chunk-N3QPYIVG.js";
4
4
  import {
5
5
  paretoChart
6
6
  } from "./chunk-DPZAEKA6.js";
@@ -995,4 +995,4 @@ export {
995
995
  summarizeExecution,
996
996
  analyzeRuns
997
997
  };
998
- //# sourceMappingURL=chunk-3A246TSA.js.map
998
+ //# sourceMappingURL=chunk-BD2OK6ZW.js.map
@@ -15,7 +15,7 @@ import {
15
15
  runImprovementLoop,
16
16
  surfaceContentHash,
17
17
  surfaceHash
18
- } from "./chunk-VZ6VKOJT.js";
18
+ } from "./chunk-U4R2AGY5.js";
19
19
  import {
20
20
  SearchLedgerConflictError,
21
21
  SearchLedgerError,
@@ -26,11 +26,13 @@ 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";
35
+ } from "./chunk-N3QPYIVG.js";
34
36
  import {
35
37
  Mutex
36
38
  } from "./chunk-3YYRZDON.js";
@@ -49,7 +51,7 @@ import {
49
51
  makePolicyEditCandidateRecord,
50
52
  policyEditsFromFindings,
51
53
  validatePolicyEditCandidateRecord
52
- } from "./chunk-S5TT5R3L.js";
54
+ } from "./chunk-5CVUPHJ4.js";
53
55
  import {
54
56
  callLlm,
55
57
  callLlmJson,
@@ -68,7 +70,7 @@ import {
68
70
  import {
69
71
  CostAccountingIncompleteError,
70
72
  CostLedger
71
- } from "./chunk-JHOJHHU7.js";
73
+ } from "./chunk-ZMXDQ4K7.js";
72
74
  import {
73
75
  analyzeTraces
74
76
  } from "./chunk-WW2A73HW.js";
@@ -7377,37 +7379,43 @@ function formatZodError(error) {
7377
7379
  }
7378
7380
 
7379
7381
  // 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;
7382
+ function assertAvailable(path) {
7383
+ const unavailable = probeAtomicFileLock({ lockPath: path, acceptLegacyPid: true });
7384
+ if (unavailable) throw unavailableError(path, unavailable);
7385
+ }
7386
+ function unavailableError(path, unavailable) {
7387
+ if (unavailable.reason === "recovery") {
7388
+ return new Error(
7389
+ `single-run lock recovery is already in progress (${path}); refusing a concurrent run`
7390
+ );
7390
7391
  }
7392
+ return new Error(
7393
+ `single-run lock held by live pid ${unavailable.holder.pid} (${path}); refusing a concurrent run on the shared resource`
7394
+ );
7391
7395
  }
7392
7396
  function acquireSingleRunLock(opts) {
7393
7397
  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));
7398
+ if (!Number.isSafeInteger(pid) || pid <= 0)
7399
+ throw new Error("single-run lock pid must be a positive integer");
7400
+ for (const path of opts.alsoCheck ?? []) assertAvailable(path);
7401
+ const acquisition = tryAcquireAtomicFileLock({
7402
+ lockPath: opts.lockPath,
7403
+ pid,
7404
+ acceptLegacyPid: true
7405
+ });
7406
+ if (!acquisition.acquired) throw unavailableError(opts.lockPath, acquisition);
7403
7407
  const release = () => {
7404
7408
  try {
7405
- if (existsSync4(opts.lockPath) && readFileSync4(opts.lockPath, "utf8").trim() === String(pid)) {
7406
- unlinkSync(opts.lockPath);
7407
- }
7409
+ acquisition.lock.release();
7408
7410
  } catch {
7409
7411
  }
7410
7412
  };
7413
+ try {
7414
+ for (const path of opts.alsoCheck ?? []) assertAvailable(path);
7415
+ } catch (error) {
7416
+ release();
7417
+ throw error;
7418
+ }
7411
7419
  if (opts.releaseOnExit ?? true) process.on("exit", release);
7412
7420
  return { release };
7413
7421
  }
@@ -7428,7 +7436,7 @@ import { execFileSync } from "child_process";
7428
7436
  import { createHash as createHash8 } from "crypto";
7429
7437
  import {
7430
7438
  closeSync,
7431
- existsSync as existsSync5,
7439
+ existsSync as existsSync4,
7432
7440
  constants as fsConstants,
7433
7441
  fstatSync,
7434
7442
  lstatSync,
@@ -7829,7 +7837,7 @@ function assertRawTreeMatchesWorktree(git, root, candidateCommit) {
7829
7837
  }
7830
7838
  function verifyCodeSurfaceWithGit(surface, path, git) {
7831
7839
  assertCodeSurfaceIdentity(surface);
7832
- if (!existsSync5(path)) {
7840
+ if (!existsSync4(path)) {
7833
7841
  throw new WorktreeAdapterError(`CodeSurface worktree does not exist: ${path}`);
7834
7842
  }
7835
7843
  const lexicalRoot = resolve3(path);
@@ -8108,4 +8116,4 @@ export {
8108
8116
  verifyCodeSurface,
8109
8117
  resolveWorktreePath
8110
8118
  };
8111
- //# sourceMappingURL=chunk-TDHX3BVA.js.map
8119
+ //# sourceMappingURL=chunk-EXMKNOP5.js.map