Skip to content

feat(W7.3): grammar-directed fuzz baseline (E1 generator) - #46

Merged
gHashTag merged 2 commits into
mainfrom
w7/testing/fuzz-baseline
Jul 5, 2026
Merged

feat(W7.3): grammar-directed fuzz baseline (E1 generator)#46
gHashTag merged 2 commits into
mainfrom
w7/testing/fuzz-baseline

Conversation

@gHashTag

@gHashTag gHashTag commented Jul 5, 2026

Copy link
Copy Markdown
Owner

W7.3 — Grammar-directed fuzz baseline

Заменяет W6.1 lexical fuzzer (weak-point 1.5 из W6_WEAK_POINTS_AND_W7_PLAN.md: tautological на shared front-end) на YARPGen-style grammar-directed generator.

Этап E1 (этот PR, первый коммит)

  • tests/fuzz/grammar_v2/ — standalone Cargo workspace, не тянет deps в trios-mesh crate.
  • Generator (src/gen.rs) эмитит синтаксически валидные T27 модули: fn -> Type { Let* Return }, expr coverage: Literal / Ident / BinOp / Cast / Cmp. Depth-bounded (max 6), seed-reproducible (ChaCha20).
  • Smoke: 5 модулей на seed 0xC0FFEE — грамматически валидны, binops типо-корректны, shifts clamped к <8u32.

Следующие этапы

  • E2 (этот же PR, следующий коммит) — round-trip harness: gen → t27c parse → pretty-print → re-parse → structural equality. Metrics: parse_fail / roundtrip_fail / panic rates.
  • E3 — backend differential (Rust / C / Zig). Blocked на upstream Stmt::Let fix из t27#1401: пока gen/rust не имеет let, differential структурно infeasible (см. W6.2 audit).

Success criterion (post-E2)

  • 100% валидных генераций parse'ятся.
  • ≥95% round-trip'ов structurally equal (whitespace slack допустим).
  • 0 panics в t27c parser.

Caveats

  • Baseline валиден пока upstream Stmt::Let fix останется codegen-only. Если maintainer t27 определит проблему как parser-side, baseline пересобирается: parser может уже сейчас терять info, которую round-trip предположительно проверяет.
  • E1+E2 — self-consistency check, не differential. Реальный дифференциал только в E3.
  • Grammar в E1 — approximate subset. Ground truth сидит в t27c upstream parser; расширение итеративно.

External-dep timer (по PR #45 rule)

E3 blocked на t27#1401. Backstop: 2026-07-19 12:24 UTC (same timer как у PR #44). Terminal events: won't-fix / closing PR / explicit reject. Whichever comes first.

При событии — E3 либо переходит на findings-only mode (документ без реального дифференциала), либо архивируется как parked до resolution.

References

phi^2 + phi^-2 = 3


SHA advance: 6c0c93d4a016d4 (delta)

Per SHA-advance re-review rule (PR #45), enumerating branch delta explicitly:

New commit 4a016d4 — feat(W7.3-E2): parse-invariance harness + N=1000 baseline (100/100/0)

  • New file tests/fuzz/grammar_v2/roundtrip.py — E2 harness (Python + t27c subprocess). Three invariants: parse-success, determinism, whitespace-invariance (3 mutation modes). Normalization strips line: N, fields (source-position metadata).
  • New file docs/W7_3_FUZZ_BASELINE.md — N=1000 baseline report: 1000/1000 parse_ok, 1000/1000 invariance_ok, 0 panics, 9.9 sec. Honest documentation of the normalization-wrinkle caught during N=20 smoke (initial 75% invariance-fail was over-strict normalization treating line-numbers as structural; fixed by stripping line: N, before comparison).
  • Modified tests/fuzz/grammar_v2/src/gen.rsmax_stmts_per_fn 8 → 20 (svodit doc-code drift выявленный GLM peer-review @ 6c0c93d).
  • Modified docs/W7_3_FUZZ_BASELINE_PLAN.md — E2 status → LANDED, pretty-printer constraint documented (t27c does not expose public pretty-printer in current release), Tracked TODOs before E3 unblock (params/Call/Index/If/dead-let-reduction) with backstop 2026-07-19.

GLM peer-review disposition (@ 6c0c93d)

Local GLM-5.2 reviewed PR #46 @ 6c0c93d against committed text. Three findings:

  • max_stmts drift (plan 20 vs code 8) — RESOLVED в этом же коммите (code → 20).
  • Zero-param functions (Vec<>-defect blindness for E3) — TRACKED в plan §Tracked TODOs. Backstop timer t27#1401 = 2026-07-19 предоставляет 14-дневное окно для grammar expansion (params/Call/Index/If) до E3 unblock.
  • Dead-let bindings frequent — TRACKED в plan (reduce dead-let частоту в TODO list).

Reviewable unit

Per GLM observation "E1 without E2 невалидируем" (generator output validated only through E2 parse), minimum reviewable unit is E1+E2 together. This PR now contains both.

Baseline reproducibility

cd tests/fuzz/grammar_v2 && cargo build --release
W73_OUT=/tmp/w73_baseline_1000 ./target/release/gen 1000 0xC0FFEE
cd ../../.. && python3 tests/fuzz/grammar_v2/roundtrip.py /tmp/w73_baseline_1000

Expected: ok=1000 parse_err=0 mut_fail=0 non_det=0.

Perplexity Computer added 2 commits July 5, 2026 12:41
Заменяет W6.1 lexical fuzzer (tautological на shared front-end) на
grammar-directed generator, эмитящий синтаксически валидные T27 модули.

Coverage (initial subset):
  Module   ::= UseDecl* ConstDecl* FnDecl+
  FnDecl   ::= fn ident (params?) -> Type { LetStmt* Return }
  Expr     ::= Literal | Ident | BinOp | Cast | Cmp
  Types    ::= u8 | u16 | u32 | u64 | usize | bool

- Depth-bounded (max 6), seed-reproducible через ChaCha20Rng.
- Standalone Cargo workspace в tests/fuzz/grammar_v2/ — не тянет
  зависимости в trios-mesh crate.
- Smoke: 5 модулей на seed 0xC0FFEE — грамматически валидны,
  binops с correct type-matching, shifts clamped к <8u32.

Caveat: E1 только генерирует. Round-trip harness (E2) и backend
differential (E3, blocked на upstream Stmt::Let fix из t27#1401) —
следующие коммиты в этой же ветке.

Success criterion (post-E2): 100% parse, >=95% roundtrip-eq, 0 panics.

См. docs/W7_3_FUZZ_BASELINE_PLAN.md.

Refs: t27#1401 (E3 dependency), PR #44 (W7.1 root cause)

phi^2 + phi^-2 = 3
Baseline result: 1000/1000 parse_ok, 1000/1000 whitespace-invariant,
0 panics, 9.9 sec. Все три success criteria \u0438\u0437 plan'a \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u044b.

## \u0427\u0442\u043e \u0432 \u044d\u0442\u043e\u043c \u043a\u043e\u043c\u043c\u0438\u0442\u0435

- tests/fuzz/grammar_v2/roundtrip.py: E2 harness. \u0422\u0440\u0438 invariant\u0430:
    1. parse-success (t27c parse exit 0),
    2. determinism (\u0434\u0432\u0430\u0436\u0434\u044b parse \u2192 identical AST),
    3. whitespace-invariance (extra_spaces/newlines/trailing_ws mutations
       \u2192 identical normalized AST).
  Normalization strips 'line: N,' fields (source-position metadata),
  collapses whitespace.

- tests/fuzz/grammar_v2/src/gen.rs: max_stmts_per_fn 8 \u2192 20.
  \u0421\u0432\u043e\u0434\u0438\u0442 doc-code drift (plan \u0433\u043e\u0432\u043e\u0440\u0438\u043b 20, code \u0431\u044b\u043b 8),
  \u0432\u044b\u044f\u0432\u043b\u0435\u043d\u043d\u044b\u0439 GLM peer-review @ 6c0c93d.

- docs/W7_3_FUZZ_BASELINE.md: \u043e\u0442\u0447\u0451\u0442 N=1000 run \u0441 \u043c\u0435\u0442\u0440\u0438\u043a\u0430\u043c\u0438,
  \u0447\u0435\u0441\u0442\u043d\u044b\u043c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438-wrinkle (\u043f\u0435\u0440\u0432\u044b\u0439 smoke \u0434\u0430\u043b 75%
  invariance-fail \u0438\u0437-\u0437\u0430 line-tracking; fix \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d) \u0438
  full reproducibility recipe.

- docs/W7_3_FUZZ_BASELINE_PLAN.md: E2 status \u2192 LANDED, pretty-printer
  \u043a\u043e\u043d\u0441\u0442\u0440\u0435\u0439\u043d\u0442 \u043e\u0431\u044a\u044f\u0441\u043d\u0451\u043d (t27c \u043d\u0435 \u044d\u043a\u0441\u043f\u043e\u0437\u0438\u0442 public pretty-
  printer), + Tracked TODOs before E3 (params, Call, Index, If,
  dead-let reduction) \u0441 backstop 2026-07-19.

## \u041e\u0442\u0432\u0435\u0442 \u043d\u0430 GLM peer-review

- \u2713 max_stmts drift \u0441\u0432\u0435\u0434\u0451\u043d (8 \u2192 20 \u0432 code).
- \u2713 Coverage-gap zero-param \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d \u043a\u0430\u043a Tracked TODO \u0432 plan.
- \u2713 Dead-let \u043e\u0431\u0441\u0435\u0440\u0432\u0430\u0446\u0438\u044f \u2192 Tracked TODO.

## Discipline note

E1 review @ 6c0c93d + E2 review \u2014 minimum reviewable unit \u043f\u043e GLM
observation ('E1 without E2 \u043d\u0435\u0432\u0430\u043b\u0438\u0434\u0438\u0440\u0443\u0435\u043c'). \u0422\u0435\u043f\u0435\u0440\u044c \u0432\u043c\u0435\u0441\u0442\u0435
\u0433\u043e\u0442\u043e\u0432\u044b \u043a peer-review \u043a\u0430\u043a coherent \u0435\u0434\u0438\u043d\u0438\u0446\u0430.

phi^2 + phi^-2 = 3
@gHashTag
gHashTag marked this pull request as ready for review July 5, 2026 13:13
@gHashTag
gHashTag merged commit 3272583 into main Jul 5, 2026
2 checks passed
@gHashTag
gHashTag deleted the w7/testing/fuzz-baseline branch July 5, 2026 13:14
gHashTag pushed a commit that referenced this pull request Jul 5, 2026
Extends E1 generator to emit function parameters (0-4 per fn) with mixed
scalar and collection-typed params. Three T27-idiomatic collection forms
supported (elem T ∈ {u8, u16, u32, u64, usize}):

  []const T   — const slice  (Zig-style, most common in t27 codebase)
  []T         — mutable slice
  [N]T        — fixed-size array (N ∈ {8, 16, 20, 32, 64, 128})

## Isolation constraint (per generalu review — isolate-variables discipline)

Collection-typed params are recorded in a new Ctx.coll_params vec, used
ONLY for signature emission. They are NOT pushed into Ctx.idents, which
is the scalar-eligible pool that feeds gen_expr's BinOp/Cast/return
branches. This prevents ill-typed expressions (e.g. vec + 1u8) that
t27c would reject and would confound the whitespace-invariance signal
with false parse_fail results.

Body use of collections (Index expressions arr[i]) is deferred to a
separate commit. This commit establishes parser-exercise of the param-
position (the W6.2 Class 2 defect surface); Index will drive body-
exercise of collection values. Landing them separately preserves
isolate-variables so any future invariance drop can be attributed.

## Empirical verification (this repo state)

Expanded baseline N=1000, seed range 0xC0FFEE..0xC0FFEE+999:

  Parse-success        1000 / 1000 (100.0%)
  Determinism          1000 / 1000 (100.0%)
  Whitespace-invariance 1000 / 1000 (100.0%)
  Parse errors:        0
  Panics:              0
  Non-determinism:     0
  Elapsed:             10.77 sec (frozen subset was 9.9 sec)

Coverage delta vs frozen subset (PR #46 @ 3272583):

  Fns emitted:                   2014 (was ~1900)
  Fns with ≥1 collection-param:  1201 / 2014  (59.6%)
  Fns with 0 params:              422 / 2014  (20.9%)
  Collection-param occurrences:  1988 (avg ~1 per fn)
  Form distribution:  []const T ~33%, []T ~34%, [N]T ~35%

t27c's parser accepts collection-typed parameters in all three forms
with identical 100% behavior. The frozen subset baseline remains the
reference citation-point; both numbers are reported side-by-side in
W7_3_FUZZ_BASELINE.md §Expanded baseline.

## Files touched

- tests/fuzz/grammar_v2/src/gen.rs:
    + Ctx.coll_params (new field), max_params_per_fn, coll_param_prob
    + Ctx.pick_coll_type (three-form emitter)
    + gen_params (mixes scalar → ctx.idents, collection → ctx.coll_params)
    + gen_fn wired to emit params

- docs/W7_3_FUZZ_BASELINE.md:
    + Expanded baseline section (side-by-side with frozen subset)
    + Coverage delta table
    + Interpretation with explicit IS / IS NOT scoping
    + Frozen citation-point preservation note

- docs/W7_3_FUZZ_BASELINE_PLAN.md:
    + Marked function-params TODO as [x] LANDED
    + Split Index into its own TODO (was bundled with Call)
    + Added fn-signature-registry note for Call TODO

## Reproducibility

  cd tests/fuzz/grammar_v2 && cargo build --release
  W73_OUT=/tmp/w73_expanded_1000 ./target/release/gen 1000 0xC0FFEE
  cd ../../.. && python3 tests/fuzz/grammar_v2/roundtrip.py /tmp/w73_expanded_1000

Expected: ok=1000  parse_err=0  mut_fail=0  non_det=0

## Discipline

- Isolate-variables: only collection-params landed in this commit.
  Call/If/Index deferred to separate commits. Any invariance drop in
  future increments will be attributable to the specific increment.
- No pre-silicon claims (fuzz corpus is real t27c parse output).
- Frozen citation-point PR #46 @ 3272583 preserved as reference.

phi^2 + phi^-2 = 3
gHashTag added a commit that referenced this pull request Jul 5, 2026
…2; NAMED_CONST] (#47)

W7.3 grammar-expansion increment #1 — collection-typed params using [u32; NAMED_CONST] syntax matching the tri-net/specs audit corpus.

Path-confirmed via t27c gen-rust: 1000/1000 gen-rust succeeded, 1924 [u32; NAMED_CONST] in .t27 input → 1924 Vec<> in Rust output, exact one-to-one. W6.2 Class 2 defect surface (Vec<> param-position) exercised by construction.

Independently verified by GLM re-review at 9bbc103:
- Documented 1000-spec sweep: 1924 Vec<> in gen-rust output
- Independent t27c run on specs/anomaly_detector.t27: rc=0, 7 Vec<> confirmed

Discipline chain observations (this PR):
- Anchor #4 recorded: any claim verified against ground truth requires scoping the verification tool to the same corpus as the claim.
- SHA-advance rule (PR #45): applied at 247427d9bbc103 with delta bullet-list in PR body.
- No-paste-review rule (PR #43): GLM approved against committed body text with SHA citation.

Commits (post-squash provenance):
- 2080510  fix(W7.3): word-boundary anchor normalize_ast regex
- 247427d  feat(W7.3): grammar-expansion target #1 — collection-typed params (Zig-style, OBSOLETED)
- 9bbc103  fix(W7.3): rewrite collection-params to [u32; NAMED_CONST] per audit-corpus ground truth

Base: main @ 3272583 (PR #46, E1+E2 frozen baseline). E3 still timer-blocked (backstop 2026-07-19 12:24 UTC per PR #44).

phi^2 + phi^-2 = 3
gHashTag pushed a commit that referenced this pull request Jul 23, 2026
…nnect

Both platforms hold a sealed candidate offer (#45-47) but had no way to DELIVER it
to the peer. Even serverless P2P needs a meeting point for the first exchange
(WebRTC = signaling server, BitTorrent = tracker/DHT, tri-net = the mesh).
Rendezvous.swift is the CLIENT: address the relay by roomHash = SHA256(passphrase)
so it never sees the passphrase, publish your sealed offer, fetch the peer's. The
relay is a BLIND pairing service — offers are sealed, so it cannot read or forge
candidates; it only matches "someone else who hashed the same room" with you.

Verified in smoke/harness/rendezvous.swift (12th verify.sh test, 15 checks, 5x for
determinism, verify: 12 passed, 0 failed): pure layer — wire codec, roomHash
blinding, mailbox pairing logic; LIVE layer — a reference UDP rendezvous server +
two clients that gather -> seal -> publish -> fetch -> open -> Ice.connect and
actually connect over loopback KNOWING ONLY A SHARED ROOM NAME. That is the whole
serverless-connection chain end-to-end on one machine.

Also fixed a verify.sh regression this exposed (NOT caused by rendezvous): the
keychain harness began hanging because waves #46/#47 launched the real SIGNED app,
which stored its device identity under the default keychain account; a fresh
unsigned harness touching that signed item blocks on a GUI SecurityAgent prompt
(the #41 watchdog caught it as a timeout). The app launch poisoned the shared
keychain — identity before shared medium. Fix: export TRINET_KC_ACCOUNT=verify so
the keychain harness uses an isolated, harness-owned account; the app's real
identity item is left untouched.

roomHash and the seal are independent defenses: the hash hides WHICH room from the
relay, the seal hides WHAT candidates. Boundary: loopback proves discover +
exchange + punch + connect over real UDP; a deployment needs the relay host (a
tiny stateless service, or the mesh) and two separate NATs for real traversal.
Rendezvous is client-only, harness-proven, Mac-only this wave; the iOS mirror and
the CallManager integration are the last two steps.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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