What's new in Bootgly 1.3

Bootgly 1.3 gives the event loop its own timers and signals, and adds S3 direct transfers, legacy password verifiers, SQL::transact() and a route list.

By Rodrigo de Araujo VieiraPublished 8 min read

Drafted with AI assistance; reviewed and edited by Rodrigo de Araujo Vieira.

Bootgly 1.3 is about the event loop: recurring timers, signal handlers and the framework's own periodic work now run on the built-in loop. Around it, the release adds S3 direct transfers, verifiers for passwords imported from another stack, a unit of work in one call for SQL, the Router's route list and a storage directory taken from the environment.

Every change and every commit is in the release notes.

Features

An event loop that owns its timers and signals

  • Recurring timers. A loop that implements the new optional capability ACI\Events\Repeating — the built-in Select does — runs a callback every $interval seconds with repeat(float $interval, Closure $Callback, float $slack = 0.0): int, down to 1 ms, stopped with the same cancel() as defer(). The schedule is a fixed grid, so it does not drift: a late run runs once and missed periods are skipped, and a callback that throws is reported and keeps its schedule. With a slack, timers start on shared instants and wake the loop once for all of them when their interval is a whole multiple of the slack.
  • Signal handlers on the loop. With the optional capability ACI\Events\Signalling, also built into Select, trap(int $signal, Closure $Handler) runs a handler on the loop, between callbacks, each time the process receives the signal; untrap() and destroy() put back what the process did before. The TCP, HTTP, WebSocket and UDP workers hand their server's signals to the loop and report a handler that throws instead of dying.
  • Stream readiness with a deadline. ABI\Events\Selector waits on the monotonic clock: watch(), forget() and wait(null|int $deadline). A signal ends the wait with $interrupted set, and waiting again with the same deadline resumes it without extending it. Every refusal is named — a closed or descriptor-less stream, a descriptor at or above FD_SETSIZE, a stream closed while watched, an indefinite wait on nothing.
  • Sub-second SSE ticks. open(Tick: …, interval: 0.1) runs the Tick every 100 ms on a loop timer of its own, whatever the heartbeat.
  • Emitter lifecycle. One-shot listeners (listen(…, once: true)) and forget($Event, $Listener).
  • Liveness checks. Connection::watch(int $interval, null|Closure $Check = null) gives a protocol its own liveness check on the worker's supervision sweep, on the built-in loop.

S3 direct transfers

  • Presigned URLs. S3::presign() lets its holder GET, HEAD or PUT one object for up to 7 days, with no credentials; a PUT can bind Content-Type, Content-Length, Content-MD5 and x-amz-meta-* into the signature.
  • Multipart uploads from the browser. $S3->Uploads creates an upload, signs its parts, lists them, and completes or aborts it. A listing gives every part or false, never a partial list.
  • Ranged reads. S3::read($path, $sink, int $offset = 0, null|int $length = null): no byte outside the window reaches the sink.
  • A public SigV4 signer, S3\Signer.

These transfers are covered by the framework's own S3 test double and the published SigV4 vectors; this release was not exercised against a live bucket.

Passwords imported from another stack

new Password(Verifiers: [...]) reads hashes PHP cannot. Native formats always come first, and a hash that passes a verifier is rehashed with argon2id at that sign-in — Users::verify() persists it. Password\Verifiers\PBKDF2 reads <prefix><iterations>:<salt>:<key> rows.

A unit of work in one call

For commands, jobs and scripts, SQL::transact(Closure $Work): mixed begins, runs the work, commits every level left open and returns the result; a throwable rolls back level by level and is rethrown, and a failed COMMIT throws. On every way out, the connection is back in the pool. Nested units of work are savepoints of the same transaction, so a level that throws is rolled back alone.

The Router's route list

$Router->Routes is a read-only list of the registered routes, complete once the Router is warm: path with its group prefix, methods, handler, the middlewares dispatch runs around it, parameters, cache options and kind. Router::warm() warms the route cache without a request, so a test, a command or a tool can read the list.

The storage directory from the environment

BOOTGLY_STORAGE_DIR moves logs, PIDs, sessions, locks, queues and cache without a launcher of your own, and project <Name> startup writes it into the systemd units it generates. On the kit image, a storage volume the platform mounts empty and root-owned gets the image's layout on a root start.

Worker limits for Web apps

Web\App\Configs takes headroom, maxWorkerPendingBytes, maxRequests, jitter and maxMemory, and App::configure() forwards them to the HTTP server; out-of-range recycling options are refused.

Improvements

Performance

  • Idle connections. On the built-in loop, the master watchdog, the recycle gate, the drain poll, every connection's idle expiration and the WebSocket heartbeat now ride one supervision sweep a second per worker — no timer per connection. With 10,000 idle connections on 16 workers, that is 20% less memory per connection, 18% less CPU to hold them and 37% less to expire them.
  • SSE streams. The streams of a worker that share an interval come due on at most 16 instants per interval (sse:1: 2,260 → 2,551 events/s delivered).
  • Emitter. An event with no listener left goes back to its zero-cost path, and an emission with one listener costs about half of what it did.

Security

  • S3. Credentials and option values that cannot travel in a header are refused before any request, header values are signed as SigV4 specifies, a listing that does not advance stops, the secret and the session token stay out of traces and dumps, and hostile XML answers (document types, non-UTF-8, over 32 MiB) are refused.
  • Passwords. Password\Verifiers\PBKDF2 uses a constant-time comparison and an iteration ceiling that bounds what a tampered row can cost, and refuses at construction a prefix too long for any row. A verifier that throws fails the verification, is reported once, and never sees the password in a trace.
  • Storage directory. BOOTGLY_STORAGE_DIR must be an absolute, canonical path to a real directory nobody else controls or can replace; an unsafe or empty value stops the boot with one line on stderr and never falls back to the default. On the kit image, nothing changes owner recursively or through a link, and Process\Service refuses an environment value systemd would drop (NUL, line break, non-UTF-8).

Fixes

  • A route set registers once on a cold Router. A handler that registers with direct route() calls runs again on every request while the Router is cold; each such run piled every dynamic route, group and intercept() middleware on top of the last — memory grew per request and a middleware ran once per earlier run. The server now rewinds a cold Router before each run, and a registration an earlier run made keeps every intercept() middleware it had — the Router note under Upgrading lists the cases that still need care.
  • Out-of-band data no longer spins a worker. The built-in loop refuses EVENT_EXCEPT registrations: nothing consumed them, and out-of-band data made the worker spin at 100% CPU.
  • Every server logs what it catches. A failure handed to Throwables::notify() — a signal handler, a recurring timer, a shutdown listener, a WebSocket message handler — reaches the exceptions log channel on TCP, WebSocket and UDP servers too, not only on HTTP.
  • Synchronous signal delivery. Workers start with synchronous signal delivery; a worker forked in Monitor mode used to inherit asynchronous delivery.
  • IO\IPC\Pipe::reading() keeps reading after a timeout or a signal, where it ended with false; it yields null on each timeout.

Upgrading

Before you upgrade, check the release-specific notes below: they can need an edit in your code or setup.

At the kit root:

bootgly kit upgrade v1.3.0

Running projects keep the code they loaded: stop them first or reload them after. Coming from a release older than v1.0.4, lay down the agent rules once afterwards (bootgly kit boot --agents); a kit older than v1.0.0-rc.1 has no kit upgrade yet, and the release notes show how to move it once by hand. With Docker, pull bootgly/bootgly.kit:1.3.0 and start it with the same volumes: a container run without one keeps nothing, and kit upgrade refuses inside the image — the image tag is the release.

Release-specific notes

  • Routes registered on a cold Router. If a request handler registers routes with direct $Router->route() calls, the routes of a run are now whole or nothing while the Router is cold: a handler that guards part of its routes to run once (a static flag, a require_once) while the rest runs on every request must drop the guard or guard everything. intercept() is now ignored on a warm Router, like route(). Avoid the two shapes the Router page lists that still lose a middleware intercepted on the first run only, and build once — outside the handler — a middleware made from the request or the time, or holding what the Router cannot compare (stdClass, PDO, the bundled AccessLog): built on every cold run, it is kept once per run.
  • Kit image volumes. A project whose server Configs demote to an account other than bootgly is refused over a root-owned volume without sessions/, as it already was over the image's own storage: hand logs/ and sessions/ to that account on the volume once (the Docker guide has the command).
  • Worker timers and signals. On the built-in loop, Timer::del() with no argument no longer stops the framework's own worker timers, and a blocking sleep() in a handler is no longer cut short every second by the alarm. A handler a server subclass installed before the fork for one of the server's own signals no longer runs in the workers.
  • New signatures for subclasses. SSE::open() declares int|float $interval; S3::read() takes int $offset = 0, null|int $length = null; Emitter\Listeners::add() takes bool $once = false and $entries is readable; Password::__construct() takes array $Verifiers = []; Process\Service declares public private(set) array $environment; SQL declares transact(); Select::$excepts is gone and add()/del() answer false for EVENT_EXCEPT. An override must match the new signature.
  • IO\IPC\Pipe::reading() no longer ends at the first timeout: a consumer that relied on it leaves the loop with break on the first null.
  • Transaction::begin() while its own BEGIN is in flight is refused: await it before the next operation.
All posts