Commit Graph
79 Commits
Author SHA1 Message Date
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
thePR0M3TH3AN 651e5e659f Merge branch 'main' into test-circular-agent-context-2548280250167598137 2026-02-17 13:38:01 -05: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 88bb2e8fff Merge branch 'main' into test/unpin-memory-coverage-10292270866664076558 2026-02-17 13:37:09 -05:00
thePR0M3TH3AN 3f93916372 Merge pull request #239 from PR0M3TH3AN/test-unpinMemory-improvement-14234727575040674588
🧪 Add unit tests for unpinMemory
2026-02-17 13:36:49 -05:00
thePR0M3TH3AN f815ab3f59 Merge pull request #238 from PR0M3TH3AN/test-improvement-relay-health-11069753813571179653
test(relay-health): add unit tests for summarizeHistory
2026-02-17 13:36:22 -05:00
google-labs-jules[bot]andPR0M3TH3AN e5b2394284 test: add coverage for circular agentContext in memory formatter
Add a test case to `test/memory-formatter.test.mjs` to ensure that `renderPromptWithMemoryContext` handles circular references in `agentContext` by falling back to `String(agentContext)` instead of throwing a `JSON.stringify` error.

This addresses a missing edge case in JSON serialization testing.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-17 18:33:44 +00:00
google-labs-jules[bot]andPR0M3TH3AN 0851d875a4 test(memory): add unit tests for unpinMemory
Adds focused unit tests for `unpinMemory` in `test/memory-pinning.test.mjs` to ensure it correctly updates the repository and clears the cache. Covers both happy path and non-existent ID scenarios.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-17 18:33:44 +00:00
google-labs-jules[bot]andPR0M3TH3AN 58660f9390 test(relay-health): add unit tests for summarizeHistory
Added comprehensive unit tests for `summarizeHistory` in `src/relay-health.mjs`.
- Covers success rate calculation, window filtering, and all-down duration logic.
- Includes edge cases for empty history and malformed entries.
- Improves test coverage for relay health monitoring logic.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-17 18:33:39 +00:00
google-labs-jules[bot]andPR0M3TH3AN 73c5f22932 test(memory): add test for circular agentContext in renderPromptWithMemoryContext
Adds a test case to `test/memory-formatter.test.mjs` to verify that `renderPromptWithMemoryContext` gracefully handles circular references in `agentContext` by falling back to string representation instead of throwing a JSON serialization error. This ensures the edge case at `src/services/memory/formatter.js:125` is covered.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-17 18:32:46 +00:00
google-labs-jules[bot]andPR0M3TH3AN 67a6b91d92 Refactor: Unify string list parsing in torch-config
- Introduced `parseStringList` helper to handle parsing of string arrays from config.
- Replaced `parseRelayList` and `parseRoster` with `parseStringList`.
- Replaced inline parsing of `relays` and `dashboard.relays` with `parseStringList`.
- Unified behavior: empty lists in config now consistently return `null` instead of `[]`.
- Added unit test verifying consistent `null` return for empty lists.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-17 18:32:40 +00:00
google-labs-jules[bot]andPR0M3TH3AN 969a7d41e7 test(memory): add unit tests for unpinMemory
Added unit tests to `test/memory-pinning.test.mjs` to cover the `unpinMemory` function.
Tests verify:
- Successful unpinning and cache clearing.
- Handling of non-existent IDs (returns null) and cache clearing.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-17 18:32:35 +00:00
thePR0M3TH3AN c549c0e8b0 Merge pull request #227 from PR0M3TH3AN/test-mark-memory-merged-6408631238217390232
test(memory): add tests for markMemoryMerged
2026-02-17 13:10:10 -05:00
thePR0M3TH3AN e61b4e3d4a Merge pull request #226 from PR0M3TH3AN/memory-telemetry-fix-8633028829140804238
🧹 Use util.debuglog for memory telemetry
2026-02-17 13:09:23 -05:00
thePR0M3TH3AN 8f51d74955 Merge pull request #229 from PR0M3TH3AN/fix/dashboard-config-security-7655777063695938949
🔒 Fix security vulnerability: Sanitize torch-config.json exposure
2026-02-17 13:09:02 -05:00
thePR0M3TH3AN 127ec4102e Merge pull request #228 from PR0M3TH3AN/fix-dashboard-file-access-vulnerability-3711172732020694981
🔒 Fix unrestricted file access in dashboard
2026-02-17 13:07:04 -05:00
google-labs-jules[bot]andPR0M3TH3AN 88506ad6e4 fix(security): sanitize torch-config.json response in dashboard
The dashboard previously served the raw `torch-config.json` file, potentially exposing sensitive information like authentication credentials.
This commit modifies the `/torch-config.json` endpoint to:
1. Parse the configuration file.
2. Sanitize the output by removing the `dashboard.auth` field and any unknown fields (using `parseTorchConfig`).
3. Support `TORCH_CONFIG_PATH` environment variable for configuration file location, improving testability and consistency with other components.

