Problem
RedisUsageStorage.fetchUsageRecords가 Redis sorted set에서 record를 읽을 때 score에 저장된 timestamp를 복원하지 않고 new Date()를 넣습니다. 과거 사용량 조회가 모두 조회 시각으로 보일 수 있어 감사, 청구, 분석 결과가 왜곡됩니다.
Evidence
packages/metering-core/src/libs/RedisUsageStorage.ts:177-193는 records를 매핑하면서 timestamp: new Date()를 설정하고 Score에서 복원해야 하지만 단순화라는 주석을 남깁니다.
packages/metering-core/src/libs/RedisUsageStorage.ts:227-239의 readUsageMembers는 zrangebyscore member만 반환하고 score를 함께 읽지 않습니다.
- Usage record 조회 API는 timestamp를 포함하는 record를 반환하므로 조회 시각으로 대체하면 도메인 의미가 깨집니다.
Desired Outcome
Redis에 저장된 usage record의 timestamp는 기록 시각을 유지해야 하며, 조회 시각으로 덮이지 않아야 합니다.
Suggested Approach
ZRANGEBYSCORE ... WITHSCORES 또는 equivalent API로 score를 함께 읽습니다.
- score를
Date로 복원하고, member 내부 timestamp가 있다면 우선순위를 명확히 합니다.
- 기존 데이터 migration/compatibility가 필요한지 검토합니다.
Acceptance Criteria
fetchUsageRecords가 record original timestamp를 반환합니다.
- 테스트가 서로 다른 기록 시각의 records를 조회해 timestamp 순서와 값을 검증합니다.
new Date() fallback은 명시적 오류/compatibility 경로로 제한됩니다.
Validation
pnpm test --filter=@croco/metering-core
- RedisUsageStorage timestamp restoration regression test
Problem
RedisUsageStorage.fetchUsageRecords가 Redis sorted set에서 record를 읽을 때 score에 저장된 timestamp를 복원하지 않고new Date()를 넣습니다. 과거 사용량 조회가 모두 조회 시각으로 보일 수 있어 감사, 청구, 분석 결과가 왜곡됩니다.Evidence
packages/metering-core/src/libs/RedisUsageStorage.ts:177-193는 records를 매핑하면서timestamp: new Date()를 설정하고Score에서 복원해야 하지만 단순화라는 주석을 남깁니다.packages/metering-core/src/libs/RedisUsageStorage.ts:227-239의readUsageMembers는zrangebyscoremember만 반환하고 score를 함께 읽지 않습니다.Desired Outcome
Redis에 저장된 usage record의 timestamp는 기록 시각을 유지해야 하며, 조회 시각으로 덮이지 않아야 합니다.
Suggested Approach
ZRANGEBYSCORE ... WITHSCORES또는 equivalent API로 score를 함께 읽습니다.Date로 복원하고, member 내부 timestamp가 있다면 우선순위를 명확히 합니다.Acceptance Criteria
fetchUsageRecords가 record original timestamp를 반환합니다.new Date()fallback은 명시적 오류/compatibility 경로로 제한됩니다.Validation
pnpm test --filter=@croco/metering-core