Loans integration: every open loan PR together, for a local build (do not merge)

Draft
JA
2mo ago
+29447-19815

Summary

Part of #100 and #184. Do not merge. This branch exists so a fresh container can be built with every open loan change at once. Each change is reviewed and merged through its own PR; this one only carries their merge commits, the conflict resolutions between them, and the build-verification commits listed below.

PRIssueWhat it does
#338#329Removing a loan's offset accounts works
#393#325The new-loan form offers offset accounts
#394#392A variable loan's minimum is the schedule's repayment in force, and its caption names the rate that repayment is sized at (option A); the rate-change table reads the schedule
#395#189Pins the 1,668.49 mid-period rate-change figure on the fork engine
#396#184 (phase 1)Admits upstream's loan migration beside the fork's; renames the colliding classes
#397#188, #18430/360 on the fork's engine; new loans default to it, existing ones stay on actual/365
#398#284actual/360, and no silent fall-through for an unknown basis
#399#184A rate-change resize is sized from the interest its period actually charged
#400#142 (phase 2)A rule action that records a loan rate change from a transaction's text
#401#100 (decision 1)The payoff projection pays the schedule's repayment, period by period
#402#184 (phase 2)Loan insurance, down payment, repayment progress and leverage come back (upstream we-promise/sure#3327)
#403#390One loan chart at the top of the account page, with the schedule, projection and extra-repayment lines
#405#184 (phases 3, 4a–4g, 6)The loans run on upstream's engine behind one interest hook, with the fork's features as adapters
#413#406The G1 contract gate checks both behaviours of C11 and C16, each with its own test and mutation
#414#409 (part)G2b offset reconciliation: loans:reconcile_statement for a private statement, plus a synthetic oracle; G2b stays open
#415#408The demo loans carry real terms and pay from their own schedules, and the "Long-term portfolio" demo goal reads on track again (stacked on #405)

#405 is included (this branch was fast-forwarded to its head ebb159e83). It keeps its own swap-only diff by targeting claude/loans-integration-base, which holds this branch's state before it (157a93691) plus the two CI-image commits below. #405 is the largest change in the set and moves figures for some loans; review it on its own.

Added 2026-10-10, evening (head then 455385584). Each merge was re-tested here before the next one:

  • 078c317a7: #413. Conflicts with #405 resolved, as #413's description records:

    • C11 keeps #405's strategy entry and adds #413's contracted-schedule entry.
    • C8 keeps #405's anchor, with its defect quoted.
    • #413's C11 test is adapted to upstream's schedule API.

    loans:verify_contract_mutations[C8,C11,C16] here caught 5 of 5.

  • e423d9f44 and ab69c1874: #414, clean. On #405's engine the C15 and C16 mutations fail the oracle as they do on main.

  • 455eb28a1: #400's added locked-schedule test (Gatekeeper light review).

  • 455385584: #415, clean; demo tests 28 runs, 0 failures.

Added 2026-10-11 (head then bb0a101b8). These merges carry the fixes from the "code master" reviews and the owner's follow-ups:

  • 55abe868f: #405 at 22e65fb03, clean.
    • #405 had merged its refreshed base, claude/loans-integration-base at c13ca9a17. That base carries the reviewed heads of #393, #394, #397, #398, #399, #400, #401 and #403.
    • The base also gained one fix of its own, e4e8a002e. pr-338, which is only on the base, reads params.dig(:account, :accountable_attributes) in LoansController#set_offset_accounts. #393 adds a test that sends account as a string, and on the base that raised TypeError before the form rendered. submitted_accountable_attributes now reads the attributes only when both levels are hashes, and a second test covers a string accountable_attributes.
    • #394's option A was ported onto #405's engine rather than taken as written; #405's description records how, with its fail-first run and five caught mutations.
  • 82a3e30e4: #413 at 4e17e3731 (pipes in a test name are split only when unescaped), clean.
  • f10217ebb: #414 at 943023e03 (statement date-order and sign checks, the realpath guard, malformed-CSV handling, refusing a statement with no interest charge), clean.
  • 8cf45291f: #415 at afe0afd37, clean.
  • bb0a101b8: #415 at a07186cf8, clean. This raises the "Long-term portfolio" demo goal's target to 300,000, at the owner's request (see Decisions).

Added 2026-10-12, morning (head then 6836ad49d). These merges carry the fixes for the nightly reviews' three blockers, at the owner's instruction ("go with your recommendations"):

  • The fixes:
    • #397 (031824d3e) and #398 (661852dda, a6af757e4): the day-count migrations' rollback now refuses while a loan is on 30/360 or actual/360. Before, it moved those loans to actual/365, losing the basis their contracts name.
    • #400 (f21a14a7f): the rate-change parser refuses "Rate change 0.25%"-style wording unless a marker names the new rate. Before, it recorded a 0.25% rate.
  • How they arrived here:
    • claude/loans-integration-base merged the three heads as f4bb52c52;
    • #405 merged that base as 24746641d;
    • #415 merged #405 as f35c392be;
    • this branch merged #405 (f1ef7e951) and #415 (6836ad49d).
  • Every merge was clean.
  • Checks:
    • migration, parser, rule-action and loan tests: 153 runs on the base, and 156 on #405 and on #415, all 0 failures;
    • full bin/rails test at 6836ad49d: 12,671 runs, 1 failure (the known Provider::OpenaiTest string);
    • loans:verify_contract_mutations: 16 rows and 18 mutations, all caught.

Added 2026-10-12, later (head then d838e0336), at the owner's instruction ("Fix the offset slowdown in #405 and soften the caption", "Fix the #403 sibling too"):

  • The fixes:

    • #394 (16a034187): the minimum-payment caption reads "The next repayment your loan's schedule sets, sized at %{rate}. Paying ahead or an offset doesn't change it." It no longer says "your lender's minimum", a figure this app doesn't hold.
    • #405 (51a2d260b) and #403 (5732ec466): Loan::OffsetResolver reads a projection's linked offsets and today's total once, rather than once per period. On a 360-month loan with two offsets, each future period had re-run both queries, 720 calls a page. Each branch has a test that resolves 60 future periods and allows at most 3 queries; it ran 121 before the fix.
  • How they arrived here:

    • the integration base merged #394 (449dd5713) and #403 (f546ab01b);
    • #405 merged the base (185130824, a344aaa25);
    • #415 merged #405 (934b26563, 95ff79e4c);
    • this branch merged #405 (793896625, abe4f17f2) and #415 (5e0729c4c, d838e0336).
  • Merges: #405 had two locale conflicts with the caption, resolved by taking the new caption and keeping #405's removal of recalculating. #405's merge of #403's fix conflicted only in a test comment, and kept #405's. Every merge here was clean.

  • Checks at d838e0336:

    • full bin/rails test: 12,673 runs, 54,003 assertions, 1 failure (the known Provider::OpenaiTest string), 0 errors, 33 skips;
    • loans:verify_contract_mutations: 16 rows and 18 mutations, all caught.
  • Loan page timings. A 360-month loan with two offsets and ten years of daily balances (median of repeated uncached renders, local):

    BuildOverviewSchedule tab
    main0.48 s1.99 s
    this branch before (6836ad49d)1.74 s1.88 s
    this branch now (d838e0336)0.56 s0.78 s

    A 1,200-month loan on the same data is 2.22 s / 2.78 s here, against 1.57 s on main. That cost is the simulation's length, not the offsets (62 and 70 queries, as for 360 months). See Risks.

Added 2026-10-12, evening (head then b87220e12):

  • 0d808a467: #405 with #394's estimate wording;
  • b87220e12: #415 at its refreshed head.

