feat: multi-tape and nondeterministic Turing machines #76

Merged
Ghost merged 7 commits from feat/tm-extend into master 2026-10-24 20:22:03 -05:00

Extends the Tm contract as authorized in #73 (one-day-old service, zero users — the new shape becomes the frozen one).

Core: Tm.tapes 1..=4; transitions state → read-tuple → action list (list > 1 = nondeterministic); deterministic fast path + PDA-style BFS (visited set, explored counter, 50k config cap, truncated = inconclusive, shortest accepting path); serde shims accept old single-action payloads; grade charges BFS explored 1:1 and det steps ÷16.
API: same /api/v1/tm/run; openapi.yaml + schema.d.ts updated; multi-tape/ND round-trip tests.
Web: tapes N DSL directive, per-tape transition lines, repeated LHS = ND; dynamic meta ({n} TAPES · DET/ND); per-tape tape rows; explored/truncated display; per-tape diagram labels; bilingual keys.
Dojo: 3 verified library entries — {ww} and palindromes via 2 tapes, one ND decider for aⁿbⁿ — with a BFS mini-simulator oracle test (all 9 entries vs oracle, 8098 assertions).

cargo fmt/clippy/test green (152 rust tests); svelte-check/test/build green (51 web tests); end-to-end validated all 9 library machines against the live engine over exhaustive words ≤ 6 with zero mismatches.

Closes #73.

Extends the `Tm` contract as authorized in #73 (one-day-old service, zero users — the new shape becomes the frozen one). **Core:** `Tm.tapes` 1..=4; transitions `state → read-tuple → action list` (list > 1 = nondeterministic); deterministic fast path + PDA-style BFS (visited set, explored counter, 50k config cap, truncated = inconclusive, shortest accepting path); serde shims accept old single-action payloads; grade charges BFS explored 1:1 and det steps ÷16. **API:** same `/api/v1/tm/run`; openapi.yaml + schema.d.ts updated; multi-tape/ND round-trip tests. **Web:** `tapes N` DSL directive, per-tape transition lines, repeated LHS = ND; dynamic meta ({n} TAPES · DET/ND); per-tape tape rows; explored/truncated display; per-tape diagram labels; bilingual keys. **Dojo:** 3 verified library entries — {ww} and palindromes via 2 tapes, one ND decider for aⁿbⁿ — with a BFS mini-simulator oracle test (all 9 entries vs oracle, 8098 assertions). cargo fmt/clippy/test green (152 rust tests); svelte-check/test/build green (51 web tests); end-to-end validated all 9 library machines against the live engine over exhaustive words ≤ 6 with zero mismatches. Closes #73.
Tm gains a tapes field (1..=4, default 1) and transitions become
state -> read-tuple -> action lists; TmAction carries per-tape writes
and moves. Old single-action payloads {write, move, to} still parse via
serde shims. Single-tape single-action machines keep the exact step
loop; anything else runs a PDA-style BFS over configurations (canonical
visited keys doubling as a parent map, shortest accepting path as the
trace, reject branches pruned, 50k-configuration cap). Grading charges
searched runs 1:1 per configuration and deterministic ones per step as
before.

Refs #73.

Co-Authored-By: GLM (OpenCode) <dev@yhkze.net>
openapi.yaml: Tm.tapes, action-list transitions and read-tuples,
TmRunResult.explored/truncated, per-tape trace windows; old
single-action payloads documented as accepted on input. New round-trip
tests for a 2-tape and a nondeterministic TM; the existing one asserts
the deterministic path's explored/truncated counters.

Refs #73.

Co-Authored-By: GLM (OpenCode) <dev@yhkze.net>
schema.d.ts regenerated from openapi.yaml. Minimal compile fixes only:
parseTm emits one-element action lists with a tapes field, the diagram
and tape renderer read the new writes/moves and per-tape trace windows,
and the dojo TM-library simulator indexes the first action. Deeper
multi-tape/nondeterminism UI comes later.

Refs #73.

Co-Authored-By: GLM (OpenCode) <dev@yhkze.net>
Records the 1-4 tapes bound and the 50k-configuration search cap in the
limits table, notes the grading unit change, and replaces the #73
in-flight pointer with a note that the extension landed (old
single-action payloads still accepted on input).

Refs #73.

Co-Authored-By: GLM (OpenCode) <dev@yhkze.net>
parseTm gains a 'tapes N' directive (1..=4, default 1) and, for
multi-tape machines, transition lines with one read symbol per tape on
the left and per-tape 'write, move' groups separated by '|' on the
right. Repeated left-hand sides now collect into the action list in all
modes (nondeterminism); only fully identical lines are rejected, as a
typo guard. The tape count is inferred from the first transition line
when no directive is present.

The machines page derives its panel meta from the edited text (tape
count with localized plural, deterministic vs nondeterministic), renders
one labelled tape row per tape, shows the explored-configuration count
for search runs, and reports traceless nondeterministic outcomes
(reject / truncated timeout). diagramFa labels multi-tape edges per
tape ('1: a→X, R | 2: _→_, L').

Refs #73.

Co-Authored-By: GLM (OpenCode) <dev@yhkze.net>
feat(dojo): verified multi-tape and ND library entries
Some checks failed
ci / web (pull_request) Successful in 37s
ci / image (oven/bun:1.4.2-debian=docker-image://git.yhkze.net/actions/bun:1.4.2-debian node:22-bookworm-slim=docker-image://git.yhkze.net/actions/node:22-bookworm-slim , web, deploy/web.Dockerfile, rgxr-web) (pull_request) Has been cancelled
ci / image (rust:1-slim-bookworm=docker-image://git.yhkze.net/actions/rust:1-slim-bookworm debian:bookworm-slim=docker-image://git.yhkze.net/actions/debian:bookworm-slim , ., deploy/api.Dockerfile, rgxr-api) (pull_request) Has been cancelled
ci / rust (pull_request) Has been cancelled
b83e80e829
Three new reference deciders, each checked by tmLibrary.test.ts against
its member oracle over every word of length <= 7: { ww } on two tapes
(copy, find the middle at double speed, compare the halves),
palindromes on two tapes (copy, compare against the reversed copy), and
{ a^n b^n } on a single nondeterministic tape (each pass marks an a and
guesses which b to pair it with). The test's mini-simulator now mirrors
the engine: multi-tape configurations and a capped breadth-first search
with visited-set pruning.

Entries whose reference is not a deterministic single-tape machine
carry full taskEn/taskEs wording; the offline bank and the sensei's
library fallback use it, and the sensei prompt asks for 'a Turing
machine' instead of prescribing the shape.

Refs #73.

Co-Authored-By: GLM (OpenCode) <dev@yhkze.net>
ci: run svelte-check in the web job
All checks were successful
ci / web (pull_request) Successful in 1m20s
ci / rust (pull_request) Successful in 3m10s
ci / image (oven/bun:1.4.2-debian=docker-image://git.yhkze.net/actions/bun:1.4.2-debian node:22-bookworm-slim=docker-image://git.yhkze.net/actions/node:22-bookworm-slim , web, deploy/web.Dockerfile, rgxr-web) (pull_request) Has been skipped
ci / image (rust:1-slim-bookworm=docker-image://git.yhkze.net/actions/rust:1-slim-bookworm debian:bookworm-slim=docker-image://git.yhkze.net/actions/debian:bookworm-slim , ., deploy/api.Dockerfile, rgxr-api) (pull_request) Has been skipped
cbd7693d3c
Enforces that es.ts covers every en.ts key — the Spanish guarantee
currently lives only in local checks.

Co-Authored-By: GLM (OpenCode) <dev@yhkze.net>
Ghost merged commit 03ec216f5d into master 2026-10-24 20:22:03 -05:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
k8s-services/rgxr!76
No description provided.