Files
Redflag/docs/B2_PreFix_Tests.md
jpetree331 59ab7cbd5f test(concurrency): B-2 pre-fix tests for data integrity and concurrency bugs
Pre-fix test suite documenting 7 data integrity and concurrency
bugs. Tests FAIL where they assert correct post-fix behavior,
PASS where they document current buggy state.

Tests added:
- F-B2-1/8 HIGH: Registration not transactional (3 tests)
- F-B2-2 MEDIUM: Command delivery race condition (3 tests)
- F-B2-9 MEDIUM: Token renewal not transactional (2 tests)
- F-B2-4 MEDIUM: No rate limit on GetCommands (3 tests)
- F-B2-5 LOW: Jitter negates rapid mode (2 tests)
- F-B2-10 LOW: No max retry for stuck commands (2 tests)
- F-B2-7 MEDIUM: No exponential backoff on reconnection (2 tests)

Current state: 7 FAIL, 10 PASS. No A/B-1 regressions.
See docs/B2_PreFix_Tests.md for full inventory.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 07:45:16 -04:00

55 lines
2.5 KiB
Markdown

# B-2 Pre-Fix Test Suite
**Date:** 2026-03-29
**Branch:** culurien
**Purpose:** Document data integrity and concurrency bugs BEFORE fixes.
**Reference:** docs/B2_Data_Integrity_Audit.md
---
## Test Files Created
| File | Package | Bugs Documented |
|------|---------|-----------------|
| `server/internal/api/handlers/registration_transaction_test.go` | `handlers_test` | F-B2-1, F-B2-8 |
| `server/internal/api/handlers/command_delivery_race_test.go` | `handlers_test` | F-B2-2 |
| `server/internal/api/handlers/token_renewal_transaction_test.go` | `handlers_test` | F-B2-9 |
| `server/internal/api/handlers/rapid_mode_ratelimit_test.go` | `handlers_test` | F-B2-4 |
| `server/internal/database/stuck_command_retry_test.go` | `database_test` | F-B2-10 |
| `agent/internal/polling_jitter_test.go` | `internal_test` | F-B2-5 |
| `agent/internal/reconnect_stagger_test.go` | `internal_test` | F-B2-7 |
---
## State-Change Summary
| Test | Bug | Current | After Fix |
|------|-----|---------|-----------|
| TestRegistrationFlowIsNotTransactional | F-B2-1 | PASS | update |
| TestRegistrationFlowMustBeTransactional | F-B2-1 | **FAIL** | PASS |
| TestRegistrationManualRollbackExists | F-B2-1 | PASS | update |
| TestGetCommandsAndMarkSentNotTransactional | F-B2-2 | PASS | update |
| TestGetCommandsMustBeAtomic | F-B2-2 | **FAIL** | PASS |
| TestSelectForUpdatePatternInGetCommands | F-B2-2 | PASS | update |
| TestTokenRenewalIsNotTransactional | F-B2-9 | PASS | update |
| TestTokenRenewalShouldBeTransactional | F-B2-9 | **FAIL** | PASS |
| TestGetCommandsEndpointHasNoRateLimit | F-B2-4 | PASS | update |
| TestGetCommandsEndpointShouldHaveRateLimit | F-B2-4 | **FAIL** | PASS |
| TestRapidModeHasServerSideMaxDuration | F-B2-4 | PASS | PASS |
| TestJitterExceedsRapidModeInterval | F-B2-5 | PASS | update |
| TestJitterDoesNotExceedPollingInterval | F-B2-5 | **FAIL** | PASS |
| TestStuckCommandHasNoMaxRetryCount | F-B2-10 | PASS | update |
| TestStuckCommandHasMaxRetryCount | F-B2-10 | **FAIL** | PASS |
| TestReconnectionUsesFixedJitterOnly | F-B2-7 | PASS | update |
| TestReconnectionUsesExponentialBackoffWithJitter | F-B2-7 | **FAIL** | PASS |
**7 FAIL** (assert post-fix behavior), **10 PASS** (document current state).
---
## Notes
1. All tests are static source inspection — no live database required.
2. All A-series and B-1 tests continue to pass (no regressions).
3. Agent tests in `internal/` package avoid the pre-existing build failures in `migration/pathutils` and `migration/validation` packages.