Zum Inhalt springen

English:Robust evaluation, AI security and governance - AI Year 9

Aus MOOCsWiki Staging
aiMOOC-Siegel aiMOOC

Robust evaluation, AI security and governance - AI Year 9

QR-Code



Introduction

An exploded diagram of a personal computer showing storage processing and other components
A computer system includes several components and boundaries. This generic hardware illustration does not depict an AI security architecture or prove that a system is protected.

An assistant can score well and still fail the cases that matter most. Compare error types, challenge untrusted source instructions and assign accountable human decisions. The examples use invented evaluation records and a pure permission simulation. No attack is attempted against a service, no private notes are read and no model or external command is executed. You will produce a baseline comparison, threat-control table and proportionate governance plan.


Compare errors rather than trusting one score

Imagine a fictional retrieval assistant whose proposed answers may need human review. The positive label means review required; a positive prediction means send for review. Define that meaning before calculating a confusion matrix, because reversing the positive label changes the interpretation of false positives and false negatives. A false negative misses a required review. A false positive creates an unnecessary review. These consequences can matter differently even when total accuracy is the same.

Our original twenty-case fixture has eighteen clear-source cases that do not require review and two damaged-source cases that do. The labels and predictions are authored teaching records, not measurements from a trained classifier or real pupil data. The baseline never requests review. It correctly handles the eighteen clear cases and misses both required-review cases, giving eighteen correct out of twenty, or ninety percent accuracy.

accuracy⁡=TP+TNTP+TN+FP+FN

A second authored candidate requests review on both damaged-source cases and on two clear cases. It has two true positives, sixteen true negatives, two false positives and no false negatives. It also gets eighteen out of twenty correct. The aggregate score is unchanged, but the pattern of errors is different. Comparing only ninety percent with ninety percent would hide this distinction.

Evaluation record TP TN FP FN Accuracy
Never-review baseline 0 18 0 2 18/20
Authored candidate 2 16 2 0 18/20

Precision asks what proportion of requested reviews were actually required. Recall asks what proportion of required reviews were requested. The candidate's precision is two over four, or one half; its recall is two over two, or one. The baseline's recall is zero over two, or zero. Baseline precision is undefined because it requests no reviews: the denominator is zero. The program reports null for that undefined value, not a fabricated zero or perfect precision.

precision⁡=TPTP+FP,recall⁡=TPTP+FN

Split the results by the declared source condition. The baseline gets all eighteen clear cases right but neither of the two damaged cases. The candidate gets sixteen clear cases right and both damaged cases right. These groups describe document conditions, not demographic characteristics of real people. A two-case group is far too small to establish a reliable future rate, and success by these two conditions does not demonstrate fairness across all users or contexts.

For an explicit illustrative cost model, assign five cost units to a missed required review and one unit to an unnecessary review. Baseline cost is ten; candidate cost is two. These weights are invented for discussion, not monetary amounts or universal ethical values. If a real setting has different consequences or review capacity, the decision may change. A cost calculation supports a declared comparison; it does not settle who should bear a harm or approve deployment.

CodeAI discusses training data and bias. Connect representation and evaluation conditions to what an aggregate score can hide. The video does not evaluate our authored fixture or certify either candidate. A responsible test plan names intended users, task, source conditions, error consequences, a simpler baseline and which new cases will be reserved before changing settings.

Attempt first: rebuild the candidate confusion matrix from the stated twenty records. Hint: label review required as positive. Partial check: four reviews are requested, but only two are needed. Explain how the candidate can improve required-review recall while leaving total accuracy unchanged. Then choose a different openly stated cost weighting and justify how it affects the comparison without claiming that the new weights are objectively correct.


Keep untrusted content outside permission decisions

The source case says that a retrieved page asks the assistant to ignore prior instructions and reveal private notes. Treat that sentence as untrusted material to inspect, not an authority that can grant access. This is a classroom description of an indirect prompt-injection risk. It is not an instruction to this course, your computer or any connected system, and you must not test it against a real service or attempt to obtain anyone's private information.

Distinguish three security ideas. Validation checks whether input has the expected form and bounds. Authentication establishes an identity through a trusted mechanism. Authorisation determines what that identity may do. A source page asserting I am the teacher is not authentication. A model proposing an action does not authorise it. A stronger prompt can be one supporting measure, but is not a substitute for independently enforced permissions and limited capabilities.

