tobogganSe connecter

louise

The Louise language: compiler, runtime, std, tooling

Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.

181 lignes · 15896 octetsBrut · Historique

ADR 0020: Git dependencies and the lockfile

Status: Accepted by the project owner on 2026-10-12; proposed 2026-10-09 (issue #51, v1 milestone M7); needs engineering review (#44).

Context

  • v0 has path dependencies only (ADR 0005, Revision 1): [dependencies] argon2 = { path = "../argon2" }. Sharing a package means copying it next to its users.
  • The v1 definition of done asks for dependencies resolved "from a registry (or git) with a lockfile" (roadmap M7). The registry is deferred to v2 (issue #63), so v1 ships git dependencies.
  • A build must be reproducible: the same checkout of a package must build the same dependency code tomorrow, on CI and on another machine, even if a branch has moved since.
  • The demo depends on a package with native C sources (argon2). Native dependencies of fetched packages must keep building.
  • The modules of a dependency are named after it (argon2, argon2/...) in one namespace shared by the whole build.

Decision

Manifest

A dependency has a path or a git URL. A git dependency names at most one reference:

[dependencies]
argon2 = { path = "../argon2" }
json   = { git = "https://example.com/json.git", tag = "v1.2.0" }
http   = { git = "https://example.com/http.git", branch = "main" }
util   = { git = "https://example.com/util.git", rev = "4f2a9c1" }
log    = { git = "https://example.com/log.git" }   # the remote's default branch
  • rev must be 4 to 40 hexadecimal digits. Anything else would be looked up as a branch or tag name.
  • The repository root is the package root: louise.toml is at the top of the repository. Packages in subdirectories of a repository and submodules are not supported.
  • URLs are anything git fetch accepts (https://, ssh://, git@host:path, file://). They should be absolute: the lockfile records them as written.

Fetching: the git command

louise runs the git executable. It does not link a git library.

git CLI (chosen)gixgit2 (libgit2)
Build costnonedozens of cratesa C library, OpenSSL and libssh2 to build or find
Authenticationthe user's own: SSH agent, credential helpers, url.insteadOf, proxiespartial; SSH goes through the ssh binary anywayits own SSH and HTTPS stacks, configured separately
Behaviourexactly what the user gets from gita reimplementation, still maturing for fetchlibgit2's, which lags git
Costa process per operation; git must be installed

At v1 scale (a handful of dependencies, fetched rarely) the processes cost nothing noticeable. Cargo offers the same choice (net.git-fetch-with-cli), for the same authentication reasons. Every git invocation sets GIT_TERMINAL_PROMPT=0, so a missing credential fails instead of waiting on a prompt that an editor or CI never answers. Arguments from manifests are passed after -- or --end-of-options.

Cache

Under $LOUISE_HOME, else $XDG_CACHE_HOME/louise, else ~/.cache/louise:

git/db/<name>-<hash of URL>/                    a bare repository: everything fetched from the URL
git/db/<name>-<hash of URL>.lock                held while fetching or checking out
git/checkouts/<name>-<hash of URL>/<commit>/    the files of one commit, without .git
  • Keys: the hash is 64-bit FNV-1a, stable across Rust releases (unlike DefaultHasher). The readable name prefix is the URL's last segment.
  • Fetching: a fetch takes every branch and tag (+refs/heads/*, +refs/tags/*), plus the remote's HEAD for a dependency on the default branch. A full commit id that no branch or tag reaches is fetched by id.
  • Checkouts: a checkout is written under a temporary name with a throwaway index (git read-tree -u), then renamed into place. A checkout directory that exists is therefore complete, and is never modified afterwards: readers need no lock.
  • Concurrency: writers (fetch, checkout) hold an exclusive file lock per repository (File::lock), so concurrent louise runs can share the cache.
  • Cleanup: nothing is garbage-collected. Deleting the cache is always safe; it is fetched again.

louise.lock

TOML, next to the root package's louise.toml, meant to be committed:

# Written by louise: the commit of each git dependency (ADR 0020).
# Commit this file. `louise update` re-resolves the dependencies.

version = 1

[[package]]
name = "json"
git = "https://example.com/json.git"
tag = "v1.2.0"
commit = "9fe23bdf32b112d25dc8151860f4ceaba3795bde"
  • Entries: one per git dependency of the whole graph, transitive ones included, sorted.
  • Key: an entry is keyed by the dependency's name, URL and requested reference. A build uses the locked commit when an entry matches. Changing any of the three in a manifest makes the entry stale: the dependency is resolved afresh and the stale entry is dropped.
  • Not locked:
    • path dependencies: their files are already on disk, in the user's own tree;
    • the lockfiles of dependencies: only the root package's lockfile counts, as in Cargo.
  • When it is written: when a resolution differs from it. A package without git dependencies gets no lockfile.
  • The locked commit must be in the cache. If it is not there, it is fetched; a commit the remote no longer has is an error that suggests louise update <name>.

Commands

check, run, build, test, coreresolve first: fetch what is missing, write the lockfile if it changed, and print one line per change (locking, updating, removing)
--lockedfail, listing the changes, if the lockfile is missing or would change. Nothing is written. CI uses it (scripts/ci.sh).
--offlinenever fetch. Locked commits must be in the cache; references without a locked commit resolve against what was last fetched.
louise update [name]resolve again, ignoring the locked commits (of name only, if given), and rewrite the lockfile. --locked is refused.

--locked and --offline are global flags. They can come before or after the subcommand, and combine (louise test --locked --offline).

Transitive resolution: one version of each package

Dependencies of dependencies are resolved breadth-first, in manifest order. A build holds at most one package per name, and one commit per git URL:

  • Same name, same source (the same URL at the same commit, or the same directory): one package, loaded once.

  • Same URL, different commits: an error. Example: the root wants branch main, and a dependency wants tag v1, which is an older commit.

    error: conflicting versions of `lib`:
      `app` requires branch main: https://example.com/lib.git at 5e6f7a8b9c
      `mid` requires tag v1: https://example.com/lib.git at 1a2b3c4d5e
    a build holds one version of each package: make these requirements agree (ADR 0020)
    

    Two different references that name the same commit agree.

  • Same name, different packages (different URLs, or a path and a URL): an error.

  • Same package under two names: an error. Its modules would be loaded twice, and its native code linked twice.

Why an error. Module names are global, so two versions cannot coexist in one build without per-package namespaces. Git references carry no version order, so there is no "newest compatible" to pick. Choosing silently would make the build depend on traversal order. The error names both requesters, and the fix is a one-line manifest change.

Path dependencies inside a git dependency must stay inside its checkout (a monorepo layout). A path that leaves it would reach whatever happens to sit next to it in the cache.

Native dependencies of git dependencies

Nothing changes in how they build. A git package's [native.*] paths are relative to its checkout, as they are to any package root. Build products go in the build directory of the program being built (build/native/, ADR 0025; .louise-native/ next to the program before it), never into the cache, so checkouts stay read-only and shared.

The language server

Db::load_package, which the language server calls, resolves with Options::cached():

  • offline: it never fetches;
  • read-only: it never writes the lockfile.

It sees git dependencies once a command-line build has fetched them. If resolution fails, the package's own modules are still loaded, imports of the missing dependencies are reported as unresolved, and the failure itself is a diagnostic in the manifest at fault (E0801, issue #62).

Incremental analysis: evaluated, deferred

Issue #51 also asks whether the language server should move to salsa. ADR 0006's criteria are not met:

  • Latency: a whole-package louise check of the demo (std, the demo, argon2: about 2,200 lines) takes about 10 ms wall-clock with a release build, process start included; a debug build takes about 90 ms. The language server re-runs the same analysis per change, so its latency should be an order of magnitude under the 100 ms threshold. (This measures the batch pipeline, not keystroke-to-diagnostics p95 in an editor, which has no harness yet.)
  • Granularity: nothing needs finer than whole-file tracking yet.

So the coarse Db stays, and the language server is unchanged apart from reading git dependencies from the cache. Revisit when a real project exceeds the threshold.

Consequences

  • Requirements: git dependencies need git on PATH. Packages without them do not.

  • Trust: building a git dependency compiles its native code, and a kind = "cargo" dependency runs its build scripts. That is the same trust as cargo build; the lockfile at least pins what is trusted.

  • Reproducibility: builds are reproducible from the lockfile and the remote. A force-pushed tag does not change a locked build. A rewritten history that drops a locked commit makes the build fail with a clear message instead.

  • Lockfiles name URLs as written. file:// URLs to local paths, as in the tests, do not travel between machines.

  • CLI: the command-line options reach the resolver through a process-wide OnceLock, set once from the flags. The alternative was threading them through every command's helper functions.

  • Not in v1:

    • version requirements and unification (semver);
    • packages in a repository's subdirectory;
    • submodules;
    • mirrors and vendoring;
    • a registry (issue #63).

    The lockfile's version field leaves room for these.

  • Tests: crates/louise/tests/packages.rs runs louise against local bare repositories over file://, with its own cache. It covers tags, revs and branches, a lockfile written then reused, update, --locked, transitive dependencies, a conflict, and --offline. It also builds the v0 demo with argon2 as a git dependency (including its C sources), then runs the demo's native tests with --locked: issue #51's exit criterion.

Alternatives considered

  • gix or git2. See the table above. Either can replace the git module later without changing the lockfile or the cache layout; only louise_package/src/git.rs runs git.
  • Downloading archives (forge tarball URLs). No dependency on git, but every forge has its own URL scheme, and private repositories need per-forge authentication.
  • Registry first. Deferred to v2 (issue #63). Git dependencies remain useful next to a registry, for forks and unpublished packages.
  • Picking one version on conflict (the root's, or the newest). Silent and order-dependent; see above.
  • One entry per package in the lockfile, instead of per request. Entries per (name, URL, reference) make a manifest edit invalidate exactly the entry it concerns, without comparing old and new manifests.
  • Honouring dependencies' lockfiles. Two dependencies' lockfiles could disagree; the root's lockfile is the single source of truth.

Revision 1 — 2026-10-23: packages in a repository's subdirectory

Status: Proposed; needs engineering review (#44). Asked in toboggan#115.

Context. The packages this repository ships (packages/uuid, packages/postgres, packages/argon2) live in subdirectories, so the rule "the repository root is the package root" left them out of git dependencies: their users depend on them by path, on a copy kept next to their own tree (toki2 points at a scratch checkout). Moving each package to a repository of its own would split one release into several and break postgres's uuid = { path = "../uuid" }.

Decision.

  • subdir. A git dependency may name the package's directory in the repository:

    [dependencies]
    postgres = { git = "https://toboggan.cloud/gabla108/louise.git", tag = "v0.2.0", subdir = "packages/postgres" }
    uuid     = { git = "https://toboggan.cloud/gabla108/louise.git", tag = "v0.2.0", subdir = "packages/uuid" }
    

    It is a relative path, without .., normalised (./packages//uuid/ is packages/uuid); subdir without git is an error. The directory must hold a louise.toml once checked out, and must resolve inside the checkout (a symbolic link leading out of it is refused). Without subdir, the package is at the top, as before.

  • A package in a checkout is known by its place in the repository. A package's identity was its canonical path, or, from git, its URL and commit. It is now, for anything inside a git checkout, the URL, the commit and the directory, however the package was reached. So uuid above and postgres's path = "../uuid" in the same checkout are one package, loaded once; at two commits they are "conflicting versions of uuid", naming both requesters, as any other conflict is. Packages of one repository are different packages: postgres and uuid may come from different commits when neither reaches the other.

  • The lockfile is unchanged (version 1). It records which commit a reference names, and a subdirectory does not change it. Changing a subdir keeps the locked commit; changing the URL or the reference re-resolves, as before. Lockfiles written before this revision stay valid, and those written after it still read in older compilers.

  • Fetching and the cache are unchanged: a repository is fetched once per run and checked out once per commit, however many of its packages the build uses.

Consequences.

  • The packages here can be depended on by tag, from any project, with the user's own git credentials (SSH, or a credential helper with a forge token).
  • Each package of a repository is locked on its own. louise update postgres re-resolves postgres alone: if its tag now names a commit other than uuid's, and postgres reaches uuid by path, the build stops with the version conflict; louise update (all) re-resolves both.
  • Compilers before this revision refuse subdir as an unknown field of the dependency. A package that uses it can say so with [package] louise, naming the first release that has it.
  • A path dependency inside a checkout used to be identified by its path in the cache; it is now identified by the repository. The only visible change is the error when two commits disagree: "conflicting versions" instead of "two different packages".

Alternatives considered.

  • Finding the package by its name anywhere in the repository, as Cargo finds a crate. It saves a key, but searches the tree, makes the choice depend on what else the repository holds, and a dependency's name need not be its [package] name.
  • A repository per package. It works today with no change, at the cost of releasing and tagging each separately, and of turning in-repository path dependencies into git ones pinned by hand.
  • Recording subdir in the lockfile. It would make the key (name, URL, reference, directory), so moving a package within its repository would re-resolve it for nothing, and the lockfile's version would have to change.