FileNonceLedger
A spent-nonce ledger backed by one file per nonce. Atomicity comes from the filesystem rather than from this class: `fopen(..., 'x')` creates the file only if it does not exist, and the kernel settles the race. A `file_exists()` followed by a write would read correctly in every test and lose to two shells pressing enter together — the exact case the ledger is for, since an authorization worth signing is one worth not running twice. Hosts with more than one machine want a shared implementation; this one is honest about being per-host, and per-host is the right scope for a local operator surface.
FileNonceLedger::__construct()
public function __construct(string $directory):Parameters
| Name | Type | Description |
|---|---|---|
| $directory | string |
FileNonceLedger::spend()
public function spend(string $nonce, int $ttlSeconds, int $now): boolWins the race or loses it, decided by the kernel rather than by this method. Returns false when the directory cannot be created: unable to remember means unable to promise single use, and refusing beats granting on a promise it knows it is not keeping.
Parameters
| Name | Type | Description |
|---|---|---|
| $nonce | string | |
| $ttlSeconds | int | |
| $now | int |