Gate the feedback loop, and match human control to impact and volume
Task
Apply the live half of the life cycle. Feedback is where the cycle becomes a loop and where it is most exposed, so build a gate that treats user feedback as untrusted input: it quarantines a coordinated push, admits the rest, and samples what it admits for human validation. Record a monitoring baseline from your own gateway log, and assign the right human arrangement to six actions an AI system might take.
Steps
- Write
~/secai-lab/lab/make-feedback.py. Withrandom.seed(11), write~/secai-lab/lab/feedback.jsonl: 45 ordinary records from twelve users spread over seven days, and 15 planted ones from three users first seen that day (fb-new-1tofb-new-3), all inside ten minutes and all carrying the same correction: Refunds are available for 365 days, no receipt needed. Each record hasid,ts,user,question,rating(upordown),correction(often empty) andplanted(true or false), which the gate must never read. - Write
~/secai-lab/lab/feedback-gate.py. Quarantine any record whose non-empty correction, after lower-casing and trimming, was submitted by three or more distinct users within 30 minutes, and any correction from a user first seen within that same window. Write the rest tolab/feedback-admitted.jsonland the quarantined records tolab/feedback-quarantined.jsonl. - Human validation by sampling: write
~/secai-lab/lab/feedback-review-sample.csvwith headerid,user,correction,reviewer_verdict, holding a random 10% (rounded up) of the admitted records, and fillreviewer_verdictyourself by checking each correction against the documents indocs/. - Monitoring baseline: write
~/secai-lab/lab/baseline.py, which readslogs/gateway.jsonland writes~/secai-lab/lab/baseline.jsonwithupto_ts(the latesttsit read),requests,distinct_users,mean_prompt_tokensandmax_latency_ms. Records with a null token count are skipped for the mean. - Write
~/secai-lab/lab/human-oversight.csvwith headerid,action,arrangement,arrangementbeingin-the-loop,oversightorvalidation, for: H1 an agent proposes a firewall rule change; H2 a triage model routes 2,000 tickets a day while an analyst watches the queues and can pause it; H3 a weekly audit of fifty chatbot answers against the source documents; H4 a refund over a set threshold drafted by a model; H5 a summariser running continuously over alerts with a working stop control; H6 a decision about an individual's access, proposed by a model.
Verify
cd ~/secai-lab
python - <<'EOF'
import csv, json, math
def load(p):
return [json.loads(l) for l in open(p, encoding="utf-8") if l.strip()]
adm, qua = load("lab/feedback-admitted.jsonl"), load("lab/feedback-quarantined.jsonl")
print("planted quarantined:", sum(r["planted"] for r in qua), "of 15")
print("planted admitted:", sum(r["planted"] for r in adm))
print("ordinary quarantined (false positives):", sum(not r["planted"] for r in qua))
sample = list(csv.DictReader(open("lab/feedback-review-sample.csv", encoding="utf-8")))
print("review sample:", len(sample), "expected", math.ceil(len(adm) / 10), "- unreviewed:", sum(not r["reviewer_verdict"] for r in sample))
b = json.load(open("lab/baseline.json"))
n = sum(1 for r in load("logs/gateway.jsonl") if r["ts"] <= b["upto_ts"])
print("baseline requests", b["requests"], "recomputed", n, "PASS" if b["requests"] == n else "FAIL")
h = {r["id"]: r["arrangement"] for r in csv.DictReader(open("lab/human-oversight.csv", encoding="utf-8"))}
print("arrangements:", " ".join(k + "=" + h.get(k, "?") for k in ("H1", "H2", "H3", "H4", "H5", "H6")))
EOF
Fifteen of fifteen planted records quarantined, none admitted, and ordinary records quarantined ideally 0 and at most 3; a review sample of the expected size with nothing unreviewed; a baseline PASS; and arrangements H1=in-the-loop H2=oversight H3=validation H4=in-the-loop H5=oversight H6=in-the-loop. A gate that admits even one planted record has let a coordinated group write the next version's training data.
Notes
The rule keyed on matching corrections is deliberately simple, and a patient attacker would vary the wording. That is why the human review sample exists alongside it: the gate removes the cheap campaign, and sampling against the source documents catches what wording changes slip past. Keep baseline.json: it records the log before domain 2's controls went in, and lesson 15's applied lab builds its per-user baseline beside it, in monitor-baseline.json.
This is an independent study companion for CompTIA SecAI+ CY0-001 and is not produced by or endorsed by CompTIA.