Skip to content

docs(base): lock time-series analysis semantics - #2262

Draft
huarenmin13 wants to merge 6 commits into
larksuite:mainfrom
huarenmin13:auto-research-sync/01KZD9G82QWMHDT8K47GNZNZ50/mr-1404-776defac
Draft

docs(base): lock time-series analysis semantics#2262
huarenmin13 wants to merge 6 commits 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

This PR now addresses only base_data_analysis_019.

  • Put the conditional, always-needed time-series delivery invariants in skills/lark-base/SKILL.md.
  • Keep the detailed metric-lock procedure in skills/lark-base/references/lark-base-data-analysis-sop.md.
  • Use one time field and one in-bucket population for paired counts, rates, and trends unless the user explicitly defines another formula.
  • Require zero-denominator handling, complete natural-period buckets, an overall cross-check, and one primary ratio in the final answer.
  • Remove the unrelated invalid/reversal filtering that targeted base_data_analysis_013.

Problem / Root Cause / Optimization

Evaluation case Problem observed Root cause General optimization
base_data_analysis_019 Runs could omit an empty first bucket and the overall summary, use a closed-only denominator, or add a second ratio that made the answer ambiguous. The detailed reference was not guaranteed to be read, and the always-loaded skill did not close the final-delivery boundary for count/rate time series. Add a conditional invariant at the domain skill boundary: reuse one time axis and one population, emit total/count/rate for every bucket, represent 0/0 as no data, add the overall numerator/denominator/rate, and do not introduce an unrequested second ratio. Keep procedural details in the existing analysis SOP.

Scope and Generality

  • Two existing Markdown files only; 10 insertions and 7 deletions relative to the previous PR head 1835de51.
  • No case IDs, Base tokens, years, business-specific field names, fixed counts, percentages, or expected answers are encoded in the guidance.
  • The rule is conditional on requests that combine a time-bucketed result count, rate, and trend; it does not change unrelated analysis tasks.
  • Documentation-only change; no unit test was added.

Verification

  • node scripts/skill-format-check/index.js
  • git diff --check 1835de51..HEAD
  • AI signature verification for commits 30726341 and eeda3835

Targeted Evaluation: base_data_analysis_019 only

  • Environment: devbox 10.37.205.146, Coco 0.120.46, model GPT-5.4, 3 repetitions.
  • Commit under test: eeda3835.
  • Task ID: 6aff1410-023e-4979-84bd-22389b433efa.
  • Report: https://bytedance.larkoffice.com/base/DLmBbFDeQamtV6sGCLxcqjrun9Y
  • Execution status: 3/3 completed; no residual evaluation process; the previous global skill was restored.
  • Agent behavior on the current Base: 3/3 used 创建时间, all records in each quarter as the denominator, included Q1 as 0 / 0 / 无数据, emitted one primary rate series plus an overall cross-check, and concluded that the win rate was worsening.

Grader result and fixture mismatch

The frozen grader score is still 0/3, but all three grader traces independently re-read the current Base and found only 30 records: Q1 0/0, Q2 5/1, Q3 21/4, Q4 4/0, annual 30/5 (16.67%). The frozen expectation requires Q4 5/0, annual 31/5 (16.13%). The source Base and copied fixture both currently contain 30 records.

The PR intentionally does not hard-code the missing record or the frozen values. That would make the guidance factually wrong for the live Base and would be single-case overfitting. The behavioral issue is stable 3/3 after this change; an official 019 pass additionally requires the fixture and expectation to be aligned.

@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 and concisely describes the documentation change that defines time-series analysis semantics.
Description check ✅ Passed The description provides detailed motivation, changes, scope, verification, and evaluation results, although it does not follow every template heading exactly.
✨ 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 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: cancelled.

@github-actions

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

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

🧩 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
1. Document time-axis and ratio-denominator defaults for underspecified period analysis
2. Require invalid or reversing fact rows to be filtered before aggregation
@huarenmin13
huarenmin13 force-pushed the auto-research-sync/01KZD9G82QWMHDT8K47GNZNZ50/mr-1404-776defac branch from b31df93 to 1835de5 Compare August 10, 2026 16:21
1. Move the metric contract before query routing so all analysis paths apply it
2. Bind paired counts and rates to one time axis and population, including zero denominators
3. Require complete buckets, overall checks, and one primary ratio while removing unrelated fact fil
    tering

说明:
- Documentation-only change; no unit test is needed

```ai-signature
改动范围: skills/lark-base/references/lark-base-data-analysis-sop.md 中的通用时间序列统计口径与交付检查
思考过程: 将跨查询不变量放在 Hard Rules 后、路由前,复用既有 SOP 并删除 013 的独立事实过滤,保持单文件最小改动
改动原因: 019 的最新轨迹已采用正确主时间轴和总体分母,但仍遗漏空时间桶与总体汇总并追加第二套比率,需要通用交付闭环
Break Change: 否
```

Co-authored-by: BASE Infra Harness <ai@base-infra-harness.noreply.local>
AI-SHA256: d57c89a3c4f1bec27a97d875d6239b691c88e940b854ff22162b9f27832f480c
@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
huarenmin13 and others added 4 commits August 11, 2026 11:49
1. Put the paired count-and-rate population invariant in the always-loaded Base query rules
2. Define a general default range for single-year calendar series and render empty buckets
3. Require one primary series, an overall consistency check, and a trend derived from that series

说明:
- First 019-only run showed the reference was skipped once and its abstract checklist was ignored tw
    ice

```ai-signature
改动范围: lark-base 主 Skill 的条件化统计交付规则,以及 data analysis SOP 的时间范围和空桶细化
思考过程: 保留详细 HOW 在 reference,只把两条每次都要看到的统计不变量放入主入口;用单自然年与已声明范围作为通用边界,避免固定题目字段或答案
改动原因: 第一轮三次 019 评测中一条未读取 SOP,另两条虽读取仍遗漏空桶和总体汇总,其中一条还让第二套分母覆盖主结论
Break Change: 否
```

Co-authored-by: BASE Infra Harness <ai@base-infra-harness.noreply.local>
AI-SHA256: 8cd14e5c8332e38f550f02278bbfc84cc01e5da51ff5933476286c5d6372b6e6
1. Keep only cross-query metric invariants in Hard Rules
2. Move time-series execution guidance to aggregation patterns and delivery checks to the final chec
    klist

说明:
- Documentation-only structural clarification; no unit test is required

```ai-signature
改动范围: skills/lark-base/references/lark-base-data-analysis-sop.md 的 Hard Rules、聚合执行模式和最终答案检查
思考过程: 删除职责混杂的 0.1 子章节,将跨流程不变量、条件化执行细节和交付核对分别放回现有责任章节,避免新增顶层编号和重复规则
改动原因: 统计口径段同时混合查询前规划、聚合执行和最终输出,放在 Hard Rules 与 Intent 路由之间会破坏 SOP 层次并产生阶段歧义
Break Change: 否
```

Co-authored-by: BASE Infra Harness <ai@base-infra-harness.noreply.local>
AI-SHA256: 3c7cf576e026a1eb47be53985793123e95157e969ec352e91ad90893b9e68547
1. Restore type-aware URL object lookup and conditional time traceability from dd0d647
2. Prevent non-temporal analyses from acquiring date fields or filters
3. Preserve the current time-series metric, empty-bucket, and delivery-check rules

说明:
- Documentation-only union; unit tests intentionally skipped

```ai-signature
改动范围: lark-base 主 Skill 的 URL 目标定位与结果追溯规则,以及 data analysis SOP 的日期字段选择边界
思考过程: 以当前 PR 远端 head 为基线,仅恢复 dd0d647 的三处语义,不改动现有时间序列、空桶和总体校验规则
改动原因: PR 分支被 force-push 后旧提交的通用保护规则丢失,需要在保留当前统计优化的同时恢复
Break Change: 否
```

Co-authored-by: BASE Infra Harness <ai@base-infra-harness.noreply.local>
AI-SHA256: e5c0c7b6a04f20faf3b143a06d7db1f0b52de850aed0862a393bf1453ab0718c
1. Revert the type-aware URL lookup and conditional time-traceability restoration
2. Return PR 2262 to the 8caee7e documentation state

说明:
- Requested withdrawal of commit 51f980a; documentation-only, no unit test

```ai-signature
改动范围: 撤销 lark-base 主 Skill 和数据分析 SOP 中由 51f980a 恢复的三处文档规则
思考过程: 使用新的反向提交精确撤销上一提交,不 force-push、不改写 PR 历史,并保持 8caee7e 已有的时间序列规则
改动原因: 用户明确要求撤回本次恢复改动,使 PR 内容回到撤回前状态,同时保留当前 PR 原有的十一行改动
Break Change: 否
```

Co-authored-by: BASE Infra Harness <ai@base-infra-harness.noreply.local>
AI-SHA256: 56a89befdfae2a0f011431c5aa53dfa96c806e4540385e6dd1cef6d56fab9dcf
Comment thread skills/lark-base/SKILL.md
5. 最终答案必须能追溯到真实表、真实字段、查询范围、筛选/排序/聚合条件和必要的连接键。
6. 一次性原始记录查询优先用 `+record-list` / `+record-search` 的 filter/sort;聚合分析优先用 `+data-query`;要把结果长期显示在表里,才考虑新增 `formula` / `lookup` 字段。
7. `+data-query` 可返回聚合结果或维度字段行,但维度行按字段组合去重且不返回 `record_id`;需要逐条记录、记录定位或完整行级字段时,再用 `+record-list` / `+record-search` / `+record-get` 回查。
8. 同一请求同时要求按时间桶的某结果数量、该结果占比和趋势时,除非用户明确给出另一公式,三者必须使用同一时间字段和同一桶内总体:占比 = 命中数量 / 桶内全部记录。计划/预计日期、已完成子集或其他派生 KPI 不得替代主结果;用户未要求多口径时不要输出第二套比率。

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.

这不是通用的引导,不同用户场景对“占比和趋势”有不同的解释,不要把片面的 prompt 放在通用的 skill 里

@huarenmin13
huarenmin13 marked this pull request as draft August 11, 2026 12:13
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.

2 participants