Skip to content

Headless Service Contract

Assertions

SVC-001 - Installer configuration is complete and deterministic

Contract: The headless installer MUST expose and document every supported CLI option and environment override. Setup MUST work without CLI options by asking only for missing values. CLI values MUST override environment values, then existing configuration, then interactive answers/defaults. Optional boolean questions MUST use [y/N] with Enter meaning no. Supplied settings MUST replace their corresponding prompts. Current stable releases MUST be the default for a new installation; saved version choices MUST survive updates. Unsupported intervals/port collisions MUST fail before installation, and non-interactive mode MUST never prompt.

Evidence:

SVC-002 - Installation is isolated and systemd units contain no secrets

Contract: Joplin Terminal, its profile, npm prefix, helper scripts, credentials, and the joplin-md-sync binary MUST use the managed per-user layout. Generated units MUST use absolute paths, contain no secret values, pass systemd verification where available, and retain reviewed sandbox exceptions for snap and filesystem sync targets.

Evidence:

SVC-003 - Service credentials are protected, distinct, and never leaked

Contract: Joplin, E2EE, MCP, and sync credentials MUST be read from protected regular files or bounded interactive prompts and MUST be removed from child environments, commands, logs, units, and reports. The generated MCP bearer token MUST be preserved across reruns and MUST differ from the Joplin token. Secret prompts MUST refuse getpass's echo fallback. A non-regular credential path, including a FIFO with no writer, MUST fail without blocking.

Evidence:

SVC-004 - Sync targets map to explicit Joplin settings

Contract: Every supported static sync target MUST map to its complete Joplin setting set. Browser-authorized targets MUST persist and verify browser authentication before service start; password-authorized and S3 targets MUST require their complete non-interactive credentials. Existing conflicting profile configuration MUST require an explicit CLI selection, interactive selection, or --reconfigure. Unchanged target/account/endpoint credentials MUST be reused through the supported Joplin CLI without another secret prompt; a changed endpoint/account MUST NOT silently receive the previous secret. Account names and S3 bucket/region values MUST compare exactly; only URL normalization actually applied to the driver settings may be ignored. The none backend MUST disable synchronization. A rerun over an existing non-empty profile without installed units MUST ask sync questions only after reading the profile through the supported Joplin CLI, use its configured target, endpoint, account and credentials as defaults, and keep them unless this run explicitly changes them; an unconfigured profile MUST still offer the backend choice, and an empty directory is a fresh profile. S3 MUST ask for both missing access and secret keys with hidden interactive prompts by default; credential files MUST remain optional and replace only their corresponding prompts. Non-interactive mode MUST fail without prompting when either credential is absent. Initial sync MUST prove a completed report without synchronization errors, not merely a zero process exit code. Custom S3 endpoint paths, regions, bucket names, credentials, and path-style policy MUST reach the real driver.

Evidence:

SVC-005 - Release downloads are exact and verified

Contract: The installer MUST resolve stable release metadata, accept only the supported platform asset name at the expected GitHub Release URL, verify its exact SHA-256 entry before replacement, and refuse unknown existing binaries or malformed release tags. Installation MUST be idempotent.

Evidence:

SVC-006 - Upgrades preserve configuration and prove both APIs

Contract: A default rerun MUST detect the installed services and update them; --upgrade MUST remain an explicit compatibility option. Upgrade MUST update Joplin Terminal and joplin-md-sync independently without re-requesting stored sync secrets, preserve protected service tokens, restart both units in dependency order, and require bounded Joplin and MCP smoke checks, including the rejection of an unauthenticated MCP request. A setup or upgrade MUST remove a regular file or symlink that an earlier installer version managed and the service no longer reads only after it has started the services and passed those checks; it MUST keep the file when it fails or leaves the services stopped, and MUST NOT remove any other kind of file at that path. An upgrade of an adapter unit that still enables the 1.x ChatGPT Actions options MUST refuse, before any change, a target release older than 2.0.0, and MUST write the new adapter unit before it replaces the executable. Failed health checks MUST stop the restart loop of both units and retain recoverable prior executable/service files without copying or automatically downgrading a Joplin profile. A failed Joplin package installation MUST restore the previous isolated npm tree, keep both units unchanged and restart only the services that were active before the upgrade. A changed joplin-md-sync executable MUST be downloaded, verified and smoke-tested before healthy services are stopped. Upgrade MUST preserve installed paths, ports, interval, listener policy and filesystem sandbox exceptions unless explicitly overridden, and refresh both units and supervisor helpers. Unreadable or inconsistent installed units MUST fail before service changes. Saved startup/version choices MUST survive reruns. An incomplete pair with only one installed unit MUST be rejected before any setup prompt or overwrite. Cleaning an incomplete or unreadable/inconsistent pair MUST require its explicit profile and prefix paths, without prompting or guessing default paths. --reconfigure MUST skip existing settings when asking for this run's choices, apply explicit/interactive enablement, and clear inactive managed configuration through supported interfaces without deleting existing notes.

Evidence:

SVC-007 - Purge is explicit, scoped, and idempotent

Contract: --clean and its --purge alias MUST run without questions or a confirmation flag, bypass setup/credential collection, obtain the profile lock before deletion, remove only managed files and units, including files that earlier installer versions managed, preserve unrelated user data, and be safe to repeat. Dry-run MUST delete nothing and MUST not require a working systemd bus. The joplin-md-sync executable MUST be removed only when it matches the path and SHA-256 in the private receipt written when the installer placed it; symlinks, changed files and executables without a receipt MUST be preserved with a message.

Evidence:

SVC-008 - The supervisor fails closed and terminates cleanly

Contract: The Joplin Terminal supervisor MUST unlock E2EE without echoing the secret, bound sensitive child output, verify API readiness, propagate child failure through nonzero exit for systemd restart, terminate hung children, and reject port collisions, read-only profiles, and failed runtime self-checks before reporting readiness.

Evidence:

SVC-009 - OAuth extends the existing service and preserves operator data

Contract: The existing installer MUST enable OAuth on the same adapter unit and port through --github-oauth. Upgrade MUST validate the candidate's OAuth configuration before stopping a healthy service or replacing its binary. OAuth state writes MUST receive a scoped sandbox exception; existing system hardening MUST remain. Ordinary OAuth disablement MUST preserve config and grants. JOPLIN_GITHUB_OAUTH MUST accept only 1/true/yes, which enables OAuth, or 0/false/no, which MUST behave as --no-github-oauth; either command-line flag MUST override it, and both flags together MUST fail. Other values MUST fail before any change. During explicit --reconfigure, disabled OAuth MUST lose its saved configuration, owned secret files and registered managed grants; external operator-owned files MUST be retained. Enabling OAuth with missing settings MUST ask for them, hide the Client Secret, and generate an owner-only signing key when no key is supplied. Purge MUST remove only installer-registered managed OAuth state and MUST preserve operator-owned custom paths and external secrets.

Evidence:

SVC-010 - The remote entry point imports a verified temporary package

Contract: The installer entry point MUST use normal imports from a local sibling package. Downloaded/stdin runs MUST download the complete package and service assets into a private /tmp directory, verify the manifest digest pinned by the entry point and every file digest before importing application code, select all companion files from the requested branch/tag/commit (--installer-ref or its environment equivalent, default main) without a fallback to main, bound file/bundle sizes and reject unsafe relative paths. Temporary files MUST be removed after normal exit or an exception. Deployed services MUST use persistent copied files, independent of the temporary package.

Evidence: