Skip to content

fix(gsd): retry empty complete-slice runs#3410

Closed
mastertyko wants to merge 10 commits intogsd-build:mainfrom
mastertyko:fix/2653-complete-slice-exhaustion-guard
Closed

fix(gsd): retry empty complete-slice runs#3410
mastertyko wants to merge 10 commits intogsd-build:mainfrom
mastertyko:fix/2653-complete-slice-exhaustion-guard

Conversation

@mastertyko
Copy link
Copy Markdown
Contributor

TL;DR

What: Treat empty complete-slice runs as retryable failures instead of successful completions.
Why: Context-exhausted complete-slice units could do zero successful tool calls, leave the slice pending, and block all downstream work.
How: Extend the existing zero-tool-call guard to complete-slice and add a regression that proves the loop retries instead of silently advancing.

What

This change extends the auto-loop's empty-tool-call protection so it also covers complete-slice units.

It updates src/resources/extensions/gsd/auto/phases.ts and adds regression coverage in src/resources/extensions/gsd/tests/auto-loop.test.ts.

Why

A context-exhausted complete-slice unit could finish with zero successful tool calls, leave the DB slice status unchanged, and then cycle through verification and dispatch without ever closing the slice. That silently blocks all dependent slices downstream.

Closes #2653

This PR is stacked on #3365.

How

  • Reuse the existing zero-tool-call retry logic for complete-slice, not just execute-task.
  • Keep the failure mode retry-oriented so the loop can recover in a fresh context instead of treating the run as success.
  • Add a regression test that simulates a zero-tool-call complete-slice iteration and verifies that the loop retries before succeeding.

Change type

  • fix — Bug fix
  • feat — New feature or capability
  • refactor — Code restructuring (no behavior change)
  • test — Adding or updating tests
  • docs — Documentation only
  • chore — Build, CI, or tooling changes

Scope

  • pi-tui — Terminal UI
  • pi-ai — AI/LLM layer
  • pi-agent-core — Agent orchestration
  • pi-coding-agent — Coding agent
  • gsd extension — GSD workflow
  • native — Native bindings
  • ci/build — Workflows, scripts, config

Breaking changes

  • No breaking changes
  • Yes — described above

Test plan

  • CI passes
  • New/updated tests included
  • Manual testing — steps described above
  • No tests needed — explained above

Verified locally with the full CI mirror gate:
npm run build
npm run typecheck:extensions
npm run test:unit
npm run test:integration

Targeted regression:
node --import ./src/resources/extensions/gsd/tests/resolve-ts.mjs --experimental-strip-types --test src/resources/extensions/gsd/tests/auto-loop.test.ts

AI disclosure

  • This PR includes AI-assisted code

This PR includes AI-assisted code — prepared with Codex and verified as described in the test plan above.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 1, 2026

🔴 PR Risk Report — CRITICAL

Files changed 12
Systems affected 4
Overall risk 🔴 CRITICAL

Affected Systems

Risk System
🔴 critical Auto Engine
🔴 critical State Machine
🟡 medium Async Jobs
🟡 medium Worktree
File Breakdown
Risk File Systems
🟡 src/resources/extensions/async-jobs/job-manager.ts Async Jobs
🔴 src/resources/extensions/gsd/auto-worktree.ts Auto Engine, Worktree
🔴 src/resources/extensions/gsd/auto/phases.ts Auto Engine
🔴 src/resources/extensions/gsd/state.ts State Machine
🟡 src/resources/extensions/gsd/worktree-manager.ts Worktree
src/resources/extensions/async-jobs/await-tool.test.ts (unclassified)
src/resources/extensions/gsd/tests/auto-loop.test.ts (unclassified)
src/resources/extensions/gsd/tests/worktree-manager.test.ts (unclassified)
src/resources/extensions/gsd/tests/worktree-teardown-safety.test.ts (unclassified)
src/rtk.ts (unclassified)
src/tests/integration/pack-install.test.ts (unclassified)
src/tests/rtk.test.ts (unclassified)

⚠️ Critical risk — please verify: state persistence, auth token lifecycle, agent loop race conditions, RPC protocol compatibility.

@jeremymcs
Copy link
Copy Markdown
Collaborator

This PR has merge conflicts with the base branch. Please rebase or merge main to resolve before review can proceed.

🤖 Automated PR audit — 2026-04-04

@mastertyko mastertyko force-pushed the fix/2653-complete-slice-exhaustion-guard branch from 12cbbae to 2b53857 Compare April 6, 2026 17:28
@mastertyko
Copy link
Copy Markdown
Contributor Author

@jeremymcs Refreshed this PR onto the current main, reran the full local gate (npm run build, npm run typecheck:extensions, npm run test:unit, npm run test:integration), and pushed the updated branch. GitHub checks are green now.

@mastertyko
Copy link
Copy Markdown
Contributor Author

Closing this in favor of #3300, which is the version that landed for this issue.

@mastertyko mastertyko closed this Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working High Priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

complete-slice unit silently fails on context exhaustion, blocks all downstream slices

2 participants