Repository navigation
feat(objectql,service-analytics): refuse a raw aggregate over a record-mode quantity unless grouped by its unit field - #36060
Conversation
…d-mode quantity unless grouped by its unit field ADR-0158 U7 R1, mirroring ADR-0144 D6: the ObjectQL aggregate door (INVALID_FIELD / 400), summary registration (INVALID_METADATA / 422, always refused in R1 per L3) and the analytics cube door (INVALID_FIELD / 400). sum, avg, min and max are raw; count and count_distinct are not judged; a fixed-mode quantity and a plain number pass. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibvMi1U7R2kBd3JbTPu
… doors Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibvMi1U7R2kBd3JbTPu
📓 Docs Drift CheckThis PR changes 2 package(s): 26 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 9 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 27 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 615f989f307ff96f1315ec58a318b22563da8b69 && git checkout 615f989f307ff96f1315ec58a318b22563da8b69
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 035a12cc248fe38610f2cb1e37d4aaeacae568c8 948f9983194a829ab2c7f35d11a4fed941908431 && git checkout -B drift-repro 035a12cc248fe38610f2cb1e37d4aaeacae568c8 && git merge --no-ff 948f9983194a829ab2c7f35d11a4fed941908431
node scripts/docs-audit/affected-docs.mjs --json 035a12cc248fe38610f2cb1e37d4aaeacae568c8
|
|
repo:objectstack#7 · os-tesla · session_01L9qibwRAQZtb2syxNdJ6zT L1 · PR #36060 · head
|
… in the changeset Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibvMi1U7R2kBd3JbTPu
|
repo:objectstack#7 · os-tesla · session_01L9qibwRAQZtb2syxNdJ6zT Delta L1 · PR #36060 · head
|
|
repo:objectstack#7 · os-tesla · session_01L9qibwRAQZtb2syxNdJ6zT Contract-review-claim: session_01L9qibwRAQZtb2syxNdJ6zT · head 948f998 · 2026-11-21T12:44Z |
|
repo:objectstack#7 · os-tesla · session_01L9qibwRAQZtb2syxNdJ6zT Contract reviewServed-tier: Rendered 2026-11-21T12:49Z by an isolated reviewer sub-agent at TIER_DEFAULT (brief in the next comment), adopted by the L1-b session. Face: declaration ( ① Derived judgments
② Semver level
Clause-②: yes (widening) — right: item ① 1 is a widening of a root type export, and items ① 3 to 5 narrow only an unreleased declaration. ③ Boundary flags
Findings:
Implemented-by: VERDICT: PASS |
|
repo:objectstack#7 · os-tesla · session_01L9qibwRAQZtb2syxNdJ6zT Brief handed to the isolated TIER_DEFAULT reviewer of the record above, posted 2026-11-21T12:49Z: Contract review brief — PR #36060 @
|
|
repo:objectstack#7 · os-tesla · session_01L9qibwRAQZtb2syxNdJ6zT Delta record rendered 2026-11-21T12:52Z by the same isolated TIER_DEFAULT reviewer (brief 7062840212), adopted by the L1-b session. Contract reviewServed-tier: ① Derived judgmentsNo change since record 7062833476: the head is the same commit ( ② Semver levelNo change: Clause-②: yes (widening) — right, as in record 7062833476. ③ Boundary flagsThis is the delta read of S1 from record 7062833476. The head is unchanged; only the PR body was edited.
Implemented-by: VERDICT: PASS |
|
repo:objectstack#7 · os-tesla · session_01L9qibvMi1U7R2kBd3JbTPu Landing #36060 at
State change: ready for review, then auto-merge. |
|
repo:objectstack#7 · os-tesla · session_01L9qibvMi1U7R2kBd3JbTPu Re-queue #36060 at Dequeued 13:30Z (
So it is not this PR's: re-queued once as is. If the same signature ejects it again, I stop and hand it on for diagnosis rather than re-queue. |
⛔ merge queue 构建失败 — 先分诊,再决定要不要重排队列构建 44907697012 红了。队列跑的是全量套件(PR 侧 CI 只跑 affected 子集), 分类: 失败的 job(日志抽取,best effort):
跨 PR 相同签名(24h,按失败测试文件聚合):
历史信号:
分诊清单:
Generated by Claude Code · merge-queue-triage workflow (#4859) |
…keeps it in the recycle bin (objectstack-ai#36097) repo:objectstack#7 · os-tesla · session_01L9qibwJEh7hMPPvagWM1g7 Fixes objectstack-ai#35667 Clause-②: no Metadata-protocol: none Clause-② basis: no (the seat's reading, from L1 O1 7063276615). Under a walled posture, a system-door delete of an org-less record is now refused with `ERR_SYSTEM_WRITE_ORGANIZATION_REQUIRED`. That is not a narrowed accept set. Every SQL store already refused that delete on the bin's NOT NULL. The memory store accepted it only by writing a bin entry no organization owns, which breaks the bin's own invariant (ADR-0148 D1, ADR-0131 D1): no organization's listing or cascade reaches it. The fix makes every store answer as D9 states, so it is a bug fix, not a `(narrowing)`. ## 维护者速读 - 用户能看到什么变化:流程、钩子或管理工具以系统身份删除一条不归属任何组织的记录时,记录会进入回收站并可恢复,不再报数据库错误;多组织隔离模式下则明确拒绝并说明原因。 - 为什么做:回收站功能的修复,替以系统身份删除全局记录的流程和管理工具解决删除失败的问题。 - 出错会怎样:最坏情况是系统身份删除被拒绝而记录原样保留,不会丢数据;撤回本次改动即恢复原状。 - 要你做什么:无。 ## What changes A delete under `{ isSystem: true }` of a record that names no organization (a record of a `tenancy: { enabled: false }` object) wrote its recycle-bin entry with no organization. On SQL the delete failed with `NOT NULL constraint failed: sys_recycle_bin.organization_id` and the record stayed. On a store that enforces no NOT NULL, the delete succeeded and left an entry that no organization owned. The entry is a row of a tenant-column object (ADR-0148 D1). It now takes the organization any system insert takes (ADR-0131 D9): the record's own, else the context's, else the engine's one system-insert resolver. Under `single` that resolver answers the Default Organization. Under a wall it refuses with `ERR_SYSTEM_WRITE_ORGANIZATION_REQUIRED` before the root row is removed. Route B of the seat's routing call (claim amendment 7062354282, analysis 7062338699): `packages/objectql/src/engine.ts` gains no line and `scripts/facade-delegation-registry.json` is untouched. - `packages/objectql/src/engine-delete-and-aggregate.ts`: the delete module already holds the engine and already reads a sibling facet's host through it (`securityResolversHost.of(this.facade)`). It hands the capture's `write()` a call to `MiddlewareAndContextFacet.resolveSystemInsertOrganization` through `middlewareAndContextHost.of(this.facade)`. That is the same body the engine's insert calls, not a second spelling of it. - `packages/objectql/src/recycle-bin/capture.ts`: `write(resolveSystemInsertOrganization)` stamps the resolver's answer when neither the record nor the context names an organization. A new exported type `RecycleBinSystemInsertOrganization` states the contract and why it arrives as an argument and not as a `RecycleBinCaptureHost` member. - Pins: - `packages/runtime/src/recycle-bin-orgless-system-delete.test.ts`: a real `ObjectQL` on a real `SqlDriver` (better-sqlite3), the bin as platform-objects declares it, and the Default Organization. - A top-level describe in `packages/objectql/src/recycle-bin/capture.test.ts`, the shared capture harness, for the store that enforces no NOT NULL. - A `patch` changeset for `@objectstack/objectql`. ### Files to read first 1. `packages/objectql/src/recycle-bin/capture.ts`, the `write()` hunk: the order is record, then context, then resolver, and a refusal throws before `driver.create`. 2. `packages/objectql/src/engine-delete-and-aggregate.ts`, the `bin?.write(...)` call: the cross-facet host read. 3. `packages/objectql/src/recycle-bin/capture.test.ts`, the `makeEngine` Default Organization seed: fixture triage, see Acceptance notes. ### Two-minute check Run `pnpm --filter @objectstack/runtime exec vitest run --project local src/recycle-bin-orgless-system-delete.test.ts` after building objectql. Expect 3 passed: under `single` the entry's `organization_id` is `org_default` and restore brings the record back; a context-named organization is kept; under `isolated` the delete is refused with `ERR_SYSTEM_WRITE_ORGANIZATION_REQUIRED` and the record stays. ## Tests All readings are on head 4bd70f0 unless noted. <details><summary>Measurement before the fix (main 8145424, scratch test, not committed)</summary> - sqlite: the system-door delete threw `SQLITE_CONSTRAINT_NOTNULL`, `NOT NULL constraint failed: sys_recycle_bin.organization_id`, and no entry was written. A beforeDelete hook saw session `{ isSystem: true }` and no `tenantId`. - memory store: the delete answered `true`, and the bin held `{ object_name: mz_global, organization_id: null }`. - Control on sqlite: a tenant-column record written by a system insert was stamped `org_default` (D9), and its delete kept the entry under `org_default`. </details> <details><summary>Gate before building (route B premises)</summary> - `pnpm check:facade-delegation-only` exited 0 and printed `packages/objectql/src/engine.ts: 6857 lines, ceiling 6857 (0 left; ruling 7051956587)`. `wc -l packages/objectql/src/engine.ts` reads 6857. - `pnpm --filter @objectstack/objectql typecheck` (`tsc --noEmit && pnpm check:test-typecheck`) passed under lock VERDICT command-exit 0 with the cross-facet call in place. </details> <details><summary>Pins, ablation and package suites</summary> - Runtime pin (sqlite): Tests 3 passed (3). - Capture harness: Tests 30 passed (30). The `src/recycle-bin/` directory: Test Files 5 passed, Tests 178 passed. - Ablation on head 4bd70f0: - The mutation went through `scripts/ablation-replace.mjs`, replacing the resolver call with `const derived: string | undefined = undefined;`. Anchor count went 1 to 0, and the blob went d124655 to 79309b11f005. - objectql was rebuilt, and `ablation-dist-preflight --absent` confirmed the marker was absent from all 14 built files. - Results with the mutation: the runtime pin had 2 failed and 1 passed (the context control). The capture harness had 2 failed and 28 passed. - Restore: `git checkout HEAD --`, then `git diff HEAD` was 0 bytes and the hash matched d124655. objectql was rebuilt, the preflight found the marker present in 2 built files, and the tree was clean. - After the restore the runtime pin had 3 passed and the capture harness 30 passed. - `pnpm --filter @objectstack/objectql test`: Test Files 624 passed (624), Tests 14217 passed (14217). `pnpm --filter @objectstack/objectql typecheck` passed. Lock VERDICT command-exit 0. - Consumers that compose the bin and delete without a booted auth (`mcp` stdio-data-bridge.recycle-bin, `cloud-connection` connection-credential-ledger, `metadata-protocol` seed-tenancy-backfill, `runtime` sandbox body-runner): 5, 11, 58 and 42 tests passed. Lock VERDICT command-exit 0. - Not run locally, left to CI: `pnpm --filter @objectstack/runtime typecheck`, which needs the runtime dependency closure built, and `test:repo`. </details> ## Verification <details><summary>Gate families</summary> `node scripts/pm/dispatch-gates.mjs --commands` derived 66 families on 4bd70f0, and all 66 exited 0. `--ran` reconciliation: 66 derived, 66 run, 0 NOT-MEASURED, 0 UNRUN. On the earlier head e95ae7d, `check:driver-memory-census` was red because the first runtime pin imported `@objectstack/driver-memory`. Head 4bd70f0 moved that leg into the capture harness, and the census is green there. `overlap-check` returned a clean verdict before each push: origin/main merges cleanly, and so does objectstack-ai#36060, which shares `engine-delete-and-aggregate.ts`. </details> ## Acceptance notes - **Deviation from the dispatch: the memory leg is not on `@objectstack/driver-memory`.** A new test consumer of that driver is a ruled disposition. `check:driver-memory-census` printed: "LEDGERED: … binds @objectstack/driver-memory (import) and the ledger does not cover it … Rule it, migrate it, or file it". So the store that enforces no NOT NULL is pinned in the capture harness, which keeps rows the way `driver-memory` does. That harness is the shared harness file for this component. - **Fixture triage (adds a missing declaration).** The capture harness registered `sys_organization` but held no organization. Under `single` that is the broken boot invariant D9 refuses. Ten existing capture tests deleted org-less records with org-less contexts there and went red on `ERR_SYSTEM_WRITE_ORGANIZATION_REQUIRED`. The harness now seeds the Default Organization. The one test whose deletes all name their organization (the organization-delete cascade) opts out, so it still counts only its own two organizations. - **Walled posture.** A system-door delete with no `tenantId` of a tenancy-disabled record is refused with `ERR_SYSTEM_WRITE_ORGANIZATION_REQUIRED` (500) and the record stays. The seat accepted this as D9 as written. A caller that needs it threads `tenantId` on the context. - **MongoDB.** `MongoDBDriver` does not stamp the tenant column on insert, by its own docblock (`packages/drivers/driver-mongodb/src/mongodb-driver.ts`, the single-tenant note). A tenant-column row it writes therefore carries no `organization_id`. No test here reproduces that; this is a code read only, and on the seat's word it is noted here and not filed. The capture change covers the system-door delete of such a row under `single`. --- _Generated by [Claude Code](https://claude.ai/code/session_01L9qibwJEh7hMPPvagWM1g7)_ <!-- signed: repo:objectstack#7 · os-tesla · session_01L9qibwJEh7hMPPvagWM1g7 --> --------- Co-authored-by: Claude <noreply@anthropic.com>
…of 2026-11-21) (objectstack-ai#37045) <!-- claude-projects-attribution: {"github_login":"huangyiirene"} --> _Requested by **Irene** · [project thread](https://claude.ai/code/project/chan_01TJXtQ1tVD26ecLDZxFS67x?thread=cmsg_01TJXtQ1tVD26ecLDZxFS67x8Be2AAcUBhodBsvnWLd3Xs)_ Fixes objectstack-ai#36086 Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:用户无感;十二份内部设计记录在与现行代码不一致的地方各加一条注明日期的补注,原决定文字不动,只有访客模型里一句已被裁决撤回的接口说明照裁决改掉。 - 为什么做:这是本周的设计记录修订合集;AI 席位改代码前会读这些记录,这十五处已与上线代码不一致,会把 AI 带偏。 - 出错会怎样:只改说明文字,不动代码和功能;补注若写错,读记录的 AI 和人会拿到错误说明,整个合并可以直接撤回。 - 要你做什么:审阅后批准一次(设计记录必须由你亲手批)。 ## What changes Seventeen append-only dated notes, for the 15 rows of this week's card whose code is on `main`, in twelve records. Each note sits directly under the passage it amends, says what `main` does now, and links its card and its landing PR. One clause is rewritten, in ADR-0138, as its row and the ruling on it ask. No other decision text is rewritten, struck or reordered. Six records whose header indexes their amendments gain a pointer entry there (ADR-0050, 0066, 0090, 0138, 0151, 0158). | # | ADR · section | What it said | What `main` does | Landing PR | Note location | |:--|:--|:--|:--|:--|:--| | 1 | ADR-0158 · Open item 12 | Which aggregates count as "raw" is left to the aggregate card | `sum`, `avg`, `min` and `max` over a `record`-mode quantity are refused unless the query groups by the quantity's own `unitField`: ObjectQL aggregate `INVALID_FIELD` / 400, `summary` field `INVALID_METADATA` / 422, cube measure `INVALID_FIELD` / 400 on each query. `count`, `count_distinct`, a `fixed`-mode quantity and a plain number are not judged. No error code is added | objectstack-ai#36060 | under Open item 12; status entry | | 2 | ADR-0066 · D2 ⑧ | View All and Modify All are the bits that vote on every field of an object | A set may carry `viewAllFields`: a read vote, never an edit vote, on every field of the object. The set's own `readable: false` row beats it. It grants no object access, no record and no admin posture | objectstack-ai#36085 | under D2 ⑧, after the 2026-11-15 note; status entry | | 3 | ADR-0090 · D5 | The high-privilege list refused on an `everyone` binding | The list gains `viewAllFields` on any object entry | objectstack-ai#36085 | under D5; status entry | | 4 | ADR-0090 · D12, condition (a) | No `viewAllRecords` or `modifyAllRecords` on `'*'` | Condition (a) also refuses `viewAllFields` on `'*'`; the bit on a named object stays inside the boundary | objectstack-ai#36085 | under D12's 2026-10-17 amendment | | 5 | ADR-0151 · D3 | The bits the agent ceiling removes | The clamp also clears `viewAllFields` on every object entry; assigning a set that carries it to an account is refused by name | objectstack-ai#36085 | under D3; header entry | | 6 | ADR-0050 · Decision 2, the 2026-10-20 note | "a per-list open mode, if ever wanted, is the list's existing `navigation.mode`" | On an object's list `navigation.mode` is deprecated and no longer picks how a record opens: the name opens the full page, the hover icon the side panel. `none` still means the rows open nothing. A page block still honours every value | objectstack-ai#35910 | under Decision 2, after the 2026-10-20 note; status entry | | 7 | ADR-0050 · the same note | The create form is chosen by convention from the object's form views | The console's record create and edit forms are the object's own, laid out by `fieldGroups`, less a `showOnCreate: false` field on a create. An internal form view steers nothing there. A public form and a named form an action opens keep their own definition | objectstack-ai#36543 | second note under Decision 2 | | 8 | ADR-0052 · section 5b, tier 1 | "Opt-in (like Feed Tracking) keeps the stream from becoming change-noise" | Old and new values show by default. Off per object with `enable.fieldHistory: false`, per field with `fieldHistory: false`. An entry serves a field's values only to a reader who is served that field | objectstack-ai#36399, objectstack-ai#36580, objectstack-ai#36613, objectstack-ai#36641, objectstack-ai#36661 | under tier 1 | | 9 | ADR-0146 · D1 | Studio is where metadata is edited | A workspace administrator also edits in the running app: the menu and the pinned header actions in design mode, a dashboard on its page, a report on its builder page, a view's settings on the view. Each save is one item's draft and publish, and writes nothing over a pending draft | objectstack-ai#36397, objectstack-ai#36437, objectstack-ai#36629, objectstack-ai#36405, objectstack-ai#36644, objectstack-ai#36411, objectstack-ai#36848 | end of D1, after the 2026-11-24 amendment's table | | 10 | ADR-0146 · D5 (two card rows) | The bridge draws on the app switcher row and the app bar entry | From 768 px up the entries are two rows of the app-name menu. "Design layout" turns on design mode. "Edit app" opens Studio, and reads "View in Studio" for a read-only package. The page header draws neither | objectstack-ai#36437, objectstack-ai#36621, objectstack-ai#36789 | under D5 | | 11 | ADR-0146 · D10, the 2026-11-22 note | An extension places only what it brings; the base's arrangement stays the base's | The App's paired `.custom` package may declare whole `fieldGroups` and `relatedLists`. Each key it writes replaces the folded result whole. Any other package is refused and prescribed `place` | objectstack-ai#36517 | under D10, after the 2026-11-22 note | | 12 | ADR-0146 · D10, the same note | (the same) | `actionLayout` is the third such key. Only the paired `.custom` package writes it on an extension. Each arm it writes replaces the served arm whole. The server refuses the shape; the reference is refused by design mode's Save and by the CLI rule only | objectstack-ai#36629 | second note under D10 | | 13 | ADR-0138 · D2, the 2026-11-20 amendment | The restriction profile is served on the unscoped route "and its environment-scoped twin" | Only the unscoped route is mounted. A request to the twin gets the host's ordinary not-found answer. A server that mounts the scoped base alone serves no profile | objectstack-ai#36531 | the clause is rewritten in place; a dated amendment under it; status entry | | 14 | ADR-0149 · D3, rules 4 and 5 | Both rules apply to an unknown word beside a grouping word; the record did not say which governs | Rule 4 governs the unknown word: the labelled fallback, nothing asked. Rule 5 is the rule for a question that names no number. Beside a fallback the note ends with one conditional sentence | objectstack-ai#36509 | under D3, after the 2026-11-19 note | | 15 | ADR-0027 · roadmap row M2 | "explicit, batched publish" | In Studio's designers a person's Save writes the draft and publishes that one item at once. Drafts and the package's batch publish remain for an AI's changes | objectstack-ai#36597, objectstack-ai#36634, objectstack-ai#36652 | under the roadmap table | | 16 | ADR-0037 · the product-boundaries amendment | "Publish remains the single commit gate shared by every surface" | The publish is the item's own, issued by the Save itself. The top bar's Publish is drawn only while a draft is pending | objectstack-ai#36597, objectstack-ai#36634, objectstack-ai#36652 | under that sentence | | 17 | ADR-0085 · section 2 | `relatedLists` is "the one place" where the re-arrange rejection yields | `actionLayout` is the second: a ruled exception (the maintainer's ruling on objectstack-ai#36635), on the object, with a `list` arm and a `record` arm | objectstack-ai#36629, objectstack-ai#36815 | under section 2, after the 2026-11-22 note; dated 2026-11-23 | The 15 card rows are the 17 lines above: the `viewAllFields` row is lines 2 to 5, and the two ADR-0146 D5 rows are line 10. **Rows not carried** - ADR-0085, the `fieldGroups[].collapse` row: already on `main` through objectstack-ai#36817. The record carries "Addendum (2026-11-22): on the synthesized record page the reader folds every titled group", which says what the row asks for. Nothing is added. No `scripts/adr-anchors/**` entry moves. No `**Status**:` line changes in the part the index projects, so `docs/adr/README.md` stays current. ## Why AI seats read the ADRs before they change code in governed territory (AGENTS.md Prime Directive objectstack-ai#13). These passages say something `main` no longer does, so a seat that trusts them is steered wrong. This is the week's rolling ADR revisions card: its rows land together as one governed `docs/adr/**` PR and one approval, on the maintainer's word of 2026-11-20 (「adr接受你的建议」). ## Tests Docs-only diff: no package, test or build input is touched, so no package test or typecheck applies, and nothing a test pins changes. ## Acceptance notes - Every row was read against the code on `main` at `a73edb3cd`, not against PR state. Each landing commit is an ancestor of the branch, and each note names the file or symbol that makes it true. `main` has moved once since (`9c57bd283`); that commit touches no `docs/adr/**` file and no file a note names. - Where a row's claim is not what `main` does, the note states what `main` does: - **ADR-0052.** The row gives the per-field switch as `trackHistory: false`. On `main` it is `fieldHistory: false`; `trackHistory: false` reads as unset. - **ADR-0146 D1.** Three sentences of the row are not written. "The fate of Studio's Interfaces pillar is still open": the 2026-11-24 amendment of D1, already on `main`, retires the pillars. "Studio is not changed by this batch": the same amendment changes it. "Each of these writes the same paired package": a report's save and a change to an existing view's settings name no package, and the menu, the action arrangement and a dashboard go to the item's own package when it is writable. The note says where each save lands. It does not repeat what that amendment already says about dashboards and reports opening in the app. - **ADR-0146 D5.** Both card rows describe a state objectstack-ai#36789 has since replaced: the row of objectstack-ai#36437 has the page header's button enter design mode, and the row of objectstack-ai#36621 has the app-name menu's "Edit app" enter it. On `main` the entry into design mode is "Design layout", and "Edit app" opens Studio. The two rows are written as one note that states the end of that sequence. - **ADR-0027.** The row says later PRs will move the other Studio editors. They have landed (objectstack-ai#36634, objectstack-ai#36652) and the note cites them. It quotes the maintainer's own sentence on the epic, not the epic's summary line. - **ADR-0037.** The row says a pending draft now means an AI's draft. Studio's generic item page still saves a person's drafts (its move is declared by D1's amendment and not built), and the note says so. - **ADR-0085.** The row says the row menu is queued and not built. objectstack-ai#36815 built it, and it follows the `record` arm; the note says so. The `list` arm still has one reader. - Header entries: added where a record's header indexes its amendments (ADR-0050, 0066, 0090, 0138, 0151, 0158). Not added to ADR-0146: its status block lists only the maintainer's in-place amendments, its 2026-11-22 note under D10 has no entry there, and open PR objectstack-ai#36957 edits that block. Not added to ADR-0027, 0037, 0052, 0085 and 0149, whose headers hold no such list. - Dates: every note is dated 2026-11-24, except ADR-0085's, dated 2026-11-23 as its row sets (that record dates its notes by ruling). ADR-0138's amendment is dated 2026-11-24 and names the ruling's date, 2026-11-22. - ADR-0151 is `Proposed`; its note follows the form of the dated notes it already carries. - The spec docblock sentence the ADR-0085 row mentions landed with objectstack-ai#36629, so nothing outside `docs/adr/**` is owed. - Noted, not filed (read-only observations, nothing was run to exercise them): - A report's save, and a change to an existing view's settings, from the running app name no package. For an item of an installed package whose stored rows are not bound to exactly one package, the server then addresses the package-unbound row, not the paired `.custom` package ADR-0146 D2 points customizations to. Whether a door refuses that write was not measured. - Two source comments still say design mode is entered from "Edit app" (the page-actions module header and the design-mode module's gate paragraph). Comments only. - Landing tier: Tier H (`docs/adr/**`, governed; the maintainer approves). The diff is +243 / -5 over 12 files. ## Verification Read first, by risk: 1. `docs/adr/0138-guest-model-anonymous-principal-doors-grants-and-organization.md`, the D2 hunk: the one place earlier text is rewritten. 2. `docs/adr/0146-studio-designs-setup-administers-one-editor-per-item-paired-customize-package.md`, the note at the end of D1: the widest claim, where each in-app save lands. 3. `docs/adr/0066-unified-authorization-model.md`, the note under D2 ⑧, with its ADR-0090 D12 twin: permission semantics. Two-minute check: `pnpm check:adr-symbol-anchors` prints a green line that starts `check-adr-symbol-anchors: 3904 anchors across 160 records`, and `git diff origin/main...HEAD --stat` shows 12 files, 243 insertions and 5 deletions. <details><summary>Gate readings on e5c60bf</summary> `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` derived the same 21 families on `8c705bc2c` and on `e5c60bff0`. The readings below are the second run, on `e5c60bff0`, each exit captured before any pipe: ```text node scripts/check-adr-links.mjs :: exit 0 node scripts/check-adr-links.mjs --self-test :: exit 0 node scripts/check-closing-keyword-parity.mjs :: exit 0 node scripts/check-closing-keyword-parity.mjs --self-test :: exit 0 node scripts/check-comment-mask-corpus.mjs :: exit 0 node scripts/ci/plan-test-core-shards.mjs --self-test :: exit 0 pnpm --filter @objectstack/lint run check:doc-formula-expressions :: exit 0 pnpm check:adr-anchors :: exit 0 pnpm check:adr-index :: exit 0 pnpm check:adr-symbol-anchors :: exit 0 pnpm check:ci-filter-parity :: exit 0 pnpm check:closed-ceremony-text :: exit 0 pnpm check:cross-package-test-inputs :: exit 0 pnpm check:doc-authoring :: exit 0 pnpm check:driver-memory-census :: exit 0 pnpm check:gitlink-declared :: exit 0 pnpm check:nul-bytes :: exit 0 pnpm check:pm-governed-merges :: exit 0 pnpm check:pm-prior-rulings :: exit 0 pnpm check:refd-timer-probe :: exit 0 pnpm check:watch-hint-literal :: exit 0 ``` On the first run `check:doc-formula-expressions` answered 3, prerequisite not met, until `formula` and `lint` were built under `os-verify-lock` (VERDICT command-exit 0, 5 of 5 tasks). `--ran` reconciliation: 21 derived, 21 run, 0 NOT-MEASURED (a derived zero). `node scripts/adr-index.mjs --check`: exit 0, the README is current. `check-commit-card-trailers --range origin/main..HEAD`: exit 0, 2 commit messages. `overlap-check`: `origin/main` and objectstack-ai#36957 both merge cleanly, VERDICT clean exit 0. `check-governed-merges --branch`: GOVERNED, 12 of 12 paths on the register, Tier H. Control-byte scan of the twelve files: 0 hits. </details> ## Human Minimum - [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic. (No schema touched.) - [x] 2. Every name I added uses the casing for its kind. (No name added.) - [ ] 3. No formatter ran; `pnpm lint` passes. (No formatter ran. `pnpm lint` was not run locally on this Markdown-only diff; CI judges it.) - [x] 4. One issue, one branch off an up-to-date `main`, one pull request. - [x] 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset. (Publishes nothing: `skip-changeset`.) - [x] 6. `packages/spec` touched: its generated artifacts are regenerated and committed. (Not touched.) - [x] 7. No hand edits to `content/docs/references/`, `packages/*/CHANGELOG.md` or `content/docs/releases/`. - [x] 8. Title, body and comments are in English. - [ ] The *Before Submitting* list in CONTRIBUTING.md is done. (Not walked item by item; the derived gates above are what ran.) 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01J8VVAoUbebHyRXKT4GxBTV --------- Co-authored-by: Claude <noreply@anthropic.com>
repo:objectstack#7 · os-tesla · session_01L9qibvMi1U7R2kBd3JbTPu
Fixes #35491
A total over a quantity whose unit is stored per row (
unitConfig: { unitMode: 'record', unitField }) is now refused unless it groups by that unit field. Before, 10 KGM plus 10 LBR answered 20 in the engine aggregate, a dataset or cube measure, and asummaryroll-up. This is ADR-0158 U7 R1, built as a one-for-one mirror of the ADR-0144 D6 record-currency doors.Clause-②: yes (widening)
Metadata-protocol: none
维护者速读
What changes
packages/objectql/src/record-unit-aggregate-door.ts, wired inObjectQL.aggregateright after the record-currency door):sum/avg/min/maxover arecord-mode quantity answersINVALID_FIELD/ 400 before any driver is asked, unlessgroupByincludes the quantity'sunitField. The message names the quantity, its unit field and the grouping to add; the thrown error carriesfield,fields,object,param: 'aggregations'andunitField(in process only: the/dataREST body keepsfieldandobjectand dropsunitField, measured below).summaryregistration (recordUnitSummaryRefusal, inSchemaRegistry.registerObjectbesiderecordCurrencySummaryRefusal): a roll-up ofsum/avg/min/maxover such a child quantity answersINVALID_METADATA/ 422 (RecordUnitSummaryRefusedError), judged at whichever registration completes the pair. Per ADR-0158 L3 every such roll-up is refused in R1 (nomaster_detailfollowing), so the roll-up recompute gets no bypass channel: the currency door needsROLLUP_AGGREGATE_OPTIONonly for its admitted roll-up, and units admit none.packages/services/service-analytics/src/cube-record-unit-door.ts, asked right after the record-currency door at all four places that ask it: the inferred, augmented and declaredensureCubepaths and the draft-preview branch ofqueryDataset):INVALID_FIELD/ 400, the thrown error carryingmember,param: 'measures',field,objectandunitField(in process only: the analytics REST body iscodeandmessage), unless a dimension's column is the unit field on the same object. The plugin'ssourceFieldMetarelaysunitFieldonly for anumberunderunitMode: 'record'. The dimension resolver both doors share moved into one private method (groupedColumnOf), with no change to what it answers.AnalyticsServiceConfig.sourceFieldMetamay answer one more optional key,unitField: anumberfield'sunitConfig.unitField, underunitMode: 'record'only.AnalyticsServicePluginrelays it for anumberunderunitMode: 'record'and for nothing else. A host that does not answer it gets no record-unit judgment from the cube door. The precedent is a35fc66,homeAmountFieldon the same answer. The errors'unitFieldmember is not part of the widening: no REST envelope carries it.@objectstack/objectqland@objectstack/service-analytics.The raw-aggregate set, as built (ADR-0158 Open item 12, the aggregate half; carried to the ADR text by the weekly ADR revisions card #36086, whose row lands after this PR merges):
sum,avg,minandmaxare raw.countreads no quantity andcount_distinctadds nothing, so neither is judged. Grouping by the quantity's ownunitFieldadmits the aggregate. Afixed-mode quantity and anumberfield with nounitConfigpass unchanged. No new error code:INVALID_FIELDandINVALID_METADATA, as ADR-0144 assigned for currency.Why
ADR-0158 U7 R1: "a build-time refusal of a raw aggregate over a
record-mode quantity unless it groups by that quantity's unit field (mirrors ADR-0144 D6)". L3: "In R1, asummaryoverrecord-mode child quantities is therefore always refused, as every such currency roll-up was before ADR-0144's D6 amendment".Tests
Read first (by risk):
packages/objectql/src/engine-delete-and-aggregate.ts: the one new call, after the record-currency door.packages/objectql/src/registry-object-registration.ts: the summary refusal beside the currency one.packages/services/service-analytics/src/analytics-service.ts: the four call sites and the extractedgroupedColumnOf.Two-minute check:
pnpm --filter @objectstack/objectql exec vitest run src/record-unit-aggregate-door.test.tsshows 8 passed;pnpm --filter @objectstack/service-analytics exec vitest run src/__tests__/record-unit-analytics.test.tsshows 23 passed.packages/objectql/src/record-unit-aggregate-door.test.ts(8): ungroupedsum/avg/min/maxrefused with code, status, field, unit field and the remedy inside the first 500 characters; grouped by another field refused; grouped by the unit field answersKGM [15, 7.5, 5, 10],LBR [10, 10, 10, 10];count3,count_distinct2, fixed-unitsum11 andmax6, plainsum6 andavg2; the summary refused at both registration orders and over itself, naming roll-up, quantity and unit field;countover the quantity,sumover the fixed quantity and the plain number register in both orders and roll up 2, 9 and 5.packages/services/service-analytics/src/__tests__/record-unit-analytics.test.ts(23, SqlDriver over better-sqlite3, both strategies): grouped values per unit; a totals grouping keeping the unit; refusals (another dimension only, each raw aggregate ungrouped, a grand total) with no read of the object;count,count_distinct, fixed-unit and plain measures served ungrouped with values; the cube face; the inferred cube refused and then served grouped; the draft preview refused and served grouped.Before and after, measured on a real engine (ObjectQL over SqlDriver / better-sqlite3)
The four wiring files restored to
origin/mainfor the before run; the probe is a throwaway file, not committed.aggregate sum(qty), rows 10 KGM and 10 LBR20INVALID_FIELD/ 400avg/min/max10/10/10INVALID_FIELD/ 400 eachcount(qty)22sum(qty)grouped byunit_codesummarysum over child rows 10 KGM, 10 LBR20INVALID_METADATA/ 422 at registrationtotalungrouped20INVALID_FIELD/ 400totalby unitqty_sum20INVALID_FIELD/ 400Ablation, one per door (committed first; scripts/ablation-replace.mjs; restore proven by blob equality)
The suites resolve
@objectstack/objectqland the service tosrc(the service-analytics vitest alias), so nodistrebuild sits between mutation and run.assertRecordUnitAggregatesGrouped(...)call inengine-delete-and-aggregate.ts: 2 failed / 6 passed (the two refusal pins); restored, blob691b2595e09a== HEAD.if (recordUnitSummary) return { refusal: recordUnitSummary };: 3 failed / 5 passed (both orders and the self roll-up); restored, blobfa4c14cb923c== HEAD.if (unitField === undefined || unitField !== undefined) continue;): 17 failed / 6 passed (every refusal pin on both strategies, the cube face, the inferred cube and the draft preview); restored, blobdad0d024e94b== HEAD.Acceptance notes
DATASET_INVALIDcompile guards (measure-currency-coherence.ts) judge a measure'scurrencykey and derived measures across currencies; a dataset that declares an ungroupedsumover a record-mode amount compiles, and the refusal rides each query selection through the cube door. Units mirror that: a dataset measure over a record-mode quantity compiles, and every selection that does not group by the unit field is refusedINVALID_FIELD. A dataset measure has nounitkey, so guard 1 has no unit twin. A derived measure combining a record-mode quantity with another quantity is not a raw aggregate and is not judged here (no ruling covers it).unitField. The object door refuses a dottedunitField, so no quantity follows a parent's unit and this door has no path arm (the currency door'sMASTER_DETAIL.CODEarm has no twin).record-mode quantity (grep ofunitMode: 'record'repo-wide: no aggregate,summaryor dataset measure over one outside this PR's own tests). Noexamples/**,packages/**/fixturesorpackages/**/__fixtures__file declaresunitConfig, so no example build is broken by the refusal.unitConfigis not in any released CHANGELOG (packages/spec/CHANGELOG.mdandpackages/objectql/CHANGELOG.mdat 18.6.0 carry nounitConfig; its changeset35489-unit-config.mdis pending), so the refusal narrows nothing published:Metadata-protocol: none. The one published-surface change is the optionalsourceFieldMetakey above, soClause-②: yes (widening).unitFieldon the wire, measured. A throwaway probe inpackages/rest(not committed) threw each door's real error into the real REST writers./data(mapDataError): 400, body keyserror,code,field,object; the INVALID_FIELD arm copiesfieldandobjectonly (packages/types/src/data-error-classification.tslines 1308 and 1309).POST /analytics/dataset/query: 400, body keyscode,message; the declared-4xx arm writescode,messageand an optionaluserMessageonly (packages/rest/src/analytics-routes.tsline 926). The same holds for the currency twin'smember,fieldandobjecton the analytics door.Verification
Suites, typecheck and gate readings at head
f01bd3db4e, onorigin/main8145424b53. Head948f998319adds a changeset-only commit (the widening declaration), re-checked below. Changed lines: 1043 (+1032 / -11, 11 files), measured bydispatch-gates.Suites and typecheck
pnpm --filter @objectstack/objectql test: Test Files 625 passed (625), Tests 14223 passed (14223); exit 0.pnpm --filter @objectstack/service-analytics test: Test Files 222 passed (222), Tests 5674 passed, 345 skipped (6019); exit 0.pnpm --filter @objectstack/objectql run typecheck(tsc pluscheck:test-typecheck, OK, debt unchanged) andpnpm --filter @objectstack/service-analytics run typecheck: lock VERDICT command-exit 0. Both new test files are in the compiled program (--listFiles).pnpm lintis CI's).Derived gate families
node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack: 84 families, each run with its exit captured before any pipe. 83 exit 0 on the first pass;check:dual-build-cjs-loadsexited 3 (PREREQUISITE NOT MET, no workspace dist). Afterturbo run build --filter='./packages/**'(81/81 tasks), its re-run exits 0: 124 entry points across 72 packages load.--ranreconciliation over the re-run record: "84 derived, 84 run, 0 NOT-MEASURED, 0 UNRUN".948f998319:node scripts/check-changeset-no-major.mjs --base origin/main --event(this body as the payload): exit 0, "clause-②yes (widening)and metadata-protocolnone… a non-protocol change atpatch";check-empty-changesetandcheck-adr-0087-registrationexit 0.pnpm check:adr-anchors: exit 0 with the two new anchors.CI carries the full farm,
test:repo(Test Core) and the dogfood battery (no!in the title and no(narrowing)arm, so no local full dogfood run is owed).Human Minimum
packages/specholds no runtime logic.pnpm lintpasses (CI).main, one pull request.packages/specnot touched.content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.🤖 Generated with Claude Code
https://claude.ai/code/session_01L9qibvMi1U7R2kBd3JbTPu