Skip to content

Adk - #33

Merged
e4c5 merged 100 commits into
masterfrom
adk
Apr 18, 2026
Merged

Adk#33
e4c5 merged 100 commits into
masterfrom
adk

Conversation

@e4c5

@e4c5 e4c5 commented Apr 18, 2026 •

Copy link
Copy Markdown
Owner

CodeAnt-AI Description

Add broader branch coverage, stream support, and more reliable mock and repository handling

What Changed

  • Branch coverage now keeps track of earlier branch choices so later conditions can be exercised in more than one combination
  • Stream evaluation now handles more stream operations, including primitive streams, sorted() without a comparator, and more terminal operations
  • Mock and return-value handling now adapts to the declared type more often, including casted Object returns, enums, numeric parsing, and missing dependency cases
  • Repository and condition handling now covers boolean returns, empty collections, enum comparisons, optional paths, and output-parameter-style lists without forcing unreachable test data
  • Added processing reports, branch traces, and new tests for the updated behavior

Impact

✅ More branch combinations covered in generated tests
✅ Fewer failures when evaluating streams and mocks
✅ More realistic test data for repository and collection code

🔄 Retrigger CodeAnt AI Review

Details

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

e4c5 and others added 30 commits March 29, 2026 08:25
- Add verified code locations table to Current State Summary
- P1: Add mapToInt/Long/Double/Obj to intermediate ops list
- P1: Add sorted() no-arg overload note
- P1: Add critical functional interface type adaptation note with adapter pattern
- P1: Clarify Variable.clazz must be set from result.getClass() for chain propagation
- P1.2: Document collect() two overloads, reduce three overloads, Optional clazz handling
- P1 checklist: expand with new test methods and functional adapter item
- P2: Correct isReturning() bug description (block-body lambdas, not expression lambdas)
- P2 tests: fix incorrect terminology (block-body, not expression-statement)
- P4: Clarify mapToInt/Long/Double routing via P1, add instanceof detection guidance
- Add Known Limitations / Out of Scope section
- Update Files Index note about private helper methods

Agent-Logs-Url: https://github.com/Cloud-Solutions-International/antikythera/sessions/2e2d9e63-4e3a-4a8b-9bad-d95f39ad7b9f

Co-authored-by: e4c5 <1635446+e4c5@users.noreply.github.com>
…ions-International/copilot/validate-and-improve-stream-support-plan

Validate and improve stream-support-implementation-plan.md
…uator fix, P3 collectors, P4 primitive streams

Agent-Logs-Url: https://github.com/Cloud-Solutions-International/antikythera/sessions/d60b1f4b-90df-4807-8543-8564bdb9cc8b

Co-authored-by: e4c5 <1635446+e4c5@users.noreply.github.com>
@codeant-ai

codeant-ai Bot commented Apr 18, 2026

Copy link
Copy Markdown

CodeAnt AI is reviewing your PR.


Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@coderabbitai

coderabbitai Bot commented Apr 18, 2026 •

Copy link
Copy Markdown

Warning

Rate limit exceeded

@e4c5 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 48 minutes and 20 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 48 minutes and 20 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5bec100e-0340-4352-9d8b-c43fb14c3ab6

📥 Commits

Reviewing files that changed from the base of the PR and between 65a88b1 and 990ee9e.

