In development. It changes without notice.
Topic
State Rules
The decisions the handlers take, with no screen, no context and no device behind them, and the list of states itself.
Among them: when an idle wait ends and what a timer then does, the order in which a session ends, where a send goes and what it reports, how long the pairing window stays open, and what a wiped or unreadable vault asks at boot. They are tested on a computer.
Files | |
| file | src/ |
| What the admin state's first tick does before it serves the portal. | |
| file | src/ |
| The application FSM's state enum and the constants the whole FSM shares. | |
| file | src/ |
| What a Bluetooth typing session says when it ends. | |
| file | src/ |
| The BLE "what do I type?" chooser model: its actions, their order and their labels. | |
| file | src/ |
| Which recovery prompt a boot shows, and what it says. | |
| file | src/ |
| When the main loop's last compositor pass composites over the glass. | |
| file | src/ |
| When a secret-entry prompt counts as left alone. | |
| file | src/ |
| When the main loop may wait out an idle stretch, and for how long. | |
| file | src/ |
| When a secret-entry surface reads the brute-force lockout again. | |
| file | src/ |
| When a pairing page closes its window: the per-tick decision every page that opens the pairing window shares. | |
| file | src/ |
| Which word names the unlock secret on a surface: "PIN" or "password". | |
| file | src/ |
| Where a send goes before the radio starts: straight out, or through the host picker. | |
| file | src/ |
| The order a session lock takes its steps in: the keys go before the Bluetooth teardown. | |
| file | src/ |
| Pure policy for the idle timers (screen-off / auto-lock / deep-sleep): the clamp, the idle predicate, the screen-off step and the relock decision. | |
| file | src/ |
| Whether a secret an entry collected was collected the way the vault on flash takes its secret, so that a wrong one may be counted. | |
| file | src/ |
| Clock policy for the unlock and write latency changes; the build switches that select it live in perf_ | |
| file | src/ |
| Vault menu action identifiers shared across the vault menu screens. | |
Functions | |
| constexpr AdminEntry | kleidos:: |
| What the admin state's first tick does, from the radios' state. | |
| constexpr Report | kleidos:: |
| The report a session ends with, from its last burst. | |
| constexpr bool | kleidos:: |
| Whether the after-send lock applies once the session ends so. | |
| constexpr ReportCopy | kleidos:: |
| The notice for a report. | |
| constexpr bool | kleidos:: |
| constexpr ActionList | kleidos:: |
| Build the chooser action list in its fixed order. | |
| constexpr i18n:: | kleidos:: |
| i18n label id for one chooser action. | |
| constexpr Prompt | kleidos:: |
| Choose the prompt for what the vault's mount reported. | |
| constexpr PromptText | kleidos:: |
The title and body of prompt. | |
| constexpr bool | kleidos:: |
| Whether the main loop's last compositor pass runs on this tick. | |
| constexpr bool | kleidos:: |
Whether an entry in state is at rest: nothing on it is in motion. | |
| constexpr uint32_t | kleidos:: |
| Whether the loop may wait out an idle stretch now, and how long. | |
| constexpr PairPromptOutcome | kleidos:: |
| What a closed pairing prompt means, from how its dialog closed. | |
| constexpr bool | kleidos:: |
| Whether the add-host page's pairing outranks its own clock. | |
| constexpr PairStep | kleidos:: |
What the pairing page does with t. | |
| constexpr bool | kleidos:: |
| Whether the add-host page's host is linked: a new bond, on the link. | |
| consteval bool | kleidos:: |
| Whether every entry of kSecretWords stands at its line's index. | |
| constexpr bool | kleidos:: |
Whether surface names a secret of kind a password. | |
| constexpr i18n:: | kleidos:: |
The words of word on surface for a secret of kind. | |
| constexpr i18n:: | kleidos:: |
The words of word on this board for a secret of kind. | |
| constexpr const kleidos:: | kleidos:: |
The label opt shows on surface over a secret of kind. | |
| constexpr const kleidos:: | kleidos:: |
The label opt shows on this board over a secret of kind. | |
| constexpr SendRoute | kleidos:: |
The route a send takes with bonded hosts in the table. | |
| constexpr bool | kleidos:: |
| Whether an idle timer has run out: the one idle predicate. | |
| constexpr uint32_t | kleidos:: |
| Time left before an idle timer runs out, read through the same rule. | |
| constexpr uint32_t | kleidos:: |
| The idle time the auto-lock and the idle sleep count: since the last input, or since the last hold when that came later. | |
| constexpr uint32_t | kleidos:: |
| Derived dim time for a screen-off window (85 %, the final-15 % rule). | |
| constexpr IdleTimers | kleidos:: |
| Repair the deep-sleep-ceiling invariant after one timer was edited. | |
| constexpr RelockAction | kleidos:: |
| Decide whether idle time has reached the vault auto-lock, and how. | |
| constexpr ScreenOffStep | kleidos:: |
| Decide what the screen-off timer does with the panel this tick. | |
Variables | |
| constexpr uint8_t | kleidos:: |
| Maximum number of chooser actions (all four present). | |
| constexpr uint16_t | kleidos:: |
| constexpr uint32_t | kleidos:: |
| The main loop's cadence while anything is going on, ms. | |
| constexpr uint32_t | kleidos:: |
| Longest idle wait while the panel shows a frame, ms. | |
| constexpr uint32_t | kleidos:: |
| constexpr uint32_t | kleidos:: |
| How long after the last input the loop keeps its cadence, ms. | |
| constexpr uint32_t | kleidos:: |
| How long after the last frame the loop keeps its cadence, ms. | |
| constexpr uint32_t | kleidos:: |
| How often a surface reads the guard while a lock holds, in milliseconds. | |
| constexpr uint32_t | kleidos:: |
| constexpr uint32_t | kleidos:: |
| constexpr uint32_t | kleidos:: |
| constexpr uint32_t | kleidos:: |
| constexpr std::array< SecretWordIds, 11 > | kleidos:: |
| Every line that names the unlock secret, in SecretWord order. | |
| constexpr std::array< SecretRowLabel, 1 > | kleidos:: |
| constexpr uint8_t | kleidos:: |
| Fewest hosts that make a send ask which one. | |
| constexpr uint32_t | kleidos:: |
| Idle-timer sentinel meaning "this timer never fires". | |
| constexpr uint32_t | kleidos:: |
| Fraction of the screen-off window at which the display starts dimming. | |
| constexpr uint32_t | kleidos:: |
| constexpr uint32_t | kleidos:: |
| Core clock the auth screen idles at with the floor off. | |
| constexpr uint32_t | kleidos:: |
Reserved minimum handed to AppContext:: (no range in use). | |
| constexpr uint32_t | kleidos:: |
| The auth screen's steady-state clock for this build. | |
Enumeration Type Documentation
Action #
One action of the BLE "what do I type?" chooser.
Every action resolves to an existing kleidos:: typing entry at staging time: UserTabPass maps to Facade:: (which already sends username, TAB, password, ENTER); Totp / User / Pass map to Facade:: with the generated code / single field staged in the password slot.
AdminEntry #
AnswerElsewhere #
AppState #
Top-level application finite-state-machine states.
| State | Meaning | Entered from |
|---|---|---|
BootCheck | Initial routing after a reset or a wake | a cold boot, a wake, a restart |
ONBOARDING | First-time setup | BootCheck, PinEntry |
PinEntry | The unlock screen: a PIN or a passphrase, by the board | BootCheck, Home |
Home | Credentials, 2FA codes and settings | PinEntry, ONBOARDING, BleHidTyping, AdminMode |
BleHidTyping | Sending a credential or a code | Home |
AdminMode | The Wi-Fi admin portal, which also installs an update | Home, PinEntry |
HwTest | Hardware test screens (debug builds) | any state |
DeepSleep | Terminal: the production sleep | any state |
ComponentGallery | Interface component gallery (debug builds) | any state |
What moves the machine from one state to the next is the table of Application States.
- Note
HwTestandComponentGalleryare reached only from the serial console of a debug build; no screen leads to them. Both enumerators always exist, and the gallery's handler is linked in debug builds only.-
AdminModeis the state that owns the update upload; the FSM has no separate update state. An installed update restarts the device, and the next boot starts atBootCheck.
| Enumerator | |
|---|---|
| BootCheck | Initial routing after reset. |
| ONBOARDING | First-time setup (no vault, setup never finished). |
| PinEntry | The unlock screen (a PIN or a passphrase). |
| Home | Credential / TOTP / actions menu. |
| BleHidTyping | Sending a credential over BLE HID. |
| AdminMode | Wi-Fi admin portal and update. |
| HwTest | Hardware test screens (debug builds, from the console). |
| DeepSleep | Shutdown into the production sleep. |
| ComponentGallery | Interface component gallery (debug builds, from the console). |
AutoLockMode #
Burst #
Ending #
PairPromptResult #
What the owner answered the numeric-comparison prompt.
PairStep #
Prompt #
The recovery prompt a boot shows.
RelockAction #
What the idle auto-lock timer should do this tick.
The vault relock is visually distinct from deep sleep (the ceiling, which tears everything down): auto-lock only drops the radios and zeroizes the key, keeping the device awake at the unlock screen's lock face. Whether that lock face is visible depends on where the screen-off timer already left the backlight.
Report #
What the session says when it ends.
ScreenOffStep #
SecretWord #
A line that names the unlock secret.
SendRoute #
TimerField #
VaultAction #
Action items available in the vault menu.
| Value | Meaning |
|---|---|
SETTINGS | Open the on-device settings tree |
AddCred | Add a new credential |
WifiAdmin | Launch the WiFi admin portal (BLE must be deinit'd) |
SdExport | Export the vault to SD (requires HAS_SDCARD) |
SdImport | Import a vault from SD (requires HAS_SDCARD) |
SdCsv | Import/export CSV via SD (requires HAS_SDCARD) |
LOCK | Lock the vault and sleep |
PassGen | Open the password generator (keyboard boards) |
Function Documentation
adminEntryFor() #
What the admin state's first tick does, from the radios' state.
- Parameters
-
Name Direction Meaning portalOff in The admin portal is off. bleOff in The BLE stack is off.
- Returns
- The step to take.
boardRowLabel() #
The label opt shows on this board over a secret of kind.
- Parameters
-
Name Direction Meaning opt in The settings row. kind in The kind of secret the vault records.
- Returns
- rowLabel on
security::.pin_ policy:: kBoardSetSurface
boardSecretWord() #
The words of word on this board for a secret of kind.
- Parameters
-
Name Direction Meaning word in The line. kind in The kind of secret the vault records.
- Returns
- secretWord on
security::.pin_ policy:: kBoardSetSurface
buildActions() #
Build the chooser action list in its fixed order.
Order: User+TAB+Password always first (the default), TOTP second only when the credential embeds one, then Username, then Password. Only the TOTP entry is conditional.
- Parameters
-
Name Direction Meaning hasTotp in True when the credential embeds a TOTP secret.
- Returns
- The ordered action list.
clampIdleTimers() #
Repair the deep-sleep-ceiling invariant after one timer was edited.
Deep sleep is the ceiling: after the edit, neither screen-off nor auto-lock may exceed it. The edited field is authoritative and is never moved; the others yield the minimum needed:
- editing ScreenOff / AutoLock: the edited value is capped at the current deep-sleep ceiling (a timer cannot outlast deep sleep);
- editing DeepSleep: the new (possibly lower) ceiling pulls screen-off and auto-lock down to it if either was above.
- Parameters
-
Name Direction Meaning t in The three timers after applying the raw edit. edited in The field the user just committed (kept authoritative).
- Returns
- The repaired timers with the ceiling invariant restored.
compositorPassRuns() #
Whether the main loop's last compositor pass runs on this tick.
- Parameters
-
Name Direction Meaning modalOwnsGlass in A handler-owned modal phase or the critical-battery dwell holds the glass. stateChanged in The FSM changed state on this tick. enteredDrew in The entering state drew its first screen in its enter()(only read whenstateChanged).
- Return values
-
Value Meaning true The pass composites over the current state's screen. false The glass is a modal's, or still the old state's.
copyFor() #
The notice for a report.
- Parameters
-
Name Direction Meaning report in What the session says.
- Returns
- Its two lines and its tone.
decidePairStep() #
What the pairing page does with t.
A pairing in flight outranks every clock the page keeps. The owner's own skip or continue outranks the pairing, because abandoning it is their choice.
- Parameters
-
Name Direction Meaning t in This tick, as the page reads it.
- Returns
- Whether to stay on the page or leave it.
decideRelock() #
Decide whether idle time has reached the vault auto-lock, and how.
Pure policy for the FSM's auto-lock: once the unlocked vault has been idle for at least autoLockMs it relocks. If the backlight is still on (auto-lock fires before the screen-off timeout) the relock shows the lock face; if the screen has already powered off (auto-lock at or past screen-off) it relocks silently, and the next input only wakes the panel, which dismisses the lock face too (wake_press.h): the input after it reaches the entry. Deep sleep is the ceiling and is handled separately (each idle view sleeps at its own idleSleepMs), so this never needs to consider it: the invariant autoLockMs <= deepSleepMs guarantees auto-lock fires first. Both timers are read through idleTimerElapsed, so a parked one never fires.
A zero autoLockMs disables auto-lock too. No writer stores one (every path clamps to the editor's 15 s floor), and a timer that fired on every tick would lock the owner out of the vault the moment it opened.
A panel that is dark already relocks silently whatever the idle time says: the screen-off timer is not the only thing that puts it to sleep (the debug console's forced screen-off does), and an activity stamp that wakes nothing (the re-encryption's slices) restarts the idle time on a dark panel. A relock onto that panel must not light it.
- Parameters
-
Name Direction Meaning idleMs in Milliseconds the session has been idle (idleSinceInputOrHold). autoLockMs in The vault-relock timeout (0 or kTimerNeverMs never fires). screenOffMs in The backlight-off timeout (splits LockFace vs Silent). vaultUnlocked in Whether a vault session is live (nothing to relock otherwise). panelAsleep in The panel sleeps already ( display::).isAsleep
- Returns
- The relock action for this tick.
decideScreenOff() #
Decide what the screen-off timer does with the panel this tick.
The timer does not put a lit panel to sleep on the call it comes due. That call only notices, so on the tick between, while the panel still takes a paint, a screen that shows a value which is wrong once stale (a one-time code) takes it off the glass (sleeping_
- Parameters
-
Name Direction Meaning due in The display is dimmed, the screen-off timeout ran out and the caller lets the panel go off. panelAsleep in The panel sleeps already. noticed in An earlier call noticed the timeout, and the panel has not woken since.
- Returns
- The step for this call.
decideSendRoute() #
The route a send takes with bonded hosts in the table.
- Parameters
-
Name Direction Meaning bonded in Hosts the bond table lists.
- Returns
PickerFirstfrom kPickerMinHosts hosts on, elseDirect.
derivedDimMs() #
Derived dim time for a screen-off window (85 %, the final-15 % rule).
- Parameters
-
Name Direction Meaning screenOffMs in The screen-off timeout in ms, or kTimerNeverMs.
- Returns
- The dim-start time in ms; kTimerNeverMs for a parked screen-off, which never dims either.
hasPendingTotp() #
Whether a staged follow-up id names a credential whose code is still to be offered.
- Parameters
-
Name Direction Meaning id in The staged follow-up id.
- Return values
-
Value Meaning true idnames a slot this device has.false Nothing is pending, or the id names no slot at all.
idleSinceInputOrHold() #
The idle time the auto-lock and the idle sleep count: since the last input, or since the last hold when that came later.
A hold (AppContext::) keeps the idle sleep from coming due through a wait the user is not idle in although no input reaches the board, without counting as input: the dim and screen-off timers count from the last input alone, so the panel still goes dark. Only the Bluetooth typing screen holds, and HOME's entry is an input that ends the hold, so the auto-lock reads the same time as the last input there.
- Parameters
-
Name Direction Meaning sinceInputMs in Milliseconds since the last input. held in A hold was made since the last input. sinceHoldMs in Milliseconds since the last hold.
- Returns
sinceHoldMswhen held and the hold is the later of the two, otherwisesinceInputMs.
idleTimerElapsed() #
Whether an idle timer has run out: the one idle predicate.
Every idle timeout (screen dim, screen off, auto-lock, deep sleep, the PIN screen's own sleep) is polled through this. idleMs is the wrapping unsigned difference now - lastActivity, so it can reach every 32-bit value: a plain idleMs >= timeoutMs would come true for one millisecond per clock wrap even on a parked timer. A parked timer therefore never fires here.
- Parameters
-
Name Direction Meaning idleMs in Milliseconds since the last user activity. timeoutMs in The timeout, or kTimerNeverMs for a parked timer.
- Returns
- true once
idleMshas reached a finitetimeoutMs.
idleTimerRemaining() #
Time left before an idle timer runs out, read through the same rule.
- Parameters
-
Name Direction Meaning idleMs in Milliseconds since the last user activity. timeoutMs in The timeout, or kTimerNeverMs for a parked timer.
- Returns
- kTimerNeverMs for a parked timer, 0 once idleTimerElapsed holds, otherwise the milliseconds still to go.
labelFor() #
i18n label id for one chooser action.
- Parameters
-
Name Direction Meaning action in Chooser action.
- Returns
- The
i18n::naming the action row.StringId
locksAfterSend() #
Whether the after-send lock applies once the session ends so.
Only when everything the owner sent landed: a session that leaves a code or a login untyped stays unlocked, so its notice is read on a lit panel and the owner can send what is missing. The idle lock still runs.
- Parameters
-
Name Direction Meaning report in What the session said.
- Return values
-
Value Meaning true The owner's "After typing: Lock now" locks the device. false The device stays unlocked.
namesPassword() #
Whether surface names a secret of kind a password.
- Parameters
-
Name Direction Meaning surface in The board's entry surface. kind in The kind of secret the vault records.
- Returns
- True on a keyboard, and for a passphrase on any surface.
newHostLinked() #
Whether the add-host page's host is linked: a new bond, on the link.
A link alone is not success there: the page is for a host the table did not hold when it opened. A bonded host the filter let through anyway (a keystore it could not read) is a link with no new bond, and the page keeps waiting.
- Parameters
-
Name Direction Meaning connected in A host holds an authenticated link. bondsNow in Hosts the bond table lists now. bondsAtOpen in Hosts it listed when the page opened.
- Returns
trueonce a host joined the table and holds the link.
pairingHolds() #
Whether the add-host page's pairing outranks its own clock.
A comparison on the glass always does. A link that is not yet authenticated does only after the owner said yes to it, and only for kAcceptedPairingHoldMs from that answer: a central that connects and never asks (or whose pairing stalls) does not keep the window, and the radio with it, open past the page's timeout.
- Parameters
-
Name Direction Meaning promptPending in A numeric comparison waits for the owner. linkPairing in A link is up and not yet authenticated (or a prompt is pending). accepted in The last comparison answered on the page was a yes. sinceAnswerMs in Since that answer.
- Returns
truewhile the pairing holds the page.
pairPromptOutcome() #
What a closed pairing prompt means, from how its dialog closed.
A yes on the glass pairs and anything else the owner did there refuses, a dialog left to lapse included; the prompt passes either to the stack, for the request it showed and no other. A dialog that closed because that request was no longer pending (ConfirmResult::) was answered elsewhere, or ended unanswered: the stack is told nothing more, an answer given elsewhere stands, and a request that ended unanswered (its link went, or a newer request replaced it) reads as withdrawn, which refuses nothing the session still holds: the next request raises its own prompt.
- Parameters
-
Name Direction Meaning closed in How the confirm dialog closed. elsewhere in The verdict of the request the dialog showed ( ble::), read once it closed.Facade:: ncVerdictFor
- Returns
- The answer that stands, and whether the prompt tells the stack.
promptFor() #
Choose the prompt for what the vault's mount reported.
- Parameters
-
Name Direction Meaning mountRefused in VaultStore::mountRefused formatFailed in VaultStore::formatFailed legacyLayout in VaultStore::legacyLayoutDetected needsManualRecovery in VaultStore::needsManualRecovery
- Returns
- The prompt to show.
reportFor() #
The report a session ends with, from its last burst.
- Parameters
-
Name Direction Meaning burst in The burst that ended. ending in How it ended.
- Returns
- What the session says.
restsIn() #
Whether an entry in state is at rest: nothing on it is in motion.
- Parameters
-
Name Direction Meaning state in The entry's state ( AuthEntryUI::).getState
- Return values
-
Value Meaning true It waits for input, typed into or not ( IDLE,ENTERING), or holds a lockout (LockedOut): an idle timer may run.false A hold is filling the dial, a digit just locked, a verify is running or its result is on the glass.
rowLabel() #
The label opt shows on surface over a secret of kind.
- Parameters
-
Name Direction Meaning opt in The settings row. surface in The board's entry surface. kind in The kind of secret the vault records.
- Returns
- The row's password label from kSecretRowLabels where namesPassword, else the row's own label.
secretWord() #
The words of word on surface for a secret of kind.
- Parameters
-
Name Direction Meaning word in The line. surface in The board's entry surface. kind in The kind of secret the vault records.
- Returns
- The line's password words where namesPassword, else its PIN words.
secretWordsInOrder() #
Whether every entry of kSecretWords stands at its line's index.
- Returns
- True when the table lists the lines in the order of SecretWord.
textOf() #
The title and body of prompt.
- Parameters
-
Name Direction Meaning prompt in A prompt other than Prompt::None, which shows nothing.
- Returns
- The strings to show.
waitMs() #
Whether the loop may wait out an idle stretch now, and how long.
- Parameters
-
Name Direction Meaning in in What the loop read this tick.
- Returns
- 0 to keep the active cadence; otherwise the longest idle wait, ms.
Variable Documentation
kAcceptedPairingHoldMs #
How long a comparison the owner accepted on the add-host page holds the page while its keys land: the stack's own pairing timer.
kAddHostPairTimeoutMs #
How long Settings' add-host page waits with nothing paired: longer than setup's, since the owner may walk to a second computer to pair it.
kDarkWaitMs #
Longest idle wait while the panel is asleep, ms. Also the longest a polled input (a power key the PMIC latches) waits to be read.
kIdleCpuMhz #
Core clock the auth screen idles at under the boost policy: the base clock of the boards. A lock face, a digit dial and a keyboard panel are all input-bound, so the base is enough and it is the frequency the device wakes into.
kLockedRereadMs #
How often a surface reads the guard while a lock holds, in milliseconds.
Twice per second of the countdown a color panel shows, so the seconds on the glass never skip one and a lock is released within half a second of running out; and longer than the cue a wrong secret plays (two 100 ms tones behind a lead-in), so the read that follows the one made as the lock was armed does not land on it.
kNoPendingTotp #
The staged follow-up id that means "no one-time code is pending".
What is staged is a credential SLOT id, and slot 0 is the first slot a fresh vault allocates (CredentialRepository:: hands out the lowest absent id), so 0 cannot also mean "nothing pending": under that reading the first credential a device ever stores is the one credential whose code is never offered after its pair is typed. The not-a-slot value of every board is what every surface that stages, clears or consumes the follow-up writes.
kPairDwellMs #
How long a pairing page stays once its host is linked, before it moves on by itself. What it shows during that dwell is the page's own business: the button and touch pages raise a "Paired" toast, the keyboard setup flips its link chip to "Connected" and beeps.
kScreenDimPermille #
Fraction of the screen-off window at which the display starts dimming.
The screen dims in the final 15 % of its time, so the dim threshold is 85 % of the screen-off timeout: derived, never a separate setting.
kSecretRowLabels #
Every settings row whose label names the unlock secret; each one's own label (SettingsOption::) carries its PIN words.
kSetupPairTimeoutMs #
How long setup's pairing page waits with nothing paired, where it gives up on its own.
kTimerNeverMs #
Idle-timer sentinel meaning "this timer never fires".
The debug stay-awake paths of the console (and the build option that disables auto-lock) park the screen-off timer, the dim time derived from it and the deep-sleep timer here; nothing parks auto-lock. Anything that PRESENTS a timer must recognize the sentinel (dividing it into seconds prints a meaningless 4294967s), and anything that POLLS one goes through idleTimerElapsed, which never fires it.