A photo-based creative workflow often has more than a technical input and an output. Someone chooses the source pictures, decides whether the people pictured agreed to a particular use, reviews a provider's retention terms, and decides who should see the resulting image. Those decisions are easy to lose when a prototype reduces the workflow to a single Upload button. A small local check can make missing review steps visible, even though software cannot decide whether a person's consent is meaningful.
This article builds a deliberately narrow Python example for a fictional review record. It does not read photographs, determine whether a person consented, contact an image service, or establish legal compliance. The example and tests use synthetic booleans and labels. I am associated with AI Baby Generator, and AI assisted in preparing this article and code. The browser-based tool at https://ai-baby-generator.org/ creates imagined baby or child portraits from two adult photos, with age, gender and resemblance options. The code below is a standalone teaching example, not a feature of that product or a test of its privacy practices. Generated portraits are illustrations, not genetic predictions.
Start with a decision, not a database schema
The example has one goal: flag a few missing decisions before a fictional image is shared. It is not intended to serve as a consent management system. A real team needs to establish which people can make a decision, how they are informed, what purpose is covered, and how withdrawal is handled. Those questions depend on the context and cannot be answered by choosing field names in a tutorial.
For a small workshop exercise, however, a review record can illustrate the difference between missing information and a positive answer. We will use two permission indicators, an audience category, a synthetic-image label and an indicator that the retention terms were reviewed. The fields are deliberately limited. They do not contain names, photographs, email addresses, documents, or any other identifying information.
This distinction matters because a sample that records sensitive information tends to become an accidental template. Teams may copy the schema without deciding how long to keep the values, who can see them, or whether they should be stored at all. Treat even a metadata record as potentially sensitive in a real system: it may become identifying when joined with a user account or a timestamp.
Define the example contract
The adult_permissions field is a list of exactly two booleans. This represents two separate adult-source-photo review decisions in the fictional exercise. The value True does not prove that a person gave informed, voluntary permission. It merely records that a reviewer marked the step complete. The checker deliberately rejects an integer such as 1, even though Python normally treats it as truthy, because accepting loosely typed values would hide a contract error.
The audience field accepts private, named-group, or public. A named group might mean a specific family chat in an example, while public means an unrestricted audience. These labels do not describe every possible sharing arrangement. An application that uses them would need to define their meanings clearly and test the actual access controls separately. A label in a record cannot prevent a file from being forwarded.
The label field accepts synthetic or unlabelled. For the exercise, any image shared beyond a private context should carry the synthetic label. This is a product decision used to demonstrate cross-field validation, not a universal legal rule. The retention_reviewed value asks whether the reviewer inspected the current terms. It does not record a retention period or assert that deletion will happen.
A small checker
The function returns stable reason codes rather than raising an exception for an incomplete record. A user interface could translate these codes into clear messages without logging the original record. The example keeps all data in memory and makes no network calls. That property applies to this function only: an application, its runtime, telemetry, backups, and the operating system can still retain data elsewhere.
"""Check a small, fictional portrait-sharing review record; no image processing."""
ALLOWED_AUDIENCES = {"private", "named-group", "public"}
ALLOWED_LABELS = {"synthetic", "unlabelled"}
def review(record):
"""Return stable reason codes; this is not proof of consent or compliance."""
if not isinstance(record, dict):
return ["invalid_record"]
issues = []
adults = record.get("adult_permissions")
if not isinstance(adults, list) or len(adults) != 2:
issues.append("two_permissions_required")
elif any(value is not True for value in adults):
issues.append("permissions_not_confirmed")
audience = record.get("audience")
if audience not in ALLOWED_AUDIENCES:
issues.append("invalid_audience")
label = record.get("label")
if label not in ALLOWED_LABELS:
issues.append("invalid_label")
elif audience in {"named-group", "public"} and label != "synthetic":
issues.append("shared_image_needs_label")
if record.get("retention_reviewed") is not True:
issues.append("retention_not_reviewed")
return issues
The check uses identity comparisons such as value is not True rather than a truthiness test. It also validates the audience and label against explicit sets. An unknown audience is not silently treated as private. When a field is invalid, the result includes an error for that field. The shared-label rule runs only for recognized shared audiences; this avoids reporting a misleading second error based on an invalid category.
Returning a list allows a form to show several actionable items at once. Keep the distinction between validation and authorization: an empty list means only that this particular sample has no detected contract issues. It does not mean the user has legal permission, the image is safe, the provider will delete data, or a recipient will honor an agreement. Avoid a success message such as “consent verified.” A more accurate message is “review fields completed; confirm the underlying decisions separately.”
Exercise synthetic cases
These unit tests run against fabricated records. They check a complete private example, the shared-label rule, missing permission entries, strict boolean handling, a non-dictionary input and several invalid values. They do not access an image or a service. The names are intentionally generic so the fixtures can be read without presenting them as real people.
import unittest
from portrait_review_check import review
class ReviewTests(unittest.TestCase):
def test_complete_private(self):
self.assertEqual(review({"adult_permissions": [True, True], "audience": "private", "label": "unlabelled", "retention_reviewed": True}), [])
def test_public_needs_label(self):
result = review({"adult_permissions": [True, True], "audience": "public", "label": "unlabelled", "retention_reviewed": True})
self.assertEqual(result, ["shared_image_needs_label"])
def test_missing_permission(self):
self.assertIn("two_permissions_required", review({"adult_permissions": [True], "audience": "private", "label": "synthetic", "retention_reviewed": True}))
def test_integer_is_not_consent(self):
self.assertIn("permissions_not_confirmed", review({"adult_permissions": [True, 1], "audience": "private", "label": "synthetic", "retention_reviewed": True}))
def test_invalid_record(self):
self.assertEqual(review(None), ["invalid_record"])
def test_unknown_fields_and_missing_review(self):
self.assertEqual(review({"adult_permissions": [True, True], "audience": "unknown", "label": "other"}), ["invalid_audience", "invalid_label", "retention_not_reviewed"])
if __name__ == "__main__":
unittest.main()
Place the checker in portrait_review_check.py and the tests in test_portrait_review_check.py, then run python3 -m unittest test_portrait_review_check -v from the directory containing both files. The six synthetic tests passed locally while preparing this example. That verifies the specific cases shown, not a production deployment, a browser integration, or an external provider. Add tests for your own input boundaries before relying on a modified version.
A useful next test would verify that a public record with label set to synthetic does not trigger the shared-label warning. Another would check that a missing key and a key with the wrong type produce an understandable result. If a project later adds more audience values, test them explicitly rather than assuming all unrecognized strings are safe. Keep fixtures synthetic and avoid adding real image paths just to make a unit test feel realistic.
Separate rules from evidence
This example accepts a reviewer's boolean assertion, but it does not validate the process behind it. In an actual application, the consent interaction might involve a clear explanation of the proposed use, a way to decline, and a way to change a decision before sharing. The appropriate process depends on the relationship, the people involved and the applicable rules. A validator cannot establish that an adult understood the implications or that the same permission covers a later audience.
Likewise, a checked retention_reviewed value is not evidence of a provider's behavior. Terms can change, and a service may distinguish between deletion from an account, removal from backups and use for improving a model. A team should inspect the actual current documentation and design its own deletion workflows around observed capabilities. Do not infer retention guarantees from this toy function or from a product screenshot.
A practical interface can ask the reviewer to revisit a decision when the audience changes. Moving an image from a private draft to an unrestricted page is a meaningful change, even if the image itself is identical. Instead of automatically carrying over a previous “yes,” show the new audience and ask the people involved again when appropriate. Keep the explanation close to the action so that users do not need to infer what a broad checkbox covers.
Make errors usable without oversharing
Reason codes are intended to be translated into ordinary language. For example, two_permissions_required could become “Review permission for both adult source photos.” Avoid printing the record into application logs when validation fails. If a diagnostic must be stored, consider whether a coarse code and a short retention period are enough. Access to those logs should be limited, and even counts can be identifying in a small group.
Do not include an image URL, filename, identity, or consent narrative in an error by default. A stable error code helps a developer diagnose a branch without replicating the underlying personal data across systems. This is only one part of a broader design: it does not replace a threat model, access control review, incident response plan or applicable professional advice.
Use the exercise responsibly
The sample is most useful as a conversation starter in a code review. Ask what each field really means, which missing states are possible, and what a user might misunderstand. Then compare the sample with the actual product and policy requirements rather than copying it into production. For a portrait generator, an especially important boundary is that visual similarity is not evidence about a real future child or inherited characteristics.
If you adapt the checker, keep its limitations visible in documentation and in the user interface. A few explicit states and a small test suite can expose missing decisions, but they cannot manufacture permission or guarantee a private outcome. Treat the code as a starting point for better questions, not as the final answer to them.
Top comments (0)