feat(logic): add SWI-Prolog MQI worker adapter #46

Open
lost-rob0t wants to merge 23 commits from agent/swi-mqi-worker-adapter into main
lost-rob0t commented 2026-08-21 01:02:08 +00:00 (Migrated from github.com)

Closes #45.

Implements STAR-LANG-011 Slice 1 only: the final Common Lisp SWI-Prolog MQI worker boundary.

Implemented

  • final star-logic-adapter-swi ASDF system, independent of starlang-prototype
  • exact caller-supplied swipl executable ownership with resolved path, version triplet, and SHA-256 executable backendBuildId
  • trusted bootstrap SHA-256 identity captured at backend construction and revalidated before every worker launch
  • minimum generic exact-argv subprocess lifecycle in star-process-port, including proper finite argv validation, separate stdout/stderr, termination escalation, and unconditional reap/disposal
  • hardened SWI launch argv disables ambient personal/site startup files, extension packs, and PCE before entering MQI
  • SWI MQI embedded launch on loopback with generated password capture
  • bounded pre-auth startup lines for port/password capture
  • private UTF-8 byte-count MQI framing with heartbeat handling, bounded headers/payloads, fragmented reads, malformed/truncated input, invalid UTF-8 rejection, and strict whole-value JSON validation
  • direction-correct framing: trusted outbound Prolog commands are term-terminated while inbound byte-counted SWI responses are parsed as JSON without inventing a Prolog-body terminator
  • authentication metadata and MQI protocol major/minor validation
  • StarLang-owned trusted bootstrap package and fixed identity/version handshake
  • one process-isolated worker per logic session; no pooling/reset/reuse
  • real open-logic-session, close-logic-session, and logic-backend-health
  • typed SWI adapter failure conditions and cleanup tests for authentication/bootstrap/crash paths
  • Nix-pinned SWI-Prolog plus reproducible CL socket/JSON/UTF-8 dependencies and committed flake.lock
  • pure codec/boundary tests and separate real-SWI integration tests
  • dedicated Real SWI MQI adapter GitHub Actions gate
  • FiveAM/ASDF failure propagation so failed assertions fail CI instead of producing false-green jobs
  • static boundary guards for prototype coupling, raw-goal exports, Python/Node helpers, nc/socat, caller-loadable Prolog files, arbitrary call/1, and SWI leakage into star-process-port

Verified real runtime evidence

Latest verified head: deea9e1b0092261da12d9895ac63bd31a52ad27e.

  • SWI-Prolog: 10.0.2
  • exact executable: /nix/store/976km9j9ibslx8pm0bl72ga9n3amwbq4-swi-prolog-10.0.2/lib/swipl/bin/x86_64-linux/swipl
  • backendBuildId: sha256:5a6ea44930fbe8f63f2e97f9f7f4f7adf33614b633e6d7a3f04bd9d9962efc64
  • negotiated MQI protocol: 1.0
  • star-process-port: 4/4 checks green
  • SWI codec/boundary suite: 45/45 checks green
  • real SWI integration suite: 31/31 checks green
  • startup line bounds are fixture-proven before authentication
  • invalid UTF-8 and valid-JSON-plus-trailing-garbage responses fail closed
  • exact launch argv is fixture-locked to -f none -F none --no-packs --no-pce mqi --write_connection_values=true --pending_connections=1
  • bootstrap-digest mismatch is proven to fail before spawning a worker
  • authentication failure, bootstrap-handshake mismatch, and crash-on-close all prove worker reap/disposal
  • fresh sequential sessions prove distinct process ownership
  • compiler, logic protocol, and logic IR checks pass in the SWI gate

Latest-head GitHub workflows:

  • star-lang CI — green
  • star-lang Nix — green
  • SWI logic adapter — green
  • star-lang logic IR — green
  • star-lang verification certificate — green

Not implemented

  • portable solve, solutions, or exists?
  • fact assertion/retraction or portable session facts
  • recursive/tabled semantics
  • constraints / CLP(FD)
  • StarIntel object projection
  • proofs / derivation normalization
  • cancellation escalation
  • worker pooling, reset, or reuse
  • automatic cross-backend failover
  • application actors or UserHunt

Capability honesty

The descriptor intentionally advertises no semantic profiles and no semantic capabilities. It identifies backendId = swi-prolog, exact engine/build metadata, and isolation = process, but remains ineligible for general :auto semantic selection until later fixture-backed conformance slices.

Trust boundary

The portable/public package exports no arbitrary Prolog execution API. Caller-controlled Prolog source, native predicate indicators, arbitrary call/1, and caller-selected consult/load_files paths remain outside the contract. The only native package load in this slice is the adapter-private, repository-owned, digest-locked bootstrap.

Design authority: STAR-LANG-007, approved STAR-LANG-009, and STAR-LANG-011 Slice 1.

