Skip to content

feat: codex-quality fallback robustness (partial-failure recovery, fuzz tracking, atomic writes)#8

Merged
code-yeongyu merged 15 commits into
mainfrom
feat/codex-fallback-completeness
May 10, 2026
Merged

feat: codex-quality fallback robustness (partial-failure recovery, fuzz tracking, atomic writes)#8
code-yeongyu merged 15 commits into
mainfrom
feat/codex-fallback-completeness

Conversation

@code-yeongyu
Copy link
Copy Markdown
Owner

@code-yeongyu code-yeongyu commented May 10, 2026

Summary

Atomic TDD commits implementing runtime robustness in split steps:

  1. Partial-failure data model (ApplyPatchResult, ApplyPatchFailure, ApplyPatchError)
  2. mustReadFiles / mustNotReadFiles recovery instructions for the LLM
  3. Fuzz tier tracking (0 / 1 / 100 / 10000) aggregated through result.details.fuzz
  4. Partial-failure tool recovery messaging while preserving compat API fail-fast behavior

Backward compatibility

  • Wire format unchanged: tool name, description, Lark grammar, parameters schema remain canonical
  • applyPatch(cwd, patchText): Promise<string[]> signature unchanged
  • applyPatch retains fail-fast semantics: first hunk failure aborts processing, no later hunks attempted
  • New applyPatchDetailed(cwd, patchText): Promise<ApplyPatchResult> is additive and used for accumulation/recovery

Commits

  • fe29036 test: cover tool recovery message for partial applyPatchDetailed failure
  • 0ceb2b7 feat: aggregate fuzz across hunks into result.details.fuzz
  • 2db695e feat: extend seekSequence to return {index, fuzz} tuple
  • bc2e43c test: cover seekSequence returning fuzz tier 0/1/100/10000
  • 3304b89 refactor: keep legacy applyPatch fail-fast semantics
  • 21dfaed test: cover applyPatch retains fail-fast on first hunk failure
  • f378f0b feat: route tool execute() through applyPatchDetailed for partial-failure recovery message
  • e773710 feat: build mustReadFiles/mustNotReadFiles in createRecoveryInstructions
  • b13ce15 feat: implement applyPatchDetailed with failure accumulation
  • 8c4ba20 feat: introduce ApplyPatchResult, ApplyPatchFailure, ApplyPatchRecoveryInstructions types and ApplyPatchError class
  • 18fd0b9 test: cover applyPatchDetailed accumulates per-hunk failures

Tests

  • Added 4 test commits for detailed accumulation, fail-fast compatibility, fuzz tiers, and tool recovery text
  • npm run check clean
  • npm test all green

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 2 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/index.ts">

<violation number="1" location="src/index.ts:689">
P2: Failure output is always labeled as a partial failure, so full failures receive misleading recovery instructions.</violation>

<violation number="2" location="src/index.ts:761">
P1: `hasPartialSuccess` is computed from summaries, which can miss side effects from a failed move hunk after the destination write succeeds.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread src/index.ts Outdated
Comment thread src/index.ts Outdated
Comment on lines +689 to +695
return [
"apply_patch partially failed.",
`Failed: ${failedFiles.join(", ")}`,
`Recovery: MUST read ${failedFiles.join(" and ")} before retrying.`,
"Earlier file actions in this patch were already applied.",
"Recovery: MUST NOT reread other files from this patch unless a specific dependency requires it.",
].join("\n");
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Failure output is always labeled as a partial failure, so full failures receive misleading recovery instructions.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/index.ts, line 689:

<comment>Failure output is always labeled as a partial failure, so full failures receive misleading recovery instructions.</comment>

<file context>
@@ -559,64 +654,122 @@ function replaceChunks(content: string, filePath: string, chunks: PatchChunk[]):
+	if (failedFiles.length === 0) {
+		return result.summaries.join("\n");
+	}
+	return [
+		"apply_patch partially failed.",
+		`Failed: ${failedFiles.join(", ")}`,
</file context>
Suggested change
return [
"apply_patch partially failed.",
`Failed: ${failedFiles.join(", ")}`,
`Recovery: MUST read ${failedFiles.join(" and ")} before retrying.`,
"Earlier file actions in this patch were already applied.",
"Recovery: MUST NOT reread other files from this patch unless a specific dependency requires it.",
].join("\n");
if (!result.hasPartialSuccess) {
return ["apply_patch failed.", `Failed: ${failedFiles.join(", ")}`].join("\n");
}
return [
"apply_patch partially failed.",
`Failed: ${failedFiles.join(", ")}`,
`Recovery: MUST read ${failedFiles.join(" and ")} before retrying.`,
"Earlier file actions in this patch were already applied.",
"Recovery: MUST NOT reread other files from this patch unless a specific dependency requires it.",
].join("\n");

@code-yeongyu code-yeongyu force-pushed the feat/codex-fallback-completeness branch from 5c7f91f to 8615655 Compare May 10, 2026 04:46
@code-yeongyu code-yeongyu force-pushed the feat/codex-fallback-completeness branch from 8615655 to fe29036 Compare May 10, 2026 05:12
@code-yeongyu code-yeongyu merged commit 84e08d6 into main May 10, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant