Repository navigation
Commit 031a19d
docs(adr): ADR-0160 amended a fifth and a sixth time; the Data API sort door reads the sortability projection's computed-type predicate (objectstack-ai#37785)
<!-- claude-projects-attribution: {"github_login":"os-elon-musk"} -->
_Requested by **Elon** · [project
thread](https://claude.ai/code/project/chan_01WedDzV26nniwxv7jC88B9D?thread=cmsg_01WedDzV26nniwxv7jC88B9DLCo5F2y7fgbM8tstGoyyUn)_
Fixes objectstack-ai#37386
Refs objectstack-ai#37486
Clause-②: no
Metadata-protocol: none
## 维护者速读
-
用户无感:这次做三件事,一是把架构记录里几处已经上线、文字却没跟上的细节补齐,二是让数据接口和列表的排序提示在「哪类字段没法排序」上读同一份判断,三是按你在另一张决策卡上选定的方案,把「确有资料被隐藏时才提示」这条约定先写进架构记录;今天每个请求的结果都和原来一样。
- 为什么做:属于「记录范围的 AI
问询」专题的收尾;记录停在旧说法,后面施工和审阅的人会按过时的约定做事,而两份各管各的判断,以后新增一种计算字段时就会对不上。
-
出错会怎样:最坏是某种字段的排序被数据接口错拒或错放,调用接口的开发者会看到排序报错;新写进记录的那条约定要等后续的修复合入才生效,知道资料包里列了哪些对象的人看到提示就能确定确有其物,这正是你选定的取舍;撤回这一次合并就恢复原状。
- 要你做什么:这是受管的架构记录修订,需要你审阅批准后才能合并。
## What changes
Four files, +170 / −48, in three parts: two under this card, and one
sentence for the card the `Refs` line names.
**1. ADR-0160, fifth amendment** —
`docs/adr/0160-record-scoped-ai-inquiry.md` (+12 / −6 of the file's +17
/ −7). The amendment writes down what `main` does in the places the card
lists, and says in words that it rests on no ruling of its own. Every
sentence was read against the tree on `main` at `7e638ba7`. The
behaviours marked *measured* were run through the executor and the input
schema in a throwaway probe that was deleted and never committed.
- **Status line and amendment log.** The status line names the third
amendment date. The `Amended` list gains a fifth entry that names this
card, PR objectstack-ai#37354 (which built row 11) and the review record of the fourth
amendment's PR (7194836142, nits N1–N3), then the four things recorded.
- **D1, "Author defects are reported on author surfaces" (card item 1,
N6).** One new sentence group: an `orderBy` that names a field the child
has and does not offer as a sort is an author defect. It names the
projection that answers the question (`resolveObjectSortability`), what
that is on `main` today (a `formula` field, or a field whose author
declared `sortable: false`), the rule id
`ai-context-sort-field-unsortable` with its symbol anchor, and why the
tool judges the field before the query: both MCP doors refuse an order
by such a field with `INVALID_SORT`, which would refuse the whole call.
- **Point 20** gains an in-place note, in the form the record already
uses for a settlement: where the judgement sits (after a field the
definition lacks, before the caller's own fields, so every caller gets
one answer), that PR objectstack-ai#37354 settled it, and the two alternatives not
taken.
- **D4 "Definition", the input row (card item 3 and N1).** "with the
record tools' aliases for the first two" is replaced by what the schema
holds: seven aliases (`object` and `table` for `objectName`; `id` and
`record_id` for `recordId`; `pack` and `contextName` for `context`;
`section` for `anchor`). The row now also says what an alias is: it is
**not accepted**. The input is strict, so a call that uses one is
refused at parse like any unknown key, and the refusal names the
declared key (*measured* for each of the seven). `outlineFrom` is stated
as an integer, 0 or more (*measured*: `-1` and `1.5` refused at parse,
`0` accepted).
- **D3 "Outline pages", "A page that does not exist" (N3).** The reasons
behind the one `RESOURCE_NOT_FOUND` gain: a pack whose `body` names a
field that is not a long-text field, or that the root does not have
(*measured*: both get the same 404 as a position past the end).
- **Point 24 (N2)** names its one exception: a heading whose entry alone
passes the body bound is listed on no page and issued no anchor, and the
cut statement counts it. A body whose headings are all that long has no
outline to cut (*measured*).
Nothing else in the record changes under the fifth amendment.
**2. The Data API's sort door reads the projection's predicate (card
item 2, N7)** —
`packages/metadata-protocol/src/protocol-query-validation.ts` (+21 /
−41), one new test file (+118), one changeset (+14).
- The third verdict of `assertSortFieldsExist` (a real field whose type
has no column to order by) judged the type by a module-local set,
`UNMATERIALIZED_SORT_TYPES`, `formula` alone. It now calls
`isVirtualSearchField` from `@objectstack/spec/data`: the predicate
`resolveObjectSortability` reads for `reason: 'virtual-type'`, and the
one this file's filter and search axes already read. The local set and
its docblock are removed; a comment at the call site says where the one
source is and why it is the storage fact and not the write contract
(`COMPUTED_VALUE_TYPES`).
- No file under `packages/spec/src/**` is edited. Nothing changes for a
caller today: both sets held `formula` and nothing else.
- What changes is the day a computed type is added: it is added in the
spec's `SEARCH_VIRTUAL_TYPES`, and the door, the projection, the list
header and the Sort picker follow together.
- `protocol.sort-door-projection-agreement-37386.test.ts` copies no
verdict table. For every member of the spec's `FieldType` it asks the
projection and holds the door to that answer (99 cases).
- Changeset `37386-sort-door-reads-projection-predicate.md`:
`@objectstack/metadata-protocol` patch.
**3. ADR-0160, sixth amendment** — the same file (+5 / −1, commit
`06b567e5`). It rests on the maintainer's ruling recorded in comment
7208943876 on the card the `Refs` line names (option B of decision
analysis 7207825366), and it comes before the code: the PR that builds
it stays a draft at `cb1a47e9` until this text is accepted.
- **D3 "Object level", the bullet "A `related` child that this caller is
not served is left out."** The sentence "Nothing of the child is read,
its definition included." is replaced by:
> Nothing of the child is read except its published definition, which is
asked once, for whether the stack defines the object at all (sixth
amendment, 2026-11-27): a name the published definitions lack is an
author defect ([D1](#d1)), left out with no statement for every caller.
The published definition is the same for every caller, so whether the
statement fires depends on this caller's served schema alone, and
nothing of the definition is carried. The statement therefore now means
that something the stack defines is hidden from this caller, so a caller
who knows the pack's names can infer that such an object exists. That is
the trade the field-level rule below already makes for fields, where the
statement fires only for an entry the published definition has.
The first two sentences are the draft in os-dev report 7207298690. The
last two name the signal in plain words, as execution item 1 of the
ruling asks.
- **Amendment log.** A sixth `Amended` entry quotes the ruled option
verbatim, names the building PR and its head, says that the text comes
before the code and what `main` does until then, and records the two
things above. It also says the record tools are not changed: a name the
caller typed is still answered alike whether the object is hidden or
does not exist.
- The fifth entry still says it rests on no ruling of its own; that
stays true of the fifth. Every other sentence of the record stands.
## Tests
Head `06b567e5`. Its one commit after `40e60883` edits the ADR alone, so
the package's source and tests are byte-identical to `40e60883`, where
the commands below ran. Every heavy command ran under the shared verify
lock; the result quoted is the lock's own `VERDICT command-exit` line.
- Dependency closure: `pnpm --workspace-concurrency=2 --filter
'@objectstack/metadata-protocol^...' build` → `VERDICT command-exit 0`.
- The new file, on `40e60883`: `pnpm --filter
@objectstack/metadata-protocol exec vitest run --maxWorkers=2
src/protocol.sort-door-projection-agreement-37386.test.ts` → `Test Files
1 passed (1)`, `Tests 99 passed (99)`, `VERDICT command-exit 0`.
- The package, on `40e60883`: `pnpm --filter
@objectstack/metadata-protocol test` → `Test Files 372 passed | 9
skipped (381)`, `Tests 23549 passed | 45 skipped (23594)`, `VERDICT
command-exit 0`.
- `pnpm --filter @objectstack/metadata-protocol typecheck`, on
`40e60883` → `VERDICT command-exit 0`. The package's `tsc --noEmit
--listFiles` lists the new test file, so the typecheck covers it.
**Ablation** (the fix committed first; `scripts/ablation-replace.mjs`;
each restore proved by blob equal to `HEAD` and an empty `git diff
HEAD`). Both were taken on the door at `70e73548`; the commits after it
leave the door byte-identical and add one side-effect import and no case
to the test file.
- **A, the door's set grows alone** (the filter replaced by a local set
holding `formula`, `summary` and a marker) → `Tests 2 failed | 97 passed
(99)`: both `summary` rows. The grid would offer that sort and the Data
API would refuse it.
- **B, the spec's set grows alone** (the filter replaced by a local set
that lacks `formula`) → `Tests 1 failed | 98 passed (99)`: the `formula`
row of the second table. The solo row stays green there, because the
door's fourth verdict still refuses the sort with the same code and
status; only the fields the refusal names tell the two verdicts apart.
That is why the second table sorts by the field under test and by a
companion that declares `sortable: false`.
## Acceptance notes
- **"D1 names the unsortable-orderBy defect and its rule id. The
amendment log cites this card."** D1's new sentences and the fifth
`Amended` entry.
- **"Exactly one source answers whether a field type is computed for
sorting. The door and the projection both read it, and a test pins that
they agree."** `isVirtualSearchField` is that source for the Data API
door and the projection; the test above pins it for every `FieldType`.
The card names `protocol-data-crud.ts` as the door's file; the claim
corrects that to `protocol-query-validation.ts`, which is where the set
was.
- **"D4's alias sentence matches the schema's aliases on `main`. N1–N3
of record 7194836142 are closed in the same ADR-0160 text."** The D4
row, the D3 list and point 24, as above.
- **Where the text says more than the card's words, on purpose.**
- The card says to state what the schema "admits". The schema does not
admit an alias: `strictObject`'s `aliases` are spellings it refuses by
name. The row says so, since "with the record tools' aliases" read as if
a caller could write them.
- N3 as written covers a `body` field with a non-body type. A `body`
naming a field the root does not have takes the same branch and gets the
same answer, so the clause names both.
- Point 24 also says what happens when every heading is too long, from
the remark under N2.
- The status line's date and the note on point 20 follow the record's
own convention for an amendment and a settlement.
- **The D3 "Object level" sentence: three commits.** `88fa54ae` added
the draft sentence the dispatch order first carried; the PM withdrew it
before this PR opened, because it waited for a maintainer ruling, and
`e2e6a626` reverts it. The ruling came (comment 7208943876, option B),
and `06b567e5` adds the sentence again, now with the two sentences that
name the signal and with a sixth amendment-log entry of its own. The
sentence describes behaviour that is not on `main` yet; the log entry
says so.
- **Not touched by the sixth amendment, on purpose.** D3 "Objects first"
still quotes the record tools' `judgeRelatedLists` docblock ("nothing
about a refused object is read, its definition included"): that is the
record tools' order, which the ruling leaves alone. Context, "What a
refusal names", is unchanged for the same reason.
- **One test-file commit after the first gate run.** `pnpm
check:test-source-alias` named the new test file: it reaches
`@objectstack/lint` through a dynamic import and did not load it at
module scope. `40e60883` adds the module-top side-effect import its
siblings in the package carry. No case changes.
- **Not changed, and why** (each `carrier: none`):
- The engine's own door, `assertOrderByIsMaterializable` in
`packages/objectql`, still spells the literal `formula`. The card names
the HTTP door and the projection; a third reader is outside the claimed
file surface.
- Six comments in four files outside this card's surface still mention
the retired name `UNMATERIALIZED_SORT_TYPES` (two in
`packages/drivers/driver-sql`, two in `packages/lint`, two in
`ui/packages/plugin-list` tests). The door's new comment keeps the
retired name so a search for it lands on the call site.
- The removed docblock said `fieldHasColumn` answers "has a column" for
a `multiple` formula. On `main` that helper reads `isMultiValueField`,
which is false for `formula`, so that paragraph was already stale and is
not carried over.
- One edge the predicate reads differently: a field whose `type` is not
a string but stringifies to `formula` was refused by the old
`String(...)` comparison and is not by `isVirtualSearchField`. No
schema-valid definition holds such a field.
- **Tier H by path.** `docs/adr/**` is governed, so the whole PR is Tier
H and stays a draft. The `Rule-change:` line is left out: the diff does
not touch `.claude/**`.
## Verification
**Read first** (by risk):
1. `docs/adr/0160-record-scoped-ai-inquiry.md`, D3 "Object level": the
replaced sentence moves a visibility boundary by a maintainer ruling,
and its last two sentences state what a caller can now infer.
2. The same file, the D4 input row: "An alias is not accepted" corrects
what the record said rather than adding to it.
3. `packages/metadata-protocol/src/protocol-query-validation.ts`, the
one-line filter in `assertSortFieldsExist`.
**Two-minute verification**: `pnpm --filter
@objectstack/metadata-protocol exec vitest run --maxWorkers=2
src/protocol.sort-door-projection-agreement-37386.test.ts` — expected
`Tests 99 passed (99)`.
**Gates, patch round (`06b567e5`).** The commit edits one file, so the
families rerun are the ones that read it: `node
scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack docs/adr/0160-record-scoped-ai-inquiry.md` →
21 commands, all exit 0 on `06b567e5`, each exit code captured before
any pipe. This is a declared narrowing: the other 52 families of the
full list read files that are byte-identical to `40e60883`, and CI runs
the whole farm on the new head.
- `--ran` reconciliation against that derivation: `✓ dispatch-gates
--ran: 21 derived famil(ies) accounted for — 21 run, 0 NOT-MEASURED (a
DERIVED zero — all 21 recorded an exit code and none of them is 3).`
- `pnpm check:issue-citations` (outside that derivation; the new entry
cites a card): exit 0.
- `dispatch-gates --tier`: changed lines 218 (+170 / −48) against the
human-merge threshold 3000: under.
- `overlap-check --branch=claude/area-o1B-37386` before the push:
`VERDICT clean exit 0` at `06b567e546` against `origin/main` at
`6e8f663710` and 0 PR heads. `origin/main` was not merged in: no
conflict.
- The derivation printed a STALE TREE warning: the branch is at least 17
commits behind `origin/main`, and 2 files the derivation reads changed
in that range.
<details><summary>Patch-round gates (21 commands on 06b567e, exit code
beside each)</summary>
```text
exit 0 · 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
```
</details>
**Gates, full union (`40e60883`).** The list is `node
scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` on `40e60883` (no paths; the script takes
the change set from the merge base): 73 commands. Each ran on `40e60883`
with its exit code captured before any pipe.
- 72 exited 0. One exited 3: `node
scripts/check-plugin-teardown-shape.mjs --self-test`, PREREQUISITE NOT
MET, so NOT MEASURED. Its positive control is pinned to a commit a
shallow clone cannot read, and the remedy it names is to unshallow the
clone every worktree in this container shares, which was not done; CI
runs it on a full checkout.
- The same list on the earlier head `e2e6a626`: one red, `pnpm
check:test-source-alias`, naming the new test file (repaired by
`40e60883`, above); and two more exit-3 refusals for built output not on
disk (`check:dual-build-cjs-loads`, `check:lean-entry-closure`). Both
measured green on `40e60883`, after `check:type-check-debt` in the same
list had built the packages under the verify lock.
- `--ran` reconciliation on `40e60883`: `✓ dispatch-gates --ran: 73
derived famil(ies) accounted for — 72 run, 1 NOT-MEASURED (1 DERIVED
from a recorded exit 3).`
- `dispatch-gates --tier` at `40e60883`: `docs/adr/**` is the mandatory
contract tier; changed lines 212 (+165 / −47) against the human-merge
threshold 3000: under.
- `overlap-check --branch=claude/area-o1B-37386` before each push:
`VERDICT clean exit 0`, the last one at `40e60883` against `origin/main`
at `8b9b9d2355` and 0 PR heads.
- CI-owned families (type-check lanes, the repo-wide lint, `Test Core`,
the changeset check, the always-runs tail) are this PR's check-runs;
they had not reported when this body was written.
<details><summary>Not measured locally (1), each with its own refusal
text</summary>
```text
✗ check-plugin-teardown-shape self-test: cannot read the positive control at 621a487.
The fixture is pinned to a commit rather than to an editable copy, so a checkout
that cannot reach it cannot run this battery. Deepen the clone:
git fetch --unshallow origin main
✗ check-plugin-teardown-shape self-test: selfTest() returned without reaching its verdict,
so no success line was printed. Exiting 0 here would report a self-test
that never finished as a self-test that passed.
```
</details>
<details><summary>Local gates (73 commands on 40e6088, exit code beside
each)</summary>
```text
exit 0 · node scripts/check-adr-0087-registration.mjs --base origin/main
exit 0 · node scripts/check-adr-0087-registration.mjs --self-test
exit 0 · node scripts/check-adr-links.mjs
exit 0 · node scripts/check-adr-links.mjs --self-test
exit 0 · node scripts/check-changeset-no-major.mjs --base origin/main
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-adoption.mjs
exit 0 · node scripts/check-comment-mask-adoption.mjs --self-test
exit 0 · node scripts/check-comment-mask-corpus.mjs
exit 0 · node scripts/check-dts-emitted.mjs --self-test
exit 0 · node scripts/check-empty-changeset.mjs --base origin/main
exit 0 · node scripts/check-empty-changeset.mjs --self-test
exit 0 · node scripts/check-issue-citations.mjs
exit 0 · node scripts/check-plugin-teardown-shape.mjs
exit 3 · node scripts/check-plugin-teardown-shape.mjs --self-test
exit 0 · node scripts/ci/assert-turbo-remote-cache.mjs --self-test
exit 0 · node scripts/ci/plan-test-core-shards.mjs --self-test
exit 0 · node scripts/ci/prune-turbo-cache.mjs --self-test
exit 0 · node scripts/ci/snapshot-next.mjs --self-test
exit 0 · node scripts/docs-audit/check-affected-docs.mjs
exit 0 · node scripts/docs-audit/check-drift-comment.mjs
exit 0 · node scripts/pm/check-governed-queue-guard.mjs --self-test
exit 0 · node scripts/pm/release-rehearsal-clone.mjs --self-test
exit 0 · node scripts/release-pending-publish.mjs --self-test
exit 0 · pnpm --filter @objectstack/lint run check:doc-formula-expressions
exit 0 · pnpm --filter @objectstack/spec run check:duration-unit-keys
exit 0 · pnpm --filter @objectstack/spec run check:error-code-provenance
exit 0 · pnpm check:adr-anchors
exit 0 · pnpm check:adr-index
exit 0 · pnpm check:adr-symbol-anchors
exit 0 · pnpm check:changeset-gate-self-tests
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:dispatcher-error-vocabulary
exit 0 · pnpm check:doc-authoring
exit 0 · pnpm check:driver-memory-census
exit 0 · pnpm check:dts-closure
exit 0 · pnpm check:dual-build-cjs-loads
exit 0 · pnpm check:durability-log-level
exit 0 · pnpm check:engine-double-contract
exit 0 · pnpm check:error-status-conformance
exit 0 · pnpm check:gitlink-declared
exit 0 · pnpm check:issue-citations
exit 0 · pnpm check:keyed-text-bounds
exit 0 · pnpm check:lean-entry-closure
exit 0 · pnpm check:logger-receiver-detach
exit 0 · pnpm check:nul-bytes
exit 0 · pnpm check:object-def-param-keys
exit 0 · pnpm check:objectql-double-limit
exit 0 · pnpm check:optional-error-sink
exit 0 · pnpm check:org-identifier
exit 0 · pnpm check:page-declaration-shape
exit 0 · pnpm check:platform-object-tenancy-census
exit 0 · pnpm check:pm-governed-merges
exit 0 · pnpm check:pm-prior-rulings
exit 0 · pnpm check:published-files
exit 0 · pnpm check:query-options-erasure
exit 0 · pnpm check:refd-timer-probe
exit 0 · pnpm check:registry-log-declared
exit 0 · pnpm check:rest-log-spy-declared
exit 0 · pnpm check:slot-lookup
exit 0 · pnpm check:sourcemap-no-sources-content
exit 0 · pnpm check:system-context-census
exit 0 · pnpm check:test-source-alias
exit 0 · pnpm check:tier-file-adoption
exit 0 · pnpm check:type-check-coverage
exit 0 · pnpm check:type-check-debt
exit 0 · pnpm check:undeclared-dep-imports
exit 0 · pnpm check:vouch-for-reference-callers
exit 0 · pnpm check:watch-hint-literal
exit 0 · pnpm check:where-matcher
```
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_016WV4cxBECSPtHxQMZDHSie)_
<!-- signed: repo:objectstack#1 · os-elon-musk ·
session_016WV4cxBECSPtHxQMZDHSie -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 4b8aca2 commit 031a19d
4 files changed
Lines changed: 170 additions & 48 deletions
File tree
- .changeset
- docs/adr
- packages/metadata-protocol/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
0 commit comments