#!/usr/bin/env python3
"""Check a supplier corrective action request (SCAR) and evaluate the supplier's response: accept or reject.
SCAR JSON keys:
scar_id, supplier, part, issued (YYYY-MM-DD), ncr_ref,
problem {requirement, actual, quantity, evidence}
due {containment, root_cause, closure} (dates)
response {containment, containment_date, clean_point, occurrence_cause, escape_cause, cause_verification,
actions: [{action, addresses: occurrence|escape, due}], effectiveness, fmea_control_plan, read_across,
root_cause_date, closure_date}
Request checks:
SR001 high problem lacks requirement, actual result, quantity or evidence
SR002 medium response due dates missing or loose (containment > 2 days, root cause > 15 days, closure > 60 days)
Response checks (when 'response' is present):
SR101 high no containment of stock at the supplier, in transit and at the customer, or no clean point
SR102 high occurrence or escape cause missing, or 'human error' / 'operator' blame
SR103 high actions are only corrections or training
SR104 medium cause not verified, or no effectiveness plan
SR105 medium PFMEA / control plan not updated, or no read-across to similar parts and lines
SR106 medium response steps later than the due dates
Verdict: ACCEPT (no high, no medium), ACCEPT WITH COMMENTS (medium only), REJECT (any high).
Usage:
python scar_check.py scar.json
Exit codes: 0 request complete and response accepted (or no response yet), 1 rejected / incomplete, 2 read error.
"""
import argparse
import datetime as dt
import json
import re
import sys
BLAME = re.compile(r"\b(human|operator|worker)\s+(error|mistake)|\bnot trained|\bcareless|\bforgot\b|\binattention\b", re.I)
WEAK = re.compile(r"\b(retrain|train|remind|re-?brief|warn|be careful|sort(ed)?|rework(ed)?|scrap(ped)?|replace(d)?|100% inspection)\b", re.I)
STRONG = re.compile(r"poka|error[- ]?proof|fixture|sensor|interlock|automat|redesign|design change|spc|control chart|vision|go/?no-?go", re.I)
def date(s):
try:
return dt.date.fromisoformat(str(s)[:10])
except (TypeError, ValueError):
return None
def check(s):
f = []
pr = s.get("problem") or {}
miss = [k for k in ("requirement", "actual", "quantity", "evidence") if not pr.get(k)]
if miss:
f.append(("SR001", "high", f"problem lacks {', '.join(miss)}: the supplier cannot investigate without them"))
issued, due = date(s.get("issued")), s.get("due") or {}
limits = {"containment": 2, "root_cause": 15, "closure": 60}
for k, lim in limits.items():
d = date(due.get(k))
if not d:
f.append(("SR002", "medium", f"no {k.replace('_', ' ')} due date"))
elif issued and (d - issued).days > lim:
f.append(("SR002", "medium", f"{k.replace('_', ' ')} due {(d - issued).days} days after issue (typical <= {lim})"))
r = s.get("response")
if not r:
return f, False
cont = str(r.get("containment") or "").lower()
gaps = [x for x in ("supplier", "transit", "customer") if x not in cont]
if not cont or gaps or not r.get("clean_point"):
what = ", ".join(gaps) if cont else "everything"
f.append(("SR101", "high", f"containment must cover stock at supplier, in transit and at customer (missing: {what})"
+ ("" if r.get("clean_point") else "; define the clean point (first certified shipment)")))
for leg in ("occurrence", "escape"):
c = str(r.get(f"{leg}_cause") or "")
if not c:
f.append(("SR102", "high", f"no {leg} root cause" + (" (why was it not detected before shipping?)" if leg == "escape" else "")))
elif BLAME.search(c):
f.append(("SR102", "high", f"{leg} cause '{c[:50]}' blames a person: why did the process allow it?"))
acts = r.get("actions") or []
strong = [x for x in acts if STRONG.search(str(x.get("action", "")))]
if not acts or (all(WEAK.search(str(x.get("action", ""))) for x in acts) and not strong):
f.append(("SR103", "high", "actions are corrections or training only: require error-proofing, process or design changes"))
for leg in ("occurrence", "escape"):
if acts and not any(str(x.get("addresses", "")).lower() == leg for x in acts):
f.append(("SR103", "high", f"no action addresses the {leg} cause"))
if not r.get("cause_verification"):
f.append(("SR104", "medium", "root cause not verified (reproduce it, switch it on/off, data)"))
if not r.get("effectiveness"):
f.append(("SR104", "medium", "no effectiveness plan (measure, period, target)"))
if not r.get("fmea_control_plan"):
f.append(("SR105", "medium", "PFMEA and control plan updates not shown"))
if not r.get("read_across"):
f.append(("SR105", "medium", "no read-across to similar parts, lines or sites"))
for k, rk in (("containment", "containment_date"), ("root_cause", "root_cause_date"), ("closure", "closure_date")):
d, got = date(due.get(k)), date(r.get(rk))
if d and got and got > d:
f.append(("SR106", "medium", f"{k.replace('_', ' ')} response {(got - d).days} days late"))
return f, True
def main():
ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
ap.add_argument("scar", help="SCAR JSON, or - for stdin")
a = ap.parse_args()
try:
s = json.load(sys.stdin if a.scar == "-" else open(a.scar, encoding="utf-8"))
if not isinstance(s, dict):
raise ValueError("SCAR JSON must be an object")
except (OSError, ValueError) as e:
print(f"error: {e}", file=sys.stderr)
return 2
f, has_resp = check(s)
print(f"SCAR {s.get('scar_id', '?')} to {s.get('supplier', '?')} for {s.get('part', '?')}")
for code, sev, msg in f:
print(f"{code} [{sev}] {msg}")
req_bad = any(c.startswith("SR00") and sv == "high" for c, sv, _ in f)
if not has_resp:
print("\nRequest " + ("incomplete: fix before sending." if req_bad else "ready to send."))
return 1 if req_bad else 0
high = any(sv == "high" for c, sv, _ in f if c.startswith("SR1"))
med = any(sv == "medium" for c, sv, _ in f if c.startswith("SR1"))
verdict = "REJECT" if high else "ACCEPT WITH COMMENTS" if med else "ACCEPT"
print(f"\nSupplier response: {verdict}")
return 1 if high or req_bad 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.