<commit_before><commit_msg>Add semgrep rule to catch non-determinism in FSM (#13725)<commit_after>rules:
  - id: "no-time-in-fsm"
    patterns:
      - pattern: time.Now()

      # Metric state is local to the server and therefore must use time.
      - pattern-not-inside: |
          defer metrics.MeasureSince(...)

      # The timetable's whole point is to roughly track timestamps for Raft log
      # indexes, so it must use time.
      - pattern-not-inside: |
          $N.timetable.Witness(...)
    message: |
      time.Now() should not be called from within the Server's FSM. Apply Raft
      log messages to the State Store must be deterministic so that each server
      contains exactly the same state. Since time drifts between nodes, it must
      be set before the Raft log message is applied so that all Raft members
      see the same timestamp.
    languages:
      - "go"
    severity: "WARNING"
    paths:
      include:
        - "nomad/fsm.*"
        - "nomad/state/state_store.*"
{'fraction_non_alphanumeric': 0.08673978065802593, 'fraction_numerical': 0.004985044865403789, 'mean_word_length': 2.3466666666666667, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3670054', 'n_tokens_mistral': 303, 'n_tokens_neox': 287, 'n_words': 113}