Skip to content

fix(eval): add environment/ fallback to get_dockerfile_hash - #264

Open
baobaolaodie wants to merge 2 commits into
rpamis:masterfrom
baobaolaodie:fix/eval-dockerfile-hash-fallback
Open

fix(eval): add environment/ fallback to get_dockerfile_hash#264
baobaolaodie wants to merge 2 commits into
rpamis:masterfrom
baobaolaodie:fix/eval-dockerfile-hash-fallback

Conversation

@baobaolaodie

@baobaolaodie baobaolaodie commented Aug 1, 2026

Copy link
Copy Markdown

✨ Summary

get_dockerfile_hash() in eval/scaffold/shell/docker.sh only checked for dir/Dockerfile, even though docker_build() already falls back to dir/environment/Dockerfile (the eval layout where task environments live under environment/). Because get_image_name() calls get_dockerfile_hash() before the build, that fallback was dead code: passing a workspace that only carries environment/Dockerfile (e.g. comet-any direct calls or validator scenarios) made image lookup fail before any Docker command ran.

This PR applies the same fallback to get_dockerfile_hash(), keeping the two functions consistent, and bumps the version to 0.4.0-beta.15.

🎯 Scope

  • CLI commands (init, status, doctor, update)
  • Core installer / platform detection
  • Comet skills (assets/skills/, assets/skills-zh/)
  • Comet shell scripts (assets/skills/comet/scripts/)
  • Tests / CI
  • Documentation / changelog
  • Other: Eval scaffold shell script (eval/scaffold/shell/docker.sh), release metadata

🧪 Testing

  • pnpm install --frozen-lockfile
  • pnpm build
  • pnpm lint (ESLint + architecture linter)
  • pnpm format:check — every file changed by this PR passes; the repo-wide check only flags the known domains/dashboard/web/ Windows CRLF boundary files, which are byte-identical to origin/master (flagged identically on master, passes on CI's Linux checkout)
  • pnpm test (full) — result identical to master: 8 files / 39 tests fail on Windows (pre-existing openspec/path-integration environment failures), 2991 pass; this PR introduces zero regressions
  • uv run pytest -q local/tests/scaffold local/tests/tasks/test_validation_scripts.py — 341 passed (one more than master, the new regression test); the same 5 pre-existing failures as master
  • uv run pytest local/tests/scaffold/test_utils.py::test_get_image_name_falls_back_to_environment_dockerfile (new regression test; red before the fix, green after)
  • uv run pytest local/tests/scaffold/test_utils.py::test_get_image_name_prefers_root_dockerfile_over_environment (complementary priority test, added after review)
  • uv run --extra dev ruff check local/tests/scaffold/test_utils.py

✅ Checklist

  • PR title follows Conventional Commits
  • User-facing behavior is documented in CHANGELOG.md
  • CHANGELOG.md is updated when behavior changes
  • Skill changes were made in Chinese first when applicable, then synced to English
  • New scripts are included in assets/manifest.json and relevant tests
  • Shell scripts remain portable across macOS, Linux, and Windows Git Bash
  • No unrelated generated files or local artifacts are included

👀 Notes for Reviewers

The fix mirrors the existing fallback in docker_build() (lines 222-226). This PR also bumps the version to 0.4.0-beta.15 per the one-version-ahead rule (master is 0.4.0-beta.14), syncing package-lock.json, assets/manifest.json, and the version assertions in test/repository/release-metadata.test.ts and test/app/cli-help.test.ts. The branch was rebased onto the latest master after the 0.4.0-beta.13/0.4.0-beta.14 releases, resolving the version-field conflicts.

The READMEs are intentionally unchanged: this is an internal eval-scaffold fix whose user-visible effect is recorded in the changelog, and the repo keeps README updates restrained. Known boundary: get_dockerfile_hash() applies the environment/ fallback to Dockerfile only, not to requirements.txt; no current eval task keeps requirements.txt under environment/, so this does not affect existing workloads.

Summary by CodeRabbit

  • Bug Fixes

    • Improved Dockerfile detection during evaluation workflows by checking the environment-specific Dockerfile when no root-level Dockerfile is available.
    • Ensured Docker image identification remains consistent with the build process.
  • Tests

    • Added coverage for Dockerfile selection across supported workspace layouts.
  • Release

    • Updated the application and release metadata to version 0.4.0-beta.15.
    • Updated the changelog with the latest release information.

@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The evaluation Dockerfile hash lookup now falls back to environment/Dockerfile. Tests cover fallback and root Dockerfile precedence. Release metadata and version expectations now use 0.4.0-beta.15.

Changes

Evaluation Dockerfile fallback

Layer / File(s) Summary
Dockerfile hash lookup and validation
eval/scaffold/shell/docker.sh, eval/local/tests/scaffold/test_utils.py
get_dockerfile_hash checks environment/Dockerfile when the root-level Dockerfile is absent. Tests validate image-name resolution, Bash handling, and root Dockerfile precedence.
Beta.15 release metadata
package.json, assets/manifest.json, CHANGELOG.md, test/app/cli-help.test.ts, test/repository/release-metadata.test.ts
Release files and version assertions now use 0.4.0-beta.15.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding an environment/ fallback to get_dockerfile_hash.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@sourcery-ai

sourcery-ai Bot commented Aug 1, 2026

Copy link
Copy Markdown

Reviewer's Guide

Aligns Docker image hash calculation with existing build-time Dockerfile fallback while adding a regression test and bumping release metadata to version 0.4.0-beta.13.

Sequence diagram for Dockerfile hash fallback in eval scaffold

sequenceDiagram
    actor EvalRunner
    participant get_image_name
    participant get_dockerfile_hash
    participant docker_build

    EvalRunner->>get_image_name: get_image_name(dir)
    get_image_name->>get_dockerfile_hash: get_dockerfile_hash(dir)

    alt root Dockerfile exists
        get_dockerfile_hash->>get_image_name: hash(Dockerfile)
    else root Dockerfile missing
        get_dockerfile_hash->>get_dockerfile_hash: [check dir/environment/Dockerfile]
        alt environment Dockerfile exists
            get_dockerfile_hash->>get_image_name: hash(environment/Dockerfile)
        else environment Dockerfile missing
            get_dockerfile_hash->>get_image_name: "" (error)
        end
    end

    get_image_name->>docker_build: docker_build(dir)
    docker_build->>docker_build: [uses same Dockerfile fallback]
Loading

File-Level Changes

Change Details Files
Ensure Dockerfile hash computation falls back to environment/Dockerfile when the root Dockerfile is missing.
  • Update get_dockerfile_hash to check dir/Dockerfile first, then dir/environment/Dockerfile as a fallback.
  • Preserve behavior of returning an empty string and non‑zero status if neither Dockerfile exists.
eval/scaffold/shell/docker.sh
Add a regression test verifying get_image_name respects the environment/ Dockerfile fallback, and support skipping when bash is unavailable.
  • Introduce test_get_image_name_falls_back_to_environment_dockerfile to exercise get_image_name against an environment/Dockerfile-only workspace.
  • Import pytest and use pytest.skip when bash is not present on the system.
eval/local/tests/scaffold/test_utils.py
Document the fix and bump project version to 0.4.0-beta.13 across metadata and tests.
  • Add a 0.4.0-beta.13 "Fixed" entry describing the Dockerfile hash fallback behavior to the changelog.
  • Update version fields in package.json, package-lock.json, and assets/manifest.json to 0.4.0-beta.13.
  • Adjust CLI help and release metadata tests to assert the new version string.
CHANGELOG.md
package.json
package-lock.json
assets/manifest.json
test/app/cli-help.test.ts
test/repository/release-metadata.test.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@baobaolaodie
baobaolaodie force-pushed the fix/eval-dockerfile-hash-fallback branch from 68e15e5 to 2e27f1e Compare August 1, 2026 16:40
@baobaolaodie
baobaolaodie marked this pull request as ready for review August 1, 2026 16:45

@sourcery-ai sourcery-ai 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.

Hey - I've found 1 issue, and left some high level feedback:

  • The Dockerfile path resolution logic is now duplicated between get_dockerfile_hash() and docker_build(); consider extracting a small helper to centralize the fallback behavior and keep these functions in sync more easily.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The Dockerfile path resolution logic is now duplicated between `get_dockerfile_hash()` and `docker_build()`; consider extracting a small helper to centralize the fallback behavior and keep these functions in sync more easily.

## Individual Comments

### Comment 1
<location path="eval/local/tests/scaffold/test_utils.py" line_range="221-230" />
<code_context>
+def test_get_image_name_falls_back_to_environment_dockerfile(tmp_path: Path):
</code_context>
<issue_to_address>
**suggestion (testing):** Add a complementary test for the case where both Dockerfile and environment/Dockerfile exist to assert priority

The current test covers the fallback when only `environment/Dockerfile` exists. To fully specify the behavior and protect against regressions, please add a test where both `dir/Dockerfile` and `dir/environment/Dockerfile` exist and assert that `get_image_name()` selects the top-level `Dockerfile`, not the environment fallback.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread eval/local/tests/scaffold/test_utils.py Outdated
@baobaolaodie

Copy link
Copy Markdown
Author

Thanks for the review. On the suggestion to extract a shared Dockerfile-resolution helper: this fix intentionally mirrors the existing fallback in docker_build() (3 lines) rather than refactoring both functions, to keep a minimal bug-fix PR. Extracting a _resolve_dockerfile() helper would also touch docker_build() and broaden the change surface; happy to follow up with that refactor separately if maintainers want it.

@baobaolaodie
baobaolaodie force-pushed the fix/eval-dockerfile-hash-fallback branch from c0a4ee7 to d9de717 Compare August 2, 2026 17:51

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@eval/local/tests/scaffold/test_utils.py`:
- Around line 250-261: Strengthen
test_get_image_name_falls_back_to_environment_dockerfile by creating a second
workspace with the same environment/Dockerfile content and asserting the
complete _get_image_name results are equal. Keep the existing
environment/Dockerfile-only setup so the test verifies that this fallback file
participates in image hash computation rather than merely checking the
image=skillbench: prefix.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: d80874cd-333b-42d3-a21c-c5ce7c64be9f

📥 Commits

Reviewing files that changed from the base of the PR and between c0a4ee7 and d9de717.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (7)
  • CHANGELOG.md
  • assets/manifest.json
  • eval/local/tests/scaffold/test_utils.py
  • eval/scaffold/shell/docker.sh
  • package.json
  • test/app/cli-help.test.ts
  • test/repository/release-metadata.test.ts
🚧 Files skipped from review as they are similar to previous changes (5)
  • eval/scaffold/shell/docker.sh
  • assets/manifest.json
  • CHANGELOG.md
  • test/repository/release-metadata.test.ts
  • package.json

Comment on lines +250 to +261
def test_get_image_name_falls_back_to_environment_dockerfile(tmp_path: Path):
"""get_image_name() resolves environment/Dockerfile when dir/Dockerfile is absent.

docker_build() falls back to environment/Dockerfile, so get_image_name() must
apply the same rule; otherwise the fallback in docker_build() is dead code and
building a workspace that only carries an environment/Dockerfile always fails.
"""
env_dir = tmp_path / "environment"
env_dir.mkdir()
(env_dir / "Dockerfile").write_text("FROM python:3.11-slim\n", encoding="utf-8")

assert "image=skillbench:" in _get_image_name(tmp_path)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

断言必须验证环境 Dockerfile 已参与镜像哈希计算。

Line 261 只验证 image=skillbench: 前缀。未修复的实现如果返回空哈希,例如 image=skillbench:,此测试仍会通过。创建一个具有相同 Dockerfile 内容的根目录工作区,并断言两个完整镜像名相等。

建议修改
     env_dir.mkdir()
     (env_dir / "Dockerfile").write_text("FROM python:3.11-slim\n", encoding="utf-8")
 
-    assert "image=skillbench:" in _get_image_name(tmp_path)
+    root_dir = tmp_path / "root"
+    root_dir.mkdir()
+    (root_dir / "Dockerfile").write_text("FROM python:3.11-slim\n", encoding="utf-8")
+
+    assert _get_image_name(tmp_path) == _get_image_name(root_dir)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@eval/local/tests/scaffold/test_utils.py` around lines 250 - 261, Strengthen
test_get_image_name_falls_back_to_environment_dockerfile by creating a second
workspace with the same environment/Dockerfile content and asserting the
complete _get_image_name results are equal. Keep the existing
environment/Dockerfile-only setup so the test verifies that this fallback file
participates in image hash computation rather than merely checking the
image=skillbench: prefix.

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