@homericintelligence/athena-opencode 0.5.0 → 0.5.1
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/README.md +30 -17
- package/package.json +2 -2
- package/plugin.js +20 -5
- package/skills/TECHNICAL_ENGLISH.md +78 -0
- package/skills/_cli.py +26 -18
- package/skills/_support/docs/dependency-resolution.md +192 -0
- package/skills/_support/docs/policies/development.md +117 -0
- package/skills/_support/docs/policies/evidence-integrity.md +40 -0
- package/skills/_support/docs/principles/README.md +542 -0
- package/skills/_support/docs/principles/details/p001-kiss.md +114 -0
- package/skills/_support/docs/principles/details/p002-yagni.md +109 -0
- package/skills/_support/docs/principles/details/p003-dry.md +126 -0
- package/skills/_support/docs/principles/details/p004-solid.md +165 -0
- package/skills/_support/docs/principles/details/p005-modularity.md +123 -0
- package/skills/_support/docs/principles/details/p006-principle-of-least-astonishment.md +115 -0
- package/skills/_support/docs/principles/details/p007-subtraction-over-addition.md +113 -0
- package/skills/_support/docs/principles/details/p008-understand-before-subtracting.md +115 -0
- package/skills/_support/docs/principles/details/p009-general-mechanisms-over-special-cases.md +108 -0
- package/skills/_support/docs/principles/details/p010-scope-fidelity.md +117 -0
- package/skills/_support/docs/principles/details/p011-minimal-coherent-change.md +128 -0
- package/skills/_support/docs/principles/details/p012-evidence-before-modification.md +115 -0
- package/skills/_support/docs/principles/details/p013-avoid-hasty-abstractions.md +112 -0
- package/skills/_support/docs/principles/details/p014-preserve-unrequested-behavior.md +110 -0
- package/skills/_support/docs/principles/details/p015-architecture-conformance.md +124 -0
- package/skills/_support/docs/principles/details/p016-separation-of-concerns.md +125 -0
- package/skills/_support/docs/principles/details/p017-high-cohesion-low-coupling.md +130 -0
- package/skills/_support/docs/principles/details/p018-information-hiding.md +128 -0
- package/skills/_support/docs/principles/details/p019-explicit-contracts.md +134 -0
- package/skills/_support/docs/principles/details/p020-executable-architecture.md +130 -0
- package/skills/_support/docs/principles/details/p021-evolutionary-and-reversible-design.md +126 -0
- package/skills/_support/docs/principles/details/p022-test-behavior-not-implementation.md +129 -0
- package/skills/_support/docs/principles/details/p023-parameterized-table-driven-testing.md +129 -0
- package/skills/_support/docs/principles/details/p024-boundary-value-testing.md +128 -0
- package/skills/_support/docs/principles/details/p025-property-based-testing-for-invariants.md +133 -0
- package/skills/_support/docs/principles/details/p026-regression-before-repair.md +134 -0
- package/skills/_support/docs/principles/details/p027-deterministic-and-hermetic-tests.md +128 -0
- package/skills/_support/docs/principles/details/p028-test-failure-paths.md +133 -0
- package/skills/_support/docs/principles/details/p029-generalize-error-policy-preserve-specific-cause.md +131 -0
- package/skills/_support/docs/principles/details/p030-nearest-responsible-error-boundary.md +133 -0
- package/skills/_support/docs/principles/details/p031-propagate-rather-than-swallow.md +131 -0
- package/skills/_support/docs/principles/details/p032-handle-once-preserve-causality.md +137 -0
- package/skills/_support/docs/principles/details/p033-state-safe-failure-semantics.md +140 -0
- package/skills/_support/docs/principles/details/p034-fail-fast.md +132 -0
- package/skills/_support/docs/principles/details/p035-fail-secure-fail-closed.md +137 -0
- package/skills/_support/docs/principles/details/p036-graceful-degradation.md +137 -0
- package/skills/_support/docs/principles/details/p037-idempotency-before-retry.md +139 -0
- package/skills/_support/docs/principles/details/p038-bounded-retry.md +145 -0
- package/skills/_support/docs/principles/details/p039-bounded-waiting.md +151 -0
- package/skills/_support/docs/principles/details/p040-bounded-resources.md +138 -0
- package/skills/_support/docs/principles/details/p041-backpressure-and-load-shedding.md +141 -0
- package/skills/_support/docs/principles/details/p042-fault-isolation-bulkheads.md +140 -0
- package/skills/_support/docs/principles/details/p043-circuit-breakers.md +148 -0
- package/skills/_support/docs/principles/details/p044-atomicity-where-possible.md +141 -0
- package/skills/_support/docs/principles/details/p045-compensation-where-atomicity-is-impossible.md +163 -0
- package/skills/_support/docs/principles/details/p046-resumability.md +138 -0
- package/skills/_support/docs/principles/details/p047-observability-is-part-of-correctness.md +134 -0
- package/skills/_support/docs/principles/details/p048-secure-by-design.md +132 -0
- package/skills/_support/docs/principles/details/p049-secure-by-default.md +126 -0
- package/skills/_support/docs/principles/details/p050-least-privilege.md +123 -0
- package/skills/_support/docs/principles/details/p051-complete-mediation.md +124 -0
- package/skills/_support/docs/principles/details/p052-separation-of-duties.md +129 -0
- package/skills/_support/docs/principles/details/p053-validate-at-trust-boundaries.md +126 -0
- package/skills/_support/docs/principles/details/p054-defense-in-depth.md +135 -0
- package/skills/_support/docs/principles/details/p055-minimize-attack-surface.md +133 -0
- package/skills/_support/docs/principles/details/p056-secrets-stay-out-of-code-and-context.md +137 -0
- package/skills/_support/docs/principles/details/p057-supply-chain-integrity.md +135 -0
- package/skills/_support/docs/principles/details/p058-bounded-agent-authority.md +137 -0
- package/skills/_support/docs/principles/details/p059-data-is-not-instruction.md +130 -0
- package/skills/_support/docs/principles/details/p060-constrain-sub-agents.md +136 -0
- package/skills/_support/docs/principles/details/p061-separate-decision-from-high-impact-execution.md +131 -0
- package/skills/_support/docs/principles/details/p062-human-approval-for-irreversible-or-high-risk-actions.md +129 -0
- package/skills/_support/docs/principles/details/p063-requirement-to-code-traceability.md +116 -0
- package/skills/_support/docs/principles/details/p064-requirement-to-test-traceability.md +116 -0
- package/skills/_support/docs/principles/details/p065-verify-before-claiming-completion.md +129 -0
- package/skills/_support/docs/principles/details/p066-preserve-existing-work.md +114 -0
- package/skills/_support/docs/principles/details/p067-no-test-cheating.md +126 -0
- package/skills/_support/docs/principles/details/p068-no-validation-bypass.md +119 -0
- package/skills/_support/docs/principles/details/p069-independent-review-for-high-risk-changes.md +129 -0
- package/skills/_support/docs/principles/details/p070-code-health-must-not-regress.md +116 -0
- package/skills/_support/docs/principles/details/p071-consistency-over-personal-preference.md +117 -0
- package/skills/_support/docs/principles/details/p072-technical-evidence-over-preference.md +122 -0
- package/skills/_support/docs/principles/details/p073-optimize-only-with-evidence.md +123 -0
- package/skills/_support/docs/principles/details/p074-prefer-existing-mechanisms.md +121 -0
- package/skills/_support/docs/principles/details/p075-make-invalid-states-hard-to-represent.md +128 -0
- package/skills/_support/docs/principles/details/p076-parse-then-validate-then-operate.md +133 -0
- package/skills/_support/docs/principles/details/p077-separate-policy-from-mechanism.md +112 -0
- package/skills/_support/docs/principles/details/p078-single-source-of-truth.md +131 -0
- package/skills/_support/docs/principles/details/p079-explicit-ownership-and-lifetimes.md +124 -0
- package/skills/_support/docs/principles/details/p080-make-concurrency-deliberate.md +122 -0
- package/skills/_support/docs/principles/details/p081-forward-progress-with-safety.md +125 -0
- package/skills/_support/docs/principles/details/p082-design-for-cancellation.md +133 -0
- package/skills/_support/docs/principles/details/p083-irreversible-actions-last.md +124 -0
- package/skills/_support/docs/principles/details/p084-prefer-local-reasoning.md +131 -0
- package/skills/_support/docs/principles/details/p085-explicit-is-better-than-implicit.md +123 -0
- package/skills/_support/docs/principles/details/p086-readability-counts.md +113 -0
- package/skills/_support/docs/principles/details/p087-comments-explain-why-code-explains-what.md +120 -0
- package/skills/_support/docs/principles/details/p088-delete-dead-code.md +125 -0
- package/skills/_support/docs/principles/details/p089-delete-obsolete-configuration-and-dependencies.md +125 -0
- package/skills/_support/docs/principles/details/p090-prefer-negative-code.md +134 -0
- package/skills/_support/docs/principles/details/p091-test-driven-development.md +149 -0
- package/skills/_support/docs/review/README.md +59 -0
- package/skills/_support/docs/review/behavior-first-testing.md +73 -0
- package/skills/_support/docs/review/common.md +365 -0
- package/skills/_support/docs/review/design-docs.md +74 -0
- package/skills/_support/docs/review/issue-planning.md +220 -0
- package/skills/_support/docs/review/language-routing.md +141 -0
- package/skills/_support/docs/review/repository-scorecard.md +170 -0
- package/skills/advise/SKILL.md +93 -67
- package/skills/advise/scripts/list_retrievable_skills.py +3 -3
- package/skills/brainstorm/SKILL.md +160 -127
- package/skills/change-review/SKILL.md +91 -71
- package/skills/change-review/references/scope-resolution.md +69 -46
- package/skills/change-review/scripts/resolve_scope.py +119 -73
- package/skills/finalize-plan/SKILL.md +198 -139
- package/skills/git-worktrees/SKILL.md +100 -80
- package/skills/git-worktrees/scripts/prepare_worktree.py +16 -10
- package/skills/issue-review/SKILL.md +136 -79
- package/skills/learn/SKILL.md +276 -186
- package/skills/myrmidon-swarm/SKILL.md +126 -86
- package/skills/plan-issue/SKILL.md +122 -81
- package/skills/pr-review/SKILL.md +164 -114
- package/skills/pr-review/references/criteria.md +58 -37
- package/skills/pr-review/references/delivery.md +156 -98
- package/skills/pr-review/references/evidence.md +265 -148
- package/skills/pr-review/references/prevalidated.md +93 -61
- package/skills/pr-review/scripts/collect_evidence.py +211 -140
- package/skills/pr-review/scripts/diff_context.py +6 -4
- package/skills/pr-review/scripts/materialize_snapshot.py +112 -120
- package/skills/pr-review/scripts/pr_identity.py +27 -15
- package/skills/pr-review/scripts/resolve_pr.py +53 -31
- package/skills/repo-review/SKILL.md +202 -131
- package/skills/systematic-debugging/SKILL.md +210 -192
- package/skills/systematic-debugging/scripts/repository_evidence.py +9 -4
- package/skills/test-driven-development/SKILL.md +126 -96
- package/skills/tidy/SKILL.md +92 -59
- package/skills/tidy/scripts/run_tidy.py +3 -3
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# P070 — Code Health Must Not Regress
|
|
2
|
+
|
|
3
|
+
## Definition
|
|
4
|
+
|
|
5
|
+
A correct local result does not prove the quality of the full change. Without a necessary technical
|
|
6
|
+
basis, a change must not decrease clarity, maintenance quality, test quality, operation
|
|
7
|
+
quality, adaptability, or security. Use incremental improvement. Prevent code decay. Do not make
|
|
8
|
+
perfection necessary.
|
|
9
|
+
|
|
10
|
+
**Aliases:** leave the codebase no worse, continuous code-health improvement.
|
|
11
|
+
|
|
12
|
+
## Provenance
|
|
13
|
+
|
|
14
|
+
**Classification:** practitioner heuristic.
|
|
15
|
+
|
|
16
|
+
This rule agrees with Google's published code-review standard. Many practitioners use related
|
|
17
|
+
"leave it better" heuristics. No verified source has exclusive ownership of the full heuristic.
|
|
18
|
+
|
|
19
|
+
## Decision rule
|
|
20
|
+
|
|
21
|
+
When a change completes necessary work without a material loss of code health, accept it although
|
|
22
|
+
it is not perfect. When a design has an unnecessary code-health cost that is more than its scoped
|
|
23
|
+
benefit, revise it. If a revision cannot remove that cost, reject the design. Examine maintenance,
|
|
24
|
+
complexity, test quality, operation, and security costs.
|
|
25
|
+
|
|
26
|
+
## How to apply
|
|
27
|
+
|
|
28
|
+
- Examine design, complexity, tests, naming, documentation, operation, and security in context.
|
|
29
|
+
- Prevent a system-wide decrease in code health from a sequence of small local compromises.
|
|
30
|
+
- Distinguish necessary corrections from optional style changes. Identify optional suggestions
|
|
31
|
+
clearly.
|
|
32
|
+
- Use small, coherent changes that are easy to review, revert, and make better.
|
|
33
|
+
- When you accept debt, document its necessity, owner, risk, and repair trigger.
|
|
34
|
+
|
|
35
|
+
## Diagram
|
|
36
|
+
|
|
37
|
+
```mermaid
|
|
38
|
+
flowchart TD
|
|
39
|
+
A["Specify necessary change"] --> B["Select narrow design"]
|
|
40
|
+
B --> C["Examine system-wide code health"]
|
|
41
|
+
C --> D{"Material regression without a necessary basis?"}
|
|
42
|
+
D -- "Yes" --> E["Revise design or decrease scope"]
|
|
43
|
+
E --> C
|
|
44
|
+
D -- "No" --> F{"Temporary debt necessary?"}
|
|
45
|
+
F -- "Yes" --> G["Record owner, risk, and repair trigger"]
|
|
46
|
+
F -- "No" --> H["Accept change"]
|
|
47
|
+
G --> H
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Language examples
|
|
51
|
+
|
|
52
|
+
The two examples add one clear data transformation with clear names and no new framework.
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
def visible_tasks(tasks):
|
|
56
|
+
eligible = [task for task in tasks if task.active]
|
|
57
|
+
ordered = sorted(eligible, key=lambda task: task.priority)
|
|
58
|
+
return [task.title for task in ordered]
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
```rust
|
|
62
|
+
fn visible_tasks(tasks: &[Task]) -> Vec<&str> {
|
|
63
|
+
let mut eligible: Vec<_> = tasks.iter().filter(|task| task.active).collect();
|
|
64
|
+
eligible.sort_by_key(|task| task.priority);
|
|
65
|
+
eligible.iter().map(|task| task.title.as_str()).collect()
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Boundaries and tensions
|
|
70
|
+
|
|
71
|
+
This principle does not authorize cleanup that is not part of the task or style changes that are not
|
|
72
|
+
necessary. It does not make perfect code necessary before delivery.
|
|
73
|
+
[P010 Scope Fidelity](p010-scope-fidelity.md) continues to limit the change. An emergency can make a
|
|
74
|
+
recorded temporary compromise necessary. A local convention does not authorize extension of a known
|
|
75
|
+
defect. Repository-wide repair can belong to a different task.
|
|
76
|
+
|
|
77
|
+
## Examples
|
|
78
|
+
|
|
79
|
+
**Positive:** A small feature uses the established interface and adds focused tests. It also makes
|
|
80
|
+
one name in the changed area clearer without a large refactor.
|
|
81
|
+
|
|
82
|
+
**Misuse:** A second copy duplicates security policy because a change to the canonical component has
|
|
83
|
+
a larger scope.
|
|
84
|
+
|
|
85
|
+
**Athena/agent workflow:** A reviewer separates a necessary contract-drift finding from an optional
|
|
86
|
+
preference. This distinction protects the skill corpus without an expansion of task scope.
|
|
87
|
+
|
|
88
|
+
## Related principles
|
|
89
|
+
|
|
90
|
+
- [P010 Scope Fidelity](p010-scope-fidelity.md)
|
|
91
|
+
- [P011 Minimal Coherent Change](p011-minimal-coherent-change.md)
|
|
92
|
+
- [P065 Verify Before Claiming Completion](p065-verify-before-claiming-completion.md)
|
|
93
|
+
- [P071 Consistency Over Personal Preference](p071-consistency-over-personal-preference.md)
|
|
94
|
+
- [P072 Technical Evidence Over Preference](p072-technical-evidence-over-preference.md)
|
|
95
|
+
|
|
96
|
+
## References
|
|
97
|
+
|
|
98
|
+
### Source information
|
|
99
|
+
|
|
100
|
+
- [Google Engineering Practices: The standard of code review](https://google.github.io/eng-practices/review/reviewer/standard.html)
|
|
101
|
+
is the primary practitioner source for code health as the primary review purpose. This page
|
|
102
|
+
does not identify all earlier sources.
|
|
103
|
+
|
|
104
|
+
### Applicable information
|
|
105
|
+
|
|
106
|
+
- [Google Engineering Practices: What to look for in a code review](https://google.github.io/eng-practices/review/reviewer/looking-for.html)
|
|
107
|
+
applies code health to design, function, complexity, tests, names, comments, style, and
|
|
108
|
+
documentation.
|
|
109
|
+
|
|
110
|
+
### More information
|
|
111
|
+
|
|
112
|
+
- [Google Engineering Practices: Small CLs](https://google.github.io/eng-practices/review/developer/small-cls.html)
|
|
113
|
+
shows that narrow changes increase review depth and design quality. Narrow changes also make
|
|
114
|
+
reversal and maintenance easier.
|
|
115
|
+
|
|
116
|
+
[Back to the engineering principles catalog](../README.md#p070)
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# P071 — Consistency Over Personal Preference
|
|
2
|
+
|
|
3
|
+
## Definition
|
|
4
|
+
|
|
5
|
+
When more than one correct alternative is available, obey established repository conventions,
|
|
6
|
+
style guides, patterns, terms, and architecture. If a different correct style is only a personal
|
|
7
|
+
preference, do not rewrite correct code.
|
|
8
|
+
|
|
9
|
+
**Aliases:** local consistency, convention over personal preference.
|
|
10
|
+
|
|
11
|
+
## Provenance
|
|
12
|
+
|
|
13
|
+
**Classification:** practitioner heuristic.
|
|
14
|
+
|
|
15
|
+
Language and project style guides use consistency rules. No verified source owns the practice. This
|
|
16
|
+
rule uses consistency to select between equivalent alternatives. Consistency does not give authority
|
|
17
|
+
to keep defects.
|
|
18
|
+
|
|
19
|
+
## Decision rule
|
|
20
|
+
|
|
21
|
+
When more than one method satisfies the same requirements, first compare the technical evidence.
|
|
22
|
+
If the evidence shows no material difference, use the repository's established method. If
|
|
23
|
+
evidence shows a material difference, apply
|
|
24
|
+
[P072 Technical Evidence](p072-technical-evidence-over-preference.md).
|
|
25
|
+
|
|
26
|
+
## How to apply
|
|
27
|
+
|
|
28
|
+
- Read repository instructions, code in the same area, public contracts, and active architecture
|
|
29
|
+
decisions.
|
|
30
|
+
- Use established terminology, layout, error conventions, test style, and extension mechanisms.
|
|
31
|
+
- When the feature does not make modernization or formatting necessary, put that work in a
|
|
32
|
+
different change.
|
|
33
|
+
- Propose clear convention changes. Apply accepted changes to all applicable code.
|
|
34
|
+
- Record the technical basis for a convention exception.
|
|
35
|
+
|
|
36
|
+
## Diagram
|
|
37
|
+
|
|
38
|
+
```mermaid
|
|
39
|
+
flowchart TD
|
|
40
|
+
A["Identify correct alternatives"] --> B{"Does evidence show that one alternative is better?"}
|
|
41
|
+
B -- "Yes" --> C["Select evidence-supported alternative"]
|
|
42
|
+
B -- "No" --> D["Examine repository convention"]
|
|
43
|
+
D --> E{"Convention is safe and current?"}
|
|
44
|
+
E -- "Yes" --> F["Use established convention"]
|
|
45
|
+
E -- "No" --> G["Propose clear convention change"]
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Language examples
|
|
49
|
+
|
|
50
|
+
The two examples use the established `api_response` helper and its standard envelope.
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
def create_user(request):
|
|
54
|
+
user = User.from_request(request)
|
|
55
|
+
payload = user.to_dict()
|
|
56
|
+
return api_response(payload, status=201)
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
```rust
|
|
60
|
+
fn create_user(request: Request) -> Response {
|
|
61
|
+
let user = User::from_request(request);
|
|
62
|
+
let payload = user.to_map();
|
|
63
|
+
api_response(payload, Status::Created)
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Boundaries and tensions
|
|
68
|
+
|
|
69
|
+
Correctness, security, accessibility, specified requirements, and measured evidence have higher
|
|
70
|
+
priority than consistency. When code in the same area contains a known vulnerability or invalid
|
|
71
|
+
pattern, do not reproduce it. A repository can have an active transition between conventions.
|
|
72
|
+
Then, obey the documented direction, not the style that occurs most frequently. Consistency protects
|
|
73
|
+
reader expectations. It does not make the same appearance necessary at all costs.
|
|
74
|
+
|
|
75
|
+
## Examples
|
|
76
|
+
|
|
77
|
+
**Positive:** Two serialization approaches are equally correct. Thus, a new endpoint uses the
|
|
78
|
+
repository serializer and error envelope.
|
|
79
|
+
|
|
80
|
+
**Misuse:** A contributor rewrites a full module with a different name and format style in one
|
|
81
|
+
small behavior change.
|
|
82
|
+
|
|
83
|
+
**Athena/agent workflow:** A skill author obeys Athena's host-neutral terms and section
|
|
84
|
+
conventions. The author does not introduce vendor-specific terms for the same capability.
|
|
85
|
+
|
|
86
|
+
## Related principles
|
|
87
|
+
|
|
88
|
+
- [P006 Principle of Least Astonishment](p006-principle-of-least-astonishment.md)
|
|
89
|
+
- [P014 Preserve Unrequested Behavior](p014-preserve-unrequested-behavior.md)
|
|
90
|
+
- [P015 Architecture Conformance](p015-architecture-conformance.md)
|
|
91
|
+
- [P070 Code Health Must Not Regress](p070-code-health-must-not-regress.md)
|
|
92
|
+
- [P072 Technical Evidence Over Preference](p072-technical-evidence-over-preference.md)
|
|
93
|
+
|
|
94
|
+
## References
|
|
95
|
+
|
|
96
|
+
### Source information
|
|
97
|
+
|
|
98
|
+
- [PEP 8: A Foolish Consistency Is the Hobgoblin of Little Minds](https://peps.python.org/pep-0008/#a-foolish-consistency-is-the-hobgoblin-of-little-minds)
|
|
99
|
+
is a language guide with a long history. It gives priority to project consistency and gives rules
|
|
100
|
+
for exceptions with technical evidence. This page does not claim it as the initial source for the
|
|
101
|
+
full heuristic.
|
|
102
|
+
|
|
103
|
+
### Applicable information
|
|
104
|
+
|
|
105
|
+
- [Google Go Style Guide: Local consistency](https://google.github.io/styleguide/go/guide.html#local-consistency)
|
|
106
|
+
uses local convention to select between equal alternatives. It rejects consistency that extends a
|
|
107
|
+
defect or violates a stronger rule.
|
|
108
|
+
- [Google Engineering Practices: The standard of code review](https://google.github.io/eng-practices/review/reviewer/standard.html)
|
|
109
|
+
gives style guides higher priority than personal preference. The guide gives technical facts
|
|
110
|
+
higher priority than style guides and personal preference.
|
|
111
|
+
|
|
112
|
+
### More information
|
|
113
|
+
|
|
114
|
+
- [Google JavaScript Style Guide: Reformatting existing code](https://google.github.io/styleguide/jsguide.html#policies-reformatting-existing-code)
|
|
115
|
+
shows the trade-off between consistency, code churn, and change focus.
|
|
116
|
+
|
|
117
|
+
[Back to the engineering principles catalog](../README.md#p071)
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# P072 — Technical Evidence Over Preference
|
|
2
|
+
|
|
3
|
+
## Definition
|
|
4
|
+
|
|
5
|
+
Use requirements, specifications, measurements, tests, profiles, architecture, and established
|
|
6
|
+
engineering principles to resolve technical decisions. When applicable evidence shows that one
|
|
7
|
+
alternative is better, do not use personal preference. Personal preference can select between
|
|
8
|
+
alternatives that the evidence shows are equivalent for the decision.
|
|
9
|
+
|
|
10
|
+
**Aliases:** facts over opinions, evidence-based engineering judgment.
|
|
11
|
+
|
|
12
|
+
## Provenance
|
|
13
|
+
|
|
14
|
+
**Classification:** practitioner heuristic.
|
|
15
|
+
|
|
16
|
+
Evidence-based decisions have scientific and engineering roots in many fields. No verified software
|
|
17
|
+
source owns the idea. Google's code-review guidance states the rule for review disputes. Athena
|
|
18
|
+
applies the rule to plans, implementation, validation, and review.
|
|
19
|
+
|
|
20
|
+
## Decision rule
|
|
21
|
+
|
|
22
|
+
When approaches conflict, identify applicable evidence. Examine its quality. Select the alternative
|
|
23
|
+
that agrees with trusted requirements and technical evidence. If there are equivalent
|
|
24
|
+
alternatives, use established convention or the responsible author's preference.
|
|
25
|
+
|
|
26
|
+
## How to apply
|
|
27
|
+
|
|
28
|
+
- State the disputed claim and the observation that can distinguish the alternatives.
|
|
29
|
+
- Compare evidence for relevance, trustworthiness, reproducibility, and applicability to the
|
|
30
|
+
workload.
|
|
31
|
+
- Use accepted requirements and specifications, not reports without evidence or author preference.
|
|
32
|
+
- When the environment changes behavior, use representative tests, benchmarks, and production data.
|
|
33
|
+
- For use in a future decision, record important evidence and uncertainty.
|
|
34
|
+
|
|
35
|
+
## Diagram
|
|
36
|
+
|
|
37
|
+
```mermaid
|
|
38
|
+
flowchart TD
|
|
39
|
+
A["State disputed technical claim"] --> B["Identify necessary observation"]
|
|
40
|
+
B --> C["Collect trusted applicable evidence"]
|
|
41
|
+
C --> D{"Does evidence show that one alternative is better?"}
|
|
42
|
+
D -- "Yes" --> E["Select supported alternative"]
|
|
43
|
+
D -- "No" --> F{"Alternatives equivalent for decision?"}
|
|
44
|
+
F -- "Yes" --> G["Use convention or owner preference"]
|
|
45
|
+
F -- "No" --> H["Record uncertainty and collect more evidence"]
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Language examples
|
|
49
|
+
|
|
50
|
+
The two examples select a parser from measurements of representative samples.
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
def choose_parser(samples):
|
|
54
|
+
results = [
|
|
55
|
+
(measure(parser, samples), parser) for parser in PARSERS
|
|
56
|
+
]
|
|
57
|
+
return min(results, key=lambda item: item[0])[1]
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
```rust
|
|
61
|
+
fn choose_parser(samples: &[Input]) -> &'static Parser {
|
|
62
|
+
let measured: Vec<_> = PARSERS
|
|
63
|
+
.iter()
|
|
64
|
+
.map(|parser| (measure(parser, samples), parser))
|
|
65
|
+
.collect();
|
|
66
|
+
measured
|
|
67
|
+
.into_iter()
|
|
68
|
+
.min_by_key(|(cost, _)| *cost)
|
|
69
|
+
.expect("PARSERS is not empty").1
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Boundaries and tensions
|
|
74
|
+
|
|
75
|
+
Measurements and tests can be stale, biased, or applicable to an incorrect contract. Measurements
|
|
76
|
+
can also have missing data. Examine evidence quality, not evidence quantity. Architecture and
|
|
77
|
+
principles give a basis for judgment but do not override a specified higher-priority requirement.
|
|
78
|
+
When stronger evidence does not show that one alternative is better, use
|
|
79
|
+
[P071 Consistency](p071-consistency-over-personal-preference.md). If there is no data, risk is
|
|
80
|
+
possible.
|
|
81
|
+
|
|
82
|
+
## Examples
|
|
83
|
+
|
|
84
|
+
**Positive:** Representative profiles identify serialization as the latency bottleneck. The team
|
|
85
|
+
optimizes that path, not a low-cost component.
|
|
86
|
+
|
|
87
|
+
**Misuse:** A reviewer blocks a correct, established implementation because a different syntax
|
|
88
|
+
"feels cleaner." The reviewer gives no contract, measurement, or design effect.
|
|
89
|
+
|
|
90
|
+
**Athena/agent workflow:** An agent finds a conflict between repository prose and executable
|
|
91
|
+
behavior. Before the agent proposes a change, it examines history, validators, tests, and current
|
|
92
|
+
policy.
|
|
93
|
+
|
|
94
|
+
## Related principles
|
|
95
|
+
|
|
96
|
+
- [P012 Evidence Before Modification](p012-evidence-before-modification.md)
|
|
97
|
+
- [P063 Requirement-to-Code Traceability](p063-requirement-to-code-traceability.md)
|
|
98
|
+
- [P065 Verify Before Claiming Completion](p065-verify-before-claiming-completion.md)
|
|
99
|
+
- [P071 Consistency Over Personal Preference](p071-consistency-over-personal-preference.md)
|
|
100
|
+
- [P073 Optimize Only With Evidence](p073-optimize-only-with-evidence.md)
|
|
101
|
+
|
|
102
|
+
## References
|
|
103
|
+
|
|
104
|
+
### Source information
|
|
105
|
+
|
|
106
|
+
- [Google Engineering Practices: The standard of code review](https://google.github.io/eng-practices/review/reviewer/standard.html)
|
|
107
|
+
states that technical facts and data have higher priority than opinions and personal preferences.
|
|
108
|
+
This page does not claim it as the initial source.
|
|
109
|
+
|
|
110
|
+
### Applicable information
|
|
111
|
+
|
|
112
|
+
- [NASA SWE-194: Delivery Requirements Verification](https://swehb.nasa.gov/spaces/SWEHBVD/pages/102695529/SWE-194%2B-%2BDelivery%2BRequirements%2BVerification)
|
|
113
|
+
links acceptance evidence to requirements, test results, and recorded verification.
|
|
114
|
+
- [NIST SSDF 1.1](https://csrc.nist.gov/pubs/sp/800/218/final) gives risk-based secure-development
|
|
115
|
+
and verification practices with specified outcomes.
|
|
116
|
+
|
|
117
|
+
### More information
|
|
118
|
+
|
|
119
|
+
- [Athena evidence integrity policy](../../policies/evidence-integrity.md) specifies how repository
|
|
120
|
+
evidence claims must identify reproducible commands, revisions, environments, and recorded output.
|
|
121
|
+
|
|
122
|
+
[Back to the engineering principles catalog](../README.md#p072)
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# P073 — Optimize Only With Evidence
|
|
2
|
+
|
|
3
|
+
## Definition
|
|
4
|
+
|
|
5
|
+
If evidence does not identify an applicable constraint, do not add a cache, concurrency, batch
|
|
6
|
+
process, or specialized data structure. Apply this rule to low-level tuning and architecture
|
|
7
|
+
complexity. Measure a representative baseline. Find the bottleneck. Optimize that bottleneck. Then
|
|
8
|
+
verify the improvement and correctness.
|
|
9
|
+
|
|
10
|
+
**Aliases:** measurement before optimization, evidence-driven optimization.
|
|
11
|
+
|
|
12
|
+
## Provenance
|
|
13
|
+
|
|
14
|
+
**Classification:** established principle.
|
|
15
|
+
|
|
16
|
+
Donald Knuth discussed premature optimization in 1974. No one author owns the general discipline or
|
|
17
|
+
the Athena text. Performance tools and frameworks apply the rule with representative
|
|
18
|
+
measurements.
|
|
19
|
+
|
|
20
|
+
## Decision rule
|
|
21
|
+
|
|
22
|
+
When an accepted requirement or trusted measurement shows an important constraint, add optimization
|
|
23
|
+
complexity. Before-and-after evidence must show an improvement and must show that the result
|
|
24
|
+
continues to satisfy the requirement.
|
|
25
|
+
|
|
26
|
+
## How to apply
|
|
27
|
+
|
|
28
|
+
- Specify the performance objective, workload, environment, and permitted trade-offs.
|
|
29
|
+
- Record a reproducible baseline with representative data and end-to-end metrics.
|
|
30
|
+
- Use a profile to find the dominant cost, not code appearance.
|
|
31
|
+
- When possible, change one factor. Compare measurements from three or more runs.
|
|
32
|
+
- Keep regression protection or monitoring for the optimized behavior.
|
|
33
|
+
|
|
34
|
+
## Diagram
|
|
35
|
+
|
|
36
|
+
```mermaid
|
|
37
|
+
flowchart TD
|
|
38
|
+
A["Specify performance requirement"] --> B{"Constraint has evidence?"}
|
|
39
|
+
B -- "No" --> C["Keep simple design"]
|
|
40
|
+
B -- "Yes" --> D["Measure representative baseline"]
|
|
41
|
+
D --> E["Profile dominant cost"]
|
|
42
|
+
E --> F["Change one factor"]
|
|
43
|
+
F --> G{"Did the result stay correct and did the metric improve?"}
|
|
44
|
+
G -- "No" --> H["Reject or revise optimization"]
|
|
45
|
+
G -- "Yes" --> I["Keep regression evidence"]
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Language examples
|
|
49
|
+
|
|
50
|
+
The two examples select the candidate only after proof of equal results and a lower measured cost.
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
def select_parser(samples):
|
|
54
|
+
if outputs(parse, samples) != outputs(cached_parse, samples):
|
|
55
|
+
raise ValueError("candidate changes parser output")
|
|
56
|
+
baseline = measure(parse, samples)
|
|
57
|
+
candidate = measure(cached_parse, samples)
|
|
58
|
+
return cached_parse if candidate < baseline else parse
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
```rust
|
|
62
|
+
fn select_parser(samples: &[Input]) -> Parser {
|
|
63
|
+
assert_eq!(outputs(parse, samples), outputs(cached_parse, samples));
|
|
64
|
+
let baseline = measure(parse, samples);
|
|
65
|
+
let candidate = measure(cached_parse, samples);
|
|
66
|
+
if candidate < baseline { cached_parse } else { parse }
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Boundaries and tensions
|
|
71
|
+
|
|
72
|
+
Specified latency, memory, cost, or capacity requirements can give evidence. A team can act before a
|
|
73
|
+
production incident. Known algorithmic hazards and hard real-time constraints can make design work
|
|
74
|
+
necessary before implementation. The team must specify the assumptions. The team must test them.
|
|
75
|
+
|
|
76
|
+
When its workload differs from the target workload, a microbenchmark can give an incorrect result.
|
|
77
|
+
If an optimization decreases correctness, security, clarity, or operation, a higher metric does not
|
|
78
|
+
make the optimization correct.
|
|
79
|
+
|
|
80
|
+
## Examples
|
|
81
|
+
|
|
82
|
+
**Positive:** A representative profile shows that many parses dominate request latency. A bounded
|
|
83
|
+
cache decreases that cost. Load tests verify latency, memory use, and correctness at the target
|
|
84
|
+
scale.
|
|
85
|
+
|
|
86
|
+
**Misuse:** A team adds concurrency, a cache, and a new service to a low-volume tool.
|
|
87
|
+
No requirement, baseline, profile, or post-change measurement gives evidence for these additions.
|
|
88
|
+
|
|
89
|
+
**Athena/agent workflow:** An agent proposes parallel subagents only for independent tasks with
|
|
90
|
+
permitted coordination cost. Before a claim that maximum concurrency is faster, the agent uses
|
|
91
|
+
evidence.
|
|
92
|
+
|
|
93
|
+
## Related principles
|
|
94
|
+
|
|
95
|
+
- [P001 KISS](p001-kiss.md)
|
|
96
|
+
- [P002 YAGNI](p002-yagni.md)
|
|
97
|
+
- [P012 Evidence Before Modification](p012-evidence-before-modification.md)
|
|
98
|
+
- [P072 Technical Evidence Over Preference](p072-technical-evidence-over-preference.md)
|
|
99
|
+
- [P080 Make Concurrency Deliberate](p080-make-concurrency-deliberate.md)
|
|
100
|
+
|
|
101
|
+
## References
|
|
102
|
+
|
|
103
|
+
### Source information
|
|
104
|
+
|
|
105
|
+
- [Knuth, "Structured Programming with go to Statements" (1974)](https://doi.org/10.1145/356635.356640)
|
|
106
|
+
is a primary source for the important discussion of premature optimization and critical code
|
|
107
|
+
paths. It is not the only source for performance measurement.
|
|
108
|
+
|
|
109
|
+
### Applicable information
|
|
110
|
+
|
|
111
|
+
- [Go diagnostics documentation](https://go.dev/doc/diagnostics) gives profiling and tracing as tools
|
|
112
|
+
that find high-cost code and measure performance behavior.
|
|
113
|
+
- [AWS Well-Architected Performance Efficiency Pillar](https://docs.aws.amazon.com/wellarchitected/latest/performance-efficiency-pillar/welcome.html)
|
|
114
|
+
states that teams must use performance indicators, monitoring, load tests, and regular
|
|
115
|
+
measurement-driven review.
|
|
116
|
+
|
|
117
|
+
### More information
|
|
118
|
+
|
|
119
|
+
- [Go profile-guided optimization](https://go.dev/doc/pgo) states that representative production
|
|
120
|
+
profiles give more applicable evidence. It also shows how narrow microbenchmarks can give
|
|
121
|
+
incorrect optimization input.
|
|
122
|
+
|
|
123
|
+
[Back to the engineering principles catalog](../README.md#p073)
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# P074 — Prefer Existing Mechanisms
|
|
2
|
+
|
|
3
|
+
## Definition
|
|
4
|
+
|
|
5
|
+
Before you make a utility, abstraction, parser, serializer, retry framework, cache, or
|
|
6
|
+
synchronization primitive, search for an applicable mechanism. Before you make a security
|
|
7
|
+
mechanism, dependency, or service, search for an applicable mechanism. The repository, language,
|
|
8
|
+
framework, platform, or standard library can supply it.
|
|
9
|
+
|
|
10
|
+
**Aliases:** reuse before a new build, use established mechanisms first.
|
|
11
|
+
|
|
12
|
+
## Provenance
|
|
13
|
+
|
|
14
|
+
**Classification:** practitioner heuristic.
|
|
15
|
+
|
|
16
|
+
Reuse of established components is a software practice with a long history. No verified source owns
|
|
17
|
+
the practice. This rule gives priority to local and standard mechanisms. The rule continues to
|
|
18
|
+
make a fitness and security assessment necessary because reuse does not always decrease risk.
|
|
19
|
+
|
|
20
|
+
## Decision rule
|
|
21
|
+
|
|
22
|
+
When the target environment supports an established mechanism and the mechanism satisfies the
|
|
23
|
+
contract, use it. Its total correctness, security, maintenance, and operation cost must be lower
|
|
24
|
+
than a new mechanism. As the default, make only the missing capability, not a second framework.
|
|
25
|
+
|
|
26
|
+
## How to apply
|
|
27
|
+
|
|
28
|
+
- Search repository code, documentation, dependency manifests, and architecture decisions first.
|
|
29
|
+
- Then, examine the language and framework standard facilities.
|
|
30
|
+
- Compare semantics, failure behavior, maintenance, provenance, licensing, and migration cost.
|
|
31
|
+
- Add a small, coherent extension at the interface that the established mechanism supplies.
|
|
32
|
+
- When available mechanisms do not satisfy the contract, document why a new mechanism is necessary.
|
|
33
|
+
|
|
34
|
+
## Diagram
|
|
35
|
+
|
|
36
|
+
```mermaid
|
|
37
|
+
flowchart TD
|
|
38
|
+
A["Specify necessary capability"] --> B["Search repository mechanisms"]
|
|
39
|
+
B --> C["Search language and platform mechanisms"]
|
|
40
|
+
C --> D{"Does established mechanism satisfy contract?"}
|
|
41
|
+
D -- "Yes" --> E["Examine support, security, and total cost"]
|
|
42
|
+
E --> F{"Reuse has lower total risk?"}
|
|
43
|
+
F -- "Yes" --> G["Use or extend established mechanism"]
|
|
44
|
+
D -- "No" --> H["Make only missing capability"]
|
|
45
|
+
F -- "No" --> H
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Language examples
|
|
49
|
+
|
|
50
|
+
The two examples use an established SHA-256 implementation. For the same input bytes, they return
|
|
51
|
+
the same 32 digest bytes in the same order.
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
from hashlib import sha256
|
|
55
|
+
|
|
56
|
+
def digest(payload: bytes) -> bytes:
|
|
57
|
+
value = sha256(payload)
|
|
58
|
+
return value.digest()
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
```rust
|
|
62
|
+
use sha2::{Digest, Sha256};
|
|
63
|
+
|
|
64
|
+
fn digest(payload: &[u8]) -> Vec<u8> {
|
|
65
|
+
let value = Sha256::digest(payload);
|
|
66
|
+
value.to_vec()
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Boundaries and tensions
|
|
71
|
+
|
|
72
|
+
An established mechanism does not always satisfy the task contract or security requirements. Its
|
|
73
|
+
owner can stop maintenance. If its contract does not include the work, do not use the mechanism. Do
|
|
74
|
+
not use private internals. Do not keep a known vulnerability only to prevent new code. A third-party
|
|
75
|
+
dependency can increase the supply-chain and attack surfaces.
|
|
76
|
+
|
|
77
|
+
Thus, a small local implementation can be safer. Reuse must keep local analysis and clear
|
|
78
|
+
ownership.
|
|
79
|
+
|
|
80
|
+
## Examples
|
|
81
|
+
|
|
82
|
+
**Positive:** A command uses the URL parser from the standard library and the repository error envelope. It
|
|
83
|
+
does not make two replacements with small differences.
|
|
84
|
+
|
|
85
|
+
**Misuse:** A custom retry loop duplicates the bounded retry in the repository client. The duplicate
|
|
86
|
+
causes nested attempts and inconsistent delay intervals.
|
|
87
|
+
|
|
88
|
+
**Athena/agent workflow:** An author invokes the documented CLI for a tested skill-local helper.
|
|
89
|
+
The author does not add a second parser to a Markdown code block.
|
|
90
|
+
|
|
91
|
+
## Related principles
|
|
92
|
+
|
|
93
|
+
- [P003 DRY](p003-dry.md)
|
|
94
|
+
- [P013 AHA](p013-avoid-hasty-abstractions.md)
|
|
95
|
+
- [P057 Supply-Chain Integrity](p057-supply-chain-integrity.md)
|
|
96
|
+
- [P078 Single Source of Truth](p078-single-source-of-truth.md)
|
|
97
|
+
- [P084 Prefer Local Reasoning](p084-prefer-local-reasoning.md)
|
|
98
|
+
|
|
99
|
+
## References
|
|
100
|
+
|
|
101
|
+
### Source information
|
|
102
|
+
|
|
103
|
+
- [Python tutorial: Batteries included](https://docs.python.org/3/tutorial/stdlib.html#batteries-included)
|
|
104
|
+
documents one important language philosophy for standard-library mechanisms. This page does not
|
|
105
|
+
claim that it is the initial source for the full reuse heuristic.
|
|
106
|
+
|
|
107
|
+
### Applicable information
|
|
108
|
+
|
|
109
|
+
- [Google Engineering Practices: What to look for in a code review](https://google.github.io/eng-practices/review/reviewer/looking-for.html)
|
|
110
|
+
states that reviewers must identify the correct owner for a change. Reviewers must also verify
|
|
111
|
+
that the change agrees with the system.
|
|
112
|
+
- [NIST SSDF 1.1](https://csrc.nist.gov/pubs/sp/800/218/final) states that organizations must manage
|
|
113
|
+
and protect internal and third-party software components.
|
|
114
|
+
|
|
115
|
+
### More information
|
|
116
|
+
|
|
117
|
+
- [Google Engineering Practices: Small CLs](https://google.github.io/eng-practices/review/developer/small-cls.html)
|
|
118
|
+
shows how APIs that no code uses can decrease change focus. Framework work that is not part of the
|
|
119
|
+
task can have the same effect.
|
|
120
|
+
|
|
121
|
+
[Back to the engineering principles catalog](../README.md#p074)
|