Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 47 additions & 12 deletions docs/concepts/identities-and-namespaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -392,15 +392,19 @@ A `definition` is promoted only:
without it (422 `VALIDATION_FAILED`), and with 409 `PRECONDITION_FAILED` when the text
no longer has it.
- With a value that is a JSON object holding a non-empty string `term` and, optionally,
a list of string `aliases`; else 422 `VALIDATION_FAILED`.
a list of string `aliases`; else 422 `VALIDATION_FAILED`. Its `applies_to` (the team
or product it is for) is part of the approved text and no condition: declaring or
changing it is an edit, which needs a new promotion.
- Not labelled `medium` and not reading as `medium` or `high` (422
`SENSITIVE_DEFINITION_REFUSED`; a `high` label answers
`HIGH_SENSITIVITY_PROMOTION_REFUSED` first, as for any row).
- Within `memory_shared_definitions_max`: a new key at the ceiling, or any promotion
while the namespace is past it, is refused (409 `DEFINITION_CEILING`).
- Under a name no other live shared definition holds as its term or an alias (409
`DEFINITION_NAME_TAKEN`, naming the keys and the names), names compared folded: format
characters dropped, NFKC, whitespace collapsed, case-folded, then NFKC again.
characters dropped, NFKC, whitespace collapsed, case-folded, then NFKC again. A
declared `applies_to` changes none of this: one definition of a name is shared, and a
second for another team or product stays an unshared row.

One namespace's definition promotions, with their ceiling and name checks, and its
definition demotes run one at a time, the last to run deciding whether the definition is
Expand Down Expand Up @@ -447,15 +451,45 @@ names are its term and aliases, folded as the name checks fold them. Its text is
with case and spacing folded, or the served hash of its whole value when it has no `body`
string, so two definitions that say the same in another case or spacing do not differ.

Each dispute carries its `names` (names held by the same definitions are one dispute) and
its `claims` in key order: each definition's key, id, version, content hash, term, aliases
and `body`. None is preferred: the read marks no row, writes nothing and changes no search
result, so a caller shows both or asks which applies. The claim an admin approved is the
one whose key a `governed: true` search hit carries. `term` narrows the answer to the
dispute that holds one name.

A name leaves the answer when its definitions say the same. A writer ends a dispute with
one of two calls:
Each dispute carries its `names` (names held by the same definitions are one dispute), its
`state` and its `claims` in key order: each definition's key, id, version, content hash,
term, aliases, `body` and `applies_to`. None is preferred: the read marks no row, writes
nothing and changes no search result, so a caller shows both or asks which applies. The
claim an admin approved is the one whose key a `governed: true` search hit carries. `term`
narrows the answer to the dispute that holds one name.

A definition says which team or product it is for in its value's `applies_to`: an object
of `team`, `product` or both, each a string of at most 64 characters. A claim's
`applies_to` carries the declared keys with their values as written, trimmed. It is empty
when the definition declares none, and when its `applies_to` is anything else: with
another key, a value that is no string or a longer value, the whole object declares
nothing, so a misspelled key separates no definitions. A blank value declares nothing for
its key only, and the other key still counts. Two claims are separated when both declare
`team`, or both declare `product`, with values that differ once folded as names are (case
and spacing make no difference). A scope on one side only, and `team` on one side with
`product` on the other, separate nothing.

A dispute's `state` is `alternatives` when every two of its claims whose texts differ are
separated: the definitions are for different teams or products, and a caller asks which
applies. Otherwise it is `suspected`: the definitions may contradict each other. Each
pair check counts as 16 characters against the 256 KiB a call reads, and a dispute whose
pairs that bound does not pay for stays `suspected`.

A name leaves the answer when its definitions say the same, and reads as `alternatives`
when they are meant to differ. A writer settles a dispute with one of three calls:

- **A declared scope** on each definition that is meant to differ: `memory.set` on its key
with `applies_to` added to its value and the claim's `content_sha256` as
`if_match_sha256`, so a definition edited since the read is refused (409
`PRECONDITION_FAILED`). `memory.set` writes a whole new version, so read the definition
and send the fields it should keep back with the value: its type, tags, entities,
confidence, sensitivity label, validity, source trace, source resource and character
limit, and its `source_class` when that is `derived`, `external` or `imported`. Leave
out any other `source_class`, which the server decides, and a `source_trace` that starts
with `copy_rule:`: `memory.set` refuses both from a caller (422). This is an edit: a
governed definition lapses (`changed`) until an admin promotes the edited text with its
hash. The name keeps one shared definition, and promoting a second is refused (409
`DEFINITION_NAME_TAKEN`).

- **An edit** of one definition to say what the other says: `memory.set` on its key, or
`memory.update_by_id`. An edited definition that was governed lapses (`changed`) until
Expand All @@ -477,7 +511,8 @@ is then read by its key with `memory.get`. A `term` longer than 16,384 character
most a compared definition's names hold, is refused (422 `VALIDATION_FAILED`). A token
narrowed to a user or a session is refused, since these definitions belong to the whole
namespace. The dashboard's Review queue shows the answer above the shared definitions on
its **Definitions** tab.
its **Definitions** tab: the names that need review first, each definition with what it
applies to, and a dialog in which a writer declares the team and the product.

### Governed definitions in search

Expand Down
17 changes: 11 additions & 6 deletions docs/development/curation-loop-design.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,17 @@ search](../concepts/identities-and-namespaces.md#governed-definitions-in-search)
A definition's value is a JSON object, which `memory.set` stores whole in `value` and in
`value_json` (the embedding reads its excerpt, as for any row):

| Field | Meaning |
| ---------- | --------------------------------------------------------------------------- |
| `term` | The name as people write it. |
| `aliases` | Other names for the same thing (an abbreviation, an older name). |
| `body` | The definition's text. |
| `rests_on` | What it is based on: for query history, the SQL and its tables and columns. |
| Field | Meaning |
| ------------ | ------------------------------------------------------------------------------------------------------------ |
| `term` | The name as people write it. |
| `aliases` | Other names for the same thing (an abbreviation, an older name). |
| `body` | The definition's text. |
| `rests_on` | What it is based on: for query history, the SQL and its tables and columns. |
| `applies_to` | The team or product it is for: an object of `team`, `product` or both, each a name of at most 64 characters. |

Two definitions of one name that both declare a `team`, or both a `product`, with
different values are alternatives, not a contradiction ([definitions that
differ](../concepts/identities-and-namespaces.md#definitions-that-differ)).

The tables and columns of a query-history `rests_on` are the ones the source's query
log recorded for the SQL, marked `lists_from: "query_log"` and flagged when a list is
Expand Down
Loading
Loading