Repository navigation
The sensitivity detector labels card numbers, SSNs and stated PINs high and IBANs medium, and the sweep pages its window from a per-agent cursor - #89
Merged
Conversation
…gh, and IBANs medium A payment card number (13-19 digits with a network's leading digits and a passing Luhn check), a US Social Security number outside the never-issued ranges, and a PIN, passcode, CVV/CVC or security code stated with its 3-8 digit value now read as high: never embedded, read by key and audited. An IBAN that passes the ISO 13616 mod-97 check reads as medium. The sweep's coarse ClickHouse filter selects the new shapes; every high row stays the `credential` probe shape, so the scheduled pass labels them by default. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…s a stated value A card number is now 13-19 digits on group boundaries of a digit run, so "4111 1111 1111 1111 12/29" and a card after another number are found. A bare `pin` takes its value only after `is`, `was`, `:`, `=` or `#`, so "pin 128 rows" and "GPIO pin 115" stay unlabelled; each whitespace run in the PIN pattern has its own anchor, so a long run of spaces is read once. A spaced IBAN followed by an uppercase word is checked without the word. The docs list the high shapes one per bullet and say that the sweep leaves a `medium` row as it is. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… needs a value Grouped digits count as a card only in a card's grouping (4-4-4-4, 4-4-4-4-3, 4-6-5, 4-6-4) or as one 13-19 digit group, so two phone numbers side by side are not read as one card. A bare `pin` no longer takes its value after `#` (a connector pin), an IBAN after an IBAN-shaped token is found, and the sweep's coarse filter selects a PIN label only when digits follow it, so ordinary uses of the word do not fill the pass's row limit. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… postal code A card's leading digits now fix its length (Visa 13/16/19, Mastercard 16, Amex 15, Diners 14, JCB and Discover 16-19), so a row of port numbers or a 15-digit IMEI is not a card, and a grouped window counts with at most one other group on each side. A `PIN code` takes 3-5 digits, since a 6-digit one is an Indian postal code. The new patterns are ASCII-only like the sweep's RE2 filter, an IBAN's check digits must be digits, the coarse IBAN branch needs a word boundary and two groups, and a question naming an IBAN or bank account counts as contact intent. The security page says `high` where its readers now leave out more than credentials. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…s 3-5 digits `match()` runs on the stored column, where an object value's line break is the two characters `\n`: the PIN and IBAN branches now take an escape as a word boundary and as whitespace, and the PIN branch follows the detector's grammar instead of any run of letters. A bare `PIN` takes 3-5 digits like `PIN code`, since `PIN: 560001` is an Indian postal code. The IBAN pattern has room for an IBAN-shaped token before a 32-character IBAN, and the contact-intent terms take plurals. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… \u escapes reach the sweep A grouped card may have up to three short groups around it, two of them after it, so "card, MMYY, CVV" and "date, card" are labelled while a table of eight or more numbers is not. The sweep's coarse PIN and IBAN branches take a `\uXXXX` escape as a word boundary, since `json.dumps` writes non-ASCII characters that way. Only a bank account number is contact intent, not any account number. A connector pin written as an assignment reading as a PIN is documented and pinned by a test. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ry JSON control escape counts A bare `pin` needs `is`, `was`, `:` or `=` before its digits in the coarse filter too, so `pin 128 rows` and `GPIO pin 115` no longer take places under the pass's row limit. `\b`, `\f` and `\u000b` count as a boundary and as whitespace beside `\n`, `\r` and `\t`, so a PIN after any control character the detector reads is selected. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… to the sweep JSON writes a control character such as a vertical tab as `\u000b` even with `ensure_ascii=False`, so a raw chunk holding "PIN is\v4471" now reads as high. The sweep's coarse filter no longer takes `\b` as whitespace, which the detector does not either, so such a row is not selected on every 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]>
…e their real ranges A single ungrouped digit group counts as a card only at 15 digits (Amex) or 16; 14 and 19 come only from a printed grouping. So a 19-digit decimal hash or a 13-digit phone number written without its `+` no longer reads as a card. The network table uses the real leading digits: Mastercard 51-55 and 2221-2720, Diners 300-305, 3095, 36, 38-39, JCB 3528-3589, Discover/UnionPay 6011, 62, 644-649, 65. The security page lists the turns conversation search ranks among the raw text served as it is, and the knobs and stack docstrings say contact intent covers a bank account. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
`{"pin": "4471"}`, `{"badge_pin": "4471"}` and `{"ssn": "123456789"}`
now read as high: `detector_text` adds the stated form of a value held
under a key whose last word is pin, passcode, cvv, cvc, security code,
ssn, card number or pan, when the value has that secret's shape. Other
keys still label nothing. The sweep's coarse filter selects such keys.
JCB and Discover/UnionPay take 16 or 19 digits, the lengths a card can
be read at; a Luhn-valid 19-digit hash with a Visa prefix, an ungrouped
Amex number, a 19-digit Visa whose first 16 digits fail Luhn, and epoch
milliseconds have tests; the grouped-window loop does its cheap checks
first; the canary reuses `_live_vectors`.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…shapes Signed-off-by: zlareb1 <[email protected]>
…eads JSON key pairs
`{"pin": "4471"}` is read as `pin is 4471`, `pin_number` as `pin number
is`, and passcode, cvv, cvc and security code as `passcode is`, so the
free-text rules decide the length and `{"pin": "560001"}`, a postal code,
stays unlabelled. A card number is found under any key, so there is no
card key. `reads_high` reads the same `"key": value` pairs in raw JSON
text, and value_reads_high and reads_high share one high-only check.
security.md says a caller's explicit level sets the stored label while
the readers that send a value to a model still leave out one that reads
as high, and a test pins it. The sweep's prefilter takes a space before
the digits, and its RE2 behaviour on ClickHouse's own JSON text is pinned
by a clickhouse-local test.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
… from the detector's `KEYED_SECRET_WORDS` lists each key word split where a key may put a separator, with the label its value is stated under (`cvv is 123`, `security code is 5512`, `pin is 4471` for `pin_code`), and the sweep's prefilter builds its key alternatives from it, so `pass_code` and `cvv_2` are selected and the two lists cannot drift. A raw `"key": value` pair's value must end where the number does, so `4471abc`, `4471.5` and a 20-digit run are not read as a shorter number. The four readers that drop a high-reading value say "whatever its label", and a test pins it on the profile fold; security.md puts the fail-closed rule in its own paragraph and says a `security.code` row is not labelled by the sweep. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…lter skips 6-digit pin values `_KEYED_PAIR` puts the spaces inside a quoted value after its quote, so 200,000 spaces after `"pin":` read in about 30 ms instead of growing with the square of the run. The sweep's prefilter selects a key stated as `pin` only with a 3-5 digit value, so postal codes are not re-selected on every pass, and allows any run of non-alphanumeric characters between a key's words, as the detector splits a key (`pin__code`, `pin/code`). The SSN key word is one constant both modules read; `reads_high` runs the cheap check before the key pairs; the two fold tests are one parametrized test. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…shapes Signed-off-by: zlareb1 <[email protected]>
…ad, and the detector says it is a lower bound A label starts after anything but a letter or digit, so `BADGE_PIN=4471`, `atm_pin: 4471` and `CARD_CVV=123` read as high and `spin: 4471` does not; two-word labels take `_` or a space, `cvv code`, `cvc number` and `pass code` count, and "PIN for the front door is 4471" reads with `for` and up to three words. The label strings are shared with the sweep's prefilter. SSN keys include `ssn_number`, `ssn_no` and `social_security_number`, read by their last three words, and the prefilter takes JSON's whitespace escapes before a keyed value. The module docstring and security.md state that the detector is a deterministic lower bound over the listed label forms, with an operator's extraction policy as the catch-all, and security.md names the double-space and dotted card gap. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ar is one function The sweep's prefilter allows any run of characters that are neither letters, digits nor a quote after a key's last word, so `"CVV:"`, `"pin "`, `"SSN:"` and `"Security Code (CVV)"` are selected and `pin_count` is not. A keyed value is stripped of ASCII whitespace only, so the stored value, a raw chunk and the prefilter give one answer. `pin_grammar(space)` builds the qualifier and separator for both the detector and the prefilter; the label strings are named by the value lengths they take; `GPIO pin number 115` is named as a trade-off. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…be the whole string `_keyed_secret` looks up a key's last one, two and three words as tuples in `KEYED_SECRET_WORDS` and `SSN_KEYS`, with one-word forms (`pincode`, `passcode`, `cvv2`, ...) as their own entries, so `p_in` is not `pin`. `_KEYED_PAIR` requires a quoted value to close after its digits, so `"4471 abc"` is not a PIN, and reads any quoted key. The sweep's prefilter reads JSON escapes in a key's separators (`"pin\n"`), names the direct `pin code` label the detector also uses, and a test pins that a dotted `security.code` row is not selected. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… an escaped quote `KEYED_SECRET_WORDS` and `SSN_KEYS` add each multi-word entry written as one word (`cvvcode`, `ssnno`, `SOCIALSECURITYNUMBER`) instead of listing them by hand. `_KEYED_PAIR` and the sweep's key separator read an escaped quote or backslash inside a key (`pin\"`, `door\\pin`). The direct `pin code` form skips a position (`PIN code 100 of the batch`), and the postcode-like label is built from `PIN_CODE_LABEL`. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…shapes Signed-off-by: zlareb1 <[email protected]>
…y word where the detector does `_KEYED_PAIR` bounds a key to 200 characters, so a run of escaped quotes reads in linear time (100,000 in under a second; 20,000 took 7 s before). The sweep's prefilter starts a key's first word after a character that is neither a letter nor a digit, a JSON escape, or a capital after a lowercase letter (`badgePin`), so `spin` and `unpin` are not selected. The detector also splits a key at every change of case, so `PINcode`, `CVVcode` and `SSNno` read as their words. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…nd `Spin` is one word The detector reads a key with the camelCase split, and reads a run of two or more capitals before a lowercase word a second way (`ATMPin` is `ATM`, `Pin`; `PINcode` is `PIN`, `code`), so `Spin` and `ATMPIN` are one word and are not labelled. The sweep's prefilter no longer copies that rule: it selects any key that ends in a label, a superset, and the detector decides. The few non-secret rows it selects (`spin`, `unpin`, `ATMPIN`) are pinned by the clickhouse-local test and documented. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…shapes Signed-off-by: zlareb1 <[email protected]>
…shapes Signed-off-by: zlareb1 <[email protected]>
…shapes Signed-off-by: zlareb1 <[email protected]>
…ate is not a PIN The scan reads its window oldest first on a (created_at, memory_key, memory_id) cursor, up to ten pages of the pass's row limit or until that many rows are labelled, so selected rows the detector leaves unlabelled can no longer hide a later high row from every pass. A stated PIN's value ends where its number does, so `the tzdata pin is 2024.1` and `base image pin is 2024-01-15` are not PINs. Comments are cut to the fact each carries, with the label forms listed in security.md only. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ord boundary in the prefilter The CLI sweep reads pages until --limit candidates are found or the rows run out, so a high row behind a page of selected-but-unlabelled rows is reached. The prefilter reads sk-, pk-lf-, AKIA, eyJ, AIza and the GitHub prefixes at a word boundary, as the detector does, so task- and disk- rows are not selected. A stated PIN value must end at its number: a version, a date with slashes or a run-on word is not a PIN. The scheduled pass's ten-page cap is documented and pinned by a test. 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]>
…rt key Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
The analyzer drive and the statements test pass `page_size` to `scan`, which requires it. `SweepCandidate.sort_key` is required, and the page size is read from the bound `LIMIT` only. The linear-time test asserts growth from n to 4n instead of a wall-clock bound, the canary write test compares the whole `memory.get` answer, and security.md says the worker selects the shapes in `LOOM_SENSITIVITY_SWEEP_SHAPES`. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…agent Pages of versions labelled before the parts merge give no row, so they never moved the scan past their agent, and a pass spent on them left its cursor at the same agent. Such a pass now leaves the cursor past that agent. The CLI tests read more than one page and check that --limit refuses 0, and the paging settings' comments are two lines. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…versions A pass that found nothing and ran out of pages left its cursor past the agent it stopped in even when its last page was an ordinary one that crossed into the next agent, so that agent's later rows waited for the sweep to come back round. The pass now records whether its last page's FINAL read gave fewer rows than keys and moves past the agent only then. ApplyResult keeps each failure once, with its error, and the module has one name for the coarse filter, coarse_shape_re. The worker docstring and security.md are re-wrapped. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…es its default The phone branch of the coarse filter takes the escape-aware whitespace class between its groups, so a number grouped by `\n` or a no-break space in stored JSON text is selected, as the detector labels it. `--limit` refuses a non-integer with the same message as 0, and its help names the default of 20000. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ield names every shape - scan sets `truncated` when any of its reads stopped before its end or the candidates were cut, and `last_page_short` only from the read that set the resume key; `_read_range` returns its own result, and the worker's stuck check no longer reads the memory key. - The memory.set / memory.update `sensitivity` description names card numbers, SSNs, PINs and IBANs; the op reference is regenerated. - The CLI reads `--limit` as already parsed. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…urrent row The skip check compared the FINAL read's row count with the page's key count, so a key written into the range between the two reads could stand in for a labelled key that gave no row, and the scan moved past an agent whose later rows were unread. It now compares the two key sets. The cursor rules are kept in security.md only; the worker docstring, `scan` and `_stuck` point there. The pages-per-pass setting's comment backticks the setting it names. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
_resume_past_agent says what the helper decides: whether the next pass starts past the agent this pass stopped in. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…nd the sweep cursor's length counts stored characters The okf export help, the include_high and examined field comments, the passage, digest and evidence comments and their generated pages now say a chunk is kept back when it holds a high shape (a credential, card number, SSN or stated PIN), not only a credential. cursor_text writes its JSON with ensure_ascii=False, so a non-ASCII agent name that fits the 512-character store stays the cursor. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
A short sweep page is one whose FINAL read gave no current row for one of its keys, which is what the key-set comparison checks. Consolidation's `examined` excludes rows labelled `high`, not every labelled row. The export docs say the server audits every released item, and the CLI paragraph is rewrapped. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ts pages per pass are capped at 1000 A page cap past what a pass can read inside its 900 s deadline would cancel every pass before it stores its cursor. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…'s stale-key flag is named for what it records Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…stores its cursor The scan takes a time budget; the worker passes half the pass deadline, so a pass whose pages cost more than the deadline allows applies what it found, stores its cursor and reports truncated instead of being cancelled at the same place every time. The pages-per-pass and shapes comments are two lines, the deadline detail is in security.md, the long-agent cursor rule names the cursor at such an agent too, and the pages-per-pass ceiling is tested. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…or enforces The worker reads the deadline from its registry spec instead of working it out again from the interval, and the worker test pins 450 s at the default daily interval. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ry, and its stale-key check reads as a set difference Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ch a test now names Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… agent A page that crosses from an agent with a key waiting for a merge into the next agent leaves the cursor at the next agent, so its later rows are read. The export-okf --include-high help in cli_tree.json matches the CLI, and the readers' comments name every high shape, not only credentials. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… before the earlier-agent case Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…INAL read The test used a counted sequence of clock reads, which pinned how often scan reads the clock. It now uses ManualClock and moves it past the pass's time once the first page's FINAL read returns. scan no longer guards against a limit below 1, which no caller passes, and its test is gone. The CLI limit test also refuses `abc` and checks the message for each bad value. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
The structured profile's filter comment and security.md's list of what reads as high cover every high shape, not credentials only. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
A page past an agent now bounds on (org, namespace, agent) alone, so it
skips no stored agent name such as `a\x00b`; the cursor writes that place
as {"past": [...]}. The structured profile build is listed among the
readers that leave out a value reading as high whatever its label, with a
test for a low-labelled PIN.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
The cursor names no key inside an agent, so each pass reads the same pages of it: a row behind more than pages-per-pass x rows-per-pass selected-but-unlabelled keys of its own agent waits until they leave the window, and the operator's run reaches it. security.md, the worker docstring and the scan comment say so; a clickhouse-local test pins it. The resume_after comment names both cases that leave it None. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
`AGENT_KEY` holds the sort key's agent columns and `past_agent` the place past an agent, replacing `past_key(key, "agent")`, the `[:3]` slices and `_agent`'s own column list. The `scan` docstring says `only_shapes` narrows the ClickHouse filter and that `value_json` is read too, and the `sensitivity_sweep_shapes` comment names `other` (IBAN-only rows) as left to `--only-shape` with `phone`. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…applies phone and IBAN rows Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
5 of 9 tasks
zlareb1
added a commit
that referenced
this pull request
Oct 21, 2026
…ercise (#120) * The tests #95 left red follow the code they exercise - test_memory_sensitivity calls _set_prepare_value with the write alone: #95 moved restated onto _SetWrite. - test_memory_webhooks builds its SweepCandidate with the sort_key #89 made required. - test_settings_env_contract probes memory_webhook_backoff_steps_seconds with a valid list of steps, as it does other validated strings. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> * The sweep candidate's sort key comes from its own identity tuple Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]> --------- Signed-off-by: zlareb1 <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
7 of 9 tasks
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):
With
sensitivityunset, a memory holding a payment card number (Luhn-checked), a US Social Security number, or a PIN, passcode, CVV or security code stated with its value is labelledhigh, so it is never embedded and is readable by key only with an audited read. An IBAN with a registered country code, that country's length and a passing mod-97 check is labelledmedium. The daily sensitivity sweep reads its window in pages ofLOOM_SENSITIVITY_SWEEP_MAX_ROWS_PER_PASSkeys, up to the new live settingLOOM_SENSITIVITY_SWEEP_PAGES_PER_PASS(default 10) pages or half its pass deadline per pass, and resumes at the agent it stopped in, from a cursor inloom.worker_status;loom sensitivity-sweep --limitnow caps the candidates found rather than the rows read, and refuses 0.Why
The detector labelled only credential shapes
highand email or phone numbersmedium. Users of a chat service paste payment and identity data into conversations, and the detector missed it: "My employee badge PIN is 4471" was stored as an ordinary memory, embedded and returned by search.The sweep's paging ships in this PR rather than a PR of its own, for three reasons. The sweep is the only labeller for rows that arrive by
observe.record,copy_to,namespace.restoreand the imports, so the new shapes protect those rows only if a pass reaches them: the old read took the firstLOOM_SENSITIVITY_SWEEP_MAX_ROWS_PER_PASSmatching rows every pass, so a card or PIN row behind that many selected rows the detector leaves unlabelled aged out of the window unlabelled. Both changes rewrite the same read: the new shapes need it to returnvalueandvalue_jsonapart (a dotted key such assecurity.codekeeps its words only invalue) and to filter by shape, and the paging replaces that statement, so a split needs an intermediate read that neither PR keeps. And the paging tests place PIN rows behind the selected-but-unlabelled ones, which needs the PIN shape. A rollback reverts both together; neither changes stored data beyond the labels and the sweep's cursor row inloom.worker_status, which a reverted build does not read.Scope and risk
server/memory/domain/sensitivity.py: four new shapes, each a single regex pass over the text. The detector is a deterministic lower bound: it recognises the label forms and shapes listed here, not every way a person can phrase a secret. The module docstring and security.md say so and list the label forms. The catch-all for extraction is an operator's extraction policy, which is a separate change.+), consecutive groups in a printed card grouping (4-4-4-4, 4-4-4-4-3, 4-6-5, 4-6-4) with at most three short groups (1-4 digits) around it, at most two of them after it. The leading digits must fix a network and its length. Visa: 4, at 16 or 19 digits. Mastercard: 51-55 and 2221-2720, at 16. Amex: 34 and 37, at 15. Diners: 300-305, 3095, 36, 38 and 39, at 14. JCB 3528-3589 and Discover/UnionPay 6011, 62, 644-649 and 65: at 16 or 19. The Luhn check must then pass. A card pasted with its expiry and CVV (4111 1111 1111 1111 0429 123), or after a date or another number, is still found. These stay unlabelled: a 19-digit decimal hash with a Visa prefix that passes Luhn (4000000000000000006, rejected by the length rule), one with no network's prefix (6000000000000000004), a row of port numbers (3000 5432 6379 9200passes Luhn), a table of eight or more 4-digit numbers, a 15-digit IMEI (always Luhn-valid) and yyyymmdd runs. Groups joined by two spaces or by dots (4111 1111 1111 1111,4111.1111.1111.1111) are not read; security.md names this gap. These are not read as cards but staymediumby the phone shape: a 13-digit phone number written without its+(4915123456787), two phone numbers side by side, and epoch milliseconds (1760000000000). The Visa-prefixed hash and the phone number both pass Luhn, so they test the length rule, not the checksum. A 19-digit Visa printed 4-4-4-4-3 whose first 16 digits fail Luhn (4000 0000 0000 0000 006) is labelled, as is an ungrouped 15-digit Amex (378282246310005).ddd-dd-ddddwithout the never-issued ranges (area 000, 666, 9xx; group 00; serial 0000).pin,pin code,pin number,passcode/pass code,cvv,cvc,cvv2,cvc2,cvv code,cvv number,cvc code,cvc numberandsecurity code. A two-word label may use_or a space (PIN_CODE,security_code). A label starts after anything but a letter or digit, so a prefix counts (BADGE_PIN=4471,atm_pin: 4471,CARD_CVV=123) and a word ending in a label does not (spin: 4471). The value followsis,was,:or=, after an optionalforand up to three words (PIN for the front door is 4471; four words or a barepinwith a direct value stay unlabelled). Every label except a barepinalso takes the value directly (CVV 123). A barepinis also a verb (pin 128 rows) and a connector pin (GPIO pin 115,pin #115), so it does not. A direct value followed byof(passcode 100 of the batch,PIN code 100 of the batch) is a position and stays unlabelled.pin number, passcode, CVV/CVC and security code take 3-8 digits.pinandpin codetake 3-5, becausePIN: 560001andPIN code 560001are Indian postal codes, so a 6-digit PIN is labelled only when stated as aPIN number(a trade-off). The other trade-off: a connector pin written as an assignment or withnumber(GPIO pin: 115,GPIO pin number 115) reads as a PIN, the price of readingPIN: 4471andPIN number 4471as one. A test pins it, and security.md says so. A value ends where its number does, so a version or a date (the tzdata pin is 2024.1,pytz pin: 2023.3,base image pin is 2024-01-15,base image pin is 2024/01/15,PIN for certifi is 2024.2.2), or a run-on word (tzdata pin: 2024a,the pin is 1234abc), is not read as a PIN, whileMy PIN is 4471.still is. Each whitespace run in the pattern has its own anchor, so a long run of spaces is read in one pass. The new patterns are ASCII-only, matching the sweep's RE2 filter, so whatever the write path labels the sweep can also select. The label strings are plain regex that RE2 reads too:POSTCODE_LIKE_PIN_LABELforpinandpin code(3-5 digits),PIN_CODE_LABELfor the directpin codeform (andPOSTCODE_LIKE_PIN_LABELis built from it), andPIN_LABELfor the rest (3-8 digits). One function,pin_grammar(space), builds the qualifier and separator for both the detector (\s) and the sweep's prefilter (the escape-aware whitespace class).medium): country code, numeric check digits and BBAN in groups of four, then the ISO 13616 checks: the country code is in the registry (_IBAN_LENGTHS, one length per country), the length is that country's, and the number is 1 mod 97. Without the registry check about 1 in 97 uppercase tokens of the shape (license keys, serials, ticket codes) passed. A spaced match can take in an uppercase token before or after the IBAN (XY12 GB82 ...,... 1332 EUR), so each run of its groups is checked: at most ten groups, 55 runs. The card check skips the digits of a valid IBAN: a spaced IBAN's groups can read as a Luhn-valid card grouping (DE24 4005 0150 0000 0005 00holds4005 0150 0000 0005, a Visa-prefixed number that passes Luhn), which labelled about one in ten such DE, FR and IT IBANshigh. The IBAN digits are masked in one pass over the text, so a value dense with IBANs is still read in linear time. Search demotesmediumrows unless the question shows contact intent, and a question that names an IBAN or a bank account (number), plurals too, now counts as contact intent (any other account number does not), so the row that answers it is not demoted.LOOM_MEMORY_SENSITIVITY_AUTODETECTturns detection on or off, and the places that calldetect_sensitivity,reads_highandvalue_reads_highare the same. New: the shapes those functions read ashighormedium, so every place that reads text ashigh(digests, extraction prompts, chunks, exports) now also treats a card number, SSN or stated PIN ashigh.reads_highnow also decodes JSON\uXXXXescapes in raw text, because a chunk's indented JSON writes a vertical tab as\u000beven withensure_ascii=False.detector_textstill reads a JSON value one scalar at a time. A key whose last one, two or three words name a PIN-like secret now states its digits under that label, as a line of its own, so the free-text rules decide the length.pin,pin_codeandpincodegivepin is <value>(3-5 digits, so{"pin": "560001"}and{"pincode": "560001"}, postal codes, stay unlabelled).pin_numbergivespin number is <value>.passcode,cvv,cvcandsecurity_codeeach give<label> is <value>(3-8 digits).pass_code,cvv_2andcvc2count too, and each label is accepted by the free-text PIN pattern withis. A key is split into words at any run of characters that are neither letters nor digits, or at a change of case, sopin__code,pin/codeandpinCodeall count. Anssn,ssn_number,ssn_noorsocial_security_numberkey states an SSN, dashes optional. A key is read by its last one or two words (three forsocial_security_number), compared as word tuples, sop_inis notpin; each multi-word entry is also derived written as one word (pincode,passcode,cvv2,cvvcode,ssnno,SOCIALSECURITYNUMBER), not listed by hand. A key splits into words with the camelCase rule (badge/Pin,ATM/Pin;SpinandATMPINare one word each). A run of two or more capitals before a lowercase word is also read a second way, as a word of its own (PINcodeisPIN/code,CVVcode,SSNno).ATMPinandPINcodehave the same shape, so one split cannot read both. A single capital starts its word under both splits, so{"Spin": 1200}stays unlabelled.cvv_code,cvv_number,cvc_codeandcvc_numberkeys count with thecvv/cvclabel. A card number is found under any key, so there is no card key. Prefixes and any case or separator are accepted (badge_pin,badgePin,PIN,security-code). Any other key still labels nothing: a{"password": ...}key does not label its value. A connector pin in a config ({"pin": 115}) reads as a PIN, asGPIO pin: 115does.reads_highreads the same"key": valuepairs in raw JSON text (a chunk of an object value) when the value is digits and dashes. A quoted value must be the whole string, with spaces allowed around the digits, so"4471 abc"is not one. A bare number ends where its digits do, so4471.5and a 20-digit run are not read as a shorter number. The key is a quoted string, escapes included ("pin\"","door\\pin"), of at most 200 characters, so the scan stays linear. Before that bound, a run of escaped quotes (\"repeated) took 0.45 s for 5,000, 1.76 s for 10,000 and 7.17 s for 20,000, which is quadratic. With the bound it takes 158 ms for 20,000 and 791 ms for 100,000. The pattern's whitespace runs each have their own anchor. The previous form (\s*"?\s*) took 1.75 s on 20,000 spaces after"pin":and 6.7 s on 40,000, so it grew quadratically. The current one reads 200,000 spaces after"pin":or"pin": "in about 30 ms each.KEYED_SECRET_WORDS), so the two cannot drift. Between a key's words it allows any run of characters that are neither letters nor digits nor a quote, as the detector splits a key;pin\/code, ClickHouse's form ofpin/code, fits. It also reads the SSN key words (SSN_KEYS) and the free-text PIN labels from the detector. The prefilter's contract for keys is a superset, not a copy: it selects a key that ends in a label, whatever comes before it, and the detector decides. So it may select a few non-secret rows (spin,unpin,Spin,ATMPIN), which the detector, comparing whole key words, leaves unlabelled. Each costs a re-check on the sweep's passes within its window. security.md and the sweep comment say so. Between a key's words and after its last word it allows a run of characters that are neither letters nor digits, read in JSON text, where one may be an escape such as\n,\/,\",\\or\u00e9("CVV:","pin ","Security Code (CVV)","pin\n"), and the value may start with JSON's\tor\nescapes, so{"pin": "\t4471"}is selected;pin_countis not. A keyed value is stripped of ASCII whitespace only, the whitespace the patterns read, so{"pin": " 4471"}gives one answer fromvalue_reads_high,reads_highon a raw chunk and the prefilter. A word stated aspinis selected only with a 3-5 digit value, so{"pin": "560001"}and{"address": {"pincode": "560001"}}are not. Every other key is selected with a value starting with three digits, after an optional quote and spaces. The sweep matches and detects on both the writer's bytes invalue, where a dotted key such as{"security.code": "5512"}keeps its words, andtoString(value_json), which an import may fill with more thanvalueholds, so a dotted key is labelled as the write path labels it.value_reads_high): consolidation, the profile fold, the structured profile, the existing memories an extraction prompt shows,observe_extractand the entity extractor. A value that reads ashighis left out of their prompts even when its writer labelled itlow, so this fails closed by design. security.md says so in its own paragraph, the five call sites' comments say "whatever its label", and tests pin it onobserve_extract, on the profile fold and on the structured profile build. The fold test is parametrized over an unlabelled credential and alowrow holdingbadge PIN is 4471, the build test over an unlabelled and alowrow holding it; neither reaches the model.server/memory/app/sensitivity_sweep.py): The coarse filter (coarse_shape_re, every shape when none is named) gains the four shapes, so the ClickHouse prefilter still selects everything the detector labels.match()runs onvalueand ontoString(value_json), which hold JSON text for an object value, so a control character there is an escape (\n,\f,\u000b) and a non-ASCII character is\uXXXX(json.dumpsescapes it). The PIN and IBAN branches take any such escape as a word boundary, and the card branches take one as the character before the number (the escape's last hex digit can be a digit, as in番号4111111111111111or a card after a no-break space), and take\f,\n,\r,\tand\u000bas whitespace, as the detector's ASCII\sreads them decoded (a backspace is not whitespace). The PIN branch follows the detector's grammar: every label afteris/was/:/=, and every label but a barepindirectly. The IBAN branch needs a word boundary and two groups. The phone branch takes the same escape-aware whitespace between its groups as the assignment branch, so415\n555\n0123and a number grouped by no-break spaces, which the detector labelsmedium, are selected by the full filter and by--only-shape phone. Ordinary uses ofpin(pin 128 rows,GPIO pin 115,pin the base image before the 2025 release) and strings likeSHA256SUMStherefore do not take places under the scheduled pass's row limit. Thepinandpin codealternatives take a 3-5 digit value followed by a non-digit, as the detector reads them, so the postal codesPIN: 560001,PIN is 560001andPIN code 560001are not selected either, whilePIN number 560001is. Some rows still are: those the coarse filter cannot rule out (passcode 100 of the batch, since RE2 has no lookahead). The pass cursor below keeps them from hiding later rows. I checked the filter against ClickHousematch()on a local server, onjson.dumpstext, the form thevaluecolumn holds for every non-object value, and ontoString(value_json)for object values holding\n,\f,\b,\vand\u201cbefore or inside a stated PIN. Every new shape matched, and the negatives did not. Everyhighrow stays thecredentialprobe shape, so the scheduled pass's default filter (credential,email) labels cards, SSNs and stated PINs with no settings change. An IBAN-only row isother, like any other medium shape outside email, and the operator applies it withloom sensitivity-sweep --apply. I did not add a new probe shape name because it would change the CLI's--only-shapechoices and the setting's default for amediumlabel. Renaming thecredentialshape, which now covers cards, SSNs and PINs too, is left for a follow-up.org, namespace, agent, user_id, session_id, memory_key), in pages ofLOOM_SENSITIVITY_SWEEP_MAX_ROWS_PER_PASSdistinct keys (SELECT DISTINCT, so a key with several unmerged versions takes one place), each page starting after the last key of the one before, until that many candidates are found,LOOM_SENSITIVITY_SWEEP_PAGES_PER_PASSpages are read, or half the pass deadline (450 s at the default daily interval) has passed. A page takes two reads. The first reads the page's keys from any row version that matches, withoutFINAL, so the window prunes partitions, every thread reads, and a read in key order stops at theLIMIT. The second reads withFINALthe current version of each key from just after the page before's last key up to this page's last key (upto_<column>parameters from the first read's last key) and keeps the ones that still match. It filters on(org, namespace, agent, user_id, session_id, memory_key) IN (<the keys in that range>)as a subquery with noLIMIT, so a key written into the range between the two reads is read too and no key is read on two pages, and it binds no key list (a list of 20,000 keys as one array parameter would be longer than the request URL allows) and reads only the granules of the page's keys. Both statements are inserver/memory/store/sensitivity_sweep_sql.py. The current version of a matching row is itself a matching row version, so the first read cannot miss one. The cursor is spelled asa > x OR (a = x AND ...).LOOM_SENSITIVITY_SWEEP_PAGES_PER_PASSis a new live setting (default 10, from 1 to 1000), in the settings catalog.scantakes a time budget (seconds), and the worker passes half the pass deadline the supervisor enforces (pass_deadline_secondsin the worker registry), a value derived from that deadline rather than a new setting. Once it is spent the scan reads no more pages: the pass applies what it found, stores its cursor and reportstruncated, so pages that cost more than the deadline allows (large pages, many pages or a short interval) cannot have the supervisor cancel every pass at the same place before its cursor is written. The worker reads it on every pass, so a runtime override reaches the next pass without a restart. The ClickHouse filter is built from the coarse alternatives of the shapes in the shape filter only: the scheduled pass (credential,email) selects the credential, card, SSN, PIN and keyed alternatives and email, not the phone or IBAN ones. A ten-digit run the detector reads as a phone number (epoch seconds such as"ts": 1760000000, a run id) is therefore not selected. The card alternative selects only what the detector can read as a card: a lone 15- or 16-digit group with a network's leading digit (2-6), or a printed grouping that starts with a 4-digit group with one. Epoch milliseconds (1760000000123) and 19-digit ids are therefore not selected either. Before, the alternative matched any run of 13 or more digits. The credential-word alternative selects only an assignment, as the detector labels one: a word from the detector's own list (ASSIGNMENT_WORDS, shared by both), at a word boundary or after a JSON escape, then:or=after any whitespace the detector's Unicode\sreads or its escape, then eight characters of a value, after an optional quote. Before, it matched the bare words (password,secret,pwd,bearer) anywhere, so prose such asI forgot my passwordorcd $(pwd)was selected and left unlabelled on every pass. So these prose and epoch-digit rows are not selected at all. The operator's run with no--only-shapekeeps the full filter. A selected row the detector leaves unlabelled stays unlabelled and is selected again on every pass. Before, the first page of such rows was re-read every pass, so a later high row could age out of the window unlabelled. Inside a pass, a full page whose first and last keys are in one agent, whoseFINALread gives back a current unlabelled row for each of its keys, and that gives no candidate moves the scan past that agent: the next page bounds on(org, namespace, agent)alone (past_agent), so it starts after every key of that agent and skips no stored agent name, whatever bytes it holds (an identity column takes any string,a\x00bincluded). One pass therefore crosses up toLOOM_SENSITIVITY_SWEEP_PAGES_PER_PASSsuch agents. A key whose only matching version is an older one gives no row on theFINALread:applylabels a row by inserting a new version, and a delete writes a tombstone version, so until the parts merge the old unlabelled version still matches the key read. A page of such keys does not move the scan past its agent; the scan reads on to the next page, so the agent's rows after the ones labelled or deleted are still read and labelled. Until the merge, each such page costs the pass one of its pages, and a pass that finds no candidate and runs out of pages on such a page (itsFINALread gave no current row for one of the page's keys in the agent of its last key; a key like that in an earlier agent on the page sorts before the cursor, so it leaves the cursor at the agent the pass stopped in; the check compares the page's keys with the rows' keys, not their counts, since that read also returns a key written into the range between the two reads) leaves the cursor past that agent, so the next pass does not read the same pages again; the rest of that agent is read when the sweep comes back round to it. A pass whose last page was an ordinary one, even one whose keys cross into the next agent, leaves the cursor at the agent it stopped in: the next pass reads that agent again, and a full page inside it moves the scan past it. The operator's run does not skip. The pass keeps the last key it read in each agent it moved past, in memory for that pass only, and once it has read every other key (the keys before its cursor too) with pages left, it reads the rest of each such agent in order, without the skip, until the pages run out. So a row more than one page (LOOM_SENSITIVITY_SWEEP_MAX_ROWS_PER_PASSselected keys) into such an agent is reached in the same pass when the pages left cover the keys ahead of it. The cursor names no key inside an agent, so every pass reads the same pages of that agent: a row behind more thanLOOM_SENSITIVITY_SWEEP_PAGES_PER_PASSxLOOM_SENSITIVITY_SWEEP_MAX_ROWS_PER_PASSselected-but-unlabelled keys of its own agent is not reached by the worker until those keys leave the window, andloom sensitivity-sweep --applyreaches it. security.md and the worker docstring say so. The pass outcome'struncatedis true when any of these reads (the range after the cursor, the range before it, or the rest of an agent moved past) stopped before its end, or the candidates were cut to the limit; the cursor decision reads only the read that set the resume key. A pass starts at the agent the previous pass stopped in: the worker stores(org, namespace, agent)of the scan's resume key as its cursor inloom.worker_status(pass_context.set_cursor, written afterapply): a JSON list[org, namespace, agent]for the agent the pass stopped in, or{"past": [org, namespace, agent]}for the place past it, bounded on those columns alone. The cursor holds no user id or memory key:loom.worker_statushas a 30-day TTL and no erasure step, so a full sort key there would outlive the user's erasure. The erasure census reason for the table says the cursor names an org, a namespace and an agent. A pass that labels rows leaves the cursor at its agent, so the next pass reads that agent again and its remaining rows are labelled on the following passes. A pass that labels nothing because its candidates fail inapplyleaves the cursor past its agent when every failed candidate is in that agent, so a row that fails on every pass is retried when the sweep comes back round to it and cannot hold every later pass in that agent. Failures in an earlier agent than the one the scan stopped in leave the cursor at the agent it stopped in, so that agent's unread rows are not skipped. A pass that started at a cursor and reaches the window's last key with pages left goes on from the first key up to the cursor (a third bound on the key read,stop_<column>), so rows that sort before the cursor are read in the same pass instead of waiting for a later one and possibly leaving the window; when it reads that whole range the cursor stays where the pass started. When a pass that started at the first key reads the window's last row the cursor is[]and the next pass starts again at the first key. When the candidates are cut to the limit,scanreports the last kept candidate's key as stored as its resume key (each candidate keeps the scanned row's sort key, since its own fields write an empty agent, user or session as-); the worker's next pass starts at that candidate's agent, and the rows the pass labelled are no longer selected. The cursor's JSON keeps non-ASCII characters as they are (ensure_ascii=False), so its length is the length the store keeps. A cursor that does not fit the store's 512 characters names the place past its namespace instead (or past the org, or the first key when even that does not fit), so an agent name that does not fit cannot stall the sweep; the agents after it in that namespace wait for the sweep to come back round. So selected rows the detector leaves unlabelled in other agents (for example{"spin": ...}keys, invalid-rangeddd-dd-ddddstrings, or Luhn-failing 16-digit order ids) cost one page each and do not keep a pass from reaching a later agent's or org's credential, unless more such agents than the page cap sit ahead of it.loom sensitivity-sweep --limittakes a positive integer. The operator'sloom sensitivity-sweeppages through its whole scope until--limitcandidates are found or the rows run out.scantakes the page size apart from the candidate cap: the worker passesLOOM_SENSITIVITY_SWEEP_MAX_ROWS_PER_PASSfor both, and the CLI reads pages ofmax(--limit, LOOM_SENSITIVITY_SWEEP_MAX_ROWS_PER_PASS)keys, so a small--limitpreview does not read the scope a few keys at a time. Its--limithelp says it caps the candidates found, which are labelled with--apply, and names the default of 20000. A value that is not a positive integer,abcor0, is refused with one message. The prefilter reads the key prefixessk-,pk-lf-,AKIA,eyJ,AIzaandgh[opusr]_at a word boundary, as the detector does, so rows holdingtask-ordisk-no longer take places in a page. The settings' comments and security.md say so.system.query_log:loom.memorywith 2,000,000 rows over 90 days (four monthly partitions, merged), 40 orgs x 5 namespaces x 4 users, every fourth row holding a ten-digit epoch, 44,463 rows in the two-day window, on 32 cores. Pages of 500 keys.max_threads = 1: 1,400 ms, 2,000,000 rows. The same read at the default thread count: 152 ms; at 3 threads, the cap thebackgroundtraffic class sets for workers and operator CLIs: 510 ms. Both read 2,000,000 rows, becauseFINALturns off partition pruning oncreated_at. The two reads now: 78 ms for the key read (443,560 rows, one partition) and no second read, at the default thread count and at 3 threads alike.FINALread 58-75 ms, 38,912-72,576 rows, 15-24 MiB, on pages 1 to 3. One page of 20,000 keys, which holds all 11,107: the key read 58-60 ms, 445,546 rows, 9 MiB; theFINALread 672-708 ms, 953,984 rows, 96-106 MiB. So a 500-key page costs about what the old read cost for a fifth of its memory, and a page that spans the whole window costs about five times the old read's time with less than half its memory.system.query_log): 2,000,040 rows over 40 orgs in 23 monthly partitions, one matching row per org in the window, so one page holds keys from every org. The key-range form of the second read, which an earlier head of this PR had, selected 2,085,760 rows (418 MB peak): the range spans almost the whole table andFINALprunes no partition. The subquery form selected 122,888 rows (804 marks, 76 MB peak); the key read itself selected 40.GROUP BYthe sort key,HAVING argMax(<the conditions>, version),LIMITthe page), which would make a short page impossible, measured with clickhouse-local on 2,000,000 rows of the same shape, two runs: in a two-day window (172,800 rows) 76-129 ms and 126 MiB against 71-104 ms and 4-39 MiB for the key read, and with no window 122-159 ms and 523 MiB against 98-200 ms and 4-44 MiB, withoptimize_aggregation_in_orderno better (161-707 ms, 86-231 MiB). The coarse filter moves fromWHEREintoHAVING, so the read groups every key in scope before theLIMITand its memory grows with the scope, not the page. The two reads stay.max_threads = 1.scripts/gates/check_no_secrets.py. It now says that only the key and token patterns do. Card numbers, SSNs and PINs are not repo-secret shapes, and the repo gate is unchanged.medium(say, an email address next to an SSN) staysmedium. The sweep cannot tell a detectedmediumfrom a caller's explicit one, and a caller's level wins, so I left that alone. security.md says so, and setting the row again withsensitivity: "high"relabels it.Compatibility, rollout and rollback
memory.set/memory.bulk_set/memory.updatewithsensitivityunset and a value holding one of these shapes now getshighormediumwhere it got''. A caller that setssensitivityexplicitly is unaffected.loom sensitivity-sweep --limitnow caps the candidates found (labelled with--apply), not the rows read, so a run reads its whole scope until that many are found, and it refuses 0 or a negative value.LOOM_SENSITIVITY_SWEEP_MAX_ROWS_PER_PASSnow also sets the sweep's page size, and the newLOOM_SENSITIVITY_SWEEP_PAGES_PER_PASScaps the pages per pass. The worker stores its cursor, an org, a namespace and an agent, inloom.worker_status. Backlog rows (older than the sweep's two-day window) are labelled byloom sensitivity-sweep --apply. During a rolling upgrade, a row written through build N-1 stays unlabelled until the daily sweep on build N labels it.highkeep their label and stay unembedded. The sweep's cursor row inloom.worker_statusstays and is not read.Tests
tests/unit/test_memory_sensitivity.py: positive and negative cases for each shape.tests/unit/test_pipeline_actor_sensitivity_gauges.py, clickhouse-local): five selected-but-unlabelled rows sit ahead of a PIN row in the same agent with a page size of two. One page finds no candidate, a scan of ten pages labels the PIN row, and the worker pass with ten pages moves past the agent after its first page, comes back to it once the rest of the window is read and labels the PIN row; with one page it leaves the cursor past the agent. A scan capped at two pages stops there and reports itself truncated. Three passes of three pages of two over seven{"spin": ...}rows ahead of a PIN row in one agent leave the PIN row unlabelled and the cursor at[]on each pass, and the operator's scan with no page cap finds it, and the CLI's dry run, with its page size lowered to two keys, reaches the PIN row behind the same rows in more than one page.loom sensitivity-sweep --limitparses 1 and refusesabc, 0 and -1, each with the message that it is not a positive integer. Pages of two rows that end inside a user, at a user boundary and at a namespace boundary return each selected row exactly once and reach the PIN row. Eighteen rows in orgacme(six epoch seconds, six epoch milliseconds and six 19-digit ids), more than a pass's two pages of two, do not keep the pass from labelling aghp_token in orgzeta, and neither do six prose rows in orgacmethat name a credential word without an assignment (I forgot my password,the secret of a good stew is time,cd $(pwd) && make). A page of three keys over six row versions holds all three keys (gone, whose current version is tombstoned;vault_door, whose current version is labelledhigh, asapplywrites it;twice, with two unlabelled versions), and theFINALread yields onlytwice, once. Three passes capped at one page of two, over two pages of{"spin": ...}rows in agentaand a PIN row in agentb: the first finds nothing in its page ofa, so its cursor is pasta; the second labels the PIN row and leaves the cursor at[]; the third starts again at the first key; every cursor holds the org, namespace and agent only. One pass of three pages of two over more than a page of{"spin": ...}rows in each of agentsaandb, ahead of a PIN row in agentc, labels the PIN row. A pass of four pages of two over three{"spin": ...}rows in each of agentsaandbmoves past both, reads the rest ofaon its last page and none ofb, and reports itself truncated. With a limit of two and three pages over[spin, PIN, PIN, PIN]under an empty user id, the first page gives one candidate and the second two, so the third is cut: the scan applies two, resumes after the second's stored key (user id'', not-), and the next scan labels the third. The pass tests write the rows a pass labels as a newhighversion in a part of their own, keeping the old unlabelled version, asapplydoes before a merge. Three passes of three pages of two over five PIN rows in one agent: the second pass's first page holds only the keys the first pass labelled and gives back no row, the pass reads on and labels the next two, and the third labels the last; the cursor stays at the agent until the last row is read. Four passes of three pages of two over six PIN rows in one agent, with the second pass failing inapply: a pass that labels rows leaves the cursor at that agent, the failed pass leaves it past the agent, and the next reaches the last row with pages left, goes back to the first key and labels the rows that failed; all six are labelled. A pass that finds a PIN row in agenta, reads on to agentdand fails to apply it leaves the cursor atd, and the next pass labels the PIN row ind. A pass with its cursor at agentband a PIN row in agentalabels the row with two pages and leaves the cursor atb; with one page it does not read it. Two passes of two pages of two over five PIN rows in agentaalready labelledhighwhose unlabelled versions stay until a merge, and a PIN row in agentb: the first pass reads both pages insidea, finds nothing and leaves the cursor pasta, and the second labels the PIN row inb. Two passes of one page of two over a{"spin": ...}row in agenta, and a{"spin": ...}row then a PIN row in agentb: the first pass's only page spansaandb, gives a row for each key and nothing to label, so its cursor stays atb, and the second labels the PIN row. The same two passes with the row in agentaalready labelledhighand its unlabelled version kept until a merge: the page's only stale key is ina, so the cursor still stays atband the second pass labels the PIN row. Three passes over more than a page of PIN rows in agentaand one in agentb, withapplyfailing on every pass: the cursor moves pasta, the next pass reaches the last row, and the third starts again at the first key. Three passes over more than a page of{"spin": ...}rows in an agent whose name does not fit the cursor, ahead of a PIN row in another namespace: the first leaves the cursor past the namespace and the second labels the PIN row. A cursor keeps the agent, decodes with the user, session and memory key emptied, names the place past the agent when asked to or when the scan stopped past it, decodes apastcursor to its columns alone, names the place past the namespace for an agent longer than the store holds, keeps a 200-character CJK agent name whose cursor fits, and reads a cursor that is not one of its forms as none. A page past agenta, on clickhouse-local, reads the next agenta\x00b. The pass tests share one helper that recordsapply's candidates.ApplyResult.failedholds each failed candidate with its error, anderrorsis read from it.sensitivity_sweep_max_rows_per_passandsensitivity_sweep_pages_per_passare on the settings ratchet's list of caps that refuse 0 (tests/unit/test_call_site_knobs.py, through the live-override path), and a pages-per-pass value of 1000 is accepted and 1001 refused. A pass whose time runs out after its first page, over two PIN rows in agentawith selected-but-unlabelled rows between them and one in agentb, applies the PIN row it found, reports itself truncated and stores its cursor ata(the test's clock moves past the pass's time after the first page'sFINALread); given the time, the same pass labels all three.sweep.scantakeslimit,page_sizeandpagesas required keywords, so a caller names its candidate cap, page size and page cap: the worker passes the settings, the CLI passes--limit, its page size andNone, and the analyzer drive passes a limit and a page of 10. ASweepCandidaterequires its sort key, whichscanresumes from. The defaults snapshot pinssensitivity_sweep_pages_per_passat 10.BADGE_PIN=4471,atm_pin: 4471,PIN_CODE=4471,CARD_CVV=123,security_code: 5512,cvv code: 123,CVV number is 123,cvc code 123,pass code: 4471,PIN for the front door is 4471andpasscode for the garage: 908712. Negatives:spin: 4471,PIN for the front door 4471,PIN for one two three four is 4471, and the versions and dates above.EUR, and one after an IBAN-shaped token.pinas a verb and as a connector pin (pin 115,pin #115), a 6-digit Indian PIN code (PIN: 560001,PIN code 560001, also not selected by the sweep's filter), fullwidth digits, a valid spaced IBAN whose groups read as a Luhn-valid Visa number (medium), an IBAN failing mod-97, and two mod-97-valid tokens, one with an unregistered country code (XY54 ...) and one with the wrong length for its country (a 20-characterDE86 ...).medium, including a 13-digit+49number, the same number written without its+, and epoch milliseconds.{"cvv_code": "123"},{"cvcNumber": "987"},{"ssn_number": "123456789"},{"ssn_no": "123-45-6789"},{"social_security_number": "123-45-6789"},{"pin": "4471"},{"pin_code": "4471"},{"pin__code": "4471"},{"pin/code": "4471"},{"pincode": "4471"},{"badge_pin": "4471"},{"badgePin": 9087},{"pin_number": "4471"},{"pinNumber": "908712"},{"PIN": "4471"},{"CVV2": "123"},{"cvv_2": "123"},{"pass_code": "4471"}, a nestedsecurity-code,{"ssn": "123-45-6789"},{"ssn": "123456789"}, a card under any key, and a connector pin{"pin": 115}arehigh. These are not:{"pin": "560001"},{"zip_pin": "560001"},{"address": {"pincode": "560001"}},{"pin_count": 4},{"pin": "A1"},{"pin": "12"},{"pin": true},{"spin": "4471"}, an SSN in a never-issued range, and a Luhn-failing or shortpan.reads_highon raw chunk text (human_text) reads{"badge_pin": "4471"}and{"ssn": 123456789}as high, and{"pin_count": 4471},{"pin": "560001"},{"pin": "4471abc"},{"pin": 4471.5}and a 20-digitpinas not.lowrow whose value reads as high is left out byobserve_extract, by the profile fold (tests/unit/test_profile_consolidation.py) and by the structured profile build (tests/unit/test_profile_schema.py).{"security.code": "5512"}is pinned as selected and labelledhighby the sweep: ClickHouse stores it as{"security":{"code":"5512"}}invalue_json, and the sweep also readsvalue, which keeps the key whole.credentialfilter alone, the part of the scheduled pass's filter that selects high rows. The other superset tests (new shapes, stored JSON text, clickhouse-local) check every high case against that filter too and keep the full filter formediumcases.match()runs on thejson.dumpstext and ontoString(CAST(... AS JSON))for 56 object values (ATMPin,SpinandATMPINamong them,spinandunpinas negatives,cvvcode,ssnno,securitycodeandPINcodeas positives,{'pin"': ...},{"door\\pin": ...},"pin\n",p_inas a negative,"CVV:","pin ","SSN:","Security Code (CVV)",{"pin": " 4471"},pass_code,cvv_2,cvv_code,pin_code,pin__code,pin/code,pincode,ssn_no,social_security_number,{"pin": "\t4471"},BADGE_PIN=4471andPIN for the front door is 4471among them, and the postal codes{"pin": "560001"}and{"address": {"pincode": "560001"}}as negatives) and on the raw text of 22 strings (CARD_CVV=123,atm_pin: 4471andcvv number is 123among them). Both lists hold credential-word assignments (db password: Tr0ub4dor&3xyz,client_secret = 9f8e7d6c5b4a3210ffee,{"note": "deploy:\npassword=hunter2222"},{"note": "api_key = abcdefgh12345678"}) and lone card numbers (mastercard 5500000000000004,amex 378282246310005,{"card": 4111111111111111}, and lone and grouped cards after番号, a no-break space and an ideographic space), so the assignment alternative's Unicode whitespace class and the lone-card alternative are checked in RE2 with the class bound as a parameter. Every fake credential is also checked against thecredentialfilter, as written and asjson.dumpstext. The objects include keyed PINs and SSNs, a dottedbadge.pin, a\u000B, curly quotes, a\/, a\na grouped 19-digit Visa, and phone numbers grouped by\nand by no-break spaces. Every case the detector labels is selected. The unlabelled cases it selects are pinned as exactly{"spin": ...},{"unpin": ...},{"Spin": ...}and{"ATMPIN": ...}; the other unlabelled ones ({"pin_count": 4},{"pin": "A1"},pin 128 rows,GPIO pin 115,SHA256SUMS, the postal codes) are not selected.pin,PIN isorcvv, and 200,000 spaces after"pin":or"pin": "in raw JSON text, and afterPIN fororPIN for the. So do 20,000 IBANs in one value. Escaped quotes are timed on their own, at 5,000 and 20,000, the sizes that took 0.45 s and 7.17 s before the key bound. The test (test_long_runs_are_read_in_linear_time) times each group at a quarter of its size and at its full size, the fastest of three reads each, and asserts the full size takes less than 8 times as long: a linear read grows about 4 times and a quadratic one 16 times, so a slow runner does not fail it.\n,\f,\b,\u000band\u201cescapes. It does not select a barepinorpasscodeword,pin 128 rows,GPIO pin 115orSHA256SUMS.highrows carry thecredentialprobe shape, and an IBAN or bank-account question, plural or not, counts as contact intent.tests/integration/test_sensitivity_high_canary.py: a PIN, a card, an SSN and an object with abadge_pinkey written bymemory.setread back ashighwith no embedding row and no search hit. An IBAN reads back asmediumand is embedded. On read-back the test compares the value, level, tags,memory_type,agent,actor,source_class,expires_at,on_expire,expire_reason,pinned,statusandlock_modeagainst the expected row, and reads the stored row's identity tuple (org,namespace,agent,user_id,session_id) from ClickHouse. The test also writes a plain row afterwards and waits until it is embedded, so the "no embedding row" check runs after the labelled row's embedding would have landed.make formatandmake lintpass and every generator is current. CI runsmake typecheck, the unit suite (the clickhouse-local tests included) and the integration suite; none of them has run on this head yet.make format lint typecheckwas clean and the sensitivity, sweep, CLI, package-contract, public-copy and doc-link unit tests passed; at 4c02c2f,make test-unitpassed (tests/unit 21469 passed, 20 skipped, 1 xfailed; bench 191 passed) andtests/integration/test_sensitivity_high_canary.pypassed against a local server and ClickHouse (13 passed). The key read, the prose and card prefilter tests and theFINALread test came after those heads.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. The patterns, the Luhn and mod-97 checks and the coarse filter were checked against the cases above and against ClickHouse
match().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. (make formatandmake lintpass on this head; CI runs the others.)docs/reference/configuration.mdand 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