Skip to content
Draft
Changes from all commits
Commits
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
25 changes: 22 additions & 3 deletions docs/adr/0160-record-scoped-ai-inquiry.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ADR-0160: Record-scoped AI inquiry — a context pack is its own metadata type, read as the caller and served by one tool; conversation focus, the `ask_ai` action type, the skill `context` key, the citation shape

**Status**: Accepted — merged 2026-11-24 (PR [objectstack#37115](https://github.com/objectstack-ai/objectstack/pull/37115)); amended 2026-11-25 (see **Amended** below). Written 2026-11-24 for objectstack#36997 (epic objectstack#36996) on the maintainer's acceptance of the epic's decision list that day, verbatim as the epic records it: 「需要拍板的事项 都同意」. It stands on cloud ADR-0119 (Accepted 2026-11-24), which rules this mechanism open source ([Provenance](#provenance)). `docs/adr/**` is Tier H (Prime Directive #14): this record becomes **Accepted** by an authorized approval or the maintainer's merge of the PR that carries it, and is in force from that merge. **This record declares; it implements nothing** — no schema, no code, no changeset, and no anchor under `scripts/adr-anchors/`; every mechanism below is cut as a card after the merge ([Implementation split](#implementation-split-after-acceptance)).
**Status**: Accepted — merged 2026-11-24 (PR [objectstack#37115](https://github.com/objectstack-ai/objectstack/pull/37115)); amended 2026-11-25 and 2026-11-26 (see **Amended** below). Written 2026-11-24 for objectstack#36997 (epic objectstack#36996) on the maintainer's acceptance of the epic's decision list that day, verbatim as the epic records it: 「需要拍板的事项 都同意」. It stands on cloud ADR-0119 (Accepted 2026-11-24), which rules this mechanism open source ([Provenance](#provenance)). `docs/adr/**` is Tier H (Prime Directive #14): this record becomes **Accepted** by an authorized approval or the maintainer's merge of the PR that carries it, and is in force from that merge. **This record declares; it implements nothing** — no schema, no code, no changeset, and no anchor under `scripts/adr-anchors/`; every mechanism below is cut as a card after the merge ([Implementation split](#implementation-split-after-acceptance)).

- **Date**: 2026-11-24
- **Amended**: 2026-11-25, by the maintainer's word, verbatim: 「同意你的建议」. The maintainer was answering two independent analyses of this record, written in the maintainer's session on 2026-11-25 for [objectstack#36996](https://github.com/objectstack-ai/objectstack/issues/36996). One weighed points 1, 2 and 10 of [Points that go past the card's words](#points-that-go-past-the-cards-words), which this record said needed the maintainer's explicit acceptance. The other reviewed the six cards cut from the [Implementation split](#implementation-split-after-acceptance). The amendment records the following:
Expand Down Expand Up @@ -31,6 +31,12 @@
- **A quote from a related row names the root record.** `object` and `id` are the pack's root; the quote is matched across the whole data member, related-list cells included; the surface opens the root record; `anchor` keeps its one meaning, a heading of the root record's body.
- The TL;DR's point 9 and [Not decided here](#not-decided-here) say the same. The ruling's words are the three answers above; the text adds one point of its own, point 23 of [Points that go past the card's words](#points-that-go-past-the-cards-words).
- Nothing else changes.
- **Amended**: 2026-11-26, a fourth time, to record what PR [objectstack#37484](https://github.com/objectstack-ai/objectstack/pull/37484) shipped for card [objectstack#37233](https://github.com/objectstack-ai/objectstack/issues/37233): a body outline past its bounds comes in pages. This amendment is card [objectstack#37490](https://github.com/objectstack-ai/objectstack/issues/37490), that PR's follow-up. It rests on no ruling of its own: it writes down what `main` does, and it is accepted with the approval or the merge of the PR that carries it. Its readings of the tree were taken on `main` at `41164656`. It records the following:
- **An outline past its bounds comes in pages.** The tool's `outlineFrom` lists a later page, and `outlineNext` on the answer's body says where the next page starts. See [D3](#d3), "Outline pages", and [D4](#d4), "Definition".
- **A walk of the pages holds for one state of the body.** The cursor is a position in the body as it is when the call reads it, so an edit between two page calls can skip or repeat a heading with no signal. See [D3](#d3), "Outline pages".
- **`anchor` and `outlineFrom` are exclusive.** A call that names both is refused before any gate is judged and any record is read. See [D4](#d4), "Definition".
- The text's own settlement is point 24 of [Points that go past the card's words](#points-that-go-past-the-cards-words).
- Nothing else changes.
- **Decided by**: the maintainer, 2026-11-24, verbatim and untranslated, as epic [objectstack#36996](https://github.com/objectstack-ai/objectstack/issues/36996) records them: 「先立专题 ① 记录范围 AI 问询 ;⑤ 应用技能进入应用内 AI ,M0 那几项知识服务缺陷 也立专题,目前开发的策略是按专题派」 and 「需要拍板的事项 都同意」. The six rulings the epic sets over every child are quoted in [Provenance](#provenance); ⛔ none of them is re-opened here.
- **Card**: [objectstack#36997](https://github.com/objectstack-ai/objectstack/issues/36997). It lists ten items; D1–D9 decide items 1–9 in the card's order and [Not decided here](#not-decided-here) carries item 10.
- **Builds on**: [ADR-0005](./0005-metadata-customization-overlay.md) (its ai row: a behavioural contract takes no environment overlay), [ADR-0011](./0011-actions-as-ai-tools.md) (an action reaches AI only through its `ai` exposure block), [ADR-0049](./0049-no-unenforced-security-properties.md) (enforce or remove), [ADR-0088](./0088-metadata-kind-admission-and-retirement.md) (the kind admission test), [ADR-0090](./0090-permission-model-v2-concept-convergence.md) D10 (the agent ceiling over reads), [ADR-0106](./0106-metadata-plane-fls-object-schema-masking.md) (the caller's served schema), [ADR-0112](./0112-error-code-vocabulary-and-ledger.md) (the error envelope and its catalogue), [ADR-0149](./0149-ai-answers-business-questions-through-the-dataset-semantic-layer.md) D2 and M1 (one definition, one executor, every transport; guidance sentences belong to the executor), [ADR-0159](./0159-forms-are-their-own-metadata-type-public-forms-are-form-items-view-is-lists-only.md) (the latest kind admission; the form of D1).
Expand Down Expand Up @@ -220,6 +226,15 @@ This is how ruling 2's sentence — "A field hidden from the caller reads 'not v

**The body.** A body within the service's bound is carried whole. A longer body is carried as an outline: its headings in order, each with an `anchor`. One section is read by calling the tool again with that `anchor` ([D4](#d4)). A long body with no headings is carried up to the bound and marked truncated. An outline is bounded too. Its listing stays within the body bound, and the most headings one outline lists is a further constant of the service (`packages/services/service-record-context/src/body-outline.ts#RECORD_CONTEXT_OUTLINE_MAX_ENTRIES`). An outline cut by either bound says so (second amendment, 2026-11-25, carried from the review of objectstack#37178). Every cut is stated in the notes — a truncated body, a cut outline, a related list cut at its `limit`, at its cap or at the door's page cap, or a cell cut under the bound below. The body bound and the row cap of a related list are constants of the service, fixed and pinned by test in row 5; the outline's cap is one too, set and pinned by test in objectstack#37178; this record sets no number.

**Outline pages (fourth amendment, 2026-11-26).** The two bounds on an outline bound one answer, not which headings can be listed. An outline past either bound comes in pages (`packages/services/service-record-context/src/body-outline.ts#boundedOutline`).

- **The order.** The pages run through the body's headings in one order: shallowest level first, and in body order within a level. Each page lists its own headings in body order. So the first page of a nested body is its top levels, and a flat body's pages are runs of it.
- **The continuation.** A page that leaves headings for a later page carries `outlineNext` on its body. Calling the tool again with that number as `outlineFrom` lists the next page ([D4](#d4)). The last page carries no `outlineNext`. An `anchor` reads its section whichever page issued it.
- **What a walk covers.** Within one state of the body, every heading is listed on exactly one page, with its anchor, so following `outlineNext` from the first page lists them all. The one exception is a heading whose entry alone passes the body bound. No page lists it and no anchor is issued for it; the cut statement counts it.
- **One state of the body.** `outlineFrom` is a position in the page order of the body as the call reads it, and the tool keeps nothing between calls. If the body is edited between two page calls, the later call answers the page at that position of the body as it then is, or is refused as below where that body has nothing left to list from it. The walk can then skip a heading or list one twice, and nothing in the answer says so. The anchors on each page are still current: they are derived from the body that call read.
- **The notes, on every page.** Every page carries the statement that the body is given as an outline. Every page that does not list all of the body's headings carries the cut statement: how many headings the page lists, how many it does not, and the `outlineFrom` of the next page, or that no later page lists more. That statement carries counts and a position, never an anchor: a note never carries record text, and an anchor is derived from heading text. That is why the cursor is a position.
- **A page that does not exist.** An `outlineFrom` above 0 with no heading left to list from it is refused, never answered with the first page. The refusal is one answer whatever the reason, with the code an `anchor` that does not resolve gets (`RESOURCE_NOT_FOUND`, 404): a position past the last heading a page lists, a body carried whole or cut without an outline, a pack with no `body`, a body the caller's projection dropped, or a body withheld from the caller. So `outlineFrom`, like `anchor`, cannot show that a pack has a body the caller's schema hides. `outlineFrom` 0 is the first page.

**The bound on carried text (amended 2026-11-25).** A related list's columns may include long-text fields, and their values are carried as served, within one bound. Text the pack carries counts toward one total bound: the body, and every long-text value in the related lists' cells.

- **What counts.** Every long-text cell counts, a long-text field in `fields` included. Nothing is carried unbounded.
Expand All @@ -243,8 +258,8 @@ The framing sentence covers the data member only, so it does not undo a note. Sp

**Definition.** Input and output are zod in `@objectstack/spec`, in a new module beside the dataset tools' module, projected to JSON Schema the way `packages/spec/src/ai/dataset-tools.zod.ts#getDatasetToolJsonSchemas` does. This follows the dataset tools' form, not the knowledge tool's.

- Input, strict: `{ objectName: string, recordId: string, context?: string, anchor?: string }`, with the record tools' aliases for the first two.
- Output: the D3 envelope, with its three parts — the data member, the notes and the framing sentence. The data member holds the pack header (`name`, `label`), the record (`object`, `id`, display name), the field entries, the related lists and the body or its outline.
- Input, strict: `{ objectName: string, recordId: string, context?: string, anchor?: string, outlineFrom?: integer }`, with the record tools' aliases for the first two. `anchor` reads one section of the body and `outlineFrom` lists one page of its outline ([D3](#d3), "Outline pages"; fourth amendment, 2026-11-26), so a call names at most one of them. A call that names both is refused `VALIDATION_ERROR` (400) in step 1 of the order below, before any gate is judged and any record is read.
- Output: the D3 envelope, with its three parts — the data member, the notes and the framing sentence. The data member holds the pack header (`name`, `label`), the record (`object`, `id`, display name), the field entries, the related lists and the body or its outline. An outline page that leaves headings for a later page carries `outlineNext` on the body: the `outlineFrom` of the next page (fourth amendment, 2026-11-26).

**Order of judgement.** The steps run in this order, and no later step changes an earlier answer:

Expand Down Expand Up @@ -385,6 +400,10 @@ Each is this record's settlement, taken from the tree's precedent. Points 1, 2 a

23. **A refused verifying call drops the citation** (D9). The ruling says a citation without `context` on an object with several packs is not verified, because the tool's refusal stands. The text reads every refusal the same way: the verifier's call answers no data member, so the quote is not found and the citation is dropped — a `context` no pack has and an `anchor` that does not resolve, as much as the several-packs case. The alternative not taken is a second call without the offending argument, which would pick a pack or a body the model did not cite.

**The fourth amendment's point (2026-11-26).** The fourth amendment records what PR objectstack#37484 shipped and rests on no ruling of its own. So its text is this record's settlement, accepted with the PR that carries the amendment, and it is listed as one point.

24. **A long outline is paged on the same tool, by a position** (D3, D4). `outlineFrom` joins `anchor` on `get_record_context`, as point 4 keeps a section read on that tool, and a call that names both is refused. The cursor is a position in the body's page order and not an anchor, because the note that says where to continue may carry no record text. So a walk holds for one state of the body, and an edit between two page calls is not signalled. The alternative that PR weighed and did not take is one answer that lists every omitted heading's anchor compactly: for a large enough body it passes the same bound and needs a cut of its own.

## Implementation split (after acceptance)

Rows 5–10 of the epic's table, with the epic's numbers, and row 11, which the second amendment of 2026-11-25 adds. Listed, not filed: the owning seat files them when this record merges. Each PR makes its own `Metadata-protocol:` declaration; the column is the expected one.
Expand Down
Loading