Эх сурвалжийг харах

docs: run-log retention is a BOOT config on each binary, and we named the wrong place

The logs route's refusal told a caller the retained count was "`runs_kept` on
the function settings". There is no such field there: it is
`functions.runs_kept` in the server's config.json for http and invoke runs,
and `function_runs_kept` in runner.json for cron and job runs. A caller
following that sentence goes to PUT /projects/{p}/settings/functions and finds
nothing, which is the one place the message was supposed to save them from.

`llms.txt` and the web UI had the matching half-truth: both quote the SERVER's
number as though it governed every trigger. The shipped runner.json defaults to
50 against the server's 500, so on a host that has not set both, we were
confidently showing a cron function's retention as ten times what it is.

Found by a consumer who hit the retention on an HTTP-triggered function and
noted, correctly, that the SERVER's value is the one that governs it - the
opposite of the crons that drove the 2026-10-22 investigation.

No behaviour change: the cap is global and per-binary, it is not settable per
function or per project, and nothing here makes it so.
fszontagh 2 долоо хоног өмнө
parent
commit
903fa4ab6e

+ 1 - 1
api/llms.txt

@@ -371,7 +371,7 @@ export default async function (ctx) {
 
 **A code push can never widen access.** `policy` is server state: a `policy` field sent with a `POST`/`PUT` body is ignored (not merged, not consulted as a fallback), and `enabled` is likewise preserved, so re-pushing code does not re-enable a function an operator turned off. A first registration inherits the project's default policy, which currently grants **no collection at all** - the function runs, logs and can call out, but reaches no data until an admin grants it a rule.
 
-- `GET  /api/v1/projects/{project}/functions` - List functions **without their sources**: `{functions:[{function_id, path, content_hash, descriptor, policy, enabled, valid, last_error, created_at, updated_at}], runners:{configured, healthy}, runs_kept}`. The `runners` counts let a client warn that a write will fail with **503** *before* an author writes a script, rather than only after the push: `configured: 0` is the common first state, because installing the runner package does not switch functions on - the server needs a `functions.runners` list. `runs_kept` is this server's configured run-log retention, so a client need not guess the default.
+- `GET  /api/v1/projects/{project}/functions` - List functions **without their sources**: `{functions:[{function_id, path, content_hash, descriptor, policy, enabled, valid, last_error, created_at, updated_at}], runners:{configured, healthy}, runs_kept}`. The `runners` counts let a client warn that a write will fail with **503** *before* an author writes a script, rather than only after the push: `configured: 0` is the common first state, because installing the runner package does not switch functions on - the server needs a `functions.runners` list. `runs_kept` is this SERVER's configured run-log retention (`functions.runs_kept`), so a client need not guess the default - but read it as covering `http` and `invoke` runs ONLY. Cron and job runs are appended and trimmed by the RUNNER, under its own `function_runs_kept` in runner.json, which this field cannot see and which ships with a DIFFERENT default (50 against the server's 500) - so on a host that has not set both, this number overstates a cron function's retention tenfold. Retention is a boot config on each binary: it is not settable per function or per project, and no request can change it.
 - `POST /api/v1/projects/{project}/functions` `{source, path?}` - Register a new function; the id comes from the validated `on` block, so there is no `function_id` field to send. An id already in use is **409** `function_exists` (PUT it to update).
 - `GET  /api/v1/projects/{project}/functions/{id}` - Get one function, **including** `source`.
 - `PUT  /api/v1/projects/{project}/functions/{id}` `{source, path?}` - Push code. The id the script declares must equal the id in the URL; a mismatch is **422** `id_mismatch` (with `error.details.declared` and `error.details.url`) rather than a rename, because the URL would otherwise move code onto another function's policy. A PUT to an unused id registers it (**201**).

+ 6 - 2
src/handlers/functions.cpp

@@ -356,8 +356,12 @@ void registerFunctionRoutes(ApiServer& s) {
                                  {"run_id"}, {"fields"}},
                                 {"limit"},
                                 "it returns the newest runs of every outcome and cannot be "
-                                "filtered or paged; the retained count per function is "
-                                "`runs_kept` on the function settings");
+                                "filtered or paged. The retained count is this SERVER's boot "
+                                "config (`functions.runs_kept` in config.json) for http and "
+                                "invoke runs, and the RUNNER's (`function_runs_kept` in "
+                                "runner.json) for cron and job runs; it is reported as "
+                                "`runs_kept` by the function listing, it is not a per-function "
+                                "or per-project setting, and no request can change it");
         if (!d->functions.get(project, id))
             throw ApiError(ErrCode::NotFound, "not_found", "no such function");
         nlohmann::json arr = nlohmann::json::array();

+ 4 - 1
webui/src/pages/Functions.tsx

@@ -975,7 +975,10 @@ function RunsTab({ project, fn, runsKept }: { project: string; fn: FunctionSumma
         Newest first. Only the newest {runsKept} runs per function are kept on this server (
         <span className="font-mono">functions.runs_kept</span>), and the log is trimmed on every
         write - so asking for more than that returns what is left, and a run_id from an older run
-        stops resolving altogether.
+        stops resolving altogether. That number covers <span className="font-mono">http</span> and{' '}
+        <span className="font-mono">invoke</span> runs only: cron and job runs are trimmed by the
+        runner's own <span className="font-mono">function_runs_kept</span>, which this page cannot
+        read and which may be set lower. Neither is per-function.
       </p>
 
       {isError && (