Skip to content

fix(game): harden Plant Operator limits and validation - #130

Merged
EvenSol merged 2 commits into
mainfrom
fix/plant-operator-review-findings
Aug 30, 2026
Merged

EvenSol merged 2 commits into
mainfrom
fix/plant-operator-review-findings

Conversation

@EvenSol

@EvenSol EvenSol commented Aug 30, 2026 •

Copy link
Copy Markdown
Owner

Summary

Follow-up to #129, which merged while its automated review was still completing.

  • tighten the challenge to < 4,200 kW total compressor power and < 5,500 kW total cooling duty
  • preserve existing JAVA_TOOL_OPTIONS and reconcile every required NeqSim JVM opening token
  • normalize invalid timeout inputs to the documented ValueError
  • make UNKNOWN and unrecognized native validation states block a game win
  • register all Plant Operator paths plus compile/test steps in the Studio CI workflow
  • restore native NeqSim archive deserialization before the reflection compatibility fallback
  • add regression coverage and update the published game contract

Native difficulty calibration

A NeqSim sweep across interstage pressure and intercooler temperature confirmed a narrower but feasible operating window.

Native case Power Cooling Outcome
Hard-window strategy (110,000 kg/hr, 78/128 bara, 22/45 °C) 4,159.45 kW 5,495.93 kW wins, 902/1000
Previous easy strategy (110,000 kg/hr, 80/130 bara, 35/40 °C) 4,402.75 kW 6,277.37 kW fails power and cooling

Both native cases completed with no failed or unavailable NeqSim constraints.

Native conservation fix

The failing clone/replay benchmark was caused by Studio's reflection-based ZIP/XML loader taking precedence over NeqSim's native archive loader. Reflection deserialization bypassed NeqSim readObject hooks and left transient SystemThermo.phaseArray state uninitialized.

The adapter now:

  1. uses NeqSim's native archive loader first so transient thermodynamic state is rebuilt;
  2. retains the unknown-element-tolerant reflection loader as a compatibility fallback; and
  3. verifies both paths with explicit loader-order regressions.

No conservation threshold or assertion was weakened.

Validation

  • PYTHONPATH=. .venv/bin/python tests/test_process_graph_conservation.py -v — 114 passed
  • PYTHONPATH=. .venv/bin/python tests/test_process_execution.py -v — 18 passed
  • PYTHONPATH=. .venv/bin/python tests/test_plant_operator_game.py -v — 7 passed
  • PYTHONPATH=. .venv/bin/python tests/test_plant_operator_page.py -v — 5 passed
  • targeted clone provenance/conservation reproduction — passed
  • affected-source compilation and git diff --check — passed
  • earlier browser profile, full Studio pilot, HTTP health, and 56-test focused suite — passed

Documentation impact: none — this is an internal deserialization-order correction; the user-facing game contract and limits are unchanged.

Review provenance

Addresses and resolves all Copilot and Codex comments raised during #129/#130 review.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-08-30T13:46:23.346014Z 779cca0 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 779cca0198

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread process_chat/plant_operator_game.py Resolved
@EvenSol
EvenSol force-pushed the fix/plant-operator-review-findings branch from 779cca0 to 7e0e572 Compare August 30, 2026 13:48
@EvenSol EvenSol changed the title fix(game): harden Plant Operator validation fix(game): harden Plant Operator limits and validation Aug 30, 2026
@EvenSol
EvenSol requested a lite review from Copilot August 30, 2026 13:49
@EvenSol
EvenSol force-pushed the fix/plant-operator-review-findings branch from 7e0e572 to 92de037 Compare August 30, 2026 13:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The JAVA_TOOL_OPTIONS guard can skip adding the required NeqSim --add-opens flags when unrelated --add-opens options already exist, which can break the intended JVM hardening behavior.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR hardens the NeqSim Plant Operator game contract by tightening the winning operating window (power/cooling), strengthening native-validation gating, normalizing timeout input handling, and updating both regression tests and published documentation accordingly.

Changes:

  • Tighten win limits to < 4,200 kW total compressor power and < 5,500 kW total cooling duty (plus associated score calibration and UI/docs text).
  • Treat native validation states other than OK/WARN as violations that block a win, and normalize invalid timeout_ms inputs to the documented ValueError.
  • Preserve existing JAVA_TOOL_OPTIONS when adding NeqSim JVM opens; add regression coverage for the above behaviors.
File summaries
File Description
tests/test_plant_operator_page.py Asserts JAVA_TOOL_OPTIONS preservation logic is present in the Streamlit page source.
tests/test_plant_operator_game.py Adds regression tests for strict limits, timeout normalization, and UNKNOWN native status blocking wins.
process_chat/plant_operator_game.py Updates limits, makes native validation stricter, adjusts score calibration, and hardens timeout parsing.
pages/36_NeqSim_Plant_Operator.py Updates JAVA_TOOL_OPTIONS handling and mission-card text to match the stricter contract.
docs/neqsim_plant_operator_game.md Updates the published game contract text to reflect strict limits and native validation requirements.
Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread pages/36_NeqSim_Plant_Operator.py Resolved
@EvenSol
EvenSol force-pushed the fix/plant-operator-review-findings branch from 92de037 to c5a093f Compare August 30, 2026 13:52
@EvenSol
EvenSol requested a lite review from Copilot August 30, 2026 13:52
@EvenSol
EvenSol force-pushed the fix/plant-operator-review-findings branch from c5a093f to 29f7ab5 Compare August 30, 2026 13:54

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new strict “<” limits and timeout validation introduce user-facing edge cases (rounded display can contradict strict thresholds; float timeouts can be silently truncated) that should be corrected before approval.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (1)

process_chat/plant_operator_game.py:375

  • Cooling-duty check is now strict (<), but the displayed actual value is rounded to 0 decimals. This can display "5,500 kW" while still passing (e.g., 5499.6), which conflicts with the "less than 5,500 kW" requirement; show at least one decimal place (or more) for the actual kW value.
            evidence.total_cooling_duty_kw < MAX_COOLING_DUTY_KW,
            f"{evidence.total_cooling_duty_kw:,.0f} kW",
            f"less than {MAX_COOLING_DUTY_KW:,.0f} kW",
  • Files reviewed: 6/6 changed files
  • Comments generated: 2
  • Review effort level: Lite

Comment thread process_chat/plant_operator_game.py Resolved
Comment thread process_chat/plant_operator_game.py Resolved
@EvenSol
EvenSol force-pushed the fix/plant-operator-review-findings branch from 29f7ab5 to e616a8b Compare August 30, 2026 13:59
@EvenSol
EvenSol requested a lite review from Copilot August 30, 2026 13:59

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The tightened contract and validation behavior are consistently implemented across code, UI/docs, tests, and CI with focused regressions covering the key edge cases introduced.

Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@EvenSol
EvenSol merged commit 100f67a into main Aug 30, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants