Skip to content

docs(adr): draft ADR-0007 — set is always an effect - #71

Merged
rsenna merged 2 commits into
mainfrom
adr-0007-set-effect
Sep 12, 2026
Merged

rsenna merged 2 commits into
mainfrom
adr-0007-set-effect

Conversation

@owkwo-bot

@owkwo-bot owkwo-bot commented Sep 12, 2026

Copy link
Copy Markdown
Collaborator

Drafts ADR-0007, deciding the design note's §4.4 open question:

  • set is always an effectset :x to <expr> is classified
    effectful (mutation), unconditionally, regardless of which mutable
    engine it targets. Any form calling set is impure.
  • Transaction rollback doesn't change that. Purity is a static,
    evaluation-time property (per ADR-0006), not a runtime-outcome one. A
    set that later rolls back was still an attempted mutation when it
    evaluated — outcome-dependent purity would be unsound for any future
    type checker (rollback can depend on state set never sees).
  • let stays pure only for the lexical engine — restates (doesn't
    re-decide) ADR-0006's existing rule, for a complete let/set picture.
    The asymmetry is intentional: set on a lexical binding is already an
    error (AGENTS.md), so set never has a pure case to begin with.

Status: Proposed — acceptance = editing the Status line, same
convention as ADR-0006.

Also updates the design note §4.4/§7 and execution-queue.md's epic
008/009 criteria to link ADR-0007 in place of the interim "planned"
placeholder.

Part of the epic 007 unblock path (ADR-0006 merged → ADR-0007 (this) → ADR-0008 + IK1 grammar ADR → 008 → 007).

Summary by Sourcery

Draft ADR-0007 to establish that every set is an effect regardless of its target or transaction outcome, unblocking the dependent binding-model and binding-kind work.

New Features:

  • Draft ADR-0007 defining set as unconditionally effectful and restating the lexical-engine-only purity rule for let.

Enhancements:

  • Clarify that transaction rollback does not alter the static purity classification of set or make mutation pure by outcome.
  • Resolve the design note’s §4.4 open question and document the resulting implications for binding taxonomy and future type checking.

Documentation:

  • Link the design note and execution queue criteria to ADR-0007 and replace the interim planned ADR-0007 references.

Summary by cubic

Drafts ADR-0007, resolving the design note's §4.4 open question: set is always an effect (mutation), regardless of target engine, expression purity, or transaction outcome, so any form calling set is impure. Status is Proposed — acceptance means editing the Status line, same convention as ADR-0006. Also updates the design note and execution queue to link ADR-0007, and incorporates the first review round's fixes.

What this decides

  • Transaction rollback does not make a set pure; purity is a static, evaluation-time property per ADR-0006, and outcome-dependent purity would be unsound for a future type checker.
  • set is deliberately exempt from the ^action ^t pattern — it mutates immediately during evaluation, gated by the transaction contract, not built-then-run.
  • let is pure only for the lexical engine, and only when <expr> is itself pure; set has no pure case since set on a lexical binding is an error.
  • No "pure by luck" allowance: a set inside a rolled-back transaction is still impure; authors needing that pattern use an ^action a caller runs.
  • Unblocks the epic 007 path: ADR-0006 merged → ADR-0007 → ADR-0008 + IK1 grammar ADR → epic 008 → 007.

Written for commit a4f4c63. Summary will update on new commits.

Review in cubic

Decides the design note's §4.4 open question:

- `set :x to <expr>` is classified effectful (mutation), unconditionally
  — independent of which mutable engine it targets and of whether the
  enclosing transaction ever commits. Any form calling `set` is impure.
