feat(registry,daemon): answer HEAD without a body; mark editor generations stale
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 3s
VoidBuildSystem CI / signing-openssl-gcc16 (push) Failing after 11s

This commit is contained in:
faumaray committed 2026-12-04 05:16:57 +03:00
1 parent 2c4eeba945
commit 3fa7ab086f
8 files changed
+190 -2

No files matched your search

+46
View File
@@ -72,6 +72,7 @@ constexpr std::size_t kMaxCompdbArguments = 256U;
constexpr std::size_t kMaxCompdbArgumentBytes = 1024U;
constexpr std::size_t kMaxCompdbEntries = 500U;
constexpr std::size_t kMaxCompdbGenerations = 128U;
constexpr std::size_t kMaxStaleReasonBytes = 512U;
constexpr std::size_t kMaxActionOutputs = 8U;
constexpr std::size_t kMaxActionLimit = 1000U;
constexpr std::size_t kMaxPendingChanges = 4096U;
@@ -1194,6 +1195,32 @@ std::string compdb_generations_project(const DaemonOptions &options,
return serialize_response(JsonValue{std::move(object)});
}
// Marks a profile's editor metadata stale while retaining the last valid compile_commands.json.
std::string compdb_stale_project(const DaemonOptions &options, std::string_view profile_name,
std::string_view reason) {
const bool valid_profile =
!profile_name.empty() && profile_name.size() <= 128 &&
std::ranges::all_of(profile_name, [](char c) {
return std::isalnum(static_cast<unsigned char>(c)) || c == '.' || c == '_' || c == '-';
});
if (!valid_profile) {
return error_response("compdb_stale: profile must be 1-128 chars of [A-Za-z0-9._-]");
}
auto marked = Editor::mark_profile_stale(options.build_root, std::string{profile_name},
Editor::GenerationStatus::Stale, reason);
if (!marked) {
return error_response(std::format("compdb_stale: {}", marked.error().format()));
}
JsonValue::Object object;
object.emplace("ok", JsonValue{true});
object.emplace("op", JsonValue{std::string{"compdb_stale"}});
object.emplace("profile", JsonValue{std::string{profile_name}});
object.emplace("status", JsonValue{std::string{"stale"}});
return serialize_response(JsonValue{std::move(object)});
}
std::string_view action_kind_label(Graph::ActionKind kind) noexcept {
switch (kind) {
case Graph::ActionKind::Compile:
@@ -2186,6 +2213,25 @@ DaemonServer::Impl::DispatchResult DaemonServer::Impl::dispatch(std::string_view
}
return {compdb_generations_project(options, *value), false};
}
if (*name == "compdb_stale") {
const auto entry = object->find("profile");
if (entry == object->end()) {
return {error_response("compdb_stale requires \"profile\""), false};
}
const auto *value = std::get_if<std::string>(&entry->second.value);
if (value == nullptr || value->empty() || value->size() > kMaxDescribeProfileBytes) {
return {error_response("\"profile\" must be a bounded non-empty string"), false};
}
std::string reason;
if (const auto reason_entry = object->find("reason"); reason_entry != object->end()) {
const auto *reason_value = std::get_if<std::string>(&reason_entry->second.value);
if (reason_value == nullptr || reason_value->size() > kMaxStaleReasonBytes) {
return {error_response("\"reason\" must be a bounded string"), false};
}
reason = *reason_value;
}
return {compdb_stale_project(options, *value, reason), false};
}
if (*name == "compdb_entries") {
std::string file_filter;
if (const auto entry = object->find("file"); entry != object->end()) {