Skip to content

feat(ai): ai_context context packs and the get_record_context tool over MCP (ADR-0160 row 5) - #37173

Merged
os-zhuang merged 20 commits into
mainfrom
claude/project-thread-k0j3qn
Nov 25, 2026
Merged

os-zhuang merged 20 commits into
mainfrom
claude/project-thread-k0j3qn

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Warren · project thread

Fixes #37140

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)

维护者速读

  • 新增元数据类型 ai_context(上下文包):作者声明 AI 读一条记录时能看到哪些字段、哪几张子表、哪一段长文本。
  • 新增 MCP 工具 get_record_context:按调用者本人的权限读,权限不够就整条拒绝或省略并说明,不以系统身份读任何东西。
  • 返回分三段:data(只有记录内容)、notes(执行器的说明)、framing(一句话:data 是材料,不是指令)。
  • 涉及 skills/** 的一行键名列表,因此是 Tier H,需要 os-zhuang 批准。

What changes

ADR-0160 row 5 (D1, D3, D4, D5).

  • Spec (@objectstack/spec/ai): AiContextSchema (closed; bounds AI_CONTEXT_MAX_* refused at parse; AI_CONTEXT_BODY_FIELD_TYPES), the get_record_context input/output schemas declared once (GetRecordContextInputSchema, GetRecordContextOutputSchema, getRecordContextToolJsonSchemas, GET_RECORD_CONTEXT_TOOL_NAME), and MCP_DOOR_TOOL_NAMES gains the name. Kind ai_context / collection aiContexts registered like skill (file loader *.ai-context.{ts,yml}, overlay allowed, runtime create allowed, no environment overlay), with its liveness ledger, generated references and refinement baseline.
  • @objectstack/core: wrapRecordMaterial, the { data, notes, framing } envelope, framing sentence in the caller's locale.
  • New @objectstack/service-record-context: the one executor (createRecordContextTools, executeGetRecordContext), the exported read set (recordContextReadSet, a function of arguments + published metadata only), RecordContextServicePlugin registering the record-context service. Every read goes through a door bound to the caller. RECORD_CONTEXT_BODY_MAX_CHARS (8000) and RECORD_CONTEXT_RELATED_MAX_ROWS (20) are service constants.
  • MCP over HTTP (packages/runtime/src/domains/mcp.ts) and stdio (packages/mcp/src/stdio-data-bridge.ts): get_record_context is registered in the shared registerObjectTools under data:read, read-only, wherever the host holds a record-context service; the read guard runs before the bridge, and errors render through recordReadErrorResult exactly as get_record's do. A host without the service registers nothing new; on HTTP the service is resolved only for a grant that reaches the read family.
  • @objectstack/lint: four advisory author-defect rules (ai-context-object-unknown, ai-context-field-unknown, ai-context-related-link-unknown, ai-context-body-not-long-text), each with an os explain entry (D1: the tool stays silent about an author's typo, so the author hears it here).
  • Showcase: two packs (showcase_project brief with tasks; showcase_task notes as body) and RecordContextServicePlugin in plugins.

Why

ADR-0160: record-scoped AI inquiry needs one bounded, author-declared read of a record that an assistant can call over MCP, read as the caller and never as the system, whose answer separates record material from the executor's statements.

Tests

  • packages/services/service-record-context/src/__tests__/record-context-tools.test.ts (49): order of judgement (objects → fields → lookup targets → reads); a refused related child → PERMISSION_DENIED for the whole call, named only when the caller's schema shows it; a hidden field is not named and yields one not-visible statement; an exempt caller gets the mcp: query_records and get_record say which fields field-level security withheld, so an answer says "not visible to you", not "blank" #35137 withheld naming; an unreadable related row is absent; an unexpanded lookup is not-visible with no id; an unresolved anchor gets one answer; the read set contains every object the executor reads; body bound and related-row cap pinned as constants; pack selection has no fallback, and two packs of one name on one root are refused with one answer.
  • packages/mcp/src/mcp-record-context-tools.test.ts (10): HTTP/stdio parity over the real executor (success, unknown pack, unknown record answered exactly as get_record, API-exposure root answered as get_record); a system root refused by the read guard before the bridge; a system child refuses unnamed; an apiEnabled: false child refuses named; a child whose package is disabled refuses unnamed, alike on both doors; not listed without the service or without data:read.
  • packages/services/service-record-context/src/__tests__/body-outline.test.ts (11): headings read, and outline parsing linear in body length.
  • packages/runtime/src/mcp-record-context-tools-bridge.test.ts (5): seam resolution, the door handed to the executor (keys, read-guard identity, packs via the protocol's merged listing), route gating on data:read.
  • packages/lint/src/validate-ai-context.test.ts (6) + authoring-rule-wiring green.

Acceptance notes

  • The author-defect lint is CLI-only (os validate / os lint / os build): it needs the full stack snapshot, so it is not wired into runtime save yet.
  • The lookup count is bounded by the field-count bound (30); no separate lookup bound.
  • Composition is explicit: a host serves the tool by adding new RecordContextServicePlugin().
  • A lookup target the caller cannot read is refused unnamed (the naming bound is a ceiling, taken conservatively).
  • Not in scope: product-registry / PLATFORM_TOOLS_BY_PACKAGE (row 9), the skill context key (row 8), the Studio form (row 7).
  • Follow-up cards from the contract review: 37140 跟进:get_record_context 在运行时 HTTP 通道上用真执行器测一遍(含拒绝) #37175 (the real executor over the runtime HTTP bridge on a real-kernel rig, refusals included, plus a registry-served row), 37140 跟进:资料包(ai_context)的作者错误在保存时报出 #37176 (author defects reported at save, ADR-0160 D1; before row 7), 37140 跟进:资料包正文目录设条数上限 #37178 (a cap on outline entries).
  • Open ruling: 37140 跟进:资料包(ai_context)按包区分同名,补进 ADR-0150 的分桶表 #37180 (the ADR-0150 bucket for ai_context). Until it is ruled, two published packs that share a name and a root are refused with one answer (RESOURCE_CONFLICT), named once, whether or not context is given; the read set is then the root alone.
  • Since the first review: body outlines are read by linear forward scans; a related child's gates run before any read of its definition and any later failure refuses unnamed (a child is named only on an API-exposure refusal); a lookup whose target the published plan does not reach refuses the call; a multi-valued link is matched with $contains, as get_record matches it. Every package the change moves is entered at minor. ai_context is registered in every table that enumerates metadata types (catalog labels in every locale, Pending changes counts, the CLI schema gate, the package-scoped enumeration, where it is read whole, never by (package, name)).

Verification

  • Locally: the four suites above green; tsc --noEmit clean for spec, core, service-record-context, mcp (incl. test typecheck), runtime, lint; the showcase's new files type-clean; eslint clean on every changed TS file (one pre-existing warning in metadata-create-seeds.test.ts); check:generated, check-stack-collection-maps, check-skill-top-level-keys, check:platform-checklist, liveness ledger and dropped-refinements baseline green.
  • Left to CI (they need builds this container does not hold): check:published-readme-exports, check:i18n, the full suites. def-key-collisions failed locally for an environmental reason (tsx missing in its temp copy). runtime's test-typecheck reports three files that cannot resolve the unbuilt @objectstack/driver-turso, none touched here.
  • Tier H: the PR touches skills/objectstack-platform/SKILL.md (one key in the top-level list), so it needs os-zhuang's approval to land.

Human Minimum

  • 1. Schemas start as Zod; packages/spec holds no runtime logic.
  • 2. Every name I added uses the casing for its kind.
  • 3. No formatter ran; pnpm lint passes.
  • 4. One issue, one branch off an up-to-date main, one pull request.
  • 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset.
  • 6. packages/spec touched: its generated artifacts are regenerated and committed.
  • 7. No hand edits to content/docs/references/, packages/*/CHANGELOG.md or content/docs/releases/.
  • 8. Title, body and comments are in English.
  • The Before Submitting list in CONTRIBUTING.md is done.

