module_id: refuse path components longer than 255 UTF-8 bytes (#97 prerequisite)
Option 2 from #97, split out on its own because placement is blocked behind the forbid(unsafe_code) question I raised on the issue — and because this stands alone: it fixes a latent store-path failure whether or not placement ever ships.
What
module_id_path_hazard (registry.rs) and its TypeScript twin assertPathSafeModuleId (clients/store/src/derivation.ts) both gain one clause: refuse an id longer than 255 UTF-8 bytes, reason is longer than 255 bytes, identical string on both sides.
Framed as a path-component limit, per your ruling, not a cgroup limit. The comments say why it is not a new restriction: module_id is already one literal component in the store-path derivation, so a 256-byte id fails to get a store directory today on any platform with NAME_MAX 255. This states the clause that was always implicit.
Bytes, not characters — and the test that can tell
NAME_MAX counts bytes. Rust str::len() is bytes; JavaScript String.length is UTF-16 code units. A naive moduleId.length <= 255 in TS accepts an id that mkdir rejects, and an ASCII-only test suite cannot see the difference — both implementations agree on every ASCII vector while disagreeing on real input.
So the fixture carries a straddle case: 64 emoji = 128 UTF-16 code units, 256 UTF-8 bytes. It must be refused. That single vector is what separates a correct implementation from a plausible one.
Fixture
Your comment named crates/subc-core/tests/fixtures/store_paths_golden.json; that file does not exist. What exists is clients/store/tests/golden/storage_vectors.json — TS-side, positive vectors only, no refusal cases anywhere — and the Rust-authored data_home_resolution.json that the TS suite already reads by relative require. The refusal predicate had nothing binding the two languages.
Rather than invent a scheme, this follows that existing precedent: a new Rust-authored crates/subc-core/tests/golden/module_id_path_component_refusals.json, read by Rust via include_str! and by TS via the same relative require. One file, two readers — so the two implementations cannot drift apart silently. Vectors: ASCII 255 accepted, ASCII 256 refused, and the emoji straddle.
Verification
Mutation-proved in both languages, each reddening by name:
registry.rs:340: assertion `left == right` failed:
shared refusal vector "ascii_256_bytes_refused" diverged
registry.rs:340: assertion `left == right` failed:
shared refusal vector "emoji_256_utf8_bytes_refused_despite_128_utf16_code_units" diverged
storage.test.ts:145: error: emoji_256_utf8_bytes_refused_despite_128_utf16_code_units
I ran the discriminating one independently rather than take it on report — swapping the TS bound from TextEncoder().encode(id).length to moduleId.length fails exactly one test, the emoji vector, and leaves the other ten green. That is the check doing its job: the ASCII vectors cannot distinguish the two implementations, and the straddle case can.
Gates: cargo test --workspace --locked, cargo clippy --workspace --all-targets --locked -D warnings, cargo fmt --all --check, clients/store bun test 11 pass / 66 assertions, wire-version check 6 crates examined none unbumped. subc-core 0.17.44, @cortexkit/store 0.1.2, Cargo.lock committed.
CONSUMER-IMPACT: ids longer than 255 UTF-8 bytes are now refused at config parse and HELLO instead of failing later at store-path derivation. No id that ever worked is affected.
Still open on #97
The placement half needs your call on the forbid(unsafe_code) question — tokio::process::Command::pre_exec is unsafe, forbid cannot be locally allowed, and the four options with my lean are on the issue. Post-spawn placement is the one I'd argue against: it leaves exactly the window that #97 exists to close.
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.
Summary by cubic
Rejects module_id values longer than 255 UTF-8 bytes during config parsing and HELLO instead of letting store-path derivation fail later. Existing working IDs, including 255-byte IDs, remain valid.
- Applies the same byte-based check in Rust and TypeScript, with shared ASCII and emoji fixtures.
- Bumps
subc-coreto 0.17.46 and@cortexkit/storeto 0.1.2.