@mrciphersmith/keryx 0.4.29 → 0.4.31

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 (123) hide show
  1. package/dist/cli.js +2446 -1391
  2. package/dist/core.js +90 -27
  3. package/dist/keryx-general-worker-entry.js +82 -25
  4. package/package.json +1 -1
  5. package/src/gdskills/bundled/install-manifest.json +2 -0
  6. package/src/gdskills/bundled/rules/core/api-contracts.mdc +21 -136
  7. package/src/gdskills/bundled/rules/core/async-patterns.mdc +18 -171
  8. package/src/gdskills/bundled/rules/core/clean-architecture.mdc +21 -3
  9. package/src/gdskills/bundled/rules/core/cli-interface-design.mdc +63 -194
  10. package/src/gdskills/bundled/rules/core/code-style-patterns.mdc +36 -49
  11. package/src/gdskills/bundled/rules/core/concurrency-patterns.mdc +32 -0
  12. package/src/gdskills/bundled/rules/core/database-patterns.mdc +26 -148
  13. package/src/gdskills/bundled/rules/core/error-handling.mdc +7 -8
  14. package/src/gdskills/bundled/rules/core/frontend-assistant.mdc +14 -29
  15. package/src/gdskills/bundled/rules/core/layout-rendering.mdc +51 -0
  16. package/src/gdskills/bundled/rules/core/mobx-store-template.mdc +69 -511
  17. package/src/gdskills/bundled/rules/core/nestjs-dto.mdc +18 -36
  18. package/src/gdskills/bundled/rules/core/playwright-testing.mdc +35 -308
  19. package/src/gdskills/bundled/rules/core/security-baseline.mdc +18 -140
  20. package/src/gdskills/bundled/rules/core/solid-principles.mdc +31 -7
  21. package/src/gdskills/bundled/rules/core/storybook-guidelines.mdc +20 -22
  22. package/src/gdskills/bundled/rules/core/tdd-workflow.mdc +37 -74
  23. package/src/gdskills/bundled/rules/core/ui-anti-slop.mdc +48 -37
  24. package/src/gdskills/bundled/skills/quality/deprecation-path/SKILL.md +1 -1
  25. package/src/gdskills/bundled/skills/review/review-architecture/SKILL.md +24 -60
  26. package/src/gdskills/bundled/skills/review/review-backend/SKILL.md +13 -65
  27. package/src/gdskills/bundled/skills/review/review-clean-code/SKILL.md +22 -35
  28. package/src/gdskills/bundled/skills/review/review-frontend/SKILL.md +16 -309
  29. package/src/gdskills/bundled/skills/review/review-frontend-conventions/SKILL.md +7 -21
  30. package/src/gdskills/bundled/skills/review/review-highload/SKILL.md +83 -227
  31. package/src/gdskills/bundled/skills/review/review-layout/SKILL.md +22 -28
  32. package/src/gdskills/bundled/skills/review/review-logic/SKILL.md +8 -8
  33. package/src/gdskills/bundled/skills/review/review-performance/SKILL.md +15 -37
  34. package/src/gdskills/bundled/skills/review/review-security-code/SKILL.md +7 -7
  35. package/src/gdskills/bundled/skills/review/review-style/SKILL.md +31 -66
  36. package/src/gdskills/bundled/skills/review/review-testing-practices/SKILL.md +21 -39
  37. package/src/gdskills/bundled/skills/review/review-ui-ux/SKILL.md +42 -82
  38. package/src/gdskills/bundled/stacks/angular/rules/coding-style.mdc +15 -57
  39. package/src/gdskills/bundled/stacks/angular/rules/patterns.mdc +16 -60
  40. package/src/gdskills/bundled/stacks/angular/rules/security.mdc +11 -49
  41. package/src/gdskills/bundled/stacks/angular/rules/testing.mdc +13 -52
  42. package/src/gdskills/bundled/stacks/c-cpp/rules/coding-style.mdc +33 -57
  43. package/src/gdskills/bundled/stacks/c-cpp/rules/patterns.mdc +35 -62
  44. package/src/gdskills/bundled/stacks/c-cpp/rules/security.mdc +35 -62
  45. package/src/gdskills/bundled/stacks/c-cpp/rules/testing.mdc +34 -54
  46. package/src/gdskills/bundled/stacks/ci-github-gitlab/rules/patterns.mdc +27 -56
  47. package/src/gdskills/bundled/stacks/ci-github-gitlab/rules/security.mdc +51 -119
  48. package/src/gdskills/bundled/stacks/csharp-dotnet/rules/coding-style.mdc +42 -74
  49. package/src/gdskills/bundled/stacks/csharp-dotnet/rules/patterns.mdc +45 -84
  50. package/src/gdskills/bundled/stacks/csharp-dotnet/rules/security.mdc +34 -59
  51. package/src/gdskills/bundled/stacks/csharp-dotnet/rules/testing.mdc +33 -62
  52. package/src/gdskills/bundled/stacks/django/rules/coding-style.mdc +15 -56
  53. package/src/gdskills/bundled/stacks/django/rules/patterns.mdc +16 -68
  54. package/src/gdskills/bundled/stacks/django/rules/security.mdc +13 -71
  55. package/src/gdskills/bundled/stacks/django/rules/testing.mdc +16 -62
  56. package/src/gdskills/bundled/stacks/docker-k8s-terraform/rules/coding-style.mdc +30 -53
  57. package/src/gdskills/bundled/stacks/docker-k8s-terraform/rules/patterns.mdc +20 -56
  58. package/src/gdskills/bundled/stacks/docker-k8s-terraform/rules/security.mdc +52 -122
  59. package/src/gdskills/bundled/stacks/docker-k8s-terraform/rules/testing.mdc +23 -42
  60. package/src/gdskills/bundled/stacks/fastapi/rules/coding-style.mdc +13 -47
  61. package/src/gdskills/bundled/stacks/fastapi/rules/patterns.mdc +18 -81
  62. package/src/gdskills/bundled/stacks/fastapi/rules/security.mdc +13 -75
  63. package/src/gdskills/bundled/stacks/fastapi/rules/testing.mdc +14 -58
  64. package/src/gdskills/bundled/stacks/flutter-dart/rules/coding-style.mdc +36 -74
  65. package/src/gdskills/bundled/stacks/flutter-dart/rules/patterns.mdc +30 -66
  66. package/src/gdskills/bundled/stacks/flutter-dart/rules/security.mdc +33 -67
  67. package/src/gdskills/bundled/stacks/flutter-dart/rules/testing.mdc +41 -73
  68. package/src/gdskills/bundled/stacks/go/rules/coding-style.mdc +36 -57
  69. package/src/gdskills/bundled/stacks/go/rules/patterns.mdc +27 -42
  70. package/src/gdskills/bundled/stacks/go/rules/security.mdc +26 -43
  71. package/src/gdskills/bundled/stacks/go/rules/testing.mdc +23 -41
  72. package/src/gdskills/bundled/stacks/java-kotlin-spring/rules/coding-style.mdc +18 -37
  73. package/src/gdskills/bundled/stacks/java-kotlin-spring/rules/patterns.mdc +26 -43
  74. package/src/gdskills/bundled/stacks/java-kotlin-spring/rules/security.mdc +25 -37
  75. package/src/gdskills/bundled/stacks/java-kotlin-spring/rules/testing.mdc +34 -50
  76. package/src/gdskills/bundled/stacks/kotlin-android/rules/coding-style.mdc +28 -65
  77. package/src/gdskills/bundled/stacks/kotlin-android/rules/patterns.mdc +34 -78
  78. package/src/gdskills/bundled/stacks/kotlin-android/rules/security.mdc +35 -68
  79. package/src/gdskills/bundled/stacks/kotlin-android/rules/testing.mdc +34 -68
  80. package/src/gdskills/bundled/stacks/mobx/rules/coding-style.mdc +18 -64
  81. package/src/gdskills/bundled/stacks/mobx/rules/patterns.mdc +13 -66
  82. package/src/gdskills/bundled/stacks/mobx/rules/security.mdc +8 -35
  83. package/src/gdskills/bundled/stacks/mobx/rules/testing.mdc +10 -39
  84. package/src/gdskills/bundled/stacks/nestjs/rules/coding-style.mdc +32 -45
  85. package/src/gdskills/bundled/stacks/nestjs/rules/patterns.mdc +40 -60
  86. package/src/gdskills/bundled/stacks/nestjs/rules/security.mdc +30 -50
  87. package/src/gdskills/bundled/stacks/nestjs/rules/testing.mdc +27 -47
  88. package/src/gdskills/bundled/stacks/nextjs-nuxt/rules/coding-style.mdc +14 -48
  89. package/src/gdskills/bundled/stacks/nextjs-nuxt/rules/patterns.mdc +15 -67
  90. package/src/gdskills/bundled/stacks/nextjs-nuxt/rules/security.mdc +12 -50
  91. package/src/gdskills/bundled/stacks/nextjs-nuxt/rules/testing.mdc +11 -43
  92. package/src/gdskills/bundled/stacks/php-laravel/rules/coding-style.mdc +17 -58
  93. package/src/gdskills/bundled/stacks/php-laravel/rules/patterns.mdc +15 -56
  94. package/src/gdskills/bundled/stacks/php-laravel/rules/security.mdc +13 -50
  95. package/src/gdskills/bundled/stacks/php-laravel/rules/testing.mdc +14 -55
  96. package/src/gdskills/bundled/stacks/python/rules/coding-style.mdc +13 -41
  97. package/src/gdskills/bundled/stacks/python/rules/patterns.mdc +20 -61
  98. package/src/gdskills/bundled/stacks/python/rules/security.mdc +15 -57
  99. package/src/gdskills/bundled/stacks/python/rules/testing.mdc +16 -50
  100. package/src/gdskills/bundled/stacks/react/rules/coding-style.mdc +14 -40
  101. package/src/gdskills/bundled/stacks/react/rules/patterns.mdc +15 -55
  102. package/src/gdskills/bundled/stacks/react/rules/security.mdc +13 -49
  103. package/src/gdskills/bundled/stacks/react/rules/testing.mdc +10 -37
  104. package/src/gdskills/bundled/stacks/ruby-rails/rules/coding-style.mdc +12 -45
  105. package/src/gdskills/bundled/stacks/ruby-rails/rules/patterns.mdc +18 -67
  106. package/src/gdskills/bundled/stacks/ruby-rails/rules/security.mdc +11 -60
  107. package/src/gdskills/bundled/stacks/ruby-rails/rules/testing.mdc +14 -65
  108. package/src/gdskills/bundled/stacks/rust/rules/coding-style.mdc +39 -65
  109. package/src/gdskills/bundled/stacks/rust/rules/patterns.mdc +33 -60
  110. package/src/gdskills/bundled/stacks/rust/rules/security.mdc +35 -57
  111. package/src/gdskills/bundled/stacks/rust/rules/testing.mdc +29 -52
  112. package/src/gdskills/bundled/stacks/sql-db/rules/coding-style.mdc +12 -48
  113. package/src/gdskills/bundled/stacks/sql-db/rules/patterns.mdc +22 -113
  114. package/src/gdskills/bundled/stacks/sql-db/rules/security.mdc +11 -56
  115. package/src/gdskills/bundled/stacks/sql-db/rules/testing.mdc +14 -59
  116. package/src/gdskills/bundled/stacks/swift-ios/rules/coding-style.mdc +29 -65
  117. package/src/gdskills/bundled/stacks/swift-ios/rules/patterns.mdc +41 -88
  118. package/src/gdskills/bundled/stacks/swift-ios/rules/security.mdc +28 -53
  119. package/src/gdskills/bundled/stacks/swift-ios/rules/testing.mdc +32 -65
  120. package/src/gdskills/bundled/stacks/vue/rules/coding-style.mdc +17 -52
  121. package/src/gdskills/bundled/stacks/vue/rules/patterns.mdc +17 -63
  122. package/src/gdskills/bundled/stacks/vue/rules/security.mdc +11 -41
  123. package/src/gdskills/bundled/stacks/vue/rules/testing.mdc +16 -48
@@ -8,73 +8,49 @@ metadata:
8
8
  # C / C++ coding style
9
9
 
10
10
  Narrows `core-common-rules`' stack-agnostic style rules to modern C++
11
- (17/20/23) and modern C idiom. Applies to both `.c`/`.h` and
12
- `.cpp`/`.cc`/`.cxx`/`.hpp`/`.hxx` files — everything not C/C++-specific
13
- still comes from the common rules this file `extends`.
11
+ (17/20/23) and modern C idiom, following the C++ Core Guidelines. Applies to
12
+ both `.c`/`.h` and `.cpp`/`.cc`/`.cxx`/`.hpp`/`.hxx` files.
14
13
 
15
14
  ## Naming and structure
16
15
 
17
16
  - `snake_case` for functions, variables, and namespaces; `PascalCase` for
18
- types (classes, structs, enums); `SCREAMING_SNAKE_CASE` for macros and
19
- compile-time constants — match whichever convention the project already
20
- uses over this default when one is established.
21
- - Keep a header self-contained: `#pragma once` (or a project-consistent
22
- include guard) at the top, and every symbol the header uses actually
23
- `#include`d in it — do not rely on an include some other header happens
24
- to pull in transitively.
25
- - One translation unit's private helpers go in an anonymous namespace
26
- (C++) or are declared `static` (C) — do not give internal linkage away
27
- by leaving a file-local helper externally visible.
28
- - An identifier's name shrinks with its scope: a loop index is `i`, a
29
- header-exposed public function gets a full descriptive name.
17
+ types; `SCREAMING_SNAKE_CASE` for macros and compile-time constants; an
18
+ established project convention wins over this default.
19
+ - A header is self-contained: `#pragma once` (or a project-consistent include
20
+ guard) and every symbol it uses `#include`d, not pulled in transitively.
21
+ - A translation unit's private helpers go in an anonymous namespace (C++) or
22
+ are `static` (C).
30
23
 
