Skip to content

fix(sight): replace hand-rolled new_id with uuid v4#830

Open
jfeng18 wants to merge 1 commit into
alibaba:mainfrom
jfeng18:fix/interruption-event-api
Open

fix(sight): replace hand-rolled new_id with uuid v4#830
jfeng18 wants to merge 1 commit into
alibaba:mainfrom
jfeng18:fix/interruption-event-api

Conversation

@jfeng18

@jfeng18 jfeng18 commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Replace new_id() (timestamp XOR stack address, zero entropy) with uuid::Uuid::new_v4() (122-bit CSPRNG)
  • Add assert_ne!(id1, id2) to test_new_id_uniqueness (previously only checked format, never asserted uniqueness)
  • Fix rustfmt on interruption/types.rs

Details

The previous new_id() generated 32-char hex IDs using nanosecond timestamp XOR'd with a stack variable address. This provided zero actual entropy — the stack address is deterministic within the same thread/call depth, and the second half was the raw timestamp. The doc comment on InterruptionEvent.interruption_id already claimed "UUID v4 hex, 32 chars" but the implementation was not UUID v4.

uuid is already a transitive dependency (via moka, debugid, llm-tokenizer) so this adds zero compile cost — only activates the v4 feature for CSPRNG-based ID generation.

Test plan

  • Local 541/541 tests pass
  • ECS 541/541 tests pass
  • test_new_id_uniqueness now asserts id1 != id2
  • Output format unchanged (32 lowercase hex chars)
  • rustfmt clean on interruption/types.rs

🤖 Generated with Claude Code

The previous new_id() used nanosecond timestamp XOR stack address,
providing zero actual entropy. The doc comment claimed "UUID v4 hex"
but the implementation was not UUID v4. The uniqueness test never
asserted id1 != id2.

Replace with uuid::Uuid::new_v4() (already a transitive dep via
moka/debugid/llm-tokenizer) and add assert_ne! to the test.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jfeng18 jfeng18 requested a review from chengshuyi as a code owner June 10, 2026 15:10
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