Skip to content

tests: OXT runtime self-test harness + docs: next-extensions plan & engine playbook#23

Merged
SethMorrowSoftware merged 2 commits into
mainfrom
claude/relaxed-cerf-816pyn
Jun 27, 2026
Merged

tests: OXT runtime self-test harness + docs: next-extensions plan & engine playbook#23
SethMorrowSoftware merged 2 commits into
mainfrom
claude/relaxed-cerf-816pyn

Conversation

@SethMorrowSoftware

@SethMorrowSoftware SethMorrowSoftware commented Jun 27, 2026

Copy link
Copy Markdown
Owner

Two post-v8 follow-ups (the plan doc joined this PR before the harness merged — independent changes, both docs/tests only).

1. tests/torrent-selftest.livecodescript — the OXT runtime self-test harness

The OXT-pass companion to the C++ smoke test: it proves the .lcb binding actually runs (foreign-decl signatures, record walkers, DataPointer round-trips) — the one layer CI can't reach. Paste into a one-card stack's stack script, reopen, and it self-builds a UI, starts a session, runs ~70 checks across 71 of 75 handlers (with real round-trips: create+seed → btFileList; add/list/remove web seed; info-hash → btFindTorrent; pause → btSessionIsPaused; keypair determinism), and shows a green/red PASS/FAIL list. The whole run is try-wrapped so a mis-declared handler is reported, not a silent halt — and it doubles as a regression tool for future ABI bumps. check-livecodescript.py now lints tests/ too, so CI gates it.

2. docs/NEXT-EXTENSIONS-PLAN.md — forward plan + engine playbook

The implementation plan for the next three native wraps — the "secure decentralized real-time" stack on top of TorrentXT:

  • libsodium (trust: signing, encryption, Argon2, BLAKE2) — do first; easiest, highest leverage.
  • ENet (reliable-UDP real-time) — second; reuses the TorrentXT pattern almost verbatim.
  • libdatachannel/libjuice (WebRTC + NAT traversal) — third; the hard one (foreign-thread callbacks → a mutex-guarded poll queue), with DHT BEP44 as the signaling channel closing the loop.

Part I is the consolidated OXT/LiveCode engine playbook — every FFI / LCB / runtime gotcha we've uncovered (the DataPointer non-bridge, no 64-bit foreign int, the out-buffer convention, the macro-comma trap, no repeat-for-each-line in LCB, constants-before-use, the ABI-sync gate, the no-unload-hook lifecycle, the single-thread playbook, …) so the next wraps don't repeat them. Parts II–IV are per-library plans (prefix/ABI, phased surface, library-specific gotchas, testing, milestones); Part V is sequencing, the shared oxtkit/ scaffolding to extract, a risk register, and a definition of done. Linked from the README.

Verification

  • check-livecodescript passes (5 files, incl. the harness); ASCII-clean; balanced handlers + try/catch; all 70 distinct bt* calls resolve.
  • No shim / ABI / record-schema change. Docs + a test stack + a one-line checker scan addition.

🤖 Generated with Claude Code

https://claude.ai/code/session_01371AXB4CUUke7enHHS8okc

claude added 2 commits June 27, 2026 13:35
Adds tests/torrent-selftest.livecodescript - the OXT-pass companion to the C++
smoke test. The smoke test proves the shim against libtorrent in CI; this proves
the .lcb BINDING actually runs (the foreign-decl signatures, the record walkers,
the Data<->Pointer buffer round-trips) - the one layer CI cannot reach, since
OXT has no headless way to compile or run .lcb.

Paste into a one-card stack's STACK script and close+reopen: it self-builds a UI,
starts a session, and runs ~70 checks, then shows a green/red PASS/FAIL list with
a summary. It exercises 71 of the 75 public handlers, including round-trips that
prove end-to-end wiring:
- create + seed a tiny temp torrent -> btFileList returns the file table
- btAddWebSeed -> btWebSeeds lists it -> btRemoveWebSeed -> gone
- btAddTracker -> btTrackers lists it
- btInfoHash -> btFindTorrent recovers the same handle
- btSessionPause -> btSessionIsPaused true -> btSessionResume
- btDhtKeypair determinism; btDhtPutImmutable -> 40-hex target
The four not auto-checked (btMoveStorage, btSetFilePriorities,
btAddTorrentWithResume, plain btAddMagnet) are destructive / async / binary-buffer
cases, noted in-app for a manual pass.

The whole run is wrapped in try/catch, so a mis-declared foreign handler is
REPORTED (which call, what error) instead of silently halting the stack - exactly
the failure this harness exists to catch, and it doubles as a regression tool for
future ABI bumps.

check-livecodescript.py now also lints tests/ by default (so CI gates the harness
too); verified statically (5 files OK, ASCII-clean, balanced handlers + try/catch,
all 70 distinct bt* calls resolve to real public handlers). Needs an OXT run to
exercise it for real - that is its whole point.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01371AXB4CUUke7enHHS8okc
…ybook

Adds docs/NEXT-EXTENSIONS-PLAN.md - the implementation plan for the next three
native wraps (the "secure decentralized real-time" stack on top of TorrentXT):
libsodium (trust), ENet (reliable-UDP real-time), libdatachannel/libjuice (WebRTC
+ NAT traversal). It opens with Part I, a consolidated ENGINE PLAYBOOK that
captures every OXT/LiveCode/LCB/FFI gotcha we have uncovered so the next wraps do
not repeat them:

- the three rules and how each library's threading model changes them (sodium has
  no threads; ENet is pump-driven; libdatachannel fires callbacks from its own
  threads -> a mutex-guarded poll queue is mandatory);
- LiveCodeScript + LCB gotchas (ASCII-only; itemDelimiter global; no
  repeat-for-each-line in LCB; constants literal-before-use; unsafe brackets;
  declarations at handler top; Boolean<->CInt; ZStringUTF8);
- the FFI contract (Data<->Pointer does not auto-bridge; the out-buffer
  bytes-written/-needed convention; no 64-bit foreign int; the getter -1 caveat);
- the C-preprocessor macro-comma trap; the exception firewall; the record codec
  and gen-tagged handle tables; the no-unload-hook lifecycle; the single-thread
  performance playbook; and the toolchain gotchas (the ABI-version sync gate,
  committed per-platform binaries, the static gates, "verified statically").

Parts II-IV are the per-library plans (prefix/ABI, phased surface, library
gotchas, testing, milestones). Part V covers sequencing, the shared oxtkit/
scaffolding to extract from TorrentXT, a risk register, and a per-library
definition of done. Linked from the README documentation list.

Plan only - no code/ABI change. ASCII-clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01371AXB4CUUke7enHHS8okc
@SethMorrowSoftware SethMorrowSoftware changed the title tests: self-building OXT runtime harness for the public API tests: OXT runtime self-test harness + docs: next-extensions plan & engine playbook Jun 27, 2026
@SethMorrowSoftware SethMorrowSoftware marked this pull request as ready for review June 27, 2026 19:16
@SethMorrowSoftware SethMorrowSoftware merged commit fa4bd3d into main Jun 27, 2026
8 checks passed
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