amos f611da1e57 Batch 24: add 23 calibrated tasks written from Bos seed directions
Batch 24 (20261102-C-bos-seed-24) screened all 3078 Bos seed queries.
Only 23 themes were in scope (pure user-space reliability, at most one
task per theme); the rest were single operations or explanations,
installs and networking, system administration, ROS2, board-only or GUI
requests. Two finished drafts were withdrawn as too close to existing
tasks. Seeds supply direction only: all sources, contracts and tests are
new, and no task shares more than 14 characters with its seed text.

Each task passed the local gate and the trace6 Docker gate (5 runs per
sample class). Claude rebuilt the catalog from the calibration receipts:
23/23 USABLE. 16 of 23 are C/C++.

Only the task directories are taken; the batch worktree's lowered disk
floor in rollout/core.py stays out of main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 17:21:50 +08:00

100 lines
2.6 KiB
C++

#ifndef SHARED_CLOCK_HPP
#define SHARED_CLOCK_HPP
#include <array>
#include <cstdint>
#include <string>
#include <vector>
namespace shared_clock {
using Tick = std::uint64_t;
constexpr Tick LIMIT = 4503599627370495ULL;
constexpr Tick PERIOD = 4398046511104ULL;
constexpr Tick MAX_SPAN = 10000000ULL;
constexpr Tick MAX_REMOTE_SPAN = 4096ULL;
enum class Status : int {
Ok = 0,
Invalid = -1,
Range = -2,
Inconsistent = -3,
Rejected = -4,
PublishFailed = -5,
Empty = -6,
Corrupt = -7,
Stale = -8
};
struct Stamp {
std::uint32_t seconds = 0;
std::uint16_t fraction = 0;
};
struct Sample {
std::uint32_t id = 0;
Tick local_send = 0;
Tick local_receive = 0;
Stamp remote_receive;
Stamp remote_send;
Tick hint = 0;
};
struct Policy {
Tick max_delay = 10000;
};
struct Estimate {
Tick local = 0;
Tick remote = 0;
std::int64_t offset = 0;
Tick delay = 0;
std::uint32_t id = 0;
};
struct Snapshot {
std::uint64_t sequence = 0;
Tick local = 0;
Tick remote = 0;
std::int64_t offset = 0;
Tick delay = 0;
std::uint32_t id = 0;
};
struct Projection {
std::uint64_t sequence = 0;
Tick remote_ticks = 0;
std::uint64_t microseconds = 0;
};
Status parse_record(const std::string& text, Sample& out);
std::string format_record(const Sample& sample);
Status decode_hex(const std::string& text, std::vector<std::uint8_t>& out);
std::string encode_hex(const std::vector<std::uint8_t>& bytes);
Status unfold(Stamp stamp, Tick hint, Tick& out);
Status ticks_to_microseconds(Tick ticks, std::uint64_t& out);
Status microseconds_to_ticks(std::uint64_t micros, Tick& out);
Status evaluate(const Sample& sample, Policy policy, Estimate& out);
Status validate_snapshot(const Snapshot& snapshot);
class Page {
public:
Page();
void reset();
Status load(const std::vector<std::uint8_t>& data);
std::vector<std::uint8_t> bytes() const;
Status publish(const Snapshot& snapshot, unsigned failpoint);
Status read(Snapshot& out) const;
private:
std::array<std::uint8_t, 64> image_;
};
Status project(const Page& page, Tick now, Tick max_age, Projection& out);
class Engine {
public:
Engine();
void reset();
Status configure(Policy policy);
Policy policy() const;
Status submit(const std::string& record, unsigned failpoint);
Status latest(Snapshot& out) const;
Status project(Tick now, Tick max_age, Projection& out) const;
std::vector<std::uint8_t> page_bytes() const;
std::string summary() const;
private:
Page page_;
Policy policy_;
std::uint64_t sequence_;
std::uint32_t last_id_;
Tick last_delay_;
};
}
#endif