How nahom-zewdu/nuvom works
1. What this repo is
Nuvom is a Python task engine packaged as a library plus a CLI. The core responsibility is to let users define tasks, discover them statically, enqueue jobs, schedule recurring or delayed work, execute jobs in workers, and persist results through interchangeable storage backends.
2. Developer-facing API surface
The main user API lives in nuvom.task, nuvom.sdk, nuvom.job, and nuvom.result_store. The README examples show the intended flow: decorate a function as a task, call delay() to enqueue a job, or schedule() for timed execution. These modules are the boundary between application code and the engine.
3. Task discovery and manifest generation
Discovery is a distinct subsystem under nuvom/discovery. It uses AST-oriented parsing and file walking (walker, parser, filters, reference, compute_path) to find task definitions without importing arbitrary user code. Discovery writes a manifest (.nuvom/manifest.json) so workers can start quickly and resolve tasks consistently. This is one of the repo’s central architectural choices.
4. Registry and task resolution
nuvom/registry and nuvom/internal/manifest.py provide the runtime index of discovered tasks. The registry bridges the static discovery output to execution-time lookup, so a queued job can be matched back to the correct task handler. The auto_register module suggests automatic registration from discovered metadata rather than manual wiring.
5. Job lifecycle
Jobs are represented in nuvom/job.py and executed through nuvom/execution/job_runner.py. The typical flow is: task call creates a job object, queue backend persists it, worker fetches it, job runner executes the underlying function, then the result is handed to a result backend. Retries, timeout handling, and result storage are part of this lifecycle and are covered by dedicated tests.
6. Queueing subsystem
Queue abstractions live in nuvom/queue.py and nuvom/queue_backends. There are concrete backends for memory, file, and SQLite, all built on a base interface. This is the primary durability boundary for “pending work”: the same job model can move through different persistence layers depending on deployment needs.
7. Result persistence subsystem
Results are separated from queueing in nuvom/result_backends and nuvom/result_store.py. Like the queue, result storage has memory, file, and SQLite implementations with a shared base contract. That separation matters architecturally because job dispatch and job outcome retention can scale or be swapped independently.
8. Scheduler and delayed execution
Scheduling is a first-class subsystem under nuvom/scheduler. It has its own models, dispatcher, backend abstraction, worker, and storage backends. The scheduler handles delayed, interval, and cron-style triggers and moves due jobs into the execution pipeline. In the architecture diagram, this is a parallel control plane feeding the queue, not the same thing as the worker that runs task code.
9. Worker runtime
nuvom/worker.py and nuvom/scheduler/worker.py represent the execution agents. The worker consumes queued jobs, resolves them through the registry/manifest, runs them through the job runner, and writes outcomes to the result store. The scheduler worker has a narrower role: detect due scheduled work and hand it off to the queue.
10. Plugin architecture
Plugins are explicit in nuvom/plugins, with contracts, loader, registry, and a Prometheus monitoring plugin. The repo also includes .nuvom_plugins.toml, which is the configuration boundary for extensions. This subsystem is how Nuvom supports custom backends, monitoring, and other operational integrations without changing core engine code.
11. CLI as the operational entry point
nuvom/cli exposes the operator-facing commands: discover tasks, list tasks, inspect jobs, view history, manage plugins, and run workers or test workers. The CLI is the main orchestration layer for developers and operators, turning the underlying subsystems into executable workflows.
12. Serialization, configuration, and support utilities
Serialization is isolated in nuvom/serialization with a msgpack-based serializer. Configuration and compatibility helpers live in nuvom/config.py and nuvom/utils, including TOML compatibility and safe file deletion. These are supporting layers that keep persistence and cross-version behavior predictable.
13. How the main data flow fits together
The central data path is: source code task definitions → discovery/manifest → registry lookup → queue/scheduler persistence → worker execution → result storage. Scheduling inserts an additional path where timed jobs are promoted into the queue. Plugins can intercept or extend this flow, especially around storage and observability.
14. What to emphasize in an architecture diagram
The key boundaries are: application tasks vs. engine internals, discovery vs. runtime execution, queue vs. result storage, scheduler vs. worker, and core engine vs. plugins. The repo is intentionally modular, with multiple backend implementations behind shared interfaces, so the diagram should show interchangeable storage and extension points rather than a single monolithic service.
Main entry points: worker.py Worker · discover_tasks.py Discovery · registry.py Registry · queue.py Queue API
Components 21
Core engine
Task API, discovery, registry, execution, and runtime coordination.
- Task API · Decorator and scheduling surface for application code.
nuvom/task.py - SDK · User-facing helpers that complement the task boundary.
nuvom/sdk.py - Job Model · Represents queued, scheduled, and executing work items.
nuvom/job.py - Discovery · AST-based task discovery and manifest generation.
nuvom/discovery/discover_tasks.py - Manifest · Persisted task metadata used for fast startup and lookup.
nuvom/discovery/manifest.py - Registry · Resolves discovered tasks to runnable handlers at execution time.
nuvom/registry/registry.py - Auto Register · Loads discovered metadata into the runtime registry.
nuvom/registry/auto_register.py - Job Runner · Executes job payloads and coordinates retries and outcomes.
nuvom/execution/job_runner.py
Persistence
Pluggable queue, result, and scheduler backends.
- Queue API · Shared interface for pending work persistence.
nuvom/queue.py - Queue Backends · Memory, file, and SQLite queue implementations.
nuvom/queue_backends/base.py - Result Store · Shared interface for storing job outcomes.
nuvom/result_store.py - Result Backends · Memory, file, and SQLite result implementations.
nuvom/result_backends/base.py - Scheduler · Plans delayed, interval, and cron-like work.
nuvom/scheduler/scheduler.py - Dispatcher · Moves due scheduled work toward execution.
nuvom/scheduler/dispatcher.py - Scheduler Backends · Memory and SQLite persistence for scheduled work.
nuvom/scheduler/backend.py
Operations
CLI, plugins, and runtime entry points.
- Worker · Consumes queued jobs, resolves tasks, runs them, and stores results.
nuvom/worker.py - Sched Worker · Detects due scheduled work and hands it off to the queue.
nuvom/scheduler/worker.py - CLI · Commands for discovery, inspection, workers, and plugins.
nuvom/cli/cli.py - Plugins · Contracts, loader, registry, and monitoring integrations.
nuvom/plugins/contracts.py
Support
Serialization and compatibility utilities.
- Serialization · Msgpack-based encoding for jobs and persisted data.
nuvom/serialization/base.py - Config · Configuration and compatibility helpers.
nuvom/config.py
Connections 26
- Task API → Job Model: creates · Task invocation produces job records for dispatch.
- SDK → Task API: builds on · SDK helpers sit on top of the public task API.
- Task API → Discovery: discovers · Task definitions are found without importing user code.
- Discovery → Manifest: writes · Static discovery materializes a manifest for later startup.
- Manifest → Registry: loads · The manifest seeds runtime task resolution.
- Auto Register → Registry: populates · Discovered task metadata is registered automatically.
- Registry → Job Runner: resolves · Execution needs a handler lookup before running a job.
- Job Model → Queue API: enqueued via · Jobs are persisted through the queue abstraction.
- Queue API → Queue Backends: implemented by · Pending work can live in memory, files, or SQLite.
- Job Runner → Result Store: stores outcome · Completed execution writes to the result boundary.
- Result Store → Result Backends: implemented by · Results can be persisted through interchangeable backends.
- Scheduler → Dispatcher: drives · The scheduler determines which work is due.
- Dispatcher → Queue API: promotes · Due scheduled jobs are handed into the queue.
- Scheduler → Scheduler Backends: persists via · Scheduled work state is stored behind backend contracts.
- Sched Worker → Scheduler: runs · A dedicated worker processes schedule-side control flow.
- Worker → Registry: looks up · Workers resolve queued jobs to task handlers.
- Worker → Job Runner: executes with · Worker runtime delegates execution to the job runner.
- Worker → Result Store: records · Worker execution outcomes are persisted as results.
- CLI → Discovery: invokes · CLI exposes task discovery and listing operations.
- CLI → Worker: launches · CLI can run workers and test workers.
- CLI → Plugins: manages · CLI surfaces plugin inspection and scaffolding commands.
- Plugins → Result Backends: extends · Plugins can add or alter operational backends and integrations.
- Serialization → Queue API: encodes · Queued jobs are serialized for persistence and transport.
- Serialization → Result Store: encodes · Stored outcomes use the shared serialization layer.
- Config → Discovery: configures · Discovery and repo scanning are guided by configuration.
- Config → Plugins: configures · Plugin loading and extension settings come from config.