lgtm-specs 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.local.json +14 -0
- package/.gemini/README.md +8 -0
- package/.gemini/config.yaml +20 -0
- package/.gemini/styleguide.md +35 -0
- package/.github/workflows/README.md +5 -0
- package/.github/workflows/release.yml +52 -0
- package/.github/workflows/validate.yml +27 -0
- package/.prettierignore +4 -0
- package/.prettierrc +1 -0
- package/AGENTS.md +151 -0
- package/README.md +98 -0
- package/VERSION +1 -0
- package/agents/README.md +73 -0
- package/agents/modes/README.md +9 -0
- package/agents/modes/build.md +88 -0
- package/agents/modes/hack.md +76 -0
- package/agents/modes/review.md +79 -0
- package/agents/roles/builder.md +75 -0
- package/agents/roles/counsel.md +96 -0
- package/agents/roles/explorer.md +77 -0
- package/agents/roles/lead.md +76 -0
- package/agents/roles/librarian.md +63 -0
- package/agents/roles/planner.md +75 -0
- package/agents/roles/reviewer/BASE.md +9 -0
- package/agents/roles/reviewer/OUTPUT_FORMAT.md +4 -0
- package/agents/roles/reviewer/README.md +48 -0
- package/agents/roles/reviewer/lite.md +51 -0
- package/agents/roles/reviewer/logic.md +48 -0
- package/agents/roles/reviewer/performance.md +45 -0
- package/agents/roles/reviewer/plan.md +52 -0
- package/agents/roles/reviewer/quality.md +49 -0
- package/agents/roles/reviewer/security.md +47 -0
- package/agents/roles/reviewer/test.md +48 -0
- package/agents/templates/README.md +6 -0
- package/agents/templates/mode.md +33 -0
- package/agents/templates/role.md +73 -0
- package/contribute/README.md +24 -0
- package/contribute/add-agent.md +29 -0
- package/contribute/add-ci.md +31 -0
- package/contribute/add-constitution.md +17 -0
- package/contribute/add-law.md +20 -0
- package/contribute/add-policy.md +27 -0
- package/contribute/checklist.md +42 -0
- package/contribute/maintenance.md +19 -0
- package/contribute/update-models.md +47 -0
- package/docs/README.md +13 -0
- package/docs/adr/0001-knowledge-engineering-workflow.md +22 -0
- package/docs/adr/0002-rule-hierarchy.md +25 -0
- package/docs/adr/0003-atomic-knowledge-graph.md +21 -0
- package/docs/adr/0004-identification-schema.md +22 -0
- package/docs/adr/0005-agent-specialization.md +39 -0
- package/docs/adr/0006-git-workflow-integrity.md +34 -0
- package/docs/adr/0007-operating-modes-and-gates.md +54 -0
- package/docs/adr/0008-rules-vs-workflows-boundary.md +64 -0
- package/docs/adr/README.md +14 -0
- package/docs/agent_architecture.md +164 -0
- package/docs/context_lifecycle.md +228 -0
- package/docs/engineering_principles.md +128 -0
- package/docs/local_policies.md +59 -0
- package/docs/meta/collaborative_dynamics.md +142 -0
- package/docs/meta/domains/README.md +8 -0
- package/docs/meta/domains/bitcoin/01-units.md +21 -0
- package/docs/meta/domains/bitcoin/02-broadcast-cancellation.md +20 -0
- package/docs/meta/domains/bitcoin/03-fee-rates-rounding.md +21 -0
- package/docs/meta/domains/bitcoin/04-confirmations-reorgs.md +20 -0
- package/docs/meta/domains/bitcoin/05-address-gap-limit.md +16 -0
- package/docs/meta/domains/bitcoin/06-relay-policy.md +27 -0
- package/docs/meta/domains/bitcoin/README.md +12 -0
- package/docs/meta/domains/git/01-workflow.md +89 -0
- package/docs/meta/domains/git/02-commits.md +57 -0
- package/docs/meta/domains/git/03-collaboration.md +40 -0
- package/docs/meta/domains/git/04-integrity.md +26 -0
- package/docs/meta/domains/git/05-configuration.md +209 -0
- package/docs/meta/domains/git/06-advanced.md +130 -0
- package/docs/meta/domains/git/README.md +29 -0
- package/docs/meta/industry_best_practices.md +555 -0
- package/docs/meta/languages/README.md +8 -0
- package/docs/meta/languages/go/01-concurrency.md +37 -0
- package/docs/meta/languages/go/02-api-design.md +30 -0
- package/docs/meta/languages/go/03-resilience.md +27 -0
- package/docs/meta/languages/go/04-errors.md +27 -0
- package/docs/meta/languages/go/05-performance.md +18 -0
- package/docs/meta/languages/go/06-safety.md +18 -0
- package/docs/meta/languages/go/07-testing.md +44 -0
- package/docs/meta/languages/go/08-config-layout.md +23 -0
- package/docs/meta/languages/go/README.md +14 -0
- package/docs/meta/languages/typescript/01-strictness.md +19 -0
- package/docs/meta/languages/typescript/02-immutability.md +15 -0
- package/docs/meta/languages/typescript/03-async.md +18 -0
- package/docs/meta/languages/typescript/04-design.md +19 -0
- package/docs/meta/languages/typescript/05-control-flow.md +11 -0
- package/docs/meta/languages/typescript/README.md +11 -0
- package/docs/meta/workflow.md +68 -0
- package/docs/philosophy.md +36 -0
- package/integrate/README.md +459 -0
- package/integrate/versioning.md +41 -0
- package/models/README.md +68 -0
- package/models/registry.yaml +55 -0
- package/package.json +11 -0
- package/rules/README.md +57 -0
- package/rules/RULE-00000-EXAMPLE.md +29 -0
- package/rules/constitution/CONS-00001-srp.md +40 -0
- package/rules/constitution/CONS-00002-ocp.md +43 -0
- package/rules/constitution/CONS-00003-lsp.md +44 -0
- package/rules/constitution/CONS-00004-isp.md +46 -0
- package/rules/constitution/CONS-00005-dip.md +37 -0
- package/rules/constitution/CONS-00006-dry.md +45 -0
- package/rules/constitution/CONS-00007-demeter.md +35 -0
- package/rules/constitution/CONS-00008-composition.md +44 -0
- package/rules/constitution/CONS-00009-deep-modules.md +39 -0
- package/rules/constitution/CONS-00010-kiss.md +47 -0
- package/rules/constitution/CONS-00011-yagni.md +49 -0
- package/rules/constitution/CONS-00012-cognitive-limits.md +28 -0
- package/rules/constitution/CONS-00013-boy-scout.md +27 -0
- package/rules/constitution/CONS-00014-broken-windows.md +35 -0
- package/rules/constitution/CONS-00015-safety.md +46 -0
- package/rules/constitution/CONS-00016-cqs.md +39 -0
- package/rules/constitution/CONS-00017-postel.md +35 -0
- package/rules/constitution/CONS-00018-cap.md +35 -0
- package/rules/constitution/CONS-00019-fallacies.md +37 -0
- package/rules/constitution/CONS-00020-shift-left.md +28 -0
- package/rules/constitution/CONS-00021-congruence.md +28 -0
- package/rules/constitution/CONS-00022-orthogonality.md +40 -0
- package/rules/constitution/CONS-00023-determinism.md +38 -0
- package/rules/constitution/CONS-00024-security.md +42 -0
- package/rules/constitution/CONS-00025-efficiency.md +38 -0
- package/rules/constitution/CONS-00026-resilience.md +41 -0
- package/rules/constitution/CONS-00027-transparency.md +40 -0
- package/rules/constitution/CONS-00028-evolvability.md +36 -0
- package/rules/constitution/CONS-00029-operability.md +36 -0
- package/rules/constitution/CONS-00030-rework-cycle.md +27 -0
- package/rules/constitution/CONS-00031-checklist.md +28 -0
- package/rules/constitution/CONS-00032-documentation.md +39 -0
- package/rules/constitution/README.md +52 -0
- package/rules/laws/README.md +15 -0
- package/rules/laws/bitcoin/BTC-00001-amounts-as-satoshis.md +39 -0
- package/rules/laws/bitcoin/BTC-00002-broadcast-not-cancelable.md +36 -0
- package/rules/laws/bitcoin/BTC-00003-fee-rate-math-rounding.md +37 -0
- package/rules/laws/bitcoin/BTC-00004-confirmations-and-reorgs.md +40 -0
- package/rules/laws/bitcoin/BTC-00005-address-gap-limit.md +37 -0
- package/rules/laws/bitcoin/BTC-00006-relay-is-policy-dependent.md +36 -0
- package/rules/laws/bitcoin/BTC-00007-dust-policy.md +36 -0
- package/rules/laws/bitcoin/BTC-00008-min-relay-fee.md +36 -0
- package/rules/laws/bitcoin/BTC-00009-feefilter.md +36 -0
- package/rules/laws/bitcoin/README.md +29 -0
- package/rules/laws/default.md +30 -0
- package/rules/laws/git/GIT-00001-atomic-commit.md +29 -0
- package/rules/laws/git/GIT-00002-imperative-subject.md +27 -0
- package/rules/laws/git/GIT-00003-formatting-50-72.md +28 -0
- package/rules/laws/git/GIT-00004-trunk-based.md +28 -0
- package/rules/laws/git/GIT-00005-public-immutability.md +26 -0
- package/rules/laws/git/GIT-00006-signing.md +27 -0
- package/rules/laws/git/GIT-00007-reviewer-capital.md +26 -0
- package/rules/laws/git/GIT-00008-patch-series.md +28 -0
- package/rules/laws/git/GIT-00009-branch-naming.md +28 -0
- package/rules/laws/git/GIT-00010-pr-hygiene.md +51 -0
- package/rules/laws/git/GIT-00011-merge-method.md +35 -0
- package/rules/laws/git/GIT-00012-conflict-resolution.md +35 -0
- package/rules/laws/git/GIT-00013-ignore-standards.md +38 -0
- package/rules/laws/git/GIT-00014-lfs-large-binaries.md +37 -0
- package/rules/laws/git/GIT-00015-git-hooks.md +35 -0
- package/rules/laws/git/GIT-00016-branch-protection.md +34 -0
- package/rules/laws/git/GIT-00017-secrets-management.md +34 -0
- package/rules/laws/git/GIT-00018-ci-enforcement.md +33 -0
- package/rules/laws/git/GIT-00019-review-checklist.md +39 -0
- package/rules/laws/git/GIT-00020-issue-references.md +34 -0
- package/rules/laws/git/GIT-00021-partial-staging.md +38 -0
- package/rules/laws/git/GIT-00022-feature-flags.md +33 -0
- package/rules/laws/git/GIT-00023-breaking-changes.md +41 -0
- package/rules/laws/git/GIT-00024-dependency-management.md +44 -0
- package/rules/laws/git/GIT-00025-large-repository-optimization.md +54 -0
- package/rules/laws/git/README.md +31 -0
- package/rules/laws/go/GO-00001-actor-model.md +51 -0
- package/rules/laws/go/GO-00002-api-design.md +37 -0
- package/rules/laws/go/GO-00003-error-handling.md +43 -0
- package/rules/laws/go/GO-00004-context.md +45 -0
- package/rules/laws/go/GO-00005-performance.md +40 -0
- package/rules/laws/go/GO-00006-packages.md +29 -0
- package/rules/laws/go/GO-00007-circuit-breakers.md +43 -0
- package/rules/laws/go/GO-00008-safety.md +39 -0
- package/rules/laws/go/GO-00009-table-driven-test.md +48 -0
- package/rules/laws/go/GO-00010-escape-analysis.md +37 -0
- package/rules/laws/go/GO-00011-retry.md +45 -0
- package/rules/laws/go/GO-00012-rate-limiting.md +42 -0
- package/rules/laws/go/GO-00013-io-buffering.md +43 -0
- package/rules/laws/go/GO-00014-memory-layout.md +41 -0
- package/rules/laws/go/GO-00015-aaa-pattern.md +49 -0
- package/rules/laws/go/GO-00016-test-libraries.md +35 -0
- package/rules/laws/go/GO-00017-comments.md +37 -0
- package/rules/laws/go/GO-00018-test-isolation.md +38 -0
- package/rules/laws/go/GO-00019-test-comments.md +36 -0
- package/rules/laws/go/GO-00020-mocking.md +36 -0
- package/rules/laws/go/GO-00021-configuration.md +36 -0
- package/rules/laws/go/GO-00022-observability.md +34 -0
- package/rules/laws/go/GO-00023-dependency-management.md +28 -0
- package/rules/laws/go/GO-00024-project-layout.md +30 -0
- package/rules/laws/go/GO-00025-concurrency-patterns.md +39 -0
- package/rules/laws/go/README.md +45 -0
- package/rules/laws/typescript/README.md +14 -0
- package/rules/laws/typescript/TS-00001-no-any.md +39 -0
- package/rules/laws/typescript/TS-00002-immutability.md +36 -0
- package/rules/laws/typescript/TS-00003-async.md +35 -0
- package/rules/laws/typescript/TS-00004-strict-null.md +38 -0
- package/rules/laws/typescript/TS-00005-unions.md +35 -0
- package/rules/laws/typescript/TS-00006-interface.md +38 -0
- package/rules/laws/typescript/TS-00007-generics.md +38 -0
- package/rules/laws/typescript/TS-00008-modules.md +28 -0
- package/rules/policies/README.md +12 -0
- package/rules/policies/default.md +28 -0
- package/scripts/README.md +45 -0
- package/scripts/generate_release_notes.py +376 -0
- package/scripts/validate_specs.py +730 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Safety by Design (CONS-00015)
|
|
2
|
+
|
|
3
|
+
**Source**: [Formal Methods & Correctness](../../docs/meta/industry_best_practices.md#61-safety-by-design)
|
|
4
|
+
**Tags**: #behavioral #correctness #safety
|
|
5
|
+
**Related**: [LSP](CONS-00003-lsp.md), [Determinism](CONS-00023-determinism.md)
|
|
6
|
+
|
|
7
|
+
## Definition
|
|
8
|
+
|
|
9
|
+
Illegal states should be unrepresentable. Testing detects bugs; design prevents them.
|
|
10
|
+
|
|
11
|
+
## Requirements
|
|
12
|
+
|
|
13
|
+
1. **Immutability**: Prefer immutable data structures to prevent race conditions.
|
|
14
|
+
2. **State Machines**: Use an explicit state model (enum/discriminated states) for mutually exclusive states, not
|
|
15
|
+
boolean flags.
|
|
16
|
+
3. **Parsing**: Validate all external input at the boundary (schema validation).
|
|
17
|
+
|
|
18
|
+
## Anti-Patterns
|
|
19
|
+
|
|
20
|
+
- **Boolean Soup**: `isLoading`, `isError`, `isSuccess` flags that can all be true at once.
|
|
21
|
+
- **Primitive Obsession**: Using `string` for an Email Address instead of a Value Object.
|
|
22
|
+
|
|
23
|
+
## Examples
|
|
24
|
+
|
|
25
|
+
**Bad:**
|
|
26
|
+
|
|
27
|
+
```text
|
|
28
|
+
state = {
|
|
29
|
+
loading: true|false,
|
|
30
|
+
error_message: "..."|empty,
|
|
31
|
+
data: user,
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
# invalid combinations are possible (e.g., loading=true and error_message set)
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**Good:**
|
|
38
|
+
|
|
39
|
+
```text
|
|
40
|
+
# a single discriminant + payload makes illegal states unrepresentable
|
|
41
|
+
State = one_of(
|
|
42
|
+
{ status: "loading" },
|
|
43
|
+
{ status: "error", message: "..." },
|
|
44
|
+
{ status: "success", data: user },
|
|
45
|
+
)
|
|
46
|
+
```
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Command-Query Separation (CONS-00016)
|
|
2
|
+
|
|
3
|
+
**Source**: [Formal Methods & Correctness](../../docs/meta/industry_best_practices.md#62-command-query-separation-cqs)
|
|
4
|
+
**Tags**: #behavioral #predictability #design
|
|
5
|
+
**Related**: [Determinism](CONS-00023-determinism.md)
|
|
6
|
+
|
|
7
|
+
## Definition
|
|
8
|
+
|
|
9
|
+
Methods must either perform an action (Command) or return data (Query), but not both.
|
|
10
|
+
|
|
11
|
+
## Requirements
|
|
12
|
+
|
|
13
|
+
1. **Side Effects**: A method that returns a value should be "Pure" (no observable side effects).
|
|
14
|
+
2. **Command Returns**: A method that mutates state should not also return a value.
|
|
15
|
+
|
|
16
|
+
## Anti-Patterns
|
|
17
|
+
|
|
18
|
+
- **The Sneaky Get**: `getUser()` that also increments a login counter.
|
|
19
|
+
- **The Talkative Set**: `setUser()` that returns the old user object.
|
|
20
|
+
|
|
21
|
+
## Examples
|
|
22
|
+
|
|
23
|
+
**Bad:**
|
|
24
|
+
|
|
25
|
+
```text
|
|
26
|
+
function login(credentials):
|
|
27
|
+
update_login_state(credentials.user_id)
|
|
28
|
+
return current_user() # command + query mixed
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
**Good:**
|
|
32
|
+
|
|
33
|
+
```text
|
|
34
|
+
function login(credentials):
|
|
35
|
+
update_login_state(credentials.user_id)
|
|
36
|
+
|
|
37
|
+
function current_user():
|
|
38
|
+
return user
|
|
39
|
+
```
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Postel's Law (Robustness Principle) (CONS-00017)
|
|
2
|
+
|
|
3
|
+
**Source**: [Formal Methods & Correctness](../../docs/meta/industry_best_practices.md#63-postels-law)
|
|
4
|
+
**Tags**: #runtime #robustness #interface
|
|
5
|
+
**Related**: [Safety by Design](CONS-00015-safety.md), [Resilience](CONS-00026-resilience.md)
|
|
6
|
+
|
|
7
|
+
## Definition
|
|
8
|
+
|
|
9
|
+
Be conservative in what you do, be liberal in what you accept.
|
|
10
|
+
|
|
11
|
+
## Requirements
|
|
12
|
+
|
|
13
|
+
1. **Strict Output**: APIs must return strict, validated, predictable data structures.
|
|
14
|
+
2. **Graceful Input**: Parse inputs tolerantly (ignore unknown fields) where safe, but reject invalid data structures explicitly.
|
|
15
|
+
|
|
16
|
+
## Anti-Patterns
|
|
17
|
+
|
|
18
|
+
- **Brittle Parsing**: Crashing the whole app because one JSON field was missing.
|
|
19
|
+
- **Loose Output**: Returning internal DB objects directly to the API consumer.
|
|
20
|
+
|
|
21
|
+
## Examples
|
|
22
|
+
|
|
23
|
+
**Bad:**
|
|
24
|
+
|
|
25
|
+
```text
|
|
26
|
+
# Returning an internal storage record directly (may include secret/internal fields)
|
|
27
|
+
return user_record
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
**Good:**
|
|
31
|
+
|
|
32
|
+
```text
|
|
33
|
+
# Returning a strict, sanitized response shape
|
|
34
|
+
return { id: user.id, name: user.name }
|
|
35
|
+
```
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# CAP & PACELC (CONS-00018)
|
|
2
|
+
|
|
3
|
+
**Source**: [Distributed Systems](../../docs/meta/industry_best_practices.md#71-cap--pacelc)
|
|
4
|
+
**Tags**: #runtime #distributed-systems #tradeoffs #consistency
|
|
5
|
+
**Related**: [Fallacies](CONS-00019-fallacies.md), [Resilience](CONS-00026-resilience.md)
|
|
6
|
+
|
|
7
|
+
## Definition
|
|
8
|
+
|
|
9
|
+
In a distributed system, you cannot have Consistency, Availability, and Partition Tolerance simultaneously. You must choose.
|
|
10
|
+
|
|
11
|
+
## Requirements
|
|
12
|
+
|
|
13
|
+
1. **Explicit Mode**: Distributed components must document their consistency model (Eventual vs Strong).
|
|
14
|
+
2. **Failure Handling**: Code must handle network partitions (timeouts, retries) explicitly.
|
|
15
|
+
|
|
16
|
+
## Anti-Patterns
|
|
17
|
+
|
|
18
|
+
- **Magical Consistency**: Assuming a write to a replicated datastore is instantly visible to a read.
|
|
19
|
+
- **Ignoring Partitions**: Coding as if the network never splits.
|
|
20
|
+
|
|
21
|
+
## Examples
|
|
22
|
+
|
|
23
|
+
**Bad:**
|
|
24
|
+
|
|
25
|
+
```text
|
|
26
|
+
write(x)
|
|
27
|
+
return read(x) # assumes read-after-write consistency
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
**Good:**
|
|
31
|
+
|
|
32
|
+
```text
|
|
33
|
+
write(x, consistency="quorum")
|
|
34
|
+
return read(x, consistency="quorum")
|
|
35
|
+
```
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Fallacies of Distributed Computing (CONS-00019)
|
|
2
|
+
|
|
3
|
+
**Source**: [Distributed Systems](../../docs/meta/industry_best_practices.md#72-fallacies-of-distributed-computing)
|
|
4
|
+
**Tags**: #runtime #distributed-systems #resilience
|
|
5
|
+
**Related**: [Resilience](CONS-00026-resilience.md), [Security](CONS-00024-security.md)
|
|
6
|
+
|
|
7
|
+
## Definition
|
|
8
|
+
|
|
9
|
+
The 8 false assumptions that lead to distributed system failures.
|
|
10
|
+
|
|
11
|
+
## Requirements
|
|
12
|
+
|
|
13
|
+
1. **Timeouts**: Every network call must have a timeout.
|
|
14
|
+
2. **Retries**: Idempotent operations should have exponential backoff.
|
|
15
|
+
3. **Security**: Encrypt all transit; do not trust internal networks.
|
|
16
|
+
4. **Topology**: Don't hardcode IPs; use Service Discovery.
|
|
17
|
+
|
|
18
|
+
## Anti-Patterns
|
|
19
|
+
|
|
20
|
+
- **Infinite Wait**: Network calls without an explicit timeout (and cancellation when applicable).
|
|
21
|
+
- **Assumption of Zero Latency**: Making 100 sequential calls in a loop.
|
|
22
|
+
|
|
23
|
+
## Examples
|
|
24
|
+
|
|
25
|
+
**Bad:**
|
|
26
|
+
|
|
27
|
+
```text
|
|
28
|
+
users = []
|
|
29
|
+
for id in ids:
|
|
30
|
+
users.append(api.get_user(id)) # sequential
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**Good:**
|
|
34
|
+
|
|
35
|
+
```text
|
|
36
|
+
users = api.batch_get_users(ids)
|
|
37
|
+
```
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Shift Left (CONS-00020)
|
|
2
|
+
|
|
3
|
+
**Source**: [Systems Theory & Dynamics](../../docs/meta/industry_best_practices.md#51-shift-left)
|
|
4
|
+
**Tags**: #operational #process #velocity #quality
|
|
5
|
+
**Related**: [Rework Cycle](CONS-00030-rework-cycle.md), [Safety](CONS-00015-safety.md)
|
|
6
|
+
|
|
7
|
+
## Definition
|
|
8
|
+
|
|
9
|
+
Verification activities should happen as early as possible. Remediating a defect in production is 100x more expensive than in design.
|
|
10
|
+
|
|
11
|
+
## Requirements
|
|
12
|
+
|
|
13
|
+
1. **Design First**: Complex features require a Design Doc or RFC before code.
|
|
14
|
+
2. **Impact Analysis**: Check dependencies before refactoring.
|
|
15
|
+
3. **Static Analysis**: Linting and type checking must run locally (pre-commit) and in CI.
|
|
16
|
+
|
|
17
|
+
## Anti-Patterns
|
|
18
|
+
|
|
19
|
+
- **"We'll fix it in QA"**: Pushing known buggy code.
|
|
20
|
+
- **Coding before Thinking**: Writing implementation details without a clear interface.
|
|
21
|
+
|
|
22
|
+
## Examples
|
|
23
|
+
|
|
24
|
+
**Bad:**
|
|
25
|
+
Writing a massive feature, then writing tests, then realizing the architecture is wrong.
|
|
26
|
+
|
|
27
|
+
**Good:**
|
|
28
|
+
Writing the Interface and Tests first (TDD), then implementing.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Socio-Technical Congruence (CONS-00021)
|
|
2
|
+
|
|
3
|
+
**Source**: [Systems Theory & Dynamics](../../docs/meta/industry_best_practices.md#52-socio-technical-congruence)
|
|
4
|
+
**Tags**: #operational #organization #architecture
|
|
5
|
+
**Related**: [SRP](CONS-00001-srp.md), [Operability](CONS-00029-operability.md)
|
|
6
|
+
|
|
7
|
+
## Definition
|
|
8
|
+
|
|
9
|
+
Align code boundaries with team boundaries. Mismatches cause communication overhead and integration failures.
|
|
10
|
+
|
|
11
|
+
## Requirements
|
|
12
|
+
|
|
13
|
+
1. **Ownership**: Every module must have a clear owner (CODEOWNERS).
|
|
14
|
+
2. **Team API**: Interfaces between teams must be verified by contracts.
|
|
15
|
+
3. **Decoupling**: Tight coupling between modules owned by different teams is a high-risk architecture violation.
|
|
16
|
+
|
|
17
|
+
## Anti-Patterns
|
|
18
|
+
|
|
19
|
+
- **Distributed Monolith**: Microservices that must be deployed together.
|
|
20
|
+
- **Shared Database**: Two teams writing to the same tables.
|
|
21
|
+
|
|
22
|
+
## Examples
|
|
23
|
+
|
|
24
|
+
**Bad:**
|
|
25
|
+
Team A modifying Team B's internal utility library directly.
|
|
26
|
+
|
|
27
|
+
**Good:**
|
|
28
|
+
Team A using Team B's public, versioned API client.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Orthogonality (CONS-00022)
|
|
2
|
+
|
|
3
|
+
**Source**: [Universal Fundamentals](../../docs/meta/industry_best_practices.md#33-orthogonality)
|
|
4
|
+
**Tags**: #structural #coupling #independence
|
|
5
|
+
**Related**: [Law of Demeter](CONS-00007-demeter.md), [DIP](CONS-00005-dip.md), [SRP](CONS-00001-srp.md)
|
|
6
|
+
|
|
7
|
+
## Definition
|
|
8
|
+
|
|
9
|
+
Changing one component should not affect unrelated components. Components are mathematically independent.
|
|
10
|
+
|
|
11
|
+
## Requirements
|
|
12
|
+
|
|
13
|
+
1. **Interface Isolation**: Components communicate via narrow, stable interfaces.
|
|
14
|
+
2. **No Global State**: State must be eliminated or strictly isolated.
|
|
15
|
+
3. **Change Propagation**: Modifications should have minimal blast radius.
|
|
16
|
+
|
|
17
|
+
## Anti-Patterns
|
|
18
|
+
|
|
19
|
+
- **Spaghetti Dependencies**: Circular imports, tight coupling.
|
|
20
|
+
- **Global Singletons**: Shared mutable state across modules.
|
|
21
|
+
|
|
22
|
+
## Examples
|
|
23
|
+
|
|
24
|
+
**Bad:**
|
|
25
|
+
|
|
26
|
+
```text
|
|
27
|
+
# UI layer directly queries storage
|
|
28
|
+
function render_user_profile():
|
|
29
|
+
user = storage.read_current_user() # violation
|
|
30
|
+
render(user)
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**Good:**
|
|
34
|
+
|
|
35
|
+
```text
|
|
36
|
+
# UI depends on an interface/service
|
|
37
|
+
function render_user_profile(user_service):
|
|
38
|
+
user = user_service.current_user()
|
|
39
|
+
render(user)
|
|
40
|
+
```
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Determinism (CONS-00023)
|
|
2
|
+
|
|
3
|
+
**Source**: [Explicitness](../../docs/meta/industry_best_practices.md#35-explicitness)
|
|
4
|
+
|
|
5
|
+
**Tags**: #behavioral #predictability #purity
|
|
6
|
+
**Related**: [CQS](CONS-00016-cqs.md), [Safety](CONS-00015-safety.md)
|
|
7
|
+
|
|
8
|
+
## Definition
|
|
9
|
+
|
|
10
|
+
System behavior is consistent and reproducible given the same initial state and inputs.
|
|
11
|
+
|
|
12
|
+
## Requirements
|
|
13
|
+
|
|
14
|
+
1. **Pure Functions**: Same input → Same output, no side effects.
|
|
15
|
+
2. **Explicit Dependencies**: All dependencies injected, no globals.
|
|
16
|
+
3. **Reproducibility**: Eliminate sources of non-determinism (time, randomness, external state).
|
|
17
|
+
|
|
18
|
+
## Anti-Patterns
|
|
19
|
+
|
|
20
|
+
- **Hidden State**: Functions reading from global config.
|
|
21
|
+
- **Implicit Time**: Using `Date.now()` directly instead of injected clock.
|
|
22
|
+
- **Unseeded Random**: Non-reproducible random values.
|
|
23
|
+
|
|
24
|
+
## Examples
|
|
25
|
+
|
|
26
|
+
**Bad:**
|
|
27
|
+
|
|
28
|
+
```text
|
|
29
|
+
function calculate_price(base):
|
|
30
|
+
return base * (1 + GLOBAL_TAX_RATE) * current_time() # non-deterministic
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**Good:**
|
|
34
|
+
|
|
35
|
+
```text
|
|
36
|
+
function calculate_price(base, tax_rate, now):
|
|
37
|
+
return base * (1 + tax_rate) * now # deterministic
|
|
38
|
+
```
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Security (CONS-00024)
|
|
2
|
+
|
|
3
|
+
**Source**: [Security Engineering](../../docs/meta/industry_best_practices.md#9-security-engineering)
|
|
4
|
+
**Tags**: #behavioral #security #defense
|
|
5
|
+
**Related**: [Postel's Law](CONS-00017-postel.md), [Safety](CONS-00015-safety.md)
|
|
6
|
+
|
|
7
|
+
## Definition
|
|
8
|
+
|
|
9
|
+
The system protects information and maintains functionality in the face of malicious acts.
|
|
10
|
+
|
|
11
|
+
## Requirements
|
|
12
|
+
|
|
13
|
+
1. **Least Privilege**: Components have minimum necessary permissions.
|
|
14
|
+
2. **Defense in Depth**: Multiple security controls, no single point of failure.
|
|
15
|
+
3. **Secure Defaults**: Systems are secure out-of-the-box.
|
|
16
|
+
4. **Input Validation**: Never trust external input; validate at boundaries.
|
|
17
|
+
|
|
18
|
+
## Anti-Patterns
|
|
19
|
+
|
|
20
|
+
- **Trust by Default**: Assuming internal network is safe.
|
|
21
|
+
- **Secrets in Code**: Hardcoded credentials, API keys.
|
|
22
|
+
- **Over-Privilege**: Services with root/admin access unnecessarily.
|
|
23
|
+
|
|
24
|
+
## Examples
|
|
25
|
+
|
|
26
|
+
**Bad:**
|
|
27
|
+
|
|
28
|
+
```text
|
|
29
|
+
function handle_request(request):
|
|
30
|
+
id = request.path_params["id"]
|
|
31
|
+
return database.query("... WHERE id = " + id) # injection risk
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
**Good:**
|
|
35
|
+
|
|
36
|
+
```text
|
|
37
|
+
function handle_request(request):
|
|
38
|
+
require_authorization(request.user, "user:read")
|
|
39
|
+
|
|
40
|
+
id = validate_id(request.path_params["id"])
|
|
41
|
+
return database.query("... WHERE id = ?", params=[id]) # parameterized
|
|
42
|
+
```
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Efficiency (CONS-00025)
|
|
2
|
+
|
|
3
|
+
**Source**: [Performance & Efficiency](../../docs/meta/industry_best_practices.md#12-performance--efficiency)
|
|
4
|
+
**Tags**: #runtime #performance #resources
|
|
5
|
+
**Related**: [Deep Modules](CONS-00009-deep-modules.md), [YAGNI](CONS-00011-yagni.md)
|
|
6
|
+
|
|
7
|
+
## Definition
|
|
8
|
+
|
|
9
|
+
Optimal use of bounded computational resources (time, memory, bandwidth).
|
|
10
|
+
|
|
11
|
+
## Requirements
|
|
12
|
+
|
|
13
|
+
1. **Algorithmic Awareness**: Known Big-O complexity for hot paths.
|
|
14
|
+
2. **Resource Bounds**: Memory/CPU usage must be bounded and measurable.
|
|
15
|
+
3. **Profiling First**: Optimize only proven bottlenecks.
|
|
16
|
+
4. **Caching Strategy**: Explicit cache policies (TTL, eviction).
|
|
17
|
+
|
|
18
|
+
## Anti-Patterns
|
|
19
|
+
|
|
20
|
+
- **N+1 Queries**: Loading related data in loops.
|
|
21
|
+
- **Unbounded Growth**: Unbounded queues, infinite caches.
|
|
22
|
+
- **Premature Optimization**: Optimizing without profiling.
|
|
23
|
+
|
|
24
|
+
## Examples
|
|
25
|
+
|
|
26
|
+
**Bad:**
|
|
27
|
+
|
|
28
|
+
```text
|
|
29
|
+
users = storage.list_users()
|
|
30
|
+
for user in users:
|
|
31
|
+
user.orders = storage.list_orders(user.id) # N+1 queries
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
**Good:**
|
|
35
|
+
|
|
36
|
+
```text
|
|
37
|
+
users = storage.list_users_with_orders() # batched retrieval
|
|
38
|
+
```
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Resilience (CONS-00026)
|
|
2
|
+
|
|
3
|
+
**Source**: [Distributed Systems](../../docs/meta/industry_best_practices.md#7-distributed-systems)
|
|
4
|
+
**Tags**: #runtime #resilience #failure
|
|
5
|
+
**Related**: [CAP](CONS-00018-cap.md), [Fallacies](CONS-00019-fallacies.md), [Postel](CONS-00017-postel.md)
|
|
6
|
+
|
|
7
|
+
## Definition
|
|
8
|
+
|
|
9
|
+
The ability to recover from failure and restore functionality, often with graceful degradation.
|
|
10
|
+
|
|
11
|
+
## Requirements
|
|
12
|
+
|
|
13
|
+
1. **Idempotency**: Operations can be retried safely.
|
|
14
|
+
2. **Circuit Breakers**: Fail fast when dependencies are unhealthy.
|
|
15
|
+
3. **Timeouts**: All external calls have explicit timeouts.
|
|
16
|
+
4. **Graceful Degradation**: Service remains partially available during failures.
|
|
17
|
+
|
|
18
|
+
## Anti-Patterns
|
|
19
|
+
|
|
20
|
+
- **Cascading Failures**: No circuit breakers, infinite retries.
|
|
21
|
+
- **Missing Timeouts**: Hanging requests consuming resources.
|
|
22
|
+
- **Non-Idempotent Mutations**: Unsafe retries causing duplicate data.
|
|
23
|
+
|
|
24
|
+
## Examples
|
|
25
|
+
|
|
26
|
+
**Bad:**
|
|
27
|
+
|
|
28
|
+
```text
|
|
29
|
+
result = call_dependency(request) # no timeout; can hang forever
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
**Good:**
|
|
33
|
+
|
|
34
|
+
```text
|
|
35
|
+
result = call_dependency_with_resilience(
|
|
36
|
+
request,
|
|
37
|
+
timeout_ms=5000,
|
|
38
|
+
retries=3,
|
|
39
|
+
circuit_breaker=true,
|
|
40
|
+
)
|
|
41
|
+
```
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Transparency (CONS-00027)
|
|
2
|
+
|
|
3
|
+
**Source**: [Observability & Operations](../../docs/meta/industry_best_practices.md#11-observability--operations)
|
|
4
|
+
**Tags**: #operational #observability #telemetry
|
|
5
|
+
**Related**: [Congruence](CONS-00021-congruence.md), [Safety](CONS-00015-safety.md)
|
|
6
|
+
|
|
7
|
+
## Definition
|
|
8
|
+
|
|
9
|
+
The ability to understand internal state and runtime behavior by examining outputs.
|
|
10
|
+
|
|
11
|
+
## Requirements
|
|
12
|
+
|
|
13
|
+
1. **Telemetry by Design**: Every service emits metrics (Latency, Errors, Traffic, Saturation).
|
|
14
|
+
2. **Structured Logging**: JSON logs with correlation IDs for tracing.
|
|
15
|
+
3. **Distinguishable States**: Failure states must be observable and actionable.
|
|
16
|
+
4. **Health Endpoints**: Explicit health/readiness checks.
|
|
17
|
+
|
|
18
|
+
## Anti-Patterns
|
|
19
|
+
|
|
20
|
+
- **Logging for Humans**: Unstructured text logs.
|
|
21
|
+
- **Silent Failures**: Errors swallowed without visibility.
|
|
22
|
+
- **Missing Correlation**: Cannot trace requests across services.
|
|
23
|
+
|
|
24
|
+
## Examples
|
|
25
|
+
|
|
26
|
+
**Bad:**
|
|
27
|
+
|
|
28
|
+
```text
|
|
29
|
+
log("user logged in: " + user_id) # unstructured
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
**Good:**
|
|
33
|
+
|
|
34
|
+
```text
|
|
35
|
+
log_event("user.login", {
|
|
36
|
+
user_id: user_id,
|
|
37
|
+
correlation_id: correlation_id,
|
|
38
|
+
duration_ms: duration_ms,
|
|
39
|
+
})
|
|
40
|
+
```
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Evolvability (CONS-00028)
|
|
2
|
+
|
|
3
|
+
**Source**: [Delivery & Evolution](../../docs/meta/industry_best_practices.md#14-delivery--evolution)
|
|
4
|
+
**Tags**: #operational #lifecycle #change
|
|
5
|
+
**Related**: [OCP](CONS-00002-ocp.md), [Orthogonality](CONS-00022-orthogonality.md)
|
|
6
|
+
|
|
7
|
+
## Definition
|
|
8
|
+
|
|
9
|
+
The ease with which the system can be adapted to new requirements or modified to fix defects over time.
|
|
10
|
+
|
|
11
|
+
## Requirements
|
|
12
|
+
|
|
13
|
+
1. **Testability**: Code must be designed to be tested (Dependency Injection).
|
|
14
|
+
2. **Feature Flags**: Decouple deployment from release to allow safe evolution.
|
|
15
|
+
3. **Versioning**: Public APIs must be strictly versioned.
|
|
16
|
+
|
|
17
|
+
## Anti-Patterns
|
|
18
|
+
|
|
19
|
+
- **Big Bang Rewrites**: "We can't change this without rewriting everything."
|
|
20
|
+
- **Hardcoded Configuration**: Magic numbers or URLs buried in code.
|
|
21
|
+
|
|
22
|
+
## Examples
|
|
23
|
+
|
|
24
|
+
**Bad:**
|
|
25
|
+
|
|
26
|
+
```text
|
|
27
|
+
API_URL = "https://example.com" # hardcoded
|
|
28
|
+
client = new_client(API_URL)
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
**Good:**
|
|
32
|
+
|
|
33
|
+
```text
|
|
34
|
+
API_URL = config["API_URL"]
|
|
35
|
+
client = new_client(API_URL)
|
|
36
|
+
```
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Operability (CONS-00029)
|
|
2
|
+
|
|
3
|
+
**Source**: [Observability & Operations](../../docs/meta/industry_best_practices.md#11-observability--operations)
|
|
4
|
+
**Tags**: #operational #lifecycle #runnability
|
|
5
|
+
**Related**: [Transparency](CONS-00027-transparency.md), [Checklist](CONS-00031-checklist.md)
|
|
6
|
+
|
|
7
|
+
## Definition
|
|
8
|
+
|
|
9
|
+
The ease with which the system can be run, monitored, and maintained by the engineering team.
|
|
10
|
+
|
|
11
|
+
## Requirements
|
|
12
|
+
|
|
13
|
+
1. **Runbooks**: Every alert must map to a documented procedure.
|
|
14
|
+
2. **Congruence**: Team boundaries must match architectural boundaries to ensure clear ownership.
|
|
15
|
+
3. **Automation**: Rote maintenance tasks (backups, cert renewal) must be automated.
|
|
16
|
+
|
|
17
|
+
## Anti-Patterns
|
|
18
|
+
|
|
19
|
+
- **Hero Culture**: Only one person knows how to restart the server.
|
|
20
|
+
- **Manual Deployment**: "SSH and git pull."
|
|
21
|
+
|
|
22
|
+
## Examples
|
|
23
|
+
|
|
24
|
+
**Bad:**
|
|
25
|
+
|
|
26
|
+
```text
|
|
27
|
+
# TODO: restart manually when memory > threshold
|
|
28
|
+
# (no automation)
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
**Good:**
|
|
32
|
+
|
|
33
|
+
```text
|
|
34
|
+
restart_policy = "on-failure"
|
|
35
|
+
health_check = enabled
|
|
36
|
+
```
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# The Rework Cycle (CONS-00030)
|
|
2
|
+
|
|
3
|
+
**Source**: [System Dynamics](../../docs/meta/industry_best_practices.md#53-the-rework-cycle)
|
|
4
|
+
**Tags**: #operational #process #velocity #feedback
|
|
5
|
+
**Related**: [Shift Left](CONS-00020-shift-left.md), [Safety](CONS-00015-safety.md)
|
|
6
|
+
|
|
7
|
+
## Definition
|
|
8
|
+
|
|
9
|
+
The primary killer of velocity is "Unknown Rework"—work marked "done" that contains hidden defects.
|
|
10
|
+
|
|
11
|
+
## Requirements
|
|
12
|
+
|
|
13
|
+
1. **Debt Paydown**: Prioritize refactoring ("Corrective Gains") to keep the rework fraction low.
|
|
14
|
+
2. **Fast Feedback**: Verification must happen immediately (CI/CD) to convert Unknown Rework to Known Rework.
|
|
15
|
+
|
|
16
|
+
## Anti-Patterns
|
|
17
|
+
|
|
18
|
+
- **The Death Spiral**: Ignoring bugs to meet a deadline, creating more bugs.
|
|
19
|
+
- **Late Testing**: QA happens only at the end of the sprint.
|
|
20
|
+
|
|
21
|
+
## Examples
|
|
22
|
+
|
|
23
|
+
**Bad:**
|
|
24
|
+
"We'll write tests next sprint."
|
|
25
|
+
|
|
26
|
+
**Good:**
|
|
27
|
+
"I can't merge this until the tests pass."
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# The Checklist (CONS-00031)
|
|
2
|
+
|
|
3
|
+
**Source**: [The Checklist Manifesto](../../docs/meta/industry_best_practices.md#44-the-checklist)
|
|
4
|
+
**Tags**: #operational #process #rigor #automation
|
|
5
|
+
**Related**: [Operability](CONS-00029-operability.md), [Safety](CONS-00015-safety.md)
|
|
6
|
+
|
|
7
|
+
## Definition
|
|
8
|
+
|
|
9
|
+
Rote verification should be offloaded to machines. Humans are fallible; checklists are consistent.
|
|
10
|
+
|
|
11
|
+
## Requirements
|
|
12
|
+
|
|
13
|
+
1. **Automation**: Formatting, linting, and imports must be automated (e.g., Pre-commit hooks).
|
|
14
|
+
2. **Cognitive Offloading**: Humans should never have to manually check something a machine can check.
|
|
15
|
+
3. **Standardization**: We do things the same way every time to reduce mental load.
|
|
16
|
+
|
|
17
|
+
## Anti-Patterns
|
|
18
|
+
|
|
19
|
+
- **Manual Nits**: Reviewer commenting "missing semicolon."
|
|
20
|
+
- **Memory-Based Process**: "Oh, I forgot to run the migration script manually."
|
|
21
|
+
|
|
22
|
+
## Examples
|
|
23
|
+
|
|
24
|
+
**Bad:**
|
|
25
|
+
A PR review comment: "Please sort these imports."
|
|
26
|
+
|
|
27
|
+
**Good:**
|
|
28
|
+
A CI job fails: "Lint check failed. Run the lint auto-fix command."
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Documentation & Comments (CONS-00032)
|
|
2
|
+
|
|
3
|
+
**Source**: [Literate Programming](../../docs/meta/industry_best_practices.md#26-comment-the-why-not-the-how)
|
|
4
|
+
**Tags**: #operational #maintenance #readability
|
|
5
|
+
**Related**: [Clean Packages](CONS-00009-deep-modules.md)
|
|
6
|
+
|
|
7
|
+
## Definition
|
|
8
|
+
|
|
9
|
+
Code tells you _how_; comments tell you _why_. Documentation bridges the gap between intent and implementation.
|
|
10
|
+
|
|
11
|
+
## Requirements
|
|
12
|
+
|
|
13
|
+
1. **The "Why" Rule**: Comments must explain the intent, context, or constraints, not the syntax.
|
|
14
|
+
2. **Public API**: Every public symbol (exported function/class) must have a docstring.
|
|
15
|
+
3. **No Noise**: Do not add comments that merely restate the code (e.g., delimiters like `// end of function`).
|
|
16
|
+
|
|
17
|
+
## Anti-Patterns
|
|
18
|
+
|
|
19
|
+
- **Echo Comments**: `i++ // increment i`.
|
|
20
|
+
- **Superficial Delimiters**: `// --- Helper Functions ---` or `// Act`.
|
|
21
|
+
- **Ghost Docs**: Comments describing parameters that were deleted months ago.
|
|
22
|
+
|
|
23
|
+
## Examples
|
|
24
|
+
|
|
25
|
+
**Bad:**
|
|
26
|
+
|
|
27
|
+
```text
|
|
28
|
+
# Loop through users
|
|
29
|
+
for each user in users:
|
|
30
|
+
...
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**Good:**
|
|
34
|
+
|
|
35
|
+
```text
|
|
36
|
+
# Filter out inactive users to prevent billing inactive accounts
|
|
37
|
+
for each user in users:
|
|
38
|
+
...
|
|
39
|
+
```
|