Skip to content

feat(profiling): the read API — a profile over HTTP, with its values gated (PR E) - #426

Merged
athvin merged 1 commit into
mainfrom
bm/profile-p5-read-api
Nov 5, 2026
Merged

athvin merged 1 commit into
mainfrom
bm/profile-p5-read-api

Conversation

@athvin

@athvin athvin commented Nov 3, 2026 •

Copy link
Copy Markdown
Owner

Two routes over the profile a job already writes:

GET  /v1/orgs/{org}/datasets/{ds}/profile?subject=&source=&tier=   viewer
POST /v1/orgs/{org}/datasets/{ds}/profile                          steward -> 202 + job id

The GET answers {"profiled": false} rather than 404 for a corpus nobody has profiled, on quality's precedent: the dataset exists and the question is fair, the answer is just "not yet".

The value gate covers five fields, not one

A profile is statistics — except where it is not. top_values is a column's most frequent real values; lex_min/lex_max are the lexically smallest and largest; num_min/num_max the numeric extremes. On an email column those are real addresses; on a salary column, one person's pay.

This gate first shipped covering top_values alone, and said so in three places — the handler's doc comment, the read's doc comment, and the statement's description — each calling it "the one field in a profile that carries personal data". It was not. The other four went to every viewer, and nothing failed, because the failure mode of a value reaching the wire is silence.

So the classification is no longer prose:

  • VALUE_BEARING_COLUMN_FIELDS and DERIVED_COLUMN_FIELDS are exhaustive, and DERIVED is listed out rather than inferred as "everything else" — a column added to the entity lands in NEITHER list and fails the gate test. That is the point: the failure asks a question that has to be answered.
  • The test reads entities/column_profile/entity.yaml as embedded in the binary, so it sees a new column without anyone remembering to tell it.
  • Membership is "could a reader recover a datum", not the column's type: num_max is a number and is gated, num_avg is a number and is not, because an average over many rows is nobody's value. Drawing the line at verbatim-or-not keeps it one sentence; drawing it at which types feel sensitive is how lex_min was missed.

Values are nulled in place, never removed, so the response shape does not depend on who asked — a consumer renders — for a null it expected and throws on a key that vanished. top_values keeps its counts, shares and ranks and loses only each entry's value: that the top value covers 3.1% of rows is the point of a skew finding, and which value it is adds nothing to it.

Steward is the bar because a steward can already read records. It is not a bar a viewer routes around: GET …/records takes explicit keys, capped at 50, and will not enumerate — so a column's most frequent values are not otherwise reachable by someone who cannot already name the rows they want.

Candidate keys reach the wire

PR D measured what each column would cost as a blocking key and persisted the ranking; nothing could read it. That was a gap this PR split created, and a profile screen without it would omit the most actionable thing in the profile.

candidate_key/read/for_run projects it cheapest-first — ORDER BY expected_pairs is the ranking, so a reader takes the top row rather than re-deriving which key is most selective.

key_columns is stored chr(31)-joined because the lake has no list type; it is split back into an array at the handler so no consumer has to know that, and so a composite key renders as two names rather than one string with a control character in it. Nothing in a candidate key is a value — a key is named by column names and described by counts — so unlike the column shapes it needs no gating.

Verification

  • er-entity verify: 17 lint rules over 48 entities, no errors; 132 generated files current; every statement plans and passes the E0xx rules, the new read included.
  • The gate test observed failing: unclassifying one field reports column_profile gained 'entropy_bits' and nothing says whether it echoes a stored value, and exits 101.
  • Three unit tests over the redaction: a steward's row is byte-identical to the input; a viewer's contains none of the three planted addresses anywhere in its serialized form (an assertion that does not depend on knowing which field holds one); every derived statistic and the whole distribution shape survive.
  • cargo clippy -p er-server --all-targets -- -D warnings clean; cargo fmt --all --check clean.
  • er-mcp/tools.json and envelopes.json regenerated for the two new routes; needs_body: false on the POST is correct — it means "takes a body this manifest could not describe", and mine is described.

🤖 Generated with Claude Code

@athvin
athvin force-pushed the bm/profile-p5-read-api branch 2 times, most recently from 119c31e to e0dba23 Compare November 3, 2026 04:42
@athvin
athvin force-pushed the bm/profile-p5-read-api branch 6 times, most recently from 5a3fc94 to c742876 Compare November 5, 2026 01:56
…gated (PR E)

Two routes over the profile a job already writes:

    GET  /v1/orgs/{org}/datasets/{ds}/profile?subject=&source=&tier=   viewer
    POST /v1/orgs/{org}/datasets/{ds}/profile                          steward -> 202

The GET answers `{"profiled": false}` rather than 404 for a corpus nobody has
profiled, on `quality`'s precedent: the dataset exists and the question is fair,
the answer is just "not yet".

A profile is statistics — except where it is not. `top_values` is a column's
most frequent REAL values; `lex_min`/`lex_max` are the lexically smallest and
largest; `num_min`/`num_max` the numeric extremes. On an email column those are
real addresses; on a salary column, one person's pay.

This gate first shipped covering `top_values` alone, and said so in three
places — the handler's doc comment, the read's doc comment, and the statement's
description — each calling it "the one field in a profile that carries personal
data". It was not. The other four went to every viewer, and nothing failed,
because the failure mode of a value reaching the wire is **silence**.

So the classification is no longer prose:

- `VALUE_BEARING_COLUMN_FIELDS` and `DERIVED_COLUMN_FIELDS` are exhaustive,
  and `DERIVED` is listed out rather than inferred as "everything else" —
  a column added to the entity lands in NEITHER list and fails the gate test,
  which is the point: the failure asks a question that has to be answered.
- The test reads `entities/column_profile/entity.yaml` as embedded in the
  binary, so it sees a new column without anyone remembering to tell it.
- Membership is "could a reader recover a datum", not the column's type:
  `num_max` is a number and is gated, `num_avg` is a number and is not, because
  an average over many rows is nobody's value. Drawing the line at
  verbatim-or-not keeps it one sentence; drawing it at which types feel
  sensitive is how `lex_min` was missed.

Values are **nulled in place, never removed**, so the response shape does not
depend on who asked — a consumer renders "—" for a null it expected and throws
on a key that vanished. `top_values` keeps its counts, shares and ranks and
loses only each entry's value: that the top value covers 3.1% of rows is the
point of a skew finding, and which value it is adds nothing to it.

Steward is the bar because a steward can already read records. It is not a bar
a viewer routes around: `GET …/records` takes explicit keys, capped at 50, and
will not enumerate — so a column's most frequent values are not otherwise
reachable by someone who cannot already name the rows they want.

PR D measured what each column would cost as a blocking key and persisted the
ranking; nothing could read it. That was a gap this PR split created, and a
profile screen without it would omit the most actionable thing in the profile.
`candidate_key/read/for_run` projects it cheapest-first — `ORDER BY
expected_pairs` IS the ranking, so a reader takes the top row rather than
re-deriving which key is most selective.

`key_columns` is stored chr(31)-joined because the lake has no list type; it is
split back into an array at the handler so no consumer has to know that, and so
a composite key renders as two names rather than one string with a control
character in it. Nothing in a candidate key is a value — a key is named by
COLUMN names and described by counts — so unlike the column shapes it needs no
gating.

- `er-entity verify`: 17 lint rules over 48 entities, no errors; 132 generated
  files current; every statement plans and passes the E0xx rules, the new read
  included.
- The gate test **observed failing**: unclassifying one field reports
  `column_profile gained 'entropy_bits' and nothing says whether it echoes a
  stored value`, and exits 101.
- Three unit tests over the redaction: a steward's row is byte-identical to the
  input; a viewer's contains none of the three planted addresses anywhere in
  its serialized form (an assertion that does not depend on knowing which field
  holds one); every derived statistic and the whole distribution shape survive.
- `cargo clippy -p er-server --all-targets -- -D warnings` clean; `cargo fmt
  --all --check` clean.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@athvin
athvin force-pushed the bm/profile-p5-read-api branch from c742876 to 8165b83 Compare November 5, 2026 02:26
@athvin
athvin merged commit 4e7e920 into main Nov 5, 2026
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants