Skip to content

grammar: open subsystem keys to arbitrary identifiers (closes #64)#68

Merged
proofmancer merged 1 commit into
mainfrom
grammar/open-subsystem-keys
May 25, 2026
Merged

grammar: open subsystem keys to arbitrary identifiers (closes #64)#68
proofmancer merged 1 commit into
mainfrom
grammar/open-subsystem-keys

Conversation

@proofmancer
Copy link
Copy Markdown
Member

Closes #64.

The chain manifest grammar was hardcoded to five subsystem keys (consensus, gas, state, exec, da). A chain wanting to declare a new axis (privacy, MEV protection, cross-chain bridging, anything we did not anticipate) could not. This PR lifts that.

What changed

Parser

`is_subsystem_key` now accepts `TK_IDENT` in addition to the five reserved keyword tokens. Any identifier is a valid subsystem key. The five names stay as keyword tokens because `state` and `gas` also start module-item declarations elsewhere in the grammar.

Grammar spec

`spec/grammar.ebnf`: `SubsystemKey = IDENT` instead of the enumerated list. The five names are documented as the stdlib axes, but no longer parser-level requirements.

Tree-sitter

`cleave-lang/tree-sitter-cleave` updated in the same change so the two grammars stay in lockstep. `subsystem_key` becomes `$.identifier` instead of a fixed-choice rule. Test corpus fixtures updated to expect the new `(subsystem_key (identifier))` shape.

Tests

`test_error_unknown_subsystem_key` deleted. It asserted that `unknown: ...` errors; after this PR that's the intended behavior. Replaced with two positive tests:

  • `test_arbitrary_subsystem_key_parses`: `chain C { privacy: GrothProver<curve=BN254> }` parses, key is "privacy"
  • `test_subsystem_key_can_still_be_stdlib_keyword`: regression guard that `consensus:` and friends still parse the same way

154 parser assertions (was 149).

End-to-end demo

```cleave
// This parses now (previously rejected)
chain MyZkChain {
consensus: Tendermint<sig=BLS12_381>
gas: Multidim<{cpu, storage, witness}>
state: SparseMerkle<key=u256, hash=Blake3>
exec: WasmVM
da: NativeDA
privacy: GrothProver<curve=BN254>
mev: FlashbotsBundler
bridge: CelestiaIBC
}
```

What this PR does NOT do

This PR is just the parser-layer lift. The full third-party extensibility story needs the three follow-ups above.

What unblocks next

@proofmancer proofmancer merged commit bf81ff6 into main May 25, 2026
2 checks passed
@proofmancer proofmancer deleted the grammar/open-subsystem-keys branch May 25, 2026 16:30
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.

Grammar: open subsystem keys to arbitrary identifiers

1 participant