Skip to content

Implement ObjectStack protocol specification with Zod schemas and TypeScript interfaces - #3

Merged
huangyiirene merged 4 commits into
mainfrom
copilot/set-up-copilot-instructions
Jan 18, 2026
Merged

huangyiirene merged 4 commits into
mainfrom
copilot/set-up-copilot-instructions

Conversation

Copilot AI commented Jan 18, 2026 •

Copy link
Copy Markdown
Contributor

Establishes the foundational type system and conventions for the ObjectStack ecosystem. This defines the "Constitution" - shared interfaces, validation schemas, and directory conventions used by ObjectOS, ObjectStudio, ObjectCloud, and third-party plugins.

Core Components

  • Manifest Schema (src/schemas/manifest.zod.ts)

    • Zod-first schema with type inference for package configuration
    • Defines package metadata (id, type, version), permissions, menu structure, entity patterns, and extension points
    • Validates app/plugin/driver/module packages
  • Plugin Runtime Interface (src/types/plugin.ts)

    • Lifecycle contract: onInstall, onEnable, onDisable
    • PluginContext provides ql (ObjectQLClient), os (ObjectOSKernel), and logger
    • Defines ObjectQL query/mutation interface and kernel event bus
  • Directory Conventions (src/constants/paths.ts)

    • Hardcoded paths: src/schemas, src/triggers, src/client/pages, assets
    • Standard files: objectstack.config.ts, src/index.ts
    • Type-safe path constants for runtime and tooling

Usage

import { ManifestSchema, ObjectStackPlugin, PKG_CONVENTIONS } from '@objectstack/spec';

// Validate package manifest
const manifest = ManifestSchema.parse({
  id: 'com.example.crm',
  version: '1.0.0',
  type: 'plugin',
  permissions: ['system.user.read']
});

// Implement plugin
export default function(): ObjectStackPlugin {
  return {
    async onInstall(ctx) { /* setup */ },
    async onEnable(ctx) { /* start */ },
    async onDisable(ctx) { /* cleanup */ }
  };
}

All types include comprehensive TSDoc for IntelliSense. No runtime dependencies except Zod. Universal compatibility (Node.js/Browser/Electron).

Original prompt

This section details on the original issue you should resolve

<issue_title>✨ Set up Copilot instructions</issue_title>
<issue_description>📜 ObjectStack Protocol & Specification Context
Role: You are the Chief Architect and Standards Committee for the ObjectStack Ecosystem.
Mission: Define the "Constitution" of the system. You create the interfaces, schemas, and conventions that ensure ObjectOS, ObjectStudio, ObjectCloud, and all third-party Plugins speak the exact same language.
Guiding Principle: "Strict Types, No Logic."
This repository contains NO database connections, NO UI components, and NO runtime business logic. It contains only:

  • TypeScript Interfaces (Shared types).
  • JSON Schemas / Zod Schemas (Validation rules).
  • Constants (Convention configurations).
  1. The "Manifest" Standard (Core Responsibility)
    You define what a "Package" looks like in ObjectStack.
  • Schema Location: src/schemas/manifest.zod.ts (Export to JSON Schema).
  • Key Definition: The ObjectStackManifest interface.
    • id: Unique identifier (e.g., com.example.crm).
    • type: app | plugin | driver | module.
    • permissions: Array of permission strings requested (e.g., ["system.user.read"]).
    • menus: Navigation structure injection.
    • entities: Glob patterns for ObjectQL files (e.g., ["./src/schema/*.gql"]).
    • extensions: Extension points (e.g., contributions to the UI).
  1. Directory Conventions (Law of Location)
    You define "Where things must be". Hardcode these paths so CLI and Runtime match perfectly.
  • File: src/constants/paths.ts
  • Rules:
    • Schemas MUST be in src/schemas.
    • Server triggers MUST be in src/triggers.
    • Client pages MUST be in src/client/pages.
    • Assets MUST be in assets.
  1. Runtime Interfaces (The Contract)
    You define the interface that every plugin must implement to be loaded by ObjectOS.
  • File: src/types/plugin.ts
  • Interface: ObjectStackPlugin
    • onInstall(ctx: PluginContext): Promise
    • onEnable(ctx: PluginContext): Promise
    • onDisable(ctx: PluginContext): Promise
  • Context: PluginContext
    • Must expose ql (ObjectQLClient), os (ObjectOSKernel), logger.
  1. Coding Rules for AI
    A. Zod First Strategy
    When defining schemas (like the Manifest), ALWAYS use Zod first.
  • Why: Zod allows us to infer the TypeScript type (z.infer) AND generate the JSON Schema for the VS Code extension/CLI validator from a single source of truth.
    B. Universal Compatibility
  • The code generated here must run in Node.js (CLI/OS), Browser (Studio/UI), and Electron.
  • Do not import Node.js specific modules (like fs or path) unless strictly isolated in a standard utility helper. Ideally, keep it pure JS/TS.
    C. Documentation is Code
    Since this is the protocol, every interface property must have TSDoc comments (/** ... */). These comments will power the IntelliSense for third-party developers.
  1. Mock Examples (Reference)
    Example: Defining the Manifest Schema (Zod)
    import { z } from 'zod';

export const ManifestSchema = z.object({
id: z.string().describe("Unique package identifier (reverse domain style)"),
version: z.string().regex(/^\d+.\d+.\d+$/),
type: z.enum(['app', 'plugin', 'driver']),
menus: z.array(z.object({
label: z.string(),
path: z.string(),
icon: z.string().optional()
})).optional()
});

export type ObjectStackManifest = z.infer;

Example: Defining Directory Constants
export const PKG_CONVENTIONS = {
// The Source of Truth for where the Engine looks for files
DIRS: {
SCHEMA: 'src/schemas',
SERVER: 'src/server',
CLIENT: 'src/client'
},
FILES: {
MANIFEST: 'objectstack.config.ts',
ENTRY: 'src/index.ts'
}
} as const;</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits January 18, 2026 08:52
Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
Copilot AI changed the title [WIP] Set up Copilot instructions for ObjectStack Implement ObjectStack protocol specification with Zod schemas and TypeScript interfaces Jan 18, 2026
Copilot AI requested a review from huangyiirene January 18, 2026 08:57
@huangyiirene
huangyiirene marked this pull request as ready for review January 18, 2026 09:20
@huangyiirene
huangyiirene merged commit a116aef into main Jan 18, 2026
Copilot AI added a commit that referenced this pull request Jan 25, 2026
- Added Chinese meta files for all website protocol sections
- Updated references meta files to include website protocol
- Updated README to document the 6 core protocol modules
- Added Website Protocol as module #3 with preview release date March 2026

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
xuyushun441-sys pushed a commit that referenced this pull request May 22, 2026
Introduces an opt-in path in ObjectStackProtocolImplementation.saveMetaItem
that writes overlay metadata through SysMetadataRepository.put instead of
the raw engine, so writes append to the change-log and emit HMR seq events.

Behavioural changes (all behind options.useRepositoryWritePath /
OBJECTSTACK_USE_REPOSITORY_WRITE_PATH=1):
- saveMetaItem request gained optional parentVersion (If-Match) and
  actor fields. ConflictError -> 409 metadata_conflict.
- Plural type aliases (views, dashboards, ...) normalized to singular
  before the repo's overlay-allowlist gate (rubber-duck #5).
- Object-registry mutation moved AFTER successful put() so a conflict
  does not leave the in-memory registry stale (rubber-duck #3 invariant
  test added).

Repo/test-fake fixes uncovered by rubber-duck review:
- SysMetadataRepository.put/delete now update/delete by row id because
  the engine's strict .update requires id or multi:true (rubber-duck #1).
