> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stateset.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Noise-based rule demotion — the pruning counterpart of evidence-based

> promotion. Disables mined flywheel:* rules that fire on decisions without ever being relevant (high noise ratio over a minimum sample)…

promotion. Disables mined `flywheel:*` rules that fire on decisions
without ever being relevant (high noise ratio over a minimum sample);
curated policy is flagged for an operator but never auto-disabled.

**Required scope:** `write`

### Request body

`DemoteNoisyRequest`

<ParamField body="dry_run" type="boolean">
  Preview only: report what WOULD be demoted without disabling anything.
</ParamField>

<ParamField body="min_noise_ratio" type="number (double)">
  Minimum noise ratio to qualify (default 0.9) — mostly noise.
</ParamField>

<ParamField body="min_sample" type="integer">
  Minimum total observations (cited + noise) before a rule is eligible (default 10) — never demote on thin evidence.
</ParamField>

<ParamField body="window_secs" type="integer (int64)">
  Analytics window in seconds (default 7d, cap 30d).
</ParamField>

### Response

`DemoteNoisyResponse`

<ResponseField name="demoted" type="DemotedRule[]" required>
  Mined `flywheel:*` rules disabled (reversible; re-enable via PATCH).

  <Expandable title="DemotedRule">
    <ResponseField name="noise_count" type="integer" required />

    <ResponseField name="noise_ratio" type="number (double)" required />

    <ResponseField name="rule" type="string" required />

    <ResponseField name="rule_id" type="string" required />
  </Expandable>
</ResponseField>

<ResponseField name="dry_run" type="boolean" required />

<ResponseField name="evaluated" type="integer" required>
  Rules that met the threshold (auto + curated).
</ResponseField>

<ResponseField name="flagged_curated" type="DemotionCandidate[]" required>
  Curated/user rules that met the noise threshold but were NOT touched — an operator must review these; the system never auto-disables policy.

  <Expandable title="DemotionCandidate">
    <ResponseField name="auto_demotable" type="boolean" required>
      True for mined `flywheel:*` rules (safe to auto-disable); false for curated/user policy (flagged for an operator, never auto-disabled).
    </ResponseField>

    <ResponseField name="cited_count" type="integer" required />

    <ResponseField name="noise_count" type="integer" required />

    <ResponseField name="noise_ratio" type="number (double)" required>
      `noise / (cited + noise)` at selection time.
    </ResponseField>

    <ResponseField name="rule" type="string" required />
  </Expandable>
</ResponseField>

### Status codes

| Code  | Meaning                                            |
| ----- | -------------------------------------------------- |
| `200` | Demotion result                                    |
| `401` | Unauthorized — missing or invalid credentials      |
| `403` | Forbidden — the key/token lacks the required scope |
| `429` | Rate limited — see Retry-After / X-RateLimit-Reset |

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url 'https://api.nsr.stateset.com/api/v1/flywheel/demote-noisy' \
    --header 'X-API-Key: YOUR_API_KEY' \
    --header 'Content-Type: application/json' \
    --data '{
    "dry_run": false,
    "min_noise_ratio": 7.5,
    "min_sample": 1,
    "window_secs": 1
  }'
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "demoted": [
      {
        "noise_count": 1,
        "noise_ratio": 7.5,
        "rule": "string",
        "rule_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
      }
    ],
    "dry_run": false,
    "evaluated": 1,
    "flagged_curated": [
      {
        "auto_demotable": true,
        "cited_count": 1,
        "noise_count": 1,
        "noise_ratio": 7.5,
        "rule": "string"
      }
    ]
  }
  ```
</ResponseExample>
