fix(audit): resolve #161, #162, #177 + close 13 stale audit issues#209
fix(audit): resolve #161, #162, #177 + close 13 stale audit issues#209ajitpratap0 merged 2 commits intomainfrom
Conversation
- CODE-005 (#161): OrchestratorClient now exposes ctx-aware variants (PauseCtx/ResumeCtx/IsPausedCtx/GetActiveAgentCountCtx) that inherit a 5s timeout from the caller's context. Dashboard handlers detect these via a narrow contextualOrchestrator type assertion and pass c.Request.Context() so an HTTP client disconnect aborts the outbound orchestrator RPC instead of pinning a goroutine for 5s. The existing non-ctx methods are retained as wrappers so the OrchestratorInterface and MockOrchestrator stay unchanged — zero churn to tests and the in-process orchestrator implementation. - CODE-006 (#162): cmd/api/main.go wraps the DB pool initialization in a 30s context.WithTimeout so the process fails fast when Postgres is unreachable instead of blocking indefinitely on the long-lived signal-derived context. - FE-010 (#177): Performance page now surfaces backend failures with an accessible error banner + Retry button that refetches the three primary queries (summary metrics, equity history, pair performance). Candlestick and drawdown are deliberately excluded — candlestick has its own NEXT_PUBLIC_USE_MOCK_CANDLES fallback and drawdown is derived from equity.
PR Review — fix(audit): #161, #162, #177Overall this is a focused, well-reasoned PR. The design decisions are clearly documented and the scope is appropriately narrow. A few items worth addressing before merge:
|
| Area | Status |
|---|---|
CODE-005 (orchestrator_client.go) |
✅ Clean, no issues |
CODE-005 (dashboard.go dispatch helpers) |
✅ Good pattern, verify nil safety in PauseTrading/ResumeTrading |
CODE-006 (main.go timeout) |
✅ Correct, comment is slightly misleading |
FE-010 (performance/page.tsx) |
AlertTriangle import; minor style items |
The three bugs being fixed are real and the fixes are appropriate. The main blocking item to confirm before merge is the AlertTriangle import.
🤖 Generated with Claude Code
- main.go: rewrite the DB init timeout comment to accurately describe pgxpool.New's context usage (initial AcquireConn only) and explain why dbInitCancel is called immediately instead of deferred. - performance/page.tsx: split the wide useQuery destructurings across lines for readability and wrap retryAll in useCallback so the onClick handler doesn't get a fresh function reference every render. Note: AlertTriangle is already imported on line 17 (pre-existing use for the Max Drawdown StatCard icon at line 121), so the review's concern about a missing import was a false alarm. Note: h.orchestrator nil-safety in PauseTrading/ResumeTrading is already guarded by the 'if h.orchestrator == nil' checks at lines 545 and 580 that existed before this PR — not shown in the diff.
|
Round 2 addressed in a6efa16 — thanks @claude. main.go comment (CODE-006) performance/page.tsx (FE-010) False alarms verified, not blocking
Deferred
Re-ran `go build ./cmd/api/...` and `npm run type-check`; both clean. |
|
Claude finished @ajitpratap0's task in 52s —— View job PR Review — Round 2 VerificationAll items from the previous review round confirmed clean. Verified in a6efa16
False alarms confirmed
Outstanding (deferred, not blocking)
This PR is ready to merge. All three genuine bugs are fixed, all review feedback has been addressed, and the two deferred items are properly tracked for follow-up. |
Code Review — PR #209Overall this is a clean, well-scoped bug-fix pass. The rationale in the PR description is clear and the three fixes are all straightforward. A few observations below. CODE-006 ·
|
| Area | Verdict |
|---|---|
| DB init timeout (CODE-006) | ✅ Correct and well-documented |
| Context-aware orchestrator (CODE-005) | ✅ Sound design; missing Ctx unit tests |
| Performance error banner (FE-010) | ✅ Accessible; retryAll deps can be simplified |
| Breaking changes | None |
| Security concerns | None |
The only actionable follow-up is unit tests for the *Ctx orchestrator methods — everything else is nits. Looks good to merge.
🤖 Generated with Claude Code
Summary
Third pass at the 2026-03-25 audit backlog. Of the 17 remaining issues triaged this session, 13 were stale (already fixed on main or described code that no longer exists) and closed with evidence links. The 3 genuinely broken items are fixed here.
Fixes
CODE-005 (#161) — request-context-aware orchestrator HTTP client
`OrchestratorClient` now exposes ctx-aware variants (`PauseCtx`, `ResumeCtx`, `IsPausedCtx`, `GetActiveAgentCountCtx`) that inherit a 5s timeout from the caller's context. Dashboard handlers pick them up through a narrow `contextualOrchestrator` type assertion and pass `c.Request.Context()` so an HTTP client disconnect aborts the outbound orchestrator RPC instead of pinning a handler goroutine for the full 5s timeout window.
Rationale for the type-assertion approach: the existing `OrchestratorInterface` is implemented by both `*OrchestratorClient` (cross-process HTTP) and `*orchestrator.Orchestrator` (in-process, used from tests and e2e). Adding ctx params to the interface would churn ~25 test sites for no real benefit — in-process calls don't need cancellation. Keeping the non-ctx methods as wrappers around the Ctx variants avoids that churn entirely while still fixing the real bug for the real code path.
CODE-006 (#162) — fail-fast DB pool init
`cmd/api/main.go` wraps `db.New` in a 30s `context.WithTimeout` derived from the signal context. Previously the signal context had no deadline, so if Postgres was slow or unreachable the process blocked indefinitely on startup instead of failing fast.
FE-010 (#177) — performance page error state
The performance page aggregates errors from the three primary queries (summary metrics, equity history, pair performance) and shows an accessible error banner with a Retry button that refetches only the failed queries. Candlestick and drawdown are excluded intentionally — candlestick has its own `NEXT_PUBLIC_USE_MOCK_CANDLES` fallback and drawdown is derived from equity.
Closed as stale (13)
Deferred
#179 FE-012 — no tests for risk/performance/agents pages. Writing these needs vitest route-level harness scaffolding; best done in a dedicated PR.
Test Plan
Breaking Changes
None.
🤖 Generated with Claude Code