opencode-skills-collection 4.1.2 → 4.1.3
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.
Potentially problematic release.
This version of opencode-skills-collection might be problematic. Click here for more details.
- package/bundled-skills/.antigravity-install-manifest.json +9 -1
- package/bundled-skills/antigravity-maintainer-batch-release/SKILL.md +15 -1
- package/bundled-skills/deep-research-framework/SKILL.md +81 -0
- package/bundled-skills/five-axis-code-review/SKILL.md +78 -0
- package/bundled-skills/git-commit-message/SKILL.md +76 -0
- package/bundled-skills/idea-to-blueprint/LICENSE +21 -0
- package/bundled-skills/idea-to-blueprint/SKILL.md +260 -0
- package/bundled-skills/idea-to-blueprint/assets/AGENTS.md.template +38 -0
- package/bundled-skills/idea-to-blueprint/assets/CLAUDE.md.template +38 -0
- package/bundled-skills/idea-to-blueprint/assets/DECISIONS.md.template +14 -0
- package/bundled-skills/idea-to-blueprint/assets/PROGRESS.md.template +47 -0
- package/bundled-skills/idea-to-blueprint/assets/session-prompt.md +23 -0
- package/bundled-skills/idea-to-blueprint/references/architecture-decisions.md +202 -0
- package/bundled-skills/idea-to-blueprint/references/blueprint-template.md +259 -0
- package/bundled-skills/idea-to-blueprint/references/code-quality-and-review.md +216 -0
- package/bundled-skills/idea-to-blueprint/references/design-minimal.md +96 -0
- package/bundled-skills/idea-to-blueprint/references/edge-case-catalog.md +239 -0
- package/bundled-skills/idea-to-blueprint/references/intake-questions.md +105 -0
- package/bundled-skills/idea-to-blueprint/references/research-protocol.md +196 -0
- package/bundled-skills/idea-to-blueprint/references/session-protocol.md +133 -0
- package/bundled-skills/idea-to-blueprint/references/stories-ac-tests.md +194 -0
- package/bundled-skills/idea-to-blueprint/references/ux-writing-guide.md +128 -0
- package/bundled-skills/idea-to-blueprint/scripts/lint_blueprint.py +460 -0
- package/bundled-skills/liuguang-banlan-ui/SKILL.md +22 -18
- package/bundled-skills/liuguang-banlan-ui/assets/starter/launcher.css +2 -2
- package/bundled-skills/liuguang-banlan-ui/assets/starter/obsidian/index.html +5 -4
- package/bundled-skills/liuguang-banlan-ui/assets/starter/obsidian/theme-config.js +3 -10
- package/bundled-skills/liuguang-banlan-ui/assets/starter/obsidian/theme.css +48 -62
- package/bundled-skills/liuguang-banlan-ui/assets/starter/opal/index.html +5 -4
- package/bundled-skills/liuguang-banlan-ui/assets/starter/opal/theme-config.js +27 -35
- package/bundled-skills/liuguang-banlan-ui/assets/starter/opal/theme.css +48 -62
- package/bundled-skills/liuguang-banlan-ui/assets/starter/shared/spectral-field.js +135 -148
- package/bundled-skills/liuguang-banlan-ui/references/style-contract.md +26 -7
- package/bundled-skills/liuguang-banlan-ui/references/verification.md +19 -7
- package/bundled-skills/liuguang-banlan-ui/scripts/measure_preview.py +78 -47
- package/bundled-skills/liuguang-banlan-ui/scripts/serve_preview.py +35 -0
- package/bundled-skills/liuguang-banlan-ui/scripts/validate_manifest.py +34 -3
- package/bundled-skills/liuguang-banlan-ui/tests/test_measure_preview.py +119 -0
- package/bundled-skills/liuguang-banlan-ui/tests/test_serve_preview.py +38 -0
- package/bundled-skills/liuguang-banlan-ui/tests/test_validate_manifest.py +73 -0
- package/bundled-skills/loki-mode/examples/todo-app-generated/frontend/package-lock.json +12 -12
- package/bundled-skills/loki-mode/examples/todo-app-generated/frontend/package.json +1 -1
- package/bundled-skills/meeting-notes/SKILL.md +80 -0
- package/bundled-skills/repo-foundation/SKILL.md +166 -0
- package/bundled-skills/repo-foundation/references/LICENSE.md +21 -0
- package/bundled-skills/repo-foundation/references/bootstrap.md +63 -0
- package/bundled-skills/repo-foundation/references/companion.md +9 -0
- package/bundled-skills/repo-foundation/references/continuity.md +50 -0
- package/bundled-skills/repo-foundation/references/evolution.md +60 -0
- package/bundled-skills/repo-foundation/references/migration-examples.md +53 -0
- package/bundled-skills/repo-foundation/references/shared-contracts.md +48 -0
- package/bundled-skills/repo-foundation/references/verification.md +50 -0
- package/bundled-skills/repo-native-refactor/SKILL.md +225 -0
- package/bundled-skills/repo-native-refactor/references/LICENSE.md +21 -0
- package/bundled-skills/repo-native-refactor/references/deterministic-tooling.md +101 -0
- package/bundled-skills/repo-native-refactor/references/error-reliability.md +117 -0
- package/bundled-skills/repo-native-refactor/references/finding-taxonomy.md +181 -0
- package/bundled-skills/repo-native-refactor/references/refactor-examples.md +77 -0
- package/bundled-skills/repo-native-refactor/references/repository-prose.md +157 -0
- package/bundled-skills/repo-native-refactor/references/repository-rehabilitation.md +94 -0
- package/bundled-skills/repo-native-refactor/references/semantic-risk.md +187 -0
- package/bundled-skills/repo-native-refactor/references/shared-contracts.md +48 -0
- package/bundled-skills/repo-native-refactor/references/testing-integrity.md +103 -0
- package/bundled-skills/tech-writing-proofread/SKILL.md +78 -0
- package/bundled-skills/typescript-expert/scripts/ts_diagnostic.py +40 -19
- package/bundled-skills/youtube-summarizer/SKILL.md +3 -3
- package/package.json +1 -1
- package/skills_index.json +254 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Refactor Examples by Risk Band (R0–R4)
|
|
2
|
+
|
|
3
|
+
Read this when `SKILL.md` Workflow steps 3–4 flag a candidate finding. Each band shows a minimal good vs bad intervention. Do not mutate on style alone. Each good example cites a concrete consequence.
|
|
4
|
+
|
|
5
|
+
## R0 - Mechanical (formatter-provable)
|
|
6
|
+
|
|
7
|
+
Bad: hand-reformat churn across 40 files in a feature diff.
|
|
8
|
+
```diff
|
|
9
|
+
- x=1
|
|
10
|
+
+ x = 1 # + 200 unrelated lines
|
|
11
|
+
```
|
|
12
|
+
Good: run repo formatter only on touched lines, zero semantic diff. Consequence avoided: review noise.
|
|
13
|
+
|
|
14
|
+
## R1 - Low Structural (local residue)
|
|
15
|
+
|
|
16
|
+
Bad: leave `import os` unused + `print(debug)` in shipped diff.
|
|
17
|
+
```python
|
|
18
|
+
import os # unused
|
|
19
|
+
print("here", x)
|
|
20
|
+
```
|
|
21
|
+
Good:
|
|
22
|
+
```diff
|
|
23
|
+
-import os
|
|
24
|
+
-print("here", x)
|
|
25
|
+
```
|
|
26
|
+
Verify: affected unit test still passes. Consequence: dead weight + log leak.
|
|
27
|
+
|
|
28
|
+
## R2 - Contextual Structural (predicate extraction)
|
|
29
|
+
|
|
30
|
+
Bad: two callers implement divergent checks for the same owned validation policy:
|
|
31
|
+
```python
|
|
32
|
+
if not tenant or not tenant.strip(): raise ValueError
|
|
33
|
+
# ... 30 lines later in another module ...
|
|
34
|
+
if tenant is None or tenant == "": raise ValueError
|
|
35
|
+
```
|
|
36
|
+
Good: single affirmative predicate, same ownership/invariants:
|
|
37
|
+
```python
|
|
38
|
+
def _is_valid_tenant(v) -> bool:
|
|
39
|
+
return isinstance(v, str) and bool(v.strip())
|
|
40
|
+
```
|
|
41
|
+
Consolidate only when shared ownership + same reason to change. Keep small local duplication if abstraction adds coupling. Consequence: divergent policy.
|
|
42
|
+
|
|
43
|
+
## R3 - Semantic (retry / serialization / transactions)
|
|
44
|
+
|
|
45
|
+
Bad: blanket retry hiding infra failure:
|
|
46
|
+
```python
|
|
47
|
+
for _ in range(5):
|
|
48
|
+
try: return publish(ev)
|
|
49
|
+
except Exception: continue
|
|
50
|
+
```
|
|
51
|
+
Good: idempotency-aware, bounded, owner-logged:
|
|
52
|
+
```python
|
|
53
|
+
for attempt in range(3):
|
|
54
|
+
try:
|
|
55
|
+
return publish(ev, idempotency_key=ev.id)
|
|
56
|
+
except TransientError:
|
|
57
|
+
if attempt == 2:
|
|
58
|
+
raise
|
|
59
|
+
log.warning(
|
|
60
|
+
"publish retry",
|
|
61
|
+
extra={"attempt": attempt + 1},
|
|
62
|
+
)
|
|
63
|
+
```
|
|
64
|
+
Retry only transient failures; propagate the final failure after exhaustion and
|
|
65
|
+
non-transient errors immediately. Follow the repository's existing backoff and timeout
|
|
66
|
+
policy. Verify eventual success, exhausted retries, and a non-retryable failure.
|
|
67
|
+
Never mass-rewrite R3 without explicit instruction + verified tests.
|
|
68
|
+
|
|
69
|
+
## R4 - Critical Boundary (auth / migration / durability)
|
|
70
|
+
|
|
71
|
+
Bad: mutate contract in place without preserving last-valid state.
|
|
72
|
+
Good: preserve + report, do not guess:
|
|
73
|
+
```python
|
|
74
|
+
# preserve LEDGER_FILE: str contract, stage replacement, fsync, atomic rename
|
|
75
|
+
# if intent/ownership/migration semantics unclear, stop and report
|
|
76
|
+
```
|
|
77
|
+
Maximum conservatism. Missing evidence means preserve plus a completion report `Needs review`.
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# Repository-native prose
|
|
2
|
+
|
|
3
|
+
Source prose should carry information that code cannot express clearly and should sound normal for its repository. The objective is not to imitate a person or evade detection. It is to remove narration, inflation, and generic language while preserving contracts and rationale.
|
|
4
|
+
|
|
5
|
+
## Resolve the local prose baseline
|
|
6
|
+
|
|
7
|
+
Before changing prose, sample healthy code near the same owner, domain, and runtime boundary. Infer only what the sample supports:
|
|
8
|
+
|
|
9
|
+
- which constructs are documented;
|
|
10
|
+
- comment density and placement;
|
|
11
|
+
- fragments versus complete sentences;
|
|
12
|
+
- capitalization and punctuation;
|
|
13
|
+
- docstring or API-documentation format;
|
|
14
|
+
- domain terminology and abbreviations;
|
|
15
|
+
- accepted tags such as `TODO`, `FIXME`, or issue references;
|
|
16
|
+
- whether test names, logs, and errors follow stable templates.
|
|
17
|
+
|
|
18
|
+
Prefer explicit repository configuration and documentation over inference. Do not treat newly introduced code, generated output, or a visibly inconsistent file as authoritative precedent.
|
|
19
|
+
|
|
20
|
+
Classify the baseline as `observed`, `likely`, `conflicting`, or `unknown`. If conventions conflict, prefer the pattern closest in ownership and domain. If evidence remains weak, use the conservative fallback below rather than inventing a house style.
|
|
21
|
+
|
|
22
|
+
## Distinguish prose surfaces
|
|
23
|
+
|
|
24
|
+
Do not apply one cleanup policy to every string.
|
|
25
|
+
|
|
26
|
+
### Internal comments
|
|
27
|
+
|
|
28
|
+
Internal comments may be removed when they merely repeat code. They are valuable when they explain a non-obvious constraint, invariant, tradeoff, external-system behavior, or reason an apparently simpler implementation is unsafe.
|
|
29
|
+
|
|
30
|
+
### Public documentation
|
|
31
|
+
|
|
32
|
+
Docstrings, API comments, annotations, and generated-documentation sources may be contracts or required by repository tooling. Preserve required structure and describe observable behavior accurately. Do not remove documentation merely because names and types look self-explanatory.
|
|
33
|
+
|
|
34
|
+
### Tests
|
|
35
|
+
|
|
36
|
+
Test descriptions and assertion messages should express behavior in the repository's established vocabulary. Avoid tutorial-like narratives and verbose restatements of the fixture. Treat expected messages and snapshots as behavioral evidence, not casual prose.
|
|
37
|
+
|
|
38
|
+
### Errors, logs, and command output
|
|
39
|
+
|
|
40
|
+
Error text, log templates, structured field names, metrics, events, stdout, and stderr may be consumed by tests, dashboards, alerts, scripts, or external systems. Treat them as observable behavior until callers and repository evidence establish otherwise.
|
|
41
|
+
|
|
42
|
+
### User-facing copy
|
|
43
|
+
|
|
44
|
+
Do not rewrite product text as code cleanup. Change it only when the task authorizes copy changes or the current wording is an established defect within scope.
|
|
45
|
+
|
|
46
|
+
## Decide: delete, preserve, tighten, correct, or report
|
|
47
|
+
|
|
48
|
+
### Delete
|
|
49
|
+
|
|
50
|
+
Delete prose that contributes no information beyond the code, including confirmed examples of:
|
|
51
|
+
|
|
52
|
+
- execution narration such as "first", "next", or "finally";
|
|
53
|
+
- comments that restate an assignment, branch, loop, guard, or function call;
|
|
54
|
+
- headings that divide a short function into obvious stages;
|
|
55
|
+
- implementation diary entries;
|
|
56
|
+
- comments added only to label ordinary getters, setters, constructors, or data movement;
|
|
57
|
+
- docstrings that repeat the symbol name and type information without adding a contract;
|
|
58
|
+
- claims that code is clean, simple, robust, elegant, or maintainable.
|
|
59
|
+
|
|
60
|
+
Prefer deletion over replacing a redundant long comment with a redundant short one.
|
|
61
|
+
|
|
62
|
+
### Preserve
|
|
63
|
+
|
|
64
|
+
Preserve still-relevant information about:
|
|
65
|
+
|
|
66
|
+
- compatibility behavior;
|
|
67
|
+
- external protocol irregularities;
|
|
68
|
+
- security boundaries;
|
|
69
|
+
- concurrency, ordering, transaction, or lifecycle constraints;
|
|
70
|
+
- counterintuitive domain rules;
|
|
71
|
+
- intentional degradation or best-effort behavior;
|
|
72
|
+
- performance tradeoffs that are not apparent locally;
|
|
73
|
+
- rationale supported by repository history or documentation.
|
|
74
|
+
|
|
75
|
+
Awkward wording alone is not enough to delete important knowledge.
|
|
76
|
+
|
|
77
|
+
### Tighten
|
|
78
|
+
|
|
79
|
+
Tighten prose when it contains necessary information but is inflated, generic, or poorly aligned with local terminology. Keep the concrete constraint and remove ceremony.
|
|
80
|
+
|
|
81
|
+
For example, replace:
|
|
82
|
+
|
|
83
|
+
```text
|
|
84
|
+
Gracefully handle the legacy response to ensure that the operation remains robust.
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
with a repository-appropriate form of:
|
|
88
|
+
|
|
89
|
+
```text
|
|
90
|
+
The v1 endpoint returns 200 with an empty body when the record is missing.
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Do not add certainty that the evidence does not support.
|
|
94
|
+
|
|
95
|
+
### Correct
|
|
96
|
+
|
|
97
|
+
Correct stale or misleading prose only when behavior and intent are established. Update the smallest relevant surface. If correcting the prose exposes an actual behavioral defect, classify that code change separately.
|
|
98
|
+
|
|
99
|
+
### Report
|
|
100
|
+
|
|
101
|
+
Report rather than rewrite when a comment may encode history, a string may be consumed, or the intended contract is unclear. Uncertainty is not permission to normalize.
|
|
102
|
+
|
|
103
|
+
## Comment necessity test
|
|
104
|
+
|
|
105
|
+
Before retaining or adding a comment, ask:
|
|
106
|
+
|
|
107
|
+
> If this prose disappeared, would a maintainer lose an important fact that the code, type system, tests, or nearby contract does not express clearly?
|
|
108
|
+
|
|
109
|
+
If not, omit the comment. If yes, state the missing fact directly and at the narrowest useful location.
|
|
110
|
+
|
|
111
|
+
## Candidate signals, not deletion rules
|
|
112
|
+
|
|
113
|
+
The following patterns often deserve inspection:
|
|
114
|
+
|
|
115
|
+
- "We need to", "This function", or "The following code";
|
|
116
|
+
- "First", "Next", "Finally", or numbered step comments;
|
|
117
|
+
- "Handle gracefully", "ensure correctness", or "properly validate" without a named invariant;
|
|
118
|
+
- "robust", "seamless", "comprehensive", "elegant", or similar ungrounded claims;
|
|
119
|
+
- banners and separators that create visual ceremony without structural meaning;
|
|
120
|
+
- a comment before nearly every small block;
|
|
121
|
+
- repeated `@param` or return prose that adds nothing beyond types;
|
|
122
|
+
- comments explaining that code exists "for clarity" or "for maintainability";
|
|
123
|
+
- comments that describe the implementation process rather than lasting system behavior.
|
|
124
|
+
|
|
125
|
+
These are discovery hints only. Phrase matching, comment-count targets, and AI detectors cannot determine whether prose is correct or necessary.
|
|
126
|
+
|
|
127
|
+
## Conservative fallback
|
|
128
|
+
|
|
129
|
+
When the repository provides little reliable prose evidence:
|
|
130
|
+
|
|
131
|
+
- prefer no comment when code is already clear;
|
|
132
|
+
- explain why, a constraint, or external behavior rather than narrating what;
|
|
133
|
+
- use concrete domain nouns and active phrasing;
|
|
134
|
+
- keep one idea per comment;
|
|
135
|
+
- place the explanation next to the boundary it qualifies;
|
|
136
|
+
- avoid tutorial voice, self-dialogue, marketing language, and performative assurances;
|
|
137
|
+
- do not add comments merely to signal craftsmanship;
|
|
138
|
+
- do not invent tickets, incidents, owners, dates, or production history.
|
|
139
|
+
- Never invent ticket, PR, or incident references. An inaccessible or unverified reference is not evidence of fabrication. Preserve existing references unless repository evidence establishes that they are incorrect or obsolete; report material uncertainty instead of deleting them.
|
|
140
|
+
|
|
141
|
+
This fallback is deliberately modest. It must not become a universal style imposed over repository evidence.
|
|
142
|
+
|
|
143
|
+
## Final prose review
|
|
144
|
+
|
|
145
|
+
Inspect the final diff and ask:
|
|
146
|
+
|
|
147
|
+
- Did any deleted comment contain a constraint not preserved elsewhere?
|
|
148
|
+
- Did a rewrite become less precise while becoming shorter?
|
|
149
|
+
- Did redundant prose survive only in paraphrased form?
|
|
150
|
+
- Did comment density move toward relevant healthy code rather than an arbitrary target?
|
|
151
|
+
- Did terminology match the owning domain?
|
|
152
|
+
- Did any error, log, event, test expectation, or command output change without contract analysis?
|
|
153
|
+
- Did the refactor fabricate rationale or history?
|
|
154
|
+
- Is each added ticket, PR, or incident reference supported by a source?
|
|
155
|
+
- Was any existing reference deleted merely because it could not be verified?
|
|
156
|
+
|
|
157
|
+
Remove prose edits that cannot be justified by semantics or repository evidence.
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# Repository Rehabilitation
|
|
2
|
+
|
|
3
|
+
Use this mode only when the authorized scope is codebase-wide or spans multiple coherent domains. Its purpose is consistent rehabilitation, not a single sweeping rewrite.
|
|
4
|
+
|
|
5
|
+
## Survey before mutation
|
|
6
|
+
|
|
7
|
+
Map the repository at the level needed to choose safe batches:
|
|
8
|
+
|
|
9
|
+
- instruction and ownership boundaries;
|
|
10
|
+
- applications, packages, modules, or domains;
|
|
11
|
+
- public, persistence, network, security, and operational boundaries;
|
|
12
|
+
- generated, vendored, migrated, snapshot, and golden artifacts;
|
|
13
|
+
- build, type, lint, test, generation, and validation workflows;
|
|
14
|
+
- areas with active user changes;
|
|
15
|
+
- duplicated systems for errors, validation, configuration, persistence, or observability;
|
|
16
|
+
- areas where repository conventions conflict.
|
|
17
|
+
|
|
18
|
+
Do not review every file at equal depth. Begin with architecture signals, representative healthy paths, changed or high-churn areas when known, and boundaries that determine behavior.
|
|
19
|
+
|
|
20
|
+
## Build a concise repository profile
|
|
21
|
+
|
|
22
|
+
Record only decisions that will guide multiple batches:
|
|
23
|
+
|
|
24
|
+
- ownership and dependency direction;
|
|
25
|
+
- domain vocabulary;
|
|
26
|
+
- type, schema, and validation boundaries;
|
|
27
|
+
- error and result model;
|
|
28
|
+
- persistence and transaction conventions;
|
|
29
|
+
- async, retry, timeout, and cancellation ownership;
|
|
30
|
+
- logging and observability conventions;
|
|
31
|
+
- test strategy and trustworthy verification commands;
|
|
32
|
+
- comment and documentation conventions;
|
|
33
|
+
- dependency policy;
|
|
34
|
+
- sensitive or excluded artifacts;
|
|
35
|
+
- observed conflicts and unresolved uncertainty.
|
|
36
|
+
|
|
37
|
+
Mark each convention `observed`, `likely`, `conflicting`, or `unknown`. Cite the repository evidence used to infer it. Keep the profile compact and task-local unless the user asks to add documentation to the repository.
|
|
38
|
+
|
|
39
|
+
Do not infer standards from generated code, obvious outliers, or the code currently suspected of being low quality.
|
|
40
|
+
|
|
41
|
+
## Choose calibration work
|
|
42
|
+
|
|
43
|
+
Start with a representative, low-to-moderate-risk batch that has meaningful verification. Use it to test whether the repository profile produces a native result before applying it broadly.
|
|
44
|
+
|
|
45
|
+
Avoid beginning with authentication, payments, migrations, destructive persistence, or concurrency-critical code unless those areas are the explicit task and have adequate evidence.
|
|
46
|
+
|
|
47
|
+
## Batch by ownership
|
|
48
|
+
|
|
49
|
+
A batch should normally share a domain, owner, runtime boundary, and verification path. It should be small enough that a maintainer can understand its purpose and inspect every changed line.
|
|
50
|
+
|
|
51
|
+
For each batch:
|
|
52
|
+
|
|
53
|
+
1. confirm scope and preservation contracts;
|
|
54
|
+
2. refine only the relevant part of the repository profile;
|
|
55
|
+
3. inventory and classify findings;
|
|
56
|
+
4. apply the smallest justified corrections;
|
|
57
|
+
5. run focused verification;
|
|
58
|
+
6. inspect the diff and remove unjustified changes;
|
|
59
|
+
7. record residual uncertainty before continuing.
|
|
60
|
+
|
|
61
|
+
Do not mix unrelated naming, dependency, architecture, and formatting campaigns in one batch.
|
|
62
|
+
|
|
63
|
+
## Update the profile carefully
|
|
64
|
+
|
|
65
|
+
New evidence may refine the profile. It should not silently reverse decisions already used elsewhere.
|
|
66
|
+
|
|
67
|
+
When a later domain follows a different valid convention, scope the convention to that domain instead of forcing global uniformity. When patterns genuinely conflict, preserve both until ownership or migration intent establishes a preferred direction.
|
|
68
|
+
|
|
69
|
+
## Cross-batch review
|
|
70
|
+
|
|
71
|
+
After the bounded passes, inspect the combined result for:
|
|
72
|
+
|
|
73
|
+
- duplicated concepts left under different names;
|
|
74
|
+
- accidental cross-domain coupling;
|
|
75
|
+
- inconsistent error, validation, or schema boundaries;
|
|
76
|
+
- prose or terminology that diverges between equivalent owners;
|
|
77
|
+
- dependencies introduced only to support cleanup;
|
|
78
|
+
- broad formatting noise;
|
|
79
|
+
- verification gaps that compound across batches.
|
|
80
|
+
|
|
81
|
+
Run repository-level validation only after focused checks are stable. A clean full-suite result does not excuse an incoherent or unreviewable combined diff.
|
|
82
|
+
|
|
83
|
+
## Stop conditions
|
|
84
|
+
|
|
85
|
+
Pause expansion into a region when:
|
|
86
|
+
|
|
87
|
+
- its owner or intended behavior cannot be established;
|
|
88
|
+
- its convention conflicts materially with the current profile;
|
|
89
|
+
- meaningful verification is unavailable for high-risk behavior;
|
|
90
|
+
- it contains unrelated active changes;
|
|
91
|
+
- generated or historical workflow is unclear;
|
|
92
|
+
- cleanup would require redesign beyond the authorized scope.
|
|
93
|
+
|
|
94
|
+
Continue elsewhere when safe. Repository-wide authorization broadens coverage, not semantic permission.
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
# Semantic risk and mutation policy
|
|
2
|
+
|
|
3
|
+
> Field note: when unsure between R2 and R3, I pick the higher band. Cheaper than a rollback.
|
|
4
|
+
|
|
5
|
+
Risk measures the potential consequence of being wrong.
|
|
6
|
+
|
|
7
|
+
Transformation safety measures confidence that a rewrite preserves meaning.
|
|
8
|
+
|
|
9
|
+
They are related but separate.
|
|
10
|
+
|
|
11
|
+
## R0 - mechanical
|
|
12
|
+
|
|
13
|
+
Typical examples:
|
|
14
|
+
|
|
15
|
+
- formatting;
|
|
16
|
+
- import ordering;
|
|
17
|
+
- provably unused imports;
|
|
18
|
+
- obvious accidental separators;
|
|
19
|
+
- deterministic syntax normalization.
|
|
20
|
+
- deletion of a locally obvious comment that only restates syntax and carries no contract.
|
|
21
|
+
|
|
22
|
+
Policy:
|
|
23
|
+
|
|
24
|
+
Automatic mutation is acceptable when repository tooling establishes the transformation.
|
|
25
|
+
|
|
26
|
+
## R1 - low structural risk
|
|
27
|
+
|
|
28
|
+
Typical examples:
|
|
29
|
+
|
|
30
|
+
- redundant local syntax;
|
|
31
|
+
- provably dead local residue;
|
|
32
|
+
- obvious no-op indirection.
|
|
33
|
+
- comment or docstring cleanup whose meaning is fully established locally.
|
|
34
|
+
|
|
35
|
+
Policy:
|
|
36
|
+
|
|
37
|
+
Mutation is acceptable when scope is local and verification is straightforward.
|
|
38
|
+
|
|
39
|
+
## R2 - contextual structural risk
|
|
40
|
+
|
|
41
|
+
Typical examples:
|
|
42
|
+
|
|
43
|
+
- renaming;
|
|
44
|
+
- moving code;
|
|
45
|
+
- extracting or inlining helpers;
|
|
46
|
+
- reducing nesting;
|
|
47
|
+
- consolidating duplication;
|
|
48
|
+
- collapsing abstractions.
|
|
49
|
+
- rewriting rationale, public documentation, test descriptions, or potentially consumed text.
|
|
50
|
+
|
|
51
|
+
Policy:
|
|
52
|
+
|
|
53
|
+
Inspect ownership and repository precedent first.
|
|
54
|
+
|
|
55
|
+
Require a concrete maintainability or semantic benefit.
|
|
56
|
+
|
|
57
|
+
Do not refactor merely because another form is prettier.
|
|
58
|
+
|
|
59
|
+
## R3 - semantic risk
|
|
60
|
+
|
|
61
|
+
Typical examples:
|
|
62
|
+
|
|
63
|
+
- exception propagation;
|
|
64
|
+
- fallbacks;
|
|
65
|
+
- retries;
|
|
66
|
+
- timeout;
|
|
67
|
+
- caching;
|
|
68
|
+
- serialization;
|
|
69
|
+
- transaction ownership;
|
|
70
|
+
- async lifecycle;
|
|
71
|
+
- resource cleanup.
|
|
72
|
+
- error or operational wording known to participate in application behavior.
|
|
73
|
+
|
|
74
|
+
Policy:
|
|
75
|
+
|
|
76
|
+
Never bulk-rewrite.
|
|
77
|
+
|
|
78
|
+
Establish the preservation contract and meaningful behavioral verification.
|
|
79
|
+
|
|
80
|
+
## R4 - critical boundary
|
|
81
|
+
|
|
82
|
+
Typical examples:
|
|
83
|
+
|
|
84
|
+
- authentication;
|
|
85
|
+
- authorization;
|
|
86
|
+
- permissions;
|
|
87
|
+
- payment;
|
|
88
|
+
- cryptography;
|
|
89
|
+
- migrations;
|
|
90
|
+
- destructive persistence;
|
|
91
|
+
- concurrency-critical logic;
|
|
92
|
+
- security enforcement.
|
|
93
|
+
|
|
94
|
+
Policy:
|
|
95
|
+
|
|
96
|
+
Maximum conservatism.
|
|
97
|
+
|
|
98
|
+
When evidence is incomplete, preserve behavior and report the finding.
|
|
99
|
+
|
|
100
|
+
## Transformation classes
|
|
101
|
+
|
|
102
|
+
### Class A - proven mechanical
|
|
103
|
+
|
|
104
|
+
May be applied unattended.
|
|
105
|
+
|
|
106
|
+
The rewrite must have clear local equivalence or be an established project-tool transformation.
|
|
107
|
+
|
|
108
|
+
### Class B - context sensitive
|
|
109
|
+
|
|
110
|
+
Generate or consider a candidate change, then inspect and verify.
|
|
111
|
+
|
|
112
|
+
Examples:
|
|
113
|
+
|
|
114
|
+
- helper inline;
|
|
115
|
+
- control-flow flattening;
|
|
116
|
+
- rename;
|
|
117
|
+
- abstraction removal;
|
|
118
|
+
- context-sensitive comment or documentation changes.
|
|
119
|
+
|
|
120
|
+
### Class C - semantic
|
|
121
|
+
|
|
122
|
+
Requires reasoning about behavioral ownership.
|
|
123
|
+
|
|
124
|
+
Examples:
|
|
125
|
+
|
|
126
|
+
- changing `catch` behavior;
|
|
127
|
+
- replacing fallbacks with exceptions;
|
|
128
|
+
- changing retries;
|
|
129
|
+
- changing transaction scope;
|
|
130
|
+
- changing auth logic;
|
|
131
|
+
- changing async error ownership.
|
|
132
|
+
|
|
133
|
+
Never run Class C as a mass structural rewrite.
|
|
134
|
+
|
|
135
|
+
## Prose risk
|
|
136
|
+
|
|
137
|
+
Prose risk depends on its role, not its appearance.
|
|
138
|
+
|
|
139
|
+
- Deleting a confirmed syntax restatement may be mechanical.
|
|
140
|
+
- Rewriting a rationale requires repository and behavioral context.
|
|
141
|
+
- Public API documentation may define a contract.
|
|
142
|
+
- Error messages, logs, event fields, snapshots, stdout, and stderr may be observable behavior.
|
|
143
|
+
- Comments around security, compatibility, transactions, concurrency, migrations, or lifecycle inherit the risk of the behavior they explain.
|
|
144
|
+
|
|
145
|
+
Phrase matching can find candidates but cannot establish a transformation class.
|
|
146
|
+
|
|
147
|
+
## Justification gate
|
|
148
|
+
|
|
149
|
+
Before a significant R2+ mutation establish:
|
|
150
|
+
|
|
151
|
+
**Observed problem:** What is wrong?
|
|
152
|
+
|
|
153
|
+
**Consequence:** Why does it matter?
|
|
154
|
+
|
|
155
|
+
**Owner:** Which layer should own the correction?
|
|
156
|
+
|
|
157
|
+
**Repository evidence:** What supports that decision?
|
|
158
|
+
|
|
159
|
+
**Minimal correction:** What is the smallest adequate repair?
|
|
160
|
+
|
|
161
|
+
**Preservation:** What behavior must remain unchanged?
|
|
162
|
+
|
|
163
|
+
**Verification:** How will the correction be checked?
|
|
164
|
+
|
|
165
|
+
If the only justification is “cleaner”, “more elegant”, or “more senior”, do not perform a broad refactor.
|
|
166
|
+
|
|
167
|
+
**Visible-text escalation:** if a structural change alters user- or contract-visible text
|
|
168
|
+
(error messages, CLI output, logs, event fields, snapshots), escalate one band
|
|
169
|
+
(R1-R2, R2-R3) and treat that text as an observable contract: preserve it exactly or
|
|
170
|
+
update its consumers within scope. A green suite that asserts only exception types does
|
|
171
|
+
not prove the text is safe to change.
|
|
172
|
+
|
|
173
|
+
## Stop conditions
|
|
174
|
+
|
|
175
|
+
Preserve rather than aggressively refactor when:
|
|
176
|
+
|
|
177
|
+
- intended behavior cannot be established;
|
|
178
|
+
- tests and implementation conflict without clear authority;
|
|
179
|
+
- repository patterns conflict materially;
|
|
180
|
+
- public contract consequences are unknown;
|
|
181
|
+
- migration intent is unclear;
|
|
182
|
+
- error ownership cannot be determined;
|
|
183
|
+
- concurrency behavior lacks verification;
|
|
184
|
+
- duplicate-looking implementations may represent independent domains;
|
|
185
|
+
- unusual code may encode an unexplained historical constraint.
|
|
186
|
+
|
|
187
|
+
A stop applies to the uncertain region, not necessarily the entire audit.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Shared contracts
|
|
2
|
+
|
|
3
|
+
These rules apply to repository development and review.
|
|
4
|
+
|
|
5
|
+
## 1. Strict contract adherence (canonical wording)
|
|
6
|
+
|
|
7
|
+
Preserve documented or demonstrably consumed public contracts across public interfaces,
|
|
8
|
+
exported parameters, module constants, return types, errors, and serialization.
|
|
9
|
+
|
|
10
|
+
- A requested behavior change may authorize a contract change only when that consequence
|
|
11
|
+
is clear from the task or from an authorized evolution. Then update affected callers,
|
|
12
|
+
tests, and living documentation within scope.
|
|
13
|
+
- Otherwise preserve exact declared types. For example, never substitute or wrap an exposed
|
|
14
|
+
primitive `str` path contract with `pathlib.Path` or custom wrapper objects merely for
|
|
15
|
+
internal convenience or preference.
|
|
16
|
+
- Internal intermediate representations may use appropriate helpers, provided all exposed
|
|
17
|
+
public contracts and types remain exact.
|
|
18
|
+
|
|
19
|
+
## 2. Evidence hierarchy (canonical order)
|
|
20
|
+
|
|
21
|
+
Use to guide investigation, not to auto-resolve material contradictions:
|
|
22
|
+
|
|
23
|
+
1. User requirements and explicitly authorized scope.
|
|
24
|
+
2. Documented architecture and repository guidelines.
|
|
25
|
+
3. Observable public contracts and persisted schemas.
|
|
26
|
+
4. Healthy sibling code within the same domain and runtime boundary.
|
|
27
|
+
5. Relevant tests, schemas, callers, and dependencies.
|
|
28
|
+
6. Dominant local conventions.
|
|
29
|
+
7. Language and runtime idioms.
|
|
30
|
+
8. Conservative, idiomatic defaults.
|
|
31
|
+
|
|
32
|
+
Never treat a temporary workaround, buggy sibling, or accidental pattern as precedent.
|
|
33
|
+
Never rewrite history or rubber-stamp code with stale notes. Reconcile before mutating
|
|
34
|
+
the affected contract.
|
|
35
|
+
|
|
36
|
+
## 3. Verification final-state rule (canonical)
|
|
37
|
+
|
|
38
|
+
- Record baseline failures as: (1) pre-existing outside scope, (2) in-scope to fix,
|
|
39
|
+
(3) regressions from current changes, (4) environment errors.
|
|
40
|
+
- Verify the final code state. Never use pre-cleanup results to certify modified code.
|
|
41
|
+
- Never claim a check ran when it did not. Distinguish verified behavior,
|
|
42
|
+
inspection-only conclusions, and unverified assumptions.
|
|
43
|
+
|
|
44
|
+
## 4. Shared judgment tests (canonical)
|
|
45
|
+
|
|
46
|
+
Two questions that both skills use when the text alone under-determines the answer.
|
|
47
|
+
|
|
48
|
+
A pattern counts as healthy precedent only if three things hold: code outside its original author consumes it, it does not contradict docs or contracts, and you would copy it into a new domain without apology. Popularity proves nothing; a workaround with tests and docs still fails. When two domains overlap, the owner is whoever owns the failure (who gets paged, who fixes the bug, whose reason to change fires first). Consolidate toward that owner, or leave both alone.
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# Testing integrity
|
|
2
|
+
|
|
3
|
+
Tests are evidence.
|
|
4
|
+
|
|
5
|
+
They are not automatically truth.
|
|
6
|
+
|
|
7
|
+
The audit must consider both:
|
|
8
|
+
|
|
9
|
+
**implementation quality**
|
|
10
|
+
|
|
11
|
+
and
|
|
12
|
+
|
|
13
|
+
**test quality**.
|
|
14
|
+
|
|
15
|
+
## Evidence confidence
|
|
16
|
+
|
|
17
|
+
### High confidence
|
|
18
|
+
|
|
19
|
+
Examples:
|
|
20
|
+
|
|
21
|
+
- contract tests;
|
|
22
|
+
- integration tests;
|
|
23
|
+
- independent expected values;
|
|
24
|
+
- observable end-to-end behavior;
|
|
25
|
+
- regression tests tied to an externally visible failure.
|
|
26
|
+
|
|
27
|
+
### Medium confidence
|
|
28
|
+
|
|
29
|
+
Examples:
|
|
30
|
+
|
|
31
|
+
- meaningful unit tests around public behavior;
|
|
32
|
+
- isolated business-rule tests with independent fixtures.
|
|
33
|
+
|
|
34
|
+
### Low confidence
|
|
35
|
+
|
|
36
|
+
Examples:
|
|
37
|
+
|
|
38
|
+
- expectations copied from implementation logic;
|
|
39
|
+
- excessive implementation mocking;
|
|
40
|
+
- tests of private structure;
|
|
41
|
+
- snapshots with little semantic meaning;
|
|
42
|
+
- tests asserting only that mocks were called.
|
|
43
|
+
|
|
44
|
+
Higher semantic risk requires stronger evidence.
|
|
45
|
+
|
|
46
|
+
If R3/R4 code has weak test evidence, reduce refactor aggressiveness.
|
|
47
|
+
|
|
48
|
+
## Test-slop patterns
|
|
49
|
+
|
|
50
|
+
### Tautological expectations
|
|
51
|
+
|
|
52
|
+
Bad pattern:
|
|
53
|
+
|
|
54
|
+
implementation computes X using formula F; test independently reproduces formula F and compares both.
|
|
55
|
+
|
|
56
|
+
The test may repeat the same mistake.
|
|
57
|
+
|
|
58
|
+
Prefer independent business examples or externally defined expected outcomes.
|
|
59
|
+
|
|
60
|
+
### Mock theatre
|
|
61
|
+
|
|
62
|
+
Mocking is not inherently bad.
|
|
63
|
+
|
|
64
|
+
The problem occurs when nearly every dependency is replaced and the test validates only the configured mocks rather than meaningful behavior.
|
|
65
|
+
|
|
66
|
+
Mock external or expensive boundaries when appropriate.
|
|
67
|
+
|
|
68
|
+
Do not mock away the behavior being audited.
|
|
69
|
+
|
|
70
|
+
### Test weakening
|
|
71
|
+
|
|
72
|
+
Never make a refactor pass by:
|
|
73
|
+
|
|
74
|
+
- deleting a regression case;
|
|
75
|
+
- changing a precise assertion into a vague one;
|
|
76
|
+
- disabling a test;
|
|
77
|
+
- expanding tolerances without domain justification.
|
|
78
|
+
|
|
79
|
+
If behavior intentionally changes, update tests because the contract changed, and report that behavioral change explicitly.
|
|
80
|
+
|
|
81
|
+
### Implementation coupling
|
|
82
|
+
|
|
83
|
+
Refactoring internals should not require widespread test rewrites when public behavior is unchanged unless repository conventions intentionally test internal units.
|
|
84
|
+
|
|
85
|
+
Large test churn during a behavior-preserving refactor is a warning sign.
|
|
86
|
+
|
|
87
|
+
### Test prose
|
|
88
|
+
|
|
89
|
+
Test names should describe meaningful behavior using the repository's vocabulary. Do not lengthen them into narrative specifications merely to appear thorough, and do not shorten them until the behavior under test becomes ambiguous.
|
|
90
|
+
|
|
91
|
+
Assertion messages, expected errors, snapshots, and golden output may constrain observable wording. Do not update them solely to accommodate stylistic rewording. If the contract intentionally changes, report it and retain independent behavioral evidence.
|
|
92
|
+
|
|
93
|
+
## Verification strategy
|
|
94
|
+
|
|
95
|
+
Prefer the smallest validation set that meaningfully constrains the change, then expand when risk requires it.
|
|
96
|
+
|
|
97
|
+
Mechanical cleanup may need type/lint/unit checks.
|
|
98
|
+
|
|
99
|
+
Structural changes may require focused unit and integration checks.
|
|
100
|
+
|
|
101
|
+
Semantic and critical-boundary changes may require contract, integration, security, or end-to-end verification.
|
|
102
|
+
|
|
103
|
+
Do not claim verification beyond what was actually run.
|