#!/usr/bin/env python3
"""Back-schedule the five APQP phases from start of production (SOP) and track deliverables.
Phases (AIAG APQP): 1 Plan and define, 2 Product design and development, 3 Process design and development,
4 Product and process validation, 5 Launch, feedback, assessment and corrective action.
Phase 4 ends --ppap-lead weeks before SOP (PPAP approval); phase 3 overlaps the second half of phase 2;
phase 5 starts at SOP with a --safe-launch period of early-production containment.
Durations (weeks: P1, P2, P3, P4) by complexity: low 4/8/8/6, medium 6/16/14/10, high 8/26/20/14.
Build-to-print suppliers (--no-design) shorten phase 2 to design-input review and feasibility (1/3 of the time).
Usage:
python apqp_plan.py --sop 2027-09-06 --complexity medium --today 2026-10-26
python apqp_plan.py --sop 2027-09-06 --complexity high --no-design --status deliverables.csv --today 2027-03-01
Status CSV columns: deliverable, phase (1-5), status (done/in-progress/not-started)
Exit codes: 0 schedule feasible and nothing late, 1 compressed schedule or late deliverables, 2 usage error.
"""
import argparse
import csv
import datetime as dt
import sys
DUR = {"low": (4, 8, 8, 6), "medium": (6, 16, 14, 10), "high": (8, 26, 20, 14)}
NAMES = ["Plan and define", "Product design and development", "Process design and development",
"Product and process validation", "Launch, feedback and corrective action"]
DELIVERABLES = {
1: ["Design goals", "Reliability and quality goals", "Preliminary bill of materials", "Preliminary process flow chart",
"Preliminary special characteristics", "Product assurance plan", "Management support (gate 1)"],
2: ["DFMEA", "Design for manufacturing and assembly", "Design verification plan and report (DVP&R)",
"Design reviews", "Prototype control plan", "Engineering drawings and specifications", "Material specifications",
"Team feasibility commitment", "Equipment, tooling and gauge requirements", "Special characteristics list"],
3: ["Packaging standards", "Process flow chart", "Floor plan layout", "Characteristics matrix", "PFMEA",
"Pre-launch control plan", "Process instructions", "MSA plan", "Preliminary process capability plan"],
4: ["Significant production run", "MSA evaluation", "Preliminary process capability (Ppk)", "PPAP submission and approval",
"Production validation testing", "Packaging evaluation", "Production control plan", "Quality planning sign-off"],
5: ["Safe-launch containment and exit", "Reduced variation (Cpk tracking)", "Customer satisfaction and delivery review",
"Lessons learned"],
}
def wk(d, n):
return d + dt.timedelta(weeks=n)
def schedule(sop, comp, design, ppap_lead, safe):
d1, d2, d3, d4 = DUR[comp]
if not design:
d2 = max(2, round(d2 / 3))
p4e = wk(sop, -ppap_lead)
p4s = wk(p4e, -d4)
p3e, p3s = p4s, wk(p4s, -d3)
p2s = wk(p3s, -d2 / 2) # phase 3 starts halfway through phase 2
p2e = wk(p2s, d2)
p1e, p1s = p2s, wk(p2s, -d1)
return [(1, p1s, p1e), (2, p2s, p2e), (3, p3s, p3e), (4, p4s, p4e), (5, sop, wk(sop, safe))]
def main():
ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
ap.add_argument("--sop", type=dt.date.fromisoformat, required=True, help="start of production YYYY-MM-DD")
ap.add_argument("--complexity", choices=DUR, default="medium")
ap.add_argument("--no-design", action="store_true", help="build-to-print: no product design responsibility")
ap.add_argument("--ppap-lead", type=int, default=4, help="weeks between PPAP approval and SOP (default 4)")
ap.add_argument("--safe-launch", type=int, default=13, help="weeks of early-production containment (default 13)")
ap.add_argument("--today", type=dt.date.fromisoformat, default=dt.date.today())
ap.add_argument("--status", help="deliverable status CSV")
a = ap.parse_args()
plan = schedule(a.sop, a.complexity, not a.no_design, a.ppap_lead, a.safe_launch)
rc = 0
print(f"APQP plan: SOP {a.sop}, {a.complexity} complexity" + (", build-to-print" if a.no_design else "") + "\n")
print(f"{'Phase':<44}{'Start':<12}{'End':<12}Gate")
for n, s, e in plan:
gate = {1: "Program approval", 2: "Design freeze", 3: "Process sign-off", 4: "PPAP approved", 5: "Safe-launch exit"}[n]
print(f"{n} {NAMES[n - 1]:<42}{s!s:<12}{e!s:<12}{gate}")
start = plan[0][1]
if start < a.today and not a.status: # planning a new program: is there still time?
short = (a.today - start).days / 7
print(f"\nCOMPRESSED: phase 1 should have started {start}, {short:.0f} weeks ago. Options: run phases in "
"parallel with extra resources, reuse carry-over designs/processes, negotiate SOP or a staged PPAP.")
rc = 1
if a.status:
try:
with open(a.status, newline="", encoding="utf-8-sig") as fh:
rows = list(csv.DictReader(fh))
except (OSError, csv.Error) as e:
print(f"error: {e}", file=sys.stderr)
return 2
ends = {n: e for n, _, e in plan}
late, done, total = [], 0, 0
listed = set()
for r in rows:
ph = int(r.get("phase") or 0)
st = (r.get("status") or "").strip().lower()
listed.add((r.get("deliverable") or "").strip().lower())
total += 1
done += st == "done"
if ph in ends and st != "done" and ends[ph] < a.today:
late.append(f"phase {ph} '{r['deliverable']}' is {st or 'not started'}; phase ended {ends[ph]}")
print(f"\nDeliverables: {done}/{total} done")
for msg in late:
print(f"LATE {msg}")
current = [n for n, s, e in plan if s <= a.today <= e]
for n in current:
missing = [d for d in DELIVERABLES[n] if d.lower() not in listed]
if missing:
print(f"Phase {n} deliverables not tracked: {', '.join(missing)}")
rc = 1 if late or rc else 0
else:
print("\nDeliverables by phase:")
for n in range(1, 6):
print(f" {n}: " + "; ".join(DELIVERABLES[n]))
return rc
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.
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.
capa-effectiveness-checker
Verify whether a corrective action actually worked (ISO 9001 10.2.1 d, IATF 16949, 8D D6) with statistics instead of 'no complaints so far': before/after defect-rate comparison with an exact conditional binomial test for Poisson counts and a minimum practical reduction, zero-defect demonstration size (n = ln(1-C)/ln(1-p), rule of three) with progress so far, and exact Clopper-Pearson upper bounds on the post-action defect rate. Returns effective, not yet demonstrated (with the units still needed) or not effective. Covers setting effectiveness criteria when the CAPA is opened, choosing the window by problem frequency, leading indicators for rare failures (Cpk, SPC stability, error-proofing checks, LPA), and traps such as volume changes, detection changes and containment masking.