#!/usr/bin/env python3
"""Build an Ishikawa (fishbone) diagram from a cause list, check it, and list what to verify next.
CSV columns: category, cause, subcause (optional), status (untested/likely/verified/ruled-out), evidence
Categories are normalised to the 6M: Man, Machine, Method, Material, Measurement, Environment
(aliases: people/personnel -> Man, equipment/tooling -> Machine, process/procedure -> Method,
materials/supplier -> Material, inspection/gauge -> Measurement, mother nature/surroundings -> Environment).
Other category names are kept as extra bones (e.g. Management, Software for services).
Checks:
FB001 medium a 6M bone is empty - brainstorm it before concluding
FB002 medium a 'cause' is a solution ('need', 'should', 'install', 'buy') - restate it as the condition
FB003 medium a cause blames a person - restate it as the process condition
FB004 low duplicate cause on several bones
FB005 low nothing is marked likely or verified yet - vote or test the top candidates
Usage:
python fishbone.py causes.csv --problem "Scratches on HS-110 face A"
python fishbone.py causes.csv --problem "..." --format mermaid > fishbone.mmd
Exit codes: 0 diagram printed (no medium findings), 1 medium findings, 2 read error.
"""
import argparse
import csv
import re
import sys
from collections import OrderedDict
SIX_M = ["Man", "Machine", "Method", "Material", "Measurement", "Environment"]
ALIASES = {"people": "Man", "personnel": "Man", "manpower": "Man", "operator": "Man", "equipment": "Machine",
"machines": "Machine", "tooling": "Machine", "process": "Method", "methods": "Method", "procedure": "Method",
"materials": "Material", "supplier": "Material", "measurements": "Measurement", "inspection": "Measurement",
"gauge": "Measurement", "environment": "Environment", "mother nature": "Environment", "surroundings": "Environment"}
SOLUTION = re.compile(r"^\s*(need|needs|should|must|install|buy|add|implement|use a|get a)\b|\bshould\b", re.I)
BLAME = re.compile(r"\b(careless|lazy|forgot|operator error|human error|not paying attention|bad attitude)\b", re.I)
MARK = {"verified": "[V]", "likely": "[L]", "ruled-out": "[x]", "untested": "[ ]", "": "[ ]"}
def norm(cat):
c = cat.strip()
if c.title() in SIX_M:
return c.title()
return ALIASES.get(c.lower(), c.strip().title() or "Other")
def main():
ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
ap.add_argument("csv", help="cause list CSV, or - for stdin")
ap.add_argument("--problem", default="Problem", help="effect at the fish head")
ap.add_argument("--format", choices=["text", "mermaid"], default="text")
a = ap.parse_args()
try:
fh = sys.stdin if a.csv == "-" else open(a.csv, newline="", encoding="utf-8-sig")
with fh:
rows = list(csv.DictReader(fh))
except (OSError, csv.Error) as e:
print(f"error: {e}", file=sys.stderr)
return 2
if not rows or not {"category", "cause"} <= set(rows[0]):
print("error: CSV needs category and cause columns", file=sys.stderr)
return 2
bones = OrderedDict((m, OrderedDict()) for m in SIX_M)
findings, seen = [], {}
for r in rows:
cat, cause = norm(r["category"]), (r["cause"] or "").strip()
if not cause:
continue
status = (r.get("status") or "").strip().lower()
node = bones.setdefault(cat, OrderedDict()).setdefault(cause, {"status": status, "subs": [], "evidence": r.get("evidence", "")})
if r.get("subcause", "").strip():
node["subs"].append(r["subcause"].strip())
if status in ("verified", "likely"):
node["status"] = status
key = cause.lower()
if key in seen and seen[key] != cat:
findings.append(("FB004", "low", f"'{cause}' appears on {seen[key]} and {cat}: keep it on one bone"))
seen.setdefault(key, cat)
if SOLUTION.search(cause):
findings.append(("FB002", "medium", f"{cat}: '{cause}' is a solution; write the condition it would fix"))
if BLAME.search(cause):
findings.append(("FB003", "medium", f"{cat}: '{cause}' blames a person; describe the process condition"))
for m in SIX_M:
if not bones[m]:
findings.append(("FB001", "medium", f"{m} bone is empty: brainstorm it (see 6m-prompts.md)"))
candidates = [(c, cat, n) for cat, causes in bones.items() for c, n in causes.items() if n["status"] in ("likely", "verified")]
if not candidates:
findings.append(("FB005", "low", "no cause marked likely or verified: multi-vote, then test the top 3"))
if a.format == "mermaid":
print("flowchart LR")
print(f' head["{a.problem}"]')
for i, (cat, causes) in enumerate(bones.items()):
if not causes:
continue
print(f' b{i}["{cat}"] --> head')
for j, (c, n) in enumerate(causes.items()):
print(f' c{i}_{j}["{MARK.get(n["status"], "[ ]")} {c}"] --> b{i}')
for k, s in enumerate(n["subs"]):
print(f' s{i}_{j}_{k}["{s}"] --> c{i}_{j}')
else:
print(f"EFFECT: {a.problem}\n")
for cat, causes in bones.items():
print(f"{cat}")
if not causes:
print(" (empty)")
for c, n in causes.items():
print(f" {MARK.get(n['status'], '[ ]')} {c}")
for s in n["subs"]:
print(f" - {s}")
print("\nKey: [V] verified [L] likely [x] ruled out [ ] untested")
if candidates:
print("\nVerify next (likely causes) / root causes (verified):")
for c, cat, n in sorted(candidates, key=lambda x: x[2]["status"] != "verified"):
print(f" {MARK[n['status']]} {cat}: {c}" + (f" - {n['evidence']}" if n["evidence"] else ""))
out = sys.stderr if a.format == "mermaid" else sys.stdout
if findings:
print(file=out)
for code, sev, msg in findings:
print(f"{code} [{sev}] {msg}", file=out)
return 1 if any(x[1] == "medium" for x in findings) 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.