Hardening
它能做什么
这个技能通过在大量生成的输入上检验示例测试背后的一般规则,来加强软件测试。它适用于希望找出示例测试遗漏的缺陷的开发者。
适用场景
- ✓当你的测试都通过了,但你怀疑它们漏掉了边界情况的时候。
- ✓当你想用大量随机输入检查某个函数的规则的时候。
- ✓当一个失败的用例需要缩减为能触发错误的最小示例的时候。
技能链接
https://github.com/danielmiessler/LifeOS/blob/main/LifeOS/install/skills/Hardening/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我们的日期解析测试都通过了,但我觉得还漏掉了边界情况。你能用属性测试加强它们吗?”
每周 5 个新技能,1 分钟读完。
工作原理
该技能会先说明示例测试背后的一般性断言,然后用大量生成的输入运行它。如果出现失败,它会把失败缩减为仍能触发错误的最小输入,然后修复错误或该属性。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Hardening Skill
Hardening sharpens tests that already exist without adding new functionality: it turns the universal claim behind a set of example tests into a fast-check property, runs it across generated inputs, and shrinks any failure to the minimal counterexample.
One intent ships. Mutation testing, complexity scoring, duplication scanning, and acceptance-test mutation were once listed here as planned; none is built, and this file no longer advertises them (external review of the v7.40.4 payload, 2026-09-03: a routing table that promises unbuilt intents is the "confidently documented, never existed" class).
Ideal State
- Every property written states the universal claim behind existing example tests, runs across generated inputs drawn from the function's real input domain, and keeps the examples it sharpens.
- Every failure ends shrunk to a minimal counterexample with its seed, and ends in either a fixed bug or a corrected property.
- What hardening lands is recorded where the system reads it: a
bun-propertyrow in the ISA's Test Strategy, and a C/R/L Learning entry when a counterexample taught something. - Functions that cannot carry a universal claim (impure, or no candidate shape) are left to example tests rather than forced into a property.
Intent Routing
| Intent | Trigger | File |
|---|---|---|
| PropertyTest | property test, property based testing, PBT, fast-check, universal quantified claim, shrink counterexample — pure functions, parsers, serializers, data transforms, invariants | Intents/PropertyTest.md |
Integration Points
- Testing Doctrine Rule #12 — names fast-check as the property-testing primitive (
LIFEOS/DOCUMENTATION/Testing/TestingDoctrine.md). - ISA format — the
bun-propertyISC type withproperty | generator | runscolumns (LIFEOS/DOCUMENTATION/ISA/ISAFormat.md§ ISC Type Vocabulary). Abun-propertyrow is a first-class assert: it counts toward every-ISC-an-assert coverage (H8) andbunker testruns it like any deterministic row. - Algorithm — hardening is elected during verification when a run's criteria warrant property depth; spend is discovered from the work.
- System prompt — Verification Is the Mechanism section at top (
LIFEOS/LIFEOS_SYSTEM_PROMPT.md).The Bunker CLI is maintainer-private and not in the public release; run code rows with
bun test ./<path>and suite rows withbun skills/Assay/Tools/EvalRunner.ts.
Gotchas
No skill-wide gotchas; the fast-check ones live in Intents/PropertyTest.md § Gotchas.
Examples
- "Property-test the slug parser" → PropertyTest → round-trip and idempotence properties in a
.property.test.tsfile at 1000 runs, abun-propertyrow in the ISA, and any failure shrunk with its seed pinned. - "What bugs are my example tests missing?" → PropertyTest → the pure functions (parsers, serializers, transforms) that have only example coverage, listed as property-test candidates.
常见问题
它会取代我的示例测试吗?
不会。它会保留被加强的示例,并在旁边添加属性测试。
哪些函数可以用这种方式测试?
具有清晰一般规则的函数。有副作用的函数或没有清晰输入形式的函数,则交给示例测试。
它使用什么工具?
它使用 fast-check,一个基于属性的测试库。
详情
作者的原始描述
Hardens LifeOS tests via property-based testing with fast-check. USE WHEN harden, hardening, property test, property based testing, PBT, fast-check, strengthen tests, find bugs example tests miss, universal quantified claim, shrink counterexample, what bugs am I missing, test the tests. NOT FOR new feature tests (bun test directly), grading agent output (Assay), UI verification (Interceptor), finding security vulnerabilities, or building new functionality.
repo: danielmiessler/LifeOS
热度
- GitHub 星标
- 20k
- 排名
- #10430
- 许可证
- MIT
- 更新时间
- 2026/10/28
评论
- …