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

142 lines
4.5 KiB
C

#include "ticket.h"
#include "input.h"
#include <inttypes.h>
#include <stdio.h>
#include <stdint.h>
static TicketGrant sentinel(void)
{
TicketGrant grant;
grant.epoch = UINT64_C(9000000001);
grant.owner = UINT64_C(9000000002);
grant.first = UINT64_C(9000000003);
grant.last = UINT64_C(9000000004);
grant.count = UINT64_C(9000000005);
grant.sum = UINT64_C(9000000006);
return grant;
}
static void print_grant(const TicketGrant *grant)
{
printf(" %" PRIu64, grant->epoch);
printf(" %" PRIu64, grant->owner);
printf(" %" PRIu64, grant->first);
printf(" %" PRIu64, grant->last);
printf(" %" PRIu64, grant->count);
printf(" %" PRIu64, grant->sum);
}
static void print_stats(const TicketStats *stats)
{
printf(" %" PRIu64, stats->open);
printf(" %" PRIu64, stats->epoch);
printf(" %" PRIu64, stats->first);
printf(" %" PRIu64, stats->limit);
printf(" %" PRIu64, stats->next);
printf(" %" PRIu64, stats->allocated);
printf(" %" PRIu64, stats->committed);
printf(" %" PRIu64, stats->canceled);
printf(" %" PRIu64, stats->pending_owners);
printf(" %" PRIu64, stats->pending_units);
printf(" %" PRIu64, stats->committed_sum);
}
static int null_call(TicketBook *book, uint64_t kind, TicketGrant *out, uint64_t *aux)
{
size_t written = UINT64_C(9000000007);
TicketGrant list[TICKET_SLOTS];
switch (kind) {
case 0: return ticket_reserve(NULL, 1, 1, out);
case 1: return ticket_reserve(book, 1, 1, NULL);
case 2: return ticket_reset(NULL, 1, 10);
case 3: return ticket_commit(book, 1, NULL);
case 4: return ticket_cancel(NULL, 1, out);
case 5: return ticket_peek(book, 1, NULL);
case 6: return ticket_stats(book, NULL);
case 7: return ticket_list(book, list, TICKET_SLOTS, NULL);
case 8: return ticket_list(NULL, list, TICKET_SLOTS, &written);
case 9: {
int rc = ticket_list(book, NULL, TICKET_SLOTS, &written);
*aux = written;
return rc;
}
default: return -1;
}
}
static int apply(TicketBook *book, const Command *command, TicketGrant *out, uint64_t *aux)
{
if (command->opcode == 1) {
return ticket_reset(book, command->a, command->b);
}
if (command->opcode == 6) {
TicketStats stats;
return ticket_stats(book, &stats);
}
if (command->opcode == 7) {
TicketGrant list[TICKET_SLOTS];
for (size_t i = 0; i < TICKET_SLOTS; ++i) { list[i] = sentinel(); }
size_t written = UINT64_C(9000000007);
int rc = ticket_list(book, list, (size_t)command->a, &written);
*aux = written;
if (rc != 0 || (written > 0 && written <= TICKET_SLOTS)) {
*out = list[0];
}
return rc;
}
if (command->opcode == 8) {
return null_call(book, command->a, out, aux);
}
if (command->a > UINT32_MAX || command->b > UINT32_MAX) {
return -1;
}
uint32_t owner = (uint32_t)command->a;
uint32_t count = (uint32_t)command->b;
switch (command->opcode) {
case 2: return ticket_reserve(book, owner, count, out);
case 3: return ticket_commit(book, owner, out);
case 4: return ticket_cancel(book, owner, out);
case 5: return ticket_peek(book, owner, out);
default: return -1;
}
}
static void observe(unsigned sequence, const Command *command, int rc, const TicketGrant *grant, uint64_t aux, TicketBook *book)
{
TicketStats stats = {0};
TicketGrant list[TICKET_SLOTS];
size_t written = UINT64_C(9000000007);
int stats_rc = ticket_stats(book, &stats);
int list_rc = ticket_list(book, list, TICKET_SLOTS, &written);
printf("%u %d %u %d", sequence, command->opcode, command->book, rc);
print_grant(grant);
printf(" %" PRIu64, aux);
print_stats(&stats);
printf(" %d %zu", list_rc, written);
for (size_t i = 0; list_rc == 0 && i < written && i < TICKET_SLOTS; ++i) {
print_grant(&list[i]);
}
printf("\n");
(void)stats_rc;
}
int main(void)
{
TicketBook books[4] = {0};
unsigned line_number = 0;
unsigned sequence = 0;
Command command;
int status;
while ((status = command_read(stdin, &command, &line_number)) > 0) {
TicketGrant grant = sentinel();
uint64_t aux = UINT64_C(9000000007);
int rc = apply(&books[command.book], &command, &grant, &aux);
observe(++sequence, &command, rc, &grant, aux, &books[command.book]);
}
if (status < 0) {
fprintf(stderr, "invalid command at line %u\n", line_number);
return 64;
}
return ferror(stdout) ? 74 : 0;
}