Skip to content

feat(runtime): invoke an operation with a positional argument list - #462

Merged
HuiJun merged 5 commits into
developfrom
feature/positional-invoke-arguments
Sep 21, 2026
Merged

HuiJun merged 5 commits into
developfrom
feature/positional-invoke-arguments

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

What and why

Context.InvokeOperation bound arguments by name only, and %invoke refused anything not written <p>=<expr>. An invocation in the model already binds positionally, so the two surfaces disagreed with each other and with the spec.

type OperationArguments struct {
    Positional []Value
    Named      map[string]Value
}
func (ctx *Context) InvokeOperationWith(inst *Instance, name string, args OperationArguments) (map[string]Value, error)
func (ctx *Context) InvokeOperation(inst, name, args map[string]Value) // now delegates: OperationArguments{Named: args}
  • A positional list binds to semantics.Model.SignatureParametersOf(op)signatureOf's effective in/inout parameters in signature order, out and result excluded — so a trailing defaulted parameter may be omitted, an inout takes a position and comes back as a result, and an out takes none. No second binder: this is the same signature an InvocationExpression is bound to.
  • operationOf now collects every same-named member and, when there are several, selects through semantics.Model.SelectAmongArguments (the evaluator's overload selection), so two calcs scaled(factor) / scaled(factor, offset) are told apart by arity.
  • Typed refusals: ErrMixedArguments (KerML: an ArgumentList is positional or named, never both), ErrOperationArity for a surplus positional, ErrUnboundParameter unchanged for a missing required one.
  • REPL: %invoke <object> <op> [<expr>... | <p>=<expr>...] via a new parseInvokeArguments; a mixed list and a parameter named twice are refused before the object is resolved (so a rejected command still materializes nothing). The shared splitArgs/continuesExpr gained one rule — a <name>=… fragment always starts a new argument — so 1 n=2 no longer glues into one unparsable token; %calc/%analysis keep their existing named-argument refusal.
  • The gRPC/proto surface and the Python client expose no operation invocation, so nothing there changed.

Shared plumbing touched: repl/meta.go continuesExpr (one added clause) and semantics/binding.go (new exported SignatureParametersOf adapter over signatureOf).

Specification basis

KerML 1.0 §8.2.5.8.3 (ArgumentList is a PositionalArgumentList or a NamedArgumentList) and §8.4.4.9.5 (a positional list binds the behavior's parameters in declaration order). Extends the Classifier Behaviors invocation row in docs/project/spec-compliance.md; the "Operation invocation with positional arguments" bullet leaves "Major Features Not Implemented"; roadmap E6 recorded as landed.

How it was verified

  • runtime/classifier_behavior_test.go:TestInvokeOperationWithPositionalArguments — defaulted trailing parameter, inout, out, arity-resolved overloads, fewer/surplus/mixed lists, named out.
  • New runtime/robustness_positional_invoke_test.go (TestRuntimeRobustnessPositionalInvoke).
  • repl/classifier_behavior_test.go:TestInvokeBindsPositionalArguments, :TestInvokeReportsItsFailureModes (mixed, surplus, twice-named); object_args_test.go malformed-command cases extended.
  • go build ./..., go vet ./..., gofmt -l . empty, go test ./... green; training and pilot corpus gates green with corpora downloaded; scripts/changelog.py check and scripts/check-doc-ids.py clean.

Checklist

  • make test and make lint pass locally
  • Tests added or updated for the change
  • Documentation extended where it already covers the surface (see CONTRIBUTING.md)
  • Changelog entry added as changes/unreleased/<slug>.<section>.md, not as an edit to CHANGELOG.md
  • baselines regenerated and make docs-counts run if a gate count moved (compliance rows need nothing: the census is counted at docs build)
  • No internal work-item labels (waves, slices, F4, K5) in the body, docs, or changelog

@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration
devin-ai-integration Bot marked this pull request as ready for review September 20, 2026 17:30
devin-ai-integration[bot]

This comment was marked as resolved.

@devin-ai-integration
devin-ai-integration Bot force-pushed the feature/positional-invoke-arguments branch from f2e3521 to c6214f2 Compare September 20, 2026 19:54
devin-ai-integration[bot]

This comment was marked as resolved.

@devin-ai-integration
devin-ai-integration Bot changed the base branch from develop to docs/protocol-state-machines-design September 20, 2026 20:03
@devin-ai-integration
devin-ai-integration Bot added this pull request to stack #476 September 20, 2026 20:04
Base automatically changed from docs/protocol-state-machines-design to develop September 21, 2026 01:30
devin-ai-integration Bot and others added 4 commits September 20, 2026 18:30
InvokeOperationWith takes OperationArguments, positional or named, binding a
positional list to the operation's effective input parameters in signature
order (semantics.Model.SignatureParametersOf) and selecting among same-named
members through SelectAmongArguments. A mixed list is ErrMixedArguments and a
surplus ErrOperationArity. %invoke accepts bare expressions beside its
<p>=<expr> pairs.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
The field splitter drops string delimiters, so a positional or named
string literal reached the argument parser unquoted. %invoke now cuts the
object and operation off the raw line and parses the rest verbatim.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
… develop

Co-Authored-By: jason.han <hanhuijun@gmail.com>
An expression's overload selection sets actions aside whenever a calc of the
name exists, since only a calc yields the value the expression needs. An
operation invocation runs either, so it selects in a mode of its own,
PerformsOperation, where the arguments alone decide between them.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
@HuiJun
HuiJun force-pushed the feature/positional-invoke-arguments branch from 4f8c00a to 9c10876 Compare September 21, 2026 01:30
devin-ai-integration[bot]

This comment was marked as resolved.

…ation

Co-Authored-By: jason.han <hanhuijun@gmail.com>
@HuiJun
HuiJun merged commit 2a65273 into develop Sep 21, 2026
15 checks passed
@HuiJun
HuiJun deleted the feature/positional-invoke-arguments branch September 21, 2026 02:13
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.

1 participant