Skip to content

Conversation

@david-zlai
Copy link
Contributor

@david-zlai david-zlai commented Sep 26, 2025

Summary

^^^

Do not want users to accidentally backfill from the main branch as that will do a branch "sync" and can disrupt any other schedules or deploys on main to be disrupted.

We will though need to allow for "CI" to be able to run off of main though.

Checklist

  • Added Unit Tests
  • Covered by existing CI
  • Integration tested
  • Documentation update

Summary by CodeRabbit

  • Bug Fixes
    • Blocks backfilling when on the main branch, stopping the workflow early and surfacing a clear error message. This prevents unintended backfills on protected branches and reduces wasted compute.
    • Improves user feedback by validating branch/mode combinations earlier in the run; no other behavior changes. No impact to public APIs. Defaults and performance unaffected.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 26, 2025

Walkthrough

Adds a guard in submit_workflow to raise ValueError when attempting BACKFILL on the main branch, placed after repo hash/branch resolution and before compute_and_upload_diffs. No other logic changes.

Changes

Cohort / File(s) Summary
Hub runner backfill guard
python/src/ai/chronon/repo/hub_runner.py
Inserted branch+mode check: if branch == "main" and mode == BACKFILL, raise ValueError; executed before compute_and_upload_diffs. No API/signature changes.

Sequence Diagram(s)

sequenceDiagram
  participant U as Caller
  participant HR as HubRunner.submit_workflow
  participant G as Git/Repo
  participant D as compute_and_upload_diffs

  U->>HR: submit_workflow(mode)
  HR->>G: compute local repo hash map
  HR->>G: get current branch
  alt branch == "main" and mode == BACKFILL
    HR-->>U: raise ValueError (short-circuit)
  else
    HR->>D: compute_and_upload_diffs(...)
    D-->>HR: result
    HR-->>U: continue workflow
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

A cautious gate before the hill,
“Main can’t backfill,” it states with will.
Early stop, a tidy fail,
No diffs set out upon the trail.
Guard in place, the flow stands still—
Safer paths, less room to spill.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title clearly states the primary change of disabling backfills from the main branch and directly reflects the guard logic added to prevent this action. It is concise and free of extraneous details, making the main intent immediately obvious to reviewers.
Description Check ✅ Passed The PR description follows the repository template by including both Summary and Checklist sections and articulates the rationale for preventing backfills on main. All required headings are present and the motivation is clear, though the checklist items remain unchecked to indicate that tests and documentation updates are still pending.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch david/ZIP-1056

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 96342ab and a00fcbd.

📒 Files selected for processing (1)
  • python/src/ai/chronon/repo/hub_runner.py (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
python/src/ai/chronon/repo/hub_runner.py (1)
python/src/ai/chronon/repo/constants.py (1)
  • RunMode (4-31)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: enforce_triggered_workflows

Comment on lines +67 to +69
if branch == "main" and mode == RunMode.BACKFILL.value:
raise ValueError("Backfilling from the main branch is not allowed. Please switch to a feature branch.")

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Guard blocks CI backfills.

CI runs the same CLI on branch main with RunMode.BACKFILL; this unconditional raise breaks that flow despite the stated exception. Please gate the guard (e.g., skip when os.environ.get("CI") == "true" or similar) so CI remains functional.

🤖 Prompt for AI Agents
In python/src/ai/chronon/repo/hub_runner.py around lines 67 to 69, the
unconditional ValueError blocking backfills from branch "main" breaks CI which
runs backfill on main; change the guard to skip raising when running in CI by
checking an environment flag (e.g., os.environ.get("CI") in ("true","1") or
lower-cased) so CI remains functional, and add an import for os at the top if
it’s not already imported.

conf_name_to_hash_dict = hub_uploader.build_local_repo_hashmap(root_dir=repo)
branch = get_current_branch()

if branch == "main" and mode == RunMode.BACKFILL.value:
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe also block deploys unless there's a flag or such indicating we're in 'ci'?

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.

3 participants