|
@@ -158,7 +158,7 @@ JSValue throwApiError(JSContext* ctx, const ApiError& e) {
|
|
|
/// A run holds a pooled runtime with its own memory limit (64 MiB on prod), and
|
|
/// A run holds a pooled runtime with its own memory limit (64 MiB on prod), and
|
|
|
/// base64 inflates by a third, so a generous value here is a footgun rather
|
|
/// base64 inflates by a third, so a generous value here is a footgun rather
|
|
|
/// than a feature.
|
|
/// than a feature.
|
|
|
-constexpr size_t kCtxFileMaxBytes = 1024 * 1024;
|
|
|
|
|
|
|
+constexpr size_t kCtxFileMaxBytesDefault = 1024 * 1024;
|
|
|
|
|
|
|
|
namespace hostdetail {
|
|
namespace hostdetail {
|
|
|
|
|
|
|
@@ -603,7 +603,7 @@ EgressDecision decideEgress(const std::string& host, const functions::SsrfPolicy
|
|
|
|
|
|
|
|
/// The most one ctx.mail call may pull off the wire, in bytes.
|
|
/// The most one ctx.mail call may pull off the wire, in bytes.
|
|
|
///
|
|
///
|
|
|
-/// The same question kCtxFileMaxBytes answers, asked about mail: not what a
|
|
|
|
|
|
|
+/// The same question kCtxFileMaxBytesDefault answers, asked about mail: not what a
|
|
|
/// mailbox may hold, but what ONE run may load into a 64 MiB JS heap. A read of
|
|
/// mailbox may hold, but what ONE run may load into a 64 MiB JS heap. A read of
|
|
|
/// twenty messages' headers and text is tens of kilobytes, so this leaves room
|
|
/// twenty messages' headers and text is tens of kilobytes, so this leaves room
|
|
|
/// for a large message or two while still refusing the mailbox whose single
|
|
/// for a large message or two while still refusing the mailbox whose single
|
|
@@ -1679,6 +1679,7 @@ struct HostContext::Impl {
|
|
|
want.configuredConnectSec = cfg.connectTimeoutSec;
|
|
want.configuredConnectSec = cfg.connectTimeoutSec;
|
|
|
want.configuredReadSec = cfg.readTimeoutSec;
|
|
want.configuredReadSec = cfg.readTimeoutSec;
|
|
|
want.callTimeoutMs = callTimeoutMs;
|
|
want.callTimeoutMs = callTimeoutMs;
|
|
|
|
|
+ want.connectCapSec = global.embeddingConnectCapSec;
|
|
|
const functions::EmbedBudget slice = functions::resolveEmbedBudget(want);
|
|
const functions::EmbedBudget slice = functions::resolveEmbedBudget(want);
|
|
|
|
|
|
|
|
EmbeddingClient emb(cfg.apiBase, cfg.apiKey, static_cast<uint32_t>(slice.connectSec),
|
|
EmbeddingClient emb(cfg.apiBase, cfg.apiKey, static_cast<uint32_t>(slice.connectSec),
|
|
@@ -1701,10 +1702,21 @@ struct HostContext::Impl {
|
|
|
// A timeout the SCRIPT asked for is reported as its own choice, so
|
|
// A timeout the SCRIPT asked for is reported as its own choice, so
|
|
|
// an author can branch on it without parsing text. Anything else
|
|
// an author can branch on it without parsing text. Anything else
|
|
|
// keeps the provider's own classification.
|
|
// keeps the provider's own classification.
|
|
|
|
|
+ // NAME THE DEADLINE THAT WAS ACTUALLY APPLIED, not the one asked
|
|
|
|
|
+ // for. This used to quote `callTimeoutMs` alone, so a script
|
|
|
|
|
+ // asking for 6000 ms was told it had exceeded 6000 ms when the
|
|
|
|
|
+ // phases it actually got were connect 3 s and read 3 s - a number
|
|
|
|
|
+ // no phase ever had, which sent an author looking for a provider
|
|
|
|
|
+ // taking over six seconds when the truth was that we had halved
|
|
|
|
|
+ // their budget. The asked-for value stays, because the author
|
|
|
|
|
+ // recognises it; what is added is what we did with it.
|
|
|
if (slice.boundByCall)
|
|
if (slice.boundByCall)
|
|
|
throw ApiError(ErrCode::GatewayTimeout, "embedding_timeout",
|
|
throw ApiError(ErrCode::GatewayTimeout, "embedding_timeout",
|
|
|
- "the embedding call exceeded the embedTimeoutMs this call asked "
|
|
|
|
|
- "for (" + std::to_string(callTimeoutMs) + "ms)");
|
|
|
|
|
|
|
+ "the embedding call exceeded the deadline it was given: "
|
|
|
|
|
+ "embedTimeoutMs " + std::to_string(callTimeoutMs) +
|
|
|
|
|
+ "ms was applied as connect " + std::to_string(slice.connectSec) +
|
|
|
|
|
+ "s + read " + std::to_string(slice.readSec) +
|
|
|
|
|
+ "s (the two phases are sequential, so their sum is the bound)");
|
|
|
throw;
|
|
throw;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -2019,7 +2031,13 @@ struct HostContext::Impl {
|
|
|
const std::string c = qualify(config.project, collection);
|
|
const std::string c = qualify(config.project, collection);
|
|
|
// The shared implementation, not a copy: a filter must mean the same
|
|
// The shared implementation, not a copy: a filter must mean the same
|
|
|
// thing here as it does on the HTTP route, scan cap included.
|
|
// thing here as it does on the HTTP route, scan cap included.
|
|
|
- const VectorSearchResult found = vectorSearch(db.client(), c, q, topK, minScore, filters);
|
|
|
|
|
|
|
+ // Same settings-driven cap as the HTTP route, from the same global
|
|
|
|
|
+ // snapshot: a filter must mean the same thing on both surfaces, and
|
|
|
|
|
+ // that now includes how deep the walk goes.
|
|
|
|
|
+ loadSettings();
|
|
|
|
|
+ const uint32_t scanCap = global.vectorFilterScanCap;
|
|
|
|
|
+ const VectorSearchResult found =
|
|
|
|
|
+ vectorSearch(db.client(), c, q, topK, minScore, filters, scanCap);
|
|
|
|
|
|
|
|
// The console warning STAYS - it is what an author reading a run log
|
|
// The console warning STAYS - it is what an author reading a run log
|
|
|
// sees. But it is no longer the only signal, because a console line
|
|
// sees. But it is no longer the only signal, because a console line
|
|
@@ -2031,7 +2049,7 @@ struct HostContext::Impl {
|
|
|
// confidence. The structured signal is added below, next to the hits.
|
|
// confidence. The structured signal is added below, next to the hits.
|
|
|
if (found.scanCapped)
|
|
if (found.scanCapped)
|
|
|
addLog("[warn] search on '" + collection + "' stopped at the " +
|
|
addLog("[warn] search on '" + collection + "' stopped at the " +
|
|
|
- std::to_string(kVectorFilterScanCap) +
|
|
|
|
|
|
|
+ std::to_string(scanCap == 0 ? kVectorFilterScanCap : scanCap) +
|
|
|
"-candidate scan cap while still short of top_k " +
|
|
"-candidate scan cap while still short of top_k " +
|
|
|
std::to_string(topK) + ": more rows may match than were returned");
|
|
std::to_string(topK) + ": more rows may match than were returned");
|
|
|
|
|
|
|
@@ -2425,11 +2443,13 @@ struct HostContext::Impl {
|
|
|
// not be able to pull megabytes into a 64 MiB JS heap on every run
|
|
// not be able to pull megabytes into a 64 MiB JS heap on every run
|
|
|
// afterwards. Refused rather than truncated - half a PNG is worse than
|
|
// afterwards. Refused rather than truncated - half a PNG is worse than
|
|
|
// an error.
|
|
// an error.
|
|
|
- if (got->second.size() > kCtxFileMaxBytes)
|
|
|
|
|
|
|
+ const size_t fileCap = config.ctxFileMaxBytes > 0 ? config.ctxFileMaxBytes
|
|
|
|
|
+ : kCtxFileMaxBytesDefault;
|
|
|
|
|
+ if (got->second.size() > fileCap)
|
|
|
throw ApiError(ErrCode::Unprocessable, "file_too_large",
|
|
throw ApiError(ErrCode::Unprocessable, "file_too_large",
|
|
|
"'" + name + "' is " + std::to_string(got->second.size()) +
|
|
"'" + name + "' is " + std::to_string(got->second.size()) +
|
|
|
" bytes, which is more than a function may load (" +
|
|
" bytes, which is more than a function may load (" +
|
|
|
- std::to_string(kCtxFileMaxBytes) + ")");
|
|
|
|
|
|
|
+ std::to_string(fileCap) + ")");
|
|
|
|
|
|
|
|
nlohmann::json out = got->first.toJson();
|
|
nlohmann::json out = got->first.toJson();
|
|
|
out["base64"] = hostdetail::base64Encode(
|
|
out["base64"] = hostdetail::base64Encode(
|