31
24
  ## Modern C++ idiom (17/20/23)
32
25
 
33
- - Own a heap allocation with `std::unique_ptr` by default; reach for
34
- `std::shared_ptr` only when the ownership is genuinely shared (more than
35
- one owner can outlive any single other owner) — a `shared_ptr` used for
36
- single ownership just adds atomic refcount overhead and obscures who
37
- actually owns the object.
38
- - Prefer `std::make_unique`/`std::make_shared` over a bare `new` passed to
39
- a smart pointer constructor — it avoids a leak on an exception thrown
40
- between the `new` and the constructor call, and avoids a second
41
- allocation for `shared_ptr`'s control block.
42
- - Use `std::span` (C++20) for a non-owning view over a contiguous range
43
- instead of a raw `(pointer, length)` pair — it carries bounds
44
- information the raw pair does not, without owning or copying the data.
45
- - Move, don't copy, when a value's ownership is transferring: accept
46
- by-value and `std::move` into place, or take an rvalue-reference
47
- overload, rather than accepting `const&` and copying when the caller's
48
- object was about to be discarded anyway.
49
- - Prefer a range-`for` or a `<ranges>` (C++20) pipeline over a manual
50
- index loop or raw iterator pair when the loop is a plain traversal —
51
- keep the manual iterator form for cases that need the iterator itself
52
- (insertion position, mutation while iterating with an explicit
53
- erase-returns-next-iterator pattern).
54
- - `constexpr`/`consteval` any function or value that can be computed at
55
- compile time; `const` (or nothing, per project convention) otherwise —
56
- do not default to `#define` for a typed constant.
26
+ - `std::unique_ptr` by default; `std::shared_ptr` only for genuinely shared
27
+ ownership.
28
+ - `std::make_unique`/`std::make_shared` over a bare `new` passed to a smart
29
+ pointer constructor.
30
+ - `std::span` (C++20) for a non-owning view over a contiguous range instead
31
+ of a raw `(pointer, length)` pair.
32
+ - Move, don't copy, when ownership transfers: by-value plus `std::move`, or
33
+ an rvalue-reference overload.
34
+ - Range-`for` or `<ranges>` (C++20) over a manual index loop for plain
35
+ traversal; keep the manual iterator form where the iterator itself is
36
+ needed.
37
+ - `constexpr`/`consteval` for anything computable at compile time; no
38
+ `#define` for a typed constant.
57
39
 
58
40
  ## Modern C safety practices
59
41
 
