Repository navigation
namespace.tune drafts changes to the settings that create a namespace's memories - #188
Merged
Merged
Conversation
zlareb1
force-pushed
the
feat/i160-tune
branch
from
November 3, 2026 13:19
d3cea75 to
aea6e16
Compare
…'s memories Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
zlareb1
force-pushed
the
feat/i160-tune
branch
from
November 3, 2026 14:11
aea6e16 to
350ba1c
Compare
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.
Related: #160
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):
namespace.tune(viewer, read-only) drafts changes to the settings that create a namespace's memories: extraction rules for the writer-side shapesnamespace.auditfound, categories for much-used tags, and a guide naming the key layout. Each draft names its real target, current and proposed value, the rows that support it and the rows it must keep working for, the agents it affects, that it changes future writes only, and the ordinary write (with its guard) that would apply it; nothing is applied and no model is called.Why
Issue 160's Tune stage drafts category, extraction-instruction and setting changes from the evidence, read-only, for a person to approve. The pieces exist — the audit's findings, the taxonomy, categories, guide and the operator extraction policy — but nothing turns them into a proposal that says which setting it would change, from what to what, on what evidence, for whom, and with which write. A reviewer had to assemble that by hand, and an agent asked to "tune the namespace" had no read-only way to show a change before making it.
What changes
server/identity/api/models_namespace_tune.py,ops_namespace.py:namespace.tune, viewer, idempotent, not audited (soread_only). Inputs:window_seconds(the audit's ledger window),sample_limit(supporting rows cited per proposal, default 5),min_rows(the rows a tag or key prefix needs to be drafted, default 5),max_category_proposals(default 5).server/identity/app/namespace_tune.pybuilds every draft from fixed rules, each section guarded (a failure lands inskippedand drafts nothing):double_encoded_values,json_prefix_excerpts,oversized_values,episodic_blobs,coordination_as_memory,hand_rolled_index_rows), drafted only whenmemory.set_from_messages' extraction writes into the namespace (rows whose source trace startspipeline:set_from_messages, read across every live row) and at least one of the finding's cited rows carries that trace. A finding none of whose cited rows extraction wrote drafts nothing and is listed inskipped(extraction: no cited row of <code> was written by extraction), as does a namespace extraction writes nothing into (extraction: memory.set_from_messages writes no row here …), so the absence is not read as clean; a finding the audit cited no live row of (its evidence read failed, or the rows went away before it) is judged on nothing, drafts nothing and is listed inskippedon its own (extraction: the audit cited no live row of <code>); a failed read of either drafts nothing and is skipped. A row two checks flag is cited once. Per-request instructions reach nothing else (aconversation:orlearning:trace, or a hand-writtenmemory.set, never passes through it). The affected agents are the agents whose rows extraction wrote; the cited rows are the finding's evidence rows extraction wrote; the flagged counts, stated as counts over every writer, cover all writers. There is no rule forhash_keys: extracted keys are sanitized to[a-z0-9_], so a key's layout is the writer's. The target is alwaysextraction_instructions.request, the instructions amemory.set_from_messagesrequest sends (no user, agent or session setting stores them);apply.argsis the part to merge into each request (args_complete: false). They are never drafted as the operator extraction policy: a policy in force overrides every other instruction and turns off extraction's recovery passes (preferences, costs, ages, corrections), so a style rule there would cost facts the namespace keeps today, and the draft'slimitssays so. For an org admin, tune reads the policy in force (the org's, then the namespace's, from the process's polled copy that extractions run under) and drops a rule whose exact text (case included) it contains; an unreadable grant is reported inskipped, not as a non-admin. That read goes through one helper,extraction_policy.for_caller, whichmemory.inspectnow uses too.counter_countis a lower bound: the smallest population those checks read, less every row they flagged (None when the audit could not read any of those populations).min_rowslive rows with no category of its name draftsnamespace.register_category; the counter count is the tagged rows already filed under another category, and the draft says registering files no row (memory.assign_categoryis a separate action).OFFERED_CATEGORIES(32) categories by name; when the namespace has that many, the draft says whether the new one would be offered and which registered name it would push out (quoted only when it is a plain name, else named by its position, since category names are stored unchecked), or that it would not be offered (registered names counted exactly, so two that differ only in case are two). That number is now one named constant inserver/memory/app/pipeline.py, bound into its statement, which tune reads.col-me-…) has no guide, so none is drafted there. A draft that would push the guide past the 32,000 charactersnamespace.guide_settakes is not made, andskippedsays why. With no guide, a guide listing the key prefixes (of keys that have a path) and tags on at leastmin_rowsrows; with one, the prefixes it does not name as a path of their own (billing/, not insidesubbilling/) appended. Applied withnamespace.guide_setandexpected_revisionset to the current revision, so a guide written since refuses the write.[A-Za-z0-9][A-Za-z0-9_.-]{0,63}), so text stored in rows or the guide cannot choose a target, an op or an argument; the unit tests feed it tags, prefixes and a guide that read as instructions. A<prefix>:tag (source:on every plugin capture,speaker:,agent:) says where a row came from, not what it is about, so it drafts no category and no guide line. A drafted guide lists tags on at leastmin_rowsrows.skippedasaudit.<check>, so a missing draft is not read as nothing to draft.affected_agentslists at most 20 writers, withaffected_agents_total.finding_evidence.revisions_for, by whole identity):memory_id,versionand thecontent_sha256memory.getserves.server/identity/store/namespace_tune.py: the writing agents (with their total) and the agents extraction writes for (with their total rows), the plain tags and the key prefixes (each only plain-named ones on at leastmin_rowsrows, filtered in SQL before a limit of 500, so a plain tag or prefix is found however many others rank above it), every spelling of a drafted tag, which cited rows extraction wrote, the rows with a tag and how many of those another category holds. Each filters on(org, namespace), takes the request's readscope, binds its values, and reads no value.server/identity/app/namespace_audit.py:namespace.tuneandmemory.inspectjoin the report ops whose own ledger rows do not close a telemetry gap. Tune runs the audit inside it, and an inspection is a read about the namespace, so a call of either from an SDK or the CLI would otherwise make a namespace whose writes left no ledger rows read as recorded, and the ledger checks report clean.telemetry_unavailablegoes torule_version2.namespace.tunejoins the assistant MCP toolset with a description that says to show a proposal, never apply it;OP_BUDGETS_P99_MSgives it 5,000 ms. It is not a scoped op, so a token narrowed below the namespace is refused.docs/features/namespaces-and-sharing.md: a row in the operations table and a section on what a proposal holds. SDKs, the operations reference and the SDK surface snapshot regenerated; the analyzer corpus gains the store's shapes.Scope and risk
system.query_log, 200,000 live rows in one namespace across 20 agents, 30 key prefixes and 50 tags, a third of them written by extraction, default inputs so five category drafts): one call runs about 47 statements, most of them the audit it reads, reading about 2.7M rows and 154 MiB in all, 44 MiB peak, 1.1–1.2 s wall time warm (2.3 s on the first, cold call).namespace.audit's samples, it cites at mostsample_limitrows per proposal by key and identifiers, never a value or an excerpt.memory.inspectshows one subject's rows); cost, latency and validation results for a proposal; Apply (the issue's approval contract); a model-run preview of extraction outputs over a sample, so no before/after examples (with no model call,model_usedis always false); and cited counterexample rows: a draft gives the rows it must keep working for as a count (counter_count, None when it could not be read or for a guide), since no store read can pick rows a check did not flag without repeating the check.Compatibility, rollout and rollback
namespace.tune, maturityexperimental);telemetry_unavailablegoes torule_version2 (two more report ops left out of its gap check). Nothing removed.UNKNOWN_OP, and its assistant listing does not carry the op.Tests
tests/unit/test_namespace_tune.py), the collaborators faked but for one case that runs the store's plain-name and row-count filter on clickhouse-local (skipped without the binary): a storedbilling\n,source:xora; btag or key prefix, or one on too few rows, never leaves the read. With the collaborators faked: the op is a viewerread_onlyop; a writer and an org admin both get per-request instructions, never the operator policy, and the draft says why; only a fired finding with a cited row extraction wrote drafts a rule, citing only those rows (once each), a finding without one is named inskipped, a failed cited read drafts nothing, and ahash_keysfinding drafts none; a clickhouse-local case shows onlypipeline:set_from_messagestraces count, notconversation:orlearning:; and a rule the policy in force holds is not drafted again; supporting rows and counts,args_complete: falseand the agent total; two findings share one draft with a true lower bound and one cited row each, and an unread population gives no bound; a rule the policy holds drops out of the evidence too;source:andspeaker:tags draft nothing; a check the audit skipped is reported asaudit.<check>; a plain much-used tag drafts a category, a registered one (any case) does not, and two tags that differ only in case draft one whose limits name the other spelling, however few rows carry it; a draft in a namespace with 32 categories says whether it would be offered and which name it would push out, a registered name that reads as an instruction is never quoted, and a draft that would not be offered never claims it would be; no guide drafts one at revision 0, a guide drafts only the prefixes it leaves out (a longer name ending in a prefix does not name it) and nothing when it names them all; tags, prefixes and a guide that read as instructions never change a target, an op or an argument; a failed section is skipped and an unread count is left out of the text, not stated as 0; a guide the addition would push past its limit is not drafted; an unreadable grant withholds the policy and says so.tests/unit/test_extraction_policy_for_caller.pycovers the shared helper's four outcomes.tests/unit/test_namespace_audit.py): a namespace.tune and a memory.inspect ledger row leave a telemetry gap open; the rule-version pin moves to 2.tests/integration/test_namespace_tune.py, private ClickHouse and server with auth on, the drafts read with aviewertoken): a namespace of hand-written double-encodedbillingrows drafts no extraction rule while extraction writes nothing there, and none after onememory.set_from_messagescall either, withskippednaming the finding none of whose cited rows extraction wrote; abillingcategory of 10 rows and a guide at revision 0; a cited row'smemory_id,versionandcontent_sha256equalmemory.get's; nothing is written; a token pinned withread_scope: own_userand a token for another namespace are refused with 403. The cross-principal walk lists the op among its core surfaces and passes, as does the assistant toolset suite; the audit-summary, findings-contract and labeled-cases suites pass on an auth-off server.tests/analyzer): anamespace_tunecase drives every store read under the whole namespace and a narrowed scope; the analyzer passes its shapes against a migrated ClickHouse.make format-check lint typecheck, the unit tests above and the generator checks.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 each statement against the tables it reads and the drafts against a live server.
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.main; no merged migration is edited. (No migration.)npm --prefix frontend run build) and its tests pass, iffrontend/changed. (No frontend change.)docs/describe the system as it now is, and this description names any operator steps and wire changes.git commit -s), as CONTRIBUTING.md asks.🤖 Generated with Claude Code