This document defines a multi-agent workflow for this repository, modeled on the mac-stats-reviewer companion project (local reference: ~/projects/mac-stats-reviewer). That project separates coordination (mac-stats-reviewer: tasks, prompts, optional autoresearch) from implementation (mac-stats). POS is a single repo: application code and agent coordination both live here; the split is logical (roles and folders), not two git roots.
Sources in mac-stats-reviewer used as basis: root README.md (agents overview, hourly commits - not adopted verbatim for POS), agents/tasks/README.md (task pipeline), and agent prompts under agents/001-log-reviewer/ … agents/007-committer/ (roles and handoffs). Optional Track A autoresearch (agents/autoresearch/README.md, RUN_24H_*.md) is out of scope for initial POS adoption unless you explicitly port tooling.
POS active queue: live task files and pipeline docs are under agents2/tasks/ and agents2/TASKS-README.md (a symlink agents → agents2 may exist for older paths; prefer agents2/ in new work).
- Traceable work: Each change flows through named stages (task file renames), like mac-stats-reviewer’s inbox pipeline.
- Separation of concerns: Review/analysis agents do not implement; coders implement; testers verify with evidence; closing reviewer archives; committer handles changelog/version only.
- POS alignment: Follow
AGENTS.md,.cursor/rules/(catalog:docs/agent-cursor-rules.md), Docker-based backend tests, Puppeteer smokes (docs/testing.md), and no new host installs (see user/project rules).
Decision plane (Laya-shaped)
We are integrating a decision plane into the thin loop: tool coordinator (next action / skip / escalate before a paid worker) and answer quality gate (keep / one repair / reopen after a result). Pattern write-up: raro42/agents-explained.
Today this repo still uses shell preflight plus Ollama / rules for cheap triage. Laya clients are not required for every tick yet. Same roles; swap the decision head when ready.
This is part of the agent strategy, not optional tooling guidance.
| Branch | Role |
|---|---|
development |
Default for all routine work. Agents commit here and git push origin development. |
master |
Production line (deployments such as amvara9 typically follow master). Updated only when promoting from development. |
Merge only if at least one applies:
- Daily cadence (default) - At least once per day, batch-integrate tested commits from
developmentintomasterand push (triggers Deploy to amvara9). Implemented byscripts/promote-development-to-master.sh, invoked as loop step 009 after the committer (AGENT_PROMOTE_INTERVAL_HOURSdefault 24). Avoid merging every small commit individually. - Big production change - Material impact: security, payments, data integrity, critical user-visible breakage, blocking migrations, multi-tenant risk, etc. Document why in commit/PR. Force with
AGENT_PROMOTE_FORCE=1or a manual merge. - Urgent / explicit production - The GitHub issue or human says urgent, hotfix, production, deploy now, or similar. Use label
production-urgenton the issue when applicable so agents and humans agree on intent. - Verified security / production-urgent (automatic) - After the tester marks PASS and the closer archives a
CLOSED-#N-…task, step 009 auto-forces promote when pending commits ondevelopmentreference issue #N and that issue has labelsecurityorproduction-urgent. No wait for the 24h window. Disable withAGENT_PROMOTE_SECURITY_FORCE=0.
All of the above still land on development first. Production is always development → master after tests, never a direct commit to master.
If none of the above applies: push development only; do not merge to master (the next daily promote will ship pending commits).
Cursor / agents: .cursor/rules/git-development-branch-workflow.mdc (alwaysApply: true) encodes this; it overrides looser “push master every time” habits.
Committer agent: Changelog and version bumps happen on development; merging to master is a separate step (009 / promote script) that follows the table above.
Multiple agents push to development. Before any step that edits the repo (application code, agents2/tasks/*.md, CHANGELOG.md, etc.), integrate the latest remote state:
- Humans / Cursor without the shell loop: run
./scripts/git-sync-development.shfrom the repo root (or the equivalentgit fetch+git pull --rebase --autostash origin developmentondevelopment). agents2/pos-cursor-loop.sh: runs that script at the start of each agent step (001, 006×5, 002, 003, 004, 007). SetAGENT_GIT_SYNC=0only to skip (offline debugging).- Before push: pull/rebase again after your commit so
git push origin developmentdoes not regress or race another agent.
This is remote integration (fetch/pull/rebase), not “open a GitHub PR before every edit.” Use normal PRs when your team wants human review before merging a branch; day-to-day development still needs pull/rebase so agents do not overwrite each other’s work.
| mac-stats-reviewer agent | POS role | Typical inputs | Writes / edits |
|---|---|---|---|
001 Log reviewer (001-gh-reviewer.md) |
GitHub → FEAT; logs → NEW | Issues + security advisories: up to 3 × FEAT-… / run for feature coders (×5 in loop). Advisories (triage / draft / published) get a tracking issue (body key security-advisory: GHSA-…) then FEAT-. Prefer advisories over ordinary issues. Logs: NEW-… only for concrete Docker log incidents |
agents2/tasks/ only. gh on satisfecho/pos issues and repos/…/security-advisories. See 001 prompt - never use NEW- for GitHub-sourced work. |
005 Marketing repos reviewer (005-marketing-repos-reviewer.md) |
NNN_slug org repos → register / deploy / FEAT-MKT | Preflight scans satisfecho/* repos named NNN_slug (e.g. 083_wimpi) for pushes and open issues |
config/marketing-sites.json, front/sites/<slug>/, FEAT-MKT-… tasks; triggers Deploy to amvara9 when bundles change. Live at https://www.satisfecho.de/<slug>/. |
008 Enhancement reviewer (008-enhancement-reviewer.md) |
Weekly repo health → FEAT-0 / NEW-0 | Preflight scans docs/changelog drift, demo seeds (check_demo_tables / waiting list / products / delivery orders / delivery settings), task-queue depth (~7d cadence). When PAUSE new_backlog or deep NEW with only owned docs/changelog SIGNAL themes (no failing demo SIGNAL), stamp only (FEAT: 0 | NEW: 0) - no new task files except a new unqueued product/demo finding. Stamp file is capped via scripts/rotate-008-time-of-last-review.sh (keep last ~100 lines; older → time-of-last-review.archive.txt). |
agents2/tasks/ only (FEAT-0-*, NEW-0-*); digest $AGENT_LOOP_TMP/008-latest-context.txt. Override: AGENT_ENHANCEMENT_REVIEWER_ALWAYS=1. |
011 Upstream monitor (011-upstream-monitor.md) |
Weekly public upstreams → POS issues | Preflight reads config/upstream-watch.json (URY ury-erp/ury, FloCafe FreeOpenSourcePOS/FloCafe, NodeDR OrderRestro Raktim94/nodedr-restaurant-pos, TastyIgniter tastyigniter/TastyIgniter). GitHub is called only when interval_days (default 7) have passed, or UPSTREAM_WATCH_FORCE=1. First scan baselines cursors and files nothing. Later CHANGE lines (commit subjects, release tag, open milestones, public doc headings such as OrderRestro ROADMAP.md and FloCafe CHANGELOG.md) wake the agent, which may open at most 3 adaptation issues on satisfecho/pos (one per project) with body key upstream-watch: owner/repo@ref. Separate from 005 marketing repos. |
Issues on satisfecho/pos only (no FEAT-* files; 001 queues those). Stamp agents2/011-upstream-monitor/time-of-last-review.txt. Digest $AGENT_LOOP_TMP/011-latest-context.txt. Override: AGENT_UPSTREAM_MONITOR_ALWAYS=1. |
002 Coder (002-coder-backend/CODER.md) |
Implementer (main) | NEW → wip; also continues wip when no NEW (orchestrator runs this step if NEW-*.md or WIP-*.md exists) |
back/, front/, tests; task file status + Testing instructions; then untested. |
006 Feature coder (010-feature-coder.md) |
Implementer (FEAT queue) | FEAT-*.md (including FEAT-MKT-* for marketing repos) → wip |
POS back//front/ or sibling marketing repo per task. |
003 Tester (TESTER.md) |
Verifier | untested → testing | Appends Test report; closed or back to wip on failure. Uses pytest (Docker), node front/scripts/…, npm run test:* per task. |
004 Closing reviewer (CLOSING-REVIEWER-PROMPT.md) |
Archivist | closed tasks | Prepends Closing summary; moves file to agents2/tasks/done/YYYY/MM/DD/ (date from CLOSED-YYYYMMDD-…; use scripts/move-agent-task-to-done.sh). |
007 Committer (040-committer.md) |
Changelog / version / commit | git status in POS root |
CHANGELOG.md, version bump; stages and commits finished work on development; Refs #N in message; scripts/link-commit-to-github-issues.sh comments on issues after push. Does not rewrite app logic. |
Orchestrator / security / release-watcher (mentioned in mac-stats-reviewer README.md): optional Cursor threads or human; not required for POS unless you add matching PROMPT-*.md files under agents2/.
Adapted filename pattern and statuses - same semantics as mac-stats-reviewer.
<STATUS>-<YYYYMMDD-HHMM>-<slug>.md
Examples: FEAT-20260323-1030-github-issue-50.md (GitHub → feature coder), NEW-20260323-1100-haproxy-503-logs.md (logs → main coder), WIP-20260323-1200-fix-rate-limit-banner.md
| Status | Meaning | Who moves it |
|---|---|---|
| new | Defined, not started | Coder picks → wip |
| feat | Feature-sized task (optional) | Feature coder picks → wip |
| wip | Active implementation | Coder → untested when done + testing instructions added |
| untested | Ready for verification | Tester → testing |
| testing | Under test | Tester → closed (pass) or wip (fail) |
| closed | Verified | Closing reviewer prepends summary → archives under agents2/tasks/done/YYYY/MM/DD/ (same basename; full date from CLOSED-YYYYMMDD-…). Use ./scripts/move-agent-task-to-done.sh. |
new ─┐
├─→ wip → untested → testing → closed → (done/YYYY/MM/DD/)
feat ─┘
Rules of thumb (no skipping):
- new/feat → wip when work starts (one clear owner per task in wip).
- wip → untested only after Testing instructions are appended (What to verify / How to test / Pass-fail criteria), same structure as mac-stats-reviewer’s coder prompt.
- untested → testing → closed (or testing → wip for rework).
- closed → done/YYYY/MM/DD/ after closing reviewer adds the Closing summary at the top of the file (see Done archive layout below).
Tester loop protection (from TESTER.md): if the same task fails verification more than three times, stop cycling; document in Test report, close per team policy (mac-stats-reviewer moves to closed with explanation).
Deploy-blocker archive: when prod verification FAILs only because the fix is on development but not yet on master / amvara9 (failed or blocked Deploy to amvara9), do not keep cycling testing → wip → untested. Archive the task (CLOSED-… → done/YYYY/MM/DD/) with a Closing summary noting the deploy blocker; resume after promotion + green deploy (see #212 / WIP-195).
Same idea as mac-stats-reviewer agents/run.sh, but named for clarity: one entrypoint to run log reviewer (001) → feature coder (up to ×5) → coder → tester → closing reviewer → committer on a timer, or single steps. Prefer ./agents2/pos-cursor-loop.sh (legacy agents/ path resolves via the agents → agents2 symlink when present).
| Invocation | Behaviour |
|---|---|
./agents2/pos-cursor-loop.sh |
Full cycle every AGENT_LOOP_SLEEP_MINUTES (default 5); requires cursor-agent on PATH. |
./agents2/pos-cursor-loop.sh log (or log-reviewer, 001) |
Run 001 log / incident reviewer only if the shell preflight finds work: open GitHub issues not yet linked from a root agents2/tasks/*.md (#NN / issues/NN), open repository security advisories (triage / draft / published) with no GHSA-… in root tasks, or Docker log lines matching incident heuristics. Otherwise 001 skips cursor-agent (saves tokens). Digest: $AGENT_LOOP_TMP/001-latest-context.txt (default $TMPDIR/pos-agent-loop/). Override: AGENT_LOG_REVIEWER_ALWAYS=1 or AGENT_001_SKIP_PREFLIGHT=1. |
./agents2/pos-cursor-loop.sh marketing (or mkt, 005) |
Run 005 marketing repos reviewer only if preflight finds new/changed NNN_slug org repos, deploy candidates, or untracked issues in those repos. Digest: $AGENT_LOOP_TMP/005-latest-context.txt. Override: AGENT_MARKETING_REVIEWER_ALWAYS=1 or AGENT_005_SKIP_PREFLIGHT=1. |
./agents2/pos-cursor-loop.sh enhancement (or enhance, 008) |
Run 008 enhancement reviewer only if preflight finds weekly due (≥7d since last stamp) or improvement SIGNAL lines (docs drift, demo seeds, queue backlog). Digest: $AGENT_LOOP_TMP/008-latest-context.txt. Override: AGENT_ENHANCEMENT_REVIEWER_ALWAYS=1 or AGENT_008_SKIP_PREFLIGHT=1. |
./agents2/pos-cursor-loop.sh upstream (or 011) |
Run 011 upstream monitor only if the weekly interval has elapsed and preflight sees public changes since agents2/011-upstream-monitor/last-scan.json. Watch list: config/upstream-watch.json. Digest: $AGENT_LOOP_TMP/011-latest-context.txt. Override: AGENT_UPSTREAM_MONITOR_ALWAYS=1 or AGENT_011_SKIP_PREFLIGHT=1. |
./agents2/pos-cursor-loop.sh coder |
Run coder step if NEW-*.md or WIP-*.md exists (and prompt file present). Prefer finishing NEW first; WIP continues in-progress work. |
./agents2/pos-cursor-loop.sh tester |
Run tester if UNTESTED-*.md or in-progress TESTING-*.md exists (so interrupted runs are not stuck). |
./agents2/pos-cursor-loop.sh feat |
Run feature coder if FEAT-*.md exists and preflight finds at least one actionable task (not parked waiting for human). Digest: $AGENT_LOOP_TMP/006-latest-context.txt. Override: AGENT_FEAT_REVIEWER_ALWAYS=1 or AGENT_006_SKIP_PREFLIGHT=1. |
./agents2/pos-cursor-loop.sh closing-review |
Run closer if CLOSED-*.md still in agents2/tasks/. |
./agents2/pos-cursor-loop.sh committer |
Run committer if POS repo has unstaged/staged changes. |
./agents2/pos-cursor-loop.sh promote (or 009, deploy) |
Run 009 daily promote: merge development → master via scripts/promote-development-to-master.sh when cadence allows (default ≥24h since last master tip and development is ahead). No cursor-agent. Disable with AGENT_PROMOTE=0. |
./agents2/pos-cursor-loop.sh help |
Usage. |
Host roles:
| Host | Checkout | Loop mode | Role |
|---|---|---|---|
| amvara3 | development |
AGENT_LOOP_MODE=full (default) |
Coding agents, FEAT intake, committer, 009 promote (development → master) |
| amvara9 | master (/development/pos) |
AGENT_LOOP_MODE=prod-ops |
Docker log preflight + severe-log GitHub alerts only. No git-sync-development, coding, or promote. Deploy is GitHub Actions on push to master (SSH reset to master). |
Set prod-ops in /etc/default/pos-cursor-loop on amvara9 (AGENT_LOOP_MODE=prod-ops), then systemctl restart pos-cursor-loop.
Keep the loop running (reboot-safe): on the host (e.g. amvara9 / amvara3), install once as root:
./scripts/install-pos-cursor-loop-systemd.shThat installs pos-cursor-loop.service (Restart=always, enabled on boot), writes optional overrides to /etc/default/pos-cursor-loop, and adds a cron watchdog every 5 minutes (scripts/watchdog-pos-cursor-loop.sh) so a stopped unit is started again. Log: tmp/pos-cursor-loop.log. Status: systemctl status pos-cursor-loop or ./scripts/watchdog-pos-cursor-loop.sh --status. Uninstall: ./scripts/install-pos-cursor-loop-systemd.sh --uninstall.
Git sync stuck (process alive, no FEAT intake): stamp-only dirty reviewer files used to conflict under git pull --rebase --autostash, leave unmerged paths, and skip every agent step while the pid stayed healthy. Prevention:
scripts/git-sync-development.shdiscards allowlisted stamp dirt before pull; on unmerged paths it exits 2 and writestmp/agent-git-sync-blocked.txt.- CHANGELOG.md (recurring amvara3 case): Sync parks local-only Unreleased bullets before pull and auto-unions
CHANGELOG.md-only conflicts (scripts/git-sync-merge-changelog.py). Disable withAGENT_GIT_SYNC_CHANGELOG_AUTO=0. - Large dirty trees: If non-stamp dirt is huge (≥40 paths, or CHANGELOG dirty with ≥20 other paths), sync auto-shelves to
wip/agent-host-autoshelve-*, pushes, and hard-resetsdevelopmenttoorigin/developmentso the loop cannot stay blocked for days. Disable withAGENT_GIT_SYNC_AUTOSHELVE=0. Prefer committing via 007 so this never fires. Branch housekeeping: keepmaster,development, and any human WIP with unique product work (e.g.gilberto-dev). After recovery ontodevelopment, prune oldwip/agent-host-autoshelve-*refs; keep only the newest one or two as a short backup. Do not delete closed feature branches until you confirm the work landed elsewhere or is abandoned. scripts/watchdog-pos-cursor-loop.shalerts when the block stamp is older thanAGENT_GIT_SYNC_BLOCK_ALERT_MINUTES(default 30). It first runsscripts/recover-agent-git-sync-block.sh(abort merge/rebase, hard-reset tracked conflicts, re-sync). Disable withAGENT_GIT_SYNC_AUTO_RECOVER=0. Only if recovery fails does it open one GitHub issue (agent-loop-blocker: git-sync).- Delegation: Coding loop host is amvara3 (
/home/amvara/projects/pos). Stamp path/development/posis amvara9 (production checkout). Do not park a FEAT as waiting-for-human when SSH can recover: on the host run./scripts/recover-agent-git-sync-block.sh, or from a laptop with SSH useAGENT_GIT_SYNC_REMOTE_HOST=amvara9 AGENT_GIT_SYNC_REMOTE_PATH=/development/pos AGENT_GIT_SYNC_RETURN_BRANCH=master ./scripts/recover-agent-git-sync-block.sh. Seedocs/pos-dev-amvara3.md.
Legacy background loop (no systemd): ./scripts/start-pos-cursor-loop-background.sh (or --restart) runs the full cycle under nohup; pid tmp/pos-cursor-loop.pid, log tmp/pos-cursor-loop.log. The watchdog falls back to this path when the systemd unit is not enabled.
001 - if gh issue list fails: preflight retries with gh api repos/<owner>/<repo>/issues?state=open&per_page=40 (issues only, PRs excluded) so G001_UNTRACKED_ISSUES and the digest can still see new work when the REST call succeeds.
001 - GitHub not authenticated: If gh stderr indicates 401 / bad credentials, pos-cursor-loop.sh prints a stderr banner on the console and sets G001_GH_AUTH_FAILED=1 in the digest summary; gh stderr is appended under === gh issue list stderr === / gh api sections.
Git: scripts/git-sync-development.sh runs only when a step actually has work (unless AGENT_GIT_SYNC=0): 001 syncs only when its preflight gate opens; 002-004 / 006-007 sync only when their queue (or, for 007, uncommitted changes) is non-empty. See Sync before edits (multi-agent) above.
Prefer config over parking: For multi-option product choices (modes, surfaces, thresholds), 010 ships a setting with a sensible default instead of waiting on GitHub. Park only for hard gates (secrets, irreversible ops, legal, paid third-party, or the issue says wait). See agents2/010-feature-coder.md and agents2/TASKS-README.md.
Stale waiting FEAT → REJECTED: Each cycle, before the 006 batch, scripts/agent-feat-stale-waiting-reject.sh archives FEAT tasks that are waiting for human with a Waiting notice posted: stamp older than AGENT_FEAT_WAITING_REJECT_DAYS (default 30) and no non-agent issue reply. Files become REJECTED-… under agents2/tasks/done/YYYY/MM/DD/; the script comments on the linked issue and closes it as not planned unless AGENT_FEAT_STALE_CLOSE_ISSUE=0. Disable with AGENT_FEAT_STALE_REJECT=0.
Token-saving gates: 002 / 003 / 004 / 006 / 007 skip cursor-agent and skip git sync when there is no matching task file at agents2/tasks/ root or (committer) no unstaged/staged diff. For 003, “matching” means UNTESTED-*.md or TESTING-*.md (unfinished test runs stay in the queue). 006 runs at most five times per cycle and stops the FEAT batch early when no FEAT-*.md remains or when every FEAT task is parked waiting for human (one waiting GitHub comment + Waiting notice posted: stamp in the task file; no further 010 runs or issue comments until a human replies - scripts/agent-feat-waiting-human-preflight.sh). 001 adds a preflight digest (issues + security advisories + log heuristics). Committer in agents2/pos-cursor-loop.sh runs 040-committer.md via cursor-agent by default when there are non-stamp changes (AGENT_COMMITTER_USE_CURSOR default 1). Stamp-only dirty trees (allowlisted time-of-last-review.txt / last-scan.json under 001/005/008/011) are not committed (AGENT_COMMITTER_LOCAL, default on): leave stamps local until a later commit that includes real code/docs/task work (#313). After a new commit, scripts/link-commit-to-github-issues.sh posts on linked GitHub issues.
Wall-clock limits (stuck-loop guard): agents2/pos-cursor-loop.sh wraps every cursor-agent invocation with a per-step timeout (GNU timeout when on PATH, else a bash fallback). Defaults: AGENT_CURSOR_TIMEOUT_MINUTES=25 for most steps; AGENT_TESTER_TIMEOUT_MINUTES=32 for 003 (deploy polling + production checks). On timeout (exit 124) the orchestrator logs and continues the loop (same as a non-zero exit); TESTING-*.md / WIP-*.md are picked up on the next cycle. Set AGENT_CURSOR_TIMEOUT=0 to disable limits. Legacy run-agents.sh used timeout 15m for goose; the cursor loop had no equivalent until this guard.
Further token / cost ideas (not all implemented):
- Raise
AGENT_LOOP_SLEEP_MINUTESwhen the queue is usually empty - fewer full cycles. AGENT_GIT_SYNC=0on a laptop loop - saves network; use when you know nobody else is pushing.- Committer (
agents2/pos-cursor-loop.sh):AGENT_COMMITTER_USE_CURSORdefaults to 1 -cursor-agentruns040-committer.mdwhen there are uncommitted non-stamp changes. Stamp-only trees (001/005/008/011 reviewer stamps andlast-scan.json) are skipped byAGENT_COMMITTER_LOCAL(default on): no chore stamp commit, no cursor-agent; files stay dirty until bundled with real work (#313). The committer commits when work looks complete, writes a human-readableCHANGELOG.md, includesRefs #Nin the commit message, and the loop runsscripts/link-commit-to-github-issues.shafter a new commit. SetAGENT_COMMITTER_USE_CURSOR=0only to disable automatic cursor committer. - Local LLM (Ollama → llama.cpp):
cursor-agentis still required for steps that editback/,front/, and run tools inside Cursor. Local models cannot replace that without a separate "apply patch + run tests" runner. What does help is cheap triage and, by default, nocursor-agentfor non-severe log-only noise when GitHub preflight succeeded and there are no untracked issues (AGENT_001_LOCAL_LOG_REVIEWER, default on - see below). Local modelSKIPstill clearsG001_LOG_SIGNALSwhen triage runs for ordinary noise;ESCALATEno longer forcescursor-agentin that log-only + empty-queue case unlessAGENT_001_LOCAL_LOG_REVIEWER=0. Standing ASGI / Internal Server hits are special (#477):G001_SEVERE_LOG_SIGNALS: set when Docker hits includeException in ASGIorInternal Server(not TS/NG compiler noise or scanner 404s). These always bypass the local log-reviewer skip:cursor-agentruns, and local LLM triage cannot clear the flag.AGENT_001_SEVERE_LOG_ESCALATE(default not 0):scripts/agent-001-escalate-severe-logs.shopens a deduped tracking GitHub issue (agent-log-incident: severe+ fingerprint) without pasting raw log blobs. Set to 0 to skip deterministic create (cursor still runs for severe).AGENT_001_LOCAL_LOG_REVIEWER(default not 0):agents2/pos-cursor-loop.shdoes not invokecursor-agentfor 001 whenG001_GH_OK=1,G001_UNTRACKED_ISSUES=0,G001_LOG_SIGNALS=1, andG001_SEVERE_LOG_SIGNALS=0(ordinary Docker heuristics only, GitHub queue empty). Preflight and optional Ollama/llama triage still run; a one-line stamp is appended toagents2/001-gh-reviewer/time-of-last-review.txtand the digest gets=== 001 cursor-agent skipped (local log reviewer) ===. SetAGENT_001_LOCAL_LOG_REVIEWER=0to restorecursor-agentfor ordinary log-only noise too.cursor-agentstill runs for severe signals,G001_UNTRACKED_ISSUES> 0,AGENT_LOG_REVIEWER_ALWAYS,AGENT_001_SKIP_PREFLIGHT, orAGENT_001_RUN_WHEN_GH_UNKNOWNwhen those gates apply.- On by default when
scripts/agent-ollama-log-triage.shcan run (AGENT_001_OLLAMA_LOG_TRIAGE≠0): default order isollama runfirst (OLLAMA_MODELdefaultGemma4:latest), then llama.cpp OpenAI-compatiblePOST …/chat/completions(defaulthttp://127.0.0.1:8080/v1,Bonsai-8B.gguf) if Ollama is empty or missing. SetAGENT_001_LLAMA_CPP_FIRST=1for llama.cpp first (previous behavior). If the primary reply has no clearESCALATE/SKIP, the script tries the other backend once before defaulting to escalate. The prompt asks for a final line with onlySKIPorESCALATE. The loop passesOLLAMA_MODELinto the triage script.OLLAMA_HOSTdefaults tohttp://127.0.0.1:11434only when unset. SetAGENT_001_LOG_TRIAGE_DEBUG=1for stderr frompython3andollama run. Triage is available ifGET …/v1/modelssucceeds andpython3exists, orollama listshows ≥1 model (OLLAMA_HOSTrespected inagents2/pos-cursor-loop.sh).AGENT_001_SKIP_LLAMA_CPP=1uses Ollama only. Log triage runs only when Docker heuristics would trigger 001 and there are zero untracked GitHub issues (issues path unchanged - no missed FEAT from local LLM). - Ollama model: repo default for triage is
Gemma4:latest(OLLAMA_MODEL). Otherollama listexamples:qwen2.5:1.5b,nemotron-3-nano:4b,huihui_ai/granite3.2-abliterated:2bfor speed;qwen3.5:4b/gemma3:latestfor alternatives;qwen2.5-coder:latestonly if you later add code-shaped local steps (heavier).
- Possible future: local model drafts closing summaries (004) or commit messages as text-only, then a thin shell step writes the file - still needs review for quality and safety.
Docker / stack: still start with repo-root ./run.sh or ./run.sh -dev - this script does not replace the POS application runner.
Prompts: steps skip if the corresponding markdown under agents2/ (e.g. 001-gh-reviewer.md, 002-coder/CODER.md, 020-test.md) is missing. Steps also skip if cursor-agent is missing (single commands); the infinite loop exits immediately if cursor-agent is not installed.
Prompt markdown and the orchestrator live under agents2/. Active task files live in agents2/tasks/; pipeline rules in agents2/TASKS-README.md.
agents2/
TASKS-README.md # Live pipeline (statuses, archive); adapted from mac-stats agents/tasks/README.md
pos-cursor-loop.sh # Orchestrator (mac-stats-reviewer style); see section above
001-gh-reviewer.md # Role prompts (also 005/008/011/010/020/030/040-*.md)
002-coder/
CODER.md # Adapt: implement under back/, front/; read docs/ first
tasks/
done/ # Archived CLOSED-* tasks: done/YYYY/MM/DD/ (see done/README.md)
inbox/ # Optional: orchestrator-only queue (mac-stats-reviewer pattern)
007-committer/
# Optional role dirs / stamps as needed
Prompt authoring: Start from the markdown in ~/projects/mac-stats-reviewer/agents/ and replace paths (~/projects/mac-stats → this repo root), log locations (Docker and docs/error-investigation-workflow), and stack commands (docker compose, front/scripts/). Land adapted prompts under agents2/.
Unlike a flat done/ folder, POS keeps closed tasks under agents2/tasks/done/<YYYY>/<MM>/<DD>/. The full calendar date comes from the YYYYMMDD segment in the filename (e.g. CLOSED-20260323-1200-slug.md → done/2026/03/23/), so one folder per day: all tasks whose CLOSED- stamp uses that day are grouped together. Put the actual finish / closure day in YYYYMMDD when naming CLOSED-… files so the archive matches “work done that day.”
- Closing reviewer (or operator): after prepending the closing summary, run
./scripts/move-agent-task-to-done.sh agents2/tasks/CLOSED-….md
(script accepts the path you pass; legacyagents/tasks/…still works when theagents→agents2symlink is present) - Details:
agents2/TASKS-README.md,agents2/tasks/done/README.md
- Per task: Tester follows Testing instructions; prefer scripts already listed in
docs/testing.mdandAGENTS.md(Puppeteer,pytestin container). - After substantive edits (including agent work): Minimum smoke: HTTP 200 on app URL or
npm run test:landing-versionwithBASE_URL; if Angular touched, checkdocker compose … logs --tail=80 frontfor compile errors (AGENTS.md). - Long-running pull + test loop (already in POS):
scripts/go-ahead-loop.sh-git pull --rebase --autostash, Docker pytest,npm run test:landing-version. Opt-inGO_AHEAD_LOOP=1. Seedocs/testing.md(section Long-running smoke loop). Run it from adevelopmentcheckout so pulls match the integration branch. This is not a substitute for task-driven testing; it complements it like a release health cadence.
mac-stats-reviewer’s committer edits CHANGELOG.md and src-tauri/Cargo.toml in mac-stats. For POS:
- Update
CHANGELOG.mdunder[Unreleased](Keep a Changelog style). - Version source:
front/package.jsonandfront/package-lock.json(see.cursor/rules/commit-changelog-version.mdc). - Does not rewrite application source; does
git add/ commit coder output when ready. - Branch policy: commit on
development;git push origin development. Merge tomasteronly per Git branching and production above - not on every committer run. - Issues: after push,
./scripts/link-commit-to-github-issues.sh(also invoked by the loop) comments on issues linked fromagents2/tasks/files in the commit.
Optional: track last version bump time in agents2/007-committer/last-version-bump.txt if you want mac-stats-reviewer’s “at most twice a day” style cap.
Is it possible? Yes. Issues for this repo can be updated from the agent workflow using the GitHub REST API or the gh CLI, as long as a credential with permission to read/write issues is available (see Authentication below). Issues do not have a built-in “WIP” field; use labels (and/or GitHub Projects “Status”) so each role can signal state in a consistent, machine-friendly way.
- Fine-grained PAT or classic PAT with Issues read/write on
satisfecho/pos, orgh auth loginon the machine running the agent. - Expose to tools as
GH_TOKEN/GITHUB_TOKEN(many tools accept either). Never commit tokens; use shell env, CI secrets, or local keychain viagh. - In GitHub Actions, the default
GITHUB_TOKENcan comment and label on the same repo when workflows are enabled.
Agent host refresh (when gh returns 401):
- Check whether a stale env token is overriding keyring auth:
echo "GH=${GH_TOKEN:+set} GITHUB=${GITHUB_TOKEN:+set}"thengh api user -q .login. StaleGH_TOKEN/GITHUB_TOKENvalues overridegh auth loginand cause HTTP 401. - Prefer keyring:
unset GH_TOKEN GITHUB_TOKENthen re-checkgh api user -q .login. The loop already does this viaensure_gh_auth_envinagents2/pos-cursor-loop.sh. - If still failing:
gh auth login(HTTPS, scopes including repo / Issues) or export a fresh scoped PAT asGH_TOKEN(do not commit it; do not paste into task files). - Smoke:
gh issue view NN --repo satisfecho/posandgh issue comment NN --repo satisfecho/pos --body "…".
At the top of each task markdown (or immediately under the title), add a stable pointer:
## GitHub
- **Issue:** https://github.com/satisfecho/pos/issues/NNThe reviewer uses the issue list as the input backlog. When they create the feature/task file, they record NN in that section (and optionally quote the issue title in the task body).
| Label | Meaning |
|---|---|
agent:planned |
Task file exists; scoped for implementation (reviewer handoff). |
agent:wip |
Coder or feature coder is implementing (rename task to wip in sync with this). |
agent:testing |
Tester is running Testing instructions (task in testing). |
production-urgent |
Issue may be merged to master immediately (bypasses normal daily batch only in the sense of intent - still follow tests/review). |
Adjust names to taste (status/planned, etc.); keep them documented here so every agent uses the same set.
| Role | When | Update the issue |
|---|---|---|
| Reviewer (001 / planning) | After creating FEAT-… for issue #NN (never NEW- for GitHub) |
Comment: link agents2/tasks/FEAT-…md; label agent:planned. Optionally remove agent:needs-triage. |
| Coder & Feature coder | When renaming task new/feat → wip | Add comment: “Implementation started”; agent:planned → agent:wip (remove planned, add wip). |
| Tester | When renaming untested → testing | Add comment: “Verification started” (commands/env if useful); agent:wip → agent:testing. |
| Committer (040) | After git push origin development for a commit that includes related task files |
Comment via scripts/link-commit-to-github-issues.sh (commit link + subject); commit message should include Refs #NN. |
| Closer | After Test report is PASS and task is closed, before/after move-agent-task-to-done.sh |
Comment: one-paragraph outcome + pointer to merged commit or PR if applicable; remove agent:testing / agent:wip. Close the issue if the feature is fully delivered and tracked only here; leave open if the issue is a parent epic or has follow-ups (say so in the comment). |
On test failure (testing → wip), the tester should comment on the issue with what failed and keep or restore agent:wip as appropriate.
# Prefer: gh auth login (or export GH_TOKEN from a local secret store)
gh issue list --repo satisfecho/pos --state open --limit 30
gh issue comment 50 --repo satisfecho/pos --body "Task file: agents2/tasks/FEAT-20260323-1030-order-tip.md - planned for implementation (feature queue)."
gh issue edit 50 --repo satisfecho/pos --add-label "agent:planned"
gh issue edit 50 --repo satisfecho/pos --remove-label "agent:planned" --add-label "agent:wip"Equivalent HTTP calls are documented in GitHub REST: Issues.
- Agents do not talk to GitHub by default - prompts must instruct the agent to run
ghorcurl(with token), or a human performs the issue update alongside the task rename. - Rate limits apply; batch comments sparingly.
- Parent/child issues: if one task maps to a single GitHub issue, keep a 1:1 link in the task file. If one issue spans multiple tasks, note that in comments and link each task file from the issue thread.
| mac-stats-reviewer item | POS note |
|---|---|
Hourly launchd commits |
Not required; POS uses explicit commits. |
Dual-repo workspace (mac-stats-agent-workspace.code-workspace) |
Single repo unless you split a pos-reviewer clone later. |
cursor-agent < PROMPT.md |
Use Cursor Chat/Agent with agents2/.../*.md open or pasted; CLI availability varies. |
start-all-agents.sh + per-agent inboxes |
Optional later; start with one agents2/tasks/ folder and agents2/TASKS-README.md. |
| Track A autoresearch / Ollama autopilot | Separate infrastructure; document only in docs/agent-loop.md until you port or reference externally. |
mac-stats-reviewer’s agents/autoresearch/README.md describes Track A: mutate only <!-- TRACK_A_AUTORESEARCH_* --> blocks in agent markdown, judge/mutate loop, optional 24h runs. POS does not include this harness. If you add it, keep POS-specific suites (e.g. “tester must cite BASE_URL and Docker compose files”) and do not require cloud Ollama unless policy allows.
agents2/TASKS-README.mdandagents2/tasks/done/README.mddefine the pipeline anddone/YYYY/MM/DD/layout; usescripts/move-agent-task-to-done.shwhen archiving (pass anagents2/tasks/CLOSED-…path).- Prompts ship in
agents2/(role.mdfiles and role dirs); refine them as needed. - Link from
AGENTS.mdor.cursor/rules- one line: “Multi-agent task workflow:docs/agent-loop.md.” - Train the team on task renames and Testing instructions / Test report format (mirror mac-stats-reviewer for consistency).
agents2/pos-cursor-loop.sh- orchestrator forcursor-agent(see Agent loop script above).- Optional: add
agents2/start-all-agents.sh-style helpers only if you run multiple Cursor sessions regularly.
AGENTS.md- Docker, smoke tests,development/master, frontend log checks..cursor/rules/git-development-branch-workflow.mdc- always-on branch and promotion rules for agents.ROADMAP.md- high-level shipped / next / deferred; refresh ~weekly (checklist in that file) after CLOSED product batches or when 008 sees drift.docs/0032-github-issues-roadmap.md- Umbrella issues #52-#54 and links (keep the #52 table aligned withROADMAP.md).docs/testing.md- Puppeteer scripts,go-ahead-loop.sh..cursor/rules/error-investigation-workflow.mdc- log order for incidents..cursor/rules/commit-changelog-version.mdc- changelog and version bump when cutting work.