Skip to content

Commit 875ae40

Browse files
os-warrenclaude
andauthored
feat(ai): get_record_context joins the service-ai platform tool group, with its chat label (ADR-0160 row 9) (#37210)
<!-- claude-projects-attribution: {"github_login":"os-warren"} --> _Requested by **Warren** · [project thread](https://claude.ai/code/project/chan_01U5RdnAAmkSQmZbqh6FtqZ8?thread=cmsg_01U5RdnAAmkSQmZbqh6FtqZ84wsrfBFiVrUB868HPtFvKC)_ Fixes #37190 ## 维护者速读 - 做什么:平台的「云端注册了哪些工具」清单加上 `get_record_context`;11 个语言包加上它在对话里显示的步骤名(中文「读取记录资料」)。 - 为什么:这是 cloud#4978(应用内助手注册这个工具)在本仓的一半,两边要一起落地。 - 出错会怎样:只影响清单注释与一条 lint 提示;作者写的东西不变。 - 要你做什么:无。**按卡上的落地顺序,本 PR 保持草稿,等 cloud#4978 的 PR(cloud#4987)就绪再合,然后由 cloud#4987 自己把 pin 前移过本 PR 的合并提交。** ## What changes - `packages/spec/src/system/constants/platform-tool-names.ts#PLATFORM_TOOLS_BY_PACKAGE`: `get_record_context` joins the `service-ai` group (cloud `@objectstack/service-ai` registers it for the in-app assistant from the same definition the MCP door serves, delegating to the same `record-context` executor, ADR-0160 D4). The group's docblock says so. It stays in `MCP_DOOR_TOOL_NAMES` too. - `chatbot.tool.get_record_context` in all eleven packs under `ui/packages/i18n/src/locales/` (en "Read the record context", zh-Hans 读取记录资料, zh-Hant 讀取記錄資料, …), placed after `get_record`. - The `skill.tools[]` lint rule (`packages/lint/src/validate-ai-tool-references.ts`) now resolves `get_record_context` for a skill kept out of MCP (`mcpPrompt: false`), so the expected report ADR-0160's implementation split note describes ends. No rule code changes: the name resolving through `PLATFORM_PROVIDED_TOOL_NAMES` is what ends it. - Pins: `platform-tool-names.test.ts` (in the `service-ai` group, at the door, not in `service-ai-studio`); `validate-ai-tool-references.test.ts` (resolves on `mcpPrompt: false`, `true` and unset, with a neighbour spelling as the control). - Changeset: `@objectstack/spec` patch, `@object-ui/i18n` patch. ## Why The registry's maintenance contract: a group is the exact set one cloud package registers, so the name joins with cloud's registration (cloud#4978, PR objectstack-ai/cloud#4987) and not before (card's *Order with cloud*). Cloud's `platform-tool-names-conformance.test.ts` asserts the `service-ai` group exactly, and cloud#4987 adds `get_record_context` to it: merge this first, then cloud#4987 carries the pin move past this merge sha (an unrelated cloud pin bump past it would turn that test red). ## Verification Container, worktree on `29f1280d` + this commit: - `pnpm --filter @objectstack/spec build` then `pnpm --filter @objectstack/spec check:generated`: all 14 artifacts up to date. - `packages/spec`: `vitest run src/system/constants/platform-tool-names.test.ts` → 12 passed. - `packages/lint`: `vitest run src/validate-ai-tool-references.test.ts` → 30 passed. - `ui`: `vitest run` of `plugin-chatbot/.../toolLabels-locale-parity-7481.test.ts`, `ChatbotEnhanced.answerSource-31868.test.tsx`, `i18n/.../all-locales-key-parity.test.ts` → all passed (94 tests). - Cloud side, against this head's framework build: cloud#4987's `platform-tool-names-conformance.test.ts` green with `get_record_context` in the group. Clause-②: yes (widening) — `PLATFORM_TOOLS_BY_PACKAGE` and `PLATFORM_PROVIDED_TOOL_NAMES` gain `get_record_context`, so `ai-skill-tool-unresolved` stops reporting it on a `mcpPrompt: false` skill; nothing that resolved before is reported Metadata-protocol: none Skills-docs: none — `skills/objectstack-ai/SKILL.md` points at the registry file and names no tool ## Human Minimum - [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic. - [x] 2. Every name I added uses the casing for its kind. - [x] 3. No formatter ran; `pnpm lint` passes. - [x] 4. One issue, one branch off an up-to-date `main`, one pull request. - [x] 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset. - [x] 6. `packages/spec` touched: its generated artifacts are regenerated and committed. - [x] 7. No hand edits to `content/docs/references/`, `packages/*/CHANGELOG.md` or `content/docs/releases/`. - [x] 8. Title, body and comments are in English. - [x] The *Before Submitting* list in CONTRIBUTING.md is done. --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent b7dee0e commit 875ae40

15 files changed

Lines changed: 64 additions & 1 deletion

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
'@objectstack/spec': patch
3+
'@object-ui/i18n': patch
4+
---
5+
6+
feat(ai): `get_record_context` joins the cloud `service-ai` group of `PLATFORM_TOOLS_BY_PACKAGE`, with its chat step label
7+
8+
Clause-②: yes (widening) — `PLATFORM_TOOLS_BY_PACKAGE` and `PLATFORM_PROVIDED_TOOL_NAMES` gain `get_record_context`, so `ai-skill-tool-unresolved` stops reporting it on a `mcpPrompt: false` skill; nothing that resolved before is reported
9+
Metadata-protocol: none
10+
Skills-docs: none — `skills/objectstack-ai/SKILL.md` points at the registry file and names no tool
11+
12+
The in-app assistant (cloud `@objectstack/service-ai`) registers `get_record_context` from the same definition the MCP door serves and delegates to the same `record-context` executor (ADR-0160 D4). Its name now sits in that group of the platform tool registry, so `PLATFORM_PROVIDED_TOOL_NAMES` resolves it. The `skill.tools[]` lint rule therefore stops reporting it for a skill kept out of MCP (`mcpPrompt: false`); before, it reported the name as served over MCP only. Nothing an author writes changes.
13+
14+
New locale key: `chatbot.tool.get_record_context` in all eleven packs (en "Read the record context", zh-Hans 读取记录资料), the step name the chat shows while the assistant reads a record's context pack.

‎packages/lint/src/validate-ai-tool-references.test.ts‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,27 @@ describe('validate-ai-tool-references', () => {
359359
expect(findings[2].message).toContain('"nope_tool" resolves to no stack, platform or materialised action tool');
360360
});
361361

362+
/**
363+
* [ADR-0160 D4] `get_record_context` is served by the MCP door and
364+
* registered by cloud `service-ai` for the in-app assistant, so a skill kept
365+
* out of MCP (`mcpPrompt: false`) that reads a pack resolves it. Before the
366+
* cloud registration joined the registry, the rule reported it as an
367+
* MCP-only name (ADR-0160's implementation split note).
368+
*/
369+
it('resolves get_record_context on a mcpPrompt: false skill, as on one MCP projects (ADR-0160 D4)', () => {
370+
for (const mcpPrompt of [false, true, undefined]) {
371+
const findings = validateAiToolReferences({
372+
skills: [{
373+
name: 'account_brief',
374+
...(mcpPrompt === undefined ? {} : { mcpPrompt }),
375+
tools: ['get_record_context', 'get_record_contexts'],
376+
}],
377+
});
378+
// The control: a neighbour spelling nobody registers is still reported.
379+
expect(findings.map((f) => f.path), String(mcpPrompt)).toEqual(['skills[0].tools[1]']);
380+
}
381+
});
382+
362383
/**
363384
* The chat's confirmed record write (cloud#3565; it replaced cloud#3383's
364385
* `draft_record`): a skill naming `create_record` / `update_record` resolves;

‎packages/spec/src/system/constants/platform-tool-names.test.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
isPlatformProvidedToolName,
2020
} from './platform-tool-names';
2121
import { LIST_DATASETS_TOOL_NAME, QUERY_DATASET_TOOL_NAME } from '../../ai/dataset-tools.zod';
22+
import { GET_RECORD_CONTEXT_TOOL_NAME } from '../../ai/record-context-tools.zod';
2223

2324
describe('PLATFORM_PROVIDED_TOOL_NAMES — internal invariants', () => {
2425
it('every name is snake_case (ToolSchema name grammar)', () => {
@@ -66,6 +67,17 @@ describe('PLATFORM_PROVIDED_TOOL_NAMES — internal invariants', () => {
6667
expect(isPlatformProvidedToolName('query_datasets')).toBe(false);
6768
});
6869

70+
it('lists get_record_context in the service-ai group and at the MCP door alike (ADR-0160 D4)', () => {
71+
// Cloud `service-ai` registers the tool for the in-app assistant from the
72+
// same definition the MCP door serves, delegating to the same executor.
73+
// Until the group carried it, a skill kept out of MCP (`mcpPrompt: false`)
74+
// that named it was reported as served over MCP only.
75+
expect(PLATFORM_TOOLS_BY_PACKAGE['service-ai']).toContain(GET_RECORD_CONTEXT_TOOL_NAME);
76+
expect(MCP_DOOR_TOOL_NAMES).toContain(GET_RECORD_CONTEXT_TOOL_NAME);
77+
// It is one cloud package's registration, not the authoring product's.
78+
expect(PLATFORM_TOOLS_BY_PACKAGE['service-ai-studio']).not.toContain(GET_RECORD_CONTEXT_TOOL_NAME);
79+
});
80+
6981
it('each group is sorted, so diffs stay reviewable', () => {
7082
for (const [pkg, names] of Object.entries(PLATFORM_TOOLS_BY_PACKAGE)) {
7183
expect([...names].sort(), pkg).toEqual([...names]);

‎packages/spec/src/system/constants/platform-tool-names.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,16 @@ export const PLATFORM_TOOLS_BY_PACKAGE: Readonly<Record<string, readonly string[
5555
* the installed datasets and the metrics each defines, and `query_dataset`
5656
* answers a question through one governed metric instead of an ad-hoc
5757
* aggregate. Their names and shapes are declared once in
58-
* `../../ai/dataset-tools.zod` (ADR-0149 D2), which MCP registers too.
58+
* `../../ai/dataset-tools.zod` (ADR-0149 D2), which MCP registers too. And
59+
* `get_record_context` (ADR-0160 D4): one record read through its context
60+
* pack, as the caller, from the definition in
61+
* `../../ai/record-context-tools.zod` and delegated to the open
62+
* `record-context` service's executor — the same one the MCP door serves.
5963
*/
6064
'service-ai': [
6165
'aggregate_data',
6266
'get_record',
67+
'get_record_context',
6368
'list_datasets',
6469
'query_data',
6570
'query_dataset',

‎ui/packages/i18n/src/locales/ar.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5069,6 +5069,7 @@ const ar = {
50695069
tool: {
50705070
aggregate_data: "تجميع البيانات ذات الصلة",
50715071
get_record: "قراءة هذا السجل",
5072+
get_record_context: "قراءة ملف سياق هذا السجل",
50725073
list_datasets: "عرض المؤشرات المتاحة",
50735074
query_data: "الاستعلام عن البيانات المطلوبة",
50745075
query_dataset: "الاستعلام حسب المؤشر",

‎ui/packages/i18n/src/locales/de.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4683,6 +4683,7 @@ const de = {
46834683
tool: {
46844684
aggregate_data: "Die Daten zusammenfassen",
46854685
get_record: "Den Datensatz lesen",
4686+
get_record_context: "Den Kontext des Datensatzes lesen",
46864687
list_datasets: "Die verfügbaren Kennzahlen ansehen",
46874688
query_data: "Die benötigten Daten abfragen",
46884689
query_dataset: "Über eine Kennzahl abfragen",

‎ui/packages/i18n/src/locales/en.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5655,6 +5655,7 @@ const en = {
56555655
tool: {
56565656
aggregate_data: 'Aggregate the data',
56575657
get_record: 'Read the record',
5658+
get_record_context: 'Read the record context',
56585659
list_datasets: 'Check the available metrics',
56595660
query_data: 'Query the data',
56605661
query_dataset: 'Query by a metric',

‎ui/packages/i18n/src/locales/es.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4780,6 +4780,7 @@ const es = {
47804780
tool: {
47814781
aggregate_data: "Resumir los datos",
47824782
get_record: "Leer el registro",
4783+
get_record_context: "Leer el contexto del registro",
47834784
list_datasets: "Ver las métricas disponibles",
47844785
query_data: "Consultar los datos necesarios",
47854786
query_dataset: "Consultar por métrica",

‎ui/packages/i18n/src/locales/fr.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4776,6 +4776,7 @@ const fr = {
47764776
tool: {
47774777
aggregate_data: "Synthétiser les données",
47784778
get_record: "Lire l’enregistrement",
4779+
get_record_context: "Lire le contexte de l’enregistrement",
47794780
list_datasets: "Consulter les indicateurs disponibles",
47804781
query_data: "Interroger les données nécessaires",
47814782
query_dataset: "Interroger un indicateur",

‎ui/packages/i18n/src/locales/ja.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4685,6 +4685,7 @@ const ja = {
46854685
tool: {
46864686
aggregate_data: "関連データを集計する",
46874687
get_record: "このレコードを読み込む",
4688+
get_record_context: "このレコードの資料を読む",
46884689
list_datasets: "利用できる指標を確認する",
46894690
query_data: "必要なデータを照会する",
46904691
query_dataset: "指標で照会する",

0 commit comments

Comments
 (0)