Skip to content

feat(plugins): rogue-hook release 1 - install the native bridge once at its fixed path (FIRE-3016) - #76

Draft
yuval-qf wants to merge 11 commits into
mainfrom
feature/rogue-hook-native-bridge-release-1-fixed-path-FIRE-3016
Draft

yuval-qf wants to merge 11 commits into
mainfrom
feature/rogue-hook-native-bridge-release-1-fixed-path-FIRE-3016

Conversation

@yuval-qf

@yuval-qf yuval-qf commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Problem

PR #65 installed rogue-hook into a directory per pinned version (~/.rogue/bin/rogue-hook/<version>/rogue-hook). The binary on main now updates itself in place at one fixed path (~/.rogue/bin/rogue-hook, or the rogue-hook.exe launcher on Windows), as FIRE-3008 asks. The two did not fit: the versioned directory blocks the binary's own update, and a binary that updated itself would never run.

Fix

This PR replaces #65. It carries #65's hand-off (squashed and rebased onto main) and reworks it for the fixed path:

  • Fixed path. The scripts exec ~/.rogue/bin/rogue-hook (%USERPROFILE%\.rogue\bin\rogue-hook.exe) whenever it is installed. The binary no longer needs a pin to get events.

  • The pin is for the first download only. When the binary is missing and the plugin ships rogue-hook.json, the scripts start the download in the background and handle the event themselves. After that, the binary updates itself from the Rogue API and checks each release's signature.

  • One OS file lock, shared with the binary. The download step takes the binary's own update lock (~/.rogue/.self-update.lock) without waiting, then checks the path again. It installs only while the path is empty, so it never replaces a binary that updated itself. On macOS and Linux it uses flock(1) or perl. On Windows it uses a byte-range lock that overlaps the binary's LockFileEx. Node runs itself again under the same lock. The per-version directories, pruning, stale-lock breaking and per-version locks are gone.

  • Staging on the same volume. Downloads go to ~/.rogue/updates/ and move into place with one rename.

  • Installers. install.sh and install.ps1 install the binary at the end of a run, from the pin of a plugin they installed. A failure only warns; the hooks retry on their own. mdm-provision-actor.sh is unchanged: it only writes /etc/rogue/env as root, and the binary belongs in each user's home.

  • One installer per OS. native-bridge-install.ps1 hands off to the sh installer when PowerShell runs on macOS or Linux (.NET cannot lock a file on macOS).

  • Conformance. tests/conformance.sh --native installs the binary at the fixed path. Unselected families get their kill switch (ROGUE_NATIVE_BRIDGE_<FAMILY>=0) instead of "no pin".

  • Docs. docs/deployment.md gets a short "The native bridge" section.

  • Kept from feat(plugins): hand hook events to a pinned native bridge (FIRE-2882) #65: auto-update has no opt-out.

  • Cortex Code (feat(cortex): rogue-hook native bridge - Cortex Code hands its hook events to the binary (FIRE-3431) #77, FIRE-3431, merged into this branch): Cortex Code hands its events to the binary too, like Muse. Its adapter is in the monorepo (rogue-security#3631), so the first rogue-hook release must come from a main that has it.

  • Version 2.0.0. Claude, Codex, Cursor, Copilot, Gemini, Antigravity, Kiro, Muse and Cortex Code move to 2.0.0 in their manifests and marketplace entries.

  • Pin. All 9 plugins ship rogue-hook.json for rogue-hook 0.1.0, the first published release (monorepo tag rogue-hook-v0.1.0). It is the release manifest, copied verbatim.

  • Macs with endpoint anti-tamper (c95d861). The system extension denies every rename into ~/.rogue/bin. It installs the binary itself only when the release signature lies beside the source as <source>.sig, and the rename still fails with EPERM. native-bridge-install.sh and the Gemini native-bridge-install.mjs now save the download route's signature there, as the binary's self-update does, and accept a failed rename when ~/.rogue/bin/rogue-hook then has the pinned sha256.

A binary that is already at the fixed path gets events at once.

Out of scope, with tickets:

  • Macs with endpoint anti-tamper on: the first install goes through the extension (see above). FIRE-3397 still tracks the endpoint side.
  • Grok Bot has no adapter in the binary: FIRE-3398.

Issue

https://linear.app/qualifire/issue/FIRE-3016 (epic FIRE-3008). Replaces #65 (FIRE-2882).

Verification

1. First install with the real binary, end to end (macOS). A Claude plugin copy on the scripts, a pin for a rogue-hook built from monorepo main, and a mock of /api/v1/hooks/download. Event 1 is answered by the script and installs the binary at the fixed path. Event 2 is handled by the binary, which then asks /api/v1/hooks/update-manifest itself, with machine_id. That shows it runs from the path where it updates itself. (Script: proof-first-install.sh, run outside the repo.)

$ cat $PLUGIN/rogue-hook.json
{
  "version": "0.1.0",
  "sha256": {
    "darwin-universal": "adc54c9107fc4a0eea3844cdd1bee161dc00241123781f36a86f00d0a8e4ae5f"
  }
}
$ ls ~/.rogue/bin   # before
ls: $TMPDIR/tmp.SDrM1VCKN9/home/.rogue/bin: No such file or directory
--- event 1: no binary yet, the script answers and starts the download
answer: {}
$ cat ~/.rogue/hook-binary.log
2026-11-24T11:11:28Z rogue-hook 0.1.0: installed (darwin-universal)
$ ls -l ~/.rogue/bin
total 42120
-rwxr-xr-x@ 1 user  staff  21562952 Nov 24 13:11 rogue-hook
$ ~/.rogue/bin/rogue-hook --version
rogue-hook 0.1.0
$ cmp ~/.rogue/bin/rogue-hook <real binary> && echo identical
identical
$ ls -A ~/.rogue/updates   # nothing left staged
--- event 2: the script execs the binary
answer: {}
$ requests the mock saw after event 2
/api/v1/hooks/update-manifest?current_version=0.1.0&os=darwin&arch=arm64&family=claude&surface=cli&plugin_version=1.0.32&machine_id=<this Mac's id>

2. Conformance against the real binary (macOS), through the real hand-off.

$ tests/conformance.sh
OK: conformance (script)
$ tests/conformance.sh --native rogue-hook/target/debug/rogue-hook      # monorepo main @ e28d8e53c
native bridge: rogue-hook 0.1.0 for: claude codex cursor copilot gemini antigravity kiro muse
native hand-offs: 459
OK: conformance (native)
$ tests/conformance.sh --native .../rogue-hook --family codex        # other families held back by their kill switch
native hand-offs: 31
OK: conformance (native)

3. Hand-off and download suites (macOS). New cases: a binary with no pin still gets events; an installed binary (one that updated itself) is never replaced; a held update lock stops the installer until it is free; install.sh installs from a plugin's pin.

$ bash tests/test_native_bridge_sh.sh                 # flock absent here, so the perl lock ran
OK: native bridge hand-off and install
$ TEST_SH=dash bash tests/test_native_bridge_sh.sh
OK: native bridge hand-off and install
$ pwsh -File tests/test_native_bridge_ps1.ps1
OK: native bridge hand-off and install (PowerShell)
$ node --test tests/test_native_bridge_mjs.mjs
# pass 18
# fail 0

4. The validate workflow's manifests job, run locally (macOS).

All 17 steps pass, among them the shell and PowerShell unit tests, the hook-log, log-shipper and beacon contracts, the Kiro end-to-end run and the shared-script sync check.

PASS 01-08  JSON, versions, shell parse, Muse/Cortex, shell unit tests, Kiro installer, snippets, shared-script sync
PASS 09.sh  Hook-log contract (sh + mjs dispatchers)
PASS 10.sh  Gemini dispatcher contract (node)
PASS 11.sh  Log-shipper contract (sh)
PASS 12.sh  Beacon throttle contract (sh)
PASS 13.sh  Kiro bridge end to end (mock server)
PASS 14.sh  Log-shipper end to end (real HTTP)
PASS 15.sh  PowerShell scripts parse
PASS 16.sh  No dash or quote lookalikes in PowerShell code
PASS 17.sh  PowerShell unit tests

5. CI on 09243d3 (with #77 and the 0.1.0 pins): manifests (ubuntu, so the flock(1) lock path) and windows (the Windows lock, ACL and install cases) pass.

6. Upgrade test on VMs, against a local Rogue env (2026-11-25). macOS 26.6 (arm64) and Windows 11 (ARM64) UTM guests with real Claude Code 2.1.332. rogue-hook 0.1.0 and 0.1.1 were debug builds of monorepo main (0086c8dc), signed with a throwaway key. A lab proxy served /hooks/download and /hooks/update-manifest from those builds. It sent every other request to a local env on monorepo main, so each event was checked in its database. The lab copy of this branch had a pin for 0.1.0 and bumped plugin versions, as the pin release does. A HOOKBIN_BLOCK marker made the proxy return a block answer, to check that the agent stops.

Step macOS Windows
Main plugins (Claude 1.0.32, Cursor 1.1.7) installed with main's installer; real claude -p session stored pass pass
Path A: Claude updates the plugin from its marketplace; session 1 handled by the script, which installs the binary pass pass after d2b9d28
Session 2 and later sent by rogue-hook/0.1.0; stored the same as the script's (same raw entries, same payload keys) pass pass
Prompt block (UserPromptSubmit) through the binary stops Claude pass pass
PreToolUse / PostToolUse through the plugin's hook command: allow {}, deny relayed, all stored pass not run
Path B: install.sh / install.ps1 install the binary; a second run leaves it unchanged pass pass
Self-update 0.1.0 to 0.1.1 from a hook event pass pass (see below)
Windows: standalone rogue-hook.exe moves to the launcher layout (versions\0.1.1, current, launcher replaced on the next run) n/a pass
Cursor events through the plugin's hook command, main plugin then branch plugin: same 6 events stored, deny relayed pass pass
No errors in ~/.rogue/logs, hook-binary.log, auto-update.log (only ShipLogs, which the local env answers 500: no Axiom there) pass after 5b9a2d5 pass
# Windows, before d2b9d28 (Claude runs hooks through Git Bash, whose bash.exe is x64)
2026-11-25T09:42:25Z rogue-hook 0.1.0: no pinned sha256 for windows-amd64; the script bridge handles events
# after d2b9d28
2026-11-25T09:47:05Z rogue-hook 0.1.0: installed (windows-arm64)
GET /api/v1/hooks/update-manifest?current_version=0.1.0&os=windows&arch=arm64&family=claude&surface=cli&plugin_version=1.0.100
POST /api/v1/hooks/claude -> 200 ua=rogue-hook/0.1.0

# Windows self-update and the launcher move (auto-update.log, then ~/.rogue/bin)
2026-11-25T09:56:06Z self-update: installed 0.1.1 over 0.1.0
2026-11-25T09:56:09Z self-update: the launcher is in use: Access is denied. (os error 5), trying again later
2026-11-25T09:57:06Z self-update: replaced the launcher
C:\Users\User\.rogue\bin\current                              5
C:\Users\User\.rogue\bin\rogue-hook.exe                       292352
C:\Users\User\.rogue\bin\versions\0.1.1\rogue-hook-update.exe 292352
C:\Users\User\.rogue\bin\versions\0.1.1\rogue_hook.dll        12123648
POST /api/v1/hooks/claude -> 200 ua=rogue-hook/0.1.1

# macOS
2026-11-25T09:32:01Z rogue-hook 0.1.0: installed (darwin-universal)
2026-11-25T09:36:23Z self-update: installed 0.1.1 over 0.1.0
UserPromptSubmit operation blocked by hook:
Rogue lab block

Found and fixed here:

  • d2b9d28: on ARM64 Windows the first download asked for windows-amd64. The process environment and .NET both say AMD64 under x64 emulation; the registry keeps the machine's arch.
  • 5b9a2d5: every session wrote a stray {} into ~/.rogue/auto-update.log (the binary's hook answer).

Found, not in this PR:

  • Windows self-update failed twice ("the download reports version nothing", then "Access is denied") while Defender's cloud lookup timed out: the guest had no direct internet, and the first --version of the new unsigned debug build took 48 s, over the binary's 10 s probe limit. With cloud lookup off it took 346 ms and the update passed. Signed release builds on a connected machine should not see this; slow endpoint AV is a risk for the binary's probe limit (monorepo).
  • Already on main: Claude on Windows cancels the SessionEnd hook (PowerShell starts too slowly), and install.ps1 registers the install without a version (unknown until the next heartbeat).

7. The published release 0.1.0 (2026-11-26). Tag run 45794754101: every job passes, notarization Accepted, all 6 Windows files Valid (Authenticode, Qualifire inc.), and the publish job checks each .sig with the shipped Linux binary's updater key. S3 has all 19 objects. The pin is the run's manifest; each built binary matches its sha256. Native conformance passes against the released macOS binary.

darwin-universal: sha256 matches    linux-amd64: sha256 matches    linux-arm64: sha256 matches
windows-amd64: sha256 matches       windows-arm64: sha256 matches
$ codesign --verify --strict --verbose=2 rogue-hook-darwin-universal
valid on disk / satisfies its Designated Requirement
Authority=Developer ID Application: Qualifire ltd (N5Q265BKR7)
$ spctl -a -t install -vv rogue-hook-darwin-universal
accepted
source=Notarized Developer ID
$ tests/conformance.sh --native rogue-hook-darwin-universal
native bridge: rogue-hook 0.1.0 for: claude codex cursor copilot gemini antigravity kiro muse cortex
native hand-offs: 472
OK: conformance (native)

8. Macs with endpoint anti-tamper (c95d861). A teammate's managed Mac (macOS 27.0.1 arm64, endpoint 1.0.43-rc.2, plugin at 09243d3) logged rogue-hook 0.1.0: cannot install …/.rogue/bin/rogue-hook; the script bridge handles events on the first install. They staged the route's signature as .sig by hand: the rename failed with EPERM, and the extension installed the binary (rogue-hook 0.1.0). Codex and Cursor then logged bridge=native for every event. New cases in tests/test_native_bridge_sh.sh and tests/test_native_bridge_mjs.mjs stand in for the extension: they fail on 09243d3 with the same log line and pass on c95d861. All 17 steps of the manifests job pass locally.

# 09243d3
FAIL: the extension installed it (expected [rogue-hook 0.1.0], got [])
FAIL: log reports install ([rogue-hook 0.1.0: installed] not in [... rogue-hook 0.1.0: cannot install .../home/.rogue/bin/rogue-hook; the script bridge handles events])
# c95d861
  ok: the extension installed it
  ok: log reports install
  ok: no temp file or signature left
  ok: no signature from the route: nothing installed

Before this fix, the extension also reported each failed attempt as tamper (decide_hook_install(false)), about once each 15 minutes. Not checked in prod data.

Not verified yet:

  • The fixed installer on a real managed Mac (the teammates' retest).
  • x64 Windows and Intel Macs; Codex, Gemini, Copilot, Antigravity, Kiro and Muse on the VMs; tool calls made by a signed-in model.
  • Signed release binaries through the real prod /hooks/download route on a real machine. That is the org test.

Merge danger

Do not merge yet. The plan is to test this branch on the Rogue org first.

Model: Claude Opus 5.5. Agent harness: Claude Code in T3 Code.

🤖 Generated with Claude Code

yuval-qf and others added 2 commits November 24, 2026 13:10
…lled (FIRE-2882)

Every plugin's hook, heartbeat, log-shipping and auto-update scripts hand their job to
rogue-hook, the native bridge, when it is installed, and keep it themselves when it is not.
Squash of rogue-plugins PR #65 and the FIRE-3016 conformance test commits, rebased onto main.

Auto-update has no opt-out: ROGUE_AUTO_UPDATE=0 and the ROGUE_PLUGIN_VERSION pin are gone.
Compiled customer bundles, which carry their own env, are still left to their admin.

Model: Claude Opus 5.5. Agent harness: Claude Code in T3 Code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…r its own update lock (FIRE-3016)

The binary now updates itself in place at ~/.rogue/bin/rogue-hook (the rogue-hook.exe launcher on
Windows). The hand-off installed it into a directory per pinned version, which blocked that update
and would never run a binary that updated itself.

- The scripts exec the binary at the fixed path whenever it is installed, with or without a pin.
- rogue-hook.json is the trust root for the first download only.
- The download step takes the binary's own lock (~/.rogue/.self-update.lock) without waiting,
  checks the path again, and installs only while it is empty: flock(1) or perl on macOS and Linux,
  a byte-range lock over the binary's LockFileEx on Windows; Node runs again under the same lock.
  Per-version directories, pruning, stale-lock breaking and per-version locks are gone.
- Downloads stage in ~/.rogue/updates, on the same volume, and move into place with one rename.
- install.sh and install.ps1 install the binary from the pin of a plugin they installed.
- PowerShell on macOS or Linux hands the download to the sh installer.
- conformance --native installs the binary at the fixed path; unselected families get their kill
  switch.

Model: Claude Opus 5.5. Agent harness: Claude Code in T3 Code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 24, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

yuval-qf and others added 5 commits November 24, 2026 13:32
…s the lock held (FIRE-3016)

flock -n exits 1 on a held lock, and exec passed that on, which stopped install.sh-style callers
under set -e. The lock test now waits for its holder: flock(1) hands the lock to its command,
which outlives a killed flock.

Model: Claude Opus 5.5. Agent harness: Claude Code in T3 Code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… under x64 Git Bash (FIRE-3016)

Claude Code runs Windows hooks through Git Bash, whose bash.exe is an x64 build. A PowerShell
or Node started from it runs under x64 emulation, so the process environment and .NET both report
AMD64 and the first download asked for windows-amd64 on an ARM64 machine. Seen on an ARM64
Windows 11 VM. The download step now reads the machine's own arch from the registry and keeps
the environment as the fallback.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…log (FIRE-3016)

auto-update.sh hands its update check to the installed binary, which prints the hook answer `{}`.
Its stdout is the log, so every session appended a stray `{}` to ~/.rogue/auto-update.log.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…bridge (FIRE-3016)

The native bridge is a major release, so Claude, Codex, Cursor, Copilot, Gemini, Antigravity,
Kiro and Muse all move to 2.0.0, in each plugin manifest and its marketplace entry. Cortex Code
stays at 0.2.0: it has no binary adapter yet (FIRE-3398) and this change does not touch it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…vents to the binary (FIRE-3431)

Cortex Code was the only plugin that stayed on its scripts in release 1, so
release 2, which deletes the scripts, would leave it without hooks.

hook.sh and hook.ps1 now hand each event to rogue-hook when it is installed,
behind ROGUE_NATIVE_BRIDGE_CORTEX. The plugin carries the shared hand-off and
installer scripts, its installers keep the rogue-hook.json pin, and the
top-level installers find a pin in the Cortex plugin folder. The conformance
suite runs the Cortex suite in both modes, and that suite now checks the exact
log line for each outcome and the request it posts.

Needs a rogue-hook release with the cortex adapter (qualifire FIRE-3431): an
older binary answers {} to an unknown family and logs nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
yuval-qf and others added 4 commits November 25, 2026 13:30
…idge (FIRE-3431)

Release 1 moved every plugin with a binary adapter to 2.0.0 and left Cortex
Code at 0.2.0 because it had none. It hands off to the binary now, so it moves
to 2.0.0 too. Plugin files reach installs only after a version bump.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tive bridge (FIRE-3016)

The plugins shipped the native bridge with no pin, so no machine downloaded the binary.
rogue-hook 0.1.0 is now published (rogue-security tag rogue-hook-v0.1.0, run 45794754101).

Each of the 9 served plugins gets the release manifest verbatim as rogue-hook.json. The first
hook event, or install.sh / install.ps1, installs the binary at ~/.rogue/bin/rogue-hook from it;
after that the binary updates itself.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…plugins ship a pin (FIRE-3016)

With the rogue-hook.json pin and no binary, each hook event starts the first download in the
background. In the hook-log suite it wrote ~/.rogue/.self-update.lock or hook-binary.log into the
test home, so 4 "writes only its log" checks failed in CI. The suite tests the script logs, so it
now runs with ROGUE_NATIVE_BRIDGE=0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… rogue-hook (FIRE-3016)

On a Mac with the hardened endpoint, the first native bridge install always
failed: the system extension denies every rename into ~/.rogue/bin and installs
the binary itself only when <source>.sig holds the release's signature. The
installers never wrote that file, and they treated the EPERM that follows the
extension's own install as a failure.

native-bridge-install.sh and the Gemini native-bridge-install.mjs now write the
download route's signature beside the staged binary, as self_update.rs does, and
accept a failed rename when ~/.rogue/bin/rogue-hook then has the pinned sha256.

Model: Claude Opus 5.5, Claude Code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.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