AI로 번역함. 영어 원문을 사람이 검증함. 원문 읽기

코드로서의 데이터 거버넌스

교육 자료 키트

2026.11.36판으로, 책의 현재 판이다. 책이 바뀌면 함께 바뀐다. 출처를 밝히면 자유롭게 사용하고 수정할 수 있다.

강의 계획서

읽기 시간은 장의 본문 기준이다. 학습자는 Lab 또는 자신의 컴퓨터에서 예제도 실행한다.

주당 한 장: 10주

5주 후

학습 목표와 개요

각 장의 학습 목표는 첫 문장이다. 각 개요는 장의 절을 따르며, 절이 정의하는 용어, 예제가 실행되기 전에 요구하는 예측, 그리고 각 절이 끝나는 규칙을 담는다. 핵심 용어와 질문으로 제시되는 예측은 퀴즈 은행이 묻는 대로 영문판의 것이다.

1. 처음부터 끝까지 살펴보는 거버넌스

읽는 데 약 48분, 6개 예제.

이 장을 마치면 데이터 플랫폼의 테이블 하나를 코드로 처음부터 끝까지 거버넌스할 수 있다. 테이블을 소유 팀과 모든 열의 분류와 함께 카탈로그에 등록하고, 그 테이블을 복사하는 파이프라인의 리니지를 수집하고, 어떤 행을 누가 읽을 수 있는지 결정해 그 결정을 쿼리에 적용하고, 아무도 분류하지 않은 열을 추가한 풀 리퀘스트가 실패하는 것을 확인한다. 각 부분은 작고 몇 초 안에 실행되며, 이후의 다섯 개 장이 각각 그중 하나를 견고하게 만든다。

강의 개요: 8절
  1. 소유자와 분류를 갖춘 테이블 카탈로그 만들기
    • 실행 catalog-the-learners.py
    • 작업 규칙 소유자, 도메인, 설명, 분류를 저장소의 검토를 거친 파일 하나에 두고, 모든 테이블의 소유자는 팀으로, 모든 열의 분류는 닫힌 목록 중 하나로 정한다. 설명은 카탈로그에 기록해 테이블을 읽는 모든 독자가 보게 하고, 카탈로그를 파일과 대조하는 테스트는 파일이 아니라 카탈로그를 순회하는 방식으로 작성한다. 편집이 카탈로그의 웹 페이지에서 이루어진다면 한쪽을 원본으로 정하고 다른 쪽은 그로부터 생성한다(2장).
  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.
  3. 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.
  4. 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.
  5. 운영 환경에서 무엇이 잘못되는가
  6. 아무도 갱신하지 않는 거버넌스 스프레드시트
    • 실행 spreadsheet-misses-new-column.py
    • 작업 규칙 거버넌스 메타데이터를 아무것도 검사하지 않는 문서에 보관하지 않는다. 검토를 거치는 파일에 보관하고, 모든 풀 리퀘스트와 정해진 일정마다 테스트가 이 파일을 실제 카탈로그와 비교하게 한다. 스프레드시트가 필요한 사람이 있다면 그 파일에서 생성하고, 생성한 시점을 스프레드시트에 적어 둔다.
  7. 한 도구는 집행하고 다른 도구는 우회하는 정책
    • 실행 read-around-the-layer.py
    • 작업 규칙 정책을 집행할 곳을 하나, 즉 모든 도구가 질의를 보내는 엔진으로 정하고, 스토리지 자격 증명은 그 엔진과 테이블에 쓰는 작업에만 주며 사람이나 노트북에는 주지 않는다. 그곳에서는 카탈로그 테이블을 거치지 않고 데이터를 읽는 쿼리를 모두 거부한다. 테이블을 보호된 것으로 치기 전에 그 파일을 읽을 수 있는 모든 것을 나열하고, 정책에 질의하지 않는 리더는 모두 우회로 취급한다. 다만 읽는 테이블과 똑같이 출력물이 카탈로그에 등록되고 분류되는 작업은 예외이다.
  8. 이 장에서 결정한 것

2. 테스트할 수 있는 카탈로그

읽는 데 약 61분, 12개 예제.

이 장을 마치면 카탈로그의 메타데이터를 코드로 관리할 수 있다. 모든 테이블에는 소유자와 도메인을 지정하고, 모든 열에는 설명과 분류를 지정하여, 팀이 검토하는 파일에 담는다. 이 파일은 이름이 바뀌어도 아무것도 잃지 않도록 키를 지정하고, Iceberg 카탈로그에 기록하며, 누락된 것이 있으면 실패하는 테스트로 검사한다. 또한 로컬 모델이 설명과 분류의 초안을 작성하게 하고, 누군가 그 초안을 받아들이기 전에 초안이 얼마나 자주 틀리는지 측정한다。

