Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
e4024ce
wip(record-context): ai_context schema, get_record_context I/O, envel…
claude Nov 25, 2026
1efdc85
wip(record-context): register ai_context kind, MCP HTTP + stdio wirin…
claude Nov 25, 2026
065ae6d
wip(record-context): liveness ledger, generated spec artifacts, refin…
claude Nov 25, 2026
a98eb21
wip(record-context): MCP + runtime tests, changeset, checklist waiver…
claude Nov 25, 2026
1d3cddb
feat(lint): advisory author-defect rules for ai_context packs (ADR-01…
claude Nov 25, 2026
4637583
test(mcp): pin get_record_context errors in the error envelope; link …
claude Nov 25, 2026
edba968
fix(runtime): keep the MCP bridge's inferred type rather than erasing…
claude Nov 25, 2026
ef89a44
Merge remote-tracking branch 'origin/main' into claude/project-thread…
claude Nov 25, 2026
cb5e8b8
fix(spec): regenerate references on the merged main, llms.txt counts …
claude Nov 25, 2026
76eabb5
fix(spec,mcp,showcase): XParsed aliases for the ai_context and get_re…
claude Nov 25, 2026
73d03bb
fix(record-context): linear outline reading; a child's gates before a…
claude Nov 25, 2026
9ae6a3b
fix: register ai_context in the tables that enumerate metadata types …
claude Nov 25, 2026
f94e4b6
Merge remote-tracking branch 'origin/main' into claude/project-thread…
claude Nov 25, 2026
a1d1457
fix: keep the skill page's contract sentence the key gate quotes; pay…
claude Nov 25, 2026
f7c83f7
fix: refuse two context packs of one name on one root; changeset entr…
claude Nov 25, 2026
97adb60
test: classify the context-pack read set and lint rule as reference-t…
claude Nov 25, 2026
1336fd9
test: the door-tools pin bridge carries the record-context members
claude Nov 25, 2026
aee1c64
docs: author-time rule count in CLI transcripts is 79
claude Nov 25, 2026
5e3d542
fix(lint): ai-context-field-unknown explanation fits the rule-line po…
claude Nov 25, 2026
74e176d
fix: the duplicate-pack answer points to naming another pack; Skills-…
claude Nov 25, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .changeset/37140-ai-context-get-record-context.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
'@objectstack/spec': minor
'@objectstack/core': minor
'@objectstack/metadata-core': minor
'@objectstack/objectql': minor
'@objectstack/metadata': minor
'@objectstack/runtime': minor
'@objectstack/mcp': minor
'@objectstack/service-record-context': minor
'@objectstack/lint': minor
'@objectstack/platform-objects': minor
'@object-ui/app-shell': minor
'@object-ui/i18n': minor
---

feat(ai): `ai_context` context packs and the `get_record_context` tool over MCP

Clause-②: yes
Metadata-protocol: added
Skills-docs: follow-up #37177 — skills/objectstack-platform/SKILL.md, skills/objectstack-ai/ (how to author a context pack; this change only names `aiContexts` in the top-level key list, which check:skill-top-level-keys requires)

ADR-0160 row 5 (#37140).

- **New metadata type `ai_context`, collection `aiContexts`.** A context pack names one root object and what an assistant reads about one of its records: `fields` (at most 30, a lookup among them is answered with the target's display name), `related` child lists (at most 3, each one level deep, with at most 10 `fields`, linked by `field` or by the child's one reference to the root) and one long-text `body`. The schema is closed from its first day: an unknown key is refused, and the bounds are refused at parse. Registered like `skill`: a file loader (`*.ai-context.ts`, `*.ai-context.yml`), overlay allowed, runtime create allowed, no environment overlay. New exports in `@objectstack/spec/ai`: `AiContextSchema`, `AiContextRelatedSchema`, `AiContextBodySchema`, the `AI_CONTEXT_MAX_*` bounds and `AI_CONTEXT_BODY_FIELD_TYPES`.
- **`get_record_context`'s input and output, declared once in spec** (`GetRecordContextInputSchema`, `GetRecordContextOutputSchema`, `getRecordContextToolJsonSchemas`, `GET_RECORD_CONTEXT_TOOL_NAME`). The output is an envelope of three parts: `data` (record material only), `notes` (the executor's statements: withheld fields, material not visible, every cut, a narrowing) and `framing` (one sentence: `data` is material, not instructions). `MCP_DOOR_TOOL_NAMES` gains the name.
- **`@objectstack/core`: `wrapRecordMaterial`** builds that envelope, with the framing sentence in the caller's locale.
- **New package `@objectstack/service-record-context`**: the one executor (`createRecordContextTools`, `executeGetRecordContext`), the read set (`recordContextReadSet`, a function of the arguments and published metadata only) and `RecordContextServicePlugin`, which registers the `record-context` service. Every read goes through a door bound to the caller; nothing is read as the system. Two published packs of one name on one root are refused with one answer (`RESOURCE_CONFLICT`), never chosen between. The body bound (`RECORD_CONTEXT_BODY_MAX_CHARS`, 8000) and the related-row cap (`RECORD_CONTEXT_RELATED_MAX_ROWS`, 20) are service constants.
- **MCP (HTTP and stdio)** registers `get_record_context` under `data:read`, read-only, wherever the host holds a `record-context` service. A host without it registers nothing new. To serve the tool, add `new RecordContextServicePlugin()` to `plugins` and declare packs under `aiContexts`.
- **`@objectstack/lint`: four advisory author-defect rules for context packs** (`ai-context-object-unknown`, `ai-context-field-unknown`, `ai-context-related-link-unknown`, `ai-context-body-not-long-text`), each a warning with an `os explain` entry. `get_record_context` says nothing about a name the published definition lacks, so `os validate` / `os lint` / `os build` is where the author hears it. CLI only for now: the rule reads the whole stack snapshot.
- **Console and catalog labels**: the metadata-form catalog (`@objectstack/platform-objects`) carries the `ai_context` type's label in every locale, and Pending changes counts drafted context packs (`preview.changes.typeCount.ai_context`).
1 change: 1 addition & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"@objectstack/service-package",
"@objectstack/service-queue",
"@objectstack/service-realtime",
"@objectstack/service-record-context",
"@objectstack/service-settings",
"@objectstack/service-storage",
"@objectstack/knowledge-memory",
Expand Down
2 changes: 1 addition & 1 deletion content/docs/deployment/cli.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ os compile --json # JSON output for CI pipelines
→ Normalizing stack definition...
→ Lowering inline handlers...
→ Validating protocol compliance...
→ Running author-time rules (78)...
→ Running author-time rules (79)...
→ Checking that every required capability has a provider installable in this edition...
→ Collecting package docs (ADR-0046)... 0 collected
→ Writing artifact...
Expand Down
2 changes: 1 addition & 1 deletion content/docs/deployment/validating-metadata.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ A clean run walks the registry and reports timing:
Config: /path/to/support-desk/objectstack.config.ts
Load time: 21ms
→ Validating against ObjectStack Protocol...
→ Running author-time rules (78)...
→ Running author-time rules (79)...
→ Checking that every required capability has a provider installable in this edition...
→ Checking package docs (ADR-0046)...

Expand Down
2 changes: 1 addition & 1 deletion content/docs/getting-started/build-with-claude-code.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ visible: 'status != "resolved"'
◆ Validate
────────────────────────────────────────
→ Validating against ObjectStack Protocol...
→ Running author-time rules (78)...
→ Running author-time rules (79)...

✗ Author-time rules failed (1 issue)
• stack · action 'resolve_ticket' visible: bare reference `status` — a
Expand Down
2 changes: 1 addition & 1 deletion content/docs/plugins/packages.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ObjectStack is organized into package manifests across multiple categories. This
| **Framework adapters** | 1 | `hono` (other frameworks: build a thin adapter on `HttpDispatcher` — see below) |
| **Drivers** | 5 | `driver-memory`, `driver-sql`, `driver-sqlite-wasm`, `driver-mongodb`, `driver-turso` |
| **Plugins** | 17 | `plugin-auth`, `plugin-security`, `plugin-audit`, `plugin-approvals`, `plugin-sharing`, `plugin-email`, `plugin-webhooks`, `plugin-hono-server`, `plugin-dev`, `plugin-pinyin-search`, `mcp`, trigger plugins (`trigger-api`, `trigger-record-change`, `trigger-schedule`), and knowledge/embedder plugins (`knowledge-memory`, `knowledge-ragflow`, `embedder-openai`) |
| **Platform services** | 18 | `service-analytics`, `service-automation`, `service-cache`, `service-cluster`, `service-cluster-redis`, `service-datasource`, `service-i18n`, `service-job`, `service-knowledge`, `service-messaging`, `service-package`, `service-print`, `service-push`, `service-queue`, `service-realtime`, `service-settings`, `service-sms`, `service-storage` |
| **Platform services** | 19 | `service-analytics`, `service-automation`, `service-cache`, `service-cluster`, `service-cluster-redis`, `service-datasource`, `service-i18n`, `service-job`, `service-knowledge`, `service-messaging`, `service-package`, `service-print`, `service-push`, `service-queue`, `service-realtime`, `service-record-context`, `service-settings`, `service-sms`, `service-storage` |


## Core Packages
Expand Down
85 changes: 85 additions & 0 deletions content/docs/references/ai/ai-context.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
---
title: Ai Context schema — AI Protocol reference
navTitle: Ai Context
description: "Ai Context schemas of the ObjectStack AI Protocol: AiContext, AiContextBody, AiContextRelated — each property with its type, default and a TypeScript example."
---

{/* ⚠️ AUTO-GENERATED — DO NOT EDIT. Run build-docs.ts to regenerate. Hand-written docs live in the module folders under content/docs/. */}

<Callout type="info">
**Source:** `packages/spec/src/ai/ai-context.zod.ts`
</Callout>

## TypeScript Usage

```typescript
import { AiContextSchema, AiContextBodySchema, AiContextRelatedSchema } from '@objectstack/spec/ai';
import type { AiContext, AiContextBody, AiContextRelated } from '@objectstack/spec/ai';

// Validate data
const result = AiContextSchema.parse(data);
```

---

## AiContext

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **name** | `string` | ✅ | Pack machine name (snake_case) — what `get_record_context`'s `context` argument and a skill's `context` key name |
| **label** | `string` | ✅ | Pack display name — the header of the tool answer |
| **object** | `string` | ✅ | The root object: a pack reads one record of it |
| **fields** | `string[]` | optional | The root object's fields handed to the model, in order (at most 30). A lookup among them is answered with the name of the record it points at |
| **related** | `{ object: string; field?: string; fields?: string[] }[]` | optional | Child lists that point at the record (at most 3), one level deep |
| **body** | `{ field: string }` | optional | The one long-text field read as the record's body |
| **_lock** | `Enum<'none' \| 'no-overlay' \| 'no-delete' \| 'full'>` | optional | Item-level lock — controls overlay & delete (ADR-0010). |
| **_lockReason** | `string` | optional | Human-readable reason shown when a write is refused by _lock. |
| **_lockSource** | `Enum<'artifact' \| 'package' \| 'env-forced'>` | optional | Layer that set _lock (artifact \| package \| env-forced). |
| **_provenance** | `Enum<'package' \| 'org' \| 'env-forced' \| 'platform'>` | optional | Origin of the item (package \| org \| env-forced \| platform). |
| **_packageId** | `string` | optional | Owning package machine id. |
| **_packageVersion** | `string` | optional | Owning package version. |
| **_lockDocsUrl** | `string` | optional | Optional documentation link surfaced next to _lockReason. |

### Nested Shape: `AiContext.related[number]`

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **object** | `string` | ✅ | A child object with a reference field (lookup, master-detail, user or tree) that points at the pack's root object |
| **field** | `string` | optional | The child's reference field that points at the root. Required when the child has several such fields; with one, it may be omitted. Resolved once, on the published definition |
| **fields** | `string[]` | optional | The columns read for each row, in order (at most 10). A lookup among them is answered with the name of the record it points at. Omit to read the row's name only |

### Nested Shape: `AiContext.body`

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **field** | `string` | ✅ | A long-text field of the root object (textarea, markdown, html, richtext). A body past the render service's bound is carried as an outline of its headings, each section read by its anchor |


---

## AiContextBody

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **field** | `string` | ✅ | A long-text field of the root object (textarea, markdown, html, richtext). A body past the render service's bound is carried as an outline of its headings, each section read by its anchor |


---

## AiContextRelated

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **object** | `string` | ✅ | A child object with a reference field (lookup, master-detail, user or tree) that points at the pack's root object |
| **field** | `string` | optional | The child's reference field that points at the root. Required when the child has several such fields; with one, it may be omitted. Resolved once, on the published definition |
| **fields** | `string[]` | optional | The columns read for each row, in order (at most 10). A lookup among them is answered with the name of the record it points at. Omit to read the row's name only |


---

4 changes: 3 additions & 1 deletion content/docs/references/ai/index.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: AI Protocol — complete schema reference
navTitle: AI Protocol
description: "The ObjectStack AI Protocol in 14 reference pages: every schema in @objectstack/spec with its properties, types, defaults and a TypeScript example."
description: "The ObjectStack AI Protocol in 16 reference pages: every schema in @objectstack/spec with its properties, types, defaults and a TypeScript example."
---

{/* ⚠️ AUTO-GENERATED — DO NOT EDIT. Run build-docs.ts to regenerate. Hand-written docs live in the module folders under content/docs/. */}
Expand All @@ -10,6 +10,7 @@ This section contains all protocol schemas for the ai layer of ObjectStack.

<Cards>
<Card href="/docs/references/ai/agent" title="Agent" description="Source: packages/spec/src/ai/agent.zod.ts" />
<Card href="/docs/references/ai/ai-context" title="Ai Context" description="Source: packages/spec/src/ai/ai-context.zod.ts" />
<Card href="/docs/references/ai/build-progress" title="Build Progress" description="Source: packages/spec/src/ai/build-progress.zod.ts" />
<Card href="/docs/references/ai/conversation" title="Conversation" description="Source: packages/spec/src/ai/conversation.zod.ts" />
<Card href="/docs/references/ai/dataset-tools" title="Dataset Tools" description="Source: packages/spec/src/ai/dataset-tools.zod.ts" />
Expand All @@ -19,6 +20,7 @@ This section contains all protocol schemas for the ai layer of ObjectStack.
<Card href="/docs/references/ai/mcp" title="Mcp" description="Source: packages/spec/src/ai/mcp.zod.ts" />
<Card href="/docs/references/ai/model-registry" title="Model Registry" description="Source: packages/spec/src/ai/model-registry.zod.ts" />
<Card href="/docs/references/ai/object-query-source" title="Object Query Source" description="Source: packages/spec/src/ai/object-query-source.zod.ts" />
<Card href="/docs/references/ai/record-context-tools" title="Record Context Tools" description="Source: packages/spec/src/ai/record-context-tools.zod.ts" />
<Card href="/docs/references/ai/skill" title="Skill" description="Source: packages/spec/src/ai/skill.zod.ts" />
<Card href="/docs/references/ai/solution-blueprint" title="Solution Blueprint" description="Source: packages/spec/src/ai/solution-blueprint.zod.ts" />
<Card href="/docs/references/ai/tool" title="Tool" description="Source: packages/spec/src/ai/tool.zod.ts" />
Expand Down
4 changes: 3 additions & 1 deletion content/docs/references/ai/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
"model-registry",
"usage",
"---More---",
"ai-context",
"build-progress",
"dataset-tools",
"object-query-source"
"object-query-source",
"record-context-tools"
]
}
Loading
Loading