Skip to content

feat: add three-layer swarm command conflict prevention system#744

Merged
zaxbysauce merged 5 commits intomainfrom
conflict-prevention
May 3, 2026
Merged

feat: add three-layer swarm command conflict prevention system#744
zaxbysauce merged 5 commits intomainfrom
conflict-prevention

Conversation

@zaxbysauce
Copy link
Copy Markdown
Owner

@zaxbysauce zaxbysauce commented May 3, 2026

Summary

  • Three-layer defense preventing Claude Code command confusion inside swarm agent sessions
  • Layer 1 (Conflict Registry): Pure data module with 9 command conflict entries, CI gate with ratchet mechanism, clashesWithNativeCcCommand field on CommandEntry, frozen ReadonlySet of 105 CC built-in commands
  • Layer 2 (Prompt Hardening): COMMAND NAMESPACE blocks in all 4 agent prompts, skill files, session contract, and commands documentation
  • Layer 3 (Runtime Intercept): Message pipeline hook that hard-blocks /reset/clear, soft-corrects /plan, logs HIGH advisories — 45 tests (23 unit + 22 adversarial), under 5ms design target

Test plan

  • bun run typecheck — clean
  • bunx biome ci . — clean
  • 109 tests pass across 6 new/modified test files
  • 22 adversarial tests cover 8 attack vectors (case variation, whitespace, code fences, URLs, comments, multi-command, corrected-form bypass, case evasion)

Invariant audit

  • 1 (plugin init): not touched
  • 2 (runtime portability): not touched
  • 3 (subprocesses): not touched
  • 4 (.swarm containment): not touched
  • 5 (plan durability): not touched
  • 6 (test_runner safety): not touched — all test runs use explicit file paths, no broad scopes
  • 7 (test writing): touched — tests follow bun:test patterns, mock.module not used
  • 8 (session state): not touched
  • 9 (guardrails/retry): not touched
  • 10 (chat/system msg): touched — cc-command-intercept hook operates on messages.transform chain
  • 11 (tool registration): not touched
  • 12 (release/cache): not touched

Pre-existing failures

  • 148 test failures in tests/unit/commands/ (resolveCommand returning undefined for some keys) and tests/unit/config/ (project-init timing) predate this PR — verified against origin/main

@zaxbysauce zaxbysauce force-pushed the conflict-prevention branch 2 times, most recently from ae12bd3 to 5dcf9aa Compare May 3, 2026 15:03
@zaxbysauce zaxbysauce force-pushed the conflict-prevention branch from 5dcf9aa to 522e67c Compare May 3, 2026 15:24
Your Name added 4 commits May 3, 2026 10:49
…t test coverage

- Replace tautological assertion that never fails with meaningful checks
- Add adversarial tests for /checkpoint: inside-fence preservation and HIGH advisory fallback
- Document /checkpoint gap in test comments (see GitHub issue #745)
@zaxbysauce zaxbysauce merged commit 563f314 into main May 3, 2026
12 checks passed
@zaxbysauce zaxbysauce deleted the conflict-prevention branch May 3, 2026 16:39
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