The user wants 2000 tasks, most of them ones Qwen cannot solve. New batch tasks are now measured on their branch first (3 Qwen trials each), and only HARD or MEDIUM tasks reach main; ROUTINE ones stay on the batch branches. A session cut by context_limit or output_limit counts as a failure for difficulty (user decision 2026-11-03); the trajectory stays incomplete. - Batch 26 (route D, real upstream fixes in embedded open-source projects): 7 HARD of 20 (coreJSON, littlefs, CANopen, coreMQTT, LwM2M, Zephyr ring, lwIP SNTP). Most failures are Qwen exhausting its context in the larger workspaces. - Batch 25 (HWE mutation repairs): 1 HARD and 1 MEDIUM of 56. - Batch 27 (spec-dense implementation tasks): 2 MEDIUM of the first 10. Each task comes from the exact commit Qwen measured, and its digest matches the measured one. Failure reasons are not yet reviewed, so difficulty is the automatic label. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
108 lines
3.8 KiB
C++
108 lines
3.8 KiB
C++
#include "chain.hpp"
|
|
#include <algorithm>
|
|
#include <functional>
|
|
#include <map>
|
|
#include <numeric>
|
|
#include <set>
|
|
#include <stdexcept>
|
|
namespace chain {
|
|
struct Engine::Impl {
|
|
unsigned width;
|
|
std::uint64_t serial = 0;
|
|
std::map<int, std::pair<Snapshot, Snapshot>> records;
|
|
explicit Impl(unsigned n) : width(n) {
|
|
for (unsigned i=0;i<n;++i) records.emplace(static_cast<int>(i),std::pair<Snapshot,Snapshot>{});
|
|
}
|
|
bool valid(int i) const { return records.find(i)!=records.end(); }
|
|
bool link(int i) const { return i==-1 || valid(i); }
|
|
Batch error(int code) const { Batch b; b.code=code; b.epoch=serial; return b; }
|
|
int follow(int i,std::set<int> &visited,std::vector<int> &order) const {
|
|
if(i==-1) return OK;
|
|
if(visited.count(i)) return CYCLE;
|
|
const auto &r=records.at(i).first;
|
|
if(!r.active) return INACTIVE;
|
|
visited.insert(i);
|
|
order.push_back(i);
|
|
return follow(r.next,visited,order);
|
|
}
|
|
void fold(int i,std::size_t left,std::uint64_t position,Batch &out) const {
|
|
if(!left) return;
|
|
const auto &r=records.at(i).second;
|
|
out.path.push_back(i);
|
|
out.byte_count+=r.bytes.size();
|
|
out.token_sum+=r.token;
|
|
std::uint64_t j=0;
|
|
out.checksum+=std::accumulate(r.bytes.begin(),r.bytes.end(),std::uint64_t{0},[&](std::uint64_t sum,unsigned v){return sum+position*(++j)*v;});
|
|
fold(r.next,left-1,position+1,out);
|
|
}
|
|
};
|
|
Engine::Engine(unsigned n) {
|
|
if(n<1 || n>24) throw std::invalid_argument("slots");
|
|
impl_=std::make_unique<Impl>(n);
|
|
}
|
|
Engine::~Engine()=default;
|
|
unsigned Engine::capacity() const { return impl_->width; }
|
|
int Engine::write(int slot,int next,std::uint32_t token,const std::vector<unsigned> &bytes) {
|
|
if(!impl_->valid(slot)) return SLOT;
|
|
if(!impl_->link(next)) return LINK;
|
|
if(bytes.empty() || bytes.size()>32 || std::any_of(bytes.begin(),bytes.end(),[](unsigned b){return b>255;})) return PAYLOAD;
|
|
auto &old=impl_->records.at(slot).first;
|
|
Snapshot replacement;
|
|
replacement.active=true;
|
|
replacement.next=next;
|
|
replacement.token=token;
|
|
replacement.revision=old.revision+1;
|
|
replacement.bytes=bytes;
|
|
old=std::move(replacement);
|
|
return OK;
|
|
}
|
|
int Engine::relink(int slot,int next) {
|
|
if(!impl_->valid(slot)) return SLOT;
|
|
if(!impl_->link(next)) return LINK;
|
|
auto &r=impl_->records.at(slot).first;
|
|
if(!r.active) return INACTIVE;
|
|
r.next=next;
|
|
++r.revision;
|
|
return OK;
|
|
}
|
|
int Engine::retire(int slot) {
|
|
if(!impl_->valid(slot)) return SLOT;
|
|
auto &r=impl_->records.at(slot).first;
|
|
auto revision=r.revision;
|
|
r=Snapshot{};
|
|
r.revision=revision+1;
|
|
return OK;
|
|
}
|
|
Snapshot Engine::view(int slot,int domain) const {
|
|
Snapshot out;
|
|
if(!impl_->valid(slot)) out.code=SLOT;
|
|
else if(domain!=0 && domain!=1) out.code=DOMAIN;
|
|
else return domain==0 ? impl_->records.at(slot).first : impl_->records.at(slot).second;
|
|
return out;
|
|
}
|
|
Batch Engine::submit(int head,const std::string &text) {
|
|
if(parse_amount(text,0).code!=OK) return impl_->error(AMOUNT);
|
|
if(!impl_->valid(head)) return impl_->error(SLOT);
|
|
std::set<int> seen;
|
|
std::vector<int> order;
|
|
int code=impl_->follow(head,seen,order);
|
|
if(code!=OK) return impl_->error(code);
|
|
auto grant=parse_amount(text,order.size());
|
|
if(grant.code!=OK) return impl_->error(AMOUNT);
|
|
Batch out;
|
|
out.granted=grant.value;
|
|
out.epoch=impl_->serial;
|
|
if(grant.value==0) return out;
|
|
order.resize(grant.value);
|
|
std::for_each(order.begin(),order.end(),[&](int i){auto &r=impl_->records.at(i); r.second=r.first;});
|
|
out.published=order;
|
|
impl_->fold(head,grant.value,1,out);
|
|
out.epoch=++impl_->serial;
|
|
return out;
|
|
}
|
|
void Engine::reset() {
|
|
unsigned n=impl_->width;
|
|
impl_=std::make_unique<Impl>(n);
|
|
}
|
|
}
|