Skip to content

engine: add --chset flag for byte (M) mode on m test/coverage/watch#2

Merged
rafael5 merged 2 commits into
mainfrom
engine-chset-byte-mode
Jun 14, 2026
Merged

engine: add --chset flag for byte (M) mode on m test/coverage/watch#2
rafael5 merged 2 commits into
mainfrom
engine-chset-byte-mode

Conversation

@rafael5

@rafael5 rafael5 commented May 30, 2026

Copy link
Copy Markdown
Contributor

What

Adds an engine-neutral --chset m|utf-8 flag to m test, m coverage, and m watch --run, threaded through engine.Options.Chset. This lets byte-oriented suites (e.g. m-stdlib's STDCSPRNG, STDB64, STDHEX, STDJSON UTF-8 decode) run the engine in byte (M) mode, where one M character == one byte.

Why

m-stdlib is byte-oriented and is only correct under ydb_chset=M. The shared m-test-engine (YottaDB) runs ydb_chset=UTF-8 by default, where byte values > 127 re-encode ($ZCHAR(200,201,202)%YDB-E-BADCHAR). That aborted STDCSPRNGTST (reported 0/0), the lone non-green suite in an otherwise fully-green core.

How

  • YDB adapter (internal/engine/ydb.go): cmd() prepends env ydb_chset=<M|UTF-8> to the argv. Works for both LocalRunner and DockerRunner (overrides the container profile default inside bash -lc) with no Runner-signature change. Mapping in engine.go ydbChset(): mM, utf-8UTF-8, ""→unset (no prefix = current behavior).
  • IRIS adapter (internal/engine/iris.go): no-op. Byte mode is inherent (IRIS round-trips all 256 byte values in-memory; no process-wide ydb_chset analog). Flag accepted only for a uniform CLI.

No regression: with the flag unset, behavior is identical to before.

Verification

Via the normal m test path (no hand docker exec), against the running m-test-engine container:

  • Byte mode (--chset m): 44 suites, 2414 assertions, 0 failed; STDCSPRNGTST 406/406 green; no failed suites.
  • Regression (no flag, default UTF-8): STDCSPRNGTST 0/0 → TESTS_FAILED (exit 3) — default unchanged.
  • Go unit tests: internal/engine green incl. new TestYdbChset / TestIrisChset; gofmt clean.

Closes Stage A of the m-stdlib follow-up tracker.

🤖 Generated with Claude Code

rafael5 and others added 2 commits June 14, 2026 09:37
Byte-oriented m-stdlib suites (STDCSPRNG, STDB64, STDHEX, STDJSON UTF-8
decode) assume one M character == one byte. On YottaDB the m-test-engine
container defaults to ydb_chset=UTF-8, under which byte ops like
$ZCHAR(200) raise %YDB-E-BADCHAR — aborting STDCSPRNGTST (0/0) even
though the library is correct under byte mode.

Add an engine-neutral --chset m|utf-8 flag, threaded through
engine.Options.Chset. The YDB-vs-IRIS difference stays in the engine
adapter (its documented role):

  - YDB: prepend `env ydb_chset=<M|UTF-8>` to the invocation argv. Works
    for both LocalRunner and DockerRunner (overrides the container
    profile default) without widening the Runner seam.
  - IRIS: no-op. Byte mode is inherent — a Unicode IRIS instance
    round-trips all 256 byte values in-memory and has no ydb_chset
    analog. The flag is accepted only to keep the CLI uniform.

Unset (the default) leaves argv untouched, so existing UTF-8 runs are
unchanged.

Verified (YDB m-test-engine / IRIS vista-iris, via the normal m test
path, no hand docker exec):
  - YDB core suite under --chset m: 44 suites, 2414 assertions, 0 failed;
    STDCSPRNGTST 406/406 green.
  - Regression: same suite without the flag → STDCSPRNGTST 0/0 (default
    behavior unchanged).
  - IRIS STDHEXTST 49/49 identical with and without --chset m (no-op).

Rebased onto post-T0.1 main: internal/engine adapters were unchanged, so
the only conflict was the testCmd struct (kept both --resident and
--chset fields); all engine.New call sites still thread Chset, and the
resident-harness path reuses the same constructed engine. Fixed an
errcheck finding in the new IRIS chset test under the current lint config.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Establish m-cli's per-repo docs/memory/ (org memory rule). Capture the
durable fact: running m-stdlib byte suites (STDCSPRNG/STDB64/STDHEX) via
m test needs --chset m on YDB; default UTF-8 aborts them; IRIS no-op.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@rafael5 rafael5 force-pushed the engine-chset-byte-mode branch from c3d8a69 to 7ea7edf Compare June 14, 2026 14:54
@rafael5 rafael5 merged commit bf525ac into main Jun 14, 2026
6 checks passed
@rafael5 rafael5 deleted the engine-chset-byte-mode branch June 14, 2026 15:03
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.

1 participant