Skip to content

t1455: add non-code routine execution guidance and helper#4251

Merged
marcusquinn merged 2 commits intomainfrom
chore/non-code-routine-guidance
Mar 12, 2026
Merged

t1455: add non-code routine execution guidance and helper#4251
marcusquinn merged 2 commits intomainfrom
chore/non-code-routine-guidance

Conversation

@marcusquinn
Copy link
Copy Markdown
Owner

@marcusquinn marcusquinn commented Mar 12, 2026

Summary

  • clarify that /full-loop is for code-change tasks while recurring operational tasks should run direct agent commands
  • add /routine command guidance covering SOP/targets/schedule design, pilot rollout, and safety gates
  • add routine-helper.sh to plan and install scheduled opencode run routines for cron/launchd usage

Verification

  • shellcheck .agents/scripts/routine-helper.sh
  • markdown-formatter check for updated/new command docs and .agents/AGENTS.md
  • .agents/scripts/routine-helper.sh plan --name seo-weekly --schedule "0 9 * * 1" --dir "/tmp" --agent "SEO" --title "Weekly rankings" --prompt "/seo-export --account client-a --format summary"

Closes #4250

Summary by CodeRabbit

  • Documentation

    • Added comprehensive guides for designing and scheduling recurring operational routines with workflow patterns
    • Clarified distinct execution modes for code changes versus operational tasks
  • New Features

    • Introduced utility for planning and installing scheduled operational routines with customizable scheduling options

@github-actions github-actions bot added the enhancement Auto-created from TODO.md tag label Mar 12, 2026
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the system's capability to manage and automate non-code operational tasks by providing clear guidelines for distinguishing between code-change workflows and direct operational execution. It introduces a structured approach for designing and deploying recurring routines and offers a helper script to streamline the scheduling process. These changes aim to improve efficiency and reduce the overhead associated with automating routine tasks that do not require code modifications or pull request traceability.

Highlights

  • Operational Routine Guidance: Clarified the distinction between using /full-loop for code-change tasks and direct agent commands for recurring operational tasks, providing a decision rule and a five-step sequence for operational execution.
  • New /routine Command Documentation: Introduced comprehensive guidance for the new /routine command, detailing the workflow for designing, validating, piloting, and scheduling non-code operational routines, along with a routine specification template and anti-patterns.
  • Routine Helper Script: Added a new routine-helper.sh script to simplify the planning and installation of scheduled opencode run routines for both cron and launchd systems, including argument parsing, validation, and command generation.
  • Updated Runners Documentation: Modified the runners documentation to explicitly differentiate between code-change and operational tasks, updating dispatch instructions and worker responsibilities to reflect the new execution modes.
Changelog
  • .agents/AGENTS.md
    • Added a new section on "Operational Routines (Non-Code Work)" to guide users on when to use direct agent commands versus /full-loop for autonomous tasks.
  • .agents/scripts/commands/routine.md
    • Introduced new documentation for the /routine command, providing comprehensive guidance on designing and scheduling recurring non-code operational routines.
  • .agents/scripts/commands/runners.md
    • Modified the runners documentation to explicitly differentiate between code-change and operational tasks, updating dispatch instructions and worker responsibilities accordingly.
  • .agents/scripts/routine-helper.sh
    • Created a new routine-helper.sh script to assist in planning and installing scheduled opencode run routines for both cron and launchd systems.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 12, 2026

Warning

Rate limit exceeded

@marcusquinn has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 22 minutes and 0 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 249d13f7-905e-4a97-8f22-a0a05ccb1123

📥 Commits

Reviewing files that changed from the base of the PR and between 8133e6b and c2bb03f.

📒 Files selected for processing (4)
  • .agents/AGENTS.md
  • .agents/scripts/commands/routine.md
  • .agents/scripts/commands/runners.md
  • .agents/scripts/routine-helper.sh

Walkthrough

This pull request introduces a structured framework for designing and scheduling non-code operational routines, with updated dispatch documentation to distinguish code-change work from operational task execution, alongside a new Bash utility script that plans and installs scheduled routines via cron or launchd.

Changes

Cohort / File(s) Summary
Operational Routines Documentation
AGENTS.md, .agents/scripts/commands/routine.md, .agents/scripts/commands/runners.md
Introduces "Operational Routines" section defining when to use non-code workflows; adds design document with SOP/Targets/Schedule dimensions, step-by-step workflow, and YAML spec template; updates runners.md to distinguish code-change tasks (/full-loop) from operational tasks (direct execution) with separate supervisor dispatch and worker routing logic.
Routine Scheduler Implementation
.agents/scripts/routine-helper.sh
New 380-line Bash utility providing plan, install-cron, and install-launchd workflows; handles cron expression validation, launchd plist generation from cron syntax, opencode command construction, and safe error handling with logging.

Sequence Diagram