🤖 Generated with Claude Code

https://claude.ai/code/session_01JQwxbakRyu1KGH6y31soLv

…ope, service package

Claude-Session: https://claude.ai/code/session_01JQwxbakRyu1KGH6y31soLv
Co-authored-by: Claude <noreply@anthropic.com>
…g, showcase packs

Claude-Session: https://claude.ai/code/session_01JQwxbakRyu1KGH6y31soLv
Co-authored-by: Claude <noreply@anthropic.com>
…, skill key list

Claude-Session: https://claude.ai/code/session_01JQwxbakRyu1KGH6y31soLv
Co-authored-by: Claude <noreply@anthropic.com>
…the executor in the lockfile

Claude-Session: https://claude.ai/code/session_01JQwxbakRyu1KGH6y31soLv
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size/xl dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation protocol:ai protocol:system tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 25, 2026
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 10 package(s): @objectstack/core, @objectstack/lint, @objectstack/mcp, @objectstack/metadata-core, @objectstack/metadata, @objectstack/objectql, @objectstack/platform-objects, @objectstack/runtime, @objectstack/service-record-context, @objectstack/spec, touching 209 documentable anchor(s). ⚠️ 20 changed file(s) yielded no anchor (packages/core/src/index.ts, packages/lint/src/index.ts, packages/mcp/vitest.config.ts, …), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

80 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: node scripts/docs-audit/affected-docs.mjs --json 753aae6dedab1b7c95b225cbe70e6aee9f1c27b0.

⛔ 16 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails.

What this run could not see
  • 20 changed file(s) yielded no anchor (packages/core/src/index.ts, packages/lint/src/index.ts, packages/mcp/vitest.config.ts, …) — pages documenting those are invisible to this run
  • 3 anchor(s) matched too much of the corpus to be a work list: objectName (symbol, 59 pages), PERMISSION_DENIED (literal, 56 pages), objectName (literal, 59 pages)
  • 30 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 69 of 252 client-bound route-ledger rows — the other 183 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 183: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 124 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 191 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 753aae6dedab1b7c95b225cbe70e6aee9f1c27b0 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 7061e12926b9a5742fd3767aac80fd1ac45156db — the merge of head 74e176d8525254b2e96694e3eb8ce8e46d7885fc into base 753aae6dedab1b7c95b225cbe70e6aee9f1c27b0, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 7061e12926b9a5742fd3767aac80fd1ac45156db && git checkout 7061e12926b9a5742fd3767aac80fd1ac45156db
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 753aae6dedab1b7c95b225cbe70e6aee9f1c27b0 74e176d8525254b2e96694e3eb8ce8e46d7885fc && git checkout -B drift-repro 753aae6dedab1b7c95b225cbe70e6aee9f1c27b0 && git merge --no-ff 74e176d8525254b2e96694e3eb8ce8e46d7885fc

node scripts/docs-audit/affected-docs.mjs --json 753aae6dedab1b7c95b225cbe70e6aee9f1c27b0

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs 753aae6dedab1b7c95b225cbe70e6aee9f1c27b0 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#1 · os-warren · session_01JQwxbZeHNsF3RWcWpj7rGj

Contract-review-claim: session_01JQwxbZeHNsF3RWcWpj7rGj · head edba968 · 2026-11-25T01:27Z

…for the two ai schemas and the new package, pay the SKILL.md key with a trimmed restatement