In our simulation, an enabled system permits an authenticated pupil or teacher to request a simulated read of public_rules. Only an authenticated teacher may request a simulated read of review_queue. Private_notes and every write request are denied for all roles in this tiny policy. A stopped system denies all valid requests. Unknown roles, actions or resources are denied by default. These are invented identifiers; there is no private-note file, real account or storage API behind them.

The caller supplies the authenticated flag and role. Therefore the program does not implement authentication or protect an actual account: it demonstrates what a policy decision could do after a real trusted service had established identity. In a real application, a learner or model must not be able to grant itself that trusted context. The Boolean flag is a teaching assumption, not a secure login system.

Supplied request Actual simulated decision
Authenticated pupil reads public_rules while enabled Allow simulated read
Authenticated pupil requests private_notes Deny policy
Authenticated pupil requests review_queue Deny policy
Authenticated teacher requests review_queue Allow simulated read
Unauthenticated teacher label requests public_rules Deny unauthenticated
Authenticated teacher requests a write Deny policy
Stopped system receives an otherwise permitted read Deny stopped

The complete bounded standard-library program calculates the evaluation results and these policy decisions. It returns decision labels without reading a resource or executing an action. Its fixed demonstration records contain case identifiers and decisions rather than private contents. It validates exact Boolean flags and bounded identifiers, and rejects malformed evaluation cases. Successful tests concern the declared pure functions, not a complete AI security system.

"""Fictional prediction audit and pure permission decision; no model or tool execution."""
from fractions import Fraction as F
import json


def cases(candidate=False):
    if type(candidate) is not bool:
        raise ValueError("Expected a Boolean candidate selector")
    rows = [dict(id="C" + str(i).zfill(2), condition="clear", target=False,
                 predicted=candidate and i in [1, 2]) for i in range(1, 19)]
    rows += [dict(id="R" + str(i).zfill(2), condition="damaged", target=True,
                  predicted=candidate) for i in [1, 2]]
    return rows


def fraction(numerator, denominator):
    return str(F(numerator, denominator)) if denominator else None


def evaluate(rows):
    if not isinstance(rows, list) or len(rows) not in range(1, 201):
        raise ValueError("Expected one to two hundred evaluation cases")
    seen = set()
    counts = dict(tp=0, tn=0, fp=0, fn=0)
    conditions = dict()
    for row in rows:
        if not isinstance(row, dict):
            raise ValueError("Expected evaluation records")
        if (not all(isinstance(row.get(k), str) and row[k] for k in ["id", "condition"])
                or type(row.get("target")) is not bool
                or type(row.get("predicted")) is not bool or row["id"] in seen):
            raise ValueError("Expected unique identity condition and exact Boolean labels")
        seen.add(row["id"])
        target, prediction = row["target"], row["predicted"]
        key = "tp" if target and prediction else "fn" if target else "fp" if prediction else "tn"
        counts[key] += 1
        group = conditions.setdefault(row["condition"], dict(total=0, correct=0))
        group["total"] += 1
        group["correct"] += int(target == prediction)
    for group in conditions.values():
        group["accuracy"] = fraction(group["correct"], group["total"])
    return dict(counts=counts, accuracy=fraction(counts["tp"] + counts["tn"], len(rows)),
                precision=fraction(counts["tp"], counts["tp"] + counts["fp"]),
                recall=fraction(counts["tp"], counts["tp"] + counts["fn"]),
                illustrative_cost=5 * counts["fn"] + counts["fp"], conditions=conditions)


def decide(enabled, authenticated, role, action, resource):
    if type(enabled) is not bool or type(authenticated) is not bool:
        raise ValueError("Expected exact Boolean state flags")
    if not all(isinstance(x, str) and 1 <= len(x) <= 40 for x in [role, action, resource]):
        raise ValueError("Expected bounded policy identifiers")
    if not enabled:
        return "DENY_STOPPED"
    if not authenticated:
        return "DENY_UNAUTHENTICATED"
    if action == "read" and resource == "public_rules" and role in ["pupil", "teacher"]:
        return "ALLOW_SIMULATED_READ"
    if action == "read" and resource == "review_queue" and role == "teacher":
        return "ALLOW_SIMULATED_READ"
    return "DENY_POLICY"


def demonstrate():
    requests = [dict(case="public", enabled=True, authenticated=True, role="pupil", action="read", resource="public_rules"),
                dict(case="private_request", enabled=True, authenticated=True, role="pupil", action="read", resource="private_notes"),
                dict(case="review_pupil", enabled=True, authenticated=True, role="pupil", action="read", resource="review_queue"),
                dict(case="review_teacher", enabled=True, authenticated=True, role="teacher", action="read", resource="review_queue"),
                dict(case="unauthenticated", enabled=True, authenticated=False, role="teacher", action="read", resource="public_rules"),
                dict(case="write", enabled=True, authenticated=True, role="teacher", action="write", resource="public_rules"),
                dict(case="stopped", enabled=False, authenticated=True, role="teacher", action="read", resource="public_rules")]
    results = [dict(case=r["case"], decision=decide(r["enabled"], r["authenticated"], r["role"], r["action"], r["resource"])) for r in requests]
    return dict(baseline=evaluate(cases()), candidate=evaluate(cases(True)), gate_cases=results,
                predictions_authored_not_model_generated=True, condition_groups_not_personal_demographics=True,
                authentication_implemented=False, private_notes_read=False, tools_executed=False)


if __name__ == "__main__":
    print(json.dumps(demonstrate(), indent=2))

Now make the source-case trace explicit. The retrieved sentence proposes revealing private_notes. A proposed read of that resource reaches the independent policy function and is denied. The source's words do not change the allowed-resource list or authenticate a different role. An event review could record a minimal case identifier, denied-action category and outcome, then refer the incident to a responsible person. Our routine does not implement durable audit storage, monitoring or escalation, and it never copies actual notes into a log.

CodeAI introduces cybersecurity and crime. Use the discussion to connect human behaviour and technical controls without assuming that this short simulation covers all threats. Only perform exercises with the supplied fictional records or a teacher-approved isolated environment. The course contains no exploit against a target and no request for credentials, learner records or private material.

Predict first: an unknown role requests a read of public_rules. Even when enabled and given a true authenticated flag, the policy denies it. Next, set enabled to false for a teacher's otherwise permitted review request: the decision is deny stopped. Keep these expected and actual outcomes separate from the unanswered real-world questions of identity verification, integration, logging and recovery.


Pair threats with controls and accountable review

Security, usefulness and fairness are related but different questions. An accurate classifier can have excessive access. A locked-down assistant can still give a poor answer. Good governance connects purpose, affected people, test evidence, decision authority and a way to challenge or stop a system. The NIST AI Risk Management Framework is voluntary risk-management guidance; it is not a certificate of safety or a substitute for the actual requirements of an organisation and its context.

For the fictional library assistant, identify what could go wrong before choosing a control. Use three distinct threat-control pairs, with a test and a limitation for each. Do not describe a planned security review as a completed penetration test, and do not confuse malformed data with malicious intent: a mistake and an attack can sometimes produce the same visible symptom.

Threat or failure route Proposed control Test and current evidence Remaining limitation
Indirect prompt injection in a retrieved passage asks for private notes Keep source text as data and enforce a separate deny-by-default capability policy The executed pure gate denies private_notes and all writes No real authentication, model integration or resource access is tested
Poisoned or unauthorised source changes an apparent rule Maintain a reviewed corpus, provenance and version-change approval Plan a copy-only fixture change and check whether review notices the discrepancy A permission label alone does not prove the source is authentic; this course implements no general poisoning detector
Adversarially altered or unfamiliar input causes a missed required review Use reserved condition tests, error analysis, human fallback and monitoring The actual twenty-case audit shows the baseline misses both damaged cases Authored predictions and two damaged cases cannot establish robustness on future inputs

Poisoning concerns contamination of data or an evidence collection; it need not look like a direct command. An adversarial input can instead target a particular prediction or use condition. The controls therefore need different tests. Review provenance and changes for a source collection; examine varied inputs and consequences for an evaluated function; restrict access separately for proposed actions. OWASP's prompt-injection guidance explains why RAG does not by itself eliminate that risk. Our examples illustrate defensive boundaries, not universal detection or prevention.

