Commit Graph
555 Commits
Author SHA1 Message Date
google-labs-jules[bot]andPR0M3TH3AN 2466c80af9 fix(dashboard): Allow access to src/constants.mjs and fix lock-ops
`frontend-console-debug-agent` run:
- Fixed a 403 Forbidden error in `src/dashboard.mjs` preventing `src/constants.mjs` from loading by adding it to the `allowedPaths` whitelist.
- Refactored `src/lock-ops.mjs` to fix a critical syntax error in `LockPublisher` class.
- Fixed a typo in `src/cmd-check.mjs` (`queryLocksFn` -> `queryLocks`).
- Added `@playwright/test` for frontend debugging.
- Added `scripts/agent/debug_frontend.mjs` for reproduction.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-17 19:52:10 +00:00
thePR0M3TH3AN 7f87c371fc Merge pull request #255 from PR0M3TH3AN/fix-insecure-random-backoff-15480292305985131336
🔒 Fix insecure random number generator in backoff logic
2026-02-17 14:30:21 -05:00
thePR0M3TH3AN 058011089d Merge branch 'main' into fix-insecure-random-backoff-15480292305985131336 2026-02-17 14:30:13 -05:00
thePR0M3TH3AN 6e31c9cec6 Merge pull request #258 from PR0M3TH3AN/fix-scheduler-env-leak-137317158852257446
🔒 Fix environment variable leakage in scheduler cycle
2026-02-17 14:29:53 -05:00
thePR0M3TH3AN 94d4136070 Merge pull request #259 from PR0M3TH3AN/refactor-cmdinit-ops-5287196156995262612
🧹 Refactor cmdInit in src/ops.mjs
2026-02-17 14:29:39 -05:00
thePR0M3TH3AN 59c286e247 Merge branch 'main' into refactor-cmdinit-ops-5287196156995262612 2026-02-17 14:29:31 -05:00
thePR0M3TH3AN 0c41456db6 Merge pull request #254 from PR0M3TH3AN/refactor-cmd-init-10842756279574756855
🧹 Refactor cmdInit in src/ops.mjs
2026-02-17 14:29:07 -05:00
thePR0M3TH3AN 65a3afc7e4 Merge pull request #252 from PR0M3TH3AN/refactor-lock-ops-publish-lock-16349393256066370386
Refactor publishLock to LockPublisher class
2026-02-17 14:28:46 -05:00
thePR0M3TH3AN 2c51424b6d Merge branch 'main' into refactor-lock-ops-publish-lock-16349393256066370386 2026-02-17 14:28:12 -05:00
thePR0M3TH3AN db38fb0e91 Merge pull request #256 from PR0M3TH3AN/refactor-lock-ops-state-3445549076565547288
Refactor lock-ops to encapsulate global state
2026-02-17 14:27:22 -05:00
thePR0M3TH3AN c2ceb00174 Merge pull request #250 from PR0M3TH3AN/test-improvement-get-relevant-memories-15158310533650216935
Test Improvement: Make getRelevantMemories testable and add unit tests
2026-02-17 14:27:03 -05:00
thePR0M3TH3AN fb558b0b4d Merge branch 'main' into test-improvement-get-relevant-memories-15158310533650216935 2026-02-17 14:26:54 -05:00
thePR0M3TH3AN e355330e5b Merge pull request #253 from PR0M3TH3AN/test-triggerPruneDryRun-12931935296810438248
test: Add tests for triggerPruneDryRun
2026-02-17 14:26:29 -05:00
thePR0M3TH3AN 79a33958ab Merge pull request #260 from PR0M3TH3AN/jules-perf-async-config-1969443791138192182
⚡ Async Config Loading Optimization
2026-02-17 14:26:16 -05:00
thePR0M3TH3AN 3502d38431 Merge branch 'main' into jules-perf-async-config-1969443791138192182 2026-02-17 14:26:06 -05:00
thePR0M3TH3AN da2e623b7c Merge pull request #246 from PR0M3TH3AN/test-render-prompt-memory-context-18203619131675777622
test: add comprehensive tests for renderPromptWithMemoryContext
2026-02-17 14:25:39 -05:00
thePR0M3TH3AN cc6f9d9259 Merge pull request #247 from PR0M3TH3AN/test/ingest-events-coverage-4058176338689655233
Add unit tests for ingestEvents function
2026-02-17 14:25:13 -05:00
thePR0M3TH3AN 4a59ccd501 Merge branch 'main' into test/ingest-events-coverage-4058176338689655233 2026-02-17 14:25:04 -05:00
thePR0M3TH3AN 26c878bdd9 Merge pull request #245 from PR0M3TH3AN/test-memory-ingest-events-14179486498291680650
Add unit tests for memory ingestEvents
2026-02-17 14:24:33 -05:00
thePR0M3TH3AN f79eae6ae9 Merge pull request #248 from PR0M3TH3AN/test/memory-stats-coverage-2370317382454489346
test: Add comprehensive tests for memoryStats function
2026-02-17 14:24:08 -05:00
thePR0M3TH3AN e9dcfb8c01 Merge pull request #251 from PR0M3TH3AN/test/cmd-check-improvements-4816638132352517865
🧪 Add tests for cmdCheck
2026-02-17 14:23:46 -05:00
thePR0M3TH3AN 4159ce1ad5 Merge pull request #257 from PR0M3TH3AN/jules-memory-prune-tests-5206348108909836817
Add tests for memory pruning cycle
2026-02-17 14:23:00 -05:00
thePR0M3TH3AN 670fdc2b22 Merge pull request #249 from PR0M3TH3AN/test-lock-utils-error-handling-1774013981640093185
🧪 Add missing error handling test for lock-utils
2026-02-17 14:22:30 -05:00
thePR0M3TH3AN 092169b0b9 Merge branch 'main' into test-lock-utils-error-handling-1774013981640093185 2026-02-17 14:22:09 -05:00
thePR0M3TH3AN 7128e6944b Merge pull request #244 from PR0M3TH3AN/test/lock-utils-coverage-13528701171132659276
Add unit tests for getCompletedAgents in src/lock-utils.mjs
2026-02-17 14:21:40 -05:00
google-labs-jules[bot]andPR0M3TH3AN 50b0cf5a07 perf: Refactor config loading to be non-blocking async
Replaces synchronous `fs.readFileSync` with `fs.promises.readFile` in `loadTorchConfig` to prevent event loop blocking.
Updates all dependent configuration getters and consumers to use async/await.
Includes benchmark proving non-blocking behavior.
Fixes dashboard tests to properly await server listening.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-17 19:02:46 +00:00
google-labs-jules[bot]andPR0M3TH3AN 68da87ac48 Refactor cmdInit in src/ops.mjs to improve modularity and maintainability
- Extracted logic into helper functions: `resolveConfiguration`, `ensureInstallDirectory`, `installAppAssets`, `installTorchAssets`, `configureTorch`, `injectHostScriptsIfNeeded`.
- Updated `cmdInit` to orchestrate these functions.
- Verified functionality with existing tests.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-17 19:01:15 +00:00
google-labs-jules[bot]andPR0M3TH3AN bd9641a536 Sanitize environment variables in run-scheduler-cycle.mjs
Prevent sensitive environment variables from leaking into child processes spawned by the scheduler. Introduce `getSafeEnv` whitelist and default `runCommand` to use it. Explicitly allow system, node, CI, and application-specific (NOSTR_, TORCH_, SCHEDULER_, AGENT_) variables. Removed `inheritProcessEnv: true` from user commands to enforce this security policy. Added `Path` support for Windows.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-17 18:59:10 +00:00
google-labs-jules[bot]andPR0M3TH3AN a940172998 feat(test): add tests for runPruneCycle
- Added `test/memory-run-prune-cycle.test.mjs` to test `runPruneCycle` logic.
- Covered active pruning, dry-run, off mode, telemetry/metrics, and scheduling.
- Utilized environment isolation (temp dir) to prevent side effects on `.scheduler-memory/memory-store.json`.
- Addressed testing gap for `runPruneCycle` in `src/services/memory/index.js`.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-17 18:55:55 +00:00
google-labs-jules[bot]andPR0M3TH3AN 59fbe1f4b8 Refactor lock-ops to encapsulate global state in RelayHealthManager class
- Replaces module-level mutable state (`metricsByRelay`, `lastSnapshotAt`) with `RelayHealthManager` class.
- Moves state-dependent functions (`ensureRelayMetrics`, `rankRelaysByHealth`, etc.) to class methods.
- Updates `queryLocks` and `publishLock` to support dependency injection for `healthManager`.
- Maintains backward compatibility via `defaultHealthManager` singleton.
- Adds `test/relay-health-manager.test.mjs` to verify state isolation and functionality.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-17 18:55:11 +00:00
google-labs-jules[bot]andPR0M3TH3AN 568d37a45c Fix insecure random number generator in backoff logic
Replaced `Math.random` with a cryptographically secure random number generator using `node:crypto.randomInt` in `src/lock-ops.mjs` to prevent potential timing attacks or predictability in backoff delays.

