Repository navigation
fix(ui): avoid forbidden requests from restricted operator roles - #189850
Conversation
Project workspace read restrictions through existing session rows and gate diff, branch, and background requests before transport. Keep server policy authoritative; classify workspace changes during diff reads as retryable UNAVAILABLE.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review in progressClawSweeper is reviewing this revision. This supersedes any previous blocked status. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Consume the physical row owner without re-routing legacy keys through fixed-store defaults. Keep strict request-facing sandbox resolution intact and update allowed-session fixtures for the projected permission fact.
|
Merged via squash.
|
…nclaw#189850) * fix(ui): avoid forbidden requests from restricted operator roles Project workspace read restrictions through existing session rows and gate diff, branch, and background requests before transport. Keep server policy authoritative; classify workspace changes during diff reads as retryable UNAVAILABLE. * fix(ui): preserve resolved session ownership in workspace projection Consume the physical row owner without re-routing legacy keys through fixed-store defaults. Keep strict request-facing sandbox resolution intact and update allowed-session fixtures for the projected permission fact. * test(gateway): use real sandbox classification in execution fixtures
Release adaptation: backport only the Socket Mode reconnect waiter owner and focused regression tests; omit the performance harness and main-only transport documentation addition. Add listener-count assertions for timer settlement and disconnect cancellation; adjust the test allocation to 41. Companion dispositions: #198007 is specific to SDK 3.2 callback/abort semantics and is not applicable to this line pinned to socket-mode 3.1.0. #197657 retires main allocations; other audit hits (#200523, #197009, #194964, #184507, #192197, #192051, #190003, #189850) only overlap the excluded shared perf README. No later #188745 mention through bd692e9. (cherry picked from commit a1d1da7) Co-authored-by: RomneyDa <[email protected]>
What Problem This Solves
Fixes repeated forbidden diff requests when an operator requires sandboxing but views a host-workspace conversation, and optional branch/background requests without their required scopes.
User Impact
Review explains the workspace restriction before making a request. Branch controls stay hidden without write scope, and Appearance skips background reads without read scope. A workspace change during a diff returns retryable
UNAVAILABLE; genuine authorization denials remainFORBIDDEN.Why This Change Was Made
Conversation visibility does not imply access to its host files. The existing session-row projection now carries
workspaceReadDisabledReason, using the same policy as file reads and the existing materialized workspace facts. Sandbox classification consumes the physical row owner already resolved by projection topology; request-facing resolvers retain their strict routing checks. The UI uses its selected-row owner and granted scopes. Server authorization remains authoritative. No new configuration, cache, database schema, or protocol version.Canvas already binds widget reads to their session and handles pending widgets; cron already gates its view. Those owners are unchanged.
Evidence
Restricted-operator browser regression: two forbidden diff calls per dashboard visit become zero, with an explanatory Review affordance. Session-only viewer: New Conversation branch calls 1→0; Appearance background calls 1→0; cron remains 0. The chat-header branch owner also goes 1→0.
Production UI against an isolated real Gateway: 5,000 synthetic sessions and 62,000 files / 1.14 GB; zero automatic diff requests and zero UI FORBIDDEN responses. A deliberate direct diff RPC still returns FORBIDDEN. This used APFS and a small synthetic database, not a 35 GiB database or btrfs; unrelated startup UNAVAILABLE responses occurred. No private data or live deployment was used.
Five interleaved owner benchmark pairs, with A/A controls:
These are owner measurements, not end-to-end production latency. Client A/A CPU medians were 16.83/16.96 ms. Projection timing shows no meaningful speed claim on the loaded host; allocation rises 4.6%, and an unconditional 100-row response grows 15.7% to carry explanations. Existing shared-field transport can deduplicate repeated values.
Focused regression and affected-consumer proof covers projection invalidation, real RPC race classification, retained UI loaders, allowed diff behavior, and scope-gated browser navigation. The real Gateway test body took 21.3 s (63 s runner); focused test and final check details follow below.
Simplification: reused existing row materialization and selected-row lookup; shared file/presentation policy replaces duplicated admission text. Production delta +173 lines, generated validator +3, test delta +206, with a matching test-line allocation for the distinct regressions. Tooling adds reproducible owner measurements. Growth is needed to project a previously missing fact and distinguish permission from retryable workspace changes.
Focused results: 148 UI owner tests passed (7.21 s runner), 51 scope-owner tests passed, four diff-browser tests passed (21.60 s runner), the extended scope-browser scenario passed (16.37 s runner; other 13 cases passed separately), 12 projection/config tests passed, 64 file/race sibling tests passed, and three publication tests passed (43.72 s runner, 2.16 s test bodies). Publication snapshots were regenerated and verified to differ only by the additive nullable field.
Known main regression: production Knip reports
CHAT_SEARCH_HIGHLIGHTandsyncChatSearchHighlightas unused exports. The identical two failures reproduce on the exact main parentd5be7a6a42934658aacc09803c52d056b1fba29b, which introduced that module in #170434. This change does not touch that owner. It remains a main follow-up, not a passing check.Pre-PR
pnpm check:changed: all format, type, lint, schema, boundary, and lifecycle checks passed; exit 1 solely for the two exact-parent Knip failures documented above. Independent Codex autoreview is scoped-clean through P2.CI repair: the first run exposed re-resolution of physical legacy row ownership in the new projection and older allowed-session fixtures missing the new fact. Both are fixed. Only the failed owners and affected sandbox policy were replayed: 46 backend/sandbox tests and 59 UI tests passed. Targeted type checks, lint, formatting, and a fresh Codex autoreview passed. Final exact-head CI provides the broad proof.
The subsequent CI run exposed an obsolete whole-module sandbox mock in environment-execution tests. Removing it lets those 18 tests use the real classifier; all passed locally, and focused Codex review was clean. This follow-up changes no production code and reduces test growth to +206 lines. All other test jobs in that run passed.
Final validation: CI run 41253510831 passed on
13ed5bc6260f3c9123362103393e0c1341a1163d, with all planned jobs complete and no failed jobs.