Repository navigation
docs: add TESTING.md + CODING.md (Google C++-style discipline) - #549
Conversation
Google C++-style testing guidelines for gunbc. Five principles: hermetic, behavior-driven, cost-of-change, one-claim-per-test, mocks-over-compile. Target ratios: ~75% unit / 15% integration / 10% boundary. Naming: <subject>_<verb>_<object>_<condition>. Names the DB-15 R2 `.dag`-native testing trajectory as the long-term shape; this document is the near-term discipline for Rust-side tests while that runtime matures. Also ships a current-state audit: 357 tests across 29 files bucketed by purpose, with refactor priorities (m0_acceptance audit, substrate walk collapse, testgen reshape, eventual port to .dag).
Google C++-style Rust implementation guidelines. Five principles: pure functions by default, data + free functions (not objects), clear interfaces, explicit dependencies, small and composable. CODING.md is the production-code twin of TESTING.md. Both referenced from CLAUDE.md so Claude sessions read them before working.
|
ChatGPT review in progress... (view conversation) Check back in ~30 minutes for the full review. |
This comment has been minimized.
This comment has been minimized.
|
claude-review — strong direction; recommend adopting with one structural addition (transition discipline) before merge. What's right
Reality check vs current stateThe docs prescribe several things the current codebase doesn't satisfy. This is fine if framed as aspirational with tracked transition discipline, but it should be named explicitly so the docs don't read as fictional. Specifically:
Recommended addition — "Adoption discipline" sectionBoth docs would benefit from a short section near the top naming the transition stance: ## Adoption
This document describes the live discipline for **new code and
refactors**. Existing code may not satisfy every prescription —
known divergences are tracked in ROADMAP under §Coding-discipline
debt, with dissolution triggers (typically: refactor-on-touch,
or a dedicated paydown lane).
The doc is enforced going forward; it does not retroactively
fail existing code. Reviewers should flag a NEW PR that violates
these guidelines as a `KEEP_ITERATING` signal; an EXISTING file
that violates them is documented debt, not a present failure.Without this, the doc reads as either fictional ("most code violates this") or as silent retrofit pressure ("all 24 integration-style tests should be rewritten"). Naming the transition stance:
Small specific items
SequencingIndependent of all in-flight PRs file-wise (only touches new docs + CLAUDE.md). Can land in any order; recommend landing soon since it doesn't block anything and starts shaping new PRs. VerdictLGTM with the adoption-discipline addition. Strong direction; minor framing addition keeps it honest with the live-state invariant. Two small specific clarifiers (mocks-over-compile scope; expressive vs amortization hidden state) would tighten the rules without expanding scope. Want me to draft the adoption-discipline section text and the two clarifiers if you want them in this PR rather than as a follow-up? |
Four changes addressing the claude-review feedback on #549: 1. "Adoption" section at top of both TESTING.md and CODING.md — describes the transition stance: the doc enforces forward, existing divergences are documented debt, reviewers flag violations in new PRs as KEEP_ITERATING signals. Keeps the docs honest against the live-state invariant without forcing a blocking refactor backlog. 2. TESTING.md "mocks over compile" scope clarifier — the anti-pattern applies to lens/accessor/single-pass tests where the subject is narrower than the pipeline. For integration / thesis / boundary tests, compile_to_dag IS the correct entry point. 3. TESTING.md post-R2 collapse note — once DB-15 R2 ships, most of the document becomes "see dsl/std/verification.dag"; Rust-side residual is compiler-internal unit tests + boundary tests only. 4. CODING.md hidden-state distinction — expressive dependency (always wrong) vs performance amortization with documented dissolution (acceptable at the edges). Also adds concrete pure-by-borrow accumulator examples pointing at compile_to_dag, emit_rust_module, and lower_* functions.
|
ChatGPT review in progress... (view conversation) Check back in ~30 minutes for the full review. |
briansrls
left a comment
There was a problem hiding this comment.
codex · gpt-5.4 · f3677091
BLOCKING (2)
Root Cause
TESTING.mdThe doc collapses crate-internal unit tests and external integration tests into one story; either land a real public Dag-construction test API or scope this guidance explicitly to internal test modules and mark the builder surface as future work.CODING.mdThe exception list was written against an aspirational or stale tree shape; verify concrete repo paths before codifying them, or describe the allowed impurity sites by role instead of naming files that are not present.
Non-blocking — Strengths
CLAUDE.mdReferencing CODING.md and TESTING.md from CLAUDE.md is the right place to make the new discipline load-bearing for contributors.
ROADMAP — Verified
- DB-15 trajectory: TESTING.md's .dag-native direction is consistent with the locked DB-15 R2 design in docs/design-test-infra.md and the current src/v3/std/verification.dag authority.
| predicate structurally. | ||
|
|
||
| At that point the hermetic principle still holds — each | ||
| `TestClaim` declaration is its own unit, the runtime just |
There was a problem hiding this comment.
BLOCKING: This section documents hand-built Dag helpers as the primary test surface, but the current repo exposes no such integration-test API (alloc_port is pub(crate) and the example's push_literal_value / push_transform do not exist), so it violates the THESIS verification rule by prescribing a workflow contributors cannot actually use.
|
Violations (could not place on specific lines):
|
|
BLOCKING (2) Root Cause
Non-blocking — Strengths
ROADMAP — Verified
|
Addresses codex review on #549 (sha f367709): 1. TESTING.md: minimal-Dag construction via push_* helpers is a crate-internal unit-test pattern today — those helpers are pub(crate), not part of the integration-test surface. Scope the guidance explicitly, name the broader public-builder API as tracked follow-up, and give practical guidance for the current narrow public surface (small compile_to_dag fixtures for integration tests, full builder for crate-internal unit tests). 2. CODING.md: replace the file-path-specific impurity list with role-based descriptions (build script / code-generation binaries / bootstrap / test amortization caches). File paths drift; roles don't. Removes the stale cli.rs reference and keeps the guidance accurate as the tree evolves.
ChatGPT ReviewGenerated by gpt-5-4-pro Here's a thorough review of PR #549 ( Principle audit.
Design question. Does the current Path to convergence.
Verdict. APPROVE — This PR is consistent with the thesis and modeling discipline. It enforces verifiability structurally, derives tests automatically from If you want, I can produce a concise table mapping |
Codex inline at TESTING.md:144: the doc named push_literal_value / push_transform / push_bind as the primary mocking surface, but the current repo only has alloc_port (pub(crate)); the others don't exist at all. Prescribing a workflow contributors cannot use violates the live-state invariant. Honest rewrite: - "Availability today" now says the builder API does not yet exist and names the full surface as tracked follow-up. - "Constructing a minimal Dag" framed as eventual shape, not current capability, with the per-variant granularity the builder should match when it lands. - "Practical guidance for now" lets integration tests use compile_to_dag(small_fixture) without apology until the builder arrives. The doc's direction (minimal-Dag construction as the unit-test primitive) is preserved; the current-state description matches what contributors can actually reach.
…x accumulator examples Codex: CODING.md cited paths that don't exist on main — src/v3/compiler/src/bin/cli.rs and tests/integration/common/cached_compile.rs. My earlier fix removed cli.rs via the role-based table but still cited cached_compile_to_dag by name; that function is in the in-flight #546 cache-consolidation PR, not on main today. Also: the accumulator-example text named compile_to_dag and emit_rust_module as &mut-threading patterns, but both return Result<Dag>/Result<String> — they aren't accumulators at the public boundary. Replaced with the actual accumulator pattern in the tree: lower::lower_into(&mut Dag, &SurfaceModule). The impurity table now describes the amortization-cache role generically without pointing at a specific function that doesn't exist on main.
|
ChatGPT review in progress... (view conversation) Check back in ~30 minutes for the full review. |
|
Meta-review in progress... (view conversation) Loop-health check: is this review cycle making forward progress, or shifting debt? Posts in ~5-15 minutes. |
|
Meta-review in progress... (view conversation) Loop-health check: is this review cycle making forward progress, or shifting debt? Posts in ~5-15 minutes. |
ChatGPT ReviewGenerated by gpt-5-4-pro Here’s a detailed review of PR #549 (docs: add TESTING.md + CODING.md) under the modeling discipline and project invariants, based on the PR files and the complementary context from THESIS, INVARIANTS, ROADMAP, and MODELING.mdchatgpt-review-cf07f05b-6986-4b… chatgpt-review-4cf526c6-66c0-49… chatgpt-review-a52636e2-36b9-4b… chatgpt-review-6b659dec-4b5d-4f… chatgpt-review-671d648d-8974-4e… . Principle audit1. Fail-closed — Satisfied. The TESTING.md doc explicitly frames every test tier (type, operation, service, workflow, real execution) as mechanically derivable and fail-closed; every invalid input triggers a rejection or diagnostic. There is no suggestion of silent chatgpt-review-a52636e2-36b9-4b… . 2. Illegal states unrepresentable — Satisfied. Both TESTING.md and CODING.md define tests against all structural variants of product/coproduct nodes and refinement types. Examples such as . 3. Facts flow forward — Partially satisfied / advisory. TESTING.md codifies the generation of tests from . 4. Coproduct dissolution — Satisfied. All examples of product and sum types are either fully decomposed into testable fields (variant-is-data) or mapped to algebraic forms in std DAGs (e.g., operators in OrderedRing, service operations). Scaffold status is explicit where needed (e.g., FnExternalBody, ArrowBody::Unparsed), with clear triggers for when user code may encounter them. Ledger entries / dissolution triggers match modeling discipline expectationschatgpt-review-671d648d-8974-4e… . 5. Single-authority metadata — Satisfied. TESTING.md and CODING.md consistently reference chatgpt-review-671d648d-8974-4e… . 6. API-level enforcement — Mostly satisfied. The docs describe mechanical derivation of tests and insist that all fields and variants be exercised. Structural enforcement is described for generating tests from 7. Loop health — Converging. This PR adds documentation scaffolding, defines structural test tiers, and references CODING.md from CLAUDE.md to integrate discipline into contributor workflow. It does not introduce new debt; it scaffolds consumer enablement by making testing and coding practices explicit. Pending work is clearly tracked (builder helpers, real Design questionDeepest structural question: How will the TESTING.md scaffold integrate with the actual
. Path to convergenceMust do before merge (blocking for full correctness):
Can ship as tracked follow-up debt (non-blocking):
VerdictAPPROVE_WITH_COMMENTS — The documentation is well-structured, aligns with the six modeling principles, and codifies the test-generation philosophy. Approval is conditional on marking aspirational references ( LOOP HEALTH: converging — scaffolds defined, consumer integration pending, no untracked debt introduced. |
Meta-Review (Loop Health)Generated by gpt-5-4-pro Here's a structured META-review of PR #549 based on the materials you provided (diff, prior reviews, THESIS, INVARIANTS, ROADMAP, MODELING.md): Loop Summary
The loop has been active, structured around PR #549, with iterative commentary and principle-based audits. Each round referenced the modeling-discipline, THESIS, and INVARIANTS. Forward Progress Evidence
.
.
chatgpt-review-8f3a6606-1b3f-40… . Debt Accumulation Evidence
Cheating Signal
Path to ConvergenceNext actions to justify KEEP_ITERATING:
SHIP_WITH_DEBT:
No untracked scaffolds, bridges, or ungrounded metadata remain. The loop is structurally sound; convergence is near-complete pending the guard-path verification. Meta-Verdict⚖️ SHIP_WITH_DEBT — forward progress is strong; all structural principles satisfied. The remaining scaffold ( Summary: The review loop successfully codified testing discipline (TESTING.md, CODING.md) per the modeling principles. Structural derivations are complete; scaffolds are bounded and documented; no hidden debt accumulates. Remaining debt is acceptable and trackable. If you want, I can produce a concise table of |
Summary
TESTING.md— hermetic, behavior-driven, unit-first test discipline. Five principles; target ratios 75% unit / 15% integration / 10% boundary. DB-15 R2.dag-native testing as the long-term shape.CODING.md— Google C++-style Rust implementation style. Pure functions by default, data + free functions (not objects), clear interfaces, explicit dependencies, small and composable.CLAUDE.mdupdated to reference both so Claude sessions read them before working.Both documents match the user's articulated style — imperative/functional Google C++, pure functions, clear interfaces, heavy use of dependency injection / mocks for testing. No code changes, pure documentation.
Anti-patterns called out
In CODING.md: builder patterns with mutable fluent interfaces, trait hierarchies for domain concepts, hidden state via
LazyLock<Mutex>in library code, god functions / god modules, panics inside library code.In TESTING.md: compiling a full source to test a single lens, asserting on implementation details (HashMap key order, error message substrings), cross-test shared state, multi-claim tests, testing private state through public surfaces.
Migration audit included
TESTING.md ships a current-state audit of the 357-test v3 suite with refactor priorities (ROI-ordered):
m0_acceptance.rs(41 tests from M0 skeleton, likely subsumed by later milestones)m1_substrate_test.rs(91 imperative substrate-walk assertions → ~20 lens-based claims)m1_5_testgen_test.rs(300s; spot-check or#[ignore]-by-default).dagonce DB-15 R2 runtime landsTest plan
m0_acceptance.rsaudit)🤖 Generated with Claude Code