Skip to content

Add proptest dependency and refactor Cardinality to use constants - #23

Merged
briansrls merged 9 commits into
mainfrom
claude/review-todo-docs-qBlwx
Feb 3, 2026
Merged

briansrls merged 9 commits into
mainfrom
claude/review-todo-docs-qBlwx

Conversation

@briansrls

Copy link
Copy Markdown
Contributor

Summary

This PR adds property-based testing support via proptest and refactors the Cardinality enum to use uppercase constant naming conventions throughout the codebase.

Key Changes

  • Added proptest dependency: Integrated proptest 1.4 as a dev dependency in the root Cargo.toml and core/ir/Cargo.toml to enable property-based testing
  • Refactored Cardinality constants: Converted all Cardinality enum variants from PascalCase to SCREAMING_SNAKE_CASE:
    • Cardinality::One → Cardinality::ONE
    • Cardinality::Zero → Cardinality::ZERO
    • Cardinality::ZeroOrOne → Cardinality::ZERO_OR_ONE
    • Cardinality::ZeroOrMore → Cardinality::ZERO_OR_MORE
    • Cardinality::OneOrMore → Cardinality::ONE_OR_MORE

Implementation Details

  • Updated all usages across the codebase including:
    • Core IR modules (dag.rs, contract.rs, type_lib.rs, type_registry.rs)
    • Pattern builders (atomic.rs, branch.rs, loop_pattern.rs, transaction.rs, upsert.rs)
    • Signature validation (signature.rs)
    • Builder and test code (builder.rs)
  • The refactoring maintains backward compatibility at the API level while improving code consistency with Rust naming conventions for constants
  • proptest brings in a comprehensive dependency tree for property-based testing infrastructure (bit-set, rand, tempfile, etc.)

https://claude.ai/code/session_01Fa4CcJwTt7tCJG2p3isSKo

Cardinality is now modeled as a closed interval on ℕ ∪ {∞} instead of a
5-variant enum. This makes the model composable, extensible, and testable
with algebraic laws rather than hand-written truth tables.

Key changes:
- Cardinality is now a struct { min: u32, max: Option<u32> }
- Named constants (ZERO, ONE, ZERO_OR_ONE, ZERO_OR_MORE, ONE_OR_MORE)
  replace enum variants
- satisfies() is O(1) interval containment, not a 25-case match
- Lattice algebra: join, meet, product derived from interval arithmetic
- can_coerce_to() for safe widening detection
- Custom Serde: named strings for standard cardinalities, {min,max} for
  arbitrary ones (backward compatible with existing serialized data)
- Property-based tests (proptest) verify reflexivity, transitivity,
  commutativity, associativity, absorption, and serde roundtrip
- Arbitrary cardinalities like [2,5] now work without code changes
- All 962 tests pass across 18 crates

Migrated 125 call sites across 17 files (mechanical One→ONE etc.).

https://claude.ai/code/session_01Fa4CcJwTt7tCJG2p3isSKo
Value::StrList(Vec<String>) and Value::MapStrStr(BTreeMap<String, String>)
were ad-hoc shortcuts that broke compositional type layering. Replace with
generic Value::List(Vec<Value>) and Value::Map(BTreeMap<String, Value>)
that mirror BaseType's compositional structure.

Convenience constructors (Value::str_list, Value::str_map) and typed
extractors (as_str_list, as_map_str_str) preserve ergonomics while the
underlying representation is now fully compositional.

