Commit Graph
289 Commits
Author SHA1 Message Date
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 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
thePR0M3TH3AN 24d614d2de Merge pull request #305 from PR0M3TH3AN/agents/daily/known-issues-agent-2026-02-18-13101749504477936442
Run known-issues-agent: Fix content-audit path and update known issues
2026-02-18 15:07:57 -05: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
thePR0M3TH3AN 6e26452dbb Merge pull request #303 from PR0M3TH3AN/test-integrity-audit-241146943857584817
Test Integrity Enforcement & Dashboard Security Fix
2026-02-18 14:34:10 -05: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
thePR0M3TH3AN 62731f77fd Merge pull request #301 from PR0M3TH3AN/chore/clean-repo-standard-12872616590007917715
chore: Enforce Clean Repo Standard and organize artifacts
2026-02-18 14:28:33 -05: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
thePR0M3TH3AN 984c35a039 Merge pull request #300 from PR0M3TH3AN/ai/innerhtml-fix/landing-index-5498721095203875822
[security] replace innerHTML usages in landing/index.html — convert to safe DOM APIs
2026-02-18 14:18:20 -05: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 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
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 0dfbf3f86f Merge branch 'main' into perf/async-memory-save-18240015948353785856 2026-02-18 09:48:42 -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 f5dee21b74 Merge branch 'main' into chore/remove-dead-code-cmd-check-6250725036284174249 2026-02-18 09:45:58 -05:00
thePR0M3TH3AN ccc4c33307 Merge branch 'main' into agents/daily/design-system-audit-agent-14566851065509091876 2026-02-18 09:44:48 -05:00
thePR0M3TH3AN 30753d97be Merge branch 'main' into agents/daily/todo-triage-agent-3669620007397262659 2026-02-18 09:43:41 -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 ae45ddd20c Merge pull request #280 from PR0M3TH3AN/refactor/extract-lock-ops-error-constants-665695259531782224
🧹 Extract hardcoded error classification strings in lock-ops.mjs
2026-02-17 22:44:53 -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 ae85044021 Merge pull request #281 from PR0M3TH3AN/perf/optimize-pruner-lifecycle-3710831960416065931
⚡ Optimize createLifecyclePlan with Promise.all
2026-02-17 22:42:24 -05:00
thePR0M3TH3AN fabe54ca50 Merge pull request #286 from PR0M3TH3AN/perf-optimize-text-match-similarity-10778846404637796189
⚡ Optimize memory text similarity check
2026-02-17 22:42:05 -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 84e1da5825 Merge pull request #279 from PR0M3TH3AN/perf-pruner-optimization-6586476437632671797
⚡ Optimize memory pruner groupNearDuplicates
2026-02-17 22:41:07 -05:00
thePR0M3TH3AN 5cb3e32b8a Merge pull request #273 from PR0M3TH3AN/remove-dead-code-cmd-lock-18301432139913694771
🧹 Remove dead code src/cmd-lock.mjs
2026-02-17 22:40:51 -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 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