Skip to content

Commit e5750d8

Browse files
committed
feat(spec): add the map settings specifier for keyed rows
SpecifierType gains map: a keyColumn header and typed value columns (duration or positive_integer). One column stores a scalar per key, several store an object per key. The keys a map admits come from a runtime option source, not the manifest. ADR-0007 amended; json stays for raw config. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017ihL2fBJ6xsLWJsnNJGMMx
1 parent b85190a commit e5750d8

6 files changed

Lines changed: 206 additions & 7 deletions

File tree

‎content/docs/references/system/settings-manifest.mdx‎

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ const result = ResolvedSettingValueSchema.parse(data);
123123
| **pattern** | `string` | optional | Regex pattern (text only) |
124124
| **rows** | `integer` | optional | |
125125
| **handler** | `{ kind: 'http'; method?: Enum<'GET' \| 'POST' \| 'PUT' \| 'DELETE' \| 'PATCH'>; url: string; body?: Record<string, any>; … } \| { kind: 'action'; name: string; params?: Record<string, any>; confirmText?: string \| Record<string, string> } \| { kind: 'navigate'; url: string; target?: Enum<'_self' \| '_blank'> }` | optional | Action handler (action_button) |
126+
| **keyColumn** | `{ label: string \| Record<string, string>; description?: string }` | optional | Key column (map) |
127+
| **columns** | `{ name: string; label: string \| Record<string, string>; description?: string; kind: Enum<'duration' \| 'positive_integer'> }[]` | optional | Value columns (map): one stores a scalar per key, several an object |
126128
| **confirmOffText** | `string \| Record<string, string>` | optional | Confirm dialog text shown before a toggle's value changes to off (omit = no confirm) |
127129
| **childNamespace** | `string` | optional | Sub-namespace (child_pane) |
128130
| **bannerText** | `string` | optional | Markdown body (info_banner) |
@@ -179,7 +181,7 @@ const result = ResolvedSettingValueSchema.parse(data);
179181

180182
| Property | Type | Required | Description |
181183
| :--- | :--- | :--- | :--- |
182-
| **type** | `Enum<'group' \| 'child_pane' \| 'info_banner' \| 'title_value' \| 'text' \| 'textarea' \| 'password' \| 'email' \| 'url' \| 'phone' \| 'number' \| 'toggle' \| 'select' \| 'radio' \| … +5 more>` | ✅ | Specifier variant |
184+
| **type** | `Enum<'group' \| 'child_pane' \| 'info_banner' \| 'title_value' \| 'text' \| 'textarea' \| 'password' \| 'email' \| 'url' \| 'phone' \| 'number' \| 'toggle' \| 'select' \| 'radio' \| … +6 more>` | ✅ | Specifier variant |
183185
| **id** | `string` | optional | Stable identifier (snake_case) |
184186
| **key** | `string` | optional | Storage key (snake_case) |
185187
| **label** | `string \| Record<string, string>` | ✅ | Display label |
@@ -206,6 +208,8 @@ const result = ResolvedSettingValueSchema.parse(data);
206208
| **pattern** | `string` | optional | Regex pattern (text only) |
207209
| **rows** | `integer` | optional | |
208210
| **handler** | `{ kind: 'http'; method?: Enum<'GET' \| 'POST' \| 'PUT' \| 'DELETE' \| 'PATCH'>; url: string; body?: Record<string, any>; … } \| { kind: 'action'; name: string; params?: Record<string, any>; confirmText?: string \| Record<string, string> } \| { kind: 'navigate'; url: string; target?: Enum<'_self' \| '_blank'> }` | optional | Action handler (action_button) |
211+
| **keyColumn** | `{ label: string \| Record<string, string>; description?: string }` | optional | Key column (map) |
212+
| **columns** | `{ name: string; label: string \| Record<string, string>; description?: string; kind: Enum<'duration' \| 'positive_integer'> }[]` | optional | Value columns (map): one stores a scalar per key, several an object |
209213
| **confirmOffText** | `string \| Record<string, string>` | optional | Confirm dialog text shown before a toggle's value changes to off (omit = no confirm) |
210214
| **childNamespace** | `string` | optional | Sub-namespace (child_pane) |
211215
| **bannerText** | `string` | optional | Markdown body (info_banner) |
@@ -231,6 +235,7 @@ const result = ResolvedSettingValueSchema.parse(data);
231235
* `slider`
232236
* `color`
233237
* `json`
238+
* `map`
234239
* `action_button`
235240

