Skip to content

t1435: keep pulse sessions fresh and canonical#4129

Merged
marcusquinn merged 1 commit intomainfrom
bugfix/t1435-fix-pulse-session-reuse
Mar 11, 2026
Merged

t1435: keep pulse sessions fresh and canonical#4129
marcusquinn merged 1 commit intomainfrom
bugfix/t1435-fix-pulse-session-reuse

Conversation

@marcusquinn
Copy link
Owner

@marcusquinn marcusquinn commented Mar 11, 2026

Summary

  • stop supervisor pulse runs from reusing persisted OpenCode sessions so each cycle executes from fresh pre-fetched state
  • make setup.sh resolve the canonical main worktree for PULSE_DIR so auto-updated machines do not repoint pulse at feature worktrees
  • add regression coverage for fresh pulse sessions while keeping worker session reuse intact

Closes #4128

Summary by CodeRabbit

  • Bug Fixes

    • Fixed session persistence behavior for pulse runs—they now start with fresh sessions instead of reusing previous ones.
    • Improved path resolution for worktree directories to ensure consistent configuration across all run types.
  • Tests

    • Added tests to verify pulse runs maintain fresh session behavior.

Prevent supervisor pulse runs from reusing persisted OpenCode sessions so each cycle executes against fresh pre-fetched state instead of stale conversational context. Also ensure setup keeps autonomous pulse services pinned to the canonical main repo path when deployed from a linked worktree, so auto-updated machines do not supervise feature worktrees by accident.
@gemini-code-assist
Copy link

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 11, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 7743783a-012f-4f0c-8be3-d03d8f880a80

📥 Commits

Reviewing files that changed from the base of the PR and between b19042a and 7c8822a.

📒 Files selected for processing (3)
  • .agents/scripts/headless-runtime-helper.sh
  • setup.sh
  • tests/test-headless-runtime-helper.sh

Walkthrough

Fixes pulse session reuse causing dispatch stalls by preventing pulse runs from persisting or retrieving sessions. Adds session clearing for pulse role, updates worktree path resolution in setup configuration, and adds test coverage to verify pulse runs don't reuse sessions.

Changes

Cohort / File(s) Summary
Session Management for Pulse Runs
.agents/scripts/headless-runtime-helper.sh
Added clear_session_id() function to delete provider sessions. Modified cmd_run to clear existing sessions for pulse role instead of retrieving persisted ones, and skip session storage after pulse runs complete.
Worktree Path Resolution
setup.sh
Added _resolve_main_worktree_dir() function to determine canonical main worktree directory. Introduced _pulse_repo_dir variable and updated plist/crontab generation to use main worktree paths instead of current directory paths.
Test Coverage
tests/test-headless-runtime-helper.sh
Added "Pulse Runs Stay Fresh" test section to verify pulse runs do not reuse persisted sessions and validates session isolation behavior.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • PR #4116: Both PRs modify .agents/scripts/headless-runtime-helper.sh session management behavior; the earlier PR introduced session persistence helpers while this PR fixes pulse session reuse by preventing persistence for pulse roles.

Suggested labels

bug

Poem

🔄 No more stale sessions haunting pulse,
Worktrees align, dispatch pulses true,
Clear skies ahead for automation's cadence—
Fresh flows, every run anew. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 42.86% 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 't1435: keep pulse sessions fresh and canonical' clearly summarizes the main change: ensuring pulse sessions remain fresh and pinned to the canonical main worktree, which is the primary objective of the PR.
Linked Issues check ✅ Passed The PR addresses all coding requirements from issue #4128: pulse runs no longer reuse persisted sessions, setup.sh resolves the canonical main worktree for PULSE_DIR, and regression tests verify fresh pulse sessions while maintaining worker session reuse.
Out of Scope Changes check ✅ Passed All changes are directly aligned with issue #4128 objectives: session handling in headless-runtime-helper.sh, main worktree resolution in setup.sh, and regression test coverage—no extraneous modifications detected.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bugfix/t1435-fix-pulse-session-reuse

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
Contributor

🔍 Code Quality Report

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

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

�[0;34m[INFO]�[0m Recent monitoring activity:
Wed Mar 11 05:02:52 UTC 2026: Code review monitoring started
Wed Mar 11 05:02:52 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 397

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 397
  • VULNERABILITIES: 0

Generated on: Wed Mar 11 05:02:55 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@sonarqubecloud
Copy link

@marcusquinn marcusquinn merged commit 08bd908 into main Mar 11, 2026
27 checks passed
@marcusquinn marcusquinn deleted the bugfix/t1435-fix-pulse-session-reuse branch March 11, 2026 05:07
alex-solovyev added a commit that referenced this pull request Mar 17, 2026
…alse repos

PULSE_DIR defaulted to ~/Git/aidevops, causing the host app to associate
all supervisor pulse sessions with that project — even when it had
pulse:false in repos.json. This created 155+ orphaned sessions in ~36h.

Root causes:
1. pulse-wrapper.sh hardcoded PULSE_DIR to ~/Git/aidevops (line 214)
2. setup.sh explicitly set PULSE_DIR to the aidevops repo path in both
   launchd plist and cron job environment variables
3. Session reuse was intentionally disabled for pulse role in PR #4129
   (headless-runtime-helper.sh clears session ID each cycle to avoid
   stale context), so each cycle creates a fresh session — by design

Fix:
- Change PULSE_DIR default to ~/.aidevops/.agent-workspace/ (neutral path
  not associated with any managed repo)
- Update setup.sh launchd plist and cron job to use the neutral path
- Add mkdir -p for PULSE_DIR to ensure the directory exists
- Document why session reuse is disabled (stale context prevention)

The supervisor is a framework-level process, not a project-level one.
Using a neutral workspace path means pulse sessions are filed under the
framework workspace rather than polluting any specific project's session
list.

Closes #5136
alex-solovyev added a commit that referenced this pull request Mar 17, 2026
…alse repos (#5137)

PULSE_DIR defaulted to ~/Git/aidevops, causing the host app to associate
all supervisor pulse sessions with that project — even when it had
pulse:false in repos.json. This created 155+ orphaned sessions in ~36h.

Root causes:
1. pulse-wrapper.sh hardcoded PULSE_DIR to ~/Git/aidevops (line 214)
2. setup.sh explicitly set PULSE_DIR to the aidevops repo path in both
   launchd plist and cron job environment variables
3. Session reuse was intentionally disabled for pulse role in PR #4129
   (headless-runtime-helper.sh clears session ID each cycle to avoid
   stale context), so each cycle creates a fresh session — by design

Fix:
- Change PULSE_DIR default to ~/.aidevops/.agent-workspace/ (neutral path
  not associated with any managed repo)
- Update setup.sh launchd plist and cron job to use the neutral path
- Add mkdir -p for PULSE_DIR to ensure the directory exists
- Document why session reuse is disabled (stale context prevention)

The supervisor is a framework-level process, not a project-level one.
Using a neutral workspace path means pulse sessions are filed under the
framework workspace rather than polluting any specific project's session
list.

Closes #5136
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

t1435: Fix persisted pulse session reuse stalling dispatch

1 participant