강의 개요: 12절
  1. 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.
  2. 필드 ID로 열 메타데이터의 키를 정한다
    • 실행 rename-orphans-name-keys.py
    • 작업 규칙 열 메타데이터는 필드 ID를 키로 삼고, 사람이 읽을 수 있도록 이름을 곁에 둔다. 더 이상 일치하지 않는 이름은 새 열이 아니라 해당 열의 설명을 검토해야 한다는 신호로 다룬다. 열을 이름으로만 아는 시스템에는 이름 키 뷰를 손으로 관리하지 말고, ID를 키로 하는 파일에서 생성한다.
  3. 테이블 스키마에 설명 기록하기
  4. 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.
  5. 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.
  6. Catch schema changes before the metadata goes stale
    • 실행 schema-changes-checked.py
    • 작업 규칙 Run both checks on every schema change: problems for columns nobody has classified or renamed ones nobody has re-read, and dropped for 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.
  7. 조인을 위한 가명 ID 분류
    • 실행 pseudonymous-learner-id.py
    • 작업 규칙 가명 ID는 자신의 테이블이 드러내는 내용으로 분류하여 분석가에게 필요한 조인이 계속 동작하게 하고, 설명에는 그 ID가 무엇을 통해 해석되는지 적는다. ID를 해석하는 테이블을 보호하고, 모든 삭제 작업에 그 ID를 포함한다. 누가 ID를 해석할 수 있는지는 접근 결정의 문제이다. ID와 해석 테이블의 개인 열을 마스킹 없이 모두 읽을 수 있는 사용자를 나열하고, 그 조합은 행을 사람에게 연결하는 것이 업무인 사용자에게만 부여한다.
  8. 로컬 모델로 메타데이터 초안 작성하기
  9. 프롬프트의 예제가 답을 알려 줄 수 있다
    • 실행 suggestions-with-platform-examples.py
    • 작업 규칙 모델로 메타데이터 초안을 작성할 때는 보내도 되는 입력만 사용하고, 가능하면 자체 머신에서 돌리는 모델을 사용한다. 각 답은 모델, 모델의 리비전, 프롬프트, 설정과 함께 기록하여 검토자가 각 초안을 무엇이 만들었는지 볼 수 있게 하고, 어떤 것이 답을 읽기 전에 모든 답을 파싱하고 검증한다 → 무엇이든 답을 읽기 전에 모든 답을 파싱하고 검증한다. 프롬프트의 예제는 프롬프트를 측정할 테이블 밖에서 가져온다. 검토를 거친 메타데이터와의 일치도는 숫자 하나가 아니라 분류별로 보고한다.
  10. 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.
  11. 운영 환경에서 잘못되는 일
  12. 이 장에서 결정한 내용

3. 개인 데이터 찾기

읽는 데 약 75분, 12개 예제.

이 장을 마치면 데이터 플랫폼에서 개인 데이터를 자동으로 찾고, 그중 얼마나 놓치는지 말할 수 있다. 열의 이름, 타입, 값의 재현 가능한 표본으로 모든 열의 분류를 제안한다. 자유 형식 텍스트 안의 개인 데이터를 구간 단위로 찾는다. 누군가 탐지기를 신뢰하기 전에 레이블이 붙은 데이터로 각 탐지기를 측정한다. 이 과정에서 Presidio의 패턴 인식기를 오프라인으로 실행하되, 임계값은 측정으로 정한다. 그 결과를 개인 데이터를 찾도록 학습된 모델이 기록해 둔 탐지 결과와 비교하고, 스키마 변경으로 추가된 열만 다시 분류한다。

강의 개요: 13절
  1. 스키마로 열 분류하기
    • 실행 column-name-rules.py
    • 작업 규칙 이름 규칙은 비용이 들지 않으므로 먼저 모든 열에 적용하되, 분류를 높이는 데만 쓰고 낮추는 데는 쓰지 않는다. 규칙은 짧게 유지하고 코드로 작성하며, 다른 규칙과 마찬가지로 검토한다. 이름이 무엇이든 자유 텍스트 열은 값을 표본으로 추출해야 하는 열로 취급하고, 다른 타입의 열은 이름만으로 분류한다.
  2. Run Presidio offline
    • 실행 presidio-offline-engine.py
    • 작업 규칙 Configure Presidio's engine explicitly: NoOpNlpEngine when you run patterns only, or a pinned model you install yourself when you need its names. Never call AnalyzerEngine() 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.
  3. 열의 값을 매 실행마다 같은 방식으로 표본추출한다
    • 실행 seeded-column-sample.py
    • 작업 규칙 NULL이 아닌 값을 고정된 시드로, 단일 스레드에서 표본추출하고, 시드를 결과와 함께 보관한다. 반드시 찾아내야 하는 가장 드문 개인 데이터를 기준으로 표본 크기를 정하며, 99%에는 n = ln(0.01) / ln(1 − p)를 쓴다. 플랫폼은 텍스트 열마다 값 200개를 표본추출하며, 이는 governance/pii.toml에 설정되어 있다. 이 크기는 1 in 43 이상의 값이 담고 있는 개인 데이터를 99%의 확률로 찾아낸다. 그보다 드문 데이터는 열 전체를 검사하거나 규칙으로 분류한다.
  4. 값으로 열 분류하기
    • 실행 classify-sampled-columns.py
    • 작업 규칙 이름이나 표본 값 중 어느 하나라도 뒷받침하는 가장 엄격한 분류를 제안하되 internal를 하한으로 삼고, 제안과 함께 근거를 보여 준다. 검토된 메타데이터보다 엄격한 제안은 표의 소유자에게 전달할 발견 사항이며, 소유자는 분류를 올리거나 올리지 않는 이유를 기록한다. 탐지기가 분류를 낮추도록 두어서는 안 된다. OpenMetadata는 이미 PII 태그가 붙은 열을 건너뛴다. 검토된 태그가 바로 점검 대상이므로, 우리는 매 실행마다 모든 텍스트 열을 표본 추출하기를 권한다.
  5. 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.
  6. 인식기를 정답에 맞춰 조정한다
    • 실행 tune-pattern-recognizers.py
    • 실행 figure-detection-scores.py
    • 작업 규칙 Presidio의 기본 임곗값 0으로, 또는 모든 인식기에 단일 임곗값을 적용해 실행하지 않는다. 텍스트에 들어 있을 수 있는 식별자의 인식기만 유지하고, 각 인식기의 임곗값을 해당 인식기의 점수로 정하며, 사용자가 사는 지역의 전화번호를 읽되 그 지역은 데이터에서 도출한다. 이 모두를 코드에 넣고, 바뀔 때마다 다시 측정한다.
  7. 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.
  8. Compare a PII model
  9. 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.
  10. 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.
  11. 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.
  12. What goes wrong in production
  13. 이 장에서 결정한 내용

4. Lineage from pipelines

읽는 데 약 69분, 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절
  1. 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.
  2. 각 출력 열을 원천까지 추적한다
    • 실행 sqlglot-misses-row-inputs.py
    • 작업 규칙 각 출력의 값이 계산되는 원천 열을 알려면 sqlglot의 lineage를 사용하고, 스키마는 직접 입력하지 말고 항상 테이블 메타데이터에서 생성한 카탈로그의 스키마를 전달한다. 그 결과를 열이 의존하는 모든 것으로 읽어서는 안 된다. 조인, 필터, 그룹화에 쓰이는 열은 빠지며, 입력 중 어느 것이 값인지도 알려 주지 않는다.
  3. 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's dataset list, 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.
  4. 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 an INSERT's columns by position against the table's columns in the catalog, never the SELECT's names, and fail when the counts differ. For a MERGE, write a SELECT of the columns it writes, and record the job's lineage from that, as an INSERT ... SELECT into the MERGE's table, until your parser handles MERGE itself.
  5. 컬럼 변경이 무엇을 깨뜨리는지 찾기
    • 실행 column-impact.py
    • 실행 figure-category-reach.py
    • 작업 규칙 이벤트로 만든 그래프에서 INDIRECT 에지를 포함해 영향 분석을 실행하고, 값이 바뀔 수 있는 컬럼과 행이 바뀔 수 있는 테이블이라는 두 목록을 보고한다. 필터와 조인에만 쓰이는 컬럼의 변경은 그 컬럼이 필터링하는 테이블의 모든 컬럼에 대한 변경으로 취급하고, 보고서는 영향이 닿는 각 테이블의 소유자에게 보낸다.
  6. 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.
  7. 운영 환경에서 무엇이 잘못되는가
  8. 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.
  9. 아무도 계측하지 않은 작업
    • 실행 uninstrumented-job.py
    • 작업 규칙 카탈로그를 리니지와 정기적으로 대조하고, 어떤 작업의 리니지로도 설명되지 않는 테이블은 사고로 취급한다. 해당 작업을 찾아 이벤트를 보내도록 만든다.
  10. 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.
  11. What this chapter decided

5. Access policies as code

읽는 데 약 65분, 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절
  1. 요청을 Trino의 형태로 만든다
    • 실행 trino-shaped-request.py
    • 작업 규칙 정책의 입력은 이를 집행할 엔진의 요청과 필드 하나하나까지 같은 형태로 만들고, 그 엔진이 보낼 수 없는 것만 검토자의 눈에 띄는 최상위에 추가한다. 사용하는 엔진이 Trino가 아니라면 그 엔진의 요청 형식에서 출발하고, lib.policy.request처럼 형태를 한 함수에 두어 테스트와 호출자가 서로 어긋나지 않게 한다.
  2. 정책이 읽는 데이터 생성하기
    • 실행 generated-policy-data.py
    • 작업 규칙 정책의 데이터는 정책을 불러올 때마다 각 사실을 소유한 파일이나 테이블에서 생성하고, 사실을 정책이나 두 번째 파일에 복사하지 않는다. 지원 상담원의 지역처럼 사실에 아직 소유자가 없다면, 플랫폼이 users.toml로 하는 것처럼 코드와 같이 검토되는 파일 하나를 소유자로 정해 준다.
  3. 기본은 거부하고, 역할에 따라 허용한다
    • 실행 allow-by-role.py
    • 작업 규칙 모든 정책은 default allow := false로 시작하고, 역할과 자원을 명시하는 규칙으로만 허용한다. 역할과 테이블의 대응은 검토자가 한 번에 모두 읽을 수 있도록 한곳에 둔다. 모든 결정에는 사유를 붙인다. 허용되어야 할 요청이 거부되면 그것을 허용하는 규칙을 추가하고, 기본값을 약화하지 않는다.
  4. 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.
  5. 결정을 하나의 문서로 반환한다
    • 실행 one-decision-document.py
    • 작업 규칙 요청마다 허용 여부, 행 필터, 열 마스크, 이유를 담은 결정 문서를 하나씩 반환하고, 이를 하나의 전체로 읽는다. 필터와 마스크는 집행 코드가 변환하는 이름과 값으로 유지하며, 정책이 작성한 SQL로 두지 않는다. Trino가 행 필터와 열 마스크에 대해 그렇듯(Trino 484, OPA access control) 엔진이 정책에서 SQL을 요구한다면, 그 둘 사이에 테스트된 함수 하나로 SQL을 생성한다.
  6. 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.
  7. 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.
  8. 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 --strict and opa test.
  9. 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.
  10. What goes wrong in production
  11. What this chapter decided

6. 쿼리에 정책 적용하기

읽는 데 약 57분, 16개 예제.

이 장을 마치면 플랫폼이 실행하는 모든 쿼리에 접근 결정을 적용할 수 있다. 각 쿼리를 다시 써서, 쿼리가 읽는 모든 테이블을 사용자가 볼 수 있는 행만 남기고 볼 수 없는 열은 마스킹하는 서브쿼리로 대체한다. 그 밖의 것을 읽는 쿼리는 모두 거부한다. 실제 쿼리를 실행해 누가 무엇을 받는지 테스트하고, DuckDB 앞단의 재작성이 어느 지점에서 더 이상 아무것도 보호하지 못하는지 설명한다。

강의 개요: 13절
  1. 쿼리가 읽는 모든 테이블과 컬럼 찾기
    • 실행 tables-a-query-reads.py
    • 실행 unknown-tables-denied.py
    • 작업 규칙 쿼리가 명시한 모든 테이블과 컬럼에 대해 정책에 묻되, *는 카탈로그의 스키마에 맞춰 펼친다. 그리고 그 스키마에 없는 것은 모두 거부한다. 알 수 없는 테이블, 파일, 테이블 함수, 단일 쿼리가 아닌 문장이 여기에 해당한다. 거부의 비용은 플랫폼 팀에 하는 질문 한 번이지만, 통과의 비용은 그 테이블에 든 모든 것이다.
  2. 카탈로그 테이블, CTE, 서브쿼리만 허용한다
    • 실행 catalog-sources-only.py
    • 작업 규칙 모든 소스를 카탈로그 테이블, 범위 안의 CTE, 서브쿼리로 이루어진 허용 목록에 대조해 검사하고, 나머지는 거부한다. 엔진이 부작용이 있다고 표시한 모든 함수도 거부하되, 그 목록은 엔진 자체의 목록에서 읽는다. 사례는 계층을 바꿀 때마다, 그리고 엔진을 업그레이드할 때마다 실행하는 회귀 테스트로 보관하고, 새로운 종류의 소스나 함수가 생길 때마다 사례를 추가한다.
  3. Masking column references leaks
    • 먼저 묻기 Predict how many of the five the rewrite stops:
    • 실행 select-list-masks-leak.py
    • 작업 규칙 Don't enforce masks by rewriting column references. However many reference shapes you cover, the engine has more ways to read a column than the rewrite can recognize. Mask where the data comes from instead, so every read sees the masked value, as the next section does.
  4. 각 테이블을 필터링되고 마스킹된 서브쿼리로 교체한다
    • 실행 table-rewrite.py
    • 실행 table-rewrite-holds.py
    • 작업 규칙 보호 대상 테이블은 모두 결정으로부터 생성한 서브쿼리로, 쿼리 자체의 별칭을 그대로 써서 교체하고, 사용자의 쿼리는 그 밖에는 건드리지 않는다. 읽지 않는 컬럼에는 타입이 지정된 NULL을 준다. 사용자가 값을 보려고 행 전체를 읽어야 한다면, 각 테이블의 모든 컬럼에 대해 정책에 묻도록 하여 마스크가 전부 적용되게 한다. 이 경우 쿼리가 쓰지 않은 컬럼을 이름으로 담은 요청과 감사 기록이 생기는 비용을 치른다.
  5. 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_contacts as "anonymized".
  6. 결정의 데이터로 행 필터 만들기
    • 실행 row-filters-from-data.py
    • 작업 규칙 모든 행 필터는 SQL 빌더로 결정의 값에서 만들고, 계층이 인식하지 못하는 필터 형태나 열은 거부한다. 알 수 없는 동의는 동의하지 않은 것으로 취급한다. 필터에 사용자가 읽을 수 없는 테이블이 필요하면, 사용자의 접근 권한을 넓히지 말고 서브쿼리 안에서 계층 자체의 접근 권한으로 읽는다.
  7. 모든 열을 행 필터로 보호한다
    • 실행 row-filter-order.py
    • 작업 규칙 사용자의 조건이 필터에서 제외된 행에 닿지 않게 하려고 엔진의 평가 순서에 의존해서는 안 된다. 사용자의 쿼리가 읽을 수 있는 모든 값이 행 필터에 의존하게 만들고, 엔진을 업그레이드할 때마다 각 필터 형태를 시험한다. PostgreSQL의 security_barrier 뷰처럼 엔진에 자체 방벽이 있다면 그것도 함께 사용한다.
  8. 쿼리를 실행해 누가 무엇을 보는지 테스트하기
    • 실행 who-sees-what-in-queries.py
    • 실행 group-change-caught.py
    • 작업 규칙 정책, 사용자 파일, 메타데이터, 계층 중 무엇이든 바뀔 때마다 누가 무엇을 보는지에 대한 사례를 계층을 통과하는 쿼리로 실행하고, 일치하지 않는 사례가 하나라도 있으면 빌드를 실패시킨다. 실패한 사례는 정책이나 사용자 파일을 바꾸어 고친다. 사용자가 받아야 할 결과가 바뀌었다는 데 데이터 소유자들이 동의할 때만 사례를 바꾼다.
  9. 보고서에서 작은 집단 보류하기
    • 실행 small-groups-difference.py
    • 작업 규칙 governance/enforcement.toml의 최솟값에 못 미치는 보고 집단은 모두 보류하고, 최솟값은 한 사람을 조회하는 것을 막는 보호책으로만 취급하며 차분 공격에 대한 보호책으로 여기지 않는다. 독자가 읽을 수 없는 속성으로 보고서를 나누어, 그 뒤의 행을 볼 수 있는 독자에게 보내지 않는다. 국가별로 나눈 강사 보고서는 국가를 알려 주는 조회표다. 세부 분류를 없애거나, 노이즈를 추가한 뒤에만 보고한다.
  10. 같은 정책을 집행하는 엔진에 넘긴다
    • 실행 trino-requests.py
    • 작업 규칙 집행은 모든 도구가 질의를 보내는 엔진에 두고, 그 엔진과 이 장의 재작성 같은 모든 재작성에 하나의 정책을 쓴다. Trino에서는 플러그인이 묻는 모든 연산에 답하고, 행 필터 URI와 열 마스크 URI를 모두 설정하며(설정하지 않으면 필터와 마스크가 적용되지 않는다), 행 필터는 읽기를 허용하는 결정에서만 반환한다. 테스트는 문서의 예시 정책이 아니라 플러그인 소스의 요청 형태로 만든다.
  11. 다른 사람을 대신해 질의하기
    • 실행 assistant-on-behalf.py
    • 작업 규칙 어시스턴트의 질의는 어시스턴트가 답하는 사람으로서 실행하고, 그 신원은 그 사람의 인증된 세션에서 가져오며, 그 사람에 대한 결정은 계층이 적용하게 한다. 어시스턴트 자신의 신원은 특정인을 위한 것이 아닌 작업, 예를 들어 강의 페이지에 올릴 동의한 후기의 야간 요약 같은 작업에만 사용하고, 두 신원을 모두 감사 로그에 기록한다. 어시스턴트의 학습 데이터셋을 만드는 사람은 9장에서처럼 본인으로서, 목적을 ai-training로 지정해 질의한다.
  12. 운영 환경에서 잘못되는 것들
  13. 이 장에서 결정한 것

