@nacre.work/api 0.0.0 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +9 -0
  3. package/dist/adapters.d.ts +326 -15
  4. package/dist/adapters.d.ts.map +1 -1
  5. package/dist/adapters.js +992 -52
  6. package/dist/adapters.js.map +1 -1
  7. package/dist/audit-export.d.ts +45 -0
  8. package/dist/audit-export.d.ts.map +1 -0
  9. package/dist/audit-export.js +155 -0
  10. package/dist/audit-export.js.map +1 -0
  11. package/dist/auth.d.ts +17 -0
  12. package/dist/auth.d.ts.map +1 -1
  13. package/dist/auth.js +17 -7
  14. package/dist/auth.js.map +1 -1
  15. package/dist/idempotency.d.ts +62 -0
  16. package/dist/idempotency.d.ts.map +1 -0
  17. package/dist/idempotency.js +147 -0
  18. package/dist/idempotency.js.map +1 -0
  19. package/dist/index.d.ts +11 -2
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +10 -1
  22. package/dist/index.js.map +1 -1
  23. package/dist/init.d.ts +9 -0
  24. package/dist/init.d.ts.map +1 -1
  25. package/dist/init.js +50 -5
  26. package/dist/init.js.map +1 -1
  27. package/dist/limits.d.ts +80 -0
  28. package/dist/limits.d.ts.map +1 -0
  29. package/dist/limits.js +63 -0
  30. package/dist/limits.js.map +1 -0
  31. package/dist/login.d.ts +94 -0
  32. package/dist/login.d.ts.map +1 -0
  33. package/dist/login.js +283 -0
  34. package/dist/login.js.map +1 -0
  35. package/dist/main.js +136 -53
  36. package/dist/main.js.map +1 -1
  37. package/dist/pagination.d.ts +72 -0
  38. package/dist/pagination.d.ts.map +1 -0
  39. package/dist/pagination.js +110 -0
  40. package/dist/pagination.js.map +1 -0
  41. package/dist/rerank.d.ts +99 -0
  42. package/dist/rerank.d.ts.map +1 -0
  43. package/dist/rerank.js +138 -0
  44. package/dist/rerank.js.map +1 -0
  45. package/dist/server.d.ts +345 -6
  46. package/dist/server.d.ts.map +1 -1
  47. package/dist/server.js +1035 -24
  48. package/dist/server.js.map +1 -1
  49. package/dist/service-keys.d.ts +13 -5
  50. package/dist/service-keys.d.ts.map +1 -1
  51. package/dist/service-keys.js +54 -31
  52. package/dist/service-keys.js.map +1 -1
  53. package/dist/source.d.ts +53 -0
  54. package/dist/source.d.ts.map +1 -0
  55. package/dist/source.js +109 -0
  56. package/dist/source.js.map +1 -0
  57. package/package.json +28 -10
  58. package/dist/__tests__/admin-surface.test.d.ts +0 -2
  59. package/dist/__tests__/admin-surface.test.d.ts.map +0 -1
  60. package/dist/__tests__/admin-surface.test.js +0 -431
  61. package/dist/__tests__/admin-surface.test.js.map +0 -1
  62. package/dist/__tests__/init.test.d.ts +0 -2
  63. package/dist/__tests__/init.test.d.ts.map +0 -1
  64. package/dist/__tests__/init.test.js +0 -125
  65. package/dist/__tests__/init.test.js.map +0 -1
  66. package/dist/__tests__/service-keys.test.d.ts +0 -2
  67. package/dist/__tests__/service-keys.test.d.ts.map +0 -1
  68. package/dist/__tests__/service-keys.test.js +0 -204
  69. package/dist/__tests__/service-keys.test.js.map +0 -1
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2026 Nacre
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,9 @@
1
+ Nacre
2
+ Copyright 2026 Nacre
3
+
4
+ This product includes software developed at Nacre (https://nacre.work).
5
+
6
+ Licensed under the Apache License, Version 2.0. See LICENSE.
7
+
8
+ "Nacre" and the Nacre mark are trademarks. Section 6 of the Apache License
9
+ grants no trademark rights; permitted use is described in TRADEMARK.md.
@@ -1,6 +1,7 @@
1
- import { aclTags, buildFilter, VectorStore } from '@nacre.work/core';
1
+ import { aclTags, buildFilter, VectorStore, type Metadata } from '@nacre.work/core';
2
2
  import type { Pool } from 'pg';
3
- import type { AuditEvent, AuditSink, Documents, GrantInput, GrantRecord, Grants, Ingest, IngestOutcome, IngestRequest, Job, Jobs, Layer, LayerOutcome, DocumentView, Layers, SearchHit, SearchService } from './server.js';
3
+ import { type Reranker } from './rerank.js';
4
+ import type { Reindex, ReindexOutcome, ReindexStatus, AuditEvent, AuditQuery, AuditReader, AuditRecord, AuditSink, Documents, GrantInput, GrantRecord, Grants, Ingest, IngestOutcome, IngestRequest, Job, Jobs, Layer, LayerOutcome, DocumentView, Layers, Page, PageResult, Workspace, WorkspaceOutcome, Workspaces, SearchHit, SearchOptions, SearchService } from './server.js';
4
5
  import type { AuthContext } from './auth.js';
5
6
  /**
6
7
  * The adapters that put the permission model on the request path.
@@ -15,8 +16,24 @@ export interface Embedder {
15
16
  }
16
17
  export declare class PostgresDocuments implements Documents {
17
18
  private readonly pool;
19
+ /**
20
+ * What writes metadata into the payload of a document's points.
21
+ *
22
+ * Narrow on purpose, like the delete path's tombstone port: this endpoint
23
+ * has no business searching, and a port that could would let a later change
24
+ * reach the index without a plan.
25
+ */
26
+ private readonly payload;
18
27
  private readonly role?;
19
- constructor(pool: Pool, role?: string | undefined);
28
+ constructor(pool: Pool,
29
+ /**
30
+ * What writes metadata into the payload of a document's points.
31
+ *
32
+ * Narrow on purpose, like the delete path's tombstone port: this endpoint
33
+ * has no business searching, and a port that could would let a later change
34
+ * reach the index without a plan.
35
+ */
36
+ payload: DocumentMetadataWriter, role?: string | undefined);
20
37
  /**
21
38
  * Undefined for absent, for another organization's, and for one this caller
22
39
  * has no grant reaching — one answer for all three.
@@ -28,20 +45,116 @@ export declare class PostgresDocuments implements Documents {
28
45
  * inside a tenant, and it is the one that was missing.
29
46
  */
30
47
  read(auth: AuthContext, documentId: string): Promise<DocumentView | undefined>;
48
+ /**
49
+ * Replace a document's metadata without re-embedding it.
50
+ *
51
+ * This is the cheap path `docs/api.md` said was not built. Ingest treats a
52
+ * metadata change as a change: the row and the vector payload would otherwise
53
+ * disagree and the document would carry a tag it does not answer to, so a
54
+ * re-tag cost a full re-parse, re-chunk and re-embed. Here the vectors are
55
+ * untouched and only the payload is rewritten — the same `setPayload` the ACL
56
+ * retag sweep uses, for the same reason.
57
+ *
58
+ * `write`, not `read`, and rule 6 means those are not the same set. The
59
+ * answer carries no body at all: a caller who may write to a document and not
60
+ * read it must not learn its title or its layer from a successful PATCH.
61
+ *
62
+ * Row first, then payload, both inside one transaction. A payload write that
63
+ * throws rolls the row back, so the two cannot end up disagreeing in the
64
+ * direction that matters — the row is what the worker rebuilds the payload
65
+ * from on the next index, so a row that ran ahead would be reverted while a
66
+ * payload that ran ahead would not.
67
+ */
68
+ updateMetadata(auth: AuthContext, documentId: string, metadata: Metadata): Promise<boolean>;
69
+ }
70
+ export interface DocumentMetadataWriter {
71
+ setMetadata(collection: string, documentId: string, metadata: Metadata): Promise<void>;
31
72
  }
32
73
  export interface SearchDeps {
33
74
  readonly pool: Pool;
34
75
  readonly vectors: VectorStore;
35
- readonly embedder: Embedder;
36
- /** Resolved per organization; the collection name is derived from it. */
37
- readonly orgSlug: (orgId: string) => Promise<string | undefined>;
38
- readonly vectorName: string;
76
+ /**
77
+ * The query embedder for a given provider.
78
+ *
79
+ * Per provider and not one for the whole process. `NACRE_EMBEDDING_MODEL`
80
+ * used to decide both the named vector a search looked in and the model the
81
+ * query was embedded with, for every layer in every organization — so a layer
82
+ * created against a second provider was silently unsearchable: its points
83
+ * carry `v_small_v2_768` and the query went to `v_bge_m3_1024`, which matches
84
+ * nothing and raises nothing. `embedding_providers` has had an `org_id`
85
+ * column and a documented "NULL = global default" since the first migration;
86
+ * the search path was the half that never honoured it.
87
+ */
88
+ readonly embedderFor: (provider: EmbeddingProvider) => Embedder;
39
89
  readonly role?: string;
90
+ /** Absent means reranking is off, which is what the `minimal` profile is. */
91
+ readonly reranker?: Reranker;
92
+ /** Candidates to rerank. docs/architecture.md says 50. */
93
+ readonly rerankCandidates?: number;
94
+ /**
95
+ * Reranking stopped working, with the search still answering in fusion order.
96
+ * An operator who turned reranking on is entitled to know it is not running.
97
+ */
98
+ readonly onRerankFailed?: (error: unknown) => void;
99
+ }
100
+ /** What a layer needs embedded with, and where. */
101
+ export interface EmbeddingProvider {
102
+ readonly id: string;
103
+ readonly endpoint: string;
104
+ readonly model: string;
105
+ readonly dimensions: number;
40
106
  }