sequenceDiagram
    participant User
    participant Routine Helper as routine-helper.sh
    participant Opencode as opencode run
    participant System as cron/launchd
    
    User->>Routine Helper: plan --name --schedule --prompt
    Routine Helper->>Routine Helper: validate inputs & cron syntax
    Routine Helper->>Routine Helper: build opencode invocation
    Routine Helper-->>User: show plan & feasibility
    
    User->>Routine Helper: install-cron/install-launchd
    Routine Helper->>Routine Helper: parse cron to launchd XML (if launchd)
    Routine Helper->>System: register job (cron entry or plist)
    System-->>Routine Helper: confirmation
    
    System->>System: at scheduled time
    System->>Opencode: invoke with targets_cmd, run_template
    Opencode->>Opencode: execute SOP against targets
    Opencode-->>System: report outcomes
Loading

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly Related PRs

  • #2295: Modifies AGENTS.md and runners.md to introduce per-task routing and execution modes (code vs ops), directly aligned with this PR's dispatch philosophy changes.
  • #2404: Updates supervisor/pulse dispatch flow and code-vs-ops task routing, overlapping with the runner dispatch logic introduced here.
  • #1329: Modifies AGENTS.md's CLI/tooling references; potential surface-level conflict with opencode references in this PR's documentation.

Suggested Labels

needs-review, documentation, feature, shell-script, devops-automation

Poem

🤖 The routines now dance on cron's steady beat,
SOPs scheduled, targets met, operations complete,
From plan to plist, each task finds its place,
Launchd and cron keeping automation's pace. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: adding non-code routine execution guidance and helper tooling.
Linked Issues check ✅ Passed The PR comprehensively addresses issue #4250 by documenting the non-code routine scheduling workflow and providing implementation tooling.
Out of Scope Changes check ✅ Passed All changes are directly scoped to non-code routine execution: documentation (AGENTS.md, routine.md, runners.md updates) and the routine-helper.sh implementation tool.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/non-code-routine-guidance
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown
Contributor

🔍 Code Quality Report

