feat(worker): lease queued actions in vbs worker
VoidBuildSystem CI / sanitizers-gcc16 (push) Failing after 3s
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 4s
VoidBuildSystem CI / signing-openssl-gcc16 (push) Failing after 32s
VoidBuildSystem CI / wine-windows-gcc16 (push) Failing after 52s

This commit is contained in:
faumaray committed 2026-12-05 11:36:17 +03:00
1 parent 2776e459e3
commit 452b2e315d
7 files changed
+107 -10

No files matched your search

+2
View File
@@ -342,6 +342,8 @@ Stage: VERIFIED — Plans 01–19 + Plan 20 Slices 1–2C + Track A + Track B (B
- **Wave 124 (Distributed Action Queue & VoidLibrary PR)**: the registry gained an in-memory action queue (`POST /api/v1/queue` to enqueue keys, `POST /api/v1/queue/lease` to lease the oldest unleased key to a worker, `GET /api/v1/queue` to list pending/leased keys), reusing the existing lease TTL/tokens; a completed result removes its key from the queue. `RegistryTests.worker_action_queue_enqueue_lease_and_complete` covers enqueue, ordered leases, exhaustion and listing. Pull request [Void/Library#64](https://git.faumaray.com/Void/Library/pulls/64) was opened for the native VoidLibrary build branch.
- **Wave 125 (Queue-Driven Worker Mode)**: `vbs worker --queue` (without `--action-key`) leases the next queued action from the registry (`Package::lease_queued_action`), then publishes blobs/record and submits the result exactly like the direct mode. The worker E2E now covers both modes, asserting the queue is empty afterwards.
## Remaining future scope
- **Superiority plan ([22-superiority-and-gaps.md](../roadmap/22-superiority-and-gaps.md), 2026-12-05)**: revised platform strategy - **macOS deferred**, **Windows via MinGW-w64 cross-compilation + Wine execution** (`dev cpp-gcc -p pkgsCross.mingwW64.stdenv.cc`, `dev cpp-gcc -p wine64`), native MSVC deferred; plus packaging parity (ZIP/DEB/RPM), IDE ecosystem, migration tooling, test-runner parity, benchmarks, CI runners, and remote execution in prioritized order.
+1
View File
@@ -127,4 +127,5 @@ Base HEAD: `fe0d1a6`
| Wave 122 (Remote worker protocol) | Registry worker registration/heartbeat, exclusive action leases with TTL/tokens, token-checked result upload with blob verification | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; new registry E2E passes, full CTest 8/8) | `registry/include/Void/Build/Registry/RegistryService.hpp`, `registry/service/RegistryService.cpp`, `tests/RegistryTests.cpp`, docs |
| Wave 123 (`vbs worker` client) | Worker CLI: register, lease, publish blobs/record, submit result; StateStore export; client APIs | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; worker CLI E2E passes, full CTest 8/8) | `src/Main.cpp`, `src/Package/RegistryClient.cpp`, `src/State/StateStore.cpp`, `tests/RegistryTests.cpp`, docs |
| Wave 124 (Distributed queue + VoidLibrary PR) | Registry action queue (enqueue/lease/list, result removes the key); PR Void/Library#64 opened | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; queue E2E passes, full CTest 8/8) | `registry/service/RegistryService.cpp`, `registry/include/Void/Build/Registry/RegistryService.hpp`, `tests/RegistryTests.cpp`, Void/Library#64, docs |
| Wave 125 (`vbs worker --queue`) | Queue-driven worker lease mode with `lease_queued_action`; E2E covers both modes | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; worker E2E passes, full CTest 8/8) | `src/Main.cpp`, `src/Package/RegistryClient.cpp`, `include/Void/Build/Package/RegistryClient.hpp`, `tests/RegistryTests.cpp`, docs |
| Future (Plan 20 Slice 3 / Tracks C, E3 editor extensions) |"}] Live `conan` CLI verification; macOS/Windows/cross-compile; binary-variant signing and key distribution; daemon-side dependency materialization and editor plugins; `Void::Net`/`Void::Sqlite` alignment | PLANNED (unimplemented) | [21-expansion-roadmap.md](../roadmap/21-expansion-roadmap.md), [20-future-translation-platforms.md](../roadmap/20-future-translation-platforms.md) |
+8
View File
@@ -1707,6 +1707,14 @@ VOID_INCLUDE_DIR=/tmp/opencode/vl-pin/include dev cpp -c bash fuzz/run.sh 30
- Also opened [Void/Library#64](https://git.faumaray.com/Void/Library/pulls/64) for the native
VoidLibrary build description.
## Queue-Driven Worker Mode (GCC 16.2, pin `0002e74`)
- `vbs worker --queue --record ... --build-dir ...` leases the next queued key instead of
`--action-key`, then publishes blobs/record and submits the result.
- `RegistryTests.worker_cli_leases_publishes_and_reports_result` **passed** (435 ms) for both the
direct and queue-driven modes; afterwards `GET /api/v1/queue` reports `"pending":[]`.
- Full CTest: **8 / 8 passed** in 287.29 s.
## Limits and Unrun Checks
1. **HTTPS git fetch**: the host shell is proxy-restricted, but the Docker container could clone `https://git.faumaray.com/Void/VoidLibrary.git`; the pinned commit `3e254055e081a104f08df68dde39711bc7813518` was fetched directly for the verification above. A separate configure against the local `/home/faumaray/Projects/Library` checkout via `VBS_VOID_SOURCE_DIR` also succeeded (development-only override, checkout unmodified).
@@ -71,6 +71,11 @@ register_worker(std::string_view registry_url, std::string_view platform,
lease_action(std::string_view registry_url, std::string_view action_key, std::string_view worker_id,
std::int64_t lease_seconds, const RegistryAuth &auth = {});
// Leases the oldest queued action for a worker (the record is not returned by the queue).
[[nodiscard]] Void::Result::Result<LeasedAction, Void::Result::Error>
lease_queued_action(std::string_view registry_url, std::string_view worker_id,
std::int64_t lease_seconds, const RegistryAuth &auth = {});
[[nodiscard]] Void::Result::Result<void, Void::Result::Error>
submit_action_result(std::string_view registry_url, std::string_view action_key,
std::string_view lease_token, std::string_view record_json,
+26 -10
View File
@@ -1453,6 +1453,7 @@ struct WorkerCmdOptions {
std::optional<std::string> registry_arg;
std::optional<std::string> action_key_arg;
std::optional<std::string> record_arg;
bool queue_mode{false};
std::string project_arg;
std::optional<std::string> build_arg;
std::string token_env{"VBS_REGISTRY_TOKEN"};
@@ -1460,8 +1461,9 @@ struct WorkerCmdOptions {
};
int execute_worker_command(const WorkerCmdOptions &opts) {
if (!opts.registry_arg || !opts.action_key_arg || !opts.record_arg) {
std::cerr << "vbs worker: --registry, --action-key, and --record are required\n";
if (!opts.registry_arg || !opts.record_arg || (!opts.action_key_arg && !opts.queue_mode)) {
std::cerr << "vbs worker: --registry, --record, and --action-key (or --queue) are "
"required\n";
return 2;
}
int lease_seconds = 60;
@@ -1472,7 +1474,6 @@ int execute_worker_command(const WorkerCmdOptions &opts) {
return 2;
}
const std::string registry = *opts.registry_arg;
const std::string action_key = *opts.action_key_arg;
Package::RegistryAuth auth{Void::Configuration::get_env_or(opts.token_env, "")};
auto record_text = Void::FileSystem::read_file(*opts.record_arg);
@@ -1506,13 +1507,26 @@ int execute_worker_command(const WorkerCmdOptions &opts) {
}
Void::Log::info("Worker", "Registered as {}", registration->worker_id);
auto leased =
Package::lease_action(registry, action_key, registration->worker_id, lease_seconds, auth);
if (!leased) {
std::cerr << "vbs worker: " << leased.error().message() << '\n';
return 1;
Package::LeasedAction leased;
if (opts.queue_mode && !opts.action_key_arg) {
auto queued =
Package::lease_queued_action(registry, registration->worker_id, lease_seconds, auth);
if (!queued) {
std::cerr << "vbs worker: " << queued.error().message() << '\n';
return 1;
}
leased = std::move(*queued);
} else {
auto direct = Package::lease_action(registry, *opts.action_key_arg, registration->worker_id,
lease_seconds, auth);
if (!direct) {
std::cerr << "vbs worker: " << direct.error().message() << '\n';
return 1;
}
leased = std::move(*direct);
}
Void::Log::info("Worker", "Leased action {} until epoch {}", action_key, leased->expires_epoch);
const std::string action_key = leased.action_key;
Void::Log::info("Worker", "Leased action {} until epoch {}", action_key, leased.expires_epoch);
State::RemoteCacheConfig remote;
remote.url = registry;
@@ -1550,7 +1564,7 @@ int execute_worker_command(const WorkerCmdOptions &opts) {
<< '\n';
return 1;
}
if (auto submitted = Package::submit_action_result(registry, action_key, leased->lease_token,
if (auto submitted = Package::submit_action_result(registry, action_key, leased.lease_token,
*record_text, auth);
!submitted) {
std::cerr << "vbs worker: " << submitted.error().message() << '\n';
@@ -3283,6 +3297,8 @@ int main(int argc, char **argv) {
worker_opts.registry_arg)
.option("--action-key", "", "Action key to lease and publish", worker_opts.action_key_arg)
.option("--record", "", "Action record JSON file to publish", worker_opts.record_arg)
.flag("--queue", "", "Lease the next action from the registry queue",
worker_opts.queue_mode)
.option_default("--project", "-C", "Project directory", worker_opts.project_arg, cwd)
.option("--build-dir", "-B", "Build directory", worker_opts.build_arg)
.option_default("--token-env", "", "Environment variable holding bearer token",
+40
View File
@@ -910,6 +910,46 @@ lease_action(std::string_view registry_url, std::string_view action_key, std::st
return leased;
}
Void::Result::Result<LeasedAction, Void::Result::Error>
lease_queued_action(std::string_view registry_url, std::string_view worker_id,
std::int64_t lease_seconds, const RegistryAuth &auth) {
auto parsed_url = parse_registry_url(registry_url);
if (!parsed_url) {
return std::unexpected{parsed_url.error()};
}
const std::string body = std::format("{{\"worker_id\":{},\"lease_seconds\":{}}}",
json_quote_of(worker_id), lease_seconds);
auto reply =
send_http_request(*parsed_url, "POST", "/api/v1/queue/lease", bearer_headers(auth), body);
if (!reply) {
return std::unexpected{reply.error()};
}
if (reply->status != 200) {
return std::unexpected{make_error(
reply->status == 404 ? Void::System::SystemErrorCode::not_found
: reply->status == 401 || reply->status == 403
? Void::System::SystemErrorCode::permission_denied
: Void::System::SystemErrorCode::io_error,
std::format("queue lease failed with HTTP {}: {}", reply->status, reply->body))};
}
auto json = Void::Json::Strict::parse(reply->body);
const auto *object = json ? std::get_if<JsonVal::Object>(&json->value) : nullptr;
if (!object) {
return std::unexpected{
make_error(Void::System::SystemErrorCode::io_error, "invalid queue lease response")};
}
LeasedAction leased;
leased.action_key = get_str(*object, "action_key");
leased.worker_id = get_str(*object, "worker_id");
leased.lease_token = get_str(*object, "lease_token");
leased.expires_epoch = get_i64(*object, "expires_epoch", 0);
if (leased.action_key.empty() || leased.lease_token.empty()) {
return std::unexpected{make_error(Void::System::SystemErrorCode::io_error,
"queue lease response is incomplete")};
}
return leased;
}
Void::Result::Result<void, Void::Result::Error> submit_action_result(std::string_view registry_url,
std::string_view action_key,
std::string_view lease_token,
+25
View File
@@ -2126,6 +2126,31 @@ VOID_TEST(RegistryTests, worker_cli_leases_publishes_and_reports_result) {
if (cas_blob) {
Void::Testing::expect(cas_blob->body == "WORKER_OUTPUT");
}
// Queue-driven mode: the worker leases the next queued key instead of --action-key.
auto enqueued = send_loopback_http(port, "POST", "/api/v1/queue", auth,
"{\"action_keys\":[\"" + action_key + "\"]}");
Void::Testing::expect(enqueued.has_value() && enqueued->status == 200);
Platform::ProcessRequest queued_worker = worker;
queued_worker.arguments = {"worker",
"--registry",
reg_url,
"--record",
record_file.string(),
"--build-dir",
(tmp / "build").string(),
"--queue"};
auto queued_res = Platform::run_supervised(queued_worker);
Void::Testing::expect_eq(
queued_res ? (queued_res->succeeded() ? std::string{}
: (queued_res->stdout_data + queued_res->stderr_data))
: queued_res.error().message(),
std::string{});
auto queue_state = send_loopback_http(port, "GET", "/api/v1/queue", auth);
Void::Testing::expect(queue_state.has_value() && queue_state->status == 200);
if (queue_state) {
Void::Testing::expect(queue_state->body.find("\"pending\":[]") != std::string::npos);
}
(*svc)->stop_http();
}