Verified with new test `test/dashboard-config-security.test.mjs` and existing auth tests.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-17 17:36:56 +00:00
google-labs-jules[bot]andPR0M3TH3AN 171836d2ac fix: restrict dashboard file access to allowed directories
This patch addresses a security vulnerability where the dashboard server could serve any file from the package root.

Changes:
- Implemented an allowlist in `src/dashboard.mjs` to restrict file access to:
  - `dashboard/`
  - `assets/`
  - `src/docs/`
  - `torch-config.json`
- Added `test/dashboard-security.test.mjs` to verify the fix and prevent regressions.

The fix ensures that sensitive files like `package.json` or source code cannot be accessed via the dashboard server.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-17 17:35:32 +00:00
google-labs-jules[bot]andPR0M3TH3AN 78c31e828d test(memory): add tests for markMemoryMerged and enable dependency injection
- Update `markMemoryMerged` to accept `options.repository` for better testability.
- Add unit tests in `test/memory-admin.test.mjs` to verify:
  - Delegation to repository.
  - Cache clearing side effect.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-17 17:32:45 +00:00
google-labs-jules[bot]andPR0M3TH3AN 53aa68ac64 Refactor memory telemetry to use util.debuglog
Replaced `console.log` with `util.debuglog('torch-memory')` in `src/services/memory/index.js` to prevent stdout pollution. Telemetry and metrics are now logged to stderr only when `NODE_DEBUG=torch-memory` is set, improving library behavior and observability control.

Added regression test `test/memory-telemetry.test.mjs`.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-17 17:31:52 +00:00
google-labs-jules[bot]andPR0M3TH3AN a3b181b3d8 test: add unit tests for pinMemory and fix dependency injection in getRelevantMemories
- Add `test/memory-pinning.test.mjs` to test `pinMemory` happy path and edge cases.
- Update `getRelevantMemories` in `src/services/memory/index.js` to use `repository.listMemories` when available, enabling isolated unit testing.
- Verified all memory tests pass.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-17 17:31:44 +00:00
thePR0M3TH3AN 4d11b2b710 Merge pull request #224 from PR0M3TH3AN/jules-fix-dashboard-auth-11280121515374886398-56017a2b
🔒 Add Authentication and Local Host Binding to Dashboard
2026-02-17 12:24:47 -05:00
google-labs-jules[bot]andPR0M3TH3AN 456bc2df18 feat(security): add authentication and host binding to dashboard
This commit addresses the missing authentication vulnerability in the
dashboard server.

Changes:
- Added Basic Authentication support via TORCH_DASHBOARD_AUTH env var
  or dashboard.auth config field.
- Defaulted dashboard host binding to 127.0.0.1 for better security.
- Added --host CLI argument to allow overriding the bind address.
- Used crypto.timingSafeEqual for secure credential comparison.
- Fixed a potential crash when parsing malformed Authorization headers.
- Added comprehensive unit tests for dashboard authentication.
- Updated documentation in README.md and torch-config.example.json.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-17 17:24:33 +00:00
thePR0M3TH3AN 3ff9e25464 Merge pull request #222 from PR0M3TH3AN/test-memory-formatter-3246489614731328152
🧪 add unit tests for memory formatter
2026-02-17 12:11:03 -05:00
google-labs-jules[bot]andPR0M3TH3AN 20ba1567d8 test: add unit tests for memory formatter
- Added `test/memory-formatter.test.mjs` with comprehensive unit tests for:
  - `estimateTokenCount`
  - `formatMemoryBlock`
  - `formatMemoriesForPrompt`
  - `renderPromptWithMemoryContext`
- Verified all tests pass and no regressions in related tests.
- Addressed testing gap in `src/services/memory/formatter.js`.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-17 17:10:52 +00:00
google-labs-jules[bot]andPR0M3TH3AN a437ddd9f7 chore(ai): refactor duplicated copying logic in src/ops.mjs
- Extracted `syncAppDirectories` and `syncAppFiles` helper functions.
- Updated `cmdInit` and `cmdUpdate` to use the new helpers.
- Improved `cmdInit` to throw an Error instead of warning when the target directory is not empty and not forced.
- Fixed hanging tests in `test/ops.test.mjs` by providing `MOCK_CONFIG`.
- Updated tests to verify strict directory check in `cmdInit`.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-17 17:09:39 +00:00
google-labs-jules[bot]andPR0M3TH3AN 5f35dde296 Fix dashboard build failure and missing documentation
- Updated `build.mjs` to correctly source `TORCH.md` and `docs/` from the project root instead of the non-existent `src/docs/`.
- Ensured `TORCH.md` is copied to `dist/src/docs/TORCH.md` as expected by the dashboard's fetch logic.
- Added `test/build_verification.test.mjs` to prevent regressions by verifying the presence of critical build artifacts (`TORCH.md`, assets, dashboard).
- Verified dashboard functionality (logos, settings modal) using a temporary Playwright script.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-17 03:53:55 +00:00
google-labs-jules[bot]andPR0M3TH3AN c6428c42c8 Implement persistent JSON memory store and disable embeddings
Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-15 23:18:13 +00:00
google-labs-jules[bot]andPR0M3TH3AN 754a1c2ce1 feat: support platform and model info in nostr lock events
This change enables agents to report their execution platform (e.g., Jules, Codex, Goose) and model (e.g., DeepSeek 3.2) in the Nostr lock events.

