All problems

Lexicographic Revision Sorting Returns an Older Calibration Record

Level 2 · node · Data · Lexicographic sorting of numeric revisions selects an outdated record

Scenario

A fictional measurement-device service stores calibration results with integer revision numbers for each device. Revision 10 can follow revision 2, and the lookup API must return the record with the largest revision. The current service sorts revisions as strings, so it may incorrectly treat revision 9 as newer than revision 10. Inspect the repository, service, and controller flow.

Requirements

Return the calibration record with the greatest integer revision for each device. Preserve behavior for single-digit or single-record histories, keep devices isolated, reject unknown devices, and do not modify stored records. Do not use external packages.

Acceptance criteria

  • The highest numeric revision is selected.
  • A device with one revision returns that record.
  • Revisions from other devices are excluded.
  • Double-digit revision numbers use numeric ordering.
  • A device with no records returns an error.
  • Reading does not mutate stored revision records.