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

6.5 KiB

Parameter store contract

This program models a deterministic configuration port. It does not link to ROS2 or claim to reproduce an rclpy implementation. Its relevant rule is that a parameter must be declared, with a default value, before it can be read or overridden. The executable is a single process; all input comes from standard input. It prints exactly one line per input command to standard output. Diagnostic bytes on standard error have no protocol meaning.

Build with make (GNU make and g++ with C++17); run ./paramctl < commands.txt. The process returns 0 after processing all complete valid command lines. A malformed command prints ERR syntax and processing continues. No shell, network, clock, or ROS2 service is involved. Input line endings are LF; a terminal CR immediately before LF is accepted. Empty lines are ignored. Names are case sensitive ASCII identifiers: first character A-Z, a-z, or _; remaining characters may additionally be 0-9; maximum 32 characters. The four predefined names below are the only names accepted by DECLARE and BOOT.

Schema

name type default allowed overrides
rate decimal 30 finite decimal from 1 through 240 inclusive
retries integer 3 base 10 integer from 0 through 8 inclusive
enabled boolean true exactly true or false
mode text auto exactly auto, manual, or safe

The type label is decimal, integer, boolean, or text. The canonical value of a decimal has no trailing zeroes after the decimal point, no decimal point if integral, and no leading plus sign. Scientific notation is accepted for a decimal override, but the canonical output is ordinary decimal notation with at most six digits after the point. Decimal overrides are required to be exactly representable at six decimal places. Integer output is ordinary base 10 without leading zeroes. All comparisons use the typed value, so 30, 30.0, and 3e1 are the same rate.

State and commands

At process start nothing is declared. Each complete nonempty line is one command; fields are separated by one or more ASCII spaces or tabs. BOOT removes prior state, declares all four names with the listed defaults, and replies OK boot 4. It can be repeated. DECLARE name declares one predefined name with its default and replies OK declare name; a repeated declaration replies ERR already_declared, and an unknown name replies ERR unknown. A failed declaration leaves state unchanged.

GET name replies OK name type value using the current canonical value, or ERR undeclared if the name is recognized but not declared, or ERR unknown for an unrecognized name. SET name value changes exactly one declared parameter and replies OK set name; an unrecognized name replies ERR unknown, a known but undeclared name replies ERR undeclared, and a value that violates its type or range replies ERR value. A failed set leaves state unchanged. A valid set is idempotent.

PATCH assignment[,assignment...] applies one to eight name=value assignments atomically. Names may occur more than once; later assignments win. It replies OK patch N where N is the number of assignments. Each assignment is checked in input order using the same precedence as SET. If any fails, it prints the corresponding ERR ... and leaves all values unchanged. Empty assignments, missing equals signs, spaces inside the patch field, and more than eight assignments are syntax errors. No string value in this schema contains a comma, equals sign, space, or tab.

RESET name sets a declared name back to its schema default and replies OK reset name; unknown and undeclared names use the same errors as GET. LIST replies OK list followed by zero or more name:type:value fields, in schema order rate, retries, enabled, mode, for currently declared names only. Values are canonical. COUNT replies OK count N, the number of declared names.

DESCRIBE name replies OK describe name type default for a known schema name whether or not it has been declared, or ERR unknown. COMPARE name value validates a value and replies OK equal true or OK equal false by comparing it with the current typed value; unknown, undeclared, and invalid-value errors follow SET. CHANGES replies OK changes followed by zero or more name:value fields for declared parameters whose current value differs from its default, in schema order. RESTORE resets all declared values to defaults while retaining declarations and replies OK restore N, where N is the number of values that actually changed.

REMOVE name undeclares one name and replies OK remove name, or the GET-style unknown/undeclared error. CLEAR undeclares every name and replies OK clear N, where N is the number removed. After either command the declaration-before-read rule still applies. VALIDATE name value checks a token against a known schema without requiring declaration or changing state; it replies OK valid name canonical-value, ERR unknown, or ERR value. MISSING replies OK missing followed by the undeclared schema names in schema order. DECLARED name replies OK declared name true or OK declared name false for a known name, or ERR unknown otherwise.

DECLARE_MANY name[,name...] declares one through four distinct predefined names atomically; it replies OK declare_many N on success. A known name already declared, including an earlier name in the same command, replies ERR already_declared; unknown names reply ERR unknown. Any error leaves all declarations unchanged. Empty name fields, a trailing comma, or more than four names are syntax errors.

CAS name expected replacement validates both values against the named schema, then replaces the current value only if it equals the typed expected value. It replies OK cas name, ERR mismatch, or the same unknown/undeclared/value errors as SET. A failed CAS leaves state unchanged. DEFAULTS replies OK defaults followed by all four name:type:default fields in schema order.

Extra fields on a command are syntax errors. A command word is uppercase only. If a line has more than 4096 input bytes excluding LF, that line replies ERR syntax and processing continues at the next LF. A final unterminated line is processed as a line.

For a known but undeclared parameter, GET, SET, RESET, and PATCH fail with ERR undeclared; a declaration must precede them. Failed operations never implicitly declare a name. A BOOT failure would violate the contract because all four schema entries are valid.