AGENTS.md
for agents landing in this repository cold.
vpac is a package manager written in V on top of the native alpm engine
in alpm.v, which follows pacman/libalpm behavior. it is a frontend of its own — its own listings, prompts,
progress drawing, and a json event protocol for other frontends — with a
config file of its own, and two package sources beyond the sync dbs: the
pkgbuild repos and arbitrary git repos built with vpac itself.
the repository
src/ module main: the frontend. one file per mode, plus the shared
parts every mode reaches for.
src/cli.v argument parsing and mode dispatch. modes: s q w n m b i r u
l o d c t a k v f (search info which deptest mark build
install remove upgrade files owner orphans clean tree
autoremove rank verify find).
src/config.v the configuration. the forms (path pkg network rank pkgbuild
options search clean tree color progress spinner
mirrorlist repo) are read from a blip file, /etc/vpac.d/config.lip by
default, and every setting keeps a __global here.
src/trans.v transaction begin/prepare/commit/cleanup and the interrupt
handler. src/db.v holds the db paths, repo registration and
freshness; src/db_check.v is verify's -D modes.
src/ipc.v --ui ipc: the event protocol (one json object per line) and
the prompter a frontend answers questions with.
src/ui.v the shared progress display and callback wiring for alpm.v;
src/prompt.v the terminal's side of every question.
(the rest of src/)
one file per command. install is remote.v, and remove.v
autoremove.v upgrade.v modify.v write the db too; find.v
files.v orphans.v deptest.v are read-only; verify.v and
verify_full.v check the disk; pkgbuild.v pkgbuild_install.v
build_repo.v mirrors.v privilege.v are the network- and
privilege-flavored ones.
vmakepkg/ a library module of its own: PKGBUILD.lip (blip format;
lip.v) and PKGBUILD.vsh (a V script; vsh.v) both turn into a
real PKGBUILD (and a .install for hooks) whose phases makepkg
runs, delegating back into vpac or v.
pkgs/ two tiny packages vpac itself builds as smoke tests of the
vmakepkg formats.
src/*_test.v, vmakepkg/*_test.v the tests.
src/testdb/ a module only the tests import: the one writer of libalpm
local dbs they share. vpac never imports it, so it is in no
build of the program.
the cross-references, and the rule about them
the binary uses the native V module alpm (a file that begins module alpm),
evaluates its config and lip files through the module
blip.vlib.blip, and reuses this repo's own vmakepkg. these dependencies
live outside the repository: on a machine, V finds them under its module
directory (typically ~/.vmodules), often as symlinks to checkouts beside vpac.
the native backend uses libarchive, curl, GPGME/GnuPG, seccomp on Linux and libc;
production builds have no libalpm header or link dependency. alpm.v keeps its C
reference under tests/coracle; never substitute it for the production backend.
the complete public parity/logging audit is still tracked in alpm.v issue #1.
- if a build cannot resolve
alpm,bliporvmakepkg, find where those checkouts are on this machine (ask, or look in V's module directory) — never stub a missing module or patch a module cache to make it work. - parity questions ("what does pacman do?", "is this libalpm behavior?") are
answered in the pacman C source — the checkout that holds
lib/libalpm/*.c— and in libalpm's headers, not guessed. vpac follows pacman's defaults closely; a lot of what looks odd is pacman's own behavior spelled out. cross-reference before you fix. - signature and checksum semantics: libalpm distinguishes the default, local file and remote file siglevels; pacman maps its config onto all three.
building and testing
- the compiler is
v.v . -o vpaccompiles to ./vpac at the repo root.v test srcandv test vmakepkgrun the two suites. there is no install step: link or copy ./vpac where you want it. - a change is finished when
v -check .is clean, both test suites pass, and every touched .v file has been through the formatter (v fmt -won the file; the formatter reflows — check the result). - tests are hermetic: each src/*_test.v compiles as its own binary and builds its own local dbs under V's temp dir. they need no network and no root. globals a test touches (config, cache dirs, colors) are saved and restored inside the test.
- smoke checks against a real system are read-only only unless you are meant to change it: search, info, --print previews, verify, find, tree are safe. installs, removals and rank -w are not.
house style
- prose comments, lowercase, sparsely worded: they say why — the intent, the pacman or posix cross-reference, the data's shape — not what the line does. when you change behavior, move the comment with it.
- error discipline: no panics behind doors a user walks through; every
alpm call's error is handled; a housekeeping failure the run goes on
from (a handle's release, a temp dir's removal) is not
or {}butor { went_on('release the alpm handle', err) }, which --verbose says; ?T (may be none) and !T (may fail) are unwrapped with their own syntax and are not interchangeable. - identifiers snake_case, files named for their one concern. the formatter is the arbiter of layout; do not hand-alignment what v fmt will rewrite.
gotchas learned the hard way (do not rediscover them)
- os.File.read reports end of input as an os.Eof error: end a chunked read
with
err is os.Eof, and treat anything else as failure (a truncated digest must never pass as a whole one). - dup(2) and dup2(2) answer their new descriptor on success — never 0 — so a
check against
!= 0fires on every success; checkfd < 0. lockis a V keyword. so a variable named it does not compile; spell the lock's pathlpathinstead.- the flag attributes read the field's long name with dashes: @[long: no_upgrade_deps] accepts --no-upgrade-deps. spell help text with dashes.
- a
?Tif-guard cannot readerr— only a!Tcall'sor {}has one. a!call cannot hide inside a function that returns ?T: either handle the error inline or widen the return. - defer always runs, including through
or { return err }: pair trans_begin withdefer { trans_cleanup(handle) }at the moment of begin and never also release by hand (Handle.release is not idempotent). - assigning one array to another needs the checker's
.clone(); a borrowed &T passed to a mut method is the local copy, never a write to the C side. - the repo's __global config values are the whole config surface: load_config resets every one of them before reading the file, so a second load in one process starts clean (tests depend on this).
conventions that hold the system together
- every question goes through ui.yesno / ui.noyes / ui.proceed / ui.choose, which pause the live display first. --noconfirm takes each preset printed; --print answers silently; pkgbuild installs refuse --noconfirm unless --nopkgbuildconfirm (the first question's preset is no).
- the ipc protocol is a versioned surface (const ipc_protocol in ipc.v): an event whose shape a reader must know about bumps it. once ipc_start ran, plain prints never touch stdout — they are led to stderr, so the channel stays whole json lines.
- the config can hold packages (pkg :hold): the check runs on the targets and again on the transaction's final victim set, after prepare.
- modes that change the system re-execute themselves as root through the root provider (the config's options :root: sudo by default, any command that runs its arguments as root; su and pkexec are known by name), carrying the config and the invoker's name across (VPAC_INVOKER, VPAC_V). pkgbuild builds and the build mode run as that invoking user, never as root. --lip-run is vpac internal: the entry generated PKGBUILDs call back through, not a mode.
- read-only modes may open a lean alpm.initialize handle; anything that writes goes through init_handle so alpm's callbacks and the configured siglevel, cachedirs, ignores and parallelism attach.
the issue tracker
there is no TODO file: the checklist of the 2026-11-09 review sweep
moved into the issue tracker — 140 issues, one per checklist id, and #2
their index. tracker numbers do not match the ids; look an id up in the
index (#2) first. later sweeps filed some findings two or three times:
close the duplicates of an issue with it. work changes state in the
tracker, not in files: open an issue first (fj issue create -R origin),
push the fix, then close the issue with the resolution
(fj issue close -R origin N -w "..."). fj talks to
the origin host (git.vorelabs.dev) and needs a token such as configured
under fj auth list — user read, repository read, issue read/write.