Skip to content

The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu

Add hook fixes

Justin D'Souzab02c125c7007
diff --git a/CLAUDE.md b/CLAUDE.md
index e2a0125e..0e678c98 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -20,7 +20,7 @@ Do not recreate or depend on removed `asymptote` mirror trees. Keep new work foc
- Do not add dependency vulnerability scanning, OSV/GHSA lookups, package remediation, or other vulnerability-enforcement flows to the public hook path.
- Do not add broad runtime enforcement unless explicitly requested. Current control behavior is limited to hook-native approvals/denials exposed by supported agent runtimes.
- Keep direct destination support scoped to local JSONL/Wazuh unless explicitly requested. Other SIEM/observability systems should consume the local output through customer-managed forwarding.
-- Default content retention should remain metadata-only. Prompt text, command output, raw tool inputs, raw OTLP attributes, and raw diffs must be opt-in via explicit retention configuration and must pass through local redaction/size limits where supported.
+- Default content retention is `full`: configured prompt text, command output, raw tool inputs, raw OTLP attributes, and raw diffs may be written to local or customer-controlled logs, still subject to local redaction and size limits where supported. Keep `metadata` and `redacted` modes available for stricter deployments.
## Telemetry Scope
@@ -95,7 +95,7 @@ go run . endpoint dashboard
- For macOS-only behavior, gate tests with `runtime.GOOS == "darwin"` or assert the non-Darwin contract explicitly.
- Keep endpoint event schema fields stable: `vendor`, `product`, `schema_version`, required event fields, and Wazuh-compatible JSONL output are release contracts.
- Preserve optional event fields for agent-native metadata (`session`, `tool`, `file`, `command`, `mcp`, `approval`, `content`, `model`, `repository`, and `branch`) without changing existing required field semantics.
-- Prefer metadata-first telemetry. If adding a new signal, include stable identifiers/counts/hashes before considering raw content.
+- When adding a new signal, include stable identifiers/counts/hashes alongside any retained raw content, and route raw fields through the configured content retention mode.
- Keep the dashboard read-only. It should inspect local status and JSONL events but must not mutate endpoint configuration or telemetry.
- Keep the release readiness guidance in `README.md` up to date when install, packaging, collector, or dashboard behavior changes.
diff --git a/README.md b/README.md
index 2f668717..02beba52 100644
--- a/README.md
+++ b/README.md
@@ -70,14 +70,13 @@ Beacon can currently:
## Privacy And Retention
-Beacon records metadata by default. Content retention is configurable with:
+Beacon records configured content fields by default. Content retention is configurable with:
-- `metadata`: default; no prompt text, raw attributes, command output, or raw
- diffs.
+- `metadata`: no prompt text, raw attributes, command output, or raw diffs.
- `redacted`: include configured content fields after local redaction and size
limits.
-- `full`: include configured content fields in local/customer-controlled logs,
- still subject to event size limits.
+- `full`: default; include configured content fields in local/customer-controlled
+ logs, still subject to event size limits.
## What Beacon Does Not Do
@@ -128,6 +127,8 @@ package or MDM deployments.
beacon endpoint install --content-retention metadata
```
+Omit the flag to use the default `full` retention mode.
+
### Configure Wazuh Output
```bash
@@ -265,7 +266,7 @@ installs the CLI, collector, Wazuh content pack, and deployment scripts. The
package should apply explicit system endpoint settings, for example:
```bash
-beacon endpoint install --system --harness claude,codex --content-retention metadata
+beacon endpoint install --system --harness claude,codex --content-retention full
```
Before publishing a release, verify the build from a clean checkout and clean
diff --git a/cli/beacon-hooks/cmd/post_tool.go b/cli/beacon-hooks/cmd/post_tool.go
index 15311555..ffd9d1a7 100644
--- a/cli/beacon-hooks/cmd/post_tool.go
+++ b/cli/beacon-hooks/cmd/post_tool.go
@@ -15,7 +15,7 @@ var postToolCmd = &cobra.Command{
Use: "post-tool",
Short: "Record file-edit telemetry",
Long: `PostToolUse hook - triggered after Write, Edit, or MultiEdit operations.
-The public Beacon build records local metadata only.`,
+The public Beacon build writes local endpoint telemetry using the configured content retention mode.`,
Run: runPostTool,
}
@@ -61,7 +61,7 @@ func runPostTool(cmd *cobra.Command, args []string) {
outputJSON(emptyResponse)
return
}
- // afterFileEdit — records file-edit metadata only (no output supported).
+ // afterFileEdit exposes file-edit metadata and diffs; retention controls raw diff inclusion.
params = parseCursorInput(input, logger)
} else {
params = parseClaudeCopilotInput(input, logger)
diff --git a/cli/beacon-hooks/cmd/pre_tool_test.go b/cli/beacon-hooks/cmd/pre_tool_test.go
index c06fd3c2..a68bda83 100644
--- a/cli/beacon-hooks/cmd/pre_tool_test.go
+++ b/cli/beacon-hooks/cmd/pre_tool_test.go
@@ -4,6 +4,7 @@ import (
"encoding/json"
"os"
"path/filepath"
+ "strings"
"testing"
"github.com/spf13/cobra"
@@ -54,6 +55,58 @@ func TestRunPromptSubmitUsesCursorResponse(t *testing.T) {
}
}
+func TestRunPromptSubmitEmitsTypedPromptForFullRetention(t *testing.T) {
+ setupHookConfigDirs(t)
+ platformFlag = "cursor"
+ logPath := filepath.Join(t.TempDir(), "runtime.jsonl")
+ t.Setenv("BEACON_ENDPOINT_LOG", logPath)
+ t.Setenv("BEACON_ENDPOINT_CONFIG", filepath.Join(t.TempDir(), "missing-config.json"))
+
+ out := runHookWithInput(t, runPromptSubmit, map[string]interface{}{
+ "conversation_id": "conv-submit",
+ "prompt": "summarize token=prompt-secret",
+ })
+ if out["continue"] != true {
+ t.Fatalf("cursor prompt response = %#v, want continue=true", out)
+ }
+
+ event := lastEndpointEvent(t, logPath)
+ prompt, ok := event["prompt"].(map[string]interface{})
+ if !ok {
+ t.Fatalf("prompt field missing: %#v", event)
+ }
+ if got := prompt["text"]; got != "summarize token=[REDACTED]" {
+ t.Fatalf("prompt.text = %q, want redacted prompt", got)
+ }
+ if _, ok := event["raw"]; ok {
+ t.Fatalf("raw should not carry prompt payload: %#v", event["raw"])
+ }
+ if events := endpointEvents(t, logPath); len(events) != 1 {
+ t.Fatalf("endpoint event count = %d, want 1; events=%#v", len(events), events)
+ }
+}
+
+func TestRunPromptSubmitOmitsPromptForMetadataRetention(t *testing.T) {
+ setupHookConfigDirs(t)
+ platformFlag = "cursor"
+ logPath := filepath.Join(t.TempDir(), "runtime.jsonl")
+ t.Setenv("BEACON_ENDPOINT_LOG", logPath)
+ t.Setenv("BEACON_CONTENT_RETENTION", "metadata")
+
+ out := runHookWithInput(t, runPromptSubmit, map[string]interface{}{
+ "conversation_id": "conv-submit",
+ "prompt": "summarize this file",
+ })
+ if out["continue"] != true {
+ t.Fatalf("cursor prompt response = %#v, want continue=true", out)
+ }
+
+ event := lastEndpointEvent(t, logPath)
+ if _, ok := event["prompt"]; ok {
+ t.Fatalf("metadata retention should omit prompt field: %#v", event["prompt"])
+ }
+}
+
func TestRunSessionStartStoresModel(t *testing.T) {
setupHookConfigDirs(t)
platformFlag = "cursor"
@@ -155,3 +208,38 @@ func runHookWithInput(t *testing.T, run func(cmd *cobra.Command, args []string),
}
return out
}
+
+func lastEndpointEvent(t *testing.T, path string) map[string]interface{} {
+ t.Helper()
+ events := endpointEvents(t, path)
+ if len(events) == 0 {
+ t.Fatal("endpoint log was empty")
+ }
+ return events[len(events)-1]
+}
+
+func endpointEvents(t *testing.T, path string) []map[string]interface{} {
+ t.Helper()
+ data, err := os.ReadFile(path)
+ if err != nil {
+ t.Fatalf("read endpoint log: %v", err)
+ }
+ lines := []string{}
+ for _, line := range strings.Split(strings.TrimSpace(string(data)), "\n") {
+ if line != "" {
+ lines = append(lines, line)
+ }
+ }
+ if len(lines) == 0 {
+ t.Fatal("endpoint log was empty")
+ }
+ events := make([]map[string]interface{}, 0, len(lines))
+ for _, line := range lines {
+ var event map[string]interface{}
+ if err := json.Unmarshal([]byte(line), &event); err != nil {
+ t.Fatalf("decode endpoint event: %v", err)
+ }
+ events = append(events, event)
+ }
+ return events
+}
diff --git a/cli/beacon-hooks/cmd/prompt_submit.go b/cli/beacon-hooks/cmd/prompt_submit.go
index 63a45055..85ad4857 100644
--- a/cli/beacon-hooks/cmd/prompt_submit.go
+++ b/cli/beacon-hooks/cmd/prompt_submit.go
@@ -43,7 +43,7 @@ func runPromptSubmit(cmd *cobra.Command, args []string) {
fields := sessionFields(sessionID, input)
if config.ContentRetentionMode() != config.ContentRetentionMetadata {
if prompt := getFirstStr(input, "prompt", "user_prompt", "text"); prompt != "" {
- fields["raw"] = map[string]interface{}{"prompt": prompt}
+ fields["prompt"] = map[string]interface{}{"text": prompt}
}
}
emitHookEvent(logger, "prompt.submitted", "prompt", "info", "Prompt submitted to agent", input, fields)
diff --git a/cli/beacon-hooks/internal/config/config.go b/cli/beacon-hooks/internal/config/config.go
index aa48bd74..8c2c7d0b 100644
--- a/cli/beacon-hooks/internal/config/config.go
+++ b/cli/beacon-hooks/internal/config/config.go
@@ -152,7 +152,7 @@ func ContentRetentionMode() ContentRetention {
return mode
}
}
- return ContentRetentionMetadata
+ return ContentRetentionFull
}
func endpointConfigPaths() []string {
@@ -173,11 +173,13 @@ func usesSystemEndpointLog(path string) bool {
func parseContentRetention(value interface{}) (ContentRetention, bool) {
mode, _ := value.(string)
switch ContentRetention(mode) {
+ case ContentRetentionMetadata:
+ return ContentRetentionMetadata, true
case ContentRetentionRedacted:
return ContentRetentionRedacted, true
case ContentRetentionFull:
return ContentRetentionFull, true
default:
- return ContentRetentionMetadata, false
+ return ContentRetentionFull, false
}
}
diff --git a/cli/beacon-hooks/internal/config/config_test.go b/cli/beacon-hooks/internal/config/config_test.go
index d9c35234..a4d285cc 100644
--- a/cli/beacon-hooks/internal/config/config_test.go
+++ b/cli/beacon-hooks/internal/config/config_test.go
@@ -145,7 +145,7 @@ func TestContentRetentionModePrefersSystemConfigForSystemLog(t *testing.T) {
}
}
-func TestContentRetentionModeDefaultsToMetadata(t *testing.T) {
+func TestContentRetentionModeDefaultsToFull(t *testing.T) {
oldBeaconDir := BeaconDir
oldSystemPath := SystemEndpointConfigPath
BeaconDir = filepath.Join(t.TempDir(), ".beacon")
@@ -155,6 +155,18 @@ func TestContentRetentionModeDefaultsToMetadata(t *testing.T) {
SystemEndpointConfigPath = oldSystemPath
})
+ if got := ContentRetentionMode(); got != ContentRetentionFull {
+ t.Fatalf("ContentRetentionMode() = %q, want %q", got, ContentRetentionFull)
+ }
+}
+
+func TestContentRetentionModePreservesExplicitMetadata(t *testing.T) {
+ path := filepath.Join(t.TempDir(), "config.json")
+ if err := os.WriteFile(path, []byte(`{"content_retention":"metadata"}`), 0644); err != nil {
+ t.Fatalf("write endpoint config: %v", err)
+ }
+ t.Setenv("BEACON_ENDPOINT_CONFIG", path)
+
if got := ContentRetentionMode(); got != ContentRetentionMetadata {
t.Fatalf("ContentRetentionMode() = %q, want %q", got, ContentRetentionMetadata)
}
diff --git a/cli/beacon-hooks/internal/logging/logging.go b/cli/beacon-hooks/internal/logging/logging.go
index 3bf85004..ce66c432 100644
--- a/cli/beacon-hooks/internal/logging/logging.go
+++ b/cli/beacon-hooks/internal/logging/logging.go
@@ -93,7 +93,6 @@ func (l *Logger) write(entry map[string]interface{}) {
fmt.Fprintf(os.Stderr, "logging: failed to write newline to %s: %v\n", l.logFile, err)
return
}
- l.writeEndpointEvent(entry)
}
func (l *Logger) writeEndpointEvent(entry map[string]interface{}) {
@@ -174,7 +173,7 @@ func (l *Logger) EndpointEvent(action, category, severity, message string, field
}
retention := string(config.ContentRetentionMode())
if retention == "" {
- retention = "metadata"
+ retention = "full"
}
event["content"] = map[string]interface{}{
"retention": retention,
diff --git a/packaging/macos/README.md b/packaging/macos/README.md
index 36d829df..deaed9d3 100644
--- a/packaging/macos/README.md
+++ b/packaging/macos/README.md
@@ -82,7 +82,7 @@ Environment variables take precedence, followed by Jamf script parameters:
```text
Parameter 4: harnesses, default claude,codex
-Parameter 5: content retention, default metadata
+Parameter 5: content retention, default full
Parameter 6: OTLP gRPC port, default 4317
Parameter 7: OTLP HTTP port, default 4318
Parameter 8: collector path, default /opt/beacon/bin/beacon-otelcol when present
@@ -122,7 +122,7 @@ Suggested Smart Groups:
- Beacon version is `not_installed`
- Collector service health is not `running`
- Last runtime event age is greater than `86400`
-- Content retention is not `metadata`
+- Content retention is not `full`
- Runtime log writability is not `writable` or `creatable`
## Jamf Validation
diff --git a/packaging/macos/install-endpoint.sh b/packaging/macos/install-endpoint.sh
index 4b52c479..b1658445 100755
--- a/packaging/macos/install-endpoint.sh
+++ b/packaging/macos/install-endpoint.sh
@@ -10,7 +10,7 @@ if [ -z "${BEACON_BIN:-}" ]; then
fi
BEACON_ENDPOINT_HARNESSES="${BEACON_ENDPOINT_HARNESSES:-${4:-claude,codex}}"
-BEACON_CONTENT_RETENTION="${BEACON_CONTENT_RETENTION:-${5:-metadata}}"
+BEACON_CONTENT_RETENTION="${BEACON_CONTENT_RETENTION:-${5:-full}}"
BEACON_OTLP_GRPC_PORT="${BEACON_OTLP_GRPC_PORT:-${6:-4317}}"
BEACON_OTLP_HTTP_PORT="${BEACON_OTLP_HTTP_PORT:-${7:-4318}}"
BEACON_COLLECTOR="${BEACON_COLLECTOR:-${8:-}}"
diff --git a/packaging/macos/jamf/scripts/repair.sh b/packaging/macos/jamf/scripts/repair.sh
index dd76c287..63eaf545 100755
--- a/packaging/macos/jamf/scripts/repair.sh
+++ b/packaging/macos/jamf/scripts/repair.sh
@@ -4,7 +4,7 @@ set -eu
BEACON_BIN="${BEACON_BIN:-/opt/beacon/bin/beacon}"
BEACON_COLLECTOR="${BEACON_COLLECTOR:-/opt/beacon/bin/beacon-otelcol}"
BEACON_ENDPOINT_HARNESSES="${BEACON_ENDPOINT_HARNESSES:-${4:-claude,codex}}"
-BEACON_CONTENT_RETENTION="${BEACON_CONTENT_RETENTION:-${5:-metadata}}"
+BEACON_CONTENT_RETENTION="${BEACON_CONTENT_RETENTION:-${5:-full}}"
BEACON_OTLP_GRPC_PORT="${BEACON_OTLP_GRPC_PORT:-${6:-4317}}"
BEACON_OTLP_HTTP_PORT="${BEACON_OTLP_HTTP_PORT:-${7:-4318}}"
diff --git a/packaging/macos/pkgbuild.md b/packaging/macos/pkgbuild.md
index 8c6f6879..58a785d2 100644
--- a/packaging/macos/pkgbuild.md
+++ b/packaging/macos/pkgbuild.md
@@ -84,7 +84,7 @@ Use these optional Jamf policy parameters when calling
```text
Parameter 4: harnesses, default claude,codex
-Parameter 5: content retention, default metadata
+Parameter 5: content retention, default full
Parameter 6: OTLP gRPC port, default 4317
Parameter 7: OTLP HTTP port, default 4318
Parameter 8: collector path, default /opt/beacon/bin/beacon-otelcol
diff --git a/packaging/macos/smoke-endpoint.sh b/packaging/macos/smoke-endpoint.sh
index f60aa992..ec27fcf2 100755
--- a/packaging/macos/smoke-endpoint.sh
+++ b/packaging/macos/smoke-endpoint.sh
@@ -61,7 +61,7 @@ run_beacon endpoint install \
--harness claude,codex \
--otlp-grpc-port 55317 \
--otlp-http-port 55318 \
- --content-retention metadata
+ --content-retention full
test -f "$HOME_DIR/.beacon/endpoint/config.json"
test -f "$HOME_DIR/.beacon/endpoint/otelcol.yaml"
diff --git a/packaging/macos/test-endpoint-scripts.sh b/packaging/macos/test-endpoint-scripts.sh
index bd5b740d..fdb61f6d 100644
--- a/packaging/macos/test-endpoint-scripts.sh
+++ b/packaging/macos/test-endpoint-scripts.sh
@@ -5,6 +5,7 @@ ROOT_DIR="$(CDPATH= cd -- "$(dirname -- "$0")/../.." && pwd)"
INSTALL_SCRIPT="$ROOT_DIR/packaging/macos/install-endpoint.sh"
UNINSTALL_SCRIPT="$ROOT_DIR/packaging/macos/uninstall-endpoint.sh"
PKG_BUILD_SCRIPT="$ROOT_DIR/packaging/macos/build-pkg.sh"
+REPAIR_SCRIPT="$ROOT_DIR/packaging/macos/jamf/scripts/repair.sh"
TMP_DIR="$(mktemp -d)"
trap 'rm -rf "$TMP_DIR"' EXIT INT TERM
@@ -25,7 +26,6 @@ chmod +x "$STUB_BIN"
BEACON_BIN="$STUB_BIN" \
BEACON_ENDPOINT_HARNESSES="claude,codex,cursor" \
-BEACON_CONTENT_RETENTION="redacted" \
BEACON_OTLP_GRPC_PORT="5317" \
BEACON_OTLP_HTTP_PORT="5318" \
BEACON_COLLECTOR="/tmp/beacon-otelcol" \
@@ -34,13 +34,27 @@ STUB_LOG="$STUB_LOG" \
INSTALL_ARGS="$(cat "$STUB_LOG")"
case "$INSTALL_ARGS" in
- "endpoint install --system --harness claude,codex,cursor --content-retention redacted --otlp-grpc-port 5317 --otlp-http-port 5318 --collector /tmp/beacon-otelcol") ;;
+ "endpoint install --system --harness claude,codex,cursor --content-retention full --otlp-grpc-port 5317 --otlp-http-port 5318 --collector /tmp/beacon-otelcol") ;;
*)
echo "unexpected install args: $INSTALL_ARGS" >&2
exit 1
;;
esac
+BEACON_BIN="$STUB_BIN" \
+BEACON_COLLECTOR="/tmp/beacon-otelcol" \
+STUB_LOG="$STUB_LOG" \
+"$REPAIR_SCRIPT"
+
+REPAIR_ARGS="$(cat "$STUB_LOG")"
+case "$REPAIR_ARGS" in
+ "endpoint repair --collector /tmp/beacon-otelcol --harness claude,codex --content-retention full --otlp-grpc-port 4317 --otlp-http-port 4318") ;;
+ *)
+ echo "unexpected repair args: $REPAIR_ARGS" >&2
+ exit 1
+ ;;
+esac
+
BEACON_BIN="$STUB_BIN" \
STUB_LOG="$STUB_LOG" \
"$INSTALL_SCRIPT" _ _ _ "claude" "metadata" "6317" "6318" "/tmp/jamf-otelcol" "1"
@@ -89,13 +103,13 @@ cat >"$CONFIG_PATH" <<'JSON'
"claude",
"codex"
],
- "content_retention": "metadata"
+ "content_retention": "full"
}
JSON
RETENTION="$(BEACON_ENDPOINT_CONFIG="$CONFIG_PATH" "$ROOT_DIR/packaging/macos/jamf/extension-attributes/content-retention.sh")"
case "$RETENTION" in
- "<result>metadata</result>") ;;
+ "<result>full</result>") ;;
*)
echo "unexpected retention extension attribute result: $RETENTION" >&2
exit 1