📒 Files selected for processing (72)
  • .codex
  • AGENTS.md
  • BRANCHING_COMBINATION_PLAN.md
  • CODE_REVIEW_REPORT.md
  • README.md
  • docs/configurations.md
  • src/main/java/sa/com/cloudsolutions/antikythera/configuration/Settings.java
  • src/main/java/sa/com/cloudsolutions/antikythera/evaluator/AntikytheraRunTime.java
  • src/main/java/sa/com/cloudsolutions/antikythera/evaluator/ArgumentGenerator.java
  • src/main/java/sa/com/cloudsolutions/antikythera/evaluator/BranchAttempt.java
  • src/main/java/sa/com/cloudsolutions/antikythera/evaluator/BranchAttemptFingerprint.java
  • src/main/java/sa/com/cloudsolutions/antikythera/evaluator/BranchAttemptPlanner.java
  • src/main/java/sa/com/cloudsolutions/antikythera/evaluator/BranchSelection.java
  • src/main/java/sa/com/cloudsolutions/antikythera/evaluator/BranchSide.java
  • src/main/java/sa/com/cloudsolutions/antikythera/evaluator/Branching.java
  • src/main/java/sa/com/cloudsolutions/antikythera/evaluator/BranchingTrace.java
  • src/main/java/sa/com/cloudsolutions/antikythera/evaluator/ConditionVisitor.java
  • src/main/java/sa/com/cloudsolutions/antikythera/evaluator/ControlFlowEvaluator.java
  • src/main/java/sa/com/cloudsolutions/antikythera/evaluator/DummyArgumentGenerator.java
  • src/main/java/sa/com/cloudsolutions/antikythera/evaluator/Evaluator.java
  • src/main/java/sa/com/cloudsolutions/antikythera/evaluator/ExceptionContext.java
  • src/main/java/sa/com/cloudsolutions/antikythera/evaluator/GeneratorState.java
  • src/main/java/sa/com/cloudsolutions/antikythera/evaluator/InnerClassEvaluator.java
  • src/main/java/sa/com/cloudsolutions/antikythera/evaluator/LineOfCode.java
  • src/main/java/sa/com/cloudsolutions/antikythera/evaluator/LoopContext.java
  • src/main/java/sa/com/cloudsolutions/antikythera/evaluator/MethodBodyMockStubAnalyzer.java
  • src/main/java/sa/com/cloudsolutions/antikythera/evaluator/MethodInterceptor.java
  • src/main/java/sa/com/cloudsolutions/antikythera/evaluator/MockReturnValueHandler.java
  • src/main/java/sa/com/cloudsolutions/antikythera/evaluator/MockingEvaluator.java
  • src/main/java/sa/com/cloudsolutions/antikythera/evaluator/NumericComparator.java
  • src/main/java/sa/com/cloudsolutions/antikythera/evaluator/PreservedPathState.java
  • src/main/java/sa/com/cloudsolutions/antikythera/evaluator/Reflect.java
  • src/main/java/sa/com/cloudsolutions/antikythera/evaluator/ReflectionArguments.java
  • src/main/java/sa/com/cloudsolutions/antikythera/evaluator/SpringEvaluator.java
  • src/main/java/sa/com/cloudsolutions/antikythera/evaluator/Variable.java
  • src/main/java/sa/com/cloudsolutions/antikythera/evaluator/functional/FPEvaluator.java
  • src/main/java/sa/com/cloudsolutions/antikythera/evaluator/functional/FunctionalInvocationHandler.java
  • src/main/java/sa/com/cloudsolutions/antikythera/evaluator/functional/NAryConsumerEvaluator.java
  • src/main/java/sa/com/cloudsolutions/antikythera/evaluator/functional/NAryFunctionEvaluator.java
  • src/main/java/sa/com/cloudsolutions/antikythera/evaluator/mock/MockingRegistry.java
  • src/main/java/sa/com/cloudsolutions/antikythera/generator/AssertionConfidence.java
  • src/main/java/sa/com/cloudsolutions/antikythera/generator/BaseRepositoryQuery.java
  • src/main/java/sa/com/cloudsolutions/antikythera/generator/CopyUtils.java
  • src/main/java/sa/com/cloudsolutions/antikythera/generator/MethodResponse.java
  • src/main/java/sa/com/cloudsolutions/antikythera/generator/RepositoryQuery.java
  • src/main/java/sa/com/cloudsolutions/antikythera/generator/SerializationConfidence.java
  • src/main/java/sa/com/cloudsolutions/antikythera/generator/TruthTable.java
  • src/main/java/sa/com/cloudsolutions/antikythera/generator/TypeWrapper.java
  • src/main/java/sa/com/cloudsolutions/antikythera/parser/AbstractCompiler.java
  • src/main/java/sa/com/cloudsolutions/antikythera/parser/BaseRepositoryParser.java
  • src/main/java/sa/com/cloudsolutions/antikythera/parser/DepsolvingParser.java
  • src/main/java/sa/com/cloudsolutions/antikythera/parser/EvaluationListener.java
  • src/main/java/sa/com/cloudsolutions/antikythera/parser/MavenHelper.java
  • src/main/java/sa/com/cloudsolutions/antikythera/parser/ProcessingReport.java
  • src/test/java/sa/com/cloudsolutions/antikythera/evaluator/TestAKBuddy.java
  • src/test/java/sa/com/cloudsolutions/antikythera/evaluator/TestBranchingCombinations.java
  • src/test/java/sa/com/cloudsolutions/antikythera/evaluator/TestConditionVisitor.java
  • src/test/java/sa/com/cloudsolutions/antikythera/evaluator/TestConditional.java
  • src/test/java/sa/com/cloudsolutions/antikythera/evaluator/TestEvaluator.java
  • src/test/java/sa/com/cloudsolutions/antikythera/evaluator/TestFunctionalStream.java
  • src/test/java/sa/com/cloudsolutions/antikythera/evaluator/TestHelper.java
  • src/test/java/sa/com/cloudsolutions/antikythera/evaluator/TestLineOfCode.java
  • src/test/java/sa/com/cloudsolutions/antikythera/evaluator/TestMockReturnValueHandler.java
  • src/test/java/sa/com/cloudsolutions/antikythera/evaluator/TestNumericComparator.java
  • src/test/java/sa/com/cloudsolutions/antikythera/evaluator/TestReflect.java
  • src/test/java/sa/com/cloudsolutions/antikythera/evaluator/mock/MockingRegistryStubReturnTest.java
  • src/test/java/sa/com/cloudsolutions/antikythera/generator/MethodResponseTest.java
  • src/test/java/sa/com/cloudsolutions/antikythera/generator/TestTruthTable.java
  • src/test/java/sa/com/cloudsolutions/antikythera/parser/AbstractCompilerTest.java
  • src/test/java/sa/com/cloudsolutions/antikythera/parser/BaseRepositoryParserTest.java
  • src/test/resources/generator-stream-tests.yml
  • src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch adk

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@viper-review

