Skip to content

docs(r3): post-#1488 follow-up — SizeVariable construction invariant + EnforceableLens uniqueness - #1500

Merged
briansrls merged 98 commits into
mainfrom
session/deep-wolf-155-r3-scope-expansion
May 2, 2026
Merged

briansrls merged 98 commits into
mainfrom
session/deep-wolf-155-r3-scope-expansion

Conversation

@briansrls

@briansrls briansrls commented May 2, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to PR #1488 (merged at c03fc60). Addresses 2 BLOCKING findings from cursor review wave (sha bef5781) that arrived AFTER PR #1488 merged. Both close subtle parallel-authority gaps in the substrate-design carriers landed there.

Commits (2)

Commit Fix
adf58fb SizeVariable.display_name construction invariant: parser is single point of construction; per-DAG PortId → String? name table canonicalizes display_name; SymbolicCost payload copies cannot diverge for same source_port. Closes the gap where SizeVariable equality on source_port only admitted divergent labels.
2c27a28 EnforceableLens canonicality: parser-level uniqueness invariant — at most ONE EnforceableLens<C, B> declaration per (Lens, Budget B) pair. User code declaring a second one fails parse-time with duplicate-canonical-enforcement Diagnostic. Closes the gap where multiple EnforceableLens declarations could compete as canonical.

Modeling-discipline class

Both fixes use parser-level uniqueness/canonicalization invariants as the strongest single-authority enforcement v3 currently supports. Type-level alternatives (existentials, singleton inhabitance, dependent types) would let these lift to type-level guarantees but require substrate hardening v3 doesn't ship today. Each fix documents the parser-level invariant explicitly + names the future hardening trigger.

Files modified

  • docs/design-cost-lens-sizevar-dimension-wiring.md — §1.2 construction invariant added (parser canonicalizes display_name).
  • docs/design-lens-application-surface.md — §2 EnforceableLens parser-level uniqueness invariant.

Test plan

  • Docs-only PR; no executable code touched
  • cargo fmt --all --check (passes via pre-push hook)
  • Reviewer chain to verify single-authority invariants on flip-to-ready

🤖 Generated with Claude Code