47 files updated across core/ir, core/exec, core/codegen, core/test,
core/testgen, gunbc-dag, and all lib/* crates.

https://claude.ai/code/session_01Fa4CcJwTt7tCJG2p3isSKo
- Extract Lattice traits (JoinSemilattice, MeetSemilattice, Lattice,
  BoundedLattice, PartialOrder, Semiring) into core/ir/src/algebra.rs
- Implement all traits for Cardinality (delegates to existing methods)
- Add property-based tests verifying algebraic laws via traits
- Add CardinalityCoverage obligation to testgen obligation model (Bucket B.3)
- Wire port_cardinalities into codegen for boundary coverage tests
- Generate per-case tests (Empty/One/Many) for non-scalar boundary ports

https://claude.ai/code/session_01Fa4CcJwTt7tCJG2p3isSKo
Merge main branch (testgen→codegen consolidation) and resolve conflict
in testgen/codegen.rs.

Additional consolidation:
- PortDef.cardinality: String → Cardinality struct (registry.rs)
- dag_gen.rs: match on Cardinality constants instead of string literals
- Custom interval fall-through in port code generation
- Update doc references to use UPPER_CASE constants (overview.md, TODONEs)

https://claude.ai/code/session_01Fa4CcJwTt7tCJG2p3isSKo
The ensure-codegen target used a "run once" stamp check that never
detected stale generated files. When IR types changed (e.g., Value
variant renames), the stamp file still existed from a prior codegen
run, so generated main.rs files were not regenerated.

Replace the shell if-exists check with Make's built-in timestamp
comparison: CODEGEN_SOURCES tracks all .rs files in core/codegen/src
and core/ir/src. The stamp file is now a real Make target that
depends on these sources, so Make automatically re-runs codegen
when any source is newer than the stamp.

Also: force codegen touches the stamp, clean removes it.

https://claude.ai/code/session_01Fa4CcJwTt7tCJG2p3isSKo
…ruth

The makegen tool registry was manually duplicated from the codegen
registry, requiring two places to be updated when adding a tool. This
also caused a flag mismatch bug: the Makefile passed shortened flags
(--repo, --base, --input) that the generated CLIs didn't recognize
(they expect --repo-path, --base-ref, --cargo-toml-path), silently
dropping arguments.

Changes:
- Add `make_var` field to CliEntrypoint for Makefile variable names
- Add `invocation` field to ToolDef for cargo run metadata
- Derive default_registry() from all_tools() via ToolInfo::from_tool_def()
- CLI flags in Makefile now match generated CLIs (fixes arg-dropping bug)
- Tools without invocation (like review) are automatically excluded
- Only ci (handwritten bootstrap binary) remains manually registered
- Add sync tests preventing future registry drift

https://claude.ai/code/session_01Fa4CcJwTt7tCJG2p3isSKo
Track known cases of duplicated lists, hardcoded paths, and implicit
dependencies that should be made structural: DAG builders as strings,
buck-out/gen in 4+ locations, static codegen source tracking, and
unverified meta-target dependency strings.

https://claude.ai/code/session_01Fa4CcJwTt7tCJG2p3isSKo
Fix: makegen_dag() declared tool_names as PortDef::list_nonempty("List")
which means "list of lists" — it's actually a list of strings. Changed
type_id to "String".

Add four new items to TODO_hacks from PR review analysis:
- "List" dual encoding as type_id and cardinality (28 files, needs design)
- CardinalityCoverage Empty case tests absence vs empty value (needs infra)
- Cardinality constants are flat, not compositional DAG nodes
- Concrete tool_names bug (fixed in this commit)

https://claude.ai/code/session_01Fa4CcJwTt7tCJG2p3isSKo
@briansrls
briansrls merged commit 5349c54 into main Feb 3, 2026
1 check passed
briansrls added a commit that referenced this pull request May 9, 2026
)

* docs(r3): §1.8 row #29 anthropic_wire_typed_serde_alignment CONSUMER_LANDED → PASSING

Cluster I (T-Anthropic-Wire) close-shape per cluster-analysis audit
§2 row I = "demo PR + ledger refresh". Refresh DECLARED→CONSUMER_LANDED
landed via PR #2399 (10-row sweep). This commit promotes #29 to PASSING
with named receipts:

- `anthropic_request_coproduct_wire_contracts_emit_targeted_serde`
  (src/v2/tests/src/pipeline.rs:6482) — emit-side wire-tag ratchet
- `anthropic_messages_request_body_json_matches_messages_wire_tags`
  (src/v2/tests/src/pipeline.rs:6918) — round-trip JSON equality

Both green at HEAD 9d9f7d7 (verified via
`cargo test -p v2-compiler-tests anthropic_ -- --skip should_fail`;
7/8 anthropic_ tests pass; the 1 fail is
`anthropic_messages_uses_typed_200_body_projection`, which belongs to
the separate 200-body coproduct slice 3 work tracked by
`structural_coverage_gap_anthropic_messages_200_residual` —
NOT in gate #29 scope per ROADMAP §"LLM service flattening" closure-trigger
identifier `rest_request_wire_serde_alignment` taxonomy).

Doc-only ledger receipt; no code changes. Mirrors gate #17 PR #2409 +
gate #23 PR #2418 close-shape.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* docs(r3): §1.7 — add #29 to concrete-exceptions list (codex review fix)

Per codex api-review on PR #2427 sha e93ae9f: the §1.8 row #29
promotion to PASSING was not mirrored in §1.7's "Concrete exceptions
at HEAD" list (which previously enumerated #97 + #28). Add #29 with
the same ratchet-citation shape as the existing entries to keep §1.7
consistent with the §1.8 ledger.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
briansrls added a commit that referenced this pull request May 14, 2026
The Blocker column listed #19–#23 as open while Current dispatch promotes

Co-authored-by: Cursor <cursoragent@cursor.com>
#20 to CONSUMER_LANDED + PASSING, which overlapped the range. Enumerate
#19, #21–#23, and #67 explicitly (P2 single-authority).
briansrls added a commit that referenced this pull request May 14, 2026
- Resolve §1.8 conflict: main gate #19 PASSING + session gate #20 PASSING
- §3 T-Numeric: Blocker lists #17/#21–#23/#67; exclude promoted #18/#19/#20/#24
- PM compile note: §9.1 cadence + 2026-05-14 §3 touch; cite gate #19 receipt
- r3-close-predicate: gate #19 HARNESS_NAMED; bucket 46 PASSING / 28 DECLARED;
  verdict 49 HARNESS_NAMED; ledger anchor notes row #19 merge

Co-authored-by: Cursor <cursoragent@cursor.com>
briansrls added a commit that referenced this pull request May 14, 2026
The Blocker column listed #19–#23 as open while Current dispatch promotes

Co-authored-by: Cursor <cursoragent@cursor.com>
#20 to CONSUMER_LANDED + PASSING, which overlapped the range. Enumerate
#19, #21–#23, and #67 explicitly (P2 single-authority).
briansrls added a commit that referenced this pull request May 14, 2026
The Blocker column listed #19–#23 as open while Current dispatch promotes

Co-authored-by: Cursor <cursoragent@cursor.com>
#20 to CONSUMER_LANDED + PASSING, which overlapped the range. Enumerate
#19, #21–#23, and #67 explicitly (P2 single-authority).
briansrls added a commit that referenced this pull request May 14, 2026
…dger sync) (#3081)

* R3 gate #23 — string_audit_receipt CONSUMER_LANDED + PASSING (documented-no-change)

§1.8 ledger promotion for gate #23 from DECLARED to CONSUMER_LANDED + PASSING.

Substrate state at HEAD:
- dsl/std/string_type.dag:17 declares `type String = FreeMonoid<Char>` —
  String is sequence algebra over Char, not a numeric carrier.
- Only `Char` remains in T-Numeric-Construction inherited scope.

Executable consumer (already merged):
- `assert_bootstrap_string_is_free_monoid_char` at
  src/v3/compiler/tests/integration/common/substrate_receipts.rs:387
- Exercised by `bootstrap_string_audit_receipt_per_gate_23` in
  src/v3/compiler/tests/integration/m1_substrate_test.rs:90.

Closure receipt (already merged):
- docs/audit/t-numeric-construction-string-audit-receipt.md

This PR is the post-merge §1.8 ledger sync per
`feedback_post_merge_ledger_receipt_sync` — the consumer + audit doc
landed in the prior T-Numeric residual-cluster slice
(docs/briefs/r3-t-numeric-residual-cluster-gates-19-21-22-23.md).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(r3-plan): correct line ref for assert_bootstrap_string_is_free_monoid_char (:387 → :395)

Per cursor/composer-2 review on #3081: at HEAD line 387 is inside
assert_bootstrap_float_aliases_real_width_refinements; the String ratchet
helper actually starts at line 395 (doc comment :393).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(r3-plan): drop volatile line ref for assert_bootstrap_string_is_free_monoid_char (symbol anchor)

Per cursor/composer-2 second BLOCKING finding on #3081: substrate_receipts.rs
has drifted again (now :468) due to repeated main-merges into this branch.
Replace the brittle :LINE pointer with a symbol-only citation
(`pub fn assert_bootstrap_string_is_free_monoid_char` in <file>); the symbol
is stable, line numbers are not.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
briansrls added a commit that referenced this pull request May 14, 2026
/#81/#91

§1.8 is canonical (INVARIANTS P2). Re-derive §3 T-Numeric residuals (drop stale
#23 DECLARED; ETA lists #23 as landed), fix T-CostLens #40 vs #70 wording, and
refresh the predicate-execution index: HARNESS_NAMED rows + verdict/buckets now
match mechanical §1.8 Status classification at HEAD (61 harness-eligible).

Co-authored-by: Cursor <cursoragent@cursor.com>
briansrls added a commit that referenced this pull request May 14, 2026
…tion) (#3097)

* WIP: R3 gate #20: numeric_inherited_bake_ins_dissolved (T-Numeric-Constructio

* WIP: R3 gate #20: numeric_inherited_bake_ins_dissolved (T-Numeric-Constructio

* docs(r3): promote gate #20 numeric_inherited_bake_ins_dissolved to PASSING

Record CONSUMER_LANDED + PASSING in §1.8 with producer/consumer citations
(types.dag Int refinements + m2_substrate_inhabitance_test ratchet). Refresh
§3 T-Numeric-Construction snapshot, PM compile note, and close-predicate index
(HARNESS_NAMED, bucket counts, ledger anchor text).

Co-authored-by: Cursor <cursoragent@cursor.com>

* docs(r3): align PM compile note header with 2026-05-14 §3 amendments

Optional editorial consistency from composer-2 review (cadence stamp vs
audit follow-up date).

Co-authored-by: Cursor <cursoragent@cursor.com>

* WIP: R3 gate #20: numeric_inherited_bake_ins_dissolved (T-Numeric-Constructio

* WIP: R3 gate #20: numeric_inherited_bake_ins_dissolved (T-Numeric-Constructio

* docs(r3): align §3 + predicate audit with §1.8 for gates #23/#40/#59/#63/#81/#91

§1.8 is canonical (INVARIANTS P2). Re-derive §3 T-Numeric residuals (drop stale
#23 DECLARED; ETA lists #23 as landed), fix T-CostLens #40 vs #70 wording, and
refresh the predicate-execution index: HARNESS_NAMED rows + verdict/buckets now
match mechanical §1.8 Status classification at HEAD (61 harness-eligible).

Co-authored-by: Cursor <cursoragent@cursor.com>

* docs(r3): sync PM compile T-CostLens clause with §1.8 + §3 lane row

§1.8 rows #37/#40/#70 are not both DECLARED; #40 is CONSUMER_LANDED + PASSING
and #70 INTEGRATION_RECEIPT (P2 single-authority vs §3 T-CostLens snapshot).

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
@briansrls
briansrls deleted the claude/review-todo-docs-qBlwx branch June 1, 2026 18:41
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.

2 participants