Every repo in the loop-eng org follows the same exhaustive, multi-pass engineering process. This document captures the methodology so any future session can replicate it exactly.
- Set up Go module, directory structure, CI, linting, Makefile, goreleaser
- CI matrix: Go 1.24 + Go 1.26, golangci-lint v2 with action@v7
- Git config: local email
rajfirke23@gmail.com, no AI attribution in commits or pushes — all commits under the user's GitHub account - Push to the
loop-engGitHub org
- Build each phase iteratively: write code, review it, test it, fan out agents to check for bugs, fix them, test again
- Use
/god-modefor maximum thoroughness — every phase gets the full treatment - After each phase: build, vet, test, lint before moving on
- README with badges, competitive table, full config reference, architecture diagram
.goreleaser.yamlfor macOS/Linux arm64/amd64 + Homebrew tap- Makefile with ldflags version injection
config initwith O_EXCL atomic create
This is where we differentiate. After implementation is complete, run an exhaustive multi-pass audit:
- Fan out 4 agents in parallel, each covering a different area of the codebase
- Agent 1: Core logic (analyzers, calculators, detectors)
- Agent 2: Parsers + file watchers
- Agent 3: Enforcement + discovery + notifications
- Agent 4: Daemon lifecycle + API + CLI + config
- Each agent reads ALL files in their scope and returns a JSON array of findings with: file, line, severity, description, evidence, fix
- Collect all findings, deduplicate, map to a FINDINGS.md file
- Verify each finding — confirm or dismiss with concrete evidence
- Fix all confirmed bugs
- Fan out an agent focused exclusively on cross-component interactions
- Test the full pipeline: discovery → watcher → parser → analyzer → enforcer
- Look for bugs INTRODUCED by the fixes themselves
- Check shutdown ordering, lock ordering, channel lifecycle
- Race conditions between concurrent goroutines
- Go back and fix every item that was deferred as "not critical"
- Nothing stays unfixed — every confirmed bug gets resolved
- Run the daemon against REAL sessions on the actual machine
- Verify cost tracking, session discovery, timestamp extraction against live data
- Test the resume flow end-to-end
- Malformed inputs: binary garbage, empty files, 2MB lines, partial JSON
- Config edge cases: negative values, zero values, huge values
- Rapid start/stop cycles (5x in quick succession)
- Concurrent session creation (3-5 simultaneous)
- No panics, no crashes, no data loss
- Test actual SIGSTOP/SIGCONT on a real running process
- Verify the process state changes to T (stopped)
- Verify SIGCONT resumes the process
- Verify LTF trace files and history.jsonl are written correctly
- Test process group safety (daemon must not SIGSTOP itself)
- Every parser path (not just the primary one)
- Every CLI command with edge cases (no args, wrong args, daemon offline)
- Stale socket recovery
- Dual daemon prevention
- Any code path that hasn't been exercised yet
- Fix literally everything — even "plausible but unverified" items
- Read real session data to fix lossy encodings
- Fix platform-specific escaping issues
- Install and run golangci-lint locally (catches things go vet misses)
- staticcheck, unused, errcheck — fix all findings
- This often catches 2-3 real issues that static review missed
- Write Go integration tests that exercise the internal pipeline in-process
- No filesystem timing dependencies — deterministic inputs, deterministic outputs
- Cover every detection heuristic, every budget edge case, every parser path
- Test idempotent operations (double-close, double-stop)
- Write Go fuzz tests for every parser and every input-processing component
- Run for 30 seconds each — generates millions of random inputs
- Catches panics, infinite loops, and memory issues no human would find
- Push and verify CI passes on all matrix targets
- This is the final gate — if CI is green, the code ships
Every repo gets a demo project that serves as both a test harness and a user-facing trial:
demo/
├── main.go # Simulator with multiple scenarios
├── trial.sh # One-command interactive demo (shows all features)
├── test_e2e.sh # Automated E2E test suite with pass/fail assertions
├── cleanup.sh # Cleans up test artifacts
└── README.md # Usage guide
- Multiple scenarios — normal operation, every detection heuristic, budget enforcement, error cases
- Interactive mode — long-lived process with real PID for manual testing
- Automated E2E suite — bash script with green/red pass/fail output, covers every feature
- One-command trial —
bash demo/trial.shwalks through everything in 30 seconds - Speed control —
-speedflag for fast testing without changing behavior - Signal handling — responds to SIGCONT so enforcement is visible
- Every detection heuristic (spin, error echo, budget, cost velocity)
- No false positives (normal operation must not trigger alerts)
- Resume flow (pause → resume → verify state)
- Config overrides (env vars honored)
- Concurrent sessions
- Graceful shutdown
- Cost tracking accuracy
- Stale state recovery
- Multi-parser paths
- CLI error handling
Before declaring a repo done, every item must be green:
[ ] go build ./... — clean
[ ] go vet ./... — clean
[ ] golangci-lint run ./... — 0 issues
[ ] go test -race -count=1 ./... — all pass, 0 races
[ ] go test -fuzz (30s per target) — 0 panics
[ ] govulncheck ./... — 0 code vulnerabilities
[ ] go mod tidy — no changes
[ ] make build / make test / make lint — all work
[ ] bash demo/test_e2e.sh — all pass
[ ] bash demo/trial.sh — runs successfully
[ ] gh run list --limit 1 — CI success
[ ] gh issue list --state open — 0 open issues
[ ] FINDINGS.md — 0 NOT FIXED entries
[ ] README.md — accurate after all changes
- Fix everything. No "deferred" items, no "known issues," no "good enough." If it's confirmed, fix it.
- Verify with real data. Don't just read code — run it against actual sessions, real processes, live signals.
- Adversarial testing. Try to break it. Binary garbage, negative configs, rapid cycling, concurrent access.
- Fuzz what you parse. Every input-processing function gets fuzz tests. Millions of random inputs.
- No false confidence. Unit tests verify code correctness, not feature correctness. E2E tests verify the feature works. Both are required.
- Parallel agents for breadth. Fan out 4 agents for initial audit — they catch different things because they have different context windows.
- Integration tests for depth. In-process tests with deterministic inputs catch edge cases E2E tests can't reach.
- CI is the final gate. If CI isn't green, it doesn't ship.
- The demo IS the test. If the demo can't demonstrate a feature, the feature doesn't work.
- Document the hunt. FINDINGS.md records every bug found, its severity, evidence, and fix. It's the audit trail.
For calibration on what "exhaustive" means:
- 12 audit passes
- 4 parallel review agents
- 40 bugs found and fixed (4 critical, 8 high, 21 medium, 7 low)
- 25 source files modified
- 68 Go unit/integration tests
- 26 E2E tests
- 3 fuzz targets, 45.7 million random inputs
- 0 panics, 0 races, 0 lint issues
- Live SIGSTOP/SIGCONT verified on real process
- Real session cost tracking verified against live data