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>
8.4 KiB
Shared clock sample and page contract
C01. This project provides a deterministic offline clock sample service. It implements this document, with no external time protocol, real clock, thread scheduling, or network dependency. All arithmetic is integer arithmetic and all API objects are independent instances.
C02. Build with g++ -std=c++17 -O2 clockctl.cpp record.cpp time_math.cpp page.cpp service.cpp -o clockctl. The supported public API is clock.hpp. Only the six listed source/header files are collected from a repair; added files are not collected.
C03. Tick is uint64_t; one tick is 1/1024 second. The supported interval is 0 through LIMIT = 4503599627370495, inclusive. A wire stamp has uint32_t seconds and uint16_t fraction, with fraction 0 through 1023. Sample IDs are unsigned 32-bit integers greater than zero.
C04. Status codes are Ok=0, Invalid=-1, Range=-2, Inconsistent=-3, Rejected=-4, PublishFailed=-5, Empty=-6, Corrupt=-7, Stale=-8. Output arguments are left unchanged whenever a function returns a nonzero status. Inputs are never modified. Validation failures do not change any committed page or service state.
C05. A sample record contains eight comma-separated decimal fields: id, local_send, local_receive, remote_receive_seconds, remote_receive_fraction, remote_send_seconds, remote_send_fraction, hint. ASCII space and tab may surround each field; signs, internal whitespace, empty fields, comments, exponents, nondecimal characters, extra fields, embedded NUL, and line endings are invalid. Record length may not exceed 512 bytes. A decimal field may have leading zeros. Bad syntax returns Invalid; a syntactically valid number outside its field domain returns Range. Syntax is validated for every field before ranges are checked. format_record emits the same fields without whitespace or leading zeros.
C06. parse_record validates only syntax and field domains; chronological and delay checks belong to evaluate. format_record is defined for domain-valid samples. decode_hex accepts an even number of ASCII hexadecimal digits, either case, including empty input; malformed input returns Invalid and preserves output. encode_hex emits lowercase digits.
C07. unfold maps a wire stamp to the supported tick value congruent to seconds*1024+fraction modulo 4398046511104 that has the smallest distance from hint; a tie selects the smaller tick value, and candidates outside the supported interval are excluded. Invalid fraction or hint returns Range.
C08. ticks_to_microseconds rounds tick values to the nearest integer microsecond, with a half rounded upward; an input beyond LIMIT returns Range. microseconds_to_ticks rounds to the nearest tick, with a half rounded upward, then returns Range if the rounded result is beyond LIMIT. Both preserve their output on error.
C09. evaluate first checks sample domains and policy domain, then local_receive >= local_send. It unfolds each remote stamp using the same hint, requires remote_send >= remote_receive, remote duration <= 4096 ticks and local duration <= 10000000 ticks, and returns Inconsistent if any of those chronological conditions fail. It then computes delay = local duration minus remote duration; a negative delay is Inconsistent. Delay greater than policy.max_delay is Rejected. The policy domain is 0 through 10000000.
C10. The offset is ((remote_receive-local_send)+(remote_send-local_receive))/2, with signed division toward zero. A successful estimate has local=local_receive, remote=local_receive+offset, offset as the signed offset, delay as above, and id as the sample id. If remote falls outside 0 through LIMIT, evaluate returns Range. Domain failures precede chronological failures, which precede delay rejection. Estimate output is unchanged on failure.
C11. A page has 64 bytes. All multibyte fields are little endian: bytes 0..3 are ASCII CKS1; offset 4 has uint16 schema 1; offset 6 has uint16 size 64; offset 8 has uint64 sequence; offsets 16 and 24 have uint64 local and remote; offset 32 has the signed 64-bit two's complement offset; offset 40 has uint64 delay; offset 48 has uint32 id; offset 52 has uint32 zero; offset 56 has uint64 FNV-1a of bytes 0..55 (initial 14695981039346656037, multiply 1099511628211 after XOR, modulo 2^64).
C12. A new or reset page contains 64 zero bytes. Reading an all-zero page returns Empty. Other pages must match the format, have positive sequence and id, local and remote within LIMIT, offset within -LIMIT through LIMIT, remote=local+offset, and delay no greater than 10000000. A violation returns Corrupt. load accepts any 64 bytes without validating their contents; other lengths return Invalid without changing the page. bytes() returns the current 64 bytes.
C13. publish(snapshot, failpoint) accepts snapshots satisfying C12's field conditions and failpoint 0..3. Invalid failpoint returns Invalid; invalid fields return Range; these checks precede an injected failure. Failpoint zero commits the complete encoded page and returns Ok. Failpoints 1, 2, and 3 simulate interruption after preparing the header, payload, or checksum and return PublishFailed; every such failure leaves all 64 previously committed bytes unchanged. read can therefore continue to obtain the last successful snapshot after a failed publication.
C14. project(page, now, max_age, out) reads the page first and propagates its failure. It next returns Range if now or max_age exceeds LIMIT. It returns Stale if now is less than snapshot.local or now-snapshot.local is greater than max_age. Otherwise it returns Range if snapshot.remote + elapsed exceeds LIMIT; on success its projection contains sequence, remote_ticks=snapshot.remote+elapsed, and the rounded microseconds from C08. The page is unchanged.
C15. An Engine starts with an empty page and policy.max_delay=10000. configure accepts the policy domain in C09 and changes no page; invalid configuration returns Range and preserves policy. submit first parses, then evaluates under the current policy, then rejects an id not greater than the last successfully committed id with Rejected, then calls publish with sequence equal to the last committed sequence plus one. A nonzero publish result is returned unchanged; it consumes neither id nor sequence. Sequence exhaustion at UINT64_MAX returns Range. Engine state changes only after successful publication. reset restores initial page and policy.
C16. submit has no background activity and does not consult the environment. latest, page_bytes, project, policy, and summary are observations. Summary is empty before any successful sample and after reset; otherwise it is id=<id>;sequence=<sequence>;delay=<delay>. latest and project have C04 output preservation semantics.
C17. The command console uses UTF-8 input framed by LF, with the last line also processed at EOF without LF, and continues after errors. Command words and unsigned integer words are separated by one or more ASCII space, tab, CR, VT, or FF characters; leading and trailing such whitespace is allowed around commands other than the sample record remainder. Input integer words consist of ASCII digits, may contain any number of leading zeros, and must have value at most UINT64_MAX; the failpoint word must also fit unsigned 32-bit. A sample command skips field whitespace after its failpoint, then passes the remaining record to C05. Blank lines, non-ASCII command/integer characters, NUL, signed integer words, extra non-whitespace fields, and out-of-domain console integer words are malformed. Numeric output records have the documented number of decimal integer fields separated by ASCII space, tab, CR, VT, or FF; integer fields may have a sign and leading zeros. Output records are separated by LF, optionally preceded by CR, with an optional final LF. The bytes and summary commands emit the canonical text described below without surrounding field whitespace. sample FAILPOINT RECORD, policy MAX_DELAY, read, project NOW AGE, bytes, summary, and reset invoke the matching Engine functions. Successful sample, policy and reset print status only; read prints status followed by sequence, local, remote, offset, delay, id; project prints status followed by sequence, remote_ticks, microseconds; failed read/project print status only. bytes prints lowercase page hex, summary prints the summary string. Unknown/malformed console commands print -1. Console exits zero at EOF. API users may instantiate Page independently for raw page import or direct publication.