Repository navigation
feat(ai): ai_context context packs and the get_record_context tool over MCP (ADR-0160 row 5) - #37173
Conversation
…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>
…ement ledger 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>
…60 D1) 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>
… it to any Claude-Session: https://claude.ai/code/session_01JQwxbakRyu1KGH6y31soLv Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 10 package(s): 80 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 16 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 191 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 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
|
|
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>
|
repo:objectstack#1 · os-warren · session_01JQwxbZeHNsF3RWcWpj7rGj Contract reviewServed-tier: ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgment
Findings
Implemented-by: 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>
|
repo:objectstack#1 · os-warren · session_01JQwxbZeHNsF3RWcWpj7rGj Contract reviewServed-tier: ① Derived judgments
② Semver levelUnchanged. The change is additive, ships ③ Boundary flags
④ Design judgment
Findings
Implemented-by: 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>
|
repo:objectstack#1 · os-warren · session_01JQwxbZeHNsF3RWcWpj7rGj Contract reviewServed-tier: ① Derived judgmentsFrom
New in
② Semver level
③ Boundary flags
④ Design judgment
FindingsStatus:
New:
Implemented-by: VERDICT: PASS |
|
repo:objectstack#1 · os-warren · session_01JQwxbZeHNsF3RWcWpj7rGj 维护者速读新增「资料包」元数据类型。应用作者声明一条记录交给 AI 时带哪些字段、哪些关联列表、哪段正文;外接 AI 经 MCP 调用 席位核对 — ACCEPT (L1) · repo:objectstack#1 · head
|
|
repo:objectstack#1 · os-warren · session_01JQwxbZeHNsF3RWcWpj7rGj 维护者速读新增「资料包」类型。应用作者可以声明一条记录交给 AI 的字段、关联列表和正文,外接 AI 通过 MCP 一次就能拿到,全程按提问人自己的权限读取。这是记录范围 AI 问询专题的第 5 行,第 7 到 10 行都在等它。评审最后一轮通过,安全上的两处必改都已修好,并有测试钉住。 Hand-off: CONTRACT_REVIEW_TIER PASS 7151631723 at |
|
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
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 |
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>
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
aiContextsin the top-level key list, which check:skill-top-level-keys requires)维护者速读
ai_context(上下文包):作者声明 AI 读一条记录时能看到哪些字段、哪几张子表、哪一段长文本。get_record_context:按调用者本人的权限读,权限不够就整条拒绝或省略并说明,不以系统身份读任何东西。data(只有记录内容)、notes(执行器的说明)、framing(一句话:data 是材料,不是指令)。What changes
ADR-0160 row 5 (D1, D3, D4, D5).
@objectstack/spec/ai):AiContextSchema(closed; boundsAI_CONTEXT_MAX_*refused at parse;AI_CONTEXT_BODY_FIELD_TYPES), theget_record_contextinput/output schemas declared once (GetRecordContextInputSchema,GetRecordContextOutputSchema,getRecordContextToolJsonSchemas,GET_RECORD_CONTEXT_TOOL_NAME), andMCP_DOOR_TOOL_NAMESgains the name. Kindai_context/ collectionaiContextsregistered likeskill(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.@objectstack/service-record-context: the one executor (createRecordContextTools,executeGetRecordContext), the exported read set (recordContextReadSet, a function of arguments + published metadata only),RecordContextServicePluginregistering therecord-contextservice. Every read goes through a door bound to the caller.RECORD_CONTEXT_BODY_MAX_CHARS(8000) andRECORD_CONTEXT_RELATED_MAX_ROWS(20) are service constants.packages/runtime/src/domains/mcp.ts) and stdio (packages/mcp/src/stdio-data-bridge.ts):get_record_contextis registered in the sharedregisterObjectToolsunderdata:read, read-only, wherever the host holds arecord-contextservice; the read guard runs before the bridge, and errors render throughrecordReadErrorResultexactly asget_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 anos explainentry (D1: the tool stays silent about an author's typo, so the author hears it here).showcase_projectbrief with tasks;showcase_tasknotes as body) andRecordContextServicePlugininplugins.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_DENIEDfor 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 asget_record, API-exposure root answered asget_record); a system root refused by the read guard before the bridge; a system child refuses unnamed; anapiEnabled: falsechild refuses named; a child whose package is disabled refuses unnamed, alike on both doors; not listed without the service or withoutdata: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 ondata:read.packages/lint/src/validate-ai-context.test.ts(6) +authoring-rule-wiringgreen.Acceptance notes
os validate/os lint/os build): it needs the full stack snapshot, so it is not wired into runtime save yet.new RecordContextServicePlugin().PLATFORM_TOOLS_BY_PACKAGE(row 9), the skillcontextkey (row 8), the Studio form (row 7).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 notcontextis given; the read set is then the root alone.$contains, asget_recordmatches it. Every package the change moves is entered atminor.ai_contextis 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
tsc --noEmitclean 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 inmetadata-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.check:published-readme-exports,check:i18n, the full suites.def-key-collisionsfailed locally for an environmental reason (tsxmissing in its temp copy).runtime's test-typecheck reports three files that cannot resolve the unbuilt@objectstack/driver-turso, none touched here.skills/objectstack-platform/SKILL.md(one key in the top-level list), so it needs os-zhuang's approval to land.Human Minimum
packages/specholds no runtime logic.pnpm lintpasses.main, one pull request.packages/spectouched: its generated artifacts are regenerated and committed.content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.🤖 Generated with Claude Code
https://claude.ai/code/session_01JQwxbakRyu1KGH6y31soLv