bisector: Add max age to search

Bug: b/401921575
Change-Id: I47179a56dffb498f77f109f35179403abbd1fb0f
Reviewed-on: https://pigweed-review.googlesource.com/c/infra/recipes/+/276713
Pigweed-Auto-Submit: Rob Mohr <mohrr@google.com>
Reviewed-by: Erik Gilling <konkers@google.com>
Presubmit-Verified: CQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com>
Lint: Lint 🤖 <android-build-ayeaye@system.gserviceaccount.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed-service-accounts.iam.gserviceaccount.com>
diff --git a/recipes/bisector.proto b/recipes/bisector.proto
index ced7e79..8bf3cba 100644
--- a/recipes/bisector.proto
+++ b/recipes/bisector.proto
@@ -32,4 +32,7 @@
 
   // Number of past builds to check. Defaults to 15.
   int32 num_builds = 5;
+
+  // Maximum age of builds to check. Defaults to seven days.
+  int32 max_age_days = 6;
 }
diff --git a/recipes/bisector.py b/recipes/bisector.py
index e320181..e61d5f7 100644
--- a/recipes/bisector.py
+++ b/recipes/bisector.py
@@ -39,6 +39,7 @@
 
 import collections
 import dataclasses
+import datetime
 import fnmatch
 import json
 from typing import TYPE_CHECKING
@@ -114,6 +115,7 @@
 
 def RunSteps(api: recipe_api.RecipeApi, props: InputProperties):
     props.dry_run = props.dry_run or api.buildbucket_util.is_tryjob
+    props.max_age_days = props.max_age_days or 7
 
     bb_cfg: bb_pb.BuildbucketCfg = api.luci_config.buildbucket()
 
@@ -177,7 +179,10 @@
                     api.time.sleep(0.5)
 
                     status: BuilderStatus = api.builder_status.retrieve(
-                        bucket=bucket.name, builder=builder.name, n=num_builds
+                        bucket=bucket.name,
+                        builder=builder.name,
+                        n=num_builds,
+                        max_age=datetime.timedelta(days=props.max_age_days),
                     )
 
                     # If the builder hasn't recently passed, we don't have a