Closes #45. Implements STAR-LANG-011 Slice 1 only: the final Common Lisp SWI-Prolog MQI worker boundary. ### Implemented - final `star-logic-adapter-swi` ASDF system, independent of `starlang-prototype` - exact caller-supplied `swipl` executable ownership with resolved path, version triplet, and SHA-256 executable `backendBuildId` - trusted bootstrap SHA-256 identity captured at backend construction and revalidated before every worker launch - minimum generic exact-argv subprocess lifecycle in `star-process-port`, including proper finite argv validation, separate stdout/stderr, termination escalation, and unconditional reap/disposal - hardened SWI launch argv disables ambient personal/site startup files, extension packs, and PCE before entering MQI - SWI MQI embedded launch on loopback with generated password capture - bounded pre-auth startup lines for port/password capture - private UTF-8 byte-count MQI framing with heartbeat handling, bounded headers/payloads, fragmented reads, malformed/truncated input, invalid UTF-8 rejection, and strict whole-value JSON validation - direction-correct framing: trusted outbound Prolog commands are term-terminated while inbound byte-counted SWI responses are parsed as JSON without inventing a Prolog-body terminator - authentication metadata and MQI protocol major/minor validation - StarLang-owned trusted bootstrap package and fixed identity/version handshake - one process-isolated worker per logic session; no pooling/reset/reuse - real `open-logic-session`, `close-logic-session`, and `logic-backend-health` - typed SWI adapter failure conditions and cleanup tests for authentication/bootstrap/crash paths - Nix-pinned SWI-Prolog plus reproducible CL socket/JSON/UTF-8 dependencies and committed `flake.lock` - pure codec/boundary tests and separate real-SWI integration tests - dedicated `Real SWI MQI adapter` GitHub Actions gate - FiveAM/ASDF failure propagation so failed assertions fail CI instead of producing false-green jobs - static boundary guards for prototype coupling, raw-goal exports, Python/Node helpers, `nc`/`socat`, caller-loadable Prolog files, arbitrary `call/1`, and SWI leakage into `star-process-port` ### Verified real runtime evidence Latest verified head: `deea9e1b0092261da12d9895ac63bd31a52ad27e`. - SWI-Prolog: `10.0.2` - exact executable: `/nix/store/976km9j9ibslx8pm0bl72ga9n3amwbq4-swi-prolog-10.0.2/lib/swipl/bin/x86_64-linux/swipl` - `backendBuildId`: `sha256:5a6ea44930fbe8f63f2e97f9f7f4f7adf33614b633e6d7a3f04bd9d9962efc64` - negotiated MQI protocol: `1.0` - `star-process-port`: 4/4 checks green - SWI codec/boundary suite: 45/45 checks green - real SWI integration suite: 31/31 checks green - startup line bounds are fixture-proven before authentication - invalid UTF-8 and valid-JSON-plus-trailing-garbage responses fail closed - exact launch argv is fixture-locked to `-f none -F none --no-packs --no-pce mqi --write_connection_values=true --pending_connections=1` - bootstrap-digest mismatch is proven to fail before spawning a worker - authentication failure, bootstrap-handshake mismatch, and crash-on-close all prove worker reap/disposal - fresh sequential sessions prove distinct process ownership - compiler, logic protocol, and logic IR checks pass in the SWI gate Latest-head GitHub workflows: - `star-lang CI` — green - `star-lang Nix` — green - `SWI logic adapter` — green - `star-lang logic IR` — green - `star-lang verification certificate` — green ### Not implemented - portable `solve`, `solutions`, or `exists?` - fact assertion/retraction or portable session facts - recursive/tabled semantics - constraints / CLP(FD) - StarIntel object projection - proofs / derivation normalization - cancellation escalation - worker pooling, reset, or reuse - automatic cross-backend failover - application actors or UserHunt ### Capability honesty The descriptor intentionally advertises no semantic profiles and no semantic capabilities. It identifies `backendId = swi-prolog`, exact engine/build metadata, and `isolation = process`, but remains ineligible for general `:auto` semantic selection until later fixture-backed conformance slices. ### Trust boundary The portable/public package exports no arbitrary Prolog execution API. Caller-controlled Prolog source, native predicate indicators, arbitrary `call/1`, and caller-selected `consult`/`load_files` paths remain outside the contract. The only native package load in this slice is the adapter-private, repository-owned, digest-locked bootstrap. Design authority: STAR-LANG-007, approved STAR-LANG-009, and STAR-LANG-011 Slice 1.
This pull request has changes conflicting with the target branch.
  • flake.nix
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin agent/swi-mqi-worker-adapter:agent/swi-mqi-worker-adapter
git switch agent/swi-mqi-worker-adapter

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch main
git merge --no-ff agent/swi-mqi-worker-adapter
git switch agent/swi-mqi-worker-adapter
git rebase main
git switch main
git merge --ff-only agent/swi-mqi-worker-adapter
git switch agent/swi-mqi-worker-adapter
git rebase main
git switch main
git merge --no-ff agent/swi-mqi-worker-adapter
git switch main
git merge --squash agent/swi-mqi-worker-adapter
git switch main
git merge --ff-only agent/swi-mqi-worker-adapter
git switch main
git merge agent/swi-mqi-worker-adapter
git push origin main
Sign in to join this conversation.
No description provided.