Repository navigation
feat: add flow variables - #59
Merged
Merged
Conversation
Final-review fixes for schema v4 flow variables, in both languages:
- A `note` (flow or step) is a comment and is never scanned for
placeholders (conformance v4/valid/placeholder-in-note).
- `fill` returns a plain v3 document: schema_version 4+ becomes 3, and
the result passes validate_outbound and round-trips on its own. A
filled prompt over the prompt limit is refused with `prompt_too_long`
(Rust FillError::PromptTooLong { node }). Fill corpus outputs are now
v3; new cases prompt-too-long, all-options-dropped, value-with-braces.
- `engine::run` fills a flow that still declares variables with its
defaults before running it; a fill error ends the run as a defect.
- A variable default longer than its max_len is refused with
`variable_default_too_long`.
- Schema, README and corpus wording describe the real v4 behaviour;
module docs state that a blank value falls back to the default.
- compat-old-readers: the oldest reader refuses v4 documents with an
error, not a panic.
After dropping options, fill removes every node no longer reachable from entry (both languages), so the filled v3 document validates on its own. Adds fill/dropped-option-only-path and fixes a typo in a v4 case description.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds flow schema v4: a flow can declare variables (each with a default) and use them as
{{name}}in prompts and menu option labels, so one published flow can be reused with different text per call.variables(description,defaultrequired,max_len1..500). Audio prompts can keep atemplatebeside their pre-voiced default audio.{{#name}}…{{/name}}keeps text only when the value is non-empty.max_lenrange. v1–v3 treat{{as plain text.fill(flow, values)(Rust + TS): replaces placeholders (given value, else default), drops an option whose label is an empty variable (with its exit), keeps pre-voiced audio when defaults are kept. Values are inserted literally. Contract: validate the source flow first; the filled result isn't re-validated.MenuChoicegains an optionallabel(omitted when absent; old JSON still reads).StepDetailnow also derivesDeserialize.Breaking for Rust callers on 0.0.x:
Prompt::Audiogainedtemplate,Variableis new,CURRENT_SCHEMA_VERSIONis 4. Behavior change: in a v4 flow,{{in a text field other than a prompt, prompt template or menu label (e.g. a transfer target, or the flow'sid/name) is now an error (placeholder_not_allowed). Notes are never scanned.The prettier pass in one commit also reflowed a few unrelated lines in
validate.ts(no behavior change).Consumers (the platform,
wk, the engine and the skill) follow in separate PRs.Tests:
cargo test -p wavekat-flow,cargo test -p compat-old-readers,pnpm --filter @wavekat/flow-schema test(310), typecheck, clippy, fmt — all green locally.