Skip to content

feat(conflict-resolution): add conflict resolution mechanisms (Issue #414)#433

Merged
zaxbysauce merged 8 commits intomainfrom
claude/implement-swarm-NuzcJ
Apr 8, 2026
Merged

feat(conflict-resolution): add conflict resolution mechanisms (Issue #414)#433
zaxbysauce merged 8 commits intomainfrom
claude/implement-swarm-NuzcJ

Conversation

@zaxbysauce
Copy link
Copy Markdown
Owner

Summary

  • Add AgentConflictDetectedEvent and AuthorityHandoffResolvedEvent to src/types/events.ts (both included in V619Event union)
  • Create src/hooks/conflict-resolution.ts with resolveAgentConflict() — centralized advisory injection and telemetry emission for agent-vs-agent conflicts
  • Add REJECTION_SPIRAL adversarial pattern to src/hooks/adversarial-detector.ts (HIGH severity, detects stuck reject/resubmit pipelines without false-positiving on neutral process language)
  • Add DelegationReason type, lastDelegationReason? session field, SoundingBoardVerdict/SoundingBoardResponse/parseSoundingBoardResponse to src/agents/critic.ts

Test plan

  • bun run typecheck — zero errors
  • New tests: 15 across conflict-resolution.test.ts, sounding-board-parser.test.ts, REJECTION_SPIRAL block in security-adversarial.test.ts — all pass
  • Smoke tests: 10/10 pass
  • Pre-existing failures in tests/unit/hooks (2094), tests/unit/agents/critic.adversarial.test.ts (1), tests/unit/agents/factory.test.ts (6), tests/security/tests/adversarial (20) confirmed identical on baseline (stash-verified — not introduced by this PR)
  • Independent reviewer confirmed all 8 implementation claims; independent critic pass addressed 3 valid findings (false-positive REJECTION_SPIRAL pattern, import path inconsistency, multiline parser regex)

claude added 3 commits April 7, 2026 23:38
…414)

Four targeted additive additions from the Conflict Resolution Mechanisms audit:

1. src/types/events.ts — Add AgentConflictDetectedEvent and
   AuthorityHandoffResolvedEvent interfaces; include both in V619Event union.

2. src/hooks/conflict-resolution.ts — New file. Exports resolveAgentConflict()
   which injects advisory messages into pendingAdvisoryMessages and emits
   agent_conflict_detected telemetry (fire-and-forget cast, no union widening).

3. src/hooks/adversarial-detector.ts — Add REJECTION_SPIRAL pattern group and
   detection block; add 'REJECTION_SPIRAL' to AdversarialPatternMatch.pattern union.

4. src/agents/critic.ts — Export SoundingBoardVerdict, SoundingBoardResponse,
   and parseSoundingBoardResponse (regex-based parser for sounding board output).

5. src/state.ts — Export DelegationReason type; add lastDelegationReason?
   to AgentSessionState after delegationActive.

6. src/hooks/delegation-tracker.ts — Re-export DelegationReason from state.js;
   set session.lastDelegationReason = 'normal_delegation' on non-architect activation.

Tests: 15 new tests across conflict-resolution, sounding-board-parser, and
REJECTION_SPIRAL adversarial detection. All pass. Zero new type errors.
Pre-existing failures are unrelated to this change (confirmed by stash test).

https://claude.ai/code/session_01UwWitPWor2ZMAX1vroNQ1v
Three fixes from independent critic pass:

- adversarial-detector: Replace overly broad REJECTION_SPIRAL pattern 3
  (`/cycle|loop.*reviewer|rejection|feedback/`) with
  `/stuck|trapped|endless|repeating.*loop|cycle/` to eliminate false
  positives on benign phrases like "our feedback loop for the reviewer".

- delegation-tracker: Standardize re-export path from '../state.js' to
  '../state' to match the existing import style throughout the file.

- critic.ts: Replace `(?=\n[A-Z]|$)` lookahead in improvedQuestion,
  answer, and warning field regexes with explicit section-header
  lookaheads (e.g. `(?=\n(?:Answer|Warning|Verdict)\s*:|$)`) so that
  multiline field values are not truncated at the first uppercase letter.

Critic findings NOT actioned:
- A1 (telemetry cast): Plan explicitly prohibits adding 'agent_conflict_detected'
  to TelemetryEvent. Cast is intentional deferral; rejected.
- C2 (lastDelegationReason not cleared on reset): lastDelegationReason?
  records the last non-architect activation reason. Retaining its value
  when the architect resets is semantically correct per field semantics.

https://claude.ai/code/session_01UwWitPWor2ZMAX1vroNQ1v
- docs/releases/v6.55.0.md: release notes for Issue #414 additions
- Apply biome organize-imports and formatting fixes to test files and
  src/agents/critic.ts, src/hooks/conflict-resolution.ts

https://claude.ai/code/session_01UwWitPWor2ZMAX1vroNQ1v
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

claude added 5 commits April 8, 2026 00:10
Updated dist/ outputs from bun run build reflecting:
- src/agents/critic.ts: SoundingBoardVerdict, SoundingBoardResponse, parseSoundingBoardResponse
- src/hooks/adversarial-detector.ts: REJECTION_SPIRAL pattern union addition
- src/hooks/conflict-resolution.ts: new file (new .d.ts)
- src/hooks/delegation-tracker.ts: DelegationReason re-export
- src/state.ts: DelegationReason type, lastDelegationReason field
- src/types/events.ts: AgentConflictDetectedEvent, AuthorityHandoffResolvedEvent

https://claude.ai/code/session_01UwWitPWor2ZMAX1vroNQ1v
Test cases that exercise Windows path handling (e.g. scope-guard adversarial
tests) create directories like C:\/ and \\server\share\ in the repo root as
a side effect. Add them to .gitignore so they don't appear as untracked files.

https://claude.ai/code/session_01UwWitPWor2ZMAX1vroNQ1v
…g-board paths (Issue #414)

Wire Target A (guardrails.ts): call resolveAgentConflict() on every
coder re-delegation (coderRevisions > 1). Derives phase from the
session's reviewerCallCount map, sets sourceAgent=reviewer/targetAgent=coder,
and sets lastDelegationReason='review_rejected'. Escalation threshold
(≥3 rejections → soundingboard) matches the existing circuit-breaker
semantics.

Wire Target B (index.ts): call parseSoundingBoardResponse() on the
critic_sounding_board tool output in the task-handoff block. Injects a
[SOUNDING_BOARD] verdict advisory into pendingAdvisoryMessages and sets
lastDelegationReason='critic_consultation'.

Wire Target C: lastDelegationReason set at both wiring points.

https://claude.ai/code/session_01UwWitPWor2ZMAX1vroNQ1v
…on wiring (Issue #414)

CRITICAL fix (guardrails.ts): Add qaSkipCount === 0 guard to Wire Target A.
Previously, resolveAgentConflict() would fire on QA-skip re-delegations
(first skip is permitted by the gate before throwing on the second), falsely
reporting feedback_rejection conflicts that had no reviewer involvement.
qaSkipCount is reset to 0 by the QA gate when reviewer/test_engineer fires,
so === 0 reliably discriminates reviewer-rejection cycles from QA skips.

HIGH fix (guardrails.ts): Replace stale Math.max(reviewerCallCount.keys())
phase heuristic with async loadPlan() / extractCurrentPhaseFromPlan(), the
same pattern already used earlier in the same function for reviewer tracking.
The old heuristic could return a phase number from a previous task.

MEDIUM fix (index.ts): Add fallback advisory when parseSoundingBoardResponse
returns null (malformed critic output). Previously a silent failure; now
injects a [SOUNDING_BOARD] WARNING advisory so the architect is not left
without guidance.

https://claude.ai/code/session_01UwWitPWor2ZMAX1vroNQ1v
…on, release notes

- conflict-resolution.ts: fix wrong file paths in self-resolve advisory
  (.swarmplan.md/.swarmspec.md/.swarmcontext.md → .swarm/plan.md/.swarm/spec.md/.swarm/context.md)
- guardrails.ts: clarify qaSkipCount reset comment to state the AND condition
  explicitly (requires BOTH reviewer AND test_engineer, not either/or)
- docs/releases/v6.55.0.md: correct AuthorityHandoffResolvedEvent description
  to state it is defined but not yet emitted (not wired in runtime code)

https://claude.ai/code/session_01UwWitPWor2ZMAX1vroNQ1v
@zaxbysauce zaxbysauce merged commit c5759bd into main Apr 8, 2026
13 of 15 checks passed
@zaxbysauce zaxbysauce deleted the claude/implement-swarm-NuzcJ branch April 8, 2026 01:50
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.

2 participants