CORE stage 8 merged, so vdm::Engine is linkable. This closes D4a and narrows D4b: `velox add <url>` now actually downloads. - sched/engine_port_core.hpp — the real EnginePort: forwards to a live vdm::Engine, keeps the DownloadHandle per task for pause/resume/ cancel/provide_auth/decide/refresh_url, drives set_task_order / set_max_active_segments / set_host_segment_cap via engine.segment_budget(). CORE confirmed the admission model: DAEMON decides when to start(); the engine's own download_task calls register_task/set_want internally — DAEMON never touches per-task budget calls. EnginePort gains release(TaskId) so the port drops a handle when the task goes terminal. - rpc/event_loop — EventLoop::post(fn): thread-safe, runs fn on the loop thread next iteration. The marshaller for engine-thread callbacks. - main.cpp — constructs vdm::Engine + EnginePortCore + Scheduler (post_to_loop = loop.post). At startup: reconcile_after_restart() (ADR 0013 §5), reload_config(), tick(). A 1 s timerfd on the loop re-runs tick() (schedule windows, missed nudges); download.add nudges via dispatcher.set_on_mutation. End-to-end verified against tools/testserver: `velox add http://127.0.0.1:.../file/512K` -> task queued -> scheduler admits -> engine downloads 524288 bytes -> complete, file on disk. First byte-path all the way through the project. safepath-adversarial.md: re-verified per its own note — CORE landed O_NOFOLLOW on the target open (core/src/io/sparse_file.cpp), so the leaf-symlink TOCTOU is now closed; residual is down to one intermediate-dir gap (documented post-M1 chase). 36 daemon/cli tests green; scheduler + uds_roundtrip TSan-clean. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Upd9WhG9oppieig5nRDLig
50 lines
2.1 KiB
C++
50 lines
2.1 KiB
C++
#pragma once
|
|
|
|
// The seam between the Scheduler and CORE's engine. Everything the Scheduler drives on the
|
|
// engine goes through this interface, so the Scheduler is unit-testable without a live
|
|
// engine and the daemon is not bound to the concrete `vdm::Engine`. The real
|
|
// implementation (engine_port_core, added when velox::core's stage-8 bodies reach main)
|
|
// wraps `vdm::Engine` + `vdm::segment::SegmentBudget`; FakeEnginePort records calls.
|
|
//
|
|
// Task ids here are `vdm::TaskId` — the engine assigns one from start() and the Scheduler
|
|
// keeps the wire-UUID <-> TaskId map (ADR 0013). Admission is the Scheduler's: it calls
|
|
// start() only for a task the governor admitted, and the engine begins probing at once
|
|
// (it does not queue). The min-1 fairness rule in SegmentBudget then guarantees each
|
|
// started task a slot; set_task_order pushes the priority.
|
|
|
|
#include <cstdint>
|
|
#include <functional>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "vdm/ids.hpp"
|
|
#include "vdm/task/download.hpp"
|
|
|
|
namespace velox::daemon::sched {
|
|
|
|
class EnginePort {
|
|
public:
|
|
virtual ~EnginePort() = default;
|
|
|
|
virtual vdm::TaskId start(const vdm::task::DownloadSpec& spec,
|
|
vdm::task::DownloadCallbacks callbacks) = 0;
|
|
|
|
virtual void pause(vdm::TaskId) = 0;
|
|
virtual void resume(vdm::TaskId) = 0;
|
|
virtual void cancel(vdm::TaskId, bool discard_partial) = 0;
|
|
virtual void provide_auth(vdm::TaskId, const std::string& username,
|
|
const std::string& password, bool remember) = 0;
|
|
virtual void decide(vdm::TaskId, vdm::task::Decision) = 0;
|
|
virtual void refresh_url(vdm::TaskId, const std::string& url) = 0;
|
|
|
|
// The daemon is done with this task (it went terminal). Drop the handle. Idempotent.
|
|
virtual void release(vdm::TaskId) = 0;
|
|
|
|
// ADR 0011 admission surface. Values are DAEMON's; enforcement is the engine's.
|
|
virtual void set_task_order(const std::vector<vdm::TaskId>& order) = 0;
|
|
virtual void set_max_active_segments(std::uint32_t n) = 0;
|
|
virtual void set_host_segment_cap(const std::string& host, std::uint32_t cap) = 0;
|
|
};
|
|
|
|
} // namespace velox::daemon::sched
|