Add Pixi-style project environments and SAT dependency solver

- Add orbit.toml project manifests, deterministic orbit.lock files, [tasks], and `orbit run`
- Add per-project .orbit/bin environments; `-g`/`--global` targets the global environment
- Replace greedy global resolution with a lazy CDCL SAT solver that explains conflicts
- Support channel::pkg dependency pins and comma-separated, comparison, and wildcard constraints
- Cache immutable sha256 manifests under ~/.orbit/cache/manifests
- Validate dependency keys and constraints in orbit.json
This commit is contained in:
nandi committed 2026-11-28 01:43:04 -08:00
1 parent 0919ce105c
commit 13aa7d7f77
9 files changed
+4563 -266

No files matched your search

+51 -11
View File
@@ -7,13 +7,14 @@ A small package manager written in MoonBit that uses any OCI registry (Gitea, GH
## What it does
- **Publish:** `orbit publish <dir>` packs `<dir>/files/` into `pkg.tar.gz` and pushes it with `<dir>/orbit.json` as the OCI config blob.
- **Install with dependencies:** it reads only the small config blob from the OCI registry to plan, then streams the layers by digest with SHA-256 verification.
- **Version constraints:** `1.2.3`, `1.2`, `^1.2.0`, `~1.2.0`, `>=1.2`, `*`. Prereleases match only when the constraint asks for one.
- **Content-addressed store:** packages unpack into `~/.orbit/store/<name>/<digest>/`, and their binaries are symlinked into `~/.orbit/bin/`.
- **Lazy CDCL SAT solver:** resolves global and project dependency graphs with backtracking, conflict explanations, and `channel::pkg` dependency pins, reading only needed config blobs and caching immutable `sha256` manifests under `~/.orbit/cache/manifests/`.
- **Pixi-style project environments:** `orbit new`, `orbit.toml` manifests, deterministic `orbit.lock` lockfiles, `[tasks]`, `orbit run`, and isolated `.orbit/bin/` environments symlinked from the shared store (`-g` / `--global` targets the global environment inside a project).
- **Version constraints:** `1.2.3`, `=1.2.3`, `==1.2.3`, `1.2`, `1.2.*`, `^1.2.0`, `~1.2.0`, `>=1.2`, `<=2.0`, `>1.0`, `<2.0`, `!=1.3.0`, `*`, and comma-separated ranges (`>=1.2.0, <2.0.0`). Prereleases match only when the constraint mentions a `-`.
- **Content-addressed store:** packages unpack into `~/.orbit/store/<name>/<digest>/`, and their binaries are symlinked into `~/.orbit/bin/` (global) or `<project>/.orbit/bin/` (project).
- **File ownership:** two packages can't provide the same binary.
- **Upgrade and rollback:** the previous two builds are kept, and `orbit rollback <name>` switches back instantly with no network.
- **Remove:** `orbit remove` refuses to delete what other packages need, then autoremoves orphaned dependencies.
- **gc** deletes builds that are neither current nor kept for rollback.
- **Upgrade and rollback:** global installs keep the previous two builds, and `orbit rollback <name>` switches back instantly with no network.
- **Remove:** `orbit remove` refuses to delete what other global packages need and autoremoves orphaned dependencies; in projects it updates `orbit.toml` and `orbit.lock`.
- **gc** deletes store builds that are neither globally current nor kept for rollback.
## Package format
@@ -52,6 +53,8 @@ Because these are ordinary OCI artifacts, you can sign them with `cosign` or `no
## Usage
### Global environment
```sh
orbit login git.site.latha.org # once, with a Gitea token (needed to publish)
eval "$(orbit env)"
@@ -64,6 +67,40 @@ orbit rollback hello
orbit remove hello
```
### Project workflow (Pixi-style)
Inside a directory with `orbit.toml` (or pass `--manifest-path <path>`), commands target the project unless you pass `-g` / `--global`:
```sh
orbit new myapp && cd myapp
orbit add hello example::greet
orbit run greet
orbit lock --update
orbit install --locked
orbit update
orbit remove hello
```
An `orbit.toml` looks like:
```toml
[project]
name = "myapp"
version = "0.1.0"
channels = ["example", "main"]
[[channels]]
name = "example"
url = "git.site.latha.org/nandi/example"
[dependencies]
hello = "^1.0.0"
greet = { version = ">=1.0.0, <2.0.0", channel = "example" }
[tasks]
hi = "greet"
```
Credentials are stored in `~/.orbit/auth.json` (`$ORBIT_ROOT/auth.json`, mode `0600`). Orbit also falls back to `~/.docker/config.json` (`$DOCKER_CONFIG/config.json`) including `credHelpers` and `credsStore`. Use `orbit logout <host>` to remove stored credentials from Orbit.
## Channels
@@ -159,12 +196,15 @@ src/main/
sha256.mbt streaming FIPS 180-4 SHA-256 (+ tests)
auth.mbt credentials store (~/.orbit/auth.json + Docker config fallback)
oci.mbt OCI Distribution v2 HTTP transport, Bearer/Basic auth, redirects
semver.mbt versions, constraints, tag selection (+ tests)
semver.mbt versions, relational/compound constraints, tag selection (+ tests)
model.mbt orbit.json / state.json / config.json (+ tests)
registry.mbt OCI registry ops: tags, resolve, fetch, publish, login verify
ops.mbt dependency planner, install/remove/upgrade/rollback/gc
registry.mbt OCI registry ops: tags, resolve, cached manifests, fetch, publish, login
solver.mbt lazy Resolvo-style CDCL SAT solver & UNSAT explainer (+ tests)
ops.mbt SAT-backed global install/upgrade, remove/rollback/gc/search
project.mbt orbit.toml, orbit.lock, .orbit/ environments, project CLI (+ tests)
channels.mbt config.toml, channel priority and lookup (+ tests)
main.mbt CLI
registry_wbtest.mbt mock-OCI registry, SAT global, and project workflow tests
```
## Toolchain notes
@@ -178,7 +218,7 @@ Fixes needed for current MoonBit, kept here in case you build with an older comp
## Known limits
- Dependency resolution is greedy (highest satisfying version, first come), not a SAT solver.
- There's no lock file for concurrent runs, and no install hooks, by design.
- `orbit info <name>` reads installed package details without contacting the registry. Use `orbit versions <name>` to check published versions.
- `orbit gc` only preserves global current and rollback builds (run `orbit install` / `orbit sync` in a project to re-populate missing store entries from its `orbit.lock`).
- `orbit info <name>` reads globally installed package details without contacting the registry. Use `orbit versions <name>` to check published versions.
- `search` needs the registry's catalog API, which Gitea doesn't expose. Use `orbit versions <name>` if you already know the package name.