The scheduling brain, built against CORE's headers (vdm/engine.hpp,
vdm/segment/budget.hpp) — signatures only; the Engine bodies land in
CORE stage 8 and the Scheduler that wires governor <-> store <-> engine
<-> timer comes after that (daemon/docs/deferrals.md D4).
- sched/governor — a pure decision function. In: a snapshot of every
task's coarse RunState and every queue's state (schedule windows
pre-resolved). Out: {to_start, to_resume, to_pause, pause_reasons,
priority_order}. Enforces, all in TASK units per ADR 0011 §1:
connection.maxConcurrentDownloads; the min(that, maxActiveSegments)
clamp (§2); Queue.maxConcurrent; the per-host task cap (§4); and a
stopped queue / closed window runs nothing. Never touches a task
paused for `user` or CORE's `auto` (ADR 0013 §3) — only Schedule /
QueueStopped / AdmissionReconcile are auto-resumable. Deterministic:
main-list before queued-in-queue, then queue order, then FIFO, then
task_id.
- sched/schedule_window — window_open(Schedule, local tm): disabled =>
always open; `once` => date + time match; `periodic` => weekday in
daysOfWeek (empty = every day) + time in [start, stop); null start =>
midnight, null stop => end of day, stop < start => overnight window.
Pure; re-evaluated every tick, no cached instants.
- veloxd_sched static lib; veloxd links it (nothing calls it yet).
Tests (ASan+UBSan and TSan clean): veloxd.sched_window (10 window
cases incl. overnight, once, null bounds), veloxd.sched_governor
(global/clamp/per-queue/per-host caps, stop vs window pause reasons,
resume-only-governor-reasons, auth-pause untouched, admission
reconcile, determinism under shuffled input). 32 daemon/cli tests
green; full tree green.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Upd9WhG9oppieig5nRDLig
88 lines
3.8 KiB
CMake
88 lines
3.8 KiB
CMake
# daemon/ produces the veloxd binary and the static libraries it is built from.
|
|
# Owned by lane DAEMON. Wired in by PKG via add_subdirectory(daemon) in the root file,
|
|
# guarded on this file existing.
|
|
#
|
|
# Layering (CLAUDE.md §3): depends on velox::core and velox::proto. No Qt. The engine
|
|
# (velox::core) is not linked yet — it arrives when sched/ and the task glue land. This
|
|
# drop is the RPC transports (Unix socket + loopback WebSocket), the SQLite store, and a
|
|
# dispatcher skeleton so the CLI and GUI have a real server to talk to.
|
|
|
|
if(NOT TARGET nlohmann_json::nlohmann_json)
|
|
find_package(nlohmann_json 3.11 REQUIRED)
|
|
endif()
|
|
find_package(Threads REQUIRED)
|
|
find_package(SQLite3 REQUIRED)
|
|
find_package(OpenSSL REQUIRED) # libcrypto: WebSocket accept hash, pairing token hash
|
|
|
|
# --- generated: migrations_embedded.hpp from src/store/migrations/*.sql ---------------
|
|
set(_mig_dir ${CMAKE_CURRENT_SOURCE_DIR}/src/store/migrations)
|
|
set(_mig_hdr ${CMAKE_CURRENT_BINARY_DIR}/generated/migrations_embedded.hpp)
|
|
file(GLOB _mig_srcs ${_mig_dir}/*.sql)
|
|
add_custom_command(
|
|
OUTPUT ${_mig_hdr}
|
|
COMMAND ${CMAKE_COMMAND} -DMIG_DIR=${_mig_dir} -DOUT=${_mig_hdr}
|
|
-P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/embed_migrations.cmake
|
|
DEPENDS ${_mig_srcs} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/embed_migrations.cmake
|
|
COMMENT "Embedding SQL migrations"
|
|
VERBATIM)
|
|
add_custom_target(veloxd_migrations_hdr DEPENDS ${_mig_hdr})
|
|
|
|
# --- veloxd_store — SQLite store, migrations, crypto helpers --------------------------
|
|
add_library(veloxd_store STATIC
|
|
src/util/crypto.cpp
|
|
src/store/sqlite.cpp
|
|
src/store/migrations.cpp
|
|
src/store/pairings.cpp
|
|
${_mig_hdr}
|
|
)
|
|
add_library(velox::daemon_store ALIAS veloxd_store)
|
|
target_include_directories(veloxd_store
|
|
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src
|
|
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/generated
|
|
)
|
|
target_compile_features(veloxd_store PUBLIC cxx_std_23)
|
|
target_compile_options(veloxd_store PRIVATE -Wall -Wextra -Wpedantic -Werror)
|
|
target_link_libraries(veloxd_store PUBLIC SQLite::SQLite3 PRIVATE OpenSSL::Crypto)
|
|
|
|
# --- veloxd_sched — the concurrency governor (pure; no engine link yet, see
|
|
# daemon/docs/deferrals.md D4) ---------------------------------------------------
|
|
add_library(veloxd_sched STATIC
|
|
src/sched/schedule_window.cpp
|
|
src/sched/governor.cpp
|
|
)
|
|
add_library(velox::daemon_sched ALIAS veloxd_sched)
|
|
target_include_directories(veloxd_sched PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
|
target_compile_features(veloxd_sched PUBLIC cxx_std_23)
|
|
target_compile_options(veloxd_sched PRIVATE -Wall -Wextra -Wpedantic -Werror)
|
|
target_link_libraries(veloxd_sched PUBLIC velox::proto nlohmann_json::nlohmann_json)
|
|
|
|
# --- veloxd_rpc — the RPC transports + dispatcher ------------------------------------
|
|
add_library(veloxd_rpc STATIC
|
|
src/rpc/runtime_dir.cpp
|
|
src/rpc/event_loop.cpp
|
|
src/rpc/uds_server.cpp
|
|
src/rpc/ws_frame.cpp
|
|
src/rpc/ws_handshake.cpp
|
|
src/rpc/ws_server.cpp
|
|
src/rpc/pairing.cpp
|
|
src/rpc/dispatcher.cpp
|
|
)
|
|
add_library(velox::daemon_rpc ALIAS veloxd_rpc)
|
|
|
|
target_include_directories(veloxd_rpc PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
|
target_compile_features(veloxd_rpc PUBLIC cxx_std_23)
|
|
target_compile_options(veloxd_rpc PRIVATE -Wall -Wextra -Wpedantic -Werror)
|
|
target_link_libraries(veloxd_rpc
|
|
PUBLIC velox::proto veloxd_store nlohmann_json::nlohmann_json Threads::Threads
|
|
)
|
|
|
|
# --- veloxd — the daemon binary -------------------------------------------------------
|
|
add_executable(veloxd src/main.cpp)
|
|
target_compile_features(veloxd PRIVATE cxx_std_23)
|
|
target_compile_options(veloxd PRIVATE -Wall -Wextra -Wpedantic -Werror)
|
|
target_link_libraries(veloxd PRIVATE veloxd_rpc veloxd_sched)
|
|
|
|
if(VELOX_BUILD_TESTS AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/tests/CMakeLists.txt)
|
|
add_subdirectory(tests)
|
|
endif()
|