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>
49 lines
1.4 KiB
C++
49 lines
1.4 KiB
C++
#include "runtime.hpp"
|
|
namespace cancelrt {
|
|
Reply Runtime::run(std::int64_t id, std::int64_t budget, std::int64_t cancel_after) {
|
|
if (!valid_id(id)) {
|
|
return fail(Code::RANGE);
|
|
}
|
|
if (!bounded(budget, 0, 32)) {
|
|
return fail(Code::RANGE);
|
|
}
|
|
if (!bounded(cancel_after, -1, 32)) {
|
|
return fail(Code::RANGE);
|
|
}
|
|
auto found = jobs_.find(static_cast<int>(id));
|
|
if (found == jobs_.end()) {
|
|
return fail(Code::MISSING);
|
|
}
|
|
Job& job = found->second;
|
|
if (job.active) {
|
|
return fail(Code::BUSY);
|
|
}
|
|
if (job.output.size() == job.input.size()) {
|
|
Reply reply = observe(job);
|
|
reply.stop = Stop::DONE;
|
|
return reply;
|
|
}
|
|
acquire(job);
|
|
int produced = 0;
|
|
Stop stop = Stop::YIELD;
|
|
while (produced < budget && job.output.size() < job.input.size()) {
|
|
if (cancel_after >= 0 && produced >= cancel_after) {
|
|
stop = Stop::INTR;
|
|
break;
|
|
}
|
|
auto index = job.output.size();
|
|
auto value = job.input[index] * job.factor + job.bias + static_cast<std::int64_t>(index);
|
|
job.output.push_back(value);
|
|
++produced;
|
|
}
|
|
if (job.output.size() == job.input.size()) {
|
|
stop = Stop::DONE;
|
|
}
|
|
release(job, stop);
|
|
Reply reply = observe(job);
|
|
reply.produced = produced;
|
|
reply.stop = stop;
|
|
return reply;
|
|
}
|
|
}
|