Ryan Malloy f295c19e06 Fix ACK loss from enumeration detection false-positives
Resolves production issue where legitimate ACK messages were triggering
enumeration detection, causing calls to die at ~64s (Timer H expiry).

### Root Cause:
ACK messages lack dialog-aware fast-path in l4handler.go. All SIP requests
go through the full security pipeline including enumeration detection.

When a client sends multiple ACKs (responding to 200 OK retransmissions),
the enumeration detector sees "rapid fire" extension probing and bans the
source IP.

### The Fix:
Exempt ACK from enumeration detection (l4handler.go:254-258):
- ACK is a mid-dialog request, not an extension probe
- ACKs arrive in response to 200 OK retransmissions (RFC 3261)
- False-positive rapid-fire/sequential detection blocked legitimate traffic

### Impact:
- **For Twilio trunk:** Whitelisting is the operational fix
- **For dynamic IP clients:** This architectural fix enables calls to work
  (residential users, mobile clients, peer-to-peer scenarios)

### Agent Thread Protocol:
Added docs/agent-threads/ for cross-project debugging:
- 001-flextel-ack-being-dropped.md — Problem report from asterpbx agent
- 002-diagnosis-ack-not-fast-pathed.md — Root cause analysis and fix options
- PROTOCOL.md — Agent communication protocol documentation

See: docs/agent-threads/ack-loss-from-twilio-trunk/ for full diagnosis

### Test Results:
All 196 tests passing  (1.213s)
2026-06-22 00:08:25 -06:00

44 lines
890 B
Markdown

# Agent Thread Protocol
Immutable flat-file protocol for agent-to-agent communication.
## Principles
1. **Immutable** - Once written, never modified
2. **Sequential** - Messages numbered in order (001, 002, 003...)
3. **Self-describing** - Metadata header in each message
4. **Human-readable** - Plain markdown
## Message Format
```markdown
# Message {NNN}
| Field | Value |
|-------|-------|
| From | {agent-identifier} |
| To | {agent-identifier} |
| Date | {ISO-8601 timestamp} |
| Re | {brief subject} |
---
{message body}
---
**Next steps for recipient:**
- [ ] {actionable item}
```
## Monitoring for Messages
Watch all threads recursively:
```bash
inotifywait -m -r -e create --format '%w%f' ./docs/agent-threads/ | \
while read filepath; do
echo "📬 New message: $filepath"
glow "$filepath"
done
```
See ~/.claude/CLAUDE.md for full protocol documentation.