Batch 21 (20261027-A-bos-redo-21) rebuilt 40 of the 53 rejected Bos-qiao environments: hidden assertions that ran inside the candidate's process now run in a trusted parent that reads observations from a low-UID worker; gold bytes are unchanged. 9 were excluded for scope (ROS2, oversize, security core), 3 are blocked because the source requires an exec bit the platform does not freeze, 1 lacks requests/bs4 in trace6. Batch 18 (20261026-C-hwe-codegen-18) adds its last 34 of 134 tasks; the first 100 landed in 2f32624d. Claude reviewed 74/74 USABLE against current digests, canonical families, no ID or source overlap with main, plain public docs. Only the new task directories are taken; the stale pre-batch-20 copies of concur-release-capsule and resource-temp-link on the batch 21 branch and both branches' progress notes stay as main has them. Difficulty is unmeasured. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
150 lines
3.6 KiB
C++
150 lines
3.6 KiB
C++
#include "internal.hpp"
|
|
namespace ag {
|
|
bool parent_valid(Number value)
|
|
{
|
|
return value >= 0 && value <= 3;
|
|
}
|
|
bool group_valid(Number value)
|
|
{
|
|
return value >= 0 && value <= 7;
|
|
}
|
|
bool name_valid(Number value)
|
|
{
|
|
return value >= 0 && value <= 15;
|
|
}
|
|
bool value_valid(Number value)
|
|
{
|
|
return value >= -100000 && value <= 100000;
|
|
}
|
|
bool bytes_valid(Number value)
|
|
{
|
|
return value >= 0 && value <= 64;
|
|
}
|
|
bool publication_valid(Number parent, Number group, Number first, Number count,
|
|
Number writable)
|
|
{
|
|
if (!parent_valid(parent)) {
|
|
return false;
|
|
}
|
|
if (!group_valid(group)) {
|
|
return false;
|
|
}
|
|
if (!name_valid(first)) {
|
|
return false;
|
|
}
|
|
if (count < 1 || count > 4) {
|
|
return false;
|
|
}
|
|
if (first > 16 - count) {
|
|
return false;
|
|
}
|
|
if (writable != 0 && writable != 1) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
Change change_error(Code code)
|
|
{
|
|
Change result;
|
|
result.code = code;
|
|
return result;
|
|
}
|
|
Reading reading_error(Code code)
|
|
{
|
|
Reading result;
|
|
result.code = code;
|
|
return result;
|
|
}
|
|
Writing writing_error(Code code)
|
|
{
|
|
Writing result;
|
|
result.code = code;
|
|
return result;
|
|
}
|
|
GroupInfo group_error(Code code)
|
|
{
|
|
GroupInfo result;
|
|
result.code = code;
|
|
return result;
|
|
}
|
|
Listing listing_error(Code code)
|
|
{
|
|
Listing result;
|
|
result.code = code;
|
|
return result;
|
|
}
|
|
Registry::Registry() : state_(new State)
|
|
{
|
|
}
|
|
Registry::~Registry() = default;
|
|
Change Registry::publish(Number parent, Number id, Number first, Number count,
|
|
Number writable)
|
|
{
|
|
if (!publication_valid(parent, id, first, count, writable)) {
|
|
return change_error(Code::RANGE);
|
|
}
|
|
auto& record = state_->groups[parent][id];
|
|
if (record.live) {
|
|
return change_error(Code::EXISTS);
|
|
}
|
|
Number generation = state_->epochs[parent][id] + 1;
|
|
Number inserted = 0;
|
|
Code failure = Code::OK;
|
|
for (Number offset = 0; offset < count; ++offset) {
|
|
Number name = first + offset;
|
|
auto& cell = state_->cells[parent][name];
|
|
if (cell.live) {
|
|
failure = Code::EXISTS;
|
|
break;
|
|
}
|
|
cell.value = 0;
|
|
cell.owner = id;
|
|
cell.generation = generation;
|
|
cell.writable = writable;
|
|
cell.live = true;
|
|
++inserted;
|
|
}
|
|
if (failure != Code::OK) {
|
|
for (Number offset = 0; offset < count; ++offset) {
|
|
auto& cell = state_->cells[parent][first + offset];
|
|
cell.live = false;
|
|
}
|
|
return change_error(failure);
|
|
}
|
|
record.live = true;
|
|
record.generation = generation;
|
|
record.first = first;
|
|
record.count = count;
|
|
record.writable = writable;
|
|
state_->epochs[parent][id] = generation;
|
|
Change result;
|
|
result.code = Code::OK;
|
|
result.generation = generation;
|
|
result.published = count;
|
|
return result;
|
|
}
|
|
Change Registry::remove(Number parent, Number id)
|
|
{
|
|
if (!parent_valid(parent) || !group_valid(id)) {
|
|
return change_error(Code::RANGE);
|
|
}
|
|
auto& record = state_->groups[parent][id];
|
|
if (!record.live) {
|
|
return change_error(Code::ABSENT);
|
|
}
|
|
for (Number offset = 0; offset < record.count; ++offset) {
|
|
Number name = record.first + offset;
|
|
auto& cell = state_->cells[parent][name];
|
|
if (cell.live && cell.owner == id && cell.generation == record.generation) {
|
|
cell.live = false;
|
|
}
|
|
}
|
|
Change result;
|
|
result.code = Code::OK;
|
|
result.generation = record.generation;
|
|
result.published = record.count;
|
|
record.live = false;
|
|
return result;
|
|
}
|
|
}
|