Commit Graph
100 Commits
Author SHA1 Message Date
google-labs-jules[bot]andPR0M3TH3AN babdd4af5d Add Home button to dashboard linking to landing page
Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-20 04:04:28 +00:00
google-labs-jules[bot]andPR0M3TH3AN 439e08042c docs: update README.md and TORCH.md with scheduler and lock commands
- Added `scheduler:daily` and `scheduler:weekly` usage examples to README.md and TORCH.md.
- Added `lock:complete` and `lock:check:daily` usage examples to README.md and TORCH.md.
- Updated TODO list to reflect completion of documentation alignment.
- Verified script presence and syntax.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-20 03:52:47 +00:00
google-labs-jules[bot]andPR0M3TH3AN 9e6d99eb1e ⚡ optimize lexical search with inverted index
- Implemented LexicalIndex class in src/services/memory/retriever.js.
- Added WeakMap caching for indices based on memory array references.
- Improved memory array stability in src/services/memory/index.js using a storeVersion counter.
- Achieved ~2x speedup for 10k memories and ~9x speedup for 100k memories in benchmarks.
- Maintains compatibility with existing textMatchSimilarity scoring.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-20 03:51:34 +00:00
google-labs-jules[bot]andPR0M3TH3AN cd744982a1 refactor(governance): extract duplicated target validation logic
Extracted duplicated target path resolution and allowlist validation logic
into a shared `resolveAndValidateTarget` helper function in
`src/services/governance/index.js`.

Updated `createProposal`, `validateProposal`, `applyProposal`, and
`rollbackPrompt` to use the new helper, ensuring consistent validation
and path handling across the service.

Added `test/governance-health.test.mjs` to verify validation logic.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-20 03:50:36 +00:00
google-labs-jules[bot]andPR0M3TH3AN 8d4ae0d616 feat(testing): add unit tests for ExitError and improve class definition
- Added `test/errors.test.mjs` with comprehensive tests for the `ExitError` class.
- Updated `src/errors.mjs` to set `this.name = 'ExitError'` in the constructor for better error reporting.
- Verified that all new tests pass and no regressions were introduced to the existing test suite.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-20 03:49:34 +00:00
google-labs-jules[bot]andPR0M3TH3AN 1e4d9720e8 fix(security): prevent command injection in governance service
Replaced `execSync` with `execFileSync` in `src/services/governance/index.js` to avoid shell interpretation of variable-derived inputs (such as agent IDs and file targets). This mitigates command injection risks in `createProposal`, `applyProposal`, and `rollbackPrompt`.

- Used `execFileSync` for all git operations.
- Updated logic to correctly handle `git diff` exit code 1.
- Removed unused `execSync` import.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-20 03:46:36 +00:00
google-labs-jules[bot]andPR0M3TH3AN 08d8407a7d feat(cli): enhance init output with config summary and dashboard link
- Updates `cmdInit` to output the Nostr hashtag, namespace, and a direct dashboard URL upon completion.
- Refactors `createDashboardLinkFile` to return the generated URL for console output.
- Ensures the initialization process provides clear next steps for both human users and agents.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-20 03:39:00 +00:00
google-labs-jules[bot]andPR0M3TH3AN a61079b505 Add Qwen Coder to landing page and platform detection
- Added Qwen Coder CLI to `landing/index.html` agent selector.
- Updated `src/utils.mjs` to detect `QWEN_API_KEY` or `QWEN_SESSION_ID` as 'qwen' platform.
- Updated `dashboard/app.js` to render Qwen tasks with appropriate badge styling.
- Added tests for Qwen platform detection in `test/utils.test.mjs`.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-20 02:42:08 +00:00
google-labs-jules[bot]andPR0M3TH3AN 0b9dfa60ce docs: align README and TORCH.md with package.json scripts
- Added `npm run scheduler:daily` to docs
- Added `npm run scheduler:weekly` to docs
- Added `npm run lock:complete` to docs
- Generated task log and artifacts for docs-alignment-agent run

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-20 02:35:34 +00:00
google-labs-jules[bot]andPR0M3TH3AN 9a28e07547 feat: Add Codex CLI (Active) and OpenCode CLI (Coming Soon) to landing page
- Enable Codex CLI card in `landing/index.html`.
- Add description "Requires full access permissions" to Codex CLI.
- Add "OpenCode CLI" as a "Coming Soon" option.
- Update `selectAgent` JavaScript to handle Codex selection.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-20 02:22:39 +00:00
google-labs-jules[bot]andPR0M3TH3AN 925ead1523 docs(scheduler): run docs-agent cycle
Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-20 02:15:11 +00:00
google-labs-jules[bot]andPR0M3TH3AN 2cba102998 Run deps-security-agent (daily cadence)
- Audited dependencies (npm audit, npm outdated)
- Generated security report
- Created scheduler run artifacts
- Created completion log

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-20 01:19:41 +00:00
google-labs-jules[bot]andPR0M3TH3AN b8598d1d92 feat: Decompose src/lock-ops.mjs into relay-health-manager.mjs and lock-publisher.mjs
- Extracted `RelayHealthManager` to `src/relay-health-manager.mjs`
- Extracted `LockPublisher` to `src/lock-publisher.mjs`
- Refactored `src/lock-ops.mjs` to import new modules
- Reduced `src/lock-ops.mjs` size significantly (> 500 lines)
- Preserved API compatibility (re-exported `defaultHealthManager`)
- Verified with lint and tests
- Updated `scripts/check-file-size.mjs` report (implicit)

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-20 00:36:49 +00:00
google-labs-jules[bot]andPR0M3TH3AN 8653521593 [decompose] extract RelayHealthManager and LockPublisher from src/lock-ops.mjs
- Extracted `RelayHealthManager` to `src/relay-health-manager.mjs`
- Extracted `LockPublisher` to `src/lock-publisher.mjs`
- Moved shared utilities to `src/lock-utils.mjs`
- Updated `src/lock-ops.mjs` to import dependencies and re-export public API
- Reduced `src/lock-ops.mjs` from 880 to 152 lines
- Verified with tests (295 passed) and linting

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-19 23:41:10 +00:00
google-labs-jules[bot]andPR0M3TH3AN 916a91b470 chore: run content-audit-agent
Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-19 22:35:48 +00:00
google-labs-jules[bot]andPR0M3TH3AN 2662e5bd45 feat(landing): Add warm accent colors, animated SVG background, and scroll reveal animations
Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-19 22:28:48 +00:00
google-labs-jules[bot]andPR0M3TH3AN e65e044941 Update agent descriptions in landing/index.html
- Jules: Web-based tool with Auto-Scheduler
- Claude Code CLI: CLI Required, needs cronjob
- Gemini CLI: CLI Required, needs cronjob
- Antigravity IDE: Manual only

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-19 22:15:31 +00:00
google-labs-jules[bot]andPR0M3TH3AN 016f3e34e2 feat: generate dashboard file and config hashtag during init
This change updates the `torch init` command to:
1.  Prompt the user for a Nostr hashtag (defaulting to `${namespace}-agent-lock`).
2.  Explicitly save the `hashtag` to `torch-config.json` under `dashboard.hashtag` for easier editing.
3.  Generate a `TORCH_DASHBOARD.md` file in the installation directory containing a link to the TORCH dashboard with the correct `hashtag`, `namespace`, and `relays` pre-filled.

