Skip to content

refactor(sim): verhaltensneutrales OASIS-Runner-Refactoring (Single-Platform) - #962

Merged
arn0ld87 merged 7 commits into
mainfrom
refactor/oasis-runner-family
Jul 29, 2026
Merged

refactor(sim): verhaltensneutrales OASIS-Runner-Refactoring (Single-Platform)#962
arn0ld87 merged 7 commits into
mainfrom
refactor/oasis-runner-family

Conversation

@arn0ld87

Copy link
Copy Markdown
Owner

Summary

Verhaltensneutrales Refactoring der OASIS-Single-Platform-Runner-Familie. Keine sichtbaren Verhaltensänderungen, keine neuen öffentlichen Schnittstellen, keine Konfigurationssemantik-Änderung. Neues Paket backend/scripts/sim_runtime/ hält die geteilte Laufzeit; die run_*_simulation.py-Entry-Points bleiben kompatible Einstiegspunkte.

Slices

Slice 1 — IPC-Extraktion (b347270c RED, d0e0e95f GREEN)

  • Neues sim_runtime.ipc mit IPCHandler (Konstruktor-Injektion von db_filename/interview_action_type/manual_action_cls) → Modul bleibt oasis-frei und auf macOS/Py3.14 ohne torch-Crash charakterisierbar.
  • 27 Characterization-Tests in test_sim_runtime_ipc.py.
  • Twitter/Reddit-Runner: lokaler IPC-Block ersetzt durch Import.
  • netto −170 LOC.

Slice 2 — Twitter/Reddit-Runner-Dedup (22fae122, 28f57344, 4254fd48)

  • Neues sim_runtime.platform_runner.py mit SinglePlatformRunner-Basis (oasis-abhängig), parametrisiert über Klassen-Attribute (PLATFORM_NAME/SLUG, PROFILE_FILENAME, DB_FILENAME, PLATFORM_TYPE, AVAILABLE_ACTIONS/NAMES, GRAPH_GENERATOR) + Template-Method _assign_initial_action.
  • Einziger echter Verhaltensunterschied bleibt erhalten: Reddit appended mehrere Initial-Posts pro Agent an eine Liste, Twitter überschreibt (reddit-Override).
  • Entry-Points reduziert auf dünne Subklassen + Modul-Setup (_install_runtime_profile mit apply_camel_context_floor-Aufruf, help-guard, _sim_common-Side-Effects, main).
  • test_run_simulation_default_tokens auf sim_runtime/platform_runner.py umgestellt (neue SSoT für den 16384-Default).
  • netto −914 LOC Duplikation.

Verifikation

Lokal (macOS): ruff clean, 52 passed (help-smoke, default-tokens, default-floor, IPC-characterization, test_simulation_runtime mit test_all_runners_apply_camel_context_floor).

armserver (arm64 Linux, echtes oasis/torch): Branch via git bundle + worktree nach /home/alex/agora-verify synchronisiert. tests/scripts/ 220 passed, 9 skipped (parallel-Runner-Segfault, pre-existing), 1 failed (test_oasis_preflight, pre-existing). Echter oasis-Smoke: --help für beide Runner, Import ohne Segfault, _assign_initial_action-Verhaltensunterschied mit echtem ManualAction verifiziert, Klassen-Attribute + PLATFORM_TYPE korrekt.

Pre-Push-Gate backend: ALL GREEN (contracts, schemas 47, ruff, mypy, sync-status).

Harte Erhaltungsregeln (Spec)

  • „Gib niemals Secrets in Logs aus." — unverändert; _create_model maskiert base_url (base_url[:40]…), keine API-Keys in Prints.
  • „Vererbe keine zusätzlichen Environment-Variablen an OASIS-Subprozesse." — unverändert; keine neuen os.environ-Sets in Subprozess-Pfaden, nur die bestehenden CAMEL-Guards (OPENAI_API_KEY/GOOGLE_API_KEY).

Nicht umgesetzt (bewusst)

P4 (Parallel-Extraktion) übersprungen nach User-Sign-off:

  • create_model darf nicht extrahiert werden — test_oasis_provider_dispatch patcht rps.ModelFactory; der Patch greift nur, solange create_model im run_parallel_simulation-Namespace lebt.
  • ParallelIPCHandler (~440 Zeilen) teilt sich nicht mit single-platform IPCHandler (redis-integriert, andere Methoden) → eine Modul-Verschiebung brächte kein echtes Dedup.
  • parallel-Runner ist weder auf macOS noch armserver verhaltensverifizierbar (Segfault beim oasis/torch-Import) → pure Modul-Verschiebung ohne Verifikation = Risiko ohne Gegenseitigen Nutzen.

Test-Plan

  • bash scripts/pre-push-gate.sh backend → ALL GREEN (lokal ausgeführt).
  • armserver-Verifikation wie oben (nachgeführbar via git bundle + worktree).

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@arn0ld87, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 4 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 36453eaf-7027-4653-bced-2770c77dde5b

📥 Commits

Reviewing files that changed from the base of the PR and between e14c630 and 9bb3e50.

📒 Files selected for processing (9)
  • CHANGELOG.md
  • backend/scripts/run_reddit_simulation.py
  • backend/scripts/run_twitter_simulation.py
  • backend/scripts/sim_runtime/__init__.py
  • backend/scripts/sim_runtime/ipc.py
  • backend/scripts/sim_runtime/platform_runner.py
  • backend/tests/scripts/test_run_simulation_default_tokens.py
  • backend/tests/scripts/test_sim_runtime_ipc.py
  • docs/STATUS.md

Comment @coderabbitai help to get the list of available commands.

@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: 1ad15ccaeb

ℹ️ 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 on lines +57 to +60
*,
db_filename: str,
interview_action_type: Any,
manual_action_cls: Any,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve the re-exported IPCHandler constructor

When existing callers import IPCHandler from either runner and instantiate it using the established IPCHandler(simulation_dir, env, agent_graph[, redis_bridge]) contract, this replacement raises TypeError because three new keyword-only arguments are mandatory. Since both entry points explicitly re-export the class for compatibility, preserve their old platform-specific constructors (for example with thin wrappers supplying the database name and OASIS symbols) rather than exposing the incompatible shared constructor.

Useful? React with 👍 / 👎.

Comment thread docs/STATUS.md Outdated
| Kategorie | Anzahl | Methode |
|---|---|---|
| Backend Tests (collected) | 3854 | `cd backend && uv run pytest --collect-only -q` |
| Backend Tests (collected) | 3880 | `cd backend && uv run pytest --collect-only -q` |

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Add the delivered refactor to CHANGELOG

When this commit is included in a release, the release history will omit the delivered backend runtime refactor because only the generated test count in STATUS.md was synchronized and CHANGELOG.md remains untouched. Record the change in the changelog in the same slice as required by the repository workflow.

AGENTS.md reference: AGENTS.md:L41-L45

Useful? React with 👍 / 👎.

arn0ld87 and others added 7 commits July 29, 2026 03:04
Sichert das Datei-/Redis-IPC-Verhalten des aus den Single-Platform-Runnern
zu extrahierenden IPCHandler-Netzwerks: Response-Format, Command-Dedup
gegen den Redis-Bus, Interview-Dispatch, _execute_command-True/False-Matrix
(Close-Env -> False) und _get_interview_result (db_filename-Pfad).

Oasis-Symbole (ManualAction, ActionType.INTERVIEW) werden als Fakes injiziert,
sodass die Tests ohne die torch-abhangige Oasis-Laufzeit laufen. RED-Commit:
sim_runtime.ipc existiert noch nicht -> Import fehlschlagt, bis der
folgende Refactor-Commit das Modul extrahiert.
Extrahiert den in run_twitter_simulation.py und run_reddit_simulation.py
duplizierten IPC-Block (Konstanten, CommandType, IPCHandler) in das neue
Paket backend/scripts/sim_runtime/ipc.py. Beide Runner importieren nun
die gemeinsame Implementierung; die IPCHandler-Konstruktion injiziert
db_filename, interview_action_type (ActionType.INTERVIEW) und
manual_action_cls (ManualAction) als Keyword-Argumente.

Verhaltensidentisch: Datei-IPC-Layout, Response-Format, Command-Dedup
(seen_command_ids) und die _execute_command-Ruckgabematrix bleiben
unverandert. Oasis-Symbole werden injiziert statt auf Modulebene importiert,
damit sim_runtime.ipc ohne torch-abhangige Oasis-Laufzeit importierbar bleibt
und im Test-Tree charakterisierbar ist.

Erhaltungsanker: _sim_common bleibt eigenstandiges Modul (importlib-Tests);
create_model/ModelFactory bleiben Attribute von run_parallel_simulation
(test_oasis_provider_dispatch); die LLM_MAX_OUTPUT_TOKENS/--num-agents/
--num-rounds-Literale bleiben in den Entry-Points.
Basis-Runner-Klasse (oasis-abhängig) parametrisiert über Klassen-Attribute
(PLATFORM_NAME/SLUG, PROFILE_FILENAME, DB_FILENAME, PLATFORM_TYPE,
AVAILABLE_ACTIONS/NAMES, GRAPH_GENERATOR) und die Template-Method
_assign_initial_action (Twitter überschreibt, Reddit appended an Listen).
Extrahiert verhaltensneutral aus run_twitter_simulation.py /
run_reddit_simulation.py; setup_signal_handlers + _shutdown_event/
_cleanup_done wandern mit in die Basis.

Entry-Points nutzen die Basis noch nicht (folgende Commits); das Modul ist
neu und ändert kein bestehendes Verhalten. Ruff clean, help-smoke +
characterization-Tests grün (45 passed).

Co-Authored-By: Claude <noreply@anthropic.com>
…class

TwitterSimulationRunner erbt __init__, _load_config, _create_model,
_get_active_agents_for_round, run, setup_signal_handlers aus der Basis;
der Entry-Point behält Modul-Setup (_sim_common-Side-Effects,
_install_runtime_profile mit apply_camel_context_floor-Aufruf, help-guard),
den oasis-/IPC-/agent_tools-Import als Modul-Attribut-Quelle und main.

_shutdown_event wird in main() auf dem Basis-Modul gesetzt, weil run dort
das Modul-Global liest. test_run_simulation_default_tokens-SCRIPTS auf
sim_runtime/platform_runner.py umgestellt (neue SSoT für den 16384-Default).

Verhaltensneutral: ruff clean, help-smoke + tokens + floor + IPC +
simulation_runtime (test_all_runners_apply_camel_context_floor) grün
(52 passed).

Co-Authored-By: Claude <noreply@anthropic.com>
…lass

RedditSimulationRunner erbt die Runner-Logik aus der Basis; einziger
Verhaltensunterschied zu Twitter bleibt erhalten als _assign_initial_action-
Override (Reddit appended mehrere Initial-Posts pro Agent an eine Liste
statt zu überschreiben). Entry-Point behält Modul-Setup, oasis-/IPC-/
agent_tools-Import und main.

Verhaltensneutral: ruff clean, help-smoke + tokens + floor + IPC +
simulation_runtime (52 passed). Slice 2 (Twitter/Reddit-Dedup) lokal
komplett — netto ca. −950 LOC Duplikation.

Co-Authored-By: Claude <noreply@anthropic.com>
…ization

+26 collected tests (27 IPCHandler characterization tests in
test_sim_runtime_ipc.py). Pre-Push-Gate sync-status --check war rot.

Co-Authored-By: Claude <noreply@anthropic.com>
…(PR #962)

AGENTS.md L41-L45 verlangt CHANGELOG.md-Update im selben Slice. Codex
PR-Review #962 P1 wies darauf hin, dass nur STATUS.md synchronisiert
wurde. Refactor-Eintrag dokumentiert Slice 1+2 ohne Verhaltensänderung:

- neues Paket backend/scripts/sim_runtime/ (ipc.py, platform_runner.py)
- IPC-Dedup (~280 LOC pro Runner)
- Runner-Dedup (Twitter/Reddit reduziert auf SinglePlatformRunner-Subklassen)
- ~1.084 LOC netto Reduktion
- P4 (Parallel-Extraktion) bewusst uebersprungen (create_model
  Patch-Constraint, ParallelIPCHandler kein Dedup)

Co-Authored-By: Claude <noreply@anthropic.com>
@arn0ld87
arn0ld87 force-pushed the refactor/oasis-runner-family branch from 1ad15cc to 9bb3e50 Compare July 29, 2026 01:12
@arn0ld87

Copy link
Copy Markdown
Owner Author

Replying to Codex P1 (CHANGELOG) and P2 (IPCHandler constructor) — please see the inline replies below.

P1 CHANGELOG: Done — added ### Changed entry unter [Unreleased] mit Slice 1+2-Inhalt, Hard Rules, P4-Skip-Begründung und Verifikations-Liste (PR #962, Commit 9bb3e50). Pre-Push-Gate schemas ALL GREEN inkl. sync-status --check (manual-Wert 3891 für die Summe aus #906 +11 und sim_runtime_ipc +26 Tests). Branch ist rebased auf e14c6304 (Conflict in docs/STATUS.md aufgelöst).

P2 IPCHandler constructor: Audit ergab — kein externer Caller verwendet die alte positionsbasierte Signatur IPCHandler(simulation_dir, env, agent_graph). Die einzigen Konstruktoraufrufe in backend/ sind platform_runner.py:411 (Basis, mit neuen kwargs) und test_sim_runtime_ipc.py:97 (Characterization-Test, mit neuen kwargs). Die früher einzigen externen Konsumenten (Twitter/Reddit-Entry-Points) wurden in Slice 2 selbst auf die neuen kwargs umgestellt. Re-Export der Symbole (IPCHandler, CommandType, Pfade) bleibt für Import-Kompatibilität erhalten — aber die alte positionsbasierte Signatur hatte keine Konsumenten mehr. Konstruktor bleibt strikt: db_filename/interview_action_type/manual_action_cls sind pro Aufruf korrekt zu setzen und nicht aus dem Aufruferkontext erratbar (Konstruktor-Injektion ist gerade der Trick, der ipc.py oasis/torch-frei hält und damit auf Py3.14/aarch64 ohne Segfault testbar macht).

@arn0ld87
arn0ld87 merged commit 187f3ef into main Jul 29, 2026
28 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.

1 participant