diff --git a/src/lock-publisher.mjs b/src/lock-publisher.mjs index 908496d..d01c68d 100644 --- a/src/lock-publisher.mjs +++ b/src/lock-publisher.mjs @@ -1,4 +1,4 @@ -import { randomUUID, randomInt } from 'node:crypto'; +import { randomUUID } from 'node:crypto'; import { SimplePool } from 'nostr-tools/pool'; import { getPublishTimeoutMs, @@ -6,20 +6,10 @@ import { getRelayFallbacks, getMinActiveRelayPool, } from './torch-config.mjs'; -import { mergeRelayList } from './lock-utils.mjs'; +import { mergeRelayList, secureRandom, withTimeout } from './lock-utils.mjs'; import { defaultHealthManager, buildRelayHealthConfig } from './relay-health-manager.mjs'; import { relayListLabel } from './utils.mjs'; -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 PUBLISH_ERROR_CODES = { TIMEOUT: 'publish_timeout', DNS: 'dns_resolution', @@ -111,8 +101,6 @@ function isTransientPublishCategory(category) { ].includes(category); } -export { secureRandom }; - function calculateBackoffDelayMs(attemptNumber, baseMs, capMs, randomFn = secureRandom) { const maxDelay = Math.min(capMs, baseMs * (2 ** Math.max(0, attemptNumber - 1))); return Math.floor(randomFn() * maxDelay); diff --git a/src/lock-utils.mjs b/src/lock-utils.mjs index c287fa5..42bddd1 100644 --- a/src/lock-utils.mjs +++ b/src/lock-utils.mjs @@ -3,7 +3,7 @@ import path from 'node:path'; import { randomInt } from 'node:crypto'; import { todayDateStr, getIsoWeekStr } from './utils.mjs'; -export { relayListLabel } from './utils.mjs'; +export { relayListLabel, mergeRelayList } from './utils.mjs'; /** * Scans the local log directory to identify agents that have already completed their task @@ -69,10 +69,6 @@ export async function getCompletedAgents(cadence, logDir, deps) { return completed; } -export function mergeRelayList(primaryRelays, fallbackRelays) { - return [...new Set([...primaryRelays, ...fallbackRelays])]; -} - const MAX_RANDOM = 281474976710655; // 2**48 - 1 export function secureRandom() { diff --git a/src/relay-health.mjs b/src/relay-health.mjs index 3e4f921..6e09d0b 100644 --- a/src/relay-health.mjs +++ b/src/relay-health.mjs @@ -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 './lock-utils.mjs'; +import { withTimeout } from './utils.mjs'; const PROBE_KIND = 27235; diff --git a/src/todo/TODO_2026-02-20T03-00-00Z.md b/src/todo/TODO_2026-02-20T03-00-00Z.md index d8f1693..368902b 100644 --- a/src/todo/TODO_2026-02-20T03-00-00Z.md +++ b/src/todo/TODO_2026-02-20T03-00-00Z.md @@ -9,7 +9,6 @@ - [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. diff --git a/task-logs/daily/.scheduler-run-state.json b/task-logs/daily/.scheduler-run-state.json deleted file mode 100644 index 92d55d6..0000000 --- a/task-logs/daily/.scheduler-run-state.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "run_date": "2026-02-20", - "lock_deferral": null -} diff --git a/task-logs/daily/2026-02-20T21-46-47Z__scheduler-update-agent__failed.md b/task-logs/daily/2026-02-20T21-46-47Z__scheduler-update-agent__failed.md deleted file mode 100644 index 374e298..0000000 --- a/task-logs/daily/2026-02-20T21-46-47Z__scheduler-update-agent__failed.md +++ /dev/null @@ -1,18 +0,0 @@ ---- -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 \ No newline at end of file diff --git a/test/verify-example-config-security.test.mjs b/test/verify-example-config-security.test.mjs deleted file mode 100644 index fffd5b2..0000000 --- a/test/verify-example-config-security.test.mjs +++ /dev/null @@ -1,14 +0,0 @@ -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'); - } -}); diff --git a/torch-config.example.json b/torch-config.example.json index df7ea44..aafd0bf 100644 --- a/torch-config.example.json +++ b/torch-config.example.json @@ -18,7 +18,8 @@ }, "dashboard": { "defaultCadenceView": "daily", - "defaultStatusView": "active" + "defaultStatusView": "active", + "auth": "admin:password" }, "scheduler": { "firstPromptByCadence": {