Merge branch 'main' into agents/daily/decompose-agent-refactor-14956609596778737678

This commit is contained in:
thePR0M3TH3AN authored and GitHub committed 2026-02-19 20:54:11 -05:00
commit 2df8b85682
7 files changed
+118

No files matched your search

@@ -0,0 +1 @@
Decomposed src/lock-ops.mjs into src/relay-health-manager.mjs and src/lock-publisher.mjs. Reduced size from 880 to 152 lines.
@@ -0,0 +1,18 @@
Run Start: 2026-02-19T10-00-00Z
Cadence: daily
Agent: decompose-agent
Prompt: src/prompts/daily/decompose-agent.md
# Context: Decompose src/lock-ops.mjs
**Target File:** `src/lock-ops.mjs` (880 lines)
**Reason:** Largest JS file in `src/` exceeding the size limit.
**Commit SHA:** e10528141db40674c793884007255fb3c46ed795
**Node Version:** v22.22.0
**Extraction Plan:**
1. Extract `RelayHealthManager` and related functions (`summarizeRelayMetrics`, `computeRelayScore`, `buildRelayHealthConfig`, `defaultHealthManager`, `_resetRelayHealthState`) into `src/relay-health-manager.mjs`.
2. Extract `LockPublisher` and related functions (`classifyPublishError`, `isTransientPublishCategory`, `PUBLISH_ERROR_CODES`, `PUBLISH_FAILURE_CATEGORIES`, `secureRandom`, `calculateBackoffDelayMs`, `publishToRelays`, `publishLock`) into `src/lock-publisher.mjs`.
3. Move shared utilities (`withTimeout`, `relayListLabel`, `mergeRelayList`) to `src/lock-utils.mjs` or ensure correct imports.
4. Update `src/lock-ops.mjs` to import these dependencies.
**Goal:** Reduce `src/lock-ops.mjs` by at least 200 lines.
@@ -0,0 +1,20 @@
Run Start: 2026-02-19T10-00-00Z
Cadence: daily
Agent: decompose-agent
Prompt: src/prompts/daily/decompose-agent.md
# Decisions: Decompose src/lock-ops.mjs
## Decision 1: Extract `RelayHealthManager`
- **Rationale:** The `RelayHealthManager` class manages complex state and logic for relay health metrics, scoring, and prioritization. It is a distinct cohesive block that can be reused and tested independently.
- **Target File:** `src/relay-health-manager.mjs`.
## Decision 2: Extract `LockPublisher`
- **Rationale:** The `LockPublisher` class encapsulates the retry logic, backoff strategy, and publishing workflow. Separating it clarifies the distinction between "publishing a lock" and "managing locks generally".
- **Target File:** `src/lock-publisher.mjs`.
## Decision 3: Move utilities
- **Rationale:** Utilities like `withTimeout` and `mergeRelayList` are used by both the extraction targets and the original file. Moving them to `src/lock-utils.mjs` (or similar) avoids circular dependencies.
## Decision 4: Skip baseline update in script
- **Rationale:** The `scripts/check-file-size.mjs` script does not support `--update` or maintain a `BASELINE` constant as described in the prompt. I manually verified that `src/lock-ops.mjs` is now under the limit (152 lines).
+18
View File
@@ -47,3 +47,21 @@ 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);
});
}
export function relayListLabel(relays) {
return relays.join(', ');
}
export function mergeRelayList(primaryRelays, fallbackRelays) {
return [...new Set([...primaryRelays, ...fallbackRelays])];
}
@@ -0,0 +1,28 @@
Run Start: 2026-02-19T10-00-00Z
Cadence: daily
Agent: decompose-agent
Prompt: src/prompts/daily/decompose-agent.md
# Test Log: Decompose src/lock-ops.mjs
**Timestamp:** 2026-02-19T10-00-00Z
**Agent:** decompose-agent
## Commands
### Lint
- **Command:** `npm run lint`
- **Result:** Passed (No errors)
### Unit Tests
- **Command:** `npm run test`
- **Result:** Passed
- **Summary:**
- Tests: 295
- Passed: 294
- Skipped: 1
## Observations
- Decomposed `src/lock-ops.mjs` into `src/relay-health-manager.mjs` and `src/lock-publisher.mjs`.
- Moved shared utilities to `src/lock-utils.mjs`.
- All tests passed, confirming no regression in functionality.
+22
View File
@@ -0,0 +1,22 @@
Run Start: 2026-02-19T10-00-00Z
Cadence: daily
Agent: decompose-agent
Prompt: src/prompts/daily/decompose-agent.md
# Todo: Decompose src/lock-ops.mjs
## Pending
- [x] Create `src/relay-health-manager.mjs` with `RelayHealthManager` logic.
- [x] Create `src/lock-publisher.mjs` with `LockPublisher` logic.
- [x] Update `src/lock-ops.mjs` to import new modules.
- [x] Verify linting passes (`npm run lint`).
- [x] Verify tests pass (`npm run test`).
- [x] Update file size baseline (skipped script update, manually verified).
## Completed
- [x] Decomposed `src/lock-ops.mjs`.
- [x] Created `src/relay-health-manager.mjs`.
- [x] Created `src/lock-publisher.mjs`.
- [x] Updated `src/lock-utils.mjs`.
- [x] Updated `src/lock-ops.mjs`.
- [x] Passed lint and tests.
@@ -0,0 +1,11 @@
---
agent: decompose-agent
cadence: daily
date: 2026-02-19
platform: jules
status: completed
run_start: 2026-02-19T10-00-00Z
---
Scheduler cycle completed successfully.
Decomposed src/lock-ops.mjs.