This improves the onboarding experience by making it easier to find and monitor the agent locks immediately after initialization.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-19 21:45:19 +00:00
google-labs-jules[bot]andPR0M3TH3AN abb4cc4361 feat(dashboard): add support for Goose, Gemini, and Antigravity platforms
- Update `src/utils.mjs` to detect `gemini` and `antigravity` platforms via environment variables.
- Update `dashboard/styles.css` with new color utilities for purple and pink themes.
- Update `dashboard/app.js` to map Goose, Gemini, and Antigravity platforms to distinct badge colors.
- Update `test/utils.test.mjs` to include unit tests for the new platform detection logic.

This ensures all active agent platforms are correctly identified and labeled in the TORCH dashboard.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-19 21:39:32 +00:00
google-labs-jules[bot]andPR0M3TH3AN b457025a8a [constants] Fix CI failure in test/scheduler-preflight-lock.e2e.test.mjs
- Added missing copy of `src/constants.mjs` to test fixture in `test/scheduler-preflight-lock.e2e.test.mjs`
- Verified fix with `npm run test:integration:e2e`

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-19 21:37:57 +00:00
google-labs-jules[bot]andPR0M3TH3AN 2174e8bc4d [constants] Refactor 1000 to MS_PER_SECOND
- Extracted MS_PER_SECOND to src/constants.mjs
- Replaced literal 1000 in src/relay-health.mjs, src/utils.mjs, src/lib.mjs, src/lock-ops.mjs
- Updated test/scheduler-lock-failure-schema.contract.test.mjs to copy constants.mjs
- Added task log and artifacts

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-19 21:34:50 +00:00
google-labs-jules[bot]andPR0M3TH3AN c00897983e Add Gemini CLI to landing page agent selector
- Add Gemini CLI card to landing/index.html
- Update selectAgent function to support Gemini
- Verified visually via Playwright script

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-19 21:18:32 +00:00
google-labs-jules[bot]andPR0M3TH3AN efe31f7c33 feat(landing): move meta prompts and add antigravity ide
- Moved the "Scheduler Meta Prompts" section to be above the "Functional Agents" section in `landing/index.html`.
- Added "Antigravity IDE" as a new option in the "Choose Your Agent" section with a corresponding install prompt.
- Verified changes with Playwright script and manual inspection of the HTML structure.
- Tests passed.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-19 20:52:39 +00:00
google-labs-jules[bot]andPR0M3TH3AN b002963cf9 feat: Enable Claude Code CLI option on landing page and add dynamic prompt selection
Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-19 20:16:16 +00:00
google-labs-jules[bot]andPR0M3TH3AN 33bd7a3e76 Update landing page to use simpler, round-robin scheduler language
Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-19 20:03:28 +00:00
google-labs-jules[bot]andPR0M3TH3AN ab99339311 docs: add TORCH evolution concept and roadmap
Adds a detailed architectural opinion/RFC in `docs/TORCH_EVOLUTION_CONCEPT.md` outlining the transition from a linear scheduler to a node-based workflow orchestrator. This document includes recommendations for UI (React Flow), integrations (OpenClaw, ClaudeCode CLI), and a phased roadmap.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-19 19:43:09 +00:00
google-labs-jules[bot]andPR0M3TH3AN d1e69ba48c chore(scheduler): run torch-garbage-collection-agent daily cycle
Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-19 19:18:16 +00:00
google-labs-jules[bot]andPR0M3TH3AN fdfd0b9348 feat(scheduler): execute daily todo-triage-agent run
- Install dependencies via `npm ci`
- Run preflight lock check
- Select `todo-triage-agent` (skipping locked agents)
- Execute `todo-triage-agent` prompt:
  - Scan codebase for TODOs (none found)
  - Generate required artifacts in `src/context`, `src/todo`, `src/decisions`, `src/test_logs`
