Skip to content

fix(sensor): age-skip old legacy DSH sessions instead of reporting drift - #215

Open
rudycelekli wants to merge 1 commit into
uber:mainfrom
rudycelekli:fix/sensor-dsh-old-legacy-session-not-drift
Open

rudycelekli wants to merge 1 commit into
uber:mainfrom
rudycelekli:fix/sensor-dsh-old-legacy-session-not-drift

Conversation

@rudycelekli

@rudycelekli rudycelekli commented Oct 19, 2026 •

Copy link
Copy Markdown

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Related issue: N/A (found by reading the code; reproduced on main at 6b33dff)

What changed?
Pass the cutoff into _select_session_generations; non-v3 generations older than the cutoff are counted as file_age_skipped (like old v3 files) instead of unsupported_schema. Recent legacy sessions and max_age_days <= 0 keep the old behaviour.

Why?
DshParser.parse_all calls _select_session_generations() (Sensor/adr_sensor/parsers/dsh_parser.py:48, 96-101) before the lookback filter, and that method records unsupported_schema for every directory whose newest file is not v3 (e.g. session.v2.jsonl), regardless of age. The age filter at :53 only ever sees v3 files. Result: a legacy session finished months ago is reported as unsupported_schema on every run, which health_record turns into status "partial" with suspected_schema_drift: true.

How did you test it?

  • Reproduction: new tests/test_dsh_parser.py::test_old_legacy_generation_is_age_skipped_not_reported_as_drift (v2 session with mtime 1970 -> expects {'file_age_skipped': 1}; plus a recent v2 session -> still unsupported_schema). main parser: FAILED ({'unsupported_schema': 1} == {'file_age_skipped': 1}); branch: passed. Existing test_future_or_legacy_generation_is_not_parsed_as_v3 still passes.
  • Test suite: Sensor pytest tests/ -q (py3.14) 609 passed; ruff clean.
  • Not tested: real DSH installs (none locally). Python 3.9.6: parser test files 245 passed.

Potential risks
The change only affects the input described above; other paths go through the same code as before, and the component's existing tests pass.

DshParser checked the session generation before the lookback window, so
every legacy (pre-v3) session directory was counted as unsupported_schema
on every run, however old it was. That marked DSH health "partial" with
suspected_schema_drift for anyone with finished legacy sessions. Legacy
generations older than the lookback window are now counted as
file_age_skipped; recent ones are still reported as unsupported.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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