Build an original governance card for the fictional project. Its purpose is to help locate public library information, not to make automatic disciplinary or grading decisions. The content owner approves source versions. A named operational role reviews errors and can stop the service. A responsible teacher decides whether a proposed classroom use is appropriate. Affected learners can report a misleading answer and request correction or human help. These are proposed roles in an invented plan, not appointments of real staff.

Record release conditions before looking for a favourable result. For example, require the source owner to resolve conflicting policy versions, a reviewer to inspect the relevant reserved cases, and an access test to deny private resources. Include a workable fallback to the actual responsible person or original information source. The two observed candidate false positives may add review workload; assess that burden rather than treating perfect recall on two examples as an automatic approval.

Consider a new stakeholder: a reader using an unsupported language or an accessibility aid. The present two condition groups do not test their experience. Add an accessible way to ask for help, evaluate relevant permissioned or invented cases with suitable review, and avoid inferring individual ability from a technical failure. If a proposed new data field contains private learner notes, question whether it is necessary at all. Data minimisation and restricted access can remove an unnecessary risk instead of trying to repair it with a stronger prompt.

For an incident, preserve enough non-sensitive evidence to understand the failure, stop an affected feature when appropriate, notify the responsible role and check the correction before resuming. Avoid dumping full conversations, private notes or credentials into routine logs. Our program's decision labels demonstrate a minimal record style, but it does not implement real notifications, persistent incident handling, deletion policies or a restart controller.

Transfer task: adapt the plan to a fictional museum catalogue that assists visitors. Recheck purpose, users, language, data permissions, source authority, error consequences and who can challenge or stop it. The arithmetic and deny-by-default principle can transfer, while roles, acceptable uses, review capacity and accessibility checks need redesign. Do not turn the school fixture's cost weights into a universal rule.

This course is editorial Year 9 enrichment linked to the GCSE computing source objective about validation and authentication. It teaches their distinction and a simulated policy boundary; it does not award a qualification or demonstrate production authentication. The complete evidence includes baseline and candidate errors, condition results, three threat-control pairs, explicit limits and a human decision route. No disclaimer or ninety-percent score replaces that accountable review.


Interactive Tasks


Quiz: Test Your Knowledge

What is the positive label in the twenty-case fixture? (Review required) (!Every answer is factually correct) (!The source is a real school record) (!The system is authorised to read private data)



How many required reviews does the never-review baseline miss? (Two) (!Zero) (!Eighteen) (!Twenty)



Why do the two authored evaluations both have ninety percent accuracy? (Each has eighteen correct cases with different errors) (!Their false positive and false negative counts are identical) (!Both have perfect recall on required reviews) (!Accuracy authenticates the user)



What is the candidate precision? (One half) (!One) (!Zero) (!Eighteen twentieths)



How should baseline precision be reported when no reviews are requested? (Undefined because the denominator is zero) (!Perfect because there are no requests) (!Automatically equal to recall) (!Ninety percent by definition)



What does a retrieved request to reveal private notes provide? (Untrusted content to inspect) (!Authentication as the teacher) (!Permission to override the policy) (!A real protected-note file in this course)



What does the pure gate do for an authenticated pupil requesting private_notes? (Deny policy) (!Read and print real notes) (!Change the role to teacher) (!Ask the model to authorise itself)



What does the program implement about authentication? (It assumes a supplied flag without implementing identity verification) (!A secure login service for real pupils) (!Automatic trusted identity from a retrieved sentence) (!A production password store)



What does an overall high score establish about security? (It does not replace separate access and threat checks) (!It guarantees no prompt injection can occur) (!It makes every future source authentic) (!It removes the need for accountable humans)



Which governance feature supports a responsible fictional use? (A clear owner human challenge route and stop decision) (!An attractive disclaimer with no decision authority) (!An automatic release after any favourable example) (!Logging every private note for convenience)





Memory Game

Validation Checking expected input form and bounds
Authentication Establishing an identity through a trusted mechanism
Authorisation Deciding what an established identity may do
False negative Missing a case that requires review
Prompt injection Untrusted input attempts to redirect model behaviour
Governance Accountable purposes roles decisions and review routes





Drag and Drop

Compare with a never-review method Establish a baseline
Separate missed and unnecessary reviews Analyse error types
Prevent a retrieved page granting capabilities Enforce an independent policy
Review source origin and approved changes Check provenance
Name who can challenge correct and stop the service Assign accountable oversight





