Skip to content

wam_go: compile uw-resolve (pkg_resolver) with cut-semantics audit - #4215

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

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

Conversation

@s243a

@s243a s243a commented Sep 3, 2026

Copy link
Copy Markdown
Owner

Compile the frozen P0.5 package resolver through wam_go with the same bar as wam_javascript: SWI-oracled corpus, seeded differential, and a 35-probe cut-semantics suite.

Runtime fixes (symptom → cause → fix → probe)

  1. unknown field Val on switch_on_structure → ConstCase {Val,Label} used for structs → emit {Functor, Label}tests/test_wam_go_switch_on_structure.pl
  2. resolve_pending([], Acc, Acc) never matched → empty *List ≠ interned []valueEquals + listFromItemstests/test_wam_go_empty_list_constant.pl
  3. sort kept one Name-Ver pair → compounds compared equal → recursive compareTermstests/test_wam_go_sort_compounds.pl
  4. removal_orphans*[] → shallow findall copy → freezeTermtests/test_wam_go_findall_freeze.pl
  5. call/1 missing label → not is_builtin_predBuiltinCall + opaque cut floor → cut p09/p10
  6. bagof/setof → call bagof/3inline_bagof_setof(true) → cut p14/p15
  7. bagof L stayed __R200 → 4-arg begin_aggregate dropped as TODO → accept 4th witness-reg arg → cut p14/p15
  8. Extra solutions lost / p29 printed 1 not ok → Y-save extra-pop on retry; !/0 used caller EnvFrame.CutB0 → §9 Call/Execute/Proceed + CP snapshots; !/0 uses PendingB0cut 35/35
  9. B3 resolve_layered unified Acc with []allocVarId climbed through driver Idx 10000+i and aliased Bindings[10002] with Selection → skip 10000–10999; shim uses vm.allocVarId()tests/test_wam_go_varid_collision.pl

Acceptance

Gate Result
run_corpus_go.sh 39/39 vs SWI (dump has 39 rows; plunit is 38)
run_differential_go.sh 2400 cases, 0 divergences, 0 crashes
tests/test_wam_go_cut_semantics.pl 35/35 vs SWI, 0 refused-loudly
Pre-existing tests/test_wam_go_*.pl green (23 files, including additive probes)
Frozen JS suites + CONFORMANCE_TARGETS=javascript green
cli_args 17/17 + differential 5067/0/0
pkg_resolver SWI plunit + wamjs corpus + term diff 38 tests / 39/39 / 2400/0

B1–B3 (this VM: SWI 9.0.4, Go 1.22.2)

  • B1 corpus Go binary: 0.024s wall, 39/39. go build (clean): 0.168s (not in B1).
  • B2 differential: Go 8.869s, SWI 1.331s, 2400/0.
  • B3 5k resolve_layered (seed 0xc0ffee01): Go load 0.060s / resolve 4.604s, 10-package selection matching SWI (p1-v(1,0,0), p10, p12, p2, p3, p30, p4, p5, p6, p7). SWI same catalog: load 0.428s / resolve 0.008s.

Residuals

  • A2 encoding X101≡Y1 unchanged. Call Y-save is a partial mitigation.
  • A3 unclassified builtins still fail silently; call/1 is classified.
  • call/1 extra solutions first-solution for nested user goals.
  • bagof witness grouping not implemented (empty witness list is correct for p14/p15).
  • Var-id skip window 10000–10999 is a shim-friendly hole, not a general heap allocator; the shim now uses vm.allocVarId().
  • No cljs/ or rust/ (concurrent rounds).
Open in Web Open in Cursor 

cursoragent and others added 5 commits September 3, 2026 02:28
… inline

uw-resolve through wam_go forced several runtime bugs:

- switch_on_structure cases now emit Functor/Label (not ConstCase Val)
- empty *List unifies with interned [] (GetConstant of nil)
- compareTerms orders compounds so ISO sort/2 keeps distinct pairs
- freezeTerm copies findall templates out of Clone() Bindings
- call/1 is a classified builtin with an opaque cut floor
- go_compile_predicate_to_wam opts into inline_bagof_setof(true)

Each of the first four has a dedicated probe; call/1 and bagof are
covered by the cut-semantics suite.

Co-authored-by: johns243a <johns243a@gmail.com>
SWI-oracled prefer_wam(true) driver matching the JS suite's probe
sources. Go has no emit_mode; lowering-refusal tests are N/A.
Probes that cannot compile must refuse loudly (none currently).

Co-authored-by: johns243a <johns243a@gmail.com>
JSON shim is term IO only. build.sh regenerates the Go WAM project
from resolver.pl; generated sources are committed. Corpus and
seeded differential drivers compare against SWI; scale probe times
resolve_layered on the 5k catalog.

Co-authored-by: johns243a <johns243a@gmail.com>
A2 remains structural (not hit). A3 residual remains for unclassified
builtins; call/1 is now classified. Cut suite is prefer_wam(true) only.

Co-authored-by: johns243a <johns243a@gmail.com>
Call pushes B0 and Y-registers; Execute rebases B0 without pushing
(LCO). Proceed pops both. !/0 truncates to PendingB0, not the caller's
EnvFrame.CutB0, so a no-Allocate neck-cut cannot steal caller
alternatives. Choice points restore the full Y-save and cut_stack
snapshots so a first-success Proceed does not extra-pop on retry.

Also accept 4-arg begin_aggregate (bagof/setof witness register) so
EndAggregate is not skipped.

Co-authored-by: johns243a <johns243a@gmail.com>
@cursor cursor Bot changed the title wam_go: compile uw-resolve (P0.5) with cut-semantics audit wam_go: compile uw-resolve (pkg_resolver) with cut-semantics audit Sep 3, 2026
Commit the generated state.go/runtime.go after the §9 cut-barrier
change. Fill uw-resolve README and WAM_GO_STATUS with corpus 39/39,
differential 2400/0, cut 35/35, and the honest B3 residual
(matching_deps/4 fails past ~1463 depends).

Co-authored-by: johns243a <johns243a@gmail.com>
@s243a
s243a marked this pull request as ready for review September 3, 2026 02:56
cursoragent and others added 2 commits September 3, 2026 03:11
Driver-minted output Unbounds use Idx 10000+i. After ~9000
PutVariable cells, NextVarId walked into that window and
Bindings[10002] aliased resolve_layered's Selection, so sort/2
unified a real Acc with [] on the 5k catalog.

Co-authored-by: johns243a <johns243a@gmail.com>
Regenerate the committed Go WAM runtime so allocVarId jumps over
Idx 10000-10999 (matching the template), cut the varid probe after
write_wam_go_project, and replace the matching_deps residual with
measured B3 numbers: Go load 0.060s / resolve 4.604s, same 10-package
selection as SWI.

Co-authored-by: johns243a <johns243a@gmail.com>
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