viper-review Bot commented Apr 18, 2026

Copy link
Copy Markdown

Viper is reviewing this pull request and will update the description shortly.

@codeant-ai codeant-ai Bot added the size:XXL This PR changes 1000+ lines, ignoring generated files label Apr 18, 2026

@viper-review viper-review 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.

Code review comments

Comment on lines 30 to 38
attachPredecessors(lineOfCode);
if (lineOfCode.shouldSchedule()) {
PriorityQueue<LineOfCode> queue = conditionals.computeIfAbsent(
lineOfCode.getCallableDeclaration(),
k -> new PriorityQueue<>(new LineOfCodeComparator())
);
queue.add(lineOfCode);
}
branches.putIfAbsent(lineOfCode.getStatement().hashCode(), lineOfCode);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[High] Predecessor links are only attached on the first registration of a LineOfCode, but the same LineOfCode is re-added to the queue later. Because predecessors is never cleared or recomputed, reused branch nodes can keep stale relationships from an earlier execution and the planner will preserve the wrong prior branch sides on subsequent method evaluations.

Prompt for AI Agents

Review observation from Viper

File: src/main/java/sa/com/cloudsolutions/antikythera/evaluator/Branching.java
Lines: 30-38

Instruction:
In src/main/java/sa/com/cloudsolutions/antikythera/evaluator/Branching.java, prevent stale predecessor state from accumulating on reused LineOfCode instances. LineOfCode.predecessors is persistent, so calling attachPredecessors() every time add() is invoked can carry old structural relationships into later evaluations and break branch-combination planning. Update add() so predecessor attachment happens only for the initial registration of a branch node (or alternatively add an explicit predecessor reset/rebuild step before reattaching). Keep the existing queueing semantics intact while ensuring repeated add()/requeue() operations cannot mutate preserved predecessor state incorrectly.


Please confirm the validity of this finding. If correct, use the instruction above to guide a fix. The implementation should be as concise as possible while resolving the issue.

