White-box @tests move into a colocated 'package regex' file (Hare +test.ha analogue; #6 non-T drop plays the build-tag role), black-box @tests stay in package regex_test — Go's foo/foo_test split. The wb/ stub driver is documented-temporary scaffolding: a same-dir importer file-resolves to regex.ww before dir-enumeration, so only a different-dir import bundles the whitebox sibling (task #33 retires it). CLAUDE.md rule-9 carve-out updated (#5 closed, gate was #6).
4.9 KiB
4.9 KiB
- This is a project for ww programming language
- ww is a programming language aiming for Hare + CSP, no GC
- cmd/ is the C bootstrap toolchain (wcc frontend lib, w6c/w6a/w6l per-arch, ww driver); selfhost/ is the ww reimplementation
- All C code must strictly align with plan 9 coding style
- lib/ is the standard library; follow Hare APIs (signatures, layout, error idioms) — consult ref/hare/ before designing new modules. Package declaration form is Go-style explicit
package foo;and imports useimport foo;(executables declarepackage main;) per language design (rob-pike + plan-9 sensibility); lib/ API surface still mirrors Hare. - ref/hare and ref/plan9front are read-only references — consult before inventing data shapes or syntax
- No workarounds. If a bug forces a workaround, STOP and report with a precise repro. Document any retained divergence at the site with a pointer to the filed task. Never silent.
- Comments are WHY-only. Never narrate WHAT the code does — names carry the WHAT. Comment only non-obvious WHY: a constraint, a divergence from a reference, a citation to a filed task.
- Hare-fidelity over convenience. No ad-hoc extensions, renames, or convenience wrappers in lib/. Cite ref/hare// for every signature ported. Carve-out: the Hare
_unsafesuffix convention is dropped wholesale (ww is C/Plan-9-lineage, an unmanaged systems language — no GC, no "safe" baseline to be unsafe relative to). bytes→str is a pure reinterpret (strings.frombytes, renamed from Hare'sfromutf8_unsafe); validation is opt-in viautf8.validate(b)?at the IO source, never wrapped per-construction. Rationale: ref/hare/strings/utf8.ha:10,22 — the suffix flags Hare's managed-bytes-safety axis, which ww doesn't have. The honest name (frombytes) reservesfromutf8for a future true validating helper. Carve-out: lib/ tests use Go's external-test-package idiom (package <mod>_test;+import <mod>;), a sanctioned Go-over-Hare departure — ww hard-rejects self-import (full Go), and Hare's same-package@testcolocation now has a ww analogue: in-package white-box@testfiles (package <mod>;, colocated) are sanctioned alongside the external black-boxpackage <mod>_test;split — Go'sfoo/foo_testmodel — now that the non-T@testdrop landed (#6, harec check.c:3941, 08a76cf; #5 closed). Rule 5/9 binds lib/ API surface, not test-authoring style. Ref: Gofoo_testconvention; task #16. - Symmetric stages. cstage and wwstage MUST emit byte-identical asm for the same input. When inference power differs, align the richer side DOWN to the leaner side, not the other way.
- Split commits when they bundle unrelated concerns. Bisect-cleanliness is the default. Multi-fix commits need a body paragraph explaining why they couldn't split.
- Simple data, simple algorithms. Sea-of-stars style. Mirror Hare's structural choices over clever alternatives.
- No hardcoded size literals in size-computation contexts. Always route through the type table (tinfo.size / Type.size / ty_*->size / size(T) / primtypesize / tyslicesize). Per Drew's framing of Hare's discipline.
make sizelintenforces and runs as a dep ofmake test. Exemptions documented inline with// sizelint-ok: <reason>(ww) or/* sizelint-ok: <reason> */(C). Optional local enforcement:ln -s ../../tools/sizelint .git/hooks/pre-commit. - Test targets. Inner-loop dev runs
make test-unit(~3.8s, skips wwstage-driver tests: 950, 990–997). Pre-commit runsmake test-commit(content-keyed tier: the 10 pure gates — 950, 989_lib_byteid, 990–997 — reportcachedwhen the input key matches the last green full run; ~25s on a hit, full gate run on any miss; key = stage-binary md5s + tracked selfhost/lib/cmd/rt/test/examples sources + harness + Makefile; cache in out/.testcache, wiped by make clean; mtime keys and partial keys are vetoed). Pre-push runs fullmake test(~3:40 measured atf940072, all 353 incl. byte-id gates) — the bootstrap-correctness gate, never cached; never push without it green. test-unit is a fast confidence check on unit-level code (stages, stdlib, smoke); a green test-unit doesn't prove bootstrap, only that the unit set is intact. New wwstage-driver tests are no longer confined to the 950/990–997 range for correctness: T3 (test-perf arc) made every build's intermediates follow its OUTPUT (ww build -o <stem>/ww run's per-pid temp) instead of landing next to every traversed source, so concurrent driver builds no longer race onselfhost/cmd/<tool>/main.{s,combined.ww,o}fixtures — the phase-2 byte-id group (incl. 993/995/950) now runs fully parallel. The 950/990–997 NNN prefixes still drive test/run's phase-2 membership, themake test-unitskip set, and themake test-commitcache set, so a heavy 43k self-compile gate should still use that range to be skipped by test-unit and cached by test-commit; a light wwstage-driver test may live at any NNN (just-o-redirect its intermediates off the source tree).