diff --git a/content/docs/ai/skills-reference.mdx b/content/docs/ai/skills-reference.mdx index 6ff1e79053d..39f6307afce 100644 --- a/content/docs/ai/skills-reference.mdx +++ b/content/docs/ai/skills-reference.mdx @@ -153,7 +153,7 @@ Use when the user is adding `*.endpoint.ts`, configuring auth providers, definin Do not use for: consuming an ObjectStack API from a client (that is just standard HTTP — no skill needed); the auto-generated CRUD endpoints (those follow from objectstack-data); request-side query syntax (see objectstack-query). CEL expressions in route guards or auth predicates: load objectstack-formula alongside. -**Tags:** `rest`, `graphql`, `endpoint`, `auth`, `realtime`, `server` +**Tags:** `rest`, `endpoint`, `auth`, `realtime`, `server` --- diff --git a/packages/lint/scripts/check-doc-security-posture.mjs b/packages/lint/scripts/check-doc-security-posture.mjs index af047132b57..ded80128f8d 100644 --- a/packages/lint/scripts/check-doc-security-posture.mjs +++ b/packages/lint/scripts/check-doc-security-posture.mjs @@ -89,17 +89,23 @@ * * ## What this gate does NOT claim * - * - **Only `content/docs/**​/*.mdx`, only `{/* os:check *\/}`-marked ts/tsx - * fences** — the marker is the author's claim "this is a complete, copyable - * example", which is exactly the population whose posture must be clean. - * Unmarked fragments are not judged (they are not copyable wholes), matching - * `check-skill-examples`' own opt-in boundary. `content/docs/references/` is - * generated and excluded for the same reason it is there. - * - **`skills/` is not scanned yet.** Its marked corpus has 4 - * `ObjectSchema.create` examples with the same defect; `skills/**` is a - * governed surface (Prime Directive #14), so the fixes cannot ride a code - * PR. Extend `ROOTS` when they land — the follow-up issue filed from #10618 - * carries both halves. + * - **Only os:check-marked ts/tsx fences** — the marker is the author's claim + * "this is a complete, copyable example", which is exactly the population + * whose posture must be clean. Unmarked fragments are not judged (they are + * not copyable wholes), matching `check-skill-examples`' own opt-in + * boundary. `content/docs/references/` is generated and excluded for the + * same reason it is there. + * - **Two roots, two marker spellings** (#10925, the deferred extension this + * header used to record as pending). `skills/` was held back at #10618 + * because `skills/**` is a governed surface (Prime Directive #14) and its 4 + * defective examples could not ride a code PR: extending the roots first + * would have made this gate born red, the trap #10618's own sequencing note + * avoided. Those 4 are fixed in the commit before this one, so the root + * lands green. The marker differs PER ROOT and that is not cosmetic — + * `.md` carries `` while MDX has no HTML comments + * (fumadocs-mdx fails the build outright on ``), so `.mdx` + * carries `{/* os:check *\/}`. `check-skill-examples.ts`'s `SOURCE_ROOTS` + * is the precedent this mirrors, down to the per-root exclusions. * - **Only `error`-severity findings gate.** `warning`/`info` rules in the * same function need permission sets / books a single-object doc example * never carries, and firing advisory rules over fragments is the false-red @@ -124,18 +130,40 @@ const HERE = dirname(fileURLToPath(import.meta.url)); const REPO_ROOT = resolve(HERE, '../../..'); /** - * The corpus root. Narrower than `check-doc-formula-expressions`' four ROOTS on - * purpose: the card (#10618) scopes this gate to `content/docs/**` os:check - * blocks, and `skills/` is deferred (see the header). `references/` is - * generated by `build-docs.ts` from the schemas, so it cannot drift - * independently of its source — same exclusion, same reason, as - * `check-skill-examples`. + * The corpus roots, each with the file extension and marker spelling it owns. + * + * `content/docs` was the #10618 scope; `skills` is the #10925 extension (see + * the header for why it landed second). `references/` is generated by + * `build-docs.ts` from the schemas, so it cannot drift independently of its + * source — same exclusion, same reason, as `check-skill-examples`. + * + * `floor` is the anti-idle guard, per root: the count of marked blocks and of + * judged create sites BELOW which the run is a failure rather than a pass. A + * root that suddenly reads zero has had its extraction rot, not had its prose + * stop teaching objects (`check-skill-examples` house rule, #4690). The + * numbers are deliberately well under today's census — they catch extraction + * breaking, not authors deleting one example. */ -const DOCS_ROOT = 'content/docs'; -const EXCLUDE_SUBTREES = ['content/docs/references']; - -/** The docs-root marker spelling — MDX comment syntax (`check-skill-examples`). */ -const MARKER = '{/* os:check */}'; +export const ROOTS = [ + { + path: 'content/docs', + label: 'docs', + ext: '.mdx', + // MDX has no HTML comments — fumadocs-mdx fails the build outright on + // ``. Each format's marker follows its own comment syntax. + marker: '{/* os:check */}', + exclude: ['content/docs/references'], + floor: { blocks: 100, sites: 10 }, + }, + { + path: 'skills', + label: 'skills', + ext: '.md', + marker: '', + exclude: [], + floor: { blocks: 10, sites: 4 }, + }, +]; /** * Deliberate, reviewed exceptions. Entry shape: @@ -150,15 +178,15 @@ const UNKNOWN = Object.freeze({ '': true }); // ── Extraction (the check-skill-examples opt-in boundary, restated) ───────── -/** Every .mdx file under `root`, sorted, exclusions applied. */ -export function mdxFiles(rootAbs, excludeAbs) { +/** Every `ext` file under `root`, sorted, exclusions applied. */ +export function proseFiles(rootAbs, excludeAbs, ext) { const out = []; const walk = (dir) => { if (excludeAbs.some((x) => dir === x || dir.startsWith(x + '/'))) return; for (const e of readdirSync(dir, { withFileTypes: true })) { const full = join(dir, e.name); if (e.isDirectory()) walk(full); - else if (e.name.endsWith('.mdx')) out.push(full); + else if (e.name.endsWith(ext)) out.push(full); } }; walk(rootAbs); @@ -172,13 +200,16 @@ export function mdxFiles(rootAbs, excludeAbs) { * `{ bodyStartLine, code }[]` — bodyStartLine is the 1-based page line of the * first code line, so an AST line L (0-based) is page line * `bodyStartLine + L`. + * + * `marker` is the OWNING ROOT's spelling, never both: a block tagged with the + * other root's form stays unadmitted, exactly as in `check-skill-examples`. */ -export function markedBlocks(fileAbs) { +export function markedBlocks(fileAbs, marker) { const lines = readFileSync(fileAbs, 'utf-8').split('\n'); const blocks = []; for (let i = 0; i < lines.length; i++) { if (!/^```(ts|typescript)\s*$/.test(lines[i])) continue; - const marked = i > 0 && lines[i - 1].trim() === MARKER; + const marked = i > 0 && lines[i - 1].trim() === marker; let close = i + 1; while (close < lines.length && !/^```\s*$/.test(lines[close])) close++; if (marked) blocks.push({ bodyStartLine: i + 2, code: lines.slice(i + 1, close).join('\n') }); @@ -267,13 +298,13 @@ function evalStatic(node) { * - refusals: shapes the gate refuses to guess about `{ pageLine, why }` * - notices: suppressed unknown-fact verdicts (informational lines) */ -export function judgeFile(fileAbs, relPath) { +export function judgeFile(fileAbs, relPath, marker) { const sites = []; const violations = []; const refusals = []; const notices = []; - for (const block of markedBlocks(fileAbs)) { + for (const block of markedBlocks(fileAbs, marker)) { const sf = ts.createSourceFile('block.ts', block.code, ts.ScriptTarget.ES2020, true, ts.ScriptKind.TS); const visit = (node) => { if (ts.isCallExpression(node) && isObjectSchemaCreate(node.expression)) { @@ -337,11 +368,11 @@ export function judgeFile(fileAbs, relPath) { // ── Scan ──────────────────────────────────────────────────────────────────── /** - * Scan a docs tree. Parameterized for the self-test; the real run passes the - * repo's own paths and exemption table. + * Scan one prose tree. Parameterized for the self-test; the real run passes + * each ROOT's own paths, extension, marker and the shared exemption table. */ -export function scan({ rootAbs, excludeAbs, exemptions }) { - const files = mdxFiles(rootAbs, excludeAbs); +export function scan({ rootAbs, excludeAbs, exemptions, ext = '.mdx', marker = '{/* os:check */}' }) { + const files = proseFiles(rootAbs, excludeAbs, ext); let markedBlockCount = 0; const allSites = []; const allViolations = []; @@ -351,8 +382,8 @@ export function scan({ rootAbs, excludeAbs, exemptions }) { for (const file of files) { const relPath = relative(REPO_ROOT, file).split('\\').join('/'); - markedBlockCount += markedBlocks(file).length; - const { sites, violations, refusals, notices } = judgeFile(file, relPath); + markedBlockCount += markedBlocks(file, marker).length; + const { sites, violations, refusals, notices } = judgeFile(file, relPath, marker); for (const s of sites) allSites.push({ ...s, file: relPath }); for (const v of violations) allViolations.push({ ...v, file: relPath }); for (const r of refusals) allRefusals.push({ ...r, file: relPath }); @@ -402,36 +433,74 @@ function fail(msg) { } function main() { - console.log('🛡 Linting ObjectSchema.create examples in os:check docs blocks (validateSecurityPosture)...\n'); - - const rootAbs = resolve(REPO_ROOT, DOCS_ROOT); - if (!existsSync(rootAbs)) fail(`docs root not found: ${DOCS_ROOT} — the corpus moved and this gate must move with it`); - const { files, markedBlockCount, allSites, gatingViolations, allNotices, errors } = scan({ - rootAbs, - excludeAbs: EXCLUDE_SUBTREES.map((p) => resolve(REPO_ROOT, p)), - exemptions: EXEMPT_SITES, - }); - - // Anti-idle guards (`check-skill-examples` house rule: a gate that checks - // nothing must not report success). The corpus carries ~190 marked blocks - // and 20+ create sites today; zero of either means the extraction rotted, - // not that the docs stopped teaching objects. - if (markedBlockCount === 0) { - fail(`no ${MARKER} blocks found under ${DOCS_ROOT} — extraction is broken (the corpus has ~190)`); - } - if (allSites.length === 0 && errors.length === 0) { + console.log('🛡 Linting ObjectSchema.create examples in os:check prose blocks (validateSecurityPosture)...\n'); + + // An exemption entry is routed to the root that owns its path. One belonging + // to no root would be dropped by that routing and never judged stale — the + // ledger would silently stop being self-invalidating, which is the whole + // discipline. Refuse loudly instead. + const unclaimed = EXEMPT_SITES.filter((e) => !ROOTS.some((r) => e.file.startsWith(r.path + '/'))); + if (unclaimed.length > 0) { fail( - `no ObjectSchema.create site found in any marked block under ${DOCS_ROOT} — ` + - `the corpus has 20+; the call matcher or evaluator has rotted`, + `exemption entr(ies) under no configured root: ${unclaimed.map((e) => e.file).join(', ')} — ` + + `an entry no root owns is never judged stale, so the ledger stops self-invalidating`, ); } - for (const n of allNotices) console.log(` ℹ ${n}`); + const allViolations = []; + const allErrors = []; + const census = []; + let totalSites = 0; + let totalBlocks = 0; + let totalFiles = 0; + + for (const root of ROOTS) { + const rootAbs = resolve(REPO_ROOT, root.path); + if (!existsSync(rootAbs)) { + fail(`${root.label} root not found: ${root.path} — the corpus moved and this gate must move with it`); + } + const { files, markedBlockCount, allSites, gatingViolations, allNotices, errors } = scan({ + rootAbs, + excludeAbs: root.exclude.map((p) => resolve(REPO_ROOT, p)), + exemptions: EXEMPT_SITES.filter((e) => e.file.startsWith(root.path + '/')), + ext: root.ext, + marker: root.marker, + }); + + // Anti-idle guards, PER ROOT (`check-skill-examples` house rule: a gate + // that checks nothing must not report success). A root reading below its + // floor means extraction rotted — a wrong marker spelling above all, which + // would otherwise leave that whole corpus silently unjudged while the run + // stayed green on the other root's census. + if (markedBlockCount < root.floor.blocks) { + fail( + `only ${markedBlockCount} \`${root.marker}\` block(s) found under ${root.path} ` + + `(floor ${root.floor.blocks}) — extraction is broken for the ${root.label} root`, + ); + } + if (allSites.length < root.floor.sites && errors.length === 0) { + fail( + `only ${allSites.length} ObjectSchema.create site(s) found in marked blocks under ${root.path} ` + + `(floor ${root.floor.sites}) — the call matcher or evaluator has rotted for the ${root.label} root`, + ); + } + + for (const n of allNotices) console.log(` ℹ ${n}`); + allViolations.push(...gatingViolations); + allErrors.push(...errors); + census.push( + ` ${root.label.padEnd(7)} ${String(allSites.length).padStart(3)} create site(s) in ` + + `${String(markedBlockCount).padStart(3)} marked block(s) across ${files.length} ${root.ext} file(s)`, + ); + totalSites += allSites.length; + totalBlocks += markedBlockCount; + totalFiles += files.length; + } - if (errors.length > 0 || gatingViolations.length > 0) { - if (gatingViolations.length > 0) { - console.error(`\n✗ docs example(s) carry a security posture \`os validate\` rejects as severity: 'error':\n`); - for (const v of gatingViolations) { + if (allErrors.length > 0 || allViolations.length > 0) { + if (allViolations.length > 0) { + console.error(`\n✗ example(s) carry a security posture \`os validate\` rejects as severity: 'error':\n`); + for (const v of allViolations) { console.error(` ${v.file}:${v.pageLine} object "${v.object}" [${v.finding.rule}]`); console.error(` ${v.finding.message}`); console.error(` fix: ${v.finding.hint}\n`); @@ -442,13 +511,14 @@ function main() { ` do not weaken the rule, and do not drop the os:check marker to dodge the gate.\n`, ); } - for (const e of errors) console.error(` ✗ ${e}`); + for (const e of allErrors) console.error(` ✗ ${e}`); process.exit(1); } + for (const line of census) console.log(line); console.log( - `\n✅ ${allSites.length} ObjectSchema.create example(s) in ${markedBlockCount} marked block(s) ` + - `across ${files.length} docs file(s) carry an os validate-clean security posture`, + `\n✅ ${totalSites} ObjectSchema.create example(s) in ${totalBlocks} marked block(s) ` + + `across ${totalFiles} prose file(s) in ${ROOTS.length} root(s) carry an os validate-clean security posture`, ); } @@ -626,6 +696,70 @@ function selfTest() { rmSync(join(dir, 'spread.mdx')); } + // ── The skills root: its own extension AND its own marker (#10925). ───── + // Both halves are load-bearing. A `.md` corpus scanned with the MDX + // marker reads as zero marked blocks — a whole governed corpus silently + // unjudged — which is why the per-root floor above is a failure and not + // a shrug, and why this leg asserts the cross-marker misses BOTH ways. + { + writeFileSync( + join(dir, 'skill-red.md'), + [ + '# A skill', // 1 + '', // 2 + '', // 3 + '```ts', // 4 + `import { ObjectSchema } from '@objectstack/spec/data';`, // 5 + '', // 6 + 'export const Case = ObjectSchema.create({', // 7 ← the create call + ` name: 'support_case',`, // 8 + ` fields: { subject: { type: 'text', required: true } },`, // 9 + '});', // 10 + '```', // 11 + '', + 'Declared posture — silent:', + '', + '', + '```ts', + `export const Ok = ObjectSchema.create({ name: 'lead', sharingModel: 'private', fields: {} });`, + '```', + '', + 'The OTHER root\'s marker spelling must NOT opt a block in here:', + '', + '{/* os:check */}', + '```ts', + `export const Wrong = ObjectSchema.create({ name: 'wrong_marker_thing', fields: {} });`, + '```', + '', + ].join('\n'), + ); + const md = scan({ rootAbs: dir, excludeAbs: [], exemptions: [], ext: '.md', marker: '' }); + check( + md.gatingViolations.length === 1 && md.gatingViolations[0].object === 'support_case', + `skills: expected exactly the support_case defect, got ${JSON.stringify(md.gatingViolations.map((v) => v.object))} — ` + + `the .md root must judge its own marker, stay silent on a declared posture, and ignore the MDX spelling`, + ); + if (md.gatingViolations.length >= 1) { + check(md.gatingViolations[0].finding.rule === 'security-owd-unset', `skills: expected security-owd-unset, got ${md.gatingViolations[0].finding.rule}`); + check(md.gatingViolations[0].pageLine === 7, `skills: reported page line ${md.gatingViolations[0].pageLine}, expected 7 — line mapping is wrong for .md`); + } + + // The .mdx scan must not reach into the .md file at all — extension + // scoping, not just marker scoping. + const mdxPass = run(); + check( + !mdxPass.allSites.some((s) => s.file.endsWith('skill-red.md')), + `skills: the .mdx root read a .md file — extension scoping is broken`, + ); + + // And the .md root must not admit the docs corpus's own spelling. + check( + !md.allSites.some((s) => s.object === 'wrong_marker_thing'), + `skills: the .md root admitted a block carrying the MDX marker — per-root marker scoping is broken`, + ); + rmSync(join(dir, 'skill-red.md')); + } + // ── Exemption discipline: stale and unnecessary entries are errors; // a live entry suppresses exactly its site. ─────────────────────────── { @@ -656,8 +790,9 @@ function selfTest() { console.log( '✅ self-test: flags the measured defect (owd-unset) and the alias value at the right page line;\n' + ' stays silent on declared postures, factory-call fields, sys_ objects, unmarked blocks,\n' + - ' dynamic values and non-ObjectSchema factories; refuses spreads loudly; and holds the\n' + - ' exemption ledger to the self-invalidating discipline in both directions.', + ' dynamic values and non-ObjectSchema factories; refuses spreads loudly; judges the skills\n' + + ' root by its own extension AND marker (neither spelling crosses); and holds the exemption\n' + + ' ledger to the self-invalidating discipline in both directions.', ); } diff --git a/scripts/check-skills-token-ratchet.mjs b/scripts/check-skills-token-ratchet.mjs index 7225673f940..09ba8d2f64a 100644 --- a/scripts/check-skills-token-ratchet.mjs +++ b/scripts/check-skills-token-ratchet.mjs @@ -145,7 +145,9 @@ export const CEILINGS = new Map([ ['skills/objectstack-api/SKILL.md', 6348], ['skills/objectstack-automation/SKILL.md', 12543], // basis 7228d6c25 (PR #10402 head), not main — see CEILING_BASIS. - ['skills/objectstack-data/SKILL.md', 13797], + // +20 (13797→13817): maintainer ruling 2026-08-23 on PR #11141 — the three + // SECURITY_OWD_UNSET-required sharingModel keys. Ruling quoted in that PR's body. + ['skills/objectstack-data/SKILL.md', 13817], ['skills/objectstack-formula/SKILL.md', 6055], ['skills/objectstack-i18n/SKILL.md', 6349], // basis 7228d6c25 (PR #10402 head), not main — see CEILING_BASIS. @@ -153,7 +155,9 @@ export const CEILINGS = new Map([ ['skills/objectstack-pm-dispatch/SKILL.md', 14239], ['skills/objectstack-query/SKILL.md', 5569], ['skills/objectstack-ui/SKILL.md', 25154], - ['skills/objectstack-upgrade/SKILL.md', 8325], + // +10 (8325→8335): same 2026-08-23 ruling — crm_lead's SECURITY_OWD_UNSET-required + // sharingModel key (value mirrored from examples/app-crm per the same ruling). + ['skills/objectstack-upgrade/SKILL.md', 8335], ]); /** diff --git a/skills/objectstack-api/SKILL.md b/skills/objectstack-api/SKILL.md index 914d341fb3d..39a5f132021 100644 --- a/skills/objectstack-api/SKILL.md +++ b/skills/objectstack-api/SKILL.md @@ -16,7 +16,7 @@ metadata: author: objectstack-ai version: "1.4" domain: api - tags: rest, graphql, endpoint, auth, realtime, server + tags: rest, endpoint, auth, realtime, server --- # API Design — ObjectStack API Protocol diff --git a/skills/objectstack-data/SKILL.md b/skills/objectstack-data/SKILL.md index 8033109fcb1..b81892a7904 100644 --- a/skills/objectstack-data/SKILL.md +++ b/skills/objectstack-data/SKILL.md @@ -91,7 +91,7 @@ Toggle system behaviours per object: |:-----|:--------|:--------| | `trackHistory` | `false` | Field-level audit trail | | `searchable` | `true` | Index records for global search | -| `apiEnabled` | `true` | Expose via automatic REST / GraphQL APIs | +| `apiEnabled` | `true` | Expose via automatic REST + MCP APIs | | `apiMethods` | all | Whitelist over the six primitives (`get`, `list`, `create`, `update`, `delete`, `bulk`); derived verbs (search/export/upsert/…) follow automatically | | `files` | `false` | Attachments & document management | | `feeds` | `true` | Social feed, comments, mentions — **opt-out**: explicit `false` hides the feed UI and rejects new comments | @@ -214,6 +214,7 @@ import { ObjectSchema } from '@objectstack/spec/data'; export default ObjectSchema.create({ name: 'account', label: 'Account', + sharingModel: 'private', fieldGroups: [ { key: 'contact_info', label: 'Contact Information', icon: 'user' }, @@ -253,6 +254,7 @@ import { ObjectSchema, Field } from '@objectstack/spec/data'; export const Invoice = ObjectSchema.create({ name: 'invoice', + sharingModel: 'private', fields: { status: Field.select({ options: [ @@ -321,6 +323,7 @@ import { ObjectSchema } from '@objectstack/spec/data'; export default ObjectSchema.create({ name: 'support_case', label: 'Support Case', + sharingModel: 'private', enable: { trackHistory: true, feeds: true, diff --git a/skills/objectstack-formula/SKILL.md b/skills/objectstack-formula/SKILL.md index 2ae09db9b66..c13a5092fa5 100644 --- a/skills/objectstack-formula/SKILL.md +++ b/skills/objectstack-formula/SKILL.md @@ -425,7 +425,6 @@ to the envelope. | `Hook` | `condition` | cel | | `SharingRule` | `condition` | cel | | `Flow.decision` | `expression` / edge `condition` | cel (use `vars..`) | -| `GraphQL.ComputedField` | `expression` | cel | | `Dataset.records[*]` | any value | cel (via `cel\`\``) | | `audit` / `metrics` / `tracing` | `condition` / `successCriteria` | structured \| cel | @@ -476,7 +475,6 @@ tmpl`Deal {{ record.name }} — {{ record.amount | currency }} closes {{ record. | `system/notification` | email subject + body, SMS message, push body + message (5 fields) | | `ai/model-registry` | `promptTemplate.system`, `promptTemplate.user` | | `integration/connector/github` | titleTemplate, bodyTemplate (PR + release) | -| `api/graphql` | cache key | There is no JS expression surface: procedural JS is the L2 `ScriptBody { language: 'js' }` surface (hook bodies), not an expression diff --git a/skills/objectstack-platform/SKILL.md b/skills/objectstack-platform/SKILL.md index 4a72b596048..11c292c6217 100644 --- a/skills/objectstack-platform/SKILL.md +++ b/skills/objectstack-platform/SKILL.md @@ -392,7 +392,7 @@ export default app; // Deploy to Cloudflare Workers, Deno, Bun, Node 1. Accept a `kernel` (ObjectKernel) instance 2. Create an `HttpDispatcher` internally -3. Mount explicit routes for auth, GraphQL, storage, discovery +3. Mount explicit routes for auth and discovery 4. Delegate everything else to the dispatcher This means **new routes added to HttpDispatcher work automatically** diff --git a/skills/objectstack-upgrade/SKILL.md b/skills/objectstack-upgrade/SKILL.md index f5884c1d880..37062eabb5d 100644 --- a/skills/objectstack-upgrade/SKILL.md +++ b/skills/objectstack-upgrade/SKILL.md @@ -634,6 +634,7 @@ import { defineAgent } from '@objectstack/spec/ai'; // physical constraint explicitly via `storage.notNull`. export const Lead = ObjectSchema.create({ name: 'crm_lead', + sharingModel: 'public_read_write', label: 'Lead', fields: { name: { type: 'text', required: true, storage: { notNull: true } },