From 3ac4ede73d6d6f832793209b6a3afeb9c9e0e84f Mon Sep 17 00:00:00 2001 From: dsh Date: Wed, 18 Nov 2026 18:57:09 +0800 Subject: [PATCH] AGENTS: the machine semantics are frozen except for INP/OUT The owner stated the rule plainly: apart from INP/OUT (which are host interface decisions), machine semantics do not change unless explicitly asked -- the eight instructions, biz/rnz testing the LSB, + rotating right, - flipping the low bit, how steps are counted, the 259 cell ring, running from the first instruction to the end of the tape. The reason is that three implementations cross check each other and none of them is a second specification: a "harmless" tweak in one makes the other two look broken, with nothing to adjudicate. Changing semantics means writing it in SPEC first and changing all four machines together (SPEC 13); otherwise only tools and views may change. --- AGENTS.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/AGENTS.md b/AGENTS.md index 33b25e6..9e3fea6 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -72,8 +72,19 @@ powershell -File tests\widths.ps1 # 位宽矩阵:每个位宽一 * **代价的大头是"走"不是"算"**:`tape_run --profile` 实测,计算器 71.1%、全家桶 73.0% 的步数是 `>`/`<`,旋转只占 7%、翻转 4~6%。这台机器没有随机寻址,每次访问的代价就是 `|Δ地址|`,所以**布局才是性能旋钮**:`clb_digits` 的 13 格草稿重排一轮,全家桶 64513 -> 62513 字符、236439 -> 206491 步(SPEC §7.7);`--opt` 再省 14~15% 步数,正是因为它砍的是往返移动。 * 一次会话很难把结论留在对话里 —— **落进 commit message 和文件注释**。 +## 一条硬规矩:不许动机器语义 + +**除了 `INP`/`OUT` 的语义(那是宿主接口,允许按需定义),机器语义在没有明确要求的情况下一个字都 +不许改**:8 条指令的行为、`biz`/`rnz` 判 `LSB`、`+` 是右旋、`-` 翻最低位、步数怎么算、 +内存是 259 格环、纸带从第一条指令跑到尾 —— 全部冻结。 + +这条规矩是有来由的:三份实现(`derive` / `tape_run` / ROT-8-viz)互为对拍,任何一边"顺手修一下" +都会让另外两边看起来是错的,而我们没有第二份规格可以裁决。要改语义,先在 SPEC 里写清楚、 +再四份一起改(见 §13),否则只改`工具`和`视图`。 + ## 语义上会咬人的几条 + ``` '-' flb 翻转最低位 cell ^= 1 '+' ror 右旋整个 cell (注意:和 Brainfuck 的 +/- 不一样,写仿真器时别按常识猜)