Documentation
¶
Overview ¶
Package report makes shareable session reports: a read-only, redacted page of one session that anyone with its link can open without signing in to the dashboard. Pull request descriptions link it so that reviewers without a dashboard account (outside contributors, readers of a public repository) can follow which step wrote each changed line.
A link is a token the server signs; kōjō stores no token. Which sessions may have one is the day-2 object settings/reports, read when a link is made and again each time one is opened. What the page leaves out is listed in build.go.
Index ¶
- Constants
- Variables
- func Decide(set config.ReportSettings, f Facts) error
- func Render(w io.Writer, r *Report) error
- func RenderError(w io.Writer, title, text string) error
- func SetHeaders(h http.Header)
- type Claims
- type DiffFile
- type DiffRow
- type Facts
- type Field
- type Link
- type Options
- type PullRequest
- type Refused
- type Report
- type Risk
- type Service
- func (s *Service) Enabled() bool
- func (s *Service) For(ctx context.Context, ses *store.Session, public, confidential bool) (string, error)
- func (s *Service) HTML(ctx context.Context, id string) ([]byte, error)
- func (s *Service) Revoke(ctx context.Context, id, actor string) (int, error)
- func (s *Service) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (s *Service) Share(ctx context.Context, id string, ttl time.Duration, actor string) (*Link, error)
- type Signer
- type Step
Constants ¶
const ( // ActionLink is audited when a person makes a link (never with the // link itself). ActionLink = "report.link" // ActionRevoke is audited when an admin revokes a session's links. The // number of these entries is the revocation count every token carries: // the audit log is append-only, so a revocation cannot be undone. ActionRevoke = "report.revoke" )
Audit actions.
const ( // MaxRevocations bounds how often one session's links can be revoked, // so the count a token carries is always read exactly. MaxRevocations = 1000 )
Variables ¶
var ( // ErrInvalid is a token that is malformed or was not signed with the // server's key. ErrInvalid = errors.New("report: the link is not valid") // ErrExpired is a token whose expiry has passed. Its claims are // returned with it. ErrExpired = errors.New("report: the link has expired") )
Errors of Parse.
ErrUnavailable is returned when the server cannot make links at all.
var LeftOut = []string{
"What models wrote and read: prompts and their instructions, the orchestrator's and subagents' own text, and the tasks the orchestrator gave subagents. A model's text can repeat its instructions, and the conversation holds team memory and messages people sent.",
"Team and personal memory: what memory_search found and what memory_save stored.",
"Messages people sent the session while it worked, and who sent them.",
"The request's text and who asked when it came from anywhere but the repository's own forge (chat, the dashboard, the CLI, MCP, a schedule).",
"On GitLab, the output of the tools that read issues and comments (get_issue, list_issues, get_pr, get_review_comments): GitLab shows kōjō confidential issues and internal notes even of a public project.",
"Sandbox details: images, egress lists, kit setup commands and their output (kits name credentials and registries), and the arguments and output of tools this page does not know.",
"The config the session ran with, the session's error detail, and error text of steps other than tool calls and checks: they can name credentials, hosts and internal services.",
"In what is shown, the user and password part of URLs (a sandbox's proxy token) and the names in credential placeholders. Credentials themselves never reach a sandbox.",
}
LeftOut lists what a report never shows, and why. The page and the docs say the same.
Functions ¶
func Decide ¶
func Decide(set config.ReportSettings, f Facts) error
Decide applies settings/reports to a session. A confidential session never has a report, whatever the settings say.
func RenderError ¶
RenderError writes the page a link that does not open a report gets.
func SetHeaders ¶
SetHeaders sets the security headers of a report page or a page of its errors. The link in the address bar is the report's key, so no Referer carries it anywhere and nothing indexes, caches or frames the page.
Types ¶
type Claims ¶
type Claims struct {
// Session is the session the report is of.
Session string
// Revocations is how many times the session's links had been revoked
// when the token was made. A token is valid while that number has not
// changed.
Revocations int
// Expires is when the token stops working, to the second.
Expires time.Time
}
Claims are what a token says.
type DiffFile ¶
type DiffFile struct {
// Name is the path in the workspace: a linked repository's files are
// under .kojo/linked/<name>.
Name string
Status string // new, deleted or empty
Added int
Removed int
Rows []DiffRow
}
DiffFile is one file of the session's change.
type DiffRow ¶
type DiffRow struct {
// Kind is hunk, add, del, ctx or meta.
Kind string
// A and B are the line's numbers in the old and the new version; 0
// where it has none.
A, B int
Text string
// Step is the replay number of the step that wrote the line, 0 for a
// line no block covers; NoStep marks a changed line no tool call wrote
// (a kit's setup, a check of the goal critic).
Step int
NoStep bool
// StepTitle says what the step was.
StepTitle string
}
DiffRow is one line of a file's diff.
type Facts ¶
type Facts struct {
// Repo is the session's repository, forge/owner/name; empty for a
// session about none.
Repo string
// Public is true only when the session's repository was public when
// the session ran, and so was everything it read beside it (linked and
// reference repositories). Unknown counts as private.
Public bool
// Confidential is set when the request was confidential or the session
// ran a skill marked confidential.
Confidential bool
// Kind is the request's kind.
Kind string
}
Facts are what decides, besides settings/reports, whether a session may have a report.
type Link ¶
type Link struct {
Session string `json:"session"`
URL string `json:"url"`
ExpiresAt time.Time `json:"expires_at"`
}
Link is a link to a session's report.
type Options ¶
type Options struct {
// Secret is server.auth.session_secret. Without one, there are no links.
Secret string
// PublicURL is server.public_url: links are /r/<token> under it.
PublicURL string
Store store.Store
Config *config.Manager
// Public reports whether a stored session's repository, and every
// repository the session read, was public when it ran
// (core.PublicSession). Nil counts every session as private.
Public func(ses *store.Session) bool
// ConfidentialSkill reports whether a skill of that name is marked
// confidential (the built-in skills).
ConfidentialSkill func(name string) bool
Log *slog.Logger
// Now is the clock; nil means time.Now.
Now func() time.Time
}
Options configure a Service.
type PullRequest ¶
PullRequest is one pull request the session opened.
type Refused ¶
type Refused struct{ Reason string }
Refused says why a session may not have a report. Its text is shown to the operator who asked for one.
type Report ¶
type Report struct {
ID string
Title string
Repo string
Status string
Outcome string
Surface string
Trigger string
Actor string
// Target is the issue or pull request the request was about.
Target string
// Text is the request's text, when it came from the repository's own
// forge; TextLeftOut says why it is not shown otherwise.
Text string
TextLeftOut string
DryRun bool
Failed bool
Summary template.HTML
CriticReport template.HTML
Passed bool
Risk *Risk
PullRequests []PullRequest
CostUSD float64
TokensIn int64
TokensOut int64
Started time.Time
Ended time.Time
Duration string
Steps []Step
StepsLeftOut int
Diff []DiffFile
DiffCut bool
ProvenanceMissing string
// Expires is when the link the page was opened with stops working;
// zero for a page written to a file.
Expires time.Time
// Dashboard is the session's page on the dashboard, for maintainers.
Dashboard string
LeftOut []string
Generated time.Time
}
Report is what the page shows of one session.
type Risk ¶
type Risk struct {
Level string
Score float64
Reasons []string
// Pin places the score on the scale, in steps of 5%: 0 to 20.
Pin int
}
Risk is the merge policy's assessment.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service makes, checks and serves report links.
func (*Service) For ¶
func (s *Service) For(ctx context.Context, ses *store.Session, public, confidential bool) (string, error)
For is the core's way in: the address of a new link to the report of a session at work, or "" when settings/reports or the session do not allow one. public and confidential are what the session knows of itself.
func (*Service) HTML ¶
HTML is the report page of a session, under the same rules as a link, for an operator to save as a file.
func (*Service) Revoke ¶
Revoke ends every link to a session's report made so far, the ones in pull request descriptions included. A link made afterwards works.
type Signer ¶
type Signer struct {
// contains filtered or unexported fields
}
Signer makes and checks tokens with a key derived from the server's session secret. Every replica with the same secret reads every token.
func NewSigner ¶
NewSigner derives the token key from secret (server.auth.session_secret). It returns nil for an empty secret: a key that changed at every restart would break every link in every pull request.
type Step ¶
type Step struct {
Seq int
Depth int
Kind string
Name string
Failed bool
Running bool
Duration string
Model string
TokensIn int64
TokensOut int64
CostUSD float64
Purpose string
Command string
Fields []Field
Outputs []Field
ExitCode string
Error string
// Note says what the report leaves out of this step.
Note string
// Lines are the lines of the session's change this step wrote.
Lines []string
}
Step is one recorded step, with only what the report may show.