Eishaan commited on
Commit
f294208
·
1 Parent(s): 306d70e

fix: 3 bugs (dead except block, inflated rewards, autocommit conflict) + cleanup

Browse files
__pycache__/models.cpython-312.pyc CHANGED
Binary files a/__pycache__/models.cpython-312.pyc and b/__pycache__/models.cpython-312.pyc differ
 
models.py CHANGED
@@ -104,7 +104,7 @@ class MigrationState(State):
104
  """
105
  State for the SQL Migration Environment.
106
 
107
- Returned by the state() property. Contains episode metadata.
108
 
109
  Inherits from State:
110
  episode_id: str — Unique episode identifier
 
104
  """
105
  State for the SQL Migration Environment.
106
 
107
+ Returned by the state() method. Contains episode metadata.
108
 
109
  Inherits from State:
110
  episode_id: str — Unique episode identifier
server/__pycache__/environment.cpython-312.pyc CHANGED
Binary files a/server/__pycache__/environment.cpython-312.pyc and b/server/__pycache__/environment.cpython-312.pyc differ
 
server/environment.py CHANGED
@@ -16,7 +16,6 @@ Architecture Fixes Applied:
16
 
17
  import re
18
  import sqlite3
19
- import threading
20
  import uuid
21
  import difflib
22
  from typing import Any, Dict, List, Optional
@@ -53,9 +52,7 @@ _TX_END = re.compile(r"^\s*(COMMIT|END|END\s+TRANSACTION|ROLLBACK)\s*;?\s*$", re
53
  _MAX_OPS = 500_000 # ~5 seconds on typical hardware
54
 
55
 
56
- class _TimeoutError(Exception):
57
- """Raised when SQL execution exceeds the operation budget."""
58
- pass
59
 
60
 
61
  class DbMigrationEnvironment(Environment):
@@ -142,8 +139,13 @@ class DbMigrationEnvironment(Environment):
142
  cursor = self._conn.execute(sql)
143
  return cursor, None
144
  except sqlite3.OperationalError as e:
145
- if "interrupted" in str(e).lower() or ops_count[0] > _MAX_OPS:
 
146
  return None, "Error: Query exceeded execution time limit (possible infinite loop). Simplify your query."
 
 
 
 
147
  return None, str(e)
148
  except sqlite3.Warning as e:
149
  # Multi-statement fallback
@@ -152,13 +154,6 @@ class DbMigrationEnvironment(Environment):
152
  return None, None
153
  except Exception as script_e:
154
  return None, f"Error (Multi-Statement Fallback Failed): {script_e}. Original error: {e}"
155
- except sqlite3.OperationalError as e:
156
- err_str = str(e).lower()
157
- if "table" in err_str and "already exists" in err_str:
158
- return None, f"Schema Error: {e}. You must DROP the old table first if replacing it."
159
- if "has no column" in err_str:
160
- return None, f"Schema Error: {e}. Check table columns."
161
- return None, str(e)
162
  except Exception as e:
163
  err_str = str(e).lower()
164
  if "values for" in err_str and "columns" in err_str:
@@ -227,7 +222,7 @@ class DbMigrationEnvironment(Environment):
227
  self._conn = None
228
 
229
  # Create fresh in-memory database
230
- self._conn = sqlite3.connect(":memory:", isolation_level=None)
231
 
232
  # Performance PRAGMAs for Docker I/O
233
  self._conn.execute("PRAGMA journal_mode = MEMORY")
@@ -253,8 +248,9 @@ class DbMigrationEnvironment(Environment):
253
  max_steps=self._max_steps, # A6
254
  )
255
 
256
- # Compute initial score
257
  initial_score = self._reconciler.score(self._conn)
 
258
  self._state.migration_progress = initial_score
259
 
260
  current_ddl = self._get_current_schema()
 
16
 
17
  import re
18
  import sqlite3
 
19
  import uuid
20
  import difflib
21
  from typing import Any, Dict, List, Optional
 
52
  _MAX_OPS = 500_000 # ~5 seconds on typical hardware
53
 
54
 
55
+ # (Timeout handled via progress handler return value, no exception needed)
 
 
56
 
57
 
58
  class DbMigrationEnvironment(Environment):
 
139
  cursor = self._conn.execute(sql)
140
  return cursor, None
141
  except sqlite3.OperationalError as e:
142
+ err_str = str(e).lower()
143
+ if "interrupted" in err_str or ops_count[0] > _MAX_OPS:
144
  return None, "Error: Query exceeded execution time limit (possible infinite loop). Simplify your query."
145
+ if "table" in err_str and "already exists" in err_str:
146
+ return None, f"Schema Error: {e}. You must DROP the old table first if replacing it."
147
+ if "has no column" in err_str:
148
+ return None, f"Schema Error: {e}. Check table columns."
149
  return None, str(e)
150
  except sqlite3.Warning as e:
151
  # Multi-statement fallback
 
154
  return None, None
155
  except Exception as script_e:
156
  return None, f"Error (Multi-Statement Fallback Failed): {script_e}. Original error: {e}"
 
 
 
 
 
 
 
157
  except Exception as e:
158
  err_str = str(e).lower()
159
  if "values for" in err_str and "columns" in err_str:
 
222
  self._conn = None
223
 
224
  # Create fresh in-memory database
225
+ self._conn = sqlite3.connect(":memory:")
226
 
227
  # Performance PRAGMAs for Docker I/O
228
  self._conn.execute("PRAGMA journal_mode = MEMORY")
 
248
  max_steps=self._max_steps, # A6
249
  )
250
 
251
+ # Compute initial score and sync grader baseline
252
  initial_score = self._reconciler.score(self._conn)
253
+ self._reconciler._last_score = initial_score # Prevent inflated first-step reward
254
  self._state.migration_progress = initial_score
255
 
256
  current_ddl = self._get_current_schema()