Repository navigation
feat(ai): a skill names the context pack it works from, and its MCP prompt takes a record id - #37552
objectstack-fleet[bot] wants to merge 10 commits into
Conversation
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>
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>
…sites Claude-Session: https://claude.ai/code/session_01Utp6CbeF2saT6wUBV4E9uc Co-authored-by: Claude <noreply@anthropic.com>
…nces, not as a second export Claude-Session: https://claude.ai/code/session_01Utp6CbeF2saT6wUBV4E9uc Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 5 package(s): 56 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 20 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 187 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 f0ea41145b1d42842ba34fe06fade32a74d86bb7 && git checkout f0ea41145b1d42842ba34fe06fade32a74d86bb7
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 411646562566a1e12b4e0fc3de256192e8302719 18429defaf7821b11d2ec2778eabc02f65d51425 && git checkout -B drift-repro 411646562566a1e12b4e0fc3de256192e8302719 && git merge --no-ff 18429defaf7821b11d2ec2778eabc02f65d51425
node scripts/docs-audit/affected-docs.mjs --json 411646562566a1e12b4e0fc3de256192e8302719
|
…ntrol; pay the metadata load at collection The skill form's new `context` control moves the platform-objects metadata-form bundles (check:i18n), and the runtime bridge test reaches a lazy `@objectstack/metadata` import (check:test-source-alias). Claude-Session: https://claude.ai/code/session_01Utp6CbeF2saT6wUBV4E9uc Co-authored-by: Claude <noreply@anthropic.com>
…shipped locale The extractor fills a new leaf with the source text; the echo-decision pins require the metadata-form catalog to carry no fills, so the label and help text are authored per locale and the positive-control count moves 837 → 838. Claude-Session: https://claude.ai/code/session_01Utp6CbeF2saT6wUBV4E9uc Co-authored-by: Claude <noreply@anthropic.com>
…ill-context-key # Conflicts: # packages/platform-objects/src/apps/translations/object-lifecycle-panel-echo-decisions.test.ts
Fixes #37141
Clause-②: yes (widening)
Metadata-protocol: added
Skills-docs: follow-up owed — skills/objectstack-ai/references/context-packs.md, skills/objectstack-ai/SKILL.md
维护者速读
What changes
ADR-0160 D8, with point 1's advisory (D1, amended 2026-11-25) and ADR-0150's addendum of 2026-11-25, reader 2.
packages/spec—SkillSchema.context?: string, a bare pack name (ROUTER_ADDRESSABLE_NAME_PATTERN; a face likeacme-policy_documentis refused). A skill that declares it and does not bindget_record_contextintools(by name or a matching wildcard) is refused at parse, located ontools(refuseUnboundRecordContext, asuperRefine).skillBindsRecordContextTool(tools)is the one predicate both the refusal and the lint advisory ask. Liveness row inliveness/skill.jsonnaming its reader; acontextcontrol inskill.form.ts.packages/mcp/src/skill-prompts.ts—skillPromptRecordContextresolves a skill'scontextby the one rule (resolvePackageScopedHolders, ADR-0150 D3) over the same pack listingget_record_contextselects from: from the skill's own package (own pack, else the one holder in its closure), or as a caller with no package for an environment skill; a refusal resolves to no pack, never one picked by order. The pack is handed on by its face (deriveAiFaceName), so the tool's selection reads back exactly that pack. When it resolves,prompts/listlists one optional argument,recordId; given, the one message isinstructions, a blank line,SKILL_PROMPT_RECORD_CONTEXT_LINE, and the call as one JSON object{objectName, recordId, context}. The id is only ever aJSON.stringifystring value; the pack is never inlined. Without the argument (or with acontextthat resolves to no pack) the result is byte-identical to the same skill without the key. A blank id is refused-32602.McpSkillBridgegains optionallistContextPacksandpackageResolutionClosure.registerSkillPrompts) and the long-lived stdio server (MCPServerRuntime.bridgePrompts, which now lists packs through the same merged read and takes the closure as an optional 4th argument;plugin.tspasses it from the engine registry throughpackageResolutionClosure).packages/runtime/src/domains/mcp.tshands the/mcpbridge the same pack listing the record-context members read (one function, hoisted) and the skill's package closure.packages/lint— insidevalidateAiToolReferences(where skills are validated,os validate):ai-skill-context-unknown(acontextnaming no pack the stack defines) andai-skill-context-omitted(a skill bindingget_record_contextwithoutcontextwhile an object has more than one pack; one finding per such object). Both warnings.authorable-surface/ai.json,api-surface/ai.json,export-origins/ai.json,liveness/state-counts/skill.md,content/docs/references/ai/skill.mdx,skills/objectstack-ai/references/_index.md(the skill-refs mirror:skill.zod.tsnow importsrecord-context-tools.zod.ts), and five new sites indropped-refinements.baseline.json(the new refinement does not project into JSON Schema; the build printed the corrected entries, copied verbatim, header total 1210 → 1215).skills/**readings (generated mirror only):skills/objectstack-ai/references/_index.md52 → 53 lines; everySKILL.mdsummed 4961 → 4961 lines (none touched).Tests
packages/spec/src/ai/skill.test.ts— parse refusal without the binding (located ontools), wildcard bindings, control withoutcontext, face/non-snake refused, the predicate.packages/mcp/src/skill-prompts.test.ts— the argument list; the message shape with and without the argument; the record id only as a JSON string value (a hostile id with quotes and newlines); acontextnaming no pack lists no argument and the prompt is unchanged; a connection that does not serveget_record_contextdoes not serve the skill (skillBindingServed); a blank id refused; D3 resolution (own package, closure, environment, refusal → no pack); the long-lived stdio server answering the same messages as the HTTP door.packages/lint/src/validate-ai-tool-references.test.ts— unknown pack (with near-miss), the item-6 advisory incl. a wildcard binding, and controls.packages/runtime/src/domains/mcp-merged-skill-read.test.ts— the/mcpbridge lists packs (read decorations stripped) only where the record-context seam is served, and the closure is the one walk over the engine registry.Ablations (both committed first, each restored with blob == HEAD proven by
scripts/ablation-replace.mjs):if (skillBindsRecordContextTool(skill.tools)) return;→ always return.skill.test.ts: 1 failed / 25 passed (the refusal case). Restored blobf49db7f7.The record is ${recordId}.→skill-prompts.test.ts: 2 failed / 48 passed (message shape, record-id-only-in-JSON). Restored blobbc176cb1.Acceptance notes
ai-skill-tool-unresolvedwarning formcpPrompt: false+contextno longer fires on this tree: Row 9, objectstack half:get_record_contextjoinsPLATFORM_TOOLS_BY_PACKAGEand gets itschatbot.toollabel in every locale #37190 already putget_record_contextintoPLATFORM_TOOLS_BY_PACKAGE['service-ai'], so the name resolves for an in-product skill (validate-ai-tool-references.test.ts"resolves get_record_context on a mcpPrompt: false skill" pins that). Nothing was suppressed here.contextagainst the stack's ownaiContexts(one holder, D3 step 1); a pack only a dependency package ships is reported as unknown byos validate. The runtime prompt resolves it through the closure.packageResolutionClosureresolves a package skill'scontextto its own package's pack only, never environment-wide.packages/mcp/src/mcp-server-runtime.ts,packages/mcp/src/plugin.tsandpackages/runtime/src/domains/mcp.ts(+ its skill-read test): the bridges that feed the prompt surface; without them the key would have no reader at run time.Verification
Two-minute check
pnpm --filter @objectstack/mcp exec vitest run src/skill-prompts.test.ts -t "a skill with context takes a record"— 14 cases green (incl. the nested resolution block); the "given the record id" case prints the message as instructions, the fixed line, then{"objectName":"policy","recordId":"pol_1","context":"policy_document"}.Read first:
packages/mcp/src/skill-prompts.ts(skillPromptRecordContext,skillPromptResult),packages/spec/src/ai/skill.zod.ts(refuseUnboundRecordContext),packages/mcp/src/mcp-server-runtime.ts(bridgePromptsregistration withargsSchema).Generated by Claude Code
https://claude.ai/code/session_01Utp6CbeF2saT6wUBV4E9uc