Commit Graph
145 Commits
Author SHA1 Message Date
Claude 639ad6877d chore: code quality, CI/CD, and DX improvements
Phase 3 — Code Quality:
- Deduplicate nowUnix() in lock-ops.mjs (import from utils.mjs)
- Promote ESLint no-unused-vars to error, fix all 46 violations
- Remove dead code: unused imports, variables, and catch bindings
- Add /* global marked */ for CDN-loaded library in dashboard

Phase 4 — CI/CD:
- Add Node.js version matrix (22, 23) to CI workflow
- Add npm audit security scan step to CI
- Add innerHTML usage check to CI pipeline
- Enable Dependabot for npm and GitHub Actions dependencies
- Create PR template

Phase 5 — Developer Experience:
- Create .env.example documenting all environment variables
- Expand CONTRIBUTING.md with commit conventions, agent/prompt
  creation guide, architecture overview, and test integrity
- Add system architecture diagram with Mermaid (docs/architecture/)

https://claude.ai/code/session_01GfwUNbgeMgXreFDbsNQMsS
2026-02-19 21:03:30 +00:00
Claude c9b23874f2 fix(tests): improve test reliability and remove unused deps
- Add --test-timeout=30000 to prevent test suite hanging
- Skip build_verification.test.mjs when dist/ is absent
- Replace setTimeout with mocked Date.now in memory-cache expiry test
- Replace wait(30) with setImmediate flush in scheduler smoke test
- Remove unused @playwright/test devDependency

https://claude.ai/code/session_01GfwUNbgeMgXreFDbsNQMsS
2026-02-19 20:55:17 +00:00
Claude e7ecd2617e fix(security): harden dashboard auth timing, XSS, and CSP
- Fix timingSafeCompare to pad buffers to equal length before comparing,
  closing the content timing side-channel on length mismatch
- Replace innerHTML with textContent for error messages to prevent XSS
- Extract inline script from dashboard/index.html into dashboard/app.js
- Remove 'unsafe-inline' from script-src CSP directive
- Update security test to match new CSP policy

https://claude.ai/code/session_01GfwUNbgeMgXreFDbsNQMsS
2026-02-19 20:53:15 +00:00
thePR0M3TH3AN fa59d658d6 Merge branch 'main' into agents/daily/protocol-research-agent-run-9833362316977900264 2026-02-19 08:38:47 -05: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
thePR0M3TH3AN 19f73142cf Merge pull request #316 from PR0M3TH3AN/agents/daily/perf-agent-run-16751979136899284510
Execute daily perf-agent run
2026-02-18 21:46:35 -05: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 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 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 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 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 57f6675c64 Weekly fuzz-agent run: fixes and execution
Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-18 15:22:04 +00:00
thePR0M3TH3AN 1d30b2f28d Merge branch 'main' into jules-test-roster-improvement-7422741331242836925 2026-02-18 09:50:23 -05:00
thePR0M3TH3AN 90fdaae6a5 Merge pull request #284 from PR0M3TH3AN/perf/optimize-roster-check-4709742538455928107
⚡ Optimize roster check in cmd-list using Set
2026-02-18 09:49:16 -05:00
thePR0M3TH3AN 845333e980 Merge branch 'main' into dashboard-security-headers-10540095592303062285 2026-02-18 09:47:42 -05:00
thePR0M3TH3AN 30212a6213 Merge pull request #275 from PR0M3TH3AN/fix-install-dir-command-injection-4005485668731201594
🔒 Fix command injection via install directory name
2026-02-18 09:47:23 -05:00
thePR0M3TH3AN 76c1513cfd Merge branch 'main' into jules-tests-utils-9764403852439497661 2026-02-18 09:46:52 -05:00
thePR0M3TH3AN 0c4650e92a Merge pull request #271 from PR0M3TH3AN/jules-3313039613758629393-8f27954c
Enhance test coverage for relay alert thresholds
2026-02-18 09:46:23 -05:00
thePR0M3TH3AN f5dee21b74 Merge branch 'main' into chore/remove-dead-code-cmd-check-6250725036284174249 2026-02-18 09:45:58 -05:00
thePR0M3TH3AN a231ea0784 Merge branch 'main' into jules/testing-relay-health-12520607155456440581 2026-02-18 09:44:14 -05:00
thePR0M3TH3AN b6775cda28 Merge pull request #289 from PR0M3TH3AN/optimize-relay-ranking-1239301882622685923
⚡ Optimize relay ranking with caching
2026-02-17 22:45:08 -05:00
thePR0M3TH3AN 34c20fadd8 Merge pull request #285 from PR0M3TH3AN/fix-dashboard-path-traversal-vulnerability-5749294800748882365
Fix path traversal vulnerability in dashboard.mjs
2026-02-17 22:43:20 -05:00
thePR0M3TH3AN 11c7510b95 Merge pull request #287 from PR0M3TH3AN/perf/optimize-pruner-lifecycle-15735036455677538666
⚡ Parallelize memory lifecycle actions in pruner
2026-02-17 22:41:48 -05:00
thePR0M3TH3AN 0d7f5a250c Merge pull request #278 from PR0M3TH3AN/fix-dashboard-config-exposure-6646545441224592886
fix(dashboard): prevent information disclosure via /torch-config.json
2026-02-17 22:40:08 -05:00
thePR0M3TH3AN ea127b9b2d Merge pull request #274 from PR0M3TH3AN/code-health-ensure-dir-13440231316649260412
Refactor: Centralize `ensureDir` utility
2026-02-17 22:39:11 -05: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 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 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 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 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
thePR0M3TH3AN 058011089d Merge branch 'main' into fix-insecure-random-backoff-15480292305985131336 2026-02-17 14:30:13 -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 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 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 4a59ccd501 Merge branch 'main' into test/ingest-events-coverage-4058176338689655233 2026-02-17 14:25:04 -05:00