@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.
Files changed (140) hide show
  1. package/ADOPTING.md +8 -8
  2. package/CHANGELOG.md +36 -0
  3. package/MIGRATING.md +40 -0
  4. package/README.md +28 -7
  5. package/api/audit.d.ts +1 -1
  6. package/api/testing.js +3 -3
  7. package/chunks/{chunk-H4V72FCW.js → chunk-2O46EB4E.js} +15 -1
  8. package/chunks/chunk-335ITLPO.js +7 -0
  9. package/chunks/{chunk-YSN46EB3.js → chunk-5U4VTFD5.js} +347 -664
  10. package/chunks/{chunk-PL2PNPAR.js → chunk-E6VR3VRV.js} +1 -6
  11. package/chunks/chunk-WF3PPYRR.js +27 -0
  12. package/core/check/tool-command.js +1120 -105
  13. package/core/mechanism-port/runner-result-types.d.ts +10 -0
  14. package/docs/adding-a-discipline-or-mechanism.md +5 -3
  15. package/docs/extending.md +2 -0
  16. package/docs/output-contract.md +64 -11
  17. package/mechanisms/audit/CD-27/test-body-logic.js +397 -46
  18. package/mechanisms/audit/runner/runner.js +5 -3
  19. package/mechanisms/audit/runner/typescript-parse.d.ts +2 -0
  20. package/mechanisms/audit/runner/walker-piece.d.ts +2 -1
  21. package/mechanisms/eslint/CD-1/cd1/cd1.eslint-plugin.js +7 -4
  22. package/mechanisms/eslint/CD-10/cd10/cd10.eslint-plugin.js +21 -11
  23. package/mechanisms/eslint/CD-14/cd14/cd14.eslint-plugin.js +15 -5
  24. package/mechanisms/eslint/CD-27/cd27/cd27.eslint-plugin.js +7 -3
  25. package/mechanisms/eslint/CD-41/README.md +1 -1
  26. package/mechanisms/eslint/CD-41/cd41/cd41.eslint-plugin.js +100 -28
  27. package/mechanisms/eslint/CD-42/cd42/cd42.eslint-plugin.js +8 -4
  28. package/mechanisms/eslint/CD-7/cd7/cd7.eslint-plugin.js +8 -4
  29. package/mechanisms/eslint/runner/README.md +9 -2
  30. package/mechanisms/eslint/runner/runner.js +1410 -1384
  31. package/methods/assessment-template.md +2 -2
  32. package/methods/lenses/clean-architecture.md +7 -8
  33. package/methods/lenses/defended-on-intent.md +2 -2
  34. package/methods/lenses/di-discipline.md +14 -18
  35. package/methods/lenses/function-first.md +16 -18
  36. package/methods/lenses/test-discipline.md +1 -1
  37. package/package.json +1 -1
  38. package/rules/CD-1/CHECKS.md +6 -2
  39. package/rules/CD-1/README.md +6 -19
  40. package/rules/CD-10/CHECKS.md +5 -3
  41. package/rules/CD-10/README.md +6 -18
  42. package/rules/CD-11/CHECKS.md +4 -2
  43. package/rules/CD-11/README.md +6 -16
  44. package/rules/CD-12/CHECKS.md +4 -2
  45. package/rules/CD-12/README.md +6 -16
  46. package/rules/CD-13/CHECKS.md +4 -2
  47. package/rules/CD-13/README.md +6 -16
  48. package/rules/CD-14/CHECKS.md +3 -1
  49. package/rules/CD-14/README.md +6 -19
  50. package/rules/CD-15/CHECKS.md +5 -1
  51. package/rules/CD-15/README.md +5 -20
  52. package/rules/CD-16/CHECKS.md +3 -1
  53. package/rules/CD-16/README.md +6 -6
  54. package/rules/CD-17/CHECKS.md +3 -1
  55. package/rules/CD-17/README.md +6 -19
  56. package/rules/CD-18/CHECKS.md +4 -2
  57. package/rules/CD-18/README.md +6 -16
  58. package/rules/CD-19/CHECKS.md +8 -6
  59. package/rules/CD-19/README.md +6 -20
  60. package/rules/CD-2/CHECKS.md +7 -3
  61. package/rules/CD-2/README.md +6 -21
  62. package/rules/CD-20/CHECKS.md +3 -1
  63. package/rules/CD-20/README.md +6 -6
  64. package/rules/CD-21/CHECKS.md +4 -2
  65. package/rules/CD-21/README.md +6 -15
  66. package/rules/CD-22/CHECKS.md +4 -2
  67. package/rules/CD-22/README.md +6 -15
  68. package/rules/CD-23/CHECKS.md +5 -3
  69. package/rules/CD-23/README.md +6 -17
  70. package/rules/CD-24/CHECKS.md +3 -1
  71. package/rules/CD-24/README.md +6 -6
  72. package/rules/CD-25/CHECKS.md +5 -3
  73. package/rules/CD-25/README.md +5 -21
  74. package/rules/CD-26/CHECKS.md +5 -3
  75. package/rules/CD-26/README.md +6 -20
  76. package/rules/CD-27/CHECKS.md +394 -9
  77. package/rules/CD-27/README.md +6 -20
  78. package/rules/CD-27/discipline.json +130 -0
  79. package/rules/CD-28/CHECKS.md +4 -2
  80. package/rules/CD-28/README.md +6 -16
  81. package/rules/CD-29/CHECKS.md +4 -2
  82. package/rules/CD-29/README.md +6 -14
  83. package/rules/CD-3/CHECKS.md +3 -1
  84. package/rules/CD-3/README.md +6 -17
  85. package/rules/CD-30/CHECKS.md +4 -2
  86. package/rules/CD-30/README.md +6 -15
  87. package/rules/CD-31/CHECKS.md +4 -2
  88. package/rules/CD-31/README.md +6 -14
  89. package/rules/CD-32/CHECKS.md +3 -1
  90. package/rules/CD-32/README.md +2 -0
  91. package/rules/CD-33/CHECKS.md +3 -1
  92. package/rules/CD-33/README.md +2 -0
  93. package/rules/CD-34/CHECKS.md +3 -1
  94. package/rules/CD-34/README.md +2 -0
  95. package/rules/CD-39/CHECKS.md +3 -1
  96. package/rules/CD-39/README.md +2 -0
  97. package/rules/CD-4/CHECKS.md +4 -2
  98. package/rules/CD-4/README.md +6 -17
  99. package/rules/CD-40/CHECKS.md +3 -1
  100. package/rules/CD-40/README.md +6 -20
  101. package/rules/CD-41/CHECKS.md +14 -2
  102. package/rules/CD-41/README.md +6 -20
  103. package/rules/CD-41/discipline.json +14 -0
  104. package/rules/CD-42/CHECKS.md +3 -1
  105. package/rules/CD-42/README.md +6 -16
  106. package/rules/CD-43/CHECKS.md +3 -1
  107. package/rules/CD-43/README.md +6 -18
  108. package/rules/CD-44/CHECKS.md +3 -1
  109. package/rules/CD-44/README.md +6 -17
  110. package/rules/CD-45/CHECKS.md +4 -2
  111. package/rules/CD-45/README.md +6 -16
  112. package/rules/CD-46/CHECKS.md +3 -1
  113. package/rules/CD-46/README.md +2 -0
  114. package/rules/CD-47/CHECKS.md +4 -2
  115. package/rules/CD-47/README.md +4 -20
  116. package/rules/CD-5/CHECKS.md +4 -2
  117. package/rules/CD-5/README.md +6 -19
  118. package/rules/CD-6/CHECKS.md +3 -1
  119. package/rules/CD-6/README.md +6 -19
  120. package/rules/CD-7/CHECKS.md +3 -1
  121. package/rules/CD-7/README.md +6 -20
  122. package/rules/CD-7a/CHECKS.md +3 -1
  123. package/rules/CD-7a/README.md +6 -17
  124. package/rules/CD-8/CHECKS.md +3 -1
  125. package/rules/CD-8/README.md +6 -17
  126. package/rules/CD-9/CHECKS.md +4 -2
  127. package/rules/CD-9/README.md +6 -17
  128. package/rules/README.md +71 -54
  129. package/rules/SPIRIT.md +3 -3
  130. package/rules/cases.md +94 -0
  131. package/rules/numbers.md +155 -0
  132. package/rules/principles.md +89 -0
  133. package/rules/records.md +150 -0
  134. package/rules/rules.md +149 -0
  135. package/rules/sources.md +142 -0
  136. package/rules/typescript/checks.md +219 -0
  137. package/rules/typescript/recipes.md +361 -0
  138. package/rules/typescript/symptoms.json +1005 -0
  139. package/rules/typescript/symptoms.md +612 -0
  140. package/chunks/chunk-YLZ73C7O.js +0 -0
@@ -0,0 +1,89 @@
1
+ # Principles
2
+
3
+ A principle is a why: what it protects and its reason to change. Each is stated in the same four lines: what must hold, what it protects, its reason to change, and where a breach sits.
4
+
5
+ The principles hold in combination, not one at a time. "The principles are not to hold my rulings on their own but in combination."
6
+
7
+ Principles name no language, tool or library. [Cases](cases.md) say what to do for each thing code is trying to do, and [rules](rules.md) say what must hold under each principle.
8
+
9
+ ## Tests are ours
10
+
11
+ - **Must hold:** A test fails only when what the code it tests returns or calls changes.
12
+ - **Protects:** Red means "this unit broke" and nothing else.
13
+ - **Reason to change:** The world around the unit changes: a clock, a machine, a collaborator.
14
+ - **Breach:** In the unit that reads the world itself (also a breach of External behaviour sits at a boundary), or whose port cannot take a plain stub (also a breach of One place decides). Shows in the test: computed expectations, stubs with logic, module mocks, waits.
15
+ - **Rules under it:** [Written-out answers](rules.md#written-out-answers), [Straight-through tests](rules.md#straight-through-tests), [Tested where it's owned](rules.md#tested-where-its-owned).
16
+ - **Source:** Freeman and Pryce teach that you mock only types you own; this principle keeps tests on what is ours.
17
+
18
+ ## One place decides
19
+
20
+ - **Must hold:** Each unit makes one decision, and each decision is made by one unit of ours.
21
+ - **Protects:** A change to one decision is one edit in one unit.
22
+ - **Reason to change:** A decision changes.
23
+ - **Breach:** In the unit holding a second decision, the second unit re-making one, or the library making one that is ours. Shows as long or nested functions, mode flags, a clock or id read inside a job that is not dating or numbering.
24
+ - **Rules under it:** [Doer or orchestrator](rules.md#doer-or-orchestrator), [Handed what it uses](rules.md#handed-what-it-uses), [Guard first](rules.md#guard-first), [One reason per module](rules.md#one-reason-per-module).
25
+ - **Source:** Parnas hides each decision that may change inside one module; Martin gathers what changes for the same reason.
26
+
27
+ ## No hidden effects
28
+
29
+ - **Must hold:** A unit changes nothing: it gives back the value it returns and calls ports passed in to it.
30
+ - **Protects:** Every effect is visible at the call site, and no unit works by holding state and changing it.
31
+ - **Reason to change:** What a call affects changes.
32
+ - **Breach:** In the function that writes to something it was not passed, changes its input, or changes a value of its own after making it. Shows as tests that patch a global to see an effect.
33
+ - **Rules under it:** none. The principle decides.
34
+ - **Source:** This is Bernhardt's functional core, imperative shell: decisions stay pure and effects stay in sight.
35
+
36
+ ## External behaviour sits at a boundary
37
+
38
+ - **Must hold:** Business logic calls only other business logic, ports passed in to it, and operations that depend on nothing but their arguments and change nothing.
39
+ - **Protects:** A change in a service, a runtime, a clock or a protocol never edits business logic.
40
+ - **Reason to change:** The thing we call changes its behaviour.
41
+ - **Breach:** In the business-logic file that makes the call. Shows as a vendor or adapter import in business logic, a module mock, or a result that differs per machine.
42
+ - **Rules under it:** [Outside dependencies stay at boundaries](rules.md#outside-dependencies-stay-at-boundaries), [Ports declared inside](rules.md#ports-declared-inside).
43
+ - **Source:** This is Cockburn's ports and adapters, and Martin's rule that dependencies point inwards.
44
+
45
+ ## No leak across a boundary
46
+
47
+ - **Must hold:** Data and failures cross a boundary only through an adapter that maps between their outside form and a type of our own.
48
+ - **Protects:** A sender's change of shape stops at the adapter.
49
+ - **Reason to change:** The shape of the data we receive changes.
50
+ - **Breach:** In the adapter that is missing or passes the outside form inward. Shows far inward: presence checks, re-parsing, casts.
51
+ - **Outside data:** anything read at a boundary, our own stored rows and files included.
52
+ - **Record:** an externally defined model adopted as the definitive thing. Evans's *Conformist*. It is a statement on a [boundary record](records.md#boundary-record).
53
+ - **Rules under it:** none. The principle decides.
54
+ - **Source:** This is Evans's anticorruption layer, applied to failures as well as data, in both directions.
55
+
56
+ ## The type checker proves it
57
+
58
+ - **Must hold:** Every fact the code relies on about a value is proven by the type checker.
59
+ - **Protects:** A wrong shape, an unhandled case or an unhandled failure fails the build, not production.
60
+ - **Reason to change:** A type gains a case or changes shape.
61
+ - **Breach:** At the declaration that admits too much. Shows at uses: casts.
62
+ - **Rules under it:** [Failures are values](rules.md#failures-are-values), [Declared, not asserted](rules.md#declared-not-asserted), [Kinds are named](rules.md#kinds-are-named).
63
+ - **Source:** Minsky makes illegal states unrepresentable; King parses once at the edge, so the types carry the proof.
64
+
65
+ ## Our code reads in the common language
66
+
67
+ - **Must hold:** The meaning of our code is carried only by language constructs engineers in the space already know and by the domain's own names.
68
+ - **Protects:** An engineer reads our code knowing two languages only: the programming language and the domain.
69
+ - **Reason to change:** Who reads the code changes.
70
+ - **Breach:** At the declaration or call that borrows a library's vocabulary or leaves meaning to prose. Shows as comments and utility-type outside dependencies.
71
+ - **Rules under it:** [One word everywhere](rules.md#one-word-everywhere).
72
+ - **Source:** This is Evans's ubiquitous language, held across the whole codebase rather than one context.
73
+
74
+ ## Outside risk is carried on purpose
75
+
76
+ - **Must hold:** No outside code or tool is used by us, or changes version, except by a recorded decision of ours.
77
+ - **Protects:** The upkeep we carry for other people's code (upgrades, vulnerabilities, drift) is upkeep we chose.
78
+ - **Reason to change:** The risk an outside party's code puts on our upkeep changes: a release, a vulnerability, a compromise, an abandoned project.
79
+ - **Breach:** In the manifest, the lock file, the pipeline or a vendored copy. Shows as an outside dependency with no record, a version that floats, a tool fetched at run time, a copy of upstream code that has drifted.
80
+ - **Differs from External behaviour sits at a boundary:** that principle keeps an outside change from editing business logic. This one decides whether the outside thing is here at all, and at which version.
81
+ - **Rules under it:** [Outside dependencies justified](rules.md#outside-dependencies-justified), [Fixed versions](rules.md#fixed-versions), [Tools live in the repo](rules.md#tools-live-in-the-repo), [Upstream stays untouched](rules.md#upstream-stays-untouched). Proposed, not accepted: [Shipped risk declared](rules.md#shipped-risk-declared).
82
+ - **Source:** This follows Twelve-Factor, OpenSSF and the SBOM: every dependency is declared, pinned and recorded.
83
+
84
+ ## Not principles
85
+
86
+ - **Failures as values.** A rule under The type checker proves it.
87
+ - **Sensitive data.** Its rules stand on their own with safety as their why.
88
+ - **Determinism.** The test half is in Tests are ours ("inputs the test writes out"). The other half is in One place decides (one unit dates, one numbers) and External behaviour sits at a boundary (a clock depends on more than its arguments).
89
+ - **Reasons to change.** The test that says what one decision is, not a principle.
@@ -0,0 +1,150 @@
1
+ # Records
2
+
3
+ A record is how a person, or the tool for legacy debt, answers a symptom at a place. "That's why checks have authorised locations and disables. They are imperfect and allow for the correct usage of each thing that is by default a symptom of not thinking it through." A record is more work than the fix.
4
+
5
+ Today's record formats are listed [beside the kinds](#todays-formats-and-the-kinds).
6
+
7
+ ## The kinds
8
+
9
+ Five kinds cover everything.
10
+
11
+ ### Authorised location
12
+
13
+ - **Answers:** A symptom whose correct use a case makes right at one place: Claimed type forced by an outside contract, Throw between our units at an adapter whose caller expects a throw, Loop keyword draining a stream, Shorthand name or Name off its casing fixed by an outside contract, Text past its reader at one test site, Edit inside vendored code.
14
+ - **Must state:** The symptom; the site; the case that makes it correct here and the rule or principle that case owes; a why-chain whose root, if it changed, would remove the need; an owner.
15
+ - **Scope:** One symptom at one site: a file, or a span within it.
16
+ - **Stale or paid when:** Stale when the symptom is no longer at the site. A vendored edit is also re-tested when the vendored version moves. A person removes it.
17
+ - **Industry name:** suppression with justification; a MISRA deviation permit. A suppression with a stated justification, as .NET and MISRA permits do.
18
+
19
+ ### Deviation
20
+
21
+ - **Answers:** A method other than a recipe, where the rule still holds: a fake in place of Stub with vi.fn, or any other recipe.
22
+ - **Must state:** The recipe by name; the reason it was chosen, as its recipe states it; why that reason does not hold at this site, with evidence; how the rule still holds.
23
+ - **Scope:** One recipe at one site.
24
+ - **Stale or paid when:** Stale when the symptom is gone. Review owes "the reason holds again".
25
+ - **Industry name:** a MISRA deviation record. Aviation's alternative means of compliance, held to a stricter proof.
26
+
27
+ ### Debt
28
+
29
+ - **Answers:** Any symptom at a site, a known breach not yet paid.
30
+ - **Must state:** The symptom and the site. Nothing more: "All debt is debt. Reason doesn't matter."
31
+ - **Scope:** One symptom in one file.
32
+ - **Stale or paid when:** Forfeited once the file is touched, so the change pays it. Stale when the symptom is gone. Removed by the tool when the file is gone.
33
+ - **Industry name:** a baseline with a ratchet. Record-debt is the baseline, and forfeit-on-touch is the ratchet. A lint baseline, as in ESLint bulk suppressions, that ratchets down.
34
+
35
+ ### Boundary record
36
+
37
+ - **Answers:** The symptoms a boundary makes correct inside an adapter: Date used directly, Ambient randomness, Process global used in place, Outside import past a boundary, Library class built in place, Outside type in a signature, Text past its reader in the producer's adapter. With a **Conformist** statement, also Schema past its adapter and Outside type in a signature beyond the adapter.
38
+ - **Must state:** The outside party, the port or ports it fulfils, and the module. For Conformist: the outside model adopted as ours, and why it is "a persisted concept that pushes into other boundaries as the definitive thing".
39
+ - **Scope:** One module: a file or a folder.
40
+ - **Stale or paid when:** Stale when the module no longer reaches that outside party. A person removes it.
41
+ - **Industry name:** an architecture decision record (Nygard). Evans's anticorruption layer, recorded.
42
+
43
+ ### Dependency record
44
+
45
+ - **Answers:** Outside dependencies justified, and Dependency without a record.
46
+ - **Must state:** The outside dependency; the native way weighed; why it fell short. For a peer dependency, the risk to whoever runs it.
47
+ - **Scope:** One direct outside dependency.
48
+ - **Stale or paid when:** Stale when the dependency is removed.
49
+ - **Industry name:** an architecture decision record (Nygard). An architecture decision record for each dependency.
50
+
51
+ ### Who may create each one without a person
52
+
53
+ Only the tool, and only debt, for findings the base revision already held ("record-debt", today). Every other kind is written by a person or an agent, and does the reasoning itself.
54
+
55
+ ### Merged into the kinds, or not a kind
56
+
57
+ - **Site-level record for one symptom:** merged. Every kind names a symptom, not a whole clause, so a record can say "this symptom, here".
58
+ - **Conformist:** merged into Boundary record. It is a decision about one outside party's model crossing a boundary.
59
+ - **Drift record:** merged into Authorised location, on the symptom Edit inside vendored code. Its case: "justified as additional drift as impossible to apply as an extension instead". It states when it should be dropped.
60
+ - **Inline suppression:** not a kind. It is where a record shows at the site. An inline disable or a tool directive is held only by a record of its symptom at that site.
61
+ - **Tracked pointer:** not a record. It is an allowed annotation.
62
+ - **Safety opt-in:** outside the cases. It is not in this model.
63
+ - **Clause-wide carve-out:** not a record. A rule a codebase does not want everywhere is not adopted: "Yes opting out means this codebase is not beholden to the rule flat out. Which is any tech leads choice to make for a codebase."
64
+
65
+ ## What is not a record
66
+
67
+ - **Scope.** "Exclude is any codebases choice to say this is not in scope. It's never bound by any rules."
68
+ - **Adopter config:** layer folders, casing, test-file naming and folder-scoped conventions. Hone does not read these as config yet. "A simple manifest of top level folders is config. Not hand kept manifest." A folder setting never switches a rule off.
69
+ - **A threshold.** "Line and complexity are symptoms that flag many things." Where a symptom fires is a check setting.
70
+ - **A named ban.** "Lodash is banned. Personal rule." No record makes it correct. Existing use is still held as debt, like any symptom: "All rules have to allow the checks to be debt. As existing repos need the opportunity to adopt and improve. Debt is debt. Not blockers."
71
+ - **A tracked pointer.** A TODO is tracked when it holds a reference to an issue or spec, in the form the adopter's config declares for its tracker (`#42`, `owner/repo#42`, `PROJ-7`), and nothing else. It is a pointer, not an explanation. A TODO beside a breach does not hold the breach: the breach still needs a record of its own.
72
+
73
+ ## What is refused
74
+
75
+ A record must contain what its kind states. Anything less is refused, as follows.
76
+
77
+ | Refused | Why | Does Hone refuse it from the form today? |
78
+ |---|---|---|
79
+ | A why that only restates the symptom ("needed here", "the check flags this") | the why-chain's purpose: "to ensure an agent has thought deeply about what its doing" | Partly, as today: the why-chain checks refuse stock restatements and answers with no new cause. A reworded restatement is left to review. |
80
+ | A thought-through record that names no case, or a case not in the [case list](cases.md) | a thought-through use names its case | Not yet enforced. In the model a machine refuses a missing or unknown case name; whether the case is true is left to review. |
81
+ | An authorised location on a symptom that no case makes correct, such as a branch in a test | "who the heck added an authorised location for an if in a test?" | No. In spirit it is not allowed, and a reviewer refuses it. The form accepts it for any symptom, because a check is never assumed perfect: "while authorised location in spirit isn't supposed to be allowed. It's mechanically always allowed as our checks for symptoms is never assumed perfect." |
82
+ | A deviation that only shows another method works | "The proof of burden is on the deviation to show that the reason it was chosen no longer holds." | Not yet enforced. In the model the form must name the recipe and use its reason's words; whether the reason fails here is left to review. |
83
+ | A fake with no showing that a stub cannot do the test | "Moving a fake is only allowed if the test cannot be done with deterministic stubs or hardcoded things." | No; review. |
84
+ | A deviation or a dependency record that makes a named ban correct. Debt is not refused; nor, by the form, is an authorised location, which answers a check that is wrong at that place. | "Lodash is banned." and "Debt is debt. Not blockers." | Not yet enforced. |
85
+ | Debt written by the tool for a file the base did not hold | today's `new-file` | Yes, as today. |
86
+ | A record standing in for a design fix, where friction points at the design | "if we have such a complex test that needs exemption we have a code architecture problem" | No; review. A machine can show records clustering on one symptom or one cause. Only review rules on it. |
87
+ | An option that weakens the whole run (`--rule`, `-c`) | today | Yes, as today: it cannot be recorded. |
88
+
89
+ This is a list of what each record must contain. It is not a ladder of exceptions.
90
+
91
+ ## The cost side
92
+
93
+ **What holds today:**
94
+ - An authorised location costs a five-step why-chain with a root check and an owner.
95
+ - Debt is visible in every report, fails the run when it forfeits on touch, and fails when stale.
96
+ - An unrecorded inline disable fails the run.
97
+ - The diff of the records is the review.
98
+ - Hotfixes do not block on debt: forfeiture can be assessed elsewhere ("blocking a hot fix on debt is not suitable practice").
99
+
100
+ **What the model adds:**
101
+ - A thought-through record names its case and the rule owed. It no longer answers only "why this file".
102
+ - A deviation must engage the recipe's own reason.
103
+ - Records are per symptom, so a record cannot quietly hold a new form of a clause, and paying one symptom is visible.
104
+ - Records are counted per symptom and cause. That makes friction measurable ("Always look for what friction is trying to tell us"), without a new step.
105
+
106
+ **What an agent gets when it cannot fix:** two honest exits, debt (visible, and it forfeits) or a thought-through record (it costs the reasoning). Neither is "give up and ask": "telling agents to give up and ask me has in experience made them just never even try and increased my workload".
107
+
108
+ ## Which kind answers which symptom
109
+
110
+ | Symptom | Kind |
111
+ |---|---|
112
+ | Date used directly (clock adapter) | Boundary record |
113
+ | Ambient randomness | Boundary record |
114
+ | Process global used in place | Boundary record |
115
+ | Outside import past a boundary | Boundary record |
116
+ | Library class built in place | Boundary record |
117
+ | Text past its reader, in the producer's adapter | Boundary record |
118
+ | Text past its reader, at one test site | Authorised location |
119
+ | Schema past its adapter (outside model adopted as ours) | Boundary record, with a Conformist statement |
120
+ | Claimed type forced by an outside contract | Authorised location |
121
+ | Untyped value | Debt |
122
+ | Throw between our units | Authorised location ("Throwing in specific places allowed is just authorised locations as prose.") |
123
+ | Loop keyword, draining a stream | Authorised location |
124
+ | Double with a body (a fake) | Deviation from Stub with vi.fn |
125
+ | Unit without a running test | Debt |
126
+ | Shorthand name, Name off its casing (outside contract) | Authorised location |
127
+ | Edit inside vendored code | Authorised location (drift) |
128
+
129
+ | Method | Kind |
130
+ |---|---|
131
+ | A fake | Deviation from Stub with vi.fn |
132
+ | A hermetic setup in an integration test | Not a record: it is the recipe |
133
+ | A real file, subprocess or temp directory in a unit test | Debt. It breaks Tested where it's owned, which is a rule, not a recipe. |
134
+ | A stream drain | Authorised location |
135
+ | A throw at the edge | Authorised location |
136
+ | Any other method in place of a recipe | Deviation |
137
+
138
+ ## Today's formats and the kinds
139
+
140
+ Records today are written in these formats. Each answers one of the kinds.
141
+
142
+ | Today | Kind | What differs from the kind |
143
+ |---|---|---|
144
+ | `authorised-location` (clause, file, reason, whyChain) | Authorised location, or Boundary record for sites of Outside import past a boundary | Names a clause, not a symptom. The site is a file. It does not name the case and the rule owed. |
145
+ | `file-carve-out` (clause, file, optional reason) | Debt | Names a clause, not a symptom. One record on the test-logic clause covers up to four symptoms. |
146
+ | `clause-wide-carve-out` | Not a record: the clause is not adopted | It sits in the records, not the selection. |
147
+ | `provenance` (imported) | The same kind, imported | Nothing. |
148
+ | Legacy why-chains | The kind of the record that holds them | Accepted while unchanged against the base. |
149
+ | Inline disables and `@ts-*` directives | Held by a record of their symptom | The record names the clause, not the symptom. |
150
+ | — | Deviation, Dependency record | No format yet. |
package/rules/rules.md ADDED
@@ -0,0 +1,149 @@
1
+ # Rules
2
+
3
+ A rule states what must hold. It carries no exceptions. A rule's id is its name, hyphenated.
4
+
5
+ Each rule passes two tests: it names no language feature, and the other rules together do not already give it. Where a rule only restated its principle, it was dropped and the principle decides. The room for a correct exception is a [record](records.md), never softness in the text.
6
+
7
+ ## Tests are ours
8
+
9
+ ### Written-out answers
10
+
11
+ - **What must hold:** Every collaborator whose result the code under test uses is passed in; the test writes out each result it gives back, and checks what the code returns and every call it makes.
12
+ - **Cases served:** Uses what a collaborator gives back; Causes an effect.
13
+ - **Source:** Meszaros calls this Literal Value: the test states its inputs and answers in place.
14
+
15
+ ### Straight-through tests
16
+
17
+ - **What must hold:** A test runs straight through: each case is distinct and complete, its input and expected output are written out in it as typed values, nothing in the test builds or picks them, nothing in it branches or catches, and no code of ours runs but the code under test.
18
+ - **Cases served:** States what the unit gives back; Checks a value that may be one of several outcomes.
19
+ - **Source:** Meszaros names branching in a test Conditional Test Logic; this rule removes it.
20
+
21
+ ### Tested where it's owned
22
+
23
+ - **What must hold:** Every unit has a running test of its own in the file beside it, and no coverage figure stands in for it. Each behaviour is tested only at the level that owns it: a unit's logic in its own test, a binding to the outside in an integration test.
24
+ - **Cases served:** Gives each unit its test; Tests across units or against a real system.
25
+ - **Source:** This is Fowler's narrow integration test; Freeman and Pryce warn against mocks at boundary objects.
26
+
27
+ Both halves answer one reason to change, which test owns a behaviour, so it stays one rule written as two sentences. A test that inherits nothing from the machine is the principle's own must-hold, so it is a case, not a rule.
28
+
29
+ ## One place decides
30
+
31
+ ### Doer or orchestrator
32
+
33
+ - **What must hold:** An orchestrator only calls our own units, on one value or on each of several, and passes each result on, a failed one returned unchanged. A doer calls, or hands to anything that calls, no unit of ours but an adapter, reached through a port passed in.
34
+ - **Cases served:** Coordinates other units; Does one job.
35
+ - **Source:** This is Westphal's Integration Operation Segregation Principle.
36
+
37
+ ### Handed what it uses
38
+
39
+ - **What must hold:** A unit is handed only what it uses: a port holds only the methods its one consumer calls; a doer takes only the fields it reads, or the entity whose module it is in; an orchestrator may pass an entity whole.
40
+ - **Cases served:** Does one job; Gives a value its type.
41
+ - **Source:** This is dependency injection, as Fowler describes it, serving Martin's DIP.
42
+
43
+ ### Guard first
44
+
45
+ - **What must hold:** Conditions sit at one level, never one inside another, and each condition that ends the work returns at once, before the work.
46
+ - **Cases served:** Checks conditions before its work.
47
+ - **Source:** Fowler's guard-clause refactoring, made the required shape.
48
+
49
+ ### One reason per module
50
+
51
+ - **What must hold:** A module holds exactly the code that changes for one reason.
52
+ - **Cases served:** Puts code in a file or folder; Reuses behaviour from another unit or type.
53
+ - **Source:** This is Martin's Single Responsibility Principle: one reason to change.
54
+
55
+ Building every real implementation in one place at start-up is a case: Doer or orchestrator plus Ports declared inside give it. DRY is held here: "dry is true but it must be held with reasons to change not "same functional code right now"".
56
+
57
+ ## No hidden effects
58
+
59
+ No rule. The principle decides. State that changes between calls lives only in an adapter: No hidden effects plus External behaviour sits at a boundary give it, so it is a case.
60
+
61
+ ## External behaviour sits at a boundary
62
+
63
+ Outside dependency: what was called a package. An internal package is our own code, under One reason per module and the layering.
64
+
65
+ ### Outside dependencies stay at boundaries
66
+
67
+ - **What must hold:** Production code uses an outside dependency only inside a recorded boundary, and no type from an outside dependency or a runtime library appears in business logic.
68
+ - **Cases served:** Uses a system or service outside the program; Takes an outside dependency.
69
+ - **Source:** Freeman and Pryce wrap outside types thinly; this rule does so for every outside dependency.
70
+
71
+ ### Ports declared inside
72
+
73
+ - **What must hold:** Business logic declares every port it is handed and names it for the capability it needs, never for the mechanism behind it.
74
+ - **Cases served:** Uses a system or service outside the program; Causes an effect.
75
+ - **Source:** Martin's DIP: the abstraction belongs to the side that uses it.
76
+
77
+ The clock, random values, new ids and outside ordering are a case: the principle plus Ports declared inside give it. An outside dependency is not wrapped: it is used inside the boundary that needs it.
78
+
79
+ ## No leak across a boundary
80
+
81
+ No rule. The principle, now covering data and failures, plus One reason per module, gives one adapter per outside party that maps both ways. That is a case.
82
+
83
+ ## The type checker proves it
84
+
85
+ ### Failures are values
86
+
87
+ - **What must hold:** Between units of ours, every way an operation can fail is a named variant in its return type, and no failure is returned as a success, a default or an empty value.
88
+ - **Cases served:** An operation can fail.
89
+ - **Source:** Wlaschin's expected failures as values; Clean Code teaches exceptions instead.
90
+
91
+ ### Declared, not asserted
92
+
93
+ - **What must hold:** A value's type comes only from a declaration of our own, never derived from an implementation, or from a parse at a boundary; no code of ours claims a type the checker does not verify.
94
+ - **Cases served:** Gives a value its type.
95
+ - **Source:** King's parse, don't validate.
96
+
97
+ ### Kinds are named
98
+
99
+ - **What must hold:** A value of several kinds or states is a closed set of named kinds of our own, and wherever code chooses by kind, the checker proves every kind is chosen.
100
+ - **Cases served:** A value is one of several kinds or states.
101
+ - **Source:** Minsky's named variants.
102
+
103
+ "Of ours" matters in Declared, not asserted: a test framework's assertion that narrows a value is not a claim of ours. The strictest checker setting is a case; the principle gives it.
104
+
105
+ ## Our code reads in the common language
106
+
107
+ ### One word everywhere
108
+
109
+ - **What must hold:** Every value, unit, field and module is named with the domain's one word for what it is, spelt the same everywhere and at every scope; no meaning rests on position, and our code carries no prose, not even prose that repeats the code.
110
+ - **Cases served:** Names something; Explains something in prose.
111
+ - **Source:** Evans's ubiquitous language, across the whole codebase.
112
+
113
+ One word everywhere keeps "no meaning rests on position". A unit whose signature is ours takes one argument; a callback shaped by an outside API takes what that API passes.
114
+
115
+ Casing is a check under this rule. Writing basic logic in the language's own constructs is a case; the principle gives it.
116
+
117
+ ## Outside risk is carried on purpose
118
+
119
+ ### Outside dependencies justified
120
+
121
+ - **What must hold:** Every direct dependency, tools included, has a record that names the native way it was weighed against and why that way was not enough.
122
+ - **Cases served:** Takes an outside dependency.
123
+ - **Source:** Ours: a written reason for every outside dependency.
124
+
125
+ ### Fixed versions
126
+
127
+ - **What must hold:** Every version we run is fixed exactly in the repository, by a pin or a lock file.
128
+ - **Cases served:** Takes an outside dependency.
129
+ - **Source:** OpenSSF Scorecard pins dependencies against supply-chain compromise.
130
+
131
+ ### Tools live in the repo
132
+
133
+ - **What must hold:** Every tool we run is a dependency of the repository; none is fetched when it runs.
134
+ - **Cases served:** Takes an outside dependency.
135
+ - **Source:** Twelve-Factor: no reliance on system-wide tools.
136
+
137
+ ### Upstream stays untouched
138
+
139
+ - **What must hold:** Vendored outside code is never edited; our change sits in an extension of ours outside it.
140
+ - **Cases served:** Takes an outside dependency.
141
+ - **Source:** Martin's Open-Closed Principle, applied to code we do not own.
142
+
143
+ ### Shipped risk declared
144
+
145
+ Proposed, not accepted.
146
+
147
+ - **Proposed wording:** "Every outside dependency we ship is declared to whoever runs it, never hidden inside our build."
148
+ - **Case it would serve:** [Ships code for others](cases.md#proposed-cases) (proposed): what we ship is visible to an adopter's scanner.
149
+ - **Source:** The NTIA SBOM: a formal record of what we ship.
@@ -0,0 +1,142 @@
1
+ # Sources
2
+
3
+ Each row names one source, the claim it makes, and how the item relates to it.
4
+
5
+ Relations:
6
+ - **SAME**: the source says what the item says.
7
+ - **STRICTER**: the item demands more than the source, and the row says where.
8
+ - **NARROWER**: the item covers less ground than the source.
9
+ - **WIDER**: the item covers more ground than the source.
10
+ - **CONFLICTS**: the source teaches the opposite.
11
+ - **NO SOURCE**: the item is ours, with no industry source behind it.
12
+
13
+ A CONFLICTS source sits beside an item's main source, never in place of it. Stricter rows are intended: "my rules are stricter than most because leaving any trade off or judgement based calls to llm leads to the easiest option locally".
14
+
15
+ ## Principles
16
+
17
+ | Item | Source and its claim | Relation |
18
+ |---|---|---|
19
+ | [Tests are ours](principles.md#tests-are-ours) | Freeman, Pryce, Mackinnon, Walnes, "Mock Roles, not Objects", OOPSLA 2004, §4.1: do not mock types you do not own; wrap them thinly. [jmock.org/oopsla2004.pdf](http://www.jmock.org/oopsla2004.pdf) | SAME |
20
+ | [One place decides](principles.md#one-place-decides) | Parnas, "On the Criteria…", CACM 15(12), 1972: each module hides one design decision likely to change. Martin, [SRP (2014)](https://blog.cleancoder.com/uncle-bob/2014/05/08/SingleReponsibilityPrinciple.html): "Gather together the things that change for the same reasons." | SAME |
21
+ | [No hidden effects](principles.md#no-hidden-effects) | Bernhardt, [Functional Core, Imperative Shell](https://www.destroyallsoftware.com/screencasts/catalog/functional-core-imperative-shell); Seemann, [Impureim sandwich (2020)](https://blog.ploeh.dk/2020/03/02/impureim-sandwich/): pure decisions sit between effects that are kept apart. | SAME |
22
+ | [External behaviour sits at a boundary](principles.md#external-behaviour-sits-at-a-boundary) | Cockburn, [Hexagonal Architecture](https://alistair.cockburn.us/hexagonal-architecture/): the application talks to the outside only through ports, with an adapter per outside party. Martin, [The Clean Architecture (2012)](https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html): source dependencies point only inwards. | SAME |
23
+ | [No leak across a boundary](principles.md#no-leak-across-a-boundary) | Evans, [Getting Started with DDD When Surrounded by Legacy Systems (2013)](https://domainlanguage.com/wp-content/uploads/2016/04/GettingStartedWithDDDWhenSurroundedByLegacySystemsV1.pdf): an anticorruption layer's interface is "entirely in terms of the downstream model". | STRICTER: Evans speaks of data coming in; ours also covers failures, in both directions |
24
+ | [The type checker proves it](principles.md#the-type-checker-proves-it) | Minsky, [Effective ML Revisited](https://blog.janestreet.com/effective-ml-revisited/): make illegal states unrepresentable. King, [Parse, don't validate (2019)](https://lexi-lambda.github.io/blog/2019/11/05/parse-don-t-validate/). | SAME |
25
+ | [Our code reads in the common language](principles.md#our-code-reads-in-the-common-language) | Fowler, [UbiquitousLanguage](https://martinfowler.com/bliki/UbiquitousLanguage.html), after Evans: one shared vocabulary used by developers, domain experts and the code. | WIDER: Evans keeps one language per bounded context ([BoundedContext](https://martinfowler.com/bliki/BoundedContext.html)); ours holds across the whole codebase |
26
+ | [Outside risk is carried on purpose](principles.md#outside-risk-is-carried-on-purpose) | [Twelve-Factor II, Dependencies](https://12factor.net/dependencies): declare and isolate every dependency. [OpenSSF Scorecard, Pinned-Dependencies](https://github.com/ossf/scorecard/blob/main/docs/checks.md). [NTIA SBOM minimum elements (2021)](https://www.ntia.gov/report/2021/minimum-elements-software-bill-materials-sbom). | SAME, made from three sources |
27
+
28
+ ## Rules
29
+
30
+ | Item | Source and its claim | Relation |
31
+ |---|---|---|
32
+ | [Written-out answers](rules.md#written-out-answers) | Meszaros, *xUnit Test Patterns* (2007), [Literal Value](http://xunitpatterns.com/Literal%20Value.html): "Use literal constants for object attributes and assertions." | SAME (conflict: Khorikov, below) |
33
+ | [Straight-through tests](rules.md#straight-through-tests) | Meszaros, [Conditional Test Logic](http://xunitpatterns.com/Conditional%20Test%20Logic.html): branches and loops in a test are a smell. | SAME (conflict: Meszaros's Test Utility Method, below) |
34
+ | [Tested where it's owned](rules.md#tested-where-its-owned) | Fowler, [IntegrationTest](https://martinfowler.com/bliki/IntegrationTest.html): a narrow integration test exercises only our code that talks to a separate service. GOOS 2004 §4.5: do not use mocks to test boundary objects. | SAME |
35
+ | [Doer or orchestrator](rules.md#doer-or-orchestrator) | Westphal, [Radical Object-Orientation #06](https://radicalobjectorientation.substack.com/p/radical-object-orientation-06-intelligent): "operation and integration must be strictly separated" (the IOSP). | SAME (conflict: Ousterhout, below) |
36
+ | [Handed what it uses](rules.md#handed-what-it-uses) | Fowler, [Inversion of Control Containers and the DI pattern (2004)](https://martinfowler.com/articles/injection.html); Martin, DIP, *C++ Report* 1996: both sides depend on abstractions. | SAME |
37
+ | [Guard first](rules.md#guard-first) | Fowler, [Replace Nested Conditional with Guard Clauses](https://refactoring.com/catalog/replaceNestedConditionalWithGuardClauses.html). | STRICTER: a refactoring you may choose becomes a requirement |
38
+ | [One reason per module](rules.md#one-reason-per-module) | Martin, [SRP (2014)](https://blog.cleancoder.com/uncle-bob/2014/05/08/SingleReponsibilityPrinciple.html): one reason to change, and "This principle is about people." | SAME |
39
+ | [Outside dependencies stay at boundaries](rules.md#outside-dependencies-stay-at-boundaries) | GOOS 2004 §4.1: do not mock runtime or library types; "write thin wrappers". Cockburn: an adapter per outside party. | STRICTER: every outside dependency is wrapped, not only those a test would mock |
40
+ | [Ports declared inside](rules.md#ports-declared-inside) | Martin, DIP 1996: "Abstractions should not depend upon details." Martin 2012: the use case calls an interface "in the inner circle". | SAME |
41
+ | [Failures are values](rules.md#failures-are-values) | Wlaschin, [Against Railway-Oriented Programming](https://fsharpforfunandprofit.com/posts/against-railway-oriented-programming/): expected domain failures are values. | SAME (conflict: Clean Code, below) |
42
+ | [Declared, not asserted](rules.md#declared-not-asserted) | King 2019: parse into a type that proves the check, instead of validating and discarding. | SAME |
43
+ | [Kinds are named](rules.md#kinds-are-named) | Minsky: variants named in the type; Wlaschin, [single-case unions](https://fsharpforfunandprofit.com/posts/designing-with-types-single-case-dus/). | SAME (conflict: OCP and Replace Conditional with Polymorphism, below) |
44
+ | [One word everywhere](rules.md#one-word-everywhere) | Fowler, UbiquitousLanguage (Evans). | STRICTER: one word across the codebase, not per bounded context |
45
+ | [Outside dependencies justified](rules.md#outside-dependencies-justified) | Nearest parallel: Nygard, [Documenting Architecture Decisions (2011)](https://www.cognitect.com/blog/2011/11/15/documenting-architecture-decisions). No source requires a written reason for each dependency. | NO SOURCE |
46
+ | [Fixed versions](rules.md#fixed-versions) | OpenSSF Scorecard, Pinned-Dependencies: "explicitly set to a specific hash instead of allowing a mutable version or range". | SAME (Scorecard goes further, to hashes) |
47
+ | [Tools live in the repo](rules.md#tools-live-in-the-repo) | Twelve-Factor II: "never relies on implicit existence of system-wide packages"; vendor any needed tools. | SAME |
48
+ | [Upstream stays untouched](rules.md#upstream-stays-untouched) | Martin, [OCP (2014)](https://blog.cleancoder.com/uncle-bob/2014/05/12/TheOpenClosedPrinciple.html): open for extension, closed for modification. | NARROWER: OCP covers all modules; this rule covers outside code |
49
+ | [Shipped risk declared](rules.md#shipped-risk-declared) (proposed) | NTIA SBOM: "a formal record containing the details and supply chain relationships of various components". | SAME |
50
+
51
+ ## Recipes
52
+
53
+ | Item | Source and its claim | Relation |
54
+ |---|---|---|
55
+ | [Stub with vi.fn](typescript/recipes.md#stub-with-vifn) | Meszaros, [Test Stub](http://xunitpatterns.com/Test%20Stub.html). Martin, [The Little Mocker (2014)](https://blog.cleancoder.com/uncle-bob/2014/05/14/TheLittleMocker.html). GOOS §4.6: "Mock objects are still stubs"; adding behaviour signals misplaced responsibility. | SAME |
56
+ | [Ports in the argument](typescript/recipes.md#ports-in-the-argument) | Fowler 2004, DI article (constructor injection); Seemann, [Pure DI (2014)](https://blog.ploeh.dk/2014/06/10/pure-di/). | NARROWER: one of Fowler's three injection forms |
57
+ | [it.each over typed rows](typescript/recipes.md#iteach-over-typed-rows) | Meszaros, [Parameterized Test](http://xunitpatterns.com/Parameterized%20Test.html). | STRICTER: rows typed and hard-coded |
58
+ | [Assert to narrow](typescript/recipes.md#assert-to-narrow) | Meszaros, [Guard Assertion](http://xunitpatterns.com/Guard%20Assertion.html): "Replace an if statement in a test with an assertion…" | SAME |
59
+ | [Whole written-out expectation](typescript/recipes.md#whole-written-out-expectation) | Meszaros, Literal Value. | SAME |
60
+ | [Failure asserted as a value](typescript/recipes.md#failure-asserted-as-a-value) | Follows from Failures are values. No test-pattern name found. | NO SOURCE |
61
+ | [Companion test file](typescript/recipes.md#companion-test-file) | Go [`testing`](https://pkg.go.dev/testing): test files are named with `_test.go` beside the package. | SAME (parallel) |
62
+ | [Integration test suffix](typescript/recipes.md#integration-test-suffix) | Maven Failsafe [default includes](https://maven.apache.org/surefire/maven-failsafe-plugin/examples/inclusion-exclusion.html): `**/*IT.java`, `**/IT*.java`, `**/*ITCase.java`. | SAME (parallel) |
63
+ | [Integration test owns its scratch](typescript/recipes.md#integration-test-owns-its-scratch) | Meszaros, [Fresh Fixture](http://xunitpatterns.com/Fresh%20Fixture.html): avoids Erratic Test. | SAME |
64
+ | [Composed orchestrator](typescript/recipes.md#composed-orchestrator) | Westphal IOSP: an integration only calls other functions. | SAME |
65
+ | [Functional iteration](typescript/recipes.md#functional-iteration) | Fowler, [Collection Pipeline](https://martinfowler.com/articles/collection-pipeline/); [Replace Loop with Pipeline](https://refactoring.com/catalog/replaceLoopWithPipeline.html). | SAME |
66
+ | [One argument object](typescript/recipes.md#one-argument-object) | Fowler, [Introduce Parameter Object](https://refactoring.com/catalog/introduceParameterObject.html). | STRICTER: always one object; "for agents the goal is always 1" |
67
+ | [Narrow ports](typescript/recipes.md#narrow-ports) | Fowler, [RoleInterface](https://martinfowler.com/bliki/RoleInterface.html): defined by one interaction between supplier and consumer. | SAME |
68
+ | [Entity module](typescript/recipes.md#entity-module) | Fowler, [EvansClassification](https://martinfowler.com/bliki/EvansClassification.html): an entity has "a distinct identity that runs through time". | NARROWER: one module per entity is a placement Evans does not prescribe |
69
+ | [Guard clauses](typescript/recipes.md#guard-clauses) | Fowler, Replace Nested Conditional with Guard Clauses. | SAME |
70
+ | [Screaming folders](typescript/recipes.md#screaming-folders) | Martin, [Screaming Architecture (2011)](https://blog.cleancoder.com/uncle-bob/2011/09/30/Screaming-Architecture.html): the top-level structure names the use cases, not the framework. | SAME |
71
+ | [Copy, never write in](typescript/recipes.md#copy-never-write-in) | Fowler, [ValueObject](https://martinfowler.com/bliki/ValueObject.html): value objects should be immutable. | SAME |
72
+ | [Closure factory](typescript/recipes.md#closure-factory) | Crockford, [Private Members in JavaScript](https://www.crockford.com/javascript/private.html): privileged methods over closure state. | SAME (conflict: Evans's mutable entities) |
73
+ | [Adapter per outside party](typescript/recipes.md#adapter-per-outside-party) | Cockburn, Hexagonal Architecture. | SAME |
74
+ | [Port in the domain](typescript/recipes.md#port-in-the-domain) | Martin DIP 1996; Martin 2012: the output port sits in the inner circle, implemented outside. Evans 2013: ACL-backed repository. | SAME on ownership |
75
+ | [World values through a port](typescript/recipes.md#world-values-through-a-port) | Seemann, [Volatile Dependencies](https://learn.microsoft.com/en-us/archive/blogs/ploeh/volatile-dependencies): time and randomness are volatile and go behind an abstraction. | STRICTER: Seemann exempts stable dependencies; ours does not |
76
+ | [Composition root](typescript/recipes.md#composition-root) | Seemann, [Composition Root (2011)](https://blog.ploeh.dk/2011/07/28/CompositionRoot/). | SAME |
77
+ | [Zod at the producer's adapter](typescript/recipes.md#zod-at-the-producers-adapter) | King 2019; Evans 2013: "ideally the translator should just translate". | SAME |
78
+ | [Map out at the adapter](typescript/recipes.md#map-out-at-the-adapter) | Evans 2013, ACL. | SAME |
79
+ | [Failure mapping at the adapter](typescript/recipes.md#failure-mapping-at-the-adapter) | Evans 2013, ACL. | STRICTER: the ACL is applied to failures too |
80
+ | [Result union](typescript/recipes.md#result-union) | Wlaschin, Against ROP. | SAME |
81
+ | [Named, exported type](typescript/recipes.md#named-exported-type) | No source found. | NO SOURCE |
82
+ | [Fix the declaration, not the value](typescript/recipes.md#fix-the-declaration-not-the-value) | No source found; nearest is King 2019. | NO SOURCE |
83
+ | [Bounded context generic](typescript/recipes.md#bounded-context-generic) | No source found. | NO SOURCE |
84
+ | [Shared strict base config](typescript/recipes.md#shared-strict-base-config) | No source found; a tool feature, not a named practice. | NO SOURCE |
85
+ | [Tagged union and exhaustive switch](typescript/recipes.md#tagged-union-and-exhaustive-switch) | TypeScript Handbook, [Narrowing: exhaustiveness checking](https://www.typescriptlang.org/docs/handbook/2/narrowing.html): a `default` branch assigns to `never`. | STRICTER: this recipe has no `default` branch |
86
+ | [Domain vocabulary list](typescript/recipes.md#domain-vocabulary-list) | Fowler, UbiquitousLanguage. | SAME |
87
+ | [Whole words](typescript/recipes.md#whole-words) | Google, [TypeScript Style Guide](https://google.github.io/styleguide/tsguide.html): names "must be descriptive and clear to a new reader". | STRICTER: Google allows short names in scopes of 10 lines or fewer |
88
+ | [Meaning in names, not comments](typescript/recipes.md#meaning-in-names-not-comments) | Martin, *Clean Code* 2nd ed. (2025) contents: ch. 5 Comments keeps a "Good Comments" section. | STRICTER than Martin (conflict: Ousterhout, below) |
89
+ | [Dependency record](typescript/recipes.md#dependency-record) | Nygard 2011, ADR. | SAME |
90
+ | [Exact pins and a lock file](typescript/recipes.md#exact-pins-and-a-lock-file) | OpenSSF Scorecard, Pinned-Dependencies. | SAME |
91
+ | [Repo scripts only](typescript/recipes.md#repo-scripts-only) | Twelve-Factor II. | SAME |
92
+ | [Extension outside the vendored code](typescript/recipes.md#extension-outside-the-vendored-code) | Martin, OCP 2014. | SAME |
93
+ | [Declared, not bundled](typescript/recipes.md#declared-not-bundled) (proposed) | Twelve-Factor II: declare dependencies explicitly. | SAME |
94
+
95
+ ## Record kinds
96
+
97
+ | Item | Source and its claim | Relation |
98
+ |---|---|---|
99
+ | [Authorised location](records.md#authorised-location) | Microsoft, [SuppressMessageAttribute.Justification](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.codeanalysis.suppressmessageattribute.justification): "the justification for suppressing the code analysis message". | SAME |
100
+ | [Deviation](records.md#deviation) | EASA, [FAQ 19026](https://www.easa.europa.eu/en/faq/19026): an alternative means of compliance must show it meets "the intent of the IR". | STRICTER: a deviation must show the recipe's reason fails at this site; meeting the rule another way is not enough |
101
+ | [Debt](records.md#debt) | ESLint, [bulk suppressions](https://eslint.org/docs/latest/use/suppressions): existing violations "will not be reported", new ones are. Martin, [The Boy Scout Rule](https://github.com/97-things/97-things-every-programmer-should-know/blob/master/en/thing_08/README.md): leave it "a little bit better". | STRICTER: touching the file forfeits the whole file's debt |
102
+ | [Boundary record](records.md#boundary-record) | Evans 2013: an ACL presents a clean interface in the downstream model; the ACL-backed repository. | SAME |
103
+ | [Dependency record](records.md#dependency-record) | Nygard 2011; NTIA SBOM. | SAME |
104
+
105
+ ## The model
106
+
107
+ | Item | Source and its claim | Relation |
108
+ |---|---|---|
109
+ | Rule with its reasoning and its check | [C++ Core Guidelines](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines): each rule has reason, example, alternative, exception and enforcement; "programmers find it hard to follow rules they don't understand". | STRICTER: our rules carry no exception clause; departures are records |
110
+ | Recipe as acceptable means of compliance | EASA [AMC FAQ](https://www.easa.europa.eu/en/faq/19026): AMC are non-binding, one way to comply. | STRICTER: the burden falls on the deviation to show the recipe's reason no longer holds |
111
+ | Symptom | Fowler, [CodeSmell](https://martinfowler.com/bliki/CodeSmell.html): "a surface indication that usually corresponds to a deeper problem". | SAME |
112
+ | Check | Thoughtworks Radar, [Architectural fitness function](https://www.thoughtworks.com/radar/techniques/architectural-fitness-function): "provides an objective integrity assessment of some architectural characteristics". | SAME |
113
+ | Case | Fowler, [Writing Software Patterns](https://martinfowler.com/articles/writingPatterns.html): the Coplien form has "Problem, Context, Forces, and Solution". | SAME |
114
+ | Record | Nygard 2011, ADR; MISRA deviation records. | SAME |
115
+ | Cross-language rules with a language layer | [SEI CERT coding standards](https://cmu-sei.github.io/secure-coding-standards/sei-cert-c-coding-standard/front-matter/introduction/how-this-coding-standard-is-organized): per-language standards, each with noncompliant and compliant examples. | SAME (parallel) |
116
+ | Two addresses per finding | No source found. | NO SOURCE |
117
+ | The chain: symptom, case, why, reason to change | No source found. Pieces only: smell to deeper problem (Fowler); problem and context (pattern form). | NO SOURCE |
118
+
119
+ ## Conflicts stated openly
120
+
121
+ | Topic | Item | The source's teaching | Our position |
122
+ |---|---|---|---|
123
+ | Classical against mockist testing | [Written-out answers](rules.md#written-out-answers) | Khorikov, [When to mock](https://enterprisecraftsmanship.com/posts/when-to-mock/): "Only unmanaged dependencies should be replaced with mocks"; use real collaborators inside. | "Stubbing most critical aspect is pure unit tests. Following the principle of failure is as fragile as the unit alone." |
124
+ | Small functions | [Doer or orchestrator](rules.md#doer-or-orchestrator) | Ousterhout, [APOSD vs Clean Code](https://github.com/johnousterhout/aposd-vs-clean-code): splitting "makes the code harder to understand". | "Functions with no outside influence should take 1… for agents the goal is always 1." |
125
+ | Comments | [Meaning in names, not comments](typescript/recipes.md#meaning-in-names-not-comments) | Ousterhout (same debate): comments "add enormous value". Martin: "I'm not hostile to comments in general." | "Good comments in my opinion or an escape hatch for poor choices almost always. And in AI world a default mess." |
126
+ | Exceptions | [Failures are values](rules.md#failures-are-values) | *Clean Code* 2nd ed. ch. 8: "Prefer Exceptions to Returning Error Codes". | "It potentially a js quirk more than a complete rule. As throwing is a mess of classes and type obscuring and control flow strangeness." |
127
+ | Polymorphism over switch | [Kinds are named](rules.md#kinds-are-named) | Fowler, Replace Conditional with Polymorphism; Martin, OCP. | "polymorphism implies object oriented. Without it and with js you get piles of shotgun validation and nested complexity." |
128
+ | Test helpers | [Straight-through tests](rules.md#straight-through-tests) | Meszaros, [Test Utility Method](http://xunitpatterns.com/Test%20Utility%20Method.html): reduces test duplication. | "test "helpers" are a problem overall as a concept" |
129
+
130
+ ## Unexplored concepts
131
+
132
+ None of these is closed off.
133
+
134
+ - **Aggregates** ([Fowler](https://martinfowler.com/bliki/DDD_Aggregate.html)): would extend One reason per module and Entity module, adding a consistency boundary.
135
+ - **Bounded contexts and context maps**: would extend No leak across a boundary and One word everywhere, scoping the language per context.
136
+ - **Open-Closed**: would extend Upstream stays untouched to our own modules.
137
+ - **Liskov substitution**: would extend Ports declared inside, so any adapter honours the port's contract.
138
+ - **Tell, Don't Ask** ([Fowler](https://martinfowler.com/bliki/TellDontAsk.html)): would extend Doer or orchestrator.
139
+ - **The use-case ring**: would extend External behaviour sits at a boundary, adding a layer between the domain and the adapters.
140
+ - **Walking skeleton** (GOOS): would extend Tests are ours, with an end-to-end slice first.
141
+ - **Humble Object** ([Meszaros](http://xunitpatterns.com/Humble%20Object.html)): would extend Tested where it's owned, keeping the untestable shell thin.
142
+ - **Domain events**: would extend No hidden effects, making a change an explicit value.