fix(api): account-scope dashboard audit-log reads + memoize sidebar nav (audit 2026-06-10) - #160
Merged
Merged
Conversation
Dashboard summary and activity queries filtered auditLog by userId only, so a multi-account user saw events from every account they belong to. Queries now also require targetAccountId = current account (or null for user-level events), threaded from the auth context. Guardrail: new lint-meta source-text rule audit-log-read-account-scoped flags any src/ auditLog read filtered by userId without targetAccountId scoping; covered in tests/lint-meta and the rule docs/catalog are regenerated. Audit: F001
useAppSidebar rebuilt the icon record and items array on every render, giving the items prop a new identity each time and defeating memoization in the sidebar subtree. The computation is now inside useMemo keyed on [showBilling, t]. Audit: F002
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
auditLogbyuserIdonly, so a user belonging to multiple accounts saw their audit events from every account in any one account's dashboard. Queries now also requiretargetAccountId = current account(orNULLfor user-level events like logins), withaccountIdthreaded from the auth context. Guardrail-first: new lint-meta source-text ruleaudit-log-read-account-scopedflagged the exact 4 defect lines before the fix and now blocks the whole class (userId-filteredauditLogreads without account scoping); rule test added, RULES.md + docs catalog regenerated.useAppSidebarrebuilt the icon record and items array on every render, giving theitemsprop a new identity each time. The computation now lives in a singleuseMemokeyed on[showBilling, t].audit-monorepo→execute-auditskill pair (report20260610-2252); 3blocked_or_uncertainitems skipped by design (osv allowlist expiry automation, Starlight markdown-remark override removal, trivy-vs-osv divergence in infra-bootstrap).Test plan
cd apps/api && bun run check— green (typecheck, eslint, lint:meta incl. new rule, knip)cd apps/ui && bun run check— greenapps/apilint-meta + dashboard suites: 121 pass / 0 fail; new multi-account isolation tests included (DB-backed assertions execute in CI's postgres service)apps/uiAppSidebar unit tests: 6/6cd apps/docs && bun run check:docs-data— catalog freshApp merge bars
cd apps/api && bun run validatecd apps/ui && bun run validatecd apps/docs && bun run build:cibun run check(from repo root)Conventions
any, no blindas, no!.env.example(+ SECURITY.md when relevant) — n/a, none addedScreenshots
n/a — UI change is render-identity only (no visual difference).