�[0;35m[MONITOR]�[0m Code Review Monitoring Report

�[0;34m[INFO]�[0m Latest Quality Status:
SonarCloud: 0 bugs, 0 vulnerabilities, 402 code smells

�[0;34m[INFO]�[0m Recent monitoring activity:
Thu Mar 12 21:52:46 UTC 2026: Code review monitoring started
Thu Mar 12 21:52:47 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 402

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 402
  • VULNERABILITIES: 0

Generated on: Thu Mar 12 21:52:50 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new concept of 'operational routines' for non-code tasks, distinguishing them from code-change tasks that use /full-loop. It adds extensive documentation for this new workflow and a new helper script, routine-helper.sh, to facilitate scheduling these routines with cron or launchd. The changes are well-documented and the new script is robust. I've found a minor documentation issue and a high-severity XML injection vulnerability in the new helper script that could lead to malformed launchd configuration files.

<array>
<string>/bin/bash</string>
<string>-lc</string>
<string>${command}</string>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-high high

This is a potential XML injection vulnerability. The ${command} variable is inserted directly into the XML heredoc without proper escaping. If the command string contains special XML characters like <, >, or & (e.g., in a prompt with redirection or shell logic), it will generate a malformed .plist file, causing launchctl load to fail. The command string should be XML-escaped before being embedded in the plist.

As per the rule for preventing injection, input must be sanitized and context-specific escaping applied before interpolation. You can achieve this by defining an XML-escaping function or using sed to replace the special characters (e.g., & with &amp;, < with &lt;) before the cat <<EOF block.

References
  1. To prevent injection vulnerabilities in shell scripts, sanitize input using a strict allowlist and also perform context-specific escaping (e.g., doubling single quotes for SQL strings) before interpolating the value into a query. This principle applies to XML content as well, requiring XML-specific escaping.

2. **It dispatches `opencode run` for each item** — one worker per task
3. **Code workers** handle branch -> implementation -> PR -> CI -> merge
4. **Ops workers** execute the requested SOP/command and report outcomes
4. **No databases, no state machines, no complex bash pipelines**
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

There's a minor typo in this numbered list. This item is numbered as 4., but the previous item is also 4.. This should be 5. to maintain the correct sequence.

Suggested change
4. **No databases, no state machines, no complex bash pipelines**
5. **No databases, no state machines, no complex bash pipelines**

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🧹 Nitpick comments (1)
.agents/AGENTS.md (1)

45-66: Keep the root guide at the decision rule and link out for the workflow.

This five-step playbook duplicates .agents/scripts/commands/routine.md and adds fairly task-specific guidance to the top-level instructions. Trimming this to the routing rule plus a pointer to /routine would reduce drift and keep .agents/AGENTS.md focused on broadly applicable rules. Based on learnings: "Applies to **/AGENTS.md : Every instruction in AGENTS.md must be relevant to >80% of tasks" and "Applies to **/AGENTS.md : Use progressive disclosure in AGENTS.md by providing pointers to subagents rather than inline content."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.agents/AGENTS.md around lines 45 - 66, The top-level AGENTS.md should not
inline the five-step playbook that duplicates
.agents/scripts/commands/routine.md; replace the detailed step list (Design the
operator..., Prove it ad-hoc..., Harden guardrails..., Pilot safely..., Schedule
the command...) with the concise decision rule already present and a single
pointer to the routine doc (referencing the existing /routine or
.agents/scripts/commands/routine.md) so AGENTS.md stays focused on broadly
applicable rules and avoids task-specific guidance.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.agents/scripts/commands/routine.md:
- Around line 94-107: Clarify that the example Routine Spec template is not
currently executable with the helper: update the doc text near the "Routine Spec
Template" example to state that .agents/scripts/routine-helper.sh currently only
accepts a literal --prompt and does not wire targets_cmd or run_template into
the plan, install-cron, or install-launchd flows; alternatively, if you prefer
to make it runnable now, implement support in routine-helper.sh to parse
targets_cmd and run_template and pass them through to the
plan/install-cron/install-launchd code paths (modify routine-helper.sh and the
plan/install handlers to accept and expand those fields). Reference the fields
targets_cmd and run_template and the script routine-helper.sh and the commands
plan, install-cron, install-launchd so maintainers can locate the code to
change.

In @.agents/scripts/commands/runners.md:
- Around line 240-242: Update the contradictory bullet that hard-codes
"/full-loop": replace the line that reads '**Always** dispatches workers via
`opencode run "/full-loop ..."` with wording that says workers are dispatched
via `opencode run` and the command is chosen by task type (e.g., code tasks may
use `"/full-loop ..."` while ops routines use a different command), so the doc
reflects dispatch via `opencode run` with command chosen by task type rather
than always using `/full-loop`.
- Around line 34-36: The docs disagree: runners.md implies flexible
execution-mode routing but pulse.md hard-codes dispatches to "/full-loop" (and
counts workers via grep '/full-loop'); fix by either (A) updating runners.md to
explicitly state that the pulse implementation currently always uses the
"/full-loop" path for worker dispatch and counting, or (B) make pulse.md follow
the general routing model by replacing hard-coded "/full-loop" dispatch targets
and the worker-count grep with the generic routing variable/interface used by
runners.md (so functions/commands that call opencode run use the common
execution-mode variable instead of "/full-loop"). Locate occurrences of
"/full-loop", the worker-counting grep, and the dispatch command invocations in
pulse.md and update them accordingly, and update runners.md text to reflect
which behavior is implementation-specific.

In @.agents/scripts/routine-helper.sh:
- Around line 81-85: The validate_routine_prompt function currently only warns
when a prompt contains "/full-loop"; change it to fail fast by returning a
non-zero exit (e.g., call exit 1) after printing an error message to stderr so
callers (plan and install-* flows) stop immediately—update
validate_routine_prompt to detect "/full-loop", print a clear error (not a
warning) to >&2, and then exit non-zero instead of continuing.
- Around line 224-229: ROUTINE_NAME is used verbatim in paths and launchd labels
so add a strict validation step to reject or sanitize unsafe characters before
any interpolation: implement and call a new function (e.g.,
validate_routine_name) that enforces a safe charset (letters, digits,
underscore, hyphen; no spaces, slashes, or other path separators) and returns
non-zero on violation, and invoke it alongside the existing
validate_required/validate_cron_expression/validate_routine_prompt checks;
update references to ROUTINE_NAME usages (cron log path, plist filename, launchd
label) to only proceed when validate_routine_name succeeds (or produce an
explicit error message) to prevent broken artifacts or path traversal.
- Around line 314-338: The plist heredoc injects unescaped dynamic values
(command, HOME, PATH, ROUTINE_NAME, launchd_schedule_xml-derived strings) into
<string> nodes causing XML parsing failures; add a small xml_escape function
(e.g., xml_escape() that replaces & < > " ' with entities) in
.agents/scripts/routine-helper.sh and use it for every interpolated value in the
heredoc: the Label value (sh.aidevops.routine-${ROUTINE_NAME}), the
ProgramArguments command entry (${command}), both EnvironmentVariables (${HOME}
and ${PATH}), and the StandardOutPath/StandardErrorPath outputs; also ensure any
place you insert launchd_schedule_xml is either pre-escaped or generated using
the escape helper so the final plist contains only XML-safe text.

---

Nitpick comments:
In @.agents/AGENTS.md:
- Around line 45-66: The top-level AGENTS.md should not inline the five-step
playbook that duplicates .agents/scripts/commands/routine.md; replace the
detailed step list (Design the operator..., Prove it ad-hoc..., Harden
guardrails..., Pilot safely..., Schedule the command...) with the concise
decision rule already present and a single pointer to the routine doc
(referencing the existing /routine or .agents/scripts/commands/routine.md) so
AGENTS.md stays focused on broadly applicable rules and avoids task-specific
guidance.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4521dc73-352f-4393-a86f-9da6d3ab515d

📥 Commits

Reviewing files that changed from the base of the PR and between da75a30 and 8133e6b.

📒 Files selected for processing (4)
  • .agents/AGENTS.md
  • .agents/scripts/commands/routine.md
  • .agents/scripts/commands/runners.md
  • .agents/scripts/routine-helper.sh

Comment on lines +34 to 36
5. Dispatches workers via `opencode run`, routing to the right agent and execution mode

See `scripts/commands/pulse.md` for the full spec.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Read-only consistency check: verify pulse docs for hard-coded /full-loop assumptions.
set -euo pipefail

fd pulse.md .agents/scripts/commands -t f | while read -r f; do
  echo "== $f =="
  rg -n --context 2 '/full-loop|WORKER_COUNT|opencode run' "$f"
done

Repository: marcusquinn/aidevops

Length of output: 7206


Clarify execution mode routing: runners.md describes flexible routing, but pulse.md hard-codes /full-loop throughout.

The runners.md description ("routing to the right agent and execution mode") implies a flexible routing model, but pulse.md consistently hard-codes /full-loop for all worker dispatches (lines 195, 578, 659, 711, 996, 1007, 1020, 1054) and worker counting (line 44: grep '/full-loop'). Either update runners.md to specify that pulse uses /full-loop dispatch, or document the general routing model more clearly to distinguish it from this specific implementation.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.agents/scripts/commands/runners.md around lines 34 - 36, The docs disagree:
runners.md implies flexible execution-mode routing but pulse.md hard-codes
dispatches to "/full-loop" (and counts workers via grep '/full-loop'); fix by
either (A) updating runners.md to explicitly state that the pulse implementation
currently always uses the "/full-loop" path for worker dispatch and counting, or
(B) make pulse.md follow the general routing model by replacing hard-coded
"/full-loop" dispatch targets and the worker-count grep with the generic routing
variable/interface used by runners.md (so functions/commands that call opencode
run use the common execution-mode variable instead of "/full-loop"). Locate
occurrences of "/full-loop", the worker-counting grep, and the dispatch command
invocations in pulse.md and update them accordingly, and update runners.md text
to reflect which behavior is implementation-specific.

@github-actions
Copy link
Copy Markdown
Contributor

🔍 Code Quality Report

�[0;35m[MONITOR]�[0m Code Review Monitoring Report

�[0;34m[INFO]�[0m Latest Quality Status:
SonarCloud: 0 bugs, 0 vulnerabilities, 402 code smells

�[0;34m[INFO]�[0m Recent monitoring activity:
Thu Mar 12 22:07:08 UTC 2026: Code review monitoring started
Thu Mar 12 22:07:09 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 402

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 402
  • VULNERABILITIES: 0

Generated on: Thu Mar 12 22:07:12 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@sonarqubecloud
Copy link
Copy Markdown

@marcusquinn marcusquinn merged commit 00a83f7 into main Mar 12, 2026
12 checks passed
@marcusquinn marcusquinn deleted the chore/non-code-routine-guidance branch March 12, 2026 22:09
alex-solovyev added a commit that referenced this pull request Mar 12, 2026
…stion

The validate_routine_name charset was ^[A-Za-z0-9_-]+$ but the coderabbit
review (issue #4273) suggested ^[A-Za-z0-9._-]+$ to allow names like
'seo.weekly'. Update the regex and error message to match.

All three HIGH findings from PR #4251 review are now fully resolved:
- validate_routine_name enforces safe charset (this commit adds dot support)
- xml_escape() applied to all plist <string> values (c2bb03f)
- ROUTINE_NAME validated before path/label interpolation (c2bb03f)

shellcheck: zero issues
alex-solovyev added a commit that referenced this pull request Mar 13, 2026
…stion (#4292)

The validate_routine_name charset was ^[A-Za-z0-9_-]+$ but the coderabbit
review (issue #4273) suggested ^[A-Za-z0-9._-]+$ to allow names like
'seo.weekly'. Update the regex and error message to match.

All three HIGH findings from PR #4251 review are now fully resolved:
- validate_routine_name enforces safe charset (this commit adds dot support)
- xml_escape() applied to all plist <string> values (c2bb03f)
- ROUTINE_NAME validated before path/label interpolation (c2bb03f)

shellcheck: zero issues
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Auto-created from TODO.md tag

Projects

None yet

Development

Successfully merging this pull request may close these issues.

t1455: Clarify non-code routine scheduling workflow

1 participant