You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Framework: non-Provider value types — exported struct fields vs +devlore:property accessor methods #287
Surfaced during phase-8 box 2 (eager property projection). The goast value types (SourceFile, GenDeclNode, FuncDecl) and other non-ProviderAnnounceType types raised a design question about how they should surface data to starlark.
What is true today (starlark bridge / goReceiver)
Methods → starlark callables. Without codegen, parameter names are lost — all arguments are positional (the reflection-derive path auto-names params 0, 1, …). Codegen MethodMetadata.ParameterNames is what restores named/kwarg dispatch.
Exported fields → starlark values, read-only.goReceiver implements starlark.HasAttrs but not HasSetField, so x.field = v is rejected. Fields project eagerly via reflection — no codegen, no dispatch, no RuntimeEnvironment.
Codegen can mark a parameterless method returning a value or (value, error) as a property via the +devlore:property directive → op.ModifierProperty → eager dispatch at attribute access.
The question
Should non-Provider value types expose their data as exported struct fields (read-only starlark values) instead of +devlore:property accessor methods? I.e. turn every +devlore:property accessor on a non-Provider type into a struct field.
Trade-offs
Fields: simplest surface — eager read, no dispatch, no env, no Modifiers codegen. But the data must be stored/precomputed as an exported field; it cannot be lazy or computed-on-read, and is read-only from starlark.
+devlore:property methods: keep encapsulation / lazy computation, but go through the reflection goReceiver dispatch and therefore require the Provider-scoped env handling landed in box 2.
This is specifically about non-Provider types. Provider getters (e.g. config.get) are inherently lazy methods and cannot be fields.
Scope
goast: SourceFile, GenDeclNode, FuncDecl
provider Observation types (file / git / pkg)
any future AnnounceType value type
Decision needed
Standardize non-Provider value types on exported fields (and retire +devlore:property for them), keep the method-property approach, or allow both.
See docs/plans/extract-starlark-from-op/phase-8/eager-property-projection.md.
Ruled on 2026-11-06, on the owner's word, and closed as declined.
A value type that is not a provider exposes its data to Starlark as exported struct fields, read as values with no generated code. The framework converts Go types to Starlark and back, and reflecting the Go code in Starlark is what we want. Read on develop the same day, goReceiver.Attr (pkg/op/starlarkbridge/go_receiver.go, line 222) resolves an exported field first and converts it by reflection when the attribute is read, one field at a time, and Starlark cannot assign to it.
Presenting a computed value as a Starlark property rather than a method is a nice-to-have, not a must-have. A computed value can be stored in an exported field, answered through op.AttributeResolver.ResolveAttr, or offered as a method; +devlore:property stays for the rare case that wants it. So this question needs no further work.
This is a design question, and design is engineering: its Area is Engineering.
Activity
David-Noble-at-work commentedon Nov 6, 2026
Ruled on 2026-11-06, on the owner's word, and closed as declined.
A value type that is not a provider exposes its data to Starlark as exported struct fields, read as values with no generated code. The framework converts Go types to Starlark and back, and reflecting the Go code in Starlark is what we want. Read on
developthe same day,goReceiver.Attr(pkg/op/starlarkbridge/go_receiver.go, line 222) resolves an exported field first and converts it by reflection when the attribute is read, one field at a time, and Starlark cannot assign to it.Presenting a computed value as a Starlark property rather than a method is a nice-to-have, not a must-have. A computed value can be stored in an exported field, answered through
op.AttributeResolver.ResolveAttr, or offered as a method;+devlore:propertystays for the rare case that wants it. So this question needs no further work.This is a design question, and design is engineering: its Area is Engineering.