Skip to content

Freeze the language contracts for loops, calls and text templates - #13

Merged
ancongui merged 14 commits into
mainfrom
feat/language-contracts
Oct 8, 2026
Merged

ancongui merged 14 commits into
mainfrom
feat/language-contracts

Conversation

@ancongui

@ancongui ancongui commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Language milestone M0 (contract freeze). Lanes E, A and O can now build on frozen names; the compiler still refuses every new construct.

  • Definitions accept forEach, callWorkflow, spec.callable, concat and join inside weave/v1alpha1; workflow.schema.json exports ForEachStep, CallWorkflowStep and CallableSpec. Existing documents and artifacts keep their canonical bytes and digests.
  • Every compiler entry point reports WV-COMP-UNSUPPORTED_FEATURE at each use of forEach, callWorkflow, concat or join; callable compiles because it only declares an interface.
  • Instance-key grammar (spec 3.2, C11) with parse, format and view functions, one regular expression and the API field types.
  • Executables gain a frozen, always-empty features field; no IR version beyond weave/ir-v1alpha3 is emitted or accepted.
  • Language manifest with studio: ready | pending marks, served through the platform API, the CLI, the SDK, the Studio host and weave schema export. Capabilities.step_kinds now lists all ten runnable kinds (it listed eight).
  • Studio's schema-coverage.test.ts reads the manifest and compares only ready entries.
  • Frozen scope_at signature and result models; the analysis lands with the loop compiler.
  • Shared fixtures for Python and Studio, examples in examples/language/, and contract documentation.

Frozen names other lanes import

Contract Name
Instance keys (C11) firefly_weave.contracts.instance_keys: InstanceKey(node_id, indexes=(), segments=(), count=None), InvalidInstanceKey, node_of, split_instance, format_instance, InstanceView(node_id, instance_key, iteration), instance_view, INSTANCE_KEY_PATTERN (unanchored; Python uses re.fullmatch, ECMAScript and JSON Schema use ^(?:...)$), InstanceKeyText, InstanceKeyTextOrEmpty
Feature vocabulary (C5) firefly_weave.contracts.language_features: LanguageFeature (text.concat, text.join, flow.forEach, flow.callWorkflow, ai.agent, ai.memory), LANGUAGE_FEATURES, ADVERTISED_FEATURES (empty in M0), KIND_FEATURES, OPERATOR_FEATURES, WORKFLOW_FIELD_FEATURES, DEFAULT_LOOP_MAX_ITEMS, MAX_LOOP_ITEMS, MAX_LOOP_DEPTH, MAX_RUN_ITERATIONS, MAX_CALL_DEPTH
Manifest (C5) firefly_weave.contracts.language: LanguageManifest, ManifestStepKind, ManifestOperator, ManifestWorkflowField, ManifestBlock, ManifestLimits, Arity, language_manifest(features=ADVERTISED_FEATURES), supported_step_kinds(features=ADVERTISED_FEATURES), IR_VERSIONS, MANIFEST_VERSION = "weave/language-manifest-v1"
Manifest access language.read = GET /api/v1/tenants/{tenant}/projects/{project}/language (catalog.read, bridged to Studio as family language); Studio host GET /studio/contracts/language; weave remote language; WeaveClient.language(); weave schema export writes language-manifest.schema.json
IR firefly_weave.compiler.ir: ExecutableBase.features: list[LanguageFeature]; IR_VERSION_EXTENSIONS = "weave/ir-v1alpha4" (spec 3.1 name; defined, not accepted until M1)
Compiler firefly_weave.compiler.language_support: COMPILED_FEATURES, UnsupportedUse, unsupported_uses(document); diagnostic WV-COMP-UNSUPPORTED_FEATURE
Scope firefly_weave.compiler.scope: scope_at(document, path, *, catalog=None) -> ScopeResult, ScopeResult, ScopeEntry, ScopeSource
Definitions ForEachStep, CallWorkflowStep, CallableSpec, CallerNames, WorkflowSpec.callable, OperatorName with concat and join
Shared fixtures studio/tests/fixtures/language/instance-keys.json, text-conversion.json, manifest.json, generated by scripts/language_fixtures.py (--check for freshness)

Instance-key node IDs are the ASCII set @?[A-Za-z0-9][A-Za-z0-9_.:@-]* (step IDs and the synthetic @ IDs).

Not in this pull request

  • Compilation, runtime and simulation of the new constructs (language milestones M1 to M9) and the agent manifest entry (Lane A).
  • Shared fixtures for template segments (spec 4.5) arrive with M1, and scope_at cases (spec 14.3) with M3, when the code that produces them exists. Spec 14.5 lists them with M0, "extended by later milestones"; this pull request publishes the instance-key, text-conversion and manifest fixtures.

Follow-ups for later milestones

  • M1: language_manifest(features) and Capabilities must add weave/ir-v1alpha4 to ir_versions once a feature is listed.
  • M1: an unknown string in an artifact's features must classify as ir_unsupported, not a generic contract error (the field is typed with the six frozen values).
  • M1: OperatorName now admits concat and join in provider-source mappings too; until they are evaluated there, such a mapping fails with a generic "Invalid request value".
  • M3/M6: the artifact dependency walker in compiler/ir.py must descend into forEach bodies and handle callWorkflow references before those features compile.
  • Each loop or call milestone shrinks EXPECTED in tests/unit/compiler/test_language_examples.py and re-checks notify-overdue and order-intake.

Local verification (macOS, head 7005566)

  • make check: all 17 stages, All requested checks passed.
  • scripts/language_fixtures.py --check and scripts/studio_schema_fixtures.py --check: exit 0.
  • Studio: npm run check, npm run format:check, npm test (59 files, 657 tests passed), npm run build.
  • Studio Playwright (npm run test:browser): 914 passed, 6 skipped. A first run under heavy machine load had two failures (connection.spec.ts:151, designer-forms.spec.ts:671) that passed in isolation and in the full rerun; this pull request changes no UI code.

CI scope

The Python suites run on Linux CI only (ci.yml uses ubuntu-latest; the macOS and Windows jobs in desktop.yml build the desktop app, not the Python suites) until S6-M0 lands the cross-platform tier. The Windows line-ending case for fixture freshness is covered by a unit test.

Test plan

  • make check
  • npm run check && npm run format:check && npm test && npm run build && npm run test:browser in studio/
  • CI green on Linux; macOS and Windows for the Python suites after S6-M0

Andres Contreras added 14 commits October 7, 2026 21:48
Say exactly how to apply INSTANCE_KEY_PATTERN: re.fullmatch in Python, the
anchored form only for ECMAScript, JSON Schema and pydantic's Rust engine,
and pin that InstanceKeyText rejects a trailing newline. Pin that the IR
model does not accept weave/ir-v1alpha4 in this milestone, rename two stale
test names, assert invalid callable specs against the exported definition
schema too, and check the diagnostics cap test keeps only unsupported-feature
findings plus one truncation marker.

Docs: spell out the node ID grammar and @legacy, name every kind of generated
inventory entry, list WeaveClient.language, and say Studio will read the
language manifest.
@ancongui
ancongui merged commit 2db5104 into main Oct 8, 2026
12 checks passed
@ancongui
ancongui deleted the feat/language-contracts branch October 8, 2026 17:31
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