You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maka.apache.org by "garvit-arora (via GitHub)" <gi...@apache.org> on 2026/10/09 13:00:32 UTC

[PR] refactor(runtime-host): extract archive retention guards [maka]

garvit-arora opened a new pull request, #6033:
URL: https://github.com/apache/maka/pull/6033

   ## Summary
   
   - Extract the retention clock high-water guard into `ArchiveRetentionClockGuard`.
   - Extract the setting-change/in-flight-tick coordination into `ArchiveRetentionTickGate`.
   - Keep `HostArchiveRetentionCoordinator` behavior and persisted document unchanged.
   - Add direct tests for clock rollback/forward-jump decisions and for a setting change waiting on the active tick while blocking new ticks.
   
   This is step 1 from #5919. It does not implement idle archiving; that will be a separate follow-up PR after this refactor is reviewed.
   
   ## Validation
   
   - Biome check passed for all three changed files.
   - `git diff --check` passed.
   - The new helper test passed (2/2).
   - The Runtime Host build/full retention coordinator test could not complete locally because this worktree resolved stale workspace package outputs from the pre-existing checkout; CI should validate it against a clean install.
   
   Part of #5919.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] refactor(runtime-host): extract archive retention guards [maka]

Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han commented on code in PR #6033:
URL: https://github.com/apache/maka/pull/6033#discussion_r4230466254


##########
packages/runtime-host/src/server/archive-retention-coordinator.ts:
##########
@@ -470,72 +455,72 @@ export class HostArchiveRetentionCoordinator {
 
   async #set(input: StorageRetentionSetInput): Promise<OperationOutcome<'storage.retention.set'>> {
     if (this.#draining) return draining();
-    this.#changing += 1;
-    try {
-      // A family admitted under the current setting finishes, and is recorded,
-      // before the setting changes; nothing new is admitted meanwhile.
-      await this.#ticking?.catch(() => undefined);
-      return await this.#serialized(async () => {
-        const current = await this.#load();
-        if (current.revision !== input.expectedRevision) {
+    return this.#tickGate.runSettingChange(async () => {
+      try {
+        // A family admitted under the current setting finishes, and is recorded,

Review Comment:
   P3 nit: the wait this comment describes now happens in `ArchiveRetentionTickGate.runSettingChange` before this callback runs, so the comment belongs at the `runSettingChange` call.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] refactor(runtime-host): extract archive retention guards [maka]

Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han commented on code in PR #6033:
URL: https://github.com/apache/maka/pull/6033#discussion_r4236840733


##########
packages/runtime-host/src/server/host-maintenance-guards.ts:
##########
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+export type HostClockDecision =
+  | { readonly kind: 'ok'; readonly previous: number; readonly observedThisRun: boolean }
+  | { readonly kind: 'pause'; readonly previous: number; readonly observedThisRun: boolean }
+  | {
+      readonly kind: 'hold';
+      readonly since: number;
+      readonly previous: number;
+      readonly observedThisRun: boolean;
+    };
+
+/** Shares high-water and per-tick clock decisions across Host maintenance policies. */
+export class HostClockGuard {
+  #observedAt = 0;
+  #observedThisRun = false;
+
+  get observedAt(): number {
+    return this.#observedAt;
+  }
+
+  isBehind(now: number): boolean {
+    return now < this.#observedAt;
+  }
+
+  shouldClearHold(now: number, holdUntil?: number): boolean {
+    return holdUntil !== undefined && now >= holdUntil;
+  }
+
+  seed(...times: readonly number[]): void {
+    this.#observedAt = Math.max(this.#observedAt, ...times);
+  }
+
+  recordSettingTime(now: number): void {
+    this.#observedAt = Math.max(this.#observedAt, now);
+    this.#observedThisRun = true;
+  }
+
+  async decideTick(options: {
+    readonly now: number;
+    readonly gapThreshold: number;
+    readonly checkBackwards: boolean;
+    readonly readLatestSessionMetadataTime: () => Promise<number | undefined>;
+  }): Promise<HostClockDecision> {
+    const previous = this.#observedAt;
+    const observedThisRun = this.#observedThisRun;
+    this.#observedAt = Math.max(previous, options.now);
+    this.#observedThisRun = true;
+    const since = observedThisRun

Review Comment:
   P3: the rationale that used to sit in `#tick` was dropped in the move. It explained that a running Host measures from what it saw, while a fresh process measures from the persisted floor and the newest metadata time, with one MAX query per process. Consider restoring it here, since this is now the only place the rule lives.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] refactor(runtime-host): extract archive retention guards [maka]

Posted by "garvit-arora (via GitHub)" <gi...@apache.org>.
garvit-arora commented on PR #6033:
URL: https://github.com/apache/maka/pull/6033#issuecomment-6081397362

   @liugddx The step-1 refactor PR is ready for review. I requested a formal reviewer, but GitHub denied `RequestReviewsByLogin` for my account; could you take a look when available?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] refactor(runtime-host): extract archive retention guards [maka]

Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han merged PR #6033:
URL: https://github.com/apache/maka/pull/6033


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] refactor(runtime-host): extract archive retention guards [maka]

Posted by "garvit-arora (via GitHub)" <gi...@apache.org>.
garvit-arora commented on PR #6033:
URL: https://github.com/apache/maka/pull/6033#issuecomment-6116298606

   @liugddx When you have a moment, could you please check your email for my contact message? Thank you.
   
   ---
   Drafted-by: Codex (GPT-6) (no human review before posting)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org