Ft/conditional prev val#14
Conversation
Review Summary by QodoReturn previous values from conditional counter operations WalkthroughsDescription• Return previous values from conditional counter operations • Update inc_if and set_if to return (new_value, old_value) tuples • Update batch operations to return (key, new, old) tuples • Modify instance-aware counter operations similarly for state tracking Diagramflowchart LR
A["Conditional Counter Methods"] -->|inc_if/set_if| B["Return new_value"]
A -->|inc_if/set_if| C["Return old_value"]
B --> D["(new_value, old_value)"]
C --> D
E["Batch Operations"] -->|inc_all_if/set_all_if| F["Return key"]
E -->|inc_all_if/set_all_if| G["Return new_value"]
E -->|inc_all_if/set_all_if| H["Return old_value"]
F --> I["(key, new, old)"]
G --> I
H --> I
File Changes1. src/counter/counter_trait.rs
|
Code Review by Qodo
|
| local current = tonumber(redis.call('HGET', container_key, key)) or 0 | ||
| if not compare_values(current, comparator, compare_against) then | ||
| return current | ||
| return {current, current} | ||
| end | ||
|
|
||
| return redis.call('HINCRBY', container_key, key, count) | ||
| return {tonumber(redis.call('HINCRBY', container_key, key, count)), current} |
There was a problem hiding this comment.
1. inc_lua returns no key 📘 Rule violation ≡ Correctness
The INC_LUA script returns only numeric values and does not echo the relevant key string, preventing safe key-addressed result mapping. This forces callers toward brittle positional alignment for batch operations.
Agent Prompt
## Issue description
`INC_LUA` does not echo the `key` in its return value, violating the key-echo requirement and preventing safe key-based association of results.
## Issue Context
Batch operations should be able to build results keyed by the returned key strings rather than relying on pipeline ordering.
## Fix Focus Areas
- src/counter/strict_counter.rs[35-42]
- src/counter/strict_counter.rs[292-313]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| let mut conn = self.connection_manager.clone(); | ||
| let mut map: HashMap<DistkitRedisKey, (i64, i64)> = HashMap::with_capacity(updates.len()); | ||
| let mut map: HashMap<DistkitRedisKey, (i64, i64, i64, i64)> = | ||
| HashMap::with_capacity(updates.len()); | ||
| let mut processed = 0; | ||
|
|
||
| while processed < updates.len() { |
There was a problem hiding this comment.
2. Batch set_on_instance drops duplicates 🐞 Bug ≡ Correctness
StrictInstanceAwareCounter::set_on_instance_if_batch also uses a HashMap keyed by DistkitRedisKey to store results, so duplicate keys overwrite earlier entries and the returned per-item new/old states are wrong for earlier duplicates.
Agent Prompt
### Issue description
`StrictInstanceAwareCounter::set_on_instance_if_batch` collapses duplicate keys by storing results in a `HashMap` and reconstructing outputs with `map.get(k)`.
### Issue Context
`execute_pipeline_with_script_retry` returns results aligned with the invocations pushed into the pipeline, which are created by iterating the chunk slice.
### Fix
Build the returned `Vec` by zipping each input update with its corresponding pipeline result (per chunk), preserving duplicates and per-item old/new state.
### Fix Focus Areas
- src/icounter/strict_instance_aware_counter.rs[1097-1178]
- src/common/mod.rs[20-54]
- src/icounter/mod.rs[526-563]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
No description provided.