Skip to content

uw-resolve P0: frozen-base package resolver (SWI oracle + wamjs) - #4212

Open
s243a wants to merge 4 commits into
grok/wamjs-lmdbfrom
grok/pkg-resolver
Open

s243a wants to merge 4 commits into
grok/wamjs-lmdbfrom
grok/pkg-resolver

Conversation

@s243a

@s243a s243a commented Sep 2, 2026

Copy link
Copy Markdown
Owner

Incubates uw-resolve P0 under examples/pkg_resolver/: a Prolog package resolver that understands a frozen immutable base (Puppy/Woof-CE style). Stock apt cannot reason about that boundary. One set of relations, four queries; SWI is the oracle; the same spec compiles through wam_javascript (emit_mode(mixed)).

Model

Catalog is data (no assert/retract):

catalog(Packages, Depends, Conflicts, Base, Installed, Requested)

Versions v(Major, Minor, Patch) lexicographic. Constraints: any, eq(V), gte(V), lt(V), range(Lo, Hi) (Lo inclusive, Hi exclusive). No Debian epoch/tilde in P0.

Determinism: resolve* commit to the first search solution (prefer base-satisfied, else highest version). Selections/manifests sorted. explain_blocked enumerates; removal_orphans returns one sorted list.

Queries

  1. resolve/3 — classic closure; may upgrade a base package
  2. resolve_layered/3 — satisfiable without touching the base; explain_blocked names the held ceiling
  3. layer_closure/3 — non-base dependency closure, deps before dependents
  4. removal_orphans/3 — PPM-style trim; base packages are never orphans

wam_javascript fixes this program forced

  1. Ground-fact memo on projectionspackages/2 interned the first catalog as the answer. Drop get_value/get_variable from the intern-once allowlist. Probe: projection_not_ground_fact_memo.
  2. Naked member/2 must stay interpreted — lowered Call is first-solution. Probe: t4_does_not_steal_search_cps.
  3. !/0 wiped all choice points — a lowered helper with a neck cut (satisfies/2) stole the caller's member/2 alternatives, so version backtracking and explain_blocked failed. Neck cut now respects the Call-frame barrier. Probe: neck_cut_does_not_steal_caller_cps.

No edits to wam_target.pl, wam_text_parser.pl, harness/registry/matrix/glue, or examples/cli_args/. Frozen examples/cli_args/wamjs/js/ was not regenerated.

Acceptance

  • swipl -q -g test_resolver -t halt examples/pkg_resolver/test_resolver.pl → 22/22
  • bash examples/pkg_resolver/wamjs/run_corpus_wamjs.sh23/23 matched SWI
  • bash examples/pkg_resolver/run_differential.sh2200 cases, 0 divergences, 0 crashes. timing: swi 1.014s wamjs 6.711s
  • preexisting suites still green:
    • tests/test_wam_javascript_lowered.pl (incl. 3 new probes)
    • tests/test_wam_javascript_builtins.pl
    • tests/test_wam_javascript_fact_sources.pl
    • CONFORMANCE_TARGETS=javascript on tests/test_wam_cross_target_conformance.pl (no javascript adapter registered; opt-in no-op as on the lane tip)
    • cli_args corpus 17/17 (frozen js/, not rebuilt)
    • cli_args differential 5067 lines, 0 divergences, 0 message mismatches (oracle 0.056s, wamjs 2.176s)

UW_PROFILE=1 on backtrack_conflict_deeper: 38 backtracks, maxCP 7, ~14 ms including profiler. Differential is ~3 ms/case on the mixed build; search stays interpreted (resolve_pending, candidates_high_first, pick) while list walks (matching_versions, matching_deps, satisfies) lower.

Deferred

Debian epoch/tilde, Provides/virtual packages, GP-LMDB catalog backend (P2), pkg-style CLI via examples/cli_args.

Open in Web Open in Cursor 

cursoragent and others added 4 commits September 2, 2026 01:52
Brings docs/proposals/PACKAGE_MANAGER_LOGIC_PROPOSAL.md from the
exploratory-docs branch as the frozen-base resolver's design brief.

Co-authored-by: johns243a <johns243a@gmail.com>
packages/2-style projections interned the first catalog as a ground
fact; drop get_value/get_variable from the intern-once allowlist.

Lowering a predicate that uses member/2 (or a callee that does) kept
only the first witness; leave those on the interpreter.

!/0 wiped state.cps entirely, so a lowered helper with a neck cut
(satisfies/2) stole the caller's member alternatives. Cut now respects
the Call-frame barrier.

Probes: projection_not_ground_fact_memo, t4_does_not_steal_search_cps,
neck_cut_does_not_steal_caller_cps.

Co-authored-by: johns243a <johns243a@gmail.com>
Spec (resolver.pl) and contract corpus (test_resolver.pl) cover classic
resolve, layered resolve without touching the base, explain_blocked
ceilings, layer_closure manifests, and removal_orphans. Catalog is
data; SWI is the oracle.

wamjs/ compiles the spec through wam_javascript mixed emit. The shim
does term↔JSON only. Seeded differential (≥2000 catalogs) gates
selection, explanation set, and orphan set against SWI.

Co-authored-by: johns243a <johns243a@gmail.com>
SWI json_write_dict sorts dict keys; the shim inserted name/needs/base_has.
Corpus and differential now stable-stringify so blocked/3 terms compare.

Co-authored-by: johns243a <johns243a@gmail.com>
@s243a
s243a marked this pull request as ready for review September 2, 2026 02:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants