The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu
Go agent-ai-cliagent-harnessesagent-securitybrowser-extensionciclaude-codecloudcodexcursordetection-engineeringjevknowledge-basememorymobile-device-managementobservabilitysecuritysecurity-information-and-event-managementsecurity-toolstelemetrytraces
Keep hook-only endpoint install from configuring Claude and Codex OTLP
Clauded97a85b60515
diff --git a/cli/beacon/cmd/endpoint_install.go b/cli/beacon/cmd/endpoint_install.goindex 7ea51eb7..a5a8966a 100644--- a/cli/beacon/cmd/endpoint_install.go+++ b/cli/beacon/cmd/endpoint_install.go@@ -91,6 +91,40 @@ func runEndpointDashboard(cmd *cobra.Command, args []string) error {})}+// Seams for tests. Production always runs the lifecycle package.+var (+ endpointLifecycleInstall = lifecycle.Install+ endpointLifecycleRepair = lifecycle.Repair+)++// endpointInstallOptions builds the lifecycle options shared by `endpoint install` and+// `endpoint repair` from the resolved target selection and flags.+//+// The selection is authoritative for OTLP runtimes: every --harness value (auto, all, an+// explicit list, or "" for collector-only) has been resolved by this point, so a selection with+// no OTLP targets means "configure none". lifecycle.InstallOptions reads a nil Harnesses as+// "unspecified" and substitutes the config default of Claude Code and Codex, which is how+// `--harness omp` came to rewrite ~/.claude/settings.json and ~/.codex/config.toml on every+// install and repair (#640). So the list is always handed over non-nil.+func endpointInstallOptions(selection endpointTargetSelection, serviceKind service.Kind) lifecycle.InstallOptions {+ harnesses := append([]string{}, selection.OTLP...)+ return lifecycle.InstallOptions{+ UserMode: endpointUserMode(),+ LogPath: endpointOpts.logPath,+ Harnesses: harnesses,+ GRPCPort: endpointOpts.grpcPort,+ HTTPPort: endpointOpts.httpPort,+ HealthPort: endpointOpts.healthPort,+ CollectorPath: endpointOpts.collectorPath,+ StartService: !endpointOpts.noStart,+ IncludeRuntimeMetrics: endpointOpts.includeRuntimeMetrics,+ IncludeCodexSpans: endpointOpts.includeCodexSpans,+ SplunkHEC: splunkHECOptions(),+ FalconHEC: falconHECOptions(),+ ServiceKind: serviceKind,+ }+}+func runEndpointInstall(cmd *cobra.Command, args []string) error {selection, err := resolveEndpointTargets(endpointOpts.harnesses, harness.DiscoverAll())if err != nil {@@ -113,21 +147,7 @@ func runEndpointInstall(cmd *cobra.Command, args []string) error {// Confirming Beacon Managed connects this endpoint; --connect does the same for// the paths the wizard did not own.connectAfterInstall := onboarded.Connect || endpointOpts.connect- result, err := lifecycle.Install(lifecycle.InstallOptions{- UserMode: endpointUserMode(),- LogPath: endpointOpts.logPath,- Harnesses: selection.OTLP,- GRPCPort: endpointOpts.grpcPort,- HTTPPort: endpointOpts.httpPort,- HealthPort: endpointOpts.healthPort,- CollectorPath: endpointOpts.collectorPath,- StartService: !endpointOpts.noStart,- IncludeRuntimeMetrics: endpointOpts.includeRuntimeMetrics,- IncludeCodexSpans: endpointOpts.includeCodexSpans,- SplunkHEC: splunkHECOptions(),- FalconHEC: falconHECOptions(),- ServiceKind: serviceKind,- })+ result, err := endpointLifecycleInstall(endpointInstallOptions(selection, serviceKind))if err != nil {return err}@@ -285,21 +305,7 @@ func runEndpointRepair(cmd *cobra.Command, args []string) error {// Resend only. Repair is a maintenance command and never asks a question, but a// signup that failed on a flaky network deserves the retry the docs promise.retryPendingOnboarding()- result, err := lifecycle.Repair(lifecycle.InstallOptions{- UserMode: endpointUserMode(),- LogPath: endpointOpts.logPath,- Harnesses: selection.OTLP,- GRPCPort: endpointOpts.grpcPort,- HTTPPort: endpointOpts.httpPort,- HealthPort: endpointOpts.healthPort,- CollectorPath: endpointOpts.collectorPath,- StartService: !endpointOpts.noStart,- IncludeRuntimeMetrics: endpointOpts.includeRuntimeMetrics,- IncludeCodexSpans: endpointOpts.includeCodexSpans,- SplunkHEC: splunkHECOptions(),- FalconHEC: falconHECOptions(),- ServiceKind: serviceKind,- })+ result, err := endpointLifecycleRepair(endpointInstallOptions(selection, serviceKind))if err != nil {return err}diff --git a/cli/beacon/cmd/endpoint_install_harness_test.go b/cli/beacon/cmd/endpoint_install_harness_test.gonew file mode 100644index 00000000..99c031cb--- /dev/null+++ b/cli/beacon/cmd/endpoint_install_harness_test.go@@ -0,0 +1,175 @@+package cmd++import (+ "strings"+ "testing"++ "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/harness"+ "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/lifecycle"+ "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/service"+ "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/testenv"+ "github.com/spf13/cobra"+)++// recordEndpointLifecycle replaces the lifecycle install and repair calls with recorders, so+// a test can run the real `endpoint install` and `endpoint repair` commands and inspect exactly+// what they asked the lifecycle package to configure, without starting a collector.+func recordEndpointLifecycle(t *testing.T) *[]lifecycle.InstallOptions {+ t.Helper()+ testenv.SetHome(t, t.TempDir())+ t.Setenv("BEACON_ONBOARDING", "0")+ t.Setenv("BEACON_ONBOARDING_EMAIL", "")+ t.Setenv("BEACON_ONBOARDING_USAGE", "")+ oldOpts := endpointOpts+ oldInstall := endpointLifecycleInstall+ oldRepair := endpointLifecycleRepair+ t.Cleanup(func() {+ endpointOpts = oldOpts+ endpointLifecycleInstall = oldInstall+ endpointLifecycleRepair = oldRepair+ })+ endpointOpts.serviceKind = string(service.KindAuto)+ endpointOpts.dryRun = false+ endpointOpts.connect = false+ endpointOpts.noStart = true+ endpointOpts.logPath = ""+ calls := &[]lifecycle.InstallOptions{}+ record := func(opts lifecycle.InstallOptions) (lifecycle.InstallResult, error) {+ *calls = append(*calls, opts)+ return lifecycle.InstallResult{}, nil+ }+ endpointLifecycleInstall = record+ endpointLifecycleRepair = record+ return calls+}++func runRecordedEndpointCommand(t *testing.T, repair bool, harnessFlag string) lifecycle.InstallOptions {+ t.Helper()+ calls := recordEndpointLifecycle(t)+ endpointOpts.harnesses = harnessFlag+ run := runEndpointInstall+ name := "install"+ if repair {+ run = runEndpointRepair+ name = "repair"+ }+ cmd := &cobra.Command{Use: name}+ cmd.SetOut(&strings.Builder{})+ cmd.SetErr(&strings.Builder{})+ if err := run(cmd, nil); err != nil {+ t.Fatalf("endpoint %s --harness %q: %v", name, harnessFlag, err)+ }+ if len(*calls) != 1 {+ t.Fatalf("endpoint %s --harness %q made %d lifecycle calls, want 1", name, harnessFlag, len(*calls))+ }+ return (*calls)[0]+}++// assertNoOTLPHarnesses checks the lifecycle was told to configure no OTLP runtime.+//+// The distinction between nil and empty is the whole contract: lifecycle.InstallOptions treats+// nil Harnesses as "not specified" and falls back to the config default of Claude Code and Codex,+// which is how a hook-only install came to rewrite ~/.claude/settings.json and ~/.codex/config.toml+// (#640). Only a non-nil empty list means "configure none".+func assertNoOTLPHarnesses(t *testing.T, label string, got []string) {+ t.Helper()+ if got == nil {+ t.Fatalf("%s: Harnesses is nil, which lifecycle reads as unspecified and replaces with claude,codex", label)+ }+ if len(got) != 0 {+ t.Fatalf("%s: Harnesses = %#v, want none", label, got)+ }+}++// #640: an explicit hook-only selection names only that hook integration. It must not also+// configure Claude Code's and Codex's OpenTelemetry settings behind the operator's back.+func TestEndpointInstallHookOnlyHarnessConfiguresNoOTLPRuntime(t *testing.T) {+ for _, flag := range []string{"omp", "cursor", "omp,cursor", "claude-hooks"} {+ opts := runRecordedEndpointCommand(t, false, flag)+ assertNoOTLPHarnesses(t, "install --harness "+flag, opts.Harnesses)+ }+}++// The same selection re-run through `endpoint repair` (and the MDM repair scripts built on it)+// must not reintroduce the writes on every run.+func TestEndpointRepairHookOnlyHarnessConfiguresNoOTLPRuntime(t *testing.T) {+ opts := runRecordedEndpointCommand(t, true, "omp")+ assertNoOTLPHarnesses(t, "repair --harness omp", opts.Harnesses)+}++// `--harness ""` is the documented collector-only install (splitHarnessCSV keeps it an empty+// list on purpose), so it must configure no runtime at all.+func TestEndpointInstallCollectorOnlyHarnessConfiguresNoOTLPRuntime(t *testing.T) {+ for _, repair := range []bool{false, true} {+ opts := runRecordedEndpointCommand(t, repair, "")+ assertNoOTLPHarnesses(t, "collector-only", opts.Harnesses)+ }+}++// Automatic selection that detects nothing OTLP-capable already reports "no runtime integrations+// will be configured", and the install docs promise the collector is installed without changing+// any runtime configuration. The lifecycle options have to agree with that message.+func TestEndpointInstallOptionsAutoWithoutOTLPRuntimeConfiguresNone(t *testing.T) {+ recordEndpointLifecycle(t)+ for name, discovered := range map[string][]harness.Harness{+ "nothing detected": nil,+ "hook-only detected": {{Name: "omp", DisplayName: "Oh My Pi", Detected: true}},+ "skip-only detected": {{Name: "vercel_fx", DisplayName: "fx", Detected: true}},+ } {+ selection, err := resolveEndpointTargets(endpointHarnessAuto, discovered)+ if err != nil {+ t.Fatalf("%s: %v", name, err)+ }+ assertNoOTLPHarnesses(t, "auto, "+name, endpointInstallOptions(selection, service.KindAuto).Harnesses)+ }+}++// No regression: selections that name OTLP runtimes still configure exactly those, including the+// default automatic selection on a machine where Claude Code and Codex are installed.+func TestEndpointInstallOptionsKeepSelectedOTLPRuntimes(t *testing.T) {+ recordEndpointLifecycle(t)+ autoDefault := endpointInstallCmd.Flags().Lookup("harness").DefValue+ cases := []struct {+ flag string+ discovered []harness.Harness+ want string+ }{+ {flag: autoDefault, discovered: []harness.Harness{+ {Name: "claude_code", DisplayName: "Claude Code", Detected: true},+ {Name: "codex_cli", DisplayName: "Codex CLI", Detected: true},+ {Name: "omp", DisplayName: "Oh My Pi", Detected: true},+ }, want: "claude,codex"},+ {flag: "claude,codex", want: "claude,codex"},+ {flag: "omp,claude", want: "claude"},+ {flag: "cursor,gemini", want: "gemini"},+ }+ for _, tc := range cases {+ selection, err := resolveEndpointTargets(tc.flag, tc.discovered)+ if err != nil {+ t.Fatalf("--harness %q: %v", tc.flag, err)+ }+ got := endpointInstallOptions(selection, service.KindAuto).Harnesses+ if strings.Join(got, ",") != tc.want {+ t.Fatalf("--harness %q: Harnesses = %#v, want %s", tc.flag, got, tc.want)+ }+ }++ all, err := resolveEndpointTargets("all", nil)+ if err != nil {+ t.Fatal(err)+ }+ got := strings.Join(endpointInstallOptions(all, service.KindAuto).Harnesses, ",")+ if !strings.Contains(got, "claude") || !strings.Contains(got, "codex") {+ t.Fatalf("--harness all: Harnesses = %q, want claude and codex among them", got)+ }+}++// The commands themselves, not only the helper, pass an OTLP selection through unchanged.+func TestEndpointInstallAndRepairPassExplicitOTLPSelection(t *testing.T) {+ for _, repair := range []bool{false, true} {+ opts := runRecordedEndpointCommand(t, repair, "codex")+ if got := strings.Join(opts.Harnesses, ","); got != "codex" {+ t.Fatalf("repair=%t --harness codex: Harnesses = %q, want codex", repair, got)+ }+ }+}diff --git a/cli/beacon/internal/endpoint/lifecycle/harness_selection_test.go b/cli/beacon/internal/endpoint/lifecycle/harness_selection_test.gonew file mode 100644index 00000000..e200a3d6--- /dev/null+++ b/cli/beacon/internal/endpoint/lifecycle/harness_selection_test.go@@ -0,0 +1,92 @@+package lifecycle++import (+ "os"+ "path/filepath"+ "testing"++ endpointconfig "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/config"+ "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/service"+ "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/testenv"+)++// #640, end to end at the lifecycle layer: a repair with an explicit empty OTLP selection (what+// `endpoint repair --harness omp` passes) must leave Claude Code's and Codex's own config files+// byte-for-byte alone, record no harness configs in the manifest, and replace a config.json+// written by an earlier install that defaulted to claude,codex rather than inheriting it.+func TestRepairWithExplicitEmptyHarnessesLeavesClaudeAndCodexConfigAlone(t *testing.T) {+ testenv.RequirePOSIXExecutableFixtures(t)+ home := t.TempDir()+ testenv.SetHome(t, home)+ t.Setenv("CODEX_HOME", "")+ installFakeInventoryJob(t, false)++ claudeSettings := filepath.Join(home, ".claude", "settings.json")+ codexConfig := filepath.Join(home, ".codex", "config.toml")+ const claudeBody = "{\n \"model\": \"opus\"\n}\n"+ const codexBody = "model = \"gpt-5\"\n"+ for path, body := range map[string]string{claudeSettings: claudeBody, codexConfig: codexBody} {+ if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {+ t.Fatal(err)+ }+ if err := os.WriteFile(path, []byte(body), 0o644); err != nil {+ t.Fatal(err)+ }+ }++ collectorPath := filepath.Join(home, "bin", "beacon-otelcol")+ if err := os.MkdirAll(filepath.Dir(collectorPath), 0o755); err != nil {+ t.Fatal(err)+ }+ if err := os.WriteFile(collectorPath, []byte("#!/bin/sh\n"), 0o755); err != nil {+ t.Fatal(err)+ }+ logPath := filepath.Join(home, ".beacon", "endpoint", "logs", "runtime.jsonl")++ // The config.json an affected install left behind: harnesses filled in by the default.+ prior := endpointconfig.Default(true, logPath)+ if _, err := endpointconfig.Save(prior); err != nil {+ t.Fatal(err)+ }++ if _, err := Repair(InstallOptions{+ UserMode: true,+ LogPath: logPath,+ Harnesses: []string{},+ GRPCPort: freePort(t),+ HTTPPort: freePort(t),+ HealthPort: freePort(t),+ CollectorPath: collectorPath,+ StartService: false,+ ServiceKind: service.KindSupervised,+ }); err != nil {+ t.Fatalf("Repair: %v", err)+ }++ for path, want := range map[string]string{claudeSettings: claudeBody, codexConfig: codexBody} {+ got, err := os.ReadFile(path)+ if err != nil {+ t.Fatal(err)+ }+ if string(got) != want {+ t.Fatalf("%s was rewritten by a repair that selected no OTLP runtime:\n%s", path, got)+ }+ if backups, _ := filepath.Glob(path + ".beacon.*.bak"); len(backups) != 0 {+ t.Fatalf("%s gained Beacon backups %v, so it was written", path, backups)+ }+ }+ manifest, err := ReadManifest(true)+ if err != nil {+ t.Fatal(err)+ }+ if len(manifest.HarnessConfigs) != 0 || len(manifest.Backups) != 0 {+ t.Fatalf("manifest records harness configs %v / backups %v, want none", manifest.HarnessConfigs, manifest.Backups)+ }+ cfg, err := endpointconfig.Load(true)+ if err != nil {+ t.Fatal(err)+ }+ if len(cfg.Harnesses) != 0 {+ t.Fatalf("config.json harnesses = %#v, want the explicit empty selection, not the prior default", cfg.Harnesses)+ }+}diff --git a/cli/beacon/internal/endpoint/lifecycle/lifecycle.go b/cli/beacon/internal/endpoint/lifecycle/lifecycle.goindex ef4ff901..b0e561f7 100644--- a/cli/beacon/internal/endpoint/lifecycle/lifecycle.go+++ b/cli/beacon/internal/endpoint/lifecycle/lifecycle.go@@ -186,8 +186,12 @@ func inventoryHeartbeatStatus(requestedUserMode bool, logPath string) InventoryH}type InstallOptions struct {- UserMode bool- LogPath string+ UserMode bool+ LogPath string+ // Harnesses lists the OTLP runtimes whose settings install writes. nil means unspecified+ // and falls back to the config default (Claude Code and Codex); a non-nil empty list means+ // configure none. A caller that resolved an explicit selection must pass it non-nil, or a+ // selection with no OTLP runtime silently configures the default ones (#640).Harnesses []stringGRPCPort intHTTPPort intdiff --git a/docs/cli/endpoint-install.mdx b/docs/cli/endpoint-install.mdxindex 9ffb31f9..81d27af9 100644--- a/docs/cli/endpoint-install.mdx+++ b/docs/cli/endpoint-install.mdx@@ -13,7 +13,7 @@ The service is a launchd job on macOS and a systemd unit on Linux. Where neitherbeacon endpoint install```-By default, Beacon discovers the runtimes installed for the invoking user and configures every integration it can safely install. This includes OTLP settings and supported hooks, plugins, or extensions; VS Code receives both its OTLP and hook configuration. An explicit `--harness` list disables automatic selection. If discovery finds no automatically installable runtime, Beacon installs the collector without changing any runtime configuration.+By default, Beacon discovers the runtimes installed for the invoking user and configures every integration it can safely install. This includes OTLP settings and supported hooks, plugins, or extensions; VS Code receives both its OTLP and hook configuration. An explicit `--harness` list disables automatic selection and configures only the runtimes it names: a hook-only list such as `--harness omp` leaves Claude Code's and Codex's settings untouched, and `--harness ""` installs the collector alone. If discovery finds no automatically installable runtime, Beacon installs the collector without changing any runtime configuration.Discovery can also find runtimes whose collection path cannot be enabled safely by a machine-wide default. Beacon reports these without treating them as install failures: GitHub Copilot CLI needs launch-environment settings, Claude Cowork needs admin configuration, poll-only fx needs `beacon endpoint fx sync`, and OpenHands CLI/GUI coverage requires project-level hooks installed from inside each repository. Factory Droid's hooks are installed automatically when Droid is detected, while its separate OTLP endpoint remains launch-environment managed.diff --git a/docs/cli/endpoint-repair.mdx b/docs/cli/endpoint-repair.mdxindex 4657b9d9..1ff35a00 100644--- a/docs/cli/endpoint-repair.mdx+++ b/docs/cli/endpoint-repair.mdx@@ -11,7 +11,7 @@ description: "Repair Beacon endpoint service files, collector configuration, andbeacon endpoint repair```-Repair preserves runtime logs while reinstalling managed endpoint files. By default it rediscovers installed runtimes and reapplies every integration Beacon can configure. Pass an explicit `--harness` list to repair only those targets. GitHub Copilot CLI and Factory Droid launch-environment settings remain customer-managed; repair does not write those environment settings.+Repair preserves runtime logs while reinstalling managed endpoint files. By default it rediscovers installed runtimes and reapplies every integration Beacon can configure. Pass an explicit `--harness` list to repair only those targets; runtimes it does not name, including Claude Code and Codex, are not written. GitHub Copilot CLI and Factory Droid launch-environment settings remain customer-managed; repair does not write those environment settings.During repair, Beacon removes the existing managed service before reinstalling it so an unhealthy collector can release local OTLP ports. If reinstall cannot complete, Beacon restores the previous endpoint configuration so local state is not left partially rolled back.