Claude-Session: https://claude.ai/code/session_01JQwxbakRyu1KGH6y31soLv
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#1 · os-warren · session_01JQwxbZeHNsF3RWcWpj7rGj

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: edba9689396d5010e32c316d273e5930ba156baf
Local-runs: none
Scope: packages/spec/src/ai/ai-context.zod.ts, packages/spec/src/ai/index.ts, packages/spec/src/ai/record-context-tools.zod.ts, packages/spec/src/kernel/collection-item-owner-stamp.ts, packages/spec/src/kernel/customization-package.ts, packages/spec/src/kernel/metadata-plugin.zod.ts, packages/spec/src/kernel/metadata-type-schemas.ts, packages/spec/src/meta-spelling/manifest-collection-spelling.ts, packages/spec/src/meta-spelling/meta-url-data.generated.ts, packages/spec/src/stack.zod.ts, packages/spec/src/system/constants/platform-tool-names.ts, skills/objectstack-platform/SKILL.md + packages/services/service-record-context/src/** (executor, read-set, door, body-outline, sentences, plugin, tests, fake door), packages/core/src/record-material-envelope.ts, packages/mcp/src/mcp-http-tools.ts, packages/mcp/src/stdio-data-bridge.ts, packages/mcp/src/plugin.ts, packages/mcp/src/mcp-record-context-tools.test.ts, packages/runtime/src/domains/mcp.ts, packages/runtime/src/mcp-record-context-tools-bridge.test.ts, packages/lint/src/validate-ai-context.ts, packages/lint/src/authoring-rules.ts, packages/metadata/src/plugin.ts, packages/metadata-core/src/types.ts, packages/objectql/src/engine-top-level.ts, packages/spec/liveness/ai_context.json and README row, .changeset/37140-*.md, .changeset/config.json, examples/app-showcase packs. Read-only outside the diff: mcp-relation-reads.ts, action-execution.ts, ADR-0160 on main.
Security-touching: yes
Rule-change-verified: none

① Derived judgments

  • Read as the caller: holds. Every record read is door.get / door.query, which are the bridges' own members: HTTP callData with the request's execution context and environment, and stdio engine.find with the resolved principal. There is no system context and no driver read. The service is stateless and resolved per request and per environment, so I found no cross-environment or cross-tenant path.
  • Order of judgement. The root's guard, API exposure and served-ness all run before listContextPacks (record-context-tools.ts:244-257). Pack selection has no fallback: an unknown name and a pack on another object get the same answer (read-set.ts:62-71). Children are judged before projection, and lookup targets before reads (:275-355). The one exception is that a child's published definition is read before its gates (R2).
  • Field level. Fields are projected onto the served definition. A hidden entry is stated once and never named. The mcp: query_records and get_record say which fields field-level security withheld, so an answer says "not visible to you", not "blank" #35137 naming reaches only fields that are served but unreadable. An unopenable lookup carries no id (:159-181). Unreadable related rows never arrive.
  • Envelope. It is built only by wrapRecordMaterial (core/record-material-envelope.ts:49), which is called in one place (:485). Both doors reach it through the one executor.
  • Schema. Strict, with the six v1 keys plus the kind-wide MetadataProtectionFields, following the skill precedent. The bounds 30 / 3 / 10 are refused at parse. The kind is registered on every surface D1 lists, with the skill row's flags. Each liveness row cites a real reader, and the type and its reader land together (ADR-0049).
  • SKILL.md. It gains aiContexts, which is the key stack.zod.ts:1228 accepts.
  • Body. An unresolved anchor gets one RESOURCE_NOT_FOUND for each case: stale anchor, no body, hidden body and withheld body (:438-463). The 8000 and 20 constants are pinned (test :38-41).

② Semver level

Clause-②: yes and Metadata-protocol: added are correct. The change is additive only: a new kind, a new collection key, new exports and one more door tool name. minor on each of the ten packages therefore matches AGENTS.md step 3. The .changeset/config.json edit puts the new package in the fixed group beside its sibling services. Downstream note: an exhaustive Record keyed on MetadataType outside this repo will need an ai_context row at the pin move, as it does for every kind admission.

③ Boundary flags

  • Lint is CLI-only. This deviates from D1 and card item 1, which say "at save". The dev can't grant that deviation (R7).
  • Lookups bounded by the 30-field bound. Acceptable, because parse cannot know which names are lookups. The ceiling is about 65 engine reads per call.
  • Composition by explicit plugin. Matches D5. A host without the service registers nothing.
  • Lookup target refused without naming it. This stays within the naming bound and is the conservative choice.
  • Registration. The tool registers inside registerObjectTools under canRead rather than as its own #wireBridgeTools step. The gate is equivalent, so this is accepted.
  • SQL push-down. No new id materialisation and no in-app join. Expansion is the engine's batched read. The second root read by id (:363-367) is the expand read that D3 names.
  • Author. The PR author is objectstack-fleet[bot], and the PR is a draft. CI on this head is red (R3).

④ Design judgment

  • ai-context.zod.ts. Sound for the executor and the showcase packs, but it fails the ADR-0122 alias gate (R3).
  • record-context-tools.zod.ts. Input and output are declared once and projected. The MCP door registers the zod input directly, as the dataset tools do. It has the same ADR-0122 gap (R3).
  • Kernel, meta-spelling, stack and index files. Each is consistent with the skill rows, and the generated file matches.
  • platform-tool-names.ts. The door name joins. PLATFORM_TOOLS_BY_PACKAGE is correctly left to row 9.
  • SKILL.md. The content is correct, but the file is over its shrink-only token ceiling (R3).
  • First consumer. The executor and both MCP doors are in this PR. The execution plan holds except for R1, R2, R4 and R5.

Findings

  • R1 must-fix (security). Outline parsing of record body text must run in time linear in the body's length, whatever the body holds, and must be pinned by an adversarial-input test. The body is untrusted record text (body-outline.ts, called from record-context-tools.ts:444). Details have gone to the implementing thread.

  • R2 must-fix (security, order and naming). No definition of a pack's related child may be read before that child's object-level judgement. Any refusal arising from such a read must come out as the one unnamed PERMISSION_DENIED. Today planObjectsOf (record-context-tools.ts:263, read-set.ts:138) reads child definitions before the gates at :275-287. The two transports can then answer the same call differently, which breaks D4's one-code rule and transport parity. Details have gone to the implementing thread.

  • R3 must-fix. Six gates are red on this head, all caused by this diff:

    • the published-skills token ratchet (SKILL.md is 6152 tokens against a ceiling of 6148);
    • the ADR-0122 parsed-alias convention (12 violations across the two new zod files);
    • generated references (content/docs/references/ai/ai-context.mdx is stale);
    • the packages/spec/llms.txt counts;
    • the test-source alias gate (showcase vitest.config);
    • WHERE-matcher conformance (mcp-record-context-tools.test.ts:94).

    The SKILL.md fix changes governed text, so the delta needs a re-read.

  • R4 should-fix (security, fail closed). A surviving lookup whose target is not in the planned read set must be dropped or refused. At record-context-tools.ts:352 it skips the read guard but stays in the expand list (:345, :365, :394). This is reachable when the served and published definitions disagree, which can happen on stdio (stdio-data-bridge.ts:1877-1880).

  • R5 should-fix. A multi-valued link field is filtered by equality (record-context-tools.ts:392), whereas get_record's related list uses $contains (mcp-relation-reads.ts:255-256). The list comes back silently empty, and no lint rule or test covers it.

  • R6 should-fix. The parity test runs one stdio bridge under two MCP transports (mcp-record-context-tools.test.ts:102-116, :160-164). The HTTP data bridge's door (runtime/src/domains/mcp.ts:1680-1698) is only wiring-tested against a mocked executor. Run the real executor over both bridges on one fixture, refusals included. Also add one read over a registry-served row, because read-set.ts:47-54 silently drops a row that doesn't parse.

  • R7 should-fix. D1's "reported at save" is not built: the rule is CLI_ONLY (authoring-rules.ts:1972-1978). The kind allows runtime create (metadata-plugin.zod.ts:1388), and the tool is silent on author defects (record-context-tools.ts:300-303, :323). Either build it, or file a follow-up card before row 7 and name it in the PR body. The Skills-docs: follow-up owed line needs its card number.

  • R8 nit. The catch at record-context-tools.ts:281-285 turns any throw from the exposure gate, a server fault included, into a named PERMISSION_DENIED.

  • R9 nit.

    • Notes are written in en and zh-Hans (sentences.ts:15), but the framing is in four languages (record-material-envelope.ts:33).
    • A related list has no order, so the 20-row cut is unstable (:391-396).
    • The spec says "plural label" (record-context-tools.zod.ts:121), but the executor serves label (:417).
    • A withheld body is appended to fields and can duplicate an entry (:464-467).

Implemented-by: session_01JQwxbakRyu1KGH6y31soLv
Reviewed-by: session_01JQwxbZeHNsF3RWcWpj7rGj

VERDICT: FAIL

…cord_context types (ADR-0122), the engine double refuses an unsupported where, the showcase aliases the executor to source

Claude-Session: https://claude.ai/code/session_01JQwxbakRyu1KGH6y31soLv
Co-authored-by: Claude <noreply@anthropic.com>
…ny definition read of it; fail closed on an unplanned lookup target; multi-valued links match with $contains

Also: the metadata owner-stamp fixture and the overlayable-tier pin name ai_context, and the platform-objects form bundles carry its label.

Claude-Session: https://claude.ai/code/session_01JQwxbakRyu1KGH6y31soLv
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#1 · os-warren · session_01JQwxbZeHNsF3RWcWpj7rGj

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 73d03bbcde6fff411100dae49acd6b1c370831fd
Local-runs: none
Scope: packages/spec/src/ai/ai-context.zod.ts, packages/spec/src/ai/index.ts, packages/spec/src/ai/record-context-tools.zod.ts, packages/spec/src/kernel/collection-item-owner-stamp.ts, packages/spec/src/kernel/customization-package.ts, packages/spec/src/kernel/metadata-plugin.zod.ts, packages/spec/src/kernel/metadata-type-schemas.ts, packages/spec/src/meta-spelling/manifest-collection-spelling.ts, packages/spec/src/meta-spelling/meta-url-data.generated.ts, packages/spec/src/stack.zod.ts, packages/spec/src/system/constants/platform-tool-names.ts, skills/objectstack-platform/SKILL.md + delta edba9689..73d03bbc (cb5e8b8, 76eabb5, 73d03bb; the merge of main read only where it meets this diff): packages/services/service-record-context/src/body-outline.ts, record-context-tools.ts, tests/body-outline.test.ts (new), tests/fake-door.ts, tests/record-context-tools.test.ts, packages/mcp/src/mcp-record-context-tools.test.ts, packages/metadata-protocol/src/protocol.legacy-overlay-delete.test.ts, packages/metadata/src/owner-stamp-residual-build-boot.test.ts, packages/platform-objects/src/translations/*.metadata-forms.generated.ts, packages/spec/llms.txt, examples/app-showcase/vitest.config.ts, regenerated references and api-surface files. Files unchanged since edba9689 stand as reviewed in 7149757761.
Security-touching: yes
Rule-change-verified: none

① Derived judgments

  • R1, outline reading is now linear. The two heading patterns are gone, and every reader in body-outline.ts:41-138 is a forward scan.
    • isFence and markdownHeadingOf (:46-65) each walk a line once.
    • htmlHeadingsOf (:88-138) advances pos on every iteration. Its > search and its per-level closing-tag search are memoised and only asked from non-decreasing positions.
    • stripTags (:68-80) is one pass, and the remaining regexes have no nested quantifiers.
    • The worst cases (many unclosed openers, openers with no tag end, long whitespace runs, nested tags) were reasoned through, and each stays linear.
  • R2, a child's gates come before any read of its definition. The order is guard, then served, then exposure (record-context-tools.ts:279-298). planObjectsOf runs after that, through publishedOf (:303-311), which turns any throw into the unnamed PERMISSION_DENIED. A child is named only on OBJECT_API_DISABLED or OBJECT_API_METHOD_NOT_ALLOWED (:227, :293-296), and only after the served definition came back non-null. So naming stays inside the bound.
  • R4. An unplanned lookup target refuses the call unnamed, before any read (:376-378).
  • R5. A multi-valued link filters with $contains (:418), read off the served field definition (:360). The fake door refuses every other operator.

② Semver level

Unchanged. The change is additive, ships minor on each package, and declares Clause-②: yes and Metadata-protocol: added. The delta adds only XParsed type aliases (ADR-0122) and regenerated files.

③ Boundary flags

  • CI. CI was not finished at read time, and R3's closure is from the diff. The seat checks for full green before ACCEPT.
  • SKILL.md. The key list is unchanged. The trimmed sentence ("A phantom key like roles: or policies: is refused: the stack fails to load") is accurate, and the ratchet script is not touched.
  • Overlayable tier. ai_context joining ROLLED_BACK_OVERLAYABLE_TYPES pins the registry row (supportsOverlay: true, allowEnvironmentOverlay: false, the skill row's flags, as in ADR-0160 D1).
  • Mechanical changes. The owner-stamp fixture row, the form bundles and the llms.txt counts (228→230, ai 14→16, packages 75→76) are mechanical.
  • SQL push-down. Nothing new.
  • Author. The PR author is objectstack-fleet[bot].

④ Design judgment

  • Spec modules: only the parsed-state aliases were added, and the accepted set is unchanged.
  • SKILL.md: sound as governed text.
  • Executor: its plan now holds for R1, R2, R4 and R5, each pinned by a test (body-outline.test.ts; the record-context-tools.test.ts ordering, unnamed-refusal, unplanned-target and $contains cases; the MCP disabled-package parity case).

Findings

Implemented-by: session_01JQwxbakRyu1KGH6y31soLv
Reviewed-by: session_01JQwxbZeHNsF3RWcWpj7rGj

VERDICT: PASS

…(catalog counts, package-scoped enumeration, CLI schema gate, Pending changes counts in every locale)

Claude-Session: https://claude.ai/code/session_01JQwxbakRyu1KGH6y31soLv
Co-authored-by: Claude <noreply@anthropic.com>
… two edited tests' dynamic imports at collection

Claude-Session: https://claude.ai/code/session_01JQwxbakRyu1KGH6y31soLv
Co-authored-by: Claude <noreply@anthropic.com>
…docs line names its card

Claude-Session: https://claude.ai/code/session_01JQwxbakRyu1KGH6y31soLv
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#1 · os-warren · session_01JQwxbZeHNsF3RWcWpj7rGj

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 74e176d8525254b2e96694e3eb8ce8e46d7885fc
Local-runs: none
Scope: packages/spec/src/ai/ai-context.zod.ts, packages/spec/src/ai/index.ts, packages/spec/src/ai/record-context-tools.zod.ts, packages/spec/src/kernel/collection-item-owner-stamp.ts, packages/spec/src/kernel/customization-package.ts, packages/spec/src/kernel/metadata-plugin.zod.ts, packages/spec/src/kernel/metadata-type-schemas.ts, packages/spec/src/meta-spelling/manifest-collection-spelling.ts, packages/spec/src/meta-spelling/meta-url-data.generated.ts, packages/spec/src/stack.zod.ts, packages/spec/src/system/constants/platform-tool-names.ts, skills/objectstack-platform/SKILL.md + delta f7c83f7e..74e176d8 (five commits): packages/core/src/security/second-object-read-exposure.pin.test.ts, packages/mcp/src/mcp-file-tools.test.ts, packages/lint/src/rule-explanations.ts, packages/services/service-record-context/src/sentences.ts, .changeset/37140-ai-context-get-record-context.md, four CLI transcripts under content/docs; also the read of 9ae6a3bf..f7c83f7e: SKILL.md, packages/metadata/src/owner-stamp-residual-build-boot.test.ts, packages/metadata-protocol/src/protocol.legacy-overlay-delete.test.ts, service-record-context read-set.ts, record-context-tools.ts and its test. Files unchanged since the earlier heads stand as reviewed there.
Security-touching: yes
Rule-change-verified: none

① Derived judgments

From 9ae6a3bf..f7c83f7e:

  • R13. The page carries "the top level refuses it and the stack fails to load" on one line, exactly the string the key gate reads (scripts/check-skill-top-level-keys.mjs:77). The surrounding text is accurate, and the token ratchet is green on this head.
  • R14. Each of the two edited tests pays its dynamic import at module top, which is the alias gate's own remedy.
  • R15. selectContextPack returns duplicate, and the executor refuses before any read (read-set.ts:65-76, record-context-tools.ts:266).
    • The code is RESOURCE_CONFLICT / 409. It is in the catalogue (spec/src/api/errors.zod.ts:95), and it is ADR-0150's code for a bare name with two holders, so D4's "the tool coins no code" holds.
    • The refusal runs after the root's gates. It names only the root and a pack rooted on it, and no package or other object, so it stays inside the naming bound.
    • The read set is the root alone, and a duplicated name beside another pack is listed once. Two tests pin this.
  • R16. All thirteen changeset entries are minor.

New in f7c83f7e..74e176d8:

  • The second-object-read classification is correct.
    • read-set.ts is executes: it reads no record, and lookupTargetOf only names a target for the read set and the read-guard ask. The expansion is the door's query with expand. That is the same shape and the same decider as the existing mcp-relation-reads.ts row (pin test :238-248), and servesExpansionTarget is a decided row that the pin enforces (:624).
    • On stdio, stdioExpandMap decides the same expansion and has its own decided row (:230-236), so both doors in this repo are covered (R19).
    • validate-ai-context.ts is not-a-served-read: it is static analysis of a stack, like its neighbouring lint rows.
  • The door-tools pin. Its every-member bridge carries the two record-context members, so MCP_DOOR_TOOL_NAMES and the registered set agree.
  • Transcripts and the lint string. The author-time rule count is 79 in four transcripts, which is one added rule entry. The covers string is only reworded.
  • R17, R18. The Skills-docs: follow-up #37177 line is in the changeset and the PR body. The duplicate answer also points to naming another pack, in both locales.
  • No change to executor logic, the door or the schema. The security judgments of the earlier records stand.

② Semver level

Clause-②: yes and Metadata-protocol: added, with minor on every package the diff moves (AGENTS.md step 3). Nothing published is narrowed.

③ Boundary flags

④ Design judgment

  • ai-context.zod.ts and record-context-tools.zod.ts. Strict, with the six v1 keys plus the kind-wide protection envelope. Bounds are refused at parse, and the parsed-state aliases are present.
  • Kernel, meta-spelling, stack and index files. Consistent with the skill rows on every surface D1 lists.
  • platform-tool-names.ts. The door name is registered, and its pin is green.
  • SKILL.md. The key list matches what the stack schema accepts, and the page carries its gate's sentence.
  • First consumer. The executor and both MCP doors land with the type (ADR-0049).
  • Execution plan. Holds for the order of judgement, the naming bound, field and row level, the body, and pack selection, with no path that chooses between two packs.

Findings

Status:

New:

Implemented-by: session_01JQwxbakRyu1KGH6y31soLv
Reviewed-by: session_01JQwxbZeHNsF3RWcWpj7rGj

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#1 · os-warren · session_01JQwxbZeHNsF3RWcWpj7rGj

维护者速读

新增「资料包」元数据类型。应用作者声明一条记录交给 AI 时带哪些字段、哪些关联列表、哪段正文;外接 AI 经 MCP 调用 get_record_context 一次拿到,全程按提问人自己的权限读,看不到的对象和字段不点名。合同评审(fable 档)四轮,最后一轮通过;安全上的两处必改项(正文目录解析耗时、子对象先读后判)已改并有测试钉住。
要你做的:这是受管文件(平台技能)且超过 3000 行,需要你在 head 74e176d8 上批准或亲自入队。

席位核对 — ACCEPT (L1) · repo:objectstack#1 · head 74e176d8 · 2026-11-25T03:09Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#1 · os-warren · session_01JQwxbZeHNsF3RWcWpj7rGj

维护者速读

新增「资料包」类型。应用作者可以声明一条记录交给 AI 的字段、关联列表和正文,外接 AI 通过 MCP 一次就能拿到,全程按提问人自己的权限读取。这是记录范围 AI 问询专题的第 5 行,第 7 到 10 行都在等它。评审最后一轮通过,安全上的两处必改都已修好,并有测试钉住。
要你做的:在 head 74e176d8 上点批准,或者自己入队。这个 PR 改了平台技能文件,又超过 3000 行,所以需要你本人放行。

Hand-off: CONTRACT_REVIEW_TIER PASS 7151631723 at 74e176d8; seat ACCEPT on this thread.

@objectstack-fleet objectstack-fleet Bot added the pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue label Nov 25, 2026
@os-zhuang
os-zhuang marked this pull request as ready for review November 25, 2026 03:10
@os-zhuang
os-zhuang added this pull request to the merge queue Nov 25, 2026

os-bob commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

maintainer · os-bob · session_012dn2AecKpLaYkUtNRiqtby

To this PR's author: the maintainer decided four points of ADR-0160 on 2026-11-25 (「同意你的建议」), and they change this PR. The record is amended in draft PR #37196 (Tier H; the maintainer merges it). Please build to #37196 as drafted; once merged, it is the authority. #37140's body is updated to match, with the changes marked [amended].

Contract changes

  1. Point 2, object level.
    • A related child the door serves to nobody (the system-object refusal, API exposure off) still refuses the whole call with PERMISSION_DENIED.
    • A related child this caller is not served (ADR-0106 object-level visibility) is now left out: never read, never named, and the notes carry the one not-visible statement (sentences.ts#notVisible).
    • In record-context-tools.ts step 4a, when servedObjectDefinitionOf returns nothing for a child, mark it hidden and skip it instead of refuseObject. Flip the test "a child the caller is not served is refused PERMISSION_DENIED without naming it".
  2. Point 1, condition 1. sentences.ts#severalPacks lists each candidate as name and label (D1: label's second reader), not the machine name alone.
  3. The bound on carried text (new in D3).
    • Long-text values in related[].fields cells are allowed, but they count toward one total bound together with the body. Today they are carried unbounded (up to 20 rows × 10 columns).
    • A cut cell is marked truncated, and the notes state the cut.
    • Choose the number against evidence and name it in the PR: whole-policy answering of about 12,000 tokens measured well in BrightRule (objectstack-ai/brightrule docs/design-record-scoped-ai.md). 8,000 characters as the only bound is too low.
  4. Point 10 stands as written. This PR already implements it.

Code points from the independent review

Points 1 and 10 stay as merged; point 2 changes. The rest of the design is unchanged.


Generated by Claude Code

Merged via the queue into main with commit 2a6f26a Nov 25, 2026
80 of 81 checks passed
@os-zhuang
os-zhuang deleted the claude/project-thread-k0j3qn branch November 25, 2026 03:39
os-justin pushed a commit that referenced this pull request Nov 25, 2026
The os-regen driver kept the branch's side of the shard in the merge commit
and step 2 took main's; gen:schema on the merged HEAD yields both: main's 56
entries (#37173) and this branch's ai/KnowledgeDocument:docHash.

Claude-Session: https://claude.ai/code/session_01QSeKYmGV9ehU2Bfmw95h7E
Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue protocol:ai protocol:system size/xl tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

记录 AI 问询 5:资料包类型 ai_context、渲染服务与 get_record_context 工具(MCP)

4 participants