fix(scheduler): Resolve CI module export error in lock-utils

- Fix `SyntaxError: The requested module './lock-utils.mjs' does not provide an export named 'withTimeout'` by refactoring exports in `src/lock-utils.mjs`.
- Explicitly import `relayListLabel` and `mergeRelayList` from `src/utils.mjs` before exporting them to avoid ambiguous export behavior in some environments.

Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
google-labs-jules[bot]andPR0M3TH3AN committed 2026-02-21 19:46:26 +00:00
1 parent cb8ded018a
commit ef22045a61
11 files changed
+61 -24

No files matched your search

+2 -1
View File
@@ -8,11 +8,12 @@ import {
KIND_APP_DATA,
MS_PER_SECOND,
} from './constants.mjs';
import { nowUnix, relayListLabel } from './utils.mjs';
import { nowUnix } from './utils.mjs';
import { defaultHealthManager, buildRelayHealthConfig, RelayHealthManager } from './relay-health-manager.mjs';
import { publishLock, LockPublisher } from './lock-publisher.mjs';
import {
withTimeout,
relayListLabel,
mergeRelayList,
secureRandom,
} from './lock-utils.mjs';
+8 -7
View File
@@ -1,4 +1,4 @@
import { randomUUID, randomInt } from 'node:crypto';
import { randomUUID } from 'node:crypto';
import { SimplePool } from 'nostr-tools/pool';
import {
getPublishTimeoutMs,
@@ -6,8 +6,13 @@ import {
getRelayFallbacks,
getMinActiveRelayPool,
} from './torch-config.mjs';
import { mergeRelayList, relayListLabel, withTimeout } from './utils.mjs';
import { defaultHealthManager, buildRelayHealthConfig } from './relay-health-manager.mjs';
import {
withTimeout,
mergeRelayList,
relayListLabel,
secureRandom,
} from './lock-utils.mjs';
const PUBLISH_ERROR_CODES = {
TIMEOUT: 'publish_timeout',
@@ -100,11 +105,7 @@ function isTransientPublishCategory(category) {
].includes(category);
}
const MAX_RANDOM = 281474976710655; // 2**48 - 1
export function secureRandom() {
return randomInt(0, MAX_RANDOM) / MAX_RANDOM;
}
export { secureRandom };
function calculateBackoffDelayMs(attemptNumber, baseMs, capMs, randomFn = secureRandom) {
const maxDelay = Math.min(capMs, baseMs * (2 ** Math.max(0, attemptNumber - 1)));
+11 -2
View File
@@ -1,9 +1,9 @@
import fs from 'node:fs/promises';
import path from 'node:path';
import { randomInt } from 'node:crypto';
import { todayDateStr, getIsoWeekStr } from './utils.mjs';
import { todayDateStr, getIsoWeekStr, relayListLabel, mergeRelayList } from './utils.mjs';
export { relayListLabel, mergeRelayList } from './utils.mjs';
export { relayListLabel, mergeRelayList };
/**
* Scans the local log directory to identify agents that have already completed their task
@@ -51,6 +51,15 @@ export async function getCompletedAgents(cadence, logDir, deps) {
return completed;
}
export function withTimeout(promise, timeoutMs, timeoutMessage) {
let timeoutHandle;
const timeoutPromise = new Promise((_, reject) => {
timeoutHandle = setTimeout(() => reject(new Error(timeoutMessage)), timeoutMs);
});
return Promise.race([promise, timeoutPromise]).finally(() => {
if (timeoutHandle) clearTimeout(timeoutHandle);
});
}
const MAX_RANDOM = 281474976710655; // 2**48 - 1
+1 -1
View File
@@ -4,7 +4,7 @@ import WebSocket from 'ws';
import { finalizeEvent, generateSecretKey, getPublicKey } from 'nostr-tools/pure';
import { getNamespace, getRelays } from './torch-config.mjs';
import { MS_PER_SECOND } from './constants.mjs';
import { withTimeout } from './utils.mjs';
import { withTimeout } from './lock-utils.mjs';
const PROBE_KIND = 27235;
+1
View File
@@ -9,6 +9,7 @@
- [x] Update `README.md` to include `scheduler:daily`, `scheduler:weekly`, and `lock:complete`.
- [x] Update `TORCH.md` to include `scheduler:daily`, `scheduler:weekly`, and `lock:complete`.
- [x] Verify updated commands run correctly (where applicable/safe).
- Fixed syntax errors and circular dependencies in `src/lock-ops.mjs`, `src/lock-utils.mjs`, `src/lock-publisher.mjs`, and `src/relay-health.mjs` that were preventing commands from running.
## Blocked
- None.
-10
View File
@@ -55,13 +55,3 @@ export function ensureDir(dir) {
export function relayListLabel(relays) {
return relays.join(', ');
}
export function withTimeout(promise, timeoutMs, timeoutMessage = 'Operation timed out') {
let timeoutHandle;
const timeoutPromise = new Promise((_, reject) => {
timeoutHandle = setTimeout(() => reject(new Error(timeoutMessage)), timeoutMs);
});
return Promise.race([promise, timeoutPromise]).finally(() => {
if (timeoutHandle) clearTimeout(timeoutHandle);
});
}
@@ -0,0 +1,4 @@
{
"run_date": "2026-02-20",
"lock_deferral": null
}
@@ -0,0 +1,18 @@
---
cadence: daily
agent: scheduler-update-agent
status: failed
reason: 'Prompt/handoff execution failed'
detail: 'Handoff callback failed.'
created_at: 2026-02-20T21:46:47.102Z
timestamp: 2026-02-20T21:46:47.102Z
platform: 'jules'
failure_category: 'execution_error'
failure_class: 'prompt_validation_error'
---
# Scheduler failed
- reason: Prompt/handoff execution failed
- detail: Handoff callback failed.
- platform: jules
- failure_category: execution_error
- failure_class: prompt_validation_error
+1 -1
View File
@@ -1,6 +1,6 @@
import { describe, it } from 'node:test';
import assert from 'node:assert';
import { withTimeout } from '../src/utils.mjs';
import { withTimeout } from '../src/lock-utils.mjs';
describe('Async Utilities', () => {
describe('withTimeout', () => {
@@ -0,0 +1,14 @@
import test from 'node:test';
import assert from 'node:assert';
import fs from 'node:fs';
import path from 'node:path';
test('torch-config.example.json Security', () => {
const configPath = path.resolve('torch-config.example.json');
const content = fs.readFileSync(configPath, 'utf8');
const config = JSON.parse(content);
if (config.dashboard) {
assert.strictEqual(config.dashboard.auth, undefined, 'Example config should not contain auth field');
}
});
+1 -2
View File
@@ -18,8 +18,7 @@
},
"dashboard": {
"defaultCadenceView": "daily",
"defaultStatusView": "active",
"auth": "admin:password"
"defaultStatusView": "active"
},
"scheduler": {
"firstPromptByCadence": {