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
Add CI session mode for agent telemetry
shukieshahdde0ea1432c0
diff --git a/.github/workflows/ci-session-smoke.yml b/.github/workflows/ci-session-smoke.ymlnew file mode 100644index 00000000..d7783b34--- /dev/null+++ b/.github/workflows/ci-session-smoke.yml@@ -0,0 +1,66 @@+name: Beacon CI session smoke++on:+ pull_request:+ paths:+ - action.yml+ - .github/workflows/ci-session-smoke.yml+ - cli/beacon/**+ - collector-builder/exporter/beaconjsonexporter/**+ - examples/github-actions/**+ workflow_dispatch:++permissions:+ contents: read++jobs:+ claude-session-smoke:+ runs-on: ubuntu-latest+ steps:+ - uses: actions/checkout@v4++ - uses: actions/setup-go@v5+ with:+ go-version-file: cli/beacon/go.mod++ - name: Build branch Beacon CLI+ run: |+ set -euo pipefail+ mkdir -p /tmp/beacon-session-smoke+ cd cli/beacon+ go build -o /tmp/beacon-session-smoke/beacon .++ - name: Download released Beacon collector+ run: |+ set -euo pipefail+ archive=/tmp/beacon-session-smoke/beacon.tgz+ curl -fsSL \+ https://github.com/asymptote-labs/agent-beacon/releases/download/v0.0.49/beacon_0.0.49_linux_amd64.tar.gz \+ -o "$archive"+ tar -xzf "$archive" -C /tmp/beacon-session-smoke beacon-otelcol+ chmod +x /tmp/beacon-session-smoke/beacon /tmp/beacon-session-smoke/beacon-otelcol++ - name: Start Beacon telemetry+ uses: ./+ with:+ mode: start+ binary-path: /tmp/beacon-session-smoke/beacon+ harnesses: claude++ - name: Install Claude Code+ run: npm install -g @anthropic-ai/claude-code++ - name: Run Claude smoke+ env:+ ANTHROPIC_API_KEY: ${{ secrets.CLAUDE_API_KEY }}+ run: 'claude --print "Say exactly: beacon session smoke"'++ - name: Finish Beacon telemetry+ if: always()+ uses: ./+ with:+ mode: finish+ binary-path: /tmp/beacon-session-smoke/beacon+ min-events: "1"+ upload-artifact: "true"+ artifact-name: beacon-ci-session-smokediff --git a/action.yml b/action.ymlindex 31836716..bc1f7775 100644--- a/action.yml+++ b/action.yml@@ -1,16 +1,26 @@name: "Agent Beacon CI Telemetry"-description: "Capture Claude Code CI telemetry to Agent Beacon JSONL, artifacts, or customer-managed destinations."+description: "Capture agent CI telemetry to Agent Beacon JSONL, artifacts, or customer-managed destinations."author: "Asymptote Labs"branding:icon: "radio"color: "purple"inputs:+ mode:+ description: "How to run Beacon CI telemetry: 'exec' (default), 'start', or 'finish'."+ required: false+ default: "exec"command:description: >-The Claude Code command to run, e.g. claude --print "Summarize this repo".Executed via bash -c so the configured telemetry environment reaches it.- required: true+ Required when mode is 'exec'.+ required: false+ default: ""+ harnesses:+ description: "Comma-separated agent harnesses to configure, e.g. claude,codex."+ required: false+ default: ""version:description: >-Beacon CLI release tag to download (e.g. v0.0.39). Defaults to a version@@ -66,7 +76,13 @@ inputs:outputs:log-path:description: "Path to the Beacon runtime JSONL log."- value: ${{ steps.exec.outputs.log-path }}+ value: ${{ steps.paths.outputs.log-path }}+ state-path:+ description: "Path to the Beacon CI session state file."+ value: ${{ steps.paths.outputs.state-path }}+ codex-home:+ description: "Path to Beacon's generated Codex home directory."+ value: ${{ steps.paths.outputs.codex-home }}runs:using: "composite"@@ -77,7 +93,7 @@ runs:env:# A specific tag is pinned here rather than resolving "latest" so runs# are reproducible and the downloaded archive can be checksum-verified.- DEFAULT_BEACON_VERSION: "v0.0.39"+ DEFAULT_BEACON_VERSION: "v0.0.49"INPUT_VERSION: ${{ inputs.version }}INPUT_BINARY_PATH: ${{ inputs.binary-path }}run: |@@ -135,30 +151,48 @@ runs:echo "beacon-bin=${workdir}/beacon" >> "$GITHUB_OUTPUT"echo "Verified and extracted beacon ${version} to ${workdir}"- - name: Run Claude with Beacon telemetry+ - name: Resolve Beacon paths+ id: paths+ shell: bash+ run: |+ set -euo pipefail+ log_dir="${RUNNER_TEMP:-$(mktemp -d)}/beacon"+ mkdir -p "${log_dir}"+ echo "base-dir=${log_dir}" >> "$GITHUB_OUTPUT"+ echo "log-path=${log_dir}/runtime.jsonl" >> "$GITHUB_OUTPUT"+ echo "state-path=${log_dir}/session.json" >> "$GITHUB_OUTPUT"+ echo "codex-home=${log_dir}/codex-home" >> "$GITHUB_OUTPUT"++ - name: Run command with Beacon telemetryid: exec+ if: ${{ inputs.mode == 'exec' }}shell: bashenv:BEACON_BIN: ${{ steps.resolve.outputs.beacon-bin }}+ INPUT_HARNESSES: ${{ inputs.harnesses }}INPUT_COMMAND: ${{ inputs.command }}INPUT_MIN_EVENTS: ${{ inputs.min-events }}INPUT_REQUIRE_TELEMETRY: ${{ inputs.require-telemetry }}INPUT_FORWARD: ${{ inputs.forward }}INPUT_FORWARD_ENDPOINT: ${{ inputs.forward-endpoint }}INPUT_UPLOAD: ${{ inputs.upload }}+ LOG_PATH: ${{ steps.paths.outputs.log-path }}run: |set -euo pipefail- log_dir="${RUNNER_TEMP:-$(mktemp -d)}/beacon"- mkdir -p "${log_dir}"- log_path="${log_dir}/runtime.jsonl"- echo "log-path=${log_path}" >> "$GITHUB_OUTPUT"+ if [ -z "${INPUT_COMMAND}" ]; then+ echo "::error::input 'command' is required when mode is 'exec'"+ exit 1+ fiargs=(ci exec- --log-path "${log_path}"+ --log-path "${LOG_PATH}"--min-events "${INPUT_MIN_EVENTS}""--require-telemetry=${INPUT_REQUIRE_TELEMETRY}")+ if [ -n "${INPUT_HARNESSES}" ]; then+ args+=(--harness "${INPUT_HARNESSES}")+ fiif [ -n "${INPUT_FORWARD}" ]; thenargs+=(--forward "${INPUT_FORWARD}")if [ -n "${INPUT_FORWARD_ENDPOINT}" ]; then@@ -179,10 +213,66 @@ runs:# this script) so workflow inputs cannot inject shell commands."${BEACON_BIN}" "${args[@]}" -- bash -c "${INPUT_COMMAND}"+ - name: Start Beacon telemetry session+ id: start+ if: ${{ inputs.mode == 'start' }}+ shell: bash+ env:+ BEACON_BIN: ${{ steps.resolve.outputs.beacon-bin }}+ INPUT_HARNESSES: ${{ inputs.harnesses }}+ INPUT_FORWARD: ${{ inputs.forward }}+ INPUT_FORWARD_ENDPOINT: ${{ inputs.forward-endpoint }}+ LOG_PATH: ${{ steps.paths.outputs.log-path }}+ STATE_PATH: ${{ steps.paths.outputs.state-path }}+ run: |+ set -euo pipefail+ harnesses="${INPUT_HARNESSES:-claude,codex}"+ args=(ci start+ --log-path "${LOG_PATH}"+ --state-path "${STATE_PATH}"+ --github-env "${GITHUB_ENV}"+ --harness "${harnesses}"+ )+ if [ -n "${INPUT_FORWARD}" ]; then+ args+=(--forward "${INPUT_FORWARD}")+ if [ -n "${INPUT_FORWARD_ENDPOINT}" ]; then+ args+=(--forward-endpoint "${INPUT_FORWARD_ENDPOINT}")+ fi+ fi+ "${BEACON_BIN}" "${args[@]}"++ - name: Finish Beacon telemetry session+ id: finish+ if: ${{ always() && inputs.mode == 'finish' }}+ shell: bash+ env:+ BEACON_BIN: ${{ steps.resolve.outputs.beacon-bin }}+ INPUT_MIN_EVENTS: ${{ inputs.min-events }}+ INPUT_REQUIRE_TELEMETRY: ${{ inputs.require-telemetry }}+ INPUT_UPLOAD: ${{ inputs.upload }}+ STATE_PATH: ${{ steps.paths.outputs.state-path }}+ run: |+ set -euo pipefail+ args=(ci finish+ --state-path "${STATE_PATH}"+ --min-events "${INPUT_MIN_EVENTS}"+ "--require-telemetry=${INPUT_REQUIRE_TELEMETRY}"+ )+ if [ -n "${INPUT_UPLOAD}" ]; then+ IFS=',' read -ra upload_values <<< "${INPUT_UPLOAD}"+ for upload in "${upload_values[@]}"; do+ upload="${upload//[[:space:]]/}"+ if [ -n "${upload}" ]; then+ args+=(--upload "${upload}")+ fi+ done+ fi+ "${BEACON_BIN}" "${args[@]}"+- name: Upload Beacon telemetry- if: ${{ always() && inputs.upload-artifact == 'true' }}+ if: ${{ always() && inputs.upload-artifact == 'true' && inputs.mode != 'start' }}uses: actions/upload-artifact@v4with:name: ${{ inputs.artifact-name }}- path: ${{ steps.exec.outputs.log-path }}+ path: ${{ steps.paths.outputs.log-path }}if-no-files-found: warndiff --git a/cli/beacon/cmd/ci.go b/cli/beacon/cmd/ci.goindex f44b8e3c..ac1f599b 100644--- a/cli/beacon/cmd/ci.go+++ b/cli/beacon/cmd/ci.go@@ -17,21 +17,24 @@ import ()var ciOpts struct {- baseDir string- logPath string- workDir string- collectorPath string- harness string- contentRetention string- grpcPort int- httpPort int- jsonOutput bool- keepArtifacts bool- minEvents int- forward string- forwardEndpoint string- uploads []string- requireTelemetry bool+ baseDir string+ logPath string+ workDir string+ collectorPath string+ harness string+ statePath string+ githubEnvPath string+ contentRetention string+ grpcPort int+ httpPort int+ jsonOutput bool+ keepArtifacts bool+ includeCodexSpans bool+ minEvents int+ forward string+ forwardEndpoint string+ uploads []string+ requireTelemetry bool}var ciCmd = &cobra.Command{@@ -49,6 +52,20 @@ var ciExecCmd = &cobra.Command{RunE: runCIExec,}+var ciStartCmd = &cobra.Command{+ Use: "start",+ Short: "Start a detached Beacon CI telemetry session",+ SilenceUsage: true,+ RunE: runCIStart,+}++var ciFinishCmd = &cobra.Command{+ Use: "finish",+ Short: "Stop and validate a detached Beacon CI telemetry session",+ SilenceUsage: true,+ RunE: runCIFinish,+}+var ciValidateCmd = &cobra.Command{Use: "validate",Short: "Validate CI runtime telemetry artifacts",@@ -59,46 +76,63 @@ var ciValidateCmd = &cobra.Command{func init() {rootCmd.AddCommand(ciCmd)ciCmd.AddCommand(ciExecCmd)+ ciCmd.AddCommand(ciStartCmd)+ ciCmd.AddCommand(ciFinishCmd)ciCmd.AddCommand(ciValidateCmd)- for _, cmd := range []*cobra.Command{ciExecCmd, ciValidateCmd} {+ for _, cmd := range []*cobra.Command{ciExecCmd, ciStartCmd, ciFinishCmd, ciValidateCmd} {cmd.Flags().StringVar(&ciOpts.logPath, "log-path", "", "CI runtime JSONL log path")- cmd.Flags().StringVar(&ciOpts.harness, "harness", beaconci.DefaultHarness, "CI harness to configure (currently only claude)")+ cmd.Flags().StringVar(&ciOpts.harness, "harness", beaconci.DefaultHarness, "CI harness to configure (claude, codex, or comma-separated)")cmd.Flags().BoolVar(&ciOpts.jsonOutput, "json", false, "Print result as JSON")cmd.Flags().IntVar(&ciOpts.minEvents, "min-events", beaconci.DefaultValidationMin, "Minimum matching events required during validation")}- ciExecCmd.Flags().StringVar(&ciOpts.baseDir, "base-dir", "", "CI session base directory (defaults to $RUNNER_TEMP/beacon or a temp directory)")+ for _, cmd := range []*cobra.Command{ciExecCmd, ciStartCmd} {+ cmd.Flags().StringVar(&ciOpts.baseDir, "base-dir", "", "CI session base directory (defaults to $RUNNER_TEMP/beacon or a temp directory)")+ cmd.Flags().StringVar(&ciOpts.collectorPath, "collector", "", "Path to a beacon-otelcol binary")+ cmd.Flags().IntVar(&ciOpts.grpcPort, "otlp-grpc-port", endpointconfig.DefaultGRPCPort, "Local OTLP gRPC port")+ cmd.Flags().IntVar(&ciOpts.httpPort, "otlp-http-port", endpointconfig.DefaultHTTPPort, "Local OTLP HTTP port")+ cmd.Flags().BoolVar(&ciOpts.includeCodexSpans, "include-codex-spans", false, "Include high-volume Codex spans for troubleshooting")+ for _, name := range []string{"base-dir", "collector", "otlp-grpc-port", "otlp-http-port", "include-codex-spans"} {+ _ = cmd.Flags().MarkHidden(name)+ }+ }ciExecCmd.Flags().StringVar(&ciOpts.workDir, "work-dir", "", "Working directory for the child command")- ciExecCmd.Flags().StringVar(&ciOpts.collectorPath, "collector", "", "Path to a beacon-otelcol binary")- ciExecCmd.Flags().IntVar(&ciOpts.grpcPort, "otlp-grpc-port", endpointconfig.DefaultGRPCPort, "Local OTLP gRPC port")- ciExecCmd.Flags().IntVar(&ciOpts.httpPort, "otlp-http-port", endpointconfig.DefaultHTTPPort, "Local OTLP HTTP port")ciExecCmd.Flags().StringVar(&ciOpts.contentRetention, "content-retention", "", "Deprecated no-op; Beacon always captures full content subject to redaction and size limits")_ = ciExecCmd.Flags().MarkHidden("content-retention")_ = ciExecCmd.Flags().MarkDeprecated("content-retention", "Beacon now always captures full content; this flag is ignored")ciExecCmd.Flags().BoolVar(&ciOpts.keepArtifacts, "keep-artifacts", true, "Keep CI runtime log and collector config after exit")- ciExecCmd.Flags().StringVar(&ciOpts.forward, "forward", "", "Optionally forward events to a customer-managed SIEM: splunk or falcon (token read from the environment)")- ciExecCmd.Flags().StringVar(&ciOpts.forwardEndpoint, "forward-endpoint", "", "SIEM HEC endpoint URL for --forward (token comes from BEACON_CI_*_HEC_TOKEN)")- ciExecCmd.Flags().StringArrayVar(&ciOpts.uploads, "upload", nil, "Upload final CI runtime JSONL after validation: s3 or gcs (repeatable)")- ciExecCmd.Flags().BoolVar(&ciOpts.requireTelemetry, "require-telemetry", true, "Fail the command when telemetry validation fails; set false to warn only")- for _, name := range []string{"base-dir", "work-dir", "collector", "otlp-grpc-port", "otlp-http-port"} {- _ = ciExecCmd.Flags().MarkHidden(name)+ _ = ciExecCmd.Flags().MarkHidden("work-dir")+ for _, cmd := range []*cobra.Command{ciExecCmd, ciStartCmd, ciFinishCmd} {+ cmd.Flags().StringVar(&ciOpts.forward, "forward", "", "Optionally forward events to a customer-managed SIEM: splunk or falcon (token read from the environment)")+ cmd.Flags().StringVar(&ciOpts.forwardEndpoint, "forward-endpoint", "", "SIEM HEC endpoint URL for --forward (token comes from BEACON_CI_*_HEC_TOKEN)")+ }+ for _, cmd := range []*cobra.Command{ciExecCmd, ciFinishCmd} {+ cmd.Flags().StringArrayVar(&ciOpts.uploads, "upload", nil, "Upload final CI runtime JSONL after validation: s3 or gcs (repeatable)")+ cmd.Flags().BoolVar(&ciOpts.requireTelemetry, "require-telemetry", true, "Fail the command when telemetry validation fails; set false to warn only")}+ for _, cmd := range []*cobra.Command{ciStartCmd, ciFinishCmd} {+ cmd.Flags().StringVar(&ciOpts.statePath, "state-path", "", "CI session state path")+ _ = cmd.Flags().MarkHidden("state-path")+ }+ ciStartCmd.Flags().StringVar(&ciOpts.githubEnvPath, "github-env", "", "Path to GITHUB_ENV for exporting telemetry variables")+ _ = ciStartCmd.Flags().MarkHidden("github-env")}func runCIExec(cmd *cobra.Command, args []string) error {runCtx, stopSignals := signal.NotifyContext(cmd.Context(), os.Interrupt, syscall.SIGTERM)defer stopSignals()session, err := beaconci.Provision(beaconci.Options{- BaseDir: ciOpts.baseDir,- LogPath: ciOpts.logPath,- WorkDir: ciOpts.workDir,- CollectorPath: ciOpts.collectorPath,- GRPCPort: ciOpts.grpcPort,- HTTPPort: ciOpts.httpPort,- Harness: ciOpts.harness,- KeepArtifacts: ciOpts.keepArtifacts,- Forward: ciOpts.forward,- ForwardEndpoint: ciOpts.forwardEndpoint,- Uploads: ciOpts.uploads,+ BaseDir: ciOpts.baseDir,+ LogPath: ciOpts.logPath,+ WorkDir: ciOpts.workDir,+ CollectorPath: ciOpts.collectorPath,+ GRPCPort: ciOpts.grpcPort,+ HTTPPort: ciOpts.httpPort,+ Harness: ciOpts.harness,+ KeepArtifacts: ciOpts.keepArtifacts,+ Forward: ciOpts.forward,+ ForwardEndpoint: ciOpts.forwardEndpoint,+ Uploads: ciOpts.uploads,+ IncludeCodexSpans: ciOpts.includeCodexSpans,})if err != nil {return err@@ -116,38 +150,24 @@ func runCIExec(cmd *cobra.Command, args []string) error {if childErr != nil {return childErr}- result := beaconci.Validate(beaconci.ValidationOptions{- LogPath: session.LogPath,- MinEvents: ciOpts.minEvents,- RequireHarness: ciOpts.harness,- Since: session.StartedAtTime(),- })+ finishResult, finishErr := finishSession(context.Background(), session)execResult := beaconci.ExecResult{Session: *session,ChildExitCode: childExit,- Validation: result,- ArtifactMessage: fmt.Sprintf("Beacon CI artifacts: log=%s config=%s", session.LogPath, session.ConfigPath),+ Validation: finishResult.Validation,+ Uploads: finishResult.Uploads,+ ArtifactMessage: finishResult.ArtifactMessage,}- if (result.Status != "fail" || !ciOpts.requireTelemetry) && len(session.Uploads) > 0 {- uploadCtx, uploadCancel := context.WithTimeout(context.Background(), 2*time.Minute)- uploadResults, uploadErr := session.UploadArtifacts(uploadCtx)- uploadCancel()- execResult.Uploads = uploadResults- if uploadErr != nil {- if ciOpts.jsonOutput {- _ = json.NewEncoder(os.Stdout).Encode(execResult)- }- fmt.Fprintf(os.Stderr, "Beacon CI upload failed: %v\n", uploadErr)- if childExit != 0 {- os.Exit(childExit)- }- return fmt.Errorf("Beacon CI upload failed: %w", uploadErr)+ if finishErr != nil {+ if ciOpts.jsonOutput {+ _ = json.NewEncoder(os.Stdout).Encode(execResult)}- if len(uploadResults) > 0 {- execResult.ArtifactMessage += fmt.Sprintf(" uploads=%s", uploadTargets(uploadResults))+ if childExit != 0 {+ os.Exit(childExit)}+ return finishErr}- if !ciOpts.keepArtifacts && result.Status != "fail" && childExit == 0 && ciOpts.baseDir == "" && ciOpts.logPath == "" {+ if !ciOpts.keepArtifacts && finishResult.Validation.Status != "fail" && childExit == 0 && ciOpts.baseDir == "" && ciOpts.logPath == "" {if err := os.RemoveAll(session.BaseDir); err != nil {fmt.Fprintf(os.Stderr, "Warning: artifact cleanup: %v\n", err)} else {@@ -157,23 +177,117 @@ func runCIExec(cmd *cobra.Command, args []string) error {if ciOpts.jsonOutput {_ = json.NewEncoder(os.Stdout).Encode(execResult)} else {- printCIValidation(result)+ printCIValidation(finishResult.Validation)fmt.Println(execResult.ArtifactMessage)}+ if childExit != 0 {+ os.Exit(childExit)+ }+ return nil+}++func runCIStart(cmd *cobra.Command, args []string) error {+ runCtx, stopSignals := signal.NotifyContext(cmd.Context(), os.Interrupt, syscall.SIGTERM)+ defer stopSignals()+ if !cmd.Flags().Changed("harness") {+ ciOpts.harness = beaconci.DefaultSessionHarness+ }+ session, err := beaconci.Provision(beaconci.Options{+ BaseDir: ciOpts.baseDir,+ LogPath: ciOpts.logPath,+ CollectorPath: ciOpts.collectorPath,+ GRPCPort: ciOpts.grpcPort,+ HTTPPort: ciOpts.httpPort,+ Harness: ciOpts.harness,+ Forward: ciOpts.forward,+ ForwardEndpoint: ciOpts.forwardEndpoint,+ IncludeCodexSpans: ciOpts.includeCodexSpans,+ })+ if err != nil {+ return err+ }+ result, err := session.StartDetached(runCtx, ciOpts.statePath, os.Stdout, os.Stderr)+ if err != nil {+ return err+ }+ if err := writeGitHubEnv(ciOpts.githubEnvPath, result.Exports); err != nil {+ return err+ }+ if ciOpts.jsonOutput {+ return json.NewEncoder(os.Stdout).Encode(result)+ }+ fmt.Println(result.ArtifactMessage)+ for key, value := range result.Exports {+ if strings.HasPrefix(key, "BEACON_CI_") || key == "CODEX_HOME" {+ fmt.Printf("%s=%s\n", key, value)+ }+ }+ return nil+}++func runCIFinish(cmd *cobra.Command, args []string) error {+ session, err := beaconci.LoadState(ciOpts.statePath)+ if err != nil {+ return err+ }+ session.Forward = ciOpts.forward+ session.ForwardEndpoint = ciOpts.forwardEndpoint+ if len(ciOpts.uploads) > 0 {+ uploads, err := beaconci.ResolveUploadDestinationsForSession(ciOpts.uploads, session)+ if err != nil {+ return err+ }+ session.Uploads = uploads+ }+ stopCtx, cancel := context.WithTimeout(context.Background(), 5*time.Second)+ stopErr := session.StopDetached(stopCtx)+ cancel()+ if stopErr != nil {+ fmt.Fprintf(os.Stderr, "Warning: collector stop: %v\n", stopErr)+ }+ result, err := finishSession(context.Background(), session)+ if ciOpts.jsonOutput {+ _ = json.NewEncoder(os.Stdout).Encode(result)+ } else {+ printCIValidation(result.Validation)+ fmt.Println(result.ArtifactMessage)+ }+ return err+}++func finishSession(ctx context.Context, session *beaconci.Session) (beaconci.FinishResult, error) {+ result := beaconci.Validate(beaconci.ValidationOptions{+ LogPath: session.LogPath,+ MinEvents: ciOpts.minEvents,+ RequireHarness: session.Harness,+ Since: session.StartedAtTime(),+ })+ finishResult := beaconci.FinishResult{+ Session: *session,+ Validation: result,+ ArtifactMessage: fmt.Sprintf("Beacon CI artifacts: log=%s config=%s", session.LogPath, session.ConfigPath),+ }+ if (result.Status != "fail" || !ciOpts.requireTelemetry) && len(session.Uploads) > 0 {+ uploadCtx, uploadCancel := context.WithTimeout(ctx, 2*time.Minute)+ uploadResults, uploadErr := session.UploadArtifacts(uploadCtx)+ uploadCancel()+ finishResult.Uploads = uploadResults+ if uploadErr != nil {+ fmt.Fprintf(os.Stderr, "Beacon CI upload failed: %v\n", uploadErr)+ return finishResult, fmt.Errorf("Beacon CI upload failed: %w", uploadErr)+ }+ if len(uploadResults) > 0 {+ finishResult.ArtifactMessage += fmt.Sprintf(" uploads=%s", uploadTargets(uploadResults))+ }+ }if result.Status == "fail" {if ciOpts.requireTelemetry {fmt.Fprintln(os.Stderr, "Beacon CI telemetry validation failed")- if childExit != 0 {- os.Exit(childExit)- }- return fmt.Errorf("Beacon CI telemetry validation failed")+ return finishResult, fmt.Errorf("Beacon CI telemetry validation failed")}fmt.Fprintln(os.Stderr, "Warning: Beacon CI telemetry validation failed (continuing because --require-telemetry=false)")}- if childExit != 0 {- os.Exit(childExit)- }- return nil+ return finishResult, nil}func uploadTargets(results []beaconci.UploadResult) string {@@ -186,6 +300,36 @@ func uploadTargets(results []beaconci.UploadResult) string {return strings.Join(targets, ",")}+func writeGitHubEnv(path string, values map[string]string) error {+ if strings.TrimSpace(path) == "" {+ path = os.Getenv("GITHUB_ENV")+ }+ if strings.TrimSpace(path) == "" || len(values) == 0 {+ return nil+ }+ file, err := os.OpenFile(path, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0600)+ if err != nil {+ return err+ }+ defer file.Close()+ for key, value := range values {+ if strings.TrimSpace(key) == "" {+ continue+ }+ if strings.ContainsAny(value, "\r\n") {+ delimiter := "BEACON_CI_ENV"+ if _, err := fmt.Fprintf(file, "%s<<%s\n%s\n%s\n", key, delimiter, value, delimiter); err != nil {+ return err+ }+ continue+ }+ if _, err := fmt.Fprintf(file, "%s=%s\n", key, value); err != nil {+ return err+ }+ }+ return nil+}+func runCIValidate(cmd *cobra.Command, args []string) error {logPath := ciOpts.logPathif logPath == "" {diff --git a/cli/beacon/internal/ci/harness.go b/cli/beacon/internal/ci/harness.goindex bcb9fafe..637c42ad 100644--- a/cli/beacon/internal/ci/harness.go+++ b/cli/beacon/internal/ci/harness.go@@ -3,11 +3,28 @@ package ciimport ("fmt""net/url"+ "os"+ "path/filepath""strings""github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/schema")+const (+ DefaultHarness = "claude"+ DefaultSessionHarness = "claude,codex"+ HarnessClaude = "claude"+ HarnessClaudeCode = "claude_code"+ HarnessCodex = "codex"+ HarnessCodexCLI = "codex_cli"+)++type HarnessConfig struct {+ Harnesses []string `json:"harnesses"`+ Env map[string]string `json:"env,omitempty"`+ Paths map[string]string `json:"paths,omitempty"`+}+func ClaudeEnv(base []string, endpoint string) []string {env := envMap(base)env["CLAUDE_CODE_ENABLE_TELEMETRY"] = "1"@@ -22,6 +39,97 @@ func ClaudeEnv(base []string, endpoint string) []string {return flattenEnv(env)}+func BuildHarnessConfig(base []string, harnessList, grpcEndpoint, baseDir string, run *schema.RunInfo) (HarnessConfig, error) {+ harnesses, err := NormalizeHarnesses(harnessList, DefaultHarness)+ if err != nil {+ return HarnessConfig{}, err+ }+ baseEnv := envMap(base)+ env := map[string]string{}+ if existing := strings.TrimSpace(baseEnv["OTEL_RESOURCE_ATTRIBUTES"]); existing != "" {+ env["OTEL_RESOURCE_ATTRIBUTES"] = existing+ }+ paths := map[string]string{}+ for _, harness := range harnesses {+ switch harness {+ case HarnessClaude:+ env = envMap(ClaudeEnv(flattenEnv(env), grpcEndpoint))+ case HarnessCodex:+ codexHome := filepath.Join(baseDir, "codex-home")+ if err := writeCodexConfig(codexHome, grpcEndpoint); err != nil {+ return HarnessConfig{}, err+ }+ env["CODEX_HOME"] = codexHome+ paths["codex_home"] = codexHome+ }+ }+ env = envMap(WithCIResourceAttributes(flattenEnv(env), run))+ env["BEACON_CI_BASE_DIR"] = baseDir+ return HarnessConfig{Harnesses: harnesses, Env: env, Paths: paths}, nil+}++func NormalizeHarnesses(value, fallback string) ([]string, error) {+ if strings.TrimSpace(value) == "" {+ value = fallback+ }+ seen := map[string]struct{}{}+ var out []string+ for _, part := range strings.Split(value, ",") {+ normalized, err := NormalizeHarness(part)+ if err != nil {+ return nil, err+ }+ if normalized == "" {+ continue+ }+ if _, ok := seen[normalized]; ok {+ continue+ }+ seen[normalized] = struct{}{}+ out = append(out, normalized)+ }+ if len(out) == 0 {+ return nil, fmt.Errorf("at least one CI harness is required")+ }+ return out, nil+}++func NormalizeHarness(value string) (string, error) {+ switch strings.ToLower(strings.TrimSpace(value)) {+ case "":+ return "", nil+ case HarnessClaude, HarnessClaudeCode:+ return HarnessClaude, nil+ case HarnessCodex, HarnessCodexCLI:+ return HarnessCodex, nil+ default:+ return "", fmt.Errorf("unsupported CI harness %q; supported values are claude and codex", value)+ }+}++func HarnessesString(harnesses []string) string {+ if len(harnesses) == 0 {+ return ""+ }+ return strings.Join(harnesses, ",")+}++func writeCodexConfig(codexHome, endpoint string) error {+ if err := os.MkdirAll(codexHome, 0755); err != nil {+ return err+ }+ body := strings.Join([]string{+ "[otel]",+ "environment = \"ci\"",+ "log_user_prompt = true",+ "",+ "[otel.exporter.\"otlp-grpc\"]",+ fmt.Sprintf("endpoint = %q", endpoint),+ "",+ }, "\n")+ return os.WriteFile(filepath.Join(codexHome, "config.toml"), []byte(body), 0600)+}+func WithCIResourceAttributes(base []string, run *schema.RunInfo) []string {attrs := RunResourceAttributes(run)if attrs == "" {diff --git a/cli/beacon/internal/ci/harness_test.go b/cli/beacon/internal/ci/harness_test.goindex 2c4f6189..f4ff818e 100644--- a/cli/beacon/internal/ci/harness_test.go+++ b/cli/beacon/internal/ci/harness_test.go@@ -1,6 +1,8 @@package ciimport (+ "os"+ "path/filepath""strings""testing")@@ -17,3 +19,42 @@ func TestClaudeEnvIncludesPromptLogging(t *testing.T) {}}}++func TestBuildHarnessConfigWritesCodexHome(t *testing.T) {+ baseDir := t.TempDir()+ cfg, err := BuildHarnessConfig(nil, "codex", "http://127.0.0.1:4317", baseDir, nil)+ if err != nil {+ t.Fatalf("BuildHarnessConfig returned error: %v", err)+ }+ codexHome := filepath.Join(baseDir, "codex-home")+ if got := cfg.Env["CODEX_HOME"]; got != codexHome {+ t.Fatalf("CODEX_HOME = %q, want %q", got, codexHome)+ }+ data, err := os.ReadFile(filepath.Join(codexHome, "config.toml"))+ if err != nil {+ t.Fatalf("read codex config: %v", err)+ }+ text := string(data)+ for _, want := range []string{+ "[otel]",+ "environment = \"ci\"",+ "log_user_prompt = true",+ "[otel.exporter.\"otlp-grpc\"]",+ "endpoint = \"http://127.0.0.1:4317\"",+ } {+ if !strings.Contains(text, want) {+ t.Fatalf("codex config missing %q:\n%s", want, text)+ }+ }+}++func TestNormalizeHarnessesSupportsClaudeAndCodexAliases(t *testing.T) {+ got, err := NormalizeHarnesses("claude_code,codex_cli,claude", DefaultHarness)+ if err != nil {+ t.Fatalf("NormalizeHarnesses returned error: %v", err)+ }+ joined := strings.Join(got, ",")+ if joined != "claude,codex" {+ t.Fatalf("NormalizeHarnesses = %q, want claude,codex", joined)+ }+}diff --git a/cli/beacon/internal/ci/session.go b/cli/beacon/internal/ci/session.goindex 7caaaa25..f501f277 100644--- a/cli/beacon/internal/ci/session.go+++ b/cli/beacon/internal/ci/session.go@@ -2,6 +2,7 @@ package ciimport ("context"+ "encoding/json""errors""fmt""io"@@ -20,7 +21,6 @@ import ()const (- DefaultHarness = "claude"DefaultValidationMin = 1)@@ -33,14 +33,15 @@ var ()type Options struct {- BaseDir string- LogPath string- WorkDir string- CollectorPath string- GRPCPort int- HTTPPort int- Harness string- KeepArtifacts bool+ BaseDir string+ LogPath string+ WorkDir string+ CollectorPath string+ GRPCPort int+ HTTPPort int+ Harness string+ KeepArtifacts bool+ IncludeCodexSpans bool// Forward selects an optional SIEM forwarder ("splunk" or "falcon") for the// ephemeral collector. ForwardEndpoint supplies the destination URL; the// token is read from the environment only.@@ -57,14 +58,19 @@ type Session struct {GRPCEndpoint string `json:"grpc_endpoint"`HTTPEndpoint string `json:"http_endpoint"`Harness string `json:"harness"`+ Harnesses []string `json:"harnesses,omitempty"`WorkDir string `json:"work_dir,omitempty"`StartedAt string `json:"started_at"`+ StatePath string `json:"state_path,omitempty"`+ CollectorPID int `json:"collector_pid,omitempty"`Run *schema.RunInfo `json:"run,omitempty"`// Forward and ForwardEndpoint describe the optional SIEM egress. The token// is never recorded here so it cannot leak into --json output.Forward string `json:"forward,omitempty"`ForwardEndpoint string `json:"forward_endpoint,omitempty"`Uploads []UploadDestination `json:"uploads,omitempty"`+ Env map[string]string `json:"env,omitempty"`+ Paths map[string]string `json:"paths,omitempty"`cfg endpointconfig.ConfigstartedAt time.Time@@ -72,6 +78,20 @@ type Session struct {done chan error}+type StartResult struct {+ Session Session `json:"session"`+ Exports map[string]string `json:"exports,omitempty"`+ StatePath string `json:"state_path,omitempty"`+ ArtifactMessage string `json:"artifact_message,omitempty"`+}++type FinishResult struct {+ Session Session `json:"session"`+ Validation ValidationResult `json:"validation"`+ Uploads []UploadResult `json:"uploads,omitempty"`+ ArtifactMessage string `json:"artifact_message,omitempty"`+}+type ExecResult struct {Session Session `json:"session"`ChildExitCode int `json:"child_exit_code"`@@ -81,7 +101,8 @@ type ExecResult struct {}func Provision(opts Options) (*Session, error) {- if err := validateHarness(opts.Harness); err != nil {+ harnesses, err := NormalizeHarnesses(opts.Harness, DefaultHarness)+ if err != nil {return nil, err}baseDir, err := resolveBaseDir(opts.BaseDir, opts.LogPath)@@ -106,12 +127,13 @@ func Provision(opts Options) (*Session, error) {httpPort = endpointconfig.DefaultHTTPPort}cfg := endpointconfig.Default(true, logPath)- cfg.Harnesses = []string{DefaultHarness}+ cfg.Harnesses = harnessescfg.Collector.BinaryPath = opts.CollectorPathcfg.Collector.ConfigPath = filepath.Join(baseDir, "otelcol.yaml")cfg.Collector.SpoolPath = filepath.Join(baseDir, "spool", "otlp.jsonl")cfg.Collector.GRPCPort = grpcPortcfg.Collector.HTTPPort = httpPort+ cfg.Collector.IncludeCodexSpans = opts.IncludeCodexSpansforward, err := normalizeForward(opts.Forward)if err != nil {return nil, err@@ -152,6 +174,10 @@ func Provision(opts Options) (*Session, error) {if err != nil {return nil, err}+ harnessCfg, err := BuildHarnessConfig(os.Environ(), HarnessesString(harnesses), fmt.Sprintf("http://127.0.0.1:%d", grpcPort), baseDir, run)+ if err != nil {+ return nil, err+ }return &Session{BaseDir: baseDir,LogPath: logPath,@@ -159,13 +185,16 @@ func Provision(opts Options) (*Session, error) {CollectorBinary: binary,GRPCEndpoint: fmt.Sprintf("http://127.0.0.1:%d", grpcPort),HTTPEndpoint: fmt.Sprintf("http://127.0.0.1:%d", httpPort),- Harness: DefaultHarness,+ Harness: HarnessesString(harnesses),+ Harnesses: harnesses,WorkDir: opts.WorkDir,StartedAt: startedAt.Format(time.RFC3339),Run: run,Forward: forward,ForwardEndpoint: forwardEndpoint,Uploads: uploads,+ Env: harnessCfg.Env,+ Paths: harnessCfg.Paths,cfg: cfg,startedAt: startedAt,}, nil@@ -190,6 +219,9 @@ func (s *Session) Start(ctx context.Context, stdout, stderr io.Writer) error {if err := cmd.Start(); err != nil {return err}+ if cmd.Process != nil {+ s.CollectorPID = cmd.Process.Pid+ }s.cmd = cmds.done = make(chan error, 1)go func() {@@ -217,6 +249,28 @@ func (s *Session) Start(ctx context.Context, stdout, stderr io.Writer) error {return nil}+func (s *Session) StartDetached(ctx context.Context, statePath string, stdout, stderr io.Writer) (StartResult, error) {+ if err := s.Start(ctx, stdout, stderr); err != nil {+ return StartResult{}, err+ }+ if statePath == "" {+ statePath = DefaultStatePath()+ }+ s.StatePath = statePath+ if err := s.SaveState(statePath); err != nil {+ cleanupCtx, cancel := context.WithTimeout(context.Background(), 5*time.Second)+ _ = s.Stop(cleanupCtx)+ cancel()+ return StartResult{}, err+ }+ return StartResult{+ Session: *s,+ Exports: s.Exports(),+ StatePath: statePath,+ ArtifactMessage: fmt.Sprintf("Beacon CI session started: log=%s config=%s state=%s", s.LogPath, s.ConfigPath, statePath),+ }, nil+}+func (s *Session) Stop(ctx context.Context) error {if s == nil || s.cmd == nil {return nil@@ -238,17 +292,47 @@ func (s *Session) Stop(ctx context.Context) error {}}+func (s *Session) StopDetached(ctx context.Context) error {+ if s == nil || s.CollectorPID == 0 {+ return nil+ }+ process, err := os.FindProcess(s.CollectorPID)+ if err != nil {+ return err+ }+ if err := terminateProcess(process); err != nil {+ return err+ }+ ticker := time.NewTicker(100 * time.Millisecond)+ defer ticker.Stop()+ for {+ if !processAlive(process) {+ return nil+ }+ select {+ case <-ctx.Done():+ _ = process.Kill()+ return ctx.Err()+ case <-ticker.C:+ }+ }+}+func (s *Session) RunChild(ctx context.Context, args []string, stdout, stderr io.Writer) (int, error) {if len(args) == 0 {return 0, errors.New("child command is required after --")}cmd := childCommandContext(ctx, args[0], args[1:]...)cmd.Dir = s.WorkDir- env := append(WithCIResourceAttributes(ClaudeEnv(os.Environ(), s.GRPCEndpoint), s.Run),- "BEACON_CI_BASE_DIR="+s.BaseDir,- "BEACON_CI_CONFIG_PATH="+s.ConfigPath,- "BEACON_CI_LOG_PATH="+s.LogPath,- )+ childEnv := envMap(os.Environ())+ for key, value := range s.Exports() {+ if key == "OTEL_RESOURCE_ATTRIBUTES" && strings.TrimSpace(childEnv[key]) != "" && strings.TrimSpace(value) != "" {+ childEnv[key] = childEnv[key] + "," + value+ continue+ }+ childEnv[key] = value+ }+ env := flattenEnv(childEnv)// The agent never needs destination credentials; keep them out of the child process.stripKeys := append([]string{}, forwardTokenEnv...)if len(s.Uploads) > 0 {@@ -268,6 +352,71 @@ func (s *Session) RunChild(ctx context.Context, args []string, stdout, stderr ioreturn 0, err}+func (s *Session) Exports() map[string]string {+ out := map[string]string{}+ if s != nil {+ if len(s.Env) == 0 {+ harness := s.Harness+ if strings.TrimSpace(harness) == "" {+ harness = DefaultHarness+ }+ cfg, err := BuildHarnessConfig(nil, harness, s.GRPCEndpoint, s.BaseDir, s.Run)+ if err == nil {+ s.Env = cfg.Env+ s.Paths = cfg.Paths+ }+ }+ for key, value := range s.Env {+ out[key] = value+ }+ out["BEACON_CI_BASE_DIR"] = s.BaseDir+ out["BEACON_CI_CONFIG_PATH"] = s.ConfigPath+ out["BEACON_CI_LOG_PATH"] = s.LogPath+ if s.StatePath != "" {+ out["BEACON_CI_STATE_PATH"] = s.StatePath+ } else {+ out["BEACON_CI_STATE_PATH"] = DefaultStatePath()+ }+ if codexHome := s.Paths["codex_home"]; codexHome != "" {+ out["CODEX_HOME"] = codexHome+ }+ }+ return out+}++func (s *Session) SaveState(path string) error {+ if s == nil {+ return errors.New("ci session is nil")+ }+ if path == "" {+ path = DefaultStatePath()+ }+ if err := os.MkdirAll(filepath.Dir(path), 0755); err != nil {+ return err+ }+ data, err := json.MarshalIndent(s, "", " ")+ if err != nil {+ return err+ }+ return os.WriteFile(path, data, 0600)+}++func LoadState(path string) (*Session, error) {+ if path == "" {+ path = DefaultStatePath()+ }+ data, err := os.ReadFile(path)+ if err != nil {+ return nil, err+ }+ var session Session+ if err := json.Unmarshal(data, &session); err != nil {+ return nil, err+ }+ session.startedAt = session.StartedAtTime()+ return &session, nil+}+func (s *Session) Config() endpointconfig.Config {if s == nil {return endpointconfig.Config{}@@ -286,14 +435,6 @@ func (s *Session) StartedAtTime() time.Time {return startedAt}-func validateHarness(harness string) error {- harness = strings.TrimSpace(harness)- if harness == "" || harness == DefaultHarness || harness == "claude_code" {- return nil- }- return fmt.Errorf("unsupported CI harness %q; only claude is supported", harness)-}-func resolveBaseDir(configured, logPath string) (string, error) {if strings.TrimSpace(configured) != "" {if err := os.MkdirAll(configured, 0755); err != nil {@@ -322,6 +463,13 @@ func resolveBaseDir(configured, logPath string) (string, error) {return filepath.Abs(base)}+func DefaultStatePath() string {+ if runnerTemp := strings.TrimSpace(os.Getenv("RUNNER_TEMP")); runnerTemp != "" {+ return filepath.Join(runnerTemp, "beacon", "session.json")+ }+ return filepath.Join(os.TempDir(), "beacon", "session.json")+}+func DefaultLogPath() string {if runnerTemp := strings.TrimSpace(os.Getenv("RUNNER_TEMP")); runnerTemp != "" {return filepath.Join(runnerTemp, "beacon", "runtime.jsonl")@@ -403,6 +551,17 @@ func terminateProcess(process *os.Process) error {return process.Signal(syscall.SIGTERM)}+func processAlive(process *os.Process) bool {+ if process == nil {+ return false+ }+ if runtime.GOOS == "windows" {+ return true+ }+ err := process.Signal(syscall.Signal(0))+ return err == nil+}+func isExpectedStopError(err error) bool {if err == nil {return truediff --git a/cli/beacon/internal/ci/session_test.go b/cli/beacon/internal/ci/session_test.goindex c32402a6..23092493 100644--- a/cli/beacon/internal/ci/session_test.go+++ b/cli/beacon/internal/ci/session_test.go@@ -67,7 +67,7 @@ func TestProvisionUsesLogPathDirectoryAsBaseDir(t *testing.T) {}func TestProvisionRejectsUnsupportedHarness(t *testing.T) {- if _, err := Provision(Options{Harness: "codex"}); err == nil {+ if _, err := Provision(Options{Harness: "unknown"}); err == nil {t.Fatal("Provision accepted unsupported harness")}}@@ -99,6 +99,56 @@ func TestStartStopCollectorProcess(t *testing.T) {}}+func TestStartDetachedWritesStateAndExports(t *testing.T) {+ if runtime.GOOS == "windows" {+ t.Skip("shell fake uses POSIX signal semantics")+ }+ dir := t.TempDir()+ collector := fakeExecutable(t, "collector", "#!/bin/sh\ntrap 'exit 0' TERM\nwhile true; do sleep 1; done\n")+ oldWait := waitCollectorReady+ waitCollectorReady = func(endpointconfig.Config, time.Duration) error { return nil }+ t.Cleanup(func() { waitCollectorReady = oldWait })++ session := &Session{+ BaseDir: dir,+ LogPath: filepath.Join(dir, "runtime.jsonl"),+ ConfigPath: filepath.Join(dir, "otelcol.yaml"),+ CollectorBinary: collector,+ GRPCEndpoint: "http://127.0.0.1:4317",+ Harness: "claude,codex",+ cfg: endpointconfig.Default(true, filepath.Join(dir, "runtime.jsonl")),+ }+ if err := os.WriteFile(session.ConfigPath, []byte("receivers: {}\n"), 0644); err != nil {+ t.Fatal(err)+ }+ statePath := filepath.Join(dir, "session.json")+ result, err := session.StartDetached(context.Background(), statePath, nil, nil)+ if err != nil {+ t.Fatalf("StartDetached returned error: %v", err)+ }+ t.Cleanup(func() {+ ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)+ defer cancel()+ _ = session.Stop(ctx)+ })+ if result.Exports["BEACON_CI_STATE_PATH"] != statePath {+ t.Fatalf("BEACON_CI_STATE_PATH = %q, want %q", result.Exports["BEACON_CI_STATE_PATH"], statePath)+ }+ if result.Exports["CODEX_HOME"] != filepath.Join(dir, "codex-home") {+ t.Fatalf("CODEX_HOME = %q", result.Exports["CODEX_HOME"])+ }+ loaded, err := LoadState(statePath)+ if err != nil {+ t.Fatalf("LoadState returned error: %v", err)+ }+ if loaded.CollectorPID == 0 || loaded.StatePath != statePath {+ t.Fatalf("loaded state missing pid/path: %+v", loaded)+ }+ if _, err := os.Stat(filepath.Join(dir, "codex-home", "config.toml")); err != nil {+ t.Fatalf("codex config missing: %v", err)+ }+}+func TestRunChildInjectsClaudeEnvAndBeaconPaths(t *testing.T) {dir := t.TempDir()output := filepath.Join(dir, "env.txt")diff --git a/cli/beacon/internal/ci/upload.go b/cli/beacon/internal/ci/upload.goindex 54d0b593..53e9c2b7 100644--- a/cli/beacon/internal/ci/upload.go+++ b/cli/beacon/internal/ci/upload.go@@ -84,6 +84,13 @@ func resolveUploadDestinations(providers []string, run *schema.RunInfo, logPathreturn destinations, nil}+func ResolveUploadDestinationsForSession(providers []string, session *Session) ([]UploadDestination, error) {+ if session == nil {+ return nil, fmt.Errorf("ci session is nil")+ }+ return resolveUploadDestinations(providers, session.Run, session.LogPath, session.StartedAtTime())+}+func normalizeUploads(values []string) ([]string, error) {seen := map[string]struct{}{}var providers []stringdiff --git a/cli/beacon/internal/ci/validate.go b/cli/beacon/internal/ci/validate.goindex 9c92d34a..32267c7d 100644--- a/cli/beacon/internal/ci/validate.go+++ b/cli/beacon/internal/ci/validate.go@@ -69,7 +69,7 @@ func Validate(opts ValidationOptions) ValidationResult {result.EventCount = len(filtered)if result.EventCount < opts.MinEvents {target := opts.LogPath- if opts.RequireHarness != "" {+ if strings.TrimSpace(opts.RequireHarness) != "" {target = opts.RequireHarness}result.Stages = append(result.Stages, ValidationStage{Name: "event_count", Target: target, Status: "fail", Severity: "high", Message: fmt.Sprintf("observed %d events, want at least %d", result.EventCount, opts.MinEvents), Evidence: fmt.Sprintf("events=%d", result.EventCount)})@@ -77,8 +77,8 @@ func Validate(opts ValidationOptions) ValidationResult {return result}result.Stages = append(result.Stages, ValidationStage{Name: "event_count", Target: opts.LogPath, Status: "ok", Severity: "info", Message: fmt.Sprintf("observed %d events", result.EventCount), Evidence: fmt.Sprintf("events=%d", result.EventCount)})- if opts.RequireHarness != "" {- result.Stages = append(result.Stages, ValidationStage{Name: "harness_events", Target: opts.RequireHarness, Status: "ok", Severity: "info", Message: "required harness events observed"})+ if strings.TrimSpace(opts.RequireHarness) != "" {+ result.Stages = append(result.Stages, ValidationStage{Name: "harness_events", Target: opts.RequireHarness, Status: "ok", Severity: "info", Message: harnessValidationMessage(opts.RequireHarness)})}result.Status = aggregateValidationStatus(result.Stages)return result@@ -129,30 +129,52 @@ func readStructuredEvents(path string, since time.Time) ([]schema.Event, []strin}func filterHarness(events []schema.Event, harness string) []schema.Event {- harness = strings.TrimSpace(harness)- if harness == "" {+ required := validationHarnesses(harness)+ if len(required) == 0 {return events}var out []schema.Eventfor _, event := range events {- if harnessMatches(event.Harness.Name, harness) {- out = append(out, event)+ for _, want := range required {+ if harnessMatches(event.Harness.Name, want) {+ out = append(out, event)+ break+ }+ }+ }+ return out+}++func validationHarnesses(harness string) []string {+ var out []string+ for _, part := range strings.Split(harness, ",") {+ trimmed := strings.TrimSpace(part)+ if trimmed != "" {+ out = append(out, trimmed)}}return out}func harnessMatches(got, want string) bool {- switch want {- case "claude":- return got == "claude" || got == "claude_code"- case "claude_code":+ got = strings.TrimSpace(got)+ switch strings.TrimSpace(want) {+ case "claude", "claude_code":return got == "claude" || got == "claude_code"+ case "codex", "codex_cli":+ return got == "codex" || got == "codex_cli"default:return got == want}}+func harnessValidationMessage(harness string) string {+ if len(validationHarnesses(harness)) > 1 {+ return "required harness events observed for at least one configured harness"+ }+ return "required harness events observed"+}+func aggregateValidationStatus(stages []ValidationStage) string {status := "ok"for _, stage := range stages {diff --git a/cli/beacon/internal/ci/validate_test.go b/cli/beacon/internal/ci/validate_test.goindex 8d4299b5..34db0b45 100644--- a/cli/beacon/internal/ci/validate_test.go+++ b/cli/beacon/internal/ci/validate_test.go@@ -54,6 +54,33 @@ func TestValidateFailsWhenHarnessEventMissing(t *testing.T) {}}+func TestValidateMatchesAnyConfiguredHarness(t *testing.T) {+ path := filepath.Join(t.TempDir(), "runtime.jsonl")+ event := NewSessionEvent("ci.test", "test event", nil)+ event.Harness.Name = "codex_cli"+ writeEventLine(t, path, event)++ result := Validate(ValidationOptions{LogPath: path, MinEvents: 1, RequireHarness: "claude,codex"})+ if result.Status != "ok" {+ t.Fatalf("Validate status = %q, stages=%#v", result.Status, result.Stages)+ }+ if result.EventCount != 1 {+ t.Fatalf("EventCount = %d, want 1", result.EventCount)+ }+}++func TestValidateMatchesCodexAlias(t *testing.T) {+ path := filepath.Join(t.TempDir(), "runtime.jsonl")+ event := NewSessionEvent("ci.test", "test event", nil)+ event.Harness.Name = "codex_cli"+ writeEventLine(t, path, event)++ result := Validate(ValidationOptions{LogPath: path, MinEvents: 1, RequireHarness: "codex"})+ if result.Status != "ok" {+ t.Fatalf("Validate status = %q, stages=%#v", result.Status, result.Stages)+ }+}+func TestValidateFiltersEventsBeforeSince(t *testing.T) {path := filepath.Join(t.TempDir(), "runtime.jsonl")event := NewSessionEvent("ci.test", "test event", nil)diff --git a/examples/github-actions/claude-security-review-session.yml b/examples/github-actions/claude-security-review-session.ymlnew file mode 100644index 00000000..3dd0e0cc--- /dev/null+++ b/examples/github-actions/claude-security-review-session.yml@@ -0,0 +1,46 @@+# Reference workflow for wrapping Anthropic's Claude Code Security Review+# action with a Beacon CI telemetry session.++name: Beacon Claude Security Review telemetry++on:+ pull_request:+ workflow_dispatch:++permissions:+ contents: read+ pull-requests: write++jobs:+ security-review:+ runs-on: ubuntu-latest+ steps:+ - uses: actions/checkout@v4+ with:+ ref: ${{ github.event.pull_request.head.sha || github.sha }}+ fetch-depth: 2++ - name: Start Beacon telemetry+ uses: asymptote-labs/agent-beacon@vNEXT+ with:+ mode: start+ version: vNEXT+ harnesses: claude++ - name: Run Claude Code Security Review+ uses: anthropics/claude-code-security-review@main+ with:+ claude-api-key: ${{ secrets.CLAUDE_API_KEY }}+ comment-pr: false+ upload-results: true+ claudecode-timeout: "10"++ - name: Finish Beacon telemetry+ if: always()+ uses: asymptote-labs/agent-beacon@vNEXT+ with:+ mode: finish+ version: vNEXT+ min-events: "1"+ upload-artifact: "true"+ artifact-name: beacon-claude-security-review-runtime-logdiff --git a/examples/github-actions/codex-action-session.yml b/examples/github-actions/codex-action-session.ymlnew file mode 100644index 00000000..9b5393e7--- /dev/null+++ b/examples/github-actions/codex-action-session.yml@@ -0,0 +1,44 @@+# Reference workflow for wrapping OpenAI's customizable Codex Action with a+# Beacon CI telemetry session.++name: Beacon Codex Action telemetry++on:+ pull_request:+ workflow_dispatch:++permissions:+ contents: read++jobs:+ codex-review:+ runs-on: ubuntu-latest+ steps:+ - uses: actions/checkout@v4++ - name: Start Beacon telemetry+ id: beacon+ uses: asymptote-labs/agent-beacon@vNEXT+ with:+ mode: start+ version: vNEXT+ harnesses: codex++ - name: Run Codex Action+ uses: openai/codex-action@main+ with:+ openai-api-key: ${{ secrets.OPENAI_API_KEY }}+ codex-home: ${{ steps.beacon.outputs.codex-home }}+ prompt: "Summarize this pull request and list one potential risk. Do not modify files."+ sandbox: read-only+ safety-strategy: read-only++ - name: Finish Beacon telemetry+ if: always()+ uses: asymptote-labs/agent-beacon@vNEXT+ with:+ mode: finish+ version: vNEXT+ min-events: "1"+ upload-artifact: "true"+ artifact-name: beacon-codex-action-runtime-log