Commit Graph

15 Commits

Author SHA1 Message Date
Azreen Jamal bd2c7d5102 feat: pi-worker now picks up and fixes real bugs from Asana
Major changes:
- Task loop polls Under Review + New Bugs sections (was only checking empty sections)
- Smart project routing: keyword matching maps task names to correct codebase
  (e.g. 'pledge' → legacy-donation-system-laravel)
- Pi executes in the project directory, not /opt/pi-worker
- Git pull before execution to get latest code
- Skips already-attempted tasks (checks Asana comments)
- Config now exposes projectsPath

First real bug fixed autonomously:
  'Duplicate Pledges Detected with Same External Reference'
  → Fixed uniqid() causing duplicate Engage pledges on every sync
  → 1 file changed in app/N3O/Schema.php

Also: fix watchdog to use systemd-notify command (unix_dgram unsupported in Bun),
add debug logging to lock acquire failures
2026-03-09 01:33:24 +08:00
Azreen Jamal cf20646290 fix: pi-worker systemd integration + lock file bug
- Fix FileLock: track 'held' state, only release if acquired, suppress ENOENT
- Upgrade systemd service: Restart=always (was on-failure, caused 2-day outage),
  StartLimitBurst, WatchdogSec=120, MemoryMax=512M, KillMode=mixed
- Add systemd watchdog: health server self-checks at :8787, notifies sd_notify
- Kill orphaned nohup process, restart cleanly via systemd
2026-03-09 01:08:40 +08:00
Azreen Jamal ea0ba4ee10 fix: major cleanup - verify cache, section cache, rate limit retry, split sweep from cleanup
- Separate cleanupCompletedMyTasks (fast, no Pi) from sweepIncompleteTasks (with Pi verify)
- Cache verified-not-done tasks for 30min to avoid re-checking every cycle
- Cache project sections for 5min to reduce API calls
- Add rate limit (429) retry with Retry-After header
- Add server error (5xx) retry
- Remove assignee:null - only use assignee_status:later
- Keep tasks assigned to user always
2026-03-06 20:40:31 +08:00
Azreen Jamal fbeb79264a fix: keep tasks assigned to user - only move to Done section, never unassign 2026-03-06 17:33:36 +08:00
Azreen Jamal 0d7f54c239 fix: unassign completed tasks to fully remove from My Tasks 2026-03-06 17:26:59 +08:00
Azreen Jamal 6acadecc7b fix: move completed My Tasks to Done/Resolved section in their respective projects 2026-03-06 17:15:23 +08:00
Azreen Jamal d95dd524be fix: clear completed tasks from Recently Assigned (set assignee_status=later) 2026-03-06 17:02:55 +08:00
Azreen Jamal 91b8ceeac9 feat: sweep My Tasks (Recently Assigned) for already-done tasks 2026-03-06 16:51:01 +08:00
Azreen Jamal 9c3e1e3a24 fix: include Recently Assigned and Awaiting More Info sections in sweep and task pickup 2026-03-06 16:41:15 +08:00
Azreen Jamal 768ccada4b feat: sweep all sections for already-done tasks before picking new work 2026-03-06 16:33:46 +08:00
Azreen Jamal 8309fc1869 fix: faster verification - 2min timeout, no deep scans 2026-03-06 16:09:03 +08:00
Azreen Jamal 086d9a3026 feat: add pre/post verification to task execution pipeline
- Before executing: verify if work is already done on server
- If already done: skip execution, comment evidence, mark complete
- After executing: run verification again to confirm work was applied
- Verification agent uses Pi with read-only investigation prompt
- Adds verification status (PASSED/COULD NOT CONFIRM) to Asana comments
- Prevents redundant work and catches false completions
2026-03-06 15:57:39 +08:00
Azreen Jamal ccdbf94450 fix: detect Pi API errors in event stream (exit code 0 on failure)
Pi CLI exits with code 0 even when the Anthropic API returns errors
(e.g. insufficient credits). The error is only visible in the JSON
event stream as stopReason:"error" with an errorMessage field.

Now the executor parses message_end/turn_end events for errorMessage
and treats them as failures, preventing false "task completed" reports.
2026-03-06 15:41:02 +08:00
Azreen Jamal bf69c43e2f fix: update task-loop section matching for Bug Intake project
- SECTIONS now uses arrays of candidate names searched in priority order
- Maps Bug Intake sections: New Bugs→TODO, Under Review→IN_PROGRESS, Resolved→DONE
- Added findFirstSection helper for array-based section lookup
2026-03-06 15:38:04 +08:00
Azreen Jamal 19420cc01d feat: add pi-worker service - autonomous Asana task executor & project improvement agent
- Asana REST API client for task polling, section management, and commenting
- Pi CLI executor for running tasks with specialist agent teams
- Task loop: polls Asana To Do/Pi Worker sections, executes tasks, reports results
- Improvement loop: rotates through 8 improvement categories (code quality, security, docs, testing, etc)
- Health server on :8787
- File-based mutex locks with stale lock detection
- Docker + docker-compose deployment config
- deploy.sh for one-command deployment to cr-server-new via SSH/Incus
2026-03-06 15:26:13 +08:00