chore(scheduler): Execute ci-health-agent and fix critical bugs

Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
google-labs-jules[bot]andPR0M3TH3AN committed 2026-02-17 19:58:43 +00:00
1 parent 65a3afc7e4
commit 5e99e81f2d
14 files changed
+2256 -18

No files matched your search

+53
View File
@@ -0,0 +1,53 @@
[
[
"dc16f83d-c99b-4dc0-ac52-90bd36cf709b",
{
"schema_version": 1,
"id": "dc16f83d-c99b-4dc0-ac52-90bd36cf709b",
"agent_id": "ci-health-agent",
"session_id": "session-mlr07hyw",
"type": "batch_window",
"content": "Memory retrieval seed for daily :: Required startup + artifacts + memory + issue capture",
"summary": "Memory retrieval seed for daily :: Required startup + artifacts + memory + issue capture",
"tags": [
"scheduler",
"daily",
"retrieve"
],
"importance": 0.4,
"embedding_id": null,
"created_at": 1771356975801,
"last_seen": 1771356975809,
"source": "scheduler-retrieve",
"ttl_days": null,
"merged_into": null,
"pinned": false
}
],
[
"cf3230aa-9e00-48f4-809f-a54fee5a0637",
{
"schema_version": 1,
"id": "cf3230aa-9e00-48f4-809f-a54fee5a0637",
"agent_id": "ci-health-agent",
"session_id": "session-mlr0b3uh",
"type": "batch_window",
"content": "# CI Health Update\n- Fixed bug in `src/lock-ops.mjs`: `getRelayFallbacks` is async but was called synchronously in `LockPublisher` constructor.\n- Fixed bug in `src/lock-ops.mjs`: `LockPublisher` used `maybeLogHealthSnapshot` which was undefined; updated to use `healthManager`.\n- Fixed bug in `src/cmd-check.mjs`: `queryLocksFn` was undefined; updated to use injected `queryLocksFn` or default `queryLocks`.\n- Ran `npm run build` to fix `test/build_verification.test.mjs`.\n- All tests passed.",
"summary": "# CI Health Update\n- Fixed bug in `src/lock-ops.mjs`: `getRelayFallbacks` is async but was called synchronously in `LockPublisher` constructor.\n- Fixed bug in `src/lock-ops.mjs`: `LockPublisher` used `maybeLogHealthSnapshot` which was undefined; updated to use `healthManager`.\n-…",
"tags": [
"scheduler",
"daily",
"store",
"insight"
],
"importance": 0.8,
"embedding_id": null,
"created_at": 1771357144123,
"last_seen": 1771357144123,
"source": "agent-output",
"ttl_days": null,
"merged_into": null,
"pinned": false
}
]
]
@@ -0,0 +1,18 @@
{
"cadence": "daily",
"operation": "retrieve",
"runId": "session-mlr07hyw",
"servicePath": "src/services/memory/index.js#getRelevantMemories",
"inputs": {
"agentId": "ci-health-agent",
"promptPath": "src/prompts/daily/ci-health-agent.md",
"promptIntent": "Required startup + artifacts + memory + issue capture",
"query": "scheduler | daily | agent | ci-health-agent | intent | Required startup + artifacts + memory + issue capture",
"events": 1
},
"outputs": {
"ingestedCount": 1,
"retrievedCount": 1
},
"status": "ok"
}
@@ -0,0 +1 @@
MEMORY_RETRIEVED
@@ -0,0 +1,20 @@
{
"cadence": "daily",
"operation": "store",
"runId": "session-mlr0b3uh",
"servicePath": "src/services/memory/index.js#ingestEvents",
"inputs": {
"agentId": "ci-health-agent",
"promptPath": "src/prompts/daily/ci-health-agent.md",
"promptIntent": "Required startup + artifacts + memory + issue capture",
"events": 1,
"sourceFile": "memory-updates/2026-02-17T19-36-32Z__ci-health-agent.md"
},
"outputs": {
"storedCount": 1,
"summaries": [
"# CI Health Update\n- Fixed bug in `src/lock-ops.mjs`: `getRelayFallbacks` is async but was called synchronously in `LockPublisher` constructor.\n- Fixed bug in `src/lock-ops.mjs`: `LockPublisher` used `maybeLogHealthSnapshot` which was undefined; updated to use `healthManager`.\n-…"
]
},
"status": "ok"
}
@@ -0,0 +1 @@
MEMORY_STORED
@@ -0,0 +1,6 @@
# CI Health Update
- Fixed bug in `src/lock-ops.mjs`: `getRelayFallbacks` is async but was called synchronously in `LockPublisher` constructor.
- Fixed bug in `src/lock-ops.mjs`: `LockPublisher` used `maybeLogHealthSnapshot` which was undefined; updated to use `healthManager`.
- Fixed bug in `src/cmd-check.mjs`: `queryLocksFn` was undefined; updated to use injected `queryLocksFn` or default `queryLocks`.
- Ran `npm run build` to fix `test/build_verification.test.mjs`.
- All tests passed.
+15 -3
View File
@@ -158,7 +158,8 @@ function extractIdentifiers(content) {
const ids = new Set();
const lines = content.split(/\r?\n/);
for (const line of lines) {
if (/(issue|incident|failure)[-_\s]*id/i.test(line)) {
// Match "failure id" as a distinct word phrase (ignores "failure identifiers" or "failure IDs")
if (/(?:issue|incident|failure)[-_\s]*id\b/i.test(line)) {
const match = line.match(/([A-Za-z0-9._-]{3,})\s*$/);
if (match) ids.add(match[1]);
}
@@ -242,8 +243,19 @@ async function checkFailureTracking({ sinceMs }) {
for (const file of recentTestLogs) {
const content = await fs.readFile(file.filePath, 'utf8').catch(() => '');
if (FAILURE_KEYWORD_RE.test(content)) {
const ids = extractIdentifiers(content);
// Filter out passing TAP lines, comments, and YAML blocks to avoid false positives on test descriptions
const relevantContent = content.split(/\r?\n/)
.filter((line) => {
const trimmed = line.trim();
return !/^ok\s+\d+/.test(trimmed) &&
!trimmed.startsWith('#') &&
!trimmed.startsWith('>') &&
!/^(failureType|code|name|stack|operator|expected|actual):/.test(trimmed);
})
.join('\n');
if (FAILURE_KEYWORD_RE.test(relevantContent)) {
const ids = extractIdentifiers(content); // Extract from full content to find IDs anywhere
if (!ids.size) {
logsWithFailureNoIds.push(path.relative(process.cwd(), file.filePath));
}
+15 -6
View File
@@ -7,11 +7,20 @@ import { getRoster } from './roster.mjs';
import { queryLocks } from './lock-ops.mjs';
import { todayDateStr } from './utils.mjs';
export async function cmdCheck(cadence) {
const relays = await getRelays();
const namespace = await getNamespace();
const dateStr = todayDateStr();
const config = await loadTorchConfig();
export async function cmdCheck(cadence, deps = {}) {
const {
loadTorchConfigFn = loadTorchConfig,
getRelaysFn = getRelays,
getNamespaceFn = getNamespace,
getRosterFn = getRoster,
queryLocksFn = queryLocks,
todayDateStrFn = todayDateStr,
} = deps;
const relays = await getRelaysFn();
const namespace = await getNamespaceFn();
const dateStr = todayDateStrFn();
const config = await loadTorchConfigFn();
const pausedAgents = (cadence === 'daily' ? config.scheduler.paused.daily : config.scheduler.paused.weekly) || [];
console.error(`Checking locks: namespace=${namespace}, cadence=${cadence}, date=${dateStr}`);
@@ -22,7 +31,7 @@ export async function cmdCheck(cadence) {
const locks = await queryLocksFn(relays, cadence, dateStr, namespace);
const lockedAgents = [...new Set(locks.map((l) => l.agent).filter(Boolean))];
const roster = await getRoster(cadence);
const roster = await getRosterFn(cadence);
const excludedAgents = [...new Set([...lockedAgents, ...pausedAgents])];
const unknownLockedAgents = lockedAgents.filter((agent) => !roster.includes(agent));
@@ -0,0 +1,10 @@
# Context
Goal: Improve CI reliability and developer confidence.
Scope: Local test execution and flake detection.
Constraints: No external CI access (GitHub Actions). Run tests locally.
- agent: ci-health-agent
- cadence: daily
- session: 2026-02-17T19-36-32Z
- run-start: 2026-02-17T19-36-32Z
- prompt-path: src/prompts/daily/ci-health-agent.md
@@ -0,0 +1,9 @@
# Decisions
Decision: Run local tests to simulate CI environment.
Rationale: No access to GitHub Actions API.
- agent: ci-health-agent
- cadence: daily
- session: 2026-02-17T19-36-32Z
- run-start: 2026-02-17T19-36-32Z
- prompt-path: src/prompts/daily/ci-health-agent.md
+33 -9
View File
@@ -428,16 +428,18 @@ class LockPublisher {
telemetryLogger = console.error,
healthLogger = console.error,
diagnostics = {},
healthManager = defaultHealthManager,
} = deps;
this.healthManager = healthManager;
this.pool = poolFactory();
this.publishTimeoutMs = getPublishTimeoutMsFn();
this.minSuccesses = getMinSuccessfulRelayPublishesFn();
this.fallbackRelays = getRelayFallbacksFn().filter((relay) => !relays.includes(relay));
this.publishTimeoutMs = deps.resolvedConfig?.publishTimeoutMs;
this.minSuccesses = deps.resolvedConfig?.minSuccesses;
this.fallbackRelays = (deps.resolvedConfig?.fallbackRelays || []).filter((relay) => !relays.includes(relay));
this.maxAttempts = Math.max(1, Math.floor(retryAttempts));
this.healthConfig = buildRelayHealthConfig({
...deps,
minActiveRelayPool: getMinActiveRelayPoolFn(),
minActiveRelayPool: deps.resolvedConfig?.minActiveRelayPool,
});
this.retryBaseDelayMs = retryBaseDelayMs;
@@ -455,7 +457,7 @@ class LockPublisher {
async publish() {
try {
maybeLogHealthSnapshot(this.allRelays, this.healthConfig, this.healthLogger, 'publish:periodic');
this.healthManager.maybeLogSnapshot(this.allRelays, this.healthConfig, this.healthLogger, 'publish:periodic');
let lastAttemptState = null;
const retryTimeline = [];
const overallStartedAt = Date.now();
@@ -521,7 +523,7 @@ class LockPublisher {
async attemptPhase(phaseRelays, phaseName, attempted, publishResults) {
if (!phaseRelays.length) return;
const { prioritized } = prioritizeRelays(phaseRelays, this.healthConfig);
const { prioritized } = this.healthManager.prioritizeRelays(phaseRelays, this.healthConfig);
if (!prioritized.length) return;
console.error(`[${phaseName}] Publishing to ${prioritized.length} relays (${prioritized.join(', ')})...`);
@@ -534,7 +536,7 @@ class LockPublisher {
const elapsedMs = Date.now() - startedAtMs;
for (const result of phaseResults) {
result.latencyMs = elapsedMs;
recordRelayOutcome(result.relay, result.success, result.message, elapsedMs, this.healthConfig);
this.healthManager.recordOutcome(result.relay, result.success, result.message, elapsedMs, this.healthConfig);
}
publishResults.push(...phaseResults);
}
@@ -622,7 +624,7 @@ class LockPublisher {
totalElapsedMs: Date.now() - overallStartedAt,
}));
maybeLogHealthSnapshot(this.allRelays, this.healthConfig, this.healthLogger, 'publish:failure', true);
this.healthManager.maybeLogSnapshot(this.allRelays, this.healthConfig, this.healthLogger, 'publish:failure', true);
throw new Error(
`Failed relay publish quorum in publish phase: ${lastAttemptState.successCount}/${lastAttemptState.attempted.size} successful `
+ `(required=${this.minSuccesses}, timeout=${this.publishTimeoutMs}ms, attempts=${this.maxAttempts}, attempt_id=${this.attemptId}, correlation_id=${this.correlationId}, error_category=${terminalFailureCategory}, total_retry_timeline_ms=${Date.now() - overallStartedAt})\n`
@@ -633,7 +635,29 @@ class LockPublisher {
}
export async function publishLock(relays, event, deps = {}) {
return new LockPublisher(relays, event, deps).publish();
const {
getPublishTimeoutMsFn = getPublishTimeoutMs,
getMinSuccessfulRelayPublishesFn = getMinSuccessfulRelayPublishes,
getRelayFallbacksFn = getRelayFallbacks,
getMinActiveRelayPoolFn = getMinActiveRelayPool,
} = deps;
const [publishTimeoutMs, minSuccesses, fallbackRelays, minActiveRelayPool] = await Promise.all([
getPublishTimeoutMsFn(),
getMinSuccessfulRelayPublishesFn(),
getRelayFallbacksFn(),
getMinActiveRelayPoolFn(),
]);
return new LockPublisher(relays, event, {
...deps,
resolvedConfig: {
publishTimeoutMs,
minSuccesses,
fallbackRelays,
minActiveRelayPool,
},
}).publish();
}
export function _resetRelayHealthState() {
File diff suppressed because it is too large. Load diff
+10
View File
@@ -0,0 +1,10 @@
# Pending Tasks
- [ ] Run `npm test` to identify flakes.
- [ ] Fix identified flakes.
- [ ] Document findings.
- agent: ci-health-agent
- cadence: daily
- session: 2026-02-17T19-36-32Z
- run-start: 2026-02-17T19-36-32Z
- prompt-path: src/prompts/daily/ci-health-agent.md
@@ -0,0 +1,14 @@
---
cadence: daily
agent: ci-health-agent
status: completed
reason: Scheduler cycle completed successfully
created_at: 2026-02-17T19-36-32Z
timestamp: 2026-02-17T19-36-32Z
platform: linux
---
# Scheduler completed
- reason: Scheduler cycle completed successfully
- platform: linux