Autonomous development for real products. Governed agents build from specs you approve, follow the rules you set, and nothing merges until another agent proves it. Your decisions, judgement and taste are the bar that work must clear. Declare your vision and let agents build it.
JavaScript agentic-codingai-agentsai-governanceautonomous-agentsclaude-codeclicode-reviewcodexcoding-agentsdeveloper-toolsgit-hooksllmlocal-firstmulti-agentsoftware-factoryspec-driven-developmentverificationvibe-coding
fix(relay): ignore future client samples in monitor status [H5,H17]
Corey Olsonacc364366f52
diff --git a/src/relay-canary-health.js b/src/relay-canary-health.jsindex 23abcf7d..d94e41ab 100644--- a/src/relay-canary-health.js+++ b/src/relay-canary-health.js@@ -34,10 +34,11 @@ function historyAt(file) {/** Format only observations this client made, with a real locally queued move count. */function projection(history, queued, now) {const monitor = history?.samples?.at(-1);- const client = history?.client?.sample;+ const observed = history?.client?.sample;+ const client = observed && Date.parse(observed.at) <= now ? observed : undefined;const last = history?.alertSince ? monitor : (!monitor || client && Date.parse(client.at) > Date.parse(monitor.at) ? client : monitor);const degradedSince = history?.alertSince ? history.degradedSince : last && last === client ? history?.client?.degradedSince : history?.degradedSince;- const stale = !last || now - Date.parse(last.at) > 120000;+ const stale = !last || now < Date.parse(last.at) || now - Date.parse(last.at) > 120000;const status = !last || stale ? 'unknown' : degradedSince ? 'degraded' : 'healthy';const since = degradedSince ?? null;const time = since ? since.slice(11, 16) : '';diff --git a/test/relay-canary-watch.test.js b/test/relay-canary-watch.test.jsindex ddc788d0..57d6058a 100644--- a/test/relay-canary-watch.test.js+++ b/test/relay-canary-watch.test.js@@ -6,6 +6,7 @@ import { delimiter, dirname, join } from 'node:path';import test from 'node:test';import { fileURLToPath } from 'node:url';import { repoInfo } from '../src/git.js';+import { probeRelayCanary } from '../src/relay-canary-probe.js';import { pendingRelayCanaryNotices } from '../src/relay-canary-health.js';import { startRelayCanaryWatch, RELAY_CANARY_INTERVAL_MS, runRelayCanary } from '../src/relay-canary-watch.js';import { relayClientFixture } from './relay-client-fixture.js';@@ -206,3 +207,21 @@ test('the canary command binds machine opt-in to its linked ordinary seat [H5,H1assert.equal(stopped.code, 1);assert.equal(stopped.document.error.code, 'RELAY_CANARY_CONFIG');});+++test('a stalled real board route is bounded by the probe deadline [H5,H17]', { timeout: 60_000 }, async t => { // budget: real linked fixture plus a 250 ms transport deadline, with fixture cleanup.+ const box = await relayClientFixture(t);+ commitConfiguration(box);+ await box.link();+ const seat = await joinedCanarySeat(box);+ box.stallApi();+ const started = performance.now();+ let result;+ try { result = await withFixtureEnvironment(box.env, () => probeRelayCanary(seat.root, { agentId: seat.agentId, deadlineMs: 250 })); }+ finally { box.stallApi(false); }+ assert.equal(result.ok, false, 'an unanswered board route is never a healthy round trip');+ assert.ok(['push', 'pull'].includes(result.step), JSON.stringify(result));+ assert.ok(performance.now() - started < 5000, 'budget: the 250 ms probe deadline must drain below the normal five-second probe ceiling');+ const healthy = await withFixtureEnvironment(box.env, () => probeRelayCanary(seat.root, { agentId: seat.agentId }));+ assert.equal(healthy.ok, true, JSON.stringify(healthy));+});diff --git a/test/relay-canary.test.js b/test/relay-canary.test.jsindex 61d5552c..f4b55072 100644--- a/test/relay-canary.test.js+++ b/test/relay-canary.test.js@@ -73,6 +73,7 @@ function displayText(value) {}test('a failed round trip alerts within two minutes and names the failed step [H2,H15,C7]', { timeout: 60_000 }, async t => { // budget: private relay startup, four real probes, and fixture cleanup; alert timing uses the injected clock.+ const drillStartedAt = new Date().toISOString();const { probeRelayCanary, observeRelayHealth, readRelayHealth } = await canaryApi();const box = await relayClientFixture(t);commitConfiguration(box);@@ -132,6 +133,9 @@ test('a failed round trip alerts within two minutes and names the failed step [Hassert.equal(recovered.health.consecutiveFailures, 0);assert.equal(recovered.finding, null);assert.equal(readRelayHealth(box.root, { now }).status, 'healthy', 'the cleared state is durable for a later status read');+ t.diagnostic(JSON.stringify({ drill: 'fixture authenticated event route blocked and restored', startedAt: drillStartedAt,+ finishedAt: new Date().toISOString(), cadence: 'injected clock; no wall-clock two-minute delivery claim',+ failedStep: second.step, alert: alerted.transition, recovery: recovered.transition, production: false }));});test('the health history waits for ten minutes of slow successful round-trip samples before p95 alerting [H5,H15,C7]', async t => {