agents/skills/injectable/l1/consensus-math-correctness/SKILL.md
L1 trigger - audits consensus arithmetic for truncation, unused bounds, EMA direction, and threshold edge errors.
npx skillsauth add plamentsv/plamen consensus-math-correctnessInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
L1 trigger:
CONSENSUSflag AND (adjust_difficultyORdifficulty_adjustORemaORmoving_averageORreward_curveORtarget_timedetected) Inject Into:depth-consensus-invariantordepth-edge-caseLanguage: Go and Rust Finding prefix:[CM-N]
Consensus math bugs are small, deterministic, and load-bearing. They rarely need fancy exploit chains: one wrong operator, one dead bound, or one flipped EMA direction can permanently skew the chain.
For every expression of the form (A / B) * C, test whether A < B is
possible. If so, the intermediate division truncates to zero before the
multiplication and the protocol silently loses precision.
Questions:
A < B happen at runtime?(A * C) / B?Tag: [CONSENSUS-MATH:DIV-FIRST]
Consensus configs often declare bounds that never influence runtime math.
Questions:
max_difficulty_adjustment_factor, min_reward, max_step_count.Tag: [CONSENSUS-MATH:UNUSED-BOUND]
For each moving-average implementation, identify the prior sample, current sample, and smoothing factor.
Questions:
Tag: [CONSENSUS-MATH:EMA-DIRECTION]
Consensus edge cases often live at threshold-1, threshold, and
threshold+1.
Questions:
> / >= / < / <= gate in consensus math, what does the
protocol text say should happen exactly at the threshold?threshold-1, threshold, and threshold+1?Tag: [CONSENSUS-MATH:BOUNDARY-OP]
Difficulty and reward math often expresses "increase/decrease by X%" using integer ratios or fixed-point factors. Enumerate the exact vectors:
| Input | Expected | Observed | |---|---|---| | no change | factor = 1.0 | | | minimum decrease | factor just below 1.0 | | | maximum decrease | e.g. 50% decrease | | | maximum increase | configured cap | | | denominator near zero | reject / clamp | |
Mandatory checks:
max_*_adjustment_factor, prove it clamps both
upward and downward movement at runtime.> vs >= at every clamp boundary.Tag: [CONSENSUS-MATH:RATIO-EDGE]
If consensus math uses f32, f64, log, log10, pow, platform C math,
SIMD, CUDA, or FFI:
Tag: [CONSENSUS-MATH:NONDET-FP]
[CONFORMANCE-PASS] > [NON-DET-PASS] >
[LSP-TRACE] > [CODE-TRACE]data-ai
Trigger Pattern Always (run during recon TASK 0, not breadth) - Inject Into Recon agent only (meta_buffer.md enrichment)
data-ai
Trigger Pattern Always (run during recon TASK 0, not breadth) - Inject Into Recon agent only (meta_buffer.md enrichment)
data-ai
Trigger Pattern Always (run during recon TASK 0, not breadth) - Inject Into Recon agent only (meta_buffer.md enrichment)
data-ai
Trigger STABLESWAP_FORK flag (fork-ancestry detects Curve/StableSwap parent via get_d/get_y/ramp_a/StableSwap patterns) - Agent Type general-purpose (standalone niche agent, 1 budget slot)