@lazyingart/agintiflow 0.20.311 → 0.20.313

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lazyingart/agintiflow",
3
- "version": "0.20.311",
3
+ "version": "0.20.313",
4
4
  "type": "module",
5
5
  "description": "AgInTiFlow is a project-aware agent workspace for hybrid wet-dry R&D, hardware-aware intelligence, software automation, and industrial workflows.",
6
6
  "license": "Apache-2.0",
@@ -1009,6 +1009,93 @@ assert.equal(
1009
1009
  "the first exact-search mismatch did not immediately open one bounded current-source refresh"
1010
1010
  );
1011
1011
  const tracebackFirstRefreshState = structuredClone(stalePatchRefreshState);
1012
+ const scopedArtifactPath =
1013
+ "output/webapp/agent/tasks/source-intake-audit/report.md";
1014
+ const scopedArtifactRoot = path.join(
1015
+ repoRoot,
1016
+ "output/webapp/agent/tasks/source-intake-audit"
1017
+ );
1018
+ const scopedArtifactGoal = [
1019
+ "Correct and verify the exact source-intake audit report.",
1020
+ `AGINTI_EVIDENCE_SCOPE_JSON: ${JSON.stringify({
1021
+ mode: "task",
1022
+ request: "Correct and verify the exact source-intake audit report.",
1023
+ artifact_root: scopedArtifactRoot,
1024
+ })}`,
1025
+ ].join("\n");
1026
+ const scopedArtifactRefreshState = {
1027
+ commandCwd: repoRoot,
1028
+ meta: {
1029
+ goalContract: {
1030
+ revision: 9,
1031
+ activeGoal: scopedArtifactGoal,
1032
+ taskGoal: scopedArtifactGoal,
1033
+ history: [],
1034
+ },
1035
+ projectVerification: {
1036
+ mutationRevision: 2,
1037
+ testRuns: [],
1038
+ },
1039
+ toolLoop: {
1040
+ stagnationEpoch: 4,
1041
+ recent: [],
1042
+ },
1043
+ },
1044
+ };
1045
+ const scopedArtifactRefresh = patchContextRefreshDecision(
1046
+ scopedArtifactRefreshState,
1047
+ {
1048
+ toolName: "apply_patch",
1049
+ args: {
1050
+ path: scopedArtifactPath,
1051
+ search: "Planned dynamic check: run the guarded document reader test.",
1052
+ replace: "Guarded document reader test: passed.",
1053
+ },
1054
+ ok: false,
1055
+ category: "workspace-patch",
1056
+ error: `Patch search text was not found in ${scopedArtifactPath}.`,
1057
+ }
1058
+ );
1059
+ assert.equal(
1060
+ scopedArtifactRefresh?.path,
1061
+ scopedArtifactPath,
1062
+ "a stale patch inside the exact scoped task artifact root was not recoverable"
1063
+ );
1064
+ scopedArtifactRefreshState.meta.toolLoop.patchContextRequired =
1065
+ scopedArtifactRefresh;
1066
+ assert.equal(
1067
+ activePatchContextRefresh(scopedArtifactRefreshState)?.path,
1068
+ scopedArtifactPath,
1069
+ "the scoped task-artifact refresh marker was rejected as a generic output path"
1070
+ );
1071
+ assert.equal(
1072
+ nextStepRuntimeConfig(baseConfig, scopedArtifactRefreshState)
1073
+ .patchContextRefreshPath,
1074
+ scopedArtifactPath,
1075
+ "the scoped task-artifact refresh path did not reach the next constrained turn"
1076
+ );
1077
+ const scopedArtifactSource = [
1078
+ "# Source Intake Audit",
1079
+ "",
1080
+ "Document reader verification is pending.",
1081
+ "",
1082
+ ].join("\n");
1083
+ assert.equal(
1084
+ consumePatchContextRefreshRead(scopedArtifactRefreshState, {
1085
+ toolName: "read_file",
1086
+ args: { path: scopedArtifactPath },
1087
+ result: { path: scopedArtifactPath },
1088
+ content: scopedArtifactSource,
1089
+ ok: true,
1090
+ })?.path,
1091
+ scopedArtifactPath,
1092
+ "an exact reread did not consume the scoped task-artifact refresh"
1093
+ );
1094
+ assert.equal(
1095
+ activePatchContextRepair(scopedArtifactRefreshState)?.path,
1096
+ scopedArtifactPath,
1097
+ "the scoped task-artifact reread did not leave a bounded repair anchor"
1098
+ );
1012
1099
  tracebackFirstRefreshState.meta.projectVerification.testRuns[0].failureSummary =
