# Engineering (QC/tolerance) sample pack — teach-surface only

This pack is a **teach-surface** exercise for the demo bundle's
self-teaching skill creator (`ai_node/skill_birth/`, the vendored S053
topic-agnostic skill-birth engine — see
`experiments/cpa_reconcile_demo/apostol-reconcile-demo.zip`,
`ai_node/GUIDE.md` "Teach it a new skill"). It does **not** map QC
measurements onto the bundle's reconcile / duplicate-detection / anomaly
tools — those are money-shaped instruments proven for cash-basis
bookkeeping; faking a fit onto dimensional-inspection data would
misrepresent both what the tools do and what this pack demonstrates. What
this pack actually proves: the engine's classify-by-threshold shape is
topic-agnostic, and it correctly refuses to invent a tolerance rule your
examples do not determine.

## Record shape

One part measurement is a flat JSON object, arity 5, all lengths in
**integer micrometers (µm)** — no float touches a measurement:

| field           | type    | meaning                                                   |
|------------------|---------|------------------------------------------------------------|
| `deviation_um`   | integer | \|measured_um − nominal_um\|, precomputed and non-negative |
| `machine_id`     | string  | which machine took the measurement                         |
| `measured_um`    | integer | measured dimension, micrometers                            |
| `nominal_um`     | integer | design/nominal dimension, micrometers                      |
| `part_id`        | string  | synthetic part identifier                                  |

`sample_records.json` in this directory holds 12 such records, illustrating
the shape a real QC feed would produce. `teach_families/*.json` holds the
worked-example families actually fed to the engine (see `RESULTS.md` for
the live runs):

- `qc_tolerance_adopt.json` / `qc_tolerance_refuse.json` — deviation
  threshold ADOPT/REFUSE pair (original).
- `qc_tolerance_no_abs_probe.json` — witnessed evidence that the algebra
  has no `abs()` (reach_limit refusal on raw nominal/measured fields).
- `we_rule1_adopt.json` — Western Electric Rule 1 mirror over the
  control-chart record below: `abs_z_x10 >= 30` (|z| ≥ 3.0, the 3σ limit)
  → `out_of_control`.
- `we_rule4_adopt.json` — Western Electric Rule 4 mirror over the run
  record below: `consecutive_same_side >= 8` → `flag_run`.

### Control-chart point record (WE-Rule-1 family), arity 4

| field         | type    | meaning                                             |
|----------------|---------|------------------------------------------------------|
| `abs_z_x10`    | integer | precomputed one-sided z-score ×10 (30 = \|z\| 3.0)   |
| `chart_id`     | string  | which control chart the point belongs to             |
| `point_seq`    | integer | position of the point in the chart sequence          |
| `subgroup_n`   | integer | subgroup sample size                                 |

### Centerline-run record (WE-Rule-4 family), arity 3

| field                   | type    | meaning                                        |
|--------------------------|---------|-------------------------------------------------|
| `consecutive_same_side`  | integer | precomputed count of consecutive points on the same side of the centerline |
| `machine_id`             | string  | which machine produced the run                  |
| `point_seq`              | integer | position of the latest point in the sequence    |

## The WINDOWED-STATISTIC → FIELD pattern

The Western Electric rules are *sequence* rules — "any single point outside
3σ," "eight consecutive points on the same side of the centerline." The
S053 engine's algebra classifies single records; it has no windowing, no
running state, and no `abs()`. The general move that makes every such rule
teachable anyway: **precompute the windowed statistic upstream and hand the
engine a record that carries it as a plain integer field.** The z-score ×10
becomes `abs_z_x10`; the run length becomes `consecutive_same_side`; the
signed deviation becomes `deviation_um`. The engine then learns the
threshold over that field exactly as it learns any other classify family —
and its refusal semantics (underdetermined / reach_limit) still hold. This
is the same move as `deviation_um` below, stated as the pattern it is: any
sequence/window rule whose trigger is "statistic crosses a threshold" is
one precomputed field away from the engine's teach surface. What the
pattern does NOT do: the engine never verifies that the upstream statistic
was computed correctly — that computation lives outside the taught rule's
guarantee and must be witnessed by whoever owns the feed.

`deviation_um` is precomputed rather than left as a raw signed difference
because the engine's operator algebra (10 generic operators, documented in
`ai_node/skill_birth/skill_birth.py`) has no `abs()` — a family that needs
one correctly REFUSEs with `reach_limit` (a feature, not a coverage gap: the
oracle names precisely the missing operation). Precomputing a one-sided
deviation field is the general fix — it belongs to the whole class of
"needs an absolute value" families, not to this one fixture.

Field naming is not decorative here either: `deviation_um` is deliberately
the alphabetically-first key, and `machine_id` (a string) is deliberately
second. The engine's adversarial-mutation stage perturbs only the first two
keys in sorted order; a threshold rule keyed on any other field, or a rule
whose second-alphabetical neighbor is itself numeric, gets exposed to a
mutated record the wire-only checker cannot recognize and is eliminated.
This ordering is what makes the ADOPT run below land at all — see the
iteration history in `RESULTS.md`.

## Honest scope

A rule this engine adopts is a decision aid learned from the worked
examples **you** labeled — nothing more. It is not an engineering standard,
not a certified tolerance spec, and it carries no metrological authority.
Concretely:

- The ADOPT family below teaches the engine one threshold on
  `deviation_um` because eight worked examples I labeled bracket that
  threshold exactly (after two authoring iterations — see `RESULTS.md`). No
  engineering standards body reviewed these labels; I wrote them to
  demonstrate the mechanism. A real QC gate built on this shape would need
  the tolerance band set by the actual part drawing/spec, not by an
  8-example synthetic fixture.
- The REFUSE family below is the other half of the honest claim: when the
  worked examples leave a gap in `deviation_um`, the engine does not guess
  a plausible-looking cutoff. It names the exact input that would settle
  the question — the constructive-refusal property this pack exists to
  demonstrate.
- The WE-Rule families mirror the *structure* of Western Electric Rules 1
  and 4 (see the evidence appendix). Mirroring the structure is the whole
  claim: the taught rules are NOT the 1956 SQC Handbook, NOT a certified
  SPC implementation, and their labels are mine, written to demonstrate
  that the real rules' threshold shape is teachable. A deployment would
  take its control limits from the actual process capability study, not
  from an 8-example synthetic fixture.
- Scope boundary, stated plainly: this pack shows that a threshold-shaped
  rule over five-field synthetic micrometer records can be taught and
  verified through the bundle's real S053 engine, and that the engine
  refuses cleanly when an operator it needs (`abs()`) is outside its
  algebra unless the field is precomputed. It does not show, and does not
  claim, that the engine is fit for real dimensional-inspection sign-off or
  any other engineering-standards decision.

## EVIDENCE APPENDIX — real-world rules the teach surface mirrors

Each quote below is verbatim from the cited source, with an evidence grade.
The framing claim these support: the WE-Rule families mirror threshold
rules engineers actually run on control charts, and the tolerance framing
(Cpk tiers, cost-of-poor-quality, FAI record structure) is the industrial
context the record shapes are drawn from.

1. **Western Electric Rule 1** (the `we_rule1_adopt.json` mirror):
   > "Any single data point falls outside the 3σ-limit..."
   Source URL: https://en.wikipedia.org/wiki/Western_Electric_rules
   Grade: tertiary (Wikipedia), restating the 1956 Western Electric
   Statistical Quality Control Handbook; the primary handbook text was not
   consulted this session.

2. **Western Electric Rule 4** (the `we_rule4_adopt.json` mirror):
   > "Eight consecutive points fall on the same side of the centerline..."
   Source URL: https://en.wikipedia.org/wiki/Western_Electric_rules
   Grade: tertiary (Wikipedia), same caveat as above.

3. **Cpk two-tier acceptance practice**:
   > "Cpk ≥ 1.33... general... Cpk ≥ 1.67" (safety-critical)
   Grade: industry-blog consensus repeated across multiple quality-
   engineering sites; NOT verified against the AIAG PPAP/SPC manual text
   this session — treat as practice folklore until checked against the
   primary manual.

4. **Cost of poor quality**:
   > "5-30 percent of gross sales"
   Source: Quality Digest, 2004.
   Grade: dated trade-press figure, not peer-reviewed, cited for scale of
   the problem only.

5. **AS9102 First Article Inspection** — the aerospace FAI standard's
   3-form structure (Form 1 part accountability, Form 2 product
   accountability, Form 3 characteristic accountability) is the record-
   keeping context the per-characteristic measurement record in this pack
   loosely reflects.
   Grade: standard's structure is public knowledge; the SAE text itself is
   paywalled and was not quoted.

Honest gaps, stated verbatim rather than papered over: no publicly
fetchable time-on-inspection percentage was found this session, and no
practitioner forum quotes were reachable this session — this appendix says
so rather than inventing them.
