Skip to content

Commit 144d368

Browse files
docs(skills): data-hooks says which refused regex patterns are errors and which only warn (#36970)
Fixes #36727 Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:使用数据技能包的 AI 助手,以前被告知「钩子脚本里写错的正则只会得到警告」,现在被告知实情:运行时也拒绝的正则会在保存和校验时直接报错,只有三种运行时其实能跑的写法才是警告。 - 为什么做:上一张已合并的卡把这类正则从警告改成了报错,技能包里这句话没跟上,AI 会照旧说法写出发布时被拦下的脚本。 - 出错会怎样:最坏是 AI 读到的说明仍不够准确,不影响任何运行行为;可以直接撤回本次合并。 - 要你做什么:无。 ## What changes One bullet of `skills/objectstack-data/references/data-hooks.md`, "Refused when it does not compile". Its last sentence said "A regex pattern the checking engine refuses is a warning: the runtime may accept it." That stopped being true when the compile rules were narrowed (merge commit `fe190968eb`, `packages/lint/src/validate-action-body-compiles.ts`). The sentence now reads: "A regex pattern the runtime refuses too is that error; only a duplicate named group, a modifier group (`(?i:a)`) or a Unicode property name only the runtime knows (any refused one on a pre-17.0-Unicode host) warns." Checked against the landed code, not the card's words: - `judgeBodyCompile` answers `warning` for the shape `regexp-dialect-gap` alone; `regexp-pattern` and every other shape is `error`. - The warning arm is the two V8 reasons `Duplicate capture group name` and `Invalid group` (`REGEXP_DIALECT_GAP_REASONS`), plus a property-name refusal where every refused name is on `REGEXP_PROPERTY_NAMES_ONLY_QUICKJS_KNOWS`. - `hostUnicodeAtLeastMeasured()` false (host Unicode tables older than 17.0, or none named) makes every property-name refusal a warning. - The hook and job rules read the same `judgeBodyCompile`, so "that error" is `hook-body-does-not-compile` (the three commands and a runtime save, `422 INVALID_METADATA`) and `job-body-does-not-compile` (the three commands), as the bullet already said. The file had 1 token of headroom, so the new sentence is paid for inside the same bullet. Dropped: "naming the hook, the `SyntaxError` and its line", the spelled-out rename example (`const data = ctx.input || {};`), and a few connecting words. Nothing outside the bullet moved, and no ceiling moved. Size readings (`node scripts/check-skills-token-ratchet.mjs`, tokens are `ceil(bytes / 4)`): | | before | after | |:--|:--|:--| | `data-hooks.md` lines | 885 | 885 | | `data-hooks.md` bytes | 40484 | 40488 | | `data-hooks.md` tokens (ceiling 10122) | 10121 | 10122 | | authored bundle tokens (ceiling 202623) | 197655 | 197656 | | whole shipped tree tokens | 294165 | 294166 | | all `SKILL.md` lines | 4941 | 4941 | A changeset is included (`@objectstack/skills`, patch), as every earlier edit of this file carries one. ## Tests Prose only: no tested behaviour changed, so no test and no ablation. Head `15b10bbc584`. ## Acceptance notes - The bullet teaches the hook and job rules only, as before. The action rule takes the same split; its paragraph in this file points here and was not touched. - The twelve measured property-name spellings are not listed in the skill: the token ceiling has no room, and the lint finding names the pattern. They are in `content/docs/automation/hook-bodies.mdx`. ## Verification Read first: the one hunk in `data-hooks.md`, against `judgeBodyCompile` and `isRegexpDialectGap` in `packages/lint/src/validate-action-body-compiles.ts`. Two-minute check: `node scripts/check-skills-token-ratchet.mjs` exits 0 and prints `data-hooks.md is 10122 tokens (ceiling 10122; headroom 0)`. Derived gates (`node scripts/pm/dispatch-gates.mjs --commands`, reconciled with `--ran`): 48 derived, 44 run and exit 0, 4 NOT MEASURED (`check:dts-closure`, `check:dual-build-cjs-loads`, `check:lean-entry-closure`, `check:sourcemap-no-sources-content` exit 3, PREREQUISITE NOT MET: they read a whole-workspace build this one-file prose edit did not make; CI runs them). --- _Generated by [Claude Code](https://claude.ai/code/session_01QSeKYpEsWWE9Y5YtSsDgqZ)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 23d61fa commit 144d368

2 files changed

Lines changed: 17 additions & 9 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
'@objectstack/skills': patch
3+
---
4+
5+
Clause-②: no
6+
Metadata-protocol: none
7+
8+
`objectstack-data`'s hook reference (`references/data-hooks.md`) no longer says every regex pattern the checking engine refuses is a warning. It now says what the compile rules do: a pattern the runtime refuses too is the same `hook-body-does-not-compile` / `job-body-does-not-compile` error, and only a duplicate named capture group, a modifier group such as `(?i:a)` or a Unicode property name only the runtime knows is a warning (on a host whose Unicode tables are older than 17.0, every property name it refuses). The file stays inside its token ceiling and its line count by tightening the same paragraph: it drops the note that the finding names the hook, the `SyntaxError` and its line, and the spelled-out rename example.

‎skills/objectstack-data/references/data-hooks.md‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -338,15 +338,15 @@ The body runs in an isolated QuickJS VM, **not** Node:
338338
a name bound at module scope, e.g. a `const slugify = …` helper sitting next to
339339
the hook. A `body` must be **self-contained**: inline the helper, or keep that
340340
hook as a bundled (deprecated) `handler`.
341-
- **Refused when it does not compile:** a `js` source is compiled, unrun, inside
342-
its wrapper, where `ctx` is already declared. So
343-
`const ctx = ctx.input || {};` (or `let ctx`, one name declared twice, any
344-
syntax error) is `hook-body-does-not-compile`: an **error** from `os validate`,
345-
`os build`, `os lint` and a runtime save (`422 INVALID_METADATA`), naming
346-
the hook, the `SyntaxError` and its line. Fix: use `ctx` as it is, or rename
347-
the local (`const data = ctx.input || {};`). A job's `js` body runs in the
348-
same wrapper: `job-body-does-not-compile`, from the three commands. A regex
349-
pattern the checking engine refuses is a warning: the runtime may accept it.
341+
- **Refused when it does not compile:** a `js` source compiles, unrun, in a
342+
wrapper that declares `ctx`, so `const ctx = ctx.input || {};` (or `let ctx`,
343+
one name declared twice, any syntax error) is `hook-body-does-not-compile`: an
344+
**error** from `os validate`, `os build`, `os lint` and a runtime save
345+
(`422 INVALID_METADATA`). Fix: use `ctx` or rename the local. A job's `js`
346+
body, same wrapper: `job-body-does-not-compile`, from the three commands. A
347+
regex pattern the runtime refuses too is that error; only a duplicate named
348+
group, a modifier group (`(?i:a)`) or a Unicode property name only the runtime
349+
knows (any refused one on a pre-17.0-Unicode host) warns.
350350

351351
> **A deadline stamped from an hours table is wall-clock hours** — nights, weekends and
352352
> holidays count. Name it `*_WALL_CLOCK_HOURS`, add `hours * 3_600_000` ms, never label it

0 commit comments

Comments
 (0)