Added 2026-10-13 (head now 16f59b96d). The owner approved these follow-ups on 2026-10-13:

  • The changes:
    • #400 (636f3fa3b, 965f4267e, 2e186c335):
      • Movement wording such as "Rate increase 0.25%" is refused unless a marker names the new rate. Before, it recorded a 0.25% rate.
      • "your rate is X%" is read as the new rate, except after a movement noun or a qualifier naming another rate. The owner decided to keep the second exception.
      • Loan#enrich_reporting_refusal gets direct tests.
    • #402 (e28db9b73): a test that a new principal reprices the memoised insurance premium.
  • How they arrived here:
    • claude/loans-integration-base merged #400 as e345685ac and #402 as 0a889657b. The #400 merge conflicted only in test/models/loan_test.rb's private helpers, and both sides are kept.
    • #405 merged that base as fc3ea844f;
    • #415 merged #405 as 78d6eb228;
    • this branch merged #405 (fc01f720f) and #415 (16f59b96d).
  • Checks:
    • migration, loan, insurance, rule and loans-task tests: 633 runs on the base and 671 on #405, all 0 failures;
    • full bin/rails test: 12,651 runs on #415 (78d6eb228) and 12,687 runs here (16f59b96d), each 0 failures, 0 errors, 33 skips;
    • bin/rubocop on the changed files: no offenses. bin/brakeman: 0 warnings.

Build-verification commits, on this branch only (not part of any loan PR; drop them before anything here goes to main):

  • a9470a6b2, ae9292a17: .github/workflows/docker-verify.yml and .github/docker-verify/verify.rb. On every push to this branch, they build the Dockerfile as written, start the image through its entrypoint, load the demo data, create a loan through the forms and run the loan checks.

  • caefdccbe, 552e50784: the CI image mirrors.

    • caefdccbe takes ci.yml's postgres:16 and redis service images from public.ecr.aws/docker/library/….
    • 552e50784 makes codacy.yml pre-pull codacy/codacy-analysis-cli:4.0.0 from mirror.gcr.io.

    Docker Hub was refusing anonymous pulls from GitHub's runners (toomanyrequests), which killed every test job at "Initialize containers" before a test ran; these are the same official images from a different registry. Both are now on main too, as 513ee49c6 (owner's instruction, 2026-10-10; main's CI green on it). ci.yml and codacy.yml are therefore identical on main, this branch and #405's base, and these two commits no longer need dropping.

Conflict resolutions made here (each also lives in the PR that owns the file where possible):

  • Day-count hint (en, de, ru, tr, uk): actual/360's wording plus #397's correction for 30/360 part periods.
  • db/schema.rb: the loans table carries day_count_convention defaulting to thirty_360, the four-value constraint, and #402's down_payment / insurance columns and constraints.
  • config/locales/views/loans/en.yml: #398's labels plus #402's down payment and insurance labels.
  • test/controllers/loans_controller_test.rb: both sides' tests kept.
  • The golden master was regenerated with #394, #399 and #401 together, and again by #405 (four scenarios move; each figure is explained there).
  • config/loan_contract_tests.yml, config/loan_contract_mutations.yml, docs/loans/calculation-contract.md, test/models/loan/amortization_schedule_test.rb: #413 with #405, as above.
  • 2026-10-11, resolved in #405's merge of its base and recorded there:
    • Loan#minimum_payment_rate and RateChangeTable are ported onto #405's engine;
    • PayoffProjection and its test keep #405's rewrite;
    • the loans locales take #394's caption copy;
    • release-evidence.md keeps ALGORITHM_VERSION 5;
    • contract row C2 takes #397's wording.

Coverage of the open loan issues

Checked against every open issue on the fork (labelled area:loans or about loans by title), 2026-10-10:

IssueCovered by
#409#414 (tooling); the private run needs the owner's statement and offset balances
#408#415
#406#413
#392#394
#390#403
#329#338 (existing PR)
#325#393
#284#398
#189#395, with the behaviour from #399
#188#397
#142#400 (phase 2; phase 1 merged as #213)
#100#401 (decision 1), #394 (decision 9), #403 (one chart, the fork's PR-B); #405 removes the projection's :hold / :reamortize strategies left unused after #392, the last PR-B deletion
#184#396 (phase 1), #402 (phase 2), #397 (phase 4a migration), #399 (the straddle defect), #405 (phases 3, 4a–4g, 6)
#107No fork code; owner to close. Its goal was the loan MVP upstream, repurposing we-promise/sure#3296. Upstream's main (this fork's mirror/upstream-main) carries two commits that replaced it: 117dd80c1 "feat(loans): amortisation engine and variable-rate loans (#3473)", 2026-09-15, and e931fae4f "feat(loans): payoff projection and the loan balance chart (#3474)", 2026-09-27.

Building it

docker build this branch with the repository's Dockerfile, then run it as usual (docker run … ./bin/rails server, or Compose). On start the entrypoint runs bin/rails db:prepare, which creates or migrates the database.

  • Migrations. The loan migrations added here are:
    • 20260908145118 (a no-op on a fork database);
    • 20260916210000 and 20260916210100 (down payment, insurance);
    • 20261009120000 and 20261009120100 (30/360 and the new-loan default);
    • 20261009130000 (actual/360).
  • Rolling back 20261009130000 or 20261009120000 refuses while any loan is on actual/360 or 30/360 respectively. The error names how many; set those loans' basis first.
  • No data backfill is needed. Persisted schedules restage on first view, because ALGORITHM_VERSION is now 5 (#405); bin/rails loans:schedule_version_status reports how many are stale. Production needs the prebuild in docs/loans/release-evidence.md.
  • Day-count defaults. Loans already on the database keep actual/365, and new loans start on 30/360. #397's second commit is separable if you would rather they did not.
  • Demo loans. Since #415, the demo loans carry real terms, so demo_data:default alone shows every loan page:
    • the mortgage has two rate changes, insurance and a down payment;
    • the car loan has insurance;
    • the student loan is ahead of schedule by an extra payment;
    • the "Long-term portfolio" goal reads on track, as its place in the goal matrix intends.

The container, built from the Dockerfile as written and run

Run 38238726266 (docker-verify.yml, job build-and-run), on GitHub's runners, at the head d838e0336, passed on its first attempt. So did 6836ad49d (run 38232284363).

Earlier passes:

  1. Build. The repository's Dockerfile and bin/docker-entrypoint are used unmodified; the job asserts git diff --exit-code on both. All 21 steps run, including both apt-get steps, bundle install, bootsnap precompile and assets:precompile. ruby:3.4.9-slim, postgres:16 and redis:7 come from public.ecr.aws (the same official images), tagged with the names the Dockerfile uses.
  2. Image contents (listed by the job): Ruby 3.4.9; libvips42t64, poppler-utils, postgresql-client-17, libjemalloc2, procps, curl, libyaml-0-2.
  3. Start. docker run … ./bin/rails server goes through the image's own entrypoint, against an empty PostgreSQL 16 and Redis 7. The entrypoint ran db:prepare and Puma started in production; GET /up returned 200 and GET /sessions/new returned 200.
  4. Demo data. bin/rails demo_data:default completed.
  5. As a user, through the forms (bin/rails runner verify.rb ui, a Rails integration session over the full production Rack stack). 17/17 pass:
    • sign in as the demo user; the new-loan form renders;
    • POST /loans creates a variable mortgage (400,000 over 360 months, drawn 30 months ago, actual/365);
    • the edit form renders with all four day-count bases and the down payment and insurance fields;
    • PATCH /loans/:id records two rate changes (one past, one two months out), a 100,000 down payment and a level-term insurance rate;
    • the Schedule tab renders with exactly one loan chart and the rate-change table;
    • the Extra repayments tab, with 250, renders one chart carrying the extra series;
    • the Overview renders insurance, leverage and repayment progress;
    • the rule form offers the rate-change action.
  6. The figures behind that loan (verify.rb model, a second runner process). 14/14 pass:
    • the form-made loan is amortizable and holds both rate changes; new loans default to thirty_360;
    • the minimum payment is the schedule's row in force (2,505.64), and the rate-change table lists the forthcoming change;
    • the default projection pays the schedule's repayment in force;
    • original_balance is the recorded principal, and insurance and leverage compute;
    • thirty_360, actual_360 and actual_365 save through the database constraint;
    • the rule action is registered, and its parser reads "NEW RATE 6.24% P.A." and refuses "Rate decreased 0.25%";
    • 20260908145118 is recorded.

Upgrade path. A database was built from main's own checkout, then migrated with this branch's db:migrate at 157a93691 (host, production mode). The six loan migrations above ran in order, and the dumped loans table equals the committed db/schema.rb, version stamp included. #405 adds no migration, and nor do #413, #414 or #415.

Evidence checklist

  • Each issue in this PR has its own acceptance criteria and no unrelated issue work is included. (Each in its own PR.)
  • Contract rows touched by this change name existing tests.
  • Any gate test has an observed failing mutation transcript attached. (In each PR.)
  • Fixtures used as evidence assert internal consistency.
  • Financial calculations use BigDecimal and documented rounding points.
  • De-identification uses token-shape allowlists; no personal data is included.
  • Files changed, decisions, tests/runtime, risks, and next unblocked issue are documented below.

Validation

  • Local, at d838e0336:

    • full bin/rails test: 12,673 runs, 54,003 assertions, 1 failure (the known Provider::OpenaiTest Ruby 3.3 vs 3.4 string), 0 errors, 33 skips;
    • loans:verify_contract_mutations: 16 contract rows, 18 mutations, every row passing unmutated and failing under each of its mutations.
  • CI at d838e0336: all checks green.

    • ci / test_unit's first attempt died at "Initialize containers" before any test ran: public.ecr.aws refused the postgres:16 pull three times (toomanyrequests: Rate exceeded). Its one re-run passed.
    • Passed on the first attempt: docker-verify / build-and-run, ci / test_system, ci / lint, ci / lint_js, ci / scan_ruby, ci / scan_js, security-scan, Codacy Security Scan, the Codacy linters, Codacy Static Code Analysis, and CodeQL's actions, Ruby, JavaScript/TypeScript, Java/Kotlin and Rust analyses. CodeQL Swift was still running at the time of writing.
  • CI at 6836ad49d: the Pull Request workflow (run 38232289331) and docker-verify passed.

  • Local, at 6836ad49d:

    • full bin/rails test: 12,671 runs, 53,991 assertions, 1 failure (the same Provider::OpenaiTest);
    • loans:verify_contract_mutations: 16 rows and 18 mutations, all caught.
  • CI at bb0a101b8: every check green except the two below.

    • Green: ci / test_unit, ci / test_system, ci / lint, ci / lint_js, ci / scan_ruby, ci / scan_js, security-scan, Codacy Security Scan, the Codacy linters and docker-verify / build-and-run.
    • CodeQL: the actions, Ruby, JavaScript/TypeScript, Java/Kotlin and Rust analyses passed. Swift was still running when this was written; it has passed on every earlier head.
    • Codacy Static Code Analysis: "Up to standards, 0 new issues".

    The one failure is not on the code: github-advanced-security is GitHub's Copilot "code scanning AI findings" job, and it stops before analysing anything with 402 You have exceeded your monthly quota (errorCode: quota) on the account. It cannot be cleared from this session; a re-run fails the same way until the quota resets.

  • CI at 8cf45291f: the same, with CodeQL complete.

  • Local, at 8cf45291f (everything above except #415's goal target):

    • full suite: 12,663 runs, 53,947 assertions, 1 failure, 0 errors, 33 skips. The failure is the known Provider::OpenaiTest Ruby 3.3 vs 3.4 string, which passes in CI;
    • loans:verify_contract_mutations: 16 contract rows, 18 mutations, every row passing unmutated and failing under each of its mutations.
  • Local, at bb0a101b8: demo and goal tests, 161 runs, 0 failures. #415's own head a07186cf8 gives 12,629 runs on its full suite, with the same single failure.

  • The individual PRs, on their own heads:

    • 2026-10-11: ci / jobs green on #393, #394, #398, #400, #401, #403 and #410; #405's CI green at 22e65fb03; #413's CI green, its CodeQL Swift job passing on its one re-run; #415 all 8 checks green at both afe0afd37 and a07186cf8.
    • 2026-10-12, morning: #397 all green at 031824d3e; #405 all green at 24746641d; #415 all green at f35c392be.
    • 2026-10-12, later:
      • #394 all green at 16a034187.
      • #403 all green at 5732ec466.
      • #415 all 7 checks green at 95ff79e4c.
      • #405 green at a344aaa25, after one re-run.
        • The failure: ci / test_unit's first attempt failed at its "Loan daily-accrual performance gate" (loans:amortization_benchmark), with p95 239 ms against the 200 ms ceiling, before any test ran.
        • Why it wasn't the code: nothing this refresh changed is on that gate's path. Loan::Simulator, Loan::DailyInterest, the rake task and the workflows are byte-identical to 24746641d, where the gate passed, and the benchmark never reaches OffsetResolver. Run alternately on one machine, the two heads gave p95 206 / 238 / 240 ms (old) and 211 / 245 / 221 ms (new), and main gave 250–257 ms there.
        • Why a re-run: ci.yml's calibration note puts this gate at p95 93–127 ms on GitHub's runners, and says a reading near the ceiling is the runner's until a second run agrees. The step took 26 s, against 14 s on the last green run.
        • The re-run passed, with the step at 13 s. So did #415's ci / test_unit, which runs the same gate on this code.
        • Codacy Static Code Analysis again shows "action required" with no issues listed, as #405's description records.
  • Earlier states:

    • At 455385584: 32 of 33 checks green, the same Copilot quota failure the only one red; local full suite 12,639 runs, 1 failure (the same Provider::OpenaiTest).
    • At 157a93691 (all PRs but #405):
      • local full suite: 12,555 runs, 1 failure;
      • local loan system tests in headless Chromium 141: 24 runs, 182 assertions, 0 failures;
      • bin/rubocop on 60 changed Ruby files: no offenses; bin/brakeman: 0 warnings;
      • erb_lint: only the 2 pre-existing autocomplete errors on the rate-change inputs, which are also on main.
    • At ebb159e83 (with #405): local full suite 12,601 runs, 1 failure (the same Provider::OpenaiTest); loan system tests 20 runs, 0 failures; rubocop, erb_lint and brakeman clean.
  • The Jshint summary review ("more than 20 potential problems") posts no inline findings, and its Codacy check run reports success. With no .jshintrc, Jshint applies ES5 rules to module and class syntax; npm run lint and ci / lint_js pass.

Decisions taken without the owner, for review

  • #401: the retirement planner seeds a variable loan with the repayment in force now, not the one at origination (#184 open question 1). #405 keeps that.
  • #397: new loans default to 30/360, per #184's 2026-09-30 decision; existing loans keep actual/365. This is a separable commit.
  • #397 / #398: rolling back the day-count migrations refuses while any loan is on the new bases (since 2026-10-12, owner's instruction after the nightly review). Earlier it moved those loans to actual/365, which lost their contract basis.
  • #400: the rate-change parser accepts a narrow, stated set of wordings, chosen without real bank samples. Anything else is refused and logged rather than guessed, including, since 2026-10-12, change wording with no marker naming the new rate.
  • #402: a recorded initial_balance now beats the first valuation as the principal (upstream's definition), so loans where they differ restage and their figures move.
  • #415: the demo half of #3327 is now ported as its own change.
    • generator.rb is upstream's file except for the "Long-term portfolio" target. Future syncs should take upstream's side except for that hunk.
    • The goal target moved from 200,000 to 300,000 at the owner's request (2026-10-11), so the goal reads on track again rather than reached. Measured across four demo seeds; the figures are in #415.
  • #394: option A, recorded on #394 at the owner's instruction: the caption names the rate the quoted repayment is sized at. Since 2026-10-12 (owner's instruction) it calls the figure the schedule's next repayment, not "your lender's minimum". #405 carries both onto upstream's engine.
  • #403 / #405: an OffsetResolver is built per projection, so it keeps the linked offsets and today's total for that projection's life. A balance that changes mid-render is picked up on the next page load, not halfway through the projection.
  • #413: C11's contract row cited a "contract regression" test that does not exist. It now has a real test and mutation, rather than a weakened gate.
  • #414: G2b gets a private-run tool and a synthetic oracle; the gate stays open.
  • #393: new offsets come only from visible accounts, as collateral does. Accounts already linked stay listed whatever their status, and #338's existing-link check is carried in #393 so the merge order does not matter.
  • Integration base: e4e8a002e fixes the interaction between pr-338 and #393 on the base itself, because neither branch has the code that fails on its own.
  • #403: any page that draws the loan chart queues the stale-schedule rebuild the tabs already queued.
  • #405: eight decisions are listed in its own description (contract rows C4 and C5, the cached interest_rate's meaning, upstream tests not adopted, behaviours kept, removals, version 5's prebuild).
  • CI images: adopted on main at the owner's instruction (513ee49c6). llm-evals.yml (which runs only on v* tags) still pulls postgres:16 and redis:7.2 from Docker Hub; that is #407.
  • #394 / #397 / #398: Ukrainian, Russian and Turkish loan strings stay English, as they were on main; translation is a separate pass.

Review findings

  • Gatekeeper light review (comment 6092941143): DRAFT_ON_TRACK, with no BLOCKER, MAJOR or MODERATE findings in the integration glue.

    • Sibling review debt: agreed; a build from this branch proves the stack builds and runs, not that each PR is reviewed. Light reviews have since landed and been answered in each PR's description:

      • #393: one MODERATE, fixed in ee48897dc and merged here;
      • #401: one MINOR, fixed in 2290b1bc4 and merged here;
      • #400: one MINOR, declined with evidence, plus the test it asked for, merged here;
      • #403: one finding, declined with evidence (the extra-payment cap is already on main, and the copy already says "if you pay");
      • #413: one MODERATE, answered with the full gate run on this branch (18 of 18 mutations caught, including C11#2 and C16#2);
      • #396, #398, #402 and #405: answered, nothing to fix.

      None yet on #394, #395, #397, #399, #414 or #415.

    • CI-mirror commits must not leak: resolved the other way. The owner had them adopted on main (513ee49c6), so the workflow files match on all three branches and #405's diff against main will carry no workflow change.

  • Codacy Jshint (the "more than 20 potential problems" summary): see Validation; all 21 annotations are ES5-rule noise on module syntax and optional chaining.

  • "code master" review (comment 6105905262), BLOCK. Agreed on its conclusion: this branch is not a deployment artifact, and each change goes through its own PR. Each item maps to the PR that owns it, or to a decision already recorded above. Checked against 455385584:

    1. Engine rewrite: #405, the owner's #184 phases 3–6. The figures that move are listed in #405, each explained. The evidence is the golden master, the G1 gate (16 rows, 18 mutations, all caught on this branch) and G2a's lender reconciliation. The :scheduled projection is #100 decision 1 (#401). No parallel old-vs-new run exists; whether #405 needs one before it merges is the owner's call.
    2. The chart's rescue StandardError: declined here; not fork code. It is upstream's loan_payoff_chart from we-promise/sure#3474: the same rescue, the same Sentry report and the same comment are on mirror/upstream-main (app/controllers/accounts_controller.rb:343). #405 carries it in. Changing it would be an upstream discussion.
    3. The 30/360 default: #397, per #184's 2026-09-30 decision, already listed under Decisions. The review is right that a loan created after the migration starts on a different basis from one created before it; that is the decision. Existing loans are unchanged, and the commit is separable.
    4. The rate-change parser: #400. Its decisions are recorded there. Anything outside the stated wordings is refused and logged, not guessed, and the 3-place rounding is the loan column's own precision. Real bank samples are #400's named follow-up.
    5. Insurance: #402, upstream's we-promise/sure#3327 re-admitted as written, validations included. An upper bound on insurance_rate would be an upstream change.
    6. The projection rewrite: #100 decision 1, in #401 (with its moved figures) and #405.
    7. Migration ordering: declined. Rails runs migrations in version order. None of 20260907000000, 20261009120000 or 20261009130000 disables the DDL transaction, so on PostgreSQL each constraint swap commits or rolls back whole. A failed third migration leaves the second's constraint and a pending migration, which db:migrate:status shows.
    8. Memoisation: declined. The memos are instance variables on records loaded per request, and Puma threads don't share Active Record instances. The schedule cache is keyed by a signature over its inputs, so a changed input rebuilds it.
    9. Validation on new fields: #402, with upstream's validations. There is no division by zero: initial_leverage_ratio returns nil unless down_payment is positive (app/models/loan.rb:501). Upper bounds would be upstream's call.
    10. Reconciliation has no production integration: by design. #414 is G2b's private diagnostic, and its own review is answered in #414.

    #413's and #414's "code master" reviews are answered in their own descriptions.

  • Nightly review (comment 6120451342), NOT READY TO MERGE, on bb0a101b8. Agreed, and nothing to change.

    • HIGH, the branch is a test assembly: that is this PR's purpose, as its title and Summary say ("Do not merge").
    • Its required fix is already the plan:
      • merge the constituent PRs in order through their own PRs;
      • test their interactions at each resulting head;
      • keep this branch for verification only.
    • The PR stays a draft and is never marked ready. Once the loan PRs merge, it is rebuilt from their heads rather than merged (Risks, "Drift").
    • The nightly reviews' three blockers on the constituent PRs (#397, #398, #400) are fixed in those PRs and merged here (2026-10-12, above).
  • Nightly review (comment 6134292526), NOT READY TO MERGE, on b87220e12. The same finding as the review above, and the same answer: nothing to change. The branch is a verification assembly and is never merged. Its required fix is the plan already in place: merge the constituent PRs in order, and re-test their interactions at each resulting head. #338, #413 and #396 have merged that way since (2026-10-12).

Review responses are recorded in each PR's description rather than as comments or thread replies, because anything posted from this session gets an assistant footer appended, which the attribution rule forbids.

Risks, blockers, and follow-up

  • Gatekeeper reviews were set aside for this build, at the owner's request. Light (draft) reviews have now landed on nine of the PRs, all DRAFT_ON_TRACK; none has had a full READY review. #390's Issue Gatekeeper Review has still not landed. #405 needs the full review most.
  • Very long loans render slower than on main. With the offset fix, a 360-month loan page is close to main (0.56 s against 0.48 s), but a 1,200-month loan is 2.22 s against 1.57 s. The extra time is #405's engine walking every period, not offsets or queries. This is recorded rather than fixed: 100-year loans are rare, and making the walk cheaper is #405's engine work, not this branch's.
  • The individual loan PRs' CI now uses the mirrors too: pull_request runs use the PR merged into main, which carries 513ee49c6.
  • The ECR mirror can rate-limit too. public.ecr.aws refused pulls on 2026-10-11 (docker-verify) and 2026-10-12 (ci / test_unit on d838e0336), both toomanyrequests: Rate exceeded. A single re-run passed each time. If it keeps recurring, the service images could be pulled through mirror.gcr.io as codacy.yml does.
  • A leftover branch. claude/loans-docker-verify was the first, throwaway home of the verification workflow; this session cannot delete branches, so it is left for the owner to remove.
  • An earlier publish run. The publish.yml dispatch (run 37992411473, push=false) stopped at its CI stage before its image build and published nothing.
  • Drift. This branch will drift from main as the PRs merge; rebuild it from their heads rather than merging it.