Repository navigation
Description
Sub-issue 2 of #2486 (owner request 2026-11-08).
What
The second executable table: (narrowing kind, store form, slot kind, value kind) → verdict + emitted-shape class + rule ID, driven by the same generator as the binding table (sub-issue 1), with Python as the control where the surface is in fidelity scope and the emitted-shape class checked by a Roslyn semantic-model pass over the generated C# (the pattern of EmittedOptionalConstructionConformanceTests).
Axes (closed rosters, contract §11):
- narrowing kind: none;
is not None/is None;isinstance(x, T)(reified generics pertype_narrowing.md"isinstance on reified generics"); union-case match; walrus-introduced;and/or/ternary expression-level narrowing (type_narrowing.md§"Expression-level narrowing"); loop-carried; after a failed guard. - store form:
=, augmented (+=…),??=, tuple element, tuple unpacking target, walrus:=(own site AND as a tuple/call-argument element),letdeclaration with annotation, attribute/subscript store, parameter write-through. - slot kind: local
T?, parameterT?, closure-capturedT?, fieldT?, element oflist[T?], tuple component,object?,Optional<T>from .NET interop, non-Optional control. - value kind: payload literal (incl. unsuffixed float into
float32?,decimal),Some(v),None(), anotherT?, anUnknown-typed expression, a call returningT?.
Seed cells (all measured @ 5d0187e, W2.2 ledger, no existing issue found for the first two)
| narrowing | store | slot | value | today | expected |
|---|---|---|---|---|---|
isinstance(x, int) |
+= |
local int? |
int | SPY0908 CS0030 on ((int)x!) |
runs, Python output |
is not None |
= |
local float32? |
0.25 |
Optional<float>.Some(0.25d) → SPY0908 CS1503 |
runs |
is not None |
walrus as tuple element | local int? |
int | prints (Some(42), 1); typed tuple CS0029 |
(42, 1) (fixed by #2443 W2.2, option B) |
is not None |
walrus own site | local int? |
int | (c = 42) implicit T → Optional<T> (#1720 forbids) |
Optional<int>.Some(42) wrap |
| none | = into T? |
any | payload | refused SPY0604/SPY0222 | refused (control) |
The rule they all instantiate is already in the spec (type_narrowing.md "Stores Use the Declared Type"): a store into a narrowed Optional slot wraps the payload explicitly, whatever the store form. The table makes "whatever the store form" a roster the compiler is checked against.
Drift prevention
- Every row names its rule ID;
DiagnosticExplanationsfor SPY0604/SPY0222/SPY0220 and the Optional-construction guard cite the rows they enforce (sub-issue 3 checks the cites). - The generator renders one program per cell; the verdict (refuse code / run+stdout) and the emitted-shape class (explicit
Some(...)wrap present / no implicit conversion, by Roslyn conversion analysis) are both compared; disagreements go to an allowlist citing issues, drained on fix. - Totality: every roster value from a compiler enumeration (the store forms from the parser's assignment/target node kinds; narrowing kinds from
TypeNarrowingContext's producers) or a named closed set; mutations: drop a row → red; flip a shape class → red on the named cell.
Relation to P82 (#2443)
P82 moves the store-wrap FACT onto IR nodes (_optionalStoreWraps tranche 1). This table checks the DECISION that produces the fact, across the whole lattice, and would have caught both walrus cells before a plan did.
Placement
With #2486 at the next /batch-issues; the generator is sub-issue 1's; the Roslyn shape check reuses EmittedOptionalConstructionConformanceTests' analysis.
Activity
process(handoff): D17 records the rule-table issues #2486-#2489
antonsynd commentedon Nov 8, 2026
Batching 2026-11-08 @ 10e1c1b — charter
docs/process/rounds/remediation-round-2026-09-20-batching.md§3.12, P51 — narrowing authority (order 12): this table is P51'sGenerator: REQUIRED FIRST(R-LO a). (narrowing kind × store form × slot kind) → emitted-shape class and verdict, as data with rule IDs, seeded with the five store-wrap cells and #2494's four;StoreTargetMatrixTestsgains the narrowing-kind and target-kind axes and is checked against the table; the differential (table verdict vs compiled C#) is the allowlist ratchet. Since P82 tranche 1 the wrap fact isIrOptionalStoreWrapfromLoweringPass.OptionalStoreWrapOf, so the table's verdicts are what that derivation must reproduce. Lane / reach: tooling · program. Tracker: #2486.Generated by Claude Code
antonsynd commentedon Nov 12, 2026
Cell: a walrus-introduced
is not Nonetest does not narrow a value-type payloadMeasured with
run@ afcbead (dev c1a8c11 plus test-only commits), oracle CPython 3.15.2. Found while probing plan-4e2867; outside that plan's contract.xinside the branchint | None(walrus)str | None(walrus)int | None,x = f()thenif x is not None:g(x)44y: int = xx + 14Table coordinates: narrowing kind = walrus-introduced, slot kind = local
T?with a value-type payload; the reference payload narrows, the value payload does not. Lane: false-refusal, reach: program.walrus_operator.mdgivesif (m := …) is not None:as the idiom.Generated by Claude Code
antonsynd commentedon Nov 19, 2026
Reproduction sweep, 2026-11-16: PARTIAL (at least one cell is right today and at least one is not).
Re-measured against
dev@ d81425f with a Debugsharpyc, about eight cells per issue; CPython 3.15.2 where python is the standard. Copied at batching call 46 (2026-11-19) fromdocs/process/rounds/sweep-2026-11-16.md. Not re-run since: P77 merged after the sweep, so a plan re-measures before relying on a row.Today: The table itself does not exist (static). Of the seed cells, the two walrus cells are fixed ((42, 1); own-site emits Optional<int>.Some(42)) and the control still refuses SPY0604; isinstance '+=' is still SPY0908 CS0030 and the float32 literal still SPY0908 CS1503. The comment cell still reproduces: SPY0220 / SPY0220 / SPY0222 for 'int | None' via walrus.
Cells (controls left out):
Generated by Claude Code