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
..

Request wait manager

This C++17 project manages up to 16 named wait requests. driver.cpp supplies a deterministic wait port so the behavior can be reproduced without a real signal, clock, board, or network. Build with make CXX=g++ and run ./app. The submitted library files are include/request.hpp, src/request.cpp, src/text.cpp, src/format.cpp, and src/console.cpp; the Makefile and driver are public support files.

Input and output

Send one command per line on stdin. Commands are case sensitive. The command interpreter separates tokens on ASCII space, tab, and carriage return. A blank line or a line whose first token begins with # has no output. The public driver also accepts E event lines before or between commands; each event is queued for the next wait call. Each command emits exactly one O line followed by its result. Each wait call emits a W sec nsec rc error line before that command's O line. The driver exits 2 for a malformed command or malformed event. Diagnostics on stderr are unrestricted.

W fields are the actual request sent to the port in normalized sec and nsec, the port return code (0 or -1), and the port errno (0 on success). The maximum duration is 1,000,000,000,000 nanoseconds. A normalized time has nonnegative seconds and 0 <= nsec < 1,000,000,000.

The following event lines are supported:

Line Port effect
E S Success; out remaining time is unspecified.
E I <remaining_ns> Return -1, errno EINTR (4), with that normalized remaining time.
E X <sec> <nsec> Return -1, errno EINTR (4), with the exact supplied time, including invalid values.
E F <errno> Return -1 with positive non-EINTR errno; remaining out time is unspecified and contains a sentinel in this driver.

If the queue is empty, a wait returns -1 with EAGAIN (11). Events are consumed in FIFO order. Valid E I remaining values are from zero through the duration passed in that particular wait call, inclusive. The port's remaining out time is defined only on EINTR, never on success or other errors. An unexpected port return/errno or invalid EINTR remaining time is a protocol error (EPROTO, 71).

Request behavior

A id duration priority adds a pending request. IDs are 1..9999, priorities 0..3, and durations 1..1,000,000,000,000 ns. Duration tokens are unsigned decimal with optional leading +, optional leading zeros, and optional ns, us, ms, or s suffix (no suffix means ns). Fractions and negatives are invalid. Out-of-range values fail with -EINVAL (22); a duplicate ID fails -EEXIST (17); a full manager fails -ENOSPC (28). No request is partially inserted on rejection.

M id duration priority changes a pending request's duration and priority; its queue serial stays the same. D existing_id new_id duplicates a pending request using its remaining duration and priority, assigning a fresh serial. T id priority changes a pending request's priority. C id cancels a pending request. For ID-taking operations, absent IDs fail -ENOENT (2), and existing nonpending IDs fail -EALREADY (114); applicable malformed values fail -EINVAL. P removes all terminal requests and reports the number removed; IDs can then be reused. Z clears all requests and historical counters.

R id runs one pending request. N runs the highest priority pending request, breaking ties by insertion serial; if none exists it reports N -1 -2. B runs pending requests in that order until there are none or the first failure; its count includes the failed request. A direct R does not change other pending requests. Running an absent or terminal ID follows the same error rules as other ID operations.

The first wait call requests the request's full duration. After EINTR, the next call requests exactly the returned remaining time; no real elapsed clock is consulted. Each valid interruption adds asked - remaining to consumed time and increments the interruption count. If remaining is zero, the request completes immediately without an extra wait. A successful wait consumes the whole duration asked in that call and completes the request. At 32 interruptions with positive remaining time, stop with -ELOOP (40), leaving the known remaining time. A non-EINTR error terminates immediately with the negative errno, does not consume time for that failed call, and retains the last known remaining time; the unspecified remaining out value must not be read. Protocol errors terminate with -EPROTO. Done, failed, and canceled requests cannot be run again until purged and re-added.

Observations

Q id reports Q 0 id state priority original remaining consumed attempts interrupts error, or Q -2 if absent. States are pending 0, done 1, failed 2, canceled 3. A terminal failed request's error is the positive errno; other states have error 0. L reports insertion-order entries as L count | <request fields> .... O reports pending execution order as O count id .... S reports S pending done failed canceled consumed calls. Historical consumed and call totals include purged requests until Z; request counters count every actual port call and valid interruption. Q, L, O, and S do not consume port events.

Every syntactically valid command has a result even when its operation fails. Result lines are O A rc, O M rc, O D rc, O T rc, O C rc, O R rc, O N id rc, O B count rc, O Q ..., O L ..., O O ..., O S ..., O P count, or O Z 0.

Reproduce the field symptom

make CXX=g++
printf 'E I 4000000\nE S\nA 7 10ms 1\nR 7\nQ 7\n' | ./app

The port trace should show requests of 10 ms followed by 4 ms, and the final request should be done with 10 ms consumed. Other documented event types and queue commands are also part of the contract.