1013
1100
  'File "./service_ctl.py", line 139 -> return start_service(args.state_dir, args.host, args.port) parser = argparse.ArgumentParser()';
1014
1101
  const tracebackFirstRefresh = patchContextRefreshDecision(tracebackFirstRefreshState, {
@@ -11,6 +11,7 @@ import {
11
11
  modelPlanningTimeoutRetryRoute,
12
12
  nextStepRuntimeConfig,
13
13
  recordAlreadyCommittedRepositoryRepair,
14
+ recordProjectVerificationOutcome,
14
15
  runAgent,
15
16
  } from "../src/agent-runner.js";
16
17
  import { resolveRuntimeConfig } from "../src/config.js";
@@ -155,43 +156,42 @@ try {
155
156
  artifact_root: scopedArtifactRoot,
156
157
  })}`,
157
158
  ].join("\n");
158
- const scopedRuntime = nextStepRuntimeConfig(
159
- { commandCwd: scopedRepairRoot, goal: scopedGoal },
160
- {
161
- goal: scopedGoal,
162
- commandCwd: scopedRepairRoot,
163
- meta: {
164
- goalContract: {
165
- revision: 1,
166
- currentRequest: scopedGoal,
167
- currentHash: "scoped-repair",
168
- },
169
- activeExecutionContract: {
170
- revision: 1,
171
- refreshedAt,
172
- startedMutationRevision: 0,
173
- requiresWorkspaceMutation: true,
174
- requiresFileMutation: true,
175
- requiresSourceGrounding: true,
176
- },
177
- projectVerification: {
178
- mutationRevision: 0,
179
- mutationHistory: [],
180
- testRuns: [],
181
- discoveredTests: [],
182
- },
183
- toolLoop: {
184
- recent: [{
185
- toolName: "read_file",
186
- ok: true,
187
- blocked: false,
188
- path: scopedSource,
189
- at: groundedAt,
190
- }],
191
- },
159
+ const scopedState = {
160
+ goal: scopedGoal,
161
+ commandCwd: scopedRepairRoot,
162
+ meta: {
163
+ goalContract: {
164
+ revision: 1,
165
+ currentRequest: scopedGoal,
166
+ currentHash: "scoped-repair",
192
167
  },
193
- }
194
- );
168
+ activeExecutionContract: {
169
+ revision: 1,
170
+ refreshedAt,
171
+ startedMutationRevision: 0,
172
+ requiresWorkspaceMutation: true,
173
+ requiresFileMutation: true,
174
+ requiresSourceGrounding: true,
175
+ },
176
+ projectVerification: {
177
+ mutationRevision: 0,
178
+ mutationHistory: [],
179
+ testRuns: [],
180
+ discoveredTests: [],
181
+ },
182
+ toolLoop: {
183
+ recent: [{
184
+ toolName: "read_file",
185
+ ok: true,
186
+ blocked: false,
187
+ path: scopedSource,
188
+ at: groundedAt,
189
+ }],
190
+ },
191
+ },
192
+ };
193
+ const scopedConfig = { commandCwd: scopedRepairRoot, goal: scopedGoal };
194
+ const scopedRuntime = nextStepRuntimeConfig(scopedConfig, scopedState);
195
195
  assert.equal(scopedRuntime.scopedArtifactTask, true);
196
196
  assert.equal(
197
197
  scopedRuntime.completionFreshMutationRequired,
@@ -200,6 +200,34 @@ try {
200
200
  );
201
201
  assert.deepEqual(scopedRuntime.completionFreshMutationPaths, [scopedSource]);
202
202
  assert.equal(scopedRuntime.completionFreshMutationNeedsSourceRead, false);
203
+ recordProjectVerificationOutcome(
204
+ scopedState,
205
+ {
206
+ toolName: "write_file",
207
+ ok: true,
208
+ path: scopedSource,
209
+ args: { path: scopedSource },
210
+ change: {
211
+ path: scopedSource,
212
+ beforeHash: "rejected-report",
213
+ afterHash: "corrected-report",
214
+ beforeBytes: 18,
215
+ afterBytes: 96,
216
+ },
217
+ },
218
+ { ...scopedConfig, ...scopedRuntime }
219
+ );
220
+ assert.deepEqual(
221
+ scopedState.meta.activeExecutionContract.scopedArtifactMutationPaths,
222
+ [scopedSource],
223
+ "a successful scoped artifact write did not persist its current-turn mutation"
224
+ );
225
+ const scopedRuntimeAfterWrite = nextStepRuntimeConfig(scopedConfig, scopedState);
226
+ assert.equal(
227
+ scopedRuntimeAfterWrite.completionFreshMutationRequired,
228
+ undefined,
229
+ "a successful current-turn scoped artifact write remained trapped in source-mutation recovery"
230
+ );
203
231
  } finally {
204
232
  await fs.rm(scopedRepairRoot, { recursive: true, force: true });
205
233
  }
@@ -734,6 +734,41 @@ assertStrict.deepEqual(
734
734
  { path: mandatoryRefreshPath },
735
735
  "mandatory patch-context recovery did not preserve the exact constrained path"
736
736
  );
737
+ const scopedMandatoryRefreshPath =
738
+ "output/webapp/agent/tasks/source-intake-audit/report.md";
739
+ const scopedMandatoryRefreshRoot =
740
+ "output/webapp/agent/tasks/source-intake-audit";
741
+ const scopedMandatoryRefreshReadDescriptor = {
742
+ ...canonicalReadDescriptor,
743
+ function: {
744
+ ...canonicalReadDescriptor.function,
745
+ parameters: {
746
+ ...canonicalReadDescriptor.function.parameters,
747
+ properties: {
748
+ path: { type: "string", enum: [scopedMandatoryRefreshPath] },
749
+ },
750
+ },
751
+ },
752
+ };
753
+ const recoveredScopedMandatoryRefresh =
754
+ recoverRequiredPatchContextReadWithoutToolCall(
755
+ {
756
+ commandCwd: process.cwd(),
757
+ scopedArtifactRoot: scopedMandatoryRefreshRoot,
758
+ patchContextRefreshRequired: true,
759
+ patchContextRefreshPath: scopedMandatoryRefreshPath,
760
+ },
761
+ [],
762
+ createToolContract([scopedMandatoryRefreshReadDescriptor, tool("finish")]),
763
+ { ok: true, calls: [], acceptedToolCalls: [], deferredToolCalls: [] }
764
+ );
765
+ assertStrict.deepEqual(
766
+ JSON.parse(
767
+ recoveredScopedMandatoryRefresh.acceptedToolCalls[0].function.arguments
768
+ ),
769
+ { path: scopedMandatoryRefreshPath },
770
+ "mandatory patch-context recovery rejected the exact scoped task artifact"
771
+ );
737
772
  const recoveredPrematureRefreshFinish = recoverRequiredPatchContextReadWithoutToolCall(
738
773
  {
739
774
  patchContextRefreshRequired: true,
@@ -6622,6 +6622,28 @@ export function recordProjectVerificationOutcome(state = {}, toolResult = {}, co
6622
6622
  const projectMutationPaths = successfulProjectMutationPaths(toolResult, state, config);
6623
6623
  const privateMutationPaths = successfulPrivateVerificationMutationPaths(toolResult);
6624
6624
  const materialMutationPaths = materialProjectMutationPaths(toolResult, state, config);
6625
+ const scopedArtifactMutationPaths = successfulScopedArtifactMutationPaths(
6626
+ toolResult,
6627
+ state,
6628
+ config
6629
+ );
6630
+ const activeExecutionContract = state.meta?.activeExecutionContract;
6631
+ if (
6632
+ ["write_file", "apply_patch"].includes(toolName) &&
6633
+ scopedArtifactMutationPaths.length > 0 &&
6634
+ Number(activeExecutionContract?.revision || 0) ===
6635
+ Number(state.meta?.goalContract?.revision || 0)
6636
+ ) {
6637
+ activeExecutionContract.scopedArtifactMutationAt = now;
6638
+ activeExecutionContract.scopedArtifactMutationPaths = [
6639
+ ...new Set([
6640
+ ...(Array.isArray(activeExecutionContract.scopedArtifactMutationPaths)
6641
+ ? activeExecutionContract.scopedArtifactMutationPaths
6642
+ : []),
6643
+ ...scopedArtifactMutationPaths,
6644
+ ]),
6645
+ ].slice(0, 24);
6646
+ }
6625
6647
  if (["write_file", "apply_patch"].includes(toolName) && privateMutationPaths.length) {
6626
6648
  delete state.meta.verifiedCompletionCandidate;
6627
6649
  verification.privateMutationRevision += 1;
@@ -6669,7 +6691,6 @@ export function recordProjectVerificationOutcome(state = {}, toolResult = {}, co
6669
6691
  }
6670
6692
  : {}),
6671
6693
  }, config);
6672
- const activeExecutionContract = state.meta?.activeExecutionContract;
6673
6694
  if (
6674
6695
  materialMutationPaths.length > 0 &&
6675
6696
  Number(activeExecutionContract?.revision || 0) ===
@@ -10171,7 +10192,8 @@ export function repeatedStaticToolBlock(state, toolName, args = {}, config = {})
10171
10192
  (
10172
10193
  (
10173
10194
  requiredPatchRefresh &&
10174
- safeRecoveryEvidencePath(args?.path) === requiredPatchRefresh.path
10195
+ safePatchContextEvidencePath(args?.path, state, config) ===
10196
+ requiredPatchRefresh.path
10175
10197
  ) ||
10176
10198
  boundedFailedTestReadPaths.includes(safeRecoveryEvidencePath(args?.path))
10177
10199
  )
@@ -12681,7 +12703,9 @@ function isPrivateVerificationEvidencePath(value = "") {
12681
12703
  }
12682
12704
 
12683
12705
  function isScopedTaskArtifactEvidencePath(value = "", state = {}, config = {}) {
12684
- const artifactRoot = scopedArtifactRoot(completionContractGoal(config, state));
12706
+ const artifactRoot =
12707
+ scopedArtifactRoot(completionContractGoal(config, state)) ||
12708
+ String(config.scopedArtifactRoot || "").trim();
12685
12709
  if (!artifactRoot) return false;
12686
12710
  const raw = String(value || "")
12687
12711
  .trim()
@@ -12700,6 +12724,41 @@ function isScopedTaskArtifactEvidencePath(value = "", state = {}, config = {}) {
12700
12724
  );
12701
12725
  }
12702
12726
 
12727
+ function safePatchContextEvidencePath(value = "", state = {}, config = {}) {
12728
+ const sourcePath = safeRecoveryEvidencePath(value);
12729
+ if (sourcePath) return sourcePath;
12730
+
12731
+ const raw = String(value || "")
12732
+ .trim()
12733
+ .replace(/^["']|["']$/g, "")
12734
+ .replace(/\\/g, "/");
12735
+ if (
12736
+ !raw ||
12737
+ raw.includes("\0") ||
12738
+ /^https?:\/\//i.test(raw) ||
12739
+ /(?:secret|credential|password|private[-_]?key|access[-_]?token)/i.test(raw)
12740
+ ) {
12741
+ return "";
12742
+ }
12743
+ const commandCwd = path.resolve(
12744
+ config.commandCwd || state.commandCwd || process.cwd()
12745
+ );
12746
+ const absolutePath = path.isAbsolute(raw)
12747
+ ? path.resolve(raw)
12748
+ : path.resolve(commandCwd, raw);
12749
+ const relativePath = path.relative(commandCwd, absolutePath).replace(/\\/g, "/");
12750
+ if (
12751
+ !relativePath ||
12752
+ relativePath.startsWith("..") ||
12753
+ path.isAbsolute(relativePath) ||
12754
+ !PLAIN_TEXT_FILE_EXTENSIONS.has(path.extname(relativePath).toLowerCase()) ||
12755
+ !isScopedTaskArtifactEvidencePath(raw, state, config)
12756
+ ) {
12757
+ return "";
12758
+ }
12759
+ return relativePath;
12760
+ }
12761
+
12703
12762
  function commandWritesOnlyEvidenceMatching(command = "", pathMatches = () => false) {
12704
12763
  const normalized = String(command || "").trim();
12705
12764
  if (!normalized) return false;
@@ -13782,6 +13841,33 @@ function successfulMutationPaths(toolResult = {}) {
13782
13841
  return [...new Set([toolResult.path, ...changes.map((change) => change.path)].filter(Boolean))];
13783
13842
  }
13784
13843
 
13844
+ function successfulScopedArtifactMutationPaths(
13845
+ toolResult = {},
13846
+ state = {},
13847
+ config = {}
13848
+ ) {
13849
+ const artifactRoot = String(
13850
+ config.scopedArtifactRoot ||
13851
+ scopedArtifactRoot(completionContractGoal(config, state)) ||
13852
+ ""
13853
+ ).trim();
13854
+ if (!artifactRoot) return [];
13855
+ const commandCwd = path.resolve(
13856
+ config.commandCwd || state.commandCwd || process.cwd()
13857
+ );
13858
+ const resolvedRoot = path.resolve(commandCwd, artifactRoot);
13859
+ return successfulMutationPaths(toolResult)
13860
+ .map((candidate) => path.resolve(commandCwd, String(candidate || "")))
13861
+ .filter((candidate) => {
13862
+ const relative = path.relative(resolvedRoot, candidate);
13863
+ return (
13864
+ relative === "" ||
13865
+ (!relative.startsWith("..") && !path.isAbsolute(relative))
13866
+ );
13867
+ })
13868
+ .map((candidate) => path.relative(commandCwd, candidate).replace(/\\/g, "/"));
13869
+ }
13870
+
13785
13871
  function successfulWorkspaceMutationPaths(toolResult = {}) {
13786
13872
  if (!toolResult || toolResult.blocked || toolResult.skipped) return [];
13787
13873
  if (!["write_file", "apply_patch"].includes(String(toolResult.toolName || ""))) return [];
@@ -15283,6 +15369,20 @@ export function nextStepRuntimeConfig(config = {}, state = {}) {
15283
15369
  runtimeConfig.scopedArtifactRoot = scopedRootRelative.replace(/\\/g, "/");
15284
15370
  runtimeConfig.workspaceWritePathScopeRoots = [runtimeConfig.scopedArtifactRoot];
15285
15371
  }
15372
+ const scopedArtifactMutationAt = Date.parse(
15373
+ String(groundingExecutionContract.scopedArtifactMutationAt || "")
15374
+ );
15375
+ const executionContractRefreshedAt = Date.parse(
15376
+ String(groundingExecutionContract.refreshedAt || "")
15377
+ );
15378
+ const groundingScopedArtifactMutationSatisfied = Boolean(
15379
+ scopedArtifactTask &&
15380
+ Number.isFinite(scopedArtifactMutationAt) &&
15381
+ (
15382
+ !Number.isFinite(executionContractRefreshedAt) ||
15383
+ scopedArtifactMutationAt >= executionContractRefreshedAt
15384
+ )
15385
+ );
15286
15386
  if (
15287
15387
  (
15288
15388
  groundingTaskContract.requiresSourceGrounding === true ||
@@ -15397,7 +15497,8 @@ export function nextStepRuntimeConfig(config = {}, state = {}) {
15397
15497
  const currentTurnRequiresFreshMutation = Boolean(
15398
15498
  groundingExecutionContract.requiresFileMutation === true &&
15399
15499
  groundingExecutionContract.requiresSourceGrounding === true &&
15400
- !groundingFreshMutationSatisfied
15500
+ !groundingFreshMutationSatisfied &&
15501
+ !groundingScopedArtifactMutationSatisfied
15401
15502
  );
15402
15503
  const explicitHeadRestore = currentTurnRequiresFreshMutation
15403
15504
  ? explicitlyRequestedDirtyHeadRestore(state, config)
@@ -17610,10 +17711,11 @@ function validatedPatchContextCompleteSource(marker = {}) {
17610
17711
 
17611
17712
  export function activePatchContextRefresh(state = {}) {
17612
17713
  const marker = state.meta?.toolLoop?.patchContextRequired;
17714
+ const markerPath = safePatchContextEvidencePath(marker?.path, state);
17613
17715
  if (
17614
17716
  !marker ||
17615
17717
  Number(marker.version || 0) !== PATCH_CONTEXT_REFRESH_VERSION ||
17616
- !safeRecoveryEvidencePath(marker.path)
17718
+ !markerPath
17617
17719
  ) {
17618
17720
  return null;
17619
17721
  }
@@ -17644,16 +17746,17 @@ export function activePatchContextRefresh(state = {}) {
17644
17746
  }
17645
17747
  return {
17646
17748
  ...marker,
17647
- path: safeRecoveryEvidencePath(marker.path),
17749
+ path: markerPath,
17648
17750
  };
17649
17751
  }
17650
17752
 
17651
17753
  export function activePatchContextRepair(state = {}) {
17652
17754
  const marker = state.meta?.toolLoop?.patchContextRepair;
17755
+ const markerPath = safePatchContextEvidencePath(marker?.path, state);
17653
17756
  if (
17654
17757
  !marker ||
17655
17758
  Number(marker.version || 0) !== PATCH_CONTEXT_REPAIR_VERSION ||
17656
- !safeRecoveryEvidencePath(marker.path) ||
17759
+ !markerPath ||
17657
17760
  !String(marker.search || "") ||
17658
17761
  !String(marker.searchHash || "")
17659
17762
  ) {
@@ -17694,8 +17797,7 @@ export function activePatchContextRepair(state = {}) {
17694
17797
  const samePathFocuses = diagnosticMatchesRevision
17695
17798
  ? (Array.isArray(diagnostic.focuses) ? diagnostic.focuses : []).filter(
17696
17799
  (focus) =>
17697
- safeRecoveryEvidencePath(focus?.path) ===
17698
- safeRecoveryEvidencePath(marker.path) &&
17800
+ safePatchContextEvidencePath(focus?.path, state) === markerPath &&
17699
17801
  String(focus?.directSearch || "")
17700
17802
  )
17701
17803
  : [];
@@ -17712,7 +17814,7 @@ export function activePatchContextRepair(state = {}) {
17712
17814
  const completeSource = validatedPatchContextCompleteSource(marker);
17713
17815
  return {
17714
17816
  ...marker,
17715
- path: safeRecoveryEvidencePath(marker.path),
17817
+ path: markerPath,
17716
17818
  completeSource,
17717
17819
  completeSourceHash: completeSource ? String(marker.completeSourceHash || "") : "",
17718
17820
  completeSourceBytes: completeSource
@@ -18072,7 +18174,7 @@ function failedTestTracebackLineAnchor(state = {}, targetPath = "") {
18072
18174
  export function bindPatchContextRepairArguments(state = {}, requestedArgs = {}) {
18073
18175
  const marker = activePatchContextRepair(state);
18074
18176
  if (!marker || typeof requestedArgs?.replace !== "string") return null;
18075
- const requestedPath = safeRecoveryEvidencePath(requestedArgs.path);
18177
+ const requestedPath = safePatchContextEvidencePath(requestedArgs.path, state);
18076
18178
  if (requestedPath && requestedPath !== marker.path) return null;
18077
18179
  const requestedSearch = String(requestedArgs.search || "");
18078
18180
  const boundedSubrange = revisionBoundRequestedPatchSubrange(
@@ -18164,7 +18266,7 @@ export function bindPatchContextRepairArguments(state = {}, requestedArgs = {})
18164
18266
  }
18165
18267
 
18166
18268
  export function patchContextScopeMismatchAttemptCount(state = {}, targetPath = "") {
18167
- const normalizedPath = safeRecoveryEvidencePath(targetPath);
18269
+ const normalizedPath = safePatchContextEvidencePath(targetPath, state);
18168
18270
  if (!normalizedPath) return 0;
18169
18271
  const toolLoop = state.meta?.toolLoop || {};
18170
18272
  const stagnationEpoch = Math.max(0, Number(toolLoop.stagnationEpoch || 0));
@@ -18178,7 +18280,7 @@ export function patchContextScopeMismatchAttemptCount(state = {}, targetPath = "
18178
18280
  entry?.toolName !== "apply_patch" ||
18179
18281
  entry?.ok !== false ||
18180
18282
  entry?.category !== "patch-context-scope-mismatch" ||
18181
- safeRecoveryEvidencePath(entry?.path) !== normalizedPath ||
18283
+ safePatchContextEvidencePath(entry?.path, state) !== normalizedPath ||
18182
18284
  Number(entry?.stagnationEpoch || 0) !== stagnationEpoch
18183
18285
  ) {
18184
18286
  return false;
@@ -18259,7 +18361,7 @@ export function patchContextRefreshDecision(state = {}, toolResult = {}) {
18259
18361
  const recent = Array.isArray(toolLoop.recent) ? toolLoop.recent : [];
18260
18362
  const samePathRecent = recent.filter(
18261
18363
  (entry) =>
18262
- safeRecoveryEvidencePath(entry?.path) === targetPath &&
18364
+ safePatchContextEvidencePath(entry?.path, state) === targetPath &&
18263
18365
  Number(entry?.stagnationEpoch || 0) === stagnationEpoch
18264
18366
  );
18265
18367
  const priorMissingSearches = samePathRecent.filter(
@@ -18570,7 +18672,8 @@ export function consumePatchContextRepairMutation(state = {}, toolResult = {}) {
18570
18672
  String(toolResult.toolName || "") !== "apply_patch" ||
18571
18673
  toolResult.ok === false ||
18572
18674
  toolResult.blocked === true ||
18573
- toolResultWorkspacePath(toolResult) !== safeRecoveryEvidencePath(marker.path) ||
18675
+ toolResultWorkspacePath(toolResult) !==
18676
+ safePatchContextEvidencePath(marker.path, state) ||
18574
18677
  ![
18575
18678
  String(marker.searchHash || ""),
18576
18679
  String(marker.lastBoundSearchHash || ""),
@@ -24211,11 +24314,13 @@ export function recoverRequiredPatchContextReadWithoutToolCall(
24211
24314
  const selectedFailedTestReadMode = Boolean(
24212
24315
  !refreshMode && !repairMode && !selectedFailedTestDiagnosticReadMode && failedTestReadMode
24213
24316
  );
24317
+ const patchContextPath = (value) =>
24318
+ safePatchContextEvidencePath(value, {}, config);
24214
24319
  const exactPath = selectedFailedTestDiagnosticReadMode
24215
24320
  ? safeGeneratedDiagnosticEvidencePath(
24216
24321
  config.testFailureWorkspaceDiagnosticReadPaths?.[0]
24217
24322
  )
24218
- : safeRecoveryEvidencePath(
24323
+ : (refreshMode || repairMode ? patchContextPath : safeRecoveryEvidencePath)(
24219
24324
  refreshMode
24220
24325
  ? config.patchContextRefreshPath
24221
24326
  : repairMode
@@ -24226,7 +24331,9 @@ export function recoverRequiredPatchContextReadWithoutToolCall(
24226
24331
  const requestedCall = calls.length === 1 ? calls[0] : null;
24227
24332
  const requestedToolName = String(requestedCall?.function?.name || "");
24228
24333
  const requestedArgs = safeParseToolArgs(requestedCall);
24229
- const requestedPath = safeRecoveryEvidencePath(requestedArgs.path);
24334
+ const requestedPath = (refreshMode || repairMode
24335
+ ? patchContextPath
24336
+ : safeRecoveryEvidencePath)(requestedArgs.path);
24230
24337
  const missingRefreshCall = validation?.ok === true && calls.length === 0 && refreshMode;
24231
24338
  const unavailableContextCall =
24232
24339
  validation?.ok !== true &&
@@ -24295,7 +24402,9 @@ export function recoverRequiredPatchContextReadWithoutToolCall(
24295
24402
  readDescriptor.function?.parameters?.properties?.path?.enum;
24296
24403
  const normalizeAllowedPath = selectedFailedTestDiagnosticReadMode
24297
24404
  ? safeGeneratedDiagnosticEvidencePath
24298
- : safeRecoveryEvidencePath;
24405
+ : refreshMode || repairMode
24406
+ ? patchContextPath
24407
+ : safeRecoveryEvidencePath;
24299
24408
  if (
24300
24409
  !Array.isArray(allowedPaths) ||
24301
24410
  (!selectedFailedTestReadMode && !selectedFailedTestDiagnosticReadMode && allowedPaths.length !== 1) ||