Skip to content

refactor(common): Lombok @Getter/@Setter for TaskDef and WorkflowDef, PK-based equals/hashCode#1154

Open
v1r3n wants to merge 3 commits into
mainfrom
refactor/lombok-taskdef-workflowdef-pk
Open

refactor(common): Lombok @Getter/@Setter for TaskDef and WorkflowDef, PK-based equals/hashCode#1154
v1r3n wants to merge 3 commits into
mainfrom
refactor/lombok-taskdef-workflowdef-pk

Conversation

@v1r3n
Copy link
Copy Markdown
Collaborator

@v1r3n v1r3n commented Jun 6, 2026

Summary

  • Replace ~400 lines of hand-written getters/setters in TaskDef and WorkflowDef with Lombok @Getter/@Setter at the class level, keeping all custom logic intact
  • equals/hashCode on both classes now key exclusively on the primary key (name + version) — written as explicit methods for readability
  • TaskDef.getVersion() coalesces null → 1, so unversioned records and version=1 records are always the same PK
  • Add version and metadata fields to TaskDef with @ProtoField annotations; wire both into AbstractProtoMapper (proto generation completes the mapping that was previously incomplete)
  • Extend schemas/TaskDef.json and schemas/WorkflowDef.json to cover all Java fields (previously missing: version, metadata, maxRetryDelaySeconds, backoffJitterMs, taskStatusListenerEnabled in TaskDef; RateLimitConfig.policy in WorkflowDef)

What was preserved (not replaced by Lombok)

Class Kept manually Reason
TaskDef getVersion(), getRateLimitPerFrequency(), getRateLimitFrequencyInSeconds(), concurrencyLimit() Null-coalescing defaults
TaskDef equals, hashCode, toString PK semantics + name-only toString
WorkflowDef equals, hashCode, toString PK semantics + full-field toString
WorkflowDef key(), getKey(), containsType(), getNextTask(), getTaskByRefName(), collectTasks() Business logic

Tests

TaskDefTest — 32 tests covering: default field values, version null→1 defaulting, equals/hashCode (reflexive, symmetric, null, different class, same PK with differing fields, different name/version, hashCode consistency), HashSet dedup, null-coalescing getters, all @Min/@NotEmpty/timeout constraint validations, and edge cases.

WorkflowDefValidatorTest — 16 new tests added alongside existing validation tests: default values, equals/hashCode, HashSet dedup, key()/getKey() correctness, toString content.

Test plan

  • ./gradlew :conductor-common:test — all 32 TaskDef + 16 WorkflowDef new tests pass
  • ./gradlew :conductor-grpc:compileJava — proto mapper compiles cleanly
  • Verify TaskDef with no version set equals one with version=1 explicitly
  • Verify two TaskDefs with the same name+version but different retryCount/ownerEmail are considered equal (PK only)

🤖 Generated with Claude Code

… PK-based equals/hashCode

Replace hand-written getters/setters in TaskDef and WorkflowDef with Lombok
@Getter/@Setter, reducing boilerplate by ~400 lines while preserving all
custom logic (null-coalescing getters, business methods, toString).

equals/hashCode keyed on PK (name + version) for both classes. TaskDef.getVersion()
defaults null to 1, so unversioned and version=1 records are treated as the same PK.

Also adds new TaskDef fields (version, metadata) with @protofield annotations,
wires them into AbstractProtoMapper, and extends both JSON schemas to cover all fields.

Tests: comprehensive coverage of equals/hashCode, version defaulting, null-coalescing
getters, all validation constraints, and edge cases for both classes.
@v1r3n v1r3n force-pushed the refactor/lombok-taskdef-workflowdef-pk branch from 1a8b442 to 1894cb3 Compare June 6, 2026 16:57
v1r3n added 2 commits June 6, 2026 10:39
…oto Value mapping

ProtoMapper.toProto(Object) only accepted Double, so any Integer/Long/Float/
BigDecimal/BigInteger in a Map<String,Object> field (inputTemplate, variables,
outputParameters, and the newly added metadata/data) threw ClassCastException.
Jackson deserializes JSON integers in generic maps as Integer/Long, so this was
reachable whenever such a definition was fetched over gRPC.

- Accept any Number, widening to double (protobuf Struct only has number_value);
  precision loss beyond 2^53 is an inherent Struct limitation, now documented.
- Coerce map keys via String.valueOf so non-String keys (Map<Integer,?>) and a
  stray null key serialize instead of throwing CCE / NPE at putFields.

Adds a full value-converter test matrix (numeric types, nesting, empty
containers, mixed lists, key coercion, rejection of non-JSON types), which was
previously entirely uncovered.
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