60
- - Prefer a fixed-size or length-tracked buffer API (`snprintf`, not
61
- `sprintf`; `strncpy`/explicit length checks, not `strcpy`/`strcat`;
62
- `fgets`, never `gets`) — every string/buffer write states or checks its
63
- destination's capacity.
64
- - Check every `malloc`/`calloc`/`realloc` return for `NULL` before
65
- dereferencing it; on `realloc` failure, keep the original pointer (do
66
- not overwrite it with the `NULL` return and leak the original block).
67
- - Prefer C99 designated initializers and stack-based fixed arrays with an
68
- explicit, checked bound over a raw pointer with an implicit length
69
- carried only in a comment.
70
- - Const-qualify a pointer parameter the function does not mutate through
71
- (`const char *`, not `char *`) — it documents the contract and lets the
72
- compiler catch an accidental write.
42
+ - `snprintf`, not `sprintf`; `strncpy`/explicit length checks, not
43
+ `strcpy`/`strcat`; `fgets`, never `gets`; every buffer write states or
44
+ checks its destination's capacity.
45
+ - Check every `malloc`/`calloc`/`realloc` return for `NULL`; on `realloc`
46
+ failure keep the original pointer.
47
+ - C99 designated initializers and fixed arrays with an explicit, checked
48
+ bound over a raw pointer with a length carried in a comment.
49
+ - `const`-qualify a pointer parameter the function does not mutate through
50
+ (`const char *`).
73
51
 
74
52
  ## Formatting
75
53
 
76
- - Format with the project's configured `clang-format`/`.clang-format` if
77
- present; do not hand-format around a formatter that is already
78
- configured.
79
- - Braces and brace-placement follow the project's existing style over any
80
- default preference in this file — match neighboring code.
54
+ - Format with the project's `clang-format`/`.clang-format` if present; do
55
+ not hand-format around it.
56
+ - Brace placement follows the project's existing style.
@@ -8,80 +8,53 @@ metadata:
8
8
  # C / C++ patterns
9
9
 
10
10
  Narrows `core-common-rules`' stack-agnostic design guidance to idiomatic
11
- C/C++ ownership, resource management, and their common anti-patterns.
12
- Applies to both C and C++ files.
11
+ C/C++ ownership and resource management (C++ Core Guidelines). Applies to
12
+ both C and C++ files.
13
13
 
14
14
  ## RAII and ownership (C++)
15
15
 
16
- - Every resource (heap memory, a file handle, a mutex lock, a socket) is
17
- owned by exactly one object whose destructor releases it — a raw `new`
18
- with a matching `delete` written by hand somewhere else in the function
19
- is a bug waiting for an early return or an exception to skip the
20
- `delete`. Wrap it in a smart pointer, `std::lock_guard`/`std::unique_lock`,
21
- or another RAII type instead.
22
- - A class that manually manages a resource follows the Rule of
23
- Zero (own nothing directly — compose from types that already manage
24
- their own resources) or, when it must own a resource directly, the Rule
25
- of Five (copy ctor, copy assign, move ctor, move assign, destructor —
26
- define all five, or `= delete` the ones that should not exist).
27
- - A function that hands back a resource does so by return value (RVO/move
28
- makes this free), not by an out-parameter raw pointer the caller must
29
- remember to release.
30
- - Never return a pointer or reference to a local (stack) variable, or to a
31
- member of a temporary — the referent is destroyed when the function
32
- returns, and the caller is left with a dangling reference.
16
+ - Every resource (heap memory, file handle, mutex lock, socket) is owned by
17
+ exactly one object whose destructor releases it; no hand-written `new`/
18
+ `delete` pair. Use a smart pointer, `std::lock_guard`/`std::unique_lock`,
19
+ or another RAII type.
20
+ - Rule of Zero by default; when a class must own a resource directly, Rule
21
+ of Five (define all five special members, or `= delete` the unwanted
22
+ ones).
23
+ - Hand a resource back by return value, not by an out-parameter raw pointer.
24
+ - Never return a pointer or reference to a local variable or a member of a
25
+ temporary.
33
26
 
34
27
  ## Manual resource management (C)
35
28
 
36
- - Pair every `malloc`/`fopen`/`pthread_mutex_lock`-style acquire with a
37
- `free`/`fclose`/`pthread_mutex_unlock` on every exit path from the
38
- function that acquired it, error paths included — a `goto cleanup;`
39
- pattern with a single exit-and-release block is the idiomatic way to
40
- keep this from being repeated (and missed) at every early `return`.
41
- - A function that allocates and returns a pointer documents, in its
42
- header comment, who owns the result and how it must be released — an
43
- API with no stated ownership contract is a leak or a double-free
44
- waiting to happen at the call site.
45
- - Never call `free` on a pointer twice, and set a pointer to `NULL`
46
- immediately after freeing it when it could otherwise be read or freed
47
- again on a later path — a double-free and a use-after-free are both
48
- more likely once a stale non-null value survives past its `free`.
29
+ - Pair every `malloc`/`fopen`/`pthread_mutex_lock`-style acquire with its
30
+ release on every exit path, error paths included; use a `goto cleanup;`
31
+ single exit-and-release block.
32
+ - A function that allocates and returns a pointer documents in its header
33
+ comment who owns the result and how to release it.
34
+ - Never `free` a pointer twice; set a pointer to `NULL` right after freeing
35
+ it when it could be read or freed again on a later path.
49
36
 
50
37
  ## Containers and iterators
51
38
 
