Skip to content
Merged
23 changes: 23 additions & 0 deletions .changeset/34770-formula-skill-router.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
'@objectstack/skills': patch
---

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

Clause-②: no
Metadata-protocol: none

`skills/objectstack-formula/SKILL.md` goes from 24.4 KB to 9.0 KB (485 lines to 135). It now holds five things: four first checks (the installed version wins over the `compatibility` line; read the object's declared fields and the contract of the key that takes the expression; bare CEL under the `F`, `P` or `cel` tag, never braces round a field reference; verify with `os validate`, `os build` or the `validate_expression` agent tool), one type-checked block that shows each tag once, the roots and the advertised function names as one list, eight 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.** Every name of `CEL_STDLIB_FUNCTIONS`, as a call form with its parameters and without the per-function notes. The eight traps, each an expression that parses and then fails, or reads wrong, at run time or at the build: `has()` is not a null check on a server-evaluated predicate, where the guard is `!= null` and the build refuses an ordering or arithmetic operator on a nullable field without it, a flow condition's bare name included; action `visible` / `disabled` are client-side and sparse, so their guard is `has(record.x) && record.x != null`; a transition compares `previous`, which is per row on a bulk write and `null` on insert, and a hook `condition` that cannot evaluate aborts the write; a list field is never compared with a scalar (`list-equality`), with the membership form for a CEL site, a flow condition and a `SharingRule` `condition`; a `date` / `datetime` field is its ISO text (`date-text-call`), with the helpers that replace date arithmetic; `label()` and the working-day functions belong to a formula or a stored field's `expression`; a dynamic seed value is the `cel` tag, never a JavaScript date; a `template` is not CEL, and only an email template reads a currency code from the send's data. The routing table keeps three more facts beside the rows that send them elsewhere: a `formula` field is virtual, so a filter, a sort and a search refuse it; a view filter is a structured rule or a date macro, not CEL; a form-view `visibleWhen` is client-side and faults open, so it is never access control.

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

- The per-function tables (what each function returns, `today()` as a calendar day at UTC midnight, `addMonths` clamping to the month end, `floor` and `ceil` rounding toward the infinities, the `rmbUpper` example, what `isBlank` and `isEmpty` count as empty), the date recipe for an inclusive span, and the working-day counting rules (the start day is not counted, the end day is): https://objectstack.ai/docs/data-modeling/formulas. An unknown or misspelled function fails `os build`, with a did-you-mean when an advertised name is close.
- The legacy translation table beyond the rows first check 3 keeps (`IF`, `CONCAT`, `TODAY()` / `NOW()`, `IN (…)`, `ISCHANGED`, the functions with no CEL counterpart): the same page, "Migration from the legacy formula DSL". Each legacy spelling fails the build.
- The table of surfaces that take an expression, the carriers of the `cron` and `template` dialects, the cron grammar and the refused `Object.titleFormat`: the contract, `node_modules/@objectstack/spec/src/shared/expression.zod.ts` and the schema of the key in hand. A save and `os validate` refuse the retired key.
- The table of where `previous` is bound, the rule that a `before*` handler's per-row rewrite must assign one key set on every row (`MULTI_UPDATE_HOOK_KEY_DIVERGENCE`): `skills/objectstack-data/references/data-hooks.md`, which the routing table names.
- The skill-boundary table: the frontmatter description and the routing table.
- Cut with no pointer, because nothing an author writes depends on them: the engine named behind each dialect, the receiver-method note and the four withheld primitives, the tenure-in-years recipe (a `daysBetween` divided by 365), and the sentence that a `SharingRule` whose condition does not lower is skipped at run time (the build fails first).

**Anchors that no longer exist in `SKILL.md`.** Every section heading of the old file below its title: `#skill-boundaries`, `#core-contract`, `#cel-syntax-cheat-sheet`, `#has-is-not-a-null-check`, `#objectstack-cel-standard-library`, `#mandatory-patterns-for-ai-emission`, `#1-computed-text-formula--always-coalesce-nullable-operands`, `#2-conditional-numeric-formula--guard-divisor`, `#3-predicate-field-rules--visibility--validation`, `#4-dynamic-seed-value--use-cel-not-new-date`, `#5-update-hook-condition--previous-vs-record`, `#mechanical-translation-table-legacy--cel`, `#surfaces-that-take-an-expression`, `#cel-surfaces-predicates--computed-values`, `#cron-and-template-surfaces`, `#verify-your-work`, `#see-also`. The new ones are `#first-checks`, `#scope-and-functions`, `#traps` and `#where-to-go`; the title's anchor is unchanged. No file in this repository linked an anchor of the old entry.
19 changes: 18 additions & 1 deletion scripts/check-skills-token-ratchet.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,24 @@ export const CEILINGS = new Map([
// 6090 -> 6088: the action `visible` / `disabled` paragraph says "a list row" where it wrote
// the retired action location word `list_item` (-7 bytes); the row follows the measurement
// down, 24384 bytes (24357 priced) -> 24377 (24350 priced) -> 6088 tokens.
['skills/objectstack-formula/SKILL.md', 6088], // -53 (was 6055), then -5 A2′ (was 6002), then +11 (was 5997), then +82 (was 6008), then -2 (was 6090)
// 6088 -> 2243 (#34770): the entry becomes a router. It keeps four first checks, one
// type-checked block of the three tags, the roots and the advertised function names as one
// list (`packages/formula/src/skill-catalog-sync.test.ts` reads them here), eight traps 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 (`shared/expression.zod.ts` and the key's own
// schema), to `os validate` / `os build` (syntax, unknown functions, `date-text-call`,
// `list-equality` and the nullable-operand refusal are errors there) or to the published
// formulas page. No row rises and no row is added. The router was first measured at 8974
// bytes; the contract review of its PR then asked for two fixes, paid in the entry: the
// checked block's transition line gains its insert guard (`previous != null && `, +20) and
// the sentence on a condition that cannot evaluate names the hook again (+7), against one
// blank line and one comma (-2). The file is 24377 bytes (24350 priced) -> 8999 (8972
// priced) -> 2243 tokens, pinned AT the measurement; the sum of all ceilings falls by the
// same 3845.
// Authority: the ruling of record that orders the entry file down to router size, decision
// record #34691 S3 = A.
// ceil(($(wc -c < skills/objectstack-formula/SKILL.md) - 27) / 4) == ceil(8972 / 4)
['skills/objectstack-formula/SKILL.md', 2243], // -53 (was 6055), then -5 A2′ (was 6002), then +11 (was 5997), then +82 (was 6008), then -2 (was 6090), then -3845 (was 6088)
// 6333 -> 6315: the top-level group list gains `packages` (`name` / `description` by
// `manifest.id`, the `os lint` warning `i18n/missing-package` and what clears it), and the
// `_relatedLists` row's remedy names both routes under a `.custom` arrangement (the owner's
Expand Down
Loading
Loading