@hailstails/hone 1.3.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ADOPTING.md +8 -8
- package/CHANGELOG.md +36 -0
- package/MIGRATING.md +40 -0
- package/README.md +28 -7
- package/api/audit.d.ts +1 -1
- package/api/testing.js +3 -3
- package/chunks/{chunk-H4V72FCW.js → chunk-2O46EB4E.js} +15 -1
- package/chunks/chunk-335ITLPO.js +7 -0
- package/chunks/{chunk-YSN46EB3.js → chunk-5U4VTFD5.js} +347 -664
- package/chunks/{chunk-PL2PNPAR.js → chunk-E6VR3VRV.js} +1 -6
- package/chunks/chunk-WF3PPYRR.js +27 -0
- package/core/check/tool-command.js +1120 -105
- package/core/mechanism-port/runner-result-types.d.ts +10 -0
- package/docs/adding-a-discipline-or-mechanism.md +5 -3
- package/docs/extending.md +2 -0
- package/docs/output-contract.md +64 -11
- package/mechanisms/audit/CD-27/test-body-logic.js +397 -46
- package/mechanisms/audit/runner/runner.js +5 -3
- package/mechanisms/audit/runner/typescript-parse.d.ts +2 -0
- package/mechanisms/audit/runner/walker-piece.d.ts +2 -1
- package/mechanisms/eslint/CD-1/cd1/cd1.eslint-plugin.js +7 -4
- package/mechanisms/eslint/CD-10/cd10/cd10.eslint-plugin.js +21 -11
- package/mechanisms/eslint/CD-14/cd14/cd14.eslint-plugin.js +15 -5
- package/mechanisms/eslint/CD-27/cd27/cd27.eslint-plugin.js +7 -3
- package/mechanisms/eslint/CD-41/README.md +1 -1
- package/mechanisms/eslint/CD-41/cd41/cd41.eslint-plugin.js +100 -28
- package/mechanisms/eslint/CD-42/cd42/cd42.eslint-plugin.js +8 -4
- package/mechanisms/eslint/CD-7/cd7/cd7.eslint-plugin.js +8 -4
- package/mechanisms/eslint/runner/README.md +9 -2
- package/mechanisms/eslint/runner/runner.js +1410 -1384
- package/methods/assessment-template.md +2 -2
- package/methods/lenses/clean-architecture.md +7 -8
- package/methods/lenses/defended-on-intent.md +2 -2
- package/methods/lenses/di-discipline.md +14 -18
- package/methods/lenses/function-first.md +16 -18
- package/methods/lenses/test-discipline.md +1 -1
- package/package.json +1 -1
- package/rules/CD-1/CHECKS.md +6 -2
- package/rules/CD-1/README.md +6 -19
- package/rules/CD-10/CHECKS.md +5 -3
- package/rules/CD-10/README.md +6 -18
- package/rules/CD-11/CHECKS.md +4 -2
- package/rules/CD-11/README.md +6 -16
- package/rules/CD-12/CHECKS.md +4 -2
- package/rules/CD-12/README.md +6 -16
- package/rules/CD-13/CHECKS.md +4 -2
- package/rules/CD-13/README.md +6 -16
- package/rules/CD-14/CHECKS.md +3 -1
- package/rules/CD-14/README.md +6 -19
- package/rules/CD-15/CHECKS.md +5 -1
- package/rules/CD-15/README.md +5 -20
- package/rules/CD-16/CHECKS.md +3 -1
- package/rules/CD-16/README.md +6 -6
- package/rules/CD-17/CHECKS.md +3 -1
- package/rules/CD-17/README.md +6 -19
- package/rules/CD-18/CHECKS.md +4 -2
- package/rules/CD-18/README.md +6 -16
- package/rules/CD-19/CHECKS.md +8 -6
- package/rules/CD-19/README.md +6 -20
- package/rules/CD-2/CHECKS.md +7 -3
- package/rules/CD-2/README.md +6 -21
- package/rules/CD-20/CHECKS.md +3 -1
- package/rules/CD-20/README.md +6 -6
- package/rules/CD-21/CHECKS.md +4 -2
- package/rules/CD-21/README.md +6 -15
- package/rules/CD-22/CHECKS.md +4 -2
- package/rules/CD-22/README.md +6 -15
- package/rules/CD-23/CHECKS.md +5 -3
- package/rules/CD-23/README.md +6 -17
- package/rules/CD-24/CHECKS.md +3 -1
- package/rules/CD-24/README.md +6 -6
- package/rules/CD-25/CHECKS.md +5 -3
- package/rules/CD-25/README.md +5 -21
- package/rules/CD-26/CHECKS.md +5 -3
- package/rules/CD-26/README.md +6 -20
- package/rules/CD-27/CHECKS.md +394 -9
- package/rules/CD-27/README.md +6 -20
- package/rules/CD-27/discipline.json +130 -0
- package/rules/CD-28/CHECKS.md +4 -2
- package/rules/CD-28/README.md +6 -16
- package/rules/CD-29/CHECKS.md +4 -2
- package/rules/CD-29/README.md +6 -14
- package/rules/CD-3/CHECKS.md +3 -1
- package/rules/CD-3/README.md +6 -17
- package/rules/CD-30/CHECKS.md +4 -2
- package/rules/CD-30/README.md +6 -15
- package/rules/CD-31/CHECKS.md +4 -2
- package/rules/CD-31/README.md +6 -14
- package/rules/CD-32/CHECKS.md +3 -1
- package/rules/CD-32/README.md +2 -0
- package/rules/CD-33/CHECKS.md +3 -1
- package/rules/CD-33/README.md +2 -0
- package/rules/CD-34/CHECKS.md +3 -1
- package/rules/CD-34/README.md +2 -0
- package/rules/CD-39/CHECKS.md +3 -1
- package/rules/CD-39/README.md +2 -0
- package/rules/CD-4/CHECKS.md +4 -2
- package/rules/CD-4/README.md +6 -17
- package/rules/CD-40/CHECKS.md +3 -1
- package/rules/CD-40/README.md +6 -20
- package/rules/CD-41/CHECKS.md +14 -2
- package/rules/CD-41/README.md +6 -20
- package/rules/CD-41/discipline.json +14 -0
- package/rules/CD-42/CHECKS.md +3 -1
- package/rules/CD-42/README.md +6 -16
- package/rules/CD-43/CHECKS.md +3 -1
- package/rules/CD-43/README.md +6 -18
- package/rules/CD-44/CHECKS.md +3 -1
- package/rules/CD-44/README.md +6 -17
- package/rules/CD-45/CHECKS.md +4 -2
- package/rules/CD-45/README.md +6 -16
- package/rules/CD-46/CHECKS.md +3 -1
- package/rules/CD-46/README.md +2 -0
- package/rules/CD-47/CHECKS.md +4 -2
- package/rules/CD-47/README.md +4 -20
- package/rules/CD-5/CHECKS.md +4 -2
- package/rules/CD-5/README.md +6 -19
- package/rules/CD-6/CHECKS.md +3 -1
- package/rules/CD-6/README.md +6 -19
- package/rules/CD-7/CHECKS.md +3 -1
- package/rules/CD-7/README.md +6 -20
- package/rules/CD-7a/CHECKS.md +3 -1
- package/rules/CD-7a/README.md +6 -17
- package/rules/CD-8/CHECKS.md +3 -1
- package/rules/CD-8/README.md +6 -17
- package/rules/CD-9/CHECKS.md +4 -2
- package/rules/CD-9/README.md +6 -17
- package/rules/README.md +71 -54
- package/rules/SPIRIT.md +3 -3
- package/rules/cases.md +94 -0
- package/rules/numbers.md +155 -0
- package/rules/principles.md +89 -0
- package/rules/records.md +150 -0
- package/rules/rules.md +149 -0
- package/rules/sources.md +142 -0
- package/rules/typescript/checks.md +219 -0
- package/rules/typescript/recipes.md +361 -0
- package/rules/typescript/symptoms.json +1005 -0
- package/rules/typescript/symptoms.md +612 -0
- package/chunks/chunk-YLZ73C7O.js +0 -0
package/rules/CD-8/CHECKS.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# CD-8 checks
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Symptom: [Default on a closed union](../typescript/symptoms.md#default-on-a-closed-union).
|
|
4
|
+
|
|
5
|
+
Read [the verdict and the named pages it points at](README.md) first. This page is the mechanics: how the rule is checked, and how to record an exception where the rule allows one.
|
|
4
6
|
|
|
5
7
|
## Clauses
|
|
6
8
|
|
package/rules/CD-8/README.md
CHANGED
|
@@ -2,25 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
## Rule
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
This numbered page is the earlier form of this rule. The [named pages](../README.md) govern where they differ, and [Every CD](../numbers.md) maps each number to its names.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
## Spirit
|
|
7
|
+
**Verdict.** Symptom of [Kinds are named](../rules.md#kinds-are-named).
|
|
10
8
|
|
|
11
|
-
**
|
|
9
|
+
**Read.** [Kinds are named](../rules.md#kinds-are-named) and [Tagged union and exhaustive switch](../typescript/recipes.md#tagged-union-and-exhaustive-switch).
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
- *A catch-all kept "for safety".* The union is closed, so the arm can only hide future cases. Remove it and let the compiler check exhaustiveness.
|
|
15
|
-
- *Input that was never parsed.* The value might be anything because it came from outside unchecked. Parse it at the boundary into the closed union; then the switch is closed.
|
|
16
|
-
- *Several cases sharing one arm.* Default is used as "everything else does the same". List those cases by name.
|
|
17
|
-
|
|
18
|
-
**Where to go.** Every switch over a closed union names every case. Adding a case lights up every place that must decide what to do with it.
|
|
11
|
+
Review lens: [type-soundness](../../methods/lenses/type-soundness.md). The lens reviews the whole rule, including what no check flags. What each check flags, how to fix a flagged site, and how to record an exception: [CHECKS.md](CHECKS.md). The thinking behind every rule: [the spirit of the rules](../SPIRIT.md).
|
|
19
12
|
|
|
20
|
-
|
|
21
|
-
- "What if a value we don't know arrives?" Then the value was not parsed. That is a boundary problem, not a switch problem.
|
|
22
|
-
- "Listing every case is verbose." The list is what the compiler checks.
|
|
13
|
+
## Spirit
|
|
23
14
|
|
|
24
|
-
|
|
25
|
-
- *Exhaustiveness checking.* The compiler proves every case is handled; a catch-all arm withdraws the proof.
|
|
26
|
-
- *Make illegal states unrepresentable* (Yaron Minsky). Once the input is a closed union, an unknown case cannot exist to be defaulted.
|
|
15
|
+
Start from the symptom a finding names: [Default on a closed union](../typescript/symptoms.md#default-on-a-closed-union). Each symptom names the cases it may indicate and the rules they point at. The why is on [The type checker proves it](../principles.md#the-type-checker-proves-it).
|
package/rules/CD-9/CHECKS.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# CD-9 checks
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Recipe: [Result union](../typescript/recipes.md#result-union). The outcome it protects is seen by [Throw between our units](../typescript/symptoms.md#throw-between-our-units).
|
|
4
|
+
|
|
5
|
+
Read [the verdict and the named pages it points at](README.md) first. This page is the mechanics: how the rule is checked, and how to record an exception where the rule allows one.
|
|
4
6
|
|
|
5
7
|
## Clauses
|
|
6
8
|
|
|
@@ -10,4 +12,4 @@ Read [the rule and its spirit](README.md) first. This page is the mechanics: how
|
|
|
10
12
|
|
|
11
13
|
## How it is checked
|
|
12
14
|
|
|
13
|
-
Every clause of this discipline is a judgement clause. It cannot be selected in `disciplines.json` and no mechanism checks it; a reviewer applies [the
|
|
15
|
+
Every clause of this discipline is a judgement clause. It cannot be selected in `disciplines.json` and no mechanism checks it; a reviewer applies [the named rules](README.md) with its review lens, as [ADOPTING.md](../../ADOPTING.md#9-apply-the-judgement-rules) describes. Selecting no clause of this discipline leaves nothing uncovered.
|
package/rules/CD-9/README.md
CHANGED
|
@@ -2,25 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
## Rule
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
This numbered page is the earlier form of this rule. The [named pages](../README.md) govern where they differ, and [Every CD](../numbers.md) maps each number to its names.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
## Spirit
|
|
7
|
+
**Verdict.** Keeps: [Failures are values](../rules.md#failures-are-values).
|
|
10
8
|
|
|
11
|
-
**
|
|
9
|
+
**Read.** [Failures are values](../rules.md#failures-are-values) and [Result union](../typescript/recipes.md#result-union).
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
- *Failures thrown because they were never listed.* Name each way the operation fails as a tagged variant.
|
|
15
|
-
- *Infrastructure treated as exceptional.* Timeouts and missing records are thrown. They are ordinary outcomes; return them.
|
|
16
|
-
- *Library exceptions leaking.* Catch at the wrapping boundary and return a result.
|
|
17
|
-
- *Callers that ignore failure.* A result is unwrapped without looking at the error. Handle each variant.
|
|
18
|
-
|
|
19
|
-
**Where to go.** Every operation that can fail returns a result with a tagged error union, and callers dispatch on it.
|
|
11
|
+
Review lens: [errors-as-data](../../methods/lenses/errors-as-data.md). The lens reviews the whole rule, including what no check flags. How it is checked: [CHECKS.md](CHECKS.md). The thinking behind every rule: [the spirit of the rules](../SPIRIT.md).
|
|
20
12
|
|
|
21
|
-
|
|
22
|
-
- "Exceptions are simpler." Simpler to write, because they skip the handling. The handling is the point.
|
|
13
|
+
## Spirit
|
|
23
14
|
|
|
24
|
-
|
|
25
|
-
- *Railway oriented programming* (Scott Wlaschin). Success and failure travel as two tracks of one value.
|
|
26
|
-
- *Make illegal states unrepresentable* (Yaron Minsky). A tagged error union lists exactly the failures that can occur.
|
|
15
|
+
Start from the symptom a finding names: [Throw between our units](../typescript/symptoms.md#throw-between-our-units) and [Failure shaped as success](../typescript/symptoms.md#failure-shaped-as-success). Each symptom names the cases it may indicate and the rules they point at. The why is on [The type checker proves it](../principles.md#the-type-checker-proves-it).
|
package/rules/README.md
CHANGED
|
@@ -1,54 +1,71 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
|
18
|
-
|
|
19
|
-
| [
|
|
20
|
-
| [
|
|
21
|
-
| [
|
|
22
|
-
| [
|
|
23
|
-
| [
|
|
24
|
-
| [
|
|
25
|
-
| [
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
1
|
+
# How to read the rules
|
|
2
|
+
|
|
3
|
+
A finding names a symptom. Read it along the chain:
|
|
4
|
+
|
|
5
|
+
**symptom → case → why → reason to change**
|
|
6
|
+
|
|
7
|
+
A [symptom](typescript/symptoms.md) is what was seen in the code. It points at the [cases](cases.md) it may indicate: what the code was trying to do. Each case owes one or more whys, its [principles](principles.md), and each principle names its reason to change. The [rules](rules.md) under a principle say what must hold, and the [recipes](typescript/recipes.md) are the known methods that make a rule hold.
|
|
8
|
+
|
|
9
|
+
## Why these rules are strict
|
|
10
|
+
|
|
11
|
+
"my rules are stricter than most because leaving any trade off or judgement based calls to llm leads to the easiest option locally. Which is almost never the better choice."
|
|
12
|
+
|
|
13
|
+
So no principle or rule leaves a trade-off or a judgement call to the reader. It states what must hold. The room for a correct exception is a record, never softness in the text. Being stricter than a cited source is intended.
|
|
14
|
+
|
|
15
|
+
## The model
|
|
16
|
+
|
|
17
|
+
| Kind | What it is | Industry name |
|
|
18
|
+
|---|---|---|
|
|
19
|
+
| [Principle](principles.md) | A why. What it protects and its reason to change. | Rationale |
|
|
20
|
+
| [Case](cases.md) | What the code is trying to do ("this needs the current time"). Where the why is owed. | Problem in context |
|
|
21
|
+
| [Rule](rules.md) | What must hold. Carries no exceptions. | Requirement |
|
|
22
|
+
| [Recipe](typescript/recipes.md) | A known method that makes a rule hold, with the reason it was chosen. "It's as binding as it's reasoning. The proof of burden is on the deviation to show that the reason it was chosen no longer holds." | Acceptable means of compliance; pattern |
|
|
23
|
+
| [Symptom](typescript/symptoms.md) | Something seen in code. Suspect by default. May point at several rules. | Code smell |
|
|
24
|
+
| [Check](typescript/checks.md) | How a symptom is found. Imperfect by design. | Enforcement; fitness function |
|
|
25
|
+
| [Record](records.md) | A thought-through use, known debt, or a design decision. | Deviation record; ADR |
|
|
26
|
+
|
|
27
|
+
"Reasons to change" is not on the list. It is the test used to place a boundary and to decide whether two things are one.
|
|
28
|
+
|
|
29
|
+
## The language boundary
|
|
30
|
+
|
|
31
|
+
Principles, cases and rules are cross-language. Recipes, symptoms and checks are written for one language; TypeScript is the one today, under [typescript](typescript/symptoms.md).
|
|
32
|
+
|
|
33
|
+
Two tests for a rule:
|
|
34
|
+
1. It names no language feature. If it only makes sense because of a quirk of the language, it is a symptom or a recipe for that language.
|
|
35
|
+
2. The other rules together do not already give it. If they do, it is a case.
|
|
36
|
+
|
|
37
|
+
## Names, not numbers
|
|
38
|
+
|
|
39
|
+
Rules, principles, cases, recipes and symptoms are named, not numbered. A name's id is the name, hyphenated. [Every CD](numbers.md) maps each old number to its new names. Selections, records and findings still use the numbered clause addresses, and each numbered folder still holds its discipline's `CHECKS.md`.
|
|
40
|
+
|
|
41
|
+
The numbered `README.md` pages are the earlier form of these rules. Where they differ, the pages here govern. Findings still link to the numbered pages until they are replaced; [Every CD](numbers.md#every-numbered-discipline) lists each one with its title, clauses, files checked and review lens.
|
|
42
|
+
|
|
43
|
+
## Words used the same way everywhere
|
|
44
|
+
|
|
45
|
+
- **Business logic:** all code outside a recorded boundary.
|
|
46
|
+
- **Unit:** one function.
|
|
47
|
+
- **Port:** an interface of ours that business logic is handed.
|
|
48
|
+
- **Adapter:** a unit inside a recorded boundary that fulfils a port.
|
|
49
|
+
- **Passed in:** given as an argument or to the factory that built the unit. Never imported.
|
|
50
|
+
- **One decision:** one reason to change.
|
|
51
|
+
- **Outside dependency:** what was called a package. An internal package is our own code.
|
|
52
|
+
|
|
53
|
+
## The pages
|
|
54
|
+
|
|
55
|
+
| Page | What it holds |
|
|
56
|
+
|---|---|
|
|
57
|
+
| [principles.md](principles.md) | The principles, each with what must hold, what it protects, its reason to change and where a breach sits |
|
|
58
|
+
| [cases.md](cases.md) | The cases under each principle, the whys each owes, and what to do |
|
|
59
|
+
| [rules.md](rules.md) | The named rules |
|
|
60
|
+
| [records.md](records.md) | The record kinds, and today's record formats beside them |
|
|
61
|
+
| [sources.md](sources.md) | The sources behind each principle, rule, recipe and record kind |
|
|
62
|
+
| [typescript/recipes.md](typescript/recipes.md) | The recipes for TypeScript |
|
|
63
|
+
| [typescript/symptoms.md](typescript/symptoms.md) | The symptoms in TypeScript, and how near today's checks come |
|
|
64
|
+
| [typescript/checks.md](typescript/checks.md) | Each check, its margin and its settings |
|
|
65
|
+
| [numbers.md](numbers.md) | Every CD number and its new names |
|
|
66
|
+
|
|
67
|
+
## Selecting checks
|
|
68
|
+
|
|
69
|
+
Adopters select clauses in `disciplines.json`. Selecting one clause adopts its discipline, so every mechanical clause of an adopted discipline must be selected, each through a mechanism its `CHECKS.md` lists, or listed as `"not-adopted"`; the check reports the rest as uncovered. Review clauses are judgement clauses: they cannot be selected and are applied in review with the discipline's review lens, as [ADOPTING.md](../ADOPTING.md#9-apply-the-judgement-rules) describes.
|
|
70
|
+
|
|
71
|
+
Exceptions are recorded in `discipline-exceptions.json`; see [the package README](../README.md#discipline-exceptionsjson). [The spirit of the rules](SPIRIT.md) explains what the friction is for.
|
package/rules/SPIRIT.md
CHANGED
|
@@ -13,7 +13,7 @@ A finding is rarely about the line it names. It is a signal about the design aro
|
|
|
13
13
|
Take this chain, in order.
|
|
14
14
|
|
|
15
15
|
1. **Measure.** Count the sites for the failing clause. Group them by folder, by the value or dependency involved, and by who wrote them when.
|
|
16
|
-
2. **Ask what each group points at.** Read the
|
|
16
|
+
2. **Ask what each group points at.** Read the symptom's "May indicate" and "Breach usually sits" lines on [the symptoms page](typescript/symptoms.md) and match each group against them. Most groups share one cause.
|
|
17
17
|
3. **Then decide.** Name the cause, where it lives, the forward goal, and the first step that unlocks it. Fix the cause and the sites go with it.
|
|
18
18
|
|
|
19
19
|
Exclusions and settings are not the first move. Reaching for one before step 2 hides the signal before anyone has read it. A count that looks like noise is usually one missing boundary seen from many places.
|
|
@@ -43,8 +43,8 @@ Tests are not exempt. A test that needs a cast, a test double with logic, a modu
|
|
|
43
43
|
|
|
44
44
|
## Older than these rules
|
|
45
45
|
|
|
46
|
-
Each rule encodes lessons programmers learned before us and wrote down under names you can look up: the SOLID principles, ports and adapters, "parse, don't validate", making illegal states unrepresentable, the test pyramid, the kinds of test double, and others.
|
|
46
|
+
Each rule encodes lessons programmers learned before us and wrote down under names you can look up: the SOLID principles, ports and adapters, "parse, don't validate", making illegal states unrepresentable, the test pyramid, the kinds of test double, and others. [The sources page](sources.md) names the source behind each principle, rule and recipe, and how the item relates to it. Read them to learn the pattern and the reasoning, not only the rule.
|
|
47
47
|
|
|
48
48
|
## Who does what
|
|
49
49
|
|
|
50
|
-
Each
|
|
50
|
+
Each symptom on [the symptoms page](typescript/symptoms.md) names the cases it may indicate and where the breach usually sits, so a reader can tell which one they have. The repository's own assessment then sharpens that to what is specific to the codebase and its intentions: which cause applies, where, the forward goal and the steps. It does not repeat the rule.
|
package/rules/cases.md
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# Cases
|
|
2
|
+
|
|
3
|
+
A case is what the code is trying to do. It is where the why is owed. A case may owe more than one why. "Owes" lists principles by short name; the first one decides what to do.
|
|
4
|
+
|
|
5
|
+
Short names: Tests ([Tests are ours](principles.md#tests-are-ours)), One place ([One place decides](principles.md#one-place-decides)), Effects ([No hidden effects](principles.md#no-hidden-effects)), Boundary ([External behaviour sits at a boundary](principles.md#external-behaviour-sits-at-a-boundary)), Leak ([No leak across a boundary](principles.md#no-leak-across-a-boundary)), Checker ([The type checker proves it](principles.md#the-type-checker-proves-it)), Language ([Our code reads in the common language](principles.md#our-code-reads-in-the-common-language)), Outside risk ([Outside risk is carried on purpose](principles.md#outside-risk-is-carried-on-purpose)).
|
|
6
|
+
|
|
7
|
+
Cases name no language, tool or library.
|
|
8
|
+
|
|
9
|
+
## Tests are ours
|
|
10
|
+
|
|
11
|
+
| Case | Owes | What to do |
|
|
12
|
+
|---|---|---|
|
|
13
|
+
| Uses what a collaborator gives back | Tests; One place | Every collaborator whose result it uses, our own units included, is passed in. The test stubs it with a written-out value and asserts only what the unit returns and calls. A stub that needs logic means the port or the collaborator holds too much: fix that. |
|
|
14
|
+
| States what the unit gives back, for one case or several | Tests; One place | Each test is one complete, distinct case. The expected value is written out, never worked out. Several cases are each written out; nothing in the test builds or picks them. No throw or catch in a test. |
|
|
15
|
+
| Checks a value that may be one of several outcomes | Tests; Checker | An assertion proves which outcome it is, so the type narrows; then the test reads it plainly. No condition, optional read or cast. |
|
|
16
|
+
| Gives each unit its test | Tests; One place | Every unit has its own test in the companion file, and it runs. A unit that only wires has a test of its wiring. No coverage figure stands in. |
|
|
17
|
+
| Tests across units or against a real system | Tests; One place | Each behaviour is tested at the level that owns it. An integration test checks only a binding to the outside, or that units join. It is the only place a file on disk or a real subsystem belongs, and only the one its binding needs. It inherits nothing from the machine. |
|
|
18
|
+
|
|
19
|
+
## One place decides
|
|
20
|
+
|
|
21
|
+
| Case | Owes | What to do |
|
|
22
|
+
|---|---|---|
|
|
23
|
+
| Coordinates other units | One place; Tests | It picks which of our units run, in what order, and passes their results on. Branching, computing or reshaping between calls is its own unit. A unit that only forwards one call decides nothing: fold it in. A test suite's body is a list of cases, not a coordinator. |
|
|
24
|
+
| Does one job | One place; Checker | One decision. It calls no other unit of business logic; it may call ports passed in to it. A second question, a mode picked by a true-or-false argument, or a mix of results is a second unit. |
|
|
25
|
+
| Checks conditions before its work | One place; Checker | Each condition that ends the work returns at once, at one level. The work is the last return, never nested in a condition. |
|
|
26
|
+
| Builds the real implementations | One place; Boundary | One place, at start-up, builds every real implementation and passes it in. Nothing else builds one. |
|
|
27
|
+
| Reuses behaviour from another unit or type | One place; Language | Two callers share a unit only when it is one decision for both. Shared behaviour is a call to that unit, never inheritance. |
|
|
28
|
+
| Puts code in a file or folder | One place; Language | A module holds what changes for one reason, named for that domain concept. A domain type lives with its logic; a file of types alone holds only port declarations. A drawer of unrelated pieces, test helpers included, has no home. |
|
|
29
|
+
|
|
30
|
+
## No hidden effects
|
|
31
|
+
|
|
32
|
+
| Case | Owes | What to do |
|
|
33
|
+
|---|---|---|
|
|
34
|
+
| Makes a new value from what it has | Effects; One place | It returns a new value. Nothing it was given or already made changes after it is made. A stream is drained only in its source's adapter, at a recorded site. |
|
|
35
|
+
| Causes an effect (writes, logs, sends, exits) | Effects; Boundary, One place | The effect is a call on a port passed in, and its test checks that call. |
|
|
36
|
+
| Keeps state or settings across calls | Effects; Checker | Settings are passed in when the unit is built. State that changes between calls lives only in an adapter, behind a port. |
|
|
37
|
+
|
|
38
|
+
## External behaviour sits at a boundary
|
|
39
|
+
|
|
40
|
+
| Case | Owes | What to do |
|
|
41
|
+
|---|---|---|
|
|
42
|
+
| Needs the current time, a random value, a new id or an outside ordering | Boundary; One place, Tests | One unit makes the value and does nothing else. Every other unit is passed the value, not its source. The source is a port; its stub returns a written-out value. |
|
|
43
|
+
| Uses a system or service outside the program | Boundary; Leak, One place | Business logic is handed a port named for the capability, not the mechanism, speaking only our types. One implementation per capability touches it and may fill several narrow ports. The protocol is its own adapter. Each adapter is a recorded boundary. |
|
|
44
|
+
|
|
45
|
+
## No leak across a boundary
|
|
46
|
+
|
|
47
|
+
| Case | Owes | What to do |
|
|
48
|
+
|---|---|---|
|
|
49
|
+
| Reads data from outside (request, file, environment, stored row, response) | Leak; Boundary, Checker | The reader for whoever produced it parses it once, at the boundary, into a type of our own. A required value that is missing is a failure, never a default. A test never sets the environment. Past the reader, units and their tests use objects, never text. |
|
|
50
|
+
| Sends data out of the program | Leak; One place | Business logic hands the adapter our own value. Only the adapter maps it to the receiver's form. |
|
|
51
|
+
|
|
52
|
+
## The type checker proves it
|
|
53
|
+
|
|
54
|
+
| Case | Owes | What to do |
|
|
55
|
+
|---|---|---|
|
|
56
|
+
| An operation can fail | Checker; Boundary | Every way it fails is a named variant in its return type. Nothing is thrown, ends the process, becomes true or false, or is swapped for a default or an empty value. Callers handle each variant. |
|
|
57
|
+
| A value is one of several kinds or states | Checker; Language | A closed union of our own, a name per kind, no catch-all. Absence or a true-or-false that stands for a state is a named kind. |
|
|
58
|
+
| Gives a value its type (declares it, or needs it narrower) | Checker; One place, Leak | It admits exactly what the code relies on, named, never derived from an implementation. To narrow it, fix the declaration or the parse; nothing asserts over it, tests included. A doer takes only the fields it reads. |
|
|
59
|
+
| Sets how strictly the checker works | Checker | One setting, the strictest, for every unit. None weakens it. |
|
|
60
|
+
|
|
61
|
+
## Our code reads in the common language
|
|
62
|
+
|
|
63
|
+
| Case | Owes | What to do |
|
|
64
|
+
|---|---|---|
|
|
65
|
+
| Names something | Language; One place | The domain's word, the same everywhere, at every scope. Values that travel together are named fields, never a position. If only a generic word fits, split it. An outside contract's names stay in its boundary. |
|
|
66
|
+
| Explains something in prose | Language; Checker | The meaning goes in a name or a type. The only annotations are a pointer to a tracked issue and a tool directive. |
|
|
67
|
+
| Writes basic logic (branching, matching, transforming, results) | Language; Outside risk | In the language's own constructs. No outside dependency's vocabulary stands in for it. |
|
|
68
|
+
|
|
69
|
+
Meaning by name, never by position: a unit whose signature is ours takes one argument; a callback shaped by an outside API takes what that API passes.
|
|
70
|
+
|
|
71
|
+
## Outside risk is carried on purpose
|
|
72
|
+
|
|
73
|
+
| Case | Owes | What to do |
|
|
74
|
+
|---|---|---|
|
|
75
|
+
| Takes an outside dependency | Outside risk; Language, Boundary, One place | A record names the native way weighed and why it was not enough. It is used only inside the recorded boundary that needs it, with no wrapper, and its types and vocabulary never reach business logic. It never makes one of our decisions. |
|
|
76
|
+
|
|
77
|
+
Outside dependency: what was called a package. An internal package is our own code. An internal package falls under One place decides and the layering, not this case.
|
|
78
|
+
|
|
79
|
+
### Proposed cases
|
|
80
|
+
|
|
81
|
+
Proposed, not accepted.
|
|
82
|
+
|
|
83
|
+
| Case | Owes | What to do |
|
|
84
|
+
|---|---|---|
|
|
85
|
+
| Ships code for others | Outside risk | What we ship is visible to an adopter's scanner. It is the case of the proposed rule [Shipped risk declared](rules.md#shipped-risk-declared). |
|
|
86
|
+
| An adopter is not handed our risk | Outside risk | A case under [Outside dependencies justified](rules.md#outside-dependencies-justified). A peer dependency is a direct dependency of ours, so it needs a record. The risk it weighs is carried by whoever runs it, the adopter included. |
|
|
87
|
+
|
|
88
|
+
## Outside the cases
|
|
89
|
+
|
|
90
|
+
- **Sensitive data:** safety is their why; no principle forces them.
|
|
91
|
+
- **Records and debt:** see [records](records.md).
|
|
92
|
+
- **A named ban:** no record makes it correct. Existing use is still held as debt, like any symptom.
|
|
93
|
+
- **How rules and checks are written:** spirit pure, strict wording, checks imperfect by design.
|
|
94
|
+
- **Process:** root cause over a guard, no deferring, no ask-me exits, no parallel machinery.
|
package/rules/numbers.md
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
# Every CD
|
|
2
|
+
|
|
3
|
+
Rules, principles, cases, recipes and symptoms are named, not numbered. This is the one page that gives the old numbers: each CD, its verdict, and where it went. Selections, records and findings still use the numbered clause addresses.
|
|
4
|
+
|
|
5
|
+
| Verdict | Meaning |
|
|
6
|
+
|---|---|
|
|
7
|
+
| Keeps | A rule under one principle. |
|
|
8
|
+
| Merges | Same reason to change as another rule. |
|
|
9
|
+
| Splits | The discipline's content went to more than one rule. |
|
|
10
|
+
| Recipe | A method for another rule. |
|
|
11
|
+
| Cases | A list of cases of an existing rule or principle. |
|
|
12
|
+
| Symptom or Check | Something seen in code, or how it is found. |
|
|
13
|
+
| Outside | Outside the cases. |
|
|
14
|
+
|
|
15
|
+
| CD | Verdict | Where |
|
|
16
|
+
|---|---|---|
|
|
17
|
+
| [CD-1](CD-1/README.md) | Symptom | of [Declared, not asserted](rules.md#declared-not-asserted) |
|
|
18
|
+
| [CD-2](CD-2/README.md) | Keeps | [Declared, not asserted](rules.md#declared-not-asserted) |
|
|
19
|
+
| [CD-3](CD-3/README.md) | Cases | strictest checker setting |
|
|
20
|
+
| [CD-4](CD-4/README.md) | Recipe | for the No leak case: [Zod at the producer's adapter](typescript/recipes.md#zod-at-the-producers-adapter) |
|
|
21
|
+
| [CD-5](CD-5/README.md) | Splits | One word everywhere; Declared, not asserted; records |
|
|
22
|
+
| [CD-6](CD-6/README.md) | Keeps | [One word everywhere](rules.md#one-word-everywhere); casing a check |
|
|
23
|
+
| [CD-7](CD-7/README.md) | Splits | One reason per module; One word everywhere; filename case a check |
|
|
24
|
+
| [CD-7a](CD-7a/README.md) | Symptom | of [Outside dependencies stay at boundaries](rules.md#outside-dependencies-stay-at-boundaries) |
|
|
25
|
+
| [CD-8](CD-8/README.md) | Symptom | of [Kinds are named](rules.md#kinds-are-named) |
|
|
26
|
+
| [CD-9](CD-9/README.md) | Keeps | [Failures are values](rules.md#failures-are-values) |
|
|
27
|
+
| [CD-10](CD-10/README.md) | Splits | Failures are values; Straight-through tests; throw-only-error a check |
|
|
28
|
+
| [CD-11](CD-11/README.md) | Recipe | for [Failures are values](rules.md#failures-are-values) |
|
|
29
|
+
| [CD-12](CD-12/README.md) | Recipe | for [Ports declared inside](rules.md#ports-declared-inside) |
|
|
30
|
+
| [CD-13](CD-13/README.md) | Keeps | [Ports declared inside](rules.md#ports-declared-inside) |
|
|
31
|
+
| [CD-14](CD-14/README.md) | Splits | no-class recipe; Outside dependencies stay at boundaries; state a case |
|
|
32
|
+
| [CD-15](CD-15/README.md) | Cases | of [No hidden effects](principles.md#no-hidden-effects) |
|
|
33
|
+
| [CD-16](CD-16/README.md) | Merges | with CD-15 |
|
|
34
|
+
| [CD-17](CD-17/README.md) | Cases | under Handed what it uses and One reason per module |
|
|
35
|
+
| [CD-18](CD-18/README.md) | Cases | under [Ports declared inside](rules.md#ports-declared-inside) |
|
|
36
|
+
| [CD-19](CD-19/README.md) | Splits | Outside dependencies stay at boundaries; Ports declared inside; construction and ids cases |
|
|
37
|
+
| [CD-20](CD-20/README.md) | Merges | with CD-19 |
|
|
38
|
+
| [CD-21](CD-21/README.md) | Cases | built at the entry point |
|
|
39
|
+
| [CD-22](CD-22/README.md) | Recipe | for [Declared, not asserted](rules.md#declared-not-asserted) |
|
|
40
|
+
| [CD-23](CD-23/README.md) | Keeps | [Tested where it's owned](rules.md#tested-where-its-owned) |
|
|
41
|
+
| [CD-24](CD-24/README.md) | Merges | with CD-23 |
|
|
42
|
+
| [CD-25](CD-25/README.md) | Keeps | [Written-out answers](rules.md#written-out-answers) |
|
|
43
|
+
| [CD-26](CD-26/README.md) | Symptom | of Written-out answers, Ports declared inside |
|
|
44
|
+
| [CD-27](CD-27/README.md) | Splits | Straight-through tests; Tested where it's owned |
|
|
45
|
+
| [CD-28](CD-28/README.md) | Merges | into [Written-out answers](rules.md#written-out-answers) |
|
|
46
|
+
| [CD-29](CD-29/README.md) | Merges | into [Tested where it's owned](rules.md#tested-where-its-owned) |
|
|
47
|
+
| [CD-30](CD-30/README.md) | Merges | into [Tested where it's owned](rules.md#tested-where-its-owned) |
|
|
48
|
+
| [CD-31](CD-31/README.md) | Check | of [Tested where it's owned](rules.md#tested-where-its-owned) |
|
|
49
|
+
| [CD-32](CD-32/README.md) | Outside | safety |
|
|
50
|
+
| [CD-33](CD-33/README.md) | Outside | safety |
|
|
51
|
+
| [CD-34](CD-34/README.md) | Outside | safety |
|
|
52
|
+
| [CD-39](CD-39/README.md) | Outside | records |
|
|
53
|
+
| [CD-40](CD-40/README.md) | Cases | of One word everywhere, Handed what it uses |
|
|
54
|
+
| [CD-41](CD-41/README.md) | Keeps | [Doer or orchestrator](rules.md#doer-or-orchestrator) |
|
|
55
|
+
| [CD-42](CD-42/README.md) | Keeps | [Guard first](rules.md#guard-first) |
|
|
56
|
+
| [CD-43](CD-43/README.md) | Keeps | [Kinds are named](rules.md#kinds-are-named) |
|
|
57
|
+
| [CD-44](CD-44/README.md) | Cases | of [No hidden effects](principles.md#no-hidden-effects) |
|
|
58
|
+
| [CD-45](CD-45/README.md) | Cases | of [No leak across a boundary](principles.md#no-leak-across-a-boundary) |
|
|
59
|
+
| [CD-46](CD-46/README.md) | Outside | records |
|
|
60
|
+
| [CD-47](CD-47/README.md) | Cases | under [Tested where it's owned](rules.md#tested-where-its-owned) |
|
|
61
|
+
|
|
62
|
+
## Every mechanical clause
|
|
63
|
+
|
|
64
|
+
Each mechanical clause and the [symptom](typescript/symptoms.md) it sees.
|
|
65
|
+
|
|
66
|
+
| Clause | Symptom |
|
|
67
|
+
|---|---|
|
|
68
|
+
| CD-1 (3 clauses) | [Claimed type](typescript/symptoms.md#claimed-type); [Untyped value](typescript/symptoms.md#untyped-value) |
|
|
69
|
+
| CD-2 (2 clauses) | [Claimed type](typescript/symptoms.md#claimed-type) |
|
|
70
|
+
| CD-3 (7 clauses) | [Strictness weakened](typescript/symptoms.md#strictness-weakened) |
|
|
71
|
+
| CD-5 | [Untracked escape](typescript/symptoms.md#untracked-escape) |
|
|
72
|
+
| CD-6#identifier-names | [Shorthand name](typescript/symptoms.md#shorthand-name) |
|
|
73
|
+
| CD-6#naming-convention | [Name off its casing](typescript/symptoms.md#name-off-its-casing) |
|
|
74
|
+
| CD-7#categorical-paths | [Drawer path](typescript/symptoms.md#drawer-path) |
|
|
75
|
+
| CD-7#filename-case | [Name off its casing](typescript/symptoms.md#name-off-its-casing) |
|
|
76
|
+
| CD-7a | [Type derived from code](typescript/symptoms.md#type-derived-from-code) |
|
|
77
|
+
| CD-8 | [Default on a closed union](typescript/symptoms.md#default-on-a-closed-union) |
|
|
78
|
+
| CD-10#throws-in-tests | [Throw or catch in a test](typescript/symptoms.md#throw-or-catch-in-a-test) |
|
|
79
|
+
| CD-10#throw-only-error | [Thrown non-error](typescript/symptoms.md#thrown-non-error) |
|
|
80
|
+
| CD-14#class-syntax, CD-14#static-only-class | [Authored class or this](typescript/symptoms.md#authored-class-or-this) |
|
|
81
|
+
| CD-15 | [Loop keyword](typescript/symptoms.md#loop-keyword) |
|
|
82
|
+
| CD-17 | [Date used directly](typescript/symptoms.md#date-used-directly) |
|
|
83
|
+
| CD-19 | [Outside import past a boundary](typescript/symptoms.md#outside-import-past-a-boundary) |
|
|
84
|
+
| CD-23 | [Unit without a running test](typescript/symptoms.md#unit-without-a-running-test) |
|
|
85
|
+
| CD-25 | [Double with a body](typescript/symptoms.md#double-with-a-body) |
|
|
86
|
+
| CD-26 | [Module or global patched](typescript/symptoms.md#module-or-global-patched) |
|
|
87
|
+
| CD-27#test-body-logic | [Branch in a test](typescript/symptoms.md#branch-in-a-test); [Computed value in a test](typescript/symptoms.md#computed-value-in-a-test); [Rebinding](typescript/symptoms.md#rebinding); [Text past its reader](typescript/symptoms.md#text-past-its-reader) |
|
|
88
|
+
| CD-27#focused-tests, CD-27#skipped-tests | [Test switched off](typescript/symptoms.md#test-switched-off) |
|
|
89
|
+
| CD-40#parameter-count | [Positional parameters](typescript/symptoms.md#positional-parameters) |
|
|
90
|
+
| CD-41#cognitive-complexity | [Tangled function](typescript/symptoms.md#tangled-function) |
|
|
91
|
+
| CD-41#function-length | [Long function](typescript/symptoms.md#long-function) |
|
|
92
|
+
| CD-42 | [Work inside a condition](typescript/symptoms.md#work-inside-a-condition) |
|
|
93
|
+
| CD-43 | [Boolean in a signature](typescript/symptoms.md#boolean-in-a-signature) |
|
|
94
|
+
| CD-44#parameter-mutation | [Write into a parameter](typescript/symptoms.md#write-into-a-parameter) |
|
|
95
|
+
| CD-44#parameter-reassignment | [Rebinding](typescript/symptoms.md#rebinding) |
|
|
96
|
+
| CD-47 | [Inherited environment in a subprocess](typescript/symptoms.md#inherited-environment-in-a-subprocess) |
|
|
97
|
+
|
|
98
|
+
The test-logic check, CD-27#test-body-logic, also sees the `let` form of [Answer set in a hook](typescript/symptoms.md#answer-set-in-a-hook), and `try`, a form of [Throw or catch in a test](typescript/symptoms.md#throw-or-catch-in-a-test).
|
|
99
|
+
|
|
100
|
+
Review clauses that demand a method (CD-4, CD-9, CD-11, CD-12, CD-21 and CD-22) map to their [recipes](typescript/recipes.md). The outcome each protects is seen by Schema past its adapter, Throw between our units, Failure shaped as success, Port outside the domain, Adapter built outside the root and Default for a required value.
|
|
101
|
+
|
|
102
|
+
Sensitive data and citation clauses (CD-32, CD-33, CD-34 and CD-39) have no symptom: they are outside the cases.
|
|
103
|
+
|
|
104
|
+
## Every numbered discipline
|
|
105
|
+
|
|
106
|
+
Each numbered discipline as its folder holds it today: its title, its clause addresses, the files its checks read, and its review lens.
|
|
107
|
+
|
|
108
|
+
Adopters select clauses in `disciplines.json`. Selecting one clause adopts its discipline, so every mechanical clause of an adopted discipline must be selected, each through a mechanism its CHECKS.md lists, or listed as `"not-adopted"`; the check reports the rest as uncovered. Clauses marked (review) are judgement clauses: they cannot be selected and are applied in review with the discipline's review lens, as [ADOPTING.md](../ADOPTING.md#9-apply-the-judgement-rules) describes.
|
|
109
|
+
|
|
110
|
+
| ID | Title | Clauses | Files checked | Review lens |
|
|
111
|
+
| --- | --- | --- | --- | --- |
|
|
112
|
+
| [CD-1](CD-1/README.md) | No any, ever | `CD-1#any-cast`, `CD-1#explicit-any`, `CD-1#implicit-any-let` | `.ts`, `.tsx` | [type-soundness](../methods/lenses/type-soundness.md) |
|
|
113
|
+
| [CD-2](CD-2/README.md) | Closed enumerated list of permitted cast sites | `CD-2#cast-expressions`, `CD-2#non-null-assertions` | `.ts`, `.tsx` | [type-soundness](../methods/lenses/type-soundness.md) |
|
|
114
|
+
| [CD-3](CD-3/README.md) | Strict mode flags inherited, never overridden | `CD-3#strict`, `#no-unchecked-indexed-access`, `#exact-optional-property-types`, `#no-implicit-override`, `#no-fallthrough-cases-in-switch`, `#no-property-access-from-index-signature`, `#use-unknown-in-catch-variables` | `tsconfig.json` | [type-soundness](../methods/lenses/type-soundness.md) |
|
|
115
|
+
| [CD-4](CD-4/README.md) | Zod at every external boundary | `CD-4#boundary-validation` (review) | — | [zod-boundary](../methods/lenses/zod-boundary.md) |
|
|
116
|
+
| [CD-5](CD-5/README.md) | No comments, no JSDoc | `CD-5#comments-directives` | `.ts`, `.tsx` | [naming](../methods/lenses/naming.md) |
|
|
117
|
+
| [CD-6](CD-6/README.md) | Meaningful names always — no shorthand, no filler words | `CD-6#identifier-names`, `CD-6#naming-convention` | `.ts`, `.tsx` | [naming](../methods/lenses/naming.md) |
|
|
118
|
+
| [CD-7](CD-7/README.md) | No categorical filenames or folder names | `CD-7#categorical-paths`, `CD-7#filename-case` | `.ts`, `.tsx` paths | [naming](../methods/lenses/naming.md) |
|
|
119
|
+
| [CD-7a](CD-7a/README.md) | No ReturnType<typeof X> for our own codebase | `CD-7a#factory-return-types` | `.ts`, `.tsx` | [type-soundness](../methods/lenses/type-soundness.md) |
|
|
120
|
+
| [CD-8](CD-8/README.md) | No default on switch over a closed discriminated union | `CD-8#switch-defaults` | `.ts`, `.tsx` | [type-soundness](../methods/lenses/type-soundness.md) |
|
|
121
|
+
| [CD-9](CD-9/README.md) | All operational failures return Result<T, E> | `CD-9#result-failures` (review) | — | [errors-as-data](../methods/lenses/errors-as-data.md) |
|
|
122
|
+
| [CD-10](CD-10/README.md) | Throws permitted in exactly two contexts | `CD-10#throws-in-tests`, `CD-10#throw-only-error` | `*.test.ts`, `*.test.tsx` | [errors-as-data](../methods/lenses/errors-as-data.md) |
|
|
123
|
+
| [CD-11](CD-11/README.md) | Operational error envelopes are plain data, not classes | `CD-11#error-envelopes` (review) | — | [errors-as-data](../methods/lenses/errors-as-data.md) |
|
|
124
|
+
| [CD-12](CD-12/README.md) | Repositories are the primary storage abstraction | `CD-12#repository-ports` (review) | — | [clean-architecture](../methods/lenses/clean-architecture.md) |
|
|
125
|
+
| [CD-13](CD-13/README.md) | Kernel layer boundaries are non-negotiable | `CD-13#layer-boundaries` (review) | — | [clean-architecture](../methods/lenses/clean-architecture.md) |
|
|
126
|
+
| [CD-14](CD-14/README.md) | Zero class authoring; classes only at external-library call sites | `CD-14#class-syntax`, `CD-14#static-only-class`, `CD-14#library-construction` (review) | TypeScript, not `.d.ts` | [function-first](../methods/lenses/function-first.md) |
|
|
127
|
+
| [CD-15](CD-15/README.md) | Iteration is functional transformation, never an imperative loop | `CD-15#loops` | `.ts`, `.tsx` | [function-first](../methods/lenses/function-first.md) |
|
|
128
|
+
| [CD-16](CD-16/README.md) | No counted for loops | see CD-15 | — | [function-first](../methods/lenses/function-first.md) |
|
|
129
|
+
| [CD-17](CD-17/README.md) | Clock is the only time source | `CD-17#clock-sources` | `.ts`, `.tsx` | [di-discipline](../methods/lenses/di-discipline.md), [test-discipline](../methods/lenses/test-discipline.md) |
|
|
130
|
+
| [CD-18](CD-18/README.md) | Process-lifecycle operations arrive through an injected port | `CD-18#process-lifecycle-ports` (review) | — | [di-discipline](../methods/lenses/di-discipline.md) |
|
|
131
|
+
| [CD-19](CD-19/README.md) | External dependencies confined to wrapping ports at the boundary | `CD-19#import-boundaries` | `.ts`, `.tsx` | [function-first](../methods/lenses/function-first.md) |
|
|
132
|
+
| [CD-20](CD-20/README.md) | Runtime stdlib imports arrive through injected ports | see CD-19 | — | [di-discipline](../methods/lenses/di-discipline.md) |
|
|
133
|
+
| [CD-21](CD-21/README.md) | Every injected port ships a default production factory | `CD-21#default-factories` (review) | — | [di-discipline](../methods/lenses/di-discipline.md) |
|
|
134
|
+
| [CD-22](CD-22/README.md) | Middleware generic context constraint | `CD-22#middleware-context` (review) | — | [di-discipline](../methods/lenses/di-discipline.md) |
|
|
135
|
+
| [CD-23](CD-23/README.md) | Every unit has a co-located test sibling | `CD-23#export-test-sibling` | production `.ts`, `.tsx` | [test-discipline](../methods/lenses/test-discipline.md) |
|
|
136
|
+
| [CD-24](CD-24/README.md) | Every file is unit-tested | see CD-23 | — | [test-discipline](../methods/lenses/test-discipline.md) |
|
|
137
|
+
| [CD-25](CD-25/README.md) | Unit tests replace everything outside the unit with test doubles | `CD-25#dependency-isolation` | `*.test.ts`, `*.test.tsx` | [di-discipline](../methods/lenses/di-discipline.md), [test-discipline](../methods/lenses/test-discipline.md) |
|
|
138
|
+
| [CD-26](CD-26/README.md) | No module-mocking — module-mock means DI is wrong | `CD-26#module-mocking` | `*.test.ts`, `*.test.tsx` | [di-discipline](../methods/lenses/di-discipline.md), [test-discipline](../methods/lenses/test-discipline.md) |
|
|
139
|
+
| [CD-27](CD-27/README.md) | Tests are zero-everything — zero logic, zero branches, zero unpredictability | `CD-27#test-body-logic`, `CD-27#focused-tests`, `CD-27#skipped-tests` | `*.test.ts`, `*.test.tsx` | [test-discipline](../methods/lenses/test-discipline.md) |
|
|
140
|
+
| [CD-28](CD-28/README.md) | Tests assert only what the unit is directly responsible for | `CD-28#unit-responsibility` (review) | — | [test-discipline](../methods/lenses/test-discipline.md) |
|
|
141
|
+
| [CD-29](CD-29/README.md) | Component/integration tests are the minimum, not the bulk | `CD-29#test-pyramid` (review) | — | [test-discipline](../methods/lenses/test-discipline.md) |
|
|
142
|
+
| [CD-30](CD-30/README.md) | Integration tests catch composition bugs only | `CD-30#composition-only` (review) | — | [test-discipline](../methods/lenses/test-discipline.md) |
|
|
143
|
+
| [CD-31](CD-31/README.md) | No coverage thresholds | `CD-31#no-coverage-thresholds` (review) | — | [test-discipline](../methods/lenses/test-discipline.md) |
|
|
144
|
+
| [CD-32](CD-32/README.md) | PII strings redact-by-default in structured logs | `CD-32#pii-redaction` (review) | — | [clean-architecture](../methods/lenses/clean-architecture.md) |
|
|
145
|
+
| [CD-33](CD-33/README.md) | Sensitive types brand-redact unconditionally | `CD-33#sensitive-brands` (review) | — | [clean-architecture](../methods/lenses/clean-architecture.md) |
|
|
146
|
+
| [CD-34](CD-34/README.md) | Secrets never enter the repo | `CD-34#no-repo-secrets` (review) | — | [clean-architecture](../methods/lenses/clean-architecture.md) |
|
|
147
|
+
| [CD-39](CD-39/README.md) | Cite principles by Roman numeral and rules by ID | `CD-39#cite-by-id` (review) | — | none |
|
|
148
|
+
| [CD-40](CD-40/README.md) | Single-object-argument functions | `CD-40#parameter-count`, `CD-40#named-object-argument` (review) | files the ESLint run includes | [function-first](../methods/lenses/function-first.md) |
|
|
149
|
+
| [CD-41](CD-41/README.md) | Orchestrators contain only orchestration | `CD-41#cognitive-complexity`, `CD-41#function-length`, `CD-41#orchestration-only` (review) | files the ESLint run includes | [decomposition](../methods/lenses/decomposition.md) |
|
|
150
|
+
| [CD-42](CD-42/README.md) | Unhappy paths are early returns; happy path is the final return | `CD-42#useless-else` | files the ESLint run includes | [decomposition](../methods/lenses/decomposition.md) |
|
|
151
|
+
| [CD-43](CD-43/README.md) | Booleans are evaluative, not declarative | `CD-43#boolean-signatures` | `.ts`, `.tsx` | [type-soundness](../methods/lenses/type-soundness.md) |
|
|
152
|
+
| [CD-44](CD-44/README.md) | Functions must not mutate fields of parameters they receive | `CD-44#parameter-mutation`, `CD-44#parameter-reassignment` | `.ts`, `.tsx` | [decomposition](../methods/lenses/decomposition.md) |
|
|
153
|
+
| [CD-45](CD-45/README.md) | Zod runs exactly once per external-boundary crossing | `CD-45#parse-once` (review) | — | [zod-boundary](../methods/lenses/zod-boundary.md) |
|
|
154
|
+
| [CD-46](CD-46/README.md) | Touching a carved-out file revokes its carve-out — leave it clean | applied to every file carve-out | — | none |
|
|
155
|
+
| [CD-47](CD-47/README.md) | Tests are hermetic — no real side effects on anything real | `CD-47#hermetic-git-spawns` | `*.test.{ts,tsx,mjs,js}`, `*.spec.{ts,mjs}` | [test-discipline](../methods/lenses/test-discipline.md) |
|