- sys_metadata.checksum column widened from 64 -> 71 chars to hold the
  sha256: prefix produced by hashSpec() (rubber-duck #2).
- Three test fake engines extended to support both overlay-tuple and
  id-based where lookups.

333/333 objectql tests pass.

Deferred to PR-10d.4: REST plumbing for parentVersion/actor
(rubber-duck #6), race-window retry for omitted parentVersion
(rubber-duck #4), default flag flip + legacy path removal.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
xuyushun441-sys pushed a commit that referenced this pull request May 23, 2026
…s (PR #3)

Resolves the gap left by PR #2: cache + storage adapters accepted an
optional MetricsRegistry but their respective Plugin classes never
forwarded one, so any host that registered observability via the
dispatcher saw zero cache/storage data.

Adds:

  packages/observability/src/service-names.ts
    OBSERVABILITY_METRICS_SERVICE = 'observability:metrics'
    OBSERVABILITY_ERRORS_SERVICE  = 'observability:errors'

  packages/runtime/src/observability/observability-service-plugin.ts
    ObservabilityServicePlugin — registers the host's MetricsRegistry
    and ErrorReporter under the canonical names. Defaults each to its
    respective Noop exporter so the services are always present.
    Also exports resolveMetrics() / resolveErrorReporter() helpers for
    consumers inside the runtime package.

CacheServicePlugin + StorageServicePlugin:
  - new `metrics?: MetricsRegistry` option (escape hatch for tests)
  - canonical resolution chain at init():
      option override → observability:metrics service → NoopMetricsRegistry
  - StorageServicePlugin's `buildAdapterFromValues` (the settings
    live-rebuild path) now also threads metrics into the freshly built
    adapter, so adapter swaps don't drop instrumentation
  - log line now reports the resolved registry class name for diagnostics

Helpers (resolveMetrics) are inlined as private functions in each
service to avoid a circular dep (services must not depend on runtime).
Constants live in @objectstack/observability which both services
already depend on.

New tests:
  - cache-service-plugin.metrics.test.ts (4 tests, resolution chain + override precedence)
  - storage-service-plugin.metrics.test.ts (4 tests, incl. settings-rebuild path)
  - observability-service-plugin.test.ts  (3 tests, registration + defaults)

All 22 service-cache + 48 service-storage + 282 runtime tests pass
(2 pre-existing i18n failures in app-plugin.test.ts on main unchanged).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
xuyushun441-sys pushed a commit that referenced this pull request May 29, 2026
…s/skills

Persist package enable/disable (#2):
- SchemaRegistry.setInitialDisabledPackageIds() seeds a disabled-id set that
  installPackage honors, so every registration path (boot artifact, marketplace
  rehydrate, local import) applies persisted disable uniformly — no fragile
  post-boot reapply hook.
- New runtime/package-state-store.ts persists the disabled set to
  <OS_HOME>/package-state/<environmentId>.json, keyed per environment.
- AppPlugin.init seeds the registry before the manifest is decomposed.
- handlePackages enable/disable persist the new state.

Round-trip tools/skills on export & import (#3):
- PLURAL_TO_SINGULAR (spec) gains tools->tool, skills->skill (drives export
  via assemblePackageManifest and the auto-derived reverse map).
- engine.registerApp metadataArrayKeys consume tools/skills on import.
- metadata ARTIFACT_FIELD_TO_TYPE gains tools->tool (skills already present).
- ObjectStackDefinition gains a top-level tools field beside agents/skills.
Covers metadata round-trip/visibility; executable ToolRegistry wiring is out
of scope.

Docs: ADR-0016 §§9.5–9.8 updated (disable now persists; tools/skills round-trip).

Verified live: disable -> restart -> stays disabled & app hidden; enable
clears state & app returns. registerApp materializes tools/skills.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
xuyushun441-sys added a commit that referenced this pull request Jun 1, 2026
* feat(spec): structured plugin manifest schema (ADR-0025 F1)

Extend ManifestSchema with the authoritative plugin-distribution shapes
so the cloud control plane can drop its stopgap mirror and import the
canonical schemas.

- PluginPermissionsSchema: structured { services, hooks, network, fs }
  (.strict()); ADR-0025 §3.2
- PluginEnginesSchema: { platform, protocol } (protocol-first, §3.10 #3)
- PluginRuntimeSchema: node | sandbox | worker (trust tier, §3.6)
- PluginPackagingSchema: bundled | manifest-deps (§3.3)
- PluginIntegritySchema: Record<path, digest> (§3.2)

ManifestSchema.permissions becomes a backward-compatible union of the
legacy string[] and the structured block; new optional runtime /
packaging / integrity / engines fields added. Legacy engine:{objectstack}
retained and superseded by engines.

Shapes match cloud's stopgap (service-cloud/src/plugin-artifact.ts) so
cloud's swap is a one-line import from @objectstack/spec/kernel.

Verified: tsc clean, 6609 spec tests pass, exports surface in
dist/kernel, runtime parse smoke (legacy + structured + strict reject).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* feat(cli): `os plugin build` + .osplugin packaging (ADR-0025 F2)

Add the build half of the plugin distribution pipeline (ADR-0025 §3.4):

- src/utils/osplugin.ts — dependency-free packaging primitives:
  - sriDigest(): canonical per-file integrity string `sha256-<base64>`
    (matches ADR §3.2's example; the format cloud/runtime align to).
  - computeIntegrity(): builds the manifest `integrity` map (excludes the
    manifest itself + SIGNATURE; deterministic key order).
  - createTar()/createTarGz(): reproducible ustar+gzip writer (mtime pinned
    to 0, sorted entries) so any tar reader can unpack the artifact and
    identical inputs yield byte-identical blobs.

- src/commands/plugin/build.ts — `os plugin build`:
  1. validate objectstack.plugin.json against the canonical ManifestSchema
     (@objectstack/spec/kernel — F1), failing fast with zod diagnostics;
  2. esbuild-bundle the entry to dist/index.mjs, externalizing
     @objectstack/* (and declared deps for packaging: manifest-deps);
  3. compute per-file integrity + emit the compiled manifest;
  4. pack dist/ (+assets, +package.json/lockfile for manifest-deps,
     +SIGNATURE placeholder) into <id>-<version>.osplugin.

Signing is a separate step; this emits an unsigned artifact.

Tests (6, all green; full CLI suite 143 green): SRI vector, integrity
exclusion+ordering, ustar round-trip with valid checksums, gzip validity,
reproducibility, and an end-to-end build that bundles a fixture plugin and
reads the .osplugin back — exercising F1's schema through the CLI.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* feat(core,cli): Ed25519 plugin signature contract + `os plugin sign` (ADR-0025 F3)

Land the canonical signature half of the plugin distribution pipeline,
byte-for-byte aligned with the cloud control plane's package-signing so
the two never drift.

core/src/security/plugin-artifact-signature.ts — the shared Ed25519
detached-signature contract:
  - format `ed25519:<keyId>:<base64url>`; sign/verify via node:crypto
    (`sign(null,…)`/`verify(null,…)`), keyId as the rotation handle.
  - verifyPublisherSignature(): publisher sig over raw artifact bytes,
    keyId-resolved key, mirroring cloud's publish-time policy
    (no sig → unverified-but-ok; malformed/unknown-key/mismatch → not ok).
  - counterSignPayload()/verifyPlatformSignature(): platform counter-sign
    over [package_id, version, blob_key, signature].join("\n") — identical
    to cloud's payload.
  - verifyPluginArtifact(): runs both trust chains at load time
    (ADR §3.7); requirePlatform=false for first-party/local builds.
  Exported from @objectstack/core/security.

cli plugin/sign.ts — `os plugin sign <artifact> --key <pem> [--key-id]`:
  detached publisher signature over the EXACT artifact bytes (the bytes
  cloud verifies at publish), written to a `<artifact>.sig` sidecar, with
  a self-verify guard. Completes build → sign → publish.

plugin-loader.ts: replace the placeholder verifyPluginSignature with an
honest check — artifact-bytes/counter-sign verification belongs at
materialize time (no artifact bytes exist at loadPlugin()), so the loader
now validates signature well-formedness via parseSignature and fails fast
on a malformed value, pointing at verifyPluginArtifact for the real chains.

Verified: core 269 tests (incl. 14 signature: format, determinism, tamper,
cloud-contract alignment, publisher policy, counter-sign, combined chains,
KeyObject), cli 138 (incl. build→sign→verify e2e against the exact bytes).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* feat(core): enforce install-time granted_permissions (ADR-0025 F4)

Bridge the cloud control plane's persisted consent into runtime
enforcement. `PluginPermissionEnforcer.registerGrantedPermissions()` and
`buildPermissionsFromGrants()` turn the structured grant set cloud writes
to `sys_package_installation.granted_permissions`
(`{ services, hooks, network, fs }`, ADR §3.2) into the runtime
`PluginPermissions` bag that `SecurePluginContext` checks.

Matching: exact value, glob (`*` / `**`), or wildcard `*`; network grants
match the request URL's host; `fs` governs read and write; a null/empty
grant set denies everything (least privilege). This enforces what was
GRANTED at install, not merely what the manifest declared — the right
default for distributed third-party plugins.

Verified: 6 new tests (service/hook/fs/network matching, least-privilege
default, enforcer + SecurePluginContext gating); full core suite 275 green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* feat(spec): plugin fields on uploadArtifact contract (ADR-0025 F5)

Extend UploadArtifactInput/Result so the IPackageService upload path
carries code-bearing `.osplugin` plugins alongside metadata packages,
aligned with the cloud control plane's publish flow:

- Input: `kind` ('metadata' | 'plugin'), detached `signature`
  (`ed25519:<keyId>:<base64url>`), `expectedChecksum` (artifact sha256).
- Result: `versionId`, `listingStatus` (e.g. pending_review), and
  `signatureVerified`.

All additive + optional — metadata packages are unaffected.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

---------

Co-authored-by: Jack Zhuang <277994282+os-zhuang@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This was referenced Nov 27, 2026
Nenzyz pushed a commit to Nenzyz/objectstack that referenced this pull request Dec 1, 2026
…bjectstack-ai#37841)

<!-- claude-projects-attribution: {"github_login":"os-sales"} -->
_Requested by **Sales** · [project
thread](https://claude.ai/code/project/chan_01D5bWFY3rFzgJcytD5gD4Uu?thread=cmsg_01D5bWFY3rFzgJcytD5gD4UuNTptyd1j97p7dHXZLEeH2g)_

Fixes objectstack-ai#37796

Clause-②: no
Metadata-protocol: none

## 维护者速读

- 用户能看到什么变化:照我们技能包写应用的 AI 助手,以后在代理的模型配置里只写模型名,不再写“提供方”这一项;想用哪家提供方,到部署的
AI 设置里打开。
- 为什么做:“提供方”这一项今天已经退役,写了会被平台拒收,而对外发布的技能页还在教它;这是那次退役欠下的技能页跟进。
- 出错会怎样:只改教学文字和一道评测题,运行时不变;最坏是 AI 助手照旧文字给出过时写法,把文字改回即可撤回。
- 要你做什么:这是对外发布的技能包,需要你批准后才能合并。

## What changes

- **`skills/objectstack-ai/SKILL.md`, Model Configuration.** The
`provider` row leaves the agent model table. The paragraph above the
table now says the `model` block names a model and never a provider: the
deployment's AI settings choose the provider and match the model name
among the providers turned on, and a written `provider` is a parse error
whose fix is to delete the key (retired in protocol 19). The `model`,
`temperature` and `maxTokens` / `topP` rows are untouched.
- **The schema citation in the same paragraph** moves from
`packages/spec/src/ai/agent.zod.ts:37-45` to `:87-95`. PR objectstack-ai#37783 added
50 lines above the key list, so the old range pointed into a comment
block. `:87` is the `provider` tombstone and `:95` is `topP`.
- **`skills/objectstack-ai/evals/skills-tools-knowledge.json`, case 2.**
The prompt is unchanged: a copilot that should use Anthropic at
temperature 0.3 with a 2000-token cap. The expected answer now writes no
provider key, puts sampling under `model`, names the model in the
free-string `model` or leaves it to the host's default, and sends the
choice of Anthropic to the deployment's AI settings. `must_contain` goes
from `provider`, `anthropic`, `temperature`, `maxTokens` to
`temperature`, `maxTokens`, `deployment`. `must_not_contain` goes from
empty to the written line `provider: 'anthropic',`.
- **`.changeset/37796-skills-agent-model-provider-retired.md`**: one
`@objectstack/skills` patch.
- **`.changeset/37711-skills-agent-model-optional.md`**: a DELIBERATE
CORRECTION, declared below.

## Why

PR objectstack-ai#37783 (merge `f07d63a5`) retired an agent's `model.provider`. The
published skill still listed the key with its enum, and eval case 2
graded an answer as correct only when it wrote `provider`. An AI that
follows the skill would write a key the platform now refuses.

The Model Registry's own provider list (`ModelProviderSchema`) is a live
key and this PR does not describe it. Its only mention in the bundle was
inside the removed row.

## DELIBERATE CORRECTION

`Check Changeset` is red on purpose: this PR edits a pending release
note it did not add, `.changeset/37711-skills-agent-model-optional.md`
(from PR objectstack-ai#37765). That note ships in the same release as this change,
and two of its sentences would be false on release day.

Title, before:

> docs(skills): an agent's model name and provider are optional

Title, after:

> docs(skills): an agent's model name is optional

Body, before:

> `skills/objectstack-ai/SKILL.md` (Model Configuration) now teaches
that `model.model` is optional, and that an agent without one runs on
the host's default model for the environment, and that `model.provider`
is optional with no default (the deployment's choice) instead of
defaulting to `openai`. The inline enum list is unchanged, and the
schema citation now points at `packages/spec/src/ai/agent.zod.ts:37-45`.
The `objectstack-ai` eval case on sampling settings accepts an omitted
`model` and states the provider has no default. Published prose only: it
teaches the optional `model` / `provider` already on main since objectstack-ai#37697.

Body, after:

> `skills/objectstack-ai/SKILL.md` (Model Configuration) now teaches
that `model.model` is optional, and that an agent without one runs on
the host's default model for the environment. It no longer says
`model.provider` defaults to `openai`; the key itself leaves the page in
the same release (see the changeset on the skill no longer teaching
`model.provider`). The `objectstack-ai` eval case on sampling settings
accepts an omitted `model`. Published prose only: it teaches the
optional `model` already on main since objectstack-ai#37697.

The note's last sentence (the token budget) is unchanged. The precedent
is PR objectstack-ai#37783 itself, which corrected
`.changeset/37686-agent-model-name-optional.md` the same way.

## Tests

### Skill eval run (recorded)

`pnpm --filter @objectstack/scenarios skill-evals --skills
objectstack-ai --repeats 3 --concurrency 4`, on head `fb8b3f20`. 12
cases, 2 arms, 3 repeats: 72 of 72 turns ran in 8 min, none out of the
denominator. Subscription login, no API key, CLI 2.1.332, the login's
default model and effort.

| case | with-skill | no-skill |
|:--|--:|--:|
| **case 2 (this PR)** | **3/3** | **0/3** |
| bundle, all 12 cases | 30/36 (83%) | 1/36 (3%) |

Case 2, read answer by answer: all three with-skill answers put
`temperature` and `maxTokens` under `model`, write no provider key, and
send Anthropic to the deployment's AI settings. All three no-skill
answers write `provider: 'anthropic',` inside the `model` block, which
is the refused spelling.

<details>
<summary>Per-case table, round 2 (head fb8b3f2)</summary>

| case | with-skill | no-skill | with-skill missed | with-skill carried
forbidden |
|:--|--:|--:|:--|:--|
| objectstack-ai#1 | 3/3 | 1/3 |  |  |
| objectstack-ai#2 | 3/3 | 0/3 |  |  |
| objectstack-ai#3 | 3/3 | 0/3 |  |  |
| objectstack-ai#4 | 3/3 | 0/3 |  |  |
| objectstack-ai#5 | 2/3 | 0/3 | `aiExposed` |  |
| objectstack-ai#6 | 1/3 | 0/3 | `signed-in session` `refused` |  |
| objectstack-ai#7 | 0/3 | 0/3 | `do not retry` |  |
| objectstack-ai#8 | 3/3 | 0/3 |  |  |
| objectstack-ai#9 | 3/3 | 0/3 |  |  |
| objectstack-ai#10 | 3/3 | 0/3 |  |  |
| objectstack-ai#11 | 3/3 | 0/3 |  |  |
| objectstack-ai#12 | 3/3 | 0/3 |  |  |

</details>

<details>
<summary>Round 1 (head 789e0c7) and why the forbidden token
changed</summary>

The first commit graded case 2 with `must_not_contain: ["provider:"]`.
Round 1 scored it 1/3 with-skill. The two failing answers were correct:
each wrote no provider key and named the retired spelling only to warn
against it ("writing `provider: 'anthropic'` now fails to parse"). A
bare `provider:` graded that warning as a failure. The second commit
narrows the token to the object-literal line `provider: 'anthropic',`
(with its trailing comma), which a warning in prose does not carry and
every no-skill answer in round 2 does. The three round 1 with-skill
answers pass under the final tokens when read by hand.

Round 1's no-skill arm is not a clean baseline for case 2. The turns
inherited this container's project-memory variables, and all three
no-skill answers quoted the team's notes on the retirement. Round 2 was
started with `CLAUDE_COWORK_MEMORY_PATH_OVERRIDE` and
`CLAUDE_MEMORY_STORES` unset, and no case 2 answer mentions memory.

</details>

Cases 5, 6 and 7 are not touched by this PR. Their with-skill misses are
literal-phrase misses in both rounds and are listed under Acceptance
notes.

### Local gates, on head `fb8b3f20`

`node scripts/pm/dispatch-gates.mjs --commands` derived 49 families for
this diff. `--ran` reconciliation: 49 derived, 48 run, 1 NOT-MEASURED, 0
unrun.

- 47 exit 0, among them `check-skills-token-ratchet` (and its
self-test), `check:skill-identifier-liveness`, `check:skill-links`,
`check:skill-compatibility`, `check:skill-frame-sync`,
`check:pm-skill-id-lint`, `check:doc-authoring`, `check:nul-bytes`,
`check:published-files` and `@objectstack/spec` `check:skill-docs`.
- `node scripts/check-empty-changeset.mjs --base origin/main` exit 1:
the DELIBERATE CORRECTION above. It names
`.changeset/37711-skills-agent-model-optional.md` and nothing else.
- `pnpm check:dual-build-cjs-loads` exit 3, NOT MEASURED: it needs a
full `pnpm build`, and this container built only the scenario runner's
closure. CI runs it.
- Outside the derived set, also exit 0: `@objectstack/spec`
`check:skill-refs` and `check:skill-served-sections`.

### Size readings (`skills/**`)

| reading | before | after |
|:--|--:|--:|
| `skills/objectstack-ai/SKILL.md`, lines | 485 | 487 |
| `skills/objectstack-ai/SKILL.md`, tokens | 6801 | 6801 (ceiling 6801,
no row moved) |
| all `skills/*/SKILL.md`, lines | 4960 | 4962 |
| `evals/skills-tools-knowledge.json`, tokens (measured, not ratcheted)
| 3359 | 3411 |
| bundle total, tokens | 301302 | 301354 |

The new sentences in `SKILL.md` are paid for by the deleted row. The
bundle total grows by the eval fixture alone.

## Acceptance notes

- The branch is the harness-assigned `claude/project-thread-2rm2nh`, not
`claude/issue-37796-…`.
- The skill's `description` still lists "configuring an LLM provider"
among its triggers. Left as is: a user who asks that is now told where
the provider is chosen. Changing it would move when the skill loads,
which this card does not ask for.
- `SKILL.md:457` cites `packages/spec/src/ai/agent.zod.ts:234, :251` for
the `agent.tools` / `agent.knowledge` tombstones. Those lines did not
hold the tombstones before PR objectstack-ai#37783 either, so this PR leaves the
citation alone. Noted, not filed.
- Eval cases 6 and 7 miss literal phrases (`signed-in session`,
`refused`, `do not retry`) on the with-skill arm in both rounds, case 7
in all six turns. That reads as a grading-token question on those cases,
not as something this diff moved. Noted for the seat.
- The eval runner passes its whole environment to each turn, so a round
started inside a project container carries that project's memory into
both arms. Noted for the seat with the round 1 records as evidence.

## Verification

Read first, by risk:

1. `skills/objectstack-ai/SKILL.md`, the hunk under `## Model
Configuration`: three new sentences that ship to every customer install.
2. `skills/objectstack-ai/evals/skills-tools-knowledge.json`, case 2:
the token lists.
3. `.changeset/37711-skills-agent-model-optional.md`: the corrected
note.

Two-minute check: `sed -n '84,96p' packages/spec/src/ai/agent.zod.ts`
shows `provider: retiredKey(...)` at `:87` and `topP` at `:95`, the
range the skill now cites, and `node
scripts/check-skills-token-ratchet.mjs` prints
`skills/objectstack-ai/SKILL.md is 6801 tokens (ceiling 6801; headroom
0)`.

## Human Minimum

- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
(No schema change.)
- [x] 2. Every name I added uses the casing for its kind. (No name
added.)
- [ ] 3. No formatter ran. `pnpm lint` is read from CI on this
prose-only diff.
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset.
- [x] 6. `packages/spec` is not touched.
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English.
- [ ] The *Before Submitting* list in CONTRIBUTING.md: lint and the test
jobs are read from CI; the rest is done.

---
_Generated by [Claude
Code](https://claude.ai/code/session_01L6bhgUjtV7ahUH66wxpMk7)_

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01L6bhgUjtV7ahUH66wxpMk7

---------

Co-authored-by: Claude <noreply@anthropic.com>
Nenzyz pushed a commit to Nenzyz/objectstack that referenced this pull request Dec 1, 2026
…ipped vs run-time mount, package-scoped identity) (objectstack-ai#38053)

repo:objectstack#1 · os-elon-musk · session_016WV4cwPhGV4g9p1BGQaZbP

Part of objectstack-ai#37310

Clause-②: no
Metadata-protocol: none

## 维护者速读

- 用户能看到什么变化:用 AI(技能文档或 MCP 搭建)写知识源的作者,现在看到的是新写法:知识源是一份元数据,用
`name`、逐个列出要索引的字段、可以不写存储;MCP
新建知识源暂不提供起始模板(模板里的占位对象和字段会被当成真实值存进去),等设置页表单从作者输入构建 `source` 后再加。
- 为什么做:知识库检索专题(按调用者权限过滤的知识检索)第三阶段的教学一行,替照着技能写知识源的 AI 解决"照文档写出来却被拒绝"的问题。
- 出错会怎样:最坏是技能里某句教法不准,AI 写出的知识源在保存时被明确拒绝并给出修法;不会悄悄索引错的字段;改动可直接撤回。
- 要你做什么:合并(技能文档是受治理面,由你亲手落地);本 PR
只完成卡片的一部分:发布校验的五条规则名要等对应的校验改动(objectstack-ai#37971)合并后再补,新建模板要等设置页表单,所以卡片保持打开。

## What changes

**`skills/objectstack-ai/SKILL.md`, § Knowledge Sources (RAG)**
(ADR-0161 K4, K5, K6 item 6; rows 3a and 3b as merged):

- A source is a `knowledge_source` item: shipped in a package
(`knowledgeSources`, `*.knowledge-source.ts` / `.yml`) or authored in
Studio or over MCP. `KnowledgeServicePlugin({ sources })` and
`registerSource` are a second door for the same schema, and a code
registration and an environment item of one name are one slot, the
second refused. A source's identity is its package and `name`:
`search_knowledge` lists a package's source as `NAMESPACE-NAME` (bare
for a source no package holds). A shipped item (a `knowledgeSources`
entry) mounts the knowledge service and its store with no `requires:
['knowledge']` (objectstack-ai#37306, PR objectstack-ai#38026); an app that ships no source and
authors its sources at run time needs `requires: ['knowledge']`, or its
items are never indexed (as main's `knowledge-rag.mdx` § Turning it on
says).
- The key table is the v1 keys of K4: `name`, `label` / `description`,
`adapter` (optional; omitted ⇒ the deployment's store, else the only one
registered, refused naming them when several and none is the
deployment's), `source.kind`, `source.object`, `source.content` (an
explicit non-empty list; why `'*'` is refused: embedding is egress, K5),
`source.metadataFields`, `source.where`, `source.split`,
`refresh.onRecordChange`, `aiExposed`. The old Hygiene column's advice
(meaningful text only, never ids or system fields; `where` keeps drafts
out) now lives in the `content` and `where` rows, and says `content`.
- Egress and cost (K4): the first build sends every listed field of
every matching record to the embedding provider; a run-time save needs
`manage_knowledge_sources` beside `manage_metadata` and passes save-time
admission.
- The retired keys by name, each with its fix, as the tombstones read:
`id` → `name`, `contentFields` → `content`, `embedding`, `vectorStore`,
`adapterConfig`, `refresh.cron`, and the `file` / `http` arms with their
four keys; `os migrate meta --from 18` for a stack, by hand for a
registration in code.
- The checked example drops `adapter: 'pgvector'` (the deployment's
store) and its comments; it is otherwise row 3a's block.
- `split`: `strategy` is required once `split` is written (`recursive`
only when `split` is omitted); the adapter-list aside is gone.
- The closing note: `topK` is a `search_knowledge` argument; rerank and
hybrid weighting are no source key, and no shipped store has a setting
for either (`knowledge-pgvector` and `knowledge-turso` fuse their legs
by RRF with a fixed `RRF_K = 60`, `pgvector-adapter.ts:124`,
`turso-adapter.ts:95`; no store plugin's options interface has a rerank,
weight or fusion key).
- The routing line in `skills/objectstack-mcp-build/SKILL.md` ("An agent
skill, tool or knowledge source | objectstack-ai") stays true: the
section name is unchanged, so it is not edited.

**Not in this PR, on purpose (amendments 7221575164 and 7224082428):**
the five `os validate` / publish rule ids of PR objectstack-ai#37971
(`knowledge-source-object-unknown`, `knowledge-source-field-unknown`,
`knowledge-source-object-not-searchable`,
`knowledge-source-system-object-not-ai-readable`,
`knowledge-source-field-never-indexed`). objectstack-ai#37971 is still open, so this
PR is `Part of objectstack-ai#37310`: that part follows on this branch after objectstack-ai#37971
lands (the keyword then returns to `Fixes`), or on a later PR if this
one lands first. The create seed is also left open: it waits for the
Studio form (objectstack-ai#37309, row 5).

**`skills/objectstack-ai/evals/skills-tools-knowledge.json`.** Case 3
(kb_article on PostgreSQL) and case 9 (policy_doc, `markdown` split) now
expect `name` and `content`, and forbid a written `contentFields:` key;
case 3 also forbids a written wildcard (`['*'],`, `['*'] }`),
`embedding:` and `vectorStore:`, and its `topK` token becomes `topK:`
(the key written) because the skill now names `topK` as a search
argument. Case 9 also requires `name:` and forbids an `id:` spelling;
case 13 forbids the double-quoted wildcard forms. New case 14 asks for
an app that ships no source and authors one at run time, and requires
the `requires: ['knowledge']` line (either quote style), with no
`contentFields:`. New case 13 asks for a source that indexes "every text
field" and expects an explicit list, the wildcard declined because
embedding is egress, and no written `contentFields:` or wildcard.

**`packages/spec/src/kernel/metadata-create-seeds.ts`: unchanged
(byte-identical to `main`).** A `knowledge_source` create seed was tried
and withdrawn at `4c965f4a5e` (comment 7229668414). Its object binding
and content list sit inside `source`, and the Studio create flow
(`buildCreateModeBody` / `seedPlaceholderKeys` in app-shell's
`createBody.ts`) clears placeholder identity at the top level only, so
it would have saved `example_object` / `example_field` into a new
source: the objectui#12810 defect. No schema-valid seed avoids this,
because `source.object` and a non-empty `content` (K5) are required and
nested. `knowledge_source` stays on `KNOWN_UNSEEDED`, whose comment now
gives the reason: a seed waits until the Studio form (objectstack-ai#37309, row 5)
builds `source` from the author's input. The card allows this ("or the
type stays on `KNOWN_UNSEEDED` with the reason").

**`packages/runtime/src/domains/mcp-authoring.test.ts`.** One case
beside the flow contract case, over the real protocol and the boot type
registry: `list_metadata_items` with `contract: true` for
`knowledge_source` serves no `createSeed`; `contractPath`
`/properties/source/properties/content` serves the content rule
(`minItems: 1`, `minLength: 1`, a pattern that refuses `*` and admits
`body`); the served schema carries no `id` or `contentFields` tombstone;
a hand-written source with one object and one field saves as a draft;
the same item with `content: ['*']`, with an `id`, or with
`contentFields` is refused `422 INVALID_METADATA`, the last two naming
their tombstone's prescription ("use `name`", "use `content`"); nothing
else is written.

**Platform catalog (review round, `6f2e756f58`).** The generator's Boot
cell (`packages/spec/scripts/lib/platform-catalog.ts`) reads ``on
`requires`, or a shipped `knowledgeSources` item`` for a provider that
declares `mountedBy`; `packages/spec/scripts/platform-catalog.test.ts`
pins that cell, with `record-context` as the control that still reads
``on `requires` ``.
`skills/objectstack-project/references/platform-catalog.md` is
regenerated.

**Token ratchet.** The standing ruling, verbatim and untranslated:
「A:先削重复,余额按实测提高」 (ruling record 6513306068, letter B). Paid down first,
in the same file: the wiring paragraph's package list, the old
`source.kind` Hygiene column (folded into two rows), the example's four
comments restating table rows and its `refresh: { onRecordChange: true
}` line restating the default, and the split passage's adapter aside.
The row moves 6609 → 6639, the measured remainder, pinned at the
measurement. Review round (`6f2e756f58`): after paying down the intro's
restating clause, its separate `search_knowledge` sentence, the "one
name is one source" clause and the longer closing note, the row moves
6639 → 6695 (+56, the measured remainder) under the same ruling.
Reproduction: `ceil(($(wc -c < skills/objectstack-ai/SKILL.md) - 27) /
4)` = ceil(26779 / 4) = 6695.

## Tests

**Review round at `6f2e756f58`** (merges `main` at `58be6770ab`; note
7230668192): unlocked, 35 commands, each exit 0, including
`check-skills-token-ratchet` (row 6695), `check:nul-bytes`,
`check-empty-changeset`, `check-adr-0087-registration`,
`check-changeset-no-major`, `check:issue-citations`,
`check:doc-authoring`, `check:skill-links`,
`check:skill-identifier-liveness`, `check:skill-frame-sync`,
`check:published-files`; `gen:skill-refs` exit 0. NOT MEASURED locally
(verify lock never acquired in six tries): `check:skill-docs`,
`check:skill-refs`, `check:yaml-examples`, the platform-catalog test,
`metadata-create-seeds.test.ts`, the MCP contract case, eval case 14. CI
on this head is the reading for them. overlap-check: `VERDICT overlap
exit 1`, the same objectstack-ai#36158-against-main conflict in the ratchet file;
`origin/main`, objectstack-ai#38032 and objectstack-ai#38013 merge cleanly.

The lock was saturated: about 70 minutes of queueing, two dogfood runs
ahead. One locked round ran at `3407f7fe6e`; the second round was not
reached. What was not measured locally is marked below, and CI runs it.

<details><summary>Locked round at 3407f7f (VERDICT command-exit 0,
held 365s)</summary>

- `pnpm turbo run build --filter='@objectstack/runtime^...'
--concurrency=2`: exit 0, `Tasks: 41 successful, 41 total`.
- `metadata-create-seeds.test.ts` (spec): the seed pin run here (`Tests
20 passed (20)`) belonged to the withdrawn seed; the file is back to
`main`'s, so CI `Test Core` is the reading. **Patch round at
`4c965f4a5e`:** the app-shell
`createBody.seedPlaceholders-12810.test.ts` (red at `19f3e118f2`, 2
failures, unedited), the spec create-seeds test and the rewritten MCP
case are NOT MEASURED locally (verify lock saturated); their inputs
equal `main`'s, so CI `Test UI` and `Test Core` on this head are the
evidence. Unlocked gates at `4c965f4a5e`, exit 0 each:
`check-skills-token-ratchet` (6639/6639), `check-empty-changeset`,
`check-adr-0087-registration`, `check-changeset-no-major`,
`check:nul-bytes`, `check:issue-citations`, `check:doc-authoring`. The
changeset no longer lists `@objectstack/spec`.
- `pnpm --filter @objectstack/runtime exec vitest run --maxWorkers=2
src/domains/mcp-authoring.test.ts`: exit 1, `Tests 1 failed | 73 passed
(74)`. The failing assertion is the new case's tombstone half: it
expected the served schema to carry `/properties/id`, and the served
schema drops tombstones (see Acceptance notes). Its content-rule and
seed assertions, which run before it, passed. The tombstone half is
rewritten in `01cf7515c2` to assert absence plus the save refusal. **NOT
MEASURED locally after that rewrite** (the second locked round never
acquired); CI `Test Core` runs it.
- `pnpm --filter @objectstack/spec run check:yaml-examples`: exit 0, `19
tagged YAML example(s) across 1 file(s) validate`.
- `pnpm --filter @objectstack/spec run check:skill-docs`: exit 0, `Skill
docs in sync`.
- `pnpm --filter @objectstack/spec run check:skill-refs`: exit 0, `10
generated files in sync with packages/spec`. The generated skill
references needed no regeneration: the section rewrite changes no
reference input.
- `pnpm --filter @objectstack/spec typecheck`: exit 0.
- `pnpm --filter @objectstack/runtime typecheck`: exit 1. `tsc --noEmit`
is clean. `check:test-typecheck` names 3 files this diff does not touch
(`boolean-written-spelling-row-scope.test.ts`,
`meta-object-publish-column-changes.test.ts`,
`organization-ownership-boot-guard.turso-remote.kernel.test.ts`).
`mcp-authoring.test.ts` is not among them. They are read here as the
closure build's gaps (only `runtime^...` was built) and not as this
diff's; CI `TypeScript Type Check` decides.
- `pnpm --filter @objectstack/spec run check:skill-examples`: exit 3,
PREREQUISITE NOT MET (the `@objectstack/client-react` dist is outside
the built closure). **NOT MEASURED**; CI runs it.

</details>

<details><summary>Unlocked gates (35 derived families, each exit 0, at
3407f7f; the ratchet and nul-bytes re-run at 19f3e11)</summary>

- `node scripts/check-skills-token-ratchet.mjs`: exit 0,
`skills/objectstack-ai/SKILL.md is 6639 tokens (ceiling 6639; headroom
0)`; with `--self-test` exit 0.
- Exit 0 each: `check-adr-0087-registration` (both forms),
`check-changeset-no-major`, `check-closing-keyword-parity` (both),
`check-declaration-mirrors` (both), `check-empty-changeset` (both),
`check-issue-citations`, `check-self-test-wired` (both),
`docs-audit/check-affected-docs`, `docs-audit/check-drift-comment`, and
`pnpm check:` `agent-test-spelling`, `changeset-gate-self-tests`,
`closed-ceremony-text`, `corpus-claim-drift`,
`cross-package-test-inputs`, `doc-authoring`, `issue-citations`,
`keyed-text-bounds`, `nul-bytes`, `pm-skill-id-lint`, `published-files`,
`ratchet-remedy-authority`, `role-word`, `skill-compatibility`,
`skill-frame-sync`, `skill-identifier-liveness`, `skill-links`,
`test-source-alias`, `tier-file-adoption`.
- `dispatch-gates --ran`: `116 derived, 38 run, 0 NOT-MEASURED, 78
UNRUN`. That is a declared narrowing: the lock was saturated, and CI
runs the 78.
- Local-only: `check-skill-frame-freshness` exit 0. `check-dev-prereqs`
exit 1 ("69 of 110 workspace packages … not on disk"), which is the
closure-only build and not a finding.

</details>

<details><summary>Eval runner and the ablation (`skill-evals`,
claude-code-cli 2.1.332, oauth login, served claude-opus-5-5)</summary>

Cases 3, 9 and 13 of `objectstack-ai/skills-tools-knowledge`, both arms,
one repeat each:

| skill text | objectstack-ai#3 with-skill | objectstack-ai#9 with-skill | objectstack-ai#13 with-skill | no-skill
(all three) |
|:--|:--|:--|:--|:--|
| this PR | pass | pass | pass | fail |
| `main`'s `SKILL.md` (`8d34c4404f`, hash `88a20cb583`), new cases
(ablation) | fail: `contentFields:` written; `name:`, `content:` missing
| fail: `contentFields:` written; `content:` missing | fail:
`contentFields:`, `['*'],` and `id: 'faq` written; no egress reason |
fail |

The ablation restored `main`'s `SKILL.md` into the working tree only
(`git restore --source=8d34c4404f`, `git hash-object` = `88a20cb583`).
The run ran, and then `HEAD`'s file came back (`fc845724ac` both on disk
and at `HEAD`). An earlier run of case 13 on this text failed with-skill
only on the token `['*']`, which a correct answer quoted while
explaining the refusal. The forbidden token is now the written wildcard
(`['*'],` / `['*'] }`), and the table above is after that change.

</details>

## Acceptance notes

- The acceptance grep (`git grep -n -E "contentFields|'\*'|adapter:
'ragflow'" skills/objectstack-ai`) returns eight lines. In `SKILL.md`,
three: the `content` row ("`'*'` is refused") and two lines of the
retired-keys paragraph. In the eval file, five: the reference answers of
cases 3 and 13, which name both as retired, and the `must_not_contain`
lists of cases 3, 9 and 13, which forbid a written `contentFields:` and
a written wildcard (`['*'],`, `['*'] }`). The card itself asks the eval
to fail on `contentFields` or `'*'`, which puts the forbidden token on
the assertion line. The reviewer decides whether those lines count as
"naming a retired key as retired".
- `adapter: 'ragflow'` has no hit: objectstack-ai#37004 already removed it.
- The new MCP pin is an `it` inside the existing real-protocol
`describe` of `mcp-authoring.test.ts`, beside the flow contract case,
because that describe holds the real-protocol harness (`realProtocol`,
`STUDIO_BASE`). It is in the shared harness file, not a new file.
- **Premise correction (card item 3).** The card asks the served
contract to carry "the tombstones' prescriptions as the describes read".
It does not, by design: the served JSON Schema drops every
`retiredKey()` tombstone (`{ not: {} }`; see the note in
`packages/metadata-protocol/src/protocol-meta-type-schema.ts`: the
served schema publishes what an author MAY write). The prescription
reaches an MCP author through the save refusal instead. The pin asserts
both halves: the tombstone is absent from the served schema, and a save
that writes the retired key is refused naming its replacement.
- The save half of the MCP pin covers row 3a's parse. Row 4's checks
(objectstack-ai#37971) are not on main, so a hand-written draft is not yet judged by
them here. Today the save passes with no knowledge service mounted ("no
knowledge service judges nothing").
- overlap-check before the PR: `VERDICT overlap exit 1`. `origin/main`,
objectstack-ai#38032 and objectstack-ai#38013 merge cleanly. objectstack-ai#36158 (a draft last updated
2026-11-25) conflicts in `scripts/check-skills-token-ratchet.mjs`. That
conflict is objectstack-ai#36158's own against `origin/main`: `git merge-tree
origin/main` with objectstack-ai#36158's head conflicts in the same file, and every
conflict hunk is at line 798 or later, away from this branch's hunk near
line 453. Reported here, not resolved.

## Verification

Files to read first, by risk:
1. `skills/objectstack-ai/SKILL.md` § Knowledge Sources (RAG): the
`adapter` and `content` rows and the retired-keys paragraph.
2. `packages/spec/src/kernel/metadata-create-seeds.test.ts`: the
`KNOWN_UNSEEDED` reason for `knowledge_source` (no seed;
`metadata-create-seeds.ts` is byte-identical to `main`).
3. `packages/runtime/src/domains/mcp-authoring.test.ts`: the new
contract case.

Two-minute check: `node scripts/check-skills-token-ratchet.mjs`. Expect
`skills/objectstack-ai/SKILL.md is 6695 tokens (ceiling 6695; headroom
0)`.

Readings: `skills/objectstack-ai/SKILL.md` 464 → 469 lines, 26462 →
26806 bytes (6609 → 6695 priced tokens, in two moves). Every published
`SKILL.md` summed: 4936 → 4941 lines, 261366 → 261485 bytes (65342 →
65372 tokens). The eval file is 125 → 137 lines and 13611 → 15185 bytes;
eval fixtures are measured, not ratcheted.

---

_Generated by [Claude
Code](https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP)_

---------

Co-authored-by: Claude <noreply@anthropic.com>
Nenzyz pushed a commit to Nenzyz/objectstack that referenced this pull request Dec 1, 2026
…iles become routers (objectstack-ai#38347)

<!-- claude-projects-attribution: {"github_login":"os-sales"} -->
_Requested by **Sales** · [project
thread](https://claude.ai/code/project/chan_01D5bWFY3rFzgJcytD5gD4Uu?thread=cmsg_01D5bWFY3rFzgJcytD5gD4UuUejT99q3PMj1DD6eNBk5Kd)_

Part of objectstack-ai#34770

Clause-②: no
Metadata-protocol: none

Supersedes draft PR objectstack-ai#36158: the same change, resumed from
`claude/issue-34770-skill-router-budget@937e2f1`
on a new branch after seat 4's lane went vacant, with `main` merged in
and the three eval cases of ruling 7176941587 Q1 B added. objectstack-ai#36158 can be
closed with a pointer here; nothing on its branch is missing from this
one.

`Part of`, not `Fixes`: rulings 7128031203 and 7168461386 keep the first
line at `Part of objectstack-ai#34770` until the catalog-size line of the card's
Done-when is met, and this PR does not meet it (the catalog descriptions
are not touched here).

## 维护者速读

- 用户能看到什么变化:用户无感。发给 AI 的两份技能说明(数据建模、自动化)的入口文件从约 27 KB、28 KB 缩到 9 KB、10.7
KB:入口只留开工前四项检查、会悄悄出错的坑、和「写什么去读哪个文件」的路由表,其余原文搬进同包的参考文件,教的内容不变。
- 为什么做:入口文件每次都整份装进 AI 的上下文,越长越贵、越容易漏读;缩成路由后,AI 只在需要时才读细节。
- 出错会怎样:只动教 AI 的文字和三道评测题的判分词,没有产品行为变化。风险是 AI 少读一段后答错;为此前后各跑了一轮评测,逐题对照(见
Tests)。可整笔撤回。
- 要你做的:座位复核后请审批人批准(`skills/**` 属 Tier H)。本 PR 合并后,云端仓库要按 #36934
把十一处托管章节的指向跟着改。

## Rulings this executes

- **7128031203** (①A ②A ④A): land as is, the hosted repoint is cloud's
(#36934); a before and an after eval round, parity = the after round's
failing set is the before round's or a subset, a flipped case is re-run
once and the second reading counts; a ceiling row raised because text
MOVED is accepted at the measured bytes with zero headroom when the sum
of ceilings does not rise.
- **7168461386** (A): six flow-shape facts go back into the automation
entry, and that one row rises by exactly the bytes restored.
- **7176941587** (Q1 B, Q2 A, Q3 A): three eval cases are relaxed first,
then both rounds are run; the 187 bytes of entry wording stay;
`triggers#6` is the eval seat's and is not touched here.

## What changes

**Two entry files become routers.** `skills/objectstack-data/SKILL.md`
26,860 → 8,983 bytes (472 → 167 lines),
`skills/objectstack-automation/SKILL.md` 28,206 → 10,703 bytes (480 →
215 lines). Each keeps four first checks, the traps that parse and then
fail at run time, and a table that says which file to open for what is
being written. No rule's teaching changes; the text moved, and the
changeset lists section by section where it went and which anchors no
longer exist in the entry files.

**Eight files receive the moved text**:
`objectstack-data/references/examples-objects.md`,
`rules/field-types.md`, `rules/relationships.md`, `rules/security.md`,
`rules/validation.md`;
`objectstack-automation/references/examples-flows.md`,
`references/integration-recipes.md`, and a re-pointed link in
`references/state-machines-and-approvals.md`.

**One correction** (unchanged from objectstack-ai#36158): the multi-value lookup note
showed a `{record.tags.0}` token "in flow values", which a flow value
slot refuses; it now shows the CEL spelling `record.tags[0]`.

**New in this round, over `937e2f14`:**

1. **`main` merged** (through `600197a6ae`; a merge commit, not a
rebase). Two things `main` changed in the entry files while objectstack-ai#36158 was
open were mapped onto the relocated text instead of being lost with the
old sections:
- objectstack-ai#37551's option-label wording. The automation entry's item 4 of §
Valid-but-silently-wrong keeps the rule and both outcomes (refused at
publish where the options are inline, else no row matches or the run
fails); `references/examples-flows.md` carries `main`'s sentence
verbatim.
- objectstack-ai#37551's `actionLayout` sentence of § Object Extension Model, now in
`references/examples-objects.md`, verbatim.
- A scan of every line `main` removed from the two entry files found no
stale copy left in a receiving file.
2. **Three eval cases accept the spellings the bundles teach** (ruling
7176941587 Q1 B):
- `objectstack-automation/evals/flows-triggers-approvals.json` case 1:
`must_not_contain` `values:` → `values: {` (the key form a node carries;
a prose heading also spells the bare word).
- `objectstack-data/evals/hooks-security-seeds-datasources.json` case 7:
`hooks: {` leaves `must_contain` for one any-of group `hooks: {` /
`"hooks": {` / `.refusals.CREDIT_LIMIT` (the nested literal, its JSON
spelling, or the dotted key `references/data-hooks.md` teaches).
- `objectstack-data/evals/objects-fields-relationships.json` case 10:
`type: 'boolean'` leaves `must_contain` for one any-of group `type:
'boolean'` / `Field.boolean(`.
3. **Ratchet rows re-measured on the merged tree**, since objectstack-ai#37747 made a
row equal its measurement exactly (see Verification).
4. **The changeset** follows the merged tree's sizes and names the three
eval cases.
5. **Three nits of contract review 7240993637** (head `edcd7df4ad`, one
commit over the reviewed `3b62b5e9b0`):
- `skills/objectstack-project/SKILL.md` line 187 pointed at
objectstack-data, "Schema evolution", a heading the router moved. It now
names `rules/field-types.md` § Changing a field that has data. That file
sat at its ceiling, so the longer pointer is paid in the same file by
five function-word cuts that lose no fact; its row stays 2990.
- `scripts/check-skills-token-ratchet.mjs` loses one formula comment
line the merge left in the `rules/security.md` history block.
- The changeset says what the `Skill Boundaries` table listed (the
neighbouring skills) and names the re-pointed objectstack-project line.

## Acceptance notes

Decided by the thread (small, no shipped behaviour):

- `"hooks": {` is a third member of case 7's any-of group. The ruling
names the dotted key; the JSON spelling of the same nested literal is
the form a `.json` translation file carries, and refusing it would fail
a correct answer on quote marks.
- `references/state-machines-and-approvals.md` measured 2 tokens over
`main`'s row after the merge (the re-pointed link is 9 bytes longer). It
is paid inside the file ("In a packaged flow, see below" → "A packaged
flow: below") instead of raising a row no ruling covers.
- The before round ran on `main` `600197a6ae` plus only the three
eval-case edits (skill text byte-identical to `main`), so both rounds
grade with the same token lists. Without that the three relaxed cases
would differ between the rounds for a reason that is not the router.

Not done, and why:

- **objectstack-ai#36718's flow-shape harness is NOT re-run** (a merge condition of
ruling 7128031203). It was scratch in the vacated container and is not
in the repository. It was run to 0 on `937e2f14` (report 7170977110);
this round adds no flow example over that head, only the two sentences
above, both `main`'s own words. NOT MEASURED on this head.
- The catalog-size line of Done-when: outside this PR, hence `Part of`.
- `triggers#6` (ruling Q3 A): the eval seat's.

## Tests

Skill evals, the command line of objectstack-ai#37235 unchanged for both rounds, run
in the thread's cloud container (subscription login, no API key):

```
pnpm --filter @objectstack/scenarios skill-evals --skills objectstack-data,objectstack-automation --repeats 1 --model <as objectstack-ai#37235> --effort medium --concurrency 4
```

| round | tree | turns | with-skill | objectstack-automation |
objectstack-data | no-skill | trigger cases |
|:--|:--|--:|--:|--:|--:|--:|--:|
| before | `main` `600197a6ae` + the three eval-case edits
(`304a4c5375`, local only) | 206/206 | 75/96 | 24/29 | 51/67 | 2/96 |
14/14 |
| after, first reading | head `3b62b5e9b0` | 206/206 | 77/96 | 23/29 |
54/67 | 2/96 | 13/14 |
| after, with the second readings | head `3b62b5e9b0` | +7 | **80/96** |
24/29 | 56/67 | | 14/14 |

**Parity under ruling 7128031203 ②A holds: the after round's failing set
is a strict subset of the before round's.**

- **Failed in both rounds (16):** automation `flows-triggers-approvals`
objectstack-ai#5, objectstack-ai#11, objectstack-ai#14, objectstack-ai#16, `integrations-declared` objectstack-ai#1; data
`hooks-security-seeds-datasources` objectstack-ai#3, objectstack-ai#6, objectstack-ai#8, objectstack-ai#16, objectstack-ai#19, objectstack-ai#34, objectstack-ai#38; data
`objects-fields-relationships` objectstack-ai#2, objectstack-ai#8, objectstack-ai#22, objectstack-ai#24.
- **Failed before, pass after (5):** data
`hooks-security-seeds-datasources` objectstack-ai#5, objectstack-ai#14, objectstack-ai#15, objectstack-ai#24;
`objects-fields-relationships` objectstack-ai#10.
- **Passed before, failed on the after round's first reading (4), each
re-run once as the rule says, and each passed its second reading:**
automation `flows-triggers-approvals` objectstack-ai#7 (the first answer carried the
forbidden `current_user.positions`), data
`hooks-security-seeds-datasources` objectstack-ai#25 (missed `default datasource`),
`objects-fields-relationships` objectstack-ai#11 (missed `type: 'select'`), and
trigger case `objectstack-data/triggers#6` (the bundle was read when it
should have been left alone; the case of ruling Q3 A, which this PR does
not change). Re-run with the same flags plus `--case` for those four
keys: 7 of 7 turns, all four pass.
- The three relaxed cases: `flows-triggers-approvals` objectstack-ai#1 and
`hooks-security-seeds-datasources` objectstack-ai#7 pass in both rounds;
`objects-fields-relationships` objectstack-ai#10 failed before on `label: '是否完成'`, not
on the relaxed token, and passes after.

One repetition per case is the round the card and objectstack-ai#37235 fix; at that
depth a single case moves between readings for no reason of the text
(four did here, in the unfavourable direction, and reverted). The five
that moved the favourable way were not re-read: the rule re-reads a flip
that would break parity, and a gain is not claimed from one reading.
Read the result as "not lower", not as "five cases better".

Both rounds were read on `3b62b5e9b0`. The commit after it
(`edcd7df4ad`) changes no file of the two evaluated bundles (one line of
objectstack-project, a script comment, the changeset), so the rounds
were not run again.

Records (round.json, every turn's record, both summaries):
`skill-evals-before-304a4c53.tgz`, `skill-evals-after-3b62b5e9.tgz`,
`skill-evals-after-reread-3b62b5e9.tgz` in the project's shared files,
folder `34770/`.

No unit test changes: the diff is skill text, three eval fixtures,
ratchet rows and a changeset. The one test that names the ratchet
script, `packages/spec/scripts/platform-catalog.test.ts`, ran apart from
the gate list (see Verification).

## Verification

Eleven skill files, measured on the head `edcd7df4ad` against `main`
(`ceil((utf8 bytes − the SKILL.md version stamp line) / 4)`, the
ratchet's own arithmetic):

| file | lines | bytes | ratchet row |
|:--|--:|--:|--:|
| `objectstack-data/SKILL.md` | 472 → 167 | 26,860 → 8,983 | 6709 → 2239
|
| `objectstack-data/references/examples-objects.md` | 192 → 305 | 6,892
→ 14,441 | 1723 → 3611 |
| `objectstack-data/rules/field-types.md` | 273 → 318 | 14,160 → 16,799
| 3540 → 4200 |
| `objectstack-data/rules/relationships.md` | 384 → 393 | 16,714 →
17,274 | 4179 → 4319 |
| `objectstack-data/rules/security.md` | 349 → 388 | 17,335 → 19,290 |
4334 → 4823 |
| `objectstack-data/rules/validation.md` | 329 → 392 | 11,031 → 13,861 |
2758 → 3466 |
| `objectstack-automation/SKILL.md` | 480 → 215 | 28,206 → 10,703 | 7045
→ 2669 |
| `objectstack-automation/references/examples-flows.md` | 145 → 432 |
6,170 → 25,729 | 1543 → 6433 |
| `objectstack-automation/references/integration-recipes.md` | 186 → 212
| 10,379 → 12,222 | 2595 → 3056 |
| `objectstack-automation/references/state-machines-and-approvals.md` |
388 → 388 | 23,706 → 23,708 | 5927 → 5927 |
| **ten files of the move** | 3,198 → 3,210 | 161,453 → 163,010 | 40,353
→ 40,743 |
| `objectstack-project/SKILL.md` (the re-pointed line) | 214 → 214 |
11,985 → 11,987 | 2990 → 2990 |

- **What an AI loads first**: the two entry files together 55,066 →
19,686 bytes (13,754 → 4,908 tokens), 64% smaller.
- **Whole pack**: authored (ratcheted) 200,068 → 200,458 tokens (+390);
bundle total 304,380 → 304,770. The pack does not shrink: the text moved
inside it.
- **Ruling ④A accounting**: every raised row equals its measured bytes,
zero headroom (the gate is exact since objectstack-ai#37747, so a row above or below
its file is red). Of the +390, +430 is the automation entry's own row
(the pure router measured 2239; ruling 7168461386 A restores six
flow-shape facts and ruling 7176941587 Q2 A keeps 187 bytes, 2239 →
2670, then 2669 after the merge). Set that authorised row aside and the
moves sum to −40: the sum of ceilings does not rise.

<details><summary>Gates run locally on the head</summary>

Derived with `node scripts/pm/dispatch-gates.mjs --commands` on
`3b62b5e9b0`, each command run and its exit code recorded, then
reconciled with `--ran`: **69 derived, 68 run (each exit 0), 1
NOT-MEASURED, 0 unrun.**

On head `edcd7df4ad` (the three nits) the 16 gates that read the changed
files were run again, each exit 0: the fourteen skill gates
(`check-skills-token-ratchet` and its self-test, `check:skill-docs`,
`check:skill-refs`, `check:skill-served-sections`, `check:skill-links`,
`check:skill-identifier-liveness`, `check:skill-compatibility`,
`check:skill-frame-sync`, `check:doc-authoring`, `check:nul-bytes`,
`check:pm-skill-id-lint`, `check:skill-examples`,
`check:doc-formula-expressions`) and the two changeset gates. The other
gates were not re-run on it. A trial merge with `origin/main`
`c6a1328dfe` (which moved the ratchet script and
`skills/objectstack-ai/SKILL.md` meanwhile) has no conflict and the
ratchet is green on the merged tree (200,510 / 200,510); the trial was
discarded and `main` is not merged again.

- NOT MEASURED: `pnpm check:dual-build-cjs-loads` exited 3 (prerequisite
not met: it needs every package's `dist`, a whole `pnpm build`). Long
builds go to GitHub under this project's standing rule, so CI is the
reading for it; the diff touches no package source.
- `pnpm check:skill-examples` needed `pnpm --filter
'@objectstack/client-react...' --filter '@objectstack/lint...' build`
first; then exit 0, 351 prose examples type-check across 3 surfaces.
- Outside the derived list, run apart: `pnpm --filter @objectstack/spec
exec vitest run scripts/platform-catalog.test.ts` (the one test that
names the ratchet script), 21 of 21.
- `node scripts/pm/overlap-check.mjs` before the first push: clean
against `origin/main` and the two open PRs that share a file (objectstack-ai#38224,
objectstack-ai#38192).

Exit 0, all 68: `node scripts/check-adr-0087-registration.mjs --base
origin/main` · `node scripts/check-adr-0087-registration.mjs
--self-test` · `node scripts/check-changeset-no-major.mjs --base
origin/main` · `node scripts/check-closing-keyword-parity.mjs` · `node
scripts/check-closing-keyword-parity.mjs --self-test` · `node
scripts/check-comment-mask-corpus.mjs` · `node
scripts/check-declaration-mirrors.mjs` · `node
scripts/check-declaration-mirrors.mjs --self-test` · `node
scripts/check-doc-route-spelling.mjs --advisory` · `node
scripts/check-doc-route-spelling.mjs --self-test` · `node
scripts/check-dts-emitted.mjs --self-test` · `node
scripts/check-empty-changeset.mjs --base origin/main` · `node
scripts/check-empty-changeset.mjs --self-test` · `node
scripts/check-self-test-wired.mjs` · `node
scripts/check-self-test-wired.mjs --self-test` · `node
scripts/check-self-test-workflow-commands.mjs` · `node
scripts/check-self-test-workflow-commands.mjs --self-test` · `node
scripts/check-skills-token-ratchet.mjs` · `node
scripts/check-skills-token-ratchet.mjs --self-test` · `node
scripts/check-whole-set-label-write.mjs` · `node
scripts/check-whole-set-label-write.mjs --self-test` · `node
scripts/ci/assert-turbo-remote-cache.mjs --self-test` · `node
scripts/ci/plan-test-core-shards.mjs --self-test` · `node
scripts/ci/prune-turbo-cache.mjs --self-test` · `node
scripts/ci/snapshot-next.mjs --self-test` · `node
scripts/pm/bare-root-worklist.mjs --self-test` · `node
scripts/pm/check-governed-queue-guard.mjs --self-test` · `node
scripts/pm/release-rehearsal-clone.mjs --self-test` · `node
scripts/release-pending-publish.mjs --self-test` · `--filter
@objectstack/lint run check:doc-formula-expressions` · `--filter
@objectstack/spec run check:skill-docs` · `--filter @objectstack/spec
run check:skill-refs` · `--filter @objectstack/spec run
check:skill-served-sections` · `check:adr-anchors` ·
`check:agent-test-spelling` · `check:bash32-floor` ·
`check:changeset-gate-self-tests` · `check:ci-filter-parity` ·
`check:cli-command-ids` · `check:closed-ceremony-text` ·
`check:corpus-claim-drift` · `check:cross-package-test-inputs` ·
`check:doc-authoring` · `check:driver-memory-census` ·
`check:dts-closure` · `check:entry-guard` · `check:gitlink-declared` ·
`check:lean-entry-closure` · `check:merge-driver` · `check:nul-bytes` ·
`check:parse-guard` · `check:pm-dispatch-gates` ·
`check:pm-expected-skips` · `check:pm-governed-merges` ·
`check:pm-skill-id-lint` · `check:pnpm-filter-targets` ·
`check:pnpm-flag-spellings` · `check:published-files` ·
`check:ratchet-remedy-authority` · `check:refd-timer-probe` ·
`check:role-word` · `check:scripts-symbol-anchors` ·
`check:skill-compatibility` · `check:skill-frame-sync` ·
`check:skill-identifier-liveness` · `check:skill-links` ·
`check:sourcemap-no-sources-content` · `check:watch-hint-literal`

</details>

**Writer**: all `skills/**` text was written by the card thread itself,
a session at `CONTRACT_REVIEW_TIER` per the claim (7240213191). Every
assistant turn of the session's transcript was served at the tier (210
of 210 when counted against the constant in
`scripts/pm/dispatch-gates.mjs`); `verify-review-tier.mjs` itself
refuses the transcript because the session once ran a read-only
sub-agent to read the rulebook, so that count is the thread's reading,
not the script's PASS.

---
_Generated by [Claude
Code](https://claude.ai/code/session_01L6bhgUTzGxLiCQYi8Wvn3K)_

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01L6bhgUTzGxLiCQYi8Wvn3K

<!-- signed: repo:objectstack#2 · os-sales ·
session_01L6bhgUTzGxLiCQYi8Wvn3K -->

---------

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

✨ Set up Copilot instructions

3 participants