Skip to content

feat(execution-factory): let a Cypher function input be optional - #1316

Merged
sh00tg0a1 merged 1 commit into
mainfrom
feat/cypher-optional-inputs
Nov 11, 2026
Merged

sh00tg0a1 merged 1 commit into
mainfrom
feat/cypher-optional-inputs

Conversation

@sh00tg0a1

Copy link
Copy Markdown
Member

Pull Request

What Changed

Brief description of changes:

  • Function workbench: an input the statement tests with $name IS NULL (or IS NOT NULL) starts optional, and keeps whatever the author sets for "required". Every other input stays required, as before.
  • Trial run: an optional input that is not given, or is null, is left out instead of reported missing.
  • AI prompt (en/zh): when the description says a condition may be left out, write ($name IS NULL OR condition).
  • Cypher reference (en/zh): a rule for optional conditions.

Why


How

  • Key implementation points:
    • syncCypherInputs: finds the parameters followed by IS NULL / IS NOT NULL, with string literals and comments blanked first.
      • A new parameter that is tested this way starts with required: false.
      • A parameter that is already declared and tested keeps its required value.
      • Any other parameter is set to required: true, as before.
    • cypherArguments: skips an input with required: false that is not given or is null. An input with no required field still counts as required.
  • Breaking changes (API, config, database, etc.): none.

Testing

  • Unit tests passed locally:
    • vitest for src/modules/execution-factory, src/modules/knowledge-network/cypher and the locale parity test (572 tests), plus cypher-reference.test.ts and CypherQueryScene.test.tsx.
    • tsc -b; eslint and prettier on the touched files; the hardcoded-Chinese scan; the license check.
  • Integration tests passed locally. N/A: no integration suite covers the workbench.
  • Verified in test environment. Not yet in the browser. The backend half (bkn-backend and execution-factory) was verified on the dev VM in feat(bkn-backend): make a Cypher condition optional with $name IS NULL bkn-foundry#3097, with a function saved with two optional inputs.

Test notes:

  • New: a new input tested with IS NULL starts optional, and a declared one keeps required. '$code IS NULL' inside a string literal does not count. An input without the test is set back to required.
  • New: the trial run leaves out an optional input that is missing or null, and still reports a missing required one.

Risk & Rollback


Additional Notes

🤖 Generated with Claude Code

@sh00tg0a1 sh00tg0a1 added the by-agent Issue or pull request produced by an agent label Nov 11, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IS NULL 检测按 blankCypherLiterals 后的文本和 scan 的 span 偏移判断,字符串、注释里的 $name IS NULL 不会误判;cypherArguments 跳过未传的可选输入,zh/en 文案也都改了,没发现阻塞项。剩下一个疑点要作者确认:参数完全不传时后端怎么处理。

影响范围与未覆盖面
  • 影响范围:影响执行工厂 Cypher 函数工作台的输入同步和试跑参数校验;已保存的函数里 required 为 undefined 的输入仍按必填处理。
  • 未覆盖:后端(bkn-backend 与执行工厂)怎么处理缺失参数,前端仓库里核实不了。

待确认项(不阻断放行)

  • src/modules/execution-factory/utils/cypher-function.ts — 可选输入没传时,cypherArguments 会把它从 parameters 里整个去掉,而不是传 null。原注释写的是「a statement using $name fails without one」,所以要确认两件事:bkn-backend 的 run_cypher 是否把缺失的参数当 null;执行工厂实际调用函数时是不传还是传 null。只要有一方会报 missing parameter,就应该改成显式传 `nam…

有异议或想再评一轮,请回复 /review——普通回帖不会触发复评,且回帖人需为本仓 OWNER/MEMBER/COLLABORATOR。

bkn-backend now makes a condition optional with ($name IS NULL OR ...). The
function workbench starts an input the statement tests with IS NULL as
optional and keeps the author's choice for it, while every other input stays
required. The trial run leaves an optional input out when it is not given.
The AI prompt and the Cypher reference describe the form.

Refs openbkn-ai/bkn-foundry#2670

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sh00tg0a1
sh00tg0a1 force-pushed the feat/cypher-optional-inputs branch from b3d26d9 to a0388e9 Compare November 11, 2026 15:07
@sh00tg0a1
sh00tg0a1 merged commit 44206bb into main Nov 11, 2026
28 checks passed
@sh00tg0a1
sh00tg0a1 deleted the feat/cypher-optional-inputs branch November 11, 2026 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

by-agent Issue or pull request produced by an agent

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant