Skip to content

Commit 0c45d66

Browse files
feat(plugin-audit,spec,client): one read returns the comment threads on the records a list filter selects, as the caller (#39135)
<!-- claude-projects-attribution: {"github_login":"os-support-ai"} --> _Requested by **Yibo Wang** · [project thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBRcN813GZAexn3xsDCyu5rG)_ Fixes #39084 Clause-②: yes (widening) Metadata-protocol: added Skills-docs: none — the added keys are the request and response shape of one built-in REST read on the api shard, not anything a metadata author writes in an object, view or app, so no authoring skill teaches them; the read is documented in content/docs/api/data-api.mdx and the generated reference page, and the list-page UI card (U3) is its consumer ## 维护者速读 - 用户看到什么:列表页评论栏可以一次请求拿到「当前视图里这些记录上的评论串」,按看的人的权限过滤,最新在前,带记录名、回复数和最近三位回复人,可翻页。 - 为什么:专题 #39077 的 S3,列表页评论栏(U3)要用;视图再大也一次算对,不用一条条记录去读。 - 出错会怎样:只按调用者权限读,读不到的记录不出现;筛选不合法或没权限会直接报错,不会给出残缺结果。 - 要你做什么:无。托管部署(调度器)上暂不提供这个读取口,已另立 #39134。 ## What changes - **`@objectstack/spec`** — `packages/spec/src/api/comment-threads.zod.ts`: strict `CommentThreadsQueryRequestSchema` (`object`, `filter` in the `GET /data/{object}` syntax, `showResolved`, `onlyMine`, `limit` 1..`COMMENT_THREADS_MAX_LIMIT`, opaque keyset `cursor`) and `CommentThreadsQueryResponseSchema` (`threads[]` of `{ comment, record: { id, name }, replyCount, repliers[≤3] }`, `nextCursor`), limits as exported constants. Generated artifacts regenerated (see Verification). - **`@objectstack/plugin-audit`** — new `comment-threads-query.ts` serves `POST /api/v1/comments/threads/query` from `registerCommentDoorsRoutes`, steps 1–6 of the epic's §5, **every read as the caller**: 1. caller resolution; anonymous 401; held sign-in 403; 2. no query parameter, strict body, a cursor this read issued, a filter `parseFilterAST` takes — else `400 VALIDATION_ERROR` before the engine is asked anything; 3. object registered, served by the data door for `get`, not `sys_comment`, `enable.feeds !== false` (else `403 FEEDS_DISABLED`); 4. `ObjectQL#planReadScope(sys_comment, object, { where: filter, context })`, **planned per request and never cached** (two-user pin), its refusals are the answer (`PERMISSION_DENIED`, `INVALID_FILTER` on MongoDB/OData); 5. ONE `find` on `sys_comment`: object, scope, top-level, unresolved unless `showResolved`, `participants $contains caller` when `onlyMine`, keyset after the cursor, newest first by `(created_at, id)`, `limit + 1`; the comment read gate ANDs its condition as on any read; 6. the page's replies (author columns and parent pointer only, keyset-paged, as the caller) for reply count at any depth and the latest three distinct repliers, and one read of the object for the page's record display names (ADR-0079). - Ledger row `POST /api/v1/comments/threads/query` → `sdk`, `comments.queryThreads`; conformance test updated. - **`@objectstack/client`** — `client.comments.queryThreads`; the URL-conformance sweep now reads the comment route ledger (so `turbo.json` and `scripts/cross-package-test-inputs.mjs` declare it as a client test input). - **`@objectstack/objectql`** — exports the `PlanReadScopeOptions` and `ReadScopeComparand` types (N3 of 7341533575). - Docs: a section in `content/docs/api/data-api.mdx`; `packages/spec/llms.txt` counts; a changeset: `minor` on `@objectstack/spec` (`Metadata-protocol: added`, because the new schemas enter the `api` authorable-surface shard, the precedent of #38999), `patch` on objectql, plugin-audit and client. The claim said `none`; the Check Changeset gate on cb3695e read the shard as added keys, and commit fb20c06 corrects the declaration. ## Why Epic #39077 S3 (rulings 7338398195: a dedicated read; "current view" = saved filter + temporary filters, the search box not counted). The list page's comment panel (U3) needs the threads of the view's records in one request, correct on a view of any size, with the same refusals a list read gives and no new read authority. ## Acceptance notes Where each card bullet is pinned (HTTP = `packages/qa/dogfood/test/comment-threads-query.dogfood.test.ts`, booted stack with the real SecurityPlugin; engine = `comment-threads-query.integration.test.ts` and the dogfood file's engine cells): - 3 of 5 records selected → only their top-level open threads, newest first, record id + name, reply count, ≤3 latest repliers: HTTP test 1, engine. - A member who cannot read one of the 3 → its threads omitted; no read on the object → that read's own refusal: HTTP test 2, engine cells on SQLite and PostgreSQL. - `showResolved` / `onlyMine`: HTTP tests 3 and 4, engine. - `limit` + `cursor` walk every thread once while a comment is posted between pages: HTTP test 5, plus an engine test with a `created_at` tie. - Unknown key, any query parameter, `limit` out of range → `400 VALIDATION_ERROR` and the engine never called (spy): HTTP test 6. Filter on an unreadable field → `PERMISSION_DENIED`: HTTP test 7. Feeds off → 403; anonymous → 401: HTTP test 8. - A view larger than the id cap answered in full with ONE threads statement carrying the planned read: HTTP test 9 on SQLite (1,005 records, driver statement log), and engine cells on SQLite and PostgreSQL. - No new error code: `ERROR_CODE_LEDGER` diff is empty. - **Two-user per-request pin** (7343013270): unit test "two users through one door" and the engine cells (`planReadScope` call order BOB, ALICE, BOB, ALICE). Ablation: caching the planned scope in a module-level `??=` turns the unit test red. Deviations and notes: - **Self-hosted only.** The read is mounted where the comment registrar mounts (`http.server`); the hosted dispatcher's `/comments` domain does not claim it, and the boot log says so. Seat ruling on hand-back; follow-up **#39134** serves it on the hosted kernel. "Advertised wherever the comment doors are advertised and nowhere it is not mounted" holds: `packages/runtime/src/domains/comments.ts` is untouched. - **HTTP fixture:** the dogfood file uses its own inline stack rather than the showcase, because the acceptance needs a row-scoped persona, a persona with an unreadable field and one with no read on the object, which the showcase's fallback permission set makes impossible. - **Reply counts** come from the page's replies read as the caller (keyset-paged, author columns only), not a grouped count by `parent_id`: a count "at any depth" needs each reply's thread root, which a grouped count over `parent_id` does not give for nested replies. - **Not measured:** whether `sys_comment` wants an index leading with `(object_name, created_at)` for this read — no plan was read on PostgreSQL or SQLite, and `sys-comment.object.ts` is outside this card's claim. - **PostgreSQL** (N5 of 7341533575): the PG cells run where `OS_TEST_POSTGRES_URL` is set; no CI job provisions it, so they are **not measured in CI**. Local run on PostgreSQL 16.15 (`/usr/lib/postgresql/16/bin`, throwaway server on 127.0.0.1:54391) at head c4d4266: `OS_TEST_POSTGRES_URL=… pnpm --filter @objectstack/dogfood exec vitest run test/comment-threads-query.dogfood.test.ts` → 17 passed (17), including 4 live-postgres tests. - Claim 7343360143, amendment 7346184382 (llms.txt, the two test-input declarations, generator outputs). ## Verification - `@objectstack/plugin-audit` 118 files / 1944 tests passed; `@objectstack/client` 60 / 841; `@objectstack/objectql` 646 / 14685; `@objectstack/spec` 922 / 29119 (1 todo); the dogfood file 17 / 17 with PG. New suites: `comment-threads-query.test.ts` (19), `comment-threads-query.integration.test.ts` (7), `comment-threads.test.ts` (9), ledger conformance (+1), client URL conformance (+2). - **L2 rounds** (records on this PR): r1 FAIL on fb20c06 (M1: a filter array the list read cannot lower was dropped, answering every readable record; S1: a decodable cursor with no instant reached the engine). r2 PASS on 7b0b230 with S1 open for placeholders. r3 PASS on 809a6e1, no must-fix and no should-fix. The fixes: `lowerThreadsFilter` refuses such a filter `INVALID_FILTER` / 400 as `GET /data/{object}` does, and the cursor decoder accepts only what the encoder writes. After them, `comment-threads-query.test.ts` has 21 tests and the integration file 7, 28 of 28 passing. Ablation against the previous source fails the new cases. Typecheck and eslint are clean. Nits N1 (a stored thread root, so reply counts need no in-app walk) and N2 (the microsecond keyset edge on PostgreSQL) are filed as follow-up **#39142** (Part of #39077, p2, area:data), per seat amendment 7347081374. r4 PASS on 750a1ea accepts the one ui file below. - **`ui/scripts/check-spec-symbol-derivation.mjs`** (seat amendment 7347081374): the new spec export `CommentThread` collides with `@object-ui/collaboration`'s published React component `CommentThread`. The two are different layers, so the fix is one ALLOW entry with its reason, as `EmptyState` has; the seat ruled ALLOW over a rename. The guard passes, and its 8 test files pass 195 of 195. A UI consumer (U3) imports the spec type under an alias. - Typecheck passes for spec, plugin-audit, client, objectql and dogfood; ESLint `--max-warnings=0` over the changed sources passes. - `node scripts/pm/dispatch-gates.mjs --ran`: 127 of 127 derived families run. `check:llms-txt` and `check:cross-package-test-inputs` were red until the amendment commit and pass on this head. <details><summary>Generated outputs (written by the generators, never by hand)</summary> `packages/spec/authorable-surface/api.json`, `declaration-map/api.json`, `api-surface/api.json`, `export-origins/api.json`, `json-schema.manifest/api.json`, `packages/spec/docs/references/api/comment-threads.md` (the generator's path; the claim named `content/docs/references/api/`), `packages/spec/docs/references/README.md`, `packages/spec/docs/references/api/README.md`, `content/docs/references/index.mdx`, `docs/audits/2026-07-unknown-key-strictness-ledger.counts/api.md`. </details> ## Human Minimum - [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic. - [x] 2. Every name I added uses the casing for its kind. - [x] 3. No formatter ran; `pnpm lint` passes (eslint on changed files). - [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. - [x] 6. `packages/spec` touched: its generated artifacts are regenerated and committed. - [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 维护者速读 block is the allowed Chinese channel). - [x] The *Before Submitting* list in CONTRIBUTING.md is done. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01WGufzfHCzQWh6PeQnvToFz <!-- signed: repo:objectstack@os-support-ai · os-support-ai · session_01WGufzfHCzQWh6PeQnvToFz --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 491ea82 commit 0c45d66

32 files changed

Lines changed: 2573 additions & 19 deletions
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
'@objectstack/spec': minor
3+
'@objectstack/objectql': patch
4+
'@objectstack/plugin-audit': patch
5+
'@objectstack/client': patch
6+
---
7+
8+
feat(plugin-audit,spec,client): one read returns the comment threads on the records a list filter selects, as the caller
9+
10+
Clause-②: yes (widening)
11+
Metadata-protocol: added
12+
13+
Widened: a new route, `POST /api/v1/comments/threads/query`, mounted by plugin-audit's comment registrar beside the resolution and own-comment delete doors. The body (`CommentThreadsQueryRequestSchema`, strict) names an object and carries a list's filter in the `GET /data/{object}` syntax, with `showResolved`, `onlyMine`, `limit` (1 to `COMMENT_THREADS_MAX_LIMIT`, default `COMMENT_THREADS_DEFAULT_LIMIT`) and an opaque keyset `cursor`; the answer (`CommentThreadsQueryResponseSchema`) is one page of the object's top-level comments on the records the filter selects and the caller may read, newest first, each with its record's id and display name, its reply count at any depth and its latest three distinct repliers, and the next page's cursor. Every step runs as the caller: the engine plans the caller's read of the object with the filter (`ObjectQL#planReadScope`) and places it in the comment read as one subquery, so a view past the 1,000-id cap is answered in full; its refusals are the answer (`PERMISSION_DENIED` for a caller with no read on the object or a filter on a field the caller cannot read, `INVALID_FILTER` on MongoDB and OData). A query parameter, an unknown body key, a `limit` out of range or a cursor the read did not issue is `400 VALIDATION_ERROR` before anything is read, and a filter the list read cannot lower is `400 INVALID_FILTER`, as `GET /data/{object}` answers it, never dropped; an object with `enable.feeds: false` is `403 FEEDS_DISABLED`. The read is served on a kernel with an HTTP server; the hosted dispatcher's `/comments` domain does not claim it. `client.comments.queryThreads` is its SDK method. `@objectstack/objectql` exports the `PlanReadScopeOptions` and `ReadScopeComparand` types. No new error code. `Metadata-protocol: added`: the request and response schemas enter the `api` authorable-surface shard, which the level axis reads as added keys, so `@objectstack/spec` is a `minor`; nothing an author writes in an object, view or app definition changes.

‎content/docs/api/data-api.mdx‎

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,84 @@ the approvals-family read and is unchanged.
682682

683683
---
684684

685+
## Comment threads
686+
687+
The discussions on the records a list shows, in one read: what a list page's
688+
comment panel asks. Served by `@objectstack/plugin-audit` on a kernel with an
689+
HTTP server; the SDK method is `client.comments.queryThreads`.
690+
691+
### `POST /comments/threads/query`
692+
693+
The body (`CommentThreadsQueryRequestSchema`) names the object and carries the
694+
list's own filter, in the syntax `GET /data/:object` accepts: the saved view's
695+
filter AND the reader's temporary filters. A search box is not a filter and is
696+
not sent.
697+
698+
| Key | Meaning |
699+
| :--- | :--- |
700+
| `object` | The object whose records the list shows. Required; not `sys_comment`. |
701+
| `filter` | The list's filter. Absent: every record of the object the caller may read. |
702+
| `showResolved` | `true` answers resolved threads too. Absent: unresolved threads only. |
703+
| `onlyMine` | `true` answers only the threads the caller started, replied in or is mentioned in. |
704+
| `limit` | Threads per page, 1 to 50. Absent: 25. |
705+
| `cursor` | The previous page's `nextCursor`, as it was answered. Absent: the first page. |
706+
707+
The answer is one page of the object's top-level comments on the records the
708+
filter selects and the caller may read, newest first, and the cursor of the
709+
next page (`null` on the last):
710+
711+
```json
712+
{ "success": true, "data": {
713+
"threads": [{
714+
"comment": { "id": "cmt_9", "body": "Can we ship Friday?", "author_id": "usr_1", "is_resolved": false, "created_at": "2026-12-02T09:30:00.000Z" },
715+
"record": { "id": "acc_1", "name": "Acme" },
716+
"replyCount": 4,
717+
"repliers": [{ "id": "usr_2", "name": "Ben", "avatarUrl": null }]
718+
}],
719+
"nextCursor": "WyIyMDI2LTEyLTAy..."
720+
} }
721+
```
722+
723+
`replyCount` counts the replies under the thread at any depth; `repliers` are
724+
the latest distinct ones, newest first, at most three. `record.name` is the
725+
record's title field read as the caller (`Record #` and the id when it is
726+
empty or not served).
727+
728+
Every step runs as the caller. The records are the caller's own read of the
729+
object with the filter, planned by the engine and placed in the comment read
730+
as one subquery, so a view of any size is answered in full; where the engine
731+
cannot prove that read it reads the ids as the caller and refuses past its cap
732+
(`400 INVALID_FILTER`), never a part of the view. The comment read is an
733+
ordinary read of `sys_comment`, so the comment read gate decides as on
734+
`GET /data/sys_comment`. The cursor is a keyset over creation time and id: a
735+
comment posted while you page does not repeat or skip a thread.
736+
737+
Refusals:
738+
739+
- any query parameter, a body key outside the table, a `limit` out of range, a
740+
`cursor` the read did not issue, or `object: "sys_comment"`: `400 VALIDATION_ERROR`,
741+
before anything is read;
742+
- a filter the list read cannot lower (a filter array that is not a comparison,
743+
a prefix `["and"|"or", ...]` node or a list of those, an infix join, or a
744+
value that is neither a filter object nor a filter array): `400 INVALID_FILTER`,
745+
before anything is read, the answer `GET /data/{object}` gives the same value;
746+
`null` and `[]` are no filter;
747+
- no signed-in caller: `401 UNAUTHENTICATED`;
748+
- an unknown object: `404 OBJECT_NOT_FOUND`; an object the data door does not
749+
serve: the data door's own refusal; an object with `enable.feeds: false`:
750+
`403 FEEDS_DISABLED`;
751+
- a caller with no read on the object, or a filter naming a field the caller
752+
cannot read: `403 PERMISSION_DENIED`, the object read's own refusal, never an
753+
empty answer;
754+
- an object on a driver that cannot run the subquery (MongoDB, OData):
755+
`400 INVALID_FILTER`.
756+
757+
A kernel with no HTTP server (a hosted tenant kernel) serves the other comment
758+
doors through the dispatcher's `/comments` domain, which does not claim this
759+
read, so it is not served there.
760+
761+
---
762+
685763
## Analytics
686764

