Home · Developers · Guides · Device Access, Capability Discovery & Authorization

Security

Device Access, Capability Discovery & Authorization

Grant-scoped host operations

Nova Coder's device layer (novacoder/device/) gives the AI an accurate, live picture of the machine it runs on, platform, environment, tools, permissions, plus legitimate OS-mediated authorization workflows. It never bypasses operating-system security.

Architecture

novacoder/device/
├── platform_info.py   # OS, version, arch, distro, env context
├── states.py          # PermissionState + AccessLevel
├── discovery.py       # dev-environment inventory
├── probes.py          # os.access, sudo -n, pkexec, UAC, TCC probes
├── registry.py        # live resource → permission-state table
├── grants.py          # persisted scoped authorizations (user-managed)
├── elevation.py       # OS prompt workflows (pkexec/sudo/osascript/UAC)
├── consequential.py   # destructive-operation classification
├── audit.py           # JSONL audit log with secret redaction
├── tools.py           # DeviceOps, guarded fs/exec operation surface
├── capabilities.py    # device.* engine capabilities (11)
└── service.py         # DeviceService (kernel service #38)

Platform & environment detection

detect_platform() reports:

  • OS (linux / darwin / windows), release, version, distro, machine
  • execution context: host, wsl, container (docker/podman/k8s via /proc + env sentinels), vm (DMI vendor strings), ssh, flatpak, snap, sandboxed
  • user, uid, is_root, is_admin (via sudo -n or IsUserAnAdmin, a non-interactive check that never supplies credentials)

discover() inventories the development environment, interpreters, toolchains, package managers, VCS, containers, databases, LSP servers, local AI runtimes, GPUs (nvidia-smi/DRM), shells, mounted volumes (/proc/mounts / mount), user directories (XDG/known-folders), project markers, and local dev services (passive localhost port probe). Read-only: no writes, no file contents outside system probe files, env vars reported as presence-flags (proxy values may embed credentials).

Permission states

Every registry resource reports one of:

available · unavailable · restricted · auth_required · user_denied · temporarily_unavailable · unsupported · externally_managed

Entries are re-probed on refresh or after a staleness TTL, the environment changes, so access is never permanently assumed.

Scoped grants (user-managed)

GrantStore persists to <data_dir>/device_grants.json:

  • Kinds: project (auto-granted workspace root), directory, tool, capability
  • project_only mode (default ON): anything outside granted scopes reports auth_required. Off ⇒ user-home reads allowed, system paths still need grants.
  • Deny shadows: a denied directory blocks every path beneath it, even inside a granted scope.
  • Access ≠ authorization: a granted scope still requires explicit confirmation for consequential operations.
  • The AI-facing capabilities can list grants but cannot create or revoke them, grant mutations exist only on the authenticated API (/api/device/grants*), i.e. the user.

Elevation workflows

ElevationManager.prepare() returns the exact command, mechanism, and instructions, never executes. .launch() invokes the OS prompt:

Platform Mechanism
Linux + display pkexec (PolicyKit dialog)
Linux headless sudo detached → OS terminal prompt; or manual instructions
macOS osascript 'do shell script … with administrator privileges'
Windows ShellExecuteEx runas (UAC consent)
None available honest manual instructions, never faked

Credentials are never accepted, stored, or forwarded, sudo -S is deliberately unused. After the prompt, callers re-probe; denial results in user_denied and graceful degradation.

Consequential-operation gate

classify_command / classify_path_write separate consequence from access:

  • benign, normal dev work inside scope
  • consequential, rm -rf trees, system package/process changes, writes outside scope or to ~/.ssh-class areas → needs confirmed
  • elevated, protected system locations (/etc, C:\Windows, /System…) → needs elevation AND confirmation
  • prohibited, security-control edits (visudo, tccutil, csrutil, bcdedit, firewall/SELinux/apparmor changes) → always refused; the user does these manually

Guarded operations (DeviceOps)

service.ops (tools.py) is the single funnel for device-level file/command work, the "clear tool interfaces" the AI uses instead of raw filesystem/subprocess access:

  • fs_list(path), directory listing inside a granted scope
  • fs_read(path, max_bytes), text read; byte-capped, binary refused
  • fs_write(path, content, confirmed=, create_dirs=), write; confirm-gated when the consequence classifier flags it
  • exec(argv, cwd, timeout, confirmed=), argv only (no shell string interpolation); cwd must be inside a granted scope; timeout-capped

Every operation runs the same gate chain: grant scope → OS probe → consequence classification → audit. The structured result carries {ok, state, data, reason, consequence}, state explains a refusal (auth_required, prohibited, failed) instead of raising. Even a confirmed destructive op still runs as the normal user, the OS's own permission check is a second, independent gate.

Audit

<data_dir>/device_audit.jsonl records tool, category, resource, action, elevation, authorization, outcome, with token/key/password patterns redacted before persisting. Size-capped rotation. Every guarded op attempt (allowed or refused) is recorded.

API

Route Purpose
GET /api/device/info platform + context + grant summary
GET /api/device/inventory?refresh= environment inventory
GET /api/device/registry?refresh= resource state table
POST /api/device/registry/refresh re-probe everything
POST /api/device/access/check probe+grant+consequence for a path
POST /api/device/command/check classify a command
GET/POST /api/device/grants · POST …/grants/revoke grant mgmt
POST /api/device/project_only scope-mode toggle
POST /api/device/elevate prepare (invoke:false) or launch prompt
GET /api/device/audit audit tail
POST /api/device/fs/list guarded directory listing
POST /api/device/fs/read guarded file read (max_bytes cap)
POST /api/device/fs/write guarded write (confirmed when flagged)
POST /api/device/exec guarded command (argv, cwd, timeout, confirmed)

Engine capabilities

Read-only discovery/inspection: device.info, device.inventory, device.check_access, device.request_access (prepare only), device.elevate (launches OS prompt, requires_approval), device.grants, device.audit.

Guarded operations (grant + consequence gated): device.fs.list, device.fs.read, device.fs.write, device.exec.

UI

/device page (View → Device): platform card, environment inventory, live registry with per-resource states and re-probe, grant management with revoke/deny and project-only toggle, access checker, elevation helper, and the audit table.

Boundaries

  • Most operations run with standard user privileges; elevation is per-operation, OS-mediated.
  • Discovery never ingests file contents; grants scope what the AI may touch.
  • macOS/Windows backends are implemented (osascript/TCC probes, runas/UAC) but verified only on Linux, see report 31.

Source: wiki/device-access.md · rendered 2026-11-10