Suggested change
attachPredecessors(lineOfCode);
if (lineOfCode.shouldSchedule()) {
PriorityQueue<LineOfCode> queue = conditionals.computeIfAbsent(
lineOfCode.getCallableDeclaration(),
k -> new PriorityQueue<>(new LineOfCodeComparator())
);
queue.add(lineOfCode);
}
branches.putIfAbsent(lineOfCode.getStatement().hashCode(), lineOfCode);
if (lineOfCode.shouldSchedule()) {
PriorityQueue<LineOfCode> queue = conditionals.computeIfAbsent(
lineOfCode.getCallableDeclaration(),
k -> new PriorityQueue<>(new LineOfCodeComparator())
);
if (!queue.contains(lineOfCode)) {
attachPredecessors(lineOfCode);
queue.add(lineOfCode);
}
}
branches.putIfAbsent(lineOfCode.getStatement().hashCode(), lineOfCode);

@viper-review viper-review 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.

Code review comments

Comment on lines +70 to +71
return preservedSidesByBranch.toString();
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[Medium] toString() omits rowHint, so trace output conflates preserved states that differ only by row selection. That makes the new branch-attempt diagnostics misleading exactly in the multi-row OR cases this planner is trying to debug.

Prompt for AI Agents

Review observation from Viper

File: src/main/java/sa/com/cloudsolutions/antikythera/evaluator/PreservedPathState.java
Lines: 70-71

Instruction:
In src/main/java/sa/com/cloudsolutions/antikythera/evaluator/PreservedPathState.java, update toString() so it includes rowHint in addition to the preserved branch-side map. rowHint participates in equality and attempt planning, so leaving it out makes BranchingTrace logs ambiguous and hides distinct preserved states during debugging of cross-product branch exploration.


Please confirm the validity of this finding. If correct, use the instruction above to guide a fix. The implementation should be as concise as possible while resolving the issue.

Suggested change
return preservedSidesByBranch.toString();
}
return "PreservedPathState{" +
"sides=" + preservedSidesByBranch +
", rowHint=" + rowHint +
'}';

@viper-review

viper-review Bot commented Apr 18, 2026

Copy link
Copy Markdown

Walkthrough

  • Branch Planning and Control Flow

    • Added branch-attempt planning types and trace/state preservation logic.
    • Updated evaluator/control-flow components to record and replay branch decisions.
  • Runtime Evaluation and Invocation

    • Refined argument generation, reflection helpers, method interception, and exception/loop context handling.
    • Extended functional and Spring/mock evaluation paths.
  • Generation and Parsing

    • Updated truth-table, response/confidence, repository query, and parser/reporting components to consume richer evaluation outcomes.
  • Tests and Documentation

    • Added focused tests for branching combinations, mocks, numeric comparison, parser/compiler behavior, and generator flows.
    • Expanded configuration and review/planning documentation.

Findings Overview

  • High

    • Branch graph state management: Branching retains stale predecessor links when LineOfCode instances are re-queued, causing preserved-path planning to use incorrect prior branch relationships across evaluations.
  • Medium

    • Diagnostic fidelity: PreservedPathState.toString() omits rowHint, making trace logs ambiguous for multi-row OR preservation cases and reducing the usefulness of the new planner diagnostics.

Narrative Summary

This PR materially extends the evaluator from single-pass condition handling toward preserved-path branch exploration and more comprehensive execution modeling. The most significant issue is in Branching, where predecessor metadata is reused without recomputation when nodes are revisited; this can invalidate branch-attempt planning and should be corrected first because it affects behavioral correctness, not just observability. Secondary attention should go to trace rendering in PreservedPathState, since the new debugging output currently collapses distinct preserved states in the exact scenarios the planner is meant to explain. Once branch-state lifecycle and diagnostics are aligned, the added tests and infrastructure should provide a stronger foundation for the expanded evaluator behavior.

