a06f331eb8
CI / benchmark (push) Has been skipped
install-script / posix-syntax (push) Successful in 6m1s
CI / build-onnx (push) Failing after 6m43s
init-smoke / dry-run (push) Failing after 15m57s
security / govulncheck (push) Has been cancelled
security / trivy-fs (push) Has been cancelled
CI / test (1.26, ubuntu-latest) (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
CI / test (1.26, macos-latest) (push) Has been cancelled
CI / build-windows (push) Has been cancelled
CI / lint (push) Has been cancelled
install-script / powershell-syntax (push) Has been cancelled
install-script / install (macos-14) (push) Has been cancelled
install-script / install (ubuntu-latest) (push) Has been cancelled
32 lines
1.0 KiB
Go
32 lines
1.0 KiB
Go
package daemon
|
|
|
|
import "context"
|
|
|
|
// auditInfo carries the request-scoped fields the federation fan-out adds
|
|
// to its audit lines so a federated remote call records the same
|
|
// {session_id, cwd, tool, target_slug} tuple as the single-remote proxy
|
|
// route. It rides the context because the Federator's Augment/fanOut take
|
|
// the request ctx but not the router's RouteContext.
|
|
type auditInfo struct {
|
|
Cwd string
|
|
SessionID string
|
|
}
|
|
|
|
type auditInfoKey struct{}
|
|
|
|
// withAuditInfo attaches the caller's cwd + session id to ctx for the
|
|
// fan-out audit. A no-op when both are empty (control/HTTP paths).
|
|
func withAuditInfo(ctx context.Context, cwd, sessionID string) context.Context {
|
|
if cwd == "" && sessionID == "" {
|
|
return ctx
|
|
}
|
|
return context.WithValue(ctx, auditInfoKey{}, auditInfo{Cwd: cwd, SessionID: sessionID})
|
|
}
|
|
|
|
// auditInfoFrom returns the audit fields carried on ctx, or the zero
|
|
// value when none were attached.
|
|
func auditInfoFrom(ctx context.Context) auditInfo {
|
|
v, _ := ctx.Value(auditInfoKey{}).(auditInfo)
|
|
return v
|
|
}
|