@eagleoutice/flowr 2.15.4 → 2.15.5
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/config.d.ts +2 -0
- package/config.js +2 -1
- package/dataflow/environments/frame-memory.d.ts +19 -0
- package/dataflow/environments/frame-memory.js +53 -1
- package/dataflow/environments/resolve-by-name.js +7 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +16 -4
- package/linter/rules/unescaped-arguments.js +43 -3
- package/package.json +1 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +4 -0
- package/project/sigdb/reader.d.ts +4 -2
- package/project/sigdb/reader.js +9 -4
- package/util/version.js +2 -2
package/config.d.ts
CHANGED
|
@@ -158,6 +158,8 @@ export interface FlowrConfig {
|
|
|
158
158
|
readonly loadProjectDependencies: boolean;
|
|
159
159
|
readonly eagerlyLoad: boolean;
|
|
160
160
|
readonly eagerlyLoadExports: boolean;
|
|
161
|
+
/** How many MiB of decoded package blobs every open bundle may hold together; a bigger budget re-reads and re-parses less, a smaller one keeps less in memory (default `16`). */
|
|
162
|
+
readonly blobCacheBudgetMb?: number;
|
|
161
163
|
/**
|
|
162
164
|
* R version assumed when resolving versioned (base-R) exports: a pin, or `"auto"` to detect the installed R
|
|
163
165
|
* (falling back to {@link DefaultAssumedRVersion} if none, e.g. tree-sitter). See {@link resolveAssumedRVersion}.
|
package/config.js
CHANGED
|
@@ -292,7 +292,7 @@ exports.FlowrConfig = {
|
|
|
292
292
|
variables: VariableResolve.Alias,
|
|
293
293
|
evalStrings: true,
|
|
294
294
|
trackEnvironments: true,
|
|
295
|
-
sigdb: { enabled: true, loadProjectDependencies: true, eagerlyLoad: false, eagerlyLoadExports: false, assumedRVersion: 'auto', linkBaseR: false, linkDescriptionDependencies: false, linkBaseRCalls: false, linkPackageCalls: false, warmInBackground: false, additionalPaths: [], autoSync: false, versionSelection: VersionSelection.Newest, versionOverrides: {}, installedLibrary: { enabled: false, paths: [], useEnvironment: true, useProjectLibrary: true, maxDepth: 3, packages: [] } },
|
|
295
|
+
sigdb: { enabled: true, loadProjectDependencies: true, eagerlyLoad: false, eagerlyLoadExports: false, blobCacheBudgetMb: 16, assumedRVersion: 'auto', linkBaseR: false, linkDescriptionDependencies: false, linkBaseRCalls: false, linkPackageCalls: false, warmInBackground: false, additionalPaths: [], autoSync: false, versionSelection: VersionSelection.Newest, versionOverrides: {}, installedLibrary: { enabled: false, paths: [], useEnvironment: true, useProjectLibrary: true, maxDepth: 3, packages: [] } },
|
|
296
296
|
versionManagement: { linkedVersionGroups: [] },
|
|
297
297
|
resolveSource: {
|
|
298
298
|
dropPaths: DropPathsOption.No,
|
|
@@ -441,6 +441,7 @@ exports.FlowrConfig = {
|
|
|
441
441
|
maxDepth: joi_1.default.number().optional().description('How far to descend into the nested layout of a project-local library (default 3).'),
|
|
442
442
|
packages: joi_1.default.array().items(joi_1.default.string()).optional().description('Only recover packages whose name matches one of these regular expressions; empty means any.')
|
|
443
443
|
}).optional().description('Recovering packages no signature database knows from the copy installed on this machine.'),
|
|
444
|
+
blobCacheBudgetMb: joi_1.default.number().min(0).optional().description('How many MiB of decoded package blobs every open bundle may hold together (default 16).'),
|
|
444
445
|
versionSelection: joi_1.default.string().valid(...Object.values(VersionSelection)).optional().description('When a project constrains a dependency, resolve to the newest (default), oldest, or system-installed version satisfying it; system needs R and falls back to newest. Base-R packages always resolve against the assumed R version.'),
|
|
445
446
|
versionOverrides: joi_1.default.object().pattern(joi_1.default.string(), joi_1.default.string()).optional().description('Force an exact version for specific packages (name -> version), overriding both the project constraint and the versionSelection policy (default {}).')
|
|
446
447
|
}).description('Resolving library exports from a signature database.'),
|
|
@@ -82,3 +82,22 @@ export declare class WritableMemory {
|
|
|
82
82
|
get(name: BrandedIdentifier): IdentifierDefinition[] | undefined;
|
|
83
83
|
has(name: BrandedIdentifier): boolean;
|
|
84
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* The bindings of an attached package, built one name at a time. An attach used to materialize a definition per
|
|
87
|
+
* export, and a script attaching a handful of packages carries hundreds of thousands of them for the few dozen
|
|
88
|
+
* names it ever mentions. Here the export list is all that is held until a lookup asks for one.
|
|
89
|
+
*/
|
|
90
|
+
export declare class LazyBindings implements ReadonlyMap<BrandedIdentifier, IdentifierDefinition[]> {
|
|
91
|
+
private readonly names;
|
|
92
|
+
private readonly bind;
|
|
93
|
+
private readonly built;
|
|
94
|
+
constructor(names: ReadonlySet<BrandedIdentifier>, bind: (name: BrandedIdentifier) => IdentifierDefinition[]);
|
|
95
|
+
get(name: BrandedIdentifier): IdentifierDefinition[] | undefined;
|
|
96
|
+
has(name: BrandedIdentifier): boolean;
|
|
97
|
+
get size(): number;
|
|
98
|
+
keys(): MapIterator<BrandedIdentifier>;
|
|
99
|
+
entries(): MapIterator<[BrandedIdentifier, IdentifierDefinition[]]>;
|
|
100
|
+
[Symbol.iterator](): MapIterator<[BrandedIdentifier, IdentifierDefinition[]]>;
|
|
101
|
+
values(): MapIterator<IdentifierDefinition[]>;
|
|
102
|
+
forEach(fn: (defs: IdentifierDefinition[], name: BrandedIdentifier, map: ReadonlyMap<BrandedIdentifier, IdentifierDefinition[]>) => void, thisArg?: unknown): void;
|
|
103
|
+
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @module
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.WritableMemory = exports.MemoryView = exports.Frame = void 0;
|
|
10
|
+
exports.LazyBindings = exports.WritableMemory = exports.MemoryView = exports.Frame = void 0;
|
|
11
11
|
const assert_1 = require("../../util/assert");
|
|
12
12
|
/** the index in `history` of what the greatest version at most `version` bound, `-1` if unbound then */
|
|
13
13
|
function at(history, version) {
|
|
@@ -238,4 +238,56 @@ class WritableMemory {
|
|
|
238
238
|
}
|
|
239
239
|
}
|
|
240
240
|
exports.WritableMemory = WritableMemory;
|
|
241
|
+
/**
|
|
242
|
+
* The bindings of an attached package, built one name at a time. An attach used to materialize a definition per
|
|
243
|
+
* export, and a script attaching a handful of packages carries hundreds of thousands of them for the few dozen
|
|
244
|
+
* names it ever mentions. Here the export list is all that is held until a lookup asks for one.
|
|
245
|
+
*/
|
|
246
|
+
class LazyBindings {
|
|
247
|
+
names;
|
|
248
|
+
bind;
|
|
249
|
+
built = new Map();
|
|
250
|
+
constructor(names, bind) {
|
|
251
|
+
this.names = names;
|
|
252
|
+
this.bind = bind;
|
|
253
|
+
}
|
|
254
|
+
get(name) {
|
|
255
|
+
if (!this.names.has(name)) {
|
|
256
|
+
return undefined;
|
|
257
|
+
}
|
|
258
|
+
let defs = this.built.get(name);
|
|
259
|
+
if (defs === undefined) {
|
|
260
|
+
this.built.set(name, defs = this.bind(name));
|
|
261
|
+
}
|
|
262
|
+
return defs;
|
|
263
|
+
}
|
|
264
|
+
has(name) {
|
|
265
|
+
return this.names.has(name);
|
|
266
|
+
}
|
|
267
|
+
get size() {
|
|
268
|
+
return this.names.size;
|
|
269
|
+
}
|
|
270
|
+
keys() {
|
|
271
|
+
return this.names.keys();
|
|
272
|
+
}
|
|
273
|
+
*entries() {
|
|
274
|
+
for (const name of this.names) {
|
|
275
|
+
yield [name, this.get(name)];
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
[Symbol.iterator]() {
|
|
279
|
+
return this.entries();
|
|
280
|
+
}
|
|
281
|
+
*values() {
|
|
282
|
+
for (const [, defs] of this.entries()) {
|
|
283
|
+
yield defs;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
forEach(fn, thisArg) {
|
|
287
|
+
for (const [name, defs] of this.entries()) {
|
|
288
|
+
fn.call(thisArg, defs, name, this);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
exports.LazyBindings = LazyBindings;
|
|
241
293
|
//# sourceMappingURL=frame-memory.js.map
|
|
@@ -10,6 +10,8 @@ const identifier_1 = require("./identifier");
|
|
|
10
10
|
const info_1 = require("../info");
|
|
11
11
|
const built_in_s_seven_dispatch_1 = require("../internal/process/functions/call/built-in/built-in-s-seven-dispatch");
|
|
12
12
|
const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
13
|
+
/** how many answers a frozen layer memoizes before it starts over, so the memo cannot grow without bound */
|
|
14
|
+
const TailCacheCap = 4096;
|
|
13
15
|
/** A namespaced lookup only sees its matching layer; a bare lookup skips loaded-but-unattached namespaces (`requireNamespace`). */
|
|
14
16
|
function layerSkipped(layer, ns) {
|
|
15
17
|
if (ns !== undefined) {
|
|
@@ -164,7 +166,11 @@ function resolveByTargetType(id, environment, target) {
|
|
|
164
166
|
? (builtIns === undefined || builtIns.length === 0 ? definitions : definitions.concat(builtIns))
|
|
165
167
|
: (builtIns === undefined || builtIns.length > 0 ? builtIns : undefined);
|
|
166
168
|
if (flattenAt !== undefined) {
|
|
167
|
-
|
|
169
|
+
const memo = flattenAt.tailCache ??= new Map();
|
|
170
|
+
if (memo.size >= TailCacheCap) {
|
|
171
|
+
memo.clear();
|
|
172
|
+
}
|
|
173
|
+
memo.set(key, result);
|
|
168
174
|
}
|
|
169
175
|
return result;
|
|
170
176
|
}
|
|
@@ -22,6 +22,7 @@ const logger_1 = require("../../../../../logger");
|
|
|
22
22
|
const r_string_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-string");
|
|
23
23
|
const type_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/type");
|
|
24
24
|
const make_argument_1 = require("../argument/make-argument");
|
|
25
|
+
const frame_memory_1 = require("../../../../../environments/frame-memory");
|
|
25
26
|
const identifier_1 = require("../../../../../environments/identifier");
|
|
26
27
|
const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-name");
|
|
27
28
|
const environment_1 = require("../../../../../environments/environment");
|
|
@@ -350,6 +351,17 @@ function selectExports(callables, spec) {
|
|
|
350
351
|
}
|
|
351
352
|
return callables.filter(c => !spec.exclude?.has(c)).map(c => ({ exported: c, as: c }));
|
|
352
353
|
}
|
|
354
|
+
/**
|
|
355
|
+
* What a package's attached layer binds, built per name on the first lookup. An attach names thousands of exports
|
|
356
|
+
* and a script mentions a few dozen, so the definitions are only made for the ones something asks about.
|
|
357
|
+
*/
|
|
358
|
+
function lazyExports(pack, exports, ctx, definedAt) {
|
|
359
|
+
const byName = new Map();
|
|
360
|
+
for (const exp of exports) {
|
|
361
|
+
byName.set(identifier_1.Identifier.getName(identifier_1.Identifier.make(exp.as, pack)), exp);
|
|
362
|
+
}
|
|
363
|
+
return new frame_memory_1.LazyBindings(new Set(byName.keys()), name => [exportDefinition(pack, byName.get(name), ctx, definedAt)]);
|
|
364
|
+
}
|
|
353
365
|
/**
|
|
354
366
|
* The identifier definition binding a package export (or its alias) to its built-in function-definition.
|
|
355
367
|
* The identity stays the plain export (so a call still materializes its `built-in:pkg:fn` vertex); whatever the configuration states about that name (processor, config, eval handler) rides along on top.
|
|
@@ -392,15 +404,15 @@ function attachDependencyToEnvironment(dependency, envInfo, ctx, spec = {}, defi
|
|
|
392
404
|
// a subset import restricts the attached exports, so no imports layer is materialized
|
|
393
405
|
if (spec.namespaceOnly || (spec.include !== undefined && !spec.all)) {
|
|
394
406
|
const layerType = spec.namespaceOnly ? environment_1.EnvType.LoadedNamespace : environment_1.EnvType.Namespace;
|
|
395
|
-
const layer = new environment_1.Environment(envInfo.current).asLibrary(pack, layerType)
|
|
396
|
-
|
|
407
|
+
const layer = new environment_1.Environment(envInfo.current).asLibrary(pack, layerType);
|
|
408
|
+
layer.adoptMap(lazyExports(pack, exports, ctx, definedAt));
|
|
397
409
|
return { level: envInfo.level, current: environment_1.REnvironment.attachAt(envInfo.current, layer, layer, spec.pos) };
|
|
398
410
|
}
|
|
399
411
|
// full attach: imports layer at the bottom, namespace (exports) layer on top
|
|
400
412
|
let importsEnv = new environment_1.Environment(envInfo.current).asLibrary(pack, environment_1.EnvType.Imports);
|
|
401
413
|
importsEnv = recImports(importsEnv, dependency.namespaceInfo, ctx, new Set());
|
|
402
|
-
const namespaceEnv = new environment_1.Environment(importsEnv).asLibrary(pack, environment_1.EnvType.Namespace)
|
|
403
|
-
|
|
414
|
+
const namespaceEnv = new environment_1.Environment(importsEnv).asLibrary(pack, environment_1.EnvType.Namespace);
|
|
415
|
+
namespaceEnv.adoptMap(lazyExports(pack, exports, ctx, definedAt));
|
|
404
416
|
const attached = { level: envInfo.level, current: environment_1.REnvironment.attachAt(envInfo.current, namespaceEnv, importsEnv, spec.pos) };
|
|
405
417
|
/* whatever R puts on the search path with it, `pack` first so a dependency cycle stays finite (the guard above stops it) */
|
|
406
418
|
return (0, attached_packages_1.attachedAlongside)(pack, ctx.deps.signatureSources()).reduce((env, alongside) => {
|
|
@@ -11,6 +11,7 @@ const vertex_1 = require("../../dataflow/graph/vertex");
|
|
|
11
11
|
const identify_link_to_last_call_relation_1 = require("../../queries/catalog/call-context-query/identify-link-to-last-call-relation");
|
|
12
12
|
const input_source_functions_1 = require("../../queries/catalog/input-sources-query/input-source-functions");
|
|
13
13
|
const simple_input_classifier_1 = require("../../queries/catalog/input-sources-query/simple-input-classifier");
|
|
14
|
+
const edge_1 = require("../../dataflow/graph/edge");
|
|
14
15
|
const model_1 = require("../../r-bridge/lang-4.x/ast/model/model");
|
|
15
16
|
const flowr_search_builder_1 = require("../../search/flowr-search-builder");
|
|
16
17
|
const parse_1 = require("../../slicing/criterion/parse");
|
|
@@ -35,6 +36,8 @@ var UnescapedArgumentCategory;
|
|
|
35
36
|
/** Functions generating/running JavaScript code, e.g. `shinyjs::runjs` */
|
|
36
37
|
UnescapedArgumentCategory["JavaScript"] = "javascript";
|
|
37
38
|
})(UnescapedArgumentCategory || (exports.UnescapedArgumentCategory = UnescapedArgumentCategory = {}));
|
|
39
|
+
/** how many vertices {@link readsParameter} may visit before it gives up on finding one */
|
|
40
|
+
const ParameterSearchLimit = 256;
|
|
38
41
|
/** Maximum depth to descent to find unescaped part of argument */
|
|
39
42
|
const MaxDescentDepth = 5;
|
|
40
43
|
/** Input types that are considered to be safe */
|
|
@@ -111,6 +114,36 @@ function mapInputSourceToArgs(call, sources) {
|
|
|
111
114
|
}
|
|
112
115
|
return result;
|
|
113
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
* Whether anything `start` reads is a parameter of an enclosing function. What the call sites happen to pass says
|
|
119
|
+
* nothing here: the function escapes its parameter, and it is one call away from being handed anything at all.
|
|
120
|
+
*/
|
|
121
|
+
function readsParameter(graph, start, sanitizers) {
|
|
122
|
+
const seen = new Set([start]);
|
|
123
|
+
const queue = [start];
|
|
124
|
+
while (queue.length > 0) {
|
|
125
|
+
const id = queue.pop();
|
|
126
|
+
if (graph.idMap?.get(id)?.info.role === "param-n" /* RoleInParent.ParameterName */) {
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
129
|
+
const vertex = graph.getVertex(id);
|
|
130
|
+
/* what a sanitizer hands back is escaped, whatever it read to get there */
|
|
131
|
+
if (vertex_1.FunctionCallVertex.is(vertex) && sanitizers.has(identifier_1.Identifier.getName(vertex.name))) {
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
if (seen.size > ParameterSearchLimit) {
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
for (const [to, edge] of graph.outgoingEdges(id) ?? graph_1.NoEdges) {
|
|
138
|
+
/* only what the value is built from, never the calls it is an argument of */
|
|
139
|
+
if (!seen.has(to) && edge_1.DfEdge.includesType(edge, edge_1.EdgeType.Reads | edge_1.EdgeType.DefinedBy | edge_1.EdgeType.Returns)) {
|
|
140
|
+
seen.add(to);
|
|
141
|
+
queue.push(to);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
114
147
|
function isAcceptedInput(source, config) {
|
|
115
148
|
return source.types.every(type => config.acceptedInputs.includes(type));
|
|
116
149
|
}
|
|
@@ -121,6 +154,7 @@ function isCertainlyCritical(source, config) {
|
|
|
121
154
|
* Gets all unescaped sources for the critical target calls of the given category
|
|
122
155
|
*/
|
|
123
156
|
async function getUnescapedSources(category, targets, config, data, graph) {
|
|
157
|
+
const sanitizerNames = new Set((config.categories[category].sanitizers ?? []).map(call => identifier_1.Identifier.getName(call)));
|
|
124
158
|
const sanitizers = (config.categories[category].sanitizers ?? []).map(call => ({ call }));
|
|
125
159
|
const queryConfig = { narrowing: [...(0, input_source_functions_1.narrowingFunctions)(), ...sanitizers] };
|
|
126
160
|
const found = new Map();
|
|
@@ -137,14 +171,20 @@ async function getUnescapedSources(category, targets, config, data, graph) {
|
|
|
137
171
|
}
|
|
138
172
|
for (const [arg, source] of mapInputSourceToArgs(call, classified[parse_1.SlicingCriterion.fromId(entry.call)] ?? [])) {
|
|
139
173
|
const vertex = graph.getVertex(arg);
|
|
140
|
-
|
|
174
|
+
/* a call passing a constant today makes the argument constant, but the function still escapes its
|
|
175
|
+
parameter, and it is one call away from being handed anything */
|
|
176
|
+
const viaParameter = isAcceptedInput(source, config)
|
|
177
|
+
&& source.types.length > 0 && source.types.every(t => t === simple_input_classifier_1.InputType.Constant || t === simple_input_classifier_1.InputType.DerivedConstant)
|
|
178
|
+
&& readsParameter(graph, arg, sanitizerNames);
|
|
179
|
+
if ((entry.only !== undefined && !entry.only.has(arg)) || (isAcceptedInput(source, config) && !viaParameter)) {
|
|
141
180
|
continue;
|
|
142
181
|
}
|
|
143
|
-
else if (entry.depth < config.maxDecentDepth && source.trace === simple_input_classifier_1.InputTraceType.Known && vertex_1.FunctionCallVertex.is(vertex) && !vertex_1.FunctionCallVertex.hasOrigin(vertex, built_in_proc_name_1.BuiltInProcName.Access)) {
|
|
182
|
+
else if (entry.depth < config.maxDecentDepth && (source.trace === simple_input_classifier_1.InputTraceType.Known || viaParameter) && vertex_1.FunctionCallVertex.is(vertex) && !vertex_1.FunctionCallVertex.hasOrigin(vertex, built_in_proc_name_1.BuiltInProcName.Access)) {
|
|
144
183
|
next.push({ target: entry.target, call: arg, only: undefined, depth: entry.depth + 1 });
|
|
145
184
|
}
|
|
146
185
|
else {
|
|
147
|
-
|
|
186
|
+
const types = viaParameter ? [...source.types, simple_input_classifier_1.InputType.Parameter] : source.types;
|
|
187
|
+
found.set(entry.target, [...(found.get(entry.target) ?? []), { ...source, id: arg, types }]);
|
|
148
188
|
}
|
|
149
189
|
}
|
|
150
190
|
}
|
package/package.json
CHANGED
package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js
CHANGED
|
@@ -217,6 +217,10 @@ class FlowrAnalyzerPackageVersionsSigDbPlugin extends flowr_analyzer_package_ver
|
|
|
217
217
|
this.resetAssembled(); // reload on (re)registration so config/source changes take effect (shared bundles are reused)
|
|
218
218
|
this.analyzerCtx = ctx;
|
|
219
219
|
if ((0, config_1.isSigDbEnabled)(ctx.config)) {
|
|
220
|
+
const budgetMb = ctx.config.solver.sigdb.blobCacheBudgetMb;
|
|
221
|
+
if (budgetMb !== undefined) {
|
|
222
|
+
(0, reader_1.setBlobCacheBudget)(budgetMb * 1024 * 1024);
|
|
223
|
+
}
|
|
220
224
|
ctx.deps.addLazyResolver((name, existing) => this.resolve(name, existing));
|
|
221
225
|
if (ctx.config.solver.sigdb.warmInBackground) {
|
|
222
226
|
this.startBackgroundWarm();
|
|
@@ -137,13 +137,15 @@ export interface OpenSyncOptions {
|
|
|
137
137
|
export interface OpenSyncFromOptions extends SigDbOpenOptions, OpenSyncOptions {
|
|
138
138
|
hash?: string;
|
|
139
139
|
}
|
|
140
|
+
/** Sets how many bytes of decoded blobs all open bundles may hold together (`solver.sigdb.blobCacheBudgetMb`). */
|
|
141
|
+
export declare function setBlobCacheBudget(bytes: number): void;
|
|
140
142
|
/**
|
|
141
143
|
* Fast, partial reader for a single bundle. `open()`/`openSync()` load the string dictionary + `.idx` once, then every
|
|
142
144
|
* query seeks straight to one package blob; `open()` additionally decompresses a `.br`/`.gz` source into a hash-keyed cache.
|
|
143
145
|
*/
|
|
144
146
|
export declare class SigDatabase implements PackageSignatureSource {
|
|
145
147
|
private closed;
|
|
146
|
-
/** parsed blobs by blob index so repeated lookups skip the re-read + JSON.parse; bounded by {@link
|
|
148
|
+
/** parsed blobs by blob index so repeated lookups skip the re-read + JSON.parse; bounded by {@link setBlobCacheBudget|the shared budget} */
|
|
147
149
|
private readonly blobCache;
|
|
148
150
|
/** a version's function indices plus its `name -> index` view, keyed by package and version; FIFO-bounded */
|
|
149
151
|
private readonly versionFnCache;
|
|
@@ -214,7 +216,7 @@ export declare class SigDatabase implements PackageSignatureSource {
|
|
|
214
216
|
/**
|
|
215
217
|
* Resolve a package version to its blob and the function records of that version (the shared prologue of
|
|
216
218
|
* {@link functions}/{@link functionByName}). The blob comes from {@link blob} every time rather than out of
|
|
217
|
-
* {@link versionFnCache}: holding one here would keep it decoded past what {@link
|
|
219
|
+
* {@link versionFnCache}: holding one here would keep it decoded past what {@link setBlobCacheBudget|the shared budget} allows.
|
|
218
220
|
*/
|
|
219
221
|
private versionFns;
|
|
220
222
|
functions(pkg: string, version?: string): DecodedFunction[] | undefined;
|
package/project/sigdb/reader.js
CHANGED
|
@@ -8,6 +8,7 @@ exports.readSignatureDb = readSignatureDb;
|
|
|
8
8
|
exports.availableVersionEntries = availableVersionEntries;
|
|
9
9
|
exports.classOwnerIndexFor = classOwnerIndexFor;
|
|
10
10
|
exports.sourceForPackage = sourceForPackage;
|
|
11
|
+
exports.setBlobCacheBudget = setBlobCacheBudget;
|
|
11
12
|
exports.getSharedSigSourceSync = getSharedSigSourceSync;
|
|
12
13
|
exports.getSharedSigSource = getSharedSigSource;
|
|
13
14
|
exports.verifyShardedDatabase = verifyShardedDatabase;
|
|
@@ -313,7 +314,11 @@ const NoFile = -1;
|
|
|
313
314
|
* anything: how many shards a query set opens is not something the caller picks, and each would claim the
|
|
314
315
|
* budget again. A count would not bound anything either -- one package's blob outweighs a hundred small ones.
|
|
315
316
|
*/
|
|
316
|
-
|
|
317
|
+
let blobCacheBudget = 16 * 1024 * 1024;
|
|
318
|
+
/** Sets how many bytes of decoded blobs all open bundles may hold together (`solver.sigdb.blobCacheBudgetMb`). */
|
|
319
|
+
function setBlobCacheBudget(bytes) {
|
|
320
|
+
blobCacheBudget = Math.max(0, bytes);
|
|
321
|
+
}
|
|
317
322
|
/** what every open bundle holds decoded, so the budget is spent across all of them */
|
|
318
323
|
const cachedBlobs = [];
|
|
319
324
|
/** where {@link keepBlob} resumes looking for something to drop */
|
|
@@ -323,7 +328,7 @@ let cachedBlobBytes = 0;
|
|
|
323
328
|
* Keep `blob` decoded for `db`, dropping blobs until all of them fit the budget (age gated).
|
|
324
329
|
*/
|
|
325
330
|
function keepBlob(db, blobIdx, bytes) {
|
|
326
|
-
while (cachedBlobBytes + bytes >
|
|
331
|
+
while (cachedBlobBytes + bytes > blobCacheBudget && cachedBlobs.length > 0) {
|
|
327
332
|
if (hand >= cachedBlobs.length) {
|
|
328
333
|
hand = 0;
|
|
329
334
|
}
|
|
@@ -362,7 +367,7 @@ function releaseBlobs(db) {
|
|
|
362
367
|
*/
|
|
363
368
|
class SigDatabase {
|
|
364
369
|
closed = false;
|
|
365
|
-
/** parsed blobs by blob index so repeated lookups skip the re-read + JSON.parse; bounded by {@link
|
|
370
|
+
/** parsed blobs by blob index so repeated lookups skip the re-read + JSON.parse; bounded by {@link setBlobCacheBudget|the shared budget} */
|
|
366
371
|
blobCache = new Map();
|
|
367
372
|
/** a version's function indices plus its `name -> index` view, keyed by package and version; FIFO-bounded */
|
|
368
373
|
versionFnCache = new Map();
|
|
@@ -603,7 +608,7 @@ class SigDatabase {
|
|
|
603
608
|
/**
|
|
604
609
|
* Resolve a package version to its blob and the function records of that version (the shared prologue of
|
|
605
610
|
* {@link functions}/{@link functionByName}). The blob comes from {@link blob} every time rather than out of
|
|
606
|
-
* {@link versionFnCache}: holding one here would keep it decoded past what {@link
|
|
611
|
+
* {@link versionFnCache}: holding one here would keep it decoded past what {@link setBlobCacheBudget|the shared budget} allows.
|
|
607
612
|
*/
|
|
608
613
|
versionFns(pkg, version) {
|
|
609
614
|
const bm = this.blobMeta(pkg);
|
package/util/version.js
CHANGED
|
@@ -42,9 +42,9 @@ const assert_1 = require("./assert");
|
|
|
42
42
|
const sigdb_download_1 = require("../project/sigdb/sigdb-download");
|
|
43
43
|
const doc_files_1 = require("../documentation/doc-util/doc-files");
|
|
44
44
|
// this is automatically replaced with the current version by release-it
|
|
45
|
-
const version = '2.15.
|
|
45
|
+
const version = '2.15.5';
|
|
46
46
|
// this is automatically replaced with the release date by release-it (regex-bumper, see package.json)
|
|
47
|
-
const versionDate = '2026-08-
|
|
47
|
+
const versionDate = '2026-08-26T19:54:19Z';
|
|
48
48
|
/**
|
|
49
49
|
* Retrieves the current flowR version as a new {@link SemVer} object.
|
|
50
50
|
*/
|