Skip to content
ERPForAll DocsDevelopment

    Command-Line Interface (erp)

    The erp CLI tool provides developer utilities for scaffolding new addons, managing module installation, upgrade, and uninstallation, and running the local development environment.

    The CLI is compiled as part of the ERPForAll workspace:

    Terminal window
    cargo build -p erp-cli --bin erp

    The erp scaffold command creates a complete addon skeleton conforming to the ERPForAll addon architecture (ADR 0001, ADR 0005, ADR 0009). Scaffolding generates files atomically into a temporary directory sibling, guaranteeing that failures leave no partial trees on disk. Destination paths that are symlinks, existing files, or non-empty directories are strictly refused.

    By default, erp scaffold generates a compiled Rust addon crate:

    Terminal window
    erp scaffold my_addon --summary "My custom sales module" --author "Your Name"

    This creates the following directory layout under ./addons/my_addon:

    my_addon/
    ├── Cargo.toml # Addon crate depending on erp-sdk
    ├── manifest.toml # Strict TOML manifest
    ├── src/
    │ ├── lib.rs # Library root with erp_sdk::addon! declaration
    │ └── models.rs # Models declared with #[model]
    ├── views/
    │ └── my_addon_views.xml # Form and list view architectures (<erp> root)
    ├── data/
    │ └── my_addon_data.xml # Initial seed data (<erp> root)
    └── tests/
    └── test_my_addon.rs # Integration test suite

    The generated Cargo.toml explicitly sets edition = "2024", license = "MIT OR Apache-2.0", and depends directly on erp-sdk = "0.1". src/lib.rs registers the addon via erp_sdk::addon!(name = "my_addon", depends = ["base"]);. src/models.rs imports erp_sdk::prelude::* and provides a model declaration template using #[model]. Summary and module name attributes are escaped so that quotes or non-ASCII characters never break the generated crate.

    The generated Cargo.toml references erp-sdk = "0.1", which is the intended published crate name on crates.io once ERPForAll reaches release. Until erp-sdk is published:

    • In-tree / CI tests (test_scaffold_build_cargo_check): Tests patch Cargo.toml with a local workspace path dependency (erp-sdk = { path = "../../crates/erp-sdk" }) and copy the workspace’s [patch.crates-io] entries (absolute paths) before invoking cargo check --offline. Required registry crates must already be available in Cargo’s local cache; a missing crate fails the test with Cargo’s offline resolution error.
    • External developers outside the repository: To build a scaffolded addon outside the main repository, adjust Cargo.toml to point to the local checkout path or git repository:
      [dependencies]
      erp-sdk = { path = "/path/to/ERPForAll/crates/erp-sdk" }
      # or via git dependency:
      # erp-sdk = { git = "https://github.com/IndoERP/ERPForAll.git" }
      # Required in both cases: ERPForAll builds against vendored, patched copies of two crates
      # (vendor/README.md), and Cargo applies [patch] only from the top-level workspace, never from a
      # dependency. Copy the [patch.crates-io] entries of ERPForAll's Cargo.toml with paths into your
      # checkout; without the tokio-postgres entry erp-orm does not compile (ADR 0055).
      [patch.crates-io]
      hyper = { path = "/path/to/ERPForAll/vendor/hyper" }
      tokio-postgres = { path = "/path/to/ERPForAll/vendor/tokio-postgres" }

    The generated manifest.toml is pre-configured with:

    • Valid technical module name my_addon matching ^[a-zA-Z0-9_]{1,256}$.
    • Initial version 1.0.0 (semver compatible per ADR 0009 §5).
    • License set to MIT OR Apache-2.0.
    • Core dependency depends = ["base"].
    • Declared data and view files that exist on disk.

    To create a data-only addon without a Cargo.toml or Rust code (ADR 0001, ADR 0009 §1), use the --data-only flag:

    Terminal window
    erp scaffold custom_tags --data-only --summary "Declarative tags for partner records"

    This creates:

    custom_tags/
    ├── manifest.toml # Addon manifest
    ├── views/
    │ └── custom_tags_views.xml
    └── data/
    └── custom_tags_data.xml

    Data-only addons declare views and data in XML/CSV per ADR 0019, requiring no Rust compilation step.

    The erp module command coordinates module lifecycle operations against a target PostgreSQL database. Without --dry-run it runs the operation through the module system (ADR 0022): one transaction per operation, as the superuser, with the same rules as button_immediate_install, button_immediate_upgrade and button_immediate_uninstall.

    Live runs need:

    • DATABASE_URL in the environment (URL or key=value form) for the credentials. The database is the one named by -d; the database in the URL is ignored. Credentials never come from the command line, and error messages never echo the connection string. Use the role that owns the database (it may create the trusted extensions the modules need), not a PostgreSQL superuser: module operations run hooks and data loaders as that role, and a superuser would give them rights they do not need.
    • A database the module system already initialized (it lists the addons, installs base). On an empty database the command fails with Database <name> not initialized and exit code 1; it never initializes a database for you.
    • Addons the erp binary can load: data-only addons (manifest, models in models/*.toml, data files). A manifest that names a hook (pre_init_hook and the like) needs the hook implementation linked into the binary; until you build a binary that links your addon, a hook-carrying addon is refused with no #[hook] implementation of it is linked.
    Terminal window
    export DATABASE_URL="postgres://erp@db.internal/postgres"
    erp module install -d production_db sale --addons-path ./addons

    prints what the operation did:

    Install completed:
    installed: base_setup, sale
    post-commit steps run: 0

    The first line of work is a plain load of the database (it also finishes an operation a crashed run left pending); the operation follows.

    CodeMeaning
    0Done.
    1The request was refused: unknown module, module not installed (upgrade), incompatible modules, protected module (base), uninitialized database, missing DATABASE_URL, invalid arguments, unresolvable dependencies. Nothing changed.
    2System error: database or I/O failure, broken invariant.
    3The database is busy: another module operation runs, or a lock or statement timeout hit. Run it again later. Nothing changed.
    4A step of the operation failed (hook, schema update, init(), data file, purge) and the operation was rolled back; the message names the module, the step and the cause. Nothing persists.
    5The operation committed, but its post-commit phase (index builds and the like) did not finish: the report lists the failed steps; they run again after the next module operation.
    Terminal window
    erp module install -d production_db sale account --addons-path ./addons --dry-run

    Options:

    • -d, --database <DB>: Target PostgreSQL database name (required, 1..=63 ASCII alphanumeric or underscore characters).
    • --addons-path <PATHS>: Comma-separated paths containing addon directories [default: ./addons].
    • --dry-run: Compute and display the resolved topological load order without applying database changes. Needs no connection.
    • --with-demo / --without-demo: the demo data choice. Without either, the install follows the choice the database was initialized with. --with-demo on a database without demo data first loads the demo data of every installed addon (as “Load demo data” in the browser does; it cannot be undone), then installs. --without-demo on a database with demo data is refused: demo data cannot be switched off. Upgrade and uninstall refuse both options.

    A live install marks the named modules and their uninstalled dependencies, then the auto_install modules their installation triggers; the report lists every module installed, in order.

    Terminal window
    erp module upgrade -d production_db sale --addons-path ./addons

    Upgrades the named installed modules and, as in Odoo, the installed modules that depend on them. A module that is not installed is refused (exit 1). Without a database, --dry-run has no module states to inspect: the plan conservatively marks dependencies of upgraded modules ToInstall.

    Terminal window
    erp module uninstall -d production_db sale --addons-path ./addons

    Uninstalling cascades to the installed modules that depend on the named ones (Odoo’s behavior); the report lists everything removed, so read it. Modules base, rpc and web cannot be uninstalled. A module whose records would be orphaned (records in models that stay installed) is refused until the data loader’s purge handles them. --dry-run has no database state: it conservatively refuses an uninstall when another addon on disk depends on the target.

    Upgrade and uninstall require an installed per-addon content receipt matching the admitted files. An unknown receipt refuses with identity unknown, run identity-enroll first; unchanged manifest versions do not approve changed bytes. Install creates a receipt atomically and uninstall removes it atomically. These rules also apply to protected/native addons; there is no legacy addon-name exemption.

    After reviewing an existing database’s artifact provenance, the operator explicitly enrolls its installed addons using the protected server configuration and owner connection:

    Terminal window
    erp module identity-enroll --config /protected/server.toml \
    --operator operator@example.test --note "Reviewed installed release provenance" base acceptance_notes

    Unlike ordinary module commands, this administration command takes the target and owner connection from --config; it does not take -d or --addons-path. Keep the configuration and owner credentials outside git and readable only by the operator. Enrollment requires between one and 64 unique installed addon names, an operator identity of one to 256 bytes and a reason of one to 4096 bytes. Identity and audit changes commit together; the audit records operator, timestamp, note and per-addon hashes. Enrollment is deliberate recovery authority, never a routine retry for a mismatched or unknown file.

    For the first identity-aware release over a legacy prepared release, use the candidate binary with identity-enroll --config /protected/server.toml --legacy-release /path/to/old-release --installed --operator operator@example.test --note "Reviewed installed old release". --installed and --legacy-release are paired and replace explicit addon names. This explicit bootstrap hashes the old release’s installed addon files, including files changed in the candidate, and records an atomic audit. It refuses an identity-aware previous release and a conflicting existing receipt. The ordinary enrollment command retains its native artifact attestation rules. Rehearse enrollment and forward upgrade on an isolated clone before performing the same steps on the target database; investigate any uncertain commit before retrying. A forward upgrade must select every installed addon whose candidate content differs from its installed receipt; omitting a changed addon refuses during lifecycle admission before upgrade effects or publication.

    identity-activate is the release helper’s internal publication command. It validates the explicit candidate and previous release receipts and a protected successful forward migration receipt; the candidate must already be active. After successful migration, switch and health, one lifecycle transaction retains unchanged identities and transitions changed ones. Runtime upgrade does not re-stamp. Automatic restore and manual rollback never re-stamp. If publication fails or its commit outcome is uncertain, inspect and reconcile the release and database state before another lifecycle operation; a failed command is not proof the transaction rolled back.

    Per-addon file identity is separate from the node configuration/build digest and from database schema compatibility. File-content identity authorizes lifecycle operations on addon artifacts; it is not a database schema-version check (that admission check is planned). See the lifecycle engine guide for the integration and recovery boundaries. Deployment operators should follow their protected release runbook.

    Module operations perform strict validation before making any changes:

    1. All technical module names are validated at CLI argument parsing time.
    2. Database names are validated against identifier constraints.
    3. Database connection credentials come exclusively from the DATABASE_URL environment variable, never from command-line arguments (argv).
    4. An AddonIndex scans the configured search paths.
    5. Transitive dependencies are computed and ordered using ModuleGraph in LoadMode::Update.
    6. If any dependency is missing or a dependency cycle is detected, the command fails loudly with exit code 1 and displays the cycle members or missing dependency.
    7. In --dry-run mode, the plan is returned without calling any database executor.
    8. A live run asks the module system, which checks the plan against the database’s own module states.

    The erp dev command validates configuration and discovers addons:

    Terminal window
    erp dev -d dev_db --addons-path ./addons --port 8069

    [!NOTE] The development server HTTP runtime and live reload are scheduled for M3 (erp-server). Running erp dev currently validates the configuration and addon paths and fails loudly naming M3.

    With -d, erp dev first registers in that database as a dev node (ADR 0057). When live non-dev nodes already serve the database it refuses with exit code 1 and names them (erp dev refuses to join a database served by live non-dev nodes: app-1 (host h1, pid 4242, app)), so a development process never joins a production cluster: use a development database. Until the HTTP server exists, the dev node leaves again at once.

    Every server process registers a row in its database and keeps it alive with a heartbeat (ADR 0057, spec docs/specs/node-registry.md). A node becomes ready only when its configuration, build and addons match the nodes that are already ready; otherwise it stays unready and says what differs. These commands connect with the DATABASE_URL role (the database owner) to the database named by -d:

    Terminal window
    erp cluster nodes -d prod # one line per node: name, role, state, fresh, host, pid, build, digest, lease end, id
    erp cluster rollout open -d prod --to <digest> --for 30m # let <digest> become ready next to the current one
    erp cluster rollout status -d prod
    erp cluster rollout close -d prod
    • A rolling upgrade opens a window from the running digest (--from; when omitted, the one digest the ready nodes run) to the new one (--to, the 64-hex digest the new node prints in its unready reason). Opening a window closes the one that was open. While the window is open, exactly those two digests may be ready side by side; when it ends or is closed, newcomers must match again.
    • --for takes <n>s, <n>m or <n>h, from 1 minute to 24 hours. A rollback is a window with --from and --to swapped.
    • Malformed digests and durations exit with code 1 before any connection. A refused window (the duration is out of bounds, --from equals --to, or --from is omitted while no node or nodes of several digests are ready) exits with code 1; a missing node table or a database fault exits with code 2.

    Two commands read and repair the access policy of a database, as the System principal (ADR 0035). The connection credentials come from DATABASE_URL (URL or key=value form, never echoed), the database from -d:

    Terminal window
    DATABASE_URL="postgres://erp@db.internal/postgres" erp access report -d prod

    report prints the policy generation and the build report of compiling the database’s rules: counts, every rule that cannot be compiled (it denies the operations it covers), capabilities declared in the binary without an ir_capability row (asking for them fails), rows naming no declared capability, and group implication cycles.

    Terminal window
    erp access disable-rule -d prod sale.sale_order_rule_portal

    disable-rule sets active = false on the rule with that external id, through the ORM (audit fields written, the policy change recorded for every process), and prints access rule <id> '<name>' on <model> disabled, or ... was already disabled when it was. An unknown external id, or one naming a record of another model, exits with code 1. ir.access itself is governed by permissions only, so this always works for an administrator.

    [!NOTE] The registry is composed from the addons linked into the erp binary (base and the external-id model); composing the registry of a given database (its installed modules and custom fields) comes with the HTTP server (planned).

    Terminal window
    erp db build-object -d prod --model booking.booking --object _no_double_booking \
    [--lock-timeout <secs>] [--build-timeout <secs>]

    Builds an exclusion constraint or WITHOUT OVERLAPS key on a table above large_table_rows, where the install refuses it (the build holds ACCESS EXCLUSIVE on the table: run it in a maintenance window). Credentials come from DATABASE_URL, as for erp access.

    • --lock-timeout is 1 to 3600 seconds (default 30). While the build waits for its ACCESS EXCLUSIVE lock, every new reader and writer of the table queues behind it, so choose a short timeout on a busy table.
    • --build-timeout is 60 to 86400 seconds (default 21600, six hours) and must be longer than the lock timeout. A statement that runs past it is stopped, nothing is changed, and the message names the object, the table and the limit.

    Prints a report with the statements that ran, or says the object is already present; exit code 1 for an unknown model or object, conflicting rows or a lock timeout. Details: docs/addon-guide/exclusions.md.

    Terminal window
    erp db init --config server.toml --admin-login admin --admin-password-file /private/admin-password [--with-demo | --without-demo]

    Installs base and web into the empty database of the configuration and creates the administrator from the login and the mode-600 password file; no default credential exists. --with-demo makes it a demo database: base gets demo data and every addon installed later gets its own (demo data). The default is --without-demo. The choice is stored on the database; on an initialized database the other choice is refused.

    Database copies: erp db drop, dump, restore, neutralize

    Section titled “Database copies: erp db drop, dump, restore, neutralize”
    Terminal window
    erp db dump --config server.toml -d erpforall --file /backups/erpforall.dump [--force-live]
    erp db restore --config server.toml -d erpforall_copy --file /backups/erpforall.dump [--replace] [--force-live]
    erp db neutralize --config server.toml -d erpforall_copy --password-file /private/throwaway [--physical-copy] [--unrecorded-identity] [--force-live]
    erp db drop --config server.toml -d erpforall_copy [--force-live]

    Each command acts on the one database named by -d. It connects with the owner connection of the deployment configuration (the same file as erp server --config); the configuration’s own database is not used, so one configuration serves for the database and its copies. Nothing these commands print contains a connection URL or a password, also not in an error.

    • A live database is refused. When a node of the database is running (its row in the node registry is not stopped and its lease has not expired), the command refuses and names the database and the nodes. Stop the server first. --force-live acts anyway; a drop then also ends the open sessions.
    • dump writes the PostgreSQL custom archive format to a new file created with mode 600. It never replaces a file; a failed dump removes what it wrote. Attachment content in the attachment store is not part of the archive.
    • restore first reads the archive’s table of contents; a file that is not an archive, or one this pg_restore cannot read, is refused and nothing changes. It then restores the archive into a new temporary database <name>_erp_restore (created like every ERPForAll database: from template0, encoding UTF8, collation C) and gives it the target name only when the restore succeeded. An existing database is refused unless --replace. After the archive restored (and the live check on the existing database passed again), the existing database is renamed to <name>_erp_replaced, the restored one takes the target name, and only then is the replaced one dropped; if the second rename fails, the existing database gets its name back. A bad archive therefore never costs you the existing database: a restore that fails drops the temporary database and leaves the existing one untouched. The name can have at most 50 bytes, so that both reserved names fit. When a database already exists under <name>_erp_restore or <name>_erp_replaced, the restore refuses and names it: a restore stopped before it finished, or one is running now. If none is running, drop the temporary one, and either drop the replaced one or rename it back to the target name, then restore again. When the target name itself is missing, the replaced database is the only copy of the original: the refusal tells you to rename it back to the target name, never to drop it. A failure message says what happened to the existing database: left untouched, its sessions ended by --force-live, or renamed away and back. Owners and grants of the source are not restored: the owner role of the configuration owns everything, so run erp db publish-grants with a configuration of the restored database before serving it. When an installed addon declares a SECURITY DEFINER function, publish-grants refuses it after a restore (its owner is then the owner role, not the definer role); no addon declares one yet.
    • drop removes the database. The attachment store, roles and other files of a deployment are not touched.
    • dump and restore run pg_dump and pg_restore (PostgreSQL 18 client programs, at least the server’s version). --pg-bin <dir> or the environment variable ERP_PG_BIN names their directory; without it they are looked up on PATH. A program that fails is reported with its own error and a pointer to these two settings (an older client than the server is the usual cause). The credential reaches them through their environment, never their argument list, and no PG* variable of your shell reaches them.
    • postgres, template0 and template1 are refused.

    erp db neutralize makes a copy safe to test on, in one transaction, and can be repeated:

    WhatWhy
    Scheduled actions switched offthey would run the copy’s business logic as if it were the original
    Every job held, except the job queue’s own clean-up of old dead letters and run historyscheduled messages and attachment store jobs must not act from a copy; the attachment store may be shared with the original
    Sessions removedthey were issued by the original
    API keys removedintegrations of the original must not reach the copy
    Login throttle rows clearedthey are keyed with the database secret that is replaced
    Every password replaced by the throwaway passwordnobody’s real password is kept in a copy; testers sign in with the throwaway one
    Database secret replaceda copy never shares the signing secret of the original
    database.neutralized = truemarks the database as a neutralized copy for you and your tools; nothing reads it yet, so a held job or a scheduled action can still be started again by hand

    neutralize refuses the database a copy was made from. A database records its physical identity (cluster and database number) the first time its attachment ownership work runs (the owner heartbeat, for example); a restored copy has another database number. When the recorded identity is the database’s own, the command refuses and changes nothing. A physical copy of the whole cluster (a base backup or a volume snapshot) carries the original’s identity: pass --physical-copy for it. A database without a recorded identity cannot be told from the original it may have been copied from, so the command refuses it too and says so. Pass --unrecorded-identity only when you know the database is a copy; the command then prints a line saying the identity check was skipped.

    The throwaway password is read from a mode-600 regular file (--password-file, at least 12 bytes) and is never printed. Users without a password stay without one. The table is the whole list: an addon cannot add a neutralize step of its own yet, and outgoing mail servers are not part of the list.

    • 0: Success (including --help and --version).
    • 1: User, argument, and validation errors (including invalid database identifier syntax -d, invalid module names, missing modules, dependency resolution failures, or invalid input values). Both CLI argument parsing of an invalid -d and programmatic validation via DatabaseName consistently exit with code 1.
    • 2: Command-line usage errors (unknown flags, missing required arguments such as omitted -d), system I/O errors, or unimplemented runtime/execution errors.

    Start the linked native application with one explicit deployment configuration:

    Terminal window
    erp server --config /private/deployment/server.toml

    The command uses the existing application listener, registry and authentication services. It registers an application node and checks its build, addon and shared-setting identity before admitting work. Use prepared runtime addon trees; package-manager links and build caches are not runtime artifacts. Probe GET /erp/health/ready and require HTTP 200 before routing application traffic. A listener accepting connections does not establish readiness. See server lifecycle.

    The configuration is strict TOML: unknown keys and invalid supplied values are refused. Relative file and addon paths resolve from the configuration file’s directory. Each connection URL and proxy token is read from a private, mode-600 regular file; symlinks and insecure secret files are refused. Keep those files outside version control. This direct-access example binds only to loopback:

    database = 'erpforall'
    database_url_file = '/private/deployment/request-url'
    owner_database_url_file = '/private/deployment/owner-url'
    node_database_url_file = '/private/deployment/node-url'
    node_name = 'app-1'
    shutdown_deadline_secs = 45
    bind = '127.0.0.1:8069'
    public_origin = 'http://127.0.0.1:8069'
    proxy_mode = 'direct'
    addons_path = ['/srv/erp/addons']
    assets_manifest = '/srv/erp/assets/manifest.json'
    [startup_limits]
    'http.max_connections' = 8192
    'process.memory_soft_bytes' = 4294967296

    database is a nonempty ASCII alphanumeric/underscore name of at most 63 bytes. The request, owner and node connections target that same database and endpoint, with distinct roles. A serving command requires node_database_url_file; it is optional only for configuration consumers such as database initialization. The node name defaults to erp-server and accepts one to 63 ASCII alphanumeric, dot, underscore or hyphen bytes. The shutdown deadline defaults to 45 seconds and accepts 5 to 3600 seconds; HTTP drain, node departure and runtime shutdown use the remaining absolute budget.

    For an external HTTPS service, use proxy_mode = 'authenticated', an HTTPS public_origin, a trusted_proxies list of allowed peer IP addresses, and proxy_token_file pointing to a protected shared token. Direct mode requires a loopback bind and refuses proxy peers/token configuration. Configure the proxy to supply one actual client IP in X-Forwarded-For; without it, the peer IP becomes the throttle address and users behind that proxy share its address bucket. The canonical public origin is shared across replicas even when their bind addresses differ.

    The live HTTP/1 connection timers use the optional top-level keys http_header_deadline_secs (default 5, range 1–60), http_keep_alive_idle_secs (default 30, range 5–600), and http_max_connection_age_secs (default 120, range 10–3600). They require header deadline < idle limit < maximum age. The separately validated [startup_limits] keys http.header_read_secs and http.keepalive_idle_secs currently do not override these live timers; their aliasing is pending.

    [startup_limits] accepts quoted dotted keys with integer values. Missing values use the defaults below; wrong types, unknown keys, out-of-range values and incompatible byte budgets refuse startup. These are admission settings, not a claim that pending websocket, streaming, cache or cancellation facilities are implemented or that actual memory use has been measured.

    http.max_connections is live: it caps concurrent HTTP connections. Give the process a descriptor limit (ulimit -n, systemd LimitNOFILE) above that cap plus the database pools and open files. When accept() still runs out of descriptors, socket buffers or memory, the server stops taking new connections for 100 ms at a time, so existing connections can finish, and logs one warning when the episode starts and one when it ends; it does not exit. A handshake the peer aborted, or a pending network error of the new connection (Linux accept(2) retry list), is skipped. Any other listener error stops the server.

    KeysDefaults
    http.max_connections, http.keepalive_idle_secs, http.header_read_secs, http.body_read_secs8192 connections; 60, 10 and 30 seconds
    http.body_min_bytes_per_sec, http.response_min_bytes_per_sec8192 and 16384 bytes/s
    db.cancel_concurrency, limits.header_bytes, limits.header_count4; 16384 bytes; 100
    admission.inflight_bytes, admission.ws_inflight_bytes536870912 and 67108864 bytes
    buffers.thread_cache_bytes, assets.memory_bytes, rpc.spec_cache_bytes4194304, 268435456 and 16777216 bytes
    limits.rate_table_entries, session.touch_queue_entries65536 entries each
    ws.read_buffer_bytes, ws.message_read_secs, ws.min_bytes_per_sec, ws.max_message_bytes4096 bytes; 30 seconds; 8192 bytes/s; 1048576 bytes
    limits.rpc_body_bytes, limits.rpc_result_bytes, process.memory_soft_bytes2097152, 16777216 and 4294967296 bytes

    Session timing is database policy under ADR 0200; remove the retired startup touch key before restarting. The authentication configuration table lists all database timing and node [auth] settings with defaults and bounds.

    Inflight capacity must cover twice the maximum RPC body, the maximum result and the websocket share; the websocket share must cover a maximum message. Inflight capacity and the checked configured reservation sum, including the actual hashing pool, must fit the process soft cap. The hashing pool must fit one quarter of that cap. The cap must fit reported physical host RAM. The current check uses host RAM rather than a container’s cgroup limit; the default cap refuses a host with less than 4 GiB. Choose an explicit compatible cap and reservation configuration for smaller deployments. A passing startup check is not performance acceptance.

    Refresh the audit table: erp audit maintain

    Section titled “Refresh the audit table: erp audit maintain”
    Terminal window
    erp audit maintain --config /private/deployment/server.toml

    Runs as the owner role. It installs the audit table erp_event.ir_audit_entry when it is missing, checks an existing one against its fixed definition (it never adopts or repairs a table of another shape) and creates the missing daily partitions of the window (today plus 31 UTC days). It is idempotent and changes no grants; every erp db publish-grants does the same and then grants the request role its insert-only rights. When the event outbox table erp_event.ir_event_outbox is installed, the command also creates its missing daily partitions (today plus 7 UTC days); when it is not installed the output says so and nothing else happens. The output names both tables.

    The server keeps both windows itself: it runs the same partition upkeep at every start and then once an hour on every node, so this command is for repairs and for an immediate refresh. When another session holds the outbox table’s lock longer than the partition lock timeout, the command stops with an error that says so; run it again. See the audit trail.

    End keys or sessions in an emergency: erp auth emergency-revoke

    Section titled “End keys or sessions in an emergency: erp auth emergency-revoke”
    Terminal window
    erp auth emergency-revoke --config /private/deployment/server.toml --reason compromised --key 41 42
    erp auth emergency-revoke --config /private/deployment/server.toml --reason lost --session 0193f2c4-8a1e-7b3d-9c2a-5e6f70819a2b
    erp auth emergency-revoke --config /private/deployment/server.toml --reason offboarding --user 17 --keys --sessions

    Use it when a credential must end now and the normal path cannot do it: the runtime role cannot write audit rows (its insert right was revoked), or a person or service has to lose its keys and sessions at once. Ordinary revocation (the key’s own revoke, a logout, the devices page) stays the normal way; it commits with its audit row and fails when the audit store is unavailable.

    The command ends the keys and sessions that exist when it runs. It does not archive the user, reset the password or block a later login or a new key. To cut a person off, the operator also archives the user or resets the password. A key issued for the user while the command runs waits for it on the user’s row: it is either deleted by the run or issued after it commits.

    The command runs on the owner connection of the configuration (owner_database_url_file) as the core System principal. It writes its own audit row in the same transaction as the deletions, so there is no unaudited revocation.

    OptionMeaning
    --config FILEDeployment configuration; its owner connection is used. Required.
    --reason REASONWhy: one of compromised, lost, offboarding, incident. Closed list; recorded in the audit row. Required.
    --key ID...API key ids, at most 500 per run. Every id must exist.
    --session UUID...Session ids, at most 500 per run. Every id must exist.
    --user UID with --keys, --sessions or bothAll keys (500 per transaction, each its own audit row) and/or all sessions of one user.

    Give exactly one of --key, --session and --user. The command never takes a key secret, a key prefix or a key name. Its output lists ids and counts only. A user with nothing to revoke is a success: it prints 0 revoked and writes no row.

    It refuses before any deletion when:

    • the connected role does not own res_users_apikeys, erp_session and erp_event.ir_audit_entry. The message names the first table it does not own and says that emergency revocation runs only on the owner connection. A superuser that is not the owner is refused too;
    • the audit store cannot take the row on the owner connection: the table is missing, has another shape or has no partition day left. The message names the state and erp audit maintain; run that first. The command does not install partitions itself;
    • a named key, session or user does not exist. The message lists the missing ids and nothing is revoked.

    Exit codes: 0 success (including 0 revoked); 1 the request was refused (wrong owner role, unknown id, bad argument value); 2 a failure (the audit store cannot take the row, a database error, a usage error such as a missing option). A later chunk of --user --keys that fails leaves the earlier chunks revoked and audited; the error says how many were committed. If the connection drops during a commit, the message says the outcome is unknown: check the keys and sessions before you run the command again.

    Session-end hooks run in the same transaction on the owner connection, but only the hooks linked into the erp binary. When installed addons exist beyond the ones the CLI links, the output says so (decision D6 of ADR 0151).

    The owner role can rewrite its own audit rows. The row this command writes is evidence for the operator and for the audit reader; it does not defend against a hostile owner. Keep the owner credential to the people who may run this command. See the audit trail.

    Publish native runtime grants after module operations

    Section titled “Publish native runtime grants after module operations”

    A native deployment uses separate owner and runtime roles. CLI module operations use DATABASE_URL as owner and do not know the deployed runtime identity. After a successful install or upgrade, use the candidate binary with the protected deployment configuration:

    Terminal window
    erp db publish-grants --config /private/deployment/server.toml

    Run the release’s schema/module upgrade before publication, then publish grants before starting or activating the candidate server. Publication does not create missing node or authentication collector tables. The command reads owner/request credentials from the configuration’s protected files, publishes the same grants as native initialization/browser install, and verifies the server’s schema, table and sequence privilege check as the request role. It preserves the restricted signal, post-commit and installation-audit privileges.

    The request role receives SELECT and UPDATE on the durable erp_auth_gc_state singleton, while INSERT, DELETE, TRUNCATE, REFERENCES and TRIGGER privileges are revoked. Collection needs no table ownership or CREATE privilege. The request role receives no access to erp_node, erp_node_detail or erp_node_rollout. When node_database_url_file is configured, publication also grants the separate heartbeat role its restricted node-table privileges and schema usage.

    Publication and server startup refuse any request/heartbeat role membership in either direction, including reachable NOINHERIT/SET/ADMIN paths; a request role with reachable node-table privileges is refused. A heartbeat role with reachable business or authentication table privileges, or the checked administrative role attributes, is also refused. Revoke the offending source of effective access instead of granting either role ownership or broader privileges.

    Repeated publication is safe. It does not run module hooks, initialize the database or recover pending operations. A busy lifecycle lock returns exit 3; pending recovery, unsafe roles, database errors and failed verification return nonzero. Failed verification after commit explicitly says the grants were committed; fix the runtime connection or finish the concurrent operation and rerun. No success is reported until runtime verification completes.

    erp db runtime-grant-contract reports this binary’s compiled privilege contract as {"version":16,"ui_assets":"read-only","node_features":"execute-only","event_outbox":"insert-only","uom_references":"guarded-monotone","job_queue":"column-grants","audit_trail":"insert-only","attachment_usage":"append-only","audit_reader":"select-only","attachment_owner":"read-only","attachment_pending":"guarded-create","attachment_peer":"read-only","attachment_recovery":"owner-write, progress-read","sql_objects":"exclusive-id-sequences"}. It needs no configuration or database connection, performs no publication, and does not verify an existing database’s grants. Version 1 declares only read-only UI assets; version 2 adds execute-only node-feature access; version 5 adds the job queue’s column-level grants (ADR 0150). The unmerged historical outbox-only version-2 shape is unsupported. Version 3 combines both guarantees with the dedicated event-schema insert allowlist (ADR 0136). Version 4 adds the UoM permanent-reference grant and admission matrix (ADR 0144). Version 15 added declared SQL-object role bindings. Version 16 also protects explicitly exclusive named id sequences during grant publication, startup and recovery. See SQL-object database roles. Version 6 adds the insert-only audit trail (ADR 0151): the request role may insert the columns it supplies into erp_event.ir_audit_entry and use its sequence, and nothing else. A release restore or grant reassertion with an older publisher over a version-6 release is refused before any grant is published, because an older publisher revokes the audit insert right and every call that changes data would then fail closed. Version 8 adds isolated reader publication and admission (ADR 0167); restore to an older publisher is likewise refused because it does not implement that contract. Operators restore from backup or move forward. The request role can read markers, update only the fence’s singleton column and execute bounded id-only registration. It cannot mutate markers or use their sequences/internal functions. Missing guard infrastructure and leaked effective privileges refuse publication/startup; neither path repairs history.

    Release recovery probes verified source and target binaries before the target publisher runs. Equal contracts recover normally. Version 3 may recover to version 2: that publisher leaves the erp_event schema untouched. Versions 12 and 13 recover to each other in both directions: version 13 only relabels the attachment recovery capability and both publish the same grants. Recovery from version 2 or 3 to version 1 requires disabled, unapproved login-feature state and its private durable rollback fingerprint before broad grants. Roll-forward validates that fingerprint before and after narrowing. Other unequal recovery contracts, unsupported output and probe failures refuse before target publication or switching. The existing identity-aware-to-legacy refusal also remains. Use ordinary forward activation for upgrades, or explicit operator reconciliation when recovery is refused. By contract declaration (ADR 0136), v2 promises the same node-feature and UI-asset fences as v3; the pinned v2 literal SQL exercises only the node-feature and event halves. --activate refuses, before any publication, a pre-contract candidate over a supported-contract active release and any candidate whose contract is older than the active one (use --rollback for a recorded previous release). From version 4, every older target refuses before publication or switching, including the otherwise allowed v3-to-v2/v1 cases. This applies even without UoM installed. Failed v4 activation can therefore require backup/operator recovery; an attempted recovery does not establish that a previous release is healthy.

    The translation verification table erp_translated_verified, when present, is owner-only. Publication removes the runtime role’s direct grants and verifies its effective privileges, including access inherited from another role or PUBLIC. If access remains, revoke that source and publish again. Run publication as part of upgrading an existing deployment before serving requests; a node refuses publication when its runtime role can still access the table.

    scripts/human-release.py --activate runs this command using the packaged candidate before switching the active release. Run the schema upgrade first; activation does not migrate the database. A publication failure leaves the active release unchanged and reports a safe child exit code, timeout or spawn failure. Child stdout/stderr remain suppressed. Deploying older binaries without this command requires their historical release procedure; automatic activation with the new script refuses them. Rollback remains the existing explicit --rollback operation.

    Tenant bundle hashes and installed-addon static declarations are served from verified resident identity, gzip and Brotli forms. The host supplies one shared AssetStore to release-bundle and tenant publication, using the validated startup_limits.assets.memory_bytes setting. That setting already participates in the configured process reservation. It does not disable limits when zero; startup refuses invalid settings.

    Admission includes live representation payloads and conservative resident bookkeeping, plus separate owned publication metadata. Identical complete content entries can share across tenant snapshots, while each snapshot pays for its own declarations. Active snapshots, response bodies and detached clones of response header values keep their allowance until their last owner drops. Cache eviction reclaims only idle entries; a detached header can retain its charge after eviction. A candidate that cannot fit fails loudly with asset publication refused: assets.memory_bytes admission limit exceeded. The logical admission charge is not a measured process RSS value. Bounded database decoding and codec scratch are separate transient work; retained-load preflight applies the lower host/hard cap.

    A rollout can temporarily hold old and new generations. Provide enough allowance for that overlap; otherwise a newly authoritative generation can answer maintenance/503 until an operator adjusts capacity or reduces declared assets through the normal lifecycle. Do not delete manifests, remove admission checks or grant broader database rights to work around the refusal. Read the server log for the failed admission boundary, then retry through the normal startup/publication path.

    When a running replica refuses to re-admit a newer generation on a request, it logs UI asset re-admission failed; web assets answer 503 with the cause and answers clients only the fixed text “UI assets are unavailable; the operator must check the server log”. It remembers that refusal for the same generation and retention list for 30 seconds, so requests in between get the 503 at once instead of repeating the reload. After 30 seconds, or as soon as the published generation changes, one request tries again; this lets the replica recover once older generations drain.

    /erp/assets/<hash>.* uses private, max-age=31536000, immutable; a declared /<module>/static/... uses exactly no-cache. Available encoded forms are negotiated with Accept-Encoding; ETags identify the actual selected bytes. Conditional GET can answer an empty 304. An unacceptable encoding set gives 406/no-store; malformed negotiation gives 400. The current durable authority query remains: a memory hit never proves tenant authorization or compatible runtime. Unchanged admitted generations do not reload blob payloads.

    Operator client.<hash>.js/css release manifests remain schema-1 identity-only in this delivery. Release compressed sidecars and the older large-static streaming design remain open scope; there is no directory mount or request-time compression. The source repository records this contract in ADR 0122 and the ASERVE specification. Product performance acceptance is DEFERRED_PERFORMANCE under ADR 0065.

    Version 7 adds append-only attachment usage, a read-only compacted base and column-limited attachment writes (ADR 0165). An older publisher cannot safely restore over this contract. Apply the authorized base schema upgrade before publishing these grants.

    Set audit_reader_database_url_file='audit-reader-url' in the deployment TOML to enable reader connection admission. Store the reader URL in that protected mode-600 file; do not pass it as a CLI argument. Provision a distinct login without SUPERUSER, CREATEDB, CREATEROLE, REPLICATION or BYPASSRLS, and without memberships leading to runtime, owner, node or administrative roles.

    Use erp db publish-grants --config <protected-config> as the owner. It publishes parent-only audit SELECT for the reader, preserving runtime INSERT-only rights, and verifies the actual reader login after the grant transaction commits. Initial administrator activation and native addon lifecycle publication also verify a configured reader. A configured bad credential produces a nonzero failure; startup never falls back to another credential. Repeated publication restores the same intended ACLs.

    The reader must not inherit PUBLIC TEMPORARY on the database, PUBLIC CREATE on a schema, unrelated table/column/sequence rights or executable application SECURITY DEFINER functions. The operator must reconcile those sources deliberately before publication; the tool does not revoke shared grants for other roles. Parent SELECT covers future partitions without direct partition grants. erp audit maintain continues to refresh partitions; newly created event partitions discard non-owner default ACLs.

    The exact compiled publisher contract is version 13 with attachment_recovery: owner-write, progress-read, attachment_peer: read-only, attachment_owner: read-only, audit_reader: select-only and audit_trail: insert-only, plus the earlier capabilities. Version 12 added attachment recovery (ADR 0183) under the label owner-only; version 13 grants exactly the same and relabels it, because the owner connection writes the claim and the runtime role reads its progress. Automatic restore to versions 1–11 or a pre-contract binary is refused before grants, login-state changes or pointer switching. Use a compatible candidate or the documented backup/recovery path. No audit reader RPC method or audit-log UI is supplied by role publication alone.

    Publisher contract version 9 retains the audit reader and accounting capabilities and adds attachment_owner: read-only: request roles read ownership health but cannot mutate identity, pending intents, heartbeat, contest or observation state. Publication refuses a partially installed ownership schema or inherited/PUBLIC write rights. Restoring a pre-v9 publisher requires operator reconciliation before any grant publication; automatic restore/reassert refuses it.

    erp attachments probe-store --peer --config <protected-server.toml> --store <key> start --timeout 120 starts a bounded two-host attempt; join <session-uuid> joins from the second host and status reports current durable state. It uses the owner connection and linked raw registry without loading pending module work, running hooks, upgrading addons or starting jobs. The configuration must select a registered shared local store. See the installation attachment-store runbook.

    Publisher contract version 11 retains every version-10 capability and adds attachment_peer: read-only. The publisher excludes peer evidence from blanket CRUD, requires its schema and checks effective privileges, including PUBLIC and inherited roles. A version-10 or older publisher cannot be restored over this authority. Upgrade base before publishing version-11 grants.

    Publisher contract 10 additionally declares attachment_pending: guarded-create (ADR 0176). After the base upgrade, request roles may SELECT/INSERT pending guard rows and UPDATE only their generation. Startup rejects missing schema and effective unsafe rights. A pre-10 publisher can restore blanket CRUD on the retained table, so automatic restore/reassert refuses it before effects.

    After a native addon operation, erp db publish-grants --config <protected-server.toml> reconciles runtime access against the installed addon set without running hooks or recovering pending operations. Restricted SQL-object tables retain their declared operations; ordinary tables receive CRUD access. An unsafe role or an unresolved declaration refuses publication. If an addon operation already committed, correct the reported cause and retry publication without repeating the addon operation.