Repository navigation
Operators define a profile schema per namespace and each user's profile is kept current in that shape - #93
Merged
Merged
Conversation
…le is kept current in that shape profile_schema.set / get / clear (admin, audited for set and clear) store a bounded JSON Schema per namespace in loom.profile_schemas (migration 063). The structured_profile worker builds each user's profile from their current facts with one model call, holds the answer to the schema and writes it as the user's structured_profile profile row, tagged with the schema hash and a digest of its sources. profile.structured returns the profile with ready, stale, pending or no_schema, without a model call, under the caller's read scope. The fold's source query moves to server/memory/store/profile_sources.py and both builders share it, so neither reads a high row. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ed and backs off failing users Review fixes: namespaces rotate through a pass cursor with an equal share of the budget each; a failed build backs the user off in the worker's process; the stale-user scan prefilters on max(updated_at) since the profile's sources were read (valid_at) and digests only those candidates; a build whose user's facts were erased during the model call writes nothing; non-finite numbers read null; title is accepted at every level; the tags come from one helper; the record value helpers are public. The migration is 059, the next free number. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…fusals Review fixes: the stale-user scan reads per-state change times from loom.memory_versions, so a restatement never looks new and a row that turns high, is retyped or retagged, expires or passes valid_to does; a deletion skips the cooldown; an expired or redacted profile is no profile; a lock or pin is checked before the model call and a refused write waits for a new digest; the store reads take the read scope, and profile.structured refuses a session-bounded token; the fold sorts same-day facts by time; the namespaces rotate in one statement; schema rows carry writer_actor and next_version, and clear answers the schema it cleared. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
The profile schemas migration is 060: main took 059. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ith their contract tests Registers the structured_profile LLM stage, classifies loom.profile_schemas as a builder table with a test that its writers carry every column, covers the worker's settings and registry row, and refreshes the SDK surface snapshot. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…egate Review fixes: users_behind compares each user's sources digest with the profile's tag in one loom.memory FINAL aggregate (exact for reverts, restores and writes that are no source; cost follows live rows), with a source-count tag so a deletion skips the cooldown and refused users last. A failing namespace is counted and the pass moves on; budget a namespace leaves goes to one still behind. A build writes nothing when a fact it read is no longer current. The schema hash covers the parsed properties and the stored schema keeps the admin's order. The label rides into the write; the workers import at module top; the candidates setting is removed. security.md states that a redaction does not scrub earlier profile versions. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ofile row too Review fixes: the sources digest is an XOR of sipHash64 over each source's id, content hash, confidence and date; a refusal holds at the (digest, profile row version) it saw and lapses after six hours, so an unpin, an unlock or a lapsed lock is retried; the pass checks for a stop before each user, scans through one helper, prunes waits that are over, and idles on its own interval (LOOM_STRUCTURED_PROFILE_IDLE_INTERVAL_SECONDS); list_active returns parsed schemas; Refused carries its digest; the erasure and staleness docs say what the checks cover. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…veral passes Review fixes: user_facts dates a fact by valid_at else updated_at and ranks by confidence then last change, for the fold too; one scan lists ten times a namespace's share and later passes take from it until it is drained, the schema changes or it is ten minutes old, under its own execution and memory caps; the leftover round takes from that list; a build skips a user already current; list_active returns rows and a schema that no longer parses is counted; 409 and 429 are failures, not refusals; duplicates are no source; the digest is padded to 16 characters; the memory_limit and cooldown settings have behaviour tests. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…or a failing namespace waits Review fixes: the digest hashes valid_at else updated_at, so a restatement costs one rebuild after the cooldown; the scan runs under statement_timeout and max_memory_usage from LOOM_STRUCTURED_PROFILE_SCAN_TIMEOUT_SECONDS and _SCAN_MAX_MEMORY_BYTES; a scan that found every user behind is not repeated for ten minutes once drained; a namespace whose scan or schema fails backs off like a user; every 4xx from the write is a refusal; the candidate list is a deque. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
The worker keeps a namespace's last scan for minutes, longer than a test waits between a write and the next pass. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
The profile schemas migration is 062: main took 060. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ts wait Review fixes: list_active leaves out each (org, namespace, schema hash) backing off in SQL, so the limit counts runnable namespaces, and a new schema hash ends the wait; the namespace wait has its own map; the scan caps sit in the worker's config and are passed to users_behind, with the timeout at least 1 s; a refusal is logged with its status; integration builds forget the scan through forget_scans; long doc lines are rewrapped. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… settings refuse 0 The free-text fold test pins that a duplicate row is left out; the pass result counts namespaces_reached; the doc names the fold's filter and where leftover share goes. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ounded read is refused before its scope resolves - system_prompt appends pattern, length and value bounds to each property's line, so the model answers in the form conform checks. - profile.structured refuses an own_session scope before resolving it; the docs name both refusals (IDENTITY_INCOMPLETE without a session_id from the gate, AUTH_INSUFFICIENT with one). - pending is documented as also covering a user with no facts to build from. - sources_digest runs the one-user aggregate itself; the batch digests reader is gone. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… output cap are settings The backoff base and cap, the refusal retry, the scan list's age and the build's max_tokens move from module constants and a call-site literal to LOOM_STRUCTURED_PROFILE_* settings read at call time. The pass intervals, the cooldown and every new knob have a floor, a value below it is refused, and each new op budget states its reason. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
The structured profile settings move into server/settings/catalog.py; the per-pass ones are live and the worker reads each where it is used, so its config keeps only the namespace filter. The model call's output cap is the structured_profile entry of LLM_MAX_TOKENS and the four new ops' p99 budgets are in OP_BUDGETS_P99_MS. The schema and row-size bounds say why they are not settings, the scan no longer clamps values its settings already bound, and intervals, backoffs and timeouts are gt=0. Signed-off-by: zlareb1 <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
A raised `structured_profile` entry of LOOM_LLM_MAX_TOKENS_OVERRIDES no longer makes its answers exceed the row's char_limit: the bound is the larger of 32768 and 8 characters per output token. The settings table links the Structured profiles reference section, the doc names LLM_MAX_TOKENS as the cap's default, two stale inventory gaps are gone, and the worker tests set their budget through settings_override. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
A user with no facts and no profile row gets no new row, so a pass that takes an erased user from an older scan leaves nothing for the finished erasure saga to miss. A pass that reached only part of the namespace rotation is no longer idle, so namespaces past its page wait the busy interval, not the idle one. The migration takes the next free number, 061. A test pins that structured_profile_enabled=False removes the worker. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…efaults are pinned run_pass read structured_profile_max_users_per_pass twice, so an override between the reads made the wrap check disagree with the page list_active returned. The 14 structured profile settings are added to the defaults snapshot. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
A structured profile and the free-text fold name the memories they read in their trace (profile.fold:<label>:<memory ids>). memory.redact now scrubs every version of the user's profiles whose trace names the redacted memory, and each profile key's derived rows, so no earlier profile version keeps text a model wrote from it. The fold's source test reads real rows on clickhouse-local instead of matching its source code. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ses the redact profile.render and profile search leave out a profile head that memory.redact scrubbed, so packs and primers no longer serve its marker. memory.redact checks the lock of every profile key it would scrub before it changes anything, and refuses as it does for the memory's own key. The structured profile build reads the pin and lock of the key's head, even a redacted or expired one, before paying for the model call. The docs state that a profile version whose trace names no memory ids is not reached, and the profile_schema.set description says only a change to the properties makes profiles stale. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…drops their cached answers All the profile versions built from a redacted memory are scrubbed by one ALTER UPDATE on loom.memory and one on loom.memory_versions, however many there are. The cached answers and ask precedents whose window held a scrubbed profile key are deleted with those of the memory's own key. The structured profile pass goes idle only when it reached every namespace in its page. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… the org-wide cache reach profile.structured now returns the row's version also as a decimal string, exact for a JavaScript caller, as memory.get does. The security page states that a scrubbed profile key clears cached answers and precedents across the org, since windows hold bare keys. CHARS_PER_OUTPUT_TOKEN fits on one line. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ed during the model call The pre-write check recomputes the user's sources digest instead of checking that each memory id is still a current fact, so a fact edited (and its old version redacted) while the model ran stops the write too. `live_ids` is gone. `profile_head_hold` and `users_behind` take a required read scope like the module's other readers. The docs name `version_text` and say when a deletion is rebuilt. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ok users is not idle A refused build is keyed on the version of the structured profile key's head, redacted or expired, so an unpin or an unlock of a redacted head ends the wait. A pass goes idle only when it took no user from any scan list: users taken but not written leave others behind in the list. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
A pass read one page of `max_users_per_pass` namespaces and stopped, so a namespace with nothing to build used a place without spending budget, and a user behind in a namespace far down the rotation waited many passes. The pass now reads the next page from the last namespace reached until its budget is spent, the rotation comes back round or the pass is stopped. The fold's attribute and about:other exclusions are checked by the clickhouse-local fold test, which now also writes an attribute-tagged row; the two string-matching tests are removed. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
The pass now has its own deadline, LOOM_STRUCTURED_PROFILE_MAX_PASS_SECONDS (600), and stops taking users once half of it is gone, so a slow pass ends on its own rather than being cancelled and counted as a failure; the users it took but did not reach go back to the front of the scan list. Each page of namespaces now holds at most the budget left, as its comment says. Two comments that described the old single-version redaction are reworded. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…is not told who set the schema A `high` head of the structured profile key now refuses a rebuild before the model call, like a pin or a lock, so the worker no longer writes an unlabelled row over it. profile_schema.get leaves updated_by empty for a token narrowed to one user. The docs and the backoff setting's comment state the real retry bound for a failed build: the first scan after the wait ends, at most the wait plus the scan's maximum age. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…s the second half of the pass, and lists a high head among refusals Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
memory.redact passes the named version and every profile version built from it to one redact_versions call, so a redact issues two mutations and no failure between calls leaves the fact scrubbed but not its profiles. profile_versions_built_from reads only loom.memory_versions. The idle interval and cooldown settings describe when the worker idles and what skips the wait, and the docs describe unreached profile versions by their trace. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…nd pending means not built yet A user whose facts are all gone reads ready with every property null; the field comment and the status table say so. The worker's backoff and refusal maps hold small frozen dataclasses read by name. The structured profile setting comments say what each value controls, and the references are regenerated. profile_schema.set's idempotency comment says what holds. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
The bound was estimated at 8 characters per output token, which escaped non-ASCII text exceeds, so a long Japanese profile was refused. The row's char_limit is now the larger of 32768 and the written JSON's length; the schema already bounds the profile's shape. The deployment guide's models table lists LOOM_STRUCTURED_PROFILE_MODEL. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…pins the fake model conform already bounds the profile's shape, so the worker writes with char_limit=None instead of a floor that could never refuse; the docs and comments no longer list a size cap among the refusals. The in-process worker pass in the integration test uses FakeLLMClient, so a provider key in the test environment never reaches a real model. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
The profile versions built from a redacted memory are now selected by a predicate on the user's profile rows and their trace, so the two mutations stay the same size however long the profile history is; a list of every version could exceed the server's cap on one bound parameter. The lock check reads only the distinct profile keys with their newest version built from the memory. Also narrows an optional in the namespace backoff for the mypy gate, and says in the redact output and docs that a missing version answers redacted=false. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
profile.structured answers pending for a profile never built and for a built row that expired, was redacted or is labelled high. The field comment, the operations reference and the feature page now say so. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…act reaches the same profile keys The live profile predicate binds actor to the worker's actor, so a row a caller writes to the key with forged tags reads as pending and its user as behind. memory.redact looks up the profile keys built from the memory with redacted versions included, so a retry after a failed derivative scrub or cache delete reaches them again; the UPDATE still skips versions already redacted. The profile doc's Passes bullet is reflowed and names every in-process wait. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
The worker's actor is now `worker:structured-profile`: a token maps only to a `human:` or `process:` actor, so a service account whose subject names the worker can no longer write a row profile.structured serves. parse_answer returns None for any answer that is not a JSON object, and the worker tests move their waits through the manual clock. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
The cap is the `structured_profile` entry of LLM_MAX_TOKENS, now 32 tokens per value, times the values a full answer holds (one per property, maxItems per array). profile_schema.set refuses a schema whose full answer holds more than 256 values, so the cap stays at most 8,192 tokens and a valid schema's answer is never cut off and retried forever. ProfileSchemaOutput describes updated_by and updated_at as the last set or clear, and the redact comment on profile locks stands on its own. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…profile rows profile.structured answers ready with the all-null profile when the user has no row and no facts, which is what the worker would build. The redaction's profile predicate names agent '-', where the builders write, so the sort key narrows the read to the user. The read_scope and status descriptions say what the fields do in one short line each. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
version_exists takes the history target and filters on every sort-key column, so a redact no longer scans the org's version history a second time. The profile store tests name their fixed dates by day. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
The built_at, memory_id, version and version_text descriptions name the ready answer for a user with no facts as well as pending. The Storage bullet names a high label as one the worker leaves alone, the redaction module docstring names the profile versions it scrubs, and the worker's pass comments are one line each, with the rest in the module docstring. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… and value The cap is the LLM_MAX_TOKENS base plus the schema's estimate of a full answer: each key with its punctuation, and each value sized by its maxLength, its longest enum value or a default for a short phrase. profile_schema.set refuses a schema whose estimate passes 16,384 tokens. An answer stopped at the cap is a refusal held until the user's sources, the profile head or the schema hash change, not a failure retried on backoff. The docs name memory.lock and memory.unlock as digest changes that move a fact to the newest place a build reads. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
- built_at reads the row's valid_at, which a lock or unlock carries forward, instead of updated_at. - answer_tokens types max_length, so the mypy ratchet passes. - MemoryRedactOutput's comments say redacted is false for a caller who is not admin of the namespace, and that the deletion counts include each profile key the redact reached, across the org. - memory-architecture.md states that a worker with no auth context writes as its pipeline actor, that no token maps to worker:<name>, and that the structured profile reads trust only worker:structured-profile; security.md links to it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ch workers carry an actor The write-path page now says only a worker that sets pipeline_actor writes as it, and the refusal retry setting and the LLM_MAX_TOKENS entry each have a one- or two-line comment. The configuration reference, settings schema and example file are regenerated. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Merged
7 of 9 tasks
9 of 11 tasks
pufit
added a commit
that referenced
this pull request
Oct 21, 2026
… writer The structured profile worker from #93 named only the org, so its model calls went out as the gateway's default agent. build_profile now names the namespace, the user and the newest principal that wrote the facts it reads (user_facts returns each fact's actor and version), as the profile fold does; a pipeline's or a worker's own write names no principal, and the call is then for the agent whose namespace it is. A build held for its identity (customer.GROUP_HOLDS: the org switched off, the identity refused, asked to wait or unread) leaves that user out of the namespace's passes until the hold ends (hold_seconds, as the fold's), through the worker's own per-user wait: no failure is counted, and a failure backoff's next wait stays as it was. Other holds still only skip the user. Tests pin the identity the build sends (the newest writer; the namespace's agent when no principal wrote the facts) and that a held user waits out its hold while the pass and the next one take the namespace's other users. Signed-off-by: pufit <[email protected]>
5 of 9 tasks
zlareb1
added a commit
that referenced
this pull request
Oct 22, 2026
…ty holds only that identity (#111) * Model calls name whom they are for in configurable identity headers LOOM_INFERENCE_IDENTITY_HEADERS_JSON maps header names to templates over {org}, {namespace}, {subject}, {user_id}, {agent}, {tenant} and {email}. Every chat, embedding, rerank and classify request carries them. A request names its token's subject; a background job names the writer of the row it works on, else the agent whose own namespace the row is in, and splits a batch by identity. A gateway that bills each agent then sees the agent behind background work as well as requests, instead of the deployment for both. With no templates nothing changes. Signed-off-by: pufit <[email protected]> * The workload token can be sent to the gateway as the bearer itself LOOM_INFERENCE_WORKLOAD_TOKEN_MODE=bearer sends the content of LOOM_INFERENCE_WORKLOAD_TOKEN_FILE as Authorization: Bearer on every model call, for a gateway that verifies the workload's token itself and has no token exchange. The file is read again at most once a minute and at once after the gateway answers 401, so a rotated token is picked up without a restart. The mode requires the gateway, as the exchange does, so the token goes nowhere else. A keyless compatible embedder now sends the workload token in either mode instead of falling back to the fake embedder. The default mode, exchange, behaves as before. Signed-off-by: pufit <[email protected]> * A gateway refusing one identity holds that identity's calls, not the provider With identity headers set, a 403 or a 429 whose error names a budget, from a gateway host, is the gateway refusing the identity the call was made for. The model client's response hook raises ModelCallRefused (403, MODEL_CALL_REFUSED, with the gateway's status and code) instead of an HTTP error, so the request answers it, nothing retries it or hands it to the fallback model, /v1/health does not read it as a provider failure, and the org's switch is untouched. It is one of customer.HOLDS: a background job leaves the row as it is, and for LOOM_INFERENCE_REFUSAL_COOLDOWN_SECONDS (600) its calls for that identity are refused before anything is sent, while other identities' work goes on. One over-budget agent no longer reads as the provider being down for the whole deployment. Any other 429 is a rate limit, retried as before. The bearer tests now point each sender at a fresh model client: a sender first imported while another test patched get_model_client kept that patch. Signed-off-by: pufit <[email protected]> * A job's model call is for the row's writer, the namespace's agent only without one Jobs that never passed the writer fell back to the namespace's owner even when the row recorded its actor, so the owner agent, or nobody for a shared namespace, paid for a member's or another agent's work. The embedding worker, projection repair and the code-link judge now read the writer of the memory they work on; observe-extract takes the newest writer of the session's observations, a profile fold the newest writer of its facts, reflection and the period digest the newest writer of the session's memories, and the conflict sweep passes the write's writer to settle(). The owner is used only for a row that records no principal. A pipeline's own actor (process:extraction-worker, process:cli:<command>, the other provenance.PIPELINE_ACTORS) names no principal: subject_of() returns '' for it, so such a row falls back to its namespace instead of going out with no agent. A test pins every process:<name> literal in the server to the registry. The writer reads run only while an identity header names more than the org and namespace. Signed-off-by: pufit <[email protected]> * Identity headers name the agent whole, and a call naming no org is refused The headers whose templates name {agent} or {tenant} are now sent together or not at all. An agent whose trust requires no exact tenant, or a trust's own token, used to send the agent header alone; the gateway refuses half an identity with a 400, which read as a provider failure for the whole cell. Now neither goes and the gateway applies its default identity. With identity headers set, a call that names no org is refused and logged (MODEL_CALL_UNATTRIBUTED) unless it is the deployment's own, as it already was with the customer header: an MCP call whose identity stamping failed, or a loom command run without --org, no longer goes out under the gateway's default identity. A job batching rows now groups them by the identity they render, so one agent's rows in several namespaces share a call. Templates are trimmed, and an empty template or a hop-by-hop header name is refused at load. Signed-off-by: pufit <[email protected]> * Only the answers a deployment lists hold one identity, matched exactly LOOM_INFERENCE_IDENTITY_REFUSALS_JSON lists the gateway answers that are one identity's, not the provider's: {"refused": [...], "wait": [...]}, each entry a status and at least one of the error body's code, type or message, matched exactly. The default lists the metering's 429 budget_exceeded. A refused answer raises ModelCallRefused as before; a wait answer (too many of an agent's requests in progress, no credential for it yet) raises the new ModelCallDeferred, 503 MODEL_CALL_DEFERRED with the gateway's Retry-After. Any other answer is the provider's: another 403 is a provider failure again, still not retried, and no word in a message counts. A job's hold moves from customer.require() to the model client's request hook (gateway.sending) and is keyed by the identity and the path and model the answer was for, so one model's refusal no longer holds an agent's embeddings. A wait holds for its Retry-After (at most 5 minutes), a refusal for the cooldown, and a success at that path and model ends the hold. The identity headers go only to the gateway's hosts: the request hook drops them from any other request, a redirect hop included, and setting them now requires LOOM_INFERENCE_GATEWAY_HOSTS. The reranker and the classifier post through the model client (never redirected, as before), so the gateway check, the identity headers and the refusal handling apply to them, and a refusal raises instead of keeping the input order or the caller's type. Signed-off-by: pufit <[email protected]> * A job skips an identity the gateway holds instead of stalling on it A job that meets a held identity remembers the work it left until the hold ends (server/workers/holds.py, ModelCallRefused.hold_s) and leaves it out of its next selections, so its batch goes to other identities' work. The profile fold leaves the held identity out of its scan. The embedding worker names the held stubs for find_embedding_stubs to leave out (exclude_keys) and, while any identity is held, reads four times its batch and drops the held identities' stubs before calling, so stubs a held writer filled the oldest slots with no longer stop other writers' stubs from being embedded. What names an identity going unread (IdentityUnread) now holds one group like a switched-off org or a refused identity (customer.GROUP_HOLDS) in the four batch embedders: the memory and code embedding workers, loom reembed and a model rebuild write the vectors the other groups' calls bought instead of stopping the pass or failing the rebuild step as a provider error. Signed-off-by: pufit <[email protected]> * The extraction queue holds, backs off and spends no attempt on an outage A replay whose model call is held (the org switched off since the claim, the switch unread, the enqueuer's identity refused, asked to wait or unread) is marked `held` with the reason in last_error until the hold ends, instead of staying `running` behind its lease; no attempt is spent. While it is held the claim takes none of that enqueuer's other requests in the namespace and for that user, so the batch goes to other work rather than rows that would only be held again. A failed attempt now waits 15 s, 1, 5, then 30 minutes before the next claim, and LOOM_EXTRACTION_QUEUE_MAX_ATTEMPTS defaults to 8 instead of 3 (recorded in the settings history). A model provider or gateway that cannot be reached (a transport error, a timeout, 502/503/504) spends no attempt and waits the same backoff. A request still waiting on its last day before the table's 30-day TTL is dropped with a memory_drops record (held_past_ttl or waited_past_ttl) and marked failed, never removed unseen. memory.extraction_status takes and reports the `held` state, and its pending count, memory.search's pending_extraction and the pending evidence include held batches. Signed-off-by: pufit <[email protected]> * code.refresh calls models as its caller; in-database reembed is refused when calls must be named The ingest pass code.refresh runs (the poller's) now makes its model calls for the request's caller, its token's subject, as any request's calls are; the poller's calls stay the namespace's agent's. loom reembed --in-database is refused, before any row is read, while a customer header or identity headers are set or the inference gateway is required: ClickHouse's aiEmbed calls the provider itself, naming no customer or identity and outside the gateway's host check. The CLI prints the reason and exits 2; the Python path is unchanged. Signed-off-by: pufit <[email protected]> * Identity headers are decoded once per value, not on every read Every model call reads LOOM_INFERENCE_IDENTITY_HEADERS_JSON several times (rendering, grouping, the request hook, the gateway's answer); it is now decoded once per value, as the refusals table is. Signed-off-by: pufit <[email protected]> * Only a provider that does not answer spares a queued extraction an attempt A request the client cannot make at all (a bad scheme, a local protocol error) is the request's failure and spends an attempt; no connection, a timeout, an answer cut off, no gateway token, or a 502/503/504 spends none. Signed-off-by: pufit <[email protected]> * The CLI surface snapshot pins the in-database refusal in reembed's help Signed-off-by: pufit <[email protected]> * The embedding worker holds writer groups, not stub keys, and binds lists that fit Holding a writer's stubs by their keys put up to 2000 eight-string tuples in one parameter, and the 4x read put 1600 candidate keys in the next two: both past ClickHouse's 128 KiB form-field limit (http_max_field_value_size), so once enough stubs were held every pass failed with "Field value too long". The worker now keeps the held identities (each stub's writer's) and the (org, namespace, agent, user_id) groups their stubs are in. The selection reads the held groups' stubs after every other stub (a handful of tuples, cut to one field), and the held identities' rows among what it reads are left uncalled, so other writers' stubs, a held writer's neighbours under its label included when the batch has room, are embedded meanwhile. The read is the batch again, not four times it. Every list a stub read or writer lookup binds goes in chunks that each fit one field (server/core/ch_params.py), measured as the driver renders them. session_writers read loom.memory without FINAL and by created_at, so it could name the writer of a deleted memory or of a replaced version (an update keeps created_at). It reads FINAL now and picks by version, as the profile fold does. Signed-off-by: pufit <[email protected]> * The extraction queue's enqueuer gets its own column, so the claim reads no payloads The claim left out every enqueuer with a request held now by reading JSONExtractString(payload) in both its outer NOT IN and the subquery, so each 15-second pass read every payload in the table twice (3000 finished rows of 20 KB: 120 MB a pass, against 165 KB before), growing for the queue's 30 days. Migration 063 adds memory_extraction_queue.enqueued_by (String DEFAULT ''), the principal the payload already names. enqueue writes it, every mirrored version carries it, a hold fills it for a row queued before the column, and the claim's held-enqueuer check reads it with the other narrow columns, so the payload is read for the claimed rows alone. A row queued before the column reads '' and is claimed and held at once if its enqueuer is held. The queue's column list is pinned to the table's in the schema test. Signed-off-by: pufit <[email protected]> * The profile fold reads four times its slots and gives a held identity's to the next The fold runs every six hours and a hold lasts ten minutes, so an identity held in one pass was selected again by the next, and ten held identities at the top of the ranking took every slot, pass after pass. The scan now reads four times max_identities_per_pass, and a fold held in the pass takes no slot: the next identity read is folded in its place, and the held one stays out of the selection while its hold lasts. A switch gone unread ends the pass. Signed-off-by: pufit <[email protected]> * Rendered identity header values are trimmed, and left out when only space remains A template such as "{email} via loom" rendered " via loom" for an agent, which has no address, and the HTTP layer refuses a header value with a leading space. Each value is now trimmed after rendering; one with nothing left is not sent. Signed-off-by: pufit <[email protected]> * A short wait on a request's model call is waited out once before it is deferred A "wait" answer made a request fail at once with 503 MODEL_CALL_DEFERRED, where Loom used to retry a busy provider in process; the gateway's per-agent request limit asks for one second. A request's call (never a job's) asked to wait two seconds or less now waits it out once and lets its sender's own retry ask again; a second such answer for the same call, or a longer wait, defers it. A job's call is still held at once. Signed-off-by: pufit <[email protected]> * The built-in refusals table matches the gateway's answers by code The inference proxy now writes a stable error.code in every body, so the default LOOM_INFERENCE_IDENTITY_REFUSALS_JSON matches its per-agent answers by code: agent_denied (403), identity_incomplete and identity_malformed (400) refused, agent_request_limit (429) a wait. The metering's budget refusal is matched twice: by code (budget_exceeded) on OpenAI routes, and by type and whole message (rate_limit_error, "budget exceeded") in the Anthropic envelope of /v1/messages, which carries no code. token_unavailable and identity_missing stay out of the table and the docs say never to list them: the first is also what a credential-service outage answers, the second a gateway with no default agent, and either would vanish from health. The deployment-level answers (caller_*, scope_not_granted, route_not_found, upstream_*, misconfigured, no_identity) stay provider failures. The docs' examples match by code, no longer by message text. Signed-off-by: pufit <[email protected]> * A loom command names its namespace, and one naming none is refused while the headers name the agent The CLI named only --org around a command's model calls, so an in-process import's calls rendered no agent and went out as the gateway's default agent (not refused, since an org was named). The dispatcher now names the command's --namespace too, so its calls are for the agent whose namespace it is, and while the identity headers name the agent, a command's call with --org and no namespace or subject is refused (MODEL_CALL_UNATTRIBUTED, logged) rather than billed to the default agent. Commands that walk namespaces name each row's own. Signed-off-by: pufit <[email protected]> * A deferred conflict judge scheduled inside a job is for the job's writer schedule_settle took the request's caller, which a worker has none of, so a write an extraction replay made for its enqueuer sent its deferred judge out for the namespace's agent. It now takes whom the surrounding calls are for (a request's caller, or the writer a job named for its row), else the write's own principal from its provenance; a pipeline's own write still names no one. Signed-off-by: pufit <[email protected]> * The SDK references say where a deferred model call's wait is; a stale test citation is fixed MODEL_CALL_DEFERRED reaches both SDKs as BackendUnavailable, which carries no retry_after_s: the references say the wait is in detail.retry_after_s and the Retry-After header (the Python transport's retries of an idempotent op honour it), and the error's docstring says so too. The provenance registry's comment named a test file that does not exist. Signed-off-by: pufit <[email protected]> * The analyzer corpus drives the new statements, and its shape list is current Regenerates tests/analyzer/shapes.txt for the claim, pending_count and the schema dump, and adds cases so CI checks the new statements against an engine: the queue's TTL drop, the session-writer read, the profile fold's scan with and without a held identity, and the stub selection through its FINAL read with and without a held group ordered last. Signed-off-by: pufit <[email protected]> * The architecture page describes the holds as they now work The embedding worker orders a held writer's groups last instead of reading four times its batch, the profile fold over-fetches instead, and the queue's held-enqueuer check reads its own column. Signed-off-by: pufit <[email protected]> * The carry-columns test reads the stub selection's FINAL read where it now is find_embedding_stubs reads its stubs in _stub_rows (one read per bound chunk of keys); the test that pins the columns the RMT carry needs reads that function and checks find_embedding_stubs calls it. Signed-off-by: pufit <[email protected]> * Deployment calls inside a loom command are exempt, the refusal log no longer leaks across tests, and list parameters are measured in bytes The CLI's no-namespace refusal had no exemption for the deployment's own calls, so `loom recalibrate`, or a model change's calibration run inside a command, was refused while identity headers were on. A call inside customer.system() is exempt from it, as from the no-org refusal. The test suite now clears the once-a-minute limiter of the MODEL_CALL_UNATTRIBUTED log line after every test (tests/unit/conftest.py), which made the CLI refusal test depend on the order tests ran in (seed 1357); the test asserts the refusal itself. server/core/ch_params.py measured a parameter's rendered length in characters, but ClickHouse limits the field in bytes: 300-character CJK keys made a 65,359-character chunk of 148,759 bytes. It measures UTF-8 bytes now, tested with multi-byte keys. Signed-off-by: pufit <[email protected]> * The structured profile build calls for its user's namespace, user and writer The structured profile worker from #93 named only the org, so its model calls went out as the gateway's default agent. build_profile now names the namespace, the user and the newest principal that wrote the facts it reads (user_facts returns each fact's actor and version), as the profile fold does; a pipeline's or a worker's own write names no principal, and the call is then for the agent whose namespace it is. A build held for its identity (customer.GROUP_HOLDS: the org switched off, the identity refused, asked to wait or unread) leaves that user out of the namespace's passes until the hold ends (hold_seconds, as the fold's), through the worker's own per-user wait: no failure is counted, and a failure backoff's next wait stays as it was. Other holds still only skip the user. Tests pin the identity the build sends (the newest writer; the namespace's agent when no principal wrote the facts) and that a held user waits out its hold while the pass and the next one take the namespace's other users. Signed-off-by: pufit <[email protected]> * Keep model attribution and held work correct across retries Signed-off-by: Lareb Zafar <[email protected]> * Attribute filtered model inputs and count held extraction work Signed-off-by: Lareb Zafar <[email protected]> * Model unmerged rows and worker inputs accurately in tests Signed-off-by: Lareb Zafar <[email protected]> * Keep unchanged analyzer descriptions as generated on main Signed-off-by: Lareb Zafar <[email protected]> * Record held enqueuer claim SQL in the analyzer corpus Signed-off-by: Lareb Zafar <[email protected]> * Collections menu focus rings fit inside their cells Signed-off-by: Lareb Zafar <[email protected]> * Projection repair walks past held failures A keyset cursor lets each bounded pass reach later failures while held identities remain active. Timestamp ties follow ClickHouse's native UUID order. Signed-off-by: Lareb Zafar <[email protected]> * Exercise current knowledge hits and resolver attribution in unit tests Signed-off-by: Lareb Zafar <[email protected]> * jsdom supplies scrolling for delayed transcript navigation Signed-off-by: Lareb Zafar <[email protected]> * Accessibility audits wait for the page entry fade Signed-off-by: Lareb Zafar <[email protected]> * Assert default user and session in sensitivity canary responses Signed-off-by: Lareb Zafar <[email protected]> * Record namespace guide statements in the analyzer corpus Signed-off-by: Lareb Zafar <[email protected]> * Focused rows stay visible during page entry The entry translation suppresses scroll anchoring while offscreen rows replace their size estimates. Focus removes the translation while the opacity fade continues, so keyboard navigation keeps the row clear of the sticky toolbar. Signed-off-by: Lareb Zafar <[email protected]> * Back keeps its saved scroll offset after focus Restoration checks the offset one frame after scrolling or focusing. Deferred rows can resize after focus and change the offset, so restoration continues until the requested position remains in place. The existing timeout bounds missing content. Signed-off-by: Lareb Zafar <[email protected]> * Drain buffered events before erasure counts their rows A delayed telemetry batch can arrive after the event deletion step finds no rows and fail the residue census. Serialize flushes and drain this replica before counting, with a bounded wait that leaves erasure retryable. Coalesce threshold flushes so slow inserts do not accumulate waiting tasks. Signed-off-by: Lareb Zafar <[email protected]> * Row estimates use content height Skeletons and estimates share a row height. Containment subtracts the existing padding and borders because its size applies to content. The browser regression measures a fresh skipped box instead of comparing different box models. Signed-off-by: Lareb Zafar <[email protected]> * Namespace keyboard checks wait for search focus Popover visibility precedes the lazy panel focus handoff. Arrow-key traversal starts after the search owns focus, preserving the scroll and fade assertions. Signed-off-by: Lareb Zafar <[email protected]> * Configure the event drain deadline used by erasure Expose the five-second event drain deadline as LOOM_ERASURE_EVENT_DRAIN_TIMEOUT_S. Reject non-positive and non-finite values so erasure always bounds its wait before counting event rows. Signed-off-by: Lareb Zafar <[email protected]> * Scope model-call selector fixtures to their own namespace Global bounded selectors can fill their batches from unrelated orgs before reaching the fixture. Keep both fixture orgs in one fresh namespace and use the existing namespace filters while retaining the limits and switch assertions. Signed-off-by: Lareb Zafar <[email protected]> * Extraction tests expect ignored learning arguments to be removed Signed-off-by: Lareb Zafar <[email protected]> --------- Signed-off-by: pufit <[email protected]> Signed-off-by: Lareb Zafar <[email protected]> Co-authored-by: Lareb Zafar <[email protected]>
zlareb1
added a commit
that referenced
this pull request
Oct 22, 2026
… /me landing, and platform-admin machine identities (#110) * Coded vector DDL follows the codec settings this user can have on Loom took enable_quantized_codec for available whenever system.settings listed it. ClickHouse Cloud lists it but holds it read-only: its default is 0, and the operator enables it per service with a settings-profile override. Where it is held at 0, the coded CREATE sent SETTINGS enable_quantized_codec = 1 and the server refused it (code 452), so a fresh install failed instead of creating the plain layout. With the codec enabled, allow_suspicious_codecs stays read-only at 0 there, and the entity_vectors CREATE failed on its LZ4 chain (code 36 without the setting, 452 with it). Every path that creates a coded table reads value, readonly, min, max and disallowed_values of the codec settings before it sends any (vector_codec_ddl.CodecSettings). A setting is held when this user may not set it to 1: readonly, or a <max>0</max> or <disallowed>1</disallowed> constraint, which system.settings shows with readonly = 0. state enable_quantized_codec allow_suspicious_codecs settable coded, sent LZ4 chain kept, sent held at 1 coded, not sent LZ4 chain kept, not sent held at 0 plain layout Quantized alone, not sent absent plain layout Quantized alone, not sent - the migration runner's fresh-install layout, and codes_state's codec_available; - the provider rebuild's candidate table: refused before its CREATE where the codec cannot be on (an owned stale candidate is dropped first), its chain dropped where it must be; 26.7 keeps the allow_experimental_codecs gate under the same rule; - scripts/ops/vector_codec_rebuild.py: refuses to run where the codec cannot be on, and refuses --chain where allow_suspicious_codecs cannot be; a held setting goes with no statement, the copy, the deltas and a rollback included; - dev/restore_loom.py: refuses a backup with coded tables before anything is written, --dry-run included, where the codec settings cannot be read or the codec cannot be on (checked again under the restore lock), and drops the chain on an explicit CREATE. Without the chain, entity_vectors.entity_embedding takes about four times the space LZ4 gave it: the operator enables allow_suspicious_codecs and rebuilds that table with --chain LZ4, or accepts the larger column. The server accepts a held setting sent at its current value, and clickhouse-connect drops a readonly one before sending; a held setting is left out so neither is relied on. Servers where both settings are settable, and servers before 26.8, take the same layout and settings as before. The one difference on 26.7: scripts/ops/vector_codec_rebuild.py refuses with the reason instead of failing on UNKNOWN_SETTING. Unit tests cover every state pair and each constraint shape at the migration runner and the provider rebuild, and each tool's refusal and degrade branch. Signed-off-by: pufit <[email protected]> * feat(oidc): reach the provider at a back-channel base, verify the algorithms it lists LOOM_OIDC_BACKCHANNEL_BASE_URL (default empty) names a base URL (http(s), host, optional port) Loom reaches the identity provider at when the issuer's own host is not reachable from it. Loom's own calls to the issuer's host (discovery at <base>/<issuer path>/.well-known/ openid-configuration, the token and revocation endpoints, the signing keys) go there with the path kept and the issuer's host in Host; the browser still goes to the issuer's authorization endpoint, an endpoint on another host is called as it is, and the discovery document and every ID token must still name LOOM_OIDC_ISSUER. None of these calls follows a redirect. The value is checked at load and never echoed. An ID token is verified with the algorithms the discovery document lists in id_token_signing_alg_values_supported among RS256, RS384, RS512, PS256, ES256, ES384 and ES512 (RS256 alone when it lists none), so a provider that signs with ES256 signs people in; none and HMAC algorithms are never accepted. Signed-off-by: pufit <[email protected]> * feat(auth): let a machine identity hold platform_admin, and mint it with an expiry A control plane that administers Loom (registers trusts, grants, erasure) had no sanctioned way to hold an expiring platform-admin credential: the role was conferred only at sign-in from LOOM_PLATFORM_ADMINS. - `loom bot create --platform-admin` and "platform_admin": true on /v1/admin/bots.create (platform admins only) register a bot whose every token holds the role: a flat token over every namespace, hour-long as any bot's, ended by `loom bot disable`. Such a bot names no namespace and takes no agent claim (refused at registration). The flag is a new column, loom.machine_identities.platform_admin (migration 072, DEFAULT 0), recorded in the auth.machine_created audit row and shown by `loom bot list` and /v1/admin/bots.list. The check that two trusts of one issuer cannot take one token is unchanged; trusts kept apart by their sub claims register side by side. - `loom mint-token --platform-admin --subject sa:<name> --ttl-days N` mints the role for a service account and refuses a token without an expiry, a person's subject, --user-token and --namespace-role. A build without the column writes 0 when it saves a bot, and mints no token for a platform-admin bot (it names no namespace), so a rolling upgrade never widens a bot. schemas/schema.sql carries the column as the dump lays out an added one. Signed-off-by: pufit <[email protected]> * fix(auth): a platform-admin bot is registered by a person, with exact claims Review fixes for platform-admin machine identities: - A bot row or dict without platform_admin (an older build's, the integration fixture's) reads as one without the role: machines.save, the token exchange and the listings read the flag with a default instead of raising KeyError. The integration fixture names it. - /v1/admin/bots.create refuses platform_admin (create and replace) to every service account's token, a platform-admin bot's own included, so a leaked hour-long token cannot register itself a lasting successor with a generated key or an issuer of its own; a person signed in as a platform admin, or `loom bot create` on the host, registers one. - A platform-admin trust matches every claim exactly: a prefix (`*`) would hand the role to every token it matches. - `loom mint-token --platform-admin` mints for at most 90 days, never for an agent's subject (sa:<trust>:<agent>), and records each mint as an auth.platform_admin_minted audit row before printing the token; a mint the audit log misses is not handed out. - The docs register the platform-admin trust with an audience of its own. Signed-off-by: pufit <[email protected]> * docs(schema): state the platform-admin column's rolling-upgrade rule docs/architecture/rolling-upgrades.md gains rule 24 for 072_machine_platform_admin.sql: existing bots read 0; an N-1 replica answers a platform-admin bot's exchange 401 and refuses the field on bots.create (422), so such a bot is registered and used only after the rollout; N-1 writes the flag back to 0 only on an explicit disable or replace. Signed-off-by: pufit <[email protected]> * fix(oidc): only the sign-in provider's own keys go through the back-channel base oidc.signing_key is shared with the machine-identity path, so a bot trust's https jwks_uri on the issuer's host was fetched over LOOM_OIDC_BACKCHANNEL_BASE_URL, past bot_from's https rule. The route now applies only when verify_id_token asks for the sign-in provider's keys (sign_in=True); a trust's keys are fetched from the address it names, and the client cache keeps the two apart. Signed-off-by: pufit <[email protected]> * fix(auth): a dashboard sign-in reads revocations before it mints The dashboard sign-in reads revocations from ClickHouse before it mints, as every other mint does: a revoked subject gets "Sign-in denied" (audited as auth.signin_denied) instead of a token refused at its first use, and a failed read answers the sign-in-unavailable page. The SSO callback lands on /me#token=, the page served without the LOOM_DASHBOARD_REDIRECT_URL redirect, so the fragment never follows a redirect to another origin. The break-glass and minted-token instructions and the HTTP route table name /me, and the tests pin the landing. Signed-off-by: pufit <[email protected]> * fix(auth): a third-party client's session registers no platform-admin bot - /v1/admin/bots.create also refuses platform_admin to a third-party MCP client's session token (a session id, not first-party): its tokens end with the session, so it mints nothing that outlives it, as delegation already rules; a person's own `loom login` or dashboard session still registers one. - The dashboard page says /me is the one page load the aggregator redirect (LOOM_DASHBOARD_REDIRECT_URL) leaves alone. - Tests name their trusts with neutral placeholders. Signed-off-by: pufit <[email protected]> * Renumber the platform-admin migration to 074: main took 072 Signed-off-by: pufit <[email protected]> * Short-lived tokens cannot rebind an account's SSO sign-in either bots.create refuses platform_admin to a service account's token and to a third-party session, but sso.link, sso.adopt (apply), sso.unlink and sso.password_link took any platform-admin bearer: a platform-admin bot could link an admin's account to an address it holds, sign in as that admin and register a lasting admin bot. They now refuse those callers the same way. Signed-off-by: pufit <[email protected]> * The unit and integration jobs fit their suites, and the docker smoke and a replay test wait for what they check (#140) * The docker smoke passes until every fixture has its first index The code smoke seeded its eight fixture repositories with at most five back-to-back ingest passes and went on to the compiler tiers whether or not every git_head had landed. A pass hands a missing mirror's clone to a background job and moves on, and an entry's first index (its git_head) is written by the bootstrap leg of a later pass. When the clones took longer than five quick passes, as on the amd64 Quickstart run of main at 49b3d356 (the five passes and the Python tier ended 0.3 s after the first clone's sandbox probe), scip_py_delta found no git_head and the smoke failed with "code-docker-smoke-python: git_head not seeded". The same tree passed on the pull request's own run and on arm64. The seed now passes until every entry's git_head equals its head, a second apart, and fails naming the entries still without one after 180 s. Two unit tests drive seed() with collaborators whose heads land on the eighth pass, and with none landing. Signed-off-by: pufit <[email protected]> * The replay test waits for its failure's resolved mark test_a_replay_that_inserted_never_inserts_again_after_a_failed_repair asserted that the org has no active projection failure right after the second retry returned resolved. The retry marks the failure with mark_projection_failures_resolved, an ALTER UPDATE without mutations_sync, so the mark lands in the background; _mutations_done waits only for the triple and edge mutations. On a loaded runner the read came first and listed the failure still active, with the payload of the replay that resolved it (main at 49b3d356 and at 18fe4dd3). The test now waits up to 30 s for the active list to empty, as the 4,000-failure mark test in test_retirement_ch.py does; a mark that never lands still fails it. Signed-off-by: pufit <[email protected]> * The unit and integration jobs have room for the suites they run Over the last 40 pushes to main the unit job's pytest step took 16.9 to 29.7 minutes, and the job hit its 30-minute limit in 10 of them: on 49b3d356 it was cancelled at 99% with every test so far passing (the same seed passes locally, 23,345 tests). The integration job's first pytest step has taken 42 to 59 minutes since the conflict-resolver tests arrived, before the auth-on server's tests (about 6 minutes) start; it was cancelled at its 60-minute limit on 7fba7f5d and 87879ba6, and the green pull request run of 49b3d356's tree took 56 minutes. Neither job hangs: both are cut off while still passing tests. The unit job now has 45 minutes and the integration job 90. Signed-off-by: pufit <[email protected]> --------- Signed-off-by: pufit <[email protected]> * Bump the actions group with 2 updates (#141) Bumps the actions group with 2 updates: [astral-sh/setup-uv](https://github.com/astral-sh/setup-uv) and [actions/setup-node](https://github.com/actions/setup-node). Updates `astral-sh/setup-uv` from 10.2.0 to 10.3.0 - [Release notes](https://github.com/astral-sh/setup-uv/releases) - [Commits](https://github.com/astral-sh/setup-uv/compare/v10.2.0...1c37ad07a6a961277cf70c0d37d6f313000f5884) Updates `actions/setup-node` from 7.0.0 to 7.1.0 - [Release notes](https://github.com/actions/setup-node/releases) - [Commits](https://github.com/actions/setup-node/compare/v7...949feb2413d6458794dcd2491c4babbbce0c15c1) --- updated-dependencies: - dependency-name: astral-sh/setup-uv dependency-version: 10.3.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: actions - dependency-name: actions/setup-node dependency-version: 7.1.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: actions ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Model calls name whom they are for, and a gateway refusing one identity holds only that identity (#111) * Model calls name whom they are for in configurable identity headers LOOM_INFERENCE_IDENTITY_HEADERS_JSON maps header names to templates over {org}, {namespace}, {subject}, {user_id}, {agent}, {tenant} and {email}. Every chat, embedding, rerank and classify request carries them. A request names its token's subject; a background job names the writer of the row it works on, else the agent whose own namespace the row is in, and splits a batch by identity. A gateway that bills each agent then sees the agent behind background work as well as requests, instead of the deployment for both. With no templates nothing changes. Signed-off-by: pufit <[email protected]> * The workload token can be sent to the gateway as the bearer itself LOOM_INFERENCE_WORKLOAD_TOKEN_MODE=bearer sends the content of LOOM_INFERENCE_WORKLOAD_TOKEN_FILE as Authorization: Bearer on every model call, for a gateway that verifies the workload's token itself and has no token exchange. The file is read again at most once a minute and at once after the gateway answers 401, so a rotated token is picked up without a restart. The mode requires the gateway, as the exchange does, so the token goes nowhere else. A keyless compatible embedder now sends the workload token in either mode instead of falling back to the fake embedder. The default mode, exchange, behaves as before. Signed-off-by: pufit <[email protected]> * A gateway refusing one identity holds that identity's calls, not the provider With identity headers set, a 403 or a 429 whose error names a budget, from a gateway host, is the gateway refusing the identity the call was made for. The model client's response hook raises ModelCallRefused (403, MODEL_CALL_REFUSED, with the gateway's status and code) instead of an HTTP error, so the request answers it, nothing retries it or hands it to the fallback model, /v1/health does not read it as a provider failure, and the org's switch is untouched. It is one of customer.HOLDS: a background job leaves the row as it is, and for LOOM_INFERENCE_REFUSAL_COOLDOWN_SECONDS (600) its calls for that identity are refused before anything is sent, while other identities' work goes on. One over-budget agent no longer reads as the provider being down for the whole deployment. Any other 429 is a rate limit, retried as before. The bearer tests now point each sender at a fresh model client: a sender first imported while another test patched get_model_client kept that patch. Signed-off-by: pufit <[email protected]> * A job's model call is for the row's writer, the namespace's agent only without one Jobs that never passed the writer fell back to the namespace's owner even when the row recorded its actor, so the owner agent, or nobody for a shared namespace, paid for a member's or another agent's work. The embedding worker, projection repair and the code-link judge now read the writer of the memory they work on; observe-extract takes the newest writer of the session's observations, a profile fold the newest writer of its facts, reflection and the period digest the newest writer of the session's memories, and the conflict sweep passes the write's writer to settle(). The owner is used only for a row that records no principal. A pipeline's own actor (process:extraction-worker, process:cli:<command>, the other provenance.PIPELINE_ACTORS) names no principal: subject_of() returns '' for it, so such a row falls back to its namespace instead of going out with no agent. A test pins every process:<name> literal in the server to the registry. The writer reads run only while an identity header names more than the org and namespace. Signed-off-by: pufit <[email protected]> * Identity headers name the agent whole, and a call naming no org is refused The headers whose templates name {agent} or {tenant} are now sent together or not at all. An agent whose trust requires no exact tenant, or a trust's own token, used to send the agent header alone; the gateway refuses half an identity with a 400, which read as a provider failure for the whole cell. Now neither goes and the gateway applies its default identity. With identity headers set, a call that names no org is refused and logged (MODEL_CALL_UNATTRIBUTED) unless it is the deployment's own, as it already was with the customer header: an MCP call whose identity stamping failed, or a loom command run without --org, no longer goes out under the gateway's default identity. A job batching rows now groups them by the identity they render, so one agent's rows in several namespaces share a call. Templates are trimmed, and an empty template or a hop-by-hop header name is refused at load. Signed-off-by: pufit <[email protected]> * Only the answers a deployment lists hold one identity, matched exactly LOOM_INFERENCE_IDENTITY_REFUSALS_JSON lists the gateway answers that are one identity's, not the provider's: {"refused": [...], "wait": [...]}, each entry a status and at least one of the error body's code, type or message, matched exactly. The default lists the metering's 429 budget_exceeded. A refused answer raises ModelCallRefused as before; a wait answer (too many of an agent's requests in progress, no credential for it yet) raises the new ModelCallDeferred, 503 MODEL_CALL_DEFERRED with the gateway's Retry-After. Any other answer is the provider's: another 403 is a provider failure again, still not retried, and no word in a message counts. A job's hold moves from customer.require() to the model client's request hook (gateway.sending) and is keyed by the identity and the path and model the answer was for, so one model's refusal no longer holds an agent's embeddings. A wait holds for its Retry-After (at most 5 minutes), a refusal for the cooldown, and a success at that path and model ends the hold. The identity headers go only to the gateway's hosts: the request hook drops them from any other request, a redirect hop included, and setting them now requires LOOM_INFERENCE_GATEWAY_HOSTS. The reranker and the classifier post through the model client (never redirected, as before), so the gateway check, the identity headers and the refusal handling apply to them, and a refusal raises instead of keeping the input order or the caller's type. Signed-off-by: pufit <[email protected]> * A job skips an identity the gateway holds instead of stalling on it A job that meets a held identity remembers the work it left until the hold ends (server/workers/holds.py, ModelCallRefused.hold_s) and leaves it out of its next selections, so its batch goes to other identities' work. The profile fold leaves the held identity out of its scan. The embedding worker names the held stubs for find_embedding_stubs to leave out (exclude_keys) and, while any identity is held, reads four times its batch and drops the held identities' stubs before calling, so stubs a held writer filled the oldest slots with no longer stop other writers' stubs from being embedded. What names an identity going unread (IdentityUnread) now holds one group like a switched-off org or a refused identity (customer.GROUP_HOLDS) in the four batch embedders: the memory and code embedding workers, loom reembed and a model rebuild write the vectors the other groups' calls bought instead of stopping the pass or failing the rebuild step as a provider error. Signed-off-by: pufit <[email protected]> * The extraction queue holds, backs off and spends no attempt on an outage A replay whose model call is held (the org switched off since the claim, the switch unread, the enqueuer's identity refused, asked to wait or unread) is marked `held` with the reason in last_error until the hold ends, instead of staying `running` behind its lease; no attempt is spent. While it is held the claim takes none of that enqueuer's other requests in the namespace and for that user, so the batch goes to other work rather than rows that would only be held again. A failed attempt now waits 15 s, 1, 5, then 30 minutes before the next claim, and LOOM_EXTRACTION_QUEUE_MAX_ATTEMPTS defaults to 8 instead of 3 (recorded in the settings history). A model provider or gateway that cannot be reached (a transport error, a timeout, 502/503/504) spends no attempt and waits the same backoff. A request still waiting on its last day before the table's 30-day TTL is dropped with a memory_drops record (held_past_ttl or waited_past_ttl) and marked failed, never removed unseen. memory.extraction_status takes and reports the `held` state, and its pending count, memory.search's pending_extraction and the pending evidence include held batches. Signed-off-by: pufit <[email protected]> * code.refresh calls models as its caller; in-database reembed is refused when calls must be named The ingest pass code.refresh runs (the poller's) now makes its model calls for the request's caller, its token's subject, as any request's calls are; the poller's calls stay the namespace's agent's. loom reembed --in-database is refused, before any row is read, while a customer header or identity headers are set or the inference gateway is required: ClickHouse's aiEmbed calls the provider itself, naming no customer or identity and outside the gateway's host check. The CLI prints the reason and exits 2; the Python path is unchanged. Signed-off-by: pufit <[email protected]> * Identity headers are decoded once per value, not on every read Every model call reads LOOM_INFERENCE_IDENTITY_HEADERS_JSON several times (rendering, grouping, the request hook, the gateway's answer); it is now decoded once per value, as the refusals table is. Signed-off-by: pufit <[email protected]> * Only a provider that does not answer spares a queued extraction an attempt A request the client cannot make at all (a bad scheme, a local protocol error) is the request's failure and spends an attempt; no connection, a timeout, an answer cut off, no gateway token, or a 502/503/504 spends none. Signed-off-by: pufit <[email protected]> * The CLI surface snapshot pins the in-database refusal in reembed's help Signed-off-by: pufit <[email protected]> * The embedding worker holds writer groups, not stub keys, and binds lists that fit Holding a writer's stubs by their keys put up to 2000 eight-string tuples in one parameter, and the 4x read put 1600 candidate keys in the next two: both past ClickHouse's 128 KiB form-field limit (http_max_field_value_size), so once enough stubs were held every pass failed with "Field value too long". The worker now keeps the held identities (each stub's writer's) and the (org, namespace, agent, user_id) groups their stubs are in. The selection reads the held groups' stubs after every other stub (a handful of tuples, cut to one field), and the held identities' rows among what it reads are left uncalled, so other writers' stubs, a held writer's neighbours under its label included when the batch has room, are embedded meanwhile. The read is the batch again, not four times it. Every list a stub read or writer lookup binds goes in chunks that each fit one field (server/core/ch_params.py), measured as the driver renders them. session_writers read loom.memory without FINAL and by created_at, so it could name the writer of a deleted memory or of a replaced version (an update keeps created_at). It reads FINAL now and picks by version, as the profile fold does. Signed-off-by: pufit <[email protected]> * The extraction queue's enqueuer gets its own column, so the claim reads no payloads The claim left out every enqueuer with a request held now by reading JSONExtractString(payload) in both its outer NOT IN and the subquery, so each 15-second pass read every payload in the table twice (3000 finished rows of 20 KB: 120 MB a pass, against 165 KB before), growing for the queue's 30 days. Migration 063 adds memory_extraction_queue.enqueued_by (String DEFAULT ''), the principal the payload already names. enqueue writes it, every mirrored version carries it, a hold fills it for a row queued before the column, and the claim's held-enqueuer check reads it with the other narrow columns, so the payload is read for the claimed rows alone. A row queued before the column reads '' and is claimed and held at once if its enqueuer is held. The queue's column list is pinned to the table's in the schema test. Signed-off-by: pufit <[email protected]> * The profile fold reads four times its slots and gives a held identity's to the next The fold runs every six hours and a hold lasts ten minutes, so an identity held in one pass was selected again by the next, and ten held identities at the top of the ranking took every slot, pass after pass. The scan now reads four times max_identities_per_pass, and a fold held in the pass takes no slot: the next identity read is folded in its place, and the held one stays out of the selection while its hold lasts. A switch gone unread ends the pass. Signed-off-by: pufit <[email protected]> * Rendered identity header values are trimmed, and left out when only space remains A template such as "{email} via loom" rendered " via loom" for an agent, which has no address, and the HTTP layer refuses a header value with a leading space. Each value is now trimmed after rendering; one with nothing left is not sent. Signed-off-by: pufit <[email protected]> * A short wait on a request's model call is waited out once before it is deferred A "wait" answer made a request fail at once with 503 MODEL_CALL_DEFERRED, where Loom used to retry a busy provider in process; the gateway's per-agent request limit asks for one second. A request's call (never a job's) asked to wait two seconds or less now waits it out once and lets its sender's own retry ask again; a second such answer for the same call, or a longer wait, defers it. A job's call is still held at once. Signed-off-by: pufit <[email protected]> * The built-in refusals table matches the gateway's answers by code The inference proxy now writes a stable error.code in every body, so the default LOOM_INFERENCE_IDENTITY_REFUSALS_JSON matches its per-agent answers by code: agent_denied (403), identity_incomplete and identity_malformed (400) refused, agent_request_limit (429) a wait. The metering's budget refusal is matched twice: by code (budget_exceeded) on OpenAI routes, and by type and whole message (rate_limit_error, "budget exceeded") in the Anthropic envelope of /v1/messages, which carries no code. token_unavailable and identity_missing stay out of the table and the docs say never to list them: the first is also what a credential-service outage answers, the second a gateway with no default agent, and either would vanish from health. The deployment-level answers (caller_*, scope_not_granted, route_not_found, upstream_*, misconfigured, no_identity) stay provider failures. The docs' examples match by code, no longer by message text. Signed-off-by: pufit <[email protected]> * A loom command names its namespace, and one naming none is refused while the headers name the agent The CLI named only --org around a command's model calls, so an in-process import's calls rendered no agent and went out as the gateway's default agent (not refused, since an org was named). The dispatcher now names the command's --namespace too, so its calls are for the agent whose namespace it is, and while the identity headers name the agent, a command's call with --org and no namespace or subject is refused (MODEL_CALL_UNATTRIBUTED, logged) rather than billed to the default agent. Commands that walk namespaces name each row's own. Signed-off-by: pufit <[email protected]> * A deferred conflict judge scheduled inside a job is for the job's writer schedule_settle took the request's caller, which a worker has none of, so a write an extraction replay made for its enqueuer sent its deferred judge out for the namespace's agent. It now takes whom the surrounding calls are for (a request's caller, or the writer a job named for its row), else the write's own principal from its provenance; a pipeline's own write still names no one. Signed-off-by: pufit <[email protected]> * The SDK references say where a deferred model call's wait is; a stale test citation is fixed MODEL_CALL_DEFERRED reaches both SDKs as BackendUnavailable, which carries no retry_after_s: the references say the wait is in detail.retry_after_s and the Retry-After header (the Python transport's retries of an idempotent op honour it), and the error's docstring says so too. The provenance registry's comment named a test file that does not exist. Signed-off-by: pufit <[email protected]> * The analyzer corpus drives the new statements, and its shape list is current Regenerates tests/analyzer/shapes.txt for the claim, pending_count and the schema dump, and adds cases so CI checks the new statements against an engine: the queue's TTL drop, the session-writer read, the profile fold's scan with and without a held identity, and the stub selection through its FINAL read with and without a held group ordered last. Signed-off-by: pufit <[email protected]> * The architecture page describes the holds as they now work The embedding worker orders a held writer's groups last instead of reading four times its batch, the profile fold over-fetches instead, and the queue's held-enqueuer check reads its own column. Signed-off-by: pufit <[email protected]> * The carry-columns test reads the stub selection's FINAL read where it now is find_embedding_stubs reads its stubs in _stub_rows (one read per bound chunk of keys); the test that pins the columns the RMT carry needs reads that function and checks find_embedding_stubs calls it. Signed-off-by: pufit <[email protected]> * Deployment calls inside a loom command are exempt, the refusal log no longer leaks across tests, and list parameters are measured in bytes The CLI's no-namespace refusal had no exemption for the deployment's own calls, so `loom recalibrate`, or a model change's calibration run inside a command, was refused while identity headers were on. A call inside customer.system() is exempt from it, as from the no-org refusal. The test suite now clears the once-a-minute limiter of the MODEL_CALL_UNATTRIBUTED log line after every test (tests/unit/conftest.py), which made the CLI refusal test depend on the order tests ran in (seed 1357); the test asserts the refusal itself. server/core/ch_params.py measured a parameter's rendered length in characters, but ClickHouse limits the field in bytes: 300-character CJK keys made a 65,359-character chunk of 148,759 bytes. It measures UTF-8 bytes now, tested with multi-byte keys. Signed-off-by: pufit <[email protected]> * The structured profile build calls for its user's namespace, user and writer The structured profile worker from #93 named only the org, so its model calls went out as the gateway's default agent. build_profile now names the namespace, the user and the newest principal that wrote the facts it reads (user_facts returns each fact's actor and version), as the profile fold does; a pipeline's or a worker's own write names no principal, and the call is then for the agent whose namespace it is. A build held for its identity (customer.GROUP_HOLDS: the org switched off, the identity refused, asked to wait or unread) leaves that user out of the namespace's passes until the hold ends (hold_seconds, as the fold's), through the worker's own per-user wait: no failure is counted, and a failure backoff's next wait stays as it was. Other holds still only skip the user. Tests pin the identity the build sends (the newest writer; the namespace's agent when no principal wrote the facts) and that a held user waits out its hold while the pass and the next one take the namespace's other users. Signed-off-by: pufit <[email protected]> * Keep model attribution and held work correct across retries Signed-off-by: Lareb Zafar <[email protected]> * Attribute filtered model inputs and count held extraction work Signed-off-by: Lareb Zafar <[email protected]> * Model unmerged rows and worker inputs accurately in tests Signed-off-by: Lareb Zafar <[email protected]> * Keep unchanged analyzer descriptions as generated on main Signed-off-by: Lareb Zafar <[email protected]> * Record held enqueuer claim SQL in the analyzer corpus Signed-off-by: Lareb Zafar <[email protected]> * Collections menu focus rings fit inside their cells Signed-off-by: Lareb Zafar <[email protected]> * Projection repair walks past held failures A keyset cursor lets each bounded pass reach later failures while held identities remain active. Timestamp ties follow ClickHouse's native UUID order. Signed-off-by: Lareb Zafar <[email protected]> * Exercise current knowledge hits and resolver attribution in unit tests Signed-off-by: Lareb Zafar <[email protected]> * jsdom supplies scrolling for delayed transcript navigation Signed-off-by: Lareb Zafar <[email protected]> * Accessibility audits wait for the page entry fade Signed-off-by: Lareb Zafar <[email protected]> * Assert default user and session in sensitivity canary responses Signed-off-by: Lareb Zafar <[email protected]> * Record namespace guide statements in the analyzer corpus Signed-off-by: Lareb Zafar <[email protected]> * Focused rows stay visible during page entry The entry translation suppresses scroll anchoring while offscreen rows replace their size estimates. Focus removes the translation while the opacity fade continues, so keyboard navigation keeps the row clear of the sticky toolbar. Signed-off-by: Lareb Zafar <[email protected]> * Back keeps its saved scroll offset after focus Restoration checks the offset one frame after scrolling or focusing. Deferred rows can resize after focus and change the offset, so restoration continues until the requested position remains in place. The existing timeout bounds missing content. Signed-off-by: Lareb Zafar <[email protected]> * Drain buffered events before erasure counts their rows A delayed telemetry batch can arrive after the event deletion step finds no rows and fail the residue census. Serialize flushes and drain this replica before counting, with a bounded wait that leaves erasure retryable. Coalesce threshold flushes so slow inserts do not accumulate waiting tasks. Signed-off-by: Lareb Zafar <[email protected]> * Row estimates use content height Skeletons and estimates share a row height. Containment subtracts the existing padding and borders because its size applies to content. The browser regression measures a fresh skipped box instead of comparing different box models. Signed-off-by: Lareb Zafar <[email protected]> * Namespace keyboard checks wait for search focus Popover visibility precedes the lazy panel focus handoff. Arrow-key traversal starts after the search owns focus, preserving the scroll and fade assertions. Signed-off-by: Lareb Zafar <[email protected]> * Configure the event drain deadline used by erasure Expose the five-second event drain deadline as LOOM_ERASURE_EVENT_DRAIN_TIMEOUT_S. Reject non-positive and non-finite values so erasure always bounds its wait before counting event rows. Signed-off-by: Lareb Zafar <[email protected]> * Scope model-call selector fixtures to their own namespace Global bounded selectors can fill their batches from unrelated orgs before reaching the fixture. Keep both fixture orgs in one fresh namespace and use the existing namespace filters while retaining the limits and switch assertions. Signed-off-by: Lareb Zafar <[email protected]> * Extraction tests expect ignored learning arguments to be removed Signed-off-by: Lareb Zafar <[email protected]> --------- Signed-off-by: pufit <[email protected]> Signed-off-by: Lareb Zafar <[email protected]> Co-authored-by: Lareb Zafar <[email protected]> * Inserts into the tables written on every request share ClickHouse parts by default and still return once written (#129) * Inserts into the tables written on every request batch server-side in ClickHouse audit_log, conversations, conversation_embeddings, agent_events, the webhook outbox and attempts, entity_canonical_map, memory_evidence, memory_belief_sources and memory_chunks are written with async_insert = 1, wait_for_async_insert = 1: concurrent inserts share a part, and each returns once that part is written. Two live settings bound the wait. bench/write_rate.py measures latency and parts per table at a fixed write rate. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Address review: pin the new defaults, state the parts bound per node and shape, test batched read-back and dedup, harness takes a token Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Address review: parts bound reads both ways, carry acks use the bounded wait, bench counts unstored turns as errors Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Address review: the remaining async-wait inserts use the bounded helper, the shared-parts test stops merges, the docs name each batched writer Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Address review: name the policy witness's exposures rows, fix the chunk insert comment Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Address review: keep code spans whole in the doc, say what a failed shared flush means, read back every field Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Address review: label the interval writers in the batched list, shorten the flush comment Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Address review: sign-in attempts, projection-failure records and graph Undo markers use the bounded helper Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Address review: the attempts comment sits on its insert, the doc lists every batched site, the failure-row test says what it checks Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Address review: entity_canonical_map stays committed, a flush makes one part per partition, the usage drain test expects the batched settings entity_canonical_map is partitioned by org, so a shared flush writes one part per org and can exceed max_partitions_per_insert_block across tenants; it goes back to a committed insert. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Tests check that the tables written on every request use batched inserts A parametrised AST check asserts that the audit_log, agent_events, conversation_embeddings, webhook outbox and attempts, memory_evidence and memory_belief_sources inserts pass `batched_insert_settings()`, and that no insert into them omits `settings=`. The audit test stubs require `settings`, and the emit_many test asserts both audit inserts are batched. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Batched-insert tests pin every insert site, and entity_vectors and write marks batch The read-path test records an insert without settings as the session defaults and any unresolved settings value as a failing entry. The batched test covers memory_chunks, entity_vectors, namespace_write_marks and carry_acks. entity_vectors and every namespace_write_marks insert are sent batched. write_rate.py reports the async_insert value each conversation insert carried, from system.query_log. The architecture page calls inserts that wait "waited", and "committed" means async_insert = 0 only. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * conversation.append and set_from_messages budgets cover their batched waits conversation.append makes two batched inserts in sequence and memory.set_from_messages about six, so their p99 budgets rise to 130 and 2800 ms. The memory.set budget, the restricted-access docstring, the batched-insert comments and the failure-and-recovery page describe batched inserts as waited, not committed, and the batched-insert rule as waited inserts that need no fence or identity token. The runtime-override test fakes go back to their optional settings argument. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Batched inserts are described by the rows that use them, and write_rate.py cleans up its client rows The setting, client and helper text name the inserts sent with batched_insert_settings() instead of defining them by what they lack, the async-insert dedup rule names both kinds, the restricted-access audit docs say the row is a batched insert, the failure page lists the two wait settings in the client table, and write_rate.py runs under a per-run org and deletes its in-process conversation rows at the end. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Async inserts are described as deduplicated by token, and every batched insert site is pinned normalize_insert_settings and the clickhouse.md bullet say dedup_settings turns async deduplication back on with the per-batch token. The conversation append, the graph Undo markers, auth_attempts, memory_projection_failures and memory_usage_events are pinned to batched_insert_settings(); the usage-event fallback insert is batched like its flush. The restricted_audit_inline comment names the awaited insert's whole latency. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Async inserts are deduplicated by token without a separate normalising step, and write_rate.py sends its baseline directly normalize_insert_settings set async_insert_deduplicate = 0 only for dedup_settings to set it back to 1, so it is removed. The batched-insert wait settings describe the writes they affect in two lines each. The write-rate bench passes committed or batched settings to its inserts instead of reassigning a store attribute, and deletes its client rows in a finally block. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Rows with a Quantized-coded vector stay committed, and the session dedup comment says what each insert sends A mis-sized vector fails the shared part of a batched flush and with it every other insert in that flush, so conversation_embeddings, entity_vectors and memory_chunks keep committed inserts. The conversation.append and set_from_messages budgets drop to match. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * The policy witness writes its rows, and write_rate.py reads an unset async_insert as the server default The witness sends batched_insert_settings(), so its helper, docstrings, log lines and test say the row is written, not committed. write_rate.py's inserts_sent read an insert sent at the server's default async_insert (1 on recent releases, which the query log leaves out) as 0; it now reads the default from system.settings. Two long lines are re-wrapped. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * A waited entity-graph insert uses the batched-insert settings, and batched inserts have their own section graph_insert_settings(wait=True) returns batched_insert_settings(), so the live ch_batched_insert_wait_* bounds govern memory.set's waited entity_triples inserts too. The batched-insert convention moves into a "Batched inserts" subsection of the ClickHouse page, with the tables that stay committed listed one group per line, and the failure-and-recovery Inserts row links to it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * write_rate.py deletes only its own run's rows, and batched inserts send the adaptive busy timeout The client-target cleanup scopes its delete to the run's thread ids, so an org named with --org keeps its own transcripts. batched_insert_settings sends async_insert_use_adaptive_busy_timeout = 1, so the min and max wait bounds hold whatever the server profile sets. The duplicate design-principles bullet is gone. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Pin the tables that stay committed, and give entity_canonical_map's reason A block-level error in a shared flush fails every insert waiting on it, so the Quantized-coded vector tables and the org-partitioned canonical map stay committed; a test now pins each of their insert sites. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Batch the conversation embedding row when its width cannot fail the flush A conversation_embeddings row is batched when the column is plain, or coded at the served model's embedding_dim with a vector of that width; it stays committed without a reading or while a model change or rebuild is pending, and a batched row whose flush another width failed is sent again committed. The usage-event recorder loses its unreachable direct-insert branch, and the p99 budgets of the ops that await a batched insert (memory.delete, memory.delete_version, memory.pin, memory.get, memory.get_by_id, conversation.append) cover its wait. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Describe memory.pin's batched inserts, share the committed insert settings, split the usage-buffer lock from the flusher start memory.pin's budget comment names the same inserts as memory.set. The committed insert settings in the conversations store are one module constant the identity-token append and the bench reuse. The usage store's buffer lock comes from _buffer_lock(), so _ensure_usage_flusher_started only starts the flush task and the analyzer can stub it with a no-op. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Give memory.update, update_by_id and restore the outbox wait allowance, and name the batched wait as an OVERLOADED cause memory.update, memory.update_by_id and memory.restore await the same batched outbox insert as memory.delete, so their p99 budgets gain the same 50 ms allowance. The troubleshooting entry for OVERLOADED names batched inserts holding their connection and the settings that bound it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Check every committed-table insert under server/, give memory.pin memory.set's budget, reuse the committed insert settings Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Batch inserts by default behind a live switch, give background inserts a longer wait ch_batched_inserts (live, on) sends every batched insert committed when off. Inserts no request waits on (the usage-event flusher, the write-mark flush and process-start mark, webhook delivery attempts) wait up to ch_batched_insert_background_wait_max_ms (200). memory.bulk_get and memory.history get the batched audit row's allowance, COMMITTED_INSERT_SETTINGS moves to ch_writes, and the docs state ClickHouse's own target and when to turn batching off. Signed-off-by: zlareb1 <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * Describe what the batching switch leaves async, size the pool by mechanism, test batched settings by value - ch_batched_inserts' description and clickhouse.md: off sends the inserts that would be batched as committed inserts; fire-and-forget inserts are unchanged. - clickhouse.md states the pool cost as a formula instead of one run's figures. - insert_embedding tells a batched insert by its async_insert value, and the settings helpers hand out a copy of the committed settings. - memory.set's budget comment names all three batched inserts it awaits. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Switching batching off sends each insert as before, pin each table's wait window With ch_batched_inserts off, the sites that were waited async inserts before batching (auth attempts, carry acks, the write-mark and usage flushes, the policy witness, projection failures, graph Undo markers and waited graph inserts) pass async_when_off and stay async on the profile's timeouts; the rest are committed. The batched-tables test pins each table's wait window and checks both switch states. COMMITTED_INSERT_SETTINGS is exported, and the unreachable no-loop branch of the usage flusher start is gone. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Describe the batching switch by what it does off, pass the shared insert settings as they are Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Test each switch-off insert form, hand out copies of the shared insert settings With ch_batched_inserts off, the policy witness, the Undo markers and the waited graph insert are tested as waited async inserts and a plain conversation append as committed. batched_insert_settings and embedding_insert_settings return a new dict on every path. Rewrap the restricted_audit_inline description, its handler's docstring and the batched-inserts section. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Pin each usage-event flush's wait window, hand out committed settings from a function, size the pool per window The flush a full buffer forces inside record_usage_event is tested to take the short window, and the flush loop's tick and the shutdown drain the background one. committed_insert_settings() returns a new dict per call, as batched_insert_settings() does, so no caller shares a mutable module dict. The pool-sizing rule counts both wait windows, and the OVERLOADED fix names the background wait and the batching switch. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Send async_insert_max_query_number with a batched insert, describe the switch by what it does off, note why a batched table takes no row that can fail its flush Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Keep the ledger flushes on the batched bounds with the switch off, budget bulk_set's two waits, describe the switch by what it does The sites that were waited async inserts already (carry acks, auth attempts, policy witness rows, projection failures, graph Undo markers, waited entity triples, usage and write-mark flushes) now call async_insert_settings, which ignores ch_batched_inserts; the switch governs only the sites it commits. memory.bulk_set's budget covers its audit and outbox waits. The docs scope the committed resend to conversation_embeddings, and the usage docstring says the call that fills the buffer waits for its flush. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Mark the async-insert buffer bound on the line above it, pin the usage flushes for both switch values The `# not a setting:` marker of _ASYNC_INSERT_MAX_QUERY_NUMBER now sits directly above the assignment, where the tunable-constants ratchet looks. The usage-flush tests run with ch_batched_inserts on and off, since those flushes ignore it, and the live-ClickHouse test names its settings dicts by what they hold. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Name the live path for the insert waits under OVERLOADED, describe the wait bounds by both their uses, mark the buffer bound in one line Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Test a mis-sized vector in a shared flush on the coded table, budget save_message's waits, state the pool formula as a lower bound Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Ship batched inserts off by default, call the store from the write-rate bench, pin the write marks through a recording client ch_batched_inserts now defaults to false: a waited async insert holds its pooled connection for the window and the flush, and one process at 200 two-insert writes a second refused writes at ch_pool_maxsize = 64 where committed inserts refused none. The docs name the pool-sizing step before turning it on and list every insert the switch covers. The write-rate client arm calls conversations.append and insert_embedding, and --committed switches ch_batched_inserts off. The live-ClickHouse tests run with batching on and a 1 s window so their inserts share a flush. The write-mark test drives bump, flush_now and mark_process_start with a recording client under both switch values. The broad except in insert_embedding states why. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Ship batched inserts on by default, state the pool cost under the operator steps ch_batched_inserts defaults to true again; LOOM_CH_BATCHED_INSERTS=false sends the inserts main committed as committed inserts. clickhouse.md and troubleshooting state that a waited batched insert holds its pooled connection for the wait, that the measured 200 writes/s single-process run once ended with 212 OVERLOADED at ch_pool_maxsize = 64, and that a process at that rate raises ch_pool_maxsize or turns the switch off. The op budget comments say their waits apply with ch_batched_inserts on. The wait-bound rows in failure-and-recovery.md cover the waited async inserts too. The write-rate docs name the batched default arm and the committed arm. The width test compares each read-back row with the row it was built from. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Size the pool for batched inserts before upgrading, budget memory.evidence's audit wait, read every embedding column back The upgrade steps, the ch_pool_maxsize and ch_batched_inserts comments and the tuning and failure tables now say a batched insert holds a pooled connection for its wait, so the pool grows with the write rate. memory.evidence gets the 50 ms allowance for its high-sensitivity audit row, as memory.get does. The shared-flush test reads every written column with a count per row instead of DISTINCT, so a row that lands twice fails it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Define the pool-sizing terms for batched inserts and the check after rollout The upgrade step defines R_request and R_background, says the measured need was more than 3 times the bound, and names the pool gauges to watch. The architecture page's example is a reachable request-path rate, the tuning guide lists the minimum wait, and the width-error catch keeps the re-raise comment form. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Shorten the batched-insert and restricted-audit setting comments, name compaction's summary turn among batched inserts Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Send a follow plan's successor inserts on the batched bounds, scope the switch's description The follow plan's three successor inserts now use async_insert_settings(), so ch_batched_insert_wait_max_ms bounds them; a test pins it with the switch on and off. The ch_batched_inserts description names the request-path sites it covers and that ledger flushes stay waited async inserts either way. The op budgets state the batched-insert wait once and name each op's waits in one line, and the usage-event docstring says when a failed flush drops its batch. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Cite the pool exhaustion the committed write-rate harness reproduces At 200 writes a second in one process, bench/write_rate.py with batching on refuses 3,367 of 12,000 writes with OVERLOADED at a pool of 20, the formula's bound, and none at 40 or 64. The upgrade, troubleshooting and batched-insert pages cite that run. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Keep the write marks' erasure bump and process-start mark committed, state the pool step as a floor Both write one row per erasure or per boot, so batching them saved no parts and only added a wait. The upgrade step now names the default pool of 64 and when to raise it, and the batched-insert and pool setting comments fit two lines. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Committed inserts use committed_insert_settings, the usage flush takes its lock through _buffer_lock The three inserts that stay committed (entity_vectors, memory_chunks, entity_canonical_map) call the helper instead of repeating its dict. The ch_pool_maxsize comment names the base sizing again, and the troubleshooting pool sentence is split in two. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * The ch_batched_inserts description names the inserts it batches and the ledger flushes it leaves waited Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * The ch_batched_inserts description names the inserts the switch leaves waited, the pool step uses one x3 rule Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * The pool step sizes from its own rule, the batched tables are listed once, a non-width batched failure is not resent Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * memory.move's budget covers its redirect's outbox-row wait, the pool sizing step reads cleanly Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Pool sizing counts a memory.set at six waited inserts, and the batching switch's comment names what it batches The upgrade step, the batched-inserts section and the PR's operator steps count the audit, outbox, two entity-edge and two entity-triple inserts (plus carry_acks) per memory.set, and say the graph inserts stay waited with ch_batched_inserts off. The memory.set budget comment names the edge-projection wait. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Op budgets state when a batched-insert wait raises one, and the pool step names its margin once Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Batched-insert waits are capped well under the write deadline, and the pool sizing rule lives on one page The three wait settings take an upper bound (1000, 5000 and 1000 ms), the ch_batched_inserts description names the tables it batches and the pool sizing it needs, and upgrades.md and troubleshooting.md link the sizing rule in clickhouse.md instead of restating it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Batched-insert setting comments take two lines and point to the architecture page The table list and the wait bounds the fields already declare live on docs/architecture/clickhouse.md#batched-inserts, not in the comments the reference prints. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * The batched-insert switch names the inserts it covers, and memory.move keeps its 400 ms budget ch_batched_inserts names the audit, transcript, agent_events, outbox and evidence inserts it switches, and says the waited async inserts keep their windows. The clickhouse page lists a follow plan's successor inserts and the carry-ack withdraw among those. memory.move stays at 400 ms, as the budget rule says, and memory.restore's comment names the Undo's audit wait that every namespace pays. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * The pool-sizing paragraph reads in order, and the batching switch's comment points to its list Move the lower-bound sentence next to the formula it qualifies and say a process above the default's rate acts. Cut the ch_batched_inserts comment to two lines and regenerate the settings reference, schema and example. Keep the literal committed settings at the sites batching does not touch. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Committed inserts in the write-marks and webhook stores use committed_insert_settings() The session-settings comment states the rule and points to the batched-inserts list. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Put the pool-sizing rule in the settings comments, name fire-and-forget inserts in the session-settings comment, give memory.set's budget its current reason Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Point the pool comment at the full sizing rule, keep the upgrade procedure release-neutral, name committed_insert_settings among the entry points Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Keep webhook delivery attempts committed, pin that each resent embedding row went batched first Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Drop batched_insert_settings' unused background flag, order the wait bounds min first, name the wait setting rather than its default in budget comments Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Name the inserts that take the background window, order the wait rows min first, give each raised budget a one-line reason Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Name the wait settings by field, not position; make each usage flush say its window; match table constants within their own module Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Give each batched table one window in its test, use committed_insert_settings for the thread i…
zlareb1
added a commit
that referenced
this pull request
Oct 22, 2026
…after folding each person (#117) * Coded vector DDL follows the codec settings this user can have on Loom took enable_quantized_codec for available whenever system.settings listed it. ClickHouse Cloud lists it but holds it read-only: its default is 0, and the operator enables it per service with a settings-profile override. Where it is held at 0, the coded CREATE sent SETTINGS enable_quantized_codec = 1 and the server refused it (code 452), so a fresh install failed instead of creating the plain layout. With the codec enabled, allow_suspicious_codecs stays read-only at 0 there, and the entity_vectors CREATE failed on its LZ4 chain (code 36 without the setting, 452 with it). Every path that creates a coded table reads value, readonly, min, max and disallowed_values of the codec settings before it sends any (vector_codec_ddl.CodecSettings). A setting is held when this user may not set it to 1: readonly, or a <max>0</max> or <disallowed>1</disallowed> constraint, which system.settings shows with readonly = 0. state enable_quantized_codec allow_suspicious_codecs settable coded, sent LZ4 chain kept, sent held at 1 coded, not sent LZ4 chain kept, not sent held at 0 plain layout Quantized alone, not sent absent plain layout Quantized alone, not sent - the migration runner's fresh-install layout, and codes_state's codec_available; - the provider rebuild's candidate table: refused before its CREATE where the codec cannot be on (an owned stale candidate is dropped first), its chain dropped where it must be; 26.7 keeps the allow_experimental_codecs gate under the same rule; - scripts/ops/vector_codec_rebuild.py: refuses to run where the codec cannot be on, and refuses --chain where allow_suspicious_codecs cannot be; a held setting goes with no statement, the copy, the deltas and a rollback included; - dev/restore_loom.py: refuses a backup with coded tables before anything is written, --dry-run included, where the codec settings cannot be read or the codec cannot be on (checked again under the restore lock), and drops the chain on an explicit CREATE. Without the chain, entity_vectors.entity_embedding takes about four times the space LZ4 gave it: the operator enables allow_suspicious_codecs and rebuilds that table with --chain LZ4, or accepts the larger column. The server accepts a held setting sent at its current value, and clickhouse-connect drops a readonly one before sending; a held setting is left out so neither is relied on. Servers where both settings are settable, and servers before 26.8, take the same layout and settings as before. The one difference on 26.7: scripts/ops/vector_codec_rebuild.py refuses with the reason instead of failing on UNKNOWN_SETTING. Unit tests cover every state pair and each constraint shape at the migration runner and the provider rebuild, and each tool's refusal and degrade branch. Signed-off-by: pufit <[email protected]> * grants.list pages with a namespace-bound cursor and cuts a page only after folding each person grants.list answered at most `limit` rows (100 by default, 500 at most) with no cursor and no sign that it had stopped, and it applied the limit before a person's login handle and email rows were folded into one. A caller reconciling grants against a desired set could neither see a large namespace whole nor tell that it had not: it rewrote grants it never saw and missed revocations. The op takes `cursor` and answers `next_cursor` (null on the last page) and `truncated`; `limit` keeps its default of 100 and its maximum of 500, and counts people. The fold moves into the statement: rows are grouped per person (a subject the directory ties to a login folds onto it, any other onto its lower case) before the keyset and the limit apply, so no page splits a person and `truncated` is exact. The keyset is the person's newest row, (granted_at, subject) descending, so a grant added or revoked mid-walk neither repeats nor skips anyone else. One statement replaces the per-subject alias reads; fold_by_alias, now unused, is removed. Only active rows rank a person's role. An older pending admin request beside an active viewer grant read as an active admin, and the other order read as pending for someone with access. A person with an active row now reads active at their highest active role, their outstanding request in pending_role; one with none reads as their newest row. Behaviour changes: a failed read of the account directory now fails the call (503 or 504) where the per-subject alias reads caught the failure and could list one person as two rows; and the SDK's agent.grants.list walks every page, up to max_pages, raising rather than returning a list it cannot show is whole (past max_pages, or from a server that does not page grants.list). The cursor carries the position under a MAC over the op, the org and the namespace, keyed from LOOM_JWT_SECRET: another namespace's cursor, an edited one, or one issued before a rotation is a 422. clickhouse-local tests run their session in UTC, as the server does. The default call keeps its shape and its contract: next_cursor and truncated are additive. Signed-off-by: pufit <[email protected]> * The unit and integration jobs fit their suites, and the docker smoke and a replay test wait for what they check (#140) * The docker smoke passes until every fixture has its first index The code smoke seeded its eight fixture repositories with at most five back-to-back ingest passes and went on to the compiler tiers whether or not every git_head had landed. A pass hands a missing mirror's clone to a background job and moves on, and an entry's first index (its git_head) is written by the bootstrap leg of a later pass. When the clones took longer than five quick passes, as on the amd64 Quickstart run of main at 49b3d356 (the five passes and the Python tier ended 0.3 s after the first clone's sandbox probe), scip_py_delta found no git_head and the smoke failed with "code-docker-smoke-python: git_head not seeded". The same tree passed on the pull request's own run and on arm64. The seed now passes until every entry's git_head equals its head, a second apart, and fails naming the entries still without one after 180 s. Two unit tests drive seed() with collaborators whose heads land on the eighth pass, and with none landing. Signed-off-by: pufit <[email protected]> * The replay test waits for its failure's resolved mark test_a_replay_that_inserted_never_inserts_again_after_a_failed_repair asserted that the org has no active projection failure right after the second retry returned resolved. The retry marks the failure with mark_projection_failures_resolved, an ALTER UPDATE without mutations_sync, so the mark lands in the background; _mutations_done waits only for the triple and edge mutations. On a loaded runner the read came first and listed the failure still active, with the payload of the replay that resolved it (main at 49b3d356 and at 18fe4dd3). The test now waits up to 30 s for the active list to empty, as the 4,000-failure mark test in test_retirement_ch.py does; a mark that never lands still fails it. Signed-off-by: pufit <[email protected]> * The unit and integration jobs have room for the suites they run Over the last 40 pushes to main the unit job's pytest step took 16.9 to 29.7 minutes, and the job hit its 30-minute limit in 10 of them: on 49b3d356 it was cancelled at 99% with every test so far passing (the same seed passes locally, 23,345 tests). The integration job's first pytest step has taken 42 to 59 minutes since the conflict-resolver tests arrived, before the auth-on server's tests (about 6 minutes) start; it was cancelled at its 60-minute limit on 7fba7f5d and 87879ba6, and the green pull request run of 49b3d356's tree took 56 minutes. Neither job hangs: both are cut off while still passing tests. The unit job now has 45 minutes and the integration job 90. Signed-off-by: pufit <[email protected]> --------- Signed-off-by: pufit <[email protected]> * Bump the actions group with 2 updates (#141) Bumps the actions group with 2 updates: [astral-sh/setup-uv](https://github.com/astral-sh/setup-uv) and [actions/setup-node](https://github.com/actions/setup-node). Updates `astral-sh/setup-uv` from 10.2.0 to 10.3.0 - [Release notes](https://github.com/astral-sh/setup-uv/releases) - [Commits](https://github.com/astral-sh/setup-uv/compare/v10.2.0...1c37ad07a6a961277cf70c0d37d6f313000f5884) Updates `actions/setup-node` from 7.0.0 to 7.1.0 - [Release notes](https://github.com/actions/setup-node/releases) - [Commits](https://github.com/actions/setup-node/compare/v7...949feb2413d6458794dcd2491c4babbbce0c15c1) --- updated-dependencies: - dependency-name: astral-sh/setup-uv dependency-version: 10.3.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: actions - dependency-name: actions/setup-node dependency-version: 7.1.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: actions ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Model calls name whom they are for, and a gateway refusing one identity holds only that identity (#111) * Model calls name whom they are for in configurable identity headers LOOM_INFERENCE_IDENTITY_HEADERS_JSON maps header names to templates over {org}, {namespace}, {subject}, {user_id}, {agent}, {tenant} and {email}. Every chat, embedding, rerank and classify request carries them. A request names its token's subject; a background job names the writer of the row it works on, else the agent whose own namespace the row is in, and splits a batch by identity. A gateway that bills each agent then sees the agent behind background work as well as requests, instead of the deployment for both. With no templates nothing changes. Signed-off-by: pufit <[email protected]> * The workload token can be sent to the gateway as the bearer itself LOOM_INFERENCE_WORKLOAD_TOKEN_MODE=bearer sends the content of LOOM_INFERENCE_WORKLOAD_TOKEN_FILE as Authorization: Bearer on every model call, for a gateway that verifies the workload's token itself and has no token exchange. The file is read again at most once a minute and at once after the gateway answers 401, so a rotated token is picked up without a restart. The mode requires the gateway, as the exchange does, so the token goes nowhere else. A keyless compatible embedder now sends the workload token in either mode instead of falling back to the fake embedder. The default mode, exchange, behaves as before. Signed-off-by: pufit <[email protected]> * A gateway refusing one identity holds that identity's calls, not the provider With identity headers set, a 403 or a 429 whose error names a budget, from a gateway host, is the gateway refusing the identity the call was made for. The model client's response hook raises ModelCallRefused (403, MODEL_CALL_REFUSED, with the gateway's status and code) instead of an HTTP error, so the request answers it, nothing retries it or hands it to the fallback model, /v1/health does not read it as a provider failure, and the org's switch is untouched. It is one of customer.HOLDS: a background job leaves the row as it is, and for LOOM_INFERENCE_REFUSAL_COOLDOWN_SECONDS (600) its calls for that identity are refused before anything is sent, while other identities' work goes on. One over-budget agent no longer reads as the provider being down for the whole deployment. Any other 429 is a rate limit, retried as before. The bearer tests now point each sender at a fresh model client: a sender first imported while another test patched get_model_client kept that patch. Signed-off-by: pufit <[email protected]> * A job's model call is for the row's writer, the namespace's agent only without one Jobs that never passed the writer fell back to the namespace's owner even when the row recorded its actor, so the owner agent, or nobody for a shared namespace, paid for a member's or another agent's work. The embedding worker, projection repair and the code-link judge now read the writer of the memory they work on; observe-extract takes the newest writer of the session's observations, a profile fold the newest writer of its facts, reflection and the period digest the newest writer of the session's memories, and the conflict sweep passes the write's writer to settle(). The owner is used only for a row that records no principal. A pipeline's own actor (process:extraction-worker, process:cli:<command>, the other provenance.PIPELINE_ACTORS) names no principal: subject_of() returns '' for it, so such a row falls back to its namespace instead of going out with no agent. A test pins every process:<name> literal in the server to the registry. The writer reads run only while an identity header names more than the org and namespace. Signed-off-by: pufit <[email protected]> * Identity headers name the agent whole, and a call naming no org is refused The headers whose templates name {agent} or {tenant} are now sent together or not at all. An agent whose trust requires no exact tenant, or a trust's own token, used to send the agent header alone; the gateway refuses half an identity with a 400, which read as a provider failure for the whole cell. Now neither goes and the gateway applies its default identity. With identity headers set, a call that names no org is refused and logged (MODEL_CALL_UNATTRIBUTED) unless it is the deployment's own, as it already was with the customer header: an MCP call whose identity stamping failed, or a loom command run without --org, no longer goes out under the gateway's default identity. A job batching rows now groups them by the identity they render, so one agent's rows in several namespaces share a call. Templates are trimmed, and an empty template or a hop-by-hop header name is refused at load. Signed-off-by: pufit <[email protected]> * Only the answers a deployment lists hold one identity, matched exactly LOOM_INFERENCE_IDENTITY_REFUSALS_JSON lists the gateway answers that are one identity's, not the provider's: {"refused": [...], "wait": [...]}, each entry a status and at least one of the error body's code, type or message, matched exactly. The default lists the metering's 429 budget_exceeded. A refused answer raises ModelCallRefused as before; a wait answer (too many of an agent's requests in progress, no credential for it yet) raises the new ModelCallDeferred, 503 MODEL_CALL_DEFERRED with the gateway's Retry-After. Any other answer is the provider's: another 403 is a provider failure again, still not retried, and no word in a message counts. A job's hold moves from customer.require() to the model client's request hook (gateway.sending) and is keyed by the identity and the path and model the answer was for, so one model's refusal no longer holds an agent's embeddings. A wait holds for its Retry-After (at most 5 minutes), a refusal for the cooldown, and a success at that path and model ends the hold. The identity headers go only to the gateway's hosts: the request hook drops them from any other request, a redirect hop included, and setting them now requires LOOM_INFERENCE_GATEWAY_HOSTS. The reranker and the classifier post through the model client (never redirected, as before), so the gateway check, the identity headers and the refusal handling apply to them, and a refusal raises instead of keeping the input order or the caller's type. Signed-off-by: pufit <[email protected]> * A job skips an identity the gateway holds instead of stalling on it A job that meets a held identity remembers the work it left until the hold ends (server/workers/holds.py, ModelCallRefused.hold_s) and leaves it out of its next selections, so its batch goes to other identities' work. The profile fold leaves the held identity out of its scan. The embedding worker names the held stubs for find_embedding_stubs to leave out (exclude_keys) and, while any identity is held, reads four times its batch and drops the held identities' stubs before calling, so stubs a held writer filled the oldest slots with no longer stop other writers' stubs from being embedded. What names an identity going unread (IdentityUnread) now holds one group like a switched-off org or a refused identity (customer.GROUP_HOLDS) in the four batch embedders: the memory and code embedding workers, loom reembed and a model rebuild write the vectors the other groups' calls bought instead of stopping the pass or failing the rebuild step as a provider error. Signed-off-by: pufit <[email protected]> * The extraction queue holds, backs off and spends no attempt on an outage A replay whose model call is held (the org switched off since the claim, the switch unread, the enqueuer's identity refused, asked to wait or unread) is marked `held` with the reason in last_error until the hold ends, instead of staying `running` behind its lease; no attempt is spent. While it is held the claim takes none of that enqueuer's other requests in the namespace and for that user, so the batch goes to other work rather than rows that would only be held again. A failed attempt now waits 15 s, 1, 5, then 30 minutes before the next claim, and LOOM_EXTRACTION_QUEUE_MAX_ATTEMPTS defaults to 8 instead of 3 (recorded in the settings history). A model provider or gateway that cannot be reached (a transport error, a timeout, 502/503/504) spends no attempt and waits the same backoff. A request still waiting on its last day before the table's 30-day TTL is dropped with a memory_drops record (held_past_ttl or waited_past_ttl) and marked failed, never removed unseen. memory.extraction_status takes and reports the `held` state, and its pending count, memory.search's pending_extraction and the pending evidence include held batches. Signed-off-by: pufit <[email protected]> * code.refresh calls models as its caller; in-database reembed is refused when calls must be named The ingest pass code.refresh runs (the poller's) now makes its model calls for the request's caller, its token's subject, as any request's calls are; the poller's calls stay the namespace's agent's. loom reembed --in-database is refused, before any row is read, while a customer header or identity headers are set or the inference gateway is required: ClickHouse's aiEmbed calls the provider itself, naming no customer or identity and outside the gateway's host check. The CLI prints the reason and exits 2; the Python path is unchanged. Signed-off-by: pufit <[email protected]> * Identity headers are decoded once per value, not on every read Every model call reads LOOM_INFERENCE_IDENTITY_HEADERS_JSON several times (rendering, grouping, the request hook, the gateway's answer); it is now decoded once per value, as the refusals table is. Signed-off-by: pufit <[email protected]> * Only a provider that does not answer spares a queued extraction an attempt A request the client cannot make at all (a bad scheme, a local protocol error) is the request's failure and spends an attempt; no connection, a timeout, an answer cut off, no gateway token, or a 502/503/504 spends none. Signed-off-by: pufit <[email protected]> * The CLI surface snapshot pins the in-database refusal in reembed's help Signed-off-by: pufit <[email protected]> * The embedding worker holds writer groups, not stub keys, and binds lists that fit Holding a writer's stubs by their keys put up to 2000 eight-string tuples in one parameter, and the 4x read put 1600 candidate keys in the next two: both past ClickHouse's 128 KiB form-field limit (http_max_field_value_size), so once enough stubs were held every pass failed with "Field value too long". The worker now keeps the held identities (each stub's writer's) and the (org, namespace, agent, user_id) groups their stubs are in. The selection reads the held groups' stubs after every other stub (a handful of tuples, cut to one field), and the held identities' rows among what it reads are left uncalled, so other writers' stubs, a held writer's neighbours under its label included when the batch has room, are embedded meanwhile. The read is the batch again, not four times it. Every list a stub read or writer lookup binds goes in chunks that each fit one field (server/core/ch_params.py), measured as the driver renders them. session_writers read loom.memory without FINAL and by created_at, so it could name the writer of a deleted memory or of a replaced version (an update keeps created_at). It reads FINAL now and picks by version, as the profile fold does. Signed-off-by: pufit <[email protected]> * The extraction queue's enqueuer gets its own column, so the claim reads no payloads The claim left out every enqueuer with a request held now by reading JSONExtractString(payload) in both its outer NOT IN and the subquery, so each 15-second pass read every payload in the table twice (3000 finished rows of 20 KB: 120 MB a pass, against 165 KB before), growing for the queue's 30 days. Migration 063 adds memory_extraction_queue.enqueued_by (String DEFAULT ''), the principal the payload already names. enqueue writes it, every mirrored version carries it, a hold fills it for a row queued before the column, and the claim's held-enqueuer check reads it with the other narrow columns, so the payload is read for the claimed rows alone. A row queued before the column reads '' and is claimed and held at once if its enqueuer is held. The queue's column list is pinned to the table's in the schema test. Signed-off-by: pufit <[email protected]> * The profile fold reads four times its slots and gives a held identity's to the next The fold runs every six hours and a hold lasts ten minutes, so an identity held in one pass was selected again by the next, and ten held identities at the top of the ranking took every slot, pass after pass. The scan now reads four times max_identities_per_pass, and a fold held in the pass takes no slot: the next identity read is folded in its place, and the held one stays out of the selection while its hold lasts. A switch gone unread ends the pass. Signed-off-by: pufit <[email protected]> * Rendered identity header values are trimmed, and left out when only space remains A template such as "{email} via loom" rendered " via loom" for an agent, which has no address, and the HTTP layer refuses a header value with a leading space. Each value is now trimmed after rendering; one with nothing left is not sent. Signed-off-by: pufit <[email protected]> * A short wait on a request's model call is waited out once before it is deferred A "wait" answer made a request fail at once with 503 MODEL_CALL_DEFERRED, where Loom used to retry a busy provider in process; the gateway's per-agent request limit asks for one second. A request's call (never a job's) asked to wait two seconds or less now waits it out once and lets its sender's own retry ask again; a second such answer for the same call, or a longer wait, defers it. A job's call is still held at once. Signed-off-by: pufit <[email protected]> * The built-in refusals table matches the gateway's answers by code The inference proxy now writes a stable error.code in every body, so the default LOOM_INFERENCE_IDENTITY_REFUSALS_JSON matches its per-agent answers by code: agent_denied (403), identity_incomplete and identity_malformed (400) refused, agent_request_limit (429) a wait. The metering's budget refusal is matched twice: by code (budget_exceeded) on OpenAI routes, and by type and whole message (rate_limit_error, "budget exceeded") in the Anthropic envelope of /v1/messages, which carries no code. token_unavailable and identity_missing stay out of the table and the docs say never to list them: the first is also what a credential-service outage answers, the second a gateway with no default agent, and either would vanish from health. The deployment-level answers (caller_*, scope_not_granted, route_not_found, upstream_*, misconfigured, no_identity) stay provider failures. The docs' examples match by code, no longer by message text. Signed-off-by: pufit <[email protected]> * A loom command names its namespace, and one naming none is refused while the headers name the agent The CLI named only --org around a command's model calls, so an in-process import's calls rendered no agent and went out as the gateway's default agent (not refused, since an org was named). The dispatcher now names the command's --namespace too, so its calls are for the agent whose namespace it is, and while the identity headers name the agent, a command's call with --org and no namespace or subject is refused (MODEL_CALL_UNATTRIBUTED, logged) rather than billed to the default agent. Commands that walk namespaces name each row's own. Signed-off-by: pufit <[email protected]> * A deferred conflict judge scheduled inside a job is for the job's writer schedule_settle took the request's caller, which a worker has none of, so a write an extraction replay made for its enqueuer sent its deferred judge out for the namespace's agent. It now takes whom the surrounding calls are for (a request's caller, or the writer a job named for its row), else the write's own principal from its provenance; a pipeline's own write still names no one. Signed-off-by: pufit <[email protected]> * The SDK references say where a deferred model call's wait is; a stale test citation is fixed MODEL_CALL_DEFERRED reaches both SDKs as BackendUnavailable, which carries no retry_after_s: the references say the wait is in detail.retry_after_s and the Retry-After header (the Python transport's retries of an idempotent op honour it), and the error's docstring says so too. The provenance registry's comment named a test file that does not exist. Signed-off-by: pufit <[email protected]> * The analyzer corpus drives the new statements, and its shape list is current Regenerates tests/analyzer/shapes.txt for the claim, pending_count and the schema dump, and adds cases so CI checks the new statements against an engine: the queue's TTL drop, the session-writer read, the profile fold's scan with and without a held identity, and the stub selection through its FINAL read with and without a held group ordered last. Signed-off-by: pufit <[email protected]> * The architecture page describes the holds as they now work The embedding worker orders a held writer's groups last instead of reading four times its batch, the profile fold over-fetches instead, and the queue's held-enqueuer check reads its own column. Signed-off-by: pufit <[email protected]> * The carry-columns test reads the stub selection's FINAL read where it now is find_embedding_stubs reads its stubs in _stub_rows (one read per bound chunk of keys); the test that pins the columns the RMT carry needs reads that function and checks find_embedding_stubs calls it. Signed-off-by: pufit <[email protected]> * Deployment calls inside a loom command are exempt, the refusal log no longer leaks across tests, and list parameters are measured in bytes The CLI's no-namespace refusal had no exemption for the deployment's own calls, so `loom recalibrate`, or a model change's calibration run inside a command, was refused while identity headers were on. A call inside customer.system() is exempt from it, as from the no-org refusal. The test suite now clears the once-a-minute limiter of the MODEL_CALL_UNATTRIBUTED log line after every test (tests/unit/conftest.py), which made the CLI refusal test depend on the order tests ran in (seed 1357); the test asserts the refusal itself. server/core/ch_params.py measured a parameter's rendered length in characters, but ClickHouse limits the field in bytes: 300-character CJK keys made a 65,359-character chunk of 148,759 bytes. It measures UTF-8 bytes now, tested with multi-byte keys. Signed-off-by: pufit <[email protected]> * The structured profile build calls for its user's namespace, user and writer The structured profile worker from #93 named only the org, so its model calls went out as the gateway's default agent. build_profile now names the namespace, the user and the newest principal that wrote the facts it reads (user_facts returns each fact's actor and version), as the profile fold does; a pipeline's or a worker's own write names no principal, and the call is then for the agent whose namespace it is. A build held for its identity (customer.GROUP_HOLDS: the org switched off, the identity refused, asked to wait or unread) leaves that user out of the namespace's passes until the hold ends (hold_seconds, as the fold's), through the worker's own per-user wait: no failure is counted, and a failure backoff's next wait stays as it was. Other holds still only skip the user. Tests pin the identity the build sends (the newest writer; the namespace's agent when no principal wrote the facts) and that a held user waits out its hold while the pass and the next one take the namespace's other users. Signed-off-by: pufit <[email protected]> * Keep model attribution and held work correct across retries Signed-off-by: Lareb Zafar <[email protected]> * Attribute filtered model inputs and count held extraction work Signed-off-by: Lareb Zafar <[email protected]> * Model unmerged rows and worker inputs accurately in tests Signed-off-by: Lareb Zafar <[email protected]> * Keep unchanged analyzer descriptions as generated on main Signed-off-by: Lareb Zafar <[email protected]> * Record held enqueuer claim SQL in the analyzer corpus Signed-off-by: Lareb Zafar <[email protected]> * Collections menu focus rings fit inside their cells Signed-off-by: Lareb Zafar <[email protected]> * Projection repair walks past held failures A keyset cursor lets each bounded pass reach later failures while held identities remain active. Timestamp ties follow ClickHouse's native UUID order. Signed-off-by: Lareb Zafar <[email protected]> * Exercise current knowledge hits and resolver attribution in unit tests Signed-off-by: Lareb Zafar <[email protected]> * jsdom supplies scrolling for delayed transcript navigation Signed-off-by: Lareb Zafar <[email protected]> * Accessibility audits wait for the page entry fade Signed-off-by: Lareb Zafar <[email protected]> * Assert default user and session in sensitivity canary responses Signed-off-by: Lareb Zafar <[email protected]> * Record namespace guide statements in the analyzer corpus Signed-off-by: Lareb Zafar <[email protected]> * Focused rows stay visible during page entry The entry translation suppresses scroll anchoring while offscreen rows replace their size estimates. Focus removes the translation while the opacity fade continues, so keyboard navigation keeps the row clear of the sticky toolbar. Signed-off-by: Lareb Zafar <[email protected]> * Back keeps its saved scroll offset after focus Restoration checks the offset one frame after scrolling or focusing. Deferred rows can resize after focus and change the offset, so restoration continues until the requested position remains in place. The existing timeout bounds missing content. Signed-off-by: Lareb Zafar <[email protected]> * Drain buffered events before erasure counts their rows A delayed telemetry batch can arrive after the event deletion step finds no rows and fail the residue census. Serialize flushes and drain this replica before counting, with a bounded wait that leaves erasure retryable. Coalesce threshold flushes so slow inserts do not accumulate waiting tasks. Signed-off-by: Lareb Zafar <[email protected]> * Row estimates use content height Skeletons and estimates share a row height. Containment subtracts the existing padding and borders because its size applies to content. The browser regression measures a fresh skipped box instead of comparing different box models. Signed-off-by: Lareb Zafar <[email protected]> * Namespace keyboard checks wait for search focus Popover visibility precedes the lazy panel focus handoff. Arrow-key traversal starts after the search owns focus, preserving the scroll and fade assertions. Signed-off-by: Lareb Zafar <[email protected]> * Configure the event drain deadline used by erasure Expose the five-second event drain deadline as LOOM_ERASURE_EVENT_DRAIN_TIMEOUT_S. Reject non-positive and non-finite values so erasure always bounds its wait before counting event rows. Signed-off-by: Lareb Zafar <[email protected]> * Scope model-call selector fixtures to their own namespace Global bounded selectors can fill their batches from unrelated orgs before reaching the fixture. Keep both fixture orgs in one fresh namespace and use the existing namespace filters while retaining the limits and switch assertions. Signed-off-by: Lareb Zafar <[email protected]> * Extraction tests expect ignored learning arguments to be removed Signed-off-by: Lareb Zafar <[email protected]> --------- Signed-off-by: pufit <[email protected]> Signed-off-by: Lareb Zafar <[email protected]> Co-authored-by: Lareb Zafar <[email protected]> * Inserts into the tables written on every request share ClickHouse parts by default and still return once written (#129) * Inserts into the tables written on every request batch server-side in ClickHouse audit_log, conversations, conversation_embeddings, agent_events, the webhook outbox and attempts, entity_canonical_map, memory_evidence, memory_belief_sources and memory_chunks are written with async_insert = 1, wait_for_async_insert = 1: concurrent inserts share a part, and each returns once that part is written. Two live settings bound the wait. bench/write_rate.py measures latency and parts per table at a fixed write rate. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Address review: pin the new defaults, state the parts bound per node and shape, test batched read-back and dedup, harness takes a token Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Address review: parts bound reads both ways, carry acks use the bounded wait, bench counts unstored turns as errors Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Address review: the remaining async-wait inserts use the bounded helper, the shared-parts test stops merges, the docs name each batched writer Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Address review: name the policy witness's exposures rows, fix the chunk insert comment Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Address review: keep code spans whole in the doc, say what a failed shared flush means, read back every field Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Address review: label the interval writers in the batched list, shorten the flush comment Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Address review: sign-in attempts, projection-failure records and graph Undo markers use the bounded helper Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Address review: the attempts comment sits on its insert, the doc lists every batched site, the failure-row test says what it checks Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Address review: entity_canonical_map stays committed, a flush makes one part per partition, the usage drain test expects the batched settings entity_canonical_map is partitioned by org, so a shared flush writes one part per org and can exceed max_partitions_per_insert_block across tenants; it goes back to a committed insert. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Tests check that the tables written on every request use batched inserts A parametrised AST check asserts that the audit_log, agent_events, conversation_embeddings, webhook outbox and attempts, memory_evidence and memory_belief_sources inserts pass `batched_insert_settings()`, and that no insert into them omits `settings=`. The audit test stubs require `settings`, and the emit_many test asserts both audit inserts are batched. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Batched-insert tests pin every insert site, and entity_vectors and write marks batch The read-path test records an insert without settings as the session defaults and any unresolved settings value as a failing entry. The batched test covers memory_chunks, entity_vectors, namespace_write_marks and carry_acks. entity_vectors and every namespace_write_marks insert are sent batched. write_rate.py reports the async_insert value each conversation insert carried, from system.query_log. The architecture page calls inserts that wait "waited", and "committed" means async_insert = 0 only. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * conversation.append and set_from_messages budgets cover their batched waits conversation.append makes two batched inserts in sequence and memory.set_from_messages about six, so their p99 budgets rise to 130 and 2800 ms. The memory.set budget, the restricted-access docstring, the batched-insert comments and the failure-and-recovery page describe batched inserts as waited, not committed, and the batched-insert rule as waited inserts that need no fence or identity token. The runtime-override test fakes go back to their optional settings argument. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Batched inserts are described by the rows that use them, and write_rate.py cleans up its client rows The setting, client and helper text name the inserts sent with batched_insert_settings() instead of defining them by what they lack, the async-insert dedup rule names both kinds, the restricted-access audit docs say the row is a batched insert, the failure page lists the two wait settings in the client table, and write_rate.py runs under a per-run org and deletes its in-process conversation rows at the end. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Async inserts are described as deduplicated by token, and every batched insert site is pinned normalize_insert_settings and the clickhouse.md bullet say dedup_settings turns async deduplication back on with the per-batch token. The conversation append, the graph Undo markers, auth_attempts, memory_projection_failures and memory_usage_events are pinned to batched_insert_settings(); the usage-event fallback insert is batched like its flush. The restricted_audit_inline comment names the awaited insert's whole latency. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Async inserts are deduplicated by token without a separate normalising step, and write_rate.py sends its baseline directly normalize_insert_settings set async_insert_deduplicate = 0 only for dedup_settings to set it back to 1, so it is removed. The batched-insert wait settings describe the writes they affect in two lines each. The write-rate bench passes committed or batched settings to its inserts instead of reassigning a store attribute, and deletes its client rows in a finally block. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Rows with a Quantized-coded vector stay committed, and the session dedup comment says what each insert sends A mis-sized vector fails the shared part of a batched flush and with it every other insert in that flush, so conversation_embeddings, entity_vectors and memory_chunks keep committed inserts. The conversation.append and set_from_messages budgets drop to match. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * The policy witness writes its rows, and write_rate.py reads an unset async_insert as the server default The witness sends batched_insert_settings(), so its helper, docstrings, log lines and test say the row is written, not committed. write_rate.py's inserts_sent read an insert sent at the server's default async_insert (1 on recent releases, which the query log leaves out) as 0; it now reads the default from system.settings. Two long lines are re-wrapped. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * A waited entity-graph insert uses the batched-insert settings, and batched inserts have their own section graph_insert_settings(wait=True) returns batched_insert_settings(), so the live ch_batched_insert_wait_* bounds govern memory.set's waited entity_triples inserts too. The batched-insert convention moves into a "Batched inserts" subsection of the ClickHouse page, with the tables that stay committed listed one group per line, and the failure-and-recovery Inserts row links to it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * write_rate.py deletes only its own run's rows, and batched inserts send the adaptive busy timeout The client-target cleanup scopes its delete to the run's thread ids, so an org named with --org keeps its own transcripts. batched_insert_settings sends async_insert_use_adaptive_busy_timeout = 1, so the min and max wait bounds hold whatever the server profile sets. The duplicate design-principles bullet is gone. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Pin the tables that stay committed, and give entity_canonical_map's reason A block-level error in a shared flush fails every insert waiting on it, so the Quantized-coded vector tables and the org-partitioned canonical map stay committed; a test now pins each of their insert sites. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Batch the conversation embedding row when its width cannot fail the flush A conversation_embeddings row is batched when the column is plain, or coded at the served model's embedding_dim with a vector of that width; it stays committed without a reading or while a model change or rebuild is pending, and a batched row whose flush another width failed is sent again committed. The usage-event recorder loses its unreachable direct-insert branch, and the p99 budgets of the ops that await a batched insert (memory.delete, memory.delete_version, memory.pin, memory.get, memory.get_by_id, conversation.append) cover its wait. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Describe memory.pin's batched inserts, share the committed insert settings, split the usage-buffer lock from the flusher start memory.pin's budget comment names the same inserts as memory.set. The committed insert settings in the conversations store are one module constant the identity-token append and the bench reuse. The usage store's buffer lock comes from _buffer_lock(), so _ensure_usage_flusher_started only starts the flush task and the analyzer can stub it with a no-op. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Give memory.update, update_by_id and restore the outbox wait allowance, and name the batched wait as an OVERLOADED cause memory.update, memory.update_by_id and memory.restore await the same batched outbox insert as memory.delete, so their p99 budgets gain the same 50 ms allowance. The troubleshooting entry for OVERLOADED names batched inserts holding their connection and the settings that bound it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Check every committed-table insert under server/, give memory.pin memory.set's budget, reuse the committed insert settings Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Batch inserts by default behind a live switch, give background inserts a longer wait ch_batched_inserts (live, on) sends every batched insert committed when off. Inserts no request waits on (the usage-event flusher, the write-mark flush and process-start mark, webhook delivery attempts) wait up to ch_batched_insert_background_wait_max_ms (200). memory.bulk_get and memory.history get the batched audit row's allowance, COMMITTED_INSERT_SETTINGS moves to ch_writes, and the docs state ClickHouse's own target and when to turn batching off. Signed-off-by: zlareb1 <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * Describe what the batching switch leaves async, size the pool by mechanism, test batched settings by value - ch_batched_inserts' description and clickhouse.md: off sends the inserts that would be batched as committed inserts; fire-and-forget inserts are unchanged. - clickhouse.md states the pool cost as a formula instead of one run's figures. - insert_embedding tells a batched insert by its async_insert value, and the settings helpers hand out a copy of the committed settings. - memory.set's budget comment names all three batched inserts it awaits. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Switching batching off sends each insert as before, pin each table's wait window With ch_batched_inserts off, the sites that were waited async inserts before batching (auth attempts, carry acks, the write-mark and usage flushes, the policy witness, projection failures, graph Undo markers and waited graph inserts) pass async_when_off and stay async on the profile's timeouts; the rest are committed. The batched-tables test pins each table's wait window and checks both switch states. COMMITTED_INSERT_SETTINGS is exported, and the unreachable no-loop branch of the usage flusher start is gone. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Describe the batching switch by what it does off, pass the shared insert settings as they are Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Test each switch-off insert form, hand out copies of the shared insert settings With ch_batched_inserts off, the policy witness, the Undo markers and the waited graph insert are tested as waited async inserts and a plain conversation append as committed. batched_insert_settings and embedding_insert_settings return a new dict on every path. Rewrap the restricted_audit_inline description, its handler's docstring and the batched-inserts section. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Pin each usage-event flush's wait window, hand out committed settings from a function, size the pool per window The flush a full buffer forces inside record_usage_event is tested to take the short window, and the flush loop's tick and the shutdown drain the background one. committed_insert_settings() returns a new dict per call, as batched_insert_settings() does, so no caller shares a mutable module dict. The pool-sizing rule counts both wait windows, and the OVERLOADED fix names the background wait and the batching switch. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Send async_insert_max_query_number with a batched insert, describe the switch by what it does off, note why a batched table takes no row that can fail its flush Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Keep the ledger flushes on the batched bounds with the switch off, budget bulk_set's two waits, describe the switch by what it does The sites that were waited async inserts already (carry acks, auth attempts, policy witness rows, projection failures, graph Undo markers, waited entity triples, usage and write-mark flushes) now call async_insert_settings, which ignores ch_batched_inserts; the switch governs only the sites it commits. memory.bulk_set's budget covers its audit and outbox waits. The docs scope the committed resend to conversation_embeddings, and the usage docstring says the call that fills the buffer waits for its flush. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Mark the async-insert buffer bound on the line above it, pin the usage flushes for both switch values The `# not a setting:` marker of _ASYNC_INSERT_MAX_QUERY_NUMBER now sits directly above the assignment, where the tunable-constants ratchet looks. The usage-flush tests run with ch_batched_inserts on and off, since those flushes ignore it, and the live-ClickHouse test names its settings dicts by what they hold. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Name the live path for the insert waits under OVERLOADED, describe the wait bounds by both their uses, mark the buffer bound in one line Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Test a mis-sized vector in a shared flush on the coded table, budget save_message's waits, state the pool formula as a lower bound Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Ship batched inserts off by default, call the store from the write-rate bench, pin the write marks through a recording client ch_batched_inserts now defaults to false: a waited async insert holds its pooled connection for the window and the flush, and one process at 200 two-insert writes a second refused writes at ch_pool_maxsize = 64 where committed inserts refused none. The docs name the pool-sizing step before turning it on and list every insert the switch covers. The write-rate client arm calls conversations.append and insert_embedding, and --committed switches ch_batched_inserts off. The live-ClickHouse tests run with batching on and a 1 s window so their inserts share a flush. The write-mark test drives bump, flush_now and mark_process_start with a recording client under both switch values. The broad except in insert_embedding states why. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Ship batched inserts on by default, state the pool cost under the operator steps ch_batched_inserts defaults to true again; LOOM_CH_BATCHED_INSERTS=false sends the inserts main committed as committed inserts. clickhouse.md and troubleshooting state that a waited batched insert holds its pooled connection for the wait, that the measured 200 writes/s single-process run once ended with 212 OVERLOADED at ch_pool_maxsize = 64, and that a process at that rate raises ch_pool_maxsize or turns the switch off. The op budget comments say their waits apply with ch_batched_inserts on. The wait-bound rows in failure-and-recovery.md cover the waited async inserts too. The write-rate docs name the batched default arm and the committed arm. The width test compares each read-back row with the row it was built from. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Size the pool for batched inserts before upgrading, budget memory.evidence's audit wait, read every embedding column back The upgrade steps, the ch_pool_maxsize and ch_batched_inserts comments and the tuning and failure tables now say a batched insert holds a pooled connection for its wait, so the pool grows with the write rate. memory.evidence gets the 50 ms allowance for its high-sensitivity audit row, as memory.get does. The shared-flush test reads every written column with a count per row instead of DISTINCT, so a row that lands twice fails it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Define the pool-sizing terms for batched inserts and the check after rollout The upgrade step defines R_request and R_background, says the measured need was more than 3 times the bound, and names the pool gauges to watch. The architecture page's example is a reachable request-path rate, the tuning guide lists the minimum wait, and the width-error catch keeps the re-raise comment form. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Shorten the batched-insert and restricted-audit setting comments, name compaction's summary turn among batched inserts Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Send a follow plan's successor inserts on the batched bounds, scope the switch's description The follow plan's three successor inserts now use async_insert_settings(), so ch_batched_insert_wait_max_ms bounds them; a test pins it with the switch on and off. The ch_batched_inserts description names the request-path sites it covers and that ledger flushes stay waited async inserts either way. The op budgets state the batched-insert wait once and name each op's waits in one line, and the usage-event docstring says when a failed flush drops its batch. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Cite the pool exhaustion the committed write-rate harness reproduces At 200 writes a second in one process, bench/write_rate.py with batching on refuses 3,367 of 12,000 writes with OVERLOADED at a pool of 20, the formula's bound, and none at 40 or 64. The upgrade, troubleshooting and batched-insert pages cite that run. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Keep the write marks' erasure bump and process-start mark committed, state the pool step as a floor Both write one row per erasure or per boot, so batching them saved no parts and only added a wait. The upgrade step now names the default pool of 64 and when to raise it, and the batched-insert and pool setting comments fit two lines. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Committed inserts use committed_insert_settings, the usage flush takes its lock through _buffer_lock The three inserts that stay committed (entity_vectors, memory_chunks, entity_canonical_map) call the helper instead of repeating its dict. The ch_pool_maxsize comment names the base sizing again, and the troubleshooting pool sentence is split in two. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * The ch_batched_inserts description names the inserts it batches and the ledger flushes it leaves waited Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * The ch_batched_inserts description names the inserts the switch leaves waited, the pool step uses one x3 rule Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * The pool step sizes from its own rule, the batched tables are listed once, a non-width batched failure is not resent Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * memory.move's budget covers its redirect's outbox-row wait, the pool sizing step reads cleanly Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Pool sizing counts a memory.set at six waited inserts, and the batching switch's comment names what it batches The upgrade step, the batched-inserts section and the PR's operator steps count the audit, outbox, two entity-edge and two entity-triple inserts (plus carry_acks) per memory.set, and say the graph inserts stay waited with ch_batched_inserts off. The memory.set budget comment names the edge-projection wait. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Op budgets state when a batched-insert wait raises one, and the pool step names its margin once Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Batched-insert waits are capped well under the write deadline, and the pool sizing rule lives on one page The three wait settings take an upper bound (1000, 5000 and 1000 ms), the ch_batched_inserts description names the tables it batches and the pool sizing it needs, and upgrades.md and troubleshooting.md link the sizing rule in clickhouse.md instead of restating it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Batched-insert setting comments take two lines and point to the architecture page The table list and the wait bounds the fields already declare live on docs/architecture/clickhouse.md#batched-inserts, not in the comments the reference prints. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * The batched-insert switch names the inserts it covers, and memory.move keeps its 400 ms budget ch_batched_inserts names the audit, transcript, agent_events, outbox and evidence inserts it switches, and says the waited async inserts keep their windows. The clickhouse page lists a follow plan's successor inserts and the carry-ack withdraw among those. memory.move stays at 400 ms, as the budget rule says, and memory.restore's comment names the Undo's audit wait that every namespace pays. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * The pool-sizing paragraph reads in order, and the batching switch's comment points to its list Move the lower-bound sentence next to the formula it qualifies and say a process above the default's rate acts. Cut the ch_batched_inserts comment to two lines and regenerate the settings reference, schema and example. Keep the literal committed settings at the sites batching does not touch. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Committed inserts in the write-marks and webhook stores use committed_insert_settings() The session-settings comment states the rule and points to the batched-inserts list. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Put the pool-sizing rule in the settings comments, name fire-and-forget inserts in the session-settings comment, give memory.set's budget its current reason Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Point the pool comment at the full sizing rule, keep the upgrade procedure release-neutral, name committed_insert_settings among the entry points Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Keep webhook delivery attempts committed, pin that each resent embedding row went batched first Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Drop batched_insert_settings' unused background flag, order the wait bounds min first, name the wait setting rather than its default in budget comments Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Name the inserts that take the background window, order the wait rows min first, give each raised budget a one-line reason Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Name the wait settings by field, not position; make each usage flush say its window; match table constants within their own module Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Give each batched table one window in its test, use committed_insert_settings for the thread insert Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Read the listed op budgets from the catalog in the operations-listing test Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * State when a committed insert uses committed_insert_settings, use naive_utc_now in the write-rate bench Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Price conditional insert waits as budget shapes, keep main's base budgets memory.get, get_by_id, bulk_get, history and evidence wait on an insert only when they audit a high-sensitivity read; memory.delete, delete_version, update and update_by_id only when the namespace has a webhook. Their base budgets are main's again, and the handlers note an "audited" or "webhook" shape that OP_SHAPE_BUDGETS_P99_MS prices with the wait. webhooks.announce says whether it wrote outbox rows. The waited-inserts bullet in the ClickHouse page no longer repeats the retries bullet. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Price bulk_set, restore and save_message waits as shapes, count a failed outbox insert memory.bulk_set and memory.restore keep main's base budgets: a bulk write that sends outbox rows notes "webhook", an Undo notes "undo" before its awaited audit record and an undelete with a webhook notes "webhook". conversation.save_message keeps one embedding-row wait in its base and notes "rewrite" when deduplication dropped the turn and it is written again. webhooks.announce answers True once it sent outbox rows, even if the insert then failed. memory.delete_version's base comment is main's again, and the shape block says its budgets are the base plus the default wait, not a measured p99. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Raise the profile write budgets to memory.set's, pin every shape's off case profile.set, profile.append and profile.replace write through memory.set's handler, so they carry its 200 ms budget, as memory.pin does. The tests now pin that a bulk write or a finished delete_version that sends no outbox rows, the retry of an Undo whose restore landed late, and a get_by_id that omits the high value note no budget shape. The budgets header says the restricted-access audit wait sits in the transport's admission gate, outside the measured handler time. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Price profile.append, profile.replace and procedure.add by the handlers they run profile.append and profile.replace read the section through memory.get before memory.set's write path, so each is 225 ms; procedure.add runs memory.set's handler, so it is 200 ms. ch_batched_inserts' description and the OVERLOADED fix say the switch covers only the switched group: the waited async inserts still wait with it off. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Shorten the batched-inserts comment, name the background-window test by what it pins, compare against committed_insert_settings, replace only the flusher's sleep Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Name every waited entity-graph insert among the inserts the switch leaves waiting Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * State the budget-shape rule as the table applies it Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Read each embedding row's first send directly in the shared-flush width test Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Say when the agent_events flush shares parts and why a missing column spares the batch Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * List insert batching among the live settings, say what announce's result means Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * Reflow announce's docstring Co-Autho…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changelog category (leave one):
Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):
An admin can give a namespace a profile schema (
profile_schema.set), and Loom keeps each user's profile current in that shape from the user's memories.profile.structuredreturns it withstatusandbuilt_at(when the build read the user's memories; a lock or unlock of the profile key keeps it), without a model call.ready: current, or all null for a user with no facts;stale: memories or schema changed since the build;pending: no live profile yet (unbuilt, expired, redacted orhigh);no_schema: none set, or it no longer parses.Why
A chat bot needs to know its user before the first reply, in a shape its code can read: a name, a time zone, the languages they speak. Today the only option is free-form profile sections, or the
profile_consolidationfold, which writes free text and is off by default. Typed records already validate JSON against a schema, but they hold entities, not one always-current object per user.Design:
titleaccepted and ignored at every level), stored as the admin wrote it, key order kept: 1 to 64properties, at most 16 KiB, each with atype(string,number,integer,boolean, orarrayof one of those) and a requireddescriptionthe model reads. String and number constraints (enum,pattern,minLength/maxLength,minimum/maximum) map onto the typed-record constraints and are checked byrecord_constraintsandrecord_values, the codememory_schema.registerandmemory.record.writeuse. The worker's prompt names each property's constraints, so the model answers in the form they expect. Every property is in every profile,nullwhen the memories do not settle it, so there is norequired, andadditionalPropertiesmay only befalse. The schema hash covers the parsed properties only, so atitleor a reordering stales no profile.loom.profile_schemas(migration 061), one ReplacingMergeTree row per (org, namespace), a tombstone for clear. It holds no memory content (classifiedNO_MEMORY_CONTENT). The profile itself is an ordinaryprofilememory row (agent-, keystructured_profile), so history,profile.render,context.pack, read scope and erasure are memory's own. Its provenance isderived;source_traceisprofile.fold:structured_profile:<memory ids>.sipHash64over each one's id, content hash, confidence and the date a build reads and orders by,valid_atelseupdated_at) and their count, andvalid_at, when its sources were read. The read recomputes the digest in one aggregate query. A schema change makes every profilestaleat once. The read serves the stored profile in the current schema's shape.structured_profile(on by default, 120 s): it reads only namespaces with a schema, so a deployment without one makes no model call. Per pass it builds at mostLOOM_STRUCTURED_PROFILE_MAX_USERS_PER_PASSprofiles. Namespaces are reached in(org, namespace)order from the pass cursor, wrapping around, one page of at mostbudgetnamespaces per statement, and each in a page getsceil(budget left / namespaces in the page). A namespace with nothing to build spends no budget, so the pass reads the next page from the last namespace reached until the budget is spent, the rotation comes back round or the pass is stopped; a namespace whose drained scan list is complete costs no query. With 30 namespaces and only the 25th behind, one pass builds it; what a namespace leaves goes to the ones that used their whole share, from the list their scan already made. One scan of a namespace lists up to ten times its share; later passes take from that list (leaving out users backing off or still refused) until it drains, the schema hash changes, or it isLOOM_STRUCTURED_PROFILE_SCAN_MAX_AGE_SECONDS(600 s) old, whichever comes first; at the defaults a namespace that stays behind is rescanned every 5 passes. A scan that found every user behind (fewer than it asked for) is not repeated before its ten minutes are up once drained, so in the steady state a namespace costs at most one scan per ten minutes. A namespace whose scan fails or whose stored schema no longer parses backs off like a failing user (5 minutes, doubling to 6 hours) until its wait is over or its schema hash changes; a waiting namespace is left out in SQL, so it takes no place in the pass's namespace limit, and it does not keep the pass from idling. Both scan caps are read from the settings at the scan and passed to it, and the timeout must be above 0. A build skips a user whose profile is already current, so a list a few minutes old costs no extra model call. Every 4xx from the write (PINNED_CONFLICT409,LOCKED423,BLACKLISTED422) is a refusal;memory.setraises no 429 (rate limits are the transport's), and anything else is a failure that backs off. A namespace whose scan fails is counted inerrorsand noted on the pass; the cursor has already moved past it, so it is tried again when the rotation comes back to it, neither stalling every pass nor skipped for good. A failed build (a model error, an answer that is not a JSON object) backs the user off for 5 minutes, doubling to 6 hours, cleared on success; the scans made while the user waits leave them out, so the retry comes at the first scan after the wait ends, at most the wait plusLOOM_STRUCTURED_PROFILE_SCAN_MAX_AGE_SECONDSafter the failure. A build the profile row refuses (a lock, a pin or ahighlabel on the key's head, checked before the model call; a 4xx from the write such as the blacklist), and a build whose answer stops at the output cap (stop reasonlengthormax_tokens: the same facts under the same schema stop there again), sorts last and is not retried until the user's sources digest, the version of the profile key's head (an unpin, an unlock, an edit, of a redacted head too) or the schema hash changes, or six hours pass, so a lock whoselock_untillapses with no write is retried. Both waits live in the worker's process, are pruned once over, and start over when the lease moves. The pass checks for a stop before each user, and takes no user once half ofLOOM_STRUCTURED_PROFILE_MAX_PASS_SECONDS(600 s, the worker's pass deadline) is gone: the build in flight has the second half to finish, so a slow pass ends on its own instead of being cancelled at the deadline and counted as a failure, and the users it took but did not reach go back to the front of the scan list for the next pass. A pass that takes no user waitsLOOM_STRUCTURED_PROFILE_IDLE_INTERVAL_SECONDS(600) only when it reached the end of the rotation (a pass whose users were all current, moved or refused runs again at the busy interval, since its scan lists may hold more); one that saw only part of it runs again at the 120 s interval.loom.memory FINALwith the sources predicate computes every user's digest and source count, joined to the live profile rows (written by the worker's actor, not expired, not redacted, nothigh;join_use_nulls = 0, so a user with no profile reads[]and is kept, neverNULL). A user is behind with no profile under the schema's tag, or with aprofile_sources:<digest>tag other than the current digest, after the cooldown (600 s); a user with fewer sources than the profile'sprofile_count:<n>tag (a deletion) skips the cooldown. A recall, a backfill or a write that is no source (an episodic row, a profile section) changes no digest, and an edit, a revert, a restore, a deletion, an expiry, a passedvalid_to, a row turninghighor retyped does. A restatement, amemory.lockand amemory.unlockwrite a newupdated_atwith the content unchanged, which dates the fact at that write and moves it to the newest place the build reads, so each changes the digest too and costs one rebuild after the cooldown. Of two current facts that disagree under different keys, the one locked or unlocked last then reads as the most recent, and the rebuilt profile follows it; a source is dated and ranked by the row's last write, not by its last content change. Its cost follows the namespace's live rows, not their version history. The digest covers every source while a build reads only theLOOM_STRUCTURED_PROFILE_MEMORY_LIMIT(100) most confident and newest, so for a user with more facts than that a change to one outside that set costs a model call that cannot change the answer. A build for a user with no facts and no profile row writes nothing, so a user erased after a scan listed them gets no new row when a later pass takes them from that scan. Just before writing, a build recomputes the user's sources digest and writes nothing when it differs from the one read at the start: a fact edited, redacted, erased, deleted or added during the model call stops the write, so a profile is never built from a version that stopped being current while the model read it; a row written in the short gap between that check and the write while the erasure saga runs is one its final census finds, and the saga fails closed on it.profile.fold:<label>:<memory ids>; the free-text fold'sconsolidated_profilenow does too, where it named only the label).memory.redactscrubs, besides the version it names and that key's derived rows, every version of the user's profiles whose trace names the redacted memory, the live one included, and each profile key's embedding, chunk and code-link rows that held that text. The named version and every profile version reached are scrubbed in one statement per version table, chosen by a predicate on the user's profile rows (agent-, where the builders write, so the sort key narrows the read to the user) and their trace rather than a bound list of versions, so a redact issues two mutations of the same size however many profile versions name the memory; the lock check reads only the distinct profile keys, and the cached answers and ask precedents whose window held a scrubbed profile key are deleted with those of the memory's own key. A window records bare keys and every user's profile has the same key, so this reach is org-wide: one redaction clears every cached answer and precedent in the org, in any namespace, whose window rendered any user's profile, and each profile key reached adds one deletion per table. The trace names the memory, not its version, so a profile built from another version of it is scrubbed too. A lock on a profile key reached refuses the redact before anything is scrubbed, as a lock on the memory's own key does. A version that does not exist scrubs nothing: the redact answersredacted=falsebefore it reads any profile, and no cached answer or precedent is deleted. A scrubbed live profile reads aspendingand is left out ofprofile.renderand profile search until the worker rebuilds it from current facts. The profile keys are looked up with their redacted versions included, so a redact retried after a failed derivative scrub or cache delete reaches the same profile keys as the first call. A version whose trace names no memory ids is not reached: every fold version written before this change, and every one build N-1 writes during a rolling upgrade. A user's erasure removes every version.customer.for_org, skips orgs whose model calls are switched off, goes through the configured client (and so the inference gateway host list), fences the facts as data, and is held to the schema before the write. A user whose facts are all gone gets an all-null profile without a model call, which readsready. Only a row the worker wrote (actor = worker:structured-profile, stamped by the server; a token maps only to ahuman:orprocess:actor, so no request can write as it, whatever its subject) is served: a row a caller writes to the key with the worker's tags reads as no profile and its user as behind. A user with no facts and no row readsreadywith every property null, the profile the worker would build.server/memory/store/profile_sources.pyand both builders share it: current facts only, never ahighrow, a duplicate, a fact about someone else, a protected attribute or a stored request to forget, plus the existing credential-shape check on the values. Each fact is dated byvalid_at, else by its last change (updated_at), and the builds rank by confidence then last change, so an edit is read as the newest statement. This changes the free-text fold in three ways: it leaves out aduplicaterow (its canonical row is the fact), it dates each fact byvalid_atelseupdated_at(wascreated_at), and it reads by confidence thenupdated_at(wascreated_at); its rendered input now sorts by the full timestamp, so two facts of one day keep their order.profile.structuredresolves the read scope likeprofile.render, passes it to every store read, and always reads oneuser_id. A token pinned to a user (an end user's token) reads only that user's profile, with or withoutuser_idin the body; another user is 403. A session-bounded token (own_session) is refused (IDENTITY_INCOMPLETEwithout asession_id,AUTH_INSUFFICIENTwith one): a profile spans the user's sessions. It is inSCOPED_OPS;profile_schema.getis inNARROW_SAFE_OPS(operator configuration, no memory); a narrowed token gets an emptyupdated_by, so it is not told which admin subject set the schema.Alternatives considered: a column on
loom.namespaces(every namespace write would have to carry it, and a write that omitted it would clear the schema); extendingprofile_consolidationin place (its namespace opt-in, itsuser_…key rule and its free-text output all differ; the two share the source query instead); a timestamp-based staleness check (comparing a profile's build time with its sources' newestupdated_at): it cannot see a revert to an earlier value, a restored fact, a source leaving the set (turninghigh, retyped, an expiry or avalid_tothat passes without a write), or a change merges have folded away, all of which the digest of the current sources catches.Scope and risk
source_trace(now names the memories it read),memory.redact(reaches the profiles built from the memory), andprofile.renderand profile search, which now filter onredacted_at IS NULL: a profile head scrubbed bymemory.redactreads as no section instead of its redaction marker, andcontext.packand the MCP primer inherit that throughprofile.render.stale, and the next pass rebuilds it.(org, namespace)and the read onuser_idfrom the resolved read scope. The cross-principal and restricted-namespace leakage suites pass with the new read ops.Compatibility, rollout and rollback
profile_schema.set,profile_schema.get,profile_schema.clearandprofile.structured(allexperimental).profile.structuredanswers the row'sversionandversion_text, the same version as a decimal string, exact for a JavaScript caller.profile_schema.getis not audited, likememory_schema.list; set and clear are. No existing field changes, but two existing ops answer differently:memory.redactanswersredacted=falsefor a version that does not exist, andprofile.renderleaves out a section scrubbed bymemory.redact.profile.activitynow countsprofile.structuredas a profile read.061_profile_schemas.sql(additive), the next free number aftermain's 060; if another PR merges 061 first, this one renumbers to the next free number on rebase. New settings inserver/settings/catalog.py:LOOM_STRUCTURED_PROFILE_ENABLED(true),_INTERVAL_SECONDS(120, above 0) and_IDLE_INTERVAL_SECONDS(600, above 0), which the worker supervisor reads at startup;_MAX_PASS_SECONDS(600, above 0), the pass deadline the supervisor reads at startup, so not live;_LABEL(structured_profile) and_MODEL(empty: the default model), read on every call but not live: a changed label orphans every builtstructured_profilerow, and the model stays non-live like every other*_modelsetting; and, live (read at each pass or call),_SCAN_TIMEOUT_SECONDS(60, above 0),_SCAN_MAX_MEMORY_BYTES(4 GiB, at least 1 MiB),_MAX_USERS_PER_PASS(20, at least 1),_MEMORY_LIMIT(100, at least 1),_COOLDOWN_SECONDS(600, at least 0),_BACKOFF_BASE_SECONDS(300, above 0),_BACKOFF_CAP_SECONDS(21600, above 0),_REFUSAL_RETRY_SECONDS(21600, above 0) and_SCAN_MAX_AGE_SECONDS(600, above 0). The model call's output cap is thestructured_profileentry ofLLM_MAX_TOKENS(32 tokens for the object, changed throughLOOM_LLM_MAX_TOKENS_OVERRIDES) plus the schema's estimate of a full answer (profile_schema.answer_tokens): each property's key with 4 tokens of punctuation, and each value (one per property,maxItemsper array) sized by itsmaxLengthor its longestenumvalue at 2 characters a token, 48 tokens for a string with neither, 12 for a number or a boolean.profile_schema.setrefuses a schema whose full answer holds more than 256 values or whose estimate passes 16,384 tokens; every schema with nomaxLengthis under that bound. A string longer than its estimate can still be cut off; that build is a refusal, not a failure that retries on backoff. The profile row has nochar_limit, since the schema already bounds its shape (64 properties, 50 items per array, 256 values); the four new ops' p99 budgets are inOP_BUDGETS_P99_MS. No existing setting's default changes. Nothing happens until an admin sets a schema.profile.renderas JSON, as it does any object-valued section, and also a scrubbed live profile, as its redaction marker, since itsprofile.renderdoes not filter onredacted_at. While N-1 servesmemory.redact, the redact scrubs no profile version, though N's worker may already have built one from the memory; and the fold versions N-1 writes name no memory ids, so a later redact on N does not reach them either. Neither is re-scrubbed afterwards: that text stays in the profile key's history until the user is erased.loom.profile_schemasand the builtstructured_profilerows; the rows are ordinary profile sections that their users' erasure removes.Tests
Unit:
tests/unit/test_profile_schema.pycovers schema validation (every refusal and cap), the hash's key-order independence, holding an answer to the schema (coercion, enum, bounds, array caps, undeclared keys), projection onto a changed schema, the prompt and the fake model's answer, and staleness on clickhouse-local against the realloom.memorytable: missing, current, touched (still current), edited (behind, waits out the cooldown), schema changed (behind at once), ahighrow and anabout:otherrow left out of the digest, and a user whose facts are gone.Unit, the pass (
tests/unit/test_structured_profile_worker.py): the equal share of the budget, the leftover going to a namespace still behind, resuming after the cursor and wrapping around, a pass reading past its first page when the namespaces in it have nothing to build (30 namespaces, only the 25th behind, built in one pass), a failing namespace counted while the pass goes on and the cursor moves past it, a switched-off org passed over, a failed build counted and backed off (doubling, capped, retried once the wait is over, cleared on success), a refused build remembered with its digest and profile row version and tried again once the refusal lapses, waits that are over pruned, a pass stopped between users building no more, a slow pass that stops taking users halfway to its deadline and leaves the rest listed for the next pass, a pinned,read_onlyorhighprofile refusing a write (ahighhead is held before the model call, so its label survives), a 4xx from the write raised as a refusal, a fact erased or moved to a new version during the model call stopping the write, and a build writing its label, tags and sources.Unit, the store on clickhouse-local (
tests/unit/test_profile_schema.py): a revert A→B→rebuild→A brings the user back; a restored fact does; a source row that turnshigh, is retyped, taggedabout:other, deleted, superseded, expires or passesvalid_todoes; 15 users writing episodic rows, profile sections and restatements after their build never crowd out one editor atlimit=5; a deletion skips the cooldown; a refused user sorts last and waits for a new digest; an unpinned or unlocked profile (a new row version) is rebuilt, a redacted one too; a profile row written under another actor with the worker's tags (a human, or a service account whose subject isstructured-profile-worker) is no profile and its user is behind; an expired, redacted orhighprofile is no profile, soprofile.structuredreads it aspending, and the key's head still reports ahighlabel; the schema hash ignores titles and order; two same-day facts keep their time order; the schema listing wraps after the cursor and skips deactivated namespaces; non-finite and out-of-range numbers, items pastmaxItemscounted as dropped; a schema whose full answer holds more than 256 values, or whose token estimate passes 16,384, is refused; the largest schema's cap is its estimate plus the base; a free-text property's cap leaves room for a value of itsmaxLengthcharacters (and a default without one), and an answer stopped at the cap is a refusal, not a retried failure.The fold's source tests now run on clickhouse-local through
_consolidate_identity: a superseded, an expired, a past-valid_to, aforget-tagged, anabout:other, anattribute:-tagged and a non-user_row are left out, the user's own preferences are kept and dated byvalid_at, elseupdated_at; another pins that the fold leaves out a duplicate row. A clickhouse-local test (tests/unit/test_profile_redaction.py) builds four profile versions, three of them from one memory, redacts that memory, and checks that one statement per version table scrubbed all three, that noloom.memoryorloom.memory_versionsrow of the profile key still holds its text while the version built without it is kept, and that a cached answer and a precedent whose window held the profile key are deleted. Redacting a version that does not exist leaves the profile versions and the caches untouched. A redact whose profile derivative scrub fails is retried and then deletes the profile key's embedding rows and cached answers. Another redacts a memory named by 3,000 more profile versions, more than one bound parameter slice holds as a list, and checks that two statements with small parameters scrub them all. Another redacts the memory a live profile head was built from and checks thatprofile.renderand profile search's fetch no longer return that key. A locked profile key (read_onlyorno_delete) refuses the redact before any scrub, and a pin on a redacted profile head refuses the build before the model call. A stored schema that no longer parses reads asno_schema; every new numericLOOM_STRUCTURED_PROFILE_*setting below its floor is refused.Integration, against a local server with an in-process worker pass pinned to the fake LLM client scoped to the test's namespace, every schema cleared on teardown (
tests/integration/test_structured_profile.py): set schema,pending, a user with no factsreadyand all null, one pass,readywith the expected object, the row's type, provenance andsource_trace, ahighfact never reaching the profile; a new fact makes itstaleand the next passreadywith a higher version; a schema change makes itstalein the new shape; clear givesno_schema; a bad schema is 422; a writer cannot set one (403); a token pinned to a user reads its own profile and is refused another user's; a session-bounded token is refused, with and without asession_id; a user's erasure removes the profile row, after which the user readsreadyand all null.Scan cost by live rows, on a private ClickHouse (seed deleted after each run): users x 100 facts in two versions, every profile current; then every user had one fact recalled (a new version that keeps
updated_at), 10 users edited one, 10 reverted one to its first value, one fact turnedhighand another passed itsvalid_to. At both sizesusers_behindreturned exactly those 22 users and none whose fact was only recalled.system.query_log(read_rowscounts the versions merges had not folded yet):users_behindusers_behindprofile.structured's digest of one userThe scan reads linearly with a namespace's live rows and runs under
statement_timeout(LOOM_STRUCTURED_PROFILE_SCAN_TIMEOUT_SECONDS)(60 s) andmax_memory_usagefromLOOM_STRUCTURED_PROFILE_SCAN_MAX_MEMORY_BYTES(4 GiB). Its memory grows sublinearly: ten times the rows took under twice the memory, about 2 KiB per user for the per-user aggregate and the join, since the digest is a fixed-size XOR, not a list per user. A backfill of 100,000 users in one namespace at the defaults (20 profiles a pass, a pass every 120 s) takes 5,000 passes, about 7 days of intervals plus the build time itself (100,000 times the mean build); the list is rescanned every 5 passes (its 10-minute age comes before its 200 users drain), so about 1,000 scans of about 2 s and 2.8 GiB read each, about 2.8 TiB in all. WithLOOM_STRUCTURED_PROFILE_MAX_USERS_PER_PASS=200it takes 500 passes and about 100 scans (about 270 GiB), as long as 200 builds fit in the first half ofLOOM_STRUCTURED_PROFILE_MAX_PASS_SECONDS(300 s at the default, so builds averaging under 1.5 s); slower builds leave users for later passes, and the backfill takes about 100,000 times the mean build plus 120 s between passes. RaiseLOOM_STRUCTURED_PROFILE_MAX_PASS_SECONDSwith the user budget. Once the backfill is done a namespace is scanned at most once per ten minutes. To reproduce: insert factsk0..k99ofUSERSusers twice intoloom.memory(SELECT ... FROM numbers(USERS * 100), a fixedmemory_idper fact); write every profile row withINSERT ... SELECTfrom the sameSOURCES_DIGESTaggregate; insert version 3 ofk0for every user with the same value andupdated_at(a recall), a changedk1foru0..u9,k2at its first value foru10..u19,k3ofu20withsensitivity = 'high'andk4ofu21withvalid_to = now() - 60; callprofile_sources.users_behind(..., limit=50)andsources_digest(...)underset_query_tag(...);SYSTEM FLUSH LOGSand readread_rows,read_bytes,query_duration_ms,memory_usagefromsystem.query_logbylog_comment.tests/integration/test_cross_principal_leakage.py,test_restricted_namespace_leakage.py,test_profile.py: pass.At an earlier head, before main's settings catalog merged in: the contract, docs-reference, SDK-generated, worker-registry, read-scope, census and analyzer-corpus tests.
At this head:
make format lint, the mypy ratchet (scripts/gates/mypy_gate.py, run on this head: 0 errors, no file above its baseline) and the settings codegen checks (configuration reference, settings schema, example file) pass;tests/unit/snapshots/settings_defaults.jsonwas regenerated withLOOM_UPDATE_SNAPSHOT=1.tests/analyzer/shapes.txtwas regenerated withpython -m tests.analyzer.corpus --write, and the docs and SDK generators rerun. The unit, analyzer and integration suites run in CI, not locally. Not run:make test-mixed-version(needs docker images of both builds).AI assistance in the code (leave one; writing this description with AI is fine):
AI-generated (an agent wrote most of the diff): Claude Code. Checked: the read-scope behaviour under a pinned token, the staleness SQL on clickhouse-local and against a live server, and that no model call happens on a read.
I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
make format-check,make lint,make typecheckandmake test-unitpass; the integration suite passes if server behaviour changed.docs/reference/configuration.md,schemas/loom-settings.schema.json,loom.example.yamland thedocs/reference/tables (python scripts/codegen/docs_reference.py), the reach manifest,schemas/schema.sql(make schema-dump) and the Codex plugin copies (python3 scripts/codegen/agent_plugin_sync.py).main; no merged migration is edited.hooks/,lib/,bin/,skills/,.mcp.json, the Codexplugin-defaults.json) bumps both plugin manifests' version, and no other open PR uses that version.npm --prefix frontend run build) and its tests pass, iffrontend/changed.docs/describe the system as it now is, and this description names any operator steps and wire changes.tests/unit/test_public_copy.py).git commit -s), as CONTRIBUTING.md asks.🤖 Generated with Claude Code