Skip to content

refactor(eval): make framework selection single-source - #3066

Merged
Astro-Han merged 2 commits into
apache:mainfrom
1625567290:fix/eval-framework-single-source
Aug 16, 2026
Merged

Astro-Han merged 2 commits into
apache:mainfrom
1625567290:fix/eval-framework-single-source

Conversation

@1625567290

Copy link
Copy Markdown
Contributor

Summary

Harbor or Pier was selected twice: once as the validated run_trial.py argv, and again via MAKA_EVAL_FRAMEWORK for relay_agent.py. Those contracts could disagree.

run_trial.py now validates argv and installs the selection before any framework or relay import. The relay reads that installed value. TypeScript no longer injects or reserves MAKA_EVAL_FRAMEWORK.

Fixes #3036

Verification

  • python3.13 test_eval_framework.py 3/3, test_run_trial_policy.py 4/4, test_relay_contract.py 20/20 (harbor and pier load; env is ignored), test_relay_artifacts.py 1/1, test_relay_lifecycle.py 12 (2 skip GNU setsid)
  • npm --workspace @maka/eval run typecheck — pass
  • lifecycle-boundaries including the new no-MAKA_EVAL_FRAMEWORK lock — pass
  • biome check on the touched TypeScript — clean

Checklist

  • Tests cover the change and fail without it
  • Focused lint/typecheck and the affected suites pass locally
  • Full workspace lint/format/typecheck

Does this PR entail a change in behavior?

  • Yes — framework selection is only the validated run_trial.py argument

Validate the run_trial.py framework argument and install it before
Harbor, Pier, or the relay import. Stop injecting or reserving
MAKA_EVAL_FRAMEWORK from TypeScript so argv is the only authority.

Fixes apache#3036

Generated-by: Grok
@coderabbitai

coderabbitai Bot commented Aug 15, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 71dda024-9a4c-4e9b-8dba-6b010ae28b7e

📥 Commits

Reviewing files that changed from the base of the PR and between 1c6504c and a1c376c.

📒 Files selected for processing (1)
  • packages/eval/src/__tests__/lifecycle-boundaries.test.ts

Included review availability: Your plan includes up to 3 reviews per rolling hour; 0 remain after this review.


📝 Walkthrough

Summary

This PR makes the validated run_trial.py framework argument the single source of truth for Harbor and Pier selection.

  • run_trial.py validates and installs the framework before importing framework or relay modules.
  • relay_agent.py reads the installed selection through eval_framework.selected().
  • TypeScript no longer injects or reserves MAKA_EVAL_FRAMEWORK.
  • Invalid framework values fail before trial or relay execution.

Design

This PR extends the existing run_trial.py input path. It does not create a parallel selection path. The shared eval_framework module stores one installed value for the runner and relay.

The solution is the smallest coherent change. The module adds limited state to bridge argument parsing and later imports. The tests verify this import-order boundary and the selection behavior. The PR does not change frameworks, workflows, pinned versions, result semantics, or artifact semantics.

Tests and validation

The PR adds coverage for:

  • Uninstalled and invalid framework selections.
  • Valid Harbor and Pier installations.
  • Framework installation before imports.
  • Harbor and Pier relay loading.
  • Installed selection taking precedence over the environment.
  • Trial lifecycle behavior.
  • Omission of MAKA_EVAL_FRAMEWORK from launched trial environments.

Reported focused results:

  • lifecycle-boundaries: 16/16
  • test_eval_framework.py: 3/3
  • test_relay_contract.py: 20/20
  • test_run_trial_policy.py: 4/4

TypeScript typechecking and Biome validation also passed. Full workspace linting, formatting, and typechecking were not run. Required-check status remains unverified without direct CI evidence.

Simplification opportunities

No deletion is required without weakening behavior or regression coverage. The lifecycle test replaces the weaker source-text scan with an observable child-environment test. The framework, import-order, invalid-input, and relay tests provide distinct coverage.

Review-relevant risks

The diff changes the trial launch environment by removing MAKA_EVAL_FRAMEWORK injection and changes the relay selection contract to use installed process state. These are user-visible execution and integration behavior changes. Material changes in these areas require independent human review under repository policy.

No security, licensing, release, or governance effect was identified in the current diff.

The person performing the merge must review the final diff. A maintainer makes the final determination.

Walkthrough

The evaluation runner now provides the single framework selection authority. Harbor and Pier relay loading uses the installed selection. The TypeScript harness no longer injects or reserves MAKA_EVAL_FRAMEWORK, and tests cover validation and selection behavior.

Changes

Framework selection flow

Layer / File(s) Summary
Selection contract and trial entry points
packages/eval/harbor/eval_framework.py, packages/eval/harbor/run_trial.py, packages/eval/harbor/test_eval_framework.py, packages/eval/harbor/test_run_trial_policy.py, packages/eval/package.json
The new module validates and stores Harbor or Pier. Trial entry points install the selected framework before execution. Tests cover invalid and pre-installation states.
Relay framework resolution
packages/eval/harbor/relay_agent.py, packages/eval/harbor/test_relay_*.py
Relay loading uses the installed framework to select Harbor or Pier. Relay tests verify explicit selection and environment-variable precedence.
Preparation environment cleanup
packages/eval/src/harness-executor.ts, packages/eval/src/__tests__/lifecycle-boundaries.test.ts
The harness no longer passes, injects, or reserves MAKA_EVAL_FRAMEWORK. A boundary test verifies its absence.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to a1c37

