Skip to content

feat(ci): add test count guard to prevent AI agents from deleting tests#642

Closed
diberry wants to merge 1 commit intobradygaster:devfrom
diberry:squad/39-test-integrity-guards
Closed

feat(ci): add test count guard to prevent AI agents from deleting tests#642
diberry wants to merge 1 commit intobradygaster:devfrom
diberry:squad/39-test-integrity-guards

Conversation

@diberry
Copy link
Copy Markdown
Collaborator

@diberry diberry commented Mar 26, 2026

CI guard script that compares actual test count against a baseline, blocking PRs that reduce test count. Prevents AI agents from deleting tests to make failing code pass.

  • test-count-guard.mjs with --from-json support (no double test run)
  • test-baseline.json (4,662 tests) with _instructions field
  • copilot-instructions.md test integrity directive
  • 11 tests covering all guard paths + edge cases
  • Workflow uses if: success() || failure() (skips on cancellation)

Team review: Flight ✅, FIDO ✅, Procedures ✅

Closes diberry#39

Adds a CI step that compares the current test count against a baseline
stored in .github/test-baseline.json. PRs that reduce the test count
below baseline are rejected.

Also updates copilot-instructions.md with explicit 'never delete tests'
directive for @copilot and other AI agents.

Closes #39

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@diberry
Copy link
Copy Markdown
Collaborator Author

diberry commented Mar 26, 2026

@bradygaster Ready for your review — team-approved with 3-reviewer gate (Flight, FIDO, Procedures).

larsontim12 pushed a commit to larsontim12/squad that referenced this pull request Mar 27, 2026
bradygaster#642)

* fix: dedup concurrent connect() calls in SquadClient

When the REPL starts with .init-prompt and an empty roster, eager
session warm-up and auto-cast race to call connect(). The second
call hit state=connecting and threw 'Connection already in progress'.

Replace the throwing guard with a connection promise dedup pattern:
concurrent callers now share the same in-flight promise instead of
crashing. connectPromise is cleared on completion and in disconnect/
forceDisconnect for clean state reset.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* test: add concurrent connect() dedup tests

Update adapter-client tests for the new connect() dedup behavior.
Replace the old 'throws on concurrent connect' test with tests that
verify concurrent callers share the same promise: both resolve on
success, both reject on failure, and fresh connect works after failure.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* chore: merge connect dedup decision into decisions.md

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@diberry
Copy link
Copy Markdown
Collaborator Author

diberry commented Mar 27, 2026

Closing as duplicate — Brady merged the same goal (test deletion guard) in #634 (source tree canary).

@diberry diberry closed this Mar 27, 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.

feat: Prevent AI agents from deleting/weakening tests to pass CI

2 participants