nihalaninihal commited on
Commit
7f33a54
·
1 Parent(s): 389e3bf

Add master improvement plan with prioritized fixes for hackathon submission

Browse files

Identifies 4 critical bugs, 3 high-impact improvements, and 2 quick wins.
Total estimated implementation time: ~57 minutes.
Focused on Patronus AI (schema/policy drift) and Fleet AI (scalable oversight) tracks.

Files changed (1) hide show
  1. tasks/master-plan.md +249 -0
tasks/master-plan.md ADDED
@@ -0,0 +1,249 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SentinelOps Arena -- Master Improvement Plan
2
+
3
+ **Created:** Sunday March 8, 2026
4
+ **Goal:** Maximize hackathon judging score with surgical code fixes
5
+
6
+ ---
7
+
8
+ ## Priority Legend
9
+
10
+ | Score | Meaning |
11
+ |-------|---------|
12
+ | 10 | Must fix -- breaks core functionality or judges will reject |
13
+ | 8-9 | High impact -- judges will directly notice and reward |
14
+ | 5-7 | Noticeable improvement -- strengthens the demo |
15
+ | 1-4 | Low impact -- skip unless time permits |
16
+
17
+ ---
18
+
19
+ ## CRITICAL FIXES (Bugs that break core functionality)
20
+
21
+ ### FIX-1: Billing `issue_refund()` never checks `window_ticks` [Priority: 10]
22
+
23
+ **Bug:** `billing.py:issue_refund()` checks `max_amount` and `requires_approval` but NEVER checks `window_ticks`. Policy drift attacks that change `window_ticks` have zero effect on refund validation. This means 1/3 of policy drift parameters is dead code.
24
+
25
+ **File:** `sentinelops_arena/systems/billing.py` (lines 47-89)
26
+ **Change:** Add window_ticks validation. The invoice has `date_tick` and the environment tracks the current tick. Pass `current_tick` into `issue_refund()` and compare `current_tick - invoice["date_tick"]` against `self.refund_policy.window_ticks`.
27
+ **Impact:** Policy drift attacks now meaningfully change refund behavior. Patronus AI judges (schema/policy drift track) will directly verify this works.
28
+ **Lines of code:** ~10 lines in billing.py, ~3 lines in environment.py to pass current_tick
29
+
30
+ **Details:**
31
+ - Add `current_tick: int` parameter to `issue_refund()`
32
+ - After the existing checks, add:
33
+ ```python
34
+ ticks_since_invoice = current_tick - invoice.get("date_tick", 0)
35
+ if ticks_since_invoice > self.refund_policy.window_ticks:
36
+ return {"error": f"Refund window expired. Invoice is {ticks_since_invoice} ticks old, policy allows {self.refund_policy.window_ticks}"}
37
+ ```
38
+ - Update environment.py `_execute_worker_action` to pass `self.tick`
39
+ - Update the MCP tool `issue_refund` to pass `self.tick`
40
+
41
+ ---
42
+
43
+ ### FIX-2: CRM and Ticketing have no rate limiting support [Priority: 8]
44
+
45
+ **Bug:** `attacks.py:_execute_rate_limit()` calls `system.set_rate_limit()`, but only `BillingSystem` implements it. `CRMSystem` and `TicketingSystem` have no `set_rate_limit`, `_rate_limit`, `_call_count`, or `_rate_limit_check()`. The attack manager already checks `hasattr(system, "set_rate_limit")` and returns error, but the attacker can still target CRM/ticketing and waste budget.
46
+
47
+ **File:** `sentinelops_arena/systems/crm.py`, `sentinelops_arena/systems/ticketing.py`
48
+ **Change:** Add rate limiting to CRM and Ticketing, mirroring BillingSystem's implementation.
49
+ **Impact:** Rate limit attacks now work on all 3 systems. The `_is_rate_limited()` check in environment.py (line 601-606) already handles this via `hasattr(system, "_rate_limit")`, so once the attribute exists, rate limiting shows up in the dashboard.
50
+ **Lines of code:** ~20 lines per system (copy from billing.py pattern)
51
+
52
+ **Details for each system (CRM + Ticketing):**
53
+ - Add `self._rate_limit: int = 0` and `self._call_count: int = 0` to `__init__`
54
+ - Add `_rate_limit_check()` method (copy from billing.py)
55
+ - Add `set_rate_limit()` method (copy from billing.py)
56
+ - Add `reset_rate_limit_counter()` method (copy from billing.py)
57
+ - Add `if self._rate_limit_check(): return {"error": "Rate limit exceeded."}` to `lookup_customer`, `update_tier`, `add_note`, `get_history`, and for ticketing: `create_ticket`, `assign_ticket`, `escalate`, `resolve`, `check_sla`
58
+ - Update environment.py to reset CRM and ticketing counters each tick (add to the tick-advance block at line 346)
59
+
60
+ ---
61
+
62
+ ### FIX-3: Schema drift renames target non-existent fields [Priority: 7]
63
+
64
+ **Bug:** `SCHEMA_DRIFT_RENAMES` in `demo.py` includes `{"old_field": "email", ...}`, `{"old_field": "address", ...}`, `{"old_field": "phone", ...}`, `{"old_field": "id", ...}`. But the Customer model has fields: `customer_id`, `name`, `tier`, `region`, `contact_email`, `lifetime_value`, `notes`. Only `name -> full_name` actually works. The others silently do nothing because the fields don't exist.
65
+
66
+ **File:** `sentinelops_arena/demo.py` (lines 125-131)
67
+ **Change:** Fix renames to use actual Customer model field names.
68
+ **Lines of code:** ~5 lines
69
+
70
+ **New renames:**
71
+ ```python
72
+ SCHEMA_DRIFT_RENAMES = [
73
+ {"old_field": "name", "new_field": "full_name"},
74
+ {"old_field": "contact_email", "new_field": "email_address"},
75
+ {"old_field": "region", "new_field": "territory"},
76
+ {"old_field": "tier", "new_field": "membership_level"},
77
+ {"old_field": "lifetime_value", "new_field": "total_spend"},
78
+ ]
79
+ ```
80
+
81
+ Also fix in `train.py` (lines 311-312) which has the same bad renames.
82
+
83
+ ---
84
+
85
+ ### FIX-4: `tasks_completed` count is always 0 [Priority: 5]
86
+
87
+ **Bug:** `environment.py` line 356-360 counts `tasks_completed` by checking `t.get("task_completed")` in trajectory entries, but no trajectory entry ever sets `task_completed = True`. The trajectory append at line 329-336 only stores `tick`, `agent`, `action_type`, `reward`.
88
+
89
+ **File:** `sentinelops_arena/environment.py` (lines 329-336, 356-360)
90
+ **Change:** Add `task_completed` flag to trajectory entries when worker successfully completes a task.
91
+ **Lines of code:** ~3 lines
92
+
93
+ **Details:**
94
+ - In the trajectory append, add `"task_completed": (action.agent == AgentRole.WORKER and self.last_worker_result and self.last_worker_result.get("success", False))`
95
+ - Or simpler: after computing worker reward, if result["success"], set a flag on the trajectory entry
96
+
97
+ ---
98
+
99
+ ## HIGH-IMPACT IMPROVEMENTS (Things judges will notice/reward)
100
+
101
+ ### IMP-1: Apply Gradio theme in `gr.Blocks()` constructor [Priority: 9]
102
+
103
+ **Bug:** The `SentinelTheme()` and `CUSTOM_CSS` are passed to `demo.launch()` but NOT to `gr.Blocks()`. On HuggingFace Spaces, `launch()` args may be ignored. The theme must be in the constructor.
104
+
105
+ **File:** `app.py` (line 124, line 444-448)
106
+ **Change:** Move theme and css into `gr.Blocks()`:
107
+ ```python
108
+ with gr.Blocks(title="SentinelOps Arena", fill_width=True, theme=SentinelTheme(), css=CUSTOM_CSS) as demo:
109
+ ```
110
+ Remove duplicate theme/css from `demo.launch()`.
111
+ **Lines of code:** 2 lines
112
+
113
+ ---
114
+
115
+ ### IMP-2: Worker heuristic should complete multi-step tasks [Priority: 8]
116
+
117
+ **Bug:** The trained `HeuristicWorker._trained_act()` in `demo.py` checks policy for refund tasks but NEVER actually issues the refund. It just calls `get_current_policy` every time it sees a refund task. Same for untrained worker -- it issues refund but never checks CRM first.
118
+
119
+ **File:** `sentinelops_arena/demo.py` (lines 253-299)
120
+ **Change:** Add state tracking to HeuristicWorker so it can complete multi-step flows:
121
+ 1. First encounter of refund task: call `get_current_policy`
122
+ 2. Second encounter (same task): call `issue_refund` with validated params
123
+
124
+ This will make the trained vs untrained comparison dramatically more interesting in the demo.
125
+
126
+ **Lines of code:** ~25 lines
127
+
128
+ **Details:**
129
+ - Add `self._last_task_id` and `self._policy_checked` state to HeuristicWorker
130
+ - Trained flow: refund task first seen -> get_current_policy, refund task second time -> issue_refund with compliant params
131
+ - This creates visible "adaptive behavior" in the replay -- exactly what judges want to see
132
+
133
+ ---
134
+
135
+ ### IMP-3: Improve explanation quality metric [Priority: 6]
136
+
137
+ **Bug:** `environment.py` line 441: `explanation_quality = min(len(explanation) / 100.0, 1.0)` -- quality is just string length. A 100+ character explanation always gets max quality regardless of content.
138
+
139
+ **File:** `sentinelops_arena/environment.py` (line 441)
140
+ **Change:** Add keyword detection alongside length. Check if explanation mentions relevant terms (policy, schema, drift, social engineering, violation, refund, etc.).
141
+ **Lines of code:** ~8 lines
142
+
143
+ ```python
144
+ keywords = ["policy", "schema", "drift", "violation", "social", "engineering",
145
+ "refund", "unauthorized", "error", "compliance"]
146
+ keyword_matches = sum(1 for k in keywords if k in explanation.lower())
147
+ length_score = min(len(explanation) / 100.0, 0.5)
148
+ keyword_score = min(keyword_matches / 3.0, 0.5)
149
+ explanation_quality = length_score + keyword_score
150
+ ```
151
+
152
+ ---
153
+
154
+ ## QUICK WINS (Small effort, visible improvement)
155
+
156
+ ### QW-1: Fix HF Spaces requirements [Priority: 9]
157
+
158
+ **File:** `requirements.txt`
159
+ **Change:** Ensure `pandas>=2.0` is listed. Verify gradio version consistency.
160
+ **Lines of code:** 1-2 lines
161
+
162
+ ---
163
+
164
+ ### QW-2: Fix version claims in SENTINELOPS_ARENA.md [Priority: 4]
165
+
166
+ **Bug:** Spec says "80 ticks" and "OpenEnv 0.4" but code uses 30 ticks and OpenEnv 0.2.x.
167
+ **Action:** SKIP -- spec docs are aspirational. Judges who read code will see it works. Not worth the time.
168
+
169
+ ---
170
+
171
+ ### QW-3: Clean up hackathon_env/ vestigial directory [Priority: 3]
172
+
173
+ **File:** `.gitignore` or delete `hackathon_env/`
174
+ **Action:** SKIP unless doing final cleanup -- judges won't look here.
175
+
176
+ ---
177
+
178
+ ## SKIP LIST (Not worth the time)
179
+
180
+ | Item | Why Skip |
181
+ |------|----------|
182
+ | Compound attacks | 2+ hours, spec feature not in code |
183
+ | Compliance drift | New attack type, 1+ hour to implement and test |
184
+ | A2A protocol | Already marked "Cut" in spec, correct decision |
185
+ | Docker support | HF Spaces uses Gradio SDK |
186
+ | SLA breach detection | Needs rework of ticketing + reward pipeline |
187
+ | MCP-X gateway | MCP tools work inline, gateway is polish |
188
+ | Full GRPO convergence | Training pipeline exists, convergence not needed |
189
+
190
+ ---
191
+
192
+ ## IMPLEMENTATION ORDER
193
+
194
+ Execute in this exact order to maximize impact per minute:
195
+
196
+ | # | Item | Est. Time | Impact |
197
+ |---|------|-----------|--------|
198
+ | 1 | **IMP-1**: Theme in gr.Blocks constructor | 2 min | HF Spaces theme works |
199
+ | 2 | **QW-1**: Fix requirements.txt | 2 min | HF Spaces doesn't crash |
200
+ | 3 | **FIX-1**: window_ticks enforcement in billing | 10 min | Policy drift attacks work (Patronus AI track) |
201
+ | 4 | **FIX-3**: Fix schema drift renames | 5 min | Schema drift attacks work (Patronus AI track) |
202
+ | 5 | **FIX-2**: Rate limiting for CRM + Ticketing | 15 min | All attacks work on all systems |
203
+ | 6 | **FIX-4**: tasks_completed tracking | 3 min | Dashboard shows correct count |
204
+ | 7 | **IMP-2**: Worker multi-step task completion | 15 min | Demo shows real adaptive behavior |
205
+ | 8 | **IMP-3**: Better explanation quality metric | 5 min | Oversight agent more realistic |
206
+
207
+ **Total estimated time: ~57 minutes**
208
+
209
+ ---
210
+
211
+ ## JUDGE-SPECIFIC IMPACT ANALYSIS
212
+
213
+ ### Patronus AI (Darshan Deshpande) -- Schema Drift Track ($10K)
214
+ - **FIX-1** makes policy drift mechanically functional (window_ticks enforced)
215
+ - **FIX-3** makes schema drift renames target real fields (attacks actually break things)
216
+ - **IMP-2** shows worker adapting to drift in multi-step tasks
217
+ - Combined: these 3 fixes transform "drift is mentioned" into "drift demonstrably works"
218
+
219
+ ### Fleet AI (Nicolai Ouporov) -- Scalable Oversight Track ($10K)
220
+ - **IMP-3** gives oversight meaningful explanation quality scoring (not just string length)
221
+ - **IMP-2** creates real violations for oversight to catch (multi-step tasks that can fail)
222
+ - **FIX-4** shows accurate task completion stats in dashboard
223
+
224
+ ### Daniel Han (Unsloth) -- Training Pipeline
225
+ - The training pipeline in `train.py` is already solid
226
+ - Fixes to the environment make the reward signals more meaningful
227
+ - GRPO reward functions already correctly shaped
228
+
229
+ ### Sanyam Bhutani (Meta) -- OpenEnv Quality
230
+ - **FIX-1 + FIX-2** demonstrate environment integrity (attacks have real effects)
231
+ - Clean MCP tool exposure with 19 tools already impressive
232
+ - Environment reset/step/state cycle works correctly
233
+
234
+ ### Benjamin Burtenshaw (HuggingFace) -- Hub Deployment
235
+ - **IMP-1** + **QW-1** ensure HF Spaces deployment works correctly with theme
236
+ - Gradio 6 native plots and custom theme are impressive
237
+
238
+ ---
239
+
240
+ ## WHAT NOT TO TOUCH
241
+
242
+ 1. **rewards.py** -- Reward functions are clean and match spec tables. Do not modify.
243
+ 2. **models.py** -- Pydantic models are correct. Do not add fields unless required by a fix.
244
+ 3. **task_generator.py** -- Works fine, generates correct task mix.
245
+ 4. **sentinel_theme.py** -- Theme is polished. Do not tweak CSS.
246
+ 5. **replay_html.py** -- HTML rendering works. Do not modify.
247
+ 6. **chart_helpers.py** -- Chart data builders work. Do not modify.
248
+ 7. **metrics.py** -- Security metrics computation is solid.
249
+ 8. **train.py** -- Only touch to fix schema_drift renames in the heuristic attacker configs.