- Verify run artifacts
- Publish lock completion
- Create final task log

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-19 18:15:59 +00:00
google-labs-jules[bot]andPR0M3TH3AN c6b73959fc chore(scheduler): Execute daily test-audit-agent
Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-19 17:00:24 +00:00
google-labs-jules[bot]andPR0M3TH3AN cc9a3fe69e Fix CI failure: copy missing deps & symlink node_modules in memory policy test
- Updates `test/run-scheduler-cycle-memory-policy.test.mjs` to copy `src/utils.mjs`, `src/torch-config.mjs`, `src/constants.mjs`, `src/relay-health.mjs`, and `src/lock-ops.mjs` to the temporary test environment.
- Symlinks `node_modules` into the test environment to resolve external dependencies (e.g., `nostr-tools`).
- Resolves `ERR_MODULE_NOT_FOUND` errors during CI.
- Includes Protocol Research Agent daily run artifacts (Protocol Inventory update and Report).

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-19 13:29:58 +00:00
google-labs-jules[bot]andPR0M3TH3AN 09268c2d4c chore(scheduler): run weekly pr-review-agent cycle
- Executed weekly scheduler cycle for pr-review-agent.
- Generated task log for simulated run failure (due to missing artifacts in simulation).
- Ensured log filename is cross-platform compatible.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-19 05:09:57 +00:00
google-labs-jules[bot]andPR0M3TH3AN a4766fe745 chore(ai): run style-agent daily task
Executed style-agent for daily cadence.
Ran npm run lint (and --fix), npm run build, and npm test.
Verified no style issues were auto-fixable.
Created completion log.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-19 02:28:27 +00:00
google-labs-jules[bot]andPR0M3TH3AN 69b605efcd fix(test): set AGENT_PLATFORM=codex in scheduler memory policy tests
Explicitly defaults `AGENT_PLATFORM` to `'codex'` in the test environment for `run-scheduler-cycle-memory-policy.test.mjs`. This resolves assertion failures where tests expected platform metadata (e.g., `platform: 'codex'`) but received `'unknown'` in CI environments where the variable is unset.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-19 02:19:42 +00:00
google-labs-jules[bot]andPR0M3TH3AN bf41f181ee fix(test): inject AGENT_PLATFORM=codex in scheduler cycle tests
- Explicitly sets `AGENT_PLATFORM: 'codex'` in `test/run-scheduler-cycle-memory-policy.test.mjs` for tests that assert platform-specific output.
- Resolves CI failures where `detectPlatform` was falling back to `'unknown'` or the host environment's platform, causing assertion mismatches.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-19 01:09:14 +00:00
google-labs-jules[bot]andPR0M3TH3AN e4fecf631b fix(test): copy src/utils.mjs to temp dir in scheduler cycle test
- Addresses `ERR_MODULE_NOT_FOUND` in `test/run-scheduler-cycle-memory-policy.test.mjs` caused by missing dependency in the temporary test environment.
- Ensures `src/utils.mjs` is available for `scripts/agent/run-scheduler-cycle.mjs` during test execution.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-19 01:04:59 +00:00
google-labs-jules[bot]andPR0M3TH3AN 031f042ee0 fix(landing): improve mobile responsiveness for modal and meta prompts
- Update `.prompts-grid` to use `minmax(280px, 1fr)` instead of `400px` to fit mobile screens.
- Add media query to reduce `.meta-prompts` padding on small screens.
- Add `word-break: break-all` and `overflow-wrap: break-word` to `#promptModal` code blocks to prevent horizontal overflow.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-19 01:00:20 +00:00
google-labs-jules[bot]andPR0M3TH3AN afefda9281 fix(test): copy src/utils.mjs to temp env in scheduler tests
Resolves `ERR_MODULE_NOT_FOUND` in `run-scheduler-cycle-memory-policy.test.mjs` by explicitly copying `src/utils.mjs` to the temporary test directory structure, satisfying the import dependency of `scripts/agent/run-scheduler-cycle.mjs`.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-19 00:58:25 +00:00
google-labs-jules[bot]andPR0M3TH3AN 58000b69ad Run protocol-research-agent (Daily)
- Executed protocol-research-agent prompt
- Verified PROTOCOL_INVENTORY.md
- Created src/context/CONTEXT_2026-02-19.md
- Created reports/protocol/protocol-report-2026-02-19.md
- Created task-logs/daily/2026-02-19T00-42-38Z__protocol-research-agent__completed.md

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-19 00:45:34 +00:00
google-labs-jules[bot]andPR0M3TH3AN b6af6f49bf feat(scheduler): execute daily perf-agent run
- Execute `perf-agent` as part of the daily schedule.
- Generate performance reports `reports/performance/hits-2026-02-19.json` and `reports/performance/daily-perf-report-2026-02-19.md`.
- Create required run artifacts in `src/context/`, `src/todo/`, `src/decisions/`, and `src/test_logs/` with strict metadata.
- Validate run artifacts and linting.
- Publish task completion via `torch-lock`.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-19 00:29:33 +00:00
google-labs-jules[bot]andPR0M3TH3AN d6a1e22f56 chore(scheduler): Execute onboarding-audit-agent
- Executed onboarding-audit-agent daily task.
- Validated onboarding from a clean checkout (npm install, build, test, lint).
- Updated package-lock.json with missing metadata (license, engines).
- Created audit report in reports/audit/.
- Created required context/todo/decision artifacts in src/.
- Completed scheduler lock cycle.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-18 23:23:51 +00:00
google-labs-jules[bot]andPR0M3TH3AN ac87628317 chore(scheduler): execute daily log-fixer-agent run
Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-18 22:31:57 +00:00
google-labs-jules[bot]andPR0M3TH3AN 23bb42a20c Fix: Update e2e test to allow 'unknown' platform
- Updated `test/scheduler-preflight-lock.e2e.test.mjs` to expect `detectPlatform() || 'unknown'` instead of hardcoding `'codex'`.
- This ensures the test passes in CI environments where `detectPlatform()` returns `null`, causing the script to default to `'unknown'`, as well as in local environments where it detects a platform like `'jules'`. This aligns with the updated default logic in `run-scheduler-cycle.mjs`.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-18 21:55:00 +00:00
google-labs-jules[bot]andPR0M3TH3AN f003970195 Fix: Update e2e test to match detected platform
- Updated `test/scheduler-preflight-lock.e2e.test.mjs` to expect `detectPlatform() || 'codex'` instead of hardcoding `'codex'`.
- This ensures the test passes when running in environments where the platform is correctly detected (e.g., 'jules'), aligning with the changes made in the previous commit.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-18 21:51:11 +00:00
google-labs-jules[bot]andPR0M3TH3AN c1a4499499 Fix: Correctly detect agent platform and fix test fixture
- Updated `src/utils.mjs` to detect 'claude' platform via `CLAUDE_API_KEY`, `ANTHROPIC_API_KEY`, or `CLAUDE_SESSION_ID`.
- Updated `scripts/agent/scheduler-utils.mjs` `getSafeEnv` to preserve `JULES_`, `CODEX_`, `CLAUDE_`, `ANTHROPIC_`, and `GOOSE_` environment variables when spawning child processes.
- Updated `scripts/agent/run-scheduler-cycle.mjs` to use `detectPlatform()` as a fallback for `AGENT_PLATFORM` instead of hardcoding `'codex'`, ensuring the correct platform is used for lock creation.
- Added unit tests for `detectPlatform` in `test/utils.test.mjs`.
- Fixed `test/scheduler-lock-failure-schema.contract.test.mjs` to include `src/utils.mjs` in the temporary test environment, resolving `ERR_MODULE_NOT_FOUND`.

This resolves the issue where lock cards displayed "Unknown" or incorrect platforms and fixes the resulting CI failure.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-18 21:46:40 +00:00
google-labs-jules[bot]andPR0M3TH3AN ae2e382bfd Fix: Correctly detect agent platform for locks
- Updated `src/utils.mjs` to detect 'claude' platform via `CLAUDE_API_KEY`, `ANTHROPIC_API_KEY`, or `CLAUDE_SESSION_ID`.
- Updated `scripts/agent/scheduler-utils.mjs` `getSafeEnv` to preserve `JULES_`, `CODEX_`, `CLAUDE_`, `ANTHROPIC_`, and `GOOSE_` environment variables when spawning child processes.
- Updated `scripts/agent/run-scheduler-cycle.mjs` to use `detectPlatform()` as a fallback for `AGENT_PLATFORM` instead of hardcoding `'codex'`, ensuring the correct platform is used for lock creation.
- Added unit tests for `detectPlatform` in `test/utils.test.mjs`.

This resolves the issue where lock cards displayed "Unknown" or incorrect platforms.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-18 21:42:56 +00:00
google-labs-jules[bot]andPR0M3TH3AN dd9e5b7921 feat: add standard CI workflow and fix lint/test failures
- Added `.github/workflows/ci.yml` to run build, lint, and test on PRs/push to main.
- Updated `.github/workflows/ci-resilience-nightly.yml` to use Node.js 22.
- Fixed lint errors in `src/services/governance/index.js` (no-empty, preserve-caught-error).
- Added `governance-agent` to daily roster and scheduler prompt to fix `npm test` scheduler validation failure.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-18 21:24:43 +00:00
google-labs-jules[bot]andPR0M3TH3AN 64b6f43df1 feat: add governance system for prompt evolution
Implement a comprehensive governance system to manage agent prompt changes safely.

Key features:
- **Proposal Workflow:** Prompt changes are now "proposals" stored in `src/proposals/` with metadata and diffs.
- **Governance Agent:** A new `governance-agent` reviews and applies proposals using `scripts/governance/process-proposals.mjs`.
- **Validation:** Strict validation ensures changes are limited to allowed directories (`src/prompts/daily|weekly`) and preserve required headers.
- **Lock Enhancements:** Lock events now include `promptHash`, `promptPath`, and `gitCommit` for full auditability.
- **Rollback:** New `torch-lock rollback` command restores prompts from local history (`.torch/prompt-history/`) or git.
- **CLI:** Added `proposal` (create, list, show, apply, reject) and `rollback` commands.

This establishes a "Stage -> Evaluate -> Apply" gate for prompt evolution, preventing silent drift and ensuring constitutional stability.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-18 21:09:39 +00:00
google-labs-jules[bot]andPR0M3TH3AN 1dfabdcd66 feat: implement load-test-agent harness and report
- Create scripts/agent/load-test.mjs with nostr-tools and ws.
- Generate load test report in reports/load-test/.
- Verify with dry run.
- Scheduler cycle completion log for load-test-agent.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-18 21:09:27 +00:00
google-labs-jules[bot]andPR0M3TH3AN 12625bc41b Cleanup repo structure and consolidate tests
- Consolidated `tests/` into `test/`
- Moved `test-audit/` scripts to `scripts/test-audit/`
- Updated audit scripts to support configurable output directory
- Removed root clutter (`test_output.txt`)
- Updated documentation and agent prompts

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-18 20:49:19 +00:00
google-labs-jules[bot]andPR0M3TH3AN 8bf1ca13f7 feat(landing): categorize agents by function
This change updates the landing page (`landing/index.html`) to group functional agents into "TORCH Maintenance & Agent Evolution" and "Repo Development" categories, instead of the default "Daily" and "Weekly" schedule-based grouping.

- Introduced `AGENT_CATEGORIES` mapping in `landing/index.html`.
- Updated `fetchAgents` to flatten the roster and group by functional category.
- Preserved the "Daily"/"Weekly" badge on agent cards.
- Verified changes with a Playwright script checking for the presence of new category headers.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-18 20:03:38 +00:00
google-labs-jules[bot]andPR0M3TH3AN 6614535361 perf: optimize rankRelays for subset queries
- Optimized `RelayHealthManager.rankRelays` to use O(M log M) lookup for small subsets instead of O(N) filter.
- Added `byRelay` Map to `_sortedCache` for O(1) access.
- Fixed `NaN` bug in `buildRelayHealthConfig` when `minActiveRelayPool` is undefined.
- Updated `perf/benchmark-lock-ops.mjs` to measure subset performance.
- Added performance report `reports/performance/weekly-perf-report-2026-02-18.md`.
- Achieved ~6.8x speedup in benchmark.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-18 19:54:47 +00:00
google-labs-jules[bot]andPR0M3TH3AN 3cf6f2e3b2 feat(known-issues-agent): resolve content-audit-agent target directory and update triage report
- Fixed `content-audit-agent` target directory by updating `src/prompts/daily/content-audit-agent.md` to reference `docs/` instead of `/content`.
- Verified `npm test` prompt contract violations are resolved.
- Updated `KNOWN_ISSUES.md` with resolved status and verification dates.
- Generated `reports/known-issues/known-issues-report-2026-02-18.md` with triage summary.
- Ensured memory retrieval and storage workflows were executed.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-18 19:52:48 +00:00
google-labs-jules[bot]andPR0M3TH3AN bbbe9980d7 fix(build): ensure agent roster and prompts are included in dist
The landing page (`landing/index.html`) relies on fetching `roster.json` and agent markdown files from `src/prompts/`. Previously, the build process did not copy these files to the `dist/` directory, causing 404 errors on the hosted landing page.

This change:
- Modifies `build.mjs` to recursively copy `src/prompts/` to `dist/src/prompts/`.
- Updates `build.mjs` to replace `../src/prompts/` paths in `landing/index.html` with `src/prompts/` during the build, ensuring correct path resolution when served from `dist/`.
- Removes the individual `META_PROMPTS.md` copy step as it is now covered by the directory copy.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-18 19:49:38 +00:00
google-labs-jules[bot]andPR0M3TH3AN 9d0d7d274e chore: test integrity enforcement and dashboard security fix
- Refactored `test/memory-scheduler.test.mjs` to use `mock.timers` for deterministic execution, replacing flaky `wait` logic.
- Strengthened `test/lock-ops.test.mjs` with edge case tests for `parseLockEvent` handling invalid JSON and missing fields.
- Fixed a security vulnerability in `src/dashboard.mjs` where sensitive configuration (e.g., rosters, auth) was exposed in `/torch-config.json`.
- Updated `src/prompts/daily/test-audit-agent.md` to comply with the canonical prompt contract.
- Added `reports/test-audit/test-integrity-note-2025-02-14.yaml` detailing test changes and anti-cheat measures.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-18 19:33:29 +00:00
google-labs-jules[bot]andPR0M3TH3AN 79b9497270 feat: Add icons to Functional Agents on landing page
- Added AGENT_ICONS map in JS.
- Updated agent card rendering to include emoji icons.
- Added CSS for icon alignment.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-18 19:30:45 +00:00
google-labs-jules[bot]andPR0M3TH3AN 326608ce7e chore: Enforce Clean Repo Standard and organize artifacts
- Added "Clean Repo Standard" to `AGENTS.md` and `CLAUDE.md`, explicitly forbidding root-level logs/artifacts.
- Moved clutter files (`test_output_full.txt`, `benchmark-after.txt`, `dashboard.log`, etc.) to `test_logs/`, `task-logs/`, and `reports/performance/`.
- Moved `INITIAL_BASELINE.md` and other baseline files to `reports/performance/`.
- Updated `src/prompts/daily/perf-agent.md` and `src/prompts/daily/const-refactor-agent.md` to reference the new location of `INITIAL_BASELINE.md`.
- Updated `.gitignore` to ignore logs and temporary artifacts in the new directories.
- Moved `DIAGNOSIS.md` to `reports/performance/`.
- Moved `perf/` data files to `reports/performance/`.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-18 19:28:03 +00:00
google-labs-jules[bot]andPR0M3TH3AN b29f257b98 [security] replace innerHTML usages in landing/index.html — convert to safe DOM APIs
Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-18 19:17:12 +00:00
google-labs-jules[bot]andPR0M3TH3AN 0d13b28f53 Add agent showcase section to landing page
Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-18 19:08:49 +00:00
google-labs-jules[bot]andPR0M3TH3AN 31b18f5d5a chore: standardize agent report locations and fix script paths
- Created `reports/` directory with subdirectories for each category (audit, performance, security, etc.).
- Moved existing reports to the new `reports/` structure.
- Updated `AGENTS.md` to define the "Report Location Standard".
- Updated all agent prompts in `src/prompts/` to:
    - Output reports to the new locations.
    - Fix incorrect script paths (replaced `torch/scripts/` with `scripts/`).
- Updated `load-test-agent.md` to produce a Markdown summary report.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-18 19:05:42 +00:00
google-labs-jules[bot]andPR0M3TH3AN 5d698a8455 feat: establish scenario-first testing standards
- Created `AGENTS.md` and `CLAUDE.md` to define test integrity rules and behavior-based validation.
- Updated `TORCH.md` to include "Scenario-First Tests & Test Integrity" and the "Test Integrity & Scenario Spec Agent" role.
- Updated `src/prompts/daily/test-audit-agent.md` to adopt the new "Enforcer" role, prioritizing test fidelity over CI green state.
- Preserved existing scheduler contract headers in the agent prompt.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-18 18:35:38 +00:00
google-labs-jules[bot]andPR0M3TH3AN 8455c99dfc chore(ai): document src/lock-ops.mjs
- Added JSDoc to exported functions and classes in src/lock-ops.mjs
- Added inline comments to complex logic areas
- Created docs/lock-ops-overview.md
- Created task log for daily docs-code-investigator agent

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-18 18:19:28 +00:00
google-labs-jules[bot]andPR0M3TH3AN 7c41e040bd docs: align package config and documentation paths
- Update `package.json` to include `TORCH.md` and `scripts/memory/` in distribution.
- Update `README.md` to reference `TORCH.md` correctly.
- Update `src/ops.mjs` to robustly handle memory policy paths in `torch-config.json` generation.
- Update `.gitignore` to exclude `.scheduler-memory/`.
- Update `torch-config.example.json` to include memory policy with standard defaults.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-18 16:51:35 +00:00
google-labs-jules[bot]andPR0M3TH3AN 57f6675c64 Weekly fuzz-agent run: fixes and execution
Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-18 15:22:04 +00:00
google-labs-jules[bot]andPR0M3TH3AN c123dd9a77 perf: make saveMemoryStore async and non-blocking
Optimizes `saveMemoryStore` in `src/services/memory/index.js` to use `fs.promises.writeFile` instead of synchronous `fs.writeFileSync`.
Implements a coalescing mechanism to handle concurrent save requests efficiently, preventing race conditions and reducing I/O operations by batching pending updates into a single write.
Reduces event loop blocking from ~420ms (sync) to ~3ms (async) for large write operations in benchmarks.
Updates all `memoryRepository` methods to await the async save operation.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-18 03:37:12 +00:00
google-labs-jules[bot]andPR0M3TH3AN a9f30f13f9 feat(perf): cache relay ranking in RelayHealthManager
- Implement caching for `rankRelays` to avoid redundant sorting and computations.
- Cache is invalidated on new outcomes or when quarantine status changes.
- Add `_metricsVersion` to track metrics updates.
- Benchmarks show ~3x performance improvement (0.06ms -> 0.02ms per call for 100 relays).
- Add unit tests for caching behavior and invalidation.
- Add `perf/benchmark-lock-ops.mjs`.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-18 03:33:59 +00:00
google-labs-jules[bot]andPR0M3TH3AN 0f29e9126e perf: parallelize applyLifecycleActions for faster pruning
- Use Promise.all to execute memory lifecycle actions concurrently.
- Maintain intra-item dependency order (merged_into before action).
- Update tests to support non-deterministic execution order of independent items.
- Benchmark shows ~65x improvement for 100 items with 10ms latency.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-18 03:32:03 +00:00
google-labs-jules[bot]andPR0M3TH3AN 850be9c37d perf: Optimize textMatchSimilarity in memory retriever
Avoids redundant string concatenation and lowercasing in the inner loop of `buildSimilarityIndex`.
Pre-computes query terms and regexes once per query.
Uses RegExp.test for case-insensitive matching without allocation.
Benchmark shows ~2x speedup (99ms vs 191ms for 10k memories).

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-18 03:31:22 +00:00
google-labs-jules[bot]andPR0M3TH3AN 5fe9e8a1f9 Fix: Strengthen path traversal protection in dashboard.mjs
- Replaced brittle regex-based sanitization with `path.resolve` relative to `packageRoot`.
- Added `test/dashboard-path-traversal-fix.test.mjs` to verify robust protection against traversal attacks.
- Verified that legitimate access to allowed paths is maintained.
- Verified that access to restricted files (like package.json) is blocked.
- Updated path handling to correctly handle absolute paths and URL-encoded characters.

This change addresses a potential security vulnerability where the previous sanitization logic could be bypassed in certain environments or with specific edge cases. By using standard path resolution and explicitly checking against a canonical root, the implementation is more secure and maintainable.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-18 03:31:18 +00:00
google-labs-jules[bot]andPR0M3TH3AN 62afdbb774 perf: optimize roster check in cmd-list using Set
Refactored `src/cmd-list.mjs` to use a `Set` for roster lookups, reducing complexity from O(M*N) to O(M+N).
Added dependency injection to `cmdList` to enable unit testing.
Added `test/cmd-list.test.mjs` to verify functionality.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-18 03:31:13 +00:00
google-labs-jules[bot]andPR0M3TH3AN a31332457d test: add unit tests for roster loading logic
- Implemented dependency injection in `src/roster.mjs` to allow mocking `fs` and `loadTorchConfig`.
- Added `test/roster.test.mjs` with comprehensive test cases:
    - Fallback behavior when no files/config exist.
    - Priority of `torch/roster.json` (User Roster) over `roster.json` (CWD).
    - Internal module roster fallback.
    - Environment variable overrides.
    - Configuration overrides.
    - Error handling for malformed JSON or missing fields.
- Exported `_resetRosterCache`, `_setRosterDependencies`, and `_restoreRosterDependencies` for testing purposes.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-18 03:31:12 +00:00
google-labs-jules[bot]andPR0M3TH3AN cc932d31de refactor: extract hardcoded error classification strings in lock-ops.mjs
- Introduced `PUBLISH_ERROR_CODES` constant for publish error classification.
- Introduced `PUBLISH_FAILURE_CATEGORIES` constant for failure categorization.
- Replaced hardcoded strings in `classifyPublishError`, `isTransientPublishCategory`, `LockPublisher.publish`, and `determineFailureCategory` with these constants.
- Verified changes with existing tests.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-18 03:30:29 +00:00
google-labs-jules[bot]andPR0M3TH3AN 7305dd964d Optimize createLifecyclePlan with Promise.all
Replaced sequential `await condenseGroup` calls with `Promise.all` to run condensation tasks concurrently.
Added `scripts/benchmark-pruner.mjs` to measure performance improvement.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-18 03:30:28 +00:00
google-labs-jules[bot]andPR0M3TH3AN ace069cc19 perf(pruner): optimize groupNearDuplicates to O(N log N) from O(N^2)
Sorts memories by created_at and uses an early exit condition in the inner loop to avoid checking all pairs. This reduces complexity from O(N^2) to roughly O(N * k) where k is the number of items within the duplicate window.

Measured improvement for 30k items: ~2.1s -> ~0.25s (8x speedup).

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-18 03:30:11 +00:00
google-labs-jules[bot]andPR0M3TH3AN aad5e46b31 fix(dashboard): whitelist exposed torch-config.json fields
Restrict the /torch-config.json endpoint to only return fields required by the dashboard frontend (dashboard config excluding auth, and nostrLock namespace/relays). This prevents exposure of sensitive internal configuration such as rosters, scheduler settings, and full relay lists.

- Modify src/dashboard.mjs to sanitize config using an allowlist approach.
- Add test/dashboard-config-exposure.test.mjs to verify sensitive fields are stripped.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-18 03:29:23 +00:00
google-labs-jules[bot]andPR0M3TH3AN 75c9b669c0 feat(dashboard): add HTTP security headers
Adds standard HTTP security headers (CSP, X-Content-Type-Options, X-Frame-Options, Referrer-Policy) to all dashboard responses to mitigate XSS, clickjacking, and MIME sniffing attacks.

Includes verification tests in test/dashboard-security.test.mjs.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-18 03:29:21 +00:00
google-labs-jules[bot]andPR0M3TH3AN e12c415f28 feat(test): add unit tests for roster loading logic with dependency injection
- Refactor `src/roster.mjs` to support dependency injection for `fs` and `loadTorchConfig`.
- Add `test/roster.test.mjs` to test roster loading scenarios including file precedence, caching, fallback, and configuration overrides.
- Export `_resetRosterCache` in `src/roster.mjs` for testing purposes.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-18 03:29:09 +00:00
google-labs-jules[bot]andPR0M3TH3AN b1353cb79b fix: prevent command injection in init scripts by validating install dir
- Added `validateInstallDir` function to `src/ops.mjs` to enforce strict allowlist for directory names (alphanumeric, hyphens, underscores, slashes, periods).
- Integrated validation into `resolveConfiguration` to sanitize both interactive and mock inputs.
- Added comprehensive unit tests in `test/install_dir_validation.test.mjs`.

This fixes a vulnerability where malicious directory names could inject shell commands into `package.json` scripts during initialization.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-18 03:28:59 +00:00
google-labs-jules[bot]andPR0M3TH3AN ba5d86142c Refactor: Move ensureDir to src/utils.mjs
Moved the `ensureDir` utility function from `src/ops.mjs` to `src/utils.mjs` to promote code reuse and centralization.
Updated `src/ops.mjs` and `src/services/memory/index.js` to use the shared utility.
Added unit tests for `ensureDir` in `test/utils.test.mjs`.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-18 03:28:09 +00:00
google-labs-jules[bot]andPR0M3TH3AN 74993c1d47 I've removed the dead code in src/cmd-lock.mjs. This file contained duplicated logic that is now handled in src/lib.mjs and is not imported by any other module in the codebase.
Verified by:
- Searching the codebase to confirm no imports.
- Running the tests to ensure no regressions.
- Running the build to ensure the process is unaffected.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-18 03:28:01 +00:00
google-labs-jules[bot]andPR0M3TH3AN e787247c6f test(utils): add unit tests for todayDateStr and nowUnix
Add comprehensive unit tests for `todayDateStr` and `nowUnix` in `src/utils.mjs`.
These tests use `node:test`'s mock timers to ensure deterministic execution, verifying
that the date formatting and timestamp generation behave as expected.

- `todayDateStr`: verified correct YYYY-MM-DD format
- `nowUnix`: verified correct integer timestamp generation

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-18 03:27:26 +00:00
google-labs-jules[bot]andPR0M3TH3AN b012ae19da test: enhance coverage for relay alert thresholds
Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-18 03:27:21 +00:00
google-labs-jules[bot]andPR0M3TH3AN 9a9f93aa04 chore: remove dead code src/cmd-check.mjs
- Remove `src/cmd-check.mjs` as it is not used in the codebase and contains outdated logic.
- Remove `test/cmd-check.test.mjs` as it tests the deleted file.
- Verify that `cmdCheck` in `src/lib.mjs` is covered by `test/lib.test.mjs`.

This improves code health by removing unused and duplicate code.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-18 03:23:18 +00:00
google-labs-jules[bot]andPR0M3TH3AN 06ddd10f1a chore(scheduler): run daily design-system-audit-agent
- Executed design-system-audit-agent on daily cadence
- Generated design system audit report (memory-update.md)
- Created run artifacts in src/context, src/todo, src/decisions, src/test_logs
- Published lock completion and final task log

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-18 02:42:06 +00:00
google-labs-jules[bot]andPR0M3TH3AN f436beab9b docs(agent): audit and improve documentation (docs-agent)
- Created `CONTRIBUTING.md` with development instructions.
- Updated `README.md` to include a Development section.
- Added daily scheduler run artifacts.
- Completed scheduler cycle for `docs-agent`.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-18 01:16:10 +00:00
google-labs-jules[bot]andPR0M3TH3AN c90508ba42 chore(ui): design system audit (autofixes)
- Ran design-system-audit-agent.
- Audited landing/index.html for inline styles and design system violations.
- Applied safe auto-fixes to landing/index.html (margins, colors, text alignment).
- Generated audit report in task-logs/daily/.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-18 00:24:07 +00:00
google-labs-jules[bot]andPR0M3TH3AN da4d360af1 chore(scheduler): execute deps-security-agent
Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-17 23:27:49 +00:00
google-labs-jules[bot]andPR0M3TH3AN 9e993800fa [scheduler] daily/decompose-agent: Decompose scripts/agent/run-scheduler-cycle.mjs
- Executed daily scheduler cycle.
- Selected `decompose-agent` (next in roster).
- Decomposed `scripts/agent/run-scheduler-cycle.mjs` (1127 lines) into `scripts/agent/scheduler-utils.mjs` (195 lines) and `scripts/agent/scheduler-lock.mjs` (173 lines).
- Resulting main file size: 788 lines (339 lines reduction).
- Fixed lint warnings.
- Updated `test/scheduler-preflight-lock.e2e.test.mjs`, `test/run-scheduler-cycle-memory-policy.test.mjs`, `test/scheduler-lock-failure-schema.contract.test.mjs` to copy new modules into test fixtures.
- Updated `test/scheduler-ratchet.test.mjs` to verify moved functions in `scheduler-lock.mjs`.
- Note: `scripts/check-file-size.mjs` was not updated as it lacks the baseline feature referenced in the prompt.
- Created artifacts: `src/context/CONTEXT_...`, `src/decisions/DECISIONS_...`, `src/test_logs/TEST_LOG_...`, `src/todo/TODO_...`.
- Created scheduler log: `task-logs/daily/2026-02-17T22-29-00Z__decompose-agent__completed.md`.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-17 22:41:37 +00:00
google-labs-jules[bot]andPR0M3TH3AN ed56a72f69 Daily Agent: content-audit-agent run (missing content directory) + fix lock-ops
- Audited `/content` directory: Not found.
- Updated `KNOWN_ISSUES.md`.
- Fixed a bug in `src/lock-ops.mjs` where `deps` was undefined in `LockPublisher`.
- Created run artifacts and task logs.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-17 21:39:10 +00:00
google-labs-jules[bot]andPR0M3TH3AN 5e99e81f2d chore(scheduler): Execute ci-health-agent and fix critical bugs
Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-17 19:58:43 +00:00
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
google-labs-jules[bot]andPR0M3TH3AN 03ccb232ee Refactor lock backend constants and fix scheduler syntax error
- Extracted hardcoded retry/health constants from `src/lock-ops.mjs` to `src/constants.mjs`.
- Refactored `src/lock-ops.mjs` to use `LockPublisher` class pattern and shared constants.
- Fixed `SyntaxError` in `src/lock-ops.mjs` (function inside function).
- Fixed `ReferenceError` in `src/cmd-check.mjs` (`queryLocksFn` -> `queryLocks`).
- Verified with unit tests (`test:unit:lock-backend`) and linting.
- Completed daily scheduler cycle for `const-refactor-agent`.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-17 19:50:48 +00: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