Skip to content

fix: address claude-review feedback on blocker origins (#487)#531

Merged
frankbria merged 1 commit into
mainfrom
fix/issue-487-review-feedback
Apr 3, 2026
Merged

fix: address claude-review feedback on blocker origins (#487)#531
frankbria merged 1 commit into
mainfrom
fix/issue-487-review-feedback

Conversation

@frankbria

@frankbria frankbria commented Apr 3, 2026

Copy link
Copy Markdown
Owner

Summary

Follow-up to #530 addressing feedback from claude-review that was not read before merging.

Issues fixed:

  • Bug — system guidance text wrong for PRD discovery: Changed from "Agent was inactive for too long..." to "System-initiated pause. Review the context and answer to continue." — covers both stall-timeout and discovery session pause use cases
  • Fragile magic string: Extracted _REASON_STALL_DETECTED = "stall_detected" constant in react_agent.py, replacing all 5 raw string usages
  • Migration test gap: Added test_alter_table_migration_adds_created_by_column which creates a DB with the old schema (no created_by), runs _init_database, and asserts the column is added
  • Weak typing on BlockerResponse.created_by: Changed from str = "human" to BlockerOrigin = BlockerOrigin.HUMAN — free Pydantic validation + OpenAPI enum docs
  • Weak typing on blockers.create() parameter: Changed from str to Union[BlockerOrigin, str]

Test Plan

  • 9 Python tests passing (includes new migration ALTER TABLE test)
  • 20 React tests passing
  • Linting clean

Why this wasn't caught before

The CI claude-review check had completed and posted feedback before I merged, but I merged without reading it. CodeRabbit was still pending. Both should have been reviewed first.

Summary by CodeRabbit

  • New Features

    • Improved blocker origin classification system to consistently distinguish between human-initiated and system-initiated blockers.
  • Bug Fixes

    • Updated guidance text for system-initiated pauses to clarify the reason for the pause ("System-initiated pause. Review the context and answer to continue.").
  • Tests

    • Added database migration validation tests for blocker origin handling.

- Fix system guidance text to be generic ("System-initiated pause...")
  covering both stall-timeout and PRD discovery pause origins
- Extract _REASON_STALL_DETECTED constant to eliminate magic string
  in react_agent.py origin detection
- Add migration coverage test for the ALTER TABLE branch
  (test_alter_table_migration_adds_created_by_column)
- Use BlockerOrigin enum in BlockerResponse (stronger typing + OpenAPI docs)
- Type blockers.create() param as Union[BlockerOrigin, str]
@coderabbitai

coderabbitai Bot commented Apr 3, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f14a407a-9547-4640-b866-f8cf24ce9424

📥 Commits

Reviewing files that changed from the base of the PR and between 787add1 and 43cfe57.

📒 Files selected for processing (6)
  • codeframe/core/blockers.py
  • codeframe/core/react_agent.py
  • codeframe/ui/routers/blockers_v2.py
  • tests/core/test_blocker_origin.py
  • web-ui/__tests__/components/blockers/BlockerCard.test.tsx
  • web-ui/src/components/blockers/BlockerCard.tsx

Walkthrough

The PR refactors blocker origin handling by allowing the create() function to accept BlockerOrigin enum values or strings, standardizing stall-related blocker creation with a shared constant marked as system-originated, and updating UI models and guidance text to reflect these changes consistently across core, API, and frontend layers.

Changes

Cohort / File(s) Summary
Core Blocker Infrastructure
codeframe/core/blockers.py, codeframe/core/react_agent.py
Updated create() function signature to accept Union[BlockerOrigin, str] for created_by. Introduced _REASON_STALL_DETECTED module constant to standardize stall comparisons and set system origin for stall-created blockers.
API Response Models
codeframe/ui/routers/blockers_v2.py
Updated BlockerResponse.created_by field type from str to BlockerOrigin with corresponding default value change.
Backend Tests
tests/core/test_blocker_origin.py
Added migration test to verify created_by column creation and updated docstring for pre-migration blocker fallback behavior.
Frontend UI
web-ui/src/components/blockers/BlockerCard.tsx, web-ui/__tests__/components/blockers/BlockerCard.test.tsx
Updated system-origin guidance text from inactive timeout message to system-pause message with matching test assertion.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Poem

🐰 A rabbit hops through blocker code,
Where origins now take a clearer road!
From strings to enums, stalls now shine,
System pauses marked with design—
Thump thump!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main purpose of the pull request: addressing code review feedback on blocker origins, which aligns with the substantive changes across blockers.py, react_agent.py, blockers_v2.py, tests, and UI components.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/issue-487-review-feedback

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

@claude

claude Bot commented Apr 3, 2026

Copy link
Copy Markdown

Review of PR 531 - Follow-up to 530 blocker origin feedback

This is a clean, focused cleanup that correctly addresses the issues raised in the previous review. Each fix is targeted and well-scoped.

_REASON_STALL_DETECTED constant - exactly the right fix. Eliminates all 5 magic string usages in one shot. The remaining reason strings ('escalated_to_blocker', 'max_iterations_reached') could similarly be extracted in future, but that is out of scope here.

Migration test - test_alter_table_migration_adds_created_by_column is well-structured: creates an old-schema DB, confirms absence of the column, runs _init_database, confirms presence. This is exactly the regression guard this migration needed. The docstring update on the existing test (clarifying it tests the COALESCE fallback, not the ALTER TABLE path) is a nice touch.

Guidance text - The new text covers stall-timeout AND discovery session pauses, which is more accurate than the previous stall-specific wording. Test updated in sync.

One thing worth verifying: Union[BlockerOrigin, str] to SQLite serialization. The default is now BlockerOrigin.HUMAN (an enum), but callers in react_agent.py still pass plain strings ('system', 'agent'). The INSERT in blockers.create() needs to call .value on the enum (or use a StrEnum) to store 'human' rather than the enum repr. Since the tests pass this is presumably handled correctly, but worth a quick check of the INSERT to confirm there is no silent mismatch between stored value and what BlockerOrigin expects when reading back.

BlockerResponse.created_by: BlockerOrigin - strict enum typing on the response model is correct and the OpenAPI docs benefit is real. Consistent with the core model approach from 530.

Summary: All five issues from the original review are cleanly resolved. No scope creep, tests cover the new migration path, and the constant extraction is the right level of refactor. Ready to merge once the SQLite serialization path is confirmed.

@frankbria frankbria merged commit 7d5caab into main Apr 3, 2026
10 checks passed
frankbria pushed a commit that referenced this pull request Apr 4, 2026
The frontend-tests CI job was disabled during the Phase 2 CLI-first
refactor and never re-enabled when Phase 3 web UI became active. This
allowed component changes to silently break tests across multiple PRs.

CI change:
- Uncomment frontend-tests job in test.yml (runs npm run test:coverage)
- Add frontend-tests to test-summary needs and failure check
- Exclude e2e/ (Playwright) and test-helpers.ts from Jest via jest.config.js

Test fixes (component updated but test not):
- QuickActions: rewrite tests to exercise all 5 pipeline states
  (broke in #493 — context-aware refactor changed button labels)
- TaskCard: update dependency title to regex match Radix Tooltip text
  (broke in #524 — tooltip replaced title attribute)
- TaskDetailModal: update dep count assertion to "Dependencies (N)"
  (broke in #524 — label changed from "2 dependencies")
- BlockerCard: update success text to "answer recorded"
  (broke in #531 — success message reworded)
- TaskBoardView: update empty state to "No tasks yet" (single block)
  (broke in #499 — empty state redesigned with CTA)
frankbria added a commit that referenced this pull request Apr 4, 2026
* feat(core): WorktreeRegistry, orphan cleanup, and get_base_branch (#533)

Add atomic worktree registration and stale cleanup to complete the
worktree-per-task isolation feature for parallel batch execution.

Changes:
- codeframe/core/worktrees.py: add WorktreeRegistry (register/unregister/
  list_stale/cleanup_stale), get_base_branch(), list_worktrees()
- codeframe/core/sandbox/context.py: use get_base_branch() instead of
  hardcoded "main" when creating worktrees
- codeframe/core/conductor.py: call WorktreeRegistry.cleanup_stale() at
  _execute_parallel() start when isolation == worktree
- codeframe/cli/env_commands.py: report stale worktrees in cf env doctor
- tests/core/test_worktrees.py: 13 new tests for registry, get_base_branch,
  list_worktrees, and conductor orphan cleanup integration

Closes #533

* fix(web-ui): re-enable frontend CI and fix 5 stale tests

The frontend-tests CI job was disabled during the Phase 2 CLI-first
refactor and never re-enabled when Phase 3 web UI became active. This
allowed component changes to silently break tests across multiple PRs.

CI change:
- Uncomment frontend-tests job in test.yml (runs npm run test:coverage)
- Add frontend-tests to test-summary needs and failure check
- Exclude e2e/ (Playwright) and test-helpers.ts from Jest via jest.config.js

Test fixes (component updated but test not):
- QuickActions: rewrite tests to exercise all 5 pipeline states
  (broke in #493 — context-aware refactor changed button labels)
- TaskCard: update dependency title to regex match Radix Tooltip text
  (broke in #524 — tooltip replaced title attribute)
- TaskDetailModal: update dep count assertion to "Dependencies (N)"
  (broke in #524 — label changed from "2 dependencies")
- BlockerCard: update success text to "answer recorded"
  (broke in #531 — success message reworded)
- TaskBoardView: update empty state to "No tasks yet" (single block)
  (broke in #499 — empty state redesigned with CTA)

* fix(core): address code review feedback on WorktreeRegistry (#537)

- wire register()/unregister() into create_execution_context() — registry
  was defined but never populated, making cleanup_stale() a no-op
- fix list_stale() to catch PermissionError separately (process alive,
  different owner is not stale); previously OSError caught both cases
- guard list_worktrees() against non-list JSON (returns [] for dicts etc.)
- fix get_base_branch() to return "main" in detached HEAD state
  (git returns literal "HEAD" — now treated as fallback)
- fix conductor.py string comparison to use IsolationLevel.WORKTREE.value
- replace misleading conductor test with two focused tests that patch
  WorktreeRegistry.cleanup_stale directly and assert call/no-call
- add tests for detached HEAD fallback and non-list JSON guard

---------

Co-authored-by: Test User <test@example.com>
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