Speaking personally, and not on behalf of Timeform, I suggest the answer would be "it depends". It depends on the type of horse, the time scale of its performance ratings, of whether the ratings are generally progressive or regressive, and so on.
That said, when writing the business rules for The Sportsman’s automated ratings database, which was attempting to ape some of what Timeform had been doing manually for decades previously, the default instructions were something like:
Maximum rating of last 5 runs in that code (AW Flat, AW Turf, hurdles, chases or bumpers) within timescale that was 12 months for Flat racing and two seasons for jumps ratings.
Which broadly agrees with the first of your suppositions.
Thereafter, it was left to manual handicappers to fine-tune the ratings as they saw fit. Which takes us back to the "it depends" scenario mentioned above and which has more to do with the contextualising of your second supposition.
In annual Timeform publications, the rating is customarily the maximum figure of the period under review. On a day-to-day basis, it tends to be more of a judgement call as to how long a rating is held on to, though the majority of master ratings will have been prompted from the horse’s last six Timeform performance ratings (which are listed in the racecards).
Views on ease of victory, disadvantage of draw, likely finishing position if had not fallen, etc also feed into the process.