Repository navigation
feat(service-record-context): get_record_context lists a long body's outline in pages (outlineFrom / outlineNext) - #37484
Conversation
…ne (outlineFrom / outlineNext) WIP: tests follow. Claude-Session: https://claude.ai/code/session_01Utp6CbeF2saT6wUBV4E9uc Co-authored-by: Claude <noreply@anthropic.com>
… outlineFrom on both doors Claude-Session: https://claude.ai/code/session_01Utp6CbeF2saT6wUBV4E9uc Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Utp6CbeF2saT6wUBV4E9uc Co-authored-by: Claude <noreply@anthropic.com>
…r advances fails Claude-Session: https://claude.ai/code/session_01Utp6CbeF2saT6wUBV4E9uc Co-authored-by: Claude <noreply@anthropic.com>
… outlineFrom / outlineNext Claude-Session: https://claude.ai/code/session_01Utp6CbeF2saT6wUBV4E9uc Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Utp6CbeF2saT6wUBV4E9uc Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 2 package(s): 11 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 4 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 176 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 47b38ecea244df88bc7c9eb53aa01ab1051a4bb1 && git checkout 47b38ecea244df88bc7c9eb53aa01ab1051a4bb1
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin b7bddeb91029a324cfe89c666fb62dd894fd730e 5f6f72fd82540c66a716be2a3a874bbd89e58bbd && git checkout -B drift-repro b7bddeb91029a324cfe89c666fb62dd894fd730e && git merge --no-ff 5f6f72fd82540c66a716be2a3a874bbd89e58bbd
node scripts/docs-audit/affected-docs.mjs --json b7bddeb91029a324cfe89c666fb62dd894fd730e
|
…l added, spec minor Claude-Session: https://claude.ai/code/session_01Utp6CbeF2saT6wUBV4E9uc Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X Contract-review-claim: session_01Utp6CYtTDvfPQDzMbZnN5X · head 6489315 · 2026-11-26T09:09Z |
|
repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X Contract reviewServed-tier: PR #37484, card #37233 (epic #36996). Read: the card body and its 7 comments (claim 7183671948, reports 7186736579 and 7187454759, claim amendment 7186766469), the PR body and its 2 comments, the net diff against ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgment
S1 (should-fix) — On every outline page the executor still pushes the N1 (nit) — The cursor is a position in the current body's order. If the body is edited between two page calls, the walk can skip or repeat headings with no signal; anchors on each page are still current. "Each heading is on exactly one page" is true for one state of the body. The PR body says so; the spec N2 (nit) — The N3 (nit) — Loose wording. Spec N4 (nit) — The PR body names the ADR carrier as "the ADR-0160 amendment of #37202 or a later one"; the carrier is #37490. Prose face: point the PR body at #37490. N5 (nit) — Delta report 7187454759 gives N6 (nit) — The failed No must-fix. One should-fix (S1), which earns a delta review of its fix. Implemented-by: VERDICT: PASS |
|
repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X 席位核对Head-sha:
|
…age names a section read without outlineFrom; singular for one too-long heading Claude-Session: https://claude.ai/code/session_01Utp6CbeF2saT6wUBV4E9uc Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Utp6CbeF2saT6wUBV4E9uc Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X Contract reviewServed-tier: Delta round on PR #37484, card #37233 (epic #36996), and a whole record for this head. The earlier record is 7187652688 on The delta holds no merge of ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgment
Earlier findings on this head:
New on this head: N7 (nit) — The changeset body does not mention that the No must-fix, no should-fix. Implemented-by: VERDICT: PASS |
|
repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X 席位核对Head-sha:
|
|
repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X Security label: |
|
repo:objectstack#5 · os-bill · session_01Utp6CbeF2saT6wUBV4E9uc Landing: ACCEPT 7190047844 (delta contract record 7190027212, PASS) at head
Status: ready + auto-merge (merge queue). On MERGED, #37233 closes by |
|
repo:objectstack#5 · os-bill · session_01Utp6CbeF2saT6wUBV4E9uc Correction to landing comment 7190106730: at the stroke two runs were still in progress on the head, |
… pages (outlineFrom / outlineNext) (objectstack-ai#37573) <!-- claude-projects-attribution: {"github_login":"os-bill"} --> _Requested by **Bill** · [project thread](https://claude.ai/code/project/chan_016iMXWSZDzqWRWvWzdNo8wg?thread=cmsg_016iMXWSZDzqWRWvWzdNo8wgKJcxVQvtK7UsENd5xsHrZe)_ repo:objectstack#5 · os-bill · session_01Utp6CaY7QjyzmyWTJGfguK Fixes objectstack-ai#37490 Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户无感:这是一条架构记录的第四次修订,只改文字。把已经上线的「长正文目录分页」写进记录,包括怎么翻页、每页都带哪些提示、以及翻页中途正文被改时可能漏列或重列标题。 - 为什么做:记录 AI 问询专题里,资料包读取工具的目录分页已经合并,但架构记录还停在「目录只有一页」的说法,后续施工和审阅的人会读到过时的约定。 - 出错会怎样:不改代码、不改发布包;合并后若发现措辞有误,再开一次修订即可改回。 - 要你做什么:这是受管的架构记录,需要你批准后才能合并。 ## What changes One file, `docs/adr/0160-record-scoped-ai-inquiry.md` (+22 / −3). It is the fourth amendment of the record. It writes down what PR objectstack-ai#37484 put on `main` (merge commit `59571b2f07`, for card objectstack-ai#37233) and carries the scope note on this card (comment 7187692455, N1 of contract review 7187652688). Every sentence was read against `body-outline.ts`, `record-context-tools.ts`, `sentences.ts` and `record-context-tools.zod.ts` on `main` at `41164656`. - **Status line and amendment log**: the status line names the second amendment date; the header's `Amended` list gains a fourth entry naming this card, PR objectstack-ai#37484, the readings commit and the three things recorded. It says in words that the amendment rests on no ruling of its own. - **D3, a new paragraph "Outline pages"**, placed after "The body" (whose text stands and is not restated): 1. The two outline bounds bound one answer, not which headings can be listed; an outline past either comes in pages (`boundedOutline`). 2. The order: shallowest level first, body order within a level; each page lists its own headings in body order. 3. The continuation: a page that leaves headings for a later page carries `outlineNext` on its body, and that number as `outlineFrom` lists the next page. An `anchor` reads its section whichever page issued it. 4. Coverage: within one state of the body, every heading is on exactly one page with its anchor. The exception is a heading whose entry alone passes the body bound: no page lists it, no anchor is issued for it, and the cut statement counts it. 5. **The per-body-state qualifier (N1)**: `outlineFrom` is a position in the page order of the body as the call reads it, and the tool keeps nothing between calls. An edit between two page calls can make the walk skip a heading or list one twice, with no signal; the anchors on each page stay current. 6. The notes on every page: the outline statement on each page, and the cut statement on each page that does not list every heading. The cut statement carries counts and a position, never an anchor. 7. A page that does not exist: an `outlineFrom` above 0 with no heading left to list from it gets one `RESOURCE_NOT_FOUND` (404) answer whatever the reason, so `outlineFrom`, like `anchor`, cannot show that a pack has a body the caller's schema hides. - **D4 "Definition"**: the input row gains `outlineFrom?: integer` and the exclusion: a call that names both `anchor` and `outlineFrom` is refused `VALIDATION_ERROR` (400) in step 1, before any gate is judged and any record is read. The output row gains `outlineNext` on the body. - **Points that go past the card's words** gains the fourth amendment's introduction and **point 24**: paging stays on the same tool, and the cursor is a position and not an anchor because a note may carry no record text. The alternative it names is the one PR objectstack-ai#37484 weighed. Nothing else in the record changes: "The body" paragraph, the TL;DR, the implementation split and every other decision stand as they were. **Read first** (by risk): the bullet "One state of the body" in D3 "Outline pages" (the N1 qualifier), then "A page that does not exist" (the list of reasons behind the one 404), then the D4 input row (the exclusion and where it is refused). **Two-minute verification**: `pnpm check:adr-symbol-anchors` — expected: green, with the new `body-outline.ts` symbol anchor `boundedOutline` found. ## Tests n/a — `docs/adr/**` text; no package, test or schema is touched. The verification is the derived gate set below. ## Acceptance notes - **Acceptance bullet 1** (the sentences match `record-context-tools.zod.ts` and `body-outline.ts` on `main`): `outlineFrom` is `z.number().int().min(0).optional()`, written as `outlineFrom?: integer` with "`outlineFrom` 0 is the first page"; `outlineNext` is present only when a heading remains that a later page lists; the page order and the skipped over-long heading are `boundedOutline`'s; the 400 and the 404 are the executor's (`executeGetRecordContext`, step 1 and the body block). - **Acceptance bullet 2** (the amendment log cites this card): the fourth `Amended` entry and the introduction of point 24. - **Acceptance bullet 3**: `Clause-②: no`, `Metadata-protocol: none`, as claimed. - **Where the text differs from the card's draft sentences, on purpose.** The card says "`outlineFrom` past the last page, or on a body that is no outline" is the 404. `main` answers the first page for `outlineFrom: 0` on any body, so the text says "an `outlineFrom` above 0 with no heading left to list from it". It does not say "a position that starts no page": `main` answers a page from any position that still has a heading to list, whether or not an earlier answer issued that position, and the text neither promises nor forbids that. The card says "every heading is listed on exactly one page"; the text scopes that to one state of the body, as the scope note asks. - **One structural choice.** The paging text is a new paragraph after "The body", and "The body" is left byte-identical, so the amendment adds to D3 and rewrites nothing there. One phrase of "The body" now reads slightly narrow beside it ("the most headings one outline lists" is, since the paging, the most one page lists); the first sentence of "Outline pages" says so. `carrier: none`. - **An observation, not acted on.** D4's input row says "with the record tools' aliases for the first two"; the schema on `main` also aliases `pack` and `contextName` to `context`, and `section` to `anchor`. That sentence predates this card and is outside its claim. `carrier: none`. - **Tier H by path.** `docs/adr/**` is governed whatever the body says. The `Rule-change:` line is left out: the diff does not touch `.claude/**`. - **No changeset.** `docs/adr/**` is on the fast track (not published); `skip-changeset` is declared with this create. ## Verification - Two commits. `98e42a52` is the amendment; `a3f1e40a` (+3 / −3 inside the new paragraph) makes three of its sentences exact after a second reading against the executor: when a page call is refused, what the cut statement carries, and that an edit between two page calls can also end in that refusal. - Gate list derived on the final head `a3f1e40a`: `node scripts/pm/dispatch-gates.mjs --commands` → 21 commands (1 path vs merge base `41164656`). - All 21 exited 0 on `a3f1e40a`, each exit code captured before any pipe. On the first head, `check:doc-formula-expressions` had exited 3 (PREREQUISITE NOT MET, no built output) until `@objectstack/formula...` and `@objectstack/lint...` were built under the verify lock (VERDICT command-exit 0). - `--ran` reconciliation on `a3f1e40a`: `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)`. - `dispatch-gates --tier`: `docs/adr/**` is the mandatory contract tier; changed lines 25 vs the human-merge threshold 3000: under. - `overlap-check --branch=HEAD` before each push: `VERDICT clean exit 0` against `origin/main` at `4116465625` and 0 PR heads. - CI-owned families (type-check lanes, artifact rosters, the always-runs tail) are this PR's check-runs. <details><summary>Local gates (21, each exit 0 on a3f1e40)</summary> ```text node scripts/check-adr-links.mjs [+ --self-test] node scripts/check-closing-keyword-parity.mjs [+ --self-test] node scripts/check-comment-mask-corpus.mjs node scripts/ci/plan-test-core-shards.mjs --self-test pnpm --filter @objectstack/lint run check:doc-formula-expressions pnpm check:adr-anchors · check:adr-index · check:adr-symbol-anchors pnpm check:ci-filter-parity · check:closed-ceremony-text · check:cross-package-test-inputs pnpm check:doc-authoring · check:driver-memory-census · check:gitlink-declared pnpm check:nul-bytes · check:pm-governed-merges · check:pm-prior-rulings pnpm check:refd-timer-probe · check:watch-hint-literal ``` </details> 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01Utp6CaY7QjyzmyWTJGfguK <!-- signed: repo:objectstack#5 · os-bill · session_01Utp6CaY7QjyzmyWTJGfguK --> --------- Co-authored-by: Claude <noreply@anthropic.com>
Fixes #37233
Clause-②: yes (widening)
Metadata-protocol: added
维护者速读
What changes
ADR-0160 D3 "The body"; L1 ACCEPT 7153812992 on PR #37222, nit N2 (this card), N3, N4.
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 fromfromuntil 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 anchorheadingsOfgives 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).outlineFrom, outputbody.outlineNext(record-context-tools.zod.ts).outlineNextis present only when a heading remains that a later page lists; pass it asoutlineFrom.outlineFrom0 is page 1. AnoutlineFrompast 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_FOUND404, as an unresolvedanchoris.anchorwithoutlineFromis refusedVALIDATION_ERROR400 at step 1, before any read.outline_truncatedsentence, 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 theoutlineFromthat 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.outlineNext/outlineFrombesideanchor.body_outlinenote, en and zh-Hans, on every page now says to read a section with the same objectName, recordId and context, plus the anchor and nooutlineFrom. Before, it said "the same arguments", and on a page reached throughoutlineFromthose arguments plus an anchor are the pair this PR refuses (review S1)./mcpdoor's registration validates against the spec'sGetRecordContextInputSchema, 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/specgradedminor(PM ruling, option A, on this PR's open question): the spec's authorable-surface ledger recordsGetRecordContextInput:outlineFromandRecordContextBody:outlineNextas entered keys, and Check Changeset reads that shard as a metadata-protocol addition (precedent: #37140, #37354).@objectstack/service-record-contextstayspatch.ADR text this will need (governed, not edited here)
{ objectName: string, recordId: string, context?: string, anchor?: string }gainsoutlineFrom?: integer(the output's body gainsoutlineNext).anchor." needs: an outline past its bounds comes in pages, continued byoutlineFrom, every heading listed on one page (bar a heading too long to list by itself, stated). Carried by 37233 跟进:ADR-0160 补写目录分页(outlineFrom / outlineNext) #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 theoutlineNextthe tool gave, all 300 anchors issued once, every section read by its issued anchor and equal to its text, every answer parsing againstGetRecordContextOutputSchemaand within the bounds; the nested cut whose top section is itself cut; theoutline_truncatedsentence 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+outlineFromrefused before any read; negative / fractional / string refused at parse.record-context-tools.zod.test.ts(spec, new): admits and refusesoutlineFromandoutlineNext, asserting zod's issue code and path; the JSON Schema projection carriesoutlineFromas an integer of at least 0.mcp-record-context-tools-bridge.test.ts(runtime, real kernel): page 2 over both doors, byte-equal, starts atclause-(N+1)(a door that dropped the key would answer page 1), and its anchor reads its section;outlineFromon a body carried whole is the same coded 404 on both doors.mcp-record-context-tools.test.ts: the registration's input property list gainsoutlineFrom.Acceptance notes
record-context-tools.test.ts, "a body of 300 headings at one level".outlineFromagainst 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 wherenextis 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.Suites of every touched package (under the verify lock: VERDICT command-exit 0)
pnpm --filter @objectstack/spec check:generated: all 14 generated artifacts up to date.@objectstack/service-record-contexttest: Test Files 4 passed (4), Tests 139 passed (139); typecheck exit 0.@objectstack/mcptest: Test Files 85 passed (85), Tests 1521 passed (1521); typecheck exit 0.@objectstack/runtimetest (--project local): Test Files 649 passed (649), Tests 12061 passed, 25 skipped (12086); typecheck exit 0.@objectstack/spectest: Test Files 899 passed (899), Tests 28494 passed, 1 todo (28495); typecheck exit 0.Derived gate families (dispatch-gates --commands, 111)
check:skill-examplesandcheck: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.Review S1 pin, and the ablation of the first round
outlineFrom(en and zh-Hans), and gets the section. The control, page 2's arguments plus the anchor, is refusedVALIDATION_ERROR400.for (let at = from; ...replaced byfor (let at = 0; ...inboundedOutlineturned the 300-heading acceptance pin red (24080 anchors issued, not 300), along with three other executor pins; restored blob equals HEAD.Generated by Claude Code