Skip to content

wam_go: P3 uw-resolve (deb / Provides / alternatives) - #4218

Open
s243a wants to merge 9 commits into
claude/peerhailer-exploratory-docs-aodas5from
grok/pkg-resolver-go-p3
Open

wam_go: P3 uw-resolve (deb / Provides / alternatives)#4218
s243a wants to merge 9 commits into
claude/peerhailer-exploratory-docs-aodas5from
grok/pkg-resolver-go-p3

Conversation

@s243a

@s243a s243a commented Sep 4, 2026

Copy link
Copy Markdown
Owner

Port uw-resolve P3 (Debian versions, Provides, alternatives groups, catalog/10) onto the Go WAM runtime and shim. Branched from claude/peerhailer-exploratory-docs-aodas5 as grok/pkg-resolver-go-p3.

Gates

Gate Result
Corpus 51/51 vs SWI, wall 0.053s
Differential 2600 cases, 0 divergences, 0 crashes — SWI 1.671s / Go 17.179s
Cut 35/35, 0 refused-loudly
Frameless ITE + five D51 probes green
Full tests/test_wam_go_*.pl (26) green
Shared-lane JS suites + CONFORMANCE_TARGETS=javascript green
cli_args 17/17 + wamjs 5067/0/0
pkg_resolver wamjs corpus 51/51

Builtin inventory

Name Found Implemented Classified
maplist/2,3,4 missing yes — meta-calls user preds wam_go_direct_builtin
predsort/3 missing (cmp_ver/3) yes yes
functor/3, arg/3, =../2 implemented, unclassified (A3) already in executeBuiltin now classified
string_codes/2 empty was *List{} empty via listFromItems already classified
memberchk/2 already OK

UW_WAM_WARN_UNKNOWN=1 (off by default) prints [wam_go] call|execute of unresolved goal NAME failed. Lowered pred_to_go_call also falls back to executeBuiltin then warn.

Shim

examples/pkg_resolver/go/shim.go round-trips P3 JSON matching the wamjs encoding: deb/3 both directions, alternatives groups in depends, provides 3- and 4-ary, catalog/10, blocked(..., providers([...])) / blocked(alternatives([...])). loadRichJSONL keeps provides / alternatives for B3.

Bugs beyond missing builtins

  1. Switch default / TryMeElse skippick_need indexes on Mode; classic is switch "default" with two clauses. Pc rewrite jumped to the TryMeElse then skipped it, so virtual-only Provides never reached provider_candidate. Fix: label-form default falls through; Pc form keeps the jump when the target is a try/retry head. Probe: tests/test_wam_go_switch_default_chain.pl.

  2. predsort smashed A2invokeAtPC writes Order/X/Y into A0–A2 and does not restore them on success. Unify(getReg(2), Sorted) then compared a version to a list, so predsort failed whenever cmp_ver actually ran. Corpus P3 rows survived (one matching version → less-func never ran); 40 generated p3g* cases failed. Fix: capture A2; restore regs after each comparator; invokeGoalOnce drops leftover CPs. Probe: gpreduser in tests/test_wam_go_maplist_predsort.pl.

Benchmarks (B1–B3)

Bench Number
B1 0.053s, 51/51
B2 2600/0 — SWI 1.671s / Go 17.179s
B3 load 0.065s / resolve 10.620s, same 10-package selection as D51 SWI

Index: 5k catalog is far above frozen index_threshold(64), so resolve_layered wraps icat/3 (cannot toggle from owned files). D51 pre-index Go B3 was 11.0s; with-index is 10.62s (~1.04×). wamjs saw 9.2× on the same G1 trees — Go's interpreted index build (~45 WAM instructions/row × 5k) almost cancels the lookup win.

Residuals

  • A2 X↔Y alias on flat vm.Regs (unchanged)
  • A3: unclassified builtins still fail the query; the warn knob makes the next miss loud
  • A4: no string type
  • Lowered-lane “call then tail-execute loses output binding”
  • bagof witness grouping
  • Frozen resolver: Breaks≡Conflicts, Pre-Depends, Recommends/Suggests, multiarch, epoch display 0, write paths

Owned files only: examples/pkg_resolver/go/, wam_go_target.pl, wam_go_lowered_emitter.pl, templates/targets/go_wam/, additive tests/test_wam_go_*.pl, docs/WAM_GO_STATUS.md. resolver.pl untouched.

Open in Web Open in Cursor 

cursoragent and others added 9 commits September 4, 2026 23:12
Classify and implement maplist/2,3,4 (user-pred meta-call), predsort/3,
and previously-unclassified functor/3, arg/3, =../2. Call/Execute fall
back to executeBuiltin and emit UW_WAM_WARN_UNKNOWN diagnostics.
string_codes/2 empty results go through listFromItems. The Go shim
round-trips deb versions, alternatives, provides, and catalog/10.

Co-authored-by: johns243a <johns243a@gmail.com>
WAM text still says `call predsort/3`; the interpreter lane rewrites
that to BuiltinCall but the lowered emitter did a Labels-only lookup.
Unknown goals now try executeBuiltin and honor UW_WAM_WARN_UNKNOWN.
Regenerated the committed Go WAM tables from the current resolver
(D59 catalog index included).

Co-authored-by: johns243a <johns243a@gmail.com>
SwitchOnConstant treated pick_need's classic key as default and
indexedClauseBodyStart skipped TryMeElse, so only the real-package
clause ran. Virtual-only Provides (3 corpus rows) then failed even
though provider_candidate/5 succeeded in isolation. Default now
falls through so every clause that shares the key is tried.

Co-authored-by: johns243a <johns243a@gmail.com>
resolveInstructions rewrites SwitchOnConstant to the Pc form.
indexedClauseBodyStart then skipped the default TryMeElse, so
pick_need never reached the provider clause. Chain-head targets
now execute the try/retry sequence. Corpus 51/51.

Co-authored-by: johns243a <johns243a@gmail.com>
predsort's cmp_ver/3 → version_lt/2 comparator is ITE-heavy. Leftover
choice points stayed on the stack so a later resolve failure backtracked
into a stale comparator and aborted generated P3 catalogs (40 p3g*
divergences). invokeGoalOnce keeps success bindings and truncates CPs.

Co-authored-by: johns243a <johns243a@gmail.com>
go run lives under cmd/run, so 2>../warn.err landed in cmd/ while the
probe read proj/warn.err.

Co-authored-by: johns243a <johns243a@gmail.com>
invokeAtPC writes Order/X/Y into A0–A2 and does not restore them on
success. Unify(getReg(2), Sorted) then compared a version to a list, so
predsort failed whenever cmp_ver actually ran. Single-element lists and
the compare/3 short-circuit never hit this — which is why the 51-row
corpus stayed green while the 40 generated P3 cases failed.

Co-authored-by: johns243a <johns243a@gmail.com>
Corpus 51/51, differential 2600/0, B3 with-index 10.62s vs D51
pre-index 11.0s. Documents the switch-default and predsort A2 bugs
plus UW_WAM_WARN_UNKNOWN.

Co-authored-by: johns243a <johns243a@gmail.com>
Co-authored-by: johns243a <johns243a@gmail.com>
@cursor cursor Bot changed the title wam_go P3: maplist/predsort runtime + pkg_resolver Go shim wam_go: P3 uw-resolve (deb / Provides / alternatives) Sep 4, 2026
@s243a
s243a marked this pull request as ready for review September 4, 2026 23:29
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