100 tasks from the HWE arm-linux code-gen pool (outside the lk/man/pth range given to batch 22), each with at least one independent contract-edge defect and plain public docs. Claude reviewed 100/100 USABLE against current digests; no ID or source overlap with main or batch 22. Difficulty is unmeasured. progress.md records the wrap-up: all Codex sessions and Qwen schedulers stopped for the user's rollout, Qwen results so far (57 HARD of 373), and what is left on each batch branch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
12 KiB
Virtual deadline dispatch contract
Every clause below is required. Time is integer ticks and this model has no threads, wall clock, operating-system queues, callbacks, files or hardware. Any implementation with the public C++17 API and these observations is valid; internal layouts and algorithms may change.
Objects and values
D01. dispatch.hpp is the public API in namespace edf. A default Dispatcher has capacity 8, clock 0, no task definitions or jobs, zero lifetime counters, and next admission serial 1. Objects, including copied objects, have independent state. Copy construction and copy assignment copy all state; self assignment preserves it. Destruction has no externally visible effect.
D02. Integer method arguments are signed 64-bit values. Valid task IDs are 1..1000000000, capacities 1..64, relative deadlines and configured execution budgets 1..1000000000, release delays and advance deltas 0..1000000000000, tags 0..4294967295, and run CPU limits 0..1000000000. MAX_TIME is 1000000000000. Stored times range from 0 to MAX_TIME inclusive. These ranges are independent: budget may exceed relative deadline.
D03. Status integers are Ok=0, Invalid=-1, Missing=-2, Exists=-3, Busy=-4, Full=-5, Range=-6, Empty=-7, Syntax=-8, Limit=-9. Errors change no object state or lifetime counters. A RunResult error has an empty event vector. All observation methods are const and change no state.
D04. reset(capacity, now) first checks capacity (Invalid), then clock (Range), then replaces the whole state with the specified capacity and clock. All definitions/jobs/counters disappear and next serial becomes 1. Constructor is equivalent to reset(8,0). Reset failure is atomic.
Definitions and admissions
D05. define(id, relative, budget) validates all scalar ranges first (Invalid), rejects an existing definition (Exists), then rejects capacity exhaustion (Full); otherwise adds an inactive definition. Definition capacity does not limit lifetime submission count. Definitions have no implicit priority from ID or insertion order.
D06. update(id, relative, budget) validates all scalar ranges (Invalid), requires a definition (Missing), then requires it to be inactive (Busy). Success changes both configured fields. erase(id) validates ID (Invalid), requires a definition (Missing), and requires inactive state (Busy), then removes it. Erase does not alter lifetime counters. Lowest or largest ID has no allocation semantics.
D07. post(id, delay, tag) validates scalar ranges (Invalid), requires a definition (Missing), and requires no active job for it (Busy), in that order. It then computes release=now+delay and absolute deadline=release+relative; either sum above MAX_TIME returns Range atomically. Success creates one job with remaining=configured budget and the supplied tag, assigns the next serial, increments that serial and submitted count. Serial is an unsigned 64-bit positive integer; if assigning it would prevent the following serial from being represented, admission returns Range without change.
D08. A definition has at most one active job. A second post never replaces it, even when its deadline has passed. Expiry is resolved only by a nonzero run. Jobs can be admitted before their release, and a positive relative deadline always puts deadline strictly after release. No budget is consumed by post or clock movement.
D09. cancel(id) validates ID (Invalid), requires a definition (Missing), then an active job (Empty). Success removes the entire job and increments cancelled once; partial CPU work remains charged to executed. A second cancel returns Empty. A cancelled or completed/missed definition can be posted again with a fresh serial/tag and its full configured budget.
D10. retime(id, delay) validates ID and delay (Invalid), requires definition (Missing), then active job (Empty), then checks the same release/deadline sums and serial representability as post (Range). Success replaces release, deadline and serial using the current clock and next serial; it preserves tag and the exact remaining execution ticks. It consumes one serial but changes no submitted/completed/cancelled/missed/executed counter. It is valid for future, partially executed and already overdue jobs. Repeated retimes are separate successful reorderings. Failure preserves the original job and serial allocator.
D11. advance(delta) validates delta (Invalid), checks now+delta<=MAX_TIME (Range), then moves the clock. It neither executes nor removes jobs, even when crossing releases or deadlines. Delta zero succeeds and preserves state.
Running
D12. run(cpu_limit) validates its range (Invalid). A zero limit succeeds with no events, no clock change and no expiry processing. A positive limit repeatedly processes the rules below until its CPU allowance is exhausted or no jobs remain. Idle clock jumps and missed-job events do not consume CPU allowance.
D13. At the start of each iteration of a positive run, remove every active job with deadline<=now and positive remaining work. Emit a Missed event for each, sorted by (deadline,serial), increment missed, and preserve executed. This sweep also occurs after a slice consumes the last CPU tick; it occurs after any just-completed job is removed. A zero-budget completion is therefore never a miss. Expiry compares absolute deadline with the current virtual clock; it is not conditioned on configured budget or task ID.
D14. After the sweep, stop if CPU allowance is zero or there are no jobs. Among jobs with release<=now, select the minimum (deadline,serial). Serial makes ties stable in admission/retime order. If none is ready, jump clock to the minimum active release, then repeat the sweep/selection; do not emit an idle event. Every selected job has a strictly positive time until deadline.
D15. Execute a slice whose ticks are the minimum of remaining job work, unused CPU allowance, deadline-now, and the distance to the earliest strictly future release among all active jobs (omit this last bound if there is no future job). Every release boundary ends a slice even if the arriving job will not preempt the current winner. Advance clock by the slice ticks and subtract them from the job's remaining work and the allowance; add them to executed. Ready jobs may preempt only at such slice boundaries or between run calls. Clock never passes MAX_TIME because all active deadlines are within it.
D16. Emit exactly one event per slice: Done=2 if remaining became zero, otherwise Partial=1. A Done removes the job and increments completed once. Event start/end are the clock before/after the slice; used=end-start is that slice's work, and remaining is the work left after the slice. Completion exactly at deadline is Done. On the next iteration, overdue unfinished jobs (including a Partial that reached its deadline) generate Missed events. A Missed event has kind=3, start=end=now, used=0, and remaining equal to discarded work.
D17. Every event contains the selected/expired job's id, tag, absolute deadline and current serial. Events are returned in processing order. Errors never emit events. No event is emitted by reset, define, update, erase, post, cancel, retime, advance or observations.
Observations and accounting
D18. stats() returns capacity, now, defined (definition count), active (job count), submitted, completed, cancelled, missed, and executed (total CPU ticks in slices since reset). Successful post increments submitted, successful cancel increments cancelled, completion increments completed, and missed removal increments missed. No other action changes these four counters. Always submitted=active+completed+cancelled+missed, regardless of failed operations, retime, erasure or idle jumps.
D19. inspect() returns a vector of View for every definition sorted by ascending id. Each has id, configured relative/budget, active flag, release, deadline, remaining, serial and tag. All five job fields are zero for inactive definitions; active flag is false/true. Returned vectors and structs are value snapshots; modifying them cannot change a dispatcher. Inspect does not process overdue jobs. Stats and inspect remain valid on an empty dispatcher and after any error.
Transactional plan API
D20. apply_plan(Dispatcher&, string_view) accepts at most 4096 bytes and 32 instructions. The exact ASCII grammar is plan := instruction (';' instruction)*; instruction is one of define(id,relative,budget), update(id,relative,budget), erase(id), post(id,delay,tag), cancel(id), retime(id,delay), advance(delta). Names are case sensitive; punctuation is literal. No whitespace, sign, comments, empty instructions or final semicolon is allowed. Numbers contain one or more ASCII decimal digits, allow leading zeros, and must fit signed 64-bit. Non-ASCII bytes and embedded NUL are Syntax. Empty text is a successful empty plan.
D21. PlanResult has status code and zero-based instruction index. Over 4096 bytes returns Limit with index=0 before parsing; attempting a 33rd instruction (including an empty one) returns Limit with index=32 before parsing that instruction. Otherwise all instructions are parsed before executing any. A syntax error returns Syntax with its instruction index, even when a preceding syntactically valid instruction would fail semantically. For example erase(77);bad(1) returns Syntax,index=1 regardless of state. Parsing numeric overflow is Syntax. Parsed but out-of-method-range values are semantic Invalid/Range as specified above.
D22. For syntactically valid text, execute instructions against a deep copy in order. The first nonzero method status returns that status and its instruction index; discard every earlier mutation from the plan, including serial allocation, clock, definitions and counters. Success commits the copied state and returns Ok,index=instruction count (0 for empty). No partial result is observable. The same plan may be applied independently to multiple objects. The API deliberately excludes reset and run from plans.
Build and console
D23. Public files are dispatch.hpp, dispatch.cpp, plan.cpp, console.cpp, Makefile and these docs. Build with make; it uses g++ -std=c++17 and no nonstandard library. The immutable console observes the public API. Final grading rebuilds declared candidate files with an equivalent observation-only harness; only dispatch.hpp, dispatch.cpp and plan.cpp are submitted and graded. Additional files are not collected. Preserve public signatures/types/enumerator values; private representation and source organization within these three files can change.
D24. Console input is one command per line. Each command selects an object number 0 or 1: n s cap now, d s id relative budget, u s id relative budget, e s id, p s id delay tag, c s id, t s id delay, a s delta, r s cpu, s s, v s, b s text, and y destination source (copy assignment). Here the initial lowercase command is followed by the shown numeric arguments; s is the object number. For b, text is the entire remainder after exactly one separator space; b s means empty plan. Console numeric tokens are signed decimal int64, with an optional minus sign and no plus sign; tokens must fit int64 exactly, including unused extra tokens. Commands and object numbers are separate whitespace-delimited tokens. Malformed console syntax exits 2; normal EOF exits 0. Library status errors are ordinary observations and do not terminate input. The console itself does not assert correctness or generate inputs.
D25. Each non-observation command prints R status; plan prints B status index; stats prints S capacity now defined active submitted completed cancelled missed executed; inspect prints V count followed by one J id relative budget active release deadline remaining serial tag per view. Run prints R status event_count followed by F id tag kind start end deadline serial used remaining per event. Copy prints R 0. All integers are decimal. There are no other stdout lines. Output structs can be inspected directly by other harnesses; console formatting is only the public demonstration protocol.