Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# v4 TS Algebra Inhabitance Widening Worksheet (stable fact IDs)

> **Status:** DRAFT — `ready-for-review` (TypeScript RCA Manager `fierce-fox-719`; 2026-06-01).
> **Lane:** ALPHA/PREVIEW — NOT release-minimum.
> **Analog:** W1.7 / Rust #4000 widening (`rust_integer_algebra_inhabitance_rust_facts_i32`); Python #4117 (`python_integer_algebra_inhabitance_python_facts_int`).
> **Authority:** `docs/planning/v4-leaf-model-verification-2026-05-30.md` §5 Layer A (model owns facts; claims reference fact IDs).

---

## Mechanical dispatch rule

> **No TS algebra widening worker may land until this worksheet is Modeling DFS Arbiter–approved.**

This worksheet is **substrate on typescript.dag** (fact ID exposure). Leaf-model host runners are **downstream** in the R2/R3-external worksheet.

---

## §10.0-adapted worksheet

```text
Migration class: TS-ALGEBRA-INHABITANCE-WIDENING (W1.7 / #4000 analog for typescript.dag)
Representative failure: ts_number_algebra_inhabitance(facts) and ts_bigint_algebra_inhabitance(facts)
exist as fn bodies but lack stable top-level data fact IDs — claim corpus
cannot reference subjects without duplicating AlgebraInhabitanceDecl shapes.
Immediate local patch:
LeafModelClaim Subject coproduct arms per primitive on typescript.dag (forbidden by W2.6b deferral).
Why that patch is forbidden:
Phase 1 discriminator is LeafModelClaimId + fact Symbol references (rust/python pattern).
DFS path:
std/ authority:
- AlgebraInhabitanceDecl at src/v4/std/model_core.dag (consume only)
extdeps/language authority:
- src/v4/extdeps/languages/typescript.dag
claim corpus:
- References widened data lines (typescript_r2a.dag, typescript_r2b.dag)
Deepest unsound boundary:
Algebra inhabitance facts are not addressable as stable claim subjects.
Systemic fix:
Add top-level data bindings (names ratified here; worker may adjust spelling with Arbiter):
data ts_number_algebra_inhabitance_ts_facts_number: AlgebraInhabitanceDecl =
ts_number_algebra_inhabitance(facts: ts_facts_number)
data ts_bigint_algebra_inhabitance_ts_facts_bigint: AlgebraInhabitanceDecl =
ts_bigint_algebra_inhabitance(facts: ts_facts_bigint)
data ts_bool_algebra_inhabitance_ts_facts_boolean: AlgebraInhabitanceDecl =
ts_bool_algebra_inhabitance()
Optional Phase 1.5:
data ts_string_algebra_inhabitance_ts_facts_string: AlgebraInhabitanceDecl =
ts_string_algebra_inhabitance(facts: ts_facts_string)
Non-goals:
- New Subject/Expectation coproduct types on typescript.dag (W2.6b posture).
- Changing claimed algebra (ApproximateField vs OrderedRing) — verification may FALSIFY model;
that routes to Modeling DFS per v4-leaf-model-verification §9, not silent emit patch.
- Wave-2b law obligation expansion (separate T-4 tranche).
Falsification probe:
After widening: claim fixture pair in typescript_r2a.dag references
ts_number_algebra_inhabitance_ts_facts_number by Symbol equality (compile-time TestClaim).
Mutate witness node in typescript.dag; claim wiring test MUST fail without claim file edit.
Metric allowed only as secondary:
Count of AlgebraInhabitanceDecl rows with exported fact IDs.
```

---

## Claim ↔ fact wiring table

| Stable fact ID | Algebra (modeled) | Leaf-model consumer |
|----------------|-------------------|---------------------|
| `ts_number_algebra_inhabitance_ts_facts_number` | `ApproximateField` on `number` / IEEE-754 | R2a |
| `ts_bigint_algebra_inhabitance_ts_facts_bigint` | `OrderedRing` on `bigint` | R2b |
| `ts_bool_algebra_inhabitance_ts_facts_boolean` | `BooleanAlgebra` on `boolean` | Phase 2 unless batched |
| `ts_string_algebra_inhabitance_ts_facts_string` | `FreeMonoid` on string code units | Phase 2 unless batched |

---

## §8 Manager approval checklist — OPEN

- [ ] No new Subject/Expectation coproduct at Phase 1
- [ ] `LeafModelClaimId` + fact Symbol discriminator only
- [ ] Number vs bigint split explicit (no faux unified `Int`)
- [ ] Worker may land **before** R2 host runners but **after** Arbiter approval
- [ ] Worker dispatch — **forbidden** until Arbiter sign-off

## Related artifacts

- `docs/planning/v4-w2.6b-python-leaf-model-claim-worksheet-2026-05-30.md` (deferral precedent)
- `src/v4/extdeps/languages/python.dag` — `python_integer_algebra_inhabitance_python_facts_int`
- `docs/planning/v4-ts-leaf-model-r2-r3-external-worksheet-2026-06-01.md`
101 changes: 101 additions & 0 deletions docs/planning/v4-ts-grammar-inverse-testclaims-worksheet-2026-06-01.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# v4 TS Grammar-Inverse TestClaims Worksheet (#3850 line, alpha lane)

> **Status:** DRAFT — `ready-for-review` (TypeScript RCA Manager `fierce-fox-719`; 2026-06-01).
> **Lane:** ALPHA/PREVIEW — NOT v4-done / release-minimum gate.
> **Authority:** `docs/planning/v4-predicate-dependency-graph-2026-06-01-eod.md` §8.7 (#3850); T-11 MVP-1 receipts on main.
> **Existing substrate:** `mvp1_typescript_add_translate.dag`, `mvp1_typescript_record_task_translate.dag`, `typescript_wave2a*.dag`.

---

## Mechanical dispatch rule

> **No TS grammar-inverse expansion worker may land until this worksheet is Modeling DFS Arbiter–approved.**

Acceptance is **CompilesClaim / EqualsClaim** receipts on named productions — not "translate compiles" without grammar-inverse path exercised.

---

## §10.0-adapted worksheet

```text
Migration class: TS-GRAMMAR-INVERSE-TESTCLAIMS (Shape-A target, alpha/preview)
Representative failure: T-11 typescript slice proves MVP-1 add-fn compile-inferred path, but
grammar-inverse coverage is not enumerated per production; packaging/module
layout unmodeled — L1 blocked silently.
Immediate local patch:
Expand hand-authored expected source strings in manual tests without production→claim map.
Why that patch is forbidden:
Claims must name grammar productions / TargetModel edges as authority (mvp1_rust pattern).
DFS path:
std/ authority:
- grammar.dag relation rows, derive_grammar_relation_row
extdeps/language authority:
- typescript.dag — ts_production_mvp1_fn_add, wave2a type/record productions
compiler:
- 06_translate.dag grammar-inverse serialize (translate_grammar_inverse_* )
test/claim:
- src/v4/test/claim/manual/mvp1_typescript_*.dag (extend, do not fork parallel vocab)
Deepest unsound boundary:
Grammar-inverse path is exercised for one MVP-1 fixture but not receipt-closed per production
class; module resolution not in model.
Systemic fix:
Phase 1 L0 scope (ratified minimal set):
G1. mvp1 add-fn — production ts_production_mvp1_fn_add (existing anchor; refresh labels)
G2. wave2a type_alias_decl — production ts_production_wave2a_type_annotation family
(record_task_translate.dag authority)
Each: TestClaim asserts compile_inferred → emit → translate → grammar-inverse → canonical
source_text equals ts_mvp1_source_text / wave2a expected authority.
Explicit NOT_IN_L0: import/export paths, package.json, project references, nodenext resolution.
Non-goals:
- Full Rust Reference-scale grammar closure.
- Source ingestion from .ts files on disk (§14 GAP — separate T-4 tranche).
- v4-done L5 cross-target equivalence.
- Replacing tsc with grammar-inverse alone (inverse is structural receipt; tsc remains L0 leaf-model).
Falsification probe:
Mutate single token in grammar_relation_row emitted field; grammar-inverse claim MUST fail
(EqualsClaim mismatch). Attempt inverse on production without serialize_source edge →
translate_grammar_inverse_not_realized diagnostic (fail-closed).
Metric allowed only as secondary:
Count of productions with Tier1 Boundary claims.
```

---

## #3850 relevance (2026-06-01 disposition)

Post-#4091 elastic CI ratification, the #3850 "grammar-inverse TestClaims for python/go/cpp/typescript Shape-A targets" line remains **relevant for TS alpha lane** but **scoped down**:

| Target | L0 action |
|--------|-----------|
| TypeScript | This worksheet — G1 + G2 only |
| python/go/cpp | Owned by respective RCA managers (release-minimum family) |

---

## Packaging / module-layout blocker (documented, not solved in L0)

TypeScript L1 (compiler-subset emit typechecks) requires modeling:

- `import` / `export` / `export type`
- `moduleResolution` / `module` kind (at least Node16/NodeNext stand-in)
- Single-file vs project emit

**Escalation path:** if worker hits packaging before L0 leaf-model closes, TS RCA Manager escalates via `dashboard-ops escalate` — does not smuggle packaging into grammar-inverse L0 claims.

---

## §8 Manager approval checklist — OPEN

- [ ] L0 scope = G1 + G2 productions only
- [ ] Packaging explicitly deferred to L1
- [ ] Reuse manual TestClaim patterns from mvp1_typescript_*.dag
- [ ] Alpha/preview — NOT v4-done gate
- [ ] Worker dispatch — **forbidden** until Arbiter sign-off

## Related artifacts

- `src/v4/test/claim/manual/mvp1_typescript_add_translate.dag`
- `src/v4/test/claim/manual/mvp1_typescript_record_task_translate.dag`
- `src/v4/test/claim/parse/typescript_wave2a.dag`
- `src/v4/std/grammar.dag` — `grammar-inverse-lhs-exact-selection` gate
- `docs/planning/v4-ts-leaf-model-r2-r3-external-worksheet-2026-06-01.md` (orthogonal L0 track)
138 changes: 138 additions & 0 deletions docs/planning/v4-ts-leaf-model-r2-r3-external-worksheet-2026-06-01.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
# v4 TS Leaf-Model R2a / R2b / R3-external Worksheet (MW-D3 alpha lane)

> **Status:** DRAFT — `ready-for-review` (TypeScript RCA Manager `fierce-fox-719`; 2026-06-01).
> **Lane:** ALPHA/PREVIEW — NOT v4 release-minimum (Wave F F3). Mirror landed pattern: Python #4117, Rust #4000.
> **Authority:** `docs/planning/v4-leaf-model-verification-2026-05-30.md` §5–§7; `docs/planning/v4-predicate-dependency-graph-2026-06-01-eod.md` §11.8.2.
> **Prerequisite worksheets:** `v4-ts-target-atom-realization-worksheet-2026-06-01.md` (R3-external row must exist before R3 worker); `v4-ts-algebra-inhabitance-widening-worksheet-2026-06-01.md` (stable fact IDs for R2a/R2b subjects).

---

## Mechanical dispatch rule

> **No TS R2a/R2b/R3-external implementation worker may land until this worksheet is Modeling DFS Arbiter–approved.**

Acceptance is dual-path verification (happy + falsification) against **tsc** and, where noted, **Node** runtime — not TestClaim compile-only wiring alone.

---

## §10.0-adapted worksheet

```text
Migration class: TS-LEAF-MODEL-R2-R3-EXTERNAL (MW-D3 cross-target widening, alpha lane)
Representative failure: typescript.dag declares ApproximateField<number> and OrderedRing<bigint>
algebra inhabitance, but no LeafModelClaim + host runner exercises ECMA
semantics; emit/translate bugs masquerade as "TS backend gaps."
Immediate local patch:
Hand-author emitted .ts snippets in integration tests without modeled claim IDs or
falsification probes — parallel authority on TS numeric/atom facts.
Why that patch is forbidden:
INVARIANTS P2 — claim corpus must reference stable fact IDs on typescript.dag;
unfalsifiable assertions (happy path only) violate v4-leaf-model-verification §5.
DFS path:
std/ authority:
- LeafModelClaimId + LeafModelVerificationRunReceipt at src/v4/std/leaf_model_verification.dag
- Target verdict vocabulary (NEW): TargetTypeScriptCompileVerdict / TargetTypeScriptRuntimeVerdict
— Arbiter must ratify before worker (no copy-paste of Rust/Python enums without review)
extdeps/language authority:
- src/v4/extdeps/languages/typescript.dag — ts_number_algebra_inhabitance,
ts_bigint_algebra_inhabitance (widened fact IDs per algebra-inhabitance worksheet)
- R3-external: ts_target_atom_realization_symbol (per atom-realization worksheet)
claim corpus (sibling files, Layer A):
- src/v4/test/claim/language_model/typescript_r2a.dag
- src/v4/test/claim/language_model/typescript_r2b.dag
- src/v4/test/claim/language_model/typescript_r3_external.dag
fixture authority:
- src/v4/lens/leaf_model_verification.dag (TS fixture pairs + source strings)
host runners (interim, dissolve-on-arrival per #4117 pattern):
- scripts/v4-leaf-model-typescript-r2a-verify.sh
- scripts/v4-leaf-model-typescript-r2b-verify.sh
- scripts/v4-leaf-model-typescript-r3-external-verify.sh
compiler stage:
- None for Phase 1 L0 (external toolchain only). R3-internal remains out of scope (Rust-only SG-1 receipt).
Deepest unsound boundary:
Modeled algebra + atom facts on typescript.dag are not exercised against tsc/Node.
Systemic fix:
Phase 1 claim set (3 claim IDs) + fixture pairs + host runners (tsc/Node). Hand-Rust
boundary test is NOT optional — see §P5(b) implementation worker receipt below (same
gate as Python #4117; alpha lane does NOT waive Mechanism (b)).
Non-goals:
- R1 primitive surface-spelling claims (defer unless Arbiter batches with Go L0).
- R3-internal emit projection mutation receipt (Rust SG-1 only at L0).
- Full ~50–100 fixture inventory (Phase 2 after framework proves useful on 3 claims).
- Module packaging / project-reference modeling (L1 concern; see grammar-inverse worksheet).
- tsc replacing Node for all runtime semantics (R2b may require Node where tsc is silent).
Falsification probe (per claim):
R2a: happy exercises + and < on declared primitive; falsification calls non-existent method
(TS2339 Property 'log2_exact' does not exist — analog E0599 / Python AttributeError).
R2b: happy bigint add beyond Number.MAX_SAFE_INTEGER; falsification uses number lane for same
magnitude and expects IEEE754 precision loss or tsc rejection per declared expectation.
R3-external: happy ECMA Symbol() factory call `Symbol("x")` typechecks; falsification uses
illegal `new Symbol("x")` (Symbol is not a constructor — ECMA-262 / MDN) or arity
`Symbol(1, 2)` → TS2554.
Metric allowed only as secondary:
TestClaim wiring count; NOT acceptance.
```

---

## Claim inventory (Phase 1 L0)

| Claim ID | Subject fact (typescript.dag) | Happy exercise | Falsification |
|----------|------------------------------|----------------|---------------|
| `leaf_model_claim_ts_r2a_number_algebra_operations` | `ts_number_algebra_inhabitance_ts_facts_number` | `function r2a(a: number, b: number): [number, boolean] { return [a + b, a < b]; }` | Call `a.log2_exact()` → TS2339 |
| `leaf_model_claim_ts_r2b_bigint_beyond_safe_integer` | `ts_bigint_algebra_inhabitance_ts_facts_bigint` | Runtime: `(2n ** 63n - 1n) + 1n === 2n ** 63n` via Node | Same expr in `number` lane → diverges from model |

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BLOCKING: The R2b falsification is not falsifying: ((2 ** 63 - 1) + 1) === 2 ** 63 evaluates true under JavaScript number rounding, so the wrong-path probe can pass with the same verdict as bigint, violating the leaf-model falsification contract and INVARIANTS P1.

| `leaf_model_claim_ts_r3_external_symbol_projection` | `ts_target_atom_realization_symbol` | `const s: symbol = Symbol("x");` typechecks (`Symbol()` factory; not constructable) | `new Symbol("x")` → not constructable (tsc) **or** `Symbol(1, 2)` → TS2554 |

**R3-external ECMA grounding (P1):** TypeScript `Symbol` is a callable factory, **not** a constructor — `new Symbol()` is invalid ([MDN Symbol()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/Symbol)). Do **not** mirror Python R3’s nominal `class Symbol` + `__init__` happy path; that pattern is CPython-faithful, not TS-faithful.

## §P5(b) implementation worker receipt (hand-Rust — separate PR from worksheets)

> **This worksheet PR (#4147) lands markdown only — zero paths under `src/v3/compiler/tests/**`.**
> Hand-Rust is **forbidden** here. The first implementation worker that adds the boundary
> harness MUST satisfy **exactly one** checkable P5 Mechanism (b) receipt per
> `INVARIANTS.md` Dispatch-Discipline (b) — mirror PR #4117 / `sg0-pr-body-append.4117.txt`.

| Receipt artifact (same PR as harness) | Required content |
|--------------------------------------|------------------|
| `src/v3/compiler/tests/boundary/v4_leaf_model_typescript_r2_r3_external_test.rs` | Boundary tsc (+ Node for R2b bigint) exercise; fixture bytes pinned to `src/v4/lens/leaf_model_verification.dag` authority strings |
| `_internal/INVARIANTS_OPS.md` | New table row: path, ROADMAP **T-PB-B** / `pb_rust_tests_outside_residual_zero`, dissolution (T-22 `run_target_verification` on `typescript_r{2a,2b,3_external}.dag`), interim ratchet test names |
| `src/v3/compiler/tests/integration/sg0_census_test.rs` | **Net +1** on `EXPECTED_HAND_AUTHORED_TEST` for the boundary path (before/after counts in PR body) |
| `scripts/ci-merge/sg0-pr-body-append.*.txt` (or PR body) | SG-0 pairing `(c)` line naming path + INVARIANTS §P5(b) + paired verify shells |
| Host runners (same PR) | `scripts/v4-leaf-model-typescript-r2a-verify.sh`, `r2b-verify.sh`, `r3-external-verify.sh` |
| Claim wiring (same PR or prior) | `typescript_r2a.dag`, `typescript_r2b.dag`, `typescript_r3_external.dag` + lens fixtures |

**Forbidden:** landing boundary Rust without the INVARIANTS row + census line in the **same** PR; vague deferrals; “alpha lane exempt” from census.

---

**Numeric lane split (operator-visible):** TypeScript has no single `Int` primitive. R2a anchors on ECMA `number` (IEEE-754 binary64 / `ApproximateField`). R2b anchors on `bigint` (exact ℤ / `OrderedRing`). This mirrors Python (#4117) splitting unbounded int behavior (R2b) from algebra ops (R2a), adapted to TS’s dual numeric types.

---

## Verification toolchain

| Step | Tool | Notes |
|------|------|-------|
| Typecheck | `tsc --strict` (or `npx tsc` with repo-pinned TS version) | Primary authority for R2a/R3-external |
| Runtime | `node` on emitted `.mjs` or `.ts` via `tsx` only if tsc insufficient | R2b bigint equality |
| Packaging | Single-file fixtures in scratch dir | **No** `package.json` / path-mapping in L0 scope |

---

## §8 Manager approval checklist (TypeScript RCA Manager) — OPEN

- [ ] Single-authority fact: claim IDs reference typescript.dag data lines only (no parallel Subject coproduct at Phase 1)
- [ ] Shared verdict carriers ratified by Modeling DFS Arbiter (not reinvented in typescript.dag)
- [ ] Prerequisite: atom-realization + algebra-widening worksheets approved
- [ ] R3-external blocked until `ts_target_atom_realization_symbol` row lands
- [ ] Alpha/preview framing explicit — NOT v4-done / release-minimum gate
- [ ] §P5(b) receipt table accepted for downstream implementation PR (not this worksheet PR)
- [ ] Worker dispatch — **forbidden** until Arbiter sign-off

## Related artifacts

- `docs/planning/v4-leaf-model-verification-2026-05-30.md` §7 (R2a/R2b/R3-external definitions)
- Python mirror: `src/v4/test/claim/language_model/python_r{2a,2b,3_external}.dag`, `scripts/v4-leaf-model-python-*.sh`
- Rust mirror: `src/v4/test/claim/language_model/rust_r{2a,2b,3_external}.dag`
- `docs/planning/v4-ts-target-atom-realization-worksheet-2026-06-01.md`
- `docs/planning/v4-ts-algebra-inhabitance-widening-worksheet-2026-06-01.md`
Loading
Loading