[rubber-stamper] Add host-level clean revert time_window.

Bug: 1111958
Change-Id: Ib63ce96a42bda8b45c8d921072ea66ff93b2f132
Reviewed-on: https://chromium-review.googlesource.com/c/infra/infra/+/2607746
Commit-Queue: Xinyu Yang <xinyuoffline@google.com>
Reviewed-by: Jason Clinton <jclinton@chromium.org>
Reviewed-by: Yulan Lin <yulanlin@google.com>
Cr-Commit-Position: refs/heads/master@{#37411}
diff --git a/go/src/infra/appengine/rubber-stamper/config/config.pb.go b/go/src/infra/appengine/rubber-stamper/config/config.pb.go
index d438a4f..7c0ba2b 100644
--- a/go/src/infra/appengine/rubber-stamper/config/config.pb.go
+++ b/go/src/infra/appengine/rubber-stamper/config/config.pb.go
@@ -34,6 +34,9 @@
 	// hosts (e.g. "chromium" or "chrome-internal"), values are corresponding
 	// configs.
 	HostConfigs map[string]*HostConfig `protobuf:"bytes,1,rep,name=host_configs,json=hostConfigs,proto3" json:"host_configs,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
+	// A global default time window for clean reverts and cherry picks. The
+	// format is the same as that of CleanRevertPattern.time_window.
+	DefaultTimeWindow string `protobuf:"bytes,2,opt,name=default_time_window,json=defaultTimeWindow,proto3" json:"default_time_window,omitempty"`
 }
 
 func (x *Config) Reset() {
@@ -75,6 +78,13 @@
 	return nil
 }
 
+func (x *Config) GetDefaultTimeWindow() string {
+	if x != nil {
+		return x.DefaultTimeWindow
+	}
+	return ""
+}
+
 // HostConfig describes the config to be used for a Gerrit host.
 type HostConfig struct {
 	state         protoimpl.MessageState
@@ -84,6 +94,11 @@
 	// A map stores config for repositories, where keys are names of repos (e.g.
 	// "chromium/src", "infra/infra") and values are corresponding configs.
 	RepoConfigs map[string]*RepoConfig `protobuf:"bytes,1,rep,name=repo_configs,json=repoConfigs,proto3" json:"repo_configs,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
+	// The default valid time window for clean reverts. This time window is
+	// applied at a host-level and the time window configured in repo-level
+	// configs will override this one. The format is the same as that of
+	// CleanRevertPattern.time_window.
+	CleanRevertTimeWindow string `protobuf:"bytes,2,opt,name=clean_revert_time_window,json=cleanRevertTimeWindow,proto3" json:"clean_revert_time_window,omitempty"`
 }
 
 func (x *HostConfig) Reset() {
@@ -125,6 +140,13 @@
 	return nil
 }
 