Added `test/secure-random.test.mjs` to verify the secure random generator.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-17 18:54:42 +00:00
google-labs-jules[bot]andPR0M3TH3AN bcc501e52f Refactor cmdInit in src/ops.mjs to improve modularity
Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-17 18:54:33 +00:00
google-labs-jules[bot]andPR0M3TH3AN 6be1809585 test: Add tests for triggerPruneDryRun
Added unit tests for triggerPruneDryRun in src/services/memory/index.js.
Tests cover database-backed pruning and in-memory fallback pruning using mocked repositories.
Also included validation of output structure.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-17 18:54:04 +00:00
google-labs-jules[bot]andPR0M3TH3AN 321d5848ac Refactor publishLock into LockPublisher class in src/lock-ops.mjs
- Extracted complex retry logic from `publishLock` into `LockPublisher` class.
- Decomposed `publishLock` into `executePublishCycle`, `attemptPhase`, `analyzeFailures`, `determineFailureCategory`, and logging helpers.
- Preserved existing functionality and behavior including telemetry, health management, and error handling.
- Verified with existing tests.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-17 18:54:02 +00:00
google-labs-jules[bot]andPR0M3TH3AN 99bd4ba2a3 test: add unit tests for cmdCheck
Refactor `cmdCheck` in `src/cmd-check.mjs` to support dependency injection for better testability.
Add `test/cmd-check.test.mjs` with comprehensive unit tests for `cmdCheck`, covering happy paths and edge cases.
Verify tests pass with `node --test test/cmd-check.test.mjs`.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-17 18:53:55 +00:00
google-labs-jules[bot]andPR0M3TH3AN 694afb1462 feat: make getRelevantMemories testable and add tests
- Modified `getRelevantMemories` in `src/services/memory/index.js` to accept optional `ranker` and `cache` parameters for dependency injection.
- Added `test/memory-index.test.mjs` with comprehensive unit tests for `getRelevantMemories` using `node:test` mocks.
- Verified that existing behavior is preserved via default parameters.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-17 18:53:52 +00:00
google-labs-jules[bot]andPR0M3TH3AN 1926426b11 test: add missing error handling test for lock-utils
Add a unit test for `getCompletedAgents` in `src/lock-utils.mjs` to verify that:
1. It correctly identifies completed agents.
2. It handles `ENOENT` gracefully (silent).
3. It logs an error for non-`ENOENT` errors (e.g. permission denied).

