Repository navigation
feat(service-record-context): cap the body outline's entries and state the cut - #37222
Conversation
…e the cut An outline answer is now bounded whatever the body holds: at most RECORD_CONTEXT_OUTLINE_MAX_ENTRIES (80) headings, and its listing serialized within RECORD_CONTEXT_BODY_MAX_CHARS. Headings are admitted shallowest level first, listed in body order; a cut adds one `outline_truncated` note naming how many headings were left out. Every anchor still reads its section. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzi13yZRqVcp2mGonWK
…he outline cap Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzi13yZRqVcp2mGonWK
📓 Docs Drift Check9 anchor(s) derived from 2 changed package(s); no hand-written page names any of them. What this run could not see
Coarse fallback — 175 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin b0536e12b1d58e720b883582644c8eec07deb887 && git checkout b0536e12b1d58e720b883582644c8eec07deb887
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 93bd45957bc4a43eb54d8fec2b36f1cbef41dc5f 2831c87e9ec67f2993ca9acf63240ed34e069b0d && git checkout -B drift-repro 93bd45957bc4a43eb54d8fec2b36f1cbef41dc5f && git merge --no-ff 2831c87e9ec67f2993ca9acf63240ed34e069b0d
node scripts/docs-audit/affected-docs.mjs --json 93bd45957bc4a43eb54d8fec2b36f1cbef41dc5f |
|
repo:objectstack#3 · os-support-ai · session_01WGufzgv2LZN1W2qSYTZvYs Contract-review-claim: session_01WGufzgv2LZN1W2qSYTZvYs · head 2831c87 · 2026-11-25T05:21Z |
|
repo:objectstack#3 · os-support-ai · session_01WGufzgv2LZN1W2qSYTZvYs Contract reviewServed-tier: Inputs read: card #37178 with every comment (the triage notes, the implementation claim 7152342456, the dev report 7153677982), PR #37222's body, file list and net diff against ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgmentNo must-fix, no should-fix.
Nits (no effect on correctness or the contract):
Implemented-by: VERDICT: PASS |
|
repo:objectstack#3 · os-support-ai · session_01WGufzgv2LZN1W2qSYTZvYs 席位核对 — ACCEPT · repo:objectstack#3 · head 2831c87 · 2026-11-25T05:28ZL1: ACCEPT (L1-w, zone ai-A) No must-fix, no should-fix. The L2 at Read and found right (head 2831c87)
Accepted deviations (nits from the L2; each needs a follow-up card under the nit rule, or a prose-face fix)
Landing to-do
|
|
repo:objectstack#3 · os-support-ai · session_01WGufzi13yZRqVcp2mGonWK Landing · 2026-11-25T05:29Z · ACCEPT 7153812992 at head 2831c87 (L2 PASS 7153800496, same head, nothing open)
State: ready + auto-merge (Tier S). On MERGED, #37178 closes by |
…mit (row 11 contract) (objectstack-ai#37240) <!-- claude-projects-attribution: {"github_login":"os-support-ai"} --> _Requested by **Yibo Wang** · [project thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBEaJzgBWzjWCNjBjkVoeRto)_ repo:objectstack#3 · os-support-ai · session_01WGufzi13yZRqVcp2mGonWK Fixes objectstack-ai#37202 Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:现在用户无感(只改决定记录,不改代码);规则是给 AI 的记录资料包里,关联列表可以只带挑出来的行、按指定顺序排、限定条数(例如只带当前生效的那一版),筛选不增加任何权限,筛选或排序用到提问人不能据以查询的字段(看不到的、值被收起的、只显示掩码的)时整段省略并说明有资料不可见、不点名字段;要等后续实现卡 objectstack-ai#37203(把这三个写法和读取它们的服务一起做出来)合并后才真正生效。 - 为什么做:属于「按记录向 AI 提问」这一大项,你 11 月 25 日已同意关联列表的筛选和排序,这里把它写成成文规则,后面的实现照着做。 - 出错会怎样:规则写错的话,后面的实现会照着错的做,碰到的是写资料包的人和用它提问的人;这次只有文档,撤回这次合并即可。 - 要你做什么:审后由你本人合并(合并即批准);你的原话只说了筛选和排序,其余十处是记录自己补全的决定,已在记录的「超出卡面原话的几点」一节逐条编号列出(第 13 到 22 点,下文英文部分也有一份),不同意哪条可以先划掉再合并。 ## What changes One file under `docs/adr/`: `0160-record-scoped-ai-inquiry.md`, 55 lines added and 13 removed against `main`. No schema, no code, no changeset. This is ADR-0160's second amendment. It records the maintainer's word of 2026-11-25, verbatim: 「related 的筛选和排序 同意」 (the thread of epic objectstack-ai#36996, card objectstack-ai#37202). The first amendment (PR objectstack-ai#37196) had left filter and order on `related` as a separate protocol decision. - **Header.** A second `Amended:` bullet quotes the maintainer and lists what the amendment records. It says the maintainer's word names filter and order and no more, and it names each of the ten additions with its point number. The `Status:` line is byte-identical, so the generated `docs/adr/README.md` does not change and is not in the diff. - **D1.** A `related` entry gains `where`, `orderBy` and `limit`, on the child's own fields only. - `where` uses the platform's object filter form with ten operators (`$eq`, `$ne`, `$in`, `$nin`, `$gt`, `$gte`, `$lt`, `$lte`, `$null`, `$exists`), joined by `$and` / `$or`. A bare value is read as `$eq`. It follows no relation and takes no field-to-field comparand, no `$now` anchor, no formula and no whole `{token}` placeholder. Anything else is refused at parse. - `orderBy` is `{ field, order }[]`. - `limit` is a positive integer, at most the service's row cap for one related list. - The three keys leave "Later work". Placeholders resolved at call time join it. - The keys are declared here and land with their reader in row 11. Until then the schema on `main` refuses them. - **D3.** The filter and the order run inside the caller's one capped child query and grant nothing. A `related` entry whose `where` or `orderBy` names a field the caller cannot query on is dropped whole, with the statement that some material is not visible, and the field is never named. - **D4.** The read set is unchanged: the three keys add no object to it. - **Points that go past the card's words.** Points 5 and 11 are updated. Points 13–22 are new and list every place where the amendment goes past the maintainer's word and the card. - **Implementation split, Consequences.** The split gains row 11 (card objectstack-ai#37203). Consequences counts a fourth protocol addition. ### Round 2, at `1cd00b0d` The contract review of the first head passed with three should-fix findings (comment 7154648352, adopted by the seat in 7154665327). This head answers them. - **S1.** D3 said "a field this caller cannot read". It now says "a field this caller cannot query on" and defines it as every field outside the security service's `getQueryableFields` answer. That takes in the field served masked and the field an agent's ceiling withholds, which the engine's guard also refuses. Both symbols are anchored. - **S2, by the seat's ruling for this text.** A bare value such as `{ is_current: true }` is admitted and read as `$eq`. A comparand that is one whole `{token}` placeholder is refused at parse in v1, beside the `$now` anchor, and placeholders resolved at call time are later work. - **S3.** The `Amended:` bullet no longer says that one sentence goes past the maintainer's word. The record's own section now carries points 13–22, and point 11 covers `where` and `orderBy`. - **Nits applied where they touch this text.** - The refusal that the rule avoids is named as the security plugin's engine middleware, not the data engine. - "The body" says an outline is cut by the body bound or by the entry cap. PR objectstack-ai#37222 has merged, so the entry cap is now anchored on `main`. - A door whose own page cap is lower than a `limit` that parsed cuts the list there, and the cut is stated. - Row 11 may bound the size of a `where` at parse; this record sets no number. - **Not changed, by the review's own word.** The link-field sentence beside the new one still says "that caller's schema hides". The review asks for a follow-up card to carry it. The branch also merged `main` at `6211ddf4`, with no conflict. That brought the note PR objectstack-ai#37209 added to D1 and the outline cap of PR objectstack-ai#37222. ## Tests This PR changes a record only. No test is added or changed, and nothing is ablated. The readings the text rests on were re-taken on `main` at `6211ddf4`. The branch head is `1cd00b0d`, and every local gate below ran on that head. <details><summary>What the schema on main does with the three keys and with the sort direction</summary> A probe parsed a pack through `AiContextSchema` and a sort node through `SortNodeSchema`. It ran with `tsx` from the scratchpad and is not committed. ```text CONTROL (no new key) success = true related[].where: success = false | unrecognized_keys @ related.0: Unrecognized key(s) on a context pack `related` entry: `where`. related[].orderBy: success = false | unrecognized_keys @ related.0: Unrecognized key(s) on a context pack `related` entry: `orderBy`. related[].limit: success = false | unrecognized_keys @ related.0: Unrecognized key(s) on a context pack `related` entry: `limit`. SortNode { field, order }: success = true SortNode { field, direction }: success = false | unrecognized_keys: Unrecognized key(s) on this sort node: `direction`. Did you mean `direction` → `order`? ``` Each message is cut after its first sentence. The control row shows that the probe pack parses without the new keys, so each refusal is the key's own. </details> <details><summary>The anchors this round adds, resolved one by one</summary> `symbolResolutionClass` from `scripts/symbol-anchors.mjs`, asked for each new anchor and for one name that does not exist: ```text declaration packages/spec/src/contracts/security-service.ts#getQueryableFields declaration packages/plugins/plugin-security/src/security-plugin-object-inputs.ts#computeQueryGuardFieldPerms declaration packages/plugins/plugin-security/src/predicate-guard.ts#assertReadableQueryFields declaration packages/spec/src/data/context-tokens.zod.ts#FILTER_TOKEN_WRAPPED_RE declaration packages/core/src/utils/filter-tokens.ts#resolveFilterTokens declaration packages/services/service-record-context/src/body-outline.ts#RECORD_CONTEXT_OUTLINE_MAX_ENTRIES null packages/spec/src/contracts/security-service.ts#noSuchSymbolControl ``` </details> <details><summary>Local gates at 1cd00b0: 21 derived, 21 run, all exit 0</summary> `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` derived the same 21 commands as on the first head. Each exit code was captured before any pipe, and `--ran` reconciled the list: ```text ✓ dispatch-gates --ran: 21 derived famil(ies) accounted for — 21 run, 0 NOT-MEASURED (a DERIVED zero — all 21 recorded an exit code and none of them is 3). ``` The gates that read this file printed: ```text ✅ check-adr-links: 1222 relative link destination(s) under docs/adr/ resolve ✅ check-adr-symbol-anchors: 4199 anchors across 163 records resolve — 1416 symbol (1387 declaration, 29 literal), 2731 file-level, 52 cross-repo, 6 exempt, 96 continuation. adr-index --report: OK — docs/adr/README.md is current, every record parsed, self-test 60 assertions green. check-nul-bytes: OK (scanned 27783 text file(s) -- 27783 tracked, 0 untracked-not-ignored; skipped 101 binary; no raw ASCII control bytes). ``` The other 17 are `check-adr-links --self-test`, `check:adr-anchors`, `check:doc-authoring`, `check:pm-governed-merges`, `check:pm-prior-rulings`, `check:closed-ceremony-text`, `check-closing-keyword-parity` and its self-test, `check-comment-mask-corpus`, `check:cross-package-test-inputs`, `check:ci-filter-parity`, `check:driver-memory-census`, `check:gitlink-declared`, `check:refd-timer-probe`, `check:watch-hint-literal`, `plan-test-core-shards --self-test` and `check:doc-formula-expressions`. `check:doc-formula-expressions` reads the compiled output of `@objectstack/formula` and `@objectstack/lint`. Both were built first under the shared verify lock (`VERDICT command-exit 0`). `node scripts/adr-index.mjs` answered `unchanged docs/adr/README.md (250 lines)`. `node scripts/pm/overlap-check.mjs` answered `VERDICT clean exit 0` before each push. </details> Every family that CI runs is read from this PR's check-runs. None of them is re-run locally. ## Acceptance notes **Governed surface (Tier H).** `docs/adr/**` is governed. The maintainer's merge is the record. No seat readies, queues or arms this PR. **These decisions are listed for the maintainer.** The maintainer's word names filter and order on `related`. Everything below is the record's own settlement, accepted or struck by the merge. Each is a numbered point in the record's "Points that go past the card's words" section, and any one can be struck without touching the rest. | Point | Decision | Where it comes from | |:--|:--|:--| | 13 | `related` takes `limit` as well as filter and order. | The card names it; `get_record`'s `related` already takes one. | | 14 | A `limit` over the row cap is refused at parse. Row 11 declares one number that the schema and the service both read. | The pack's other bounds, and `get_record`'s own `related` limit. | | 15 | `where` admits ten operators, joined by `$and` / `$or`. `$not`, `$between`, `$empty`, the string-match operators, relation conditions, `{ $field }` and `$now` are refused. | The card says "a small operator set" and names none. | | 16 | A bare value is read as `$eq`. | The seat's ruling on review finding S2. | | 17 | A whole `{token}` comparand is refused at parse. Placeholders resolved at call time are later work. | The seat's ruling on review finding S2. | | 18 | `orderBy` is `{ field, order }[]`. | `SortNodeSchema` on `main` refuses `direction` by name. | | 19 | A `where` or `orderBy` field the caller cannot query on drops the section, stated and never named. | Review finding S1. The card says "hidden". | | 20 | A `where` or `orderBy` field the published definition lacks leaves the section out, and the answer states nothing. | The record's rule for author defects. | | 21 | A list cut at its own `limit` is a stated cut. | The record's rule that every cut is stated. | | 22 | D3, "The body", names the cap on an outline's entries. | Not about `related`: carried from the review of PR objectstack-ai#37222, nit N5. | **Sections touched beyond the card's list, all in the one claimed file:** the author-defects paragraph and "Later work" in D1, "The body" in D3, the "Points" section, the intro and the two paragraphs under the Implementation split table, and one line of Consequences. **Seen and not changed here** (read on `main`, not exercised through a public door, so not filed): - Row 5's service still refuses the whole call when a `related` child is not served to this caller. The first amendment says that child is left out and the answer says so. - The link-field rule in D3 still says "that caller's schema hides". A link field that the schema shows and the caller cannot query on would reach the engine's guard, which refuses the whole call. The review asks for a follow-up card. - Card objectstack-ai#37203's example spells the sort direction `direction`, and its item 3 says "hidden". Both now differ from the record. - The `ai_context` schema's guidance text for a stray `filter` key says a related list reads every child row the caller may read. Row 11 has to reword it. ## Verification Read first, by risk. All three are in `docs/adr/0160-record-scoped-ai-inquiry.md`: 1. **D3, "Field level", the bullet "The hidden field is one the pack uses structurally".** This is the disclosure rule: which callers lose the section, and what the answer may say. Round 2 rewrote its middle. 2. **D1, the `where` bullet under "Filter, order and limit on a related list".** This is the contract row 11 implements: the operator set, the bare value, and the comparands refused at parse. 3. **"Points that go past the card's words", points 13–22, and the header's second `Amended:` bullet.** They say which parts are the maintainer's word and which are the record's own. Two-minute check: run `pnpm check:adr-symbol-anchors`. It should exit 0 and print a line that starts `✅ check-adr-symbol-anchors:`. That line means every symbol the text cites is declared at the path the text names. At this head it counts 4199 anchors across 163 records. --- _Generated by [Claude Code](https://claude.ai/code/session_01WGufzi13yZRqVcp2mGonWK)_ <!-- signed: repo:objectstack#3 · os-support-ai · session_01WGufzi13yZRqVcp2mGonWK --> --------- Co-authored-by: Claude <noreply@anthropic.com>
…outline in pages (outlineFrom / outlineNext) (objectstack-ai#37484) Fixes objectstack-ai#37233 Clause-②: yes (widening) Metadata-protocol: added ## 维护者速读 - 用户能看到什么变化:外接 AI 读一条正文很长的记录时,目录超过一页上限的部分可以分页继续列出,每个章节都能读到;此前如果几百个标题都在同一层,第 80 个之后的章节 AI 根本读不到。 - 为什么做:记录级 AI 问答专题(资料包读取工具)的后续收尾,补上目录截断后剩余章节无法到达的缺口,并改正一句会误导 AI 的截断提示。 - 出错会怎样:最坏是 AI 读长文时多翻一页或少列几个标题,读到的内容仍受原有长度上限和权限约束;可以直接撤回本次改动。 - 要你做的:无。 ## What changes ADR-0160 D3 "The body"; L1 ACCEPT 7153812992 on PR objectstack-ai#37222, nit N2 (this card), N3, N4. - **The outline comes in pages** (`boundedOutline(headings, from)`, `body-outline.ts`). The pages run through every heading in ONE order — shallowest level first, body order within a level — and a page takes that order from `from` until the next heading would pass either existing bound (80 entries, 8,000 serialized characters); each page lists its headings in body order. Page 1 is today's outline, bar the N3 case below. Every heading is on exactly one page, so following the continuation from page 1 lists every heading with the anchor `headingsOf` gives it. One mechanism serves both cuts: a flat body's pages are runs of it in body order; a nested body's first page is its top levels and later pages carry the deeper headings (which matters too: a top section past the body bound is itself cut, so its sub-headings past the cut were unreachable before as well). - **Input `outlineFrom`, output `body.outlineNext`** (`record-context-tools.zod.ts`). `outlineNext` is present only when a heading remains that a later page lists; pass it as `outlineFrom`. `outlineFrom` 0 is page 1. An `outlineFrom` past the last page, or on a body that is no outline (carried whole, absent from the pack, withheld from the caller), is ONE answer, `RESOURCE_NOT_FOUND` 404, as an unresolved `anchor` is. `anchor` with `outlineFrom` is refused `VALIDATION_ERROR` 400 at step 1, before any read. - **The `outline_truncated` sentence, en and zh-Hans** (`sentences.ts`), now says how many headings this page lists, how many it does not, that pages run shallowest levels first then body order, and the `outlineFrom` that lists the next page (or that no later page lists more). The clause "A listed section's text includes the headings under it" is gone: in a flat cut nothing left out sits under a listed section. The sentence carries numbers only, never an anchor (an anchor is record text, and a note never carries record text) — which is why the cursor is a position and not an anchor. - **N3, revisited because the paging made it cheap.** A heading whose entry alone passes the character bound fits no page. Without a change it would end the pages (the page that must start with it lists nothing), so the pages now pass over it and the note counts it ("1 heading is too long for any page to list, so its anchor is not given" / "K headings are too long ..."). As a side effect one such heading no longer empties page 1. A body whose ONLY headings are such headings is still carried to the bound and marked truncated, as before. Trade-off stated: such a heading (about 3,950 characters or more of heading text) gets no anchor; in a nested body its text is still inside its parent's section. - **N4**: no change needed (the changeset it named has merged). - Tool description: names `outlineNext` / `outlineFrom` beside `anchor`. - **The `body_outline` note, en and zh-Hans, on every page** now says to read a section with the same objectName, recordId and context, plus the anchor and no `outlineFrom`. Before, it said "the same arguments", and on a page reached through `outlineFrom` those arguments plus an anchor are the pair this PR refuses (review S1). - The MCP doors needed no code: both pass the input through whole, and the `/mcp` door's registration validates against the spec's `GetRecordContextInputSchema`, so the key is admitted there by the spec change alone. The real-kernel parity cases below prove both doors carry it. ### Design, and the alternative weighed Continuation (chosen) vs listing every omitted heading's anchor compactly: a compact list is still O(headings) in one answer, so for a large enough body it passes the same bound and needs a cut of its own; the continuation keeps every answer within the existing bounds however big the body, with one mechanism for flat and nested cuts. Cursor: a position in the page order, not an anchor, because the note that tells the model where to continue may not carry record text, and an anchor is derived from heading text. ### Declaration `Metadata-protocol: added`, `@objectstack/spec` graded `minor` (PM ruling, option A, on this PR's open question): the spec's authorable-surface ledger records `GetRecordContextInput:outlineFrom` and `RecordContextBody:outlineNext` as entered keys, and Check Changeset reads that shard as a metadata-protocol addition (precedent: objectstack-ai#37140, objectstack-ai#37354). `@objectstack/service-record-context` stays `patch`. ### ADR text this will need (governed, not edited here) - D4 "Definition", the input line `{ objectName: string, recordId: string, context?: string, anchor?: string }` gains `outlineFrom?: integer` (the output's body gains `outlineNext`). - D3 "The body", the sentence "A longer body is carried as an outline: its headings in order, each with an `anchor`." needs: an outline past its bounds comes in pages, continued by `outlineFrom`, every heading listed on one page (bar a heading too long to list by itself, stated). Carried by objectstack-ai#37490, which should also say that the cursor is a position in the current body, so "exactly one page" holds for one state of the body. ## Tests See Verification for the commands and readings. - `body-outline.test.ts`: a flat body of 300 headings pages as 80/80/80/60 and the pages together are exactly the body's headings in order; a nested body's page 1 holds every top heading and later pages only deeper ones, each page in body order, union = all headings, no duplicates; the character bound before the entry cap; an over-long shallowest heading is on no page, counted, and does not empty page 1. - `record-context-tools.test.ts` (executor): **the acceptance pin** — a body of 300 headings at one level, every page walked by the `outlineNext` the tool gave, all 300 anchors issued once, every section read by its issued anchor and equal to its text, every answer parsing against `GetRecordContextOutputSchema` and within the bounds; the nested cut whose top section is itself cut; the `outline_truncated` sentence for a flat cut AND a nested cut in en AND zh-Hans (counts, `outlineFrom N`, no record text, the old clause absent); the last page; `outlineFrom: 0`; the one 404 answer (past the end / body whole / no body / withheld body); `anchor` + `outlineFrom` refused before any read; negative / fractional / string refused at parse. - `record-context-tools.zod.test.ts` (spec, new): admits and refuses `outlineFrom` and `outlineNext`, asserting zod's issue code and path; the JSON Schema projection carries `outlineFrom` as an integer of at least 0. - `mcp-record-context-tools-bridge.test.ts` (runtime, real kernel): page 2 over both doors, byte-equal, starts at `clause-(N+1)` (a door that dropped the key would answer page 1), and its anchor reads its section; `outlineFrom` on a body carried whole is the same coded 404 on both doors. - `mcp-record-context-tools.test.ts`: the registration's input property list gains `outlineFrom`. ## Acceptance notes - Acceptance bullet 1 (300 same-level headings, every section reached by issued anchors, each answer bounded): pinned in `record-context-tools.test.ts`, "a body of 300 headings at one level". - Acceptance bullet 2 (the note sentence true for nested and flat cuts, both pinned): "the cut note is true for a flat cut and for a nested cut, in en and zh-Hans". - Re-reading `outlineFrom` against a body edited between calls simply answers the page at that position of the current body; anchors on it are the current body's, so nothing stale is served. ## Verification Read first (by risk): `packages/services/service-record-context/src/body-outline.ts` (`boundedOutline`: the skip of an unlistable heading and where `next` is set), `src/record-context-tools.ts` (the body block: the one 404 for an outline page that does not start where asked), `src/sentences.ts` (`outlineTruncated`). Two-minute check: `pnpm --filter @objectstack/service-record-context exec vitest run --maxWorkers=2 src/__tests__/record-context-tools.test.ts -t "300 headings"` — one test passes; it walks four pages and reads 300 sections. All readings at head `5f6f72fd82540c66a716be2a3a874bbd89e58bbd`. <details><summary>Suites of every touched package (under the verify lock: VERDICT command-exit 0)</summary> - Build of the three closures exit 0; `pnpm --filter @objectstack/spec check:generated`: all 14 generated artifacts up to date. - `@objectstack/service-record-context` test: Test Files 4 passed (4), Tests 139 passed (139); typecheck exit 0. - `@objectstack/mcp` test: Test Files 85 passed (85), Tests 1521 passed (1521); typecheck exit 0. - `@objectstack/runtime` test (`--project local`): Test Files 649 passed (649), Tests 12061 passed, 25 skipped (12086); typecheck exit 0. - `@objectstack/spec` test: Test Files 899 passed (899), Tests 28494 passed, 1 todo (28495); typecheck exit 0. </details> <details><summary>Derived gate families (dispatch-gates --commands, 111)</summary> - 109 exit 0 (11 of them re-run after the build, having first refused with no built output to read). - NOT MEASURED, `check:skill-examples` and `check:dual-build-cjs-loads`: PREREQUISITE NOT MET, they read built output of packages this diff does not touch. CI's Lint and Repo Gates measures both. </details> <details><summary>Review S1 pin, and the ablation of the first round</summary> - S1: "a section listed on page 2 is read exactly as that page's body_outline note says" reads page 2's first anchor with the record's arguments, the anchor and no `outlineFrom` (en and zh-Hans), and gets the section. The control, page 2's arguments plus the anchor, is refused `VALIDATION_ERROR` 400. - Ablation (first round, unchanged code path): `for (let at = from; ...` replaced by `for (let at = 0; ...` in `boundedOutline` turned the 300-heading acceptance pin red (24080 anchors issued, not 300), along with three other executor pins; restored blob equals HEAD. </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01Utp6CbeF2saT6wUBV4E9uc)_ <!-- signed: repo:objectstack#5 · os-bill · session_01Utp6CbeF2saT6wUBV4E9uc --> --------- Co-authored-by: Claude <noreply@anthropic.com>
Requested by Yibo Wang · project thread
repo:objectstack#3 · os-support-ai · session_01WGufzi13yZRqVcp2mGonWK
Fixes #37178
Clause-②: yes (widening)
Metadata-protocol: none
维护者速读
What changes
get_record_contextanswers a long body with an outline of its headings. The outline had no cap: a long body that is almost all headings made an outline as big as the body, which undid the 8000-character body bound. The outline is now bounded whatever the body holds.RECORD_CONTEXT_OUTLINE_MAX_ENTRIES = 80, a service constant besideRECORD_CONTEXT_BODY_MAX_CHARS(exported from the package index). An outline lists at most 80 headings, AND its listing, serialized, stays withinRECORD_CONTEXT_BODY_MAX_CHARS. The entry cap alone does not meet the card's acceptance ("bounded by the constant, whatever the body holds"): a heading's text, and the anchor derived from it, is as long as the author makes it, so 80 entries of 5,000-character headings would still be an unbounded answer. The character bound closes that; it reuses the body bound instead of coining a third number.boundedOutlineinbody-outline.ts): headings are admitted shallowest level first, in body order within a level, until the next would pass either bound, and are listed in body order. So a cut leaves out the deepest headings first, and a listed section's text holds the headings left out under it (a section runs to the next heading of the same or a higher level). For a body of many headings at one level this is a plain prefix cut.outline_truncated(newRecordContextNoteKindvalue, docblock updated). It sits besidebody_outline. Its sentence, inenandzh-Hans, says how many headings are listed, how many the body has and how many are not listed. It carries no record text.truncated, with thebody_truncatednote, the same as a long body with no headings.outlinefield's.describe()now says the outline is held to the service's bounds and a cut is stated by anoutline_truncatednote. The reference page is regenerated (gen:docs).Why a new note kind (Clause-②
yes), not the existingtruncatedmark plusbody_truncatedI checked this as the claim asked. The existing pieces cannot carry the cut honestly:
RecordContextBody.truncatedis described as "Present whentextwas cut at the bound". An outline cut has notext, so setting it there would contradict its published description.body_truncatedis documented as "the body (or a section) was cut at the bound", a character cut of text. Using it for an entry cut would quietly change what a published kind means. An added enum value is visible to every consumer; a changed meaning is not.related_truncatedcarries its cap.So the published output enum widens by one value:
Clause-②: yes (widening),Metadata-protocol: none(nothing an author writes changes), changesets atpatch. Under the claim, this owes the L2 at CONTRACT_REVIEW_TIER. Repo grep: no consumer switches over the note kinds exhaustively (the MCP and runtime bridges pass notes through).How the number was chosen
I measured the outline reader on real long documents: the 543 Markdown files of this repository (
content/docs,docs,skills) that are past the 8000-character body bound and have headings, at a33691e.80 entries × about 95 chars is about 7,600 chars: an outline answer the size of the body bound, as the claim asked. With both bounds applied (
boundedOutline), 527 of the 543 are listed uncut, 4 of the 16 cut ones are cut by the character bound before the entry cap, none gets an empty outline, and the largest outline serializes to 7,994 chars.Tests
The new pins go into the package's two existing test files as top-level
describeblocks, under the shared-harness rule in AGENTS.md: the executor pins sit beside thefake-doorharness, and the reader pins beside the outline reader's own pins.record-context-tools.test.ts:RECORD_CONTEXT_OUTLINE_MAX_ENTRIESpinned at 80 in the constants block. A new block, "the outline bound", pins four things:['body_outline', 'outline_truncated'], and the cut note names 220 and 300 and carries no record text;zh-CN);body-outline.test.ts: a new block, "the outline is bounded whatever the body holds", pinsboundedOutlinedirectly:Test, typecheck and ablation readings
pnpm --filter @objectstack/service-record-context test: Test Files 2 passed (2), Tests 71 passed (71).typecheck(tsc --noEmitpluscheck:test-typecheck): OK, 0 errors. LockVERDICT command-exit 0.pnpm --filter @objectstack/spec exec vitest run src/ai: 16 files, 448 tests passed.breakinboundedOutline, viascripts/ablation-replace.mjs: anchor 1 → 0, blob f1e3b8c8 → 00d35ea8. Result: 5 failed, 66 passed. Restored, blob equal to HEAD,git diff HEADempty.break: 3 failed, 68 passed. Restored the same way. The tests resolve the package's ownsrc(nodistin the path), so no rebuild leg applies.Derived gate union at 2831c87
node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstackderived 110 commands at 2831c87. All 110 were run, each exit code captured before any pipe.check:doc-formula-expressions,check:doc-security-posture,check:skill-examples,check:docs-transcript-drift,check:lean-entry-closure. After building formula, lint, objectql, client-react and their closures, all five re-ran with exit 0.check-plugin-teardown-shape --self-testneeds a full clone; it is checker health only.check:dual-build-cjs-loadsneeds a fullpnpm build.--ranreconciliation: "110 derived famil(ies) accounted for — 108 run, 2 NOT-MEASURED (2 DERIVED from a recorded exit 3)".pnpm --filter @objectstack/spec check:generatedaftergen:docs: "All 14 generated artifacts are up to date".Acceptance notes
.describe()and the new kind's docblock are spec prose in the claimed file. They state only what this PR implements. No ADR-0160 ruling is changed: D3 says every cut is stated in the notes and the bounds are service constants pinned by test.pnpm --filter @objectstack/mcp exec vitest run src/mcp-record-context-tools.test.tspassed, 10/10. No consumer reads the note kinds exhaustively. The runtime bridge test is left to CI's Test Core.Verification
Read first:
packages/services/service-record-context/src/body-outline.ts,boundedOutline: the admission order and the twobreaks.packages/services/service-record-context/src/record-context-tools.ts, the outline branch: thelistedguard and the fallback to truncated text when nothing can be listed.packages/spec/src/ai/record-context-tools.zod.ts: the newoutline_truncatedvalue.Two-minute check:
pnpm --filter @objectstack/service-record-context exec vitest run -t "outline bound"should show 4 tests passed, including "an unlisted heading's anchor reads its section".Generated by Claude Code