Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .changeset/34770-api-skill-router.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
'@objectstack/skills': patch
---

docs(skills): the objectstack-api entry file becomes a router

Clause-②: no
Metadata-protocol: none

`skills/objectstack-api/SKILL.md` goes from 21.4 KB to 9.0 KB (438 lines to 151). It now holds six things: four first checks (the installed version wins over the `compatibility` line, and an `apis:` block written before protocol 17 turns live; read the stack's `apis`, its `manifest.namespace` and the object's `apiMethods`; read the contract and never recall a key or a code; verify with `os validate` or `os build` and read a publish rejection), the generated routes, the `apiMethods` primitives and what derives from them, one type-checked declared endpoint, six traps, and a table that says where to go for the rest. No rule's teaching changes. This skill has no hand-written reference file, so no text moved: what left the entry was cut, and this entry says what now answers it.

**What the entry keeps.** The generated routes as one listing (the `data` routes, the two `batch` routes, import and export, the metadata read), with the two request contracts a client gets wrong: the metadata list reads a closed query set and narrows by `?names=`, and an import mapping's entry form, `{ sourceField, targetField, applyOn }`, is the only one that carries `applyOn`. The section `## API Methods (Operations)` keeps its heading and every one of the six authorable primitives, with the eight derived operations and what each derives from. The declared endpoint keeps its example: the path carve-out, `object_operation` with `objectParams`, `cacheTtlSeconds`. The six traps, each a declaration or a call that passes and then answers wrong at run time: `authRequired: false` needs `rateLimit.enabled: true`, because a budget with only `windowMs` / `maxRequests` meters nothing; an app never mounts on `http.server`, handler code runs in a flow's `script` or `connector_action` node, an inbound webhook is a `type: 'api'` flow verified by `x-objectstack-signature` or a declared `config.signature`, and three cases have no app surface; `DELETE` keeps a business object's rows in the recycle bin, with the restore door and its two grants; a `PATCH` with no version token skips the concurrency check; a public form answers `404 FORM_NOT_FOUND` unless its `sharing` declares `enabled`, `allowAnonymous` and `publicLink`, strips fields outside its sections, and is withheld on a walled posture with only a warning at save and publish; a person is shown `userMessage`, never `message`, on a batch publish's `probes.issues[]`, and a failed flow door renders `userMessage`, then `details.innerRefusal`, then `message`.

**What left, and what answers it now.**

- The publish gates one by one, and the mapping refusals beyond `transform` (`inputMapping` on a `find` / `get` / `delete` operation, two entries writing one target path): https://objectstack.ai/docs/api/declarative-endpoints, and the rejection itself, which names the endpoint, the key and the fix. `os validate` runs the same gates.
- The steps for an `apis:` block written before protocol 17 (move every `path` into the carve-out, review every `authRequired: false`): the `declarative-apis-endpoints-live` entry of the protocol upgrade guide, which the entry still names.
- The endpoint naming table: cut. Its two patterns (`/api/v1/{object}/:id/{action}`, `/api/v1/{domain}/{action}`) are not paths an app can declare: a declared path lives under `/api/v1/apps/<manifest.namespace>/`, and the endpoint vocabulary has no path-template syntax.
- The per-primitive route table, the four `RESTORE_*` refusals of a restore, the list, purge and empty doors of the recycle bin, the one metadata type whose list refuses `names`, and the discovery route: https://objectstack.ai/docs/protocol/kernel/http-protocol. The quoted-empty entity-tag refusal (`400 VALIDATION_FAILED`): https://objectstack.ai/docs/api/wire-format. The `ApiOperation` vocabulary: `data/object.zod.ts`. Each refusal among them is loud when hit. The health and readiness routes are cut: nothing in a stack declares them.
- The dispatcher's four codes, the two envelope shapes, the two-tier `error.code` vocabulary and the downstream-ledger recipe (`envelopeViolations`, `makeApiErrorSchema`): `api/errors.zod.ts`, `api/dispatcher.zod.ts`, `api/error-code-ledger.zod.ts` and `api/contract.zod.ts` under `node_modules/@objectstack/spec/src/`, and https://objectstack.ai/docs/api/error-catalog. The entry keeps that a code in no ledger fails CI.
- The realtime pointers (`api/realtime.zod.ts`, `api/websocket.zod.ts`): `references/_index.md`, which lists both.
- The login request's field list, and the flat `public` + `permissions` pair of `RestApiEndpointSchema` (the plugin route registry, `api/plugin-rest-api.zod.ts`): the contract. The entry keeps `AuthProvider` with its members, `LoginRequestSchema`, and that a declared endpoint has `authRequired` and no nested `auth` block (the strict endpoint shape refuses `auth` and names `authRequired`).
- A public form's file-field rule (`public-form-file-field`, an error at `os validate` and at publish) and the `guest_portal` name: https://objectstack.ai/docs/ui/forms. The form contracts: `ui/view.zod.ts` (`FormViewSchema`) and `ui/sharing.zod.ts` (`SharingConfigSchema`).
- The locale ladder's subtag steps, the `advisories[]` / 422 `issues[]` element (`RuntimeAuthoringIssueSchema`), and the `errorMessage` and `summary` keys of a failed flow's details: `api/protocol.zod.ts` and `api/automation-api.zod.ts`. An app-authored refusal having no `en` floor is in objectstack-i18n.
- The skill-boundaries table: the frontmatter description and the last routing row.

**Anchors that no longer exist in `SKILL.md`.** `#skill-boundaries`, `#auto-generated-vs-custom-apis`, `#auto-generated-apis`, `#metadata-api-meta`, `#public-anonymous-form-endpoints`, `#declarative-endpoints-apis--no-handler-code`, `#choosing-between-apis-and-a-code-handler`, `#the-path-carve-out-adr-0121-d1d2`, `#five-publish-gates-each-with-a-prescription`, `#authrequired-and-the-d6-pairing`, `#mapping-keys-projection-only`, `#upgrading-a-pre-17-stack`, `#endpoint-naming-conventions`, `#discovery--health`, `#dispatcher-error-codes`, `#realtime-subscriptions`, `#authentication--authorization`, `#auth-configuration`, `#auth-providers`, `#error-envelopes--the-code-ledger-adr-0112`, `#best-practices`, `#common-pitfalls`, `#verify-your-work`, `#references`. `#api-methods-operations` stays. The new ones are `#first-checks`, `#generated-routes`, `#a-declared-endpoint`, `#traps` and `#where-to-go`. No file in this repository linked an anchor of the old entry.
17 changes: 16 additions & 1 deletion scripts/check-skills-token-ratchet.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,22 @@ export const CEILINGS = new Map([
// longer has. Lowered to the measurement, per the shrink-only discipline.
// 6319 -> 6314: A2′ — the release-stamp line left the count (see
// STAMP_LINE_REPIN); the file's count fell by the same 5, headroom unchanged.
['skills/objectstack-api/SKILL.md', 5333], // -981 to the measurement (was 6314)
// 6314 -> 5333: lowered to the measurement (-981).
// 5333 -> 2240 (#34770): the entry becomes a router. It keeps four first checks, the
// generated routes with the two request contracts a client gets wrong (the closed query set
// of the metadata list, an import mapping's `applyOn`), the `apiMethods` primitives and what
// derives from them, one type-checked declared endpoint, six traps (each passes the build
// and then answers wrong at run time, or is refused only at publish with the form to write)
// and a routing table. This skill has no hand-authored reference file, so nothing MOVED: the
// rest is CUT behind a pointer, to the contract (`api/*.zod.ts`, whose strict endpoint shape
// refuses a wrong key with the key to write), to the publish gates (`os validate` runs them
// and each rejection carries its fix) or to the published API pages. No row rises and no
// row is added. The file is 21359 bytes (21332 priced) -> 8986 (8959 priced) -> 2240
// tokens, pinned AT the measurement; the sum of all ceilings falls by the same 3093.
// Authority: the ruling of record that orders the entry file down to router size, decision
// record #34691 S3 = A.
// ceil(($(wc -c < skills/objectstack-api/SKILL.md) - 27) / 4) == ceil(8959 / 4)
['skills/objectstack-api/SKILL.md', 2240],
// 12511 -> 12643 (#11348): the flow value-expression section documented the
// expression surface but not the function vocabulary (round/floor/ceil/abs/
// min/max); an unknown function fails at RUNTIME, not at flow-save, so the
Expand Down
Loading
Loading