Skip to content

Per-cell permissions in the dev tool's Data table - #256

Merged
crs48 merged 4 commits into
mainfrom
claude/devtools-cell-permissions-impl
Jun 25, 2026
Merged

crs48 merged 4 commits into
mainfrom
claude/devtools-cell-permissions-impl

Conversation

@crs48

@crs48 crs48 commented Jun 24, 2026

Copy link
Copy Markdown
Owner

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 avoidable PermissionError only after you tried to save. This wires the existing store.auth policy engine into the grid so the UI tells the truth up front.

How

  • @xnetjs/views — GridSurface/GridCell: new optional cellLockReasons?: ReadonlyMap<string, string> (key rowId:fieldId → human reason). A shared isCellLocked predicate 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 subtle Lock glyph with the reason as the cell title. Default-absent ⇒ unchanged behavior, so DatabaseView in the app is unaffected.
  • @xnetjs/devtools — useCellPermissions: lazy, edit-mode-only per-node write decisions over the visible window (guarded on store.auth, optimistic until resolved). Locks a cell when the node isn't writable or a restricted fieldRule denies the field. Pure deriveCellLocks extracted for testing.
  • AuthTraceView extracted from AuthZPanel and reused in a NodePermissions section of the node detail pane (store.auth.explain for read + write → roles, grants, reasons, steps).
  • No-authz fallback: stores without an authEvaluator keep type-based editing and show a "permissions not enforced in this store" note — no spurious locks.
  • Authz cache fix: DefaultPolicyEvaluator.can no longer reads/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 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

xNet Test and others added 4 commits June 24, 2026 15:53
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]>
@crs48
crs48 temporarily deployed to pr-256 June 24, 2026 23:50 — with GitHub Actions Inactive
@github-actions

Copy link
Copy Markdown
Contributor

🖼️ UI changes in this PR

No visual differences detected in the changed UI.

CI run

github-actions Bot added a commit that referenced this pull request Jun 24, 2026
@github-actions

github-actions Bot commented Jun 24, 2026 •

Copy link
Copy Markdown
Contributor

Preview removed for PR #256.

github-actions Bot added a commit that referenced this pull request Jun 24, 2026
)
}

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 }) {
@crs48
crs48 merged commit 5f3bda1 into main Jun 25, 2026
14 of 15 checks passed
@crs48
crs48 deleted the claude/devtools-cell-permissions-impl branch June 25, 2026 00:04
github-actions Bot added a commit that referenced this pull request Jun 25, 2026

This branch was previously deployed

1 inactive deployment
pr-256 — bed514b3 Deployed Jun 24, 2026 by crs48 via deploy-preview #434
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants