mail-address-semantics/impl/js
tegwick 71c17fb5f9 MAS-WP-0014 T01: independent JS email side for mode contract v0.1; MCP-1..6; flow a-008
impl/js/src/email.mjs (written from CONTRACT.md + FLOWS.md): both roles,
case store, handoffs, timeouts, one-cap outbox with holding, authorization.
Passes all 22 flows from the bundle; with the JS master all 12 slave
flows (no Python contract party). Writing it found six contract gaps,
folded into the draft as MCP-1..6 (acknowledgement, details convention,
resume names the outcome, opaque case key, error table, transfer
reporting); flows now check outcome tokens, not reference prose. A
mutation check found a missing flow: a-008 (per-type master check).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Assistant: claude-code
Assistant-Model: opus
Assistant-Process: 5787@bnt-lap001
Assistant-Session: 5db26b82-138b-40cc-9856-4d5eb0f752fd
2026-10-19 13:56:53 +02:00
..
src MAS-WP-0014 T01: independent JS email side for mode contract v0.1; MCP-1..6; flow a-008 2026-10-19 13:56:53 +02:00
test MAS-WP-0009 T01: independent JS implementation (impl/js), differential test, SCP-9 2026-10-19 13:22:22 +02:00
package.json MAS-WP-0009 T01: independent JS implementation (impl/js), differential test, SCP-9 2026-10-19 13:22:22 +02:00
README.md MAS-WP-0014 T01: independent JS email side for mode contract v0.1; MCP-1..6; flow a-008 2026-10-19 13:56:53 +02:00

mas-js: second, independent MAS implementation

Written from the specification texts and fixtures only, not ported from mas_core (MAS-WP-0009). It uses Node 20+ and has zero dependencies.

Module Covers Checked by
src/parser.mjs canonical grammar, P1/P2 (address spec §4) mas-v0.2-spec/conformance/addresses.json
src/statute.mjs stand-ins (§6.3), equivalence (§8), destination transforms (§12.1), length (§13) mas-v0.2-spec/conformance/statute-aware.json
src/signing.mjs peer authentication (mode contract §7) mas-modes-v0.1-spec/conformance/auth.json
src/master.mjs outside master for email's slave role (mode contract §3.2) mas-modes-v0.1-spec/conformance/flows.json, slave setups, run against the Python email side
src/email.mjs email side in both roles: case store, handoffs, timeouts, the outbox with one cap and holding, authorization (mode contract §3 to §7) every flow in flows.json, with the Python gateway and callback stub as peers, alone or with master.mjs (MAS-WP-0014)
cd impl/js && node --test                       # the three bundles, read in place
cd ../.. && .venv/bin/pytest tests/test_js_impl.py tests/test_differential.py

src/batch.mjs evaluates parse, interpret and destination cases in bulk. tests/test_differential.py compares it with mas_core over 1500 generated local-parts per operation. Its first run found two gaps in the spec text (SCP-9).

Nothing in Python imports this code. The flow runner starts master.mjs and email.mjs as separate processes and drives them only through their loopback control APIs (mas_modes/external.py). Writing email.mjs from the contract text found six gaps (MCP-1 to MCP-6, docs/mode-contract-proposals.md). Its mutation check found a missing flow (a-008).