All 161 task packages, including the 21 batch 6 C++17 tasks that passed
gates 1/2, are now in Git. rollout.catalog builds docs/task-catalog.{json,md}
from the task packages, a fresh trace5 calibration (128/128 PASS), every
verified controller receipt on the current task digest, documented holds
and digest-bound difficulty reviews. 123 tasks are usable (6 HARD),
5 are on hold and 33 still need a subprocess-only grader.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
54 lines
2.7 KiB
C++
54 lines
2.7 KiB
C++
#include "alternative_registry.h"
|
|
#include <algorithm>
|
|
#include <set>
|
|
#include <utility>
|
|
|
|
namespace alternatives {
|
|
Error compile_world(const std::vector<Group> &groups, World &output) {
|
|
output = World{};
|
|
if (groups.size() > 64) return Error::invalid;
|
|
World next;
|
|
std::set<std::string> group_names, links;
|
|
std::size_t candidates = 0, slots = 0;
|
|
for (const Group &given : groups) {
|
|
if (!valid_id(given.name) || !group_names.insert(given.name).second || !valid_path(given.master_link) ||
|
|
!links.insert(given.master_link).second || given.candidates.size() > 64 || given.slots.size() > 16)
|
|
return Error::invalid;
|
|
candidates += given.candidates.size(); slots += given.slots.size();
|
|
if (candidates > 256 || slots > 256) return Error::invalid;
|
|
std::set<std::string> slot_names;
|
|
for (const Slot &slot : given.slots) {
|
|
if (!valid_id(slot.name) || !slot_names.insert(slot.name).second || !valid_path(slot.link) ||
|
|
!links.insert(slot.link).second) return Error::invalid;
|
|
}
|
|
std::set<std::string> paths;
|
|
for (const Candidate &candidate : given.candidates) {
|
|
if (!valid_path(candidate.path) || !paths.insert(candidate.path).second || candidate.attachments.size() > 16)
|
|
return Error::invalid;
|
|
std::set<std::string> attached;
|
|
for (const Attachment &attachment : candidate.attachments) {
|
|
if (!slot_names.count(attachment.slot) || !attached.insert(attachment.slot).second ||
|
|
!valid_path(attachment.target)) return Error::invalid;
|
|
}
|
|
}
|
|
if (given.mode == Mode::automatic) {
|
|
if (!given.pin.empty()) return Error::invalid;
|
|
} else if (given.mode == Mode::manual) {
|
|
if (!paths.count(given.pin)) return Error::invalid;
|
|
} else return Error::invalid;
|
|
Group normalized = given;
|
|
std::sort(normalized.slots.begin(), normalized.slots.end(),
|
|
[](const Slot &a, const Slot &b) { return a.name < b.name; });
|
|
std::sort(normalized.candidates.begin(), normalized.candidates.end(),
|
|
[](const Candidate &a, const Candidate &b) { return a.path < b.path; });
|
|
for (Candidate &candidate : normalized.candidates)
|
|
std::sort(candidate.attachments.begin(), candidate.attachments.end(),
|
|
[](const Attachment &a, const Attachment &b) { return a.slot < b.slot; });
|
|
next.groups.push_back(std::move(normalized));
|
|
}
|
|
std::sort(next.groups.begin(), next.groups.end(), [](const Group &a, const Group &b) { return a.name < b.name; });
|
|
output = std::move(next);
|
|
return Error::none;
|
|
}
|
|
}
|