wam_go: P3 uw-resolve (deb / Provides / alternatives) - #4218
Open
s243a wants to merge 9 commits into
Open
Conversation
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>
s243a
marked this pull request as ready for review
September 4, 2026 23:29
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Port uw-resolve P3 (Debian versions, Provides, alternatives groups,
catalog/10) onto the Go WAM runtime and shim. Branched fromclaude/peerhailer-exploratory-docs-aodas5asgrok/pkg-resolver-go-p3.Gates
tests/test_wam_go_*.pl(26)CONFORMANCE_TARGETS=javascriptBuiltin inventory
maplist/2,3,4wam_go_direct_builtinpredsort/3cmp_ver/3)functor/3,arg/3,=../2executeBuiltinstring_codes/2*List{}listFromItemsmemberchk/2UW_WAM_WARN_UNKNOWN=1(off by default) prints[wam_go] call|execute of unresolved goal NAME failed. Loweredpred_to_go_callalso falls back toexecuteBuiltinthen warn.Shim
examples/pkg_resolver/go/shim.goround-trips P3 JSON matching the wamjs encoding:deb/3both directions, alternatives groups in depends, provides 3- and 4-ary,catalog/10,blocked(..., providers([...]))/blocked(alternatives([...])).loadRichJSONLkeeps provides / alternatives for B3.Bugs beyond missing builtins
Switch default / TryMeElse skip —
pick_needindexes on Mode;classicis switch"default"with two clauses. Pc rewrite jumped to theTryMeElsethen skipped it, so virtual-only Provides never reachedprovider_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.predsort smashed A2 —
invokeAtPCwrites 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 whenevercmp_veractually ran. Corpus P3 rows survived (one matching version → less-func never ran); 40 generatedp3g*cases failed. Fix: capture A2; restore regs after each comparator;invokeGoalOncedrops leftover CPs. Probe:gpreduserintests/test_wam_go_maplist_predsort.pl.Benchmarks (B1–B3)
Index: 5k catalog is far above frozen
index_threshold(64), soresolve_layeredwrapsicat/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
vm.Regs(unchanged)0, write pathsOwned files only:
examples/pkg_resolver/go/,wam_go_target.pl,wam_go_lowered_emitter.pl,templates/targets/go_wam/, additivetests/test_wam_go_*.pl,docs/WAM_GO_STATUS.md.resolver.pluntouched.