Smartstack: add the polling stack worker and supervisor - #475
Open
timbeccue wants to merge 5 commits into
Open
Conversation
This was referenced Aug 6, 2026
This was referenced Aug 7, 2026
timbeccue
marked this pull request as ready for review
August 7, 2026 06:51
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This is PR 6 of 8 completing the v1 banzai implementation of Smartstacking at site.
PR1 (#469): combine math
PR2 (#470): JPEG utilities
PR3 (#471): DB updates
PR4 (#473): shipper contract
PR5 (#474): smartstack data products
PR6 (#475): stack worker polling <-- you are here
PR7 (#476): e2e tests, compose cleanup
PR8 (#477): logging
PRs 1–4 provide the independent foundations for combining images, rendering JPEGs, storing stack state, and shipper integration (this PR). PR5 builds the data products, this PR adds the polling worker, crash-only supervisor, and site deployment configuration. PR7 adds cross-service E2E and recovery proof; PR8 adds structured lifecycle telemetry and final documentation.
Stack Worker Lifecycle behavior
The runtime starts one stateless polling process per camera. Each poll:
is_lastmember is present.A failed preview does not advance the stored preview count, allowing a later poll to retry it.
Finalization and retries
Finalization follows a deliberate order:
The attempt and backoff are persisted before product work begins. A build or publish failure therefore leaves the stack active for a bounded retry, while exhausted attempts end in
error.Publishing happens before the terminal database update. A failure between those steps can produce a duplicate notification with identical paths, but cannot leave a stack marked complete without having notified the shipper.
Process recovery
Ordinary exceptions are contained inside each worker loop. If a child dies violently—for example from an OOM kill—the supervisor exits and Docker restarts the service.
Because all lifecycle, retry, and preview state lives in PostgreSQL, workers restart without reconstructing process-local state. Claiming before product work also prevents a consistently failing stack from causing an endless restart loop.
Scope
This PR adds the polling worker, crash-only supervisor, and site deployment configuration. PR7 adds cross-service E2E and recovery proof; PR8 adds structured lifecycle telemetry and final documentation.
Focused tests cover completion and timeout precedence, preview gating, finalization ordering, retries, publish failures, attempt exhaustion, worker-loop resilience, and supervisor behavior.