@nacre.work/core 0.1.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/audit.d.ts +41 -0
- package/dist/audit.d.ts.map +1 -0
- package/dist/audit.js +18 -0
- package/dist/audit.js.map +1 -0
- package/dist/authz/cache.d.ts +20 -0
- package/dist/authz/cache.d.ts.map +1 -1
- package/dist/authz/cache.js +29 -0
- package/dist/authz/cache.js.map +1 -1
- package/dist/authz/index.d.ts +1 -2
- package/dist/authz/index.d.ts.map +1 -1
- package/dist/authz/index.js +1 -2
- package/dist/authz/index.js.map +1 -1
- package/dist/config.d.ts +132 -5
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +439 -22
- 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 +16 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -4
- package/dist/index.js.map +1 -1
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +13 -26
- package/dist/lifecycle.js.map +1 -1
- package/dist/logging.d.ts +46 -0
- package/dist/logging.d.ts.map +1 -0
- package/dist/logging.js +110 -0
- package/dist/logging.js.map +1 -0
- package/dist/metrics.d.ts +11 -7
- package/dist/metrics.d.ts.map +1 -1
- package/dist/metrics.js +32 -7
- package/dist/metrics.js.map +1 -1
- package/dist/migrations/0014_retired_collections.sql +68 -0
- 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 +43 -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/s3.d.ts +111 -0
- package/dist/s3.d.ts.map +1 -0
- package/dist/s3.js +242 -0
- package/dist/s3.js.map +1 -0
- 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 +86 -1
- package/dist/vector/search.d.ts.map +1 -1
- package/dist/vector/search.js +185 -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
package/dist/index.d.ts
CHANGED
|
@@ -2,16 +2,26 @@ 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';
|
|
12
14
|
export { migrate, loadMigrations } from './db/migrate.js';
|
|
13
15
|
export { loadGrants, loadGroupsVersion, loadScopeTree, PostgresGroupGraph } from './authz/store.js';
|
|
14
|
-
export { explainQdrant, VectorStore } from './vector/search.js';
|
|
16
|
+
export { explainQdrant, MetadataIndexer, METADATA_INDEX_LIMIT, VectorStore } from './vector/search.js';
|
|
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';
|
|
20
|
+
export type { QueryAudit } from './audit.js';
|
|
21
|
+
export { configureLogging, createLogger, logger } from './logging.js';
|
|
22
|
+
export type { Logger, LoggerOptions, LogFormat, LogLevel } from './logging.js';
|
|
23
|
+
export { documentKey, S3, S3Error } from './s3.js';
|
|
24
|
+
export type { S3Options } from './s3.js';
|
|
15
25
|
export type { Hit, SearchRequest, VectorStoreOptions } from './vector/search.js';
|
|
16
26
|
export { buildHybridQuery, collectionConfig, collectionName, PAYLOAD_INDEXES, vectorName } from './vector/query.js';
|
|
17
27
|
export type { Branch, HybridQuery } from './vector/query.js';
|
|
@@ -20,8 +30,8 @@ export type { Labels, Metrics } from './metrics.js';
|
|
|
20
30
|
export { collectDatabaseGauges } from './observability.js';
|
|
21
31
|
export { Redis, RedisError } from './redis.js';
|
|
22
32
|
export type { RedisOptions } from './redis.js';
|
|
23
|
-
export { reindexProgress, toStateJson, fromStateJson } from './reindex.js';
|
|
24
|
-
export type { ReindexState } from './reindex.js';
|
|
33
|
+
export { reindexProgress, toStateJson, toCheckJson, fromStateJson } from './reindex.js';
|
|
34
|
+
export type { ReindexState, ReindexCheck } from './reindex.js';
|
|
25
35
|
export { hashingLoad, hashPassword, needsRehash, spendVerificationTime, TooBusy, verifyPassword, } from './passwords.js';
|
|
26
36
|
export { installGuards, onListenError } from './lifecycle.js';
|
|
27
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,MAAM,eAAe,CAAA;AACtB,YAAY,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;
|
|
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,EAC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AAE,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,17 +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
|
-
export { explainQdrant, VectorStore } from './vector/search.js';
|
|
10
|
+
export { explainQdrant, MetadataIndexer, METADATA_INDEX_LIMIT, VectorStore } from './vector/search.js';
|
|
11
|
+
export { MAX_AUDITED_QUERY, queryAudit } from './audit.js';
|
|
12
|
+
export { MAX_PARTS, MAX_PART_HEADER_BYTES, MultipartError, multipartBoundary, parseMultipart, } from './multipart.js';
|
|
13
|
+
export { configureLogging, createLogger, logger } from './logging.js';
|
|
14
|
+
export { documentKey, S3, S3Error } from './s3.js';
|
|
10
15
|
export { buildHybridQuery, collectionConfig, collectionName, PAYLOAD_INDEXES, vectorName } from './vector/query.js';
|
|
11
16
|
export { Counter, Gauge, Histogram, Registry, createMetrics } from './metrics.js';
|
|
12
17
|
export { collectDatabaseGauges } from './observability.js';
|
|
13
18
|
export { Redis, RedisError } from './redis.js';
|
|
14
|
-
export { reindexProgress, toStateJson, fromStateJson } from './reindex.js';
|
|
19
|
+
export { reindexProgress, toStateJson, toCheckJson, fromStateJson } from './reindex.js';
|
|
15
20
|
export { hashingLoad, hashPassword, needsRehash, spendVerificationTime, TooBusy, verifyPassword, } from './passwords.js';
|
|
16
21
|
export { installGuards, onListenError } from './lifecycle.js';
|
|
17
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,CAAA;AAEtB,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;
|
|
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,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mB,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/lifecycle.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../lifecycle.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../lifecycle.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,MAAM,WAAW,MAAM;IACrB,kFAAkF;IAClF,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;IAC9C,8EAA8E;IAC9E,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;IACzB,gEAAgE;IAChE,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;CACvC;AAkBD;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAA;CAAE,CAmDhF;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE;IAAE,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,cAAc,KAAK,IAAI,GAAG,OAAO,CAAA;CAAE,EACzF,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,IAAI,GAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAmC,GAC1D,IAAI,CAWN"}
|
package/dist/lifecycle.js
CHANGED
|
@@ -1,26 +1,13 @@
|
|
|
1
|
+
import { logger } from './logging.js';
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
3
|
-
* die for a reason nobody wrote down.
|
|
3
|
+
* Through the process logger, so `NACRE_LOG_FORMAT` reaches these too.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* - **No `unhandledRejection` handler.** Node terminates the process on one,
|
|
10
|
-
* with a raw stack on stderr and no service name, no timestamp in the format
|
|
11
|
-
* every other line uses, and nothing to join to a request.
|
|
12
|
-
* - **No `error` listener on `listen`.** `EADDRINUSE` is emitted on the server
|
|
13
|
-
* *after* `main()` has already resolved, so `main().catch` never sees it and
|
|
14
|
-
* the careful ConfigError path — which exits 2 with an explanation — is
|
|
15
|
-
* bypassed by the one startup failure an operator hits most.
|
|
16
|
-
* - **No deadline on shutdown.** `server.close()` waits for in-flight requests
|
|
17
|
-
* with no upper bound. One request blocked on a slow dependency means the
|
|
18
|
-
* callback never runs, the pool is never released, and the orchestrator
|
|
19
|
-
* SIGKILLs at the end of its grace period — turning every rolling deploy into
|
|
20
|
-
* an abrupt one, silently.
|
|
5
|
+
* The level is a parameter rather than always `error`: a clean shutdown is not
|
|
6
|
+
* a failure, and reporting it as one is how a dashboard counting errors turns
|
|
7
|
+
* every deploy into an incident. What is an error stays an error.
|
|
21
8
|
*/
|
|
22
|
-
const log = (service, msg, extra = {}) => {
|
|
23
|
-
|
|
9
|
+
const log = (level, service, msg, extra = {}) => {
|
|
10
|
+
logger[level](msg, { service, ...extra });
|
|
24
11
|
};
|
|
25
12
|
/**
|
|
26
13
|
* Install the handlers. Returns a `stop` to call from a signal handler.
|
|
@@ -37,11 +24,11 @@ export function installGuards(guards) {
|
|
|
37
24
|
// nobody awaited failing means the process is in a state its author did not
|
|
38
25
|
// plan for, and continuing from there is how one bad request becomes a
|
|
39
26
|
// corrupt one.
|
|
40
|
-
log(service, 'unhandled rejection; exiting', { error: String(reason).slice(0, 500) });
|
|
27
|
+
log('error', service, 'unhandled rejection; exiting', { error: String(reason).slice(0, 500) });
|
|
41
28
|
exit(1);
|
|
42
29
|
});
|
|
43
30
|
process.on('uncaughtException', (error) => {
|
|
44
|
-
log(service, 'uncaught exception; exiting', {
|
|
31
|
+
log('error', service, 'uncaught exception; exiting', {
|
|
45
32
|
error: String(error).slice(0, 500),
|
|
46
33
|
stack: error.stack?.split('\n').slice(1, 6).join(' | '),
|
|
47
34
|
});
|
|
@@ -51,11 +38,11 @@ export function installGuards(guards) {
|
|
|
51
38
|
if (stopping)
|
|
52
39
|
return;
|
|
53
40
|
stopping = true;
|
|
54
|
-
log(service, 'shutting down', { signal });
|
|
41
|
+
log('info', service, 'shutting down', { signal });
|
|
55
42
|
// The deadline runs whatever happens, and `unref` keeps it from being the
|
|
56
43
|
// thing that holds the process open once everything else has let go.
|
|
57
44
|
const deadline = setTimeout(() => {
|
|
58
|
-
log(service, 'shutdown did not finish in time; exiting anyway', { grace_ms: graceMs });
|
|
45
|
+
log('error', service, 'shutdown did not finish in time; exiting anyway', { grace_ms: graceMs });
|
|
59
46
|
exit(1);
|
|
60
47
|
}, graceMs);
|
|
61
48
|
deadline.unref();
|
|
@@ -66,7 +53,7 @@ export function installGuards(guards) {
|
|
|
66
53
|
exit(0);
|
|
67
54
|
}
|
|
68
55
|
catch (error) {
|
|
69
|
-
log(service, 'shutdown failed', { error: String(error).slice(0, 500) });
|
|
56
|
+
log('error', service, 'shutdown failed', { error: String(error).slice(0, 500) });
|
|
70
57
|
clearTimeout(deadline);
|
|
71
58
|
exit(1);
|
|
72
59
|
}
|
|
@@ -90,7 +77,7 @@ export function onListenError(server, service, port, exit = (code) => process.ex
|
|
|
90
77
|
: error.code === 'EACCES'
|
|
91
78
|
? `port ${port} needs privileges this process does not have`
|
|
92
79
|
: String(error);
|
|
93
|
-
log(service, 'could not listen', { port, detail });
|
|
80
|
+
log('error', service, 'could not listen', { port, detail });
|
|
94
81
|
exit(2);
|
|
95
82
|
});
|
|
96
83
|
}
|
package/dist/lifecycle.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lifecycle.js","sourceRoot":"","sources":["../lifecycle.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"lifecycle.js","sourceRoot":"","sources":["../lifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAwCrC;;;;;;GAMG;AACH,MAAM,GAAG,GAAG,CACV,KAAuB,EACvB,OAAe,EACf,GAAW,EACX,QAAiC,EAAE,EAC7B,EAAE;IACR,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,GAAG,KAAK,EAAE,CAAC,CAAA;AAC3C,CAAC,CAAA;AAED;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,MAAc;IAC1C,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,GAAG,MAAM,EAAE,IAAI,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,MAAM,CAAA;IAC3F,IAAI,QAAQ,GAAG,KAAK,CAAA;IAEpB,OAAO,CAAC,EAAE,CAAC,oBAAoB,EAAE,CAAC,MAAM,EAAE,EAAE;QAC1C,wEAAwE;QACxE,4EAA4E;QAC5E,uEAAuE;QACvE,eAAe;QACf,GAAG,CA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AC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logging, at the level and in the format the deployment asked for.
|
|
3
|
+
*
|
|
4
|
+
* `NACRE_LOG_LEVEL` and `NACRE_LOG_FORMAT` were validated at startup and read
|
|
5
|
+
* by nothing: every process wrote structured JSON at one level, so an operator
|
|
6
|
+
* setting `warn` still got every `info` line and one setting `text` still got
|
|
7
|
+
* JSON. Both are among the first variables anyone sets.
|
|
8
|
+
*
|
|
9
|
+
* ─── what does not go through here ───
|
|
10
|
+
*
|
|
11
|
+
* **Configuration errors.** They happen before a configuration exists, so there
|
|
12
|
+
* is nothing to ask about the level, and a process that cannot start must say
|
|
13
|
+
* why whatever anyone configured. Those stay on `console.error`.
|
|
14
|
+
*
|
|
15
|
+
* **`init` and `migrate` output.** Those are commands a person runs and reads —
|
|
16
|
+
* the printed org id, the applied migrations. That is program output, like
|
|
17
|
+
* `--help`, and putting it behind a level would mean `NACRE_LOG_LEVEL=warn`
|
|
18
|
+
* silently swallows the one line the command exists to produce.
|
|
19
|
+
*
|
|
20
|
+
* ─── what a field may hold ───
|
|
21
|
+
*
|
|
22
|
+
* The same rule as everywhere else in this repository: no document contents and
|
|
23
|
+
* no full query text. This module cannot enforce that — it takes what it is
|
|
24
|
+
* given — so it is stated where the fields are named rather than here.
|
|
25
|
+
*/
|
|
26
|
+
export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
27
|
+
export type LogFormat = 'json' | 'text';
|
|
28
|
+
export interface Logger {
|
|
29
|
+
debug(message: string, fields?: Record<string, unknown>): void;
|
|
30
|
+
info(message: string, fields?: Record<string, unknown>): void;
|
|
31
|
+
warn(message: string, fields?: Record<string, unknown>): void;
|
|
32
|
+
error(message: string, fields?: Record<string, unknown>): void;
|
|
33
|
+
}
|
|
34
|
+
export interface LoggerOptions {
|
|
35
|
+
readonly level: LogLevel;
|
|
36
|
+
readonly format: LogFormat;
|
|
37
|
+
/** Injected so a test can assert on a line rather than on a moving timestamp. */
|
|
38
|
+
readonly now?: () => Date;
|
|
39
|
+
/** Injected for the same reason. Defaults to the console. */
|
|
40
|
+
readonly write?: (level: LogLevel, line: string) => void;
|
|
41
|
+
}
|
|
42
|
+
export declare function createLogger(options: LoggerOptions): Logger;
|
|
43
|
+
export declare function configureLogging(options: LoggerOptions): void;
|
|
44
|
+
/** Delegates on every call, so a module may hold this and still see the change. */
|
|
45
|
+
export declare const logger: Logger;
|
|
46
|
+
//# sourceMappingURL=logging.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logging.d.ts","sourceRoot":"","sources":["../logging.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;AAC1D,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,CAAA;AAIvC,MAAM,WAAW,MAAM;IACrB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAA;IAC9D,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAA;IAC7D,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAA;IAC7D,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAA;CAC/D;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAA;IACxB,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAA;IAC1B,iFAAiF;IACjF,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,IAAI,CAAA;IACzB,6DAA6D;IAC7D,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;CACzD;AA+BD,wBAAgB,YAAY,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,CA6B3D;AAiBD,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAE7D;AAED,mFAAmF;AACnF,eAAO,MAAM,MAAM,EAAE,MAKpB,CAAA"}
|
package/dist/logging.js
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logging, at the level and in the format the deployment asked for.
|
|
3
|
+
*
|
|
4
|
+
* `NACRE_LOG_LEVEL` and `NACRE_LOG_FORMAT` were validated at startup and read
|
|
5
|
+
* by nothing: every process wrote structured JSON at one level, so an operator
|
|
6
|
+
* setting `warn` still got every `info` line and one setting `text` still got
|
|
7
|
+
* JSON. Both are among the first variables anyone sets.
|
|
8
|
+
*
|
|
9
|
+
* ─── what does not go through here ───
|
|
10
|
+
*
|
|
11
|
+
* **Configuration errors.** They happen before a configuration exists, so there
|
|
12
|
+
* is nothing to ask about the level, and a process that cannot start must say
|
|
13
|
+
* why whatever anyone configured. Those stay on `console.error`.
|
|
14
|
+
*
|
|
15
|
+
* **`init` and `migrate` output.** Those are commands a person runs and reads —
|
|
16
|
+
* the printed org id, the applied migrations. That is program output, like
|
|
17
|
+
* `--help`, and putting it behind a level would mean `NACRE_LOG_LEVEL=warn`
|
|
18
|
+
* silently swallows the one line the command exists to produce.
|
|
19
|
+
*
|
|
20
|
+
* ─── what a field may hold ───
|
|
21
|
+
*
|
|
22
|
+
* The same rule as everywhere else in this repository: no document contents and
|
|
23
|
+
* no full query text. This module cannot enforce that — it takes what it is
|
|
24
|
+
* given — so it is stated where the fields are named rather than here.
|
|
25
|
+
*/
|
|
26
|
+
const ORDER = { debug: 10, info: 20, warn: 30, error: 40 };
|
|
27
|
+
/**
|
|
28
|
+
* `warn` and `error` to stderr, the rest to stdout.
|
|
29
|
+
*
|
|
30
|
+
* Not a style choice: a container that pipes stdout into a log shipper and
|
|
31
|
+
* leaves stderr on the terminal is a real deployment, and a failure that went
|
|
32
|
+
* to stdout with everything else is a failure nobody saw at 3am.
|
|
33
|
+
*/
|
|
34
|
+
function toConsole(level, line) {
|
|
35
|
+
if (level === 'warn')
|
|
36
|
+
console.warn(line);
|
|
37
|
+
else if (level === 'error')
|
|
38
|
+
console.error(line);
|
|
39
|
+
else
|
|
40
|
+
console.log(line);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* `key=value`, with anything ambiguous quoted.
|
|
44
|
+
*
|
|
45
|
+
* Text format is for a person reading a terminal, so it is optimised for
|
|
46
|
+
* scanning rather than for parsing — but a value containing a space or a quote
|
|
47
|
+
* still has to survive, or two fields read as one.
|
|
48
|
+
*/
|
|
49
|
+
function render(value) {
|
|
50
|
+
if (value === null)
|
|
51
|
+
return 'null';
|
|
52
|
+
if (typeof value === 'string') {
|
|
53
|
+
return /[\s"=]/.test(value) ? JSON.stringify(value) : value;
|
|
54
|
+
}
|
|
55
|
+
if (typeof value === 'number' || typeof value === 'boolean')
|
|
56
|
+
return String(value);
|
|
57
|
+
return JSON.stringify(value);
|
|
58
|
+
}
|
|
59
|
+
export function createLogger(options) {
|
|
60
|
+
const threshold = ORDER[options.level];
|
|
61
|
+
const now = options.now ?? (() => new Date());
|
|
62
|
+
const write = options.write ?? toConsole;
|
|
63
|
+
const emit = (level, message, fields) => {
|
|
64
|
+
if (ORDER[level] < threshold)
|
|
65
|
+
return;
|
|
66
|
+
const ts = now().toISOString();
|
|
67
|
+
if (options.format === 'json') {
|
|
68
|
+
// `msg` first and named the same as before, because every existing line
|
|
69
|
+
// was `{"msg": ...}` and anything already grepping for it should keep
|
|
70
|
+
// working. The level and timestamp are additions, not a replacement.
|
|
71
|
+
write(level, JSON.stringify({ level, ts, msg: message, ...fields }));
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const rest = Object.entries(fields ?? {})
|
|
75
|
+
.map(([key, value]) => ` ${key}=${render(value)}`)
|
|
76
|
+
.join('');
|
|
77
|
+
write(level, `${ts} ${level.toUpperCase().padEnd(5)} ${message}${rest}`);
|
|
78
|
+
};
|
|
79
|
+
return {
|
|
80
|
+
debug: (m, f) => emit('debug', m, f),
|
|
81
|
+
info: (m, f) => emit('info', m, f),
|
|
82
|
+
warn: (m, f) => emit('warn', m, f),
|
|
83
|
+
error: (m, f) => emit('error', m, f),
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* The process-wide logger.
|
|
88
|
+
*
|
|
89
|
+
* A module-level default that `configureLogging` replaces once the
|
|
90
|
+
* configuration is read. Deliberately the one piece of global state in this
|
|
91
|
+
* repository, and it is safe to be: it carries no authorization semantics, the
|
|
92
|
+
* worst a wrong one does is print at the wrong level, and the alternative —
|
|
93
|
+
* threading a logger through every adapter and port — buys nothing a reader of
|
|
94
|
+
* those signatures would want.
|
|
95
|
+
*
|
|
96
|
+
* The default is `info`/`json`, so a module that logs before `configureLogging`
|
|
97
|
+
* runs behaves exactly as the whole system did before this existed.
|
|
98
|
+
*/
|
|
99
|
+
let current = createLogger({ level: 'info', format: 'json' });
|
|
100
|
+
export function configureLogging(options) {
|
|
101
|
+
current = createLogger(options);
|
|
102
|
+
}
|
|
103
|
+
/** Delegates on every call, so a module may hold this and still see the change. */
|
|
104
|
+
export const logger = {
|
|
105
|
+
debug: (m, f) => current.debug(m, f),
|
|
106
|
+
info: (m, f) => current.info(m, f),
|
|
107
|
+
warn: (m, f) => current.warn(m, f),
|
|
108
|
+
error: (m, f) => current.error(m, f),
|
|
109
|
+
};
|
|
110
|
+
//# sourceMappingURL=logging.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logging.js","sourceRoot":"","sources":["../logging.ts"],"names":[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CAAC,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;KACrC,CAAA;AACH,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,IAAI,OAAO,GAAW,YAAY,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;AAErE,MAAM,UAAU,gBAAgB,CAAC,OAAsB;IACrD,OAAO,GAAG,YAAY,CAAC,OAAO,CAAC,CAAA;AACjC,CAAC;AAED,mFAAmF;AACnF,MAAM,CAAC,MAAM,MAAM,GAAW;IAC5B,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;IACpC,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;IAClC,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;IAClC,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;CACrC,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,26 @@ 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;
|
|
94
|
+
collectionsRetired: Gauge;
|
|
91
95
|
};
|
|
92
96
|
export type Metrics = ReturnType<typeof createMetrics>;
|
|
93
97
|
export {};
|
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,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AI,MAAM,EAAE;CAInB;AAID,qBAAa,SAAU,YAAW,MAAM;;IAKpC,QAAQ,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,24 @@ 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')),
|
|
270
|
+
// A gauge and not a counter, because the question an operator has is "how
|
|
271
|
+
// much disk is a finished migration still holding", not "how many have I
|
|
272
|
+
// reclaimed since this process started". Each one retained is a full copy
|
|
273
|
+
// of an organization's vectors, so a number that stays high is the signal —
|
|
274
|
+
// and a number that never falls means the sweep is not running at all,
|
|
275
|
+
// which is the state this whole table replaced.
|
|
276
|
+
collectionsRetired: registry.register(new Gauge('nacre_collections_retired_total', 'Superseded collections still held for the reindex rollback window, by organization. Each is a full copy of that organization vectors')),
|
|
252
277
|
};
|
|
253
278
|
}
|
|
254
279
|
//# sourceMappingURL=metrics.js.map
|
package/dist/metrics.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1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IAAsI,CACvI,CACF;KACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
-- The collections a reindex leaves behind.
|
|
2
|
+
--
|
|
3
|
+
-- Every model migration builds a new collection, copies every point across, and
|
|
4
|
+
-- moves `organizations.vector_collection` at the end. The old collection is
|
|
5
|
+
-- still there afterwards, holding a full copy of the organization's vectors,
|
|
6
|
+
-- and nothing has ever removed one. `runbooks/rollback-layer-reindex.md` says
|
|
7
|
+
-- so in as many words — "каждая переиндексация оставляет коллекцию … ничего их
|
|
8
|
+
-- не подчищает" — and hands the operator a shell loop.
|
|
9
|
+
--
|
|
10
|
+
-- That loop is also the wrong rule. It reads every collection Qdrant has,
|
|
11
|
+
-- subtracts the ones an organization points at, and calls the difference
|
|
12
|
+
-- orphaned. During a copy the *target* is exactly that: built, filling up, and
|
|
13
|
+
-- not yet pointed at by anything. Running the documented cleanup while a
|
|
14
|
+
-- migration is copying deletes the migration.
|
|
15
|
+
--
|
|
16
|
+
-- ─── so the record is kept, not derived ───
|
|
17
|
+
--
|
|
18
|
+
-- A row is written when the pointer moves, naming the collection it moved away
|
|
19
|
+
-- from. Nothing else is ever a candidate for deletion. A copy in progress has
|
|
20
|
+
-- no row, because the row is written by the same statement that supersedes it,
|
|
21
|
+
-- so the dangerous case is not merely avoided — it is unrepresentable.
|
|
22
|
+
--
|
|
23
|
+
-- The delay is the point of the window, not an implementation detail: D2 in the
|
|
24
|
+
-- rollback runbook is "move the pointer back", which is instant and only works
|
|
25
|
+
-- while the old collection still exists. `NACRE_COLLECTION_RETENTION_DAYS` is
|
|
26
|
+
-- how long that stays possible.
|
|
27
|
+
--
|
|
28
|
+
-- ─── what this does not cover ───
|
|
29
|
+
--
|
|
30
|
+
-- A copy that was abandoned — the reindex failed partway — leaves a target
|
|
31
|
+
-- collection with no row and no pointer, and the sweep will not touch it. That
|
|
32
|
+
-- is deliberate for now: the safe rule is "delete only what a successful
|
|
33
|
+
-- migration superseded", and widening it to "delete anything unreferenced"
|
|
34
|
+
-- brings back the race above. The runbook keeps its manual procedure for that
|
|
35
|
+
-- case alone.
|
|
36
|
+
|
|
37
|
+
CREATE TABLE retired_collections (
|
|
38
|
+
org_id uuid NOT NULL REFERENCES organizations (id) ON DELETE CASCADE,
|
|
39
|
+
-- The Qdrant collection name, which is the whole payload of a row. Not a
|
|
40
|
+
-- reference to anything: by the time this matters the collection may
|
|
41
|
+
-- already be gone, and a dangling name is the normal end state.
|
|
42
|
+
name text NOT NULL,
|
|
43
|
+
retired_at timestamptz NOT NULL DEFAULT now(),
|
|
44
|
+
|
|
45
|
+
-- One row per name per organization. A second migration away from the same
|
|
46
|
+
-- collection cannot happen — the pointer only ever leaves a name once — but
|
|
47
|
+
-- an idempotent insert is cheaper to reason about than a proof that it
|
|
48
|
+
-- cannot repeat.
|
|
49
|
+
PRIMARY KEY (org_id, name)
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
-- The sweep asks one question: which rows are older than the window. It asks it
|
|
53
|
+
-- across organizations, so the index is on the timestamp alone.
|
|
54
|
+
CREATE INDEX retired_collections_due ON retired_collections (retired_at);
|
|
55
|
+
|
|
56
|
+
-- Tenant data, so RLS, and FORCE because ENABLE alone does not apply to the
|
|
57
|
+
-- owner and migrations run as the owner.
|
|
58
|
+
ALTER TABLE retired_collections ENABLE ROW LEVEL SECURITY;
|
|
59
|
+
ALTER TABLE retired_collections FORCE ROW LEVEL SECURITY;
|
|
60
|
+
|
|
61
|
+
CREATE POLICY org_isolation ON retired_collections
|
|
62
|
+
USING (org_id = current_setting('app.current_org')::uuid);
|
|
63
|
+
|
|
64
|
+
-- `nacre_app` inserts, because the pointer moves under `withOrg` in the worker's
|
|
65
|
+
-- copy phase and that runs as the application role. `nacre_worker` deletes,
|
|
66
|
+
-- because the sweep runs across organizations.
|
|
67
|
+
GRANT SELECT, INSERT ON retired_collections TO nacre_app;
|
|
68
|
+
GRANT SELECT, INSERT, DELETE ON retired_collections TO nacre_worker;
|