The `getCompletedAgents` function already supported dependency injection via a `deps` object, which is utilized in this test to mock `fs.readdir` and other dependencies.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-17 18:53:34 +00:00
google-labs-jules[bot]andPR0M3TH3AN fde5dbc67d test: Add comprehensive tests for memoryStats function
Adds `test/memory-stats.test.mjs` to validats `memoryStats` behavior including:
- Empty and populated repository states
- Ingest throughput calculation with mocked time
- Deleted rate metrics
- Window parameter handling

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-17 18:53:07 +00:00
google-labs-jules[bot]andPR0M3TH3AN e8cad0b42d feat(test): add unit tests for ingestEvents in memory service
Added `test/memory-ingest.test.mjs` to cover `ingestEvents` functionality.
Tests cover:
- Happy path ingestion with mocked repository and telemetry.
- Feature flag handling (skipping ingestion when disabled).
- Cache invalidation after ingestion.
- Deduplication logic.
- Error propagation from repository.

This improves test coverage for the memory service and ensures reliability of the ingestion process.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-17 18:53:00 +00:00
google-labs-jules[bot]andPR0M3TH3AN 5f0aefe67e test: add comprehensive tests for renderPromptWithMemoryContext
Adds test cases for `renderPromptWithMemoryContext` in `src/services/memory/formatter.js`, covering:
- Agent context serialization (arrays, objects, primitives)
- Memory usage updates side effects
- Edge cases for empty/null memories
- Feature flag handling (global toggle and allowlist)
- Parameter passing (k, tokenBudget)

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-17 18:52:30 +00:00
google-labs-jules[bot]andPR0M3TH3AN 33bde42591 feat(test): add unit tests for memory ingestEvents
Added comprehensive unit tests for `ingestEvents` in `src/services/memory/index.js`.
Tests cover:
- Happy path ingestion with mocked repository and telemetry.
- Feature flag skipping behavior.
- Cache clearing side effects.
- Deduplication logic.
- Error handling.

This improves test coverage and reliability for the memory service.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-17 18:52:27 +00:00
google-labs-jules[bot]andPR0M3TH3AN 526b6a34c7 test: add unit tests for getCompletedAgents in src/lock-utils.mjs
Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-17 18:50:12 +00:00
thePR0M3TH3AN b3f4a5c9cd Merge pull request #242 from PR0M3TH3AN/scheduler-cycle-optimization-6566135138689301144
⚡ Optimize scheduler cycle log reading performance
2026-02-17 13:38:36 -05:00
thePR0M3TH3AN 39b7783899 Merge pull request #241 from PR0M3TH3AN/refactor-usage-text-5134896285807665530
🧹 Refactor usage text to constants
2026-02-17 13:38:21 -05:00
thePR0M3TH3AN 8701ea6eb2 Merge pull request #240 from PR0M3TH3AN/test-circular-agent-context-2548280250167598137
test: add coverage for circular agentContext in memory formatter
2026-02-17 13:38:08 -05:00
thePR0M3TH3AN 651e5e659f Merge branch 'main' into test-circular-agent-context-2548280250167598137 2026-02-17 13:38:01 -05:00
thePR0M3TH3AN f0437a9647 Merge pull request #231 from PR0M3TH3AN/code-health/relay-health-comment-8690906014173608719
Sweep: Add comment to swallowed error in relay-health.mjs
2026-02-17 13:37:43 -05:00
google-labs-jules[bot]andPR0M3TH3AN 32ba0d2621 perf(scheduler): parallelize log file reading in getLatestFile
Optimizes the `getLatestFile` function in `scripts/agent/run-scheduler-cycle.mjs` by parallelizing the reading and parsing of log files using `Promise.all`. This replaces the sequential `for...of` loop which caused I/O bottlenecks when processing large numbers of log files.

Measured improvement: ~56% faster (530ms -> 207ms) for 1000 log files.

Also removed a tracked `test_output.log` file that shouldn't be in the repository.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-17 18:37:39 +00:00
thePR0M3TH3AN d3926f8a36 Merge pull request #234 from PR0M3TH3AN/test-memory-formatter-circular-context-16916269218151396900
🧪 Add test for circular agentContext in renderPromptWithMemoryContext
2026-02-17 13:37:29 -05:00
thePR0M3TH3AN ef3e20b1aa Merge pull request #232 from PR0M3TH3AN/test/unpin-memory-coverage-10292270866664076558
🧪 Test unpinMemory function
2026-02-17 13:37:15 -05:00