Key changes:
- Updated `torch-lock` CLI to accept `--platform` and `--model` arguments.
- Implemented `detectPlatform` utility to infer platform from environment variables if not provided.
- Updated `src/lib.mjs` to include these fields in the event content.
- Updated `scripts/agent/run-scheduler-cycle.mjs` to propagate `--model` and `AGENT_MODEL`.
- Updated `dashboard/index.html` to display the model information on the lock card.
- Fixed a regression in `scripts/validate-scheduler-flow-parity.mjs` and `test/scheduler-ratchet.test.mjs` caused by argument string matching.
- Deleted `repro_test.mjs` temporary file.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-15 20:18:59 +00:00
google-labs-jules[bot]andPR0M3TH3AN dba1d43c94 refactor(core): extract parseArgs to cli-parser.mjs
- Extracted `parseArgs` function from `src/lib.mjs` to `src/cli-parser.mjs`.
- Added unit tests for argument parsing logic in `test/cli-parser.test.mjs`.
- Updated `src/lib.mjs` to import `parseArgs`.
- Fixed roster drift in `src/prompts/weekly-scheduler.md` to match `roster.json`.
- Verified with `npm test` and `npm run lint`.
- Completed weekly scheduler task for `refactor-agent`.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-15 15:49:29 +00:00
google-labs-jules[bot]andPR0M3TH3AN 1d4097483c Fix race condition in cmdLock sort order
- Add deterministic tie-breaker (eventId) for lock events with identical timestamps in `src/lib.mjs`.
- Add regression tests in `test/lib.test.mjs` verifying win/loss conditions.
- Create weekly race condition report and run artifacts.
- Mark `race-condition-agent` task as completed.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-15 15:31:28 +00:00
thePR0M3TH3AN 969b72d3e1 Add scheduler error rendering snapshot coverage 2026-02-14 20:10:26 -05:00
thePR0M3TH3AN 6259f7f2f5 Add ci-resilience lock acquisition test suite 2026-02-14 20:06:30 -05:00
thePR0M3TH3AN c1d0de071c test: add scheduler lock failure frontmatter contract coverage 2026-02-14 20:01:32 -05:00
thePR0M3TH3AN ccc76d8b51 Add scheduler lock preflight e2e coverage 2026-02-14 19:56:25 -05:00
thePR0M3TH3AN 4349485ef1 Add relay fanout quorum integration tests 2026-02-14 19:51:56 -05:00
thePR0M3TH3AN aad60b795a test: add publish retry matrix coverage for lock backend 2026-02-14 19:47:32 -05:00
thePR0M3TH3AN 874747de91 Classify scheduler failures and document lock remediation 2026-02-14 19:42:03 -05:00
thePR0M3TH3AN 1e97118e8b Add relay health preflight job and scheduler deferral handling 2026-02-14 19:35:56 -05:00
thePR0M3TH3AN 46198a500e Improve lock publish diagnostics and scheduler failure summaries 2026-02-14 19:30:00 -05:00
thePR0M3TH3AN 9aad0d933d Add lock deferral policy for scheduler backend failures 2026-02-14 19:23:37 -05:00
thePR0M3TH3AN 57ba0fe4f4 Improve lock relay health ranking and quarantine handling 2026-02-14 19:15:31 -05:00
thePR0M3TH3AN f22bcfb713 Add bounded retry logic for lock publish quorum 2026-02-14 19:08:53 -05:00
thePR0M3TH3AN 84d3e7eded Harden lock backend config validation and fallback behavior 2026-02-14 18:48:21 -05:00
thePR0M3TH3AN ecb26dfa99 Improve scheduler lock observability and reliability reporting 2026-02-14 18:42:52 -05:00
thePR0M3TH3AN bc51e2f2e8 Add scheduler relay health preflight gate 2026-02-14 18:36:01 -05:00
thePR0M3TH3AN 9c069f75a6 Add scheduler lock retries for backend failures 2026-02-14 18:29:55 -05:00
thePR0M3TH3AN c38dfe1258 Enrich scheduler lock backend failure logging 2026-02-14 18:23:52 -05:00
google-labs-jules[bot]andPR0M3TH3AN 0f3fd3209f feat: random namespace generation in init
This commit updates the `npx torch-lock init` command to automatically generate a `torch-config.json` file if it doesn't already exist. The generated configuration includes a randomized `nostrLock.namespace` (e.g., `torch-a1b2c3d4`) to ensure unique discovery topics for each installation, preventing message collisions across different repositories.

- Modified `src/ops.mjs` to import `crypto` and implement the config generation logic in `cmdInit`.
- Added a test case in `test/ops.test.mjs` to verify the random namespace generation.
- Uses `torch-config.example.json` as a template.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-14 23:19:25 +00:00
thePR0M3TH3AN 909a7f9541 Strengthen run-artifact verification metadata and issue linkage 2026-02-14 18:05:54 -05:00