236241
### Nested Shape: `Specifier.options[number]`
@@ -269,6 +274,22 @@ const result = ResolvedSettingValueSchema.parse(data);
269274
| **url** | `string` | ✅ | Target URL or in-app route |
270275
| **target** | `Enum<'_self' \| '_blank'>` | optional (default: `"_self"`) | |
271276

277+
### Nested Shape: `Specifier.keyColumn`
278+
279+
| Property | Type | Required | Description |
280+
| :--- | :--- | :--- | :--- |
281+
| **label** | `string \| Record<string, string>` | ✅ | Key column header |
282+
| **description** | `string` | optional | Help text for the key column |
283+
284+
### Nested Shape: `Specifier.columns[number]`
285+
286+
| Property | Type | Required | Description |
287+
| :--- | :--- | :--- | :--- |
288+
| **name** | `string` | ✅ | Column identifier: the stored property name when the map has several value columns |
289+
| **label** | `string \| Record<string, string>` | ✅ | Column header |
290+
| **description** | `string` | optional | Help text for the column |
291+
| **kind** | `Enum<'duration' \| 'positive_integer'>` | ✅ | Value kind: duration literal or positive integer |
292+
272293

273294
---
274295

@@ -367,6 +388,7 @@ This schema accepts one of the following structures:
367388
* `slider`
368389
* `color`
369390
* `json`
391+
* `map`
370392
* `action_button`
371393

372394

‎docs/adr/0007-settings-manifest-and-kv-store.md‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ADR-0007: Settings — Manifest + K/V Store + Resolver (Apple-style)
22

