Skip to content

SY-3961: Arc Ranges RFC#2276

Open
sy-nico wants to merge 30 commits intorcfrom
sy-3961-arc-ranges-rfc
Open

SY-3961: Arc Ranges RFC#2276
sy-nico wants to merge 30 commits intorcfrom
sy-3961-arc-ranges-rfc

Conversation

@sy-nico
Copy link
Copy Markdown
Contributor

@sy-nico sy-nico commented Apr 28, 2026

Pull Request

SY-3961

Greptile Summary

This RFC defines the ranges module for the Arc language, exposing ranges.create and ranges.delete as dual-mode constructs (WASM host functions + Flow nodes). All concerns from the previous review round — color shadowing, non-transactional batch delete counter, missing type definitions for all three create variants, reportWarning/reportInfo signature ambiguity, Flow node Next() ignoring parent, and 3/4/5-arg dispatch description — have been addressed in this revision. The one remaining gap is the missing 4-arg create_with_color host function snippet in Section 5.1.0.

Confidence Score: 5/5

Documentation-only RFC; all previous blocking issues have been resolved and only a minor documentation gap remains.

All P0/P1 concerns from the prior round (color shadowing, non-transactional delete count, missing type definitions, reportWarning/reportInfo signatures, Flow node parent handling, dispatch arity description) have been addressed. The sole remaining finding is a P2 style gap (missing 4-arg snippet), which does not affect correctness.

No files require special attention beyond the minor snippet gap in Section 5.1.0.

Important Files Changed

Filename Overview
docs/tech/rfc/0036-260427-arc-ranges.md New RFC proposing the Arc ranges module (ranges.create / ranges.delete) with WASM host functions and Flow nodes; all prior review concerns resolved in this revision — one minor gap remains: the 4-arg create_with_color host function snippet is missing from Section 5.1.0.

Sequence Diagram

sequenceDiagram
    participant Arc as Arc Program (WASM)
    participant Host as Host Function (Go)
    participant RS as ranger.Service
    participant DB as Synnax Server

    Note over Arc,DB: ranges.create (3-arg)
    Arc->>Host: create(nameHandle, start, end)
    Host->>Host: strings.Get(nameHandle) → name
    Host->>Host: doCreate(name, start, end, "", zero ID)
    Host->>RS: w.Create(ctx, &rng)
    RS->>DB: persist range
    DB-->>RS: rng.Key (UUID)
    Host-->>Arc: strings.Create(key) → handle

    Note over Arc,DB: ranges.create (5-arg, with parent)
    Arc->>Host: create_with_color_parent(name,start,end,colorH,parentH)
    Host->>Host: resolveParent(parentStr)
    Host->>RS: NewRetrieve().WhereNames(parentStr)
    RS->>DB: query
    DB-->>RS: []ranger.Range
    Host->>RS: w.CreateWithParent(ctx, &rng, parentID)
    RS->>DB: persist range + ontology link
    DB-->>RS: rng.Key
    Host-->>Arc: handle

    Note over Arc,DB: ranges.delete (by name)
    Arc->>Host: delete(identifierHandle)
    Host->>RS: NewRetrieve().WhereNames(identifier)
    RS->>DB: query
    DB-->>RS: []ranger.Range
    loop for each matched range
        Host->>RS: w.Delete(ctx, rng.Key)
        RS->>DB: delete + cascade children
    end
    Host->>Host: reportInfo if deleted > 1
Loading

Reviews (5): Last reviewed commit: "SY-3961: Update RFC" | Re-trigger Greptile

sy-nico added 27 commits April 14, 2026 18:57
* Add ExecContext gates: analyzer rejects WASM-only nodes in flow statements, compiler rejects flow-only nodes in func blocks, LSP filters completions by execution context
* Add flow representation for `time.now` (C++ and Go), making it the first ExecBoth node
* Add optional `offset` parameter to `time.now` for both WASM and flow execution paths
* Support negated literals in flow config values (e.g. `offset=-3h`)
* Unit and integration tests across all layers
* Gate exec context at call sites rather than the resolver, because resolver gating conflates wrong-context with undefined, requiring extra error plumbing to distinguish them and to avoid passing `ResolveAny` to 22 unrelated interfaces
…g in CompoundFactory

Add status.set() as the preferred qualified form for set_status, with deprecation warning, LSP hover docs, and tests across Go and C++.

Fix a latent bug in CompoundFactory/MultiFactory where qualified names with the same member (e.g. authority.set vs status.set) would collide after prefix stripping. Factories can now declare a module name so the dispatcher routes to the correct one.
…upport

Move add, subtract, multiply, divide, mod, neg from op into math with deprecation warnings for bare forms. Symbols are ExecBoth, callable in both func blocks and flow statements. WASM host bindings added across all numeric types in Go and C++. pow remains ExecWASM only.

Consolidate shared code for integration tests and hover.go
…s.set routing

- Add SignedNumericConstraint kind that promotes unsigned types to wider signed equivalents (u8→i16, u16→i32, u32→i64, u64→f64) for math.neg
- Add cross-type negate ops (NegateU8/U16/U32/U64) in telem/op
- Handle promotion in both WASM compiler and flow constraint unifier
- Fix CompoundFactory routing: move ModuleName() to Module so status nodes don't intercept authority.set
- Restore status.set name config parameter
- Check exec context before argument validation in analyzer
…improve error messages, and validate now() offset type
…since both are now internal. The `len` hover doc remains. The compiler dispatch for `string.len` stays since it's used internally when `len()` dispatches based on argument type.
@sy-nico sy-nico requested review from emilbon99 and pjdotson April 28, 2026 04:13
Comment thread docs/tech/rfc/0036-260427-arc-ranges.md
Comment thread docs/tech/rfc/0036-260427-arc-ranges.md Outdated
Comment thread docs/tech/rfc/0036-260427-arc-ranges.md
Comment thread docs/tech/rfc/0036-260427-arc-ranges.md Outdated
Comment thread docs/tech/rfc/0036-260427-arc-ranges.md
Comment thread docs/tech/rfc/0036-260427-arc-ranges.md
Comment thread docs/tech/rfc/0036-260427-arc-ranges.md Outdated
Comment thread docs/tech/rfc/0036-260427-arc-ranges.md
@sy-nico sy-nico force-pushed the sy-3961-arc-ranges-rfc branch from c7d0401 to 120c35c Compare April 28, 2026 06:00
Comment thread docs/tech/rfc/0036-260427-arc-ranges.md
# 0 - Summary

This RFC proposes a `ranges` module for the Arc programming language that exposes Synnax
range operations, initially `ranges.create` and `ranges.delete`, as first-class language
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

note: we should standardize on singular / plural for module names. Currently you have
status.set (singular) and ranges.create (plural). I think singular would make the
most sense here.

```
ranges.create(name: string, start: timestamp, end: timestamp) -> string
ranges.create(name: string, start: timestamp, end: timestamp, color: string) -> string
ranges.create(name: string, start: timestamp, end: timestamp, color: string, parent: string) -> string
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

does this always have to be called in this exact order, even if i specify the arguments?

| ------------------------- | ----------- | -------- | ------- | ------------------------------------------------------ |
| `name` | `string` | yes | | Human-readable range name |
| `start` | `timestamp` | yes | | Start time (nanosecond epoch, inclusive) |
| `end` | `timestamp` | yes | | End time (nanosecond epoch, inclusive) |
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

end should probably default to TimeStamp.MAX, which is what it would mean to create an
in-progress range

| `color` | `string` | no | `""` | Hex color code (e.g., `"#FF0000"`) |
| `parent` | `string` | no | `""` | Parent range identifier (UUID key or range name) |
| `key` | `string` | no | auto | Pre-set UUID (server-generates if omitted). Flow-only. |
| `retrieve_if_name_exists` | `bool` | no | `false` | Return existing range if name matches. Flow-only. |
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

same comment as on statuses RFC: we should have same API for both Flow and WASM

error.

Flow config values are static constants (not runtime expressions), so dynamic timestamps
like `time.now() - 1h` require the WASM form.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why?


**Examples:**

```go
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

you shouldn't call these go if they use the Arc syntax

```

If multiple ranges share the parent name, the first match is used and a warning is
emitted.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is another place where you might want to think more about safety vs usability.
Warning / erroring when there are multiple ranges means that the user will have to
think and specify what they want to do upfront, which is generally safer and means we
won't be doing anything "magic". However, the user needs to think about it before they
call, or we make it a general pattern to use when using Arc (like how Go has if err :=
...; err != nil { ... } )

**Adaptations from client interface:**

- Arc uses separate `start` and `end` timestamps instead of a compound `TimeRange`
object because Arc has no struct or object types.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We might want to start thinking about how we could support an object / struct type in
Arc, especially for creating types like a range.Range type that we know has certain fields.

| `core/pkg/service/arc/runtime/factory.go` | Add `Ranger *ranger.Service` to `FactoryConfig` |
| `core/pkg/service/arc/runtime/task.go` | Instantiate ranges module in WASM builder + `CompoundFactory` |
| `core/pkg/service/layer.go` | Wire `l.Ranger` into `FactoryConfig` |
| `arc/go/compiler/expression/compiler.go` | Add `compileBuiltinRangesCreate` for 3/4/5-arg dispatch |
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

need C++ too

| `parent` | `string` | no | `""` | Parent range identifier (UUID key or range name) |
| `key` | `string` | no | auto | Pre-set UUID (server-generates if omitted). Flow-only. |
| `retrieve_if_name_exists` | `bool` | no | `false` | Return existing range if name matches. Flow-only. |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should consider a way to set the stage of a range as well

Base automatically changed from sy-4071-dot-module-syntax-followup to rc April 30, 2026 02:01
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