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>
6.1 KiB
Resource lifecycle station, version 1
This is an in-process C++17 software model. The port outlives every node. Removing an object does not close a port ticket. Nothing here models DDS, ROS middleware, physical devices, operating-system descriptors or process-exit cleanup.
C01: Identity and storage
A Station has eight slots, numbered 0..7. NEW slot owner subscriptions creates an unconfigured node. owner is 1..1000000 and must be unique among present nodes; subscriptions is 0..6. Invalid arguments return -22. An occupied slot or duplicate owner returns -17. A nonexistent slot returns -2; invalid slot numbers return -22. Argument validation precedes occupied/duplicate checks. NEW has no port activity. A removed slot is reusable. Other slots and port owners are unaffected by an operation.
C02: Lifecycle
States are unconfigured=0, inactive=1, active=2, finalized=3. CONFIG is permitted only in state 0, acquires one device (kind=0,index=0), then subscriptions (kind=1,index=0..subscriptions-1) in ascending order, and commits state 1 only when all acquisitions succeed. On acquisition failure release all acquired tickets in reverse acquisition order, retain state 0 and return -5. CONFIG elsewhere returns -16 without side effects. Each attempted acquisition consumes a monotonically increasing attempt number, including failures; only successes consume ticket IDs.
ACTIVATE from 1 enables each subscription in ascending index order and enters 2. DEACTIVATE from 2 disables each subscription in ascending index order and enters 1. Each returns -16 in other states and performs no port operations there. CLEANUP from 1 releases subscriptions in descending index order, then the device, increments cleanup_calls, and enters 0. Else it returns -16 without side effects.
C03: Terminal transitions and object removal
SHUTDOWN from each of states 0, 1 and 2 invokes that node's terminal callback once. The callback increments shutdown_calls, emits a terminal event, disables enabled subscriptions in ascending index order, releases subscriptions in descending index order then the device, and leaves state 3 with no tickets. SHUTDOWN in state 3 is an idempotent success: no additional callback or port activity. The callback applies equally to nodes that have never activated, nodes with zero subscriptions, and active nodes. STOP performs the same SHUTDOWN transition and then removes the node from its slot. A finalized node can be STOPped without another callback. Node destructors have no port access: they cannot substitute for the externally visible terminal transition. The terminal event records the pre-transition state; external port history survives.
C04: Port, faults and messages
Tickets start at 100 and increase by one on each successful acquisition, never reused. Port entries record ticket, owner, kind, index and enabled (initially 0). Port events have increasing serials starting at 1. Events are [serial,code,ticket, owner,kind,index,value]: acquire=1,value=0; release=2,value=last enabled flag; enable/disable=3,value=new flag; failed acquire=4,ticket=-1,value=-5; delivery=5,value=payload; terminal callback=6,ticket=-1,kind=-1,index=-1, value=prior_state. The terminal event precedes all callback resource operations. Only live subscription tickets can be enabled or delivered. No redundant enable/disable events are emitted. Failed acquisitions do not create entries. FAIL n selects absolute acquisition attempt n (n>=0); 0 disables injection. It does not reset counters; the matching attempt fails exactly once. Other acquisitions succeed. PUBLISH owner index payload (owner 1..1000000,index 0..5,payload 0..1000000) returns -22 for invalid arguments; otherwise delivers to that owner's enabled live subscription with that index, emits a delivery event, increments deliveries, and returns 1. If no enabled subscription matches, it returns 0 with no event.
C05: Observations
VIEW slot returns [-2] if absent, [-22] if invalid, otherwise [0,owner,state, subscriptions,device_ticket,shutdown_calls,cleanup_calls,subscription_tickets...]. Tickets are -1 when absent; exactly subscriptions entries follow, including -1. PORT returns [attempts,next_ticket,event_serial,deliveries,entry_count, (ticket,owner,kind,index,enabled)...], with entries in ticket order. EVENTS returns [event_count,(serial,code,ticket,owner,kind,index,value)...] in serial order. Reading observations has no side effects. No unspecified storage tail is observed.
C06: Text observer and submission
The supplied observer dispatches NEW, CONFIG, ACTIVATE, DEACTIVATE, CLEANUP, SHUTDOWN, STOP, FAIL and PUBLISH and prints their integer result as a JSON array. VIEW, PORT and EVENTS print the arrays above. Every command produces exactly one JSON array line, with integer elements (not booleans/fractions). Legal alternative JSON integer spellings and horizontal whitespace follow JSON rules. stderr is unrestricted diagnostic bytes and is not part of this protocol. Exit 0 on EOF. Inputs are valid commands with ASCII decimal integers in signed 32-bit range; blank lines and lines starting # are ignored. Tokens are separated by space/TAB/CR. The observer is fixed public support; formal grading rebuilds it with the submitted lifecycle.hpp, lifecycle.cpp and resource_port.cpp, using g++ -std=c++17 -O2. Retain public signatures/types, and satisfy C01..C07 for all allowed command sequences, including repeated transitions, independent slots, fault recovery and many create/stop cycles. No external dependencies or filesystem/network inputs.
C07: Persistent forensic queries
STATS owner validates owner 1..1000000 (-22 otherwise) and prints [0,live_devices, live_subscriptions,enabled_subscriptions,successful_acquisitions,releases, failed_acquisitions,deliveries]. Counts include all historical events for that owner, even after STOP and reusing the same owner; live counts use the current port ledger. HISTORY owner after accepts owner 0..1000000 (0 means all owners) and after 0..current_serial, else [-22]. It returns [0,event_count,events...] with exactly the C04 event fields, restricted to matching owner and serial >after. Both queries preserve all state and print only [-22] on invalid arguments.