Documentation
¶
Overview ¶
Package capability runs the interaction-capability study: how far an agent gets from a sparse, time-aligned representation of a conversation, and which behaviours need richer acoustic evidence or tighter language/speech coupling.
The unit of evidence here is the matched pair, not the run. Two branches of a pair share one prefix - structurally the same slice of events, not two copies that happen to agree - and diverge only at an authored piece of feedback. A difference in what the agent says after that point is therefore attributable to the feedback rather than to sampling, because the negative control is the same branch with the feedback removed.
Everything in this package is causal by construction. An event carries the time it was said and, separately, the time a policy is allowed to see it; nothing that has not yet happened can be admitted, and no scorer may consult a transcript the policy never received. See docs/interaction-capability-study.md for the design and docs/experiments/interaction-capability-v1.yaml for the frozen cells.
Index ¶
- Constants
- Variables
- func ValidatePairs(pairs []Pair) error
- type Action
- type Admission
- type Availability
- type Cell
- type Channels
- type ContentScreen
- type Decision
- type Delays
- type Event
- type Expectation
- type Family
- type Heard
- type JointPolicy
- type Kind
- type Listener
- type Mark
- type Observation
- type Pair
- type Planning
- type Playback
- func (p *Playback) Add(id, text string, generatedAt time.Duration, sampleRate int) error
- func (p *Playback) Cancel(id string)
- func (p *Playback) End(id string) error
- func (p *Playback) FinishPlayback(id string, at time.Duration) error
- func (p *Playback) Generated(id string, samples int64) error
- func (p *Playback) Mark(id string, played int64, at time.Duration) error
- func (p *Playback) Self() Self
- type Schedule
- type Segment
- type Self
- type Source
- type Split
- type Variant
Constants ¶
const JointPrompt = `` /* 2131-byte string literal not displayed */
JointPrompt is the prompted debugging policy's system text. A released trained checkpoint uses its own grammar instead.
const SpeakerUser = "user"
SpeakerUser is the participant the agent is talking to. Other speakers exist so the addressing family can put speech in the room that is not addressed to the agent; they reach the agent down the same microphone.
const Tick = 500 * time.Millisecond
Tick is the study's clock. 500 ms first, as the existing micro-turn profiles use; the 200/500/1000 ms sweep is a diagnostic to run after the principal contrast works, not a way to find a setting that makes one cell look good.
Variables ¶
var Acts = []string{"wait", "speak", "continue", "backchannel", "yield", "revise"}
Acts are the joint policy's action vocabulary.
var DefaultDelays = Delays{SoundOnset: 20 * time.Millisecond, SoundOffset: 200 * time.Millisecond}
DefaultDelays matches the detector the existing micro-turn sidecar runs, so an annotated diagnostic is not accidentally more responsive than anything that could be built.
var Families = []Family{ FamilySemanticCorrection, FamilySteering, FamilyProsodic, FamilySilence, FamilyAddressing, FamilyProactive, FamilyConcurrent, FamilyRevision, }
Families is every family in the preregistered order used by reports.
Functions ¶
func ValidatePairs ¶
ValidatePairs checks a whole suite, including that pair IDs are unique.
Types ¶
type Action ¶
type Action struct {
Act string `json:"act"`
Text string `json:"text"`
ReplacesPending string `json:"replaces_pending"`
}
Action is one bounded joint decision: what to do and the next words to say.
type Admission ¶
type Admission struct {
At time.Duration `json:"at"`
Mark Mark `json:"mark"`
EventID string `json:"event_id"`
Kind Kind `json:"kind"`
Speaker string `json:"speaker"`
Text string `json:"text,omitempty"`
Cue string `json:"cue,omitempty"`
SourceStart time.Duration `json:"source_start"`
SourceEnd time.Duration `json:"source_end"`
Provisional bool `json:"provisional,omitempty"`
Replaces string `json:"replaces,omitempty"`
// Withheld names the channel this cell did not declare, and is empty
// when the evidence was admitted.
Withheld string `json:"withheld,omitempty"`
// InjectedDelay is how much later than the annotation this was released,
// for the evidence-delay sweep.
InjectedDelay time.Duration `json:"injected_delay,omitempty"`
}
Admission is one moment at which evidence became visible to a policy, or the record that it was withheld from this cell.
It is the row written to admitted-evidence.jsonl. Keeping the withheld rows is what lets two cells be compared: A2 and A3 run the same schedule, and the trace shows the cue rows admitted in one and withheld in the other rather than two schedules that might have differed for some other reason.
type Availability ¶
type Availability string
Availability keeps a desired cell in the matrix when its resource is missing, so the study does not silently shrink to whatever happened to run.
const ( AvailabilityRunnable Availability = "runnable" )
type Cell ¶
type Cell struct {
ID string `json:"id"`
Study string `json:"study"`
// Purpose is what this cell is for, in the study's own terms. It is
// stored with the results because a cell's meaning is the contrast it
// takes part in, not its name.
Purpose string `json:"purpose"`
// Contrast names the cell this one is read against and the single factor
// that differs. A cell that changes two things at once has to say so.
Contrast string `json:"contrast,omitempty"`
Schedule Schedule `json:"schedule"`
Channels Channels `json:"channels"`
Planning Planning `json:"planning"`
TickInterval time.Duration `json:"tick_interval"`
// Joint says the policy chooses an action and its next content in one
// decision. The alternative is the existing arrangement: an enumerated
// control question, then a separate answer stream that new evidence can
// only stop, never change.
Joint bool `json:"joint"`
// Deliberation adds thinking-enabled decisions. "background" keeps the
// per-tick fast policy and runs a thinking request from the snapshot at
// new user words, admitting its result as a proposal at a later tick if
// no newer user words arrived meanwhile. "synchronous" makes every tick's
// decision a blocking thinking request. Empty means neither.
Deliberation string `json:"deliberation,omitempty"`
Availability Availability `json:"availability"`
Unavailable string `json:"unavailable,omitempty"`
}
Cell is one experimental condition: a declared schedule, a declared set of input channels, and a declared planning mode. Nothing about a run may differ from what the cell declares, and the run records the declaration beside its results so a comparison can be checked rather than trusted.
func Cells ¶
func Cells() []Cell
Cells is the frozen catalogue. IDs are stable: a result file names one of these and means exactly what is written here.
func (Cell) Render ¶
func (cell Cell) Render(observation Observation, self Self) string
Render is the exact text handed to the policy at one tick.
It is built only from channels the cell declared. A quantity the cell may not see is not shown in a vaguer form; it is absent, and the closing line says which channels were silent so the model is not left to guess whether a gap was silence or deafness.
type Channels ¶
type Channels struct {
// Timing shows the model when each word was said and how long the gaps
// were. Removing it is the narrow ablation of temporal evidence: the
// words and the task are unchanged, only their arrangement in time.
Timing bool `json:"timing"`
// Sound admits acoustic activity - that somebody is making sound now,
// before any word has been decoded.
Sound bool `json:"sound"`
// Cues admits acoustic annotations: intonation, hesitancy, emphasis.
Cues bool `json:"cues"`
// Speakers admits who said what. It is acoustic evidence, not textual:
// one microphone in a room produces one stream of words, and telling the
// person being helped from somebody else talking nearby is done on
// voice, direction and distance. A cell without it hears the room as one
// speaker, which is what a single-channel cascade actually has.
Speakers bool `json:"speakers"`
// Provisional admits recogniser hypotheses before they are committed. A
// cell without it waits for commitment and pays the wait.
Provisional bool `json:"provisional"`
}
Channels is what a cell is allowed to perceive. It is declared per cell and enforced here, so a text-only condition cannot quietly decide on acoustic evidence: an undeclared channel is not filtered out at the prompt, it is never admitted, and the trace records that it was withheld.
type ContentScreen ¶
type ContentScreen struct {
Passed bool `json:"passed"`
Text string `json:"text"`
MissingGroups [][]string `json:"missing_groups,omitempty"`
Forbidden []string `json:"forbidden,omitempty"`
TooShort bool `json:"too_short"`
InvalidPlaybackEvidence bool `json:"invalid_playback_evidence"`
SpeechInSilentWindow bool `json:"speech_in_silent_window"`
EstimatedFromSynthesisText bool `json:"estimated_from_synthesis_text"`
}
ContentScreen is a conservative lexical diagnostic, not semantic or human validation. Only entirely played segments inside the window contribute text. Withheld-feedback controls are scored by the same rule, never forced to fail.
func ScreenContent ¶
func ScreenContent(expect Expectation, opens time.Duration, playback Playback) ContentScreen
ScreenContent scores the window that opens when the expectation's anchor is admitted. Speech generated before the window opened is not an adaptation to the evidence and does not count.
type Decision ¶
type Decision struct {
StartedAt time.Time `json:"started_at"`
Duration time.Duration `json:"duration_ns"`
Request json.RawMessage `json:"request"`
Response json.RawMessage `json:"response,omitempty"`
Action Action `json:"action"`
Error string `json:"error,omitempty"`
}
Decision retains the exact request and response alongside the action.
type Delays ¶
type Delays struct {
// Words delays decoded text, the recogniser's trail.
Words time.Duration `json:"words"`
// Cues delays acoustic annotations.
Cues time.Duration `json:"cues"`
// SoundOnset is how long a detector takes to call a sound started.
SoundOnset time.Duration `json:"sound_onset"`
// SoundOffset is the hangover before a detector calls it stopped. It is
// declared rather than assumed: a policy that treats the hangover as
// silence is waiting longer than the annotation says.
SoundOffset time.Duration `json:"sound_offset"`
}
Delays is the injected availability delay, by kind. It is a struct rather than one number because the kinds are not delayed by the same thing: words wait for a recogniser, cues for an annotator, and acoustic activity for a detector that needs only a frame or two.
type Event ¶
type Event struct {
ID string `json:"id"`
// Group ties the events of one authored phrase together - its words, the
// sound they made, and any cue annotating them. The negative control
// removes a group, because removing a single word of "I know that part"
// would leave a different sentence rather than no feedback.
Group string `json:"group"`
Kind Kind `json:"kind"`
Speaker string `json:"speaker,omitempty"`
Text string `json:"text,omitempty"`
Cue string `json:"cue,omitempty"`
SourceStart time.Duration `json:"source_start"`
SourceEnd time.Duration `json:"source_end"`
AvailableAt time.Duration `json:"available_at"`
// Provisional marks a hypothesis a recogniser may still revise. A cell
// that waits for commitment pays for the wait; one that acts on
// provisional text risks acting on words that were never said.
Provisional bool `json:"provisional,omitempty"`
// Replaces names the earlier event this supersedes, for a revision, or
// the event a KindCommit finalises.
Replaces string `json:"replaces,omitempty"`
}
Event is one piece of evidence with two distinct times.
SourceStart/SourceEnd are when the sound happened. AvailableAt is when a policy may first see it, which is strictly later: recognition trails speech, and an annotation of a whole utterance is not available while it is still being said. Keeping both is what makes a delay sweep a manipulation of one variable rather than a rewrite of the conversation.
type Expectation ¶
type Expectation struct {
// After names the event whose availability opens the window. Content the
// agent had already committed to before that moment cannot be credited.
After string `json:"after"`
// Within bounds how long the adapted content may take to become audible.
Within time.Duration `json:"within"`
// RequireAnyOf is a conjunction of disjunctions: every group must be
// satisfied by at least one of its terms. Groups carry synonyms so the
// scorer does not reward one particular wording.
RequireAnyOf [][]string `json:"require_any_of"`
// Forbid is content that shows the agent did not adapt: continuing with
// the superseded topic, or answering the question it was asked to skip.
Forbid []string `json:"forbid"`
// MinWords is how much the agent must actually say in the window. It
// exists because stopping the old answer and acknowledging the user is
// not fulfilling the changed request: "Kyoto, got it." contains every
// required term and completes nothing.
MinWords int `json:"min_words"`
// Silent instead requires that nothing be audible in the window - the
// branch where the right move is to keep waiting. It is only ever half
// of a pair: the other branch requires speech, so a system that never
// speaks fails the pair rather than scoring half of it.
Silent bool `json:"silent,omitempty"`
}
Expectation is the preregistered scoring policy for one branch.
It is stated in terms of an event and a bound rather than a wall-clock instant because how long the shared prefix takes to say is decided by a synthesiser, and a window pinned to a millisecond would pass or fail on the length of a vowel.
type Family ¶
type Family string
Family is one of the eight task families the study scores separately. Per-family reporting is required: an average over families hides that a system which never intervenes scores well on half of them.
const ( FamilySemanticCorrection Family = "semantic-correction" FamilySteering Family = "mid-explanation-steering" FamilyProsodic Family = "prosodic-acknowledgement" FamilySilence Family = "silence-and-hesitation" FamilyAddressing Family = "addressing-and-overlap" FamilyProactive Family = "proactive-semantic-action" FamilyConcurrent Family = "concurrent-task" FamilyRevision Family = "output-revision" )
type Heard ¶
type Heard struct {
EventID string
Speaker string
Text string
SourceStart time.Duration
SourceEnd time.Duration
AdmittedAt time.Duration
Provisional bool
}
Heard is one piece of evidence as the policy sees it.
type JointPolicy ¶
type JointPolicy struct {
URL string
Model string
MaxTokens int
Seed int
// Prompt overrides JointPrompt for an explicitly declared treatment.
Prompt string
// Thinking enables the model's reasoning. Decoding is then unconstrained,
// and the action is the last JSON action object after any reasoning text.
Thinking bool
Client *http.Client
}
JointPolicy asks an OpenAI-compatible chat endpoint for one joint action.
type Kind ¶
type Kind string
Kind is what a piece of annotated evidence is.
The kinds are separate because a policy's declared input channels are enforced by admitting some kinds and not others. A text-only cell that could still see KindSound would be deciding on acoustic evidence while reporting that it had none.
const ( // KindWord is one recognised or annotated word of speech. KindWord Kind = "word" // KindSound is acoustic activity without decoded words: evidence that // somebody is making sound now, which a trailing recogniser cannot give. KindSound Kind = "sound" // KindCue is an acoustic annotation - rising intonation, hesitancy, // emphasis. Only cells that declare acoustic evidence admit it. KindCue Kind = "cue" // KindCommit marks an earlier provisional event final without changing // its text, so the cost of waiting for commitment stays visible. KindCommit Kind = "commit" )
type Listener ¶
type Listener struct {
// contains filtered or unexported fields
}
Listener accumulates admissions into the observation a policy is shown.
func NewListener ¶
NewListener starts an empty observation for one cell.
type Mark ¶
type Mark string
Mark says what an admission revealed. Sound is split into onset and offset because admitting one event at its start would hand the policy the moment the sound was going to stop, which it cannot know while it is still going.
type Observation ¶
type Observation struct {
Now time.Duration
// Words is the transcript as the policy may see it, with revisions
// applied and superseded hypotheses dropped.
Words []Heard
// Sounding is how long the current run of sound has been going, or zero
// when the user is not audibly speaking. Only meaningful with the sound
// channel.
Sounding time.Duration
// Quiet is how long it has been since sound stopped. It is negative when
// nothing has been heard yet, which is not the same as silence observed.
Quiet time.Duration
// Cues are the acoustic annotations admitted so far.
Cues []Heard
// FreshSince lists what arrived since the previous tick, so "no new
// transcript" is a statement the encoder can make rather than an absence
// the model has to infer.
FreshSince []Admission
// Channels is what this cell declared, carried along so a rendered input
// can say which silences were observed and which were never listened for.
Channels Channels
// SoundObserved is whether any acoustic activity has ever been admitted.
SoundObserved bool
}
Observation is the evidence state at one tick: everything admitted so far, arranged the way the cell's declared channels allow it to be seen.
It distinguishes the four situations the study requires to stay apart: observed silence, sound without decoded words, no new transcript since the last tick, and a channel this cell never had.
func (Observation) Said ¶
func (observation Observation) Said(speaker string) string
Said is the visible transcript of one speaker, in the order it was said.
func (Observation) Speakers ¶
func (observation Observation) Speakers() []string
Speakers is every speaker whose words have been admitted, user first.
func (Observation) String ¶
func (observation Observation) String() string
String renders an observation for a log line. The model-visible rendering lives with the cell, which decides how much of this it is allowed to show.
type Pair ¶
type Pair struct {
ID string `json:"id"`
Family Family `json:"family"`
Split Split `json:"split"`
// Instructions is the session prompt, identical across branches and
// cells: a treatment must not smuggle in a different task.
Instructions string `json:"instructions"`
Prefix []Event `json:"prefix"`
Variants []Variant `json:"variants"`
}
Pair is one matched counterfactual.
Prefix is one slice, shared by both branches rather than duplicated, so "the branches share an identical prefix" is a property of the type instead of a check that could pass while the two drifted apart.
func (Pair) Branch ¶
Branch is the full event stream of one variant: the shared prefix followed by that branch's own events.
func (Pair) PrefixEnd ¶
PrefixEnd is when the shared audio stops. A branch may not place speech before it.
It is measured in source time, not availability time: the prefix's last word may still be arriving from a recogniser while a branch's first word is being said, and that is ordinary. What matters is that both branches receive the identical prefix admissions, which they do because the prefix is one slice rather than two copies.
func (Pair) Validate ¶
Validate reports every way a pair violates the study's causal contract. It returns all of them at once: a fixture with four mistakes should be fixed once, not four times.
func (Pair) WithoutFeedback ¶
WithoutFeedback is the negative control: the same branch with the authored feedback removed and nothing else changed. A run of it must not satisfy the branch's expectation - if it does, the expectation is measuring something other than the feedback.
type Planning ¶
type Planning string
Planning is how much of the answer is decided before any of it is spoken, and whether what remains unspoken may still change. It is Study B's factor and is held fixed across Study A.
const ( // PlanningFixed writes the whole answer once and speaks it unchanged. PlanningFixed Planning = "fixed-full" // PlanningRevisable writes the whole answer but may rewrite whatever has // not yet been spoken. A long tentative plan need not be a long // irrevocable utterance, and this cell is what shows the difference. PlanningRevisable Planning = "revisable-full" // PlanningIncremental formulates only the next bounded continuation and // reconsiders after every admitted observation. PlanningIncremental Planning = "incremental" )
type Playback ¶
type Playback struct {
Segments []Segment `json:"segments"`
}
Playback is the ledger of every segment in one trial. It is not safe for concurrent use; the caller serialises access.
func (*Playback) Cancel ¶
Cancel cuts a segment that has not completed. Unknown or completed segments are left unchanged: what was heard in full stays heard.
func (*Playback) FinishPlayback ¶
FinishPlayback completes a segment whose generated audio all played.
type Schedule ¶
type Schedule string
Schedule is how often the policy gets to act, which is a separate treatment from what it gets to see. The two current micro-turn profiles change both at once; the study cells change one at a time.
const ( // ScheduleWholeTurn asks the policy once, after the user's turn has // ended: conventional endpoint-triggered answering. ScheduleWholeTurn Schedule = "whole-turn" // ScheduleMicroTurn asks on a fixed clock whether or not anything was // said, so silence is an input rather than the absence of one. ScheduleMicroTurn Schedule = "micro-turn" )
type Segment ¶
type Segment struct {
ID string `json:"id"`
Text string `json:"text"`
GeneratedAt time.Duration `json:"generated_at"`
SampleRate int `json:"sample_rate"`
GeneratedSamples int64 `json:"generated_samples"`
PlayedSamples int64 `json:"played_samples"`
Ended bool `json:"ended"`
Cut bool `json:"cut"`
FirstPlayedAt *time.Duration `json:"first_played_at,omitempty"`
LastPlayedAt *time.Duration `json:"last_played_at,omitempty"`
CompletedAt *time.Duration `json:"completed_at,omitempty"`
}
Segment is one piece of assistant speech from request to playback. Generated text is not heard text: only samples acknowledged by the playback sink count as played, and only a segment whose every generated sample played is heard in full. Exact heard words of a partially played segment are unknown.
type Self ¶
type Self struct {
Speaking bool
// Began is when the current run of speech started playing.
Began time.Duration
// Heard is what has audibly played, from playback marks.
Heard string
// Partial describes partially played or interrupted segments, whose exact
// heard words are unknown.
Partial string
// Pending is text accepted by the synthesiser that has not yet played.
Pending string
// Plan is content the policy intends to say and has not yet sent.
Plan string
}
Self is what the agent knows about its own speech and plan.
Heard, Pending, and Plan are kept apart because conflating them is the failure the study exists to catch: text handed to a synthesiser is not text the user heard, and a plan that was never sent is neither.
type Source ¶
type Source struct {
// contains filtered or unexported fields
}
Source releases annotated evidence on the study clock.
The whole schedule is computed up front from the events, the channels, and the injected delays, and Advance only walks it. That is deliberate: what a policy could know at any moment is then a pure function of the fixture and the cell, decided before the run started and unable to depend on anything the model did.
func (*Source) Advance ¶
Advance releases everything due at or before now and returns it. Calling it with a time earlier than the previous call releases nothing: the clock only moves forward, and replay never changes what the model knew at a past tick.
type Split ¶
type Split string
Split keeps prompt design away from the material that produces the reported numbers. Scorers and prompts are frozen on the pilot; the held-out split is run once against that frozen configuration.
type Variant ¶
type Variant struct {
ID string `json:"id"`
Label string `json:"label"`
// Feedback names the event group carrying the authored difference.
// Removing it is the negative control, so the difference has to be one
// identifiable phrase rather than a property of the whole branch.
Feedback string `json:"feedback"`
Events []Event `json:"events"`
Expect Expectation `json:"expect"`
}
Variant is one branch of a matched pair: what the user does after the shared prefix, and what the agent must then say.