Skip to content

docs(base): stabilize continuous-period sums - #2262

Closed
huarenmin13 wants to merge 1 commit into
larksuite:mainfrom
huarenmin13:auto-research-sync/01KZD9G82QWMHDT8K47GNZNZ50/mr-1404-776defac
Closed

huarenmin13 wants to merge 1 commit into
larksuite:mainfrom
huarenmin13:auto-research-sync/01KZD9G82QWMHDT8K47GNZNZ50/mr-1404-776defac

Conversation

@huarenmin13

@huarenmin13 huarenmin13 commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Narrow this documentation change to reusable correctness gaps in continuous calendar-period sums. The shipped guidance stays operation-scoped: it does not introduce business-specific field priorities or defaults for rate calculations.

The top-level skills/lark-base/SKILL.md remains unchanged. Calendar-sum workflow guidance lives in the conditional Record query/analysis SOP, while +data-query-specific datetime behavior stays in its DSL reference.

Changes

  • Use adjacent half-open calendar intervals [start, next_start) and the actual +record-list lower-bound capability.
  • When +data-query strict datetime filters cannot express an inclusive local-calendar start exactly, recover through a complete date-dimension result below the 5000-row ceiling or route to complete NDJSON.
  • Lock the source, sum field, date field, complete range, granularity, and filters before conclusion-bearing calculations.
  • Verify input coverage and reconcile mutually exclusive period sums with the same-scope full-range sum.
  • For a requested complete-period series, deliver each period, the same-scope full-range total, and trend comparisons derived from unrounded period values.

Scope

  • Sum-only period analysis; no numerator, denominator, rate, conversion, win-rate, zero-denominator, or empty-bucket defaults.
  • No business field names, evaluation values, years, or case-specific answer recipe.
  • Documentation only; no runtime behavior change.

Evaluation attribution

The evaluated quarterly sales runs showed that exact period values depended on correct local-calendar membership and complete aggregation input. The remaining reusable delivery gap was omission of the same-scope full-year total. This PR addresses only those two causes; it does not encode expected values or business semantics.

Validation

  • node scripts/skill-format-check/index.js
  • QUALITY_GATE_CHANGED_FROM=b6d04738e5933b9f9668acfc7b35b12e631923ac make quality-gate
  • git diff --check b6d04738e5933b9f9668acfc7b35b12e631923ac...HEAD

Related Issues

  • None

@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 Aug 10, 2026
@coderabbitai

coderabbitai Bot commented Aug 10, 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

The Lark Base data analysis SOP adds rules for consistent statistical scope, date-field selection, ratio denominators, zero-denominator handling, complete time-bucket output, and trend conclusions.

Changes

Statistical scope updates

Layer / File(s) Summary
Statistical scope controls
skills/lark-base/references/lark-base-data-analysis-sop.md
The SOP fixes the population, time axis, numerator, denominator, exclusions, and full time range for analysis. It defines date-field selection and fallback rules, default denominators, zero-denominator output, complete time buckets, and consistent aggregate and trend results.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Suggested reviewers: liangshuo-1

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 clearly identifies the documentation change for continuous-period sums, which is a real and central aspect of the changes.
Description check ✅ Passed The description provides a clear summary, detailed changes, scope, validation evidence, and related-issue status; it uses Validation instead of Test Plan.
✨ 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.

@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 `@skills/lark-base/references/lark-base-data-query-guide.md`:
- Line 23: Update the rate-denominator guidance in the calendar-period query
instructions to make it independent of numerator status scope: use all records
in each requested bucket as the denominator whenever a denominator is not
explicitly specified, even when the numerator has a status filter. Restrict a
closed-only denominator to requests that explicitly ask for it, and align the
wording with the rule in SKILL.md.

In `@tests/cli_e2e/base/base_skill_contract_test.go`:
- Around line 47-61: Expand the contract assertions in the test around the
existing skill, SOP, and guide checks to cover the structured-error gate,
prohibition of unauthorized `--as bot` fallback, formula echoing, empty-bucket
handling, and half-open datetime boundaries. Add direct assertions for each
changed clause, and use strings.Index with require.Less to verify the
user-credential attempt appears before authorization recovery.
- Line 24: Update the assertion in the base skill contract test to match wording
actually present in SKILL.md, replacing the absent “文件导入转 lark-drive” substring
with an exact existing file-import phrase such as the local-file/Base import or
lark-drive import/export wording.
🪄 Autofix

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: dff154a1-f641-4d14-8c5e-8d58157c495a

📥 Commits

Reviewing files that changed from the base of the PR and between 2016120 and d84fe12.

📒 Files selected for processing (7)
  • shortcuts/base/base_data_query.go
  • shortcuts/base/base_shortcuts_test.go
  • shortcuts/base/record_list.go
  • skills/lark-base/SKILL.md
  • skills/lark-base/references/lark-base-data-analysis-sop.md
  • skills/lark-base/references/lark-base-data-query-guide.md
  • tests/cli_e2e/base/base_skill_contract_test.go

Comment thread skills/lark-base/references/lark-base-data-query-guide.md Outdated

skill := string(content)
require.Contains(t, skill, "文件导入/导出转 lark-drive")
require.Contains(t, skill, "文件导入转 lark-drive")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Fix the file-import wording assertion.

Line 24 expects 文件导入转 lark-drive, but skills/lark-base/SKILL.md contains 把本地文件导入成 Base and 本地文件与 Base 之间的导入/导出转 \lark-drive`` instead. The exact substring is absent, so this test fails deterministically.

Proposed fix
-	require.Contains(t, skill, "文件导入转 lark-drive")
+	require.Contains(t, skill, "把本地文件导入成 Base")
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
require.Contains(t, skill, "文件导入转 lark-drive")
require.Contains(t, skill, "把本地文件导入成 Base")
🤖 Prompt for 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.

In `@tests/cli_e2e/base/base_skill_contract_test.go` at line 24, Update the
assertion in the base skill contract test to match wording actually present in
SKILL.md, replacing the absent “文件导入转 lark-drive” substring with an exact
existing file-import phrase such as the local-file/Base import or lark-drive
import/export wording.

Comment on lines +47 to +61
for _, want := range []string{
"先按本 skill 的路径尝试 `--as user`",
"不要因为看到 `/base/` 链接就预先运行 `auth login`",
"原始 `datetime` / `created_at` 字段",
"未指定比例分母时,默认用请求时间桶内的全部记录",
} {
require.Contains(t, skill, want)
}
require.Contains(t, sop, "完整正确性契约统一见 [lark-base-data-query-guide.md]")
require.Contains(t, guide, "copy the user's requested measure, date field, status scope, and ratio denominator")
require.Contains(t, guide, "datetime `isGreater`/`isLess` are strict")
require.Contains(t, guide, "A zero denominator is “no data”, not 0%")
require.Contains(t, guide, "prefer an original `datetime` or `created_at` field")
require.Contains(t, guide, "use all records in each requested bucket as the denominator")
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Assert the complete identity and analysis contract.

These assertions cover only selected substrings. They do not verify the structured-error gate, the prohibition on unauthorized --as bot fallback, formula echoing, empty-bucket handling, or half-open datetime boundaries. Presence checks also do not verify that the user-credential attempt occurs before authorization recovery.

Add assertions for each changed clause. Use strings.Index with require.Less for the identity ordering.

As per coding guidelines, contract tests must assert the changed behavior directly so reverting the implementation causes a test failure.

🤖 Prompt for 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.

In `@tests/cli_e2e/base/base_skill_contract_test.go` around lines 47 - 61, Expand
the contract assertions in the test around the existing skill, SOP, and guide
checks to cover the structured-error gate, prohibition of unauthorized `--as
bot` fallback, formula echoing, empty-bucket handling, and half-open datetime
boundaries. Add direct assertions for each changed clause, and use strings.Index
with require.Less to verify the user-credential attempt appears before
authorization recovery.

Source: Coding guidelines

@huarenmin13 huarenmin13 changed the title feat(base): clarify data analysis and identity contracts docs(base): harden query routing and analysis correctness Aug 10, 2026

@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 `@skills/lark-base/references/lark-base-data-analysis-sop.md`:
- Around line 21-23: Update
skills/lark-base/references/lark-base-data-analysis-sop.md lines 21-23 so
candidate date-field selection and non-empty coverage validation apply only when
the request includes date filters, time dimensions, or calendar-range semantics;
non-temporal analyses must not force a time field or add filters. Update
skills/lark-base/SKILL.md line 109 so time-field traceability is required only
for temporal criteria, while non-temporal analyses explicitly report that no
time field was used.

In `@skills/lark-base/SKILL.md`:
- Line 43: Update the Base/Wiki URL resolution rule to include a
workflow-specific lookup when block_type is workflow and block_name does not
match the user’s target: use +workflow-list or reference the existing workflow
lookup rule. Keep the current type-specific branches for data tables and
dashboards unchanged.
🪄 Autofix

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: 4180760e-0d5f-41d7-a2f8-06b359077d8d

📥 Commits

Reviewing files that changed from the base of the PR and between d84fe12 and a1a1431.

📒 Files selected for processing (4)
  • skills/lark-base/SKILL.md
  • skills/lark-base/references/lark-base-data-analysis-sop.md
  • skills/lark-base/references/lark-base-data-query-guide.md
  • skills/lark-base/references/lark-base-data-query.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • skills/lark-base/references/lark-base-data-query-guide.md

Comment thread skills/lark-base/references/lark-base-data-analysis-sop.md Outdated
Comment thread skills/lark-base/SKILL.md Outdated
@github-actions

github-actions Bot commented Aug 10, 2026 •

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

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

🧩 Skill update

npx skills add huarenmin13/cli#auto-research-sync/01KZD9G82QWMHDT8K47GNZNZ50/mr-1404-776defac -y -g

@huarenmin13
huarenmin13 force-pushed the auto-research-sync/01KZD9G82QWMHDT8K47GNZNZ50/mr-1404-776defac branch from dd0d647 to b31df93 Compare August 10, 2026 16:20
@huarenmin13 huarenmin13 changed the title docs(base): harden query routing and analysis correctness docs(base): define aggregation metric semantics Aug 10, 2026
@huarenmin13
huarenmin13 force-pushed the auto-research-sync/01KZD9G82QWMHDT8K47GNZNZ50/mr-1404-776defac branch from b31df93 to 1835de5 Compare August 10, 2026 16:21
@huarenmin13 huarenmin13 changed the title docs(base): define aggregation metric semantics docs(base): lock time-series analysis semantics Aug 11, 2026

@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 `@skills/lark-base/references/lark-base-data-analysis-sop.md`:
- Around line 27-29: 补充该数据分析 SOP
的完整无数据契约:在最终输出前为用户要求的每个时间桶执行缺失桶补全,即使查询未返回记录也要输出该桶;桶级或总体分母为 0 时统一输出“无数据”,不得将其当作 0
参与趋势分析。明确仅对有效分母桶计算趋势,并规定部分桶有效时总体分子、分母、比率及趋势结论的处理方式;如已有相关流程参考,链接该引用。
🪄 Autofix

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: f6f82db6-1905-4c6c-87b3-ee9efb1bc7fd

📥 Commits

Reviewing files that changed from the base of the PR and between 1835de5 and 3072634.

📒 Files selected for processing (1)
  • skills/lark-base/references/lark-base-data-analysis-sop.md

Comment thread skills/lark-base/references/lark-base-data-analysis-sop.md Outdated
Comment thread skills/lark-base/SKILL.md Outdated
@huarenmin13
huarenmin13 marked this pull request as draft August 11, 2026 12:13
@huarenmin13 huarenmin13 changed the title docs(base): lock time-series analysis semantics docs(base): generalize analysis contracts Aug 14, 2026
@huarenmin13
huarenmin13 marked this pull request as ready for review August 14, 2026 03:54
@huarenmin13
huarenmin13 requested a review from kongenpei as a code owner August 14, 2026 03:54

@yballul-bytedance yballul-bytedance left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed the final net diff. This is a docs-only update to the Base data analysis SOP, and the generalized metric/ratio/time-bucket contracts look scoped and consistent with the reference structure. Approval is based on the current documentation diff; CI still needs to finish separately.

@yballul-bytedance yballul-bytedance left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approve.

@huarenmin13
huarenmin13 force-pushed the auto-research-sync/01KZD9G82QWMHDT8K47GNZNZ50/mr-1404-776defac branch from 0fc5d0a to 5f28fe7 Compare August 18, 2026 03:35
@huarenmin13
huarenmin13 marked this pull request as draft August 18, 2026 03:50
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@huarenmin13 huarenmin13 changed the title docs(base): generalize analysis contracts docs(base): stabilize continuous-period sums Aug 20, 2026
@huarenmin13
huarenmin13 marked this pull request as ready for review August 20, 2026 15:43
Narrow the change to reusable correctness gaps in continuous
calendar-period sums; runtime behavior is unchanged and the
always-loaded SKILL.md is untouched.

- Use adjacent half-open calendar intervals [start, next_start) and the
  actual +record-list lower-bound capability.
- Restrict +record-list datetime range conditions to strict > / <, and
  keep a safe strict upper-bound example while removing the unsafe
  prior-day-millisecond lower-bound workaround.
- Route exact local-calendar boundaries through the +data-query date
  dimension recovery path or a complete NDJSON export, and report an
  evidence gap when neither can express or fully return the range.
- Add the continuous-period sum pattern: lock source, sum field, date
  field, complete range, granularity and filters before conclusions,
  reconcile mutually exclusive bucket sums against the same-scope
  full-range total, and derive trends from unrounded bucket values.

Documentation only; no unit test is required.

Co-authored-by: TRAE CLI <noreply@bytedance.com>
Co-authored-by: TRAE CLI <traecli@bytedance.com>
@huarenmin13
huarenmin13 force-pushed the auto-research-sync/01KZD9G82QWMHDT8K47GNZNZ50/mr-1404-776defac branch from 1bfd7d1 to c7d9ecc Compare August 21, 2026 09:02
> - **范围型关键字**(`CurrentWeek`、`LastWeek`、`CurrentMonth`、`LastMonth`、`TheLastWeek`、`TheNextWeek`、`TheLastMonth`、`TheNextMonth`)仅支持 `is` 运算符。
> - **关键字大小写敏感**:`ExactDate`、`Today`、`CurrentWeek` 等首字母大写,写错大小写会导致校验失败。
>
> **本地日历范围边界**:`+data-query` 的 datetime 范围只有严格的 `isGreater` / `isLess`,不得把下界向前移动一天来模拟“包含起始日”,否则会把前一天的记录带入总体。对于可按日期重组的指标,可以移除有歧义的范围 filter,改为按日期字段作为 dimension、返回组成该指标且可合并的 measures,并显式设置 `pagination.limit=5000`;只有结果少于 5000 行时,才在本地按返回的日期值筛选并汇总到 `[start, next_start)`。结果达到上限或指标不能从日期维度结果准确重组时,返回统一 SOP 改走可完整导出的 NDJSON 路径,否则报告证据缺口。

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

这里有问题,目前不支持 isGreaterEqual,所以为了实现包含起始日必须下界前移 1ms,这里不允许前移一天有问题

["业务日期", "==", "ExactDate(2026-08-07)"], // 具体一天:按 Base 时区匹配 2026-08-07 当天
["发生时间", ">", "ExactDate(2024-01-31 23:59:59.999)"], // 日期不支持 >=;用 > 前一天最后一毫秒表达含当天的下界
["发生时间", "<", "ExactDate(2024-03-01 00:00:00)"] // 2024 年 2 月范围上界:小于 3 月 1 日零点
["发生时间", "<", "ExactDate(2024-03-01)"] // 范围上界:严格小于 3 月 1 日零点,得到 2 月区间的开区间上界;含首日的下界不要用 > 前一天最后一毫秒,改用下文半开区间 [start, next_start) 口径

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

这个设计不能删除,目前不支持 >= 所以必须用 -1ms 来模拟

}
```

`+record-list` 的 `datetime` 范围条件只使用严格的 `>` / `<`,不要套用通用 tuple 中的 `>=` / `<=`。`ExactDate(...)` 按 Base 时区的日期边界解释,也不能通过把下界前移一天来模拟“包含首日”。需要精确的本地日历半开区间 `[start, next_start)` 时,指标可按日期重组则使用下文 `+data-query` 的日期维度恢复路径;否则按本 SOP 完整导出 NDJSON,再用序列化值中的本地日期筛选。

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

不要加这个


例如,`2026-03-20T23:30:00.000-05:00` 与 `2026-03-21T12:30:00.000+08:00` 表示同一时刻;前者若是来源 Base 的值,本地日报归入 3 月 20 日,而时长或排序计算应把它解析为绝对时刻。只构造任务实际需要的日期表示,并在分析引擎中使用具备 datetime 功能的列。

连续日历区间分桶时,从用户请求的范围和粒度生成相邻、不重叠的半开区间 `[start, next_start)`;上界使用下一周期首日,不能把本周期最后一天复用为下一周期起点。

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

冗余了,一个指令没有必要重复那么多次。另外,前一天最后 1ms 的设计被破坏了,不能改动这个


## 常见分析模式

### 连续分期求和

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

这个不是“常见分析模式”,不要放在这个文档内部


- 对按连续日历周期统计的 `sum`,在第一次用于支撑结论的计算前锁定数据源、求和字段、日期字段、完整范围、粒度和过滤条件;主计算、校验和最终答案复用这些口径。
- 在把结果视为完整前,确认 `records_count` / `has_more` 或 Cloud 聚合覆盖目标范围,抽查范围边界记录,并将互斥、完整的分桶值之和与同口径全区间结果对账;不一致时先修正范围或计算。
- 当用户要求覆盖完整周期的连续分期结果时,最终交付逐桶结果和同口径全区间合计;逐桶值、合计和趋势直接复用同一份已校验的结构化计算结果,提交前逐项核对。用户要求走势时,基于未舍入的分桶值给出相邻周期变化和首尾比较。

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

感觉在过拟合测评题目,移除一下

@huarenmin13
huarenmin13 marked this pull request as draft August 24, 2026 06:39
@github-actions

Copy link
Copy Markdown

PR Quality Summary

CI did not complete successfully. Use the failed check links below to decide whether this PR needs a code change or a rerun.

CI status

  • Workflow conclusion: failure.

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.

4 participants