Skip to content

migrate(CRDTAGY): translate credit agency batch (1..5)#30

Merged
a2chang merged 3 commits intomainfrom
migrate/CRDTAGY
May 1, 2026
Merged

migrate(CRDTAGY): translate credit agency batch (1..5)#30
a2chang merged 3 commits intomainfrom
migrate/CRDTAGY

Conversation

@a2chang
Copy link
Copy Markdown
Contributor

@a2chang a2chang commented May 1, 2026

Source program

Mapped REST endpoints

  • POST /api/v1/crdtagy/{agencyNumber} where agencyNumber is 1..5

Notable decisions

  • Modeled the five COBOL programs as a shared CreditAgency enum/registry plus one async CreditAgencyService, avoiding five copy-paste service classes.
  • Reused the existing CreCust DTO envelope because the CRDTAGY container layout matches the customer commarea that CRECUST already sends to the async child programs.
  • Kept the credit-agency delay/score generators injectable for deterministic tests while using @async("creditAgencyExecutor") with the existing virtual-thread executor in production.
  • Mirrored the COBOL COMPUTE/integer-receiver behavior with exclusive upper bounds (nextLong(1, 3) effective delay range and nextInt(1, 999) effective score range), rather than the looser prose comments in the COBOL headers.
  • Tightened CrecustService to a single 3-second overall reply window so the parent orchestration matches the COBOL DELAY FOR SECONDS(3) + FETCH ANY NOSUSPEND flow more closely.
  • No Flyway migration was needed because CRDTAGY is a pure async simulation with no new persistence tables.

Test coverage

  • Unit: CreditAgencyServiceUnitTest
  • @SpringBootTest: CreditAgencyServiceIntegrationTest
  • MockMvc: CrdtagyControllerWebMvcTest
  • Regression coverage: CrecustServiceUnitTest, CrecustServiceIntegrationTest

@a2chang
Copy link
Copy Markdown
Contributor Author

a2chang commented May 1, 2026

augment review

@augmentcode
Copy link
Copy Markdown
Contributor

augmentcode Bot commented May 1, 2026

Test Coverage Guardian 🧪

Test coverage looks good. The new/changed behavior in this PR has adequate test coverage. No additional tests needed.

Copy link
Copy Markdown

@augment-app-staging augment-app-staging Bot left a comment

Choose a reason for hiding this comment

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

Review completed. 2 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

continue;
}

Optional<Integer> maybeScore = future.get(remainingNanos, TimeUnit.NANOSECONDS);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Because the credit-agency futures are awaited sequentially up to a shared deadline, one slow/hung agency can consume the entire reply window and prevent collecting other agencies that already completed, which can incorrectly trigger the "credit check could not be completed" path.

Severity: medium

🤖 Was this useful? React with 👍 or 👎


private int awaitCreditScore(CrecustRequest request, int agencyNumber) {
try {
return creditAgencyService.requestCreditScore(request, agencyNumber).join().orElse(0);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

awaitCreditScore() uses join() without any timeout/cancellation, so if requestCreditScore() stalls the HTTP request can block indefinitely (unlike the bounded reply window used by CrecustService).

Severity: medium

🤖 Was this useful? React with 👍 or 👎

Copy link
Copy Markdown

@augment-app-staging augment-app-staging Bot left a comment

Choose a reason for hiding this comment

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

Review completed. 2 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

}

int score = scoreGenerator.nextCreditScore(agency, request);
if (score < 1 || score > 999) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The score bounds check allows 999, but creditAgencyScoreGenerator() is documented as producing 1..998 to mirror COBOL truncation; if 998 is the intended effective upper bound, allowing 999 here could let injected generators drift from that behavior.

Severity: low

🤖 Was this useful? React with 👍 or 👎

continue;
}

Optional<Integer> maybeScore = future.get(remainingNanos, TimeUnit.NANOSECONDS);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This method now enforces a single overall reply deadline via deadlineNanos, but the TimeoutException comment below still describes a per-agency timeout; that mismatch could mislead future changes.

Severity: low

🤖 Was this useful? React with 👍 or 👎

@a2chang
Copy link
Copy Markdown
Contributor Author

a2chang commented May 1, 2026

augment review

Copy link
Copy Markdown

@augment-app-staging augment-app-staging Bot left a comment

Choose a reason for hiding this comment

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

Review completed. 1 suggestion posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

boolean interrupted = false;
for (CompletableFuture<Optional<Integer>> future : futures) {
if (interrupted) {
if (!future.isDone() || future.isCompletedExceptionally() || future.isCancelled()) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

In evaluateCredit, a future can complete between the !future.isDone() check and the subsequent cancel(true) call, which can cause a valid score to be skipped even though it completed within the reply window. Consider handling the cancel() return value (or reading the result before cancelling) to avoid dropping just-completed replies.

Severity: medium

🤖 Was this useful? React with 👍 or 👎

@a2chang
Copy link
Copy Markdown
Contributor Author

a2chang commented May 1, 2026

augment review

Copy link
Copy Markdown

@augment-app-staging augment-app-staging Bot left a comment

Choose a reason for hiding this comment

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

Review completed. 1 suggestion posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

commarea.commDateOfBirth(),
creditScore,
defaultInt(commarea.commCsReviewDate()),
defaultString(commarea.commSuccess()),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

On successful processing, CommSuccess / CommFailCode are currently echoed from the request (and defaulted), so callers can receive a credit score but still see a blank/incorrect success indicator. Consider populating these fields from the actual outcome (similar to other controllers) so the response consistently signals success/failure.

Severity: medium

🤖 Was this useful? React with 👍 or 👎

@a2chang a2chang merged commit d2cdb94 into main May 1, 2026
1 check passed
@a2chang a2chang deleted the migrate/CRDTAGY branch May 1, 2026 14:00
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