Skip to content

fix(hooks): port checkRalplan() and checkTeamPipeline() to persistent-mode.cjs - #1482

Merged
Yeachan-Heo merged 1 commit into
Yeachan-Heo:devfrom
lifrary:fix/port-ralplan-team-checks
Mar 9, 2026
Merged

Yeachan-Heo merged 1 commit into
Yeachan-Heo:devfrom
lifrary:fix/port-ralplan-team-checks

Conversation

@lifrary

@lifrary lifrary commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #1480. Ports first-class stop-hook enforcement for ralplan and team
pipeline from src/hooks/persistent-mode/index.ts to scripts/persistent-mode.cjs.

  • Add readStopBreaker() / writeStopBreaker() helpers with TTL-based expiry
  • Add Team Pipeline enforcement (Priority 2.5) with phase normalization, terminal
    detection, active-phase gating, status-level checks, and circuit breaker
  • Add Ralplan enforcement (Priority 2.6) with terminal phase detection and circuit breaker
  • Cache cancelInProgress for TOCTOU defense (fix: hook system — duplicate Ralph loop, cancel TOCTOU, mode list copies #1058)
  • Guard existing Priority 6 Team block to avoid double-handling

Refs #1479

Parameters (matching bridge code)

Mode Max Reinforcements TTL
Team Pipeline 20 5 min
Ralplan 30 45 min

Changes from code review

  • Added cancelInProgress bypass inside team pipeline and ralplan blocks (TOCTOU defense)
  • Added !isStaleState() check for ralplan (consistency with all other modes)
  • Added "canceled" (American spelling) to ralplan terminal phases

Test plan

  • Syntax check passes (node -c)
  • All helper functions (readStopBreaker, writeStopBreaker, readStateFileWithSession, isSessionMatch, writeJsonFile, unlinkSync) verified to exist
  • Circuit breaker parameters match src/hooks/persistent-mode/index.ts exactly
  • Manual: run /ralplan, verify stop is blocked with [RALPLAN - CONSENSUS PLANNING]
  • Manual: run /team, verify stop is blocked with [TEAM PIPELINE - PHASE:]

🤖 Generated with Claude Code

@Yeachan-Heo Yeachan-Heo left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Clean port of both first-class checks from src/hooks/persistent-mode/index.ts to scripts/persistent-mode.cjs.

Key things verified:

  • Team pipeline (Priority 2.5): 20 reinforcements, 5-min TTL, proper phase/status detection, TOCTOU defense via cached cancelInProgress ✅
  • Ralplan (Priority 2.6): 30 reinforcements, 45-min TTL, terminal phase detection ✅
  • Stop breaker helpers: session-scoped, atomic writes, TTL-based cleanup ✅
  • Priority 6 fallback: teamPipelineHandled guard prevents double-blocking ✅
  • Cancel bypass: properly inherited from cached check ✅

This completes #1479 — the runtime scripts now match the bridge code's stop-hook behavior.

LGTM ✅

—
[repo owner's gaebal-gajae (clawdbot) 🦞]

…-mode.cjs

Follow-up to Yeachan-Heo#1480. Ports the first-class stop-hook enforcement for
ralplan and team pipeline from src/hooks/persistent-mode/index.ts to
the actual runtime script scripts/persistent-mode.cjs.

Previously only generic skill-active-state protection existed in
scripts/. This adds dedicated enforcement matching the bridge code:

Team Pipeline (Priority 2.5):
- Phase normalization with canonical field priority
  (phase → current_phase → currentStage → current_stage → stage)
- Terminal phase detection (complete/failed/cancelled/etc.)
- Known active phase gating with fail-open for unknown phases
- Status-level terminal check
- cancel.requested bypass
- Circuit breaker: 20 reinforcements, 5-min TTL
- Guards existing Priority 6 Team block to avoid double-handling

Ralplan (Priority 2.6):
- Terminal current_phase detection
  (complete/completed/failed/cancelled/done)
- Session isolation via isSessionMatch()
- Circuit breaker: 30 reinforcements, 45-min TTL

Shared:
- readStopBreaker() / writeStopBreaker() helpers with TTL-based expiry
- Constants matching src/hooks/persistent-mode/index.ts exactly

Refs: Yeachan-Heo#1479, Yeachan-Heo#1424, Yeachan-Heo#1432

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@lifrary
lifrary force-pushed the fix/port-ralplan-team-checks branch from 24ff0b8 to 5bc6956 Compare March 9, 2026 06:42
@Yeachan-Heo
Yeachan-Heo merged commit 5587a22 into Yeachan-Heo:dev Mar 9, 2026
7 checks passed
ChoKhoOu added a commit to ChoKhoOu/oh-my-claudecode that referenced this pull request Mar 10, 2026
The .cjs Stop hook outputs `{ decision: "block" }` without
`continue: false` when blocking stops for active modes. The original
fix (Yeachan-Heo#1216) added `continue: false` to the .mjs scripts but the .cjs
version was never updated, and subsequent commits (Yeachan-Heo#1306, Yeachan-Heo#1330, Yeachan-Heo#1374,
Yeachan-Heo#1480, Yeachan-Heo#1482) did not carry over this fix.

Since hooks.json references the .cjs version, the plugin Stop hook has
been missing hard-block capability, allowing sessions to end mid-execution.

- Add `continue: false` to all 12 blocking outputs in persistent-mode.cjs
- Add `continue: false` to context-guard-stop.mjs (1 output)
- Add `continue: false` to code-simplifier.mjs and its template (1 each)

Closes Yeachan-Heo#1516
Yeachan-Heo added a commit that referenced this pull request Mar 11, 2026
…arch (#1549)

* feat(setup): add rtk token optimization integration

* revert(setup): remove RTK integration from PR #1489

* fix(hooks): fail open on critical context exhaustion

* fix(skill): harden omc-teams tmux and agent validation

* Add Ralph critic selection for verification

* fix(doctor): accept supported omc config keys

* feat(openclaw): normalize native clawhip signals

* fix: skip legacy agent sync when plugin agents exist

* fix(hud): preserve stale usage limits on API failures

* Reduce startup OMC guidance context

* fix: clean up stale transient files on session end (#1510)

- session-end: cleanupTransientState now removes agent-replay-*.jsonl,
  last-tool-error.json, hud-state.json, hud-stdin-cache.json,
  idle-notif-cooldown.json, *-stop-breaker.json, cancel-signal files
  inside session dirs, and empty session directories
- keyword-detector: activateState adds project_path field for parity
  with TypeScript activateUltrawork in bridge.ts
- persistent-mode: readStateFileWithSession adds fallback scan of all
  session directories when session-scoped path lookup fails

* fix(hud): reduce transient usage API retry hammering (#1513)

* fix(hooks): add missing continue: false to persistent-mode.cjs Stop hook

The .cjs Stop hook outputs `{ decision: "block" }` without
`continue: false` when blocking stops for active modes. The original
fix (#1216) added `continue: false` to the .mjs scripts but the .cjs
version was never updated, and subsequent commits (#1306, #1330, #1374,
#1480, #1482) did not carry over this fix.

Since hooks.json references the .cjs version, the plugin Stop hook has
been missing hard-block capability, allowing sessions to end mid-execution.

- Add `continue: false` to all 12 blocking outputs in persistent-mode.cjs
- Add `continue: false` to context-guard-stop.mjs (1 output)
- Add `continue: false` to code-simplifier.mjs and its template (1 each)

Closes #1516

* feat(doc-specialist): add first-pass context hub guidance (#1519)

* Add skill pipeline handoff metadata (#1520)

* chore: remove stale root development artifacts (#1526)

* docs(rebrand): update scoped guidance docs (#1527)

* docs: rebrand main README to oh-my-openagent (#1528)

* docs: rebrand localized readmes to oh-my-openagent (#1529)

* revert: undo unauthorized rebrand PRs 1527-1529

* docs: fix outdated install references in REFERENCE.md

- Update platform support table: "curl or npm" → "Claude Code Plugin"
  for macOS/Linux, consistent with the deprecation notice at the top
  of the Installation section
- Replace deprecated curl uninstall one-liner with the plugin uninstall
  command (/plugin uninstall oh-my-claudecode@oh-my-claudecode)

Co-Authored-By: Claude Opus 4.6 <[email protected]>

* docs: remove stale analytics references

* fix(team): port startup hardening from omx

* fix(team): finish runtime hardening port

* fix(team): resolve worktree mailbox trigger paths

* fix(hud): avoid repeated watch mode initialization

* feat: add session history search

* fix(team): require real startup evidence

* fix(routing): normalize explicit model IDs in all code paths (#1415)

The prior fix (PR #1464) only normalized auto-injected models but missed
two paths where full model IDs like 'claude-sonnet-4-6' leaked through:

1. enforceModel() passed explicitly-provided models as-is without
   normalizing to CC aliases (sonnet/opus/haiku)
2. buildLaunchArgs() in model-contract.ts passed model directly to
   --model flag for team worker launches

Extract normalizeToCcAlias() helper and apply it in both paths.
Add 5 tests covering explicit ID normalization and Bedrock ID handling.

Closes #1415

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>

* chore(release): bump version to v4.7.10

Version bumps:
- package.json: 4.7.9 → 4.7.10
- .claude-plugin/plugin.json: 4.7.9 → 4.7.10
- .claude-plugin/marketplace.json: 4.7.9 → 4.7.10
- CHANGELOG.md: Updated release header

Includes rebuilt dist artifacts for:
- Bedrock model routing fixes
- Team runtime hardening
- Session history search feature
- Lazy agent loading

Co-Authored-By: Claude Opus 4.6 <[email protected]>

---------

Co-authored-by: ChoKhoOu <[email protected]>
Co-authored-by: Yong <[email protected]>
Co-authored-by: Claude Opus 4.6 <[email protected]>
Co-authored-by: Carlos Cubas <[email protected]>
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.

2 participants