3-
**Status**: Accepted — backend implemented; UI pending (objectui) (proposed 2026-05-20 · calibrated 2026-06-12) · **Amended (2026-11-05, #30385)** — D6: a clear (`null`) of an env-pinned key is not refused; it clears the stored value beneath the override and changes nothing in force.
3+
**Status**: Accepted — backend implemented; UI pending (objectui) (proposed 2026-05-20 · calibrated 2026-06-12) · **Amended (2026-11-05, #30385)** — D6: a clear (`null`) of an env-pinned key is not refused; it clears the stored value beneath the override and changes nothing in force. · **Amended (2026-11-08, #30208)** — §Specifier set gains `map` (keyed rows with typed value columns); `json` stays for raw config and is no longer the home for maps.
44
**Deciders**: ObjectStack Protocol Architects
55
**Builds on**: [ADR-0005](./0005-metadata-customization-overlay.md) (Metadata Customization Overlay), [ADR-0006 v4](./0006-project-environment-split.v4.md) (Project/Environment Split — this record was originally built on v3, superseded by v4)
66
**Consumers**: `@objectstack/spec`, `@objectstack/platform-objects`, new `@objectstack/service-settings`, `@objectstack/plugin-auth` (Setup app), `objectui` (Settings renderer)
@@ -106,6 +106,8 @@ ObjectStack's protocol-first DNA matches Apple's: a small set of declarative spe
106106

107107
A small, **closed** set of specifier types. Borrowed from Apple's PreferenceSpecifiers and trimmed to what enterprise settings actually need. New types require an ADR amendment.
108108

109+
*Amended 2026-11-08 (#30208, ruling record 6715997428): `map` added. A setting whose value is a map of rows (an object → a window, an object → a row count) declares that shape as a `map`, so the console draws a table and both doors (the save and the `OS_*` override) judge each key against the running system's domain and each cell against its column's kind, as they judge `options` and `pattern`. Its stored value is the object a `json` key held, unchanged. `json` stays in the set for genuinely raw config; it is no longer the home for maps.*
110+
109111
| Specifier | Renders as | Persists | Notes |
110112
|---|---|---|---|
111113
| `group` | section header + divider | — | `visible` expression supported for conditional sections |
@@ -120,7 +122,8 @@ A small, **closed** set of specifier types. Borrowed from Apple's PreferenceSpec
120122
| `multiselect` | checkbox list / tag picker | array | |
121123
| `slider` | range slider | number | `min`, `max`, `step` |
122124
| `color` | colour picker | hex string | |
123-
| `json` | code editor | object | for advanced/raw config |
125+
| `json` | code editor | object | for advanced/raw config — not for maps (see `map`) |
126+
| `map` | keyed rows: a key column + typed value columns | object: `Record<key, value>` with one value column, `Record<key, {column: value}>` with several | `keyColumn`, `columns: [{name, label, kind}]`, `kind` ∈ `duration` \| `positive_integer`; the keys a map admits are served by a runtime option source, never listed in the manifest |
124127
| `title-value` | read-only label | — | display computed/derived values |
125128
| `child-pane` | nav row → sub-page | — | references another manifest namespace |
126129
| `action-button` | button | — | triggers `handler` (HTTP / built-in) |

‎docs/audits/2026-07-unknown-key-strictness-ledger.counts/system.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ hand-patch a number here** — fix the code or the verdict and regenerate.
1919

2020
| Dir | Sites |
2121
|---|---|
22-
| `system/` | 397 |
22+
| `system/` | 399 |

‎packages/spec/authorable-surface/system.json‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,6 +1140,7 @@
11401140
"system/Specifier:bannerSeverity",
11411141
"system/Specifier:bannerText",
11421142
"system/Specifier:childNamespace",
1143+
"system/Specifier:columns",
11431144
"system/Specifier:confirmOffText",
11441145
"system/Specifier:default",
11451146
"system/Specifier:deprecated",
@@ -1149,6 +1150,7 @@
11491150
"system/Specifier:icon",
11501151
"system/Specifier:id",
11511152
"system/Specifier:key",
1153+
"system/Specifier:keyColumn",
11521154
"system/Specifier:label",
11531155
"system/Specifier:lockable",
11541156
"system/Specifier:max",

‎packages/spec/src/system/settings-manifest.test.ts‎

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ describe('SpecifierType', () => {
2020
'group', 'child_pane', 'info_banner', 'title_value',
2121
'text', 'textarea', 'password', 'email', 'url', 'phone',
2222
'number', 'toggle', 'select', 'radio', 'multiselect',
23-
'slider', 'color', 'json', 'action_button',
23+
'slider', 'color', 'json', 'map', 'action_button',
2424
];
2525
for (const k of kinds) {
2626
expect(() => SpecifierType.parse(k)).not.toThrow();
@@ -195,6 +195,71 @@ describe('SpecifierSchema — layout-only specifiers', () => {
195195
});
196196
});
197197

198+
describe('SpecifierSchema — `map`, keyed rows with typed value columns (#30208, ADR-0007 amended 2026-11-08)', () => {
199+
const quotas = {
200+
type: 'map',
201+
key: 'quotas',
202+
label: 'Row quotas',
203+
keyColumn: { label: 'Object' },
204+
columns: [{ name: 'rows', label: 'Max rows', kind: 'positive_integer' }],
205+
} as const;
206+
const overrides = {
207+
type: 'map',
208+
key: 'retention_overrides',
209+
label: 'Retention overrides',
210+
keyColumn: { label: 'Object' },
211+
columns: [
212+
{ name: 'maxAge', label: 'Keep for', kind: 'duration' },
213+
{ name: 'expireAfter', label: 'Expire after', kind: 'duration' },
214+
],
215+
} as const;
216+
217+
it('parses a one-column and a several-column map, keeping the columns as declared', () => {
218+
const one = SpecifierSchema.parse(quotas);
219+
expect(one.type).toBe('map');
220+
expect(one.keyColumn).toEqual({ label: 'Object' });
221+
expect(one.columns).toEqual([{ name: 'rows', label: 'Max rows', kind: 'positive_integer' }]);
222+
const several = SpecifierSchema.parse(overrides);
223+
// camelCase survives: the column name is the stored property.
224+
expect(several.columns!.map((c) => c.name)).toEqual(['maxAge', 'expireAfter']);
225+
});
226+
227+
it('is value-bearing: a map without a key is refused', () => {
228+
const { key: _key, ...keyless } = quotas;
229+
expect(() => SpecifierSchema.parse(keyless)).toThrow(/requires a 'key'/);
230+
});
231+
232+
it('refuses a map without columns, with an empty column list, or without a key column', () => {
233+
const { columns: _c, ...noColumns } = quotas;
234+
expect(() => SpecifierSchema.parse(noColumns)).toThrow(/requires at least one value column in 'columns'/);
235+
expect(() => SpecifierSchema.parse({ ...quotas, columns: [] })).toThrow(/requires at least one value column/);
236+
const { keyColumn: _k, ...noKeyColumn } = quotas;
237+
expect(() => SpecifierSchema.parse(noKeyColumn)).toThrow(/requires a 'keyColumn'/);
238+
});
239+
240+
it('refuses a column kind outside the closed set, and a duplicate column', () => {
241+
expect(() => SpecifierSchema.parse({
242+
...quotas, columns: [{ name: 'rows', label: 'Rows', kind: 'number' }],
243+
})).toThrow();
244+
expect(() => SpecifierSchema.parse({
245+
...overrides, columns: [overrides.columns[0], overrides.columns[0]],
246+
})).toThrow(/Duplicate map column 'maxAge'/);
247+
});
248+
249+
it('refuses `columns` and `keyColumn` on any other type', () => {
250+
expect(() => SpecifierSchema.parse({
251+
type: 'json', key: 'quotas', label: 'Row quotas', columns: quotas.columns,
252+
})).toThrow(/must not declare 'columns' \(only a 'map' may\)/);
253+
expect(() => SpecifierSchema.parse({
254+
type: 'text', key: 'x', label: 'X', keyColumn: { label: 'Object' },
255+
})).toThrow(/must not declare 'keyColumn'/);
256+
});
257+
258+
it('`json` stays in the set for raw config', () => {
259+
expect(SpecifierSchema.parse({ type: 'json', key: 'raw', label: 'Raw' }).type).toBe('json');
260+
});
261+
});
262+
198263
describe('SpecifierValueDomainSchema — the closed standard-domain vocabulary', () => {
199264
it('accepts exactly the three domains with measured authoring pull', () => {
200265
for (const d of ['iana_time_zone', 'iso_4217_currency', 'iso_3166_alpha2']) {

‎packages/spec/src/system/settings-manifest.zod.ts‎

Lines changed: 109 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { SnakeCaseIdentifierSchema } from '../shared/identifiers.zod';
66
import { EvaluatedExpressionInputSchema } from '../shared/expression.zod';
77
import { I18nLabelSchema } from '../ui/i18n.zod';
88
import { ValueDomainSchema } from '../shared/value-domain.zod';
9+
import { LIFECYCLE_DURATION_REGEX } from '../data/object.zod';
910

1011
/**
1112
* Settings Manifest Protocol
@@ -53,7 +54,8 @@ export const SpecifierType = z.enum([
5354
'multiselect',
5455
'slider',
5556
'color',
56-
'json',
57+
'json', // raw config only; a map of rows is a `map` (ADR-0007, amended 2026-11-08)
58+
'map', // keyed rows: a key column plus typed value columns
5759

5860
// Actions
5961
'action_button', // calls handler (test connection / rotate / etc.)
@@ -63,13 +65,56 @@ export type SpecifierType = z.input<typeof SpecifierType>;
6365
const SPECIFIERS_REQUIRING_KEY: ReadonlySet<SpecifierType> = new Set([
6466
'text', 'textarea', 'password', 'email', 'url', 'phone',
6567
'number', 'toggle', 'select', 'radio', 'multiselect',
66-
'slider', 'color', 'json',
68+
'slider', 'color', 'json', 'map',
6769
]);
6870

6971
// ---------------------------------------------------------------------------
7072
// Sub-schemas
7173
// ---------------------------------------------------------------------------
7274

75+
/**
76+
* The value kinds a `map` column may declare (#30208, ADR-0007 as amended
77+
* 2026-11-08). Closed, like the specifier set: a new kind is an ADR amendment.
78+
*
79+
* - `duration` — a duration literal `<n><unit>`, unit `h`, `d`, `w` or `y`
80+
* (`'6h'`, `'14d'`, `'12w'`, `'7y'`): the lifecycle window's own grammar,
81+
* {@link LIFECYCLE_DURATION_REGEX}, which the settings doors judge by too.
82+
* - `positive_integer` — a whole number greater than 0.
83+
*/
84+
const SpecifierMapColumnKindSchema = z.enum(['duration', 'positive_integer'])
85+
.describe(`Map column value kind: 'duration' (a literal matching ${LIFECYCLE_DURATION_REGEX.source}) or 'positive_integer'`);
86+
87+
/**
88+
* One value column of a `map` specifier.
89+
*
90+
* `name` is the property the column's value is stored under when the map has
91+
* several value columns (`retention_overrides` stores
92+
* `{ "<object>": { "maxAge": "1y", "expireAfter": "30d" } }`), so it keeps the
93+
* stored property's own spelling, camelCase included. With one value column the
94+
* name is not stored: the entry IS the value (`quotas` stores
95+
* `{ "<object>": 1000000 }`).
96+
*/
97+
const SpecifierMapColumnSchema = z.object({
98+
name: z.string()
99+
.regex(/^[A-Za-z][A-Za-z0-9_]*$/, 'A map column name is an identifier (letters, digits, `_`), stored as the property name')
100+
.describe('Column identifier: the stored property name when the map has several value columns'),
101+
label: I18nLabelSchema.describe('Column header'),
102+
description: z.string().optional().describe('Help text for the column'),
103+
kind: SpecifierMapColumnKindSchema.describe('Value kind: duration literal or positive integer'),
104+
});
105+
106+
/**
107+
* The key column of a `map` specifier: the header the renderer draws over the
108+
* keys. It declares no list of keys. The keys a map admits are served at run
109+
* time by the settings service's option source for that map key (objects that
110+
* declare a lifecycle, the lifecycle classes): a list written here would be
111+
* stale the day an object is added.
112+
*/
113+
const SpecifierMapKeyColumnSchema = z.object({
114+
label: I18nLabelSchema.describe('Key column header'),
115+
description: z.string().optional().describe('Help text for the key column'),
116+
});
117+
73118
export const SpecifierOptionSchema = lazySchema(() => z.object({
74119
value: z.union([z.string(), z.number(), z.boolean()]).describe('Stored value'),
75120
label: I18nLabelSchema.describe('Display label'),
@@ -544,6 +589,27 @@ export const SpecifierSchema = lazySchema(() => z.object({
544589
/** `action_button`: handler invoked on click. */
545590
handler: SpecifierHandlerSchema.optional().describe('Action handler (action_button)'),
546591

592+
/**
593+
* `map`: the key column (#30208). A `map` is a set of keyed rows: one key
594+
* column, then the value columns in {@link columns}. Stored shape:
595+
*
596+
* - **one value column** stores `Record<key, value>`: `{ "sys_audit_log": 1000000 }`;
597+
* - **several value columns** store `Record<key, { [column.name]: value }>`:
598+
* `{ "sys_job_run": { "maxAge": "1y", "expireAfter": "30d" } }`, each entry
599+
* carrying at least one declared column and no other property.
600+
*
601+
* The keys a map admits are not declared here. A runtime option source the
602+
* settings service registers for the map key serves them (they are what the
603+
* running system has: its objects, its lifecycle classes), both doors judge a
604+
* key against it, and every manifest read serves them as this specifier's
605+
* `options`. Without a source, a declared `options` table is the fallback,
606+
* as for a `select`; without either, any key is admitted.
607+
*/
608+
keyColumn: SpecifierMapKeyColumnSchema.optional().describe('Key column (map)'),
609+
610+
/** `map`: the value columns, in display order. See {@link keyColumn} for the stored shape. */
611+
columns: z.array(SpecifierMapColumnSchema).optional().describe('Value columns (map): one stores a scalar per key, several an object'),
612+
547613
/**
548614
* `toggle`: the confirm dialog text shown before the value changes to off
549615
* (omit = no confirm). The name mirrors a handler's `confirmText`; it is
@@ -611,6 +677,47 @@ export const SpecifierSchema = lazySchema(() => z.object({
611677
});
612678
}
613679
}
680+
// A `map` declares its key column and at least one value column; no other
681+
// type carries either, which would be a declaration nothing draws or judges
682+
// (Prime Directive #10).
683+
if (spec.type === 'map') {
684+
if (!spec.keyColumn) {
685+
ctx.addIssue({
686+
code: z.ZodIssueCode.custom,
687+
path: ['keyColumn'],
688+
message: `Specifier of type 'map' requires a 'keyColumn'.`,
689+
});
690+
}
691+
if (!spec.columns || spec.columns.length === 0) {
692+
ctx.addIssue({
693+
code: z.ZodIssueCode.custom,
694+
path: ['columns'],
695+
message: `Specifier of type 'map' requires at least one value column in 'columns'.`,
696+
});
697+
} else {
698+
const seen = new Set<string>();
699+
spec.columns.forEach((col, idx) => {
700+
if (seen.has(col.name)) {
701+
ctx.addIssue({
702+
code: z.ZodIssueCode.custom,
703+
path: ['columns', idx, 'name'],
704+
message: `Duplicate map column '${col.name}'.`,
705+
});
706+
}
707+
seen.add(col.name);
708+
});
709+
}
710+
} else {
711+
for (const slot of ['keyColumn', 'columns'] as const) {
712+
if (spec[slot] !== undefined) {
713+
ctx.addIssue({
714+
code: z.ZodIssueCode.custom,
715+
path: [slot],
716+
message: `Specifier of type '${spec.type}' must not declare '${slot}' (only a 'map' may).`,
717+
});
718+
}
719+
}
720+
}
614721
// action_button requires a handler.
615722
if (spec.type === 'action_button' && !spec.handler) {
616723
ctx.addIssue({

0 commit comments

Comments
 (0)