- Resolves the transaction-rollback wrinkle the design note raised
  directly: purity is a static, evaluation-time property (per
  ADR-0006), not a runtime-outcome one. A set that later rolls back was
  still an attempted mutation at evaluation time — treating rollback as
  purity-restoring would make purity depend on runtime state, which
  ADR-0006 already rules out, and would be unsound for any future type
  checker (rollback can depend on state set doesn't see).
- Restates (does not re-decide) ADR-0006's let-into-mutable-engine rule
  for a complete let/set picture: let is pure only for the lexical
  engine; set never has a pure case, because set on a lexical binding
  is already an error (AGENTS.md).

Status: Proposed (acceptance = editing the Status line, same
convention as ADR-0006).

Also updates design-note.md §4.4/§7 and execution-queue.md's epic
008/009 criteria to link ADR-0007 in place of the interim "planned"
placeholder.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012SbjL7643FUSoVuwCGtkJv
@sourcery-ai

sourcery-ai Bot commented Sep 12, 2026

Copy link
Copy Markdown

Reviewer's Guide

This PR drafts ADR-0007, establishing that set is always a statically effectful mutation—even when a transaction later rolls back—while retaining lexical-only purity for let; it then wires that decision into the design note and epic 008/009 dependency criteria.

File-Level Changes

Change Details Files
Adds a proposed ADR that makes every set evaluation effectful and explicitly separates static purity from transaction outcomes.
  • Classifies set as unconditional mutation across all mutable engines, regardless of expression purity or rollback.
  • Explains rollback as a runtime outcome that cannot retroactively affect static, evaluation-time purity.
  • Restates that only lexical-engine let is pure and documents the intentional let/set asymmetry.
  • Defines scope, non-decisions, consequences, and follow-up responsibilities for epics 008 and 009.
specs/decisions/ADR-0007-set-effect-classification.md
Connects the new ADR to the design note and execution dependencies, replacing interim planned references with explicit links.
  • Marks §4.4 as decided by proposed ADR-0007 and records the set classification.
  • Updates epic 008 and 009 dependency/start criteria to require ADR-0007 acceptance.
  • Preserves ADR-0006 as the source for the existing effect-model and lexical let rules.
specs/006-strictness-effects-spike/design-note.md
specs/execution-queue.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai

coderabbitai Bot commented Sep 12, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 18 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 42529143-a39b-44fc-9a8e-a87835acf278

📥 Commits

Reviewing files that changed from the base of the PR and between e8519c9 and a4f4c63.

📒 Files selected for processing (3)
  • specs/006-strictness-effects-spike/design-note.md
  • specs/decisions/ADR-0007-set-effect-classification.md
  • specs/execution-queue.md

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@sourcery-ai sourcery-ai 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.

Hey - I've found 2 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="specs/decisions/ADR-0007-set-effect-classification.md" line_range="61-71" />
<code_context>
+- Per ADR-0006, purity is a property of **evaluation**, determined
</code_context>
<issue_to_address>
**issue (broader_impact):** ADR-0007 defines `set` as an evaluation-time mutation attempt but does not reconcile that behavior with ADR-0006 and `LANGUAGE.md`, which say effectful forms produce `^action ^t` values and effects execute only at explicit effect boundaries. Implementers cannot determine whether `set` mutates immediately during ordinary evaluation, returns an action to be run later, or is a special evaluation effect outside the `^action` model.

**Triggers:** When a future type checker or runtime implements the `^action` marker model.

**Suggested fix:** Explicitly state that `set` is an immediate evaluation-time mutation that is effectful without returning `^action`, and explain why it is intentionally exempt from the action-boundary rule; alternatively specify that `set` returns an action and revise the surrounding purity examples accordingly.
</issue_to_address>

### Comment 2
<location path="specs/decisions/ADR-0007-set-effect-classification.md" line_range="55" />
<code_context>
+  form whose evaluation calls `set` is impure — there is no condition under
+  which a `set`-calling form is nonetheless pure.
+- This is unconditional on **which** mutable engine is targeted
+  (`graph` / `dynamic` / `reactive` / `sync`) and on **whether `<expr>`
+  itself is pure** — evaluating `<expr>` may be pure, but the `set` that
+  consumes its result is not.
+
+### 2. Transaction rollback does not change the classification
+
</code_context>
<issue_to_address>
**nitpick:** The ADR names `sync` as a mutable engine, but the canonical binding table in `LANGUAGE.md` names that engine `synchronised` and only uses `sync` in the `sync%token` binding prefix. Epic 009 implementers following the ADR can therefore treat `sync` as the engine identifier and diverge from the established taxonomy.

**Triggers:** When epic 008/009 defines the engine mapping and binding-kind vocabulary.

**Suggested fix:** Use the established engine name `synchronised` (or explicitly declare `sync` as its canonical abbreviation and update the binding table).

```suggestion
  (`graph` / `dynamic` / `reactive` / `synchronised`) and on **whether `<expr>`
```
</issue_to_address>

Sourcery assessment

Approval pending. 1 finding to address first.

Blocking findings: specs/decisions/ADR-0007-set-effect-classification.md:71


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread specs/decisions/ADR-0007-set-effect-classification.md
Comment thread specs/decisions/ADR-0007-set-effect-classification.md Outdated

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 3 files

Heads up: you’re close to your included review allowance. Set a flex budget so reviews don’t pause.

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread specs/decisions/ADR-0007-set-effect-classification.md Outdated
Comment thread specs/decisions/ADR-0007-set-effect-classification.md Outdated
Comment thread specs/decisions/ADR-0007-set-effect-classification.md
Comment thread specs/decisions/ADR-0007-set-effect-classification.md Outdated
Five review findings from sourcery-ai + cubic-dev-ai, all valid:

- `set` vs the ^action model was never reconciled: ADR-0006 models IO
  effects as build-then-run ^action values, but set mutates immediately
  during evaluation. Added an explicit exemption: set is a language
  primitive gated by the transaction contract, not a composable IO
  action -- there's no useful "build the intent to set, run it later"
  split the way cp "a" "b" usefully represents a copy intent. set was
  already classified this way pre-^action; this ADR keeps it there.
- `set :x` used the lexical sigil (:name) as a set example, which this
  same ADR says set must reject. Replaced with LANGUAGE.md's own
  confirmed example, `set $a to <expr>` (dynamic engine).
- Engine name `sync` doesn't match the canonical `synchronized`
  (AGENTS.md's non-negotiable rule); fixed throughout, with a note that
  LANGUAGE.md's own Transaction contract section abbreviates it as
  `sync` and epic 008 settles the canonical name.
- `let :x be run :action` would have been misclassified pure: the ADR
  said lexical `let` is pure by engine alone, but purity needs `<expr>`
  itself to be pure too -- the lexical engine only removes the *extra*
  effect a let could add (the commit), it doesn't launder whatever
  <expr> does. Qualified §3 accordingly.
- The AGENTS.md quote was misattributed partly to LANGUAGE.md and used
  the wrong engine list; fixed to cite AGENTS.md verbatim.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012SbjL7643FUSoVuwCGtkJv
@sonarqubecloud

Copy link
Copy Markdown

@sourcery-ai sourcery-ai 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.

Sourcery assessment

Approved.

@rsenna
rsenna merged commit b3bca16 into main Sep 12, 2026
7 checks passed
@rsenna
rsenna deleted the adr-0007-set-effect branch September 12, 2026 00:32
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