Documentation
¶
Overview ¶
Package assistant gated edit loop (D-27/D-30/D-39).
RunGatedEditLoop is the ONLY writable file path in the system. It executes untrusted LLM-directed file edits strictly inside the sealed snapshot work copy (the workDir handed in, produced by PrepareSnapshot), never on the host workspace. Every write passes lexical pre-checks, os.OpenRoot confinement, and a post-open handle verification, and is debited against EditCaps.
This file intentionally has no transport, no git invocation, and no secret material of any kind.
Index ¶
Constants ¶
const ( // DefaultEditMaxFiles caps the number of distinct files per loop run. DefaultEditMaxFiles = 10 // DefaultEditMaxTotalLines caps the total written lines per loop run. DefaultEditMaxTotalLines = 500 // DefaultEditMaxTotalBytes caps the total written bytes per loop run (1 MiB). DefaultEditMaxTotalBytes = 1048576 // MaxGatedEditTurns bounds the LLM turn loop. MaxGatedEditTurns = 8 // MaxGatedEditViolations aborts the loop after repeated forbidden actions. MaxGatedEditViolations = 3 )
Default edit-loop bounds (D-39).
Variables ¶
var ErrGatedEditViolationsExceeded = errors.New("gated edit loop: model exceeded violation limit")
ErrGatedEditViolationsExceeded aborts the loop after the model repeatedly requests forbidden mutation actions.
Functions ¶
This section is empty.
Types ¶
type Assistant ¶
type Assistant struct {
// contains filtered or unexported fields
}
func NewAssistant ¶
func (*Assistant) HandleMention ¶
func (a *Assistant) HandleMention(ctx context.Context, owner, repo string, number int, userQuestion string) (string, error)
HandleMention executes an interactive multi-step question/command regarding a PR
type EditCaps ¶
type EditCaps struct {
// MaxFiles caps distinct files written. Zero means DefaultEditMaxFiles.
MaxFiles int
// MaxTotalLines caps total lines written. Zero means DefaultEditMaxTotalLines.
MaxTotalLines int
// MaxTotalBytes caps total bytes written. Zero means DefaultEditMaxTotalBytes.
MaxTotalBytes int
}
EditCaps bounds a single RunGatedEditLoop run (D-39).
func DefaultEditCaps ¶
func DefaultEditCaps() EditCaps
DefaultEditCaps returns the plan-mandated bounds: 10 files, 500 lines, 1 MiB.
type EditResult ¶
type EditResult struct {
// FilesChanged lists work-copy-relative paths written, in write order.
FilesChanged []string
// TotalLines counts written lines across all writes.
TotalLines int
// TotalBytes counts written bytes across all writes.
TotalBytes int
// OmissionNotice names skipped paths when a cap stopped the run.
OmissionNotice string
// Truncated is true when caps stopped the run before the model finished.
Truncated bool
}
EditResult reports what the gated loop changed inside the work copy.
func RunGatedEditLoop ¶
func RunGatedEditLoop(ctx context.Context, llmClient GatedEditLLM, workDir string, instruction string, stickyContext string, caps EditCaps) (EditResult, error)
RunGatedEditLoop applies one LLM-directed improvement inside workDir, the sealed snapshot work copy. It returns the applied-change summary; the caller assembles any host-side push from the returned byte state (plan 05-04).
type GatedEditLLM ¶
type GatedEditLLM interface {
ChatCompletion(ctx context.Context, systemPrompt, userPrompt string) (string, error)
}
GatedEditLLM is the minimal LLM surface the gated loop needs. *llm.Client satisfies it; tests inject scripted fakes.