Repository navigation
test(obs): the PII boundary on spans, enforced rather than documented (telemetry P14) - #454
Merged
Merged
Conversation
… (P14) This is a deduplication engine, so names, emails, phones and addresses ARE the payload, and §10.4's rule is that telemetry carries identifiers and counts and never attribute values. #429 made that boundary matter more: spans now leave the process over OTLP, so it is an exportable store rather than in-account Postgres. The real guarantee is structural and already shipped — `er_span::sql_span` takes no parameter argument, so there is nowhere to put a bind value. These are the shape gates around it, because that property only holds while the call stays where it is: 1. only GENERATED code may call `sql_span` (244 sites, all in er-entities); product code calls `generator_span`, which has no `sql` parameter at all. `er-span` and `er-sql-check/src/emit.rs` are allowlisted with reasons — the latter WRITES those calls as string literals rather than making them. 2. every emitted `sql_span` argument is a string literal, `SQL`, or a `Store` discriminant, so none can carry a runtime value. 3. the names `er-span` declares `Pii::Never` appear nowhere in code. Each test also asserts a floor on what it examined (>60 files, >20 generated callers, >200 statements), so a moved crate tree fails here rather than passing having looked at nothing — the false-green shape this repo keeps being bitten by. The forbidden list is READ OUT of er-span/src/attr.rs rather than restated. A hardcoded copy is how a registry and its enforcement drift apart, which er-entity-lint's own header records as how three documented codes ended up never implemented. ## Two things the gate taught me while being written Its first version failed on `er-server/src/telemetry.rs` — whose comment says `url.query` is deliberately NOT recorded. A file explaining the rule was being reported as breaking it. Writing down why an attribute is forbidden is exactly the behaviour to encourage, so prose is now exempt and only code counts. And the comment stripper's limitation runs the UNSAFE way, so it says so: it does not understand string literals, so a `//` inside one strips the rest of that line and a forbidden name after it would be MISSED. A false negative, not a false positive. Accepted because the structural guarantee does not depend on this scan; if it ever does, this wants to be a real lint. Both gates observed failing on injected violations before being trusted. `make check` passes. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
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.
This is a deduplication engine, so names, emails, phones and addresses are the payload, and §10.4's rule is that telemetry carries identifiers and counts and never attribute values. #429 made that boundary matter more: spans now leave the process over OTLP, so it is an exportable store rather than in-account Postgres.
The real guarantee is structural and already shipped —
er_span::sql_spantakes no parameter argument, so there is nowhere to put a bind value. These are the shape gates around it, because that property only holds while the call stays where it is.only_generated_code_calls_sql_span@generatedfiles; product code must usegenerator_span, which has nosqlparameter at allevery_emitted_sql_span_argument_is_a_literalSQL, or aStorediscriminant — never a runtime valueforbidden_attribute_names_are_never_recordeder-spandeclaresPii::Neverappear nowhere in codeer-spanander-sql-check/src/emit.rsare allowlisted with reasons — the latter writes those calls as string literals rather than making them.Each test also asserts a floor on what it examined (>60 files, >20 generated callers, >200 statements), so a moved crate tree fails here rather than passing having looked at nothing — the false-green shape this repo keeps being bitten by.
The forbidden list is read out of
er-span/src/attr.rsrather than restated. A hardcoded copy is how a registry and its enforcement drift apart, whicher-entity-lint's own header records as how three documented codes ended up never implemented.Two things the gate taught me while being written
Its first version failed on
er-server/src/telemetry.rs— whose comment saysurl.queryis deliberately not recorded. A file explaining the rule was being reported as breaking it. Writing down why an attribute is forbidden is exactly the behaviour to encourage, so prose is now exempt and only code counts.The comment stripper's limitation runs the unsafe way, so it says so. It does not understand string literals, so a
//inside one strips the rest of that line and a forbidden name after it on the same line would be missed — a false negative, not a false positive. Accepted because the structural guarantee does not depend on this scan at all; if that ever stops being true, this wants to become a real lint rather than a slightly better regex.What this deliberately does not do
The plan's "declared statements are literal-free" check is not here, and the reason is worth recording rather than leaving as a silent omission:
''escapes, reporting the text between two literals as a literal.E010already validates literals against accepted-values (enum) columns, so the genuinely uncovered risk is a literal against a payload column likeemail.Verification
Both gates observed failing on injected violations before being trusted — a
sql_spancall added to product code, and aurl.queryconst — then restored green.make checkpasses.🤖 Generated with Claude Code