Add package conflicts
Rolling Release / build (push) Successful in 1m41s
Rolling Release / publish (push) Successful in 9s

Packages can declare conflicts in orbit.json. The solver keeps them apart,
and a global install offers to replace the installed ones in the way.
Rollback now checks for clashes before it unlinks anything.

Planning: 8m9kt

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
nandiandClaude Opus 5.5 committed 2026-12-01 05:29:25 -08:00
1 parent 6d35f207fd
commit cc47acb3e2
9 files changed
+831 -28

No files matched your search

+14 -2
View File
@@ -18,6 +18,7 @@ struct Manifest {
description : String
documentation : String
depends : Map[String, String]
conflicts : Map[String, String]
bins : Array[String]
}
@@ -30,6 +31,7 @@ struct Gen {
description : String
bins : Array[String]
depends : Map[String, String]
conflicts : Map[String, String]
}
///|
@@ -43,6 +45,7 @@ struct Installed {
mut constraint : String
mut bins : Array[String]
mut depends : Map[String, String]
mut conflicts : Map[String, String]
history : Array[Gen]
}
@@ -197,12 +200,14 @@ fn valid_dep_key(key : String) -> Bool {
///|
fn parse_manifest(text : String) -> Manifest raise OrbitError {
let o = parse_object(text, "orbit.json")
let name = jstr(o, "name", "")
let m = Manifest::{
name: jstr(o, "name", ""),
name,
version: jstr(o, "version", ""),
description: jstr(o, "description", ""),
documentation: jstr(o, "documentation", ""),
depends: jmap(o, "depends"),
conflicts: parse_conflicts(o, name),
bins: jstrs(o, "bin"),
}
if !valid_name(m.name) {
@@ -242,6 +247,7 @@ fn gen_json(g : Gen) -> Json {
o["description"] = Json::string(g.description)
o["bin"] = strs_json(g.bins)
o["depends"] = map_json(g.depends)
o["conflicts"] = map_json(g.conflicts)
Json::object(o)
}
@@ -256,6 +262,7 @@ fn installed_json(p : Installed) -> Json {
o["constraint"] = Json::string(p.constraint)
o["bin"] = strs_json(p.bins)
o["depends"] = map_json(p.depends)
o["conflicts"] = map_json(p.conflicts)
let h : Array[Json] = []
for g in p.history {
h.push(gen_json(g))
@@ -298,6 +305,7 @@ fn state_from_text(text : String) -> Map[String, Installed] raise OrbitError {
description: jstr(h, "description", ""),
bins: jstrs(h, "bin"),
depends: jmap(h, "depends"),
conflicts: jmap(h, "conflicts"),
})
_ => ()
}
@@ -314,6 +322,7 @@ fn state_from_text(text : String) -> Map[String, Installed] raise OrbitError {
constraint: jstr(o, "constraint", "*"),
bins: jstrs(o, "bin"),
depends: jmap(o, "depends"),
conflicts: jmap(o, "conflicts"),
history,
}
}
@@ -328,12 +337,15 @@ fn state_from_text(text : String) -> Map[String, Installed] raise OrbitError {
///|
test "installed and rollback descriptions round trip with legacy entries" {
let text =
#|{"packages":{"tool":{"description":"Current build","history":[{"description":"Previous build"},{}]}}}
#|{"packages":{"tool":{"description":"Current build","conflicts":{"a":"*"},"history":[{"description":"Previous build","conflicts":{"b":"<2"}},{}]}}}
let state = state_from_text(state_to_text(state_from_text(text)))
guard state.get("tool") is Some(p) else { fail("missing installed package") }
assert_eq(p.description, "Current build")
assert_eq(p.history[0].description, "Previous build")
assert_eq(p.history[1].description, "")
assert_eq(p.conflicts.get("a"), Some("*"))
assert_eq(p.history[0].conflicts.get("b"), Some("<2"))
assert_true(p.history[1].conflicts.is_empty())
}
// ---------------------------------------------------------------- context