Outcome determinism

From PlamenTSV/plamen · View interactive version

Outcome determinism is an AI agent skill from the GitHub repository PlamenTSV/plamen. Protocol Type Trigger outcome_determinism - detected when EITHER of these code patterns are present - - Selection from finite depletable pool with fallback behavior (while(full)...

How to use this skill

Skill file

Injectable Skill: Outcome Determinism - Selection Fairness & Strategic Timing

Protocol Type Trigger: outcome_determinism - detected when EITHER of these code patterns are present:

- Selection from finite depletable pool with fallback behavior (while(full) next, modulo with shrinking domain, category/slot/validator selection)

- Time-gated actions with observable default/fallback outcomes (deadline, claimPeriod, defaultSelection, expiry + fallback path that computes from predictable state)

Inject Into: Breadth agents, depth-edge-case

Language: All (rational actor patterns are chain-agnostic)

Finding prefix: [OD-N]

Added in: v1.1

NOTE: Callback selective revert (Section 1a of the original skill) and RNG consumption enumeration (Section 1b) are now ALWAYS-ON checks in the depth agent template - they do not require this injectable to trigger.

What This Injectable Adds (beyond always-on checks)

The always-on depth template already covers:

This injectable adds analysis that only applies when SPECIFIC structural patterns exist:


1. Selection Fairness Under Constraint Changes

For every selection algorithm operating on a set that can shrink, grow, or be modified between selections:

1a. Probability Redistribution on Depletion

| Selection Function | Pool Size | Depletion Mechanism | Fallback Behavior | Redistribution Fair? |

|-------------------|-----------|--------------------|--------------------|---------------------|

Fairness test: When element X is removed from a pool of N:

Common biased patterns across protocol types:

Quantify: At each depletion level (1-of-N, N/2-of-N, N-1-of-N), what is the maximum probability deviation from uniform? Is it exploitable (can the actor influence which elements deplete first)?

Tag: [VARIATION:pool N→N-K → element X probability 1/N→{new_prob} → bias={factor}x]

1b. Admin Parameter Regression on Selection Algorithms

For bounded parameters (caps, limits, quotas) where the bound can be LOWERED below already-accumulated state and the bound is used by a selection/iteration algorithm:

| Parameter | Setter | Current Accumulated | Can Set Below Accumulated? | Selection Algorithm Affected | What Breaks? |

|-----------|--------|--------------------|--------------------------|-------|--------------|

This extends Rule 14 (Setter Regression) specifically for selection/allocation algorithms: when a cap is lowered below the current count, does the selection algorithm's termination condition still hold? (e.g., while (count == max) becomes unreachable when count > max)


2. Strategic Timing - Delay, Front-Run, Sequence

Core question: For each user-facing action, is the TIMING of the action exploitable by a rational self-interested actor?

2a. Delay-vs-Act Rationality

For every time-gated action with a default or fallback:

| Action | Active Path | Default/Fallback Path | Default Predictable? | Default Sometimes Better? | Delay Cost |

|--------|-----------|----------------------|---------------------|--------------------------|-----------|

A rational actor will delay when ALL THREE hold:

  1. The default outcome is predictable (computed from observable on-chain state, not future unknowns)
  2. The default is sometimes better than the active choice (different formula, different prices, different parameters)
  3. The cost of waiting (opportunity cost, gas, penalty) is lower than the expected value gain

Cross-protocol examples:

Methodology:

  1. Identify the active path (user calls function before deadline)
  2. Identify the default path (what happens if user doesn't act - system assigns default, claim expires, fallback triggers)
  3. Is the default outcome computable from CURRENT on-chain state? (If it depends on future block hash or unresolved oracle → not predictable → no strategic edge)
  4. Compare: under what market/state conditions is default > active? How often do those conditions occur?
  5. What does delay cost? (forfeiture, penalty, opportunity cost, gas savings)

Tag: [TRACE:action={fn} deadline={T} → default={fallback_fn} → computed_from={state_vars} → predictable={YES/NO} → default_better_when={condition}]

2b. Admin Action Information Asymmetry

For every admin-settable parameter that affects pending or future user operations:

| Parameter | Setter | Timelock? | Event Emitted? | Affects Pending Operations? | Asymmetry Window |

|-----------|--------|-----------|---------------|---------------------------|-----------------|

Applies universally - any onlyOwner/onlyAdmin setter that changes a parameter used in user-facing calculations creates a window where the admin knows the new value but users don't.

Severity factors:

2c. Sequence-Dependent Outcomes

For actions where the ORDER of multiple actors matters:

| Action | Same-Block Ordering Matters? | Cross-Block Ordering Matters? | First-Mover Advantage? | Last-Mover Advantage? |

|--------|----------------------------|------------------------------|----------------------|---------------------|

Check: Can an actor observe others' pending actions (mempool) and position before/after them for profit?


Key Questions (must answer all)

  1. For each selection from a shrinking pool: does probability redistribute uniformly? Quantify the bias.
  2. For each time-gated action: is the default/fallback predictable and sometimes better than active choice?
  3. For each admin setter: what is the information asymmetry window? Does it affect pending operations?
  4. For each multi-actor sequence: can ordering be exploited?

Common False Positives

Step Execution Checklist (MANDATORY)

| Section | Required | Completed? | Notes |

|---------|----------|------------|-------|

| 1a. Depletion Redistribution | IF selection from finite/depletable pool | | Quantify bias at each depletion level |

| 1b. Parameter Regression on Selection | IF admin can lower cap below accumulated AND cap used by selection algo | | Extends Rule 14 |

| 2a. Delay-vs-Act Rationality | IF time-gated action with default/fallback | | Check all three conditions |

| 2b. Admin Information Asymmetry | IF admin setter affects pending user operations | | Check timelock AND event emission |

| 2c. Sequence-Dependent Outcomes | IF multiple actors' ordering affects results | | Check same-block and cross-block |

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.