amos 9d633e9e67 Batch 15 (20261023-C-hwe-scale-15): 320 HWE-derived repair tasks
One user-space repair task per eligible HWE debug-diag / compile-deploy base
ID: 320 admitted (C 218, C++ 97, build scripts 5), 1 skipped by the content
filter. Each ships a public spec with a check-to-basis table, at least two
defects with single-fix fixtures, a symptom-masking fixture and an alternative
correct implementation. Claude re-checked all 320: structure, the HWE quality
items and trace6 Docker calibration receipts against current digests
(320/320 USABLE). Difficulty is unmeasured. Known follow-up: 212 tasks use 120
ad-hoc family names; the next batch maps them to the canonical list.
The batch's 1,256-line progress log stays in its factory report and the
36-local branch batch15-hwe.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 01:55:56 +08:00

90 lines
2.3 KiB
C++

#ifndef PACKET_HPP
#define PACKET_HPP
#include <array>
#include <cstddef>
#include <cstdint>
#include <string>
#include <vector>
namespace packet {
enum class Kind { Node, Payload };
struct Allocation {
void* address;
std::size_t bytes;
Kind kind;
};
struct MemoryView {
std::uint64_t attempts = 0;
std::uint64_t allocated = 0;
std::uint64_t released = 0;
std::uint64_t failures = 0;
std::uint64_t invalid = 0;
std::uint64_t nodes = 0;
std::uint64_t payloads = 0;
std::uint64_t bytes = 0;
};
class Memory {
public:
Memory();
~Memory();
Memory(const Memory&) = delete;
Memory& operator=(const Memory&) = delete;
void* acquire(Kind kind, std::size_t bytes);
void release(void* address);
void fail_after(std::uint64_t count);
MemoryView view() const;
private:
std::vector<Allocation> live_;
MemoryView counters_;
std::uint64_t countdown_;
};
struct Packet {
std::uint32_t id = 0;
unsigned priority = 0;
std::uint32_t deadline = 0;
std::string data;
};
struct LaneView {
std::size_t count = 0;
std::size_t bytes = 0;
std::uint32_t head = 0;
std::uint32_t tail = 0;
std::uint32_t checksum = 0;
unsigned capacity = 8;
};
struct Stats {
std::uint64_t accepted = 0;
std::uint64_t popped = 0;
std::uint64_t expired = 0;
std::uint64_t cleared = 0;
std::uint64_t moved = 0;
std::uint64_t refused = 0;
std::uint64_t oom = 0;
};
class Queue {
public:
explicit Queue(Memory& memory);
~Queue();
Queue(const Queue&) = delete;
Queue& operator=(const Queue&) = delete;
int push(unsigned lane, const Packet& packet);
int pop(unsigned lane, Packet& packet);
int peek(unsigned lane, Packet& packet) const;
int expire(unsigned lane, std::uint32_t now);
int clear(unsigned lane);
int move(unsigned from, unsigned to, unsigned maximum);
int limit(unsigned lane, unsigned capacity);
LaneView lane(unsigned index) const;
Stats stats() const;
void shutdown();
private:
struct State;
State* state_;
};
bool number(const std::string& token, std::uint32_t maximum, std::uint32_t& value);
bool decode(const std::string& token, std::string& bytes);
std::string encode(const std::string& bytes);
std::uint32_t checksum(const Packet& packet);
std::vector<std::string> words(const std::string& line);
}
#endif