+func (x *HostConfig) GetCleanRevertTimeWindow() string {
+	if x != nil {
+		return x.CleanRevertTimeWindow
+	}
+	return ""
+}
+
 // RepoConfig describes the config to be used for a Gerrit repository.
 type RepoConfig struct {
 	state         protoimpl.MessageState
@@ -300,56 +322,63 @@
 	0x65, 0x2f, 0x72, 0x75, 0x62, 0x62, 0x65, 0x72, 0x2d, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x65, 0x72,
 	0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70,
 	0x72, 0x6f, 0x74, 0x6f, 0x12, 0x15, 0x72, 0x75, 0x62, 0x62, 0x65, 0x72, 0x5f, 0x73, 0x74, 0x61,
-	0x6d, 0x70, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x22, 0xbe, 0x01, 0x0a, 0x06,
+	0x6d, 0x70, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x22, 0xee, 0x01, 0x0a, 0x06,
 	0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x51, 0x0a, 0x0c, 0x68, 0x6f, 0x73, 0x74, 0x5f, 0x63,
 	0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2e, 0x2e, 0x72,
 	0x75, 0x62, 0x62, 0x65, 0x72, 0x5f, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x65, 0x72, 0x2e, 0x63, 0x6f,
 	0x6e, 0x66, 0x69, 0x67, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x48, 0x6f, 0x73, 0x74,
 	0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0b, 0x68, 0x6f,
-	0x73, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x1a, 0x61, 0x0a, 0x10, 0x48, 0x6f, 0x73,
+	0x73, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x12, 0x2e, 0x0a, 0x13, 0x64, 0x65, 0x66,
+	0x61, 0x75, 0x6c, 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x5f, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77,
+	0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x54,
+	0x69, 0x6d, 0x65, 0x57, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x1a, 0x61, 0x0a, 0x10, 0x48, 0x6f, 0x73,
 	0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a,
 	0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12,
 	0x37, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21,
 	0x2e, 0x72, 0x75, 0x62, 0x62, 0x65, 0x72, 0x5f, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x65, 0x72, 0x2e,
 	0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x48, 0x6f, 0x73, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69,
-	0x67, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0xc6, 0x01, 0x0a,
+	0x67, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0xff, 0x01, 0x0a,
 	0x0a, 0x48, 0x6f, 0x73, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x55, 0x0a, 0x0c, 0x72,
 	0x65, 0x70, 0x6f, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28,
 	0x0b, 0x32, 0x32, 0x2e, 0x72, 0x75, 0x62, 0x62, 0x65, 0x72, 0x5f, 0x73, 0x74, 0x61, 0x6d, 0x70,
 	0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x48, 0x6f, 0x73, 0x74, 0x43, 0x6f,
 	0x6e, 0x66, 0x69, 0x67, 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73,
 	0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0b, 0x72, 0x65, 0x70, 0x6f, 0x43, 0x6f, 0x6e, 0x66, 0x69,
-	0x67, 0x73, 0x1a, 0x61, 0x0a, 0x10, 0x52, 0x65, 0x70, 0x6f, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67,
-	0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20,
-	0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x37, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75,
-	0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x72, 0x75, 0x62, 0x62, 0x65, 0x72,
-	0x5f, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e,
-	0x52, 0x65, 0x70, 0x6f, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75,
-	0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0xc3, 0x01, 0x0a, 0x0a, 0x52, 0x65, 0x70, 0x6f, 0x43, 0x6f,
-	0x6e, 0x66, 0x69, 0x67, 0x12, 0x58, 0x0a, 0x13, 0x62, 0x65, 0x6e, 0x69, 0x67, 0x6e, 0x5f, 0x66,
-	0x69, 0x6c, 0x65, 0x5f, 0x70, 0x61, 0x74, 0x74, 0x65, 0x72, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28,
-	0x0b, 0x32, 0x28, 0x2e, 0x72, 0x75, 0x62, 0x62, 0x65, 0x72, 0x5f, 0x73, 0x74, 0x61, 0x6d, 0x70,
-	0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x42, 0x65, 0x6e, 0x69, 0x67, 0x6e,
-	0x46, 0x69, 0x6c, 0x65, 0x50, 0x61, 0x74, 0x74, 0x65, 0x72, 0x6e, 0x52, 0x11, 0x62, 0x65, 0x6e,
-	0x69, 0x67, 0x6e, 0x46, 0x69, 0x6c, 0x65, 0x50, 0x61, 0x74, 0x74, 0x65, 0x72, 0x6e, 0x12, 0x5b,
-	0x0a, 0x14, 0x63, 0x6c, 0x65, 0x61, 0x6e, 0x5f, 0x72, 0x65, 0x76, 0x65, 0x72, 0x74, 0x5f, 0x70,
-	0x61, 0x74, 0x74, 0x65, 0x72, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x72,
-	0x75, 0x62, 0x62, 0x65, 0x72, 0x5f, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x65, 0x72, 0x2e, 0x63, 0x6f,
-	0x6e, 0x66, 0x69, 0x67, 0x2e, 0x43, 0x6c, 0x65, 0x61, 0x6e, 0x52, 0x65, 0x76, 0x65, 0x72, 0x74,
-	0x50, 0x61, 0x74, 0x74, 0x65, 0x72, 0x6e, 0x52, 0x12, 0x63, 0x6c, 0x65, 0x61, 0x6e, 0x52, 0x65,
-	0x76, 0x65, 0x72, 0x74, 0x50, 0x61, 0x74, 0x74, 0x65, 0x72, 0x6e, 0x22, 0x2f, 0x0a, 0x11, 0x42,
-	0x65, 0x6e, 0x69, 0x67, 0x6e, 0x46, 0x69, 0x6c, 0x65, 0x50, 0x61, 0x74, 0x74, 0x65, 0x72, 0x6e,
-	0x12, 0x14, 0x0a, 0x05, 0x70, 0x61, 0x74, 0x68, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52,
-	0x05, 0x70, 0x61, 0x74, 0x68, 0x73, 0x4a, 0x04, 0x08, 0x01, 0x10, 0x02, 0x22, 0x5c, 0x0a, 0x12,
-	0x43, 0x6c, 0x65, 0x61, 0x6e, 0x52, 0x65, 0x76, 0x65, 0x72, 0x74, 0x50, 0x61, 0x74, 0x74, 0x65,
-	0x72, 0x6e, 0x12, 0x1f, 0x0a, 0x0b, 0x74, 0x69, 0x6d, 0x65, 0x5f, 0x77, 0x69, 0x6e, 0x64, 0x6f,
-	0x77, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x74, 0x69, 0x6d, 0x65, 0x57, 0x69, 0x6e,
-	0x64, 0x6f, 0x77, 0x12, 0x25, 0x0a, 0x0e, 0x65, 0x78, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x64, 0x5f,
-	0x70, 0x61, 0x74, 0x68, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0d, 0x65, 0x78, 0x63,
-	0x6c, 0x75, 0x64, 0x65, 0x64, 0x50, 0x61, 0x74, 0x68, 0x73, 0x42, 0x27, 0x5a, 0x25, 0x69, 0x6e,
-	0x66, 0x72, 0x61, 0x2f, 0x61, 0x70, 0x70, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x2f, 0x72, 0x75,
-	0x62, 0x62, 0x65, 0x72, 0x2d, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x65, 0x72, 0x2f, 0x63, 0x6f, 0x6e,
-	0x66, 0x69, 0x67, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+	0x67, 0x73, 0x12, 0x37, 0x0a, 0x18, 0x63, 0x6c, 0x65, 0x61, 0x6e, 0x5f, 0x72, 0x65, 0x76, 0x65,
+	0x72, 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x5f, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x18, 0x02,
+	0x20, 0x01, 0x28, 0x09, 0x52, 0x15, 0x63, 0x6c, 0x65, 0x61, 0x6e, 0x52, 0x65, 0x76, 0x65, 0x72,
+	0x74, 0x54, 0x69, 0x6d, 0x65, 0x57, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x1a, 0x61, 0x0a, 0x10, 0x52,
+	0x65, 0x70, 0x6f, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12,
+	0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65,
+	0x79, 0x12, 0x37, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b,
+	0x32, 0x21, 0x2e, 0x72, 0x75, 0x62, 0x62, 0x65, 0x72, 0x5f, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x65,
+	0x72, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x43, 0x6f, 0x6e,
+	0x66, 0x69, 0x67, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0xc3,
+	0x01, 0x0a, 0x0a, 0x52, 0x65, 0x70, 0x6f, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x58, 0x0a,
+	0x13, 0x62, 0x65, 0x6e, 0x69, 0x67, 0x6e, 0x5f, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x70, 0x61, 0x74,
+	0x74, 0x65, 0x72, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x72, 0x75, 0x62,
+	0x62, 0x65, 0x72, 0x5f, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6e, 0x66,
+	0x69, 0x67, 0x2e, 0x42, 0x65, 0x6e, 0x69, 0x67, 0x6e, 0x46, 0x69, 0x6c, 0x65, 0x50, 0x61, 0x74,
+	0x74, 0x65, 0x72, 0x6e, 0x52, 0x11, 0x62, 0x65, 0x6e, 0x69, 0x67, 0x6e, 0x46, 0x69, 0x6c, 0x65,
+	0x50, 0x61, 0x74, 0x74, 0x65, 0x72, 0x6e, 0x12, 0x5b, 0x0a, 0x14, 0x63, 0x6c, 0x65, 0x61, 0x6e,
+	0x5f, 0x72, 0x65, 0x76, 0x65, 0x72, 0x74, 0x5f, 0x70, 0x61, 0x74, 0x74, 0x65, 0x72, 0x6e, 0x18,
+	0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x72, 0x75, 0x62, 0x62, 0x65, 0x72, 0x5f, 0x73,
+	0x74, 0x61, 0x6d, 0x70, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x43, 0x6c,
+	0x65, 0x61, 0x6e, 0x52, 0x65, 0x76, 0x65, 0x72, 0x74, 0x50, 0x61, 0x74, 0x74, 0x65, 0x72, 0x6e,
+	0x52, 0x12, 0x63, 0x6c, 0x65, 0x61, 0x6e, 0x52, 0x65, 0x76, 0x65, 0x72, 0x74, 0x50, 0x61, 0x74,
+	0x74, 0x65, 0x72, 0x6e, 0x22, 0x2f, 0x0a, 0x11, 0x42, 0x65, 0x6e, 0x69, 0x67, 0x6e, 0x46, 0x69,
+	0x6c, 0x65, 0x50, 0x61, 0x74, 0x74, 0x65, 0x72, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x61, 0x74,
+	0x68, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x70, 0x61, 0x74, 0x68, 0x73, 0x4a,
+	0x04, 0x08, 0x01, 0x10, 0x02, 0x22, 0x5c, 0x0a, 0x12, 0x43, 0x6c, 0x65, 0x61, 0x6e, 0x52, 0x65,
+	0x76, 0x65, 0x72, 0x74, 0x50, 0x61, 0x74, 0x74, 0x65, 0x72, 0x6e, 0x12, 0x1f, 0x0a, 0x0b, 0x74,
+	0x69, 0x6d, 0x65, 0x5f, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
+	0x52, 0x0a, 0x74, 0x69, 0x6d, 0x65, 0x57, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x12, 0x25, 0x0a, 0x0e,
+	0x65, 0x78, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x64, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x73, 0x18, 0x02,
+	0x20, 0x03, 0x28, 0x09, 0x52, 0x0d, 0x65, 0x78, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x64, 0x50, 0x61,
+	0x74, 0x68, 0x73, 0x42, 0x27, 0x5a, 0x25, 0x69, 0x6e, 0x66, 0x72, 0x61, 0x2f, 0x61, 0x70, 0x70,
+	0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x2f, 0x72, 0x75, 0x62, 0x62, 0x65, 0x72, 0x2d, 0x73, 0x74,
+	0x61, 0x6d, 0x70, 0x65, 0x72, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x62, 0x06, 0x70, 0x72,
+	0x6f, 0x74, 0x6f, 0x33,
 }
 
 var (
diff --git a/go/src/infra/appengine/rubber-stamper/config/config.proto b/go/src/infra/appengine/rubber-stamper/config/config.proto
index 4077acd..daeb934 100644
--- a/go/src/infra/appengine/rubber-stamper/config/config.proto
+++ b/go/src/infra/appengine/rubber-stamper/config/config.proto
@@ -14,6 +14,9 @@
   // hosts (e.g. "chromium" or "chrome-internal"), values are corresponding
   // configs.
   map<string, HostConfig> host_configs = 1;
+  // A global default time window for clean reverts and cherry picks. The
+  // format is the same as that of CleanRevertPattern.time_window.
+  string default_time_window = 2;
 }
 
 // HostConfig describes the config to be used for a Gerrit host.