Comment on lines +222 to +234
String fieldName = fd.getVariable(0).getNameAsString();
Variable fieldVar = eval.getField(fieldName);
if (fieldVar != null && fieldVar.getValue() == null) {
Type fieldType = fd.getVariable(0).getType();
if (fieldType.isClassOrInterfaceType()
&& "String".equals(fieldType.asClassOrInterfaceType().getNameAsString())
&& hasSetterMethod(typeDecl, fieldName)) {
fieldVar.setValue("0");
if (fieldVar.getInitializer().isEmpty()) {
fieldVar.setInitializer(List.of(new StringLiteralExpr("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.

Suggestion: This only initializes the first variable in each field declaration (getVariable(0)), so declarations like String a, b; leave b null and can still trigger null-driven branch failures. Iterate over all declared variables in each field declaration. [logic error]

Severity Level: Major ⚠️
- ❌ DummyArgumentGenerator misses String fields after first in declaration.
- ⚠️ ControlFlowEvaluator branch analysis wrong for uninitialized String fields.
- ⚠️ MockingEvaluator-generated collections omit data from skipped fields.
Suggested change
String fieldName = fd.getVariable(0).getNameAsString();
Variable fieldVar = eval.getField(fieldName);
if (fieldVar != null && fieldVar.getValue() == null) {
Type fieldType = fd.getVariable(0).getType();
if (fieldType.isClassOrInterfaceType()
&& "String".equals(fieldType.asClassOrInterfaceType().getNameAsString())
&& hasSetterMethod(typeDecl, fieldName)) {
fieldVar.setValue("0");
if (fieldVar.getInitializer().isEmpty()) {
fieldVar.setInitializer(List.of(new StringLiteralExpr("0")));
}
}
}
fd.getVariables().forEach(vd -> {
String fieldName = vd.getNameAsString();
Variable fieldVar = eval.getField(fieldName);
if (fieldVar != null && fieldVar.getValue() == null) {
Type fieldType = vd.getType();
if (fieldType.isClassOrInterfaceType()
&& "String".equals(fieldType.asClassOrInterfaceType().getNameAsString())
&& hasSetterMethod(typeDecl, fieldName)) {
fieldVar.setValue("0");
if (fieldVar.getInitializer().isEmpty()) {
fieldVar.setInitializer(List.of(new StringLiteralExpr("0")));
}
}
}
});
Steps of Reproduction ✅
1. In `MockingEvaluator.handleRepositorySingleEntityReturn`
(`src/main/java/sa/com/cloudsolutions/antikythera/evaluator/MockingEvaluator.java:23-27`),
a repository method returning a `Collection<Entity>` is processed and
`setupNonEmptyCollection(...)` is invoked at `MockingEvaluator.java:15-20`.

2. `setupNonEmptyCollection(...)` in `ControlFlowEvaluator`
(`src/main/java/sa/com/cloudsolutions/antikythera/evaluator/ControlFlowEvaluator.java:902-917`)
computes the collection element type and, when `member.getValue() == null`, calls
`recreateVariable(primaryType)` at line 914.

3. `recreateVariable(...)` (`ControlFlowEvaluator.java:923-942`) resolves the element type
and calls
`DummyArgumentGenerator.createObjectWithSimplestConstructor(wrapper.getType().asClassOrInterfaceDeclaration(),
"nomatter")` at line 927, which in turn invokes `initializeEvaluatorStringFields(o,
cdecl)` at `DummyArgumentGenerator.java:210`.

4. Inside `initializeEvaluatorStringFields(...)` (`DummyArgumentGenerator.java:220-235`),
the loop iterates `for (FieldDeclaration fd : typeDecl.getFields())` but always uses
`fd.getVariable(0)` for both name and type; for a user type with a declaration like
`String firstName, lastName;`, only `firstName` gets a non-null `Variable` in the
evaluator, while `lastName` stays null, so any conditional logic in evaluated methods that
depends on `lastName` being non-null will incorrectly take the "null" branch during
evaluation and generated test synthesis.
Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** src/main/java/sa/com/cloudsolutions/antikythera/evaluator/DummyArgumentGenerator.java
**Line:** 222:234
**Comment:**
	*Logic Error: This only initializes the first variable in each field declaration (`getVariable(0)`), so declarations like `String a, b;` leave `b` null and can still trigger null-driven branch failures. Iterate over all declared variables in each field declaration.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
👍 | 👎

Comment on lines +291 to +296
f.setAccessible(true);
try {
if (f.get(instance) == null) {
f.set(instance, "0");
}
} catch (IllegalAccessException e) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggestion: setAccessible(true) can throw runtime access exceptions (for example under Java module encapsulation), which currently escape and fail argument generation. Catch those runtime access failures and skip inaccessible fields. [possible bug]

Severity Level: Critical 🚨
- ❌ initializeNullStringFields can throw RuntimeException on setAccessible.
- ❌ DummyArgumentGenerator.generateArgument crashes, aborting evaluator argument generation.
- ⚠️ MockingEvaluator collection setup fails when entity instantiation fails.
Suggested change
f.setAccessible(true);
try {
if (f.get(instance) == null) {
f.set(instance, "0");
}
} catch (IllegalAccessException e) {
try {
f.setAccessible(true);
if (f.get(instance) == null) {
f.set(instance, "0");
}
} catch (RuntimeException | IllegalAccessException e) {
// skip fields that can't be accessed in this runtime
Steps of Reproduction ✅
1. A non-primitive parameter is evaluated via
`DummyArgumentGenerator.generateArgument(Parameter param)`
(`src/main/java/sa/com/cloudsolutions/antikythera/evaluator/DummyArgumentGenerator.java:36-47`),
for example through tests that set `((SpringEvaluator)evaluator).setArgumentGenerator(new
DummyArgumentGenerator())` in `TestConditional`
(`src/test/java/sa/com/cloudsolutions/antikythera/evaluator/TestConditional.java:80, 97,
111, 125, 138`), or any consumer using `DummyArgumentGenerator` for a user class with
private `String` fields in a non-open module.

2. `generateArgument` calls `mockNonPrimitiveParameter(param)`
(`DummyArgumentGenerator.java:50-66`), which delegates to
`mockNonPrimitiveParameterHelper(param)` at line 51; when the target type resolves to a
concrete `Class<?>` (non-`java.util`, non-interface, non-enum), control flows into
`mockNonPrimitiveParameterHelper(Parameter, TypeWrapper)` at
`DummyArgumentGenerator.java:244-285`.

3. In `mockNonPrimitiveParameterHelper(Parameter, TypeWrapper)`, the code creates an
instance via `clazz.getDeclaredConstructor().newInstance()` and then calls
`initializeNullStringFields(instance)` at `DummyArgumentGenerator.java:275` to populate
non-static `String` fields with a default `"0"` value.

4. `initializeNullStringFields(...)` (`DummyArgumentGenerator.java:288-300`) iterates
`instance.getClass().getDeclaredFields()` and, for each non-static `String` field,
executes `f.setAccessible(true);` at line 291 outside the surrounding `try`/`catch`; on
strongly encapsulated Java 9+ runtimes, this can throw `InaccessibleObjectException` (a
`RuntimeException`) for fields in non-open modules, which is not caught by the existing
`catch (IllegalAccessException e)` block, causing an uncaught runtime exception that
aborts `generateArgument` and the entire evaluator flow instead of harmlessly skipping
inaccessible fields.
Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** src/main/java/sa/com/cloudsolutions/antikythera/evaluator/DummyArgumentGenerator.java
**Line:** 291:296
**Comment:**
	*Possible Bug: `setAccessible(true)` can throw runtime access exceptions (for example under Java module encapsulation), which currently escape and fail argument generation. Catch those runtime access failures and skip inaccessible fields.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
👍 | 👎

expanded.add(state.with(predecessor, side, row));
}
} else {
expanded.add(state.with(predecessor, side));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggestion: The preserved row index is being reset to 0 whenever a predecessor side is added without OR-row expansion, which discards row selection chosen earlier in the same state build. This causes wrong preserved combinations to be materialized for earlier predecessors. Keep the existing row hint when adding non-expanded sides. [logic error]

Severity Level: Critical 🚨
- ❌ Cross-product predecessor combinations not fully explored in SpringEvaluator.
- ⚠️ Preserved-path truth-table rows collapse to first row only.
- ⚠️ Branching.resetBranchesWithUntriedCombinations underestimates remaining combinations.
- ⚠️ Test BranchingCombinations may miss certain preserved branch scenarios.
Suggested change
expanded.add(state.with(predecessor, side));
expanded.add(state.with(predecessor, side, state.getRowHint()));
Steps of Reproduction ✅
1. Run the JUnit test `sequentialDirectShouldCoverAllFourCombinations` in
`src/test/java/sa/com/cloudsolutions/antikythera/evaluator/TestBranchingCombinations.java:127-155`.
This constructs an evaluator for
`sa.com.cloudsolutions.antikythera.testhelper.evaluator.BranchingCombinations` and calls
`evaluator.visit(method)` to drive branch exploration.

2. Inside `SpringEvaluator.visit(...)`, the main evaluation loop at
`src/main/java/sa/com/cloudsolutions/antikythera/evaluator/SpringEvaluator.java:300-327`
repeatedly pulls `LineOfCode` instances from `Branching` and, for each `if`-like
conditional, calls `setupIfCondition(...)` which in turn calls
`Branching.selectTargetAttempt(currentConditional, targetSide, combinations)` at
`SpringEvaluator.java:1225-1227`.

3. `Branching.selectTargetAttempt(...)` in
`src/main/java/sa/com/cloudsolutions/antikythera/evaluator/Branching.java:64-66` delegates
to `BranchAttemptPlanner.selectNextAttempt(...)`, which calls
`candidatePreservedPathStates(target)` at `BranchAttemptPlanner.java:37-39`. For a target
with multiple sibling predecessors, where at least one predecessor has an `OR` condition
(so `trueRowCount > 1`) and at least one predecessor does not,
`candidatePreservedPathStates(...)` at `BranchAttemptPlanner.java:117-127` first creates
states with non-zero `rowHint` via `state.with(predecessor, side, row)` for the `OR`
predecessor, then later executes the `else` block at `BranchAttemptPlanner.java:125-127`,
which calls `state.with(predecessor, side)` and thereby resets `rowHint` to `0` (because
`PreservedPathState.with(LineOfCode, BranchSide)` delegates to `with(branch, side, 0)` in
`PreservedPathState.java:26-31`).

4. When the resulting `BranchAttempt` is applied,
`SpringEvaluator.applyPreservedPathState(...)` at `SpringEvaluator.java:1250-1254` reads
`rowHint` from the `PreservedPathState` and passes it to `materializeBranchSide(...)`.
`materializeBranchSide(...)` uses `rowHint` to select a truth-table row via `int index =
rowHint % combinations.size()` at `SpringEvaluator.java:1269-1275`. Because `rowHint` was
reset to `0` by the `else` branch in
`BranchAttemptPlanner.candidatePreservedPathStates(...)`, all preserved predecessors are
forced to use the first truth-table row, and any previously chosen non-zero row index for
an earlier `OR` predecessor is discarded. This prevents the evaluator from materializing
all intended preserved combinations across sibling predecessors, reducing cross-product
coverage.
Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** src/main/java/sa/com/cloudsolutions/antikythera/evaluator/BranchAttemptPlanner.java
**Line:** 126:126
**Comment:**
	*Logic Error: The preserved row index is being reset to `0` whenever a predecessor side is added without OR-row expansion, which discards row selection chosen earlier in the same state build. This causes wrong preserved combinations to be materialized for earlier predecessors. Keep the existing row hint when adding non-expanded sides.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
👍 | 👎

@codeant-ai

codeant-ai Bot commented Apr 18, 2026

Copy link
Copy Markdown

CodeAnt AI finished reviewing your PR.

@e4c5

e4c5 commented Apr 18, 2026

Copy link
Copy Markdown
Owner Author

@viper-review Thanks for the walkthrough. The High finding (stale predecessor links in Branching) and Medium finding (toString omitting rowHint) are tracked in fixes.md for implementation. The inline thread comments from all reviewers have been triaged.

@viper-review

viper-review Bot commented Apr 18, 2026

Copy link
Copy Markdown

Summary

No specific issues were identified in this incremental update.

Description

This update refines the evaluator’s branching and argument-generation logic across BranchAttemptPlanner, Branching, DummyArgumentGenerator, and PreservedPathState. The changes appear focused on follow-up fixes to path exploration behavior, branch attempt planning, and preservation of evaluator state during execution. The intent is to stabilize control-flow evaluation and improve correctness of generated dummy inputs and preserved branch state handling.

@e4c5
e4c5 merged commit e397cbf into master Apr 18, 2026
6 of 9 checks passed
@e4c5
e4c5 deleted the adk branch April 18, 2026 04:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL This PR changes 1000+ lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants