Commit Graph
59 Commits
Author SHA1 Message Date
thePR0M3TH3AN 1e3f88e488 Fix Windows-unsafe artifact filenames and enforce safe timestamp format 2026-02-25 21:07:32 -05:00
thePR0M3TH3AN 1fa4d4560e Fix host-repo scheduler config resolution and handoff defaults 2026-02-25 14:48:11 -05:00
thePR0M3TH3AN 55208c2e45 Merge origin/main into refactor/lock-ops-decomposition-2507393976208881863 (resolve conflicts) 2026-02-25 12:22:43 -05:00
google-labs-jules[bot]andPR0M3TH3AN 45f0e16631 feat(scheduler): execute load-test-agent daily run
- Implement `scripts/agent/simple-relay.mjs` for local load testing
- Execute `load-test-agent` prompt via scheduler flow
- Generate load test reports and run artifacts
- Complete daily task for `load-test-agent`

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-22 23:09:26 +00:00
google-labs-jules[bot]andPR0M3TH3AN 003e18b93b Fix CI lint error in lock-publisher.mjs
- Ensure `src/lock-publisher.mjs` does not import `randomInt`.
- Clean up test output artifacts.
- Re-verify tests pass locally.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-21 20:48:15 +00:00
thePR0M3TH3AN 9fef4c4f46 update 2026-02-21 15:16:45 -05:00
thePR0M3TH3AN 2b8a0c3d0d update 2026-02-20 12:51:17 -05:00
thePR0M3TH3ANandClaude Sonnet 4.6 a5f08ff082 feat(scheduler): add local time-window guard to prevent within-window re-runs
Adds a cadence-aware time-window check that runs after the Nostr relay lock
check to exclude agents that already ran within the current window (24h daily,
7d weekly). This closes the cross-midnight edge case where the relay's
date-scoped d-tag rolls over but the agent ran minutes ago.

Changes:
- scheduler-utils.mjs: export log-parsing helpers (parseDateValue,
  parseTimestampFromFilename, parseAgentFromFilename, isStrictSchedulerLogFilename,
  parseFrontmatterCreatedAt, parseFrontmatterAgent, parseFrontmatterValue) plus
  CADENCE_WINDOW_MS constant and buildRecentlyRunExclusionSet(). Helpers are
  exported so they can be unit-tested independently. Adds 'node:path' import.
- run-scheduler-cycle.mjs: import the moved helpers from utils (removes ~45 lines
  of duplicate definitions), call buildRecentlyRunExclusionSet after excludedSet
  is built from relay data, merge results, log newly-excluded agents. Adds cycle
  saturation detection: when all roster agents are covered by the time-window
  guard, exit 0 with a clear "Cycle complete" message instead of a failure.
- test/scheduler-time-window.test.mjs: 30 new scenario-first unit tests covering
  SCN-TWG-01..11 (in-window exclusion, out-of-window pass-through, cross-midnight,
  frontmatter precedence, weekly threshold, empty dir, missing dir, deferred
  log passthrough, mixed rosters, anti-cheat for non-log files).

All 30 new tests pass. Existing scheduler-ratchet tests (7) still pass.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
2026-02-20 11:05:52 -05:00
thePR0M3TH3ANandClaude Sonnet 4.6 8a9080e7c3 fix(memory): close the content gap so agents can actually write and retrieve learnings
- run-selected-prompt.mjs: set SCHEDULER_MEMORY_FILE env var before spawning each agent so
  store.mjs has a well-known path to read from (memory-updates/<ts>__<agent>.md)
- retrieve.mjs: format memories.md using m.summary + date/tags in readable markdown sections
  instead of raw m.content blobs; agents can now scan injected context at a glance
- store.mjs: remove semantically-empty fallback placeholder events that polluted the store
  and degraded retrieval quality; also fix default cadence 'weekly' -> 'daily' to match retrieve
- scheduler-flow.md: replace vague "write insights" instruction with a concrete three-section
  template (Key findings / Patterns / Warnings) and clarify that $SCHEDULER_MEMORY_FILE is
  set by the scheduler automatically

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
2026-02-20 10:51:03 -05:00
thePR0M3TH3AN 206146b78e Merge pull request #365 from PR0M3TH3AN/agents/weekly/prompt-safety-agent-1954565905191419761
feat: Weekly Prompt Safety Audit
2026-02-20 07:48:05 -05:00
google-labs-jules[bot]andPR0M3TH3AN b23b9e4982 feat: Weekly Prompt Safety Audit
Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-20 05:10:15 +00:00
google-labs-jules[bot]andPR0M3TH3AN 9278dadab0 Print final run summary in scheduler cycle and prompts
Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-20 04:50:26 +00:00
thePR0M3TH3AN a7a7679223 update 2026-02-19 23:36:01 -05:00
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
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 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 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 8fb2a2ab99 Merge branch 'main' into agents/daily/ci-health-agent-2026-02-17-8365488986185039286 2026-02-17 15:09:34 -05: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 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
thePR0M3TH3AN b3f4a5c9cd Merge pull request #242 from PR0M3TH3AN/scheduler-cycle-optimization-6566135138689301144
⚡ Optimize scheduler cycle log reading performance
2026-02-17 13:38:36 -05:00
google-labs-jules[bot]andPR0M3TH3AN 32ba0d2621 perf(scheduler): parallelize log file reading in getLatestFile
Optimizes the `getLatestFile` function in `scripts/agent/run-scheduler-cycle.mjs` by parallelizing the reading and parsing of log files using `Promise.all`. This replaces the sequential `for...of` loop which caused I/O bottlenecks when processing large numbers of log files.

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

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

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-17 18:37:39 +00:00
thePR0M3TH3AN 2de7bdd5ce Merge pull request #237 from PR0M3TH3AN/perf/optimize-reliability-summary-12744973006292843555
⚡ Optimize lock reliability summary with Promise.all
2026-02-17 13:36:35 -05:00
google-labs-jules[bot]andPR0M3TH3AN 18eedc7810 perf: parallelize log processing in summarize-lock-reliability.mjs
Replaces sequential file processing loop with Promise.all to improve performance.
Benchmark showed ~2.5x speedup (1638ms -> 658ms) on 2000 files.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-17 18:33:10 +00:00
google-labs-jules[bot]andPR0M3TH3AN 3d459ef905 perf(scheduler): parallelize artifact checks in verifyMemoryStep
Optimize the `verifyMemoryStep` function in `scripts/agent/run-scheduler-cycle.mjs` to check for artifact existence in parallel using `Promise.all` instead of a sequential loop.

Benchmarks indicate a ~10x performance improvement (from ~500ms to ~50ms) when checking for 10 artifacts where none or the last one exists, with no regression in the best-case scenario.

Verified with `test/run-scheduler-cycle-memory-policy.test.mjs`.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-17 18:32:46 +00:00
google-labs-jules[bot]andPR0M3TH3AN fa4c9ca175 perf: optimize lock failure reason summarization
Replace inefficient `[...events].reverse().find()` with `events.findLast()`.
This avoids a shallow copy of the array and an in-place reverse,
improving performance from O(N) space/time to O(1) space and O(N) time
(where N is the number of events searched).

In benchmarks with 100,000 events:
- Element near the end: 99.9% improvement (~0.8ms vs ~950ms)
- Element at the beginning: ~42% improvement (~145ms vs ~250ms)

Node.js v18.6.0+ is required for `findLast`, which is supported in the
current environment (v22.22.0).

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-17 17:11:16 +00:00
google-labs-jules[bot]andPR0M3TH3AN 2a39713189 feat(scheduler): generate unique memory update files per run to avoid merge conflicts
- Modified `scripts/agent/run-scheduler-cycle.mjs` to generate a unique `memory-updates/<timestamp>__<agent>.md` path and pass it via `SCHEDULER_MEMORY_FILE` env var.
- Updated `scripts/memory/store.mjs` to prioritize `SCHEDULER_MEMORY_FILE` for ingestion.
- Updated `src/prompts/scheduler-flow.md` to instruct agents to write to the unique memory file.
- Updated `src/prompts/daily/torch-garbage-collection-agent.md` to include `memory-updates/*.md` in the cleanup scope.
- Moved existing `memory-update.md` to `memory-updates/legacy-memory-update-<timestamp>.md` to clear the root.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-17 15:19:52 +00:00
google-labs-jules[bot]andPR0M3TH3AN d02fa41079 fix(scheduler): relax prompt validation and correct default lint command
- Update `scripts/agent/run-scheduler-cycle.mjs` to allow prompt files to start with a blockquote (`>`) in addition to a markdown header (`#`), unblocking agents with shared contract headers.
- Fix default validation command from `['npm', 'run', 'lint']` to `['npm run lint']` to prevent `npm` usage errors.
- Include daily task logs demonstrating successful scheduler cycle execution (skipping failed locks and completing `load-test-agent`).

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-16 16:33:37 +00:00
thePR0M3TH3AN 118c365022 Merge branch 'main' into feat/nostr-platform-model-info-17811919130475421613 2026-02-15 17:41:19 -05: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 512a0413c7 feat: truncate logs and inject memory into prompts to reduce token burn
This change implements several optimizations to reduce token consumption and improve agent context:

1.  **Log Truncation**: `scripts/agent/run-scheduler-cycle.mjs` now truncates the echoed output of spawned processes to 20KB per stream (stdout/stderr). This prevents the scheduler agent's context from being flooded with excessive logs from sub-agents.
2.  **Memory Injection**: `torch-config.json`'s `retrieveCommand` has been updated to write retrieved memories to `.scheduler-memory/latest/<cadence>/memories.md`. `scripts/agent/run-selected-prompt.mjs` now checks for this file and injects its content into the agent's prompt, providing immediate context from the memory system.
3.  **CLI Optimization**: The `torch-lock list-memories` command now truncates the `content` field of memories to 200 characters by default. A new `--full` flag has been added to `src/cli-parser.mjs` and `src/lib.mjs` to view the full content when needed.

These changes aim to make the agent process more efficient ("error on the side of caution") and leverage the memory system more effectively.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-15 19:55:20 +00:00
thePR0M3TH3AN 3156ee0bb5 Merge branch 'main' of https://github.com/PR0M3TH3AN/TORCH 2026-02-15 14:27:20 -05:00
thePR0M3TH3AN c20af61643 making Torch more Goose friendly 2026-02-15 14:27:11 -05:00
google-labs-jules[bot]andPR0M3TH3AN 64f22cd741 feat(scheduler): implement smoke-agent and complete weekly run
- Added `scripts/agent/smoke-test.mjs` for automated smoke testing.
- Executed smoke test against `wss://relay.damus.io`.
- Verified event publication and retrieval.
- Completed scheduler cycle for `smoke-agent`.
- Added completion log `task-logs/weekly/2026-02-15T19-00-40Z__smoke-agent__completed.md`.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-15 19:01:58 +00:00
google-labs-jules[bot]andPR0M3TH3AN f5e857b3d0 feat: support linux platform in agent runner
- Updated scripts/agent/run-selected-prompt.mjs to support AGENT_PLATFORM=linux.
- Updated src/docs/TORCH.md to document the new platform support.
- Generated weekly task log for repo-fit-agent.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-15 16:23:37 +00:00
thePR0M3TH3AN 969b72d3e1 Add scheduler error rendering snapshot coverage 2026-02-14 20:10:26 -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 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
google-labs-jules[bot]andPR0M3TH3AN dd27f28f3b feat(ai): add load-test-agent script
- Added `scripts/agent/load-test.mjs` for daily load testing.
- Includes `DRY_RUN` mode for safe simulation.
- Includes real publishing logic using `nostr-tools/relay` and `nostr-tools/pure`.
- Generated sample report in `artifacts/`.
- Updated `task-logs/daily/` with completion status.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-15 00:01:16 +00: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
thePR0M3TH3AN 827c7038c9 Harden scheduler log candidate selection 2026-02-14 18:10:29 -05:00
thePR0M3TH3AN 909a7f9541 Strengthen run-artifact verification metadata and issue linkage 2026-02-14 18:05:54 -05:00