@@ -21,6 +24,11 @@
   // A map stores config for repositories, where keys are names of repos (e.g.
   // "chromium/src", "infra/infra") and values are corresponding configs.
   map<string, RepoConfig> repo_configs = 1;
+  // The default valid time window for clean reverts. This time window is
+  // applied at a host-level and the time window configured in repo-level
+  // configs will override this one. The format is the same as that of
+  // CleanRevertPattern.time_window.
+  string clean_revert_time_window = 2;
 }
 
 // RepoConfig describes the config to be used for a Gerrit repository.
diff --git a/go/src/infra/appengine/rubber-stamper/config/validate.go b/go/src/infra/appengine/rubber-stamper/config/validate.go
index 0f2931e..f0a078a 100644
--- a/go/src/infra/appengine/rubber-stamper/config/validate.go
+++ b/go/src/infra/appengine/rubber-stamper/config/validate.go
@@ -19,6 +19,12 @@
 		validateHostConfig(c, hostConfig)
 		c.Exit()
 	}
+
+	if cfg.DefaultTimeWindow != "" {
+		validateTimeWindow(c, cfg.DefaultTimeWindow)
+	} else {
+		c.Errorf("empty default_time_window")
+	}
 }
 
 func validateHostConfig(c *validation.Context, hostConfig *HostConfig) {
@@ -27,6 +33,10 @@
 		validateRepoConfig(c, repoConfig)
 		c.Exit()
 	}
