Skip to content

W7.3 grammar-expansion (follow-up к #46) - #47

Merged
gHashTag merged 3 commits into
mainfrom
w7/testing/grammar-expansion
Jul 5, 2026
Merged

W7.3 grammar-expansion (follow-up к #46)#47
gHashTag merged 3 commits into
mainfrom
w7/testing/grammar-expansion

Conversation

@gHashTag

@gHashTag gHashTag commented Jul 5, 2026

Copy link
Copy Markdown
Owner

W7.3 grammar-expansion (продолжение PR #46)

Base: main @ 3272583 (PR #46 merged, E1+E2 baseline frozen — 100/100/0 subset)
Head: 9bbc103
Scope: grammar-expansion до E3 unblock (E3 timer-blocked до 2026-07-19 12:24 UTC per PR #44 backstop)

Commits (по SHA, chronological)

2080510\b-fix normalize_ast (carry-over из GLM PR #46 review)

Non-blocking precision-nit из GLM peer-review PR #46 @ 4a016d4:

  • Regex line:\s*\d+,? без \b теоретически over-match на *line: N полях
  • Empirical verification на N=1000 frozen baseline — nit latent, не active
  • Fix defensive против future parser evolution
  • Regression check N=50 subset → 50/50/0 ok

247427d — grammar-expansion target #1 (collection-typed params) — OBSOLETED by 9bbc103

Emitted Zig-style []const T / []T / [N]T collection forms. GLM peer-review flagged blocking finding: syntax mismatch with the actual W6.2 audit corpus at tri-net/specs on PR #39 branch (that corpus uses Rust-style [T; NAMED_CONST] exclusively). Retained in history for traceability; replaced by 9bbc103.

9bbc103 — collection-params rewrite to [u32; NAMED_CONST] (audit-corpus-aligned)

Corpus-mismatch resolution:

The audit corpus targeted by W6.2 lives at tri-net/specs on the PR #39 branch (feat/strategic-audit-2026-07-04, 68 spec files). Verification against that corpus:

  • 0 []const T occurrences (Zig-style is absent).
  • 159 [u32; NAMED_CONST] occurrences across the 68 files.
  • 100% u32 element type.
  • Top declared consts by count: MAX_NODES (29), MAX_PARAMS (18), MAX_METRICS (12), MAX_FLOWS (11), and so on.
  • Const-decl syntax: const NAME: u32 = <literal>; at module scope, literals in [2, 32].

247427d was chosen from a workspace-wide grep that also matched a parallel non-tri-net corpus at ../t27/specs/ (830 []const T occurrences there). Corpus was not scoped to tri-net/specs. Anchor recorded (Anchor #4): any claim verified against ground truth requires scoping the verification tool to the same corpus as the claim.

Revision applied (option a — drop Zig-forms + u32-only):

  • pick_coll_type rewritten to emit only [u32; NAMED_CONST].
  • Ctx.declared_consts: Vec<(String, u32)> added for per-module tracking.
  • gen_const_decls: 1–4 module-scope const NAME: u32 = <literal>; per module, values in [2, 32], no repeats within a module.
  • NAMED_CONST_POOL = top-10 audit-corpus names (MAX_NODES, MAX_PARAMS, MAX_METRICS, MAX_FLOWS, MAX_ENTRIES, MAX_MODULES, MAX_TASKS, MAX_FUNCTIONS, MAX_SAMPLES, MAX_RESULTS).
  • gen_module emits const-decls before fn-decls.
  • gen_params guards: emits collection-param only if declared_consts non-empty, else falls back to scalar.
  • Isolation constraint preserved: collection-typed idents recorded in Ctx.coll_params, never pushed into Ctx.idents.
  • Grammar header comment updated.

Re-baseline N=1000 (this HEAD 9bbc103):

Metric Frozen subset (3272583) Expanded (9bbc103)
Parse-success 1000/1000 (100.0%) 1000/1000 (100.0%)
Determinism 1000/1000 (100.0%) 1000/1000 (100.0%)
Whitespace-invariance 1000/1000 (100.0%) 1000/1000 (100.0%)
Parse errors / Panics / Non-det 0 / 0 / 0 0 / 0 / 0
Fns emitted ~1900 (0-param only) 1951 (mix 0–4 params)
Fns with ≥1 collection-param 0 1177 (60.3%)
Fns with 0 params ~1900 392 (20.1%)
[u32; NAMED_CONST] occurrences 0 1924
Module-scope const-decls 0 2510 (avg 2.5 per module)

Sample module snippet:

module W73Fuzz0 {
    const MAX_SAMPLES: u32 = 25;
    const MAX_ENTRIES: u32 = 27;
    const MAX_TASKS: u32 = 31;
    const MAX_PARAMS: u32 = 18;

    fn f0(p_4412: u8, p_8371: [u32; MAX_TASKS], p_5676: [u32; MAX_SAMPLES], p_3484: u64) -> u16 {
        ...
    }
}

Планируемые следующие коммиты (tracked, не landed — separate PRs / commits per isolate-variables)

Priority по strategic value:

  1. Collection-typed params [u32; NAMED_CONST] — LANDED @ 9bbc103 (superseded 247427d)
  2. Index expressions (arr[i]) — next; makes collection-params live in body (actual W6.2 Class 2 defect-surface exercise). Isolate-variables: alone, re-baseline, then next.
  3. Call — requires fn-signature registry in Ctx
  4. If-statements — Terminal-Return invariant extends to both branches

SHA-advance rule application

Per docs/W7_COLLAB_OPTIONS.md §SHA-advance rule (merged via PR #45 → main @ be06148):

  • Prior review target: 247427d (Zig-style, BLOCKING FINDING from GLM re-review — syntax mismatch with tri-net/specs corpus).
  • SHA advance: 247427d9bbc103 — delta:
    • - Zig-style pick_coll_type (three-form emitter for []const T / []T / [N]T)
    • + Rust-style pick_coll_type (one form: [u32; NAMED_CONST])
    • + Ctx.declared_consts: Vec<(String, u32)> field
    • + gen_const_decls — module-scope const-decl emitter (1–4 per module, [2,32] literals)
    • + NAMED_CONST_POOL — 10 audit-corpus top consts
    • + gen_module emits const-decls before fns
    • + gen_params guarded on declared_consts non-empty
    • Grammar comment updated (Module includes ConstDecl* prefix; CollType is [u32; IDENT])
    • ~ docs/W7_3_FUZZ_BASELINE.md §Expanded baseline rewritten (new §Corpus-mismatch resolution + new numbers table + new interpretation)
    • Isolation constraint retained unchanged
    • No changes to roundtrip.py

Reviewer: re-confirm against 9bbc103 per rule (Re-reviewed at 9bbc103: delta <bullet-list> in review comment).

External-dep window

Discipline compliance

  • Draft-only per house rule (no merge until reviewed)
  • Empirical grounding: every claim verified against fetched output on this commit
  • Frozen citation-point PR feat(W7.3): grammar-directed fuzz baseline (E1 generator) #46 @ 3272583 preserved as reference
  • Isolate-variables: only one grammar-target per commit (this = collection-params, revised for corpus alignment)
  • Corpus-scope discipline: syntax choice verified against tri-net/specs on PR docs: strategic audit 2026-07-04 (7 findings + 3 options) #39 branch (the actual W6.2 audit corpus), not workspace-wide grep
  • No pre-silicon claims (fuzz corpus is real t27c parse output)

phi^2 + phi^-2 = 3


Path-confirmation spot-check (GLM condition @ 9bbc103)

Peer-review of 9bbc103 approved the code and doc, gated merge on one path-confirmation check: verify that t27c gen-rust on a fuzz-generated spec produces Vec<> in param position (the W6.2 Class 2 defect surface). Executed 2026-07-05, full 1000-spec sweep:

Metric Value
t27c gen-rust success 1000 / 1000
t27c gen-rust failed 0 / 1000
[u32; NAMED_CONST] in .t27 input 1924
Vec<> in gen-rust Rust output 1924
Match exact one-to-one

Sample (spec fuzz_00000_seed_0x00c0ffee.t27):

Input (t27):

    const MAX_SAMPLES: u32 = 25;
    const MAX_TASKS: u32 = 31;
    fn f0(p_4412: u8, p_8371: [u32; MAX_TASKS], p_5676: [u32; MAX_SAMPLES], p_3484: u64) -> u16 {

Output (t27c gen-rust):

pub const MAX_SAMPLES: u32 = 25;
pub const MAX_TASKS: u32 = 31;
pub fn f0(p_4412: u8, p_8371: Vec<>, p_5676: Vec<>, p_3484: u64) -> u16 {

Confirms: syntax match ↔ codegen path match. Every collection-param position in the fuzz corpus exercises the W6.2 Class 2 defect surface (Vec<> param-position), not a divergent lowering path.

Doc-nit correction (GLM cosmetic)

Prior body said "pick_coll_type rewritten". Precise wording: the standalone pick_coll_type function from 247427d was removed; the equivalent collection-type emission is inlined into gen_params as format!("[u32; {}]", const_name) at gen.rs line 229. Semantics identical, structure simplified. Not a behavior delta.

phi^2 + phi^-2 = 3

Perplexity Computer added 3 commits July 5, 2026 13:14
Carry-over from GLM peer-review of PR #46 @ 4a016d4 (RE-APPROVE with
one non-blocking precision-nit tracked for expansion-PR).

GLM finding: normalize_ast regex `line:\s*\d+,?` без word-boundary
\b теоретически over-match'ит на любом `*line: N` AST-поле (например
`inline: 5,` → strip до `in`), потенциально маскируя real structural
diff или создавая false-match.

Empirical verification на N=1000 baseline (main @ 3272583): дампы
t27c parse не содержат ни одного `*line:` поля. Nit был latent, не
active — 100/100/0 baseline валиден. Fix — defensive precision против
future parser evolution (если в t27c AST добавят inline/pipeline/
baseline поля с numeric values).

Change: `re.sub(r"line:\s*\d+,?", "", ast_text)`
     →  `re.sub(r"\bline:\s*\d+,?", "", ast_text)`

Regression check: N=50 subset of frozen baseline → 50/50/0 ok
(parse_ok=1.0, invariance_ok=1.0). Fix не меняет observable behavior
на текущем parser, только защищает от regression при parser evolution.

phi^2 + phi^-2 = 3
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
…corpus ground truth

SHA-advance delta: 247427d → HEAD

Blocking finding from GLM peer-review of 247427d: collection-params
syntax mismatch with the actual audit corpus.

247427d emitted Zig-style forms:
  fn f(p: []const u8, q: [16]u32, r: []u16)

This was chosen from a workspace-wide grep that included a parallel
non-tri-net corpus at ../t27/specs/ (830 []const T occurrences there).
Re-verification against the audit corpus at tri-net/specs on the PR #39
branch (feat/strategic-audit-2026-07-04, 68 files) confirmed 0
[]const T occurrences. That corpus uses Rust-style [T; NAMED_CONST]
exclusively — 159 total occurrences, 100% u32 element type,
module-scope const-decls in the [2, 32] literal range.

Revision applied (option a, drop Zig-forms + u32-only):
- Rewrote gen.rs pick_coll_type to emit only [u32; NAMED_CONST].
- Added Ctx.declared_consts: Vec<(String, u32)> for per-module tracking.
- Added gen_const_decls: emits 1–4 module-scope const NAME: u32 = <lit>;
  before fns, values in [2, 32], no repeats within a module.
- Added NAMED_CONST_POOL: top-10 audit-corpus consts (MAX_NODES,
  MAX_PARAMS, MAX_METRICS, MAX_FLOWS, MAX_ENTRIES, MAX_MODULES,
  MAX_TASKS, MAX_FUNCTIONS, MAX_SAMPLES, MAX_RESULTS).
- gen_module now emits const-decls before fn-decls.
- gen_params guards: emit collection-param only if declared_consts
  non-empty, else fall back to scalar.
- Isolation constraint preserved: collection-typed idents recorded in
  Ctx.coll_params, never pushed into Ctx.idents.
- Grammar header comment updated.

Re-baseline (N=1000, seed range 0xC0FFEE..0xC0FFEE+999):
- ok=1000  parse_err=0  mut_fail=0  non_det=0
- 1951 fns emitted (1177 with ≥1 collection-param, 60.3%; 392 with 0
  params, 20.1%)
- 1924 [u32; NAMED_CONST] occurrences, distribution 166–224 per name
- 2510 module-scope const-decls (avg 2.5 per module)

BASELINE.md §Expanded baseline rewritten:
- New §Corpus-mismatch resolution and syntax choice documents the
  scope error and its fix explicitly.
- Results table replaced with [u32; NAMED_CONST] numbers.
- Coverage delta rewritten with actual named-const distribution.
- Interpretation notes updated; Zig-style absence documented as
  explicit non-coverage.

Anchor recorded (Anchor #4): any claim verified against ground truth
requires scoping the verification tool to the same corpus as the
claim. Workspace-wide grep is not corpus-scoped grep.

Discipline: honors SHA-advance rule (PR #45 → main @ be06148) —
this commit is a delta from 247427d, delta bulletized in PR body.

phi^2 + phi^-2 = 3
@gHashTag
gHashTag marked this pull request as ready for review July 5, 2026 14:23
@gHashTag
gHashTag merged commit fb23de5 into main Jul 5, 2026
2 checks passed
@gHashTag
gHashTag deleted the w7/testing/grammar-expansion branch July 5, 2026 14:23
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