Internal Quality Audit Program (manufacturing-quality/as9100/internal-quality-audit)
Use when the task is planning and scoring an internal quality audit
program under an AS9100-style quality management system: scheduling
audits by process risk, checking auditor independence and competence
for the assigned scope, sampling records, categorizing findings, and
verifying closure of corrective action responses. This leaf implements
the audit program mechanics in pure Python, stdlib only, with no
randomness. It pairs with manufacturing-quality/as9100/quality, which
maps audit focus areas to AS9100 clauses and shapes the auditor
evidence plan, and with manufacturing-quality/as9100/corrective-action,
which owns the corrective action response record. AS9100 is referenced,
not reproduced; the model below is the leaf audit program methodology.
Domain quick reference
- Audit interval: base_interval_months (12.0 default) times the risk
multiplier, RISK_MULTIPLIERS = {low: 1.5, medium: 1.0, high: 0.5}.
High risk processes are audited more often, so the interval is
shorter. The due date is the last audit date plus that span in
calendar months with the day clamped to the target month end, so a
high risk audit 6 months after 2026-03-15 is due 2026-09-15.
- Auditor independence: the auditor must not be the area owner, and no
conflict may be declared for the assignment.
- Auditor competence: every required area must appear in the auditor
qualification list (case insensitive substring match).
- Record sampling: n = ceil(sqrt(lot_size) * factor), factor 1.0 at
0.95 confidence, 1.2 at 0.99, 0.8 at 0.90, interpolated between the
anchors, at least 1 record.
- Finding ladder: impact severity 4-5 or containment required gives a
major nonconformity; severity 2-3 gives minor, and systemic spread
escalates minor to major; severity 1 is an opportunity for
improvement.
- Closure verdict: the corrective action response closes the finding
only when the corrective action taken, the root cause statement and
the effectiveness check are all present.
- Confidence bounds: lot sizes below 1, confidence outside [0.5,
0.999] and severity outside 1-5 are rejected with ValueError.
Workflow
- Schedule the audit: audit_due_date(last_audit_date_iso,
risk_category, base_interval_months) returns the due date ISO
string, with the risk multiplier shortening high risk intervals.
- Check the assignment: auditor_independent(auditor_name,
area_owner_name, independence_ok) returns {independent, reason}.
- Check the qualifications: auditor_competent(qualifications,
audit_scope_areas, required_areas) is True when every required area
is covered by the qualification list.
- Size the sample: audit_sample_size(lot_size, confidence_level)
returns the number of records to pull from the lot.
- Categorize each finding: classify_finding(impact_severity,
containment_required, systemic) returns major, minor or ofi.
- Verify the response: verify_closure(corrective_action_taken,
root_cause_stated, effectiveness_check) gates the finding closed.
- Chain the whole review: internal_audit_review(...) returns the
schedule, interval, independence and competence verdicts, sample
size, finding category and closure verdict in one dict.
- Confirm the deterministic checks with the contract test
scripts/test_internal_quality_audit.py.
Worked example
Last audit 2026-03-15 on a high risk process (multiplier 0.5 gives a
6 month interval), 400 records at 95% confidence, auditor A. Chen
against area owner B. Lopez, required areas [calibration, corrective
action] with matching qualifications, impact severity 3 with
containment required and no systemic spread. Running the module prints:
- due_date "2026-09-15" (6.0 calendar months, the about-2026-09-15
bound holds).
- interval_months 6.0.
- auditor_independent True (auditor differs from the owner, no
conflict).
- auditor_competent True (both required areas are qualified).
- sample_size 20 (ceil(sqrt(400)) = 20 at 0.95, inside the 15-25
bound).
- finding_classification "major" (containment required escalates).
- closure_verified True (all three response elements are set).
Verification
- audit_due_date clamps month ends: 2026-01-31 plus 1 month gives
2026-02-28, and 2024-01-31 gives 2024-02-29 in the leap year.
- Malformed dates, unknown risk categories, empty required area lists,
lot sizes below 1, confidence outside [0.5, 0.999] and impact
severity outside 1-5 all raise ValueError.
- auditor_independent is False when the auditor name matches the owner
name (case insensitive) or when a conflict is declared.
- audit_sample_size(400) is 20 at 0.95, 24 at 0.99 and 16 at 0.90.
- classify_finding: severity 5 or containment required gives major;
severity 2-3 systemic gives major; severity 2-3 alone gives minor;
severity 1 gives ofi.
- verify_closure is False when any of the three elements is missing.
- Determinism: no RNG anywhere, run-to-run identical output.
- Run the contract test offline: python3
scripts/test_internal_quality_audit.py (30 tests, deterministic).
Related leaves
- manufacturing-quality/as9100/quality: maps audit focus areas to
AS9100 clauses and shapes the evidence plan for each focus area.
- manufacturing-quality/as9100/corrective-action: owns the corrective
action response record that this leaf gates on closure.
- manufacturing-quality/as9100/calibration-control: the calibration
records an audit may sample.
- manufacturing-quality/as9100/nonconformance-control: disposition of
product records an audit finds nonconforming.
- manufacturing-quality/as9100/supplier-control: external provider
audits belong to supplier control, not to this internal audit leaf.
Pitfalls
- Assigning the area owner as the auditor: independence fails when the
auditor name matches the owner name (case insensitive) or when any
conflict is declared, whatever the competence record says.
- Scheduling from the base interval alone: the risk multiplier shortens
the interval (high risk 0.5, medium 1.0, low 1.5), and the due date
clamps to the target month end - 2026-01-31 plus 1 month is
2026-02-28 (2024-02-29 in the leap year), not March.
- Sizing the sample with sqrt(lot) at every confidence level: the
factor is interpolated between the anchors (0.8 at 0.90, 1.0 at
0.95, 1.2 at 0.99), so 400 records sample 20, 16 or 24 records
depending on the confidence stated.
- Scoring severity without the escalators: containment required makes
any finding major, systemic spread escalates a minor (severity 2-3)
to major, and severity 1 is an opportunity for improvement - not a
minor finding.
- Closing a finding on the response's existence alone: closure requires
the corrective action taken, the root cause statement and the
effectiveness check all present; any missing element leaves the
finding open.
- Ignoring the audit program's determinism: this leaf uses no
randomness anywhere, so any run-to-run variation in schedule, sample
size or verdict is a caller bug, not audit sampling noise - and
malformed dates, unknown risk categories, lot sizes below 1,
confidence outside [0.5, 0.999] and severity outside 1-5 are all
rejected with ValueError.
Behavior contract (gate 3)
Run the deterministic contract test (stdlib unittest, offline):
python3 scripts/test_internal_quality_audit.py
The test covers risk-based scheduling with month end clamping, the
independence rule including declared conflicts, competence against the
required areas, the sample size formula at the confidence anchors,
the finding ladder with systemic and containment escalation, closure
verification, the worked example outputs inside the spec magnitude
bounds, exact result keys, ValueError rejection of every non-physical
input, and run-to-run determinism.
Compliance
- Standards referenced, not reproduced: AS9100 is a commercial SAE
standard; the audit program equations above are the leaf audit
program methodology, summary-only per standards-map.yaml.
- compliance: STANDARDS-REF, gated: false.
1---2name: internal-quality-audit3description: Use when you must plan and score an internal quality audit program under an AS9100-style quality management system: compute the audit due date from the last audit date, the base interval and the process risk category, check auditor independence and competence for the assigned audit scope, size the record sample from the lot size and confidence level, and categorize an audit finding by impact severity, containment need and systemic spread. Produces the audit schedule, the auditor assignment verdict, the sample size, the finding classification, and the closure verdict that gate an internal audit program. Trigger: internal-quality-audit, audit-schedule, auditor-independence, audit-sample-size, finding-classification, closure-verification.4license: Apache-2.05---67# Internal Quality Audit Program (manufacturing-quality/as9100/internal-quality-audit)89Use when the task is planning and scoring an internal quality audit10program under an AS9100-style quality management system: scheduling11audits by process risk, checking auditor independence and competence12for the assigned scope, sampling records, categorizing findings, and13verifying closure of corrective action responses. This leaf implements14the audit program mechanics in pure Python, stdlib only, with no15randomness. It pairs with manufacturing-quality/as9100/quality, which16maps audit focus areas to AS9100 clauses and shapes the auditor17evidence plan, and with manufacturing-quality/as9100/corrective-action,18which owns the corrective action response record. AS9100 is referenced,19not reproduced; the model below is the leaf audit program methodology.2021## Domain quick reference2223- Audit interval: base_interval_months (12.0 default) times the risk24 multiplier, RISK_MULTIPLIERS = {low: 1.5, medium: 1.0, high: 0.5}.25 High risk processes are audited more often, so the interval is26 shorter. The due date is the last audit date plus that span in27 calendar months with the day clamped to the target month end, so a28 high risk audit 6 months after 2026-03-15 is due 2026-09-15.29- Auditor independence: the auditor must not be the area owner, and no30 conflict may be declared for the assignment.31- Auditor competence: every required area must appear in the auditor32 qualification list (case insensitive substring match).33- Record sampling: n = ceil(sqrt(lot_size) * factor), factor 1.0 at34 0.95 confidence, 1.2 at 0.99, 0.8 at 0.90, interpolated between the35 anchors, at least 1 record.36- Finding ladder: impact severity 4-5 or containment required gives a37 major nonconformity; severity 2-3 gives minor, and systemic spread38 escalates minor to major; severity 1 is an opportunity for39 improvement.40- Closure verdict: the corrective action response closes the finding41 only when the corrective action taken, the root cause statement and42 the effectiveness check are all present.43- Confidence bounds: lot sizes below 1, confidence outside [0.5,44 0.999] and severity outside 1-5 are rejected with ValueError.4546## Workflow47481. Schedule the audit: audit_due_date(last_audit_date_iso,49 risk_category, base_interval_months) returns the due date ISO50 string, with the risk multiplier shortening high risk intervals.512. Check the assignment: auditor_independent(auditor_name,52 area_owner_name, independence_ok) returns {independent, reason}.533. Check the qualifications: auditor_competent(qualifications,54 audit_scope_areas, required_areas) is True when every required area55 is covered by the qualification list.564. Size the sample: audit_sample_size(lot_size, confidence_level)57 returns the number of records to pull from the lot.585. Categorize each finding: classify_finding(impact_severity,59 containment_required, systemic) returns major, minor or ofi.606. Verify the response: verify_closure(corrective_action_taken,61 root_cause_stated, effectiveness_check) gates the finding closed.627. Chain the whole review: internal_audit_review(...) returns the63 schedule, interval, independence and competence verdicts, sample64 size, finding category and closure verdict in one dict.658. Confirm the deterministic checks with the contract test66 scripts/test_internal_quality_audit.py.6768## Worked example6970Last audit 2026-03-15 on a high risk process (multiplier 0.5 gives a716 month interval), 400 records at 95% confidence, auditor A. Chen72against area owner B. Lopez, required areas [calibration, corrective73action] with matching qualifications, impact severity 3 with74containment required and no systemic spread. Running the module prints:7576- due_date "2026-09-15" (6.0 calendar months, the about-2026-09-1577 bound holds).78- interval_months 6.0.79- auditor_independent True (auditor differs from the owner, no80 conflict).81- auditor_competent True (both required areas are qualified).82- sample_size 20 (ceil(sqrt(400)) = 20 at 0.95, inside the 15-2583 bound).84- finding_classification "major" (containment required escalates).85- closure_verified True (all three response elements are set).8687## Verification8889- audit_due_date clamps month ends: 2026-01-31 plus 1 month gives90 2026-02-28, and 2024-01-31 gives 2024-02-29 in the leap year.91- Malformed dates, unknown risk categories, empty required area lists,92 lot sizes below 1, confidence outside [0.5, 0.999] and impact93 severity outside 1-5 all raise ValueError.94- auditor_independent is False when the auditor name matches the owner95 name (case insensitive) or when a conflict is declared.96- audit_sample_size(400) is 20 at 0.95, 24 at 0.99 and 16 at 0.90.97- classify_finding: severity 5 or containment required gives major;98 severity 2-3 systemic gives major; severity 2-3 alone gives minor;99 severity 1 gives ofi.100- verify_closure is False when any of the three elements is missing.101- Determinism: no RNG anywhere, run-to-run identical output.102- Run the contract test offline: python3103 scripts/test_internal_quality_audit.py (30 tests, deterministic).104105## Related leaves106107- manufacturing-quality/as9100/quality: maps audit focus areas to108 AS9100 clauses and shapes the evidence plan for each focus area.109- manufacturing-quality/as9100/corrective-action: owns the corrective110 action response record that this leaf gates on closure.111- manufacturing-quality/as9100/calibration-control: the calibration112 records an audit may sample.113- manufacturing-quality/as9100/nonconformance-control: disposition of114 product records an audit finds nonconforming.115- manufacturing-quality/as9100/supplier-control: external provider116 audits belong to supplier control, not to this internal audit leaf.117118## Pitfalls119120- Assigning the area owner as the auditor: independence fails when the121 auditor name matches the owner name (case insensitive) or when any122 conflict is declared, whatever the competence record says.123- Scheduling from the base interval alone: the risk multiplier shortens124 the interval (high risk 0.5, medium 1.0, low 1.5), and the due date125 clamps to the target month end - 2026-01-31 plus 1 month is126 2026-02-28 (2024-02-29 in the leap year), not March.127- Sizing the sample with sqrt(lot) at every confidence level: the128 factor is interpolated between the anchors (0.8 at 0.90, 1.0 at129 0.95, 1.2 at 0.99), so 400 records sample 20, 16 or 24 records130 depending on the confidence stated.131- Scoring severity without the escalators: containment required makes132 any finding major, systemic spread escalates a minor (severity 2-3)133 to major, and severity 1 is an opportunity for improvement - not a134 minor finding.135- Closing a finding on the response's existence alone: closure requires136 the corrective action taken, the root cause statement and the137 effectiveness check all present; any missing element leaves the138 finding open.139- Ignoring the audit program's determinism: this leaf uses no140 randomness anywhere, so any run-to-run variation in schedule, sample141 size or verdict is a caller bug, not audit sampling noise - and142 malformed dates, unknown risk categories, lot sizes below 1,143 confidence outside [0.5, 0.999] and severity outside 1-5 are all144 rejected with ValueError.145146## Behavior contract (gate 3)147148Run the deterministic contract test (stdlib unittest, offline):149150 python3 scripts/test_internal_quality_audit.py151152The test covers risk-based scheduling with month end clamping, the153independence rule including declared conflicts, competence against the154required areas, the sample size formula at the confidence anchors,155the finding ladder with systemic and containment escalation, closure156verification, the worked example outputs inside the spec magnitude157bounds, exact result keys, ValueError rejection of every non-physical158input, and run-to-run determinism.159160## Compliance161162- Standards referenced, not reproduced: AS9100 is a commercial SAE163 standard; the audit program equations above are the leaf audit164 program methodology, summary-only per standards-map.yaml.165- compliance: STANDARDS-REF, gated: false.