coderunner

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 13, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package coderunner executes model-authored analysis inside the sandbox (§12.1).

For the analyses SQL cannot express — regression, seasonality, anything needing row-level access. The boundary moves rather than opening: inside the container there is no model to protect the data from, so the script may read every row, and only a declared, numeric output envelope crosses back.

What constrains this is the container and the output contract, not the aggregation gate. A name the plan did not declare does not cross, and an undeclared key is counted rather than repeated — a key is text the script chose, and repeating it would make the key itself a channel.

The verdict on a statistical result is derived here, never taken from the script: a model reporting its own significance is a model grading its own work.

Index

Constants

View Source
const DefaultImage = "python:3.13-slim"

DefaultImage is the interpreter.

Pinned to a tag rather than a digest, because a tag is what a user will have pulled and a digest they do not have is an error message instead of a feature. `doctor` reports whether it is present.

View Source
const MountPath = "/data/connector.sqlite"

MountPath is where the connector's database appears inside the container.

Variables

View Source
var ErrUnavailable = errors.New("coderunner: unavailable")

ErrUnavailable means no usable runtime, which is a normal state and not a failure: §12.2 says the sandbox is not the control for the SQL path, so local analysis works without this entirely.

Functions

func DefaultCommand

func DefaultCommand() []string

DefaultCommand reads the script from stdin.

A function, not a package-level slice: a mutable global holding the command that launches model-authored code is the wrong shape, and the repo's own precedent (academic.Kinds) returns a fresh copy.

Types

type Contract

type Contract struct {
	// Metrics are named scalars.
	Metrics []string `json:"metrics,omitempty"`
	// Tests are named statistical results.
	Tests []string `json:"tests,omitempty"`
}

Contract is what a plan declared it would emit, established before the script runs. Nothing outside it comes back.

func (Contract) Empty

func (c Contract) Empty() bool

Empty reports whether the contract permits nothing, in which case running the script could only waste a container.

type Finding

type Finding struct {
	Name       string        `json:"name"`
	N          int64         `json:"n"`
	Statistic  float64       `json:"statistic"`
	P          float64       `json:"p"`
	EffectSize float64       `json:"effect_size"`
	Verdict    stats.Verdict `json:"verdict"`
}

Finding is one statistical result the script computed.

The script supplies the numbers; the VERDICT is derived here, using the same thresholds as the SQL path. A script reporting its own verdict would be a model deciding whether its own result was significant.

func (Finding) Summary

func (f Finding) Summary() string

Summary is the sentence a claim has to quote.

Built by stats.Sentence, so the two evidence paths cannot word the same verdict differently — they did, in the underpowered clause and in whether an effect size appeared at all, under a comment claiming a reader could not tell them apart.

type Output

type Output struct {
	Metrics  map[string]float64 `json:"metrics,omitempty"`
	Findings []Finding          `json:"findings,omitempty"`

	// Dropped names refused outputs the plan DID declare — mole's own strings,
	// safe to repeat, and the case a model needs to see to fix its script.
	Dropped []string `json:"dropped,omitempty"`
	// Undeclared counts refused outputs the plan did not declare. A count and
	// not a list: an undeclared key is text the script chose, and repeating it
	// would make the key a channel out of the sandbox.
	Undeclared int      `json:"undeclared,omitempty"`
	Notes      []string `json:"notes,omitempty"`
}

Output is what came back and is allowed to cross.

func Parse

func Parse(raw string, c Contract) (Output, error)

Parse filters a script's stdout down to what the contract declared.

func (Output) Empty

func (o Output) Empty() bool

Empty reports whether anything crossed.

func (Output) Text

func (o Output) Text(script string) string

Text renders the output as the passage a claim is mined from and quoted against, exactly as an AggregateEnvelope does — so §11.5 applies to a claim about a regression the same way it applies to one about a web page.

type Request

type Request struct {
	// DBPath is the connector database, mounted read-only.
	DBPath string
	// Query is the statement the script is told to run. Already through
	// sqlguard: the script could run anything against the mounted database, so
	// this is guidance rather than a control — the container is the control.
	Query    string
	Script   string
	Contract Contract
}

Request is one analysis.

type Runner

type Runner interface {
	Analyze(ctx context.Context, req Request) (Output, error)
}

Runner executes an analysis. Separate from the parsing so a caller can be tested without a container.

type Sandboxed

type Sandboxed struct {
	Report sandbox.Report
	Image  string
	// Command defaults to DefaultCommand.
	Command []string
	Limits  sandbox.Limits
}

Sandboxed is the real Runner.

func (Sandboxed) Analyze

func (s Sandboxed) Analyze(ctx context.Context, req Request) (Output, error)

Analyze runs the script and returns only what the contract declared.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL