feat(conflict-resolution): add conflict resolution mechanisms (Issue #414)#433
Merged
zaxbysauce merged 8 commits intomainfrom Apr 8, 2026
Merged
feat(conflict-resolution): add conflict resolution mechanisms (Issue #414)#433zaxbysauce merged 8 commits intomainfrom
zaxbysauce merged 8 commits intomainfrom
Conversation
…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
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AgentConflictDetectedEventandAuthorityHandoffResolvedEventtosrc/types/events.ts(both included inV619Eventunion)src/hooks/conflict-resolution.tswithresolveAgentConflict()— centralized advisory injection and telemetry emission for agent-vs-agent conflictsREJECTION_SPIRALadversarial pattern tosrc/hooks/adversarial-detector.ts(HIGH severity, detects stuck reject/resubmit pipelines without false-positiving on neutral process language)DelegationReasontype,lastDelegationReason?session field,SoundingBoardVerdict/SoundingBoardResponse/parseSoundingBoardResponsetosrc/agents/critic.tsTest plan
bun run typecheck— zero errorsconflict-resolution.test.ts,sounding-board-parser.test.ts, REJECTION_SPIRAL block insecurity-adversarial.test.ts— all passtests/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)