@ultimat3/ai 31.40.0 → 31.40.1
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/CLAUDE.md +1 -1
- package/README.md +9 -6
- package/package.json +11 -11
- package/src/vector-scope.ts +14 -9
package/CLAUDE.md
CHANGED
|
@@ -268,7 +268,7 @@ One switch (`GenerateRequest.promptCache`), `promptCacheRule`: provider rows (`P
|
|
|
268
268
|
|
|
269
269
|
In brief ([full text](../../docs/history/ai.md#evals-retrieval-fix-lines)): no fix line names
|
|
270
270
|
an `ai` command (none exists); an eval gates on the DROP from its baseline, mean AND per case, and every prompt has one;
|
|
271
|
-
retrieval is hybrid only; an unbound store
|
|
271
|
+
retrieval is hybrid only; an unbound store used in any request, by any actor, is `X_VECTOR_UNSCOPED`;
|
|
272
272
|
`postgresVectorStore()` filters tenant and policy in SQL on every statement (hnsw reads widen the
|
|
273
273
|
scan, `pg-vector-recall.ts`); `scoped()` TIGHTENS.
|
|
274
274
|
|
package/README.md
CHANGED
|
@@ -1100,11 +1100,14 @@ Allow-lists are default deny: a row missing the key is invisible, and an empty l
|
|
|
1100
1100
|
nothing. `scoped()` only ever **tightens** — re-scoping to a different tenant is
|
|
1101
1101
|
`X_VECTOR_SCOPE_WIDENED`, never a silent widening.
|
|
1102
1102
|
|
|
1103
|
-
A store opened without a scope binds no tenant, and **reading or writing it inside
|
|
1104
|
-
|
|
1105
|
-
`
|
|
1106
|
-
|
|
1107
|
-
|
|
1103
|
+
A store opened without a scope binds no tenant, and **reading or writing it inside any request is
|
|
1104
|
+
`X_VECTOR_UNSCOPED`** — `search`, `searchText`, `hybrid`, `upsert`, `prune`, `delete`, so
|
|
1105
|
+
`indexDocument()` too, whoever the actor: an org's, an org-less user's, anonymous, a `tenant: 'none'`
|
|
1106
|
+
job's. The forgotten `.scoped()` searched every tenant's rows, deleted every tenant's row sharing an
|
|
1107
|
+
id, or wrote into the shared no-tenant bucket; an actor with no org has no tenant to be confined to,
|
|
1108
|
+
so it reached every org too — the actors `entity` refuses as `X_TENANCY_ACTOR_ORG_REQUIRED`.
|
|
1109
|
+
Outside any request (a script, a boot task) it reads and writes as written, as entity derives
|
|
1110
|
+
nothing there either. The backfill path and a single-tenant app opt in by name:
|
|
1108
1111
|
`postgresVectorStore({ name, dimension, scope: UNSCOPED })`, or `store.scoped(UNSCOPED)`.
|
|
1109
1112
|
|
|
1110
1113
|
`chunkDocument()` is token-aware with overlap and splits at paragraph, then sentence, then hard wrap
|
|
@@ -1178,7 +1181,7 @@ fail-closed `terminal` default.
|
|
|
1178
1181
|
| `X_EVAL_THRESHOLD` | an eval scored below its bar |
|
|
1179
1182
|
| `X_VECTOR_DIM_MISMATCH` | a vector's length disagrees with the store |
|
|
1180
1183
|
| `X_VECTOR_SCOPE_WIDENED` | a derived vector scope tried to leave the tenant it was bound to |
|
|
1181
|
-
| `X_VECTOR_UNSCOPED` | a store with no tenant bound was read or written inside a request
|
|
1184
|
+
| `X_VECTOR_UNSCOPED` | a store with no tenant bound was read or written inside a request, for any actor; `scope: UNSCOPED` is the named opt-out |
|
|
1182
1185
|
| `X_NOT_IMPLEMENTED` | a remote driver with no key or transport; the fix names the env var |
|
|
1183
1186
|
|
|
1184
1187
|
A failure thrown after a provider call was started carries what the run was billed on `meta.billed` (`billedOf(error)` → `{ usage, cost, calls, unsettled }`); `unsettled` counts the calls whose bill cannot be known. [Agents → Unattended runs](https://github.com/developerz-ai/ultimate/wiki/Agents#unattended-runs).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultimat3/ai",
|
|
3
|
-
"version": "31.40.
|
|
3
|
+
"version": "31.40.1",
|
|
4
4
|
"description": "LLM gateway, versioned prompts, evals as tests, embeddings, hybrid vector search, RAG",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ultimate",
|
|
@@ -45,17 +45,17 @@
|
|
|
45
45
|
"test": "bun test"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@ultimat3/action": "31.40.
|
|
49
|
-
"@ultimat3/cache": "31.40.
|
|
50
|
-
"@ultimat3/core": "31.40.
|
|
51
|
-
"@ultimat3/db": "31.40.
|
|
52
|
-
"@ultimat3/http": "31.40.
|
|
53
|
-
"@ultimat3/jobs": "31.40.
|
|
54
|
-
"@ultimat3/money": "31.40.
|
|
55
|
-
"@ultimat3/schema": "31.40.
|
|
56
|
-
"@ultimat3/time": "31.40.
|
|
48
|
+
"@ultimat3/action": "31.40.1",
|
|
49
|
+
"@ultimat3/cache": "31.40.1",
|
|
50
|
+
"@ultimat3/core": "31.40.1",
|
|
51
|
+
"@ultimat3/db": "31.40.1",
|
|
52
|
+
"@ultimat3/http": "31.40.1",
|
|
53
|
+
"@ultimat3/jobs": "31.40.1",
|
|
54
|
+
"@ultimat3/money": "31.40.1",
|
|
55
|
+
"@ultimat3/schema": "31.40.1",
|
|
56
|
+
"@ultimat3/time": "31.40.1"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@ultimat3/policy": "31.40.
|
|
59
|
+
"@ultimat3/policy": "31.40.1"
|
|
60
60
|
}
|
|
61
61
|
}
|
package/src/vector-scope.ts
CHANGED
|
@@ -19,7 +19,7 @@ export interface VectorScope {
|
|
|
19
19
|
readonly allow?: Readonly<Record<string, readonly string[]>> | undefined;
|
|
20
20
|
/**
|
|
21
21
|
* Every tenant, ON PURPOSE — `UNSCOPED`'s mark, and the only way a read with no tenant bound
|
|
22
|
-
* runs inside a request
|
|
22
|
+
* runs inside a request. Meaningless once a tenant is bound, so dropped then.
|
|
23
23
|
*/
|
|
24
24
|
readonly crossTenant?: true | undefined;
|
|
25
25
|
}
|
|
@@ -27,7 +27,7 @@ export interface VectorScope {
|
|
|
27
27
|
/**
|
|
28
28
|
* Every tenant, every row, named on purpose: the backfill and migration path. Pass it as a
|
|
29
29
|
* store's `scope` (or `.scoped(UNSCOPED)`) where a cross-tenant read is the point. A store opened
|
|
30
|
-
* with no scope binds no tenant either, but reading it inside
|
|
30
|
+
* with no scope binds no tenant either, but reading or writing it inside any request is refused.
|
|
31
31
|
*/
|
|
32
32
|
export const UNSCOPED: VectorScope = Object.freeze({ crossTenant: true });
|
|
33
33
|
|
|
@@ -58,16 +58,20 @@ export function narrowScope(store: string, base: VectorScope, next: VectorScope)
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
/**
|
|
61
|
-
* Refuse any statement — read or write — that would reach every tenant inside a request
|
|
62
|
-
*
|
|
61
|
+
* Refuse any statement — read or write — that would reach every tenant from inside a request.
|
|
62
|
+
* Entities derive the tenant from the ambient actor; a vector store is bound by
|
|
63
63
|
* `.scoped({ tenant })`, and a forgotten call answered with every org's rows, deleted every org's
|
|
64
64
|
* rows sharing an id (the key is `(tenant, id)`, so ids collide across tenants by design), or wrote
|
|
65
|
-
* into the shared no-tenant bucket.
|
|
66
|
-
* tenant
|
|
65
|
+
* into the shared no-tenant bucket. An actor with no org is no exception: anonymous, an org-less
|
|
66
|
+
* user and a `tenant: 'none'` job have NO tenant to be confined to, so an unbound statement under
|
|
67
|
+
* them reached every org — the same actors `entity`'s `actorTenant` refuses
|
|
68
|
+
* (`X_TENANCY_ACTOR_ORG_REQUIRED`). A single-tenant app says so once, with `scope: UNSCOPED`.
|
|
69
|
+
* Outside any request (a script, a boot task) there is no identity to confine, and entity derives
|
|
70
|
+
* nothing there either: the statement runs as written.
|
|
67
71
|
*/
|
|
68
72
|
export function assertTenantBound(store: string, scope: VectorScope): void {
|
|
69
73
|
if (scope.tenant !== undefined || scope.crossTenant === true) return;
|
|
70
|
-
if (tryUseContext()
|
|
74
|
+
if (tryUseContext() === undefined) return;
|
|
71
75
|
throw new VectorUnscopedError({ store });
|
|
72
76
|
}
|
|
73
77
|
|
|
@@ -78,8 +82,9 @@ export class VectorUnscopedError extends UltimateError {
|
|
|
78
82
|
code: 'X_VECTOR_UNSCOPED',
|
|
79
83
|
cause:
|
|
80
84
|
`vector store "${input.store}" was read or written with no tenant bound, inside a request ` +
|
|
81
|
-
'
|
|
82
|
-
'cross-tenant read or write (a backfill, a
|
|
85
|
+
'— the statement would reach every tenant’s rows, whoever the actor (an org-less or ' +
|
|
86
|
+
'anonymous one included). A deliberate cross-tenant read or write (a backfill, a ' +
|
|
87
|
+
'migration, a single-tenant app) opens the store with scope: UNSCOPED',
|
|
83
88
|
fix: 'vectorStore.scoped({ tenant: ctx.actor.orgId })',
|
|
84
89
|
});
|
|
85
90
|
}
|