52
- - An iterator, pointer, or reference into a `std::vector` (or similar
53
- contiguous container) is invalidated by any operation that can
54
- reallocate or shift the underlying storage (`push_back` past capacity,
55
- `insert`, `erase`) — do not hold one across such a call; re-fetch it, or
56
- use the iterator `erase`/`insert` return to keep iterating correctly.
57
- - Prefer `std::vector`/`std::array`/`std::string` over a raw
58
- owning array or a hand-rolled dynamic buffer — the standard container
59
- already manages growth, bounds, and destruction correctly.
39
+ - Do not hold an iterator, pointer, or reference into a `std::vector` across
40
+ `push_back` past capacity, `insert`, or `erase`; re-fetch it or use the
41
+ iterator `erase`/`insert` return.
42
+ - `std::vector`/`std::array`/`std::string` over a raw owning array or
43
+ hand-rolled dynamic buffer.
60
44
 
61
45
  ## Composition and interfaces
62
46
 
63
- - Prefer composition over deep inheritance hierarchies; reach for
64
- polymorphism only when callers genuinely need to treat different
65
- concrete types uniformly through a shared interface, not as a default
66
- way to share code.
67
- - A C++ base class meant to be used polymorphically through a base
68
- pointer/reference has a `virtual` (or `= default`d, explicitly
69
- `virtual`) destructor — a non-virtual destructor on a polymorphic base
70
- is undefined behavior when deleting through the base pointer.
71
- - Keep a public C API's surface small and its ownership rules explicit in
72
- the header; do not expose an internal struct's full layout when an
73
- opaque handle plus accessor functions would let the implementation
74
- change without breaking callers.
47
+ - Composition over deep inheritance; polymorphism only when callers must
48
+ treat different concrete types uniformly.
49
+ - A polymorphic C++ base class has a `virtual` destructor.
50
+ - A public C API keeps its surface small with ownership rules explicit in the
51
+ header; prefer an opaque handle plus accessors over exposing a struct's
52
+ layout.
75
53
 
76
54
  ## Anti-patterns to flag
77
55
 
78
- - A "god header" with unrelated free functions and macros accumulating
79
- under a generic name (`utils.h`, `common.h`) — split by what the code
80
- actually does.
81
- - C-style casts (`(Type)x`) in C++ where a named cast
82
- (`static_cast`/`dynamic_cast`/`const_cast`/`reinterpret_cast`) would say
83
- which conversion is actually intended and let the compiler catch the
84
- wrong one.
85
- - Output parameters used to fake multiple return values where
86
- `std::tuple`/`std::pair`/a small struct (or, in C, a returned struct)
87
- would be clearer and harder to call incorrectly.
56
+ - A "god header" (`utils.h`, `common.h`).
57
+ - C-style casts (`(Type)x`) in C++; use `static_cast`/`dynamic_cast`/
58
+ `const_cast`/`reinterpret_cast`.
59
+ - Output parameters faking multiple return values where `std::tuple`/
60
+ `std::pair`/a small struct (in C, a returned struct) fits.
@@ -8,83 +8,56 @@ metadata:
8
8
  # C / C++ security
9
9
 
10
10
  Narrows `core-common-rules`' stack-agnostic security rules to C/C++
11
- memory-safety and undefined-behavior risks, and the sanitizers/safe APIs
12
- to use instead. Applies to both C and C++ files.
11
+ memory-safety and undefined-behavior risks, and the sanitizers/safe APIs to
12
+ use. Applies to both C and C++ files.
13
13
 
14
14
  ## Memory safety
15
15
 
16
- - Never dereference, write through, or `free` a pointer after it has been
17
- freed or has gone out of scope (use-after-free) — set a freed pointer
18
- to `NULL` when it could be read again, and never return a pointer or
19
- reference to a stack-local object.
20
- - Never `free`/`delete` the same pointer twice (double-free) — a
21
- freed-and-nulled pointer makes a second `free`/`delete` a harmless
22
- no-op instead of heap corruption.
16
+ - Never dereference, write through, or `free` a pointer after it was freed or
17
+ left scope (use-after-free); set a freed pointer to `NULL` when it could be
18
+ read again.
19
+ - Never `free`/`delete` the same pointer twice.
23
20
  - Bounds-check every array/buffer index and every pointer arithmetic
24
- expression built from untrusted input before it is used to read or
25
- write memory — an off-by-one or an unchecked length from user input is
26
- the most common route to a buffer overflow.
27
- - Never use `strcpy`, `strcat`, `sprintf`, or `gets` on data whose length
28
- is not already statically known to fit the destination — use
29
- `snprintf`, a length-checked copy, or a `std::string`/`std::vector`
30
- that manages its own capacity.
21
+ expression built from untrusted input before it reads or writes memory.
22
+ - Never `strcpy`, `strcat`, `sprintf`, or `gets` on data not statically known
23
+ to fit; use `snprintf`, a length-checked copy, or `std::string`/
24
+ `std::vector`.
31
25
 
32
26
  ## Undefined behavior
33
27
 
34
- - Signed integer overflow is undefined behavior in C/C++ (unlike
35
- unsigned wraparound, which is well-defined modular arithmetic) — check
36
- bounds before an addition/multiplication that could overflow a signed
37
- type, or use an unsigned/wider type, or a checked-arithmetic helper,
38
- for a bounds or size computation derived from untrusted input.
39
- - Never read an uninitialized local variable or heap allocation — value-
40
- initialize (`Type x{};` in C++, an explicit `= 0`/`memset` in C) any
41
- variable whose first use might be a read, and never rely on whatever
42
- value happened to be left on the stack or heap.
43
- - Never access an object through a pointer of an incompatible type (a
44
- strict-aliasing violation) — use `memcpy` for a type-punning copy, or
45
- (C++20+) `std::bit_cast`, instead of reinterpreting a pointer's type
46
- and dereferencing it.
47
- - Do not read past the end of an array via pointer arithmetic even when
48
- the read "usually" lands in valid memory — an out-of-bounds read past
49
- the last element is undefined behavior regardless of what happens to be
50
- mapped there.
28
+ - Signed integer overflow is UB (unsigned wraparound is not): check bounds
29
+ before a signed addition/multiplication, or use an unsigned/wider type or a
30
+ checked-arithmetic helper, for size computations from untrusted input.
31
+ - Never read an uninitialized local or heap allocation; value-initialize
32
+ (`Type x{};` in C++, `= 0`/`memset` in C).
33
+ - No strict-aliasing violations; use `memcpy`, or `std::bit_cast` (C++20+),
34
+ for type punning.
35
+ - No out-of-bounds read past the last element via pointer arithmetic.
51
36
 
52
37
  ## Concurrency
53
38
 
54
- - Every variable read from more than one thread while at least one thread
55
- writes it is guarded by a mutex, or is a `std::atomic`/C11 `_Atomic`
56
- type — an unsynchronized shared read/write is a data race, which is
57
- undefined behavior in both C and C++, not merely "occasionally wrong."
58
- - Acquire locks in a consistent global order across the codebase to avoid
59
- deadlock; prefer `std::lock_guard`/`std::scoped_lock` (which also
60
- supports locking multiple mutexes deadlock-free in one call) over
61
- manual `lock()`/`unlock()` pairs, since a manual pair skips the unlock
62
- on an early return or exception.
39
+ - Every variable read by more than one thread while one writes it is guarded
40
+ by a mutex or is `std::atomic`/C11 `_Atomic`.
41
+ - Acquire locks in a consistent global order; prefer `std::lock_guard`/
42
+ `std::scoped_lock` (the latter locks several mutexes deadlock-free) over
43
+ manual `lock()`/`unlock()` pairs.
63
44
 
64
45
  ## Sanitizers
65
46
 
66
47
  - Build and run with AddressSanitizer + UndefinedBehaviorSanitizer
67
48
  (`-fsanitize=address,undefined -fno-omit-frame-pointer -g`, Clang/GCC)
68
- whenever investigating a memory-safety or UB bug report, or before
69
- trusting a fix for one — ASan catches use-after-free, double-free,
70
- buffer overflow, and heap corruption at the exact faulting access; UBSan
71
- catches signed overflow, misaligned access, and other UB the compiler
72
- is otherwise free to miscompile around silently.
73
- - Build and run with ThreadSanitizer (`-fsanitize=thread`) — built as a
74
- separate binary from ASan/UBSan, the two runtimes are not composable in
75
- one build — whenever investigating a suspected data race or before
76
- trusting a fix for one.
77
- - A memory-safety, UB, or concurrency bug report is not actually verified
78
- fixed until it has been reproduced and re-run under the relevant
79
- sanitizer and comes back clean; a fix that only "looks right" by
80
- inspection, or that only passes without a sanitizer attached, has not
81
- been verified.
49
+ when investigating a memory-safety or UB report, or before trusting a fix
50
+ for one.
51
+ - Build and run with ThreadSanitizer (`-fsanitize=thread`) as a separate
52
+ binary from ASan/UBSan, since the runtimes are not composable, when
53
+ investigating a data race or before trusting a fix for one.
54
+ - A memory-safety, UB, or concurrency bug is not verified fixed until it is
55
+ reproduced and re-run clean under the relevant sanitizer.
82
56
 
83
57
  ## Dependency and input hygiene
84
58
 
85
- - Validate the length/format of any externally-sourced buffer (network,
86
- file, IPC, command-line argument) before parsing it — do not assume a
87
- length field in the input itself is trustworthy without a sanity check
88
- against the buffer's actual size.
89
- - Never hard-code a credential, API key, or signing secret in source;
90
- load it from environment/secret storage the project already uses.
59
+ - Validate the length/format of any externally-sourced buffer (network, file,
60
+ IPC, command-line argument) before parsing; check a length field in the
61
+ input against the buffer's actual size.
62
+ - No hard-coded credential, API key, or signing secret; load from the
63
+ environment/secret storage the project already uses.
@@ -7,77 +7,57 @@ metadata:
7
7
 
8
8
  # C / C++ testing
9
9
 
10
- Narrows `core-common-rules`' stack-agnostic testing rules to GoogleTest
11
- (and Catch2, where a project already uses it) plus sanitizer-backed
12
- verification. Applies to both C and C++ test files.
10
+ Narrows `core-common-rules`' stack-agnostic testing rules to GoogleTest (and
11
+ Catch2, where a project already uses it) plus sanitizer-backed verification.
12
+ Applies to both C and C++ test files.
13
13
 
14
14
  ## Layout and naming
15
15
 
16
- - Tests live under a project's own existing test tree (commonly
17
- `tests/`, `test/`, or beside the source with a `_test.cpp` suffix) —
18
- match whichever convention the project already uses, do not invent a
19
- second one.
20
- - `TEST(SuiteName, CaseName)` for a standalone case; `TEST_F(FixtureName,
21
- CaseName)` when the case needs shared `SetUp()`/`TearDown()` state via a
22
- fixture class derived from `::testing::Test`. Name suites/cases for the
23
- behavior under test, not `Test1`/`Test2`.
24
- - `TEST_P` with `INSTANTIATE_TEST_SUITE_P` for a parameterized case run
25
- against a range of inputs, instead of copy-pasting the same body with
26
- different literals across several `TEST`s.
16
+ - Tests live in the project's existing test tree (`tests/`, `test/`, or
17
+ beside the source with a `_test.cpp` suffix); do not invent a second
18
+ convention.
19
+ - `TEST(SuiteName, CaseName)` standalone; `TEST_F(FixtureName, CaseName)` for
20
+ shared `SetUp()`/`TearDown()` state. Name for the behavior, not
21
+ `Test1`/`Test2`.
22
+ - `TEST_P` with `INSTANTIATE_TEST_SUITE_P` for a case run against a range of
23
+ inputs.
27
24
 
28
25
  ## Fixtures and lifecycle
29
26
 
30
- - Put shared per-test setup in `SetUp()` and teardown in `TearDown()`,
31
- not the fixture's constructor/destructor, when the setup can fail in a
32
- way the test should assert on (`SetUp()` runs inside the test's own
33
- assertion context; a constructor failure does not).
34
- - A fixture that owns a resource (a temp file, a mock server, a thread)
35
- releases it in `TearDown()` even when the test body fails an assertion
36
- partway through — do not rely on a `TEST_F` body reaching a cleanup
37
- statement at its end.
27
+ - Per-test setup that can fail in `SetUp()`, teardown in `TearDown()`, not
28
+ the fixture's constructor/destructor.
29
+ - A fixture owning a resource (temp file, mock server, thread) releases it in
30
+ `TearDown()` even when the body fails partway.
38
31
 
39
32
  ## Assertions
40
33
 
41
- - `ASSERT_*` when the test cannot meaningfully continue after a failure
42
- (a null pointer that every following line would dereference);
43
- `EXPECT_*` when later checks in the same test still give useful
44
- information after one fails.
45
- - `ASSERT_DEATH`/`EXPECT_DEATH` for code whose contract is to terminate
46
- the process on a given input (an assertion failure, a `CHECK`) — set
47
- `GTEST_FLAG_SET(death_test_style, "threadsafe")` (or the project's own
48
- configured style) when the test binary is multi-threaded, since the
49
- default `fast` style can misbehave by forking a process with more than
50
- one live thread.
51
- - Compare floating-point values with `EXPECT_NEAR`/`EXPECT_FLOAT_EQ`, not
52
- `EXPECT_EQ`, unless the value is provably exact (an integer-valued
53
- computation stored in a float).
34
+ - `ASSERT_*` when the test cannot continue after a failure; `EXPECT_*` when
35
+ later checks still give information.
36
+ - `ASSERT_DEATH`/`EXPECT_DEATH` for code whose contract is to terminate; set
37
+ `GTEST_FLAG_SET(death_test_style, "threadsafe")` (or the project's style)
38
+ when the binary is multi-threaded.
39
+ - `EXPECT_NEAR`/`EXPECT_FLOAT_EQ` for floating point, not `EXPECT_EQ`, unless
40
+ the value is provably exact.
54
41
 
55
42
  ## Determinism and concurrency
56
43
 
57
44
  - Never synchronize a multi-threaded test with `sleep`/`usleep`/
58
- `std::this_thread::sleep_for` to "give the other thread time" — join
59
- the thread, wait on a condition variable, or use a future/promise so
60
- the test is deterministic and not flaky under load.
61
- - A test exercising concurrent code is run under ThreadSanitizer
62
- (`-fsanitize=thread`) at least once before being trusted, since a data
63
- race can pass every assertion while still being undefined behavior.
45
+ `std::this_thread::sleep_for`; join, wait on a condition variable, or use a
46
+ future/promise.
47
+ - A test of concurrent code is run under ThreadSanitizer
48
+ (`-fsanitize=thread`) at least once.
64
49
 
65
50
  ## Sanitizer-backed verification
66
51
 
67
- - Build and run the test suite under AddressSanitizer + UndefinedBehavior-
68
- Sanitizer for any change touching manual memory management, buffers, or
69
- pointer arithmetic — a leaking or corrupting test can still report
70
- green under plain assertions while ASan/UBSan catch the actual bug.
52
+ - Run the suite under AddressSanitizer + UndefinedBehaviorSanitizer for any
53
+ change touching manual memory management, buffers, or pointer arithmetic.
71
54
  - New behavior gets a new test in the same change; a bug fix (especially
72
- a memory-safety or UB fix) gets a regression test that reproduces the
73
- failure under the relevant sanitizer before the fix and passes clean
74
- after it.
55
+ memory-safety or UB) gets a regression test that reproduces the failure
56
+ under the relevant sanitizer before the fix and passes clean after.
75
57
 
76
58
  ## Fuzzing
77
59
 
78
- - A parser, decoder, or anything else that touches untrusted input
79
- formats gets a libFuzzer harness (`LLVMFuzzerTestOneInput`, built with
80
- `-fsanitize=fuzzer,address,undefined`) when the project already has
81
- fuzzing infrastructure, or a documented seed corpus ready for one to be
82
- added — do not skip fuzz coverage for a new untrusted-input parser
83
- solely because unit tests pass.
60
+ - A parser or decoder of untrusted input formats gets a libFuzzer harness
61
+ (`LLVMFuzzerTestOneInput`, `-fsanitize=fuzzer,address,undefined`) when the
62
+ project has fuzzing infrastructure, or a documented seed corpus ready for
63
+ one.
@@ -7,71 +7,42 @@ metadata:
7
7
 
8
8
  # CI workflow patterns (GitHub Actions & GitLab CI)
9
9
 
10
- Narrows `core-common-rules`' stack-agnostic design guidance to workflow-YAML
11
- structure and reuse. Applies only to GitHub Actions workflow files under
12
- `.github/workflows/`, GitHub composite `action.yml`/`action.yaml` files
13
- under `.github/actions/`, `.gitlab-ci.yml`, and GitLab CI included config
14
- under `.gitlab/` — not to Kubernetes manifests,
15
- Docker Compose files, or any other YAML the `docker-k8s-terraform` pack
16
- already scopes to.
10
+ Narrows `core-common-rules`' design guidance to workflow-YAML structure and reuse. Applies only to GitHub Actions workflows under `.github/workflows/`, composite `action.yml`/`action.yaml` under `.github/actions/`, `.gitlab-ci.yml` and GitLab CI included config under `.gitlab/`, not to YAML the `docker-k8s-terraform` pack scopes.
17
11
 
18
12
  ## Trigger and concurrency shape
19
13
 
20
- - Scope `on:`/`rules:` to the events a workflow actually needs (a specific
21
- branch, path filter, or event type) rather than firing on every push —
22
- a broad trigger wastes runner minutes and widens the surface a
23
- misconfigured job can affect.
24
- - Add a `concurrency:` group (GitHub Actions) or a `resource_group` (GitLab
25
- CI) to any workflow that deploys or mutates shared state, so a second
26
- push does not race an in-flight run against the same target — a
27
- `resource_group` serializes/queues jobs targeting the same resource,
28
- which is the property a deploy job needs. Do not reach for
29
- `interruptible: true` here: that flag means the OPPOSITE (this job is
30
- SAFE to auto-cancel when a newer pipeline starts), which is right for a
31
- build/test job made obsolete by a newer commit, not for a deploy already
32
- in flight.
33
- - Keep `pull_request` as the default trigger for anything that only builds
34
- or tests untrusted contributions; reach for `pull_request_target` only
35
- when the job genuinely needs base-repo secrets, and see
36
- `rules/security.mdc` for what that requires.
14
+ - Scope `on:`/`rules:` to the events needed (a branch, path filter or event type),
15
+ not every push.
16
+ - Add a `concurrency:` group (GitHub Actions) or `resource_group` (GitLab CI) to
17
+ any workflow that deploys or mutates shared state. Not `interruptible: true` for
18
+ a deploy: it means the job is SAFE to auto-cancel, which fits a build/test job
19
+ made obsolete by a newer commit, not a deploy in flight.
20
+ - Keep `pull_request` as the default trigger for anything that only builds or
21
+ tests untrusted contributions; `pull_request_target` only when the job needs
22
+ base-repo secrets, see `rules/security.mdc`.
37
23
 
38
24
  ## Job structure and reuse
39
25
 
40
- - Give every job an explicit `name:` and a `timeout-minutes` (GitHub
41
- Actions) or job-level `timeout` (GitLab CI) — an unbounded job can hang
42
- a runner indefinitely on a stuck process or a flaky network call.
43
- - Factor a step sequence used by more than one workflow into a reusable
44
- workflow (`workflow_call`) or composite action (GitHub Actions), or an
45
- `include:`/`extends:` template (GitLab CI), instead of copy-pasting the
46
- same steps into every workflow file — the copy drifts the moment one
47
- copy gets a fix the others do not.
48
- - Pin a `runs-on`/`image:` to a specific, known runner or image tag rather
49
- than a rolling `latest`, so a runner image update cannot silently change
50
- build behavior underneath an unrelated change.
51
- - Use a job-level `needs:` (GitHub Actions) or `needs:`/stage ordering
52
- (GitLab CI) to express real dependencies between jobs explicitly, rather
53
- than relying on default stage ordering to imply an ordering the config
54
- does not actually state.
26
+ - Give every job an explicit `name:` and a `timeout-minutes` (GitHub Actions) or
27
+ job-level `timeout` (GitLab CI).
28
+ - Factor a step sequence used by more than one workflow into a reusable workflow
29
+ (`workflow_call`) or composite action (GitHub Actions), or an
30
+ `include:`/`extends:` template (GitLab CI).
31
+ - Pin `runs-on`/`image:` to a specific runner or image tag, not a rolling `latest`.
32
+ - Express real job dependencies with `needs:` (GitHub Actions) or
33
+ `needs:`/stage ordering (GitLab CI), not implied default stage order.
55
34
 
56
35
  ## Caching and artifacts
57
36
 
58
- - Key a cache (`actions/cache`, GitLab's `cache:key`) off the lockfile or
59
- dependency manifest hash, not a static string — a static key serves a
60
- stale cache forever and a hash-based key invalidates exactly when the
61
- dependency set actually changes.
62
- - Scope `artifacts:`/`actions/upload-artifact` to the files a later job
63
- actually consumes, with an explicit retention/expiry, rather than
64
- uploading an entire working directory that balloons storage and
65
- transfer time.
37
+ - Key a cache (`actions/cache`, GitLab `cache:key`) off the lockfile or dependency
38
+ manifest hash, not a static string.
39
+ - Scope `artifacts:`/`actions/upload-artifact` to the files a later job consumes,
40
+ with an explicit retention/expiry, not a whole working directory.
66
41
 
67
42
  ## Anti-patterns to flag
68
43
 
69
- - A workflow that duplicates the same 10+ line step sequence across
70
- multiple jobs or files instead of a reusable workflow, composite
71
- action, or `include:`/`extends:` template.
72
- - A job with no `timeout-minutes`/`timeout` on a step that can hang (a
73
- network call, a wait loop, an interactive prompt the runner cannot
74
- answer).
75
- - A cache key that never changes (a literal string with no hash of the
76
- lockfile), which either never invalidates or never actually caches
77
- anything useful.
44
+ - The same 10+ line step sequence duplicated across jobs or files instead of a
45
+ reusable workflow, composite action or `include:`/`extends:` template.
46
+ - A job with no `timeout-minutes`/`timeout` on a step that can hang (a network
47
+ call, a wait loop, an interactive prompt).
48
+ - A cache key that never changes (a literal string with no lockfile hash).