You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(autonumber): document tokens in data skill; lint unrecognized format tokens (#2046)
Follow-up to #2043 — close the AI-authoring gap on top of the runtime guards:
- skills/objectstack-data field-types rules: the autonumber section only showed
`CASE-{0000}`. Expanded with the date / {field} / per-scope tokens and the
authoring rules that prevent silent mis-numbering — interpolated fields must be
required, put a delimiter between adjacent variable tokens, pad width is a
minimum, date tokens are exact/case-sensitive — plus an incorrect/correct example.
- compile lint: warn when an autonumber `{...}` token is not a counter/date/{field}
token. Unrecognized groups (wrong case, spaces, a second {0..0} slot) render
LITERALLY into the record number; the field-reference checks miss the
non-identifier cases. New advisory rule `autonumber-unrecognized-token`.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: skills/objectstack-data/rules/field-types.md
+36-1Lines changed: 36 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -85,7 +85,7 @@ All use `fileAttachmentConfig` for size limits, allowed types, virus scanning, a
85
85
|:-----|:------------|:-------|
86
86
|`formula`| Computed from an expression referencing other fields |`expression`, `resultType`|
87
87
|`summary`| Roll-up aggregation from child records |`summaryType` (count/sum/min/max/avg), `summaryField`, `reference`|
88
-
|`autonumber`| Auto-incrementing display format |`format` (e.g., `"CASE-{0000}"`) |
88
+
|`autonumber`| Auto-incrementing display format ({0000} counter + optional date / {field} tokens, resets per scope) |`format` (e.g., `"CASE-{0000}"`, `"AD{YYYYMMDD}{0000}"`) |
89
89
90
90
## Enhanced Types
91
91
@@ -282,6 +282,23 @@ What kind of data?
282
282
}
283
283
```
284
284
285
+
The `format` is literal text interleaved with `{...}` tokens:
286
+
287
+
| Token | Renders | Example |
288
+
|:------|:--------|:--------|
289
+
|`{0000}`| The counter, zero-padded to that many digits (**minimum** width). At most ONE slot. |`CASE-{0000}` → `CASE-0042`|
290
+
|`{YYYY}``{YY}``{MM}``{DD}``{YYYYMMDD}`| Generation date in the request's business timezone |`AD{YYYYMMDD}{0000}` → `AD202606170001`|
291
+
|`{field_name}`| The value of another field **on the same record**|`{plan_no}{000}` → `PLAN-001001`|
292
+
293
+
**The counter resets per "scope"** — everything rendered *before* the `{0000}` slot. So `AD{YYYYMMDD}{0000}` restarts each day, `{section}{island_zone}{000}` counts per group, `{plan_no}{000}` counts per parent — no separate reset config. A fixed-prefix format (`CASE-{0000}`) has an empty scope → one global counter.
294
+
295
+
**Rules — get these wrong and records mis-number silently or fail to save:**
296
+
297
+
1.**Every `{field}` you interpolate must be `required: true`** and set before the record is created. An empty interpolated field makes the record number generation *throw* (the compile lint flags a non-existent field as an error, an optional one as a warning).
298
+
2.**Put a delimiter between adjacent variable tokens** — `{section}-{zone}{000}`, not `{section}{zone}{000}`. Without one, `('AB','C')` and `('A','BC')` both render prefix `ABC` and share a counter (to keep numbers unique). The literal separator keeps distinct groups apart.
299
+
3.**Pad width is a MINIMUM, not a cap.**`{000}` → `001`…`999`, then `1000` (it grows, never wraps). Size it for readability, not as a ceiling.
300
+
4.**Only known tokens are interpolated.** Date tokens are **case-sensitive and exact** (`{YYYY}`, not `{yyyy}` or `{YYYY-MM}`). An unrecognized `{...}` is emitted **literally** into the number — `{ YYYY }` (spaces) renders the text `{ YYYY }`.
0 commit comments