Skip to content

fix(gate): evidence-incomplete no longer hard-blocks task completion when session state confirms gates passed#780

Merged
zaxbysauce merged 5 commits intomainfrom
copilot/fix-gate-system-plan-update
May 7, 2026
Merged

fix(gate): evidence-incomplete no longer hard-blocks task completion when session state confirms gates passed#780
zaxbysauce merged 5 commits intomainfrom
copilot/fix-gate-system-plan-update

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 6, 2026

update_task_status("in_progress") always creates .swarm/evidence/<task>.json with gates: {}. If evidence recording in the delegation hook subsequently fails silently (lock timeout, permission error), the gates stay empty on disk — causing checkReviewerGate to return blocked: true permanently, even though the in-memory session state was correctly advanced to tests_run by the same hook.

Root cause

checkReviewerGate treated an evidence file with incomplete gates as immediately authoritative, returning blocked without consulting session state, delegation chains, or plan.json:

// Before: hard block, all fallbacks skipped
if (!allGatesMet) {
  return { blocked: true, reason: `...missing gates...` };
}

// After: save reason, fall through to the same fallbacks used for ENOENT
evidenceIncompleteReason = `Task ${taskId} is missing required gates: [${missingGates.join(', ')}]...`;
// falls through to session state → plan.json → delegation chain checks

State advancement (in-memory) and evidence recording are independent operations in the toolAfter hook — state advances first and always; evidence write can fail silently. The fix aligns the incomplete-evidence path with the existing ENOENT path: session state and delegation chains become the authority when evidence is untrustworthy.

Changes

  • src/tools/update-task-status.tscheckReviewerGate: incomplete evidence saves the specific missing-gates reason and falls through to all existing session-state / delegation-chain fallbacks; the evidence reason is used in the final blocked return (more informative than the generic session message)
  • src/hooks/delegation-gate.ts — replace /^\d+\.\d+$/ (two occurrences) with isStrictTaskId(), which correctly accepts N.M.P format task IDs
  • src/tools/update-task-status.gates.test.ts — three new regression tests: gates:{} + tests_run → pass, gates:{} + idle → block (with gate names), partial gates + tests_run → pass

Copilot AI linked an issue May 6, 2026 that may be closed by this pull request
… gates

When update_task_status("in_progress") creates the evidence file with
gates:{}, a silent evidence recording failure in the delegation hook
would leave gates empty. checkReviewerGate was returning blocked:true
immediately based on the empty evidence file, without consulting the
in-memory session state which the delegation hook correctly advances
to tests_run independently of evidence recording.

Fix: save the evidence-incomplete reason and fall through to the full
session-state / delegation-chain fallback stack. Only block after all
fallbacks are exhausted, using the evidence-specific reason for its
more informative "missing gates: [X]" message.

Also fix the /^\d+\.\d+$/ regex in delegation-gate.ts (two places) to
use isStrictTaskId() which correctly accepts N.M.P format task IDs.

Agent-Logs-Url: https://github.com/zaxbysauce/opencode-swarm/sessions/2dd206a5-05d3-4aeb-94c2-e4be628a03b1

Co-authored-by: zaxbysauce <10211642+zaxbysauce@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix not updating plan issue in gate system fix(gate): evidence-incomplete no longer hard-blocks task completion when session state confirms gates passed May 6, 2026
Copilot AI requested a review from zaxbysauce May 6, 2026 23:11
@zaxbysauce zaxbysauce marked this pull request as ready for review May 7, 2026 16:08
@zaxbysauce zaxbysauce merged commit 7d7d3e1 into main May 7, 2026
12 checks passed
@zaxbysauce zaxbysauce deleted the copilot/fix-gate-system-plan-update branch May 7, 2026 16:08
This was referenced May 7, 2026
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.

[Bug] Not updating plan anymore - Gate system

2 participants