pointer

package
v1.119.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package pointer holds the parts of the pointers to spec sources that do not depend on the agent (spec issue-3556).

A spec source is a file of the spec folder that the push stores as its own material. A session transcript can hold the same content again, for example in a full read of the file or in the write that created it. Each agent that can find these copies replaces each one, at its position, with a pointer that holds the digest of the material. Only exact copies are replaced: the digest of the content must be equal to the digest of a source.

Index

Constants

View Source
const (
	FinderFileRead  = "file_read"
	FinderFileWrite = "file_write"
)

The finders, as the match report names them.

View Source
const (
	ReasonNoSpecEntry = "no spec entry with this digest"
	ReasonFileGone    = "file gone"
	ReasonFileChanged = "file changed"
	ReasonPartialRead = "partial read"
	ReasonToolError   = "tool error"
	ReasonUnsupported = "unsupported result"
)

Reasons for a copy that stays inline, as the match report gives them.

View Source
const Marker = "chainloop.replaced"

Marker is the type of a pointer, and the name of the field that holds a pointer in place of a text field. It tells any reader that Chainloop replaced the content.

Variables

This section is empty.

Functions

func Digest

func Digest(content []byte) string

Digest returns the digest of content in the form that Sources uses.

func DigestReader

func DigestReader(r io.Reader) (string, error)

DigestReader returns the digest of what r holds, in the form that Sources uses, with no copy of it in memory.

func New

func New(digest string) json.RawMessage

New returns the pointer to the material with the given digest.

Types

type Report

type Report map[string]*Result

Report is the match report of one session, per finder.

func (Report) Finder

func (r Report) Finder(name string) *Result

Finder returns the result of a finder, which it adds when it is not there.

type Result

type Result struct {
	// Replaced is the number of copies replaced with a pointer.
	Replaced int
	// Skipped counts, per reason, the copies that stay inline.
	Skipped map[string]int
	// BytesRemoved is the size of the replaced content.
	BytesRemoved int
}

Result counts the copies one finder looked at.

func (*Result) Skip

func (r *Result) Skip(reason string, copies int)

Skip counts copies that stay inline for reason.

type Sources

type Sources map[string]string

Sources maps the digest of each spec source, as the file is on disk, to the digest of the material it is stored as. The two differ for a text file, whose material is its redacted copy.

Jump to

Keyboard shortcuts

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