You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maka.apache.org by as...@apache.org on 2026/10/09 12:47:53 UTC

(maka) branch main updated: test(runtime-host): pin the settlement coverage window to the usage window (#6023)

This is an automated email from the ASF dual-hosted git repository.

Astro-Han pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/maka.git


The following commit(s) were added to refs/heads/main by this push:
     new 6f8fd706ac test(runtime-host): pin the settlement coverage window to the usage window (#6023)
6f8fd706ac is described below

commit 6f8fd706ac5a832a5a398371b9c1d59a756ed0d1
Author: 小七 <gg...@gmail.com>
AuthorDate: Fri Oct 9 20:47:48 2026 +0800

    test(runtime-host): pin the settlement coverage window to the usage window (#6023)
    
    Follow-up to #5890 (merged): the runner passes the same startedAt/settledAt
    window to the completeness check and to the usage summary, and nothing
    asserted it - the review noted a later edit could quietly separate the two
    and re-open the delegated-Session undercount. The coverage stub now records
    its calls and the residencies test asserts it received exactly the window
    the usage summary read (100, 200 with the harness clock). Swapping the
    arguments in the runner turns the assertion red.
    
    Implements the non-blocking suggestion from the #5890 review.
    
    Generated-by: GLM-5.3-Flash (ZCode)
---
 .../src/__tests__/hosted-execution-runner.test.ts  | 27 ++++++++++++++++------
 1 file changed, 20 insertions(+), 7 deletions(-)

diff --git a/packages/runtime-host/src/__tests__/hosted-execution-runner.test.ts b/packages/runtime-host/src/__tests__/hosted-execution-runner.test.ts
index 40624dc78c..0ca619095b 100644
--- a/packages/runtime-host/src/__tests__/hosted-execution-runner.test.ts
+++ b/packages/runtime-host/src/__tests__/hosted-execution-runner.test.ts
@@ -26,6 +26,7 @@ import { HostHostedExecutionRunner } from '../server/hosted-execution-runner.js'
 test('hosted execution reads usage only after execution residencies settle', async () => {
   const residency = deferred();
   let usageRead = false;
+  const coverage = settlementCoverage();
   const runner = new HostHostedExecutionRunner({
     handlers: handlers({
       usage: () => {
@@ -33,7 +34,7 @@ test('hosted execution reads usage only after execution residencies settle', asy
         return usageSummary();
       },
     }),
-    runSettlementCoverage: settlementCoverage(),
+    runSettlementCoverage: coverage,
     context: context(),
     requestDrain: () => {},
     waitForExecutionResidencies: () => residency.promise,
@@ -61,6 +62,10 @@ test('hosted execution reads usage only after execution residencies settle', asy
     costUsd: 0.25,
   });
   assert.equal(usageRead, true);
+  // The completeness check must read the exact window the usage summary read
+  // (#5890 review): separating the two silently re-opens the delegated-Session
+  // undercount that window scoping closed.
+  assert.deepEqual(coverage.calls, [[100, 200]]);
 });
 
 test('a run-owned unsettled attempt refuses settlement with its fixed safe cause', async () => {
@@ -376,16 +381,24 @@ function usageSummary() {
 
 /**
  * The run-scoped incompleteness check's stub: a hosted execution owns no
- * usage-unknown rows unless the test says otherwise.
+ * usage-unknown rows unless the test says otherwise. Calls are recorded so a
+ * test can pin the window the runner passed in.
  */
 function settlementCoverage(
   overrides: { usageMissingAttempts?: number; usagePartialAttempts?: number } = {},
 ) {
-  return async (_from: number, _to: number) => ({
-    usageMissingAttempts: 0,
-    usagePartialAttempts: 0,
-    ...overrides,
-  });
+  const calls: Array<[number, number]> = [];
+  return Object.assign(
+    async (from: number, to: number) => {
+      calls.push([from, to]);
+      return {
+        usageMissingAttempts: 0,
+        usagePartialAttempts: 0,
+        ...overrides,
+      };
+    },
+    { calls },
+  );
 }
 
 function emptySkillInvocation() {


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