Skip to content

Commit 5bd786e

Browse files
docs(skills): the objectstack-query entry file becomes a router (#38821)
<!-- claude-projects-attribution: {"github_login":"os-steve"} --> _Requested by **Steve** · [project thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi99QsuPTPkC1uKm2mViUT3Rf)_ Part of #34770 Clause-②: no Metadata-protocol: none `Part of`, not the closing form: the catalog-size line of the card's Done-when is not met by this PR. This is PR 6 of the per-skill split, under claim 7280537583 and its amendments 7280758590, 7288186602 and 7296541080. ## 维护者速读 - 用户能看到什么变化:用户无感。发给 AI 的「查询」技能说明,入口文件从约 18 KB 缩到 9 KB:入口只留开工前四项检查、一段可照抄的查询写法、七个「写得通过、跑起来却答错或变慢」的坑、全文搜索的规则、已下线写法的替代表,以及其余内容去哪里查的指路表。 - 为什么做:这是「技能目录瘦身」的第九份(界面、数据、自动化、平台、跨大版本升级、多语言翻译、表达式与公式、接口设计八份已完成)。入口文件每次都整份装进 AI 的上下文,越长越贵,也越容易漏读。 - 出错会怎样:只动教 AI 的文字,没有产品行为变化;风险是 AI 少读一段后答错。评测已在定稿上整轮跑完(十道题,每题三遍,改动前后同一时段各一轮):改动后三十次对二十六次,改动前三十次对二十九次;没有哪道题在改动后三遍全错,按既有裁决不算退步。少对的几次集中在两道题:「按关键词搜任务并显示负责人」改动后三遍对一遍、改动前三遍对两遍(这道题另各加测六遍:改动后对三遍,改动前对四遍,两边都时对时错);「按台北时区分月统计」改动后三遍对一遍,错的两遍内容是对的,只是没用题目要求的原词。可整笔撤回。 - 要你做什么:无。席位核对与合约审查都通过后,才会按治理规则请审批人批准。 ## Rulings this executes - **Card Scope** (decision record on the card, S3 = A): the entry file holds first checks, at most about 8 traps and a routing list; 6–9 KB, hard cap 500 lines; restated option lists and tables go behind a pointer; no trap is removed until a publish-time check covers it or it stays inline. - **7128031203** fork 4 = A: ratchet rows are pinned at the measurement with zero headroom, and the sum of ceilings does not rise. Here two rows fall, no row rises and none is added. - **7168461386** = A: text an eval shows the entry lost goes back into the entry, paid inside the entry. **Used once**: the first after-round showed case 4 lost (0 of 3 against 1 of 3 on `main`); three pieces of text went back and four cuts paid for them (see Eval parity). - **Ruling record 7249189592**, the parity rule: a case whose result flips between runs on both trees is unstable on both and does not block; a case that fails on every run of the head while `main` passes is a regression. Read below on full rounds of both trees in one window: no case fails on every run of the head. - **Seat order for this PR** (claim amendment 7296541080, PR 6 = `objectstack-query`): the same shape as PRs 3 to 5; no new file under `skills/` (a new file needs a new ratchet row, which stays with a human). This skill has three hand-written rules files, each with its own row, so text could have moved into them under fork 4 = A. None did: every fact that left the entry was already in a rules file, in the contract or on the published page. ## Review rounds **Second round** (contract review 7300640479 on `410a7ed7`: passed, with one should-fix), commit `25cf270b`. - **S1, fixed.** The search section said a dotted path in `searchFields` "is refused". That holds at the protocol door, which judges every name, and on an engine call only when no listed name is searchable: the engine's refusal (`refuseSearchOverrideNamingNoSearchableField`) fires on an all-unknown list, and its test keeps the tolerance for a partly-known one ("a partly-known override still narrows to its known names"). So `searchFields: ['title', 'project_id.name']` on the engine call the entry teaches is accepted and searches `title` alone: a wrong answer with no error. The bullet now reads: "a dotted path (`project_id.name`) is refused at the protocol door and when it stands alone; beside real fields the engine drops it silently." Paid inside the entry: the three schema names after the closed-set rule (first check 3 already routes to the file that holds them) and a few words of first check 4. The entry is 8,984 bytes; the row stays 2240 and the sum of ceilings does not move. - **N1, not taken.** The closed-set sentence still does not list `find`'s six driver passthrough keys. The refusal prints them, the changeset says where they are declared, and listing them costs bytes this round had to find for S1. - **N2, not taken.** Trap 5's keyset example sorts by `created_at` alone, and the warning that a repeating sort key can skip or repeat rows at a page boundary stays in `rules/pagination.md`. Every recorded run of the paging case, on both trees, opened that file. Open to the seat: it is the same class as the traps kept inline, and adding it needs a paying cut. **First round** (contract review of `b8182abb`: one should-fix and two nits), commit `d74dc1de`. - **S1, fixed.** The operator list carried `$like` / `$ilike` bare. A pattern with no wildcard is accepted and compares exactly (the contract's own description: the pattern must cover the whole value, and a pattern with no wildcards is an exact comparison, not a substring search), which is a silent wrong answer, the class this entry keeps inline. Trap 2 now ends: "`$like` / `$ilike` match the WHOLE value and you write the `%`: `{ name: { $like: 'acme' } }` is an exact match." Paid inside the entry by three cuts, each loud or already said elsewhere: the REST refusal of a search field outside the searchable set, "applied before counting or grouping" after the `count` / `aggregate` search sentence, and "Unsorted pages are not stable." - **N3, fixed.** First check 2 said a query names nothing beyond the object's declared fields, while the entry's own example uses `created_at` and `owner_id`. It now reads "the object's fields (declared or platform-injected; a query invents none)". - **N1, fixed.** The changeset pointed the six driver passthrough keys at `data/data-engine.zod.ts`, which does not hold them. It now names the driver options contract (`data/driver.zod.ts`) for the keys and says which method takes them is the engine's own list, printed by the refusal. ## What changes **The entry file becomes a router.** `skills/objectstack-query/SKILL.md`: 18,455 → 8,984 bytes, 429 → 154 lines, 4,607 → 2,240 tokens. Frontmatter (description, tags) is byte-identical. It now holds: - `## First checks`, four: the installed contract wins over the `compatibility` line; read the object's fields (declared or platform-injected), which of them are relation fields, and its `searchableFields`; read the contract and never recall a key or an operator (`references/_index.md` for the query and filter schemas, `data/data-engine.zod.ts` for each engine method's option keys); `os validate` reads no query in code, so run the query, while query metadata (a list view's filter, a dashboard dataset) is judged by it. - `## Calling convention`: one type-checked block (a `find` with `where`, `fields`, `orderBy`, `limit` and `expand`; a system read with `context: { isSystem: true }`; an `aggregate` with three measures, one carrying its own `filter`), then the closed-set rule (a key outside a method's set is refused by name with the legal list), what an `aggregate` bag does not take, what a literal carrying `object` is, and the operator names as one list with the four combination rules. - `## Traps`, seven, each accepted and answering wrong or slow with no error: a read with no `context` returns fewer rows; four string operators compare case-sensitively, and `$like` / `$ilike` match the whole value; a column with no value fails every ordering test, and `$null` misses blank text where `$empty` does not; `expand` reads the foreign key off each row, skips a key that is not a relation field, and applies only `fields`, `where` and a further `expand` of a nested value; a page needs `orderBy` and a keyset must match its direction; `where`, `having` and a measure's `filter` scope three different things, with the rule for which side buckets a date under a non-UTC `timezone`; a date computed at module load freezes, with the tokens, the week key and the now-anchored comparand. - `## Full-Text Search`: the bare-string form with `searchFields`, the matching rules, that `count` and `aggregate` take the same pair, that `search` never traverses (where a dotted path is refused and where the engine drops it silently; the stored mirror, with the `searchFields` to write), and the six knobs that validate and do nothing. - `## Removed keys`: all six rows, each with what to write. - `## Where to go`: six rows (the three rules files, the published query-syntax page, objectstack-ui, objectstack-data). **No text moved.** What left the entry was cut, each behind what now answers it. `rules/filters.md` changes two pointers that named sections the entry no longer has (the line under its operator list, and the sibling-keys note): 10,382 → 10,361 bytes. `rules/aggregation.md` and `rules/pagination.md` are untouched; their pointers to "the removal table in `SKILL.md`" and "the calling convention in `SKILL.md`" still hold. | Old entry section | Now | |:--|:--| | Calling Convention (the per-method key table, the passthrough six, the alias folding) | `## Calling convention`: the block and the closed-set rule; first check 3 names the contract file. Cut to the contract (`data/data-engine.zod.ts`): each method's key list and `top` / `filter` folding. Cut: the six driver passthrough keys and why `count` and `aggregate` refuse them; the driver options contract (`data/driver.zod.ts`) holds the keys, and which method takes them is the engine's own list. An unknown key is refused by name and the refusal prints the legal keys, the passthrough ones included. | | Which filter dialect? | The objectstack-ui routing row, which names `VIEW_FILTER_OPERATORS`. | | Execution Context (`context`) | Trap 1 and the block's system read. Cut: the `403 PERMISSION_DENIED` refusal of a context with no user, position or permission set (loud when hit), and that a write takes its context only as the trailing argument (the contract, `contracts/data-engine.ts`). | | Removed Keys → Live Replacement | `## Removed keys`, six rows. Cut: the second alternative for `array_agg` / `string_agg` (a stored roll-up field) and the sentence dating the removal; objectstack-upgrade, which the entry names, holds the register. | | Quick Reference — Detailed Rules | `## Where to go`. | | Filter Operators (six operator tables and their examples) | The operator names as one list, linked to `rules/filters.md` § Operator Reference (one example each), and traps 2 and 3; trap 2 keeps that `$like` / `$ilike` match the whole value. Cut to the contract (`data/filter.zod.ts`, each operator's `.describe()` text) and the published page: purpose, SQL equivalent, value types; the view-filter `is_empty` lowering; the refusal of `$empty` on an undeclared column. | | Filtering by a related record; Cross-field comparisons | The `query.joins` row keeps the shape `{ customer: { country: 'US' } }`; trap 7 keeps the now-anchored comparand. The rest was already whole in `rules/filters.md` § Relation Filters, § Field References and § Now-Anchored Comparands. | | Sorting | The block's two-key `orderBy` and trap 5. Cut: array order is sort priority and `order` defaults to `'asc'` (the contract); index advice is the objectstack-data routing row. | | Pagination | Trap 5 (the keyset shape, the direction rule, what an `offset` still costs) and `rules/pagination.md`, whose § Sorting with Pagination says why an unsorted page is not stable. | | Aggregation | The block's `aggregate` call, the sentence under it, and trap 6. | | Expand (Related Records) | The block's `expand` with the foreign key kept in `fields`, and trap 4. Cut: the batched-read note and the nested example. | | Full-Text Search | Kept under the same heading, shorter. Cut to the published page and objectstack-data's Search Fields reference: the expanded-filter comment block, the protocol spelling of the narrowing key, the description of the default searchable set, the REST refusal of a name outside the set (`400 INVALID_FIELD`, loud when hit). Cut to the contract's docblocks: that `count` and `aggregate` apply the pair before counting or grouping. | | Common Patterns: Cross-Object Queries | Trap 4 (display; page or sort related records by querying the related object), the search section (the stored mirror), `rules/filters.md` § Relation Filters, the objectstack-ui routing row. | | Common Patterns: Pagination Pattern for APIs; Dashboard Aggregation Pattern | `rules/pagination.md`; the block's per-measure `filter` and trap 6 ("a total and a conditional count share one call"); dashboards are the objectstack-ui routing row. | | Verify your work; References | First checks 4 and 3. | **Sizes** (bytes · lines · ratchet tokens): | | before (`main` at `13a0d3fe`, merged in) | after (head `655229c6`) | |:--|--:|--:| | `SKILL.md` (entry) | 18,455 · 429 · 4,607 | 8,984 · 154 · 2,240 | | `rules/filters.md` | 10,382 · 217 · 2,596 | 10,361 · 217 · 2,591 | | `skills/objectstack-query/**` (7 files) | 55,118 · 1,318 | 45,626 · 1,043 | | all 14 `SKILL.md` together | 152,901 · 2,769 | 143,430 · 2,494 | | whole `skills/` tree (115 files) | 1,193,953 | 1,184,461 | | whole tree without `evals/` (73 files) | 829,914 | 820,422 | | ratchet: authored tokens = sum of all ceilings | 189,821 | 187,449 | | ratchet: bundle total, tokens | 295,693 | 293,321 | The head column is measured, and so are the byte and line figures of the `main` column (the files of `main` at `13a0d3fe`). The two ratchet figures of the `main` column are the head's reading plus the fall of this skill's two rows: the entry and `rules/filters.md` are the only files under `skills/` that differ (`git diff --stat origin/main HEAD -- skills`: 2 files). `main` raised another skill's row since the last round, which is why both columns are higher than in the earlier body. **Budget reading:** the entry is 8,984 B, inside the card's 6–9 KB line, and 154 lines against the 500-line cap. The whole catalog is 9,492 bytes smaller, all of it cut. **Ratchet rows** (`scripts/check-skills-token-ratchet.mjs`), each pinned AT its measurement, zero headroom. Two rows move, both down: - `skills/objectstack-query/SKILL.md` 4607 → 2240 (−2,367): `ceil((8984 − 27) / 4) = ceil(8957 / 4) = 2240`. Why: the entry became a router. The two review rounds moved the file from 8,984 to 8,987 bytes and back to 8,984; the row did not move (2240 is the measurement of each). - `skills/objectstack-query/rules/filters.md` 2596 → 2591 (−5): `ceil(10361 / 4) = 2591`. Why: the two pointer lines are 21 bytes shorter. The rows of `rules/aggregation.md` (2346) and `rules/pagination.md` (1289) do not move. The sum of all ceilings goes 189,821 → 187,449 (−2,372). No row rises and none is added. ## Tests ### Eval parity Command, every full round: `pnpm --filter @objectstack/scenarios skill-evals --skills objectstack-query --repeats 3 --concurrency 4 --max-utilization 0.99`, with the model and effort flags PR 3's rounds used; CLI 2.1.333, subscription login. 10 behaviour cases in `evals/filters-pagination-search.json` on both arms and 7 trigger cases in `evals/triggers.json`, both files untouched: 81 turns a round. **The reading the rule is judged on**: one full round on each tree, run back to back in one window, on the pushed head and on the `main` it merged. | case | subject | `main` at `13a0d3fe` (with-skill · no-skill) | head `655229c6` (with-skill · no-skill) | |:--|:--|--:|--:| | 1 | filters, `$in`, case-blind match, two-key sort | 3/3 · 0/3 | 3/3 · 0/3 | | 2 | keyset paging for an infinite scroll | 3/3 · 0/3 | 3/3 · 0/3 | | 3 | grouped measures with `count_distinct` | 3/3 · 0/3 | 3/3 · 0/3 | | 4 | search across a related record's title, with `expand` | 2/3 · 0/3 | 1/3 · 0/3 | | 5 | a system read in a hook | 3/3 · 0/3 | 3/3 · 0/3 | | 6 | now shifted by a field's days | 3/3 · 0/3 | 3/3 · 0/3 | | 7 | blank text with `$empty` | 3/3 · 0/3 | 3/3 · 0/3 | | 8 | a total and a conditional count in one call | 3/3 · 0/3 | 3/3 · 0/3 | | 9 | month buckets under a `timezone` | 3/3 · 0/3 | 1/3 · 0/3 | | 10 | the current-week tokens | 3/3 · 0/3 | 3/3 · 0/3 | | **all** | | **29/30 · 0/30** | **26/30 · 0/30** | | triggers | loaded when it should · left alone when it should not | 15/15 · 3/6 | 15/15 · 3/6 | | case 4 again, 6 runs an arm, right after | | 4/6 · 0/6 | 3/6 · 0/6 | Both full rounds ran 81 of 81 turns (4.2 and 4.3 minutes); the two case-4 reads ran 12 of 12 turns each. **Reading under the parity rule: no regression.** No case fails on every run of the head. The head's total is three lower than `main`'s in this window, all of it in two cases that flip on both trees: - **Case 4: head 1 of 3 and then 3 of 6; `main` 2 of 3 and then 4 of 6.** This is the case whose text the second review round changed, so it was read six more times on each tree. The head's failing answers put the keyword in a `where` `$or` with a relation condition on the project, repeat the entry's new sentence (the dotted path "is refused, or silently dropped next to real fields"), and offer the stored mirror with `searchFields: ['title', 'project_name']` as the alternative; they miss the literal `stored` (they write "store the project name on the task"). `main`'s failing answers miss the same literal, or `owner_id` and `searchFields`. Across every full or targeted read: `main` 9 of 15; the router's text between the restoration and this round 7 of 9; the text of this round 4 of 9. Unstable on both trees, and lower on this round's text than on the text before it, by a margin that nine runs cannot separate from chance. Open question for the seat (see the report): accept under the rule, or reword the bullet so the stored mirror comes before the `where` alternative. - **Case 9: head 1 of 3; `main` 3 of 3.** Both failing answers give the right table (the database buckets on PostgreSQL with `Asia/Taipei`; a fixed offset or SQLite stays in memory) and miss a literal by its form: one writes "the database does the bucketing", the other capitalises "In memory" in a table cell. The text the case draws on (trap 6) has not changed since the first router commit. Across all rounds: head 10 of 12, `main` 7 of 9. - **Case 2: 3 of 3 on both.** Its earlier failures on the router's text (a function parameter named `cursor`, which the case's forbidden literal `cursor:` catches) did not recur: 5 of 16 runs across all router rounds, 0 of 9 on `main`. - **Triggers.** Trigger 7 (a list view's filter) loads the skill on every run of both trees; trigger 6 was left alone on every run of both. The frontmatter that decides loading is byte-identical on both trees. **Earlier rounds**, kept as the record of how the text got here: | reading | tree | with-skill | no-skill | with-skill cases below 3 of 3 | |:--|:--|--:|--:|:--| | before round, 81 of 81 turns | `0fc9eab9` (the first branch point) | 26/30 | 1/30 | case 4, 1 of 3 (missed `owner_id`, `stored`); case 9, 1 of 3 (missed `in the database`, `in memory`) | | after round 1, 81 of 81 turns | local `f9ed325e`, the first router commit (`11d8ae17` on this branch) | 25/30 | 1/30 | case 1, 2 of 3 (one answer used `$ilike`); case 2, 2 of 3; **case 4, 0 of 3** | | after round 2, cases 1, 2, 4 and 5 only, 24 of 24 turns | local `a2ece3bf`, after the restoration (`0a4ed24d` on this branch) | 12/12 | 0/12 | none | | after round 3, stopped by the quota guard after 4 of 81 turns | the same skill text | case 1: 1 of 1; case 2: 0 of 1 | 0/2 | case 2 | | after round 4, stopped on the seat's order after 76 of 81 turns (all 60 behaviour turns, 16 of 21 trigger turns): the first review fix had to land first | tree `cd045f3b`, the head before the review rounds | 27/30 | 0/30 | case 2, 1 of 3; case 4, 2 of 3 | | after round 5, 81 of 81 turns, with a `main` round beside it (`00f97b30`: 28/30 · 1/30; case 4, 2 of 3; case 10, 2 of 3) | `410a7ed7`, the head after the first review round | 28/30 | 0/30 | case 2, 2 of 3; case 4, 2 of 3 | **The restoration (ruling 7168461386).** After round 1, case 4 (search tasks by keyword across the title and the parent project's name, and show the assignee) failed all three runs: the answers put a relation condition in `where` and called the field `assignee`. Three pieces went back into the entry: the search bullet now says a relation condition in `where` is a filter, not a search, and gives `searchFields: ['title', 'project_name']`; the example's comment names `owner_id` as the record owner ("assignee"); trap 2 regains `{ email: { $icontains: '@company.com' } }` (case 1). Paid inside the entry: the objectstack-ask routing row (the frontmatter description carries it), the relation-condition sentence under the operator list (its shape moved into the `query.joins` row), an inline example in trap 4, and half a sentence of trap 1. The entry went from 8,989 to 8,984 bytes. **Quota readings** (the login's seven-day window, status `allowed_warning`, reset 2026-12-06 14:00 UTC; guard `--max-utilization 0.99` by the maintainer's choice recorded in claim amendment 7296541080, never raised). Before the maintainer's reset: before round 0.96 → 0.97; after round 1 0.97 → 0.98; after round 2 0.98; after round 3 stopped at 0.99, exit 3. After the reset: after round 4 0.54 → 0.55; after round 5 0.56 → 0.57 and its `main` round 0.57; this round's head round 0.64, its `main` round 0.64 → 0.65, the two case-4 reads 0.65. One check that calls no model, beside the rounds: of the 38 `must_contain` literals of the 10 cases, `main`'s entry carries 28 and the head's entry 35. One is lost, `engine.find('account'` (case 1; the router's example object is `task`, and an answer composes the call from the prompt); 8 are gained (cases 6, 8, 9 and 10); 2 are in neither tree (`timezone: 'Asia/Taipei'`, `plan_week: '{current_iso_week}'`, both composed from the prompt). Of the `must_not_contain` literals, `main`'s entry carries two (`orderBy:` of case 3, `'project_id.name'` of case 4) and the head's entry one (`orderBy:`, in the `find` example; case 3 is an `aggregate` case and read 3 of 3 on both trees). ### Other tests On the pushed head `655229c6` (tree `e1d917f5`), under the verify lock (`VERDICT command-exit 0`): - `pnpm --filter @objectstack/spec exec vitest run --maxWorkers=2 scripts/platform-catalog.test.ts scripts/skill-map-guards.test.ts scripts/query-pointer-row.test.ts` (the suite that names the ratchet script, the skill-map guards, and the test that names this skill's pointer row): `Test Files 3 passed (3)`, `Tests 61 passed (61)`. - `pnpm --filter create-objectstack exec vitest run --maxWorkers=2 src/created-summary.test.ts src/scaffold-skills-single-copy.test.ts` (the two test files there that name this skill): `Test Files 2 passed (2)`, `Tests 34 passed (34)`. Two more test files name the skill and were not run: `packages/cli/test/skills-commands.test.ts` uses the name with fixture strings, and a `driver-sql` test cites `rules/aggregation.md` in a comment; neither reads a file this PR changes. No ablation: the diff changes prose and one ledger, no tested behaviour. ## Acceptance notes Held by a gate or by another file, recorded here as it stands: - **`rules/filters.md` § Operator Reference stays where it is.** `scripts/check-skill-identifier-liveness.mjs` registers that section as exhaustive for `FILTER_OPERATORS`; the entry's operator list links to it. - **The heading `## Full-Text Search` is kept.** objectstack-ui's list-view rules send the reader to "objectstack-query → Full-Text Search" by name. - **The removed-keys table stays inline, all six rows.** Each is refused loudly, so the trap rule alone would let it go; but `rules/aggregation.md` and `rules/pagination.md` point at "the removal table in `SKILL.md`" four times, and the table is where a model that remembers an old key learns what to write. Decided here (small, no shipped behaviour), each open to reversal in review: - **"No trap is removed unless a publish-time check covers it or it stays inline" was read as: a query that is accepted and then answers wrong or slow with no error stays inline.** Inline: the seven traps and the two search bullets. Cut to a pointer, each loud when hit: the per-method key lists (an unknown key is refused by name with the legal list), a context with no identity (`403`), a relation filter past its limits (`INVALID_FILTER`), `$empty` on a column with no declaration, a search field outside the searchable set (`400`). - **Traps 3, 6 and 7 state inline what `main`'s entry left to the rules files**: the `$or` with `$null` beside an ordering test, which side buckets a date under a `timezone`, the tokens, the week key and the now-anchored comparand. Each is a silent wrong answer, and eval cases 6, 8, 9 and 10 ask for them; case 9 read 1 of 3 on `main` and 3 of 3 here. The rules files still hold the detail. - **Trap 6 is scoped to where it is true.** The database buckets a non-UTC date only on a driver that declares `supports.zonedDateBucketing` and only for an area/location zone name; a fixed offset, or any other driver, keeps the call in memory with the same buckets. The cost is speed, which is why the list's opening line says "wrong or slow". - **Trap 4 says "the engine skips any other" key**, not "returns nothing": the sentence is about the engine call the entry teaches. - **Two statements of `main`'s entry were corrected in passing, inside this file.** Its `count` row listed `context` and `where` only, and the contract also takes `search` and `searchFields` (`EngineCountOptionsSchema`). It said an `expand` key must be a `lookup` or `master_detail` field, and the engine resolves `user` and `tree` fields too. - **The example calls the assignee field `owner_id`**: objectstack-data's rule is that `owner_id` is the platform-injected record owner, also when the request says "assignee", and eval case 4 asks for the name. - **The operator names stay inline as one list** (0.3 KB): first check 3 says never recall an operator, and the list is the vocabulary to choose from before the rules file is opened. - **The docs link was checked by hand.** `check:published-readme-links` does not read `skills/` (a deliberately broken link in the entry still passed, and the file was restored), so its green says nothing about the entry's link. The page exists as `content/docs/protocol/objectql/query-syntax.mdx` and is listed in its `meta.json`. - **Section anchors of the entry changed.** The changeset lists every anchor that left `SKILL.md` (24) and the five new ones; the title's anchor and `#full-text-search` stay. No file in this repository links one of the old ones. - **Four lines in the summary above, not six**: the standing order for this card thread asks for six, and the agent file that binds the dev fixes four named lines and wins on conflict. - **Footer form**: this body ends with the single block AGENTS.md prescribes for a PR body. Noted, not changed: - Three eval cases grade a literal that a correct answer can miss or carry: case 2 forbids `cursor:` and so fails an answer whose function takes a parameter of that name; case 1 fails an answer that uses `$ilike`; case 9 requires the phrases `in the database` and `in memory` in that casing. The parity rule treats the cases as fixed, so this PR does not touch them. Carrier: none; noted for whoever owns the case file. - Trigger case 7 (a list view's filter, which should not load this skill) loads it on every run of both trees, with this bundle the only one installed in the turn. Carrier: none; the eval seat's reading. - The contract's docblock on `expand` (`data/data-engine.zod.ts`) says keys are lookup or master_detail fields and that a nested value controls sort; the engine resolves four relation types and re-keys the related rows by id, so a nested `orderBy` has no visible effect. A reading of two files, not a measured failure through a public door. Carrier: none. - `scripts/check-corpus-claim-drift.mjs` carries a self-test fixture label that cites `skills/objectstack-query/SKILL.md:154`. It is a label, not a live reference; the file is outside this claim's surface. - `main` moved during the work, five times: PR 5 of this split (#38802); a release-version commit that restamped every entry's `version` line (the same byte length, so no row moved); a commit that changed a gate script; a range that raised another skill's ratchet row (#38813, a different row, merged cleanly); and a range that changed a deploy workflow. Each was merged in as a plain merge commit; the textual merges were clean, the workspace was rebuilt after the last one and every gate below ran after it. ## Verification Read first, by risk: 1. `skills/objectstack-query/SKILL.md`, the whole file: is anything a model needs before opening the contract or a rules file missing? The risk hunks are `## Traps` (seven items replace most of the old file) and the one example block, which now carries the whole calling convention. 2. `.changeset/34770-query-skill-router.md`: the "what left, and what answers it now" list is the record of every cut. 3. `scripts/check-skills-token-ratchet.mjs`: the two `objectstack-query` rows. Two-minute check: `node scripts/check-skills-token-ratchet.mjs` prints `ratcheted (authored) 187449 / 187449 (+0)` and `skills/objectstack-query/SKILL.md 2240 / 2240 (+0)`; `wc -c skills/objectstack-query/SKILL.md` prints 8984. Gates, local, each exit code captured before any pipe. The whole derived list ran on the pushed head `655229c6` (tree `e1d917f5`), after the merge of `main` at `13a0d3fe` and a rebuild of the merged workspace. <details><summary>Derived families on head `655229c6`: 69 derived, 69 run green, 0 NOT MEASURED</summary> - Reconciliation: `✓ dispatch-gates --ran: 69 derived famil(ies) accounted for — 69 run, 0 NOT-MEASURED (a DERIVED zero — all 69 recorded an exit code and none of them is 3).` No STALE TREE warning against `main` at `13a0d3fe`, the ref the list was derived on. - `node scripts/check-skills-token-ratchet.mjs`: `✓ check-skills-token-ratchet: 61 authored bundle file(s) within their ceilings; 11 generator-owned file(s) and 42 eval fixture(s) measured, not ratcheted.` (`ratcheted (authored) 187449 / 187449 (+0)`, `bundle total 293321`); its `--self-test`: `111 cases pass`. - `pnpm check:dual-build-cjs-loads`: `127 published require entry point(s) across 75 package(s) load; 2594 emitted CommonJS file(s) parse`. It reads every package's built `dist/`; `pnpm build --concurrency=2` ran first on the merged tree under the verify lock (`VERDICT command-exit 0`, `124 successful, 124 total`). - `pnpm check:dts-closure`: `124 built package(s) swept - 326/326 declared declaration file(s) present`. - `pnpm check:skill-links`: `286 relative link(s) in 76 published skill file(s) resolve; 161 fragment(s) name a real heading under GitHub's slug rule.` - `pnpm check:skill-identifier-liveness`: `Leg 1: 494 citation(s) over 76 published file(s) ...; Leg 2: 11 registered exhaustive section(s), 0 ledgered gap(s).` - `pnpm --filter @objectstack/spec run check:skill-docs`, `pnpm --filter @objectstack/lint run check:doc-formula-expressions`, `pnpm check:skill-compatibility`, `check:skill-frame-sync`, `check:role-word`, `check:corpus-claim-drift`, `check:doc-authoring`, `check:published-files`, `check:nul-bytes`, `check:cross-package-test-inputs`, `check:ratchet-remedy-authority`: exit 0. - The changeset gates (`check-changeset-no-major`, `check-empty-changeset`, `check-adr-0087-registration`, `check:changeset-gate-self-tests`): exit 0. `pnpm check:pm-dispatch-gates`: exit 0. </details> <details><summary>Beside the derived list, on head `655229c6`, all exit 0</summary> - `pnpm --filter @objectstack/spec run check:skill-examples`, under the verify lock: `341 prose examples type-check across 3 surface(s)`. The entry's one block is among them. - `pnpm --filter @objectstack/spec run check:skill-refs`: `10 generated files in sync with packages/spec`. - `pnpm --filter @objectstack/spec run check:skill-served-sections`: `24 served section(s), each heading exactly once in its file`. - `pnpm check:doc-anchors`: `1190 internal #fragment link(s) across 368 source file(s) all resolve to a real heading`. - `pnpm check:published-readme-links`: `567 outbound link(s) across 169 published markdown file(s)`. It does not read `skills/` (see Acceptance notes). - `pnpm check:skill-top-level-keys`, `pnpm check:skill-frame-freshness`, `pnpm check:dev-prereqs`: exit 0. - `pnpm --filter @objectstack/spec run check:generated`, under the verify lock, after the merge and the rebuild: `All 14 generated artifacts are up to date`. - `node scripts/check-platform-checklist.mjs --changed-from origin/main`: `0 anchored files in the change set — nothing judged.` - `node scripts/check-nul-bytes.mjs`: exit 0; a control-byte scan of the four changed files finds none. </details> `node scripts/pm/overlap-check.mjs` before the push of `655229c6`: `VERDICT clean exit 0` (origin/main at `13a0d3fe` merges cleanly; no open PR shares a changed file). Not run locally: `test:repo` (CI's). Base: the four router commits were written on a local branch and cherry-picked onto the thread branch as `11d8ae17`, `0a4ed24d`, `5cc3f615`, `b8182abb` (local `f9ed325e`, `a2ece3bf`, `17197139`, `5b365fa9`). The first review round added `d74dc1de` between two merges of `main` (`c879b19a`, `410a7ed7`). The second added `25cf270b`, then two more merges of `main`, each a plain merge commit taken when the gate tool reported a stale tree (`d77374eb` for `6f82fd05`, `655229c6` for `13a0d3fe`). A full gate pass ran on `d77374eb` and was repeated in full on `655229c6`. `main` was still at `13a0d3fe` when the head was pushed. CI on the pushed head is the seat's reading. --- _Generated by [Claude Code](https://claude.ai/code/session_01ADHkmSM46qymk97AyqPzoS)_ <!-- signed: repo:objectstack@os-steve · os-steve · session_01ADHkmSAjFEZHRpRq3WCj6z --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 30aee20 commit 5bd786e

4 files changed

Lines changed: 172 additions & 387 deletions

File tree

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
'@objectstack/skills': patch
3+
---
4+
5+
docs(skills): the objectstack-query entry file becomes a router
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
`skills/objectstack-query/SKILL.md` goes from 18.5 KB to 9.0 KB (429 lines to 154). It now holds seven things: four first checks (the installed version wins over the `compatibility` line; read the object's fields, declared or platform-injected, its relation fields and its `searchableFields`; read the contract and never recall a key or an operator; a query in code is judged only when it runs, query metadata by `os validate`), the calling convention as one type-checked block (a `find`, a system read, an `aggregate`) with the closed-set rule, the operator names as one list, seven traps, `## Full-Text Search`, the removed-keys table, and a table that says where to go for the rest. No rule's teaching changes. No text moved between files: what left the entry was cut, and this entry says what now answers it. The three rules files (`rules/filters.md`, `rules/aggregation.md`, `rules/pagination.md`) keep their text; `rules/filters.md` changes two pointers (below).
11+
12+
**What the entry keeps.** The seven traps, each a query that is accepted and answers, wrong or slow, with no error: a read with no `context` runs as whatever identity the caller carried, so org-scoping returns fewer rows; `$contains`, `$notContains`, `$startsWith` and `$endsWith` compare case-sensitively and typed text wants `$icontains`, and `$like` / `$ilike` match the whole value, so a pattern with no `%` is an exact match; a column with no value fails every ordering test, in `where`, a measure's `filter` and `having` alike, and `$null` misses a text field saved blank where `$empty` does not; `expand` reads the foreign key off each row, so a projection that drops it returns no related data, a key that is not a relation field is skipped, and of a nested value only `fields`, `where` and a further `expand` take effect; a page needs `orderBy` and a keyset `where` must match the sort key and its direction; `where` scopes rows before grouping, `having` filters groups and a measure's `filter` scopes that measure, with the rule for which side buckets a date under a non-UTC `timezone`; a date computed at module load freezes into the built artifact, with the tokens to write in its place, `{current_iso_week}` as a text week key, and the now-anchored comparand `{ $now: true, addDays }`. The search section keeps the bare-string form with `searchFields`, the term and option-label matching, the narrowing rule, that `count` and `aggregate` take the same pair, that `search` never traverses (a dotted path is refused at the protocol door and when it stands alone, and listed beside real fields the engine drops it silently; mirror the related title into a stored field and name it in `searchFields`), and the six knobs of the object form that validate and do nothing. The removed-keys table keeps all six rows. Traps 3, 6 and 7 state inline what the old entry left to the rules files (the `$or` with `$null` beside an ordering test, which side buckets a date under a `timezone`, the tokens and the week key); the rules files still hold the detail.
13+
14+
**What left, and what answers it now.**
15+
16+
- The table of each engine method's legal option keys and the `top` / `filter` alias folding: the contract, `node_modules/@objectstack/spec/src/data/data-engine.zod.ts` (`EngineQueryOptionsSchema`, `EngineAggregateOptionsSchema`, `EngineCountOptionsSchema`). The six driver passthrough keys (`transaction`, `tenantId`, `tenantIds`, `timezone`, `bypassTenantAudit`, `preserveAudit`) with the reason `count` and `aggregate` refuse them: that file does not hold them; the driver options contract does (`node_modules/@objectstack/spec/src/data/driver.zod.ts`), and which method takes them is the engine's own list. A key outside a method's set is refused by name, and the refusal prints that method's legal keys, the passthrough ones included. The entry states the closed-set rule without the three schema names; its first check 3 names the file. The old table's `count` row listed `context` and `where` only; the contract also takes `search` and `searchFields` there, and the entry now says so.
17+
- From the execution-context section: that a context carrying no user, position or permission set is refused `403 PERMISSION_DENIED`, which is loud when hit, and that a write takes its context only as the trailing argument, which is the contract (`node_modules/@objectstack/spec/src/contracts/data-engine.ts`). Trap 1 keeps the silent half: fewer rows, with no error.
18+
- From the removed-keys section: the second alternative for `array_agg` / `string_agg` (materialise the roll-up as a stored field), and the sentence dating the removal to `@objectstack/spec` 17. objectstack-upgrade, which the entry names, holds the register.
19+
- The operator tables (purpose, SQL equivalent, value types), the implicit-equality and logical-operator examples, and the notes under the null and existence operators (a view filter's `is_empty` / `is_not_empty` lowers to `$empty`; a face that judges by declared type refuses `$empty` on a column it holds no declaration for): the contract, `node_modules/@objectstack/spec/src/data/filter.zod.ts`, where each operator's `.describe()` text says what it does. `rules/filters.md` § Operator Reference has one example of each operator, and https://objectstack.ai/docs/protocol/objectql/query-syntax has the tables.
20+
- The relation-filter paragraph (the driver capability it needs, the three-relationship limit, the 1000-id cap, the caller's permissions at every hop, the two-step route) and the cross-field paragraph: `rules/filters.md` § Relation Filters, § Field References and § Now-Anchored Comparands, which already held all of it. The entry keeps the shape of a relation condition in the removed-keys row for `query.joins`.
21+
- The "which filter dialect" table: the routing row for objectstack-ui, which names `VIEW_FILTER_OPERATORS`.
22+
- The sorting rules (array order is sort priority, `order` defaults to `'asc'`), the offset-paging block and the "Pagination Pattern for APIs" block: `rules/pagination.md` (its § Sorting with Pagination also says why an unsorted page is not stable) and the contract. Index advice is the routing row for objectstack-data.
23+
- The aggregation call-shape block and the "Dashboard Aggregation Pattern" block: the entry's one block shows a grouped call with a per-measure `filter`; the rest is `rules/aggregation.md` § Filtered Aggregation. Dashboards and reports are the routing row for objectstack-ui.
24+
- From the expand section: that the engine resolves an expand with batched `$in` reads, and the nested-expand example. Nothing an author writes depends on the first; trap 4 states the three-level limit and the contract carries the shape. The old rule said an `expand` key must be a `lookup` or `master_detail` field; the engine resolves `user` and `tree` fields too, and trap 4 names all four.
25+
- From the search section: the comment block that showed the expanded filter, the note that the protocol's `$searchFields` and the object form's `search.fields` spell the same narrowing (the entry says to write `searchFields`), the description of the default searchable set (name or title, short-text fields, fields marked `searchable: true`), the REST refusal of a name outside that set (`400 INVALID_FIELD`, loud when hit), and that `count` and `aggregate` apply the pair before counting or grouping (the contract's docblocks on those two option sets): the published page above, § Full-Text Search, and objectstack-data's Search Fields reference (`searchableFields`), which the entry names.
26+
- The "Cross-Object Queries: Which Tool to Use?" table: trap 4 (`expand` to display; page or sort related records by querying the related object), the search section (the stored mirror), `rules/filters.md` § Relation Filters (filter by a lookup target's column, and a parent by its children in two steps) and the routing row for objectstack-ui (analytics across objects).
27+
- The "Quick Reference" list: the routing table. The "Verify your work" and "References" sections: first checks 4 and 3. The `os build` spelling is objectstack-platform's (its "Verify your work" reference), a scaffolded project's `npm run validate` alias is in that project's own `package.json`, and the sentence on a dashboard widget whose dataset does not resolve is objectstack-ui's (its dashboard rules).
28+
- The routing line to objectstack-ask: the frontmatter description, which is unchanged.
29+
30+
**`rules/filters.md`.** Two pointers named sections the entry no longer has. The line under the operator list sent the reader to the entry's "Filter Operators" section for purpose, SQL equivalent and case sensitivity; it now names the contract (`data/filter.zod.ts`) for what each operator does and the entry's trap 2 for case sensitivity. The sibling-keys note no longer points at the entry's "Logical Operators" section. The file is 21 bytes smaller and nothing else in it changed.
31+
32+
**Anchors that no longer exist in `SKILL.md`.** `#calling-convention--object-is-the-first-argument`, `#which-filter-dialect`, `#execution-context-context`, `#removed-keys--live-replacement`, `#quick-reference--detailed-rules`, `#filter-operators`, `#implicit-equality-shorthand`, `#comparison-operators`, `#set--range-operators`, `#string-operators`, `#null--existence-operators`, `#logical-operators`, `#filtering-by-a-related-record`, `#cross-field-comparisons`, `#sorting`, `#pagination`, `#aggregation`, `#expand-related-records`, `#common-patterns`, `#cross-object-queries-which-tool-to-use`, `#pagination-pattern-for-apis`, `#dashboard-aggregation-pattern`, `#verify-your-work`, `#references`. The new ones are `#first-checks`, `#calling-convention`, `#traps`, `#removed-keys` and `#where-to-go`; the title's anchor and `#full-text-search` are unchanged. No file in this repository linked an anchor of the old entry.

‎scripts/check-skills-token-ratchet.mjs‎

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,7 +1232,28 @@ export const CEILINGS = new Map([
12321232
// 「发布版 skills/objectstack-pm-dispatch 删」). A row for a file the walk cannot
12331233
// read is red, not a skip (#4690), so the rows go with the files; the bundle
12341234
// total drops by the two ceilings, which is the ratchet's ordinary direction.
1235-
['skills/objectstack-query/SKILL.md', 4607], // -17 (was 5569), then -5 A2′ (was 5552), then -940 to the measurement (was 5547)
1235+
// 4607 -> 2240 (#34770): the entry becomes a router. It keeps four first checks, the calling
1236+
// convention as one type-checked block (a find, a system read, an aggregate) with the
1237+
// closed-set rule and the operator names as one list, seven traps (each is accepted and
1238+
// answers, wrong or slow, with no error), `## Full-Text Search` (no rules file holds it and
1239+
// objectstack-ui names the section), the removal table the three rules files point at, and a
1240+
// routing table. Nothing MOVED: what left is CUT behind what already says it, the three
1241+
// rules files (rows below), the contract (`data/filter.zod.ts` describes each operator,
1242+
// `data/data-engine.zod.ts` holds each method's option keys, and the engine's refusal of an
1243+
// unknown key prints the legal ones) or the published query-syntax page. No row rises and
1244+
// no row is added; `rules/filters.md` falls 5 with it (row below). The router was first
1245+
// measured at 8989 bytes; the parity round then put back, paid in the entry, the
1246+
// `$icontains` example of the case-sensitivity trap and the stored-mirror prescription for a
1247+
// search by a related record's title. The review round then added, paid in the entry, that
1248+
// `$like` / `$ilike` match the whole value (8984 -> 8987 bytes, the same 2240 tokens), and
1249+
// the second review round, also paid in the entry, that the engine silently drops a dotted
1250+
// search field listed beside real ones (8987 -> 8984). The file is 18455 bytes (18428
1251+
// priced) -> 8984 (8957 priced) -> 2240 tokens, pinned AT the measurement; with the filters
1252+
// row the sum of all ceilings falls by 2372.
1253+
// Authority: the ruling of record that orders the entry file down to router size, decision
1254+
// record #34691 S3 = A.
1255+
// ceil(($(wc -c < skills/objectstack-query/SKILL.md) - 27) / 4) == ceil(8957 / 4)
1256+
['skills/objectstack-query/SKILL.md', 2240], // -17 (was 5569), then -5 A2′ (was 5552), then -940 to the measurement (was 5547), then -2367 (was 4607)
12361257
// 25125 -> 25143: the CRM UI Blueprint — the catalog's module-completeness
12371258
// list, and the only place an agent is told what a finished module contains —
12381259
// priced `src/views/**`, `src/apps/**`, dashboards and reports but never the
@@ -1912,7 +1933,14 @@ export const CEILINGS = new Map([
19121933
// bytes: 9876 landed -> 10382, +506 -> 127 tokens, the row's 4 tokens of
19131934
// headroom absorbed, ceiling +123, pinned AT the measurement.
19141935
// ceil($(wc -c < skills/objectstack-query/rules/filters.md) / 4) == ceil(10382 / 4)
1915-
['skills/objectstack-query/rules/filters.md', 2596],
1936+
// 2596 -> 2591 (#34770): LOWERED. Two pointers named SKILL.md sections the router no longer
1937+
// has. The line under the operator list said "Purpose, SQL equivalent, case sensitivity:
1938+
// SKILL.md, Filter Operators"; it now names the contract (`data/filter.zod.ts`) for what
1939+
// each operator does and the entry's trap 2 for case sensitivity. The sibling-keys note
1940+
// drops its "(SKILL.md, Logical Operators)" parenthesis. No teaching moved in or out:
1941+
// 10382 -> 10361 bytes (-21); the ceiling follows the file down to the measurement.
1942+
// ceil($(wc -c < skills/objectstack-query/rules/filters.md) / 4) == ceil(10361 / 4)
1943+
['skills/objectstack-query/rules/filters.md', 2591],
19161944
['skills/objectstack-query/rules/pagination.md', 1289], // -93 to the measurement (was 1382)
19171945

19181946
// objectstack-ui `rules/` — the five files the #14296 item 1 split created.

0 commit comments

Comments
 (0)