Free self-study · No account needed · Progress stays in this browser. Back it up before clearing site data or changing devices.

← Week 18: Sandboxing and Governance

Week 18 / Lesson 3

Keeping usable and private audit records

Record consequential decisions without creating a new disclosure channel.

Section 3.1 1 of 7

Overview

Focus

Record consequential decisions without creating a new disclosure channel.

Your route through the lesson

  • 3.2 Actors, operation identifiers, and linked effects
  • 3.3 Redaction, access, retention, and deletion
  • 3.4 Deployment rights and incident ownership
  • 3.5 Put it into practice
  • 3.6 Guided comparison
  • 3.7 A debugging log containing a secret

All required teaching is included here. Review selections are saved. Choose a correct answer for every question to continue; retries are unlimited. Study time and personal notes are optional.

Section 3.2 2 of 7

Actors, operation identifiers, and linked effects

Focus

Link actors, decisions, and observed effects with stable operation identifiers.

An audit record should explain who requested what, which authority was checked, what decision was made, and whether an effect actually occurred. Stable operation identifiers connect request, approval, execution attempt, and result. An attempt identifier can distinguish retries without pretending each is a new logical business operation.

For a local export, record actor worker1, project p1, operation x1, approval a1, policy v2, decision allow, and effect local-export-1. A denied operation x2 records deny and no effect. If execution fails after approval, record allowed plus failed or unknown effect status rather than rewriting the decision as denied. Authorization and outcome answer different questions.

Use timestamps with a stated convention and retain links to relevant artifact versions. Logs should be structured enough to reconstruct a sequence without storing full prompts or payloads by default. A sentence saying everything worked is too vague to distinguish approved success, safe rejection, and uncertain remote completion. The audit is evidence, so protect its writer identity and access separately from the worker whose actions it describes.

// Quick review

Check your understanding.

Choose an answer for immediate feedback. Retry freely; a correct answer for every question unlocks the next section.

1. An export is approved but the service times out with unknown outcome. Audit should record?
2. What links retries to one logical export?
3. Why protect audit writing separately from the worker?

Section 3.3 3 of 7

Redaction, access, retention, and deletion

Focus

Minimize sensitive content and define log access, retention, and deletion.

Audit data can create a new disclosure channel if it contains secrets, private documents, or complete tool arguments. Record the minimum needed to explain a decision: identifiers, policy version, scope metadata, reason codes, sizes, and effect references. Avoid full payload logging unless a justified controlled process requires it.

Redaction removes or replaces sensitive fields before storage. It should happen at the logging boundary, not only in the user interface, because hidden raw logs can still leak. Hashes are not automatically anonymous: a digest of a low-entropy value can be guessed by trying possible inputs. Choose identifiers and summaries appropriate to the risk rather than hashing every secret and calling it private.

Define who may read logs, how long they remain, and how deletion applies to backups and derived copies. Retention supports incident investigation, while unnecessary retention expands exposure. The classroom fixture uses a synthetic canary and verifies its literal absence from serialized records. That is a concrete narrow check, not proof that every personal detail or transformed secret has been removed. Real systems need field-level policy and access enforcement alongside useful audit content.

// Quick review

Check your understanding.

Choose an answer for immediate feedback. Retry freely; a correct answer for every question unlocks the next section.

1. Secret text is hidden in the interface but still stored in raw logs. Is it redacted at storage?
2. A short secret is hashed. Is its digest automatically anonymous?
3. What must a retention policy consider besides the primary log?

Section 3.4 4 of 7

Deployment rights and incident ownership

Focus

Assign deployment rights and incident responsibility outside the optimizing worker.

Governance makes consequential authority and responsibility explicit. The worker proposing a change should not automatically deploy it, alter policy, and erase its audit trail. Define which actor can approve releases, change permissions, inspect sensitive logs, revoke access, and coordinate incident recovery.

For the classroom platform, candidate generation writes proposals, a verifier records evidence, and a separately authorized executor changes the active version. An incident owner can stop new effects, preserve relevant evidence, and reconcile uncertain operations. These roles may be implemented by people or services, but their permissions must be deliberate rather than inherited from a shared administrator credential.

An incident record should connect the observed symptom, affected versions, operation identifiers, containment decision, and unresolved effects. Do not dump every secret into the record in the name of debugging. Restore service through a compatible known-good release and keep the evidence needed to understand what happened. Governance is not a fictional teacher approval step for the learner; the local script represents role and event fields without claiming any real person reviewed or authorized its output.

// Quick review

Check your understanding.

Choose an answer for immediate feedback. Retry freely; a correct answer for every question unlocks the next section.

1. An optimizer can deploy itself and delete its own audit records. What is missing?
2. Which incident action is appropriate for uncertain exports?
3. A fixture names an incident owner field. Does that mean a real person approved it?

Section 3.5 5 of 7

Put it into practice

Focus

Run allowed and denied exports through a redacted local audit record.

Download week18.py, save it in an exercise folder, and run python week18.py --lesson 3. This single practice writes two structured audit events into a temporary file. It requires only a small processor and standard-library Python, finishes within seconds, and sends no export or network request. It is an audit-format fixture, separate from runtime isolation.

The synthetic canary remains a local variable. The allowed record contains operation x1, actor worker1, approval a1, policy v2, decision allow, effect local-export-1, and payload byte count. The denied x2 record has no approval and no effect, with reason approval_missing. None represents a real external export.

json.dumps serializes the list; read_text retrieves it. assert canary not in text checks literal non-disclosure in this file. json.loads reconstructs the records, and assertions inspect the allowed effect reference and denied null effect. Python None becomes JSON null during serialization. Expected PASS says the two outcomes can be reconstructed without the synthetic secret. This does not prove log access control, retention enforcement, or resistance to every transformed disclosure; those remain separate operational requirements.

Download this week’s Python lab ↓

// Quick review

Check your understanding.

Choose an answer for immediate feedback. Retry freely; a correct answer for every question unlocks the next section.

1. The denied x2 event has effect=None. What does that represent in this fixture?
2. What does Python None become in JSON serialization?
3. The synthetic canary is absent from audit.json. Which claim is supported?

Section 3.6 6 of 7

Guided comparison

Focus

Reconstruct the two fixture decisions while preserving privacy limits.

The worked allowed event connects worker1 to operation x1, approval a1, policy v2, and effect local-export-1. The denied event connects x2 to the same actor and policy but records approval_missing and no effect. A reader can therefore distinguish an authorized represented completion from a safe represented rejection without seeing the payload.

The byte-count field supplies limited diagnostic context while avoiding the secret itself. In this fixture the canary contains only ordinary single-byte characters, so len(canary) matches its UTF-8 byte count; a general logger should measure len(payload.encode('utf-8')) when reporting bytes for arbitrary text. That distinction matters for multilingual payloads.

The serialized file is checked for the literal canary before the reconstructed records are inspected. This combines privacy and usefulness: omission alone would be insufficient if the remaining record could not explain the decision. The fixture's temporary file has no independent production access policy, so its result remains a format-and-content check. A deployed audit service would add controlled writers, reader permissions, retention, deletion handling, and durable tamper evidence appropriate to its threat model.

// Quick review

Check your understanding.

Choose an answer for immediate feedback. Retry freely; a correct answer for every question unlocks the next section.

1. Why retain approval and policy identifiers while omitting the payload?
2. For arbitrary Unicode text, correct UTF-8 byte count expression?
3. A temporary audit-format fixture passes. What remains a deployment requirement?

Section 3.7 7 of 7

A debugging log containing a secret

Focus

Repair a debugging log that contains a synthetic secret without destroying needed evidence.

During a failed export test, a debug logger writes the complete payload, including a synthetic secret. The action itself was denied, but the log created another disclosure path. A successful authorization control therefore coexists with a privacy failure in observability.

The worked repair replaces raw payload logging with operation identifier, actor, policy version, destination category, payload byte count, decision, reason, and effect reference. It checks the resulting record for the synthetic secret and verifies that an investigator can still distinguish allowed, denied, and unknown outcomes. The raw sensitive copy must be handled under the applicable deletion and incident process, including backups and derived records; changing future formatting alone does not remove the existing copy.

Access to debugging features should also be controlled so a worker cannot re-enable full payload dumps to bypass redaction. Preserve necessary non-sensitive evidence of the incident rather than erasing the whole trail. This transfer closes the loop between governance and engineering: useful audit records support recovery, while deliberate minimization prevents the recovery mechanism itself from becoming an uncontrolled store of protected data.

// Quick review

Check your understanding.

Choose an answer for immediate feedback. Retry freely; a correct answer for every question unlocks the next section.

1. Export was denied but a raw debug log contains the secret. Overall result?
2. Changing future log formatting removes an existing sensitive backup automatically. Correct?
3. What should replace a full secret payload in a useful audit event?

Your personal notes

Optional, ungraded, and saved only in this browser. Export a backup from the Academy homepage to keep them.

References and further reading
Ask your own AI assistant

Copy this prompt into an assistant you already use. Nothing is sent automatically, and your personal notes are not included.

Next lesson: Designing representative evaluation sets →