@hailstails/hone 1.4.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 (121) hide show
  1. package/ADOPTING.md +8 -8
  2. package/CHANGELOG.md +14 -0
  3. package/MIGRATING.md +17 -0
  4. package/README.md +10 -10
  5. package/api/testing.js +2 -2
  6. package/chunks/{chunk-FEWCJU7H.js → chunk-2O46EB4E.js} +6 -0
  7. package/chunks/{chunk-6SM3HKWO.js → chunk-5U4VTFD5.js} +88 -51
  8. package/core/check/tool-command.js +379 -56
  9. package/core/mechanism-port/runner-result-types.d.ts +4 -0
  10. package/docs/adding-a-discipline-or-mechanism.md +2 -0
  11. package/docs/extending.md +1 -0
  12. package/docs/output-contract.md +17 -6
  13. package/mechanisms/audit/CD-27/test-body-logic.js +5 -2
  14. package/mechanisms/audit/runner/runner.js +5 -3
  15. package/mechanisms/eslint/runner/runner.js +7 -3
  16. package/methods/assessment-template.md +2 -2
  17. package/methods/lenses/clean-architecture.md +7 -8
  18. package/methods/lenses/defended-on-intent.md +2 -2
  19. package/methods/lenses/di-discipline.md +10 -13
  20. package/methods/lenses/function-first.md +16 -18
  21. package/package.json +1 -1
  22. package/rules/CD-1/CHECKS.md +4 -2
  23. package/rules/CD-1/README.md +6 -19
  24. package/rules/CD-10/CHECKS.md +5 -3
  25. package/rules/CD-10/README.md +6 -18
  26. package/rules/CD-11/CHECKS.md +4 -2
  27. package/rules/CD-11/README.md +6 -16
  28. package/rules/CD-12/CHECKS.md +4 -2
  29. package/rules/CD-12/README.md +6 -16
  30. package/rules/CD-13/CHECKS.md +4 -2
  31. package/rules/CD-13/README.md +6 -16
  32. package/rules/CD-14/CHECKS.md +3 -1
  33. package/rules/CD-14/README.md +6 -19
  34. package/rules/CD-15/CHECKS.md +3 -1
  35. package/rules/CD-15/README.md +5 -20
  36. package/rules/CD-16/CHECKS.md +3 -1
  37. package/rules/CD-16/README.md +6 -6
  38. package/rules/CD-17/CHECKS.md +3 -1
  39. package/rules/CD-17/README.md +6 -19
  40. package/rules/CD-18/CHECKS.md +4 -2
  41. package/rules/CD-18/README.md +6 -16
  42. package/rules/CD-19/CHECKS.md +8 -6
  43. package/rules/CD-19/README.md +6 -20
  44. package/rules/CD-2/CHECKS.md +5 -3
  45. package/rules/CD-2/README.md +6 -21
  46. package/rules/CD-20/CHECKS.md +3 -1
  47. package/rules/CD-20/README.md +6 -6
  48. package/rules/CD-21/CHECKS.md +4 -2
  49. package/rules/CD-21/README.md +6 -15
  50. package/rules/CD-22/CHECKS.md +4 -2
  51. package/rules/CD-22/README.md +6 -15
  52. package/rules/CD-23/CHECKS.md +5 -3
  53. package/rules/CD-23/README.md +6 -17
  54. package/rules/CD-24/CHECKS.md +3 -1
  55. package/rules/CD-24/README.md +6 -6
  56. package/rules/CD-25/CHECKS.md +3 -1
  57. package/rules/CD-25/README.md +5 -21
  58. package/rules/CD-26/CHECKS.md +5 -3
  59. package/rules/CD-26/README.md +6 -20
  60. package/rules/CD-27/CHECKS.md +16 -7
  61. package/rules/CD-27/README.md +6 -20
  62. package/rules/CD-28/CHECKS.md +4 -2
  63. package/rules/CD-28/README.md +6 -16
  64. package/rules/CD-29/CHECKS.md +4 -2
  65. package/rules/CD-29/README.md +6 -14
  66. package/rules/CD-3/CHECKS.md +3 -1
  67. package/rules/CD-3/README.md +6 -17
  68. package/rules/CD-30/CHECKS.md +4 -2
  69. package/rules/CD-30/README.md +6 -15
  70. package/rules/CD-31/CHECKS.md +4 -2
  71. package/rules/CD-31/README.md +6 -14
  72. package/rules/CD-32/CHECKS.md +3 -1
  73. package/rules/CD-32/README.md +2 -0
  74. package/rules/CD-33/CHECKS.md +3 -1
  75. package/rules/CD-33/README.md +2 -0
  76. package/rules/CD-34/CHECKS.md +3 -1
  77. package/rules/CD-34/README.md +2 -0
  78. package/rules/CD-39/CHECKS.md +3 -1
  79. package/rules/CD-39/README.md +2 -0
  80. package/rules/CD-4/CHECKS.md +4 -2
  81. package/rules/CD-4/README.md +6 -17
  82. package/rules/CD-40/CHECKS.md +3 -1
  83. package/rules/CD-40/README.md +6 -20
  84. package/rules/CD-41/CHECKS.md +4 -2
  85. package/rules/CD-41/README.md +6 -22
  86. package/rules/CD-42/CHECKS.md +3 -1
  87. package/rules/CD-42/README.md +6 -16
  88. package/rules/CD-43/CHECKS.md +3 -1
  89. package/rules/CD-43/README.md +6 -18
  90. package/rules/CD-44/CHECKS.md +3 -1
  91. package/rules/CD-44/README.md +6 -17
  92. package/rules/CD-45/CHECKS.md +4 -2
  93. package/rules/CD-45/README.md +6 -16
  94. package/rules/CD-46/CHECKS.md +3 -1
  95. package/rules/CD-46/README.md +2 -0
  96. package/rules/CD-47/CHECKS.md +4 -2
  97. package/rules/CD-47/README.md +4 -20
  98. package/rules/CD-5/CHECKS.md +4 -2
  99. package/rules/CD-5/README.md +6 -19
  100. package/rules/CD-6/CHECKS.md +3 -1
  101. package/rules/CD-6/README.md +6 -19
  102. package/rules/CD-7/CHECKS.md +3 -1
  103. package/rules/CD-7/README.md +6 -20
  104. package/rules/CD-7a/CHECKS.md +3 -1
  105. package/rules/CD-7a/README.md +6 -17
  106. package/rules/CD-8/CHECKS.md +3 -1
  107. package/rules/CD-8/README.md +6 -17
  108. package/rules/CD-9/CHECKS.md +4 -2
  109. package/rules/CD-9/README.md +6 -17
  110. package/rules/README.md +71 -54
  111. package/rules/SPIRIT.md +3 -3
  112. package/rules/cases.md +94 -0
  113. package/rules/numbers.md +155 -0
  114. package/rules/principles.md +89 -0
  115. package/rules/records.md +150 -0
  116. package/rules/rules.md +149 -0
  117. package/rules/sources.md +142 -0
  118. package/rules/typescript/checks.md +219 -0
  119. package/rules/typescript/recipes.md +361 -0
  120. package/rules/typescript/symptoms.json +1005 -0
  121. package/rules/typescript/symptoms.md +612 -0
