Repository navigation
A definition declares the team or product it applies to, and declared differences read as alternatives - #2378
Merged
Merged
Conversation
… differences read as alternatives Two teams can each define one name differently on purpose. Without a declared scope every such pair reads as a dispute to correct. A definition's value may hold applies_to, an object of team, product or both, each a string of at most 64 characters. A claim of memory.definitions.disputes serves it as applies_to, and a dispute carries state: alternatives when every two claims whose texts differ both declare team, or both product, with values that differ once folded as names are; suspected otherwise. A scope on one side only, team against product, and an applies_to with any other key or value shape separate nothing. Each pair check is charged 16 characters to the request's work bound, and a dispute whose pairs the bound does not pay for stays suspected. Declaring a scope is an edit of the definition through memory.set under the claim's hash, so a governed definition lapses as changed until its edited text is promoted, and a name keeps one shared definition. The Review queue's Definitions tab shows what each differing definition applies to, draws the names that need review before the alternatives, and lets a writer declare the team and product in a dialog that says before Save when the definition stops being governed. The memory drawer's Save refuses text that is no JSON over a stored object: saved as typed, it would replace the object with a string. Signed-off-by: Mohammad Lareb Zafar <lareb.zafar@clickhouse.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The generated SDK wire models merge without a conflict; every generator's check passes on the merged tree. Signed-off-by: Mohammad Lareb Zafar <lareb.zafar@clickhouse.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The generated SDK wire models merge without a conflict; every generator's check passes on the merged tree. Signed-off-by: Mohammad Lareb Zafar <lareb.zafar@clickhouse.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
memory.set builds the whole new version from its input, so a write that sends the value, type, tags and character limit resets the rest: a definition lost its validity window, confidence, entities, source and sensitivity label when a writer named its team. The dialog's write sends the row's fields back as a pin does, from one builder both share (rowFields). A copy rule's mark on the source trace is left out: memory.set refuses it from a caller, and the edited value is no longer the text the rule's run wrote. setMemory loses the hash option only the dialog used. The Applies to dialog is drawn outside the states of the list read. It was drawn inside the answered state, so a read that failed after a refusal removed it with its reason and the names typed, and Retry opened a new one on the stale claim. The concepts page says a blank scope value declares nothing for its key only, as the code does, and tells a caller of memory.set to send the definition's other fields back. A unit case pins the blank value beside a declared key, and the wire model's comment says the served value is trimmed. Signed-off-by: Mohammad Lareb Zafar <lareb.zafar@clickhouse.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
docs/features/dashboard.md conflicted on the Review queue row: it keeps main's sentence on a correction request in a stewardship review and this branch's on the names that need review first and the team or product a definition applies to. Signed-off-by: Mohammad Lareb Zafar <lareb.zafar@clickhouse.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ates memory.set builds the whole new version from its input, so a field the call leaves out is reset: confidence to 1.0, the sensitivity label to what detection gives for the value, the character limit to none. The sentence on declaring a scope named the type, tags, entities, validity and source. It names the confidence, sensitivity label, source trace, source resource and character limit too, as the dashboard's dialog sends them, and the two values memory.set refuses from a caller with 422: a source_class other than derived, external or imported, and a source_trace that starts with copy_rule:. Signed-off-by: Mohammad Lareb Zafar <lareb.zafar@clickhouse.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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: #1765
Related: #1232
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):
A definition can say which team or product it is for (
applies_toin its value), andmemory.definitions.disputesreports a name whose differing definitions each declare another team or product asalternativesinstead of a dispute to correct. The Review queue's Definitions tab shows what each definition applies to, lists the names that need review first, and lets a writer declare the team and product.Why
Two teams can each define one name differently on purpose.
memory.definitions.disputescompares text only, so every such pair read as a dispute, and the only ways out of the list were to make the texts equal or delete one. A declared scope lets the definitions stay different and tells a reader which case they are looking at.Scope and risk
Design in brief:
applies_tois a key of the definition's stored value: an object ofteam,productor both, each a string of at most 64 characters. There is no table, column, migration or setting. Anything else underapplies_to(another key, a value that is no string or is longer) declares nothing, so a misspelled key separates no definitions. A blank value declares nothing for its key only, and the other key still counts.team, or both declareproduct, with different values. Values are compared with the helper that folds a definition's names (fold_name: format characters dropped, NFKC, trimmed, runs of whitespace made one space, case-folded), soFinanceandFINANCEare one team. A scope on one side only, andteamon one side againstproducton the other, separate nothing. A dispute isalternativeswhen every two claims whose texts differ are separated; two claims with the same text need no separation from each other. Everything else issuspected, which is what every dispute was.suspected: the answer never saysalternativesfor pairs it did not check.memory.seton its key with the claim'scontent_sha256asif_match_sha256. A governed definition lapses aschangeduntil an admin promotes the edited text, as for any edit. A name keeps one shared definition: promoting a second, scoped or not, is refused with 409DEFINITION_NAME_TAKEN, which is unchanged behaviour that the new integration test pins.What it touches:
server/memory/domain/definition_disputes.py(claim_ofreads the scope;separated,dispute_state),server/memory/app/definition_disputes.py(the bounded state pass),server/memory/api/models_lifecycle.py(the two fields). The locate statement and every other statement are unchanged.frontend/src/views/admin/Definitions.tsx(the Applies to line and dialog, the badges, the order),frontend/src/api/definitions.ts(declareAppliesTo),frontend/src/api/memory.ts(rowFields: the fields of a row that a write of a new version sends back, whichpinMemoryand the dialog share), and one rule infrontend/src/components/MemoryInspector.tsx: Save refuses text that does not parse as JSON over a stored object, with a field error and no write. Saved as typed, such text replaced the object with a string.Left alone: comparing definitions across namespaces, a state that allows both definitions without a scope, validation of
applies_toat write time (a value the read does not accept is stored and reads as not declared; the dialog refuses a name over 64 characters), the drawer's handling of text that parses as JSON, and the drawer's Save, tag and expiry writes, which send the row's type, tags and character limit only.What could break:
applies_toobject of that shape starts to be read as a scope. Only a dispute'sstatechanges; no row, search result or promotion rule does.memory.setbuilds the whole new version from its input, so the dialog sends the row's other fields back with the value, as a pin does: type, tags, entities, confidence, sensitivity label, source trace, source resource, a source class a caller may declare, the validity window and the character limit. Declaring a scope changes the scope only: a definition with an end date keeps it. A copy rule's mark on the source trace is left out, sincememory.setrefuses it from a caller and the edited value is no longer the text the rule's run wrote. The concepts page names the same fields for a caller ofmemory.set, with the two values the op refuses from a caller: a source class the server decides and a copy rule's mark.Compatibility, rollout and rollback
memory.definitions.disputestakes the same input. Each entry ofdisputesgainsstate(suspectedoralternatives, defaultsuspected), and each claim gainsapplies_to(an object of string values, empty when the definition declares none). Both are additive. No op, error code, migration or setting is added: the registry holds 426 operations (312 experimental), as before.alternatives; its first line, which the help row shows, is unchanged. SDKs: the Python, TypeScript, Go and Rust wire models are regenerated; the Ruby SDK, the Python client and the reference pages did not change. CLI:loom call memory.definitions.disputes; a scope is declared withloom call memory.set.stateandapplies_toand draws every dispute as before. A server of the previous build sends neither, which this dashboard reads as a name that needs review whose definitions declare nothing (a frontend test covers it). A scope written through this build is an ordinary key of the value to the previous one.applies_toalready written stays in its definition's value as an inert key.Tests
Run on a ClickHouse and a server started for this change.
tests/unit/test_definition_disputes.py(48 tests, 13 added): 47 passed, 1 skipped (it runs SQL through theclickhousebinary, which the machine lacks). The added tests were written before the rules, and their first run failed on the missingdispute_state. Each rule was then broken in turn to see which test fails:test_a_key_both_declare_with_different_values_reads_as_alternativesfails when no pair is ever separated, when values are compared as written instead of folded, and when a blank value beside a declared key voids the whole scope instead of its own key.test_a_scope_on_one_side_only_is_suspectedfails when a declared scope against an undeclared one separates.test_disjoint_or_unknown_scope_keys_are_suspected(8 cases:teamagainstproduct, an unknown key, an unknown key beside a known one, a number, a 65-character value, a blank value, a text and a list in place of the object) fails when an unknown key is dropped instead of voiding the scope, and when any two different scopes separate.test_alternatives_needs_every_differing_pair_separatedfails when claims that say the same must also be separated, and when one unseparated pair is let through.test_a_pair_past_the_work_bound_stays_suspectedfails when the pair checks are not charged to the bound: one character short of the fourth check leaves the second disputesuspected.test_another_task_runs_before_each_disputes_pairs_are_checked: the loop gets a turn before each dispute.tests/integration/test_definition_disputes.py(5 tests, 1 added) withtests/analyzer: 17 passed.test_declaring_a_scope_lapses_the_governed_copy_as_changedpromotes a definition, declares its team throughmemory.setunder the claim's hash and readslapsed/changedfrommemory.definitions.list; a write under the hash of the text before the edit is refused withPRECONDITION_FAILEDand leaves the version; the dispute issuspectedwith one side declared andalternativeswith both; promoting the second definition is refused withDEFINITION_NAME_TAKEN; promoting the edited text governs the first again.npx vitest run --maxWorkers=2 --testTimeout=30000, on the final tree:src/views/admin/Definitions.test.tsx(42 tests, 12 added),src/api/definitions.test.ts(6, new),src/api.memory.test.ts,src/views/admin/ReviewQueue.test.tsx,src/components/MemoryInspector.pin.test.tsx,src/views/Recent.lists.test.tsx: 6 files, 191 passed.src/components/MemoryInspector.rename.test.tsx(12, 2 added),src/lib/callReason.test.ts,src/lib/canCall.test.ts,src/callBudget.test.tsx,src/views/copy.rules.test.ts: 5 files, 56 passed.statereads as alternatives: that test is the previous server's answer.src/api/definitions.test.ts: the body carries the row's type, tags, entities, confidence, sensitivity label, source trace, source resource, source class, validity window and character limit back with the new value, and leaves out a class the server decides, a copy rule's mark and an end date the row does not have. Both failed while the write sent the type, tags and character limit only. The body of the first parses as the op's input model, which refuses the copy rule's mark.npm --prefix frontend run build: built.npm --prefix frontend run budget: OK, the index chunk at 112.4 kB of 120 kB. Biome 2.5.14 on the changed files: clean.test_package_contracts,test_op_transport_contract,test_mcp_listing_budget,test_sdk_surface_contract,test_go_sdk_contract,test_docs_reference,test_op_reach_census,test_tunable_constants,test_store_names_refused,test_degraded_unnoted,test_public_copy,test_doc_links,test_agent_instructions,test_definitions_list,test_promote_definition,test_definition_write_rules,test_definition_term_match): 1024 passed, 15 skipped. Thentest_definition_disputes,test_session_content_senders,test_i18n,test_doc_links,test_public_copyandtest_read_scope_admission: 1571 passed, 1 skipped. Both were run before the review fixes.test_definition_disputeswith the scanstest_package_contracts,test_op_transport_contract,test_tunable_constants,test_store_names_refused,test_degraded_unnoted,test_public_copy,test_doc_links,test_agent_instructionsandtests/analyzer: 662 passed, 13 skipped, 1 failed. The failure istest_degraded_unnoted, which names a handler inserver/code/app/index/review_brief_build.py. This change touches neither that file, the scan nor its list.test_definition_disputes: 616 passed, 12 skipped, 1 failed, on the same handler.mainhas changed the handler since, so the scan passes there; this branch does not hold that commit, andgit merge-treereports no conflict withmain.make typecheck: 0 errors. Prettier 3.9.9 and the prose checker on the page: clean.make typecheck: 0 errors.ruff format --checkandruff checkon the changed files: clean. The function-length gate is at its baseline. Prettier 3.9.9 on the four changed pages: clean.mainwas merged three times. The third merge conflicted on the Review queue row ofdocs/features/dashboard.md; the row keeps both sides' sentences, and on that treetest_doc_linksandtest_public_copy(310 passed),src/views/emptyStates.rules.test.ts(2 passed) and Prettier on the page pass. The first two merged without a conflict. On the tree of the second merge every generator's--checkexits 0 (sdk_py_gen,sdk_py_client_gen,sdk_py_admin_gen,sdk_ts_gen,sdk_rb_gen,sdk_rust_gen,sdk_rust_gen --fixtures,sdk_go_gen,docs_reference,op_reach_census,plugin_eval_tools), the registry holds 426 operations (312 experimental), andtest_session_content_senders,test_definition_disputes,test_docs_reference,test_sdk_surface_contract,test_go_sdk_contract,test_op_reach_census,test_mcp_listing_budgetandtest_op_transport_contractpass (320 passed, 1 skipped).sdk/rust/src/wire_models.rsis 2,401,641 bytes on the merged tree, under the 4,194,304 byte bound on a tracked SDK source file. The Go and Rust wire models were formatted withgofmtfrom the Go 1.27.4 image andrustfmtfrom the Rust 1.85.1 image; neither tool is installed on the machine that ran the generators.Not run: the full unit suite, the full integration suite and the Playwright run (CI runs them;
frontend/e2e/definitions.spec.tsserves the new fields and asserts the badge and the Applies to lines), and no benchmark or load run.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 by writing the server tests and the drawer's Save test before their rules, by breaking each server rule and two dashboard rules in turn and reading which test failed, by running the tests above against a ClickHouse and a server started for this change, and by reading the whole diff against the area rules.
I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
make test-unitand applicable integration results are reported by CI; a full local run is not required before pushing.docs/reference/configuration.mdand thedocs/reference/tables (python scripts/codegen/docs_reference.py), the reach manifest,schemas/schema.sql(make schema-dump), the Codex plugin copies (python3 scripts/codegen/agent_plugin_sync.py) and the standalone skill bundles (python3 scripts/codegen/standalone_skills.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