Skip to content

Harden protected-branch hooks for VS Code terminal Codex sessions#10

Merged
NagyVikt merged 1 commit into
mainfrom
agent/fix-protected-branch-context-20260411
Apr 11, 2026
Merged

Harden protected-branch hooks for VS Code terminal Codex sessions#10
NagyVikt merged 1 commit into
mainfrom
agent/fix-protected-branch-context-20260411

Conversation

@NagyVikt

Copy link
Copy Markdown
Collaborator

Summary\n- tighten protected-branch VS Code detection in pre-commit/pre-push hooks\n- allow only VS Code Source Control hook envs (VSCODE_GIT_* / VSCODE_IPC_HOOK_CLI)\n- add regression tests proving TERM_PROGRAM=vscode alone is blocked\n\n## Verification\n- npm test

…eguards

This rebases the old protected-branch PR on top of current main and keeps only the still-useful delta: template pre-push guardrails plus branch-finish PR fallback modes. The AGENTS template line is updated so generated guidance matches the actual finish behavior.

Constraint: Keep current main hook policy intact while making legacy PR branch mergeable

Rejected: Merge old branch content wholesale | reintroduced stale protections and broke current tests

Confidence: high

Scope-risk: narrow

Reversibility: clean

Directive: Keep AGENTS template text synchronized with actual script behavior when finish-flow options change

Tested: npm test (41/41 pass)

Not-tested: live GitHub protected-base merge under required-review policy
@NagyVikt NagyVikt force-pushed the agent/fix-protected-branch-context-20260411 branch from 4789d27 to 9ef7188 Compare April 11, 2026 11:18
@NagyVikt NagyVikt merged commit 16d3d45 into main Apr 11, 2026
7 checks passed
@NagyVikt NagyVikt deleted the agent/fix-protected-branch-context-20260411 branch April 20, 2026 07:45
NagyVikt added a commit that referenced this pull request Jun 5, 2026
…t calls, add live dirty signal (#628)

* feat(mcp): gx mcp — cross-repo read-only multi-agent observability server

Agents running in parallel couldn't see who was on which branch/PR or who
had claimed a file, so they collided (and edited the primary checkout, which
auto-stashed). gitguardex already knows all of this; this exposes it to agents.

- src/mcp/server.js: dependency-free stdio JSON-RPC MCP server (no SDK; gx
  stays at 2 deps). Tools: list_agents, repo_state, who_owns, my_context.
- src/mcp/collect.js: read-only collector over git worktrees + per-worktree
  lock files + pr.findOpenPrForBranch + cockpit projects-finder. who_owns
  aggregates locks across ALL worktrees (they're per-worktree on disk);
  surfaces a warning when a lane edits the primary checkout.
- src/cli/commands/mcp.js: gx mcp serve | list-agents | who-owns | register.
- Wired into src/cli/main.js dispatch.
- Tests: mcp-collect (lanes, cross-worktree who_owns, dedupe, primary warning)
  + mcp-server (JSON-RPC protocol). 12/12 pass; no-new-failures vs base.

Read-only; never mutates a repo. Registration is opt-in (gx mcp register).

* fix(mcp): address adversarial review — pin protocol version, bound git calls, add live dirty signal

Review verdict SHIP_WITH_FIXES. Applied:
- HIGH #5: initialize pins server PROTOCOL_VERSION instead of echoing the
  client's requested version (correct MCP version negotiation).
- HIGH #10: bound every git() call with a 7s timeout + maxBuffer, and make
  list_agents PR fetch opt-in (default off) so a hung gh can't exceed the MCP
  client timeout. repo_state/my_context keep PRs on (narrow scope).
- Value gap #16: add per-lane 'dirty' (git status --porcelain) — the files an
  agent is editing RIGHT NOW, independent of commit-time locks. Filters .omx/.omc
  runtime churn. Caught+fixed a porcelain parse bug (git() .trim() ate the first
  line's leading status column).
- Cheap: parse errors -> JSON-RPC -32700 (id null); stderr warn on corrupt lock.

Tests: 15/15 (added protocol-pin, parse-error, and live-dirty cases).

---------

Co-authored-by: NagyVikt <nagy.viktordp@gmail.com>
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