@nacre.work/core 0.2.0 → 0.3.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.
- package/dist/authz/index.d.ts +0 -1
- package/dist/authz/index.d.ts.map +1 -1
- package/dist/authz/index.js +0 -1
- package/dist/authz/index.js.map +1 -1
- package/dist/config.d.ts +110 -4
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +347 -34
- package/dist/config.js.map +1 -1
- package/dist/db/migrate.d.ts +45 -0
- package/dist/db/migrate.d.ts.map +1 -1
- package/dist/db/migrate.js +61 -0
- package/dist/db/migrate.js.map +1 -1
- package/dist/extensions.d.ts +298 -0
- package/dist/extensions.d.ts.map +1 -0
- package/dist/extensions.js +246 -0
- package/dist/extensions.js.map +1 -0
- package/dist/index.d.ts +9 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/dist/metrics.d.ts +10 -7
- package/dist/metrics.d.ts.map +1 -1
- package/dist/metrics.js +25 -7
- package/dist/metrics.js.map +1 -1
- package/dist/migrations/0015_reference_queries.sql +97 -0
- package/dist/migrations/0016_drop_acl_tag_cache.sql +62 -0
- package/dist/migrations/0017_drop_workspace_admin_role.sql +30 -0
- package/dist/migrations/0018_group_members_nulls_not_distinct.sql +46 -0
- package/dist/migrations/0019_embedding_provider_write_guard.sql +58 -0
- package/dist/multipart.d.ts +55 -0
- package/dist/multipart.d.ts.map +1 -0
- package/dist/multipart.js +158 -0
- package/dist/multipart.js.map +1 -0
- package/dist/oauth.d.ts +10 -0
- package/dist/oauth.d.ts.map +1 -1
- package/dist/oauth.js +10 -0
- package/dist/oauth.js.map +1 -1
- package/dist/observability.d.ts.map +1 -1
- package/dist/observability.js +24 -46
- package/dist/observability.js.map +1 -1
- package/dist/reindex.d.ts +44 -0
- package/dist/reindex.d.ts.map +1 -1
- package/dist/reindex.js +49 -0
- package/dist/reindex.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/vector/query.d.ts +7 -9
- package/dist/vector/query.d.ts.map +1 -1
- package/dist/vector/query.js +7 -6
- package/dist/vector/query.js.map +1 -1
- package/dist/vector/search.d.ts +20 -1
- package/dist/vector/search.d.ts.map +1 -1
- package/dist/vector/search.js +31 -1
- package/dist/vector/search.js.map +1 -1
- package/package.json +1 -1
- package/dist/authz/tags.d.ts +0 -40
- package/dist/authz/tags.d.ts.map +0 -1
- package/dist/authz/tags.js +0 -48
- package/dist/authz/tags.js.map +0 -1
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { resolve as builtInResolve } from './authz/resolve.js';
|
|
2
|
+
const registry = { resolver: undefined, providers: [], sinks: [], routes: [], gates: [] };
|
|
3
|
+
/** Which module is registering, or `undefined` when registration is closed. */
|
|
4
|
+
let loading;
|
|
5
|
+
class ExtensionError extends Error {
|
|
6
|
+
constructor(message) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.name = 'ExtensionError';
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
function mustBeLoading(what) {
|
|
12
|
+
if (loading === undefined) {
|
|
13
|
+
throw new ExtensionError(`${what} was registered outside module loading. Extensions are read once, ` +
|
|
14
|
+
'when the surfaces are composed, so anything registered afterwards would ' +
|
|
15
|
+
'be configured and never consulted. Register from the module body, which ' +
|
|
16
|
+
'runs during loadModules().');
|
|
17
|
+
}
|
|
18
|
+
return loading;
|
|
19
|
+
}
|
|
20
|
+
export function registerAuthzResolver(resolver) {
|
|
21
|
+
const module = mustBeLoading('an authorization resolver');
|
|
22
|
+
if (registry.resolver !== undefined) {
|
|
23
|
+
// Refused rather than replaced. See the note at the top: the loser would
|
|
24
|
+
// stay loaded and appear to be in force.
|
|
25
|
+
throw new ExtensionError(`two authorization resolvers were registered — ${registry.resolver.module} ` +
|
|
26
|
+
`and ${module}. There is one answer to who decides access and no order ` +
|
|
27
|
+
'of precedence worth inventing. Load one.');
|
|
28
|
+
}
|
|
29
|
+
registry.resolver = { module, value: resolver };
|
|
30
|
+
}
|
|
31
|
+
export function registerAuthProvider(provider) {
|
|
32
|
+
registry.providers.push({ module: mustBeLoading('an auth provider'), value: provider });
|
|
33
|
+
}
|
|
34
|
+
export function registerAuditSink(sink) {
|
|
35
|
+
registry.sinks.push({ module: mustBeLoading('an audit sink'), value: sink });
|
|
36
|
+
}
|
|
37
|
+
export function registerIngestGate(gate) {
|
|
38
|
+
registry.gates.push({ module: mustBeLoading('an ingest gate'), value: gate });
|
|
39
|
+
}
|
|
40
|
+
export const ADMIN_PREFIX = '/v1/admin/';
|
|
41
|
+
/**
|
|
42
|
+
* Paths the pattern is asked about directly.
|
|
43
|
+
*
|
|
44
|
+
* Not a proof and not meant as one — the anchor check above is the guarantee.
|
|
45
|
+
* This catches the thing the anchor check cannot see, which is a top-level
|
|
46
|
+
* alternation: `^/v1/admin/x|^/v1/search` starts with the right prefix and
|
|
47
|
+
* matches a documented surface anyway. The list is the surfaces where being
|
|
48
|
+
* wrong costs the most, plus the two near misses on the prefix itself.
|
|
49
|
+
*/
|
|
50
|
+
const MUST_NOT_MATCH = [
|
|
51
|
+
'/v1/search',
|
|
52
|
+
'/v1/documents/00000000-0000-0000-0000-000000000000',
|
|
53
|
+
'/v1/grants',
|
|
54
|
+
'/v1/layers',
|
|
55
|
+
'/v1/workspaces',
|
|
56
|
+
'/v1/audit',
|
|
57
|
+
'/v1/auth/login',
|
|
58
|
+
'/v1/health',
|
|
59
|
+
'/.well-known/jwks.json',
|
|
60
|
+
'/v1/admin',
|
|
61
|
+
'/v1/adminish/things',
|
|
62
|
+
];
|
|
63
|
+
export function mountAdminRoutes(...routes) {
|
|
64
|
+
const module = mustBeLoading('admin routes');
|
|
65
|
+
for (const route of routes) {
|
|
66
|
+
// Checked here rather than trusted. A route outside the prefix would be a
|
|
67
|
+
// module replacing a documented surface rather than adding to one, and the
|
|
68
|
+
// dispatcher would happily serve it.
|
|
69
|
+
//
|
|
70
|
+
// Anchored, not merely containing: `/v1/admin/x` without the `^` matches
|
|
71
|
+
// `/v1/search?q=/v1/admin/x` shaped paths as readily as the intended one,
|
|
72
|
+
// and the whole value of the prefix is that it is a prefix.
|
|
73
|
+
//
|
|
74
|
+
// `\/` is unescaped first, because `/^\/v1\/admin\/x$/.source` is
|
|
75
|
+
// `^\/v1\/admin\/x$` while `new RegExp('^/v1/admin/x').source` is
|
|
76
|
+
// `^/v1/admin/x` — the same pattern, two spellings. A check on the raw
|
|
77
|
+
// source accepts one and refuses the other, which makes it a check on how
|
|
78
|
+
// the author escaped rather than on what the pattern matches. `\/` in a
|
|
79
|
+
// pattern means the character `/` and nothing else, so this rewrite is
|
|
80
|
+
// exact rather than a guess.
|
|
81
|
+
// `g` and `y` make a pattern stateful: `test` and `exec` advance
|
|
82
|
+
// `lastIndex` and the next call starts from there, so the same request
|
|
83
|
+
// path matches or does not depending on what was dispatched before it.
|
|
84
|
+
// Refused rather than worked around by resetting, because a route that
|
|
85
|
+
// only works because the dispatcher remembers to clear a field is a route
|
|
86
|
+
// that breaks the first time someone matches it somewhere else.
|
|
87
|
+
if (route.pattern.global || route.pattern.sticky) {
|
|
88
|
+
throw new ExtensionError(`${module} mounted a route whose pattern carries the ` +
|
|
89
|
+
`${route.pattern.global ? 'g' : 'y'} flag: ${String(route.pattern)}. ` +
|
|
90
|
+
'A stateful pattern matches or does not depending on what was ' +
|
|
91
|
+
'matched before it. Drop the flag.');
|
|
92
|
+
}
|
|
93
|
+
const source = route.pattern.source.replaceAll('\\/', '/');
|
|
94
|
+
if (!source.startsWith(`^${ADMIN_PREFIX}`)) {
|
|
95
|
+
throw new ExtensionError(`${module} mounted a route whose pattern is not anchored under ` +
|
|
96
|
+
`${ADMIN_PREFIX}: ${route.pattern.source}. Modules extend the admin ` +
|
|
97
|
+
'surface; they do not replace the documented ones.');
|
|
98
|
+
}
|
|
99
|
+
for (const path of MUST_NOT_MATCH) {
|
|
100
|
+
if (route.pattern.test(path)) {
|
|
101
|
+
throw new ExtensionError(`${module} mounted a route anchored under ${ADMIN_PREFIX} that also ` +
|
|
102
|
+
`matches ${path}. A pattern can leave the prefix through a ` +
|
|
103
|
+
'top-level alternation; this one does. Mount one route per path.');
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
// Every route checked before any is kept, so a refused batch mounts none of
|
|
108
|
+
// itself. A partial mount would be a module half in force, which is the state
|
|
109
|
+
// this file refuses everywhere else.
|
|
110
|
+
for (const route of routes)
|
|
111
|
+
registry.routes.push({ module, value: route });
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Import the named modules and let them register, then close registration.
|
|
115
|
+
*
|
|
116
|
+
* Dynamic by name, from configuration, which is what keeps the enterprise
|
|
117
|
+
* package's name out of this repository's source — the `boundary` job greps for
|
|
118
|
+
* it, and a static import would be the leak that job exists to catch.
|
|
119
|
+
*
|
|
120
|
+
* A module that cannot be imported is a startup failure, not a warning. The
|
|
121
|
+
* whole point of naming one is that a deployment is paying for what it does,
|
|
122
|
+
* and starting without it would silently be a different product.
|
|
123
|
+
*/
|
|
124
|
+
export async function loadModules(names, importer = (name) => import(/* @vite-ignore */ name)) {
|
|
125
|
+
for (const name of names) {
|
|
126
|
+
loading = name;
|
|
127
|
+
try {
|
|
128
|
+
await importer(name);
|
|
129
|
+
}
|
|
130
|
+
catch (cause) {
|
|
131
|
+
throw new ExtensionError(`module ${name} could not be loaded: ${String(cause)}`);
|
|
132
|
+
}
|
|
133
|
+
finally {
|
|
134
|
+
loading = undefined;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* The resolver in force.
|
|
140
|
+
*
|
|
141
|
+
* The built-in one unless a module replaced it, which is what makes the core
|
|
142
|
+
* complete with nothing plugged in. Read per call rather than captured, so
|
|
143
|
+
* there is no window in which a surface holds a stale one.
|
|
144
|
+
*/
|
|
145
|
+
export function activeResolver() {
|
|
146
|
+
return registry.resolver?.value ?? { resolve: builtInResolve };
|
|
147
|
+
}
|
|
148
|
+
export const authProviders = () => registry.providers.map((p) => p.value);
|
|
149
|
+
export const auditSinks = () => registry.sinks.map((s) => s.value);
|
|
150
|
+
export const adminRoutes = () => registry.routes.map((r) => r.value);
|
|
151
|
+
/**
|
|
152
|
+
* Run every gate, in order, and report the first refusal.
|
|
153
|
+
*
|
|
154
|
+
* `undefined` is admission: no gates registered, or every one admitted, which
|
|
155
|
+
* is why the open core accepts what a caller may write. The first deny stops the
|
|
156
|
+
* rest — a document refused by one gate is refused, and asking the others would
|
|
157
|
+
* be work whose answer cannot change the outcome. The default status is `403`,
|
|
158
|
+
* so a gate that only sets a reason still refuses with a status a caller with
|
|
159
|
+
* access can act on rather than a `404` that would hide the layer it just wrote
|
|
160
|
+
* a check against.
|
|
161
|
+
*/
|
|
162
|
+
export async function admitIngest(context) {
|
|
163
|
+
for (const gate of registry.gates) {
|
|
164
|
+
const verdict = await gate.value.admit(context);
|
|
165
|
+
if (!verdict.admit) {
|
|
166
|
+
return { module: gate.value.name, status: verdict.status ?? 403, reason: verdict.reason };
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return undefined;
|
|
170
|
+
}
|
|
171
|
+
const FANNED_OUT = Symbol.for('nacre.auditSinksApplied');
|
|
172
|
+
/**
|
|
173
|
+
* Record the event, then hand it to every sink.
|
|
174
|
+
*
|
|
175
|
+
* A decorator over the port rather than something the Postgres adapter does,
|
|
176
|
+
* which is where it started and which put it one layer too low: forwarding is a
|
|
177
|
+
* property of *an event having been recorded*, not of which adapter recorded it.
|
|
178
|
+
* A second adapter — or a surface handed a different port — would have been a
|
|
179
|
+
* SIEM silently missing a class of events, with nothing to notice it by.
|
|
180
|
+
*
|
|
181
|
+
* The table first and never the reverse. The journal is what an auditor reads
|
|
182
|
+
* and what the append-only grant protects, so a forwarder must not be able to
|
|
183
|
+
* make a row conditional on a network hop succeeding.
|
|
184
|
+
*
|
|
185
|
+
* A sink that throws does not fail the request. It is a copy of something
|
|
186
|
+
* already durably recorded, and turning a collector outage into a 500 on every
|
|
187
|
+
* authenticated call would take the installation down to protect a duplicate.
|
|
188
|
+
*
|
|
189
|
+
* Applying it twice is a no-op, so a construction site that wraps a port
|
|
190
|
+
* already wrapped does not double every event in the deployment's SIEM.
|
|
191
|
+
*/
|
|
192
|
+
export function withAuditSinks(port, onError = () => { }) {
|
|
193
|
+
if (port[FANNED_OUT] === true)
|
|
194
|
+
return port;
|
|
195
|
+
const wrapped = {
|
|
196
|
+
write: async (event) => {
|
|
197
|
+
await port.write(event);
|
|
198
|
+
for (const sink of auditSinks()) {
|
|
199
|
+
try {
|
|
200
|
+
await sink.write(event);
|
|
201
|
+
}
|
|
202
|
+
catch (error) {
|
|
203
|
+
onError(sink.name, event, error);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
};
|
|
208
|
+
return Object.assign(Object.create(port), wrapped, { [FANNED_OUT]: true });
|
|
209
|
+
}
|
|
210
|
+
/** What was loaded, for the startup line. An operator needs to see it. */
|
|
211
|
+
export function loadedExtensions() {
|
|
212
|
+
return {
|
|
213
|
+
resolver: registry.resolver?.module ?? null,
|
|
214
|
+
providers: registry.providers.map((p) => `${p.module}:${p.value.name}`),
|
|
215
|
+
sinks: registry.sinks.map((s) => `${s.module}:${s.value.name}`),
|
|
216
|
+
routes: registry.routes.length,
|
|
217
|
+
gates: registry.gates.map((g) => `${g.module}:${g.value.name}`),
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Empty the registry. **Tests only**, and named so that is unmistakable.
|
|
222
|
+
*
|
|
223
|
+
* A process does not unload a module, so there is no production reason to call
|
|
224
|
+
* this — but a test file that registered one would otherwise leak it into every
|
|
225
|
+
* test after it, which is exactly the shape of failure a global registry earns
|
|
226
|
+
* if nobody gives it a way out.
|
|
227
|
+
*/
|
|
228
|
+
export function resetExtensionsForTests() {
|
|
229
|
+
registry.resolver = undefined;
|
|
230
|
+
registry.providers.length = 0;
|
|
231
|
+
registry.sinks.length = 0;
|
|
232
|
+
registry.routes.length = 0;
|
|
233
|
+
registry.gates.length = 0;
|
|
234
|
+
loading = undefined;
|
|
235
|
+
}
|
|
236
|
+
/** Open registration without importing anything. **Tests only.** */
|
|
237
|
+
export function withLoadingModuleForTests(name, fn) {
|
|
238
|
+
loading = name;
|
|
239
|
+
try {
|
|
240
|
+
return fn();
|
|
241
|
+
}
|
|
242
|
+
finally {
|
|
243
|
+
loading = undefined;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
//# sourceMappingURL=extensions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extensions.js","sourceRoot":"","sources":["../extensions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,oBAAoB,CAAA;AA8N9D,MAAM,QAAQ,GAAa,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAA;AAEnG,+EAA+E;AAC/E,IAAI,OAA2B,CAAA;AAE/B,MAAM,cAAe,SAAQ,KAAK;IAChC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAA;IAC9B,CAAC;CACF;AAED,SAAS,aAAa,CAAC,IAAY;IACjC,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,MAAM,IAAI,cAAc,CACtB,GAAG,IAAI,oEAAoE;YACzE,0EAA0E;YAC1E,0EAA0E;YAC1E,4BAA4B,CAC/B,CAAA;IACH,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,QAAuB;IAC3D,MAAM,MAAM,GAAG,aAAa,CAAC,2BAA2B,CAAC,CAAA;IACzD,IAAI,QAAQ,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC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,IAAI,CAAA;IACd,IAAI,CAAC;QACH,OAAO,EAAE,EAAE,CAAA;IACb,CAAC;YAAS,CAAC;QACT,OAAO,GAAG,SAAS,CAAA;IACrB,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,10 +2,12 @@ export * from './types.js';
|
|
|
2
2
|
export * from './authz/index.js';
|
|
3
3
|
export { parseFilters, parseMetadata, MetadataError, MAX_METADATA_KEYS, MAX_METADATA_KEY_LENGTH, MAX_METADATA_LIST, MAX_METADATA_VALUE_LENGTH, } from './metadata.js';
|
|
4
4
|
export type { Metadata } from './metadata.js';
|
|
5
|
-
export { loadConfig, loadJwtKeys, ConfigError } from './config.js';
|
|
6
|
-
export { protectedResourceMetadata, PROTECTED_RESOURCE_PATH } from './oauth.js';
|
|
5
|
+
export { loadConfig, loadJwtKeys, loadJwtVerification, keyFingerprint, ConfigError } from './config.js';
|
|
6
|
+
export { protectedResourceMetadata, PROTECTED_RESOURCE_PATH, JWKS_PATH } from './oauth.js';
|
|
7
|
+
export { activeResolver, admitIngest, ADMIN_PREFIX, adminRoutes, auditSinks, authProviders, loadModules, loadedExtensions, mountAdminRoutes, registerAuditSink, registerAuthProvider, registerAuthzResolver, registerIngestGate, resetExtensionsForTests, withAuditSinks, withLoadingModuleForTests, } from './extensions.js';
|
|
8
|
+
export type { AdminRequest, AdminResponse, AdminRoute, AuditEvent, AuditSink, AuditWriter, AuthProvider, AuthzResolver, IngestContext, IngestGate, IngestRefusal, IngestVerdict, ResolvedPrincipal, } from './extensions.js';
|
|
7
9
|
export type { ProtectedResourceMetadata } from './oauth.js';
|
|
8
|
-
export type { JwtKeys } from './config.js';
|
|
10
|
+
export type { JwtKeys, JwtVerification } from './config.js';
|
|
9
11
|
export type { Config } from './config.js';
|
|
10
12
|
export { acrossOrganizations, createPool, whileAuthenticating, withOrg } from './db/client.js';
|
|
11
13
|
export type { DbOptions, WithOrgOptions } from './db/client.js';
|
|
@@ -13,6 +15,8 @@ export { migrate, loadMigrations } from './db/migrate.js';
|
|
|
13
15
|
export { loadGrants, loadGroupsVersion, loadScopeTree, PostgresGroupGraph } from './authz/store.js';
|
|
14
16
|
export { explainQdrant, MetadataIndexer, METADATA_INDEX_LIMIT, VectorStore } from './vector/search.js';
|
|
15
17
|
export { MAX_AUDITED_QUERY, queryAudit } from './audit.js';
|
|
18
|
+
export { MAX_PARTS, MAX_PART_HEADER_BYTES, MultipartError, multipartBoundary, parseMultipart, } from './multipart.js';
|
|
19
|
+
export type { MultipartPart } from './multipart.js';
|
|
16
20
|
export type { QueryAudit } from './audit.js';
|
|
17
21
|
export { configureLogging, createLogger, logger } from './logging.js';
|
|
18
22
|
export type { Logger, LoggerOptions, LogFormat, LogLevel } from './logging.js';
|
|
@@ -26,8 +30,8 @@ export type { Labels, Metrics } from './metrics.js';
|
|
|
26
30
|
export { collectDatabaseGauges } from './observability.js';
|
|
27
31
|
export { Redis, RedisError } from './redis.js';
|
|
28
32
|
export type { RedisOptions } from './redis.js';
|
|
29
|
-
export { reindexProgress, toStateJson, fromStateJson } from './reindex.js';
|
|
30
|
-
export type { ReindexState } from './reindex.js';
|
|
33
|
+
export { reindexProgress, toStateJson, toCheckJson, fromStateJson } from './reindex.js';
|
|
34
|
+
export type { ReindexState, ReindexCheck } from './reindex.js';
|
|
31
35
|
export { hashingLoad, hashPassword, needsRehash, spendVerificationTime, TooBusy, verifyPassword, } from './passwords.js';
|
|
32
36
|
export { installGuards, onListenError } from './lifecycle.js';
|
|
33
37
|
export type { Guards } from './lifecycle.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,kBAAkB,CAAA;AAChC,OAAO,EACL,YAAY,EACZ,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,uBAAuB,EACvB,iBAAiB,EACjB,yBAAyB,GAC1B,MA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EAAE,MAAM,cAAc,CAAA;AACjF,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAC1D,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAC9C,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAC9C,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AACvF,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC9D,OAAO,EACL,WAAW,EACX,YAAY,EACZ,WAAW,EACX,qBAAqB,EACrB,OAAO,EACP,cAAc,GACf,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAC7D,YAAY,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
export * from './types.js';
|
|
2
2
|
export * from './authz/index.js';
|
|
3
3
|
export { parseFilters, parseMetadata, MetadataError, MAX_METADATA_KEYS, MAX_METADATA_KEY_LENGTH, MAX_METADATA_LIST, MAX_METADATA_VALUE_LENGTH, } from './metadata.js';
|
|
4
|
-
export { loadConfig, loadJwtKeys, ConfigError } from './config.js';
|
|
5
|
-
export { protectedResourceMetadata, PROTECTED_RESOURCE_PATH } from './oauth.js';
|
|
4
|
+
export { loadConfig, loadJwtKeys, loadJwtVerification, keyFingerprint, ConfigError } from './config.js';
|
|
5
|
+
export { protectedResourceMetadata, PROTECTED_RESOURCE_PATH, JWKS_PATH } from './oauth.js';
|
|
6
|
+
export { activeResolver, admitIngest, ADMIN_PREFIX, adminRoutes, auditSinks, authProviders, loadModules, loadedExtensions, mountAdminRoutes, registerAuditSink, registerAuthProvider, registerAuthzResolver, registerIngestGate, resetExtensionsForTests, withAuditSinks, withLoadingModuleForTests, } from './extensions.js';
|
|
6
7
|
export { acrossOrganizations, createPool, whileAuthenticating, withOrg } from './db/client.js';
|
|
7
8
|
export { migrate, loadMigrations } from './db/migrate.js';
|
|
8
9
|
export { loadGrants, loadGroupsVersion, loadScopeTree, PostgresGroupGraph } from './authz/store.js';
|
|
9
10
|
export { explainQdrant, MetadataIndexer, METADATA_INDEX_LIMIT, VectorStore } from './vector/search.js';
|
|
10
11
|
export { MAX_AUDITED_QUERY, queryAudit } from './audit.js';
|
|
12
|
+
export { MAX_PARTS, MAX_PART_HEADER_BYTES, MultipartError, multipartBoundary, parseMultipart, } from './multipart.js';
|
|
11
13
|
export { configureLogging, createLogger, logger } from './logging.js';
|
|
12
14
|
export { documentKey, S3, S3Error } from './s3.js';
|
|
13
15
|
export { buildHybridQuery, collectionConfig, collectionName, PAYLOAD_INDEXES, vectorName } from './vector/query.js';
|
|
14
16
|
export { Counter, Gauge, Histogram, Registry, createMetrics } from './metrics.js';
|
|
15
17
|
export { collectDatabaseGauges } from './observability.js';
|
|
16
18
|
export { Redis, RedisError } from './redis.js';
|
|
17
|
-
export { reindexProgress, toStateJson, fromStateJson } from './reindex.js';
|
|
19
|
+
export { reindexProgress, toStateJson, toCheckJson, fromStateJson } from './reindex.js';
|
|
18
20
|
export { hashingLoad, hashPassword, needsRehash, spendVerificationTime, TooBusy, verifyPassword, } from './passwords.js';
|
|
19
21
|
export { installGuards, onListenError } from './lifecycle.js';
|
|
20
22
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,kBAAkB,CAAA;AAChC,OAAO,EACL,YAAY,EACZ,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,uBAAuB,EACvB,iBAAiB,EACjB,yBAAyB,GAC1B,MAAM,eAAe,C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BAAgB,CAAA;AAGvB,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAErE,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAGlD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,cAAc,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAEnH,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAEjF,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAC1D,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAE9C,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAEvF,OAAO,EACL,WAAW,EACX,YAAY,EACZ,WAAW,EACX,qBAAqB,EACrB,OAAO,EACP,cAAc,GACf,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA"}
|
package/dist/metrics.d.ts
CHANGED
|
@@ -49,7 +49,7 @@ export declare class Registry {
|
|
|
49
49
|
register<T extends Metric>(metric: T): T;
|
|
50
50
|
/**
|
|
51
51
|
* A function run before every scrape, for values that are queries rather than
|
|
52
|
-
* counters — document counts
|
|
52
|
+
* counters — document counts and pending tombstones.
|
|
53
53
|
*/
|
|
54
54
|
collect(fn: () => Promise<void>): void;
|
|
55
55
|
/**
|
|
@@ -72,22 +72,25 @@ export declare class Registry {
|
|
|
72
72
|
/**
|
|
73
73
|
* The metrics docs/config.md requires.
|
|
74
74
|
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
75
|
+
* There is deliberately no `nacre_acl_propagation_lag_seconds` here. It was the
|
|
76
|
+
* one metric with an alert on it, back when invariant I4 was temporal — a
|
|
77
|
+
* revoked grant reflected *within an SLA*, with a cache the worker had to catch
|
|
78
|
+
* up. Migration 0016 removed that cache: the permitted set is computed per
|
|
79
|
+
* request from the grants, so I4 is structural now and there is no lag to
|
|
80
|
+
* measure. A gauge that reported one would be reporting on a subsystem that no
|
|
81
|
+
* longer exists.
|
|
80
82
|
*/
|
|
81
83
|
export declare function createMetrics(registry: Registry): {
|
|
82
84
|
searchDuration: Histogram;
|
|
83
85
|
searchResults: Counter;
|
|
84
86
|
aclDenials: Counter;
|
|
85
87
|
authFailures: Counter;
|
|
86
|
-
|
|
88
|
+
rateLimitUnavailable: Counter;
|
|
87
89
|
ingestDuration: Histogram;
|
|
88
90
|
documents: Gauge;
|
|
89
91
|
reindexProgress: Gauge;
|
|
90
92
|
tombstonesPending: Gauge;
|
|
93
|
+
processingAge: Gauge;
|
|
91
94
|
collectionsRetired: Gauge;
|
|
92
95
|
};
|
|
93
96
|
export type Metrics = ReturnType<typeof createMetrics>;
|
package/dist/metrics.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../metrics.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;AAgBrD,UAAU,MAAM;IACd,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,GAAG,WAAW,CAAA;IAChD,MAAM,IAAI,MAAM,EAAE,CAAA;CACnB;AAED,qBAAa,OAAQ,YAAW,MAAM;;IAKlC,QAAQ,CAAC,IAAI,EAAE,MAAM;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM;IALvB,QAAQ,CAAC,IAAI,EAAG,SAA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,CAAC,IAAI,EAAE,MAAM;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM;IACrB,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE;IANrC,QAAQ,CAAC,IAAI,EAAG,WAAW,CAAS;gBAIzB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,SAAS,MAAM,EAAoB;IAKvD,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,GAAE,MAAW,GAAG,IAAI;IAgBnD,2EAA2E;IACrE,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAS/D,MAAM,IAAI,MAAM,EAAE;CAmBnB;AAED,qBAAa,QAAQ;;IAInB,QAAQ,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC;IAQxC;;;OAGG;IACH,OAAO,CAAC,EAAE,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;IAItC;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,QAAQ,CAAC,cAAc,SAAS;IAwCjC,MAAM,CAAC,GAAG,GAAE,MAAmB,GAAG,OAAO,CAAC,MAAM,CAAC;CAWxD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,QAAQ;;;;;;;;;;;;EAiG/C;AAED,MAAM,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAA"}
|
package/dist/metrics.js
CHANGED
|
@@ -137,7 +137,7 @@ export class Registry {
|
|
|
137
137
|
}
|
|
138
138
|
/**
|
|
139
139
|
* A function run before every scrape, for values that are queries rather than
|
|
140
|
-
* counters — document counts
|
|
140
|
+
* counters — document counts and pending tombstones.
|
|
141
141
|
*/
|
|
142
142
|
collect(fn) {
|
|
143
143
|
this.#collectors.push(fn);
|
|
@@ -208,11 +208,13 @@ _a = Registry;
|
|
|
208
208
|
/**
|
|
209
209
|
* The metrics docs/config.md requires.
|
|
210
210
|
*
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
*
|
|
215
|
-
*
|
|
211
|
+
* There is deliberately no `nacre_acl_propagation_lag_seconds` here. It was the
|
|
212
|
+
* one metric with an alert on it, back when invariant I4 was temporal — a
|
|
213
|
+
* revoked grant reflected *within an SLA*, with a cache the worker had to catch
|
|
214
|
+
* up. Migration 0016 removed that cache: the permitted set is computed per
|
|
215
|
+
* request from the grants, so I4 is structural now and there is no lag to
|
|
216
|
+
* measure. A gauge that reported one would be reporting on a subsystem that no
|
|
217
|
+
* longer exists.
|
|
216
218
|
*/
|
|
217
219
|
export function createMetrics(registry) {
|
|
218
220
|
return {
|
|
@@ -232,7 +234,12 @@ export function createMetrics(registry) {
|
|
|
232
234
|
// staying flat through the same window is the check that the rotation hit
|
|
233
235
|
// only what it was meant to.
|
|
234
236
|
authFailures: registry.register(new Counter('nacre_auth_failures_total', 'Rejected credentials, by the kind presented: missing, jwt, service_key. Never by reason — the 401 is deliberately one answer')),
|
|
235
|
-
|
|
237
|
+
// Rate limiting fails open when Redis is unreachable, deliberately — it is
|
|
238
|
+
// availability protection, not an authorization control. That is the one
|
|
239
|
+
// degradation an operator has to be able to see, because the symptom is
|
|
240
|
+
// *silence*: requests keep flowing and nothing is being counted. Every
|
|
241
|
+
// increment here is a request that was let through unmetered.
|
|
242
|
+
rateLimitUnavailable: registry.register(new Counter('nacre_rate_limit_unavailable_total', 'Requests allowed because the rate-limit check could not run (Redis unreachable), by resource')),
|
|
236
243
|
ingestDuration: registry.register(new Histogram('nacre_ingest_duration_seconds', 'Indexing latency, by stage')),
|
|
237
244
|
documents: registry.register(new Gauge('nacre_documents_total', 'Documents, by organization and status')),
|
|
238
245
|
// Specified in docs/config.md and registered by nothing until there was a
|
|
@@ -249,6 +256,17 @@ export function createMetrics(registry) {
|
|
|
249
256
|
// rather than a layer at zero: a real layer always carries a `layer` label.
|
|
250
257
|
reindexProgress: registry.register(new Gauge('nacre_reindex_progress_ratio', 'How far a layer is through a reindex, 0 to 1. Absent when no reindex has run; 0 means one started and has moved nothing')),
|
|
251
258
|
tombstonesPending: registry.register(new Gauge('nacre_tombstones_pending_total', 'Deleted documents whose vectors are not yet purged. Climbing means garbage collection is losing')),
|
|
259
|
+
// The one thing a wedged worker leaves outside its own log. The worker
|
|
260
|
+
// serves no port and has no registry — by design, so that a liveness check
|
|
261
|
+
// is not a second surface with an auth story — so a worker stuck inside one
|
|
262
|
+
// document is invisible except in the log line that stopped. This is the
|
|
263
|
+
// age of the oldest document currently claimed for indexing, per
|
|
264
|
+
// organization, computed on the API's side from `documents.claimed_at`. A
|
|
265
|
+
// series appears only while something is in flight; one that climbs past
|
|
266
|
+
// NACRE_INDEX_LEASE is a worker wedged in a document, or gone with the
|
|
267
|
+
// reaper not reclaiming it — and either way the document behind it is not
|
|
268
|
+
// getting indexed.
|
|
269
|
+
processingAge: registry.register(new Gauge('nacre_document_processing_age_seconds', 'Age of the oldest document a worker is currently indexing, by organization. Absent when nothing is in flight; past the index lease means a worker is wedged or gone')),
|
|
252
270
|
// A gauge and not a counter, because the question an operator has is "how
|
|
253
271
|
// much disk is a finished migration still holding", not "how many have I
|
|
254
272
|
// reclaimed since this process started". Each one retained is a full copy
|
package/dist/metrics.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metrics.js","sourceRoot":"","sources":["../metrics.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;;AAIH,MAAM,IAAI,GAAG,4BAA4B,CAAA;AAEzC,SAAS,WAAW,CAAC,KAAa;IAChC,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;AAChF,CAAC;AAED,SAAS,MAAM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AE,4BAA4B,CAAC,CAC7E;QACD,SAAS,EAAE,QAAQ,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC,uBAAuB,EAAE,uCAAuC,CAAC,CAAC;QACzG,0EAA0E;QAC1E,sBAAsB;QACtB,EAAE;QACF,2EAA2E;QAC3E,oEAAoE;QACpE,qEAAqE;QACrE,qDAAqD;QACrD,EAAE;QACF,2DAA2D;QAC3D,wEAAwE;QACxE,uEAAuE;QACvE,4EAA4E;QAC5E,eAAe,EAAE,QAAQ,CAAC,QAAQ,CAChC,IAAI,KAAK,CACP,8BAA8B,EAC9B,yHAAyH,CAC1H,CACF;QACD,iBAAiB,EAAE,QAAQ,CAAC,QAAQ,CAClC,IAAI,KAAK,CACP,gCAAgC,EAChC,iGAAiG,CAClG,CACF;QACD,uEAAuE;QACvE,2EAA2E;QAC3E,4EAA4E;QAC5E,yEAAyE;QACzE,iEAAiE;QACjE,0EAA0E;QAC1E,yEAAyE;QACzE,uEAAuE;QACvE,0EAA0E;QAC1E,mBAAmB;QACnB,aAAa,EAAE,QAAQ,CAAC,QAAQ,CAC9B,IAAI,KAAK,CACP,uCAAuC,EACvC,qKAAqK,CACtK,CACF;QACD,0EAA0E;QAC1E,yEAAyE;QACzE,0EAA0E;QAC1E,4EAA4E;QAC5E,uEAAuE;QACvE,gDAAgD;QAChD,kBAAkB,EAAE,QAAQ,CAAC,QAAQ,CACnC,IAAI,KAAK,CACP,iCAAiC,EACjC,sIAAsI,CACvI,CACF;KACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
-- The query set a reindex is checked against.
|
|
2
|
+
--
|
|
3
|
+
-- `docs/architecture.md` has carried a step 4 since before there was a reindex
|
|
4
|
+
-- — "the recall check against a reference query set" — and has listed it as not
|
|
5
|
+
-- built for just as long, with the reason: it is "a gate nobody can run without
|
|
6
|
+
-- a query set". This is the query set.
|
|
7
|
+
--
|
|
8
|
+
-- ─── what the gate is for ───
|
|
9
|
+
--
|
|
10
|
+
-- A migration onto a new model succeeds mechanically whether or not the new
|
|
11
|
+
-- model works. Every document gets a shadow vector, the count reaches zero,
|
|
12
|
+
-- `vector_name` moves, and search is now answered by the new slot. If the
|
|
13
|
+
-- provider was misconfigured — the right endpoint behind the wrong model name,
|
|
14
|
+
-- a truncated dimension, an embedder returning near-constant vectors — every
|
|
15
|
+
-- step still reports success and retrieval quietly collapses. There is no
|
|
16
|
+
-- failing test, no alert, and no error anywhere, because nothing failed.
|
|
17
|
+
--
|
|
18
|
+
-- The gate is the only thing in the sequence that asks whether the new model
|
|
19
|
+
-- can still answer, rather than whether the write happened.
|
|
20
|
+
--
|
|
21
|
+
-- ─── why ground truth rather than agreement with the old model ───
|
|
22
|
+
--
|
|
23
|
+
-- The cheaper design compares the new slot's answers against the old slot's and
|
|
24
|
+
-- gates on the overlap. It needs nothing from the operator, and it is wrong:
|
|
25
|
+
-- **a better model disagrees with the worse one it replaces**, so a gate on
|
|
26
|
+
-- agreement blocks exactly the migrations worth making, and passes a new model
|
|
27
|
+
-- that reproduces the old one's mistakes. What an operator means by "search
|
|
28
|
+
-- still works" is against documents they picked, which is a thing only they
|
|
29
|
+
-- have.
|
|
30
|
+
--
|
|
31
|
+
-- So the set is theirs and the gate is off until they write one. That is the
|
|
32
|
+
-- honest arrangement, and it is why this table exists rather than a constant.
|
|
33
|
+
--
|
|
34
|
+
-- ─── external ids, not document ids ───
|
|
35
|
+
--
|
|
36
|
+
-- `expected` names documents the way the operator does. A document deleted and
|
|
37
|
+
-- re-ingested is the same reference; a document id would have changed underneath
|
|
38
|
+
-- them silently and scored as a miss. The resolution to ids happens when the
|
|
39
|
+
-- check runs, and an entry that resolves to nothing **fails the check with that
|
|
40
|
+
-- reason** rather than counting as a miss — a stale reference set and a bad
|
|
41
|
+
-- model are different problems and must not produce the same number.
|
|
42
|
+
|
|
43
|
+
-- Composite keys for the cross-tenant foreign key below, the same shape 0002
|
|
44
|
+
-- gave `groups` and `users`. Without it a row could name a layer in one
|
|
45
|
+
-- organization while claiming another, and only the code writing the insert
|
|
46
|
+
-- would stop it.
|
|
47
|
+
ALTER TABLE layers ADD CONSTRAINT layers_id_org_key UNIQUE (id, org_id);
|
|
48
|
+
|
|
49
|
+
CREATE TABLE reference_queries (
|
|
50
|
+
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
51
|
+
org_id uuid NOT NULL REFERENCES organizations (id) ON DELETE CASCADE,
|
|
52
|
+
layer_id uuid NOT NULL,
|
|
53
|
+
|
|
54
|
+
-- Bounded because every one of these is an embedding round trip at the end
|
|
55
|
+
-- of a migration, and because an unbounded text column reached by an API is
|
|
56
|
+
-- a way to store something else.
|
|
57
|
+
query text NOT NULL CHECK (length(query) BETWEEN 1 AND 1024),
|
|
58
|
+
|
|
59
|
+
-- At most ten, which is the `k` the check retrieves at. A set naming more
|
|
60
|
+
-- expected documents than the check can return could never score 1.0, so
|
|
61
|
+
-- the floor would be unreachable and the operator would read it as a
|
|
62
|
+
-- regression. Refused here as well as at the API, because the two disagree
|
|
63
|
+
-- exactly when someone writes to the database by hand.
|
|
64
|
+
expected text[] NOT NULL CHECK (
|
|
65
|
+
cardinality(expected) BETWEEN 1 AND 10
|
|
66
|
+
AND array_position(expected, NULL) IS NULL
|
|
67
|
+
),
|
|
68
|
+
|
|
69
|
+
-- The operator's order, preserved. A reference set is read as a list and a
|
|
70
|
+
-- report that renumbers it every time it is fetched is a report nobody can
|
|
71
|
+
-- compare against the last one.
|
|
72
|
+
ordinal int NOT NULL,
|
|
73
|
+
created_at timestamptz NOT NULL DEFAULT now(),
|
|
74
|
+
|
|
75
|
+
CONSTRAINT reference_queries_layer_in_org
|
|
76
|
+
FOREIGN KEY (layer_id, org_id) REFERENCES layers (id, org_id) ON DELETE CASCADE,
|
|
77
|
+
CONSTRAINT reference_queries_ordinal UNIQUE (layer_id, ordinal)
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
-- The two questions asked of this table: "the set for this layer" (the API, and
|
|
81
|
+
-- the check) and "does this layer have one at all" (the switch predicate).
|
|
82
|
+
CREATE INDEX reference_queries_layer ON reference_queries (org_id, layer_id);
|
|
83
|
+
|
|
84
|
+
-- Tenant data, so RLS, and FORCE because ENABLE alone does not apply to the
|
|
85
|
+
-- owner and migrations run as the owner.
|
|
86
|
+
ALTER TABLE reference_queries ENABLE ROW LEVEL SECURITY;
|
|
87
|
+
ALTER TABLE reference_queries FORCE ROW LEVEL SECURITY;
|
|
88
|
+
|
|
89
|
+
CREATE POLICY org_isolation ON reference_queries
|
|
90
|
+
USING (org_id = current_setting('app.current_org')::uuid);
|
|
91
|
+
|
|
92
|
+
-- `nacre_app` reads and rewrites the set, because the API does. `nacre_worker`
|
|
93
|
+
-- only reads: the check must not be able to alter the thing it is checked
|
|
94
|
+
-- against, and a sweep that could delete a reference query could turn a failing
|
|
95
|
+
-- gate into a passing one by emptying it.
|
|
96
|
+
GRANT SELECT, INSERT, DELETE ON reference_queries TO nacre_app;
|
|
97
|
+
GRANT SELECT ON reference_queries TO nacre_worker;
|