Crossword Puzzle

RECALL The share of required reviews actually requested
PRECISION The share of requested reviews actually needed
BASELINE A simpler method for comparison
VALIDATION Checking input form and bounds
AUTHENTICATION Establishing identity through a trusted mechanism
GOVERNANCE Accountable human purposes decisions and oversight





LearningApps

Optional extra practice. Choose an appropriate activity with your teacher. If the external collection is unavailable, use the native activities and independent tasks in this course.


Cloze Text

Complete the explanation.
The simple comparison method is a

. A missed required review is a false

. An unnecessary review is a false

. The two fixtures have equal overall

. Required-review coverage is measured by

. A source page cannot grant

. Establishing identity is

. Input format checking is

. Untrusted source instructions can be prompt

. A stopped simulation must

requests. The code executes no external

. Responsible use needs accountable human

.



Open Tasks


Easy

  1. Label a confusion matrix: Mark review required as positive and fill the baseline table from the twenty-case description. Hint: all eighteen clear cases are true negatives. Explain what the two missed cases mean.
  2. Compare equal scores: Draw two bars labelled eighteen out of twenty, then annotate their different errors. State why equal accuracy does not mean equal consequences or equal required-review coverage.
  3. Separate security terms: Use original fictional examples to distinguish validation authentication and authorisation. Explain why a retrieved sentence claiming to be the teacher cannot establish trusted identity.
  4. Trace the denied request: Draw the route from the untrusted private-note request to the separate policy decision. Keep the message as data and state that no real resource is opened in the exercise.


Standard

  1. Calculate precision and recall: Recompute the candidate precision recall and both condition accuracies. Hint: four reviews are requested. Explain the baseline undefined precision without replacing it by a convenient number.
  2. Test the policy boundary: Predict public read pupil review-queue read teacher review-queue read and stopped-system outcomes before inspecting the code. Record expected and actual labels and the assumed trusted context.
  3. Complete three threat-control pairs: For injection poisoned evidence and unfamiliar inputs specify a control test and remaining limitation. Separate the two executed functions from the provenance and monitoring work that remains planned.
  4. Draft a governance card: Name fictional purpose source owner operational reviewer challenge route stop authority and fallback. Include the workload from unnecessary reviews and an unresolved question that prevents automatic release.


Advanced

  1. Change the declared costs: Calculate both fixture costs for a different justified pair of missed-review and unnecessary-review weights. Explain whose consequences the weights represent and why numbers alone cannot approve the use.
  2. Introduce an affected user: Add a fictional reader using an unsupported language or accessibility aid. Identify what the existing cases do not test and propose a proportionate accessible evaluation and human help route without collecting personal learner data.
  3. Audit the integration assumption: Explain how a pure policy could fail to protect a real service if an untrusted caller could set the authenticated flag or bypass the gate. Propose independent controls and tests without attacking any real system.
  4. Transfer and communicate limits: Adapt the project to an invented museum catalogue in an original poster or short narrated diagram with a text transcript. Keep three threat-control pairs baseline evidence human challenge and stop route, and state which responsibilities and conditions need redesign.



Learning Check

  1. Reconstruct both evaluations: Give baseline and candidate confusion counts and explain equal accuracy.
  2. Interpret metrics and conditions: Calculate candidate precision recall and condition results, including the baseline boundary.
  3. Use costs with explicit assumptions: Compare the two methods under the illustrative five-to-one weighting.
  4. Explain an independent boundary: Handle the untrusted request and distinguish actual code from authentication.
  5. Provide three tested threat-control pairs: Connect each failure route to a distinct control and evidence limit.
  6. Assign accountable oversight and transfer: What belongs in the governance plan and what must change for a museum catalogue?


