consent

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package consent tracks whether the app is allowed to call agent.Learn after a chat exchange without asking first.

The gate this package backs is narrow on purpose: it only covers automatic learning from conversation (Stage 4.2). MCP writes have their own, separately-scoped default in internal/mcpserver (BRAIN_TRUST_MCP), and manual/CLI writes are never gated at all. Conflating the three would mean one on/off switch governing every write path in the app, which is exactly the kind of blanket toggle that either nags on every turn or gets flipped on once and forgotten — neither of which is "ask before learning."

Asking before every single Learn would be correct but exhausting: a chat session is many exchanges, and re-prompting after each one trains the user to click through without reading, which defeats the point of asking at all. So consent here is not a single bit — it is a bit plus an expiry. Grant(d) says "stop asking for a while," Revoke undoes that early, and Allowed reports whether the grant is still live. This mirrors how the rest of the app treats trust as a scoped, time-bounded thing rather than a permanent setting: see internal/mcpserver's BRAIN_TRUST_MCP for the sibling decision on the MCP side.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Allowed

func Allowed() bool

Allowed reports whether automatic learning may proceed right now without asking. It is false until something calls Grant, and reverts to false once a timed grant expires — the caller (chat.go) is expected to re-ask at that point rather than silently resume learning.

func Grant

func Grant(d time.Duration)

Grant allows automatic learning without asking, for d. d <= 0 means for the rest of this run (until Revoke or process exit) rather than a specific duration — a caller that wants "always" for this session passes 0, not an arbitrarily large duration that would be wrong to display.

func Remaining

func Remaining() time.Duration

Remaining reports how long the current grant has left. It returns 0 when there is no grant, and a duration you should not treat as ever expiring when the grant is for the rest of the run — callers that only want to know "am I allowed" should use Allowed instead; this exists for a UI that wants to show a countdown.

func Revoke

func Revoke()

Revoke withdraws any standing grant immediately. The next chat exchange goes back to asking before it learns.

Types

This section is empty.

Jump to

Keyboard shortcuts

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