Skip to content

JS WAM persistent indexed fact stores (GP-LMDB) - #4211

Open
s243a wants to merge 5 commits into
grok/wamjs-perf2from
grok/wamjs-lmdb
Open

JS WAM persistent indexed fact stores (GP-LMDB)#4211
s243a wants to merge 5 commits into
grok/wamjs-perf2from
grok/wamjs-lmdb

Conversation

@s243a

@s243a s243a commented Sep 1, 2026

Copy link
Copy Markdown
Owner

Add persistent indexed P/2 fact stores for the JavaScript WAM, extending D27 CallFactStream rather than forking it.

Option syntax

  • source(P/2, file(Path)) — D27 in-memory TSV/CSV/JSONL. Emit is unchanged ({ path }, no kind).
  • source(P/2, indexed(Prefix)) — backend B (default capability, zero deps). Files: Prefix.data + Prefix.idx.
  • source(P/2, lmdb(Dir)) — backend A (opt-in lmdb npm package). Dir is an LMDB environment directory (noSubdir: false, so names like edges.lmdb stay directories).

Unbound A1 enumerates in source-file order. Bound A1 is an indexed lookup. Other-args-bound filters streamed candidates. Cells go through parse_term (D34/D37).

Backend B

Sorted key table + binary search (Buffer.compare). Build: node scripts/js_wam/uw_fact_index.js build <tsv|jsonl> <prefix>. Format spec is in docs/WAM_JAVASCRIPT_STATUS.md. This is LMDB-style (persistent + indexed + seek-based), not LMDB.

Bound-lookup proof on the 5004-row fixture: fact_io bytes_read=506 data_size=992872 n_reads=29.

Backend A

Lazy createRequire("lmdb") only when an lmdb(...) source is used. Missing package is one loud error (npm install lmdb); never falls back to B. Not a repo package.json dependency. The lmdb-gated tests ran in this environment (npm install --prefix /tmp/uw-lmdb-pkg lmdb).

Shared-semantics: SWI probekey → [alpha,beta]; Node backends B and A both print shared_ok / true.

Tests

  • B unconditional (thousands of rows, bound/unbound/filter, bytes-read ≪ file size).
  • A gated on the package loading; missing-package path always tested (UW_LMDB_FORCE_MISSING=1).
  • Shared-semantics probe: same fixture through B and A.
  • builtins / lowered / 48 local conformance wrappers / corpus 17/17 / differential 0/0.

Out of scope

Multi-arg secondary indexes and write paths.

docs/WAM_FLEET_GAPS.md is not edited; the JS status doc records that this target now has LMDB while the fleet doc still lists it as Lua-matching out-of-scope.

Open in Web Open in Cursor 

cursoragent and others added 5 commits September 1, 2026 20:18
Extend D27 CallFactStream with source(P/2, indexed(Prefix)) (zero-dep
sorted key table) and source(P/2, lmdb(Dir)) (lazy npm lmdb, loud
missing-package error, never a silent fallback). file(Path) emit is
unchanged. Ship uw_fact_index / uw_fact_lmdb builders and document
the on-disk format, key encoding, and optional-dependency policy.

Co-authored-by: johns243a <johns243a@gmail.com>
lmdb-js treats a path with an extension as the data file; edges.lmdb as
a directory then throws EISDIR. Both the loader and runtime now open an
environment directory. Bound-lookup stats also record n_reads.

Co-authored-by: johns243a <johns243a@gmail.com>
Co-authored-by: johns243a <johns243a@gmail.com>
sub_string(..., 12, ...) skipped the leading digit of 506, so the proof
printed 6. Require bytes_read > 200 so a mis-parse cannot pass.

Co-authored-by: johns243a <johns243a@gmail.com>
Co-authored-by: johns243a <johns243a@gmail.com>
@s243a
s243a marked this pull request as ready for review September 1, 2026 20:24
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