Framework selection now comes only from the validated run_trial.py argument, preventing conflicting configuration between components; no actionable merge-blocking risk remains after normal checks and review.

Suggested reviewers: astro-han, hqhq1025

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Ai Use Disclosure ⚠️ Warning The PR description selects neither AI-use declaration, while both introduced commits contain Generated-by: Grok; the trailer is not disclosed in the PR description. Select substantive generative-tool use, name Grok and its scope, and keep both trailers through squash or amend. See CONTRIBUTING.md, “Human ownership and AI attribution”.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: making evaluation framework selection single-source.
Description check ✅ Passed The description covers the problem, solution, issue link, verification, behavior change, and test status; the AI use section is omitted.
Linked Issues check ✅ Passed The changes satisfy issue #3036 by centralizing selection, removing TypeScript environment handling, validating early, and adding Harbor and Pier coverage.
Out of Scope Changes check ✅ Passed The code and tests remain within the linked issue scope and do not add frameworks, workflows, or changes to result and artifact semantics.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (1)
packages/eval/src/__tests__/lifecycle-boundaries.test.ts (1)

1058-1061: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Test the launch environment instead of source text.

Line 1059 reads an implementation file. Line 1060 fails for an unrelated comment and does not verify the spawned environment. Replace this test with a harness-boundary test that verifies MAKA_EVAL_FRAMEWORK is absent from the launched process environment.

As per path instructions, flag tests that “assert implementation details” or “do not protect observable behavior.”

Source: Path instructions


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 3f07857a-1877-4dcf-a6ed-e71caa1aef4c

📥 Commits

Reviewing files that changed from the base of the PR and between 820a47b and 1c6504c.

📒 Files selected for processing (11)
  • packages/eval/harbor/eval_framework.py
  • packages/eval/harbor/relay_agent.py
  • packages/eval/harbor/run_trial.py
  • packages/eval/harbor/test_eval_framework.py
  • packages/eval/harbor/test_relay_artifacts.py
  • packages/eval/harbor/test_relay_contract.py
  • packages/eval/harbor/test_relay_lifecycle.py
  • packages/eval/harbor/test_run_trial_policy.py
  • packages/eval/package.json
  • packages/eval/src/__tests__/lifecycle-boundaries.test.ts
  • packages/eval/src/harness-executor.ts
💤 Files with no reviewable changes (1)
  • packages/eval/src/harness-executor.ts

Replace the source-text scan with a harness launch that records the
child environment after the parent sets the unused selector.

Generated-by: Grok
@1625567290

Copy link
Copy Markdown
Contributor Author

Replaced the source-text scan in a1c376c.

The new lifecycle test launches a Harbor trial while the parent has MAKA_EVAL_FRAMEWORK=pier, then asserts the child environment recorded framework: null. That is the observable allowlist contract; a comment in harness-executor.ts no longer trips the test.

lifecycle-boundaries 16/16, test_eval_framework.py 3/3, test_relay_contract.py 20/20, test_run_trial_policy.py 4/4.

Generated-by: Grok

@Astro-Han Astro-Han left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed against #3036.

The smaller design I wanted (pass the framework into a relay factory) is blocked by Harbor: the trial loads relay_agent:RelayAgent by import path, and the base class is chosen at import time. A process-scoped install is forced by that, not invented here. Reading sys.argv[1] from the relay would be the same kind of global, with the argv layout as a hidden contract. eval_framework.py is the explicit version of that.

install() runs before any harbor / pier / relay import on both run_trial() and main(). Production code no longer reads or injects MAKA_EVAL_FRAMEWORK. The launch test that replaced the source-text scan is the right check.

Non-blocking: test_install_selects_harbor_and_pier treats re-install in one process as part of the contract; only the test helper load_relay does that. The two function-local from eval_framework import install lines in run_trial.py can move to module scope. test_relay_contract.py sets MAKA_EVAL_FRAMEWORK and does not restore it.

Approve.

AI-assisted review: Grok 4.6 drafted the first pass. A second pass on opencode-go/deepseek-v4-flash:max ran the focused Python suites, mutated relay_agent.py back to env selection to confirm those tests fail, and checked that an unset or invalid framework cannot reach the relay import. I read the issue and diff, grepped the PR branch for MAKA_EVAL_FRAMEWORK, and checked how Harbor loads the relay. Unverified by me: I did not rerun those Python suites myself.

@Astro-Han

Copy link
Copy Markdown
Contributor

Fast path: framework selection already lived on the validated run_trial.py argument; this removes the unused MAKA_EVAL_FRAMEWORK writer/reader so the trial and relay cannot disagree. No new framework, workflow, or result/artifact semantics. Required checks are green. Easy to revert.

I reviewed the final diff and am merging on that basis. Human contributor of record for this review: Astro-Han.

@Astro-Han
Astro-Han merged commit d6bef01 into apache:main Aug 16, 2026
13 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Aug 18, 2026
4 of 6 tasks
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.

refactor(eval): make framework selection single-source

2 participants