Repository navigation
Description
Owner request 2026-11-08 (W2.2 session, after the walrus store-wrap findings on #2443): "is it possible for us to create a formal model of the type system and variable/field scoping that the compiler and code must adhere to? i'm most concerned about the decisions we make about walrus ops and field/local/module visibility and being inconsistent … if we went with a model, how do we programmatically prevent drift between the model and the code?"
Sub-issues: #2487 (binding/scoping rule table) · #2488 (narrowing-lattice rule table) · #2489 (CI cite check).
Contract that is violated today
Every binding/scoping/narrowing verdict (refuse with code X / run and print what Python prints / deviation row) is supposed to be uniform across its axis (binding kind × scope kind × operation × store form; narrowing kind × store form × slot kind). Today the verdicts live in prose and rulings, not in one executable place, so the only consistency check is memory:
docs/design/name-resolution.md(N1–N7, S1–S3; principle ruled 2026-11-01) is the design of record but is prose;variable_scoping.md(586 lines),walrus_operator.md(402),type_narrowing.md("Stores Use the Declared Type", expression-level narrowing) each carry their own tables.- The call-38 rulings D10–D22 (R-KX…R-LJ on name resolution: implement the adopted principle — scope decides meaning, values ready before use, ambiguity refused, global/nonlocal reinstated (tracker, owner ruling 2026-11-01) #2427) are the
must-run/must-refusearms of the P77a harness, encoded inNameResolutionDifferentialTests.Families.cs(9 rule cites in the file;SharpyTag.MustRun/MustRefuseper cell), i.e. the model exists only implicitly in test code. DiagnosticExplanations.cscites 0 rule IDs (grepN[1-7]\b), so no refusal says which rule it enforces.- Evidence the drift is already real (all measured @ 5d0187e, W2.2 ledger): a walrus as an unparenthesized tuple element into a narrowed
int?prints(Some(42), 1)(python(42, 1)) and a typed tuple is SPY0908 CS0029 (key collision between two_optionalStoreWrapsreaders); the walrus's own-site store(c = 42)intoOptional<int>rides the implicit operator that spec/semantic: retire implicit T -> T? conversion and bare None for T? — full-strict Optional construction (ruling 2026-08-31) #1720 forbids in emitted C# (EmittedOptionalConstructionConformanceTests, allowlists empty, no committed snapshot has the shape);x: int?narrowed byisinstance(x, int)thenx += 1→ SPY0908 CS0030; a float literal stored into a narrowedfloat32?→ SPY0908 CS1503. Each is a cell of "store form × narrowing × slot kind" that no table enumerates.
What already exists (reuse, do not rebuild)
- The P77a generator:
src/Sharpy.Compiler.Tests/Conformance/NameResolutionDifferentialTests.*.cs(12 files, ~11k lines:Axes,Rosters(enums as axis images with totality assertions),Classifier,Families,Census,TwinRenderer, python control), allowlistname-resolution-differential-allowlist.txtciting open issues — this IS a model-vs-code differential; the model is just not a readable artifact. - Contract §11's roster/totality pattern (
docs/design/verification-contract.md): every axis the image of a compiler enumeration under a map with no default arm. build_tools/check_spec_blocks.sh,check_allowlist_issue_state.sh,check_plan_refs.py: the shape a cite check takes.
Cure (class, not cells) — three sub-issues
- Binding/scoping rule table: N1–N7, S1–S3 and D10–D22 as data with rule IDs, store form a closed roster (incl. walrus), loaded by the P77a classifier #2487 Binding/scoping rule table: N1–N7, S1–S3 and D10–D22 as rows
(binding kind, scope kind, operation, store form) → verdict, rule ID, loaded by the P77a classifier; store form is a roster that includes=, augmented, tuple/star, walrus,let,global/nonlocal(andvarif P21b adopts it) so no form can be the forgotten arm. - Narrowing-lattice rule table: (narrowing kind × store form × slot kind) → emitted-shape class and verdict, seeded with the Optional store-wrap cells #2488 Narrowing-lattice rule table:
(narrowing kind, store form, slot kind) → emitted-shape class / verdict, rule ID, seeded with the four cells above and driven by the same generator. - CI cite check: every rule ID in DiagnosticExplanations, the spec, the charter and plans resolves to a rule-table row, and every row is cited #2489 Cite check in CI: every rule ID in
DiagnosticExplanations, the spec, the charter and the plans resolves to a table row, and every row is cited by ≥ 1 diagnostic or deviation; a row or cite without its counterpart fails the gate.
Not a proof assistant / TLA+ model: nothing in them executes against the compiler, so they drift silently. The model stays small and independent of the compiler (shared code cannot catch its own bugs); the generator drives both, the allowlist ratchet pins disagreements with issue cites.
Done when
- The two tables are the only place verdicts live; the spec's verdict tables and the harness's
must-*arms are generated from or asserted equal to them (totality asserted, no default arm, mutation-tested: delete a row → the roster test red; flip a verdict → the differential red on the generated cell). DiagnosticExplanationscites a rule ID for every binding/narrowing refusal; the cite check runs in CI.- Owner rulings on bindings (e.g. handoff D17, the walrus's role once
let/var/global/nonlocalland) become table rows, not prose.
Placement
Charter placement at the next /batch-issues; the natural slot is beside P21b (bindings: let/var/walrus decided together) and after P77b (the harness residue). Tests-only instrument group like P63/P68. Lane tooling, reach program (the verdicts it pins are program-reach).
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.20l (P78) and §3.12 (P51); this issue is the tracker across the three tables. Ruling R-LO (owner, 2026-11-08): (a) distribute — #2487 is P78's generator row (P21b reads it forlet/var); #2488 is P51'sGenerator: REQUIRED FIRST(#2494's four cells are its first failing rows); #2489 is a band chore once one table exists. Rejected: (b) one light (e) tooling group building all three tables before P78 — a round with no consumer, against rules P77/P78 are about to change.The table is the model and the cite check is the drift guard, per your question of 2026-11-08 ("how do we programmatically prevent drift between the model and the code?"). Lane / reach: tooling · program. This tracker closes when the three sub-issues have.
Generated by Claude Code
antonsynd commentedon Nov 9, 2026
Wave 3 ledger flush, 2026-11-09 @ 63da689 (dev)
A narrowing cell for this tracker's contract ("Every binding/scoping/narrowing verdict … is supposed to be uniform across its axis"). It belongs in #2488's table (P51,
Generator: REQUIRED FIRST) under narrowing kind "walrus-introduced", and is that kind's first failing READ cell. Found by the W3.2 spec-block drain (PR #2519). Lane false-refusal · reach program.T?×is not Nonedef get() -> str?…if (y := get()) is not None: print(y.upper())str; runs(dog := animal as? Dog) is not Nonethendog.bark())T | None×is not None-> str | Noner = a as? Dogthenif r is not None: r.bark(), forT?andT | NoneCells for the table: walrus target × {
T?,T \| None} × {is not None,is None+else} × read {member, call, store intoT}. The plain-binding twin is the oracle.The allowlist row
type_casting.md::c7a9a2b5a1moves from #1952 to this issue in 5e40981e4 (not yet pushed). It still fails @ 63da689.Re-measured with
sharpyc run@ 63da689 (worktree build of dev): every cell above gives the same verdict.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 'T?' walrus cell still gives SPY0326 (and 'is None'+else, and 'as? Dog'); the store-into-T read gives SPY0220. The 'str | None' walrus cell now runs and prints HI. No rule-table artifact exists in the repo (static).
Cells (controls left out):
Generated by Claude Code
feat(build_tools): ruling_evidence measures a ruling's programs and door
feat(build_tools): check_rulings gates ruling records against the laws
antonsynd commentedon Nov 22, 2026
Related work on branch
claude/quirky-planck-bpunzb(pull request to follow): rulings as checked records. This is a first, hand-seeded version of the "verdicts as data" idea in this tracker. It does not build the rule tables of #2487 and #2488.What it adds (measured @
993681ab3, basebfbeeee6a, CPython 3.15.2):docs/process/rulings/: one record per charter ruling (460, labels from the 2026-11-21 audit, unreviewed), the written laws with the text that anchors each, 32 draft principles, five hand-listed case families, a draft policy file.build_tools/check_rulings.py: twelve checks across records, laws and charters (schema,charter-totality,law-anchor,reference,supersession,charter-mark,exception-in-law,collision,invariance,door,considered,owner-required).build_tools/ruling_evidence.py: runs a ruling's program on the compiler and on python3, derives the door from the two observations, and re-runs every recorded program.On the tree as it stands the checks report 20 findings from the data alone. They wait in
docs/process/rulings/known-findings.yamland are decisions for the next/batch-issuescall::=onto an existingletan error (R-GV, "never re-asked"), open (R-LR), or a rebind (R-BK; what the compiler does)? Posted on #1974.==on a type with no__eq__?strofOptionaland ofResult?The audit's other questions (its section 6: C3, C4, U4 to U7, L3, L4 and four clashes between unwritten principles) have no case in the data yet, so no check reports them:
docs/audits/ruling-audit-2026-11-21.md.What this tracker's plan should know:
docs/process/rulings/axes.yamlare hand-listed, which contract section 11 does not accept as a roster. They should be replaced by the rosters of Binding/scoping rule table: N1–N7, S1–S3 and D10–D22 as data with rule IDs, store form a closed roster (incl. walrus), loaded by the P77a classifier #2487 as those land.derive_doortherefore reports two measured facts, andpolicy.yaml(a draft) says which combinations an agent may decide.ruling_evidence.py recheckruns inbuild_tools/tests/, so a change that lands a ruling must update that ruling's recorded observation in the same pull request.Generated by Claude Code
fix(build_tools): apply the nine findings of the review @ 993681a
fix(build_tools): apply the three findings of the review @ 87da778
fix(build_tools): apply three nits of the review @ 7e9f191