Fork ancestry

From PlamenTSV/plamen · View interactive version

Fork ancestry is an AI agent skill from the GitHub repository PlamenTSV/plamen. Trigger Pattern Always (run during recon TASK 0, not breadth) - Inject Into Recon agent only (meta_buffer.md enrichment)

How to use this skill

Skill file

FORK_ANCESTRY Skill (Sui)

Trigger Pattern: Always (run during recon TASK 0, not breadth)

Inject Into: Recon agent only (meta_buffer.md enrichment)

Finding prefix: [FA-N]

Purpose: Detect known parent Sui packages and inherit their historical vulnerability patterns.


1. Detect Fork Indicators

Grep the codebase for known parent Sui package signatures:

| Parent Project | Detection Patterns | Common Forks |

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

| Cetus | cetus\|clmm\|tick\|concentrated_liquidity\|cetus_clmm\|tick_math\|sqrt_price_math\|CetusPool | Concentrated liquidity forks |

| Suilend | suilend\|lending_market\|reserve\|obligation\|refresh_reserve\|LendingMarket\|ObligationKey | Lending protocol forks |

| NAVI | navi\|navi_protocol\|lending\|pool_manager\|incentive\|StoragePool\|navi_lending | Lending protocol forks |

| Scallop | scallop\|s_coin\|market\|obligation\|borrow_dynamics\|ScallopMarket\|sCoin | Lending protocol forks |

| Turbos | turbos\|pool_factory\|position_manager\|turbos_clmm\|TurbosPool\|TurbosPosition | Concentrated liquidity forks |

| Curve StableSwap | stable_swap\|stableswap\|get_d\|get_y\|ramp_a\|stop_ramp_a\|A_PRECISION\|RATE_MULTIPLIER\|calc_withdraw_one_coin\|remove_liquidity_imbalance\|get_virtual_price\|admin_fee | StableSwap AMM forks — set STABLESWAP_FORK flag if MEDIUM+ confidence |

| DeepBook | deepbook\|clob\|order_book\|custodian\|deep_book\|DeepBookPool\|BalanceManager | Order book DEX forks |

| Aftermath | aftermath\|af_lp\|pool_registry\|amm_v2\|AftermathPool\|StakedSui | AMM / liquid staking forks |

| Bucket | bucket\|bucket_protocol\|tank\|well\|fountain\|BucketProtocol\|BUCK | Stablecoin / CDP forks |

| Kriya | kriya\|kriya_dex\|spot_dex\|clmm\|KriyaPool\|KriyaPosition | DEX forks |

| FlowX | flowx\|flowx_clmm\|router\|pair_v2\|FlowXPool\|FlowXRouter | DEX forks |

| Sui System Staking | staking_pool\|validator\|sui_system\|delegation\|StakedSui\|StakingPool\|ValidatorCap | Liquid staking / validator forks |

Also check:

Git-based detection (complements code-pattern matching — catches forks that renamed all identifiers).

Skip if REPO_SHAPE: squashed_import in build_status.md — single-commit repos have no meaningful git metadata.

Output: List of detected parents with confidence level:


2. Query Known Parent Issues

For each detected parent (confidence MEDIUM or HIGH):

2a. Solodit Search (two queries, run in parallel)

// Query 1: Known high-quality issues
search_solodit_live(
  keywords="{parent_name} sui move",
  impact=["HIGH", "CRITICAL"],
  language="Move",
  quality_score=3,
  sort_by="Quality",
  max_results=15
)
// Query 2: Fork-specific divergence issues
search_solodit_live(
  keywords="{parent_name} fork modified sui object",
  impact=["HIGH", "MEDIUM"],
  language="Move",
  sort_by="Rarity",
  max_results=10
)

2b. Tavily Search

tavily_search(query="{parent_name} sui move vulnerability exploit audit finding 2024 2025 2026")

2c. Known Issue Catalog

Compile results into:

| Parent | Known Issue | Severity | Root Cause | Solodit Ref | Applicable to Fork? |

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

| {parent} | {issue title} | {severity} | {brief root cause} | {link/ID} | YES / NO / CHECK |

Applicability criteria:

2d. Hardcoded Known-Issue Floor (Web Search Fallback)

If Solodit AND Tavily BOTH fail, use this minimum catalog -- check EACH applicable parent.

This floor is keyed on the parent's TYPE (generic mechanism), NOT on any

specific protocol name — brand-keyed rows are prohibited (a floor row naming a

specific protocol is the confirmed benchmark-contamination vector; see the HARD

no-overfit rule). Classify the detected parent (from Section 1) into a type

below and check the generic known-issue class; use at most one illustrative

brand only in prose, never as the row key.

| Parent Type | Critical Known Issue | Root Cause | Search Keywords |

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

