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, |
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