Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Engine reference — generated from the canonical engineering source. Do not edit this page by hand.

Consent: what a repository can change — and what it can never change

Luna treats project-local files as untrusted input. Cloning a repository and running luna inside it must not silently disable the sandbox, redirect your credentials, execute repo-shipped code, or hand your fleet a different toolbox. This page is the consolidated model. The code authorities are:

ConcernAuthority
Approval path/record validation/atomic write/TTY promptclient/core/approvals_store.lua
Repo-config security families + stripclient/core/repo_config_security.lua
Repo-config consent hash/markerclient/core/repo_config_trust.lua
MCP definition + tool-manifest approvalclient/core/mcp_config.lua
MCP manager gate (discovery/refresh/notification)client/core/mcp_manager.lua
Extension consent (manifest + source bytes)client/core/extension_consent.lua
MCP elicitation operator surfaceclient/core/mcp_elicitation.lua
Consent census lintci/luna_consent_lint.py + ci/luna_consent_registry.json

The trust boundary

Consent records live in user-owned storage: ~/.luna/approvals/. A marker inside the repository (for example a .luna/trust file) is deliberately never used — the attacker who ships the repository also ships the marker. Only core.approvals_store constructs approval paths; every other module asks it.

Three record namespaces are preserved for compatibility:

PlaneRecord filenameContent bound
Repo config + repo toolstrust-<sha256>.jsonSecurity-family subtree in merge precedence order; .luna/agents permission_override values; repo tool file contents
MCP<sha256>.jsonNormalized server definition + discovered tool manifest
Extensionsextension-<sha256>.jsonCanonical manifest + sorted content hashes of every .lua under the extension dir

New records carry v=1 and kind. Existence is no longer approval: a corrupt/truncated record, a record whose hash or kind names a different identity, or an unknown record version is treated as absent (fail closed). Legacy records without those fields — including bare {} markers — remain readable. Writes are atomic (FFI.atomic_write: mkostemp 0600 from birth, fsync, checked rename), so a credentialed record is never world-readable and a crash cannot leave a torn row.

Security-relevant keys sourced from .luna.json, .luna/settings.json or .luna/settings.local.json apply only with a matching trust- record:

execution.* (sandbox posture, network, bind roots), permission_* (mode, overrides), server_permissions, workspace, workspace_root, extensions_enabled, agents_dir, local_agents_dir, mode, provider_base_url, api_key, api_keys, auxiliary, fallback_providers, otel_endpoint, classifier — the AI permission-classifier’s provider plane (enabled/model/provider/base_url); base_url is a network destination, so a repo cannot redirect classifier traffic without approval, providers — settings-level custom provider definitions (base_url/wire_format/models/api_key_env); both the destination and the credential source, so a repo cannot add or redirect a custom endpoint without approval.

Without a record:

Interactive session (TTY): Luna prints the family list and asks once ([y/N]); only an explicit y/yes writes the record; Headless/agent/CI: the keys are ignored (stripped) with a loud stderr warning and a counter. The sandbox default stays ON.

The hash is content-derived: editing the security subtree invalidates the record and re-asks. The permission-mode permission_override scan is part of the same hash (one approval covers both file sets). config.lua records the provenance of project-carried provider keys and provider.from_model independently refuses a repo-carried destination while consent is false (defense in depth against a future strip bypass).

Project MCP servers

.luna/mcp.json servers (stdio and HTTP) never start without a definition-keyed mcp record. HTTP servers are not exempt: a repo URL is an SSRF-into-context primitive even though it executes no local code.

Since the approval also binds the discovered toolbox:

first discovery with a legacy (no tools_hash) record is TOFU-stamped silently — no re-prompt, because the definition was already approved; a changed manifest prompts with a bounded added/removed/changed summary on a TTY. A decline or a non-TTY session means the changed tools are Not registered, the server is stopped, and the typed degradation mcp_tools_changed:<server> is surfaced; the gate runs after discovery, before registration, on deferred notifications/tools/list_changed refreshes, and on reconnect/refresh; global ~/.luna/mcp.json servers are user-owned and are not gated.

A definition change produces a new approval key; its prompt lists the changed field names only (never env/header/auth values).

Project extensions

A repo’s .luna/extensions/*/extension.lua is repo-shipped code. It loads only with a source-bound extension- record:

the record binds the canonical manifest plus the sorted content hashes of every .lua under the extension directory; the loader passes the exact extension.lua bytes it is about to execute into the consent call, so a rewrite between approval and load cannot slip through; any manifest or source edit re-asks. Without a record and a TTY the extension is refused and reported in the failed list; the scanner and sandbox env remain defense-in-depth; user-level ~/.luna/extensions is user-owned and unaffected.

MCP elicitation

Server-initiated elicitation/create requests are operator-mediated:

the client advertises the capability only when the manager registered a handler (mcp_elicitation_enabled defaults ON); params are redacted and capped before any event/log; URLs are displayed, never fetched; tokens are never logged; default/headless is decline. An in-process responder may accept, decline, or cancel — there is no auto-accept path.

What a repository can never change

Write or replace an approval record (the store is under the user’s home, never the repository; repo-writable markers are ignored). Get a corrupt, truncated, foreign-hash, foreign-kind, or unknown-version record treated as approval. Apply a security family or start a project MCP server / extension without a matching record in a headless session. Redirect classifier or provider traffic without the trust- record. Change an approved extension’s source or an approved MCP server’s toolbox without a re-ask. Make elicitation auto-accept, fetch a server-supplied URL, or log a credential.

Operator notes

Re-approve by running Luna interactively in the project once. Inspect records with any JSON reader under ~/.luna/approvals/; delete a record to revoke that approval (the next interactive run re-asks). client/tests/test_consent_unification.lua, test_mcp_approval_renewal.lua and test_mcp_elicitation_operator.lua pin these contracts. The ci/luna_consent_lint.py census (with ci/luna_consent_registry.json) fails if a security family loses its consent row, if any module outside the store constructs an approval path, or if the extension source binding disappears; its CI manifest wiring lands with the next lint-suite batch.