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>
3.6 KiB
设备探测登记合同
C01. 这是单线程、确定性的内存设备登记库,不连接实际外设。include/probe.hpp 声明公共API。设备ID为0..31,code为0=offline、1=ready、2=busy、3=fault,evidence为0..65535,lifetime为0..1000,逻辑时钟范围0..1000000。库对API域外参数返回失败,不改变任何登记或时钟。
C02. Registry初始时钟为构造参数(默认0),空登记;无效构造参数等价初始0。reset有效时清空全部登记并设置时钟,无效时返回false且保持原状。advance接受非负增量且新时钟不超过1000000;成功只移动时钟,不刷新登记。
C03. set在当前时钟记录(id,code,evidence,stamp,lifetime)。首次登记revision=1、checks/accepted/rejected=0、last=-1;覆盖只替换前述探测事实并让revision加1,保留计数与last。drop仅删除存在的有效ID,删除后的再登记视为首次。每个ID相互独立。
C04. ask的Query必须保持三个输入字段完全不变。无效query(ID、strict不在0/1、evidence域外)返回6且不更新登记;有效但缺失返回-1。其余按以下顺序:now-stamp>lifetime返回5;未过期的offline/busy/fault分别返回0/2/3;ready且strict=1且证据编号不等返回4;其他ready返回1。边界now=stamp+lifetime仍有效。strict默认使用0;严格复核可显式使用1,evidence=0也是普通合法编号。
C05. ask不能改变code、evidence、stamp、lifetime、revision或其他设备。只有命中存在登记且query有效时,checks加1,last设为返回值;返回1则accepted加1,否则rejected加1。重复查询按相同事实判定,各计数继续累加。
C06. view只观察,返回exists和原始Record。缺失快照为exists=0、id=请求ID、code/evidence/stamp/lifetime=-1、revision/checks/accepted/rejected=0、last=-1。ids按ID升序返回当前登记ID;snapshots按相同顺序返回全部存活快照。所有观测不修改状态。
C07. totals只汇总当前存活登记:live、各code的offline/ready/busy/fault数量、未过期fresh数量、checks/accepted/rejected/revisions之和和fingerprint。fresh不取决于code。fingerprint为各登记(id+1)(3id+5code+7evidence+11stamp+13lifetime+17revision+19checks+23accepted+29rejected+31*last)之和,以int64计算。
C08. observer.cpp只是公开原始观察器。输入按LF分行,行内只以space/TAB/CR分隔,空行忽略。支持RESET now、SET id code evidence lifetime、ADV ticks、ASK id strict evidence、VIEW id、DROP id、SUMMARY;参数是完整ASCII十进制token,可有+/-和任意前导0,必须落在int64(SET/ASK/VIEW/DROP还要求int32)。语法错误返回2;有效语法的API域外值由库按条款拒绝并继续。stderr可包含任意诊断字节,不参与业务判定。
C09. 每命令输出一行原始十进制整数,token可有前导+、前导0、负零;token间允许space/TAB/CR,行以LF结束。不可有非数字token或额外行。快照序列S=[exists,id,code,evidence,stamp,lifetime,revision,checks,accepted,rejected,last],汇总序列T=[live,offline,ready,busy,fault,fresh,checks,accepted,rejected,revisions,fingerprint]。RESET=[0,ok,now];SET=[1,ok]+S;ADV=[3,ok,now];ASK=[2,verdict,query.id,query.strict,query.evidence]+S;VIEW=[4]+S;DROP=[5,ok]+T;SUMMARY=[6,now]+T。
C10. 只修改并提交列出的四个库文件,允许使用标准C++17;其余公开观察器与构建配置固定。不得读取评分器、依赖外部状态或硬编码公开复现输入。构建无下载:make;运行:./probe-demo < examples/default.txt。全部输入命令累计不超过10000条,所有计数与fingerprint在int64范围内。