Repository navigation
Per-cell permissions in the dev tool's Data table - #256
Merged
Merged
Conversation
Reflect real per-cell permissions instead of failing edits reactively:
- GridSurface gains an additive `cellLockReasons` map ("rowId:fieldId" -> reason)
that blocks editing that cell (keyboard + double-click) and renders a lock
glyph + hover tooltip via GridCell. Read is node-level and unreadable nodes
are already filtered out, so the locks we surface are edit locks.
- useCellPermissions computes per-node write decisions lazily (edit-mode only,
over the loaded window) via store.auth.can, plus per-field checks for fields
carrying a fieldRule. A non-writable node locks all its editable cells; a
restrictive field rule locks that one cell. Optimistic until decisions
resolve (no flicker). Guarded on store.auth (shows a "not enforced" note when
authz is off).
- The row detail pane gains a Permissions section showing read + write
derivation (roles, grants, reasons, evaluation steps) via store.auth.explain.
- Extracted AuthTraceView + StatusBadge from the AuthZ Playground so the panel
and the cell popover render decisions identically.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Adversarial review of the per-cell permission work surfaced three real gaps; this addresses them: - All grid write paths now consult the shared `isCellLocked` predicate, not just inline editing. Paste, fill-down, cut/clear (via refsInRect), and file-drop previously bypassed `cellLockReasons` and could mutate a locked cell. Each now skips locked targets. - `DefaultPolicyEvaluator.can` no longer reads or writes the decision cache when a `patch` is present. The cache is keyed only by subject/action/node, so a prior node-level write check could mask a field rule for the rest of the TTL, silently bypassing field-level restrictions. Added a regression test. - The node detail pane clears the previous node's auth traces before re-evaluating, so a freshly selected node shows "Evaluating…" rather than briefly attributing the prior node's permissions to it. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Contributor
🖼️ UI changes in this PRNo visual differences detected in the changed UI. |
Contributor
|
Preview removed for PR #256. |
| ) | ||
| } | ||
|
|
||
| export function AuthTraceView({ trace }: { trace: AuthTrace }) { |
|
|
||
| /** Read + write authorization for a node, with the full derivation (roles, | ||
| * grants, deny reasons, evaluation steps) — the "how is this derived" view. */ | ||
| function NodePermissions({ nodeId }: { nodeId: string }) { |
This branch was previously deployed
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.
What
The dev tool's Data panel (Ctrl/Cmd+Shift+D) now reflects your real authorization per cell. When editing is on, cells you're not allowed to write are locked instead of failing on save, and a row's detail pane shows exactly how your read/write permissions are derived. Implements exploration 0219.
Why
Inline editing (added in #252) let you double-click any cell and call
store.update— but the grid had no idea what authorization said. Editing a cell you couldn't write surfaced an avoidablePermissionErroronly after you tried to save. This wires the existingstore.authpolicy engine into the grid so the UI tells the truth up front.How
@xnetjs/views—GridSurface/GridCell: new optionalcellLockReasons?: ReadonlyMap<string, string>(keyrowId:fieldId→ human reason). A sharedisCellLockedpredicate guards every write path — edit-start, double-click, paste, fill-down, cut/clear (refsInRect), and file-drop — not just the editor. Locked cells render a subtleLockglyph with the reason as the celltitle. Default-absent ⇒ unchanged behavior, soDatabaseViewin the app is unaffected.@xnetjs/devtools—useCellPermissions: lazy, edit-mode-only per-nodewritedecisions over the visible window (guarded onstore.auth, optimistic until resolved). Locks a cell when the node isn't writable or a restrictedfieldRuledenies the field. PurederiveCellLocksextracted for testing.AuthTraceViewextracted fromAuthZPaneland reused in aNodePermissionssection of the node detail pane (store.auth.explainfor read + write → roles, grants, reasons, steps).authEvaluatorkeep type-based editing and show a "permissions not enforced in this store" note — no spurious locks.DefaultPolicyEvaluator.canno longer reads/writes the decision cache when apatchis present. The cache is keyed only by subject/action/node, so a prior node-level write check could otherwise mask a field rule for the rest of the TTL — silently bypassing field-level restrictions.Tests
GridSurface: a locked cell blocks Enter + double-click editing (shows title); sibling row still edits.deriveCellLocks/restrictedFieldNames: node-deny locks all editable fields, writable unlocked, field-rule lock, optimistic-undecided.evaluator: regression — a cached node-level decision no longer masks a field rule.Verified live in the browser preview (the dev store has no
authEvaluator, so the preview exercises the graceful "not enforced" fallback; the enforced lock path is covered by the unit tests above).🤖 Generated with Claude Code