읽는 데 약 67분, 11개 예제.

이 장을 마치면 보존 규칙을 검토를 거친 설정으로 관리하고, 동의 철회가 다음 쿼리부터 결과를 바꾸게 하며, 한 사람의 데이터가 닿은 모든 테이블에서 그 사람을 삭제할 수 있다. 보존 규칙은 직접 넘겨 준 날짜를 기준으로 적용하고, 데이터가 닿은 테이블은 리니지에서 찾으며, 법무팀이 예외로 기록해 둔 데이터만 남긴다. 또한 행을 삭제한 뒤에도 Iceberg 테이블에 남는 것, 즉 오래된 스냅샷, 참조되지 않는 파일, 열 통계를 제거한다. 마지막으로 남은 모든 파일을 읽어 어느 파일에도 그 사람이 없음을 보여 주는 스캔으로 마무리한다。

강의 개요: 13절
  1. 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.
  2. 행 삭제로 만료된 행 지우기
    • 실행 apply-retention.py
    • 작업 규칙 보존은 Iceberg 행 삭제로 규칙 하나씩 적용하고, 각 커밋의 스냅샷 요약에 규칙과 날짜를 기록한다. 작업은 같은 날짜에 대해 멱등하게 만든다. 큰 테이블은 규칙이 기준으로 세는 열로 파티션해, 삭제가 파일을 다시 쓰는 대신 파일 전체를 버리게 한다. PyIceberg에서는 이를 쓰기 위해 pyiceberg-core 추가 패키지를 설치한다. 오래된 스냅샷이 만료되고 그 파일이 제거된 뒤에야 작업이 끝난 것으로 본다.
  3. 쿼리가 실행되는 곳에서 동의를 읽는다
    • 실행 consent-withdrawal.py
    • 작업 규칙 동의는 쿼리가 실행되는 곳에 둔다. 즉 학습자가 사용하는 시스템이 최신 상태로 유지하는 하나의 테이블에 두고, 정책이 이를 행 필터로 읽게 하여 철회가 다음 쿼리를 바꾸되 아무것도 삭제하지 않게 한다. 플랫폼의 법률 담당자가 철회도 삭제 사유라고 판단하면 삭제 경로로도 보낸다. 동의 필터로 만든 모든 테이블은 동의가 바뀔 때마다 다시 빌드하거나, 그 테이블의 읽는 이에게 같은 필터를 적용한다. 각 동의는 상태와 그 상태가 바뀐 시각으로 기록하고, 정책이 읽는 참 또는 거짓 속성은 이로부터 도출하되 알 수 없음은 부여되지 않음으로 센다.
  4. 계보에서 삭제 계획 세우기
    • 실행 erasure-plan.py
    • 작업 규칙 모든 삭제는 누군가 관리하는 목록이 아니라 카탈로그와 계보 그래프에서 계획한다. 먼저 그 사람의 ID 컬럼이 있는 모든 테이블을, 그다음 계보에 따라 그 사람의 행이 도달하는 모든 테이블을 대상으로 삼는다. 파생 테이블에서는 계보가 ID의 변경 없는 복사본임을 보여 주는 컬럼으로 삭제하고, 그 사람의 행이 형태만 만든 파생 테이블은 다시 만든다. 예외는 법무팀이 사유와 함께 작성하는 설정에 두고, 계획이 이를 읽어 보여 주게 하며, 코드가 예외를 결정하게 해서는 안 된다. 계획은 계보에 나타나지 않는 사본에는 도달할 수 없으므로, 작업의 계보로 설명되지 않는 테이블을 찾는 4장의 점검을 먼저 실행한다.
  5. 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.
  6. 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.enabled and the history.expire settings 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, as history.expire.max-snapshot-age-ms says, measured on the clock, since snapshots carry real commit times.
  7. 어떤 스냅숏도 참조하지 않는 파일 제거
    • 실행 sweep-unreferenced-files.py
    • 작업 규칙 만료할 때마다 참조되지 않는 파일을 제거하되, PyIceberg에는 이를 수행하는 기능이 없으므로 inspect 테이블을 바탕으로 직접 만든 스윕을 사용한다. 운영 환경에서는 쓰기가 진행 중인 파일이 보존되도록 며칠 단위의 최소 수명을 유지한다. 수명 0은 하나의 프로세스만 쓰는 곳에서만 사용한다. 어떤 데이터 파일에도 없다는 이유로 사람이 삭제되었다고 간주하지 않는다. 매니페스트에 그 사람의 값이 남아 있을 수 있다.
  8. Keep personal values out of manifests
    • 실행 statistics-off-for-personal-columns.py
    • 작업 규칙 Generate per-column metrics properties from your classifications, none or counts for 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.
  9. 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.
  10. 운영 환경에서 잘못되는 것들
  11. 삭제된 학습자가 되돌아온다
    • 실행 erased-learner-returns.py
    • 작업 규칙 원본 시스템에서 먼저, 또는 같은 요청 안에서 삭제하고, 삭제된 ID의 키 해시 대장을 두어 모든 적재가 이 대장으로 걸러내고 모든 실행이 이를 검사하게 하며, 키는 데이터와 분리해 비밀 값으로 보관한다. 삭제된 ID가 있는 행은 유출과 마찬가지로 사고로 취급한다.
  12. 그 밖의 실패
  13. 이 장에서 결정한 것

8. 감사와 증거

읽는 데 약 51분, 9개 예제.

이 장을 마치면 모든 접근 결정과 쿼리에 대한 감사 로그를 값 없이 남기고, 수정이 드러나도록 연결할 수 있다. 결정이 내려지는 곳에서 로그를 기록하고, 로그의 헤드, 즉 마지막 레코드의 번호와 해시를 로그 작성자가 바꿀 수 없는 곳에 따로 적어 둔다. 그러면 그 헤드까지의 어떤 레코드든 수정하거나 삭제하면 드러난다. 또한 정책이 바뀐 뒤에도 오래된 결정을 설명하고, 로그를 쿼리 엔진이 실행한 내용에 대한 자체 기록과 대조하며, 로그와 정책에서 접근 검토와 증거 보고서를 누구나 다시 실행할 수 있는 코드로 생성하는 방법을 익힌다。

강의 개요: 9절
  1. 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).
  2. 기록에 값을 남기지 않는다
    • 실행 query-without-literals.py
    • 실행 query-shape-hard-cases.py
    • 작업 규칙 쿼리의 값이 아니라 형태를 기록한다. 엔진이 받아들이는 모든 구문의 리터럴과 카탈로그에 없는 모든 이름을 바꾸고, 주석은 버리며, 거부 사유에서도 같은 값을 제거하고, 실행된 SQL은 로그를 읽는 사람이 키를 얻지 못하는 키 기반 다이제스트로만 보관한다. 개인정보가 담겼을 수 있는 텍스트에는 일반 해시를 쓰지 않는다. 한 사람의 데이터를 누가 읽었는지 알아야 할 때는, 변조 증거 로그가 아니라 보존과 삭제가 미치는 별도의 로그에 보관한다.
  3. 오래된 결정을 그 결정의 정책으로 재현하기
    • 실행 explain-old-decision.py
    • 작업 규칙 모든 결정에, 요청을 제외하고 그 결정이 의존한 모든 것의 해시, 즉 정책의 모듈과 데이터 문서를 함께 묶은 해시로 지문을 남긴다. 각 리비전은 로그를 보관하는 기간만큼 아카이브에 보관하고, 오래된 결정은 현재 리비전이 아니라 그 결정의 리비전으로 재현하여 설명한다. 정책이 시계를 읽거나 다른 서비스를 호출한다면, OPA의 nd_builtin_cache처럼 그 결과도 기록한다.
  4. 편집이 드러나도록 기록을 연쇄한다
    • 먼저 묻기 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과 순번으로 바로 앞 기록에 연쇄하되, 체인이 보호하는 것은 계층의 통제 밖에 적어 둔 마지막 헤드까지의 기록뿐이라고 전제한다. 헤드는 추가 전용 저장소나 다른 자격 증명을 쓰는 다른 시스템에, 보호받지 못하는 기록의 수로 감당할 수 있는 만큼 자주 적어 둔다. 그 수가 0이라면 각 기록을 쓰는 즉시 머신 밖으로 보낸다. 정해진 일정에 따라 마지막 헤드와 대조해 체인을 검사한다. AU-9(3)이 설명하는 것이 필요하다면, 계층이 키를 전혀 갖지 않는 시스템이 각 헤드에 서명하게 한다. 언젠가 한 사람 때문에 지워야 할 수도 있는 기록은 절대 연쇄하지 말고, 대신 기간 전체가 만료되게 한다.
  5. 로그를 DuckDB의 쿼리 로그와 교차 검증하기
    • 실행 query-log-cross-check.py
    • 작업 규칙 정책을 강제하는 모든 곳에서 엔진 자체의 쿼리 로그를 켜고, 모든 결과를 계층 안에서 가져오며, 마지막 검사 이후 기록된 레코드와 로그를 정기적으로 양방향으로 대조한다. 엔진이 실행한 모든 쿼리는 어떤 기록과 일치해야 하고, 허용된 모든 기록은 어떤 쿼리와 일치해야 한다. 그런 다음 로그를 비운다. 로그에는 쿼리의 값이 남아 있기 때문이다. 불일치는 걸러낼 잡음이 아니라 원인을 밝혀야 할 사고로 다룬다. 이 검사는 실수를 잡아내리라고 기대해야 하며, 연결을 쥐고 숨기려는 코드를 잡아내리라고 기대해서는 안 된다. 그런 코드에는 프로세스 밖에 기록된 로그만 도움이 된다. 엔진의 로그를 감사 로그로 쓰지 않는다. 그 로그에는 사용자도 결정도 없다.
  6. 로그로 접근 검토 생성하기
    • 실행 access-review.py
    • 작업 규칙 접근 검토는 역할 소속 목록이 아니라 정책과 감사 로그로 생성한다. 각 사람이 읽을 수 있는 것과 읽은 것, 거부된 내역, 정책이 더 이상 알지 못하는 소속을 비교한다. 검토는 분기처럼 모든 업무의 주기를 포괄할 만큼 긴 기간에 걸쳐 실행하고, 각 발견 사항은 그것이 해당하는 테이블이나 그룹의 소유자에게 보낸다. 해당 기간에 아무도 사용하지 않은 권한은 소유자가 필요한 이유를 밝히지 않는 한 제거한다.
  7. 증거를 데이터로 만들기
    • 실행 evidence-report.py
    • 작업 규칙 증거는 기록으로부터 코드로, 일정에 따라 그리고 정책이 바뀔 때마다 생성하고, 각 절에 정책 리비전, 입력의 다이제스트, 다시 계산하는 데 필요한 것을 스탬프로 남기며, 누구도 다시 계산할 수 없는 부분은 그렇다고 밝힌다. 보고서는 로그의 기록자가 바꿀 수 없는 곳에 보관하고, 실패한 결과는 걸러 내지 말고 포함하며, 각 보고서가 직전 보고서가 적어 둔 헤드를 기준으로 체인을 검사하게 한다. 보고서를 생성할 수 있다면 스크린샷을 보내지 않는다. 10장은 이와 같은 검사를 모든 풀 리퀘스트에서 실행한다.
  8. 운영 환경에서 잘못되는 것
  9. 이 장에서 결정한 것

9. AI를 위한 데이터 거버넌스

읽는 데 약 78분, 11개 예제.

이 장을 마치면 AI 어시스턴트가 학습하는 데이터를 플랫폼의 다른 모든 읽기 작업과 같은 규칙 아래에서 구축할 수 있다. 작성자가 그 용도에 동의한 레코드만 받아들이고, 개인 데이터를 가명으로 바꾸고 탐지기가 놓친 것을 측정하며, MinHash로 찾은 중복을 제거하고, 모든 레코드의 출처를 레코드와 함께 보관하고, 파이프라인이 실행될 때마다 데이터셋 카드를 작성하고 검사하게 한다. 또한 EU AI Act가 학습 데이터에 관해 말하는 내용을 인용할 수 있게 된다。

강의 개요: 12절
  1. 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.
  2. 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.
  3. 키 기반 해시로 가명을 일관되게 유지하기
    • 실행 keyed-pseudonyms.py
    • 작업 규칙 가명은 작업만 가진 키로 HMAC을 사용해 만들고, 가명끼리 조인되어서는 안 되는 코퍼스나 대상마다 별도의 키를 부여한다. 가명에 솔트 없이 Presidio의 hash 연산자를 쓰지 않는다. 고정된 버전에서는 해시마다 솔트가 무작위로 적용되기 때문이다. 두 사람이 이름의 한 단어를 공유할 수 있다면 이름의 단어가 아니라 사람의 ID를 가명화하고, 후속 단계에서 사람을 구분할 필요가 없다면 단순한 자리 표시자를 사용한다.
  4. 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.
  5. 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.
  6. 모든 레코드에 출처 정보를 싣는다
    • 실행 corpus-provenance.py
    • 작업 규칙 모든 레코드에 원본 테이블, 그 행의 ID, 그리고 그것을 쓴 작업과 실행을 부여하고, 작업의 계보는 필터와 마스크를 포함해 실제 실행된 쿼리를 기준으로 기록한다. 이 출처 정보를 통해 과거 빌드를 오늘의 동의 기준으로 검사한다. 모델이 보기 전에 모든 검색 결과를, 각 레코드의 원본 행에 대한 독자 본인의 결정으로 필터링한다.
  7. 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.
  8. EU AI Act가 학습 데이터에 대해 말하는 내용을 인용한다
    • 작업 규칙 개정된 법을 공보(Official Journal)에서 인용하고, 링크와 읽은 날짜를 함께 적는다. 옴니버스가 본문과 날짜를 모두 바꾸었기 때문이다. 법 해석을 파이프라인의 로직 바깥에 둔다. 카드의 사실은 실행 결과에서 생성하고, 어느 구절이 적용되는지는 법적 질문에 답하는 사람들이 결정하게 한다.
  9. 운영 환경에서 무엇이 잘못되는가
  10. 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.
  11. Other failures
  12. What this chapter decided

10. Governance in CI

