Documentation
¶
Overview ¶
Package callercontext names the AI harness (and its session) a DataTug command runs under, from the harness's own environment, so local records such as policy exception proposals and their audit events can say who proposed or used what.
It is self-reported: any process can set these variables. It never grants authority and is never sent to telemetry. Besides attribution it may only make a read stricter: a detected agent is refused, rather than warned about, columns that read-time suggestions mark sensitive. Hiding the harness drops a caller to the owner's baseline, never above it.
Index ¶
Constants ¶
const ( HarnessEnv = "DATATUG_CALLER_HARNESS" SessionEnv = "DATATUG_CALLER_SESSION" // AIAgentEnv is the generic agent marker some harnesses set: // <name>[_<version with dashes>[_agent]] (Claude Code sets // claude-code_2-1-317_agent; OpenCode sets opencode). AIAgentEnv = "AI_AGENT" )
Explicit overrides any harness, or the person, may set; they take precedence over everything detected.
const ( SourceOverride = "override" SourceHarnessEnv = "harness-env" SourceAIAgent = "ai-agent" )
Sources of a detected caller.
Variables ¶
var Harnesses = []Harness{ {Name: "claude-code", Marker: "CLAUDECODE", MarkerValue: "1", SessionVars: []string{"CLAUDE_CODE_SESSION_ID"}, AIAgentVersion: true}, {Name: "codex", Marker: "CODEX_THREAD_ID", SessionVars: []string{"CODEX_SESSION_ID", "CODEX_THREAD_ID"}, VersionVar: "CODEX_VERSION"}, {Name: "opencode", Marker: "OPENCODE", MarkerValue: "1", SessionVars: []string{"OPENCODE_SESSION_ID"}}, {Name: "deepseek-harness", Marker: "DSH_SHELL", MarkerValue: "1", SessionVars: []string{"DSH_SESSION_ID"}}, }
Harnesses are the known harnesses. They are mutually exclusive: when several markers are set (nested harnesses) the one with a session wins, and a tie goes to the harness AI_AGENT names, else the first listed.
Functions ¶
This section is empty.
Types ¶
type Caller ¶
type Caller struct {
Harness string `json:"harness,omitempty"`
HarnessVersion string `json:"harnessVersion,omitempty"`
Session string `json:"session,omitempty"`
// Source says where the first known field came from: override,
// harness-env or ai-agent.
Source string `json:"source,omitempty"`
}
Caller is who a command says it runs for. Empty fields are unknown.
func Detect ¶
Detect reads the caller from the environment lookup gives: the explicit DATATUG_CALLER_* overrides first, then the known harness whose marker is set (see Harnesses for nested ones), then a generic AI_AGENT value; each field falls back separately. A value that does not match its conservative pattern (at most 128 characters) is dropped.
type Harness ¶
type Harness struct {
Name string
// Marker marks a process the harness runs: set to MarkerValue, or to any
// non-empty value when MarkerValue is "".
Marker, MarkerValue string
// SessionVars hold the session id, first non-empty wins.
SessionVars []string
// VersionVar holds the version as is; AIAgentVersion reads it from
// AI_AGENT instead.
VersionVar string
AIAgentVersion bool
}
Harness is one harness the detector knows, read from its own environment.