+
+	if hostConfig.CleanRevertTimeWindow != "" {
+		validateTimeWindow(c, hostConfig.CleanRevertTimeWindow)
+	}
 }
 
 func validateRepoConfig(c *validation.Context, repoConfig *RepoConfig) {
@@ -39,10 +49,8 @@
 
 func validateCleanRevertPattern(c *validation.Context, cleanRevertPattern *CleanRevertPattern) {
 	tw := cleanRevertPattern.TimeWindow
-	unit := tw[len(tw)-1:]
-	_, err := strconv.Atoi(tw[:len(tw)-1])
-	if err != nil || !validTimeUnits[unit] {
-		c.Errorf("invalid time_window %s: %s", tw, err)
+	if tw != "" {
+		validateTimeWindow(c, tw)
 	}
 
 	for _, p := range cleanRevertPattern.ExcludedPaths {
@@ -56,3 +64,11 @@
 		}
 	}
 }
+
+func validateTimeWindow(c *validation.Context, tw string) {
+	unit := tw[len(tw)-1:]
+	_, err := strconv.Atoi(tw[:len(tw)-1])
+	if err != nil || !validTimeUnits[unit] {
+		c.Errorf("invalid time_window %s: %s", tw, err)
+	}
+}
diff --git a/go/src/infra/appengine/rubber-stamper/config/validate_test.go b/go/src/infra/appengine/rubber-stamper/config/validate_test.go
index fc22e37..65762fa 100644
--- a/go/src/infra/appengine/rubber-stamper/config/validate_test.go
+++ b/go/src/infra/appengine/rubber-stamper/config/validate_test.go
@@ -14,6 +14,7 @@
 )
 
 var sampleConfigStr = `
+	default_time_window: "7d"
 	host_configs {
 		key: "test-host"
 		value: {
@@ -56,6 +57,10 @@
 
 	Convey("validateConfig catches errors", t, func() {
 		cfg := createConfig()
+		Convey("empty default_time_window", func() {
+			cfg.DefaultTimeWindow = ""
+			So(validate(cfg), ShouldErrLike, "empty default_time_window")
+		})
 		Convey("validateCleanRevertPattern catches errors", func() {
 			crp := cfg.HostConfigs["test-host"].RepoConfigs["dummy"].CleanRevertPattern
 			Convey("invalid time window value", func() {