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

87 lines
2.6 KiB
C

#ifndef COMMAND_PORT_H
#define COMMAND_PORT_H
#include <stddef.h>
#include <stdint.h>
#define COMMAND_MAX_BYTES 2048
#define COMMAND_MAX_RECORDS 16
#define COMMAND_MAX_EVENTS 32768
#define PORT_INTERRUPTED (-2)
#define PORT_ERROR (-1)
struct command_plan {
unsigned char payload[COMMAND_MAX_BYTES];
size_t payload_size;
size_t chunk_size;
long read_fault_at;
unsigned read_interrupts;
unsigned wait_interrupts;
unsigned child_exit;
unsigned child_signal;
int fail_open;
};
struct command_request {
size_t capture_limit;
unsigned tag;
};
enum command_status {
COMMAND_OK = 0,
COMMAND_OPEN_ERROR = 1,
COMMAND_READ_ERROR = 2,
COMMAND_CHILD_ERROR = 3,
COMMAND_INVALID = 4
};
struct command_result {
enum command_status status;
size_t bytes_seen;
size_t bytes_stored;
uint32_t checksum;
unsigned child_exit;
unsigned child_signal;
int truncated;
unsigned char capture[COMMAND_MAX_BYTES];
};
struct port_record {
int active;
int stream_open;
int child_owned;
unsigned generation;
unsigned tag;
size_t position;
unsigned read_interrupts;
unsigned wait_interrupts;
};
struct port_event {
unsigned operation;
unsigned token;
long value;
};
struct command_port {
struct command_plan plan;
struct port_record records[COMMAND_MAX_RECORDS];
struct port_event events[COMMAND_MAX_EVENTS];
size_t event_count;
unsigned next_generation;
unsigned stream_capacity;
unsigned child_capacity;
unsigned streams_live;
unsigned children_live;
unsigned streams_peak;
unsigned children_peak;
unsigned opens;
unsigned closes;
unsigned waits;
unsigned reads;
unsigned failures;
unsigned protocol_errors;
unsigned dropped_events;
};
int command_plan_valid(const struct command_plan *plan);
void command_port_init(struct command_port *port, unsigned streams, unsigned children);
int command_port_configure(struct command_port *port, const struct command_plan *plan);
int command_port_open(struct command_port *port, unsigned tag, unsigned *token);
long command_port_read(struct command_port *port, unsigned token, unsigned char *data, size_t size);
int command_port_close(struct command_port *port, unsigned token);
int command_port_wait(struct command_port *port, unsigned token, unsigned *exit_code, unsigned *signal_number);
size_t command_port_events(const struct command_port *port, struct port_event *events, size_t capacity);
int command_collect(struct command_port *port, const struct command_request *request, struct command_result *result);
#endif