@leing2021/super-pi 0.26.0 → 0.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leing2021/super-pi",
3
- "version": "0.26.0",
3
+ "version": "0.27.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Pi-native Compound Engineering package for iterative development workflows",
package/rules/README.md CHANGED
@@ -24,6 +24,7 @@ rules/
24
24
 
25
25
  - **common/** contains universal principles — no language-specific code examples.
26
26
  - **Language directories** extend the common rules with framework-specific patterns, tools, and code examples. Each file references its common counterpart.
27
+ - **`review-checklist.md`** (optional, per language) holds precise, actionable defect patterns for code review — distinct from `patterns.md` which holds reusable design patterns. Currently used by `golang/` and `python/`.
27
28
 
28
29
  ## Installation
29
30
 
@@ -83,6 +84,7 @@ To add support for a new language (e.g., `rust/`):
83
84
  - `patterns.md` — language-specific design patterns
84
85
  - `hooks.md` — PostToolUse hooks for formatters, linters, type checkers
85
86
  - `security.md` — secret management, security scanning tools
87
+ - `review-checklist.md` — *(optional)* precise defect patterns for code review, used together with `common/code-review.md`
86
88
  3. Each file should start with:
87
89
  ```
88
90
  > This file extends [common/xxx.md](../common/xxx.md) with <Language> specific content.
@@ -4,6 +4,22 @@
4
4
 
5
5
  Code review ensures quality, security, and maintainability before code is merged. This rule defines when and how to conduct code reviews.
6
6
 
7
+ ## Precision Discipline
8
+
9
+ **Favor precision over recall.** Report only defects you are confident are real in the changed code and its reachable context. A false positive costs more reviewer trust than a missed minor issue.
10
+
11
+ ### Gate-keeping rules
12
+
13
+ 1. **Verify before asserting** — Before flagging a non-local claim (race condition, security boundary, resource leak), use `file_read` and `code_search` to establish call sites, ownership, synchronization, and input boundaries. Do not infer concurrent invocation, attacker control, or error contracts from function names or package imports alone.
14
+
15
+ 2. **Do not duplicate deterministic tools** — Do not flag issues that the language compiler, formatter, linter, or type checker already catches reliably, unless the diff shows a concrete user-visible consequence those tools will not express.
16
+
17
+ 3. **Stay silent when context is unclear** — If the surrounding code, ownership, or data flow cannot be determined from available evidence, do not guess. A miss on an unclear code path is acceptable; a false alarm on it damages trust.
18
+
19
+ 4. **Distinguish blocking vs non-blocking** — Treat correctness and security findings as blocking (CRITICAL/HIGH). Style-only, idiom, or naming suggestions are non-blocking (LOW). Explicitly label each finding's severity.
20
+
21
+ 5. **No cargo-cult patterns** — Do not report a pattern just because it is "best practice." Evaluate whether the pattern applies to THIS codebase, THIS data flow, and THIS risk profile. If the code deviates from convention for a deliberate reason visible in context, accept it.
22
+
7
23
  ## When to Review
8
24
 
9
25
  **MANDATORY review triggers:**
@@ -85,6 +101,7 @@ Use these agents for code review:
85
101
 
86
102
  ### Security
87
103
 
104
+ - **Precision gate:** Before reporting any security issue, confirm the data source and attack surface with `code_search`. A pattern that looks like SQL injection but uses parameterized queries is not a finding.
88
105
  - Hardcoded credentials (API keys, passwords, tokens)
89
106
  - SQL injection (string concatenation in queries)
90
107
  - XSS vulnerabilities (unescaped user input)
@@ -0,0 +1,53 @@
1
+ ---
2
+ paths:
3
+ - "**/*.go"
4
+ - "**/go.mod"
5
+ - "**/go.sum"
6
+ ---
7
+ # Go Review Checklist
8
+
9
+ > Go-specific defect patterns for code review. Used together with [common/code-review.md](../common/code-review.md).
10
+ > **Precision over recall:** report only defects you are confident are real in the changed code. Verify claims with `file_read` and `code_search` before reporting.
11
+
12
+ ## Errors, Panics, and API Contracts
13
+
14
+ - Errors returned from calls that are ignored, overwritten, or converted into success/default values that hide a failure. A deliberately best-effort operation is acceptable only when the ignored failure is safe and evident from context.
15
+ - Error wrapping that loses the original cause (`fmt.Errorf("...: %v", err)` when callers need `errors.Is`/`errors.As`), wraps nil, returns a misleading sentinel, or exposes internal details at a public boundary. Prefer `%w` when preserving identity.
16
+ - `panic`, `log.Fatal`, `os.Exit` in request, worker, library, or cleanup paths where a recoverable error can be returned. Do not flag impossible internal invariants or documented programmer contracts.
17
+ - Deferred cleanup that overwrites a primary error, drops a meaningful `Close`/`Commit`/`Rollback` error, or returns success after cleanup makes the result invalid.
18
+
19
+ ## Nil, Interfaces, and Value Semantics
20
+
21
+ - A typed nil pointer, map, slice, function, channel, or error stored in a non-nil interface and later treated as absent. Check the concrete assignment and all interface checks first.
22
+ - Nil maps written to, nil channels used unintentionally (block forever), or nil pointers dereferenced on paths inputs or constructors can actually produce.
23
+ - Copying a value after first use when it contains `sync.Mutex`, `sync.RWMutex`, `sync.Once`, `sync.Pool`, `atomic` state, or another non-copyable synchronization primitive. Flag through value receivers, assignment, return, append, map values only when the value can have been used first.
24
+ - Value receivers or copies that silently mutate only a copy when callers expect shared state, especially for structs holding maps, slices, pointers, locks, or atomic state.
25
+ - `sync.Once` used for work that must retry after failure. `Once.Do` considers its func complete even if it panics; a captured error does not make a later `Do` retry.
26
+
27
+ ## Context, Goroutines, and Cancellation
28
+
29
+ - Request-scoped work started with `context.Background()`/`TODO()` when it should inherit the caller's deadline, cancellation, values, or tracing. Independent background work is valid.
30
+ - `context.Context` stored in a struct or replaced with a custom context interface when it should be passed explicitly as the first parameter.
31
+ - `context.WithCancel`, `WithTimeout`, `WithDeadline` whose cancel function is not called once the derived context is no longer needed.
32
+ - Blocking I/O, waits, retries, selects, or loops on a request/worker path that lack cancellation or deadline where the dependency can stall.
33
+ - Goroutines that can outlive their owner (wait forever on a channel, lock, I/O, unbounded retry), lack shutdown, or have no way for errors/completion to be observed when that matters.
34
+ - Fire-and-forget goroutines that capture request-local mutable data, write to a response after handler returns, panic without recovery at a process boundary, or race with cleanup.
35
+ - Loop-variable or mutable outer-variable captures in goroutines/callbacks where a closure can observe a later value. Verify the module's `go` directive (Go 1.22 changed range-loop semantics).
36
+
37
+ ## Channels, Locks, and Shared State
38
+
39
+ Only report races or deadlocks with evidence that state is reachable concurrently; inspect surrounding call sites. Do not flag immutable data, per-goroutine locals, or synchronization guaranteed by ownership.
40
+
41
+ - Unsynchronized concurrent reads/writes of maps, slices, pointers, counters, caches, or compound state; check-then-act sequences that can interleave.
42
+ - Holding a mutex/RWMutex across blocking I/O, channel operations, callbacks, network calls, or long CPU work when another path needs the lock to progress.
43
+ - `RLock` used while mutating protected data; unlocked mutation of a field whose peers protect it; atomic and non-atomic access mixed for the same state.
44
+ - Sends/receives that can block indefinitely because a peer may stop, a buffer may fill, or shutdown/cancellation is not selected.
45
+ - Multiple possible channel closers, send-on-closed-channel risk, or double-close.
46
+ - `select` defaults that busy-spin, drop required work, or bypass cancellation; unbounded retries without backoff/cancellation.
47
+ - WaitGroups with `Add` racing with `Wait`, missing `Done`, or concurrent Add after Wait begins.
48
+
49
+ ## Not for this rule
50
+
51
+ - Do not report issues that `go vet`, Staticcheck, `go test -race`, the compiler, or `gofmt` already catch reliably.
52
+ - Do not infer concurrent invocation, attacker control, resource ownership, or error contracts solely from function names or package imports.
53
+ - Do not flag intentional immutable value objects, single-threaded locals, or documented ownership patterns.
@@ -0,0 +1,70 @@
1
+ ---
2
+ paths:
3
+ - "**/*.py"
4
+ - "**/*.pyi"
5
+ ---
6
+ # Python Review Checklist
7
+
8
+ > Python-specific defect patterns for code review. Used together with [common/code-review.md](../common/code-review.md).
9
+ > **Precision over recall:** only raise an issue when confident it is a real defect. Stay silent when surrounding context is unclear. Treat security/correctness as blocking; style/idiom as non-blocking.
10
+
11
+ ## Mutable Default Arguments and Shared State
12
+
13
+ - Mutable default arguments (`def f(x=[])` or `def f(x={})`): the default is created once and shared across every call. Default to `None` and build inside the body.
14
+ - Class-level mutable attributes shared unintentionally across instances when a per-instance value was intended.
15
+ - Module-level mutable globals (lists, dicts, caches) mutated across requests or threads, retaining state that surprises the caller.
16
+ - Closures that capture a loop variable by reference and all end up seeing its final value.
17
+ - Do not report when the function never mutates the argument, or the shared default is a deliberate documented cache or sentinel.
18
+
19
+ ## Boundary and Edge-Case Handling
20
+
21
+ - Empty inputs assumed non-empty: indexing `xs[0]`, `max()`/`min()`, slicing without first handling empty `list`, `str`, `dict`, or iterator.
22
+ - Off-by-one and out-of-range access on indices, ranges, or slices, especially at first/last element.
23
+ - `None` reaching code that assumes a value, when an upstream call or default can legitimately return `None`. Confirm the data source with `file_read` before flagging.
24
+ - Comparing floats for exact equality with `==`; use `math.isclose` or explicit tolerance.
25
+ - Integer/float division assumptions: unintended truncation with `//`, or `ZeroDivisionError` when a divisor can be zero.
26
+ - Dictionary access by key without handling the missing-key case (`d[k]` vs `d.get(k)`).
27
+ - Do not report edge cases that a caller or type contract has already ruled out, or inputs that cannot occur given validated boundaries upstream.
28
+
29
+ ## Error Handling and Exceptions
30
+
31
+ - Bare `except:` swallows everything including `KeyboardInterrupt` and `SystemExit`; catch `except Exception` at minimum.
32
+ - `except Exception` broader than the failure being handled; narrow it to the specific exception types expected.
33
+ - Exceptions caught and silently discarded (`pass`) without logging or re-raising.
34
+ - Original traceback lost when re-raising; prefer `raise NewError(...) from err` to preserve the cause.
35
+ - Broad `try` blocks that wrap far more than the line that can actually fail, hiding where the error originates.
36
+ - `assert` used for runtime validation of external input — assertions are stripped under `python -O`.
37
+
38
+ ## Identity and Equality Comparisons
39
+
40
+ - Using `is`/`is not` to compare against literals (strings, numbers, tuples); this relies on implementation-specific interning rather than value equality — use `==`.
41
+ - Comparing against `True`/`False` with `==`, where a truthy-but-not-`True` value (e.g. `1`) would compare unequal; prefer plain truthiness check.
42
+ - Comparing against `None` with `==`/`!=` rather than `is`/`is not` — minor style preference.
43
+
44
+ ## Resource Management
45
+
46
+ - Files, sockets, locks, or DB connections opened without a `with` statement, risking leaks on early return or exception.
47
+ - Resources acquired in a `try` whose `finally` cleanup is missing or incomplete on the error path.
48
+ - Do not report short-lived scripts, or handles already managed by an enclosing `with` or framework.
49
+
50
+ ## Performance
51
+
52
+ Confirm data scale and hot path before flagging:
53
+ - Building strings with `+=` in a loop instead of accumulating in a list and `"".join(...)`.
54
+ - Repeated membership tests against a `list` where a `set` or `dict` would turn O(n) into O(1).
55
+ - Building a full list when a generator would avoid holding everything in memory.
56
+ - Passing eagerly formatted f-string to `logging` (`logging.info(f"...")`) instead of `logging.info("%s", value)`, which defeats lazy formatting.
57
+
58
+ ## Concurrency
59
+
60
+ Only flag when there is evidence of multi-threaded or async invocation (confirm with `code_search`):
61
+ - CPU-bound work parallelized with `threading` under the GIL where `multiprocessing` is the right tool.
62
+ - Check-then-act races on shared state without a `Lock`, or non-atomic compound operations.
63
+ - Do not report single-threaded locals, immutable data, or framework-managed async contexts.
64
+
65
+ ## Not for this rule
66
+
67
+ - Do not report spelling errors at reference sites (determined by the declaration).
68
+ - Do not report dead code that is intentionally preserved for documentation or future use.
69
+ - Do not report resource management issues in short-lived scripts.
70
+ - Do not flag style preferences that the project's formatter (black, ruff) already enforces.
@@ -38,6 +38,15 @@ Code review is **technical evaluation**, not social performance:
38
38
  - **Evidence before assertions:** cite specific code, not principles
39
39
  - **Architecture axis:** audit module depth and seams using `../references/module-design.md`
40
40
 
41
+ ### Precision gate
42
+
43
+ **Favor precision over recall.** A false positive costs more trust than a missed minor issue.
44
+ - Before reporting a non-local claim (race condition, security boundary, resource leak), use `file_read` and `code_search` to confirm evidence. Do not infer from names alone.
45
+ - Stay silent when the surrounding context is unclear. A miss on ambiguous code is acceptable; a false alarm is not.
46
+ - Do not flag issues that a compiler, formatter, linter, or type checker already catches, unless the diff shows a concrete user-visible consequence those tools miss.
47
+ - Label each finding with severity. Blocking (CRITICAL/HIGH) for correctness and security; non-blocking (LOW) for style and naming.
48
+ - Apply language-specific rules from `rules/{lang}/review-checklist.md` — they contain precise, actionable defect patterns per language.
49
+
41
50
  ## Handling findings
42
51
 
43
52
  1. **Read** — complete all findings without reacting
@@ -9,6 +9,29 @@ Use this skill after solving a problem so the repository gains a reusable learni
9
9
 
10
10
  See [shared pipeline instructions](../references/pipeline-config.md) for model routing and pipeline behavior.
11
11
 
12
+ ## Necessity gate (decide FIRST)
13
+
14
+ **Before writing anything, decide whether this learning is worth preserving.** Most solved problems are NOT worth a solution artifact. Silence is acceptable; noise is not.
15
+
16
+ ### Worth preserving (ALL must hold)
17
+
18
+ 1. **Non-trivial** — the solution required real investigation, not a one-glance fix.
19
+ 2. **Reusable** — the root cause or fix pattern could recur in this or another project.
20
+ 3. **Not already documented** — the knowledge is not trivially findable in framework docs, the codebase, a prior solution artifact, or a commit message.
21
+
22
+ ### Not worth preserving (any ONE is disqualifying)
23
+
24
+ - **One-off** — a typo, a rename, a personal-environment quirk unlikely to recur.
25
+ - **Common knowledge** — standard framework usage, language basics, or anything a competent practitioner would know or find in official docs in under a minute.
26
+ - **Already captured** — the learning is fully expressed in the code, its tests, a commit message, or an existing `docs/solutions/` artifact.
27
+ - **Trivial refactor** — formatting, import sorting, or mechanical changes with no insight.
28
+ - **No root cause insight** — the fix worked but you cannot explain *why* it worked; without the "why", the artifact will not help future readers.
29
+
30
+ ### Outcome
31
+
32
+ - If **not worth preserving**: respond concisely (e.g. "No solution artifact needed: <one-line reason>") and stop. Do not create a file.
33
+ - If **worth preserving**: proceed to Core rules below.
34
+
12
35
  ## Core rules
13
36
 
14
37
  - Every solution MUST include YAML frontmatter per `references/solution-schema.yaml` (title, category, severity, tags, applies_when).