installchange

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package installchange tells a running pig that the files it runs from changed on disk.

Pi (packages/coding-agent/src/config.ts detectInstallChange, #10439) warns when an update or removal replaced the package its process loads code from. PiG is one native executable that embeds its code, so the same hazard comes from other files: an update replaces or removes the executable, and another pig's cache prune removes an extension cell or runtime file this process still starts on demand.

pig additive (D95): there is no upstream equivalent of tracking an executable and cache files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Record

func Record()

Record records this process's executable. The first call wins, so the identity is the startup one.

func TrackFile

func TrackFile(path string)

TrackFile records a cell or runtime file on the process's tracker. Before Record it does nothing.

Types

type Change

type Change struct {
	Kind Kind
	Path string
}

Change is one detected change. Path names the file that changed.

func Detect

func Detect() *Change

Detect reports the first change on the process's tracker. Before Record it reports nothing.

type FileID

type FileID struct {
	Device uint64
	Index  uint64
}

FileID is a file's device and inode on Unix, or its volume serial number and file index on Windows.

type Identity

type Identity struct {
	// Path is the path with its symbolic links resolved.
	Path    string
	File    FileID
	Size    int64
	ModTime time.Time
}

Identity is what a path named when it was recorded.

type Kind

type Kind string

Kind classifies a change.

const (
	// BinaryReplaced means the executable at the recorded path is another file now.
	BinaryReplaced Kind = "binary-replaced"
	// BinaryRemoved means the executable is gone.
	BinaryRemoved Kind = "binary-removed"
	// FilesPruned means an extension cell or runtime file this process uses is gone.
	FilesPruned Kind = "files-pruned"
)

type Tracker

type Tracker struct {
	// contains filtered or unexported fields
}

Tracker holds what one process recorded at startup.

func Default

func Default() *Tracker

Default returns the tracker Record made, or nil before Record.

func NewTracker

func NewTracker(executable string) *Tracker

NewTracker records executable's identity, or this process's executable (linkerexec.Executable, which knows a program started through the Android linker) when executable is empty. An executable that cannot be read at startup is not tracked, because there is nothing to compare it with.

func (*Tracker) Detect

func (t *Tracker) Detect() *Change

Detect reports the first change since startup, or nil. Ports packages/coding-agent/src/config.ts (detectInstallChange).

It checks the recorded paths and never searches for another install, so an install removed from under the process is reported as removed even when another executable of the same name sits further up the tree, as Pi reads the package.json it started from. Only a missing file counts: an error such as a permission failure says nothing about the install.

func (*Tracker) Executable

func (t *Tracker) Executable() (Identity, bool)

Executable returns what was recorded for the executable.

func (*Tracker) TrackFile

func (t *Tracker) TrackFile(path string)

TrackFile records a cell or runtime file this process uses, so a later Detect notices that it is gone. A repeated path is recorded once.

func (*Tracker) TrackedFiles

func (t *Tracker) TrackedFiles() []string

TrackedFiles returns the recorded cell and runtime files in the order they were recorded.

Jump to

Keyboard shortcuts

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