#!/usr/bin/env python3
"""Check audit findings for the three-part structure (requirement, evidence, statement) and fair grading.
Input: JSON list (or CSV) of findings with keys id, grade (major/minor/ofi), clause, requirement, evidence, statement.
Checks:
AF001 high no requirement: clause or requirement text missing for a nonconformity
AF002 high no objective evidence, or evidence with nothing verifiable (no ID, date, number or location)
AF003 high graded nonconformity but worded as advice ('could be improved', 'consider') - make it an OFI
AF004 medium opinion or loaded words (poor, inadequate, sloppy, lack of commitment, I feel)
AF005 medium names a person (Mr/Ms/Dr ...): findings are about the system, not people
AF006 medium nonconformity prescribes the solution ('should implement', 'must purchase')
AF007 medium grade looks wrong: 'major' for a single lapse, or 'minor' worded as a total absence/breakdown
AF008 low vague quantities (some, several, many) without numbers
AF009 low no sample size ('3 of 12 records') in the evidence of a nonconformity
AF010 low statement over 50 words
Usage:
python finding_lint.py findings.json
python finding_lint.py findings.csv --json
Exit codes: 0 no high findings, 1 high findings, 2 read or format error.
"""
import argparse
import csv
import json
import re
import sys
ADVICE = re.compile(r"\b(could be improved|could be better|consider\w*|recommend\w*|suggest\w*|it would be good|may wish|opportunity)\b", re.I)
OPINION = re.compile(r"\b(poor(ly)?|inadequate|sloppy|careless|lazy|terrible|bad|lack of commitment|unprofessional|i feel|i think|seems|apparently|obviously|clearly)\b", re.I)
PERSON = re.compile(r"\b(Mr|Mrs|Ms|Miss|Dr)\.?\s+[A-Z][a-z]+")
PRESCRIBE = re.compile(r"\b(should|must|needs? to|shall)\s+(implement|purchase|buy|install|hire|create|introduce|use|adopt)\b", re.I)
SYSTEMIC = re.compile(r"\b(no (evidence of any|internal audits?|management review|procedure|system|records? at all)|not (been )?(established|implemented|carried out|conducted) (at all|since)|never|none of|absence of|all \d+|0 of \d+)\b", re.I)
SINGLE = re.compile(r"\b(one|1|a single|isolated)\s+(of|instance|record|gauge|case|occasion)\b", re.I)
VAGUE = re.compile(r"\b(some|several|many|various|a few|numerous|most)\b", re.I)
VERIFIABLE = re.compile(r"\d|[A-Z]{2,}-?\d|\b(station|line|cell|area|shift|machine|lathe|press)\b", re.I)
SAMPLE = re.compile(r"\b\d+\s+(of|out of)\s+\d+\b|\bsampled\b|\breviewed \d+", re.I)
def load(path):
text = sys.stdin.read() if path == "-" else open(path, encoding="utf-8-sig").read()
if text.lstrip().startswith(("[", "{")):
data = json.loads(text)
else:
data = list(csv.DictReader(text.splitlines()))
if not isinstance(data, list) or not data or not all(isinstance(d, dict) for d in data):
raise ValueError("expected a JSON list of finding objects or a CSV with a header")
return data
def lint(fd):
g = lambda k: str(fd.get(k) or "").strip()
grade = g("grade").lower()
nc = grade in ("major", "minor", "nc", "nonconformity")
ev, st, req = g("evidence"), g("statement"), g("requirement")
allt = " ".join((req, ev, st))
out = []
if nc and not (g("clause") and req):
out.append(("AF001", "high", "state the requirement: clause number and what it requires (or the procedure clause)"))
if not ev:
out.append(("AF002", "high", "no objective evidence"))
elif not VERIFIABLE.search(ev):
out.append(("AF002", "high", "evidence has nothing verifiable: add record IDs, dates, quantities or locations"))
if nc and ADVICE.search(st):
out.append(("AF003", "high", f"worded as advice ('{ADVICE.search(st).group(1)}'): if no requirement is broken, grade it OFI"))
m = OPINION.search(allt)
if m:
out.append(("AF004", "medium", f"opinion word '{m.group(1)}': state facts only"))
m = PERSON.search(allt)
if m:
out.append(("AF005", "medium", f"names a person ('{m.group(0)}'): use the role"))
if nc and PRESCRIBE.search(st):
out.append(("AF006", "medium", "prescribes a solution; the auditee owns root cause and action"))
if grade == "major" and SINGLE.search(ev) and not SYSTEMIC.search(allt):
out.append(("AF007", "medium", "graded major but evidence shows a single lapse: likely minor unless it shipped nonconforming product"))
elif grade == "minor" and SYSTEMIC.search(allt):
out.append(("AF007", "medium", f"graded minor but describes a total absence ('{SYSTEMIC.search(allt).group(0)}'): likely major"))
m = VAGUE.search(ev)
if m and not re.search(r"\d", ev):
out.append(("AF008", "low", f"vague quantity '{m.group(1)}': give the count"))
if nc and ev and not SAMPLE.search(ev):
out.append(("AF009", "low", "say how many were sampled and how many failed ('3 of 12 records')"))
if len(st.split()) > 50:
out.append(("AF010", "low", f"statement is {len(st.split())} words; keep it to one or two sentences"))
return out
def main():
ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
ap.add_argument("file", help="findings JSON or CSV, or - for stdin")
ap.add_argument("--json", action="store_true")
a = ap.parse_args()
try:
findings = load(a.file)
except (OSError, ValueError) as e:
print(f"error: {e}", file=sys.stderr)
return 2
report, high = [], 0
for i, fd in enumerate(findings, 1):
issues = lint(fd)
high += sum(s == "high" for _, s, _ in issues)
report.append({"id": fd.get("id") or i, "grade": fd.get("grade", ""), "issues": issues})
if a.json:
print(json.dumps([{**r, "issues": [dict(zip(("code", "severity", "message"), x)) for x in r["issues"]]}
for r in report], indent=2))
else:
for r in report:
print(f"{r['id']} ({r['grade'] or 'no grade'}): " + ("ok" if not r["issues"] else f"{len(r['issues'])} issue(s)"))
for code, sev, msg in r["issues"]:
print(f" {code} [{sev}] {msg}")
print(f"\n{len(report)} finding(s) checked, {high} high issue(s)")
return 1 if high else 0
if __name__ == "__main__":
sys.exit(main())
8d-problem-solving-report-writer
Write and review 8D problem-solving reports for customer complaints and serious nonconformities (automotive and aerospace practice: Ford Global 8D, VDA, GM, Stellantis formats): D0 emergency response, D1 cross-functional team and champion, D2 problem description with 5W2H and is / is-not and no cause in the statement, D3 interim containment within 24 hours with verification and clean point, D4 verified occurrence and escape (non-detection) root causes plus systemic cause, D5 permanent corrective actions for each cause verified before implementation, D6 implementation, validation with production data and removal of containment, D7 PFMEA, control plan and read-across to similar products, D8 closure and recognition. Checks an 8D discipline by discipline for missing content, human-error root causes, missing escape cause or action, late containment and dates out of order.
acceptance-sampling-plan-selector
Select and evaluate acceptance sampling plans for incoming, in-process and final inspection: ANSI/ASQ Z1.4 / ISO 2859-1 single sampling under normal inspection (code letter from lot size and inspection level I, II, III, S-1 to S-4; sample size, Ac and Re from AQL, following the table's arrows to the correct plan; 100% when n reaches the lot size; AQLs above 10 per 100 units), operating characteristic curves (Pa at any quality, producer's quality level, indifference point, LTPD, AOQ and AOQL, binomial or hypergeometric), plans designed from producer and consumer risk, and c = 0 zero-acceptance plans. Covers AQL choice by defect class, switching rules between normal, tightened and reduced inspection, when sampling is not appropriate, and random sampling.
approved-supplier-list-manager
Manage and audit an approved supplier list (ASL) / external provider register for ISO 9001 8.4.1, IATF 16949 8.4 and AS9100 8.4.1: supplier status (approved, conditional, probation, pending, disqualified), scope of approval by commodity and process, risk class, certification and expiry, re-evaluation intervals by risk, conditions with end dates, single-source contingency, approver and customer-directed sources. Audits the list for expired or expiring certificates, overdue re-evaluations, conditional or probation status past its decision date, high-risk suppliers without the required certification, single-source suppliers without backup and missing approvers, and checks purchase orders for suppliers that are off-list, disqualified or pending, or buying outside the approved scope. Covers ERP blocks, PO requirements, off-list and emergency purchases.
apqp-phase-planner
Plan and track Advanced Product Quality Planning (AIAG APQP 3rd edition, IATF 16949) for a new or changed automotive part: back-schedule the five phases (plan and define, product design, process design, product and process validation, launch and feedback) from the start-of-production date by program complexity, with overlap, PPAP lead and safe-launch period; list the deliverables and gate for each phase (DFMEA, DVP&R, feasibility, process flow, PFMEA, control plans, MSA, Ppk, run at rate, PPAP, safe launch, lessons learned); adjust for build-to-print suppliers; flag compressed timelines and late or untracked deliverables against a status list. Covers gate reviews, red/yellow/green status reporting, run at rate and safe-launch exit criteria.
as9100-gap-analyzer
Run an AS9100D / EN 9100:2018 gap analysis for aviation, space and defence suppliers on the requirements added to ISO 9001: on-time delivery and conformity focus, management representative, ethics and human-factors awareness, operational planning and operational risk management, configuration management, product safety, counterfeit-part prevention, special requirements, critical items and key characteristics, external provider register and flow-down, FOD prevention, tooling and NC program control, special process validation, first article inspection (AS9102), traceability, in-service data and nonconforming product control. Generates and scores a worksheet, grades missing core controls as major, and checks invalid n/a claims. Covers AS9101/AS9104, OASIS, AS9102 FAI forms, counterfeit standards (AS5553, AS6174, AS6081), NADCAP and the planned IA9100 transition.
audit-report-writer
Write internal, supplier and pre-certification audit reports with the content ISO 19011:2018 6.5 expects: audit objectives, scope, criteria with revisions, dates, team and auditees, method and sampling statement, specific strengths, findings table and three-part finding details (requirement, evidence, statement), conclusion on the degree of fulfilment of criteria, diverging opinions, follow-up deadlines and distribution. Builds a Markdown report from a JSON audit record, generates the conclusion from the findings (major / minor / none) and flags reports missing required content or findings without clause or evidence. Covers conclusion wording, closing meetings, response expectations and verifying corrective actions.