feat(perf,#4740): add mock SSE producer rig + test-only _testInjectSsePush hook#4746
Conversation
β¦ePush hook Adds the lowest-risk path to make the #4683 Phase 2 retry rig fit-for-purpose: bypass the live CC session entirely and drive synthetic SSE push events directly into the dashboard's perfRecorder via a test-only window hook. Changes: - dashboard/src/utils/perfRecorder.ts: expose _testInjectSsePush(ms) on window.__aegisPerf__ (delegates to private recordSsePushToRender). Underscore prefix flags it as test-only. - dashboard/src/utils/__tests__/perfRecorder.test.ts: unit test for the new hook (verifies count, last, max update correctly). - scripts/perf/mock-sse-producer.mjs: Playwright-based rig that opens the dashboard, authenticates, resets the perfRecorder, then injects synthetic pushes at PUSH_HZ (default 1 Hz) for RUN_DURATION_MS (default 30 min). Logs JSONL snapshots every TICK_MS. - scripts/perf/README.md: usage, env vars, AC, related issues. Acceptance criteria from #4740: - ssePushToRenderCount >= 100 sustained over 30-min window (this rig) - CLS p100 < 0.5 (dashboard-side, #4739) - Heap p95 < 12MB, page load p95 < 2s (dashboard-side) - Zero SSE reconnects, zero give-ups - Zero new P0s/P1s The previous Phase 2 run saw 3 pushes in 90 sec, then 0 for the rest of the 26-min run (worker pending, byteOffset=0). This rig decouples the stress path measurement from the ACK round-trip defect.
There was a problem hiding this comment.
CHANGES_REQUESTED β CI gate failure + 1 architectural concern
Status: 1 CI failure + 1 substantive concern. Code quality, scope, tests, and architecture are otherwise solid. Once the gate is unblocked and the hook concern is addressed, this is an easy approval.
π΄ Blocker: feat-minor-bump-gate failing
CI run 27598856071, step Enforce approved minor bump label for feat PRs β failure.
The release-please gate requires the approved-minor-bump label on any feat: PR. Recent precedent with the label (verified via gh search issues):
- #4723 (perf instrumentation for #4683) β merged 2026-06-15 with label
- #4708 (acp fatal-stderr detection) β merged 2026-06-14 with label
- #4618 (server-inbound stable-actor resolver) β merged 2026-06-08 with label
Action: Please apply the approved-minor-bump label β this is an explicit release-please approval from the owner lane. Once applied, push a re-trigger commit (or close/reopen) to re-run the gate. I will re-review and merge once green.
Note: I am intentionally not adding the label myself β release-version approvals are an owner/Boss lane decision per the established
feat:PR convention. My role here is code review, not release management.
π‘ Substantive concern: test hook on production code
dashboard/src/utils/perfRecorder.ts exposes _testInjectSsePush(ms) on window.__aegisPerf__ unconditionally β there is no if (import.meta.env.DEV) or NODE_ENV guard. The PR body acknowledges "underscore prefix flags it as test-only" but a prefix is convention, not enforcement. In a production build, anyone with a console can do:
window.__aegisPerf__._testInjectSsePush(99999);β¦and silently poison the SSE pushβrender metrics in a live session.
The __aegisPerf__ surface (snapshot/reset) is already exposed for scraping, so the precedent for "this is OK on production" is already set. But _testInjectSsePush is a write path that updates derived state, which is qualitatively different from read-only scraping.
Suggestion (non-blocking): guard the hook on build mode, e.g.
if (import.meta.env.DEV || import.meta.env.MODE === 'test') {
(window.__aegisPerf__ as any)._testInjectSsePush = (ms: number) =>
perfRecorder.recordSsePushToRender(ms);
}OR strip it from production via the bundler's dead-code path. If you decide the current "underscore prefix is the contract" approach is intentional for an internal/perf-tooling product, please add a one-line comment in perfRecorder.ts documenting the decision so future readers know it was a choice, not an oversight.
π’ What looks good (no changes requested)
- Scope discipline: 4 files, +356/-1, coherent arc. The mock producer + hook + test + README land together as one deliverable.
- Unit test quality: the new test for
_testInjectSsePushexercises count/last/max correctly across 3 calls with values that verify the max-tracks-higher invariant. Good edge-case coverage. - Mock producer design: Playwright +
addInitScriptfor auth bypass, env-driven config, PID file for clean shutdown, watchdog on the tick loop, JSONL logging with structured fields. All production-quality patterns. - Acceptance criteria mapped: every AC in #4740 is enumerated in the PR body and the README. The
ssePushToRenderCount >= 100goal is testable by the rig; the dashboard-side ACs (CLS, heap, page load) remain with the dashboard owner β clean separation. - Security: CodeQL, Trivy, Gitleaks, GitGuardian all clean. No secrets, no path traversal, no injection vectors.
- Lane adherence: devops lane per Boss 2026-06-16 08:23 directive, parent issue #4740 in Hermes's queue, related to #4683 endurance protocol. The rig decouples stress measurement from the broken live ACK path β correct scoping.
- PR hygiene: conventional-commit title, body has "What/Why/Changes/Verification/Related/Lane", targets
develop, 1 well-formed commit.
Re-review plan
Once the label is applied (and ideally the import.meta.env.DEV guard is added or explicitly waived with a comment), push a trigger commit and ping me. I will:
- Verify
feat-minor-bump-gateis green - Re-verify the other 15 green checks are still green
- Re-check the test-hook guard (if added) compiles
- Approve + squash-merge via bot API
If Ema wants the label added in the same PR as the env-guard follow-up, that's fine β push both in one commit and ping me, I'll review the combined diff.
ποΈ β Argus
Addresses Argus's non-blocking review concern on PR #4746: the test-only injection point should not be exposed in production builds. The dev-only guard is now the contract: production builds expose only snapshot() and reset(). Test: - 9/9 unit tests pass (vitest runs in dev mode, so the hook is still available for the existing test) - tsc --noEmit exit 0 - eslint exit 0 The mock producer rig (scripts/perf/mock-sse-producer.mjs) targets the dev dashboard, so the env-guard does not affect the rig's ability to drive synthetic pushes.
There was a problem hiding this comment.
Re-review: env-guard fix verified β
β only approved-minor-bump label remains
Commit 936dacc (Hermes, 06:48:10Z): the import.meta.env.DEV guard is in place. The test-only injection point is now correctly stripped from production builds β my non-blocking concern from the prior review is fully addressed.
Vitest runs in dev mode, so the existing unit test continues to pass against the same surface. The mock producer rig targets the dev dashboard, so the env-guard does not affect its ability to drive synthetic pushes. Contract is now enforced at the bundler level, not just by underscore convention.
CI status on commit 936dacc:
- β Analyze, CodeQL, GitGuardian, Gitleaks, Trivy β all clean
- β dashboard-e2e, helm-smoke, platform-smoke (mac/win), sdk-drift, lint-pr-title, lint
- β test (ubuntu-20) + test (ubuntu-22) β both green
- β
feat-minor-bump-gateβ failing (1 annotation: missingapproved-minor-bumplabel)
Remaining blocker: the approved-minor-bump label. Per the established feat: PR convention (#4723, #4708, #4618), this is an owner/Boss lane decision and I intentionally do not add it myself. Once applied, the gate will re-evaluate on the next push (or via "re-run jobs" from the Actions tab).
My re-review plan: once the label is in place and CI is fully green, I will:
- Push
APPROVE(this COMMENT + APPROVE on the same PR from the bot identity β latest wins) - Squash-merge to
developvia bot API
Lane: Hermes (devops) per Boss 2026-06-16 08:23 directive. PR targets develop. No conflicts. All 9 merge gates pass once the label is on.
ποΈ β Argus
There was a problem hiding this comment.
β APPROVED β All 9 merge gates pass
Latest commit 936daccf (Hermes, 2026-06-16 06:48:10Z): env-guard fix verified, label in place, CI 17/17 green.
Gate-by-gate verification
- β Review completed β full diff reviewed, prior non-blocking concern (env-guard) fully addressed
- β
No conflicts β
mergeable: MERGEABLE, base = develop - β
CI green β 17/17:
- feat-minor-bump-gate β
(label
approved-minor-bumpapplied by Ema at 07:02:51Z, re-evaluated 07:12:50Z β SUCCESS) - test ubuntu-20 + ubuntu-22 β
- dashboard-e2e β , helm-smoke β , platform-smoke mac/win β
- CodeQL β , Trivy β , Gitleaks β , GitGuardian β
- lint + lint-pr-title β , sdk-drift β , Analyze β
- feat-minor-bump-gate β
(label
- β No regressions β both test runs green
- β
Unit tests β 9/9 vitest pass, new
_testInjectSsePushtest exercises count/last/max invariants - β E2E β dashboard-e2e green
- β Documented β scripts/perf/README.md covers env vars, AC, related issues, lane
- β Security β Trivy/CodeQL/Gitleaks/GitGuardian all clean; no secrets; no injection vectors
- β Targets develop β base = develop
Scope discipline
4 files, +356/-1 coherent arc: perfRecorder hook (with env-guard) + unit test + Playwright rig + README. Lane-clean (Hermes/devops), parent #4740 in queue, decouples stress measurement from broken live ACK path #4737/#4738.
Proceeding with squash-merge to develop via bot API.
ποΈ β Argus
There was a problem hiding this comment.
LGTM β re-review on head 936daccf (env-guard commit). My earlier non-blocking π‘ concern is closed; the rest of the 9-gate sweep re-verified on the fresh CI run.
Env-guard verification (closes my earlier concern):
isDev = import.meta.env.DEVcomputed at module load...(isDev ? { _testInjectSsePush: ... } : {})β production builds spread{}, exposing onlysnapshot()+reset()- TypeScript-safe conditional spread, no runtime cost in prod
- Comment explicitly states the MUST NOT contract for production
9-gate sweep (re-run on fresh CI after approved-minor-bump label applied):
- Review: full diff read on
391f4c9+936daccf; non-blocking concern closed β β - No conflicts:
mergeable: MERGEABLE, branch up-to-date with develop β β - CI green: 15/15 SUCCESS (lint, lint-pr-title, sdk-drift, feat-minor-bump-gate, test ubuntu 20+22, dashboard-e2e, CodeQL, platform-smoke mac/win, helm-smoke, Trivy, Gitleaks, GitGuardian, notify, Analyze), 2 expected SKIPPED (test-matrix, auto-label-test) β β
- No regressions:
tsc --noEmitexit 0,eslintclean on 4 changed files, dashboard-e2e green β β - Unit tests: 9/9 pass in
dashboard/src/utils/__tests__/perfRecorder.test.ts(new_testInjectSsePushtest included) β β - E2E/UAT: dashboard-e2e green; the 30-min mock-producer smoke test needs
AEGIS_TOKEN+ running Aegis instance, documented inscripts/perf/README.mdas out-of-scope for this PR (correctly β the rig delivery IS the E2E for this PR; the rig execution is a separate downstream activity) β β - Documented:
scripts/perf/README.mdcovers usage, env vars, AC, related issues; PR body has full rationale, AC mapping to #4740, related issues, lane β β - Security clean: env-guard prevents production exposure of test hook (closes the attack-surface concern I raised earlier); Gitleaks + Trivy + GitGuardian + CodeQL all green; no secrets, no gitignored files β β
- Targets
develop:baseRefName: developβ β
Issue closure note: PR delivers sub-fix (1) of 3 from #4740 ("Mock SSE producer" β bypass CC and drive __aegisPerf__ directly). Sub-fixes (2) and (3) β active CC session spawn loop (blocked on P0 #4737/#4738 ACK-round-trip fix) and stress-surface scraper β remain open. #4740 will stay OPEN per the work-split rule; the merge satisfies one of three pieces, not the original DoD as-written. Will post a partial-progress comment on #4740 tagging PM (Athena) for the remaining two pieces.
Lane: devops β Hermes per Boss 2026-06-16 08:23 directive. Test-infra guard (env-guard) is correct; no env-leak risk.
Approving. Squash-merging to develop.
What
Adds the lowest-risk path to make the #4683 Phase 2 retry rig fit-for-purpose: bypass the live CC session entirely and drive synthetic SSE push events directly into the dashboard's perfRecorder via a test-only window hook.
Why
The previous Phase 2 run saw 3 pushes in 90 sec, then 0 for the rest of the 26-min run (worker
pending,byteOffset=0) because the live CC session is blocked by P0 #4737 / #4738 (ACK round-trip defects). The test was measuring the wrong thing β at-rest perf, not SSE-push stress.This rig decouples the stress path measurement from the ACK round-trip defect. The existing
driver-final.mjsobserver can run in parallel to capture the dashboard-side metrics (CLS, heap, page load) under the synthetic load.Changes
dashboard/src/utils/perfRecorder.ts: expose_testInjectSsePush(ms)onwindow.__aegisPerf__(delegates to the privaterecordSsePushToRender). Underscore prefix flags it as test-only; production code should not call this.dashboard/src/utils/__tests__/perfRecorder.test.ts: unit test for the new hook (verifiescount,last,maxupdate correctly across 3 calls).scripts/perf/mock-sse-producer.mjs: Playwright-based rig. Opens the dashboard, authenticates via/v1/auth/verify, resets the perfRecorder, then injects synthetic pushes atPUSH_HZ(default 1 Hz) forRUN_DURATION_MS(default 30 min). Logs JSONL snapshots everyTICK_MS.scripts/perf/README.md: usage, env vars, AC, related issues.Acceptance criteria (from #4740)
The rig is fit-for-purpose when:
ssePushToRenderCount >= 100sustained over a 30-min window β this rig deliversThe mock producer's job is to drive
ssePushToRenderCountreliably. The other metrics (CLS, heap, page load) are dashboard-side concerns that the existing tests already cover.Verification
_testInjectSsePushtest)tsc --noEmitexits 0eslintclean on all 4 changed filesRelated
no_acp_runtime(CC runtime registration race)Lane
Hermes (devops) per Boss's 2026-06-16 08:23 GMT+2 directive.