Documentation
¶
Overview ¶
Package fixturecapture records bounded, anonymized terminal output for adapter fixtures. It deliberately has no input, shell-script, environment, provider, or credential API.
Index ¶
- Constants
- Variables
- func HelperMain(arguments []string, diagnostics io.Writer) (handled bool, exitCode int)
- func Marshal(fixture Fixture, anonymizer *Anonymizer) ([]byte, error)
- func Validate(fixture Fixture, anonymizer *Anonymizer) error
- func WriteFile(path string, fixture Fixture, anonymizer *Anonymizer) error
- type Anonymizer
- type Backend
- type Chunk
- type Fixture
- type Options
- type Outcome
Constants ¶
const ( // SchemaVersion is incremented when the persisted JSON contract changes. SchemaVersion = 1 DefaultMaxBytes = 256 * 1024 HardMaxBytes = 4 * 1024 * 1024 DefaultTimeout = 20 * time.Second MaximumTimeout = 5 * time.Minute )
Variables ¶
var ( ErrSensitiveContent = errors.New("fixture contains sensitive content") ErrUnsupported = errors.New("fixture capture is unsupported on this platform") )
Functions ¶
func HelperMain ¶
HelperMain handles only the private tmux launch protocol. Public commands must call it before flag parsing. Diagnostics intentionally contain no argv, paths, environment values, or captured output.
func Marshal ¶
func Marshal(fixture Fixture, anonymizer *Anonymizer) ([]byte, error)
Marshal validates and serializes one fixture with a trailing newline. The returned slice never aliases fixture storage.
func Validate ¶
func Validate(fixture Fixture, anonymizer *Anonymizer) error
Validate checks the schema, all memory bounds, and that the persisted chunk stream is already in canonical anonymized form.
Types ¶
type Anonymizer ¶
type Anonymizer struct {
// contains filtered or unexported fields
}
Anonymizer centralizes the only transformation permitted before fixture persistence. Credential-shaped content is rejected; identity-bearing email addresses and home-directory prefixes are replaced with stable markers.
func NewAnonymizer ¶
func NewAnonymizer(homePaths []string) (*Anonymizer, error)
NewAnonymizer defensively copies explicit home-directory prefixes. It is exported so tests and offline fixture validators do not depend on host data.
func NewDefaultAnonymizer ¶
func NewDefaultAnonymizer() (*Anonymizer, error)
NewDefaultAnonymizer includes the current user's home path without exposing it in the resulting value or artifact.
func (*Anonymizer) Anonymize ¶
func (anonymizer *Anonymizer) Anonymize(input []byte) ([]byte, error)
Anonymize returns independent storage safe for a fixture, or fails closed when a token, JWT, authorization value, API key, URL credential, or another credential-shaped value is observed. It never returns partially sanitized bytes together with an error.
type Backend ¶
type Backend string
Backend identifies the local terminal transport used for the observation.
type Fixture ¶
type Fixture struct {
SchemaVersion int `json:"schema_version"`
Tool string `json:"tool"`
Adapter string `json:"adapter"`
Backend Backend `json:"backend"`
Outcome Outcome `json:"outcome"`
ExitCode *int `json:"exit_code,omitempty"`
Truncated bool `json:"truncated,omitempty"`
Chunks []Chunk `json:"chunks"`
}
Fixture is the complete versioned on-disk contract. It intentionally omits argv, cwd, environment variables, raw input, timestamps, and user identity.
func Capture ¶
Capture starts exactly one output-only CLI in a PTY or an isolated private tmux server. It never forwards caller input and never accepts or records an environment map. Timeout and output-limit outcomes still return a fixture.
type Options ¶
type Options struct {
Tool string
Adapter string
Backend Backend
Command []string
Cwd string
TmuxPath string
HelperPath string
Timeout time.Duration
MaxBytes int
Anonymizer *Anonymizer
}
Options configures an output-only PTY capture. Command is exact argv and the harness never wraps it in an implicit shell. A caller can still explicitly choose a shell executable, so argv remains security-sensitive. There is intentionally no environment or stdin field. The child receives a small internal allowlist of non-secret process environment variables plus disposable private HOME, TMPDIR, and XDG roots; it never inherits the caller's configuration directories.