diff --git a/code-reviews/2026-12-02-perf-bugs/PLAN.md b/code-reviews/2026-12-02-perf-bugs/PLAN.md index 8bb0bdb8..315f6e51 100644 --- a/code-reviews/2026-12-02-perf-bugs/PLAN.md +++ b/code-reviews/2026-12-02-perf-bugs/PLAN.md @@ -2,11 +2,11 @@ Plan for the 99 findings in [README.md](README.md). The work is grouped into phases by risk: security and authz first, then merging the perf work that already exists, then lifecycle, alarms, conversion, the remaining performance items and the clients. Each phase is one branch (`fix/review-2026-12-`) and can merge on its own. Phases 0–2 come first. Phases 3–6 are independent of each other and can run in parallel. -Per CLAUDE.md, file each phase (or each High finding) as a Gitea issue labelled `type:review-finding` plus a priority, and refer to issues as `#N`. Docs change in the same commit as the code. During each task run only the targeted tests (`--filter`), and run the full gateway suite once at the end of the phase. +Tracking issues: phases #251–#257, and High findings #241–#250 (SES-002 #241, SES-003 #242, DSH-001 #243, SEC-001 #244, SEC-002 #245, WIP-001 #246, SES-001 #247, DSH-002 #248, MXA-001 #249, SEC-005 #250). MXA-002 / WIP-002 are tracked by the existing #235 / #236. Docs change in the same commit as the code. During each task run only the targeted tests (`--filter`), and run the full gateway suite once at the end of the phase. --- -## Phase 0 — Authorization and auth throttling (p0) +## Phase 0 — Authorization and auth throttling (p0) → #251 These are real trust-boundary gaps. The SES-002, SES-003 and DSH-001 code paths were re-checked by hand. @@ -23,7 +23,7 @@ These are real trust-boundary gaps. The SES-002, SES-003 and DSH-001 code paths --- -## Phase 1 — Land the existing perf work (p1) +## Phase 1 — Land the existing perf work (p1) → #252 MXA-002 / WIP-002 / MXA-006. The fixes are already written, tested on windev, and deployed on DEV vd03 (worker CPU 45% → 0.3% of a core). They were never merged. The branches stack: @@ -40,7 +40,7 @@ Close `perf.md` by moving it into `docs/` (or deleting it, since it is untracked --- -## Phase 2 — Session and worker lifecycle (p1) +## Phase 2 — Session and worker lifecycle (p1) → #253 | # | Finding(s) | Change | |---|---|---| @@ -60,7 +60,7 @@ Close `perf.md` by moving it into `docs/` (or deleting it, since it is untracked --- -## Phase 3 — Alarm pipeline correctness (p1) +## Phase 3 — Alarm pipeline correctness (p1) → #254 | # | Finding(s) | Change | |---|---|---| @@ -77,7 +77,7 @@ Close `perf.md` by moving it into `docs/` (or deleting it, since it is untracked --- -## Phase 4 — Worker value conversion and status mapping (p2) +## Phase 4 — Worker value conversion and status mapping (p2) → #255 All worker-side (net48 x86, so no init-only props or records). MXAccess parity is the reference. @@ -94,7 +94,7 @@ All worker-side (net48 x86, so no init-only props or records). MXAccess parity i --- -## Phase 5 — Remaining performance (p2/p3) +## Phase 5 — Remaining performance (p2/p3) → #256 | # | Finding(s) | Change | |---|---|---| @@ -113,7 +113,7 @@ All worker-side (net48 x86, so no init-only props or records). MXAccess parity i --- -## Phase 6 — Clients (p2) +## Phase 6 — Clients (p2) → #257 Each item is applied to every affected client in one change, so the five clients stay in step. Run each client's verification from the CLAUDE.md table. diff --git a/code-reviews/2026-12-02-perf-bugs/README.md b/code-reviews/2026-12-02-perf-bugs/README.md index af8996db..d8493cb0 100644 --- a/code-reviews/2026-12-02-perf-bugs/README.md +++ b/code-reviews/2026-12-02-perf-bugs/README.md @@ -1,6 +1,6 @@ # Bug and Performance Review — 2026-12-02 -Full-codebase review at `main` `54367e74`, scoped to **correctness bugs and performance only** (no style or docs findings). Eight parallel reviewers each covered one area and wrote a per-area report in this directory. Everything was found by reading the code: nothing was built, run or exercised live. The fix plan is in [PLAN.md](PLAN.md). +Full-codebase review at `main` `54367e74`, scoped to **correctness bugs and performance only** (no style or docs findings). Eight parallel reviewers each covered one area and wrote a per-area report in this directory. Everything was found by reading the code: nothing was built, run or exercised live. The fix plan is in [PLAN.md](PLAN.md). Gitea issues: phases #251–#257, High findings #241–#250. ## Reports @@ -22,17 +22,17 @@ Each report gives location, failure scenario, suggested fix, test idea and a con | ID | Category | Finding | |---|---|---| -| SES-002 | Bug (authz) | `Invoke` and `CloseSession` are not owner-scoped. Another key with `events:read` can `Invoke(DrainEvents)` a session and steal its events, which never reach the owner's stream or replay ring. Spot-checked: `OwnerKeyId` is compared only in `EventStreamService.cs:58`. | -| SES-003 | Bug (authz) | `AddBufferedItem` has no case in `ApplyConstraintsAsync`, so it skips API-key read constraints. Spot-checked. | -| DSH-001 | Bug (authz) | `Routes.razor` uses a plain `RouteView`, so the `[Authorize(AlarmsPolicy)]` on `/alarms` is enforced only on a full page load. In-circuit navigation lets anonymous localhost reach the alarm feed. Spot-checked. `/admin/secrets` may be exposed the same way (unverified). | -| SEC-001 | Bug (security) | The gRPC failure limiter partitions on `context.Peer`, which includes the ephemeral port, so the per-peer throttle resets on every new connection. | -| SEC-002 | Bug (security) | The aggregate throttle runs before the verification cache, so an unauthenticated sprayer who knows a key id can lock out its legitimate holder. | -| SEC-005 | Bug | A restart of the alarm monitor clears its cache without sending Clear or provider-status frames, so alarms cleared during the gap stay active for feed subscribers. | -| MXA-001 | Bug | Alarm failover never engages, or falsely "recovers", when the wnwrap primary fails to subscribe: `PollOnce` is a silent no-op that resets the failure counter. | -| SES-001 | Bug | On host stop, Kestrel waits 30 s on open `StreamEvents`, then every worker is killed instead of closed gracefully. | -| DSH-002 | Bug | A failed dashboard live read drops the session without closing it, orphaning it and its x86 worker for the 30-minute lease. Repeated failures can exhaust `MaxSessions`. | -| WIP-001 | Bug | Under sustained heavy event load (about 700 ev/s or more for over 15 s), the unbounded message-pump drain starves STA commands and the activity stamp, so the session is killed as `StaHung`. | -| MXA-002 / WIP-002 | Performance | None of the `perf.md` worker fixes (record-info pin, dedicated drain thread, synchronous flush, single write per frame) are on `main`. They exist only on the local branches `feat/worker-perf-prototype` and `feat/gateway-relay-hops` (#236, #235), which `perf.md` measured cutting worker CPU from 45% to 0.3% of a core. | +| SES-002 (#241) | Bug (authz) | `Invoke` and `CloseSession` are not owner-scoped. Another key with `events:read` can `Invoke(DrainEvents)` a session and steal its events, which never reach the owner's stream or replay ring. Spot-checked: `OwnerKeyId` is compared only in `EventStreamService.cs:58`. | +| SES-003 (#242) | Bug (authz) | `AddBufferedItem` has no case in `ApplyConstraintsAsync`, so it skips API-key read constraints. Spot-checked. | +| DSH-001 (#243) | Bug (authz) | `Routes.razor` uses a plain `RouteView`, so the `[Authorize(AlarmsPolicy)]` on `/alarms` is enforced only on a full page load. In-circuit navigation lets anonymous localhost reach the alarm feed. Spot-checked. `/admin/secrets` may be exposed the same way (unverified). | +| SEC-001 (#244) | Bug (security) | The gRPC failure limiter partitions on `context.Peer`, which includes the ephemeral port, so the per-peer throttle resets on every new connection. | +| SEC-002 (#245) | Bug (security) | The aggregate throttle runs before the verification cache, so an unauthenticated sprayer who knows a key id can lock out its legitimate holder. | +| SEC-005 (#250) | Bug | A restart of the alarm monitor clears its cache without sending Clear or provider-status frames, so alarms cleared during the gap stay active for feed subscribers. | +| MXA-001 (#249) | Bug | Alarm failover never engages, or falsely "recovers", when the wnwrap primary fails to subscribe: `PollOnce` is a silent no-op that resets the failure counter. | +| SES-001 (#247) | Bug | On host stop, Kestrel waits 30 s on open `StreamEvents`, then every worker is killed instead of closed gracefully. | +| DSH-002 (#248) | Bug | A failed dashboard live read drops the session without closing it, orphaning it and its x86 worker for the 30-minute lease. Repeated failures can exhaust `MaxSessions`. | +| WIP-001 (#246) | Bug | Under sustained heavy event load (about 700 ev/s or more for over 15 s), the unbounded message-pump drain starves STA commands and the activity stamp, so the session is killed as `StaHung`. | +| MXA-002 / WIP-002 (#235, #236) | Performance | None of the `perf.md` worker fixes (record-info pin, dedicated drain thread, synchronous flush, single write per frame) are on `main`. They exist only on the local branches `feat/worker-perf-prototype` and `feat/gateway-relay-hops` (#236, #235), which `perf.md` measured cutting worker CPU from 45% to 0.3% of a core. | ## Patterns across areas