amos 73a5240295 Batches 21 and 18: add 74 calibrated tasks (40 Bos redo, 34 HWE code-gen)
Batch 21 (20261027-A-bos-redo-21) rebuilt 40 of the 53 rejected Bos-qiao
environments: hidden assertions that ran inside the candidate's process
now run in a trusted parent that reads observations from a low-UID
worker; gold bytes are unchanged. 9 were excluded for scope (ROS2,
oversize, security core), 3 are blocked because the source requires an
exec bit the platform does not freeze, 1 lacks requests/bs4 in trace6.

Batch 18 (20261026-C-hwe-codegen-18) adds its last 34 of 134 tasks; the
first 100 landed in 2f32624d.

Claude reviewed 74/74 USABLE against current digests, canonical
families, no ID or source overlap with main, plain public docs. Only the
new task directories are taken; the stale pre-batch-20 copies of
concur-release-capsule and resource-temp-link on the batch 21 branch and
both branches' progress notes stay as main has them. Difficulty is
unmeasured.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 10:23:12 +08:00

19 lines
6.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# FlashBank 软件合同
1. 工程使用 C++17 和标准库,在 Linux 普通进程运行。这里的命令是本工程定义的逻辑操作,不接触 SPI、设备文件、线程或真实时间。实现须符合本文所有条款。提交 flash.hpp、flash.cpp、cli.cpp、main.cpp,保留公开声明;可以改变私有结构和算法。
2. namespace flash 的 Number 为 int64_t。Code 数值为 Ok=0、Range=1、Absent=2、Exists=3、Busy=4、Locked=5、Page=6、Syntax=7、Limit=8。Result 包含 code、error 字符串、fields 整数向量和 data 字节向量。成功的 error 为空;失败的 fields 和 data 为空,error 分别为 range、absent、exists、busy、locked、page、syntax、limit。所有失败均保持 Bank 的全部状态和数据。
3. 每个 FlashBank 对象独立拥有编号 0..3 的 chip。构造和 reset() 使所有 chip 不存在,所有字段及 image 字节为零,reset 成功且 fields/data 为空。可以同时使用多个 Bank,对象互不影响。
4. 存在的 chip 有 128 字节 image、wel、busy、kind、address、count、value、accepted、completed。wel 为 0 或 1;busy 是剩余逻辑 tick;kind 为 0(无命令)、1(program)、2(erase)。空闲命令描述符 kind/address/count/value 均为零。计数从零开始,仅接受命令和完成命令分别增加 accepted、completed。只读方法不改变状态。
5. attach(id,fill):id 为 0..3,fill 为 0..255。先检查数值范围,再检查 chip 是否已存在;已存在返回 Exists。成功创建一个新 chip,image 全部为 fill,其余字段为零,fields=[id,fill]。detach(id):先检查 id 范围,再检查是否存在,再检查 busy;不存在返回 Absent,busy 非零返回 Busy。成功恢复该 chip 的不存在初态,fields=[id]。
6. wren(id)、wrdi(id):先检查 id 范围、存在性、busy。成功分别设置 wel 为 1、0,fields=[id];重复调用仍成功。
7. program(id,address,count,value):id 为 0..3,address 为 0..127,count 为 1..16,value 为 0..255。先检查所有数值范围,再检查存在性、busy、wel、地址段。不存在返回 Absent,busy 非零返回 Busy,wel 为零返回 Locked;address 与 address+count-1 所属的 16 字节 page 不同则返回 Page。成功设置 busy=2、kind=1 及传入 address/count/value,accepted 加一,fields=[id,address,count,value]。image 此时不变。
8. erase(id,sector):id 为 0..3,sector 为 0..3。先检查所有数值范围,再检查存在性、busy、wel,所用错误与 program 相同。成功设置 busy=3、kind=2、address=sector*32、count=32、value=255,accepted 加一,fields=[id,sector]。image 此时不变。program 或 erase 接受时将 wel 置零,完成后保持为零。
9. advance(id,ticks):id 为 0..3,ticks 为 0..8;先检查数值范围再检查存在性。成功将 busy 减去 ticks 并截到零。原 busy 非零且本次变为零时,program 将目标字节逐个与 value 按位 AND,erase 将目标 32 字节置 255;完成后清零 kind/address/count/value,completed 加一。空闲时或 ticks=0 时成功而不完成新命令,fields=[id,ticks,剩余busy]。其它方法均不推进时间。
10. read(id,address,count) const:id 为 0..3,address 为 0..128,count 为 0..128 且 address+count<=128。先检查全部数值范围和和约束,再检查存在性、busy。成功 fields=[id,address,count],data 是 image 中从 address 开始的 count 字节,count=0 时 data 为空。word(id,address,width) const:id 为 0..3,address 为 0..127,width 为 1..4 且 address+width<=128;检查顺序同 read。成功 fields=[id,address,width,value],value 是相应连续字节组成的无符号小端整数,data 为空。
11. status(id) const:检查 id 范围及存在性,忙时仍可成功。成功 fields=[id,exists,wel,busy,kind,address,count,value,accepted,completed],data 为空。inspect() const 始终成功;fields 为 id 从 0 到 3 的四组 [exists,wel,busy,kind,address,count,value,accepted,completed],data 为同顺序四幅完整 image 的拼接;不存在的 chip 对应全零。inspect 忙时也可观察 image。
12. 除 read 和 inspect 的成功数据外,各方法 data 为空。各方法的成功 fields 只含上文列出的内容,返回 Code::Ok。所有公开方法不得向 stdout/stderr 写诊断,不读取外部资源。
13. CliResult 有 Number physical、processed、syntax 和 bool limited。run_cli(istream&,ostream&,FlashBank&) 每次先 reset 所提供的 Bank,计数从零开始。其输入按 LF 分物理行,末行无 LF 也处理;空输入不产生行。分词的分隔符仅为空格、TAB、CR,空行是 Syntax。命令区分大小写,不允许行内注释;整数是可带一个前导负号的十进制数字,允许前导零,禁止加号,必须落在 int64_t 范围;其它字节和溢出是 Syntax。
14. CLI 动词和参数为 RESET;ATTACH id fill;DETACH id;WREN id;WRDI id;PROGRAM id address count value;ERASE id sector;ADVANCE id ticks;READ id address count;WORD id address width;STATUS id;INSPECT。缺参、多参、未知动词或坏整数均输出 Syntax 并保持当前状态;合法语法调用同名 API 并使用其 Result。可以在错误后继续处理下一行。
15. run_cli 最多分派前 128 个物理行,包括成功、Syntax 和 API 错误行。读到第 129 行时输出一次 Limit,limited=true,停止分派;该行及后续行不得执行命令。physical 为已读行数,processed 为已分派行数,syntax 为前 128 行中 Syntax 数。未达到第 129 行时 limited=false。
16. 每个输出行格式为 `code error长度:error的hex fields数量 [各field] data长度:data的hex`,中间用单个 ASCII 空格;若 fields 为空,不放 field。所有整数使用无前导零的十进制,零写 0,hex 为小写,每字节两位,空字符串/空data写 0:,行尾为单个 LF。run_cli 不受 output 的数字基数、showbase、showpos、宽度、填充字符和 locale 数字分组设置影响;不要求保留这些格式标志。main 从 stdin 调用一次 run_cli,将其输出写 stdout,所有输入包括错误与 Limit 均返回 exit0,stderr 为空。正常空输入产生空 stdout。