41
107
  export declare class NacreSearchService implements SearchService {
42
108
  private readonly deps;
43
109
  constructor(deps: SearchDeps);
44
- search(auth: AuthContext, query: string, topK: number): Promise<readonly SearchHit[]>;
110
+ search(auth: AuthContext, query: string, topK: number, options?: SearchOptions): Promise<readonly SearchHit[]>;
111
+ /**
112
+ * The organization's layers, grouped by the model they are indexed with.
113
+ *
114
+ * Restricted first to what this search can actually reach — the permission
115
+ * plan, then the caller's own `layers` narrowing — so a query never embeds
116
+ * against a provider whose layers contribute nothing. That is not only a
117
+ * saving: an embedding endpoint that is down would otherwise fail a search
118
+ * over layers that have no connection to it.
119
+ *
120
+ * A plan carrying `extraDocs` keeps every group. Documents granted
121
+ * individually can sit in any layer, including one the caller reaches no
122
+ * other way, so dropping a group here would answer empty where the correct
123
+ * answer is "the documents you were granted".
124
+ */
125
+ private groupsInScope;
126
+ /**
127
+ * Layer slugs to ids, within one organization.
128
+ *
129
+ * Scoped through `withOrg` like every other tenant read, so a slug belonging
130
+ * to another organization resolves to nothing rather than to their layer. The
131
+ * result is intersected with what the caller may reach by the filter itself —
132
+ * the ids become a `must` and the permission constraint stays a `should`, so
133
+ * a layer this caller cannot read contributes no results even when it
134
+ * resolves here.
135
+ *
136
+ * Unknown slugs are dropped rather than reported. Answering "no such layer"
137
+ * would separate "does not exist" from "you cannot see it", which is exactly
138
+ * the distinction invariant I4 exists to prevent.
139
+ */
140
+ private layerIds;
141
+ /**
142
+ * Reorder by cross-encoder score, or answer in fusion order and say so.
143
+ *
144
+ * The text comes from the hydration that had to happen anyway. A reranker
145
+ * scores query against text, and the vector store holds no text — so the
146
+ * order here is search, hydrate the candidates, rerank, cut. Hydrating fifty
147
+ * rows rather than ten is one query with a wider `ANY($2)`, which is the cost
148
+ * of the quality this buys.
149
+ *
150
+ * Failure answers with what fusion produced rather than raising. Reranking
151
+ * decides ordering over candidates that were all permitted before it saw
152
+ * them, so a reranker being down is a quality degradation and not a
153
+ * permissions one — and making the product's central operation depend on an
154
+ * optional model server would be the worse trade. It is reported, never
155
+ * silent.
156
+ */
157
+ private rerank;
45
158
  /**
46
159
  * Turn hits into results a caller can read.
47
160
  *
@@ -92,7 +205,20 @@ export declare class HttpEmbedder implements Embedder {
92
205
  private readonly endpoint;
93
206
  private readonly model;
94
207
  private readonly dimensions;
95
- constructor(endpoint: string, model: string, dimensions: number);
208
+ /** One query, one vector, and a caller waiting on it. */
209
+ private readonly timeoutMs;
210
+ constructor(endpoint: string, model: string, dimensions: number,
211
+ /** One query, one vector, and a caller waiting on it. */
212
+ timeoutMs?: number);
213
+ /**
214
+ * One embedder per provider, built once and reused.
215
+ *
216
+ * Keyed on the provider's id, so an operator who edits an endpoint has to
217
+ * restart — which is true of every other piece of configuration here, and the
218
+ * alternative is a cache that has to be invalidated from a table nothing
219
+ * watches.
220
+ */
221
+ static pool(timeoutMs?: number): (provider: EmbeddingProvider) => Embedder;
96
222
  embed(texts: readonly string[]): Promise<readonly (readonly number[])[]>;
97
223
  }
98
224
  export { aclTags };
@@ -112,12 +238,10 @@ export interface IngestDeps {
112
238
  * would let a later change reach the index without a plan.
113
239
  */
114
240
  readonly tombstone: DocumentTombstone;
115
- /** Resolved per organization; the collection name is derived from it. */
116
- readonly orgSlug: (orgId: string) => Promise<string | undefined>;
117
241
  readonly role?: string;
118
242
  }
119
243
  export interface DocumentTombstone {
120
- tombstone(orgSlug: string, documentId: string): Promise<void>;
244
+ tombstone(collection: string, documentId: string): Promise<void>;
121
245
  }
122
246
  export declare class NacreIngest implements Ingest {
123
247
  private readonly deps;
@@ -145,8 +269,34 @@ export declare class PostgresJobs implements Jobs {
145
269
  }
146
270
  export declare class PostgresLayers implements Layers {
147
271
  private readonly pool;
272
+ /**
273
+ * Only to ask which named vectors the organization's collection has.
274
+ *
275
+ * A layer is created against a provider, and the provider decides which
276
+ * named vector the layer's points go into. Qdrant fixes that set when the
277
+ * collection is created and has no way to extend it, so a layer on a
278
+ * provider the collection has no slot for is a layer whose every document
279
+ * fails in the worker with `Not existing vector name` — after the API has
280
+ * answered 202 and the row says `pending`. Checking here is what turns that
281
+ * into a collection rebuild instead.
282
+ */
283
+ private readonly vectors;
148
284
  private readonly role?;
149
- constructor(pool: Pool, role?: string | undefined);
285
+ constructor(pool: Pool,
286
+ /**
287
+ * Only to ask which named vectors the organization's collection has.
288
+ *
289
+ * A layer is created against a provider, and the provider decides which
290
+ * named vector the layer's points go into. Qdrant fixes that set when the
291
+ * collection is created and has no way to extend it, so a layer on a
292
+ * provider the collection has no slot for is a layer whose every document
293
+ * fails in the worker with `Not existing vector name` — after the API has
294
+ * answered 202 and the row says `pending`. Checking here is what turns that
295
+ * into a collection rebuild instead.
296
+ */
297
+ vectors: {
298
+ vectorsOf(collection: string): Promise<Record<string, number>>;
299
+ }, role?: string | undefined);
150
300
  private get scope();
151
301
  /**
152
302
  * The layers this caller may read.
@@ -156,13 +306,71 @@ export declare class PostgresLayers implements Layers {
156
306
  * break invariant I2 — but writing it the other way keeps one habit for both
157
307
  * and removes the question of which endpoints are allowed to be sloppy.
158
308
  */
159
- list(auth: AuthContext): Promise<readonly Layer[]>;
309
+ list(auth: AuthContext, page?: Page): Promise<PageResult<Layer>>;
310
+ update(auth: AuthContext, layerId: string, input: {
311
+ name?: string;
312
+ description?: string;
313
+ }): Promise<boolean>;
160
314
  create(auth: AuthContext, input: {
161
315
  workspaceId: string;
162
316
  slug: string;
163
317
  name: string;
318
+ providerId?: string;
164
319
  }): Promise<LayerOutcome>;
165
320
  }
321
+ /**
322
+ * Workspaces.
323
+ *
324
+ * The missing link in the API's own flow: creating a layer takes a
325
+ * `workspace_id`, and until this existed the only way to have one was the line
326
+ * `init` printed. `docs/quickstart.md` said as much — "the workspace id is the
327
+ * one `init` printed" — so a second administrator, a client library, or anyone
328
+ * who closed that terminal had no way forward that did not involve reading the
329
+ * database directly.
330
+ */
331
+ export declare class PostgresWorkspaces implements Workspaces {
332
+ private readonly pool;
333
+ private readonly role?;
334
+ constructor(pool: Pool, role?: string | undefined);
335
+ private get scope();
336
+ /**
337
+ * The workspaces this caller can reach, newest last, cursor-paged.
338
+ *
339
+ * Two ways to reach one, and the second is the reason this endpoint had to
340
+ * exist at all:
341
+ *
342
+ * 1. it holds a layer the read plan reaches — the ordinary case, and the same
343
+ * narrowing the layer listing does;
344
+ * 2. the caller holds a grant on the workspace itself. An **empty** workspace
345
+ * has no layers to be reached through, so without this an administrator
346
+ * who had just been granted one could not see it, and therefore could not
347
+ * create the first layer in it. That is the exact deadlock this endpoint
348
+ * is here to break.
349
+ *
350
+ * Filtered in memory rather than in SQL because the second rule is the
351
+ * resolver's to answer, not a join's, and an organization has tens of
352
+ * workspaces rather than thousands. The listing is narrowed before it is
353
+ * paged — a page assembled first and filtered second would leak the count.
354
+ */
355
+ list(auth: AuthContext, page?: Page): Promise<PageResult<Workspace>>;
356
+ /**
357
+ * Create a workspace. `org_admin` only.
358
+ *
359
+ * There is no scope above a workspace to hold a grant on — `scope_type` is
360
+ * one of workspace, layer, document — so there is no one to ask except the
361
+ * role. `referenceAllows` would answer this with `role === 'org_admin'` and
362
+ * nothing else, so the check is written plainly rather than routed through a
363
+ * resolver call that can only return one thing.
364
+ *
365
+ * `platform_admin` is refused along with everyone else. Rule 2: it
366
+ * administers organizations and reads no documents, and a workspace is where
367
+ * documents live.
368
+ */
369
+ create(auth: AuthContext, input: {
370
+ slug: string;
371
+ name: string;
372
+ }): Promise<WorkspaceOutcome>;
373
+ }
166
374
  export declare class PostgresGrants implements Grants {
167
375
  private readonly pool;
168
376
  private readonly role?;
@@ -176,7 +384,20 @@ export declare class PostgresGrants implements Grants {
176
384
  * than none — an administrator who cannot see an existing grant revokes the
177
385
  * wrong thing.
178
386
  */
179
- list(auth: AuthContext): Promise<readonly GrantRecord[]>;
387
+ /**
388
+ * Paginated, and the page may be short.
389
+ *
390
+ * Which grants a caller may see is decided by `referenceAllows` against the
391
+ * scope tree, which SQL cannot express — so rows are fetched by cursor and
392
+ * filtered afterwards. That makes `items.length < limit` normal rather than a
393
+ * signal, and `next_cursor` the only thing that says whether more exist.
394
+ *
395
+ * The cursor comes from the last row **fetched**, not the last returned.
396
+ * Deriving it from the last returned row would skip everything the filter
397
+ * removed after it, which is a page of grants silently missing from an
398
+ * administrator's view of who can reach what.
399
+ */
400
+ list(auth: AuthContext, page?: Page): Promise<PageResult<GrantRecord>>;
180
401
  issue(auth: AuthContext, input: GrantInput): Promise<GrantRecord | undefined>;
181
402
  /**
182
403
  * Withdraw a grant.
@@ -194,4 +415,94 @@ export declare class PostgresGrants implements Grants {
194
415
  */
195
416
  revoke(auth: AuthContext, grantId: string): Promise<boolean>;
196
417
  }
418
+ /**
419
+ * Reading the access log back.
420
+ *
421
+ * Scoped through `withOrg` like every other tenant read, so the row-level
422
+ * policy on `audit_events` is the second line of defence behind the role check
423
+ * in the handler. `SELECT` is the only grant the application role has on this
424
+ * table and that stays true — nothing here writes.
425
+ *
426
+ * ## Newest first, and what that does to the cursor
427
+ *
428
+ * Every other paged collection here reads oldest-first, because a catalog is a
429
+ * set and the order is arbitrary. A log is not: the useful end is the recent
430
+ * one, and an auditor paging forward from the beginning of a 400-day retention
431
+ * window to find yesterday is not a feature. So this orders
432
+ * `(occurred_at, id) DESC` and the seek predicate is `<` rather than `>`.
433
+ *
434
+ * The cursor still means "everything after the last row you saw", which is the
435
+ * same contract read in the other direction. It is worth being explicit because
436
+ * copying the seek clause from the layers adapter — where it is `>` — would
437
+ * produce a first page that works and a second page that silently returns the
438
+ * beginning of the log.
439
+ */
440
+ export declare class PostgresAuditReader implements AuditReader {
441
+ private readonly pool;
442
+ private readonly role?;
443
+ constructor(pool: Pool, role?: string | undefined);
444
+ /**
445
+ * Actions that record a substantive access to a document's contents.
446
+ *
447
+ * Withheld from `platform_admin`, per rule 2 in docs/authz.md as
448
+ * docs/audit.md applies it to the journal. Named as a deny-list rather than
449
+ * an allow-list of administrative actions, and that is the uncomfortable
450
+ * direction: a new action defaults to *visible* to a platform administrator
451
+ * rather than hidden.
452
+ *
453
+ * Chosen anyway, because the alternative fails worse. An allow-list means a
454
+ * new administrative action is invisible to the operator who administers the
455
+ * installation until someone remembers to add it — a silent gap in an
456
+ * operational tool. This way a new *access* action is visible until someone
457
+ * adds it here, which is a disclosure to an already highly-privileged role
458
+ * within one installation. Both are bugs; only one of them is quiet.
459
+ *
460
+ * The `audit-event` skill's checklist is where this list is kept in step.
461
+ */
462
+ private static readonly DOCUMENT_ACCESS;
463
+ read(auth: AuthContext, query: AuditQuery, page: Page): Promise<PageResult<AuditRecord>>;
464
+ private scopeFor;
465
+ }
466
+ /**
467
+ * Starting a reindex, and reporting on one.
468
+ *
469
+ * The work is the worker's. This writes the intent — `layers.reindex_state` —
470
+ * counts what there is to do, and declares the new named vector on the
471
+ * collection.
472
+ *
473
+ * That last part belongs here and an earlier version of this comment said the
474
+ * opposite: that Qdrant creates a named vector when a point is first written
475
+ * with it, so the worker's first batch would bring it into existence. It does
476
+ * not. `updateVectors` against an undeclared name answers
477
+ * `Not existing vector name error`, and the reindex that assumed otherwise
478
+ * started cleanly, reported `running`, and failed every document forever with
479
+ * the progress gauge sitting at zero — which is step 1 of the sequence in
480
+ * docs/architecture.md being skipped, and the document has it first for a
481
+ * reason.
482
+ *
483
+ * Doing it here rather than in the worker also puts the failure where somebody
484
+ * is looking: an operator who cannot create the vector finds out from the
485
+ * response to their own request, not by watching a counter not move.
486
+ */
487
+ export declare class PostgresReindex implements Reindex {
488
+ private readonly pool;
489
+ private readonly vectors;
490
+ private readonly role?;
491
+ constructor(pool: Pool, vectors: {
492
+ vectorsOf(collection: string): Promise<Record<string, number>>;
493
+ }, role?: string | undefined);
494
+ private get scope();
495
+ start(auth: AuthContext, layerId: string, providerId: string): Promise<ReindexOutcome | undefined>;
496
+ status(auth: AuthContext, layerId: string): Promise<ReindexStatus | undefined>;
497
+ /**
498
+ * Live documents in the layer that do not yet carry this vector.
499
+ *
500
+ * The same predicate the worker's claim uses and the same one the switch is
501
+ * guarded by. Three places, one meaning — and if they ever disagree, the
502
+ * switch is the one that is right, because it is the only one inside the
503
+ * statement that performs it.
504
+ */
505
+ private remaining;
506
+ private statusOf;
507
+ }
197
508
  //# sourceMappingURL=adapters.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"adapters.d.ts","sourceRoot":"","sources":["../src/adapters.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,WAAW,EAOX,WAAW,EAIZ,MAAM,kBAAkB,CAAA;AAGzB,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,IAAI,CAAA;AAE9B,OAAO,KAAK,EACV,UAAU,EACV,SAAS,EACT,SAAS,EACT,UAAU,EACV,WAAW,EACX,MAAM,EACN,MAAM,EACN,aAAa,EACb,aAAa,EACb,GAAG,EACH,IAAI,EACJ,KAAK,EACL,YAAY,EACZ,YAAY,EACZ,MAAM,EACN,SAAS,EACT,aAAa,EACd,MAAM,aAAa,CAAA;AACpB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAE5C;;;;;;;GAOG;AAEH,MAAM,WAAW,QAAQ;IACvB,KAAK,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,SAAS,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,CAAC,CAAA;CACzE;AAED,qBAAa,iBAAkB,YAAW,SAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,IAAI;IAAQ,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC;gBAAlC,IAAI,EAAE,IAAI,EAAmB,IAAI,CAAC,EAAE,MAAM,YAAA;IAEvE;;;;;;;;;OASG;IACG,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC;CAwDrF;AAED,MAAM,WAAW,UAA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