fix(self-operated): remove business collection deadline limits

This commit is contained in:
2026-10-13 21:39:51 +08:00
parent 242a76221e
commit f1fb5662ca
12 changed files with 150 additions and 114 deletions
@@ -7,7 +7,7 @@ import java.net.URI;
import java.time.Duration;
import java.time.Instant;
/** An operator-attested exclusive window; it is not a distributed account lock. */
/** Exclusive grant identity; externalExclusiveUntil bounds VALIDATION only, not BUSINESS. */
@ConfigurationProperties(prefix = "baiyue.integration.lingxing-wms.egress")
public record LingxingEgressProperties(@DefaultValue("OFF") CollectionMode collectionMode,
@DefaultValue("test") String environmentLabel, String sourceAccount, String externalExclusiveGrantId,
@@ -11,7 +11,7 @@ import java.time.Instant;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
/** Local serialization supplements, never replaces, the externally attested window and durable budget. */
/** Local serialization supplements the exclusive grant and durable account protection. */
@Component
public final class LingxingEgressGate {
private static final Logger log = LoggerFactory.getLogger(LingxingEgressGate.class);
@@ -62,7 +62,7 @@ public final class LingxingEgressGate {
|| !hash.equals(permit.requestHash()) || permit.allowedAttempts() != 1 || !permit.exclusiveConfirmed()
|| !permit.budgetConsumed() || permit.expiresAt() == null || !clock.instant().isBefore(permit.expiresAt())
|| permit.expiresAt().isAfter(clock.instant().plusSeconds(30))
|| (!continuousBusiness() && permit.expiresAt().isAfter(properties.externalExclusiveUntil()))) {
|| (!business() && permit.expiresAt().isAfter(properties.externalExclusiveUntil()))) {
recoverableRatePause = false; paused = true; throw failure("BUDGET_PERMIT_INVALID");
}
// A new persisted permit proves the coordinator accepted the account's cooldown/budget/root state.
@@ -108,11 +108,13 @@ public final class LingxingEgressGate {
|| !context.sourceAccount().equals(properties.sourceAccount())) throw failure("EGRESS_CONTEXT_INVALID");
if (properties.externalExclusiveGrantId() == null || properties.externalExclusiveGrantId().isBlank()
|| !properties.externalExclusiveGrantId().equals(context.exclusiveGrantId())
|| (!continuousBusiness() && (properties.externalExclusiveUntil() == null || !clock.instant().isBefore(properties.externalExclusiveUntil())))
|| (!business() && (properties.externalExclusiveUntil() == null || !clock.instant().isBefore(properties.externalExclusiveUntil())))
|| properties.budgetAuthorityBaseUri() == null) throw failure("EXCLUSIVE_WINDOW_UNCONFIRMED");
}
private boolean continuousBusiness() {
return properties.collectionMode() == CollectionMode.BUSINESS && properties.continuousBusinessCollectionEnabled();
private boolean business() {
// The account authority validates the original task identity, including manual roots.
// BUSINESS has no operator session cutoff; each individual permit remains finite.
return properties.collectionMode() == CollectionMode.BUSINESS;
}
private static boolean identifier(String value, int maximum) {
return value != null && value.length() <= maximum && value.matches("[A-Za-z0-9][A-Za-z0-9._:-]*");