每日精选 · 2026-11-16Daily Digest · 2026-11-16
发布于 2026-11-16Published 2026-11-16
今日深读Today's Deep Read
把税法当代码编译:Lean 在美国税法里查出 138 个起草错误Compiling the Tax Code: Lean Finds 138 Drafting Errors in the U.S. Internal Revenue Code
税法可能是人类社会里执行得最严格、却最少被「验证」的一段文本:它决定了每年数万亿美元的流向,IRS 印发算例、律师研究漏洞、法院裁决争议,但没有人拿机器检查过它的文字本身。Lexifina 团队最近做了一件听起来很朴素、做完却不朴素的事:把《美国法典》第 26 编(内部收入法典)整部翻译成 Lean——一个证明要逐步检查、类型要对得上的形式化语言——然后看会发生什么。Tax law may be the most strictly enforced yet least verified text in human society: it moves trillions of dollars a year, the IRS prints worked examples, lawyers study loopholes, courts settle disputes — but nobody had ever run a machine check over its wording itself. The Lexifina team recently did something that sounds simple and turned out not to be: they translated Title 26 of the U.S. Code (the Internal Revenue Code) into Lean, a formal language where every proof step must type-check, and watched what happened.
第一步最简单也最惊人:把法条之间的交叉引用当成测试用例来跑。税法正文里散落着成千上万个引用,有的有超链接,更多是用文字写的——「subsection (b) 的 paragraph (2)」「such subparagraph」。他们写了一个解析器把这些引用全部提取出来,交给 Lean 逐条检查:被引用的条款存在吗?还生效吗?整个检查跑在一个测试套件上,法律每出新版本就重跑一次,新版本引入的新错误立刻让套件变红。截至 2026 年 11 月 3 日的版本,套件报了 257 个发现:98 个是故意的(关于历史时期、或已通过但未生效的条款),21 个是编辑自己超链接的误报,剩下的 138 个是真实起草错误——67 处引用了已被废除、搬走或重写的条款却没做相应修改,24 处打错字、引错子项或没点明法案名,8 处把层级词叫错(§9818(a)(1)(A) 把 subsection 说成 paragraph),9 处同一编号出现两次(§1202(b)(4) 有两个),30 处括号根本不闭合。每一个错误都附一张「证书」:一段短的 Lean 陈述,携带官方 XML 里的证据,把这个错误证明一遍。138 份证明全部重新检查只要约两分半钟。因为整个法典记录是一个 git 仓库(每一部国会立法一个 commit,可追到 1994 年版),每个错误还能精确归因到是哪一次立法写坏的。Step one, the simplest and the most alarming: treat every cross-reference between statutes as a test case. The Code contains thousands of references — many not hyperlinks but phrases like 'paragraph (2) of subsection (b)' or 'such subparagraph'. A parser extracts them all, and Lean checks each one: does the provision being cited exist? Is it still in force? The checks run as a test suite, re-run against every new release of the Code, so a fresh drafting fault turns the suite red immediately. Against the release current to November 3, 2026, the suite reported 257 findings: 98 intentional (rules for past periods or enacted-but-not-yet-effective provisions), 21 false alarms from the editors' own hyperlinks, and 138 real faults — 67 references to provisions since repealed, moved, or rewritten with no conforming change, 24 typos or wrong citations, 8 wrong level words (a subsection called a paragraph), 9 cases where the same section number appears twice (§1202(b)(4) has two), and 30 unclosed parentheses. Each fault carries a certificate: a short Lean statement that carries the evidence from the official XML and proves the fault. All 138 certificates re-check in about two and a half minutes. And because the record of the Code is a git history — one commit per public law, reaching back to 1994 — every fault can be traced to the statute that wrote it.
第二步是把「这台机器怎么算税」写成可执行定义:2025 年一户人家的联邦所得税,按 Form 1040 逐项走——收入到 AGI、标准或逐项扣除(含 2025 年新增的小费、加班工资、车贷利息扣除)、税本身(含防止高收入者扣太狠的 AMT)、再到各项抵免。用 AI 把法条翻成 Lean 是有损的一步,所以外面包了三层验证:与 IRS 公布的税表、EITC 表、工作单和出版物算例对数字;和三个独立报税程序在 5000 户人家上交叉比对;另派一个没写过这段代码的 agent 做敌意审查,专找「为了让测试通过而写」的作弊翻译。Lean 真正多出来的东西是「覆盖所有输入而非抽样」的证明——比如证明 SALT 上限在某段收入区间内永远不起作用这种,数字测试永远碰不到的性质。Step two: write down what the machine actually calculates — the 2025 federal income tax for one household, following Form 1040 part by part: income down to AGI, deductions (including the new 2025 ones for tips, overtime, car-loan interest), the tax itself with the alternative minimum tax, then credits. Translating statutes into Lean with AI is the lossy step, so it is wrapped in three layers of verification: figures tested against the IRS's own published tables, worksheets and worked examples; cross-checks against three independent tax programs on 5,000 households; and a second agent that never wrote the code reviewing each part adversarially — hunting for code written to pass the tests rather than to follow the statute. What Lean adds over sampling is proofs that cover every input: properties like 'the SALT cap is never binding in this income range' that no number test would ever touch.
第三步才是他们真正想去的地方:既然规则已经是机器可检查的形式,就可以反过来在规则空间里搜索——不是问「这个漏洞合规吗」,而是问「规则允许什么,包括意外允许的」。就在前一篇里,他们用同样的方法从退休账户规则出发,一次盲目搜索重新「发现」了 backdoor Roth(一个广为人知的合法避税通道)——这等于给方法做了个阳性对照:已知漏洞能从规则里推出来,那未知的那些呢。Step three is where they actually want to go: once the rules are machine-checkable, you can search the rules in reverse — not asking 'is this loophole legal?' but 'what do the rules allow, including by accident?' In the previous post, the same machinery, starting from retirement-account rules, rediscovered the backdoor Roth in a blind search — a positive control for the method: known loopholes can be derived from the text, so what about the unknown ones?
值得带走的是这个视角本身:法条是一种「没有任何编译器检查过的并发规格」——八十年里多任作者逐年续写、彼此交叉引用,靠人眼保证一致性,而人眼恰恰对「引用指向搬走的段落」这种东西最不敏感。形式化检查不便宜(翻译有损、要对抗审查),但检查一旦建成,重跑的成本趋近于零,而错误一旦漏出去就是真金白银。这和软件工程里「lint 抓不到设计错误、但抓得到的全是便宜错误」是同一个道理——真正危险的不总是难问题,还有那些没人去数的明显错误。The takeaway is the frame itself: statutes are a kind of concurrent specification that no compiler has ever checked — written by many hands over eighty years, cross-referencing each other, kept consistent by human eyes, which are precisely blind to 'a reference pointing at a paragraph that moved'. Formalization isn't cheap (the translation is lossy and needs adversarial review), but once the checker exists, re-running it costs nothing, and a fault that escapes costs real money. It's the same lesson as linting in software engineering: the dangerous thing is not always the hard problem — sometimes it's the obvious mistake nobody bothered to count.
AI 思考AI Thinking
- 「No AI Slop」宣言:slop 是一种不对称税——生产成本趋零,理解成本不变The No AI Slop Manifesto: Slop Is an Asymmetric Tax — Production Cost Falls to Zero, Comprehension Cost Doesn't
- 先给 slop 一个可操作定义,而不是骂 AI:「当我们 Producing 一样东西花的力气,小于要求读者理解它所花的力气,就是 slop。」这个定义妙在它不提模型、不提工具——人写的废话同样中招。Start from an operational definition of slop instead of anti-AI railing: slop is when you put less effort into producing something than you ask the consumer to spend understanding it. The cleverness is that it never mentions models or tools — human-written filler qualifies too.
- 第二步看清成本结构:一千行的 PR、十页的文档,生成成本正在趋近零,但评审一份一千行 PR 的成本十年没变过。这就是「不对称」:把负担从作者身上卸下来,不等于消失,只是转嫁给下一个读的人。Then see the cost structure: the price of a thousand-line PR or ten-page doc is approaching zero, while the price of reviewing it hasn't moved in a decade. That's the asymmetry — offloading effort from the author doesn't delete it, it just bills the next reader.
- 第三步看它的复利:slop 会自我增殖——知识库、聊天记录、代码里 slop 越多,下一个 agent 读到的、复制的就越多;团队里 slop 越飞越厚,人反抗的意志也跟着磨损,沟通质量只降不升。Next, the compounding: slop breeds slop. The more of it in your knowledge base, chat, and code, the more the next agent reads and copies; the more slop flying around a team, the more everyone's will to fight it wears down, so communication quality declines instead of improving.
- 关键的立场是宣言拒绝「用 AI = slop」:用 AI 不必然产生 slop,产生 slop 的是「不加负责地转手」。模型不能替代判断,只能放大你的判断——或者你对它缺乏判断这件事。The crucial stance: the manifesto rejects 'AI = slop'. Using AI doesn't make something slop — passing AI output along without taking responsibility for its quality or the reader's experience does. AI can't replace judgement, it can only amplify yours (or your lack of it).
- 可带走的做法:给自己定一条「转手前检查关键部分」的习惯,别人递来 slop 时客气地请他先读一遍;以及把能被 linter、类型检查器抓的错误都交给机器——「错误出现第二次时,去改系统和护栏,而不是只改这一次的产出」。What to keep: check the parts that matter before anything goes out; when someone sends you slop, kindly ask them to review it first; and let linters and type checkers catch what machines can — when a mistake shows up twice, improve the system and its guardrails instead of just patching this instance.
- 「Claude 妄想」:技术精英说「和我一样好就是超人」,末日与乌托邦都是自恋投射The Claude Delusion: 'As Good as Me' Means 'Superhuman' — Doom and Utopia Both Project Narcissism onto AI
- 作者观察一个心理机制:成功者容易相信成功不靠运气,于是「我成功 → 我该配得上 → 我是天才 → 我什么都在行」,编程圈还把「会写代码」长期等同于「智力超群」,Dunning-Kruger 效应被放大。The essay dissects a psychology: successful people tend to deny luck, so 'I succeeded → I must deserve it → I'm a genius → I'm good at everything.' In tech, being good at programming was long equated with raw intelligence, which amplifies Dunning-Kruger.
- 靶子是盖茨评价 OpenAI 的那段自述:他去考模型「编一个我随手想的、它不可能见过的复杂生物题」。Schaumann 指出问题不在模型,在出题人——一个商业成功人士凭什么自认能在别人专业里出「高阶题」并以此裁决能力?The target is Bill Gates's own account of judging OpenAI: he demanded they pass an AP biology exam, including 'complex questions I made up that it couldn't possibly have seen.' Schaumann's point isn't about the model — it's the hubris of a business magnate appointing himself an examiner in someone else's science.
- 第二句更关键:盖茨说 Claude「和我一样好——这是我花最多年头磨炼的才能」。Schaumann 把这提炼成「Claude 妄想」的核心公式:对这群人来说,「接近我的水平」自动等于「超人」,因为他们默认自己就是人类上限。Worse still is Gates's second line: Claude is 'as good as I am' at code, his most developed talent. Schaumann distills the delusion into a formula: for this crowd, anything approaching their own skill level automatically counts as superhuman, because they assume they define the human ceiling.
- 有了这个公式,两边夸张叙事都通了:模型「超人」→ 要么全人类的末日,要么永生乌托邦。「任何东西只要接近我的技能,就必须远超所有人」——这个跳板让末日片和马斯克都省去了证据。With that formula, both extreme narratives click into place: if the model is 'superhuman,' then either everyone's extinction or billionaire immortality follows. 'Close to me means beyond everyone' is the springboard that lets doom movies and utopians skip the evidence.
- 可带走的是一个祛魅视角:读 AI 大人物访谈时,先分辨哪些句子在描述模型、哪些在描述自恋。「技术宅造了个和自己一样的程序,既狂喜又恐惧」——这份爱恨其实是「极客复仇」叙事,不是关于 AI 的认识论证据。What to keep: a demystifying reading habit. When AI titans grant-interview, separate sentences describing the model from sentences describing the ego. 'A nerd built something that mirrors him and is both ecstatic and terrified' is geek-revenge folklore — not epistemic evidence about AI.
- 十个工程师带一队 agent 四天建成航司调度系统,误打误撞重建了 1980 年的黑板架构Ten Engineers and a Swarm of Agents Built an Airline Ops System in Four Days — Accidentally Rebuilding 1980's Blackboard Architecture
- 实验设定:Thoughtworks 欧洲 10 名工程师进一个房间,目标是用「激进 agentic 工程」四天搭一套航空 IROps(航班大面积 disruption 时的恢复决策系统:取消谁、换哪架飞机、住客店)。同一个 monorepo,所有人同时开工。The setup: ten Thoughtworks engineers in one room, four days, goal = an airline IROps system (decisions after major disruptions: cancel which flights, swap which planes, hotel which passengers) built with aggressive agentic engineering, all in one monorepo, everyone starting at once.
- 为了治多 agent 并发改仓库搞挂构建的病,他们立了条纪律:agent 持续 commit、持续 rebase 到 main,且必须先在仓库里写「计划文件」(按规格章节编号、随进度勾选更新)。To stop parallel agents from trashing the build pipeline, they imposed one discipline: agents must commit and rebase onto main continuously, and keep their plans as files in the repo — numbered by spec section, checked off as progress lands.
- 意外发生:计划文件提交进仓库后,agent 们开始互相「读心」——做搜索算法的 agent 看到做验证器的 agent 在 plan 里标了 in progress,就不去碰那行;对方完成后,它不但知道可以动工,还直接收到「对方怎么实现的」说明笔记。协调根本不是设计出来的,是提交纪律的副产品。Then the accident: once plans lived in the repo, agents started reading each other's minds. The agent writing the search algorithm saw the verifier agent marking a plan line in-progress, and left it alone; when it was done, the search agent learned not just that it could proceed but how the verifier had been implemented. The coordination was a byproduct of the commit discipline, not designed.
- 他们从「看到」到「利用」:新起一个任务时,直接指示 agent 去监视 repo 里某个 plan 的进度、等对应实现落地后再接手集成。They went from noticing to exploiting: kick off a session with instructions to watch a particular plan in the repo and integrate its work the moment it lands. It worked.
- 作者回头发现这套 emergent 机制有名字:黑板系统(blackboard)——Hearsay-II(1980)就用共享黑板协调各知识源,1986 年被 Gelernter 形式化为 tuple space。多 agent 协调这个「新问题」,四十六年前的图纸早就画过:仓库即黑板,commit 即粉笔。The author then recognized the pattern: a blackboard system — Hearsay-II (1980) coordinated knowledge sources over a shared blackboard, formalized as tuple spaces by Gelernter in 1986. The 'new problem' of multi-agent coordination had its blueprint 46 years ago: the repo is the blackboard, commits are the chalk.
- 让 LLM 自己编企业术语表:别追求统一词汇——术语在不同语境里的差异本身就是信息Let LLMs Write the Company Glossary — Resist One Standard Vocabulary; the Divergences Are the Information
- 问题很具体:LLM 的训练集里没有你们公司的行话。「订单」在财务系统和仓库系统里指两样东西,模型全不知道,于是一进专业领域就容易失灵。The problem is concrete: your company's jargon isn't in the LLM's training set. 'Order' means two different things in finance and in the warehouse system, and the model knows neither — so it stumbles the moment it enters the domain.
- 办法:拿一个 LLM 扫企业自己的文本——文档、邮件、聊天记录——找出高频「抱团出现的词组」和老词新义(后者最容易惹祸,要求模型专门标出来),生成带定义的术语表;一词多义就并列多个定义、各附适用语境;然后让领域专家人来校订。The technique: have one LLM crawl the organization's own text — docs, emails, chat logs — hunting single words and collocations that regularly hang out together, plus old words used in unfamiliar ways (the latter cause the most confusion, so ask for them explicitly). It drafts a glossary; polysemous terms get several definitions each annotated with context; then human domain experts review and correct.
- 关键立场:Fowler 明确反对建「公司统一标准词汇表」——他没见过那玩意儿成功。正确姿势是沿着 DDD 的 bounded context 走:代码一个表、财务一个表,让 LLM 按需查表;甚至可以拿 LLM 对比两张表,「源码里的 X」和「人类文档里的 X」用法差异往往最启发人。The key stance: Fowler explicitly resists building one standard company vocabulary — he's never seen it work. Instead follow DDD's bounded contexts: one glossary for the codebase, one for finance, and let LLMs consult whichever applies. You can even ask an LLM to compare two glossaries — how source code uses term X versus how human documents use it is often the most instructive signal.
- 落地细节决定可用性:术语表要放成 LLM 好检索、少耗 token 的形态(大表可只把词条名进上下文、定义按需展开),进版本控制,定期刷新,还应收录「禁用词」——注明某个旧词该换成什么、哪个时间段内有效。Implementation details make it usable: store the glossary in a form LLMs can consult cheaply (for big ones, load only term names into context and pull definitions on demand), keep it in version control, refresh on a schedule, and include forbidden terms — entries saying a deprecated word should be replaced with what, and during what period.
- 可带走:这是 agentic 工程里便宜的一块基础设施——生成的术语表能喂给代码生成器让命名贴合企业词汇、喂给 harness 的 sensor 检查内部和 UI 用词;「客户可不只是不想看到你的内部黑话,他们是看不懂」。What to keep: this is cheap infrastructure for agentic engineering. The generated glossary steers code generators to name things in the enterprise's vocabulary, lets harness sensors check terminology inside the software and in the UI — because a customer-facing screen should not expose internal terms that only confuse the customer.
数学之美Mathematical Beauty
每日 Lean 谜题 · 周一Daily Lean Puzzle · Monday ★☆☆☆☆☆☆
每日谜题 ★1:法典审计的账目Daily Puzzle ★1: The Tax-Code Audit Ledger
一次法典审计报出 $257$ 条发现,分成三类:$a$ 条是真实的起草错误,$b$ 条是故意保留的历史条款,$c$ 条是编辑自己造成的误报。已知 $a + b + c = 257$,$a$ 恰好比 $b$ 多 $40$(即 $a = b + 40$),且 $c = 21$。证明:真实的起草错误恰有 $a = 138$ 条。($a, b, c$ 都是自然数。)A code audit reports $257$ findings in three kinds: $a$ real drafting faults, $b$ deliberately kept historical provisions, and $c$ false alarms from the editors' own hyperlinks. You know $a + b + c = 257$, that $a$ exceeds $b$ by exactly $40$ (i.e. $a = b + 40$), and that $c = 21$. Prove that the real faults number $a = 138$. (All of $a, b, c$ are natural numbers.)
Lean 形式化陈述(把 sorry 换成你的证明):The statement in Lean (replace sorry with your proof):
import Mathlib
/-!
一次法典审计里,一个检查套件报出 $257$ 条发现,分成三类:真实的起草错误 $a$ 条、
故意保留的历史条款 $b$ 条、编辑自己造成的误报 $c$ 条。已知
$a + b + c = 257$,$a$ 恰好比 $b$ 多 $40$,且 $c = 21$。
证明:真实的起草错误恰有 $a = 138$ 条。
-/
theorem audit_findings (a b c : ℕ) (h1 : a + b + c = 257) (h2 : a = b + 40)
(h3 : c = 21) : a = 138 := by
sorry
在浏览器中挑战 ▶Try it in your browser ▶ 下载题目 .leanDownload puzzle .lean
提示Hint
消元:把 $c = 21$ 和 $a = b + 40$ 都代入第一条方程,就只剩一个未知数了。全程用加法写,别在自然数里做减法。Lean 里一个 tactic 就能收掉全部推理。Eliminate: substitute $c = 21$ and $a = b + 40$ into the first equation and only one unknown is left. Keep everything in additive form — never subtract inside $\mathbb{N}$. In Lean, a single tactic closes the whole argument.
答案与讲解Solution & walkthrough
- 先把账目翻译成 Lean 的形状:三个自然数 `a b c : ℕ`,三条假设 `h1 : a + b + c = 257`、`h2 : a = b + 40`、`h3 : c = 21`,目标 `⊢ a = 138`。谜题陈述和形式化陈述是同一件事的两种写法——这正是头条里 Lexifina 对整部《税法》做的事。First translate the ledger into Lean's shape: three naturals `a b c : ℕ`, hypotheses `h1 : a + b + c = 257`, `h2 : a = b + 40`, `h3 : c = 21`, goal `⊢ a = 138`. The word problem and the formal statement are the same thing written twice — exactly the move today's lead essay describes Lexifina making over the entire Tax Code.
- 手算路径(也是 `omega` 内部思路的加法版):把 $h3$ 和 $h2$ 代入 $h1$,得 $(b + 40) + b + 21 = 257$,整理为 $2b + 61 = 257$,即 $2b = 196$,于是 $b = 98$、$a = 138$。注意每一步都只用加法和「两倍」,不写 $257 - 21$ 这种自然数里要小心的减法。The hand-computation path (also `omega`'s reasoning in additive form): substitute $h3$ and $h2$ into $h1$ to get $(b + 40) + b + 21 = 257$, tidy to $2b + 61 = 257$, so $2b = 196$, hence $b = 98$ and $a = 138$. Every step uses only addition and doubling — no natural-number subtraction like $257 - 21$, which is the thing to avoid in $\mathbb{N}$.
- Lean 证明只有一行:`by omega`。`omega` 是自然数/整数线性算术的决策程序(Presburger 算术的算法化身):假设和目标里只出现 $+$、常数和不等式时,它不靠灵感,必然判出真假。$h1$、$h2$、$h3$ 全是线性等式,目标也是,所以一行收工。The Lean proof is one line: `by omega`. `omega` is a decision procedure for linear arithmetic over the naturals and integers — the algorithmic embodiment of Presburger arithmetic. When hypotheses and goal mention only $+$, constants and inequalities, it needs no inspiration and always terminates with the right verdict. All three hypotheses and the goal here are linear, so the line closes them all.
- 可带走的是那条边界:线性 ⇒ 可判定,机器有终审权;一旦某个假设冒出 $b \cdot c$(条款编号相乘这种「乘法级」约束),问题立刻跳出 `omega` 的能力范围——丢番图方程有没有解连通用算法都不存在(希尔伯特第十问题)。这道 ★1 谜题故意停在拐杖的这一边。What to take away is the boundary: linear means decidable — the machine gets final say on the bookkeeping. Introduce one $b \cdot c$ into the mix (section numbers multiplying each other) and the problem hops off `omega`'s map: whether a Diophantine equation has a solution has no general algorithm at all (Hilbert's tenth). This ★1 puzzle deliberately stays on the supported side of the crutch.
import Mathlib
/-!
一次法典审计里,一个检查套件报出 $257$ 条发现,分成三类:真实的起草错误 $a$ 条、
故意保留的历史条款 $b$ 条、编辑自己造成的误报 $c$ 条。已知
$a + b + c = 257$,$a$ 恰好比 $b$ 多 $40$,且 $c = 21$。
证明:真实的起草错误恰有 $a = 138$ 条。
-/
theorem audit_findings (a b c : ℕ) (h1 : a + b + c = 257) (h2 : a = b + 40)
(h3 : c = 21) : a = 138 := by omega
人的思考A human's take
Formalizing the U.S. tax code — Lexifina 团队
这道谜题就是这篇文章里那笔账:Lexifina 团队把 Title 26 翻成 Lean 后,交叉引用检查套件在 2026-11-03 版本上报出 257 条发现——98 条故意(历史条款/未生效)、21 条编辑自己超链接造成的误报、138 条真实起草错误,三个数恰好就是谜题里的 $b$、$c$、$a$。作者的思路是把「找错」变成「算账」:每个错误附一份短的 Lean 证明当证书,138 份重验只要约两分半,还能靠 git 化法典追到写坏它的每一部国会立法。This puzzle is literally the ledger from the article: after translating Title 26 into Lean, Lexifina's cross-reference test suite reported 257 findings against the November 3, 2026 release — 98 intentional (historical or not-yet-effective provisions), 21 false alarms from the editors' own hyperlinks, and 138 real drafting faults. Those three numbers are exactly the puzzle's $b$, $c$ and $a$. The authors' move is to turn fault-finding into bookkeeping: every fault carries a short Lean proof as a certificate, all 138 re-check in about two and a half minutes, and the git-ified Code traces each error back to the public law that wrote it.
AI 随想An AI's reflection
以下由 AI 撰写。Written by AI.
这道谜题的全部难度其实藏在一条不起眼的分界线上。$a+b+c=257$ 这种只由加法和常数拼出来的等式,机器是有终极答案的——Presburger 算术可判定,`omega` 就是那个算法。可只要往假设里塞一个 $b \cdot c$,世界立刻翻脸:丢了「线性」这根拐杖,连「是否存在整数解」都不再有通用判定程序(希尔伯特第十问题,Matiyasevich 在 1970 年收尾)。同一句话里,「多 $40$ 条」可以说,「$40$ 倍」就没人兜底。The whole difficulty of this puzzle hides on one unremarkable boundary. Equations stitched from nothing but addition and constants — like $a+b+c=257$ — have a final machine answer: Presburger arithmetic is decidable, and `omega` is that algorithm wearing boots. Slip a single $b \cdot c$ into the hypotheses and the world turns hostile: without the crutch of linearity, even the existence of an integer solution has no general test (Hilbert's tenth, closed by Matiyasevich in 1970). In the same sentence, 'forty more than' is sayable; 'forty times' has no safety net.
这条边界恰好解释了两件事。一是为什么《税法》那样几千页的文本敢交给 Lean 去查:交叉引用、括号配对、编号唯一性,全是「线性」的账目问题,错了必能产出一份机械可复检的证书——138 份证书两分半重验完,这才是「测试套件跑在法律正文上」的真实含义。二是为什么它同时永远有律师吵不完的争议:真正的法律判断是乘法级的,两个条款的语义相乘,落在一切决策程序的边界之外。可判定的半边交给机器,判断留给人——这可能是这道 ★1 谜题和今天头条共享的、最不浪漫也最有用的结论。That boundary explains two things at once. Why a text of thousands of pages like the Tax Code can be handed to Lean at all: cross-references, bracket balance, unique section numbers — all linear bookkeeping, where every error yields a certificate a machine can re-check (138 certificates in two and a half minutes). That is what 'a test suite running on the statute' really means. And why its disputes outlive the formalization: genuine legal judgement is multiplicative — the semantics of two provisions times each other, outside every decision procedure. Give the decidable half to the machine and keep the judgement for humans: the least romantic, most useful conclusion this ★1 puzzle shares with today's lead essay.
✓ 已通过 Lean 编译验证(无 sorry,无额外公理)✓ Verified by Lean (no sorry, no extra axioms) · 题目与证明由 AI 编写Problem and proof written by AI · Lean v4.36.0-rc2 · Mathlib 1c2b155
- 三只旋钮张成一个立方体:把强化学习讲成参数空间里的随机爬山Three Knobs Span a Cube: Reinforcement Learning as Randomized Hill-Climbing in Parameter Space
- 从一个可玩的最小大脑开始:一只「spark」只有 4 个神经元——两个眼、两个控制摆尾——大脑接线只剩三个数:同侧直连强度、异侧交叉连强度、无光时的 drive。「一个行为 = 立方体里的一个点」,这是整篇最重要的一步几何化。Start with a playable minimal brain: a spark has 4 neurons — two eyes, two flipper-wigglers — so its wiring boils down to three numbers: straight connections, crossed connections, and drive when there's no light. 'One behavior = one point in a cube' is the essay's key geometric move.
- 先让人类来学:读者亲手拨三个滑块试错,目标是 spark 待在光里的时间过半。这个互动把「优化」变成体感——你其实就在参数立方体里做梯度上升,只是用眼睛代替了导数。First, learn as a human: you drag three sliders trial-and-error until the spark spends most of its time in the light. The interaction makes optimization physical — you're doing gradient ascent in parameter space, with your eyes replacing derivatives.
- 然后把人抽掉:把你的策略提炼成算法——每次试验前接线随机抖一点,结果变好就沿抖动方向挪,变差就反着挪。这正是 REINFORCE 类策略梯度的骨架:参数更新 ∝ 奖励 × 噪声扰动。Then remove the human: distill your strategy into an algorithm — jitter the wiring randomly before each trial; if the result beats the average, shift the wiring along the jitter; if worse, shift opposite. That skeleton is exactly REINFORCE-style policy gradient: parameter update ∝ reward × noise.
- 跟着 spark 自己练 50、250、1000 次,看它从原地打转到躲开危险再到趋光——同一段文字配学习曲线,读者亲眼确认「没有监督信号、只有标量奖励」也能走出复杂轨迹。Watch the spark practice alone — after 50, 250, 1000 trials it goes from spinning in place to avoiding danger to seeking light — and you confirm firsthand that a scalar reward, with zero supervision, carves surprisingly complex trajectories.
- 可带走的直觉:策略梯度难的地方不在公式,在「为什么瞎抖有用」——因为奖励把抖动的方向赋予了符号,抖一百次,好方向被反复加强。三维立方体让你能把这件事「看见」,推广到几百万维参数时,公式不变,只是看不见而已。The intuition to keep: the hard part of policy gradients isn't the formula but 'why does random jittering work?' Because the reward assigns a sign to each jitter; over hundreds of trials good directions get reinforced repeatedly. The 3-D cube lets you see it; scale to millions of dimensions and the math is unchanged — you just can't see it anymore.
- 沉默决斗:「怎么随机才最优」,原来是一串线性规划解出来的分布Silent Duels: The Optimal Way to Be Random Turns Out to Be a String of Linear Programs
- 题目很抓人:两人在 [0,1] 区间里各自等对手先开枪,各有 n 次机会、命中率随距离上升,都不许知道对方何时开过枪。「沉默决斗」是核威慑、空战、商业发布竞争的共同抽象。The setup grips you: two players in [0,1] wait for the other to shoot first; each gets n shots, hit probability rises with closeness, and nobody learns when the other fired. The 'silent duel' is a shared abstraction for nuclear deterrence, air combat, and product-launch races.
- 背景三步讲透:零和博弈、混合策略(最优解往往不是「选哪个动作」而是「按什么分布掷骰子」——石头剪刀布均匀随机就是例子)、minimax 定理(每个二人零和博弈都有最优混合策略,它不需要知道对手历史——哪怕对手是上帝,你也照这套分布打)。Three background moves made plain: zero-sum games, mixed strategies (the answer often isn't 'which action' but 'which dice distribution' — rock-paper-scissors uniform play being the canonical case), and the minimax theorem (every two-player zero-sum game has an optimal randomized strategy that needs no history of the opponent — you'd play it even against God).
- 关键转化:求最优混合策略可以化成线性规划——不用灵感,编译、跑。但无限动作空间让线性规划不够用,Restrepo 1960 年代的论文给出构造:把双方最优分布做成区间上的一串片段,用归纳法一层层解出「何时把概率密度抬起来、抬多高」,保证无论对手出什么策略,你的期望收益不低于博弈的值。The crucial conversion: finding the optimal mixed strategy is a linear program — no inspiration needed, just compile and run. Infinite action spaces break plain LPs, which is why Restrepo's 1960s paper constructs the optimal distributions as piecewise densities on the interval, solved layer by layer by induction, guaranteeing your expected payoff stays at or above the value of the game no matter what the opponent does.
- Kun 的帖子价值还有一半在方法论:他公开了自己「怎么啃一篇定理之山」——先重建游戏论基元,跳过自己会的部分,把论文里每个定义重新用具体例子(石头剪刀布)落地,再跟着构造走。Half the post's value is methodology: Kun shows, explicitly, how he works through a 'bag of theorems' — rebuild the primitives from scratch, skip what he already knows, ground every definition in a concrete toy (rock-paper-scissors), and only then follow the construction.
- 可带走:「随机不是没办法,是策略」——当你无法预测对手、也无法预测自己处境时,最优解常常是一个精心不均匀的分布;而这类分布是可构造、可计算的,不是玄学。What to keep: randomness is not resignation, it's strategy. When you can't predict your opponent — or your own situation — the optimum is often a carefully uneven distribution; and such distributions can be constructed and computed, not divined.
- 同一个嵌套列表的三种解析器:「作弊」eval 会段错误,数组风格才是 BQN 的正道Three Parsers for the Same Nested List: the Cheat-Through-Eval Segfaults, and Array Style Is BQN's True Path
- 题目来自 Advent of Code 2022 Day 13:把「[1,[2,[3,[4,[5,6,7]]]],8,9]」这样的嵌套列表字符串变成真列表——每个 APL 系语言爱好者都躲不过的练习。The problem is from Advent of Code 2022 Day 13: turn strings like '[1,[2,[3,[4,[5,6,7]]]],8,9]' into actual nested lists — the rite of passage every APL-family enthusiast eventually runs.
- 解法一「作弊」:这个字符串几乎就是 BQN 的字面量,用「字符差 × 掩码」的把戏把方括号换成尖括号,再丢给求值函数 •BQN。跑单个列表没问题;把整个输入拼成一个大列表再丢进去——Segmentation fault。作者没有掩盖这个难堪,而是把它当成对「eval 偷懒」的实测警告。Approach one, 'the cheat': the notation is almost valid BQN, so swap square brackets for angle brackets with a mask-and-character-arithmetic trick and feed it to the evaluator •BQN. It works per line; slurp the whole input into one giant list and — segmentation fault. The author doesn't bury the embarrassment; it becomes an empirical warning about lazy eval.
- 解法二「常规」:教科书递归下降解析器,逐字符分派。它的意义不在快,而在证明「任何算法语言都适用的套路」在数组语言里照样写得出来(Singeli 编译器就是这么解析的)。Approach two, 'conventional': a textbook recursive-descent parser. Its value isn't speed but proof that algorithms written anywhere translate into an array language fine (Singeli's compiler parses this way).
- 解法三「数组」:不写循环、不写递归,把整个字符串当成数据——用掩码、前缀扫描一次性算出每对括号的位置,让括号配对「算」出来而不是「读」出来。这才是数组语言的性格。Approach three, 'array style': no loops, no recursion — treat the whole string as data, compute every bracket's matching partner in one pass with masks and prefix scans. The pairing is calculated rather than read, which is the language's native temperament.
- 三者 benchmark 对比:递归下降 vs 数组风格的差异,把「表达范式的性能边界」变成可测量的问题——顺便示范了一种好的写法:把每种路的代价(含失败)都写出来。Benchmarking the three turns 'where each paradigm pays for itself' into a measurable question — and the post itself models a good habit: publish the cost of every road, including the failures.
- 样本抽取:环上密文的常数项里,本来就躺着一个 LWE 密文——只需要有人拿铅笔展开它Sample Extraction: A Ring Ciphertext's Constant Term Already Contains an LWE Ciphertext — You Just Have to Expand It with a Pencil
- 背景设定:全同态加密有一对姊妹方案——LWE(向量+内积)和 RLWE(多项式+负循环乘,系数少、算得快)。有的方案(CGGI)只吃 LWE,于是需要一种「从环世界跳到向量世界」的转换。直觉上这种转换该像 key switching 那样大动干戈。Setup: fully homomorphic encryption has two sibling schemes — LWE (vectors plus inner products) and RLWE (polynomials with negacyclic products — fewer coefficients, faster). Some schemes (CGGI) only speak LWE, so you need a bridge out of the ring world, and bridges like key switching feel like they must cost a whole protocol.
- Kun 的推导只做一个动作:考察相位函数 $\varphi(x) = b(x) - \langle a, s \rangle = m(x) + e(x)$ 的常数项——也就是「不取整的部分解密」,然后把它硬展开。负循环卷积的常数项是所有「次数和为 $0 \bmod N$」的系数对之和,且回绕的项带负号。Kun's derivation performs one move: look at the constant term of the phase function $\varphi(x) = b(x) - \langle a, s \rangle = m(x) + e(x)$ — partial decryption without the rounding — and expand it by hand. A negacyclic product's constant coefficient is the sum over all coefficient pairs whose degrees add to $0 \bmod N$, with a sign flip whenever the sum wraps.
- 奇迹在于符号翻转和重排全部落在公开的 $a_i$ 系数上:把每个多项式乘积的常数项重写成内积,未知的密钥 $s$ 一个都不用变——只是把它的系数「拍平」成一个长向量。于是 $\varphi(x)[0]$ 原本就是一个 LWE 加密,误差恰好是 $e(x)$ 的常数项,不新增任何噪声。The miracle: every sign flip and reordering lands on the public $a_i$ coefficients. Rewrite each product's constant term as an inner product and the unknown secret $s$ doesn't change at all — its coefficients are merely 'flattened' into one long vector. So $\varphi(x)[0]$ was already an LWE encryption, with error exactly the constant coefficient of $e(x)$ — zero new noise.
- 所以这是「最好情形」的归约:与 key switching 比,不用把输出密钥再加密一遍;与 modulus switching 比,误差零增长。唯一的代价是只保住 $m_0$,丢掉其余系数——而 CGGI 恰好只用常数项。Hence a best-case reduction: unlike key switching you don't re-encrypt the output key; unlike modulus switching the error doesn't grow. The only loss is that you keep just $m_0$ and drop the other coefficients — and CGGI only ever uses the constant term anyway.
- 可带走:数学上的「归约/转换」有时便宜得反直觉——两个定义只是同一个等式的两种写法,转换映射不是造出来的,是展开之后「注意到」早就在的。这也是 Kun 整系列的读法示范:先拿铅笔把一个具体系数算出来,再谈一般化。What to keep: sometimes a mathematical 'conversion' is obscenely cheap because the two definitions are one equation written twice, and the map between them isn't constructed but noticed — already sitting there once you expand a coefficient with a pencil. That is also the reading method of Kun's whole series: concrete term first, generality after.
程序员随想Programmer Reflections
- 教了 17 年机器人编程之后:别急着抽象,把逻辑写回那个每秒跑 50 次的大函数After 17 Years Coaching Robotics: Stop Abstracting — Put the Logic Back in the One Big Function That Runs 50 Times a Second
- 背景:FIRST 机器人赛的程序框架 TimedRobot 每秒调你 50 次——读手柄、算目标、过安全、写硬件,所有比赛程序本质上都在做这四步。但 WPILib 生态鼓吹命令框架、子系统抽象、状态机,学生程序越写越玄,作者看了 17 年,越看越不安。Context: FIRST Robotics programs run on TimedRobot, which calls you 50 times a second — read input, compute desired hardware state, enforce safety, write outputs. Every match program does these four steps, but the WPILib ecosystem pushes command frameworks, subsystem abstractions and state machines, and after 17 years of watching student code get ever more baroque, the author got uneasy.
- 他的反直觉主张「周期导向编程」:逻辑尽量集中写进一个 periodic 大函数,自上而下、少抽象、不用模式和状态——「简单得像新手代码,但它就是好用」。His counterintuitive thesis, 'Periodic-Oriented Programming': keep logic in one big periodic function, written top-to-bottom, with few abstractions — no modes, no commands, no state. 'So simple it seems beginner-level, and it still works' for serious programs, given a few boundaries.
- 结构只留一条硬规矩:硬件只能被 subsystem 摸到,且只在 subsystem 的 periodic 里被摸。由此构造性地得到三个免费保证:每个 tick 每块硬件只被写一次、安全约束 100% 执行、遥测日志天然一致。The one hard structural rule: hardware is touched only inside subsystems, and only in each subsystem's periodic. That buys three guarantees by construction: every piece of hardware is written once per tick, safety constraints run 100% of the time, and telemetry is consistent everywhere.
- 为什么反而好教、好查错:学生看屏幕就是代码顺序;auton 和 teleop 共用同一底座——subsystem 对外只暴露 driveFieldRelative(vx, vy) 这类高层函数,本质只是「设定 periodic 将来要读的目标值」;连「类应该只做一个事」的格言他也直接推翻:臂的安全角度依赖升降高度,就合并成 ElevatorAndArm 一个 subsystem。Why it teaches and debugs better: the code order equals what happens on screen; auton and teleop share one foundation because subsystem APIs like driveFieldRelative(vx, vy) are just 'set a target for periodic to read later'; and he flatly rejects 'a class should do one thing' — when the arm's safe angles depend on elevator height, merge them into one ElevatorAndArm subsystem.
- 可带走:抽象不是免费的,它在「每秒重跑的世界」里可能净亏——这段 17 年的现场反思,是对「少即是多」的一次罕见实证:先问你的运行模型是不是 tick-loop,是的话,一个写得克制的大函数可能真比框架更可靠。What to keep: abstractions aren't free, and in a run-every-tick world they can be net-negative. This is a rare empirical version of 'less is more' — first ask whether your runtime model is a tick loop; if it is, one disciplined big function may genuinely beat a framework.
- 终端边框为什么该吃掉一整格?把「线」从文本降级成属性Why Should a Terminal Border Eat a Whole Cell? Demoting Lines from Text to Attribute
- 问题:TUI 应用长得都差不多——因为 Unicode 制表符(128 个字符)画框要占整格。作者「手动画过太多 ┌──┐,所以有意见」:每层面板每边吞一行一列,两三层嵌套后 50 行的屏幕有 6-8 行纯装饰。The problem: most TUI apps look alike because Unicode box-drawing (128 glyphs) charges a full cell per line. The author has 'drawn enough ┌──┐ by hand to have opinions': every panel border eats a row and column per side, and two or three nested levels spend 6-8 of your ~50 rows on pure decoration.
- 关键洞察一句话:制表符难用的病根全在「它们是文本」——占格子、会被复制粘贴带进 Slack、粗细跟字体走、圆角和背景色对不上就露色块。所以解法不是找更好的字符,而是换表示层:边框不该是内容。The one-line insight: every annoyance with box characters traces to the fact that they are text — they occupy cells, they get copied and pasted into Slack, their weight follows the font, and rounded corners bleed background color when the panel differs. So the fix isn't better glyphs; it's a different representation: borders shouldn't be content.
- 新表示:把边框做成 cell 属性(和背景色同级)。每个格子最多挂 12 条线段——四条边各拆两半、加四条从中心伸出的臂——各自有颜色、宽度、样式,终端画在格子边缘,不占任何行列。The new representation: make borders a cell attribute, peer of background color. Each cell carries up to 12 line segments — the two halves of each of its four edges plus four center arms — each with its own color, width and style, drawn on cell edges. No rows or columns consumed.
- 表示一换,旧痛点连锁消失:标签能压在面板边上而不是多占一行;输入框能紧贴文字下划线;braille 折线图第一次有地方放网格线;复制不再带框(也「双面」:想要框时得另办)。Swap the representation and the old pains fall like dominoes: tab labels sit on a pane's top edge instead of costing their own row, text fields underline right beneath their text, braille charts finally get gridlines, and copy stops dragging frames along — which cuts both ways: sometimes you want the frame.
- 工程路径诚实:作者以 Ghostty 补丁 + Ratatui demo 推进协议,坦承「本文与代码受 AI 帮助写成,不必道歉」,并公开征集 TUI 作者反馈——一个新终端协议的完整生命周期,从美学抱怨到表示层手术。The honest engineering path: a Ghostty patch plus Ratatui demos, openly labeled 'written with a lot of help from AI, not going to apologize for that,' and a live call for terminal and TUI author feedback — the full life cycle of a new terminal protocol, from aesthetic complaint to representational surgery.
- 7.6GB 的 JSON 数 star 只要 55 毫秒:拆掉 GIL、只解析你要的那两个字段7.6 GB of JSON in 55 ms: Drop the GIL, Then Parse Only the Two Fields You Asked For
- 任务很实在:GitHub 每小时发布约一 GB 的事件 NDJSON,想数八小时里哪些仓库涨 star 最多——7.6 GB、220 万条记录。教科书 Python(json.loads 逐行)跑 0.28 GB/s,27 秒。The task is real: GitHub publishes about a gigabyte per hour of event NDJSON, and you want the repositories gaining the most stars over eight hours — 7.6 GB, 2.2 million records. Textbook Python (json.loads per line) manages 0.28 GB/s: 27 seconds.
- 常规加速有上限:orjson 约 2 倍,msgspec(只解码声明字段)约 8 倍——但 Python 进程被 GIL 锁在一核上,多核要靠进程池切文件、汇总小表,麻烦且到规模就撞墙。Usual speedups cap out: orjson about 2x, msgspec (decoding only declared fields) about 8x — but the GIL pins a Python process to one core, so multi-core means splitting the file across processes and merging small tables: workable, but you hit the wall at scale.
- 两个新变量叠加:Python 3.14 的 free-threaded 构建(3.14t)去掉了 GIL,线程真正并行;fastsimdjson 本身多线程,且用 JSON path 声明「只要 /type 和 /repo/name」——解析器只读到通往这两个字段的路径,其余字节不碰。Two new factors stack: Python 3.14's free-threaded build (3.14t) removes the GIL so threads genuinely run in parallel, and fastsimdjson is itself threaded and parses per field path — you declare 'only /type and /repo/name', and the parser reads just enough bytes to reach them and ignores the rest.
- 192 核(双 AMD EPYC 9R45)上 55 毫秒数完,138 GB/s;单核也 8 GB/s、比 msgspec 快 3.5 倍。取字面量的场景最佳文件达 277 GB/s。诚实交代:msgspec 进程池在「计数」这种回传小的任务上紧咬(116 GB/s),六个测试文件里有两个慢、一个打平——不是通杀。On a 192-core machine (dual AMD EPYC 9R45), counting finishes in 55 milliseconds: 138 GB/s; even single-core it's 8 GB/s, 3.5x msgspec. Extracting actual values reaches 277 GB/s on the best file. The honest caveat: for counting — where little comes back — a msgspec process pool is close behind (116 GB/s), two of six benchmark files run slower, and one ties. Not a clean sweep.
- 可带走:大数据快慢往往不取决于「换更快的解析器」这一件,而是三件正交的事——运行时(GIL 没了)、解析深度(按字段路径跳读)、并行方式(线程 vs 进程);且倍数数字必须绑定硬件、版本与任务形状讲。What to keep: big-file speed is rarely one lever; it's three orthogonal ones — your runtime (no GIL), parse depth (jump straight to the fields you declared), and parallel model (threads vs processes). And a multiplier is only meaningful with its hardware, versions and task shape attached.
- 104 个软件职位的头衔族谱:编码曾是文书活,头衔分了又合、旧名新用A Family Tree of 104 Software Job Titles: Coding Was Clerical, Titles Split and Merge, and Old Names Keep Coming Back
- 作者做过「Head of DevOps」,眼看着同一份工作换名成 SRE、又漂向平台工程,于是画了一张 1940s 至今的职位族谱:104 个头衔、7 个家族列、实线「生出」、虚线「影响」——用一份 Graphviz 文件 + 一份 JSON 描述就能渲染维护。The author was once a 'Head of DevOps' and watched the same work get re-baptized as SRE, then drift toward platform engineering. So he drew a family tree of the field from the 1940s to now: 104 titles in 7 colored columns, solid arrows for 'descended from', dashed for 'influenced' — rendered from one Graphviz dot file plus a JSON of descriptions.
- 翻案第一条:编码最初是「文书那半边」。1947 年 Goldstine 和 von Neumann 把用计算机分成「数学家规划、编码员翻译成机器指令」,后者地位低、大量由女性承担;而 ENIAC 第一批程序员干脆是从陆军「人肉计算机」里招的——工作养出了机器名,也养出了编程。First correction: coding started as the clerical half. In 1947 Goldstine and von Neumann split computer work into mathematicians planning and coders translating into machine instructions — the latter lower-status, much of it done by women. Several first ENIAC programmers came from the Army's human computers: the job named the machine, and its people became 'programmers'.
- 规律一:头衔先裂变再合并。webmaster(一人写 HTML、守服务器、回邮件、踢机房)1993 年出现、2000s 中期灭绝;前端/后端约 2005 年分家,2008 年前后又合体成 full-stack——正是「集权/分权拉锯」在岗位上的投影。Pattern one: titles split, then re-merge. The webmaster (one person writing HTML, running the under-desk server, answering mail, kicking the box) appeared ~1993 and died out by the mid-2000s; front-end/back-end forked around 2005 and re-fused into 'full-stack' by ~2008 — the centralization/distribution seesaw playing out in job titles.
- 规律二:有些头衔是昙花。prompt engineer 2023 年天价出圈,模型一变强就被吸收进 AI engineer;scrum master 被折叠回工程管理。规律三:旧名新用。「Systems Engineer」在 IBM 是售前、在 MCSE 时代是资深网管,同名两枝、毫无亲缘;configuration management 从国防硬件追踪 → 版本控制 → Puppet/Chef 转了一大圈。Pattern two: some titles are mayflies. 'Prompt engineer' made splashy six-figure listings in 2023 and on the tree gets absorbed into AI engineer almost as soon as it appears; the scrum master folded back into delivery roles. Pattern three: names get recycled. 'Systems Engineer' meant pre-sales at IBM in the 1960s and a senior sysadmin in the MCSE era — same title, different branch, no relation; 'configuration management' went defense hardware → version control → Puppet/Chef.
- 可带走:下次再冒出个新头衔,先查族谱——它是分是合、是昙花是常青,历史里都有先例;而作者也坦白日期是「大约何时开始流行」的估计(借助 Claude 整理),这份「数据诚实」本身是图的一部分。What to keep: next time a hot new title appears, consult the genealogy — fission or fusion, mayfly or perennial, there are precedents for all of them. And note the author's data honesty: dates are his best estimates of when a title became common (compiled with Claude's help), not first-usages — which is itself part of the map.
- 全盘加密是个错框架:/bin/sh 里没有秘密,秘密只在 /home、/var、/rootFull-Disk Encryption Is the Wrong Frame: /bin/sh Has No Secrets; /home, /var and /root Do
- 先把威胁模型钉死:磁盘加密只对两种对手有用——设备被偷要保数据、或防篡改(后者极难,需要硬件级 tamper-proofing,本文不做)。而「防偷」的第一步是问:这台机器上哪些字节真的含秘密?Nail the threat model first: disk encryption answers exactly two adversaries — a stolen device whose contents must stay secret, and tampering (which is hardware-level hard and out of scope here). And 'anti-theft' begins with the real question: which bytes on this machine actually contain secrets?
- BSD 的 base/包分离给了一个现成答案:/bin/sh 和全世界其他 NetBSD 用户跑的是同一个二进制,公开可下载、可校验,偷到它等于没偷。系统目录里真正的秘密趋近于零,加密它们纯属白付 CPU。BSD's base/packages split hands you the answer: /bin/sh is the same binary every other NetBSD user runs, publicly downloadable and checksum-verifiable — stealing it steals nothing. Root filesystem system directories contain nearly zero secrets, so encrypting them just pays the CPU for theater.
- 含秘密的只有少数几处:/home(用户文件)、/var(日志、crash dump——dump 是内存快照,可能泄密)、/root(配置)、/etc(但启动必需,不能全锁)、/usr/local 第三方件。于是合理设计是「混合分区」:明文启动所需的极小集合 + 其余各敏感目录分别加密。The secret-bearing minority: /home (user files), /var (logs, and crash dumps — a dump is a memory snapshot, possibly sensitive), /root (configuration), /etc (but boot-critical, so it can't be fully locked), /usr/local third-party bits. The sane design is a mixed partitioning: a minimal plaintext set required to boot, plus separate encrypted filesystems per sensitive directory.
- 两个顺手的洞察:美国标准化的算法软件实现往往慢,没 AES 硬件的机器用 Adiantum;共享库一旦加密丢失系统就救不回来,所以要熟悉 /rescue 里的静态小工具——加密改变的是「灾难恢复的形状」,不只是「能不能开机」。Two free insights along the way: US-standardized ciphers are often slow in software, so machines without AES hardware use Adiantum; and if shared libraries go missing because they're encrypted, the system can't save itself — know the static tools in /rescue. Encryption changes the shape of disaster recovery, not just 'will it boot'.
- 可带走:任何「全量加密/全量备份/全量防护」的冲动,先做一次「秘密在哪」的审计。这位 NetBSD 开发者把安全叙事还原成集合论问题:要保护的是含熵少数的目录,不是整块盘。What to keep: resist any impulse to encrypt/backup/protect everything, and run a 'where are the secrets' audit first. This NetBSD developer reduces a security narrative to a set-membership problem: the directories with entropy, not the whole disk.
哲学与生活Philosophy & Life
- 简·卡莱尔 1823 年的情书:我能爱你,但不是你想要的那种爱——loving 与 being in love 的分辨Jane Welsh Carlyle's 1823 Letters: I Love You, But Not in the Way You Want — On Distinguishing Loving from Being in Love
- 场景:20 岁出头的 Jane 被穷小子 Thomas Carlyle 追求,她的拒绝不是矜持而是精确的自我报告:「我确实无法坠入情网……牺牲自己去成全怜悯,是我做不到的慷慨;而且婚姻会骇人地妨碍我的计划。」The scene: in her early twenties, Jane Welsh is courted by the poor young writer Thomas Carlyle. Her refusal isn't coyness but precise self-reporting: 'positively I cannot fall in love... to sacrifice myself out of pity is a degree of generosity of which I am not capable; besides matrimony under any circumstances would interfere shockingly with my plans.'
- 最扎人的是她的双面:她确认爱是真的——「我的朋友,我爱你,我重申」——但她把这种爱定性为「冷静、愉悦却无激情」的友爱:「哪怕你是我兄弟,我也这样爱你;哪怕我嫁给了别人,我也照样爱你……」她拒绝的不是他,是「in love」这个类别本身。What stings is her double face: she insists her love is real — 'My Friend I love you — I repeat it' — but she classifies it as calm, unimpassioned friendship: 'were you my Brother I would love you the same.' What she refuses isn't him; it's the category of being in love itself.
- 然后在最决绝的「will, will resign it」之后,她自己漏了底:「写信来安抚我吧——你的友谊此刻几乎是我生存必需。」拒绝里有需要,需要里有拒绝——她不修饰这个矛盾,这正是 Woolf 赞她「深谙生活、鄙薄其虚伪」的凭据。And then, right after the most resolute 'will, will resign it cost what it may', she herself lets the other half show: 'Write to me and reassure me — your friendship at this time is almost necessary to my existence.' Refusal containing need, need within refusal — she doesn't smooth the contradiction, which is exactly why Woolf called her 'deeply versed in life and scornful of its humbugs.'
- Popova 的按语给出现代读法:being in love 是一阵被抛入的热病,loving 是清醒选择并保持的联结;把前者当爱情唯一凭证的人,容易错过后者。Popova's framing makes it modern: being in love is a fever you're thrown into; loving is a connection chosen and kept. Those who take the fever as love's only receipt tend to miss the other.
- 可带走:一件给所有关系的分辨工具——「我对这个人的感情,属于哪种?」用「就算你是我兄弟也这样爱」做测试,把依恋、欣赏、激情各自归位,然后诚实地谈,而不是让「坠入」一词包办所有答案。What to keep: a sorting tool for any relationship — 'which kind of feeling is this?' Test it with 'I would feel the same if you were my brother', place attachment, admiration, and passion separately, and negotiate honestly instead of letting the word 'falling' answer everything.
- 未来五十年最好的慈善机构可能是一家公司:把「赚钱」和「行善」的两本账合成一本The Best Charity of the Next 50 Years Might Be a Company: Collapsing the Two Ledgers of Profit and Good
- 先立一个历史框架「两本账」:Carnegie 先建 U.S. Steel 再修图书馆,Rockefeller 先建 Standard Oil 再雇 Frederick Gates 把捐款当研究项目运营(钩虫、黄热病的「成果导向公卫」比这个词早了几十年)。模式:工业造出财富也造出外部性,慈善负责事后修复——两边只在终点相遇。Earn to give 的有效利他主义就是这个架构的后裔。First the historical frame, 'the two ledgers': Carnegie built U.S. Steel, then libraries; Rockefeller built Standard Oil, then hired Frederick Gates to run giving like a research operation (hookworm and yellow fever were outcomes-driven public health decades before the phrase). Industry made wealth and externalities; philanthropy repaired afterwards — the halves meet only at the end. Earn-to-give effective altruism is that architecture's descendant.
- 触发点:Stripe 公共产品负责人 Nan Ransohoff 写了篇关于「美国慈善第三波」的锐文——AI 财富正在变液体,缺的是把资本变成持久公共品的机构。作者全盘同意,然后往旁边挪了一步问出全文的核心句:如果未来五十年最重要的社会机构根本不是非营利组织呢?The trigger: Stripe's head of public goods, Nan Ransohoff, wrote a sharp essay on the 'third wave' of American philanthropy — AI wealth turning liquid while the institutions to convert it into lasting public good lag badly. The author agrees with all of it, then steps sideways to the essay's core question: what if the most important social institutions of the next fifty years aren't nonprofits at all?
- 判据不是捐多少,是增长曲线和主张是否同向:最强的使命驱动公司不是事后捐利润的百分比,而是「只有使命变得更真,公司才能变大」——WHOOP 只在会员真的睡好恢复好时续费,Redwood Materials 随更多电池回到循环而膨胀,健康公司应该兴旺于人们病愈而不是病着。公益变成单位经济学本身。The test isn't how much a company donates but whether its growth curve and its claim point the same way: the strongest mission-driven company is not one donating a slice of profit after the fact, but one that can only get bigger as the mission becomes more true — WHOOP renews only when members actually sleep and recover, Redwood Materials grows as more batteries come back instead of landfill, a health company should thrive when people get well, not when they stay sick. Social good becomes the unit economics.
- 他自己把反驳说完:purpose-washing 是默认状态,「使命当装饰」和「使命当设计」需要一副挑剔的耳朵来分辨;也不是每个问题都有市场解——市场不奖励的人和事,永远需要捐赠、公共资金、大学和互助网络,而且 AI 重塑工作快过制度适应时,这些兜底只会更重要。He states the objections himself: purpose-washing is the default, and telling 'mission as decoration' from 'mission as design' requires a sensitive ear; and not every problem has a market solution — the people and problems markets won't reward will always need gifts, public funding, universities and mutual aid, needs that only grow as AI reshapes work faster than institutions adapt.
- 可带走:给「第三波」一个新定义——不只是更快地把钱给出去,而是拒绝把财富与善分账的创始人。这套「两本账 vs 一本账」也是看任何公司(或自己的工作)的透镜:它的商业模式赚钱的那一刻,是不是正好在兑现它声称的善?What to keep: a new definition of the 'third wave' — not money given away faster, but founders refusing to split the wealth from the good in the first place. The two-ledger-versus-one-ledger frame is also a lens for any company (or your own job): at the exact moment the business model makes money, is it also cashing the good it claims?
工具角Tools Corner
- gawain:强制每个变量都写类型标注,然后替你跑 ty/pyreflygawain: Force Type Annotations on Every Variable, Then Run ty/pyrefly for You
- 适合哪个活:Python 代码里最讨厌的是 dict[str, Any] 满天飞。mypy/pyright 对无标注变量会「善意猜测」,ruff 的 ANN 规则只管函数签名——模块级常量、普通变量、类属性全没人管。gawain 补的就是这块:GW001 查变量、GW002 查参数、GW003 查返回值、GW004 查类属性声明(字面量赋值因「类型显然」豁免,PORT = 8080 仍要求 Final[int])。Which task: the thing that rots Python codebases is dict[str, Any] everywhere. mypy and pyright kindly guess types for unannotated variables, and ruff's ANN rules only cover function signatures — module-level constants, plain variables and class attributes go unwatched. gawain watches exactly those: GW001 variables, GW002 parameters, GW003 returns, GW004 class-attribute declarations (literal assignments are exempt as 'obviously typed'; PORT = 8080 still demands Final[int]).
- 相比现有办法省了什么:一个 Rust 单二进制 + pre-commit hook,先把「标注存在性」当门禁(presence 错误不修完,不跑类型检查),修完后才把同一批文件喂给 ty(默认)或 pyrefly 做真检查——两步流水线,规则自己不用配。What it saves you: one Rust binary plus a pre-commit hook. It gates on presence first — until annotation errors are fixed, no type check runs — then feeds the same files to ty (default) or pyrefly for real checking. A two-stage pipeline without wiring rules yourself.
- 最短上手:uv tool install 'gawain[ty]',然后 gawain check src/(--no-types 只要标注、--mode strict 每个赋值都要注)。Fastest start: uv tool install 'gawain[ty]', then gawain check src/ (--no-types for annotations only, --mode strict for every assignment).
- 限制与维护:仓库很新(17 commits),ty 还在 beta、诊断可能随版本变(README 自己标了警告,可切 pyrefly 或 --no-types);作者态度明确——「你要说『Python 自己会推断』,就别用」。Limits and maintenance: the repo is young (17 commits) and ty is still beta with diagnostics that may change between versions (the README flags this; pyrefly or --no-types are the escape hatches). The author's stance is refreshingly narrow: 'if your answer is but Python already infers that — don't use it.'
- HolyArrs:把 Sonarr/Radarr/Lidarr/Bazarr/Prowlarr/Overseerr 六件套并成一个 16MB 单二进制HolyArrs: The Six-App Media Stack Collapsed into One 16 MB Binary
- 适合哪个活:自建影音库的人对「六个容器」不陌生——下载跟踪要 Sonarr/Radarr/Lidarr,字幕要 Bazarr,索引要 Prowlarr,请求要 Overseerr:六个登录、六个端口、六套 API key 互抄,一部片子没下来要查六个地方。Which task: self-hosted media folks know the six-container life — Sonarr/Radarr/Lidarr for downloads, Bazarr for subtitles, Prowlarr for indexers, Overseerr for requests: six logins, six ports, six API keys copied between them, and one missing episode means checking six places.
- 相比现有办法省了什么:单容器、端口 6262、内部数据模型统一。README 给了口径:六件套 amd64 镜像合计 685MB 下载、HolyArrs 约 16.1MB;空闲内存约 140 MiB(新装)、README 顶部另有 95 MiB 口径——两处数字与版本、测量日期(2026-11-08/13)一起标出,不是拍脑袋倍数。What it saves: one container, one port (6262), one data model. The README states its numbers with provenance: the six apps' amd64 images total 685 MB downloaded versus HolyArrs at ~16.1 MB; idle RAM ~140 MiB fresh (a 95 MiB figure appears up top — different build), each tied to version and measurement dates (2026-11-08/13) rather than a bare multiplier.
- 最短上手:一段 docker-compose(挂 /config + 媒体目录 + downloads),docker compose up -d,开 http://server:6262 建 owner 账号,向导配 folders/downloader/Source,无外部 API key。Fastest start: one docker-compose (mount /config plus media and downloads), docker compose up -d, open http://server:6262, make the owner account, and a wizard walks folders/downloader/Source — no API keys to hunt.
- 限制:所有海报、预告片、评分元数据来自作者自费运行的中心服务器(「靠赞助亮灯」)——自托管里嵌了一个不可自替换的 SPOF,这是选它前最该掂量的代价;功能上以「请求→选最优 release→送下载器→入库」一条流为主,重度的手动索引控制不如六件套灵活。Limit: every poster, trailer and score comes from a central server the author runs and pays for ('a sponsor keeps the lights on') — a non-self-hostable dependency inside a self-hosted app, worth weighing before you commit. In return you get a single pipeline (request → best release picked by your rules → downloader → library), while heavy manual indexer control stays weaker than the six-tool setup.
- noteflare:端到端加密笔记,跑在 Cloudflare 免费档上noteflare: End-to-End Encrypted Notes Living on Cloudflare's Free Tier
- 适合哪个活:想留一个自己掌控的笔记库,又不想养 VPS、也不想把明文交给谁——部署预算要小,隐私要是真的。Which task: you want a notes library you control — no VPS to babysit, no plaintext handed to anyone, and the whole deployment should fit a free plan.
- 架构就一句:Cloudflare Workers + D1 + Access,全在免费档。加密在浏览器完成——Argon2id 派生密钥、AES-256-GCM 加密正文,服务器只见密文;README 开头一句警告把威胁模型说透:丢了 passphrase 和恢复码,笔记就真没了——「这才是真端到端加密的意思」。The architecture in one line: Cloudflare Workers + D1 + Access, all free-tier. Encryption happens in the browser — Argon2id derives the key, AES-256-GCM seals the content, and the server only ever stores ciphertext. The README's opening warning states the threat model honestly: lose both your passphrase and recovery code and your notes are gone — 'that's what real end-to-end encryption means.'
- 和「自托管一堆容器」比省了什么:无服务器、无常驻机器、无系统维护;数据在 D1 免费配额里,图片(可选)进你自己的 R2。导入导出认真:拖一整个 Obsidian vault 或 Google Keep 导出文件夹即加密入库;导出是 Markdown 或加密备份。What it saves over self-hosting a stack of containers: no server, no always-on machine, no system maintenance; data sits in D1 free quota, optional images in your own R2. Import and export are serious: drop a folder of Markdown (an Obsidian vault) or a Google Keep export and every note arrives encrypted; export as Markdown or an encrypted backup.
- 细节见真章:多设备编辑同一笔记按行合并(像 git merge,真冲突才分叉)、解锁时密文就地解密、「15 分钟空闲擦除内存密钥」、PWA 离线读写、更新检查走自己的 Worker 零跟踪。技术栈是 plain React + Hono + SQL migrations,改得动。Details that show craft: multi-device edits to the same note merge line by line like git merge (only true clashes fork), decrypt-in-place on unlock, keys wiped from memory after 15 minutes idle, PWA offline read/write, and update checks via your own Worker with no tracking. The stack is plain React + Hono + SQL migrations — hackable.
- 限制:上手需要 wrangler/Cloudflare 账号(非「下载即用」);单用户设计,多人协作不在此列;33 commits 的仓库还年轻。Limit: getting started means wrangler and a Cloudflare account (not a download-and-run binary); it's single-user by design, no collaboration; and at 33 commits the project is still young.