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>
93 lines
2.7 KiB
C++
93 lines
2.7 KiB
C++
#ifndef PARAM_H
|
|
#define PARAM_H
|
|
|
|
#include <array>
|
|
#include <cstddef>
|
|
#include <cstdint>
|
|
#include <map>
|
|
#include <optional>
|
|
#include <string>
|
|
#include <string_view>
|
|
#include <vector>
|
|
|
|
namespace param {
|
|
|
|
enum class Kind { Decimal, Integer, Boolean, Text };
|
|
enum class Error { None, Unknown, Undeclared, AlreadyDeclared, Value, Syntax, Mismatch };
|
|
|
|
struct Value {
|
|
Kind kind = Kind::Text;
|
|
std::int64_t decimal_micros = 0;
|
|
int integer = 0;
|
|
bool boolean = false;
|
|
std::string text;
|
|
};
|
|
|
|
struct Schema {
|
|
std::string name;
|
|
Kind kind;
|
|
Value default_value;
|
|
};
|
|
|
|
struct Result {
|
|
Error error = Error::None;
|
|
std::string payload;
|
|
};
|
|
|
|
struct Assignment {
|
|
std::string name;
|
|
std::string token;
|
|
};
|
|
|
|
bool valid_name(std::string_view name);
|
|
std::optional<Schema> find_schema(std::string_view name);
|
|
const std::array<std::string_view, 4>& schema_order();
|
|
std::optional<Value> parse_value(const Schema& schema, std::string_view token);
|
|
std::string format_value(const Value& value);
|
|
std::string kind_name(Kind kind);
|
|
std::string error_name(Error error);
|
|
bool equal_value(const Value& left, const Value& right);
|
|
|
|
class Store {
|
|
public:
|
|
Store() = default;
|
|
void clear();
|
|
Result declare_one(const std::string& name);
|
|
Result declare_defaults();
|
|
Result declare_many(const std::vector<std::string>& names);
|
|
Result get(const std::string& name) const;
|
|
Result set(const std::string& name, const std::string& token);
|
|
Result patch(const std::vector<Assignment>& assignments);
|
|
Result reset(const std::string& name);
|
|
Result list() const;
|
|
Result count() const;
|
|
Result describe(const std::string& name) const;
|
|
Result compare(const std::string& name, const std::string& token) const;
|
|
Result changes() const;
|
|
Result restore_all();
|
|
Result remove(const std::string& name);
|
|
Result remove_all();
|
|
Result validate(const std::string& name, const std::string& token) const;
|
|
Result cas(const std::string& name, const std::string& expected, const std::string& replacement);
|
|
Result defaults() const;
|
|
Result missing() const;
|
|
Result declared_query(const std::string& name) const;
|
|
bool declared(const std::string& name) const;
|
|
std::size_t size() const;
|
|
|
|
private:
|
|
std::map<std::string, Value> values_;
|
|
Error validate_target(const std::string& name) const;
|
|
Result read_with_schema(const std::string& name, const Schema& schema) const;
|
|
Result write_one(const std::string& name, const Value& value);
|
|
};
|
|
|
|
std::vector<std::string> split_fields(std::string_view line);
|
|
Result execute(Store& store, std::string_view line);
|
|
std::string render(const Result& result);
|
|
std::string trim_line_end(std::string line);
|
|
|
|
} // namespace param
|
|
|
|
#endif
|