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>
75 lines
7.1 KiB
Markdown
75 lines
7.1 KiB
Markdown
# Array report contract v1
|
|
|
|
## C1 Build and interface
|
|
Use `make` with the available native gcc C11 toolchain. This is software execution on x86_64, not ARM certification.
|
|
The four submitted translation units link with array_report.h and observer.c; no external dependencies or extra files are used.
|
|
The callable entry is `int ra_process(const ra_request *, const ra_port *)`; the header defines all structures and helper interfaces.
|
|
All helper functions declared by the header remain linkable; their outputs have the definitions below.
|
|
A port offers allocate(context, bytes), release(context, pointer), and publish(context, report).
|
|
Each invocation is independent. Input structures must not be changed. stderr may contain arbitrary diagnostic bytes without a size limit.
|
|
|
|
## C2 Validation and results
|
|
A request is valid exactly when count=0..128, seed=0..65535, base=-100..100, step=-7..7, mode=0..3,
|
|
cutoff=0..100, window=1..16, bins=1..8 and fail_at=0..2. Missing request/port/callback is invalid.
|
|
Invalid requests return -2 without allocating, releasing or publishing. A valid count=0 returns 1 with no callbacks.
|
|
For nonempty valid input request count*sizeof(ra_cell) bytes, then count*sizeof(unsigned) bytes, in that order, once each.
|
|
The allocator returns NULL on call fail_at when fail_at is 1 or 2. Otherwise it returns distinct malloc-backed storage.
|
|
A NULL result returns -1 without publishing. Release every successful allocation exactly once on every exit path; never release NULL or unknown storage.
|
|
On success publish exactly one fully computed report, release both buffers and return 0. Publication occurs before either buffer is released.
|
|
No failed invocation publishes partial output. No unbounded allocation, real OOM, overflow or freed-storage access is needed.
|
|
|
|
## C3 Source array and selection
|
|
Begin with uint32_t word=seed. At each original position i=0..count-1, replace word by (1664525*word+1013904223) modulo 2^32.
|
|
Let raw=base+(i modulo 11)*step+((word>>16) modulo 101)-50.
|
|
mode 0 keeps raw; mode 1 takes abs(raw); mode 2 clamps raw into [-25,25]; mode 3 takes sign(raw)*raw*raw (zero stays zero).
|
|
Keep a transformed cell exactly when abs(value)>=cutoff. Keep original positions and preserve source order in the selected sequence.
|
|
Only the first selected_count cells and order entries are defined; unused tails have no required contents.
|
|
`ra_valid`, `ra_transform` and `ra_generate` implement these definitions.
|
|
|
|
## C4 Report fields 0..22: sequence analytics
|
|
All 56 fields are signed long long; initialise them to zero and then set the fields below. All results fit signed 64 bits.
|
|
0 original count; 1 selected count n; 2 rejected count; 3 sum; 4 sum of absolute values; 5 sum of value squares.
|
|
6 sum of (original_position+1)*value. 7 minimum; 8 maximum; 9 original position of first minimum; 10 original position of first maximum.
|
|
11 negative count; 12 zero count; 13 positive count; 14 sum of even values; 15 sum of odd values.
|
|
16 longest contiguous nondecreasing run length; 17 longest contiguous nonincreasing run length; empty sequences have run length zero.
|
|
18 sum of abs(difference) between neighbours of the selected sequence.
|
|
19 largest sum of a window of min(window,n) consecutive selected cells; 20 first selected-sequence index attaining it.
|
|
21 largest sum of a nonempty contiguous segment (may be negative). For empty sequences fields 7..10,19..21 remain zero.
|
|
22 uint32 checksum: begin 2166136261, for each selected cell xor uint32(value), multiply 16777619 modulo 2^32,
|
|
then xor original_position and multiply 16777619 modulo 2^32. Empty checksum is 2166136261.
|
|
`ra_analyse` sets exactly fields 3..22.
|
|
|
|
## C5 Report fields 23..35: order analytics
|
|
`ra_order` writes indexes of selected cells sorted by value ascending, ties by original position ascending.
|
|
23 number of distinct values; 24,25,26 sorted values at floor((n-1)*k/4) for k=1,2,3 respectively.
|
|
27 sum of (sorted_rank+1)*sorted_value; 28 largest gap between sorted neighbours (zero for n<2).
|
|
29 sum of abs(value-lower_median), where lower_median is field25. 30 original position of first sorted cell.
|
|
Partition [minimum,maximum] into bins integer buckets: index=floor((value-minimum)*bins/(maximum-minimum+1)).
|
|
When minimum=maximum every selected cell has bucket0. 31 earliest bucket with largest count; 32 that count;
|
|
33 number of occupied buckets; 34 sum of (bucket+1)*bucket_count. All fields23..34 are zero for empty selection.
|
|
35 number of pairs i<j in selected source order with value[i]>value[j]. `ra_rank` sets exactly fields23..35.
|
|
|
|
## C6 Report fields 36..55: signal analytics
|
|
36 minimum prefix sum and 37 maximum prefix sum, including the empty prefix of sum0.
|
|
38 number of strictly positive contiguous runs; 39 number of strictly negative contiguous runs; zero terminates both kinds.
|
|
40 longest strictly positive run length; 41 longest strictly negative run length.
|
|
42 number of strict interior local maxima; 43 number of strict interior local minima; endpoints are excluded.
|
|
44 number of equal neighbour pairs; 45 sum of products of neighbours.
|
|
46 largest count of skipped original positions between selected neighbours; 47 total skipped positions between selected neighbours.
|
|
48 length of longest strictly increasing subsequence; 49 length of longest strictly decreasing subsequence (not necessarily contiguous).
|
|
50 most frequent value, tied by its first occurrence in selected source order; 51 its frequency; 52 number of equal-value pairs i<j.
|
|
53 alternating sum value0-value1+value2-... in selected source order. Empty sequence fields36..55 are zero.
|
|
54 number of sign changes after removing zero values; 55 longest contiguous equal-value run length (empty=0).
|
|
`ra_trends` sets exactly fields36..55.
|
|
|
|
## C7 Public observer protocol
|
|
observer reads one decimal request per stdin line, nine fields in header order, until EOF; public examples use decimal ints. Counts -2,-3,-4,-5,-6 probe missing request, port, allocate, release, publish respectively, with an otherwise count=1 request.
|
|
Its callback instrumentation records allocation calls, release calls, live allocations, invalid releases, two requested byte sizes, and publish calls.
|
|
Release removes a tracked allocation; invalid release increments invalid_releases. After observing a request, observer safely frees any leftover tracked allocation.
|
|
The publication observer copies the 56 report fields and records a lifecycle violation as invalid_releases if either required allocation is no longer live. Any change to request or port fields also increments invalid_releases.
|
|
stdout has exactly one line per request: return_code allocation_calls release_calls live_allocations invalid_releases size1 size2 publish_calls then 56 report fields.
|
|
Before a publication the report copy is zero. Only the defined report fields are observed, never unused tails.
|
|
Each token is signed decimal ASCII: optional + or -, arbitrary leading zeros, separated by one or more SPACE/TAB/CR bytes.
|
|
One LF separates records, with optional final LF. No extra records or other stdout text are allowed. stderr is diagnostic only.
|
|
observer's successful exit is 0. An input syntax error is 2. Required grading inputs are within C int range, including explicit invalid-contract requests.
|