Repository navigation
Commit 898655a
fix(service-analytics)!: the dataset query door refuses measures and dimensions the dataset does not declare (#34198)
<!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} -->
_Requested by **Steedos** · [project
thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9UbbKnsd8ZLsq9hBbRRm5JvJb2)_
Fixes #34005
Clause-②: no (narrowing)
Metadata-protocol: none
Skills-docs: follow-up #34328 — `skills/**` teach dataset selections by
the dataset's declared measures and dimensions (objectstack-ui: a report
selects `rows` and `values` "from that dataset"), which the door now
enforces; they do not yet say that a compare widget's date key must be
the name of a declared date dimension, and that teaching is carried by
#34328; `content/docs/data-modeling/analytics.mdx` and
`content/docs/ui/dashboards.mdx` state the rule in this change.
> [!WARNING]
> **BREAKING** for a caller of `POST /api/v1/analytics/dataset/query`
(and each entry of `/analytics/dataset/query/batch`), or of
`AnalyticsService.queryDataset` in process, that names a measure or
dimension the dataset does not declare. That selection used to be
answered with a member minted on the fly; it is now refused `400
INVALID_FIELD`, the same refusal the AI tool `query_dataset` gives.
ADR-0087 disposition (in the changeset, one marker): `not-required
(no-migration-prescription)`, because a runtime request refusal changes
the shape of no metadata key, value or stored row. Authored dashboards,
reports and charts are save-gated to declared members in their measures
and dimensions, but one class is not: a dashboard compare widget whose
date-range field is not also the name of a declared dimension passes
every save and publish check and is refused after this change. When the
date-range field is a field of the dataset's own object, the refusal
names the remedy: declare a date dimension named after the date-range
field (seat re-ruling 6909938292 on #34005 (question 4, M1 option a)).
When it is a related record's dotted field (`account.signed_at`), which
the dataset query used to answer through the dataset's `include`, this
is a break with no in-dataset remedy: no dimension name can carry a dot,
so the refusal names no declaration for that key and says the comparison
needs a date field of the dataset's own object that a declared date
dimension names (seat ruling 6911721875 on #34005 (L2 M1, dotted date
key, option A)). The renderer mapping a dotted date key onto a declared
dimension over that path is carried by #34350. The missing save gate is
#34308; the skills teaching for the compare widget's date key is #34328.
## 维护者速读
- 改了什么:数据集查询入口(REST 单查与批量、服务内 `queryDataset`)现在只接受数据集自己声明的度量和维度,与 AI 工具
`query_dataset` 共用同一条判定。
- 为什么改:以前入口会临时造指标(`count`、把原始字段当 `sum`、`_sum` 后缀、`数据集名.`
前缀、原始字段当维度),看板上可能出现一个数据集从没定义过的「指标」,并且两个入口对同一个名字给出不同答案。
- 风险与回滚:直接调 API 并且用未声明成员的调用方会收到
400。另有一类没有保存校验兜住:看板的对比(compareTo)组件,如果看板日期范围字段不是数据集里某个已声明维度的名字,现在会被拒绝:日期范围字段是数据集本对象字段时,报错文案给出修法(声明一个与之同名的日期维度);是关联记录的点号字段(如
`account.signed_at`)时,没有数据集内的修法,文案只说明对比需要本对象的日期字段,渲染端映射由 #34350
承接;补保存校验的卡是 #34308,技能文档补教的卡是 #34328。按名字普查了官方示例和 hotcrm 的看板与报表,命中为
0。回滚方式是 revert 本 PR(改动只在 service-analytics、测试和文档里)。
- 先看:`packages/services/service-analytics/src/analytics-service.ts` 里的
`assertSelectionMembersDeclared`(拒绝点和 403
先于成员清单的顺序),`src/dataset-declared-members.ts`(共用判定),`src/dataset-tools.ts`(AI
入口改为复用)。
- 两分钟验证:`pnpm --filter @objectstack/service-analytics exec vitest run
--maxWorkers=2
src/__tests__/dataset-query-declared-members.test.ts`,预期全绿;拒绝用例断言
`INVALID_FIELD`/400、`member`/`param`/`cube`,以及「可用成员」清单。
- 需要你做的:无,席位落地。
## What changes
- **One rule, two faces.** The new file
`src/dataset-declared-members.ts` holds `undeclaredSelectionMembers`. It
judges `selection.measures`, `selection.dimensions` and each
`timeDimensions[].dimension` against the dataset's own `measures[].name`
/ `dimensions[].name`, spelled exactly. The AI tool's
`assertDeclaredMembers` (`dataset-tools.ts`, from PR #33958) now calls
it, so the judgment is lifted, not forked. Each face words its own next
step: the AI face falls back to the object query tools, and the door
tells an author to declare the member.
- **The door.** `AnalyticsService.answerDataset` calls
`assertSelectionMembersDeclared` right after compiling the dataset,
before anything is read. Order of answers:
- A missing dataset is still `404 NOT_FOUND`, first.
- A caller who may not read the dataset's object still gets the read
refusal (`403`), never a member list.
- Otherwise the answer is `400 INVALID_FIELD`. Over REST the body is `{
code, message }`; in process the thrown error also carries `member`,
`param` and `cube` from the first undeclared entry. The message names
every undeclared member, the measures and dimensions THIS caller may use
(never a withheld member, and never one over an `internal` field, per
ADR-0100), and the remedy.
- **Unchanged.** A declared member over a field the caller may not read
still reaches the field gate (`403 PERMISSION_DENIED`). `runtimeFilter`
keys are fields and are judged as before. The cube door `POST
/analytics/query` is not a dataset and keeps its ad-hoc members.
- **Source-field remedy on the dataset door (5a127a4).** A dataset
reaches the measure and dimension source-field gates only through a
DECLARED member whose field the object does not have; an undeclared one
is refused first. Those gates ended with the cube door's hint (measures
are inferred from the object's own fields as `FIELD_sum`…, and any own
field may be used as a dimension without declaring it), which is false
on the dataset door. A dataset call's scope now carries `datasetDoor`,
which `ensureCube` and the draft preview pass to both gates. On the
dataset door the refusal says "The dataset declares this
measure/dimension over 'FIELD': point its `field` at one of the object's
fields, or remove the measure/dimension". The cube door's message is
byte-identical. The changeset notes it (e2a0a9c).
- **Inline datasets.** An inline `dataset` body is judged against its
own `measures` and `dimensions`.
- **Docs.** `content/docs/data-modeling/analytics.mdx` states the rule
beside the body-key paragraph. `content/docs/ui/dashboards.mdx` no
longer says the analytics query API accepts an object's own field as an
ad-hoc dimension: the dataset query answers declared members only, and
only the cube query (`POST /analytics/query`) still groups by an
undeclared field. A new section, "The Date Key of a Compare Widget",
says a compare widget's date key is the date-range field's name and must
be the name of a declared date dimension, with the remedy, and (fix
round 4) that a related record's dotted date field has no in-dataset
remedy. The spec TSDoc on the dashboard global filter's `field`
(`packages/spec/src/ui/dashboard.zod.ts`) says the same old thing and is
outside this PR's surface: card #34307.
- **Compare-window remedy (seat re-ruling 6909938292 on #34005 (question
4, M1 option a)).** The refusal stays. When the refused member is a
comparison window's date key (a `timeDimensions` entry carrying a
`dateRange` in a selection with `compareTo`, which is how a dashboard
compare widget sends its date-range field), the message adds: the
dimension is the date key of the comparison window; declare a date
dimension named after it on the dataset (over that field). That is the
only remedy it names, and only for a key that can be a dimension name
(fix round 4: a key the dimension-name schema refuses, such as a dotted
`relationship.field`, gets the own-object requirement instead). With two
or more such keys it names them together, in the plural.
`compareWindowRemedy` in `dataset-declared-members.ts`; the AI tool's
wording is unchanged. The generic select-or-declare sentence ("Use one
of these, or declare the member on the dataset … and query it by that
name") covers only members it can fix (fix round 4 completion): it is
left out when every undeclared member is such an unnameable key, and it
names the members it is for when only some are.
- **Draft-preview comments.** The #28172 / #28201 comments at the
draft-preview gates in `analytics-service.ts` now note that selection
members never reach that branch (refused earlier by
`assertSelectionMembersDeclared`).
- **Changeset.** `.changeset/34005-dataset-door-declared-members.md` is
a `patch` (Metadata-protocol `none`) with the BREAKING paragraph and the
ADR-0087 disposition. Both now name the compare-widget class and its
remedy, and the BREAKING paragraph says the refusal names that remedy in
its message.
## Tests
- **New: `src/__tests__/dataset-query-declared-members.test.ts`** (real
`AnalyticsServicePlugin`, security double).
- Seven refusal cases: `count`, a raw field, a suffix spelling, a
`DATASET.`-qualified spelling, an undeclared measure beside a declared
one, a raw dimension, and a raw time dimension. Each asserts `code`,
`status`, `member`, `param`, `cube`, the declared-member list and the
remedy, and checks that nothing was read.
- The refusal names only caller-usable members.
- An inline dataset is judged against its own declaration.
- Controls: an unreadable object answers 403 with no member list; a
declared but forbidden member answers 403; declared members are served;
the cube door still mints `count`.
- **New:
`packages/qa/dogfood/test/analytics-dataset-declared-members.dogfood.test.ts`**
(stock showcase, real HTTP stack).
- Six refusal cases on `showcase_task_metrics`.
- The batch door refuses one entry and serves its declared sibling.
- Controls: declared members are served, and a missing dataset is still
404.
- **Triaged pins.** These pinned the minting this PR removes. Each was
re-judged, not batch-respelled:
- `preview-undeclared-measure-parity` and
`preview-undeclared-dimension-parity`: every spelling now gets the
closed-member refusal; the declared controls are kept.
- `query-dataset-request-scope`, `dataset-drill-scopes`,
`dimension-source-field-gate` and `dotted-path-preview-parity`: the
undeclared spellings are now refusals; the `runtimeFilter` and
declared-member pins are kept.
- `dotted-dimension-unbacked-join-parity`: the case list was extended.
The backed-join CONTROLs that passed only because a raw path was minted
were removed.
- `preview-filter-field-json-dimension-parity`: now selects the declared
`payload_dim`.
- `preview-time-filter-fk-parity`: the fixture now declares `closed_on`,
`account_id`, `account_name` and `account_ref`, and the FK pins select
those names. A declared lookup dimension resolves display labels, so the
expected rows are `'Acme'`/`'Globex'`. The raw spellings are a new
refusal row.
- **Rest pins moved (d9106e8).** Four `@objectstack/rest` pins
selected members their dataset never declared, so they now meet the
closed-member refusal before the gate they pin:
- `analytics-dataset-dimension-gate`: the source-field gate (`groups by
field 'bogus_dim'`, and `buckets field` for the time dimension) is
reached through a stale declared dimension. The raw-field leg (`phone`,
`bogus_dim`) is its own closed-member pin. The positive control stays
200 and groups a declared `phone_dim`.
- `analytics-dataset-refusal-envelope`: the include positive control
stays 200 and reads `account.region` through a declared
`account_region`.
- `analytics-dataset-unlisted-refusal-envelope`: `profit_sum` is refused
as undeclared. A stale declared `profit_total` keeps the `aggregates
field 'profit'` assertion.
- `analytics-relationship-path-admission`: the declared-join reference
stays 403. The undeclared path member is refused 400 before any read;
the dataset's own objects are readable, so the read 403 does not apply.
- **Test-source alias (8e358c3).** `analytics-dataset-dimension-gate`
and `analytics-dataset-refusal-envelope` now import
`@objectstack/objectql` at module top, so its first load is paid at
collection rather than inside a clocked window. `pnpm
check:test-source-alias`: exit 0.
- **Docs (b25fa01).** The `content/docs/api/data-api.mdx` "How to
spell a measure" callout now says that the inferred spellings belong to
the cube query only, and that the dataset query refuses any undeclared
name `400 INVALID_FIELD`.
- **Remedy pins (5a127a4).** `dataset-query-declared-members.test.ts`
pins both directions: a stale declared measure and a stale declared
dimension on the dataset door name the declared field and the fix and
carry no inferred-member hint, while the cube door (`query()`) keeps
both hints. `preview-undeclared-measure-parity` pins the same
dataset-door message on the native, ObjectQL and draft-preview faces.
The rest stale-declaration pins (`analytics-dataset-dimension-gate`,
`analytics-dataset-unlisted-refusal-envelope`) assert the dataset-door
remedy and the absence of the hint end to end.
- **Fix round 2 (review 6908009392).**
- Compare-window remedy: `dataset-query-declared-members.test.ts` pins
the message for an undeclared `closed_on` window with `compareTo`
(`member`/`param`/`cube`, the date-key sentence and the remedy; fix
round 3 below narrows the remedy pin), plus a control that the same
undeclared time dimension without `compareTo` gets no compare-widget
sentence.
- Refusal order against the read gate, in process: beside the existing
denial pin, a caller the read gate cannot decide for (its lookup throws)
gets `503 SERVICE_UNAVAILABLE` with no member list and nothing read.
- Through the REST door
(`packages/rest/src/analytics-read-gate-fault-envelope.test.ts`, the
real service): an undeclared selection answers `403 PERMISSION_DENIED`
for a denied caller and `503 SERVICE_UNAVAILABLE` for an undecidable
one, both with no member list and nothing executed; the admitted control
answers `400 INVALID_FIELD` with "Measures you may use: revenue.". The
file now imports `@objectstack/objectql` at module top (`pnpm
check:test-source-alias`).
- `dotted-dimension-unbacked-join-parity`: the served control is back as
a DECLARED dimension over the backed path (`account_name` reads
`account.name`): both live strategies return Acme 130 / Globex 50, and
the draft preview keeps its own refusal.
- **Verification on 43b494b (fix round 2).**
- Local tests and the closure build are NOT MEASURED, reason: the shared
verify lock was never acquired in seven attempts (each `VERDICT
queue-timeout (exit 99)`, about 65 minutes in all, behind sibling runs).
The PR's own CI on this head carries them: `Test Core` (8/8 shards)
success, with `dataset-query-declared-members.test.ts` (19 tests),
`dotted-dimension-unbacked-join-parity.test.ts` (29 tests) and
`analytics-read-gate-fault-envelope.test.ts` (10 tests) each passing in
the shard logs; `TypeScript Type Check` success; `Lint & Repo Gates`
success; `Build Core` success; `Dogfood Regression Gate` success; `Check
Changeset` success.
- `pnpm check:test-source-alias`: exit 0.
- Derived gates (`dispatch-gates --repo objectstack-ai/objectstack
--ran`, exit codes recorded): 101 derived, 91 exit 0, 10 NOT MEASURED
because no `dist/` was built locally (9 exit 3, PREREQUISITE NOT MET;
`check:docs` exit 1, refusing the missing spec build tree). `Lint & Repo
Gates` and `TypeScript Type Check` carry those families on this head.
- No ablation of the compare-window sentence was run (it needs the
lock); the control beside it pins that the sentence is absent without
`compareTo`.
- **Ablation of the flag.** One mutation through
`scripts/ablation-replace.mjs`: `datasetDoor: compiled !== undefined` →
`datasetDoor: false` (blob 74714b8 → 684ea485151b). Baseline 27/27;
mutated 3 failed, 24 passed (the two dataset-door pins and the
preview-face pin; the cube-door control stays green); restored blob ==
HEAD, `git diff HEAD` empty. A first attempt ran before the workspace
build and failed at collection (`Cannot find package
'@objectstack/spec/ui'`, no tests run): a no-op, discarded and re-run
after the build.
- **Verification on e2a0a9c** (one lock hold, VERDICT command-exit
0):
- `pnpm --filter '@objectstack/rest^...' build`: exit 0.
- `pnpm --filter @objectstack/service-analytics test`: exit 0, Test
Files 216 passed (216), Tests 5251 passed, 335 skipped (5586).
`typecheck`: exit 0.
- `pnpm --filter @objectstack/rest test`: exit 0, Test Files 413 passed
(413), Tests 8463 passed, 332 skipped (8795). `typecheck` (with
`check:test-typecheck`): exit 0.
- `pnpm check:test-source-alias`: exit 0.
- Derived gates (`dispatch-gates --ran`, exit codes recorded): 101
derived, 99 run with exit 0, 2 NOT-MEASURED (exit 3, prerequisite
`dist/` absent locally: `check:skill-examples`,
`check:dual-build-cjs-loads`). `check-nul-bytes`: exit 0.
## Fix round 3 (review 6909901648)
Ruling: seat re-ruling 6909938292 on #34005 (question 4, M1 option a).
Head `75e3e0618c`, after merging `origin/main` at `7917a19e54` (16
commits behind; the merge touches no file of this PR).
- **M1.** The refusal, the dashboards page ("The Date Key of a Compare
Widget"), the changeset's BREAKING bullet and the ADR-0087 marker now
name one remedy: declare a date dimension named after the date-range
field. The class they describe no longer carries a `compareTo`
qualification. `compareWindowRemedy` (`dataset-declared-members.ts`);
the `compareTo` table row on the page did not repeat the remedy and is
unchanged.
- **M1 pin.** New case in `dataset-query-declared-members.test.ts`:
`compareTo` names the declared `close_month`, and a second dated
`timeDimensions` entry names the undeclared `closed_on`. It asserts
`INVALID_FIELD`/400 with `member: 'closed_on'`, the date-key sentence,
the one remedy, that the message does not contain `compareTo.dimension`,
and that nothing was read. The existing compare-window pin now asserts
the same absence.
- **N2.** The plural arm reads "The dimensions "closed_on" and
"created_at" are the date keys …" and "Declare a date dimension for each
on the dataset, named "closed_on" and "created_at", each over the field
of the same name." New pin for it. The singular sentence is unchanged
apart from the dropped remedy.
- **S2.** `Skills-docs:` in this body and in the changeset now cites
follow-up #34328: the skills teach declared measures and dimensions, and
the compare widget's date key is carried by #34328.
- **N1.** Card #34308 was corrected by comment; cited as before.
<details><summary>Verification on 75e3e06</summary>
- One lock hold, VERDICT command-exit 0: `pnpm --filter
'@objectstack/rest^...' build` exit 0;
`dataset-query-declared-members.test.ts` exit 0, Tests 21 passed (21);
`pnpm --filter @objectstack/service-analytics test` exit 0, Test Files
216 passed (216), Tests 5259 passed, 335 skipped (5594); `typecheck`
exit 0.
- Ablation (one leg, `scripts/ablation-replace.mjs`): the old two-remedy
sentence put back in the singular arm (anchor 1 → 0, injected text 0 →
1, blob e0e203e → 1356fedb9a4a).
`dataset-query-declared-members.test.ts`: 2 failed, 19 passed. Red: the
existing compare-window pin and the new `compareTo.dimension` pin. The
plural pin stays green, as expected, because the mutation is in the
singular arm. Restored with `git checkout HEAD --`: blob == HEAD
(e0e203e), `git diff HEAD` empty.
- `pnpm check:test-source-alias`: exit 0.
- Derived gates (`dispatch-gates --repo objectstack-ai/objectstack
--ran`, exit codes recorded): 101 derived, 98 exit 0, 3 NOT MEASURED
(exit 3, PREREQUISITE NOT MET: `check:skill-examples` and
`check:dual-build-cjs-loads` read `dist/` not built here;
`check:type-check-debt` never acquired the shared lock behind a dogfood
run). CI carries them.
- `@objectstack/rest` tests were not re-run locally: this round changes
no rest file, and no rest pin asserts the compare-window sentence. CI's
`Test Core` carries them.
</details>
## Fix round 4 (review 6911685604)
Ruling: seat ruling 6911721875 on #34005 (L2 M1, dotted date key, option
A). The refusal stays; no executor behaviour change. Head `d782833df3`;
4 commits behind `origin/main`, not merged.
- **M1, message.** `compareWindowRemedy` (`dataset-declared-members.ts`)
decides per key whether it can be a dimension name with the dataset
schema's own `SnakeCaseIdentifierSchema` (no hand-rolled pattern). A key
that cannot (a dotted `relationship.field`, or any key the grammar
refuses) gets no "declare a date dimension named" sentence; the message
says it cannot be a dimension name, so no date dimension can be declared
under it, and that the comparison cannot run on a dataset query unless
the dashboard's date field is a field of the dataset's own object that a
declared date dimension names. A nameable key keeps the existing remedy,
byte-identical. Mixed keys get one sentence per kind, the declare-it one
scoped "For the key(s) that can be a dimension name(s)".
- **M1, prose.** The dashboards page ("The Date Key of a Compare Widget"
and the `compareTo` table row), the changeset's BREAKING bullet and the
ADR-0087 marker state the dotted class as a break with no in-dataset
remedy. The changeset cites #34350 for the renderer mapping; the docs
page cites no card.
- **M1, pins.** `dotted-path-preview-parity.test.ts` replaces the
removed served control: a compare window over the backed
`account.founded_at` is refused `INVALID_FIELD`/400 alike on every face,
the message names no "declare a date dimension named" remedy, and it
names the own-object requirement.
`dataset-query-declared-members.test.ts` pins one mixed plural case
through the service, plus a grammar table over every combination the
function produces (1 or 2 nameable, 1 or 2 unnameable, a non-dotted
grammar failure, two mixes).
- **Completed in "Fix round 4 (completion)" below:** the ablation, the
full `service-analytics` suite, `typecheck`, the derived gates, and the
dotted-only message.
<details><summary>Verification on d782833</summary>
- One lock hold: `pnpm --filter '@objectstack/service-analytics^...'
build`, VERDICT command-exit 0.
- `vitest run` of `dataset-query-declared-members.test.ts` and
`dotted-path-preview-parity.test.ts` on `ab7c7ca809` (the code commit;
`d782833df3` adds docs and changeset only): VERDICT command-exit 0, Test
Files 2 passed (2), Tests 47 passed (47).
- Gates run locally, exit 0: `check-adr-0087-registration --base
origin/main` and its `--self-test`, `check:test-source-alias`,
`check:doc-authoring`, `check:doc-anchors`, `check-adr-links`,
`check-changeset-no-major`, `check-empty-changeset`,
`check-issue-citations` and `check:issue-citations`, `check:nul-bytes`,
`check:cross-package-test-inputs`, `check:undeclared-dep-imports`,
`check-closing-keyword-parity`, `check-docs-section-name`,
`check-comment-mask-adoption`.
- The rest was measured on the final head; see "Fix round 4
(completion)".
</details>
## Fix round 4 (completion)
Takeover of the handed-off round (hand-off 6912068262) by
`repo:objectstack#1`, under seat ruling 6911721875 on #34005 (dotted
compare-window date key, option A). Code commit `7a6aa7d0ed`; final head
`29a15c032b`, a merge of `origin/main` at `d01f399e3b` taken because
sibling PR #34335 landed with its own edit of
`content/docs/ui/dashboards.mdx` (its native-SQL paragraph under
"Filtering on a Related Record's Field"). The merge applied without
conflicts and keeps both edits; the PR's own diff is still the same 23
files. CI on the handed-off head `d782833df3` was green: 53 checks, 36
success, 17 skipped, none failed or pending.
- **The open point, measured.** On `d782833df3`, a compare window whose
only undeclared member is a dotted key read: "… Dimensions you may use:
region. Use one of these, or declare the member on the dataset (its
`measures` or `dimensions`) and query it by that name. The dimension
"account.founded_at" is the date key … "account.founded_at" cannot be a
dimension name …, so no date dimension can be declared under it: …". The
first sentence tells the author to declare the one member, the dotted
key, under its name; the ruling says the refusal does not tell the
author that. With an undeclared measure beside the dotted key, "declare
the member" covered both members alike.
- **Fix.** `undeclaredMembersRefusal` (`dataset-declared-members.ts`)
builds the select-or-declare sentence only for members it can fix: a
compare-window date key that the dimension-name grammar refuses is never
one. When every undeclared member is such a key, the sentence is left
out and the compare-window sentence is the whole remedy. When some are,
it reads "For the measure "amount_sum", use one of these, or declare the
member on the dataset …". When none are, it is byte-identical to before.
Unchanged: which members are refused, `INVALID_FIELD`/400,
`member`/`param`/`cube`, and `compareWindowRemedy` (the nameable-key
text included). The changeset's general bullet and the dashboards page
say the dotted key gets no declaration.
- **Pins.** `dataset-query-declared-members.test.ts`: a dotted key as
the only undeclared member (the message goes straight from "Dimensions
you may use: …" to the date-key sentence, names no declaration, and
carries the ruling's sentence in full), a dotted key beside an
undeclared measure (the sentence names the measure only), and the
existing nameable-plus-dotted case now asserts its scoped sentence.
`dotted-path-preview-parity.test.ts`: the dotted compare-window pin
asserts the absence of the generic sentence on every face.
<details><summary>Verification on 7a6aa7d (the code commit) and
29a15c0 (the merged final head)</summary>
- Closure build `pnpm --filter '@objectstack/service-analytics^...'
build`: VERDICT command-exit 0.
- The two touched files: VERDICT command-exit 0, Test Files 2 passed
(2), Tests 49 passed (49).
- `pnpm --filter @objectstack/service-analytics test`: exit 0, Test
Files 216 passed (216), Tests 5271 passed, 335 skipped (5606).
`typecheck` (`tsc --noEmit`): exit 0. One lock hold.
- Ablation A (owed by the hand-off), through
`scripts/ablation-replace.mjs`: `canBeDimensionName` returns `true`, so
a dotted key gets the old "declare a date dimension named …" remedy
(anchor 1 → 0, blob 17f2d8f → 9a8f74f32e22). The two files: 9
failed, 40 passed. Red: the dotted pin on every face, the dotted-only,
dotted-plus-measure and nameable-plus-dotted service pins, and the five
grammar-table rows with an unnameable key. Restored: blob == HEAD
(17f2d8f), `git diff HEAD` empty.
- Ablation B (this round's change): `const fixable = undeclared;` (blob
17f2d8f → f712c77fe6e6). 4 failed, 45 passed: the dotted pin on
every face and the three service pins on the select-or-declare sentence.
The grammar table stays green, as expected. Restored: blob == HEAD, `git
diff HEAD` empty.
- On `29a15c032b`, one lock hold (VERDICT command-exit 0): the closure
build plus service-analytics exit 0; `pnpm --filter
@objectstack/service-analytics test` exit 0, Test Files 217 passed
(217), Tests 5295 passed, 335 skipped (5630); `typecheck` exit 0.
- Derived gates on `29a15c032b` (`dispatch-gates --repo
objectstack-ai/objectstack --ran`, exit codes recorded): 101 derived,
101 run, all exit 0 on the first run, 0 NOT-MEASURED
(`check:type-check-debt`: 0 raw tsc errors).
- Derived gates on `7a6aa7d0ed`: 101 derived, 101 run, 0 NOT-MEASURED.
Four families first exited 3 (PREREQUISITE NOT MET) and were re-run once
the prerequisite held: `check-plugin-teardown-shape --self-test` after
`git fetch --unshallow`; `check:type-check-debt` (0 raw tsc errors,
every ledger entry at its number), `check:skill-examples` (347 examples)
and `check:dual-build-cjs-loads` after the workspace build, under one
lock hold. All exit 0.
- `check-governed-merges.mjs --pr 34198`: NOT governed, 0 of 23 paths on
the register, 1867 changed lines.
- Dogfood battery (title carries `!`, (narrowing) arm), `pnpm --filter
@objectstack/dogfood test` under the lock, no shard, no path: on
`7a6aa7d0ed`, VERDICT command-exit 0, Test Files 474 passed, 3 skipped
(477), Tests 4012 passed, 42 skipped (4054). On the final head
`29a15c032b` (after its own `@objectstack/dogfood^...` closure build,
exit 0): VERDICT command-exit 0, Test Files 475 passed, 3 skipped (478),
Tests 4018 passed, 42 skipped (4060).
- CI on `7a6aa7d0ed`: 53 checks, 38 success, 15 skipped, none failed or
pending. CI on the final head `29a15c032b`: 53 checks, 38 success, 15
skipped, none failed or pending.
</details>
## Acceptance notes
- **Census (H2): 0 hits.** The census resolved every dashboard widget,
report and chart selection against its dataset, with a positive control
of 6 seeded hits:
| Stack | Datasets | Selection sites | Hits |
|---|---|---|---|
| app-crm | 1 | 6 | 0 |
| showcase UI modules | 4 | 49 | 0 |
| platform-objects system dashboards | 5 | 9 | 0 |
| hotcrm at e7490b6 | 11 | 83 | 0 |
No declarations were needed. The save-time and build lint rules
(`widget-measure-unknown`, `widget-dimension-unknown`,
`chart-measure-unknown`, the report rows/columns/values checks) keep the
measures and dimensions of stored items on declared members.
`report-date-range-dimension-unknown` judges a report's
`dateRange.dimension` only; it does not cover dashboards.
- **Compare windows.** A dashboard compare widget lowers its date
window, the dashboard date-range filter included, into `timeDimensions`
under the filtered field's name. A dashboard's `dateRange.field`
resolves against the object, not the dataset, and no save or publish
rule reads a widget's `compareTo`, so stored dashboards are NOT
save-gated for this class: a compare widget whose date-range field is
not also the name of a declared dimension is now refused. The census
found none (each shipped compare widget's date field is also a declared
dimension of the same name); a dashboard saved at runtime or by a third
party has no such guarantee. The refusal names one remedy, declaring a
date dimension named after the date-range field (seat re-ruling
6909938292 on #34005 (question 4, M1 option a)). For a related record's
dotted date field it names no declaration and says the comparison needs
a date field of the dataset's own object (seat ruling 6911721875). The
missing save gate is card #34308. The skills' compare-widget section
does not yet teach the date key: card #34328.
- **Dead code.** The preview path's member-minting branch in
`answerDataset` is no longer reachable for selection members. It is left
in place with a one-line note at the branch; this is an observation
only, with no card.
- **Out of scope.** The code cites ADR-0149 D1 for the closed-member
rule; the ADR carries no line for it yet. That line is governed text
owed by the skills lane, card #34309.
## Verification
The readings below are from the first round, on `b263c8df14` (a merge of
`origin/main` into the branch). The final head's readings are in "Fix
round 4 (completion)" above.
<details><summary>service-analytics suite, typecheck, dependents (one
lock hold, VERDICT command-exit 0)</summary>
- `pnpm install`: exit 0.
- `pnpm --filter '@objectstack/dogfood^...' build`: exit 0.
- `pnpm --filter @objectstack/service-analytics test`: exit 0, Test
Files 216 passed (216), Tests 5247 passed, 335 skipped (5582).
- service-analytics `tsc --noEmit`: exit 0. Its tsconfig includes the
src tests.
- The 7 runtime-facing files: exit 0, 45 passed, 18 skipped.
- metadata-protocol build-probes: exit 0, 4 files, 21 tests.
</details>
<details><summary>Ablation (each leg landed and was restored to the HEAD
blob)</summary>
Both legs ran through `scripts/ablation-replace.mjs`, with a trap that
restores to `HEAD`.
| Leg | Mutation | Tests run | Result | Restore |
|---|---|---|---|---|
| 1 | delete the service call `await
this.assertSelectionMembersDeclared(...)` (anchor 1 → 0, blob
386a29b → 156d9334211e) | `dataset-query-declared-members` +
`preview-undeclared-measure-parity` | 17 failed, 6 passed: every refusal
pin red, controls green | blob == HEAD (386a29b), `git diff HEAD`
empty |
| 2 | delete the tool call `assertDeclaredMembers(...)` (anchor 1 → 0,
blob cc4635d → 0069eb75e100) | `dataset-tools.test.ts` | 7 failed,
36 passed | blob == HEAD (cc4635d), `git diff HEAD` empty |
Final check: `DIFF_HEAD_EMPTY=yes`.
</details>
<details><summary>Dogfood battery (title carries `!` and a (narrowing)
arm)</summary>
- Command: `pnpm --filter @objectstack/dogfood test` under the lock. No
shard and no path.
- VERDICT command-exit 0.
- Test Files 470 passed, 3 skipped (473). Tests 3983 passed, 42 skipped
(4025). This includes the new
`analytics-dataset-declared-members.dogfood.test.ts`.
</details>
<details><summary>Derived gate families (dispatch-gates)</summary>
- `node scripts/pm/dispatch-gates.mjs --repo objectstack-ai/objectstack
--ran` reports: 101 derived, 98 run, 3 NOT-MEASURED, 0 UNRUN. The exit
codes are recorded per family.
- 98 families exited 0, including:
- `check-adr-0087-registration --base origin/main` (exemption notice)
- `check-changeset-no-major`
- `check-closing-keyword-parity`
- `check-nul-bytes`
- `check:docs-transcript-drift`
- `check:dts-closure`
- 3 families are NOT MEASURED. Each exited 3 (PREREQUISITE NOT MET)
because the local tree has no built `dist/` for the packages they read.
The PR check-runs carry them:
- `pnpm --filter @objectstack/spec run check:skill-examples`:
`packages/client-react/dist` is not built.
- `pnpm check:dual-build-cjs-loads`: some package has no `dist/`.
- `pnpm check:type-check-debt`: closure build queued behind the shared
lock; stopped.
- Repo-wide `pnpm lint` and `test:repo` are left to CI.
</details>
<details><summary>Merge-tree</summary>
- Against `origin/main`: clean.
- #34025: already merged, `git merge-tree` exit 0.
- #33652 (open): exit 1, but the conflicts are in objectql files that
`main` itself conflicts on. File overlap with this diff: none.
</details>
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- signed: repo:objectstack#1 · os-project-manager ·
session_01FEkQ5pHNFS9mn8hS13iGyL -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 80cdbd4 commit 898655a
23 files changed
Lines changed: 1517 additions & 350 deletions
File tree
- .changeset
- content/docs
- api
- data-modeling
- ui
- packages
- qa/dogfood/test
- rest/src
- services/service-analytics/src
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
490 | 490 | | |
491 | 491 | | |
492 | 492 | | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
493 | 499 | | |
494 | 500 | | |
495 | 501 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
269 | 269 | | |
270 | 270 | | |
271 | 271 | | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
272 | 284 | | |
273 | 285 | | |
274 | 286 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
106 | | - | |
| 106 | + | |
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
| |||
494 | 494 | | |
495 | 495 | | |
496 | 496 | | |
497 | | - | |
498 | | - | |
499 | | - | |
500 | | - | |
501 | | - | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
502 | 539 | | |
503 | 540 | | |
504 | 541 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
0 commit comments