@@ -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.
@@ -0,0 +1,219 @@
1
+ # Checks in TypeScript
2
+
3
+ A check is how a [symptom](symptoms.md) is found. It is imperfect by design. "We aim for a check to find that. But we assess ways to narrow the margin of error and start with the 80/20 rule and reuse what we have where it is sufficient for first cut of mechanical ways to check what we are looking for."
4
+
5
+ So the symptom states exactly what is seen; a check aims at it and states its margin: what it flags that is not the symptom, and what it misses. An existing check that is sufficient for a first cut is reused.
6
+
7
+ Correct use at an authorised location is never margin: "it flagging the one allowed location is not a fault. It's what authorised locations are for".
8
+
9
+ Today's checks are addressed by clause. [Every CD](../numbers.md#every-mechanical-clause) gives the symptom each mechanical clause sees.
10
+
11
+ Outside dependency: what was called a package. An internal package is our own code. Telling an outside dependency from an internal package needs the workspace layout, which is files and config Hone can read.
12
+
13
+ **Columns.**
14
+ - **Reports:** *seen* (where the symptom is), or *seen → breach* (it could also name the breach, given what follows the arrow).
15
+ - **Needs:** syntax, types, graph (imports between files), app (the app's structure), files (config, names, build output), history, person.
16
+ - **Today:**
17
+ - *reuse:* a clause is enough for a first cut.
18
+ - *partial:* a clause sees part of the symptom.
19
+ - *review:* only a review clause covers it today.
20
+ - *new:* nothing covers it today.
21
+ - **Margin:** what it flags that is not the symptom / what it misses. "Review owes" names what only a person sees.
22
+ - **Settings traced to:** each threshold or setting, and the rule or recipe sentence behind it. *Nothing* means no sentence says so.
23
+
24
+ ## The outside world reached directly
25
+
26
+ | Check for | Reports | Needs | Today | Margin | Settings traced to |
27
+ |---|---|---|---|---|---|
28
+ | Date used directly | seen | syntax | reuse | `Date.now` in comments and strings / `performance.now()` | none |
29
+ | Ambient randomness | seen | syntax | new | — / — | none |
30
+ | Process global used in place | seen | syntax | review | — / — | none |
31
+ | Outside import past a boundary | seen | graph | partial | — / `import()`, `require`, globals | `confinedPackages`, empty by default on purpose: the universe of outside dependencies cannot be listed, and flagging every import would catch internal packages. Telling outside from internal needs the workspace layout, which Hone can read. |
32
+ | Outside type in a signature | seen → breach (the adapter that returns it, by types) | types | new | — / — | none |
33
+ | Library class built in place | seen | types | review | — / — | none |
34
+
35
+ ## Text and schemas past their reader
36
+
37
+ | Check for | Reports | Needs | Today | Margin | Settings traced to |
38
+ |---|---|---|---|---|---|
39
+ | Text past its reader | seen → breach (the port that carries text, by types) | syntax; boundary records | partial (tests only) | — / production sites | the edition: **nothing** |
40
+ | Schema past its adapter | seen | graph; boundary records | review | — / — | none |
41
+
42
+ ## Claimed or loose types
43
+
44
+ | Check for | Reports | Needs | Today | Margin | Settings traced to |
45
+ |---|---|---|---|---|---|
46
+ | Claimed type | seen → breach (the declaration, by types) | syntax | reuse | — / `any` reached through an outside dependency's types | `as const` allowed: Declared, not asserted |
47
+ | Untyped value | seen | syntax | reuse | — / — | none |
48
+ | Own type guard | seen | syntax | new | — / — | none |
49
+ | Type derived from code | seen | syntax | reuse | text in comments / `Parameters<typeof>`, `typeof` alone | none |
50
+ | Strictness weakened | seen | files | reuse (edition 2) | edition 1: a flag set to `true` / edition 1: a base reached by `extends` | flag list: The type checker proves it. Edition 1 flags presence, which is the Shared strict base config recipe: **traced to a recipe, not a rule** |
51
+ | Default on a closed union | seen | types | reuse | a `switch` over an open set / — | none |
52
+ | Boolean in a signature | seen | syntax | reuse | a predicate's boolean return / — | none |
53
+ | Absence standing for a state | — | person | only review | review owes it | — |
54
+ | Default for a required value | seen | types | review | — / — | none |
55
+
56
+ ## Failures
57
+
58
+ | Check for | Reports | Needs | Today | Margin | Settings traced to |
59
+ |---|---|---|---|---|---|
60
+ | Throw between our units | seen | syntax; boundary records | review | — / — | authorised locations: "Throwing in specific places allowed is just authorised locations as prose" |
61
+ | Thrown non-error | seen | syntax | reuse | — / — | none |
62
+ | Failure shaped as success | — | person; syntax for a `catch` that returns | only review | review owes it | — |
63
+ | Catch-all failure kind | seen | types | new | — / — | none |
64
+
65
+ ## Effects and state
66
+
67
+ | Check for | Reports | Needs | Today | Margin | Settings traced to |
68
+ |---|---|---|---|---|---|
69
+ | Loop keyword | seen | syntax | reuse | — / — | none |
70
+ | Write into a parameter | seen | syntax | reuse | — / — | none |
71
+ | Rebinding | seen | syntax | reuse | — / a local `let` in production | none |
72
+ | Authored class or this | seen | syntax | reuse | — / `this` outside a class | none |
73
+ | Module-level state | seen | syntax | new | — / — | none |
74
+
75
+ ## Unit shape
76
+
77
+ | Check for | Reports | Needs | Today | Margin | Settings traced to |
78
+ |---|---|---|---|---|---|
79
+ | Long function | seen | syntax | reuse | — / — | 50 lines: where a broad symptom fires. "Line and complexity are symptoms that flag many things." Suite bodies not measured: "A test suite's body is a list of cases, not a coordinator." |
80
+ | Tangled function | seen | syntax | reuse | — / — | complexity 15: where a broad symptom fires (as above) |
81
+ | Work inside a condition | seen | syntax | partial | — / an `if` nested with no `else` | none |
82
+ | Orchestrator that computes | seen | types, graph | review | — / — | none |
83
+ | Doer calling our own unit | seen | types, graph | new | — / — | none |
84
+ | Positional parameters | seen | syntax for inline callbacks (passed straight to a call); types or the symbol graph for named ones | partial | — / our own functions with exactly two parameters | `max: 2`: a recorded compromise of the check, which cannot tell the two kinds apart. "Positional parameters is 2 because it flags functions designed to be used in native APIs even inline unnamed ones for things like map/reduce. Making 1 untenable."; "The check is not right. Its unable to distinguish." |
85
+ | Tuple as data | seen | syntax, types | new | — / — | none |
86
+ | Wide input | seen → breach (the input's declaration) | types | new | — / — | none |
87
+ | Wide port | seen → breach (the port) | types, graph | new | — / — | none |
88
+
89
+ ## Layers and wiring
90
+
91
+ | Check for | Reports | Needs | Today | Margin | Settings traced to |
92
+ |---|---|---|---|---|---|
93
+ | Inner layer imports outer | seen | app (folder-to-layer config), graph | review | — / — | which folder is which layer: the adopter's top-level folder config |
94
+ | Port outside the domain | seen | graph, types | review | — / — | none |
95
+ | Adapter built outside the root | seen | graph | review | — / — | which module is the root: nothing yet |
96
+ | Port named for a mechanism | — | person | only review | review owes it | — |
97
+
98
+ ## Tests
99
+
100
+ | Check for | Reports | Needs | Today | Margin | Settings traced to |
101
+ |---|---|---|---|---|---|
102
+ | Double with a body | seen → breach (the port it fills, by types) | syntax; types for hand-written doubles | reuse | — / hand-written doubles | test file is `.test.ts(x)`: Companion test file recipe |
103
+ | Module or global patched | seen → breach (the unit that imports the module, by graph) | syntax | partial | — / `vi.stubGlobal`, `process.env` set in a test | as above |
104
+ | Branch in a test | seen → breach (the type branched on, by types) | syntax | reuse | unit's own API (edition 1) / — | the edition: backwards compatibility for adopters since the npm release |
105
+ | Computed value in a test | seen | syntax | reuse | as above | as above |
106
+ | Throw or catch in a test | seen | syntax | reuse | — / `catch` | none |
107
+ | Unasserted call | seen | syntax, types | new | — / — | none |
108
+ | Answer set in a hook | seen | syntax | partial | — / an answer given by `mockReturnValue`, `mockResolvedValue` or `mockImplementation` in a hook | none |
109
+ | Test switched off | seen | syntax | reuse | — / `.todo` | `.todo` not flagged: a miss |
110
+ | Unit without a running test | seen | files, graph | reuse | — / an empty or non-running sibling | `__tests__` skipped by default, on purpose (noise; the practice is not adopted). `exclude` is scope. |
111
+ | Machine touched in a unit test | seen → breach (the unit with no port) | syntax; the suffix | new | — / — | integration test suffix: recipe ("keep pyramid checkable") |
112
+ | Inherited environment in a subprocess | seen | syntax, types | partial | — / `env` built from `process.env` under an accepted name | accepted helper names: **nothing**; `.spec`, `.js`, `.mjs` test files: **nothing** |
113
+ | Behaviour tested away from its owner | — | person; graph for candidates | only review | review owes it | — |
114
+ | Integration-heavy suite | seen | files (suffix) | review | — / — | the suffix: recipe |
115
+ | Coverage gate | seen | files | review | — / — | none |
116
+ | Large input for a few fields | — | person (the cast is Claimed type) | only review | review owes it | — |
117
+ | Test of the type checker | — | person | only review | review owes it | — |
118
+
119
+ ## Names, prose and files
120
+
121
+ | Check for | Reports | Needs | Today | Margin | Settings traced to |
122
+ |---|---|---|---|---|---|
123
+ | Shorthand name | seen | syntax | reuse | — / shorthand not on the list | shorthand and filler list: Whole words recipe |
124
+ | Name off its casing | seen | syntax, files | reuse | — / — | Hone's own casing option lists: **nothing**; casing is the adopter's own lint |
125
+ | Drawer path | seen | files | reuse | — / a drawer under an ordinary name | drawer names: Screaming folders recipe |
126
+ | Types-only file | seen | syntax | new | — / — | port declarations allowed: Entity module recipe |
127
+ | Prose in code | seen | syntax | new | — / — | tracked pointer form: [records](../records.md#what-is-not-a-record) |
128
+ | Untracked escape | seen | syntax | reuse | — / — | reference form "need a digit": **nothing** |
129
+ | Many spellings of one concept | seen | files (the vocabulary list) | new | — / — | the Domain vocabulary list recipe |
130
+ | Outside dependency vocabulary for basic logic | seen | graph; workspace layout | new | — / — | which outside dependencies: nothing yet |
131
+ | Duplicate decision | — | person; clones surface candidates | only review | review owes the ruling ("reasons to change") | — |
132
+ | Change spread across modules | seen | history | new | — / — | none |
133
+
134
+ ## Dependencies and versions
135
+
136
+ | Check for | Reports | Needs | Today | Margin | Settings traced to |
137
+ |---|---|---|---|---|---|
138
+ | Floating version | seen | files | new | — / — | Fixed versions |
139
+ | No lock file | seen | files | new | — / — | Fixed versions |
140
+ | Dependency without a record | seen | files; records | new | — / — | Outside dependencies justified |
141
+ | Tool fetched at run time | seen | files | new | — / — | Tools live in the repo |
142
+ | Edit inside vendored code | seen | history | new | — / — | which folder is vendored: a boundary record |
143
+ | Bundled dependency | seen | build output | new | — / — | Shipped risk declared (proposed, not accepted) |
144
+
145
+ ## Findings that point at the breach
146
+
147
+ Several symptoms are seen far from their breach. Each finding has two addresses:
148
+ - where the symptom is seen;
149
+ - the rule or rules the symptom indicates, with the place the breach usually sits.
150
+
151
+ | Symptom seen | Where it is seen | Where the breach usually sits | What a check needs to name the breach |
152
+ |---|---|---|---|
153
+ | Double with a body | the test | the port's width, or a collaborator with two decisions | types: the port the double fills, and its uncalled methods |
154
+ | Large input for a few fields | the test (often a cast) | the unit's declared input | types: the parameter's declaration and the fields read |
155
+ | Branch in a test | the test | the type of the value branched on | types: the declaring type of the member read |
156
+ | Text past its reader (in a test) | the test | the port that carries text | types: the port method the text is fed to |
157
+ | Module or global patched | the test | the unit that imports what it should be passed | graph: who imports the mocked module |
158
+ | Machine touched in a unit test | the test | the unit with no port | graph: what the unit imports |
159
+ | Date used directly | the unit | a doer doing two jobs | person |
160
+ | Claimed type | the cast | the declaration it works around | types |
161
+
162
+ Until a check can name the breach, a finding names the rules the symptom points at and where the breach usually sits. It never says only "this line".
163
+
164
+ ## Settings
165
+
166
+ A setting fails only if it changes what a rule requires. It does not fail when it:
167
+ - tunes how early a symptom fires: "Line and complexity are symptoms that flag many things.";
168
+ - is scope a codebase chose: "Exclude is any codebases choice to say this is not in scope. It's never bound by any rules."
169
+
170
+ A default that quietly narrows a rule, which no codebase chose, still fails.
171
+
172
+ **Settings that change what a rule requires today:**
173
+
174
+ | Setting | What it changes | Traced to |
175
+ |---|---|---|
176
+ | Strictness edition 1 flags a flag's presence | requires the recipe's layout, not strictness | a recipe, not a rule. "The older strictness check is probably just a flaw." |
177
+ | `.todo` not flagged | a test that does not run passes | a miss. "Todo not flagged is probably just a false negative." |
178
+ | Accepted helper names | The subprocess-environment check passes a git spawn when its `env:` option mentions one of three hard-coded identifiers: `hermeticGitEnvironment`, `withoutInheritedGitBindings` or `environment`. It matches the name, not what the value holds, so any variable called `environment` passes. | nothing; a margin of the check (it misses by name) |
179
+ | Casing fixed inside Hone | Today file names must be kebab-case or PascalCase, both allowed everywhere, hard-coded. Identifier casing is a fixed option list in Hone's own piece, built on typescript-eslint's naming-convention. The adopter declares neither. | nothing. "Casing should be config from adopter to declare for consistency but requires the folder nuance settings." |
180
+ | Tracked-reference form | which TODO counts as tracked | nothing yet |
181
+
182
+ **Settings that do not:**
183
+
184
+ | Setting | Why |
185
+ |---|---|
186
+ | 50-line limit, complexity 15 | where two broad symptoms fire; they change no rule |
187
+ | `max-params: 2` | a recorded compromise of the check; its miss is margin |
188
+ | `exclude` | scope chosen by the codebase |
189
+ | Edition defaults | "Edition defaults would be for backwards compatability since we went npm." An existing adopter keeps the behaviour it installed. |
190
+ | `confinedPackages` empty by default | "packages is empty because we can't define the universe and if we just said imports at all we would catch internal packages." Seeing every outside dependency needs a way to tell it from an internal package; until then the list is the adopter's to fill. |
191
+ | `__tests__` skipped by default | "probably because of noise level and the fact I don't adopt that folder practice deliberately at all." |
192
+ | `.spec.ts` not treated as a test file by most checks | "Spec is also just not a naming practice I use." Then: "It honestly should be config for user to declare file naming structure so we can match their conventions." Hone has no such config yet; the Companion test file and Integration test suffix recipes are the convention it reads. |
193
+ | Generated folders skipped (`node_modules`, `dist` and the like) | not code of ours |
194
+ | Reading `.test.js` and `.test.mjs` in the subprocess-environment check | it widens one check, not narrows a rule |
195
+ | Suite-body exemption | "A test suite's body is a list of cases, not a coordinator." |
196
+ | Drawer names | Screaming folders |
197
+ | Shorthand list | Whole words |
198
+ | `as const` | Declared, not asserted |
199
+ | Integration suffix | its recipe |
200
+
201
+ ## Folder-scoped settings
202
+
203
+ Hone has no folder-scoped settings yet. "glob or folder specific ruleset settings would be useful to smooth those" (React beside a Node server; GraphQL types generated in a boundary folder).
204
+
205
+ Checks whose convention can differ by folder in one repository:
206
+ - **Name off its casing.** Identifier and file-name conventions: a React folder's PascalCase components beside a Node server's kebab-case files.
207
+ - **Generated code at a boundary.** Checks that would read an outside generator's output as ours: Shorthand name, Name off its casing, Prose in code, Claimed type, Untyped value, Type derived from code, Unit without a running test.
208
+
209
+ What a folder-scoped setting does:
210
+ - It **smooths** a second convention, by choosing which convention a check measures a folder against.
211
+ - It **marks generated code** as an outside party's code at a boundary, under that boundary's record.
212
+
213
+ What it must not be able to do:
214
+ - **Switch a rule off for a folder.** That is a record: an authorised location with its why, or debt.
215
+ - **Change what a rule means.** For example, a looser line limit, a wider parameter count or a narrower test-file definition for a folder.
216
+
217
+ So a setting never deselects a clause and never carries debt.
218
+
219
+ `exclude` is different again. It is scope, outside the model. It needs no rule sentence and no record.