읽는 데 약 70분, 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절
  1. 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.
  2. 커밋이 아니라 풀 리퀘스트를 게이트로 삼는다
    • 작업 규칙 훅은 작성자의 컴퓨터에서 단일 파일을 빠르게 검사하는 데 사용하고, 풀 리퀘스트의 CI 작업을 게이트로 삼아 메인 브랜치의 브랜치 보호로 필수화한다. 모든 발견 사항은 ID와 해야 할 일을 함께 풀 리퀘스트 자체에 남기고, 대시보드에만 남기지 않는다. 어떤 풀 리퀘스트와도 무관하게 변경되는 테이블을 위해, 이 작업의 검사를 운영 카탈로그에 대해서도 일정에 따라 실행한다.
  3. Report what a schema change reaches
    • 실행 schema-change-impact.py
    • 작업 규칙 Diff schemas by field ID, never by name or schema ID, and report every rename, type change and removal three ways: whether Iceberg readers are affected, which pipelines' SQL names the column, and what it reaches through lineage, INDIRECT edges included. Send the report to the owners of every table it reaches. Merge a rename that breaks a pipeline in the same pull request as the pipeline's fix, never before it.
  4. 분류를 낮추기 전에 소유자에게 물어라
    • 실행 classification-downgrade.py
    • 작업 규칙 분류를 낮추는 일, 소유자를 바꾸는 일, 다른 도메인으로 옮기는 일은 main 브랜치 기준 테이블 소유자의 승인이 필요한 변경으로 다루고, 승인이 주어질 때까지 작업을 실패시킨다. 이런 변경을 호환성 파괴 변경 검사기에 맡겨서는 안 된다. 같은 풀 리퀘스트에서 열의 설명에 이유를 적도록 요구한다. 분류를 높이는 일은 숨기는 범위만 넓힐 뿐이므로 이런 승인이 필요하지 않다.
  5. 컬럼을 제거하기 전에 먼저 폐기 표시하기
    • 실행 deprecate-then-remove.py
    • 작업 규칙 컬럼은 두 개의 풀 리퀘스트로 제거한다. 먼저 설명에 대체 수단을 적어 컬럼을 폐기 표시하고 병합한 다음, 테이블에서 컬럼을 삭제하고 메타데이터에서 해당 항목을 삭제한다. 메인 브랜치가 폐기 표시하지 않은 컬럼의 제거는 모두 실패 처리한다. 이 검사 작업은 폐기가 먼저 이루어졌는지만 확인하므로, 폐기 기간을 얼마로 할지는 컬럼의 독자와 합의한다.
  6. 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.
  7. 전역 규칙 위에 도메인 규칙을 겹쳐 쌓기
    • 실행 global-and-domain-rules.py
    • 작업 규칙 모든 도메인이 따라야 하는 규칙은 플랫폼 팀이 관리하는 하나의 전역 패키지로 작성하고, 각 도메인이 자기 팀이 소유하며 그 도메인의 계약에만 실행되는 패키지를 따로 추가하게 한다. 위반 사항은 단순한 통과나 실패가 아니라 안정적인 대상을 가진 데이터로 반환한다. 도메인 규칙은 전역 규칙에 더해지는 것이지 대체하는 것이 아니게 하고, 테이블이 다른 도메인으로 옮겨 가는 것은 소유권 변경으로 취급하여, 단어 하나를 바꾸는 것으로 자기 도메인의 규칙을 피해 가는 팀이 없게 한다.
  8. 점검별 면제된 발견 사항 집계
    • 실행 waived-findings.py
    • 작업 규칙 면제는 풀 리퀘스트가 새로 만드는 발견 사항 정확히 하나를 지정하게 하고, 담당 팀과 사유, 몇 달 이내의 종료일을 갖추게 한다. 분류나 소유자의 누락처럼 어떤 면제로도 침묵시킬 수 없는 점검은 목록으로 만든다. 점검마다 면제되었거나 main에 남겨져 아무도 조치하지 않은 발견 사항이 몇 건인지 보고하고, 그 대부분을 차지하는 점검은 검토한다. 점검이 잘못되었거나 플랫폼이 잘못된 것인데, 그 수치만으로는 어느 쪽인지 알 수 없다.
  9. 운영 환경에서 잘못되는 것들
  10. A check that reads every row
    • 실행 slow-check-every-row.py
    • 작업 규칙 Size pull-request checks by the change, not by the data: metadata, schemas, policies and the names of the columns a pull request adds. Run checks that read values on a schedule, with a fixed sample, as chapter 3 does, and send their findings to the owning team. Document where the job's checks stop, such as at a column added empty.
  11. 모든 ID를 문제로 표시하는 검사
    • 실행 noisy-check-waivers.py
    • 작업 규칙 검사를 추가하기 전에 메인 브랜치에서 실행해 모든 발견 사항을 읽는다. 대부분이 면제될 것이라면 발견 사항을 면제하지 말고 규칙을 바꾼다. 발견 사항 대부분이 계속 면제되는 검사는 제거하고, 올바른 검사에서 면제 비율이 높게 나타나면 담당자와 기한을 정해 처리할 작업으로 일정에 넣는다.
  12. 깨진 파일은 발견 사항이 된다
    • 실행 broken-files-become-findings.py
    • 작업 규칙 비정상 종료하는 검사는 작업을 실패시키는 발견 사항 하나로 바꾸고, 여기에 오류의 첫 줄과 그 오류가 가리키는 파일을 담는다. 다른 검사도 그대로 실행하며, 면제로 이 발견 사항을 잠재우지 못하게 한다.
  13. 그 밖의 실패
  14. 이 장에서 결정한 것

퀴즈 모음

인증된 교육자를 위해 모든 장의 질문과 정답 해설을 제공한다. 각 답은 해당 절과 연결된다. 증명을 얻는 방법