Skip to content

feat(gateway): /toggle-enforce-branches command (v0.5.34)#136

Open
royosherove wants to merge 2 commits into
mainfrom
feat/toggle-enforce-branches
Open

feat(gateway): /toggle-enforce-branches command (v0.5.34)#136
royosherove wants to merge 2 commits into
mainfrom
feat/toggle-enforce-branches

Conversation

@royosherove
Copy link
Copy Markdown
Member

Adds an immediate runtime kill-switch for pi-branch-enforcer enforcement, controllable from Telegram.

/toggle-enforce-branches            toggle on <-> off
/toggle-enforce-branches on|off     explicit
/toggle-enforce-branches status     query only

How it works

Toggles ~/.pi-branch-enforcer/disabled marker file. When present, pi-branch-enforcer >=3.3.0 fails open on every bash tool_call.

  • Persists across agent restarts (file-based)
  • Immediate effect — next bash command sees the new state, no /restart
  • Aliases supported: enable/disableon/off
  • Idempotent: /toggle-enforce-branches off when already off → "Already in target state"

Implementation

  • New module: src/gateway/toggle-enforce-branches-command.ts (single responsibility, follows /model and /topic patterns)
  • Wired via descriptor pattern in buildCommandDescriptors() (in-turn, acceptsArgs: true)
  • Added to BOT_COMMANDS so it shows up in the Telegram / menu
  • Pure filesystem operations — no IPC, no extension dependency at compile time
  • Marker path is the stable contract with the extension

Tests

10 new unit tests using a tmp $HOME for isolation:

  • toggle from enabled → disabled
  • toggle from disabled → enabled
  • explicit on / off / enable / disable
  • explicit status (no state change)
  • idempotence (no-change message when already in target state)
  • unknown arg → usage message, no state change

550 tests passing (was 540, +10 new).

Companion PR

Requires @inceptionstack/pi-branch-enforcer >= 3.3.0:
inceptionstack/pi-branch-enforcer#new

Adds an immediate runtime kill-switch for pi-branch-enforcer enforcement.

  /toggle-enforce-branches            toggle on<->off
  /toggle-enforce-branches on|off     explicit
  /toggle-enforce-branches status     query only

Persists across agent restarts via ~/.pi-branch-enforcer/disabled marker
file. Effect is immediate — pi-branch-enforcer >=3.3.0 checks the marker
on every bash tool_call, so toggling takes effect on the next command
without /restart.

- New module src/gateway/toggle-enforce-branches-command.ts
- Wired into buildCommandDescriptors() (in-turn, acceptsArgs)
- Added to BOT_COMMANDS so it shows up in the Telegram / menu
- 10 new unit tests (toggle / explicit / status / aliases /
  idempotence / unknown-arg) — 550 total green

Requires @inceptionstack/pi-branch-enforcer >= 3.3.0
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 71d6f2a507

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

{ command: "doctor", description: "Run diagnostics" },
{ command: "crons", description: "List scheduled cron jobs" },
{ command: "jobs", description: "Show running jobs" },
{ command: "toggle-enforce-branches", description: "Toggle branch-protection enforcement" },
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Rename command to Telegram-safe identifier

The new toggle-enforce-branches entry uses hyphens, but Telegram BotCommand.command only allows lowercase letters, digits, and underscores; when registerCommands() calls setMyCommands, Telegram returns BOT_COMMAND_INVALID for this payload, so startup command registration fails and the bot command menu is not updated. This impacts every Telegram deployment that enables command registration, not just this new command, because the API call validates the full command list.

Useful? React with 👍 / 👎.

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.

1 participant