Expand description
The one runtime decision between a release run and a test run (M21), and the only sanctioned reader of a test or override selector (M23).
Design rule: the strongest guarantee is that a release binary contains no code that reads a test or override selector. So there are two builds of this module:
- Without the
test-modecargo feature (the default, and the only thing a release build may use):decidereturnsMode::Releaseand performs no environment or argument read at all. [test_selector!] expands toNoneand drops its name literal. The binary carries no selector name and no [TEST_MODE_MARKER].rootsresolves from the operating system’s account database (Suite::per_user_default), never from the environment. - With
test-mode(QA and dev builds only):decidereads the activation selector. A run is a test run only when the activation selector AND a root that passes every check below are present; anything partial is aRefusalbefore any store, log, credential or service opens. The root must be absolute, an existing directory, not itself a symlink, disjoint from the real per-user suite root and the user’s Documents/Pictures-style folders (equal, ancestor, descendant, or reached through a symlinked ancestor), outside cloud-sync folders, private to the current user on Unix, and carry the binding file (.rightkit-app.json,{"app": "<id>"}) thatrightkit-qawrites when it creates an isolated home, naming this app.
@rightkit/release (release-switch-scan.mjs) refuses a release build that enables
test-mode, and refuses a native binary that contains [TEST_MODE_MARKER] text or any selector
name. Selector names therefore live only behind the feature, and no message in this module that is
compiled into a release build names one.
The decision is deliberately injectable (ModeInput) so tests can prove the “reads nothing”
and “refuses” properties without touching the real process environment.
Structs§
- AppId
- The app asking for a mode.
idis the binding key ("viewright");dir_nameis the folder underOrthic Labsthat holds the app’s own data ("ViewRight"). - AppRoots
- Resolved roots a store must come through.
- Process
Input - The real process environment.
- Test
Root - A verified test root: canonical, symlink-free at the leaf, disjoint from real user data,
private, and bound to one app by the runner. Constructible only by
decidein a build that compiledtest-mode.
Enums§
- Mode
- How a run was decided.
Releaseis the only value a build withouttest-modecan produce. - Refusal
- Why a test run was refused. Each variant names its rule through
Refusal::rule. Messages never name an environment variable: this enum is compiled into release builds too.
Constants§
- TEST_
CAPABILITY - Whether this build compiled the test capability (cargo feature
test-mode).
Traits§
- Mode
Input - Where
decidereads from. The default implementation of the provided methods is the real operating system. A test supplies a fake, including one that panics on any read.
Functions§
- decide
- Decide once, before any store, log, credential or service starts.
- default_
protected_ paths - Protected paths derived from the real suite root: the whole
Orthic Labsfolder and the user’s content folders under the home. - init_
or_ exit decideagainst the real process, once per process. Prints one line to stderr and exits with status 2 on aRefusal; hosts call it first inmain.- roots
- The roots every store must come through, against the real process.
- roots_
with rootswith an injectable source for the real per-user root.