@lazyingart/agintiflow 0.20.311 → 0.20.312

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.312",
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, {
@@ -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,
@@ -10171,7 +10171,8 @@ export function repeatedStaticToolBlock(state, toolName, args = {}, config = {})
10171
10171
  (
10172
10172
  (
10173
10173
  requiredPatchRefresh &&
10174
- safeRecoveryEvidencePath(args?.path) === requiredPatchRefresh.path
10174
+ safePatchContextEvidencePath(args?.path, state, config) ===
10175
+ requiredPatchRefresh.path
10175
10176
  ) ||
10176
10177
  boundedFailedTestReadPaths.includes(safeRecoveryEvidencePath(args?.path))
10177
10178
  )
@@ -12681,7 +12682,9 @@ function isPrivateVerificationEvidencePath(value = "") {
12681
12682
  }
12682
12683
 
12683
12684
  function isScopedTaskArtifactEvidencePath(value = "", state = {}, config = {}) {
12684
- const artifactRoot = scopedArtifactRoot(completionContractGoal(config, state));
12685
+ const artifactRoot =
12686
+ scopedArtifactRoot(completionContractGoal(config, state)) ||
12687
+ String(config.scopedArtifactRoot || "").trim();
12685
12688
  if (!artifactRoot) return false;
12686
12689
  const raw = String(value || "")
12687
12690
  .trim()
@@ -12700,6 +12703,41 @@ function isScopedTaskArtifactEvidencePath(value = "", state = {}, config = {}) {
12700
12703
  );
12701
12704
  }
12702
12705
 
12706
+ function safePatchContextEvidencePath(value = "", state = {}, config = {}) {
12707
+ const sourcePath = safeRecoveryEvidencePath(value);
12708
+ if (sourcePath) return sourcePath;
12709
+
12710
+ const raw = String(value || "")
12711
+ .trim()
12712
+ .replace(/^["']|["']$/g, "")
12713
+ .replace(/\\/g, "/");
12714
+ if (
12715
+ !raw ||
12716
+ raw.includes("\0") ||
12717
+ /^https?:\/\//i.test(raw) ||
12718
+ /(?:secret|credential|password|private[-_]?key|access[-_]?token)/i.test(raw)
12719
+ ) {
12720
+ return "";
12721
+ }
12722
+ const commandCwd = path.resolve(
12723
+ config.commandCwd || state.commandCwd || process.cwd()
12724
+ );
12725
+ const absolutePath = path.isAbsolute(raw)
12726
+ ? path.resolve(raw)
12727
+ : path.resolve(commandCwd, raw);
12728
+ const relativePath = path.relative(commandCwd, absolutePath).replace(/\\/g, "/");
12729
+ if (
12730
+ !relativePath ||
12731
+ relativePath.startsWith("..") ||
12732
+ path.isAbsolute(relativePath) ||
12733
+ !PLAIN_TEXT_FILE_EXTENSIONS.has(path.extname(relativePath).toLowerCase()) ||
12734
+ !isScopedTaskArtifactEvidencePath(raw, state, config)
12735
+ ) {
12736
+ return "";
12737
+ }
12738
+ return relativePath;
12739
+ }
12740
+
12703
12741
  function commandWritesOnlyEvidenceMatching(command = "", pathMatches = () => false) {
12704
12742
  const normalized = String(command || "").trim();
12705
12743
  if (!normalized) return false;
@@ -17610,10 +17648,11 @@ function validatedPatchContextCompleteSource(marker = {}) {
17610
17648
 
17611
17649
  export function activePatchContextRefresh(state = {}) {
17612
17650
  const marker = state.meta?.toolLoop?.patchContextRequired;
17651
+ const markerPath = safePatchContextEvidencePath(marker?.path, state);
17613
17652
  if (
17614
17653
  !marker ||
17615
17654
  Number(marker.version || 0) !== PATCH_CONTEXT_REFRESH_VERSION ||
17616
- !safeRecoveryEvidencePath(marker.path)
17655
+ !markerPath
17617
17656
  ) {
17618
17657
  return null;
17619
17658
  }
@@ -17644,16 +17683,17 @@ export function activePatchContextRefresh(state = {}) {
17644
17683
  }
17645
17684
  return {
17646
17685
  ...marker,
17647
- path: safeRecoveryEvidencePath(marker.path),
17686
+ path: markerPath,
17648
17687
  };
17649
17688
  }
17650
17689
 
17651
17690
  export function activePatchContextRepair(state = {}) {
17652
17691
  const marker = state.meta?.toolLoop?.patchContextRepair;
17692
+ const markerPath = safePatchContextEvidencePath(marker?.path, state);
17653
17693
  if (
17654
17694
  !marker ||
17655
17695
  Number(marker.version || 0) !== PATCH_CONTEXT_REPAIR_VERSION ||
17656
- !safeRecoveryEvidencePath(marker.path) ||
17696
+ !markerPath ||
17657
17697
  !String(marker.search || "") ||
17658
17698
  !String(marker.searchHash || "")
17659
17699
  ) {
@@ -17694,8 +17734,7 @@ export function activePatchContextRepair(state = {}) {
17694
17734
  const samePathFocuses = diagnosticMatchesRevision
17695
17735
  ? (Array.isArray(diagnostic.focuses) ? diagnostic.focuses : []).filter(
17696
17736
  (focus) =>
17697
- safeRecoveryEvidencePath(focus?.path) ===
17698
- safeRecoveryEvidencePath(marker.path) &&
17737
+ safePatchContextEvidencePath(focus?.path, state) === markerPath &&
17699
17738
  String(focus?.directSearch || "")
17700
17739
  )
17701
17740
  : [];
@@ -17712,7 +17751,7 @@ export function activePatchContextRepair(state = {}) {
17712
17751
  const completeSource = validatedPatchContextCompleteSource(marker);
17713
17752
  return {
17714
17753
  ...marker,
17715
- path: safeRecoveryEvidencePath(marker.path),
17754
+ path: markerPath,
17716
17755
  completeSource,
17717
17756
  completeSourceHash: completeSource ? String(marker.completeSourceHash || "") : "",
17718
17757
  completeSourceBytes: completeSource
@@ -18072,7 +18111,7 @@ function failedTestTracebackLineAnchor(state = {}, targetPath = "") {
18072
18111
  export function bindPatchContextRepairArguments(state = {}, requestedArgs = {}) {
18073
18112
  const marker = activePatchContextRepair(state);
18074
18113
  if (!marker || typeof requestedArgs?.replace !== "string") return null;
18075
- const requestedPath = safeRecoveryEvidencePath(requestedArgs.path);
18114
+ const requestedPath = safePatchContextEvidencePath(requestedArgs.path, state);
18076
18115
  if (requestedPath && requestedPath !== marker.path) return null;
18077
18116
  const requestedSearch = String(requestedArgs.search || "");
18078
18117
  const boundedSubrange = revisionBoundRequestedPatchSubrange(
@@ -18164,7 +18203,7 @@ export function bindPatchContextRepairArguments(state = {}, requestedArgs = {})
18164
18203
  }
18165
18204
 
18166
18205
  export function patchContextScopeMismatchAttemptCount(state = {}, targetPath = "") {
18167
- const normalizedPath = safeRecoveryEvidencePath(targetPath);
18206
+ const normalizedPath = safePatchContextEvidencePath(targetPath, state);
18168
18207
  if (!normalizedPath) return 0;
18169
18208
  const toolLoop = state.meta?.toolLoop || {};
18170
18209
  const stagnationEpoch = Math.max(0, Number(toolLoop.stagnationEpoch || 0));
@@ -18178,7 +18217,7 @@ export function patchContextScopeMismatchAttemptCount(state = {}, targetPath = "
18178
18217
  entry?.toolName !== "apply_patch" ||
18179
18218
  entry?.ok !== false ||
18180
18219
  entry?.category !== "patch-context-scope-mismatch" ||
18181
- safeRecoveryEvidencePath(entry?.path) !== normalizedPath ||
18220
+ safePatchContextEvidencePath(entry?.path, state) !== normalizedPath ||
18182
18221
  Number(entry?.stagnationEpoch || 0) !== stagnationEpoch
18183
18222
  ) {
18184
18223
  return false;
@@ -18259,7 +18298,7 @@ export function patchContextRefreshDecision(state = {}, toolResult = {}) {
18259
18298
  const recent = Array.isArray(toolLoop.recent) ? toolLoop.recent : [];
18260
18299
  const samePathRecent = recent.filter(
18261
18300
  (entry) =>
18262
- safeRecoveryEvidencePath(entry?.path) === targetPath &&
18301
+ safePatchContextEvidencePath(entry?.path, state) === targetPath &&
18263
18302
  Number(entry?.stagnationEpoch || 0) === stagnationEpoch
18264
18303
  );
18265
18304
  const priorMissingSearches = samePathRecent.filter(
@@ -18570,7 +18609,8 @@ export function consumePatchContextRepairMutation(state = {}, toolResult = {}) {
18570
18609
  String(toolResult.toolName || "") !== "apply_patch" ||
18571
18610
  toolResult.ok === false ||
18572
18611
  toolResult.blocked === true ||
18573
- toolResultWorkspacePath(toolResult) !== safeRecoveryEvidencePath(marker.path) ||
18612
+ toolResultWorkspacePath(toolResult) !==
18613
+ safePatchContextEvidencePath(marker.path, state) ||
18574
18614
  ![
18575
18615
  String(marker.searchHash || ""),
18576
18616
  String(marker.lastBoundSearchHash || ""),
@@ -24211,11 +24251,13 @@ export function recoverRequiredPatchContextReadWithoutToolCall(
24211
24251
  const selectedFailedTestReadMode = Boolean(
24212
24252
  !refreshMode && !repairMode && !selectedFailedTestDiagnosticReadMode && failedTestReadMode
24213
24253
  );
24254
+ const patchContextPath = (value) =>
24255
+ safePatchContextEvidencePath(value, {}, config);
24214
24256
  const exactPath = selectedFailedTestDiagnosticReadMode
24215
24257
  ? safeGeneratedDiagnosticEvidencePath(
24216
24258
  config.testFailureWorkspaceDiagnosticReadPaths?.[0]
24217
24259
  )
24218
- : safeRecoveryEvidencePath(
24260
+ : (refreshMode || repairMode ? patchContextPath : safeRecoveryEvidencePath)(
24219
24261
  refreshMode
24220
24262
  ? config.patchContextRefreshPath
24221
24263
  : repairMode
@@ -24226,7 +24268,9 @@ export function recoverRequiredPatchContextReadWithoutToolCall(
24226
24268
  const requestedCall = calls.length === 1 ? calls[0] : null;
24227
24269
  const requestedToolName = String(requestedCall?.function?.name || "");
24228
24270
  const requestedArgs = safeParseToolArgs(requestedCall);
24229
- const requestedPath = safeRecoveryEvidencePath(requestedArgs.path);
24271
+ const requestedPath = (refreshMode || repairMode
24272
+ ? patchContextPath
24273
+ : safeRecoveryEvidencePath)(requestedArgs.path);
24230
24274
  const missingRefreshCall = validation?.ok === true && calls.length === 0 && refreshMode;
24231
24275
  const unavailableContextCall =
24232
24276
  validation?.ok !== true &&
@@ -24295,7 +24339,9 @@ export function recoverRequiredPatchContextReadWithoutToolCall(
24295
24339
  readDescriptor.function?.parameters?.properties?.path?.enum;
24296
24340
  const normalizeAllowedPath = selectedFailedTestDiagnosticReadMode
24297
24341
  ? safeGeneratedDiagnosticEvidencePath
24298
- : safeRecoveryEvidencePath;
24342
+ : refreshMode || repairMode
24343
+ ? patchContextPath
24344
+ : safeRecoveryEvidencePath;
24299
24345
  if (
24300
24346
  !Array.isArray(allowedPaths) ||
24301
24347
  (!selectedFailedTestReadMode && !selectedFailedTestDiagnosticReadMode && allowedPaths.length !== 1) ||