Worked checks and assessment guidance

  1. The baseline has TP zero TN eighteen FP zero FN two. The candidate has TP two TN sixteen FP two FN zero. Both have eighteen correct out of twenty or nine tenths accuracy, but the candidate catches both required-review cases while adding two unnecessary reviews. These predictions are authored rather than obtained from a model.
  2. Candidate precision is two over four or one half and recall two over two or one. Its clear-condition accuracy is sixteen over eighteen or eight ninths and damaged-condition accuracy two over two or one. Baseline clear accuracy is one and damaged accuracy zero; recall is zero. Baseline precision is undefined because no positive predictions exist. Two damaged cases do not establish a reliable future rate or demographic fairness.
  3. Five times two missed baseline reviews plus zero unnecessary reviews gives ten units. The candidate has no missed reviews and two unnecessary reviews so cost is two. These are fictional consequence weights, not money or a universal ethical rule. Another setting may have different harms review capacity and acceptable uses.
  4. A retrieved request to reveal private_notes cannot authenticate a role or grant permission. The separate pure policy denies that resource and every write, permits only the declared simulated reads, and denies valid requests when stopped. It receives a supplied authenticated flag and implements no login resource read external command or complete model integration. A real trusted server must establish identity and enforce the boundary.
  5. For indirect injection, separate source text from capability decisions and test denied private requests; only the pure gate is executed. For poisoned evidence, review provenance and approved version changes with an isolated planted discrepancy; no general detector is implemented. For unfamiliar or adversarial inputs, analyse condition errors reserved cases human fallback and monitoring; the authored twenty-case audit is limited evidence rather than future robustness.
  6. State intended purpose users data source owner error reviewer decision and stop authority human challenge route release conditions and fallback. Recheck language accessibility permissions authority error consequences and review capacity for the new context. Minimise unnecessary private fields and avoid sensitive raw logs. A disclaimer high aggregate accuracy or stronger prompt cannot replace independent access controls evidence and accountable humans.


Learning evidence

Retain both labelled confusion matrices, precision and recall with the undefined-denominator case, condition-level results and declared cost comparison. Add expected and actual pure-gate decisions, the authentication-versus-authorisation distinction, three threat-control pairs and a governance card with challenge stop and fallback routes. Distinguish authored predictions from model performance, a supplied trusted flag from implemented authentication and planned security controls from completed production tests.


OER and Wikipedia

OWASP GenAI Security Project: LLM01 Prompt Injection, direct and indirect injection and mitigation context, inspected 15 November 2026. Retrieved material can affect model behaviour and RAG does not itself remove the vulnerability. Our independent capability policy is a limited teaching simulation rather than complete prevention.

NIST AI Risk Management Framework, overview inspected, describes voluntary risk management for AI design development use and evaluation. NIST AI 600-1 Generative AI Profile supplies additional risk-and-oversight context. These sources do not certify the example or approve a real service.

DfE GCSE subject content for computer science, updated 31 March 2025, Skills security-techniques objective, inspected. The Year 9 AI route is editorial enrichment, not a Year-specific statutory requirement or a qualification. Validation authentication and authorisation are distinguished; actual identity verification is not implemented by the code.

Personal computer, exploded.svg, Gustavb, CC BY 2.5. Image embedded unchanged as a generic system-component illustration, not an AI threat diagram or proof of security. Original source metadata and preview hash are retained.

https://www.youtube.com/watch?v=AuYNXgO_f3Y — CodeAI: The Internet, Cybersecurity and Crime. https://www.youtube.com/watch?v=x2mRoFNm22g — CodeAI: AI Training Data and Bias. Actual retained video records embedding availability and preview bytes were checked and previews visually inspected. Unchanged external embeds imply no transcript copying endorsement or relicensing. Required explanations are also in text.

The twenty-case labels predictions error-cost weights policy identifiers role assumptions and governance plan are original fictional teaching constructions. The standard-library evaluator and pure decision function were actually executed. No model was trained or queried; no attack against a real target, private-note read, external command or production authentication occurred. Author checks are not independent expert certification, and no local generative model paid API or personal learner data is used.


Linked learning areas


aiMOOC Projects



Schulfach+




aiMOOCs



aiMOOC Projekte









MOOCwiki · Deutsch

Nach dem Lernen ist vor dem Lernen

Entdecke direkt den nächsten Lernkurs. Weitere Inhalte erscheinen, wenn Du weiter nach unten scrollst.

Zur MOOCwiki-Hauptseite

Mediathek

Suche verfeinern

Dein Lernplan bestimmt, was oben steht. Alle anderen Inhalte bleiben erreichbar. Seitenaufrufe beeinflussen die Auswahl nicht.

Inhalte werden geladen ...

Mediathek wird aus dem Wiki geladen ...