@hailstails/hone 0.1.0-pre.5 → 0.1.0-pre.7
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 +151 -42
- package/MIGRATING.md +55 -4
- package/README.md +120 -43
- package/THIRD-PARTY-NOTICES.md +1 -1
- package/api/audit.d.ts +3 -0
- package/api/audit.js +10 -0
- package/api/rule-set.js +0 -0
- package/api/testing.d.ts +5 -0
- package/api/testing.js +211 -0
- package/chunks/chunk-3LCKBX5T.js +2134 -0
- package/chunks/chunk-5LCLBXP7.js +76 -0
- package/chunks/{chunk-7PVPPH4C.js → chunk-LDQUT742.js} +3 -1
- package/chunks/{chunk-VUG3DJHN.js → chunk-MYX7GAVM.js} +9 -9
- package/chunks/{chunk-SWPCKTJV.js → chunk-NCDYOPHG.js} +7340 -2124
- package/chunks/{chunk-HVABJ7T4.js → chunk-NRXSM7BY.js} +73 -12
- package/chunks/{chunk-YBWVUDIG.js → chunk-P3NLETF5.js} +1 -1
- package/chunks/{chunk-IIMK5BCL.js → chunk-POZL7G62.js} +15 -13
- package/chunks/{chunk-7OVV6NEU.js → chunk-WPRR2MPJ.js} +1 -1
- package/core/check/tool-command.js +531 -1967
- package/core/conformance/conformance-testing-types.d.ts +28 -0
- package/core/conformance/conformance-types.d.ts +7 -0
- package/docs/adding-a-discipline-or-mechanism.md +27 -14
- package/docs/extending.md +22 -11
- package/docs/output-contract.md +326 -0
- package/mechanisms/audit/CD-19/import-boundaries.js +3 -3
- package/mechanisms/audit/CD-2/piece.json +6 -1
- package/mechanisms/audit/CD-5/comments-directives.js +10 -26
- package/mechanisms/audit/runner/README.md +3 -2
- package/mechanisms/audit/runner/runner.js +97 -35
- package/mechanisms/eslint/CD-2/README.md +12 -0
- package/mechanisms/eslint/CD-2/cd2/cd2.eslint-plugin.js +16 -0
- package/mechanisms/eslint/CD-2/piece.json +25 -0
- package/mechanisms/eslint/runner/README.md +12 -5
- package/mechanisms/eslint/runner/runner.js +900 -242
- package/methods/README.md +2 -0
- package/methods/assessment-template.md +35 -0
- package/methods/lenses/clean-architecture.md +2 -2
- package/methods/lenses/decomposition.md +2 -2
- package/methods/lenses/defended-on-intent.md +7 -7
- package/methods/lenses/di-discipline.md +38 -26
- package/methods/lenses/errors-as-data.md +2 -2
- package/methods/lenses/function-first.md +2 -2
- package/methods/lenses/naming.md +2 -2
- package/methods/lenses/test-discipline.md +15 -13
- package/methods/lenses/type-soundness.md +2 -2
- package/methods/lenses/zod-boundary.md +2 -2
- package/package.json +8 -3
- package/rules/CD-1/CHECKS.md +37 -0
- package/rules/CD-1/README.md +17 -32
- package/rules/CD-10/CHECKS.md +49 -0
- package/rules/CD-10/README.md +21 -49
- package/rules/CD-11/CHECKS.md +13 -0
- package/rules/CD-11/README.md +14 -8
- package/rules/CD-12/CHECKS.md +13 -0
- package/rules/CD-12/README.md +14 -8
- package/rules/CD-13/CHECKS.md +13 -0
- package/rules/CD-13/README.md +14 -8
- package/rules/CD-14/CHECKS.md +49 -0
- package/rules/CD-14/README.md +22 -48
- package/rules/CD-15/CHECKS.md +40 -0
- package/rules/CD-15/README.md +22 -40
- package/rules/CD-16/CHECKS.md +7 -0
- package/rules/CD-16/README.md +3 -5
- package/rules/CD-17/CHECKS.md +37 -0
- package/rules/CD-17/README.md +17 -31
- package/rules/CD-18/CHECKS.md +13 -0
- package/rules/CD-18/README.md +15 -9
- package/rules/CD-19/CHECKS.md +49 -0
- package/rules/CD-19/README.md +18 -44
- package/rules/CD-2/CHECKS.md +56 -0
- package/rules/CD-2/README.md +18 -35
- package/rules/CD-2/discipline.json +68 -0
- package/rules/CD-20/CHECKS.md +7 -0
- package/rules/CD-20/README.md +3 -5
- package/rules/CD-21/CHECKS.md +13 -0
- package/rules/CD-21/README.md +14 -9
- package/rules/CD-22/CHECKS.md +13 -0
- package/rules/CD-22/README.md +13 -8
- package/rules/CD-23/CHECKS.md +35 -0
- package/rules/CD-23/README.md +14 -29
- package/rules/CD-24/CHECKS.md +7 -0
- package/rules/CD-24/README.md +3 -5
- package/rules/CD-25/CHECKS.md +38 -0
- package/rules/CD-25/README.md +20 -32
- package/rules/CD-26/CHECKS.md +36 -0
- package/rules/CD-26/README.md +18 -31
- package/rules/CD-27/CHECKS.md +45 -0
- package/rules/CD-27/README.md +18 -40
- package/rules/CD-28/CHECKS.md +13 -0
- package/rules/CD-28/README.md +14 -8
- package/rules/CD-29/CHECKS.md +13 -0
- package/rules/CD-29/README.md +12 -8
- package/rules/CD-3/CHECKS.md +42 -0
- package/rules/CD-3/README.md +20 -42
- package/rules/CD-30/CHECKS.md +13 -0
- package/rules/CD-30/README.md +13 -8
- package/rules/CD-31/CHECKS.md +13 -0
- package/rules/CD-31/README.md +12 -8
- package/rules/CD-32/CHECKS.md +13 -0
- package/rules/CD-32/README.md +13 -8
- package/rules/CD-33/CHECKS.md +13 -0
- package/rules/CD-33/README.md +13 -8
- package/rules/CD-34/CHECKS.md +13 -0
- package/rules/CD-34/README.md +12 -8
- package/rules/CD-39/CHECKS.md +13 -0
- package/rules/CD-39/README.md +13 -8
- package/rules/CD-4/CHECKS.md +13 -0
- package/rules/CD-4/README.md +15 -8
- package/rules/CD-40/CHECKS.md +39 -0
- package/rules/CD-40/README.md +17 -33
- package/rules/CD-41/CHECKS.md +54 -0
- package/rules/CD-41/README.md +23 -54
- package/rules/CD-42/CHECKS.md +47 -0
- package/rules/CD-42/README.md +19 -47
- package/rules/CD-43/CHECKS.md +37 -0
- package/rules/CD-43/README.md +15 -31
- package/rules/CD-44/CHECKS.md +48 -0
- package/rules/CD-44/README.md +20 -48
- package/rules/CD-45/CHECKS.md +13 -0
- package/rules/CD-45/README.md +14 -8
- package/rules/CD-46/CHECKS.md +7 -0
- package/rules/CD-46/README.md +16 -4
- package/rules/CD-47/CHECKS.md +37 -0
- package/rules/CD-47/README.md +16 -32
- package/rules/CD-5/CHECKS.md +52 -0
- package/rules/CD-5/README.md +22 -52
- package/rules/CD-6/CHECKS.md +51 -0
- package/rules/CD-6/README.md +22 -51
- package/rules/CD-7/CHECKS.md +46 -0
- package/rules/CD-7/README.md +23 -46
- package/rules/CD-7a/CHECKS.md +38 -0
- package/rules/CD-7a/README.md +14 -32
- package/rules/CD-8/CHECKS.md +42 -0
- package/rules/CD-8/README.md +20 -42
- package/rules/CD-9/CHECKS.md +13 -0
- package/rules/CD-9/README.md +15 -8
- package/rules/README.md +5 -3
- package/rules/SPIRIT.md +50 -0
- package/api/audit.mjs +0 -1
- package/api/rule-set.mjs +0 -1
package/rules/CD-3/README.md
CHANGED
|
@@ -4,45 +4,23 @@
|
|
|
4
4
|
|
|
5
5
|
Every unit compiles under one shared, maximally-strict compiler configuration; no unit weakens it locally. A relaxed flag in one corner (disabling strictness, unchecked indexing, exact-optional handling, catch-variable typing) creates a zone where the type system quietly stops protecting you, and that zone spreads. Strictness is inherited, never overridden.
|
|
6
6
|
|
|
7
|
-
The
|
|
8
|
-
|
|
9
|
-
##
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
-
|
|
26
|
-
-
|
|
27
|
-
|
|
28
|
-
## Example violation
|
|
29
|
-
```json
|
|
30
|
-
{ "compilerOptions": { "strict": false } }
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
## How to fix
|
|
34
|
-
```json
|
|
35
|
-
{ "extends": "../../tsconfig.base.json", "compilerOptions": { "outDir": "dist" } }
|
|
36
|
-
```
|
|
37
|
-
Put the flags in a shared base file that is not named `tsconfig.json`, and leave them out of every `tsconfig.json`. That the base file turns them on is left to review.
|
|
38
|
-
|
|
39
|
-
## Exceptions
|
|
40
|
-
Add an entry to `discipline-exceptions.json` at the repository root. Use `authorised-location` when a package must set the flag itself. Use `file-carve-out` for debt in one file: it needs a `whyChain` and is forfeited once the file is touched. See [discipline-exceptions.json](../../README.md#discipline-exceptionsjson).
|
|
41
|
-
|
|
42
|
-
```json
|
|
43
|
-
{ "version": 1, "exceptions": [
|
|
44
|
-
{ "kind": "authorised-location", "clause": "CD-3#strict", "file": "packages/legacy/tsconfig.json", "reason": "..." }
|
|
45
|
-
] }
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
Every record, `authorised-location` included, also needs a `whyChain` that follows the [why-chain contract](../../docs/why-chain-contract.md): five whys chained cause to cause, a `rootCause`, its `rootCheck`, a `readback` and an `owner`. The one exception is a record imported from an earlier system, which carries `provenance` instead. [The exceptions format](../../README.md#discipline-exceptionsjson) gives both shapes.
|
|
7
|
+
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).
|
|
8
|
+
|
|
9
|
+
## Spirit
|
|
10
|
+
|
|
11
|
+
**What the friction is for.** Every relaxed compiler flag is a zone where the types quietly stop protecting you. The friction keeps one strict standard everywhere, so no corner of the codebase becomes the place errors hide.
|
|
12
|
+
|
|
13
|
+
**What a finding points at.** Match the configs against these causes.
|
|
14
|
+
- *Errors switched off instead of fixed.* A flag was relaxed because turning it on produced many errors. Those errors are the real finding; fix them by area.
|
|
15
|
+
- *A package that was never brought up to standard.* Legacy or imported code was given its own looser config. Raise it, starting with the flag that hides the most.
|
|
16
|
+
- *Types wrong at a boundary.* Indexed or optional access errors cluster around outside data. Parse that data into exact types at the boundary.
|
|
17
|
+
|
|
18
|
+
**Where to go.** Every unit inherits the one strict configuration and overrides nothing.
|
|
19
|
+
|
|
20
|
+
**Reactions to distrust.**
|
|
21
|
+
- "This flag is too strict for our code." It reports the cases your code does not handle. Handle them.
|
|
22
|
+
- "Just for this package." A relaxed corner spreads: code moves, and the looser rules move with it.
|
|
23
|
+
|
|
24
|
+
**Principles behind it.**
|
|
25
|
+
- *Broken windows* (Andrew Hunt and David Thomas, *The Pragmatic Programmer*). One tolerated lapse signals that lapses are acceptable, and more follow.
|
|
26
|
+
- *Fail fast.* A strict compiler reports the defect when it is written, not when it runs.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# CD-30 checks
|
|
2
|
+
|
|
3
|
+
Read [the rule and its spirit](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
|
+
|
|
5
|
+
## Clauses
|
|
6
|
+
|
|
7
|
+
| Clause | Mechanism | Checks |
|
|
8
|
+
| --- | --- | --- |
|
|
9
|
+
| `CD-30#composition-only` | review | an integration test targets the wiring between units, not their logic |
|
|
10
|
+
|
|
11
|
+
## How it is checked
|
|
12
|
+
|
|
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 rule](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-30/README.md
CHANGED
|
@@ -4,16 +4,21 @@
|
|
|
4
4
|
|
|
5
5
|
An integration test exists to catch composition bugs — wiring, contracts between units — not unit-level logic bugs. If an integration test is the first thing to fail on a logic error, the missing test is a unit test; add it at the base rather than diagnosing through the composed system.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Review lens: [test-discipline](../../methods/lenses/test-discipline.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).
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## Spirit
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
| --- | --- | --- |
|
|
13
|
-
| `CD-30#composition-only` | review | an integration test targets the wiring between units, not their logic |
|
|
11
|
+
**What the friction is for.** An integration test that finds a logic bug is doing a unit test's job slowly and vaguely. The friction keeps integration tests on wiring, so each layer catches what it is best at.
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
**What a finding points at.** Match the tests against these causes.
|
|
14
|
+
- *A missing unit test.* A logic bug surfaced first in integration. Add the unit test at the base.
|
|
15
|
+
- *Integration tests asserting logic.* The test checks calculations, not connections. Move those cases down.
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
**Where to go.** Integration tests check that units connect correctly. Unit tests check what each unit computes.
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
**Reactions to distrust.**
|
|
20
|
+
- "It's more realistic." Realism costs speed and precision. Spend it on wiring only.
|
|
21
|
+
|
|
22
|
+
**Principles behind it.**
|
|
23
|
+
- *The test pyramid* (Mike Cohn). Each layer has a job; broad tests are few because they localise faults poorly.
|
|
24
|
+
- *Defect localisation.* A failing test should point at the fault. A logic failure in an integration test points at the whole system.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# CD-31 checks
|
|
2
|
+
|
|
3
|
+
Read [the rule and its spirit](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
|
+
|
|
5
|
+
## Clauses
|
|
6
|
+
|
|
7
|
+
| Clause | Mechanism | Checks |
|
|
8
|
+
| --- | --- | --- |
|
|
9
|
+
| `CD-31#no-coverage-thresholds` | review | no percentage coverage threshold gates a run |
|
|
10
|
+
|
|
11
|
+
## How it is checked
|
|
12
|
+
|
|
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 rule](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-31/README.md
CHANGED
|
@@ -4,16 +4,20 @@
|
|
|
4
4
|
|
|
5
5
|
Coverage is a diagnostic to read, not a gate to pass. A percentage threshold rewards tests written to move a number; the real floor is the every-file test sibling. Chasing a coverage figure produces assertion-free tests that raise the metric and protect nothing.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Review lens: [test-discipline](../../methods/lenses/test-discipline.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).
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## Spirit
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
| --- | --- | --- |
|
|
13
|
-
| `CD-31#no-coverage-thresholds` | review | no percentage coverage threshold gates a run |
|
|
11
|
+
**What the friction is for.** A coverage target rewards running code, not checking it. Without the target, nothing rewards a test that moves the number and checks nothing. The floor comes from every unit having its own test, and coverage stays something to read.
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
**What a finding points at.** Match the configuration against these causes.
|
|
14
|
+
- *A number standing in for a floor.* The threshold exists because nothing guaranteed every unit a test. The every-file sibling rule is that floor.
|
|
15
|
+
- *Tests written to move the number.* Tests with no real assertions appear. Remove them; read coverage as a diagnostic.
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
**Where to go.** Coverage is read to find untested behaviour, never gated.
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
**Reactions to distrust.**
|
|
20
|
+
- "Without a target, coverage will drop." The sibling rule holds the floor; the number is for reading.
|
|
21
|
+
|
|
22
|
+
**Principles behind it.**
|
|
23
|
+
- *Goodhart's law*, in Marilyn Strathern's phrasing: "When a measure becomes a target, it ceases to be a good measure."
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# CD-32 checks
|
|
2
|
+
|
|
3
|
+
Read [the rule and its spirit](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
|
+
|
|
5
|
+
## Clauses
|
|
6
|
+
|
|
7
|
+
| Clause | Mechanism | Checks |
|
|
8
|
+
| --- | --- | --- |
|
|
9
|
+
| `CD-32#pii-redaction` | review | structured logs redact PII strings unless a field is explicitly opted in |
|
|
10
|
+
|
|
11
|
+
## How it is checked
|
|
12
|
+
|
|
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 rule](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-32/README.md
CHANGED
|
@@ -4,16 +4,21 @@
|
|
|
4
4
|
|
|
5
5
|
Structured logs redact personally-identifying data by default; a field becomes loggable only by explicitly opting in as safe. Redaction is the default so a new field is never accidentally leaked into logs — safety is the resting state, exposure the deliberate exception.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Review lens: [clean-architecture](../../methods/lenses/clean-architecture.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).
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## Spirit
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
| --- | --- | --- |
|
|
13
|
-
| `CD-32#pii-redaction` | review | structured logs redact PII strings unless a field is explicitly opted in |
|
|
11
|
+
**What the friction is for.** A log field added in a hurry should not leak personal data. The friction makes redaction the resting state, so exposure takes a deliberate decision.
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
**What a finding points at.** Match the sites against these causes.
|
|
14
|
+
- *Logging whole objects.* Records are logged as they are, carrying every field. Log named, safe fields.
|
|
15
|
+
- *Safe-listing by habit.* Fields are opted in without thought. Each opt-in is a decision; record why the field is safe.
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
**Where to go.** Logs redact personal data by default; only fields explicitly marked safe appear.
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
**Reactions to distrust.**
|
|
20
|
+
- "We need it for debugging." Then log an identifier that leads to it, not the data.
|
|
21
|
+
|
|
22
|
+
**Principles behind it.**
|
|
23
|
+
- *Secure by default.* The safe state needs no action; the risky one needs a decision.
|
|
24
|
+
- *Privacy by design* (Ann Cavoukian). Protection of personal data is built into the system, not added later.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# CD-33 checks
|
|
2
|
+
|
|
3
|
+
Read [the rule and its spirit](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
|
+
|
|
5
|
+
## Clauses
|
|
6
|
+
|
|
7
|
+
| Clause | Mechanism | Checks |
|
|
8
|
+
| --- | --- | --- |
|
|
9
|
+
| `CD-33#sensitive-brands` | review | sensitive branded types redact everywhere, with no opt-out |
|
|
10
|
+
|
|
11
|
+
## How it is checked
|
|
12
|
+
|
|
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 rule](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-33/README.md
CHANGED
|
@@ -4,16 +4,21 @@
|
|
|
4
4
|
|
|
5
5
|
A value whose type is branded sensitive redacts unconditionally wherever it surfaces — logs, errors, serialisation — with no opt-out. Branding sensitivity into the type means the redaction travels with the value by construction, rather than depending on every call site remembering to hide it.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Review lens: [clean-architecture](../../methods/lenses/clean-architecture.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).
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## Spirit
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
| --- | --- | --- |
|
|
13
|
-
| `CD-33#sensitive-brands` | review | sensitive branded types redact everywhere, with no opt-out |
|
|
11
|
+
**What the friction is for.** Remembering to hide a secret at every call site fails eventually. The friction puts the redaction in the type, so it travels with the value.
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
**What a finding points at.** Match the sites against these causes.
|
|
14
|
+
- *Sensitive values as plain strings.* Tokens or keys are typed as strings. Brand them, so redaction follows by construction.
|
|
15
|
+
- *An escape to print the value.* A path exposes the raw value for convenience. Remove it; the rule has no opt-out.
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
**Where to go.** Every sensitive value has a branded type that redacts wherever it surfaces.
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
**Reactions to distrust.**
|
|
20
|
+
- "We need to see it sometimes." Then that is a deliberate operation at a boundary that needs the value, not a log line.
|
|
21
|
+
|
|
22
|
+
**Principles behind it.**
|
|
23
|
+
- *Make illegal states unrepresentable* (Yaron Minsky). A branded type cannot be printed in the clear by mistake.
|
|
24
|
+
- *Secure by default.* Redaction needs no action from the caller.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# CD-34 checks
|
|
2
|
+
|
|
3
|
+
Read [the rule and its spirit](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
|
+
|
|
5
|
+
## Clauses
|
|
6
|
+
|
|
7
|
+
| Clause | Mechanism | Checks |
|
|
8
|
+
| --- | --- | --- |
|
|
9
|
+
| `CD-34#no-repo-secrets` | review | secrets never enter source, history, logs or URLs |
|
|
10
|
+
|
|
11
|
+
## How it is checked
|
|
12
|
+
|
|
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 rule](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-34/README.md
CHANGED
|
@@ -4,16 +4,20 @@
|
|
|
4
4
|
|
|
5
5
|
Secrets live only in the environment or a secrets manager — never in source, never in logs, never in URL query parameters. A committed secret is compromised the moment it lands in history, whatever happens to it later; the repository is not a place a secret can safely exist.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Review lens: [clean-architecture](../../methods/lenses/clean-architecture.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).
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## Spirit
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
| --- | --- | --- |
|
|
13
|
-
| `CD-34#no-repo-secrets` | review | secrets never enter source, history, logs or URLs |
|
|
11
|
+
**What the friction is for.** A secret in history is compromised for good. The friction keeps secrets out of the repository entirely, so there is nothing to leak.
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
**What a finding points at.** Match the sites against these causes.
|
|
14
|
+
- *Configuration mixed with code.* Credentials sit in source because config has no other home. Read them from the environment or a secrets manager.
|
|
15
|
+
- *Test credentials that are real.* Tests use live keys. Use placeholder or generated test values.
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
**Where to go.** Source holds no secrets. Secrets arrive at runtime from the environment or a secrets manager.
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
**Reactions to distrust.**
|
|
20
|
+
- "It's a private repository." Access changes, history stays.
|
|
21
|
+
|
|
22
|
+
**Principles behind it.**
|
|
23
|
+
- *Config in the environment* (The Twelve-Factor App). Configuration that varies by deploy, credentials included, lives outside the code.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# CD-39 checks
|
|
2
|
+
|
|
3
|
+
Read [the rule and its spirit](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
|
+
|
|
5
|
+
## Clauses
|
|
6
|
+
|
|
7
|
+
| Clause | Mechanism | Checks |
|
|
8
|
+
| --- | --- | --- |
|
|
9
|
+
| `CD-39#cite-by-id` | review | reviews and rationale cite principles and rules by identifier |
|
|
10
|
+
|
|
11
|
+
## How it is checked
|
|
12
|
+
|
|
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 rule](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-39/README.md
CHANGED
|
@@ -4,16 +4,21 @@
|
|
|
4
4
|
|
|
5
5
|
Reviews and rationale cite specific rules by their identifier, not vague appeals to "the standards". A citation anchors a finding to the named rule and its intent, so remediation is precise and the disagreement, if any, is about the rule rather than about taste.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Review lens: none. A reviewer applies the rule text directly. How it is checked: [CHECKS.md](CHECKS.md). The thinking behind every rule: [the spirit of the rules](../SPIRIT.md).
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## Spirit
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
| --- | --- | --- |
|
|
13
|
-
| `CD-39#cite-by-id` | review | reviews and rationale cite principles and rules by identifier |
|
|
11
|
+
**What the friction is for.** "This doesn't meet our standards" cannot be acted on or argued with. Citing the rule by its identifier turns a finding into something precise.
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
**What a finding points at.** Match the reviews against these causes.
|
|
14
|
+
- *Findings argued from taste.* No rule is cited, so the disagreement is personal. Cite the rule, or say none applies.
|
|
15
|
+
- *Rules nobody can find.* Reviewers cannot cite because the rules are not known. Point at the rule pages.
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
**Where to go.** Every finding and rationale names the rule it rests on.
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
**Reactions to distrust.**
|
|
20
|
+
- "Everyone knows the rule." Then citing it costs nothing, and newcomers learn it.
|
|
21
|
+
|
|
22
|
+
**Principles behind it.**
|
|
23
|
+
- *Traceability.* Each decision links to the rule that justifies it, so it can be checked and challenged.
|
|
24
|
+
- *Architecture decision records* (Michael Nygard). Decisions are written down with their reasons, so later readers can follow them.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# CD-4 checks
|
|
2
|
+
|
|
3
|
+
Read [the rule and its spirit](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
|
+
|
|
5
|
+
## Clauses
|
|
6
|
+
|
|
7
|
+
| Clause | Mechanism | Checks |
|
|
8
|
+
| --- | --- | --- |
|
|
9
|
+
| `CD-4#boundary-validation` | review | every crossing from the untyped outside world is schema-validated at the seam |
|
|
10
|
+
|
|
11
|
+
## How it is checked
|
|
12
|
+
|
|
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 rule](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-4/README.md
CHANGED
|
@@ -4,16 +4,23 @@
|
|
|
4
4
|
|
|
5
5
|
Every crossing from the untyped outside world — HTTP, environment, files, database rows, inter-process input — is validated by a schema at the seam and handed inward as plain typed data. The boundary is the one place the program does not yet know the shape of its input; parse it there, once, so everything deeper can trust its types.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Review lens: [zod-boundary](../../methods/lenses/zod-boundary.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).
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## Spirit
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
| --- | --- | --- |
|
|
13
|
-
| `CD-4#boundary-validation` | review | every crossing from the untyped outside world is schema-validated at the seam |
|
|
11
|
+
**What the friction is for.** The boundary is the one place the program does not know the shape of what it receives. The friction makes checking it there the easy path, so everything inside can trust its types.
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
**What a finding points at.** Match the sites against these causes.
|
|
14
|
+
- *Input trusted on arrival.* A request, file, environment value, or database row is used as if typed. Parse it with a schema at the seam.
|
|
15
|
+
- *No clear seam.* Outside data enters in many places. Gather each source behind one adapter that parses it.
|
|
16
|
+
- *Checks scattered inward.* Inner code tests fields for presence. That means nothing parsed at the edge; move the check there.
|
|
16
17
|
|
|
17
|
-
|
|
18
|
+
**Where to go.** Every outside source has one seam that parses it into plain typed data. Nothing inside checks shape again.
|
|
18
19
|
|
|
19
|
-
|
|
20
|
+
**Reactions to distrust.**
|
|
21
|
+
- "It's our own database." It is still outside the type system. Rows can be anything the schema has ever allowed.
|
|
22
|
+
- "The client already validates." The server cannot rely on code it does not run.
|
|
23
|
+
|
|
24
|
+
**Principles behind it.**
|
|
25
|
+
- *Parse, don't validate* (Alexis King). Parsing produces a typed value once; validation leaves the raw value to be checked again.
|
|
26
|
+
- *Ports and adapters* (Alistair Cockburn, hexagonal architecture). Each outside system enters through one adapter, which is where its data is translated.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# CD-40 checks
|
|
2
|
+
|
|
3
|
+
Read [the rule and its spirit](README.md) first. This page is the mechanics: what each check flags and misses, how to fix a flagged site, and how to record an exception.
|
|
4
|
+
|
|
5
|
+
## Clauses
|
|
6
|
+
|
|
7
|
+
| Clause | Mechanism | Checks |
|
|
8
|
+
| --- | --- | --- |
|
|
9
|
+
| `CD-40#parameter-count` | eslint | a function with more than two parameters |
|
|
10
|
+
| `CD-40#named-object-argument` | review | the single argument is an object with named fields, not a positional scalar |
|
|
11
|
+
|
|
12
|
+
## What the check flags
|
|
13
|
+
- The ESLint piece lints whatever files the team's ESLint run includes. It needs ESLint adopted through the projection; see [the ESLint piece](../../mechanisms/eslint/CD-40/README.md).
|
|
14
|
+
- Rule `hone-cd40/max-params`, which is typescript-eslint's `max-params` with `{ "max": 2, "countVoidThis": true }`.
|
|
15
|
+
- A function declaration, function expression, arrow function, method or constructor with more than two parameters. A `this` parameter counts.
|
|
16
|
+
- Not flagged by the check: functions with two or fewer parameters. The rule asks for one named object; a function with two parameters is left to review, where the function-first lens treats every authored function with two or more parameters as a candidate.
|
|
17
|
+
- `named-object-argument` is a judgement clause. It cannot be selected and is enforced by review.
|
|
18
|
+
|
|
19
|
+
## Example violation
|
|
20
|
+
```ts
|
|
21
|
+
const createOrder = (customerId: string, items: Item[], currency: string) => ({ customerId, items, currency });
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## How to fix
|
|
25
|
+
```ts
|
|
26
|
+
const createOrder = ({ customerId, items, currency }: OrderRequest) => ({ customerId, items, currency });
|
|
27
|
+
```
|
|
28
|
+
Take one object with named fields so each call site reads as a labelled contract.
|
|
29
|
+
|
|
30
|
+
## Exceptions
|
|
31
|
+
Add an entry to `discipline-exceptions.json` at the repository root. Use `authorised-location` when a file must implement a callback signature fixed by an external library. Use `file-carve-out` for debt in one file: it needs a `whyChain` and is forfeited once the file is touched. Judgement clauses cannot be selected and need no exception record. See [discipline-exceptions.json](../../README.md#discipline-exceptionsjson).
|
|
32
|
+
|
|
33
|
+
```json
|
|
34
|
+
{ "version": 1, "exceptions": [
|
|
35
|
+
{ "kind": "authorised-location", "clause": "CD-40#parameter-count", "file": "src/adapters/vendor-callback.ts", "reason": "..." }
|
|
36
|
+
] }
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Every record, `authorised-location` included, also needs a `whyChain` that follows the [why-chain contract](../../docs/why-chain-contract.md): five whys chained cause to cause, a `rootCause`, its `rootCheck`, a `readback` and an `owner`. The one exception is a record imported from an earlier system, which carries `provenance` instead. [The exceptions format](../../README.md#discipline-exceptionsjson) gives both shapes.
|
package/rules/CD-40/README.md
CHANGED
|
@@ -4,42 +4,26 @@
|
|
|
4
4
|
|
|
5
5
|
A function takes a single named-field object argument rather than a positional parameter list, so every call site reads as a labelled contract instead of a sequence of unlabelled values whose meaning depends on order. Named fields also make adding or reordering parameters a safe, non-breaking change.
|
|
6
6
|
|
|
7
|
-
The
|
|
7
|
+
Review lens: [function-first](../../methods/lenses/function-first.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).
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## Spirit
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
| --- | --- | --- |
|
|
13
|
-
| `CD-40#parameter-count` | eslint | a function with more than two parameters |
|
|
14
|
-
| `CD-40#named-object-argument` | review | the single argument is an object with named fields, not a positional scalar |
|
|
11
|
+
**What the friction is for.** Positional arguments make meaning depend on order, and nothing checks the order. The friction makes a labelled call the easy one, and turns what each function needs into a named shape a reader can see.
|
|
15
12
|
|
|
16
|
-
|
|
13
|
+
**What a finding points at.** Match the sites against these causes.
|
|
14
|
+
- *Values that travel together without a name.* The same group of arguments passes through several functions. Name the group as one type.
|
|
15
|
+
- *A function with several jobs.* It has many parameters because it serves many concerns. Split it.
|
|
16
|
+
- *Flags steering behaviour.* An argument switches between modes. Split the function, or make the mode a named union.
|
|
17
|
+
- *Asking for more than it uses.* Converting to one object invites passing a whole record. Take only the fields the function reads; tests then build only those.
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
- The ESLint piece lints whatever files the team's ESLint run includes. It needs ESLint adopted through the projection; see [the ESLint piece](../../mechanisms/eslint/CD-40/README.md).
|
|
20
|
-
- Rule `hone-cd40/max-params`, which is typescript-eslint's `max-params` with `{ "max": 2, "countVoidThis": true }`.
|
|
21
|
-
- A function declaration, function expression, arrow function, method or constructor with more than two parameters. A `this` parameter counts.
|
|
22
|
-
- Allowed: functions with two or fewer parameters.
|
|
23
|
-
- `named-object-argument` is a judgement clause. It cannot be selected and is enforced by review.
|
|
19
|
+
**Where to go.** Every function takes one object whose fields are named and minimal. Adding a field breaks no caller.
|
|
24
20
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
**Reactions to distrust.**
|
|
22
|
+
- "Two parameters is fine." The rule asks for one named object. Two positional values already have an order to get wrong.
|
|
23
|
+
- "The library dictates this callback." Then the callback is the boundary. Hand off to a single-object function on its first line.
|
|
24
|
+
- "An object is more typing." It is a few characters at the call site, against every reader guessing the order.
|
|
29
25
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
Take one object with named fields so each call site reads as a labelled contract.
|
|
35
|
-
|
|
36
|
-
## Exceptions
|
|
37
|
-
Add an entry to `discipline-exceptions.json` at the repository root. Use `authorised-location` when a file must implement a callback signature fixed by an external library. Use `file-carve-out` for debt in one file: it needs a `whyChain` and is forfeited once the file is touched. Judgement clauses cannot be selected and need no exception record. See [discipline-exceptions.json](../../README.md#discipline-exceptionsjson).
|
|
38
|
-
|
|
39
|
-
```json
|
|
40
|
-
{ "version": 1, "exceptions": [
|
|
41
|
-
{ "kind": "authorised-location", "clause": "CD-40#parameter-count", "file": "src/adapters/vendor-callback.ts", "reason": "..." }
|
|
42
|
-
] }
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
Every record, `authorised-location` included, also needs a `whyChain` that follows the [why-chain contract](../../docs/why-chain-contract.md): five whys chained cause to cause, a `rootCause`, its `rootCheck`, a `readback` and an `owner`. The one exception is a record imported from an earlier system, which carries `provenance` instead. [The exceptions format](../../README.md#discipline-exceptionsjson) gives both shapes.
|
|
26
|
+
**Principles behind it.**
|
|
27
|
+
- *Function arguments* (Robert C. Martin, *Clean Code*). Each extra argument is something the reader must hold in mind and the caller can get wrong.
|
|
28
|
+
- *Introduce Parameter Object* (Martin Fowler, *Refactoring*). The refactoring that names a group of values that travel together.
|
|
29
|
+
- *Interface Segregation Principle* (Robert C. Martin, SOLID). The object asks for exactly the fields used, no more.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# CD-41 checks
|
|
2
|
+
|
|
3
|
+
Read [the rule and its spirit](README.md) first. This page is the mechanics: what each check flags and misses, how to fix a flagged site, and how to record an exception.
|
|
4
|
+
|
|
5
|
+
## Clauses
|
|
6
|
+
|
|
7
|
+
| Clause | Mechanism | Checks |
|
|
8
|
+
| --- | --- | --- |
|
|
9
|
+
| `CD-41#cognitive-complexity` | eslint | a function whose cognitive complexity is above 15 |
|
|
10
|
+
| `CD-41#function-length` | eslint | a function body longer than 50 lines |
|
|
11
|
+
| `CD-41#orchestration-only` | review | an orchestrator only composes helper calls and assembles their results |
|
|
12
|
+
|
|
13
|
+
## What the check flags
|
|
14
|
+
- The ESLint piece lints whatever files the team's ESLint run includes. It needs ESLint adopted through the projection; see [the ESLint piece](../../mechanisms/eslint/CD-41/README.md).
|
|
15
|
+
- `hone-cd41/cognitive-complexity`: each function's cognitive complexity must be at most 15.
|
|
16
|
+
- An `if`, `else if`, `switch`, ternary, `catch` and each loop adds 1 plus the current nesting depth.
|
|
17
|
+
- An `else`, a `finally`, a labelled `break` or `continue`, and each run of the same logical operator add 1.
|
|
18
|
+
- Nesting deepens inside `if`, loops, `switch`, `catch` and ternaries.
|
|
19
|
+
- A nested function is scored on its own, starting one level deeper, and its score is not added to its parent.
|
|
20
|
+
- Reported at the function's name.
|
|
21
|
+
- `hone-cd41/function-length`: a function body may span at most 50 lines. Blank and comment lines count; lines holding only `{` or `}` do not. Getters and setters are not checked. Reported at the function.
|
|
22
|
+
- `orchestration-only` is a judgement clause. It cannot be selected and is enforced by review.
|
|
23
|
+
|
|
24
|
+
## Example violation
|
|
25
|
+
```ts
|
|
26
|
+
const settle = (orders: Order[]) => {
|
|
27
|
+
for (const order of orders) {
|
|
28
|
+
if (order.paid) {
|
|
29
|
+
for (const line of order.lines) {
|
|
30
|
+
if (line.refundable && line.quantity > 0) {
|
|
31
|
+
refund(line);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## How to fix
|
|
40
|
+
```ts
|
|
41
|
+
const settle = (orders: Order[]) => orders.filter(isPaid).forEach(refundEligibleLines);
|
|
42
|
+
```
|
|
43
|
+
Move each branch into a named helper so the orchestrator only composes calls.
|
|
44
|
+
|
|
45
|
+
## Exceptions
|
|
46
|
+
Add an entry to `discipline-exceptions.json` at the repository root. Use `authorised-location` when a file holds a function whose shape is fixed by an external contract. Use `file-carve-out` for debt in one file: it needs a `whyChain` and is forfeited once the file is touched. Judgement clauses cannot be selected and need no exception record. See [discipline-exceptions.json](../../README.md#discipline-exceptionsjson).
|
|
47
|
+
|
|
48
|
+
```json
|
|
49
|
+
{ "version": 1, "exceptions": [
|
|
50
|
+
{ "kind": "authorised-location", "clause": "CD-41#cognitive-complexity", "file": "src/legacy/tax-engine.ts", "reason": "..." }
|
|
51
|
+
] }
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Every record, `authorised-location` included, also needs a `whyChain` that follows the [why-chain contract](../../docs/why-chain-contract.md): five whys chained cause to cause, a `rootCause`, its `rootCheck`, a `readback` and an `owner`. The one exception is a record imported from an earlier system, which carries `provenance` instead. [The exceptions format](../../README.md#discipline-exceptionsjson) gives both shapes.
|