Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Invariants

These hold in every mode and every build that is not a dev build. A change that would break one is a decision for the project owner, recorded in Decisions, never a workaround.

Each has the reason it exists and what enforces it.

1. Loosening is always delayed; tightening is immediate

Any change that weakens protection waits out the current delay tier on the phone. The delay starts when the phone accepts the change, not when it was created.

  • Why: the delay is the whole product. An urge passes; a countdown that can be cancelled with one tap outlasts it.
  • Enforced by: the tightening classifier (Config.isTightening, defaulting to loosening when unsure) and the delay engine in android/core; the shared vectors in protocol/vectors/classifier.json.

2. The holder of the phone can always get out

“Pair a new key”, started on the phone with no key, exists in every mode, partner mode included, and a newly paired key can always send a signed exit, which waits out the config’s delay. Nothing may remove either.

  • Why: a tool that can trap its user is a tool nobody should install. Losing a key must cost time, never the phone.
  • Enforced by: BundleProcessor.requestRePair asks for no key and no secret (in partner mode it only waits); the re-pair tests in SessionAndProcessorTest.

3. No stealth

The app is always visible in the launcher, always shows whether it is armed, and always shows any running countdown.

  • Why: QuitLock is a commitment the user makes to themselves, not something done to them.
  • Enforced by: the manifest’s launcher activity and the main screen, which has no way to hide the status or the countdown.

4. No monitoring

The app never records, stores or transmits what the user browses or which apps they use. It holds INTERNET for one reason only: the platform’s Private DNS call tests the resolver from inside the calling app and fails without it (platform facts, item 12). The app’s own code opens no network connection.

  • Why: a tool for a private struggle must not become a record of it.
  • Enforced by: scripts/check-invariants.sh, which fails the build on a permission outside an exact list and on any networking code in the app’s source.

5. Release builds contain no instant-removal code, and no developer tools

That code lives only in the debug source set; the release source set has a stub with a null hook.

  • Why: a release build that could be removed instantly would undo invariant 1.
  • Enforced by: scripts/check-invariants.sh: the release stubs must contain no functions, the debug-only classes must not appear in the main source set or the release APK’s dex, and the developer tools screen is declared in the debug manifest only.

6. Nothing is enforced until the user arms it

Before arming, removal is instant.

  • Why: setting up must be safe to try, and to abandon.
  • Enforced by: Lifecycle (NOT_OWNER, UNARMED, ARMED) and the Arm button, which only the user can press.

7. Shortening the delay is itself a loosening change

It waits out the old delay.

  • Why: otherwise a delay could be shortened first and then everything else loosened quickly.
  • Enforced by: the classifier: only raising the tier is tightening.

8. Signatures are checked over the exact bytes received

A payload is never re-serialised before it is verified.

  • Why: two encoders that disagree on one byte would make a signature mean something else.
  • Enforced by: the verifier works on the envelope’s payload bytes; the shared vectors.

9. Every signed command is bound to one device, carries a sequence number and expires

Replays and cross-device reuse are rejected.

  • Enforced by: Acceptance, steps 3 to 5; the shared vectors.

10. App updates are a loosening change

There is no automatic or silent self-update outside the bundle path.

  • Why: a new version could remove anything.
  • Enforced by: the update bundle type, which needs the same approvals and delay as any loosening change; the phone installs only the same app, signed with the same key, at a version no lower than the installed one.

11. Teardown reverses everything before device owner is cleared

  • Why: a half-removed QuitLock would leave a locked-down phone with nothing to unlock it.
  • Enforced by: Enforcer.teardown, in a fixed order and safe to re-run; RemovalTest and ExitTest on the emulator.

12. Security never depends on the transport

A bundle is verified the same way however it arrives. The connection to the computer is untrusted.

  • Enforced by: one acceptance path (BundleProcessor.process) that connections and file import both feed; the transport parity tests.

13. While armed, adb is on only during a debugging window the user opened on the phone

Connecting over the USB accessory leaves adb off. Allow USB debugging on the phone opens a window with a hard 5-minute limit, watched for tampering, ended by a self-check and logged (Connecting). The computer cannot open one.

  • Why: an adb shell can change things a device owner cannot fully lock (platform facts, item 16). A connection over the accessory carries only the connection protocol, where every change still needs a signature.
  • Enforced by: DebugWindow and Enforcer.keepsAdbOff; the self-check turns adb off whenever no window is open; AdbLockTest and LinksTest.