AIによる翻訳。英語版は人による検証済みである。 原文を読む
教材キット
2026.11.36版(書籍の現行版)より。書籍が更新されると変わる。出典を明記すれば、自由に利用および改変できる。
シラバス
読書時間は章の本文に基づく。学習者はLabまたは自分のマシンでコード例も実行する。
週ごとに一章: 10 週
| 週 | 章 | 読書 | 例 |
|---|---|---|---|
| 1 | 1. エンドツーエンドのガバナンス | 58分 | 6 |
| 2 | 2. テストできるカタログ | 77分 | 12 |
| 3 | 3. 個人データの発見 | 89分 | 12 |
| 4 | 4. Lineage from pipelines | 78分 | 12 |
| 5 | 5. Access policies as code | 74分 | 13 |
| 6 | 6. クエリへのポリシー適用 | 75分 | 16 |
| 7 | 7. 保持期間、同意、消去 | 81分 | 11 |
| 8 | 8. 監査と証跡 | 67分 | 9 |
| 9 | 9. AIのためのデータガバナンス | 89分 | 11 |
| 10 | 10. Governance in CI | 79分 | 10 |
5 週間後
| 週 | 章 | 読書 | 例 |
|---|---|---|---|
| 1 | 1. エンドツーエンドのガバナンス 2. テストできるカタログ | 135分 | 18 |
| 2 | 3. 個人データの発見 4. Lineage from pipelines | 167分 | 24 |
| 3 | 5. Access policies as code 6. クエリへのポリシー適用 | 149分 | 29 |
| 4 | 7. 保持期間、同意、消去 8. 監査と証跡 | 148分 | 20 |
| 5 | 9. AIのためのデータガバナンス 10. Governance in CI | 168分 | 21 |
学習目標と概要
各章の学習目標はその冒頭の一文である。各構成案は章の節に従い、定義される用語、例を実行する前に求められる予測、各節が締めくくる規則を含む。 主要な用語と確認すべき予測は、クイズバンクが出題するとおり英語版のものである。
1. エンドツーエンドのガバナンス
読了まで約58分。6 例。
この章を終えると、データプラットフォームの 1 つのテーブルを、コードによってエンドツーエンドでガバナンスできるようになる。
講義概要: 8 節
-
テーブルを所有者と分類つきでカタログ化する
- 実行
catalog-the-learners.py - 実践ルール 所有者、ドメイン、説明、分類は、レビューを経る一つのファイルとしてリポジトリに置く。すべてのテーブルの所有者はチームとし、すべての列には閉じた一覧から選んだ分類を一つ付ける。説明はカタログにも書き込み、テーブルを読む誰もが目にできるようにする。カタログをファイルと照合するテストは、ファイルではなくカタログをたどって行う。編集がカタログのウェブページで行われる場合は、どちらか一方を正とし、もう一方をそこから生成する(第2章)。
- 実行
-
Capture one pipeline's column lineage
- 実行
audience-pipeline-lineage.py - 実践ルール Emit lineage from the code that runs each job, never after it (chapter 4): a START event, then a COMPLETE or FAIL event, with the output's column lineage in the COMPLETE event, parsed from the job's SQL, and the inputs that join and filter rows as well as those that supply values. Read lineage back from the events, never from the SQL, so the graph shows what ran. Where a job isn't SQL that a parser can read, such as a Python script, write its lineage in the same code, and review the two together.
- 実行
-
Enforce one access decision on a query
- 実行
support-region-enforced.py - 実践ルール Write access rules as one policy in the repository that denies by default and returns its decision as data: allow, row filters and column masks. Apply that decision in one layer that rewrites every query before the engine runs it, and give users that layer's answers, never the engine's connection. When an engine can ask the policy itself, as Trino can ask OPA, let the engine be that layer.
- 実行
-
Fail the pull request that adds an unclassified column
- 実行
unclassified-column-fails.py - 実践ルール Run every governance check as one job on every pull request, required by branch protection, and fail it by exit code on any finding the pull request introduces. Report the findings already on the main branch with their owners, without failing the pull request for them. Put every finding in the pull request itself, under an ID that stays the same from run to run, with what to do about it. Run the same checks on a schedule against the production catalog too, for what changes outside pull requests.
- 実行
- 本番環境で何がうまくいかなくなるか
-
誰も更新しないガバナンス用スプレッドシート
- 実行
spreadsheet-misses-new-column.py - 実践ルール ガバナンス用のメタデータを、何も検査しない文書に置いてはならない。レビューを経たファイルに置き、プルリクエストごとと定期スケジュールで、テストによってそのファイルを稼働中のカタログと比較する。スプレッドシートが必要な場合は、そのファイルから生成し、生成した日時をスプレッドシート上に明記する。
- 実行
-
一つのツールが適用し、別のツールが迂回するポリシー
- 実行
read-around-the-layer.py - 実践ルール ポリシーを適用する場所を一つ選ぶ。それはすべてのツールがクエリを発行する際に経由するエンジンである。ストレージの認証情報は、そのエンジンとテーブルに書き込むジョブにだけ与え、人やノートブックには与えない。その場所では、カタログテーブルを通さずにデータを読むクエリをすべて拒否する。テーブルを保護済みと数える前に、そのファイルを読めるものをすべて列挙する。ポリシーに問い合わせないリーダーは、迂回経路として扱う。ただし、出力がカタログに登録され、読み取り元のテーブルと同じように分類されるジョブは除く。
- 実行
- この章で決めたこと
2. テストできるカタログ
読了まで約77分。12 例。
この章を終えると、カタログのメタデータをコードとして管理できるようになる。
講義概要: 12 節
-
Keep the metadata in a reviewed file
- 重要用語 metadata
- 実行
metadata-model.py - 実践ルール Keep owners, domains, descriptions and classifications in a file in the repository, reviewed like the pipelines. Use a closed list of classifications, ordered by how much protection each needs, and one owning team per table. If your organization edits metadata in a catalog server's web page, make one side the source and generate the other from it; two sources that both accept edits drift apart.
-
列のメタデータはフィールド ID をキーにする
- 実行
rename-orphans-name-keys.py - 実践ルール 列のメタデータはフィールド ID をキーにし、人が読むために名前を隣に添える。名前が一致しなくなった場合は、新しい列とみなすのではなく、その列の説明を見直す契機として扱う。列を名前でしか知らないシステムでは、名前をキーにしたビューを ID をキーにしたファイルから生成し、手作業で保守してはならない。
- 実行
- テーブルのスキーマに説明を書き込む
-
A description edit is a schema change
- 実行
doc-edit-schema-id.py - 実践ルール Write column descriptions into Iceberg's
doc, so every reader of the table gets them, and keep classifications in the reviewed file. Put no more than an owner and a domain in table properties, and say in your code why. To decide whether a schema change needs a review, compare field IDs, names and types, never schema IDs.
- 実行
-
Test the catalog against the metadata
- 実行
metadata-gaps.py - 実践ルール Walk the catalog, not the metadata file, so a table nobody described shows up. Fail the test on any table without an owner and any column without one of the four classifications, and never default a missing classification to anything but the most protected value. A pipeline that creates a table ships with that table's metadata, in the same pull request.
- 実行
-
Catch schema changes before the metadata goes stale
- 実行
schema-changes-checked.py - 実践ルール Run both checks on every schema change:
problemsfor columns nobody has classified or renamed ones nobody has re-read, anddroppedfor entries that describe nothing. Remove a dropped column's entry in the same pull request that drops it. Dropping a personal column doesn't remove its values, which time travel reads until the snapshots that hold them expire and their files are deleted. Never drop and re-add a column to rename it: rename it in place, so it keeps its field ID and its data.
- 実行
-
Classify pseudonymous IDs for joining
- 実行
pseudonymous-learner-id.py - 実践ルール Classify a pseudonymous ID by what its own table reveals, so the joins your analysts need keep working, and say in its description what it resolves through. Protect the table that resolves it, and include the ID in every erasure. Who can resolve the ID is an access decision: list the users who may read both the ID and the resolving table's personal columns unmasked, and grant that pair only to those whose job is linking rows to people.
- 実行
- ローカルモデルによるメタデータの下書き
-
プロンプト中の例は答えを漏らすことがある
- 実行
suggestions-with-platform-examples.py - 実践ルール モデルでメタデータの草案を作るのは、送信してよい入力に限り、できれば自分たちの計算機上のモデルを使う。各回答は、モデル、そのリビジョン、プロンプト、設定とともに記録し、レビュー担当者が各草案を何が生成したかを確認できるようにする。そして、どの回答も、読み取られる前に構文解析と検証を行う。プロンプトの例は、測定対象のテーブルの外から取る。レビュー済みメタデータとの一致率は、分類ごとに報告し、単一の数値で報告してはならない。
- 実行
-
Measure where the model's drafts are wrong
- 実行
suggestion-mistakes.py - 実行
figure-model-against-review.py - 実行
suggestion-descriptions.py - 実践ルール Let a model raise a column's classification, never lower it: only a reviewer lowers one, in the pull request, with the reason in the column's description. Treat the model's descriptions as first drafts for someone who knows the column to rewrite. Before a model drafts metadata for tables nobody has reviewed, measure it against your reviewed metadata, per classification and per direction of error, and measure again whenever the model or the prompt changes.
- 実行
- 本番環境で何がうまくいかなくなるか
- この章で決めたこと
3. 個人データの発見
読了まで約89分。12 例。
この章を終えるころには、データプラットフォーム上の個人データを自動的に見つけ、見逃した割合を示せるようになる。
講義概要: 13 節
-
スキーマから列を分類する
- 実行
column-name-rules.py - 実践ルール 無料であるため、まず名前の規則をすべての列に適用する。規則は分類を引き上げるためにのみ使い、引き下げてはならない。規則は短く保ち、コードとして管理し、他の規則と同様にレビューする。名前にかかわらず、自由記述テキストの列はすべて、値のサンプリングが必要なものとして扱う。他の型の列は名前だけで分類する。
- 実行
-
Run Presidio offline
- 実行
presidio-offline-engine.py - 実践ルール Configure Presidio's engine explicitly:
NoOpNlpEnginewhen you run patterns only, or a pinned model you install yourself when you need its names. Never callAnalyzerEngine()bare in a pipeline, and pin anything a recognizer would download, such as the Public Suffix List. Read each score as a constant set for its pattern, never as a probability.
- 実行
-
列の値を毎回同じ方法でサンプリングする
- 実行
seeded-column-sample.py - 実践ルール NULL でない値を、固定したシードで、単一スレッドでサンプリングし、シードを結果とともに保存する。サンプルの大きさは、検出しなければならない最も稀な個人データから決め、99% では n = ln(0.01) / ln(1 − p) を用いる。プラットフォームはテキスト列ごとに 200 個の値をサンプリングする。この値は
governance/pii.tomlで設定され、1 in 43 以上の値が保持する個人データを 99% の確率で捕捉する。それより稀なものについては、列全体を走査するか、ルールで分類する。
- 実行
-
値から列を分類する
- 実行
classify-sampled-columns.py - 実践ルール 名前またはサンプリングした値のいずれかが裏付ける最も厳格な分類を、
internalを下限として提案し、提案と併せて証拠を示す。レビュー済みメタデータより厳格な提案は、テーブルの所有者に対する指摘事項であり、所有者は分類を引き上げるか、引き上げない理由を記録する。検出器に分類を引き下げさせてはならない。OpenMetadata は、すでに PII タグが付いている列をスキップする。しかし、検査の対象はレビュー済みのタグそのものであるため、実行のたびにすべてのテキスト列をサンプリングすることを推奨する。
- 実行
-
Measure a detector against labelled spans
- 実行
measure-pattern-recognizers.py - 実践ルール Measure every detector against labelled spans before it masks anything: recall per entity type by exact and by overlap matching, both with a label of the right type, coverage whatever the label, precision per label, and the share of texts with nothing personal left. Weigh recall first. Before you trust a detector on your text, label a few hundred real records by hand and measure on those too.
- 実行
-
認識器を正解データに照らして調整する
- 実行
tune-pattern-recognizers.py - 実行
figure-detection-scores.py - 実践ルール Presidio の既定の閾値 0 や、すべての認識器に共通の単一の閾値で運用してはならない。テキストに含まれうる識別子の認識器だけを保持し、各認識器の閾値をそれ自身のスコアから決め、電話番号はデータから導いた利用者の居住地域で読み取る。そのすべてをコードに記述し、変更のたびに測定し直す。
- 実行
-
See where patterns fail
- 実行
pattern-hard-cases.py - 実践ルール Read a detector's misses by case, not by total, and keep a list of the cases your text holds. Use patterns for what has a checkable shape, such as emails, IBANs, card numbers, phone numbers and dates, and never for names or addresses. Keep the checksums and numbering plans, because they're what makes the patterns precise. Check the card pattern against the card numbers your payment provider issues, and the date patterns against the ways your users write dates.
- 実行
- Compare a PII model
-
Read the model's misses
- 実行
privacy-filter-hard-cases.py - 実践ルール Mask free text with a PII model and the tuned patterns together, whatever either finds: the model for names and addresses, the patterns' checksums for card numbers and IBANs. Record the model's output with its revision, weights and operating point pinned, keep its own labels, and map them in code. Measure it on your own text, by hard case, before use and after every model change; if it misses too much, try an operating point that leans toward recall and record again. Treat masked text as reduced, never as anonymous.
- 実行
-
Count what a wrong label costs
- 実行
privacy-filter-labels.py - 実践ルール Report coverage, whatever the label, beside recall with the right label: masking needs the first, classification the second. Read which labels a detector gives each type of span, and keep a recognizer with a checksum for every identifier whose label decides a classification, such as card numbers.
- 実行
-
Classify again when the schema changes
- 実行
reclassify-new-columns.py - 実践ルール Classify every field ID the metadata doesn't have, in the pull request that adds it, and don't let it merge without a reviewed classification. Key the trigger on field IDs, never on schema IDs. Sample every text column again on a schedule too, because values change without a schema change.
- 実行
- What goes wrong in production
- What this chapter decided
4. Lineage from pipelines
読了まで約78分。12 例。
学習の終わりには、capture lineage from your pipelines as OpenLineage run events, with column lineage parsed from their SQL, including the columns that only join, filter and groupできるようになる。
講義概要: 11 節
-
Send a run event from every pipeline
- 重要用語 job, run, dataset, facet
- 実行
pipeline-run-events.py - 実践ルール Send a START and then a COMPLETE or FAIL event from the code that runs each job, so no run can happen without them, and name datasets by catalog identifiers under a namespace you choose, never a path. In tests, use the file transport with a fixed event time and static run IDs, and compare what events say, never their bytes. In production, send through a transport to your lineage server, and derive each run ID from the scheduled time, the job and the attempt, so a resent event never creates a duplicate run.
-
各出力列をその元の列までたどる
- 実行
sqlglot-misses-row-inputs.py - 実践ルール 各出力の値が計算される元の列を求めるには、sqlglot の
lineageを使う。このとき、常にカタログのスキーマを渡す。スキーマはテーブルのメタデータから生成したものとし、手で入力してはならない。その答えを、列が依存するすべてとして読んではならない。結合、フィルタ、グループ化に使われる列は漏れており、入力のうちどれが値であるかも示されない。
- 実行
-
Add the inputs that decide which rows exist
- 実行
indirect-column-lineage.py - 実践ルール Record INDIRECT inputs with every job's column lineage: the join keys, filters and grouping columns of every
SELECT, CTEs included, in the facet'sdatasetlist, and type each value input with OpenLineage's subtypes. Expect more edges, many of them join keys. Keep them anyway: a filter on a consent column decides who may be emailed, and it reaches the table only as an INDIRECT input.
- 実行
-
Fail on statements the parser can't read
- 実行
insert-and-merge-lineage.py - 実行
misspelt-column-lineage.py - 実践ルール Treat a statement your parser can't read correctly as an error, never as empty or partial lineage. Refuse every kind of statement it gets wrong, such as
MERGE, before you ask it, and fail on empty lineage, a source the parser can't place and a column the schema doesn't have. Match anINSERT's columns by position against the table's columns in the catalog, never theSELECT's names, and fail when the counts differ. For aMERGE, write aSELECTof the columns it writes, and record the job's lineage from that, as anINSERT ... SELECTinto theMERGE's table, until your parser handlesMERGEitself.
- 実行
-
カラムの変更が何を壊すかを調べる
- 実行
column-impact.py - 実行
figure-category-reach.py - 実践ルール イベントから構築したグラフ上で、INDIRECT エッジを含めて影響分析を実行し、2 つのリストを報告する。値が変わりうるカラムと、行が変わりうるテーブルである。フィルタと結合にのみ使われるカラムの変更は、それがフィルタするテーブルのすべてのカラムの変更として扱い、報告は到達したテーブルそれぞれの所有者に送る。
- 実行
-
Propose classifications from lineage
- 実行
propagate-classifications.py - 実行
personal-filter-propagates.py - 実践ルール Propose each derived column's classification as the stricter of its inputs', counting INDIRECT inputs, and send the proposals to the table's owner for review before they become metadata. Never let lineage lower a classification someone declared, and never treat masking as declassification. Count DIRECT inputs only if your pipelines often join or filter on personal columns, such as matching on email, and every output would otherwise come out personal; then review INDIRECT personal inputs by hand.
- 実行
- 本番環境で何が問題になるか
-
Events that never arrive
- 実行
lineage-disabled-silently.py - 実践ルール After every scheduled run, compare the jobs that ran with the jobs whose COMPLETE events arrived, and alert on any difference. Don't rely on the emitter to report its own silence.
- 実行
-
誰も計装しなかったジョブ
- 実行
uninstrumented-job.py - 実践ルール カタログとリネージの照合を定期的に実行し、どのジョブのリネージでも説明できないテーブルはインシデントとして扱うこと。該当するジョブを特定し、イベントを送信させる。
- 実行
-
Personal data in a table classified internal
- 実行
personal-copy-tagged-internal.py - 実践ルール Run
lib.lineage.understated, or your own check like it, on every lineage update, and fail when a declared classification is lower than lineage proposes. Classify by what a table holds, never by who reads it, and fix such a finding by raising the classification, not by dropping the edge.
- 実行
- この章で決めたこと
5. Access policies as code
読了まで約74分。13 例。
学習の終わりには、write a data platform's access rules as one policy that denies by default and returns row filters and column masks as dataできるようになる。
講義概要: 11 節
-
リクエストの形を Trino に合わせる
- 実行
trino-shaped-request.py - 実践ルール ポリシーの入力は、それを実施するエンジンのリクエストにフィールド単位で合わせ、そのエンジンが送れないものだけを、レビュー担当者の目に入る最上位に追加する。使用するエンジンが Trino でなければ、そのエンジンのリクエスト形式から出発する。また、
lib.policy.requestと同様に、形を1つの関数にまとめておき、テストと呼び出し側がずれないようにする。
- 実行
-
ポリシーが読むデータを生成する
- 実行
generated-policy-data.py - 実践ルール ポリシーのデータは、ポリシーを読み込むたびに、各事実を所有するファイルまたはテーブルから生成する。事実をポリシーや別のファイルにコピーしてはならない。サポート担当者のリージョンのように、事実にまだ所有者がいない場合は、プラットフォームが
users.tomlで行っているように、コードと同様にレビューされる 1 つのファイルをその所有者とする。
- 実行
-
既定で拒否し、ロールで許可する
- 実行
allow-by-role.py - 実践ルール すべてのポリシーを
default allow := falseで始め、ロールとリソースを名指しする規則を通してのみ許可する。ロールからテーブルへのマップは一か所にまとめ、レビュー担当者が一度にすべてを読めるようにし、すべての判定に理由を付ける。許可されるべきリクエストが拒否された場合は、それを許可する規則を追加する。デフォルトを弱めてはならない。
- 実行
-
Narrow by attribute: region, consent and purpose
- 重要用語 region, purpose
- 実行
attributes-as-row-filters.py - 実践ルール Model each condition as an attribute of the principal, the data or the request, read by one rule per role, rather than as another role. When an attribute comes from the requester, as a purpose does, let it unlock access only under a narrower condition, so that leaving it out, or getting it wrong, falls back to what the role allows anyway.
-
判断を一つのドキュメントとして返す
- 実行
one-decision-document.py - 実践ルール リクエストごとに一つの判断ドキュメントを返し、そこに許可、行フィルタ、列マスク、理由を含めて、全体として読み取る。フィルタとマスクは、実施側のコードが変換する名前と値として保ち、ポリシーが書く SQL にはしない。エンジンがポリシーに SQL を求める場合、たとえば Trino が行フィルタと列マスクで求める場合は(Trino 484、OPA アクセス制御)、両者の間に置いた、テスト済みの一つの関数で SQL を生成する。
- 実行
-
Unit-test the policy in Rego
- 実行
policy-unit-tests.py - 実践ルール Write a test for every rule that grants or narrows access, and one for every way a request can be denied, and compare whole filters and masks, not single keys. Run the tests on every change to the policy and to the data the policy reads.
- 実行
-
Check who sees what from a decision table
- 実行
who-sees-what.py - 実践ルール Keep a who-sees-what table in the repository with the policy, run it with the unit tests, and show its printed form to the data's owners, in terms they can check. When an owner disagrees with a row, change the row first, and let the failing row drive the change to the policy.
- 実行
-
Know where regopy differs from OPA
- 実行
regopy-silent-differences.py - 実行
regopy-failed-outputs.py - 実行
regopy-sprintf-quotes.py - 実践ルール Treat regopy as a fast local evaluator and OPA as the reference. Write Rego v1 only, bind every decision to a variable, mock input one path at a time with literal values, and check that an output succeeded before reading it. Before a policy guards production data, check and test it with OPA itself, with
opa check --strictandopa test.
- 実行
-
Write the same rules in Cedar
- 実行
cedar-same-rules.py - 実践ルール Choose Cedar when every question is "may this principal do this to this resource?", as in an application's permission checks, and you want a schema to check every policy before it runs. Choose Rego when the answer has to carry data, as a warehouse's row filters and column masks do, or when the engine already asks OPA, as Trino does. For the platform's warehouse, we recommend Rego.
- 実行
- What goes wrong in production
- この章で決めたこと
6. クエリへのポリシー適用
読了まで約75分。16 例。
この章を終えると、プラットフォームが実行するすべてのクエリに対してアクセス判定を適用できるようになる。
講義概要: 13 節
-
クエリが読むすべてのテーブルと列を見つける
- 実行
tables-a-query-reads.py - 実行
unknown-tables-denied.py - 実践ルール クエリが名指しするすべてのテーブルと列についてポリシーに尋ねる。その際、
*はカタログのスキーマに照らして展開する。スキーマに存在しないものは拒否する。すなわち、未知のテーブル、ファイル、テーブル関数、および単一のクエリ以外の文である。拒否のコストはプラットフォームチームへの 1 回の問い合わせで済むが、通過させた場合のコストは、そのテーブルが保持するもの全体に及ぶ。
- 実行
-
Allow only catalog tables, CTEs and subqueries
- 実行
catalog-sources-only.py - 実践ルール Check every source against an allowlist of catalog tables, CTEs in scope and subqueries, deny the rest, and deny every function the engine marks as having side effects, read from its own list. Keep the cases as a regression test for every layer change and engine upgrade, and add one for each new kind of source or function.
- 実行
-
列への参照をマスクすると漏えいする
- 先に確認する Predict how many of the five the rewrite stops:
- 実行
select-list-masks-leak.py - 実践ルール 列参照を書き換えてマスクを強制してはならない。どれだけ多くの参照の形に対応しても、エンジンには、書き換えが認識できる以上の列の読み取り方がある。代わりに、データの取得元でマスクし、すべての読み取りがマスク済みの値を見るようにする。次の節 はそのようにしている。
-
各テーブルをフィルタ済みでマスク済みのサブクエリに置き換える
- 実行
table-rewrite.py - 実行
table-rewrite-holds.py - 実践ルール 保護対象のテーブルはすべて、決定から生成したサブクエリに、クエリ自身のエイリアスのまま置き換え、ユーザーのクエリには他に手を加えない。読まれない列には型付きの
NULLを与える。ユーザーが値を表示するために行全体の読み取りを必要とする場合は、代わりに各テーブルのすべての列についてポリシーに問い合わせ、マスクがそれらすべてを覆うようにする。その代償として、クエリが使わなかった列を名指しする要求と監査記録が生じる。
- 実行
-
Write each mask as SQL in one place
- 重要用語
redact,pseudonymize - 実行
masks-as-sql.py - 実行
pseudonym-key.py - 実行
redact-contacts-recall.py - 実践ルール Keep every mask's SQL in one table in the enforcement layer, and let the policy name masks, never write them. Key every pseudonym with a secret only the layer holds, passed as a parameter. Measure each text mask against labelled data before a policy relies on it, and name masks for what they remove, so nobody reads
redact_contactsas "anonymized".
- 重要用語
-
判断のデータから行フィルタを組み立てる
- 実行
row-filters-from-data.py - 実践ルール すべての行フィルタは、SQL ビルダーを使って判断の値から組み立てる。層が認識しないフィルタの形や列は拒否する。不明な同意は同意なしとして扱う。フィルタがユーザーに読む権限のないテーブルを必要とするときは、ユーザーのアクセスを広げるのではなく、サブクエリの中で層自身のアクセス権を使って読む。
- 実行
-
すべての列を行フィルタで保護する
- 実行
row-filter-order.py - 実践ルール フィルタが除外する行からユーザーの条件を遠ざけるために、エンジンの評価順序に頼ってはならない。ユーザーのクエリが読めるすべての値を行フィルタに依存させ、エンジンをアップグレードするたびに各フィルタの形をテストする。PostgreSQLの
security_barrierビューのように、エンジンが独自の防壁を備えている場合は、それも併用する。
- 実行
-
クエリを実行して誰に何が見えるかをテストする
- 実行
who-sees-what-in-queries.py - 実行
group-change-caught.py - 実践ルール ポリシー、ユーザーファイル、メタデータ、レイヤーのいずれかを変更するたびに、誰に何が見えるかのケースをレイヤー経由のクエリとして実行し、一致しないケースが一つでもあればビルドを失敗させる。失敗したケースは、ポリシーまたはユーザーファイルを変更して直す。ケースを変更するのは、ユーザーが受け取るべき内容が変わったことにデータの所有者が合意した場合に限る。
- 実行
-
レポートで小さなグループを伏せる
- 実行
small-groups-difference.py - 実践ルール
governance/enforcement.tomlの最小値を下回る報告グループはすべて伏せ、最小値は 1 人を特定する検索に対する保護であって、差分攻撃に対する保護ではないと考えること。読み手が読むことを許されていない属性でレポートを分割し、その背後にある行を見られる読み手に送ってはならない。国別の講師向けレポートは、国を引くための対応表になっている。分割をやめるか、ノイズを加えた後にのみ報告すること。
- 実行
-
同じポリシーを、それを強制するエンジンに渡す
- 実行
trino-requests.py - 実践ルール 強制は、すべてのツールがクエリを発行するエンジンで行い、そのエンジンと本章のような書き換えの両方に同じポリシーを使う。Trino では、プラグインが問い合わせるすべての操作に答え、行フィルタと列マスクの両方の URI を設定し(設定しなければフィルタもマスクも適用されない)、行フィルタは読み取りを許可する決定からのみ返す。テストは、ドキュメントのポリシー例ではなく、プラグインのソースにあるリクエストの形から組み立てる。
- 実行
-
誰かの代理としてのクエリ
- 実行
assistant-on-behalf.py - 実践ルール アシスタントのクエリは、回答する相手の人として実行する。その ID は認証済みのセッションから取得し、その人の判断をレイヤーに適用させる。アシスタント自身の ID を使うのは、特定の誰のためでもない作業に限る。たとえば、講座ページ向けに同意済みレビューを夜間に要約する作業である。いずれの場合も、両方の ID を監査ログに記録する。アシスタントの学習セットを構築する者は、第 9 章のとおり、自分自身として、目的を
ai-trainingとしてクエリを実行する。
- 実行
- What goes wrong in production
- この章で決めたこと
7. 保持期間、同意、消去
読了まで約81分。11 例。
この章を読み終えると、保持ルールをレビュー済みの設定として管理し、同意の撤回を次のクエリに反映させ、ある一人のデータが到達したすべてのテーブルからその人を消去できるようになる。
講義概要: 13 節
-
Keep retention rules in a reviewed file
- 実行
retention-rules-due.py - 実践ルール Keep each table's retention period, the column it counts from and the state a row must be in, in a reviewed file, and apply it against a day the scheduler passes in, never the clock. Count from the date the rule means. When the table doesn't record that date, as the platform's tickets don't record when they closed, ask the table's owner to add the column rather than let the rule count from another date for good, and say in the rule's file which way it errs until then.
- 実行
-
行削除で期限切れの行を削除する
- 実行
apply-retention.py - 実践ルール 保持は Iceberg の行削除として、ルールを一つずつ適用し、各コミットのスナップショットサマリーにルールと日付を記録する。ジョブは、ある日付について冪等にする。大きなテーブルは、ルールが起算する列でパーティション分割し、削除がファイルを書き直さずファイルごとの破棄になるようにする。PyIceberg でそれらを書くには、
pyiceberg-core追加パッケージをインストールする。ジョブが完了したと見なすのは、古いスナップショットが期限切れになり、そのファイルが削除された後だけである。
- 実行
-
クエリが実行される場所で同意を読む
- 実行
consent-withdrawal.py - 実践ルール 同意はクエリが実行される場所に置く。すなわち、学習者が使うシステムが最新に保つ一つのテーブルに置き、ポリシーが行フィルタとして読む。これにより、撤回は次のクエリを変え、何も削除しない。プラットフォームの法務担当者が、撤回は削除の根拠でもあると判断した場合は、削除の経路にも送る。同意フィルタを用いて作成するすべてのテーブルは、同意が変わるたびに再構築するか、その読み手に同じフィルタを適用する。各同意は状態と変更時刻として記録し、ポリシーが読む真偽値の属性はそこから導出する。その際、不明は未付与として数える。
- 実行
-
系譜から消去を計画する
- 実行
erasure-plan.py - 実践ルール すべての消去は、誰かが保守する一覧からではなく、カタログと系譜グラフから計画する。まず本人の ID 列を持つすべてのテーブルを対象とし、次に系譜が本人の行の到達先とするすべてのテーブルを対象とする。派生テーブルからは、系譜が ID の変更されていないコピーと示す列で削除し、本人の行が形作っただけの派生テーブルは再構築する。例外は設定に置き、法務チームが理由とともに書く。計画にはそれを読ませて表示させ、コードに例外を決めさせてはならない。まず、どのジョブの系譜にも説明されないテーブルについての第4章の検査を実行すること。系譜に現れないコピーには、計画が到達できないからである。
- 実行
-
Erase the rows the plan lists
- 実行
erase-learner.py - 実践ルール Carry out an erasure as row deletes in the plan's order, and record only a request ID in each commit, never a value of the person's. Treat the delete as the first of three steps: the snapshots before it still hold the person, and anyone allowed to time travel can read them until they're expired.
- 実行
-
Expire snapshots by the table's own settings
- 実行
expiry-ignores-table-settings.py - 実行
erasure-refuses-to-start.py - 実践ルール Expire snapshots through one function of your own that reads
gc.enabledand thehistory.expiresettings before it expires anything, and refuses when garbage collection is off, because PyIceberg's expiry reads neither; check again at every PyIceberg release. Before an erasure deletes anything, check every table in its plan the same way, and refuse the whole erasure when one would keep the person. For an erasure, expire every snapshot older than the delete. For retention, expire by age, ashistory.expire.max-snapshot-age-mssays, measured on the clock, since snapshots carry real commit times.
- 実行
-
どのスナップショットからも参照されないファイルを削除する
- 実行
sweep-unreferenced-files.py - 実践ルール 期限切れの後は毎回、参照されないファイルを削除する。PyIceberg にはその機能がないので、inspect テーブルをもとにした自前のスイープを使う。本番環境では、書き込み中のファイルが残るように、最小経過時間を数日にしておく。経過時間 0 を使うのは、単一のプロセスだけが書き込む場合に限る。データファイルに含まれていないことを理由に、その人が消去されたとみなしてはならない。マニフェストにその人の値が残っている可能性がある。
- 実行
-
Keep personal values out of manifests
- 実行
statistics-off-for-personal-columns.py - 実践ルール Generate per-column metrics properties from your classifications,
noneorcountsfor every personal, sensitive or unclassified column, and apply them when a table is created or, for an existing table, with one rewrite followed by expiry and a sweep. Keep statistics on the ID columns you filter and erase by. Generate the properties again after every schema change.
- 実行
-
Prove the erasure by reading every file
- 実行
verify-erasure.py - 実践ルール End every erasure with a scan of every file the platform stores, for the person's IDs and identifying values, read with each format's own reader, and keep its result, counts and IDs only, as the evidence. Search for as much of each value as every bound keeps unchanged, which is one character less than the truncation length. Treat any file that still holds the person as a failed erasure, not a warning. Search the stores outside the warehouse that you control, and list in the record the ones you can't search.
- 実行
- 本番環境で起こる問題
-
消去した学習者が戻ってくる
- 実行
erased-learner-returns.py - 実践ルール 消去はまずソースシステムで、または同じ要求の中で行う。消去した ID のキー付きハッシュの台帳を保持し、すべてのロードでそれに照らしてフィルタし、すべての実行で検査する。鍵はデータとは別に、秘密情報として保管する。消去済みの ID を持つ行は、漏えいと同様にインシデントとして扱う。
- 実行
- その他の失敗
- この章で決めたこと
8. 監査と証跡
読了まで約67分。9 例。
この章を終えると、すべてのアクセス判断とクエリについて、値を含まず、編集があれば分かるように連鎖させた監査ログを残せるようになる。
講義概要: 9 節
-
Record every decision where it's made
- 実行
decision-record.py - 実践ルール Write the audit record in the enforcement layer, where the principal, the query and the decision meet, and write it before the query runs, so that a failed write stops the query. Record every identity involved, the person and any assistant acting for them, and every table's decision with its filters, masks and reasons. When an engine enforces the policy itself, as the SQL engine Trino does through OPA, turn on OPA's decision log instead, and make sure its input names every identity involved: Trino's
opa.identity.extra-credentials-keys, for example, forwards the credentials it lists "to OPA as extraCredentials in the identity context" (Trino 484, OPA access control).
- 実行
-
記録に値を残さない
- 実行
query-without-literals.py - 実行
query-shape-hard-cases.py - 実践ルール クエリの形を記録し、値は決して記録しない。エンジンが受け付けるあらゆる構文のリテラルと、カタログに存在しない名前をすべて置き換え、コメントを捨て、拒否理由からも同じ値を取り除き、実行された SQL は、ログの読者が鍵を入手できない鍵付きダイジェストとしてのみ保持する。個人データを含みうるテキストの単純なハッシュは決して使わない。ある一人のデータを誰が読んだかを知る必要があるときは、それを改ざん検知可能なログではなく、保持期間と消去が及ぶ別のログに保持する。
- 実行
-
古い決定をそれ自身のポリシーで再現する
- 実行
explain-old-decision.py - 実践ルール すべての決定に、リクエスト以外にその決定が依存したすべてのもののハッシュ、すなわちポリシーのモジュールとそのデータドキュメントを合わせたハッシュでフィンガープリントを付ける。各リビジョンは、ログを保持する期間と同じだけアーカイブする。古い決定は、現在のリビジョンではなく、その決定自身のリビジョンで再現して説明する。ポリシーが時計を読んだり他のサービスを呼んだりする場合は、OPA の
nd_builtin_cacheと同様に、それらの結果も記録する。
- 実行
-
編集が分かるようにレコードを連鎖させる
- 先に確認する Before you run it, predict which of the five the chain finds on its own, and which against the noon head.
- 実行
chain-catches-edit.py - 実践ルール すべてのレコードを、SHA-256 と連番によって直前のレコードに連鎖させる。ただし、連鎖が保護するのは、この層の制御の外に書き留めた最後のヘッドまでのレコードだけだと考える。ヘッドは、追記専用のストアか、別の資格情報の下にある別のシステムに、受け入れられる未保護レコード数に見合う頻度で書き留める。その数がゼロなら、各レコードを書き込むたびにマシンの外へ送り出す。連鎖は、最後のヘッドと照合して定期的に検査する。AU-9(3) が述べる保護が必要なら、この層が鍵を一切持たないシステムに各ヘッドへ署名させる。いつか特定の個人のために消去する必要が生じうるレコードは、決して連鎖させない。代わりに、期間全体を満了させる。
-
ログをDuckDBのクエリログと突き合わせる
- 実行
query-log-cross-check.py - 実践ルール ポリシーを強制する場所ではどこでも、エンジン自身のクエリログを有効にし、すべての結果をレイヤー内で取得し、前回の検査以降に書かれた記録と照らして、定期的にログを双方向に検査する。エンジンが実行したすべてのクエリは記録と対応しなければならず、許可されたすべての記録はクエリと対応しなければならない。その後、ログを空にする。ログはクエリの値を保持するからである。不一致は、除外すべき雑音ではなく、説明すべきインシデントとして扱う。この検査に期待できるのは誤りの捕捉であり、接続を握って隠蔽しようとするコードの捕捉ではない。そのようなコードには、プロセスの外に書かれたログだけが有効である。エンジンのログを監査ログとして使ってはならない。ユーザーも判定も含まないからである。
- 実行
-
ログからアクセスレビューを生成する
- 実行
access-review.py - 実践ルール アクセスレビューは、ロール所属の一覧からではなく、ポリシーと監査ログから生成する。各人が読んでよいものと実際に読んだもの、拒否された件、ポリシーがもう知らない所属を照らし合わせる。レビューは、すべての業務のリズムを含められる長さの期間、たとえば四半期にわたって実行し、各発見事項は、それに関わるテーブルまたはグループの所有者に送る。期間中に誰も使わなかった権限は、所有者が必要な理由を示さない限り削除する。
- 実行
-
証拠をデータとして生成する
- 実行
evidence-report.py - 実践ルール 証拠は、記録からコードで、スケジュールに従って、またポリシーを変更するたびに生成する。各節には、ポリシーのリビジョン、入力のダイジェスト、再計算に必要なものをスタンプとして記し、誰にも再計算できない部分はそうと明記する。レポートはログの書き手が変更できない場所に保管し、失敗した所見はフィルタで除かずに含め、各レポートでは前回のレポートが書き留めたヘッドに対してチェーンを検査する。レポートを生成できる場面でスクリーンショットを送ってはならない。第10章では、このような検査をすべてのプルリクエストで実行する。
- 実行
- 本番環境で何が問題になるか
- この章で決めたこと
9. AIのためのデータガバナンス
読了まで約89分。11 例。
本章を終えると、AIアシスタントが学習に用いるデータを、プラットフォームの他のあらゆる読み取りと同じ規則の下で構築できるようになる。
講義概要: 12 節
-
Admit only reviews whose authors consented
- 実行
corpus-consent-filter.py - 実践ルール Decide consent per record, when the corpus is built, from the answer your legal team says covers the use, and admit only records whose answer is yes: never filter out the refusals and keep the rest. Build the corpus through the enforcement layer with its purpose stated, and have the build check that the layer filters on that answer. Keep the legal team's answers, with their reasons, in a reviewed file the code reads, and carry licences per record when a source mixes them.
- 実行
-
Replace personal data in the text, then measure what's left
- 実行
corpus-personal-data-left.py - 実行
privacy-filter-on-the-corpus.py - 実践ルール Detect personal data in corpus text after the enforcement layer's masks, add the identifiers your platform holds about the people the text is about, and measure what's left against labelled data, by value, after every change to the detector. Prefer a short list of the names your text is about to every name you hold, since a long list matches ordinary words. Have a job that may read the names build the list, and record which list each corpus used. Measure a named-entity model the same way before you rely on it for names no list holds. Keep the list out of the corpus, and call the result pseudonymized.
- 実行
-
キー付きハッシュで仮名を一貫させる
- 実行
keyed-pseudonyms.py - 実践ルール 仮名は、ジョブだけが持つキーのもとで HMAC を用いて作る。仮名どうしを結合させてはならないコーパスや対象ごとに、それぞれ固有のキーを与える。仮名のために、ソルトなしで Presidio の
hashオペレータを使ってはならない。固定されたバージョンでは、ハッシュのたびに値がランダムになるからである。二人の人物が名前の一語を共有しうる場合には、名前の一語ではなく人物の ID を仮名化する。下流で人を区別する必要がない場合には、単純なプレースホルダを使う。
- 実行
-
Find near-duplicates with MinHash
- 実行
corpus-duplicates.py - 実行
names-and-near-duplicates.py - 実践ルール Deduplicate training text in two steps, exact copies by a hash of the normalized text and then near-duplicates by MinHash, each confirmed by its exact similarity, and report how much each step removed. Pseudonymize first, so that no name reaches the comparison or the sketches and the comparison can tell which pairs differ only in a name. Keep those pairs apart when the text's meaning depends on whom it names, and compare on placeholders when it doesn't. Choose the threshold by reading the pairs close above and below it in your own text.
- 実行
-
Tune LSH for recall, then confirm every pair
- 実行
lsh-misses-near-duplicates.py - 実行
figure-lsh-candidate-chance.py - 実践ルール Tune LSH below your similarity threshold, so that it misses few pairs, and confirm every candidate by its exact similarity. Measure LSH's misses against an exhaustive comparison on a sample of your corpus whenever its settings, its library or the text change. Pin the MinHash library, write its hashing scheme into your settings, and never compare counts or stored sketches made under different schemes.
- 実行
-
すべてのレコードに来歴を持たせる
- 実行
corpus-provenance.py - 実践ルール すべてのレコードに、元のテーブル、その行の ID、それを書き込んだジョブと実行を持たせる。ジョブのリネージは、フィルタとマスクを含め、実行されたとおりのクエリから記録する。古い構築は、この来歴を通じて今日の同意状況に照らして検査する。モデルが目にする前に、すべての検索結果を、各レコードの元の行に対する読者自身の判断でフィルタする。
- 実行
-
Generate the dataset card from the run
- 実行
corpus-dataset-card.py - 実践ルール Generate the card in the run that builds the data, with every count, hash, source and version taken from that run, and write the format's version out. Check the card with your own code for every property the specification requires, since the library's validator doesn't report them all, and don't publish or train on a corpus whose card fails.
- 実行
-
EU AI法が訓練データについて述べていることを引用する
- 実践ルール 同法は、官報に掲載された改正後のものを、リンクと閲覧した日付を添えて引用すること。オムニバスによって文言も日付も動いたためである。法律をパイプラインの論理に持ち込まないこと。カードの事実は実行結果から生成し、どの条文が適用されるかは、法的な問いに答える担当者に判断させる。
- 本番環境で何が問題になるか
-
A learner withdraws after the build
- 実行
consent-withdrawn-after-build.py - 実践ルール Record which build, by run ID, every model and index was made from. Before every training run, check the build's records against today's consent and the file's hash against its card, and refuse a build that fails either. When a learner withdraws, find the builds that hold their records and the models made from them, and let your legal team's answer in config decide what happens to those.
- 実行
- その他の失敗
- What this chapter decided
10. Governance in CI
読了まで約79分。10 例。
学習の終わりには、run the governance checks of chapters 2 to 7 as one job on each pull request, judging only what the pull request changesできるようになる。
講義概要: 14 節
-
Run every check as one job
- 実行
governance-ci-report.py - 実践ルール Run every check as one job on every pull request, each reporting all its findings under stable IDs, and a crashed check as a failing finding. Fail the job by exit code on any finding the pull request introduces that is neither waived nor approved. Report every finding already on main, counted and named with its owner, without failing a pull request that leaves it as it is. Keep the list of checks in a reviewed file.
- 実行
-
コミットではなくプルリクエストをゲートにする
- 実践ルール フックは、作成者のマシン上での単一ファイルの高速なチェックに使い、ゲートはプルリクエスト上の CI ジョブとして、メインブランチのブランチ保護で必須にする。検出結果はすべて、ID と対処方法を添えてプルリクエスト自体に載せ、ダッシュボードだけに置いてはならない。プルリクエストの外で変更されるテーブルのために、同じチェックを本番カタログに対しても定期的に実行する。
-
スキーマ変更が及ぶ範囲を報告する
- 実行
schema-change-impact.py - 実践ルール スキーマの差分は、名前やスキーマ ID ではなく、必ずフィールド ID で取る。名前変更、型変更、削除のすべてを三つの観点で報告する。Iceberg の読み手が影響を受けるか、どのパイプラインの SQL がその列を名指ししているか、そして INDIRECT エッジを含め、リネージを通じて何に及ぶか、である。報告は、及ぶすべてのテーブルの所有者に送る。パイプラインを壊す名前変更は、そのパイプラインの修正と同じプルリクエストでマージし、修正より前にマージしてはならない。
- 実行
-
分類を下げる前にオーナーへ確認する
- 実行
classification-downgrade.py - 実践ルール 分類の引き下げ、オーナーの変更、別のドメインへの移動は、main ブランチ上でのテーブルのオーナーの承認が必要な変更として扱い、承認されるまでジョブを失敗させる。これらについて、破壊的変更の検査ツールに頼ってはならない。同じプルリクエストのなかで、列の説明に理由を書くことを求める。分類の引き上げには、このような承認は要らない。隠す範囲が広がるだけだからである。
- 実行
-
列を削除する前に非推奨にする
- 実行
deprecate-then-remove.py - 実践ルール 列の削除は 2 つのプルリクエストに分ける。まず、代替手段を description に記して列を非推奨とし、それをマージする。次に、列をテーブルから落とし、そのエントリをメタデータから削除する。メインブランチで非推奨にされていない列の削除は、すべて失敗させる。ジョブが確認するのは非推奨が先にあったことだけなので、非推奨の期間は列の読み手と合意しておく。
- 実行
-
Route each domain's reviews by path
- 実行
domain-contracts.py - 実践ルール Keep each domain's metadata under a path of its own, as one ODCS contract per table with one domain and one owning team, generated from the metadata and checked by the job, with a CODEOWNERS line for that team. Give the platform team the CODEOWNERS file, the job's settings, its global rules, the waivers and the migrations. Require code-owner review, and count approvals per team in the job when one isn't enough.
- 実行
-
グローバルルールの上にドメインルールを重ねる
- 実行
global-and-domain-rules.py - 実践ルール すべてのドメインが従わなければならないルールを、プラットフォームチームが管理する一つのグローバルパッケージとして書き、各ドメインには、そのチームが所有し、そのドメインの契約にだけ実行される独自のパッケージを追加させる。違反は、単なる合格か不合格かではなく、安定した対象を持つデータとして返す。ドメインルールはグローバルルールに追加するものとし、置き換えてはならない。また、テーブルの別ドメインへの移動は所有権の変更として扱い、単語一つを変えることでドメインのルールを逃れるチームが出ないようにする。
- 実行
-
チェックごとに免除された指摘を数える
- 実行
waived-findings.py - 実践ルール 免除は、プルリクエストが持ち込む指摘を正確に1つだけ特定し、責任を負うチーム、理由、数か月以内の終了日を備えるものとする。分類や所有者の欠落のように、どの免除でも黙らせてはならないチェックを一覧にしておく。チェックごとに、誰も対応しなかった指摘の数を、免除されたものも main に残されたものも含めて報告する。その大半が対応されなかったチェックはレビューの対象とする。チェックが誤っているか、プラットフォームが誤っているかのどちらかであり、件数だけではどちらかは分からない。
- 実行
- 本番環境で何がうまくいかなくなるか
-
すべての行を読むチェック
- 実行
slow-check-every-row.py - 実践ルール プルリクエストのチェックの規模は、データではなく変更に合わせる。対象は、メタデータ、スキーマ、ポリシー、およびプルリクエストが追加する列の名前である。値を読むチェックは、3章のように固定のサンプルを用いて定期的に実行し、その結果は所有するチームに送る。ジョブのチェックがどこで止まるかは、たとえば空のまま追加された列のように、文書に記しておく。
- 実行
-
すべての ID を検出するチェック
- 実行
noisy-check-waivers.py - 実践ルール チェックを追加する前に、メインブランチで実行してすべての検出結果を読む。検出結果の大半が免除されるのであれば、免除するのではなくルールを変更する。検出結果の大半が免除されたままのチェックは削除する。正しいチェックで免除の割合が高い場合は、担当者と期日を定めて取り組むべき作業として計画する。
- 実行
-
壊れたファイルは指摘事項になる
- 実行
broken-files-become-findings.py - 実践ルール クラッシュしたチェックは、エラーの最初の行とそのエラーが示すファイルを添えた、ジョブを失敗させる一つの指摘事項に変える。それでも他のチェックは実行し、いかなる免除でもその指摘事項を黙らせてはならない。
- 実行
- その他の失敗
- この章で決めたこと
問題バンク
全章の設問と解答を、認証済み教育者向けに提供する。各解答は該当する節に紐づいている。 入手方法
問題集を読み込み中…