CoolFace
Apppublic

RonyForAI/Mirage_DB_RL

sourceHugging Faceupdated 6mo agoView on Hugging Face
0likes
openenv.yaml135 linesDownload Raw Back to root
1spec_version: 12name: Mirage_RL3type: space4runtime: fastapi5app: server.app:app6port: 80007 8description: >9  Mirage_RL is a reinforcement-learning environment for database query10  join-order optimisation. An AI agent must decide which tables to join,11  in which order, and using which join strategy (hash / nested-loop /12  merge-sort) to minimise the total estimated join cost.13  Three difficulty tiers are available: Easy (3 tables), Medium (5 tables),14  and Hard (7 tables with mixed index availability and high cardinality noise).15 16author: meta-hackathon-team17 18tasks:19  - id: easy20    name: "OLTP Join Optimizer — 3-Table Queries"21    difficulty: easy22    description: >23      Optimise join order for 3-table production OLTP queries (e-commerce24      and SaaS schemas). All tables have covering indexes. Statistics are25      accurate (noise sigma <= 0.06). Score in [0.0, 1.0].26    num_tables: 327    max_steps: 328 29  - id: medium30    name: "OLAP Join Optimizer — 5-Table Queries with Estimation Noise"31    difficulty: medium32    description: >33      Optimise join order for 5-table analytical queries across e-commerce,34      marketing, and financial schemas. Some tables lack indexes. Cardinality35      estimates contain realistic noise (sigma 0.05-0.25). Score in [0.0, 1.0].36    num_tables: 537    max_steps: 538 39  - id: hard40    name: "Complex OLAP Join Optimizer — 7-Table Queries, High Noise"41    difficulty: hard42    description: >43      Optimise join order for 7-table enterprise analytical queries including44      billion-row event tables, missing indexes, and high cardinality estimation45      noise (sigma up to 0.60). 7-factorial = 5040 possible orderings.46      Score in [0.0, 1.0].47    num_tables: 748    max_steps: 749 50reward_range: [0.0, 1.0]51 52action_schema:53  type: object54  required: [next_table, join_type, use_index]55  properties:56    next_table:57      type: integer58      minimum: 059      description: >60        Index of the next table to add to the join tree.61        Must be selected from the current remaining_tables list.62    join_type:63      type: integer64      enum: [0, 1, 2]65      description: >66        Join algorithm to use.67        0 = hash join (1.0× cost multiplier),68        1 = nested-loop join (2.0× — most expensive),69        2 = merge-sort join (0.8× — cheapest).70    use_index:71      type: integer72      enum: [0, 1]73      description: >74        Whether to use an index scan on this table.75        1 = use index (halves base row count when index is available),76        0 = full table scan.77 78observation_schema:79  type: object80  properties:81    tables:82      type: array83      items: {type: string}84      description: "Ordered list of table names for the current task."85    table_rows:86      type: array87      items: {type: integer}88      description: "Estimated row count for each table."89    selectivities:90      type: array91      items: {type: number}92      description: >93        Join selectivity for each table — the fraction of rows that pass94        the join predicate (lower means fewer output rows).95    has_index:96      type: array97      items: {type: integer}98      description: >99        Index availability per table: 1 = index present, 0 = no index.100    chosen_order:101      type: array102      items: {type: integer}103      description: "Indices of tables already added to the join tree, in order."104    remaining_tables:105      type: array106      items: {type: integer}107      description: "Indices of tables not yet joined (valid choices for next_table)."108    step_number:109      type: integer110      description: "Zero-based step counter within the current episode."111    current_cost:112      type: number113      description: "Accumulated join cost across all steps so far."114    intermediate_size:115      type: number116      minimum: 1.0117      description: >118        Estimated size of the intermediate result accumulated across all joined119        tables so far. Computed as the product of (est_rows x selectivity) for120        each joined table using the agent-visible estimated cardinalities.121        Joining large-output tables early causes this to grow rapidly, compounding122        all subsequent join costs. The agent should prefer joining small-output123        (selective) tables first to keep this value small.124    done:125      type: boolean126      description: "True when all tables have been joined (episode complete)."127    reward:128      type: number129      minimum: 0.0130      maximum: 1.0131      description: >132        Normalised reward for this step in [0.0, 1.0].133        Per-step: quality of join choice relative to worst/best for that table.134        Final step: combined score = 60% method quality + 40% order quality.135