| CLMM DEX | Tick boundary crossing precision loss + liquidity accounting desync | sqrt_price calculation at tick boundaries, Position NFT state vs pool liquidity mismatch | clmm tick precision sqrt_price |

| Lending protocol (obligation-based) | Obligation refresh staleness + liquidation racing on shared objects | Reserve refresh not enforced before obligation health check, concurrent tx ordering | lending obligation refresh stale liquidation shared object |

| Lending protocol (pool-based) | Pool balance desync via flash loan deposit/withdraw + incentive calculation overflow | Balance tracking diverges from actual Coin balance, large TVL causes incentive arithmetic overflow | lending balance flash loan pool desync |

| Lending protocol (receipt-token) | Receipt token exchange rate manipulation via first depositor + borrow dynamics staleness | Empty market rounding in receipt token minting, stale interest rate applied across epochs | lending receipt token exchange rate first deposit borrow dynamics |

| Orderbook DEX | Order matching priority manipulation + balance manager accounting edge cases | Self-trading for priority manipulation, dust amounts in partial fills | orderbook order priority self-trade balance dust |

| CDP/stablecoin protocol | Reward distribution fairness + overflow at extreme collateral ratios | Discrete epoch distribution timing, arithmetic overflow in collateral ratio calculation | cdp reward epoch collateral overflow |

| Liquid staking / validator protocol | Validator list manipulation via stake deposit ordering + reward fee timing | Stake account priority ordering in validator selection, reward distribution during epoch boundary | sui staking validator reward epoch boundary |

| AMM / LP share pool | LP share price manipulation via donation to pool + liquid-staking-token exchange rate lag | Direct Coin transfer to pool object inflates share price, staking rewards not reflected immediately in the receipt token's exchange rate | amm pool share price donation staking token exchange rate |


3. Divergence Analysis

For each detected parent:

3a. Identify What Changed

Compare fork vs parent in security-critical paths:

| Component | Parent Behavior | Fork Behavior | Security Impact |

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

| {component} | {original} | {modified or SAME} | {new risk or NONE} |

Sui-specific divergence focus areas (ordered by criticality):

Object Ownership Model Changes (HIGHEST PRIORITY)
Capability and Admin Pattern Changes
Balance and Coin Handling Changes
Dynamic Field Schema Changes
Other Divergence Areas

3b. New Attack Surface from Divergence

For each modification:


4. Output to meta_buffer.md

Append to {SCRATCHPAD}/meta_buffer.md:

## Fork Ancestry Analysis

### Detected Parents
| Parent | Confidence | Patterns Found | Move.toml Dependency? |
|--------|-----------|---------------|----------------------|

### Inherited Vulnerabilities to Verify
| # | Parent Issue | Severity | Location in Fork | Status |
|---|-------------|----------|------------------|--------|
| 1 | {issue} | {severity} | {fork location: module::function} | CHECK / VERIFIED_SAFE / VULNERABLE |

### Fork Divergences (Security-Critical)
| # | Component | Change Type | Change Description | New Risk? |
|---|-----------|------------|-------------------|-----------|
| 1 | {component} | OWNERSHIP_MODEL / CAPABILITY / BALANCE / DYNAMIC_FIELD / OTHER | {what changed} | YES/NO/CHECK |

### Questions for Breadth Agents
1. {derived from inherited vulnerabilities}
2. {derived from divergence analysis}
3. {derived from ownership model changes}

Step Execution Checklist (MANDATORY)

| Section | Required | Completed? | Notes |

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

| 1. Detect Fork Indicators | YES | Y/N/? | Check Move.toml deps + source patterns |

| 2. Query Known Parent Issues | IF parent detected | Y/N(no parent)/? | |

| 2d. Hardcoded Known-Issue Floor | IF Solodit+Tavily both fail | Y/N(not needed)/? | |

| 3. Divergence Analysis | IF parent detected | Y/N(no parent)/? | |

| 3a. Object Ownership Model Changes | IF parent detected | Y/N(no parent)/? | Highest priority |

| 3a. Capability and Admin Pattern Changes | IF parent detected | Y/N(no parent)/? | |

| 3a. Balance and Coin Handling Changes | IF parent detected | Y/N(no parent)/? | |

| 3a. Dynamic Field Schema Changes | IF parent detected | Y/N(no parent)/? | |

| 4. Output to meta_buffer.md | YES | Y/N/? | |

Cross-Reference Markers

After Step 1: If Move.toml shows specific parent package address dependencies, verify the addresses match known mainnet deployments (not test/devnet).

After Step 3a (Ownership Model): Feed changed ownership models to OBJECT_OWNERSHIP skill for targeted re-analysis of affected objects.

After Step 3a (Capability): Feed new/changed capabilities to SEMI_TRUSTED_ROLES skill for admin privilege analysis.

After Step 3a (Balance): Feed changed balance handling to TOKEN_FLOW_TRACING skill for flow analysis.

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.