nextlevelbuilder/ui-ux-pro-max-skill · error · ValueError

{} contains duplicate actions

Error message

{} contains duplicate actions

What it means

After per-action validation, parse_decision_rules rejects action arrays containing repeated identical entries (checked via len(actions) != len(set(actions))). The rules must be a set-like list: duplicates would double-apply the same mutation and bloat the audit trail apply_decision_rules produces.

Source

Thrown at src/ui-ux-pro-max/scripts/reasoning_contract.py:83


def parse_decision_rules(raw):
    """Parse the canonical condition -> action-array representation."""
    try:
        rules = json.loads(raw or "{}", object_pairs_hook=_object_without_duplicates)
    except json.JSONDecodeError as error:
        raise ValueError("invalid decision-rule JSON: {}".format(error)) from error
    if not isinstance(rules, dict):
        raise ValueError("decision rules must be a JSON object")
    for condition, actions in rules.items():
        if condition not in ALLOWED_CONDITIONS:
            raise ValueError("unknown decision-rule condition: {}".format(condition))
        if not isinstance(actions, list) or not actions:
            raise ValueError("{} must map to a non-empty action array".format(condition))
        for action in actions:
            _validate_action(action)
        if len(actions) != len(set(actions)):
            raise ValueError("{} contains duplicate actions".format(condition))
    return rules


def _validate_action(action):
    if not isinstance(action, str) or ":" not in action:
        raise ValueError("action must use a known prefix: {}".format(action))
    prefix, value = action.split(":", 1)
    if prefix not in ACTION_PREFIXES:
        raise ValueError("unknown decision-rule action: {}".format(action))
    if prefix in TOKEN_ACTION_PREFIXES and not TOKEN_RE.fullmatch(value):
        raise ValueError("invalid {} action value: {}".format(prefix, value))
    if prefix == "pattern" and not value.strip():
        raise ValueError("pattern action must name a pattern")
    if prefix == "mode" and value not in {"dark", "light"}:
        raise ValueError("mode action must be dark or light")


def apply_decision_rules(rules, query):

View on GitHub (pinned to a38d04c3d5)

Solutions

  1. Remove the duplicate entry named by inspection of the condition's array.
  2. Deduplicate while preserving order when merging: `list(dict.fromkeys(a + b))`.
  3. Add a pre-save lint that calls parse_decision_rules on the payload so duplicates are caught before commit.

Example fix

# before
merged = actions_a + actions_b

# after
merged = list(dict.fromkeys(actions_a + actions_b))
Defensive patterns

Strategy: validation

Validate before calling

import json
rules = json.loads(raw)
for cond, actions in rules.items():
    if len(actions) != len(set(actions)):
        dupes = {a for a in actions if actions.count(a) > 1}
        raise ValueError(f"{cond} contains duplicate actions: {sorted(dupes)}")

Prevention

When it happens

Trigger: Merging two rule lists with `actions_a + actions_b` without deduplicating, e.g. ["style:minimal", "mode:dark", "style:minimal"], or hand-editing a rule and re-adding an action that was already present.

Common situations: Programmatic composition of rule sets; copy-paste duplication while editing a long action array in a CSV cell.

Related errors


AI-assisted analysis of nextlevelbuilder/ui-ux-pro-max-skill@a38d04c3d5 (2026-08-14). Data as JSON: /api/errors/01385f1d2a9e4ef4. Report an issue: GitHub.