Sandboxed Plugins

Experimental, under active development. Use sandboxed plugins for experiments only, never for anything a site depends on: the manifest, the call contract and what a plugin can reach may all change without a compatible path. They are switched off on every site until a superadmin turns on Allow sandboxed plugins (sandboxed_plugins_enabled, on the Settings page); see The switch.

A sandboxed plugin reaches the platform only through the doors its manifest declares: nothing in its folder is ever included by the site's PHP, and it can do nothing its manifest does not say. Native plugins (PHP, plugin.json) are described in the Plugin Developer Guide; this page is the other kind. The design and its decisions are in the spec plugin_tiers.md.

Its code runs in a fence, one process per call. src/plugin.php is PHP, started by core under joinery-jail as the plugin's own Unix user, with no network, no database, no config file and nothing writable; it reaches the site only by asking core over its standard input and output, and core carries each ask out with the plugin's approved reach (the spec sandboxed_php_plugins.md). See Calls. Where the fence is not installed, or the plugin's user is not made yet, a call is unavailable and says why.

What one is

A folder in plugins/ holding exactly two entries and nothing else:

plugins/notifier/
  manifest.json      what the plugin is and may do
  src/               the plugin's code

manifest.json is a regular file and src/ a real directory; neither may be a link. The platform reads nothing from src/. The kind is always read from the folder's contents (SandboxPlugins::isSandboxedDir()), never from what a package or a row says about itself: a third entry, or a plugin.json in place of the manifest, makes it a native plugin, judged as one. Native plugin loading skips a sandboxed folder (PluginHelper::getAvailablePlugins()), so nothing in it is ever included.

A sandboxed plugin is a row in plg_plugins like any plugin and moves through the same lifecycle on the Plugins page (install, activate, deactivate, uninstall). PluginManager hands the steps that would read a native plugin's PHP or plugin.json to SandboxPluginManager.

Writing one

Start from the sample, docs/examples/notes_sample/: a model of its own (Note, a regular model file in src/data/notes_class.php with a method and a rule of its own), a plain admin page that lists and adds notes (src/admin/notes.php), a member page using a setting and an own-rows grant (src/views/mine.php), a framed board with its own script calling one handler (src/views/board.php), an API action that adds a note (src/logic/add_logic.php), and src/plugin.php answering the signal, the schedule and the board's call. tests/functional/sandbox/sandbox_sample_plugin_test.php runs it.

plugins/notes_sample/
  manifest.json          what it is and may do (the manifest, below)
  src/plugin.php         on_ui(), on_signal(), on_schedule()
  src/admin/{slug}.php   an admin page it draws
  src/views/{slug}.php   a member page it draws (or a framed page's document)
  src/data/{table}_class.php its models, one file each (see Data)
  src/logic/{action}_logic.php its API actions, one file each (see Its own API actions)
  src/includes/          its other classes, found by name
  src/assets/            images its pages show (assets/NAME)

Write it the way a native plugin is written: models (new Note(), new MultiNote([...])), Globalvars::get_instance()->get_setting() for its own settings, SessionControl::get_instance() for who is viewing, FormWriter or plain HTML for forms. What it cannot do (raw SQL, a session write, the config file, the network beside an approved host, mail without send_email, uploads without accept_uploads) fails with a message that says so; each part is under Calls.

The author's command, utils/sandbox_plugin.php:

php utils/sandbox_plugin.php validate docs/examples/notes_sample      any site: shape, manifest, this site
php utils/sandbox_plugin.php load docs/examples/notes_sample          a dev site: install, approve, activate
php utils/sandbox_plugin.php call notes_sample page mine --as=USER_ID a page, and its body as core shows it
php utils/sandbox_plugin.php call notes_sample ui pin '{"id":1}' --from=frame --page=board --as=USER_ID
                                                                      a framed page's handler, as its script calls it
php utils/sandbox_plugin.php call notes_sample signal account.signup '{"user_id":1}'
php utils/sandbox_plugin.php call notes_sample schedule tidy
php utils/sandbox_plugin.php call notes_sample action add '{"text":"hi"}' --as=USER_ID   one of its API actions, as that user
php utils/sandbox_plugin.php log notes_sample                         its last calls, with each ask

On a dev site the plugin's code runs in the fence once its user exists (a minute after load puts the folder in plugins/); until then a call says it is being set up.

The switch

The setting sandboxed_plugins_enabled is off by default (SandboxPlugins::enabled()). While it is off:

  • an uploaded sandboxed zip is refused, by the Plugins page and by the root installer, and the upload box does not mention the kind;
  • a sandboxed folder already in plugins/ cannot be installed, approved or activated; each refusal says the kind is switched off and where to allow it;
  • utils/sandbox_plugin.php load is refused the same way.
A plugin that is already active keeps running, and can be deactivated or uninstalled; turning the setting off stops new use, it does not stop a running plugin.

A shared host refuses them whatever the setting says. Where the host's restrictions file refuses unsigned packages (HostRestrictions::has('unsigned_packages'), a multi-tenant host), SandboxPlugins::enabled() is false: nothing is uploaded, installed, approved or activated, every call is unavailable (SandboxRunner), and the refusals and the upload box say the server is shared (SandboxPlugins::offMessage()). Every sandboxed plugin is unsigned.

The manifest

SandboxManifest parses and validates it. Every name that becomes a class, table, column, URL or setting is held to a strict pattern there, so nothing a manifest says can be code.

{
  "name": "notifier",
  "id": "3f9a1c2e7b4d4e0f9a6b8c1d2e3f4a5b",
  "title": "Notifier",
  "version": "1.0.0",
  "description": "Posts chosen signals to a chat webhook.",
  "author": "Example Ltd",
  "platform": 1,
  "permissions": {
    "actions": ["notification_unread_count"],
    "records": {"EventRegistrant": ["read"]}
  },
  "signals": ["event.registered"],
  "schedules": [{"name": "digest", "frequency": "daily", "time": "08:00"}],
  "outbound_hosts": ["hooks.slack.com"],
  "settings": [
    {"name": "webhook_url", "label": "Webhook URL", "type": "url", "secret": true}
  ],
  "admin_pages": [{"slug": "log", "title": "Sent messages", "sections": [
    {"type": "table", "model": "SentLog", "columns": ["create_time", "signal", "message"], "order": "-create_time"}
  ]}],
  "menu": {"title": "Notifier"},
  "limits": {"memory_mb": 16, "timeout_ms": 5000}
}

KeyRequiredRule
nameyesThe folder's name. 2-20 characters of a-z and 0-9, starting with a letter, words joined by a single _ (no __, none at the end); not one of PluginManager::RESERVED_NAMES (core and the system's URL segments)
idyes32 characters of 0-9 and a-f, made once when the plugin is first written (php -r "echo bin2hex(random_bytes(16));") and kept the same in every version. It is what tells an upgrade from a different plugin of the same name (see Installing)
titleyesAt most 80 characters
versionyesx.y.z
platformyesThe platform API version the plugin was built for (SandboxManifest::PLATFORM_VERSION is this site's)
description, authornoText, at most 1000 and 120 characters
permissionsnoactions: action names it may call. records: model class → verbs (read, create, update, delete) it may use on models outside the plugin; File takes read, update and delete (see Files)
signalsnoSignal names delivered to it
schedulesnoname, frequency (hourly, daily, weekly), time (HH:MM, daily and weekly), day_of_week (0-6, weekly)
outbound_hostsnoHostnames it may call over HTTPS: no scheme, port, address or wildcard
send_emailnotrue when it sends mail (see Mail); true or false only
accept_uploadsnotrue when its drawn pages take uploaded files (see Files); true or false only
settingsnoname, label, type (text, textarea, number, boolean, select, url, email), secret (text and url only, no default), default, required, options (select), help
admin_pages, profile_pagesnoslug, title, sections (text, table, form, settings); a profile page holds no table or settings
public_pagesnoPages anyone can open (see Public pages): what a profile page holds, plus cache (true or false, default true) and cache_query (up to 10 query names, each cached apart); a slug a profile page also uses is refused
A form field may not be named plugin, page, action, section, website_url, antispam_question, antispam_question_answer, h-captcha-response or g-recaptcha-response: the site uses those names on the form itself. | menu | no | title: one admin menu entry holding a link to each admin page | | limits | no | memory_mb (default 16) and timeout_ms (100-10000, default 5000) for each call. A call gets at most the memory the site gives a page request (memory_limit of the web server's PHP, 128 MB unless the site sets otherwise; SandboxManifest::memoryCeilingMb()), which is what a native plugin's code has; asking for more gives that |

Any key not listed is refused, so a misspelling is an error rather than a silently ignored declaration. A plugin's models are not in the manifest: they are model files (see Data), and a manifest with a models key is refused, pointing there.

Data

A sandboxed plugin declares its models as a first-party plugin does: one regular model file each, in src/data/, named for its table.

<?php
// src/data/sent_logs_class.php
class SentLog extends SystemBase {
	public static $prefix = 'snt';
	public static $tablename = 'snt_sent_logs';
	public static $pkey_column = 'snt_sent_log_id';
	public static $access_class = 'content';

	public static $field_specifications = array(
		'snt_sent_log_id'  => array('type' => 'int8', 'is_nullable' => false, 'serial' => true, 'is_primary_key' => true),
		'snt_usr_user_id'  => array('type' => 'int8', 'is_nullable' => true, 'index' => true),
		'snt_signal'       => array('type' => 'varchar(100)', 'index' => true),
		'snt_message'      => array('type' => 'text', 'required' => true),
		'snt_create_time'  => array('type' => 'timestamp(6)', 'is_nullable' => false, 'default' => 'now()'),
		'snt_delete_time'  => array('type' => 'timestamp(6)', 'is_nullable' => true),
	);

	protected static $foreign_key_actions = array(
		'snt_usr_user_id' => array('action' => 'cascade'),
	);

	function prepare() {
		if (trim((string)$this->get('snt_message')) === '') {
			throw new RuntimeException('A message needs some text.');
		}
	}
}

class MultiSentLog extends SystemMultiBase {
	protected static $model_class = 'SentLog';
}

The site reads the file and never runs it. SandboxModelFile tokenizes each file in the parser jail (DocumentText::parseWith()), so the plugin's bytes meet PHP's tokenizer only there, and answers what it declares; SandboxModelDeclarations holds that to the allow-lists below and builds the declaration the site uses. Anything the sandbox cannot honour is refused at install, naming the file, the class and the thing; nothing is silently ignored. A box with no parser jail refuses the install. Inside the fence the plugin's code loads the same file as written.

What a file may hold. <?php, comments, one class extends SystemBase and its Multi{Name} extends SystemMultiBase, whose $model_class names it. A static's value is a plain literal: a quoted string with nothing joined into it, a number, true, false, null, or an array of these with literal keys; User::USER_DELETED is read as a delete rule's set_value. Refused, each naming the line: anything else at the top level (a require, a namespace, a use, declare(strict_types=1);, a function, a statement), text after a closing ?>, a trait, an attribute, a class constant, another base class, an interface, and a static that is a constant, a call, a joined or interpolated string or a heredoc. A file is at most 256 KB; a PHP file in src/data/ not named {table}_class.php, or a folder there, is refused (helpers go in src/includes/).

StaticRule
$prefixThree lowercase letters, unique in the plugin, not the prefix of any core or first-party model
$tablename{prefix}_ then a-z, 0-9 and single _. The real table is sbx_{plugin}__{tablename}
$pkey_columnOne of its columns, declared 'type' => 'int8', 'serial' => true
$field_specificationsAt most 40 columns, each {prefix}_…, at most 63 characters
$foreign_key_actionsSee Links below
$access_classRequired: a class in permissions.json
$read_permission, $write_permission, $delete_permission, $permanent_delete_permissionA whole number 0-10
$owner_columnfalse, or one of its int8 columns; left out, {prefix}_usr_user_id when it has one, as natively
$api_readabletrue or false
$api_writablefalse only: only the plugin's own code writes its rows
$api_unreadable_fieldsA list of its own columns
Every other static is refused by name ("SentLog::$sealed_fields is not available to a sandboxed plugin"), $api_public_read, $sealed_fields and $retention_policy among them, and so is any static of the author's own.

A column's specification may hold type, is_nullable, required, default, serial and is_primary_key (the key column only), unique, unique_with, index, index_with, allowed_values (at most 50 numbers or strings of at most 100 characters), zero_on_create, stamp_on_save, insert_only and access_class. type is one of varchar(1..2000), text, int2, int4, int8, integer, bigint, smallint, numeric(p,s) up to (30,10), bool, boolean, timestamp(6), timestamp, date, json, jsonb, matched whole. A default is a number, true or false, or a string; the one string written into SQL as it stands is now(), on a timestamp column. unique_with and index_with list the model's other columns. foreign_key (a database constraint) is refused: a link is declared in $foreign_key_actions.

Methods are the author's own and run only in the fence. Of SystemBase's, only prepare() and save() may be written: the site calls the others itself (permission checks, deletes, API answers) and could not run the plugin's. The Multi class holds $model_class and methods of the author's own; it writes no getMultiResults() (which is SQL) and overrides nothing of SystemMultiBase. It lists with the built-in query by the model's columns, as any collection with no query of its own does.

Plugin notifier, model SentLog
Class on the siteSbx_notifier_SentLog (MultiSbx_notifier_SentLog)
Tablesbx_notifier__snt_sent_logs
Columnsas the file declares them (snt_signal)
EndpointsGET/POST /api/v1/Sbx_notifier_SentLog, GET /api/v1/Sbx_notifier_SentLogs, PUT/DELETE /api/v1/Sbx_notifier_SentLog/{id}
Settingsbx_notifier__{name}
A plugin name has no __ and no trailing _, and a model's table name holds no __, so sbx_{plugin}__ splits a table exactly one way; a class name has no _ past the plugin's, so the last _ splits a class. Every class starts Sbx_ and every table and setting sbx_, which no core or native name does, with or without case, so a sandboxed model can never be, or shadow, another class. A model named like a core or native class (Post) is refused, since in the plugin's own code it would mean the site's.

Links. A key of $foreign_key_actions is one of the model's columns, and a rule holds action (cascade, permanent_delete, null, set_value, prevent), value (a set_value's number, string or User::USER_DELETED), and source_class or source_table where the column's name does not say what it links to. As natively, {prefix}_{their prefix}_{entity}_id links by its name, the plugin's own models first and then the site's (snt_usr_user_id is a user). A column whose name reads as a link and has no rule is refused, never registered as a guess. A link to another sandboxed plugin's table is refused. A rule's message is the platform's: a prevent reads "The plugin {title} holds {model} records for this."

Who may do what with its rows.

  • Only the plugin's own code creates and changes them, so its prepare() and save() run on every save. Its own requests (SandboxRecord::isOwnRequest(): its key, no member named) read, write and delete its rows whatever its API flags, are not held to the model's row and column levels (its code decides what each member may do), and may set the owner column, so it saves a row for the member in front of it. Anyone else who needs to change its data asks the plugin: its pages, or its own API actions.
  • Reading through the API follows the native rules where the file opens it ($api_readable): staff at the read level read every row, a member their own by the owner column, and a member's list is narrowed to their rows.
  • Staff delete a row (to the trash, through the API's DELETE) at the model's delete level; the row's owner gets no pass, since a member deletes their own through the plugin. A model with no {prefix}_delete_time has no API delete.
What a model opens beyond the plugin, and each prevent that can stop a site record being deleted, is part of what an admin approves (see Approval): until it is, the model is the narrower one (not read through the API, deleted only by a superadmin, no owner column) and the prevent is not registered. A prevent between two of the plugin's own models can stop a site record being deleted when that record's delete reaches the protected model through permanent_delete rules (a user's tasks deleted with the user, a task's notes refusing); it is approved as such, naming the site record. A cascade, null or set_value runs as SQL without the rows' own rules, so it carries no block. When an update makes a site record reach a prevent that was approved for another, the prevent is not registered at all until the new reach is approved: meanwhile that delete removes the rows it used to protect.

Where the declarations live. The checked declarations are kept on the plugin's row (plg_metadata._sandbox_models), with a sha256, size and time of each file. They are read and stored at install, at activation, at Sync with Filesystem and when an approval is given; opening the approval page reads them to show them and stores nothing. After that the stored copy is the only source: the classes, model discovery, the delete rules and the page of blocking rows work with the plugin's folder or manifest unreadable or gone. Before a call, core compares the files in src/data/ with what it stored (size and time first, a hash only when one differs); while they differ the call is refused with "its model files changed since the site last read them; sync the plugin".

Lifecycle. Install and activation make the tables and bring them up to the files as they stand; a column a file stops declaring is kept, as for a native plugin. The tables made are recorded on the plugin's row (plg_metadata._sandbox_tables). Deactivation keeps the data and the delete rules. Uninstall drops every table its declarations name or the row recorded (each held to the sbx_{plugin}__ pattern), with each one's id sequence (made without OWNED BY, so CASCADE would leave it), and the deletion rules that named them.

Its rows blocking a delete. A record of the site with a plugin's rows linked to it by an approved prevent cannot be permanently deleted, as with a first-party prevent; the rule counts the plugin's deleted rows too. An admin can always see and remove those rows: the refused delete (a user's permanent delete page) links to the page of the rows that block (/admin/admin_sandbox_blocks, SandboxBlockingRows), and so does the plugin's row on the Plugins page ("Rows that block deletes"), whether the plugin is active, inactive or its folder gone. The page lists the plugin's blocking links with how many rows hold a link now, and a link's rows (for one record or all), each with a Delete permanently button, at the model's permanent delete level. A delete there is permanent_delete() on the site's own class, so the plugin's own rules apply. The dry run of a delete names each blocker by table, column and record (blockers), a blocker on a record the delete would remove among them.

How the classes exist. No file of a sandboxed plugin is included, so SandboxModels declares each model's class and its Multi collection at run time from one fixed template, with only the class name inserted, after it has been held to SandboxModels::CLASS_PATTERN twice, and fills their statics from the stored declaration (SandboxRecord::sandboxFill()). This is the one eval in the codebase; tests/unit/sandbox_models_test.php fails if another appears, or if any class or table in the tree starts with the sandboxed prefix. An active plugin's models resolve by name through ClassAutoloader like any class; one plugin's resolve through SandboxModels::classesFor() (its install and uninstall), and model discovery over many plugins (schema and deletion work) takes the installed plugins whose declarations are stored, so a folder merely sitting in plugins/ declares nothing. A sandboxed model is left out of the deletion system's prefix map, so a plugin's prefix never becomes a candidate for a core column's link, and registers its declared rules only.

Installing

A sandboxed plugin is uploaded as a zip on the Plugins page, exactly as a native one is. The zip holds manifest.json and src/, at its top or in one folder. PluginManager and the root installer (utils/install_extension.php) read the kind from the contents (SandboxPlugins::isSandboxedDir()):

  • the manifest is validated on root's own copy before anything moves, and its name must be the folder's;
  • it is handled as code. A package our release key did not sign is refused on a host that refuses unsigned packages (HostRestrictions), and elsewhere installs only on the owner's acknowledgement of the unsigned warning, with every superadmin emailed. Its row records plg_trust = 'sandboxed' and the event log sandboxed_package_installed, naming who approved it;
  • it is listed as code that is not ours: on the Updates page under Not signed by Joinery, and in the vault health row for unsigned plugins and themes (VaultHealth::checkUnsignedExtensions());
  • it carries no fork mark: no release ships a sandboxed plugin, so a deploy always keeps one (DeploymentHelper::preserveReason());
  • the code check counts an unsigned one as unsigned code (PackageSignature::verifyTree(), utils/verify_package.php --tree).
The publishing box (the site holding the release signing key) takes no uploaded zip, since its plugins are its source tree. A sandboxed plugin is written into its plugins/ and installed from there: recorded plg_trust = 'sandboxed', refused while the switch is off, and with no email to superadmins.

Uploading a new version of an installed plugin replaces it like any package. When the plugin is active, everything it owns follows the new manifest at once, within what was approved (below).

An upgrade has the same id. A package over an installed sandboxed plugin is an upgrade only when its manifest id is the installed one's; one with another id is a different plugin and is refused, when it is staged and again by root before anything moves: "A different plugin named notifier is installed; uninstall it first." (PluginInstallIdentity::installRefusal()). An installed copy whose manifest has no id takes the package's. Nothing in a package is secret, so the id tells two unrelated plugins of one name apart; it does not stop someone copying a real plugin's id.

One install, one id. Each install of a plugin has an install id (plg_plugins.plg_install_id, see the Plugin Developer Guide). What a sandboxed plugin keeps past its uninstall is keyed by it: the files it kept (fil_install_id) and its call log (sbl_install_id). A later plugin installed under the same name has a new id and reaches neither. A fresh install also removes any setting or table under its own prefix (sbx_{name}__) that no install's ledger holds, so it starts with its own defaults and empty tables, never an earlier install's.

Each member's own records. permissions.own_records, beside records, asks for each member's own rows of a personal model: {"Order": ["read"]}. The model must be one the API reads, not public content, with an owner column (SandboxCompatibility::ownRecordsProblem()). The key gets Order:read:own. When the plugin's code asks for such a model during a page or form call, core's relay names the member that call is for (header X-Joinery-Sandbox-Viewer, from core's envelope, never from the plugin), and the API acts as that member at member level whatever their own level: rows and lists are theirs alone (a list is narrowed in the query, so its count is theirs too), and a row it creates is theirs. An admin viewing the page is treated the same way. A signal or a schedule has no member viewing, so an own-rows ask is refused there. The API accepts the header only on a sandboxed plugin's key from this machine, and with it admits only the plugin's own-rows entries. A plugin that also holds records on the model reads all rows instead.

An admin page of a plugin that holds every row of a personal model is shown only to a viewer who may read that model at its own level.

Approval

A sandboxed plugin can do nothing until a superadmin approves what it asks for. Until then the Plugins page offers Review and activate in place of Activate, and PluginManager::activate() refuses it (SandboxApprovalNeededException). The review page (/admin/admin_sandbox_approve?plugin=<name>) lists, in plain words (SandboxConsent::describe()):

GroupFrom the manifest
Records it may use, one group per feature that owns the modelpermissions.records
Each member's own recordspermissions.own_records
Read this program codethe native plugins whose models it reads (the fence reads their includes/ and data/)
Run these site actionspermissions.actions, with each action's description
Be told when these happensignals, with each signal's label
Run on a scheduleschedules
Send data to these websitesoutbound_hosts
Send emailsend_email: to any address, through the site's mail service, from any sender address it accepts (never a protected mailbox domain), using the site's email templates
Accept uploaded filesaccept_uploads: on its own pages, from the person viewing; each file kept in that person's account, private to them and admins; it reaches only the files it kept
Add these pages to members' menusprofile_pages, saying which have a form members fill in and which the plugin draws
Pages anyone can open, signed in or not. What they show and do runs with the access approved herepublic_pages, saying the same of each
Open its own records beyond the pluginits model files: each model read through the API, a read or delete level below its class's, each member reading their own rows
Stop the site's records being deleted while it holds rows for themits model files: each prevent on a site table
Let the site's AI assistant run these of its actions without asking firstits action files: each with ai_agent set to auto
Warningpersonal records (all rows or own), or the files people upload to it, beside outside websites or email: it could send them off the site
and, as its own, its models (one line each: who may read it and what it is linked to, from its files as they are now), its admin pages, its API actions (one line each: who may call it, and whether the AI assistant may run it after asking or without asking) and its settings. A record grant reaches every record of the model ("All users: read only"), since the plugin's credential acts as an admin; each signal says what personal data it carries. Approve and activate records the approval (SandboxConsent::approve(), kept on the plugin's SandboxInstall row with who approved it and when) and activates the plugin, in one transaction. The button carries a digest of what the page showed (reviewDigest()): a plugin replaced between showing and approving is refused, to be reviewed again.

What a plugin may do is what its manifest asks for and the approval covers (SandboxConsent::effective()). A newer version asking for more keeps what was approved and nothing more (a member page it adds is not shown); the Plugins page marks it Waiting for approval, and the review page lists what is new. An approval stands while the admin who gave it is a superadmin, not disabled and not deleted: demoting, disabling or deleting them switches the plugin's key off at once and ends the approval (SandboxCredentials::lapseApprovalsOf(), from User::save() and User::soft_delete(); a permanent delete takes the key with the account). The plugin then waits on an admin's approval, which mints a key as that admin. Restoring the admin does not bring the ended approval back; they may approve it again like anyone else. Another superadmin may approve an approved plugin as themselves (*Approve as me*), which moves its credential to them.

Compatibility

The API actions, the signal catalog and the manifest's page and field types are a promise to plugin authors: additions are always allowed, and a change that breaks an existing one raises SandboxManifest::PLATFORM_VERSION. Install and activation refuse a plugin built for a later platform, or one that needs an action (or a machine-callable one), a model, a record verb the API allows, or a signal this site does not have, naming each (SandboxCompatibility::problems()).

They also refuse a sandboxed plugin that has a native plugin's name: one in the publisher's catalog (as far as the site knows it, from its day-old copy) or a plugin.json folder on disk. Core checks a native plugin by name (PluginHelper::isPluginActive()) meaning its PHP is there, and a sandboxed plugin never answers that question; the few questions about a plugin of either kind (its declared settings, its API models, its secrets) ask PluginHelper::isActiveOfEitherKind().

What an active plugin owns

SandboxPluginManager::reconcile() brings all of these up to the manifest, within the approval, on activation, on each approval, and when an active plugin's files are replaced.

Its credential (door 1). A machine API key (SandboxCredentials) scoped to exactly the approved actions and record verbs plus every verb on its own models, owned by the approving admin and acting as them, usable from this machine only (127.0.0.1, ::1). Its secret is sealed on the SandboxInstall row (sbi_sandbox_installs.sbi_api_secret, a regenerable sealed secret whose recipe mints a new key) and put in the envelope of every call. Each approval mints a new key and deletes the old. Deactivation switches it off; uninstall deletes it. The key pages show it as the plugin's and refuse to delete it or reset its secret.

Its signals (door 2). One SignalReceiver of kind sandbox naming the plugin (sgr_plugin) carries the approved signals. Signals queue and retry on the same delivery queue as webhooks (SignalDeliveryQueue), and the drain makes each an on_signal call. A call that comes back unavailable, busy or timed out is retried on the queue's backoff, and the plugin is not tried again in the same pass.

Its schedules (door 3). One SandboxScheduledRun row per approved schedule, tagged with the plugin's name (so it is suspended and resumed with the plugin and removed at uninstall), at the manifest's frequency and time in the site's time zone, configured {plugin, schedule}. Each run is an on_schedule call; one that does not come back ok is the run's error. The task is never offered for activation on the Scheduled Tasks page (`"activated_by_hand": false in its .json`).

Its settings and pages (door 4), below.

Its Unix user. Every sandboxed plugin folder on the machine has a user of its own, jpx-NAME, kept by the parser jail's installer (install_parser_jail.sh) at each root moment: no shell, no home, no file anywhere, primary group joinery-jpx, a uid above a high-water mark in /var/lib/joinery-jail/jpx_uid_mark so no uid is ever handed out twice, and removed a week after no site on the machine has the plugin's folder. At most 20 are made per run and 200 exist at once. The launcher runs a plugin as that user (joinery-jail --user=jpx-NAME) inside the allowlist fence described in docs/document_text.md § The parser jail, with no scratch folder.

Pages and settings

A page with sections in the manifest is drawn by the platform from them. A page with none is drawn by the plugin's own view (a plain page; below). Admin pages are at /admin/admin_sandbox_page?plugin=<name>&page=<slug> (permission 8), linked from one admin menu entry titled by menu.title. Profile pages are at /profile/sandbox_page?plugin=<name>&page=<slug>, each an entry in the signed-in member's menu (slug sbx-<plugin>-p-<page>, apart from the admin entries' sbx-<plugin>-<page>). A member page's logic is logic/sandbox_page_logic.php, which is also the API action sandbox_page: an app submits a form with {plugin, page, section, values: {field: value}} and gets the plugin's answer back as result `{ok, status, lines, errors}`. Sections:

SectionShows
textIts words
tableRows of one of the plugin's own models (model, its class name): columns (its columns, with or without the prefix, checked against its model file at install), order (a column, - for descending; newest first by its key when left out), limit
formIts fields; a submission is the plugin's handler to answer
settingsThe plugin's settings, saved by SettingsWriter
Settings. Each manifest setting is a declaration like any other, named sbx_<plugin>__<name> (SandboxSettings), grouped under the plugin's title, seeded on activation and removed at uninstall. Only an installed plugin's manifest declares settings; a folder alone declares nothing. url and email settings are validated as such, number as a number, and a secret one is a credential field. They go in each call's envelope by their manifest names, secrets opened.

Forms. A form posts its fields as sbx_<field>; only the declared fields are sent, as an on_ui call. Its answer is `{message, errors: {field: message}, status}`; the page shows the message, or the errors, as text. A UI call is given at most SandboxHost::UI_TIMEOUT_MS (5 s, or less if the manifest's limit is lower); at most SandboxHost::UI_SLOTS (2) such calls run at once per site, and one per person (locks in {site root}/cache/sandbox/). Past any of those the page says the plugin is busy or did not respond; a call that could not be run shows why.

Plain pages, drawn by the plugin. A page declared with only slug and title is the plugin's own view: src/admin/{slug}.php for an admin page, src/views/{slug}.php for a member's, run in the fence as an on_page call (SandboxHost::page(), the UI call's bounds; logged as kind page) after src/plugin.php when there is one. What the view echoes is the page's body. SandboxPage gives it the request: isPost(), field($name), query($name), $input ({page, kind, method, query, fields, user}), and lets it set title($text) or ask for redirect($page, $query), honoured only to another of the plugin's own pages of the same kind.

Core cleans the body before showing it (SandboxHtmlCleaner, run in the parser jail through DocumentText::parseWith()), with PHP's HTML5 parser and an allowlist: text structure, tables, lists, links, images, forms and their controls, title, lang, dir, each element's own attributes, and class only from the kit's content classes (SandboxHtmlCleaner::CLASSES: buttons, tables, form rows, alerts, badges, text). autocomplete keeps on and off only. Everything else is dropped with its contents, script and style among them, and no id, style, on*, data-*, form, formaction, srcset or name outside a control survives. Links keep http:, https:, mailto: and relative addresses. Every form posts back to the page itself, by GET or POST, and the post reaches the view as fields; a GET form is given the page's own plugin and page as hidden fields (a GET submit replaces the action's query). No password input survives, and a file input only in a POST form of a plugin approved to take uploads (the form is then sent as multipart/form-data; see Files); nor does a control named _csrf_token, plugin, page, action or section, and the page logic takes the plugin and page from the address only, never from a posted body. An image is the plugin's own file, assets/NAME (served by core from src/assets/ at /sandbox_asset?plugin=&file=, PNG, JPEG, GIF or WebP, to anyone (a framed page's document loads them with no cookies), no link and no path out), https on one of its approved hosts, or, for a plugin approved to take uploads, a plain path under /uploads/ (a file it kept, served only to whoever may see it); any other is dropped. The cleaner parses its own output again and refuses the page unless nothing changes. The page carries a line naming the plugin that drew it (SandboxPages::provenance()), and the body sits in a box that asks the browser to keep everything in it (SandboxPages::bodyOpen(): contain: layout paint, overflow: hidden, so even a fixed element stays inside), whatever class its markup carries; held as far as each browser honours containment. The API action sandbox_page refuses a page the plugin draws: an app would show the body without the site's script policy.

A plain page is shown only where the strict script policy is enforced (enable_csp on, csp_report_only off, csp_strict_scripts enforce): elsewhere it says so and draws nothing. A member page drawn by the plugin is named that way on the approval screen.

Framed pages: its own script, in a sealed frame. A page with "frame": true (and no sections) is the plugin's whole document, drawn by the same view, script and styles inline, served uncleaned in a frame. The outer page (the admin or member page) holds an <iframe sandbox="allow-scripts"> of /sandbox_frame?plugin=&kind=admin|member|public&page= and core's bridge assets/js/sandbox-frame.js, and its frame-src names that route alone (PublicPageBase::restrict_frames_to()): every policy the page sends is narrowed, and one more is sent, enforced whatever the site's own policy settings say (Content-Security-Policy: frame-src the route), so the frame can be navigated nowhere else. The route serves only a same-origin frame load (Sec-Fetch-Dest: iframe, Sec-Fetch-Site: same-origin; opened directly it answers nothing), to a viewer who may open the page (SandboxPages::framedPage()), with SandboxPages::frameHeaders(): sandbox allow-scripts (another site to the browser, with no cookies of this one), default-src 'none', inline script and style, images from data: and /sandbox_asset, the kit stylesheet assets/css/joinery-styles.css as the one file it may load, no connect, form, frame or worker source, frame-ancestors 'self', webrtc 'block', no referrer, no cache. A document may be 4 MB. Core writes a doctype and one script of its own ahead of the document (SandboxPages::framePrelude()); it runs before any of the plugin's and removes the WebRTC constructors (RTCPeerConnection and its kin), which a browser that does not know the webrtc directive (Chromium) would otherwise let reach any STUN or TURN host. The frame has no other window to fetch them back from: it may not load a frame, open a popup or start a worker, and the outer page's frame-src stops it navigating itself anywhere but this route. The wall is held against the frame reaching this site (its cookies, pages, storage, API, the outer page) and against it sending data out, except DNS prefetch, which is not covered in every browser.

The frame's one way out is a message to the bridge, which acts only on messages from that frame's window and answers it alone: {type: 'sbx-call', id, handler, data} calls the plugin's own handler as the viewer (the action sandbox_frame_call, browser session only, a guest's for a public page only, answered by on_ui with values = data and source frame, kind and page), but only a handler the framed page lists in the manifest's handlers; an admin form's handler is never reachable from a member's frame and comes back as {type: 'sbx-answer', id, ok, output, message}; {type: 'sbx-height', height} sets the frame's height (100 to 20000 pixels). Nothing else is understood. A framed member page is named so on the approval screen, and a framed admin page is a grant of its own ("Run its own script in admins' browsers"), so a page that becomes framed waits on approval. Assets at /sandbox_asset need no sign-in: the frame loads them without the site's cookies.

Public pages

A page in public_pages opens for anyone, signed in or not, at the plugin's own address, /<plugin>/<slug>, where a native plugin's views open; /<plugin> alone opens its page index. An address is answered here only when nothing else on the site answers it (SandboxPublicPages::forPath(), reached from RouteHelper's view lookup), so a plugin never takes one of the site's pages, and a plugin's name is never one of the reserved names (PluginManager::RESERVED_NAMES). It is drawn as a member page is: from its sections, by the plugin's view src/views/{slug}.php (told kind public), or framed (/sandbox_frame?...&kind=public). Its view is views/sandbox_public_page.php and its logic logic/sandbox_public_page_logic.php, which is no API action. It carries the line naming the plugin, and takes no uploads. Each page is a grant: one not approved is a 404.

A signed-in visitor is the page's viewer, as on a member page. A visitor not signed in is no one: the call's user is null, so own-rows asks and uploads are refused, and the call is a visitor's:

  • It reads. A GET, a framed page's handler call and every other call for such a visitor may read, log and fill a template, and nothing else: a create, update or delete, an action, mail, an outside request or page.refresh is refused for that call.
  • A form it sent, once checked, may write a little. A POST of a form the site drew or cleaned first passes FormWriter's spam checks, each as the site's settings have it (the honeypot, answered with a 404; the anti-spam question; the captcha), before the plugin is called. The site puts those inputs at the end of each POST form itself, after cleaning, where the cleaner marked it with a token of the call's; their names (SandboxHtmlCleaner::SPAM_CHECK_NAMES) are core's, never drawn by the plugin nor handed to it. Such a call has the plugin's full approved access within three caps that hold even with every spam check switched off: 10 record writes, actions and page.refresh asks together (SandboxRelay::MAX_ANON_WRITES), 3 people addressed in all, To, Cc and Bcc (MAX_ANON_RECIPIENTS), each counted against the visitor's network at 10 an hour (sandbox_public_mail), and no email.batch.
  • Its own pool. Visitors' calls run in SandboxHost::ANON_SLOTS (2) of their own, never a member's slot, so no number of visitors makes a member's or an admin's page busy; one at a time per network (an IPv4 address, an IPv6 /64; locks anon_net_{0-63} in {site root}/cache/sandbox/); and SandboxHost::PUBLIC_CALLS_PER_MINUTE (60) a minute per network (sandbox_public_page). A call refused for any of these writes nothing; one that runs is logged with no user and the visitor's network (sbl_ip_network), and kept sandbox_anonymous_log_retention_days (2).
A visitor's GET goes through the static page cache as a native page's does: the bare address, or with only the query names cache_query lists (any other name is not cached), at most SandboxPublicPages::MAX_COPIES (200) copies a page, and never a page holding a POST form, a framed page, a draw that failed or was refused, or one with "cache": false. The frame's document is never cached. The plugin drops its own pages' copies as native code does, with StaticPageCache::invalidatePath('/<plugin>/<slug>'), which in the fence is the ask page.refresh, under its own address only and where writes are allowed. Installing, activating, approving, replacing its files, deactivating, a lapsed approval and uninstalling drop every copy under /<plugin>/.

Calls

Core never includes a sandboxed plugin's code. SandboxHost builds one envelope per call, carrying everything the call may use except a credential, hands it to the runner, and records the answer:

{
  "call_id": "c_…", "plugin": "notifier",
  "export": "on_ui | on_page | action | on_signal | on_schedule",
  "input": {},
  "limits": {"memory_mb": 16, "timeout_ms": 5000},
  "settings": {"webhook_url": "…"},
  "outbound_hosts": ["hooks.slack.com"]
}

outbound_hosts are the approved ones. The plugin's API key is never in it: core's relay opens the key when it carries out an ask. input per export: on_ui `{handler, values, user: {id, permission}}; action {action, values, user: {id, permission, timezone}}`, the permission being the level the request acts at; on_signal {signal, message_id, timestamp, data}; on_schedule {schedule, time}.

The runner. SandboxHost::$runner is a callable that takes the envelope and returns `{ok, output, error, timed_out, duration_ms, calls: [{door, target, status, detail}]}, or {unavailable: "why"}`. Null (the platform) means SandboxRunner::run(). A runner that throws or returns something that is not an answer is an error. Tests set a stand-in (sandbox_stand_in_runner() in tests/lib/sandbox.php).

SandboxRunner refuses (unavailable) on a shared host, where the launcher with the allowlist is not installed, where src/ is not a real folder, and until the plugin's user jpx-{plugin} exists (the root step makes it within a minute of a sandboxed folder arriving). Otherwise it starts

joinery-jail --user=jpx-NAME --watch-fd=3 --timeout=S --rlimit-as=B --read=<runner> --read=<src/>
    -- php -n -d enable_dl=0 -d extension=... -d memory_limit=NM utils/sandbox_php_runner.php <src/>

with the manifest's limits (address space: the memory limit plus 96 MB for PHP itself) and a fixed environment, and talks to it one JSON object per line. The first line it writes is the envelope. The runner script loads src/plugin.php and calls the function the export names, on_ui($input), on_signal($input) or on_schedule($input); what it returns is the call's output, and what it echoes is dropped. Plugin code asks core for things with SandboxPipe::ask($ask, $args), which writes one line and waits for core's answer ({ok: true, ...}; a refusal throws SandboxPipeException with the reason). The call ends with {"ask": "done", "ok": true, "output": ...}.

What the plugin's code finds. Before src/plugin.php loads, the runner boots core the way the document parser does (the real PathHelper, ClassAutoloader::restrictToCore(): core classes from includes/ and data/, no settings, no database) and fills three singletons with stand-ins (utils/sandbox_runtime.php, utils/sandbox_runtime_standins*.php):

  • Globalvars::get_instance()->get_setting() answers the plugin's own settings by their full sbx_{plugin}__{name} names, and by their manifest names too unless core declares a setting of that name (a plugin's debug answers only as sbx_{plugin}__debug), and the site's site_name, webDir, default_timezone, default_email_template (the outer template quickSend() names) and upload_web_dir (where File::get_url() points). Every other name is unset (null), a secret or not; config_file_setting() gives its default.
  • SessionControl::get_instance() answers who is viewing: get_user_id(), is_logged_in(), get_permission(), get_timezone(), and check_permission($level), which throws SandboxRuntimeException below that level instead of redirecting. The PHP session is the process's own, stored nowhere: nothing written to it outlives the call. A signal or a schedule has no viewer.
  • DbConnector::get_instance() gives an object whose every use throws "A sandboxed plugin has no database; use a model."
The plugin's own classes resolve from src/includes/ and src/data/, after core's, by their full names where a file declares a namespace: a class named like a core one never replaces it. Core code that catches an exception answers quietly in the fence, so a false from it is not an answer about the site: PluginHelper::isPluginActive() is false for every plugin there. Core classes that need only these work: FormWriterV2HTML5 draws a form (its database unique rule throws). Page classes (PublicPage) are not for the fence: core draws the page around what the plugin returns.

Models. In the fence SystemBase::$remote_store is set (SandboxRemoteStore, utils/sandbox_runtime_models.php), so model code reads like native code and each load, save, trash and list is an ask:

$event = new Location(12, TRUE);                                        // record.get
$note = new Note(); $note->set('nte_text', 'hi'); $note->save();        // record.create
foreach (new MultiNote(['text' => 'hi'], ['nte_qty' => 'DESC'], 50) as $row) { … }   // record.list
foreach (new MultiNote(['note_id' => [4, 9, 12]]) as $row) { … }                     // record.list, any of them

The plugin's own models are its model files, loaded as written (Note, MultiNote); the envelope's models maps each to the name the site knows it by (Note => Sbx_notes_Note), which each ask carries. Its methods are there, and its prepare() runs before a save is asked for. A class of the plugin's that extends one of its models saves to that model. A core or native plugin's model is read only if the plugin was approved for it; asking for another throws, saying so. Its native plugin's includes/ and data/ .php files are granted to the fence for that, so the approval screen lists that plugin's program code under "Read this program code". A model name that a core or native class already has (Post, Page) is refused at install (SandboxPluginManager::modelCollisions()): in the plugin's code it would mean the site's model. A collection takes column filters (one value each, or a list of up to 200 meaning any of them, as a column filter takes natively: the whole list is one ask, and an empty list matches no row without asking), deleted, one sort column, a limit up to 200 and an offset that is a whole number of pages; with no limit it is read 200 rows at a time. count() and count_all() work. Refused, each saying why: raw SQL, a string condition ("IS NULL"), a split-parenthesis OR, a NULL filter, an OR collection, two sort columns, undelete(), permanent_delete(), and a collection of the plugin's own that writes getMultiResults(). A collection of the plugin's that writes none and declares $default_options sends them as column filters on every list, so a default whose value is NULL is refused on every list, as any NULL filter is. Core runs every save with the checks any API caller gets. The plugin's own rules run in the fence first: a prepare() its code declares runs before the ask and may refuse the save, and an overridden save() runs as written; they bind only the plugin. On the site SystemBase::$remote_store is null and none of this applies.

Mail

A plugin whose manifest says "send_email": true, once an admin approves it, sends mail with the site's own classes, written as native code writes them (see Email System):

$message = EmailMessage::fromTemplate('welcome_email', $values)->to($email);
(new EmailSender())->send($message);
EmailSender::quickSend($to, 'Your note', '<p>Saved.</p>');
EmailSender::sendTemplate('welcome_email', $to, $values);
(new EmailSender())->sendBatch($message, $addresses);

In the fence EmailSender::remote() answers SandboxRemoteMail (utils/sandbox_runtime_mail.php), made at its first use however EmailSender's file was loaded, so each send and each template fill is an ask, and the site runs it with the same EmailSender and EmailTemplateRenderer: the site's From and Reply-To defaults, the protected identity domains, test mode and dry run, the retry queue, Joinery Direct. send() answers true or false and lastSendReport() what the site reported, as on the site, and the From and Reply-To that send() filled in are on the plugin's message after it (test mode's rewriting of the recipients and subject is not copied back). A template is filled on the site, where the templates are, so the renderer's getters answer after fill_template(). A missing template throws from fromTemplate(), sendTemplate() and quickSend() as on the site; with EmailTemplateRenderer used directly it throws from fill_template(), where on the site it throws from the constructor. A DateTime among the values crosses as a date and is formatted as on the site. A footer given as text (['body' => ...]) is filled on the site, outside the fence's limits, so it may not hold a {loop}; a stored footer may.

A message travels as EmailMessage::toTransfer()'s data. A file attached by path is read in the fence and sent as its bytes, so it can be only a file the plugin may read (its own src/); the site's side (fromTransfer()) takes an attachment only as bytes. A transport object is refused: the plugin sends through the site's mail service. The calls about the mail setup itself (the providers, their settings, validateServiceConfiguration()) need the provider's code and credentials, which are not in the fence, and fail there.

Each send is a line of the call log (door email): the first three addresses, how many more, and the subject. Without the approval every send is refused, saying the plugin was not approved to send email. On the site EmailSender::$remote is null.

Files

A plugin whose manifest says "accept_uploads": true, once an admin approves it, takes files on the pages it draws and keeps them with the site's own File class, written as native code writes it:

// src/admin/import.php, posted by <form method="post"><input type="file" name="doc">...
if (SandboxPage::isPost() && ($_FILES['doc']['error'] ?? null) === UPLOAD_ERR_OK) {
	$me = SessionControl::get_instance()->get_user_id();
	$file = File::createFromUpload($_FILES['doc']['tmp_name'], $_FILES['doc']['name'], $_FILES['doc']['type'], $me,
		array('fil_title' => 'Import'));
	$note = new Note();
	$note->set('nte_fil_file_id', $file->key);   // an int8 column of its own model, its link to the file
	$note->save();
}
$file = new File($note->get('nte_fil_file_id'), TRUE);
echo '<a href="' . htmlspecialchars($file->get_url()) . '">' . htmlspecialchars($file->get_name()) . '</a>';
$csv = $file->read_bytes();
$file->set('fil_title', 'Imported'); $file->save();
$file->soft_delete();
foreach (new MultiFile(array('fil_title' => 'Import')) as $f) { ... }
File::createFromBytes($report, 'report.csv', 'text/csv', $me);

A page call carries the request's files as $_FILES, in PHP's own shape (a name[] box is lists), at most 20, and SandboxPage::file($name) gives one box. The files come only through the plugin's own drawn pages, admin and member: a framed page posts nothing, and a section form and the sandbox_page API action carry no files.

In the fence File::remote() answers SandboxRemoteFiles (utils/sandbox_runtime_files.php), made at its first use, so making a file and reading one's bytes are asks the site carries out with the same File; new File(), MultiFile, save() and soft_delete() are the model layer's record asks, as for any model. The site holds every file to these rules:

  • it is kept in the account of the person viewing the page ($owner_id must be theirs; a signal or schedule call has no one, so it keeps none), private (its owner and admins see it, File::is_viewable()), and tagged sbx_{plugin}, which the admin Files page lists as "{title} files";
  • the plugin sets only fil_title and fil_description;
  • it reaches, lists, renames and trashes the files with its tag, and with a records grant on File (read, update, delete, each its own) every file on the site, which the approval screen says in those words. A Drive file is read only to it: Drive's own rename and trash keep every device in step and run only from a signed-in browser, so a rename or trash of one is refused. Out of its reach a file is not found. A grant needs no accept_uploads, but making a file does. File is not a model the API serves, so these asks are carried out by core's relay, not through /api/v1;
  • an upload's tmp_name is the site's own temporary path, taken back only when it is one of the request's uploads and PHP says it was uploaded; the fence cannot read that file, so a plugin that wants to look before keeping keeps it, reads it, and trashes it if it does not want it. A file it does not keep is deleted by PHP when the request ends;
  • read_bytes() answers a file's original and createFromBytes() takes bytes of up to half of the call's memory past the 6 MB the runtime holds (about 5 MB at the default 16 MB, 61 MB at 128 MB), since the bytes are held whole; they cross in 1 MB parts. A larger file is refused, saying the limit and how to raise it;
  • the site's own upload limits apply, and on a shared host its disk allowance.
Each file call is a line of the call log (door file). Without the approval every file call is refused, saying the plugin was not approved to take uploaded files, and a file input is dropped from its pages. A file it keeps carries its install id (fil_install_id), and its reach to its own files is by tag and install id together. The files stay when the plugin is uninstalled: they are the uploaders'. A later plugin of the same name has another install id and reaches none of them. On the site File::$remote is null.

Its own API actions

A sandboxed plugin's action is written as a first-party plugin's is (API, "Making a Logic Function Available via API"): a logic file per action, src/logic/{action}_logic.php, holding {action}_logic_descriptor() and {action}_logic($input), which returns a LogicResult. The sample's src/logic/add_logic.php:

function add_logic_descriptor(): array {
	return array(
		'description' => 'Add a note, written by the caller.',
		'mutates'     => true,
		'ai_agent'    => 'confirm',
		'auth'        => array('capability' => 'write', 'min_user_permission' => 5),
		'input'       => array('text' => array('type' => 'string', 'required' => true, 'max_length' => 200)),
	);
}

function add_logic($input) {
	$note = new Note();
	$note->set('nte_text', $input['text']);
	$note->set('nte_usr_user_id', SessionControl::get_instance()->get_user_id());
	$note->save();
	return LogicResult::render(array('note_id' => (int)$note->key));
}

It is called the way any plugin action is, POST /api/v1/action/notes_sample/add, with any credential its descriptor admits (a member's app session, a browser session, a machine key, a key scoped to this one action), and ApiLogicEndpoint runs it through the same steps: the auth block, the input schema (a 422 before anything runs), Idempotency-Key, the request log, the answer built from the LogicResult, the discovery listing (GET /api/v1/actions) and the admin page that scopes a key to named actions. First-party code calls one with SandboxActions::call($plugin, $action, $input, $user), which returns the LogicResult; the site's AI assistant offers one marked ai_agent, keyed {plugin}/{action}, at the tier approved.

The descriptor is read, never run (SandboxModelFile::readLogic(), in the parser jail, with the model files and at the same moments). The function is a single return of a plain array, and holds only:

KeyWhat it may be
descriptiona string of at most 300 characters (the AI assistant reads it as the plugin's words)
mutatestrue or false
ai_agentconfirm (the assistant asks first) or auto (it runs without asking; an approval entry of its own)
inputthe fields the API checks, in DescriptorValidator's words: type, required, label, description, default, enum, min, max, max_length, items, max_items
requires_settingone of the plugin's own settings, by its manifest name: the action is listed and callable only while it is on
authmin_user_permission (required: a level from 0 to 10, or a class and verb such as content:write), capability, requires_machine_key, requires_scoped_key, requires_person_credential, requires_browser_session
Refused, each naming the file: allow_guest (its public pages serve visitors), session_write, app_purpose, a {action}_logic_form() companion, a top-level function the site's own code declares (process_logic()), and anything else. A logic file with no descriptor is not an action and is not read. The checked descriptors are kept on the plugin's row (plg_metadata._sandbox_actions), and the site answers from that copy alone. An action that becomes auto in an update installs, and the assistant asks first until an admin approves it again.

The call runs in the fence (SandboxHost::action(), export action), in the page slots: one call per person, two a site, five seconds at most. The runner loads src/plugin.php when there is one, then the logic file, and calls {action}_logic($input) with $_POST holding the input. Only the fields the descriptor declares cross, at most 1 MB in all. SessionControl answers who is calling and the level the request acts at; the plugin's asks carry its own approved reach. Core rebuilds the LogicResult from the parts the runner sends back: data as JSON of at most 1 MB, redirect a path on this site (anything else is refused), the error at most 500 characters, and at most 50 validation errors of at most 300 characters each. A call that is busy or unavailable answers 503 and was never run, so its Idempotency-Key is released and a retry runs it; a timeout answers 504 and keeps the key, since the code may have run; a failure answers 500. Each call is a row in the call log, kind action.

A sandboxed plugin cannot ask for a sandboxed plugin's action (its own or another's) in permissions.actions: from inside its own fenced call it would wait for a second slot. Install refuses it, and the relay refuses the ask.

Webhooks

An outside service (a payment processor, a mail service) POSTs to the site when something happens. It is not signed in; it proves itself by signing the bytes it sent with a secret both sides hold. A webhook is an action whose descriptor says requires_session => false, with no auth and no ai_agent, as a first-party sessionless action is written:

function inbound_logic_descriptor(): array {
	return array(
		'description'      => 'Receives delivery events from the mail service.',
		'requires_session' => false,
		'mutates'          => true,
	);
}

function inbound_logic($input) {
	$secret = Globalvars::get_instance()->get_setting('webhook_secret');
	$sent = (string)($_SERVER['HTTP_X_SIGNATURE'] ?? '');
	if (!hash_equals(hash_hmac('sha256', SandboxRequest::rawBody(), (string)$secret), $sent)) {
		return LogicResult::error('Bad signature.', array('http_status' => 401));
	}
	// ... save what it says
	return LogicResult::render(array());
}

The service is given the address https://{site}/api/v1/action/{plugin}/inbound. The call carries the request's headers in $_SERVER['HTTP_*'], without Cookie, Authorization, Proxy-Authorization, the key headers and core's own X-Joinery-*, and its raw body, at most 1 MB, through SandboxRequest::rawBody() (in the fence php://input is the runner's own pipe). Content-Type and Content-Length are also CONTENT_TYPE and CONTENT_LENGTH, where native code reads them. The fields the descriptor declares are its input as for any action. A 1 MB body with full headers takes about 14 MB of the call's memory before the plugin decodes it: a plugin that takes large bodies raises limits.memory_mb in its manifest.

Each webhook is its own approval entry, "Accepts calls from anyone on the internet at /api/v1/action/{plugin}/{action}, and can change its records, call its approved websites and send mail when called"; until approved it is the same 404 as an action not there, so an update that adds one waits on an approval. It is never offered to the AI assistant or for scoping a key, and SandboxActions::call() refuses one: only its address runs it.

Core treats every call as from someone unknown, since it cannot tell a real service from anyone else who found the address; the plugin's own check runs after core has let the call in.

LimitValue
Calls at oncethe anonymous pool public pages use: two a site, one per network
Calls a minute60 per network (counted with public pages), and 300 per plugin from every network (SandboxHost::WEBHOOK_CALLS_PER_MINUTE)
Changes a call10: record create, update and delete, actions, page.refresh
Outside requests a call5
Mailat most 3 people a call, never a batch; 10 people an hour per network; 10 people an hour per plugin from webhooks
Filesnone read or stored
A refusal by a count answers 429 with retry_after_seconds, before the plugin runs; one that finds the pool busy answers 503. Neither writes a call log row; a call that runs is a row of kind action carrying the caller's network.

What a webhook cannot receive: an action answers POST only and a success is 200 in the API's envelope, so a service that first checks an address with a GET, or wants a bare text echoed back, cannot be set up; and a service that signs with the Authorization header cannot be checked, since it is not passed on.

The asks

Every ask the fence writes, and what core does with it:

AskArgumentsCore does
record.getmodel, idGET /api/v1/{Class}/{id}; answers record
record.listmodel, filters, sort, direction, limit (1-200), offset (a multiple of the limit)GET /api/v1/{Class}s; answers records, total
record.createmodel, fieldsPOST /api/v1/{Class}; answers record
record.updatemodel, id, fieldsPUT /api/v1/{Class}/{id}; answers record
record.deletemodel, idDELETE /api/v1/{Class}/{id}: to the trash, restorable; answers record
actionname, inputPOST /api/v1/action/{name}; answers data
httpmethod, url, headers, bodyan HTTPS request to an approved outbound host; answers status, headers, body (or body_base64)
loglevel, messagea line in the call's log
email.sendmessage, queue_on_failureEmailSender::send(); answers sent, report
email.batchmessage, recipientsEmailSender::sendBatch(); answers success, failed_recipients
email.renderinner, outer, footer, valuesEmailTemplateRenderer filled; answers subject, html, text, has_content, set_values
file.uploadtmp_name, name, type, owner_id, restrictionsFile::createFromUpload() of one of this call's uploads; answers record
file.bytespart (base64), more; on the last part name, type, owner_id, restrictionsthe parts gathered, then File::createFromBytes(); answers record
file.readid, offsetone 1 MB part of read_bytes() of a file it reaches; answers bytes (base64), size, next
page.refreshpath, with_childrenStaticPageCache::invalidatePath() of a path under /<plugin>/; answers removed
model is one of the plugin's own models by its class name (SentLog) or a core model it was approved for (Event). Record and action asks go to the site's own API over this machine's loopback, signed with the plugin's key, so every API rule applies as for any caller: the scope, the model's opt-in, the unreadable-column floor, per-row checks, the page cap, rate limits and the locked answer for sealed rows. The address is built from names checked against the key's scope and an integer id. A filter, a sort and a written field must each be a declared column of the model that the API shows (by its full name or without the model's prefix), or the deleted filter (true or false); a filter value is one string, number or true/false, or a list of up to 200 of them, sent as column[]=a&column[]=b. Anything else is refused before the API is called.

An http ask is https on 443 only, to a host the plugin declared and an admin approved, through SafeHttpClient: public addresses only, no redirects, answers up to 1 MB. No header that steers the connection (Host, Connection, Content-Length, Transfer-Encoding, User-Agent and the like) and no name or value with CR, LF or NUL. The call log names its host, never the rest of the address.

Caps on a call: one line up to 4 MB (a framed page's document; a plain page's body is cleaned to 1 MB), at most 200 asks, its time limit with the asks inside it. The conversation goes in strict turns: while an answer is unwritten, nothing more is read from the plugin. Core ends a run, at its deadline, at a refusal or just after its answer, by closing the launcher's watch pipe (descriptor 3), since it cannot signal the supervisor; a call that answered is answered whatever the plugin does after. The launcher must name watch-fd on its JOINERY_JAIL_FEATURES= line (2.1.0), which DocumentText::jailFeatures() reads, or every call is unavailable. A plugin's API requests are logged with rql_key sandbox:{install id} and left out of the loopback address's count, so one plugin cannot spend it for the rest. They have no request budget: the key is accepted only from this machine, and a plugin's load is bounded by its run slots, each call's time cap and its 200 asks a call. Over a container's plain HTTP the relay says X-Forwarded-Proto: https. What the process writes to standard error goes to the error log, capped and on one line. Signal and schedule calls run at most SandboxHost::BACKGROUND_SLOTS (2) at a time per site, beside the UI slots. A signal reaches the plugin through the delivery queue (SignalDeliveryQueue): one it is no longer approved for ends unsent; a busy or unavailable call is tried again without counting as an attempt; one plugin's calls may use SignalDeliveryQueue::$sandbox_share_seconds (10) of a drain pass before its rows wait for the next.

The author's command. utils/sandbox_plugin.php: validate (the folder's shape, the manifest, and this site's compatibility, from a folder, a manifest or a zip, on any site), and on a dev site (debug on) load (copy a folder into plugins/, install or update it, approve it as a superadmin, activate it), call (one ui, signal or schedule call, printing the answer and each door's use) and log.

The call log. Every call is a SandboxLog row: the plugin, the kind (ui, signal, schedule, test), the handler, signal or schedule, the outcome (ok, error, timeout, unavailable, busy), its message, how long it took, who asked (for a UI call) and what the plugin reached (calls, at most 200, each field cut to a set length), under the plugin's install id (sbl_install_id). Rows are kept sandbox_log_retention_days days (default 14). An admin reads them on the plugin's call log page (/admin/admin_sandbox_log?plugin=<name>, permission 8, from the Plugins page), filtered by kind or outcome: this install's calls only, never an earlier install's of the same name.