Skip to content

Agents - snapshot retention deletes newer numbered snapshots before older ones #235

Description

@mlguys

Area

Agents & chat

What happened

Session snapshot retention deletes numerically newer snapshots while preserving
older ones because numbered snapshot filenames are sorted lexicographically.

At tick 158 with a 100-snapshot cap, the retained tick ranges were 2-9,
16-99, and 151-158. The expected retained range was 59-158.

The complete sanitized observation is attached as
condor-snapshot-retention-evidence.txt.

Expected

Retention should keep the newest 100 numeric ticks and delete the oldest numeric
ticks, regardless of how many digits appear in the filename.

Likely source path

A minimal fix is to sort valid snapshot paths by the parsed integer tick before
pruning. A regression test should cross the filename-width boundary: with ticks
1 through 102 and a cap of 100, cleanup should retain exactly ticks 3 through
102. Existing snapshot listing tests are in
tests/test_sessions_index_snapshots.py; retention cleanup currently lacks this
boundary case.

Steps to reproduce

  1. Create an isolated temporary session snapshots directory.
  2. Create snapshot_1.md through snapshot_102.md.
  3. Invoke JournalManager._cleanup_old_snapshots().
  4. Observe that lexicographic cleanup removes snapshot_1.md and
    snapshot_10.md.
  5. The correct numeric cleanup would remove snapshot_1.md and
    snapshot_2.md.

Environment

Observed in a private downstream checkout; no private branch or source is
published with this report. The same cleanup implementation was independently
confirmed in public upstream Condor commit
a3997a2b.

Logs

Attach: condor-snapshot-retention-evidence.txt

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions