Skip to content

Add design brief for for/while loop sugar over Loop - #12085

Merged
briansrls merged 6 commits into
mainfrom
claude/adoring-edison-o4nz5e
Sep 24, 2026
Merged

briansrls merged 6 commits into
mainfrom
claude/adoring-edison-o4nz5e

Conversation

@briansrls

@briansrls briansrls commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This adds a design brief for implementing for and while as frontend sugar over the existing Loop behavior. It is a hand-off document in the shape of the blackjack onboarding brief, and it implements nothing.

  • dag/gunbc/plans/for_while_loop_sugar.dag is the authority, registered in gunbc.plan_registry_batch_g.
  • docs/plans/for-while-loop-sugar.md is its projection, rendered by gunbc.plan expected_plan_md. Its .gitattributes merge-driver row is included.

The design, as of the third cut

  • Rule: surface syntax chooses one canonical meaning. Dependency analysis may change scheduling but never reinterpret the source.
  • S0, the canonical encodings. Adds one optional ^loop_domain_edge on Loop instead of a seventh behavior. The carrier edge stays a binder, and initial state comes from an enclosing Bind. Result assembly is fixed by which edges are present. The brief states the current substrate as it is:
    • the grammar is unary loop <expr>;
    • both Loop interpreters reject;
    • the fold seam carries neither the list nor init.
  • S1, for over List<T> only. It lowers directly to the domain encoding, never through list_map. The body must be pure. The construct contributes no implicit positional edge between members.
  • S2, stateful while. It needs a Bool guard and a measure proven to decrease on a domain that can't decrease forever. The brief names four pieces the termination proof needs and one producer in v2.std.cardinality, which loop_multiplicity and inferred_facts_descent both read.
  • S3: the fold seam moves to the full encoding in one change. S4: EffectPlanStep.While shares the same measure. EffectPlanStep.For gets a stated divergence.
  • Refused: while (xs) and while (true).
  • Out of scope: services (a separate lifecycle design) and budgeted repetition.
  • Parallelism is a realization choice, not a keyword. Results and diagnostics are ordered by list index under every schedule.

Review history

  • The first cut lowered for through list_map, which is built on fold_list_right and would have installed a carrier.
  • The second cut was held in review because it:
    • described a Loop shape the substrate cannot represent;
    • gave the carrier edge two meanings;
    • specified a repeat that could not execute;
    • cited a termination-proof path that does not exist;
    • asked for a check whose failing case cannot be written.
  • The third cut corrects each of those in place.

🤖 Generated with Claude Code

https://claude.ai/code/session_01QBhtZJTkWo5Lf2TmCDJP35

…efault

Adds gunbc.plans.for_while_loop_sugar, a hand-off design brief in the shape
of the blackjack onboarding brief, registered in batch_g. for and while add
no core behavior: carrier-free for lowers to map, a carrier lowers to fold
through the existing fold seam, a decreasing while lowers to Loop with a
proven measure or refuses, and while true reuses the existing loop N form
with std.computation forever_iteration_bound. Iterations are independent
unless a carrier or an effect couples them; parallel realization stays a
separate, later change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QBhtZJTkWo5Lf2TmCDJP35
for lowers to a carrier-less Loop, not through list_map, whose
fold_list_right body installs the carrier the design exists to avoid.
A range index is a coordinate, not state. while is an explicit state
transition with a Bool guard and a proven measure; while(xs) and
while(true) are refused with named alternatives; repeat ... up_to: N is
the explicit budget with a typed exhaustion arm; long-lived services are
a separate lifecycle design. Results and diagnostics are ordered by
domain position under every permitted schedule. reduce and scan are
named as gated frontiers rather than minted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QBhtZJTkWo5Lf2TmCDJP35
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-22T23:25:44.091977Z 8252dd8 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8252dd86e1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread dag/gunbc/plans/for_while_loop_sugar.dag
Comment thread dag/gunbc/plans/for_while_loop_sugar.dag Outdated
claude and others added 4 commits September 22, 2026 23:35
…erence

docs/plans/for-while-loop-sugar.md is the gunbc.plan expected_plan_md
projection of gunbc.plans.for_while_loop_sugar. The spelling decision
points at section 12 Q2 rather than the deviations table, and the
admitted/refused table no longer carries an empty cell.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QBhtZJTkWo5Lf2TmCDJP35
Ledger-Repair-Judged: docs/design-rung-drops.md
Heal-Candidate-Run: 35798178176
Review held the brief because it described a Loop the substrate cannot
represent. This cut adds S0: one optional ^loop_domain_edge on Loop (no
seventh behavior), the carrier edge keeps its single binder meaning with
initial state from an enclosing Bind, and result assembly is fixed by
which edges are present. The existing state is stated honestly: the
grammar is unary loop <expr>, both Loop interpreters reject, and the fold
seam carries neither the list nor init (its migration is S3).

repeat is withdrawn (no budget path, uninhabited completed arm). The
per-loop termination proof gets four named joins and one producer in
v2.std.cardinality that loop_multiplicity and inferred_facts_descent both
read. S1 admits List<T> only. The construct guarantees no implicit
positional edge; independence is derived, and unresolved coupling is
refused for parallelism rather than serialized. The unauthorable
reduction-shaped-body diagnostic is deleted, and EffectPlanStep.For gets
a stated divergence beside While's conformance.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QBhtZJTkWo5Lf2TmCDJP35
@briansrls
briansrls added this pull request to the merge queue Sep 24, 2026
Merged via the queue into main with commit a035d86 Sep 24, 2026
5 checks passed
@briansrls
briansrls deleted the claude/adoring-edison-o4nz5e branch September 24, 2026 19:49
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