Skip to content

Deduplicate worker cap logic: make get_worker_cap() delegate to WorkerCapLogic - #256

Closed
itsmiso-ai wants to merge 1 commit into
mainfrom
foreman/wl-misospace-windowstead-244/issue-244
Closed

Deduplicate worker cap logic: make get_worker_cap() delegate to WorkerCapLogic#256
itsmiso-ai wants to merge 1 commit into
mainfrom
foreman/wl-misospace-windowstead-244/issue-244

Conversation

@itsmiso-ai

Copy link
Copy Markdown
Contributor

main.gd:get_worker_cap() now delegates to WorkerCapLogic.calculate_worker_cap(), deduplicating worker cap logic as requested in issue #244.

Fixes #244

Opened by foreman on review GO (workload wl-misospace-windowstead-244).

…rCapLogic

The get_worker_cap() function in main.gd duplicated the same calculation
already present in worker_cap_logic.gd. Replace the inline implementation
with a call to WorkerCapLogic.calculate_worker_cap(builds) and add the
corresponding preload constant.

Fixes #244

Signed-off-by: Saffron <263493777+itsmiso-ai@users.noreply.github.com>
@itsmiso-ai
itsmiso-ai requested a review from joryirving as a code owner July 8, 2026 02:31

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

AI Automated Review

Full PR review.

Analysis engine: MiniMax-M2.7@https://litellm.jory.dev/v1 (anthropic) — escalated (fast_low_confidence)

Review: PR PR 256 — Deduplicate worker cap logic

Summary

This PR completes issue PR 244 by making get_worker_cap() in main.gd delegate to WorkerCapLogic.calculate_worker_cap(), eliminating duplicated worker cap calculation logic.

Change-by-Change Analysis

scripts/main.gd — Lines 19, 1061-1062

Before After
Inline 6-line loop over builds to sum WORKER_CAP_BONUSES Single-line delegation: return WorkerCapLogic.calculate_worker_cap(state.get("builds", []))
  • Added WorkerCapLogic constant at the top of the file (line 19)
  • Replaced 6-line implementation with 1-line delegation
  • Parameter passed to delegate (state.get("builds", [])) matches the original inline logic exactly

Tests Verification

The existing test suite (tests/test_worker_cap.gd) exercises main.get_worker_cap() directly and was not modified. All 6 test cases continue to validate:

  • Base cap (2) with no builds
  • +2 bonus for one completed hut (total 4)
  • +4 bonus for two completed huts (total 6)
  • Workshop adds no bonus
  • Mixed structures (hut + workshop)
  • Incomplete builds excluded

Standards Compliance

Check Status
Follows extraction pattern used for goal_progression.gd, layout_math.gd, worker_cap_logic.gd ✅ Pass
Keeps main.gd readable per CONTRIBUTING.md ✅ Pass (reduced by 4 net lines)
WorkerCapLogic module is already documented in DESIGN.md as extracted logic ✅ Pass
No API changes — all callers of get_worker_cap() work unchanged ✅ Pass

Linked Issue Fit

Issue PR 244: "Deduplicate worker cap logic: make main.gd:get_worker_cap() delegate to worker_cap_logic.gd"

  • ✅ Explicitly adds WorkerCapLogic import
  • get_worker_cap() now delegates to WorkerCapLogic.calculate_worker_cap()
  • ✅ Deduplication achieved with identical behavior

CI Status

All validation gates passed on commit 61059c68:

  • Headless smoke test: ✅
  • Script test suite: ✅
  • macOS validation: ✅
  • Export validation (Linux): ✅

Unknowns / Needs Verification

None. The implementation is complete, tests pass, CI is green, and the change matches the issue requirements exactly.

Recommendation

Approve. The PR cleanly fulfills the issue PR 244 acceptance criteria with a minimal, well-scoped change that reduces code duplication while preserving all existing behavior and tests.

@joryirving joryirving closed this Jul 9, 2026
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.

Deduplicate worker cap logic: make main.gd:getworkercap() delegate to workercaplogic.gd

2 participants