briansrls and others added 30 commits May 1, 2026 16:59
Director relayed two analyses against current main:
- Exploratory (gpt-5-5-pro main@8cd5359): 9 findings against
  dsl/std/*.dag, src/v2/tests/src/*.rs, dsl/extdeps/, THESIS,
  INVARIANTS, MODELING, ROADMAP — 2 novel correctness bugs
  (SymbolicCost semiring violation, emitter expect() panic paths),
  3 sharpened tracked items (SubValueRelation lattice-law
  contradiction, ?? / % syntax-parser drift, CollectionOps/StringOps/
  MapOps duplicates), 4 already-tracked items
- Reflective (gpt-5-5-pro main@6ea9812 → now): 5 cross-PR patterns
  + 6 highest-priority course corrections + verdict "advancing,
  scaffold-velocity dominates"

PM ingestion folds into single ROADMAP debt section per Director's
prior 2026-04-30 analyses ingestion pattern (PR #1319). Sections:

- A: Exploratory novel correctness bugs (SymbolicCost product-zero
     bug, SubValueRelation BoundedLattice claim violation, emitter
     expect panic paths)
- B: Exploratory sharpened tracked items (?? / % drift,
     CollectionOps/StringOps/MapOps duplicates)
- C: Exploratory already-tracked confirmations (no new ROADMAP rows)
- D: Reflective 5 cross-PR patterns (author-now/fire-later, test_
     runner.rs second predicate language, typed-carrier-Rust-mirror
     accumulation, numeric philosophy mid-window shift validating
     T-Numeric-Construction reframe, bridge retirement tracked-not-
     retired)
- E: Reflective 6 highest-priority course corrections with owner
     attribution + lane connection table
- F: CI cost signal (e765c86 60min timeout) + velocity-tripwire
     calibration (64 docs / 16 feat / 9 fix ratio)
- G: PM strategic synthesis: 3 cross-cutting meta-themes
     (algebraic-law-witness coverage gap; "make scaffolds executable"
     cluster; "tighten existing structural enforcement" cluster)

Per-finding/correction owner attribution names R3 Substrate Mgr,
R3 Verification Mgr, R3 Grounding Mgr, R3 PB Mgr per ownership
boundaries. Lane connections cite T-V-L4-L7-Direct, T-Free-
Consequences-Demonstration, T-Ground-Services parser-grammar slice,
T-Numeric-Construction Slice 2 sequencing, etc.

Highest-value novel: SymbolicCost product-zero bug (cost-lens reads
incorrect facts; iterate(ConstantCost(0), ...) returns body cost
instead of zero) + emitter expect() panics. Highest-value
sharpened-tracked: SubValueRelation BoundedLattice false-claim.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
briansrls and others added 2 commits May 2, 2026 10:51
…anonicalizes; copies cannot diverge

Cursor BLOCKING on PR #1488 sha bef5781: SizeVariable equality on
source_port only, while display_name was admitted as an independent
field. SymbolicCost payloads (LinearCost(SizeVariable), etc.) store
copies; if the construction site allowed two SizeVariables with the
same source_port but different display_name values, the user-facing
label would not be single-authority — consumers picking either copy
would render different labels for the same logical port.

Resolution: specify the parser-level CONSTRUCTION INVARIANT explicitly
in §1.2:

- SizeVariable is constructed EXCLUSIVELY by the parser at authoring
  sites, against a per-DAG `PortId → String?` name table populated at
  parse time.
- Every SizeVariable instance referencing source_port `p` carries the
  canonical display_name for `p` (or None if no authored name).
- Parser is the only construction site (no user-facing `SizeVariable
  { ... }` literal at authoring time — SizeVariables emerge from
  let-binding references during lowering).
- SymbolicCost payloads carrying SizeVariable copies cannot have
  divergent labels for the same source_port — single-authority by
  construction.

Equality on source_port only is correct under this invariant: same
source_port always carries same display_name. The redundancy is
explicit (display_name is canonical-per-source_port, derived at
construction).

Future hardening note: when v3 lands a substrate-level `port_id →
name` query (currently unwired per algebra.dag:143), display_name
can retire from the carrier entirely. For now the parser-
canonicalized field is what v3 supports.

This is a parser-level invariant, not a type-level guarantee, but
the parser is the only construction site for SizeVariable —
divergent labels are unrepresentable through the public construction
path.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…riant per (lens, Budget) pair

Cursor BLOCKING on PR #1488 sha bef5781: EnforceableLens<Output, Budget>
is a constructible record, so user code could declare another
type-compatible Lens<C> + LensEnforcement<C, B> pairing as a different
EnforceableLens. Canonical enforcement remained convention rather than
API-level enforcement.

Resolution: specify the PARSER-LEVEL UNIQUENESS INVARIANT in §2:
"at most ONE EnforceableLens<C, B> declaration per (Lens<C>, Budget B)
pair in the program". User code that declares a second EnforceableLens
referencing the same lens with a type-compatible Budget fails
parse-time with a Diagnostic naming both declarations as the
duplicate-canonical-enforcement violation. Same shape as v3's other
single-authority parser invariants (one declaration per name; one
BoundedLattice instance per type).

EnforcedApplication.enforceable_lens references resolve unambiguously
to the SOLE canonical EnforceableLens for that (lens, Budget) tuple.

Why parser-level, not type-level: full type-level enforcement would
require existentials or singleton inhabitance — substrate features
v3 doesn't fully express today (per substrate.dag inhabitance support
is sparse). The parser-level invariant achieves the same single-
authority outcome (no two competing canonical enforcements for a
lens/budget pair) at the only construction site v3 currently supports
as a structural gate.

Future substrate hardening (existentials / dependent inhabitance)
would let this lift to type-level — recorded as future cleanup.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@briansrls briansrls changed the title Gunbc PM docs(r3): post-#1488 follow-up — SizeVariable construction invariant + EnforceableLens uniqueness May 2, 2026
@briansrls
briansrls marked this pull request as ready for review May 2, 2026 10:57
@briansrls

Copy link
Copy Markdown
Contributor Author

Review metadata

  • Provider / model: claude / claude-opus-4-7
  • Commit: 2c27a28f · Trigger: schedule
  • Comparison: origin/main @ c03fc604 ... review/pr-1500-2c27a28f @ 2c27a28f
  • Thinking: 17s wall

APPROVE — Documentation-only changes that strengthen previously-asserted single-authority claims by spelling out the construction-site mechanism (parser canonicalization for SizeVariable.display_name, parser-level uniqueness for EnforceableLens<C, B>). Both additions are honest about the layer (parser-level invariant, not type-level) and name the future substrate work that would lift them. No diff content violates INVARIANTS, modeling-discipline, CODING, or TESTING.

Exploratory observations (optional):

  • docs/design-cost-lens-sizevar-dimension-wiring.md:74 says SymbolicCost payloads "cannot have divergent labels" — true under the stated invariant, but the surrounding type (SizeVariable { source_port, display_name }) still structurally permits the divergence the prose forbids. The "Future hardening" note (retire display_name, query by port_id at render time) is the real illegal-states-unrepresentable fix; worth keeping that trigger named on a lane gate so the parser-only invariant doesn't ossify.
  • docs/design-lens-application-surface.md:103-106 cites src/v3/std/lens.dag and substrate.dag for "inhabitance support is sparse" — readers chasing the citation will want a more specific anchor (line or symbol) than the bare filename, similar to the algebra.dag:143 style used in the sibling doc.

@briansrls briansrls left a comment

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.

Review metadata

  • Provider / model: codex / unknown
  • Commit: 2c27a28f · Trigger: schedule
  • Thinking: 152s wall

✅ Docs-only follow-up; the added parser-level invariants are documented, bounded, and consistent with the thesis/invariants, with no blocking concerns.

@briansrls

Copy link
Copy Markdown
Contributor Author

Review metadata

  • Provider / model: cursor / composer-2
  • Commit: 96bb1ab2 · Trigger: schedule
  • Comparison: origin/main @ 23542b50 ... review/pr-1500-96bb1ab2 @ 96bb1ab2
  • Thinking: 24s wall

Findings

No blocking issues. The diff only updates two design markdown files. It states parser-level (not type-level) rules for SizeVariable.display_name and EnforceableLens uniqueness, which matches modeling-discipline.md practice 6’s distinction between structural vs behavioral enforcement instead of pretending the substrate proves those facts today. The Future hardening paragraph names a concrete dissolution (“when a substrate-level port_id → name query lands, retire display_name”), which fits INVARIANTS.md P5-style tracked follow-up rather than an unnamed bridge.

Nothing in this diff touches CODING.md (no Rust) or TESTING.md (no tests).

Verdict

APPROVE — Narrow documentation follow-up: construction invariant for SizeVariable, uniqueness story for EnforceableLens, and an explicit future cleanup for display_name. No rubric violation grounded in these lines.

Exploratory observations (optional)

The new cross-reference “currently unwired per src/v3/std/algebra.dag:143” (added around 90:90:docs/design-cost-lens-sizevar-dimension-wiring.md) points at a comment line whose text is about an InternTable lookup not being run yet; that’s aligned in spirit with a future name/query path, but “port_id → name query” vs “InternTable lookup” wording doesn’t match that line verbatim—consider a small range cite (e.g. 141–145) if you want pixel-perfect traceability. Non-blocking.

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