Documentation
¶
Overview ¶
Package ratchet stores project rules recorded from agent failures (issue #249): each rule keeps the incident that caused it and an expiry date or review condition, so stale rules can be pruned as models improve. Rules live in <cwd>/.tinyagent/ratchet.toml; a project without the file pays nothing. Active rules become guidance at run start, and a rule with a deny matcher is also enforced as a permissions deny rule.
Index ¶
Constants ¶
const ( DefaultCommandTools = "bash|start_process" DefaultPathTools = "write_file|edit_file|apply_patch" DefaultHostTools = "web_fetch" )
Default tools a deny matcher applies to when tool is left empty.
const DateLayout = "2006-01-02"
DateLayout is the format of created and expires.
const DefaultExpiryDays = 90
DefaultExpiryDays is how long a rule recorded without --ratchet-expires or --ratchet-review stays active.
const RelPath = ".tinyagent/ratchet.toml"
RelPath is the rules file relative to --cwd.
Variables ¶
This section is empty.
Functions ¶
func PermissionRules ¶
func PermissionRules(active []Rule) []config.PermissionRule
PermissionRules returns a deny rule for each active rule with a matcher.
Types ¶
type Deny ¶
type Deny struct {
Tool string `toml:"tool,omitempty"`
Command string `toml:"command,omitempty"`
Path string `toml:"path,omitempty"`
Host string `toml:"host,omitempty"`
}
Deny is an enforceable matcher with the permissions rule syntax. At most one of Command, Path and Host may be set.
type Rule ¶
type Rule struct {
// ID is r1, r2, ...; assigned by Add.
ID string `toml:"id"`
// Rule is the guidance shown to the model.
Rule string `toml:"rule"`
// Incident is what went wrong and led to the rule.
Incident string `toml:"incident"`
// Created is the YYYY-MM-DD date the rule was recorded.
Created string `toml:"created"`
// Expires is the YYYY-MM-DD date from which the rule is skipped.
Expires string `toml:"expires,omitempty"`
// Review is a condition under which the rule should be reconsidered.
Review string `toml:"review,omitempty"`
// Deny, when set, also enforces the rule as a permissions deny rule.
Deny *Deny `toml:"deny,omitempty"`
}
Rule is one recorded rule.
func Add ¶
Add appends r to the rules in path, creating the file and its directory when needed. It assigns the next id and today's created date, and with no expires and no review sets expires DefaultExpiryDays from now.
func Load ¶
Load reads the rules in path. A missing file is no rules and no error. Errors name the rule's position.