Skip to content

fix(base): align workflow validation and agent guidance - #2078

Open
huarenmin13 wants to merge 16 commits into
larksuite:mainfrom
huarenmin13:codex/base-workflow-contracts
Open

fix(base): align workflow validation and agent guidance#2078
huarenmin13 wants to merge 16 commits into
larksuite:mainfrom
huarenmin13:codex/base-workflow-contracts

Conversation

@huarenmin13

@huarenmin13 huarenmin13 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Fix Base workflow cases 014 and 026 without adding a general workflow schema validator.

  • 014: Document DeleteRecordTrigger as known unsupported. When a requested capability is unavailable, agents must preserve the original intent, stop writes, and execute alternatives only after explicit user selection.
  • 026: Validate LarkMessageAction.data before workflow create/update: data must be an object, receiver and content must be non-empty arrays, and optional send_to_everyone/btn_list fields are type-checked when present.

Changes

  • Share one create/update validator for the LarkMessageAction contract and return typed --json field errors before transport.
  • Preserve valid request bodies and leave non-target or unknown step shapes to server validation.
  • Align workflow get/update guidance and the delivered Skill schema.
  • Keep the effective diff within existing files.

Validation

  • make build
  • go test ./shortcuts/base -count=1
  • Current-binary delivered-Skill E2E tests
  • go vet ./shortcuts/base ./tests/cli_e2e/base
  • gofmt and git diff --check

The opt-in live workflow round-trip was not run.

Related

Base workflow evaluation cases 014 and 026.

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Workflow create and update now perform structured workflow-definition validation, including message-action fields and unsupported steps. Guidance and schema references describe the updated contracts, while unit and CLI tests cover validation errors, dry-run output, and request-body preservation.

Changes

Workflow contracts and validation

Layer / File(s) Summary
Workflow validation and command wiring
shortcuts/base/workflow_message_validation.go, shortcuts/base/workflow_create.go, shortcuts/base/workflow_update.go
Create and update validate workflow titles, steps, supported types, and LarkMessageAction fields with structured validation errors.
Execution and request preservation coverage
shortcuts/base/workflow_execute_test.go
Tests cover validation subtypes and hints, preserved create/update JSON bodies, message-action payloads, and empty steps.
Workflow guidance and delivered schema contracts
shortcuts/base/workflow_get.go, shortcuts/base/workflow_update.go, skills/lark-base/references/*, shortcuts/base/base_shortcuts_test.go, tests/cli_e2e/base/*
Tips and references document full replacement, status handling, omitted optional fields, and unsupported triggers; CLI tests verify delivered guidance and dry-run behavior.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant BaseWorkflowCreate
  participant validateWorkflowDefinition
  participant WorkflowAPI
  CLI->>BaseWorkflowCreate: submit --json workflow body
  BaseWorkflowCreate->>validateWorkflowDefinition: validate workflow definition
  validateWorkflowDefinition-->>BaseWorkflowCreate: validation result
  BaseWorkflowCreate->>WorkflowAPI: send validated JSON request
Loading

Possibly related PRs

  • larksuite/cli#2092: Adds closely related workflow message-action validation and command wiring.

Suggested labels: domain/base, size/M

Suggested reviewers: liangshuo-1

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title is concise and accurately summarizes the main change: workflow validation and guidance alignment.
Description check ✅ Passed The description covers the required summary, changes, validation, and related issues, with only the Test Plan heading folded into Validation.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added domain/base PR touches the base domain size/M Single-domain feat or fix with limited business impact labels Jul 28, 2026
@huarenmin13

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@huarenmin13
huarenmin13 marked this pull request as ready for review July 28, 2026 08:37
@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai 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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@shortcuts/base/workflow_execute_test.go`:
- Around line 169-212: The TestBaseWorkflowExecuteUpdatePreservesValidRequests
cases need stronger request-body assertions. In the “valid message action”
subtest, inspect the captured JSON from decodeCapturedJSONBody and verify the
preserved receiver and content values, not just the steps length; in the “empty
steps” subtest, assert that the captured body contains steps as an empty array
while retaining the existing dispatch verification.

In `@tests/cli_e2e/base/workflow_skill_contract_test.go`:
- Around line 32-45: The workflow skill contract test’s contracts table only
covers DeleteRecordTrigger text and must also validate the changed
LarkMessageAction schema. Extend the contracts in the test to assert non-empty
receiver and content fields, while covering optional send_to_everyone and
btn_list fields, using the existing contract assertion flow.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: e21b0491-5417-4af6-ac57-8c3831d258f8

📥 Commits

Reviewing files that changed from the base of the PR and between 1b173e1 and efedfe1.

📒 Files selected for processing (11)
  • shortcuts/base/base_shortcuts_test.go
  • shortcuts/base/workflow_create.go
  • shortcuts/base/workflow_execute_test.go
  • shortcuts/base/workflow_get.go
  • shortcuts/base/workflow_message_validation.go
  • shortcuts/base/workflow_update.go
  • skills/lark-base/SKILL.md
  • skills/lark-base/references/lark-base-workflow-schema.md
  • tests/cli_e2e/base/url_resolution_skill_contract_test.go
  • tests/cli_e2e/base/workflow_skill_contract_test.go
  • tests/cli_e2e/base/workflow_update_dryrun_test.go

Comment thread shortcuts/base/workflow_execute_test.go Outdated
Comment thread tests/cli_e2e/base/workflow_skill_contract_test.go Outdated
1. Document form-share support in resolver help and recovery hints
2. Assert exact workflow request bodies and LarkMessageAction schema contracts

```ai-signature
改动范围: Base URL resolver 的命令描述、参数提示、错误恢复提示,以及 workflow 请求体和 schema 契约测试
思考过程: 按当前两个 review thread 做最小修复,复用请求捕获辅助函数并比较完整 JSON,避免只验证数组长度而漏掉字段丢失
改动原因: PR larksuite#2078 的帮助文本漏列 form-share,现有测试未完整固定合法请求、空 steps 和文档字段契约
Break Change: 否
```

Co-authored-by: BASE Infra Harness <ai@base-infra-harness.noreply.local>
AI-SHA256: 4538bb15e1079d6ca9c48275b205a10ca68a03dad1000c0beff1b5981e29787f

@coderabbitai coderabbitai 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.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@shortcuts/base/base_resolve_test.go`:
- Line 234: Update the unrelated Base URL case in the relevant resolve test to
assert the complete typed error contract: verify Category, Subtype, and the
preserved cause using errs.ProblemOf with errors.Is or errors.As, and extract
Param directly from the *errs.ValidationError instead of errs.ProblemOf. Retain
the existing message and Hint assertions.
- Around line 283-285: Add a success-path test for the form-share resolver
alongside the existing BaseURLResolve assertions, exercising a
/share/base/form/<token> request and verifying the returned input_type,
resource_type, and share_token. Keep the description assertion, but ensure the
execution test confirms routing selects the form-share behavior rather than the
generic Base branch.

In `@shortcuts/base/base_resolve.go`:
- Line 18: Update classifyBaseURL so the specific /share/base/form/ pattern is
checked before the generic /base/ pattern, ensuring form-share URLs reach
resolveFormShareURL instead of the generic base resolution. Add a regression
test covering successful classification and resolution of a form-share URL.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 654d0113-d33f-4048-bd8b-d6bbba9569be

📥 Commits

Reviewing files that changed from the base of the PR and between efedfe1 and ffc792b.

📒 Files selected for processing (4)
  • shortcuts/base/base_resolve.go
  • shortcuts/base/base_resolve_test.go
  • shortcuts/base/workflow_execute_test.go
  • tests/cli_e2e/base/workflow_skill_contract_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • shortcuts/base/workflow_execute_test.go

Comment thread shortcuts/base/base_resolve_test.go Outdated
Comment thread shortcuts/base/base_resolve_test.go Outdated
Comment thread shortcuts/base/base_resolve.go Outdated
1. assert exact workflow create request preservation
2. strengthen resolver routing and typed error contracts

```ai-signature
改动范围: shortcuts/base/base_resolve.go、base_resolve_test.go、workflow_execute_test.go
思考过程: 用完整请求体深比较锁住 create 转发;用 resource_type 证明 form-share 真实分支;仅在 URL 解析失败时保留底层 cause
改动原因: 关闭两个 P2 和三条 CodeRabbit 反馈,同时按用户决定将 live E2E 保持为非阻塞项
Break Change: 否
```

Co-authored-by: BASE Infra Harness <ai@base-infra-harness.noreply.local>
AI-SHA256: 3a6f6ad6ac1520fe5967c052c8de1f0a31f67facb80767dd52383721975d271b

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@shortcuts/base/base_resolve_test.go`:
- Around line 260-265: Strengthen error assertions in
shortcuts/base/base_resolve_test.go at lines 260-265, 415-418, and 429-432: in
the malformed-URL case, verify the unwrapped cause is specifically *url.Error
rather than only non-nil; in both semantic validation cases, assert
CategoryValidation, SubtypeInvalidArgument, and a nil cause using the existing
typed-error assertion patterns.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 01b9a56d-56d5-4371-8208-234c09a60325

📥 Commits

Reviewing files that changed from the base of the PR and between ffc792b and cf82941.

📒 Files selected for processing (3)
  • shortcuts/base/base_resolve.go
  • shortcuts/base/base_resolve_test.go
  • shortcuts/base/workflow_execute_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • shortcuts/base/workflow_execute_test.go

Comment thread shortcuts/base/base_resolve_test.go Outdated
huarenmin13 and others added 4 commits July 28, 2026 18:07
1. require malformed URL failures to preserve a url.Error cause
2. verify title validation metadata and nil semantic causes

```ai-signature
改动范围: shortcuts/base/base_resolve_test.go
思考过程: 按错误来源区分解析失败与语义校验;前者断言具体 url.Error,后者明确断言无底层 cause
改动原因: 关闭 CodeRabbit 增量复审新增的 typed-error 合同测试缺口
Break Change: 否
```

Co-authored-by: BASE Infra Harness <ai@base-infra-harness.noreply.local>
AI-SHA256: 16558d9f4339a7d2660d3e398d33ea19ce9eac04538f4fa2f0a5d44a97b11381
1. Propagate the selected alias flag through structured resolver validation errors.
2. Align embedded workflow guidance with title and steps while managing status separately.
3. Cover alias errors and delivered guidance with unit and real-binary regression tests.

```ai-signature
改动范围: shortcuts/base resolver 实现及单元测试,并更新 lark-base workflow 指南与真实二进制 E2E 合同测试。
思考过程: 保留既有请求和解析行为,仅让输入读取结果携带实际 flag 名;指南测试经 LARK_CLI_BIN 执行 skills read,直接覆盖二进制交付面。
改动原因: 隐藏 alias 的结构化错误会误报 canonical 参数,且内嵌指南错误地把 status 放入 create/update 写入契约。
Break Change: 否
```

Co-authored-by: BASE Infra Harness <ai@base-infra-harness.noreply.local>
AI-SHA256: b0cf1649b3fb329b4910eff6cbc7d8135cc6e0e34b7bbb17bcca4761c5be9fdc
Keep this PR scoped to DeleteRecordTrigger guidance and LarkMessageAction validation.
@github-actions

github-actions Bot commented Jul 29, 2026

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

npm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@b6e49aeff132b9e729323ba0cd1b9c616cb716f7

🧩 Skill update

npx skills add huarenmin13/cli#codex/base-workflow-contracts -y -g

@huarenmin13
huarenmin13 force-pushed the codex/base-workflow-contracts branch from c53cc4c to 3b49167 Compare July 29, 2026 06:55
@huarenmin13 huarenmin13 changed the title fix(base): align workflow validation and agent guidance fix(base): validate workflow message action shapes Jul 29, 2026
@huarenmin13
huarenmin13 force-pushed the codex/base-workflow-contracts branch from 3b49167 to c53cc4c Compare July 29, 2026 07:08
@huarenmin13 huarenmin13 changed the title fix(base): validate workflow message action shapes fix(base): align workflow validation and agent guidance Jul 29, 2026
huarenmin13 and others added 2 commits July 29, 2026 17:27
1. Move the workflow validation matrix to the shared validator and keep representative create and up
    date wiring cases.
2. Reuse existing dry-run and embedded-reference helpers while preserving the 014 and 026 regression
    contracts.

```ai-signature
改动范围: shortcuts/base/workflow_execute_test.go 以及两个 Base workflow CLI E2E 测试文件
思考过程: 将字段组合放在共享 validator 层验证,仅保留 create 和 update 的接线回归,并复用仓库现有 dry-run helper,避免重复命令执行样板
改动原因: PR2078 的有效 diff 中测试占比过高,重复断言和环境初始化降低可审阅性,需要在不改变生产行为与两题契约覆盖的前提下压缩
Break Change: 否
```

Co-authored-by: BASE Infra Harness <ai@base-infra-harness.noreply.local>
AI-SHA256: 3865fb792cd29489fbafb179fd107cd3949b3235a62b26267266706dc6de7cf9
huarenmin13 and others added 2 commits July 29, 2026 18:19
1. Reject non-object workflow step entries and non-string step types with indexed validation errors.
2. Cover malformed step shapes while preserving unknown string step types for server-side validation
    .

```ai-signature
改动范围: shortcuts/base/workflow_message_validation.go 和 shortcuts/base/workflow_execute_test.go
思考过程: 在现有共享 workflow validator 的解析边界返回索引化错误,只收紧畸形 step 结构,不建立封闭类型白名单,也不改变未知字符串 step 的透传
改动原因: 当前 workflowSteps 会把非对象元素和非字符串 type 清零后静默跳过,导致明显畸形输入仍发往服务端,增加代理重试与错误恢复成本
Break Change: 否
```

Co-authored-by: BASE Infra Harness <ai@base-infra-harness.noreply.local>
AI-SHA256: 0374d62cc198d61578a71c746b97a20165e3730060d7bcd68179b0fa7c238275
1. Require every workflow step type to be a non-empty string before sending a request.
2. Cover missing, empty, and whitespace-only types while preserving unknown non-empty string types.

```ai-signature
改动范围: shortcuts/base/workflow_message_validation.go 和 shortcuts/base/workflow_execute_test.go
思考过程: 复用共享 workflowSteps 解析边界收紧 type 的结构契约,仅要求非空字符串,不增加类型白名单,也不改变 FutureTrigger 等未来字符串类型的透传行为
改动原因: 当前解析器允许缺失、空串或纯空白 type 以零值继续进入请求,与 workflow schema 中 type 必填且为 string 的契约不一致
Break Change: 否
```

Co-authored-by: BASE Infra Harness <ai@base-infra-harness.noreply.local>
AI-SHA256: 9255a69f2935afab109cbfc183a946504a1dc172f52eefc84404a1886affb97c
@huarenmin13

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

1. Reject case-variant aliases for validated workflow and message-action fields.
2. Preserve unknown future fields and step types.
3. Add unit and branch-binary dry-run regressions.
4. Sync the Base workflow E2E coverage inventory.

```ai-signature
改动范围: workflow_message_validation.go、workflow_execute_test.go、workflow_update_dryrun_test.go 和 Base E2E coverage.md
思考过程: 将已知契约字段解析改为 map 精确取键,并只拒绝大小写等价别名;未知字段和未来 step type 继续透传,避免把修复扩成严格白名单
改动原因: encoding/json 对 struct 字段进行大小写不敏感匹配,导致错误大小写字段通过校验后按原键外发,可能绕过 workflow full-replacement 防护
Break Change: 否
```

Co-authored-by: BASE Infra Harness <ai@base-infra-harness.noreply.local>
AI-SHA256: c466c5e718ec6aa51cf55955fcadc90b151acc20072e5bf2f985bc87c2392a00
huarenmin13 and others added 4 commits July 30, 2026 00:51
1. Keep preflight checks limited to DeleteRecordTrigger and LarkMessageAction contracts
2. Move shared validation and E2E coverage into existing workflow files
3. Restore unrelated update and coverage behavior to the pre-PR baseline

```ai-signature
改动范围: shortcuts/base 的 workflow create/update 校验、既有测试文件与 lark-base workflow 指南
思考过程: 保留 014 和 026 的发送前防线,删除顶层 schema 校验和重复解析,并把原新增文件内容合并到现有文件以缩小有效 diff
改动原因: PR 仅需修复不支持的删除触发器与消息动作缺字段问题,现有实现扩大了契约和文件数量
Break Change: 否
```

Co-authored-by: BASE Infra Harness <ai@base-infra-harness.noreply.local>
AI-SHA256: 55da68b4a04ec4c0250365527417936252760795db3044e7a68e2664d33c606b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain/base PR touches the base domain size/M Single-domain feat or fix with limited business impact

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant