fix(cli): assign new wheels.Injector to application.wheelsdi in scaffolded Application.cfc#2623
Conversation
… in scaffolded Application.cfc The CLI's scaffolded Application.cfc declared a local `injector` variable in onApplicationStart() and onError() but then referenced application.wheelsdi without an explicit assignment. The runtime only worked because Injector.init() self-registers at application.wheelsdi — reading the template suggested otherwise and matched the bug report in issue #2622 ("application.wheelsdi is never assigned"). Replace the orphan local in all four templates (the canonical CLI template and the in-repo public/, examples/tweet/, examples/starter-app/ copies) so every reference goes through application.wheelsdi. Pin the contract with a new spec at vendor/wheels/tests/specs/cli/ ApplicationCfcInjectorAssignmentSpec.cfc so freshly scaffolded apps and the in-repo derivatives cannot drift back into the inconsistent form. Signed-off-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Wheels Bot — No doc updatesReviewed this PR's diff and found no docs that need updating (the fix corrects an internal inconsistency in scaffold-generated |
There was a problem hiding this comment.
Wheels Bot — Reviewer A
TL;DR: This is a focused, correct bug fix. Four Application.cfc files had a local injector variable in onApplicationStart() and onError() that was never assigned to application.wheelsdi — the runtime only worked because Injector.init() self-registers as a side effect. The fix makes every reference explicit via application.wheelsdi. The regression spec is well-formed and follows the established buildArtifactLicenseSpec.cfc pattern. No blockers found; recommending approval by a human maintainer.
Correctness
The four Application.cfc files (cli/lucli/templates/app/public/, public/, examples/tweet/public/, examples/starter-app/public/) are updated consistently. Every occurrence of the orphan local injector variable has been replaced with application.wheelsdi.
One observation worth having on record: the onError() handler now explicitly overwrites application.wheelsdi with a fresh injector. In the old code this was already happening as an Injector.init() side effect (the PR description notes: "The runtime only worked because Injector.init() self-registers at application.wheelsdi"), so the observable behavior is unchanged — the new code is just honest about it. No regression here; flagging for reader awareness only.
Tests
vendor/wheels/tests/specs/cli/ApplicationCfcInjectorAssignmentSpec.cfc follows the same var repoRoot = expandPath("/wheels/../..") + IIFE loop-capture pattern used in buildArtifactLicenseSpec.cfc, so the closure/outer-var pattern has established precedent in this suite. The four assertions per file (positive assignment, no orphan local, no orphan getInstance, positive wheelsdi.getInstance) cover the fix thoroughly.
Commits
fix(cli): assign new wheels.Injector directly to application.wheelsdi in scaffolded Application.cfc — valid commitlint type, subject under 100 chars, not ALL-CAPS.
Docs
CHANGELOG [Unreleased] / Fixed entry is present and accurate. Docs/AI-ref deferred to bot-update-docs.yml per checklist — appropriate for a bug fix of this scope.
Wheels Bot — Reviewer B (round 1)A's review is accurate. The fix is correct, the test spec is well-formed, and A's recommendation to defer formal approval to a human is appropriate for a DI-subsystem change. No adjustments needed. SycophancyNone detected. A gave concrete, line-by-line evidence for every claim rather than a blanket "LGTM", and deliberately stopped short of a formal GitHub approval, instead saying "recommending approval by a human maintainer" — the right posture for code that touches False positivesNone detected. I re-read every cited section:
Missed issuesNone significant. One cosmetic note A skipped: the block-comment header in the new spec uses The DCO: Verdict alignmentA's COMMENTED state + "recommend human approval" is consistent with the findings and with the standing rule that DI-subsystem changes require a human sign-off. Correct verdict. ConvergenceAligned. The fix is correct, the regression spec is solid, and the appropriate guard (human approval before merge) is already in place. No changes are required from the author. |
Summary
The CLI's scaffolded
Application.cfcdeclared a localinjectorvariable inonApplicationStart()andonError()but then referencedapplication.wheelsdiwithout an explicit assignment. The runtime only worked becauseInjector.init()self-registers atapplication.wheelsdi— reading the template suggested otherwise and matched the bug report in #2622.This PR makes the assignment explicit in all four affected files (the canonical CLI template plus the in-repo
public/,examples/tweet/, andexamples/starter-app/derivatives) so every reference now reads throughapplication.wheelsdi, matching the documented 4.0 DI container name. A new framework-test spec (vendor/wheels/tests/specs/cli/ApplicationCfcInjectorAssignmentSpec.cfc) pins the contract so the templates cannot drift back.Related Issue
Closes #2622
Type of Change
Feature Completeness Checklist
git commit -sused; trailer presentvendor/wheels/tests/specs/cli/ApplicationCfcInjectorAssignmentSpec.cfc(failing → passing TDD)bot-update-docs.ymlbot-update-docs.ymlbot-update-docs.yml[Unreleased] / Fixedcurl http://localhost:60007/wheels/core/tests?db=sqlite&format=json&directory=wheels.tests.specs.clireturnstotalPass:5, totalFail:0, totalError:0(4 new tests + the existing ApiControllerSnippet test). Smoke-checkedwheels.tests.specs.dispatchfor regressions — still 3 pass / 0 fail / 0 error.Test Plan
Application.cfcfiles fail the assertion"application.wheelsdi = new wheels.Injector("(4 fails)cli,dispatch)developbefore merge