687765
Semantic BI queries using a cube-style API. Provided by `@objectstack/service-analytics` —

‎content/docs/references/index.mdx‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Protocol reference — every schema by module
33
navTitle: Protocol Reference
4-
description: Every schema published by @objectstack/spec — 1756 schemas across 14 protocol modules
4+
description: Every schema published by @objectstack/spec — 1761 schemas across 14 protocol modules
55
---
66

77
{/* ⚠️ AUTO-GENERATED — DO NOT EDIT. Run build-docs.ts to regenerate. Hand-written docs live in the module folders under content/docs/. */}
@@ -23,7 +23,7 @@ counts are sums of the rows they head. Regenerate with
2323
| Module | Pages | Schemas | Description |
2424
| :--- | ---: | ---: | :--- |
2525
| [AI Protocol](/docs/references/ai) | 18 | 108 | Agents, tools, skills, RAG and knowledge sources, model registry, conversations. |
26-
| [API Protocol](https://github.com/objectstack-ai/objectstack/tree/main/packages/spec/docs/references/api) | 38 | 534 | REST contracts, endpoints, routing, realtime, batch, discovery. |
26+
| [API Protocol](https://github.com/objectstack-ai/objectstack/tree/main/packages/spec/docs/references/api) | 39 | 539 | REST contracts, endpoints, routing, realtime, batch, discovery. |
2727
| [Automation Protocol](/docs/references/automation) | 16 | 82 | Flows and their nodes, approvals, ETL pipelines, webhooks, state machines, execution records. |
2828
| [Data Protocol](/docs/references/data) | 35 | 198 | Objects, fields, queries, filters, datasources and drivers — the ObjectQL layer. |
2929
| [Identity Protocol](https://github.com/objectstack-ai/objectstack/tree/main/packages/spec/docs/references/identity) | 5 | 27 | Users and accounts, organizations, positions, SCIM provisioning. |
@@ -36,7 +36,7 @@ counts are sums of the rows they head. Regenerate with
3636
| [Studio Protocol](https://github.com/objectstack-ai/objectstack/tree/main/packages/spec/docs/references/studio) | 3 | 35 | Studio designer metadata — the authoring surfaces for the protocols above. |
3737
| [System Protocol](https://github.com/objectstack-ai/objectstack/tree/main/packages/spec/docs/references/system) | 40 | 298 | The runtime environment — logging, jobs, cache, metrics, notifications, i18n and compliance. |
3838
| [UI Protocol](/docs/references/ui) | 17 | 188 | Apps, pages, views, dashboards, reports, actions and themes — the ObjectUI layer. |
39-
| **Total** | **225** | **1756** | 14 protocol modules |
39+
| **Total** | **226** | **1761** | 14 protocol modules |
4040

4141
---
4242

@@ -71,7 +71,7 @@ Agents, tools, skills, RAG and knowledge sources, model registry, conversations.
7171

7272
## API Protocol
7373

74-
**Source:** `packages/spec/src/api/` · **Import:** `@objectstack/spec/api` · **38 pages, 534 schemas**
74+
**Source:** `packages/spec/src/api/` · **Import:** `@objectstack/spec/api` · **39 pages, 539 schemas**
7575

7676
REST contracts, endpoints, routing, realtime, batch, discovery.
7777

@@ -84,6 +84,7 @@ REST contracts, endpoints, routing, realtime, batch, discovery.
8484
| [`auth-endpoints.zod.ts`](https://github.com/objectstack-ai/objectstack/blob/main/packages/spec/docs/references/api/auth-endpoints.md) | `AuthEndpoint`, `AuthFeaturesConfig`, `AuthProviderInfo`, `DeviceRequestResponse`, `DeviceTokenResponse`, `EmailPasswordConfigPublic`, `GetAuthConfigResponse`, `OneTimeTokenHandoffQuery`, `OneTimeTokenVerifyRequest`, `OneTimeTokenVerifyResponse`, `OrganizationEditionChoice` |
8585
| [`automation-api.zod.ts`](https://github.com/objectstack-ai/objectstack/blob/main/packages/spec/docs/references/api/automation-api.md) | `AutomationApiErrorCode`, `AutomationFlowPathParams`, `AutomationRunPathParams`, `CloneFlowRequest`, `CloneFlowResponse`, `CreateFlowRequest`, `CreateFlowResponse`, `DeleteFlowRequest`, `DeleteFlowResponse`, `FlowFailureDetails`, `FlowInnerRefusal`, `GetFlowRequest`, `GetFlowResponse`, `GetRunRequest`, `GetRunResponse`, `ListRunsRequest`, `ListRunsResponse`, `RecordUpdateStart`, `RecordUpdateStartsRequest`, `RecordUpdateStartsResponse`, `ResumeFailureDetails`, `ToggleFlowRequest`, `ToggleFlowResponse`, `TriggerFlowRequest`, `TriggerFlowResponse`, `UpdateFlowRequest`, `UpdateFlowResponse` |
8686
| [`batch.zod.ts`](https://github.com/objectstack-ai/objectstack/blob/main/packages/spec/docs/references/api/batch.md) | `BatchConfig`, `BatchOperationResult`, `BatchOperationType`, `BatchOptions`, `BatchRecord`, `BatchUpdateRequest`, `BatchUpdateResponse`, `CrossObjectBatchDroppedFields`, `CrossObjectBatchOperation`, `CrossObjectBatchRequest`, `CrossObjectBatchResponse`, `DeleteManyRequest`, `UpdateManyRecord`, `UpdateManyRequest` |
87+
| [`comment-threads.zod.ts`](https://github.com/objectstack-ai/objectstack/blob/main/packages/spec/docs/references/api/comment-threads.md) | `CommentThread`, `CommentThreadRecord`, `CommentThreadReplier`, `CommentThreadsQueryRequest`, `CommentThreadsQueryResponse` |
8788
| [`contract.zod.ts`](https://github.com/objectstack-ai/objectstack/blob/main/packages/spec/docs/references/api/contract.md) | `ApiError`, `BaseResponse`, `BatchLoadingStrategy`, `BulkRequest`, `BulkResponse`, `CreateRequest`, `DataLoaderConfig`, `DeleteResponse`, `ExportRequest`, `IdRequest`, `ListRecordResponse`, `ModificationResult`, `QueryOptimizationConfig`, `RecordData`, `SingleRecordResponse`, `UpdateRequest` |
8889
| [`discovery.zod.ts`](https://github.com/objectstack-ai/objectstack/blob/main/packages/spec/docs/references/api/discovery.md) | `ApiRoutes`, `AuthFamilies`, `CapabilityDescriptor`, `Discovery`, `DiscoveryEnvironment`, `EnvironmentType`, `RouteHealthEntry`, `RouteHealthReport`, `ServiceInfo`, `ServiceSelfInfo`, `ServiceStatus`, `WellKnownCapabilities` |
8990
| [`dispatcher.zod.ts`](https://github.com/objectstack-ai/objectstack/blob/main/packages/spec/docs/references/api/dispatcher.md) | `DispatcherConfig`, `DispatcherErrorCode`, `DispatcherErrorResponse`, `DispatcherRoute` |

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

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

2020
| Dir | Sites |
2121
|---|---|
22-
| `api/` | 550 |
22+
| `api/` | 555 |

‎packages/client/src/client-url-conformance.test.ts‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ import { REST_ROUTE_LEDGER } from '../../rest/src/rest-route-ledger';
5050
import { STORAGE_ROUTE_LEDGER } from '../../services/service-storage/src/storage-route-ledger';
5151
import { I18N_ROUTE_LEDGER } from '../../services/service-i18n/src/i18n-route-ledger';
5252
import { AUTH_ROUTE_LEDGER } from '../../plugins/plugin-auth/src/auth-route-ledger';
53+
import { COMMENT_ROUTE_LEDGER } from '../../plugins/plugin-audit/src/comment-route-ledger';
5354

5455
const BASE = 'http://localhost:9';
5556

@@ -119,6 +120,10 @@ const PATTERNS: Pattern[] = [
119120
...STORAGE_ROUTE_LEDGER.map((r) => r.route).flatMap((r) => compile(r, '', 'storage')),
120121
...I18N_ROUTE_LEDGER.map((r) => r.route).flatMap((r) => compile(r, '', 'i18n')),
121122
...AUTH_ROUTE_LEDGER.map((r) => r.route).flatMap((r) => compile(r, '', 'auth')),
123+
// The comment registrar's own mount (plugin-audit, self-hosted only): the
124+
// threads read is SDK surface (`comments.queryThreads`), so the URL that
125+
// method builds is matched against the ledger of the registrar that mounts it.
126+
...COMMENT_ROUTE_LEDGER.map((r) => r.route).flatMap((r) => compile(r, '', 'comments')),
122127
]
123128
// Exact rows before wildcard families, so a URL that a real route covers is
124129
// never CREDITED to a `**` prefix claim that happens to sit earlier in the
@@ -481,3 +486,30 @@ describe('client URL conformance ↔ the union of all four route ledgers (#3642)
481486
).toBe(0);
482487
});
483488
});
489+
490+
describe('the comment registrar ledger ↔ @objectstack/client', () => {
491+
it('every comment ledger row naming a client method resolves to a real function', () => {
492+
const client = new ObjectStackClient({ baseUrl: BASE });
493+
const broken = COMMENT_ROUTE_LEDGER.filter((e) => e.client != null)
494+
.filter((e) => typeof e.client!.split('.').reduce<unknown>((o, k) => (o == null ? o : (o as Record<string, unknown>)[k]), client) !== 'function')
495+
.map((e) => `${e.route} → client.${e.client}`);
496+
expect(broken).toEqual([]);
497+
expect(COMMENT_ROUTE_LEDGER.filter((e) => e.disposition === 'sdk').map((e) => e.client)).toEqual(['comments.queryThreads']);
498+
});
499+
500+
it('comments.queryThreads POSTs the request as the JSON body to the threads read, and resolves the answer\'s data', async () => {
501+
const data = { threads: [], nextCursor: null };
502+
const calls: Array<{ verb: string; url: string; body: unknown }> = [];
503+
const client = new ObjectStackClient({
504+
baseUrl: BASE,
505+
fetch: async (input: RequestInfo | URL, init?: RequestInit) => {
506+
calls.push({ verb: (init?.method ?? 'GET').toUpperCase(), url: String(input), body: init?.body });
507+
return makeResponse({ success: true, data });
508+
},
509+
});
510+
const request = { object: 'account', filter: [['status', '=', 'open']], showResolved: true, limit: 10, cursor: 'c' };
511+
await expect(client.comments.queryThreads(request)).resolves.toEqual(data);
512+
expect(calls.map((c) => `${c.verb} ${c.url}`)).toEqual([`POST ${BASE}/api/v1/comments/threads/query`]);
513+
expect(JSON.parse(String(calls[0].body))).toEqual(request);
514+
});
515+
});

‎packages/client/src/index.ts‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import {
99
GetRecordLocksResponse,
1010
RecordPageRequest,
1111
RecordPageResponse,
12+
CommentThreadsQueryRequest,
13+
CommentThreadsQueryResponse,
1214
// [#32200] The batch dataset-query answer `analytics.queryDatasetBatch`
1315
// resolves to the `data` of.
1416
DatasetQueryBatchResponse,
@@ -7468,6 +7470,33 @@ export class ObjectStackClient {
74687470
* record, served under the data surface. Every route 501s
74697471
* [NOT_IMPLEMENTED] on deployments without the sharing service.
74707472
*/
7473+
/**
7474+
* Comment threads across records. Served by plugin-audit's comment
7475+
* registrar on a kernel with an HTTP server.
7476+
*/
7477+
comments = {
7478+
/**
7479+
* The comment threads on the records a list filter selects —
7480+
* `POST /api/v1/comments/threads/query`, declared by
7481+
* `CommentThreadsQueryRequestSchema` / `CommentThreadsQueryResponseSchema`
7482+
* (`@objectstack/spec/api`). One page of top-level comments on the records
7483+
* of `request.object` that `request.filter` (the `GET /data/{object}`
7484+
* filter syntax) selects and the caller may read, newest first, each with
7485+
* its record's id and name, its reply count and its latest repliers.
7486+
* Pass the answer's `nextCursor` back as `request.cursor` for the next
7487+
* page. Unresolved threads only unless `showResolved`; only the caller's
7488+
* own threads (started, replied in, mentioned in) when `onlyMine`. A
7489+
* caller with no read on the object rejects with that read's refusal.
7490+
*/
7491+
queryThreads: async (request: CommentThreadsQueryRequest): Promise<CommentThreadsQueryResponse> => {
7492+
const res = await this.fetch(`${this.baseUrl}/api/v1/comments/threads/query`, {
7493+
method: 'POST',
7494+
body: JSON.stringify(request),
7495+
});
7496+
return this.unwrapResponse<CommentThreadsQueryResponse>(res);
7497+
},
7498+
};
7499+
74717500
shares = {
74727501
/** List the sharing grants on a record. */
74737502
list: async (object: string, recordId: string): Promise<RecordShare[]> => {
@@ -9694,6 +9723,8 @@ export type {
96949723
RecordLockEntry,
96959724
RecordPageRequest,
96969725
RecordPageResponse,
9726+
CommentThreadsQueryRequest,
9727+
CommentThreadsQueryResponse,
96979728
RealtimeConnectRequest,
96989729
RealtimeConnectResponse,
96999730
RealtimeSubscribeRequest,

‎packages/objectql/src/index.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,10 @@ export type { DatasourceDef } from './engine.js';
278278
// refuses the filter rather than truncate it, and its words name this number.
279279
// Exported so a caller running the two-step route itself can page by it.
280280
export { RELATION_FILTER_ID_CAP } from './relation-filter-lowering.js';
281+
// What `ObjectQL#planReadScope` takes besides the two object names, and the `$in`
282+
// comparand it answers, so an in-process caller can name both (the comment threads
283+
// read in plugin-audit plans and places one per request).
284+
export type { PlanReadScopeOptions, ReadScopeComparand } from './engine-query-lowering.js';
281285
// [ADR-0155 D4, plan step 5] The seam's recognition of D4's two classes and
282286
// its reader of a driver's `fixedReadLeaves` declaration, so an evaluator that
283287
// declines before it compiles (the analytics native compiler) asks the seam

0 commit comments

Comments
 (0)